mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Closes #2119 Only define clone() in PHP4 when it hasn't been already defined.
Closes #2213, Support multiple plugin paths. Closes #2234, filepaths to behavior classes should be cached in class.paths.php also Closes #2345, ability to group components into subfolders Closes #2645, Improvement to basic.php for class loading. Fixes #3526, Cache::write, when using just the config name, it fails. Fixes #3559, loading plugin model as assoc don't work. Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique) Fixes #3579, email.php component: Parse error with php 4. Adding new class and file importer. Updated most of the core to use the importer. Added ClassRegsitry::init() that will create and instance of an object and store it in the registry. Deprecated most of the load functions in basics.php Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model. var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set: var $uses = array('SomeModel'); will look for some_model.php in the app/models var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php All of the above will work between plugins and main app These changes also allow placing model and controllers is sub directories Removed old class.paths.php file generation git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
58d9d38be1
commit
c000940e36
40 changed files with 1065 additions and 756 deletions
541
cake/basics.php
541
cake/basics.php
|
@ -39,6 +39,7 @@
|
||||||
/**
|
/**
|
||||||
* Patch for PHP < 5.0
|
* Patch for PHP < 5.0
|
||||||
*/
|
*/
|
||||||
|
if (!function_exists('clone')) {
|
||||||
if (version_compare(phpversion(), '5.0') < 0) {
|
if (version_compare(phpversion(), '5.0') < 0) {
|
||||||
eval ('
|
eval ('
|
||||||
function clone($object)
|
function clone($object)
|
||||||
|
@ -46,6 +47,7 @@
|
||||||
return $object;
|
return $object;
|
||||||
}');
|
}');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Loads all models, or set of specified models.
|
* Loads all models, or set of specified models.
|
||||||
* E.g:
|
* E.g:
|
||||||
|
@ -98,154 +100,6 @@
|
||||||
}
|
}
|
||||||
return $loadedModels;
|
return $loadedModels;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Loads all plugin models.
|
|
||||||
*
|
|
||||||
* @param string $plugin Name of plugin
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
function loadPluginModels($plugin) {
|
|
||||||
if (!class_exists('AppModel')) {
|
|
||||||
loadModel();
|
|
||||||
}
|
|
||||||
$plugin = Inflector::underscore($plugin);
|
|
||||||
$pluginAppModel = Inflector::camelize($plugin . '_app_model');
|
|
||||||
$pluginAppModelFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_model.php';
|
|
||||||
|
|
||||||
if (!class_exists($pluginAppModel)) {
|
|
||||||
if (file_exists($pluginAppModelFile)) {
|
|
||||||
require($pluginAppModelFile);
|
|
||||||
Overloadable::overload($pluginAppModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$pluginModelDir = APP . 'plugins' . DS . $plugin . DS . 'models' . DS;
|
|
||||||
if (is_dir($pluginModelDir)) {
|
|
||||||
foreach (listClasses($pluginModelDir)as $modelFileName) {
|
|
||||||
list($name) = explode('.', $modelFileName);
|
|
||||||
$className = Inflector::camelize($name);
|
|
||||||
|
|
||||||
if (!class_exists($className)) {
|
|
||||||
require($pluginModelDir . $modelFileName);
|
|
||||||
Overloadable::overload($className);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Loads custom view class. Use dot notation to load a view class
|
|
||||||
* from a plugin, e.g: plugin.MyView
|
|
||||||
*
|
|
||||||
* @param string $viewClass Name of the view class to load (camelized)
|
|
||||||
* @return boolean Success
|
|
||||||
*/
|
|
||||||
function loadView($viewClass) {
|
|
||||||
if (strpos($viewClass, '.') !== false) {
|
|
||||||
list($plugin, $viewClass) = explode('.', $viewClass);
|
|
||||||
$file = APP . 'plugins' . DS . Inflector::underscore($plugin) . DS . 'views' . DS . Inflector::underscore($viewClass) . '.php';
|
|
||||||
if (file_exists($file)) {
|
|
||||||
require($file);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!class_exists($viewClass . 'View')) {
|
|
||||||
$paths = Configure::getInstance();
|
|
||||||
$file = Inflector::underscore($viewClass) . '.php';
|
|
||||||
|
|
||||||
foreach ($paths->viewPaths as $path) {
|
|
||||||
if (file_exists($path . $file)) {
|
|
||||||
return require($path . $file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($viewFile = fileExistsInPath(LIBS . 'view' . DS . $file)) {
|
|
||||||
if (file_exists($viewFile)) {
|
|
||||||
require($viewFile);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Loads a model by CamelCase name if specified, otherwise load model
|
|
||||||
* basic requirements (model and AppModel classes). Use dot notation
|
|
||||||
* to load a model located inside a plugin folder.
|
|
||||||
*
|
|
||||||
* @param $name Name of model to load
|
|
||||||
* @return boolean Success
|
|
||||||
*/
|
|
||||||
function loadModel($name = null) {
|
|
||||||
if (!class_exists('Model')) {
|
|
||||||
require LIBS . 'model' . DS . 'model.php';
|
|
||||||
}
|
|
||||||
if (!class_exists('AppModel')) {
|
|
||||||
if (file_exists(APP . 'app_model.php')) {
|
|
||||||
require(APP . 'app_model.php');
|
|
||||||
} else {
|
|
||||||
require(CAKE . 'app_model.php');
|
|
||||||
}
|
|
||||||
Overloadable::overload('AppModel');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strpos($name, '.') !== false) {
|
|
||||||
list($plugin, $name) = explode('.', $name);
|
|
||||||
$plugin = Inflector::underscore($plugin);
|
|
||||||
$pluginAppModel = Inflector::camelize($plugin . '_app_model');
|
|
||||||
$pluginAppModelFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_model.php';
|
|
||||||
|
|
||||||
if (!class_exists($pluginAppModel)) {
|
|
||||||
if (file_exists($pluginAppModelFile)) {
|
|
||||||
require($pluginAppModelFile);
|
|
||||||
Overloadable::overload($pluginAppModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!class_exists($name)) {
|
|
||||||
$className = $name;
|
|
||||||
$name = Inflector::underscore($name);
|
|
||||||
$path = APP . 'plugins' . DS . $plugin . DS . 'models' . DS;
|
|
||||||
if (file_exists($path . $name . '.php')) {
|
|
||||||
require($path . $name . '.php');
|
|
||||||
Overloadable::overload($className);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_null($name) && !class_exists($name)) {
|
|
||||||
$className = $name;
|
|
||||||
$name = Inflector::underscore($name);
|
|
||||||
$models = Configure::read('Models');
|
|
||||||
if (is_array($models)) {
|
|
||||||
if (array_key_exists($className, $models)) {
|
|
||||||
require($models[$className]['path']);
|
|
||||||
Overloadable::overload($className);
|
|
||||||
return true;
|
|
||||||
} elseif (isset($models['Core']) && array_key_exists($className, $models['Core'])) {
|
|
||||||
require($models['Core'][$className]['path']);
|
|
||||||
Overloadable::overload($className);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$paths = Configure::getInstance();
|
|
||||||
foreach ($paths->modelPaths as $path) {
|
|
||||||
if (file_exists($path . $name . '.php')) {
|
|
||||||
Configure::store('Models', 'class.paths', array($className => array('path' => $path . $name . '.php')));
|
|
||||||
require($path . $name . '.php');
|
|
||||||
Overloadable::overload($className);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Get CakePHP basic paths as an indexed array.
|
* Get CakePHP basic paths as an indexed array.
|
||||||
* Resulting array will contain array of paths
|
* Resulting array will contain array of paths
|
||||||
|
@ -275,7 +129,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!class_exists('Folder')) {
|
if (!class_exists('Folder')) {
|
||||||
uses('Folder');
|
App::import('Core', 'Folder');
|
||||||
}
|
}
|
||||||
|
|
||||||
$folder =& new Folder(APP.'plugins'.DS);
|
$folder =& new Folder(APP.'plugins'.DS);
|
||||||
|
@ -324,285 +178,6 @@
|
||||||
}
|
}
|
||||||
return $loadedControllers;
|
return $loadedControllers;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Loads a controller and its helper libraries.
|
|
||||||
*
|
|
||||||
* @param string $name Name of controller
|
|
||||||
* @return boolean Success
|
|
||||||
*/
|
|
||||||
function loadController($name) {
|
|
||||||
if (!class_exists('AppController')) {
|
|
||||||
if (file_exists(APP . 'app_controller.php')) {
|
|
||||||
require(APP . 'app_controller.php');
|
|
||||||
} else {
|
|
||||||
require(CAKE . 'app_controller.php');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($name === null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$parent = 'AppController';
|
|
||||||
if (strpos($name, '.') !== false) {
|
|
||||||
list($plugin, $name) = explode('.', $name);
|
|
||||||
|
|
||||||
$parent = Inflector::camelize($plugin . '_app_controller');
|
|
||||||
$plugin = Inflector::underscore($plugin);
|
|
||||||
$pluginAppControllerFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_controller.php';
|
|
||||||
|
|
||||||
if (!class_exists($parent)) {
|
|
||||||
if (file_exists($pluginAppControllerFile)) {
|
|
||||||
require($pluginAppControllerFile);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($name)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!class_exists($name . 'Controller')) {
|
|
||||||
$name = Inflector::underscore($name);
|
|
||||||
$file = APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $name . '_controller.php';
|
|
||||||
if (file_exists($file)) {
|
|
||||||
require($file);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$className = $name . 'Controller';
|
|
||||||
if (class_exists($className) && low(get_parent_class($className)) !== low($name . 'AppController')) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
$name = Inflector::underscore($className);
|
|
||||||
$controllers = Configure::read('Controllers');
|
|
||||||
if (is_array($controllers)) {
|
|
||||||
if (array_key_exists($className, $controllers)) {
|
|
||||||
require($controllers[$className]['path']);
|
|
||||||
return true;
|
|
||||||
} elseif (isset($controllers['Core']) && array_key_exists($className, $controllers['Core'])) {
|
|
||||||
require($controllers['Core'][$className]['path']);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$paths = Configure::getInstance();
|
|
||||||
foreach ($paths->controllerPaths as $path) {
|
|
||||||
if (file_exists($path . $name . '.php')) {
|
|
||||||
Configure::store('Controllers', 'class.paths', array($className => array('path' => $path . $name . '.php')));
|
|
||||||
require($path . $name . '.php');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($controllerFilename = fileExistsInPath(LIBS . 'controller' . DS . $name . '.php')) {
|
|
||||||
if (file_exists($controllerFilename)) {
|
|
||||||
Configure::store('Controllers\'][\'Core', 'class.paths', array($className => array('path' => $controllerFilename)));
|
|
||||||
require($controllerFilename);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Loads a helper
|
|
||||||
*
|
|
||||||
* @param string $name Name of helper
|
|
||||||
* @return boolean Success
|
|
||||||
*/
|
|
||||||
function loadHelper($name) {
|
|
||||||
if (!class_exists('AppHelper')) {
|
|
||||||
if (file_exists(APP . 'app_helper.php')) {
|
|
||||||
require(APP . 'app_helper.php');
|
|
||||||
} else {
|
|
||||||
require(CAKE . 'app_helper.php');
|
|
||||||
}
|
|
||||||
Overloadable::overload('AppHelper');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($name === null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strpos($name, '.') !== false) {
|
|
||||||
list($plugin, $name) = explode('.', $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$className = $name . 'Helper';
|
|
||||||
if (!class_exists($className)) {
|
|
||||||
$name = Inflector::underscore($name);
|
|
||||||
$helpers = Configure::read('Helpers');
|
|
||||||
|
|
||||||
if (is_array($helpers)) {
|
|
||||||
if (array_key_exists($className, $helpers)) {
|
|
||||||
require($helpers[$className]['path']);
|
|
||||||
return true;
|
|
||||||
} elseif (isset($helpers['Core']) && array_key_exists($className, $helpers['Core'])) {
|
|
||||||
require($helpers['Core'][$className]['path']);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$paths = Configure::getInstance();
|
|
||||||
foreach ($paths->helperPaths as $path) {
|
|
||||||
if (file_exists($path . $name . '.php')) {
|
|
||||||
Configure::store('Helpers', 'class.paths', array($className => array('path' => $path . $name . '.php')));
|
|
||||||
require($path . $name . '.php');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($helperFilename = fileExistsInPath(LIBS . 'view' . DS . 'helpers' . DS . $name . '.php')) {
|
|
||||||
if (file_exists($helperFilename)) {
|
|
||||||
Configure::store('Helpers\'][\'Core', 'class.paths', array($className => array('path' => $helperFilename)));
|
|
||||||
require($helperFilename);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Loads a plugin's helper
|
|
||||||
*
|
|
||||||
* @param string $plugin Name of plugin
|
|
||||||
* @param string $helper Name of helper to load
|
|
||||||
* @return boolean Success
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
function loadPluginHelper($plugin, $helper) {
|
|
||||||
loadHelper(null);
|
|
||||||
|
|
||||||
if (!class_exists($helper . 'Helper')) {
|
|
||||||
$helper = Inflector::underscore($helper);
|
|
||||||
$file = APP . 'plugins' . DS . $plugin . DS . 'views' . DS . 'helpers' . DS . $helper . '.php';
|
|
||||||
if (file_exists($file)) {
|
|
||||||
require($file);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Loads a component
|
|
||||||
*
|
|
||||||
* @param string $name Name of component
|
|
||||||
* @return boolean Success
|
|
||||||
*/
|
|
||||||
function loadComponent($name) {
|
|
||||||
if ($name === null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strpos($name, '.') !== false) {
|
|
||||||
list($plugin, $name) = explode('.', $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$className = $name . 'Component';
|
|
||||||
if (!class_exists($className)) {
|
|
||||||
$name = Inflector::underscore($name);
|
|
||||||
$components = Configure::read('Components');
|
|
||||||
|
|
||||||
if (is_array($components)) {
|
|
||||||
if (array_key_exists($className, $components)) {
|
|
||||||
require($components[$className]['path']);
|
|
||||||
return true;
|
|
||||||
} elseif (isset($components['Core']) && array_key_exists($className, $components['Core'])) {
|
|
||||||
require($components['Core'][$className]['path']);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$paths = Configure::getInstance();
|
|
||||||
|
|
||||||
foreach ($paths->componentPaths as $path) {
|
|
||||||
if (file_exists($path . $name . '.php')) {
|
|
||||||
Configure::store('Components', 'class.paths', array($className => array('path' => $path . $name . '.php')));
|
|
||||||
require($path . $name . '.php');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($componentFilename = fileExistsInPath(LIBS . 'controller' . DS . 'components' . DS . $name . '.php')) {
|
|
||||||
if (file_exists($componentFilename)) {
|
|
||||||
Configure::store('Components\'][\'Core', 'class.paths', array($className => array('path' => $componentFilename)));
|
|
||||||
require($componentFilename);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Loads a plugin's component
|
|
||||||
*
|
|
||||||
* @param string $plugin Name of plugin
|
|
||||||
* @param string $helper Name of component to load
|
|
||||||
* @return boolean Success
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
function loadPluginComponent($plugin, $component) {
|
|
||||||
if (!class_exists($component . 'Component')) {
|
|
||||||
$component = Inflector::underscore($component);
|
|
||||||
$file = APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . 'components' . DS . $component . '.php';
|
|
||||||
if (file_exists($file)) {
|
|
||||||
require($file);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Loads a behavior
|
|
||||||
*
|
|
||||||
* @param string $name Name of behavior
|
|
||||||
* @return boolean Success
|
|
||||||
*/
|
|
||||||
function loadBehavior($name) {
|
|
||||||
if ($name === null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (strpos($name, '.') !== false) {
|
|
||||||
list($plugin, $name) = explode('.', $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
$paths = Configure::getInstance();
|
|
||||||
|
|
||||||
if (!class_exists($name . 'Behavior')) {
|
|
||||||
$name = Inflector::underscore($name);
|
|
||||||
|
|
||||||
foreach ($paths->behaviorPaths as $path) {
|
|
||||||
if (file_exists($path . $name . '.php')) {
|
|
||||||
require($path . $name . '.php');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($behavior_fn = fileExistsInPath(LIBS . 'model' . DS . 'behaviors' . DS . $name . '.php')) {
|
|
||||||
if (file_exists($behavior_fn)) {
|
|
||||||
require($behavior_fn);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of filenames of PHP files in given directory.
|
* Returns an array of filenames of PHP files in given directory.
|
||||||
*
|
*
|
||||||
|
@ -661,10 +236,8 @@
|
||||||
*/
|
*/
|
||||||
function uses() {
|
function uses() {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
$c = func_num_args();
|
foreach ($args as $file) {
|
||||||
|
require_once(LIBS . strtolower($file) . '.php');
|
||||||
for ($i = 0; $i < $c; $i++) {
|
|
||||||
require_once(LIBS . low($args[$i]) . '.php');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1204,7 +777,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!class_exists('I18n')) {
|
if (!class_exists('I18n')) {
|
||||||
uses('i18n');
|
App::import('Core', 'i18n');
|
||||||
}
|
}
|
||||||
$calledFrom = debug_backtrace();
|
$calledFrom = debug_backtrace();
|
||||||
$dir = dirname($calledFrom[0]['file']);
|
$dir = dirname($calledFrom[0]['file']);
|
||||||
|
@ -1231,7 +804,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!class_exists('I18n')) {
|
if (!class_exists('I18n')) {
|
||||||
uses('i18n');
|
App::import('Core', 'i18n');
|
||||||
}
|
}
|
||||||
$calledFrom = debug_backtrace();
|
$calledFrom = debug_backtrace();
|
||||||
$dir = dirname($calledFrom[0]['file']);
|
$dir = dirname($calledFrom[0]['file']);
|
||||||
|
@ -1256,7 +829,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!class_exists('I18n')) {
|
if (!class_exists('I18n')) {
|
||||||
uses('i18n');
|
App::import('Core', 'i18n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($return === false) {
|
if ($return === false) {
|
||||||
|
@ -1282,7 +855,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!class_exists('I18n')) {
|
if (!class_exists('I18n')) {
|
||||||
uses('i18n');
|
App::import('Core', 'i18n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($return === false) {
|
if ($return === false) {
|
||||||
|
@ -1318,7 +891,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!class_exists('I18n')) {
|
if (!class_exists('I18n')) {
|
||||||
uses('i18n');
|
App::import('Core', 'i18n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($return === false) {
|
if ($return === false) {
|
||||||
|
@ -1358,7 +931,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!class_exists('I18n')) {
|
if (!class_exists('I18n')) {
|
||||||
uses('i18n');
|
App::import('Core', 'i18n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($return === false) {
|
if ($return === false) {
|
||||||
|
@ -1390,7 +963,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!class_exists('I18n')) {
|
if (!class_exists('I18n')) {
|
||||||
uses('i18n');
|
App::import('Core', 'i18n');
|
||||||
}
|
}
|
||||||
$calledFrom = debug_backtrace();
|
$calledFrom = debug_backtrace();
|
||||||
$dir = dirname($calledFrom[0]['file']);
|
$dir = dirname($calledFrom[0]['file']);
|
||||||
|
@ -1460,7 +1033,7 @@
|
||||||
*/
|
*/
|
||||||
function LogError($message) {
|
function LogError($message) {
|
||||||
if (!class_exists('CakeLog')) {
|
if (!class_exists('CakeLog')) {
|
||||||
uses('cake_log');
|
App::import('Core', 'CakeLog');
|
||||||
}
|
}
|
||||||
$bad = array("\n", "\r", "\t");
|
$bad = array("\n", "\r", "\t");
|
||||||
$good = ' ';
|
$good = ' ';
|
||||||
|
@ -1555,4 +1128,92 @@
|
||||||
}
|
}
|
||||||
return $val2;
|
return $val2;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see App::import('Model', 'PluginName.PluginModel');
|
||||||
|
*/
|
||||||
|
function loadPluginModels($plugin) {
|
||||||
|
if (!class_exists('AppModel')) {
|
||||||
|
loadModel();
|
||||||
|
}
|
||||||
|
$plugin = Inflector::underscore($plugin);
|
||||||
|
$pluginAppModel = Inflector::camelize($plugin . '_app_model');
|
||||||
|
$pluginAppModelFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_model.php';
|
||||||
|
|
||||||
|
if (!class_exists($pluginAppModel)) {
|
||||||
|
if (file_exists($pluginAppModelFile)) {
|
||||||
|
require($pluginAppModelFile);
|
||||||
|
Overloadable::overload($pluginAppModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pluginModelDir = APP . 'plugins' . DS . $plugin . DS . 'models' . DS;
|
||||||
|
if (is_dir($pluginModelDir)) {
|
||||||
|
foreach (listClasses($pluginModelDir)as $modelFileName) {
|
||||||
|
list($name) = explode('.', $modelFileName);
|
||||||
|
$className = Inflector::camelize($name);
|
||||||
|
|
||||||
|
if (!class_exists($className)) {
|
||||||
|
require($pluginModelDir . $modelFileName);
|
||||||
|
Overloadable::overload($className);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see App::import('View', 'ModelName');
|
||||||
|
*/
|
||||||
|
function loadView($viewClass) {
|
||||||
|
return App::import('View', $name);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see App::import('Model', 'ModelName');
|
||||||
|
*/
|
||||||
|
function loadModel($name = null) {
|
||||||
|
return App::import('Model', $name);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see App::import('Controller', 'ControllerName');
|
||||||
|
*/
|
||||||
|
function loadController($name) {
|
||||||
|
return App::import('Controller', $name);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see App::import('Helper', 'HelperName');
|
||||||
|
*/
|
||||||
|
function loadHelper($name) {
|
||||||
|
return App::import('Helper', $name);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see App::import('Helper', 'PluginName.HelperName');
|
||||||
|
*/
|
||||||
|
function loadPluginHelper($plugin, $helper) {
|
||||||
|
return App::import('Helper', $plugin . '.' . $helper);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see App::import('Component', 'PluginName.ComponentName');
|
||||||
|
*/
|
||||||
|
function loadComponent($name) {
|
||||||
|
return App::import('Component', $name);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see App::import('Component', 'PluginName.ComponentName');
|
||||||
|
*/
|
||||||
|
function loadPluginComponent($plugin, $component) {
|
||||||
|
return App::import('Component', $plugin . '.' . $component);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @see App::import('Behavior', 'BehaviorrName');
|
||||||
|
*/
|
||||||
|
function loadBehavior($name) {
|
||||||
|
return App::import('Behavior', $name);
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -43,26 +43,15 @@ if (!defined('SERVER_IIS') && php_sapi_name() == 'isapi') {
|
||||||
require LIBS . 'inflector.php';
|
require LIBS . 'inflector.php';
|
||||||
require LIBS . 'configure.php';
|
require LIBS . 'configure.php';
|
||||||
}
|
}
|
||||||
|
require LIBS . 'file.php';
|
||||||
require LIBS . 'cache.php';
|
require LIBS . 'cache.php';
|
||||||
|
|
||||||
Configure::getInstance();
|
Configure::getInstance();
|
||||||
|
|
||||||
if(Configure::read('Cache.disable') !== true) {
|
|
||||||
$cache = Cache::settings();
|
|
||||||
if(empty($cache)) {
|
|
||||||
trigger_error('Cache not configured properly. Please check Cache::config(); in APP/config/core.php', E_USER_WARNING);
|
|
||||||
Cache::config('default', array('engine' => 'File'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
require LIBS . 'session.php';
|
require LIBS . 'session.php';
|
||||||
require LIBS . 'security.php';
|
require LIBS . 'security.php';
|
||||||
require LIBS . 'string.php';
|
require LIBS . 'string.php';
|
||||||
|
|
||||||
|
|
||||||
Configure::store(null, 'class.paths');
|
|
||||||
Configure::load('class.paths');
|
|
||||||
|
|
||||||
$url = null;
|
$url = null;
|
||||||
require CAKE . 'dispatcher.php';
|
require CAKE . 'dispatcher.php';
|
||||||
?>
|
?>
|
|
@ -24,5 +24,5 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*/
|
*/
|
||||||
$config['Cake.version'] = '1.2.0.5875 pre-beta';
|
return $config['Cake.version'] = '1.2.0.5875 pre-beta';
|
||||||
?>
|
?>
|
|
@ -30,7 +30,8 @@
|
||||||
/**
|
/**
|
||||||
* List of helpers to include
|
* List of helpers to include
|
||||||
*/
|
*/
|
||||||
uses('router', DS.'controller'.DS.'controller');
|
App::import('Core', 'Router');
|
||||||
|
App::import('Core', 'Controller');
|
||||||
/**
|
/**
|
||||||
* Dispatcher translates URLs to controller-action-paramter triads.
|
* Dispatcher translates URLs to controller-action-paramter triads.
|
||||||
*
|
*
|
||||||
|
@ -216,11 +217,6 @@ class Dispatcher extends Object {
|
||||||
|
|
||||||
Router::setRequestInfo(array($this->params, array('base' => $this->base, 'here' => $this->here, 'webroot' => $this->webroot)));
|
Router::setRequestInfo(array($this->params, array('base' => $this->base, 'here' => $this->here, 'webroot' => $this->webroot)));
|
||||||
$controller->_initComponents();
|
$controller->_initComponents();
|
||||||
|
|
||||||
if (isset($this->plugin)) {
|
|
||||||
loadPluginModels($this->plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
$controller->constructClasses();
|
$controller->constructClasses();
|
||||||
|
|
||||||
$this->start($controller);
|
$this->start($controller);
|
||||||
|
@ -252,7 +248,7 @@ class Dispatcher extends Object {
|
||||||
function _invoke(&$controller, $params, $missingAction = false) {
|
function _invoke(&$controller, $params, $missingAction = false) {
|
||||||
$classVars = get_object_vars($controller);
|
$classVars = get_object_vars($controller);
|
||||||
if ($missingAction && in_array('scaffold', array_keys($classVars))) {
|
if ($missingAction && in_array('scaffold', array_keys($classVars))) {
|
||||||
uses('controller'. DS . 'scaffold');
|
App::import('Core', 'Scaffold');
|
||||||
return new Scaffold($controller, $params);
|
return new Scaffold($controller, $params);
|
||||||
} elseif ($missingAction && !in_array('scaffold', array_keys($classVars))) {
|
} elseif ($missingAction && !in_array('scaffold', array_keys($classVars))) {
|
||||||
return $this->cakeError('missingAction', array(
|
return $this->cakeError('missingAction', array(
|
||||||
|
@ -525,7 +521,7 @@ class Dispatcher extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pluginPath . $controller) {
|
if ($pluginPath . $controller) {
|
||||||
if (loadController($pluginPath . $controller)) {
|
if (App::import('Controller', $pluginPath . $controller)) {
|
||||||
$ctrlClass = $controller . 'Controller';
|
$ctrlClass = $controller . 'Controller';
|
||||||
return $ctrlClass;
|
return $ctrlClass;
|
||||||
}
|
}
|
||||||
|
@ -645,7 +641,8 @@ class Dispatcher extends Object {
|
||||||
}
|
}
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
if (!class_exists('View')) {
|
if (!class_exists('View')) {
|
||||||
uses('controller' . DS . 'component', DS . 'view' . DS . 'view');
|
App::import('Core', 'Component');
|
||||||
|
App::import('Core', 'View');;
|
||||||
}
|
}
|
||||||
$controller = null;
|
$controller = null;
|
||||||
$view = new View($controller);
|
$view = new View($controller);
|
||||||
|
|
|
@ -191,10 +191,12 @@ class Cache extends Object {
|
||||||
*/
|
*/
|
||||||
function write($key, $value, $duration = null) {
|
function write($key, $value, $duration = null) {
|
||||||
$_this =& Cache::getInstance();
|
$_this =& Cache::getInstance();
|
||||||
|
$config = null;
|
||||||
if (is_array($duration)) {
|
if (is_array($duration)) {
|
||||||
extract($duration);
|
extract($duration);
|
||||||
} else {
|
} elseif (isset($_this->__config[$duration])) {
|
||||||
$config = $duration;
|
$config = $duration;
|
||||||
|
$duration = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = $_this->config($config);
|
$config = $_this->config($config);
|
||||||
|
@ -215,8 +217,8 @@ class Cache extends Object {
|
||||||
if (!$duration) {
|
if (!$duration) {
|
||||||
$duration = $settings['duration'];
|
$duration = $settings['duration'];
|
||||||
}
|
}
|
||||||
|
$duration = ife(is_numeric($duration), intval($duration), strtotime($duration) - time());
|
||||||
|
|
||||||
$duration = ife(is_string($duration), strtotime($duration) - time(), intval($duration));
|
|
||||||
if ($duration < 1) {
|
if ($duration < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
4
cake/libs/cache/file.php
vendored
4
cake/libs/cache/file.php
vendored
|
@ -29,8 +29,8 @@
|
||||||
* Included libraries.
|
* Included libraries.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (!class_exists('file')) {
|
if (!class_exists('File')) {
|
||||||
uses ('file');
|
uses ('File');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* File Storage engine for cache
|
* File Storage engine for cache
|
||||||
|
|
4
cake/libs/cache/model.php
vendored
4
cake/libs/cache/model.php
vendored
|
@ -72,8 +72,8 @@ class ModelEngine extends CacheEngine {
|
||||||
$this->settings = am($this->settings, $defaults, $settings);
|
$this->settings = am($this->settings, $defaults, $settings);
|
||||||
$className = $this->settings['className'];
|
$className = $this->settings['className'];
|
||||||
$this->__fields = $this->settings['fields'];
|
$this->__fields = $this->settings['fields'];
|
||||||
if (class_exists($className) || loadModel($className)) {
|
if (App::import($className)) {
|
||||||
$this->__Model = new $className();
|
$this->__Model = ClassRegistry::init($className);
|
||||||
} else {
|
} else {
|
||||||
$this->__Model = new Model(array('name' => $className));
|
$this->__Model = new Model(array('name' => $className));
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,121 @@ class ClassRegistry {
|
||||||
}
|
}
|
||||||
return $instance[0];
|
return $instance[0];
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Loads a class, registers the object in the registry and returns instance of the object.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param mixed $class as a string or a single key => value array instance will be created, stored in the registry and returned.
|
||||||
|
* Required: array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass');
|
||||||
|
* Model Classes can accept optional array('id' => $id, 'table' => $table, 'ds' => $ds, 'alias' => $alias);
|
||||||
|
* When $class is a numeric keyed array, multiple class instances will be stored in the registry, no instance of the object will be returned
|
||||||
|
* array(
|
||||||
|
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass'),
|
||||||
|
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass'),
|
||||||
|
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass'));
|
||||||
|
*
|
||||||
|
* @param string $type TypeOfClass
|
||||||
|
* @return object intance of ClassName
|
||||||
|
*/
|
||||||
|
function &init($class, $type = null) {
|
||||||
|
$_this =& ClassRegistry::getInstance();
|
||||||
|
$id = $false = false;
|
||||||
|
$table = $ds = $alias = $plugin = null;
|
||||||
|
$options = null;
|
||||||
|
$true = true;
|
||||||
|
if(!$type) {
|
||||||
|
$type = 'Model';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($class)) {
|
||||||
|
if (isset($class[0])) {
|
||||||
|
foreach ($class as $key => $setttings) {
|
||||||
|
if (is_array($setttings)) {
|
||||||
|
$plugin = null;
|
||||||
|
|
||||||
|
extract($setttings, EXTR_OVERWRITE);
|
||||||
|
|
||||||
|
if (strpos($class, '.') !== false) {
|
||||||
|
list($plugin, $class) = explode('.', $class);
|
||||||
|
$plugin = $plugin . '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type === 'Model') {
|
||||||
|
$options = array('id' => $id, 'table' => $table, 'ds' => $ds, 'alias' => $alias, 'name' => $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (App::import($type, $plugin . $class)) {
|
||||||
|
${$class} = new $class($options);
|
||||||
|
if($type !== 'Model') {
|
||||||
|
$_this->addObject($this->alias, ${$class});
|
||||||
|
} else {
|
||||||
|
$_this->map($alias, $class);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
trigger_error(sprintf(__('(ClassRegistry::init() could not create instance of %1$s class %2$s ', true), $class, $type), E_USER_WARNING);
|
||||||
|
return $false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} elseif (is_numeric($setttings)) {
|
||||||
|
trigger_error(__('(ClassRegistry::init() Attempted to create instance of a class with a numeric name', true), E_USER_WARNING);
|
||||||
|
return $false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $true;
|
||||||
|
} else {
|
||||||
|
extract($class, EXTR_OVERWRITE);
|
||||||
|
if (strpos($class, '.') !== false) {
|
||||||
|
list($plugin, $class) = explode('.', $class);
|
||||||
|
$plugin = $plugin . '.';
|
||||||
|
}
|
||||||
|
if ($_this->_duplicate($alias, $class)) {
|
||||||
|
$_this->map($alias, $class);
|
||||||
|
return $_this->getObject($alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type === 'Model') {
|
||||||
|
$options = array('id' => $id, 'table' => $table, 'ds' => $ds, 'alias' => $alias, 'name' => $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (App::import($type, $plugin . $class)) {
|
||||||
|
${$class} = new $class($options);
|
||||||
|
if($type !== 'Model') {
|
||||||
|
$_this->addObject($this->alias, ${$class});
|
||||||
|
} else {
|
||||||
|
$_this->map($alias, $class);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (strpos($class, '.') !== false) {
|
||||||
|
list($plugin, $class) = explode('.', $class);
|
||||||
|
$plugin = $plugin . '.';
|
||||||
|
}
|
||||||
|
$alias = $class;
|
||||||
|
|
||||||
|
if ($_this->_duplicate($alias, $class)) {
|
||||||
|
$_this->map($alias, $class);
|
||||||
|
return $_this->getObject($alias);
|
||||||
|
}
|
||||||
|
if ($type === 'Model') {
|
||||||
|
$option = array('name' => $class, 'alias' => $alias, 'id' => $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (App::import($type, $plugin . $class)) {
|
||||||
|
${$class} = new $class($option);
|
||||||
|
if($type !== 'Model') {
|
||||||
|
$_this->addObject($this->alias, ${$class});
|
||||||
|
} else {
|
||||||
|
$_this->map($alias, $class);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ${$class};
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Add $object to the registry, associating it with the name $key.
|
* Add $object to the registry, associating it with the name $key.
|
||||||
*
|
*
|
||||||
|
@ -144,6 +259,26 @@ class ClassRegistry {
|
||||||
$return = false;
|
$return = false;
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Checks to see if $alias is a duplicate $class Object
|
||||||
|
*
|
||||||
|
* @param string $alias
|
||||||
|
* @param string $class
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function _duplicate($alias, $class) {
|
||||||
|
$_this =& ClassRegistry::getInstance();
|
||||||
|
$duplicate = false;
|
||||||
|
|
||||||
|
if ($_this->isKeySet($alias)) {
|
||||||
|
$model = $_this->getObject($alias);
|
||||||
|
if (is_a($model, $class)) {
|
||||||
|
$duplicate = true;
|
||||||
|
}
|
||||||
|
unset($model);
|
||||||
|
}
|
||||||
|
return $duplicate;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Add a key name pair to the registry to map name to class in the regisrty.
|
* Add a key name pair to the registry to map name to class in the regisrty.
|
||||||
*
|
*
|
||||||
|
@ -183,7 +318,7 @@ class ClassRegistry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Flushes all objects from the ClassREgistry.
|
* Flushes all objects from the ClassRegistry.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/**
|
/**
|
||||||
* Short description for file.
|
* Short description for file.
|
||||||
*
|
*
|
||||||
* Long description for file
|
* Long description for filec
|
||||||
*
|
*
|
||||||
* PHP versions 4 and 5
|
* PHP versions 4 and 5
|
||||||
*
|
*
|
||||||
|
@ -84,6 +84,20 @@ class Configure extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $debug = null;
|
var $debug = null;
|
||||||
|
/**
|
||||||
|
* Determine if $__objects cache should be wrote
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $__cache = false;
|
||||||
|
/**
|
||||||
|
* Holds and key => value array of objects type
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $__objects = array();
|
||||||
/**
|
/**
|
||||||
* Return a singleton instance of Configure.
|
* Return a singleton instance of Configure.
|
||||||
*
|
*
|
||||||
|
@ -108,6 +122,12 @@ class Configure extends Object {
|
||||||
*/
|
*/
|
||||||
function listObjects($type, $path = null) {
|
function listObjects($type, $path = null) {
|
||||||
$_this =& Configure::getInstance();
|
$_this =& Configure::getInstance();
|
||||||
|
$objects = array();
|
||||||
|
if (empty($_this->__objects)) {
|
||||||
|
$_this->__objects = Cache::read('object_map', '_cake_core_');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($_this->__objects) || !isset($_this->__objects[$type])) {
|
||||||
$Inflector =& Inflector::getInstance();
|
$Inflector =& Inflector::getInstance();
|
||||||
|
|
||||||
$types = array(
|
$types = array(
|
||||||
|
@ -121,6 +141,7 @@ class Configure extends Object {
|
||||||
if (!isset($types[$type])) {
|
if (!isset($types[$type])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($path)) {
|
if (empty($path)) {
|
||||||
$pathVar = $type . 'Paths';
|
$pathVar = $type . 'Paths';
|
||||||
$path = $_this->{$pathVar};
|
$path = $_this->{$pathVar};
|
||||||
|
@ -137,7 +158,10 @@ class Configure extends Object {
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
return array_map(array(&$Inflector, 'camelize'), $objects);
|
$_this->__objects[$type] = array_map(array(&$Inflector, 'camelize'), $objects);
|
||||||
|
$_this->__cache = true;
|
||||||
|
}
|
||||||
|
return $_this->__objects[$type];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns an array of filenames of PHP files in given directory.
|
* Returns an array of filenames of PHP files in given directory.
|
||||||
|
@ -409,107 +433,34 @@ class Configure extends Object {
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sets the var modelPaths
|
* Sets the paths for the given object type
|
||||||
*
|
*
|
||||||
* @param array $modelPaths Path to model files
|
* @param array $paths paths defines in config/bootstrap.php
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __buildModelPaths($modelPaths) {
|
function __buildPaths($paths) {
|
||||||
$_this =& Configure::getInstance();
|
$_this =& Configure::getInstance();
|
||||||
$_this->modelPaths[] = MODELS;
|
|
||||||
if (isset($modelPaths)) {
|
$basePaths = array(
|
||||||
foreach ($modelPaths as $value) {
|
'plugin' => APP . 'plugins' . DS,
|
||||||
$_this->modelPaths[] = $value;
|
'behavior' => array(BEHAVIORS, CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'libs' . DS . 'model' . DS . 'behaviors' . DS),
|
||||||
|
'component' => array(COMPONENTS, CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'libs' . DS . 'controller' . DS . 'components' . DS),
|
||||||
|
'helper' => array(HELPERS, APP, CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'libs' . DS . 'view' . DS . 'helpers' . DS),
|
||||||
|
'controller' => array(CONTROLLERS, APP, CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'libs' . DS . 'controller' . DS),
|
||||||
|
'view' => array(VIEWS, CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'libs' . DS . 'view'. DS),
|
||||||
|
'model' => array(MODELS, APP, CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'libs' . DS . 'model'. DS)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($basePaths as $type => $default) {
|
||||||
|
$pathsVar = $type . 'Paths';
|
||||||
|
if (!is_array($default)) {
|
||||||
|
$default = array($default);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
$_this->{$pathsVar} = $default;
|
||||||
/**
|
|
||||||
* Sets the var viewPaths
|
if (isset($paths[$pathsVar]) && !empty($paths[$pathsVar])) {
|
||||||
*
|
$_this->{$pathsVar} = array_merge((array)$paths[$pathsVar], $_this->{$pathsVar});
|
||||||
* @param array $viewPaths Path to view files
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function __buildViewPaths($viewPaths) {
|
|
||||||
$_this =& Configure::getInstance();
|
|
||||||
$_this->viewPaths[] = VIEWS;
|
|
||||||
if (isset($viewPaths)) {
|
|
||||||
foreach ($viewPaths as $value) {
|
|
||||||
$_this->viewPaths[] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Sets the var controllerPaths
|
|
||||||
*
|
|
||||||
* @param array $controllerPaths Path to controller files
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function __buildControllerPaths($controllerPaths) {
|
|
||||||
$_this =& Configure::getInstance();
|
|
||||||
$_this->controllerPaths[] = CONTROLLERS;
|
|
||||||
if (isset($controllerPaths)) {
|
|
||||||
foreach ($controllerPaths as $value) {
|
|
||||||
$_this->controllerPaths[] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Sets the var helperPaths
|
|
||||||
*
|
|
||||||
* @param array $helperPaths Path to helper files
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function __buildHelperPaths($helperPaths) {
|
|
||||||
$_this =& Configure::getInstance();
|
|
||||||
$_this->helperPaths[] = HELPERS;
|
|
||||||
if (isset($helperPaths)) {
|
|
||||||
foreach ($helperPaths as $value) {
|
|
||||||
$_this->helperPaths[] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Sets the var componentPaths
|
|
||||||
*
|
|
||||||
* @param array $componentPaths Path to component files
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function __buildComponentPaths($componentPaths) {
|
|
||||||
$_this =& Configure::getInstance();
|
|
||||||
$_this->componentPaths[] = COMPONENTS;
|
|
||||||
if (isset($componentPaths)) {
|
|
||||||
foreach ($componentPaths as $value) {
|
|
||||||
$_this->componentPaths[] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Sets the var behaviorPaths
|
|
||||||
*
|
|
||||||
* @param array $behaviorPaths Path to behavior files
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function __buildBehaviorPaths($behaviorPaths) {
|
|
||||||
$_this =& Configure::getInstance();
|
|
||||||
$_this->behaviorPaths[] = BEHAVIORS;
|
|
||||||
if (isset($behaviorPaths)) {
|
|
||||||
foreach ($behaviorPaths as $value) {
|
|
||||||
$_this->behaviorPaths[] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Sets the var pluginPaths
|
|
||||||
*
|
|
||||||
* @param array $pluginPaths Path to plugins
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
function __buildPluginPaths($pluginPaths) {
|
|
||||||
$_this =& Configure::getInstance();
|
|
||||||
$_this->pluginPaths[] = APP . 'plugins' . DS;
|
|
||||||
if (isset($pluginPaths)) {
|
|
||||||
foreach ($pluginPaths as $value) {
|
|
||||||
$_this->pluginPaths[] = $value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,32 +475,37 @@ class Configure extends Object {
|
||||||
function __loadBootstrap($boot) {
|
function __loadBootstrap($boot) {
|
||||||
$_this =& Configure::getInstance();
|
$_this =& Configure::getInstance();
|
||||||
|
|
||||||
$modelPaths = null;
|
|
||||||
$viewPaths = null;
|
|
||||||
$controllerPaths = null;
|
|
||||||
$helperPaths = null;
|
|
||||||
$componentPaths = null;
|
|
||||||
$behaviorPaths = null;
|
|
||||||
$pluginPaths = null;
|
|
||||||
|
|
||||||
if ($boot) {
|
if ($boot) {
|
||||||
$_this->write('App', array('base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR));
|
$_this->write('App', array('base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR));
|
||||||
if (!include(APP_PATH . 'config' . DS . 'core.php')) {
|
if (!include(APP_PATH . 'config' . DS . 'core.php')) {
|
||||||
trigger_error(sprintf(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", true), CONFIGS), E_USER_ERROR);
|
trigger_error(sprintf(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", true), CONFIGS), E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
$modelPaths = $viewPaths = $controllerPaths = $helperPaths = $componentPaths = $behaviorPaths = $pluginPaths = null;
|
||||||
|
|
||||||
if (!include(APP_PATH . 'config' . DS . 'bootstrap.php')) {
|
if (!include(APP_PATH . 'config' . DS . 'bootstrap.php')) {
|
||||||
trigger_error(sprintf(__("Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", true), CONFIGS), E_USER_ERROR);
|
trigger_error(sprintf(__("Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", true), CONFIGS), E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$modelPaths = $viewPaths = $controllerPaths = $helperPaths = $componentPaths = $behaviorPaths = $pluginPaths = null;
|
||||||
|
|
||||||
|
$_this->__buildPaths(compact('modelPaths', 'viewPaths', 'controllerPaths', 'helperPaths', 'componentPaths', 'behaviorPaths', 'pluginPaths'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if($_this->read('Cache.disable') !== true) {
|
||||||
|
$cache = Cache::settings();
|
||||||
|
if(empty($cache)) {
|
||||||
|
trigger_error('Cache not configured properly. Please check Cache::config(); in APP/config/core.php', E_USER_WARNING);
|
||||||
|
Cache::config('default', array('engine' => 'File'));
|
||||||
|
$cache = Cache::settings();
|
||||||
|
}
|
||||||
|
$settings = array('prefix' => 'cake_core_', 'path' => CACHE . 'persistent' . DS);
|
||||||
|
if (Configure::read() > 1) {
|
||||||
|
$settings = array('prefix' => 'cake_core_', 'duration' => 10, 'path' => CACHE . 'persistent' . DS);
|
||||||
|
}
|
||||||
|
Cache::config('_cake_core_' , array_merge($cache, $settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
$_this->__buildModelPaths($modelPaths);
|
|
||||||
$_this->__buildViewPaths($viewPaths);
|
|
||||||
$_this->__buildControllerPaths($controllerPaths);
|
|
||||||
$_this->__buildHelperPaths($helperPaths);
|
|
||||||
$_this->__buildComponentPaths($componentPaths);
|
|
||||||
$_this->__buildBehaviorPaths($behaviorPaths);
|
|
||||||
$_this->__buildPluginPaths($pluginPaths);
|
|
||||||
|
|
||||||
if (defined('BASE_URL')) {
|
if (defined('BASE_URL')) {
|
||||||
trigger_error('BASE_URL Deprecated: See Configure::write(\'App.baseUrl\', \'' . BASE_URL . '\'); in APP/config/core.php', E_USER_WARNING);
|
trigger_error('BASE_URL Deprecated: See Configure::write(\'App.baseUrl\', \'' . BASE_URL . '\'); in APP/config/core.php', E_USER_WARNING);
|
||||||
|
@ -604,5 +560,396 @@ class Configure extends Object {
|
||||||
$_this->write('Session.start', AUTO_SESSION);
|
$_this->write('Session.start', AUTO_SESSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function __destruct() {
|
||||||
|
$_this = & Configure::getInstance();
|
||||||
|
if ($_this->__cache) {
|
||||||
|
Cache::write('object_map', array_filter($_this->__objects), '_cake_core_');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Class and file loader.
|
||||||
|
*
|
||||||
|
* @since CakePHP(tm) v 1.2.0.6001
|
||||||
|
* @package cake
|
||||||
|
* @subpackage cake.cake.libs
|
||||||
|
*/
|
||||||
|
class App extends Object {
|
||||||
|
/**
|
||||||
|
* Paths to search for files
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $search = array();
|
||||||
|
/**
|
||||||
|
* Return the file that is loaded
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $return = false;
|
||||||
|
/**
|
||||||
|
* Determine if $__maps and $__paths cache should be wrote
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $__cache = false;
|
||||||
|
/**
|
||||||
|
* Holds key => values pairs of $type => file path
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $__map = array();
|
||||||
|
/**
|
||||||
|
* Holds paths for deep searching of files
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $__paths = array();
|
||||||
|
/**
|
||||||
|
* Will find Classes based on the $name, or can accept specific file to search for
|
||||||
|
*
|
||||||
|
* @param mixed $type The type of Class if passed as a string, or all params can be passed as an single array to $type,
|
||||||
|
* @param string $name Name of the Class or a unique name for the file
|
||||||
|
* @param mixed $parent boolean true if Class Parent should be searched, accepts key => value array('parent' => $parent ,'file' => $file, 'search' => $search);
|
||||||
|
* @param array $search paths to search for files, array('path 1', 'path 2', 'path 3');
|
||||||
|
* @param string $file full name of the file to search for including extension
|
||||||
|
* @param boolean $return, return the loaded file, the file must have a return statement in it to work: return $variable;
|
||||||
|
* @return boolean true if Class is already in memory or if file is found and loaded, false if not
|
||||||
|
* @access public
|
||||||
|
* @todo when App::import() is called without params initialize all the files from the core in one call
|
||||||
|
*/
|
||||||
|
function import($type = null, $name = null, $parent = true, $search = array(), $file = null, $return = false) {
|
||||||
|
$plugin = null;
|
||||||
|
$directory = null;
|
||||||
|
if (is_array($type)) {
|
||||||
|
extract($type, EXTR_OVERWRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($parent)) {
|
||||||
|
extract($parent, EXTR_OVERWRITE);
|
||||||
|
die(debug($this));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($name === null && $file === null) {
|
||||||
|
$name = $type;
|
||||||
|
$type = 'Core';
|
||||||
|
} elseif ($name === null) {
|
||||||
|
$type = 'File';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($name != null && strpos($name, '.') !== false) {
|
||||||
|
list($plugin, $name) = explode('.', $name);
|
||||||
|
}
|
||||||
|
$_this =& App::getInstance();
|
||||||
|
$_this->return = $return;
|
||||||
|
|
||||||
|
$ext = $_this->__settings($type, $plugin, $parent);
|
||||||
|
|
||||||
|
if ($name != null && !class_exists($name . $ext['class'])) {
|
||||||
|
if ($load = $_this->__mapped($name . $ext['class'], $type, $plugin)) {
|
||||||
|
if ($_this->__load($load)) {
|
||||||
|
$_this->__overload($type, $name . $ext['class']);
|
||||||
|
if($_this->return) {
|
||||||
|
$value = include $load;
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$_this->__remove($name . $ext['class'], $type, $plugin);
|
||||||
|
$_this->__cache = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($search)) {
|
||||||
|
$_this->search = $search;
|
||||||
|
} elseif ($plugin) {
|
||||||
|
$_this->search = $_this->__paths('plugin');
|
||||||
|
} else {
|
||||||
|
$_this->search = $_this->__paths($type);
|
||||||
|
}
|
||||||
|
|
||||||
|
$find = $file;
|
||||||
|
if ($find === null) {
|
||||||
|
$find = Inflector::underscore($name . $ext['suffix']).'.php';
|
||||||
|
if ($plugin) {
|
||||||
|
$find = Inflector::underscore($plugin) . DS . Inflector::underscore($type) . 's' . DS . $find;
|
||||||
|
$plugin = Inflector::camelize($plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($search) && $_this->__load($file)) {
|
||||||
|
$directory = false;
|
||||||
|
} else {
|
||||||
|
$file = $find;
|
||||||
|
$directory = $_this->__find($find, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($directory !== null) {
|
||||||
|
$_this->__cache = true;
|
||||||
|
$_this->__map($directory . $file, $name . $ext['class'], $type, $plugin);
|
||||||
|
$_this->__overload($type, $name . $ext['class']);
|
||||||
|
if( $_this->return) {
|
||||||
|
$value = include $directory . $file;
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns a single instance of App
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function &getInstance() {
|
||||||
|
static $instance = array();
|
||||||
|
if (!$instance) {
|
||||||
|
$instance[0] =& new App();
|
||||||
|
$map = Cache::read('file_map', 'import_map');
|
||||||
|
|
||||||
|
if ($map) {
|
||||||
|
$instance[0]->__map = $map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $instance[0];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Locates the $file in $__paths, searches recursively
|
||||||
|
*
|
||||||
|
* @param string $file full file name
|
||||||
|
* @param boolean $recursive search $__paths recursively
|
||||||
|
* @return mixed boolean on fail, $file directory path on success
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function __find($file, $recursive = true) {
|
||||||
|
$_this =& App::getInstance();
|
||||||
|
if (empty($_this->search)) {
|
||||||
|
return null;
|
||||||
|
} elseif (is_string($_this->search)) {
|
||||||
|
$_this->search = array($_this->search);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($_this->__paths)) {
|
||||||
|
$map = Cache::read('dir_map', '_cake_core_');
|
||||||
|
if ($map) {
|
||||||
|
$_this->__paths = $map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($_this->search as $path) {
|
||||||
|
$path = rtrim($path, DS);
|
||||||
|
if ($path === rtrim(APP, DS)) {
|
||||||
|
$recursive = false;
|
||||||
|
}
|
||||||
|
if ($recursive === false) {
|
||||||
|
if ($_this->__load($path . DS . $file)) {
|
||||||
|
return $path . DS;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!isset($_this->__paths[$path])) {
|
||||||
|
if (!class_exists('Folder')) {
|
||||||
|
uses('Folder');
|
||||||
|
}
|
||||||
|
$Folder =& new Folder();
|
||||||
|
$directories = $Folder->tree($path, false, 'dir');
|
||||||
|
$_this->__paths[$path] = $directories;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($_this->__paths[$path] as $directory) {
|
||||||
|
if ($_this->__load($directory . DS . $file)) {
|
||||||
|
return $directory . DS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Attempts to load $file
|
||||||
|
*
|
||||||
|
* @param string $file full path to file including file name
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function __load($file) {
|
||||||
|
$_this =& App::getInstance();
|
||||||
|
if (file_exists($file)) {
|
||||||
|
if(!$_this->return) {
|
||||||
|
require($file);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Maps the $name to the $file
|
||||||
|
*
|
||||||
|
* @param string $file full path to file
|
||||||
|
* @param string $name unique name for this map
|
||||||
|
* @param string $type type object being mapped
|
||||||
|
* @param string $plugin if object is from a plugin, the name of the plugin
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function __map($file, $name, $type, $plugin) {
|
||||||
|
$_this =& App::getInstance();
|
||||||
|
|
||||||
|
if ($plugin) {
|
||||||
|
$plugin = Inflector::camelize($plugin);
|
||||||
|
$_this->__map['Plugin'][$plugin][$type][$name] = $file;
|
||||||
|
} else {
|
||||||
|
$_this->__map[$type][$name] = $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return files complete path
|
||||||
|
*
|
||||||
|
* @param string $name unique name
|
||||||
|
* @param string $type type object
|
||||||
|
* @param string $plugin if object is from a plugin, the name of the plugin
|
||||||
|
* @return mixed, file path if found, false otherwise
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function __mapped($name, $type, $plugin) {
|
||||||
|
$_this =& App::getInstance();
|
||||||
|
|
||||||
|
if ($plugin) {
|
||||||
|
$plugin = Inflector::camelize($plugin);
|
||||||
|
if (isset($_this->__map['Plugin'][$plugin][$type])) {
|
||||||
|
if (array_key_exists($name, $_this->__map['Plugin'][$plugin][$type])) {
|
||||||
|
return $_this->__map['Plugin'][$plugin][$type][$name];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_this->__map[$type])) {
|
||||||
|
if (array_key_exists($name, $_this->__map[$type])) {
|
||||||
|
return $_this->__map[$type][$name];
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Used to overload Objects as needed
|
||||||
|
*
|
||||||
|
* @param string $type Model or Helper
|
||||||
|
* @param string $name Class name to overload
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function __overload($type, $name) {
|
||||||
|
$overload = array('Model', 'Helper');
|
||||||
|
if (in_array($type, $overload)) {
|
||||||
|
Overloadable::overload($name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Loads parent classes based on the $type
|
||||||
|
* Returns and prefix or suffix needed for load files
|
||||||
|
*
|
||||||
|
* @param string $type type of object
|
||||||
|
* @param string $plugin name of plugin
|
||||||
|
* @param boolean $parent false will not attempt to load parent
|
||||||
|
* @return array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function __settings($type, $plugin, $parent) {
|
||||||
|
$_this = & App::getInstance();
|
||||||
|
if (empty($parent)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ($parent !== true) {
|
||||||
|
$_this->import($_this->parent, $type, false);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ($plugin) {
|
||||||
|
$plugin = Inflector::underscore($plugin);
|
||||||
|
$name = Inflector::camelize($plugin);
|
||||||
|
}
|
||||||
|
$load = strtolower($type);
|
||||||
|
|
||||||
|
switch ($load) {
|
||||||
|
case 'model':
|
||||||
|
if (!class_exists('Model')) {
|
||||||
|
$_this->import('Core', 'Model', false);
|
||||||
|
}
|
||||||
|
$_this->import($type, 'AppModel', false);
|
||||||
|
if ($plugin) {
|
||||||
|
$_this->import($type, $plugin . '.' . $name . 'AppModel', false, array(), $plugin . DS . $plugin . '_app_model.php');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'view':
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case 'controller':
|
||||||
|
$_this->import($type, 'AppController', false);
|
||||||
|
if ($plugin) {
|
||||||
|
$_this->import($type, $plugin . '.' . $name . 'AppController', false, array(), $plugin . DS . $plugin . '_app_controller.php');
|
||||||
|
}
|
||||||
|
return array('class' => $type, 'suffix' => $type);
|
||||||
|
break;
|
||||||
|
case 'helper':
|
||||||
|
$_this->import($type, 'AppHelper', false);
|
||||||
|
return array('class' => $type, 'suffix' => null);
|
||||||
|
break;
|
||||||
|
case 'component':
|
||||||
|
return array('class' => $type, 'suffix' => null);
|
||||||
|
break;
|
||||||
|
case 'behavior':
|
||||||
|
$_this->import($type, 'Behavior', false);
|
||||||
|
return array('class' => $type, 'suffix' => null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return array('class' => null, 'suffix' => null);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns default paths to search
|
||||||
|
*
|
||||||
|
* @param string $type type of object to be searched
|
||||||
|
* @return array list of paths
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function __paths($type) {
|
||||||
|
if ($type === 'Core') {
|
||||||
|
return array(CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'libs');
|
||||||
|
}
|
||||||
|
$paths = Configure::read(strtolower($type) . 'Paths');
|
||||||
|
return $paths;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Removes file location from map if file has been deleted
|
||||||
|
*
|
||||||
|
* @param string $name name of object
|
||||||
|
* @param string $type type of object
|
||||||
|
* @param string $plugin name of plugin
|
||||||
|
*/
|
||||||
|
function __remove($name, $type, $plugin) {
|
||||||
|
$_this =& App::getInstance();
|
||||||
|
if ($plugin) {
|
||||||
|
$plugin = Inflector::camelize($plugin);
|
||||||
|
unset($_this->__map['Plugin'][$plugin][$type][$name]);
|
||||||
|
} else {
|
||||||
|
unset($_this->__map[$type][$name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Object destructor
|
||||||
|
*
|
||||||
|
* Write cache file if changes have been made to the $__map or $__paths
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function __destruct() {
|
||||||
|
$_this = & App::getInstance();
|
||||||
|
if ($_this->__cache) {
|
||||||
|
Cache::write('dir_map', array_filter($_this->__paths), '_cake_core_');
|
||||||
|
Cache::write('file_map', array_filter($_this->__map), '_cake_core_');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -109,7 +109,7 @@ class Component extends Object {
|
||||||
if (in_array($component, array_keys($loaded)) !== true) {
|
if (in_array($component, array_keys($loaded)) !== true) {
|
||||||
if (!class_exists($componentCn)) {
|
if (!class_exists($componentCn)) {
|
||||||
if (is_null($plugin) || !loadPluginComponent($plugin, $component)) {
|
if (is_null($plugin) || !loadPluginComponent($plugin, $component)) {
|
||||||
if (!loadComponent($component)) {
|
if (!App::import('Component', $component)) {
|
||||||
$this->cakeError('missingComponentFile', array(array(
|
$this->cakeError('missingComponentFile', array(array(
|
||||||
'className' => $this->controller->name,
|
'className' => $this->controller->name,
|
||||||
'component' => $component,
|
'component' => $component,
|
||||||
|
|
|
@ -49,7 +49,7 @@ class AclComponent extends Object {
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$name = Configure::read('Acl.classname');
|
$name = Configure::read('Acl.classname');
|
||||||
if (!class_exists($name)) {
|
if (!class_exists($name)) {
|
||||||
if (loadComponent($name)) {
|
if (App::import('Component'. $name)) {
|
||||||
if (strpos($name, '.') !== false) {
|
if (strpos($name, '.') !== false) {
|
||||||
list($plugin, $name) = explode('.', $name);
|
list($plugin, $name) = explode('.', $name);
|
||||||
}
|
}
|
||||||
|
@ -245,8 +245,8 @@ class DB_ACL extends AclBase {
|
||||||
function __construct() {
|
function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
uses('model' . DS . 'db_acl');
|
uses('model' . DS . 'db_acl');
|
||||||
$this->Aro =& new Aro();
|
$this->Aro =& ClassRegistry::init(array('class' => 'Aro', 'alias' => 'Aro'));
|
||||||
$this->Aco =& new Aco();
|
$this->Aco =& ClassRegistry::init(array('class' => 'Aco', 'alias' => 'Aco'));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
|
|
|
@ -654,21 +654,21 @@ class EmailComponent extends Object{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->__sendData("MAIL FROM: {$this->__formatAddress($this->from, true)}\r\n")) {
|
if (!$this->__sendData("MAIL FROM: " . $this->__formatAddress($this->from, true) . "\r\n")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->__sendData("RCPT TO: {$this->__formatAddress($this->to, true)}\r\n")) {
|
if (!$this->__sendData("RCPT TO: " . $this->__formatAddress($this->to, true) . "\r\n")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->cc as $cc) {
|
foreach ($this->cc as $cc) {
|
||||||
if (!$this->__sendData("RCPT TO: {$this->__formatAddress($cc, true)}\r\n")) {
|
if (!$this->__sendData("RCPT TO: " . $this->__formatAddress($cc, true) . "\r\n")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($this->bcc as $bcc) {
|
foreach ($this->bcc as $bcc) {
|
||||||
if (!$this->__sendData("RCPT TO: {$this->__formatAddress($bcc, true)}\r\n")) {
|
if (!$this->__sendData("RCPT TO: " . $this->__formatAddress($bcc, true) . "\r\n")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -680,7 +680,7 @@ class EmailComponent extends Object{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->__sendData("{$this->__header}\r\n{$this->__message}\r\n\r\n\r\n.\r\n")) {
|
if (!$this->__sendData($this->__header . "\r\n" . $this->__message . "\r\n\r\n\r\n.\r\n")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->__sendData("QUIT\r\n", false);
|
$this->__sendData("QUIT\r\n", false);
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
/**
|
/**
|
||||||
* Include files
|
* Include files
|
||||||
*/
|
*/
|
||||||
uses('controller' . DS . 'component', 'view' . DS . 'view');
|
App::import('Core', 'Component');
|
||||||
|
App::import('Core', 'View');;
|
||||||
/**
|
/**
|
||||||
* Controller
|
* Controller
|
||||||
*
|
*
|
||||||
|
@ -383,37 +384,40 @@ class Controller extends Object {
|
||||||
* @return mixed true when single model found and instance created error returned if models not found.
|
* @return mixed true when single model found and instance created error returned if models not found.
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function loadModel($modelClass = null, $id = false) {
|
function loadModel($modelClass = null, $id = null) {
|
||||||
if ($modelClass === null) {
|
if ($modelClass === null) {
|
||||||
$modelClass = $this->modelClass;
|
$modelClass = $this->modelClass;
|
||||||
}
|
}
|
||||||
$cached = false;
|
$cached = false;
|
||||||
$object = null;
|
$object = null;
|
||||||
$plugin = null;
|
$plugin = null;
|
||||||
|
if ($this->uses === false) {
|
||||||
if ($this->plugin) {
|
if ($this->plugin) {
|
||||||
$plugin = $this->plugin . '.';
|
$plugin = $this->plugin . '.';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (strpos($modelClass, '.') !== false) {
|
if (strpos($modelClass, '.') !== false) {
|
||||||
list($plugin, $modelClass) = explode('.', $modelClass);
|
list($plugin, $modelClass) = explode('.', $modelClass);
|
||||||
$plugin = $plugin . '.';
|
$plugin = $plugin . '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$modelKey = Inflector::underscore($modelClass);
|
|
||||||
|
|
||||||
if (!class_exists($modelClass)) {
|
|
||||||
loadModel($plugin . $modelClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (class_exists($modelClass)) {
|
|
||||||
if ($this->persistModel === true) {
|
if ($this->persistModel === true) {
|
||||||
$cached = $this->_persist($modelClass, null, $object);
|
$cached = $this->_persist($modelClass, null, $object);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($cached === false)) {
|
if (($cached === false)) {
|
||||||
$model =& new $modelClass($id);
|
|
||||||
$this->modelNames[] = $modelClass;
|
$this->modelNames[] = $modelClass;
|
||||||
$this->{$modelClass} =& $model;
|
|
||||||
|
if (!PHP5) {
|
||||||
|
$this->{$modelClass} =& ClassRegistry::init(array('class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id));
|
||||||
|
} else {
|
||||||
|
$this->{$modelClass} = ClassRegistry::init(array('class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->{$modelClass}) {
|
||||||
|
return $this->cakeError('missingModel', array(array('className' => $modelClass, 'webroot' => '', 'base' => $this->base)));
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->persistModel === true) {
|
if ($this->persistModel === true) {
|
||||||
$this->_persist($modelClass, true, $model);
|
$this->_persist($modelClass, true, $model);
|
||||||
|
@ -425,9 +429,6 @@ class Controller extends Object {
|
||||||
$this->_persist($modelClass, true, $object);
|
$this->_persist($modelClass, true, $object);
|
||||||
$this->modelNames[] = $modelClass;
|
$this->modelNames[] = $modelClass;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return $this->cakeError('missingModel', array(array('className' => $modelClass, 'webroot' => '', 'base' => $this->base)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Redirects to given $url, after turning off $this->autoRender.
|
* Redirects to given $url, after turning off $this->autoRender.
|
||||||
|
@ -1036,5 +1037,4 @@ class Controller extends Object {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -154,9 +154,14 @@ class Scaffold extends Object {
|
||||||
return $this->cakeError('missingModel', array(array('className' => $this->modelKey, 'webroot' => '', 'base' => $this->controller->base)));
|
return $this->cakeError('missingModel', array(array('className' => $this->modelKey, 'webroot' => '', 'base' => $this->controller->base)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($controller->uses) && class_exists($controller->uses[0])) {
|
$class = $controller->uses[0];
|
||||||
$controller->modelClass = $controller->uses[0];
|
if (strpos($class, '.') !== false) {
|
||||||
$controller->modelKey = Inflector::underscore($controller->modelClass);
|
list($plugin, $class) = explode('.', $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($controller->uses) && class_exists($class)) {
|
||||||
|
$controller->modelClass = $class;
|
||||||
|
$controller->modelKey = Inflector::underscore($class);
|
||||||
}
|
}
|
||||||
$this->modelClass = $controller->modelClass;
|
$this->modelClass = $controller->modelClass;
|
||||||
$this->modelKey = $controller->modelKey;
|
$this->modelKey = $controller->modelKey;
|
||||||
|
|
|
@ -65,8 +65,9 @@ class ErrorHandler extends Object{
|
||||||
}
|
}
|
||||||
$this->__dispatch =& new Dispatcher();
|
$this->__dispatch =& new Dispatcher();
|
||||||
if (!class_exists('appcontroller')) {
|
if (!class_exists('appcontroller')) {
|
||||||
loadController(null);
|
App::import('Controller', 'App');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($__previousError != array($method, $messages)) {
|
if ($__previousError != array($method, $messages)) {
|
||||||
$__previousError = array($method, $messages);
|
$__previousError = array($method, $messages);
|
||||||
|
|
||||||
|
@ -392,5 +393,4 @@ class ErrorHandler extends Object{
|
||||||
return $this->__dispatch->webroot;
|
return $this->__dispatch->webroot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -412,11 +412,12 @@ class Folder extends Object{
|
||||||
* Returns an array of nested directories and files in each directory
|
* Returns an array of nested directories and files in each directory
|
||||||
*
|
*
|
||||||
* @param string $path the directory path to build the tree from
|
* @param string $path the directory path to build the tree from
|
||||||
* @param = boolean $hidden return hidden files and directories
|
* @param boolean $hidden return hidden files and directories
|
||||||
|
* @param string $type either file or dir. null returns both files and directories
|
||||||
* @return mixed array of nested directories and files in each directory
|
* @return mixed array of nested directories and files in each directory
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function tree($path, $hidden = true) {
|
function tree($path, $hidden = true, $type = null) {
|
||||||
$path = rtrim($path, DS);
|
$path = rtrim($path, DS);
|
||||||
$this->__files = array();
|
$this->__files = array();
|
||||||
$this->__directories = array($path);
|
$this->__directories = array($path);
|
||||||
|
@ -428,8 +429,13 @@ class Folder extends Object{
|
||||||
array_push($directories, $dir);
|
array_push($directories, $dir);
|
||||||
|
|
||||||
}
|
}
|
||||||
$return = array($directories, $this->__files);
|
if ($type === null) {
|
||||||
return $return;
|
return array($directories, $this->__files);
|
||||||
|
}
|
||||||
|
if ($type === 'dir') {
|
||||||
|
return $directories;
|
||||||
|
}
|
||||||
|
return $this->__files;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Private method to list directories and files in each directory
|
* Private method to list directories and files in each directory
|
||||||
|
@ -457,9 +463,9 @@ class Folder extends Object{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
closedir($dirHandle);
|
closedir($dirHandle);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Create a directory structure recursively.
|
* Create a directory structure recursively.
|
||||||
*
|
*
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
/**
|
/**
|
||||||
* Included libraries.
|
* Included libraries.
|
||||||
*/
|
*/
|
||||||
uses('l10n');
|
App::import('Core', 'l10n');
|
||||||
/**
|
/**
|
||||||
* Short description for file.
|
* Short description for file.
|
||||||
*
|
*
|
||||||
|
|
|
@ -291,7 +291,14 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
$className = 'I18nModel';
|
$className = 'I18nModel';
|
||||||
} else {
|
} else {
|
||||||
$className = $model->translateModel;
|
$className = $model->translateModel;
|
||||||
if (!class_exists($className) && !loadModel($className)) {
|
$plugin = null;
|
||||||
|
|
||||||
|
if (strpos($className, '.') !== false) {
|
||||||
|
list($plugin, $className) = explode('.', $className);
|
||||||
|
$plugin = $plugin . '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!class_exists($className) && !loadModel($plugin . $className)) {
|
||||||
return $this->cakeError('missingModel', array(array('className' => $className)));
|
return $this->cakeError('missingModel', array(array('className' => $className)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
/**
|
/**
|
||||||
* Load Model and AppModel
|
* Load Model and AppModel
|
||||||
*/
|
*/
|
||||||
loadModel();
|
App::import('Model', 'App');
|
||||||
/**
|
/**
|
||||||
* Short description for file.
|
* Short description for file.
|
||||||
*
|
*
|
||||||
|
@ -126,11 +126,11 @@ class AclNode extends AppModel {
|
||||||
} elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) {
|
} elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) {
|
||||||
$name = key($ref);
|
$name = key($ref);
|
||||||
if (!ClassRegistry::isKeySet($name)) {
|
if (!ClassRegistry::isKeySet($name)) {
|
||||||
if (!loadModel($name)) {
|
if (!App::import($name)) {
|
||||||
trigger_error("Model class '$name' not found in AclNode::node() when trying to bind {$this->alias} object", E_USER_WARNING);
|
trigger_error("Model class '$name' not found in AclNode::node() when trying to bind {$this->alias} object", E_USER_WARNING);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$model =& new $name();
|
$model =& ClassRegistry::init(array('class' => $name, 'alias' => $name));
|
||||||
} else {
|
} else {
|
||||||
$model =& ClassRegistry::getObject($name);
|
$model =& ClassRegistry::getObject($name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,12 @@
|
||||||
/**
|
/**
|
||||||
* Included libs
|
* Included libs
|
||||||
*/
|
*/
|
||||||
uses('class_registry', 'validation', 'overloadable', 'model' . DS . 'behavior', 'model' . DS . 'connection_manager', 'set');
|
App::import('Core', 'ClassRegistry');
|
||||||
|
App::import('Core', 'Validation');
|
||||||
|
App::import('Core', 'Behavior');
|
||||||
|
App::import('Core', 'ConnectionManager');
|
||||||
|
App::import('Core', 'Set');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object-relational mapper.
|
* Object-relational mapper.
|
||||||
*
|
*
|
||||||
|
@ -334,9 +339,7 @@ class Model extends Overloadable {
|
||||||
} else {
|
} else {
|
||||||
$this->alias = $this->name;
|
$this->alias = $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassRegistry::addObject($this->alias, $this);
|
ClassRegistry::addObject($this->alias, $this);
|
||||||
ClassRegistry::map($this->alias, $this->alias);
|
|
||||||
|
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
unset($id);
|
unset($id);
|
||||||
|
@ -399,7 +402,7 @@ class Model extends Overloadable {
|
||||||
foreach ($this->actsAs as $behavior => $config) {
|
foreach ($this->actsAs as $behavior => $config) {
|
||||||
$className = $behavior . 'Behavior';
|
$className = $behavior . 'Behavior';
|
||||||
|
|
||||||
if (!loadBehavior($behavior)) {
|
if (!App::import('Behavior', $behavior)) {
|
||||||
// Raise an error
|
// Raise an error
|
||||||
} else {
|
} else {
|
||||||
if (ClassRegistry::isKeySet($className)) {
|
if (ClassRegistry::isKeySet($className)) {
|
||||||
|
@ -611,18 +614,32 @@ class Model extends Overloadable {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->{$type} as $assoc => $value) {
|
foreach ($this->{$type} as $assoc => $value) {
|
||||||
|
$plugin = null;
|
||||||
if (is_numeric($assoc)) {
|
if (is_numeric($assoc)) {
|
||||||
unset ($this->{$type}[$assoc]);
|
unset ($this->{$type}[$assoc]);
|
||||||
$assoc = $value;
|
$assoc = $value;
|
||||||
$value = array();
|
$value = array();
|
||||||
$this->{$type}[$assoc] = $value;
|
$this->{$type}[$assoc] = $value;
|
||||||
|
|
||||||
|
if (strpos($assoc, '.') !== false) {
|
||||||
|
$value = $this->{$type}[$assoc];
|
||||||
|
unset($this->{$type}[$assoc]);
|
||||||
|
list($plugin, $assoc) = explode('.', $assoc);
|
||||||
|
$this->{$type}[$assoc] = $value;
|
||||||
|
$plugin = $plugin . '.';
|
||||||
}
|
}
|
||||||
$className = $assoc;
|
}
|
||||||
|
$className = $plugin . $assoc;
|
||||||
|
|
||||||
if (isset($value['className']) && !empty($value['className'])) {
|
if (isset($value['className']) && !empty($value['className'])) {
|
||||||
$className = $value['className'];
|
$className = $value['className'];
|
||||||
|
if (strpos($className, '.') !== false) {
|
||||||
|
list($plugin, $className) = explode('.', $className);
|
||||||
|
$plugin = $plugin . '.';
|
||||||
|
$this->{$type}[$assoc]['className'] = $className;
|
||||||
}
|
}
|
||||||
$this->__constructLinkedModel($assoc, $className);
|
}
|
||||||
|
$this->__constructLinkedModel($assoc, $plugin . $className);
|
||||||
}
|
}
|
||||||
$this->__generateAssociation($type);
|
$this->__generateAssociation($type);
|
||||||
}
|
}
|
||||||
|
@ -641,44 +658,20 @@ class Model extends Overloadable {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __constructLinkedModel($assoc, $className = null) {
|
function __constructLinkedModel($assoc, $className = null) {
|
||||||
$colKey = Inflector::underscore($assoc);
|
|
||||||
if(empty($className)) {
|
if(empty($className)) {
|
||||||
$className = $assoc;
|
$className = $assoc;
|
||||||
}
|
}
|
||||||
|
$model = array('class' => $className, 'alias' => $assoc);
|
||||||
|
|
||||||
if (!class_exists($className)) {
|
if (PHP5) {
|
||||||
if (!loadModel($className)) {
|
$this->{$assoc} = ClassRegistry::init($model);
|
||||||
return $this->cakeError('missingModel', array(array('className' => $className)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$duplicate = false;
|
|
||||||
|
|
||||||
if (ClassRegistry::isKeySet($colKey)) {
|
|
||||||
$model = ClassRegistry::getObject($colKey);
|
|
||||||
if (is_a($model, $className)) {
|
|
||||||
$duplicate = true;
|
|
||||||
}
|
|
||||||
unset($model);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($duplicate === true) {
|
|
||||||
if (!PHP5) {
|
|
||||||
$this->{$assoc} =& ClassRegistry::getObject($colKey);
|
|
||||||
ClassRegistry::map($assoc, $colKey);
|
|
||||||
} else {
|
} else {
|
||||||
$this->{$assoc} = ClassRegistry::getObject($colKey);
|
$this->{$assoc} =& ClassRegistry::init($model);
|
||||||
ClassRegistry::map($assoc, $colKey);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$model = array('name' => $className, 'alias' => $assoc);
|
|
||||||
if (!PHP5) {
|
|
||||||
$this->{$assoc} =& new $className($model);
|
|
||||||
} else {
|
|
||||||
$this->{$assoc} = new $className($model);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if ($assoc) {
|
||||||
$this->tableToModel[$this->{$assoc}->table] = $assoc;
|
$this->tableToModel[$this->{$assoc}->table] = $assoc;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Build array-based association from string.
|
* Build array-based association from string.
|
||||||
*
|
*
|
||||||
|
@ -727,7 +720,15 @@ class Model extends Overloadable {
|
||||||
|
|
||||||
if (isset($this->{$type}[$assocKey]['with']) && !empty($this->{$type}[$assocKey]['with'])) {
|
if (isset($this->{$type}[$assocKey]['with']) && !empty($this->{$type}[$assocKey]['with'])) {
|
||||||
$joinClass = $this->{$type}[$assocKey]['with'];
|
$joinClass = $this->{$type}[$assocKey]['with'];
|
||||||
if (!loadModel($joinClass)) {
|
$plugin = null;
|
||||||
|
|
||||||
|
if (strpos($joinClass, '.') !== false) {
|
||||||
|
list($plugin, $joinClass) = explode('.', $joinClass);
|
||||||
|
$plugin = $plugin . '.';
|
||||||
|
$this->{$type}[$assocKey]['with'] = $joinClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!App::import('Model', $plugin . $joinClass)) {
|
||||||
$this->{$joinClass} = new AppModel(array(
|
$this->{$joinClass} = new AppModel(array(
|
||||||
'name' => $joinClass,
|
'name' => $joinClass,
|
||||||
'table' => $this->{$type}[$assocKey]['joinTable'],
|
'table' => $this->{$type}[$assocKey]['joinTable'],
|
||||||
|
@ -736,7 +737,7 @@ class Model extends Overloadable {
|
||||||
$this->{$joinClass}->primaryKey = $this->{$type}[$assocKey]['foreignKey'];
|
$this->{$joinClass}->primaryKey = $this->{$type}[$assocKey]['foreignKey'];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->__constructLinkedModel($joinClass);
|
$this->__constructLinkedModel($plugin . $joinClass);
|
||||||
$this->{$joinClass}->primaryKey = $this->{$type}[$assocKey]['foreignKey'];
|
$this->{$joinClass}->primaryKey = $this->{$type}[$assocKey]['foreignKey'];
|
||||||
$this->{$type}[$assocKey]['joinTable'] = $this->{$joinClass}->table;
|
$this->{$type}[$assocKey]['joinTable'] = $this->{$joinClass}->table;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
require_once CAKE.'dispatcher.php';
|
require_once CAKE.'dispatcher.php';
|
||||||
require_once CAKE.'app_controller.php';
|
App::import('Core', 'AppController');
|
||||||
|
|
||||||
class TestDispatcher extends Dispatcher {
|
class TestDispatcher extends Dispatcher {
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,97 @@
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
uses('class_registry');
|
uses('class_registry');
|
||||||
/**
|
class ClassRegisterModel extends CakeTestModel {
|
||||||
* Short description for class.
|
var $useTable = false;
|
||||||
*
|
}
|
||||||
* @package cake.tests
|
|
||||||
* @subpackage cake.tests.cases.libs
|
|
||||||
*/
|
|
||||||
class ClassRegistryTest extends UnitTestCase {
|
|
||||||
|
|
||||||
function skip() {
|
class RegisterArticle extends ClassRegisterModel {
|
||||||
$this->skipif (true, 'ClassRegistry not implemented');
|
var $name = 'RegisterArticle';
|
||||||
|
}
|
||||||
|
class RegisterArticleFeatured extends ClassRegisterModel {
|
||||||
|
var $name = 'RegisterArticlFeatured';
|
||||||
|
}
|
||||||
|
|
||||||
|
class RegisterArticleTag extends ClassRegisterModel {
|
||||||
|
var $name = 'RegisterArticlTag';
|
||||||
|
}
|
||||||
|
|
||||||
|
class ClassRegistryTest extends UnitTestCase {
|
||||||
|
function testAddModel() {
|
||||||
|
if (PHP5) {
|
||||||
|
$Tag = ClassRegistry::init('RegisterArticleTag');
|
||||||
|
} else {
|
||||||
|
$Tag =& ClassRegistry::init('RegisterArticleTag');
|
||||||
|
}
|
||||||
|
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
|
||||||
|
|
||||||
|
$TagCopy = ClassRegistry::isKeySet('RegisterArticleTag');
|
||||||
|
$this->assertTrue($TagCopy);
|
||||||
|
|
||||||
|
$Tag->name = 'SomeNewName';
|
||||||
|
|
||||||
|
$TagCopy = ClassRegistry::getObject('RegisterArticleTag');
|
||||||
|
$this->assertTrue(is_a($TagCopy, 'RegisterArticleTag'));
|
||||||
|
$this->assertIdentical($Tag, $TagCopy);
|
||||||
|
|
||||||
|
$NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
|
||||||
|
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
|
||||||
|
|
||||||
|
$this->assertNotIdentical($Tag, $NewTag);
|
||||||
|
|
||||||
|
$NewTag->name = 'SomeOtherName';
|
||||||
|
$this->assertNotIdentical($Tag, $NewTag);
|
||||||
|
|
||||||
|
$Tag->name = 'SomeOtherName';
|
||||||
|
$this->assertNotIdentical($Tag, $NewTag);
|
||||||
|
|
||||||
|
$this->assertTrue($TagCopy->name === 'SomeOtherName');
|
||||||
|
}
|
||||||
|
|
||||||
|
function testClassRegistryFlush () {
|
||||||
|
$ArticleTag = ClassRegistry::getObject('RegisterArticleTag');
|
||||||
|
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
|
||||||
|
ClassRegistry::flush();
|
||||||
|
|
||||||
|
$NoArticleTag = ClassRegistry::isKeySet('RegisterArticleTag');
|
||||||
|
$this->assertFalse($NoArticleTag);
|
||||||
|
$this->assertTrue(is_a($ArticleTag, 'RegisterArticleTag'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function testAddMultiplModels () {
|
||||||
|
$Article = ClassRegistry::isKeySet('Article');
|
||||||
|
$this->assertFalse($Article);
|
||||||
|
|
||||||
|
$Featured = ClassRegistry::isKeySet('Featured');
|
||||||
|
$this->assertFalse($Featured);
|
||||||
|
|
||||||
|
$Tag = ClassRegistry::isKeySet('Tag');
|
||||||
|
$this->assertFalse($Tag);
|
||||||
|
|
||||||
|
$models = array(array('class' => 'RegisterArticle', 'alias' => 'Article'),
|
||||||
|
array('class' => 'RegisterArticleFeatured', 'alias' => 'Featured'),
|
||||||
|
array('class' => 'RegisterArticleTag', 'alias' => 'Tag'));
|
||||||
|
|
||||||
|
$added = ClassRegistry::init($models);
|
||||||
|
$this->assertTrue($added);
|
||||||
|
|
||||||
|
$Article = ClassRegistry::isKeySet('Article');
|
||||||
|
$this->assertTrue($Article);
|
||||||
|
|
||||||
|
$Featured = ClassRegistry::isKeySet('Featured');
|
||||||
|
$this->assertTrue($Featured);
|
||||||
|
|
||||||
|
$Tag = ClassRegistry::isKeySet('Tag');
|
||||||
|
$this->assertTrue($Tag);
|
||||||
|
|
||||||
|
$Article = ClassRegistry::getObject('Article');
|
||||||
|
$this->assertTrue(is_a($Article, 'RegisterArticle'));
|
||||||
|
|
||||||
|
$Featured = ClassRegistry::getObject('Featured');
|
||||||
|
$this->assertTrue(is_a($Featured, 'RegisterArticleFeatured'));
|
||||||
|
|
||||||
|
$Tag = ClassRegistry::getObject('Tag');
|
||||||
|
$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -59,22 +59,19 @@ class ControllerTest extends CakeTestCase {
|
||||||
$Controller->uses = array('ControllerPost', 'ControllerComment');
|
$Controller->uses = array('ControllerPost', 'ControllerComment');
|
||||||
$Controller->passedArgs[] = '1';
|
$Controller->passedArgs[] = '1';
|
||||||
$Controller->constructClasses();
|
$Controller->constructClasses();
|
||||||
$this->assertTrue($Controller->ControllerPost == new ControllerPost());
|
$this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost'));
|
||||||
$this->assertTrue($Controller->ControllerComment == new ControllerComment());
|
$this->assertTrue(is_a($Controller->ControllerComment, 'ControllerComment'));
|
||||||
$this->assertFalse($Controller->ControllerComment != new ControllerComment());
|
|
||||||
|
|
||||||
unset($Controller);
|
unset($Controller);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testPersistent() {
|
function testPersistent() {
|
||||||
|
|
||||||
$Controller =& new Controller();
|
$Controller =& new Controller();
|
||||||
$Controller->modelClass = 'ControllerPost';
|
$Controller->modelClass = 'ControllerPost';
|
||||||
$Controller->persistModel = true;
|
$Controller->persistModel = true;
|
||||||
$Controller->constructClasses();
|
$Controller->constructClasses();
|
||||||
$this->assertTrue(file_exists(CACHE . 'persistent' . DS .'controllerpost.php'));
|
$this->assertTrue(file_exists(CACHE . 'persistent' . DS .'controllerpost.php'));
|
||||||
$this->assertTrue($Controller->ControllerPost == new ControllerPost());
|
$this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost'));
|
||||||
unlink(CACHE . 'persistent' . DS . 'controllerpost.php');
|
unlink(CACHE . 'persistent' . DS . 'controllerpost.php');
|
||||||
unlink(CACHE . 'persistent' . DS . 'controllerpostregistry.php');
|
unlink(CACHE . 'persistent' . DS . 'controllerpostregistry.php');
|
||||||
|
|
||||||
|
|
99
cake/tests/cases/libs/loader.test.php
Normal file
99
cake/tests/cases/libs/loader.test.php
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
<?php
|
||||||
|
/* SVN FILE: $Id$ */
|
||||||
|
/**
|
||||||
|
* Short description for file.
|
||||||
|
*
|
||||||
|
* Long description for file
|
||||||
|
*
|
||||||
|
* PHP versions 4 and 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||||
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* 1785 E. Sahara Avenue, Suite 490-204
|
||||||
|
* Las Vegas, Nevada 89104
|
||||||
|
*
|
||||||
|
* Licensed under The Open Group Test Suite License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @filesource
|
||||||
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
||||||
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||||
|
* @package cake.tests
|
||||||
|
* @subpackage cake.tests.cases.libs
|
||||||
|
* @since CakePHP(tm) v 1.2.0.5432
|
||||||
|
* @version $Revision$
|
||||||
|
* @modifiedby $LastChangedBy$
|
||||||
|
* @lastmodified $Date$
|
||||||
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
|
*/
|
||||||
|
uses('configure');
|
||||||
|
class AppImportTest extends UnitTestCase {
|
||||||
|
var $realFile;
|
||||||
|
|
||||||
|
function testClassLoading() {
|
||||||
|
$file = App::import();
|
||||||
|
$this->assertTrue($file);
|
||||||
|
|
||||||
|
$file = App::import('Core', 'Model', false);
|
||||||
|
$this->assertTrue($file);
|
||||||
|
|
||||||
|
$file = App::import('Model', 'SomeRandomModelThatDoesNotExist', false);
|
||||||
|
$this->assertFalse($file);
|
||||||
|
|
||||||
|
$file = App::import('Model', 'AppModel', false);
|
||||||
|
$this->assertTrue($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFileLoading () {
|
||||||
|
$file = App::import('File', 'RealFile', false, array(), CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'config' . DS . 'config.php');
|
||||||
|
$this->assertTrue($file);
|
||||||
|
|
||||||
|
$file = App::import('File', 'NoFile', false, array(), CAKE_CORE_INCLUDE_PATH . DS . 'config' . DS . 'cake' . DS . 'config.php');
|
||||||
|
$this->assertFalse($file);
|
||||||
|
}
|
||||||
|
// import($type = null, $name = null, $parent = true, $file = null, $search = array(), $return = false) {
|
||||||
|
function testFileLoadingWithArray() {
|
||||||
|
$type = array('type' => 'File', 'name' => 'SomeName', 'parent' => false,
|
||||||
|
'file' => CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'config' . DS . 'config.php');
|
||||||
|
$file = App::import($type);
|
||||||
|
$this->assertTrue($file);
|
||||||
|
|
||||||
|
$type = array('type' => 'File', 'name' => 'NoFile', 'parent' => false,
|
||||||
|
'file' => CAKE_CORE_INCLUDE_PATH . DS . 'config' . DS . 'cake' . DS . 'config.php');
|
||||||
|
$file = App::import($type);
|
||||||
|
$this->assertFalse($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFileLoadingReturnValue () {
|
||||||
|
$file = App::import('File', 'Name', false, array(), CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'config' . DS . 'config.php', true);
|
||||||
|
$this->assertTrue($file);
|
||||||
|
|
||||||
|
$this->assertTrue(isset($file['Cake.version']));
|
||||||
|
|
||||||
|
$type = array('type' => 'File', 'name' => 'OtherName', 'parent' => false,
|
||||||
|
'file' => CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'config' . DS . 'config.php', 'return' => true);
|
||||||
|
$file = App::import($type);
|
||||||
|
$this->assertTrue($file);
|
||||||
|
|
||||||
|
$this->assertTrue(isset($file['Cake.version']));
|
||||||
|
}
|
||||||
|
|
||||||
|
function testLoadingWithSearch () {
|
||||||
|
$file = App::import('File', 'NewName', false, array(CAKE_CORE_INCLUDE_PATH), 'config.php');
|
||||||
|
$this->assertTrue($file);
|
||||||
|
|
||||||
|
$file = App::import('File', 'AnotherNewName', false, array(LIBS), 'config.php');
|
||||||
|
$this->assertFalse($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testLoadingWithSearchArray () {
|
||||||
|
$type = array('type' => 'File', 'name' => 'RandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(CAKE_CORE_INCLUDE_PATH));
|
||||||
|
$file = App::import($type);
|
||||||
|
$this->assertTrue($file);
|
||||||
|
|
||||||
|
$type = array('type' => 'File', 'name' => 'AnotherRandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(LIBS));
|
||||||
|
$file = App::import($type);
|
||||||
|
$this->assertFalse($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
|
@ -154,5 +154,4 @@ class DBACL_TEST extends DB_ACL {
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -29,9 +29,7 @@
|
||||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||||
}
|
}
|
||||||
|
uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'ajax',
|
||||||
require_once CAKE.'app_helper.php';
|
|
||||||
uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'ajax',
|
|
||||||
'view'.DS.'helpers'.DS.'html', 'view'.DS.'helpers'.DS.'form', 'view'.DS.'helpers'.DS.'javascript');
|
'view'.DS.'helpers'.DS.'html', 'view'.DS.'helpers'.DS.'form', 'view'.DS.'helpers'.DS.'javascript');
|
||||||
|
|
||||||
class AjaxTestController extends Controller {
|
class AjaxTestController extends Controller {
|
||||||
|
|
|
@ -30,8 +30,7 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'cache');
|
||||||
uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'cache');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
|
|
|
@ -30,13 +30,10 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper',
|
||||||
|
|
||||||
uses(
|
|
||||||
'class_registry', 'controller'.DS.'controller', 'model'.DS.'model',
|
'class_registry', 'controller'.DS.'controller', 'model'.DS.'model',
|
||||||
'view'.DS.'helper', 'view'.DS.'helpers'.DS.'html', 'view'.DS.'view',
|
'view'.DS.'helper', 'view'.DS.'helpers'.DS.'html', 'view'.DS.'view',
|
||||||
'view'.DS.'helpers'.DS.'form'
|
'view'.DS.'helpers'.DS.'form');
|
||||||
);
|
|
||||||
|
|
||||||
class ContactTestController extends Controller {
|
class ContactTestController extends Controller {
|
||||||
var $name = 'ContactTest';
|
var $name = 'ContactTest';
|
||||||
|
|
|
@ -26,8 +26,7 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper', 'class_registry', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper',
|
||||||
uses('class_registry', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper',
|
|
||||||
'view'.DS.'helpers'.DS.'html', 'view'.DS.'helpers'.DS.'form');
|
'view'.DS.'helpers'.DS.'html', 'view'.DS.'helpers'.DS.'form');
|
||||||
|
|
||||||
class TheHtmlTestController extends Controller {
|
class TheHtmlTestController extends Controller {
|
||||||
|
|
|
@ -26,8 +26,7 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'javascript',
|
||||||
uses('view'.DS.'helper', 'view'.DS.'helpers'.DS.'javascript',
|
|
||||||
'view'.DS.'helpers'.DS.'html', 'view'.DS.'helpers'.DS.'form');
|
'view'.DS.'helpers'.DS.'html', 'view'.DS.'helpers'.DS.'form');
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
|
|
|
@ -30,8 +30,7 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'js');
|
||||||
uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'js');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
|
|
|
@ -26,8 +26,7 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'number');
|
||||||
uses('view'.DS.'helper', 'view'.DS.'helpers'.DS.'number');
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
|
|
@ -26,8 +26,7 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'html', 'view'.DS.'helpers'.DS.'form',
|
||||||
uses('view'.DS.'helper', 'view'.DS.'helpers'.DS.'html', 'view'.DS.'helpers'.DS.'form',
|
|
||||||
'view'.DS.'helpers'.DS.'ajax', 'view'.DS.'helpers'.DS.'javascript', 'view'.DS.'helpers'.DS.'paginator');
|
'view'.DS.'helpers'.DS.'ajax', 'view'.DS.'helpers'.DS.'javascript', 'view'.DS.'helpers'.DS.'paginator');
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
|
|
|
@ -29,9 +29,7 @@
|
||||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||||
}
|
}
|
||||||
|
uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'rss');
|
||||||
require_once CAKE.'app_helper.php';
|
|
||||||
uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'rss');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
|
|
|
@ -30,8 +30,7 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'session');
|
||||||
uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'session');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
|
|
|
@ -26,8 +26,7 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'text');
|
||||||
uses('view'.DS.'helper', 'view'.DS.'helpers'.DS.'text');
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
|
|
@ -30,8 +30,7 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'time');
|
||||||
uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'time');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
|
|
|
@ -30,8 +30,7 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once CAKE.'app_helper.php';
|
uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'xml');
|
||||||
uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'xml');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
|
|
Loading…
Reference in a new issue