Merge branch '2.0-class-loading' into 2.0

This commit is contained in:
Jose Lorenzo Rodriguez 2011-04-11 23:32:38 -04:30
commit a07094fd69
855 changed files with 5667 additions and 5697 deletions

2
app/console/cake.php → app/Console/cake.php Executable file → Normal file
View file

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

View file

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

0
app/tmp/cache/models/empty vendored Executable file → Normal file
View file

0
app/tmp/cache/views/empty vendored Executable file → Normal file
View file

0
app/tmp/logs/empty Executable file → Normal file
View file

0
app/tmp/sessions/empty Executable file → Normal file
View file

0
app/tmp/tests/empty Executable file → Normal file
View file

View file

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

View file

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

View file

@ -1,39 +0,0 @@
<?php
/**
* Basic Cake functionality.
*
* Handles loading of core files needed on every request
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 8192);
}
error_reporting(E_ALL & ~E_DEPRECATED);
require CORE_PATH . 'cake' . DS . 'basics.php';
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
require LIBS . 'error' . DS . 'exceptions.php';
require LIBS . 'object.php';
require LIBS . 'object_collection.php';
require LIBS . 'inflector.php';
require LIBS . 'app.php';
require LIBS . 'configure.php';
require LIBS . 'set.php';
require LIBS . 'cache.php';
require LIBS . 'error' . DS . 'error_handler.php';
Configure::bootstrap(isset($boot) ? $boot : true);

View file

@ -1,908 +0,0 @@
<?php
/**
* App class
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs
* @since CakePHP(tm) v 1.2.0.6001
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* App is responsible for path managment, class location and class loading.
*
* ### Adding paths
*
* You can add paths to the search indexes App uses to find classes using `App::build()`. Adding
* additional controller paths for example would alter where CakePHP looks for controllers when you
* call App::import('Controller', 'Posts'); This allows you to split your application up across the filesystem.
*
* ### Inspecting loaded paths
*
* You can inspect the currently loaded paths using `App::path('controller')` for example to see loaded
* controller paths.
*
* ### Locating plugins and themes
*
* Plugins and Themes can be located with App as well. Using App::pluginPath('DebugKit') for example, will
* give you the full path to the DebugKit plugin. App::themePath('purple'), would give the full path to the
* `purple` theme.
*
* ### Inspecting known objects
*
* You can find out which objects App knows about using App::objects('controller') for example to find
* which application controllers App knows about.
*
* @link http://book.cakephp.org/view/933/The-App-Class
* @package cake.libs
*/
class App {
/**
* List of object types and their properties
*
* @var array
*/
public static $types = array(
'class' => 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_');
}
}
}

View file

@ -1,291 +0,0 @@
<?php
/**
* MagicDb parser and file analyzer
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs
* @since CakePHP(tm) v 1.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
if (!class_exists('Object')) {
require LIBS . 'object.php';
}
if (!class_exists('File')) {
require LIBS . 'file.php';
}
/**
* A class to parse and use the MagicDb for file type analysis
*
* @package cake.libs
*/
class MagicDb extends Object {
/**
* Holds the parsed MagicDb for this class instance
*
* @var array
*/
public $db = array();
/**
* Reads a MagicDb from various formats
*
* @public $magicDb mixed Can be an array containing the db, a magic db as a string, or a filename pointing to a magic db in .db or magic.db.php format
* @return boolean Returns false if reading / validation failed or true on success.
* @author Felix
*/
function read($magicDb = null) {
if (!is_string($magicDb) && !is_array($magicDb)) {
return false;
}
if (is_array($magicDb) || strpos($magicDb, '# FILE_ID DB') === 0) {
$data = $magicDb;
} else {
$File = new File($magicDb);
if (!$File->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;
}
}
}

View file

@ -1,44 +0,0 @@
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs.view.templates.errors
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h2><?php echo __('Missing Method in %s', $controller); ?></h2>
<p class="error">
<strong><?php echo __('Error'); ?>: </strong>
<?php echo __('The action %1$s is not defined in controller %2$s', '<em>' . $action . '</em>', '<em>' . $controller . '</em>'); ?>
</p>
<p class="error">
<strong><?php echo __('Error'); ?>: </strong>
<?php echo __('Create %1$s%2$s in file: %3$s.', '<em>' . $controller . '::</em>', '<em>' . $action . '()</em>', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?>
</p>
<pre>
&lt;?php
class <?php echo $controller;?> extends AppController {
<strong>
function <?php echo $action;?> {
}
</strong>
}
?&gt;
</pre>
<p class="notice">
<strong><?php echo __('Notice'); ?>: </strong>
<?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_action.ctp'); ?>
</p>
<?php echo $this->element('exception_stack_trace'); ?>

View file

@ -1,33 +0,0 @@
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs.view.templates.errors
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<h2><?php echo __('Missing View'); ?></h2>
<p class="error">
<strong><?php echo __('Error'); ?>: </strong>
<?php echo __('The view for %1$s%2$s was not found.', '<em>' . Inflector::camelize($this->request->controller) . 'Controller::</em>', '<em>' . $this->request->action . '()</em>'); ?>
</p>
<p class="error">
<strong><?php echo __('Error'); ?>: </strong>
<?php echo __('Confirm you have created the file: %s', $file); ?>
</p>
<p class="notice">
<strong><?php echo __('Notice'); ?>: </strong>
<?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_view.ctp'); ?>
</p>
<?php echo $this->element('exception_stack_trace'); ?>

View file

@ -1,174 +0,0 @@
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs.view.templates.pages
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
if (Configure::read() == 0):
throw new NotFoundException();
endif;
App::import('Core', 'Debugger');
?>
<h2><?php echo __('Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<a href="http://cakephp.org/changelogs/1.3.6"><?php __('Read the changelog'); ?> </a>
<?php
if (Configure::read() > 0):
Debugger::checkSecurityKeys();
endif;
?>
<p>
<?php
if (is_writable(TMP)):
echo '<span class="notice success">';
echo __('Your tmp directory is writable.');
echo '</span>';
else:
echo '<span class="notice">';
echo __('Your tmp directory is NOT writable.');
echo '</span>';
endif;
?>
</p>
<p>
<?php
$settings = Cache::settings();
if (!empty($settings)):
echo '<span class="notice success">';
echo __('The %s is being used for caching. To change the config edit APP/config/core.php ', '<em>'. $settings['engine'] . 'Engine</em>');
echo '</span>';
else:
echo '<span class="notice">';
echo __('Your cache is NOT working. Please check the settings in APP/config/core.php');
echo '</span>';
endif;
?>
</p>
<p>
<?php
$filePresent = null;
if (file_exists(CONFIGS.'database.php')):
echo '<span class="notice success">';
echo __('Your database configuration file is present.');
$filePresent = true;
echo '</span>';
else:
echo '<span class="notice">';
echo __('Your database configuration file is NOT present.');
echo '<br/>';
echo __('Rename config/database.php.default to config/database.php');
echo '</span>';
endif;
?>
</p>
<?php
App::import('Core', 'Validation');
if (!Validation::alphaNumeric('cakephp')) {
echo '<p><span class="notice">';
__('PCRE has not been compiled with Unicode support.');
echo '<br/>';
__('Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
echo '</span></p>';
}
?>
<?php
if (isset($filePresent)):
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
$db = ConnectionManager::getInstance();
try {
$connected = $db->getDataSource('default');
} catch (Exception $e) {
$connected = false;
}
?>
<p>
<?php
if ($connected && $connected->isConnected()):
echo '<span class="notice success">';
echo __('Cake is able to connect to the database.');
echo '</span>';
else:
echo '<span class="notice">';
echo __('Cake is NOT able to connect to the database.');
echo '</span>';
endif;
?>
</p>
<?php endif;?>
<h3><?php echo __('Editing this Page'); ?></h3>
<p>
<?php
echo __('To change the content of this page, create: APP/views/pages/home.ctp.<br />
To change its layout, create: APP/views/layouts/default.ctp.<br />
You can also add some CSS styles for your pages at: APP/webroot/css.');
?>
</p>
<h3><?php echo __('Getting Started'); ?></h3>
<p>
<?php
echo $this->Html->link(
sprintf('<strong>%s</strong> %s', __('New'), __('CakePHP 1.3 Docs')),
'http://book.cakephp.org/view/875/x1-3-Collection',
array('target' => '_blank', 'escape' => false)
);
?>
</p>
<p>
<?php
echo $this->Html->link(
__('The 15 min Blog Tutorial'),
'http://book.cakephp.org/view/1528/Blog',
array('target' => '_blank', 'escape' => false)
);
?>
</p>
<h3><?php echo __('More about Cake'); ?></h3>
<p>
<?php echo __('CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?>
</p>
<p>
<?php echo __('Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.'); ?>
</p>
<ul>
<li><a href="http://cakefoundation.org/"><?php echo __('Cake Software Foundation'); ?> </a>
<ul><li><?php echo __('Promoting development related to CakePHP'); ?></li></ul></li>
<li><a href="http://www.cakephp.org"><?php echo __('CakePHP'); ?> </a>
<ul><li><?php echo __('The Rapid Development Framework'); ?></li></ul></li>
<li><a href="http://book.cakephp.org"><?php echo __('CakePHP Documentation'); ?> </a>
<ul><li><?php echo __('Your Rapid Development Cookbook'); ?></li></ul></li>
<li><a href="http://api.cakephp.org"><?php echo __('CakePHP API'); ?> </a>
<ul><li><?php echo __('Quick Reference'); ?></li></ul></li>
<li><a href="http://bakery.cakephp.org"><?php echo __('The Bakery'); ?> </a>
<ul><li><?php echo __('Everything CakePHP'); ?></li></ul></li>
<li><a href="http://live.cakephp.org"><?php echo __('The Show'); ?> </a>
<ul><li><?php echo __('The Show is a live and archived internet radio broadcast CakePHP-related topics and answer questions live via IRC, Skype, and telephone.'); ?></li></ul></li>
<li><a href="http://groups.google.com/group/cake-php"><?php echo __('CakePHP Google Group'); ?> </a>
<ul><li><?php echo __('Community mailing list'); ?></li></ul></li>
<li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a>
<ul><li><?php echo __('Live chat about CakePHP'); ?></li></ul></li>
<li><a href="http://github.com/cakephp/"><?php echo __('CakePHP Code'); ?> </a>
<ul><li><?php echo __('For the Development of CakePHP Git repository, Downloads'); ?></li></ul></li>
<li><a href="http://cakephp.lighthouseapp.com/"><?php echo __('CakePHP Lighthouse'); ?> </a>
<ul><li><?php echo __('CakePHP Tickets, Wiki pages, Roadmap'); ?></li></ul></li>
<li><a href="http://www.cakeforge.org"><?php echo __('CakeForge'); ?> </a>
<ul><li><?php echo __('Open Development for CakePHP'); ?></li></ul></li>
<li><a href="http://astore.amazon.com/cakesoftwaref-20/"><?php echo __('Book Store'); ?> </a>
<ul><li><?php echo __('Recommended Software Books'); ?></li></ul></li>
<li><a href="http://www.cafepress.com/cakefoundation"><?php echo __('CakePHP gear'); ?> </a>
<ul><li><?php echo __('Get your own CakePHP gear - Doughnate to Cake'); ?></li></ul></li>
</ul>

View file

@ -1,53 +0,0 @@
<?php
/**
* AllLibsTest file
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.tests.cases
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* AllLibsTest class
*
* This test group will run all non mvc related lib class tests
*
* @package cake.tests.cases
*/
class AllLibsTest extends PHPUnit_Framework_TestSuite {
/**
* suite method, defines tests for this suite.
*
* @return void
*/
public static function suite() {
$suite = new PHPUnit_Framework_TestSuite('All non-MVC lib class tests');
$suite->addTestFile(CORE_TEST_CASES . DS . 'basics.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_session.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'debugger.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'file.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'folder.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'inflector.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'log' . DS . 'file_log.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_log.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'class_registry.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'sanitize.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'set.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'string.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'validation.test.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'object_collection.test.php');
return $suite;
}
}

View file

@ -1,61 +0,0 @@
<?php
/**
* AllTests file
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.tests.cases
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* AllTests class
*
* This test group will run all test in the cases/libs/models/behaviors directory
*
* @package cake.tests.groups
*/
class AllTests extends PHPUnit_Framework_TestSuite {
/**
* Suite define the tests for this suite
*
* @return void
*/
public static function suite() {
$suite = new PHPUnit_Framework_TestSuite('All Tests');
$path = CORE_TEST_CASES . DS . 'libs' . DS;
$console = CORE_TEST_CASES . DS . 'console' . DS;
$suite->addTestFile($console . 'all_console_libs.test.php');
$suite->addTestFile($console . 'all_shells.test.php');
$suite->addTestFile($console . 'all_tasks.test.php');
$suite->addTestFile($path . 'all_behaviors.test.php');
$suite->addTestFile($path . 'all_cache_engines.test.php');
$suite->addTestFile($path . 'all_components.test.php');
$suite->addTestFile($path . 'all_configure.test.php');
$suite->addTestFile($path . 'all_controllers.test.php');
$suite->addTestFile($path . 'all_database.test.php');
$suite->addTestFile($path . 'all_error.test.php');
$suite->addTestFile($path . 'all_helpers.test.php');
$suite->addTestFile($path . 'all_libs.test.php');
$suite->addTestFile($path . 'all_localization.test.php');
$suite->addTestFile($path . 'all_model.test.php');
$suite->addTestFile($path . 'all_routing.test.php');
$suite->addTestFile($path . 'all_socket.test.php');
$suite->addTestFile($path . 'all_test_suite.test.php');;
$suite->addTestFile($path . 'all_views.test.php');
$suite->addTestFile($path . 'all_xml.test.php');
return $suite;
}
}

View file

@ -1,568 +0,0 @@
<?php
/**
* AppImportTest class
*
* @package cake.tests.cases.libs
*/
class AppImportTest extends CakeTestCase {
/**
* testBuild method
*
* @access public
* @return void
*/
function testBuild() {
$old = App::path('models');
$expected = array(
APP . 'models' . DS,
APP,
LIBS . 'model' . DS
);
$this->assertEqual($expected, $old);
App::build(array('models' => array('/path/to/models/')));
$new = App::path('models');
$expected = array(
'/path/to/models/',
APP . 'models' . DS,
APP,
LIBS . 'model' . DS
);
$this->assertEqual($expected, $new);
App::build(); //reset defaults
$defaults = App::path('models');
$this->assertEqual($old, $defaults);
}
/**
* testBuildWithReset method
*
* @access public
* @return void
*/
function testBuildWithReset() {
$old = App::path('models');
$expected = array(
APP . 'models' . DS,
APP,
LIBS . 'model' . DS
);
$this->assertEqual($expected, $old);
App::build(array('models' => array('/path/to/models/')), true);
$new = App::path('models');
$expected = array(
'/path/to/models/'
);
$this->assertEqual($expected, $new);
App::build(); //reset defaults
$defaults = App::path('models');
$this->assertEqual($old, $defaults);
}
/**
* testCore method
*
* @access public
* @return void
*/
function testCore() {
$model = App::core('models');
$this->assertEqual(array(LIBS . 'model' . DS), $model);
$view = App::core('views');
$this->assertEqual(array(LIBS . 'view' . DS), $view);
$controller = App::core('controllers');
$this->assertEqual(array(LIBS . 'controller' . DS), $controller);
}
/**
* testListObjects method
*
* @access public
* @return void
*/
function testListObjects() {
$result = App::objects('class', TEST_CAKE_CORE_INCLUDE_PATH . 'libs', false);
$this->assertTrue(in_array('Xml', $result));
$this->assertTrue(in_array('Cache', $result));
$this->assertTrue(in_array('HttpSocket', $result));
$result = App::objects('behavior', null, false);
$this->assertTrue(in_array('Tree', $result));
$result = App::objects('controller', null, false);
$this->assertTrue(in_array('Pages', $result));
$result = App::objects('component', null, false);
$this->assertTrue(in_array('Auth', $result));
$result = App::objects('view', null, false);
$this->assertTrue(in_array('Media', $result));
$result = App::objects('helper', null, false);
$this->assertTrue(in_array('Html', $result));
$result = App::objects('model', null, false);
$notExpected = array('AppModel', 'ModelBehavior', 'ConnectionManager', 'DbAcl', 'Model', 'CakeSchema');
foreach ($notExpected as $class) {
$this->assertFalse(in_array($class, $result));
}
$result = App::objects('file');
$this->assertFalse($result);
$result = App::objects('file', 'non_existing_configure');
$expected = array();
$this->assertEqual($result, $expected);
$result = App::objects('NonExistingType');
$this->assertFalse($result);
App::build(array(
'plugins' => array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS
)
));
$result = App::objects('plugin', null, false);
$this->assertTrue(in_array('Cache', $result));
$this->assertTrue(in_array('Log', $result));
App::build();
}
/**
* Tests listing objects within a plugin
*
* @return void
*/
function testListObjectsInPlugin() {
App::build(array(
'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$oldCache = App::$models;
$result = App::objects('TestPlugin.model');
$this->assertTrue(in_array('TestPluginPost', $result));
$this->assertEquals($oldCache, App::$models);
$result = App::objects('TestPlugin.behavior');
$this->assertTrue(in_array('TestPluginPersisterOne', $result));
$result = App::objects('TestPlugin.helper');
$expected = array('OtherHelper', 'PluggedHelper', 'TestPluginApp');
$this->assertEquals($result, $expected);
$result = App::objects('TestPlugin.component');
$this->assertTrue(in_array('OtherComponent', $result));
$result = App::objects('TestPluginTwo.behavior');
$this->assertEquals($result, array());
$result = App::objects('model', null, false);
$this->assertTrue(in_array('Comment', $result));
$this->assertTrue(in_array('Post', $result));
App::build();
}
/**
* test that pluginPath can find paths for plugins.
*
* @return void
*/
function testPluginPath() {
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$path = App::pluginPath('test_plugin');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
$this->assertEqual($path, $expected);
$path = App::pluginPath('TestPlugin');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
$this->assertEqual($path, $expected);
$path = App::pluginPath('TestPluginTwo');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS;
$this->assertEqual($path, $expected);
App::build();
}
/**
* test that pluginPath can find paths for plugins.
*
* @return void
*/
function testThemePath() {
App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)
));
$path = App::themePath('test_theme');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;
$this->assertEqual($path, $expected);
$path = App::themePath('TestTheme');
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;
$this->assertEqual($path, $expected);
App::build();
}
/**
* testClassLoading method
*
* @access public
* @return void
*/
function testClassLoading() {
$file = App::import();
$this->assertTrue($file);
$file = App::import('Model', 'Model', false);
$this->assertTrue($file);
$this->assertTrue(class_exists('Model'));
$file = App::import('Controller', 'Controller', false);
$this->assertTrue($file);
$this->assertTrue(class_exists('Controller'));
$file = App::import('Component', 'Component', false);
$this->assertTrue($file);
$this->assertTrue(class_exists('Component'));
$file = App::import('Shell', 'Shell', false);
$this->assertTrue($file);
$this->assertTrue(class_exists('Shell'));
$file = App::import('Lib', 'config/PhpReader');
$this->assertTrue($file);
$this->assertTrue(class_exists('PhpReader'));
$file = App::import('Model', 'SomeRandomModelThatDoesNotExist', false);
$this->assertFalse($file);
$file = App::import('Model', 'AppModel', false);
$this->assertTrue($file);
$this->assertTrue(class_exists('AppModel'));
$file = App::import('WrongType', null, true, array(), '');
$this->assertTrue($file);
$file = App::import('Model', 'NonExistingPlugin.NonExistingModel', false);
$this->assertFalse($file);
$file = App::import('Core', 'NonExistingPlugin.NonExistingModel', false);
$this->assertFalse($file);
$file = App::import('Model', array('NonExistingPlugin.NonExistingModel'), false);
$this->assertFalse($file);
$file = App::import('Core', array('NonExistingPlugin.NonExistingModel'), false);
$this->assertFalse($file);
$file = App::import('Core', array('NonExistingPlugin.NonExistingModel.AnotherChild'), false);
$this->assertFalse($file);
if (!class_exists('AppController')) {
$classes = array_flip(get_declared_classes());
$this->assertFalse(isset($classes['PagesController']));
$this->assertFalse(isset($classes['AppController']));
$file = App::import('Controller', 'Pages');
$this->assertTrue($file);
$this->assertTrue(class_exists('PagesController'));
$classes = array_flip(get_declared_classes());
$this->assertTrue(isset($classes['PagesController']));
$this->assertTrue(isset($classes['AppController']));
$file = App::import('Behavior', 'Containable');
$this->assertTrue($file);
$this->assertTrue(class_exists('ContainableBehavior'));
$file = App::import('Component', 'RequestHandler');
$this->assertTrue($file);
$this->assertTrue(class_exists('RequestHandlerComponent'));
$file = App::import('Helper', 'Form');
$this->assertTrue($file);
$this->assertTrue(class_exists('FormHelper'));
$file = App::import('Model', 'NonExistingModel');
$this->assertFalse($file);
$file = App::import('Datasource', 'DboSource');
$this->assertTrue($file);
$this->assertTrue(class_exists('DboSource'));
}
App::build();
}
/**
* test import() with plugins
*
* @return void
*/
function testPluginImporting() {
App::build(array(
'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$result = App::import('Controller', 'TestPlugin.Tests');
$this->assertTrue($result);
$this->assertTrue(class_exists('TestPluginAppController'));
$this->assertTrue(class_exists('TestsController'));
$result = App::import('Lib', 'TestPlugin.TestPluginLibrary');
$this->assertTrue($result);
$this->assertTrue(class_exists('TestPluginLibrary'));
$result = App::import('Lib', 'Library');
$this->assertTrue($result);
$this->assertTrue(class_exists('Library'));
$result = App::import('Helper', 'TestPlugin.OtherHelper');
$this->assertTrue($result);
$this->assertTrue(class_exists('OtherHelperHelper'));
$result = App::import('Helper', 'TestPlugin.TestPluginApp');
$this->assertTrue($result);
$this->assertTrue(class_exists('TestPluginAppHelper'));
$result = App::import('Datasource', 'TestPlugin.TestSource');
$this->assertTrue($result);
$this->assertTrue(class_exists('TestSource'));
App::build();
}
/**
* test that building helper paths actually works.
*
* @return void
* @link http://cakephp.lighthouseapp.com/projects/42648/tickets/410
*/
function testImportingHelpersFromAlternatePaths() {
App::build();
$this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.');
App::import('Helper', 'Banana');
$this->assertFalse(class_exists('BananaHelper'), 'BananaHelper was not found because the path does not exist.');
App::build(array(
'helpers' => array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS
)
));
App::build(array('vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH)));
$this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.');
App::import('Helper', 'Banana');
$this->assertTrue(class_exists('BananaHelper'), 'BananaHelper was not loaded.');
App::build();
}
/**
* testFileLoading method
*
* @access public
* @return void
*/
function testFileLoading () {
$file = App::import('File', 'RealFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php');
$this->assertTrue($file);
$file = App::import('File', 'NoFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'cake' . DS . 'config.php');
$this->assertFalse($file);
}
/**
* testFileLoadingWithArray method
*
* @access public
* @return void
*/
function testFileLoadingWithArray() {
$type = array('type' => 'File', 'name' => 'SomeName', 'parent' => false,
'file' => TEST_CAKE_CORE_INCLUDE_PATH . DS . 'config' . DS . 'config.php');
$file = App::import($type);
$this->assertTrue($file);
$type = array('type' => 'File', 'name' => 'NoFile', 'parent' => false,
'file' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'cake' . DS . 'config.php');
$file = App::import($type);
$this->assertFalse($file);
}
/**
* testFileLoadingReturnValue method
*
* @access public
* @return void
*/
function testFileLoadingReturnValue () {
$file = App::import('File', 'Name', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', true);
$this->assertTrue(!empty($file));
$this->assertTrue(isset($file['Cake.version']));
$type = array('type' => 'File', 'name' => 'OtherName', 'parent' => false,
'file' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', 'return' => true);
$file = App::import($type);
$this->assertTrue(!empty($file));
$this->assertTrue(isset($file['Cake.version']));
}
/**
* testLoadingWithSearch method
*
* @access public
* @return void
*/
function testLoadingWithSearch () {
$file = App::import('File', 'NewName', false, array(TEST_CAKE_CORE_INCLUDE_PATH ), 'config.php');
$this->assertTrue($file);
$file = App::import('File', 'AnotherNewName', false, array(LIBS), 'config.php');
$this->assertFalse($file);
}
/**
* testLoadingWithSearchArray method
*
* @access public
* @return void
*/
function testLoadingWithSearchArray () {
$type = array('type' => 'File', 'name' => 'RandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(TEST_CAKE_CORE_INCLUDE_PATH ));
$file = App::import($type);
$this->assertTrue($file);
$type = array('type' => 'File', 'name' => 'AnotherRandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(LIBS));
$file = App::import($type);
$this->assertFalse($file);
}
/**
* testMultipleLoading method
*
* @access public
* @return void
*/
function testMultipleLoading() {
if (class_exists('I18n', false) || class_exists('CakeSocket', false)) {
$this->markTestSkipped('Cannot test loading of classes that exist.');
}
$toLoad = array('I18n', 'CakeSocket');
$classes = array_flip(get_declared_classes());
$this->assertFalse(isset($classes['i18n']));
$this->assertFalse(isset($classes['CakeSocket']));
$load = App::import($toLoad);
$this->assertTrue($load);
$classes = array_flip(get_declared_classes());
$this->assertTrue(isset($classes['I18n']));
$load = App::import(array('I18n', 'SomeNotFoundClass', 'CakeSocket'));
$this->assertFalse($load);
$load = App::import($toLoad);
$this->assertTrue($load);
}
/**
* This test only works if you have plugins/my_plugin set up.
* plugins/my_plugin/models/my_plugin.php and other_model.php
*/
/*
function testMultipleLoadingByType() {
$classes = array_flip(get_declared_classes());
$this->assertFalse(isset($classes['OtherPlugin']));
$this->assertFalse(isset($classes['MyPlugin']));
$load = App::import('Model', array('MyPlugin.OtherPlugin', 'MyPlugin.MyPlugin'));
$this->assertTrue($load);
$classes = array_flip(get_declared_classes());
$this->assertTrue(isset($classes['OtherPlugin']));
$this->assertTrue(isset($classes['MyPlugin']));
}
*/
function testLoadingVendor() {
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
), true);
ob_start();
$result = App::import('Vendor', 'TestPlugin.TestPluginAsset', array('ext' => 'css'));
$text = ob_get_clean();
$this->assertTrue($result);
$this->assertEqual($text, 'this is the test plugin asset css file');
ob_start();
$result = App::import('Vendor', 'TestAsset', array('ext' => 'css'));
$text = ob_get_clean();
$this->assertTrue($result);
$this->assertEqual($text, 'this is the test asset css file');
$result = App::import('Vendor', 'TestPlugin.SamplePlugin');
$this->assertTrue($result);
$this->assertTrue(class_exists('SamplePluginClassTestName'));
$result = App::import('Vendor', 'ConfigureTestVendorSample');
$this->assertTrue($result);
$this->assertTrue(class_exists('ConfigureTestVendorSample'));
ob_start();
$result = App::import('Vendor', 'SomeName', array('file' => 'some.name.php'));
$text = ob_get_clean();
$this->assertTrue($result);
$this->assertEqual($text, 'This is a file with dot in file name');
ob_start();
$result = App::import('Vendor', 'TestHello', array('file' => 'Test'.DS.'hello.php'));
$text = ob_get_clean();
$this->assertTrue($result);
$this->assertEqual($text, 'This is the hello.php file in Test directory');
ob_start();
$result = App::import('Vendor', 'MyTest', array('file' => 'Test'.DS.'MyTest.php'));
$text = ob_get_clean();
$this->assertTrue($result);
$this->assertEqual($text, 'This is the MyTest.php file');
ob_start();
$result = App::import('Vendor', 'Welcome');
$text = ob_get_clean();
$this->assertTrue($result);
$this->assertEqual($text, 'This is the welcome.php file in vendors directory');
ob_start();
$result = App::import('Vendor', 'TestPlugin.Welcome');
$text = ob_get_clean();
$this->assertTrue($result);
$this->assertEqual($text, 'This is the welcome.php file in test_plugin/vendors directory');
}
}

File diff suppressed because one or more lines are too long

View file

@ -1,5 +0,0 @@
<?php
class TestLocalDriver extends TestSource {
}

View file

@ -1,74 +0,0 @@
<h2>Sweet, "Test App" got Baked by CakePHP!</h2>
<p>
<?php
if (is_writable(TMP)):
echo '<span class="notice success">';
echo __('Your tmp directory is writable.');
echo '</span>';
else:
echo '<span class="notice">';
echo __('Your tmp directory is NOT writable.');
echo '</span>';
endif;
?>
</p>
<p>
<?php
$settings = array();
if (!empty($settings)):
echo '<span class="notice success">';
echo __('The %s is being used for caching. To change the config edit APP/config/core.php ', '<em>'. $settings['engine'] . 'Engine</em>');
echo '</span>';
else:
echo '<span class="notice">';
echo __('Your cache is NOT working. Please check the settings in APP/config/core.php');
echo '</span>';
endif;
?>
</p>
<p>
<?php
$filePresent = null;
if (file_exists(CONFIGS . 'database.php')):
echo '<span class="notice success">';
echo __('Your database configuration file is present.');
$filePresent = true;
echo '</span>';
else:
echo '<span class="notice">';
echo __('Your database configuration file is NOT present.');
echo '<br/>';
echo __('Rename config/database.php.default to config/database.php');
echo '</span>';
endif;
?>
</p>
<?php
if (!empty($filePresent)):
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
?>
<p>
<?php
if (true):
echo '<span class="notice success">';
echo __('Cake is able to connect to the database.');
echo '</span>';
else:
echo '<span class="notice">';
echo __('Cake is NOT able to connect to the database.');
echo '</span>';
endif;
?>
</p>
<?php endif;?>
<h3><?php echo __('Editing this Page') ?></h3>
<p>
<?php
echo __('To change the content of this page, edit: %s
To change its layout, edit: %s
You can also add some CSS styles for your pages at: %s',
APP . 'views' . DS . 'pages' . DS . 'home.ctp.<br />', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.<br />', APP . 'webroot' . DS . 'css');
?>
</p>

View file

@ -1,143 +0,0 @@
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs.view.templates.pages
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<p>
<!--nocache-->
<span class="notice">
<?php
echo __('Your tmp directory is ');
if (is_writable(TMP)):
echo __('writable.');
else:
echo __('NOT writable.');
endif;
?>
</span>
<!--/nocache-->
</p>
<p>
<span class="notice">
<?php
echo __('Your cache is ');
if (Cache::isInitialized('default')):
echo __('set up and initialized properly.');
$settings = Cache::settings();
echo '<p>' . $settings['engine'];
echo __(' is being used to cache, to change this edit config/core.php ');
echo '</p>';
echo 'Settings: <ul>';
foreach ($settings as $name => $value):
echo '<li>' . $name . ': ' . $value . '</li>';
endforeach;
echo '</ul>';
else:
echo __('NOT working.');
echo '<br />';
if (is_writable(TMP)):
echo __('Edit: config/core.php to insure you have the newset version of this file and the variable $cakeCache set properly');
endif;
endif;
?>
</span>
</p>
<p>
<span class="notice">
<?php
echo __('Your database configuration file is ');
$filePresent = null;
if (file_exists(CONFIGS.'database.php')):
echo __('present.');
$filePresent = true;
else:
echo __('NOT present.');
echo '<br/>';
echo __('Rename config/database.php.default to config/database.php');
endif;
?>
</span>
</p>
<?php
if (!empty($filePresent)):
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
}
$db = ConnectionManager::getInstance();
$connected = $db->getDataSource('default');
?>
<p>
<span class="notice">
<?php
__('Cake');
if ($connected->isConnected()):
__(' is able to ');
else:
__(' is NOT able to ');
endif;
__('connect to the database.');
?>
</span>
</p>
<?php endif; ?>
<h2><?php echo __('Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<a href="https://trac.cakephp.org/wiki/notes/1.2.x.x"><?php __('Read the release notes and get the latest version'); ?> </a>
<h2><?php __('Editing this Page'); ?></h2>
<p>
<?php __('To change the content of this page, create: /app/views/pages/home.ctp.'); ?><br />
<?php __('To change its layout, create: /app/views/layouts/default.ctp.'); ?><br />
<a href="http://manual.cakephp.org/"><?php __('See the views section of the manual for more info.'); ?> </a><br />
<?php __('You can also add some CSS styles for your pages at: app/webroot/css/.'); ?>
</p>
<h2><?php __('Getting Started'); ?></h2>
<p>
<a href="http://manual.cakephp.org/appendix/blog_tutorial"><?php __('The 15 min Blog Tutorial'); ?></a><br />
<a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-cake1.html"><?php __('Cook up Web sites fast with CakePHP'); ?></a><br />
<a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-wiki1.html"><?php __('Create an interactive production wiki using PHP'); ?></a>
</p>
<h2><?php __('More about Cake'); ?></h2>
<p>
<?php __('CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?>
</p>
<p>
<?php __('Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.'); ?>
</p>
<ul>
<li><a href="http://cakefoundation.org/"><?php __('Cake Software Foundation'); ?> </a>
<ul><li><?php __('Promoting development related to CakePHP'); ?></li></ul></li>
<li><a href="http://bakery.cakephp.org"><?php __('The Bakery'); ?> </a>
<ul><li><?php __('Everything CakePHP'); ?></li></ul></li>
<li><a href="http://astore.amazon.com/cakesoftwaref-20/"><?php __('Book Store'); ?> </a>
<ul><li><?php __('Recommended Software Books'); ?></li></ul></li>
<li><a href="http://www.cafepress.com/cakefoundation"><?php __('CakeSchwag'); ?> </a>
<ul><li><?php __('Get your own CakePHP gear - Doughnate to Cake'); ?></li></ul></li>
<li><a href="http://www.cakephp.org"><?php __('CakePHP'); ?> </a>
<ul><li><?php __('The Rapid Development Framework'); ?></li></ul></li>
<li><a href="http://manual.cakephp.org"><?php __('CakePHP Manual'); ?> </a>
<ul><li><?php __('Your Rapid Development Cookbook'); ?></li></ul></li>
<li><a href="http://api.cakephp.org"><?php __('CakePHP API'); ?> </a>
<ul><li><?php __('Docblock Your Best Friend'); ?></li></ul></li>
<li><a href="http://www.cakeforge.org"><?php __('CakeForge'); ?> </a>
<ul><li><?php __('Open Development for CakePHP'); ?></li></ul></li>
<li><a href="https://trac.cakephp.org/"><?php __('CakePHP Trac'); ?> </a>
<ul><li><?php __('For the Development of CakePHP (Tickets, SVN browser, Roadmap, Changelogs)'); ?></li></ul></li>
<li><a href="http://groups-beta.google.com/group/cake-php"><?php __('CakePHP Google Group'); ?> </a>
<ul><li><?php __('Community mailing list'); ?></li></ul></li>
<li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a>
<ul><li><?php __('Live chat about CakePHP'); ?></li></ul></li>
</ul>

View file

@ -18,14 +18,16 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Inflector', 'Utility');
/**
* Cache provides a consistent interface to Caching in your application. It allows you
* to use several different Cache engines, without coupling your application to a specific
* implementation. It also allows you to change out cache storage or configuration without effecting
* to use several different Cache engines, without coupling your application to a specific
* implementation. It also allows you to change out cache storage or configuration without effecting
* the rest of your application.
*
* You can configure Cache engines in your application's `bootstrap.php` file. A sample configuration would
* be
* You can configure Cache engines in your application's `bootstrap.php` file. A sample configuration would
* be
*
* {{{
* Cache::config('shared', array(
@ -35,7 +37,7 @@
* }}}
*
* This would configure an APC cache engine to the 'shared' alias. You could then read and write
* to that cache alias by using it for the `$config` parameter in the various Cache methods. In
* to that cache alias by using it for the `$config` parameter in the various Cache methods. In
* general all Cache operations are supported by all cache engines. However, Cache::increment() and
* Cache::decrement() are not supported by File caching.
*
@ -148,14 +150,15 @@ class Cache {
protected static function _buildEngine($name) {
$config = self::$_config[$name];
list($plugin, $class) = pluginSplit($config['engine']);
list($plugin, $class) = pluginSplit($config['engine'], true);
$cacheClass = $class . 'Engine';
if (!class_exists($cacheClass) && self::_loadEngine($class, $plugin) === false) {
App::uses($cacheClass, $plugin . 'Cache/Engine');
if (!class_exists($cacheClass)) {
return false;
}
$cacheClass = $class . 'Engine';
if (!is_subclass_of($cacheClass, 'CacheEngine')) {
throw new CacheException(__('Cache engines must use CacheEngine as a base class.'));
throw new CacheException(__d('cake_dev', 'Cache engines must use CacheEngine as a base class.'));
}
self::$_engines[$name] = new $cacheClass();
if (self::$_engines[$name]->init($config)) {
@ -192,35 +195,15 @@ class Cache {
return true;
}
/**
* Tries to find and include a file for a cache engine and returns object instance
*
* @param $name Name of the engine (without 'Engine')
* @return mixed $engine object or null
*/
protected static function _loadEngine($name, $plugin = null) {
if ($plugin) {
return App::import('Lib', $plugin . '.cache' . DS . $name, false);
} else {
$core = App::core();
$path = $core['libs'][0] . 'cache' . DS . strtolower($name) . '.php';
if (file_exists($path)) {
require $path;
return true;
}
return App::import('Lib', 'cache' . DS . $name, false);
}
}
/**
* Temporarily change the settings on a cache config. The settings will persist for the next write
* operation (write, decrement, increment, clear). Any reads that are done before the write, will
* use the modified settings. If `$settings` is empty, the settings will be reset to the
* operation (write, decrement, increment, clear). Any reads that are done before the write, will
* use the modified settings. If `$settings` is empty, the settings will be reset to the
* original configuration.
*
* Can be called with 2 or 3 parameters. To set multiple values at once.
*
* `Cache::set(array('duration' => '+30 minutes'), 'my_config');`
* `Cache::set(array('duration' => '+30 minutes'), 'my_config');`
*
* Or to set one value.
*
@ -315,7 +298,7 @@ class Cache {
self::set(null, $config);
if ($success === false && $value !== '') {
trigger_error(
__("%s cache was unable to write '%s' to cache", $config, $key),
__d('cake_dev', "%s cache was unable to write '%s' to cache", $config, $key),
E_USER_WARNING
);
}
@ -389,7 +372,7 @@ class Cache {
*
* @param string $key Identifier for the data
* @param integer $offset How much to substract
* @param string $config Optional string configuration name. Defaults to 'default'
* @param string $config Optional string configuration name. Defaults to 'default'
* @return mixed new value, or false if the data doesn't exist, is not integer,
* or if there was an error fetching it
*/

View file

@ -37,7 +37,7 @@ class FileEngine extends CacheEngine {
/**
* Settings
*
*
* - path = absolute path to cache directory, default => CACHE
* - prefix = string prefix for filename, default => cake_
* - lock = enable file locking on write, default => false
@ -162,7 +162,7 @@ class FileEngine extends CacheEngine {
if ($cachetime !== false && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) {
return false;
}
$data = '';
$this->_File->next();
while ($this->_File->valid()) {
@ -251,7 +251,7 @@ class FileEngine extends CacheEngine {
* @throws CacheException
*/
public function decrement($key, $offset = 1) {
throw new CacheException(__('Files cannot be atomically decremented.'));
throw new CacheException(__d('cake_dev', 'Files cannot be atomically decremented.'));
}
/**
@ -261,7 +261,7 @@ class FileEngine extends CacheEngine {
* @throws CacheException
*/
public function increment($key, $offset = 1) {
throw new CacheException(__('Files cannot be atomically incremented.'));
throw new CacheException(__d('cake_dev', 'Files cannot be atomically incremented.'));
}
/**
@ -297,9 +297,9 @@ class FileEngine extends CacheEngine {
$dir = new SplFileInfo($this->settings['path']);
if ($this->_init && !($dir->isDir() && $dir->isWritable())) {
$this->_init = false;
trigger_error(__('%s is not writable', $this->settings['path']), E_USER_WARNING);
trigger_error(__d('cake_dev', '%s is not writable', $this->settings['path']), E_USER_WARNING);
return false;
}
return true;
}
}
}

View file

@ -19,7 +19,7 @@
*/
/**
* Memcache storage engine for cache. Memcache has some limitations in the amount of
* Memcache storage engine for cache. Memcache has some limitations in the amount of
* control you have over expire times far in the future. See MemcacheEngine::write() for
* more information.
*
@ -61,8 +61,8 @@ class MemcacheEngine extends CacheEngine {
return false;
}
parent::init(array_merge(array(
'engine'=> 'Memcache',
'prefix' => Inflector::slug(APP_DIR) . '_',
'engine'=> 'Memcache',
'prefix' => Inflector::slug(APP_DIR) . '_',
'servers' => array('127.0.0.1'),
'compress'=> false
), $settings)
@ -115,7 +115,7 @@ class MemcacheEngine extends CacheEngine {
/**
* Write data for key into cache. When using memcache as your cache engine
* remember that the Memcache pecl extension does not support cache expiry times greater
* remember that the Memcache pecl extension does not support cache expiry times greater
* than 30 days in the future. Any duration greater than 30 days will be treated as never expiring.
*
* @param string $key Identifier for the data
@ -153,7 +153,7 @@ class MemcacheEngine extends CacheEngine {
public function increment($key, $offset = 1) {
if ($this->settings['compress']) {
throw new CacheException(
__('Method increment() not implemented for compressed cache in %s', __CLASS__)
__d('cake_dev', 'Method increment() not implemented for compressed cache in %s', __CLASS__)
);
}
return $this->_Memcache->increment($key, $offset);
@ -171,7 +171,7 @@ class MemcacheEngine extends CacheEngine {
public function decrement($key, $offset = 1) {
if ($this->settings['compress']) {
throw new CacheException(
__('Method decrement() not implemented for compressed cache in %s', __CLASS__)
__d('cake_dev', 'Method decrement() not implemented for compressed cache in %s', __CLASS__)
);
}
return $this->_Memcache->decrement($key, $offset);
@ -212,4 +212,4 @@ class MemcacheEngine extends CacheEngine {
}
return true;
}
}
}

View file

@ -27,7 +27,7 @@
* you to create nested arrays structures in an ini config file. For example:
*
* `db.password = secret` would turn into `array('db' => array('password' => 'secret'))`
*
*
* You can nest properties as deeply as needed using .'s. IniReader also manipulates
* how the special ini values of 'yes', 'no', 'on', 'off', 'null' are handled.
* These values will be converted to their boolean equivalents.
@ -74,7 +74,7 @@ class IniReader implements ConfigReaderInterface {
if (!file_exists($filename)) {
$filename .= '.ini';
if (!file_exists($filename)) {
throw new ConfigureException(__('Could not load configuration files: %s or %s', substr($filename, 0, -4), $filename));
throw new ConfigureException(__d('cake_dev', 'Could not load configuration files: %s or %s', substr($filename, 0, -4), $filename));
}
}
$contents = parse_ini_file($filename, true);

View file

@ -18,7 +18,7 @@
*/
/**
* PHP Reader allows Configure to load configuration values from
* PHP Reader allows Configure to load configuration values from
* files containing simple PHP arrays.
*
* @package cake.libs.config
@ -55,13 +55,13 @@ class PhpReader implements ConfigReaderInterface {
*/
public function read($key) {
if (strpos($key, '..') !== false) {
throw new ConfigureException(__('Cannot load configuration files with ../ in them.'));
throw new ConfigureException(__d('cake_dev', 'Cannot load configuration files with ../ in them.'));
}
if (substr($key, -4) === '.php') {
$key = substr($key, 0, -4);
}
list($plugin, $key) = pluginSplit($key);
if ($plugin) {
$file = App::pluginPath($plugin) . 'config' . DS . $key;
} else {
@ -70,13 +70,13 @@ class PhpReader implements ConfigReaderInterface {
if (!file_exists($file)) {
$file .= '.php';
if (!file_exists($file)) {
throw new ConfigureException(__('Could not load configuration files: %s or %s', substr($file, 0, -4), $file));
throw new ConfigureException(__d('cake_dev', 'Could not load configuration files: %s or %s', substr($file, 0, -4), $file));
}
}
include $file;
if (!isset($config)) {
throw new ConfigureException(
sprintf(__('No variable $config found in %s.php'), $file)
sprintf(__d('cake_dev', 'No variable $config found in %s.php'), $file)
);
}
return $config;

View file

@ -19,7 +19,7 @@
/**
* This is a placeholder class.
* Create the same file in app/console/shells/app_shell.php
* Create the same file in app/console/shells/AppShell.php
*
* Add your application-wide methods in the class below, your shells
* will inherit them.

View file

@ -16,8 +16,8 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Component', 'Acl');
App::import('Model', 'DbAcl');
App::uses('AclComponent', 'Controller/Component');
App::uses('DbAcl', 'Model');
/**
* Shell for ACL management. This console is known to have issues with zend.ze1_compatibility_mode
@ -71,12 +71,12 @@ class AclShell extends Shell {
if (!in_array(Configure::read('Acl.classname'), array('DbAcl', 'DB_ACL'))) {
$out = "--------------------------------------------------\n";
$out .= __('Error: Your current Cake configuration is set to') . "\n";
$out .= __('an ACL implementation other than DB. Please change') . "\n";
$out .= __('your core config to reflect your decision to use') . "\n";
$out .= __('DbAcl before attempting to use this script') . ".\n";
$out .= __d('cake_console', 'Error: Your current Cake configuration is set to') . "\n";
$out .= __d('cake_console', 'an ACL implementation other than DB. Please change') . "\n";
$out .= __d('cake_console', 'your core config to reflect your decision to use') . "\n";
$out .= __d('cake_console', 'DbAcl before attempting to use this script') . ".\n";
$out .= "--------------------------------------------------\n";
$out .= __('Current ACL Classname: %s', Configure::read('Acl.classname')) . "\n";
$out .= __d('cake_console', 'Current ACL Classname: %s', Configure::read('Acl.classname')) . "\n";
$out .= "--------------------------------------------------\n";
$this->err($out);
$this->_stop();
@ -84,7 +84,7 @@ class AclShell extends Shell {
if ($this->command) {
if (!config('database')) {
$this->out(__('Your database configuration was not found. Take a moment to create one.'), true);
$this->out(__d('cake_console', 'Your database configuration was not found. Take a moment to create one.'), true);
$this->args = null;
return $this->DbConfig->execute();
}
@ -127,15 +127,15 @@ class AclShell extends Shell {
if (is_string($data) && $data != '/') {
$data = array('alias' => $data);
} elseif (is_string($data)) {
$this->error(__('/ can not be used as an alias!') . __(" / is the root, please supply a sub alias"));
$this->error(__d('cake_console', '/ can not be used as an alias!') . __d('cake_console', " / is the root, please supply a sub alias"));
}
$data['parent_id'] = $parent;
$this->Acl->{$class}->create();
if ($this->Acl->{$class}->save($data)) {
$this->out(__("<success>New %s</success> '%s' created.", $class, $this->args[2]), 2);
$this->out(__d('cake_console', "<success>New %s</success> '%s' created.", $class, $this->args[2]), 2);
} else {
$this->err(__("There was a problem creating a new %s '%s'.", $class, $this->args[2]));
$this->err(__d('cake_console', "There was a problem creating a new %s '%s'.", $class, $this->args[2]));
}
}
@ -150,9 +150,9 @@ class AclShell extends Shell {
$nodeId = $this->_getNodeId($class, $identifier);
if (!$this->Acl->{$class}->delete($nodeId)) {
$this->error(__('Node Not Deleted') . __('There was an error deleting the %s. Check that the node exists', $class) . ".\n");
$this->error(__d('cake_console', 'Node Not Deleted') . __d('cake_console', 'There was an error deleting the %s. Check that the node exists', $class) . ".\n");
}
$this->out(__('<success>%s deleted.</success>', $class), 2);
$this->out(__d('cake_console', '<success>%s deleted.</success>', $class), 2);
}
/**
@ -172,9 +172,9 @@ class AclShell extends Shell {
);
$this->Acl->{$class}->create();
if (!$this->Acl->{$class}->save($data)) {
$this->out(__('Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.'), true);
$this->out(__d('cake_console', 'Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.'), true);
} else {
$this->out(__('Node parent set to %s', $this->args[2]) . "\n", true);
$this->out(__d('cake_console', 'Node parent set to %s', $this->args[2]) . "\n", true);
}
}
@ -191,11 +191,11 @@ class AclShell extends Shell {
if (empty($nodes)) {
$this->error(
__("Supplied Node '%s' not found", $this->args[1]),
__('No tree returned.')
__d('cake_console', "Supplied Node '%s' not found", $this->args[1]),
__d('cake_console', 'No tree returned.')
);
}
$this->out(__('Path:'));
$this->out(__d('cake_console', 'Path:'));
$this->hr();
for ($i = 0; $i < count($nodes); $i++) {
$this->_outputNode($class, $nodes[$i], $i);
@ -228,9 +228,9 @@ class AclShell extends Shell {
extract($this->__getParams());
if ($this->Acl->check($aro, $aco, $action)) {
$this->out(__('%s is <success>allowed</success>.', $aroName), true);
$this->out(__d('cake_console', '%s is <success>allowed</success>.', $aroName), true);
} else {
$this->out(__('%s is <error>not allowed</error>.', $aroName), true);
$this->out(__d('cake_console', '%s is <error>not allowed</error>.', $aroName), true);
}
}
@ -242,9 +242,9 @@ class AclShell extends Shell {
extract($this->__getParams());
if ($this->Acl->allow($aro, $aco, $action)) {
$this->out(__('Permission <success>granted</success>.'), true);
$this->out(__d('cake_console', 'Permission <success>granted</success>.'), true);
} else {
$this->out(__('Permission was <error>not granted</error>.'), true);
$this->out(__d('cake_console', 'Permission was <error>not granted</error>.'), true);
}
}
@ -256,9 +256,9 @@ class AclShell extends Shell {
extract($this->__getParams());
if ($this->Acl->deny($aro, $aco, $action)) {
$this->out(__('Permission denied.'), true);
$this->out(__d('cake_console', 'Permission denied.'), true);
} else {
$this->out(__('Permission was not denied.'), true);
$this->out(__d('cake_console', 'Permission was not denied.'), true);
}
}
@ -270,9 +270,9 @@ class AclShell extends Shell {
extract($this->__getParams());
if ($this->Acl->inherit($aro, $aco, $action)) {
$this->out(__('Permission inherited.'), true);
$this->out(__d('cake_console', 'Permission inherited.'), true);
} else {
$this->out(__('Permission was not inherited.'), true);
$this->out(__d('cake_console', 'Permission was not inherited.'), true);
}
}
@ -303,9 +303,9 @@ class AclShell extends Shell {
if (empty($nodes)) {
if (isset($this->args[1])) {
$this->error(__('%s not found', $this->args[1]), __('No tree returned.'));
$this->error(__d('cake_console', '%s not found', $this->args[1]), __d('cake_console', 'No tree returned.'));
} elseif (isset($this->args[0])) {
$this->error(__('%s not found', $this->args[0]), __('No tree returned.'));
$this->error(__d('cake_console', '%s not found', $this->args[0]), __d('cake_console', 'No tree returned.'));
}
}
$this->out($class . " tree:");
@ -354,140 +354,140 @@ class AclShell extends Shell {
$type = array(
'choices' => array('aro', 'aco'),
'required' => true,
'help' => __('Type of node to create.')
'help' => __d('cake_console', 'Type of node to create.')
);
$parser->description('A console tool for managing the DbAcl')
->addSubcommand('create', array(
'help' => __('Create a new ACL node'),
'help' => __d('cake_console', 'Create a new ACL node'),
'parser' => array(
'description' => __('Creates a new ACL object <node> under the parent'),
'description' => __d('cake_console', 'Creates a new ACL object <node> under the parent'),
'arguments' => array(
'type' => $type,
'parent' => array(
'help' => __('The node selector for the parent.'),
'help' => __d('cake_console', 'The node selector for the parent.'),
'required' => true
),
'alias' => array(
'help' => __('The alias to use for the newly created node.'),
'help' => __d('cake_console', 'The alias to use for the newly created node.'),
'required' => true
)
)
)
))->addSubcommand('delete', array(
'help' => __('Deletes the ACL object with the given <node> reference'),
'help' => __d('cake_console', 'Deletes the ACL object with the given <node> reference'),
'parser' => array(
'description' => __('Delete an ACL node.'),
'description' => __d('cake_console', 'Delete an ACL node.'),
'arguments' => array(
'type' => $type,
'node' => array(
'help' => __('The node identifier to delete.'),
'help' => __d('cake_console', 'The node identifier to delete.'),
'required' => true,
)
)
)
))->addSubcommand('setparent', array(
'help' => __('Moves the ACL node under a new parent.'),
'help' => __d('cake_console', 'Moves the ACL node under a new parent.'),
'parser' => array(
'description' => __('Moves the ACL object specified by <node> beneath <parent>'),
'description' => __d('cake_console', 'Moves the ACL object specified by <node> beneath <parent>'),
'arguments' => array(
'type' => $type,
'node' => array(
'help' => __('The node to move'),
'help' => __d('cake_console', 'The node to move'),
'required' => true,
),
'parent' => array(
'help' => __('The new parent for <node>.'),
'help' => __d('cake_console', 'The new parent for <node>.'),
'required' => true
)
)
)
))->addSubcommand('getpath', array(
'help' => __('Print out the path to an ACL node.'),
'help' => __d('cake_console', 'Print out the path to an ACL node.'),
'parser' => array(
'description' => array(
__("Returns the path to the ACL object specified by <node>."),
__("This command is useful in determining the inhertiance of permissions"),
__("for a certain object in the tree.")
__d('cake_console', "Returns the path to the ACL object specified by <node>."),
__d('cake_console', "This command is useful in determining the inhertiance of permissions"),
__d('cake_console', "for a certain object in the tree.")
),
'arguments' => array(
'type' => $type,
'node' => array(
'help' => __('The node to get the path of'),
'help' => __d('cake_console', 'The node to get the path of'),
'required' => true,
)
)
)
))->addSubcommand('check', array(
'help' => __('Check the permissions between an ACO and ARO.'),
'help' => __d('cake_console', 'Check the permissions between an ACO and ARO.'),
'parser' => array(
'description' => array(
__("Use this command to grant ACL permissions. Once executed, the ARO "),
__("specified (and its children, if any) will have ALLOW access to the"),
__("specified ACO action (and the ACO's children, if any).")
__d('cake_console', "Use this command to grant ACL permissions. Once executed, the ARO "),
__d('cake_console', "specified (and its children, if any) will have ALLOW access to the"),
__d('cake_console', "specified ACO action (and the ACO's children, if any).")
),
'arguments' => array(
'aro' => array('help' => __('ARO to check.'), 'required' => true),
'aco' => array('help' => __('ACO to check.'), 'required' => true),
'action' => array('help' => __('Action to check'), 'default' => 'all')
'aro' => array('help' => __d('cake_console', 'ARO to check.'), 'required' => true),
'aco' => array('help' => __d('cake_console', 'ACO to check.'), 'required' => true),
'action' => array('help' => __d('cake_console', 'Action to check'), 'default' => 'all')
)
)
))->addSubcommand('grant', array(
'help' => __('Grant an ARO permissions to an ACO.'),
'help' => __d('cake_console', 'Grant an ARO permissions to an ACO.'),
'parser' => array(
'description' => array(
__("Use this command to grant ACL permissions. Once executed, the ARO"),
__("specified (and its children, if any) will have ALLOW access to the"),
__("specified ACO action (and the ACO's children, if any).")
__d('cake_console', "Use this command to grant ACL permissions. Once executed, the ARO"),
__d('cake_console', "specified (and its children, if any) will have ALLOW access to the"),
__d('cake_console', "specified ACO action (and the ACO's children, if any).")
),
'arguments' => array(
'aro' => array('help' => __('ARO to grant permission to.'), 'required' => true),
'aco' => array('help' => __('ACO to grant access to.'), 'required' => true),
'action' => array('help' => __('Action to grant'), 'default' => 'all')
'aro' => array('help' => __d('cake_console', 'ARO to grant permission to.'), 'required' => true),
'aco' => array('help' => __d('cake_console', 'ACO to grant access to.'), 'required' => true),
'action' => array('help' => __d('cake_console', 'Action to grant'), 'default' => 'all')
)
)
))->addSubcommand('deny', array(
'help' => __('Deny an ARO permissions to an ACO.'),
'help' => __d('cake_console', 'Deny an ARO permissions to an ACO.'),
'parser' => array(
'description' => array(
__("Use this command to deny ACL permissions. Once executed, the ARO"),
__("specified (and its children, if any) will have DENY access to the"),
__("specified ACO action (and the ACO's children, if any).")
__d('cake_console', "Use this command to deny ACL permissions. Once executed, the ARO"),
__d('cake_console', "specified (and its children, if any) will have DENY access to the"),
__d('cake_console', "specified ACO action (and the ACO's children, if any).")
),
'arguments' => array(
'aro' => array('help' => __('ARO to deny.'), 'required' => true),
'aco' => array('help' => __('ACO to deny.'), 'required' => true),
'action' => array('help' => __('Action to deny'), 'default' => 'all')
'aro' => array('help' => __d('cake_console', 'ARO to deny.'), 'required' => true),
'aco' => array('help' => __d('cake_console', 'ACO to deny.'), 'required' => true),
'action' => array('help' => __d('cake_console', 'Action to deny'), 'default' => 'all')
)
)
))->addSubcommand('inherit', array(
'help' => __('Inherit an ARO\'s parent permissions.'),
'help' => __d('cake_console', 'Inherit an ARO\'s parent permissions.'),
'parser' => array(
'description' => array(
__("Use this command to force a child ARO object to inherit its"),
__("permissions settings from its parent.")
__d('cake_console', "Use this command to force a child ARO object to inherit its"),
__d('cake_console', "permissions settings from its parent.")
),
'arguments' => array(
'aro' => array('help' => __('ARO to have permisssions inherit.'), 'required' => true),
'aco' => array('help' => __('ACO to inherit permissions on.'), 'required' => true),
'action' => array('help' => __('Action to inherit'), 'default' => 'all')
'aro' => array('help' => __d('cake_console', 'ARO to have permisssions inherit.'), 'required' => true),
'aco' => array('help' => __d('cake_console', 'ACO to inherit permissions on.'), 'required' => true),
'action' => array('help' => __d('cake_console', 'Action to inherit'), 'default' => 'all')
)
)
))->addSubcommand('view', array(
'help' => __('View a tree or a single node\'s subtree.'),
'help' => __d('cake_console', 'View a tree or a single node\'s subtree.'),
'parser' => array(
'description' => array(
__("The view command will return the ARO or ACO tree."),
__("The optional node parameter allows you to return"),
__("only a portion of the requested tree.")
__d('cake_console', "The view command will return the ARO or ACO tree."),
__d('cake_console', "The optional node parameter allows you to return"),
__d('cake_console', "only a portion of the requested tree.")
),
'arguments' => array(
'type' => $type,
'node' => array('help' => __('The optional node to view the subtree of.'))
'node' => array('help' => __d('cake_console', 'The optional node to view the subtree of.'))
)
)
))->addSubcommand('initdb', array(
'help' => __('Initialize the DbAcl tables. Uses this command : cake schema run create DbAcl')
'help' => __d('cake_console', 'Initialize the DbAcl tables. Uses this command : cake schema run create DbAcl')
))->epilog(
array(
'Node and parent arguments can be in one of the following formats:',
@ -520,7 +520,7 @@ class AclShell extends Shell {
$conditions = array($class . '.' . $key => $this->args[1]);
$possibility = $this->Acl->{$class}->find('all', compact('conditions'));
if (empty($possibility)) {
$this->error(__('%s not found', $this->args[1]), __('No tree returned.'));
$this->error(__d('cake_console', '%s not found', $this->args[1]), __d('cake_console', 'No tree returned.'));
}
return $possibility;
}
@ -556,7 +556,7 @@ class AclShell extends Shell {
if (is_array($identifier)) {
$identifier = var_export($identifier, true);
}
$this->error(__('Could not find node using reference "%s"', $identifier));
$this->error(__d('cake_console', 'Could not find node using reference "%s"', $identifier));
}
return Set::extract($node, "0.{$class}.id");
}

View file

@ -18,7 +18,7 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'File');
App::uses('File', 'Utility');
/**
* API shell to show method signatures of CakePHP core classes.
@ -41,13 +41,13 @@ class ApiShell extends Shell {
*/
public function initialize() {
$this->paths = array_merge($this->paths, array(
'behavior' => LIBS . 'model' . DS . 'behaviors' . DS,
'cache' => LIBS . 'cache' . DS,
'controller' => LIBS . 'controller' . DS,
'component' => LIBS . 'controller' . DS . 'components' . DS,
'helper' => LIBS . 'view' . DS . 'helpers' . DS,
'model' => LIBS . 'model' . DS,
'view' => LIBS . 'view' . DS,
'behavior' => LIBS . 'Model' . DS . 'Behavior' . DS,
'cache' => LIBS . 'Cache' . DS,
'controller' => LIBS . 'Controller' . DS,
'component' => LIBS . 'Controller' . DS . 'Component' . DS,
'helper' => LIBS . 'View' . DS . 'Helper' . DS,
'model' => LIBS . 'Model' . DS,
'view' => LIBS . 'View' . DS,
'core' => LIBS
));
}
@ -74,7 +74,7 @@ class ApiShell extends Shell {
$class = Inflector::camelize($type);
} elseif (count($this->args) > 1) {
$file = Inflector::underscore($this->args[1]);
$class = Inflector::camelize($file);
$class = Inflector::camelize($this->args[1]);
}
$objects = App::objects('class', $path);
if (in_array($class, $objects)) {
@ -85,15 +85,15 @@ class ApiShell extends Shell {
}
} else {
$this->error(__('%s not found', $class));
$this->error(__d('cake_console', '%s not found', $class));
}
$parsed = $this->__parseClass($path . $file .'.php', $class);
$parsed = $this->__parseClass($path . $class .'.php', $class);
if (!empty($parsed)) {
if (isset($this->params['method'])) {
if (!isset($parsed[$this->params['method']])) {
$this->err(__('%s::%s() could not be found', $class, $this->params['method']));
$this->err(__d('cake_console', '%s::%s() could not be found', $class, $this->params['method']));
$this->_stop();
}
$method = $parsed[$this->params['method']];
@ -110,9 +110,9 @@ class ApiShell extends Shell {
$this->out($list);
$methods = array_keys($parsed);
while ($number = strtolower($this->in(__('Select a number to see the more information about a specific method. q to quit. l to list.'), null, 'q'))) {
while ($number = strtolower($this->in(__d('cake_console', 'Select a number to see the more information about a specific method. q to quit. l to list.'), null, 'q'))) {
if ($number === 'q') {
$this->out(__('Done'));
$this->out(__d('cake_console', 'Done'));
return $this->_stop();
}
@ -145,8 +145,8 @@ class ApiShell extends Shell {
'help' => 'A CakePHP core class name (e.g: Component, HtmlHelper).'
))->addOption('method', array(
'short' => 'm',
'help' => __('The specific method you want help on.')
))->description(__('Lookup doc block comments for classes in CakePHP.'));
'help' => __d('cake_console', 'The specific method you want help on.')
))->description(__d('cake_console', 'Lookup doc block comments for classes in CakePHP.'));
return $parser;
}
/**
@ -197,9 +197,12 @@ class ApiShell extends Shell {
function __parseClass($path, $class) {
$parsed = array();
if (!include_once($path)) {
$this->err(__('%s could not be found', $path));
if (!class_exists($class)) {
if (!include_once($path)) {
$this->err(__d('cake_console', '%s could not be found', $path));
}
}
$reflection = new ReflectionClass($class);
foreach ($reflection->getMethods() as $method) {

View file

@ -21,6 +21,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Model', 'Model');
/**
* Bake is a command-line code generation utility for automating programmer chores.
*
@ -73,7 +75,7 @@ class BakeShell extends Shell {
}
if (!config('database')) {
$this->out(__('Your database configuration was not found. Take a moment to create one.'));
$this->out(__d('cake_console', 'Your database configuration was not found. Take a moment to create one.'));
$this->args = null;
return $this->DbConfig->execute();
}
@ -88,7 +90,7 @@ class BakeShell extends Shell {
$this->out('[T]est case');
$this->out('[Q]uit');
$classToBake = strtoupper($this->in(__('What would you like to Bake?'), array('D', 'M', 'V', 'C', 'P', 'F', 'T', 'Q')));
$classToBake = strtoupper($this->in(__d('cake_console', 'What would you like to Bake?'), array('D', 'M', 'V', 'C', 'P', 'F', 'T', 'Q')));
switch ($classToBake) {
case 'D':
$this->DbConfig->execute();
@ -115,7 +117,7 @@ class BakeShell extends Shell {
exit(0);
break;
default:
$this->out(__('You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.'));
$this->out(__d('cake_console', 'You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.'));
}
$this->hr();
$this->main();
@ -149,11 +151,11 @@ class BakeShell extends Shell {
$modelExists = false;
$model = $this->_modelName($name);
if (App::import('Model', $model)) {
App::uses($model, 'Model');
if (class_exists($model)) {
$object = new $model();
$modelExists = true;
} else {
App::import('Model', 'Model', false);
$object = new Model(array('name' => $name, 'ds' => $this->connection));
}
@ -174,15 +176,16 @@ class BakeShell extends Shell {
$this->Controller->bakeTest($controller);
}
}
if (App::import('Controller', $controller)) {
App::uses($controller . 'Controller', 'Controller');
if (class_exists($controller . 'Controller')) {
$this->View->args = array($controller);
$this->View->execute();
}
$this->out('', 1, Shell::QUIET);
$this->out(__('<success>Bake All complete</success>'), 1, Shell::QUIET);
$this->out(__d('cake_console', '<success>Bake All complete</success>'), 1, Shell::QUIET);
array_shift($this->args);
} else {
$this->error(__('Bake All could not continue without a valid model'));
$this->error(__d('cake_console', 'Bake All could not continue without a valid model'));
}
return $this->_stop();
}
@ -200,33 +203,33 @@ class BakeShell extends Shell {
'creation process. You can customize the generation process by telling Bake' .
'where different parts of your application are using command line arguments.'
)->addSubcommand('all', array(
'help' => __('Bake a complete MVC. optional <name> of a Model'),
'help' => __d('cake_console', 'Bake a complete MVC. optional <name> of a Model'),
))->addSubcommand('project', array(
'help' => __('Bake a new app folder in the path supplied or in current directory if no path is specified'),
'help' => __d('cake_console', 'Bake a new app folder in the path supplied or in current directory if no path is specified'),
'parser' => $this->Project->getOptionParser()
))->addSubcommand('plugin', array(
'help' => __('Bake a new plugin folder in the path supplied or in current directory if no path is specified.'),
'help' => __d('cake_console', 'Bake a new plugin folder in the path supplied or in current directory if no path is specified.'),
'parser' => $this->Plugin->getOptionParser()
))->addSubcommand('db_config', array(
'help' => __('Bake a database.php file in config directory.'),
'help' => __d('cake_console', 'Bake a database.php file in config directory.'),
'parser' => $this->DbConfig->getOptionParser()
))->addSubcommand('model', array(
'help' => __('Bake a model.'),
'help' => __d('cake_console', 'Bake a model.'),
'parser' => $this->Model->getOptionParser()
))->addSubcommand('view', array(
'help' => __('Bake views for controllers.'),
'help' => __d('cake_console', 'Bake views for controllers.'),
'parser' => $this->View->getOptionParser()
))->addSubcommand('controller', array(
'help' => __('Bake a controller.'),
'help' => __d('cake_console', 'Bake a controller.'),
'parser' => $this->Controller->getOptionParser()
))->addSubcommand('fixture', array(
'help' => __('Bake a fixture.'),
'help' => __d('cake_console', 'Bake a fixture.'),
'parser' => $this->Fixture->getOptionParser()
))->addSubcommand('test', array(
'help' => __('Bake a unit test.'),
'help' => __d('cake_console', 'Bake a unit test.'),
'parser' => $this->Test->getOptionParser()
))->addOption('connection', array(
'help' => __('Database connection to use in conjunction with `bake all`.'),
'help' => __d('cake_console', 'Database connection to use in conjunction with `bake all`.'),
'short' => 'c',
'default' => 'default'
));

View file

@ -16,6 +16,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Inflector', 'Utility');
/**
* Shows a list of commands available from the console.
*
@ -79,17 +81,18 @@ class CommandListShell extends Shell {
protected function _getShellList() {
$shellList = array();
$corePaths = App::core('shells');
$shellList = $this->_appendShells('CORE', $corePaths, $shellList);
$shells = App::objects('file', App::core('Console/Command'));
$shellList = $this->_appendShells('CORE', $shells, $shellList);
$appPaths = array_diff(App::path('shells'), $corePaths);
$shellList = $this->_appendShells('app', $appPaths, $shellList);
$appShells = App::objects('Console/Command', null, false);
$shellList = $this->_appendShells('app', $appShells, $shellList);
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
$pluginPath = App::pluginPath($plugin) . 'console' . DS . 'shells' . DS;
$shellList = $this->_appendShells($plugin, array($pluginPath), $shellList);
$pluginShells = App::objects($plugin . '.Console/Command');
$shellList = $this->_appendShells($plugin, $pluginShells, $shellList);
}
return $shellList;
}
@ -98,22 +101,10 @@ class CommandListShell extends Shell {
*
* @return array
*/
protected function _appendShells($type, $paths, $shellList) {
foreach ($paths as $path) {
if (!is_dir($path)) {
continue;
}
$shells = App::objects('file', $path);
if (empty($shells)) {
continue;
}
foreach ($shells as $shell) {
if ($shell !== 'shell.php' && $shell !== 'app_shell.php') {
$shell = str_replace('.php', '', $shell);
$shellList[$shell][$type] = $type;
}
}
protected function _appendShells($type, $shells, $shellList) {
foreach ($shells as $shell) {
$shell = Inflector::underscore(str_replace('Shell', '', $shell));
$shellList[$shell][$type] = $type;
}
return $shellList;
}
@ -223,10 +214,10 @@ class CommandListShell extends Shell {
$parser = parent::getOptionParser();
return $parser->description('Get the list of available shells for this CakePHP application.')
->addOption('xml', array(
'help' => __('Get the listing as XML.'),
'help' => __d('cake_console', 'Get the listing as XML.'),
'boolean' => true
))->addOption('sort', array(
'help' => __('Sorts the commands by where they are located.'),
'help' => __d('cake_console', 'Sorts the commands by where they are located.'),
'boolean' => true
));
}

View file

@ -51,14 +51,14 @@ class ConsoleShell extends Shell {
*
*/
public function initialize() {
require_once CAKE . 'dispatcher.php';
App::uses('Dispatcher', 'Routing');
$this->Dispatcher = new Dispatcher();
$this->models = App::objects('model');
App::import('Model', $this->models);
foreach ($this->models as $model) {
$class = Inflector::camelize(str_replace('.php', '', $model));
$this->models[$model] = $class;
App::uses($class, 'Model');
$this->{$class} = new $class();
}
$this->out('Model classes:');
@ -333,21 +333,20 @@ class ConsoleShell extends Shell {
* @return boolean True if config reload was a success, otherwise false
*/
protected function _loadRoutes() {
$router = Router::getInstance();
$router->reload();
extract($router->getNamedExpressions());
Router::reload();
extract(Router::getNamedExpressions());
if (!@include(CONFIGS . 'routes.php')) {
return false;
}
$router->parse('/');
Router::parse('/');
foreach (array_keys($router->getNamedExpressions()) as $var) {
foreach (array_keys(Router::getNamedExpressions()) as $var) {
unset(${$var});
}
for ($i = 0, $len = count($router->routes); $i < $len; $i++) {
$router->routes[$i]->compile();
foreach (Router::$routes as $route) {
$route->compile();
}
return true;
}

View file

@ -52,7 +52,7 @@ class I18nShell extends Shell {
if ($this->command && !in_array($this->command, array('help'))) {
if (!config('database')) {
$this->out(__('Your database configuration was not found. Take a moment to create one.'), true);
$this->out(__d('cake_console', 'Your database configuration was not found. Take a moment to create one.'), true);
return $this->DbConfig->execute();
}
}
@ -63,14 +63,14 @@ class I18nShell extends Shell {
*
*/
public function main() {
$this->out(__('<info>I18n Shell</info>'));
$this->out(__d('cake_console', '<info>I18n Shell</info>'));
$this->hr();
$this->out(__('[E]xtract POT file from sources'));
$this->out(__('[I]nitialize i18n database table'));
$this->out(__('[H]elp'));
$this->out(__('[Q]uit'));
$this->out(__d('cake_console', '[E]xtract POT file from sources'));
$this->out(__d('cake_console', '[I]nitialize i18n database table'));
$this->out(__d('cake_console', '[H]elp'));
$this->out(__d('cake_console', '[Q]uit'));
$choice = strtolower($this->in(__('What would you like to do?'), array('E', 'I', 'H', 'Q')));
$choice = strtolower($this->in(__d('cake_console', 'What would you like to do?'), array('E', 'I', 'H', 'Q')));
switch ($choice) {
case 'e':
$this->Extract->execute();
@ -85,7 +85,7 @@ class I18nShell extends Shell {
exit(0);
break;
default:
$this->out(__('You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.'));
$this->out(__d('cake_console', 'You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.'));
}
$this->hr();
$this->main();
@ -107,11 +107,11 @@ class I18nShell extends Shell {
public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(
__('I18n Shell initializes i18n database table for your application and generates .pot files(s) with translations.')
__d('cake_console', 'I18n Shell initializes i18n database table for your application and generates .pot files(s) with translations.')
)->addSubcommand('initdb', array(
'help' => __('Initialize the i18n table.')
'help' => __d('cake_console', 'Initialize the i18n table.')
))->addSubcommand('extract', array(
'help' => __('Extract the po translations from your application'),
'help' => __d('cake_console', 'Extract the po translations from your application'),
'parser' => $this->Extract->getOptionParser()
));
}

View file

@ -19,8 +19,8 @@
* @since CakePHP(tm) v 1.2.0.5550
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'File', false);
App::import('Model', 'CakeSchema', false);
App::uses('File', 'Utility');
App::uses('CakeSchema', 'Model');
/**
* Schema is a command-line database management utility for automating programmer chores.
@ -112,7 +112,7 @@ class SchemaShell extends Shell {
$this->_stop();
} else {
$file = $this->Schema->path . DS . $this->params['file'];
$this->err(__('Schema file (%s) could not be found.', $file));
$this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file));
$this->_stop();
}
}
@ -123,7 +123,7 @@ class SchemaShell extends Shell {
*
*/
public function generate() {
$this->out(__('Generating Schema...'));
$this->out(__d('cake_console', 'Generating Schema...'));
$options = array();
if (isset($this->params['force'])) {
$options = array('models' => false);
@ -182,10 +182,10 @@ class SchemaShell extends Shell {
}
if ($this->Schema->write($content)) {
$this->out(__('Schema file: %s generated', $content['file']));
$this->out(__d('cake_console', 'Schema file: %s generated', $content['file']));
$this->_stop();
} else {
$this->err(__('Schema file: %s generated'));
$this->err(__d('cake_console', 'Schema file: %s generated'));
$this->_stop();
}
}
@ -202,7 +202,7 @@ class SchemaShell extends Shell {
$write = false;
$Schema = $this->Schema->load();
if (!$Schema) {
$this->err(__('Schema could not be loaded'));
$this->err(__d('cake_console', 'Schema could not be loaded'));
$this->_stop();
}
if (!empty($this->params['write'])) {
@ -227,10 +227,10 @@ class SchemaShell extends Shell {
}
if ($File->write($contents)) {
$this->out(__('SQL dump file created in %s', $File->pwd()));
$this->out(__d('cake_console', 'SQL dump file created in %s', $File->pwd()));
$this->_stop();
} else {
$this->err(__('SQL dump could not be created'));
$this->err(__d('cake_console', 'SQL dump could not be created'));
$this->_stop();
}
}
@ -274,7 +274,7 @@ class SchemaShell extends Shell {
if (!empty($this->params['dry'])) {
$this->__dry = true;
$this->out(__('Performing a dry run.'));
$this->out(__d('cake_console', 'Performing a dry run.'));
}
$options = array('name' => $name, 'plugin' => $plugin);
@ -286,7 +286,7 @@ class SchemaShell extends Shell {
$Schema = $this->Schema->load($options);
if (!$Schema) {
$this->err(__('%s could not be loaded', $this->Schema->path . DS . $this->Schema->file));
$this->err(__d('cake_console', '%s could not be loaded', $this->Schema->path . DS . $this->Schema->file));
$this->_stop();
}
$table = null;
@ -317,26 +317,26 @@ class SchemaShell extends Shell {
$create[$table] = $db->createSchema($Schema, $table);
}
if (empty($drop) || empty($create)) {
$this->out(__('Schema is up to date.'));
$this->out(__d('cake_console', 'Schema is up to date.'));
$this->_stop();
}
$this->out("\n" . __('The following table(s) will be dropped.'));
$this->out("\n" . __d('cake_console', 'The following table(s) will be dropped.'));
$this->out(array_keys($drop));
if ('y' == $this->in(__('Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n')) {
$this->out(__('Dropping table(s).'));
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n')) {
$this->out(__d('cake_console', 'Dropping table(s).'));
$this->__run($drop, 'drop', $Schema);
}
$this->out("\n" . __('The following table(s) will be created.'));
$this->out("\n" . __d('cake_console', 'The following table(s) will be created.'));
$this->out(array_keys($create));
if ('y' == $this->in(__('Are you sure you want to create the table(s)?'), array('y', 'n'), 'y')) {
$this->out(__('Creating table(s).'));
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y')) {
$this->out(__d('cake_console', 'Creating table(s).'));
$this->__run($create, 'create', $Schema);
}
$this->out(__('End create.'));
$this->out(__d('cake_console', 'End create.'));
}
/**
@ -348,7 +348,7 @@ class SchemaShell extends Shell {
function __update(&$Schema, $table = null) {
$db = ConnectionManager::getDataSource($this->Schema->connection);
$this->out(__('Comparing Database to Schema...'));
$this->out(__d('cake_console', 'Comparing Database to Schema...'));
$options = array();
if (isset($this->params['force'])) {
$options['models'] = false;
@ -367,19 +367,19 @@ class SchemaShell extends Shell {
}
if (empty($contents)) {
$this->out(__('Schema is up to date.'));
$this->out(__d('cake_console', 'Schema is up to date.'));
$this->_stop();
}
$this->out("\n" . __('The following statements will run.'));
$this->out("\n" . __d('cake_console', 'The following statements will run.'));
$this->out(array_map('trim', $contents));
if ('y' == $this->in(__('Are you sure you want to alter the tables?'), array('y', 'n'), 'n')) {
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n')) {
$this->out();
$this->out(__('Updating Database...'));
$this->out(__d('cake_console', 'Updating Database...'));
$this->__run($contents, 'update', $Schema);
}
$this->out(__('End update.'));
$this->out(__d('cake_console', 'End update.'));
}
/**
@ -389,7 +389,7 @@ class SchemaShell extends Shell {
*/
function __run($contents, $event, &$Schema) {
if (empty($contents)) {
$this->err(__('Sql could not be run'));
$this->err(__d('cake_console', 'Sql could not be run'));
return;
}
Configure::write('debug', 2);
@ -397,10 +397,10 @@ class SchemaShell extends Shell {
foreach ($contents as $table => $sql) {
if (empty($sql)) {
$this->out(__('%s is up to date.', $table));
$this->out(__d('cake_console', '%s is up to date.', $table));
} else {
if ($this->__dry === true) {
$this->out(__('Dry run for %s :', $table));
$this->out(__d('cake_console', 'Dry run for %s :', $table));
$this->out($sql);
} else {
if (!$Schema->before(array($event => $table))) {
@ -416,7 +416,7 @@ class SchemaShell extends Shell {
if (!empty($error)) {
$this->out($error);
} else {
$this->out(__('%s updated.', $table));
$this->out(__d('cake_console', '%s updated.', $table));
}
}
}
@ -430,26 +430,26 @@ class SchemaShell extends Shell {
*/
public function getOptionParser() {
$plugin = array(
'help' => __('The plugin to use.'),
'help' => __d('cake_console', 'The plugin to use.'),
);
$connection = array(
'help' => __('Set the db config to use.'),
'help' => __d('cake_console', 'Set the db config to use.'),
'default' => 'default'
);
$path = array(
'help' => __('Path to read and write schema.php'),
'help' => __d('cake_console', 'Path to read and write schema.php'),
'default' => CONFIGS . 'schema'
);
$file = array(
'help' => __('File name to read and write.'),
'help' => __d('cake_console', 'File name to read and write.'),
'default' => 'schema.php'
);
$name = array(
'help' => __('Classname to use. If its Plugin.class, both name and plugin options will be set.')
'help' => __d('cake_console', 'Classname to use. If its Plugin.class, both name and plugin options will be set.')
);
$snapshot = array(
'short' => 's',
'help' => __('Snapshot number to use/make.')
'help' => __d('cake_console', 'Snapshot number to use/make.')
);
$dry = array(
'help' => 'Perform a dry run on create and update commands. Queries will be output instead of run.',
@ -457,11 +457,11 @@ class SchemaShell extends Shell {
);
$force = array(
'short' => 'f',
'help' => __('Force "generate" to create a new schema'),
'help' => __d('cake_console', 'Force "generate" to create a new schema'),
'boolean' => true
);
$write = array(
'help' => __('Write the dumped SQL to a file.')
'help' => __d('cake_console', 'Write the dumped SQL to a file.')
);
$parser = parent::getOptionParser();
@ -475,42 +475,42 @@ class SchemaShell extends Shell {
'arguments' => compact('name')
)
))->addSubcommand('generate', array(
'help' => __('Reads from --connection and writes to --path. Generate snapshots with -s'),
'help' => __d('cake_console', 'Reads from --connection and writes to --path. Generate snapshots with -s'),
'parser' => array(
'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'snapshot', 'force'),
'arguments' => array(
'snapshot' => array('help' => __('Generate a snapshot.'))
'snapshot' => array('help' => __d('cake_console', 'Generate a snapshot.'))
)
)
))->addSubcommand('dump', array(
'help' => __('Dump database SQL based on a schema file to stdout.'),
'help' => __d('cake_console', 'Dump database SQL based on a schema file to stdout.'),
'parser' => array(
'options' => compact('plugin', 'path', 'file', 'name', 'connection'),
'arguments' => compact('name')
)
))->addSubcommand('create', array(
'help' => __('Drop and create tables based on the schema file.'),
'help' => __d('cake_console', 'Drop and create tables based on the schema file.'),
'parser' => array(
'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'dry', 'snapshot'),
'args' => array(
'name' => array(
'help' => __('Name of schema to use.')
'help' => __d('cake_console', 'Name of schema to use.')
),
'table' => array(
'help' => __('Only create the specified table.')
'help' => __d('cake_console', 'Only create the specified table.')
)
)
)
))->addSubcommand('update', array(
'help' => __('Alter the tables based on the schema file.'),
'help' => __d('cake_console', 'Alter the tables based on the schema file.'),
'parser' => array(
'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'dry', 'snapshot'),
'args' => array(
'name' => array(
'help' => __('Name of schema to use.')
'help' => __d('cake_console', 'Name of schema to use.')
),
'table' => array(
'help' => __('Only create the specified table.')
'help' => __d('cake_console', 'Only create the specified table.')
)
)
)

View file

@ -50,7 +50,7 @@ class BakeTask extends Shell {
public function getPath() {
$path = $this->path;
if (isset($this->plugin)) {
$path = $this->_pluginPath($this->plugin) . Inflector::pluralize(Inflector::underscore($this->name)) . DS;
$path = $this->_pluginPath($this->plugin) . $this->name . DS;
}
return $path;
}

View file

@ -17,7 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
include_once dirname(__FILE__) . DS . 'bake.php';
App::uses('BakeTask', 'Console/Command/Task');
/**
* Task class for creating and updating controller files.
@ -71,13 +71,13 @@ class ControllerTask extends BakeTask {
$actions = '';
if (!empty($this->params['public'])) {
$this->out(__('Baking basic crud methods for ') . $controller);
$this->out(__d('cake_console', 'Baking basic crud methods for ') . $controller);
$actions .= $this->bakeActions($controller);
}
if (!empty($this->params['admin'])) {
$admin = $this->Project->getPrefix();
if ($admin) {
$this->out(__('Adding %s methods', $admin));
$this->out(__d('cake_console', 'Adding %s methods', $admin));
$actions .= "\n" . $this->bakeActions($controller, $admin);
}
}
@ -106,7 +106,8 @@ class ControllerTask extends BakeTask {
foreach ($this->__tables as $table) {
$model = $this->_modelName($table);
$controller = $this->_controllerName($model);
if (App::import('Model', $model)) {
App::uses($model, 'Model');
if (class_exists($model)) {
$actions = $this->bakeActions($controller);
if ($this->bake($controller, $actions) && $unitTestExists) {
$this->bakeTest($controller);
@ -123,7 +124,7 @@ class ControllerTask extends BakeTask {
protected function _interactive() {
$this->interactive = true;
$this->hr();
$this->out(__("Bake Controller\nPath: %s", $this->path));
$this->out(__d('cake_console', "Bake Controller\nPath: %s", $this->path));
$this->hr();
if (empty($this->connection)) {
@ -132,7 +133,7 @@ class ControllerTask extends BakeTask {
$controllerName = $this->getName();
$this->hr();
$this->out(__('Baking %sController', $controllerName));
$this->out(__d('cake_console', 'Baking %sController', $controllerName));
$this->hr();
$helpers = $components = array();
@ -142,18 +143,17 @@ class ControllerTask extends BakeTask {
$useDynamicScaffold = 'n';
$wannaBakeCrud = 'y';
$controllerFile = strtolower(Inflector::underscore($controllerName));
$question[] = __("Would you like to build your controller interactively?");
if (file_exists($this->path . $controllerFile .'_controller.php')) {
$question[] = __("Warning: Choosing no will overwrite the %sController.", $controllerName);
$question[] = __d('cake_console', "Would you like to build your controller interactively?");
if (file_exists($this->path . $controllerName .'Controller.php')) {
$question[] = __d('cake_console', "Warning: Choosing no will overwrite the %sController.", $controllerName);
}
$doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y');
if (strtolower($doItInteractive) == 'y') {
$this->interactive = true;
$useDynamicScaffold = $this->in(
__("Would you like to use dynamic scaffolding?"), array('y','n'), 'n'
__d('cake_console', "Would you like to use dynamic scaffolding?"), array('y','n'), 'n'
);
if (strtolower($useDynamicScaffold) == 'y') {
@ -166,7 +166,7 @@ class ControllerTask extends BakeTask {
$components = $this->doComponents();
$wannaUseSession = $this->in(
__("Would you like to use Session flash messages?"), array('y','n'), 'y'
__d('cake_console', "Would you like to use Session flash messages?"), array('y','n'), 'y'
);
}
} else {
@ -184,7 +184,7 @@ class ControllerTask extends BakeTask {
$baked = false;
if ($this->interactive === true) {
$this->confirmController($controllerName, $useDynamicScaffold, $helpers, $components);
$looksGood = $this->in(__('Look okay?'), array('y','n'), 'y');
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y','n'), 'y');
if (strtolower($looksGood) == 'y') {
$baked = $this->bake($controllerName, $actions, $helpers, $components);
@ -209,17 +209,17 @@ class ControllerTask extends BakeTask {
public function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) {
$this->out();
$this->hr();
$this->out(__('The following controller will be created:'));
$this->out(__d('cake_console', 'The following controller will be created:'));
$this->hr();
$this->out(__("Controller Name:\n\t%s", $controllerName));
$this->out(__d('cake_console', "Controller Name:\n\t%s", $controllerName));
if (strtolower($useDynamicScaffold) == 'y') {
$this->out("var \$scaffold;");
}
$properties = array(
'helpers' => __('Helpers:'),
'components' => __('Components:'),
'helpers' => __d('cake_console', 'Helpers:'),
'components' => __d('cake_console', 'Components:'),
);
foreach ($properties as $var => $title) {
@ -246,11 +246,11 @@ class ControllerTask extends BakeTask {
*/
protected function _askAboutMethods() {
$wannaBakeCrud = $this->in(
__("Would you like to create some basic class methods \n(index(), add(), view(), edit())?"),
__d('cake_console', "Would you like to create some basic class methods \n(index(), add(), view(), edit())?"),
array('y','n'), 'n'
);
$wannaBakeAdminCrud = $this->in(
__("Would you like to create the basic class methods for admin routing?"),
__d('cake_console', "Would you like to create the basic class methods for admin routing?"),
array('y','n'), 'n'
);
return array($wannaBakeCrud, $wannaBakeAdminCrud);
@ -269,10 +269,11 @@ class ControllerTask extends BakeTask {
$currentModelName = $modelImport = $this->_modelName($controllerName);
$plugin = $this->plugin;
if ($plugin) {
$modelImport = $plugin . '.' . $modelImport;
$plugin .= '.';
}
if (!App::import('Model', $modelImport)) {
$this->err(__('You must have a model for this class to build basic methods. Please try again.'));
App::uses($modelImport, $plugin . 'Model');
if (!class_exists($modelImport)) {
$this->err(__d('cake_console', 'You must have a model for this class to build basic methods. Please try again.'));
$this->_stop();
}
@ -286,7 +287,7 @@ class ControllerTask extends BakeTask {
$primaryKey = $modelObj->primaryKey;
$this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName',
'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName',
'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName',
'displayField', 'primaryKey'
));
$actions = $this->Template->generate('actions', 'controller_actions');
@ -313,7 +314,7 @@ class ControllerTask extends BakeTask {
$contents = $this->Template->generate('classes', 'controller');
$path = $this->getPath();
$filename = $path . $this->_controllerPath($controllerName) . '_controller.php';
$filename = $path . $this->_controllerName($controllerName) . 'Controller.php';
if ($this->createFile($filename, $contents)) {
return $contents;
}
@ -340,8 +341,8 @@ class ControllerTask extends BakeTask {
*/
public function doHelpers() {
return $this->_doPropertyChoices(
__("Would you like this controller to use other helpers\nbesides HtmlHelper and FormHelper?"),
__("Please provide a comma separated list of the other\nhelper names you'd like to use.\nExample: 'Ajax, Javascript, Time'")
__d('cake_console', "Would you like this controller to use other helpers\nbesides HtmlHelper and FormHelper?"),
__d('cake_console', "Please provide a comma separated list of the other\nhelper names you'd like to use.\nExample: 'Ajax, Javascript, Time'")
);
}
@ -352,8 +353,8 @@ class ControllerTask extends BakeTask {
*/
public function doComponents() {
return $this->_doPropertyChoices(
__("Would you like this controller to use any components?"),
__("Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'")
__d('cake_console', "Would you like this controller to use any components?"),
__d('cake_console', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'")
);
}
@ -389,7 +390,7 @@ class ControllerTask extends BakeTask {
$this->__tables = $this->Model->getAllTables($useDbConfig);
if ($this->interactive == true) {
$this->out(__('Possible Controllers based on your current database:'));
$this->out(__d('cake_console', 'Possible Controllers based on your current database:'));
$this->_controllerNames = array();
$count = count($this->__tables);
for ($i = 0; $i < $count; $i++) {
@ -412,14 +413,14 @@ class ControllerTask extends BakeTask {
$enteredController = '';
while ($enteredController == '') {
$enteredController = $this->in(__("Enter a number from the list above,\ntype in the name of another controller, or 'q' to exit"), null, 'q');
$enteredController = $this->in(__d('cake_console', "Enter a number from the list above,\ntype in the name of another controller, or 'q' to exit"), null, 'q');
if ($enteredController === 'q') {
$this->out(__('Exit'));
$this->out(__d('cake_console', 'Exit'));
return $this->_stop();
}
if ($enteredController == '' || intval($enteredController) > count($controllers)) {
$this->err(__("The Controller name you supplied was empty,\nor the number you selected was not an option. Please try again."));
$this->err(__d('cake_console', "The Controller name you supplied was empty,\nor the number you selected was not an option. Please try again."));
$enteredController = '';
}
}
@ -440,24 +441,24 @@ class ControllerTask extends BakeTask {
public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(
__('Bake a controller for a model. Using options you can bake public, admin or both.')
__d('cake_console', 'Bake a controller for a model. Using options you can bake public, admin or both.')
)->addArgument('name', array(
'help' => __('Name of the controller to bake. Can use Plugin.name to bake controllers into plugins.')
'help' => __d('cake_console', 'Name of the controller to bake. Can use Plugin.name to bake controllers into plugins.')
))->addOption('public', array(
'help' => __('Bake a controller with basic crud actions (index, view, add, edit, delete).'),
'help' => __d('cake_console', 'Bake a controller with basic crud actions (index, view, add, edit, delete).'),
'boolean' => true
))->addOption('admin', array(
'help' => __('Bake a controller with crud actions for one of the Routing.prefixes.'),
'help' => __d('cake_console', 'Bake a controller with crud actions for one of the Routing.prefixes.'),
'boolean' => true
))->addOption('plugin', array(
'short' => 'p',
'help' => __('Plugin to bake the controller into.')
'help' => __d('cake_console', 'Plugin to bake the controller into.')
))->addOption('connection', array(
'short' => 'c',
'help' => __('The connection the controller\'s model is on.')
'help' => __d('cake_console', 'The connection the controller\'s model is on.')
))->addSubcommand('all', array(
'help' => __('Bake all controllers with CRUD methods.')
))->epilog(__('Omitting all arguments and options will enter into an interactive mode.'));
'help' => __d('cake_console', 'Bake all controllers with CRUD methods.')
))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.'));
}
/**
@ -498,4 +499,4 @@ class ControllerTask extends BakeTask {
$this->out();
$this->_stop();
}
}
}

View file

@ -351,7 +351,7 @@ class DbConfigTask extends Shell {
* @return void
*/
public function getConfig() {
App::import('Model', 'ConnectionManager', false);
App::uses('ConnectionManager', 'Model');
$useDbConfig = 'default';
$configs = get_class_vars($this->databaseClassName);
@ -361,7 +361,7 @@ class DbConfigTask extends Shell {
$connections = array_keys($configs);
if (count($connections) > 1) {
$useDbConfig = $this->in(__('Use Database Config') .':', $connections, 'default');
$useDbConfig = $this->in(__d('cake_console', 'Use Database Config') .':', $connections, 'default');
}
return $useDbConfig;
}
@ -374,7 +374,7 @@ class DbConfigTask extends Shell {
public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(
__('Bake new database configuration settings.')
__d('cake_console', 'Bake new database configuration settings.')
);
}
}

View file

@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'File');
App::uses('File', 'Utility');
/**
* Language string extractor
*
@ -112,11 +112,11 @@ class ExtractTask extends Shell {
$this->__paths = explode(',', $this->params['paths']);
} else {
$defaultPath = APP_PATH;
$message = __("What is the full path you would like to extract?\nExample: %s\n[Q]uit [D]one", $this->Dispatch->params['root'] . DS . 'myapp');
$message = __d('cake_console', "What is the full path you would like to extract?\nExample: %s\n[Q]uit [D]one", $defaultPath);
while (true) {
$response = $this->in($message, null, $defaultPath);
if (strtoupper($response) === 'Q') {
$this->out(__('Extract Aborted'));
$this->out(__d('cake_console', 'Extract Aborted'));
$this->_stop();
} elseif (strtoupper($response) === 'D') {
$this->out();
@ -125,7 +125,7 @@ class ExtractTask extends Shell {
$this->__paths[] = $response;
$defaultPath = 'D';
} else {
$this->err(__('The directory path you supplied was not found. Please try again.'));
$this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.'));
}
$this->out();
}
@ -134,17 +134,17 @@ class ExtractTask extends Shell {
if (isset($this->params['output'])) {
$this->__output = $this->params['output'];
} else {
$message = __("What is the full path you would like to output?\nExample: %s\n[Q]uit", $this->__paths[0] . DS . 'locale');
$message = __d('cake_console', "What is the full path you would like to output?\nExample: %s\n[Q]uit", $this->__paths[0] . DS . 'locale');
while (true) {
$response = $this->in($message, null, $this->__paths[0] . DS . 'locale');
if (strtoupper($response) === 'Q') {
$this->out(__('Extract Aborted'));
$this->out(__d('cake_console', 'Extract Aborted'));
$this->_stop();
} elseif (is_dir($response)) {
$this->__output = $response . DS;
break;
} else {
$this->err(__('The directory path you supplied was not found. Please try again.'));
$this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.'));
}
$this->out();
}
@ -154,7 +154,7 @@ class ExtractTask extends Shell {
$this->__merge = !(strtolower($this->params['merge']) === 'no');
} else {
$this->out();
$response = $this->in(__('Would you like to merge all domains strings into the default.pot file?'), array('y', 'n'), 'n');
$response = $this->in(__d('cake_console', 'Would you like to merge all domains strings into the default.pot file?'), array('y', 'n'), 'n');
$this->__merge = strtolower($response) === 'y';
}
@ -173,13 +173,13 @@ class ExtractTask extends Shell {
function __extract() {
$this->out();
$this->out();
$this->out(__('Extracting...'));
$this->out(__d('cake_console', 'Extracting...'));
$this->hr();
$this->out(__('Paths:'));
$this->out(__d('cake_console', 'Paths:'));
foreach ($this->__paths as $path) {
$this->out(' ' . $path);
}
$this->out(__('Output Directory: ') . $this->__output);
$this->out(__d('cake_console', 'Output Directory: ') . $this->__output);
$this->hr();
$this->__extractTokens();
$this->__buildFiles();
@ -187,7 +187,7 @@ class ExtractTask extends Shell {
$this->__paths = $this->__files = $this->__storage = array();
$this->__strings = $this->__tokens = array();
$this->out();
$this->out(__('Done.'));
$this->out(__d('cake_console', 'Done.'));
}
/**
@ -197,17 +197,17 @@ class ExtractTask extends Shell {
*/
public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(__('CakePHP Language String Extraction:'))
->addOption('app', array('help' => __('Directory where your application is located.')))
->addOption('paths', array('help' => __('Comma separted list of paths, full paths are needed.')))
return $parser->description(__d('cake_console', 'CakePHP Language String Extraction:'))
->addOption('app', array('help' => __d('cake_console', 'Directory where your application is located.')))
->addOption('paths', array('help' => __d('cake_console', 'Comma separted list of paths, full paths are needed.')))
->addOption('merge', array(
'help' => __('Merge all domain strings into the default.po file.'),
'help' => __d('cake_console', 'Merge all domain strings into the default.po file.'),
'choices' => array('yes', 'no')
))
->addOption('output', array('help' => __('Full path to output directory.')))
->addOption('files', array('help' => __('Comma separated list of files, full paths are needed.')))
->addOption('output', array('help' => __d('cake_console', 'Full path to output directory.')))
->addOption('files', array('help' => __d('cake_console', 'Comma separated list of files, full paths are needed.')))
->addOption('exclude', array(
'help' => __('Comma separated list of directories to exclude. Any path containing a path segment with the provided values will be skipped. E.g. test,vendors')
'help' => __d('cake_console', 'Comma separated list of directories to exclude. Any path containing a path segment with the provided values will be skipped. E.g. test,vendors')
));
}
@ -217,25 +217,25 @@ class ExtractTask extends Shell {
* @return void
*/
public function help() {
$this->out(__('CakePHP Language String Extraction:'));
$this->out(__d('cake_console', 'CakePHP Language String Extraction:'));
$this->hr();
$this->out(__('The Extract script generates .pot file(s) with translations'));
$this->out(__('By default the .pot file(s) will be place in the locale directory of -app'));
$this->out(__('By default -app is ROOT/app'));
$this->out(__d('cake_console', 'The Extract script generates .pot file(s) with translations'));
$this->out(__d('cake_console', 'By default the .pot file(s) will be place in the locale directory of -app'));
$this->out(__d('cake_console', 'By default -app is ROOT/app'));
$this->hr();
$this->out(__('Usage: cake i18n extract <command> <param1> <param2>...'));
$this->out(__d('cake_console', 'Usage: cake i18n extract <command> <param1> <param2>...'));
$this->out();
$this->out(__('Params:'));
$this->out(__(' -app [path...]: directory where your application is located'));
$this->out(__(' -root [path...]: path to install'));
$this->out(__(' -core [path...]: path to cake directory'));
$this->out(__(' -paths [comma separated list of paths, full path is needed]'));
$this->out(__(' -merge [yes|no]: Merge all domains strings into the default.pot file'));
$this->out(__(' -output [path...]: Full path to output directory'));
$this->out(__(' -files: [comma separated list of files, full path to file is needed]'));
$this->out(__d('cake_console', 'Params:'));
$this->out(__d('cake_console', ' -app [path...]: directory where your application is located'));
$this->out(__d('cake_console', ' -root [path...]: path to install'));
$this->out(__d('cake_console', ' -core [path...]: path to cake directory'));
$this->out(__d('cake_console', ' -paths [comma separated list of paths, full path is needed]'));
$this->out(__d('cake_console', ' -merge [yes|no]: Merge all domains strings into the default.pot file'));
$this->out(__d('cake_console', ' -output [path...]: Full path to output directory'));
$this->out(__d('cake_console', ' -files: [comma separated list of files, full path to file is needed]'));
$this->out();
$this->out(__('Commands:'));
$this->out(__(' cake i18n extract help: Shows this help message.'));
$this->out(__d('cake_console', 'Commands:'));
$this->out(__d('cake_console', ' cake i18n extract help: Shows this help message.'));
$this->out();
}
@ -248,7 +248,7 @@ class ExtractTask extends Shell {
function __extractTokens() {
foreach ($this->__files as $file) {
$this->__file = $file;
$this->out(__('Processing %s...', $file));
$this->out(__d('cake_console', 'Processing %s...', $file));
$code = file_get_contents($file);
$allTokens = token_get_all($code);
@ -411,11 +411,11 @@ class ExtractTask extends Shell {
$response = '';
while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') {
$this->out();
$response = $this->in(__('Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll', $filename), array('y', 'n', 'a'), 'y');
$response = $this->in(__d('cake_console', 'Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll', $filename), array('y', 'n', 'a'), 'y');
if (strtoupper($response) === 'N') {
$response = '';
while ($response == '') {
$response = $this->in(__("What would you like to name this file?\nExample: %s", 'new_' . $filename), null, 'new_' . $filename);
$response = $this->in(__d('cake_console', "What would you like to name this file?\nExample: %s", 'new_' . $filename), null, 'new_' . $filename);
$File = new File($this->__output . $response);
$filename = $response;
}
@ -483,7 +483,7 @@ class ExtractTask extends Shell {
* @access private
*/
function __markerError($file, $line, $marker, $count) {
$this->out(__("Invalid marker content in %s:%s\n* %s(", $file, $line, $marker), true);
$this->out(__d('cake_console', "Invalid marker content in %s:%s\n* %s(", $file, $line, $marker), true);
$count += 2;
$tokenCount = count($this->__tokens);
$parenthesis = 1;

View file

@ -16,7 +16,10 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
include_once dirname(__FILE__) . DS . 'bake.php';
App::uses('BakeTask', 'Console/Command/Task');
App::uses('Model', 'Model');
/**
* Task class for creating and updating fixtures files.
*
@ -54,7 +57,7 @@ class FixtureTask extends BakeTask {
*/
public function __construct($stdout = null, $stderr = null, $stdin = null) {
parent::__construct($stdout, $stderr, $stdin);
$this->path = APP . 'tests' . DS . 'fixtures' . DS;
$this->path = APP . 'tests' . DS . 'Fixture' . DS;
}
/**
@ -65,25 +68,25 @@ class FixtureTask extends BakeTask {
public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(
__('Generate fixtures for use with the test suite. You can use `bake fixture all` to bake all fixtures.')
__d('cake_console', 'Generate fixtures for use with the test suite. You can use `bake fixture all` to bake all fixtures.')
)->addArgument('name', array(
'help' => __('Name of the fixture to bake. Can use Plugin.name to bake plugin fixtures.')
'help' => __d('cake_console', 'Name of the fixture to bake. Can use Plugin.name to bake plugin fixtures.')
))->addOption('count', array(
'help' => __('When using generated data, the number of records to include in the fixture(s).'),
'help' => __d('cake_console', 'When using generated data, the number of records to include in the fixture(s).'),
'short' => 'n',
'default' => 10
))->addOption('connection', array(
'help' => __('Which database configuration to use for baking.'),
'help' => __d('cake_console', 'Which database configuration to use for baking.'),
'short' => 'c',
'default' => 'default'
))->addOption('plugin', array(
'help' => __('CamelCased name of the plugin to bake fixtures for.'),
'help' => __d('cake_console', 'CamelCased name of the plugin to bake fixtures for.'),
'short' => 'p',
))->addOption('records', array(
'help' => 'Used with --count and <name>/all commands to pull [n] records from the live tables, where [n] is either --count or the default of 10',
'short' => 'r',
'boolean' => true
))->epilog(__('Omitting all arguments and options will enter into an interactive mode.'));;
))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.'));;
}
/**
@ -155,16 +158,16 @@ class FixtureTask extends BakeTask {
*/
public function importOptions($modelName) {
$options = array();
$doSchema = $this->in(__('Would you like to import schema for this fixture?'), array('y', 'n'), 'n');
$doSchema = $this->in(__d('cake_console', 'Would you like to import schema for this fixture?'), array('y', 'n'), 'n');
if ($doSchema == 'y') {
$options['schema'] = $modelName;
}
$doRecords = $this->in(__('Would you like to use record importing for this fixture?'), array('y', 'n'), 'n');
$doRecords = $this->in(__d('cake_console', 'Would you like to use record importing for this fixture?'), array('y', 'n'), 'n');
if ($doRecords == 'y') {
$options['records'] = true;
}
if ($doRecords == 'n') {
$prompt = __("Would you like to build this fixture with data from %s's table?", $modelName);
$prompt = __d('cake_console', "Would you like to build this fixture with data from %s's table?", $modelName);
$fromTable = $this->in($prompt, array('y', 'n'), 'n');
if (strtolower($fromTable) == 'y') {
$options['fromTable'] = true;
@ -182,9 +185,7 @@ class FixtureTask extends BakeTask {
* @return string Baked fixture content
*/
public function bake($model, $useTable = false, $importOptions = array()) {
if (!class_exists('CakeSchema')) {
App::import('Model', 'CakeSchema', false);
}
App::uses('CakeSchema', 'Model');
$table = $schema = $records = $import = $modelImport = null;
$importBits = array();
@ -248,7 +249,7 @@ class FixtureTask extends BakeTask {
$vars = array_merge($defaults, $otherVars);
$path = $this->getPath();
$filename = Inflector::underscore($model) . '_fixture.php';
$filename = Inflector::camelize($model) . 'Fixture.php';
$this->Template->set('model', $model);
$this->Template->set($vars);
@ -267,7 +268,7 @@ class FixtureTask extends BakeTask {
public function getPath() {
$path = $this->path;
if (isset($this->plugin)) {
$path = $this->_pluginPath($this->plugin) . 'tests' . DS . 'fixtures' . DS;
$path = $this->_pluginPath($this->plugin) . 'tests' . DS . 'Fixture' . DS;
}
return $path;
}
@ -386,14 +387,13 @@ class FixtureTask extends BakeTask {
protected function _getRecordsFromTable($modelName, $useTable = null) {
if ($this->interactive) {
$condition = null;
$prompt = __("Please provide a SQL fragment to use as conditions\nExample: WHERE 1=1 LIMIT 10");
$prompt = __d('cake_console', "Please provide a SQL fragment to use as conditions\nExample: WHERE 1=1 LIMIT 10");
while (!$condition) {
$condition = $this->in($prompt, null, 'WHERE 1=1 LIMIT 10');
}
} else {
$condition = 'WHERE 1=1 LIMIT ' . (isset($this->params['count']) ? $this->params['count'] : 10);
}
App::import('Model', 'Model', false);
$modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
$records = $modelObject->find('all', array(
'conditions' => $condition,

View file

@ -17,7 +17,10 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
include_once dirname(__FILE__) . DS . 'bake.php';
App::uses('BakeTask', 'Console/Command/Task');
App::uses('ConnectionManager', 'Model');
App::uses('Model', 'Model');
App::uses('Validation', 'Utility');
/**
* Task class for creating and updating model files.
@ -71,7 +74,6 @@ class ModelTask extends BakeTask {
*
*/
public function execute() {
App::import('Model', 'Model', false);
parent::execute();
if (empty($this->args)) {
@ -110,7 +112,7 @@ class ModelTask extends BakeTask {
continue;
}
$modelClass = Inflector::classify($table);
$this->out(__('Baking %s', $modelClass));
$this->out(__d('cake_console', 'Baking %s', $modelClass));
$object = $this->_getModelObject($modelClass);
if ($this->bake($object, false) && $unitTestExists) {
$this->bakeFixture($modelClass);
@ -149,7 +151,7 @@ class ModelTask extends BakeTask {
$this->out($i + 1 .'. ' . $option);
}
if (empty($prompt)) {
$prompt = __('Make a selection from the choices above');
$prompt = __d('cake_console', 'Make a selection from the choices above');
}
$choice = $this->in($prompt, null, $default);
if (intval($choice) > 0 && intval($choice) <= $max) {
@ -188,7 +190,7 @@ class ModelTask extends BakeTask {
$primaryKey = $this->findPrimaryKey($fields);
}
} else {
$this->err(__('Table %s does not exist, cannot bake a model without a table.', $useTable));
$this->err(__d('cake_console', 'Table %s does not exist, cannot bake a model without a table.', $useTable));
$this->_stop();
return false;
}
@ -197,13 +199,13 @@ class ModelTask extends BakeTask {
$displayField = $this->findDisplayField($tempModel->schema());
}
$prompt = __("Would you like to supply validation criteria \nfor the fields in your model?");
$prompt = __d('cake_console', "Would you like to supply validation criteria \nfor the fields in your model?");
$wannaDoValidation = $this->in($prompt, array('y','n'), 'y');
if (array_search($useTable, $this->_tables) !== false && strtolower($wannaDoValidation) == 'y') {
$validate = $this->doValidation($tempModel);
}
$prompt = __("Would you like to define model associations\n(hasMany, hasOne, belongsTo, etc.)?");
$prompt = __d('cake_console', "Would you like to define model associations\n(hasMany, hasOne, belongsTo, etc.)?");
$wannaDoAssoc = $this->in($prompt, array('y','n'), 'y');
if (strtolower($wannaDoAssoc) == 'y') {
$associations = $this->doAssociations($tempModel);
@ -211,24 +213,24 @@ class ModelTask extends BakeTask {
$this->out();
$this->hr();
$this->out(__('The following Model will be created:'));
$this->out(__d('cake_console', 'The following Model will be created:'));
$this->hr();
$this->out("Name: " . $currentModelName);
if ($this->connection !== 'default') {
$this->out(__("DB Config: %s", $this->connection));
$this->out(__d('cake_console', "DB Config: %s", $this->connection));
}
if ($fullTableName !== Inflector::tableize($currentModelName)) {
$this->out(__('DB Table: %s', $fullTableName));
$this->out(__d('cake_console', 'DB Table: %s', $fullTableName));
}
if ($primaryKey != 'id') {
$this->out(__('Primary Key: %s', $primaryKey));
$this->out(__d('cake_console', 'Primary Key: %s', $primaryKey));
}
if (!empty($validate)) {
$this->out(__('Validation: %s', print_r($validate, true)));
$this->out(__d('cake_console', 'Validation: %s', print_r($validate, true)));
}
if (!empty($associations)) {
$this->out(__('Associations:'));
$this->out(__d('cake_console', 'Associations:'));
$assocKeys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
foreach ($assocKeys as $assocKey) {
$this->_printAssociation($currentModelName, $assocKey, $associations);
@ -236,7 +238,7 @@ class ModelTask extends BakeTask {
}
$this->hr();
$looksGood = $this->in(__('Look okay?'), array('y','n'), 'y');
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y','n'), 'y');
if (strtolower($looksGood) == 'y') {
$vars = compact('associations', 'validate', 'primaryKey', 'useTable', 'displayField');
@ -281,7 +283,7 @@ class ModelTask extends BakeTask {
break;
}
}
return $this->in(__('What is the primaryKey?'), null, $name);
return $this->in(__d('cake_console', 'What is the primaryKey?'), null, $name);
}
/**
@ -292,12 +294,12 @@ class ModelTask extends BakeTask {
*/
public function findDisplayField($fields) {
$fieldNames = array_keys($fields);
$prompt = __("A displayField could not be automatically detected\nwould you like to choose one?");
$prompt = __d('cake_console', "A displayField could not be automatically detected\nwould you like to choose one?");
$continue = $this->in($prompt, array('y', 'n'));
if (strtolower($continue) == 'n') {
return false;
}
$prompt = __('Choose a field from the options above:');
$prompt = __d('cake_console', 'Choose a field from the options above:');
$choice = $this->inOptions($fieldNames, $prompt);
return $fieldNames[$choice];
}
@ -365,10 +367,10 @@ class ModelTask extends BakeTask {
while ($anotherValidator == 'y') {
if ($this->interactive) {
$this->out();
$this->out(__('Field: %s', $fieldName));
$this->out(__('Type: %s', $metaData['type']));
$this->out(__d('cake_console', 'Field: %s', $fieldName));
$this->out(__d('cake_console', 'Type: %s', $metaData['type']));
$this->hr();
$this->out(__('Please select one of the following validation options:'));
$this->out(__d('cake_console', 'Please select one of the following validation options:'));
$this->hr();
}
@ -376,8 +378,8 @@ class ModelTask extends BakeTask {
for ($i = 1; $i < $defaultChoice; $i++) {
$prompt .= $i . ' - ' . $this->_validations[$i] . "\n";
}
$prompt .= __("%s - Do not do any validation on this field.\n", $defaultChoice);
$prompt .= __("... or enter in a valid regex validation string.\n");
$prompt .= __d('cake_console', "%s - Do not do any validation on this field.\n", $defaultChoice);
$prompt .= __d('cake_console', "... or enter in a valid regex validation string.\n");
$methods = array_flip($this->_validations);
$guess = $defaultChoice;
@ -400,11 +402,11 @@ class ModelTask extends BakeTask {
if ($this->interactive === true) {
$choice = $this->in($prompt, null, $guess);
if (in_array($choice, $alreadyChosen)) {
$this->out(__("You have already chosen that validation rule,\nplease choose again"));
$this->out(__d('cake_console', "You have already chosen that validation rule,\nplease choose again"));
continue;
}
if (!isset($this->_validations[$choice]) && is_numeric($choice)) {
$this->out(__('Please make a valid selection.'));
$this->out(__d('cake_console', 'Please make a valid selection.'));
continue;
}
$alreadyChosen[] = $choice;
@ -426,7 +428,7 @@ class ModelTask extends BakeTask {
}
}
if ($this->interactive == true && $choice != $defaultChoice) {
$anotherValidator = $this->in(__('Would you like to add another validation rule?'), array('y', 'n'), 'n');
$anotherValidator = $this->in(__d('cake_console', 'Would you like to add another validation rule?'), array('y', 'n'), 'n');
} else {
$anotherValidator = 'n';
}
@ -445,7 +447,7 @@ class ModelTask extends BakeTask {
return false;
}
if ($this->interactive === true) {
$this->out(__('One moment while the associations are detected.'));
$this->out(__d('cake_console', 'One moment while the associations are detected.'));
}
$fields = $model->schema(true);
@ -473,9 +475,9 @@ class ModelTask extends BakeTask {
if ($this->interactive === true) {
$this->hr();
if (empty($associations)) {
$this->out(__('None found.'));
$this->out(__d('cake_console', 'None found.'));
} else {
$this->out(__('Please confirm the following associations:'));
$this->out(__d('cake_console', 'Please confirm the following associations:'));
$this->hr();
$associations = $this->confirmAssociations($model, $associations);
}
@ -632,19 +634,19 @@ class ModelTask extends BakeTask {
* @return array Array of associations.
*/
public function doMoreAssociations($model, $associations) {
$prompt = __('Would you like to define some additional model associations?');
$prompt = __d('cake_console', 'Would you like to define some additional model associations?');
$wannaDoMoreAssoc = $this->in($prompt, array('y','n'), 'n');
$possibleKeys = $this->_generatePossibleKeys();
while (strtolower($wannaDoMoreAssoc) == 'y') {
$assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
$this->out(__('What is the association type?'));
$assocType = intval($this->inOptions($assocs, __('Enter a number')));
$this->out(__d('cake_console', 'What is the association type?'));
$assocType = intval($this->inOptions($assocs, __d('cake_console', 'Enter a number')));
$this->out(__("For the following options be very careful to match your setup exactly.\nAny spelling mistakes will cause errors."));
$this->out(__d('cake_console', "For the following options be very careful to match your setup exactly.\nAny spelling mistakes will cause errors."));
$this->hr();
$alias = $this->in(__('What is the alias for this association?'));
$className = $this->in(__('What className will %s use?', $alias), null, $alias );
$alias = $this->in(__d('cake_console', 'What is the alias for this association?'));
$className = $this->in(__d('cake_console', 'What className will %s use?', $alias), null, $alias );
$suggestedForeignKey = null;
if ($assocType == 0) {
@ -659,22 +661,22 @@ class ModelTask extends BakeTask {
$showKeys = null;
}
} else {
$otherTable = $this->in(__('What is the table for this model?'));
$otherTable = $this->in(__d('cake_console', 'What is the table for this model?'));
$showKeys = $possibleKeys[$otherTable];
}
$suggestedForeignKey = $this->_modelKey($model->name);
}
if (!empty($showKeys)) {
$this->out(__('A helpful List of possible keys'));
$foreignKey = $this->inOptions($showKeys, __('What is the foreignKey?'));
$this->out(__d('cake_console', 'A helpful List of possible keys'));
$foreignKey = $this->inOptions($showKeys, __d('cake_console', 'What is the foreignKey?'));
$foreignKey = $showKeys[intval($foreignKey)];
}
if (!isset($foreignKey)) {
$foreignKey = $this->in(__('What is the foreignKey? Specify your own.'), null, $suggestedForeignKey);
$foreignKey = $this->in(__d('cake_console', 'What is the foreignKey? Specify your own.'), null, $suggestedForeignKey);
}
if ($assocType == 3) {
$associationForeignKey = $this->in(__('What is the associationForeignKey?'), null, $this->_modelKey($model->name));
$joinTable = $this->in(__('What is the joinTable?'));
$associationForeignKey = $this->in(__d('cake_console', 'What is the associationForeignKey?'), null, $this->_modelKey($model->name));
$joinTable = $this->in(__d('cake_console', 'What is the joinTable?'));
}
$associations[$assocs[$assocType]] = array_values((array)$associations[$assocs[$assocType]]);
$count = count($associations[$assocs[$assocType]]);
@ -686,7 +688,7 @@ class ModelTask extends BakeTask {
$associations[$assocs[$assocType]][$i]['associationForeignKey'] = $associationForeignKey;
$associations[$assocs[$assocType]][$i]['joinTable'] = $joinTable;
}
$wannaDoMoreAssoc = $this->in(__('Define another association?'), array('y','n'), 'y');
$wannaDoMoreAssoc = $this->in(__d('cake_console', 'Define another association?'), array('y','n'), 'y');
}
return $associations;
}
@ -739,7 +741,7 @@ class ModelTask extends BakeTask {
$out = $this->Template->generate('classes', 'model');
$path = $this->getPath();
$filename = $path . Inflector::underscore($name) . '.php';
$filename = $path . $name . '.php';
$this->out("\nBaking model class for $name...", 1, Shell::QUIET);
$this->createFile($filename, $out);
ClassRegistry::flush();
@ -767,7 +769,7 @@ class ModelTask extends BakeTask {
$this->_tables = $this->getAllTables($useDbConfig);
if ($this->interactive === true) {
$this->out(__('Possible Models based on your current database:'));
$this->out(__d('cake_console', 'Possible Models based on your current database:'));
$this->_modelNames = array();
$count = count($this->_tables);
for ($i = 0; $i < $count; $i++) {
@ -789,7 +791,6 @@ class ModelTask extends BakeTask {
if (!isset($useDbConfig)) {
$useDbConfig = $this->connection;
}
App::import('Model', 'ConnectionManager', false);
$db = ConnectionManager::getDataSource($useDbConfig);
$useTable = Inflector::tableize($modelName);
@ -798,11 +799,11 @@ class ModelTask extends BakeTask {
if (array_search($useTable, $this->_tables) === false) {
$this->out();
$this->out(__("Given your model named '%s',\nCake would expect a database table named '%s'", $modelName, $fullTableName));
$tableIsGood = $this->in(__('Do you want to use this table?'), array('y','n'), 'y');
$this->out(__d('cake_console', "Given your model named '%s',\nCake would expect a database table named '%s'", $modelName, $fullTableName));
$tableIsGood = $this->in(__d('cake_console', 'Do you want to use this table?'), array('y','n'), 'y');
}
if (strtolower($tableIsGood) == 'n') {
$useTable = $this->in(__('What is the name of the table?'));
$useTable = $this->in(__d('cake_console', 'What is the name of the table?'));
}
return $useTable;
}
@ -818,7 +819,6 @@ class ModelTask extends BakeTask {
if (!isset($useDbConfig)) {
$useDbConfig = $this->connection;
}
App::import('Model', 'ConnectionManager', false);
$tables = array();
$db = ConnectionManager::getDataSource($useDbConfig);
@ -834,7 +834,7 @@ class ModelTask extends BakeTask {
$tables = $db->listSources();
}
if (empty($tables)) {
$this->err(__('Your database does not have any tables.'));
$this->err(__d('cake_console', 'Your database does not have any tables.'));
$this->_stop();
}
return $tables;
@ -851,15 +851,15 @@ class ModelTask extends BakeTask {
$enteredModel = '';
while ($enteredModel == '') {
$enteredModel = $this->in(__("Enter a number from the list above,\ntype in the name of another model, or 'q' to exit"), null, 'q');
$enteredModel = $this->in(__d('cake_console', "Enter a number from the list above,\ntype in the name of another model, or 'q' to exit"), null, 'q');
if ($enteredModel === 'q') {
$this->out(__('Exit'));
$this->out(__d('cake_console', 'Exit'));
$this->_stop();
}
if ($enteredModel == '' || intval($enteredModel) > count($this->_modelNames)) {
$this->err(__("The model name you supplied was empty,\nor the number you selected was not an option. Please try again."));
$this->err(__d('cake_console', "The model name you supplied was empty,\nor the number you selected was not an option. Please try again."));
$enteredModel = '';
}
}
@ -879,18 +879,18 @@ class ModelTask extends BakeTask {
public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(
__('Bake models.')
__d('cake_console', 'Bake models.')
)->addArgument('name', array(
'help' => __('Name of the model to bake. Can use Plugin.name to bake plugin models.')
'help' => __d('cake_console', 'Name of the model to bake. Can use Plugin.name to bake plugin models.')
))->addSubcommand('all', array(
'help' => __('Bake all model files with associations and validation.')
'help' => __d('cake_console', 'Bake all model files with associations and validation.')
))->addOption('plugin', array(
'short' => 'p',
'help' => __('Plugin to bake the model into.')
'help' => __d('cake_console', 'Plugin to bake the model into.')
))->addOption('connection', array(
'short' => 'c',
'help' => __('The connection the model table is on.')
))->epilog(__('Omitting all arguments and options will enter into an interactive mode.'));
'help' => __d('cake_console', 'The connection the model table is on.')
))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.'));
}
/**

View file

@ -16,7 +16,9 @@
* @since CakePHP(tm) v 1.2
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'File');
App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
/**
* Task class for creating a plugin
@ -54,8 +56,8 @@ class PluginTask extends Shell {
$plugin = Inflector::camelize($this->args[0]);
$pluginPath = $this->_pluginPath($plugin);
if (is_dir($pluginPath)) {
$this->out(__('Plugin: %s', $plugin));
$this->out(__('Path: %s', $pluginPath));
$this->out(__d('cake_console', 'Plugin: %s', $plugin));
$this->out(__d('cake_console', 'Path: %s', $pluginPath));
} else {
$this->_interactive($plugin);
}
@ -72,11 +74,11 @@ class PluginTask extends Shell {
*/
protected function _interactive($plugin = null) {
while ($plugin === null) {
$plugin = $this->in(__('Enter the name of the plugin in CamelCase format'));
$plugin = $this->in(__d('cake_console', 'Enter the name of the plugin in CamelCase format'));
}
if (!$this->bake($plugin)) {
$this->error(__("An error occured trying to bake: %s in %s", $plugin, $this->path . Inflector::underscore($pluginPath)));
$this->error(__d('cake_console', "An error occured trying to bake: %s in %s", $plugin, $this->path . Inflector::underscore($pluginPath)));
}
}
@ -95,11 +97,11 @@ class PluginTask extends Shell {
$this->findPath($pathOptions);
}
$this->hr();
$this->out(__("<info>Plugin Name:</info> %s", $plugin));
$this->out(__("<info>Plugin Directory:</info> %s", $this->path . $pluginPath));
$this->out(__d('cake_console', "<info>Plugin Name:</info> %s", $plugin));
$this->out(__d('cake_console', "<info>Plugin Directory:</info> %s", $this->path . $pluginPath));
$this->hr();
$looksGood = $this->in(__('Look okay?'), array('y', 'n', 'q'), 'y');
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n', 'q'), 'y');
if (strtolower($looksGood) == 'y') {
$Folder = new Folder($this->path . $pluginPath);
@ -154,7 +156,7 @@ class PluginTask extends Shell {
$this->createFile($this->path . $pluginPath . DS . $modelFileName, $out);
$this->hr();
$this->out(__('<success>Created:</success> %s in %s', $plugin, $this->path . $pluginPath), 2);
$this->out(__d('cake_console', '<success>Created:</success> %s in %s', $plugin, $this->path . $pluginPath), 2);
}
return true;
@ -172,7 +174,7 @@ class PluginTask extends Shell {
foreach ($pathOptions as $i => $option) {
$this->out($i + 1 .'. ' . $option);
}
$prompt = __('Choose a plugin path from the paths above.');
$prompt = __d('cake_console', 'Choose a plugin path from the paths above.');
$choice = $this->in($prompt);
if (intval($choice) > 0 && intval($choice) <= $max) {
$valid = true;
@ -192,7 +194,7 @@ class PluginTask extends Shell {
'Create the directory structure, AppModel and AppController classes for a new plugin. ' .
'Can create plugins in any of your bootstrapped plugin paths.'
)->addArgument('name', array(
'help' => __('CamelCased name of the plugin to create.')
'help' => __d('cake_console', 'CamelCased name of the plugin to create.')
));
}

View file

@ -17,7 +17,10 @@
* @since CakePHP(tm) v 1.2
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'File');
App::uses('File', 'Utility');
App::uses('String', 'Utility');
App::uses('Security', 'Utility');
/**
* Task class for creating new project apps and plugins
@ -49,16 +52,8 @@ class ProjectTask extends Shell {
$project = $_SERVER['PWD'] . DS . $project;
}
if (empty($this->params['skel'])) {
$core = App::core('shells');
$skelPath = dirname($core[0]) . DS . 'templates' . DS . 'skel';
if (is_dir($skelPath) === true) {
$this->params['skel'] = $skelPath;
}
}
while (!$project) {
$prompt = __("What is the full path for this app including the app directory name?\n Example:");
$prompt = __d('cake_console', "What is the full path for this app including the app directory name?\n Example:");
$default = APP_PATH . 'myapp';
$project = $this->in($prompt . $default, null, $default);
}
@ -66,7 +61,7 @@ class ProjectTask extends Shell {
if ($project) {
$response = false;
while ($response == false && is_dir($project) === true && file_exists($project . 'config' . 'core.php')) {
$prompt = __('<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
$prompt = __d('cake_console', '<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
$response = $this->in($prompt, array('y','n'), 'n');
if (strtolower($response) === 'n') {
$response = $project = false;
@ -78,51 +73,51 @@ class ProjectTask extends Shell {
if ($this->bake($project)) {
$path = Folder::slashTerm($project);
if ($this->createHome($path)) {
$this->out(__(' * Welcome page created'));
$this->out(__d('cake_console', ' * Welcome page created'));
} else {
$this->err(__('The Welcome page was <error>NOT</error> created'));
$this->err(__d('cake_console', 'The Welcome page was <error>NOT</error> created'));
$success = false;
}
if ($this->securitySalt($path) === true) {
$this->out(__(' * Random hash key created for \'Security.salt\''));
$this->out(__d('cake_console', ' * Random hash key created for \'Security.salt\''));
} else {
$this->err(__('Unable to generate random hash for \'Security.salt\', you should change it in %s', CONFIGS . 'core.php'));
$this->err(__d('cake_console', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', CONFIGS . 'core.php'));
$success = false;
}
if ($this->securityCipherSeed($path) === true) {
$this->out(__(' * Random seed created for \'Security.cipherSeed\''));
$this->out(__d('cake_console', ' * Random seed created for \'Security.cipherSeed\''));
} else {
$this->err(__('Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', CONFIGS . 'core.php'));
$this->err(__d('cake_console', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', CONFIGS . 'core.php'));
$success = false;
}
if ($this->corePath($path) === true) {
$this->out(__(' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH));
$this->out(__(' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH));
$this->out(__(' * <warning>Remember to check these value after moving to production server</warning>'));
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH));
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH));
$this->out(__d('cake_console', ' * <warning>Remember to check these value after moving to production server</warning>'));
} else {
$this->err(__('Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' .DS .'index.php'));
$this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' .DS .'index.php'));
$success = false;
}
if ($this->consolePath($path) === true) {
$this->out(__(' * app/console/cake.php path set.'));
$this->out(__d('cake_console', ' * app/Console/cake.php path set.'));
} else {
$this->err(__('Unable to set console path for app/console.'));
$this->err(__d('cake_console', 'Unable to set console path for app/Console.'));
$success = false;
}
$Folder = new Folder($path);
if (!$Folder->chmod($path . 'tmp', 0777)) {
$this->err(__('Could not set permissions on %s', $path . DS .'tmp'));
$this->out(__('chmod -R 0777 %s', $path . DS .'tmp'));
$this->err(__d('cake_console', 'Could not set permissions on %s', $path . DS .'tmp'));
$this->out(__d('cake_console', 'chmod -R 0777 %s', $path . DS .'tmp'));
$success = false;
}
if ($success) {
$this->out(__('<success>Project baked successfully!</success>'));
$this->out(__d('cake_console', '<success>Project baked successfully!</success>'));
} else {
$this->out(__('Project baked but with <warning>some issues.</warning>.'));
$this->out(__d('cake_console', 'Project baked but with <warning>some issues.</warning>.'));
}
return $path;
}
@ -144,23 +139,23 @@ class ProjectTask extends Shell {
$skel = $this->params['skel'];
}
while (!$skel) {
$skel = $this->in(__("What is the path to the directory layout you wish to copy?\nExample: %s", APP, null, ROOT . DS . 'myapp' . DS));
$skel = $this->in(__d('cake_console', "What is the path to the directory layout you wish to copy?\nExample: %s", APP, null, ROOT . DS . 'myapp' . DS));
if ($skel == '') {
$this->err(__('The directory path you supplied was empty. Please try again.'));
$this->err(__d('cake_console', 'The directory path you supplied was empty. Please try again.'));
} else {
while (is_dir($skel) === false) {
$skel = $this->in(__('Directory path does not exist please choose another:'));
$skel = $this->in(__d('cake_console', 'Directory path does not exist please choose another:'));
}
}
}
$app = basename($path);
$this->out(__('<info>Skel Directory</info>: ') . $skel);
$this->out(__('<info>Will be copied to</info>: ') . $path);
$this->out(__d('cake_console', '<info>Skel Directory</info>: ') . $skel);
$this->out(__d('cake_console', '<info>Will be copied to</info>: ') . $path);
$this->hr();
$looksGood = $this->in(__('Look okay?'), array('y', 'n', 'q'), 'y');
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n', 'q'), 'y');
if (strtolower($looksGood) == 'y') {
$Folder = new Folder($skel);
@ -170,10 +165,10 @@ class ProjectTask extends Shell {
if ($Folder->copy(array('to' => $path, 'skip' => $skip))) {
$this->hr();
$this->out(__('<success>Created:</success> %s in %s', $app, $path));
$this->out(__d('cake_console', '<success>Created:</success> %s in %s', $app, $path));
$this->hr();
} else {
$this->err(__("<error>Could not create</error> '%s' properly.", $app));
$this->err(__d('cake_console', "<error>Could not create</error> '%s' properly.", $app));
return false;
}
@ -183,7 +178,7 @@ class ProjectTask extends Shell {
return true;
} elseif (strtolower($looksGood) == 'q') {
$this->out(__('Bake Aborted.'));
$this->out(__d('cake_console', 'Bake Aborted.'));
} else {
$this->execute(false);
return false;
@ -199,7 +194,7 @@ class ProjectTask extends Shell {
public function createHome($dir) {
$app = basename($dir);
$path = $dir . 'views' . DS . 'pages' . DS;
$source = CAKE . 'console' . DS . 'templates' . DS .'default' . DS . 'views' . DS . 'home.ctp';
$source = LIBS . 'Console' . DS . 'templates' . DS .'default' . DS . 'views' . DS . 'home.ctp';
include($source);
return $this->createFile($path.'home.ctp', $output);
}
@ -212,10 +207,10 @@ class ProjectTask extends Shell {
* @return boolean success
*/
public function consolePath($path) {
$File = new File($path . 'console' . DS . 'cake.php');
$File = new File($path . 'Console' . DS . 'cake.php');
$contents = $File->read();
if (preg_match('/(__CAKE_PATH__)/', $contents, $match)) {
$path = CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS;
$path = LIBS . 'Console' . DS;
$replacement = "'" . str_replace(DS, "' . DIRECTORY_SEPARATOR . '", $path) . "'";
$result = str_replace($match[0], $replacement, $contents);
if ($File->write($result)) {
@ -236,9 +231,6 @@ class ProjectTask extends Shell {
$File = new File($path . 'config' . DS . 'core.php');
$contents = $File->read();
if (preg_match('/([\s]*Configure::write\(\'Security.salt\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
if (!class_exists('Security')) {
require LIBS . 'security.php';
}
$string = Security::generateAuthKey();
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \''.$string.'\');', $contents);
if ($File->write($result)) {
@ -260,7 +252,7 @@ class ProjectTask extends Shell {
$contents = $File->read();
if (preg_match('/([\s]*Configure::write\(\'Security.cipherSeed\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
if (!class_exists('Security')) {
require LIBS . 'security.php';
require LIBS . 'Utility' . DS . 'security.php';
}
$string = substr(bin2hex(Security::generateAuthKey()), 0, 30);
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.cipherSeed\', \''.$string.'\');', $contents);
@ -343,7 +335,7 @@ class ProjectTask extends Shell {
}
if ($this->interactive) {
$this->out();
$this->out(__('You have more than one routing prefix configured'));
$this->out(__d('cake_console', 'You have more than one routing prefix configured'));
}
$options = array();
foreach ($prefixes as $i => $prefix) {
@ -352,19 +344,19 @@ class ProjectTask extends Shell {
$this->out($i + 1 . '. ' . $prefix);
}
}
$selection = $this->in(__('Please choose a prefix to bake with.'), $options, 1);
$selection = $this->in(__d('cake_console', 'Please choose a prefix to bake with.'), $options, 1);
return $prefixes[$selection - 1] . '_';
}
if ($this->interactive) {
$this->hr();
$this->out('You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.');
$this->out(__('What would you like the prefix route to be?'));
$this->out(__('Example: www.example.com/admin/controller'));
$this->out(__d('cake_console', 'What would you like the prefix route to be?'));
$this->out(__d('cake_console', 'Example: www.example.com/admin/controller'));
while ($admin == '') {
$admin = $this->in(__('Enter a routing prefix:'), null, 'admin');
$admin = $this->in(__d('cake_console', 'Enter a routing prefix:'), null, 'admin');
}
if ($this->cakeAdmin($admin) !== true) {
$this->out(__('<error>Unable to write to</error> /app/config/core.php.'));
$this->out(__d('cake_console', '<error>Unable to write to</error> /app/config/core.php.'));
$this->out('You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.');
$this->_stop();
}
@ -381,13 +373,14 @@ class ProjectTask extends Shell {
public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(
__('Generate a new CakePHP project skeleton.')
__d('cake_console', 'Generate a new CakePHP project skeleton.')
)->addArgument('name', array(
'help' => __('Application directory to make, if it starts with "/" the path is absolute.')
'help' => __d('cake_console', 'Application directory to make, if it starts with "/" the path is absolute.')
))->addOption('empty', array(
'help' => __('Create empty files in each of the directories. Good if you are using git')
'help' => __d('cake_console', 'Create empty files in each of the directories. Good if you are using git')
))->addOption('skel', array(
'help' => __('The directory layout to use for the new application skeleton. Defaults to cake/console/templates/skel of CakePHP used to create the project.')
'default' => current(App::core('Console')) . DS . 'templates' . DS . 'skel',
'help' => __d('cake_console', 'The directory layout to use for the new application skeleton. Defaults to cake/console/templates/skel of CakePHP used to create the project.')
));
}

View file

@ -16,7 +16,8 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'Folder');
App::uses('Folder', 'Utility');
class TemplateTask extends Shell {
@ -53,8 +54,8 @@ class TemplateTask extends Shell {
* @return array Array of bake themes that are installed.
*/
protected function _findThemes() {
$paths = App::path('shells');
$core = array_pop($paths);
$paths = App::path('Console');
$core = current(App::core('Console'));
$separator = DS === '/' ? '/' : '\\\\';
$core = preg_replace('#shells' . $separator . '$#', '', $core);
@ -169,8 +170,8 @@ class TemplateTask extends Shell {
}
$this->hr();
$this->out(__('You have more than one set of templates installed.'));
$this->out(__('Please choose the template set you wish to use:'));
$this->out(__d('cake_console', 'You have more than one set of templates installed.'));
$this->out(__d('cake_console', 'Please choose the template set you wish to use:'));
$this->hr();
$i = 1;
@ -180,7 +181,7 @@ class TemplateTask extends Shell {
$indexedPaths[$i] = $path;
$i++;
}
$index = $this->in(__('Which bake theme would you like to use?'), range(1, $i - 1), 1);
$index = $this->in(__d('cake_console', 'Which bake theme would you like to use?'), range(1, $i - 1), 1);
$themeNames = array_keys($this->templatePaths);
$this->params['theme'] = $themeNames[$index - 1];
return $indexedPaths[$index];
@ -207,7 +208,7 @@ class TemplateTask extends Shell {
return $templatePath;
}
}
$this->err(__('Could not find template for %s', $filename));
$this->err(__d('cake_console', 'Could not find template for %s', $filename));
return false;
}
}

View file

@ -17,8 +17,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
include_once dirname(__FILE__) . DS . 'bake.php';
App::import('Model', 'ClassRegistry');
App::uses('BakeTask', 'Console/Command/Task');
App::uses('ClassRegistry', 'Utility');
/**
* Task class for creating and updating test files.
@ -49,7 +49,13 @@ class TestTask extends BakeTask {
* @var array
* @access public
*/
public $classTypes = array('Model', 'Controller', 'Component', 'Behavior', 'Helper');
public $classTypes = array(
'Model' => 'Model',
'Controller' => 'Controller',
'Component' => 'Controller/Component',
'Behavior' => 'Model/Behavior',
'Helper' => 'View/Helper'
);
/**
* Internal list of fixtures that have been added so far.
@ -89,14 +95,14 @@ class TestTask extends BakeTask {
protected function _interactive($type = null) {
$this->interactive = true;
$this->hr();
$this->out(__('Bake Tests'));
$this->out(__('Path: %s', $this->path));
$this->out(__d('cake_console', 'Bake Tests'));
$this->out(__d('cake_console', 'Path: %s', $this->path));
$this->hr();
if ($type) {
$type = Inflector::camelize($type);
if (!in_array($type, $this->classTypes)) {
$this->error(__('Incorrect type provided. Please choose one of %s', implode(', ', $this->classTypes)));
if (!isset($this->classTypes[$type])) {
$this->error(__d('cake_console', 'Incorrect type provided. Please choose one of %s', implode(', ', array_keys($this->classTypes))));
}
} else {
$type = $this->getObjectType();
@ -113,13 +119,17 @@ class TestTask extends BakeTask {
*/
public function bake($type, $className) {
if ($this->typeCanDetectFixtures($type) && $this->isLoadableClass($type, $className)) {
$this->out(__('Bake is detecting possible fixtures...'));
$this->out(__d('cake_console', 'Bake is detecting possible fixtures...'));
$testSubject = $this->buildTestSubject($type, $className);
$this->generateFixtureList($testSubject);
} elseif ($this->interactive) {
$this->getUserFixtures();
}
$fullClassName = $this->getRealClassName($type, $className);
$fullClassName = $className;
if (!$this->interactive) {
$fullClassName = $this->getRealClassName($type, $className);
}
$methods = array();
if (class_exists($fullClassName)) {
@ -154,20 +164,22 @@ class TestTask extends BakeTask {
*/
public function getObjectType() {
$this->hr();
$this->out(__('Select an object type:'));
$this->out(__d('cake_console', 'Select an object type:'));
$this->hr();
$keys = array();
foreach ($this->classTypes as $key => $option) {
$this->out(++$key . '. ' . $option);
$keys[] = $key;
$i = 0;
foreach ($this->classTypes as $option => $package) {
$this->out(++$i . '. ' . $option);
$keys[] = $i;
}
$keys[] = 'q';
$selection = $this->in(__('Enter the type of object to bake a test for or (q)uit'), $keys, 'q');
$selection = $this->in(__d('cake_console', 'Enter the type of object to bake a test for or (q)uit'), $keys, 'q');
if ($selection == 'q') {
return $this->_stop();
}
return $this->classTypes[$selection - 1];
$types = array_keys($this->classTypes);
return $types[$selection - 1];
}
/**
@ -181,23 +193,24 @@ class TestTask extends BakeTask {
if ($this->plugin) {
$path = Inflector::pluralize($type);
if ($type === 'helper') {
$path = 'views' . DS . $path;
$path = 'View/Helper';
} elseif ($type === 'component') {
$path = 'controllers' . DS . $path;
$path = 'Controller/Component';
} elseif ($type === 'behavior') {
$path = 'models' . DS . $path;
$path = 'Model/Behavior';
}
$options = App::objects($type, App::pluginPath($this->plugin) . $path, false);
$plugin = $this->plugin . '.';
$options = App::objects($plugin . $type);
} else {
$options = App::objects($type);
}
$this->out(__('Choose a %s class', $objectType));
$this->out(__d('cake_console', 'Choose a %s class', $objectType));
$keys = array();
foreach ($options as $key => $option) {
$this->out(++$key . '. ' . $option);
$keys[] = $key;
}
$selection = $this->in(__('Choose an existing class, or enter the name of a class that does not exist'));
$selection = $this->in(__d('cake_console', 'Choose an existing class, or enter the name of a class that does not exist'));
if (isset($options[$selection - 1])) {
return $options[$selection - 1];
}
@ -256,7 +269,7 @@ class TestTask extends BakeTask {
* @return string Real classname
*/
public function getRealClassName($type, $class) {
if (strtolower($type) == 'model') {
if (strtolower($type) == 'model' || empty($this->classTypes[$type])) {
return $class;
}
return $class . $type;
@ -365,10 +378,10 @@ class TestTask extends BakeTask {
* @return array Array of fixtures the user wants to add.
*/
public function getUserFixtures() {
$proceed = $this->in(__('Bake could not detect fixtures, would you like to add some?'), array('y','n'), 'n');
$proceed = $this->in(__d('cake_console', 'Bake could not detect fixtures, would you like to add some?'), array('y','n'), 'n');
$fixtures = array();
if (strtolower($proceed) == 'y') {
$fixtureList = $this->in(__("Please provide a comma separated list of the fixtures names you'd like to use.\nExample: 'app.comment, app.post, plugin.forums.post'"));
$fixtureList = $this->in(__d('cake_console', "Please provide a comma separated list of the fixtures names you'd like to use.\nExample: 'app.comment, app.post, plugin.forums.post'"));
$fixtureListTrimmed = str_replace(' ', '', $fixtureList);
$fixtures = explode(',', $fixtureListTrimmed);
}
@ -416,12 +429,14 @@ class TestTask extends BakeTask {
* @return string filename the test should be created on.
*/
public function testCaseFileName($type, $className) {
$path = $this->getPath();;
$path .= 'cases' . DS . strtolower($type) . 's' . DS;
if (strtolower($type) == 'controller') {
$path = $this->getPath() . 'Case' . DS;
if (isset($this->classTypes[$type])) {
$path .= $this->classTypes[$type] . DS;
}
if (!$this->interactive) {
$className = $this->getRealClassName($type, $className);
}
return $path . Inflector::underscore($className) . '.test.php';
return $path . Inflector::camelize($className) . 'Test.php';
}
/**
@ -431,15 +446,29 @@ class TestTask extends BakeTask {
*/
public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(__('Bake test case skeletons for classes.'))
return $parser->description(__d('cake_console', 'Bake test case skeletons for classes.'))
->addArgument('type', array(
'help' => __('Type of class to bake, can be any of the following: controller, model, helper, component or behavior.'),
'help' => __d('cake_console', 'Type of class to bake, can be any of the following: controller, model, helper, component or behavior.'),
'choices' => array('controller', 'model', 'helper', 'component', 'behavior')
))->addArgument('name', array(
'help' => __('An existing class to bake tests for.')
'help' => __d('cake_console', 'An existing class to bake tests for.')
))->addOption('plugin', array(
'short' => 'p',
'help' => __('CamelCased name of the plugin to bake tests for.')
))->epilog(__('Omitting all arguments and options will enter into an interactive mode.'));
'help' => __d('cake_console', 'CamelCased name of the plugin to bake tests for.')
))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.'));
}
/**
* Gets the path for output. Checks the plugin property
* and returns the correct path.
*
* @return string Path to output.
*/
public function getPath() {
$path = $this->path;
if (isset($this->plugin)) {
$path = $this->_pluginPath($this->plugin) . 'tests' . DS;
}
return $path;
}
}

View file

@ -16,8 +16,9 @@
* @since CakePHP(tm) v 1.2
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Controller', 'Controller', false);
include_once dirname(__FILE__) . DS . 'bake.php';
App::uses('Controller', 'Controller');
App::uses('BakeTask', 'Console/Command/Task');
/**
* Task class for creating and updating view files.
@ -146,7 +147,7 @@ class ViewTask extends BakeTask {
protected function _methodsToBake() {
$methods = array_diff(
array_map('strtolower', get_class_methods($this->controllerName . 'Controller')),
array_map('strtolower', get_class_methods('appcontroller'))
array_map('strtolower', get_class_methods('AppController'))
);
$scaffoldActions = false;
if (empty($methods)) {
@ -188,7 +189,8 @@ class ViewTask extends BakeTask {
$model = $this->_modelName($table);
$this->controllerName = $this->_controllerName($model);
$this->controllerPath = Inflector::underscore($this->controllerName);
if (App::import('Model', $model)) {
App::uses($model, 'Model');
if (class_exists($model)) {
$vars = $this->__loadController();
if (!$actions) {
$actions = $this->_methodsToBake();
@ -219,17 +221,17 @@ class ViewTask extends BakeTask {
$this->controllerPath = strtolower(Inflector::underscore($this->controllerName));
$prompt = __("Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite %s views if it exist.", $this->controllerName);
$prompt = __d('cake_console', "Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite %s views if it exist.", $this->controllerName);
$interactive = $this->in($prompt, array('y', 'n'), 'n');
if (strtolower($interactive) == 'n') {
$this->interactive = false;
}
$prompt = __("Would you like to create some CRUD views\n(index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller\nand model classes (including associated models).");
$prompt = __d('cake_console', "Would you like to create some CRUD views\n(index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller\nand model classes (including associated models).");
$wannaDoScaffold = $this->in($prompt, array('y','n'), 'y');
$wannaDoAdmin = $this->in(__("Would you like to create the views for admin routing?"), array('y','n'), 'n');
$wannaDoAdmin = $this->in(__d('cake_console', "Would you like to create the views for admin routing?"), array('y','n'), 'n');
if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoAdmin) == 'y') {
$vars = $this->__loadController();
@ -248,7 +250,7 @@ class ViewTask extends BakeTask {
}
$this->hr();
$this->out();
$this->out(__("View Scaffolding Complete.\n"));
$this->out(__d('cake_console', "View Scaffolding Complete.\n"));
} else {
$this->customAction();
}
@ -266,20 +268,21 @@ class ViewTask extends BakeTask {
*/
private function __loadController() {
if (!$this->controllerName) {
$this->err(__('Controller not found'));
$this->err(__d('cake_console', 'Controller not found'));
}
$import = $this->controllerName;
$plugin = null;
if ($this->plugin) {
$import = $this->plugin . '.' . $this->controllerName;
$plugin = $this->plugin . '.';
}
if (!App::import('Controller', $import)) {
$file = $this->controllerPath . '_controller.php';
$this->err(__("The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file));
$controllerClassName = $this->controllerName . 'Controller';
App::uses($controllerClassName, $plugin . 'Controller');
if (!class_exists($controllerClassName)) {
$file = $controllerClassName . '.php';
$this->err(__d('cake_console', "The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file));
$this->_stop();
}
$controllerClassName = $this->controllerName . 'Controller';
$controllerObj = new $controllerClassName();
$controllerObj->plugin = $this->plugin;
$controllerObj->constructClasses();
@ -328,25 +331,25 @@ class ViewTask extends BakeTask {
public function customAction() {
$action = '';
while ($action == '') {
$action = $this->in(__('Action Name? (use lowercase_underscored function name)'));
$action = $this->in(__d('cake_console', 'Action Name? (use lowercase_underscored function name)'));
if ($action == '') {
$this->out(__('The action name you supplied was empty. Please try again.'));
$this->out(__d('cake_console', 'The action name you supplied was empty. Please try again.'));
}
}
$this->out();
$this->hr();
$this->out(__('The following view will be created:'));
$this->out(__d('cake_console', 'The following view will be created:'));
$this->hr();
$this->out(__('Controller Name: %s', $this->controllerName));
$this->out(__('Action Name: %s', $action));
$this->out(__('Path: %s', $this->params['app'] . DS . $this->controllerPath . DS . Inflector::underscore($action) . ".ctp"));
$this->out(__d('cake_console', 'Controller Name: %s', $this->controllerName));
$this->out(__d('cake_console', 'Action Name: %s', $action));
$this->out(__d('cake_console', 'Path: %s', $this->params['app'] . DS . $this->controllerPath . DS . Inflector::underscore($action) . ".ctp"));
$this->hr();
$looksGood = $this->in(__('Look okay?'), array('y','n'), 'y');
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y','n'), 'y');
if (strtolower($looksGood) == 'y') {
$this->bake($action, ' ');
$this->_stop();
} else {
$this->out(__('Bake Aborted.'));
$this->out(__d('cake_console', 'Bake Aborted.'));
}
}
@ -428,25 +431,25 @@ class ViewTask extends BakeTask {
public function getOptionParser() {
$parser = parent::getOptionParser();
return $parser->description(
__('Bake views for a controller, using built-in or custom templates.')
__d('cake_console', 'Bake views for a controller, using built-in or custom templates.')
)->addArgument('controller', array(
'help' => __('Name of the controller views to bake. Can be Plugin.name as a shortcut for plugin baking.')
'help' => __d('cake_console', 'Name of the controller views to bake. Can be Plugin.name as a shortcut for plugin baking.')
))->addArgument('action', array(
'help' => __("Will bake a single action's file. core templates are (index, add, edit, view)")
'help' => __d('cake_console', "Will bake a single action's file. core templates are (index, add, edit, view)")
))->addArgument('alias', array(
'help' => __('Will bake the template in <action> but create the filename after <alias>.')
'help' => __d('cake_console', 'Will bake the template in <action> but create the filename after <alias>.')
))->addOption('plugin', array(
'short' => 'p',
'help' => __('Plugin to bake the view into.')
'help' => __d('cake_console', 'Plugin to bake the view into.')
))->addOption('admin', array(
'help' => __('Set to only bake views for a prefix in Routing.prefixes'),
'help' => __d('cake_console', 'Set to only bake views for a prefix in Routing.prefixes'),
'boolean' => true
))->addOption('connection', array(
'short' => 'c',
'help' => __('The connection the connected model is on.')
'help' => __d('cake_console', 'The connection the connected model is on.')
))->addSubcommand('all', array(
'help' => __('Bake all CRUD action views for all controllers. Requires models and controllers to exist.')
))->epilog(__('Omitting all arguments and options will enter into an interactive mode.'));
'help' => __d('cake_console', 'Bake all CRUD action views for all controllers. Requires models and controllers to exist.')
))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.'));
}
/**

View file

@ -18,7 +18,13 @@
* @since CakePHP(tm) v 1.2.0.4433
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class TestSuiteShell extends Shell {
App::uses('Shell', 'Console');
App::uses('CakeTestSuiteDispatcher', 'TestSuite');
App::uses('CakeTestSuiteCommand', 'TestSuite');
App::uses('CakeTestLoader', 'TestSuite');
class TestsuiteShell extends Shell {
/**
* Dispatcher object for the run.
@ -38,113 +44,113 @@ class TestSuiteShell extends Shell {
'The CakePHP Testsuite allows you to run test cases from the command line',
'If run with no command line arguments, a list of available core test cases will be shown'
))->addArgument('category', array(
'help' => __('app, core or name of a plugin.'),
'help' => __d('cake_console', 'app, core or name of a plugin.'),
'required' => true
))->addArgument('file', array(
'help' => __('file name with folder prefix and without the test.php suffix.'),
'help' => __d('cake_console', 'file name with folder prefix and without the test.php suffix.'),
'required' => false,
))->addOption('log-junit', array(
'help' => __('<file> Log test execution in JUnit XML format to file.'),
'help' => __d('cake_console', '<file> Log test execution in JUnit XML format to file.'),
'default' => false
))->addOption('log-json', array(
'help' => __('<file> Log test execution in TAP format to file.'),
'help' => __d('cake_console', '<file> Log test execution in TAP format to file.'),
'default' => false
))->addOption('log-tap', array(
'help' => __('<file> Log test execution in TAP format to file.'),
'help' => __d('cake_console', '<file> Log test execution in TAP format to file.'),
'default' => false
))->addOption('log-dbus', array(
'help' => __('Log test execution to DBUS.'),
'help' => __d('cake_console', 'Log test execution to DBUS.'),
'default' => false
))->addOption('coverage-html', array(
'help' => __('<dir> Generate code coverage report in HTML format.'),
'help' => __d('cake_console', '<dir> Generate code coverage report in HTML format.'),
'default' => false
))->addOption('coverage-clover', array(
'help' => __('<file> Write code coverage data in Clover XML format.'),
'help' => __d('cake_console', '<file> Write code coverage data in Clover XML format.'),
'default' => false
))->addOption('testdox-html', array(
'help' => __('<file> Write agile documentation in HTML format to file.'),
'help' => __d('cake_console', '<file> Write agile documentation in HTML format to file.'),
'default' => false
))->addOption('testdox-text', array(
'help' => __('<file> Write agile documentation in Text format to file.'),
'help' => __d('cake_console', '<file> Write agile documentation in Text format to file.'),
'default' => false
))->addOption('filter', array(
'help' => __('<pattern> Filter which tests to run.'),
'help' => __d('cake_console', '<pattern> Filter which tests to run.'),
'default' => false
))->addOption('group', array(
'help' => __('<name> Only runs tests from the specified group(s).'),
'help' => __d('cake_console', '<name> Only runs tests from the specified group(s).'),
'default' => false
))->addOption('exclude-group', array(
'help' => __('<name> Exclude tests from the specified group(s).'),
'help' => __d('cake_console', '<name> Exclude tests from the specified group(s).'),
'default' => false
))->addOption('list-groups', array(
'help' => __('List available test groups.'),
'help' => __d('cake_console', 'List available test groups.'),
'boolean' => true
))->addOption('loader', array(
'help' => __('TestSuiteLoader implementation to use.'),
'help' => __d('cake_console', 'TestSuiteLoader implementation to use.'),
'default' => false
))->addOption('repeat', array(
'help' => __('<times> Runs the test(s) repeatedly.'),
'help' => __d('cake_console', '<times> Runs the test(s) repeatedly.'),
'default' => false
))->addOption('tap', array(
'help' => __('Report test execution progress in TAP format.'),
'help' => __d('cake_console', 'Report test execution progress in TAP format.'),
'boolean' => true
))->addOption('testdox', array(
'help' => __('Report test execution progress in TestDox format.'),
'help' => __d('cake_console', 'Report test execution progress in TestDox format.'),
'default' => false,
'boolean' => true
))->addOption('no-colors', array(
'help' => __('Do not use colors in output.'),
'help' => __d('cake_console', 'Do not use colors in output.'),
'boolean' => true
))->addOption('stderr', array(
'help' => __('Write to STDERR instead of STDOUT.'),
'help' => __d('cake_console', 'Write to STDERR instead of STDOUT.'),
'boolean' => true
))->addOption('stop-on-error', array(
'help' => __('Stop execution upon first error or failure.'),
'help' => __d('cake_console', 'Stop execution upon first error or failure.'),
'boolean' => true
))->addOption('stop-on-failure', array(
'help' => __('Stop execution upon first failure.'),
'help' => __d('cake_console', 'Stop execution upon first failure.'),
'boolean' => true
))->addOption('stop-on-skipped ', array(
'help' => __('Stop execution upon first skipped test.'),
'help' => __d('cake_console', 'Stop execution upon first skipped test.'),
'boolean' => true
))->addOption('stop-on-incomplete', array(
'help' => __('Stop execution upon first incomplete test.'),
'help' => __d('cake_console', 'Stop execution upon first incomplete test.'),
'boolean' => true
))->addOption('strict', array(
'help' => __('Mark a test as incomplete if no assertions are made.'),
'help' => __d('cake_console', 'Mark a test as incomplete if no assertions are made.'),
'boolean' => true
))->addOption('wait', array(
'help' => __('Waits for a keystroke after each test.'),
'help' => __d('cake_console', 'Waits for a keystroke after each test.'),
'boolean' => true
))->addOption('process-isolation', array(
'help' => __('Run each test in a separate PHP process.'),
'help' => __d('cake_console', 'Run each test in a separate PHP process.'),
'boolean' => true
))->addOption('no-globals-backup', array(
'help' => __('Do not backup and restore $GLOBALS for each test.'),
'help' => __d('cake_console', 'Do not backup and restore $GLOBALS for each test.'),
'boolean' => true
))->addOption('static-backup ', array(
'help' => __('Backup and restore static attributes for each test.'),
'help' => __d('cake_console', 'Backup and restore static attributes for each test.'),
'boolean' => true
))->addOption('syntax-check', array(
'help' => __('Try to check source files for syntax errors.'),
'help' => __d('cake_console', 'Try to check source files for syntax errors.'),
'boolean' => true
))->addOption('bootstrap', array(
'help' => __('<file> A "bootstrap" PHP file that is run before the tests.'),
'help' => __d('cake_console', '<file> A "bootstrap" PHP file that is run before the tests.'),
'default' => false
))->addOption('configuraion', array(
'help' => __('<file> Read configuration from XML file.'),
))->addOption('configuration', array(
'help' => __d('cake_console', '<file> Read configuration from XML file.'),
'default' => false
))->addOption('no-configuration', array(
'help' => __('Ignore default configuration file (phpunit.xml).'),
'help' => __d('cake_console', 'Ignore default configuration file (phpunit.xml).'),
'boolean' => true
))->addOption('include-path', array(
'help' => __('<path(s)> Prepend PHP include_path with given path(s).'),
'help' => __d('cake_console', '<path(s)> Prepend PHP include_path with given path(s).'),
'default' => false
))->addOption('directive', array(
'help' => __('key[=value] Sets a php.ini value.'),
'help' => __d('cake_console', 'key[=value] Sets a php.ini value.'),
'default' => false
))->addOption('fixture', array(
'help' => __('Choose a custom fixture manager.'),
'help' => __d('cake_console', 'Choose a custom fixture manager.'),
));
return $parser;
@ -156,18 +162,8 @@ class TestSuiteShell extends Shell {
* @return void
*/
public function initialize() {
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_dispatcher.php';
$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);
}
$this->_dispatcher = new CakeTestSuiteDispatcher();
$this->_dispatcher->loadTestFramework();
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php';
}
/**
@ -197,7 +193,7 @@ class TestSuiteShell extends Shell {
}
if (isset($this->args[1])) {
$params['case'] = Inflector::underscore($this->args[1]);
$params['case'] = $this->args[1];
}
return $params;
}
@ -236,7 +232,7 @@ class TestSuiteShell extends Shell {
* @return void
*/
public function main() {
$this->out(__('CakePHP Test Shell'));
$this->out(__d('cake_console', 'CakePHP Test Shell'));
$this->hr();
$args = $this->parseArgs();
@ -256,7 +252,6 @@ class TestSuiteShell extends Shell {
* @return void
*/
protected function run($runnerArgs, $options = array()) {
restore_error_handler();
restore_error_handler();
@ -286,7 +281,7 @@ class TestSuiteShell extends Shell {
}
if (empty($testCases)) {
$this->out(__("No test cases available \n\n"));
$this->out(__d('cake_console', "No test cases available \n\n"));
return $this->out($this->OptionParser->help());
}
@ -294,15 +289,15 @@ class TestSuiteShell extends Shell {
$i = 1;
$cases = array();
foreach ($testCases as $testCaseFile => $testCase) {
$case = explode(DS, str_replace('.test.php', '', $testCase));
$case[count($case) - 1] = Inflector::camelize($case[count($case) - 1]);
$case = explode(DS, str_replace('Test.php', '', $testCase));
$case[count($case) - 1] = $case[count($case) - 1];
$case = implode('/', $case);
$this->out("[$i] $case");
$cases[$i] = $case;
$i++;
}
while ($choice = $this->in(__('What test case would you like to run?'), null, 'q')) {
while ($choice = $this->in(__d('cake_console', 'What test case would you like to run?'), null, 'q')) {
if (is_numeric($choice) && isset($cases[$choice])) {
$this->args[0] = $category;
$this->args[1] = $cases[$choice];

View file

@ -16,8 +16,9 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'ErrorHandler');
require_once 'console_output.php';
App::uses('ErrorHandler', 'Error');
App::uses('ConsoleOutput', 'Console');
App::uses('CakeLog', 'Log');
/**
* Error Handler for Cake console. Does simple printing of the
@ -57,7 +58,7 @@ class ConsoleErrorHandler extends ErrorHandler {
public static function handleException(Exception $exception) {
$stderr = self::getStderr();
$stderr->write(sprintf(
__("<error>Error:</error> %s\n%s"),
__d('cake_console', "<error>Error:</error> %s\n%s"),
$exception->getMessage(),
$exception->getTraceAsString()
));
@ -79,11 +80,10 @@ class ConsoleErrorHandler extends ErrorHandler {
}
$stderr = self::getStderr();
list($name, $log) = self::_mapErrorCode($code);
$message = __('%s in [%s, line %s]', $description, $file, $line);
$stderr->write(__("<error>%s Error:</error> %s\n", $name, $message));
$message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line);
$stderr->write(__d('cake_console', "<error>%s Error:</error> %s\n", $name, $message));
if (Configure::read('debug') == 0) {
App::import('Core', 'CakeLog');
CakeLog::write($log, $message);
}
}

View file

@ -95,10 +95,10 @@ class ConsoleInputArgument {
}
$optional = '';
if (!$this->isRequired()) {
$optional = __(' <comment>(optional)</comment>');
$optional = __d('cake_console', ' <comment>(optional)</comment>');
}
if (!empty($this->_choices)) {
$optional .= __(' <comment>(choices: %s)</comment>', implode('|', $this->_choices));
$optional .= __d('cake_console', ' <comment>(choices: %s)</comment>', implode('|', $this->_choices));
}
return sprintf('%s%s%s', $name, $this->_help, $optional);
}
@ -140,7 +140,7 @@ class ConsoleInputArgument {
}
if (!in_array($value, $this->_choices)) {
throw new ConsoleException(sprintf(
__('"%s" is not a valid value for %s. Please use one of "%s"'),
__d('cake_console', '"%s" is not a valid value for %s. Please use one of "%s"'),
$value, $this->_name, implode(', ', $this->_choices)
));
}

View file

@ -119,10 +119,10 @@ class ConsoleInputOption {
public function help($width = 0) {
$default = $short = '';
if (!empty($this->_default) && $this->_default !== true) {
$default = __(' <comment>(default: %s)</comment>', $this->_default);
$default = __d('cake_console', ' <comment>(default: %s)</comment>', $this->_default);
}
if (!empty($this->_choices)) {
$default .= __(' <comment>(choices: %s)</comment>', implode('|', $this->_choices));
$default .= __d('cake_console', ' <comment>(choices: %s)</comment>', implode('|', $this->_choices));
}
if (!empty($this->_short)) {
$short = ', -' . $this->_short;
@ -180,7 +180,7 @@ class ConsoleInputOption {
}
if (!in_array($value, $this->_choices)) {
throw new ConsoleException(sprintf(
__('"%s" is not a valid value for --%s. Please use one of "%s"'),
__d('cake_console', '"%s" is not a valid value for --%s. Please use one of "%s"'),
$value, $this->_name, implode(', ', $this->_choices)
));
}

View file

@ -16,10 +16,15 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
require_once CONSOLE_LIBS . 'console_input_option.php';
require_once CONSOLE_LIBS . 'console_input_argument.php';
require_once CONSOLE_LIBS . 'console_input_subcommand.php';
require_once CONSOLE_LIBS . 'help_formatter.php';
App::uses('TaskCollection', 'Console');
App::uses('ConsoleOutput', 'Console');
App::uses('ConsoleInput', 'Console');
App::uses('ConsoleInputSubcommand', 'Console');
App::uses('ConsoleInputOption', 'Console');
App::uses('ConsoleInputArgument', 'Console');
App::uses('ConsoleOptionParser', 'Console');
App::uses('HelpFormatter', 'Console');
/**
* Handles parsing the ARGV in the command line and provides support
@ -129,11 +134,11 @@ class ConsoleOptionParser {
if ($defaultOptions) {
$this->addOption('verbose', array(
'short' => 'v',
'help' => __('Enable verbose output.'),
'help' => __d('cake_console', 'Enable verbose output.'),
'boolean' => true
))->addOption('quiet', array(
'short' => 'q',
'help' => __('Enable quiet output.'),
'help' => __d('cake_console', 'Enable quiet output.'),
'boolean' => true
));
}
@ -456,7 +461,7 @@ class ConsoleOptionParser {
foreach ($this->_args as $i => $arg) {
if ($arg->isRequired() && !isset($args[$i]) && empty($params['help'])) {
throw new ConsoleException(
__('Missing required arguments. %s is required.', $arg->name())
__d('cake_console', 'Missing required arguments. %s is required.', $arg->name())
);
}
}
@ -550,7 +555,7 @@ class ConsoleOptionParser {
*/
protected function _parseOption($name, $params) {
if (!isset($this->_options[$name])) {
throw new ConsoleException(__('Unknown option `%s`', $name));
throw new ConsoleException(__d('cake_console', 'Unknown option `%s`', $name));
}
$option = $this->_options[$name];
$isBoolean = $option->isBoolean();
@ -584,7 +589,7 @@ class ConsoleOptionParser {
}
$next = count($args);
if (!isset($this->_args[$next])) {
throw new ConsoleException(__('Too many arguments.'));
throw new ConsoleException(__d('cake_console', 'Too many arguments.'));
}
if ($this->_args[$next]->validChoice($argument)) {

View file

@ -14,7 +14,7 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'String', false);
App::uses('String', 'Utility');
/**
* HelpFormatter formats help for console shells. Can format to either
@ -69,7 +69,7 @@ class HelpFormatter {
}
$out[] = '';
$out[] = sprintf(
__('To see help on a subcommand use <info>`cake %s [subcommand] --help`</info>'),
__d('cake_console', 'To see help on a subcommand use <info>`cake %s [subcommand] --help`</info>'),
$parser->command()
);
$out[] = '';

View file

@ -16,10 +16,13 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
require_once CONSOLE_LIBS . 'task_collection.php';
require_once CONSOLE_LIBS . 'console_output.php';
require_once CONSOLE_LIBS . 'console_input.php';
require_once CONSOLE_LIBS . 'console_option_parser.php';
App::uses('TaskCollection', 'Console');
App::uses('ConsoleOutput', 'Console');
App::uses('ConsoleInput', 'Console');
App::uses('ConsoleInputSubcommand', 'Console');
App::uses('ConsoleOptionParser', 'Console');
App::uses('File', 'Utility');
/**
* Base class for command-line utilities for automating programmer chores.
@ -557,7 +560,7 @@ class Shell extends Object {
* @param string $message An optional error message
*/
public function error($title, $message = null) {
$this->err(__('<error>Error:</error> %s', $title));
$this->err(__d('cake_console', '<error>Error:</error> %s', $title));
if (!empty($message)) {
$this->err($message);
@ -593,31 +596,27 @@ class Shell extends Object {
$this->out();
if (is_file($path) && $this->interactive === true) {
$this->out(__('<warning>File `%s` exists</warning>', $path));
$key = $this->in(__('Do you want to overwrite?'), array('y', 'n', 'q'), 'n');
$this->out(__d('cake_console', '<warning>File `%s` exists</warning>', $path));
$key = $this->in(__d('cake_console', 'Do you want to overwrite?'), array('y', 'n', 'q'), 'n');
if (strtolower($key) == 'q') {
$this->out(__('<error>Quitting</error>.'), 2);
$this->out(__d('cake_console', '<error>Quitting</error>.'), 2);
$this->_stop();
} elseif (strtolower($key) != 'y') {
$this->out(__('Skip `%s`', $path), 2);
$this->out(__d('cake_console', 'Skip `%s`', $path), 2);
return false;
}
} else {
$this->out(__('Creating file %s', $path));
}
if (!class_exists('File')) {
require LIBS . 'file.php';
$this->out(__d('cake_console', 'Creating file %s', $path));
}
if ($File = new File($path, true)) {
$data = $File->prepare($contents);
$File->write($data);
$this->out(__('<success>Wrote</success> `%s`', $path));
$this->out(__d('cake_console', '<success>Wrote</success> `%s`', $path));
return true;
} else {
$this->err(__('<error>Could not write to `%s`</error>.', $path), 2);
$this->err(__d('cake_console', '<error>Could not write to `%s`</error>.', $path), 2);
return false;
}
}
@ -664,7 +663,7 @@ class Shell extends Object {
* @return string Path to controller
*/
protected function _controllerPath($name) {
return strtolower(Inflector::underscore($name));
return Inflector::underscore($name);
}
/**

View file

@ -105,7 +105,7 @@ class ShellDispatcher {
if (!isset($this->args[0]) || !isset($this->params['working'])) {
$message = "This file has been loaded incorrectly and cannot continue.\n" .
"Please make sure that " . DIRECTORY_SEPARATOR . "cake" . DIRECTORY_SEPARATOR . "console is in your system path,\n" .
"Please make sure that " . DIRECTORY_SEPARATOR . "cake" . DIRECTORY_SEPARATOR . "console is in your system path,\n" .
"and check the cookbook for the correct usage of this command.\n" .
"(http://book.cakephp.org/)";
throw new CakeException($message);
@ -127,17 +127,17 @@ class ShellDispatcher {
define('APP_PATH', $this->params['working'] . DS);
define('WWW_ROOT', APP_PATH . $this->params['webroot'] . DS);
if (!is_dir(ROOT . DS . APP_DIR . DS . 'tmp')) {
define('TMP', CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'templates' . DS . 'skel' . DS . 'tmp' . DS);
define('TMP', CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'templates' . DS . 'skel' . DS . 'tmp' . DS);
}
$boot = file_exists(ROOT . DS . APP_DIR . DS . 'config' . DS . 'bootstrap.php');
require CORE_PATH . 'cake' . DS . 'bootstrap.php';
require CORE_PATH . 'Cake' . DS . 'bootstrap.php';
if (!file_exists(APP_PATH . 'config' . DS . 'core.php')) {
include_once CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'templates' . DS . 'skel' . DS . 'config' . DS . 'core.php';
include_once CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'templates' . DS . 'skel' . DS . 'config' . DS . 'core.php';
App::build();
}
require_once CONSOLE_LIBS . 'console_error_handler.php';
require_once CONSOLE_LIBS . 'ConsoleErrorHandler.php';
set_exception_handler(array('ConsoleErrorHandler', 'handleException'));
set_error_handler(array('ConsoleErrorHandler', 'handleError'), Configure::read('Error.level'));
@ -207,14 +207,14 @@ class ShellDispatcher {
protected function _getShell($shell) {
list($plugin, $shell) = pluginSplit($shell, true);
$loaded = App::import('Shell', $plugin . $shell);
$class = Inflector::camelize($shell) . 'Shell';
if (!$loaded) {
throw new MissingShellFileException(array('shell' => $shell));
}
App::uses('Shell', 'Console');
App::uses($class, $plugin . 'Console/Command');
if (!class_exists($class)) {
throw new MissingShellClassException(array('shell' => $class));
throw new MissingShellFileException(array('shell' => $shell));
}
$Shell = new $class();
return $Shell;
@ -229,9 +229,9 @@ class ShellDispatcher {
$this->_parsePaths($args);
$defaults = array(
'app' => 'app',
'app' => 'app',
'root' => dirname(dirname(dirname(__FILE__))),
'working' => null,
'working' => null,
'webroot' => 'webroot'
);
$params = array_merge($defaults, array_intersect_key($this->params, $defaults));

View file

@ -15,6 +15,9 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('ObjectCollection', 'Utility');
class TaskCollection extends ObjectCollection {
/**
* Shell to use to set params to tasks.
@ -57,10 +60,8 @@ class TaskCollection extends ObjectCollection {
}
$taskFile = Inflector::underscore($name);
$taskClass = $name . 'Task';
App::uses($taskClass, $plugin . 'Console/Command/Task');
if (!class_exists($taskClass)) {
if (!App::import('Shell', $plugin . $this->taskPathPrefix . $name)) {
throw new MissingTaskFileException($taskFile . '.php');
}
if (!class_exists($taskClass)) {
throw new MissingTaskClassException($taskClass);
}

View file

@ -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(__FILE__) . DIRECTORY_SEPARATOR. 'shell_dispatcher.php');
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'ShellDispatcher.php');
return ShellDispatcher::run($argv);

View file

@ -20,7 +20,7 @@
echo "<?php\n";
echo "/* ". $className ." Test cases generated on: " . date('Y-m-d H:i:s') . " : ". time() . "*/\n";
?>
App::import('<?php echo $type; ?>', '<?php echo $plugin . $className;?>');
App::uses('<?php echo $fullClassName; ?>', '<?php echo $plugin . $type;?>');
<?php if ($mock and strtolower($type) == 'controller'): ?>
/**

View file

@ -2,7 +2,7 @@
$output = "<h2>Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!</h2>\n";
$output .="
<?php
App::import('Core', 'Debugger');
App::uses('Debugger', 'Utility');
if (Configure::read() > 0):
Debugger::checkSecurityKeys();
endif;
@ -52,27 +52,38 @@ endif;
?>
</p>
<?php
if (!empty(\$filePresent)):
if (!class_exists('ConnectionManager')) {
require LIBS . 'model' . DS . 'connection_manager.php';
if (isset(\$filePresent)):
App::uses('ConnectionManager', 'Model');
try {
\$connected = ConnectionManager::getDataSource('default');
} catch (Exception \$e) {
\$connected = false;
}
\$db = ConnectionManager::getInstance();
\$connected = \$db->getDataSource('default');
?>
<p>
<?php
if (\$connected && \$connected->isConnected()):
echo '<span class=\"notice success\">';
echo __('Cake is able to connect to the database.');
echo '</span>';
else:
echo '<span class=\"notice\">';
echo __('Cake is NOT able to connect to the database.');
echo '</span>';
endif;
?>
</p>
<?php endif;?>
<?php
if (\$connected->isConnected()):
echo '<span class=\"notice success\">';
echo __('Cake is able to connect to the database.');
echo '</span>';
else:
echo '<span class=\"notice\">';
echo __('Cake is NOT able to connect to the database.');
echo '</span>';
endif;
?>
</p>\n";
$output .= "<?php endif;?>\n";
App::uses('Validation', 'Utility');
if (!Validation::alphaNumeric('cakephp')) {
echo '<p><span class=\"notice\">';
__('PCRE has not been compiled with Unicode support.');
echo '<br/>';
__('Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
echo '</span></p>';
}
?>\n";
$output .= "<h3><?php echo __('Editing this Page') ?></h3>\n";
$output .= "<p>\n";
$output .= "<?php\n";

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