mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-05 11:02:40 +00:00
Merge branch '2.0' of github.com:cakephp/cakephp into 2.0
This commit is contained in:
commit
54429837b4
44 changed files with 434 additions and 456 deletions
|
@ -286,7 +286,7 @@
|
|||
|
||||
/**
|
||||
* Pick the caching engine to use. If APC is enabled use it.
|
||||
* If running via cli - apc is disabled by default. ensure it's avaiable and enabled in this case
|
||||
* If running via cli - apc is disabled by default. ensure it's available and enabled in this case
|
||||
*
|
||||
*/
|
||||
$engine = 'File';
|
||||
|
|
|
@ -71,10 +71,8 @@ class AclShell extends Shell {
|
|||
|
||||
if (!in_array(Configure::read('Acl.classname'), array('DbAcl', 'DB_ACL'))) {
|
||||
$out = "--------------------------------------------------\n";
|
||||
$out .= __d('cake_console', 'Error: Your current Cake configuration is set to') . "\n";
|
||||
$out .= __d('cake_console', 'an ACL implementation other than DB. Please change') . "\n";
|
||||
$out .= __d('cake_console', 'your core config to reflect your decision to use') . "\n";
|
||||
$out .= __d('cake_console', 'DbAcl before attempting to use this script') . ".\n";
|
||||
$out .= __d('cake_console', 'Error: Your current Cake configuration is set to an ACL implementation other than DB.') . "\n";
|
||||
$out .= __d('cake_console', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n";
|
||||
$out .= "--------------------------------------------------\n";
|
||||
$out .= __d('cake_console', 'Current ACL Classname: %s', Configure::read('Acl.classname')) . "\n";
|
||||
$out .= "--------------------------------------------------\n";
|
||||
|
@ -150,7 +148,7 @@ class AclShell extends Shell {
|
|||
$nodeId = $this->_getNodeId($class, $identifier);
|
||||
|
||||
if (!$this->Acl->{$class}->delete($nodeId)) {
|
||||
$this->error(__d('cake_console', 'Node Not Deleted') . __d('cake_console', 'There was an error deleting the %s. Check that the node exists', $class) . ".\n");
|
||||
$this->error(__d('cake_console', 'Node Not Deleted') . __d('cake_console', 'There was an error deleting the %s. Check that the node exists.', $class) . "\n");
|
||||
}
|
||||
$this->out(__d('cake_console', '<success>%s deleted.</success>', $class), 2);
|
||||
}
|
||||
|
@ -263,7 +261,7 @@ class AclShell extends Shell {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set an ARO to inhermit permission to an ACO.
|
||||
* Set an ARO to inherit permission to an ACO.
|
||||
*
|
||||
*/
|
||||
public function inherit() {
|
||||
|
@ -308,7 +306,7 @@ class AclShell extends Shell {
|
|||
$this->error(__d('cake_console', '%s not found', $this->args[0]), __d('cake_console', 'No tree returned.'));
|
||||
}
|
||||
}
|
||||
$this->out($class . " tree:");
|
||||
$this->out($class . ' tree:');
|
||||
$this->hr();
|
||||
|
||||
$stack = array();
|
||||
|
@ -357,7 +355,7 @@ class AclShell extends Shell {
|
|||
'help' => __d('cake_console', 'Type of node to create.')
|
||||
);
|
||||
|
||||
$parser->description('A console tool for managing the DbAcl')
|
||||
$parser->description(__d('cake_console', 'A console tool for managing the DbAcl'))
|
||||
->addSubcommand('create', array(
|
||||
'help' => __d('cake_console', 'Create a new ACL node'),
|
||||
'parser' => array(
|
||||
|
@ -407,8 +405,7 @@ class AclShell extends Shell {
|
|||
'parser' => array(
|
||||
'description' => array(
|
||||
__d('cake_console', "Returns the path to the ACL object specified by <node>."),
|
||||
__d('cake_console', "This command is useful in determining the inhertiance of permissions"),
|
||||
__d('cake_console', "for a certain object in the tree.")
|
||||
__d('cake_console', "This command is useful in determining the inheritance of permissions for a certain object in the tree.")
|
||||
),
|
||||
'arguments' => array(
|
||||
'type' => $type,
|
||||
|
@ -422,9 +419,7 @@ class AclShell extends Shell {
|
|||
'help' => __d('cake_console', 'Check the permissions between an ACO and ARO.'),
|
||||
'parser' => array(
|
||||
'description' => array(
|
||||
__d('cake_console', "Use this command to grant ACL permissions. Once executed, the ARO "),
|
||||
__d('cake_console', "specified (and its children, if any) will have ALLOW access to the"),
|
||||
__d('cake_console', "specified ACO action (and the ACO's children, if any).")
|
||||
__d('cake_console', 'Use this command to grant ACL permissions. Once executed, the ARO specified (and its children, if any) will have ALLOW access to the specified ACO action (and the ACO\'s children, if any).')
|
||||
),
|
||||
'arguments' => array(
|
||||
'aro' => array('help' => __d('cake_console', 'ARO to check.'), 'required' => true),
|
||||
|
@ -436,9 +431,7 @@ class AclShell extends Shell {
|
|||
'help' => __d('cake_console', 'Grant an ARO permissions to an ACO.'),
|
||||
'parser' => array(
|
||||
'description' => array(
|
||||
__d('cake_console', "Use this command to grant ACL permissions. Once executed, the ARO"),
|
||||
__d('cake_console', "specified (and its children, if any) will have ALLOW access to the"),
|
||||
__d('cake_console', "specified ACO action (and the ACO's children, if any).")
|
||||
__d('cake_console', 'Use this command to grant ACL permissions. Once executed, the ARO specified (and its children, if any) will have ALLOW access to the specified ACO action (and the ACO\'s children, if any).')
|
||||
),
|
||||
'arguments' => array(
|
||||
'aro' => array('help' => __d('cake_console', 'ARO to grant permission to.'), 'required' => true),
|
||||
|
@ -450,9 +443,7 @@ class AclShell extends Shell {
|
|||
'help' => __d('cake_console', 'Deny an ARO permissions to an ACO.'),
|
||||
'parser' => array(
|
||||
'description' => array(
|
||||
__d('cake_console', "Use this command to deny ACL permissions. Once executed, the ARO"),
|
||||
__d('cake_console', "specified (and its children, if any) will have DENY access to the"),
|
||||
__d('cake_console', "specified ACO action (and the ACO's children, if any).")
|
||||
__d('cake_console', 'Use this command to deny ACL permissions. Once executed, the ARO specified (and its children, if any) will have DENY access to the specified ACO action (and the ACO\'s children, if any).')
|
||||
),
|
||||
'arguments' => array(
|
||||
'aro' => array('help' => __d('cake_console', 'ARO to deny.'), 'required' => true),
|
||||
|
@ -464,11 +455,10 @@ class AclShell extends Shell {
|
|||
'help' => __d('cake_console', 'Inherit an ARO\'s parent permissions.'),
|
||||
'parser' => array(
|
||||
'description' => array(
|
||||
__d('cake_console', "Use this command to force a child ARO object to inherit its"),
|
||||
__d('cake_console', "permissions settings from its parent.")
|
||||
__d('cake_console', "Use this command to force a child ARO object to inherit its permissions settings from its parent.")
|
||||
),
|
||||
'arguments' => array(
|
||||
'aro' => array('help' => __d('cake_console', 'ARO to have permisssions inherit.'), 'required' => true),
|
||||
'aro' => array('help' => __d('cake_console', 'ARO to have permissions inherit.'), 'required' => true),
|
||||
'aco' => array('help' => __d('cake_console', 'ACO to inherit permissions on.'), 'required' => true),
|
||||
'action' => array('help' => __d('cake_console', 'Action to inherit'), 'default' => 'all')
|
||||
)
|
||||
|
@ -526,7 +516,7 @@ class AclShell extends Shell {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parse an identifier into Model.foriegnKey or an alias.
|
||||
* Parse an identifier into Model.foreignKey or an alias.
|
||||
* Takes an identifier determines its type and returns the result as used by other methods.
|
||||
*
|
||||
* @param string $identifier Identifier to parse
|
||||
|
|
|
@ -36,7 +36,7 @@ class ApiShell extends Shell {
|
|||
public $paths = array();
|
||||
|
||||
/**
|
||||
* Override intialize of the Shell
|
||||
* Override initialize of the Shell
|
||||
*
|
||||
*/
|
||||
public function initialize() {
|
||||
|
@ -140,9 +140,9 @@ class ApiShell extends Shell {
|
|||
public function getOptionParser() {
|
||||
$parser = parent::getOptionParser();
|
||||
$parser->addArgument('type', array(
|
||||
'help' => 'Either a full path or type of class (model, behavior, controller, component, view, helper)'
|
||||
'help' => __d('cake_console', 'Either a full path or type of class (model, behavior, controller, component, view, helper)')
|
||||
))->addArgument('className', array(
|
||||
'help' => 'A CakePHP core class name (e.g: Component, HtmlHelper).'
|
||||
'help' => __d('cake_console', 'A CakePHP core class name (e.g: Component, HtmlHelper).')
|
||||
))->addOption('method', array(
|
||||
'short' => 'm',
|
||||
'help' => __d('cake_console', 'The specific method you want help on.')
|
||||
|
@ -181,7 +181,7 @@ class ApiShell extends Shell {
|
|||
} elseif (isset($commands[strtolower($this->args[1])])) {
|
||||
$this->out($commands[strtolower($this->args[1])] . "\n\n");
|
||||
} else {
|
||||
$this->out("Command '" . $this->args[1] . "' not found");
|
||||
$this->out(__d('cake_console', 'Command %s not found', $this->args[1]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,16 +79,16 @@ class BakeShell extends Shell {
|
|||
$this->args = null;
|
||||
return $this->DbConfig->execute();
|
||||
}
|
||||
$this->out('Interactive Bake Shell');
|
||||
$this->out(__d('cake_console', 'Interactive Bake Shell'));
|
||||
$this->hr();
|
||||
$this->out('[D]atabase Configuration');
|
||||
$this->out('[M]odel');
|
||||
$this->out('[V]iew');
|
||||
$this->out('[C]ontroller');
|
||||
$this->out('[P]roject');
|
||||
$this->out('[F]ixture');
|
||||
$this->out('[T]est case');
|
||||
$this->out('[Q]uit');
|
||||
$this->out(__d('cake_console', '[D]atabase Configuration'));
|
||||
$this->out(__d('cake_console', '[M]odel'));
|
||||
$this->out(__d('cake_console', '[V]iew'));
|
||||
$this->out(__d('cake_console', '[C]ontroller'));
|
||||
$this->out(__d('cake_console', '[P]roject'));
|
||||
$this->out(__d('cake_console', '[F]ixture'));
|
||||
$this->out(__d('cake_console', '[T]est case'));
|
||||
$this->out(__d('cake_console', '[Q]uit'));
|
||||
|
||||
$classToBake = strtoupper($this->in(__d('cake_console', 'What would you like to Bake?'), array('D', 'M', 'V', 'C', 'P', 'F', 'T', 'Q')));
|
||||
switch ($classToBake) {
|
||||
|
@ -199,12 +199,11 @@ class BakeShell extends Shell {
|
|||
*/
|
||||
public function getOptionParser() {
|
||||
$parser = parent::getOptionParser();
|
||||
return $parser->description(
|
||||
'The Bake script generates controllers, views and models for your application.' .
|
||||
'If run with no command line arguments, Bake guides the user through the class' .
|
||||
'creation process. You can customize the generation process by telling Bake' .
|
||||
'where different parts of your application are using command line arguments.'
|
||||
)->addSubcommand('all', array(
|
||||
return $parser->description(__d('cake_console',
|
||||
'The Bake script generates controllers, views and models for your application.'
|
||||
. ' If run with no command line arguments, Bake guides the user through the class creation process.'
|
||||
. ' You can customize the generation process by telling Bake where different parts of your application are using command line arguments.'
|
||||
))->addSubcommand('all', array(
|
||||
'help' => __d('cake_console', 'Bake a complete MVC. optional <name> of a Model'),
|
||||
))->addSubcommand('project', array(
|
||||
'help' => __d('cake_console', 'Bake a new app folder in the path supplied or in current directory if no path is specified'),
|
||||
|
@ -231,7 +230,7 @@ class BakeShell extends Shell {
|
|||
'help' => __d('cake_console', 'Bake a unit test.'),
|
||||
'parser' => $this->Test->getOptionParser()
|
||||
))->addOption('connection', array(
|
||||
'help' => __d('cake_console', 'Database connection to use in conjunction with `bake all`.'),
|
||||
'help' => __d('cake_console', 'Database connection to use in conjunction with `bake all`.'),
|
||||
'short' => 'c',
|
||||
'default' => 'default'
|
||||
));
|
||||
|
|
|
@ -43,18 +43,17 @@ class CommandListShell extends Shell {
|
|||
*/
|
||||
public function main() {
|
||||
if (empty($this->params['xml'])) {
|
||||
$this->out("<info>Current Paths:</info>", 2);
|
||||
$this->out(__d('cake_console', "<info>Current Paths:</info>"), 2);
|
||||
$this->out(" -app: ". APP_DIR);
|
||||
$this->out(" -working: " . rtrim(APP_PATH, DS));
|
||||
$this->out(" -root: " . rtrim(ROOT, DS));
|
||||
$this->out(" -core: " . rtrim(CORE_PATH, DS));
|
||||
$this->out("");
|
||||
$this->out("<info>Changing Paths:</info>", 2);
|
||||
$this->out("Your working path should be the same as your application path");
|
||||
$this->out("to change your path use the '-app' param.");
|
||||
$this->out("Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp", 2);
|
||||
$this->out(__d('cake_console', "<info>Changing Paths:</info>"), 2);
|
||||
$this->out(__d('cake_console', "Your working path should be the same as your application path to change your path use the '-app' param."));
|
||||
$this->out(__d('cake_console', "Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp"), 2);
|
||||
|
||||
$this->out("<info>Available Shells:</info>", 2);
|
||||
$this->out(__d('cake_console', "<info>Available Shells:</info>"), 2);
|
||||
}
|
||||
|
||||
$shellList = $this->_getShellList();
|
||||
|
@ -140,8 +139,8 @@ class CommandListShell extends Shell {
|
|||
$this->out(" " . $row);
|
||||
}
|
||||
$this->out();
|
||||
$this->out("To run a command, type <info>cake shell_name [args]</info>");
|
||||
$this->out("To get help on a specific command, type <info>cake shell_name --help</info>", 2);
|
||||
$this->out(__d('cake_console', "To run a command, type <info>cake shell_name [args]</info>"));
|
||||
$this->out(__d('cake_console', "To get help on a specific command, type <info>cake shell_name --help</info>"), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,7 +211,7 @@ class CommandListShell extends Shell {
|
|||
*/
|
||||
public function getOptionParser() {
|
||||
$parser = parent::getOptionParser();
|
||||
return $parser->description('Get the list of available shells for this CakePHP application.')
|
||||
return $parser->description(__d('cake_console', 'Get the list of available shells for this CakePHP application.'))
|
||||
->addOption('xml', array(
|
||||
'help' => __d('cake_console', 'Get the listing as XML.'),
|
||||
'boolean' => true
|
||||
|
|
|
@ -47,7 +47,7 @@ class ConsoleShell extends Shell {
|
|||
public $models = array();
|
||||
|
||||
/**
|
||||
* Override intialize of the Shell
|
||||
* Override initialize of the Shell
|
||||
*
|
||||
*/
|
||||
public function initialize() {
|
||||
|
@ -61,8 +61,8 @@ class ConsoleShell extends Shell {
|
|||
App::uses($class, 'Model');
|
||||
$this->{$class} = new $class();
|
||||
}
|
||||
$this->out('Model classes:');
|
||||
$this->out('--------------');
|
||||
$this->out(__d('cake_console', 'Model classes:'));
|
||||
$this->hr();
|
||||
|
||||
foreach ($this->models as $model) {
|
||||
$this->out(" - {$model}");
|
||||
|
@ -151,7 +151,7 @@ class ConsoleShell extends Shell {
|
|||
return true;
|
||||
break;
|
||||
case 'models':
|
||||
$this->out('Model classes:');
|
||||
$this->out(__d('cake_console', 'Model classes:'));
|
||||
$this->hr();
|
||||
foreach ($this->models as $model) {
|
||||
$this->out(" - {$model}");
|
||||
|
@ -169,9 +169,10 @@ class ConsoleShell extends Shell {
|
|||
|
||||
if ($this->_isValidModel($modelA) && $this->_isValidModel($modelB) && in_array($association, $this->associations)) {
|
||||
$this->{$modelA}->bindModel(array($association => array($modelB => array('className' => $modelB))), false);
|
||||
$this->out("Created $association association between $modelA and $modelB");
|
||||
$this->out(__d('cake_console', "Created %s association between %s and %s",
|
||||
$association, $modelA, $modelB));
|
||||
} else {
|
||||
$this->out("Please verify you are using valid models and association types");
|
||||
$this->out(__d('cake_console', "Please verify you are using valid models and association types"));
|
||||
}
|
||||
break;
|
||||
case (preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp) == true):
|
||||
|
@ -196,9 +197,10 @@ class ConsoleShell extends Shell {
|
|||
|
||||
if ($this->_isValidModel($modelA) && $this->_isValidModel($modelB) && in_array($association, $this->associations) && $validCurrentAssociation) {
|
||||
$this->{$modelA}->unbindModel(array($association => array($modelB)));
|
||||
$this->out("Removed $association association between $modelA and $modelB");
|
||||
$this->out(__d('cake_console', "Removed %s association between %s and %s",
|
||||
$association, $modelA, $modelB));
|
||||
} else {
|
||||
$this->out("Please verify you are using valid models, valid current association, and valid association types");
|
||||
$this->out(__d('cake_console', "Please verify you are using valid models, valid current association, and valid association types"));
|
||||
}
|
||||
break;
|
||||
case (strpos($command, "->find") > 0):
|
||||
|
@ -248,10 +250,11 @@ class ConsoleShell extends Shell {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
$this->out("\nNo result set found");
|
||||
$this->out();
|
||||
$this->out(__d('cake_console', "No result set found"));
|
||||
}
|
||||
} else {
|
||||
$this->out("$modelToCheck is not a valid model");
|
||||
$this->out(__d('cake_console', "%s is not a valid model", $modelToCheck));
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -267,7 +270,7 @@ class ConsoleShell extends Shell {
|
|||
$data = preg_replace('/^\(*(array)?\(*(.+?)\)*$/i', '\\2', $data);
|
||||
$saveCommand = "\$this->{$modelToSave}->save(array('{$modelToSave}' => array({$data})));";
|
||||
@eval($saveCommand);
|
||||
$this->out('Saved record for ' . $modelToSave);
|
||||
$this->out(__d('cake_console', 'Saved record for %s', $modelToSave));
|
||||
}
|
||||
break;
|
||||
case (preg_match("/^(\w+) columns/", $command, $tmp) == true):
|
||||
|
@ -284,17 +287,16 @@ class ConsoleShell extends Shell {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
$this->out("Please verify that you selected a valid model");
|
||||
$this->out(__d('cake_console', "Please verify that you selected a valid model"));
|
||||
}
|
||||
break;
|
||||
case (preg_match("/^routes\s+reload/i", $command, $tmp) == true):
|
||||
$router = Router::getInstance();
|
||||
if (!$this->_loadRoutes()) {
|
||||
$this->out("There was an error loading the routes config. Please check that the file");
|
||||
$this->out("exists and is free of parse errors.");
|
||||
$this->out(__d('cake_console', "There was an error loading the routes config. Please check that the file exists and is free of parse errors."));
|
||||
break;
|
||||
}
|
||||
$this->out("Routes configuration reloaded, " . count($router->routes) . " routes connected");
|
||||
$this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count($router->routes)));
|
||||
break;
|
||||
case (preg_match("/^routes\s+show/i", $command, $tmp) == true):
|
||||
$router = Router::getInstance();
|
||||
|
@ -309,7 +311,8 @@ class ConsoleShell extends Shell {
|
|||
$this->out(var_export(Router::parse($tmp[1]), true));
|
||||
break;
|
||||
default:
|
||||
$this->out("Invalid command\n");
|
||||
$this->out(__d('cake_console', "Invalid command"));
|
||||
$this->out();
|
||||
break;
|
||||
}
|
||||
$command = '';
|
||||
|
|
|
@ -137,7 +137,8 @@ class SchemaShell extends Shell {
|
|||
|
||||
if (!$snapshot && file_exists($this->Schema->path . DS . $this->params['file'])) {
|
||||
$snapshot = true;
|
||||
$result = strtolower($this->in("Schema file exists.\n [O]verwrite\n [S]napshot\n [Q]uit\nWould you like to do?", array('o', 's', 'q'), 's'));
|
||||
$prompt = __d('cake_console', "Schema file exists.\n [O]verwrite\n [S]napshot\n [Q]uit\nWould you like to do?");
|
||||
$result = strtolower($this->in($prompt, array('o', 's', 'q'), 's'));
|
||||
if ($result === 'q') {
|
||||
return $this->_stop();
|
||||
}
|
||||
|
@ -453,7 +454,7 @@ class SchemaShell extends Shell {
|
|||
'help' => __d('cake_console', 'Snapshot number to use/make.')
|
||||
);
|
||||
$dry = array(
|
||||
'help' => 'Perform a dry run on create and update commands. Queries will be output instead of run.',
|
||||
'help' => __d('cake_console', 'Perform a dry run on create and update commands. Queries will be output instead of run.'),
|
||||
'boolean' => true
|
||||
);
|
||||
$force = array(
|
||||
|
@ -467,10 +468,9 @@ class SchemaShell extends Shell {
|
|||
|
||||
$parser = parent::getOptionParser();
|
||||
$parser->description(
|
||||
'The Schema Shell generates a schema object from' .
|
||||
'the database and updates the database from the schema.'
|
||||
__d('cake_console', 'The Schema Shell generates a schema object from the database and updates the database from the schema.')
|
||||
)->addSubcommand('view', array(
|
||||
'help' => 'read and output the contents of a schema file',
|
||||
'help' => __d('cake_console', 'Read and output the contents of a schema file'),
|
||||
'parser' => array(
|
||||
'options' => compact('plugin', 'path', 'file', 'name', 'connection'),
|
||||
'arguments' => compact('name')
|
||||
|
|
|
@ -305,7 +305,7 @@ class ControllerTask extends BakeTask {
|
|||
* @return string Baked controller
|
||||
*/
|
||||
public function bake($controllerName, $actions = '', $helpers = null, $components = null) {
|
||||
$this->out("\nBaking controller class for $controllerName...", 1, Shell::QUIET);
|
||||
$this->out("\n" . __d('cake_console', 'Baking controller class for %s...', $controllerName), 1, Shell::QUIET);
|
||||
|
||||
$isScaffold = ($actions === 'scaffold') ? true : false;
|
||||
|
||||
|
|
|
@ -94,19 +94,19 @@ class DbConfigTask extends Shell {
|
|||
$name = '';
|
||||
|
||||
while ($name == '') {
|
||||
$name = $this->in("Name:", null, 'default');
|
||||
$name = $this->in(__d('cake_console', "Name:"), null, 'default');
|
||||
if (preg_match('/[^a-z0-9_]/i', $name)) {
|
||||
$name = '';
|
||||
$this->out('The name may only contain unaccented latin characters, numbers or underscores');
|
||||
$this->out(__d('cake_console', 'The name may only contain unaccented latin characters, numbers or underscores'));
|
||||
} else if (preg_match('/^[^a-z_]/i', $name)) {
|
||||
$name = '';
|
||||
$this->out('The name must start with an unaccented latin character or an underscore');
|
||||
$this->out(__d('cake_console', 'The name must start with an unaccented latin character or an underscore'));
|
||||
}
|
||||
}
|
||||
|
||||
$driver = $this->in('Driver:', array('mssql', 'mysql', 'oracle', 'postgres', 'sqlite'), 'mysql');
|
||||
$driver = $this->in(__d('cake_console', 'Driver:'), array('mssql', 'mysql', 'oracle', 'postgres', 'sqlite'), 'mysql');
|
||||
|
||||
$persistent = $this->in('Persistent Connection?', array('y', 'n'), 'n');
|
||||
$persistent = $this->in(__d('cake_console', 'Persistent Connection?'), array('y', 'n'), 'n');
|
||||
if (strtolower($persistent) == 'n') {
|
||||
$persistent = 'false';
|
||||
} else {
|
||||
|
@ -115,12 +115,12 @@ class DbConfigTask extends Shell {
|
|||
|
||||
$host = '';
|
||||
while ($host == '') {
|
||||
$host = $this->in('Database Host:', null, 'localhost');
|
||||
$host = $this->in(__d('cake_console', 'Database Host:'), null, 'localhost');
|
||||
}
|
||||
|
||||
$port = '';
|
||||
while ($port == '') {
|
||||
$port = $this->in('Port?', null, 'n');
|
||||
$port = $this->in(__d('cake_console', 'Port?'), null, 'n');
|
||||
}
|
||||
|
||||
if (strtolower($port) == 'n') {
|
||||
|
@ -129,16 +129,16 @@ class DbConfigTask extends Shell {
|
|||
|
||||
$login = '';
|
||||
while ($login == '') {
|
||||
$login = $this->in('User:', null, 'root');
|
||||
$login = $this->in(__d('cake_console', 'User:'), null, 'root');
|
||||
}
|
||||
$password = '';
|
||||
$blankPassword = false;
|
||||
|
||||
while ($password == '' && $blankPassword == false) {
|
||||
$password = $this->in('Password:');
|
||||
$password = $this->in(__d('cake_console', 'Password:'));
|
||||
|
||||
if ($password == '') {
|
||||
$blank = $this->in('The password you supplied was empty. Use an empty password?', array('y', 'n'), 'n');
|
||||
$blank = $this->in(__d('cake_console', 'The password you supplied was empty. Use an empty password?'), array('y', 'n'), 'n');
|
||||
if ($blank == 'y') {
|
||||
$blankPassword = true;
|
||||
}
|
||||
|
@ -147,12 +147,12 @@ class DbConfigTask extends Shell {
|
|||
|
||||
$database = '';
|
||||
while ($database == '') {
|
||||
$database = $this->in('Database Name:', null, 'cake');
|
||||
$database = $this->in(__d('cake_console', 'Database Name:'), null, 'cake');
|
||||
}
|
||||
|
||||
$prefix = '';
|
||||
while ($prefix == '') {
|
||||
$prefix = $this->in('Table Prefix?', null, 'n');
|
||||
$prefix = $this->in(__d('cake_console', 'Table Prefix?'), null, 'n');
|
||||
}
|
||||
if (strtolower($prefix) == 'n') {
|
||||
$prefix = null;
|
||||
|
@ -160,7 +160,7 @@ class DbConfigTask extends Shell {
|
|||
|
||||
$encoding = '';
|
||||
while ($encoding == '') {
|
||||
$encoding = $this->in('Table encoding?', null, 'n');
|
||||
$encoding = $this->in(__d('cake_console', 'Table encoding?'), null, 'n');
|
||||
}
|
||||
if (strtolower($encoding) == 'n') {
|
||||
$encoding = null;
|
||||
|
@ -169,7 +169,7 @@ class DbConfigTask extends Shell {
|
|||
$schema = '';
|
||||
if ($driver == 'postgres') {
|
||||
while ($schema == '') {
|
||||
$schema = $this->in('Table schema?', null, 'n');
|
||||
$schema = $this->in(__d('cake_console', 'Table schema?'), null, 'n');
|
||||
}
|
||||
}
|
||||
if (strtolower($schema) == 'n') {
|
||||
|
@ -183,7 +183,7 @@ class DbConfigTask extends Shell {
|
|||
}
|
||||
|
||||
$dbConfigs[] = $config;
|
||||
$doneYet = $this->in('Do you wish to add another database configuration?', null, 'n');
|
||||
$doneYet = $this->in(__d('cake_console', 'Do you wish to add another database configuration?'), null, 'n');
|
||||
|
||||
if (strtolower($doneYet == 'n')) {
|
||||
$done = true;
|
||||
|
@ -205,35 +205,35 @@ class DbConfigTask extends Shell {
|
|||
extract($config);
|
||||
$this->out();
|
||||
$this->hr();
|
||||
$this->out('The following database configuration will be created:');
|
||||
$this->out(__d('cake_console', 'The following database configuration will be created:'));
|
||||
$this->hr();
|
||||
$this->out("Name: $name");
|
||||
$this->out("Driver: $driver");
|
||||
$this->out("Persistent: $persistent");
|
||||
$this->out("Host: $host");
|
||||
$this->out(__d('cake_console', "Name: %s", $name));
|
||||
$this->out(__d('cake_console', "Driver: %s", $driver));
|
||||
$this->out(__d('cake_console', "Persistent: %s", $persistent));
|
||||
$this->out(__d('cake_console', "Host: %s", $host));
|
||||
|
||||
if ($port) {
|
||||
$this->out("Port: $port");
|
||||
$this->out(__d('cake_console', "Port: %s", $port));
|
||||
}
|
||||
|
||||
$this->out("User: $login");
|
||||
$this->out("Pass: " . str_repeat('*', strlen($password)));
|
||||
$this->out("Database: $database");
|
||||
$this->out(__d('cake_console', "User: %s", $login));
|
||||
$this->out(__d('cake_console', "Pass: %s", str_repeat('*', strlen($password))));
|
||||
$this->out(__d('cake_console', "Database: %s", $database));
|
||||
|
||||
if ($prefix) {
|
||||
$this->out("Table prefix: $prefix");
|
||||
$this->out(__d('cake_console', "Table prefix: %s", $prefix));
|
||||
}
|
||||
|
||||
if ($schema) {
|
||||
$this->out("Schema: $schema");
|
||||
$this->out(__d('cake_console', "Schema: %s", $schema));
|
||||
}
|
||||
|
||||
if ($encoding) {
|
||||
$this->out("Encoding: $encoding");
|
||||
$this->out(__d('cake_console', "Encoding: %s", $encoding));
|
||||
}
|
||||
|
||||
$this->hr();
|
||||
$looksGood = $this->in('Look okay?', array('y', 'n'), 'y');
|
||||
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y');
|
||||
|
||||
if (strtolower($looksGood) == 'y') {
|
||||
return $config;
|
||||
|
@ -249,7 +249,7 @@ class DbConfigTask extends Shell {
|
|||
*/
|
||||
public function bake($configs) {
|
||||
if (!is_dir($this->path)) {
|
||||
$this->err($this->path . ' not found');
|
||||
$this->err(__d('cake_console', '%s not found', $this->path));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,65 +30,65 @@ class ExtractTask extends Shell {
|
|||
* Paths to use when looking for strings
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
private $__paths = array();
|
||||
protected $_paths = array();
|
||||
|
||||
/**
|
||||
* Files from where to extract
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
private $__files = array();
|
||||
protected $_files = array();
|
||||
|
||||
/**
|
||||
* Merge all domains string into the default.pot file
|
||||
*
|
||||
* @var boolean
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
private $__merge = false;
|
||||
protected $_merge = false;
|
||||
|
||||
/**
|
||||
* Current file being processed
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
private $__file = null;
|
||||
protected $_file = null;
|
||||
|
||||
/**
|
||||
* Contains all content waiting to be write
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
private $__storage = array();
|
||||
protected $_storage = array();
|
||||
|
||||
/**
|
||||
* Extracted tokens
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
private $__tokens = array();
|
||||
protected $_tokens = array();
|
||||
|
||||
/**
|
||||
* Extracted strings
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
private $__strings = array();
|
||||
protected $_strings = array();
|
||||
|
||||
/**
|
||||
* Destination path
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
private $__output = null;
|
||||
protected $_output = null;
|
||||
|
||||
/**
|
||||
* An array of directories to exclude.
|
||||
|
@ -101,17 +101,17 @@ class ExtractTask extends Shell {
|
|||
* Execution method always used for tasks
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
* @access public
|
||||
*/
|
||||
function execute() {
|
||||
public function execute() {
|
||||
if (!empty($this->params['exclude'])) {
|
||||
$this->_exclude = explode(',', $this->params['exclude']);
|
||||
}
|
||||
if (isset($this->params['files']) && !is_array($this->params['files'])) {
|
||||
$this->__files = explode(',', $this->params['files']);
|
||||
$this->_files = explode(',', $this->params['files']);
|
||||
}
|
||||
if (isset($this->params['paths'])) {
|
||||
$this->__paths = explode(',', $this->params['paths']);
|
||||
$this->_paths = explode(',', $this->params['paths']);
|
||||
} else {
|
||||
$defaultPath = APP_PATH;
|
||||
$message = __d('cake_console', "What is the path you would like to extract?\n[Q]uit [D]one");
|
||||
|
@ -124,7 +124,7 @@ class ExtractTask extends Shell {
|
|||
$this->out();
|
||||
break;
|
||||
} elseif (is_dir($response)) {
|
||||
$this->__paths[] = $response;
|
||||
$this->_paths[] = $response;
|
||||
$defaultPath = 'D';
|
||||
} else {
|
||||
$this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.'));
|
||||
|
@ -134,16 +134,16 @@ class ExtractTask extends Shell {
|
|||
}
|
||||
|
||||
if (isset($this->params['output'])) {
|
||||
$this->__output = $this->params['output'];
|
||||
$this->_output = $this->params['output'];
|
||||
} else {
|
||||
$message = __d('cake_console', "What is the path you would like to output?\n[Q]uit", $this->__paths[0] . DS . 'locale');
|
||||
$message = __d('cake_console', "What is the path you would like to output?\n[Q]uit", $this->_paths[0] . DS . 'locale');
|
||||
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') {
|
||||
$this->out(__d('cake_console', 'Extract Aborted'));
|
||||
$this->_stop();
|
||||
} elseif (is_dir($response)) {
|
||||
$this->__output = $response . DS;
|
||||
$this->_output = $response . DS;
|
||||
break;
|
||||
} else {
|
||||
$this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.'));
|
||||
|
@ -153,41 +153,41 @@ class ExtractTask extends Shell {
|
|||
}
|
||||
|
||||
if (isset($this->params['merge'])) {
|
||||
$this->__merge = !(strtolower($this->params['merge']) === 'no');
|
||||
$this->_merge = !(strtolower($this->params['merge']) === 'no');
|
||||
} else {
|
||||
$this->out();
|
||||
$response = $this->in(__d('cake_console', 'Would you like to merge all domains strings into the default.pot file?'), array('y', 'n'), 'n');
|
||||
$this->__merge = strtolower($response) === 'y';
|
||||
$this->_merge = strtolower($response) === 'y';
|
||||
}
|
||||
|
||||
if (empty($this->__files)) {
|
||||
$this->__searchFiles();
|
||||
if (empty($this->_files)) {
|
||||
$this->_searchFiles();
|
||||
}
|
||||
$this->__extract();
|
||||
$this->_extract();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract text
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __extract() {
|
||||
protected function _extract() {
|
||||
$this->out();
|
||||
$this->out();
|
||||
$this->out(__d('cake_console', 'Extracting...'));
|
||||
$this->hr();
|
||||
$this->out(__d('cake_console', 'Paths:'));
|
||||
foreach ($this->__paths as $path) {
|
||||
foreach ($this->_paths as $path) {
|
||||
$this->out(' ' . $path);
|
||||
}
|
||||
$this->out(__d('cake_console', 'Output Directory: ') . $this->__output);
|
||||
$this->out(__d('cake_console', 'Output Directory: ') . $this->_output);
|
||||
$this->hr();
|
||||
$this->__extractTokens();
|
||||
$this->__buildFiles();
|
||||
$this->__writeFiles();
|
||||
$this->__paths = $this->__files = $this->__storage = array();
|
||||
$this->__strings = $this->__tokens = array();
|
||||
$this->_extractTokens();
|
||||
$this->_buildFiles();
|
||||
$this->_writeFiles();
|
||||
$this->_paths = $this->_files = $this->_storage = array();
|
||||
$this->_strings = $this->_tokens = array();
|
||||
$this->out();
|
||||
$this->out(__d('cake_console', 'Done.'));
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ class ExtractTask extends Shell {
|
|||
$parser = parent::getOptionParser();
|
||||
return $parser->description(__d('cake_console', 'CakePHP Language String Extraction:'))
|
||||
->addOption('app', array('help' => __d('cake_console', 'Directory where your application is located.')))
|
||||
->addOption('paths', array('help' => __d('cake_console', 'Comma separted list of paths.')))
|
||||
->addOption('paths', array('help' => __d('cake_console', 'Comma separated list of paths.')))
|
||||
->addOption('merge', array(
|
||||
'help' => __d('cake_console', 'Merge all domain strings into the default.po file.'),
|
||||
'choices' => array('yes', 'no')
|
||||
|
@ -245,40 +245,30 @@ class ExtractTask extends Shell {
|
|||
* Extract tokens out of all files to be processed
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __extractTokens() {
|
||||
foreach ($this->__files as $file) {
|
||||
$this->__file = $file;
|
||||
protected function _extractTokens() {
|
||||
foreach ($this->_files as $file) {
|
||||
$this->_file = $file;
|
||||
$this->out(__d('cake_console', 'Processing %s...', $file));
|
||||
|
||||
$code = file_get_contents($file);
|
||||
$allTokens = token_get_all($code);
|
||||
$this->__tokens = array();
|
||||
$lineNumber = 1;
|
||||
|
||||
$this->_tokens = array();
|
||||
foreach ($allTokens as $token) {
|
||||
if ((!is_array($token)) || (($token[0] != T_WHITESPACE) && ($token[0] != T_INLINE_HTML))) {
|
||||
if (is_array($token)) {
|
||||
$token[] = $lineNumber;
|
||||
}
|
||||
$this->__tokens[] = $token;
|
||||
}
|
||||
|
||||
if (is_array($token)) {
|
||||
$lineNumber += count(explode("\n", $token[1])) - 1;
|
||||
} else {
|
||||
$lineNumber += count(explode("\n", $token)) - 1;
|
||||
if (!is_array($token) || ($token[0] != T_WHITESPACE && $token[0] != T_INLINE_HTML)) {
|
||||
$this->_tokens[] = $token;
|
||||
}
|
||||
}
|
||||
unset($allTokens);
|
||||
$this->__parse('__', array('singular'));
|
||||
$this->__parse('__n', array('singular', 'plural'));
|
||||
$this->__parse('__d', array('domain', 'singular'));
|
||||
$this->__parse('__c', array('singular'));
|
||||
$this->__parse('__dc', array('domain', 'singular'));
|
||||
$this->__parse('__dn', array('domain', 'singular', 'plural'));
|
||||
$this->__parse('__dcn', array('domain', 'singular', 'plural'));
|
||||
$this->_parse('__', array('singular'));
|
||||
$this->_parse('__n', array('singular', 'plural'));
|
||||
$this->_parse('__d', array('domain', 'singular'));
|
||||
$this->_parse('__c', array('singular'));
|
||||
$this->_parse('__dc', array('domain', 'singular'));
|
||||
$this->_parse('__dn', array('domain', 'singular', 'plural'));
|
||||
$this->_parse('__dcn', array('domain', 'singular', 'plural'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,14 +278,14 @@ class ExtractTask extends Shell {
|
|||
* @param string $functionName Function name that indicates translatable string (e.g: '__')
|
||||
* @param array $map Array containing what variables it will find (e.g: domain, singular, plural)
|
||||
* @return void
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __parse($functionName, $map) {
|
||||
protected function _parse($functionName, $map) {
|
||||
$count = 0;
|
||||
$tokenCount = count($this->__tokens);
|
||||
$tokenCount = count($this->_tokens);
|
||||
|
||||
while (($tokenCount - $count) > 1) {
|
||||
list($countToken, $firstParenthesis) = array($this->__tokens[$count], $this->__tokens[$count + 1]);
|
||||
list($countToken, $firstParenthesis) = array($this->_tokens[$count], $this->_tokens[$count + 1]);
|
||||
if (!is_array($countToken)) {
|
||||
$count++;
|
||||
continue;
|
||||
|
@ -307,35 +297,24 @@ class ExtractTask extends Shell {
|
|||
$depth = 0;
|
||||
|
||||
while ($depth == 0) {
|
||||
if ($this->__tokens[$position] == '(') {
|
||||
if ($this->_tokens[$position] == '(') {
|
||||
$depth++;
|
||||
} elseif ($this->__tokens[$position] == ')') {
|
||||
} elseif ($this->_tokens[$position] == ')') {
|
||||
$depth--;
|
||||
}
|
||||
$position++;
|
||||
}
|
||||
|
||||
$mapCount = count($map);
|
||||
$strings = array();
|
||||
while (count($strings) < $mapCount && ($this->__tokens[$position] == ',' || $this->__tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING)) {
|
||||
if ($this->__tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
|
||||
$strings[] = $this->__tokens[$position][1];
|
||||
}
|
||||
$position++;
|
||||
}
|
||||
$strings = $this->_getStrings($position, $mapCount);
|
||||
|
||||
if ($mapCount == count($strings)) {
|
||||
extract(array_combine($map, $strings));
|
||||
if (!isset($domain)) {
|
||||
$domain = '\'default\'';
|
||||
}
|
||||
$string = $this->__formatString($singular);
|
||||
if (isset($plural)) {
|
||||
$string .= "\0" . $this->__formatString($plural);
|
||||
}
|
||||
$this->__strings[$this->__formatString($domain)][$string][$this->__file][] = $line;
|
||||
$domain = isset($domain) ? $domain : 'default';
|
||||
$string = isset($plural) ? $singular . "\0" . $plural : $singular;
|
||||
$this->_strings[$domain][$string][$this->_file][] = $line;
|
||||
} else {
|
||||
$this->__markerError($this->__file, $line, $functionName, $count);
|
||||
$this->_markerError($this->_file, $line, $functionName, $count);
|
||||
}
|
||||
}
|
||||
$count++;
|
||||
|
@ -346,17 +325,17 @@ class ExtractTask extends Shell {
|
|||
* Build the translate template file contents out of obtained strings
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __buildFiles() {
|
||||
foreach ($this->__strings as $domain => $strings) {
|
||||
protected function _buildFiles() {
|
||||
foreach ($this->_strings as $domain => $strings) {
|
||||
foreach ($strings as $string => $files) {
|
||||
$occurrences = array();
|
||||
foreach ($files as $file => $lines) {
|
||||
$occurrences[] = $file . ':' . implode(';', $lines);
|
||||
}
|
||||
$occurrences = implode("\n#: ", $occurrences);
|
||||
$header = '#: ' . str_replace($this->__paths, '', $occurrences) . "\n";
|
||||
$header = '#: ' . str_replace($this->_paths, '', $occurrences) . "\n";
|
||||
|
||||
if (strpos($string, "\0") === false) {
|
||||
$sentence = "msgid \"{$string}\"\n";
|
||||
|
@ -369,9 +348,9 @@ class ExtractTask extends Shell {
|
|||
$sentence .= "msgstr[1] \"\"\n\n";
|
||||
}
|
||||
|
||||
$this->__store($domain, $header, $sentence);
|
||||
if ($domain != 'default' && $this->__merge) {
|
||||
$this->__store('default', $header, $sentence);
|
||||
$this->_store($domain, $header, $sentence);
|
||||
if ($domain != 'default' && $this->_merge) {
|
||||
$this->_store('default', $header, $sentence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -381,16 +360,16 @@ class ExtractTask extends Shell {
|
|||
* Prepare a file to be stored
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __store($domain, $header, $sentence) {
|
||||
if (!isset($this->__storage[$domain])) {
|
||||
$this->__storage[$domain] = array();
|
||||
protected function _store($domain, $header, $sentence) {
|
||||
if (!isset($this->_storage[$domain])) {
|
||||
$this->_storage[$domain] = array();
|
||||
}
|
||||
if (!isset($this->__storage[$domain][$sentence])) {
|
||||
$this->__storage[$domain][$sentence] = $header;
|
||||
if (!isset($this->_storage[$domain][$sentence])) {
|
||||
$this->_storage[$domain][$sentence] = $header;
|
||||
} else {
|
||||
$this->__storage[$domain][$sentence] .= $header;
|
||||
$this->_storage[$domain][$sentence] .= $header;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,18 +377,18 @@ class ExtractTask extends Shell {
|
|||
* Write the files that need to be stored
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __writeFiles() {
|
||||
protected function _writeFiles() {
|
||||
$overwriteAll = false;
|
||||
foreach ($this->__storage as $domain => $sentences) {
|
||||
$output = $this->__writeHeader();
|
||||
foreach ($this->_storage as $domain => $sentences) {
|
||||
$output = $this->_writeHeader();
|
||||
foreach ($sentences as $sentence => $header) {
|
||||
$output .= $header . $sentence;
|
||||
}
|
||||
|
||||
$filename = $domain . '.pot';
|
||||
$File = new File($this->__output . $filename);
|
||||
$File = new File($this->_output . $filename);
|
||||
$response = '';
|
||||
while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') {
|
||||
$this->out();
|
||||
|
@ -418,7 +397,7 @@ class ExtractTask extends Shell {
|
|||
$response = '';
|
||||
while ($response == '') {
|
||||
$response = $this->in(__d('cake_console', "What would you like to name this file?"), null, 'new_' . $filename);
|
||||
$File = new File($this->__output . $response);
|
||||
$File = new File($this->_output . $response);
|
||||
$filename = $response;
|
||||
}
|
||||
} elseif (strtoupper($response) === 'A') {
|
||||
|
@ -434,9 +413,9 @@ class ExtractTask extends Shell {
|
|||
* Build the translation template header
|
||||
*
|
||||
* @return string Translation template header
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __writeHeader() {
|
||||
protected function _writeHeader() {
|
||||
$output = "# LANGUAGE translation of CakePHP Application\n";
|
||||
$output .= "# Copyright YEAR NAME <EMAIL@ADDRESS>\n";
|
||||
$output .= "#\n";
|
||||
|
@ -454,15 +433,43 @@ class ExtractTask extends Shell {
|
|||
$output .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n\n";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the strings from the position forward
|
||||
*
|
||||
* @param int $position Actual position on tokens array
|
||||
* @param int $target Number of strings to extract
|
||||
* @return array Strings extracted
|
||||
* @access protected
|
||||
*/
|
||||
protected function _getStrings(&$position, $target) {
|
||||
$strings = array();
|
||||
while (count($strings) < $target && ($this->_tokens[$position] == ',' || $this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING)) {
|
||||
if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING && $this->_tokens[$position+1] == '.') {
|
||||
$string = '';
|
||||
while ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING || $this->_tokens[$position] == '.') {
|
||||
if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
|
||||
$string .= $this->_formatString($this->_tokens[$position][1]);
|
||||
}
|
||||
$position++;
|
||||
}
|
||||
$strings[] = $string;
|
||||
} else if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
|
||||
$strings[] = $this->_formatString($this->_tokens[$position][1]);
|
||||
}
|
||||
$position++;
|
||||
}
|
||||
return $strings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a string to be added as a translateable string
|
||||
* Format a string to be added as a translatable string
|
||||
*
|
||||
* @param string $string String to format
|
||||
* @return string Formatted string
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __formatString($string) {
|
||||
protected function _formatString($string) {
|
||||
$quote = substr($string, 0, 1);
|
||||
$string = substr($string, 1, -1);
|
||||
if ($quote == '"') {
|
||||
|
@ -482,24 +489,24 @@ class ExtractTask extends Shell {
|
|||
* @param string $marker Marker found
|
||||
* @param integer $count Count
|
||||
* @return void
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __markerError($file, $line, $marker, $count) {
|
||||
protected function _markerError($file, $line, $marker, $count) {
|
||||
$this->out(__d('cake_console', "Invalid marker content in %s:%s\n* %s(", $file, $line, $marker), true);
|
||||
$count += 2;
|
||||
$tokenCount = count($this->__tokens);
|
||||
$tokenCount = count($this->_tokens);
|
||||
$parenthesis = 1;
|
||||
|
||||
while ((($tokenCount - $count) > 0) && $parenthesis) {
|
||||
if (is_array($this->__tokens[$count])) {
|
||||
$this->out($this->__tokens[$count][1], false);
|
||||
if (is_array($this->_tokens[$count])) {
|
||||
$this->out($this->_tokens[$count][1], false);
|
||||
} else {
|
||||
$this->out($this->__tokens[$count], false);
|
||||
if ($this->__tokens[$count] == '(') {
|
||||
$this->out($this->_tokens[$count], false);
|
||||
if ($this->_tokens[$count] == '(') {
|
||||
$parenthesis++;
|
||||
}
|
||||
|
||||
if ($this->__tokens[$count] == ')') {
|
||||
if ($this->_tokens[$count] == ')') {
|
||||
$parenthesis--;
|
||||
}
|
||||
}
|
||||
|
@ -509,17 +516,17 @@ class ExtractTask extends Shell {
|
|||
}
|
||||
|
||||
/**
|
||||
* Search files that may contain translateable strings
|
||||
* Search files that may contain translatable strings
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
* @access protected
|
||||
*/
|
||||
function __searchFiles() {
|
||||
protected function _searchFiles() {
|
||||
$pattern = false;
|
||||
if (!empty($this->_exclude)) {
|
||||
$pattern = '/[\/\\\\]' . implode('|', $this->_exclude) . '[\/\\\\]/';
|
||||
}
|
||||
foreach ($this->__paths as $path) {
|
||||
foreach ($this->_paths as $path) {
|
||||
$Folder = new Folder($path);
|
||||
$files = $Folder->findRecursive('.*\.(php|ctp|thtml|inc|tpl)', true);
|
||||
if (!empty($pattern)) {
|
||||
|
@ -530,7 +537,7 @@ class ExtractTask extends Shell {
|
|||
}
|
||||
$files = array_values($files);
|
||||
}
|
||||
$this->__files = array_merge($this->__files, $files);
|
||||
$this->_files = array_merge($this->_files, $files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ class FixtureTask extends BakeTask {
|
|||
'help' => __d('cake_console', 'CamelCased name of the plugin to bake fixtures for.'),
|
||||
'short' => 'p',
|
||||
))->addOption('records', array(
|
||||
'help' => 'Used with --count and <name>/all commands to pull [n] records from the live tables, where [n] is either --count or the default of 10',
|
||||
'help' => __d('cake_console', 'Used with --count and <name>/all commands to pull [n] records from the live tables, where [n] is either --count or the default of 10'),
|
||||
'short' => 'r',
|
||||
'boolean' => true
|
||||
))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.'));;
|
||||
|
@ -91,7 +91,7 @@ class FixtureTask extends BakeTask {
|
|||
|
||||
/**
|
||||
* Execution method always used for tasks
|
||||
* Handles dispatching to interactive, named, or all processess.
|
||||
* Handles dispatching to interactive, named, or all processeses.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -137,7 +137,7 @@ class FixtureTask extends BakeTask {
|
|||
protected function _interactive() {
|
||||
$this->DbConfig->interactive = $this->Model->interactive = $this->interactive = true;
|
||||
$this->hr();
|
||||
$this->out(sprintf("Bake Fixture\nPath: %s", $this->path));
|
||||
$this->out(__d('cake_console', "Bake Fixture\nPath: %s", $this->path));
|
||||
$this->hr();
|
||||
|
||||
if (!isset($this->connection)) {
|
||||
|
@ -254,7 +254,7 @@ class FixtureTask extends BakeTask {
|
|||
$this->Template->set($vars);
|
||||
$content = $this->Template->generate('classes', 'fixture');
|
||||
|
||||
$this->out("\nBaking test fixture for $model...", 1, Shell::QUIET);
|
||||
$this->out("\n" . __d('cake_console', 'Baking test fixture for %s...', $model), 1, Shell::QUIET);
|
||||
$this->createFile($path . $filename, $content);
|
||||
return $content;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ class ModelTask extends BakeTask {
|
|||
*/
|
||||
protected function _interactive() {
|
||||
$this->hr();
|
||||
$this->out(sprintf("Bake Model\nPath: %s", $this->path));
|
||||
$this->out(__d('cake_console', "Bake Model\nPath: %s", $this->path));
|
||||
$this->hr();
|
||||
$this->interactive = true;
|
||||
|
||||
|
@ -215,7 +215,7 @@ class ModelTask extends BakeTask {
|
|||
$this->hr();
|
||||
$this->out(__d('cake_console', 'The following Model will be created:'));
|
||||
$this->hr();
|
||||
$this->out("Name: " . $currentModelName);
|
||||
$this->out(__d('cake_console', "Name: %s", $currentModelName));
|
||||
|
||||
if ($this->connection !== 'default') {
|
||||
$this->out(__d('cake_console', "DB Config: %s", $this->connection));
|
||||
|
@ -561,7 +561,7 @@ class ModelTask extends BakeTask {
|
|||
* Find the hasAndBelongsToMany relations and add them to associations list
|
||||
*
|
||||
* @param object $model Model instance being generated
|
||||
* @param array $associations Array of inprogress associations
|
||||
* @param array $associations Array of in-progress associations
|
||||
* @return array $associations with hasAndBelongsToMany added in.
|
||||
*/
|
||||
public function findHasAndBelongsToMany($model, $associations) {
|
||||
|
@ -738,7 +738,7 @@ class ModelTask extends BakeTask {
|
|||
|
||||
$path = $this->getPath();
|
||||
$filename = $path . $name . '.php';
|
||||
$this->out("\nBaking model class for $name...", 1, Shell::QUIET);
|
||||
$this->out("\n" . __d('cake_console', 'Baking model class for %s...', $name), 1, Shell::QUIET);
|
||||
$this->createFile($filename, $out);
|
||||
ClassRegistry::flush();
|
||||
return $out;
|
||||
|
|
|
@ -185,10 +185,10 @@ class PluginTask extends Shell {
|
|||
*/
|
||||
public function getOptionParser() {
|
||||
$parser = parent::getOptionParser();
|
||||
return $parser->description(
|
||||
return $parser->description(__d('cake_console',
|
||||
'Create the directory structure, AppModel and AppController classes for a new plugin. ' .
|
||||
'Can create plugins in any of your bootstrapped plugin paths.'
|
||||
)->addArgument('name', array(
|
||||
))->addArgument('name', array(
|
||||
'help' => __d('cake_console', 'CamelCased name of the plugin to create.')
|
||||
));
|
||||
|
||||
|
|
|
@ -357,7 +357,7 @@ class ProjectTask extends Shell {
|
|||
}
|
||||
if ($this->interactive) {
|
||||
$this->hr();
|
||||
$this->out('You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.');
|
||||
$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.'));
|
||||
$this->out(__d('cake_console', 'What would you like the prefix route to be?'));
|
||||
$this->out(__d('cake_console', 'Example: www.example.com/admin/controller'));
|
||||
while ($admin == '') {
|
||||
|
@ -365,7 +365,7 @@ class ProjectTask extends Shell {
|
|||
}
|
||||
if ($this->cakeAdmin($admin) !== true) {
|
||||
$this->out(__d('cake_console', '<error>Unable to write to</error> /app/config/core.php.'));
|
||||
$this->out('You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.');
|
||||
$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.'));
|
||||
$this->_stop();
|
||||
}
|
||||
return $admin . '_';
|
||||
|
|
|
@ -142,7 +142,7 @@ class TestTask extends BakeTask {
|
|||
if ($this->plugin) {
|
||||
$plugin = $this->plugin . '.';
|
||||
}
|
||||
$this->out("\nBaking test case for $className $type...", 1, Shell::QUIET);
|
||||
$this->out("\n" . __d('cake_console', 'Baking test case for %s %s ...', $className, $type), 1, Shell::QUIET);
|
||||
|
||||
$this->Template->set('fixtures', $this->_fixtures);
|
||||
$this->Template->set('plugin', $plugin);
|
||||
|
|
|
@ -367,7 +367,7 @@ class ViewTask extends BakeTask {
|
|||
if (empty($content)) {
|
||||
return false;
|
||||
}
|
||||
$this->out("\nBaking `$action` view file...", 1, Shell::QUIET);
|
||||
$this->out("\n" . __d('cake_console', 'Baking `%s` view file...', $action), 1, Shell::QUIET);
|
||||
$path = $this->getPath();
|
||||
$filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp';
|
||||
return $this->createFile($filename, $content);
|
||||
|
|
|
@ -41,8 +41,8 @@ class TestsuiteShell extends Shell {
|
|||
public function getOptionParser() {
|
||||
$parser = new ConsoleOptionParser($this->name);
|
||||
$parser->description(array(
|
||||
'The CakePHP Testsuite allows you to run test cases from the command line',
|
||||
'If run with no command line arguments, a list of available core test cases will be shown'
|
||||
__d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line'),
|
||||
__d('cake_console', 'If run with no command line arguments, a list of available core test cases will be shown')
|
||||
))->addArgument('category', array(
|
||||
'help' => __d('cake_console', 'app, core or name of a plugin.'),
|
||||
'required' => true
|
||||
|
@ -157,7 +157,7 @@ class TestsuiteShell extends Shell {
|
|||
}
|
||||
|
||||
/**
|
||||
* Initialization method installs Simpletest and loads all plugins
|
||||
* Initialization method installs PHPUnit and loads all plugins
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -57,8 +57,7 @@ class ConsoleErrorHandler extends ErrorHandler {
|
|||
*/
|
||||
public static function handleException(Exception $exception) {
|
||||
$stderr = self::getStderr();
|
||||
$stderr->write(sprintf(
|
||||
__d('cake_console', "<error>Error:</error> %s\n%s"),
|
||||
$stderr->write(__d('cake_console', "<error>Error:</error> %s\n%s",
|
||||
$exception->getMessage(),
|
||||
$exception->getTraceAsString()
|
||||
));
|
||||
|
@ -70,7 +69,7 @@ class ConsoleErrorHandler extends ErrorHandler {
|
|||
* @param int $code Error code
|
||||
* @param string $description Description of the error.
|
||||
* @param string $file The file the error occurred in.
|
||||
* @param int $line The line the error ocurrred on.
|
||||
* @param int $line The line the error occurred on.
|
||||
* @param array $context The backtrace of the error.
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -55,7 +55,7 @@ class ConsoleInputArgument {
|
|||
/**
|
||||
* Make a new Input Argument
|
||||
*
|
||||
* @param mixed $name The long name of the option, or an array with all the properites.
|
||||
* @param mixed $name The long name of the option, or an array with all the properties.
|
||||
* @param string $help The help text for this option
|
||||
* @param boolean $required Whether this argument is required. Missing required args will trigger exceptions
|
||||
* @param array $choices Valid choices for this option.
|
||||
|
@ -139,8 +139,8 @@ class ConsoleInputArgument {
|
|||
return true;
|
||||
}
|
||||
if (!in_array($value, $this->_choices)) {
|
||||
throw new ConsoleException(sprintf(
|
||||
__d('cake_console', '"%s" is not a valid value for %s. Please use one of "%s"'),
|
||||
throw new ConsoleException(
|
||||
__d('cake_console', '"%s" is not a valid value for %s. Please use one of "%s"',
|
||||
$value, $this->_name, implode(', ', $this->_choices)
|
||||
));
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class ConsoleInputOption {
|
|||
/**
|
||||
* Make a new Input Option
|
||||
*
|
||||
* @param mixed $name The long name of the option, or an array with all the properites.
|
||||
* @param mixed $name The long name of the option, or an array with all the properties.
|
||||
* @param string $short The short alias for this option
|
||||
* @param string $help The help text for this option
|
||||
* @param boolean $boolean Whether this option is a boolean option. Boolean options don't consume extra tokens
|
||||
|
@ -179,8 +179,8 @@ class ConsoleInputOption {
|
|||
return true;
|
||||
}
|
||||
if (!in_array($value, $this->_choices)) {
|
||||
throw new ConsoleException(sprintf(
|
||||
__d('cake_console', '"%s" is not a valid value for --%s. Please use one of "%s"'),
|
||||
throw new ConsoleException(
|
||||
__d('cake_console', '"%s" is not a valid value for --%s. Please use one of "%s"',
|
||||
$value, $this->_name, implode(', ', $this->_choices)
|
||||
));
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class ConsoleInputSubcommand {
|
|||
/**
|
||||
* Make a new Subcommand
|
||||
*
|
||||
* @param mixed $name The long name of the subcommand, or an array with all the properites.
|
||||
* @param mixed $name The long name of the subcommand, or an array with all the properties.
|
||||
* @param string $help The help text for this option
|
||||
* @param mixed $parser A parser for this subcommand. Either a ConsoleOptionParser, or an array that can be
|
||||
* used with ConsoleOptionParser::buildFromArray()
|
||||
|
|
|
@ -86,9 +86,9 @@ class ConsoleOptionParser {
|
|||
*
|
||||
* ### Options
|
||||
*
|
||||
* Named arguments come in two forms, long and short. Long arguments are preceeded
|
||||
* Named arguments come in two forms, long and short. Long arguments are preceded
|
||||
* by two - and give a more verbose option name. i.e. `--version`. Short arguments are
|
||||
* preceeded by one - and are only one character long. They usually match with a long option,
|
||||
* preceded by one - and are only one character long. They usually match with a long option,
|
||||
* and provide a more terse alternative.
|
||||
*
|
||||
* ### Using Options
|
||||
|
@ -102,7 +102,7 @@ class ConsoleOptionParser {
|
|||
*
|
||||
* `cake myshell command --connection default --name=something`
|
||||
*
|
||||
* Short options can be defined singally or in groups.
|
||||
* Short options can be defined signally or in groups.
|
||||
*
|
||||
* `cake myshell command -cn`
|
||||
*
|
||||
|
@ -127,7 +127,7 @@ class ConsoleOptionParser {
|
|||
|
||||
$this->addOption('help', array(
|
||||
'short' => 'h',
|
||||
'help' => 'Display this help.',
|
||||
'help' => __d('cake_console', 'Display this help.'),
|
||||
'boolean' => true
|
||||
));
|
||||
|
||||
|
@ -330,7 +330,7 @@ class ConsoleOptionParser {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add multiple arugments at once. Take an array of arugment defintions.
|
||||
* Add multiple arguments at once. Take an array of argument definitions.
|
||||
* The keys are used as the argument names, and the values as params for the argument.
|
||||
*
|
||||
* @param array $args Array of arguments to add.
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
/**
|
||||
* Object wrapper for outputing information from a shell application.
|
||||
* Object wrapper for outputting information from a shell application.
|
||||
* Can be connected to any stream resource that can be used with fopen()
|
||||
*
|
||||
* Can generate colourized output on consoles that support it. There are a few
|
||||
* Can generate colorized output on consoles that support it. There are a few
|
||||
* built in styles
|
||||
*
|
||||
* - `error` Error messages.
|
||||
|
@ -37,7 +37,7 @@
|
|||
*
|
||||
* `$this->out('<warning>Overwrite:</warning> foo.php was overwritten.');`
|
||||
*
|
||||
* This would create orange 'Overwrite:' text, while the rest of the text would remain the normal colour.
|
||||
* This would create orange 'Overwrite:' text, while the rest of the text would remain the normal color.
|
||||
* See ConsoleOutput::styles() to learn more about defining your own styles. Nested styles are not supported
|
||||
* at this time.
|
||||
*
|
||||
|
@ -55,7 +55,7 @@ class ConsoleOutput {
|
|||
const PLAIN = 1;
|
||||
|
||||
/**
|
||||
* Colour output - Convert known tags in to ANSI color escape codes.
|
||||
* Color output - Convert known tags in to ANSI color escape codes.
|
||||
*/
|
||||
const COLOR = 2;
|
||||
|
||||
|
@ -79,7 +79,7 @@ class ConsoleOutput {
|
|||
protected $_outputAs = self::COLOR;
|
||||
|
||||
/**
|
||||
* text colors used in coloured output.
|
||||
* text colors used in colored output.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -95,7 +95,7 @@ class ConsoleOutput {
|
|||
);
|
||||
|
||||
/**
|
||||
* background colours used in coloured output.
|
||||
* background colors used in colored output.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -111,7 +111,7 @@ class ConsoleOutput {
|
|||
);
|
||||
|
||||
/**
|
||||
* formatting options for coloured output
|
||||
* formatting options for colored output
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@ -140,7 +140,7 @@ class ConsoleOutput {
|
|||
/**
|
||||
* Construct the output object.
|
||||
*
|
||||
* Checks for a pretty console enviornment. Ansicon allows pretty consoles
|
||||
* Checks for a pretty console environment. Ansicon allows pretty consoles
|
||||
* on windows, and is supported.
|
||||
*
|
||||
* @param string $stream The identifier of the stream to write output to.
|
||||
|
@ -267,7 +267,7 @@ class ConsoleOutput {
|
|||
/**
|
||||
* Get/Set the output type to use. The output type how formatting tags are treated.
|
||||
*
|
||||
* @param int $type The output type to use. Should be one of the class contstants.
|
||||
* @param int $type The output type to use. Should be one of the class constants.
|
||||
* @return mixed Either null or the value if getting.
|
||||
*/
|
||||
public function outputAs($type = null) {
|
||||
|
|
|
@ -23,7 +23,7 @@ App::uses('String', 'Utility');
|
|||
* Generally not directly used. Using $parser->help($command, 'xml'); is usually
|
||||
* how you would access help. Or via the `--help=xml` option on the command line.
|
||||
*
|
||||
* Xml output is useful for intergration with other tools like IDE's or other build tools.
|
||||
* Xml output is useful for integration with other tools like IDE's or other build tools.
|
||||
*
|
||||
* @package cake.console.libs
|
||||
* @since CakePHP(tm) v 2.0
|
||||
|
@ -52,12 +52,12 @@ class HelpFormatter {
|
|||
$out[] = String::wrap($description, $width);
|
||||
$out[] = '';
|
||||
}
|
||||
$out[] = '<info>Usage:</info>';
|
||||
$out[] = __d('cake_console', '<info>Usage:</info>');
|
||||
$out[] = $this->_generateUsage();
|
||||
$out[] = '';
|
||||
$subcommands = $parser->subcommands();
|
||||
if (!empty($subcommands)) {
|
||||
$out[] = '<info>Subcommands:</info>';
|
||||
$out[] = __d('cake_console', '<info>Subcommands:</info>');
|
||||
$out[] = '';
|
||||
$max = $this->_getMaxLength($subcommands) + 2;
|
||||
foreach ($subcommands as $command) {
|
||||
|
@ -68,17 +68,14 @@ class HelpFormatter {
|
|||
));
|
||||
}
|
||||
$out[] = '';
|
||||
$out[] = sprintf(
|
||||
__d('cake_console', 'To see help on a subcommand use <info>`cake %s [subcommand] --help`</info>'),
|
||||
$parser->command()
|
||||
);
|
||||
$out[] = __d('cake_console', 'To see help on a subcommand use <info>`cake %s [subcommand] --help`</info>', $parser->command());
|
||||
$out[] = '';
|
||||
}
|
||||
|
||||
$options = $parser->options();
|
||||
if (!empty($options)) {
|
||||
$max = $this->_getMaxLength($options) + 8;
|
||||
$out[] = '<info>Options:</info>';
|
||||
$out[] = __d('cake_console', '<info>Options:</info>');
|
||||
$out[] = '';
|
||||
foreach ($options as $option) {
|
||||
$out[] = String::wrap($option->help($max), array(
|
||||
|
@ -93,7 +90,7 @@ class HelpFormatter {
|
|||
$arguments = $parser->arguments();
|
||||
if (!empty($arguments)) {
|
||||
$max = $this->_getMaxLength($arguments) + 2;
|
||||
$out[] = '<info>Arguments:</info>';
|
||||
$out[] = __d('cake_console', '<info>Arguments:</info>');
|
||||
$out[] = '';
|
||||
foreach ($arguments as $argument) {
|
||||
$out[] = String::wrap($argument->help($max), array(
|
||||
|
@ -114,7 +111,7 @@ class HelpFormatter {
|
|||
|
||||
/**
|
||||
* Generate the usage for a shell based on its arguments and options.
|
||||
* Usage strings favour short options over the long ones. and optional args will
|
||||
* Usage strings favor short options over the long ones. and optional args will
|
||||
* be indicated with []
|
||||
*
|
||||
* @return string
|
||||
|
@ -156,7 +153,7 @@ class HelpFormatter {
|
|||
public function xml($string = true) {
|
||||
$parser = $this->_parser;
|
||||
$xml = new SimpleXmlElement('<shell></shell>');
|
||||
$xml->addChild('commmand', $parser->command());
|
||||
$xml->addChild('command', $parser->command());
|
||||
$xml->addChild('description', $parser->description());
|
||||
|
||||
$xml->addChild('epilog', $parser->epilog());
|
||||
|
|
|
@ -188,7 +188,7 @@ class Shell extends Object {
|
|||
/**
|
||||
* Starts up the Shell
|
||||
* allows for checking and configuring prior to command or main execution
|
||||
* can be overriden in subclasses
|
||||
* can be overridden in subclasses
|
||||
*
|
||||
*/
|
||||
public function startup() {
|
||||
|
@ -201,10 +201,10 @@ class Shell extends Object {
|
|||
*/
|
||||
protected function _welcome() {
|
||||
$this->out();
|
||||
$this->out('<info>Welcome to CakePHP v' . Configure::version() . ' Console</info>');
|
||||
$this->out(__d('cake_console', '<info>Welcome to CakePHP %s Console</info>', 'v' . Configure::version()));
|
||||
$this->hr();
|
||||
$this->out('App : '. APP_DIR);
|
||||
$this->out('Path: '. APP_PATH);
|
||||
$this->out(__d('cake_console', 'App : %s', APP_DIR));
|
||||
$this->out(__d('cake_console', 'Path: %s', APP_PATH));
|
||||
$this->hr();
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ class Shell extends Object {
|
|||
*
|
||||
* ### Usage:
|
||||
*
|
||||
* With a string commmand:
|
||||
* With a string command:
|
||||
*
|
||||
* `return $this->dispatchShell('schema create DbAcl');`
|
||||
*
|
||||
|
@ -578,7 +578,7 @@ class Shell extends Object {
|
|||
*/
|
||||
public function clear() {
|
||||
if (empty($this->params['noclear'])) {
|
||||
if ( DS === '/') {
|
||||
if (DS === '/') {
|
||||
passthru('clear');
|
||||
} else {
|
||||
passthru('cls');
|
||||
|
@ -600,7 +600,7 @@ class Shell extends Object {
|
|||
|
||||
if (is_file($path) && $this->interactive === true) {
|
||||
$this->out(__d('cake_console', '<warning>File `%s` exists</warning>', $path));
|
||||
$key = $this->in(__d('cake_console', 'Do you want to overwrite?'), array('y', 'n', 'q'), 'n');
|
||||
$key = $this->in(__d('cake_console', 'Do you want to overwrite?'), array('y', 'n', 'q'), 'n');
|
||||
|
||||
if (strtolower($key) == 'q') {
|
||||
$this->out(__d('cake_console', '<error>Quitting</error>.'), 2);
|
||||
|
@ -636,13 +636,13 @@ class Shell extends Object {
|
|||
if (@include 'PHPUnit' . DS . 'Autoload.php') {
|
||||
return true;
|
||||
}
|
||||
$prompt = 'PHPUnit is not installed. Do you want to bake unit test files anyway?';
|
||||
$prompt = __d('cake_console', 'PHPUnit is not installed. Do you want to bake unit test files anyway?');
|
||||
$unitTest = $this->in($prompt, array('y','n'), 'y');
|
||||
$result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes';
|
||||
|
||||
if ($result) {
|
||||
$this->out();
|
||||
$this->out('You can download PHPUnit from http://phpunit.de');
|
||||
$this->out(__d('cake_console', 'You can download PHPUnit from %s', 'http://phpunit.de'));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -99,13 +99,13 @@ class ShellDispatcher {
|
|||
*/
|
||||
protected function _initEnvironment() {
|
||||
if (!$this->__bootstrap()) {
|
||||
$message = "Unable to load CakePHP core.\nMake sure " . DS . 'cake' . DS . 'libs exists in ' . CAKE_CORE_INCLUDE_PATH;
|
||||
$message = "Unable to load CakePHP core.\nMake sure " . DS . 'lib' . DS . 'Cake exists in ' . CAKE_CORE_INCLUDE_PATH;
|
||||
throw new CakeException($message);
|
||||
}
|
||||
|
||||
if (!isset($this->args[0]) || !isset($this->params['working'])) {
|
||||
$message = "This file has been loaded incorrectly and cannot continue.\n" .
|
||||
"Please make sure that " . DIRECTORY_SEPARATOR . "cake" . DIRECTORY_SEPARATOR . "console is in your system path,\n" .
|
||||
"Please make sure that " . DS . 'lib' . DS . 'Cake' . DS . "Console is in your system path,\n" .
|
||||
"and check the cookbook for the correct usage of this command.\n" .
|
||||
"(http://book.cakephp.org/)";
|
||||
throw new CakeException($message);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
App::uses('Component', 'Controller');
|
||||
App::uses('Multibyte', 'I18n');
|
||||
App::uses('CakeEmail', 'Network');
|
||||
App::uses('CakeEmail', 'Network/Email');
|
||||
|
||||
/**
|
||||
* EmailComponent
|
||||
|
|
|
@ -336,6 +336,7 @@ class Controller extends Object {
|
|||
|
||||
/**
|
||||
* Provides backwards compatibility to avoid problems with empty and isset to alias properties.
|
||||
* Lazy loads models using the loadModel() method if declared in $uses
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -349,6 +350,27 @@ class Controller extends Object {
|
|||
case 'params':
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_array($this->uses)) {
|
||||
foreach ($this->uses as $modelClass) {
|
||||
list($plugin, $class) = pluginSplit($modelClass, true);
|
||||
if ($name === $class) {
|
||||
if (!$plugin) {
|
||||
$plugin = $this->plugin ? $this->plugin . '.' : null;
|
||||
}
|
||||
return $this->loadModel($modelClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($name === $this->modelClass) {
|
||||
list($plugin, $class) = pluginSplit($name, true);
|
||||
if (!$plugin) {
|
||||
$plugin = $this->plugin ? $this->plugin . '.' : null;
|
||||
}
|
||||
return $this->loadModel($plugin . $this->modelClass);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -372,6 +394,11 @@ class Controller extends Object {
|
|||
case 'paginate':
|
||||
return $this->Components->load('Paginator')->settings;
|
||||
}
|
||||
|
||||
if (isset($this->{$name})) {
|
||||
return $this->{$name};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -493,25 +520,9 @@ class Controller extends Object {
|
|||
public function constructClasses() {
|
||||
$this->__mergeVars();
|
||||
$this->Components->init($this);
|
||||
|
||||
if ($this->uses !== null || ($this->uses !== array())) {
|
||||
if (empty($this->passedArgs) || !isset($this->passedArgs['0'])) {
|
||||
$id = false;
|
||||
} else {
|
||||
$id = $this->passedArgs['0'];
|
||||
}
|
||||
$plugin = $this->plugin ? $this->plugin . '.' : null;
|
||||
|
||||
if ($this->uses === false) {
|
||||
$this->loadModel($plugin . $this->modelClass, $id);
|
||||
} elseif ($this->uses) {
|
||||
$uses = is_array($this->uses) ? $this->uses : array($this->uses);
|
||||
list($plugin, $modelClassName) = pluginSplit($uses[0]);
|
||||
$this->modelClass = $modelClassName;
|
||||
foreach ($uses as $modelClass) {
|
||||
$this->loadModel($modelClass);
|
||||
}
|
||||
}
|
||||
if ($this->uses) {
|
||||
$this->uses = (array) $this->uses;
|
||||
list(, $this->modelClass) = pluginSplit(current($this->uses));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -389,9 +389,7 @@ class App {
|
|||
* @return string full path to package
|
||||
*/
|
||||
public static function core($type) {
|
||||
if ($type) {
|
||||
return isset($paths[$type]) ? $paths[$type] : array(LIBS . $type . DS);
|
||||
}
|
||||
return array(LIBS . str_replace('/', DS, $type) . DS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -184,7 +184,7 @@ class ExceptionRenderer {
|
|||
$this->controller->set($error->getAttributes());
|
||||
$this->_outputMessage($this->template);
|
||||
} catch (Exception $e) {
|
||||
$this->_outputMessage('error500');
|
||||
$this->_outputMessageSafe('error500');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -235,4 +235,16 @@ class ExceptionRenderer {
|
|||
$this->controller->afterFilter();
|
||||
$this->controller->response->send();
|
||||
}
|
||||
|
||||
/**
|
||||
* A safer way to render error messages, replaces all helpers, with basics
|
||||
* and doesn't call component methods.
|
||||
*
|
||||
* @param string $template The template to render
|
||||
*/
|
||||
protected function _outputMessageSafe($template) {
|
||||
$this->controller->helpers = array('Form', 'Html', 'Session');
|
||||
$this->controller->render($template);
|
||||
$this->controller->response->send();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -405,7 +405,7 @@ class HttpSocket extends CakeSocket {
|
|||
*/
|
||||
public function get($uri = null, $query = array(), $request = array()) {
|
||||
if (!empty($query)) {
|
||||
$uri = $this->_parseUri($uri);
|
||||
$uri = $this->_parseUri($uri, $this->config['request']['uri']);
|
||||
if (isset($uri['query'])) {
|
||||
$uri['query'] = array_merge($uri['query'], $query);
|
||||
} else {
|
||||
|
|
|
@ -1809,7 +1809,7 @@ class FormHelper extends AppHelper {
|
|||
$attributes['value'] = $meridian;
|
||||
} else {
|
||||
if (empty($value)) {
|
||||
if (!$attribues['empty']) {
|
||||
if (!$attributes['empty']) {
|
||||
$attributes['value'] = date('a');
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -27,13 +27,6 @@ App::uses('AppHelper', 'View/Helper');
|
|||
* @package cake.view.helpers
|
||||
*/
|
||||
abstract class JsBaseEngineHelper extends AppHelper {
|
||||
/**
|
||||
* Determines whether native JSON extension is used for encoding. Set by object constructor.
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
public $useNative = false;
|
||||
|
||||
/**
|
||||
* The js snippet for the current selection.
|
||||
|
@ -76,7 +69,6 @@ abstract class JsBaseEngineHelper extends AppHelper {
|
|||
*/
|
||||
function __construct($View, $settings = array()) {
|
||||
parent::__construct($View, $settings);
|
||||
$this->useNative = function_exists('json_encode');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,50 +146,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
|
|||
);
|
||||
$options = array_merge($defaultOptions, $options);
|
||||
|
||||
if (is_object($data)) {
|
||||
$data = get_object_vars($data);
|
||||
}
|
||||
|
||||
$out = $keys = array();
|
||||
$numeric = true;
|
||||
|
||||
if ($this->useNative && function_exists('json_encode')) {
|
||||
$rt = json_encode($data);
|
||||
} else {
|
||||
if (is_null($data)) {
|
||||
return 'null';
|
||||
}
|
||||
if (is_bool($data)) {
|
||||
return $data ? 'true' : 'false';
|
||||
}
|
||||
if (is_array($data)) {
|
||||
$keys = array_keys($data);
|
||||
}
|
||||
|
||||
if (!empty($keys)) {
|
||||
$numeric = (array_values($keys) === array_keys(array_values($keys)));
|
||||
}
|
||||
|
||||
foreach ($data as $key => $val) {
|
||||
if (is_array($val) || is_object($val)) {
|
||||
$val = $this->object($val);
|
||||
} else {
|
||||
$val = $this->value($val);
|
||||
}
|
||||
if (!$numeric) {
|
||||
$val = '"' . $this->value($key, false) . '":' . $val;
|
||||
}
|
||||
$out[] = $val;
|
||||
}
|
||||
|
||||
if (!$numeric) {
|
||||
$rt = '{' . join(',', $out) . '}';
|
||||
} else {
|
||||
$rt = '[' . join(',', $out) . ']';
|
||||
}
|
||||
}
|
||||
$rt = $options['prefix'] . $rt . $options['postfix'];
|
||||
return $rt;
|
||||
return $options['prefix'] . json_encode($data) . $options['postfix'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -118,7 +118,6 @@ class ExtractTaskTest extends CakeTestCase {
|
|||
$pattern = '/To change its layout, create: APP\/views\/layouts\/default\.ctp\./s';
|
||||
$this->assertPattern($pattern, $result);
|
||||
|
||||
|
||||
// extract.ctp
|
||||
$pattern = '/\#: (\\\\|\/)extract\.ctp:6\n';
|
||||
$pattern .= 'msgid "You have %d new message."\nmsgid_plural "You have %d new messages."/';
|
||||
|
@ -131,9 +130,15 @@ class ExtractTaskTest extends CakeTestCase {
|
|||
$pattern = '/\#: (\\\\|\/)extract\.ctp:14\n';
|
||||
$pattern .= '\#: (\\\\|\/)home\.ctp:99\n';
|
||||
$pattern .= 'msgid "Editing this Page"\nmsgstr ""/';
|
||||
|
||||
$this->assertPattern($pattern, $result);
|
||||
|
||||
|
||||
$pattern = '/\#: (\\\\|\/)extract\.ctp:17\nmsgid "';
|
||||
$pattern .= 'Hot features!';
|
||||
$pattern .= '\\\n - No Configuration: Set-up the database and let the magic begin';
|
||||
$pattern .= '\\\n - Extremely Simple: Just look at the name...It\'s Cake';
|
||||
$pattern .= '\\\n - Active, Friendly Community: Join us #cakephp on IRC. We\'d love to help you get started';
|
||||
$pattern .= '"\nmsgstr ""/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
|
||||
// extract.ctp - reading the domain.pot
|
||||
$result = file_get_contents($this->path . DS . 'domain.pot');
|
||||
|
|
|
@ -470,16 +470,8 @@ class ControllerTest extends CakeTestCase {
|
|||
$request = new CakeRequest('controller_posts/index');
|
||||
$Controller = new Controller($request);
|
||||
|
||||
$Controller->modelClass = 'ControllerPost';
|
||||
$Controller->passedArgs[] = '1';
|
||||
$Controller->constructClasses();
|
||||
$this->assertEqual($Controller->ControllerPost->id, 1);
|
||||
|
||||
unset($Controller);
|
||||
|
||||
$Controller = new Controller($request);
|
||||
$Controller->uses = array('ControllerPost', 'ControllerComment');
|
||||
$Controller->passedArgs[] = '1';
|
||||
$Controller->constructClasses();
|
||||
$this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost'));
|
||||
$this->assertTrue(is_a($Controller->ControllerComment, 'ControllerComment'));
|
||||
|
@ -494,7 +486,6 @@ class ControllerTest extends CakeTestCase {
|
|||
$Controller->uses = array('TestPlugin.TestPluginPost');
|
||||
$Controller->constructClasses();
|
||||
|
||||
$this->assertEqual($Controller->modelClass, 'TestPluginPost');
|
||||
$this->assertTrue(isset($Controller->TestPluginPost));
|
||||
$this->assertTrue(is_a($Controller->TestPluginPost, 'TestPluginPost'));
|
||||
|
||||
|
@ -917,7 +908,7 @@ class ControllerTest extends CakeTestCase {
|
|||
$this->assertTrue(in_array('ControllerPost', $appVars['uses']));
|
||||
$this->assertNull($testVars['uses']);
|
||||
|
||||
$this->assertFalse(isset($TestController->ControllerPost));
|
||||
$this->assertFalse(property_exists($TestController, 'ControllerPost'));
|
||||
|
||||
|
||||
$TestController = new ControllerCommentsController($request);
|
||||
|
|
|
@ -609,4 +609,32 @@ class ExceptionRendererTest extends CakeTestCase {
|
|||
$this->assertPattern($pattern, $result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exceptions being raised when helpers are missing.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testMissingRenderSafe() {
|
||||
$exception = new MissingHelperFileException(array('class' => 'Fail'));
|
||||
$ExceptionRenderer = new ExceptionRenderer($exception);
|
||||
|
||||
$ExceptionRenderer->controller = $this->getMock('Controller');
|
||||
$ExceptionRenderer->controller->helpers = array('Fail', 'Boom');
|
||||
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
|
||||
$ExceptionRenderer->controller->expects($this->at(2))
|
||||
->method('render')
|
||||
->with('missingHelperFile')
|
||||
->will($this->throwException($exception));
|
||||
|
||||
$ExceptionRenderer->controller->expects($this->at(3))
|
||||
->method('render')
|
||||
->with('error500')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$ExceptionRenderer->controller->response = $this->getMock('CakeResponse');
|
||||
$ExceptionRenderer->render();
|
||||
sort($ExceptionRenderer->controller->helpers);
|
||||
$this->assertEquals(array('Form', 'Html', 'Session'), $ExceptionRenderer->controller->helpers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* @since CakePHP(tm) v 2.0.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
App::uses('CakeEmail', 'Network');
|
||||
App::uses('CakeEmail', 'Network/Email');
|
||||
|
||||
/**
|
||||
* Help to test CakeEmail
|
|
@ -16,7 +16,7 @@
|
|||
* @since CakePHP(tm) v 2.0.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
App::uses('CakeEmail', 'Network');
|
||||
App::uses('CakeEmail', 'Network/Email');
|
||||
App::uses('AbstractTransport', 'Network/Email');
|
||||
App::uses('SmtpTransport', 'Network/Email');
|
||||
|
||||
|
|
|
@ -595,6 +595,34 @@ class HttpSocketTest extends CakeTestCase {
|
|||
$this->assertFalse($this->Socket->connected);
|
||||
}
|
||||
|
||||
/**
|
||||
* testRequestWithConstructor method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRequestWithConstructor() {
|
||||
$request = array(
|
||||
'request' => array(
|
||||
'uri' => array(
|
||||
'scheme' => 'http',
|
||||
'host' => 'localhost',
|
||||
'port' => '5984',
|
||||
'user' => null,
|
||||
'pass' => null
|
||||
)
|
||||
)
|
||||
);
|
||||
$http = new MockHttpSocketRequests($request);
|
||||
|
||||
$expected = array('method' => 'GET', 'uri' => '/_test');
|
||||
$http->expects($this->at(0))->method('request')->with($expected);
|
||||
$http->get('/_test');
|
||||
|
||||
$expected = array('method' => 'GET', 'uri' => 'http://localhost:5984/_test?count=4');
|
||||
$http->expects($this->at(0))->method('request')->with($expected);
|
||||
$http->get('/_test', array('count' => 4));
|
||||
}
|
||||
|
||||
/**
|
||||
* testRequestWithResource
|
||||
*
|
||||
|
|
|
@ -25,6 +25,12 @@ App::uses('FormHelper', 'View/Helper');
|
|||
App::uses('View', 'View');
|
||||
App::uses('ClassRegistry', 'Utility');
|
||||
|
||||
class JsEncodingObject {
|
||||
protected $_title = 'Old thing';
|
||||
|
||||
private $__noshow = 'Never ever';
|
||||
}
|
||||
|
||||
class OptionEngineHelper extends JsBaseEngineHelper {
|
||||
protected $_optionMap = array(
|
||||
'request' => array(
|
||||
|
@ -797,13 +803,18 @@ class JsBaseEngineTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testObject() {
|
||||
$this->JsEngine->useNative = false;
|
||||
|
||||
$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8));
|
||||
$result = $this->JsEngine->object($object);
|
||||
$expected = '{"title":"New thing","indexes":[5,6,7,8]}';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$object = new JsEncodingObject();
|
||||
$object->title = 'New thing';
|
||||
$object->indexes = array(5,6,7,8);
|
||||
$result = $this->JsEngine->object($object);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->JsEngine->object(array('default' => 0));
|
||||
$expected = '{"default":0}';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
@ -842,70 +853,6 @@ class JsBaseEngineTest extends CakeTestCase {
|
|||
$this->assertNoPattern('/.POSTFIX./', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test compatibility of JsBaseEngineHelper::object() vs. json_encode()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testObjectAgainstJsonEncode() {
|
||||
$skip = $this->skipIf(!function_exists('json_encode'), 'json_encode() not found, comparison tests skipped. %s');
|
||||
if ($skip) {
|
||||
return;
|
||||
}
|
||||
$this->JsEngine->useNative = false;
|
||||
$data = array();
|
||||
$data['mystring'] = "simple string";
|
||||
$this->assertEqual(json_encode($data), $this->JsEngine->object($data));
|
||||
|
||||
$data['mystring'] = "strïng with spécial chârs";
|
||||
$this->assertEqual(json_encode($data), $this->JsEngine->object($data));
|
||||
|
||||
$data['mystring'] = "a two lines\nstring";
|
||||
$this->assertEqual(json_encode($data), $this->JsEngine->object($data));
|
||||
|
||||
$data['mystring'] = "a \t tabbed \t string";
|
||||
$this->assertEqual(json_encode($data), $this->JsEngine->object($data));
|
||||
|
||||
$data['mystring'] = "a \"double-quoted\" string";
|
||||
$this->assertEqual(json_encode($data), $this->JsEngine->object($data));
|
||||
|
||||
$data['mystring'] = 'a \\"double-quoted\\" string';
|
||||
$this->assertEqual(json_encode($data), $this->JsEngine->object($data));
|
||||
|
||||
unset($data['mystring']);
|
||||
$data[3] = array(1, 2, 3);
|
||||
$this->assertEqual(json_encode($data), $this->JsEngine->object($data));
|
||||
|
||||
unset($data[3]);
|
||||
$data = array('mystring' => null, 'bool' => false, 'array' => array(1, 44, 66));
|
||||
$this->assertEqual(json_encode($data), $this->JsEngine->object($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that JSON made with JsBaseEngineHelper::object() against json_decode()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testObjectAgainstJsonDecode() {
|
||||
$skip = $this->skipIf(!function_exists('json_encode'), 'json_encode() not found, comparison tests skipped. %s');
|
||||
if ($skip) {
|
||||
return;
|
||||
}
|
||||
$this->JsEngine->useNative = false;
|
||||
|
||||
$data = array("simple string");
|
||||
$result = $this->JsEngine->object($data);
|
||||
$this->assertEqual(json_decode($result), $data);
|
||||
|
||||
$data = array('my "string"');
|
||||
$result = $this->JsEngine->object($data);
|
||||
$this->assertEqual(json_decode($result), $data);
|
||||
|
||||
$data = array('my \\"string\\"');
|
||||
$result = $this->JsEngine->object($data);
|
||||
$this->assertEqual(json_decode($result), $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* test Mapping of options.
|
||||
*
|
||||
|
|
|
@ -117,7 +117,7 @@ class MediaViewTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testRenderWithUnknownFileTypeGeneric() {
|
||||
$currentUserAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||
$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Some generic browser';
|
||||
$this->MediaView->viewVars = array(
|
||||
'path' => LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS,
|
||||
|
@ -165,7 +165,9 @@ class MediaViewTest extends CakeTestCase {
|
|||
$output = ob_get_clean();
|
||||
$this->assertEqual("some_key = some_value\nbool_key = 1\n", $output);
|
||||
$this->assertTrue($result !== false);
|
||||
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
||||
if ($currentUserAgent !== null) {
|
||||
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,7 +177,7 @@ class MediaViewTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testRenderWithUnknownFileTypeOpera() {
|
||||
$currentUserAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||
$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10';
|
||||
$this->MediaView->viewVars = array(
|
||||
'path' => LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS,
|
||||
|
@ -228,7 +230,9 @@ class MediaViewTest extends CakeTestCase {
|
|||
$output = ob_get_clean();
|
||||
$this->assertEqual("some_key = some_value\nbool_key = 1\n", $output);
|
||||
$this->assertTrue($result !== false);
|
||||
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
||||
if ($currentUserAgent !== null) {
|
||||
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,7 +242,7 @@ class MediaViewTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testRenderWithUnknownFileTypeIE() {
|
||||
$currentUserAgent = $_SERVER['HTTP_USER_AGENT'];
|
||||
$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
|
||||
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Media Center PC 4.0; SLCC1; .NET CLR 3.0.04320)';
|
||||
$this->MediaView->viewVars = array(
|
||||
'path' => LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS,
|
||||
|
@ -291,7 +295,9 @@ class MediaViewTest extends CakeTestCase {
|
|||
$output = ob_get_clean();
|
||||
$this->assertEqual("some_key = some_value\nbool_key = 1\n", $output);
|
||||
$this->assertTrue($result !== false);
|
||||
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
||||
if ($currentUserAgent !== null) {
|
||||
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,4 +11,13 @@ echo __dn('domain', 'You have %d new message (domain).', 'You have %d new messag
|
|||
echo __dn('domain', 'You deleted %d message (domain).', 'You deleted %d messages (domain).', $messages['count']);
|
||||
|
||||
// Duplicated Message
|
||||
echo __('Editing this Page');
|
||||
echo __('Editing this Page');
|
||||
|
||||
// Multiline
|
||||
__('Hot features!'
|
||||
. "\n - No Configuration:"
|
||||
. ' Set-up the database and let the magic begin'
|
||||
. "\n - Extremely Simple:"
|
||||
. ' Just look at the name...It\'s Cake'
|
||||
. "\n - Active, Friendly Community:"
|
||||
. ' Join us #cakephp on IRC. We\'d love to help you get started');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue