Merge branch '2.0' of github.com:cakephp/cakephp into 2.0

This commit is contained in:
Graham Weldon 2011-12-14 16:04:40 +11:00
commit d83115927d
241 changed files with 2119 additions and 1038 deletions

View file

@ -200,6 +200,7 @@
* timestamping regardless of debug value.
*/
//Configure::write('Asset.timestamp', true);
/**
* Compress CSS output by removing comments, whitespace, repeating tags, etc.
* This requires a/var/cache directory to be writable by the web server for caching.

View file

@ -285,7 +285,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -335,7 +335,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -360,7 +360,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -374,6 +374,7 @@ class Cache {
self::set(null, $config);
return $success;
}
/**
* Decrement a number under the key and return decremented value.
*
@ -387,7 +388,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -401,6 +402,7 @@ class Cache {
self::set(null, $config);
return $success;
}
/**
* Delete a key from the cache.
*
@ -422,7 +424,7 @@ class Cache {
$settings = self::settings($config);
if (empty($settings)) {
return null;
return false;
}
if (!self::isInitialized($config)) {
return false;
@ -505,7 +507,7 @@ abstract class CacheEngine {
*/
public function init($settings = array()) {
$this->settings = array_merge(
array('prefix' => 'cake_', 'duration'=> 3600, 'probability'=> 100),
array('prefix' => 'cake_', 'duration' => 3600, 'probability' => 100),
$this->settings,
$settings
);

View file

@ -21,7 +21,11 @@
*/
/**
* File Storage engine for cache
* File Storage engine for cache. Filestorage is the slowest cache storage
* to read and write. However, it is good for servers that don't have other storage
* engine available, or have content which is not performance sensitive.
*
* You can configure a FileEngine cache, using Cache::config()
*
* @package Cake.Cache.Engine
*/
@ -66,8 +70,8 @@ class FileEngine extends CacheEngine {
public function init($settings = array()) {
parent::init(array_merge(
array(
'engine' => 'File', 'path' => CACHE, 'prefix'=> 'cake_', 'lock'=> true,
'serialize'=> true, 'isWindows' => false, 'mask' => 0664
'engine' => 'File', 'path' => CACHE, 'prefix' => 'cake_', 'lock' => true,
'serialize' => true, 'isWindows' => false, 'mask' => 0664
),
$settings
));
@ -84,7 +88,7 @@ class FileEngine extends CacheEngine {
/**
* Garbage collection. Permanently remove all expired and deleted data
*
* @return boolean True if garbage collection was succesful, false on failure
* @return boolean True if garbage collection was successful, false on failure
*/
public function gc() {
return $this->clear(true);
@ -273,7 +277,7 @@ class FileEngine extends CacheEngine {
/**
* Sets the current cache key this class is managing, and creates a writable SplFileObject
* for the cache file the key is refering to.
* for the cache file the key is referring to.
*
* @param string $key The key
* @param boolean $createKey Whether the key should be created if it doesn't exists, or not

View file

@ -59,10 +59,10 @@ class MemcacheEngine extends CacheEngine {
return false;
}
parent::init(array_merge(array(
'engine'=> 'Memcache',
'engine' => 'Memcache',
'prefix' => Inflector::slug(APP_DIR) . '_',
'servers' => array('127.0.0.1'),
'compress'=> false,
'compress' => false,
'persistent' => true
), $settings)
);

View file

@ -110,6 +110,7 @@ class XcacheEngine extends CacheEngine {
public function decrement($key, $offset = 1) {
return xcache_dec($key, $offset);
}
/**
* Delete a key from the cache
*

View file

@ -24,6 +24,8 @@ App::uses('File', 'Utility');
/**
* API shell to show method signatures of CakePHP core classes.
*
* Implementation of a Cake Shell to show CakePHP core method signatures.
*
* @package Cake.Console.Command
*/
class ApiShell extends AppShell {
@ -151,6 +153,7 @@ class ApiShell extends AppShell {
))->description(__d('cake_console', 'Lookup doc block comments for classes in CakePHP.'));
return $parser;
}
/**
* Show help for this shell.
*

View file

@ -24,7 +24,11 @@ App::uses('AppShell', 'Console/Command');
App::uses('Model', 'Model');
/**
* Bake is a command-line code generation utility for automating programmer chores.
* Command-line code generation utility to automate programmer chores.
*
* Bake is CakePHP's code generation script, which can help you kickstart
* application development by writing fully functional skeleton controllers,
* models, and views. Going further, Bake can also write Unit Tests for you.
*
* @package Cake.Console.Command
* @link http://book.cakephp.org/2.0/en/console-and-shells/code-generation-with-bake.html
@ -185,7 +189,7 @@ class BakeShell extends AppShell {
}
App::uses($controller . 'Controller', 'Controller');
if (class_exists($controller . 'Controller')) {
$this->View->args = array($controller);
$this->View->args = array($name);
$this->View->execute();
}
$this->out('', 1, Shell::QUIET);

View file

@ -88,7 +88,7 @@ class ConsoleShell extends AppShell {
$out .= "\n";
$out .= 'To dynamically set associations, you can do the following:';
$out .= "\tModelA bind <association> ModelB";
$out .= "where the supported assocations are hasOne, hasMany, belongsTo, hasAndBelongsToMany";
$out .= "where the supported associations are hasOne, hasMany, belongsTo, hasAndBelongsToMany";
$out .= "\n";
$out .= 'To dynamically remove associations, you can do the following:';
$out .= "\t ModelA unbind <association> ModelB";
@ -117,7 +117,7 @@ class ConsoleShell extends AppShell {
$out .= "\n";
$out .= "will return something like the following:";
$out .= "\n";
$out .= "\tarray (";
$out .= "\tarray(";
$out .= "\t [...]";
$out .= "\t 'controller' => 'posts',";
$out .= "\t 'action' => 'view',";

View file

@ -27,6 +27,9 @@ App::uses('CakeSchema', 'Model');
/**
* Schema is a command-line database management utility for automating programmer chores.
*
* Schema is CakePHP's database management utility. This helps you maintain versions of
* of your database.
*
* @package Cake.Console.Command
* @link http://book.cakephp.org/2.0/en/console-and-shells/schema-management-and-migrations.html
*/

View file

@ -79,7 +79,7 @@ class BakeTask extends AppShell {
* @return void
*/
public function execute() {
foreach($this->args as $i => $arg) {
foreach ($this->args as $i => $arg) {
if (strpos($arg, '.')) {
list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
break;

View file

@ -39,14 +39,14 @@ class DbConfigTask extends AppShell {
*/
protected $_defaultConfig = array(
'name' => 'default',
'datasource'=> 'Database/Mysql',
'persistent'=> 'false',
'host'=> 'localhost',
'login'=> 'root',
'password'=> 'password',
'database'=> 'project_name',
'schema'=> null,
'prefix'=> null,
'datasource' => 'Database/Mysql',
'persistent' => 'false',
'host' => 'localhost',
'login' => 'root',
'password' => 'password',
'database' => 'project_name',
'schema' => null,
'prefix' => null,
'encoding' => null,
'port' => null
);

View file

@ -91,7 +91,7 @@ class FixtureTask extends BakeTask {
/**
* Execution method always used for tasks
* Handles dispatching to interactive, named, or all processeses.
* Handles dispatching to interactive, named, or all processes.
*
* @return void
*/
@ -222,14 +222,14 @@ class FixtureTask extends BakeTask {
$schema = $this->_generateSchema($tableInfo);
}
if (!isset($importOptions['records']) && !isset($importOptions['fromTable'])) {
if (empty($importOptions['records']) && !isset($importOptions['fromTable'])) {
$recordCount = 1;
if (isset($this->params['count'])) {
$recordCount = $this->params['count'];
}
$records = $this->_makeRecordString($this->_generateRecords($tableInfo, $recordCount));
}
if (isset($this->params['records']) || isset($importOptions['fromTable'])) {
if (!empty($this->params['records']) || isset($importOptions['fromTable'])) {
$records = $this->_makeRecordString($this->_getRecordsFromTable($model, $useTable));
}
$out = $this->generateFixtureFile($model, compact('records', 'table', 'schema', 'import', 'fields'));

View file

@ -101,10 +101,12 @@ class ModelTask extends BakeTask {
return $this->all();
}
$model = $this->_modelName($this->args[0]);
$object = $this->_getModelObject($model);
$this->listAll($this->connection);
$useTable = $this->getTable($model);
$object = $this->_getModelObject($model, $useTable);
if ($this->bake($object, false)) {
if ($this->_checkUnitTest()) {
$this->bakeFixture($model);
$this->bakeFixture($model, $useTable);
$this->bakeTest($model);
}
}
@ -220,13 +222,13 @@ class ModelTask extends BakeTask {
}
$prompt = __d('cake_console', "Would you like to supply validation criteria \nfor the fields in your model?");
$wannaDoValidation = $this->in($prompt, array('y','n'), 'y');
$wannaDoValidation = $this->in($prompt, array('y', 'n'), 'y');
if (array_search($useTable, $this->_tables) !== false && strtolower($wannaDoValidation) == 'y') {
$validate = $this->doValidation($tempModel);
}
$prompt = __d('cake_console', "Would you like to define model associations\n(hasMany, hasOne, belongsTo, etc.)?");
$wannaDoAssoc = $this->in($prompt, array('y','n'), 'y');
$wannaDoAssoc = $this->in($prompt, array('y', 'n'), 'y');
if (strtolower($wannaDoAssoc) == 'y') {
$associations = $this->doAssociations($tempModel);
}
@ -258,7 +260,7 @@ class ModelTask extends BakeTask {
}
$this->hr();
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y','n'), 'y');
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y');
if (strtolower($looksGood) == 'y') {
$vars = compact('associations', 'validate', 'primaryKey', 'useTable', 'displayField');
@ -298,6 +300,7 @@ class ModelTask extends BakeTask {
* @return string Name of field that is a primary key.
*/
public function findPrimaryKey($fields) {
$name = 'id';
foreach ($fields as $name => $field) {
if (isset($field['key']) && $field['key'] == 'primary') {
break;
@ -486,7 +489,7 @@ class ModelTask extends BakeTask {
}
$associations = array(
'belongsTo' => array(), 'hasMany' => array(), 'hasOne'=> array(), 'hasAndBelongsToMany' => array()
'belongsTo' => array(), 'hasMany' => array(), 'hasOne' => array(), 'hasAndBelongsToMany' => array()
);
$associations = $this->findBelongsTo($model, $associations);
@ -515,7 +518,7 @@ class ModelTask extends BakeTask {
* Find belongsTo relations and add them to the associations list.
*
* @param Model $model Model instance of model being generated.
* @param array $associations Array of inprogress associations
* @param array $associations Array of in progress associations
* @return array $associations with belongsTo added in.
*/
public function findBelongsTo($model, $associations) {
@ -544,7 +547,7 @@ class ModelTask extends BakeTask {
* Find the hasOne and HasMany relations and add them to associations list
*
* @param Model $model Model instance being generated
* @param array $associations Array of inprogress associations
* @param array $associations Array of in progress associations
* @return array $associations with hasOne and hasMany added in.
*/
public function findHasOneAndMany($model, $associations) {
@ -635,7 +638,7 @@ class ModelTask extends BakeTask {
if (!empty($associations[$type])) {
foreach ($associations[$type] as $i => $assoc) {
$prompt = "{$model->name} {$type} {$assoc['alias']}?";
$response = $this->in($prompt, array('y','n'), 'y');
$response = $this->in($prompt, array('y', 'n'), 'y');
if ('n' == strtolower($response)) {
unset($associations[$type][$i]);
@ -658,7 +661,7 @@ class ModelTask extends BakeTask {
*/
public function doMoreAssociations($model, $associations) {
$prompt = __d('cake_console', 'Would you like to define some additional model associations?');
$wannaDoMoreAssoc = $this->in($prompt, array('y','n'), 'n');
$wannaDoMoreAssoc = $this->in($prompt, array('y', 'n'), 'n');
$possibleKeys = $this->_generatePossibleKeys();
while (strtolower($wannaDoMoreAssoc) == 'y') {
$assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
@ -710,7 +713,7 @@ class ModelTask extends BakeTask {
$associations[$assocs[$assocType]][$i]['associationForeignKey'] = $associationForeignKey;
$associations[$assocs[$assocType]][$i]['joinTable'] = $joinTable;
}
$wannaDoMoreAssoc = $this->in(__d('cake_console', 'Define another association?'), array('y','n'), 'y');
$wannaDoMoreAssoc = $this->in(__d('cake_console', 'Define another association?'), array('y', 'n'), 'y');
}
return $associations;
}
@ -796,12 +799,14 @@ class ModelTask extends BakeTask {
public function listAll($useDbConfig = null) {
$this->_tables = $this->getAllTables($useDbConfig);
$this->_modelNames = array();
$count = count($this->_tables);
for ($i = 0; $i < $count; $i++) {
$this->_modelNames[] = $this->_modelName($this->_tables[$i]);
}
if ($this->interactive === true) {
$this->out(__d('cake_console', 'Possible Models based on your current database:'));
$this->_modelNames = array();
$count = count($this->_tables);
for ($i = 0; $i < $count; $i++) {
$this->_modelNames[] = $this->_modelName($this->_tables[$i]);
$this->out($i + 1 . ". " . $this->_modelNames[$i]);
}
}
@ -816,26 +821,27 @@ class ModelTask extends BakeTask {
* @return string Table name
*/
public function getTable($modelName, $useDbConfig = null) {
if (!isset($useDbConfig)) {
$useDbConfig = $this->connection;
}
$db = ConnectionManager::getDataSource($useDbConfig);
$useTable = Inflector::tableize($modelName);
if (in_array($modelName, $this->_modelNames)) {
$modelNames = array_flip($this->_modelNames);
$useTable = $this->_tables[$modelNames[$modelName]];
}
$fullTableName = $db->fullTableName($useTable, false);
$tableIsGood = false;
if (array_search($useTable, $this->_tables) === false) {
$this->out();
$this->out(__d('cake_console', "Given your model named '%s',\nCake would expect a database table named '%s'", $modelName, $fullTableName));
$tableIsGood = $this->in(__d('cake_console', 'Do you want to use this table?'), array('y','n'), 'y');
}
if (strtolower($tableIsGood) == 'n') {
$useTable = $this->in(__d('cake_console', 'What is the name of the table?'));
if ($this->interactive === true) {
if (!isset($useDbConfig)) {
$useDbConfig = $this->connection;
}
$db = ConnectionManager::getDataSource($useDbConfig);
$fullTableName = $db->fullTableName($useTable, false);
$tableIsGood = false;
if (array_search($useTable, $this->_tables) === false) {
$this->out();
$this->out(__d('cake_console', "Given your model named '%s',\nCake would expect a database table named '%s'", $modelName, $fullTableName));
$tableIsGood = $this->in(__d('cake_console', 'Do you want to use this table?'), array('y', 'n'), 'y');
}
if (strtolower($tableIsGood) == 'n') {
$useTable = $this->in(__d('cake_console', 'What is the name of the table?'));
}
}
return $useTable;
}

View file

@ -21,7 +21,7 @@ App::uses('File', 'Utility');
App::uses('Folder', 'Utility');
/**
* Task class for creating a plugin
* The Plugin Task handles creating an empty plugin, ready to be used
*
* @package Cake.Console.Command.Task
*/
@ -75,7 +75,7 @@ class PluginTask extends AppShell {
}
if (!$this->bake($plugin)) {
$this->error(__d('cake_console', "An error occured trying to bake: %s in %s", $plugin, $this->path . $plugin));
$this->error(__d('cake_console', "An error occurred trying to bake: %s in %s", $plugin, $this->path . $plugin));
}
}
@ -159,8 +159,8 @@ class PluginTask extends AppShell {
*/
public function findPath($pathOptions) {
$valid = false;
foreach ($pathOptions as $i =>$path) {
if(!is_dir($path)) {
foreach ($pathOptions as $i => $path) {
if (!is_dir($path)) {
array_splice($pathOptions, $i, 1);
}
}

View file

@ -62,7 +62,7 @@ class ProjectTask extends AppShell {
$response = false;
while ($response == false && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
$prompt = __d('cake_console', '<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
$response = $this->in($prompt, array('y','n'), 'n');
$response = $this->in($prompt, array('y', 'n'), 'n');
if (strtolower($response) === 'n') {
$response = $project = false;
}
@ -288,9 +288,7 @@ class ProjectTask extends AppShell {
$File = new File($path . 'Config' . DS . 'core.php');
$contents = $File->read();
if (preg_match('/([\s]*Configure::write\(\'Security.cipherSeed\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
if (!class_exists('Security')) {
require CAKE . 'Utility' . DS . 'security.php';
}
App::uses('Security', 'Utility');
$string = substr(bin2hex(Security::generateAuthKey()), 0, 30);
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.cipherSeed\', \''.$string.'\');', $contents);
if ($File->write($result)) {

View file

@ -59,7 +59,7 @@ class TemplateTask extends AppShell {
* @return array Array of bake themes that are installed.
*/
protected function _findThemes() {
$paths = App::path('Console');
$paths = array();
$core = current(App::core('Console'));
$separator = DS === '/' ? '/' : '\\\\';
$core = preg_replace('#shells' . $separator . '$#', '', $core);
@ -70,10 +70,12 @@ class TemplateTask extends AppShell {
$themeFolders = $contents[0];
$plugins = App::objects('plugin');
$paths[] = $core;
foreach ($plugins as $plugin) {
$paths[] = $this->_pluginPath($plugin) . 'Console' . DS;
}
$paths[] = $core;
$paths = array_merge($paths, App::path('Console'));
// TEMPORARY TODO remove when all paths are DS terminated
foreach ($paths as $i => $path) {

View file

@ -402,7 +402,7 @@ class TestTask extends BakeTask {
* @return array Array of fixtures the user wants to add.
*/
public function getUserFixtures() {
$proceed = $this->in(__d('cake_console', 'Bake could not detect fixtures, would you like to add some?'), array('y','n'), 'n');
$proceed = $this->in(__d('cake_console', 'Bake could not detect fixtures, would you like to add some?'), array('y', 'n'), 'n');
$fixtures = array();
if (strtolower($proceed) == 'y') {
$fixtureList = $this->in(__d('cake_console', "Please provide a comma separated list of the fixtures names you'd like to use.\nExample: 'app.comment, app.post, plugin.forums.post'"));

View file

@ -215,9 +215,9 @@ class ViewTask extends BakeTask {
}
$prompt = __d('cake_console', "Would you like to create some CRUD views\n(index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller\nand model classes (including associated models).");
$wannaDoScaffold = $this->in($prompt, array('y','n'), 'y');
$wannaDoScaffold = $this->in($prompt, array('y', 'n'), 'y');
$wannaDoAdmin = $this->in(__d('cake_console', "Would you like to create the views for admin routing?"), array('y','n'), 'n');
$wannaDoAdmin = $this->in(__d('cake_console', "Would you like to create the views for admin routing?"), array('y', 'n'), 'n');
if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoAdmin) == 'y') {
$vars = $this->_loadController();
@ -292,7 +292,7 @@ class ViewTask extends BakeTask {
$pluralHumanName = $this->_pluralHumanName($this->controllerName);
return compact('modelClass', 'schema', 'primaryKey', 'displayField', 'singularVar', 'pluralVar',
'singularHumanName', 'pluralHumanName', 'fields','associations');
'singularHumanName', 'pluralHumanName', 'fields', 'associations');
}
/**
@ -330,7 +330,7 @@ class ViewTask extends BakeTask {
$this->out(__d('cake_console', 'Action Name: %s', $action));
$this->out(__d('cake_console', 'Path: %s', $this->getPath() . $this->controllerName . DS . Inflector::underscore($action) . ".ctp"));
$this->hr();
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y','n'), 'y');
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y');
if (strtolower($looksGood) == 'y') {
$this->bake($action, ' ');
$this->_stop();

View file

@ -83,7 +83,7 @@ class UpgradeShell extends AppShell {
* @return void
*/
public function all() {
foreach($this->OptionParser->subcommands() as $command) {
foreach ($this->OptionParser->subcommands() as $command) {
$name = $command->name();
if ($name === 'all') {
continue;
@ -135,7 +135,7 @@ class UpgradeShell extends AppShell {
if (is_dir('plugins')) {
$Folder = new Folder('plugins');
list($plugins) = $Folder->read();
foreach($plugins as $plugin) {
foreach ($plugins as $plugin) {
chdir($cwd . DS . 'plugins' . DS . $plugin);
$this->locations();
}
@ -155,7 +155,7 @@ class UpgradeShell extends AppShell {
'Test' . DS . 'fixtures' => 'Test' . DS . 'Fixture',
'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates',
);
foreach($moves as $old => $new) {
foreach ($moves as $old => $new) {
if (is_dir($old)) {
$this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
if (!$this->params['dry-run']) {
@ -190,7 +190,7 @@ class UpgradeShell extends AppShell {
'checkFolder' => true,
'regex' => '@class (\S*) .*{@i'
);
foreach($sourceDirs as $dir => $options) {
foreach ($sourceDirs as $dir => $options) {
if (is_numeric($dir)) {
$dir = $options;
$options = array();
@ -555,6 +555,7 @@ class UpgradeShell extends AppShell {
);
$this->_filesRegexpUpdate($patterns);
}
/**
* Move application views files to where they now should be
*
@ -615,7 +616,7 @@ class UpgradeShell extends AppShell {
$this->_findFiles('php');
} else {
$this->_files = scandir($path);
foreach($this->_files as $i => $file) {
foreach ($this->_files as $i => $file) {
if (strlen($file) < 5 || substr($file, -4) !== '.php') {
unset($this->_files[$i]);
}
@ -765,7 +766,7 @@ class UpgradeShell extends AppShell {
'help' => __d('cake_console', 'Use git command for moving files around.'),
'boolean' => true
),
'dry-run'=> array(
'dry-run' => array(
'short' => 'd',
'help' => __d('cake_console', 'Dry run the update, no files will actually be modified.'),
'boolean' => true

View file

@ -140,7 +140,7 @@ class HelpFormatter {
foreach ($this->_parser->options() as $option) {
$options[] = $option->usage();
}
if (count($options) > $this->_maxOptions){
if (count($options) > $this->_maxOptions) {
$options = array('[options]');
}
$usage = array_merge($usage, $options);

View file

@ -79,6 +79,14 @@ class Shell extends Object {
*/
public $name = null;
/**
* The name of the plugin the shell belongs to.
* Is automatically set by ShellDispatcher when a shell is constructed.
*
* @var string
*/
public $plugin = null;
/**
* Contains tasks to load and instantiate
*
@ -366,7 +374,7 @@ class Shell extends Object {
return $this->_displayHelp($command);
}
if (($isTask || $isMethod || $isMain) && $command !== 'execute' ) {
if (($isTask || $isMethod || $isMain) && $command !== 'execute') {
$this->startup();
}
@ -409,7 +417,8 @@ class Shell extends Object {
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::getOptionParser
*/
public function getOptionParser() {
$parser = new ConsoleOptionParser($this->name);
$name = ($this->plugin ? $this->plugin . '.' : '') . $this->name;
$parser = new ConsoleOptionParser($name);
return $parser;
}
@ -648,7 +657,7 @@ class Shell extends Object {
}
$File = new File($path, true);
if ($File->exists()) {
if ($File->exists() && $File->writable()) {
$data = $File->prepare($contents);
$File->write($data);
$this->out(__d('cake_console', '<success>Wrote</success> `%s`', $path));
@ -672,7 +681,7 @@ class Shell extends Object {
return true;
}
$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');
$unitTest = $this->in($prompt, array('y', 'n'), 'y');
$result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes';
if ($result) {
@ -716,10 +725,10 @@ class Shell extends Object {
}
/**
* Creates the proper controller camelized name (singularized) for the specified name
* Creates the proper model camelized name (singularized) for the specified name
*
* @param string $name Name
* @return string Camelized and singularized controller name
* @return string Camelized and singularized model name
*/
protected function _modelName($name) {
return Inflector::camelize(Inflector::singularize($name));

View file

@ -219,6 +219,7 @@ class ShellDispatcher {
));
}
$Shell = new $class();
$Shell->plugin = trim($plugin, '.');
return $Shell;
}

View file

@ -143,7 +143,7 @@
if ($this-><?php echo $currentModelName; ?>->delete()) {
<?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'));
$this->redirect(array('action'=>'index'));
$this->redirect(array('action' => 'index'));
<?php else: ?>
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index'));
<?php endif; ?>

View file

@ -50,7 +50,7 @@ class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>App
<?php
if (count($helpers)):
echo "/**\n * Helpers\n *\n * @var array\n */\n";
echo "\tvar \$helpers = array(";
echo "\tpublic \$helpers = array(";
for ($i = 0, $len = count($helpers); $i < $len; $i++):
if ($i != $len - 1):
echo "'" . Inflector::camelize($helpers[$i]) . "', ";

View file

@ -39,35 +39,35 @@ class DbAclSchema extends CakeSchema {
}
public $acos = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'model' => array('type'=>'string', 'null' => true),
'foreign_key' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'alias' => array('type'=>'string', 'null' => true),
'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'model' => array('type' => 'string', 'null' => true),
'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'alias' => array('type' => 'string', 'null' => true),
'lft' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
public $aros = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'model' => array('type'=>'string', 'null' => true),
'foreign_key' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'alias' => array('type'=>'string', 'null' => true),
'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'model' => array('type' => 'string', 'null' => true),
'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'alias' => array('type' => 'string', 'null' => true),
'lft' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
public $aros_acos = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'aro_id' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'aco_id' => array('type'=>'integer', 'null' => false, 'length' => 10),
'_create' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'_read' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'_update' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'_delete' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'aro_id' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'aco_id' => array('type' => 'integer', 'null' => false, 'length' => 10),
'_create' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'_read' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'_update' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'_delete' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'ARO_ACO_KEY' => array('column' => array('aro_id', 'aco_id'), 'unique' => 1))
);

View file

@ -39,12 +39,12 @@ class i18nSchema extends CakeSchema {
}
public $i18n = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'),
'model' => array('type'=>'string', 'null' => false, 'key' => 'index'),
'foreign_key' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'field' => array('type'=>'string', 'null' => false, 'key' => 'index'),
'content' => array('type'=>'text', 'null' => true, 'default' => NULL),
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'),
'model' => array('type' => 'string', 'null' => false, 'key' => 'index'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'field' => array('type' => 'string', 'null' => false, 'key' => 'index'),
'content' => array('type' => 'text', 'null' => true, 'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0))
);

View file

@ -39,9 +39,9 @@ class SessionsSchema extends CakeSchema {
}
public $cake_sessions = array(
'id' => array('type'=>'string', 'null' => false, 'key' => 'primary'),
'data' => array('type'=>'text', 'null' => true, 'default' => NULL),
'expires' => array('type'=>'integer', 'null' => true, 'default' => NULL),
'id' => array('type' => 'string', 'null' => false, 'key' => 'primary'),
'data' => array('type' => 'text', 'null' => true, 'default' => NULL),
'expires' => array('type' => 'integer', 'null' => true, 'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);

View file

@ -200,6 +200,7 @@
* timestamping regardless of debug value.
*/
//Configure::write('Asset.timestamp', true);
/**
* Compress CSS output by removing comments, whitespace, repeating tags, etc.
* This requires a/var/cache directory to be writable by the web server for caching.
@ -239,8 +240,8 @@
*
* Cache::config('default', array(
* 'engine' => 'File', //[required]
* 'duration'=> 3600, //[optional]
* 'probability'=> 100, //[optional]
* 'duration' => 3600, //[optional]
* 'probability' => 100, //[optional]
* 'path' => CACHE, //[optional] use system tmp directory - remember to use absolute path
* 'prefix' => 'cake_', //[optional] prefix every cache file with this string
* 'lock' => false, //[optional] use file locking
@ -251,8 +252,8 @@
*
* Cache::config('default', array(
* 'engine' => 'Apc', //[required]
* 'duration'=> 3600, //[optional]
* 'probability'=> 100, //[optional]
* 'duration' => 3600, //[optional]
* 'probability' => 100, //[optional]
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
* ));
*
@ -260,8 +261,8 @@
*
* Cache::config('default', array(
* 'engine' => 'Xcache', //[required]
* 'duration'=> 3600, //[optional]
* 'probability'=> 100, //[optional]
* 'duration' => 3600, //[optional]
* 'probability' => 100, //[optional]
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
* 'user' => 'user', //user from xcache.admin.user settings
* 'password' => 'password', //plaintext password (xcache.admin.pass)
@ -271,8 +272,8 @@
*
* Cache::config('default', array(
* 'engine' => 'Memcache', //[required]
* 'duration'=> 3600, //[optional]
* 'probability'=> 100, //[optional]
* 'duration' => 3600, //[optional]
* 'probability' => 100, //[optional]
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
* 'servers' => array(
* '127.0.0.1:11211' // localhost, default port 11211
@ -285,8 +286,8 @@
*
* Cache::config('default', array(
* 'engine' => 'Wincache', //[required]
* 'duration'=> 3600, //[optional]
* 'probability'=> 100, //[optional]
* 'duration' => 3600, //[optional]
* 'probability' => 100, //[optional]
* 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
* ));
*/

View file

@ -46,7 +46,7 @@
</div>
<div id="footer">
<?php echo $this->Html->link(
$this->Html->image('cake.power.gif', array('alt'=> __('CakePHP: the rapid development php framework'), 'border' => '0')),
$this->Html->image('cake.power.gif', array('alt' => __('CakePHP: the rapid development php framework'), 'border' => '0')),
'http://www.cakephp.org/',
array('target' => '_blank', 'escape' => false)
);

View file

@ -16,16 +16,16 @@
*/
* {
margin:0;
padding:0;
margin: 0;
padding: 0;
}
/** General Style Info **/
body {
background: #003d4c;
color: #fff;
font-family:'lucida grande',verdana,helvetica,arial,sans-serif;
font-size:90%;
font-family: 'lucida grande', verdana, helvetica, arial, sans-serif;
font-size: 90%;
margin: 0;
}
a {
@ -35,29 +35,29 @@ a {
}
a:hover {
color: #367889;
text-decoration:none;
text-decoration: none;
}
a img {
border:none;
border: none;
}
h1, h2, h3, h4 {
font-weight: normal;
margin-bottom:0.5em;
margin-bottom: 0.5em;
}
h1 {
background:#fff;
background: #fff;
color: #003d4c;
font-size: 100%;
}
h2 {
background:#fff;
background: #fff;
color: #e32;
font-family:'Gill Sans','lucida grande', helvetica, arial, sans-serif;
font-family: 'Gill Sans', 'lucida grande', helvetica, arial, sans-serif;
font-size: 190%;
}
h3 {
color: #2c6877;
font-family:'Gill Sans','lucida grande', helvetica, arial, sans-serif;
font-family: 'Gill Sans', 'lucida grande', helvetica, arial, sans-serif;
font-size: 165%;
}
h4 {
@ -80,7 +80,7 @@ p {
padding: 10px 20px;
}
#header h1 {
line-height:20px;
line-height: 20px;
background: #003d4c url('../img/cake.icon.png') no-repeat left;
color: #fff;
padding: 0px 30px;
@ -113,35 +113,35 @@ p {
div.form,
div.index,
div.view {
float:right;
width:76%;
border-left:1px solid #666;
padding:10px 2%;
float: right;
width: 76%;
border-left: 1px solid #666;
padding: 10px 2%;
}
div.actions {
float:left;
width:16%;
padding:10px 1.5%;
float: left;
width: 16%;
padding: 10px 1.5%;
}
div.actions h3 {
padding-top:0;
color:#777;
padding-top: 0;
color: #777;
}
/** Tables **/
table {
border-right:0;
border-right: 0;
clear: both;
color: #333;
margin-bottom: 10px;
width: 100%;
}
th {
border:0;
border-bottom:2px solid #555;
border: 0;
border-bottom: 2px solid #555;
text-align: left;
padding:4px;
padding: 4px;
}
th a {
display: block;
@ -158,7 +158,7 @@ table tr td {
padding: 6px;
text-align: left;
vertical-align: top;
border-bottom:1px solid #ddd;
border-bottom: 1px solid #ddd;
}
table tr:nth-child(even) {
background: #f9f9f9;
@ -169,7 +169,7 @@ td.actions {
}
table td.actions a {
margin: 0px 6px;
padding:2px 5px;
padding: 2px 5px;
}
/* SQL log */
@ -182,15 +182,15 @@ table td.actions a {
font-family: Monaco, Consolas, "Courier New", monospaced;
}
.cake-sql-log caption {
color:#fff;
color: #fff;
}
/** Paging **/
.paging {
background:#fff;
background: #fff;
color: #ccc;
margin-top: 1em;
clear:both;
clear: both;
}
.paging .current,
.paging .disabled,
@ -296,7 +296,7 @@ form .required {
form .required label:after {
color: #e32;
content: '*';
display:inline;
display: inline;
}
form div.submit {
border: 0;
@ -306,14 +306,14 @@ form div.submit {
label {
display: block;
font-size: 110%;
margin-bottom:3px;
margin-bottom: 3px;
}
input, textarea {
clear: both;
font-size: 140%;
font-family: "frutiger linotype", "lucida grande", "verdana", sans-serif;
padding: 1%;
width:98%;
width: 98%;
}
select {
clear: both;
@ -337,8 +337,8 @@ div.checkbox label {
display: inline;
}
input[type=radio] {
float:left;
width:auto;
float: left;
width: auto;
margin: 6px 0;
padding: 0;
line-height: 26px;
@ -353,7 +353,7 @@ input[type=submit] {
width: auto;
}
form .submit input[type=submit] {
background:#62af56;
background: #62af56;
background-image: -webkit-gradient(linear, left top, left bottom, from(#76BF6B), to(#3B8230));
background-image: -webkit-linear-gradient(top, #76BF6B, #3B8230);
background-image: -moz-linear-gradient(top, #76BF6B, #3B8230);
@ -365,6 +365,7 @@ form .submit input[type=submit] {
form .submit input[type=submit]:hover {
background: #5BA150;
}
/* Form errors */
form .error {
background: #FFDACC;
@ -491,7 +492,7 @@ p.error em {
padding: 0;
}
.actions li {
margin:0 0 0.5em 0;
margin: 0 0 0.5em 0;
list-style-type: none;
white-space: nowrap;
padding: 0;
@ -506,7 +507,7 @@ p.error em {
input[type=submit],
.actions ul li a,
.actions a {
font-weight:normal;
font-weight: normal;
padding: 4px 8px;
background: #dcdcdc;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#dcdcdc));
@ -515,8 +516,8 @@ input[type=submit],
background-image: -ms-linear-gradient(top, #fefefe, #dcdcdc);
background-image: -o-linear-gradient(top, #fefefe, #dcdcdc);
background-image: linear-gradient(top, #fefefe, #dcdcdc);
color:#333;
border:1px solid #bbb;
color: #333;
border: 1px solid #bbb;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
@ -646,6 +647,7 @@ pre {
overflow: auto;
text-shadow: none;
}
/* excerpt */
.cake-code-dump pre,
.cake-code-dump pre code {
@ -661,50 +663,50 @@ pre {
background-color: rgba(255, 255, 0, 0.5);
}
.code-coverage-results div.code-line {
padding-left:5px;
display:block;
margin-left:10px;
padding-left: 5px;
display: block;
margin-left: 10px;
}
.code-coverage-results div.uncovered span.content {
background:#ecc;
background: #ecc;
}
.code-coverage-results div.covered span.content {
background:#cec;
background: #cec;
}
.code-coverage-results div.ignored span.content {
color:#aaa;
color: #aaa;
}
.code-coverage-results span.line-num {
color:#666;
display:block;
float:left;
width:20px;
text-align:right;
margin-right:5px;
color: #666;
display: block;
float: left;
width: 20px;
text-align: right;
margin-right: 5px;
}
.code-coverage-results span.line-num strong {
color:#666;
color: #666;
}
.code-coverage-results div.start {
border:1px solid #aaa;
border-width:1px 1px 0px 1px;
margin-top:30px;
padding-top:5px;
border: 1px solid #aaa;
border-width: 1px 1px 0px 1px;
margin-top: 30px;
padding-top: 5px;
}
.code-coverage-results div.end {
border:1px solid #aaa;
border-width:0px 1px 1px 1px;
margin-bottom:30px;
padding-bottom:5px;
border: 1px solid #aaa;
border-width: 0px 1px 1px 1px;
margin-bottom: 30px;
padding-bottom: 5px;
}
.code-coverage-results div.realstart {
margin-top:0px;
margin-top: 0px;
}
.code-coverage-results p.note {
color:#bbb;
padding:5px;
margin:5px 0 10px;
font-size:10px;
color: #bbb;
padding: 5px;
margin: 5px 0 10px;
font-size: 10px;
}
.code-coverage-results span.result-bad {
color: #a00;
@ -718,5 +720,5 @@ pre {
/** Elements **/
#url-rewriting-warning {
display:none;
display: none;
}

View file

@ -24,6 +24,7 @@
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
@ -37,6 +38,7 @@
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
/**
* The actual directory name for the "app".
*

View file

@ -24,6 +24,7 @@ ini_set('display_errors', 1);
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
@ -37,6 +38,7 @@ ini_set('display_errors', 1);
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
/**
* The actual directory name for the "app".
*

View file

@ -18,6 +18,14 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Error Handling Controller
*
* Controller used by ErrorHandler to render error views.
*
* @package Cake.Controller
*/
class CakeErrorController extends AppController {
/**
@ -55,7 +63,7 @@ class CakeErrorController extends AppController {
public function beforeRender() {
parent::beforeRender();
foreach ($this->viewVars as $key => $value) {
if (!is_object($value)){
if (!is_object($value)) {
$this->viewVars[$key] = h($value);
}
}

View file

@ -90,7 +90,7 @@ abstract class BaseAuthenticate {
}
/**
* Hash the plain text password so that it matches the hashed/encrytped password
* Hash the plain text password so that it matches the hashed/encrypted password
* in the datasource.
*
* @param string $password The plain text password.
@ -111,7 +111,7 @@ abstract class BaseAuthenticate {
/**
* Allows you to hook into AuthComponent::logout(),
* and implement specialized logout behaviour.
* and implement specialized logout behavior.
*
* All attached authentication objects will have this method
* called when a user logs out.

View file

@ -100,6 +100,7 @@ class DigestAuthenticate extends BaseAuthenticate {
$this->settings['opaque'] = md5($this->settings['realm']);
}
}
/**
* Authenticate a user using Digest HTTP auth. Will use the configured User model and attempt a
* login using Digest HTTP auth.
@ -142,6 +143,7 @@ class DigestAuthenticate extends BaseAuthenticate {
}
return false;
}
/**
* Find a user record using the standard options.
*

View file

@ -204,7 +204,7 @@ class AuthComponent extends Component {
/**
* Error to display when user attempts to access an object or action to which they do not have
* acccess.
* access.
*
* @var string
* @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#AuthComponent::$authError

View file

@ -93,8 +93,8 @@ class EmailComponent extends Component {
public $bcc = array();
/**
* The date to put in the Date: header. This should be a date
* conformant with the RFC2822 standard. Leave null, to have
* The date to put in the Date: header. This should be a date
* conforming with the RFC2822 standard. Leave null, to have
* today's date generated.
*
* @var string
@ -198,7 +198,7 @@ class EmailComponent extends Component {
public $xMailer = 'CakePHP Email Component';
/**
* The list of paths to search if an attachment isnt absolute
* The list of paths to search if an attachment isn't absolute
*
* @var array
*/
@ -465,7 +465,7 @@ class EmailComponent extends Component {
/**
* Remove certain elements (such as bcc:, to:, %0a) from given value.
* Helps prevent header injection / mainipulation on user content.
* Helps prevent header injection / manipulation on user content.
*
* @param string $value Value to strip
* @param boolean $message Set to true to indicate main message content

View file

@ -19,7 +19,7 @@
/**
* This component is used to handle automatic model data pagination. The primary way to use this
* component is to call the paginate() method. There is a convience wrapper on Controller as well.
* component is to call the paginate() method. There is a convenience wrapper on Controller as well.
*
* ### Configuring pagination
*

View file

@ -22,7 +22,11 @@
App::uses('Xml', 'Utility');
/**
* Request object for handling HTTP requests
* Request object for handling alternative HTTP requests
*
* Alternative HTTP requests can come from wireless units like mobile phones, palmtop computers,
* and the like. These units have no use for Ajax requests, and this Component can tell how Cake
* should respond to the different needs of a handheld computer and a desktop machine.
*
* @package Cake.Controller.Component
* @link http://book.cakephp.org/2.0/en/core-libraries/components/request-handling.html
@ -485,7 +489,7 @@ class RequestHandlerComponent extends Component {
* 'html', 'xml', 'js', etc.
* @return mixed If $type is null or not provided, the first content-type in the
* list, based on preference, is returned. If a single type is provided
* a boolean will be returnend if that type is preferred.
* a boolean will be returned if that type is preferred.
* If an array of types are provided then the first preferred type is returned.
* If no type is provided the first preferred type is returned.
* @see RequestHandlerComponent::setContent()

View file

@ -22,7 +22,14 @@ App::uses('String', 'Utility');
App::uses('Security', 'Utility');
/**
* SecurityComponent
* The Security Component creates an easy way to integrate tighter security in
* your application. It provides methods for various tasks like:
*
* - Restricting which HTTP methods your application accepts.
* - CSRF protection.
* - Form tampering protection
* - Requiring that SSL be used.
* - Limiting cross controller communication.
*
* @package Cake.Controller.Component
* @link http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html

View file

@ -1,6 +1,6 @@
<?php
/**
* SessionComponent. Provides access to Sessions from the Controller layer
* SessionComponent. Provides access to Sessions from the Controller layer
*
* PHP 5
*
@ -21,9 +21,9 @@ App::uses('Component', 'Controller');
App::uses('CakeSession', 'Model/Datasource');
/**
* Session Component.
*
* Session handling from the controller.
* The CakePHP SessionComponent provides a way to persist client data between
* page requests. It acts as a wrapper for the `$_SESSION` as well as providing
* convenience methods for several `$_SESSION` related functions.
*
* @package Cake.Controller.Component
* @link http://book.cakephp.org/2.0/en/core-libraries/components/sessions.html

View file

@ -19,6 +19,12 @@
App::uses('ObjectCollection', 'Utility');
App::uses('Component', 'Controller');
/**
* Components collection is used as a registry for loaded components and handles loading
* and constructing component class objects.
*
* @package Cake.Controller
*/
class ComponentCollection extends ObjectCollection {
/**

View file

@ -18,7 +18,8 @@
*/
/**
* CakePlugin class
* CakePlugin is responsible for loading and unloading plugins. It also can
* retrieve plugin paths and load their bootstrap and routes files.
*
* @package Cake.Core
* @link http://book.cakephp.org/2.0/en/plugins.html

View file

@ -55,7 +55,7 @@ class Object {
* or tie plugins into a main application. requestAction can be used to return rendered views
* or fetch the return value from controller actions.
*
* Under the hood this method uses Router::reverse() to convert the $url parmeter into a string
* Under the hood this method uses Router::reverse() to convert the $url parameter into a string
* URL. You should use URL formats that are compatible with Router::reverse()
*
* #### Passing POST and GET data
@ -64,7 +64,7 @@ class Object {
* GET data. The `$extra['data']` parameter allows POST data simulation.
*
* @param mixed $url String or array-based url. Unlike other url arrays in CakePHP, this
* url will not automatically handle passed and named arguments in the $url paramenter.
* url will not automatically handle passed and named arguments in the $url parameter.
* @param array $extra if array includes the key "return" it sets the AutoRender to true. Can
* also be used to submit GET/POST data, and named/passed arguments.
* @return mixed Boolean true or false on success/failure, or contents
@ -144,7 +144,7 @@ class Object {
}
/**
* Convience method to write a message to CakeLog. See CakeLog::write()
* Convenience method to write a message to CakeLog. See CakeLog::write()
* for more information on writing to logs.
*
* @param string $msg Log message
@ -152,9 +152,7 @@ class Object {
* @return boolean Success of log write
*/
public function log($msg, $type = LOG_ERROR) {
if (!class_exists('CakeLog')) {
require CAKE . 'cake_log.php';
}
App::uses('CakeLog', 'Log');
if (!is_string($msg)) {
$msg = print_r($msg, true);
}

View file

@ -222,7 +222,7 @@ class ExceptionRenderer {
public function error500($error) {
$message = $error->getMessage();
if (Configure::read('debug') == 0) {
$message = __d('cake', 'An Internal Error Has Occurred');
$message = __d('cake', 'An Internal Error Has Occurred.');
}
$url = $this->controller->request->here();
$code = ($error->getCode() > 500 && $error->getCode() < 506) ? $error->getCode() : 500;

View file

@ -226,6 +226,7 @@ class MissingActionException extends CakeException {
parent::__construct($message, $code);
}
}
/**
* Private Action exception - used when a controller action
* starts with a `_`.

View file

@ -96,7 +96,7 @@ class I18n {
*
* @return void
*/
protected function __construct() {
public function __construct() {
$this->l10n = new L10n();
}
@ -511,7 +511,7 @@ class I18n {
continue;
}
$mustEscape = array($escape . ',' , $escape . ';', $escape . '<', $escape . '>', $escape . $escape);
$mustEscape = array($escape . ',', $escape . ';', $escape . '<', $escape . '>', $escape . $escape);
$replacements = array_map('crc32', $mustEscape);
$value = str_replace($mustEscape, $replacements, $value);
$value = explode(';', $value);

View file

@ -16,15 +16,11 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Load Model and AppModel
*/
App::uses('AppModel', 'Model');
/**
* ACL Node
*
*
* @package Cake.Model
*/
class AclNode extends AppModel {

View file

@ -16,9 +16,6 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Load Model and AppModel
*/
App::uses('AppModel', 'Model');
/**

View file

@ -16,9 +16,6 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Load Model and AppModel
*/
App::uses('AppModel', 'Model');
/**

View file

@ -16,9 +16,6 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Load Model and AppModel
*/
App::uses('AppModel', 'Model');
/**

View file

@ -23,6 +23,8 @@ App::uses('AclNode', 'Model');
/**
* ACL behavior
*
* Enables objects to easily tie into an ACL system
*
* @package Cake.Model.Behavior
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/acl.html
*/

View file

@ -20,8 +20,9 @@
*/
/**
* Behavior to allow for dynamic and atomic manipulation of a Model's associations used for a find call. Most useful for limiting
* the amount of associations and data returned.
* Behavior to allow for dynamic and atomic manipulation of a Model's associations
* used for a find call. Most useful for limiting the amount of associations and
* data returned.
*
* @package Cake.Model.Behavior
* @link http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html
@ -259,7 +260,7 @@ class ContainableBehavior extends ModelBehavior {
* @param Model $Model Model on which binding restriction is being applied
* @param array $contain Parameters to use for restricting this model
* @param array $containments Current set of containments
* @param boolean $throwErrors Wether unexisting bindings show throw errors
* @param boolean $throwErrors Whether non-existent bindings show throw errors
* @return array Containments
*/
public function containments($Model, $contain, $containments = array(), $throwErrors = null) {
@ -349,7 +350,7 @@ class ContainableBehavior extends ModelBehavior {
}
if (!isset($containments['models'][$Model->alias])) {
$containments['models'][$Model->alias] = array('keep' => array(),'instance' => &$Model);
$containments['models'][$Model->alias] = array('keep' => array(), 'instance' => &$Model);
}
$containments['models'][$Model->alias]['keep'] = array_merge($containments['models'][$Model->alias]['keep'], $keep);

View file

@ -38,7 +38,7 @@ class TranslateBehavior extends ModelBehavior {
* Callback
*
* $config for TranslateBehavior should be
* array( 'fields' => array('field_one',
* array('fields' => array('field_one',
* 'field_two' => 'FieldAssoc', 'field_three'))
*
* With above example only one permanent hasMany will be joined (for field_two

View file

@ -73,7 +73,7 @@ class TreeBehavior extends ModelBehavior {
/**
* After save method. Called after all saves
*
* Overriden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
* Overridden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
* parameters to be saved.
*
* @param Model $Model Model instance.
@ -125,7 +125,7 @@ class TreeBehavior extends ModelBehavior {
/**
* Before save method. Called before all saves
*
* Overriden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
* Overridden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
* parameters to be saved. For newly created nodes with NO parent the left and right field values are set directly by
* this method bypassing the setParent logic.
*
@ -562,7 +562,7 @@ class TreeBehavior extends ModelBehavior {
$Model->recursive = $recursive;
if ($mode == 'parent') {
$Model->bindModel(array('belongsTo' => array('VerifyParent' => array(
'className' => $Model->alias,
'className' => $Model->name,
'foreignKey' => $parent,
'fields' => array($Model->primaryKey, $left, $right, $parent),
))));
@ -624,7 +624,7 @@ class TreeBehavior extends ModelBehavior {
* Options:
*
* - 'id' id of record to use as top node for reordering
* - 'field' Which field to use in reordeing defaults to displayField
* - 'field' Which field to use in reordering defaults to displayField
* - 'order' Direction to order either DESC or ASC (defaults to ASC)
* - 'verify' Whether or not to verify the tree before reorder. defaults to true.
*
@ -770,7 +770,7 @@ class TreeBehavior extends ModelBehavior {
}
$Model->bindModel(array('belongsTo' => array('VerifyParent' => array(
'className' => $Model->alias,
'className' => $Model->name,
'foreignKey' => $parent,
'fields' => array($Model->primaryKey, $left, $right, $parent)
))));

View file

@ -208,7 +208,7 @@ class BehaviorCollection extends ObjectCollection {
/**
* Dispatches a behavior method. Will call either normal methods or mapped methods.
*
* If a method is not handeled by the BehaviorCollection, and $strict is false, a
* If a method is not handled by the BehaviorCollection, and $strict is false, a
* special return of `array('unhandled')` will be returned to signal the method was not found.
*
* @param Model $model The model the method was originally called on.
@ -253,8 +253,8 @@ class BehaviorCollection extends ObjectCollection {
*
* @param string $method The method to find.
* @param boolean $callback Return the callback for the method.
* @return mixed If $callback is false, a boolean will be returnned, if its true, an array
* containing callback information will be returnned. For mapped methods the array will have 3 elements.
* @return mixed If $callback is false, a boolean will be returned, if its true, an array
* containing callback information will be returned. For mapped methods the array will have 3 elements.
*/
public function hasMethod($method, $callback = false) {
if (isset($this->_methods[$method])) {

View file

@ -16,6 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5550
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
App::uses('ConnectionManager', 'Model');
@ -247,7 +248,12 @@ class CakeSchema extends Object {
continue;
}
$Object = ClassRegistry::init(array('class' => $model, 'ds' => $connection));
try {
$Object = ClassRegistry::init(array('class' => $model, 'ds' => $connection));
} catch (CakeException $e) {
continue;
}
$db = $Object->getDataSource();
if (is_object($Object) && $Object->useTable !== false) {
$fulltable = $table = $db->fullTableName($Object, false);
@ -402,7 +408,7 @@ class CakeSchema extends Object {
if ($field != 'indexes' && $field != 'tableParameters') {
if (is_string($value)) {
$type = $value;
$value = array('type'=> $type);
$value = array('type' => $type);
}
$col = "\t\t'{$field}' => array('type' => '" . $value['type'] . "', ";
unset($value['type']);

View file

@ -24,6 +24,9 @@ App::uses('DataSource', 'Model/Datasource');
/**
* Manages loaded instances of DataSource objects
*
* Provides an interface for loading and enumerating connections defined in
* app/Config/database.php
*
* @package Cake.Model
*/
class ConnectionManager {

View file

@ -181,7 +181,7 @@ class Mysql extends DboSource {
* Returns an array of sources (tables) in the database.
*
* @param mixed $data
* @return array Array of tablenames in the database
* @return array Array of table names in the database
*/
public function listSources($data = null) {
$cache = parent::listSources();
@ -543,11 +543,11 @@ class Mysql extends DboSource {
}
/**
* Generate MySQL table parameter alteration statementes for a table.
* Generate MySQL table parameter alteration statements for a table.
*
* @param string $table Table to alter parameters for.
* @param array $parameters Parameters to add & drop.
* @return array Array of table property alteration statementes.
* @return array Array of table property alteration statements.
* @todo Implement this method.
*/
protected function _alterTableParameters($table, $parameters) {
@ -567,7 +567,7 @@ class Mysql extends DboSource {
protected function _alterIndexes($table, $indexes) {
$alter = array();
if (isset($indexes['drop'])) {
foreach($indexes['drop'] as $name => $value) {
foreach ($indexes['drop'] as $name => $value) {
$out = 'DROP ';
if ($name == 'PRIMARY') {
$out .= 'PRIMARY KEY';
@ -603,7 +603,7 @@ class Mysql extends DboSource {
* 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
* @return array Array of table names in the database
*/
public function listDetailedSources($name = null) {
$condition = '';

View file

@ -22,8 +22,6 @@ App::uses('DboSource', 'Model/Datasource');
/**
* PostgreSQL layer for DBO.
*
* Long description for class
*
* @package Cake.Model.Datasource.Database
*/
class Postgres extends DboSource {
@ -153,7 +151,7 @@ class Postgres extends DboSource {
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
*
* @param mixed $data
* @return array Array of tablenames in the database
* @return array Array of table names in the database
*/
public function listSources($data = null) {
$cache = parent::listSources();
@ -296,22 +294,21 @@ class Postgres extends DboSource {
* Deletes all the records in a table and drops all associated auto-increment sequences
*
* @param mixed $table A string or model class representing the table to be truncated
* @param boolean $reset true for resseting the sequence, false to leave it as is.
* and if 1, sequences are not modified
* @param boolean $reset true for resetting the sequence, false to leave it as is.
* and if 1, sequences are not modified
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
*/
public function truncate($table, $reset = 0) {
$table = $this->fullTableName($table, false);
if (!isset($this->_sequenceMap[$table])) {
public function truncate($table, $reset = false) {
$fullTable = $this->fullTableName($table, false);
if (!isset($this->_sequenceMap[$fullTable])) {
$cache = $this->cacheSources;
$this->cacheSources = false;
$this->describe($table);
$this->cacheSources = $cache;
}
if ($this->execute('DELETE FROM ' . $this->fullTableName($table))) {
$table = $this->fullTableName($table, false);
if (isset($this->_sequenceMap[$table]) && $reset !== 1) {
foreach ($this->_sequenceMap[$table] as $field => $sequence) {
if (isset($this->_sequenceMap[$fullTable]) && $reset != true) {
foreach ($this->_sequenceMap[$fullTable] as $field => $sequence) {
$this->_execute("ALTER SEQUENCE \"{$sequence}\" RESTART WITH 1");
}
}
@ -337,7 +334,7 @@ class Postgres extends DboSource {
* Generates the fields list of an SQL query.
*
* @param Model $model
* @param string $alias Alias tablename
* @param string $alias Alias table name
* @param mixed $fields
* @param boolean $quote
* @return array
@ -397,7 +394,7 @@ class Postgres extends DboSource {
* Quotes the fields in a function call.
*
* @param string $match matched string
* @return string quoted strig
* @return string quoted string
*/
protected function _quoteFunctionField($match) {
$prepend = '';
@ -409,7 +406,7 @@ class Postgres extends DboSource {
if (!$constant && strpos($match[1], '.') === false) {
$match[1] = $this->name($match[1]);
} elseif (!$constant){
} elseif (!$constant) {
$parts = explode('.', $match[1]);
if (!Set::numeric($parts)) {
$match[1] = $this->name($match[1]);
@ -550,7 +547,7 @@ class Postgres extends DboSource {
protected function _alterIndexes($table, $indexes) {
$alter = array();
if (isset($indexes['drop'])) {
foreach($indexes['drop'] as $name => $value) {
foreach ($indexes['drop'] as $name => $value) {
$out = 'DROP ';
if ($name == 'PRIMARY') {
continue;
@ -737,7 +734,7 @@ class Postgres extends DboSource {
* Translates between PHP boolean values and PostgreSQL boolean values
*
* @param mixed $data Value to be translated
* @param boolean $quote true to quote a boolean to be used in a query, flase to return the boolean value
* @param boolean $quote true to quote a boolean to be used in a query, false to return the boolean value
* @return boolean Converted boolean value
*/
public function boolean($data, $quote = false) {

View file

@ -131,7 +131,7 @@ class Sqlite extends DboSource {
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
*
* @param mixed $data
* @return array Array of tablenames in the database
* @return array Array of table names in the database
*/
public function listSources($data = null) {
$cache = parent::listSources();
@ -165,7 +165,7 @@ class Sqlite extends DboSource {
if ($cache != null) {
return $cache;
}
$table = $this->fullTableName($model);
$table = $this->fullTableName($model, false);
$fields = array();
$result = $this->_execute('PRAGMA table_info(' . $table . ')');
@ -286,9 +286,9 @@ class Sqlite extends DboSource {
}
} elseif (strpos($querystring, 'PRAGMA table_info') === 0) {
$selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk');
} elseif(strpos($querystring, 'PRAGMA index_list') === 0) {
} elseif (strpos($querystring, 'PRAGMA index_list') === 0) {
$selects = array('seq', 'name', 'unique');
} elseif(strpos($querystring, 'PRAGMA index_info') === 0) {
} elseif (strpos($querystring, 'PRAGMA index_info') === 0) {
$selects = array('seqno', 'cid', 'name');
}
while ($j < $num_fields) {
@ -297,7 +297,7 @@ class Sqlite extends DboSource {
continue;
}
if (preg_match('/\bAS\s+(.*)/i', $selects[$j], $matches)) {
$columnName = trim($matches[1],'"');
$columnName = trim($matches[1], '"');
} else {
$columnName = trim(str_replace('"', '', $selects[$j]));
}
@ -454,7 +454,7 @@ class Sqlite extends DboSource {
}
/**
* Overrides DboSource::index to handle SQLite indexe introspection
* Overrides DboSource::index to handle SQLite index introspection
* Returns an array of the indexes in given table name.
*
* @param string $model Name of model to inspect

View file

@ -167,7 +167,7 @@ class Sqlserver extends DboSource {
* Returns an array of sources (tables) in the database.
*
* @param mixed $data
* @return array Array of tablenames in the database
* @return array Array of table names in the database
*/
public function listSources($data = null) {
$cache = parent::listSources();
@ -260,7 +260,7 @@ class Sqlserver extends DboSource {
* Generates the fields list of an SQL query.
*
* @param Model $model
* @param string $alias Alias tablename
* @param string $alias Alias table name
* @param array $fields
* @param boolean $quote
* @return array
@ -585,6 +585,7 @@ class Sqlserver extends DboSource {
return parent::value($data, $column);
}
}
/**
* Returns an array of all result rows for a given SQL query.
* Returns false if no rows matched.
@ -742,14 +743,15 @@ class Sqlserver extends DboSource {
}
return $affected;
}
/**
* Executes given SQL statement.
*
* @param string $sql SQL statement
* @param array $params list of params to be bound to query (supported only in select)
* @param array $prepareOptions Options to be used in the prepare statement
* @return mixed PDOStatement if query executes with no problem, true as the result of a succesfull, false on error
* query returning no rows, suchs as a CREATE statement, false otherwise
* @return mixed PDOStatement if query executes with no problem, true as the result of a successful, false on error
* query returning no rows, such as a CREATE statement, false otherwise
*/
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
$this->_lastAffected = false;

View file

@ -135,7 +135,7 @@ class DboSource extends DataSource {
protected $_queriesLogMax = 200;
/**
* Caches serialzed results of executed queries
* Caches serialized results of executed queries
*
* @var array Maximum number of queries in the queries log.
*/
@ -344,7 +344,7 @@ class DboSource extends DataSource {
/**
* Returns an object to represent a database identifier in a query. Expression objects
* are not sanitized or esacped.
* are not sanitized or escaped.
*
* @param string $identifier A SQL expression to be used as an identifier
* @return stdClass An object representing a database identifier to be used in a query
@ -358,7 +358,7 @@ class DboSource extends DataSource {
/**
* Returns an object to represent a database expression in a query. Expression objects
* are not sanitized or esacped.
* are not sanitized or escaped.
*
* @param string $expression An arbitrary SQL expression to be inserted into a query.
* @return stdClass An object representing a database expression to be used in a query
@ -418,7 +418,7 @@ class DboSource extends DataSource {
* @param array $params list of params to be bound to query
* @param array $prepareOptions Options to be used in the prepare statement
* @return mixed PDOStatement if query executes with no problem, true as the result of a successful, false on error
* query returning no rows, suchs as a CREATE statement, false otherwise
* query returning no rows, such as a CREATE statement, false otherwise
*/
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
$sql = trim($sql);
@ -744,7 +744,7 @@ class DboSource extends DataSource {
* A read will either return the value or null.
*
* @param string $method Name of the method being cached.
* @param string $key The keyname for the cache operation.
* @param string $key The key name for the cache operation.
* @param mixed $value The value to cache into memory.
* @return mixed Either null on failure, or the value if its set.
*/
@ -1791,7 +1791,7 @@ class DboSource extends DataSource {
* @param array $fields
* @param boolean $quoteValues If values should be quoted, or treated as SQL snippets
* @param boolean $alias Include the model alias in the field name
* @return array Fields and values, quoted and preparted
* @return array Fields and values, quoted and prepared
*/
protected function _prepareUpdateFields($model, $fields, $quoteValues = true, $alias = false) {
$quotedAlias = $this->startQuote . $model->alias . $this->endQuote;
@ -1947,7 +1947,7 @@ class DboSource extends DataSource {
if (!isset($params[1])) {
$params[1] = 'count';
}
if (is_object($model) && $model->isVirtualField($params[0])){
if (is_object($model) && $model->isVirtualField($params[0])) {
$arg = $this->_quoteFields($model->getVirtualField($params[0]));
} else {
$arg = $this->name($params[0]);
@ -2048,7 +2048,7 @@ class DboSource extends DataSource {
*
* @param Model $model
* @param mixed $conditions Array of conditions, conditions string, null or false. If an array of conditions,
* or string conditions those conditions will be returned. With other values the model's existance will be checked.
* or string conditions those conditions will be returned. With other values the model's existence will be checked.
* If the model doesn't exist a null or false will be returned depending on the input value.
* @param boolean $useAlias Use model aliases rather than table names when generating conditions
* @return mixed Either null, false, $conditions or an array of default conditions to use.
@ -2110,7 +2110,7 @@ class DboSource extends DataSource {
* Converts model virtual fields into sql expressions to be fetched later
*
* @param Model $model
* @param string $alias Alias tablename
* @param string $alias Alias table name
* @param mixed $fields virtual fields to be used on query
* @return array
*/
@ -2128,7 +2128,7 @@ class DboSource extends DataSource {
* Generates the fields list of an SQL query.
*
* @param Model $model
* @param string $alias Alias tablename
* @param string $alias Alias table name
* @param mixed $fields
* @param boolean $quote If false, returns fields array unquoted
* @return array
@ -2191,7 +2191,7 @@ class DboSource extends DataSource {
}
if (is_object($fields[$i]) && isset($fields[$i]->type) && $fields[$i]->type === 'expression') {
$fields[$i] = $fields[$i]->value;
} elseif (preg_match('/^\(.*\)\s' . $this->alias . '.*/i', $fields[$i])){
} elseif (preg_match('/^\(.*\)\s' . $this->alias . '.*/i', $fields[$i])) {
continue;
} elseif (!preg_match('/^.+\\(.*\\)/', $fields[$i])) {
$prepend = '';
@ -2505,7 +2505,7 @@ class DboSource extends DataSource {
* Auxiliary function to quote matches `Model.fields` from a preg_replace_callback call
*
* @param string $match matched string
* @return string quoted strig
* @return string quoted string
*/
protected function _quoteMatchedField($match) {
if (is_numeric($match[0])) {
@ -2622,7 +2622,7 @@ class DboSource extends DataSource {
if (!is_array($group)) {
$group = array($group);
}
foreach($group as $index => $key) {
foreach ($group as $index => $key) {
if (is_object($model) && $model->isVirtualField($key)) {
$group[$index] = '(' . $model->getVirtualField($key) . ')';
}
@ -2877,7 +2877,7 @@ class DboSource extends DataSource {
/**
* Generate a database-native column schema string
*
* @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]),
* @param array $column An array structured like the following: array('name' => 'value', 'type' => 'value'[, options]),
* where options can be 'default', 'length', or 'key'.
* @return string
*/
@ -2911,7 +2911,7 @@ class DboSource extends DataSource {
$out .= '(' . $length . ')';
}
if (($column['type'] === 'integer' || $column['type'] === 'float' ) && isset($column['default']) && $column['default'] === '') {
if (($column['type'] === 'integer' || $column['type'] === 'float') && isset($column['default']) && $column['default'] === '') {
$column['default'] = null;
}
$out = $this->_buildFieldParameters($out, $column, 'beforeDefault');

View file

@ -47,13 +47,13 @@ class DatabaseSession implements CakeSessionHandlerInterface {
if (empty($modelName)) {
$settings = array(
'class' =>'Session',
'class' => 'Session',
'alias' => 'Session',
'table' => 'cake_sessions',
);
} else {
$settings = array(
'class' =>$modelName,
'class' => $modelName,
'alias' => 'Session',
);
}

View file

@ -19,12 +19,10 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Included libs
*/
App::uses('ClassRegistry', 'Utility');
App::uses('Validation', 'Utility');
App::uses('String', 'Utility');
App::uses('Set', 'Utility');
App::uses('BehaviorCollection', 'Model');
App::uses('ModelBehavior', 'Model');
App::uses('ConnectionManager', 'Model');
@ -536,7 +534,7 @@ class Model extends Object {
*/
protected $_associationKeys = array(
'belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'),
'hasOne' => array('className', 'foreignKey','conditions', 'fields','order', 'dependent'),
'hasOne' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'dependent'),
'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'),
'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery', 'deleteQuery', 'insertQuery')
);
@ -700,6 +698,11 @@ class Model extends Object {
} elseif ($this->table === false) {
$this->table = Inflector::tableize($this->name);
}
if ($this->tablePrefix === null) {
unset($this->tablePrefix);
}
$this->_createLinks();
$this->Behaviors->init($this->alias, $this->actsAs);
}
@ -724,7 +727,7 @@ class Model extends Object {
/**
* Handles the lazy loading of model associations by looking in the association arrays for the requested variable
*
* @param string $name variable tested for existance in class
* @param string $name variable tested for existence in class
* @return boolean true if the variable exists (if is a not loaded model association it will be created), false otherwise
*/
public function __isset($name) {
@ -799,6 +802,13 @@ class Model extends Object {
if ($name === 'displayField') {
return $this->displayField = $this->hasField(array('title', 'name', $this->primaryKey));
}
if ($name === 'tablePrefix') {
$this->setDataSource();
if (property_exists($this, 'tablePrefix')) {
return $this->tablePrefix;
}
return $this->tablePrefix = null;
}
if (isset($this->{$name})) {
return $this->{$name};
}
@ -1183,12 +1193,14 @@ class Model extends Object {
}
}
$format = $this->getDataSource()->columns[$type]['format'];
$day = empty($date['Y']) ? null : $date['Y'] . '-' . $date['m'] . '-' . $date['d'] . ' ';
$hour = empty($date['H']) ? null : $date['H'] . ':' . $date['i'] . ':' . $date['s'];
$date = new DateTime($day . $hour);
if ($useNewDate && !empty($date)) {
return $date->format($format);
$format = $this->getDataSource()->columns[$type]['format'];
foreach (array('m', 'd', 'H', 'i', 's') as $index) {
if (isset($date[$index])) {
$date[$index] = sprintf('%02d', $date[$index]);
}
}
return str_replace(array_keys($date), array_values($date), $format);
}
}
return $data;
@ -1394,7 +1406,7 @@ class Model extends Object {
* Returns a list of fields from the database, and sets the current model
* data (Model::$data) with the record found.
*
* @param mixed $fields String of single fieldname, or an array of fieldnames.
* @param mixed $fields String of single field name, or an array of field names.
* @param mixed $id The ID of the record to read
* @return array Array of database fields, or false if not found
* @link http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-read
@ -1849,7 +1861,7 @@ class Model extends Object {
}
/**
* Backwards compatible passtrough method for:
* Backwards compatible passthrough method for:
* saveMany(), validateMany(), saveAssociated() and validateAssociated()
*
* Saves multiple individual records for a single model; Also works with a single record, as well as
@ -2136,7 +2148,7 @@ class Model extends Object {
if (in_array($associations[$association], array('belongsTo', 'hasOne'))) {
$validates = $this->{$association}->create($values) && $this->{$association}->validates($options);
$return[$association][] = $validates;
} elseif($associations[$association] === 'hasMany') {
} elseif ($associations[$association] === 'hasMany') {
$validates = $this->{$association}->validateMany($values, $options);
$return[$association] = $validates;
}
@ -2249,11 +2261,17 @@ class Model extends Object {
if ($data['dependent'] === true) {
$model = $this->{$assoc};
$conditions = array($model->escapeField($data['foreignKey']) => $id);
if ($data['conditions']) {
$conditions = array_merge((array)$data['conditions'], $conditions);
if ($data['foreignKey'] === false && $data['conditions'] && in_array($this->name, $model->getAssociated('belongsTo'))) {
$model->recursive = 0;
$conditions = array($this->escapeField(null, $this->name) => $id);
} else {
$model->recursive = -1;
$conditions = array($model->escapeField($data['foreignKey']) => $id);
if ($data['conditions']) {
$conditions = array_merge((array)$data['conditions'], $conditions);
}
}
$model->recursive = -1;
if (isset($data['exclusive']) && $data['exclusive']) {
$model->deleteAll($conditions);
@ -3066,6 +3084,7 @@ class Model extends Object {
}
return $valid;
}
/**
* Marks a field as invalid, optionally setting the name of validation
* rule (in case of multiple validation for field) that was broken.

View file

@ -16,9 +16,6 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Load Model and AppModel
*/
App::uses('AppModel', 'Model');
/**

View file

@ -222,7 +222,7 @@ class CakeRequest implements ArrayAccess {
$uri = substr($uri, strlen($base));
}
if (strpos($uri, '?') !== false) {
$uri = parse_url($uri, PHP_URL_PATH);
list($uri) = explode('?', $uri, 2);
}
if (empty($uri) || $uri == '/' || $uri == '//') {
return '/';
@ -278,10 +278,10 @@ class CakeRequest implements ArrayAccess {
$docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot);
if (!empty($base) || !$docRootContainsWebroot) {
if (strpos($this->webroot, $dir) === false) {
if (strpos($this->webroot, '/' . $dir . '/') === false) {
$this->webroot .= $dir . '/' ;
}
if (strpos($this->webroot, $webroot) === false) {
if (strpos($this->webroot, '/' . $webroot . '/') === false) {
$this->webroot .= $webroot . '/';
}
}
@ -483,7 +483,7 @@ class CakeRequest implements ArrayAccess {
* ### Callback detectors
*
* Callback detectors allow you to provide a 'callback' type to handle the check. The callback will
* recieve the request object as its only parameter.
* receive the request object as its only parameter.
*
* e.g `addDetector('custom', array('callback' => array('SomeClass', 'somemethod')));`
*

View file

@ -423,7 +423,7 @@ class CakeResponse {
* will have the same effect as only doing `header('WWW-Authenticate: Not-Negotiate');`
*
* @param mixed $header. An array of header strings or a single header string
* - an assotiative array of "header name" => "header value" is also accepted
* - an associative array of "header name" => "header value" is also accepted
* - an array of string headers is also accepted
* @param mixed $value. The header value.
* @return array list of headers to be sent
@ -674,7 +674,7 @@ class CakeResponse {
}
/**
* Sets the correct headers to instruct the browser to dowload the response as a file.
* Sets the correct headers to instruct the browser to download the response as a file.
*
* @param string $filename the name of the file as the browser will download the response
* @return void

View file

@ -16,6 +16,7 @@
* @since CakePHP(tm) v 1.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Validation', 'Utility');
/**

View file

@ -18,7 +18,7 @@
*/
/**
* Abstract class
* Abstract transport for sending email
*
* @package Cake.Network.Email
*/

View file

@ -16,6 +16,7 @@
* @since CakePHP(tm) v 2.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Validation', 'Utility');
App::uses('Multibyte', 'I18n');
App::uses('AbstractTransport', 'Network/Email');

View file

@ -18,7 +18,7 @@
*/
/**
* Mail class
* Send mail using mail() function
*
* @package Cake.Network.Email
*/

View file

@ -16,10 +16,11 @@
* @since CakePHP(tm) v 2.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('CakeSocket', 'Network');
/**
* SendEmail class
* Send mail using SMTP protocol
*
* @package Cake.Network.Email
*/

View file

@ -42,7 +42,7 @@ class DigestAuthentication {
}
/**
* Retrive information about the authetication
* Retrieve information about the authentication
*
* @param HttpSocket $http
* @param array $authInfo

View file

@ -18,7 +18,7 @@
*/
/**
* HTTP Response
* HTTP Response from HttpSocket.
*
* @package Cake.Network.Http
*/
@ -74,7 +74,7 @@ class HttpResponse implements ArrayAccess {
public $raw = '';
/**
* Contructor
* Constructor
*
* @param string $message
*/
@ -168,7 +168,7 @@ class HttpResponse implements ArrayAccess {
* Generic function to decode a $body with a given $encoding. Returns either an array with the keys
* 'body' and 'header' or false on failure.
*
* @param string $body A string continaing the body to decode.
* @param string $body A string containing the body to decode.
* @param mixed $encoding Can be false in case no encoding is being used, or a string representing the encoding.
* @return mixed Array of response headers and body or false.
*/
@ -191,7 +191,7 @@ class HttpResponse implements ArrayAccess {
* Decodes a chunked message $body and returns either an array with the keys 'body' and 'header' or false as
* a result.
*
* @param string $body A string continaing the chunked body to decode.
* @param string $body A string containing the chunked body to decode.
* @return mixed Array of response headers and body or false.
* @throws SocketException
*/
@ -283,7 +283,7 @@ class HttpResponse implements ArrayAccess {
* Parses cookies in response headers.
*
* @param array $header Header array containing one ore more 'Set-Cookie' headers.
* @return mixed Either false on no cookies, or an array of cookies recieved.
* @return mixed Either false on no cookies, or an array of cookies received.
* @todo Make this 100% RFC 2965 confirm
*/
public function parseCookies($header) {
@ -411,7 +411,7 @@ class HttpResponse implements ArrayAccess {
}
/**
* ArrayAccess - 0ffset Set
* ArrayAccess - Offset Set
*
* @param mixed $offset
* @param mixed $value

View file

@ -157,7 +157,30 @@ class HttpSocket extends CakeSocket {
}
/**
* Set authentication settings
* Set authentication settings.
*
* Accepts two forms of parameters. If all you need is a username + password, as with
* Basic authentication you can do the following:
*
* {{{
* $http->configAuth('Basic', 'mark', 'secret');
* }}}
*
* If you are using an authentication strategy that requires more inputs, like Digest authentication
* you can call `configAuth()` with an array of user information.
*
* {{{
* $http->configAuth('Digest', array(
* 'user' => 'mark',
* 'pass' => 'secret',
* 'realm' => 'my-realm',
* 'nonce' => 1235
* ));
* }}}
*
* To remove any set authentication strategy, call `configAuth()` with no parameters:
*
* `$http->configAuth();`
*
* @param string $method Authentication method (ie. Basic, Digest). If empty, disable authentication
* @param mixed $user Username for authentication. Can be an array with settings to authentication class
@ -273,17 +296,17 @@ class HttpSocket extends CakeSocket {
if (!empty($this->request['cookies'])) {
$cookies = $this->buildCookies($this->request['cookies']);
}
$schema = '';
$scheme = '';
$port = 0;
if (isset($this->request['uri']['schema'])) {
$schema = $this->request['uri']['schema'];
if (isset($this->request['uri']['scheme'])) {
$scheme = $this->request['uri']['scheme'];
}
if (isset($this->request['uri']['port'])) {
$port = $this->request['uri']['port'];
}
if (
($schema === 'http' && $port != 80) ||
($schema === 'https' && $port != 443) ||
($scheme === 'http' && $port != 80) ||
($scheme === 'https' && $port != 443) ||
($port != 80 && $port != 443)
) {
$Host .= ':' . $port;
@ -610,7 +633,7 @@ class HttpSocket extends CakeSocket {
*
* @param mixed $uri Either A $uri array, or a request string. Will use $this->config if left empty.
* @param string $uriTemplate The Uri template/format to use.
* @return mixed A fully qualified URL formated according to $uriTemplate, or false on failure
* @return mixed A fully qualified URL formatted according to $uriTemplate, or false on failure
*/
protected function _buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') {
if (is_string($uri)) {
@ -712,7 +735,7 @@ class HttpSocket extends CakeSocket {
/**
* This function can be thought of as a reverse to PHP5's http_build_query(). It takes a given query string and turns it into an array and
* supports nesting by using the php bracket syntax. So this menas you can parse queries like:
* supports nesting by using the php bracket syntax. So this means you can parse queries like:
*
* - ?key[subKey]=value
* - ?key[]=value1&key[]=value2

View file

@ -20,9 +20,6 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* List of helpers to include
*/
App::uses('Router', 'Routing');
App::uses('CakeRequest', 'Network');
App::uses('CakeResponse', 'Network');
@ -56,7 +53,7 @@ class Dispatcher {
* to autoRender, via Controller::$autoRender, then Dispatcher will render the view.
*
* Actions in CakePHP can be any public method on a controller, that is not declared in Controller. If you
* want controller methods to be public and in-accesible by URL, then prefix them with a `_`.
* want controller methods to be public and in-accessible by URL, then prefix them with a `_`.
* For example `public function _loadPosts() { }` would not be accessible via URL. Private and protected methods
* are also not accessible via URL.
*
@ -272,7 +269,7 @@ class Dispatcher {
if ($parts[0] === 'theme') {
$themeName = $parts[1];
unset($parts[0], $parts[1]);
$fileFragment = implode(DS, $parts);
$fileFragment = urldecode(implode(DS, $parts));
$path = App::themePath($themeName) . 'webroot' . DS;
if (file_exists($path . $fileFragment)) {
$assetFile = $path . $fileFragment;
@ -281,7 +278,7 @@ class Dispatcher {
$plugin = Inflector::camelize($parts[0]);
if (CakePlugin::loaded($plugin)) {
unset($parts[0]);
$fileFragment = implode(DS, $parts);
$fileFragment = urldecode(implode(DS, $parts));
$pluginWebroot = CakePlugin::path($plugin) . 'webroot' . DS;
if (file_exists($pluginWebroot . $fileFragment)) {
$assetFile = $pluginWebroot . $fileFragment;

View file

@ -1,13 +1,5 @@
<?php
/**
* A single Route used by the Router to connect requests to
* parameter maps.
*
* Not normally created as a standalone. Use Router::connect() to create
* Routes for your application.
*
* PHP5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@ -16,10 +8,21 @@
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Routing.Route
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Set', 'Utility');
/**
* A single Route used by the Router to connect requests to
* parameter maps.
*
* Not normally created as a standalone. Use Router::connect() to create
* Routes for your application.
*
* @package Cake.Routing.Route
*/
class CakeRoute {
/**
@ -60,7 +63,7 @@ class CakeRoute {
protected $_greedy = false;
/**
* The compiled route regular expresssion
* The compiled route regular expression
*
* @var string
*/
@ -229,7 +232,7 @@ class CakeRoute {
// restructure 'pass' key route params
if (isset($this->options['pass'])) {
$j = count($this->options['pass']);
while($j--) {
while ($j--) {
if (isset($route[$this->options['pass'][$j]])) {
array_unshift($route['pass'], $route[$this->options['pass'][$j]]);
}
@ -341,7 +344,7 @@ class CakeRoute {
}
/**
* Apply persistent parameters to a url array. Persistant parameters are a special
* Apply persistent parameters to a url array. Persistent parameters are a special
* key used during route creation to force route parameters to persist when omitted from
* a url array.
*
@ -475,7 +478,8 @@ class CakeRoute {
$named = array();
foreach ($params['named'] as $key => $value) {
if (is_array($value)) {
foreach ($value as $namedKey => $namedValue) {
$flat = Set::flatten($value, '][');
foreach ($flat as $namedKey => $namedValue) {
$named[] = $key . "[$namedKey]" . $separator . rawurlencode($namedValue);
}
} else {

View file

@ -1,11 +1,5 @@
<?php
App::uses('CakeRoute', 'Routing/Route');
/**
* Plugin short route, that copies the plugin param to the controller parameters
* It is used for supporting /:plugin routes.
*
* PHP5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@ -14,14 +8,22 @@ App::uses('CakeRoute', 'Routing/Route');
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Routing.Route
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('CakeRoute', 'Routing/Route');
/**
* Plugin short route, that copies the plugin param to the controller parameters
* It is used for supporting /:plugin routes.
*
* @package Cake.Routing.Route
*/
class PluginShortRoute extends CakeRoute {
/**
* Parses a string url into an array. If a plugin key is found, it will be copied to the
* Parses a string url into an array. If a plugin key is found, it will be copied to the
* controller parameter
*
* @param string $url The url to parse
@ -37,7 +39,7 @@ class PluginShortRoute extends CakeRoute {
}
/**
* Reverse route plugin shortcut urls. If the plugin and controller
* Reverse route plugin shortcut urls. If the plugin and controller
* are not the same the match is an auto fail.
*
* @param array $url Array of parameters to convert to a string.

View file

@ -1,14 +1,5 @@
<?php
App::uses('CakeResponse', 'Network');
App::uses('CakeRoute', 'Routing/Route');
/**
* Redirect route will perform an immediate redirect. Redirect routes
* are useful when you want to have Routing layer redirects occur in your
* application, for when URLs move.
*
* PHP5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@ -21,6 +12,17 @@ App::uses('CakeRoute', 'Routing/Route');
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('CakeResponse', 'Network');
App::uses('CakeRoute', 'Routing/Route');
/**
* Redirect route will perform an immediate redirect. Redirect routes
* are useful when you want to have Routing layer redirects occur in your
* application, for when URLs move.
*
* @package Cake.Routing.Route
*/
class RedirectRoute extends CakeRoute {
/**
@ -31,7 +33,7 @@ class RedirectRoute extends CakeRoute {
public $response = null;
/**
* The location to redirect to. Either a string or a cake array url.
* The location to redirect to. Either a string or a cake array url.
*
* @var mixed
*/
@ -100,7 +102,7 @@ class RedirectRoute extends CakeRoute {
}
/**
* Stop execution of the current script. Wraps exit() making
* Stop execution of the current script. Wraps exit() making
* testing easier.
*
* @param integer|string $status see http://php.net/exit for values

View file

@ -80,6 +80,7 @@ class BasicsTest extends CakeTestCase {
$this->assertEquals($result, array());
}
/**
* testHttpBase method
*
@ -256,7 +257,7 @@ class BasicsTest extends CakeTestCase {
$this->assertEquals($expected, $result);
$result = am(array('one' => array(2, 3), 'two' => array('foo')), array('one' => array(4, 5)));
$expected = array('one' => array(4, 5),'two' => array('foo'));
$expected = array('one' => array(4, 5), 'two' => array('foo'));
$this->assertEquals($expected, $result);
}

View file

@ -126,6 +126,19 @@ class CacheTest extends CakeTestCase {
$read = Cache::read('Test', 'invalid');
}
/**
* Test reading from a config that is undefined.
*
* @return void
*/
public function testReadNonExistingConfig() {
$this->assertFalse(Cache::read('key', 'totally fake'));
$this->assertFalse(Cache::write('key', 'value', 'totally fake'));
$this->assertFalse(Cache::increment('key', 1, 'totally fake'));
$this->assertFalse(Cache::decrement('key', 1, 'totally fake'));
}
/**
* test that trying to configure classes that don't extend CacheEngine fail.
*
@ -148,10 +161,10 @@ class CacheTest extends CakeTestCase {
$_cacheConfigSessions = Cache::config('sessions');
$_cacheConfigTests = Cache::config('tests');
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
$result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'sessions'));
$this->assertEquals($result['settings'], Cache::settings('sessions'));
$result = Cache::config('tests', array('engine'=> 'File', 'path' => TMP . 'tests'));
$result = Cache::config('tests', array('engine' => 'File', 'path' => TMP . 'tests'));
$this->assertEquals($result['settings'], Cache::settings('tests'));
Cache::config('sessions', $_cacheConfigSessions['settings']);
@ -322,7 +335,7 @@ class CacheTest extends CakeTestCase {
*/
public function testCacheDisable() {
Configure::write('Cache.disable', false);
Cache::config('test_cache_disable_1', array('engine'=> 'File', 'path' => TMP . 'tests'));
Cache::config('test_cache_disable_1', array('engine' => 'File', 'path' => TMP . 'tests'));
$this->assertTrue(Cache::write('key_1', 'hello', 'test_cache_disable_1'));
$this->assertSame(Cache::read('key_1', 'test_cache_disable_1'), 'hello');
@ -338,7 +351,7 @@ class CacheTest extends CakeTestCase {
$this->assertSame(Cache::read('key_3', 'test_cache_disable_1'), 'hello');
Configure::write('Cache.disable', true);
Cache::config('test_cache_disable_2', array('engine'=> 'File', 'path' => TMP . 'tests'));
Cache::config('test_cache_disable_2', array('engine' => 'File', 'path' => TMP . 'tests'));
$this->assertFalse(Cache::write('key_4', 'hello', 'test_cache_disable_2'));
$this->assertFalse(Cache::read('key_4', 'test_cache_disable_2'));

View file

@ -45,7 +45,7 @@ class FileEngineTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/
@ -61,10 +61,10 @@ class FileEngineTest extends CakeTestCase {
* @return void
*/
public function testCacheDirChange() {
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
$result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'sessions'));
$this->assertEquals($result['settings'], Cache::settings('sessions'));
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'tests'));
$result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'tests'));
$this->assertEquals($result['settings'], Cache::settings('sessions'));
$this->assertNotEquals($result['settings'], Cache::settings('default'));
}
@ -276,7 +276,7 @@ class FileEngineTest extends CakeTestCase {
public function testRemoveWindowsSlashesFromCache() {
Cache::config('windows_test', array('engine' => 'File', 'isWindows' => true, 'prefix' => null, 'path' => TMP));
$expected = array (
$expected = array(
'C:\dev\prj2\sites\cake\libs' => array(
0 => 'C:\dev\prj2\sites\cake\libs', 1 => 'C:\dev\prj2\sites\cake\libs\view',
2 => 'C:\dev\prj2\sites\cake\libs\view\scaffolds', 3 => 'C:\dev\prj2\sites\cake\libs\view\pages',
@ -361,7 +361,7 @@ class FileEngineTest extends CakeTestCase {
$write = Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o',fileperms(TMP . 'tests' . DS .'cake_masking_test')), -4);
$expected = '0664';
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
Cache::delete('masking_test', 'mask_test');
Cache::drop('mask_test');
@ -369,7 +369,7 @@ class FileEngineTest extends CakeTestCase {
$write = Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o',fileperms(TMP . 'tests' . DS .'cake_masking_test')), -4);
$expected = '0666';
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
Cache::delete('masking_test', 'mask_test');
Cache::drop('mask_test');
@ -377,7 +377,7 @@ class FileEngineTest extends CakeTestCase {
$write = Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o',fileperms(TMP . 'tests' . DS .'cake_masking_test')), -4);
$expected = '0644';
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
Cache::delete('masking_test', 'mask_test');
Cache::drop('mask_test');
@ -385,7 +385,7 @@ class FileEngineTest extends CakeTestCase {
$write = Cache::write('masking_test', $data, 'mask_test');
$result = substr(sprintf('%o',fileperms(TMP . 'tests' . DS .'cake_masking_test')), -4);
$expected = '0640';
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
Cache::delete('masking_test', 'mask_test');
Cache::drop('mask_test');
}

View file

@ -81,7 +81,7 @@ class MemcacheEngineTest extends CakeTestCase {
unset($settings['serialize'], $settings['path']);
$expecting = array(
'prefix' => 'cake_',
'duration'=> 3600,
'duration' => 3600,
'probability' => 100,
'servers' => array('127.0.0.1'),
'persistent' => true,
@ -102,7 +102,7 @@ class MemcacheEngineTest extends CakeTestCase {
$available = true;
$Memcache = new Memcache();
foreach($servers as $server) {
foreach ($servers as $server) {
list($host, $port) = explode(':', $server);
if (!@$Memcache->connect($host, $port)) {
$available = false;
@ -312,12 +312,12 @@ class MemcacheEngineTest extends CakeTestCase {
public function testConfigurationConflict() {
Cache::config('long_memcache', array(
'engine' => 'Memcache',
'duration'=> '+2 seconds',
'duration' => '+2 seconds',
'servers' => array('127.0.0.1:11211'),
));
Cache::config('short_memcache', array(
'engine' => 'Memcache',
'duration'=> '+1 seconds',
'duration' => '+1 seconds',
'servers' => array('127.0.0.1:11211'),
));
Cache::config('some_file', array('engine' => 'File'));
@ -364,6 +364,7 @@ class MemcacheEngineTest extends CakeTestCase {
Cache::clear(false, 'memcache2');
}
/**
* test that a 0 duration can succesfully write.
*

View file

@ -59,7 +59,7 @@ class XcacheEngineTest extends CakeTestCase {
$settings = Cache::settings();
$expecting = array(
'prefix' => 'cake_',
'duration'=> 3600,
'duration' => 3600,
'probability' => 100,
'engine' => 'Xcache',
);

View file

@ -32,8 +32,8 @@ class IniReaderTest extends CakeTestCase {
*
* @return void
*/
public function setup() {
parent::setup();
public function setUp() {
parent::setUp();
$this->path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
}

View file

@ -28,6 +28,7 @@ class PhpReaderTest extends CakeTestCase {
parent::setUp();
$this->path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
}
/**
* test reading files
*

View file

@ -37,11 +37,12 @@ class AclShellTest extends CakeTestCase {
public $fixtures = array('core.aco', 'core.aro', 'core.aros_aco');
/**
* setup method
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
Configure::write('Acl.database', 'test');
Configure::write('Acl.classname', 'DbAcl');

View file

@ -59,7 +59,7 @@ class BakeShellTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/
@ -83,21 +83,38 @@ class BakeShellTest extends CakeTestCase {
$this->Shell->View = $this->getMock('ModelTask', array(), array(&$this->Dispatcher));
$this->Shell->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher));
$this->Shell->DbConfig->expects($this->once())->method('getConfig')->will($this->returnValue('test'));
$this->Shell->DbConfig->expects($this->once())
->method('getConfig')
->will($this->returnValue('test'));
$this->Shell->Model->expects($this->never())->method('getName');
$this->Shell->Model->expects($this->once())->method('bake')->will($this->returnValue(true));
$this->Shell->Model->expects($this->never())
->method('getName');
$this->Shell->Model->expects($this->once())
->method('bake')
->will($this->returnValue(true));
$this->Shell->Controller->expects($this->once())->method('bake')->will($this->returnValue(true));
$this->Shell->View->expects($this->once())->method('execute');
$this->Shell->Controller->expects($this->once())
->method('bake')
->will($this->returnValue(true));
$this->Shell->View->expects($this->once())
->method('execute');
$this->Shell->expects($this->once())->method('_stop');
$this->Shell->expects($this->at(0))->method('out')->with('Bake All');
$this->Shell->expects($this->at(5))->method('out')->with('<success>Bake All complete</success>');
$this->Shell->expects($this->at(0))
->method('out')
->with('Bake All');
$this->Shell->expects($this->at(5))
->method('out')
->with('<success>Bake All complete</success>');
$this->Shell->connection = '';
$this->Shell->params = array();
$this->Shell->args = array('User');
$this->Shell->all();
$this->assertEquals('User', $this->Shell->View->args[0]);
}
}

View file

@ -60,7 +60,7 @@ class CommandListShellTest extends CakeTestCase {
}
/**
* teardown
* tearDown
*
* @return void
*/

View file

@ -97,7 +97,7 @@ class SchemaShellTest extends CakeTestCase {
);
/**
* setup method
* setUp method
*
* @return void
*/

View file

@ -64,6 +64,7 @@ class ControllerTaskTest extends CakeTestCase {
* @return void
*/
public function setUp() {
parent::setUp();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ControllerTask',
@ -86,14 +87,15 @@ class ControllerTaskTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/
public function teardown() {
public function tearDown() {
unset($this->Task);
ClassRegistry::flush();
App::build();
parent::tearDown();
}
/**
@ -274,8 +276,8 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertContains(' * @property AclComponent $Acl', $result);
$this->assertContains(' * @property AuthComponent $Auth', $result);
$this->assertContains('class ArticlesController extends AppController', $result);
$this->assertContains("\$components = array('Acl', 'Auth')", $result);
$this->assertContains("\$helpers = array('Ajax', 'Time')", $result);
$this->assertContains("public \$components = array('Acl', 'Auth')", $result);
$this->assertContains("public \$helpers = array('Ajax', 'Time')", $result);
$this->assertContains("--actions--", $result);
$result = $this->Task->bake('Articles', 'scaffold', $helpers, $components);

View file

@ -31,7 +31,7 @@ App::uses('DbConfigTask', 'Console/Command/Task');
class DbConfigTaskTest extends CakeTestCase {
/**
* setup method
* setUp method
*
* @return void
*/

View file

@ -95,7 +95,7 @@ class ModelTaskTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/
@ -205,7 +205,7 @@ class ModelTaskTest extends CakeTestCase {
*
* @return void
*/
public function testGetTableOddTable() {
public function testGetTableOddTableInteractive() {
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ModelTask',
@ -233,6 +233,34 @@ class ModelTaskTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
/**
* test getTable with non-conventional tablenames
*
* @return void
*/
public function testGetTableOddTable() {
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ModelTask',
array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables'),
array($out, $out, $in)
);
$this->_setupOtherMocks();
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->interactive = false;
$this->Task->args = array('BakeOdd');
$this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd')));
$this->Task->listAll();
$result = $this->Task->getTable('BakeOdd');
$expected = 'bake_odd';
$this->assertEquals($expected, $result);
}
/**
* test that initializing the validations works.
*
@ -970,6 +998,61 @@ STRINGEND;
$this->Task->execute();
}
/**
* test that odd tablenames arent inflected back from modelname
*
* @return void
*/
public function testExecuteIntoBakeOddTables() {
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ModelTask',
array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'bake', 'bakeFixture'),
array($out, $out, $in)
);
$this->_setupOtherMocks();
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('BakeOdd');
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
$this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd')));
$object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test'));
$this->Task->expects($this->once())->method('_getModelObject')->with('BakeOdd', 'bake_odd')->will($this->returnValue($object));
$this->Task->expects($this->once())->method('bake')->with($object, false)->will($this->returnValue(true));
$this->Task->expects($this->once())->method('bakeFixture')->with('BakeOdd', 'bake_odd');
$this->Task->execute();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('ModelTask',
array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'createFile'),
array($out, $out, $in)
);
$this->_setupOtherMocks();
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('BakeOdd');
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
$this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd')));
$object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test'));
$this->Task->expects($this->once())->method('_getModelObject')->will($this->returnValue($object));
$this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue(array()));
$this->Task->expects($this->once())->method('doValidation')->will($this->returnValue(array()));
$filename = '/my/path/BakeOdd.php';
$this->Task->expects($this->once())->method('createFile')
->with($filename, $this->stringContains('class BakeOdd'));
$filename = '/my/path/BakeOdd.php';
$this->Task->expects($this->once())->method('createFile')
->with($filename, $this->stringContains('public $useTable = \'bake_odd\''));
$this->Task->execute();
}
/**
* test that skipTables changes how all() works.
*

View file

@ -36,7 +36,7 @@ App::uses('File', 'Utility');
class PluginTaskTest extends CakeTestCase {
/**
* setup method
* setUp method
*
* @return void
*/

View file

@ -35,7 +35,7 @@ App::uses('File', 'Utility');
class ProjectTaskTest extends CakeTestCase {
/**
* setup method
* setUp method
*
* @return void
*/
@ -52,7 +52,7 @@ class ProjectTaskTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/

View file

@ -19,12 +19,12 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('ShellDispatcher', 'Console');
App::uses('ConsoleOutput', 'Console');
App::uses('ConsoleInput', 'Console');
App::uses('Shell', 'Console');
App::uses('TemplateTask', 'Console/Command/Task');
/**
* TemplateTaskTest class
*
@ -33,11 +33,11 @@ App::uses('TemplateTask', 'Console/Command/Task');
class TemplateTaskTest extends CakeTestCase {
/**
* setup method
* setUp method
*
* @return void
*/
public function setup() {
public function setUp() {
parent::setUp();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
@ -49,7 +49,7 @@ class TemplateTaskTest extends CakeTestCase {
}
/**
* teardown method
* tearDown method
*
* @return void
*/

View file

@ -220,12 +220,12 @@ class TestTaskTest extends CakeTestCase {
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
/**
* setup method
* setUp method
*
* @return void
*/
public function setup() {
parent::setup();
public function setUp() {
parent::setUp();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);

View file

@ -38,7 +38,7 @@ class ConsoleErrorHandlerTest extends CakeTestCase {
}
/**
* teardown
* tearDown
*
* @return void
*/

View file

@ -422,6 +422,8 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('test_plugin.example');
$this->assertInstanceOf('ExampleShell', $result);
$this->assertEquals('TestPlugin', $result->plugin);
$this->assertEquals('Example', $result->name);
$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('TestPlugin.example');

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