mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '1.3-misc' of code.cakephp.org:cakephp into 1.3-misc
This commit is contained in:
commit
1795733eda
32 changed files with 418 additions and 514 deletions
|
@ -229,7 +229,7 @@ class BakeShell extends Shell {
|
|||
$this->out("\n\tbake model\n\t\tbakes a model. run 'bake model help' for more info");
|
||||
$this->out("\n\tbake view\n\t\tbakes views. run 'bake view help' for more info");
|
||||
$this->out("\n\tbake controller\n\t\tbakes a controller. run 'bake controller help' for more info");
|
||||
$this->out("");
|
||||
$this->out();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ class ConsoleShell extends Shell {
|
|||
$this->out("\t$field2: $value2");
|
||||
}
|
||||
|
||||
$this->out("");
|
||||
$this->out();
|
||||
} else {
|
||||
$this->out("\t$field: $value");
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ class ConsoleShell extends Shell {
|
|||
$this->out("\t$field2: $value2");
|
||||
}
|
||||
|
||||
$this->out("");
|
||||
$this->out();
|
||||
} else {
|
||||
$this->out("\t$field: $value");
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ class I18nShell extends Shell {
|
|||
$this->out(__('usage:', true));
|
||||
$this->out(' cake i18n help');
|
||||
$this->out(' cake i18n initdb [-datasource custom]');
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->hr();
|
||||
|
||||
$this->Extract->help();
|
||||
|
|
|
@ -372,7 +372,7 @@ class SchemaShell extends Shell {
|
|||
$this->out("\n" . __('The following statements will run.', true));
|
||||
$this->out(array_map('trim', $contents));
|
||||
if ('y' == $this->in(__('Are you sure you want to alter the tables?', true), array('y', 'n'), 'n')) {
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out(__('Updating Database...', true));
|
||||
$this->__run($contents, 'update', $Schema);
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ class SchemaShell extends Shell {
|
|||
$this->out("\n\tschema dump <filename>\n\t\tDump database sql based on schema file to <filename>. \n\t\tIf <filename> is write, schema dump will be written to a file\n\t\tthat has the same name as the app directory.");
|
||||
$this->out("\n\tschema run create <schema> <table>\n\t\tDrop and create tables based on schema file\n\t\toptional <schema> arg for selecting schema name\n\t\toptional <table> arg for creating only one table\n\t\tpass the -s param with a number to use a snapshot\n\t\tTo see the changes, perform a dry run with the -dry param");
|
||||
$this->out("\n\tschema run update <schema> <table>\n\t\talter tables based on schema file\n\t\toptional <schema> arg for selecting schema name.\n\t\toptional <table> arg for altering only one table.\n\t\tTo use a snapshot, pass the -s param with the snapshot number\n\t\tTo see the changes, perform a dry run with the -dry param");
|
||||
$this->out("");
|
||||
$this->out();
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@ class Shell extends Object {
|
|||
*/
|
||||
function __construct(&$dispatch) {
|
||||
$vars = array('params', 'args', 'shell', 'shellCommand' => 'command');
|
||||
|
||||
foreach ($vars as $key => $var) {
|
||||
if (is_string($key)) {
|
||||
$this->{$var} =& $dispatch->{$key};
|
||||
|
@ -205,8 +206,9 @@ class Shell extends Object {
|
|||
*/
|
||||
function _welcome() {
|
||||
$this->Dispatch->clear();
|
||||
$this->out("\nWelcome to CakePHP v" . Configure::version() . " Console");
|
||||
$this->out("---------------------------------------------------------------");
|
||||
$this->out();
|
||||
$this->out('Welcome to CakePHP v' . Configure::version() . ' Console');
|
||||
$this->hr();
|
||||
$this->out('App : '. $this->params['app']);
|
||||
$this->out('Path: '. $this->params['working']);
|
||||
$this->hr();
|
||||
|
@ -224,8 +226,8 @@ class Shell extends Object {
|
|||
$this->DbConfig =& new DATABASE_CONFIG();
|
||||
return true;
|
||||
}
|
||||
$this->err('Database config could not be loaded');
|
||||
$this->out('Run \'bake\' to create the database configuration');
|
||||
$this->err('Database config could not be loaded.');
|
||||
$this->out('Run `bake` to create the database configuration.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -296,7 +298,7 @@ class Shell extends Object {
|
|||
|
||||
if (!class_exists($taskClass)) {
|
||||
foreach ($this->Dispatch->shellPaths as $path) {
|
||||
$taskPath = $path . 'tasks' . DS . $task.'.php';
|
||||
$taskPath = $path . 'tasks' . DS . $task . '.php';
|
||||
if (file_exists($taskPath)) {
|
||||
require_once $taskPath;
|
||||
break;
|
||||
|
@ -320,7 +322,7 @@ class Shell extends Object {
|
|||
}
|
||||
|
||||
if (!isset($this->{$taskName})) {
|
||||
$this->err("Task '" . $taskName . "' could not be loaded");
|
||||
$this->err("Task `{$taskName}` could not be loaded");
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
|
@ -363,63 +365,58 @@ class Shell extends Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* Outputs a single or multiple messages to stdout.
|
||||
* Outputs a single or multiple messages to stdout. If no parameters
|
||||
* are passed outputs just a newline.
|
||||
*
|
||||
* @param mixed $message A string or a an array of strings to output
|
||||
* @param mixed $after Appended to message, if true a newline is used
|
||||
* @param integer $newlines Number of newlines to append
|
||||
* @access public
|
||||
*/
|
||||
function out($message, $after = true) {
|
||||
function out($message = null, $newlines = 1) {
|
||||
if (is_array($message)) {
|
||||
$message = implode($this->nl(), $message);
|
||||
}
|
||||
$this->Dispatch->stdout($message . $this->nl($after), false);
|
||||
$this->Dispatch->stdout($message . $this->nl($newlines), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a single or multiple error messages to stderr.
|
||||
* Outputs a single or multiple error messages to stderr. If no parameters
|
||||
* are passed outputs just a newline.
|
||||
*
|
||||
* @param mixed $message A string or a an array of strings to output
|
||||
* @param mixed $after Appended to message, if true a newline is used
|
||||
* @param integer $newlines Number of newlines to append
|
||||
* @access public
|
||||
*/
|
||||
function err($message, $after = true) {
|
||||
function err($message = null, $newlines = 1) {
|
||||
if (is_array($message)) {
|
||||
$message = implode($this->nl(), $message);
|
||||
}
|
||||
$this->Dispatch->stderr($message . $this->nl($after));
|
||||
$this->Dispatch->stderr($message . $this->nl($newlines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single or multiple linefeeds sequences.
|
||||
*
|
||||
* @param mixed $format If true returns a linefeed sequence, if false null,
|
||||
* if a string is given that is returned,
|
||||
* if an integer is given it is used as a multiplier to return multiple linefeed sequences
|
||||
* @param integer $multiplier Number of times the linefeed sequence should be repeated
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function nl($format = true) {
|
||||
if (is_string($format)) {
|
||||
return $format . "\n";
|
||||
}
|
||||
if (is_int($format)) {
|
||||
return str_repeat("\n", $format);
|
||||
}
|
||||
return $format ? "\n" : null;
|
||||
function nl($multiplier = 1) {
|
||||
return str_repeat("\n", $multiplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a series of minus characters to the standard output, acts as a visual separator.
|
||||
*
|
||||
* @param mixed $surround If true, the outputs gets surrounded by newlines.
|
||||
* @param integer $newlines Number of newlines to pre- and append
|
||||
* @access public
|
||||
*/
|
||||
function hr($surround = false) {
|
||||
$this->out(null, $surround);
|
||||
function hr($newlines = 0) {
|
||||
$this->out(null, $newlines);
|
||||
$this->out('---------------------------------------------------------------');
|
||||
$this->out(null, $surround);
|
||||
$this->out(null, $newlines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a formatted error message
|
||||
* and exits the application with status code 1
|
||||
|
@ -449,7 +446,11 @@ class Shell extends Object {
|
|||
$command = $this->command;
|
||||
}
|
||||
if (count($this->args) < $expectedNum) {
|
||||
$this->error("Wrong number of parameters: ".count($this->args), "Expected: {$expectedNum}\nPlease type 'cake {$this->shell} help' for help on usage of the {$this->name} {$command}");
|
||||
$message[] = "Got: " . count($this->args);
|
||||
$message[] = "Expected: {$expectedNum}";
|
||||
$message[] = "Please type `cake {$this->shell} help` for help";
|
||||
$message[] = "on usage of the {$this->name} {$command}.";
|
||||
$this->error('Wrong number of parameters', $message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,16 +462,21 @@ class Shell extends Object {
|
|||
* @return boolean Success
|
||||
* @access public
|
||||
*/
|
||||
function createFile ($path, $contents) {
|
||||
function createFile($path, $contents) {
|
||||
$path = str_replace(DS . DS, DS, $path);
|
||||
$this->out("\n" . sprintf(__("Creating file %s", true), $path));
|
||||
|
||||
$this->out();
|
||||
$this->out(sprintf(__("Creating file %s", true), $path));
|
||||
|
||||
if (is_file($path) && $this->interactive === true) {
|
||||
$key = $this->in(__("File exists, overwrite?", true). " {$path}", array('y', 'n', 'q'), 'n');
|
||||
$prompt = sprintf(__('File `%s` exists, overwrite?', true), $path);
|
||||
$key = $this->in($prompt, array('y', 'n', 'q'), 'n');
|
||||
|
||||
if (strtolower($key) == 'q') {
|
||||
$this->out(__("Quitting.", true) ."\n");
|
||||
exit;
|
||||
$this->out(__('Quitting.', true), 2);
|
||||
$this->_stop();
|
||||
} elseif (strtolower($key) != 'y') {
|
||||
$this->out(__("Skip", true) ." {$path}\n");
|
||||
$this->out(sprintf(__('Skip `%s`', true), $path), 2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -481,10 +487,10 @@ class Shell extends Object {
|
|||
if ($File = new File($path, true)) {
|
||||
$data = $File->prepare($contents);
|
||||
$File->write($data);
|
||||
$this->out(__("Wrote", true) ." {$path}");
|
||||
$this->out(sprintf(__('Wrote `%s`', true), $path));
|
||||
return true;
|
||||
} else {
|
||||
$this->err(__("Error! Could not write to", true)." {$path}.\n");
|
||||
$this->err(sprintf(__('Could not write to `%s`.', true), $path), 2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -496,7 +502,8 @@ class Shell extends Object {
|
|||
*/
|
||||
function help() {
|
||||
if ($this->command != null) {
|
||||
$this->err("Unknown {$this->name} command '$this->command'.\nFor usage, try 'cake {$this->shell} help'.\n\n");
|
||||
$this->err("Unknown {$this->name} command `{$this->command}`.");
|
||||
$this->err("For usage, try `cake {$this->shell} help`.", 2);
|
||||
} else {
|
||||
$this->Dispatch->help();
|
||||
}
|
||||
|
@ -512,11 +519,13 @@ class Shell extends Object {
|
|||
if (App::import('vendor', 'simpletest' . DS . 'simpletest')) {
|
||||
return true;
|
||||
}
|
||||
$unitTest = $this->in('SimpleTest is not installed. Do you want to bake unit test files anyway?', array('y','n'), 'y');
|
||||
$prompt = 'SimpleTest 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("\nYou can download SimpleTest from http://simpletest.org", true);
|
||||
$this->out();
|
||||
$this->out('You can download SimpleTest from http://simpletest.org');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -575,7 +584,7 @@ class Shell extends Object {
|
|||
* @access protected
|
||||
*/
|
||||
function _modelKey($name) {
|
||||
return Inflector::underscore(Inflector::singularize($name)).'_id';
|
||||
return Inflector::underscore(Inflector::singularize($name)) . '_id';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -586,8 +595,7 @@ class Shell extends Object {
|
|||
* @access protected
|
||||
*/
|
||||
function _modelNameFromKey($key) {
|
||||
$name = str_replace('_id', '',$key);
|
||||
return Inflector::camelize($name);
|
||||
return Inflector::camelize(str_replace('_id', '', $key));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -643,6 +651,7 @@ class Shell extends Object {
|
|||
function _pluginPath($pluginName) {
|
||||
$pluginPaths = App::path('plugins');
|
||||
$pluginDirName = Inflector::underscore($pluginName);
|
||||
|
||||
foreach ($pluginPaths as $path) {
|
||||
if (is_dir($path . $pluginDirName)) {
|
||||
return $path . $pluginDirName . DS ;
|
||||
|
|
|
@ -222,7 +222,7 @@ class ControllerTask extends Shell {
|
|||
* @return void
|
||||
**/
|
||||
function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) {
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->hr();
|
||||
$this->out(__('The following controller will be created:', true));
|
||||
$this->hr();
|
||||
|
@ -457,27 +457,27 @@ class ControllerTask extends Shell {
|
|||
$this->out("Usage: cake bake controller <arg1> <arg2>...");
|
||||
$this->hr();
|
||||
$this->out('Commands:');
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("controller <name>");
|
||||
$this->out("\tbakes controller with var \$scaffold");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("controller <name> public");
|
||||
$this->out("\tbakes controller with basic crud actions");
|
||||
$this->out("\t(index, view, add, edit, delete)");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("controller <name> admin");
|
||||
$this->out("\tbakes a controller with basic crud actions for");
|
||||
$this->out("\tConfigure::read('Routing.admin') methods.");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("controller <name> public admin");
|
||||
$this->out("\tbakes a controller with basic crud actions for");
|
||||
$this->out("\tConfigure::read('Routing.admin') and non admin methods.");
|
||||
$this->out("\t(index, view, add, edit, delete,");
|
||||
$this->out("\tadmin_index, admin_view, admin_edit, admin_add, admin_delete)");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("controller all");
|
||||
$this->out("\tbakes all controllers with CRUD methods.");
|
||||
$this->out("");
|
||||
$this->out();
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ class DbConfigTask extends Shell {
|
|||
function __verify($config) {
|
||||
$config = array_merge($this->__defaultConfig, $config);
|
||||
extract($config);
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->hr();
|
||||
$this->out('The following database configuration will be created:');
|
||||
$this->hr();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Short description for file.
|
||||
* Language string extractor
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
|
@ -21,73 +21,29 @@
|
|||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Only used when -debug option
|
||||
*/
|
||||
ob_start();
|
||||
|
||||
$singularReturn = __('Singular string return __()', true);
|
||||
$singularEcho = __('Singular string echo __()');
|
||||
|
||||
$pluralReturn = __n('% apple in the bowl (plural string return __n())', '% apples in the blowl (plural string 2 return __n())', 3, true);
|
||||
$pluralEcho = __n('% apple in the bowl (plural string 2 echo __n())', '% apples in the blowl (plural string 2 echo __n()', 3);
|
||||
|
||||
$singularDomainReturn = __d('controllers', 'Singular string domain lookup return __d()', true);
|
||||
$singularDomainEcho = __d('controllers', 'Singular string domain lookup echo __d()');
|
||||
|
||||
$pluralDomainReturn = __dn('controllers', '% pears in the bowl (plural string domain lookup return __dn())', '% pears in the blowl (plural string domain lookup return __dn())', 3, true);
|
||||
$pluralDomainEcho = __dn('controllers', '% pears in the bowl (plural string domain lookup echo __dn())', '% pears in the blowl (plural string domain lookup echo __dn())', 3);
|
||||
|
||||
$singularDomainCategoryReturn = __dc('controllers', 'Singular string domain and category lookup return __dc()', 5, true);
|
||||
$singularDomainCategoryEcho = __dc('controllers', 'Singular string domain and category lookup echo __dc()', 5);
|
||||
|
||||
$pluralDomainCategoryReturn = __dcn('controllers', '% apple in the bowl (plural string 1 domain and category lookup return __dcn())', '% apples in the blowl (plural string 2 domain and category lookup return __dcn())', 3, 5, true);
|
||||
$pluralDomainCategoryEcho = __dcn('controllers', '% apple in the bowl (plural string 1 domain and category lookup echo __dcn())', '% apples in the blowl (plural string 2 domain and category lookup echo __dcn())', 3, 5);
|
||||
|
||||
$categoryReturn = __c('Category string lookup line return __c()', 5, true);
|
||||
$categoryEcho = __c('Category string lookup line echo __c()', 5);
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
/**
|
||||
* Language string extractor
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.console.libs
|
||||
* @subpackage cake.cake.console.libs.tasks
|
||||
*/
|
||||
class ExtractTask extends Shell{
|
||||
class ExtractTask extends Shell {
|
||||
|
||||
/**
|
||||
* Path to use when looking for strings
|
||||
* Paths to use when looking for strings
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
* @access private
|
||||
*/
|
||||
var $path = null;
|
||||
var $__paths = array();
|
||||
|
||||
/**
|
||||
* Files from where to extract
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $files = array();
|
||||
|
||||
/**
|
||||
* Filename where to deposit translations
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $__filename = 'default';
|
||||
|
||||
/**
|
||||
* True if all strings should be merged into one file
|
||||
*
|
||||
* @var boolean
|
||||
* @access private
|
||||
*/
|
||||
var $__oneFile = true;
|
||||
var $__files = array();
|
||||
|
||||
/**
|
||||
* Current file being processed
|
||||
|
@ -97,6 +53,14 @@ class ExtractTask extends Shell{
|
|||
*/
|
||||
var $__file = null;
|
||||
|
||||
/**
|
||||
* Contains all content waiting to be write
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $__storage = array();
|
||||
|
||||
/**
|
||||
* Extracted tokens
|
||||
*
|
||||
|
@ -113,14 +77,6 @@ class ExtractTask extends Shell{
|
|||
*/
|
||||
var $__strings = array();
|
||||
|
||||
/**
|
||||
* History of file versions
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $__fileVersions = array();
|
||||
|
||||
/**
|
||||
* Destination path
|
||||
*
|
||||
|
@ -132,59 +88,57 @@ class ExtractTask extends Shell{
|
|||
/**
|
||||
* Execution method always used for tasks
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function execute() {
|
||||
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['path'])) {
|
||||
$this->path = $this->params['path'];
|
||||
if (isset($this->params['paths'])) {
|
||||
$this->__paths = explode(',', $this->params['paths']);
|
||||
} else {
|
||||
$response = '';
|
||||
while ($response == '') {
|
||||
$response = $this->in("What is the full path you would like to extract?\nExample: " . $this->params['root'] . DS . "myapp\n[Q]uit", null, $this->params['working']);
|
||||
$defaultPath = $this->params['working'];
|
||||
$message = sprintf(__("What is the full path you would like to extract?\nExample: %s\n[Q]uit [D]one", true), $this->params['root'] . DS . 'myapp');
|
||||
while (true) {
|
||||
$response = $this->in($message, null, $defaultPath);
|
||||
if (strtoupper($response) === 'Q') {
|
||||
$this->out('Extract Aborted');
|
||||
$this->out(__('Extract Aborted', true));
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
|
||||
if (is_dir($response)) {
|
||||
$this->path = $response;
|
||||
} elseif (strtoupper($response) === 'D') {
|
||||
$this->out();
|
||||
break;
|
||||
} elseif (is_dir($response)) {
|
||||
$this->__paths[] = $response;
|
||||
$defaultPath = 'D';
|
||||
} else {
|
||||
$this->err('The directory path you supplied was not found. Please try again.');
|
||||
$this->execute();
|
||||
$this->err(__('The directory path you supplied was not found. Please try again.', true));
|
||||
}
|
||||
$this->out();
|
||||
}
|
||||
|
||||
if (isset($this->params['debug'])) {
|
||||
$this->path = ROOT;
|
||||
$this->files = array(__FILE__);
|
||||
}
|
||||
|
||||
if (isset($this->params['output'])) {
|
||||
$this->__output = $this->params['output'];
|
||||
} else {
|
||||
$response = '';
|
||||
while ($response == '') {
|
||||
$response = $this->in("What is the full path you would like to output?\nExample: " . $this->path . DS . "locale\n[Q]uit", null, $this->path . DS . "locale");
|
||||
$message = sprintf(__("What is the full path you would like to output?\nExample: %s\n[Q]uit", true), $this->__paths[0] . DS . 'locale');
|
||||
while (true) {
|
||||
$response = $this->in($message, null, $this->__paths[0] . DS . 'locale');
|
||||
if (strtoupper($response) === 'Q') {
|
||||
$this->out('Extract Aborted');
|
||||
$this->out(__('Extract Aborted', true));
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
|
||||
if (is_dir($response)) {
|
||||
} elseif (is_dir($response)) {
|
||||
$this->__output = $response . DS;
|
||||
break;
|
||||
} else {
|
||||
$this->err('The directory path you supplied was not found. Please try again.');
|
||||
$this->execute();
|
||||
$this->err(__('The directory path you supplied was not found. Please try again.', true));
|
||||
}
|
||||
$this->out();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->files)) {
|
||||
$this->files = $this->__searchDirectory();
|
||||
if (empty($this->__files)) {
|
||||
$this->__searchFiles();
|
||||
}
|
||||
$this->__extract();
|
||||
}
|
||||
|
@ -192,39 +146,27 @@ class ExtractTask extends Shell{
|
|||
/**
|
||||
* Extract text
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function __extract() {
|
||||
$this->out('');
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out();
|
||||
$this->out(__('Extracting...', true));
|
||||
$this->hr();
|
||||
$this->out(__('Path: ', true). $this->path);
|
||||
$this->out(__('Output Directory: ', true). $this->__output);
|
||||
$this->out(__('Paths:', true));
|
||||
foreach ($this->__paths as $path) {
|
||||
$this->out(' ' . $path);
|
||||
}
|
||||
$this->out(__('Output Directory: ', true) . $this->__output);
|
||||
$this->hr();
|
||||
|
||||
$response = '';
|
||||
$filename = '';
|
||||
while ($response == '') {
|
||||
$response = $this->in(__('Would you like to merge all translations into one file?', true), array('y','n'), 'y');
|
||||
if (strtolower($response) == 'n') {
|
||||
$this->__oneFile = false;
|
||||
} else {
|
||||
while ($filename == '') {
|
||||
$filename = $this->in(__('What should we name this file?', true), null, $this->__filename);
|
||||
if ($filename == '') {
|
||||
$this->out(__('The filesname you supplied was empty. Please try again.', true));
|
||||
}
|
||||
}
|
||||
$this->__filename = $filename;
|
||||
}
|
||||
}
|
||||
$this->__extractTokens();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show help options
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function help() {
|
||||
|
@ -234,33 +176,31 @@ class ExtractTask extends Shell{
|
|||
$this->out(__('By default the .pot file(s) will be place in the locale directory of -app', true));
|
||||
$this->out(__('By default -app is ROOT/app', true));
|
||||
$this->hr();
|
||||
$this->out(__('usage: cake i18n extract [command] [path...]', true));
|
||||
$this->out('');
|
||||
$this->out(__('commands:', true));
|
||||
$this->out(__('Usage: cake i18n extract [command] [path...]', true));
|
||||
$this->out();
|
||||
$this->out(__('Commands:', true));
|
||||
$this->out(__(' -app [path...]: directory where your application is located', true));
|
||||
$this->out(__(' -root [path...]: path to install', true));
|
||||
$this->out(__(' -core [path...]: path to cake directory', true));
|
||||
$this->out(__(' -path [path...]: Full path to directory to extract strings', true));
|
||||
$this->out(__(' -paths [comma separated list of paths, full path is needed]', true));
|
||||
$this->out(__(' -output [path...]: Full path to output directory', true));
|
||||
$this->out(__(' -files: [comma separated list of files, full path to file is needed]', true));
|
||||
$this->out(__(' cake i18n extract help: Shows this help message.', true));
|
||||
$this->out(__(' -debug: Perform self test.', true));
|
||||
$this->out('');
|
||||
$this->out();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract tokens out of all files to be processed
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function __extractTokens() {
|
||||
foreach ($this->files as $file) {
|
||||
foreach ($this->__files as $file) {
|
||||
$this->__file = $file;
|
||||
$this->out(sprintf(__('Processing %s...', true), $file));
|
||||
|
||||
$code = file_get_contents($file);
|
||||
|
||||
$this->__findVersion($code, $file);
|
||||
$allTokens = token_get_all($code);
|
||||
$this->__tokens = array();
|
||||
$lineNumber = 1;
|
||||
|
@ -290,7 +230,8 @@ class ExtractTask extends Shell{
|
|||
}
|
||||
$this->__buildFiles();
|
||||
$this->__writeFiles();
|
||||
$this->out('Done.');
|
||||
$this->out();
|
||||
$this->out(__('Done.', true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,7 +239,8 @@ 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)
|
||||
* @access public
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function __parse($functionName, $map) {
|
||||
$count = 0;
|
||||
|
@ -336,19 +278,14 @@ class ExtractTask extends Shell{
|
|||
|
||||
if ($mapCount == count($strings)) {
|
||||
extract(array_combine($map, $strings));
|
||||
if ($this->__oneFile === true) {
|
||||
if (!isset($domain)) {
|
||||
$domain = '\'default\'';
|
||||
}
|
||||
$string = $this->__formatString($singular);
|
||||
if (isset($plural)) {
|
||||
$this->__strings[$this->__formatString($singular) . "\0" . $this->__formatString($plural)][$this->__file][] = $line;
|
||||
} else {
|
||||
$this->__strings[$this->__formatString($singular)][$this->__file][] = $line;
|
||||
}
|
||||
} else {
|
||||
if ($plural) {
|
||||
$this->__strings[$this->__file][$this->__formatString($singular) . "\0" . $this->__formatString($plural)][] = $line;
|
||||
} else {
|
||||
$this->__strings[$this->__file][$this->__formatString($singular)][] = $line;
|
||||
}
|
||||
$string .= "\0" . $this->__formatString($plural);
|
||||
}
|
||||
$this->__strings[$this->__formatString($domain)][$string][$this->__file][] = $line;
|
||||
} else {
|
||||
$this->__markerError($this->__file, $line, $functionName, $count);
|
||||
}
|
||||
|
@ -360,170 +297,89 @@ class ExtractTask extends Shell{
|
|||
/**
|
||||
* Build the translate template file contents out of obtained strings
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function __buildFiles() {
|
||||
foreach ($this->__strings as $str => $fileInfo) {
|
||||
$output = '';
|
||||
$occured = $fileList = array();
|
||||
|
||||
if ($this->__oneFile === true) {
|
||||
foreach ($fileInfo as $file => $lines) {
|
||||
$occured[] = "$file:" . join(';', $lines);
|
||||
|
||||
if (isset($this->__fileVersions[$file])) {
|
||||
$fileList[] = $this->__fileVersions[$file];
|
||||
foreach ($this->__strings as $domain => $strings) {
|
||||
foreach ($strings as $string => $files) {
|
||||
$occurances = array();
|
||||
foreach ($files as $file => $lines) {
|
||||
$occurances[] = $file . ':' . implode(';', $lines);
|
||||
}
|
||||
}
|
||||
$occurances = join("\n#: ", $occured);
|
||||
$occurances = str_replace($this->path, '', $occurances);
|
||||
$output = "#: $occurances\n";
|
||||
$filename = $this->__filename;
|
||||
$occurances = implode("\n#: ", $occurances);
|
||||
$header = '#: ' . str_replace($this->__paths, '', $occurances) . "\n";
|
||||
|
||||
if (strpos($str, "\0") === false) {
|
||||
$output .= "msgid \"$str\"\n";
|
||||
$output .= "msgstr \"\"\n";
|
||||
if (strpos($string, "\0") === false) {
|
||||
$sentence = "msgid \"{$string}\"\n";
|
||||
$sentence .= "msgstr \"\"\n\n";
|
||||
} else {
|
||||
list($singular, $plural) = explode("\0", $str);
|
||||
$output .= "msgid \"$singular\"\n";
|
||||
$output .= "msgid_plural \"$plural\"\n";
|
||||
$output .= "msgstr[0] \"\"\n";
|
||||
$output .= "msgstr[1] \"\"\n";
|
||||
list($singular, $plural) = explode("\0", $string);
|
||||
$sentence = "msgid \"{$singular}\"\n";
|
||||
$sentence .= "msgid_plural \"{$plural}\"\n";
|
||||
$sentence .= "msgstr[0] \"\"\n";
|
||||
$sentence .= "msgstr[1] \"\"\n\n";
|
||||
}
|
||||
$output .= "\n";
|
||||
} else {
|
||||
foreach ($fileInfo as $file => $lines) {
|
||||
$filename = $str;
|
||||
$occured = array("$str:" . join(';', $lines));
|
||||
|
||||
if (isset($this->__fileVersions[$str])) {
|
||||
$fileList[] = $this->__fileVersions[$str];
|
||||
}
|
||||
$occurances = join("\n#: ", $occured);
|
||||
$occurances = str_replace($this->path, '', $occurances);
|
||||
$output .= "#: $occurances\n";
|
||||
|
||||
if (strpos($file, "\0") === false) {
|
||||
$output .= "msgid \"$file\"\n";
|
||||
$output .= "msgstr \"\"\n";
|
||||
} else {
|
||||
list($singular, $plural) = explode("\0", $file);
|
||||
$output .= "msgid \"$singular\"\n";
|
||||
$output .= "msgid_plural \"$plural\"\n";
|
||||
$output .= "msgstr[0] \"\"\n";
|
||||
$output .= "msgstr[1] \"\"\n";
|
||||
}
|
||||
$output .= "\n";
|
||||
$this->__store($domain, $header, $sentence);
|
||||
if ($domain != 'default') {
|
||||
$this->__store('default', $header, $sentence);
|
||||
}
|
||||
}
|
||||
$this->__store($filename, $output, $fileList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare a file to be stored
|
||||
*
|
||||
* @param string $file Filename
|
||||
* @param string $input What to store
|
||||
* @param array $fileList File list
|
||||
* @param integer $get Set to 1 to get files to store, false to set
|
||||
* @return mixed If $get == 1, files to store, otherwise void
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function __store($file = 0, $input = 0, $fileList = array(), $get = 0) {
|
||||
static $storage = array();
|
||||
|
||||
if (!$get) {
|
||||
if (isset($storage[$file])) {
|
||||
$storage[$file][1] = array_unique(array_merge($storage[$file][1], $fileList));
|
||||
$storage[$file][] = $input;
|
||||
} else {
|
||||
$storage[$file] = array();
|
||||
$storage[$file][0] = $this->__writeHeader();
|
||||
$storage[$file][1] = $fileList;
|
||||
$storage[$file][2] = $input;
|
||||
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;
|
||||
} else {
|
||||
return $storage;
|
||||
$this->__storage[$domain][$sentence] .= $header;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the files that need to be stored
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function __writeFiles() {
|
||||
$output = $this->__store(0, 0, array(), 1);
|
||||
$output = $this->__mergeFiles($output);
|
||||
|
||||
foreach ($output as $file => $content) {
|
||||
$tmp = str_replace(array($this->path, '.php','.ctp','.thtml', '.inc','.tpl' ), '', $file);
|
||||
$tmp = str_replace(DS, '.', $tmp);
|
||||
$file = str_replace('.', '-', $tmp) .'.pot';
|
||||
$fileList = $content[1];
|
||||
|
||||
unset($content[1]);
|
||||
|
||||
$fileList = str_replace(array($this->path), '', $fileList);
|
||||
|
||||
if (count($fileList) > 1) {
|
||||
$fileList = "Generated from files:\n# " . join("\n# ", $fileList);
|
||||
} elseif (count($fileList) == 1) {
|
||||
$fileList = 'Generated from file: ' . join('', $fileList);
|
||||
} else {
|
||||
$fileList = 'No version information was available in the source files.';
|
||||
foreach ($this->__storage as $domain => $sentences) {
|
||||
$output = $this->__writeHeader();
|
||||
foreach ($sentences as $sentence => $header) {
|
||||
$output .= $header . $sentence;
|
||||
}
|
||||
|
||||
if (is_file($this->__output . $file)) {
|
||||
$filename = $domain . '.pot';
|
||||
$File = new File($this->__output . $filename);
|
||||
if ($File->exists()) {
|
||||
$response = '';
|
||||
while ($response == '') {
|
||||
$response = $this->in("\n\nError: ".$file . ' already exists in this location. Overwrite?', array('y','n', 'q'), 'n');
|
||||
if (strtoupper($response) === 'Q') {
|
||||
$this->out('Extract Aborted');
|
||||
$this->_stop();
|
||||
} elseif (strtoupper($response) === 'N') {
|
||||
$this->out();
|
||||
$response = $this->in(sprintf(__('Error: %s already exists in this location. Overwrite?', true), $filename), array('y', 'n'), 'y');
|
||||
if (strtoupper($response) === 'N') {
|
||||
$response = '';
|
||||
while ($response == '') {
|
||||
$response = $this->in("What would you like to name this file?\nExample: new_" . $file, null, "new_" . $file);
|
||||
$file = $response;
|
||||
$response = $this->in(sprintf(__("What would you like to name this file?\nExample: %s", true), 'new_' . $filename), null, 'new_' . $filename);
|
||||
$File = new File($this->__output . $response);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$fp = fopen($this->__output . $file, 'w');
|
||||
fwrite($fp, str_replace('--VERSIONS--', $fileList, join('', $content)));
|
||||
fclose($fp);
|
||||
$File->write($output);
|
||||
$File->close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge output files
|
||||
*
|
||||
* @param array $output Output to merge
|
||||
* @return array Merged output
|
||||
* @access private
|
||||
*/
|
||||
function __mergeFiles($output) {
|
||||
foreach ($output as $file => $content) {
|
||||
if (count($content) <= 1 && $file != $this->__filename) {
|
||||
@$output[$this->__filename][1] = array_unique(array_merge($output[$this->__filename][1], $content[1]));
|
||||
|
||||
if (!isset($output[$this->__filename][0])) {
|
||||
$output[$this->__filename][0] = $content[0];
|
||||
}
|
||||
unset($content[0]);
|
||||
unset($content[1]);
|
||||
|
||||
foreach ($content as $msgid) {
|
||||
$output[$this->__filename][] = $msgid;
|
||||
}
|
||||
unset($output[$file]);
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the translation template header
|
||||
*
|
||||
|
@ -533,7 +389,6 @@ class ExtractTask extends Shell{
|
|||
function __writeHeader() {
|
||||
$output = "# LANGUAGE translation of CakePHP Application\n";
|
||||
$output .= "# Copyright YEAR NAME <EMAIL@ADDRESS>\n";
|
||||
$output .= "# --VERSIONS--\n";
|
||||
$output .= "#\n";
|
||||
$output .= "#, fuzzy\n";
|
||||
$output .= "msgid \"\"\n";
|
||||
|
@ -550,21 +405,6 @@ class ExtractTask extends Shell{
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the version number of a file looking for SVN commands
|
||||
*
|
||||
* @param string $code Source code of file
|
||||
* @param string $file File
|
||||
* @access private
|
||||
*/
|
||||
function __findVersion($code, $file) {
|
||||
$header = '$Id' . ':';
|
||||
if (preg_match('/\\' . $header . ' [\\w.]* ([\\d]*)/', $code, $versionInfo)) {
|
||||
$version = str_replace(ROOT, '', 'Revision: ' . $versionInfo[1] . ' ' .$file);
|
||||
$this->__fileVersions[$file] = $version;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a string to be added as a translateable string
|
||||
*
|
||||
|
@ -591,10 +431,11 @@ class ExtractTask extends Shell{
|
|||
* @param integer $line Line number
|
||||
* @param string $marker Marker found
|
||||
* @param integer $count Count
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function __markerError($file, $line, $marker, $count) {
|
||||
$this->out("Invalid marker content in $file:$line\n* $marker(", true);
|
||||
$this->out(sprintf(__("Invalid marker content in %s:%s\n* %s(", true), $file, $line, $marker), true);
|
||||
$count += 2;
|
||||
$tokenCount = count($this->__tokens);
|
||||
$parenthesis = 1;
|
||||
|
@ -618,31 +459,17 @@ class ExtractTask extends Shell{
|
|||
}
|
||||
|
||||
/**
|
||||
* Search the specified path for files that may contain translateable strings
|
||||
* Search files that may contain translateable strings
|
||||
*
|
||||
* @param string $path Path (or set to null to use current)
|
||||
* @return array Files
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
function __searchDirectory($path = null) {
|
||||
if ($path === null) {
|
||||
$path = $this->path .DS;
|
||||
function __searchFiles() {
|
||||
foreach ($this->__paths as $path) {
|
||||
$Folder = new Folder($path);
|
||||
$files = $Folder->findRecursive('.*\.(php|ctp|thtml|inc|tpl)', true);
|
||||
$this->__files += $files;
|
||||
}
|
||||
$files = glob("$path*.{php,ctp,thtml,inc,tpl}", GLOB_BRACE);
|
||||
$dirs = glob("$path*", GLOB_ONLYDIR);
|
||||
|
||||
$files = $files ? $files : array();
|
||||
$dirs = $dirs ? $dirs : array();
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
if (!preg_match("!(^|.+/)(CVS|.svn)$!", $dir)) {
|
||||
$files = array_merge($files, $this->__searchDirectory("$dir" . DS));
|
||||
if (($id = array_search($dir . DS . 'extract.php', $files)) !== FALSE) {
|
||||
unset($files[$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -423,12 +423,12 @@ class FixtureTask extends Shell {
|
|||
$this->out('Commands:');
|
||||
$this->out("\nfixture <name>\n\tbakes fixture with specified name.");
|
||||
$this->out("\nfixture all\n\tbakes all fixtures.");
|
||||
$this->out("");
|
||||
$this->out();
|
||||
$this->out('Parameters:');
|
||||
$this->out("\t-count When using generated data, the number of records to include in the fixture(s).");
|
||||
$this->out("\t-connection Which database configuration to use for baking.");
|
||||
$this->out("\t-plugin CamelCased name of plugin to bake fixtures for.");
|
||||
$this->out("");
|
||||
$this->out();
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ class ModelTask extends Shell {
|
|||
$associations = $this->doAssociations($tempModel);
|
||||
}
|
||||
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->hr();
|
||||
$this->out(__('The following Model will be created:', true));
|
||||
$this->hr();
|
||||
|
@ -379,7 +379,7 @@ class ModelTask extends Shell {
|
|||
$anotherValidator = 'y';
|
||||
while ($anotherValidator == 'y') {
|
||||
if ($this->interactive) {
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out(sprintf(__('Field: %s', true), $fieldName));
|
||||
$this->out(sprintf(__('Type: %s', true), $metaData['type']));
|
||||
$this->hr();
|
||||
|
@ -801,7 +801,7 @@ class ModelTask extends Shell {
|
|||
$tableIsGood = 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'", true), $modelName, $fullTableName));
|
||||
$tableIsGood = $this->in(__('Do you want to use this table?', true), array('y','n'), 'y');
|
||||
}
|
||||
|
@ -883,16 +883,16 @@ class ModelTask extends Shell {
|
|||
$this->out("Usage: cake bake model <arg1>");
|
||||
$this->hr();
|
||||
$this->out('Commands:');
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("model");
|
||||
$this->out("\tbakes model in interactive mode.");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("model <name>");
|
||||
$this->out("\tbakes model file with no associations or validation");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("model all");
|
||||
$this->out("\tbakes all model files with associations and validation");
|
||||
$this->out("");
|
||||
$this->out();
|
||||
$this->_stop();
|
||||
}
|
||||
|
||||
|
|
|
@ -232,19 +232,19 @@ class PluginTask extends Shell {
|
|||
$this->out("Usage: cake bake plugin <arg1> <arg2>...");
|
||||
$this->hr();
|
||||
$this->out('Commands:');
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("plugin <name>");
|
||||
$this->out("\tbakes plugin directory structure");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("plugin <name> model");
|
||||
$this->out("\tbakes model. Run 'cake bake model help' for more info.");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("plugin <name> controller");
|
||||
$this->out("\tbakes controller. Run 'cake bake controller help' for more info.");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("plugin <name> view");
|
||||
$this->out("\tbakes view. Run 'cake bake view help' for more info.");
|
||||
$this->out("");
|
||||
$this->out();
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,11 +309,11 @@ class ProjectTask extends Shell {
|
|||
$this->out("Usage: cake bake project <arg1>");
|
||||
$this->hr();
|
||||
$this->out('Commands:');
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("project <name>");
|
||||
$this->out("\tbakes app directory structure.");
|
||||
$this->out("\tif <name> begins with '/' path is absolute.");
|
||||
$this->out("");
|
||||
$this->out();
|
||||
$this->_stop();
|
||||
}
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ class ViewTask extends Shell {
|
|||
$this->bakeActions($adminActions, $vars);
|
||||
}
|
||||
$this->hr();
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out(__("View Scaffolding Complete.\n", true));
|
||||
} else {
|
||||
$this->customAction();
|
||||
|
@ -330,7 +330,7 @@ class ViewTask extends Shell {
|
|||
$this->out(__('The action name you supplied was empty. Please try again.', true));
|
||||
}
|
||||
}
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->hr();
|
||||
$this->out(__('The following view will be created:', true));
|
||||
$this->hr();
|
||||
|
@ -425,7 +425,7 @@ class ViewTask extends Shell {
|
|||
$this->out("Usage: cake bake view <arg1> <arg2>...");
|
||||
$this->hr();
|
||||
$this->out('Commands:');
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("view <controller>");
|
||||
$this->out("\tWill read the given controller for methods");
|
||||
$this->out("\tand bake corresponding views.");
|
||||
|
@ -433,14 +433,14 @@ class ViewTask extends Shell {
|
|||
$this->out("\tthat begin with Routing.admin.");
|
||||
$this->out("\tIf var scaffold is found it will bake the CRUD actions");
|
||||
$this->out("\t(index,view,add,edit)");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("view <controller> <action>");
|
||||
$this->out("\tWill bake a template. core templates: (index, add, edit, view)");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("view <controller> <template> <alias>");
|
||||
$this->out("\tWill use the template specified");
|
||||
$this->out("\tbut name the file based on the alias");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("view all");
|
||||
$this->out("\tBake all CRUD action views for all controllers.");
|
||||
$this->out("\tRequires that models and controllers exist.");
|
||||
|
|
|
@ -170,28 +170,28 @@ class TestSuiteShell extends Shell {
|
|||
$this->out("\t\t- category - \"app\", \"core\" or name of a plugin");
|
||||
$this->out("\t\t- test_type - \"case\", \"group\" or \"all\"");
|
||||
$this->out("\t\t- test_file - file name with folder prefix and without the (test|group).php suffix");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out('Examples: ');
|
||||
$this->out("\t\tcake testsuite app all");
|
||||
$this->out("\t\tcake testsuite core all");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("\t\tcake testsuite app case behaviors/debuggable");
|
||||
$this->out("\t\tcake testsuite app case models/my_model");
|
||||
$this->out("\t\tcake testsuite app case controllers/my_controller");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("\t\tcake testsuite core case file");
|
||||
$this->out("\t\tcake testsuite core case router");
|
||||
$this->out("\t\tcake testsuite core case set");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("\t\tcake testsuite app group mygroup");
|
||||
$this->out("\t\tcake testsuite core group acl");
|
||||
$this->out("\t\tcake testsuite core group socket");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out("\t\tcake testsuite bugs case models/bug");
|
||||
$this->out("\t\t // for the plugin 'bugs' and its test case 'models/bug'");
|
||||
$this->out("\t\tcake testsuite bugs group bug");
|
||||
$this->out("\t\t // for the plugin bugs and its test group 'bug'");
|
||||
$this->out('');
|
||||
$this->out();
|
||||
$this->out('Code Coverage Analysis: ');
|
||||
$this->out("\n\nAppend 'cov' to any of the above in order to enable code coverage analysis");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Session class for Cake.
|
||||
*
|
||||
|
@ -12,20 +10,17 @@
|
|||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
|
||||
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs
|
||||
* @since CakePHP(tm) v .0.10.0.1222
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
|
@ -243,6 +238,17 @@ class CakeSession extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a variable from the session
|
||||
*
|
||||
* @return boolean
|
||||
* @deprecated Use CakeSession::delete instead
|
||||
**/
|
||||
function del($name) {
|
||||
trigger_error('CakeSession::del() is deprecated, use CakeSession::delete() instead.', E_USER_WARNING);
|
||||
return $this->delete($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a variable from session.
|
||||
*
|
||||
|
@ -250,7 +256,7 @@ class CakeSession extends Object {
|
|||
* @return boolean Success
|
||||
* @access public
|
||||
*/
|
||||
function del($name) {
|
||||
function delete($name) {
|
||||
if ($this->check($name)) {
|
||||
if ($var = $this->__validateKeys($name)) {
|
||||
if (in_array($var, $this->watchKeys)) {
|
||||
|
|
|
@ -183,7 +183,7 @@ class SessionComponent extends CakeSession {
|
|||
function delete($name) {
|
||||
if ($this->__active === true) {
|
||||
$this->__start();
|
||||
return parent::del($name);
|
||||
return parent::delete($name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -909,17 +909,18 @@ class Controller extends Object {
|
|||
* @param string $message Message to display to the user
|
||||
* @param mixed $url Relative string or array-based URL to redirect to after the time expires
|
||||
* @param integer $pause Time to show the message
|
||||
* @param string $layout Layout you want to use, defaults to 'flash'
|
||||
* @return void Renders flash layout
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/426/flash
|
||||
*/
|
||||
function flash($message, $url, $pause = 1) {
|
||||
function flash($message, $url, $pause = 1, $layout = 'flash') {
|
||||
$this->autoRender = false;
|
||||
$this->set('url', Router::url($url));
|
||||
$this->set('message', $message);
|
||||
$this->set('pause', $pause);
|
||||
$this->set('page_title', $message);
|
||||
$this->render(false, 'flash');
|
||||
$this->render(false, $layout);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -386,7 +386,7 @@ class Scaffold extends Object {
|
|||
$this->controller->Session->setFlash($message);
|
||||
$this->controller->redirect($this->redirect);
|
||||
} else {
|
||||
$this->controller->flash($message, '/' . Inflector::underscore($this->controller->viewPath));
|
||||
$this->controller->flash($message, $this->redirect);
|
||||
return $this->_output();
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ class Scaffold extends Object {
|
|||
$this->controller->Session->setFlash($message);
|
||||
$this->controller->redirect($this->redirect);
|
||||
} else {
|
||||
$this->controller->flash($message, '/' . $this->viewPath);
|
||||
$this->controller->flash($message, $this->redirect);
|
||||
return $this->_output();
|
||||
}
|
||||
} else {
|
||||
|
@ -411,7 +411,7 @@ class Scaffold extends Object {
|
|||
$this->controller->Session->setFlash($message);
|
||||
$this->controller->redirect($this->redirect);
|
||||
} else {
|
||||
$this->controller->flash($message, '/' . $this->viewPath);
|
||||
$this->controller->flash($message, $this->redirect);
|
||||
return $this->_output();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -369,6 +369,52 @@ class DboMysqlBase extends DboSource {
|
|||
$values = implode(', ', $values);
|
||||
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}");
|
||||
}
|
||||
/**
|
||||
* Returns an detailed array of sources (tables) in the database.
|
||||
*
|
||||
* @param string $name Table name to get parameters
|
||||
* @return array Array of tablenames in the database
|
||||
*/
|
||||
function listDetailedSources($name = null) {
|
||||
$condition = '';
|
||||
if (is_string($name)) {
|
||||
$condition = ' WHERE Name = ' . $this->value($name);
|
||||
}
|
||||
$result = $this->query('SHOW TABLE STATUS FROM ' . $this->name($this->config['database']) . $condition . ';');
|
||||
if (!$result) {
|
||||
return array();
|
||||
} else {
|
||||
$tables = array();
|
||||
foreach ($result as $row) {
|
||||
$tables[$row['TABLES']['Name']] = $row['TABLES'];
|
||||
if (!empty($row['TABLES']['Collation'])) {
|
||||
$charset = $this->getCharsetName($row['TABLES']['Collation']);
|
||||
if ($charset) {
|
||||
$tables[$row['TABLES']['Name']]['charset'] = $charset;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_string($name)) {
|
||||
return $tables[$name];
|
||||
}
|
||||
return $tables;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Query charset by collation
|
||||
*
|
||||
* @param string $name Collation name
|
||||
* @return string Character set name
|
||||
*/
|
||||
function getCharsetName($name) {
|
||||
$cols = $this->query('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME= ' . $this->value($name) . ';');
|
||||
if (isset($cols[0]['COLLATIONS']['CHARACTER_SET_NAME'])) {
|
||||
return $cols[0]['COLLATIONS']['CHARACTER_SET_NAME'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -481,38 +527,6 @@ class DboMysql extends DboMysqlBase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an detailed array of sources (tables) in the database.
|
||||
*
|
||||
* @param string $name Table name to get parameters
|
||||
* @return array Array of tablenames in the database
|
||||
*/
|
||||
function listDetailedSources($name = null) {
|
||||
$condition = '';
|
||||
if (is_string($name)) {
|
||||
$condition = ' WHERE Name=' . $this->value($name);
|
||||
}
|
||||
$result = $this->query('SHOW TABLE STATUS FROM ' . $this->name($this->config['database']) . $condition . ';');
|
||||
if (!$result) {
|
||||
return array();
|
||||
} else {
|
||||
$tables = array();
|
||||
foreach ($result as $row) {
|
||||
$tables[$row['TABLES']['Name']] = $row['TABLES'];
|
||||
if (!empty($row['TABLES']['Collation'])) {
|
||||
$charset = $this->getCharsetName($row['TABLES']['Collation']);
|
||||
if ($charset) {
|
||||
$tables[$row['TABLES']['Name']]['charset'] = $charset;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_string($name)) {
|
||||
return $tables[$name];
|
||||
}
|
||||
return $tables;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the fields in given table name.
|
||||
*
|
||||
|
@ -559,20 +573,6 @@ class DboMysql extends DboMysqlBase {
|
|||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query charset by collation
|
||||
*
|
||||
* @param string $name Collation name
|
||||
* @return string Character set name
|
||||
*/
|
||||
function getCharsetName($name) {
|
||||
$cols = $this->query('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME= ' . $this->value($name) . ';');
|
||||
if (isset($cols[0]['COLLATIONS']['CHARACTER_SET_NAME'])) {
|
||||
return $cols[0]['COLLATIONS']['CHARACTER_SET_NAME'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a quoted and escaped string of $data for use in an SQL statement.
|
||||
*
|
||||
|
|
|
@ -2547,6 +2547,13 @@ class Model extends Overloadable {
|
|||
$valid = $Validation->dispatchMethod($rule, $ruleParams);
|
||||
} elseif (!is_array($validator['rule'])) {
|
||||
$valid = preg_match($rule, $data[$fieldName]);
|
||||
} elseif (Configure::read('debug') > 0) {
|
||||
$error = sprintf(
|
||||
__('Could not find validation handler %s for %s', true),
|
||||
$rule,
|
||||
$fieldName
|
||||
);
|
||||
trigger_error($error, E_USER_WARNING);
|
||||
}
|
||||
|
||||
if (!$valid || (is_string($valid) && strlen($valid) > 0)) {
|
||||
|
|
|
@ -177,10 +177,10 @@ class Router {
|
|||
**/
|
||||
function __setPrefixes() {
|
||||
$routing = Configure::read('Routing');
|
||||
if (isset($routing['admin'])) {
|
||||
if (!empty($routing['admin'])) {
|
||||
$this->__prefixes[] = $routing['admin'];
|
||||
}
|
||||
if (isset($routing['prefixes'])) {
|
||||
if (!empty($routing['prefixes'])) {
|
||||
$this->__prefixes = array_merge($this->__prefixes, (array)$routing['prefixes']);
|
||||
}
|
||||
}
|
||||
|
@ -899,9 +899,7 @@ class Router {
|
|||
|
||||
// Remove this once parsed URL parameters can be inserted into 'pass'
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($i === 0 && is_numeric($keys[$i]) && in_array('id', $keys)) {
|
||||
$args[0] = $url[$keys[$i]];
|
||||
} elseif (is_numeric($keys[$i]) || $keys[$i] === 'id') {
|
||||
if (is_numeric($keys[$i])) {
|
||||
$args[] = $url[$keys[$i]];
|
||||
} else {
|
||||
$named[$keys[$i]] = $url[$keys[$i]];
|
||||
|
@ -1413,7 +1411,7 @@ class Router {
|
|||
if ((!isset($options['named']) || !empty($options['named'])) && $separatorIsPresent) {
|
||||
list($key, $val) = explode($_this->named['separator'], $param, 2);
|
||||
$hasRule = isset($rules[$key]);
|
||||
$passIt = (!$hasRule && !$greedy) || ($hasRule && !Router::matchNamed($key, $val, $rules[$key], $context));
|
||||
$passIt = (!$hasRule && !$greedy) || ($hasRule && !$_this->matchNamed($key, $val, $rules[$key], $context));
|
||||
if ($passIt) {
|
||||
$pass[] = $param;
|
||||
} else {
|
||||
|
|
|
@ -198,7 +198,7 @@ class FormHelper extends AppHelper {
|
|||
'plugin' => $this->plugin,
|
||||
'controller' => $view->viewPath,
|
||||
'action' => $options['action'],
|
||||
'id' => $id
|
||||
0 => $id
|
||||
);
|
||||
if (!empty($options['action']) && !isset($options['id'])) {
|
||||
$options['id'] = $model . Inflector::camelize($options['action']) . 'Form';
|
||||
|
|
|
@ -150,7 +150,7 @@ class SessionHelper extends CakeSession {
|
|||
$out = $view->element($flash['element'], $tmpVars);
|
||||
}
|
||||
echo($out);
|
||||
parent::del('Message.' . $key);
|
||||
parent::delete('Message.' . $key);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,7 +235,11 @@ class ShellTest extends CakeTestCase {
|
|||
|
||||
$this->Shell->Dispatch->expectAt(2, 'stdout', array("Just\na\ntest\n\n", false));
|
||||
$this->Shell->out(array('Just', 'a', 'test'), 2);
|
||||
|
||||
$this->Shell->Dispatch->expectAt(3, 'stdout', array("\n", false));
|
||||
$this->Shell->out();
|
||||
}
|
||||
|
||||
/**
|
||||
* testErr method
|
||||
*
|
||||
|
@ -251,7 +255,11 @@ class ShellTest extends CakeTestCase {
|
|||
|
||||
$this->Shell->Dispatch->expectAt(2, 'stderr', array("Just\na\ntest\n\n"));
|
||||
$this->Shell->err(array('Just', 'a', 'test'), 2);
|
||||
|
||||
$this->Shell->Dispatch->expectAt(3, 'stderr', array("\n"));
|
||||
$this->Shell->err();
|
||||
}
|
||||
|
||||
/**
|
||||
* testNl
|
||||
*
|
||||
|
@ -264,8 +272,8 @@ class ShellTest extends CakeTestCase {
|
|||
$this->assertEqual($this->Shell->nl(false), "");
|
||||
$this->assertEqual($this->Shell->nl(2), "\n\n");
|
||||
$this->assertEqual($this->Shell->nl(1), "\n");
|
||||
$this->assertEqual($this->Shell->nl("custom"), "custom\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* testHr
|
||||
*
|
||||
|
@ -290,6 +298,7 @@ class ShellTest extends CakeTestCase {
|
|||
$this->Shell->Dispatch->expectAt(5, 'stdout', array("\n\n", false));
|
||||
$this->Shell->hr(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* testError
|
||||
*
|
||||
|
@ -308,6 +317,7 @@ class ShellTest extends CakeTestCase {
|
|||
$this->Shell->error('Foo Not Found', 'Searched all...');
|
||||
$this->assertIdentical($this->Shell->stopped, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* testLoadTasks method
|
||||
*
|
||||
|
|
|
@ -84,15 +84,12 @@ class ExtractTaskTest extends CakeTestCase {
|
|||
* @access public
|
||||
*/
|
||||
function testExecute() {
|
||||
$path = TMP . 'extract_task_test';
|
||||
$folder1 = $path . DS . 'locale';
|
||||
|
||||
new Folder($path, true);
|
||||
new Folder($folder1, true);
|
||||
$path = TMP . 'tests' . DS . 'extract_task_test';
|
||||
new Folder($path . DS . 'locale', true);
|
||||
|
||||
$this->Task->interactive = false;
|
||||
|
||||
$this->Task->params['path'] = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages';
|
||||
$this->Task->params['paths'] = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages';
|
||||
$this->Task->params['output'] = $path . DS;
|
||||
$this->Task->Dispatch->expectNever('stderr');
|
||||
$this->Task->Dispatch->expectNever('_stop');
|
||||
|
@ -146,6 +143,20 @@ class ExtractTaskTest extends CakeTestCase {
|
|||
$pattern = '/msgid "You deleted %d message \(domain\)."\nmsgid_plural "You deleted %d messages \(domain\)."/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
|
||||
// extract.ctp - reading the domain.pot
|
||||
$result = file_get_contents($path . DS . 'domain.pot');
|
||||
|
||||
$pattern = '/msgid "You have %d new message."\nmsgid_plural "You have %d new messages."/';
|
||||
$this->assertNoPattern($pattern, $result);
|
||||
$pattern = '/msgid "You deleted %d message."\nmsgid_plural "You deleted %d messages."/';
|
||||
$this->assertNoPattern($pattern, $result);
|
||||
|
||||
$pattern = '/msgid "You have %d new message \(domain\)."\nmsgid_plural "You have %d new messages \(domain\)."/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
$pattern = '/msgid "You deleted %d message \(domain\)."\nmsgid_plural "You deleted %d messages \(domain\)."/';
|
||||
$this->assertPattern($pattern, $result);
|
||||
|
||||
|
||||
$Folder = new Folder($path);
|
||||
$Folder->delete();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* SessionTest file
|
||||
*
|
||||
|
@ -9,20 +7,17 @@
|
|||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
if (!class_exists('CakeSession')) {
|
||||
|
@ -190,7 +185,7 @@ class SessionTest extends CakeTestCase {
|
|||
$result = $this->Session->error();
|
||||
$this->assertEqual($result, "Does.not.exist doesn't exist");
|
||||
|
||||
$this->Session->del('Failing.delete');
|
||||
$this->Session->delete('Failing.delete');
|
||||
$result = $this->Session->error();
|
||||
$this->assertEqual($result, "Failing.delete doesn't exist");
|
||||
}
|
||||
|
@ -201,14 +196,14 @@ class SessionTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testDel() {
|
||||
function testDelete() {
|
||||
$this->assertTrue($this->Session->write('Delete.me', 'Clearing out'));
|
||||
$this->assertTrue($this->Session->del('Delete.me'));
|
||||
$this->assertTrue($this->Session->delete('Delete.me'));
|
||||
$this->assertFalse($this->Session->check('Delete.me'));
|
||||
$this->assertTrue($this->Session->check('Delete'));
|
||||
|
||||
$this->assertTrue($this->Session->write('Clearing.sale', 'everything must go'));
|
||||
$this->assertTrue($this->Session->del('Clearing'));
|
||||
$this->assertTrue($this->Session->delete('Clearing'));
|
||||
$this->assertFalse($this->Session->check('Clearing.sale'));
|
||||
$this->assertFalse($this->Session->check('Clearing'));
|
||||
}
|
||||
|
@ -228,7 +223,7 @@ class SessionTest extends CakeTestCase {
|
|||
$this->Session->write('Watching', 'They found us!');
|
||||
|
||||
$this->expectError('Deleting session key {Watching}');
|
||||
$this->Session->del('Watching');
|
||||
$this->Session->delete('Watching');
|
||||
|
||||
$this->assertFalse($this->Session->watch('Invalid.key'));
|
||||
}
|
||||
|
@ -289,7 +284,7 @@ class SessionTest extends CakeTestCase {
|
|||
function testCheckKeyWithSpaces() {
|
||||
$this->assertTrue($this->Session->write('Session Test', "test"));
|
||||
$this->assertEqual($this->Session->check('Session Test'), 'test');
|
||||
$this->Session->del('Session Test');
|
||||
$this->Session->delete('Session Test');
|
||||
|
||||
$this->assertTrue($this->Session->write('Session Test.Test Case', "test"));
|
||||
$this->assertTrue($this->Session->check('Session Test.Test Case'));
|
||||
|
|
|
@ -721,6 +721,13 @@ class ControllerTest extends CakeTestCase {
|
|||
$result = str_replace(array("\t", "\r\n", "\n"), "", $result);
|
||||
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)));
|
||||
$Controller =& new Controller();
|
||||
$Controller->flash('this should work', '/flash', 1, 'ajax2');
|
||||
$result = $Controller->output;
|
||||
$this->assertPattern('/Ajax!/', $result);
|
||||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -649,6 +649,7 @@ class DboMysqlTest extends CakeTestCase {
|
|||
'collate' => 'utf8_unicode_ci',
|
||||
'engine' => 'InnoDB');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->db->query('DROP TABLE ' . $this->db->fullTableName('tinyint'));
|
||||
$this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;');
|
||||
$result = $this->db->readTableParameters('tinyint');
|
||||
|
|
|
@ -102,34 +102,6 @@ class MysqliTestModel extends Model {
|
|||
*/
|
||||
var $useTable = false;
|
||||
|
||||
/**
|
||||
* find method
|
||||
*
|
||||
* @param mixed $conditions
|
||||
* @param mixed $fields
|
||||
* @param mixed $order
|
||||
* @param mixed $recursive
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function find($conditions = null, $fields = null, $order = null, $recursive = null) {
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* findAll method
|
||||
*
|
||||
* @param mixed $conditions
|
||||
* @param mixed $fields
|
||||
* @param mixed $order
|
||||
* @param mixed $recursive
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function findAll($conditions = null, $fields = null, $order = null, $recursive = null) {
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* schema method
|
||||
*
|
||||
|
@ -318,20 +290,48 @@ class DboMysqliTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* undocumented function
|
||||
* test transaction commands.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testTransactions() {
|
||||
$this->db->begin($this->model);
|
||||
$this->assertTrue($this->db->_transactionStarted);
|
||||
$this->db->testing = false;
|
||||
$result = $this->db->begin($this->model);
|
||||
$this->assertTrue($result);
|
||||
|
||||
$beginSqlCalls = Set::extract('/.[query=START TRANSACTION]', $this->db->_queriesLog);
|
||||
$this->assertEqual(1, count($beginSqlCalls));
|
||||
|
||||
$this->db->commit($this->model);
|
||||
$this->assertFalse($this->db->_transactionStarted);
|
||||
$result = $this->db->commit($this->model);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that tableParameters like collation, charset and engine are functioning.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testReadTableParameters() {
|
||||
$this->db->cacheSources = $this->db->testing = false;
|
||||
$this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;');
|
||||
$result = $this->db->readTableParameters('tinyint');
|
||||
$expected = array(
|
||||
'charset' => 'utf8',
|
||||
'collate' => 'utf8_unicode_ci',
|
||||
'engine' => 'InnoDB');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->db->query('DROP TABLE ' . $this->db->fullTableName('tinyint'));
|
||||
$this->db->query('CREATE TABLE ' . $this->db->fullTableName('tinyint') . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;');
|
||||
$result = $this->db->readTableParameters('tinyint');
|
||||
$expected = array(
|
||||
'charset' => 'cp1250',
|
||||
'collate' => 'cp1250_general_ci',
|
||||
'engine' => 'MyISAM');
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->db->query('DROP TABLE ' . $this->db->fullTableName('tinyint'));
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -126,5 +126,32 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$this->assertEqual($TestModel->validate, $validate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that missing validation methods trigger errors in development mode.
|
||||
* Helps to make developement easier.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testMissingValidationErrorTriggering() {
|
||||
$restore = Configure::read('debug');
|
||||
Configure::write('debug', 2);
|
||||
|
||||
$TestModel =& new ValidationTest1();
|
||||
$TestModel->create(array('title' => 'foo'));
|
||||
$TestModel->validate = array(
|
||||
'title' => array(
|
||||
'rule' => array('thisOneBringsThePain'),
|
||||
'required' => true
|
||||
)
|
||||
);
|
||||
$this->expectError(new PatternExpectation('/thisOneBringsThePain for title/i'));
|
||||
$TestModel->invalidFields(array('fieldList' => array('title')));
|
||||
|
||||
Configure::write('debug', 0);
|
||||
$this->assertNoErrors();
|
||||
$TestModel->invalidFields(array('fieldList' => array('title')));
|
||||
Configure::write('debug', $restore);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -686,7 +686,7 @@ class RouterTest extends CakeTestCase {
|
|||
|
||||
Router::parse('/');
|
||||
|
||||
$result = Router::url(array('plugin' => null, 'controller' => 'pages', 'action' => 'edit', 'id' => '284'));
|
||||
$result = Router::url(array('plugin' => null, 'controller' => 'pages', 'action' => 'edit', 284));
|
||||
$expected = '/admin/pages/edit/284';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
|
@ -706,7 +706,7 @@ class RouterTest extends CakeTestCase {
|
|||
Router::parse('/');
|
||||
|
||||
$result = Router::url(array(
|
||||
'plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'edit', 'id' => '6',
|
||||
'plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'edit', 6,
|
||||
'admin' => true, 'prefix' => 'admin'
|
||||
));
|
||||
$expected = '/admin/shows/show_tickets/edit/6';
|
||||
|
@ -1297,7 +1297,7 @@ class RouterTest extends CakeTestCase {
|
|||
$expected = '/12/file:asdf.png';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = Router::url(array('controller' => 'graphs', 'action' => 'view', 'id' => 12, 'file' => 'asdf.foo'));
|
||||
$result = Router::url(array('controller' => 'graphs', 'action' => 'view', 12, 'file' => 'asdf.foo'));
|
||||
$expected = '/graphs/view/12/file:asdf.foo';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
|
|
|
@ -449,8 +449,11 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testUrlGenerationWithPrefixes() {
|
||||
$memberPrefixes = array('prefix' => 'members', 'members' => true);
|
||||
Router::connect('/members/:controller/:action/*', $memberPrefixes);
|
||||
$_back = Configure::read('Routing');
|
||||
|
||||
Configure::write('Routing.prefixes', array('members'));
|
||||
Router::reload();
|
||||
|
||||
Router::parse('/');
|
||||
|
||||
Router::setRequestInfo( array(
|
||||
|
@ -500,6 +503,8 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
$result = $this->Paginator->url($options);
|
||||
$expected = '/posts/index/page:2/sort:Article.name/direction:desc';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
Configure::write('Routing', $_back);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue