Merge pull request #882 from pliablepixels/881-merge-angularui-apis

Merged Angular UI branch API to master
pull/884/head
Isaac Connor 2015-06-12 11:06:59 -04:00
commit ecb7720056
149 changed files with 5677 additions and 102 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "web/api/app/Plugin/Crud"]
path = web/api/app/Plugin/Crud
url = https://github.com/FriendsOfCake/crud.git

View File

@ -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})

View File

@ -0,0 +1 @@
0

View File

@ -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:

387
web/api/app/Config/core.php Normal file
View File

@ -0,0 +1,387 @@
<?php
/**
* This is core configuration file.
*
* Use it to configure core behavior of Cake.
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.Config
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* CakePHP Debug Level:
*
* Production Mode:
* 0: No error messages, errors, or warnings shown. Flash messages redirect.
*
* Development Mode:
* 1: Errors and warnings shown, model caches refreshed, flash messages halted.
* 2: As in 1, but also with full debug messages and SQL output.
*
* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/
Configure::write('debug', 2);
/**
* Configure the Error handler used to handle errors for your application. By default
* ErrorHandler::handleError() is used. It will display errors using Debugger, when debug > 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/<name>.php.
* Make sure the class implements `CakeSessionHandlerInterface` and set Session.handler to <name>
*
* 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
));

View File

@ -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();
/**

View File

@ -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']
]
];
}

View File

@ -24,7 +24,7 @@ class ConfigParserComponent extends Component {
public function getInput($name, $type, $id) {
if ($type == 'checkbox') {
$string = '<input id="%s" type="checkbox" ng-change="updateConfig(\'%s\', \'%s\')" ng-model="myModel.configData[\'%s\']" ng-true-value="1" ng-false-value="0"><span class="form-control-feedback"></span></div>';
$string = '<input id="%s" type="checkbox" ng-change="updateConfig(\'%s\', \'%s\')" ng-model="myModel.configData[\'%s\']" ng-true-value="\'1\'" ng-false-value="\'0\'"><span class="form-control-feedback"></span></div>';
} elseif ($type == 'text') {
$string = '<input id="%s" type="text" ng-change="updateConfig(\'%s\', \'%s\')" ng-model="myModel.configData[\'%s\']" class="form-control"><span class="form-control-feedback"></span></div>';
} elseif ($type == 'textarea') {

View File

@ -0,0 +1,34 @@
<?php
App::uses('Component', 'Controller');
class FilterComponent extends Component {
// Build a CakePHP find() condition based on the named parameters
// that are passed in
public function buildFilter($namedParams) {
if ($namedParams) {
$conditions = array();
foreach ($namedParams as $attribute => $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;
}
}
?>

View File

@ -0,0 +1,89 @@
<?php
App::uses('Component', 'Controller');
class ImageComponent extends Component {
public function getImageSrc( $event, $frame, $scale, $config ) {
$eventPath = $this->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']) );
}
}
?>

View File

@ -0,0 +1,27 @@
<?php
App::uses('Component', 'Controller');
class ScalerComponent extends Component {
public function reScale( $dimension, $dummy ) {
for ( $i = 1; $i < func_num_args(); $i++ )
{
$scale = func_get_arg( $i );
if ( !empty($scale) && $scale != 100 )
$dimension = (int)(($dimension*$scale)/100);
}
return( $dimension );
}
public function deScale( $dimension, $dummy )
{
for ( $i = 1; $i < func_num_args(); $i++ )
{
$scale = func_get_arg( $i );
if ( !empty($scale) && $scale != 100 )
$dimension = (int)(($dimension*100)/$scale);
}
return( $dimension );
}
}
?>

View File

@ -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')
));
}
}

View File

@ -0,0 +1,59 @@
<?php
App::uses('AppController', 'Controller');
/**
* Controls Controller
*
* @property Control $Control
* @property PaginatorComponent $Paginator
*/
/*
We need a control API to get the PTZ parameters associated with a monitor
The monitor API returns a control ID which we then need to use to construct
an appropriate PTZ command to control PTZ operations
https://github.com/ZoneMinder/ZoneMinder/issues/799#issuecomment-105233112
*/
class ControlsController extends AppController {
/**
* Components
*
* @var array
*/
public $components = array('Paginator', 'RequestHandler');
/**
* index method
*
* @return void
*/
public function index() {
$this->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')
));
}
}

View File

@ -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')
));
}
}

View File

@ -0,0 +1,110 @@
<?php
App::uses('AppController', 'Controller');
class HostController extends AppController {
public $components = array('RequestHandler');
public function daemonCheck($daemon=false, $args=false) {
$string = Configure::read('ZM_PATH_BIN')."/zmdc.pl check";
if ( $daemon )
{
$string .= " $daemon";
if ( $args )
$string .= " $args";
}
$result = exec( $string );
$result = preg_match( '/running/', $result );
$this->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')
));
}
}

View File

@ -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'));
}
/**

View File

@ -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 );
}
}
}

View File

@ -0,0 +1,117 @@
<?php
App::uses('AppController', 'Controller');
/**
* States Controller
*
* @property State $State
* @property PaginatorComponent $Paginator
*/
class StatesController extends AppController {
public $components = array('RequestHandler');
/**
* index method
*
* @return void
*/
public function index() {
$this->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;
}
}

View File

@ -0,0 +1,99 @@
<?php
App::uses('AppController', 'Controller');
/**
* ZonePresets Controller
*
* @property ZonePreset $ZonePreset
* @property PaginatorComponent $Paginator
*/
class ZonePresetsController extends AppController {
/**
* Components
*
* @var array
*/
public $components = array('RequestHandler');
/**
* index method
*
* @return void
*/
public function index() {
$zonePresets = $this->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'));
}
}}

View File

@ -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')
));
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,54 @@
<?php
App::uses('AppModel', 'Model');
/**
* Control Model
* For PTZ table access via APIs
* https://github.com/ZoneMinder/ZoneMinder/issues/799#issuecomment-105233112
*
* @property Event $Event
* @property Zone $Zone
*/
class Control extends AppModel {
/**
* Use table
*
* @var mixed False or table name
*/
public $useTable = 'Controls';
/**
* Primary key field
*
* @var string
*/
public $primaryKey = 'Id';
/**
* Display field
*
* @var string
*/
public $displayField = 'Name';
public $recursive = -1;
/**
* Validation rules
*
* @var array
*/
public $validate = array(
'Id' => 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
),
),
);
}

View File

@ -121,4 +121,6 @@ class Frame extends AppModel {
'order' => ''
)
);
public $recursive = -1;
}

View File

@ -0,0 +1,9 @@
<?php
App::uses('AppModel', 'Model');
class Host extends AppModel {
public $useTable = false;
}

View File

@ -29,6 +29,8 @@ class Monitor extends AppModel {
*/
public $displayField = 'Name';
public $recursive = -1;
/**
* Validation rules
*

View File

@ -0,0 +1,30 @@
<?php
App::uses('AppModel', 'Model');
/**
* State Model
*
*/
class State extends AppModel {
/**
* Use table
*
* @var mixed False or table name
*/
public $useTable = 'States';
/**
* Primary key field
*
* @var string
*/
public $primaryKey = 'Name';
/**
* Display field
*
* @var string
*/
public $displayField = 'Name';
}

View File

@ -28,6 +28,7 @@ class Zone extends AppModel {
*/
public $displayField = 'Name';
public $recursive = -1;
//The Associations below have been created with all possible keys, those that are not needed can be removed

View File

@ -0,0 +1,30 @@
<?php
App::uses('AppModel', 'Model');
/**
* ZonePreset Model
*
*/
class ZonePreset extends AppModel {
/**
* Use table
*
* @var mixed False or table name
*/
public $useTable = 'ZonePresets';
/**
* Primary key field
*
* @var string
*/
public $primaryKey = 'Id';
/**
* Display field
*
* @var string
*/
public $displayField = 'Name';
}

@ -0,0 +1 @@
Subproject commit f1cf70ffff0657db29388eca94e6c5ea4944a164

View File

@ -1 +1,5 @@
echo json_encode($events);
<?php
$array['events'] = $events;
$array['pagination'] = $this->Paginator->params();
echo json_encode($array);
?>

View File

@ -0,0 +1,5 @@
<?php
$array['logs'] = $logs;
$array['pagination'] = $this->Paginator->params();
echo json_encode($array);
?>

View File

@ -0,0 +1 @@
echo json_encode($config);

View File

@ -0,0 +1 @@
echo json_encode($configs);

View File

@ -0,0 +1 @@
echo json_encode($config);

View File

@ -0,0 +1,2 @@
$xml = Xml::fromArray(array('response' => $configs));
echo $xml->asXML();

View File

@ -0,0 +1,2 @@
$xml = Xml::fromArray(array('response' => $config));
echo $xml->asXML();

View File

View File

@ -0,0 +1,25 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Emails.html
* @since CakePHP(tm) v 0.10.0.1076
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
?>
<?php
$content = explode("\n", $content);
foreach ($content as $line):
echo '<p> ' . $line . "</p>\n";
endforeach;
?>

View File

@ -0,0 +1,19 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Emails.text
* @since CakePHP(tm) v 0.10.0.1076
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
?>
<?php echo $content; ?>

View File

@ -0,0 +1,31 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Errors
* @since CakePHP(tm) v 0.10.0.1076
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
?>
<h2><?php echo $message; ?></h2>
<p class="error">
<strong><?php echo __d('cake', 'Error'); ?>: </strong>
<?php printf(
__d('cake', 'The requested address %s was not found on this server.'),
"<strong>'{$url}'</strong>"
); ?>
</p>
<?php
if (Configure::read('debug') > 0):
echo $this->element('exception_stack_trace');
endif;
?>

View File

@ -0,0 +1,28 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Errors
* @since CakePHP(tm) v 0.10.0.1076
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
?>
<h2><?php echo $message; ?></h2>
<p class="error">
<strong><?php echo __d('cake', 'Error'); ?>: </strong>
<?php echo __d('cake', 'An Internal Error Has Occurred.'); ?>
</p>
<?php
if (Configure::read('debug') > 0):
echo $this->element('exception_stack_trace');
endif;
?>

View File

@ -0,0 +1,5 @@
<?php
$array['events'] = $events;
$array['pagination'] = $this->Paginator->params();
echo json_encode($array);
?>

View File

@ -0,0 +1 @@
echo json_encode($event);

View File

@ -0,0 +1,2 @@
$xml = Xml::fromArray(array('response' => $events));
echo $xml->asXML();

View File

@ -0,0 +1,2 @@
$xml = Xml::fromArray(array('response' => $event));
echo $xml->asXML();

View File

@ -0,0 +1,33 @@
<?php
/**
* Application level View Helper
*
* This file is application-wide helper file. You can put all
* application-wide helper-related methods here.
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Helper
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('Helper', 'View');
/**
* Application helper
*
* Add your application-wide methods in the class below, your helpers
* will inherit them.
*
* @package app.View.Helper
*/
class AppHelper extends Helper {
}

View File

@ -0,0 +1,29 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Layouts.Email.html
* @since CakePHP(tm) v 0.10.0.1076
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title><?php echo $title_for_layout; ?></title>
</head>
<body>
<?php echo $this->fetch('content'); ?>
<p>This email was sent using the <a href="http://cakephp.org">CakePHP Framework</a></p>
</body>
</html>

View File

@ -0,0 +1,21 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Layouts.Email.text
* @since CakePHP(tm) v 0.10.0.1076
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
?>
<?php echo $this->fetch('content'); ?>
This email was sent using the CakePHP Framework, http://cakephp.org.

View File

@ -0,0 +1,19 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Layouts
* @since CakePHP(tm) v 0.10.0.1076
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
?>
<?php echo $this->fetch('content'); ?>

View File

@ -0,0 +1,65 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Layouts
* @since CakePHP(tm) v 0.10.0.1076
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
$cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework');
$cakeVersion = __d('cake_dev', 'CakePHP %s', Configure::version())
?>
<!DOCTYPE html>
<html>
<head>
<?php echo $this->Html->charset(); ?>
<title>
<?php echo $cakeDescription ?>:
<?php echo $title_for_layout; ?>
</title>
<?php
echo $this->Html->meta('icon');
echo $this->Html->css('cake.generic');
echo $this->fetch('meta');
echo $this->fetch('css');
echo $this->fetch('script');
?>
</head>
<body>
<div id="container">
<div id="header">
<h1><?php echo $this->Html->link($cakeDescription, 'http://cakephp.org'); ?></h1>
</div>
<div id="content">
<?php echo $this->Session->flash(); ?>
<?php echo $this->fetch('content'); ?>
</div>
<div id="footer">
<?php echo $this->Html->link(
$this->Html->image('cake.power.gif', array('alt' => $cakeDescription, 'border' => '0')),
'http://www.cakephp.org/',
array('target' => '_blank', 'escape' => false, 'id' => 'cake-powered')
);
?>
<p>
<?php echo $cakeVersion; ?>
</p>
</div>
</div>
<?php echo $this->element('sql_dump'); ?>
</body>
</html>

View File

@ -0,0 +1,61 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Layouts
* @since CakePHP(tm) v 0.10.0.1076
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
$cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework');
?>
<!DOCTYPE html>
<html>
<head>
<?php echo $this->Html->charset(); ?>
<title>
<?php echo $cakeDescription ?>:
<?php echo $title_for_layout; ?>
</title>
<?php
echo $this->Html->meta('icon');
echo $this->Html->css('cake.generic');
echo $this->fetch('meta');
echo $this->fetch('css');
echo $this->fetch('script');
?>
</head>
<body>
<div id="container">
<div id="header">
<h1><?php echo $this->Html->link($cakeDescription, 'http://cakephp.org'); ?></h1>
</div>
<div id="content">
<?php echo $this->Session->flash(); ?>
<?php echo $this->fetch('content'); ?>
</div>
<div id="footer">
<?php echo $this->Html->link(
$this->Html->image('cake.power.gif', array('alt' => $cakeDescription, 'border' => '0')),
'http://www.cakephp.org/',
array('target' => '_blank', 'escape' => false)
);
?>
</div>
</div>
<?php echo $this->element('sql_dump'); ?>
</body>
</html>

View File

@ -0,0 +1,37 @@
<?php
/**
*
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Layouts
* @since CakePHP(tm) v 0.10.0.1076
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
?>
<!DOCTYPE html>
<html>
<head>
<?php echo $this->Html->charset(); ?>
<title><?php echo $page_title; ?></title>
<?php if (Configure::read('debug') == 0): ?>
<meta http-equiv="Refresh" content="<?php echo $pause; ?>;url=<?php echo $url; ?>"/>
<?php endif; ?>
<style><!--
P { text-align:center; font:bold 1.1em sans-serif }
A { color:#444; text-decoration:none }
A:HOVER { text-decoration: underline; color:#44E }
--></style>
</head>
<body>
<p><a href="<?php echo $url; ?>"><?php echo $message; ?></a></p>
</body>
</html>

View File

@ -0,0 +1,2 @@
<?php echo $scripts_for_layout; ?>
<script type="text/javascript"><?php echo $this->fetch('content'); ?></script>

View File

@ -0,0 +1,14 @@
<?php
if (!isset($channel)):
$channel = array();
endif;
if (!isset($channel['title'])):
$channel['title'] = $title_for_layout;
endif;
echo $this->Rss->document(
$this->Rss->channel(
array(), $channel, $this->fetch('content')
)
);
?>

View File

@ -0,0 +1 @@
<?php echo $this->fetch('content'); ?>

View File

@ -0,0 +1,5 @@
<?php
$array['logs'] = $logs;
$array['pagination'] = $this->Paginator->params();
echo json_encode($array);
?>

View File

@ -0,0 +1,2 @@
echo json_encode($message);
echo json_encode($monitor);

View File

@ -0,0 +1 @@
echo json_encode($monitors);

View File

@ -0,0 +1 @@
echo json_encode($monitor);

View File

@ -0,0 +1,2 @@
$xml = Xml::fromArray(array('response' => $message));
echo $xml->asXML();

View File

@ -0,0 +1,2 @@
$xml = Xml::fromArray(array('response' => $monitors));
echo $xml->asXML();

View File

@ -0,0 +1,2 @@
$xml = Xml::fromArray(array('response' => $monitor));
echo $xml->asXML();

View File

@ -0,0 +1,233 @@
<?php
/**
*
*
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Pages
* @since CakePHP(tm) v 0.10.0.1076
*/
if (!Configure::read('debug')):
throw new NotFoundException();
endif;
App::uses('Debugger', 'Utility');
?>
<h2><?php echo __d('cake_dev', 'Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<p>
<a href="http://cakephp.org/changelogs/<?php echo Configure::version(); ?>"><?php echo __d('cake_dev', 'Read the changelog'); ?> </a>
</p>
<?php
if (Configure::read('debug') > 0):
Debugger::checkSecurityKeys();
endif;
?>
<?php
if (file_exists(WWW_ROOT . 'css' . DS . 'cake.generic.css')):
?>
<p id="url-rewriting-warning" style="background-color:#e32; color:#fff;">
<?php echo __d('cake_dev', 'URL rewriting is not properly configured on your server.'); ?>
1) <a target="_blank" href="http://book.cakephp.org/2.0/en/installation/url-rewriting.html" style="color:#fff;">Help me configure it</a>
2) <a target="_blank" href="http://book.cakephp.org/2.0/en/development/configuration.html#cakephp-core-configuration" style="color:#fff;">I don't / can't use URL rewriting</a>
</p>
<?php
endif;
?>
<p>
<?php
if (version_compare(PHP_VERSION, '5.2.8', '>=')):
echo '<span class="notice success">';
echo __d('cake_dev', 'Your version of PHP is 5.2.8 or higher.');
echo '</span>';
else:
echo '<span class="notice">';
echo __d('cake_dev', 'Your version of PHP is too low. You need PHP 5.2.8 or higher to use CakePHP.');
echo '</span>';
endif;
?>
</p>
<p>
<?php
if (is_writable(TMP)):
echo '<span class="notice success">';
echo __d('cake_dev', 'Your tmp directory is writable.');
echo '</span>';
else:
echo '<span class="notice">';
echo __d('cake_dev', 'Your tmp directory is NOT writable.');
echo '</span>';
endif;
?>
</p>
<p>
<?php
$settings = Cache::settings();
if (!empty($settings)):
echo '<span class="notice success">';
echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit %s', '<em>'. $settings['engine'] . 'Engine</em>', 'APP/Config/core.php');
echo '</span>';
else:
echo '<span class="notice">';
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in %s', 'APP/Config/core.php');
echo '</span>';
endif;
?>
</p>
<p>
<?php
$filePresent = null;
if (file_exists(APP . 'Config' . DS . 'database.php')):
echo '<span class="notice success">';
echo __d('cake_dev', 'Your database configuration file is present.');
$filePresent = true;
echo '</span>';
else:
echo '<span class="notice">';
echo __d('cake_dev', 'Your database configuration file is NOT present.');
echo '<br/>';
echo __d('cake_dev', 'Rename %s to %s', 'APP/Config/database.php.default', 'APP/Config/database.php');
echo '</span>';
endif;
?>
</p>
<?php
if (isset($filePresent)):
App::uses('ConnectionManager', 'Model');
try {
$connected = ConnectionManager::getDataSource('default');
} catch (Exception $connectionError) {
$connected = false;
$errorMsg = $connectionError->getMessage();
if (method_exists($connectionError, 'getAttributes')):
$attributes = $connectionError->getAttributes();
if (isset($errorMsg['message'])):
$errorMsg .= '<br />' . $attributes['message'];
endif;
endif;
}
?>
<p>
<?php
if ($connected && $connected->isConnected()):
echo '<span class="notice success">';
echo __d('cake_dev', 'CakePHP is able to connect to the database.');
echo '</span>';
else:
echo '<span class="notice">';
echo __d('cake_dev', 'CakePHP is NOT able to connect to the database.');
echo '<br /><br />';
echo $errorMsg;
echo '</span>';
endif;
?>
</p>
<?php endif; ?>
<?php
App::uses('Validation', 'Utility');
if (!Validation::alphaNumeric('cakephp')):
echo '<p><span class="notice">';
echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.');
echo '<br/>';
echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
echo '</span></p>';
endif;
?>
<p>
<?php
if (CakePlugin::loaded('DebugKit')):
echo '<span class="notice success">';
echo __d('cake_dev', 'DebugKit plugin is present');
echo '</span>';
else:
echo '<span class="notice">';
echo __d('cake_dev', 'DebugKit is not installed. It will help you inspect and debug different aspects of your application.');
echo '<br/>';
echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit'));
echo '</span>';
endif;
?>
</p>
<h3><?php echo __d('cake_dev', 'Editing this Page'); ?></h3>
<p>
<?php
echo __d('cake_dev', 'To change the content of this page, edit: %s.<br />
To change its layout, edit: %s.<br />
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');
?>
</p>
<h3><?php echo __d('cake_dev', 'Getting Started'); ?></h3>
<p>
<?php
echo $this->Html->link(
sprintf('<strong>%s</strong> %s', __d('cake_dev', 'New'), __d('cake_dev', 'CakePHP 2.0 Docs')),
'http://book.cakephp.org/2.0/en/',
array('target' => '_blank', 'escape' => false)
);
?>
</p>
<p>
<?php
echo $this->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)
);
?>
</p>
<h3><?php echo __d('cake_dev', 'Official Plugins'); ?></h3>
<p>
<ul>
<li>
<?php echo $this->Html->link('DebugKit', 'https://github.com/cakephp/debug_kit') ?>:
<?php echo __d('cake_dev', 'provides a debugging toolbar and enhanced debugging tools for CakePHP applications.'); ?>
</li>
<li>
<?php echo $this->Html->link('Localized', 'https://github.com/cakephp/localized') ?>:
<?php echo __d('cake_dev', 'contains various localized validation classes and translations for specific countries'); ?>
</li>
</ul>
</p>
<h3><?php echo __d('cake_dev', 'More about CakePHP'); ?></h3>
<p>
<?php echo __d('cake_dev', 'CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?>
</p>
<p>
<?php echo __d('cake_dev', 'Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.'); ?>
</p>
<ul>
<li><a href="http://cakephp.org">CakePHP</a>
<ul><li><?php echo __d('cake_dev', 'The Rapid Development Framework'); ?></li></ul></li>
<li><a href="http://book.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Documentation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Your Rapid Development Cookbook'); ?></li></ul></li>
<li><a href="http://api.cakephp.org"><?php echo __d('cake_dev', 'CakePHP API'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Quick API Reference'); ?></li></ul></li>
<li><a href="http://bakery.cakephp.org"><?php echo __d('cake_dev', 'The Bakery'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Everything CakePHP'); ?></li></ul></li>
<li><a href="http://plugins.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Plugins'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'A comprehensive list of all CakePHP plugins created by the community'); ?></li></ul></li>
<li><a href="http://community.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Community Center'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Everything related to the CakePHP community in one place'); ?></li></ul></li>
<li><a href="https://groups.google.com/group/cake-php"><?php echo __d('cake_dev', 'CakePHP Google Group'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Community mailing list'); ?></li></ul></li>
<li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a>
<ul><li><?php echo __d('cake_dev', 'Live chat about CakePHP'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/"><?php echo __d('cake_dev', 'CakePHP Code'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Find the CakePHP code on GitHub and contribute to the framework'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/cakephp/issues"><?php echo __d('cake_dev', 'CakePHP Issues'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP Issues'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/cakephp/wiki#roadmaps"><?php echo __d('cake_dev', 'CakePHP Roadmaps'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP Roadmaps'); ?></li></ul></li>
<li><a href="http://training.cakephp.org"><?php echo __d('cake_dev', 'Training'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Join a live session and get skilled with the framework'); ?></li></ul></li>
<li><a href="http://cakefest.org"><?php echo __d('cake_dev', 'CakeFest'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Don\'t miss our annual CakePHP conference'); ?></li></ul></li>
<li><a href="http://cakefoundation.org"><?php echo __d('cake_dev', 'Cake Software Foundation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Promoting development related to CakePHP'); ?></li></ul></li>
</ul>

View File

7
web/api/app/vendor/autoload.php vendored Normal file
View File

@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInitdfd8518a66bb8898e7b22470609a6c8f::getLoader();

View File

@ -0,0 +1,413 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* 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 <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
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;
}

View File

@ -0,0 +1,9 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

View File

@ -0,0 +1,10 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src'),
);

View File

@ -0,0 +1,9 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

View File

@ -0,0 +1,50 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitdfd8518a66bb8898e7b22470609a6c8f
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitdfd8518a66bb8898e7b22470609a6c8f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitdfd8518a66bb8898e7b22470609a6c8f', 'loadClassLoader'));
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $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;
}

View File

@ -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"
]
}
]

View File

@ -0,0 +1,10 @@
; top-most EditorConfig file
root = true
; Unix-style newlines
[*]
end_of_line = LF
[*.php]
indent_style = space
indent_size = 4

View File

@ -0,0 +1,3 @@
vendor/
composer.lock
.idea/

View File

@ -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

View File

@ -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.

View File

@ -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`<br>`asgard-theme`
| AGL | `agl-module`
| AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service`
| Bitrix | `bitrix-module`<br>`bitrix-component`<br>`bitrix-theme`
| CakePHP 2+ | **`cakephp-plugin`**
| Chef | `chef-cookbook`<br>`chef-role`
| CCFramework | `ccframework-ship`<br>`ccframework-theme`
| CodeIgniter | `codeigniter-library`<br>`codeigniter-third-party`<br>`codeigniter-module`
| concrete5 | `concrete5-block`<br>`concrete5-package`<br>`concrete5-theme`<br>`concrete5-update`
| Craft | `craft-plugin`
| Croogo | `croogo-plugin`<br>`croogo-theme`
| DokuWiki | `dokuwiki-plugin`<br>`dokuwiki-template`
| Dolibarr | `dolibarr-module`
| Drupal | <b>`drupal-module`<br>`drupal-theme`</b><br>`drupal-library`<br>`drupal-profile`<br>`drupal-drush`
| Elgg | `elgg-plugin`
| FuelPHP v1.x | `fuel-module`<br>`fuel-package`<br/>`fuel-theme`
| FuelPHP v2.x | `fuelphp-component`
| Grav | `grav-plugin`<br>`grav-theme`
| Hurad | `hurad-plugin`<br>`hurad-theme`
| Joomla | `joomla-component`<br>`joomla-module`<br>`joomla-template`<br>`joomla-plugin`<br>`joomla-library`
| Kirby | **`kirby-plugin`**
| Kohana | **`kohana-module`**
| Laravel | `laravel-library`
| Lithium | **`lithium-library`<br>`lithium-source`**
| Magento | `magento-library`<br>`magento-skin`<br>`magento-theme`
| Mako | `mako-package`
| MODX Evo | `modxevo-snippet`<br>`modxevo-plugin`<br>`modxevo-module`<br>`modxevo-template`<br>`modxevo-lib`
| MediaWiki | `mediawiki-extension`
| October | **`october-module`<br>`october-plugin`<br>`october-theme`**
| OXID | `oxid-module`<br>`oxid-theme`<br>`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`<br>`phpbb-style`<br>`phpbb-language`
| Pimcore | `pimcore-plugin`
| PPI | **`ppi-module`**
| Puppet | `puppet-module`
| REDAXO | `redaxo-addon`
| Roundcube | `roundcube-plugin`
| shopware | `shopware-backend-plugin`<br/>`shopware-core-plugin`<br/>`shopware-frontend-plugin`<br/>`shopware-theme`
| SilverStripe | `silverstripe-module`<br>`silverstripe-theme`
| SMF | `smf-module`<br>`smf-theme`
| symfony1 | **`symfony1-plugin`**
| Tusk | `tusk-task`<br>`tusk-command`<br>`tusk-asset`
| TYPO3 Flow | `typo3-flow-package`<br>`typo3-flow-framework`<br>`typo3-flow-plugin`<br>`typo3-flow-site`<br>`typo3-flow-boilerplate`<br>`typo3-flow-build`
| TYPO3 CMS | `typo3-cms-extension`
| Wolf CMS | `wolfcms-plugin`
| WordPress | <b>`wordpress-plugin`<br>`wordpress-theme`</b><br>`wordpress-muplugin`
| Zend | `zend-library`<br>`zend-extra`<br>`zend-module`
| Zikula | `zikula-module`<br>`zikula-theme`
| Prestashop | `prestashop-module`<br>`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.

View File

@ -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.*"
}
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>
<testsuites>
<testsuite name="Installers Test Suite">
<directory>tests/Composer/Installers</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src/Composer/Installers</directory>
</whitelist>
</filter>
</phpunit>

View File

@ -0,0 +1,21 @@
<?php
namespace Composer\Installers;
class AglInstaller extends BaseInstaller
{
protected $locations = array(
'module' => '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;
}
}

View File

@ -0,0 +1,9 @@
<?php
namespace Composer\Installers;
class AimeosInstaller extends BaseInstaller
{
protected $locations = array(
'extension' => 'ext/{$name}/',
);
}

View File

@ -0,0 +1,11 @@
<?php
namespace Composer\Installers;
class AnnotateCmsInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'addons/modules/{$name}/',
'component' => 'addons/components/{$name}/',
'service' => 'addons/services/{$name}/',
);
}

View File

@ -0,0 +1,45 @@
<?php
namespace Composer\Installers;
class AsgardInstaller extends BaseInstaller
{
protected $locations = array(
'module' => '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;
}
}

View File

@ -0,0 +1,131 @@
<?php
namespace Composer\Installers;
use Composer\Composer;
use Composer\Package\PackageInterface;
abstract class BaseInstaller
{
protected $locations = array();
protected $composer;
protected $package;
/**
* Initializes base installer.
*
* @param PackageInterface $package
* @param Composer $composer
*/
public function __construct(PackageInterface $package = null, Composer $composer = null)
{
$this->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;
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace Composer\Installers;
class BitrixInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'local/modules/{$name}/',
'component' => 'local/components/{$name}/',
'theme' => 'local/templates/{$name}/'
);
}

View File

@ -0,0 +1,78 @@
<?php
namespace Composer\Installers;
use Composer\DependencyResolver\Pool;
use Composer\Package\PackageInterface;
use Composer\Package\LinkConstraint\MultiConstraint;
use Composer\Package\LinkConstraint\VersionConstraint;
class CakePHPInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => '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;
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace Composer\Installers;
class ChefInstaller extends BaseInstaller
{
protected $locations = array(
'cookbook' => 'Chef/{$vendor}/{$name}/',
'role' => 'Chef/roles/{$name}/',
);
}

View File

@ -0,0 +1,10 @@
<?php
namespace Composer\Installers;
class ClanCatsFrameworkInstaller extends BaseInstaller
{
protected $locations = array(
'ship' => 'CCF/orbit/{$name}/',
'theme' => 'CCF/app/themes/{$name}/',
);
}

View File

@ -0,0 +1,11 @@
<?php
namespace Composer\Installers;
class CodeIgniterInstaller extends BaseInstaller
{
protected $locations = array(
'library' => 'application/libraries/{$name}/',
'third-party' => 'application/third_party/{$name}/',
'module' => 'application/modules/{$name}/',
);
}

View File

@ -0,0 +1,12 @@
<?php
namespace Composer\Installers;
class Concrete5Installer extends BaseInstaller
{
protected $locations = array(
'block' => 'blocks/{$name}/',
'package' => 'packages/{$name}/',
'theme' => 'themes/{$name}/',
'update' => 'updates/{$name}/',
);
}

View File

@ -0,0 +1,9 @@
<?php
namespace Composer\Installers;
class CraftInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'craft/plugins/{$name}/',
);
}

View File

@ -0,0 +1,21 @@
<?php
namespace Composer\Installers;
class CroogoInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => '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;
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace Composer\Installers;
class DokuWikiInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => '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;
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace Composer\Installers;
/**
* Class DolibarrInstaller
*
* @package Composer\Installers
* @author Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*/
class DolibarrInstaller extends BaseInstaller
{
//TODO: Add support for scripts and themes
protected $locations = array(
'module' => 'htdocs/custom/{$name}/',
);
}

View File

@ -0,0 +1,14 @@
<?php
namespace Composer\Installers;
class DrupalInstaller extends BaseInstaller
{
protected $locations = array(
'core' => 'core/',
'module' => 'modules/{$name}/',
'theme' => 'themes/{$name}/',
'library' => 'libraries/{$name}/',
'profile' => 'profiles/{$name}/',
'drush' => 'drush/{$name}/',
);
}

View File

@ -0,0 +1,9 @@
<?php
namespace Composer\Installers;
class ElggInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => 'mod/{$name}/',
);
}

View File

@ -0,0 +1,11 @@
<?php
namespace Composer\Installers;
class FuelInstaller extends BaseInstaller
{
protected $locations = array(
'module' => 'fuel/app/modules/{$name}/',
'package' => 'fuel/packages/{$name}/',
'theme' => 'fuel/app/themes/{$name}/',
);
}

View File

@ -0,0 +1,9 @@
<?php
namespace Composer\Installers;
class FuelphpInstaller extends BaseInstaller
{
protected $locations = array(
'component' => 'components/{$name}/',
);
}

View File

@ -0,0 +1,30 @@
<?php
namespace Composer\Installers;
class GravInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => '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;
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Composer\Installers;
class HuradInstaller extends BaseInstaller
{
protected $locations = array(
'plugin' => '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;
}
}

View File

@ -0,0 +1,163 @@
<?php
namespace Composer\Installers;
use Composer\Installer\LibraryInstaller;
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;
class Installer extends LibraryInstaller
{
/**
* Package types to installer class map
*
* @var array
*/
private $supportedTypes = array(
'aimeos' => '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) ? '<comment>deleted</comment>' : '<error>not deleted</error>'));
}
/**
* {@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+)';
}
}

Some files were not shown because too many files have changed in this diff Show More