Merge remote branch 'origin/2.0' into 2.0-class-loading

Conflicts:
	lib/Cake/Model/ConnectionManager.php
	lib/Cake/basics.php
This commit is contained in:
José Lorenzo Rodríguez 2010-12-05 23:43:58 -04:30
commit 3f64844de9
97 changed files with 827 additions and 438 deletions

View file

@ -35,12 +35,7 @@
* sqlite - SQLite (PHP5 only), * sqlite - SQLite (PHP5 only),
* postgres - PostgreSQL 7 and higher, * postgres - PostgreSQL 7 and higher,
* mssql - Microsoft SQL Server 2000 and higher, * mssql - Microsoft SQL Server 2000 and higher,
* db2 - IBM DB2, Cloudscape, and Apache Derby (http://php.net/ibm-db2)
* oracle - Oracle 8 and higher * oracle - Oracle 8 and higher
* firebird - Firebird/Interbase
* sybase - Sybase ASE
* adodb-[drivername] - ADOdb interface wrapper (see below),
* odbc - ODBC DBO driver
* *
* You can add custom database drivers (or override existing drivers) by adding the * You can add custom database drivers (or override existing drivers) by adding the
* appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php', * appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php',
@ -49,12 +44,6 @@
* persistent => true / false * persistent => true / false
* Determines whether or not the database should use a persistent connection * Determines whether or not the database should use a persistent connection
* *
* connect =>
* ADOdb set the connect to one of these
* (http://phplens.com/adodb/supported.databases.html) and
* append it '|p' for persistent connection. (mssql|p for example, or just mssql for not persistent)
* For all other databases, this setting is deprecated.
*
* host => * host =>
* the host you connect to the database. To add a socket or port number, use 'port' => # * the host you connect to the database. To add a socket or port number, use 'port' => #
* *
@ -63,11 +52,11 @@
* on a per-table basis with the Model::$tablePrefix property. * on a per-table basis with the Model::$tablePrefix property.
* *
* schema => * schema =>
* For Postgres and DB2, specifies which schema you would like to use the tables in. Postgres defaults to * For Postgresspecifies which schema you would like to use the tables in. Postgres defaults to
* 'public', DB2 defaults to empty. * 'public', DB2 defaults to empty.
* *
* encoding => * encoding =>
* For MySQL, MySQLi, Postgres and DB2, specifies the character encoding to use when connecting to the * For MySQL, MySQLi, Postgres specifies the character encoding to use when connecting to the
* database. Uses database default. * database. Uses database default.
* *
*/ */

View file

@ -55,7 +55,7 @@ class ConsoleErrorHandler extends ErrorHandler {
* *
* @return void * @return void
*/ */
public static function handleException($exception) { public static function handleException(Exception $exception) {
$stderr = self::getStderr(); $stderr = self::getStderr();
$stderr->write(sprintf( $stderr->write(sprintf(
__("<error>Error:</error> %s\n%s"), __("<error>Error:</error> %s\n%s"),
@ -75,8 +75,8 @@ class ConsoleErrorHandler extends ErrorHandler {
} }
$stderr = self::getStderr(); $stderr = self::getStderr();
list($name, $log) = self::_mapErrorCode($code); list($name, $log) = self::_mapErrorCode($code);
$message = sprintf(__('%s in [%s, line %s]'), $description, $file, $line); $message = __('%s in [%s, line %s]', $description, $file, $line);
$stderr->write(sprintf(__("<error>%s Error:</error> %s\n"), $name, $message)); $stderr->write(__("<error>%s Error:</error> %s\n", $name, $message));
if (Configure::read('debug') == 0) { if (Configure::read('debug') == 0) {
App::import('Core', 'CakeLog'); App::import('Core', 'CakeLog');

View file

@ -75,7 +75,7 @@ class ConsoleInputArgument {
$optional = __(' <comment>(optional)</comment>'); $optional = __(' <comment>(optional)</comment>');
} }
if (!empty($this->_choices)) { if (!empty($this->_choices)) {
$optional .= sprintf(__(' <comment>(choices: %s)</comment>'), implode('|', $this->_choices)); $optional .= __(' <comment>(choices: %s)</comment>', implode('|', $this->_choices));
} }
return sprintf('%s%s%s', $name, $this->_help, $optional); return sprintf('%s%s%s', $name, $this->_help, $optional);
} }

View file

@ -82,10 +82,10 @@ class ConsoleInputOption {
public function help($width = 0) { public function help($width = 0) {
$default = $short = ''; $default = $short = '';
if (!empty($this->_default) && $this->_default !== true) { if (!empty($this->_default) && $this->_default !== true) {
$default = sprintf(__(' <comment>(default: %s)</comment>'), $this->_default); $default = __(' <comment>(default: %s)</comment>', $this->_default);
} }
if (!empty($this->_choices)) { if (!empty($this->_choices)) {
$default .= sprintf(__(' <comment>(choices: %s)</comment>'), implode('|', $this->_choices)); $default .= __(' <comment>(choices: %s)</comment>', implode('|', $this->_choices));
} }
if (!empty($this->_short)) { if (!empty($this->_short)) {
$short = ', -' . $this->_short; $short = ', -' . $this->_short;

View file

@ -458,7 +458,7 @@ class ConsoleOptionParser {
foreach ($this->_args as $i => $arg) { foreach ($this->_args as $i => $arg) {
if ($arg->isRequired() && !isset($args[$i]) && empty($params['help'])) { if ($arg->isRequired() && !isset($args[$i]) && empty($params['help'])) {
throw new RuntimeException( throw new RuntimeException(
sprintf(__('Missing required arguments. %s is required.'), $arg->name()) __('Missing required arguments. %s is required.', $arg->name())
); );
} }
} }
@ -552,7 +552,7 @@ class ConsoleOptionParser {
*/ */
protected function _parseOption($name, $params) { protected function _parseOption($name, $params) {
if (!isset($this->_options[$name])) { if (!isset($this->_options[$name])) {
throw new InvalidArgumentException(sprintf(__('Unknown option `%s`'), $name)); throw new InvalidArgumentException(__('Unknown option `%s`', $name));
} }
$option = $this->_options[$name]; $option = $this->_options[$name];
$isBoolean = $option->isBoolean(); $isBoolean = $option->isBoolean();

View file

@ -90,14 +90,10 @@ class ShellDispatcher {
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__)))); define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__))));
define('CAKEPHP_SHELL', true); define('CAKEPHP_SHELL', true);
if (!defined('CORE_PATH')) { if (!defined('CORE_PATH')) {
if (function_exists('ini_set') && ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ini_get('include_path'))) {
define('CORE_PATH', null);
} else {
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
} }
} }
} }
}
/** /**
* Defines current working environment. * Defines current working environment.

View file

@ -78,7 +78,7 @@ class AclShell extends Shell {
$out .= __('your core config to reflect your decision to use') . "\n"; $out .= __('your core config to reflect your decision to use') . "\n";
$out .= __('DbAcl before attempting to use this script') . ".\n"; $out .= __('DbAcl before attempting to use this script') . ".\n";
$out .= "--------------------------------------------------\n"; $out .= "--------------------------------------------------\n";
$out .= sprintf(__('Current ACL Classname: %s'), Configure::read('Acl.classname')) . "\n"; $out .= __('Current ACL Classname: %s', Configure::read('Acl.classname')) . "\n";
$out .= "--------------------------------------------------\n"; $out .= "--------------------------------------------------\n";
$this->err($out); $this->err($out);
$this->_stop(); $this->_stop();
@ -135,9 +135,9 @@ class AclShell extends Shell {
$data['parent_id'] = $parent; $data['parent_id'] = $parent;
$this->Acl->{$class}->create(); $this->Acl->{$class}->create();
if ($this->Acl->{$class}->save($data)) { if ($this->Acl->{$class}->save($data)) {
$this->out(sprintf(__("<success>New %s</success> '%s' created."), $class, $this->args[2]), 2); $this->out(__("<success>New %s</success> '%s' created.", $class, $this->args[2]), 2);
} else { } else {
$this->err(sprintf(__("There was a problem creating a new %s '%s'."), $class, $this->args[2])); $this->err(__("There was a problem creating a new %s '%s'.", $class, $this->args[2]));
} }
} }
@ -152,9 +152,9 @@ class AclShell extends Shell {
$nodeId = $this->_getNodeId($class, $identifier); $nodeId = $this->_getNodeId($class, $identifier);
if (!$this->Acl->{$class}->delete($nodeId)) { if (!$this->Acl->{$class}->delete($nodeId)) {
$this->error(__('Node Not Deleted') . sprintf(__('There was an error deleting the %s. Check that the node exists'), $class) . ".\n"); $this->error(__('Node Not Deleted') . __('There was an error deleting the %s. Check that the node exists', $class) . ".\n");
} }
$this->out(sprintf(__('<success>%s deleted.</success>'), $class), 2); $this->out(__('<success>%s deleted.</success>', $class), 2);
} }
/** /**
@ -176,7 +176,7 @@ class AclShell extends Shell {
if (!$this->Acl->{$class}->save($data)) { 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(__('Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.'), true);
} else { } else {
$this->out(sprintf(__('Node parent set to %s'), $this->args[2]) . "\n", true); $this->out(__('Node parent set to %s', $this->args[2]) . "\n", true);
} }
} }
@ -193,7 +193,7 @@ class AclShell extends Shell {
if (empty($nodes)) { if (empty($nodes)) {
$this->error( $this->error(
sprintf(__("Supplied Node '%s' not found"), $this->args[1]), __("Supplied Node '%s' not found", $this->args[1]),
__('No tree returned.') __('No tree returned.')
); );
} }
@ -230,9 +230,9 @@ class AclShell extends Shell {
extract($this->__getParams()); extract($this->__getParams());
if ($this->Acl->check($aro, $aco, $action)) { if ($this->Acl->check($aro, $aco, $action)) {
$this->out(sprintf(__('%s is <success>allowed</success>.'), $aroName), true); $this->out(__('%s is <success>allowed</success>.', $aroName), true);
} else { } else {
$this->out(sprintf(__('%s is <error>not allowed</error>.'), $aroName), true); $this->out(__('%s is <error>not allowed</error>.', $aroName), true);
} }
} }
@ -305,9 +305,9 @@ class AclShell extends Shell {
if (empty($nodes)) { if (empty($nodes)) {
if (isset($this->args[1])) { if (isset($this->args[1])) {
$this->error(sprintf(__('%s not found'), $this->args[1]), __('No tree returned.')); $this->error(__('%s not found', $this->args[1]), __('No tree returned.'));
} elseif (isset($this->args[0])) { } elseif (isset($this->args[0])) {
$this->error(sprintf(__('%s not found'), $this->args[0]), __('No tree returned.')); $this->error(__('%s not found', $this->args[0]), __('No tree returned.'));
} }
} }
$this->out($class . " tree:"); $this->out($class . " tree:");
@ -522,7 +522,7 @@ class AclShell extends Shell {
$conditions = array($class . '.' . $key => $this->args[1]); $conditions = array($class . '.' . $key => $this->args[1]);
$possibility = $this->Acl->{$class}->find('all', compact('conditions')); $possibility = $this->Acl->{$class}->find('all', compact('conditions'));
if (empty($possibility)) { if (empty($possibility)) {
$this->error(sprintf(__('%s not found'), $this->args[1]), __('No tree returned.')); $this->error(__('%s not found', $this->args[1]), __('No tree returned.'));
} }
return $possibility; return $possibility;
} }
@ -558,7 +558,7 @@ class AclShell extends Shell {
if (is_array($identifier)) { if (is_array($identifier)) {
$identifier = var_export($identifier, true); $identifier = var_export($identifier, true);
} }
$this->error(sprintf(__('Could not find node using reference "%s"'), $identifier)); $this->error(__('Could not find node using reference "%s"', $identifier));
} }
return Set::extract($node, "0.{$class}.id"); return Set::extract($node, "0.{$class}.id");
} }

View file

@ -87,7 +87,7 @@ class ApiShell extends Shell {
} }
} else { } else {
$this->error(sprintf(__('%s not found'), $class)); $this->error(__('%s not found', $class));
} }
$parsed = $this->__parseClass($path . $file .'.php', $class); $parsed = $this->__parseClass($path . $file .'.php', $class);
@ -95,7 +95,7 @@ class ApiShell extends Shell {
if (!empty($parsed)) { if (!empty($parsed)) {
if (isset($this->params['method'])) { if (isset($this->params['method'])) {
if (!isset($parsed[$this->params['method']])) { if (!isset($parsed[$this->params['method']])) {
$this->err(sprintf(__('%s::%s() could not be found'), $class, $this->params['method'])); $this->err(__('%s::%s() could not be found', $class, $this->params['method']));
$this->_stop(); $this->_stop();
} }
$method = $parsed[$this->params['method']]; $method = $parsed[$this->params['method']];
@ -200,7 +200,7 @@ class ApiShell extends Shell {
$parsed = array(); $parsed = array();
if (!include_once($path)) { if (!include_once($path)) {
$this->err(sprintf(__('%s could not be found'), $path)); $this->err(__('%s could not be found', $path));
} }
$reflection = new ReflectionClass($class); $reflection = new ReflectionClass($class);

View file

@ -114,7 +114,7 @@ class SchemaShell extends Shell {
$this->_stop(); $this->_stop();
} else { } else {
$file = $this->Schema->path . DS . $this->params['file']; $file = $this->Schema->path . DS . $this->params['file'];
$this->err(sprintf(__('Schema file (%s) could not be found.'), $file)); $this->err(__('Schema file (%s) could not be found.', $file));
$this->_stop(); $this->_stop();
} }
} }
@ -179,7 +179,7 @@ class SchemaShell extends Shell {
} }
if ($this->Schema->write($content)) { if ($this->Schema->write($content)) {
$this->out(sprintf(__('Schema file: %s generated'), $content['file'])); $this->out(__('Schema file: %s generated', $content['file']));
$this->_stop(); $this->_stop();
} else { } else {
$this->err(__('Schema file: %s generated')); $this->err(__('Schema file: %s generated'));
@ -224,7 +224,7 @@ class SchemaShell extends Shell {
} }
if ($File->write($contents)) { if ($File->write($contents)) {
$this->out(sprintf(__('SQL dump file created in %s'), $File->pwd())); $this->out(__('SQL dump file created in %s', $File->pwd()));
$this->_stop(); $this->_stop();
} else { } else {
$this->err(__('SQL dump could not be created')); $this->err(__('SQL dump could not be created'));
@ -283,7 +283,7 @@ class SchemaShell extends Shell {
$Schema = $this->Schema->load($options); $Schema = $this->Schema->load($options);
if (!$Schema) { if (!$Schema) {
$this->err(sprintf(__('%s could not be loaded'), $this->Schema->path . DS . $this->Schema->file)); $this->err(__('%s could not be loaded', $this->Schema->path . DS . $this->Schema->file));
$this->_stop(); $this->_stop();
} }
$table = null; $table = null;
@ -394,10 +394,10 @@ class SchemaShell extends Shell {
foreach ($contents as $table => $sql) { foreach ($contents as $table => $sql) {
if (empty($sql)) { if (empty($sql)) {
$this->out(sprintf(__('%s is up to date.'), $table)); $this->out(__('%s is up to date.', $table));
} else { } else {
if ($this->__dry === true) { if ($this->__dry === true) {
$this->out(sprintf(__('Dry run for %s :'), $table)); $this->out(__('Dry run for %s :', $table));
$this->out($sql); $this->out($sql);
} else { } else {
if (!$Schema->before(array($event => $table))) { if (!$Schema->before(array($event => $table))) {
@ -413,7 +413,7 @@ class SchemaShell extends Shell {
if (!empty($error)) { if (!empty($error)) {
$this->out($error); $this->out($error);
} else { } else {
$this->out(sprintf(__('%s updated.'), $table)); $this->out(__('%s updated.', $table));
} }
} }
} }

View file

@ -558,7 +558,7 @@ class Shell extends Object {
* @param string $message An optional error message * @param string $message An optional error message
*/ */
public function error($title, $message = null) { public function error($title, $message = null) {
$this->err(sprintf(__('<error>Error:</error> %s'), $title)); $this->err(__('<error>Error:</error> %s', $title));
if (!empty($message)) { if (!empty($message)) {
$this->err($message); $this->err($message);
@ -594,18 +594,18 @@ class Shell extends Object {
$this->out(); $this->out();
if (is_file($path) && $this->interactive === true) { if (is_file($path) && $this->interactive === true) {
$this->out(sprintf(__('<warning>File `%s` exists</warning>'), $path)); $this->out(__('<warning>File `%s` exists</warning>', $path));
$key = $this->in(__('Do you want to overwrite?'), array('y', 'n', 'q'), 'n'); $key = $this->in(__('Do you want to overwrite?'), array('y', 'n', 'q'), 'n');
if (strtolower($key) == 'q') { if (strtolower($key) == 'q') {
$this->out(__('<error>Quitting</error>.'), 2); $this->out(__('<error>Quitting</error>.'), 2);
$this->_stop(); $this->_stop();
} elseif (strtolower($key) != 'y') { } elseif (strtolower($key) != 'y') {
$this->out(sprintf(__('Skip `%s`'), $path), 2); $this->out(__('Skip `%s`', $path), 2);
return false; return false;
} }
} else { } else {
$this->out(sprintf(__('Creating file %s'), $path)); $this->out(__('Creating file %s', $path));
} }
if (!class_exists('File')) { if (!class_exists('File')) {
@ -615,10 +615,10 @@ class Shell extends Object {
if ($File = new File($path, true)) { if ($File = new File($path, true)) {
$data = $File->prepare($contents); $data = $File->prepare($contents);
$File->write($data); $File->write($data);
$this->out(sprintf(__('<success>Wrote</success> `%s`'), $path)); $this->out(__('<success>Wrote</success> `%s`', $path));
return true; return true;
} else { } else {
$this->err(sprintf(__('<error>Could not write to `%s`</error>.'), $path), 2); $this->err(__('<error>Could not write to `%s`</error>.', $path), 2);
return false; return false;
} }
} }

View file

@ -79,7 +79,7 @@ class ControllerTask extends BakeTask {
if (!empty($this->params['admin'])) { if (!empty($this->params['admin'])) {
$admin = $this->Project->getPrefix(); $admin = $this->Project->getPrefix();
if ($admin) { if ($admin) {
$this->out(sprintf(__('Adding %s methods'), $admin)); $this->out(__('Adding %s methods', $admin));
$actions .= "\n" . $this->bakeActions($controller, $admin); $actions .= "\n" . $this->bakeActions($controller, $admin);
} }
} }
@ -125,7 +125,7 @@ class ControllerTask extends BakeTask {
protected function _interactive() { protected function _interactive() {
$this->interactive = true; $this->interactive = true;
$this->hr(); $this->hr();
$this->out(sprintf(__("Bake Controller\nPath: %s"), $this->path)); $this->out(__("Bake Controller\nPath: %s", $this->path));
$this->hr(); $this->hr();
if (empty($this->connection)) { if (empty($this->connection)) {
@ -134,7 +134,7 @@ class ControllerTask extends BakeTask {
$controllerName = $this->getName(); $controllerName = $this->getName();
$this->hr(); $this->hr();
$this->out(sprintf(__('Baking %sController'), $controllerName)); $this->out(__('Baking %sController', $controllerName));
$this->hr(); $this->hr();
$helpers = $components = array(); $helpers = $components = array();
@ -148,7 +148,7 @@ class ControllerTask extends BakeTask {
$question[] = __("Would you like to build your controller interactively?"); $question[] = __("Would you like to build your controller interactively?");
if (file_exists($this->path . $controllerFile .'_controller.php')) { if (file_exists($this->path . $controllerFile .'_controller.php')) {
$question[] = sprintf(__("Warning: Choosing no will overwrite the %sController."), $controllerName); $question[] = __("Warning: Choosing no will overwrite the %sController.", $controllerName);
} }
$doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y'); $doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y');
@ -213,7 +213,7 @@ class ControllerTask extends BakeTask {
$this->hr(); $this->hr();
$this->out(__('The following controller will be created:')); $this->out(__('The following controller will be created:'));
$this->hr(); $this->hr();
$this->out(sprintf(__("Controller Name:\n\t%s"), $controllerName)); $this->out(__("Controller Name:\n\t%s", $controllerName));
if (strtolower($useDynamicScaffold) == 'y') { if (strtolower($useDynamicScaffold) == 'y') {
$this->out("var \$scaffold;"); $this->out("var \$scaffold;");

View file

@ -114,7 +114,7 @@ class ExtractTask extends Shell {
$this->__paths = explode(',', $this->params['paths']); $this->__paths = explode(',', $this->params['paths']);
} else { } else {
$defaultPath = APP_PATH; $defaultPath = APP_PATH;
$message = sprintf(__("What is the full path you would like to extract?\nExample: %s\n[Q]uit [D]one"), $this->Dispatch->params['root'] . DS . 'myapp'); $message = __("What is the full path you would like to extract?\nExample: %s\n[Q]uit [D]one", $this->Dispatch->params['root'] . DS . 'myapp');
while (true) { while (true) {
$response = $this->in($message, null, $defaultPath); $response = $this->in($message, null, $defaultPath);
if (strtoupper($response) === 'Q') { if (strtoupper($response) === 'Q') {
@ -136,7 +136,7 @@ class ExtractTask extends Shell {
if (isset($this->params['output'])) { if (isset($this->params['output'])) {
$this->__output = $this->params['output']; $this->__output = $this->params['output'];
} else { } else {
$message = sprintf(__("What is the full path you would like to output?\nExample: %s\n[Q]uit"), $this->__paths[0] . DS . 'locale'); $message = __("What is the full path you would like to output?\nExample: %s\n[Q]uit", $this->__paths[0] . DS . 'locale');
while (true) { while (true) {
$response = $this->in($message, null, $this->__paths[0] . DS . 'locale'); $response = $this->in($message, null, $this->__paths[0] . DS . 'locale');
if (strtoupper($response) === 'Q') { if (strtoupper($response) === 'Q') {
@ -156,7 +156,7 @@ class ExtractTask extends Shell {
$this->__merge = !(strtolower($this->params['merge']) === 'no'); $this->__merge = !(strtolower($this->params['merge']) === 'no');
} else { } else {
$this->out(); $this->out();
$response = $this->in(sprintf(__('Would you like to merge all domains strings into the default.pot file?')), array('y', 'n'), 'n'); $response = $this->in(__('Would you like to merge all domains strings into the default.pot file?'), array('y', 'n'), 'n');
$this->__merge = strtolower($response) === 'y'; $this->__merge = strtolower($response) === 'y';
} }
@ -250,7 +250,7 @@ class ExtractTask extends Shell {
function __extractTokens() { function __extractTokens() {
foreach ($this->__files as $file) { foreach ($this->__files as $file) {
$this->__file = $file; $this->__file = $file;
$this->out(sprintf(__('Processing %s...'), $file)); $this->out(__('Processing %s...', $file));
$code = file_get_contents($file); $code = file_get_contents($file);
$allTokens = token_get_all($code); $allTokens = token_get_all($code);
@ -413,11 +413,11 @@ class ExtractTask extends Shell {
$response = ''; $response = '';
while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') { while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') {
$this->out(); $this->out();
$response = $this->in(sprintf(__('Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll'), $filename), array('y', 'n', 'a'), 'y'); $response = $this->in(__('Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll', $filename), array('y', 'n', 'a'), 'y');
if (strtoupper($response) === 'N') { if (strtoupper($response) === 'N') {
$response = ''; $response = '';
while ($response == '') { while ($response == '') {
$response = $this->in(sprintf(__("What would you like to name this file?\nExample: %s"), 'new_' . $filename), null, 'new_' . $filename); $response = $this->in(__("What would you like to name this file?\nExample: %s", 'new_' . $filename), null, 'new_' . $filename);
$File = new File($this->__output . $response); $File = new File($this->__output . $response);
$filename = $response; $filename = $response;
} }
@ -485,7 +485,7 @@ class ExtractTask extends Shell {
* @access private * @access private
*/ */
function __markerError($file, $line, $marker, $count) { function __markerError($file, $line, $marker, $count) {
$this->out(sprintf(__("Invalid marker content in %s:%s\n* %s("), $file, $line, $marker), true); $this->out(__("Invalid marker content in %s:%s\n* %s(", $file, $line, $marker), true);
$count += 2; $count += 2;
$tokenCount = count($this->__tokens); $tokenCount = count($this->__tokens);
$parenthesis = 1; $parenthesis = 1;

View file

@ -166,7 +166,7 @@ class FixtureTask extends BakeTask {
$options['records'] = true; $options['records'] = true;
} }
if ($doRecords == 'n') { if ($doRecords == 'n') {
$prompt = sprintf(__("Would you like to build this fixture with data from %s's table?"), $modelName); $prompt = __("Would you like to build this fixture with data from %s's table?", $modelName);
$fromTable = $this->in($prompt, array('y', 'n'), 'n'); $fromTable = $this->in($prompt, array('y', 'n'), 'n');
if (strtolower($fromTable) == 'y') { if (strtolower($fromTable) == 'y') {
$options['fromTable'] = true; $options['fromTable'] = true;

View file

@ -112,7 +112,7 @@ class ModelTask extends BakeTask {
continue; continue;
} }
$modelClass = Inflector::classify($table); $modelClass = Inflector::classify($table);
$this->out(sprintf(__('Baking %s'), $modelClass)); $this->out(__('Baking %s', $modelClass));
$object = $this->_getModelObject($modelClass); $object = $this->_getModelObject($modelClass);
if ($this->bake($object, false) && $unitTestExists) { if ($this->bake($object, false) && $unitTestExists) {
$this->bakeFixture($modelClass); $this->bakeFixture($modelClass);
@ -190,7 +190,7 @@ class ModelTask extends BakeTask {
$primaryKey = $this->findPrimaryKey($fields); $primaryKey = $this->findPrimaryKey($fields);
} }
} else { } else {
$this->err(sprintf(__('Table %s does not exist, cannot bake a model without a table.'), $useTable)); $this->err(__('Table %s does not exist, cannot bake a model without a table.', $useTable));
$this->_stop(); $this->_stop();
return false; return false;
} }
@ -218,16 +218,16 @@ class ModelTask extends BakeTask {
$this->out("Name: " . $currentModelName); $this->out("Name: " . $currentModelName);
if ($this->connection !== 'default') { if ($this->connection !== 'default') {
$this->out(sprintf(__("DB Config: %s"), $this->connection)); $this->out(__("DB Config: %s", $this->connection));
} }
if ($fullTableName !== Inflector::tableize($currentModelName)) { if ($fullTableName !== Inflector::tableize($currentModelName)) {
$this->out(sprintf(__('DB Table: %s'), $fullTableName)); $this->out(__('DB Table: %s', $fullTableName));
} }
if ($primaryKey != 'id') { if ($primaryKey != 'id') {
$this->out(sprintf(__('Primary Key: %s'), $primaryKey)); $this->out(__('Primary Key: %s', $primaryKey));
} }
if (!empty($validate)) { if (!empty($validate)) {
$this->out(sprintf(__('Validation: %s'), print_r($validate, true))); $this->out(__('Validation: %s', print_r($validate, true)));
} }
if (!empty($associations)) { if (!empty($associations)) {
$this->out(__('Associations:')); $this->out(__('Associations:'));
@ -367,8 +367,8 @@ class ModelTask extends BakeTask {
while ($anotherValidator == 'y') { while ($anotherValidator == 'y') {
if ($this->interactive) { if ($this->interactive) {
$this->out(); $this->out();
$this->out(sprintf(__('Field: %s'), $fieldName)); $this->out(__('Field: %s', $fieldName));
$this->out(sprintf(__('Type: %s'), $metaData['type'])); $this->out(__('Type: %s', $metaData['type']));
$this->hr(); $this->hr();
$this->out(__('Please select one of the following validation options:')); $this->out(__('Please select one of the following validation options:'));
$this->hr(); $this->hr();
@ -378,7 +378,7 @@ class ModelTask extends BakeTask {
for ($i = 1; $i < $defaultChoice; $i++) { for ($i = 1; $i < $defaultChoice; $i++) {
$prompt .= $i . ' - ' . $this->_validations[$i] . "\n"; $prompt .= $i . ' - ' . $this->_validations[$i] . "\n";
} }
$prompt .= sprintf(__("%s - Do not do any validation on this field.\n"), $defaultChoice); $prompt .= __("%s - Do not do any validation on this field.\n", $defaultChoice);
$prompt .= __("... or enter in a valid regex validation string.\n"); $prompt .= __("... or enter in a valid regex validation string.\n");
$methods = array_flip($this->_validations); $methods = array_flip($this->_validations);
@ -646,7 +646,7 @@ class ModelTask extends BakeTask {
$this->hr(); $this->hr();
$alias = $this->in(__('What is the alias for this association?')); $alias = $this->in(__('What is the alias for this association?'));
$className = $this->in(sprintf(__('What className will %s use?'), $alias), null, $alias ); $className = $this->in(__('What className will %s use?', $alias), null, $alias );
$suggestedForeignKey = null; $suggestedForeignKey = null;
if ($assocType == 0) { if ($assocType == 0) {
@ -800,7 +800,7 @@ class ModelTask extends BakeTask {
if (array_search($useTable, $this->_tables) === false) { if (array_search($useTable, $this->_tables) === false) {
$this->out(); $this->out();
$this->out(sprintf(__("Given your model named '%s',\nCake would expect a database table named '%s'"), $modelName, $fullTableName)); $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'); $tableIsGood = $this->in(__('Do you want to use this table?'), array('y','n'), 'y');
} }
if (strtolower($tableIsGood) == 'n') { if (strtolower($tableIsGood) == 'n') {

View file

@ -56,8 +56,8 @@ class PluginTask extends Shell {
$plugin = Inflector::camelize($this->args[0]); $plugin = Inflector::camelize($this->args[0]);
$pluginPath = $this->_pluginPath($plugin); $pluginPath = $this->_pluginPath($plugin);
if (is_dir($pluginPath)) { if (is_dir($pluginPath)) {
$this->out(sprintf(__('Plugin: %s'), $plugin)); $this->out(__('Plugin: %s', $plugin));
$this->out(sprintf(__('Path: %s'), $pluginPath)); $this->out(__('Path: %s', $pluginPath));
} else { } else {
$this->_interactive($plugin); $this->_interactive($plugin);
} }
@ -78,7 +78,7 @@ class PluginTask extends Shell {
} }
if (!$this->bake($plugin)) { if (!$this->bake($plugin)) {
$this->error(sprintf(__("An error occured trying to bake: %s in %s"), $plugin, $this->path . Inflector::underscore($pluginPath))); $this->error(__("An error occured trying to bake: %s in %s", $plugin, $this->path . Inflector::underscore($pluginPath)));
} }
} }
@ -97,8 +97,8 @@ class PluginTask extends Shell {
$this->findPath($pathOptions); $this->findPath($pathOptions);
} }
$this->hr(); $this->hr();
$this->out(sprintf(__("<info>Plugin Name:</info> %s"), $plugin)); $this->out(__("<info>Plugin Name:</info> %s", $plugin));
$this->out(sprintf(__("<info>Plugin Directory:</info> %s"), $this->path . $pluginPath)); $this->out(__("<info>Plugin Directory:</info> %s", $this->path . $pluginPath));
$this->hr(); $this->hr();
$looksGood = $this->in(__('Look okay?'), array('y', 'n', 'q'), 'y'); $looksGood = $this->in(__('Look okay?'), array('y', 'n', 'q'), 'y');
@ -156,7 +156,7 @@ class PluginTask extends Shell {
$this->createFile($this->path . $pluginPath . DS . $modelFileName, $out); $this->createFile($this->path . $pluginPath . DS . $modelFileName, $out);
$this->hr(); $this->hr();
$this->out(sprintf(__('<success>Created:</success> %s in %s'), $plugin, $this->path . $pluginPath), 2); $this->out(__('<success>Created:</success> %s in %s', $plugin, $this->path . $pluginPath), 2);
} }
return true; return true;

View file

@ -68,7 +68,7 @@ class ProjectTask extends Shell {
if ($project) { if ($project) {
$response = false; $response = false;
while ($response == false && is_dir($project) === true && file_exists($project . 'config' . 'core.php')) { while ($response == false && is_dir($project) === true && file_exists($project . 'config' . 'core.php')) {
$prompt = sprintf(__('<warning>A project already exists in this location:</warning> %s Overwrite?'), $project); $prompt = __('<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
$response = $this->in($prompt, array('y','n'), 'n'); $response = $this->in($prompt, array('y','n'), 'n');
if (strtolower($response) === 'n') { if (strtolower($response) === 'n') {
$response = $project = false; $response = $project = false;
@ -89,23 +89,23 @@ class ProjectTask extends Shell {
if ($this->securitySalt($path) === true) { if ($this->securitySalt($path) === true) {
$this->out(__(' * Random hash key created for \'Security.salt\'')); $this->out(__(' * Random hash key created for \'Security.salt\''));
} else { } else {
$this->err(sprintf(__('Unable to generate random hash for \'Security.salt\', you should change it in %s'), CONFIGS . 'core.php')); $this->err(__('Unable to generate random hash for \'Security.salt\', you should change it in %s', CONFIGS . 'core.php'));
$success = false; $success = false;
} }
if ($this->securityCipherSeed($path) === true) { if ($this->securityCipherSeed($path) === true) {
$this->out(__(' * Random seed created for \'Security.cipherSeed\'')); $this->out(__(' * Random seed created for \'Security.cipherSeed\''));
} else { } else {
$this->err(sprintf(__('Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s'), CONFIGS . 'core.php')); $this->err(__('Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', CONFIGS . 'core.php'));
$success = false; $success = false;
} }
if ($this->corePath($path) === true) { if ($this->corePath($path) === true) {
$this->out(sprintf(__(' * 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/index.php', CAKE_CORE_INCLUDE_PATH));
$this->out(sprintf(__(' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php'), CAKE_CORE_INCLUDE_PATH)); $this->out(__(' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH));
$this->out(__(' * <warning>Remember to check these value after moving to production server</warning>')); $this->out(__(' * <warning>Remember to check these value after moving to production server</warning>'));
} else { } else {
$this->err(sprintf(__('Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s'), $path . 'webroot' .DS .'index.php')); $this->err(__('Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' .DS .'index.php'));
$success = false; $success = false;
} }
if ($this->consolePath($path) === true) { if ($this->consolePath($path) === true) {
@ -117,8 +117,8 @@ class ProjectTask extends Shell {
$Folder = new Folder($path); $Folder = new Folder($path);
if (!$Folder->chmod($path . 'tmp', 0777)) { if (!$Folder->chmod($path . 'tmp', 0777)) {
$this->err(sprintf(__('Could not set permissions on %s'), $path . DS .'tmp')); $this->err(__('Could not set permissions on %s', $path . DS .'tmp'));
$this->out(sprintf(__('chmod -R 0777 %s'), $path . DS .'tmp')); $this->out(__('chmod -R 0777 %s', $path . DS .'tmp'));
$success = false; $success = false;
} }
if ($success) { if ($success) {
@ -146,7 +146,7 @@ class ProjectTask extends Shell {
$skel = $this->params['skel']; $skel = $this->params['skel'];
} }
while (!$skel) { while (!$skel) {
$skel = $this->in(sprintf(__("What is the path to the directory layout you wish to copy?\nExample: %s"), APP, null, ROOT . DS . 'myapp' . DS)); $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 == '') { if ($skel == '') {
$this->err(__('The directory path you supplied was empty. Please try again.')); $this->err(__('The directory path you supplied was empty. Please try again.'));
} else { } else {
@ -172,10 +172,10 @@ class ProjectTask extends Shell {
if ($Folder->copy(array('to' => $path, 'skip' => $skip))) { if ($Folder->copy(array('to' => $path, 'skip' => $skip))) {
$this->hr(); $this->hr();
$this->out(sprintf(__('<success>Created:</success> %s in %s'), $app, $path)); $this->out(__('<success>Created:</success> %s in %s', $app, $path));
$this->hr(); $this->hr();
} else { } else {
$this->err(sprintf(__("<error>Could not create</error> '%s' properly."), $app)); $this->err(__("<error>Could not create</error> '%s' properly.", $app));
return false; return false;
} }

View file

@ -206,7 +206,7 @@ class TemplateTask extends Shell {
return $templatePath; return $templatePath;
} }
} }
$this->err(sprintf(__('Could not find template for %s'), $filename)); $this->err(__('Could not find template for %s', $filename));
return false; return false;
} }
} }

View file

@ -92,13 +92,13 @@ class TestTask extends BakeTask {
$this->interactive = true; $this->interactive = true;
$this->hr(); $this->hr();
$this->out(__('Bake Tests')); $this->out(__('Bake Tests'));
$this->out(sprintf(__('Path: %s'), $this->path)); $this->out(__('Path: %s', $this->path));
$this->hr(); $this->hr();
if ($type) { if ($type) {
$type = Inflector::camelize($type); $type = Inflector::camelize($type);
if (!in_array($type, $this->classTypes)) { if (!in_array($type, $this->classTypes)) {
$this->error(sprintf('Incorrect type provided. Please choose one of %s', implode(', ', $this->classTypes))); $this->error(__('Incorrect type provided. Please choose one of %s', implode(', ', $this->classTypes)));
} }
} else { } else {
$type = $this->getObjectType(); $type = $this->getObjectType();
@ -180,7 +180,7 @@ class TestTask extends BakeTask {
*/ */
public function getClassName($objectType) { public function getClassName($objectType) {
$options = App::objects(strtolower($objectType)); $options = App::objects(strtolower($objectType));
$this->out(sprintf(__('Choose a %s class'), $objectType)); $this->out(__('Choose a %s class', $objectType));
$keys = array(); $keys = array();
foreach ($options as $key => $option) { foreach ($options as $key => $option) {
$this->out(++$key . '. ' . $option); $this->out(++$key . '. ' . $option);

View file

@ -221,7 +221,7 @@ class ViewTask extends BakeTask {
$this->controllerPath = strtolower(Inflector::underscore($this->controllerName)); $this->controllerPath = strtolower(Inflector::underscore($this->controllerName));
$prompt = sprintf(__("Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite %s views if it exist."), $this->controllerName); $prompt = __("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'); $interactive = $this->in($prompt, array('y', 'n'), 'n');
if (strtolower($interactive) == 'n') { if (strtolower($interactive) == 'n') {
@ -278,7 +278,7 @@ class ViewTask extends BakeTask {
if (!App::import('Controller', $import)) { if (!App::import('Controller', $import)) {
$file = $this->controllerPath . '_controller.php'; $file = $this->controllerPath . '_controller.php';
$this->err(sprintf(__("The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller."), $file)); $this->err(__("The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file));
$this->_stop(); $this->_stop();
} }
$controllerClassName = $this->controllerName . 'Controller'; $controllerClassName = $this->controllerName . 'Controller';
@ -339,9 +339,9 @@ class ViewTask extends BakeTask {
$this->hr(); $this->hr();
$this->out(__('The following view will be created:')); $this->out(__('The following view will be created:'));
$this->hr(); $this->hr();
$this->out(sprintf(__('Controller Name: %s'), $this->controllerName)); $this->out(__('Controller Name: %s', $this->controllerName));
$this->out(sprintf(__('Action Name: %s'), $action)); $this->out(__('Action Name: %s', $action));
$this->out(sprintf(__('Path: %s'), $this->params['app'] . DS . $this->controllerPath . DS . Inflector::underscore($action) . ".ctp")); $this->out(__('Path: %s', $this->params['app'] . DS . $this->controllerPath . DS . Inflector::underscore($action) . ".ctp"));
$this->hr(); $this->hr();
$looksGood = $this->in(__('Look okay?'), array('y','n'), 'y'); $looksGood = $this->in(__('Look okay?'), array('y','n'), 'y');
if (strtolower($looksGood) == 'y') { if (strtolower($looksGood) == 'y') {

View file

@ -77,7 +77,7 @@
$this->Session->setFlash(__('Invalid <?php echo strtolower($singularHumanName); ?>')); $this->Session->setFlash(__('Invalid <?php echo strtolower($singularHumanName); ?>'));
$this->redirect(array('action' => 'index')); $this->redirect(array('action' => 'index'));
<?php else: ?> <?php else: ?>
$this->flash(sprintf(__('Invalid <?php echo strtolower($singularHumanName); ?>')), array('action' => 'index')); $this->flash(__('Invalid <?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} }
if ($this->request->is('post')) { if ($this->request->is('post')) {
@ -123,7 +123,7 @@
$this->Session->setFlash(__('Invalid id for <?php echo strtolower($singularHumanName); ?>')); $this->Session->setFlash(__('Invalid id for <?php echo strtolower($singularHumanName); ?>'));
$this->redirect(array('action'=>'index')); $this->redirect(array('action'=>'index'));
<?php else: ?> <?php else: ?>
$this->flash(sprintf(__('Invalid <?php echo strtolower($singularHumanName); ?>')), array('action' => 'index')); $this->flash(__('Invalid <?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} }
if ($this-><?php echo $currentModelName; ?>->delete($id)) { if ($this-><?php echo $currentModelName; ?>->delete($id)) {

View file

@ -47,7 +47,7 @@
<ul> <ul>
<?php if (strpos($action, 'add') === false): ?> <?php if (strpos($action, 'add') === false): ?>
<li><?php echo "<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?'), \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>";?></li> <li><?php echo "<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>";?></li>
<?php endif;?> <?php endif;?>
<li><?php echo "<?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index'));?>";?></li> <li><?php echo "<?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index'));?>";?></li>
<?php <?php

View file

@ -24,7 +24,7 @@ endif;
\$settings = Cache::settings(); \$settings = Cache::settings();
if (!empty(\$settings)): if (!empty(\$settings)):
echo '<span class=\"notice success\">'; echo '<span class=\"notice success\">';
printf(__('The %s is being used for caching. To change the config edit APP/config/core.php '), '<em>'. \$settings['engine'] . 'Engine</em>'); echo __('The %s is being used for caching. To change the config edit APP/config/core.php ', '<em>'. \$settings['engine'] . 'Engine</em>');
echo '</span>'; echo '</span>';
else: else:
echo '<span class=\"notice\">'; echo '<span class=\"notice\">';
@ -75,9 +75,9 @@ $output .= "<?php endif;?>\n";
$output .= "<h3><?php echo __('Editing this Page') ?></h3>\n"; $output .= "<h3><?php echo __('Editing this Page') ?></h3>\n";
$output .= "<p>\n"; $output .= "<p>\n";
$output .= "<?php\n"; $output .= "<?php\n";
$output .= "\tprintf(__('To change the content of this page, edit: %s\n"; $output .= "\techo __('To change the content of this page, edit: %s\n";
$output .= "\t\tTo change its layout, edit: %s\n"; $output .= "\t\tTo change its layout, edit: %s\n";
$output .= "\t\tYou can also add some CSS styles for your pages at: %s'),\n"; $output .= "\t\tYou can also add some CSS styles for your pages at: %s',\n";
$output .= "\t\tAPP . 'views' . DS . 'pages' . DS . 'home.ctp.<br />', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.<br />', APP . 'webroot' . DS . 'css');\n"; $output .= "\t\tAPP . 'views' . DS . 'pages' . DS . 'home.ctp.<br />', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.<br />', APP . 'webroot' . DS . 'css');\n";
$output .= "?>\n"; $output .= "?>\n";
$output .= "</p>\n"; $output .= "</p>\n";

View file

@ -55,7 +55,7 @@
echo "\t\t<td class=\"actions\">\n"; echo "\t\t<td class=\"actions\">\n";
echo "\t\t\t<?php echo \$this->Html->link(__('View'), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; echo "\t\t\t<?php echo \$this->Html->link(__('View'), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t\t<?php echo \$this->Html->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; echo "\t\t\t<?php echo \$this->Html->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; echo "\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
echo "\t\t</td>\n"; echo "\t\t</td>\n";
echo "\t</tr>\n"; echo "\t</tr>\n";

View file

@ -46,7 +46,7 @@ foreach ($fields as $field) {
<ul> <ul>
<?php <?php
echo "\t\t<li><?php echo \$this->Html->link(__('Edit " . $singularHumanName ."'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n"; echo "\t\t<li><?php echo \$this->Html->link(__('Edit " . $singularHumanName ."'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n"; echo "\t\t<li><?php echo \$this->Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?> </li>\n"; echo "\t\t<li><?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$this->Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?> </li>\n"; echo "\t\t<li><?php echo \$this->Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?> </li>\n";
@ -129,7 +129,7 @@ echo "\t<?php
echo "\t\t\t<td class=\"actions\">\n"; echo "\t\t\t<td class=\"actions\">\n";
echo "\t\t\t\t<?php echo \$this->Html->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; echo "\t\t\t\t<?php echo \$this->Html->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Html->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; echo "\t\t\t\t<?php echo \$this->Html->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; echo "\t\t\t\t<?php echo \$this->Form->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
echo "\t\t\t</td>\n"; echo "\t\t\t</td>\n";
echo "\t\t</tr>\n"; echo "\t\t</tr>\n";

View file

@ -34,12 +34,7 @@
* sqlite - SQLite (PHP5 only), * sqlite - SQLite (PHP5 only),
* postgres - PostgreSQL 7 and higher, * postgres - PostgreSQL 7 and higher,
* mssql - Microsoft SQL Server 2000 and higher, * mssql - Microsoft SQL Server 2000 and higher,
* db2 - IBM DB2, Cloudscape, and Apache Derby (http://php.net/ibm-db2)
* oracle - Oracle 8 and higher * oracle - Oracle 8 and higher
* firebird - Firebird/Interbase
* sybase - Sybase ASE
* adodb-[drivername] - ADOdb interface wrapper (see below),
* odbc - ODBC DBO driver
* *
* You can add custom database drivers (or override existing drivers) by adding the * You can add custom database drivers (or override existing drivers) by adding the
* appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php', * appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php',
@ -48,12 +43,6 @@
* persistent => true / false * persistent => true / false
* Determines whether or not the database should use a persistent connection * Determines whether or not the database should use a persistent connection
* *
* connect =>
* ADOdb set the connect to one of these
* (http://phplens.com/adodb/supported.databases.html) and
* append it '|p' for persistent connection. (mssql|p for example, or just mssql for not persistent)
* For all other databases, this setting is deprecated.
*
* host => * host =>
* the host you connect to the database. To add a socket or port number, use 'port' => # * the host you connect to the database. To add a socket or port number, use 'port' => #
* *
@ -62,11 +51,11 @@
* on a per-table basis with the Model::$tablePrefix property. * on a per-table basis with the Model::$tablePrefix property.
* *
* schema => * schema =>
* For Postgres and DB2, specifies which schema you would like to use the tables in. Postgres defaults to * For Postgresspecifies which schema you would like to use the tables in. Postgres defaults to
* 'public', DB2 defaults to empty. * 'public', DB2 defaults to empty.
* *
* encoding => * encoding =>
* For MySQL, Postgres and DB2, specifies the character encoding to use when connecting to the * For MySQL, Postgres and Sqlite, specifies the character encoding to use when connecting to the
* database. Uses database default. * database. Uses database default.
* *
*/ */

View file

@ -56,7 +56,7 @@ class AclBehavior extends ModelBehavior {
} }
$model->{$type} = ClassRegistry::init($type); $model->{$type} = ClassRegistry::init($type);
if (!method_exists($model, 'parentNode')) { if (!method_exists($model, 'parentNode')) {
trigger_error(sprintf(__('Callback parentNode() not defined in %s'), $model->alias), E_USER_WARNING); trigger_error(__('Callback parentNode() not defined in %s', $model->alias), E_USER_WARNING);
} }
} }

View file

@ -354,7 +354,7 @@ class ContainableBehavior extends ModelBehavior {
if (!isset($Model->{$name}) || !is_object($Model->{$name})) { if (!isset($Model->{$name}) || !is_object($Model->{$name})) {
if ($throwErrors) { if ($throwErrors) {
trigger_error(sprintf(__('Model "%s" is not associated with model "%s"'), $Model->alias, $name), E_USER_WARNING); trigger_error(__('Model "%s" is not associated with model "%s"', $Model->alias, $name), E_USER_WARNING);
} }
continue; continue;
} }

View file

@ -57,7 +57,7 @@ class TranslateBehavior extends ModelBehavior {
$db = ConnectionManager::getDataSource($model->useDbConfig); $db = ConnectionManager::getDataSource($model->useDbConfig);
if (!$db->connected) { if (!$db->connected) {
trigger_error( trigger_error(
sprintf(__('Datasource %s for TranslateBehavior of model %s is not connected'), $model->useDbConfig, $model->alias), __('Datasource %s for TranslateBehavior of model %s is not connected', $model->useDbConfig, $model->alias),
E_USER_ERROR E_USER_ERROR
); );
return false; return false;
@ -424,7 +424,7 @@ class TranslateBehavior extends ModelBehavior {
foreach (array('hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany') as $type) { foreach (array('hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany') as $type) {
if (isset($model->{$type}[$association]) || isset($model->__backAssociation[$type][$association])) { if (isset($model->{$type}[$association]) || isset($model->__backAssociation[$type][$association])) {
trigger_error( trigger_error(
sprintf(__('Association %s is already binded to model %s'), $association, $model->alias), __('Association %s is already binded to model %s', $association, $model->alias),
E_USER_ERROR E_USER_ERROR
); );
return false; return false;

View file

@ -367,6 +367,30 @@ class BasicsTest extends CakeTestCase {
$result = __('Plural Rule 1 (from core)'); $result = __('Plural Rule 1 (from core)');
$expected = 'Plural Rule 1 (from core translated)'; $expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = __('Some string with %s', 'arguments');
$expected = 'Some string with arguments';
$this->assertEqual($result, $expected);
$result = __('Some string with %s %s', 'multiple', 'arguments');
$expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected);
$result = __('Some string with %s %s', array('multiple', 'arguments'));
$expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected);
$result = __('Testing %2$s %1$s', 'order', 'different');
$expected = 'Testing different order';
$this->assertEqual($result, $expected);
$result = __('Testing %2$s %1$s', array('order', 'different'));
$expected = 'Testing different order';
$this->assertEqual($result, $expected);
$result = __('Testing %.2f number', 1.2345);
$expected = 'Testing 1.23 number';
$this->assertEqual($result, $expected);
} }
/** /**
@ -388,6 +412,18 @@ class BasicsTest extends CakeTestCase {
$result = __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2); $result = __n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', 2);
$expected = '%d = 0 or > 1 (from core translated)'; $expected = '%d = 0 or > 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = __n('%d item.', '%d items.', 1, 1);
$expected = '1 item.';
$this->assertEqual($result, $expected);
$result = __n('%d item for id %s', '%d items for id %s', 2, 2, '1234');
$expected = '2 items for id 1234';
$this->assertEqual($result, $expected);
$result = __n('%d item for id %s', '%d items for id %s', 2, array(2, '1234'));
$expected = '2 items for id 1234';
$this->assertEqual($result, $expected);
} }
/** /**
@ -409,6 +445,18 @@ class BasicsTest extends CakeTestCase {
$result = __d('core', 'Plural Rule 1 (from core)'); $result = __d('core', 'Plural Rule 1 (from core)');
$expected = 'Plural Rule 1 (from core translated)'; $expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = __d('core', 'Some string with %s', 'arguments');
$expected = 'Some string with arguments';
$this->assertEqual($result, $expected);
$result = __d('core', 'Some string with %s %s', 'multiple', 'arguments');
$expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected);
$result = __d('core', 'Some string with %s %s', array('multiple', 'arguments'));
$expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected);
} }
/** /**
@ -435,6 +483,17 @@ class BasicsTest extends CakeTestCase {
$expected = '%d = 1 (translated)'; $expected = '%d = 1 (translated)';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = __dn('core', '%d item.', '%d items.', 1, 1);
$expected = '1 item.';
$this->assertEqual($result, $expected);
$result = __dn('core', '%d item for id %s', '%d items for id %s', 2, 2, '1234');
$expected = '2 items for id 1234';
$this->assertEqual($result, $expected);
$result = __dn('core', '%d item for id %s', '%d items for id %s', 2, array(2, '1234'));
$expected = '2 items for id 1234';
$this->assertEqual($result, $expected);
} }
/** /**
@ -452,6 +511,18 @@ class BasicsTest extends CakeTestCase {
$result = __c('Plural Rule 1 (from core)', 6); $result = __c('Plural Rule 1 (from core)', 6);
$expected = 'Plural Rule 1 (from core translated)'; $expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = __c('Some string with %s', 6, 'arguments');
$expected = 'Some string with arguments';
$this->assertEqual($result, $expected);
$result = __c('Some string with %s %s', 6, 'multiple', 'arguments');
$expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected);
$result = __c('Some string with %s %s', 6, array('multiple', 'arguments'));
$expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected);
} }
/** /**
@ -477,6 +548,18 @@ class BasicsTest extends CakeTestCase {
$result = __dc('core', 'Plural Rule 1 (from core)', 6); $result = __dc('core', 'Plural Rule 1 (from core)', 6);
$expected = 'Plural Rule 1 (from core translated)'; $expected = 'Plural Rule 1 (from core translated)';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = __dc('core', 'Some string with %s', 6, 'arguments');
$expected = 'Some string with arguments';
$this->assertEqual($result, $expected);
$result = __dc('core', 'Some string with %s %s', 6, 'multiple', 'arguments');
$expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected);
$result = __dc('core', 'Some string with %s %s', 6, array('multiple', 'arguments'));
$expected = 'Some string with multiple arguments';
$this->assertEqual($result, $expected);
} }
/** /**
@ -498,6 +581,18 @@ class BasicsTest extends CakeTestCase {
$result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 6); $result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 6);
$expected = '%d = 0 or > 1'; $expected = '%d = 0 or > 1';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = __dcn('core', '%d item.', '%d items.', 1, 6, 1);
$expected = '1 item.';
$this->assertEqual($result, $expected);
$result = __dcn('core', '%d item for id %s', '%d items for id %s', 2, 6, 2, '1234');
$expected = '2 items for id 1234';
$this->assertEqual($result, $expected);
$result = __dcn('core', '%d item for id %s', '%d items for id %s', 2, 6, array(2, '1234'));
$expected = '2 items for id 1234';
$this->assertEqual($result, $expected);
} }
/** /**

View file

@ -19,7 +19,7 @@ class AppImportTest extends CakeTestCase {
$expected = array( $expected = array(
APP . 'models' . DS, APP . 'models' . DS,
APP, APP,
ROOT . DS . LIBS . 'model' . DS LIBS . 'model' . DS
); );
$this->assertEqual($expected, $old); $this->assertEqual($expected, $old);
@ -31,7 +31,7 @@ class AppImportTest extends CakeTestCase {
'/path/to/models/', '/path/to/models/',
APP . 'models' . DS, APP . 'models' . DS,
APP, APP,
ROOT . DS . LIBS . 'model' . DS LIBS . 'model' . DS
); );
$this->assertEqual($expected, $new); $this->assertEqual($expected, $new);
@ -51,7 +51,7 @@ class AppImportTest extends CakeTestCase {
$expected = array( $expected = array(
APP . 'models' . DS, APP . 'models' . DS,
APP, APP,
ROOT . DS . LIBS . 'model' . DS LIBS . 'model' . DS
); );
$this->assertEqual($expected, $old); $this->assertEqual($expected, $old);
@ -77,13 +77,13 @@ class AppImportTest extends CakeTestCase {
*/ */
function testCore() { function testCore() {
$model = App::core('models'); $model = App::core('models');
$this->assertEqual(array(ROOT . DS . LIBS . 'model' . DS), $model); $this->assertEqual(array(LIBS . 'model' . DS), $model);
$view = App::core('views'); $view = App::core('views');
$this->assertEqual(array(ROOT . DS . LIBS . 'view' . DS), $view); $this->assertEqual(array(LIBS . 'view' . DS), $view);
$controller = App::core('controllers'); $controller = App::core('controllers');
$this->assertEqual(array(ROOT . DS . LIBS . 'controller' . DS), $controller); $this->assertEqual(array(LIBS . 'controller' . DS), $controller);
} }
@ -329,7 +329,9 @@ class AppImportTest extends CakeTestCase {
$this->assertFalse(class_exists('BananaHelper'), 'BananaHelper was not found because the path does not exist.'); $this->assertFalse(class_exists('BananaHelper'), 'BananaHelper was not found because the path does not exist.');
App::build(array( App::build(array(
'helpers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS) 'helpers' => array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS
)
)); ));
App::build(array('vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH))); App::build(array('vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH)));
$this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.'); $this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.');

View file

@ -610,7 +610,7 @@ class ControllerTest extends CakeTestCase {
$Controller = new Controller($request); $Controller = new Controller($request);
$Controller->uses = array('ControllerPost', 'ControllerComment'); $Controller->uses = array('ControllerPost', 'ControllerComment');
$Controller->passedArgs[] = '1'; $Controller->passedArgs[] = '1';
$Controller->query = array(); $Controller->params['url'] = array();
$Controller->constructClasses(); $Controller->constructClasses();
$results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id');
@ -700,7 +700,7 @@ class ControllerTest extends CakeTestCase {
$Controller->uses = array('ControllerPost', 'ControllerComment'); $Controller->uses = array('ControllerPost', 'ControllerComment');
$Controller->passedArgs[] = '1'; $Controller->passedArgs[] = '1';
$Controller->query = array(); $Controller->params['url'] = array();
$Controller->constructClasses(); $Controller->constructClasses();
$Controller->passedArgs = array('page' => '-1', 'contain' => array('ControllerComment')); $Controller->passedArgs = array('page' => '-1', 'contain' => array('ControllerComment'));
@ -731,7 +731,7 @@ class ControllerTest extends CakeTestCase {
$Controller = new Controller($request); $Controller = new Controller($request);
$Controller->uses = array('ControllerPaginateModel'); $Controller->uses = array('ControllerPaginateModel');
$Controller->query = array(); $Controller->params['url'] = array();
$Controller->constructClasses(); $Controller->constructClasses();
$Controller->paginate = array( $Controller->paginate = array(
'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id') 'ControllerPaginateModel' => array('contain' => array('ControllerPaginateModel'), 'group' => 'Comment.author_id')
@ -757,10 +757,12 @@ class ControllerTest extends CakeTestCase {
* @access public * @access public
*/ */
function testPaginateFieldsDouble(){ function testPaginateFieldsDouble(){
$Controller = new Controller($this->getMock('CakeRequest')); $request = new CakeRequest('controller_posts/index');
$Controller = new Controller($request);
$Controller->uses = array('ControllerPost'); $Controller->uses = array('ControllerPost');
$Controller->request = $this->getMock('CakeRequest'); $Controller->request = $this->getMock('CakeRequest');
$Controller->request->query = array(); $Controller->request->params['url'] = array();
$Controller->constructClasses(); $Controller->constructClasses();
$Controller->paginate = array( $Controller->paginate = array(
@ -801,7 +803,7 @@ class ControllerTest extends CakeTestCase {
$Controller = new Controller($request); $Controller = new Controller($request);
$Controller->uses = array('ControllerPost'); $Controller->uses = array('ControllerPost');
$Controller->passedArgs[] = array('1', '2', '3'); $Controller->passedArgs[] = array('1', '2', '3');
$Controller->query = array(); $Controller->params['url'] = array();
$Controller->constructClasses(); $Controller->constructClasses();
$Controller->paginate = array( $Controller->paginate = array(
@ -837,7 +839,7 @@ class ControllerTest extends CakeTestCase {
$Controller = new Controller($request); $Controller = new Controller($request);
$Controller->uses = array('ControllerPost', 'ControllerComment'); $Controller->uses = array('ControllerPost', 'ControllerComment');
$Controller->passedArgs[] = '1'; $Controller->passedArgs[] = '1';
$Controller->query = array(); $Controller->params['url'] = array();
$Controller->constructClasses(); $Controller->constructClasses();
$Controller->paginate = array('ControllerPost' => array('popular', 'fields' => array('id', 'title'))); $Controller->paginate = array('ControllerPost' => array('popular', 'fields' => array('id', 'title')));
@ -861,7 +863,7 @@ class ControllerTest extends CakeTestCase {
$Controller = new Controller($request); $Controller = new Controller($request);
$Controller->modelClass = 'ControllerPost'; $Controller->modelClass = 'ControllerPost';
$Controller->query = array(); $Controller->params['url'] = array();
$Controller->paginate = array('order' => 'ControllerPost.id DESC'); $Controller->paginate = array('order' => 'ControllerPost.id DESC');
$Controller->constructClasses(); $Controller->constructClasses();
$results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); $results = Set::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id');
@ -881,7 +883,7 @@ class ControllerTest extends CakeTestCase {
$Controller = new Controller($request); $Controller = new Controller($request);
$Controller->uses = array('ControllerPost', 'ControllerComment'); $Controller->uses = array('ControllerPost', 'ControllerComment');
$Controller->query = array(); $Controller->params['url'] = array();
$Controller->constructClasses(); $Controller->constructClasses();
$Controller->ControllerPost->virtualFields = array( $Controller->ControllerPost->virtualFields = array(
'offset_test' => 'ControllerPost.id + 1' 'offset_test' => 'ControllerPost.id + 1'
@ -1241,7 +1243,7 @@ class ControllerTest extends CakeTestCase {
? array_merge($appVars['uses'], $testVars['uses']) ? array_merge($appVars['uses'], $testVars['uses'])
: $testVars['uses']; : $testVars['uses'];
$this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->helpers), Set::normalize($helpers))), 0); $this->assertEqual(count(array_diff($TestController->helpers, $helpers)), 0);
$this->assertEqual(count(array_diff($TestController->uses, $uses)), 0); $this->assertEqual(count(array_diff($TestController->uses, $uses)), 0);
$this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0); $this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0);
@ -1499,7 +1501,7 @@ class ControllerTest extends CakeTestCase {
$Controller->components = array("RequestHandler"); $Controller->components = array("RequestHandler");
$Controller->modelClass='ControllerPost'; $Controller->modelClass='ControllerPost';
$Controller->request->params['url'] = array('ext' => 'rss'); $Controller->params['url'] = array('ext' => 'rss');
$Controller->constructClasses(); $Controller->constructClasses();
$Controller->Components->trigger('initialize', array(&$Controller)); $Controller->Components->trigger('initialize', array(&$Controller));
$Controller->beforeFilter(); $Controller->beforeFilter();

View file

@ -484,8 +484,7 @@ class FileTest extends CakeTestCase {
$assertLine = $assertLine->traceMethod(); $assertLine = $assertLine->traceMethod();
$shortPath = substr($tmpFile, strlen(ROOT)); $shortPath = substr($tmpFile, strlen(ROOT));
$message = '[FileTest] Skipping %s because "%s" not writeable!'; $message = __('[FileTest] Skipping %s because "%s" not writeable!', $caller, $shortPath).$assertLine;
$message = sprintf(__($message), $caller, $shortPath).$assertLine;
$this->_reporter->paintSkip($message); $this->_reporter->paintSkip($message);
} }
return false; return false;

View file

@ -2601,6 +2601,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void * @return void
*/ */
function testCalculations() { function testCalculations() {
$this->Model = new TestModel();
$result = $this->Dbo->calculate($this->Model, 'count'); $result = $this->Dbo->calculate($this->Model, 'count');
$this->assertEqual($result, 'COUNT(*) AS `count`'); $this->assertEqual($result, 'COUNT(*) AS `count`');
@ -3111,7 +3112,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void * @return void
*/ */
function testVirtualFieldsComplexRead() { function testVirtualFieldsComplexRead() {
$this->loadFixtures('DataTest', 'Article', 'Comment', 'User', 'Tag'); $this->loadFixtures('DataTest', 'Article', 'Comment', 'User', 'Tag', 'ArticlesTag');
$Article = ClassRegistry::init('Article'); $Article = ClassRegistry::init('Article');
$commentTable = $this->Dbo->fullTableName('comments'); $commentTable = $this->Dbo->fullTableName('comments');
@ -3306,7 +3307,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void * @return void
*/ */
function testRealQueries() { function testRealQueries() {
$this->loadFixtures('Apple', 'Article', 'User', 'Comment', 'Tag', 'Sample'); $this->loadFixtures('Apple', 'Article', 'User', 'Comment', 'Tag', 'Sample', 'ArticlesTag');
$Apple = ClassRegistry::init('Apple'); $Apple = ClassRegistry::init('Apple');
$Article = ClassRegistry::init('Article'); $Article = ClassRegistry::init('Article');

View file

@ -44,7 +44,7 @@ class DboPostgresTestDb extends DboPostgres {
* @access protected * @access protected
* @return void * @return void
*/ */
function _execute($sql) { function _execute($sql, $params = array()) {
$this->simulated[] = $sql; $this->simulated[] = $sql;
return null; return null;
} }
@ -130,7 +130,7 @@ class PostgresTestModel extends Model {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { function schema($field = false) {
return array( return array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
@ -184,7 +184,7 @@ class PostgresClientTestModel extends Model {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { function schema($field = false) {
return array( return array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'), 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),

View file

@ -42,7 +42,7 @@ class DboSqliteTestDb extends DboSqlite {
* @access protected * @access protected
* @return void * @return void
*/ */
function _execute($sql) { function _execute($sql, $params = array()) {
$this->simulated[] = $sql; $this->simulated[] = $sql;
return null; return null;
} }

View file

@ -262,7 +262,7 @@ class Article extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function beforeSave() { function beforeSave($options = array()) {
return $this->beforeSaveReturn; return $this->beforeSaveReturn;
} }
@ -560,7 +560,7 @@ class ModifiedComment extends CakeTestModel {
* *
* @return void * @return void
*/ */
function afterFind($results) { function afterFind($results, $primary = false) {
if (isset($results[0])) { if (isset($results[0])) {
$results[0]['Comment']['callback'] = 'Fire'; $results[0]['Comment']['callback'] = 'Fire';
} }
@ -605,7 +605,7 @@ class AgainModifiedComment extends CakeTestModel {
* *
* @return void * @return void
*/ */
function afterFind($results) { function afterFind($results, $primary = false) {
if (isset($results[0])) { if (isset($results[0])) {
$results[0]['Comment']['querytype'] = $this->findQueryType; $results[0]['Comment']['querytype'] = $this->findQueryType;
} }
@ -921,7 +921,7 @@ class Post extends CakeTestModel {
return true; return true;
} }
function afterFind($results) { function afterFind($results, $primary = false) {
$this->useDbConfig = 'test'; $this->useDbConfig = 'test';
return $results; return $results;
} }
@ -958,7 +958,7 @@ class Author extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function afterFind($results) { function afterFind($results, $primary = false) {
$results[0]['Author']['test'] = 'working'; $results[0]['Author']['test'] = 'working';
return $results; return $results;
} }
@ -987,7 +987,7 @@ class ModifiedAuthor extends Author {
* @access public * @access public
* @return void * @return void
*/ */
function afterFind($results) { function afterFind($results, $primary = false) {
foreach($results as $index => $result) { foreach($results as $index => $result) {
$results[$index]['Author']['user'] .= ' (CakePHP)'; $results[$index]['Author']['user'] .= ' (CakePHP)';
} }
@ -1166,7 +1166,7 @@ class NodeAfterFind extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function afterFind($results) { function afterFind($results, $primary = false) {
return $results; return $results;
} }
} }
@ -2075,7 +2075,7 @@ class CallbackPostTestModel extends CakeTestModel {
* *
* @return void * @return void
*/ */
function beforeSave($options) { function beforeSave($options = array()) {
return $this->beforeSaveReturn; return $this->beforeSaveReturn;
} }
/** /**
@ -2083,7 +2083,7 @@ class CallbackPostTestModel extends CakeTestModel {
* *
* @return void * @return void
*/ */
function beforeValidate($options) { function beforeValidate($options = array()) {
return $this->beforeValidateReturn; return $this->beforeValidateReturn;
} }
/** /**
@ -2304,7 +2304,7 @@ class ValidationTest2 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
return array(); return array();
} }
} }
@ -3801,7 +3801,7 @@ class TestModel4 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
@ -3852,7 +3852,7 @@ class TestModel4TestModel7 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'test_model4_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'test_model4_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
@ -3923,7 +3923,7 @@ class TestModel5 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
@ -3986,7 +3986,7 @@ class TestModel6 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
@ -4038,7 +4038,7 @@ class TestModel7 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
@ -4103,7 +4103,7 @@ class TestModel8 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
@ -4167,7 +4167,7 @@ class TestModel9 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
@ -4234,7 +4234,7 @@ class Level extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
@ -4299,7 +4299,7 @@ class Group extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
@ -4377,7 +4377,7 @@ class User2 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
@ -4463,7 +4463,7 @@ class Category2 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
@ -4528,7 +4528,7 @@ class Article2 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
@ -4594,7 +4594,7 @@ class CategoryFeatured2 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'),
@ -4658,7 +4658,7 @@ class Featured2 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
@ -4717,7 +4717,7 @@ class Comment2 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
@ -4799,7 +4799,7 @@ class ArticleFeatured2 extends CakeTestModel {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
if (!isset($this->_schema)) { if (!isset($this->_schema)) {
$this->_schema = array( $this->_schema = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'),
@ -4875,7 +4875,7 @@ class MysqlTestModel extends Model {
* @access public * @access public
* @return void * @return void
*/ */
function schema() { public function schema($field = false) {
return array( return array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),

View file

@ -0,0 +1,278 @@
<?php
/**
* ComponentCollectionTest file
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'ObjectCollection');
/**
* A generic object class
*/
class GenericObject {
}
/**
* First Extension of Generic Object
*/
class FirstGenericObject extends GenericObject {
/**
* A generic callback
*/
public function callback() {
}
}
/**
* Second Extension of Generic Object
*/
class SecondGenericObject extends GenericObject {
public function callback() {
}
}
/**
* A collection of Generic objects
*/
class GenericObjectCollection extends ObjectCollection {
/**
* Loads a generic object
*
* @param string $object Object name
* @param array $settings Settings array
* @param boolean $enable Start object as enabled
* @return array List of loaded objects
*/
public function load($object, $settings = array(), $enable = true) {
list($plugin, $name) = pluginSplit($object);
if (isset($this->_loaded[$name])) {
return $this->_loaded[$name];
}
$objectClass = $name . 'GenericObject';
$this->_loaded[$name] = new $objectClass($this, $settings);
if ($enable === true) {
$this->_enabled[] = $name;
}
return $this->_loaded[$name];
}
}
class ObjectCollectionTest extends CakeTestCase {
/**
* setup
*
* @return void
*/
function setup() {
$this->Objects = new GenericObjectCollection();
}
/**
* teardown
*
* @return void
*/
function teardown() {
unset($this->Objects);
}
/**
* test triggering callbacks on loaded helpers
*
* @return void
*/
function testLoad() {
$result = $this->Objects->load('First');
$this->assertType('FirstGenericObject', $result);
$this->assertType('FirstGenericObject', $this->Objects->First);
$result = $this->Objects->attached();
$this->assertEquals(array('First'), $result, 'attached() results are wrong.');
$this->assertTrue($this->Objects->enabled('First'));
$result = $this->Objects->load('First');
$this->assertSame($result, $this->Objects->First);
}
/**
* test unload()
*
* @return void
*/
function testUnload() {
$this->Objects->load('First');
$this->Objects->load('Second');
$result = $this->Objects->attached();
$this->assertEquals(array('First', 'Second'), $result, 'loaded objects are wrong');
$this->Objects->unload('First');
$this->assertFalse(isset($this->Objects->First));
$this->assertTrue(isset($this->Objects->Second));
$result = $this->Objects->attached();
$this->assertEquals(array('Second'), $result, 'loaded objects are wrong');
$result = $this->Objects->enabled();
$this->assertEquals(array('Second'), $result, 'enabled objects are wrong');
}
/**
* creates mock classes for testing
*
* @return void
*/
protected function _makeMockClasses() {
if (!class_exists('TriggerMockFirstGenericObject')) {
$this->getMock('FirstGenericObject', array(), array(), 'TriggerMockFirstGenericObject', false);
}
if (!class_exists('TriggerMockSecondGenericObject')) {
$this->getMock('SecondGenericObject', array(), array(), 'TriggerMockSecondGenericObject', false);
}
}
/**
* test triggering callbacks.
*
* @return void
*/
function testTrigger() {
$this->_makeMockClasses();
$this->Objects->load('TriggerMockFirst');
$this->Objects->load('TriggerMockSecond');
$this->Objects->TriggerMockFirst->expects($this->once())
->method('callback');
$this->Objects->TriggerMockSecond->expects($this->once())
->method('callback');
$this->assertTrue($this->Objects->trigger('callback'));
}
/**
* test that the initalize callback is triggered on all components even those that are disabled.
*
* @return void
*/
function testTriggerWithTriggerDisabledObjects() {
$this->_makeMockClasses();
$this->Objects->load('TriggerMockFirst', array(), false);
$this->Objects->load('TriggerMockSecond');
$this->Objects->TriggerMockFirst->expects($this->once())
->method('callback');
$this->Objects->TriggerMockSecond->expects($this->once())
->method('callback');
$result = $this->Objects->trigger('callback', array(), array('triggerDisabled' => true));
$this->assertTrue($result);
}
/**
* test trigger and disabled helpers.
*
* @return void
*/
function testTriggerWithDisabledComponents() {
$this->_makeMockClasses();
$this->Objects->load('TriggerMockFirst');
$this->Objects->load('TriggerMockSecond');
$this->Objects->TriggerMockFirst->expects($this->once())
->method('callback');
$this->Objects->TriggerMockSecond->expects($this->never())
->method('callback');
$this->Objects->disable('TriggerMockSecond');
$this->assertTrue($this->Objects->trigger('callback', array()));
}
/**
* test that the collectReturn option works.
*
* @return void
*/
function testTriggerWithCollectReturn() {
$this->_makeMockClasses();
$this->Objects->load('TriggerMockFirst');
$this->Objects->load('TriggerMockSecond');
$this->Objects->TriggerMockFirst->expects($this->once())
->method('callback')
->will($this->returnValue(array('one', 'two')));
$this->Objects->TriggerMockSecond->expects($this->once())
->method('callback')
->will($this->returnValue(array('three', 'four')));
$result = $this->Objects->trigger('callback', array(), array('collectReturn' => true));
$expected = array(
array('one', 'two'),
array('three', 'four')
);
$this->assertEquals($expected, $result);
}
/**
* test that trigger with break & breakOn works.
*
* @return void
*/
function testTriggerWithBreak() {
$this->_makeMockClasses();
$this->Objects->load('TriggerMockFirst');
$this->Objects->load('TriggerMockSecond');
$this->Objects->TriggerMockFirst->expects($this->once())
->method('callback')
->will($this->returnValue(false));
$this->Objects->TriggerMockSecond->expects($this->never())
->method('callback');
$result = $this->Objects->trigger(
'callback',
array(&$controller),
array('break' => true, 'breakOn' => false)
);
$this->assertFalse($result);
}
/**
* test normalizeObjectArray
*
* @return void
*/
function testnormalizeObjectArray() {
$components = array(
'Html',
'Foo.Bar' => array('one', 'two'),
'Something',
'Banana.Apple' => array('foo' => 'bar')
);
$result = ComponentCollection::normalizeObjectArray($components);
$expected = array(
'Html' => array('class' => 'Html', 'settings' => array()),
'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')),
'Something' => array('class' => 'Something', 'settings' => array()),
'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')),
);
$this->assertEquals($expected, $result);
}
}

View file

@ -253,7 +253,7 @@ class CakeFixtureManager {
$fixture->truncate($db); $fixture->truncate($db);
$fixture->insert($db); $fixture->insert($db);
} else { } else {
throw new UnexpectedValueException(sprintf(__('Referenced fixture class %s not found'), $name)); throw new UnexpectedValueException(__('Referenced fixture class %s not found', $name));
} }
} }

View file

@ -201,7 +201,7 @@ class CakeBaseReporter implements PHPUnit_Framework_TestListener {
* @param PHPUnit_Framework_TestSuite $suite * @param PHPUnit_Framework_TestSuite $suite
*/ */
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
echo sprintf(__('Running %s'), $suite->getName()) . "\n"; echo __('Running %s', $suite->getName()) . "\n";
} }
/** /**

View file

@ -237,7 +237,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
echo "<li class='fail'>\n"; echo "<li class='fail'>\n";
echo "<span>Failed</span>"; echo "<span>Failed</span>";
echo "<div class='msg'><pre>" . $this->_htmlEntities($message->toString()) . "</pre></div>\n"; echo "<div class='msg'><pre>" . $this->_htmlEntities($message->toString()) . "</pre></div>\n";
echo "<div class='msg'>" . sprintf(__('Test case: %s'), $testName) . "</div>\n"; echo "<div class='msg'>" . __('Test case: %s', $testName) . "</div>\n";
echo "<div class='msg'>" . __('Stack trace:') . '<br />' . $trace . "</div>\n"; echo "<div class='msg'>" . __('Stack trace:') . '<br />' . $trace . "</div>\n";
echo "</li>\n"; echo "</li>\n";
} }
@ -275,7 +275,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
echo "<span>Exception</span>"; echo "<span>Exception</span>";
echo "<div class='msg'>" . $this->_htmlEntities($message->getMessage()) . "</div>\n"; echo "<div class='msg'>" . $this->_htmlEntities($message->getMessage()) . "</div>\n";
echo "<div class='msg'>" . sprintf(__('Test case: %s'), $testName) . "</div>\n"; echo "<div class='msg'>" . __('Test case: %s', $testName) . "</div>\n";
echo "<div class='msg'>" . __('Stack trace:') . '<br />' . $trace . "</div>\n"; echo "<div class='msg'>" . __('Stack trace:') . '<br />' . $trace . "</div>\n";
echo "</li>\n"; echo "</li>\n";
} }
@ -341,6 +341,6 @@ class CakeHtmlReporter extends CakeBaseReporter {
* @param PHPUnit_Framework_TestSuite $suite * @param PHPUnit_Framework_TestSuite $suite
*/ */
public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { public function startTestSuite(PHPUnit_Framework_TestSuite $suite) {
echo '<h2>' . sprintf(__('Running %s'), $suite->getName()) . '</h2>'; echo '<h2>' . __('Running %s', $suite->getName()) . '</h2>';
} }
} }

View file

@ -152,10 +152,10 @@ class TestManager {
$testCaseFileWithPath = $this->_getTestsPath($this->params) . DS . $testCaseFile; $testCaseFileWithPath = $this->_getTestsPath($this->params) . DS . $testCaseFile;
if (!file_exists($testCaseFileWithPath) || strpos($testCaseFileWithPath, '..')) { if (!file_exists($testCaseFileWithPath) || strpos($testCaseFileWithPath, '..')) {
throw new InvalidArgumentException(sprintf(__('Unable to load test file %s'), htmlentities($testCaseFile))); throw new InvalidArgumentException(__('Unable to load test file %s', htmlentities($testCaseFile)));
} }
if (!$suite) { if (!$suite) {
$suite = $this->getTestSuite(sprintf(__('Individual test case: %s', true), $testCaseFile)); $suite = $this->getTestSuite(__('Individual test case: %s', $testCaseFile));
} }
$suite->addTestFile($testCaseFileWithPath); $suite->addTestFile($testCaseFileWithPath);

View file

@ -17,7 +17,7 @@
$settings = array(); $settings = array();
if (!empty($settings)): if (!empty($settings)):
echo '<span class="notice success">'; echo '<span class="notice success">';
printf(__('The %s is being used for caching. To change the config edit APP/config/core.php '), '<em>'. $settings['engine'] . 'Engine</em>'); echo __('The %s is being used for caching. To change the config edit APP/config/core.php ', '<em>'. $settings['engine'] . 'Engine</em>');
echo '</span>'; echo '</span>';
else: else:
echo '<span class="notice">'; echo '<span class="notice">';
@ -66,9 +66,9 @@ if (!empty($filePresent)):
<h3><?php echo __('Editing this Page') ?></h3> <h3><?php echo __('Editing this Page') ?></h3>
<p> <p>
<?php <?php
printf(__('To change the content of this page, edit: %s echo __('To change the content of this page, edit: %s
To change its layout, edit: %s To change its layout, edit: %s
You can also add some CSS styles for your pages at: %s'), You can also add some CSS styles for your pages at: %s',
APP . 'views' . DS . 'pages' . DS . 'home.ctp.<br />', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.<br />', APP . 'webroot' . DS . 'css'); APP . 'views' . DS . 'pages' . DS . 'home.ctp.<br />', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.<br />', APP . 'webroot' . DS . 'css');
?> ?>
</p> </p>

View file

@ -96,7 +96,7 @@ if (!empty($filePresent)):
</span> </span>
</p> </p>
<?php endif; ?> <?php endif; ?>
<h2><?php printf(__('Release Notes for CakePHP %s.', true), Configure::version()); ?></h2> <h2><?php echo __('Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<a href="https://trac.cakephp.org/wiki/notes/1.2.x.x"><?php __('Read the release notes and get the latest version'); ?> </a> <a href="https://trac.cakephp.org/wiki/notes/1.2.x.x"><?php __('Read the release notes and get the latest version'); ?> </a>
<h2><?php __('Editing this Page'); ?></h2> <h2><?php __('Editing this Page'); ?></h2>
<p> <p>

View file

@ -257,7 +257,7 @@ class Cache {
self::set(null, $config); self::set(null, $config);
if ($success === false && $value !== '') { if ($success === false && $value !== '') {
trigger_error( trigger_error(
sprintf(__("%s cache was unable to write '%s' to cache", true), $config, $key), __("%s cache was unable to write '%s' to cache", $config, $key),
E_USER_WARNING E_USER_WARNING
); );
} }

View file

@ -298,7 +298,7 @@ class FileEngine extends CacheEngine {
$dir = new SplFileInfo($this->settings['path']); $dir = new SplFileInfo($this->settings['path']);
if ($this->_init && !($dir->isDir() && $dir->isWritable())) { if ($this->_init && !($dir->isDir() && $dir->isWritable())) {
$this->_init = false; $this->_init = false;
trigger_error(sprintf(__('%s is not writable'), $this->settings['path']), E_USER_WARNING); trigger_error(__('%s is not writable', $this->settings['path']), E_USER_WARNING);
return false; return false;
} }
return true; return true;

View file

@ -153,7 +153,7 @@ class MemcacheEngine extends CacheEngine {
public function increment($key, $offset = 1) { public function increment($key, $offset = 1) {
if ($this->settings['compress']) { if ($this->settings['compress']) {
throw new RuntimeException( throw new RuntimeException(
sprintf(__('Method increment() not implemented for compressed cache in %s'), __CLASS__) __('Method increment() not implemented for compressed cache in %s', __CLASS__)
); );
} }
return $this->__Memcache->increment($key, $offset); return $this->__Memcache->increment($key, $offset);
@ -171,7 +171,7 @@ class MemcacheEngine extends CacheEngine {
public function decrement($key, $offset = 1) { public function decrement($key, $offset = 1) {
if ($this->settings['compress']) { if ($this->settings['compress']) {
throw new RuntimeException( throw new RuntimeException(
sprintf(__('Method decrement() not implemented for compressed cache in %s'), __CLASS__) __('Method decrement() not implemented for compressed cache in %s', __CLASS__)
); );
} }
return $this->__Memcache->decrement($key, $offset); return $this->__Memcache->decrement($key, $offset);

View file

@ -68,7 +68,7 @@ class AclComponent extends Component {
list($plugin, $name) = pluginSplit($name); list($plugin, $name) = pluginSplit($name);
$name .= 'Component'; $name .= 'Component';
} else { } else {
throw new Exception(sprintf(__('Could not find %s.'), $name)); throw new Exception(__('Could not find %s.', $name));
} }
} }
$this->adapter($name); $this->adapter($name);
@ -316,7 +316,7 @@ class DbAcl extends Object implements AclInterface {
$acoNode = $acoPath[0]; $acoNode = $acoPath[0];
if ($action != '*' && !in_array('_' . $action, $permKeys)) { if ($action != '*' && !in_array('_' . $action, $permKeys)) {
trigger_error(sprintf(__("ACO permissions key %s does not exist in DbAcl::check()"), $action), E_USER_NOTICE); trigger_error(__("ACO permissions key %s does not exist in DbAcl::check()", $action), E_USER_NOTICE);
return false; return false;
} }

View file

@ -523,7 +523,7 @@ class AuthComponent extends Component {
case 'crud': case 'crud':
if (!isset($this->actionMap[$this->request['action']])) { if (!isset($this->actionMap[$this->request['action']])) {
trigger_error( trigger_error(
sprintf(__('Auth::startup() - Attempted access of un-mapped action "%1$s" in controller "%2$s"'), $this->request['action'], $this->request['controller']), __('Auth::startup() - Attempted access of un-mapped action "%1$s" in controller "%2$s"', $this->request['action'], $this->request['controller']),
E_USER_WARNING E_USER_WARNING
); );
} else { } else {
@ -547,13 +547,13 @@ class AuthComponent extends Component {
$action = $this->action(':action'); $action = $this->action(':action');
} }
if (empty($object)) { if (empty($object)) {
trigger_error(sprintf(__('Could not find %s. Set AuthComponent::$object in beforeFilter() or pass a valid object'), get_class($object)), E_USER_WARNING); trigger_error(__('Could not find %s. Set AuthComponent::$object in beforeFilter() or pass a valid object', get_class($object)), E_USER_WARNING);
return; return;
} }
if (method_exists($object, 'isAuthorized')) { if (method_exists($object, 'isAuthorized')) {
$valid = $object->isAuthorized($user, $this->action(':controller'), $action); $valid = $object->isAuthorized($user, $this->action(':controller'), $action);
} elseif ($object) { } elseif ($object) {
trigger_error(sprintf(__('%s::isAuthorized() is not defined.'), get_class($object)), E_USER_WARNING); trigger_error(__('%s::isAuthorized() is not defined.', get_class($object)), E_USER_WARNING);
} }
break; break;
case null: case null:

View file

@ -732,7 +732,7 @@ class Controller extends Object {
*/ */
public function isAuthorized() { public function isAuthorized() {
trigger_error(sprintf( trigger_error(sprintf(
__('%s::isAuthorized() is not defined.'), $this->name __('%sController::isAuthorized() is not defined.'), $this->name
), E_USER_WARNING); ), E_USER_WARNING);
return false; return false;
} }
@ -1220,5 +1220,3 @@ class Controller extends Object {
return false; return false;
} }
} }
class MissingModelException extends RuntimeException {}

View file

@ -58,7 +58,7 @@ class Configure {
self::write('App', array('base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR, 'www_root' => WWW_ROOT)); self::write('App', array('base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR, 'www_root' => WWW_ROOT));
if (!include(CONFIGS . 'core.php')) { if (!include(CONFIGS . 'core.php')) {
trigger_error(sprintf(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP."), CONFIGS), E_USER_ERROR); trigger_error(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR);
} }
if (Configure::read('Cache.disable') !== true) { if (Configure::read('Cache.disable') !== true) {
@ -100,7 +100,7 @@ class Configure {
App::init(); App::init();
App::build(); App::build();
if (!include(CONFIGS . 'bootstrap.php')) { if (!include(CONFIGS . 'bootstrap.php')) {
trigger_error(sprintf(__("Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP."), CONFIGS), E_USER_ERROR); trigger_error(__("Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR);
} }
$level = -1; $level = -1;
if (isset(self::$_values['Error']['level'])) { if (isset(self::$_values['Error']['level'])) {
@ -299,7 +299,7 @@ class Configure {
} }
if (!isset($config)) { if (!isset($config)) {
trigger_error(sprintf(__('Configure::load() - no variable $config found in %s.php'), $fileName), E_USER_WARNING); trigger_error(__('Configure::load() - no variable $config found in %s.php', $fileName), E_USER_WARNING);
return false; return false;
} }
return self::write($config); return self::write($config);

View file

@ -174,7 +174,7 @@ class CakeException extends RuntimeException {
public function __construct($message, $code = 500) { public function __construct($message, $code = 500) {
if (is_array($message)) { if (is_array($message)) {
$this->_attributes = $message; $this->_attributes = $message;
$message = vsprintf(__($this->_messageTemplate), $message); $message = __($this->_messageTemplate, $message);
} }
parent::__construct($message, $code); parent::__construct($message, $code);
} }
@ -301,6 +301,8 @@ class MissingHelperClassException extends CakeException {
/** /**
* Runtime Exceptions for ConnectionManager * Runtime Exceptions for ConnectionManager
*
* @package cake.libs
*/ */
class MissingDatabaseException extends CakeException { class MissingDatabaseException extends CakeException {
protected $_messageTemplate = 'Database connection "%s" could not be found.'; protected $_messageTemplate = 'Database connection "%s" could not be found.';
@ -368,3 +370,12 @@ class MissingShellFileException extends CakeException {
class MissingTableException extends CakeException { class MissingTableException extends CakeException {
protected $_messageTemplate = 'Database table %s for model %s was not found.'; protected $_messageTemplate = 'Database table %s for model %s was not found.';
} }
/**
* Exception Raised when a Model could not be found.
*
* @package cake.libs
*/
class MissingModelException extends CakeException {
protected $_messageTemplate = 'Model %s could not be found.';
}

View file

@ -128,7 +128,7 @@ class CakeLog {
App::uses($loggerName, $plugin . 'Log/Engine'); App::uses($loggerName, $plugin . 'Log/Engine');
if (!class_exists($loggerName)) { if (!class_exists($loggerName)) {
throw new Exception(sprintf(__('Could not load class %s'), $loggerName)); throw new Exception(__('Could not load class %s', $loggerName));
} }
return $loggerName; return $loggerName;
} }

View file

@ -203,7 +203,7 @@ class BehaviorCollection extends ObjectCollection {
$call = null; $call = null;
if ($strict && !$found) { if ($strict && !$found) {
trigger_error(sprintf(__("BehaviorCollection::dispatchMethod() - Method %s not found in any attached behavior"), $method), E_USER_WARNING); trigger_error(__("BehaviorCollection::dispatchMethod() - Method %s not found in any attached behavior", $method), E_USER_WARNING);
return null; return null;
} elseif ($found) { } elseif ($found) {
$methods = array_combine($methods, array_values($this->__methods)); $methods = array_combine($methods, array_values($this->__methods));

View file

@ -585,7 +585,7 @@ class CakeSchema extends Object {
$value['key'] = 'primary'; $value['key'] = 'primary';
} }
if (!isset($db->columns[$value['type']])) { if (!isset($db->columns[$value['type']])) {
trigger_error(sprintf(__('Schema generation error: invalid column type %s does not exist in DBO'), $value['type']), E_USER_NOTICE); trigger_error(__('Schema generation error: invalid column type %s does not exist in DBO', $value['type']), E_USER_NOTICE);
continue; continue;
} else { } else {
$defaultCol = $db->columns[$value['type']]; $defaultCol = $db->columns[$value['type']];

View file

@ -263,12 +263,12 @@ class CakeSession {
public static function delete($name) { public static function delete($name) {
if (self::check($name)) { if (self::check($name)) {
if (in_array($name, self::$watchKeys)) { if (in_array($name, self::$watchKeys)) {
trigger_error(sprintf(__('Deleting session key {%s}'), $name), E_USER_NOTICE); trigger_error(__('Deleting session key {%s}', $name), E_USER_NOTICE);
} }
self::__overwrite($_SESSION, Set::remove($_SESSION, $name)); self::__overwrite($_SESSION, Set::remove($_SESSION, $name));
return (self::check($name) == false); return (self::check($name) == false);
} }
self::__setError(2, sprintf(__("%s doesn't exist"), $name)); self::__setError(2, __("%s doesn't exist", $name));
return false; return false;
} }
@ -453,7 +453,7 @@ class CakeSession {
} }
foreach ($write as $key => $val) { foreach ($write as $key => $val) {
if (in_array($key, self::$watchKeys)) { if (in_array($key, self::$watchKeys)) {
trigger_error(sprintf(__('Writing session key {%s}: %s'), $key, Debugger::exportVar($val)), E_USER_NOTICE); trigger_error(__('Writing session key {%s}: %s', $key, Debugger::exportVar($val)), E_USER_NOTICE);
} }
self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val)); self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val));
if (Set::classicExtract($_SESSION, $key) !== $val) { if (Set::classicExtract($_SESSION, $key) !== $val) {
@ -563,7 +563,7 @@ class CakeSession {
App::import('Core', 'session/' . $class); App::import('Core', 'session/' . $class);
} }
if (!class_exists($class)) { if (!class_exists($class)) {
throw new Exception(sprintf(__('Could not load %s to handle the session.'), $class)); throw new Exception(__('Could not load %s to handle the session.', $class));
} }
$handler = new $class(); $handler = new $class();
if ($handler instanceof CakeSessionHandlerInterface) { if ($handler instanceof CakeSessionHandlerInterface) {

View file

@ -96,7 +96,7 @@ class ConnectionManager {
} }
if (empty($_this->_connectionsEnum[$name])) { if (empty($_this->_connectionsEnum[$name])) {
trigger_error(sprintf(__("ConnectionManager::getDataSource - Non-existent data source %s"), $name), E_USER_ERROR); trigger_error(__("ConnectionManager::getDataSource - Non-existent data source %s", $name), E_USER_ERROR);
$null = null; $null = null;
return $null; return $null;
} }
@ -104,7 +104,7 @@ class ConnectionManager {
$class = $conn['classname']; $class = $conn['classname'];
if ($_this->loadDataSource($name) === null) { if ($_this->loadDataSource($name) === null) {
trigger_error(sprintf(__("ConnectionManager::getDataSource - Could not load class %s"), $class), E_USER_ERROR); trigger_error(__("ConnectionManager::getDataSource - Could not load class %s", $class), E_USER_ERROR);
$null = null; $null = null;
return $null; return $null;
} }
@ -175,7 +175,7 @@ class ConnectionManager {
App::uses($conn['classname'], $plugin . 'Model/Datasource' . $package); App::uses($conn['classname'], $plugin . 'Model/Datasource' . $package);
if (!class_exists($conn['classname'])) { if (!class_exists($conn['classname'])) {
trigger_error(sprintf(__('ConnectionManager::loadDataSource - Unable to import DataSource class %s'), $class), E_USER_ERROR); trigger_error(__('ConnectionManager::loadDataSource - Unable to import DataSource class %s', $class), E_USER_ERROR);
return null; return null;
} }
return true; return true;

View file

@ -286,7 +286,7 @@ class DataSource extends Object {
* *
* @return boolean Returns true if a transaction is not in progress * @return boolean Returns true if a transaction is not in progress
*/ */
public function begin(&$model) { public function begin() {
return !$this->_transactionStarted; return !$this->_transactionStarted;
} }
@ -295,7 +295,7 @@ class DataSource extends Object {
* *
* @return boolean Returns true if a transaction is in progress * @return boolean Returns true if a transaction is in progress
*/ */
public function commit(&$model) { public function commit() {
return $this->_transactionStarted; return $this->_transactionStarted;
} }
@ -304,7 +304,7 @@ class DataSource extends Object {
* *
* @return boolean Returns true if a transaction is in progress * @return boolean Returns true if a transaction is in progress
*/ */
public function rollback(&$model) { public function rollback() {
return $this->_transactionStarted; return $this->_transactionStarted;
} }
@ -328,7 +328,7 @@ class DataSource extends Object {
* @param array $values An Array of values to save. * @param array $values An Array of values to save.
* @return boolean success * @return boolean success
*/ */
public function create(&$model, $fields = null, $values = null) { public function create($model, $fields = null, $values = null) {
return false; return false;
} }
@ -341,7 +341,7 @@ class DataSource extends Object {
* @param array $queryData An array of query data used to find the data you want * @param array $queryData An array of query data used to find the data you want
* @return mixed * @return mixed
*/ */
public function read(&$model, $queryData = array()) { public function read($model, $queryData = array()) {
return false; return false;
} }
@ -355,7 +355,7 @@ class DataSource extends Object {
* @param array $values Array of values to be update $fields to. * @param array $values Array of values to be update $fields to.
* @return boolean Success * @return boolean Success
*/ */
public function update(&$model, $fields = null, $values = null) { public function update($model, $fields = null, $values = null) {
return false; return false;
} }
@ -367,7 +367,7 @@ class DataSource extends Object {
* @param Model $model The model class having record(s) deleted * @param Model $model The model class having record(s) deleted
* @param mixed $id Primary key of the model * @param mixed $id Primary key of the model
*/ */
public function delete(&$model, $id = null) { public function delete($model, $id = null) {
if ($id == null) { if ($id == null) {
$id = $model->id; $id = $model->id;
} }

View file

@ -227,7 +227,7 @@ class DboMssql extends DboSource {
* @param Model $model Model object to describe * @param Model $model Model object to describe
* @return array Fields in table. Keys are name and type * @return array Fields in table. Keys are name and type
*/ */
function describe(&$model) { function describe($model) {
$cache = parent::describe($model); $cache = parent::describe($model);
if ($cache != null) { if ($cache != null) {
@ -317,7 +317,7 @@ class DboMssql extends DboSource {
* @param mixed $fields * @param mixed $fields
* @return array * @return array
*/ */
function fields(&$model, $alias = null, $fields = array(), $quote = true) { function fields($model, $alias = null, $fields = array(), $quote = true) {
if (empty($alias)) { if (empty($alias)) {
$alias = $model->alias; $alias = $model->alias;
} }
@ -383,7 +383,7 @@ class DboMssql extends DboSource {
* @param mixed $conditions * @param mixed $conditions
* @return array * @return array
*/ */
function create(&$model, $fields = null, $values = null) { function create($model, $fields = null, $values = null) {
if (!empty($values)) { if (!empty($values)) {
$fields = array_combine($fields, $values); $fields = array_combine($fields, $values);
} }
@ -413,7 +413,7 @@ class DboMssql extends DboSource {
* @param mixed $conditions * @param mixed $conditions
* @return array * @return array
*/ */
function update(&$model, $fields = array(), $values = null, $conditions = null) { function update($model, $fields = array(), $values = null, $conditions = null) {
if (!empty($values)) { if (!empty($values)) {
$fields = array_combine($fields, $values); $fields = array_combine($fields, $values);
} }
@ -667,7 +667,7 @@ class DboMssql extends DboSource {
* @param boolean $cache Enables returning/storing cached query results * @param boolean $cache Enables returning/storing cached query results
* @return array Array of resultset rows, or false if no rows matched * @return array Array of resultset rows, or false if no rows matched
*/ */
function read(&$model, $queryData = array(), $recursive = null) { function read($model, $queryData = array(), $recursive = null) {
$results = parent::read($model, $queryData, $recursive); $results = parent::read($model, $queryData, $recursive);
$this->__fieldMappings = array(); $this->__fieldMappings = array();
return $results; return $results;

View file

@ -331,7 +331,7 @@ class Mysql extends DboSource {
* @param mixed $conditions * @param mixed $conditions
* @return array * @return array
*/ */
function update(&$model, $fields = array(), $values = null, $conditions = null) { function update($model, $fields = array(), $values = null, $conditions = null) {
if (!$this->_useAlias) { if (!$this->_useAlias) {
return parent::update($model, $fields, $values, $conditions); return parent::update($model, $fields, $values, $conditions);
} }
@ -373,7 +373,7 @@ class Mysql extends DboSource {
* @param mixed $conditions * @param mixed $conditions
* @return boolean Success * @return boolean Success
*/ */
function delete(&$model, $conditions = null) { function delete($model, $conditions = null) {
if (!$this->_useAlias) { if (!$this->_useAlias) {
return parent::delete($model, $conditions); return parent::delete($model, $conditions);
} }
@ -502,16 +502,12 @@ class Mysql extends DboSource {
/** /**
* Generate a MySQL "drop table" statement for the given Schema object * Generate a MySQL "drop table" statement for the given Schema object
* *
* @param object $schema An instance of a subclass of CakeSchema * @param CakeSchema $schema An instance of a subclass of CakeSchema
* @param string $table Optional. If specified only the table name given will be generated. * @param string $table Optional. If specified only the table name given will be generated.
* Otherwise, all tables defined in the schema are generated. * Otherwise, all tables defined in the schema are generated.
* @return string * @return string
*/ */
function dropSchema($schema, $table = null) { function dropSchema(CakeSchema $schema, $table = null) {
if (!is_a($schema, 'CakeSchema')) {
trigger_error(__('Invalid schema object'), E_USER_WARNING);
return null;
}
$out = ''; $out = '';
foreach ($schema->tables as $curTable => $columns) { foreach ($schema->tables as $curTable => $columns) {
if (!$table || $table == $curTable) { if (!$table || $table == $curTable) {

View file

@ -478,7 +478,7 @@ class DboOracle extends DboSource {
* @param object instance of a model to inspect * @param object instance of a model to inspect
* @return array Fields in table. Keys are name and type * @return array Fields in table. Keys are name and type
*/ */
public function describe(&$model) { public function describe($model) {
$table = $this->fullTableName($model, false); $table = $this->fullTableName($model, false);
if (!empty($model->sequence)) { if (!empty($model->sequence)) {
@ -974,11 +974,11 @@ class DboOracle extends DboSource {
* @param integer $recursive Number of levels of association * @param integer $recursive Number of levels of association
* @param array $stack * @param array $stack
*/ */
function queryAssociation(&$model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) { function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
if (!isset($resultSet) || !is_array($resultSet)) { if (!isset($resultSet) || !is_array($resultSet)) {
if (Configure::read('debug') > 0) { if (Configure::read('debug') > 0) {
echo '<div style = "font: Verdana bold 12px; color: #FF0000">' . sprintf(__('SQL Error in model %s:'), $model->alias) . ' '; echo '<div style = "font: Verdana bold 12px; color: #FF0000">' . __('SQL Error in model %s:', $model->alias) . ' ';
if (isset($this->error) && $this->error != null) { if (isset($this->error) && $this->error != null) {
echo $this->error; echo $this->error;
} }
@ -1121,16 +1121,12 @@ class DboOracle extends DboSource {
/** /**
* Generate a "drop table" statement for the given Schema object * Generate a "drop table" statement for the given Schema object
* *
* @param object $schema An instance of a subclass of CakeSchema * @param CakeSchema $schema An instance of a subclass of CakeSchema
* @param string $table Optional. If specified only the table name given will be generated. * @param string $table Optional. If specified only the table name given will be generated.
* Otherwise, all tables defined in the schema are generated. * Otherwise, all tables defined in the schema are generated.
* @return string * @return string
*/ */
function dropSchema($schema, $table = null) { function dropSchema(CakeSchema $schema, $table = null) {
if (!is_a($schema, 'CakeSchema')) {
trigger_error(__('Invalid schema object'), E_USER_WARNING);
return null;
}
$out = ''; $out = '';
foreach ($schema->tables as $curTable => $columns) { foreach ($schema->tables as $curTable => $columns) {

View file

@ -152,7 +152,7 @@ class DboPostgres extends DboSource {
* *
* @return array Array of tablenames in the database * @return array Array of tablenames in the database
*/ */
function listSources() { function listSources($data = null) {
$cache = parent::listSources(); $cache = parent::listSources();
if ($cache != null) { if ($cache != null) {
@ -185,7 +185,7 @@ class DboPostgres extends DboSource {
* @param string $tableName Name of database table to inspect * @param string $tableName Name of database table to inspect
* @return array Fields in table. Keys are name and type * @return array Fields in table. Keys are name and type
*/ */
function &describe(&$model) { function describe($model) {
$fields = parent::describe($model); $fields = parent::describe($model);
$table = $this->fullTableName($model, false); $table = $this->fullTableName($model, false);
$this->_sequenceMap[$table] = array(); $this->_sequenceMap[$table] = array();
@ -332,7 +332,7 @@ class DboPostgres extends DboSource {
* @param mixed $fields * @param mixed $fields
* @return array * @return array
*/ */
function fields(&$model, $alias = null, $fields = array(), $quote = true) { function fields($model, $alias = null, $fields = array(), $quote = true) {
if (empty($alias)) { if (empty($alias)) {
$alias = $model->alias; $alias = $model->alias;
} }

View file

@ -138,7 +138,7 @@ class DboSqlite extends DboSource {
* @return array Array of tablenames in the database * @return array Array of tablenames in the database
* @access public * @access public
*/ */
function listSources() { function listSources($data = null) {
$cache = parent::listSources(); $cache = parent::listSources();
if ($cache != null) { if ($cache != null) {
return $cache; return $cache;
@ -166,7 +166,7 @@ class DboSqlite extends DboSource {
* @return array Fields in table. Keys are name and type * @return array Fields in table. Keys are name and type
* @access public * @access public
*/ */
function describe(&$model) { function describe($model) {
$cache = parent::describe($model); $cache = parent::describe($model);
if ($cache != null) { if ($cache != null) {
return $cache; return $cache;
@ -208,7 +208,7 @@ class DboSqlite extends DboSource {
* @return array * @return array
* @access public * @access public
*/ */
function update(&$model, $fields = array(), $values = null, $conditions = null) { function update($model, $fields = array(), $values = null, $conditions = null) {
if (empty($values) && !empty($fields)) { if (empty($values) && !empty($fields)) {
foreach ($fields as $field => $value) { foreach ($fields as $field => $value) {
if (strpos($field, $model->alias . '.') !== false) { if (strpos($field, $model->alias . '.') !== false) {
@ -382,7 +382,7 @@ class DboSqlite extends DboSource {
} }
if (!isset($this->columns[$type])) { if (!isset($this->columns[$type])) {
trigger_error("Column type {$type} does not exist", E_USER_WARNING); trigger_error(__('Column type %s does not exist', $type), E_USER_WARNING);
return null; return null;
} }
@ -458,7 +458,7 @@ class DboSqlite extends DboSource {
* @return array Fields in table. Keys are column and unique * @return array Fields in table. Keys are column and unique
* @access public * @access public
*/ */
function index(&$model) { function index($model) {
$index = array(); $index = array();
$table = $this->fullTableName($model); $table = $this->fullTableName($model);
if ($table) { if ($table) {

View file

@ -88,14 +88,6 @@ class DboSource extends DataSource {
*/ */
private $__sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to'); private $__sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to');
/**
* Indicates that a transaction have been started
*
* @var boolean
* @access protected
*/
protected $_transactionStarted = false;
/** /**
* Indicates the level of nested transactions * Indicates the level of nested transactions
* *
@ -181,7 +173,7 @@ class DboSource extends DataSource {
* @return boolean True if the database could be disconnected, else false * @return boolean True if the database could be disconnected, else false
*/ */
function disconnect() { function disconnect() {
if (is_a($this->_result, 'PDOStatement')) { if ($this->_result instanceof PDOStatement) {
$this->_result->closeCursor(); $this->_result->closeCursor();
} }
unset($this->_connection); unset($this->_connection);
@ -189,6 +181,11 @@ class DboSource extends DataSource {
return !$this->connected; return !$this->connected;
} }
/**
* Get the underlying connection object.
*
* @return PDOConnection
*/
public function getConnection() { public function getConnection() {
return $this->_connection; return $this->_connection;
} }
@ -336,7 +333,7 @@ class DboSource extends DataSource {
*/ */
protected function _execute($sql, $params = array()) { protected function _execute($sql, $params = array()) {
$sql = trim($sql); $sql = trim($sql);
if (preg_match('/^CREATE|^ALTER|^DROP/i', $sql)) { if (preg_match('/^(?:CREATE|ALTER|DROP)/i', $sql)) {
$statements = array_filter(explode(';', $sql)); $statements = array_filter(explode(';', $sql));
if (count($statements) > 1) { if (count($statements) > 1) {
$result = array_map(array($this, '_execute'), $statements); $result = array_map(array($this, '_execute'), $statements);
@ -419,10 +416,10 @@ class DboSource extends DataSource {
if (count($args) == 1) { if (count($args) == 1) {
return $this->fetchAll($args[0]); return $this->fetchAll($args[0]);
} elseif (count($args) > 1 && (strpos(strtolower($args[0]), 'findby') === 0 || strpos(strtolower($args[0]), 'findallby') === 0)) { } elseif (count($args) > 1 && (strpos($args[0], 'findBy') === 0 || strpos($args[0], 'findAllBy') === 0)) {
$params = $args[1]; $params = $args[1];
if (strpos(strtolower($args[0]), 'findby') === 0) { if (strpos($args[0], 'findBy') === 0) {
$all = false; $all = false;
$field = Inflector::underscore(preg_replace('/^findBy/i', '', $args[0])); $field = Inflector::underscore(preg_replace('/^findBy/i', '', $args[0]));
} else { } else {
@ -818,7 +815,7 @@ class DboSource extends DataSource {
if ($error) { if ($error) {
trigger_error('<span style="color:Red;text-align:left"><b>' . __('SQL Error:') . "</b> {$this->error}</span>", E_USER_WARNING); trigger_error('<span style="color:Red;text-align:left"><b>' . __('SQL Error:') . "</b> {$this->error}</span>", E_USER_WARNING);
} else { } else {
$out = ('<small>[' . sprintf(__('Aff:%s Num:%s Took:%sms'), $this->affected, $this->numRows, $this->took) . ']</small>'); $out = ('<small>[' . __('Aff:%s Num:%s Took:%sms', $this->affected, $this->numRows, $this->took) . ']</small>');
} }
pr(sprintf('<p style="text-align:left"><b>' . __('Query:') . '</b> %s %s</p>', $sql, $out)); pr(sprintf('<p style="text-align:left"><b>' . __('Query:') . '</b> %s %s</p>', $sql, $out));
} }
@ -857,7 +854,7 @@ class DboSource extends DataSource {
* be used to generate values. * be used to generate values.
* @return boolean Success * @return boolean Success
*/ */
public function create(&$model, $fields = null, $values = null) { public function create($model, $fields = null, $values = null) {
$id = null; $id = null;
if ($fields == null) { if ($fields == null) {
@ -905,7 +902,7 @@ class DboSource extends DataSource {
* @param integer $recursive Number of levels of association * @param integer $recursive Number of levels of association
* @return mixed boolean false on error/failure. An array of results on success. * @return mixed boolean false on error/failure. An array of results on success.
*/ */
public function read(&$model, $queryData = array(), $recursive = null) { public function read($model, $queryData = array(), $recursive = null) {
$queryData = $this->__scrubQueryData($queryData); $queryData = $this->__scrubQueryData($queryData);
$null = null; $null = null;
@ -1049,11 +1046,11 @@ class DboSource extends DataSource {
* @param integer $recursive Number of levels of association * @param integer $recursive Number of levels of association
* @param array $stack * @param array $stack
*/ */
public function queryAssociation(&$model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) { public function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
if (!isset($resultSet) || !is_array($resultSet)) { if (!isset($resultSet) || !is_array($resultSet)) {
if (Configure::read('debug') > 0) { if (Configure::read('debug') > 0) {
echo '<div style = "font: Verdana bold 12px; color: #FF0000">' . sprintf(__('SQL Error in model %s:'), $model->alias) . ' '; echo '<div style = "font: Verdana bold 12px; color: #FF0000">' . __('SQL Error in model %s:', $model->alias) . ' ';
if (isset($this->error) && $this->error != null) { if (isset($this->error) && $this->error != null) {
echo $this->error; echo $this->error;
} }
@ -1345,7 +1342,7 @@ class DboSource extends DataSource {
* @param array $resultSet * @param array $resultSet
* @return mixed * @return mixed
*/ */
public function generateAssociationQuery(&$model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) { public function generateAssociationQuery($model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
$queryData = $this->__scrubQueryData($queryData); $queryData = $this->__scrubQueryData($queryData);
$assocData = $this->__scrubQueryData($assocData); $assocData = $this->__scrubQueryData($assocData);
@ -1578,7 +1575,7 @@ class DboSource extends DataSource {
* @access public * @access public
* @see DboSource::renderStatement() * @see DboSource::renderStatement()
*/ */
public function buildStatement($query, &$model) { public function buildStatement($query, $model) {
$query = array_merge(array('offset' => null, 'joins' => array()), $query); $query = array_merge(array('offset' => null, 'joins' => array()), $query);
if (!empty($query['joins'])) { if (!empty($query['joins'])) {
$count = count($query['joins']); $count = count($query['joins']);
@ -1697,7 +1694,7 @@ class DboSource extends DataSource {
* @param mixed $conditions * @param mixed $conditions
* @return boolean Success * @return boolean Success
*/ */
public function update(&$model, $fields = array(), $values = null, $conditions = null) { public function update($model, $fields = array(), $values = null, $conditions = null) {
if ($values == null) { if ($values == null) {
$combined = $fields; $combined = $fields;
} else { } else {
@ -1731,7 +1728,7 @@ class DboSource extends DataSource {
* @param boolean $alias Include the model alias in the field name * @param boolean $alias Include the model alias in the field name
* @return array Fields and values, quoted and preparted * @return array Fields and values, quoted and preparted
*/ */
protected function _prepareUpdateFields(&$model, $fields, $quoteValues = true, $alias = false) { protected function _prepareUpdateFields($model, $fields, $quoteValues = true, $alias = false) {
$quotedAlias = $this->startQuote . $model->alias . $this->endQuote; $quotedAlias = $this->startQuote . $model->alias . $this->endQuote;
$updates = array(); $updates = array();
@ -1774,7 +1771,7 @@ class DboSource extends DataSource {
* @param mixed $conditions * @param mixed $conditions
* @return boolean Success * @return boolean Success
*/ */
public function delete(&$model, $conditions = null) { public function delete($model, $conditions = null) {
$alias = $joins = null; $alias = $joins = null;
$table = $this->fullTableName($model); $table = $this->fullTableName($model);
$conditions = $this->_matchRecords($model, $conditions); $conditions = $this->_matchRecords($model, $conditions);
@ -1798,7 +1795,7 @@ class DboSource extends DataSource {
* @param mixed $conditions * @param mixed $conditions
* @return array List of record IDs * @return array List of record IDs
*/ */
protected function _matchRecords(&$model, $conditions = null) { protected function _matchRecords($model, $conditions = null) {
if ($conditions === true) { if ($conditions === true) {
$conditions = $this->conditions(true); $conditions = $this->conditions(true);
} elseif ($conditions === null) { } elseif ($conditions === null) {
@ -1874,7 +1871,7 @@ class DboSource extends DataSource {
* @param array $params Function parameters (any values must be quoted manually) * @param array $params Function parameters (any values must be quoted manually)
* @return string An SQL calculation function * @return string An SQL calculation function
*/ */
public function calculate(&$model, $func, $params = array()) { public function calculate($model, $func, $params = array()) {
$params = (array)$params; $params = (array)$params;
switch (strtolower($func)) { switch (strtolower($func)) {
@ -1993,7 +1990,7 @@ class DboSource extends DataSource {
* @see DboSource::update() * @see DboSource::update()
* @see DboSource::conditions() * @see DboSource::conditions()
*/ */
public function defaultConditions(&$model, $conditions, $useAlias = true) { public function defaultConditions($model, $conditions, $useAlias = true) {
if (!empty($conditions)) { if (!empty($conditions)) {
return $conditions; return $conditions;
} }
@ -2052,7 +2049,7 @@ class DboSource extends DataSource {
* @param mixed $fields virtual fields to be used on query * @param mixed $fields virtual fields to be used on query
* @return array * @return array
*/ */
protected function _constructVirtualFields(&$model, $alias, $fields) { protected function _constructVirtualFields($model, $alias, $fields) {
$virtual = array(); $virtual = array();
foreach ($fields as $field) { foreach ($fields as $field) {
$virtualField = $this->name($alias . $this->virtualFieldSeparator . $field); $virtualField = $this->name($alias . $this->virtualFieldSeparator . $field);
@ -2071,7 +2068,7 @@ class DboSource extends DataSource {
* @param boolean $quote If false, returns fields array unquoted * @param boolean $quote If false, returns fields array unquoted
* @return array * @return array
*/ */
public function fields(&$model, $alias = null, $fields = array(), $quote = true) { public function fields($model, $alias = null, $fields = array(), $quote = true) {
if (empty($alias)) { if (empty($alias)) {
$alias = $model->alias; $alias = $model->alias;
} }
@ -2364,7 +2361,7 @@ class DboSource extends DataSource {
* @return string * @return string
* @access private * @access private
*/ */
function __parseKey(&$model, $key, $value) { function __parseKey($model, $key, $value) {
$operatorMatch = '/^((' . implode(')|(', $this->__sqlOps); $operatorMatch = '/^((' . implode(')|(', $this->__sqlOps);
$operatorMatch .= '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is'; $operatorMatch .= '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is';
$bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false)); $bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false));
@ -2615,7 +2612,7 @@ class DboSource extends DataSource {
* @param string $sql SQL WHERE clause (condition only, not the "WHERE" part) * @param string $sql SQL WHERE clause (condition only, not the "WHERE" part)
* @return boolean True if the table has a matching record, else false * @return boolean True if the table has a matching record, else false
*/ */
public function hasAny(&$Model, $sql) { public function hasAny($Model, $sql) {
$sql = $this->conditions($sql); $sql = $this->conditions($sql);
$table = $this->fullTableName($Model); $table = $this->fullTableName($Model);
$alias = $this->alias . $this->name($Model->alias); $alias = $this->alias . $this->name($Model->alias);
@ -2804,16 +2801,12 @@ class DboSource extends DataSource {
/** /**
* Generate a "drop table" statement for the given Schema object * Generate a "drop table" statement for the given Schema object
* *
* @param object $schema An instance of a subclass of CakeSchema * @param CakeSchema $schema An instance of a subclass of CakeSchema
* @param string $table Optional. If specified only the table name given will be generated. * @param string $table Optional. If specified only the table name given will be generated.
* Otherwise, all tables defined in the schema are generated. * Otherwise, all tables defined in the schema are generated.
* @return string * @return string
*/ */
public function dropSchema($schema, $table = null) { public function dropSchema(CakeSchema $schema, $table = null) {
if (!is_a($schema, 'CakeSchema')) {
trigger_error(__('Invalid schema object'), E_USER_WARNING);
return null;
}
$out = ''; $out = '';
foreach ($schema->tables as $curTable => $columns) { foreach ($schema->tables as $curTable => $columns) {
@ -2841,7 +2834,7 @@ class DboSource extends DataSource {
} }
if (!isset($this->columns[$type])) { if (!isset($this->columns[$type])) {
trigger_error(sprintf(__('Column type %s does not exist'), $type), E_USER_WARNING); trigger_error(__('Column type %s does not exist', $type), E_USER_WARNING);
return null; return null;
} }

View file

@ -138,7 +138,7 @@ class AclNode extends AppModel {
$model = ClassRegistry::init(array('class' => $name, 'alias' => $name)); $model = ClassRegistry::init(array('class' => $name, 'alias' => $name));
if (empty($model)) { if (empty($model)) {
trigger_error(sprintf(__("Model class '%s' not found in AclNode::node() when trying to bind %s object"), $type, $this->alias), E_USER_WARNING); trigger_error(__("Model class '%s' not found in AclNode::node() when trying to bind %s object", $type, $this->alias), E_USER_WARNING);
return null; return null;
} }
@ -183,7 +183,7 @@ class AclNode extends AppModel {
$result = $db->read($this, $queryData, -1); $result = $db->read($this, $queryData, -1);
if (!$result) { if (!$result) {
trigger_error(sprintf(__("AclNode::node() - Couldn't find %s node identified by \"%s\""), $type, print_r($ref, true)), E_USER_WARNING); trigger_error(__("AclNode::node() - Couldn't find %s node identified by \"%s\"", $type, print_r($ref, true)), E_USER_WARNING);
} }
} }
return $result; return $result;

View file

@ -2634,7 +2634,7 @@ class Model extends Object {
} elseif (!is_array($validator['rule'])) { } elseif (!is_array($validator['rule'])) {
$valid = preg_match($rule, $data[$fieldName]); $valid = preg_match($rule, $data[$fieldName]);
} elseif (Configure::read('debug') > 0) { } elseif (Configure::read('debug') > 0) {
trigger_error(sprintf(__('Could not find validation handler %s for %s'), $rule, $fieldName), E_USER_WARNING); trigger_error(__('Could not find validation handler %s for %s', $rule, $fieldName), E_USER_WARNING);
} }
if (!$valid || (is_string($valid) && strlen($valid) > 0)) { if (!$valid || (is_string($valid) && strlen($valid) > 0)) {
@ -2943,7 +2943,7 @@ class Model extends Object {
return array($with, array_unique(array_merge($assoc[$with], $keys))); return array($with, array_unique(array_merge($assoc[$with], $keys)));
} }
trigger_error( trigger_error(
sprintf(__('Invalid join model settings in %s'), $model->alias), __('Invalid join model settings in %s', $model->alias),
E_USER_WARNING E_USER_WARNING
); );
} }

View file

@ -59,7 +59,7 @@ class ModelBehavior extends Object {
* @param object $model Model using this behavior * @param object $model Model using this behavior
* @param array $config Configuration settings for $model * @param array $config Configuration settings for $model
*/ */
public function setup(&$model, $config = array()) { } public function setup($model, $config = array()) { }
/** /**
* Clean up any initialization this behavior has done on a model. Called when a behavior is dynamically * Clean up any initialization this behavior has done on a model. Called when a behavior is dynamically
@ -69,7 +69,7 @@ class ModelBehavior extends Object {
* @access public * @access public
* @see BehaviorCollection::detach() * @see BehaviorCollection::detach()
*/ */
function cleanup(&$model) { function cleanup($model) {
if (isset($this->settings[$model->alias])) { if (isset($this->settings[$model->alias])) {
unset($this->settings[$model->alias]); unset($this->settings[$model->alias]);
} }
@ -83,7 +83,7 @@ class ModelBehavior extends Object {
* @return mixed False if the operation should abort. An array will replace the value of $query. * @return mixed False if the operation should abort. An array will replace the value of $query.
* @access public * @access public
*/ */
public function beforeFind(&$model, $query) { } public function beforeFind($model, $query) { }
/** /**
* After find callback. Can be used to modify any results returned by find and findAll. * After find callback. Can be used to modify any results returned by find and findAll.
@ -94,7 +94,7 @@ class ModelBehavior extends Object {
* @return mixed An array value will replace the value of $results - any other value will be ignored. * @return mixed An array value will replace the value of $results - any other value will be ignored.
* @access public * @access public
*/ */
public function afterFind(&$model, $results, $primary) { } public function afterFind($model, $results, $primary) { }
/** /**
* Before validate callback * Before validate callback
@ -103,7 +103,7 @@ class ModelBehavior extends Object {
* @return mixed False if the operation should abort. Any other result will continue. * @return mixed False if the operation should abort. Any other result will continue.
* @access public * @access public
*/ */
public function beforeValidate(&$model) { } public function beforeValidate($model) { }
/** /**
* Before save callback * Before save callback
@ -112,7 +112,7 @@ class ModelBehavior extends Object {
* @return mixed False if the operation should abort. Any other result will continue. * @return mixed False if the operation should abort. Any other result will continue.
* @access public * @access public
*/ */
public function beforeSave(&$model) { } public function beforeSave($model) { }
/** /**
* After save callback * After save callback
@ -120,7 +120,7 @@ class ModelBehavior extends Object {
* @param object $model Model using this behavior * @param object $model Model using this behavior
* @param boolean $created True if this save created a new record * @param boolean $created True if this save created a new record
*/ */
public function afterSave(&$model, $created) { } public function afterSave($model, $created) { }
/** /**
* Before delete callback * Before delete callback
@ -130,14 +130,14 @@ class ModelBehavior extends Object {
* @return mixed False if the operation should abort. Any other result will continue. * @return mixed False if the operation should abort. Any other result will continue.
* @access public * @access public
*/ */
public function beforeDelete(&$model, $cascade = true) { } public function beforeDelete($model, $cascade = true) { }
/** /**
* After delete callback * After delete callback
* *
* @param object $model Model using this behavior * @param object $model Model using this behavior
*/ */
public function afterDelete(&$model) { } public function afterDelete($model) { }
/** /**
* DataSource error callback * DataSource error callback
@ -145,7 +145,7 @@ class ModelBehavior extends Object {
* @param object $model Model using this behavior * @param object $model Model using this behavior
* @param string $error Error generated in DataSource * @param string $error Error generated in DataSource
*/ */
public function onError(&$model, $error) { } public function onError($model, $error) { }
/** /**
* If $model's whitelist property is non-empty, $field will be added to it. * If $model's whitelist property is non-empty, $field will be added to it.
@ -158,7 +158,7 @@ class ModelBehavior extends Object {
* @access protected * @access protected
* @return void * @return void
*/ */
function _addToWhitelist(&$model, $field) { function _addToWhitelist($model, $field) {
if (is_array($field)) { if (is_array($field)) {
foreach ($field as $f) { foreach ($field as $f) {
$this->_addToWhitelist($model, $f); $this->_addToWhitelist($model, $f);

View file

@ -13,7 +13,6 @@
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project * @link http://cakephp.org CakePHP(tm) Project
* @package cake * @package cake
* @subpackage cake.cake.libs
* @since CakePHP(tm) v 2.0 * @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
@ -27,6 +26,7 @@ App::uses('Set', 'Core');
* *
* `$request['controller']` or `$request->controller`. * `$request['controller']` or `$request->controller`.
* *
* @package cake.libs
*/ */
class CakeRequest implements ArrayAccess { class CakeRequest implements ArrayAccess {
/** /**

View file

@ -528,7 +528,7 @@ class HttpSocket extends CakeSocket {
if (!is_callable(array(&$this, $decodeMethod))) { if (!is_callable(array(&$this, $decodeMethod))) {
if (!$this->quirksMode) { if (!$this->quirksMode) {
trigger_error(sprintf(__('HttpSocket::_decodeBody - Unknown encoding: %s. Activate quirks mode to surpress error.'), h($encoding)), E_USER_WARNING); trigger_error(__('HttpSocket::_decodeBody - Unknown encoding: %s. Activate quirks mode to surpress error.', h($encoding)), E_USER_WARNING);
} }
return array('body' => $body, 'header' => false); return array('body' => $body, 'header' => false);
} }
@ -825,7 +825,7 @@ class HttpSocket extends CakeSocket {
$request['uri'] = $this->_buildUri($request['uri'], '/%path?%query'); $request['uri'] = $this->_buildUri($request['uri'], '/%path?%query');
if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) { if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) {
trigger_error(sprintf(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.'), join(',', $asteriskMethods)), E_USER_WARNING); trigger_error(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', implode(',', $asteriskMethods)), E_USER_WARNING);
return false; return false;
} }
return $request['method'].' '.$request['uri'].' '.$versionToken.$this->lineBreak; return $request['method'].' '.$request['uri'].' '.$versionToken.$this->lineBreak;

View file

@ -150,7 +150,7 @@ class ClassRegistry {
} }
if (!isset(${$class})) { if (!isset(${$class})) {
trigger_error(sprintf(__('(ClassRegistry::init() could not create instance of %1$s class %2$s '), $class, $type), E_USER_WARNING); trigger_error(__('(ClassRegistry::init() could not create instance of %1$s class %2$s ', $class, $type), E_USER_WARNING);
return $false; return $false;
} }

View file

@ -359,11 +359,11 @@ class Folder {
if ($recursive === false && is_dir($path)) { if ($recursive === false && is_dir($path)) {
if (@chmod($path, intval($mode, 8))) { if (@chmod($path, intval($mode, 8))) {
$this->__messages[] = sprintf(__('%s changed to %s'), $path, $mode); $this->__messages[] = __('%s changed to %s', $path, $mode);
return true; return true;
} }
$this->__errors[] = sprintf(__('%s NOT changed to %s'), $path, $mode); $this->__errors[] = __('%s NOT changed to %s', $path, $mode);
return false; return false;
} }
@ -380,9 +380,9 @@ class Folder {
} }
if (@chmod($fullpath, intval($mode, 8))) { if (@chmod($fullpath, intval($mode, 8))) {
$this->__messages[] = sprintf(__('%s changed to %s'), $fullpath, $mode); $this->__messages[] = __('%s changed to %s', $fullpath, $mode);
} else { } else {
$this->__errors[] = sprintf(__('%s NOT changed to %s'), $fullpath, $mode); $this->__errors[] = __('%s NOT changed to %s', $fullpath, $mode);
} }
} }
} }
@ -467,7 +467,7 @@ class Folder {
} }
if (is_file($pathname)) { if (is_file($pathname)) {
$this->__errors[] = sprintf(__('%s is a file'), $pathname); $this->__errors[] = __('%s is a file', $pathname);
return false; return false;
} }
$pathname = rtrim($pathname, DS); $pathname = rtrim($pathname, DS);
@ -478,11 +478,11 @@ class Folder {
$old = umask(0); $old = umask(0);
if (mkdir($pathname, $mode)) { if (mkdir($pathname, $mode)) {
umask($old); umask($old);
$this->__messages[] = sprintf(__('%s created'), $pathname); $this->__messages[] = __('%s created', $pathname);
return true; return true;
} else { } else {
umask($old); umask($old);
$this->__errors[] = sprintf(__('%s NOT created'), $pathname); $this->__errors[] = __('%s NOT created', $pathname);
return false; return false;
} }
} }
@ -555,9 +555,9 @@ class Folder {
} }
if (is_file($file) === true) { if (is_file($file) === true) {
if (@unlink($file)) { if (@unlink($file)) {
$this->__messages[] = sprintf(__('%s removed'), $file); $this->__messages[] = __('%s removed', $file);
} else { } else {
$this->__errors[] = sprintf(__('%s NOT removed'), $file); $this->__errors[] = __('%s NOT removed', $file);
} }
} elseif (is_dir($file) === true && $this->delete($file) === false) { } elseif (is_dir($file) === true && $this->delete($file) === false) {
return false; return false;
@ -566,10 +566,10 @@ class Folder {
} }
$path = substr($path, 0, strlen($path) - 1); $path = substr($path, 0, strlen($path) - 1);
if (rmdir($path) === false) { if (rmdir($path) === false) {
$this->__errors[] = sprintf(__('%s NOT removed'), $path); $this->__errors[] = __('%s NOT removed', $path);
return false; return false;
} else { } else {
$this->__messages[] = sprintf(__('%s removed'), $path); $this->__messages[] = __('%s removed', $path);
} }
} }
return true; return true;
@ -604,7 +604,7 @@ class Folder {
$mode = $options['mode']; $mode = $options['mode'];
if (!$this->cd($fromDir)) { if (!$this->cd($fromDir)) {
$this->__errors[] = sprintf(__('%s not found'), $fromDir); $this->__errors[] = __('%s not found', $fromDir);
return false; return false;
} }
@ -613,7 +613,7 @@ class Folder {
} }
if (!is_writable($toDir)) { if (!is_writable($toDir)) {
$this->__errors[] = sprintf(__('%s not writable'), $toDir); $this->__errors[] = __('%s not writable', $toDir);
return false; return false;
} }
@ -627,9 +627,9 @@ class Folder {
if (copy($from, $to)) { if (copy($from, $to)) {
chmod($to, intval($mode, 8)); chmod($to, intval($mode, 8));
touch($to, filemtime($from)); touch($to, filemtime($from));
$this->__messages[] = sprintf(__('%s copied to %s'), $from, $to); $this->__messages[] = __('%s copied to %s', $from, $to);
} else { } else {
$this->__errors[] = sprintf(__('%s NOT copied to %s'), $from, $to); $this->__errors[] = __('%s NOT copied to %s', $from, $to);
} }
} }
@ -640,11 +640,11 @@ class Folder {
$old = umask(0); $old = umask(0);
chmod($to, $mode); chmod($to, $mode);
umask($old); umask($old);
$this->__messages[] = sprintf(__('%s created'), $to); $this->__messages[] = __('%s created', $to);
$options = array_merge($options, array('to'=> $to, 'from'=> $from)); $options = array_merge($options, array('to'=> $to, 'from'=> $from));
$this->copy($options); $this->copy($options);
} else { } else {
$this->__errors[] = sprintf(__('%s not created'), $to); $this->__errors[] = __('%s not created', $to);
} }
} }
} }

View file

@ -713,11 +713,11 @@ class Validation {
protected static function _pass($method, $check, $classPrefix) { protected static function _pass($method, $check, $classPrefix) {
$className = ucwords($classPrefix) . 'Validation'; $className = ucwords($classPrefix) . 'Validation';
if (!class_exists($className)) { if (!class_exists($className)) {
trigger_error(sprintf(__('Could not find %s class, unable to complete validation.', true), $className), E_USER_WARNING); trigger_error(__('Could not find %s class, unable to complete validation.', $className), E_USER_WARNING);
return false; return false;
} }
if (!method_exists($className, $method)) { if (!method_exists($className, $method)) {
trigger_error(sprintf(__('Method %s does not exist on %s unable to complete validation.', true), $method, $className), E_USER_WARNING); trigger_error(__('Method %s does not exist on %s unable to complete validation.', $method, $className), E_USER_WARNING);
return false; return false;
} }
$check = (array)$check; $check = (array)$check;

View file

@ -127,7 +127,7 @@ class Helper extends Object {
* @param array $params Array of params for the method. * @param array $params Array of params for the method.
*/ */
public function __call($method, $params) { public function __call($method, $params) {
trigger_error(sprintf(__('Method %1$s::%2$s does not exist'), get_class($this), $method), E_USER_WARNING); trigger_error(__('Method %1$s::%2$s does not exist', get_class($this), $method), E_USER_WARNING);
} }
/** /**

View file

@ -507,7 +507,7 @@ class FormHelper extends AppHelper {
if ($text != null) { if ($text != null) {
$error = $text; $error = $text;
} elseif (is_numeric($error)) { } elseif (is_numeric($error)) {
$error = sprintf(__('Error in field %s'), Inflector::humanize($this->field())); $error = __('Error in field %s', Inflector::humanize($this->field()));
} }
if ($options['escape']) { if ($options['escape']) {
$error = h($error); $error = h($error);
@ -1142,7 +1142,7 @@ class FormHelper extends AppHelper {
public function __call($method, $params) { public function __call($method, $params) {
$options = array(); $options = array();
if (empty($params)) { if (empty($params)) {
throw new Exception(sprintf(__('Missing field name for FormHelper::%s'), $method)); throw new Exception(__('Missing field name for FormHelper::%s', $method));
} }
if (isset($params[1])) { if (isset($params[1])) {
$options = $params[1]; $options = $params[1];

View file

@ -155,7 +155,7 @@ class JsHelper extends AppHelper {
if (method_exists($this, $method . '_')) { if (method_exists($this, $method . '_')) {
return call_user_func(array(&$this, $method . '_'), $params); return call_user_func(array(&$this, $method . '_'), $params);
} }
trigger_error(sprintf(__('JsHelper:: Missing Method %s is undefined'), $method), E_USER_WARNING); trigger_error(__('JsHelper:: Missing Method %s is undefined', $method), E_USER_WARNING);
} }
/** /**

View file

@ -90,15 +90,15 @@ class NumberHelper extends AppHelper {
public function toReadableSize($size) { public function toReadableSize($size) {
switch (true) { switch (true) {
case $size < 1024: case $size < 1024:
return sprintf(__n('%d Byte', '%d Bytes', $size), $size); return __n('%d Byte', '%d Bytes', $size, $size);
case round($size / 1024) < 1024: case round($size / 1024) < 1024:
return sprintf(__('%d KB'), $this->precision($size / 1024, 0)); return __('%d KB', $this->precision($size / 1024, 0));
case round($size / 1024 / 1024, 2) < 1024: case round($size / 1024 / 1024, 2) < 1024:
return sprintf(__('%.2f MB'), $this->precision($size / 1024 / 1024, 2)); return __('%.2f MB', $this->precision($size / 1024 / 1024, 2));
case round($size / 1024 / 1024 / 1024, 2) < 1024: case round($size / 1024 / 1024 / 1024, 2) < 1024:
return sprintf(__('%.2f GB'), $this->precision($size / 1024 / 1024 / 1024, 2)); return __('%.2f GB', $this->precision($size / 1024 / 1024 / 1024, 2));
default: default:
return sprintf(__('%.2f TB'), $this->precision($size / 1024 / 1024 / 1024 / 1024, 2)); return __('%.2f TB', $this->precision($size / 1024 / 1024 / 1024 / 1024, 2));
} }
} }

View file

@ -226,9 +226,9 @@ class TimeHelper extends AppHelper {
$y = $this->isThisYear($date) ? '' : ' %Y'; $y = $this->isThisYear($date) ? '' : ' %Y';
if ($this->isToday($date)) { if ($this->isToday($date)) {
$ret = sprintf(__('Today, %s'), strftime("%H:%M", $date)); $ret = __('Today, %s', strftime("%H:%M", $date));
} elseif ($this->wasYesterday($date)) { } elseif ($this->wasYesterday($date)) {
$ret = sprintf(__('Yesterday, %s'), strftime("%H:%M", $date)); $ret = __('Yesterday, %s', strftime("%H:%M", $date));
} else { } else {
$format = $this->convertSpecifiers("%b %eS{$y}, %H:%M", $date); $format = $this->convertSpecifiers("%b %eS{$y}, %H:%M", $date);
$ret = strftime($format, $date); $ret = strftime($format, $date);
@ -574,7 +574,7 @@ class TimeHelper extends AppHelper {
$diff = $futureTime - $pastTime; $diff = $futureTime - $pastTime;
if ($diff > abs($now - $this->fromString($end))) { if ($diff > abs($now - $this->fromString($end))) {
$relativeDate = sprintf(__('on %s'), date($format, $inSeconds)); $relativeDate = __('on %s', date($format, $inSeconds));
} else { } else {
if ($years > 0) { if ($years > 0) {
// years and months and days // years and months and days
@ -608,7 +608,7 @@ class TimeHelper extends AppHelper {
} }
if (!$backwards) { if (!$backwards) {
$relativeDate = sprintf(__('%s ago'), $relativeDate); $relativeDate = __('%s ago', $relativeDate);
} }
} }
return $relativeDate; return $relativeDate;

View file

@ -408,7 +408,7 @@ class View extends Object {
$layout = $this->layout; $layout = $this->layout;
} }
if ($this->output === false) { if ($this->output === false) {
throw new RuntimeException(sprintf(__("Error in view %s, got no content."), $viewFileName)); throw new RuntimeException(__("Error in view %s, got no content.", $viewFileName));
} }
if ($layout && $this->autoLayout) { if ($layout && $this->autoLayout) {
$this->output = $this->renderLayout($this->output, $layout); $this->output = $this->renderLayout($this->output, $layout);
@ -450,7 +450,7 @@ class View extends Object {
$this->output = $this->_render($layoutFileName); $this->output = $this->_render($layoutFileName);
if ($this->output === false) { if ($this->output === false) {
throw new RuntimeException(sprintf(__("Error in layout %s, got no content."), $layoutFileName)); throw new RuntimeException(__("Error in layout %s, got no content.", $layoutFileName));
} }
$this->Helpers->trigger('afterLayout', array($layoutFileName)); $this->Helpers->trigger('afterLayout', array($layoutFileName));

View file

@ -17,14 +17,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
?> ?>
<h2><?php printf(__('Missing Method in %s'), $controller); ?></h2> <h2><?php echo __('Missing Method in %s', $controller); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('The action %1$s is not defined in controller %2$s'), '<em>' . $action . '</em>', '<em>' . $controller . '</em>'); ?> <?php echo __('The action %1$s is not defined in controller %2$s', '<em>' . $action . '</em>', '<em>' . $controller . '</em>'); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Create %1$s%2$s in file: %3$s.'), '<em>' . $controller . '::</em>', '<em>' . $action . '()</em>', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?> <?php echo __('Create %1$s%2$s in file: %3$s.', '<em>' . $controller . '::</em>', '<em>' . $action . '()</em>', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -40,6 +40,6 @@ class <?php echo $controller;?> extends AppController {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_action.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_action.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -20,11 +20,11 @@
<h2><?php echo __('Missing Behavior Class'); ?></h2> <h2><?php echo __('Missing Behavior Class'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('The behavior class <em>%s</em> can not be found or does not exist.'), $class); ?> <?php echo __('The behavior class <em>%s</em> can not be found or does not exist.', $class); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Create the class below in file: %s'), APP_DIR . DS . 'models' . DS . 'behaviors' . DS . $file); ?> <?php echo __('Create the class below in file: %s', APP_DIR . DS . 'models' . DS . 'behaviors' . DS . $file); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -35,7 +35,7 @@ class <?php echo $class;?> extends ModelBehavior {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_behavior_class.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_behavior_class.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -20,11 +20,11 @@
<h2><?php echo __('Missing Behavior File'); ?></h2> <h2><?php echo __('Missing Behavior File'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('The Behavior file %s can not be found or does not exist.'), APP_DIR . DS . 'models' . DS . 'behaviors' . DS . $file); ?> <?php echo __('The Behavior file %s can not be found or does not exist.', APP_DIR . DS . 'models' . DS . 'behaviors' . DS . $file); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Create the class below in file: %s'), APP_DIR . DS . 'models' . DS . 'behaviors' . DS . $file); ?> <?php echo __('Create the class below in file: %s', APP_DIR . DS . 'models' . DS . 'behaviors' . DS . $file); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -35,7 +35,7 @@ class <?php echo $class;?> extends ModelBehavior {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_behavior_file.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_behavior_file.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -20,11 +20,11 @@
<h2><?php echo __('Missing Component Class'); ?></h2> <h2><?php echo __('Missing Component Class'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Component class %1$s was not found.'), '<em>' . $class . '</em>'); ?> <?php echo __('Component class %1$s was not found.', '<em>' . $class . '</em>'); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Create the class %s in file: %s'), '<em>' . $class . '</em>', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?> <?php echo __('Create the class %s in file: %s', '<em>' . $class . '</em>', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -35,7 +35,7 @@ class <?php echo $class;?> extends Component {<br />
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_component_class.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_component_class.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -24,7 +24,7 @@
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Create the class %s in file: %s'), '<em>' . $class . '</em>', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?> <?php echo __('Create the class %s in file: %s', '<em>' . $class . '</em>', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -35,7 +35,7 @@ class <?php echo $class;?> extends Component {<br />
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_component_file.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_component_file.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -20,15 +20,15 @@
<h2><?php echo __('Missing Database Connection'); ?></h2> <h2><?php echo __('Missing Database Connection'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('%s requires a database connection'), $class); ?> <?php echo __('%s requires a database connection', $class); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Confirm you have created the file : %s.'), APP_DIR . DS . 'config' . DS . 'database.php'); ?> <?php echo __('Confirm you have created the file : %s.', APP_DIR . DS . 'config' . DS . 'database.php'); ?>
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s.'), APP_DIR . DS . 'views' . DS . 'errors' . DS . basename(__FILE__)); ?> <?php echo __('If you want to customize this error message, create %s.', APP_DIR . DS . 'views' . DS . 'errors' . DS . basename(__FILE__)); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -20,11 +20,11 @@
<h2><?php echo __('Missing Controller'); ?></h2> <h2><?php echo __('Missing Controller'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('%s could not be found.'), '<em>' . $controller . '</em>'); ?> <?php echo __('%s could not be found.', '<em>' . $controller . '</em>'); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Create the class %s below in file: %s'), '<em>' . $controller . '</em>', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?> <?php echo __('Create the class %s below in file: %s', '<em>' . $controller . '</em>', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -35,7 +35,7 @@ class <?php echo $controller;?> extends AppController {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_controller.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_controller.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -24,11 +24,11 @@
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Confirm you have created the file: %s'), APP_DIR . DS . 'config' . DS . 'database.php'); ?> <?php echo __('Confirm you have created the file: %s', APP_DIR . DS . 'config' . DS . 'database.php'); ?>
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_scaffolddb.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_scaffolddb.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -20,11 +20,11 @@
<h2><?php echo __('Missing Helper Class'); ?></h2> <h2><?php echo __('Missing Helper Class'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('The helper class <em>%s</em> can not be found or does not exist.'), $class); ?> <?php echo __('The helper class <em>%s</em> can not be found or does not exist.', $class); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Create the class below in file: %s'), APP_DIR . DS . 'views' . DS . 'helpers' . DS . $file); ?> <?php echo __('Create the class below in file: %s', APP_DIR . DS . 'views' . DS . 'helpers' . DS . $file); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -35,7 +35,7 @@ class <?php echo $class;?> extends AppHelper {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_helper_class.ctp'); ?> <?php __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_helper_class.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -20,11 +20,11 @@
<h2><?php echo __('Missing Helper File'); ?></h2> <h2><?php echo __('Missing Helper File'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('The helper file %s can not be found or does not exist.'), APP_DIR . DS . 'views' . DS . 'helpers' . DS . $file); ?> <?php echo __('The helper file %s can not be found or does not exist.', APP_DIR . DS . 'views' . DS . 'helpers' . DS . $file); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Create the class below in file: %s'), APP_DIR . DS . 'views' . DS . 'helpers' . DS . $file); ?> <?php echo __('Create the class below in file: %s', APP_DIR . DS . 'views' . DS . 'helpers' . DS . $file); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php
@ -35,7 +35,7 @@ class <?php echo $class;?> extends AppHelper {
</pre> </pre>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_helper_file.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_helper_file.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -20,15 +20,15 @@
<h2><?php echo __('Missing Layout'); ?></h2> <h2><?php echo __('Missing Layout'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('The layout file %s can not be found or does not exist.'), '<em>' . $file . '</em>'); ?> <?php echo __('The layout file %s can not be found or does not exist.', '<em>' . $file . '</em>'); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Confirm you have created the file: %s'), '<em>' . $file . '</em>'); ?> <?php echo __('Confirm you have created the file: %s', '<em>' . $file . '</em>'); ?>
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_layout.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_layout.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -20,11 +20,11 @@
<h2><?php echo __('Missing Database Table'); ?></h2> <h2><?php echo __('Missing Database Table'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Database table %1$s for model %2$s was not found.'), '<em>' . $table . '</em>', '<em>' . $class . '</em>'); ?> <?php echo __('Database table %1$s for model %2$s was not found.', '<em>' . $table . '</em>', '<em>' . $class . '</em>'); ?>
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_table.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_table.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -20,15 +20,15 @@
<h2><?php echo __('Missing View'); ?></h2> <h2><?php echo __('Missing View'); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('The view for %1$s%2$s was not found.'), '<em>' . Inflector::camelize($this->request->controller) . 'Controller::</em>', '<em>' . $this->request->action . '()</em>'); ?> <?php echo __('The view for %1$s%2$s was not found.', '<em>' . Inflector::camelize($this->request->controller) . 'Controller::</em>', '<em>' . $this->request->action . '()</em>'); ?>
</p> </p>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('Confirm you have created the file: %s'), $file); ?> <?php echo __('Confirm you have created the file: %s', $file); ?>
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_view.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'missing_view.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -17,14 +17,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
?> ?>
<h2><?php printf(__('Private Method in %s'), $controller); ?></h2> <h2><?php echo __('Private Method in %s', $controller); ?></h2>
<p class="error"> <p class="error">
<strong><?php echo __('Error'); ?>: </strong> <strong><?php echo __('Error'); ?>: </strong>
<?php printf(__('%s%s cannot be accessed directly.'), '<em>' . $controller . '::</em>', '<em>' . $action . '()</em>'); ?> <?php echo __('%s%s cannot be accessed directly.', '<em>' . $controller . '::</em>', '<em>' . $action . '()</em>'); ?>
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'private_action.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'private_action.ctp'); ?>
</p> </p>
<?php echo $this->element('exception_stack_trace'); ?> <?php echo $this->element('exception_stack_trace'); ?>

View file

@ -24,7 +24,7 @@
</p> </p>
<p class="notice"> <p class="notice">
<strong><?php echo __('Notice'); ?>: </strong> <strong><?php echo __('Notice'); ?>: </strong>
<?php printf(__('If you want to customize this error message, create %s'), APP_DIR . DS . 'views' . DS . 'errors' . DS . 'scaffold_error.ctp'); ?> <?php echo __('If you want to customize this error message, create %s', APP_DIR . DS . 'views' . DS . 'errors' . DS . 'scaffold_error.ctp'); ?>
</p> </p>
<pre> <pre>
&lt;?php &lt;?php

View file

@ -20,7 +20,7 @@ if (Configure::read() == 0):
$this->cakeError('error404'); $this->cakeError('error404');
endif; endif;
?> ?>
<h2><?php echo sprintf(__('Release Notes for CakePHP %s.', true), Configure::version()); ?></h2> <h2><?php echo __('Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<a href="http://cakephp.org/changelogs/1.3.6"><?php __('Read the changelog'); ?> </a> <a href="http://cakephp.org/changelogs/1.3.6"><?php __('Read the changelog'); ?> </a>
<?php <?php
if (Configure::read() > 0): if (Configure::read() > 0):
@ -45,7 +45,7 @@ endif;
$settings = Cache::settings(); $settings = Cache::settings();
if (!empty($settings)): if (!empty($settings)):
echo '<span class="notice success">'; echo '<span class="notice success">';
printf(__('The %s is being used for caching. To change the config edit APP/config/core.php '), '<em>'. $settings['engine'] . 'Engine</em>'); echo __('The %s is being used for caching. To change the config edit APP/config/core.php ', '<em>'. $settings['engine'] . 'Engine</em>');
echo '</span>'; echo '</span>';
else: else:
echo '<span class="notice">'; echo '<span class="notice">';

View file

@ -36,8 +36,8 @@
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>" . $this->Html->link(sprintf(__('List %s'), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "</li>\n";
echo "\t\t<li>" . $this->Html->link(sprintf(__('New %s'), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }

View file

@ -76,14 +76,14 @@ echo "\n";
<div class="actions"> <div class="actions">
<h3><?php echo __('Actions'); ?></h3> <h3><?php echo __('Actions'); ?></h3>
<ul> <ul>
<li><?php echo $this->Html->link(sprintf(__('New %s'), $singularHumanName), array('action' => 'add')); ?></li> <li><?php echo $this->Html->link(__('New %s', $singularHumanName), array('action' => 'add')); ?></li>
<?php <?php
$done = array(); $done = array();
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>" . $this->Html->link(sprintf(__('List %s'), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n";
echo "\t\t<li>" . $this->Html->link(sprintf(__('New %s'), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }

View file

@ -18,7 +18,7 @@
*/ */
?> ?>
<div class="<?php echo $pluralVar;?> view"> <div class="<?php echo $pluralVar;?> view">
<h2><?php printf(__('View %s'), $singularHumanName); ?></h2> <h2><?php echo __('View %s', $singularHumanName); ?></h2>
<dl> <dl>
<?php <?php
$i = 0; $i = 0;
@ -50,17 +50,17 @@ foreach ($scaffoldFields as $_field) {
<h3><?php echo __('Actions'); ?></h3> <h3><?php echo __('Actions'); ?></h3>
<ul> <ul>
<?php <?php
echo "\t\t<li>" .$this->Html->link(sprintf(__('Edit %s'), $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n"; echo "\t\t<li>" .$this->Html->link(__('Edit %s', $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n";
echo "\t\t<li>" .$this->Html->link(sprintf(__('Delete %s'), $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n"; echo "\t\t<li>" .$this->Html->link(__('Delete %s', $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n";
echo "\t\t<li>" .$this->Html->link(sprintf(__('List %s'), $pluralHumanName), array('action' => 'index')). " </li>\n"; echo "\t\t<li>" .$this->Html->link(__('List %s', $pluralHumanName), array('action' => 'index')). " </li>\n";
echo "\t\t<li>" .$this->Html->link(sprintf(__('New %s'), $singularHumanName), array('action' => 'add')). " </li>\n"; echo "\t\t<li>" .$this->Html->link(__('New %s', $singularHumanName), array('action' => 'add')). " </li>\n";
$done = array(); $done = array();
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>" . $this->Html->link(sprintf(__('List %s'), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n";
echo "\t\t<li>" . $this->Html->link(sprintf(__('New %s'), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }
@ -72,7 +72,7 @@ foreach ($scaffoldFields as $_field) {
if (!empty($associations['hasOne'])) : if (!empty($associations['hasOne'])) :
foreach ($associations['hasOne'] as $_alias => $_details): ?> foreach ($associations['hasOne'] as $_alias => $_details): ?>
<div class="related"> <div class="related">
<h3><?php printf(__("Related %s", true), Inflector::humanize($_details['controller'])); ?></h3> <h3><?php echo __("Related %s", Inflector::humanize($_details['controller'])); ?></h3>
<?php if (!empty(${$singularVar}[$_alias])):?> <?php if (!empty(${$singularVar}[$_alias])):?>
<dl> <dl>
<?php <?php
@ -91,7 +91,7 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?>
<?php endif; ?> <?php endif; ?>
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo $this->Html->link(sprintf(__('Edit %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?> <li><?php echo $this->Html->link(__('Edit %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?>
</ul> </ul>
</div> </div>
</div> </div>
@ -111,7 +111,7 @@ foreach ($relations as $_alias => $_details):
$otherSingularVar = Inflector::variable($_alias); $otherSingularVar = Inflector::variable($_alias);
?> ?>
<div class="related"> <div class="related">
<h3><?php printf(__("Related %s", true), Inflector::humanize($_details['controller'])); ?></h3> <h3><?php echo __("Related %s", Inflector::humanize($_details['controller'])); ?></h3>
<?php if (!empty(${$singularVar}[$_alias])):?> <?php if (!empty(${$singularVar}[$_alias])):?>
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr>
@ -152,7 +152,7 @@ $otherSingularVar = Inflector::variable($_alias);
<?php endif; ?> <?php endif; ?>
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo $this->Html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li> <li><?php echo $this->Html->link(__("New %s", Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li>
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -461,16 +461,23 @@ if (!function_exists('sortByKey')) {
* Returns a translated string if one is found; Otherwise, the submitted message. * Returns a translated string if one is found; Otherwise, the submitted message.
* *
* @param string $singular Text to translate * @param string $singular Text to translate
* @param boolean $return Set to true to return translated string, or false to echo * @param mixed $args Array with arguments or multiple arguments in function
* @return mixed translated string if $return is false string will be echoed * @return mixed translated string
* @link http://book.cakephp.org/view/1121/__ * @link http://book.cakephp.org/view/1121/__
*/ */
function __($singular) { function __($singular, $args = null) {
if (!$singular) { if (!$singular) {
return; return;
} }
App::uses('I18n', 'I18n'); App::uses('I18n', 'I18n');
return I18n::translate($singular); $translated = I18n::translate($singular);
if ($args === null) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 1);
}
return vsprintf($translated, $args);
} }
/** /**
@ -480,15 +487,22 @@ if (!function_exists('sortByKey')) {
* @param string $singular Singular text to translate * @param string $singular Singular text to translate
* @param string $plural Plural text * @param string $plural Plural text
* @param integer $count Count * @param integer $count Count
* @param boolean $return true to return, false to echo * @param mixed $args Array with arguments or multiple arguments in function
* @return mixed plural form of translated string if $return is false string will be echoed * @return mixed plural form of translated string
*/ */
function __n($singular, $plural, $count) { function __n($singular, $plural, $count, $args = null) {
if (!$singular) { if (!$singular) {
return; return;
} }
App::uses('I18n', 'I18n'); App::uses('I18n', 'I18n');
return I18n::translate($singular, $plural, null, 6, $count); $translated = I18n::translate($singular, $plural, null, 6, $count);
if ($args === null) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 3);
}
return vsprintf($translated, $args);
} }
/** /**
@ -496,15 +510,21 @@ if (!function_exists('sortByKey')) {
* *
* @param string $domain Domain * @param string $domain Domain
* @param string $msg String to translate * @param string $msg String to translate
* @param string $return true to return, false to echo * @param mixed $args Array with arguments or multiple arguments in function
* @return translated string if $return is false string will be echoed * @return translated string
*/ */
function __d($domain, $msg) { function __d($domain, $msg, $args = null) {
if (!$msg) { if (!$msg) {
return; return;
} }
App::uses('I18n', 'I18n'); App::uses('I18n', 'I18n');
return I18n::translate($msg, null, $domain); $translated = I18n::translate($msg, null, $domain);
if ($args === null) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 2);
}
return vsprintf($translated, $args);
} }
/** /**
@ -516,15 +536,21 @@ if (!function_exists('sortByKey')) {
* @param string $singular Singular string to translate * @param string $singular Singular string to translate
* @param string $plural Plural * @param string $plural Plural
* @param integer $count Count * @param integer $count Count
* @param boolean $return true to return, false to echo * @param mixed $args Array with arguments or multiple arguments in function
* @return plural form of translated string if $return is false string will be echoed * @return plural form of translated string
*/ */
function __dn($domain, $singular, $plural, $count) { function __dn($domain, $singular, $plural, $count, $args = null) {
if (!$singular) { if (!$singular) {
return; return;
} }
App::uses('I18n', 'I18n'); App::uses('I18n', 'I18n');
return I18n::translate($singular, $plural, $domain, 6, $count); $translated = I18n::translate($singular, $plural, $domain, 6, $count);
if ($args === null) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 4);
}
return vsprintf($translated, $args);
} }
/** /**
@ -547,15 +573,21 @@ if (!function_exists('sortByKey')) {
* @param string $domain Domain * @param string $domain Domain
* @param string $msg Message to translate * @param string $msg Message to translate
* @param integer $category Category * @param integer $category Category
* @param boolean $return true to return, false to echo * @param mixed $args Array with arguments or multiple arguments in function
* @return translated string if $return is false string will be echoed * @return translated string
*/ */
function __dc($domain, $msg, $category) { function __dc($domain, $msg, $category, $args = null) {
if (!$msg) { if (!$msg) {
return; return;
} }
App::uses('I18n', 'I18n'); App::uses('I18n', 'I18n');
return I18n::translate($msg, null, $domain, $category); $translated = I18n::translate($msg, null, $domain, $category);
if ($args === null) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 3);
}
return vsprintf($translated, $args);
} }
/** /**
@ -582,15 +614,21 @@ if (!function_exists('sortByKey')) {
* @param string $plural Plural * @param string $plural Plural
* @param integer $count Count * @param integer $count Count
* @param integer $category Category * @param integer $category Category
* @param boolean $return true to return, false to echo * @param mixed $args Array with arguments or multiple arguments in function
* @return plural form of translated string if $return is false string will be echoed * @return plural form of translated string
*/ */
function __dcn($domain, $singular, $plural, $count, $category) { function __dcn($domain, $singular, $plural, $count, $category, $args = null) {
if (!$singular) { if (!$singular) {
return; return;
} }
App::uses('I18n', 'I18n'); App::uses('I18n', 'I18n');
return I18n::translate($singular, $plural, $domain, $category, $count); $translated = I18n::translate($singular, $plural, $domain, $category, $count);
if ($args === null) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 5);
}
return vsprintf($translated, $args);
} }
/** /**
@ -609,15 +647,21 @@ if (!function_exists('sortByKey')) {
* *
* @param string $msg String to translate * @param string $msg String to translate
* @param integer $category Category * @param integer $category Category
* @param string $return true to return, false to echo * @param mixed $args Array with arguments or multiple arguments in function
* @return translated string if $return is false string will be echoed * @return translated string
*/ */
function __c($msg, $category) { function __c($msg, $category, $args = null) {
if (!$msg) { if (!$msg) {
return; return;
} }
App::uses('I18n', 'I18n'); App::uses('I18n', 'I18n');
return I18n::translate($msg, null, null, $category); $translated = I18n::translate($msg, null, null, $category);
if ($args === null) {
return $translated;
} elseif (!is_array($args)) {
$args = array_slice(func_get_args(), 2);
}
return vsprintf($translated, $args);
} }
/** /**