diff --git a/app/console/shells/empty b/app/Console/Command/Task/empty similarity index 100% rename from app/console/shells/empty rename to app/Console/Command/Task/empty diff --git a/app/console/shells/tasks/empty b/app/Console/Command/empty similarity index 100% rename from app/console/shells/tasks/empty rename to app/Console/Command/empty diff --git a/app/console/cake b/app/Console/cake similarity index 100% rename from app/console/cake rename to app/Console/cake diff --git a/app/console/cake.bat b/app/Console/cake.bat similarity index 100% rename from app/console/cake.bat rename to app/Console/cake.bat diff --git a/app/console/cake.php b/app/Console/cake.php old mode 100755 new mode 100644 similarity index 86% rename from app/console/cake.php rename to app/Console/cake.php index 9200fd36b..ef5e26816 --- a/app/console/cake.php +++ b/app/Console/cake.php @@ -19,6 +19,6 @@ * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'cake' . DIRECTORY_SEPARATOR . 'console' . DIRECTORY_SEPARATOR . 'shell_dispatcher.php'); +require_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'lib'. DIRECTORY_SEPARATOR . 'Cake' . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'ShellDispatcher.php'); return ShellDispatcher::run($argv); diff --git a/app/console/shells/templates/empty b/app/Console/templates/empty similarity index 100% rename from app/console/shells/templates/empty rename to app/Console/templates/empty diff --git a/app/controllers/components/empty b/app/Controller/Component/empty similarity index 100% rename from app/controllers/components/empty rename to app/Controller/Component/empty diff --git a/app/libs/empty b/app/Lib/empty similarity index 100% rename from app/libs/empty rename to app/Lib/empty diff --git a/app/models/behaviors/empty b/app/Model/Behavior/empty similarity index 100% rename from app/models/behaviors/empty rename to app/Model/Behavior/empty diff --git a/app/models/datasources/empty b/app/Model/Datasource/empty similarity index 100% rename from app/models/datasources/empty rename to app/Model/Datasource/empty diff --git a/app/tests/cases/behaviors/empty b/app/View/Helper/empty similarity index 100% rename from app/tests/cases/behaviors/empty rename to app/View/Helper/empty diff --git a/app/tests/cases/components/empty b/app/View/elements/email/html/empty similarity index 100% rename from app/tests/cases/components/empty rename to app/View/elements/email/html/empty diff --git a/app/tests/cases/controllers/empty b/app/View/elements/email/text/empty similarity index 100% rename from app/tests/cases/controllers/empty rename to app/View/elements/email/text/empty diff --git a/app/tests/cases/helpers/empty b/app/View/elements/empty similarity index 100% rename from app/tests/cases/helpers/empty rename to app/View/elements/empty diff --git a/app/tests/cases/models/empty b/app/View/errors/empty similarity index 100% rename from app/tests/cases/models/empty rename to app/View/errors/empty diff --git a/app/tests/fixtures/empty b/app/View/layouts/email/html/empty similarity index 100% rename from app/tests/fixtures/empty rename to app/View/layouts/email/html/empty diff --git a/app/tests/groups/empty b/app/View/layouts/email/text/empty similarity index 100% rename from app/tests/groups/empty rename to app/View/layouts/email/text/empty diff --git a/app/views/elements/email/html/empty b/app/View/layouts/js/empty similarity index 100% rename from app/views/elements/email/html/empty rename to app/View/layouts/js/empty diff --git a/app/views/elements/email/text/empty b/app/View/layouts/rss/empty similarity index 100% rename from app/views/elements/email/text/empty rename to app/View/layouts/rss/empty diff --git a/app/views/elements/empty b/app/View/layouts/xml/empty similarity index 100% rename from app/views/elements/empty rename to app/View/layouts/xml/empty diff --git a/app/views/errors/empty b/app/View/pages/empty similarity index 100% rename from app/views/errors/empty rename to app/View/pages/empty diff --git a/app/views/helpers/empty b/app/View/scaffolds/empty similarity index 100% rename from app/views/helpers/empty rename to app/View/scaffolds/empty diff --git a/app/config/database.php.default b/app/config/database.php.default index 9fb8e9e98..b7eb4bba2 100644 --- a/app/config/database.php.default +++ b/app/config/database.php.default @@ -28,15 +28,15 @@ * You can specify multiple configurations for production, development and testing. * * driver => The name of a supported driver; valid options are as follows: - * mysql - MySQL 4 & 5, - * sqlite - SQLite (PHP5 only), - * postgres - PostgreSQL 7 and higher, - * mssql - Microsoft SQL Server 2000 and higher, - * oracle - Oracle 8 and higher + * Datasabe/Mysql - MySQL 4 & 5, + * Datasabe/Sqlite - SQLite (PHP5 only), + * Datasabe/Postgres - PostgreSQL 7 and higher, + * Datasabe/Mssql - Microsoft SQL Server 2000 and higher, + * Datasabe/Oracle - Oracle 8 and higher * * You can add custom database drivers (or override existing drivers) by adding the - * appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php', - * where 'x' is the name of the database. + * appropriate file to app/models/datasources/database. Drivers should be named 'MyDriver.php', + * * * persistent => true / false * Determines whether or not the database should use a persistent connection @@ -59,7 +59,7 @@ class DATABASE_CONFIG { public $default = array( - 'driver' => 'mysql', + 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', @@ -69,7 +69,7 @@ class DATABASE_CONFIG { ); public $test = array( - 'driver' => 'mysql', + 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', diff --git a/app/views/layouts/email/html/empty b/app/tests/Case/Controller/Component/empty similarity index 100% rename from app/views/layouts/email/html/empty rename to app/tests/Case/Controller/Component/empty diff --git a/app/views/layouts/email/text/empty b/app/tests/Case/Controller/empty similarity index 100% rename from app/views/layouts/email/text/empty rename to app/tests/Case/Controller/empty diff --git a/app/views/layouts/js/empty b/app/tests/Case/Model/Behavior/empty similarity index 100% rename from app/views/layouts/js/empty rename to app/tests/Case/Model/Behavior/empty diff --git a/app/views/layouts/rss/empty b/app/tests/Case/Model/empty similarity index 100% rename from app/views/layouts/rss/empty rename to app/tests/Case/Model/empty diff --git a/app/views/layouts/xml/empty b/app/tests/Case/View/Helper/empty similarity index 100% rename from app/views/layouts/xml/empty rename to app/tests/Case/View/Helper/empty diff --git a/app/views/pages/empty b/app/tests/Fixture/empty similarity index 100% rename from app/views/pages/empty rename to app/tests/Fixture/empty diff --git a/app/tmp/cache/models/empty b/app/tmp/cache/models/empty old mode 100755 new mode 100644 diff --git a/app/tmp/cache/views/empty b/app/tmp/cache/views/empty old mode 100755 new mode 100644 diff --git a/app/tmp/logs/empty b/app/tmp/logs/empty old mode 100755 new mode 100644 diff --git a/app/tmp/sessions/empty b/app/tmp/sessions/empty old mode 100755 new mode 100644 diff --git a/app/tmp/tests/empty b/app/tmp/tests/empty old mode 100755 new mode 100644 diff --git a/app/webroot/index.php b/app/webroot/index.php index f1ff8d197..3c5e71589 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -49,7 +49,7 @@ * */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT); + define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); } /** @@ -67,7 +67,7 @@ define('APP_PATH', ROOT . DS . APP_DIR . DS); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } - if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) { + if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } @@ -75,6 +75,6 @@ return; } - require LIBS . 'dispatcher.php'; + App::uses('Dispatcher', 'Routing'); $Dispatcher = new Dispatcher(); $Dispatcher->dispatch(new CakeRequest()); diff --git a/app/webroot/test.php b/app/webroot/test.php index c11aaac99..ffcedfe39 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -45,11 +45,11 @@ ini_set('display_errors', 1); define('APP_DIR', basename(dirname(dirname(__FILE__)))); } /** - * The absolute path to the "cake" directory, WITHOUT a trailing DS. + * The absolute path to the "Cake" directory, WITHOUT a trailing DS. * */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT); + define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); } /** @@ -67,21 +67,14 @@ if (!defined('CORE_PATH')) { define('APP_PATH', ROOT . DS . APP_DIR . DS); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } -if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) { +if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } -$corePath = App::core('cake'); -if (isset($corePath[0])) { - define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS); -} else { - define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH); -} - if (Configure::read('debug') < 1) { - die(__('Debug setting does not allow access to this url.')); + die(__d('cake', 'Debug setting does not allow access to this url.')); } -require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php'; +require_once CAKE_TESTS_LIB . 'CakeTestSuiteDispatcher.php'; CakeTestSuiteDispatcher::run(); diff --git a/cake/bootstrap.php b/cake/bootstrap.php deleted file mode 100644 index aa30770fc..000000000 --- a/cake/bootstrap.php +++ /dev/null @@ -1,39 +0,0 @@ - array('suffix' => '.php', 'extends' => null, 'core' => true), - 'file' => array('suffix' => '.php', 'extends' => null, 'core' => true), - 'model' => array('suffix' => '.php', 'extends' => 'AppModel', 'core' => false), - 'behavior' => array('suffix' => '.php', 'extends' => 'ModelBehavior', 'core' => true), - 'controller' => array('suffix' => '_controller.php', 'extends' => 'AppController', 'core' => true), - 'component' => array('suffix' => '.php', 'extends' => null, 'core' => true), - 'lib' => array('suffix' => '.php', 'extends' => null, 'core' => true), - 'view' => array('suffix' => '.php', 'extends' => null, 'core' => true), - 'helper' => array('suffix' => '.php', 'extends' => 'AppHelper', 'core' => true), - 'vendor' => array('suffix' => '', 'extends' => null, 'core' => true), - 'shell' => array('suffix' => '.php', 'extends' => 'Shell', 'core' => true), - 'plugin' => array('suffix' => '', 'extends' => null, 'core' => true) - ); - -/** - * List of additional path(s) where model files reside. - * - * @var array - */ - public static $models = array(); - -/** - * List of additional path(s) where behavior files reside. - * - * @var array - */ - public static $behaviors = array(); - -/** - * List of additional path(s) where controller files reside. - * - * @var array - */ - public static $controllers = array(); - -/** - * List of additional path(s) where component files reside. - * - * @var array - */ - public static $components = array(); - -/** - * List of additional path(s) where datasource files reside. - * - * @var array - */ - public static $datasources = array(); - -/** - * List of additional path(s) where libs files reside. - * - * @var array - */ - public static $libs = array(); - -/** - * List of additional path(s) where view files reside. - * - * @var array - */ - public static $views = array(); - -/** - * List of additional path(s) where helper files reside. - * - * @var array - */ - public static $helpers = array(); - -/** - * List of additional path(s) where plugins reside. - * - * @var array - */ - public static $plugins = array(); - -/** - * List of additional path(s) where vendor packages reside. - * - * @var array - */ - public static $vendors = array(); - -/** - * List of additional path(s) where locale files reside. - * - * @var array - */ - public static $locales = array(); - -/** - * List of additional path(s) where console shell files reside. - * - * @var array - */ - public static $shells = array(); - -/** - * Paths to search for files. - * - * @var array - */ - public static $search = array(); - -/** - * Whether or not to return the file that is loaded. - * - * @var boolean - */ - public static $return = false; - -/** - * Determines if $__maps and $__paths cache should be written. - * - * @var boolean - */ - private static $__cache = false; - -/** - * Holds key/value pairs of $type => file path. - * - * @var array - */ - private static $__map = array(); - -/** - * Holds paths for deep searching of files. - * - * @var array - */ - private static $__paths = array(); - -/** - * Holds loaded files. - * - * @var array - */ - private static $__loaded = array(); - -/** - * Holds and key => value array of object types. - * - * @var array - */ - private static $__objects = array(); - -/** - * Used to read information stored path - * - * Usage: - * - * `App::path('models'); will return all paths for models` - * - * @param string $type type of path - * @return string array - */ - public static function path($type) { - if (!isset(self::${$type})) { - return array(); - } - return self::${$type}; - } - -/** - * Build path references. Merges the supplied $paths - * with the base paths and the default core paths. - * - * @param array $paths paths defines in config/bootstrap.php - * @param boolean $reset true will set paths, false merges paths [default] false - * @return void - */ - public static function build($paths = array(), $reset = false) { - $defaults = array( - 'models' => array(MODELS), - 'behaviors' => array(BEHAVIORS), - 'datasources' => array(MODELS . 'datasources'), - 'controllers' => array(CONTROLLERS), - 'components' => array(COMPONENTS), - 'libs' => array(APPLIBS), - 'views' => array(VIEWS), - 'helpers' => array(HELPERS), - 'locales' => array(APP . 'locale' . DS), - 'shells' => array( - APP . 'console' . DS . 'shells' . DS, - APP . 'vendors' . DS . 'shells' . DS, - VENDORS . 'shells' . DS - ), - 'vendors' => array(APP . 'vendors' . DS, VENDORS), - 'plugins' => array(APP . 'plugins' . DS) - ); - - if ($reset == true) { - foreach ($paths as $type => $new) { - self::${$type} = (array)$new; - } - return $paths; - } - - $core = self::core(); - $app = array('models' => true, 'controllers' => true, 'helpers' => true); - - foreach ($defaults as $type => $default) { - $merge = array(); - - if (isset($app[$type])) { - $merge = array(APP); - } - if (isset($core[$type])) { - $merge = array_merge($merge, (array)$core[$type]); - } - - if (empty(self::${$type}) || empty($paths)) { - self::${$type} = $default; - } - - if (!empty($paths[$type])) { - $path = array_flip(array_flip(array_merge( - (array)$paths[$type], self::${$type}, $merge - ))); - } else { - $path = array_flip(array_flip(array_merge(self::${$type}, $merge))); - } - self::${$type} = array_values($path); - } - } - -/** - * Get the path that a plugin is on. Searches through the defined plugin paths. - * - * @param string $plugin CamelCased/lower_cased plugin name to find the path of. - * @return string full path to the plugin. - */ - public static function pluginPath($plugin) { - $pluginDir = Inflector::underscore($plugin); - for ($i = 0, $length = count(self::$plugins); $i < $length; $i++) { - if (is_dir(self::$plugins[$i] . $pluginDir)) { - return self::$plugins[$i] . $pluginDir . DS ; - } - } - return self::$plugins[0] . $pluginDir . DS; - } - -/** - * Find the path that a theme is on. Search through the defined theme paths. - * - * @param string $theme lower_cased theme name to find the path of. - * @return string full path to the theme. - */ - public static function themePath($theme) { - $themeDir = 'themed' . DS . Inflector::underscore($theme); - for ($i = 0, $length = count(self::$views); $i < $length; $i++) { - if (is_dir(self::$views[$i] . $themeDir)) { - return self::$views[$i] . $themeDir . DS ; - } - } - return self::$views[0] . $themeDir . DS; - } - -/** - * Returns a key/value list of all paths where core libs are found. - * Passing $type only returns the values for a given value of $key. - * - * @param string $type valid values are: 'model', 'behavior', 'controller', 'component', - * 'view', 'helper', 'datasource', 'libs', and 'cake' - * @return array numeric keyed array of core lib paths - */ - public static function core($type = null) { - static $paths = false; - if (!$paths) { - $paths = array(); - $libs = dirname(__FILE__) . DS; - $cake = dirname($libs) . DS; - $path = dirname($cake) . DS; - - $paths['cake'][] = $cake; - $paths['libs'][] = $libs; - $paths['models'][] = $libs . 'model' . DS; - $paths['datasources'][] = $libs . 'model' . DS . 'datasources' . DS; - $paths['behaviors'][] = $libs . 'model' . DS . 'behaviors' . DS; - $paths['controllers'][] = $libs . 'controller' . DS; - $paths['components'][] = $libs . 'controller' . DS . 'components' . DS; - $paths['views'][] = $libs . 'view' . DS; - $paths['helpers'][] = $libs . 'view' . DS . 'helpers' . DS; - $paths['plugins'][] = $path . 'plugins' . DS; - $paths['vendors'][] = $path . 'vendors' . DS; - $paths['shells'][] = $cake . 'console' . DS . 'shells' . DS; - // Provide BC path to vendors/shells - $paths['shells'][] = $path . 'vendors' . DS . 'shells' . DS; - } - if ($type && isset($paths[$type])) { - return $paths[$type]; - } - return $paths; - } - -/** - * Returns an array of objects of the given type. - * - * Example usage: - * - * `App::objects('plugin');` returns `array('DebugKit', 'Blog', 'User');` - * - * You can also search only within a plugin's objects by using the plugin dot - * syntax (these objects are not cached): - * - * `App::objects('MyPlugin.model');` returns `array('Post', 'Comment');` - * - * @param string $type Type of object, i.e. 'model', 'controller', 'helper', or 'plugin' - * @param mixed $path Optional Scan only the path given. If null, paths for the chosen - * type will be used. - * @param boolean $cache Set to false to rescan objects of the chosen type. Defaults to true. - * @return mixed Either false on incorrect / miss. Or an array of found objects. - */ - public static function objects($type, $path = null, $cache = true) { - $objects = array(); - $extension = false; - list($plugin, $type) = pluginSplit($type); - $name = $type; - - if ($plugin) { - $path = Inflector::pluralize($type); - if ($path == 'helpers') { - $path = 'views' . DS .$path; - } elseif ($path == 'behaviors') { - $path = 'models' . DS .$path; - } elseif ($path == 'components') { - $path = 'controllers' . DS .$path; - } - $path = self::pluginPath($plugin) . $path; - $cache = false; - } - - if ($type === 'file' && !$path) { - return false; - } elseif ($type === 'file') { - $extension = true; - $name = $type . str_replace(DS, '', $path); - } - - if (empty(self::$__objects) && $cache === true) { - self::$__objects = Cache::read('object_map', '_cake_core_'); - } - - if (!isset(self::$__objects[$name]) || $cache !== true) { - $types = self::$types; - - if (!isset($types[$type])) { - return false; - } - $objects = array(); - - if (empty($path)) { - $path = self::${"{$type}s"}; - if (isset($types[$type]['core']) && $types[$type]['core'] === false) { - array_pop($path); - } - } - $items = array(); - - foreach ((array)$path as $dir) { - if ($dir != APP) { - $items = self::__list($dir, $types[$type]['suffix'], $extension); - $objects = array_merge($items, array_diff($objects, $items)); - } - } - - if ($type !== 'file') { - foreach ($objects as $key => $value) { - $objects[$key] = Inflector::camelize($value); - } - } - - if ($cache === true) { - self::$__cache = true; - } - if ($plugin) { - return $objects; - } - self::$__objects[$name] = $objects; - } - - return self::$__objects[$name]; - } - -/** - * Allows you to modify the object listings that App maintains inside of it - * Useful for testing - * - * @param string $type Type of object listing you are changing - * @param array $values The values $type should be set to. - * @return void - */ - public static function setObjects($type, $values) { - self::$__objects[$type] = $values; - } - -/** - * Finds classes based on $name or specific file(s) to search. Calling App::import() will - * not construct any classes contained in the files. It will only find and require() the file. - * - * @link http://book.cakephp.org/view/934/Using-App-import - * @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, 'ext' => '$ext'); - * $ext allows setting the extension of the file name - * based on Inflector::underscore($name) . ".$ext"; - * @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 - */ - public static function import($type = null, $name = null, $parent = true, $search = array(), $file = null, $return = false) { - $plugin = $directory = null; - - if (is_array($type)) { - extract($type, EXTR_OVERWRITE); - } - - if (is_array($parent)) { - extract($parent, EXTR_OVERWRITE); - } - - if ($name === null && $file === null) { - $name = $type; - $type = 'Core'; - } elseif ($name === null) { - $type = 'File'; - } - - if (is_array($name)) { - foreach ($name as $class) { - $tempType = $type; - $plugin = null; - - if (strpos($class, '.') !== false) { - $value = explode('.', $class); - $count = count($value); - - if ($count > 2) { - $tempType = $value[0]; - $plugin = $value[1] . '.'; - $class = $value[2]; - } elseif ($count === 2 && ($type === 'Core' || $type === 'File')) { - $tempType = $value[0]; - $class = $value[1]; - } else { - $plugin = $value[0] . '.'; - $class = $value[1]; - } - } - - if (!App::import($tempType, $plugin . $class, $parent)) { - return false; - } - } - return true; - } - - if ($name != null && strpos($name, '.') !== false) { - list($plugin, $name) = explode('.', $name); - $plugin = Inflector::camelize($plugin); - } - self::$return = $return; - - if (isset($ext)) { - $file = Inflector::underscore($name) . ".{$ext}"; - } - $ext = self::__settings($type, $plugin, $parent); - $className = $name; - if (strpos($className, '/') !== false) { - $className = substr($className, strrpos($className, '/') + 1); - } - if ($name != null && !class_exists($className . $ext['class'])) { - if ($load = self::__mapped($name . $ext['class'], $type, $plugin)) { - if (self::__load($load)) { - if (self::$return) { - return include($load); - } - return true; - } else { - self::__remove($name . $ext['class'], $type, $plugin); - self::$__cache = true; - } - } - if (!empty($search)) { - self::$search = $search; - } elseif ($plugin) { - self::$search = self::__paths('plugin'); - } else { - self::$search = self::__paths($type); - } - $find = $file; - - if ($find === null) { - $find = Inflector::underscore($name . $ext['suffix']).'.php'; - - if ($plugin) { - $paths = self::$search; - foreach ($paths as $key => $value) { - self::$search[$key] = $value . $ext['path']; - } - } - } - - if (strtolower($type) !== 'vendor' && empty($search) && self::__load($file)) { - $directory = false; - } else { - $file = $find; - $directory = self::__find($find, true); - } - - if ($directory !== null) { - self::$__cache = true; - self::__map($directory . $file, $name . $ext['class'], $type, $plugin); - - if (self::$return) { - return include($directory . $file); - } - return true; - } - return false; - } - return true; - } - -/** - * Initializes the cache for App, registers a shutdown function. - * - * @return void - */ - public static function init() { - self::$__map = (array)Cache::read('file_map', '_cake_core_'); - register_shutdown_function(array('App', 'shutdown')); - } - -/** - * 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 - */ - private static function __find($file, $recursive = true) { - static $appPath = false; - - if (empty(self::$search)) { - return null; - } elseif (is_string(self::$search)) { - self::$search = array(self::$search); - } - - if (empty(self::$__paths)) { - self::$__paths = Cache::read('dir_map', '_cake_core_'); - } - - foreach (self::$search as $path) { - if ($appPath === false) { - $appPath = rtrim(APP, DS); - } - $path = rtrim($path, DS); - - if ($path === $appPath) { - $recursive = false; - } - if ($recursive === false) { - if (self::__load($path . DS . $file)) { - return $path . DS; - } - continue; - } - - if (!isset(self::$__paths[$path])) { - if (!class_exists('Folder')) { - require LIBS . 'folder.php'; - } - $Folder = new Folder(); - $directories = $Folder->tree($path, array('.svn', '.git', 'CVS', 'tests', 'templates'), 'dir'); - sort($directories); - self::$__paths[$path] = $directories; - } - - foreach (self::$__paths[$path] as $directory) { - if (self::__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 - * @access private - */ - private static function __load($file) { - if (empty($file)) { - return false; - } - if (!self::$return && isset(self::$__loaded[$file])) { - return true; - } - if (file_exists($file)) { - if (!self::$return) { - require($file); - self::$__loaded[$file] = true; - } - 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 camelized if object is from a plugin, the name of the plugin - * @return void - * @access private - */ - private static function __map($file, $name, $type, $plugin) { - if ($plugin) { - self::$__map['Plugin'][$plugin][$type][$name] = $file; - } else { - self::$__map[$type][$name] = $file; - } - } - -/** - * Returns a file's complete path. - * - * @param string $name unique name - * @param string $type type object - * @param string $plugin camelized if object is from a plugin, the name of the plugin - * @return mixed, file path if found, false otherwise - * @access private - */ - private static function __mapped($name, $type, $plugin) { - if ($plugin) { - if (isset(self::$__map['Plugin'][$plugin][$type]) && isset(self::$__map['Plugin'][$plugin][$type][$name])) { - return self::$__map['Plugin'][$plugin][$type][$name]; - } - return false; - } - - if (isset(self::$__map[$type]) && isset(self::$__map[$type][$name])) { - return self::$__map[$type][$name]; - } - return false; - } - -/** - * Loads parent classes based on $type. - * Returns a prefix or suffix needed for loading files. - * - * @param string $type type of object - * @param string $plugin camelized name of plugin - * @param boolean $parent false will not attempt to load parent - * @return array - * @access private - */ - private static function __settings($type, $plugin, $parent) { - if (!$parent) { - return array('class' => null, 'suffix' => null, 'path' => null); - } - - if ($plugin) { - $pluginPath = Inflector::underscore($plugin); - } - $path = null; - $load = strtolower($type); - - switch ($load) { - case 'model': - if (!class_exists('Model')) { - require LIBS . 'model' . DS . 'model.php'; - } - if (!class_exists('AppModel')) { - App::import($type, 'AppModel', false); - } - if ($plugin) { - if (!class_exists($plugin . 'AppModel')) { - App::import($type, $plugin . '.' . $plugin . 'AppModel', false, array(), $pluginPath . DS . $pluginPath . '_app_model.php'); - } - $path = $pluginPath . DS . 'models' . DS; - } - return array('class' => null, 'suffix' => null, 'path' => $path); - break; - case 'behavior': - if ($plugin) { - $path = $pluginPath . DS . 'models' . DS . 'behaviors' . DS; - } - return array('class' => $type, 'suffix' => null, 'path' => $path); - break; - case 'datasource': - if ($plugin) { - $path = $pluginPath . DS . 'models' . DS . 'datasources' . DS; - } - return array('class' => $type, 'suffix' => null, 'path' => $path); - case 'controller': - App::import($type, 'AppController', false); - if ($plugin) { - App::import($type, $plugin . '.' . $plugin . 'AppController', false, array(), $pluginPath . DS . $pluginPath . '_app_controller.php'); - $path = $pluginPath . DS . 'controllers' . DS; - } - return array('class' => $type, 'suffix' => $type, 'path' => $path); - break; - case 'component': - App::import('Core', 'Component', false); - if ($plugin) { - $path = $pluginPath . DS . 'controllers' . DS . 'components' . DS; - } - return array('class' => $type, 'suffix' => null, 'path' => $path); - break; - case 'lib': - if ($plugin) { - $path = $pluginPath . DS . 'libs' . DS; - } - return array('class' => null, 'suffix' => null, 'path' => $path); - break; - case 'view': - App::import('View', 'View', false); - if ($plugin) { - $path = $pluginPath . DS . 'views' . DS; - } - return array('class' => $type, 'suffix' => null, 'path' => $path); - break; - case 'helper': - if (!class_exists('AppHelper')) { - App::import($type, 'AppHelper', false); - } - if ($plugin) { - $path = $pluginPath . DS . 'views' . DS . 'helpers' . DS; - } - return array('class' => $type, 'suffix' => null, 'path' => $path); - break; - case 'shell': - if (!class_exists('Shell')) { - App::import($type, 'Shell', false); - } - if (!class_exists('AppShell')) { - App::import($type, 'AppShell', false); - } - if ($plugin) { - $path = $pluginPath . DS . 'console' . DS . 'shells' . DS; - } - return array('class' => $type, 'suffix' => null, 'path' => $path); - break; - case 'vendor': - if ($plugin) { - $path = $pluginPath . DS . 'vendors' . DS; - } - return array('class' => null, 'suffix' => null, 'path' => $path); - break; - default: - $type = $suffix = $path = null; - break; - } - return array('class' => null, 'suffix' => null, 'path' => null); - } - -/** - * Returns default search paths. - * - * @param string $type type of object to be searched - * @return array list of paths - */ - private static function __paths($type) { - $type = strtolower($type); - $paths = array(); - - if ($type === 'core') { - return App::core('libs'); - } - if (isset(self::${$type . 's'})) { - return self::${$type . 's'}; - } - return $paths; - } - -/** - * Removes file location from map if the file has been deleted. - * - * @param string $name name of object - * @param string $type type of object - * @param string $plugin camelized name of plugin - * @return void - */ - private static function __remove($name, $type, $plugin) { - if ($plugin) { - unset(self::$__map['Plugin'][$plugin][$type][$name]); - } else { - unset(self::$__map[$type][$name]); - } - } - -/** - * Returns an array of filenames of PHP files in the given directory. - * - * @param string $path Path to scan for files - * @param string $suffix if false, return only directories. if string, match and return files - * @return array List of directories or files in directory - */ - private static function __list($path, $suffix = false, $extension = false) { - if (!class_exists('Folder')) { - require LIBS . 'folder.php'; - } - $items = array(); - $Folder = new Folder($path); - $contents = $Folder->read(false, true); - - if (is_array($contents)) { - if (!$suffix) { - return $contents[0]; - } else { - foreach ($contents[1] as $item) { - if (substr($item, - strlen($suffix)) === $suffix) { - if ($extension) { - $items[] = $item; - } else { - $items[] = substr($item, 0, strlen($item) - strlen($suffix)); - } - } - } - } - } - return $items; - } - -/** - * Object destructor. - * - * Writes cache file if changes have been made to the $__map or $__paths - * - * @return void - */ - public static function shutdown() { - if (self::$__cache) { - $core = App::core('cake'); - unset(self::$__paths[rtrim($core[0], DS)]); - Cache::write('dir_map', array_filter(self::$__paths), '_cake_core_'); - Cache::write('file_map', array_filter(self::$__map), '_cake_core_'); - Cache::write('object_map', self::$__objects, '_cake_core_'); - } - } -} diff --git a/cake/libs/magic_db.php b/cake/libs/magic_db.php deleted file mode 100644 index 86a91d82d..000000000 --- a/cake/libs/magic_db.php +++ /dev/null @@ -1,291 +0,0 @@ -exists()) { - return false; - } - if ($File->ext() == 'php') { - include($File->pwd()); - $data = $magicDb; - } else { - // @TODO: Needs test coverage - $data = $File->read(); - } - } - - $magicDb = $this->toArray($data); - if (!$this->validates($magicDb)) { - return false; - } - return !!($this->db = $magicDb); - } - -/** - * Parses a MagicDb $data string into an array or returns the current MagicDb instance as an array - * - * @param string $data A MagicDb string to turn into an array - * @return array A parsed MagicDb array or an empty array if the $data param was invalid. Returns the db property if $data is not set. - */ - public function toArray($data = null) { - if (is_array($data)) { - return $data; - } - if ($data === null) { - return $this->db; - } - - if (strpos($data, '# FILE_ID DB') !== 0) { - return array(); - } - - $lines = explode("\r\n", $data); - $db = array(); - - $validHeader = count($lines) > 3 - && preg_match('/^# Date:([0-9]{4}-[0-9]{2}-[0-9]{2})$/', $lines[1], $date) - && preg_match('/^# Source:(.+)$/', $lines[2], $source) - && strlen($lines[3]) == 0; - if (!$validHeader) { - return $db; - } - - $db = array('header' => array('Date' => $date[1], 'Source' => $source[1]), 'database' => array()); - $lines = array_splice($lines, 3); - - $format = array(); - while (!empty($lines)) { - $line = array_shift($lines); - if (isset($line[0]) && $line[0] == '#' || empty($line)) { - continue; - } - - $columns = explode("\t", $line); - if (in_array($columns[0]{0}, array('>', '&'))) { - $format[] = $columns; - } elseif (!empty($format)) { - $db['database'][] = $format; - $format = array($columns); - } else { - $format = array($columns); - } - } - - return $db; - } - -/** - * Returns true if the MagicDb instance or the passed $magicDb is valid - * - * @param mixed $magicDb A $magicDb string / array to validate (optional) - * @return boolean True if the $magicDb / instance db validates, false if not - */ - public function validates($magicDb = null) { - if (is_null($magicDb)) { - $magicDb = $this->db; - } elseif (!is_array($magicDb)) { - $magicDb = $this->toArray($magicDb); - } - - return isset($magicDb['header'], $magicDb['database']) && is_array($magicDb['header']) && is_array($magicDb['database']); - } - -/** - * Analyzes a given $file using the currently loaded MagicDb information based on the desired $options - * - * @param string $file Absolute path to the file to analyze - * @param array $options TBT - * @return mixed - */ - public function analyze($file, $options = array()) { - if (!is_string($file)) { - return false; - } - - $matches = array(); - $MagicFileResource = new MagicFileResource($file); - foreach ($this->db['database'] as $format) { - $magic = $format[0]; - $match = $MagicFileResource->test($magic); - if ($match === false) { - continue; - } - $matches[] = $magic; - } - - return $matches; - } -} - -/** - * undocumented class - * - * @package cake.libs - */ -class MagicFileResource extends Object{ - -/** - * undocumented variable - * - * @var unknown - * @access public - */ - public $resource = null; - -/** - * undocumented variable - * - * @var unknown - * @access public - */ - public $offset = 0; - -/** - * undocumented function - * - * @param unknown $file - * @return void - */ - public function __construct($file) { - if (file_exists($file)) { - $this->resource = new File($file); - } else { - $this->resource = $file; - } - } - -/** - * undocumented function - * - * @param unknown $magic - * @return void - */ - public function test($magic) { - $offset = null; - $type = null; - $expected = null; - $comment = null; - if (isset($magic[0])) { - $offset = $magic[0]; - } - if (isset($magic[1])) { - $type = $magic[1]; - } - if (isset($magic[2])) { - $expected = $magic[2]; - } - if (isset($magic[3])) { - $comment = $magic[3]; - } - $val = $this->extract($offset, $type, $expected); - return $val == $expected; - } - -/** - * undocumented function - * - * @param unknown $type - * @param unknown $length - * @return void - */ - public function read($length = null) { - if (!is_object($this->resource)) { - return substr($this->resource, $this->offset, $length); - } - return $this->resource->read($length); - } - -/** - * undocumented function - * - * @param unknown $type - * @param unknown $expected - * @return void - */ - public function extract($offset, $type, $expected) { - switch ($type) { - case 'string': - $this->offset($offset); - $val = $this->read(strlen($expected)); - if ($val === $expected) { - return true; - } - break; - } - } - -/** - * undocumented function - * - * @param unknown $offset - * @param unknown $whence - * @return void - */ - public function offset($offset = null) { - if (is_null($offset)) { - if (!is_object($this->resource)) { - return $this->offset; - } - return $this->offset; - } - - if (!ctype_digit($offset)) { - return false; - } - if (is_object($this->resource)) { - $this->resource->offset($offset); - } else { - $this->offset = $offset; - } - } -} diff --git a/cake/libs/view/errors/missing_action.ctp b/cake/libs/view/errors/missing_action.ctp deleted file mode 100644 index 5b6fdb970..000000000 --- a/cake/libs/view/errors/missing_action.ctp +++ /dev/null @@ -1,44 +0,0 @@ - -
-- : - ' . $action . '', '' . $controller . ''); ?> -
-- : - ' . $controller . '::', '' . $action . '()', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?> -
--<?php -class extends AppController { - - - function { - - } - -} -?> --
- : - -
-element('exception_stack_trace'); ?> diff --git a/cake/libs/view/errors/missing_view.ctp b/cake/libs/view/errors/missing_view.ctp deleted file mode 100644 index 9d8c7cb91..000000000 --- a/cake/libs/view/errors/missing_view.ctp +++ /dev/null @@ -1,33 +0,0 @@ - - -- : - ' . Inflector::camelize($this->request->controller) . 'Controller::', '' . $this->request->action . '()'); ?> -
-- : - -
-- : - -
- -element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/pages/home.ctp b/cake/libs/view/pages/home.ctp deleted file mode 100644 index 400df888b..000000000 --- a/cake/libs/view/pages/home.ctp +++ /dev/null @@ -1,174 +0,0 @@ - - - - 0): - Debugger::checkSecurityKeys(); -endif; -?> -- '; - echo __('Your tmp directory is writable.'); - echo ''; - else: - echo ''; - echo __('Your tmp directory is NOT writable.'); - echo ''; - endif; - ?> -
-- '; - echo __('The %s is being used for caching. To change the config edit APP/config/core.php ', ''. $settings['engine'] . 'Engine'); - echo ''; - else: - echo ''; - echo __('Your cache is NOT working. Please check the settings in APP/config/core.php'); - echo ''; - endif; - ?> -
-
- ';
- echo __('Your database configuration file is present.');
- $filePresent = true;
- echo '';
- else:
- echo '';
- echo __('Your database configuration file is NOT present.');
- echo '
';
- echo __('Rename config/database.php.default to config/database.php');
- echo '';
- endif;
- ?>
-
--enable-unicode-properties
when configuring');
- echo '';
- }
-?>
-getDataSource('default');
- } catch (Exception $e) {
- $connected = false;
- }
-?>
-- isConnected()): - echo ''; - echo __('Cake is able to connect to the database.'); - echo ''; - else: - echo ''; - echo __('Cake is NOT able to connect to the database.'); - echo ''; - endif; - ?> -
- - -
-
-To change its layout, create: APP/views/layouts/default.ctp.
-You can also add some CSS styles for your pages at: APP/webroot/css.');
-?>
-
- Html->link( - sprintf('%s %s', __('New'), __('CakePHP 1.3 Docs')), - 'http://book.cakephp.org/view/875/x1-3-Collection', - array('target' => '_blank', 'escape' => false) - ); - ?> -
-- Html->link( - __('The 15 min Blog Tutorial'), - 'http://book.cakephp.org/view/1528/Blog', - array('target' => '_blank', 'escape' => false) - ); - ?> -
- - -- -
-- -
- --'; - echo __('Your tmp directory is writable.'); - echo ''; - else: - echo ''; - echo __('Your tmp directory is NOT writable.'); - echo ''; - endif; -?> -
--'; - echo __('The %s is being used for caching. To change the config edit APP/config/core.php ', ''. $settings['engine'] . 'Engine'); - echo ''; - else: - echo ''; - echo __('Your cache is NOT working. Please check the settings in APP/config/core.php'); - echo ''; - endif; -?> -
-
-';
- echo __('Your database configuration file is present.');
- $filePresent = true;
- echo '';
- else:
- echo '';
- echo __('Your database configuration file is NOT present.');
- echo '
';
- echo __('Rename config/database.php.default to config/database.php');
- echo '';
- endif;
-?>
-
-'; - echo __('Cake is able to connect to the database.'); - echo ''; - else: - echo ''; - echo __('Cake is NOT able to connect to the database.'); - echo ''; - endif; -?> -
- - -
-', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.
', APP . 'webroot' . DS . 'css');
-?>
-
- - - - - -
-- - ' . $settings['engine']; - echo __(' is being used to cache, to change this edit config/core.php '); - echo '
'; - - echo 'Settings:- - '; - echo __('Rename config/database.php.default to config/database.php'); - endif; - ?> - -
-getDataSource('default'); -?> -- - isConnected()): - __(' is able to '); - else: - __(' is NOT able to '); - endif; - __('connect to the database.'); - ?> - -
- - - - - - - - -- -
-- -
-+ isConnected()): + echo ''; + echo __('Cake is able to connect to the database.'); + echo ''; + else: + echo ''; + echo __('Cake is NOT able to connect to the database.'); + echo ''; + endif; + ?> +
+ isConnected()): - echo ''; - echo __('Cake is able to connect to the database.'); - echo ''; - else: - echo ''; - echo __('Cake is NOT able to connect to the database.'); - echo ''; - endif; -?> -\n"; -$output .= "\n"; + App::uses('Validation', 'Utility'); + if (!Validation::alphaNumeric('cakephp')) { + echo '';
+ __('PCRE has not been compiled with Unicode support.');
+ echo '
';
+ __('Recompile PCRE with Unicode support by adding --enable-unicode-properties
when configuring');
+ echo '
\n"; $output .= " The name of a supported driver; valid options are as follows: - * mysql - MySQL 4 & 5, - * sqlite - SQLite (PHP5 only), - * postgres - PostgreSQL 7 and higher, - * mssql - Microsoft SQL Server 2000 and higher, - * oracle - Oracle 8 and higher + * Datasabe/Mysql - MySQL 4 & 5, + * Datasabe/Sqlite - SQLite (PHP5 only), + * Datasabe/Postgres - PostgreSQL 7 and higher, + * Datasabe/Mssql - Microsoft SQL Server 2000 and higher, + * Datasabe/Oracle - Oracle 8 and higher * * You can add custom database drivers (or override existing drivers) by adding the - * appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php', - * where 'x' is the name of the database. + * appropriate file to app/models/datasources/database. Drivers should be named 'MyDriver.php', + * * * persistent => true / false * Determines whether or not the database should use a persistent connection * * host => - * the host you connect to the database. To add a socket or port number, use 'port' => # + * the host you connect to the database. To add a socket or port number, use 'port' => # * * prefix => * Uses the given prefix for all the tables in this database. This setting can be overridden * on a per-table basis with the Model::$tablePrefix property. * * schema => - * For Postgresspecifies which schema you would like to use the tables in. Postgres defaults to - * 'public', DB2 defaults to empty. + * For Postgres specifies which schema you would like to use the tables in. Postgres defaults to 'public'. * * encoding => - * For MySQL, Postgres and Sqlite, specifies the character encoding to use when connecting to the - * database. Uses database default. + * For MySQL, Postgres specifies the character encoding to use when connecting to the + * database. Uses database default not specified. * */ class DATABASE_CONFIG { public $default = array( - 'driver' => 'mysql', + 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', @@ -70,7 +69,7 @@ class DATABASE_CONFIG { ); public $test = array( - 'driver' => 'mysql', + 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', diff --git a/cake/console/templates/skel/config/routes.php b/lib/Cake/Console/templates/skel/config/routes.php similarity index 100% rename from cake/console/templates/skel/config/routes.php rename to lib/Cake/Console/templates/skel/config/routes.php diff --git a/cake/console/templates/skel/config/schema/db_acl.php b/lib/Cake/Console/templates/skel/config/schema/db_acl.php similarity index 100% rename from cake/console/templates/skel/config/schema/db_acl.php rename to lib/Cake/Console/templates/skel/config/schema/db_acl.php diff --git a/cake/console/templates/skel/config/schema/db_acl.sql b/lib/Cake/Console/templates/skel/config/schema/db_acl.sql similarity index 100% rename from cake/console/templates/skel/config/schema/db_acl.sql rename to lib/Cake/Console/templates/skel/config/schema/db_acl.sql diff --git a/cake/console/templates/skel/config/schema/i18n.php b/lib/Cake/Console/templates/skel/config/schema/i18n.php similarity index 100% rename from cake/console/templates/skel/config/schema/i18n.php rename to lib/Cake/Console/templates/skel/config/schema/i18n.php diff --git a/cake/console/templates/skel/config/schema/i18n.sql b/lib/Cake/Console/templates/skel/config/schema/i18n.sql similarity index 100% rename from cake/console/templates/skel/config/schema/i18n.sql rename to lib/Cake/Console/templates/skel/config/schema/i18n.sql diff --git a/cake/console/templates/skel/config/schema/sessions.php b/lib/Cake/Console/templates/skel/config/schema/sessions.php similarity index 100% rename from cake/console/templates/skel/config/schema/sessions.php rename to lib/Cake/Console/templates/skel/config/schema/sessions.php diff --git a/cake/console/templates/skel/config/schema/sessions.sql b/lib/Cake/Console/templates/skel/config/schema/sessions.sql similarity index 100% rename from cake/console/templates/skel/config/schema/sessions.sql rename to lib/Cake/Console/templates/skel/config/schema/sessions.sql diff --git a/cake/console/templates/skel/index.php b/lib/Cake/Console/templates/skel/index.php similarity index 100% rename from cake/console/templates/skel/index.php rename to lib/Cake/Console/templates/skel/index.php diff --git a/cake/console/templates/skel/tests/cases/controllers/empty b/lib/Cake/Console/templates/skel/locale/eng/LC_MESSAGES/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/controllers/empty rename to lib/Cake/Console/templates/skel/locale/eng/LC_MESSAGES/empty diff --git a/cake/console/templates/skel/tests/cases/datasources/empty b/lib/Cake/Console/templates/skel/plugins/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/datasources/empty rename to lib/Cake/Console/templates/skel/plugins/empty diff --git a/cake/console/templates/skel/tests/cases/helpers/empty b/lib/Cake/Console/templates/skel/tests/Case/Controller/Component/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/helpers/empty rename to lib/Cake/Console/templates/skel/tests/Case/Controller/Component/empty diff --git a/cake/console/templates/skel/tests/cases/models/empty b/lib/Cake/Console/templates/skel/tests/Case/Controller/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/models/empty rename to lib/Cake/Console/templates/skel/tests/Case/Controller/empty diff --git a/cake/console/templates/skel/tests/cases/shells/empty b/lib/Cake/Console/templates/skel/tests/Case/Model/Behavior/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/shells/empty rename to lib/Cake/Console/templates/skel/tests/Case/Model/Behavior/empty diff --git a/cake/console/templates/skel/tests/fixtures/empty b/lib/Cake/Console/templates/skel/tests/Case/Model/empty similarity index 100% rename from cake/console/templates/skel/tests/fixtures/empty rename to lib/Cake/Console/templates/skel/tests/Case/Model/empty diff --git a/cake/console/templates/skel/tmp/cache/models/empty b/lib/Cake/Console/templates/skel/tests/Case/View/Helper/empty old mode 100755 new mode 100644 similarity index 100% rename from cake/console/templates/skel/tmp/cache/models/empty rename to lib/Cake/Console/templates/skel/tests/Case/View/Helper/empty diff --git a/cake/console/templates/skel/tmp/cache/persistent/empty b/lib/Cake/Console/templates/skel/tests/Fixture/empty old mode 100755 new mode 100644 similarity index 100% rename from cake/console/templates/skel/tmp/cache/persistent/empty rename to lib/Cake/Console/templates/skel/tests/Fixture/empty diff --git a/cake/console/templates/skel/tmp/cache/views/empty b/lib/Cake/Console/templates/skel/tmp/cache/models/empty old mode 100755 new mode 100644 similarity index 100% rename from cake/console/templates/skel/tmp/cache/views/empty rename to lib/Cake/Console/templates/skel/tmp/cache/models/empty diff --git a/cake/console/templates/skel/tmp/logs/empty b/lib/Cake/Console/templates/skel/tmp/cache/persistent/empty similarity index 100% rename from cake/console/templates/skel/tmp/logs/empty rename to lib/Cake/Console/templates/skel/tmp/cache/persistent/empty diff --git a/cake/console/templates/skel/tmp/sessions/empty b/lib/Cake/Console/templates/skel/tmp/cache/views/empty similarity index 100% rename from cake/console/templates/skel/tmp/sessions/empty rename to lib/Cake/Console/templates/skel/tmp/cache/views/empty diff --git a/cake/console/templates/skel/tmp/tests/empty b/lib/Cake/Console/templates/skel/tmp/logs/empty similarity index 100% rename from cake/console/templates/skel/tmp/tests/empty rename to lib/Cake/Console/templates/skel/tmp/logs/empty diff --git a/cake/console/templates/skel/vendors/empty b/lib/Cake/Console/templates/skel/tmp/sessions/empty similarity index 100% rename from cake/console/templates/skel/vendors/empty rename to lib/Cake/Console/templates/skel/tmp/sessions/empty diff --git a/cake/console/templates/skel/views/elements/empty b/lib/Cake/Console/templates/skel/tmp/tests/empty similarity index 100% rename from cake/console/templates/skel/views/elements/empty rename to lib/Cake/Console/templates/skel/tmp/tests/empty diff --git a/cake/console/templates/skel/views/errors/empty b/lib/Cake/Console/templates/skel/vendors/empty similarity index 100% rename from cake/console/templates/skel/views/errors/empty rename to lib/Cake/Console/templates/skel/vendors/empty diff --git a/cake/console/templates/skel/webroot/.htaccess b/lib/Cake/Console/templates/skel/webroot/.htaccess similarity index 100% rename from cake/console/templates/skel/webroot/.htaccess rename to lib/Cake/Console/templates/skel/webroot/.htaccess diff --git a/cake/console/templates/skel/webroot/css.php b/lib/Cake/Console/templates/skel/webroot/css.php similarity index 100% rename from cake/console/templates/skel/webroot/css.php rename to lib/Cake/Console/templates/skel/webroot/css.php diff --git a/cake/console/templates/skel/webroot/css/cake.generic.css b/lib/Cake/Console/templates/skel/webroot/css/cake.generic.css similarity index 100% rename from cake/console/templates/skel/webroot/css/cake.generic.css rename to lib/Cake/Console/templates/skel/webroot/css/cake.generic.css diff --git a/cake/console/templates/skel/webroot/favicon.ico b/lib/Cake/Console/templates/skel/webroot/favicon.ico similarity index 100% rename from cake/console/templates/skel/webroot/favicon.ico rename to lib/Cake/Console/templates/skel/webroot/favicon.ico diff --git a/cake/console/templates/skel/webroot/img/cake.icon.png b/lib/Cake/Console/templates/skel/webroot/img/cake.icon.png similarity index 100% rename from cake/console/templates/skel/webroot/img/cake.icon.png rename to lib/Cake/Console/templates/skel/webroot/img/cake.icon.png diff --git a/cake/console/templates/skel/webroot/img/cake.power.gif b/lib/Cake/Console/templates/skel/webroot/img/cake.power.gif similarity index 100% rename from cake/console/templates/skel/webroot/img/cake.power.gif rename to lib/Cake/Console/templates/skel/webroot/img/cake.power.gif diff --git a/cake/console/templates/skel/webroot/index.php b/lib/Cake/Console/templates/skel/webroot/index.php similarity index 93% rename from cake/console/templates/skel/webroot/index.php rename to lib/Cake/Console/templates/skel/webroot/index.php index f1ff8d197..77b9db786 100644 --- a/cake/console/templates/skel/webroot/index.php +++ b/lib/Cake/Console/templates/skel/webroot/index.php @@ -49,7 +49,7 @@ * */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT); + define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); } /** @@ -67,7 +67,7 @@ define('APP_PATH', ROOT . DS . APP_DIR . DS); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } - if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) { + if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } @@ -75,6 +75,6 @@ return; } - require LIBS . 'dispatcher.php'; + require LIBS . 'Routing' . DS .'Dispatcher.php'; $Dispatcher = new Dispatcher(); $Dispatcher->dispatch(new CakeRequest()); diff --git a/cake/console/templates/skel/views/helpers/empty b/lib/Cake/Console/templates/skel/webroot/js/empty similarity index 100% rename from cake/console/templates/skel/views/helpers/empty rename to lib/Cake/Console/templates/skel/webroot/js/empty diff --git a/cake/console/templates/skel/webroot/test.php b/lib/Cake/Console/templates/skel/webroot/test.php similarity index 87% rename from cake/console/templates/skel/webroot/test.php rename to lib/Cake/Console/templates/skel/webroot/test.php index c11aaac99..cb9180331 100644 --- a/cake/console/templates/skel/webroot/test.php +++ b/lib/Cake/Console/templates/skel/webroot/test.php @@ -67,21 +67,14 @@ if (!defined('CORE_PATH')) { define('APP_PATH', ROOT . DS . APP_DIR . DS); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } -if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) { +if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } -$corePath = App::core('cake'); -if (isset($corePath[0])) { - define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS); -} else { - define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH); -} - if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.')); } -require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php'; +require_once CAKE_TESTS_LIB . 'CakeTestSuiteDispatcher.php'; CakeTestSuiteDispatcher::run(); diff --git a/cake/libs/controller/app_controller.php b/lib/Cake/Controller/AppController.php similarity index 96% rename from cake/libs/controller/app_controller.php rename to lib/Cake/Controller/AppController.php index 07c117dff..383cca2be 100644 --- a/cake/libs/controller/app_controller.php +++ b/lib/Cake/Controller/AppController.php @@ -20,6 +20,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Controller', 'Controller'); + /** * This is a placeholder class. * Create the same file in app/app_controller.php diff --git a/cake/libs/controller/cake_error_controller.php b/lib/Cake/Controller/CakeErrorController.php similarity index 100% rename from cake/libs/controller/cake_error_controller.php rename to lib/Cake/Controller/CakeErrorController.php diff --git a/cake/libs/controller/component.php b/lib/Cake/Controller/Component.php similarity index 98% rename from cake/libs/controller/component.php rename to lib/Cake/Controller/Component.php index f55840d1f..0993c171b 100644 --- a/cake/libs/controller/component.php +++ b/lib/Cake/Controller/Component.php @@ -15,7 +15,7 @@ * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Controller', 'ComponentCollection', false); +App::uses('ComponentCollection', 'Controller'); /** * Base class for an individual Component. Components provide resuable bits of diff --git a/cake/libs/controller/components/acl.php b/lib/Cake/Controller/Component/AclComponent.php similarity index 94% rename from cake/libs/controller/components/acl.php rename to lib/Cake/Controller/Component/AclComponent.php index 6795ab335..fde44da62 100644 --- a/cake/libs/controller/components/acl.php +++ b/lib/Cake/Controller/Component/AclComponent.php @@ -19,6 +19,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Component', 'Controller'); + /** * Access Control List factory class. * @@ -66,7 +68,7 @@ class AclComponent extends Component { list($plugin, $name) = pluginSplit($name); $name .= 'Component'; } else { - throw new CakeException(__('Could not find %s.', $name)); + throw new CakeException(__d('cake_dev', 'Could not find %s.', $name)); } } $this->adapter($name); @@ -90,7 +92,7 @@ class AclComponent extends Component { $adapter = new $adapter(); } if (!$adapter instanceof AclInterface) { - throw new CakeException(__('AclComponent adapters must implement AclInterface')); + throw new CakeException(__d('cake_dev', 'AclComponent adapters must implement AclInterface')); } $this->_Instance = $adapter; $this->_Instance->initialize($this); @@ -161,7 +163,7 @@ class AclComponent extends Component { * @deprecated */ public function grant($aro, $aco, $action = "*") { - trigger_error(__('AclComponent::grant() is deprecated, use allow() instead'), E_USER_WARNING); + trigger_error(__d('cake_dev', 'AclComponent::grant() is deprecated, use allow() instead'), E_USER_WARNING); return $this->_Instance->allow($aro, $aco, $action); } @@ -175,7 +177,7 @@ class AclComponent extends Component { * @deprecated */ public function revoke($aro, $aco, $action = "*") { - trigger_error(__('AclComponent::revoke() is deprecated, use deny() instead'), E_USER_WARNING); + trigger_error(__d('cake_dev', 'AclComponent::revoke() is deprecated, use deny() instead'), E_USER_WARNING); return $this->_Instance->deny($aro, $aco, $action); } } @@ -262,9 +264,7 @@ class DbAcl extends Object implements AclInterface { */ function __construct() { parent::__construct(); - if (!class_exists('AclNode')) { - require LIBS . 'model' . DS . 'db_acl.php'; - } + App::uses('AclNode', 'Model'); $this->Aro = ClassRegistry::init(array('class' => 'Aro', 'alias' => 'Aro')); $this->Aco = ClassRegistry::init(array('class' => 'Aco', 'alias' => 'Aco')); } @@ -299,12 +299,12 @@ class DbAcl extends Object implements AclInterface { $acoPath = $this->Aco->node($aco); if (empty($aroPath) || empty($acoPath)) { - trigger_error(__("DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING); + trigger_error(__d('cake_dev', "DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING); return false; } if ($acoPath == null || $acoPath == array()) { - trigger_error(__("DbAcl::check() - Failed ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING); + trigger_error(__d('cake_dev', "DbAcl::check() - Failed ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING); return false; } @@ -312,7 +312,7 @@ class DbAcl extends Object implements AclInterface { $acoNode = $acoPath[0]; if ($action != '*' && !in_array('_' . $action, $permKeys)) { - trigger_error(__("ACO permissions key %s does not exist in DbAcl::check()", $action), E_USER_NOTICE); + trigger_error(__d('cake_dev', "ACO permissions key %s does not exist in DbAcl::check()", $action), E_USER_NOTICE); return false; } @@ -386,7 +386,7 @@ class DbAcl extends Object implements AclInterface { $save = array(); if ($perms == false) { - trigger_error(__('DbAcl::allow() - Invalid node'), E_USER_WARNING); + trigger_error(__d('cake_dev', 'DbAcl::allow() - Invalid node'), E_USER_WARNING); return false; } if (isset($perms[0])) { @@ -657,7 +657,7 @@ class IniAcl extends Object implements AclInterface { * @return array INI section structure */ public function readConfigFile($filename) { - App::import('Core', 'config/IniReader'); + App::uses('IniReader', 'Configure'); $iniFile = new IniReader(dirname($filename) . DS); return $iniFile->read(basename($filename)); } diff --git a/cake/libs/controller/components/auth/actions_authorize.php b/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php similarity index 95% rename from cake/libs/controller/components/auth/actions_authorize.php rename to lib/Cake/Controller/Component/Auth/ActionsAuthorize.php index c2f1f35d2..684fb47a0 100644 --- a/cake/libs/controller/components/auth/actions_authorize.php +++ b/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authorize'); + +App::uses('BaseAuthorize', 'Controller/Component/Auth'); /** * An authorization adapter for AuthComponent. Provides the ability to authorize using the AclComponent, diff --git a/cake/libs/controller/components/auth/base_authenticate.php b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php similarity index 98% rename from cake/libs/controller/components/auth/base_authenticate.php rename to lib/Cake/Controller/Component/Auth/BaseAuthenticate.php index 1cfcc8896..aba2a8328 100644 --- a/cake/libs/controller/components/auth/base_authenticate.php +++ b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Security'); + +App::uses('Security', 'Utility'); /** * Base Authentication class with common methods and properties. diff --git a/cake/libs/controller/components/auth/base_authorize.php b/lib/Cake/Controller/Component/Auth/BaseAuthorize.php similarity index 97% rename from cake/libs/controller/components/auth/base_authorize.php rename to lib/Cake/Controller/Component/Auth/BaseAuthorize.php index 911bbdb24..f4b7cad27 100644 --- a/cake/libs/controller/components/auth/base_authorize.php +++ b/lib/Cake/Controller/Component/Auth/BaseAuthorize.php @@ -87,7 +87,7 @@ abstract class BaseAuthorize { public function controller($controller = null) { if ($controller) { if (!$controller instanceof Controller) { - throw new CakeException(__('$controller needs to be an instance of Controller')); + throw new CakeException(__d('cake_dev', '$controller needs to be an instance of Controller')); } $this->_Controller = $controller; return true; diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php similarity index 98% rename from cake/libs/controller/components/auth/basic_authenticate.php rename to lib/Cake/Controller/Component/Auth/BasicAuthenticate.php index 2ba467e98..148734629 100644 --- a/cake/libs/controller/components/auth/basic_authenticate.php +++ b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authenticate'); + +App::uses('BaseAuthenticate', 'Controller/Component/Auth'); /** * Basic Authentication adapter for AuthComponent. diff --git a/cake/libs/controller/components/auth/controller_authorize.php b/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php similarity index 91% rename from cake/libs/controller/components/auth/controller_authorize.php rename to lib/Cake/Controller/Component/Auth/ControllerAuthorize.php index 8fd66b10d..641eb6aff 100644 --- a/cake/libs/controller/components/auth/controller_authorize.php +++ b/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authorize'); + +App::uses('BaseAuthorize', 'Controller/Component/Auth'); /** * An authorization adapter for AuthComponent. Provides the ability to authorize using a controller callback. @@ -45,7 +46,7 @@ class ControllerAuthorize extends BaseAuthorize { public function controller($controller = null) { if ($controller) { if (!method_exists($controller, 'isAuthorized')) { - throw new CakeException(__('$controller does not implement an isAuthorized() method.')); + throw new CakeException(__d('cake_dev', '$controller does not implement an isAuthorized() method.')); } } return parent::controller($controller); diff --git a/cake/libs/controller/components/auth/crud_authorize.php b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php similarity index 96% rename from cake/libs/controller/components/auth/crud_authorize.php rename to lib/Cake/Controller/Component/Auth/CrudAuthorize.php index be127f43a..91be83b79 100644 --- a/cake/libs/controller/components/auth/crud_authorize.php +++ b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php @@ -12,7 +12,9 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authorize'); + +App::uses('BaseAuthorize', 'Controller/Component/Auth'); +App::uses('Router', 'Routing'); /** * An authorization adapter for AuthComponent. Provides the ability to authorize using CRUD mappings. @@ -79,7 +81,7 @@ class CrudAuthorize extends BaseAuthorize { */ public function authorize($user, CakeRequest $request) { if (!isset($this->settings['actionMap'][$request->params['action']])) { - trigger_error(__( + trigger_error(__d('cake_dev', 'CrudAuthorize::authorize() - Attempted access of un-mapped action "%1$s" in controller "%2$s"', $request->action, $request->controller diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php similarity index 99% rename from cake/libs/controller/components/auth/digest_authenticate.php rename to lib/Cake/Controller/Component/Auth/DigestAuthenticate.php index c27f293c0..69c3ae228 100644 --- a/cake/libs/controller/components/auth/digest_authenticate.php +++ b/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authenticate'); + +App::uses('BaseAuthenticate', 'Controller/Component/Auth'); /** * Digest Authentication adapter for AuthComponent. diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/lib/Cake/Controller/Component/Auth/FormAuthenticate.php similarity index 97% rename from cake/libs/controller/components/auth/form_authenticate.php rename to lib/Cake/Controller/Component/Auth/FormAuthenticate.php index d24d9acf2..f0f708088 100644 --- a/cake/libs/controller/components/auth/form_authenticate.php +++ b/lib/Cake/Controller/Component/Auth/FormAuthenticate.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authenticate'); + +App::uses('BaseAuthenticate', 'Controller/Component/Auth'); /** * An authentication adapter for AuthComponent. Provides the ability to authenticate using POST diff --git a/cake/libs/controller/components/auth.php b/lib/Cake/Controller/Component/AuthComponent.php similarity index 93% rename from cake/libs/controller/components/auth.php rename to lib/Cake/Controller/Component/AuthComponent.php index 19106aca3..28b7e1bea 100644 --- a/cake/libs/controller/components/auth.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -19,11 +19,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Router', false); -App::import('Core', 'Security', false); -App::import('Core', 'CakeSession', false); -App::import('Component', 'auth/base_authorize'); -App::import('Component', 'auth/base_authenticate'); + +App::uses('Component', 'Controller'); +App::uses('Router', 'Routing'); +App::uses('Security', 'Utility'); +App::uses('Debugger', 'Utility'); +App::uses('CakeSession', 'Model/Datasource'); +App::uses('BaseAuthorize', 'Controller/Component/Auth'); +App::uses('BaseAuthenticate', 'Controller/Component/Auth'); /** * Authentication control component class @@ -253,7 +256,6 @@ class AuthComponent extends Component { $this->_methods = $controller->methods; if (Configure::read('debug') > 0) { - App::import('Debugger'); Debugger::checkSecurityKeys(); } } @@ -349,7 +351,7 @@ class AuthComponent extends Component { function __setDefaults() { $defaults = array( 'logoutRedirect' => $this->loginAction, - 'authError' => __('You are not authorized to access that location.') + 'authError' => __d('cake', 'You are not authorized to access that location.') ); foreach ($defaults as $key => $value) { if (empty($this->{$key})) { @@ -361,7 +363,7 @@ class AuthComponent extends Component { /** * Uses the configured Authorization adapters to check whether or not a user is authorized. - * Each adapter will be checked in sequence, if any of them return true, then the user will + * Each adapter will be checked in sequence, if any of them return true, then the user will * be authorized for the request. * * @param mixed $user The user to check the authorization of. If empty the user in the session will be used. @@ -405,12 +407,14 @@ class AuthComponent extends Component { unset($config[AuthComponent::ALL]); } foreach ($config as $class => $settings) { + list($plugin, $class) = pluginSplit($class, true); $className = $class . 'Authorize'; - if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authorize')) { - throw new CakeException(__('Authorization adapter "%s" was not found.', $class)); + App::uses($className, $plugin . 'Controller/Component/Auth'); + if (!class_exists($className)) { + throw new CakeException(__d('cake_dev', 'Authorization adapter "%s" was not found.', $class)); } if (!method_exists($className, 'authorize')) { - throw new CakeException(__('Authorization objects must implement an authorize method.')); + throw new CakeException(__d('cake_dev', 'Authorization objects must implement an authorize method.')); } $settings = array_merge($global, (array)$settings); $this->_authorizeObjects[] = new $className($this->_Collection, $settings); @@ -424,7 +428,7 @@ class AuthComponent extends Component { * * You can use allow with either an array, or var args. * - * `$this->Auth->allow(array('edit', 'add'));` or + * `$this->Auth->allow(array('edit', 'add'));` or * `$this->Auth->allow('edit', 'add');` * * allow() also supports '*' as a wildcard to mean all actions. @@ -454,7 +458,7 @@ class AuthComponent extends Component { * * You can use deny with either an array, or var args. * - * `$this->Auth->deny(array('edit', 'add'));` or + * `$this->Auth->deny(array('edit', 'add'));` or * `$this->Auth->deny('edit', 'add');` * * @param mixed $action Controller action name or array of actions @@ -582,8 +586,8 @@ class AuthComponent extends Component { } /** - * If no parameter is passed, gets the authentication redirect URL. Pass a url in to - * set the destination a user should be redirected to upon logging in. Will fallback to + * If no parameter is passed, gets the authentication redirect URL. Pass a url in to + * set the destination a user should be redirected to upon logging in. Will fallback to * AuthComponent::$loginRedirect if there is no stored redirect value. * * @param mixed $url Optional URL to write as the login redirect URL. @@ -643,12 +647,14 @@ class AuthComponent extends Component { unset($config[AuthComponent::ALL]); } foreach ($config as $class => $settings) { + list($plugin, $class) = pluginSplit($class, true); $className = $class . 'Authenticate'; - if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authenticate')) { - throw new CakeException(__('Authentication adapter "%s" was not found.', $class)); + App::uses($className, $plugin . 'Controller/Component/Auth'); + if (!class_exists($className)) { + throw new CakeException(__d('cake_dev', 'Authentication adapter "%s" was not found.', $class)); } if (!method_exists($className, 'authenticate')) { - throw new CakeException(__('Authentication objects must implement an authenticate method.')); + throw new CakeException(__d('cake_dev', 'Authentication objects must implement an authenticate method.')); } $settings = array_merge($global, (array)$settings); $this->_authenticateObjects[] = new $className($this->_Collection, $settings); diff --git a/cake/libs/controller/components/cookie.php b/lib/Cake/Controller/Component/CookieComponent.php similarity index 99% rename from cake/libs/controller/components/cookie.php rename to lib/Cake/Controller/Component/CookieComponent.php index bb614c0bc..cca49a5bf 100644 --- a/cake/libs/controller/components/cookie.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -17,10 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -/** - * Load Security class - */ -App::import('Core', 'Security'); +App::uses('Component', 'Controller'); +App::uses('Security', 'Utility'); /** * Cookie Component. diff --git a/cake/libs/controller/components/email.php b/lib/Cake/Controller/Component/EmailComponent.php old mode 100755 new mode 100644 similarity index 98% rename from cake/libs/controller/components/email.php rename to lib/Cake/Controller/Component/EmailComponent.php index 68972daf1..103ccafed --- a/cake/libs/controller/components/email.php +++ b/lib/Cake/Controller/Component/EmailComponent.php @@ -16,7 +16,9 @@ * @since CakePHP(tm) v 1.2.0.3467 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Multibyte'); + +App::uses('Component', 'Controller'); +App::uses('Multibyte', 'I18n'); /** * EmailComponent @@ -456,9 +458,9 @@ class EmailComponent extends Component { $viewClass = $this->Controller->view; if ($viewClass != 'View') { - list($plugin, $viewClass) = pluginSplit($viewClass); + list($plugin, $viewClass) = pluginSplit($viewClass, true); $viewClass = $viewClass . 'View'; - App::import('View', $this->Controller->view); + App::uses($viewClass, $plugin . 'View'); } $View = new $viewClass($this->Controller); @@ -723,7 +725,7 @@ class EmailComponent extends Component { $formatted = array(); if ($this->_lineLength !== null) { - trigger_error(__('_lineLength cannot be accessed please use lineLength'), E_USER_WARNING); + trigger_error(__d('cake_dev', '_lineLength cannot be accessed please use lineLength'), E_USER_WARNING); $this->lineLength = $this->_lineLength; } @@ -850,7 +852,7 @@ class EmailComponent extends Component { * @access private */ function _smtp() { - App::import('Core', 'CakeSocket'); + App::uses('CakeSocket', 'Network'); $defaults = array( 'host' => 'localhost', diff --git a/cake/libs/controller/components/paginator.php b/lib/Cake/Controller/Component/PaginatorComponent.php similarity index 100% rename from cake/libs/controller/components/paginator.php rename to lib/Cake/Controller/Component/PaginatorComponent.php diff --git a/cake/libs/controller/components/request_handler.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php similarity index 99% rename from cake/libs/controller/components/request_handler.php rename to lib/Cake/Controller/Component/RequestHandlerComponent.php index f818ef63b..56cf6c448 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -19,6 +19,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Xml', 'Utility'); + /** * Request object for handling HTTP requests * @@ -171,9 +173,6 @@ class RequestHandlerComponent extends Component { } if ($this->requestedWith('xml')) { - if (!class_exists('Xml')) { - App::import('Core', 'Xml'); - } try { $xml = Xml::build(trim(file_get_contents('php://input'))); @@ -542,7 +541,8 @@ class RequestHandlerComponent extends Component { ); if (!$isAdded) { - if (App::import('Helper', $helper)) { + App::uses($helper . 'Helper', 'View/Helper'); + if (class_exists($helper . 'Helper')) { $controller->helpers[] = $helper; } } diff --git a/cake/libs/controller/components/security.php b/lib/Cake/Controller/Component/SecurityComponent.php similarity index 99% rename from cake/libs/controller/components/security.php rename to lib/Cake/Controller/Component/SecurityComponent.php index 7b1f6cac8..16cdc6413 100644 --- a/cake/libs/controller/components/security.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -16,8 +16,10 @@ * @since CakePHP(tm) v 0.10.8.2156 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'String', false); -App::import('Core', 'Security', false); + +App::uses('Component', 'Controller'); +App::uses('String', 'Utility'); +App::uses('Security', 'Utility'); /** * SecurityComponent diff --git a/cake/libs/controller/components/session.php b/lib/Cake/Controller/Component/SessionComponent.php similarity index 98% rename from cake/libs/controller/components/session.php rename to lib/Cake/Controller/Component/SessionComponent.php index fefa7dbf7..9d2231150 100644 --- a/cake/libs/controller/components/session.php +++ b/lib/Cake/Controller/Component/SessionComponent.php @@ -16,9 +16,9 @@ * @since CakePHP(tm) v 0.10.0.1232 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('cakesession')) { - require LIBS . 'cake_session.php'; -} + +App::uses('Component', 'Controller'); +App::uses('CakeSession', 'Model/Datasource'); /** * Session Component. diff --git a/cake/libs/controller/component_collection.php b/lib/Cake/Controller/ComponentCollection.php similarity index 87% rename from cake/libs/controller/component_collection.php rename to lib/Cake/Controller/ComponentCollection.php index 07a2a6eef..909fd70e1 100644 --- a/cake/libs/controller/component_collection.php +++ b/lib/Cake/Controller/ComponentCollection.php @@ -15,6 +15,10 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('ObjectCollection', 'Utility'); +App::uses('Component', 'Controller'); + class ComponentCollection extends ObjectCollection { /** @@ -76,7 +80,7 @@ class ComponentCollection extends ObjectCollection { $alias = $component; $component = $settings['className']; } - list($plugin, $name) = pluginSplit($component); + list($plugin, $name) = pluginSplit($component, true); if (!isset($alias)) { $alias = $name; } @@ -84,19 +88,12 @@ class ComponentCollection extends ObjectCollection { return $this->_loaded[$alias]; } $componentClass = $name . 'Component'; + App::uses($componentClass, $plugin . 'Controller/Component'); if (!class_exists($componentClass)) { - if (!App::import('Component', $component)) { - throw new MissingComponentFileException(array( - 'file' => Inflector::underscore($componentClass) . '.php', - 'class' => $componentClass - )); - } - if (!class_exists($componentClass)) { - throw new MissingComponentClassException(array( - 'file' => Inflector::underscore($componentClass) . '.php', - 'class' => $componentClass - )); - } + throw new MissingComponentClassException(array( + 'file' => Inflector::underscore($componentClass) . '.php', + 'class' => $componentClass + )); } $this->_loaded[$alias] = new $componentClass($this, $settings); $enable = isset($settings['enabled']) ? $settings['enabled'] : true; diff --git a/cake/libs/controller/controller.php b/lib/Cake/Controller/Controller.php similarity index 98% rename from cake/libs/controller/controller.php rename to lib/Cake/Controller/Controller.php index f09601c86..697629387 100644 --- a/cake/libs/controller/controller.php +++ b/lib/Cake/Controller/Controller.php @@ -20,10 +20,10 @@ /** * Include files */ -App::import('Core', 'CakeResponse', false); -App::import('Core', 'ClassRegistry', false); -App::import('Controller', 'Component', false); -App::import('View', 'View', false); +App::uses('CakeResponse', 'Network'); +App::uses('ClassRegistry', 'Utility'); +App::uses('ComponentCollection', 'Controller'); +App::uses('View', 'View'); /** * Application controller class for organization of business logic. @@ -311,18 +311,14 @@ class Controller extends Object { */ public function __construct($request = null) { if ($this->name === null) { - $r = null; - if (!preg_match('/(.*)Controller/i', get_class($this), $r)) { - echo __("Controller::__construct() : Can not get or parse my own class name, exiting."); - $this->_stop(); - } - $this->name = $r[1]; + $this->name = substr(get_class($this), 0, strlen(get_class($this)) -10); } if ($this->viewPath == null) { $this->viewPath = Inflector::underscore($this->name); } - $this->modelClass = Inflector::classify($this->name); + + $this->modelClass = Inflector::singularize($this->name); $this->modelKey = Inflector::underscore($this->modelClass); $this->Components = new ComponentCollection(); @@ -339,7 +335,7 @@ class Controller extends Object { } /** - * Provides backwards compatbility avoid problems with empty and isset to alias properties. + * Provides backwards compatibility to avoid problems with empty and isset to alias properties. * * @return void */ @@ -828,9 +824,9 @@ class Controller extends Object { $viewClass = $this->viewClass; if ($this->viewClass != 'View') { - list($plugin, $viewClass) = pluginSplit($viewClass); + list($plugin, $viewClass) = pluginSplit($viewClass, true); $viewClass = $viewClass . 'View'; - App::import('View', $this->viewClass); + App::uses($viewClass, $plugin . 'View'); } $this->request->params['models'] = $this->modelNames; diff --git a/cake/libs/controller/pages_controller.php b/lib/Cake/Controller/PagesController.php similarity index 97% rename from cake/libs/controller/pages_controller.php rename to lib/Cake/Controller/PagesController.php index 65e8b0465..c842bc9ca 100644 --- a/cake/libs/controller/pages_controller.php +++ b/lib/Cake/Controller/PagesController.php @@ -19,6 +19,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppController', 'Controller'); + /** * Static content controller * diff --git a/cake/libs/controller/scaffold.php b/lib/Cake/Controller/Scaffold.php similarity index 94% rename from cake/libs/controller/scaffold.php rename to lib/Cake/Controller/Scaffold.php index ab66e137a..054e3a1a3 100644 --- a/cake/libs/controller/scaffold.php +++ b/lib/Cake/Controller/Scaffold.php @@ -18,7 +18,7 @@ * @since Cake v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('View', 'Scaffold'); +App::uses('Scaffold', 'View'); /** * Scaffolding is a set of automatic actions for starting web development work faster. @@ -127,7 +127,7 @@ class Scaffold { $this->ScaffoldModel = $this->controller->{$this->modelClass}; $this->scaffoldTitle = Inflector::humanize($this->viewPath); $this->scaffoldActions = $controller->scaffold; - $title_for_layout = __('Scaffold :: ') . Inflector::humanize($request->action) . ' :: ' . $this->scaffoldTitle; + $title_for_layout = __d('cake', 'Scaffold :: ') . Inflector::humanize($request->action) . ' :: ' . $this->scaffoldTitle; $modelClass = $this->controller->modelClass; $primaryKey = $this->ScaffoldModel->primaryKey; $displayField = $this->ScaffoldModel->displayField; @@ -174,7 +174,7 @@ class Scaffold { $this->ScaffoldModel->id = $request->params['pass'][0]; } if (!$this->ScaffoldModel->exists()) { - throw new NotFoundException(__('Invalid %s', Inflector::humanize($this->modelKey))); + throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelKey))); } $this->ScaffoldModel->recursive = 1; $this->controller->request->data = $this->ScaffoldModel->read(); @@ -231,10 +231,10 @@ class Scaffold { */ protected function _scaffoldSave(CakeRequest $request, $action = 'edit') { $formAction = 'edit'; - $success = __('updated'); + $success = __d('cake', 'updated'); if ($action === 'add') { $formAction = 'add'; - $success = __('saved'); + $success = __d('cake', 'saved'); } if ($this->controller->_beforeScaffold($action)) { @@ -243,7 +243,7 @@ class Scaffold { $this->ScaffoldModel->id = $request['pass'][0]; } if (!$this->ScaffoldModel->exists()) { - throw new NotFoundException(__('Invalid %s', Inflector::humanize($this->modelKey))); + throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelKey))); } } @@ -254,7 +254,7 @@ class Scaffold { if ($this->ScaffoldModel->save($request->data)) { if ($this->controller->_afterScaffoldSave($action)) { - $message = __( + $message = __d('cake', 'The %1$s has been %2$s', Inflector::humanize($this->modelKey), $success @@ -265,7 +265,7 @@ class Scaffold { } } else { if ($this->_validSession) { - $this->controller->Session->setFlash(__('Please correct errors below.')); + $this->controller->Session->setFlash(__d('cake', 'Please correct errors below.')); } } } @@ -312,13 +312,13 @@ class Scaffold { } $this->ScaffoldModel->id = $id; if (!$this->ScaffoldModel->exists()) { - throw new NotFoundException(__('Invalid %s', Inflector::humanize($this->modelClass))); + throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelClass))); } if ($this->ScaffoldModel->delete()) { - $message = __('The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id); + $message = __d('cake', 'The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id); return $this->_sendMessage($message); } else { - $message = __( + $message = __d('cake', 'There was an error deleting the %1$s with id: %2$d', Inflector::humanize($this->modelClass), $id diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php new file mode 100644 index 000000000..014f812db --- /dev/null +++ b/lib/Cake/Core/App.php @@ -0,0 +1,820 @@ + array('extends' => null, 'core' => true), + 'file' => array('extends' => null, 'core' => true), + 'model' => array('extends' => 'AppModel', 'core' => false), + 'behavior' => array('extends' => 'ModelBehavior', 'core' => true), + 'controller' => array('suffix' => 'Controller', 'extends' => 'AppController', 'core' => true), + 'component' => array('suffix' => 'Component', 'extends' => null, 'core' => true), + 'lib' => array('extends' => null, 'core' => true), + 'view' => array('suffix' => 'View', 'extends' => null, 'core' => true), + 'helper' => array('suffix' => 'Helper', 'extends' => 'AppHelper', 'core' => true), + 'vendor' => array('extends' => null, 'core' => true), + 'shell' => array('suffix' => 'Shell', 'extends' => 'Shell', 'core' => true), + 'plugin' => array('extends' => null, 'core' => true) + ); + +/** + * Paths to search for files. + * + * @var array + */ + public static $search = array(); + +/** + * Whether or not to return the file that is loaded. + * + * @var boolean + */ + public static $return = false; + +/** + * Determines if $__maps and $__paths cache should be written. + * + * @var boolean + */ + private static $__cache = false; + +/** + * Holds key/value pairs of $type => file path. + * + * @var array + */ + private static $__map = array(); + +/** + * Holds paths for deep searching of files. + * + * @var array + */ + private static $__paths = array(); + +/** + * Holds loaded files. + * + * @var array + */ + private static $__loaded = array(); + +/** + * Holds and key => value array of object types. + * + * @var array + */ + private static $__objects = array(); + +/** + * Holds the location of each class + * + */ + private static $__classMap = array(); + +/** + * Holds the possible paths for each package name + * + */ + private static $__packages = array(); + +/** + * Holds the templates for each customizable package path in the application + * + */ + private static $__packageFormat = array(); + +/** + * Maps an old style CakePHP class type to the corresponding package + * + */ + public static $legacy = array( + 'models' => 'Model', + 'behaviors' => 'Model/Behavior', + 'datasources' => 'Model/Datasource', + 'controllers' => 'Controller', + 'components' => 'Controller/Component', + 'views' => 'View', + 'helpers' => 'View/Helper', + 'shells' => 'Console/Command', + 'libs' => 'Lib' + ); + +/** + * Inicates whether the class cache should be stored again because of an addition to it + * + */ + private static $_cacheChange = false; + +/** + * Inicates whether the object cache should be stored again because of an addition to it + * + */ + private static $_objectCacheChange = false; + +/** + * Used to read information stored path + * + * Usage: + * + * `App::path('Model'); will return all paths for models` + * + * `App::path('Model/Datasource', 'MyPlugin'); will return the path for datasources under the 'MyPlugin' plugin` + * + * @param string $type type of path + * @param string $plugin name of plugin + * @return string array + */ + public static function path($type, $plugin = null) { + if (!empty(self::$legacy[$type])) { + $type = self::$legacy[$type]; + } + + if (!empty($plugin)) { + $path = array(); + $pluginPath = self::pluginPath($plugin); + if (!empty(self::$__packageFormat[$type])) { + foreach (self::$__packageFormat[$type] as $f) { + $path[] = sprintf($f, $pluginPath); + } + } + $path[] = $pluginPath . 'Lib' . DS . $type . DS; + return $path; + } + + if (!isset(self::$__packages[$type])) { + return array(); + } + return self::$__packages[$type]; + } + +/** + * Sets up each package location on the file system. You can configure multiple search paths + * for each package, those will be used to look for files one folder at a time in the specified order + * All paths should be terminated with a Directory separator + * + * Usage: + * + * `App::build(array(Model' => array('/a/full/path/to/models/'))); will setup a new search path for the Model package` + * + * `App::build(array('Model' => array('/path/to/models/')), true); will setup the path as the only valid path for searching models` + * + * `App::build(array('View/Helper' => array('/path/to/models/', '/another/path/))); will setup multiple search paths for helpers` + * + * @param array $paths associative array with package names as keys and a list of directories for new search paths + * @param boolean $reset true will set paths, false merges paths [default] false + * @return void + */ + public static function build($paths = array(), $reset = false) { + if (empty(self::$__packageFormat)) { + self::$__packageFormat = array( + 'Model' => array( + '%s' . 'Model' . DS, + '%s' . 'models' . DS + ), + 'Model/Behavior' => array( + '%s' . 'Model' . DS . 'Behavior' . DS, + '%s' . 'models' . DS . 'behaviors' . DS + ), + 'Model/Datasource' => array( + '%s' . 'Model' . DS . 'Datasource' . DS, + '%s' . 'models' . DS . 'datasources' . DS + ), + 'Model/Datasource/Database' => array( + '%s' . 'Model' . DS . 'Datasource' . DS . 'Database' . DS, + '%s' . 'models' . DS . 'datasources' . DS . 'database' . DS + ), + 'Model/Datasource/Session' => array( + '%s' . 'Model' . DS . 'Datasource' . DS . 'Session' . DS, + '%s' . 'models' . DS . 'datasources' . DS . 'session' . DS + ), + 'Controller' => array( + '%s' . 'Controller' . DS, + '%s' . 'controllers' . DS + ), + 'Controller/Component' => array( + '%s' . 'Controller' . DS . 'Component' . DS, + '%s' . 'controllers' . DS . 'components' . DS + ), + 'View' => array( + '%s' . 'View' . DS, + '%s' . 'views' . DS + ), + 'View/Helper' => array( + '%s' . 'View' . DS . 'Helper' . DS, + '%s' . 'views' . DS . 'helpers' . DS + ), + 'Console' => array( + '%s' . 'Console' . DS, + '%s' . 'console' . DS + ), + 'Console/Command' => array( + '%s' . 'Console' . DS . 'Command' . DS, + '%s' . 'console' . DS . 'shells' . DS, + ), + 'Console/Command/Task' => array( + '%s' . 'Console' . DS . 'Command' . DS . 'Task' . DS, + '%s' . 'console' . DS . 'shells' . DS . 'tasks' . DS + ), + 'Lib' => array( + '%s' . 'Lib' . DS, + '%s' . 'libs' . DS + ), + 'locales' => array( + '%s' . 'locale' . DS + ), + 'vendors' => array('%s' . 'vendors' . DS, VENDORS), + 'plugins' => array(APP . 'plugins' . DS, CAKE_CORE_INCLUDE_PATH . DS . 'plugins' . DS) + ); + } + + if ($reset == true) { + foreach ($paths as $type => $new) { + if (!empty(self::$legacy[$type])) { + $type = self::$legacy[$type]; + } + self::$__packages[$type] = (array)$new; + } + return $paths; + } + + //Provides Backwards compatibility for old-style package names + $legacyPaths = array(); + foreach ($paths as $type => $path) { + if (!empty(self::$legacy[$type])) { + $type = self::$legacy[$type]; + } + $legacyPaths[$type] = $path; + } + + $paths = $legacyPaths; + $defaults = array(); + foreach (self::$__packageFormat as $package => $format) { + foreach ($format as $f) { + $defaults[$package][] = sprintf($f, APP); + } + } + + $mergeExclude = array('Lib', 'locales', 'vendors', 'plugins'); + $appLibs = empty($paths['Lib']) ? $defaults['Lib'] : $paths['Lib']; + + foreach ($defaults as $type => $default) { + if (empty(self::$__packages[$type]) || empty($paths)) { + self::$__packages[$type] = $default; + } + + if (!empty($paths[$type])) { + $path = array_merge((array)$paths[$type], self::$__packages[$type]); + } else { + $path = self::$__packages[$type]; + } + + self::$__packages[$type] = array_values(array_unique($path)); + } + } + +/** + * Gets the path that a plugin is on. Searches through the defined plugin paths. + * + * Usage: + * + * `App::pluginPath('MyPlugin'); will return the full path to 'MyPlugin' plugin'` + * + * @param string $plugin CamelCased/lower_cased plugin name to find the path of. + * @return string full path to the plugin. + */ + public static function pluginPath($plugin) { + $pluginDir = Inflector::underscore($plugin); + foreach (self::$__packages['plugins'] as $pluginPath) { + if (is_dir($pluginPath . $pluginDir)) { + return $pluginPath . $pluginDir . DS ; + } + } + return self::$__packages['plugins'][0] . $pluginDir . DS; + } + +/** + * Finds the path that a theme is on. Searches through the defined theme paths. + * + * Usage: + * + * `App::themePath('MyTheme'); will return the full path to the 'MyTheme' theme` + * + * @param string $theme lower_cased theme name to find the path of. + * @return string full path to the theme. + */ + public static function themePath($theme) { + $themeDir = 'themed' . DS . Inflector::underscore($theme); + foreach (self::$__packages['View'] as $path) { + if (is_dir($path . $themeDir)) { + return $path . $themeDir . DS ; + } + } + return self::$__packages['View'][0] . $themeDir . DS; + } + +/** + * Returns the full path to a package inside the CakePHP core + * + * Usage: + * + * `App::core('Cache/Engine'); will return the full path to the cache engines package` + * + * @param string $type + * @return string full path to package + */ + public static function core($type) { + if ($type) { + return isset($paths[$type]) ? $paths[$type] : array(LIBS . $type . DS); + } + } + +/** + * Returns an array of objects of the given type. + * + * Example usage: + * + * `App::objects('plugin');` returns `array('DebugKit', 'Blog', 'User');` + * + * `App::objects('Controller');` returns `array('PagesController', 'BlogController');` + * + * You can also search only within a plugin's objects by using the plugin dot + * syntax. + * + * `App::objects('MyPlugin.Model');` returns `array('MyPluginPost', 'MyPluginComment');` + * + * @param string $type Type of object, i.e. 'Model', 'Controller', 'View/Helper', 'file', 'class' or 'plugin' + * @param mixed $path Optional Scan only the path given. If null, paths for the chosen type will be used. + * @param boolean $cache Set to false to rescan objects of the chosen type. Defaults to true. + * @return mixed Either false on incorrect / miss. Or an array of found objects. + */ + public static function objects($type, $path = null, $cache = true) { + $objects = array(); + $extension = '/\.php$/'; + $includeDirectories = false; + $name = $type; + + if ($type === 'plugin') { + $type = 'plugins'; + } + + if ($type == 'plugins') { + $extension = '/.*/'; + $includeDirectories = true; + } + + list($plugin, $type) = pluginSplit($type); + + if (isset(self::$legacy[$type . 's'])) { + $type = self::$legacy[$type . 's']; + } + + if ($type === 'file' && !$path) { + return false; + } elseif ($type === 'file') { + $extension = '/\.php$/'; + $name = $type . str_replace(DS, '', $path); + } + + if (empty(self::$__objects) && $cache === true) { + self::$__objects = Cache::read('object_map', '_cake_core_'); + } + + $cacheLocation = empty($plugin) ? 'app' : $plugin; + + if ($cache !== true || !isset(self::$__objects[$cacheLocation][$name])) { + $objects = array(); + + if (empty($path)) { + $path = self::path($type, $plugin); + } + + $items = array(); + + foreach ((array)$path as $dir) { + if ($dir != APP && is_dir($dir)) { + $files = new RegexIterator(new DirectoryIterator($dir), $extension); + foreach ($files as $file) { + if (!$file->isDot()) { + $isDir = $file->isDir() ; + if ($isDir && $includeDirectories) { + $objects[] = basename($file); + } elseif (!$includeDirectories && !$isDir) { + $objects[] = substr(basename($file), 0, -4); + } + } + } + } + } + + if ($type !== 'file') { + foreach ($objects as $key => $value) { + $objects[$key] = Inflector::camelize($value); + } + } + + if ($cache === true) { + self::$__cache = true; + } + if ($plugin) { + return $objects; + } + self::$__objects[$cacheLocation][$name] = $objects; + self::$_objectCacheChange = true; + } + + return self::$__objects[$cacheLocation][$name]; + } + +/** + * Allows you to modify the object listings that App maintains inside of it + * Useful for testing + * + * @param string $type Type of object listing you are changing + * @param array $values The values $type should be set to. + * @return void + */ + public static function setObjects($type, $values) { + list($plugin, $type) = pluginSplit($type); + $cacheLocation = empty($plugin) ? 'app' : $plugin; + self::$__objects[$cacheLocation][$type] = $values; + } + +/** + * Declares a package for a class. This package location will be used + * by the automatic class loader if the class is tried to be used + * + * Usage: + * + * `App::uses('MyCustomController', 'Controller');` will setup the class to be found under Controller package + * + * `App::uses('MyHelper', 'MyPlugin.View/Helper');` will setup the helper class to be found in plugin's helper package + * + * @param string $className the name of the class to configure package for + * @param string $location the package name + */ + public static function uses($className, $location) { + self::$__classMap[$className] = $location; + } + +/** + * Method to handle the automatic class loading. It will look for each class' package + * defined using App::uses() and with this information it will resolve the package name to a full path + * to load the class from. File name for each class should follow the class name. For instance, + * if a class is name `MyCustomClass` the file name should be `MyCustomClass.php` + * + * @param string $className the name of the class to load + */ + public static function load($className) { + if (isset(self::$__classMap[$className])) { + if ($file = self::__mapped($className)) { + return include $file; + } + + $parts = explode('.', self::$__classMap[$className], 2); + list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts)); + $paths = self::path($package, $plugin); + + if (empty($plugin)) { + $appLibs = empty(self::$__packages['Lib']) ? APPLIBS : current(self::$__packages['Lib']); + $paths[] = $appLibs . $package . DS; + $paths[] = LIBS . $package . DS; + } + + foreach ($paths as $path) { + $file = $path . $className . '.php'; + if (file_exists($file)) { + self::__map($file, $className); + return include $file; + } + } + + //To help apps migrate to 2.0 old style file names are allowed + foreach ($paths as $path) { + $underscored = Inflector::underscore($className); + $tries = array($path . $underscored . '.php'); + $parts = explode('_', $underscored); + if (count($parts) > 1) { + array_pop($parts); + $tries[] = $path . implode('_', $parts) . '.php'; + } + foreach ($tries as $file) { + if (file_exists($file)) { + self::__map($file, $className); + return include $file; + } + } + } + } + + return false; + } + +/** + * Finds classes based on $name or specific file(s) to search. Calling App::import() will + * not construct any classes contained in the files. It will only find and require() the file. + * + * @link http://book.cakephp.org/view/934/Using-App-import + * @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, 'ext' => '$ext'); + * $ext allows setting the extension of the file name + * based on Inflector::underscore($name) . ".$ext"; + * @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 + */ + public static function import($type = null, $name = null, $parent = true, $search = array(), $file = null, $return = false) { + $ext = $plugin = $directory = null; + + if (is_array($type)) { + extract($type, EXTR_OVERWRITE); + } + + if (is_array($parent)) { + extract($parent, EXTR_OVERWRITE); + } + + if ($name == null && $file == null) { + return false; + } + + if (is_array($name)) { + foreach ($name as $class) { + if (!App::import(compact('type', 'parent', 'search', 'file', 'return') + array('name' => $class))) { + return false; + } + } + return true; + } + + $originalType = $type = strtolower($type); + $specialPackage = in_array($type, array('file', 'vendor')); + if (!$specialPackage && isset(self::$legacy[$type . 's'])) { + $type = self::$legacy[$type . 's']; + } + list($plugin, $name) = pluginSplit($name); + if (!empty($plugin)) { + $plugin = Inflector::camelize($plugin); + } + + if (!$specialPackage) { + return self::_loadClass($name, $plugin, $type, $originalType, $parent); + } + + if ($type == 'file' && !empty($file)) { + return self::_loadFile($name, $plugin, $search, $file, $return); + } + + if ($type == 'vendor') { + return self::_loadVendor($name, $plugin, $file, $ext); + } + + return false; + } + +/** + * Helper function to include classes + * This is a compatibility wrapper around using App::uses() and automatic class loading + * + * @param string $name unique name of the file for identifying it inside the application + * @param string $plugin camel cased plugin name if any + * @param string $type name of the packed where the class is located + * @param string $file filename if known, the $name param will be used otherwise + * @param string $originalType type name as supplied initially by the user + * @param boolean $parent whether to load the class parent or not + * @return boolean true indicating the successful load and existence of the class + */ + private function _loadClass($name, $plugin, $type, $originalType, $parent) { + if ($type == 'Console/Command' && $name == 'Shell') { + $type = 'Console'; + } else if (isset(self::$types[$originalType]['suffix'])) { + $suffix = self::$types[$originalType]['suffix']; + $name .= ($suffix == $name) ? '' : $suffix; + } + + if ($parent && isset(self::$types[$originalType]['extends'])) { + $extends = self::$types[$originalType]['extends']; + App::uses($extends, $type); + if ($plugin && in_array($originalType, array('controller', 'model'))) { + App::uses($plugin . $extends, $plugin . '.' .$type); + } + } + if ($plugin) { + $plugin .= '.'; + } + $name = Inflector::camelize($name); + App::uses($name, $plugin . $type); + return class_exists($name); + } + +/** + * Helper function to include single files + * + * @param string $name unique name of the file for identifying it inside the application + * @param string $plugin camel cased plugin name if any + * @param array $search list of paths to search the file into + * @param string $file filename if known, the $name param will be used otherwise + * @param boolean $return whether this function should return the contents of the file after being parsed by php or just a success notice + * @return mixed, if $return contents of the file after php parses it, boolean indicating success otherwise + */ + private function _loadFile($name, $plugin, $search, $file, $return) { + $mapped = self::__mapped($name, $plugin); + if ($mapped) { + $file = $mapped; + } else if (!empty($search)) { + foreach ($search as $path) { + $found = false; + if (file_exists($path . $file)) { + $file = $path . $file; + $found = true; + break; + } + if (empty($found)) { + $file = false; + } + } + } + if (!empty($file) && file_exists($file)) { + self::__map($file, $name, $plugin); + $returnValue = include $file; + if ($return) { + return $returnValue; + } + return (bool) $returnValue; + } + return false; + } + +/** + * Helper function to load files from vendors folders + * + * @param string $name unique name of the file for identifying it inside the application + * @param string $plugin camel cased plugin name if any + * @param string $file file name if known + * @param string $ext file extension if known + * @return boolean true if the file was loaded successfully, false otherwise + */ + private function _loadVendor($name, $plugin, $file, $ext) { + if ($mapped = self::__mapped($name, $plugin)) { + return (bool) include_once($mapped); + } + $fileTries = array(); + $paths = ($plugin) ? App::path('vendors', $plugin) : App::path('vendors'); + if (empty($ext)) { + $ext = 'php'; + } + if (empty($file)) { + $fileTries[] = $name . '.' . $ext; + $fileTries[] = Inflector::underscore($name) . '.' . $ext; + } else { + $fileTries[] = $file; + } + + foreach ($fileTries as $file) { + foreach ($paths as $path) { + if (file_exists($path . $file)) { + self::__map($path . $file, $name, $plugin); + return (bool) include($path . $file); + } + } + } + return false; + } + +/** + * Initializes the cache for App, registers a shutdown function. + * + * @return void + */ + public static function init() { + self::$__map = (array)Cache::read('file_map', '_cake_core_'); + self::$__objects = (array)Cache::read('object_map', '_cake_core_'); + register_shutdown_function(array('App', 'shutdown')); + } + +/** + * Maps the $name to the $file. + * + * @param string $file full path to file + * @param string $name unique name for this map + * @param string $plugin camelized if object is from a plugin, the name of the plugin + * @return void + * @access private + */ + private static function __map($file, $name, $plugin = null) { + if ($plugin) { + self::$__map['Plugin'][$plugin][$name] = $file; + } else { + self::$__map[$name] = $file; + } + self::$_cacheChange = true; + } + +/** + * Returns a file's complete path. + * + * @param string $name unique name + * @param string $plugin camelized if object is from a plugin, the name of the plugin + * @return mixed, file path if found, false otherwise + * @access private + */ + private static function __mapped($name, $plugin = null) { + if ($plugin) { + if (isset(self::$__map['Plugin'][$plugin][$name])) { + return self::$__map['Plugin'][$plugin][$name]; + } + return false; + } + + if (isset(self::$__map[$name])) { + return self::$__map[$name]; + } + return false; + } + +/** + * Object destructor. + * + * Writes cache file if changes have been made to the $__map or $__paths + * + * @return void + */ + public static function shutdown() { + if (self::$__cache && self::$_cacheChange) { + Cache::write('file_map', array_filter(self::$__map), '_cake_core_'); + } + if (self::$__cache && self::$_objectCacheChange) { + Cache::write('object_map', self::$__objects, '_cake_core_'); + } + } +} \ No newline at end of file diff --git a/cake/libs/configure.php b/lib/Cake/Core/Configure.php similarity index 94% rename from cake/libs/configure.php rename to lib/Cake/Core/Configure.php index 97b54b3e9..ee139eb54 100644 --- a/cake/libs/configure.php +++ b/lib/Cake/Core/Configure.php @@ -21,7 +21,7 @@ * Configuration class. Used for managing runtime configuration information. * * Provides features for reading and writing to the runtime configuration, as well - * as methods for loading additional configuration files or storing runtime configuration + * as methods for loading additional configuration files or storing runtime configuration * for future use. * * @package cake.libs @@ -70,13 +70,13 @@ class Configure { )); if (!include(CONFIGS . 'core.php')) { - trigger_error(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR); + trigger_error(__d('cake_dev', "Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR); } App::init(); App::build(); if (!include(CONFIGS . 'bootstrap.php')) { - trigger_error(__("Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR); + trigger_error(__d('cake_dev', "Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR); } $level = -1; if (isset(self::$_values['Error']['level'])) { @@ -224,7 +224,7 @@ class Configure { } /** - * Add a new reader to Configure. Readers allow you to read configuration + * Add a new reader to Configure. Readers allow you to read configuration * files in various formats/storage locations. CakePHP comes with two built-in readers * PhpReader and IniReader. You can also implement your own reader classes in your application. * @@ -232,7 +232,7 @@ class Configure { * * `Configure::config('ini', new IniReader());` * - * @param string $name The name of the reader being configured. This alias is used later to + * @param string $name The name of the reader being configured. This alias is used later to * read values from a specific reader. * @param ConfigReaderInterface $reader The reader to append. * @return void @@ -254,7 +254,7 @@ class Configure { } /** - * Remove a configured reader. This will unset the reader + * Remove a configured reader. This will unset the reader * and make any future attempts to use it cause an Exception. * * @param string $name Name of the reader to drop. @@ -276,7 +276,7 @@ class Configure { * runtime configuration. You can load configuration files from plugins * by preceding the filename with the plugin name. * - * `Configure::load('Users.user', 'default')` + * `Configure::load('Users.user', 'default')` * * Would load the 'user' config file using the default config reader. You can load * app config files by giving the name of the resource you want loaded. @@ -318,7 +318,7 @@ class Configure { */ public static function version() { if (!isset(self::$_values['Cake']['version'])) { - require(CORE_PATH . 'cake' . DS . 'config' . DS . 'config.php'); + require(LIBS . 'config' . DS . 'config.php'); self::write($config); } return self::$_values['Cake']['version']; @@ -369,7 +369,7 @@ interface ConfigReaderInterface { * These sources can either be static resources like files, or dynamic ones like * a database, or other datasource. * - * @param string $key + * @param string $key * @return array An array of data to merge into the runtime configuration */ function read($key); diff --git a/cake/libs/object.php b/lib/Cake/Core/Object.php similarity index 99% rename from cake/libs/object.php rename to lib/Cake/Core/Object.php index 9096ae121..28a3d0d29 100644 --- a/cake/libs/object.php +++ b/lib/Cake/Core/Object.php @@ -20,6 +20,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Set', 'Utility'); + /** * Object class provides a few generic methods used in several subclasses. * @@ -64,9 +66,7 @@ class Object { if (empty($url)) { return false; } - if (!class_exists('dispatcher')) { - require LIBS . 'dispatcher.php'; - } + App::uses('Dispatcher', 'Routing'); if (in_array('return', $extra, true)) { $extra = array_merge($extra, array('return' => 0, 'autoRender' => 1)); } diff --git a/cake/libs/error/error_handler.php b/lib/Cake/Error/ErrorHandler.php similarity index 94% rename from cake/libs/error/error_handler.php rename to lib/Cake/Error/ErrorHandler.php index 775bd8d43..6787e23f7 100644 --- a/cake/libs/error/error_handler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -19,6 +19,11 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Debugger', 'Utility'); +App::uses('CakeLog', 'Log'); +App::uses('ExceptionRenderer', 'Error'); +App::uses('AppController', 'Controller'); + /** * * Error Handler provides basic error and exception handling for your application. It captures and @@ -102,12 +107,8 @@ class ErrorHandler { * @see http://php.net/manual/en/function.set-exception-handler.php */ public static function handleException(Exception $exception) { - App::import('Core', 'error/ExceptionRenderer'); $config = Configure::read('Exception'); if (!empty($config['log'])) { - if (!class_exists('CakeLog')) { - require LIBS . 'cake_log.php'; - } $message = sprintf("[%s] %s\n%s", get_class($exception), $exception->getMessage(), @@ -116,7 +117,7 @@ class ErrorHandler { CakeLog::write(LOG_ERR, $message); } if ($config['renderer'] !== 'ExceptionRenderer') { - App::import('Lib', $config['renderer']); + App::uses($config['renderer'], 'Error'); } $error = new $config['renderer']($exception); $error->render(); @@ -146,9 +147,6 @@ class ErrorHandler { $debug = Configure::read('debug'); if ($debug) { - if (!class_exists('Debugger')) { - require LIBS . 'debugger.php'; - } $data = array( 'level' => $log, 'code' => $code, @@ -162,14 +160,8 @@ class ErrorHandler { ); return Debugger::getInstance()->outputError($data); } else { - if (!class_exists('CakeLog')) { - require LIBS . 'cake_log.php'; - } $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; if (!empty($errorConfig['trace'])) { - if (!class_exists('Debugger')) { - require LIBS . 'debugger.php'; - } $trace = Debugger::trace(array('start' => 1, 'format' => 'log')); $message .= "\nTrace:\n" . $trace . "\n"; } diff --git a/cake/libs/error/exception_renderer.php b/lib/Cake/Error/ExceptionRenderer.php similarity index 96% rename from cake/libs/error/exception_renderer.php rename to lib/Cake/Error/ExceptionRenderer.php index 328fffd8d..761aae0c4 100644 --- a/cake/libs/error/exception_renderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -19,6 +19,10 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('Sanitize', 'Utility'); +App::uses('Router', 'Routing'); + /** * Exception Renderer. * @@ -86,8 +90,6 @@ class ExceptionRenderer { * @param array $messages Error messages */ function __construct(Exception $exception) { - App::import('Core', 'Sanitize'); - $this->controller = $this->_getController($exception); if (method_exists($this->controller, 'apperror')) { @@ -142,7 +144,7 @@ class ExceptionRenderer { */ protected function _getController($exception) { static $__previousError = null; - App::import('Controller', 'CakeError'); + App::uses('CakeErrorController', 'Controller'); if ($__previousError != $exception) { $__previousError = $exception; @@ -193,7 +195,7 @@ class ExceptionRenderer { public function error400($error) { $message = $error->getMessage(); if (Configure::read('debug') == 0 && $error instanceof CakeException) { - $message = __('Not Found'); + $message = __d('cake', 'Not Found'); } $url = $this->controller->request->here(); $this->controller->response->statusCode($error->getCode()); @@ -215,7 +217,7 @@ class ExceptionRenderer { $code = ($error->getCode() > 500) ? $error->getCode() : 500; $this->controller->response->statusCode($code); $this->controller->set(array( - 'name' => __('An Internal Error Has Occurred'), + 'name' => __d('cake', 'An Internal Error Has Occurred'), 'message' => h($url), 'error' => $error, )); diff --git a/cake/libs/error/exceptions.php b/lib/Cake/Error/exceptions.php similarity index 88% rename from cake/libs/error/exceptions.php rename to lib/Cake/Error/exceptions.php index 7baa957c1..d178005b6 100644 --- a/cake/libs/error/exceptions.php +++ b/lib/Cake/Error/exceptions.php @@ -20,12 +20,14 @@ /** * Parent class for all of the HTTP related exceptions in CakePHP. - * All HTTP status/error related exceptions should extend this class so + * All HTTP status/error related exceptions should extend this class so * catch blocks can be specifically typed. * * @package cake.libs */ -class HttpException extends RuntimeException { } +if (!class_exists('HttpException')) { + class HttpException extends RuntimeException { } +} /** * Represents an HTTP 400 error. @@ -182,7 +184,7 @@ class CakeException extends RuntimeException { public function __construct($message, $code = 500) { if (is_array($message)) { $this->_attributes = $message; - $message = __($this->_messageTemplate, $message); + $message = __d('cake_dev', $this->_messageTemplate, $message); } parent::__construct($message, $code); } @@ -198,12 +200,12 @@ class CakeException extends RuntimeException { } /** - * Missing Controller exception - used when a controller + * Missing Controller exception - used when a controller * cannot be found. * * @package cake.libs */ -class MissingControllerException extends CakeException { +class MissingControllerException extends CakeException { protected $_messageTemplate = 'Controller class %s could not be found.'; public function __construct($message, $code = 404) { @@ -212,12 +214,12 @@ class MissingControllerException extends CakeException { } /** - * Missing Action exception - used when a controller action + * Missing Action exception - used when a controller action * cannot be found. * * @package cake.libs */ -class MissingActionException extends CakeException { +class MissingActionException extends CakeException { protected $_messageTemplate = 'Action %s::%s() could not be found.'; public function __construct($message, $code = 404) { @@ -225,12 +227,12 @@ class MissingActionException extends CakeException { } } /** - * Private Action exception - used when a controller action + * Private Action exception - used when a controller action * is protected, or starts with a `_`. * * @package cake.libs */ -class PrivateActionException extends CakeException { +class PrivateActionException extends CakeException { protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.'; public function __construct($message, $code = 404, Exception $previous = null) { @@ -243,7 +245,7 @@ class PrivateActionException extends CakeException { * * @package cake.libs */ -class MissingComponentFileException extends CakeException { +class MissingComponentFileException extends CakeException { protected $_messageTemplate = 'Component File "%s" is missing.'; } @@ -252,7 +254,7 @@ class MissingComponentFileException extends CakeException { * * @package cake.libs */ -class MissingComponentClassException extends CakeException { +class MissingComponentClassException extends CakeException { protected $_messageTemplate = 'Component class "%s" is missing.'; } @@ -275,7 +277,7 @@ class MissingBehaviorClassException extends CakeException { } * * @package cake.libs */ -class MissingViewException extends CakeException { +class MissingViewException extends CakeException { protected $_messageTemplate = 'View file "%s" is missing.'; } @@ -284,7 +286,7 @@ class MissingViewException extends CakeException { * * @package cake.libs */ -class MissingLayoutException extends CakeException { +class MissingLayoutException extends CakeException { protected $_messageTemplate = 'Layout file "%s" is missing.'; } @@ -293,7 +295,7 @@ class MissingLayoutException extends CakeException { * * @package cake.libs */ -class MissingHelperFileException extends CakeException { +class MissingHelperFileException extends CakeException { protected $_messageTemplate = 'Helper File "%s" is missing.'; } @@ -302,7 +304,7 @@ class MissingHelperFileException extends CakeException { * * @package cake.libs */ -class MissingHelperClassException extends CakeException { +class MissingHelperClassException extends CakeException { protected $_messageTemplate = 'Helper class "%s" is missing.'; } @@ -330,7 +332,7 @@ class MissingConnectionException extends CakeException { * * @package cake.libs */ -class MissingTaskFileException extends CakeException { +class MissingTaskFileException extends CakeException { protected $_messageTemplate = 'Task file "%s" is missing.'; } @@ -339,7 +341,7 @@ class MissingTaskFileException extends CakeException { * * @package cake.libs */ -class MissingTaskClassException extends CakeException { +class MissingTaskClassException extends CakeException { protected $_messageTemplate = 'Task class "%s" is missing.'; } @@ -348,7 +350,7 @@ class MissingTaskClassException extends CakeException { * * @package cake.libs */ -class MissingShellMethodException extends CakeException { +class MissingShellMethodException extends CakeException { protected $_messageTemplate = "Unknown command %1\$s %2\$s.\nFor usage try `cake %1\$s --help`"; } @@ -357,7 +359,7 @@ class MissingShellMethodException extends CakeException { * * @package cake.libs */ -class MissingShellClassException extends CakeException { +class MissingShellClassException extends CakeException { protected $_messageTemplate = "Shell class %s could not be loaded."; } @@ -366,7 +368,7 @@ class MissingShellClassException extends CakeException { * * @package cake.libs */ -class MissingShellFileException extends CakeException { +class MissingShellFileException extends CakeException { protected $_messageTemplate = "Shell file %s could not be loaded."; } @@ -406,6 +408,15 @@ class MissingModelException extends CakeException { protected $_messageTemplate = 'Model %s could not be found.'; } +/** + * Exception Raised when a test loader could not be found + * + * @package cake.libs + */ +class MissingTestLoaderException extends CakeException { + protected $_messageTemplate = 'Test loader %s could not be found.'; +} + /** * Exception class for Cache. This exception will be thrown from Cache when it @@ -470,4 +481,3 @@ class XmlException extends CakeException { } * @package cake.libs */ class ConsoleException extends CakeException { } - diff --git a/cake/libs/i18n.php b/lib/Cake/I18n/I18n.php similarity index 99% rename from cake/libs/i18n.php rename to lib/Cake/I18n/I18n.php index b140790d4..e05e1bcdc 100644 --- a/cake/libs/i18n.php +++ b/lib/Cake/I18n/I18n.php @@ -20,8 +20,8 @@ /** * Included libraries. */ -App::import('Core', 'L10n'); -App::import('Core', 'Multibyte'); +App::uses('L10n', 'I18n'); +App::uses('Multibyte', 'I18n'); /** * I18n handles translation of Text and time format strings. @@ -99,7 +99,7 @@ class I18n { /** * Used by the translation functions in basics.php - * Can also be used like I18n::translate(); but only if the App::import('I18n'); has been used to load the class. + * Returns a translated string based on current language and translation files stored in locale folder * * @param string $singular String to translate * @param string $plural Plural string (if any) diff --git a/cake/libs/l10n.php b/lib/Cake/I18n/L10n.php similarity index 99% rename from cake/libs/l10n.php rename to lib/Cake/I18n/L10n.php index 2da41af34..c9bef1e79 100644 --- a/cake/libs/l10n.php +++ b/lib/Cake/I18n/L10n.php @@ -16,7 +16,7 @@ * @since CakePHP(tm) v 1.2.0.4116 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'CakeRequest'); +App::uses('CakeRequest', 'Network'); /** * Localization diff --git a/cake/libs/multibyte.php b/lib/Cake/I18n/Multibyte.php similarity index 99% rename from cake/libs/multibyte.php rename to lib/Cake/I18n/Multibyte.php index 123d3d11b..9ad06c093 100644 --- a/cake/libs/multibyte.php +++ b/lib/Cake/I18n/Multibyte.php @@ -1076,7 +1076,7 @@ class Multibyte { return null; } if (!Configure::configured('_cake_core_')) { - App::import('Core', 'config/PhpReader'); + App::uses('PhpReader', 'Configure'); Configure::config('_cake_core_', new PhpReader(CAKE . 'config' . DS)); } Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_'); diff --git a/cake/LICENSE.txt b/lib/Cake/LICENSE.txt similarity index 100% rename from cake/LICENSE.txt rename to lib/Cake/LICENSE.txt diff --git a/cake/libs/cake_log.php b/lib/Cake/Log/CakeLog.php similarity index 85% rename from cake/libs/cake_log.php rename to lib/Cake/Log/CakeLog.php index 53b29af93..8305d4fba 100644 --- a/cake/libs/cake_log.php +++ b/lib/Cake/Log/CakeLog.php @@ -36,22 +36,6 @@ define('LOG_INFO', 6); } -/** - * CakeLogStreamInterface is the interface that should be implemented - * by all classes that are going to be used as Log streams. - * - * @package cake.libs - */ -interface CakeLogInterface { -/** - * Write method to handle writes being made to the Logger - * - * @param string $type - * @param string $message - * @return void - */ - public function write($type, $message); -} /** * Logs messages to configured Log adapters. One or more adapters can be configured @@ -98,7 +82,7 @@ class CakeLog { */ public static function config($key, $config) { if (empty($config['engine'])) { - throw new CakeLogException(__('Missing logger classname')); + throw new CakeLogException(__d('cake_dev', 'Missing logger classname')); } $loggerName = $config['engine']; unset($config['engine']); @@ -106,7 +90,7 @@ class CakeLog { $logger = new $className($config); if (!$logger instanceof CakeLogInterface) { throw new CakeLogException(sprintf( - __('logger class %s does not implement a write method.'), $loggerName + __d('cake_dev', 'logger class %s does not implement a write method.'), $loggerName )); } self::$_streams[$key] = $logger; @@ -121,17 +105,11 @@ class CakeLog { * @return mixed boolean false on any failures, string of classname to use if search was successful. */ protected static function _getLogger($loggerName) { - list($plugin, $loggerName) = pluginSplit($loggerName); + list($plugin, $loggerName) = pluginSplit($loggerName, true); - if ($plugin) { - App::import('Lib', $plugin . '.log/' . $loggerName); - } else { - if (!App::import('Lib', 'log/' . $loggerName)) { - App::import('Core', 'log/' . $loggerName); - } - } + App::uses($loggerName, $plugin . 'Log/Engine'); if (!class_exists($loggerName)) { - throw new CakeLogException(__('Could not load class %s', $loggerName)); + throw new CakeLogException(__d('cake_dev', 'Could not load class %s', $loggerName)); } return $loggerName; } @@ -162,9 +140,7 @@ class CakeLog { * @return void */ protected static function _autoConfig() { - if (!class_exists('FileLog')) { - App::import('Core', 'log/FileLog'); - } + self::_getLogger('FileLog'); self::$_streams['default'] = new FileLog(array('path' => LOGS)); } @@ -219,4 +195,4 @@ class CakeLog { } return true; } -} \ No newline at end of file +} diff --git a/lib/Cake/Log/CakeLogInterface.php b/lib/Cake/Log/CakeLogInterface.php new file mode 100644 index 000000000..0b2cd1a3c --- /dev/null +++ b/lib/Cake/Log/CakeLogInterface.php @@ -0,0 +1,18 @@ + $name, 'alias' => $name)); if (empty($model)) { - trigger_error(__("Model class '%s' not found in AclNode::node() when trying to bind %s object", $type, $this->alias), E_USER_WARNING); + trigger_error(__d('cake_dev', "Model class '%s' not found in AclNode::node() when trying to bind %s object", $type, $this->alias), E_USER_WARNING); return null; } @@ -181,141 +178,9 @@ class AclNode extends AppModel { $result = $db->read($this, $queryData, -1); if (!$result) { - trigger_error(__("AclNode::node() - Couldn't find %s node identified by \"%s\"", $type, print_r($ref, true)), E_USER_WARNING); + trigger_error(__d('cake_dev', "AclNode::node() - Couldn't find %s node identified by \"%s\"", $type, print_r($ref, true)), E_USER_WARNING); } } return $result; } } - -/** - * Access Control Object - * - * @package cake.libs.model - */ -class Aco extends AclNode { - -/** - * Model name - * - * @var string - * @access public - */ - public $name = 'Aco'; - -/** - * Binds to ARO nodes through permissions settings - * - * @var array - * @access public - */ - public $hasAndBelongsToMany = array('Aro' => array('with' => 'Permission')); -} - -/** - * Action for Access Control Object - * - * @package cake.libs.model - */ -class AcoAction extends AppModel { - -/** - * Model name - * - * @var string - * @access public - */ - public $name = 'AcoAction'; - -/** - * ACO Actions belong to ACOs - * - * @var array - * @access public - */ - public $belongsTo = array('Aco'); -} - -/** - * Access Request Object - * - * @package cake.libs.model - */ -class Aro extends AclNode { - -/** - * Model name - * - * @var string - * @access public - */ - public $name = 'Aro'; - -/** - * AROs are linked to ACOs by means of Permission - * - * @var array - * @access public - */ - public $hasAndBelongsToMany = array('Aco' => array('with' => 'Permission')); -} - -/** - * Permissions linking AROs with ACOs - * - * @package cake.libs.model - */ -class Permission extends AppModel { - -/** - * Model name - * - * @var string - * @access public - */ - public $name = 'Permission'; - -/** - * Explicitly disable in-memory query caching - * - * @var boolean - * @access public - */ - public $cacheQueries = false; - -/** - * Override default table name - * - * @var string - * @access public - */ - public $useTable = 'aros_acos'; - -/** - * Permissions link AROs with ACOs - * - * @var array - * @access public - */ - public $belongsTo = array('Aro', 'Aco'); - -/** - * No behaviors for this model - * - * @var array - * @access public - */ - public $actsAs = null; - -/** - * Constructor, used to tell this model to use the - * database configured for ACL - */ - function __construct() { - $config = Configure::read('Acl.database'); - if (!empty($config)) { - $this->useDbConfig = $config; - } - parent::__construct(); - } -} diff --git a/lib/Cake/Model/Aco.php b/lib/Cake/Model/Aco.php new file mode 100644 index 000000000..f8a92bcf4 --- /dev/null +++ b/lib/Cake/Model/Aco.php @@ -0,0 +1,48 @@ + array('with' => 'Permission')); +} \ No newline at end of file diff --git a/lib/Cake/Model/AcoAction.php b/lib/Cake/Model/AcoAction.php new file mode 100644 index 000000000..fe9734228 --- /dev/null +++ b/lib/Cake/Model/AcoAction.php @@ -0,0 +1,48 @@ + array('with' => 'Permission')); +} diff --git a/cake/libs/model/behaviors/acl.php b/lib/Cake/Model/Behavior/AclBehavior.php similarity index 97% rename from cake/libs/model/behaviors/acl.php rename to lib/Cake/Model/Behavior/AclBehavior.php index 6a347bba6..ae72d960e 100644 --- a/cake/libs/model/behaviors/acl.php +++ b/lib/Cake/Model/Behavior/AclBehavior.php @@ -58,7 +58,7 @@ class AclBehavior extends ModelBehavior { $model->{$type} = ClassRegistry::init($type); } if (!method_exists($model, 'parentNode')) { - trigger_error(__('Callback parentNode() not defined in %s', $model->alias), E_USER_WARNING); + trigger_error(__d('cake_dev', 'Callback parentNode() not defined in %s', $model->alias), E_USER_WARNING); } } diff --git a/cake/libs/model/behaviors/containable.php b/lib/Cake/Model/Behavior/ContainableBehavior.php similarity index 99% rename from cake/libs/model/behaviors/containable.php rename to lib/Cake/Model/Behavior/ContainableBehavior.php index 03963a723..3c76f2a73 100644 --- a/cake/libs/model/behaviors/containable.php +++ b/lib/Cake/Model/Behavior/ContainableBehavior.php @@ -359,7 +359,7 @@ class ContainableBehavior extends ModelBehavior { if (!isset($Model->{$name}) || !is_object($Model->{$name})) { if ($throwErrors) { - trigger_error(__('Model "%s" is not associated with model "%s"', $Model->alias, $name), E_USER_WARNING); + trigger_error(__d('cake_dev', 'Model "%s" is not associated with model "%s"', $Model->alias, $name), E_USER_WARNING); } continue; } diff --git a/cake/libs/model/behaviors/translate.php b/lib/Cake/Model/Behavior/TranslateBehavior.php similarity index 98% rename from cake/libs/model/behaviors/translate.php rename to lib/Cake/Model/Behavior/TranslateBehavior.php index ff7c9bdc5..48c3d36e3 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('I18n', 'I18n'); + /** * Translate behavior * @@ -53,7 +55,7 @@ class TranslateBehavior extends ModelBehavior { $db = ConnectionManager::getDataSource($model->useDbConfig); if (!$db->connected) { trigger_error( - __('Datasource %s for TranslateBehavior of model %s is not connected', $model->useDbConfig, $model->alias), + __d('cake_dev', 'Datasource %s for TranslateBehavior of model %s is not connected', $model->useDbConfig, $model->alias), E_USER_ERROR ); return false; @@ -335,9 +337,6 @@ class TranslateBehavior extends ModelBehavior { */ protected function _getLocale($model) { if (!isset($model->locale) || is_null($model->locale)) { - if (!class_exists('I18n')) { - App::import('Core', 'i18n'); - } $I18n = I18n::getInstance(); $I18n->l10n->get(Configure::read('Config.language')); $model->locale = $I18n->l10n->locale; @@ -427,7 +426,7 @@ class TranslateBehavior extends ModelBehavior { foreach (array('hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany') as $type) { if (isset($model->{$type}[$association]) || isset($model->__backAssociation[$type][$association])) { trigger_error( - __('Association %s is already binded to model %s', $association, $model->alias), + __d('cake_dev', 'Association %s is already binded to model %s', $association, $model->alias), E_USER_ERROR ); return false; diff --git a/cake/libs/model/behaviors/tree.php b/lib/Cake/Model/Behavior/TreeBehavior.php similarity index 100% rename from cake/libs/model/behaviors/tree.php rename to lib/Cake/Model/Behavior/TreeBehavior.php diff --git a/cake/libs/model/behavior_collection.php b/lib/Cake/Model/BehaviorCollection.php similarity index 94% rename from cake/libs/model/behavior_collection.php rename to lib/Cake/Model/BehaviorCollection.php index 8bd92198f..82cb3ed77 100644 --- a/cake/libs/model/behavior_collection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -18,6 +18,9 @@ * @since CakePHP(tm) v 1.2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('ObjectCollection', 'Utility'); + /** * Model behavior collection class. * @@ -94,26 +97,21 @@ class BehaviorCollection extends ObjectCollection { * @param string $behavior CamelCased name of the behavior to load * @param array $config Behavior configuration parameters * @return boolean True on success, false on failure - * @throws MissingBehaviorFileException or MissingBehaviorClassException when a behavior could not be found. + * @throws MissingBehaviorClassException when a behavior could not be found. */ public function load($behavior, $config = array()) { if (is_array($config) && isset($config['className'])) { $alias = $behavior; $behavior = $config['className']; } - list($plugin, $name) = pluginSplit($behavior); + list($plugin, $name) = pluginSplit($behavior, true); if (!isset($alias)) { $alias = $name; } $class = $name . 'Behavior'; - if (!App::import('Behavior', $behavior)) { - throw new MissingBehaviorFileException(array( - 'file' => Inflector::underscore($behavior) . '.php', - 'class' => $class - )); - } + App::uses($class, $plugin . 'Model/Behavior'); if (!class_exists($class)) { throw new MissingBehaviorClassException(array( 'file' => Inflector::underscore($behavior) . '.php', @@ -221,7 +219,7 @@ class BehaviorCollection extends ObjectCollection { $method = $this->hasMethod($method, true); if ($strict && empty($method)) { - trigger_error(__("BehaviorCollection::dispatchMethod() - Method %s not found in any attached behavior", $method), E_USER_WARNING); + trigger_error(__d('cake_dev', "BehaviorCollection::dispatchMethod() - Method %s not found in any attached behavior", $method), E_USER_WARNING); return null; } if (empty($method)) { diff --git a/cake/libs/model/cake_schema.php b/lib/Cake/Model/CakeSchema.php similarity index 96% rename from cake/libs/model/cake_schema.php rename to lib/Cake/Model/CakeSchema.php index 5579540b0..67f1cb87a 100644 --- a/cake/libs/model/cake_schema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -16,8 +16,9 @@ * @since CakePHP(tm) v 1.2.0.5550 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Model'); -App::import('Core', 'ConnectionManager'); +App::uses('Model', 'Model'); +App::uses('AppModel', 'Model'); +App::uses('ConnectionManager', 'Model'); /** * Base Class for Schema management @@ -204,9 +205,8 @@ class CakeSchema extends Object { )); $db = ConnectionManager::getDataSource($connection); - App::import('Model', 'AppModel'); if (isset($this->plugin)) { - App::import('Model', Inflector::camelize($this->plugin) . 'AppModel'); + App::uses(Inflector::camelize($this->plugin) . 'AppModel', $this->plugin . '.Model'); } $tables = array(); @@ -219,21 +219,29 @@ class CakeSchema extends Object { if (!is_array($models) && $models !== false) { if (isset($this->plugin)) { - $models = App::objects('model', App::pluginPath($this->plugin) . 'models' . DS, false); + $models = App::objects($this->plugin . '.Model', null, false); } else { - $models = App::objects('model'); + $models = App::objects('Model'); } } if (is_array($models)) { foreach ($models as $model) { $importModel = $model; + $plugin = null; if (isset($this->plugin)) { - $importModel = $this->plugin . '.' . $model; + if ($model == $this->plugin . 'AppModel') { + continue; + } + $importModel = $model; + $plugin = $this->plugin . '.'; } - if (!App::import('Model', $importModel)) { + + App::uses($importModel, $plugin . 'Model'); + if (!class_exists($importModel)) { continue; } + $vars = get_class_vars($model); if (empty($vars['useDbConfig']) || $vars['useDbConfig'] != $connection) { continue; @@ -584,7 +592,7 @@ class CakeSchema extends Object { $value['key'] = 'primary'; } if (!isset($db->columns[$value['type']])) { - trigger_error(__('Schema generation error: invalid column type %s does not exist in DBO', $value['type']), E_USER_NOTICE); + trigger_error(__d('cake_dev', 'Schema generation error: invalid column type %s does not exist in DBO', $value['type']), E_USER_NOTICE); continue; } else { $defaultCol = $db->columns[$value['type']]; diff --git a/cake/libs/model/connection_manager.php b/lib/Cake/Model/ConnectionManager.php similarity index 54% rename from cake/libs/model/connection_manager.php rename to lib/Cake/Model/ConnectionManager.php index 568b203a2..0f0ac3435 100644 --- a/cake/libs/model/connection_manager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -18,7 +18,8 @@ * @since CakePHP(tm) v 0.10.x.1402 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require LIBS . 'model' . DS . 'datasources' . DS . 'datasource.php'; + +App::uses('DataSource', 'Model/Datasource'); config('database'); /** @@ -34,7 +35,7 @@ class ConnectionManager { * @var DATABASE_CONFIG * @access public */ - public $config = null; + public static $config = null; /** * Holds instances DataSource objects @@ -42,7 +43,7 @@ class ConnectionManager { * @var array * @access protected */ - protected $_dataSources = array(); + protected static $_dataSources = array(); /** * Contains a list of all file and class names used in Connection settings @@ -50,32 +51,26 @@ class ConnectionManager { * @var array * @access protected */ - protected $_connectionsEnum = array(); + protected static $_connectionsEnum = array(); /** - * Constructor. + * Indicates if the init code for this class has alredy been executed + * + * @var boolean + */ + private static $_init = false; + +/** + * Loads connections configuration. * */ - function __construct() { + private static function init() { + include_once CONFIGS . 'database.php'; if (class_exists('DATABASE_CONFIG')) { - $this->config = new DATABASE_CONFIG(); - $this->_getConnectionObjects(); + self::$config = new DATABASE_CONFIG(); } - } - -/** - * Gets a reference to the ConnectionManger object instance - * - * @return object Instance - */ - public static function &getInstance() { - static $instance = array(); - - if (!$instance) { - $instance[0] = new ConnectionManager(); - } - - return $instance[0]; + register_shutdown_function('ConnectionManager::shutdown'); + self::$_init = true; } /** @@ -87,23 +82,27 @@ class ConnectionManager { * @throws MissingDatasourceFileException */ public static function getDataSource($name) { - $_this = ConnectionManager::getInstance(); - - if (!empty($_this->_dataSources[$name])) { - return $_this->_dataSources[$name]; + if (empty(self::$_init)) { + self::init(); } - if (empty($_this->_connectionsEnum[$name])) { - throw new MissingDatasourceConfigException(array('config' => $name)); + if (!empty(self::$_dataSources[$name])) { + $return = self::$_dataSources[$name]; + return $return; } - $conn = $_this->_connectionsEnum[$name]; + + if (empty(self::$_connectionsEnum[$name])) { + self::_getConnectionObject($name); + } + + self::loadDataSource($name); + $conn = self::$_connectionsEnum[$name]; $class = $conn['classname']; - $_this->loadDataSource($name); - $_this->_dataSources[$name] = new $class($_this->config->{$name}); - $_this->_dataSources[$name]->configKeyName = $name; + self::$_dataSources[$name] = new $class(self::$config->{$name}); + self::$_dataSources[$name]->configKeyName = $name; - return $_this->_dataSources[$name]; + return self::$_dataSources[$name]; } /** @@ -112,8 +111,10 @@ class ConnectionManager { * @return array List of available connections */ public static function sourceList() { - $_this = ConnectionManager::getInstance(); - return array_keys($_this->_dataSources); + if (empty(self::$_init)) { + self::init(); + } + return array_keys(self::$_dataSources); } /** @@ -124,9 +125,11 @@ class ConnectionManager { * in the ConnectionManager. */ public static function getSourceName($source) { - $_this = ConnectionManager::getInstance(); - foreach ($_this->_dataSources as $name => $ds) { - if ($ds == $source) { + if (empty(self::$_init)) { + self::init(); + } + foreach (self::$_dataSources as $name => $ds) { + if ($ds === $source) { return $name; } } @@ -143,27 +146,31 @@ class ConnectionManager { * @throws MissingDatasourceFileException */ public static function loadDataSource($connName) { - $_this = ConnectionManager::getInstance(); + if (empty(self::$_init)) { + self::init(); + } if (is_array($connName)) { $conn = $connName; } else { - $conn = $_this->_connectionsEnum[$connName]; + $conn = self::$_connectionsEnum[$connName]; } - if (class_exists($conn['classname'])) { + if (class_exists($conn['classname'], false)) { return false; } - if (!empty($conn['parent'])) { - $_this->loadDataSource($conn['parent']); + $plugin = $package = null; + if (!empty($conn['plugin'])) { + $plugin = $conn['plugin'] . '.'; + } + if (!empty($conn['package'])) { + $package = '/' . $conn['package']; } - $conn = array_merge(array('plugin' => null, 'classname' => null, 'parent' => null), $conn); - $class = "{$conn['plugin']}.{$conn['classname']}"; - - if (!App::import('Datasource', $class, !is_null($conn['plugin']))) { - throw new MissingDatasourceFileException(array('class' => $conn['classname'], 'plugin' => $conn['plugin'])); + App::uses($conn['classname'], $plugin . 'Model/Datasource' . $package); + if (!class_exists($conn['classname'])) { + throw new MissingDatasourceFileException(array('class' => $conn['classname'], 'plugin' => $plugin)); } return true; } @@ -175,8 +182,10 @@ class ConnectionManager { * (as defined in Connections), and the value is an array with keys 'filename' and 'classname'. */ public static function enumConnectionObjects() { - $_this = ConnectionManager::getInstance(); - return $_this->_connectionsEnum; + if (empty(self::$_init)) { + self::init(); + } + return (array) self::$config; } /** @@ -186,16 +195,18 @@ class ConnectionManager { * @param array $config The DataSource configuration settings * @return object A reference to the DataSource object, or null if creation failed */ - public static function &create($name = '', $config = array()) { - $_this = ConnectionManager::getInstance(); + public static function create($name = '', $config = array()) { + if (empty(self::$_init)) { + self::init(); + } - if (empty($name) || empty($config) || array_key_exists($name, $_this->_connectionsEnum)) { + if (empty($name) || empty($config) || array_key_exists($name, self::$_connectionsEnum)) { $null = null; return $null; } - $_this->config->{$name} = $config; - $_this->_connectionsEnum[$name] = $_this->__connectionData($config); - $return = $_this->getDataSource($name); + self::$config->{$name} = $config; + self::$_connectionsEnum[$name] = self::_connectionData($config); + $return = self::getDataSource($name); return $return; } @@ -204,15 +215,11 @@ class ConnectionManager { * * @return void */ - protected function _getConnectionObjects() { - $connections = get_object_vars($this->config); - - if ($connections != null) { - foreach ($connections as $name => $config) { - $this->_connectionsEnum[$name] = $this->__connectionData($config); - } + protected static function _getConnectionObject($name) { + if (!empty(self::$config->{$name})) { + self::$_connectionsEnum[$name] = self::_connectionData(self::$config->{$name}); } else { - throw new MissingConnectionException(array('class' => 'ConnectionManager')); + throw new MissingDatasourceConfigException(array('config' => $name)); } } @@ -221,44 +228,22 @@ class ConnectionManager { * * @return array An indexed array with: filename, classname, plugin and parent */ - private function __connectionData($config) { - if (!isset($config['datasource'])) { - $config['datasource'] = 'dbo'; - } - $filename = $classname = $parent = $plugin = null; + private static function _connectionData($config) { + $package = $classname = $plugin = null; - if (!empty($config['driver'])) { - $parent = $this->__connectionData(array('datasource' => $config['datasource'])); - $parentSource = preg_replace('/_source$/', '', $parent['filename']); - - list($plugin, $classname) = pluginSplit($config['driver']); - if ($plugin) { - $source = Inflector::underscore($classname); - } else { - $source = $parentSource . '_' . $config['driver']; - $classname = Inflector::camelize(strtolower($source)); - } - $filename = $parentSource . DS . $source; - } else { - list($plugin, $classname) = pluginSplit($config['datasource']); - if ($plugin) { - $filename = Inflector::underscore($classname); - } else { - $filename = Inflector::underscore($config['datasource']); - } - if (substr($filename, -7) != '_source') { - $filename .= '_source'; - } - $classname = Inflector::camelize(strtolower($filename)); + list($plugin, $classname) = pluginSplit($config['datasource']); + if (strpos($classname, '/') !== false) { + $package = dirname($classname); + $classname = basename($classname); } - return compact('filename', 'classname', 'parent', 'plugin'); + return compact('package', 'classname', 'plugin'); } /** * Destructor. * */ - function __destruct() { + public static function shutdown() { if (Configure::read('Session.defaults') == 'database' && function_exists('session_write_close')) { session_write_close(); } diff --git a/cake/libs/cake_session.php b/lib/Cake/Model/Datasource/CakeSession.php similarity index 95% rename from cake/libs/cake_session.php rename to lib/Cake/Model/Datasource/CakeSession.php index ec7a86b27..d8219c448 100644 --- a/cake/libs/cake_session.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -21,9 +21,9 @@ * @since CakePHP(tm) v .0.10.0.1222 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('Security')) { - App::import('Core', 'Security'); -} + +App::uses('Set', 'Utility'); +App::uses('Security', 'Utility'); /** * Session class for Cake. @@ -254,7 +254,7 @@ class CakeSession { self::__overwrite($_SESSION, Set::remove($_SESSION, $name)); return (self::check($name) == false); } - self::__setError(2, __("%s doesn't exist", $name)); + self::__setError(2, __d('cake_dev', "%s doesn't exist", $name)); return false; } @@ -331,11 +331,12 @@ class CakeSession { * @return boolean */ protected static function _validAgentAndTime() { + $config = self::read('Config'); $validAgent = ( Configure::read('Session.checkAgent') === false || - self::$_userAgent == self::read('Config.userAgent') + self::$_userAgent == $config['userAgent'] ); - return ($validAgent && self::$time <= self::read('Config.time')); + return ($validAgent && self::$time <= $config['time']); } /** @@ -479,7 +480,7 @@ class CakeSession { foreach ($sessionConfig['ini'] as $setting => $value) { if (ini_set($setting, $value) === false) { throw new CakeSessionException(sprintf( - __('Unable to configure the session, setting %s failed.'), + __d('cake_dev', 'Unable to configure the session, setting %s failed.'), $setting )); } @@ -511,18 +512,15 @@ class CakeSession { */ protected static function _getHandler($handler) { list($plugin, $class) = pluginSplit($handler, true); - $found = App::import('Lib', $plugin . 'session/' . $class); - if (!$found) { - App::import('Core', 'session/' . $class); - } + App::uses($class, $plugin . 'Model/Datasource/Session'); if (!class_exists($class)) { - throw new CakeSessionException(__('Could not load %s to handle the session.', $class)); + throw new CakeSessionException(__d('cake_dev', 'Could not load %s to handle the session.', $class)); } $handler = new $class(); if ($handler instanceof CakeSessionHandlerInterface) { return $handler; } - throw new CakeSessionException(__('Chosen SessionHandler does not implement CakeSessionHandlerInterface it cannot be used with an engine key.')); + throw new CakeSessionException(__d('cake_dev', 'Chosen SessionHandler does not implement CakeSessionHandlerInterface it cannot be used with an engine key.')); } /** @@ -629,14 +627,14 @@ class CakeSession { self::$valid = false; return false; } - if (self::read('Config')) { + if ($config = self::read('Config')) { $sessionConfig = Configure::read('Session'); if (self::_validAgentAndTime()) { - $time = self::read('Config.time'); + $time = $config['time']; self::write('Config.time', self::$sessionTime); if (isset($sessionConfig['autoRegenerate']) && $sessionConfig['autoRegenerate'] === true) { - $check = self::read('Config.countdown'); + $check = $config['countdown']; $check -= 1; self::write('Config.countdown', $check); diff --git a/cake/libs/model/datasources/datasource.php b/lib/Cake/Model/Datasource/DataSource.php similarity index 100% rename from cake/libs/model/datasources/datasource.php rename to lib/Cake/Model/Datasource/DataSource.php diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/lib/Cake/Model/Datasource/Database/Mssql.php similarity index 99% rename from cake/libs/model/datasources/dbo/dbo_mssql.php rename to lib/Cake/Model/Datasource/Database/Mssql.php index 91db76c5f..b09e58a77 100644 --- a/cake/libs/model/datasources/dbo/dbo_mssql.php +++ b/lib/Cake/Model/Datasource/Database/Mssql.php @@ -116,7 +116,7 @@ class DboMssql extends DboSource { function __construct($config, $autoConnect = true) { if ($autoConnect) { if (!function_exists('mssql_min_message_severity')) { - trigger_error(__("PHP SQL Server interface is not installed, cannot continue. For troubleshooting information, see http://php.net/mssql/"), E_USER_WARNING); + trigger_error(__d('cake_dev', "PHP SQL Server interface is not installed, cannot continue. For troubleshooting information, see http://php.net/mssql/"), E_USER_WARNING); } mssql_min_message_severity(15); mssql_min_error_severity(2); diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php similarity index 99% rename from cake/libs/model/datasources/dbo/dbo_mysql.php rename to lib/Cake/Model/Datasource/Database/Mysql.php index 29c98c4a0..b7b9da0eb 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('DboSource', 'Model/Datasource'); + /** * MySQL DBO driver object * @@ -24,7 +26,7 @@ * * @package cake.libs.model.datasources.dbo */ -class DboMysql extends DboSource { +class Mysql extends DboSource { /** * Datasource description @@ -296,7 +298,7 @@ class DboMysql extends DboSource { $fields = false; $cols = $this->_execute('SHOW FULL COLUMNS FROM ' . $this->fullTableName($model)); if (!$cols) { - throw new CakeException(__('Could not describe table for %s', $model->name)); + throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $model->name)); } foreach ($cols as $column) { diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/lib/Cake/Model/Datasource/Database/Oracle.php similarity index 99% rename from cake/libs/model/datasources/dbo/dbo_oracle.php rename to lib/Cake/Model/Datasource/Database/Oracle.php index 4b4444211..76dfe1e1c 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/lib/Cake/Model/Datasource/Database/Oracle.php @@ -571,7 +571,7 @@ class DboOracle extends DboSource { */ function constraint($action, $table) { if (empty($table)) { - trigger_error(__('Must specify table to operate on constraints')); + trigger_error(__d('cake_dev', 'Must specify table to operate on constraints')); } $table = strtoupper($table); @@ -629,7 +629,7 @@ class DboOracle extends DboSource { return $constraints; break; default: - trigger_error(__('DboOracle::constraint() accepts only enable, disable, or list')); + trigger_error(__d('cake_dev', 'DboOracle::constraint() accepts only enable, disable, or list')); } } return true; @@ -976,7 +976,7 @@ class DboOracle extends DboSource { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { if (!isset($resultSet) || !is_array($resultSet)) { if (Configure::read('debug') > 0) { - echo '
' . __('Query:') . ' %s %s
', $sql, $out)); + pr(sprintf('' . __d('cake_dev', 'Query:') . ' %s %s
', $sql, $out)); } } @@ -1167,7 +1169,7 @@ class DboSource extends DataSource { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { if (!is_array($resultSet)) { if (Configure::read('debug') > 0) { - echo '" . $this->_htmlEntities($message->toString()) . "
- : + : '{$url}'" ); ?>
- 0 ): echo $this->element('exception_stack_trace'); endif; diff --git a/cake/libs/view/errors/error500.ctp b/lib/Cake/View/errors/error500.ctp similarity index 85% rename from cake/libs/view/errors/error500.ctp rename to lib/Cake/View/errors/error500.ctp index f7b648ff6..247f2db78 100644 --- a/cake/libs/view/errors/error500.ctp +++ b/lib/Cake/View/errors/error500.ctp @@ -18,11 +18,11 @@ ?>- : - + : +
- 0 ): echo $this->element('exception_stack_trace'); endif; -?> +?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_action.ctp b/lib/Cake/View/errors/missing_action.ctp new file mode 100644 index 000000000..cac7d2e9b --- /dev/null +++ b/lib/Cake/View/errors/missing_action.ctp @@ -0,0 +1,43 @@ + ++ : + ' . $action . '', '' . $controller . ''); ?> +
++ : + ' . $controller . '::', '' . $action . '()', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?> +
++<?php +class extends AppController { + + + function { + + } + +} +?> ++
+ : + +
+element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_behavior_class.ctp b/lib/Cake/View/errors/missing_behavior_class.ctp similarity index 52% rename from cake/libs/view/errors/missing_behavior_class.ctp rename to lib/Cake/View/errors/missing_behavior_class.ctp index e7c454069..3bc4dcb67 100644 --- a/cake/libs/view/errors/missing_behavior_class.ctp +++ b/lib/Cake/View/errors/missing_behavior_class.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - %s can not be found or does not exist.', $class); ?> + : + %s can not be found or does not exist.', $class); ?>
- : - + : +
<?php @@ -33,8 +33,8 @@ class extends ModelBehavior { ?>
- : - + : +
-element('exception_stack_trace'); ?> +element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_behavior_file.ctp b/lib/Cake/View/errors/missing_behavior_file.ctp similarity index 50% rename from cake/libs/view/errors/missing_behavior_file.ctp rename to lib/Cake/View/errors/missing_behavior_file.ctp index 09e90b350..aa3e314c2 100644 --- a/cake/libs/view/errors/missing_behavior_file.ctp +++ b/lib/Cake/View/errors/missing_behavior_file.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - + : +
- : - + : +
<?php @@ -33,8 +33,8 @@ class extends ModelBehavior { ?>
- : - + : +
-element('exception_stack_trace'); ?> +element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_component_class.ctp b/lib/Cake/View/errors/missing_component_class.ctp similarity index 51% rename from cake/libs/view/errors/missing_component_class.ctp rename to lib/Cake/View/errors/missing_component_class.ctp index cf06671dc..4465edba2 100644 --- a/cake/libs/view/errors/missing_component_class.ctp +++ b/lib/Cake/View/errors/missing_component_class.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - ' . $class . ''); ?> + : + ' . $class . ''); ?>
- : - ' . $class . '', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?> + : + ' . $class . '', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?>
<?php @@ -33,8 +33,8 @@ class extends Component {
?>
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_component_file.ctp b/lib/Cake/View/errors/missing_component_file.ctp similarity index 52% rename from cake/libs/view/errors/missing_component_file.ctp rename to lib/Cake/View/errors/missing_component_file.ctp index 527afc9c3..aeb8c3269 100644 --- a/cake/libs/view/errors/missing_component_file.ctp +++ b/lib/Cake/View/errors/missing_component_file.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - + : +
- : - ' . $class . '', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?> + : + ' . $class . '', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?>
<?php @@ -33,8 +33,8 @@ class extends Component {
?>
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_connection.ctp b/lib/Cake/View/errors/missing_connection.ctp similarity index 51% rename from cake/libs/view/errors/missing_connection.ctp rename to lib/Cake/View/errors/missing_connection.ctp index dfda66e3a..ae4887b8a 100644 --- a/cake/libs/view/errors/missing_connection.ctp +++ b/lib/Cake/View/errors/missing_connection.ctp @@ -16,18 +16,18 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - + : +
- : - + : +
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_controller.ctp b/lib/Cake/View/errors/missing_controller.ctp similarity index 51% rename from cake/libs/view/errors/missing_controller.ctp rename to lib/Cake/View/errors/missing_controller.ctp index 7f9e7d27f..b57193943 100644 --- a/cake/libs/view/errors/missing_controller.ctp +++ b/lib/Cake/View/errors/missing_controller.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - ' . $controller . ''); ?> + : + ' . $controller . ''); ?>
- : - ' . $controller . '', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?> + : + ' . $controller . '', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?>
<?php @@ -33,8 +33,8 @@ class extends AppController { ?>
- : - + : +
-element('exception_stack_trace'); ?> +element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_database.ctp b/lib/Cake/View/errors/missing_database.ctp similarity index 51% rename from cake/libs/view/errors/missing_database.ctp rename to lib/Cake/View/errors/missing_database.ctp index 7aa2d5e80..e7764506f 100644 --- a/cake/libs/view/errors/missing_database.ctp +++ b/lib/Cake/View/errors/missing_database.ctp @@ -16,18 +16,18 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - + : +
- : - + : +
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_datasource_config.ctp b/lib/Cake/View/errors/missing_datasource_config.ctp similarity index 54% rename from cake/libs/view/errors/missing_datasource_config.ctp rename to lib/Cake/View/errors/missing_datasource_config.ctp index 64c7d4c13..de6503a5a 100644 --- a/cake/libs/view/errors/missing_datasource_config.ctp +++ b/lib/Cake/View/errors/missing_datasource_config.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - ' . $config . ''); ?> + : + ' . $config . ''); ?>
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_datasource_file.ctp b/lib/Cake/View/errors/missing_datasource_file.ctp similarity index 56% rename from cake/libs/view/errors/missing_datasource_file.ctp rename to lib/Cake/View/errors/missing_datasource_file.ctp index 0d53072fb..3833504be 100644 --- a/cake/libs/view/errors/missing_datasource_file.ctp +++ b/lib/Cake/View/errors/missing_datasource_file.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - ' . $class . ''); ?> + : + ' . $class . ''); ?>
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_helper_class.ctp b/lib/Cake/View/errors/missing_helper_class.ctp similarity index 52% rename from cake/libs/view/errors/missing_helper_class.ctp rename to lib/Cake/View/errors/missing_helper_class.ctp index 842ded905..9117c87d5 100644 --- a/cake/libs/view/errors/missing_helper_class.ctp +++ b/lib/Cake/View/errors/missing_helper_class.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - %s can not be found or does not exist.', $class); ?> + : + %s can not be found or does not exist.', $class); ?>
- : - + : +
<?php @@ -33,8 +33,8 @@ class extends AppHelper { ?>
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_helper_file.ctp b/lib/Cake/View/errors/missing_helper_file.ctp similarity index 51% rename from cake/libs/view/errors/missing_helper_file.ctp rename to lib/Cake/View/errors/missing_helper_file.ctp index 6ba0e9b6f..94f90f1e2 100644 --- a/cake/libs/view/errors/missing_helper_file.ctp +++ b/lib/Cake/View/errors/missing_helper_file.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - + : +
- : - + : +
<?php @@ -33,8 +33,8 @@ class extends AppHelper { ?>
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_layout.ctp b/lib/Cake/View/errors/missing_layout.ctp similarity index 50% rename from cake/libs/view/errors/missing_layout.ctp rename to lib/Cake/View/errors/missing_layout.ctp index 011e59a64..ed35e35ab 100644 --- a/cake/libs/view/errors/missing_layout.ctp +++ b/lib/Cake/View/errors/missing_layout.ctp @@ -16,18 +16,18 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - ' . $file . ''); ?> + : + ' . $file . ''); ?>
- : - ' . $file . ''); ?> + : + ' . $file . ''); ?>
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/missing_table.ctp b/lib/Cake/View/errors/missing_table.ctp similarity index 55% rename from cake/libs/view/errors/missing_table.ctp rename to lib/Cake/View/errors/missing_table.ctp index 1288dd06a..572579e0c 100644 --- a/cake/libs/view/errors/missing_table.ctp +++ b/lib/Cake/View/errors/missing_table.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - ' . $table . '', '' . $class . ''); ?> + : + ' . $table . '', '' . $class . ''); ?>
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_view.ctp b/lib/Cake/View/errors/missing_view.ctp new file mode 100644 index 000000000..1e9727719 --- /dev/null +++ b/lib/Cake/View/errors/missing_view.ctp @@ -0,0 +1,33 @@ + + ++ : + ' . Inflector::camelize($this->request->controller) . 'Controller::', '' . $this->request->action . '()'); ?> +
++ : + +
++ : + +
+ +element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/private_action.ctp b/lib/Cake/View/errors/private_action.ctp similarity index 55% rename from cake/libs/view/errors/private_action.ctp rename to lib/Cake/View/errors/private_action.ctp index 833f42112..e36a784eb 100644 --- a/cake/libs/view/errors/private_action.ctp +++ b/lib/Cake/View/errors/private_action.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - ' . $controller . '::', '' . $action . '()'); ?> + : + ' . $controller . '::', '' . $action . '()'); ?>
- : - + : +
element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/cake/libs/view/errors/scaffold_error.ctp b/lib/Cake/View/errors/scaffold_error.ctp similarity index 60% rename from cake/libs/view/errors/scaffold_error.ctp rename to lib/Cake/View/errors/scaffold_error.ctp index 40f09c90a..2df21dcc1 100644 --- a/cake/libs/view/errors/scaffold_error.ctp +++ b/lib/Cake/View/errors/scaffold_error.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> - +- : - + : +
- : - + : +
<?php diff --git a/cake/libs/view/layouts/ajax.ctp b/lib/Cake/View/layouts/ajax.ctp similarity index 100% rename from cake/libs/view/layouts/ajax.ctp rename to lib/Cake/View/layouts/ajax.ctp diff --git a/cake/libs/view/layouts/default.ctp b/lib/Cake/View/layouts/default.ctp similarity index 81% rename from cake/libs/view/layouts/default.ctp rename to lib/Cake/View/layouts/default.ctp index 5575c7329..944b2f48c 100644 --- a/cake/libs/view/layouts/default.ctp +++ b/lib/Cake/View/layouts/default.ctp @@ -15,13 +15,15 @@ * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +$cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework'); ?> Html->charset(); ?>- + : -Html->link(__('CakePHP: the rapid development php framework'), 'http://cakephp.org'); ?>
+Html->link($cakeDescription, 'http://cakephp.org'); ?>
@@ -46,7 +48,7 @@- +request->action != 'add'): ?>
- Form->postLink( - __('Delete'), + __d('cake', 'Delete'), array('action' => 'delete', $this->Form->value($modelClass . '.' . $primaryKey)), null, - __('Are you sure you want to delete # %s?', $this->Form->value($modelClass . '.' . $primaryKey))); + __d('cake', 'Are you sure you want to delete # %s?', $this->Form->value($modelClass . '.' . $primaryKey))); ?>
-- Html->link(__('List') . ' ' . $pluralHumanName, array('action' => 'index'));?>
+- Html->link(__d('cake', 'List') . ' ' . $pluralHumanName, array('action' => 'index'));?>
$_data) { foreach ($_data as $_alias => $_details) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { - echo "\t\t- " . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "
\n"; - echo "\t\t- " . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "
\n"; + echo "\t\t- " . $this->Html->link(__d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "
\n"; + echo "\t\t- " . $this->Html->link(__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "
\n"; $done[] = $_details['controller']; } } diff --git a/cake/libs/view/scaffolds/index.ctp b/lib/Cake/View/scaffolds/index.ctp similarity index 63% rename from cake/libs/view/scaffolds/index.ctp rename to lib/Cake/View/scaffolds/index.ctp index c3da1d4d8..d0def968e 100644 --- a/cake/libs/view/scaffolds/index.ctp +++ b/lib/Cake/View/scaffolds/index.ctp @@ -23,7 +23,7 @@Paginator->sort($_field);?> -+ '; - echo $this->Html->link(__('View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])); - echo $this->Html->link(__('Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])); + echo $this->Html->link(__d('cake', 'View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])); + echo $this->Html->link(__d('cake', 'Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])); echo $this->Form->postLink( - __('Delete'), + __d('cake', 'Delete'), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, - __('Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] + __d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] ); echo ''; echo ''; @@ -67,26 +67,26 @@ endforeach; Paginator->counter(array( - 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%') + 'format' => __d('cake', 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%') )); ?>
- Paginator->prev('<< ' . __('previous'), array(), null, array('class' => 'disabled')); ?> + Paginator->prev('<< ' . __d('cake', 'previous'), array(), null, array('class' => 'disabled')); ?> | Paginator->numbers(); ?> - Paginator->next(__('next') .' >>', array(), null, array('class' => 'disabled')); ?> + Paginator->next(__d('cake', 'next') .' >>', array(), null, array('class' => 'disabled')); ?>- +-
- Html->link(__('New %s', $singularHumanName), array('action' => 'add')); ?>
+- Html->link(__d('cake', 'New %s', $singularHumanName), array('action' => 'add')); ?>
$_data) { foreach ($_data as $_alias => $_details) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { - echo "- " . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
"; - echo "- " . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
"; + echo "- " . $this->Html->link(__d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
"; + echo "- " . $this->Html->link(__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
"; $done[] = $_details['controller']; } } diff --git a/cake/libs/view/scaffolds/view.ctp b/lib/Cake/View/scaffolds/view.ctp similarity index 60% rename from cake/libs/view/scaffolds/view.ctp rename to lib/Cake/View/scaffolds/view.ctp index 010450a15..ef2fe7006 100644 --- a/cake/libs/view/scaffolds/view.ctp +++ b/lib/Cake/View/scaffolds/view.ctp @@ -17,7 +17,7 @@ */ ?>- +
- +" .$this->Html->link(__('Edit %s', $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " \n"; - echo "\t\t
- " .$this->Html->link(__('Delete %s', $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). "
\n"; - echo "\t\t- " .$this->Html->link(__('List %s', $pluralHumanName), array('action' => 'index')). "
\n"; - echo "\t\t- " .$this->Html->link(__('New %s', $singularHumanName), array('action' => 'add')). "
\n"; + echo "\t\t- " .$this->Html->link(__d('cake', 'Edit %s', $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). "
\n"; + echo "\t\t- " .$this->Html->link(__d('cake', 'Delete %s', $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). "
\n"; + echo "\t\t- " .$this->Html->link(__d('cake', 'List %s', $pluralHumanName), array('action' => 'index')). "
\n"; + echo "\t\t- " .$this->Html->link(__d('cake', 'New %s', $singularHumanName), array('action' => 'add')). "
\n"; $done = array(); foreach ($associations as $_type => $_data) { foreach ($_data as $_alias => $_details) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { - echo "\t\t- " . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
\n"; - echo "\t\t- " . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
\n"; + echo "\t\t- " . $this->Html->link(__d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
\n"; + echo "\t\t- " . $this->Html->link(__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
\n"; $done[] = $_details['controller']; } } @@ -71,7 +71,7 @@ foreach ($scaffoldFields as $_field) { if (!empty($associations['hasOne'])) : foreach ($associations['hasOne'] as $_alias => $_details): ?> @@ -110,7 +110,7 @@ foreach ($relations as $_alias => $_details): $otherSingularVar = Inflector::variable($_alias); ?>