diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..3899c241c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "web/api/app/Plugin/Crud"] + path = web/api/app/Plugin/Crud + url = https://github.com/FriendsOfCake/crud.git diff --git a/web/api/CMakeFiles/CMakeDirectoryInformation.cmake b/web/api/CMakeFiles/CMakeDirectoryInformation.cmake new file mode 100644 index 000000000..3d1e4eadd --- /dev/null +++ b/web/api/CMakeFiles/CMakeDirectoryInformation.cmake @@ -0,0 +1,16 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +# Relative path conversion top directories. +SET(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/ubuntu/zm/ZoneMinder") +SET(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/ubuntu/zm/ZoneMinder") + +# Force unix paths in dependencies. +SET(CMAKE_FORCE_UNIX_PATHS 1) + + +# The C and CXX include file regular expressions for this directory. +SET(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") +SET(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") +SET(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) +SET(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) diff --git a/web/api/CMakeFiles/progress.marks b/web/api/CMakeFiles/progress.marks new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/web/api/CMakeFiles/progress.marks @@ -0,0 +1 @@ +0 diff --git a/web/api/app/Config/bootstrap.php b/web/api/app/Config/bootstrap.php index b8932f3a6..e4102d62b 100644 --- a/web/api/app/Config/bootstrap.php +++ b/web/api/app/Config/bootstrap.php @@ -69,6 +69,7 @@ Cache::config('default', array('engine' => 'File')); * CakePlugin::load('DebugKit'); //Loads a single plugin named DebugKit * */ +CakePlugin::load('Crud'); /** * You can attach event listeners to the request lifecycle as Dispatcher Filter. By default CakePHP bundles two filters: diff --git a/web/api/app/Config/core.php b/web/api/app/Config/core.php new file mode 100644 index 000000000..1e1b11bc7 --- /dev/null +++ b/web/api/app/Config/core.php @@ -0,0 +1,387 @@ + 0 + * and log errors with CakeLog when debug = 0. + * + * Options: + * + * - `handler` - callback - The callback to handle errors. You can set this to any callable type, + * including anonymous functions. + * Make sure you add App::uses('MyHandler', 'Error'); when using a custom handler class + * - `level` - integer - The level of errors you are interested in capturing. + * - `trace` - boolean - Include stack traces for errors in log files. + * + * @see ErrorHandler for more information on error handling and configuration. + */ + Configure::write('Error', array( + 'handler' => 'ErrorHandler::handleError', + 'level' => E_ALL & ~E_DEPRECATED, + 'trace' => true + )); + +/** + * Configure the Exception handler used for uncaught exceptions. By default, + * ErrorHandler::handleException() is used. It will display a HTML page for the exception, and + * while debug > 0, framework errors like Missing Controller will be displayed. When debug = 0, + * framework errors will be coerced into generic HTTP errors. + * + * Options: + * + * - `handler` - callback - The callback to handle exceptions. You can set this to any callback type, + * including anonymous functions. + * Make sure you add App::uses('MyHandler', 'Error'); when using a custom handler class + * - `renderer` - string - The class responsible for rendering uncaught exceptions. If you choose a custom class you + * should place the file for that class in app/Lib/Error. This class needs to implement a render method. + * - `log` - boolean - Should Exceptions be logged? + * - `skipLog` - array - list of exceptions to skip for logging. Exceptions that + * extend one of the listed exceptions will also be skipped for logging. + * Example: `'skipLog' => array('NotFoundException', 'UnauthorizedException')` + * + * @see ErrorHandler for more information on exception handling and configuration. + */ + Configure::write('Exception', array( + 'handler' => 'ErrorHandler::handleException', + 'renderer' => 'ExceptionRenderer', + 'log' => true + )); + +/** + * Application wide charset encoding + */ + Configure::write('App.encoding', 'UTF-8'); + +/** + * To configure CakePHP *not* to use mod_rewrite and to + * use CakePHP pretty URLs, remove these .htaccess + * files: + * + * /.htaccess + * /app/.htaccess + * /app/webroot/.htaccess + * + * And uncomment the App.baseUrl below. But keep in mind + * that plugin assets such as images, CSS and JavaScript files + * will not work without URL rewriting! + * To work around this issue you should either symlink or copy + * the plugin assets into you app's webroot directory. This is + * recommended even when you are using mod_rewrite. Handling static + * assets through the Dispatcher is incredibly inefficient and + * included primarily as a development convenience - and + * thus not recommended for production applications. + */ + //Configure::write('App.baseUrl', env('SCRIPT_NAME')); + +/** + * To configure CakePHP to use a particular domain URL + * for any URL generation inside the application, set the following + * configuration variable to the http(s) address to your domain. This + * will override the automatic detection of full base URL and can be + * useful when generating links from the CLI (e.g. sending emails) + */ + //Configure::write('App.fullBaseUrl', 'http://example.com'); + +/** + * Web path to the public images directory under webroot. + * If not set defaults to 'img/' + */ + //Configure::write('App.imageBaseUrl', 'img/'); + +/** + * Web path to the CSS files directory under webroot. + * If not set defaults to 'css/' + */ + //Configure::write('App.cssBaseUrl', 'css/'); + +/** + * Web path to the js files directory under webroot. + * If not set defaults to 'js/' + */ + //Configure::write('App.jsBaseUrl', 'js/'); + +/** + * Uncomment the define below to use CakePHP prefix routes. + * + * The value of the define determines the names of the routes + * and their associated controller actions: + * + * Set to an array of prefixes you want to use in your application. Use for + * admin or other prefixed routes. + * + * Routing.prefixes = array('admin', 'manager'); + * + * Enables: + * `admin_index()` and `/admin/controller/index` + * `manager_index()` and `/manager/controller/index` + * + */ + //Configure::write('Routing.prefixes', array('admin')); + +/** + * Turn off all caching application-wide. + * + */ + //Configure::write('Cache.disable', true); + +/** + * Enable cache checking. + * + * If set to true, for view caching you must still use the controller + * public $cacheAction inside your controllers to define caching settings. + * You can either set it controller-wide by setting public $cacheAction = true, + * or in each action using $this->cacheAction = true. + * + */ + //Configure::write('Cache.check', true); + +/** + * Enable cache view prefixes. + * + * If set it will be prepended to the cache name for view file caching. This is + * helpful if you deploy the same application via multiple subdomains and languages, + * for instance. Each version can then have its own view cache namespace. + * Note: The final cache file name will then be `prefix_cachefilename`. + */ + //Configure::write('Cache.viewPrefix', 'prefix'); + +/** + * Session configuration. + * + * Contains an array of settings to use for session configuration. The defaults key is + * used to define a default preset to use for sessions, any settings declared here will override + * the settings of the default config. + * + * ## Options + * + * - `Session.cookie` - The name of the cookie to use. Defaults to 'CAKEPHP' + * - `Session.timeout` - The number of minutes you want sessions to live for. This timeout is handled by CakePHP + * - `Session.cookieTimeout` - The number of minutes you want session cookies to live for. + * - `Session.checkAgent` - Do you want the user agent to be checked when starting sessions? You might want to set the + * value to false, when dealing with older versions of IE, Chrome Frame or certain web-browsing devices and AJAX + * - `Session.defaults` - The default configuration set to use as a basis for your session. + * There are four builtins: php, cake, cache, database. + * - `Session.handler` - Can be used to enable a custom session handler. Expects an array of callables, + * that can be used with `session_save_handler`. Using this option will automatically add `session.save_handler` + * to the ini array. + * - `Session.autoRegenerate` - Enabling this setting, turns on automatic renewal of sessions, and + * sessionids that change frequently. See CakeSession::$requestCountdown. + * - `Session.ini` - An associative array of additional ini values to set. + * + * The built in defaults are: + * + * - 'php' - Uses settings defined in your php.ini. + * - 'cake' - Saves session files in CakePHP's /tmp directory. + * - 'database' - Uses CakePHP's database sessions. + * - 'cache' - Use the Cache class to save sessions. + * + * To define a custom session handler, save it at /app/Model/Datasource/Session/.php. + * Make sure the class implements `CakeSessionHandlerInterface` and set Session.handler to + * + * To use database sessions, run the app/Config/Schema/sessions.php schema using + * the cake shell command: cake schema create Sessions + * + */ + Configure::write('Session', array( + 'defaults' => 'php' + )); + +/** + * A random string used in security hashing methods. + */ + Configure::write('Security.salt', 'y8s4nPwjdjrmAGRxtnbxWhOknOBX6y1etr6RD8XM'); + +/** + * A random numeric string (digits only) used to encrypt/decrypt strings. + */ + Configure::write('Security.cipherSeed', '28284715058574819699789789248'); + +/** + * Apply timestamps with the last modified time to static assets (js, css, images). + * Will append a query string parameter containing the time the file was modified. This is + * useful for invalidating browser caches. + * + * Set to `true` to apply timestamps when debug > 0. Set to 'force' to always enable + * timestamping regardless of debug value. + */ + //Configure::write('Asset.timestamp', true); + +/** + * Compress CSS output by removing comments, whitespace, repeating tags, etc. + * This requires a/var/cache directory to be writable by the web server for caching. + * and /vendors/csspp/csspp.php + * + * To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use HtmlHelper::css(). + */ + //Configure::write('Asset.filter.css', 'css.php'); + +/** + * Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the + * output, and setting the config below to the name of the script. + * + * To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JsHelper::link(). + */ + //Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php'); + +/** + * The class name and database used in CakePHP's + * access control lists. + */ + Configure::write('Acl.classname', 'DbAcl'); + Configure::write('Acl.database', 'default'); + +/** + * Uncomment this line and correct your server timezone to fix + * any date & time related errors. + */ + //date_default_timezone_set('UTC'); + +/** + * `Config.timezone` is available in which you can set users' timezone string. + * If a method of CakeTime class is called with $timezone parameter as null and `Config.timezone` is set, + * then the value of `Config.timezone` will be used. This feature allows you to set users' timezone just + * once instead of passing it each time in function calls. + */ + //Configure::write('Config.timezone', 'Europe/Paris'); + +/** + * + * Cache Engine Configuration + * Default settings provided below + * + * File storage engine. + * + * Cache::config('default', array( + * 'engine' => 'File', //[required] + * 'duration' => 3600, //[optional] + * 'probability' => 100, //[optional] + * 'path' => CACHE, //[optional] use system tmp directory - remember to use absolute path + * 'prefix' => 'cake_', //[optional] prefix every cache file with this string + * 'lock' => false, //[optional] use file locking + * 'serialize' => true, //[optional] + * 'mask' => 0664, //[optional] + * )); + * + * APC (http://pecl.php.net/package/APC) + * + * Cache::config('default', array( + * 'engine' => 'Apc', //[required] + * 'duration' => 3600, //[optional] + * 'probability' => 100, //[optional] + * 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string + * )); + * + * Xcache (http://xcache.lighttpd.net/) + * + * Cache::config('default', array( + * 'engine' => 'Xcache', //[required] + * 'duration' => 3600, //[optional] + * 'probability' => 100, //[optional] + * 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string + * 'user' => 'user', //user from xcache.admin.user settings + * 'password' => 'password', //plaintext password (xcache.admin.pass) + * )); + * + * Memcached (http://www.danga.com/memcached/) + * + * Uses the memcached extension. See http://php.net/memcached + * + * Cache::config('default', array( + * 'engine' => 'Memcached', //[required] + * 'duration' => 3600, //[optional] + * 'probability' => 100, //[optional] + * 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string + * 'servers' => array( + * '127.0.0.1:11211' // localhost, default port 11211 + * ), //[optional] + * 'persistent' => 'my_connection', // [optional] The name of the persistent connection. + * 'compress' => false, // [optional] compress data in Memcached (slower, but uses less memory) + * )); + * + * Wincache (http://php.net/wincache) + * + * Cache::config('default', array( + * 'engine' => 'Wincache', //[required] + * 'duration' => 3600, //[optional] + * 'probability' => 100, //[optional] + * 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string + * )); + */ + +/** + * Configure the cache handlers that CakePHP will use for internal + * metadata like class maps, and model schema. + * + * By default File is used, but for improved performance you should use APC. + * + * Note: 'default' and other application caches should be configured in app/Config/bootstrap.php. + * Please check the comments in bootstrap.php for more info on the cache engines available + * and their settings. + */ +$engine = 'File'; + +// In development mode, caches should expire quickly. +$duration = '+999 days'; +if (Configure::read('debug') > 0) { + $duration = '+10 seconds'; +} + +// Prefix each application on the same server with a different string, to avoid Memcache and APC conflicts. +$prefix = 'myapp_'; + +/** + * Configure the cache used for general framework caching. Path information, + * object listings, and translation cache files are stored with this configuration. + */ +Cache::config('_cake_core_', array( + 'engine' => $engine, + 'prefix' => $prefix . 'cake_core_', + 'path' => CACHE . 'persistent' . DS, + 'serialize' => ($engine === 'File'), + 'duration' => $duration +)); + +/** + * Configure the cache for model and datasource caches. This cache configuration + * is used to store schema descriptions, and table listings in connections. + */ +Cache::config('_cake_model_', array( + 'engine' => $engine, + 'prefix' => $prefix . 'cake_model_', + 'path' => CACHE . 'models' . DS, + 'serialize' => ($engine === 'File'), + 'duration' => $duration +)); diff --git a/web/api/app/Config/routes.php b/web/api/app/Config/routes.php index ed2d1f2ca..0f9343644 100644 --- a/web/api/app/Config/routes.php +++ b/web/api/app/Config/routes.php @@ -28,6 +28,14 @@ Router::mapResources('configs'); Router::mapResources('events'); Router::mapResources('frames'); + Router::mapResources('host'); + Router::mapResources('logs'); + Router::mapResources('states'); + Router::mapResources('zonepresets'); + + /* Add new API to retrieve camera controls - for PTZ */ + /* refer to https://github.com/ZoneMinder/ZoneMinder/issues/799#issuecomment-105233112 */ + Router::mapResources('controls'); Router::parseExtensions(); /** diff --git a/web/api/app/Controller/AppController.php b/web/api/app/Controller/AppController.php index a827969e1..f3011e6ff 100644 --- a/web/api/app/Controller/AppController.php +++ b/web/api/app/Controller/AppController.php @@ -18,8 +18,8 @@ * @since CakePHP(tm) v 0.2.9 * @license http://www.opensource.org/licenses/mit-license.php MIT License */ - App::uses('Controller', 'Controller'); +App::uses('CrudControllerTrait', 'Crud.Lib'); /** * Application Controller @@ -31,4 +31,20 @@ App::uses('Controller', 'Controller'); * @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller */ class AppController extends Controller { + use CrudControllerTrait; + + public $components = [ + 'RequestHandler', + 'Crud.Crud' => [ + 'actions' => [ + 'index' => 'Crud.Index', + 'add' => 'Crud.Add', + 'edit' => 'Crud.Edit', + 'view' => 'Crud.View', + 'keyvalue' => 'Crud.List', + 'category' => 'Crud.Category' + ], + 'listeners' => ['Api', 'ApiTransformation'] + ] + ]; } diff --git a/web/api/app/Controller/Component/ConfigParserComponent.php b/web/api/app/Controller/Component/ConfigParserComponent.php index 18d06fba8..56a2039a0 100644 --- a/web/api/app/Controller/Component/ConfigParserComponent.php +++ b/web/api/app/Controller/Component/ConfigParserComponent.php @@ -24,7 +24,7 @@ class ConfigParserComponent extends Component { public function getInput($name, $type, $id) { if ($type == 'checkbox') { - $string = ''; + $string = ''; } elseif ($type == 'text') { $string = ''; } elseif ($type == 'textarea') { diff --git a/web/api/app/Controller/Component/FilterComponent.php b/web/api/app/Controller/Component/FilterComponent.php new file mode 100644 index 000000000..bf6e423f7 --- /dev/null +++ b/web/api/app/Controller/Component/FilterComponent.php @@ -0,0 +1,34 @@ + $value) { + // If the named param contains an array, we want to turn it into an IN condition + // Otherwise, we add it right into the $conditions array + if (is_array($value)) { + $array = array(); + + foreach ($value as $term) { + array_push($array, $term); + } + + $query = array($attribute => $array); + array_push($conditions, $query); + } else { + array_push($conditions, array($attribute => $value)); + } + } + + } + + return $conditions; + } + +} +?> diff --git a/web/api/app/Controller/Component/ImageComponent.php b/web/api/app/Controller/Component/ImageComponent.php new file mode 100644 index 000000000..147a26dd7 --- /dev/null +++ b/web/api/app/Controller/Component/ImageComponent.php @@ -0,0 +1,89 @@ +getEventPath($event); + + $captImage = sprintf( "%0".$config['ZM_EVENT_IMAGE_DIGITS']."d-capture.jpg", $frame['Frame']['FrameId'] ); + $captPath = $eventPath.'/'.$captImage; + $thumbCaptPath = $config['ZM_DIR_IMAGES'].'/'.$event['Event']['Id'].'-'.$captImage; + + $analImage = sprintf( "%0".$config['ZM_EVENT_IMAGE_DIGITS']."d-analyse.jpg", $frame['Frame']['FrameId'] ); + $analPath = $eventPath.'/'.$analImage; + $analFile = $config['ZM_DIR_EVENTS']."/".$analPath; + $thumbAnalPath = $config['ZM_DIR_IMAGES'].'/'.$event['Event']['Id'].'-'.$analImage; + + $alarmFrame = $frame['Frame']['Type']=='Alarm'; + + $hasAnalImage = $alarmFrame && file_exists( $analFile ) && filesize( $analFile ); + $isAnalImage = $hasAnalImage && !$captureOnly; + + + if ( !$config['ZM_WEB_SCALE_THUMBS'] || $scale >= 100 || !function_exists( 'imagecreatefromjpeg' ) ) { + $imagePath = $thumbPath = $isAnalImage?$analPath:$captPath; + $imageFile = $config['ZM_DIR_EVENTS']."/".$imagePath; + $thumbFile = $config['ZM_DIR_EVENTS']."/".$thumbPath; + } else { + if ( version_compare( phpversion(), "4.3.10", ">=") ) + $fraction = sprintf( "%.3F", $scale/100 ); + else + $fraction = sprintf( "%.3f", $scale/100 ); + $scale = (int)round( $scale ); + + $thumbCaptPath = preg_replace( "/\.jpg$/", "-$scale.jpg", $thumbCaptPath ); + $thumbAnalPath = preg_replace( "/\.jpg$/", "-$scale.jpg", $thumbAnalPath ); + + if ( $isAnalImage ) + { + $imagePath = $analPath; + $thumbPath = $thumbAnalPath; + } + else + { + $imagePath = $captPath; + $thumbPath = $thumbCaptPath; + } + + $imageFile = $config['ZM_DIR_EVENTS']."/".$imagePath; + //$thumbFile = ZM_DIR_EVENTS."/".$thumbPath; + $thumbFile = $thumbPath; + if ( $overwrite || !file_exists( $thumbFile ) || !filesize( $thumbFile ) ) + { + // Get new dimensions + list( $imageWidth, $imageHeight ) = getimagesize( $imageFile ); + $thumbWidth = $imageWidth * $fraction; + $thumbHeight = $imageHeight * $fraction; + + // Resample + $thumbImage = imagecreatetruecolor( $thumbWidth, $thumbHeight ); + $image = imagecreatefromjpeg( $imageFile ); + imagecopyresampled( $thumbImage, $image, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imageWidth, $imageHeight ); + + if ( !imagejpeg( $thumbImage, $thumbFile ) ) + Error( "Can't create thumbnail '$thumbPath'" ); + } + } + + $imageData = array( + 'eventPath' => $eventPath, + 'imagePath' => $imagePath, + 'thumbPath' => $thumbPath, + 'imageFile' => $imageFile, + 'thumbFile' => $thumbFile, + 'imageClass' => $alarmFrame?"alarm":"normal", + 'isAnalImage' => $isAnalImage, + 'hasAnalImage' => $hasAnalImage, + ); + + return( $imageData ); + + } + + // Take the StartTime of an Event and return + // the path to its location on the filesystem + public function getEventPath( $event ) { + return $event['Event']['MonitorId'].'/'.strftime( "%y/%m/%d/%H/%M/%S", strtotime($event['Event']['StartTime']) ); + } +} +?> diff --git a/web/api/app/Controller/Component/ScalerComponent.php b/web/api/app/Controller/Component/ScalerComponent.php new file mode 100644 index 000000000..30678dad6 --- /dev/null +++ b/web/api/app/Controller/Component/ScalerComponent.php @@ -0,0 +1,27 @@ + diff --git a/web/api/app/Controller/ConfigsController.php b/web/api/app/Controller/ConfigsController.php index 3198ae58e..651f5724e 100644 --- a/web/api/app/Controller/ConfigsController.php +++ b/web/api/app/Controller/ConfigsController.php @@ -14,20 +14,6 @@ class ConfigsController extends AppController { */ public $components = array('RequestHandler'); -/** - * index method - * - * @return void - */ - public function index() { - $this->Config->recursive = 0; - $configs = $this->Config->find('all'); - $this->set(array( - 'configs' => $configs, - '_serialize' => array('configs') - )); - } - /** * view method * @@ -47,6 +33,19 @@ class ConfigsController extends AppController { )); } + public function viewByName($name = null) { + $config = $this->Config->findByName($name, array('fields' => 'Value')); + + if (!$config) { + throw new NotFoundException(__('Invalid config')); + } + + $this->set(array( + 'config' => $config['Config'], + '_serialize' => array('config') + )); + } + /** * edit method * @@ -93,45 +92,19 @@ class ConfigsController extends AppController { /** * categories method * - * Either return a list of distinct categories - * Or all configs under a certain category + * return a list of distinct categories */ public function categories($category = null) { - if ($category != null) { - if (!$this->Config->find('first', array( 'conditions' => array('Config.Category' => $category)))) { - throw new NotFoundException(__('Invalid Config Category')); - } - - $config = $this->Config->find('all', array( - 'conditions' => array('Config.Category' => $category), - 'recursive' => 0 - )); - $this->set(array( - 'config' => $config, - '_serialize' => array('config') - )); - } else { - $categories = $this->Config->find('all', array( - 'fields' => array('DISTINCT Config.Category'), - 'conditions' => array('Config.Category !=' => 'hidden'), - 'recursive' => 0 - )); - $this->set(array( - 'categories' => $categories, - '_serialize' => array('categories') - )); - } - - } - - public function keyValue() { - $keyValues = $this->Config->find('list', array( - 'fields' => array('Config.Name', 'Config.Value') + $categories = $this->Config->find('all', array( + 'fields' => array('DISTINCT Config.Category'), + 'conditions' => array('Config.Category !=' => 'hidden'), + 'recursive' => 0 )); $this->set(array( - 'keyValues' => $keyValues, - '_serialize' => array('keyValues') + 'categories' => $categories, + '_serialize' => array('categories') )); } } + diff --git a/web/api/app/Controller/ControlsController.php b/web/api/app/Controller/ControlsController.php new file mode 100644 index 000000000..879142f75 --- /dev/null +++ b/web/api/app/Controller/ControlsController.php @@ -0,0 +1,59 @@ +Control->recursive = 0; + $controls = $this->Control->find('all'); + $this->set(array( + 'controls' => $controls, + '_serialize' => array('controls') + )); + } + +/** + * view method + * + * @throws NotFoundException + * @param string $id + * @return void + */ + public function view($id = null) { + if (!$this->Control->exists($id)) { + throw new NotFoundException(__('Invalid control')); + } + $options = array('conditions' => array('Control.' . $this->Control->primaryKey => $id)); + $control = $this->Control->find('first', $options); + $this->set(array( + 'control' => $control, + '_serialize' => array('control') + )); + } +} + diff --git a/web/api/app/Controller/EventsController.php b/web/api/app/Controller/EventsController.php index 394e61caf..05a280be3 100644 --- a/web/api/app/Controller/EventsController.php +++ b/web/api/app/Controller/EventsController.php @@ -12,20 +12,46 @@ class EventsController extends AppController { * * @var array */ - public $components = array('RequestHandler'); + public $components = array('RequestHandler', 'Scaler', 'Image', 'Paginator'); /** * index method * * @return void + * This also creates a thumbnail for each event. */ public function index() { $this->Event->recursive = -1; - $events = $this->Event->find('all'); - $this->set(array( - 'events' => $events, - '_serialize' => array('events') + + if ($this->request->params['named']) { + $this->FilterComponent = $this->Components->load('Filter'); + $conditions = $this->FilterComponent->buildFilter($this->request->params['named']); + } else { + $conditions = array(); + } + + // How many events to return + $this->loadModel('Config'); + $limit = $this->Config->find('list', array( + 'conditions' => array('Name' => 'ZM_WEB_EVENTS_PER_PAGE'), + 'fields' => array('Name', 'Value') )); + $this->Paginator->settings = array( + 'limit' => $limit['ZM_WEB_EVENTS_PER_PAGE'], + 'order' => array('StartTime', 'MaxScore'), + 'paramType' => 'querystring', + 'conditions' => $conditions + ); + $events = $this->Paginator->paginate('Event'); + + // For each event, get its thumbnail data (path, width, height) + foreach ($events as $key => $value) { + $thumbData = $this->createThumbnail($value['Event']['Id']); + $events[$key]['thumbData'] = $thumbData; + + } + + $this->set(compact('events')); } /** @@ -36,12 +62,23 @@ class EventsController extends AppController { * @return void */ public function view($id = null) { - $this->Event->recursive = -1; + $this->loadModel('Config'); + $configs = $this->Config->find('list', array( + 'fields' => array('Name', 'Value'), + 'conditions' => array('Name' => array('ZM_DIR_EVENTS')) + )); + + $this->Event->recursive = 1; if (!$this->Event->exists($id)) { throw new NotFoundException(__('Invalid event')); } $options = array('conditions' => array('Event.' . $this->Event->primaryKey => $id)); $event = $this->Event->find('first', $options); + + $path = $configs['ZM_DIR_EVENTS'].'/'.$this->Image->getEventPath($event).'/'; + + $event['Event']['BasePath'] = $path; + $this->set(array( 'event' => $event, '_serialize' => array('event') @@ -108,4 +145,142 @@ class EventsController extends AppController { } else { return $this->flash(__('The event could not be deleted. Please, try again.'), array('action' => 'index')); } - }} + } + + public function search() { + $this->Event->recursive = -1; + $conditions = array(); + + foreach ($this->params['named'] as $param_name => $value) { + // Transform params into mysql + if (preg_match("/interval/i", $value, $matches)) { + $condition = array("$param_name >= (date_sub(now(), $value))"); + } else { + $condition = array($param_name => $value); + } + array_push($conditions, $condition); + } + + $results = $this->Event->find('all', array( + 'conditions' => $conditions + )); + + $this->set(array( + 'results' => $results, + '_serialize' => array('results') + )); + + + } + + public function consoleEvents($interval = null) { + $this->Event->recursive = -1; + $results = array(); + + $query = $this->Event->query("select MonitorId, COUNT(*) AS Count from Events WHERE StartTime >= (DATE_SUB(NOW(), interval $interval)) GROUP BY MonitorId;"); + + foreach ($query as $result) { + $results[$result['Events']['MonitorId']] = $result[0]['Count']; + } + + $this->set(array( + 'results' => $results, + '_serialize' => array('results') + )); + } + + // Create a thumbnail and return the thumbnail's data for a given event id. + public function createThumbnail($id = null) { + $this->Event->recursive = -1; + + if (!$this->Event->exists($id)) { + throw new NotFoundException(__('Invalid event')); + } + + $event = $this->Event->find('first', array( + 'conditions' => array('Id' => $id) + )); + + // Find the max Frame for this Event. Error out otherwise. + $this->loadModel('Frame'); + if (! $frame = $this->Frame->find('first', array( + 'conditions' => array( + 'EventId' => $event['Event']['Id'], + 'Score' => $event['Event']['MaxScore'] + ) + ))) { + throw new NotFoundException(__("Can not find Frame for Event " . $event['Event']['Id'])); + } + + $this->loadModel('Config'); + + // Get the config options required for reScale and getImageSrc + // The $bw, $thumbs and unset() code is a workaround / temporary + // until I have a better way of handing per-bandwidth config options + $bw = (isset($_COOKIE['zmBandwidth']) ? strtoupper(substr($_COOKIE['zmBandwidth'], 0, 1)) : 'L'); + $thumbs = "ZM_WEB_${bw}_SCALE_THUMBS"; + + $config = $this->Config->find('list', array( + 'conditions' => array('OR' => array( + 'Name' => array('ZM_WEB_LIST_THUMB_WIDTH', + 'ZM_WEB_LIST_THUMB_HEIGHT', + 'ZM_EVENT_IMAGE_DIGITS', + 'ZM_DIR_IMAGES', + "$thumbs", + 'ZM_DIR_EVENTS' + ) + )), + 'fields' => array('Name', 'Value') + )); + $config['ZM_WEB_SCALE_THUMBS'] = $config[$thumbs]; + unset($config[$thumbs]); + + // reScale based on either the width, or the hight, of the event. + if ( $config['ZM_WEB_LIST_THUMB_WIDTH'] ) { + $thumbWidth = $config['ZM_WEB_LIST_THUMB_WIDTH']; + $scale = (100 * $thumbWidth) / $event['Event']['Width']; + $thumbHeight = $this->Scaler->reScale( $event['Event']['Height'], $scale ); + } + elseif ( $config['ZM_WEB_LIST_THUMB_HEIGHT'] ) { + $thumbHeight = $config['ZM_WEB_LIST_THUMB_HEIGHT']; + $scale = (100*$thumbHeight)/$event['Event']['Height']; + $thumbWidth = $this->Scaler->reScale( $event['Event']['Width'], $scale ); + } + else { + throw new NotFoundException(__('No thumbnail width or height specified, please check in Options->Web')); + } + + $imageData = $this->Image->getImageSrc( $event, $frame, $scale, $config ); + $thumbData['Path'] = $imageData['thumbPath']; + $thumbData['Width'] = (int)$thumbWidth; + $thumbData['Height'] = (int)$thumbHeight; + + return( $thumbData ); + + } + + public function archive($id = null) { + $this->Event->recursive = -1; + if (!$this->Event->exists($id)) { + throw new NotFoundException(__('Invalid event')); + } + + // Get the current value of Archive + $archived = $this->Event->find('first', array( + 'fields' => array('Event.Archived'), + 'conditions' => array('Event.Id' => $id) + )); + // If 0, 1, if 1, 0 + $archiveVal = (($archived['Event']['Archived'] == 0) ? 1 : 0); + + // Save the new value + $this->Event->id = $id; + $this->Event->saveField('Archived', $archiveVal); + + $this->set(array( + 'archived' => $archiveVal, + '_serialize' => array('archived') + )); + } + +} diff --git a/web/api/app/Controller/HostController.php b/web/api/app/Controller/HostController.php new file mode 100644 index 000000000..973caf286 --- /dev/null +++ b/web/api/app/Controller/HostController.php @@ -0,0 +1,110 @@ +set(array( + 'result' => $result, + '_serialize' => array('result') + )); + } + + function getLoad() { + $load = sys_getloadavg(); + + $this->set(array( + 'load' => $load, + '_serialize' => array('load') + )); + } + + // If $mid is set, only return disk usage for that monitor + // Else, return an array of total disk usage, and per-monitor + // usage. + function getDiskPercent($mid = null) { + $this->loadModel('Config'); + $this->loadModel('Monitor'); + + // If $mid is passed, see if it is valid + if ($mid) { + if (!$this->Monitor->exists($mid)) { + throw new NotFoundException(__('Invalid monitor')); + } + } + + $zm_dir_events = $this->Config->find('list', array( + 'conditions' => array('Name' => 'ZM_DIR_EVENTS'), + 'fields' => array('Name', 'Value') + )); + $zm_dir_events = $zm_dir_events['ZM_DIR_EVENTS' ]; + + // Test to see if $zm_dir_events is relative or absolute + if ('/' === "" || strrpos($zm_dir_events, '/', -strlen($zm_dir_events)) !== TRUE) { + // relative - so add the full path + $zm_dir_events = Configure::read('ZM_PATH_WEB') . '/' . $zm_dir_events; + } + + if ($mid) { + // Get disk usage for $mid + $usage = shell_exec ("du -sh0 $zm_dir_events/$mid | awk '{print $1}'"); + } else { + $monitors = $this->Monitor->find('all', array( + 'fields' => array('Id', 'Name', 'WebColour') + )); + $usage = array(); + + // Add each monitor's usage to array + foreach ($monitors as $key => $value) { + $id = $value['Monitor']['Id']; + $name = $value['Monitor']['Name']; + $color = $value['Monitor']['WebColour']; + + $space = shell_exec ("du -s0 $zm_dir_events/$id | awk '{print $1}'"); + if ($space == null) { + $space = 0; + } + $space = $space/1024/1024; + + $usage[$name] = array( + 'space' => rtrim($space), + 'color' => $color + ); + } + + // Add total usage to array + $space = shell_exec( "df $zm_dir_events |tail -n1 | awk '{print $3 }'"); + $space = $space/1024/1024; + $usage['Total'] = array( + 'space' => rtrim($space), + 'color' => '#F7464A' + ); + } + + $this->set(array( + 'usage' => $usage, + '_serialize' => array('usage') + )); + } + + function getVersion() { + $version = Configure::read('ZM_VERSION'); + + $this->set(array( + 'version' => $version, + '_serialize' => array('version') + )); + } +} diff --git a/web/api/app/Controller/LogsController.php b/web/api/app/Controller/LogsController.php index 908c635e2..bb8f47b80 100644 --- a/web/api/app/Controller/LogsController.php +++ b/web/api/app/Controller/LogsController.php @@ -13,7 +13,12 @@ class LogsController extends AppController { * * @var array */ - public $components = array('Paginator'); + public $components = array('Paginator', 'RequestHandler'); + public $paginate = array( + 'limit' => 100, + 'order' => array( 'Log.TimeKey' => 'asc' ), + 'paramType' => 'querystring' + ); /** * index method @@ -21,8 +26,11 @@ class LogsController extends AppController { * @return void */ public function index() { - $this->Log->recursive = 0; - $this->set('logs', $this->Paginator->paginate()); + $this->Log->recursive = -1; + $this->Paginator->settings = $this->paginate; + + $logs = $this->Paginator->paginate('Log'); + $this->set(compact('logs')); } /** diff --git a/web/api/app/Controller/MonitorsController.php b/web/api/app/Controller/MonitorsController.php index da4339e8e..0588a8cc2 100644 --- a/web/api/app/Controller/MonitorsController.php +++ b/web/api/app/Controller/MonitorsController.php @@ -59,6 +59,7 @@ class MonitorsController extends AppController { if ($this->request->is('post')) { $this->Monitor->create(); if ($this->Monitor->save($this->request->data)) { + $this->daemonControl($this->Monitor->id, 'start', $this->request->data); return $this->flash(__('The monitor has been saved.'), array('action' => 'index')); } } @@ -103,6 +104,9 @@ class MonitorsController extends AppController { throw new NotFoundException(__('Invalid monitor')); } $this->request->allowMethod('post', 'delete'); + + $this->daemonControl($this->Monitor->id, 'stop'); + if ($this->Monitor->delete()) { return $this->flash(__('The monitor has been deleted.'), array('action' => 'index')); } else { @@ -124,5 +128,81 @@ class MonitorsController extends AppController { )); } + // Check if a daemon is running for the monitor id + public function daemonStatus() { + $id = $this->request->params['named']['id']; + $daemon = $this->request->params['named']['daemon']; + + if (!$this->Monitor->exists($id)) { + throw new NotFoundException(__('Invalid monitor')); + } + + $monitor = $this->Monitor->find('first', array( + 'fields' => array('Id', 'Type', 'Device'), + 'conditions' => array('Id' => $id) + )); + + // Clean up the returned array + $monitor = Set::extract('/Monitor/.', $monitor); + + // Pass -d for local, otherwise -m + if ($monitor[0]['Type'] == 'Local') { + $args = "-d ". $monitor[0]['Device']; + } else { + $args = "-m ". $monitor[0]['Id']; + } + + // Build the command, and execute it + $zm_path_bin = Configure::read('ZM_PATH_BIN'); + $command = escapeshellcmd("$zm_path_bin/zmdc.pl status $daemon $args"); + $status = exec( $command ); + + // If 'not' is present, the daemon is not running, so return false + // https://github.com/ZoneMinder/ZoneMinder/issues/799#issuecomment-108996075 + // Also sending back the status text so we can check if the monitor is in pending + // state which means there may be an error + $statustext = $status; + $status = (strpos($status, 'not')) ? false : true; + + $this->set(array( + 'status' => $status, + 'statustext' => $statustext, + '_serialize' => array('status','statustext'), + )); + } + + public function daemonControl($id, $command, $monitor=null, $daemon=null) { + $args = ''; + $daemons = array(); + + if (!$monitor) { + // Need to see if it is local or remote + $monitor = $this->Monitor->find('first', array( + 'fields' => array('Type', 'Function'), + 'conditions' => array('Id' => $id) + )); + $monitor = $monitor['Monitor']; + } + + if ($monitor['Type'] == 'Local') { + $args = "-d " . $monitor['Device']; + } else { + $args = "-m " . $id; + } + + if ($monitor['Function'] == 'Monitor') { + array_push($daemons, 'zmc'); + } else { + array_push($daemons, 'zmc', 'zma'); + } + + $zm_path_bin = Configure::read('ZM_PATH_BIN'); + + foreach ($daemons as $daemon) { + $shellcmd = escapeshellcmd("$zm_path_bin/zmdc.pl $command $daemon $args"); + $status = exec( $shellcmd ); + } + } + } diff --git a/web/api/app/Controller/StatesController.php b/web/api/app/Controller/StatesController.php new file mode 100644 index 000000000..2b007f08f --- /dev/null +++ b/web/api/app/Controller/StatesController.php @@ -0,0 +1,117 @@ +State->recursive = 0; + $states = $this->State->find('all'); + $this->set(array( + 'states' => $states, + '_serialize' => array('states') + )); + } + +/** + * view method + * + * @throws NotFoundException + * @param string $id + * @return void + */ + public function view($id = null) { + if (!$this->State->exists($id)) { + throw new NotFoundException(__('Invalid state')); + } + $options = array('conditions' => array('State.' . $this->State->primaryKey => $id)); + $this->set('state', $this->State->find('first', $options)); + } + +/** + * add method + * + * @return void + */ + public function add() { + if ($this->request->is('post')) { + $this->State->create(); + if ($this->State->save($this->request->data)) { + return $this->flash(__('The state has been saved.'), array('action' => 'index')); + } + } + } + +/** + * edit method + * + * @throws NotFoundException + * @param string $id + * @return void + */ + public function edit($id = null) { + if (!$this->State->exists($id)) { + throw new NotFoundException(__('Invalid state')); + } + if ($this->request->is(array('post', 'put'))) { + if ($this->State->save($this->request->data)) { + return $this->flash(__('The state has been saved.'), array('action' => 'index')); + } + } else { + $options = array('conditions' => array('State.' . $this->State->primaryKey => $id)); + $this->request->data = $this->State->find('first', $options); + } + } + +/** + * delete method + * + * @throws NotFoundException + * @param string $id + * @return void + */ + public function delete($id = null) { + $this->State->id = $id; + if (!$this->State->exists()) { + throw new NotFoundException(__('Invalid state')); + } + $this->request->allowMethod('post', 'delete'); + if ($this->State->delete()) { + return $this->flash(__('The state has been deleted.'), array('action' => 'index')); + } else { + return $this->flash(__('The state could not be deleted. Please, try again.'), array('action' => 'index')); + } + } + + public function change() { + $newState = $this->request->params['pass'][0]; + $blah = $this->packageControl($newState); + + $this->set(array( + 'blah' => $blah, + '_serialize' => array('blah') + )); + } + + public function packageControl( $command ) { + $zm_path_bin = Configure::read('ZM_PATH_BIN'); + $string = $zm_path_bin.'/zmpkg.pl '.escapeshellarg( $command ); + $status = exec( $string ); + + return $status; + } + + +} diff --git a/web/api/app/Controller/ZonePresetsController.php b/web/api/app/Controller/ZonePresetsController.php new file mode 100644 index 000000000..b89a6c75d --- /dev/null +++ b/web/api/app/Controller/ZonePresetsController.php @@ -0,0 +1,99 @@ +ZonePreset->find('all'); + $this->set(array( + 'zonePresets' => $zonePresets, + '_serialize' => array('zonePresets') + )); + } + +/** + * view method + * + * @throws NotFoundException + * @param string $id + * @return void + */ + public function view($id = null) { + if (!$this->ZonePreset->exists($id)) { + throw new NotFoundException(__('Invalid zone preset')); + } + $options = array('conditions' => array('ZonePreset.' . $this->ZonePreset->primaryKey => $id)); + $this->set('zonePreset', $this->ZonePreset->find('first', $options)); + } + +/** + * add method + * + * @return void + */ + public function add() { + if ($this->request->is('post')) { + $this->ZonePreset->create(); + if ($this->ZonePreset->save($this->request->data)) { + return $this->flash(__('The zone preset has been saved.'), array('action' => 'index')); + } + } + } + +/** + * edit method + * + * @throws NotFoundException + * @param string $id + * @return void + */ + public function edit($id = null) { + if (!$this->ZonePreset->exists($id)) { + throw new NotFoundException(__('Invalid zone preset')); + } + if ($this->request->is(array('post', 'put'))) { + if ($this->ZonePreset->save($this->request->data)) { + return $this->flash(__('The zone preset has been saved.'), array('action' => 'index')); + } + } else { + $options = array('conditions' => array('ZonePreset.' . $this->ZonePreset->primaryKey => $id)); + $this->request->data = $this->ZonePreset->find('first', $options); + } + } + +/** + * delete method + * + * @throws NotFoundException + * @param string $id + * @return void + */ + public function delete($id = null) { + $this->ZonePreset->id = $id; + if (!$this->ZonePreset->exists()) { + throw new NotFoundException(__('Invalid zone preset')); + } + $this->request->allowMethod('post', 'delete'); + if ($this->ZonePreset->delete()) { + return $this->flash(__('The zone preset has been deleted.'), array('action' => 'index')); + } else { + return $this->flash(__('The zone preset could not be deleted. Please, try again.'), array('action' => 'index')); + } + }} diff --git a/web/api/app/Controller/ZonesController.php b/web/api/app/Controller/ZonesController.php index dc30a382a..be80c57fc 100644 --- a/web/api/app/Controller/ZonesController.php +++ b/web/api/app/Controller/ZonesController.php @@ -4,51 +4,26 @@ App::uses('AppController', 'Controller'); * Zones Controller * * @property Zone $Zone - * @property PaginatorComponent $Paginator */ class ZonesController extends AppController { -/** - * Components - * - * @var array - */ - public $components = array('Paginator', 'RequestHandler'); - -/** - * index method - * - * @return void - */ - public function index() { - $this->Zone->recursive = -1; - $zones = $this->Zone->find('all'); - $this->set(array( - 'zones' => $zones, - '_serialize' => array('zones') - )); - } - -/** - * view method - * - * @throws NotFoundException - * @param string $id - * @return void - */ - public function view($id = null) { - $this->Zone->recursive = -1; - if (!$this->Zone->exists($id)) { - throw new NotFoundException(__('Invalid zone')); +// Find all zones which belong to a MonitorId + public function forMonitor($id = null) { + $this->loadModel('Monitor'); + if (!$this->Monitor->exists($id)) { + throw new NotFoundException(__('Invalid monitor')); } - $options = array('conditions' => array('Zone.' . $this->Zone->primaryKey => $id)); - $zone = $this->Zone->find('first', $options); + + $this->Zone->recursive = -1; + + $zones = $this->Zone->find('all', array( + 'conditions' => array('MonitorId' => $id) + )); $this->set(array( - 'zone' => $zone, - '_serialize' => array('zone') + 'zones' => $zones, + '_serialize' => array('zones') )); } - /** * add method * @@ -108,4 +83,38 @@ class ZonesController extends AppController { } else { return $this->flash(__('The zone could not be deleted. Please, try again.'), array('action' => 'index')); } - }} + } + + + + public function createZoneImage( $id = null ) { + $this->loadModel('Monitor'); + $this->Monitor->id = $id; + if (!$this->Monitor->exists()) { + throw new NotFoundException(__('Invalid zone')); + } + + + $this->loadModel('Config'); + $zm_dir_images = $this->Config->find('list', array( + 'conditions' => array('Name' => 'ZM_DIR_IMAGES'), + 'fields' => array('Name', 'Value') + )); + + $zm_dir_images = $zm_dir_images['ZM_DIR_IMAGES']; + $zm_path_web = Configure::read('ZM_PATH_WEB'); + $zm_path_bin = Configure::read('ZM_PATH_BIN'); + $images_path = "$zm_path_web/$zm_dir_images"; + + chdir($images_path); + + $command = escapeshellcmd("$zm_path_bin/zmu -z -m $id"); + system( $command, $status ); + + $this->set(array( + 'status' => $status, + '_serialize' => array('status') + )); + + } +} diff --git a/web/api/app/Model/Config.php b/web/api/app/Model/Config.php index 2ada8258d..d83728c76 100644 --- a/web/api/app/Model/Config.php +++ b/web/api/app/Model/Config.php @@ -18,13 +18,25 @@ class Config extends AppModel { * * @var string */ - public $primaryKey = 'Id'; + public $primaryKey = 'Name'; /** * Display field * * @var string */ - public $displayField = 'Name'; + public $displayField = 'Value'; + + + // Add a find method for returning a hash of the Config table. + // This is used for the Options view. + public $findMethods = array('hash' => true); + protected function _findHash($state, $query, $results = array()) { + if ($state === 'before') { + return $query; + } + $results = Set::combine($results, '{n}.Config.Name', '{n}.Config'); + return $results; + } } diff --git a/web/api/app/Model/Control.php b/web/api/app/Model/Control.php new file mode 100644 index 000000000..d5716cc66 --- /dev/null +++ b/web/api/app/Model/Control.php @@ -0,0 +1,54 @@ + array( + 'numeric' => array( + 'rule' => array('numeric'), + //'message' => 'Your custom message here', + //'allowEmpty' => false, + //'required' => false, + //'last' => false, // Stop validation after this rule + //'on' => 'create', // Limit validation to 'create' or 'update' operations + ), + ), + ); + +} diff --git a/web/api/app/Model/Frame.php b/web/api/app/Model/Frame.php index 48b880304..96c5fdc50 100644 --- a/web/api/app/Model/Frame.php +++ b/web/api/app/Model/Frame.php @@ -121,4 +121,6 @@ class Frame extends AppModel { 'order' => '' ) ); + + public $recursive = -1; } diff --git a/web/api/app/Model/Host.php b/web/api/app/Model/Host.php new file mode 100644 index 000000000..5c24c7531 --- /dev/null +++ b/web/api/app/Model/Host.php @@ -0,0 +1,9 @@ + +Paginator->params(); + echo json_encode($array); +?> diff --git a/web/api/app/View/Logs/json/index.ctp b/web/api/app/View/Logs/json/index.ctp new file mode 100644 index 000000000..32cbd51f8 --- /dev/null +++ b/web/api/app/View/Logs/json/index.ctp @@ -0,0 +1,5 @@ +Paginator->params(); + echo json_encode($array); +?> diff --git a/web/api/app/View/View/Configs/json/edit.ctp b/web/api/app/View/View/Configs/json/edit.ctp new file mode 100644 index 000000000..75fa758bd --- /dev/null +++ b/web/api/app/View/View/Configs/json/edit.ctp @@ -0,0 +1 @@ +echo json_encode($config); diff --git a/web/api/app/View/View/Configs/json/index.ctp b/web/api/app/View/View/Configs/json/index.ctp new file mode 100644 index 000000000..86edf870a --- /dev/null +++ b/web/api/app/View/View/Configs/json/index.ctp @@ -0,0 +1 @@ +echo json_encode($configs); diff --git a/web/api/app/View/View/Configs/json/view.ctp b/web/api/app/View/View/Configs/json/view.ctp new file mode 100644 index 000000000..75fa758bd --- /dev/null +++ b/web/api/app/View/View/Configs/json/view.ctp @@ -0,0 +1 @@ +echo json_encode($config); diff --git a/web/api/app/View/View/Configs/xml/index.ctp b/web/api/app/View/View/Configs/xml/index.ctp new file mode 100644 index 000000000..b13a76093 --- /dev/null +++ b/web/api/app/View/View/Configs/xml/index.ctp @@ -0,0 +1,2 @@ +$xml = Xml::fromArray(array('response' => $configs)); +echo $xml->asXML(); diff --git a/web/api/app/View/View/Configs/xml/view.ctp b/web/api/app/View/View/Configs/xml/view.ctp new file mode 100644 index 000000000..7987d32e7 --- /dev/null +++ b/web/api/app/View/View/Configs/xml/view.ctp @@ -0,0 +1,2 @@ +$xml = Xml::fromArray(array('response' => $config)); +echo $xml->asXML(); diff --git a/web/api/app/View/View/Elements/empty b/web/api/app/View/View/Elements/empty new file mode 100644 index 000000000..e69de29bb diff --git a/web/api/app/View/View/Emails/html/default.ctp b/web/api/app/View/View/Emails/html/default.ctp new file mode 100644 index 000000000..e2bff19c0 --- /dev/null +++ b/web/api/app/View/View/Emails/html/default.ctp @@ -0,0 +1,25 @@ + + ' . $line . "

\n"; +endforeach; +?> \ No newline at end of file diff --git a/web/api/app/View/View/Emails/text/default.ctp b/web/api/app/View/View/Emails/text/default.ctp new file mode 100644 index 000000000..090b5c403 --- /dev/null +++ b/web/api/app/View/View/Emails/text/default.ctp @@ -0,0 +1,19 @@ + + \ No newline at end of file diff --git a/web/api/app/View/View/Errors/error400.ctp b/web/api/app/View/View/Errors/error400.ctp new file mode 100644 index 000000000..4c3850b28 --- /dev/null +++ b/web/api/app/View/View/Errors/error400.ctp @@ -0,0 +1,31 @@ + +

+

+ : + '{$url}'" + ); ?> +

+ 0): + echo $this->element('exception_stack_trace'); +endif; +?> diff --git a/web/api/app/View/View/Errors/error500.ctp b/web/api/app/View/View/Errors/error500.ctp new file mode 100644 index 000000000..518b9ee77 --- /dev/null +++ b/web/api/app/View/View/Errors/error500.ctp @@ -0,0 +1,28 @@ + +

+

+ : + +

+ 0): + echo $this->element('exception_stack_trace'); +endif; +?> diff --git a/web/api/app/View/View/Events/json/index.ctp b/web/api/app/View/View/Events/json/index.ctp new file mode 100644 index 000000000..d54386749 --- /dev/null +++ b/web/api/app/View/View/Events/json/index.ctp @@ -0,0 +1,5 @@ +Paginator->params(); + echo json_encode($array); +?> diff --git a/web/api/app/View/View/Events/json/view.ctp b/web/api/app/View/View/Events/json/view.ctp new file mode 100644 index 000000000..b320feb4d --- /dev/null +++ b/web/api/app/View/View/Events/json/view.ctp @@ -0,0 +1 @@ +echo json_encode($event); diff --git a/web/api/app/View/View/Events/xml/index.ctp b/web/api/app/View/View/Events/xml/index.ctp new file mode 100644 index 000000000..af960238f --- /dev/null +++ b/web/api/app/View/View/Events/xml/index.ctp @@ -0,0 +1,2 @@ +$xml = Xml::fromArray(array('response' => $events)); +echo $xml->asXML(); diff --git a/web/api/app/View/View/Events/xml/view.ctp b/web/api/app/View/View/Events/xml/view.ctp new file mode 100644 index 000000000..7f64e422f --- /dev/null +++ b/web/api/app/View/View/Events/xml/view.ctp @@ -0,0 +1,2 @@ +$xml = Xml::fromArray(array('response' => $event)); +echo $xml->asXML(); diff --git a/web/api/app/View/View/Helper/AppHelper.php b/web/api/app/View/View/Helper/AppHelper.php new file mode 100644 index 000000000..9097d33f0 --- /dev/null +++ b/web/api/app/View/View/Helper/AppHelper.php @@ -0,0 +1,33 @@ + + + + + <?php echo $title_for_layout; ?> + + + fetch('content'); ?> + +

This email was sent using the CakePHP Framework

+ + \ No newline at end of file diff --git a/web/api/app/View/View/Layouts/Emails/text/default.ctp b/web/api/app/View/View/Layouts/Emails/text/default.ctp new file mode 100644 index 000000000..ee624de45 --- /dev/null +++ b/web/api/app/View/View/Layouts/Emails/text/default.ctp @@ -0,0 +1,21 @@ + +fetch('content'); ?> + +This email was sent using the CakePHP Framework, http://cakephp.org. diff --git a/web/api/app/View/View/Layouts/ajax.ctp b/web/api/app/View/View/Layouts/ajax.ctp new file mode 100644 index 000000000..0f9a4fb62 --- /dev/null +++ b/web/api/app/View/View/Layouts/ajax.ctp @@ -0,0 +1,19 @@ + +fetch('content'); ?> diff --git a/web/api/app/View/View/Layouts/default.ctp b/web/api/app/View/View/Layouts/default.ctp new file mode 100644 index 000000000..38dececbc --- /dev/null +++ b/web/api/app/View/View/Layouts/default.ctp @@ -0,0 +1,65 @@ + + + + + Html->charset(); ?> + + <?php echo $cakeDescription ?>: + <?php echo $title_for_layout; ?> + + Html->meta('icon'); + + echo $this->Html->css('cake.generic'); + + echo $this->fetch('meta'); + echo $this->fetch('css'); + echo $this->fetch('script'); + ?> + + +
+ +
+ + Session->flash(); ?> + + fetch('content'); ?> +
+ +
+ element('sql_dump'); ?> + + diff --git a/web/api/app/View/View/Layouts/error.ctp b/web/api/app/View/View/Layouts/error.ctp new file mode 100644 index 000000000..e9d738178 --- /dev/null +++ b/web/api/app/View/View/Layouts/error.ctp @@ -0,0 +1,61 @@ + + + + + Html->charset(); ?> + + <?php echo $cakeDescription ?>: + <?php echo $title_for_layout; ?> + + Html->meta('icon'); + + echo $this->Html->css('cake.generic'); + + echo $this->fetch('meta'); + echo $this->fetch('css'); + echo $this->fetch('script'); + ?> + + +
+ +
+ + Session->flash(); ?> + + fetch('content'); ?> +
+ +
+ element('sql_dump'); ?> + + diff --git a/web/api/app/View/View/Layouts/flash.ctp b/web/api/app/View/View/Layouts/flash.ctp new file mode 100644 index 000000000..cd79f5008 --- /dev/null +++ b/web/api/app/View/View/Layouts/flash.ctp @@ -0,0 +1,37 @@ + + + + +Html->charset(); ?> +<?php echo $page_title; ?> + + + + + + + +

+ + diff --git a/web/api/app/View/View/Layouts/js/default.ctp b/web/api/app/View/View/Layouts/js/default.ctp new file mode 100644 index 000000000..7239b5dae --- /dev/null +++ b/web/api/app/View/View/Layouts/js/default.ctp @@ -0,0 +1,2 @@ + + diff --git a/web/api/app/View/View/Layouts/rss/default.ctp b/web/api/app/View/View/Layouts/rss/default.ctp new file mode 100644 index 000000000..26d875eda --- /dev/null +++ b/web/api/app/View/View/Layouts/rss/default.ctp @@ -0,0 +1,14 @@ +Rss->document( + $this->Rss->channel( + array(), $channel, $this->fetch('content') + ) +); +?> diff --git a/web/api/app/View/View/Layouts/xml/default.ctp b/web/api/app/View/View/Layouts/xml/default.ctp new file mode 100644 index 000000000..fbd5ee0c3 --- /dev/null +++ b/web/api/app/View/View/Layouts/xml/default.ctp @@ -0,0 +1 @@ +fetch('content'); ?> diff --git a/web/api/app/View/View/Logs/json/index.ctp b/web/api/app/View/View/Logs/json/index.ctp new file mode 100644 index 000000000..32cbd51f8 --- /dev/null +++ b/web/api/app/View/View/Logs/json/index.ctp @@ -0,0 +1,5 @@ +Paginator->params(); + echo json_encode($array); +?> diff --git a/web/api/app/View/View/Monitors/json/edit.ctp b/web/api/app/View/View/Monitors/json/edit.ctp new file mode 100644 index 000000000..77d2dd08b --- /dev/null +++ b/web/api/app/View/View/Monitors/json/edit.ctp @@ -0,0 +1,2 @@ +echo json_encode($message); +echo json_encode($monitor); diff --git a/web/api/app/View/View/Monitors/json/index.ctp b/web/api/app/View/View/Monitors/json/index.ctp new file mode 100644 index 000000000..facf965d4 --- /dev/null +++ b/web/api/app/View/View/Monitors/json/index.ctp @@ -0,0 +1 @@ +echo json_encode($monitors); diff --git a/web/api/app/View/View/Monitors/json/view.ctp b/web/api/app/View/View/Monitors/json/view.ctp new file mode 100644 index 000000000..acfced9d0 --- /dev/null +++ b/web/api/app/View/View/Monitors/json/view.ctp @@ -0,0 +1 @@ +echo json_encode($monitor); diff --git a/web/api/app/View/View/Monitors/xml/edit.ctp b/web/api/app/View/View/Monitors/xml/edit.ctp new file mode 100644 index 000000000..09fb8979a --- /dev/null +++ b/web/api/app/View/View/Monitors/xml/edit.ctp @@ -0,0 +1,2 @@ +$xml = Xml::fromArray(array('response' => $message)); +echo $xml->asXML(); diff --git a/web/api/app/View/View/Monitors/xml/index.ctp b/web/api/app/View/View/Monitors/xml/index.ctp new file mode 100644 index 000000000..37afc918b --- /dev/null +++ b/web/api/app/View/View/Monitors/xml/index.ctp @@ -0,0 +1,2 @@ +$xml = Xml::fromArray(array('response' => $monitors)); +echo $xml->asXML(); diff --git a/web/api/app/View/View/Monitors/xml/view.ctp b/web/api/app/View/View/Monitors/xml/view.ctp new file mode 100644 index 000000000..b33c6e79a --- /dev/null +++ b/web/api/app/View/View/Monitors/xml/view.ctp @@ -0,0 +1,2 @@ +$xml = Xml::fromArray(array('response' => $monitor)); +echo $xml->asXML(); diff --git a/web/api/app/View/View/Pages/home.ctp b/web/api/app/View/View/Pages/home.ctp new file mode 100644 index 000000000..082cc99b0 --- /dev/null +++ b/web/api/app/View/View/Pages/home.ctp @@ -0,0 +1,233 @@ + +

+

+ +

+ 0): + Debugger::checkSecurityKeys(); +endif; +?> + +

+ + 1) Help me configure it + 2) I don't / can't use URL rewriting +

+ +

+=')): + echo ''; + echo __d('cake_dev', 'Your version of PHP is 5.2.8 or higher.'); + echo ''; + else: + echo ''; + echo __d('cake_dev', 'Your version of PHP is too low. You need PHP 5.2.8 or higher to use CakePHP.'); + echo ''; + endif; +?> +

+

+ '; + echo __d('cake_dev', 'Your tmp directory is writable.'); + echo ''; + else: + echo ''; + echo __d('cake_dev', 'Your tmp directory is NOT writable.'); + echo ''; + endif; + ?> +

+

+ '; + echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', ''. $settings['engine'] . 'Engine', 'APP/Config/core.php'); + echo ''; + else: + echo ''; + echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', 'APP/Config/core.php'); + echo ''; + endif; + ?> +

+

+ '; + echo __d('cake_dev', 'Your database configuration file is present.'); + $filePresent = true; + echo ''; + else: + echo ''; + echo __d('cake_dev', 'Your database configuration file is NOT present.'); + echo '
'; + echo __d('cake_dev', 'Rename %s to %s', 'APP/Config/database.php.default', 'APP/Config/database.php'); + echo '
'; + endif; + ?> +

+getMessage(); + if (method_exists($connectionError, 'getAttributes')): + $attributes = $connectionError->getAttributes(); + if (isset($errorMsg['message'])): + $errorMsg .= '
' . $attributes['message']; + endif; + endif; + } +?> +

+ isConnected()): + echo ''; + echo __d('cake_dev', 'CakePHP is able to connect to the database.'); + echo ''; + else: + echo ''; + echo __d('cake_dev', 'CakePHP is NOT able to connect to the database.'); + echo '

'; + echo $errorMsg; + echo '
'; + endif; + ?> +

+ +'; + echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.'); + echo '
'; + echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding --enable-unicode-properties when configuring'); + echo '

'; + endif; +?> + +

+ '; + echo __d('cake_dev', 'DebugKit plugin is present'); + echo ''; + else: + echo ''; + echo __d('cake_dev', 'DebugKit is not installed. It will help you inspect and debug different aspects of your application.'); + echo '
'; + echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit')); + echo '
'; + endif; + ?> +

+ +

+

+ +To change its layout, edit: %s.
+You can also add some CSS styles for your pages at: %s.', + 'APP/View/Pages/home.ctp', 'APP/View/Layouts/default.ctp', 'APP/webroot/css'); +?> +

+ +

+

+ Html->link( + sprintf('%s %s', __d('cake_dev', 'New'), __d('cake_dev', 'CakePHP 2.0 Docs')), + 'http://book.cakephp.org/2.0/en/', + array('target' => '_blank', 'escape' => false) + ); + ?> +

+

+ Html->link( + __d('cake_dev', 'The 15 min Blog Tutorial'), + 'http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/blog.html', + array('target' => '_blank', 'escape' => false) + ); + ?> +

+ +

+

+

+

+ +

+

+ +

+

+ +

+ + diff --git a/web/api/app/View/View/Scaffolds/empty b/web/api/app/View/View/Scaffolds/empty new file mode 100644 index 000000000..e69de29bb diff --git a/web/api/app/vendor/autoload.php b/web/api/app/vendor/autoload.php new file mode 100644 index 000000000..0a2797817 --- /dev/null +++ b/web/api/app/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0 class loader + * + * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + + private $classMapAuthoritative = false; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-0 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative) { + return false; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/web/api/app/vendor/composer/autoload_classmap.php b/web/api/app/vendor/composer/autoload_classmap.php new file mode 100644 index 000000000..7a91153b0 --- /dev/null +++ b/web/api/app/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($vendorDir . '/composer/installers/src'), +); diff --git a/web/api/app/vendor/composer/autoload_psr4.php b/web/api/app/vendor/composer/autoload_psr4.php new file mode 100644 index 000000000..b265c64a2 --- /dev/null +++ b/web/api/app/vendor/composer/autoload_psr4.php @@ -0,0 +1,9 @@ + $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(true); + + return $loader; + } +} + +function composerRequiredfd8518a66bb8898e7b22470609a6c8f($file) +{ + require $file; +} diff --git a/web/api/app/vendor/composer/installed.json b/web/api/app/vendor/composer/installed.json new file mode 100644 index 000000000..39d771174 --- /dev/null +++ b/web/api/app/vendor/composer/installed.json @@ -0,0 +1,167 @@ +[ + { + "name": "composer/installers", + "version": "v1.0.21", + "version_normalized": "1.0.21.0", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/d64e23fce42a4063d63262b19b8e7c0f3b5e4c45", + "reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45", + "shasum": "" + }, + "replace": { + "roundcube/plugin-installer": "*", + "shama/baton": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "4.1.*" + }, + "time": "2015-02-18 17:17:01", + "type": "composer-installer", + "extra": { + "class": "Composer\\Installers\\Installer", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Composer\\Installers\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "http://composer.github.com/installers/", + "keywords": [ + "Craft", + "Dolibarr", + "Hurad", + "MODX Evo", + "OXID", + "SMF", + "Thelia", + "WolfCMS", + "agl", + "aimeos", + "annotatecms", + "bitrix", + "cakephp", + "chef", + "codeigniter", + "concrete5", + "croogo", + "dokuwiki", + "drupal", + "elgg", + "fuelphp", + "grav", + "installer", + "joomla", + "kohana", + "laravel", + "lithium", + "magento", + "mako", + "mediawiki", + "modulework", + "moodle", + "phpbb", + "piwik", + "ppi", + "puppet", + "roundcube", + "shopware", + "silverstripe", + "symfony", + "typo3", + "wordpress", + "zend", + "zikula" + ] + }, + { + "name": "friendsofcake/crud", + "version": "3.0.10", + "version_normalized": "3.0.10.0", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfCake/crud.git", + "reference": "c3976f1478c681b0bbc132ec3a3e82c3984eeed5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfCake/crud/zipball/c3976f1478c681b0bbc132ec3a3e82c3984eeed5", + "reference": "c3976f1478c681b0bbc132ec3a3e82c3984eeed5", + "shasum": "" + }, + "require": { + "composer/installers": "*" + }, + "suggest": { + "cakedc/search": "If you want to use the Search Listener" + }, + "time": "2015-04-18 19:08:17", + "type": "cakephp-plugin", + "extra": { + "installer-name": "Crud" + }, + "installation-source": "dist", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Winther", + "homepage": "http://cakephp.nu/", + "role": "Author" + }, + { + "name": "José Lorenzo Rodríguez", + "homepage": "https://github.com/lorenzo", + "role": "Contributor" + }, + { + "name": "Andy Dawson", + "homepage": "https://github.com/ad7six", + "role": "Contributor" + }, + { + "name": "ADmad", + "homepage": "https://github.com/admad", + "role": "Contributor" + } + ], + "description": "CakePHP Application development on steroids - rapid prototyping / scaffolding & production ready code - XML / JSON APIs and more", + "homepage": "https://github.com/FriendsOfCake/crud", + "keywords": [ + "bake", + "cake", + "cakephp", + "create", + "crud", + "delete", + "retrieve", + "scaffold", + "scaffolding", + "update" + ] + } +] diff --git a/web/api/app/vendor/composer/installers/.editorconfig b/web/api/app/vendor/composer/installers/.editorconfig new file mode 100644 index 000000000..153cf3ef5 --- /dev/null +++ b/web/api/app/vendor/composer/installers/.editorconfig @@ -0,0 +1,10 @@ +; top-most EditorConfig file +root = true + +; Unix-style newlines +[*] +end_of_line = LF + +[*.php] +indent_style = space +indent_size = 4 diff --git a/web/api/app/vendor/composer/installers/.gitignore b/web/api/app/vendor/composer/installers/.gitignore new file mode 100644 index 000000000..ff7f293dc --- /dev/null +++ b/web/api/app/vendor/composer/installers/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +.idea/ diff --git a/web/api/app/vendor/composer/installers/.travis.yml b/web/api/app/vendor/composer/installers/.travis.yml new file mode 100644 index 000000000..81ca8e101 --- /dev/null +++ b/web/api/app/vendor/composer/installers/.travis.yml @@ -0,0 +1,14 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm + +before_script: + - curl -s http://getcomposer.org/installer | php -- --quiet + - php composer.phar install --dev + +script: phpunit diff --git a/web/api/app/vendor/composer/installers/LICENSE b/web/api/app/vendor/composer/installers/LICENSE new file mode 100644 index 000000000..85f97fc79 --- /dev/null +++ b/web/api/app/vendor/composer/installers/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012 Kyle Robinson Young + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/web/api/app/vendor/composer/installers/README.md b/web/api/app/vendor/composer/installers/README.md new file mode 100644 index 000000000..b33177198 --- /dev/null +++ b/web/api/app/vendor/composer/installers/README.md @@ -0,0 +1,191 @@ +# A Multi-Framework [Composer](http://getcomposer.org) Library Installer + +[![Build Status](http://img.shields.io/travis/composer/installers.svg)](http://travis-ci.org/composer/installers) + +This is for PHP package authors to require in their `composer.json`. It will +install their package to the correct location based on the specified package +type. + +The goal of `installers` is to be a simple package type to install path map. +Users can also customize the install path per package and package authors can +modify the package name upon installing. + +`installers` isn't intended on replacing all custom installers. If your +package requires special installation handling then by all means, create a +custom installer to handle it. + +**Natively Supported Frameworks**: + +The following frameworks natively work with Composer and will be +installed to the default `vendor` directory. `composer/installers` +is not needed to install packages with these frameworks: + +* Aura +* Symfony2 +* Yii +* Yii2 + +**Current Supported Package Types**: + +> Stable types are marked as **bold**, this means that installation paths +> for those type will not be changed. Any adjustment for those types would +> require creation of brand new type that will cover required changes. + +| Framework | Types +| --------- | ----- +| Aimeos | `aimeos-extension` +| Asgard | `asgard-module`
`asgard-theme` +| AGL | `agl-module` +| AnnotateCms | `annotatecms-module`
`annotatecms-component`
`annotatecms-service` +| Bitrix | `bitrix-module`
`bitrix-component`
`bitrix-theme` +| CakePHP 2+ | **`cakephp-plugin`** +| Chef | `chef-cookbook`
`chef-role` +| CCFramework | `ccframework-ship`
`ccframework-theme` +| CodeIgniter | `codeigniter-library`
`codeigniter-third-party`
`codeigniter-module` +| concrete5 | `concrete5-block`
`concrete5-package`
`concrete5-theme`
`concrete5-update` +| Craft | `craft-plugin` +| Croogo | `croogo-plugin`
`croogo-theme` +| DokuWiki | `dokuwiki-plugin`
`dokuwiki-template` +| Dolibarr | `dolibarr-module` +| Drupal | `drupal-module`
`drupal-theme`

`drupal-library`
`drupal-profile`
`drupal-drush` +| Elgg | `elgg-plugin` +| FuelPHP v1.x | `fuel-module`
`fuel-package`
`fuel-theme` +| FuelPHP v2.x | `fuelphp-component` +| Grav | `grav-plugin`
`grav-theme` +| Hurad | `hurad-plugin`
`hurad-theme` +| Joomla | `joomla-component`
`joomla-module`
`joomla-template`
`joomla-plugin`
`joomla-library` +| Kirby | **`kirby-plugin`** +| Kohana | **`kohana-module`** +| Laravel | `laravel-library` +| Lithium | **`lithium-library`
`lithium-source`** +| Magento | `magento-library`
`magento-skin`
`magento-theme` +| Mako | `mako-package` +| MODX Evo | `modxevo-snippet`
`modxevo-plugin`
`modxevo-module`
`modxevo-template`
`modxevo-lib` +| MediaWiki | `mediawiki-extension` +| October | **`october-module`
`october-plugin`
`october-theme`** +| OXID | `oxid-module`
`oxid-theme`
`oxid-out` +| MODULEWork | `modulework-module` +| Moodle | `moodle-*` (Please [check source](https://raw.githubusercontent.com/composer/installers/master/src/Composer/Installers/MoodleInstaller.php) for all supported types) +| Piwik | `piwik-plugin` +| phpBB | `phpbb-extension`
`phpbb-style`
`phpbb-language` +| Pimcore | `pimcore-plugin` +| PPI | **`ppi-module`** +| Puppet | `puppet-module` +| REDAXO | `redaxo-addon` +| Roundcube | `roundcube-plugin` +| shopware | `shopware-backend-plugin`
`shopware-core-plugin`
`shopware-frontend-plugin`
`shopware-theme` +| SilverStripe | `silverstripe-module`
`silverstripe-theme` +| SMF | `smf-module`
`smf-theme` +| symfony1 | **`symfony1-plugin`** +| Tusk | `tusk-task`
`tusk-command`
`tusk-asset` +| TYPO3 Flow | `typo3-flow-package`
`typo3-flow-framework`
`typo3-flow-plugin`
`typo3-flow-site`
`typo3-flow-boilerplate`
`typo3-flow-build` +| TYPO3 CMS | `typo3-cms-extension` +| Wolf CMS | `wolfcms-plugin` +| WordPress | `wordpress-plugin`
`wordpress-theme`

`wordpress-muplugin` +| Zend | `zend-library`
`zend-extra`
`zend-module` +| Zikula | `zikula-module`
`zikula-theme` +| Prestashop | `prestashop-module`
`prestashop-theme` + +## Example `composer.json` File + +This is an example for a CakePHP plugin. The only important parts to set in your +composer.json file are `"type": "cakephp-plugin"` which describes what your +package is and `"require": { "composer/installers": "~1.0" }` which tells composer +to load the custom installers. + +```json +{ + "name": "you/ftp", + "type": "cakephp-plugin", + "require": { + "composer/installers": "~1.0" + } +} +``` + +This would install your package to the `Plugin/Ftp/` folder of a CakePHP app +when a user runs `php composer.phar install`. + +So submit your packages to [packagist.org](http://packagist.org)! + +## Custom Install Paths + +If you are consuming a package that uses the `composer/installers` you can +override the install path with the following extra in your `composer.json`: + +```json +{ + "extra": { + "installer-paths": { + "your/custom/path/{$name}/": ["shama/ftp", "vendor/package"] + } + } +} +``` + +A package type can have a custom installation path with a `type:` prefix. + +``` json +{ + "extra": { + "installer-paths": { + "your/custom/path/{$name}/": ["type:wordpress-plugin"] + } + } +} +``` + +This would use your custom path for each of the listed packages. The available +variables to use in your paths are: `{$name}`, `{$vendor}`, `{$type}`. + +## Custom Install Names + +If you're a package author and need your package to be named differently when +installed consider using the `installer-name` extra. + +For example you have a package named `shama/cakephp-ftp` with the type +`cakephp-plugin`. Installing with `composer/installers` would install to the +path `Plugin/CakephpFtp`. Due to the strict naming conventions, you as a +package author actually need the package to be named and installed to +`Plugin/Ftp`. Using the following config within your **package** `composer.json` +will allow this: + +```json +{ + "name": "shama/cakephp-ftp", + "type": "cakephp-plugin", + "extra": { + "installer-name": "Ftp" + } +} +``` + +Please note the name entered into `installer-name` will be the final and will +not be inflected. + +## Contribute! + +* [Fork and clone](https://help.github.com/articles/fork-a-repo). +* Run the command `php composer.phar install --dev` to install the dev + dependencies. See [Composer](https://github.com/composer/composer#installation--usage). +* Use the command `phpunit` to run the tests. See [PHPUnit](http://phpunit.de). +* Create a branch, commit, push and send us a + [pull request](https://help.github.com/articles/using-pull-requests). + +To ensure a consistent code base, you should make sure the code follows the +[Coding Standards](http://symfony.com/doc/2.0/contributing/code/standards.html) +which we borrowed from Symfony. + +If you would like to help, please take a look at the list of +[issues](https://github.com/composer/installers/issues). + +### Should we allow dynamic package types or paths? No. +What are they? The ability for a package author to determine where a package +will be installed either through setting the path directly in their +`composer.json` or through a dynamic package type: `"type": +"framework-install-here"`. + +It has been proposed many times. Even implemented once early on and then +removed. `installers` won't do this because it would allow a single package +author to wipe out entire folders without the user's consent. That user would +then come here to yell at us. diff --git a/web/api/app/vendor/composer/installers/composer.json b/web/api/app/vendor/composer/installers/composer.json new file mode 100644 index 000000000..6ee931ee9 --- /dev/null +++ b/web/api/app/vendor/composer/installers/composer.json @@ -0,0 +1,77 @@ +{ + "name": "composer/installers", + "type": "composer-installer", + "license": "MIT", + "description": "A multi-framework Composer library installer", + "keywords": [ + "installer", + "Aimeos", + "AGL", + "AnnotateCms", + "Bitrix", + "CakePHP", + "Chef", + "CodeIgniter", + "concrete5", + "Craft", + "Croogo", + "DokuWiki", + "Dolibarr", + "Drupal", + "Elgg", + "FuelPHP", + "Grav", + "Hurad", + "Joomla", + "Kohana", + "Laravel", + "Lithium", + "Magento", + "Mako", + "MODX Evo", + "MediaWiki", + "OXID", + "MODULEWork", + "Moodle", + "Piwik", + "phpBB", + "PPI", + "Puppet", + "Roundcube", + "shopware", + "SilverStripe", + "SMF", + "symfony", + "Thelia", + "TYPO3", + "WolfCMS", + "WordPress", + "Zend", + "Zikula" + ], + "homepage": "http://composer.github.com/installers/", + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "autoload": { + "psr-0": { "Composer\\Installers\\": "src/" } + }, + "extra": { + "class": "Composer\\Installers\\Installer", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "replace": { + "shama/baton": "*", + "roundcube/plugin-installer": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "4.1.*" + } +} diff --git a/web/api/app/vendor/composer/installers/phpunit.xml.dist b/web/api/app/vendor/composer/installers/phpunit.xml.dist new file mode 100644 index 000000000..cc5cc9915 --- /dev/null +++ b/web/api/app/vendor/composer/installers/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + + tests/Composer/Installers + + + + + + src/Composer/Installers + + + \ No newline at end of file diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/AglInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/AglInstaller.php new file mode 100644 index 000000000..01b8a4165 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/AglInstaller.php @@ -0,0 +1,21 @@ + 'More/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) { + return strtoupper($matches[1]); + }, $vars['name']); + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php new file mode 100644 index 000000000..79a0e958f --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php @@ -0,0 +1,9 @@ + 'ext/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php new file mode 100644 index 000000000..89d7ad905 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php @@ -0,0 +1,11 @@ + 'addons/modules/{$name}/', + 'component' => 'addons/components/{$name}/', + 'service' => 'addons/services/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php new file mode 100644 index 000000000..995ee2b49 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php @@ -0,0 +1,45 @@ + 'Modules/{$name}/', + 'theme' => 'Themes/{$name}/' + ); + + /** + * Format package name. + * + * For package type asgard-module, cut off a trailing '-plugin' if present. + * + * For package type asgard-theme, cut off a trailing '-theme' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'asgard-module') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'asgard-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = ucfirst(preg_replace('/-module/', '', $vars['name'])); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = ucfirst(preg_replace('/-theme$/', '', $vars['name'])); + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php new file mode 100644 index 000000000..cc27d3e28 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php @@ -0,0 +1,131 @@ +composer = $composer; + $this->package = $package; + } + + /** + * Return the install path based on package type. + * + * @param PackageInterface $package + * @param string $frameworkType + * @return string + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + $type = $this->package->getType(); + + $prettyName = $this->package->getPrettyName(); + if (strpos($prettyName, '/') !== false) { + list($vendor, $name) = explode('/', $prettyName); + } else { + $vendor = ''; + $name = $prettyName; + } + + $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type')); + + $extra = $package->getExtra(); + if (!empty($extra['installer-name'])) { + $availableVars['name'] = $extra['installer-name']; + } + + if ($this->composer->getPackage()) { + $extra = $this->composer->getPackage()->getExtra(); + if (!empty($extra['installer-paths'])) { + $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type); + if ($customPath !== false) { + return $this->templatePath($customPath, $availableVars); + } + } + } + + $packageType = substr($type, strlen($frameworkType) + 1); + $locations = $this->getLocations(); + if (!isset($locations[$packageType])) { + throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type)); + } + + return $this->templatePath($locations[$packageType], $availableVars); + } + + /** + * For an installer to override to modify the vars per installer. + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + return $vars; + } + + /** + * Gets the installer's locations + * + * @return array + */ + public function getLocations() + { + return $this->locations; + } + + /** + * Replace vars in a path + * + * @param string $path + * @param array $vars + * @return string + */ + protected function templatePath($path, array $vars = array()) + { + if (strpos($path, '{') !== false) { + extract($vars); + preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches); + if (!empty($matches[1])) { + foreach ($matches[1] as $var) { + $path = str_replace('{$' . $var . '}', $$var, $path); + } + } + } + + return $path; + } + + /** + * Search through a passed paths array for a custom install path. + * + * @param array $paths + * @param string $name + * @param string $type + * @return string + */ + protected function mapCustomInstallPaths(array $paths, $name, $type) + { + foreach ($paths as $path => $names) { + if (in_array($name, $names) || in_array('type:' . $type, $names)) { + return $path; + } + } + + return false; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php new file mode 100644 index 000000000..48a8367ab --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php @@ -0,0 +1,11 @@ + 'local/modules/{$name}/', + 'component' => 'local/components/{$name}/', + 'theme' => 'local/templates/{$name}/' + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php new file mode 100644 index 000000000..cbeb60b80 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php @@ -0,0 +1,78 @@ + 'Plugin/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + if ($this->matchesCakeVersion('>=', '3.0.0')) { + return $vars; + } + + $nameParts = explode('/', $vars['name']); + foreach ($nameParts as &$value) { + $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); + $value = str_replace(array('-', '_'), ' ', $value); + $value = str_replace(' ', '', ucwords($value)); + } + $vars['name'] = implode('/', $nameParts); + + return $vars; + } + + /** + * Change the default plugin location when cakephp >= 3.0 + */ + public function getLocations() + { + if ($this->matchesCakeVersion('>=', '3.0.0')) { + $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; + } + return $this->locations; + } + + /** + * Check if CakePHP version matches against a version + * + * @param string $matcher + * @param string $version + * @return bool + */ + protected function matchesCakeVersion($matcher, $version) + { + $repositoryManager = $this->composer->getRepositoryManager(); + if ($repositoryManager) { + $repos = $repositoryManager->getLocalRepository(); + if (!$repos) { + return false; + } + $cake3 = new MultiConstraint(array( + new VersionConstraint($matcher, $version), + new VersionConstraint('!=', '9999999-dev'), + )); + $pool = new Pool('dev'); + $pool->addRepository($repos); + $packages = $pool->whatProvides('cakephp/cakephp'); + foreach ($packages as $package) { + $installed = new VersionConstraint('=', $package->getVersion()); + if ($cake3->matches($installed)) { + return true; + break; + } + } + } + return false; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php new file mode 100644 index 000000000..ab2f9aad8 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php @@ -0,0 +1,11 @@ + 'Chef/{$vendor}/{$name}/', + 'role' => 'Chef/roles/{$name}/', + ); +} + diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php new file mode 100644 index 000000000..c887815c9 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php @@ -0,0 +1,10 @@ + 'CCF/orbit/{$name}/', + 'theme' => 'CCF/app/themes/{$name}/', + ); +} \ No newline at end of file diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php new file mode 100644 index 000000000..3b4a4ece1 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php @@ -0,0 +1,11 @@ + 'application/libraries/{$name}/', + 'third-party' => 'application/third_party/{$name}/', + 'module' => 'application/modules/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php new file mode 100644 index 000000000..4d398a445 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php @@ -0,0 +1,12 @@ + 'blocks/{$name}/', + 'package' => 'packages/{$name}/', + 'theme' => 'themes/{$name}/', + 'update' => 'updates/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php new file mode 100644 index 000000000..dc3be8d1a --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php @@ -0,0 +1,9 @@ + 'craft/plugins/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php new file mode 100644 index 000000000..d94219d3a --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php @@ -0,0 +1,21 @@ + 'Plugin/{$name}/', + 'theme' => 'View/Themed/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name'])); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php new file mode 100644 index 000000000..cfd638d5f --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php @@ -0,0 +1,50 @@ + 'lib/plugins/{$name}/', + 'template' => 'lib/tpl/{$name}/', + ); + + /** + * Format package name. + * + * For package type dokuwiki-plugin, cut off a trailing '-plugin', + * or leading dokuwiki_ if present. + * + * For package type dokuwiki-template, cut off a trailing '-template' if present. + * + */ + public function inflectPackageVars($vars) + { + + if ($vars['type'] === 'dokuwiki-plugin') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'dokuwiki-template') { + return $this->inflectTemplateVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']); + $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']); + + return $vars; + } + + protected function inflectTemplateVars($vars) + { + $vars['name'] = preg_replace('/-template$/', '', $vars['name']); + $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']); + + return $vars; + } + +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php new file mode 100644 index 000000000..21f7e8e80 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php @@ -0,0 +1,16 @@ + + */ +class DolibarrInstaller extends BaseInstaller +{ + //TODO: Add support for scripts and themes + protected $locations = array( + 'module' => 'htdocs/custom/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php new file mode 100644 index 000000000..179413145 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php @@ -0,0 +1,14 @@ + 'core/', + 'module' => 'modules/{$name}/', + 'theme' => 'themes/{$name}/', + 'library' => 'libraries/{$name}/', + 'profile' => 'profiles/{$name}/', + 'drush' => 'drush/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php new file mode 100644 index 000000000..c0bb609f4 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php @@ -0,0 +1,9 @@ + 'mod/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php new file mode 100644 index 000000000..6eba2e34f --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php @@ -0,0 +1,11 @@ + 'fuel/app/modules/{$name}/', + 'package' => 'fuel/packages/{$name}/', + 'theme' => 'fuel/app/themes/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php new file mode 100644 index 000000000..29d980b30 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php @@ -0,0 +1,9 @@ + 'components/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/GravInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/GravInstaller.php new file mode 100644 index 000000000..dbe63e07e --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/GravInstaller.php @@ -0,0 +1,30 @@ + 'user/plugins/{$name}/', + 'theme' => 'user/themes/{$name}/', + ); + + /** + * Format package name + * + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $restrictedWords = implode('|', array_keys($this->locations)); + + $vars['name'] = strtolower($vars['name']); + $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui', + '$1', + $vars['name'] + ); + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php new file mode 100644 index 000000000..8fe017f0f --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php @@ -0,0 +1,25 @@ + 'plugins/{$name}/', + 'theme' => 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $nameParts = explode('/', $vars['name']); + foreach ($nameParts as &$value) { + $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); + $value = str_replace(array('-', '_'), ' ', $value); + $value = str_replace(' ', '', ucwords($value)); + } + $vars['name'] = implode('/', $nameParts); + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/Installer.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/Installer.php new file mode 100644 index 000000000..63ba64ce3 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/Installer.php @@ -0,0 +1,163 @@ + 'AimeosInstaller', + 'asgard' => 'AsgardInstaller', + 'agl' => 'AglInstaller', + 'annotatecms' => 'AnnotateCmsInstaller', + 'bitrix' => 'BitrixInstaller', + 'cakephp' => 'CakePHPInstaller', + 'chef' => 'ChefInstaller', + 'ccframework' => 'ClanCatsFrameworkInstaller', + 'codeigniter' => 'CodeIgniterInstaller', + 'concrete5' => 'Concrete5Installer', + 'craft' => 'CraftInstaller', + 'croogo' => 'CroogoInstaller', + 'dokuwiki' => 'DokuWikiInstaller', + 'dolibarr' => 'DolibarrInstaller', + 'drupal' => 'DrupalInstaller', + 'elgg' => 'ElggInstaller', + 'fuel' => 'FuelInstaller', + 'fuelphp' => 'FuelphpInstaller', + 'grav' => 'GravInstaller', + 'hurad' => 'HuradInstaller', + 'joomla' => 'JoomlaInstaller', + 'kirby' => 'KirbyInstaller', + 'kohana' => 'KohanaInstaller', + 'laravel' => 'LaravelInstaller', + 'lithium' => 'LithiumInstaller', + 'magento' => 'MagentoInstaller', + 'mako' => 'MakoInstaller', + 'mediawiki' => 'MediaWikiInstaller', + 'microweber' => 'MicroweberInstaller', + 'modulework' => 'MODULEWorkInstaller', + 'modxevo' => 'MODXEvoInstaller', + 'moodle' => 'MoodleInstaller', + 'october' => 'OctoberInstaller', + 'oxid' => 'OxidInstaller', + 'phpbb' => 'PhpBBInstaller', + 'pimcore' => 'PimcoreInstaller', + 'piwik' => 'PiwikInstaller', + 'ppi' => 'PPIInstaller', + 'puppet' => 'PuppetInstaller', + 'redaxo' => 'RedaxoInstaller', + 'roundcube' => 'RoundcubeInstaller', + 'shopware' => 'ShopwareInstaller', + 'silverstripe' => 'SilverStripeInstaller', + 'smf' => 'SMFInstaller', + 'symfony1' => 'Symfony1Installer', + 'thelia' => 'TheliaInstaller', + 'tusk' => 'TuskInstaller', + 'typo3-cms' => 'TYPO3CmsInstaller', + 'typo3-flow' => 'TYPO3FlowInstaller', + 'whmcs' => 'WHMCSInstaller', + 'wolfcms' => 'WolfCMSInstaller', + 'wordpress' => 'WordPressInstaller', + 'zend' => 'ZendInstaller', + 'zikula' => 'ZikulaInstaller', + 'prestashop' => 'PrestashopInstaller', + ); + + /** + * {@inheritDoc} + */ + public function getInstallPath(PackageInterface $package) + { + $type = $package->getType(); + $frameworkType = $this->findFrameworkType($type); + + if ($frameworkType === false) { + throw new \InvalidArgumentException( + 'Sorry the package type of this package is not yet supported.' + ); + } + + $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; + $installer = new $class($package, $this->composer); + + return $installer->getInstallPath($package, $frameworkType); + } + + public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) + { + if (!$repo->hasPackage($package)) { + throw new \InvalidArgumentException('Package is not installed: '.$package); + } + + $repo->removePackage($package); + + $installPath = $this->getInstallPath($package); + $this->io->write(sprintf('Deleting %s - %s', $installPath, $this->filesystem->removeDirectory($installPath) ? 'deleted' : 'not deleted')); + } + + /** + * {@inheritDoc} + */ + public function supports($packageType) + { + $frameworkType = $this->findFrameworkType($packageType); + + if ($frameworkType === false) { + return false; + } + + $locationPattern = $this->getLocationPattern($frameworkType); + + return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1; + } + + /** + * Finds a supported framework type if it exists and returns it + * + * @param string $type + * @return string + */ + protected function findFrameworkType($type) + { + $frameworkType = false; + + krsort($this->supportedTypes); + + foreach ($this->supportedTypes as $key => $val) { + if ($key === substr($type, 0, strlen($key))) { + $frameworkType = substr($type, 0, strlen($key)); + break; + } + } + + return $frameworkType; + } + + /** + * Get the second part of the regular expression to check for support of a + * package type + * + * @param string $frameworkType + * @return string + */ + protected function getLocationPattern($frameworkType) + { + $pattern = false; + if (!empty($this->supportedTypes[$frameworkType])) { + $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; + /** @var BaseInstaller $framework */ + $framework = new $frameworkClass(null, $this->composer); + $locations = array_keys($framework->getLocations()); + $pattern = $locations ? '(' . implode('|', $locations) . ')' : false; + } + + return $pattern ? : '(\w+)'; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php new file mode 100644 index 000000000..9ee775965 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php @@ -0,0 +1,15 @@ + 'components/{$name}/', + 'module' => 'modules/{$name}/', + 'template' => 'templates/{$name}/', + 'plugin' => 'plugins/{$name}/', + 'library' => 'libraries/{$name}/', + ); + + // TODO: Add inflector for mod_ and com_ names +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php new file mode 100644 index 000000000..ae7ba8a4b --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php @@ -0,0 +1,9 @@ + 'site/plugins/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php new file mode 100644 index 000000000..dcd6d2632 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php new file mode 100644 index 000000000..be4d53a7b --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php @@ -0,0 +1,9 @@ + 'libraries/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php new file mode 100644 index 000000000..47bbd4cab --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php @@ -0,0 +1,10 @@ + 'libraries/{$name}/', + 'source' => 'libraries/_source/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php new file mode 100644 index 000000000..9c2e9fb40 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php new file mode 100644 index 000000000..5a664608d --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php @@ -0,0 +1,16 @@ + 'assets/snippets/{$name}/', + 'plugin' => 'assets/plugins/{$name}/', + 'module' => 'assets/modules/{$name}/', + 'template' => 'assets/templates/{$name}/', + 'lib' => 'assets/lib/{$name}/' + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php new file mode 100644 index 000000000..cf18e9478 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php @@ -0,0 +1,11 @@ + 'app/design/frontend/{$name}/', + 'skin' => 'skin/frontend/default/{$name}/', + 'library' => 'lib/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php new file mode 100644 index 000000000..ca3cfacb4 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php @@ -0,0 +1,9 @@ + 'app/packages/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php new file mode 100644 index 000000000..01008c638 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php @@ -0,0 +1,50 @@ + 'extensions/{$name}/', + 'skin' => 'skins/{$name}/', + ); + + /** + * Format package name. + * + * For package type mediawiki-extension, cut off a trailing '-extension' if present and transform + * to CamelCase keeping existing uppercase chars. + * + * For package type mediawiki-skin, cut off a trailing '-skin' if present. + * + */ + public function inflectPackageVars($vars) + { + + if ($vars['type'] === 'mediawiki-extension') { + return $this->inflectExtensionVars($vars); + } + + if ($vars['type'] === 'mediawiki-skin') { + return $this->inflectSkinVars($vars); + } + + return $vars; + } + + protected function inflectExtensionVars($vars) + { + $vars['name'] = preg_replace('/-extension$/', '', $vars['name']); + $vars['name'] = str_replace('-', ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + + protected function inflectSkinVars($vars) + { + $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); + + return $vars; + } + +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php new file mode 100644 index 000000000..4bbbec8c0 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php @@ -0,0 +1,111 @@ + 'userfiles/modules/{$name}/', + 'module-skin' => 'userfiles/modules/{$name}/templates/', + 'template' => 'userfiles/templates/{$name}/', + 'element' => 'userfiles/elements/{$name}/', + 'vendor' => 'vendor/{$name}/', + 'components' => 'components/{$name}/' + ); + + /** + * Format package name. + * + * For package type microweber-module, cut off a trailing '-module' if present + * + * For package type microweber-template, cut off a trailing '-template' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'microweber-template') { + return $this->inflectTemplateVars($vars); + } + if ($vars['type'] === 'microweber-templates') { + return $this->inflectTemplatesVars($vars); + } + if ($vars['type'] === 'microweber-core') { + return $this->inflectCoreVars($vars); + } + if ($vars['type'] === 'microweber-adapter') { + return $this->inflectCoreVars($vars); + } + if ($vars['type'] === 'microweber-module') { + return $this->inflectModuleVars($vars); + } + if ($vars['type'] === 'microweber-modules') { + return $this->inflectModulesVars($vars); + } + if ($vars['type'] === 'microweber-skin') { + return $this->inflectSkinVars($vars); + } + if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') { + return $this->inflectElementVars($vars); + } + + return $vars; + } + + protected function inflectTemplateVars($vars) + { + $vars['name'] = preg_replace('/-template$/', '', $vars['name']); + $vars['name'] = preg_replace('/template-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectTemplatesVars($vars) + { + $vars['name'] = preg_replace('/-templates$/', '', $vars['name']); + $vars['name'] = preg_replace('/templates-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectCoreVars($vars) + { + $vars['name'] = preg_replace('/-providers$/', '', $vars['name']); + $vars['name'] = preg_replace('/-provider$/', '', $vars['name']); + $vars['name'] = preg_replace('/-adapter$/', '', $vars['name']); + + return $vars; + } + + protected function inflectModuleVars($vars) + { + $vars['name'] = preg_replace('/-module$/', '', $vars['name']); + $vars['name'] = preg_replace('/module-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectModulesVars($vars) + { + $vars['name'] = preg_replace('/-modules$/', '', $vars['name']); + $vars['name'] = preg_replace('/modules-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectSkinVars($vars) + { + $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); + $vars['name'] = preg_replace('/skin-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectElementVars($vars) + { + $vars['name'] = preg_replace('/-elements$/', '', $vars['name']); + $vars['name'] = preg_replace('/elements-$/', '', $vars['name']); + $vars['name'] = preg_replace('/-element$/', '', $vars['name']); + $vars['name'] = preg_replace('/element-$/', '', $vars['name']); + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php new file mode 100644 index 000000000..04be73c2a --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php @@ -0,0 +1,47 @@ + 'mod/{$name}/', + 'admin_report' => 'admin/report/{$name}/', + 'tool' => 'admin/tool/{$name}/', + 'assignment' => 'mod/assignment/type/{$name}/', + 'assignsubmission' => 'mod/assign/submission/{$name}/', + 'assignfeedback' => 'mod/assign/feedback/{$name}/', + 'auth' => 'auth/{$name}/', + 'availability' => 'availability/condition/{$name}/', + 'block' => 'blocks/{$name}/', + 'calendartype' => 'calendar/type/{$name}/', + 'format' => 'course/format/{$name}/', + 'coursereport' => 'course/report/{$name}/', + 'datafield' => 'mod/data/field/{$name}/', + 'datapreset' => 'mod/data/preset/{$name}/', + 'editor' => 'lib/editor/{$name}/', + 'enrol' => 'enrol/{$name}/', + 'filter' => 'filter/{$name}/', + 'gradeexport' => 'grade/export/{$name}/', + 'gradeimport' => 'grade/import/{$name}/', + 'gradereport' => 'grade/report/{$name}/', + 'gradingform' => 'grade/grading/form/{$name}/', + 'local' => 'local/{$name}/', + 'message' => 'message/output/{$name}/', + 'plagiarism' => 'plagiarism/{$name}/', + 'portfolio' => 'portfolio/{$name}/', + 'qbehaviour' => 'question/behaviour/{$name}/', + 'qformat' => 'question/format/{$name}/', + 'qtype' => 'question/type/{$name}/', + 'quizaccess' => 'mod/quiz/accessrule/{$name}/', + 'quiz' => 'mod/quiz/report/{$name}/', + 'report' => 'report/{$name}/', + 'repository' => 'repository/{$name}/', + 'scormreport' => 'mod/scorm/report/{$name}/', + 'theme' => 'theme/{$name}/', + 'profilefield' => 'user/profile/field/{$name}/', + 'webservice' => 'webservice/{$name}/', + 'workshopallocation' => 'mod/workshop/allocation/{$name}/', + 'workshopeval' => 'mod/workshop/eval/{$name}/', + 'workshopform' => 'mod/workshop/form/{$name}/' + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php new file mode 100644 index 000000000..6bf53fd14 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php @@ -0,0 +1,46 @@ + 'modules/{$name}/', + 'plugin' => 'plugins/{$vendor}/{$name}/', + 'theme' => 'themes/{$name}/' + ); + + /** + * Format package name. + * + * For package type october-plugin, cut off a trailing '-plugin' if present. + * + * For package type october-theme, cut off a trailing '-theme' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'october-plugin') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'october-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); + + return $vars; + } +} \ No newline at end of file diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php new file mode 100644 index 000000000..22fb56aa1 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php @@ -0,0 +1,11 @@ + 'modules/{$name}/', + 'theme' => 'application/views/{$name}/', + 'out' => 'out/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php new file mode 100644 index 000000000..170136f98 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php new file mode 100644 index 000000000..deb2b77a6 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php @@ -0,0 +1,11 @@ + 'ext/{$vendor}/{$name}/', + 'language' => 'language/{$name}/', + 'style' => 'styles/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php new file mode 100644 index 000000000..4781fa6d1 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php @@ -0,0 +1,21 @@ + 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php new file mode 100644 index 000000000..c17f4572b --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php @@ -0,0 +1,32 @@ + 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php new file mode 100644 index 000000000..4c8421e36 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php @@ -0,0 +1,10 @@ + 'modules/{$name}/', + 'theme' => 'themes/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php new file mode 100644 index 000000000..77cc3dd87 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php @@ -0,0 +1,11 @@ + 'modules/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php new file mode 100644 index 000000000..09544576b --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php @@ -0,0 +1,10 @@ + 'redaxo/include/addons/{$name}/', + 'bestyle-plugin' => 'redaxo/include/addons/be_style/plugins/{$name}/' + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php new file mode 100644 index 000000000..d8d795be0 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php @@ -0,0 +1,22 @@ + 'plugins/{$name}/', + ); + + /** + * Lowercase name and changes the name to a underscores + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(str_replace('-', '_', $vars['name'])); + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php new file mode 100644 index 000000000..1acd3b14c --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php @@ -0,0 +1,10 @@ + 'Sources/{$name}/', + 'theme' => 'Themes/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php new file mode 100644 index 000000000..673f1fc1f --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php @@ -0,0 +1,58 @@ + 'engine/Shopware/Plugins/Local/Backend/{$name}/', + 'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/', + 'frontend-plugin' => 'engine/Shopware/Plugins/Local/Frontend/{$name}/', + 'theme' => 'templates/{$name}/' + ); + + /** + * Transforms the names + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'shopware-theme') { + return $this->correctThemeName($vars); + } else { + return $this->correctPluginName($vars); + } + } + + /** + * Changes the name to a camelcased combination of vendor and name + * @param array $vars + * @return array + */ + private function correctPluginName($vars) + { + $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, $vars['name']); + + $vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName); + + return $vars; + } + + /** + * Changes the name to a underscore separated name + * @param array $vars + * @return array + */ + private function correctThemeName($vars) + { + $vars['name'] = str_replace('-', '_', $vars['name']); + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php new file mode 100644 index 000000000..17ca543a2 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php @@ -0,0 +1,36 @@ + '{$name}/', + 'theme' => 'themes/{$name}/', + ); + + /** + * Return the install path based on package type. + * + * Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework + * must be installed to 'sapphire' and not 'framework' if the version is <3.0.0 + * + * @param PackageInterface $package + * @param string $frameworkType + * @return string + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + if ( + $package->getName() == 'silverstripe/framework' + && preg_match('/^\d+\.\d+\.\d+/', $package->getVersion()) + && version_compare($package->getVersion(), '2.999.999') < 0 + ) { + return $this->templatePath($this->locations['module'], array('name' => 'sapphire')); + } else { + return parent::getInstallPath($package, $frameworkType); + } + + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php new file mode 100644 index 000000000..1675c4f21 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php @@ -0,0 +1,26 @@ + + */ +class Symfony1Installer extends BaseInstaller +{ + protected $locations = array( + 'plugin' => 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, $vars['name']); + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php new file mode 100644 index 000000000..8220b40df --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php @@ -0,0 +1,14 @@ + + */ +class TYPO3CmsInstaller extends BaseInstaller +{ + protected $locations = array( + 'extension' => 'typo3conf/ext/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php new file mode 100644 index 000000000..42572f44f --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php @@ -0,0 +1,38 @@ + 'Packages/Application/{$name}/', + 'framework' => 'Packages/Framework/{$name}/', + 'plugin' => 'Packages/Plugins/{$name}/', + 'site' => 'Packages/Sites/{$name}/', + 'boilerplate' => 'Packages/Boilerplates/{$name}/', + 'build' => 'Build/{$name}/', + ); + + /** + * Modify the package name to be a TYPO3 Flow style key. + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + $autoload = $this->package->getAutoload(); + if (isset($autoload['psr-0']) && is_array($autoload['psr-0'])) { + $namespace = key($autoload['psr-0']); + $vars['name'] = str_replace('\\', '.', $namespace); + } + if (isset($autoload['psr-4']) && is_array($autoload['psr-4'])) { + $namespace = key($autoload['psr-4']); + $vars['name'] = rtrim(str_replace('\\', '.', $namespace), '.'); + } + + return $vars; + } +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php new file mode 100644 index 000000000..158af5261 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php @@ -0,0 +1,12 @@ + 'local/modules/{$name}/', + 'frontoffice-template' => 'templates/frontOffice/{$name}/', + 'backoffice-template' => 'templates/backOffice/{$name}/', + 'email-template' => 'templates/email/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php new file mode 100644 index 000000000..7c0113b85 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php @@ -0,0 +1,14 @@ + + */ + class TuskInstaller extends BaseInstaller + { + protected $locations = array( + 'task' => '.tusk/tasks/{$name}/', + 'command' => '.tusk/commands/{$name}/', + 'asset' => 'assets/tusk/{$name}/', + ); + } diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php new file mode 100644 index 000000000..2cbb4a463 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php @@ -0,0 +1,10 @@ + 'modules/gateways/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php new file mode 100644 index 000000000..cb387881d --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php @@ -0,0 +1,9 @@ + 'wolf/plugins/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php new file mode 100644 index 000000000..b03219c69 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php @@ -0,0 +1,11 @@ + 'wp-content/plugins/{$name}/', + 'theme' => 'wp-content/themes/{$name}/', + 'muplugin' => 'wp-content/mu-plugins/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php new file mode 100644 index 000000000..bde9bc8c8 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php @@ -0,0 +1,11 @@ + 'library/{$name}/', + 'extra' => 'extras/library/{$name}/', + 'module' => 'module/{$name}/', + ); +} diff --git a/web/api/app/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php b/web/api/app/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php new file mode 100644 index 000000000..56cdf5da7 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php @@ -0,0 +1,10 @@ + 'modules/{$vendor}-{$name}/', + 'theme' => 'themes/{$vendor}-{$name}/' + ); +} diff --git a/web/api/app/vendor/composer/installers/src/bootstrap.php b/web/api/app/vendor/composer/installers/src/bootstrap.php new file mode 100644 index 000000000..0de276ee2 --- /dev/null +++ b/web/api/app/vendor/composer/installers/src/bootstrap.php @@ -0,0 +1,13 @@ +installer = new AsgardInstaller( + new Package('NyanCat', '4.2', '4.2'), + new Composer() + ); + } + + /** + * @dataProvider packageNameInflectionProvider + */ + public function testInflectPackageVars($type, $name, $expected) + { + $this->assertEquals( + $this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)), + array('name' => $expected, 'type' => $type) + ); + } + + public function packageNameInflectionProvider() + { + return array( + array( + 'asgard-module', + 'asgard-module', + 'Asgard' + ), + array( + 'asgard-module', + 'blog', + 'Blog' + ), + // tests that exactly one '-theme' is cut off + array( + 'asgard-theme', + 'some-theme-theme', + 'Some-theme', + ), + // tests that names without '-theme' suffix stay valid + array( + 'asgard-theme', + 'someothertheme', + 'Someothertheme', + ), + ); + } +} diff --git a/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php new file mode 100644 index 000000000..976bd9be8 --- /dev/null +++ b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php @@ -0,0 +1,115 @@ +package = new Package('CamelCased', '1.0', '1.0'); + $this->io = $this->getMock('Composer\IO\PackageInterface'); + $this->composer = new Composer(); + $this->composer->setConfig(new Config(false)); + } + + /** + * testInflectPackageVars + * + * @return void + */ + public function testInflectPackageVars() + { + $installer = new CakePHPInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'CamelCased')); + $this->assertEquals($result, array('name' => 'CamelCased')); + + $installer = new CakePHPInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'with-dash')); + $this->assertEquals($result, array('name' => 'WithDash')); + + $installer = new CakePHPInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'with_underscore')); + $this->assertEquals($result, array('name' => 'WithUnderscore')); + + $installer = new CakePHPInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'cake/acl')); + $this->assertEquals($result, array('name' => 'Cake/Acl')); + + $installer = new CakePHPInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'cake/debug-kit')); + $this->assertEquals($result, array('name' => 'Cake/DebugKit')); + } + + /** + * Test getLocations returning appropriate values based on CakePHP version + * + */ + public function testGetLocations() { + $package = new RootPackage('CamelCased', '1.0', '1.0'); + $composer = $this->composer; + $rm = new RepositoryManager( + $this->getMock('Composer\IO\IOInterface'), + $this->getMock('Composer\Config') + ); + $composer->setRepositoryManager($rm); + $installer = new CakePHPInstaller($package, $composer); + + // 2.0 < cakephp < 3.0 + $this->setCakephpVersion($rm, '2.0.0'); + $result = $installer->getLocations(); + $this->assertContains('Plugin/', $result['plugin']); + + $this->setCakephpVersion($rm, '2.5.9'); + $result = $installer->getLocations(); + $this->assertContains('Plugin/', $result['plugin']); + + $this->setCakephpVersion($rm, '~2.5'); + $result = $installer->getLocations(); + $this->assertContains('Plugin/', $result['plugin']); + + // special handling for 2.x versions when 3.x is still in development + $this->setCakephpVersion($rm, 'dev-master'); + $result = $installer->getLocations(); + $this->assertContains('Plugin/', $result['plugin']); + + $this->setCakephpVersion($rm, '>=2.5'); + $result = $installer->getLocations(); + $this->assertContains('Plugin/', $result['plugin']); + + // cakephp >= 3.0 + $this->setCakephpVersion($rm, '3.0.*-dev'); + $result = $installer->getLocations(); + $this->assertContains('vendor/{$vendor}/{$name}/', $result['plugin']); + + $this->setCakephpVersion($rm, '~8.8'); + $result = $installer->getLocations(); + $this->assertEquals('vendor/{$vendor}/{$name}/', $result['plugin']); + } + + protected function setCakephpVersion($rm, $version) { + $parser = new VersionParser(); + list(, $version) = explode(' ', $parser->parseConstraints($version)); + $installed = new InstalledArrayRepository(); + $package = new Package('cakephp/cakephp', $version, $version); + $installed->addPackage($package); + $rm->setLocalRepository($installed); + } + +} diff --git a/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php new file mode 100644 index 000000000..9e385e6a8 --- /dev/null +++ b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/DokuWikiInstallerTest.php @@ -0,0 +1,89 @@ +installer = new DokuWikiInstaller( + new Package('NyanCat', '4.2', '4.2'), + new Composer() + ); + } + + /** + * @dataProvider packageNameInflectionProvider + */ + public function testInflectPackageVars($type, $name, $expected) + { + $this->assertEquals( + $this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)), + array('name' => $expected, 'type'=>$type) + ); + } + + public function packageNameInflectionProvider() + { + return array( + array( + 'dokuwiki-plugin', + 'dokuwiki-test-plugin', + 'test', + ), + array( + 'dokuwiki-plugin', + 'test-plugin', + 'test', + ), + array( + 'dokuwiki-plugin', + 'dokuwiki_test', + 'test', + ), + array( + 'dokuwiki-plugin', + 'test', + 'test', + ), + array( + 'dokuwiki-plugin', + 'test-template', + 'test-template', + ), + array( + 'dokuwiki-template', + 'dokuwiki-test-template', + 'test', + ), + array( + 'dokuwiki-template', + 'test-template', + 'test', + ), + array( + 'dokuwiki-template', + 'dokuwiki_test', + 'test', + ), + array( + 'dokuwiki-template', + 'test', + 'test', + ), + array( + 'dokuwiki-template', + 'test-plugin', + 'test-plugin', + ), + ); + } +} diff --git a/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php new file mode 100644 index 000000000..b757799b4 --- /dev/null +++ b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php @@ -0,0 +1,63 @@ +composer = new Composer(); + } + + public function testInflectPackageVars() + { + $package = $this->getPackage('vendor/name', '0.0.0'); + $installer = new GravInstaller($package, $this->composer); + $packageVars = $this->getPackageVars($package); + + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => 'test'))); + $this->assertEquals('test', $result['name']); + + foreach ($installer->getLocations() as $name => $location) { + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test"))); + $this->assertEquals('test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-$name"))); + $this->assertEquals('test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test-test"))); + $this->assertEquals('test-test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-test-$name"))); + $this->assertEquals('test-test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test"))); + $this->assertEquals('test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-$name"))); + $this->assertEquals('test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test-test"))); + $this->assertEquals('test-test', $result['name']); + $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-test-$name"))); + $this->assertEquals('test-test', $result['name']); + } + } + + /** + * @param $package \Composer\Package\PackageInterface + */ + public function getPackageVars($package) + { + $type = $package->getType(); + + $prettyName = $package->getPrettyName(); + if (strpos($prettyName, '/') !== false) { + list($vendor, $name) = explode('/', $prettyName); + } else { + $vendor = ''; + $name = $prettyName; + } + + return compact('name', 'vendor', 'type'); + } +} diff --git a/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php new file mode 100644 index 000000000..a516daf07 --- /dev/null +++ b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php @@ -0,0 +1,422 @@ +fs = new Filesystem; + + $this->composer = new Composer(); + $this->config = new Config(); + $this->composer->setConfig($this->config); + + $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-vendor'; + $this->ensureDirectoryExistsAndClear($this->vendorDir); + + $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-bin'; + $this->ensureDirectoryExistsAndClear($this->binDir); + + $this->config->merge(array( + 'config' => array( + 'vendor-dir' => $this->vendorDir, + 'bin-dir' => $this->binDir, + ), + )); + + $this->dm = $this->getMockBuilder('Composer\Downloader\DownloadManager') + ->disableOriginalConstructor() + ->getMock(); + $this->composer->setDownloadManager($this->dm); + + $this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); + $this->io = $this->getMock('Composer\IO\IOInterface'); + } + + /** + * tearDown + * + * @return void + */ + public function tearDown() + { + $this->fs->removeDirectory($this->vendorDir); + $this->fs->removeDirectory($this->binDir); + } + + /** + * testSupports + * + * @return void + * + * @dataProvider dataForTestSupport + */ + public function testSupports($type, $expected) + { + $installer = new Installer($this->io, $this->composer); + $this->assertSame($expected, $installer->supports($type), sprintf('Failed to show support for %s', $type)); + } + + /** + * dataForTestSupport + */ + public function dataForTestSupport() + { + return array( + array('agl-module', true), + array('aimeos-extension', true), + array('annotatecms-module', true), + array('annotatecms-component', true), + array('annotatecms-service', true), + array('bitrix-module', true), + array('bitrix-component', true), + array('bitrix-theme', true), + array('cakephp', false), + array('cakephp-', false), + array('cakephp-app', false), + array('cakephp-plugin', true), + array('chef-cookbook', true), + array('chef-role', true), + array('codeigniter-app', false), + array('codeigniter-library', true), + array('codeigniter-third-party', true), + array('codeigniter-module', true), + array('concrete5-block', true), + array('concrete5-package', true), + array('concrete5-theme', true), + array('concrete5-update', true), + array('craft-plugin', true), + array('croogo-plugin', true), + array('croogo-theme', true), + array('dokuwiki-plugin', true), + array('dokuwiki-template', true), + array('drupal-module', true), + array('dolibarr-module', true), + array('elgg-plugin', true), + array('fuel-module', true), + array('fuel-package', true), + array('fuel-theme', true), + array('fuelphp-component', true), + array('hurad-plugin', true), + array('hurad-theme', true), + array('joomla-library', true), + array('kirby-plugin', true), + array('kohana-module', true), + array('laravel-library', true), + array('lithium-library', true), + array('magento-library', true), + array('mako-package', true), + array('modxevo-snippet', true), + array('modxevo-plugin', true), + array('modxevo-module', true), + array('modxevo-template', true), + array('modxevo-lib', true), + array('mediawiki-extension', true), + array('mediawiki-skin', true), + array('microweber-module', true), + array('modulework-module', true), + array('moodle-mod', true), + array('october-module', true), + array('october-plugin', true), + array('piwik-plugin', true), + array('phpbb-extension', true), + array('pimcore-plugin', true), + array('ppi-module', true), + array('prestashop-module', true), + array('prestashop-theme', true), + array('puppet-module', true), + array('redaxo-addon', true), + array('redaxo-bestyle-plugin', true), + array('roundcube-plugin', true), + array('shopware-backend-plugin', true), + array('shopware-core-plugin', true), + array('shopware-frontend-plugin', true), + array('shopware-theme', true), + array('silverstripe-module', true), + array('silverstripe-theme', true), + array('smf-module', true), + array('smf-theme', true), + array('symfony1-plugin', true), + array('thelia-module', true), + array('thelia-frontoffice-template', true), + array('thelia-backoffice-template', true), + array('thelia-email-template', true), + array('tusk-task', true), + array('tusk-asset', true), + array('typo3-flow-plugin', true), + array('typo3-cms-extension', true), + array('whmcs-gateway', true), + array('wolfcms-plugin', true), + array('wordpress-plugin', true), + array('wordpress-core', false), + array('zend-library', true), + array('zikula-module', true), + array('zikula-theme', true), + ); + } + + /** + * testInstallPath + * + * @dataProvider dataForTestInstallPath + */ + public function testInstallPath($type, $path, $name, $version = '1.0.0') + { + $installer = new Installer($this->io, $this->composer); + $package = new Package($name, $version, $version); + + $package->setType($type); + $result = $installer->getInstallPath($package); + $this->assertEquals($path, $result); + } + + /** + * dataFormTestInstallPath + */ + public function dataForTestInstallPath() + { + return array( + array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'), + array('aimeos-extension', 'ext/ai-test/', 'author/ai-test'), + array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'), + array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'), + array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'), + array('bitrix-module', 'local/modules/my_module/', 'author/my_module'), + array('bitrix-component', 'local/components/my_component/', 'author/my_component'), + array('bitrix-theme', 'local/templates/my_theme/', 'author/my_theme'), + array('cakephp-plugin', 'Plugin/Ftp/', 'shama/ftp'), + array('chef-cookbook', 'Chef/mre/my_cookbook/', 'mre/my_cookbook'), + array('chef-role', 'Chef/roles/my_role/', 'mre/my_role'), + array('codeigniter-library', 'application/libraries/my_package/', 'shama/my_package'), + array('codeigniter-module', 'application/modules/my_package/', 'shama/my_package'), + array('concrete5-block', 'blocks/concrete5_block/', 'remo/concrete5_block'), + array('concrete5-package', 'packages/concrete5_package/', 'remo/concrete5_package'), + array('concrete5-theme', 'themes/concrete5_theme/', 'remo/concrete5_theme'), + array('concrete5-update', 'updates/concrete5/', 'concrete5/concrete5'), + array('craft-plugin', 'craft/plugins/my_plugin/', 'mdcpepper/my_plugin'), + array('croogo-plugin', 'Plugin/Sitemaps/', 'fahad19/sitemaps'), + array('croogo-theme', 'View/Themed/Readable/', 'rchavik/readable'), + array('dokuwiki-plugin', 'lib/plugins/someplugin/', 'author/someplugin'), + array('dokuwiki-template', 'lib/tpl/sometemplate/', 'author/sometemplate'), + array('dolibarr-module', 'htdocs/custom/my_module/', 'shama/my_module'), + array('drupal-module', 'modules/my_module/', 'shama/my_module'), + array('drupal-theme', 'themes/my_module/', 'shama/my_module'), + array('drupal-profile', 'profiles/my_module/', 'shama/my_module'), + array('drupal-drush', 'drush/my_module/', 'shama/my_module'), + array('elgg-plugin', 'mod/sample_plugin/', 'test/sample_plugin'), + array('fuel-module', 'fuel/app/modules/module/', 'fuel/module'), + array('fuel-package', 'fuel/packages/orm/', 'fuel/orm'), + array('fuel-theme', 'fuel/app/themes/theme/', 'fuel/theme'), + array('fuelphp-component', 'components/demo/', 'fuelphp/demo'), + array('hurad-plugin', 'plugins/Akismet/', 'atkrad/akismet'), + array('hurad-theme', 'plugins/Hurad2013/', 'atkrad/Hurad2013'), + array('joomla-plugin', 'plugins/my_plugin/', 'shama/my_plugin'), + array('kirby-plugin', 'site/plugins/my_plugin/', 'shama/my_plugin'), + array('kohana-module', 'modules/my_package/', 'shama/my_package'), + array('laravel-library', 'libraries/my_package/', 'shama/my_package'), + array('lithium-library', 'libraries/li3_test/', 'user/li3_test'), + array('magento-library', 'lib/foo/', 'test/foo'), + array('modxevo-snippet', 'assets/snippets/my_snippet/', 'shama/my_snippet'), + array('modxevo-plugin', 'assets/plugins/my_plugin/', 'shama/my_plugin'), + array('modxevo-module', 'assets/modules/my_module/', 'shama/my_module'), + array('modxevo-template', 'assets/templates/my_template/', 'shama/my_template'), + array('modxevo-lib', 'assets/lib/my_lib/', 'shama/my_lib'), + array('mako-package', 'app/packages/my_package/', 'shama/my_package'), + array('mediawiki-extension', 'extensions/APC/', 'author/APC'), + array('mediawiki-extension', 'extensions/APC/', 'author/APC-extension'), + array('mediawiki-extension', 'extensions/UploadWizard/', 'author/upload-wizard'), + array('mediawiki-extension', 'extensions/SyntaxHighlight_GeSHi/', 'author/syntax-highlight_GeSHi'), + array('mediawiki-skin', 'skins/someskin/', 'author/someskin-skin'), + array('mediawiki-skin', 'skins/someskin/', 'author/someskin'), + array('microweber-module', 'userfiles/modules/my-thing/', 'author/my-thing-module'), + array('modulework-module', 'modules/my_package/', 'shama/my_package'), + array('moodle-mod', 'mod/my_package/', 'shama/my_package'), + array('october-module', 'modules/my_plugin/', 'shama/my_plugin'), + array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'), + array('october-theme', 'themes/my_theme/', 'shama/my_theme'), + array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'), + array('prestashop-module', 'modules/a-module/', 'vendor/a-module'), + array('prestashop-theme', 'themes/a-theme/', 'vendor/a-theme'), + array('phpbb-extension', 'ext/test/foo/', 'test/foo'), + array('phpbb-style', 'styles/foo/', 'test/foo'), + array('phpbb-language', 'language/foo/', 'test/foo'), + array('pimcore-plugin', 'plugins/MyPlugin/', 'ubikz/my_plugin'), + array('ppi-module', 'modules/foo/', 'test/foo'), + array('puppet-module', 'modules/puppet-name/', 'puppet/puppet-name'), + array('redaxo-addon', 'redaxo/include/addons/my_plugin/', 'shama/my_plugin'), + array('redaxo-bestyle-plugin', 'redaxo/include/addons/be_style/plugins/my_plugin/', 'shama/my_plugin'), + array('roundcube-plugin', 'plugins/base/', 'test/base'), + array('roundcube-plugin', 'plugins/replace_dash/', 'test/replace-dash'), + array('shopware-backend-plugin', 'engine/Shopware/Plugins/Local/Backend/ShamaMyBackendPlugin/', 'shama/my-backend-plugin'), + array('shopware-core-plugin', 'engine/Shopware/Plugins/Local/Core/ShamaMyCorePlugin/', 'shama/my-core-plugin'), + array('shopware-frontend-plugin', 'engine/Shopware/Plugins/Local/Frontend/ShamaMyFrontendPlugin/', 'shama/my-frontend-plugin'), + array('shopware-theme', 'templates/my_theme/', 'shama/my-theme'), + array('silverstripe-module', 'my_module/', 'shama/my_module'), + array('silverstripe-module', 'sapphire/', 'silverstripe/framework', '2.4.0'), + array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0'), + array('silverstripe-module', 'framework/', 'silverstripe/framework', '3.0.0-rc1'), + array('silverstripe-module', 'framework/', 'silverstripe/framework', 'my/branch'), + array('silverstripe-theme', 'themes/my_theme/', 'shama/my_theme'), + array('smf-module', 'Sources/my_module/', 'shama/my_module'), + array('smf-theme', 'Themes/my_theme/', 'shama/my_theme'), + array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sfShamaPlugin'), + array('symfony1-plugin', 'plugins/sfShamaPlugin/', 'shama/sf-shama-plugin'), + array('thelia-module', 'local/modules/my_module/', 'shama/my_module'), + array('thelia-frontoffice-template', 'templates/frontOffice/my_template_fo/', 'shama/my_template_fo'), + array('thelia-backoffice-template', 'templates/backOffice/my_template_bo/', 'shama/my_template_bo'), + array('thelia-email-template', 'templates/email/my_template_email/', 'shama/my_template_email'), + array('tusk-task', '.tusk/tasks/my_task/', 'shama/my_task'), + array('typo3-flow-package', 'Packages/Application/my_package/', 'shama/my_package'), + array('typo3-flow-build', 'Build/my_package/', 'shama/my_package'), + array('typo3-cms-extension', 'typo3conf/ext/my_extension/', 'shama/my_extension'), + array('whmcs-gateway', 'modules/gateways/gateway_name/', 'vendor/gateway_name'), + array('wolfcms-plugin', 'wolf/plugins/my_plugin/', 'shama/my_plugin'), + array('wordpress-plugin', 'wp-content/plugins/my_plugin/', 'shama/my_plugin'), + array('wordpress-muplugin', 'wp-content/mu-plugins/my_plugin/', 'shama/my_plugin'), + array('zend-extra', 'extras/library/zend_test/', 'shama/zend_test'), + array('zikula-module', 'modules/my-test_module/', 'my/test_module'), + array('zikula-theme', 'themes/my-test_theme/', 'my/test_theme'), + ); + } + + /** + * testGetCakePHPInstallPathException + * + * @return void + * + * @expectedException \InvalidArgumentException + */ + public function testGetCakePHPInstallPathException() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('shama/ftp', '1.0.0', '1.0.0'); + + $package->setType('cakephp-whoops'); + $result = $installer->getInstallPath($package); + } + + /** + * testCustomInstallPath + */ + public function testCustomInstallPath() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('shama/ftp', '1.0.0', '1.0.0'); + $package->setType('cakephp-plugin'); + $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0'); + $this->composer->setPackage($consumerPackage); + $consumerPackage->setExtra(array( + 'installer-paths' => array( + 'my/custom/path/{$name}/' => array( + 'shama/ftp', + 'foo/bar', + ), + ), + )); + $result = $installer->getInstallPath($package); + $this->assertEquals('my/custom/path/Ftp/', $result); + } + + /** + * testCustomInstallerName + */ + public function testCustomInstallerName() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('shama/cakephp-ftp-plugin', '1.0.0', '1.0.0'); + $package->setType('cakephp-plugin'); + $package->setExtra(array( + 'installer-name' => 'FTP', + )); + $result = $installer->getInstallPath($package); + $this->assertEquals('Plugin/FTP/', $result); + } + + /** + * testCustomTypePath + */ + public function testCustomTypePath() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('slbmeh/my_plugin', '1.0.0', '1.0.0'); + $package->setType('wordpress-plugin'); + $consumerPackage = new RootPackage('foo/bar', '1.0.0', '1.0.0'); + $this->composer->setPackage($consumerPackage); + $consumerPackage->setExtra(array( + 'installer-paths' => array( + 'my/custom/path/{$name}/' => array( + 'type:wordpress-plugin' + ), + ), + )); + $result = $installer->getInstallPath($package); + $this->assertEquals('my/custom/path/my_plugin/', $result); + } + + /** + * testNoVendorName + */ + public function testNoVendorName() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('sfPhpunitPlugin', '1.0.0', '1.0.0'); + + $package->setType('symfony1-plugin'); + $result = $installer->getInstallPath($package); + $this->assertEquals('plugins/sfPhpunitPlugin/', $result); + } + + /** + * testTypo3Inflection + */ + public function testTypo3Inflection() + { + $installer = new Installer($this->io, $this->composer); + $package = new Package('typo3/fluid', '1.0.0', '1.0.0'); + + $package->setAutoload(array( + 'psr-0' => array( + 'TYPO3\\Fluid' => 'Classes', + ), + )); + + $package->setType('typo3-flow-package'); + $result = $installer->getInstallPath($package); + $this->assertEquals('Packages/Application/TYPO3.Fluid/', $result); + } + + public function testUninstallAndDeletePackageFromLocalRepo() + { + $package = new Package('foo', '1.0.0', '1.0.0'); + + $installer = $this->getMock('Composer\Installers\Installer', array('getInstallPath'), array($this->io, $this->composer)); + $installer->expects($this->once())->method('getInstallPath')->with($package)->will($this->returnValue(sys_get_temp_dir().'/foo')); + + $repo = $this->getMock('Composer\Repository\InstalledRepositoryInterface'); + $repo->expects($this->once())->method('hasPackage')->with($package)->will($this->returnValue(true)); + $repo->expects($this->once())->method('removePackage')->with($package); + + $installer->uninstall($repo, $package); + } +} diff --git a/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php new file mode 100644 index 000000000..3675e188b --- /dev/null +++ b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/MediaWikiInstallerTest.php @@ -0,0 +1,66 @@ +installer = new MediaWikiInstaller( + new Package('NyanCat', '4.2', '4.2'), + new Composer() + ); + } + + /** + * @dataProvider packageNameInflectionProvider + */ + public function testInflectPackageVars($type, $name, $expected) + { + $this->assertEquals( + $this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)), + array('name' => $expected, 'type'=>$type) + ); + } + + public function packageNameInflectionProvider() + { + return array( + array( + 'mediawiki-extension', + 'sub-page-list', + 'SubPageList', + ), + array( + 'mediawiki-extension', + 'sub-page-list-extension', + 'SubPageList', + ), + array( + 'mediawiki-extension', + 'semantic-mediawiki', + 'SemanticMediawiki', + ), + // tests that exactly one '-skin' is cut off, and that skins do not get ucwords treatment like extensions + array( + 'mediawiki-skin', + 'some-skin-skin', + 'some-skin', + ), + // tests that names without '-skin' suffix stay valid + array( + 'mediawiki-skin', + 'someotherskin', + 'someotherskin', + ), + ); + } +} diff --git a/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php new file mode 100644 index 000000000..fd427cdc3 --- /dev/null +++ b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/OctoberInstallerTest.php @@ -0,0 +1,66 @@ +installer = new OctoberInstaller( + new Package('NyanCat', '4.2', '4.2'), + new Composer() + ); + } + + /** + * @dataProvider packageNameInflectionProvider + */ + public function testInflectPackageVars($type, $name, $expected) + { + $this->assertEquals( + $this->installer->inflectPackageVars(array('name' => $name, 'type' => $type)), + array('name' => $expected, 'type' => $type) + ); + } + + public function packageNameInflectionProvider() + { + return array( + array( + 'october-plugin', + 'subpagelist', + 'subpagelist', + ), + array( + 'october-plugin', + 'subpagelist-plugin', + 'subpagelist', + ), + array( + 'october-plugin', + 'semanticoctober', + 'semanticoctober', + ), + // tests that exactly one '-theme' is cut off + array( + 'october-theme', + 'some-theme-theme', + 'some-theme', + ), + // tests that names without '-theme' suffix stay valid + array( + 'october-theme', + 'someothertheme', + 'someothertheme', + ), + ); + } +} \ No newline at end of file diff --git a/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php new file mode 100644 index 000000000..ea79374bf --- /dev/null +++ b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/PimcoreInstallerTest.php @@ -0,0 +1,44 @@ +package = new Package('CamelCased', '1.0', '1.0'); + $this->io = $this->getMock('Composer\IO\PackageInterface'); + $this->composer = new Composer(); + } + + /** + * testInflectPackageVars + * + * @return void + */ + public function testInflectPackageVars() + { + $installer = new PimcoreInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'CamelCased')); + $this->assertEquals($result, array('name' => 'CamelCased')); + + $installer = new PimcoreInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'with-dash')); + $this->assertEquals($result, array('name' => 'WithDash')); + + $installer = new PimcoreInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'with_underscore')); + $this->assertEquals($result, array('name' => 'WithUnderscore')); + } +} diff --git a/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php new file mode 100644 index 000000000..8d9ff3f82 --- /dev/null +++ b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/PiwikInstallerTest.php @@ -0,0 +1,63 @@ +package = new Package('VisitSummary', '1.0', '1.0'); + $this->io = $this->getMock('Composer\IO\PackageInterface'); + $this->composer = new Composer(); + } + + /** + * testInflectPackageVars + * + * @return void + */ + public function testInflectPackageVars() + { + $installer = new PiwikInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'VisitSummary')); + $this->assertEquals($result, array('name' => 'VisitSummary')); + + $installer = new PiwikInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'visit-summary')); + $this->assertEquals($result, array('name' => 'VisitSummary')); + + $installer = new PiwikInstaller($this->package, $this->composer); + $result = $installer->inflectPackageVars(array('name' => 'visit_summary')); + $this->assertEquals($result, array('name' => 'VisitSummary')); + } + +} diff --git a/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php new file mode 100644 index 000000000..6418a03b8 --- /dev/null +++ b/web/api/app/vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php @@ -0,0 +1,64 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Installers\Test; + +use Composer\Package\Version\VersionParser; +use Composer\Package\Package; +use Composer\Package\AliasPackage; +use Composer\Package\LinkConstraint\VersionConstraint; +use Composer\Util\Filesystem; + +abstract class TestCase extends \PHPUnit_Framework_TestCase +{ + private static $parser; + + protected static function getVersionParser() + { + if (!self::$parser) { + self::$parser = new VersionParser(); + } + + return self::$parser; + } + + protected function getVersionConstraint($operator, $version) + { + return new VersionConstraint( + $operator, + self::getVersionParser()->normalize($version) + ); + } + + protected function getPackage($name, $version) + { + $normVersion = self::getVersionParser()->normalize($version); + + return new Package($name, $normVersion, $version); + } + + protected function getAliasPackage($package, $version) + { + $normVersion = self::getVersionParser()->normalize($version); + + return new AliasPackage($package, $normVersion, $version); + } + + protected function ensureDirectoryExistsAndClear($directory) + { + $fs = new Filesystem(); + if (is_dir($directory)) { + $fs->removeDirectory($directory); + } + mkdir($directory, 0777, true); + } +} diff --git a/web/api/app/vendor/composer/installers/tests/bootstrap.php b/web/api/app/vendor/composer/installers/tests/bootstrap.php new file mode 100644 index 000000000..30c8fdc67 --- /dev/null +++ b/web/api/app/vendor/composer/installers/tests/bootstrap.php @@ -0,0 +1,4 @@ +add('Composer\Installers\Test', __DIR__); diff --git a/web/api/app/webroot/.htaccess b/web/api/app/webroot/.htaccess index 1f19e4c06..f08afa8b2 100644 --- a/web/api/app/webroot/.htaccess +++ b/web/api/app/webroot/.htaccess @@ -3,4 +3,5 @@ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] + RewriteBase /zm/api diff --git a/web/api/cmake_install.cmake b/web/api/cmake_install.cmake new file mode 100644 index 000000000..677eb9b9f --- /dev/null +++ b/web/api/cmake_install.cmake @@ -0,0 +1,34 @@ +# Install script for directory: /home/ubuntu/zm/ZoneMinder/web/api + +# Set the install prefix +IF(NOT DEFINED CMAKE_INSTALL_PREFIX) + SET(CMAKE_INSTALL_PREFIX "/usr/local") +ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX) +STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# Set the install configuration name. +IF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) + IF(BUILD_TYPE) + STRING(REGEX REPLACE "^[^A-Za-z0-9_]+" "" + CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") + ELSE(BUILD_TYPE) + SET(CMAKE_INSTALL_CONFIG_NAME "Release") + ENDIF(BUILD_TYPE) + MESSAGE(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") +ENDIF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) + +# Set the component getting installed. +IF(NOT CMAKE_INSTALL_COMPONENT) + IF(COMPONENT) + MESSAGE(STATUS "Install component: \"${COMPONENT}\"") + SET(CMAKE_INSTALL_COMPONENT "${COMPONENT}") + ELSE(COMPONENT) + SET(CMAKE_INSTALL_COMPONENT) + ENDIF(COMPONENT) +ENDIF(NOT CMAKE_INSTALL_COMPONENT) + +# Install shared libraries without execute permission? +IF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) + SET(CMAKE_INSTALL_SO_NO_EXE "1") +ENDIF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) +