-';
- __('PCRE has not been compiled with Unicode support.');
- echo ' ';
- __('Recompile PCRE with Unicode support by adding --enable-unicode-properties when configuring');
- echo '';
- }
-?>
-getDataSource('default');
-?>
-
- isConnected()):
- echo '';
- echo __('Cake is able to connect to the database.');
- echo '';
- else:
- echo '';
- echo __('Cake is NOT able to connect to the database.');
- echo '';
- endif;
- ?>
-
-
-
-
-
-To change its layout, create: APP/views/layouts/default.ctp.
-You can also add some CSS styles for your pages at: APP/webroot/css.');
-?>
-
-';
- echo __('The %s is being used for caching. To change the config edit APP/config/core.php ', ''. $settings['engine'] . 'Engine');
- echo '';
- else:
- echo '';
- echo __('Your cache is NOT working. Please check the settings in APP/config/core.php');
- echo '';
- endif;
-?>
-
-';
- echo __('Cake is able to connect to the database.');
- echo '';
- else:
- echo '';
- echo __('Cake is NOT able to connect to the database.');
- echo '';
- endif;
-?>
-
';
-
- else:
- echo __('NOT working.');
- echo ' ';
- 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;
- ?>
-
-
-
\ No newline at end of file
diff --git a/cake/tests/test_app/views/scaffolds/empty b/cake/tests/test_app/views/scaffolds/empty
deleted file mode 100644
index e69de29bb..000000000
diff --git a/cake/libs/cache.php b/lib/Cake/Cache/Cache.php
similarity index 86%
rename from cake/libs/cache.php
rename to lib/Cake/Cache/Cache.php
index 66f255b34..2ffdeb007 100644
--- a/cake/libs/cache.php
+++ b/lib/Cake/Cache/Cache.php
@@ -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.
*
@@ -71,14 +73,39 @@ class Cache {
* both create new configurations, return the settings for already configured
* configurations.
*
- * To create a new configuration:
+ * To create a new configuration, or to modify an existing configuration permanently:
*
* `Cache::config('my_config', array('engine' => 'File', 'path' => TMP));`
*
- * To get the settings for a configuration, and set it as the currently selected configuration
+ * If you need to modify a configuration temporarily, use Cache::set().
+ * To get the settings for a configuration:
*
* `Cache::config('default');`
*
+ * There are 4 built-in caching engines:
+ *
+ * - `FileEngine` - Uses simple files to store content. Poor performance, but good for
+ * storing large objects, or things that are not IO sensitive.
+ * - `ApcEngine` - Uses the APC object cache, one of the fastest caching engines.
+ * - `MemcacheEngine` - Uses the PECL::Memcache extension and Memcached for storage.
+ * Fast reads/writes, and benefits from memcache being distributed.
+ * - `XcacheEngine` - Uses the Xcache extension, an alternative to APC.
+ *
+ * The following keys are used in core cache engines:
+ *
+ * - `duration` Specify how long items in this cache configuration last.
+ * - `prefix` Prefix appended to all entries. Good for when you need to share a keyspace
+ * with either another cache config or annother application.
+ * - `probability` Probability of hitting a cache gc cleanup. Setting to 0 will disable
+ * cache::gc from ever being called automatically.
+ * - `servers' Used by memcache. Give the address of the memcached servers to use.
+ * - `compress` Used by memcache. Enables memcache's compressed format.
+ * - `serialize` Used by FileCache. Should cache objects be serialized first.
+ * - `path` Used by FileCache. Path to where cachefiles should be saved.
+ * - `lock` Used by FileCache. Should files be locked before writing to them?
+ * - `user` Used by Xcache. Username for XCache
+ * - `password` Used by Xcache. Password for XCache
+ *
* @see app/config/core.php for configuration settings
* @param string $name Name of the configuration
* @param array $settings Optional associative array of settings passed to the engine
@@ -123,18 +150,19 @@ 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)) {
- if (time() % self::$_engines[$name]->settings['probability'] === 0) {
+ if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) {
self::$_engines[$name]->gc();
}
return true;
@@ -167,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.
*
@@ -290,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
);
}
@@ -364,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
*/
diff --git a/cake/libs/cache/apc.php b/lib/Cake/Cache/Engine/ApcEngine.php
similarity index 100%
rename from cake/libs/cache/apc.php
rename to lib/Cake/Cache/Engine/ApcEngine.php
diff --git a/cake/libs/cache/file.php b/lib/Cake/Cache/Engine/FileEngine.php
similarity index 92%
rename from cake/libs/cache/file.php
rename to lib/Cake/Cache/Engine/FileEngine.php
index 46ff892a3..fd6286b9a 100644
--- a/cake/libs/cache/file.php
+++ b/lib/Cake/Cache/Engine/FileEngine.php
@@ -1,7 +1,10 @@
CACHE
* - prefix = string prefix for filename, default => cake_
* - lock = enable file locking on write, default => false
@@ -161,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()) {
@@ -250,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.'));
}
/**
@@ -260,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.'));
}
/**
@@ -296,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;
}
-}
+}
\ No newline at end of file
diff --git a/cake/libs/cache/memcache.php b/lib/Cake/Cache/Engine/MemcacheEngine.php
similarity index 83%
rename from cake/libs/cache/memcache.php
rename to lib/Cake/Cache/Engine/MemcacheEngine.php
index 79d98376e..7b9aa5523 100644
--- a/cake/libs/cache/memcache.php
+++ b/lib/Cake/Cache/Engine/MemcacheEngine.php
@@ -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.
*
@@ -33,7 +33,7 @@ class MemcacheEngine extends CacheEngine {
* @var Memcache
* @access private
*/
- private $__Memcache = null;
+ protected $_Memcache = null;
/**
* Settings
@@ -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)
@@ -74,12 +74,12 @@ class MemcacheEngine extends CacheEngine {
if (!is_array($this->settings['servers'])) {
$this->settings['servers'] = array($this->settings['servers']);
}
- if (!isset($this->__Memcache)) {
+ if (!isset($this->_Memcache)) {
$return = false;
- $this->__Memcache = new Memcache();
+ $this->_Memcache = new Memcache();
foreach ($this->settings['servers'] as $server) {
list($host, $port) = $this->_parseServerString($server);
- if ($this->__Memcache->addServer($host, $port)) {
+ if ($this->_Memcache->addServer($host, $port)) {
$return = true;
}
}
@@ -115,9 +115,8 @@ 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
- * than 30 days in the future. If you wish to create cache entries that do not expire, set the duration
- * to `0` in your cache configuration.
+ * 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
* @param mixed $value Data to be cached
@@ -126,7 +125,10 @@ class MemcacheEngine extends CacheEngine {
* @see http://php.net/manual/en/memcache.set.php
*/
public function write($key, $value, $duration) {
- return $this->__Memcache->set($key, $value, $this->settings['compress'], $duration);
+ if ($duration > 30 * DAY) {
+ $duration = 0;
+ }
+ return $this->_Memcache->set($key, $value, $this->settings['compress'], $duration);
}
/**
@@ -136,7 +138,7 @@ class MemcacheEngine extends CacheEngine {
* @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
*/
public function read($key) {
- return $this->__Memcache->get($key);
+ return $this->_Memcache->get($key);
}
/**
@@ -151,10 +153,10 @@ 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);
+ return $this->_Memcache->increment($key, $offset);
}
/**
@@ -169,10 +171,10 @@ 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);
+ return $this->_Memcache->decrement($key, $offset);
}
/**
@@ -182,7 +184,7 @@ class MemcacheEngine extends CacheEngine {
* @return boolean True if the value was succesfully deleted, false if it didn't exist or couldn't be removed
*/
public function delete($key) {
- return $this->__Memcache->delete($key);
+ return $this->_Memcache->delete($key);
}
/**
@@ -191,7 +193,7 @@ class MemcacheEngine extends CacheEngine {
* @return boolean True if the cache was succesfully cleared, false otherwise
*/
public function clear($check) {
- return $this->__Memcache->flush();
+ return $this->_Memcache->flush();
}
/**
@@ -202,12 +204,12 @@ class MemcacheEngine extends CacheEngine {
* @return boolean True if memcache server was connected
*/
public function connect($host, $port = 11211) {
- if ($this->__Memcache->getServerStatus($host, $port) === 0) {
- if ($this->__Memcache->connect($host, $port)) {
+ if ($this->_Memcache->getServerStatus($host, $port) === 0) {
+ if ($this->_Memcache->connect($host, $port)) {
return true;
}
return false;
}
return true;
}
-}
+}
\ No newline at end of file
diff --git a/cake/libs/cache/xcache.php b/lib/Cake/Cache/Engine/XcacheEngine.php
similarity index 100%
rename from cake/libs/cache/xcache.php
rename to lib/Cake/Cache/Engine/XcacheEngine.php
diff --git a/cake/libs/config/ini_reader.php b/lib/Cake/Configure/IniReader.php
similarity index 86%
rename from cake/libs/config/ini_reader.php
rename to lib/Cake/Configure/IniReader.php
index 915bf9498..d4eb8172d 100644
--- a/cake/libs/config/ini_reader.php
+++ b/lib/Cake/Configure/IniReader.php
@@ -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.
@@ -71,13 +71,24 @@ class IniReader implements ConfigReaderInterface {
*/
public function read($file) {
$filename = $this->_path . $file;
+ if (!file_exists($filename)) {
+ $filename .= '.ini';
+ if (!file_exists($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);
if (!empty($this->_section) && isset($contents[$this->_section])) {
$values = $this->_parseNestedValues($contents[$this->_section]);
} else {
$values = array();
foreach ($contents as $section => $attribs) {
- $values[$section] = $this->_parseNestedValues($attribs);
+ if (is_array($attribs)) {
+ $values[$section] = $this->_parseNestedValues($attribs);
+ } else {
+ $parse = $this->_parseNestedValues(array($attribs));
+ $values[$section] = array_shift($parse);
+ }
}
}
return $values;
diff --git a/cake/libs/config/php_reader.php b/lib/Cake/Configure/PhpReader.php
similarity index 78%
rename from cake/libs/config/php_reader.php
rename to lib/Cake/Configure/PhpReader.php
index c122f0808..54f99dae1 100644
--- a/cake/libs/config/php_reader.php
+++ b/lib/Cake/Configure/PhpReader.php
@@ -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,22 +55,28 @@ 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 . '.php';
+ $file = App::pluginPath($plugin) . 'config' . DS . $key;
} else {
- $file = $this->_path . $key . '.php';
+ $file = $this->_path . $key;
}
if (!file_exists($file)) {
- throw new ConfigureException(__('Could not load configuration file: ') . $file);
+ $file .= '.php';
+ if (!file_exists($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;
diff --git a/cake/console/shells/app_shell.php b/lib/Cake/Console/AppShell.php
similarity index 93%
rename from cake/console/shells/app_shell.php
rename to lib/Cake/Console/AppShell.php
index a624a31ad..ca3abc8ed 100644
--- a/cake/console/shells/app_shell.php
+++ b/lib/Cake/Console/AppShell.php
@@ -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.
diff --git a/cake/console/shells/acl.php b/lib/Cake/Console/Command/AclShell.php
similarity index 63%
rename from cake/console/shells/acl.php
rename to lib/Cake/Console/Command/AclShell.php
index b4d458ba7..29312eaef 100644
--- a/cake/console/shells/acl.php
+++ b/lib/Cake/Console/Command/AclShell.php
@@ -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(__("New %s '%s' created.", $class, $this->args[2]), 2);
+ $this->out(__d('cake_console', "New %s '%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(__('%s deleted.', $class), 2);
+ $this->out(__d('cake_console', '%s deleted.', $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 allowed.', $aroName), true);
+ $this->out(__d('cake_console', '%s is allowed.', $aroName), true);
} else {
- $this->out(__('%s is not allowed.', $aroName), true);
+ $this->out(__d('cake_console', '%s is not allowed.', $aroName), true);
}
}
@@ -242,9 +242,9 @@ class AclShell extends Shell {
extract($this->__getParams());
if ($this->Acl->allow($aro, $aco, $action)) {
- $this->out(__('Permission granted.'), true);
+ $this->out(__d('cake_console', 'Permission granted.'), true);
} else {
- $this->out(__('Permission was not granted.'), true);
+ $this->out(__d('cake_console', 'Permission was not granted.'), 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 under the parent'),
+ 'description' => __d('cake_console', 'Creates a new ACL object 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 reference'),
+ 'help' => __d('cake_console', 'Deletes the ACL object with the given 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 beneath '),
+ 'description' => __d('cake_console', 'Moves the ACL object specified by beneath '),
'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 .'),
+ 'help' => __d('cake_console', 'The new parent for .'),
'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 ."),
- __("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 ."),
+ __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");
}
diff --git a/cake/console/shells/api.php b/lib/Cake/Console/Command/ApiShell.php
similarity index 83%
rename from cake/console/shells/api.php
rename to lib/Cake/Console/Command/ApiShell.php
index 05cf326b8..d37b6acd0 100644
--- a/cake/console/shells/api.php
+++ b/lib/Cake/Console/Command/ApiShell.php
@@ -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) {
diff --git a/cake/console/shells/bake.php b/lib/Cake/Console/Command/BakeShell.php
similarity index 78%
rename from cake/console/shells/bake.php
rename to lib/Cake/Console/Command/BakeShell.php
index ec741ed3a..94b06f379 100644
--- a/cake/console/shells/bake.php
+++ b/lib/Cake/Console/Command/BakeShell.php
@@ -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,13 @@ class BakeShell extends Shell {
$modelExists = false;
$model = $this->_modelName($name);
- if (App::import('Model', $model)) {
+
+ App::uses('AppModel', '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 +178,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(__('Bake All complete'), 1, Shell::QUIET);
+ $this->out(__d('cake_console', 'Bake All complete'), 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 +205,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 of a Model'),
+ 'help' => __d('cake_console', 'Bake a complete MVC. optional 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'
));
diff --git a/cake/console/shells/command_list.php b/lib/Cake/Console/Command/CommandListShell.php
similarity index 84%
rename from cake/console/shells/command_list.php
rename to lib/Cake/Console/Command/CommandListShell.php
index e9323c6f7..aa3d0d4ed 100644
--- a/cake/console/shells/command_list.php
+++ b/lib/Cake/Console/Command/CommandListShell.php
@@ -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
));
}
diff --git a/cake/console/shells/console.php b/lib/Cake/Console/Command/ConsoleShell.php
similarity index 96%
rename from cake/console/shells/console.php
rename to lib/Cake/Console/Command/ConsoleShell.php
index 44cc13d45..1e00d7dd7 100644
--- a/cake/console/shells/console.php
+++ b/lib/Cake/Console/Command/ConsoleShell.php
@@ -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;
}
diff --git a/cake/console/shells/i18n.php b/lib/Cake/Console/Command/I18nShell.php
similarity index 69%
rename from cake/console/shells/i18n.php
rename to lib/Cake/Console/Command/I18nShell.php
index 0a2bdeef6..3a3c5691e 100644
--- a/cake/console/shells/i18n.php
+++ b/lib/Cake/Console/Command/I18nShell.php
@@ -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(__('I18n Shell'));
+ $this->out(__d('cake_console', 'I18n Shell'));
$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()
));
}
diff --git a/cake/console/shells/schema.php b/lib/Cake/Console/Command/SchemaShell.php
similarity index 76%
rename from cake/console/shells/schema.php
rename to lib/Cake/Console/Command/SchemaShell.php
index c0fe44751..f3faa5890 100644
--- a/cake/console/shells/schema.php
+++ b/lib/Cake/Console/Command/SchemaShell.php
@@ -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);
@@ -145,8 +145,13 @@ class SchemaShell extends Shell {
}
}
+ $cacheDisable = Configure::read('Cache.disable');
+ Configure::write('Cache.disable', true);
+
$content = $this->Schema->read($options);
$content['file'] = $this->params['file'];
+
+ Configure::write('Cache.disable', $cacheDisable);
if ($snapshot === true) {
$Folder = new Folder($this->Schema->path);
@@ -177,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();
}
}
@@ -197,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'])) {
@@ -222,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();
}
}
@@ -269,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);
@@ -281,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;
@@ -312,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.'));
}
/**
@@ -343,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;
@@ -362,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.'));
}
/**
@@ -384,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);
@@ -392,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))) {
@@ -411,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));
}
}
}
@@ -425,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.',
@@ -452,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();
@@ -470,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.')
)
)
)
diff --git a/cake/console/shells/tasks/bake.php b/lib/Cake/Console/Command/Task/BakeTask.php
similarity index 93%
rename from cake/console/shells/tasks/bake.php
rename to lib/Cake/Console/Command/Task/BakeTask.php
index bd7f59e69..58fc783ef 100644
--- a/cake/console/shells/tasks/bake.php
+++ b/lib/Cake/Console/Command/Task/BakeTask.php
@@ -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;
}
diff --git a/cake/console/shells/tasks/controller.php b/lib/Cake/Console/Command/Task/ControllerTask.php
similarity index 77%
rename from cake/console/shells/tasks/controller.php
rename to lib/Cake/Console/Command/Task/ControllerTask.php
index f1cac43eb..6f4723c64 100644
--- a/cake/console/shells/tasks/controller.php
+++ b/lib/Cake/Console/Command/Task/ControllerTask.php
@@ -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();
}
@@ -282,9 +283,13 @@ class ControllerTask extends BakeTask {
$singularName = Inflector::variable($currentModelName);
$singularHumanName = $this->_singularHumanName($controllerName);
$pluralHumanName = $this->_pluralName($controllerName);
+ $displayField = $modelObj->displayField;
+ $primaryKey = $modelObj->primaryKey;
- $this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName',
- 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName'));
+ $this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName',
+ 'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName',
+ 'displayField', 'primaryKey'
+ ));
$actions = $this->Template->generate('actions', 'controller_actions');
return $actions;
}
@@ -309,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;
}
@@ -336,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'")
);
}
@@ -348,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'")
);
}
@@ -385,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++) {
@@ -408,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 = '';
}
}
@@ -436,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.'));
}
/**
@@ -494,4 +499,4 @@ class ControllerTask extends BakeTask {
$this->out();
$this->_stop();
}
-}
+}
\ No newline at end of file
diff --git a/cake/console/shells/tasks/db_config.php b/lib/Cake/Console/Command/Task/DbConfigTask.php
similarity index 96%
rename from cake/console/shells/tasks/db_config.php
rename to lib/Cake/Console/Command/Task/DbConfigTask.php
index c3c2b36e1..2ffdd4ada 100644
--- a/cake/console/shells/tasks/db_config.php
+++ b/lib/Cake/Console/Command/Task/DbConfigTask.php
@@ -104,7 +104,7 @@ class DbConfigTask extends Shell {
}
}
- $driver = $this->in('Driver:', array('db2', 'firebird', 'mssql', 'mysql', 'odbc', 'oracle', 'postgres', 'sqlite', 'sybase'), 'mysql');
+ $driver = $this->in('Driver:', array('mssql', 'mysql', 'oracle', 'postgres', 'sqlite'), 'mysql');
$persistent = $this->in('Persistent Connection?', array('y', 'n'), 'n');
if (strtolower($persistent) == 'n') {
@@ -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.')
);
}
}
diff --git a/cake/console/shells/tasks/extract.php b/lib/Cake/Console/Command/Task/ExtractTask.php
similarity index 77%
rename from cake/console/shells/tasks/extract.php
rename to lib/Cake/Console/Command/Task/ExtractTask.php
index 9965876e2..8e20fabe2 100644
--- a/cake/console/shells/tasks/extract.php
+++ b/lib/Cake/Console/Command/Task/ExtractTask.php
@@ -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 ...'));
+ $this->out(__d('cake_console', 'Usage: cake i18n extract ...'));
$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;
diff --git a/cake/console/shells/tasks/fixture.php b/lib/Cake/Console/Command/Task/FixtureTask.php
similarity index 85%
rename from cake/console/shells/tasks/fixture.php
rename to lib/Cake/Console/Command/Task/FixtureTask.php
index 8fd60782b..daf3e412d 100644
--- a/cake/console/shells/tasks/fixture.php
+++ b/lib/Cake/Console/Command/Task/FixtureTask.php
@@ -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 /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,10 +185,10 @@ 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);
- }
- $table = $schema = $records = $import = $modelImport = $recordImport = null;
+ App::uses('CakeSchema', 'Model');
+ $table = $schema = $records = $import = $modelImport = null;
+ $importBits = array();
+
if (!$useTable) {
$useTable = Inflector::tableize($model);
} elseif ($useTable != Inflector::tableize($model)) {
@@ -194,16 +197,17 @@ class FixtureTask extends BakeTask {
if (!empty($importOptions)) {
if (isset($importOptions['schema'])) {
- $modelImport = "'model' => '{$importOptions['schema']}'";
+ $modelImport = true;
+ $importBits[] = "'model' => '{$importOptions['schema']}'";
}
if (isset($importOptions['records'])) {
- $recordImport = "'records' => true";
+ $importBits[] = "'records' => true";
}
- if ($modelImport && $recordImport) {
- $modelImport .= ', ';
+ if ($this->connection != 'default') {
+ $importBits[] .= "'connection' => '{$this->connection}'";
}
- if (!empty($modelImport) || !empty($recordImport)) {
- $import = sprintf("array(%s%s)", $modelImport, $recordImport);
+ if (!empty($importBits)) {
+ $import = sprintf("array(%s)", implode(', ', $importBits));
}
}
@@ -245,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);
@@ -264,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;
}
@@ -383,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,
diff --git a/cake/console/shells/tasks/model.php b/lib/Cake/Console/Command/Task/ModelTask.php
similarity index 81%
rename from cake/console/shells/tasks/model.php
rename to lib/Cake/Console/Command/Task/ModelTask.php
index 5ac132dd1..1c63147fb 100644
--- a/cake/console/shells/tasks/model.php
+++ b/lib/Cake/Console/Command/Task/ModelTask.php
@@ -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];
}
@@ -308,7 +310,7 @@ class ModelTask extends BakeTask {
* @param object $model Model to have validations generated for.
* @return array $validate Array of user selected validations.
*/
- public function doValidation(&$model) {
+ public function doValidation($model) {
if (!is_object($model)) {
return false;
}
@@ -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';
}
@@ -440,12 +442,12 @@ class ModelTask extends BakeTask {
* @param object $model
* @return array $assocaitons
*/
- public function doAssociations(&$model) {
+ public function doAssociations($model) {
if (!is_object($model)) {
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);
}
@@ -491,7 +493,7 @@ class ModelTask extends BakeTask {
* @param array $associations Array of inprogress associations
* @return array $associations with belongsTo added in.
*/
- public function findBelongsTo(&$model, $associations) {
+ public function findBelongsTo($model, $associations) {
$fields = $model->schema(true);
foreach ($fields as $fieldName => $field) {
$offset = strpos($fieldName, '_id');
@@ -520,7 +522,7 @@ class ModelTask extends BakeTask {
* @param array $associations Array of inprogress associations
* @return array $associations with hasOne and hasMany added in.
*/
- public function findHasOneAndMany(&$model, $associations) {
+ public function findHasOneAndMany($model, $associations) {
$foreignKey = $this->_modelKey($model->name);
foreach ($this->_tables as $otherTable) {
$tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable);
@@ -563,7 +565,7 @@ class ModelTask extends BakeTask {
* @param array $associations Array of inprogress associations
* @return array $associations with hasAndBelongsToMany added in.
*/
- public function findHasAndBelongsToMany(&$model, $associations) {
+ public function findHasAndBelongsToMany($model, $associations) {
$foreignKey = $this->_modelKey($model->name);
foreach ($this->_tables as $otherTable) {
$tempOtherModel = $this->_getModelObject($this->_modelName($otherTable), $otherTable);
@@ -603,7 +605,7 @@ class ModelTask extends BakeTask {
* @param array $associations Array of associations to be confirmed.
* @return array Array of confirmed associations
*/
- public function confirmAssociations(&$model, $associations) {
+ public function confirmAssociations($model, $associations) {
foreach ($associations as $type => $settings) {
if (!empty($associations[$type])) {
$count = count($associations[$type]);
@@ -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.'));
}
/**
diff --git a/cake/console/shells/tasks/plugin.php b/lib/Cake/Console/Command/Task/PluginTask.php
similarity index 82%
rename from cake/console/shells/tasks/plugin.php
rename to lib/Cake/Console/Command/Task/PluginTask.php
index 118273d45..1b6033137 100644
--- a/cake/console/shells/tasks/plugin.php
+++ b/lib/Cake/Console/Command/Task/PluginTask.php
@@ -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(__("Plugin Name: %s", $plugin));
- $this->out(__("Plugin Directory: %s", $this->path . $pluginPath));
+ $this->out(__d('cake_console', "Plugin Name: %s", $plugin));
+ $this->out(__d('cake_console', "Plugin Directory: %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(__('Created: %s in %s', $plugin, $this->path . $pluginPath), 2);
+ $this->out(__d('cake_console', 'Created: %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.')
));
}
diff --git a/cake/console/shells/tasks/project.php b/lib/Cake/Console/Command/Task/ProjectTask.php
similarity index 64%
rename from cake/console/shells/tasks/project.php
rename to lib/Cake/Console/Command/Task/ProjectTask.php
index 433ce9616..368512741 100644
--- a/cake/console/shells/tasks/project.php
+++ b/lib/Cake/Console/Command/Task/ProjectTask.php
@@ -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 = __('A project already exists in this location: %s Overwrite?', $project);
+ $prompt = __d('cake_console', 'A project already exists in this location: %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 NOT created'));
+ $this->err(__d('cake_console', 'The Welcome page was NOT 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(__(' * Remember to check these value after moving to production server'));
+ $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', ' * Remember to check these value after moving to production server'));
} 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(__('Project baked successfully!'));
+ $this->out(__d('cake_console', 'Project baked successfully!'));
} else {
- $this->out(__('Project baked but with some issues..'));
+ $this->out(__d('cake_console', 'Project baked but with some issues..'));
}
return $path;
}
@@ -140,27 +135,35 @@ class ProjectTask extends Shell {
* @access private
*/
function bake($path, $skel = null, $skip = array('empty')) {
- if (!$skel) {
+ if (!$skel && !empty($this->params['skel'])) {
$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));
- if ($skel == '') {
- $this->err(__('The directory path you supplied was empty. Please try again.'));
+ $skel = $this->in(
+ __d('cake_console', "What is the path to the directory layout you wish to copy?"),
+ null,
+ CAKE . 'Console' . DS . 'templates' . DS . 'skel'
+ );
+ if (!$skel) {
+ $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:'),
+ null,
+ CAKE . 'Console' . DS . 'templates' . DS . 'skel'
+ );
}
}
}
$app = basename($path);
- $this->out(__('Skel Directory: ') . $skel);
- $this->out(__('Will be copied to: ') . $path);
+ $this->out(__d('cake_console', 'Skel Directory: ') . $skel);
+ $this->out(__d('cake_console', 'Will be copied to: ') . $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 +173,10 @@ class ProjectTask extends Shell {
if ($Folder->copy(array('to' => $path, 'skip' => $skip))) {
$this->hr();
- $this->out(__('Created: %s in %s', $app, $path));
+ $this->out(__d('cake_console', 'Created: %s in %s', $app, $path));
$this->hr();
} else {
- $this->err(__("Could not create '%s' properly.", $app));
+ $this->err(__d('cake_console', "Could not create '%s' properly.", $app));
return false;
}
@@ -183,7 +186,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 +202,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 +215,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 +239,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 +260,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);
@@ -284,7 +284,7 @@ class ProjectTask extends Shell {
$contents = $File->read();
if (preg_match('/([\s]*define\(\'CAKE_CORE_INCLUDE_PATH\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
$root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'";
- $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', " . $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "');", $contents);
+ $result = str_replace($match[0], "\n\t\tdefine('CAKE_CORE_INCLUDE_PATH', " . $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "');", $contents);
if (!$File->write($result)) {
return false;
}
@@ -295,7 +295,7 @@ class ProjectTask extends Shell {
$File = new File($path . 'webroot' . DS . 'test.php');
$contents = $File->read();
if (preg_match('/([\s]*define\(\'CAKE_CORE_INCLUDE_PATH\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
- $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', " . $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "');", $contents);
+ $result = str_replace($match[0], "\n\t\tdefine('CAKE_CORE_INCLUDE_PATH', " . $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "');", $contents);
if (!$File->write($result)) {
return false;
}
@@ -316,8 +316,8 @@ class ProjectTask extends Shell {
$path = (empty($this->configPath)) ? CONFIGS : $this->configPath;
$File = new File($path . 'core.php');
$contents = $File->read();
- if (preg_match('%([/\s]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%', $contents, $match)) {
- $result = str_replace($match[0], "\t" . 'Configure::write(\'Routing.prefixes\', array(\''.$name.'\'));', $contents);
+ if (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%', $contents, $match)) {
+ $result = str_replace($match[0], "\n" . 'Configure::write(\'Routing.prefixes\', array(\''.$name.'\'));', $contents);
if ($File->write($result)) {
Configure::write('Routing.prefixes', array($name));
return true;
@@ -343,7 +343,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 +352,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(__('Unable to write to /app/config/core.php.'));
+ $this->out(__d('cake_console', 'Unable to write to /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,14 +381,15 @@ 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.')
));
}
-}
+}
\ No newline at end of file
diff --git a/cake/console/shells/tasks/template.php b/lib/Cake/Console/Command/Task/TemplateTask.php
similarity index 92%
rename from cake/console/shells/tasks/template.php
rename to lib/Cake/Console/Command/Task/TemplateTask.php
index 108ffa8a4..189cf7f83 100644
--- a/cake/console/shells/tasks/template.php
+++ b/lib/Cake/Console/Command/Task/TemplateTask.php
@@ -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,12 +54,13 @@ 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);
- $paths[] = $core;
+
$Folder = new Folder($core . 'templates' . DS . 'default');
+
$contents = $Folder->read();
$themeFolders = $contents[0];
@@ -67,6 +69,7 @@ class TemplateTask extends Shell {
$paths[] = $this->_pluginPath($plugin) . 'console' . DS . 'shells' . DS;
$paths[] = $this->_pluginPath($plugin) . 'vendors' . DS . 'shells' . DS;
}
+ $paths[] = $core;
// TEMPORARY TODO remove when all paths are DS terminated
foreach ($paths as $i => $path) {
@@ -167,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;
@@ -178,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];
@@ -205,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;
}
}
diff --git a/cake/console/shells/tasks/test.php b/lib/Cake/Console/Command/Task/TestTask.php
similarity index 76%
rename from cake/console/shells/tasks/test.php
rename to lib/Cake/Console/Command/Task/TestTask.php
index 0fe453040..56ecd502e 100644
--- a/cake/console/shells/tasks/test.php
+++ b/lib/Cake/Console/Command/Task/TestTask.php
@@ -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];
}
/**
@@ -177,14 +189,28 @@ class TestTask extends BakeTask {
* @return string Class name the user chose.
*/
public function getClassName($objectType) {
- $options = App::objects(strtolower($objectType));
- $this->out(__('Choose a %s class', $objectType));
+ $type = strtolower($objectType);
+ if ($this->plugin) {
+ $path = Inflector::pluralize($type);
+ if ($type === 'helper') {
+ $path = 'View/Helper';
+ } elseif ($type === 'component') {
+ $path = 'Controller/Component';
+ } elseif ($type === 'behavior') {
+ $path = 'Model/Behavior';
+ }
+ $plugin = $this->plugin . '.';
+ $options = App::objects($plugin . $type);
+ } else {
+ $options = App::objects($type);
+ }
+ $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];
}
@@ -243,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;
@@ -276,7 +302,7 @@ class TestTask extends BakeTask {
* @param object $subject The object you want to generate fixtures for.
* @return array Array of fixtures to be included in the test.
*/
- public function generateFixtureList(&$subject) {
+ public function generateFixtureList($subject) {
$this->_fixtures = array();
if (is_a($subject, 'Model')) {
$this->_processModel($subject);
@@ -293,7 +319,7 @@ class TestTask extends BakeTask {
* @param Model $subject A Model class to scan for associations and pull fixtures off of.
* @return void
*/
- protected function _processModel(&$subject) {
+ protected function _processModel($subject) {
$this->_addFixture($subject->name);
$associated = $subject->getAssociated();
foreach ($associated as $alias => $type) {
@@ -317,7 +343,7 @@ class TestTask extends BakeTask {
* @param Controller $subject A controller to pull model names off of.
* @return void
*/
- protected function _processController(&$subject) {
+ protected function _processController($subject) {
$subject->constructClasses();
$models = array(Inflector::classify($subject->name));
if (!empty($subject->uses)) {
@@ -352,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);
}
@@ -403,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';
}
/**
@@ -418,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;
}
}
diff --git a/cake/console/shells/tasks/view.php b/lib/Cake/Console/Command/Task/ViewTask.php
similarity index 79%
rename from cake/console/shells/tasks/view.php
rename to lib/Cake/Console/Command/Task/ViewTask.php
index 51c84f2f3..5e9a78c50 100644
--- a/cake/console/shells/tasks/view.php
+++ b/lib/Cake/Console/Command/Task/ViewTask.php
@@ -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 but create the filename after .')
+ 'help' => __d('cake_console', 'Will bake the template in but create the filename after .')
))->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.'));
}
/**
@@ -455,7 +458,7 @@ class ViewTask extends BakeTask {
* @return array $associations
* @access private
*/
- private function __associations(&$model) {
+ private function __associations($model) {
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
$associations = array();
diff --git a/cake/console/shells/testsuite.php b/lib/Cake/Console/Command/TestsuiteShell.php
similarity index 62%
rename from cake/console/shells/testsuite.php
rename to lib/Cake/Console/Command/TestsuiteShell.php
index b8eb079b8..d0d778484 100644
--- a/cake/console/shells/testsuite.php
+++ b/lib/Cake/Console/Command/TestsuiteShell.php
@@ -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,111 +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' => __(' Log test execution in JUnit XML format to file.'),
+ 'help' => __d('cake_console', ' Log test execution in JUnit XML format to file.'),
'default' => false
))->addOption('log-json', array(
- 'help' => __(' Log test execution in TAP format to file.'),
+ 'help' => __d('cake_console', ' Log test execution in TAP format to file.'),
'default' => false
))->addOption('log-tap', array(
- 'help' => __(' Log test execution in TAP format to file.'),
+ 'help' => __d('cake_console', ' 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' => __(' Generate code coverage report in HTML format.'),
+ 'help' => __d('cake_console', ' Generate code coverage report in HTML format.'),
'default' => false
))->addOption('coverage-clover', array(
- 'help' => __(' Write code coverage data in Clover XML format.'),
+ 'help' => __d('cake_console', ' Write code coverage data in Clover XML format.'),
'default' => false
))->addOption('testdox-html', array(
- 'help' => __(' Write agile documentation in HTML format to file.'),
+ 'help' => __d('cake_console', ' Write agile documentation in HTML format to file.'),
'default' => false
))->addOption('testdox-text', array(
- 'help' => __(' Write agile documentation in Text format to file.'),
+ 'help' => __d('cake_console', ' Write agile documentation in Text format to file.'),
'default' => false
))->addOption('filter', array(
- 'help' => __(' Filter which tests to run.'),
+ 'help' => __d('cake_console', ' Filter which tests to run.'),
'default' => false
))->addOption('group', array(
- 'help' => __(' Only runs tests from the specified group(s).'),
+ 'help' => __d('cake_console', ' Only runs tests from the specified group(s).'),
'default' => false
))->addOption('exclude-group', array(
- 'help' => __(' Exclude tests from the specified group(s).'),
+ 'help' => __d('cake_console', ' 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' => __(' Runs the test(s) repeatedly.'),
+ 'help' => __d('cake_console', ' 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' => __(' A "bootstrap" PHP file that is run before the tests.'),
+ 'help' => __d('cake_console', ' A "bootstrap" PHP file that is run before the tests.'),
'default' => false
- ))->addOption('configuraion', array(
- 'help' => __(' Read configuration from XML file.'),
+ ))->addOption('configuration', array(
+ 'help' => __d('cake_console', ' 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' => __(' Prepend PHP include_path with given path(s).'),
+ 'help' => __d('cake_console', ' 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' => __d('cake_console', 'Choose a custom fixture manager.'),
));
return $parser;
@@ -154,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 . 'test_manager.php';
}
/**
@@ -178,6 +176,7 @@ class TestSuiteShell extends Shell {
return;
}
$params = array(
+ 'core' => false,
'app' => false,
'plugin' => null,
'output' => 'text',
@@ -185,14 +184,16 @@ class TestSuiteShell extends Shell {
$category = $this->args[0];
- if ($category == 'app') {
+ if ($category == 'core') {
+ $params['core'] = true;
+ } elseif ($category == 'app') {
$params['app'] = true;
} elseif ($category != 'core') {
$params['plugin'] = $category;
}
if (isset($this->args[1])) {
- $params['case'] = Inflector::underscore($this->args[1]);
+ $params['case'] = $this->args[1];
}
return $params;
}
@@ -231,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();
@@ -251,12 +252,10 @@ class TestSuiteShell extends Shell {
* @return void
*/
protected function run($runnerArgs, $options = array()) {
- require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_runner.php';
-
restore_error_handler();
restore_error_handler();
- $testCli = new TestRunner($runnerArgs);
+ $testCli = new CakeTestSuiteCommand('CakeTestLoader', $runnerArgs);
$testCli->run($options);
}
@@ -267,7 +266,7 @@ class TestSuiteShell extends Shell {
*/
public function available() {
$params = $this->parseArgs();
- $testCases = TestManager::getTestCaseList($params);
+ $testCases = CakeTestLoader::generateTestList($params);
$app = $params['app'];
$plugin = $params['plugin'];
@@ -282,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());
}
@@ -290,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];
diff --git a/cake/console/libs/console_error_handler.php b/lib/Cake/Console/ConsoleErrorHandler.php
similarity index 87%
rename from cake/console/libs/console_error_handler.php
rename to lib/Cake/Console/ConsoleErrorHandler.php
index 80136bbcf..9020bd1be 100644
--- a/cake/console/libs/console_error_handler.php
+++ b/lib/Cake/Console/ConsoleErrorHandler.php
@@ -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: %s\n%s"),
+ __d('cake_console', "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(__("%s Error: %s\n", $name, $message));
+ $message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line);
+ $stderr->write(__d('cake_console', "%s Error: %s\n", $name, $message));
if (Configure::read('debug') == 0) {
- App::import('Core', 'CakeLog');
CakeLog::write($log, $message);
}
}
diff --git a/cake/console/libs/console_input.php b/lib/Cake/Console/ConsoleInput.php
similarity index 100%
rename from cake/console/libs/console_input.php
rename to lib/Cake/Console/ConsoleInput.php
diff --git a/cake/console/libs/console_input_argument.php b/lib/Cake/Console/ConsoleInputArgument.php
similarity index 93%
rename from cake/console/libs/console_input_argument.php
rename to lib/Cake/Console/ConsoleInputArgument.php
index 263475e9d..885ce2180 100644
--- a/cake/console/libs/console_input_argument.php
+++ b/lib/Cake/Console/ConsoleInputArgument.php
@@ -95,10 +95,10 @@ class ConsoleInputArgument {
}
$optional = '';
if (!$this->isRequired()) {
- $optional = __(' (optional)');
+ $optional = __d('cake_console', ' (optional)');
}
if (!empty($this->_choices)) {
- $optional .= __(' (choices: %s)', implode('|', $this->_choices));
+ $optional .= __d('cake_console', ' (choices: %s)', 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)
));
}
diff --git a/cake/console/libs/console_input_option.php b/lib/Cake/Console/ConsoleInputOption.php
similarity index 94%
rename from cake/console/libs/console_input_option.php
rename to lib/Cake/Console/ConsoleInputOption.php
index 3c9049248..61497e5e4 100644
--- a/cake/console/libs/console_input_option.php
+++ b/lib/Cake/Console/ConsoleInputOption.php
@@ -119,10 +119,10 @@ class ConsoleInputOption {
public function help($width = 0) {
$default = $short = '';
if (!empty($this->_default) && $this->_default !== true) {
- $default = __(' (default: %s)', $this->_default);
+ $default = __d('cake_console', ' (default: %s)', $this->_default);
}
if (!empty($this->_choices)) {
- $default .= __(' (choices: %s)', implode('|', $this->_choices));
+ $default .= __d('cake_console', ' (choices: %s)', 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)
));
}
diff --git a/cake/console/libs/console_input_subcommand.php b/lib/Cake/Console/ConsoleInputSubcommand.php
similarity index 100%
rename from cake/console/libs/console_input_subcommand.php
rename to lib/Cake/Console/ConsoleInputSubcommand.php
diff --git a/cake/console/libs/console_option_parser.php b/lib/Cake/Console/ConsoleOptionParser.php
similarity index 96%
rename from cake/console/libs/console_option_parser.php
rename to lib/Cake/Console/ConsoleOptionParser.php
index a96a0759a..6c221502b 100644
--- a/cake/console/libs/console_option_parser.php
+++ b/lib/Cake/Console/ConsoleOptionParser.php
@@ -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)) {
diff --git a/cake/console/libs/console_output.php b/lib/Cake/Console/ConsoleOutput.php
similarity index 100%
rename from cake/console/libs/console_output.php
rename to lib/Cake/Console/ConsoleOutput.php
diff --git a/cake/console/libs/help_formatter.php b/lib/Cake/Console/HelpFormatter.php
similarity index 97%
rename from cake/console/libs/help_formatter.php
rename to lib/Cake/Console/HelpFormatter.php
index f454fa8b2..94a32af88 100644
--- a/cake/console/libs/help_formatter.php
+++ b/lib/Cake/Console/HelpFormatter.php
@@ -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 `cake %s [subcommand] --help`'),
+ __d('cake_console', 'To see help on a subcommand use `cake %s [subcommand] --help`'),
$parser->command()
);
$out[] = '';
diff --git a/cake/console/shells/shell.php b/lib/Cake/Console/Shell.php
similarity index 94%
rename from cake/console/shells/shell.php
rename to lib/Cake/Console/Shell.php
index dd59dbb2c..ad5b716fa 100644
--- a/cake/console/shells/shell.php
+++ b/lib/Cake/Console/Shell.php
@@ -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: %s', $title));
+ $this->err(__d('cake_console', '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(__('File `%s` exists', $path));
- $key = $this->in(__('Do you want to overwrite?'), array('y', 'n', 'q'), 'n');
+ $this->out(__d('cake_console', 'File `%s` exists', $path));
+ $key = $this->in(__d('cake_console', 'Do you want to overwrite?'), array('y', 'n', 'q'), 'n');
if (strtolower($key) == 'q') {
- $this->out(__('Quitting.'), 2);
+ $this->out(__d('cake_console', 'Quitting.'), 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(__('Wrote `%s`', $path));
+ $this->out(__d('cake_console', 'Wrote `%s`', $path));
return true;
} else {
- $this->err(__('Could not write to `%s`.', $path), 2);
+ $this->err(__d('cake_console', 'Could not write to `%s`.', $path), 2);
return false;
}
}
@@ -628,7 +627,10 @@ class Shell extends Object {
* @return boolean Success
*/
protected function _checkUnitTest() {
- if (App::import('vendor', 'simpletest' . DS . 'simpletest')) {
+ if (App::import('Vendor', 'phpunit', array('file' => 'PHPUnit' . DS . 'Autoload.php'))) {
+ return true;
+ }
+ if (@include 'PHPUnit' . DS . 'Autoload.php') {
return true;
}
$prompt = 'PHPUnit is not installed. Do you want to bake unit test files anyway?';
@@ -661,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);
}
/**
diff --git a/cake/console/shell_dispatcher.php b/lib/Cake/Console/ShellDispatcher.php
similarity index 91%
rename from cake/console/shell_dispatcher.php
rename to lib/Cake/Console/ShellDispatcher.php
index 1b520500b..465b6d303 100644
--- a/cake/console/shell_dispatcher.php
+++ b/lib/Cake/Console/ShellDispatcher.php
@@ -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,16 @@ 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 +206,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 +228,9 @@ class ShellDispatcher {
$this->_parsePaths($args);
$defaults = array(
- 'app' => 'app',
- 'root' => dirname(dirname(dirname(__FILE__))),
- 'working' => null,
+ 'app' => 'app',
+ 'root' => dirname(dirname(dirname(dirname(__FILE__)))),
+ 'working' => null,
'webroot' => 'webroot'
);
$params = array_merge($defaults, array_intersect_key($this->params, $defaults));
@@ -244,6 +243,9 @@ class ShellDispatcher {
}
$params = str_replace('\\', '/', $params);
+ if (isset($params['working'])) {
+ $params['working'] = trim($params['working']);
+ }
if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) {
if (empty($this->params['app']) && $params['working'] != $params['root']) {
$params['root'] = dirname($params['working']);
@@ -260,7 +262,10 @@ class ShellDispatcher {
}
$params['app'] = basename($params['app']);
- $params['working'] = rtrim($params['root'], '/') . '/' . $params['app'];
+ $params['working'] = rtrim($params['root'], '/');
+ if (!$isWin || !preg_match('/^[A-Z]:$/i', $params['app'])) {
+ $params['working'] .= '/' . $params['app'];
+ }
if (!empty($matches[0]) || !empty($isWin)) {
$params = str_replace('/', '\\', $params);
@@ -317,4 +322,4 @@ class ShellDispatcher {
protected function _stop($status = 0) {
exit($status);
}
-}
\ No newline at end of file
+}
diff --git a/cake/console/libs/task_collection.php b/lib/Cake/Console/TaskCollection.php
similarity index 86%
rename from cake/console/libs/task_collection.php
rename to lib/Cake/Console/TaskCollection.php
index 32f0b31a4..3c911a2ce 100644
--- a/cake/console/libs/task_collection.php
+++ b/lib/Cake/Console/TaskCollection.php
@@ -15,7 +15,8 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'ObjectCollection');
+
+App::uses('ObjectCollection', 'Utility');
class TaskCollection extends ObjectCollection {
/**
@@ -48,11 +49,10 @@ class TaskCollection extends ObjectCollection {
*
* @param string $task Task name to load
* @param array $settings Settings for the task.
- * @param boolean $enable Whether or not this task should be enabled by default
* @return Task A task object, Either the existing loaded task or a new one.
* @throws MissingTaskFileException, MissingTaskClassException when the task could not be found
*/
- public function load($task, $settings = array(), $enable = true) {
+ public function load($task, $settings = array()) {
list($plugin, $name) = pluginSplit($task, true);
if (isset($this->_loaded[$name])) {
@@ -60,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);
}
@@ -72,6 +70,7 @@ class TaskCollection extends ObjectCollection {
$this->_loaded[$name] = new $taskClass(
$this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin
);
+ $enable = isset($settings['enabled']) ? $settings['enabled'] : true;
if ($enable === true) {
$this->_enabled[] = $name;
}
diff --git a/cake/console/cake b/lib/Cake/Console/cake
similarity index 100%
rename from cake/console/cake
rename to lib/Cake/Console/cake
diff --git a/cake/console/cake.bat b/lib/Cake/Console/cake.bat
similarity index 90%
rename from cake/console/cake.bat
rename to lib/Cake/Console/cake.bat
index 40a271425..a22cfcacd 100644
--- a/cake/console/cake.bat
+++ b/lib/Cake/Console/cake.bat
@@ -25,7 +25,7 @@
SET app=%0
SET lib=%~dp0
-php -q "%lib%cake.php" -working "%CD%" %*
+php -q "%lib%cake.php" -working "%CD% " %*
echo.
diff --git a/cake/console/cake.php b/lib/Cake/Console/cake.php
similarity index 90%
rename from cake/console/cake.php
rename to lib/Cake/Console/cake.php
index c9bce3193..4c8188b2c 100644
--- a/cake/console/cake.php
+++ b/lib/Cake/Console/cake.php
@@ -19,7 +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);
-
diff --git a/cake/console/templates/default/actions/controller_actions.ctp b/lib/Cake/Console/templates/default/actions/controller_actions.ctp
similarity index 93%
rename from cake/console/templates/default/actions/controller_actions.ctp
rename to lib/Cake/Console/templates/default/actions/controller_actions.ctp
index e6f0f8e83..1b59ba650 100644
--- a/cake/console/templates/default/actions/controller_actions.ctp
+++ b/lib/Cake/Console/templates/default/actions/controller_actions.ctp
@@ -18,11 +18,22 @@
*/
?>
+/**
+ * index method
+ *
+ * @return void
+ */
public function index() {
$this->->recursive = 0;
$this->set('', $this->paginate());
}
+/**
+ * view method
+ *
+ * @param string $id
+ * @return void
+ */
public function view($id = null) {
$this->->id = $id;
if (!$this->->exists()) {
@@ -32,6 +43,11 @@
}
+/**
+ * add method
+ *
+ * @return void
+ */
public function add() {
if ($this->request->is('post')) {
$this->->create();
@@ -66,6 +82,12 @@
}
+/**
+ * edit method
+ *
+ * @param string $id
+ * @return void
+ */
public function edit($id = null) {
$this->->id = $id;
if (!$this->->exists()) {
@@ -104,6 +126,12 @@
?>
}
+/**
+ * delete method
+ *
+ * @param string $id
+ * @return void
+ */
public function delete($id = null) {
if (!$this->request->is('post')) {
throw new MethodNotAllowedException();
diff --git a/cake/console/templates/default/classes/controller.ctp b/lib/Cake/Console/templates/default/classes/controller.ctp
similarity index 88%
rename from cake/console/templates/default/classes/controller.ctp
rename to lib/Cake/Console/templates/default/classes/controller.ctp
index 52f968824..f4dc9c9eb 100644
--- a/cake/console/templates/default/classes/controller.ctp
+++ b/lib/Cake/Console/templates/default/classes/controller.ctp
@@ -21,14 +21,23 @@
echo "
+/**
+ * Controller
+ *
+ */
class Controller extends AppController {
- public $name = '';
+/**
+ * Scaffold
+ *
+ * @var mixed
+ */
public $scaffold;
-/* Fixture generated on: */
+/* Fixture generated on: */
+
+/**
+ * Fixture
+ *
+ */
class Fixture extends CakeTestFixture {
- public $name = '';
+/**
+ * Table name
+ *
+ * @var string
+ */
public $table = '';
+/**
+ * Import
+ *
+ * @var array
+ */
public $import = ;
+/**
+ * Fields
+ *
+ * @var array
+ */
public $fields = ;
+/**
+ * Records
+ *
+ * @var array
+ */
public $records = ;
}
diff --git a/cake/console/templates/default/classes/model.ctp b/lib/Cake/Console/templates/default/classes/model.ctp
similarity index 90%
rename from cake/console/templates/default/classes/model.ctp
rename to lib/Cake/Console/templates/default/classes/model.ctp
index ece196dba..f824e8a16 100644
--- a/cake/console/templates/default/classes/model.ctp
+++ b/lib/Cake/Console/templates/default/classes/model.ctp
@@ -20,23 +20,43 @@
*/
echo "
+/**
+ * Model
+ *
+ */
class extends AppModel {
- public $name = '';
+/**
+ * Use database config
+ *
+ * @var string
+ */
public $useDbConfig = '';
+/**
+ * Primary key field
+ *
+ * @var string
+ */
public $primaryKey = '';
+/**
+ * Display field
+ *
+ * @var string
+ */
public $displayField = '';
$validations):
echo "\t\t'$field' => array(\n";
@@ -58,6 +78,7 @@ endif;
foreach ($associations as $assoc):
if (!empty($assoc)):
?>
+
//The Associations below have been created with all possible keys, those that are not needed can be removed
$relation):
$out = "\n\t\t'{$relation['alias']}' => array(\n";
@@ -87,6 +109,7 @@ endforeach;
if (!empty($associations['hasMany'])):
$belongsToCount = count($associations['hasMany']);
+ echo "\n/**\n * hasMany associations\n *\n * @var array\n */";
echo "\n\tpublic \$hasMany = array(";
foreach ($associations['hasMany'] as $i => $relation):
$out = "\n\t\t'{$relation['alias']}' => array(\n";
@@ -112,6 +135,7 @@ endif;
if (!empty($associations['hasAndBelongsToMany'])):
$habtmCount = count($associations['hasAndBelongsToMany']);
+ echo "\n/**\n * hasAndBelongsToMany associations\n *\n * @var array\n */";
echo "\n\tpublic \$hasAndBelongsToMany = array(";
foreach ($associations['hasAndBelongsToMany'] as $i => $relation):
$out = "\n\t\t'{$relation['alias']}' => array(\n";
diff --git a/cake/console/templates/default/classes/test.ctp b/lib/Cake/Console/templates/default/classes/test.ctp
similarity index 68%
rename from cake/console/templates/default/classes/test.ctp
rename to lib/Cake/Console/templates/default/classes/test.ctp
index f9dd98b0b..331347099 100644
--- a/cake/console/templates/default/classes/test.ctp
+++ b/lib/Cake/Console/templates/default/classes/test.ctp
@@ -18,35 +18,80 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
echo "
-App::import('', '');
+App::uses('', '');
+/**
+ * Test
+ *
+ */
class Test extends {
+/**
+ * Auto render
+ *
+ * @var boolean
+ */
public $autoRender = false;
+/**
+ * Redirect action
+ *
+ * @param mixed $url
+ * @param mixed $status
+ * @param boolean $exit
+ * @return void
+ */
public function redirect($url, $status = null, $exit = true) {
$this->redirectUrl = $url;
}
}
+/**
+ * Test Case
+ *
+ */
class TestCase extends CakeTestCase {
+/**
+ * Fixtures
+ *
+ * @var array
+ */
public $fixtures = array('');
- public function startTest() {
+/**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp() {
+ parent::setUp();
+
$this->
}
- public function endTest() {
+/**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown() {
unset($this->);
ClassRegistry::flush();
+
+ parent::tearDown();
}
+/**
+ * test method
+ *
+ * @return void
+ */
public function test() {
}
diff --git a/cake/console/templates/default/views/form.ctp b/lib/Cake/Console/templates/default/views/form.ctp
similarity index 95%
rename from cake/console/templates/default/views/form.ctp
rename to lib/Cake/Console/templates/default/views/form.ctp
index ce2b525f9..b466611d3 100644
--- a/cake/console/templates/default/views/form.ctp
+++ b/lib/Cake/Console/templates/default/views/form.ctp
@@ -19,7 +19,7 @@