Merge branch 'master' into 2.5

Conflicts:
	CONTRIBUTING.md
	lib/Cake/Model/Model.php
	lib/Cake/VERSION.txt
This commit is contained in:
ADmad 2013-10-30 02:34:09 +05:30
commit d9ca148499
73 changed files with 688 additions and 539 deletions

View file

@ -63,11 +63,11 @@ Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer)
repository to setup the CakePHP standard. The README contains installation info
for the sniff and phpcs.
# Additional Resources
* [CakePHP coding standards](http://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html)
* [Existing issues](https://github.com/cakephp/cakephp/issues)
* [Development Roadmaps](https://github.com/cakephp/cakephp/wiki#roadmaps)
* [General GitHub documentation](https://help.github.com/)
* [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
* #cakephp IRC channel on freenode.org

View file

@ -36,6 +36,8 @@ Get Support!
[GitHub Issues](https://github.com/cakephp/cakephp/issues) - Got issues? Please tell us!
[Roadmaps](https://github.com/cakephp/cakephp/wiki#roadmaps) - Want to contribute? Get involved!
[![Bake Status](https://secure.travis-ci.org/cakephp/cakephp.png?branch=master)](http://travis-ci.org/cakephp/cakephp)
![Cake Power](https://raw.github.com/cakephp/cakephp/master/lib/Cake/Console/Templates/skel/webroot/img/cake.power.gif)

View file

@ -1,9 +1,5 @@
<?php
/**
* This is core configuration file.
*
* Use it to configure core behaviour of CakePHP.
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
@ -18,15 +14,18 @@
* @package app.Config
* @since CakePHP(tm) v 0.2.9
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*
*/
/**
* Database configuration class.
*
* You can specify multiple configurations for production, development and testing.
*
* datasource => The name of a supported datasource; valid options are as follows:
* Database/Mysql - MySQL 4 & 5,
* Database/Sqlite - SQLite (PHP5 only),
* Database/Postgres - PostgreSQL 7 and higher,
* Database/Sqlserver - Microsoft SQL Server 2005 and higher
* Database/Mysql - MySQL 4 & 5,
* Database/Sqlite - SQLite (PHP5 only),
* Database/Postgres - PostgreSQL 7 and higher,
* Database/Sqlserver - Microsoft SQL Server 2005 and higher
*
* You can add custom database datasources (or override existing datasources) by adding the
* appropriate file to app/Model/Datasource/Database. Datasources should be named 'MyDatasource.php',
@ -43,7 +42,8 @@
* on a per-table basis with the Model::$tablePrefix property.
*
* schema =>
* For Postgres/Sqlserver specifies which schema you would like to use the tables in. Postgres defaults to 'public'. For Sqlserver, it defaults to empty and use
* For Postgres/Sqlserver specifies which schema you would like to use the tables in.
* Postgres defaults to 'public'. For Sqlserver, it defaults to empty and use
* the connected user's default schema (typically 'dbo').
*
* encoding =>

View file

@ -1,9 +1,5 @@
<?php
/**
* This is email configuration file.
*
* Use it to configure email transports of CakePHP.
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
@ -18,14 +14,20 @@
* @package app.Config
* @since CakePHP(tm) v 2.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* This is email configuration file.
*
* Use it to configure email transports of CakePHP.
*
* Email configuration class.
* You can specify multiple configurations for production, development and testing.
*
* transport => The name of a supported transport; valid options are as follows:
* Mail - Send using PHP mail function
* Smtp - Send using SMTP
* Debug - Do not send the email, just return the result
* Mail - Send using PHP mail function
* Smtp - Send using SMTP
* Debug - Do not send the email, just return the result
*
* You can add custom transports (or override existing transports) by adding the
* appropriate file to app/Network/Email. Transports should be named 'YourTransport.php',

View file

@ -18,6 +18,7 @@
* @since CakePHP(tm) v 2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
$ds = DIRECTORY_SEPARATOR;
$dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php';
@ -29,7 +30,7 @@ if (function_exists('ini_set')) {
ini_set('include_path', $root . $ds . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
if (!include ($dispatcher)) {
if (!include $dispatcher) {
trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
}
unset($paths, $path, $dispatcher, $root, $ds);

View file

@ -144,7 +144,7 @@ if (isset($filePresent)):
echo '<span class="notice">';
echo __d('cake_dev', 'DebugKit is not installed. It will help you inspect and debug different aspects of your application.');
echo '<br/>';
echo __d('cake_dev', 'You can install it from %s', $this->Html->link('github', 'https://github.com/cakephp/debug_kit'));
echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit'));
echo '</span>';
endif;
?>
@ -194,7 +194,7 @@ You can also add some CSS styles for your pages at: %s.',
</ul>
</p>
<h3><?php echo __d('cake_dev', 'More about Cake'); ?></h3>
<h3><?php echo __d('cake_dev', 'More about CakePHP'); ?></h3>
<p>
<?php echo __d('cake_dev', 'CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?>
</p>
@ -203,24 +203,32 @@ You can also add some CSS styles for your pages at: %s.',
</p>
<ul>
<li><a href="http://cakefoundation.org/"><?php echo __d('cake_dev', 'Cake Software Foundation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Promoting development related to CakePHP'); ?></li></ul></li>
<li><a href="http://www.cakephp.org">CakePHP</a>
<li><a href="http://cakephp.org">CakePHP</a>
<ul><li><?php echo __d('cake_dev', 'The Rapid Development Framework'); ?></li></ul></li>
<li><a href="http://book.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Documentation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Your Rapid Development Cookbook'); ?></li></ul></li>
<li><a href="http://api.cakephp.org"><?php echo __d('cake_dev', 'CakePHP API'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Quick Reference'); ?></li></ul></li>
<ul><li><?php echo __d('cake_dev', 'Quick API Reference'); ?></li></ul></li>
<li><a href="http://bakery.cakephp.org"><?php echo __d('cake_dev', 'The Bakery'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Everything CakePHP'); ?></li></ul></li>
<li><a href="http://plugins.cakephp.org"><?php echo __d('cake_dev', 'CakePHP plugins repo'); ?> </a>
<li><a href="http://plugins.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Plugins'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'A comprehensive list of all CakePHP plugins created by the community'); ?></li></ul></li>
<li><a href="http://community.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Community Center'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Everything related to the CakePHP community in one place'); ?></li></ul></li>
<li><a href="https://groups.google.com/group/cake-php"><?php echo __d('cake_dev', 'CakePHP Google Group'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Community mailing list'); ?></li></ul></li>
<li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a>
<ul><li><?php echo __d('cake_dev', 'Live chat about CakePHP'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/"><?php echo __d('cake_dev', 'CakePHP Code'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'For the Development of CakePHP Git repository, Downloads'); ?></li></ul></li>
<li><a href="https://cakephp.lighthouseapp.com/"><?php echo __d('cake_dev', 'CakePHP Lighthouse'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP Tickets, Wiki pages, Roadmap'); ?></li></ul></li>
<ul><li><?php echo __d('cake_dev', 'Find the CakePHP code on GitHub and contribute to the framework'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/cakephp/issues"><?php echo __d('cake_dev', 'CakePHP Issues'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP Issues'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/cakephp/wiki#roadmaps"><?php echo __d('cake_dev', 'CakePHP Roadmaps'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP Roadmaps'); ?></li></ul></li>
<li><a href="http://training.cakephp.org"><?php echo __d('cake_dev', 'Training'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Join a live session and get skilled with the framework'); ?></li></ul></li>
<li><a href="http://cakefest.org"><?php echo __d('cake_dev', 'CakeFest'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Don\'t miss our annual CakePHP conference'); ?></li></ul></li>
<li><a href="http://cakefoundation.org"><?php echo __d('cake_dev', 'Cake Software Foundation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Promoting development related to CakePHP'); ?></li></ul></li>
</ul>

View file

@ -78,7 +78,7 @@ if (!defined('WWW_ROOT')) {
}
// for built-in server
if (php_sapi_name() == 'cli-server') {
if (php_sapi_name() === 'cli-server') {
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) {
return false;
}
@ -89,11 +89,11 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if (function_exists('ini_set')) {
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
if (!include ('Cake' . DS . 'bootstrap.php')) {
if (!include 'Cake' . DS . 'bootstrap.php') {
$failed = true;
}
} else {
if (!include (CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
if (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') {
$failed = true;
}
}

View file

@ -79,11 +79,11 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if (function_exists('ini_set')) {
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
if (!include ('Cake' . DS . 'bootstrap.php')) {
if (!include 'Cake' . DS . 'bootstrap.php') {
$failed = true;
}
} else {
if (!include (CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
if (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') {
$failed = true;
}
}

View file

@ -145,9 +145,9 @@
<dirroles key="Cake/Console/Templates/default">php</dirroles>
<dirroles key="Cake/View">php</dirroles>
<release>
<install as="cake" name="bin/cake" />
<install as="cake.php" name="bin/cake.php" />
<install as="cake.bat" name="bin/cake.bat" />
<install as="cake.php" name="bin/cake.php" />
<install as="cake" name="bin/cake" />
</release>
<exceptions key="Cake/VERSION.txt">php</exceptions>
<exceptions key="Cake/LICENSE.txt">php</exceptions>

View file

@ -533,7 +533,7 @@ class Cache {
* @throws CacheException
*/
public static function groupConfigs($group = null) {
if ($group == null) {
if ($group === null) {
return self::$_groups;
}
if (isset(self::$_groups[$group])) {

View file

@ -44,7 +44,7 @@ class FileEngine extends CacheEngine {
*
* - path = absolute path to cache directory, default => CACHE
* - prefix = string prefix for filename, default => cake_
* - lock = enable file locking on write, default => false
* - lock = enable file locking on write, default => true
* - serialize = serialize the data, default => true
*
* @var array

View file

@ -91,7 +91,7 @@ class AclShell extends AppShell {
$this->args = null;
return $this->DbConfig->execute();
}
require_once (APP . 'Config' . DS . 'database.php');
require_once APP . 'Config' . DS . 'database.php';
if (!in_array($this->command, array('initdb'))) {
$collection = new ComponentCollection();

View file

@ -67,12 +67,12 @@ class SchemaShell extends AppShell {
$name = $this->params['name'] = $splitName;
}
if ($name && empty($this->params['file'])) {
$this->params['file'] = Inflector::underscore($name);
}
$defaultFile = 'schema.php';
if (empty($this->params['file'])) {
$this->params['file'] = 'schema.php';
$this->params['file'] = $defaultFile;
}
if ($name && $this->params['file'] === $defaultFile) {
$this->params['file'] = Inflector::underscore($name);
}
if (strpos($this->params['file'], '.php') === false) {
$this->params['file'] .= '.php';

View file

@ -438,6 +438,8 @@ class ModelTask extends BakeTask {
$guess = $methods['notEmpty'];
} elseif ($metaData['type'] === 'integer') {
$guess = $methods['numeric'];
} elseif ($metaData['type'] === 'float') {
$guess = $methods['numeric'];
} elseif ($metaData['type'] === 'boolean') {
$guess = $methods['boolean'];
} elseif ($metaData['type'] === 'date') {

View file

@ -295,7 +295,7 @@ class TestTask extends BakeTask {
*
* @param string $type The Type of object you are generating tests for eg. controller
* @param string $class the Classname of the class the test is being generated for.
* @return string Real classname
* @return string Real class name
*/
public function getRealClassName($type, $class) {
if (strtolower($type) === 'model' || empty($this->classTypes[$type])) {
@ -430,7 +430,7 @@ class TestTask extends BakeTask {
}
/**
* Add classname to the fixture list.
* Add class name to the fixture list.
* Sets the app. or plugin.plugin_name. prefix.
*
* @param string $name Name of the Model class that a fixture might be required for.
@ -476,7 +476,7 @@ class TestTask extends BakeTask {
}
/**
* Generate a constructor code snippet for the type and classname
* Generate a constructor code snippet for the type and class name
*
* @param string $type The Type of object you are generating tests for eg. controller
* @param string $fullClassName The Classname of the class the test is being generated for.
@ -504,7 +504,7 @@ class TestTask extends BakeTask {
}
/**
* Generate the uses() calls for a type & classname
* Generate the uses() calls for a type & class name
*
* @param string $type The Type of object you are generating tests for eg. controller
* @param string $realType The package name for the class.

View file

@ -45,7 +45,7 @@ Cache::config('default', array('engine' => 'File'));
*/
/**
* Custom Inflector rules, can be set to correctly pluralize or singularize table, model, controller names or whatever other
* Custom Inflector rules can be set to correctly pluralize or singularize table, model, controller names or whatever other
* string is passed to the inflection functions
*
* Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
@ -55,7 +55,7 @@ Cache::config('default', array('engine' => 'File'));
/**
* Plugins need to be loaded manually, you can either load them one by one or all of them in a single call
* Uncomment one of the lines below, as you need. make sure you read the documentation on CakePlugin to use more
* Uncomment one of the lines below, as you need. Make sure you read the documentation on CakePlugin to use more
* advanced ways of loading plugins
*
* CakePlugin::loadAll(); // Loads all plugins at once
@ -64,7 +64,7 @@ Cache::config('default', array('engine' => 'File'));
*/
/**
* You can attach event listeners to the request lifecycle as Dispatcher Filter . By Default CakePHP bundles two filters:
* You can attach event listeners to the request lifecycle as Dispatcher Filter . By default CakePHP bundles two filters:
*
* - AssetDispatcher filter will serve your asset files (css, images, js, etc) from your themes and plugins
* - CacheDispatcher filter will read the Cache.check configure variable and try to serve cached content generated from controllers

View file

@ -61,7 +61,7 @@
* - `renderer` - string - The class responsible for rendering uncaught exceptions. If you choose a custom class you
* should place the file for that class in app/Lib/Error. This class needs to implement a render method.
* - `log` - boolean - Should Exceptions be logged?
* - `skipLog` - array - list of exceptions to skip for logging. Exceptions that
* - `skipLog` - array - list of exceptions to skip for logging. Exceptions that
* extend one of the listed exceptions will also be skipped for logging.
* Example: `'skipLog' => array('NotFoundException', 'UnauthorizedException')`
*

View file

@ -1,9 +1,5 @@
<?php
/**
* This is core configuration file.
*
* Use it to configure core behaviour of Cake.
*
* PHP 5
*
* @link http://cakephp.org CakePHP(tm) Project
@ -16,10 +12,10 @@
* You can specify multiple configurations for production, development and testing.
*
* datasource => The name of a supported datasource; valid options are as follows:
* Database/Mysql - MySQL 4 & 5,
* Database/Sqlite - SQLite (PHP5 only),
* Database/Postgres - PostgreSQL 7 and higher,
* Database/Sqlserver - Microsoft SQL Server 2005 and higher
* Database/Mysql - MySQL 4 & 5,
* Database/Sqlite - SQLite (PHP5 only),
* Database/Postgres - PostgreSQL 7 and higher,
* Database/Sqlserver - Microsoft SQL Server 2005 and higher
*
* You can add custom database datasources (or override existing datasources) by adding the
* appropriate file to app/Model/Datasource/Database. Datasources should be named 'MyDatasource.php',
@ -45,6 +41,12 @@
*
* unix_socket =>
* For MySQL to connect via socket specify the `unix_socket` parameter instead of `host` and `port`
* settings =>
* Array of key/value pairs, on connection it executes SET statements for each pair
* For MySQL : http://dev.mysql.com/doc/refman/5.6/en/set-statement.html
* For Postgres : http://www.postgresql.org/docs/9.2/static/sql-set.html
* For Sql Server : http://msdn.microsoft.com/en-us/library/ms190356.aspx
*/
class DATABASE_CONFIG {

View file

@ -29,7 +29,7 @@ if (function_exists('ini_set')) {
ini_set('include_path', $root . PATH_SEPARATOR . __CAKE_PATH__ . PATH_SEPARATOR . ini_get('include_path'));
}
if (!include ($dispatcher)) {
if (!include $dispatcher) {
trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
}
unset($paths, $path, $dispatcher, $root, $ds);

View file

@ -14,9 +14,9 @@
<?php echo $this->Html->charset(); ?>
<title><?php echo $page_title; ?></title>
<?php if (Configure::read('debug') == 0) { ?>
<?php if (Configure::read('debug') == 0): ?>
<meta http-equiv="Refresh" content="<?php echo $pause; ?>;url=<?php echo $url; ?>"/>
<?php } ?>
<?php endif ?>
<style><!--
P { text-align:center; font:bold 1.1em sans-serif }
A { color:#444; text-decoration:none }

View file

@ -1,14 +1,13 @@
<?php
if (!isset($channel)) {
if (!isset($channel)):
$channel = array();
}
if (!isset($channel['title'])) {
endif;
if (!isset($channel['title'])):
$channel['title'] = $title_for_layout;
}
endif;
echo $this->Rss->document(
$this->Rss->channel(
array(), $channel, $this->fetch('content')
)
);
?>

View file

@ -144,7 +144,7 @@ if (isset($filePresent)):
echo '<span class="notice">';
echo __d('cake_dev', 'DebugKit is not installed. It will help you inspect and debug different aspects of your application.');
echo '<br/>';
echo __d('cake_dev', 'You can install it from %s', $this->Html->link('github', 'https://github.com/cakephp/debug_kit'));
echo __d('cake_dev', 'You can install it from %s', $this->Html->link('GitHub', 'https://github.com/cakephp/debug_kit'));
echo '</span>';
endif;
?>
@ -194,7 +194,7 @@ You can also add some CSS styles for your pages at: %s.',
</ul>
</p>
<h3><?php echo __d('cake_dev', 'More about Cake'); ?></h3>
<h3><?php echo __d('cake_dev', 'More about CakePHP'); ?></h3>
<p>
<?php echo __d('cake_dev', 'CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?>
</p>
@ -203,24 +203,32 @@ You can also add some CSS styles for your pages at: %s.',
</p>
<ul>
<li><a href="http://cakefoundation.org/"><?php echo __d('cake_dev', 'Cake Software Foundation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Promoting development related to CakePHP'); ?></li></ul></li>
<li><a href="http://www.cakephp.org">CakePHP</a>
<li><a href="http://cakephp.org">CakePHP</a>
<ul><li><?php echo __d('cake_dev', 'The Rapid Development Framework'); ?></li></ul></li>
<li><a href="http://book.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Documentation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Your Rapid Development Cookbook'); ?></li></ul></li>
<li><a href="http://api.cakephp.org"><?php echo __d('cake_dev', 'CakePHP API'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Quick Reference'); ?></li></ul></li>
<ul><li><?php echo __d('cake_dev', 'Quick API Reference'); ?></li></ul></li>
<li><a href="http://bakery.cakephp.org"><?php echo __d('cake_dev', 'The Bakery'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Everything CakePHP'); ?></li></ul></li>
<li><a href="http://plugins.cakephp.org"><?php echo __d('cake_dev', 'CakePHP plugins repo'); ?> </a>
<li><a href="http://plugins.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Plugins'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'A comprehensive list of all CakePHP plugins created by the community'); ?></li></ul></li>
<li><a href="http://community.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Community Center'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Everything related to the CakePHP community in one place'); ?></li></ul></li>
<li><a href="https://groups.google.com/group/cake-php"><?php echo __d('cake_dev', 'CakePHP Google Group'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Community mailing list'); ?></li></ul></li>
<li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a>
<ul><li><?php echo __d('cake_dev', 'Live chat about CakePHP'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/"><?php echo __d('cake_dev', 'CakePHP Code'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'For the Development of CakePHP Git repository, Downloads'); ?></li></ul></li>
<li><a href="https://cakephp.lighthouseapp.com/"><?php echo __d('cake_dev', 'CakePHP Lighthouse'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP Tickets, Wiki pages, Roadmap'); ?></li></ul></li>
<ul><li><?php echo __d('cake_dev', 'Find the CakePHP code on GitHub and contribute to the framework'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/cakephp/issues"><?php echo __d('cake_dev', 'CakePHP Issues'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP Issues'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/cakephp/wiki#roadmaps"><?php echo __d('cake_dev', 'CakePHP Roadmaps'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP Roadmaps'); ?></li></ul></li>
<li><a href="http://training.cakephp.org"><?php echo __d('cake_dev', 'Training'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Join a live session and get skilled with the framework'); ?></li></ul></li>
<li><a href="http://cakefest.org"><?php echo __d('cake_dev', 'CakeFest'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Don\'t miss our annual CakePHP conference'); ?></li></ul></li>
<li><a href="http://cakefoundation.org"><?php echo __d('cake_dev', 'Cake Software Foundation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Promoting development related to CakePHP'); ?></li></ul></li>
</ul>

View file

@ -80,11 +80,11 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if (function_exists('ini_set')) {
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
if (!include ('Cake' . DS . 'bootstrap.php')) {
if (!include 'Cake' . DS . 'bootstrap.php') {
$failed = true;
}
} else {
if (!include (CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
if (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') {
$failed = true;
}
}

View file

@ -70,11 +70,11 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if (function_exists('ini_set')) {
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
if (!include ('Cake' . DS . 'bootstrap.php')) {
if (!include 'Cake' . DS . 'bootstrap.php') {
$failed = true;
}
} else {
if (!include (CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
if (!include CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php') {
$failed = true;
}
}

View file

@ -174,7 +174,7 @@ class AuthComponent extends Component {
protected static $_user = array();
/**
* An URL (defined as a string or array) to the controller action that handles
* A URL (defined as a string or array) to the controller action that handles
* logins. Defaults to `/users/login`.
*
* @var mixed
@ -220,7 +220,7 @@ class AuthComponent extends Component {
* Controls handling of unauthorized access.
* - For default value `true` unauthorized user is redirected to the referrer URL
* or AuthComponent::$loginRedirect or '/'.
* - If set to a string or array the value is used as an URL to redirect to.
* - If set to a string or array the value is used as a URL to redirect to.
* - If set to false a ForbiddenException exception is thrown instead of redirecting.
*
* @var mixed
@ -699,7 +699,7 @@ class AuthComponent extends Component {
/**
* Get the URL a user should be redirected to upon login.
*
* Pass an URL in to set the destination a user should be redirected to upon
* Pass a URL in to set the destination a user should be redirected to upon
* logging in.
*
* If no parameter is passed, gets the authentication redirect URL. The URL

View file

@ -232,17 +232,27 @@ class CookieComponent extends Component {
}
foreach ($key as $name => $value) {
if (strpos($name, '.') === false) {
$this->_values[$this->name][$name] = $value;
$this->_write("[$name]", $value);
} else {
$names = array($name);
if (strpos($name, '.') !== false) {
$names = explode('.', $name, 2);
if (!isset($this->_values[$this->name][$names[0]])) {
$this->_values[$this->name][$names[0]] = array();
}
$this->_values[$this->name][$names[0]] = Hash::insert($this->_values[$this->name][$names[0]], $names[1], $value);
$this->_write('[' . implode('][', $names) . ']', $value);
}
$firstName = $names[0];
$isMultiValue = (is_array($value) || count($names) > 1);
if (!isset($this->_values[$this->name][$firstName]) && $isMultiValue) {
$this->_values[$this->name][$firstName] = array();
}
if (count($names) > 1) {
$this->_values[$this->name][$firstName] = Hash::insert(
$this->_values[$this->name][$firstName],
$names[1],
$value
);
} else {
$this->_values[$this->name][$firstName] = $value;
}
$this->_write('[' . $firstName . ']', $this->_values[$this->name][$firstName]);
}
$this->_encrypted = true;
}
@ -299,11 +309,17 @@ class CookieComponent extends Component {
* Delete a cookie value
*
* Optional [Name.], required key
* $this->Cookie->read('Name.key);
* $this->Cookie->delete('Name.key);
*
* You must use this method before any output is sent to the browser.
* Failure to do so will result in header already sent errors.
*
* This method will delete both the top level and 2nd level cookies set.
* For example assuming that $name = App, deleting `User` will delete
* both `App[User]` and any other cookie values like `App[User][email]`
* This is done to clean up cookie storage from before 2.4.3, where cookies
* were stored inconsistently.
*
* @param string $key Key of the value to be deleted
* @return void
* @link http://book.cakephp.org/2.0/en/core-libraries/components/cookie.html#CookieComponent::delete

View file

@ -86,7 +86,7 @@ class Controller extends Object implements CakeEventListener {
/**
* An array containing the names of helpers this controller uses. The array elements should
* not contain the "Helper" part of the classname.
* not contain the "Helper" part of the class name.
*
* Example: `public $helpers = array('Html', 'Js', 'Time', 'Ajax');`
*
@ -114,7 +114,7 @@ class Controller extends Object implements CakeEventListener {
public $response;
/**
* The classname to use for creating the response object.
* The class name to use for creating the response object.
*
* @var string
*/
@ -182,7 +182,7 @@ class Controller extends Object implements CakeEventListener {
/**
* Array containing the names of components this controller uses. Component names
* should not contain the "Component" portion of the classname.
* should not contain the "Component" portion of the class name.
*
* Example: `public $components = array('Session', 'RequestHandler', 'Acl');`
*

View file

@ -192,7 +192,7 @@ class CakeLog {
throw new CakeLogException(__d('cake_dev', 'Invalid key name'));
}
if (empty($config['engine'])) {
throw new CakeLogException(__d('cake_dev', 'Missing logger classname'));
throw new CakeLogException(__d('cake_dev', 'Missing logger class name'));
}
if (empty(self::$_Collection)) {
self::_init();

View file

@ -551,7 +551,7 @@ class CakeSchema extends Object {
continue;
}
$correspondingValue = $array2[$key];
if (is_null($value) !== is_null($correspondingValue)) {
if (($value === null) !== ($correspondingValue === null)) {
$difference[$key] = $value;
continue;
}

View file

@ -605,7 +605,7 @@ class Sqlserver extends DboSource {
* @param Model $model
* @param array $queryData
* @param integer $recursive
* @return array Array of resultset rows, or false if no rows matched
* @return array|false Array of resultset rows, or false if no rows matched
*/
public function read(Model $model, $queryData = array(), $recursive = null) {
$results = parent::read($model, $queryData, $recursive);

View file

@ -663,7 +663,8 @@ class DboSource extends DataSource {
if ($cache && ($cached = $this->getQueryCache($sql, $params)) !== false) {
return $cached;
}
if ($result = $this->execute($sql, array(), $params)) {
$result = $this->execute($sql, array(), $params);
if ($result) {
$out = array();
if ($this->hasResult()) {
@ -1072,7 +1073,7 @@ class DboSource extends DataSource {
}
}
$query = trim($this->generateAssociationQuery($model, null, null, null, null, $queryData, false, $null));
$query = $this->generateAssociationQuery($model, null, null, null, null, $queryData, false, $null);
$resultSet = $this->fetchAll($query, $model->cacheQueries);
@ -1404,7 +1405,7 @@ class DboSource extends DataSource {
if (isset($merge[$association])) {
$data[$association] = $merge[$association][0];
} else {
if (count($merge[0][$association]) > 1) {
if (!empty($merge[0][$association])) {
foreach ($merge[0] as $assoc => $data2) {
if ($assoc !== $association) {
$merge[0][$association][$assoc] = $data2;
@ -1755,19 +1756,19 @@ class DboSource extends DataSource {
switch (strtolower($type)) {
case 'select':
return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}";
return trim("SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}");
case 'create':
return "INSERT INTO {$table} ({$fields}) VALUES ({$values})";
case 'update':
if (!empty($alias)) {
$aliases = "{$this->alias}{$alias} {$joins} ";
}
return "UPDATE {$table} {$aliases}SET {$fields} {$conditions}";
return trim("UPDATE {$table} {$aliases}SET {$fields} {$conditions}");
case 'delete':
if (!empty($alias)) {
$aliases = "{$this->alias}{$alias} {$joins} ";
}
return "DELETE {$alias} FROM {$table} {$aliases}{$conditions}";
return trim("DELETE {$alias} FROM {$table} {$aliases}{$conditions}");
case 'schema':
foreach (array('columns', 'indexes', 'tableParameters') as $var) {
if (is_array(${$var})) {

View file

@ -294,7 +294,7 @@ class Model extends Object implements CakeEventListener {
*
* ### Possible keys in association
*
* - `className`: the classname of the model being associated to the current model.
* - `className`: the class name of the model being associated to the current model.
* If you're defining a 'Profile belongsTo User' relationship, the className key should equal 'User.'
* - `foreignKey`: the name of the foreign key found in the current model. This is
* especially handy if you need to define multiple belongsTo relationships. The default
@ -341,7 +341,7 @@ class Model extends Object implements CakeEventListener {
*
* ### Possible keys in association
*
* - `className`: the classname of the model being associated to the current model.
* - `className`: the class name of the model being associated to the current model.
* If you're defining a 'User hasOne Profile' relationship, the className key should equal 'Profile.'
* - `foreignKey`: the name of the foreign key found in the other model. This is
* especially handy if you need to define multiple hasOne relationships.
@ -384,7 +384,7 @@ class Model extends Object implements CakeEventListener {
*
* ### Possible keys in association
*
* - `className`: the classname of the model being associated to the current model.
* - `className`: the class name of the model being associated to the current model.
* If you're defining a 'User hasMany Comment' relationship, the className key should equal 'Comment.'
* - `foreignKey`: the name of the foreign key found in the other model. This is
* especially handy if you need to define multiple hasMany relationships. The default
@ -435,7 +435,7 @@ class Model extends Object implements CakeEventListener {
*
* ### Possible keys in association
*
* - `className`: the classname of the model being associated to the current model.
* - `className`: the class name of the model being associated to the current model.
* If you're defining a 'Recipe HABTM Tag' relationship, the className key should equal 'Tag.'
* - `joinTable`: The name of the join table used in this association (if the
* current table doesn't adhere to the naming convention for HABTM join tables).
@ -665,7 +665,8 @@ class Model extends Object implements CakeEventListener {
* Would create a model attached to the posts table on connection2. Dynamic model creation is useful
* when you want a model object that contains no associations or attached behaviors.
*
* @param integer|string|array $id Set this ID for this model on startup, can also be an array of options, see above.
* @param boolean|integer|string|array $id Set this ID for this model on startup,
* can also be an array of options, see above.
* @param string $table Name of database table to use.
* @param string $ds DataSource connection name.
*/
@ -904,7 +905,7 @@ class Model extends Object implements CakeEventListener {
* Example: Add a new hasOne binding to the Profile model not
* defined in the model source code:
*
* `$this->User->bindModel( array('hasOne' => array('Profile')) );`
* `$this->User->bindModel(array('hasOne' => array('Profile')));`
*
* Bindings that are not made permanent will be reset by the next Model::find() call on this
* model.
@ -989,30 +990,32 @@ class Model extends Object implements CakeEventListener {
*/
protected function _createLinks() {
foreach ($this->_associations as $type) {
if (!is_array($this->{$type})) {
$this->{$type} = explode(',', $this->{$type});
$association =& $this->{$type};
foreach ($this->{$type} as $i => $className) {
if (!is_array($association)) {
$association = explode(',', $association);
foreach ($association as $i => $className) {
$className = trim($className);
unset ($this->{$type}[$i]);
$this->{$type}[$className] = array();
unset ($association[$i]);
$association[$className] = array();
}
}
if (!empty($this->{$type})) {
foreach ($this->{$type} as $assoc => $value) {
if (!empty($association)) {
foreach ($association as $assoc => $value) {
$plugin = null;
if (is_numeric($assoc)) {
unset($this->{$type}[$assoc]);
unset($association[$assoc]);
$assoc = $value;
$value = array();
if (strpos($assoc, '.') !== false) {
list($plugin, $assoc) = pluginSplit($assoc, true);
$this->{$type}[$assoc] = array('className' => $plugin . $assoc);
$association[$assoc] = array('className' => $plugin . $assoc);
} else {
$this->{$type}[$assoc] = $value;
$association[$assoc] = $value;
}
}
@ -1068,9 +1071,10 @@ class Model extends Object implements CakeEventListener {
protected function _generateAssociation($type, $assocKey) {
$class = $assocKey;
$dynamicWith = false;
$assoc =& $this->{$type}[$assocKey];
foreach ($this->_associationKeys[$type] as $key) {
if (!isset($this->{$type}[$assocKey][$key]) || $this->{$type}[$assocKey][$key] === null) {
if (!isset($assoc[$key]) || $assoc[$key] === null) {
$data = '';
switch ($key) {
@ -1087,7 +1091,7 @@ class Model extends Object implements CakeEventListener {
break;
case 'with':
$data = Inflector::camelize(Inflector::singularize($this->{$type}[$assocKey]['joinTable']));
$data = Inflector::camelize(Inflector::singularize($assoc['joinTable']));
$dynamicWith = true;
break;
@ -1106,11 +1110,11 @@ class Model extends Object implements CakeEventListener {
break;
}
$this->{$type}[$assocKey][$key] = $data;
$assoc[$key] = $data;
}
if ($dynamicWith) {
$this->{$type}[$assocKey]['dynamicWith'] = true;
$assoc['dynamicWith'] = true;
}
}
}
@ -1182,24 +1186,22 @@ class Model extends Object implements CakeEventListener {
}
foreach ($data as $modelName => $fieldSet) {
if (is_array($fieldSet)) {
foreach ($fieldSet as $fieldName => $fieldValue) {
if (isset($this->validationErrors[$fieldName])) {
unset($this->validationErrors[$fieldName]);
}
if (!is_array($fieldSet)) {
continue;
}
if ($modelName === $this->alias) {
if ($fieldName === $this->primaryKey) {
$this->id = $fieldValue;
}
}
foreach ($fieldSet as $fieldName => $fieldValue) {
unset($this->validationErrors[$fieldName]);
if (is_array($fieldValue) || is_object($fieldValue)) {
$fieldValue = $this->deconstruct($fieldName, $fieldValue);
}
$this->data[$modelName][$fieldName] = $fieldValue;
if ($modelName === $this->alias && $fieldName === $this->primaryKey) {
$this->id = $fieldValue;
}
if (is_array($fieldValue) || is_object($fieldValue)) {
$fieldValue = $this->deconstruct($fieldName, $fieldValue);
}
$this->data[$modelName][$fieldName] = $fieldValue;
}
}
@ -1554,7 +1556,7 @@ class Model extends Object implements CakeEventListener {
/**
* This function is a convenient wrapper class to create(false) and, as the name suggests, clears the id, data, and validation errors.
*
* @return always boolean TRUE upon success
* @return boolean Always true upon success
* @see Model::create()
*/
public function clear() {
@ -1746,20 +1748,22 @@ class Model extends Object implements CakeEventListener {
$now = time();
foreach ($dateFields as $updateCol) {
if ($this->hasField($updateCol) && !in_array($updateCol, $fields)) {
$default = array('formatter' => 'date');
$colType = array_merge($default, $db->columns[$this->getColumnType($updateCol)]);
if (!array_key_exists('format', $colType)) {
$time = $now;
} else {
$time = call_user_func($colType['formatter'], $colType['format']);
}
if (!empty($this->whitelist)) {
$this->whitelist[] = $updateCol;
}
$this->set($updateCol, $time);
if (in_array($updateCol, $fields) || !$this->hasField($updateCol)) {
continue;
}
$default = array('formatter' => 'date');
$colType = array_merge($default, $db->columns[$this->getColumnType($updateCol)]);
$time = $now;
if (array_key_exists('format', $colType)) {
$time = call_user_func($colType['formatter'], $colType['format']);
}
if (!empty($this->whitelist)) {
$this->whitelist[] = $updateCol;
}
$this->set($updateCol, $time);
}
if ($options['callbacks'] === true || $options['callbacks'] === 'before') {
@ -1785,18 +1789,16 @@ class Model extends Object implements CakeEventListener {
$v = $v[$n];
}
$joined[$n] = $v;
} else {
if ($n === $this->alias) {
foreach (array('created', 'updated', 'modified') as $field) {
if (array_key_exists($field, $v) && empty($v[$field])) {
unset($v[$field]);
}
} elseif ($n === $this->alias) {
foreach (array('created', 'updated', 'modified') as $field) {
if (array_key_exists($field, $v) && empty($v[$field])) {
unset($v[$field]);
}
}
foreach ($v as $x => $y) {
if ($this->hasField($x) && (empty($this->whitelist) || in_array($x, $this->whitelist))) {
list($fields[], $values[]) = array($x, $y);
}
foreach ($v as $x => $y) {
if ($this->hasField($x) && (empty($this->whitelist) || in_array($x, $this->whitelist))) {
list($fields[], $values[]) = array($x, $y);
}
}
}
@ -1892,117 +1894,123 @@ class Model extends Object implements CakeEventListener {
*/
protected function _saveMulti($joined, $id, $db) {
foreach ($joined as $assoc => $data) {
if (isset($this->hasAndBelongsToMany[$assoc])) {
list($join) = $this->joinModel($this->hasAndBelongsToMany[$assoc]['with']);
if (!isset($this->hasAndBelongsToMany[$assoc])) {
continue;
}
if ($with = $this->hasAndBelongsToMany[$assoc]['with']) {
$withModel = is_array($with) ? key($with) : $with;
list(, $withModel) = pluginSplit($withModel);
$dbMulti = $this->{$withModel}->getDataSource();
} else {
$dbMulti = $db;
$habtm = $this->hasAndBelongsToMany[$assoc];
list($join) = $this->joinModel($habtm['with']);
$Model = $this->{$join};
if (!empty($habtm['with'])) {
$withModel = is_array($habtm['with']) ? key($habtm['with']) : $habtm['with'];
list(, $withModel) = pluginSplit($withModel);
$dbMulti = $this->{$withModel}->getDataSource();
} else {
$dbMulti = $db;
}
$isUUID = !empty($Model->primaryKey) && $Model->_isUUIDField($Model->primaryKey);
$newData = $newValues = $newJoins = array();
$primaryAdded = false;
$fields = array(
$dbMulti->name($habtm['foreignKey']),
$dbMulti->name($habtm['associationForeignKey'])
);
$idField = $db->name($Model->primaryKey);
if ($isUUID && !in_array($idField, $fields)) {
$fields[] = $idField;
$primaryAdded = true;
}
foreach ((array)$data as $row) {
if ((is_string($row) && (strlen($row) == 36 || strlen($row) == 16)) || is_numeric($row)) {
$newJoins[] = $row;
$values = array($id, $row);
if ($isUUID && $primaryAdded) {
$values[] = String::uuid();
}
$newValues[$row] = $values;
unset($values);
} elseif (isset($row[$habtm['associationForeignKey']])) {
if (!empty($row[$Model->primaryKey])) {
$newJoins[] = $row[$habtm['associationForeignKey']];
}
$newData[] = $row;
} elseif (isset($row[$join]) && isset($row[$join][$habtm['associationForeignKey']])) {
if (!empty($row[$join][$Model->primaryKey])) {
$newJoins[] = $row[$join][$habtm['associationForeignKey']];
}
$newData[] = $row[$join];
}
}
$isUUID = !empty($this->{$join}->primaryKey) && $this->{$join}->_isUUIDField($this->{$join}->primaryKey);
$newData = $newValues = $newJoins = array();
$primaryAdded = false;
$fields = array(
$dbMulti->name($this->hasAndBelongsToMany[$assoc]['foreignKey']),
$dbMulti->name($this->hasAndBelongsToMany[$assoc]['associationForeignKey'])
$keepExisting = $habtm['unique'] === 'keepExisting';
if ($habtm['unique']) {
$conditions = array(
$join . '.' . $habtm['foreignKey'] => $id
);
$idField = $db->name($this->{$join}->primaryKey);
if ($isUUID && !in_array($idField, $fields)) {
$fields[] = $idField;
$primaryAdded = true;
if (!empty($habtm['conditions'])) {
$conditions = array_merge($conditions, (array)$habtm['conditions']);
}
foreach ((array)$data as $row) {
if ((is_string($row) && (strlen($row) === 36 || strlen($row) === 16)) || is_numeric($row)) {
$newJoins[] = $row;
$values = array($id, $row);
$associationForeignKey = $Model->alias . '.' . $habtm['associationForeignKey'];
$links = $Model->find('all', array(
'conditions' => $conditions,
'recursive' => empty($habtm['conditions']) ? -1 : 0,
'fields' => $associationForeignKey,
));
if ($isUUID && $primaryAdded) {
$values[] = String::uuid();
}
$newValues[$row] = $values;
unset($values);
} elseif (isset($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
if (!empty($row[$this->{$join}->primaryKey])) {
$newJoins[] = $row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']];
}
$newData[] = $row;
} elseif (isset($row[$join]) && isset($row[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
if (!empty($row[$join][$this->{$join}->primaryKey])) {
$newJoins[] = $row[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']];
}
$newData[] = $row[$join];
$oldLinks = Hash::extract($links, "{n}.{$associationForeignKey}");
if (!empty($oldLinks)) {
if ($keepExisting && !empty($newJoins)) {
$conditions[$associationForeignKey] = array_diff($oldLinks, $newJoins);
} else {
$conditions[$associationForeignKey] = $oldLinks;
}
$dbMulti->delete($Model, $conditions);
}
}
$keepExisting = $this->hasAndBelongsToMany[$assoc]['unique'] === 'keepExisting';
if ($this->hasAndBelongsToMany[$assoc]['unique']) {
$conditions = array(
$join . '.' . $this->hasAndBelongsToMany[$assoc]['foreignKey'] => $id
);
if (!empty($this->hasAndBelongsToMany[$assoc]['conditions'])) {
$conditions = array_merge($conditions, (array)$this->hasAndBelongsToMany[$assoc]['conditions']);
if (!empty($newData)) {
foreach ($newData as $data) {
$data[$habtm['foreignKey']] = $id;
if (empty($data[$Model->primaryKey])) {
$Model->create();
}
$associationForeignKey = $this->{$join}->alias . '.' . $this->hasAndBelongsToMany[$assoc]['associationForeignKey'];
$links = $this->{$join}->find('all', array(
'conditions' => $conditions,
'recursive' => empty($this->hasAndBelongsToMany[$assoc]['conditions']) ? -1 : 0,
'fields' => $associationForeignKey,
));
$Model->save($data);
}
}
$oldLinks = Hash::extract($links, "{n}.{$associationForeignKey}");
if (!empty($oldLinks)) {
if ($keepExisting && !empty($newJoins)) {
$conditions[$associationForeignKey] = array_diff($oldLinks, $newJoins);
if (!empty($newValues)) {
if ($keepExisting && !empty($links)) {
foreach ($links as $link) {
$oldJoin = $link[$join][$habtm['associationForeignKey']];
if (!in_array($oldJoin, $newJoins)) {
$conditions[$associationForeignKey] = $oldJoin;
$db->delete($Model, $conditions);
} else {
$conditions[$associationForeignKey] = $oldLinks;
unset($newValues[$oldJoin]);
}
$dbMulti->delete($this->{$join}, $conditions);
}
}
if (!empty($newData)) {
foreach ($newData as $data) {
$data[$this->hasAndBelongsToMany[$assoc]['foreignKey']] = $id;
if (empty($data[$this->{$join}->primaryKey])) {
$this->{$join}->create();
}
$this->{$join}->save($data);
}
$newValues = array_values($newValues);
}
if (!empty($newValues)) {
if ($keepExisting && !empty($links)) {
foreach ($links as $link) {
$oldJoin = $link[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']];
if (!in_array($oldJoin, $newJoins)) {
$conditions[$associationForeignKey] = $oldJoin;
$db->delete($this->{$join}, $conditions);
} else {
unset($newValues[$oldJoin]);
}
}
$newValues = array_values($newValues);
}
if (!empty($newValues)) {
$dbMulti->insertMulti($this->{$join}, $fields, $newValues);
}
$dbMulti->insertMulti($Model, $fields, $newValues);
}
}
}
@ -2021,64 +2029,66 @@ class Model extends Object implements CakeEventListener {
$keys['old'] = isset($keys['old']) ? $keys['old'] : array();
foreach ($this->belongsTo as $parent => $assoc) {
if (!empty($assoc['counterCache'])) {
if (!is_array($assoc['counterCache'])) {
if (isset($assoc['counterScope'])) {
$assoc['counterCache'] = array($assoc['counterCache'] => $assoc['counterScope']);
} else {
$assoc['counterCache'] = array($assoc['counterCache'] => array());
}
if (empty($assoc['counterCache'])) {
continue;
}
$Model = $this->{$parent};
if (!is_array($assoc['counterCache'])) {
if (isset($assoc['counterScope'])) {
$assoc['counterCache'] = array($assoc['counterCache'] => $assoc['counterScope']);
} else {
$assoc['counterCache'] = array($assoc['counterCache'] => array());
}
}
$foreignKey = $assoc['foreignKey'];
$fkQuoted = $this->escapeField($assoc['foreignKey']);
foreach ($assoc['counterCache'] as $field => $conditions) {
if (!is_string($field)) {
$field = Inflector::underscore($this->alias) . '_count';
}
$foreignKey = $assoc['foreignKey'];
$fkQuoted = $this->escapeField($assoc['foreignKey']);
if (!$Model->hasField($field)) {
continue;
}
foreach ($assoc['counterCache'] as $field => $conditions) {
if (!is_string($field)) {
$field = Inflector::underscore($this->alias) . '_count';
}
if ($conditions === true) {
$conditions = array();
} else {
$conditions = (array)$conditions;
}
if (!$this->{$parent}->hasField($field)) {
continue;
}
if (!array_key_exists($foreignKey, $keys)) {
$keys[$foreignKey] = $this->field($foreignKey);
}
if ($conditions === true) {
$conditions = array();
} else {
$conditions = (array)$conditions;
}
if (!array_key_exists($foreignKey, $keys)) {
$keys[$foreignKey] = $this->field($foreignKey);
}
$recursive = (empty($conditions) ? -1 : 0);
if (isset($keys['old'][$foreignKey])) {
if ($keys['old'][$foreignKey] != $keys[$foreignKey]) {
$conditions[$fkQuoted] = $keys['old'][$foreignKey];
$count = intval($this->find('count', compact('conditions', 'recursive')));
$this->{$parent}->updateAll(
array($field => $count),
array($this->{$parent}->escapeField() => $keys['old'][$foreignKey])
);
}
}
$conditions[$fkQuoted] = $keys[$foreignKey];
if ($recursive === 0) {
$conditions = array_merge($conditions, (array)$conditions);
}
$recursive = (empty($conditions) ? -1 : 0);
if (isset($keys['old'][$foreignKey]) && $keys['old'][$foreignKey] != $keys[$foreignKey]) {
$conditions[$fkQuoted] = $keys['old'][$foreignKey];
$count = intval($this->find('count', compact('conditions', 'recursive')));
$this->{$parent}->updateAll(
$Model->updateAll(
array($field => $count),
array($this->{$parent}->escapeField() => $keys[$foreignKey])
array($Model->escapeField() => $keys['old'][$foreignKey])
);
}
$conditions[$fkQuoted] = $keys[$foreignKey];
if ($recursive === 0) {
$conditions = array_merge($conditions, (array)$conditions);
}
$count = intval($this->find('count', compact('conditions', 'recursive')));
$Model->updateAll(
array($field => $count),
array($Model->escapeField() => $keys[$foreignKey])
);
}
}
}
@ -2343,33 +2353,37 @@ class Model extends Object implements CakeEventListener {
$return = array();
$validates = true;
foreach ($data as $association => $values) {
$notEmpty = !empty($values[$association]) || (!isset($values[$association]) && !empty($values));
if (isset($associations[$association]) && $associations[$association] === 'belongsTo' && $notEmpty) {
$validates = $this->{$association}->create(null) !== null;
$saved = false;
if ($validates) {
if ($options['deep']) {
$saved = $this->{$association}->saveAssociated($values, array_merge($options, array('atomic' => false)));
} else {
$saved = $this->{$association}->save($values, array_merge($options, array('atomic' => false)));
}
$validates = ($saved === true || (is_array($saved) && !in_array(false, $saved, true)));
}
if ($validates) {
$key = $this->belongsTo[$association]['foreignKey'];
if (isset($data[$this->alias])) {
$data[$this->alias][$key] = $this->{$association}->id;
} else {
$data = array_merge(array($key => $this->{$association}->id), $data, array($key => $this->{$association}->id));
}
$options = $this->_addToWhiteList($key, $options);
} else {
$validationErrors[$association] = $this->{$association}->validationErrors;
}
$return[$association] = $validates;
$isEmpty = empty($values) || (isset($values[$association]) && empty($values[$association]));
if ($isEmpty || !isset($associations[$association]) || $associations[$association] !== 'belongsTo') {
continue;
}
$Model = $this->{$association};
$validates = $Model->create(null) !== null;
$saved = false;
if ($validates) {
if ($options['deep']) {
$saved = $Model->saveAssociated($values, array_merge($options, array('atomic' => false)));
} else {
$saved = $Model->save($values, array_merge($options, array('atomic' => false)));
}
$validates = ($saved === true || (is_array($saved) && !in_array(false, $saved, true)));
}
if ($validates) {
$key = $this->belongsTo[$association]['foreignKey'];
if (isset($data[$this->alias])) {
$data[$this->alias][$key] = $Model->id;
} else {
$data = array_merge(array($key => $Model->id), $data, array($key => $Model->id));
}
$options = $this->_addToWhiteList($key, $options);
} else {
$validationErrors[$association] = $Model->validationErrors;
}
$return[$association] = $validates;
}
if ($validates && !($this->create(null) !== null && $this->save($data, $options))) {
@ -2383,56 +2397,60 @@ class Model extends Object implements CakeEventListener {
break;
}
$notEmpty = !empty($values[$association]) || (!isset($values[$association]) && !empty($values));
if (isset($associations[$association]) && $notEmpty) {
$type = $associations[$association];
$key = $this->{$type}[$association]['foreignKey'];
switch ($type) {
case 'hasOne':
if (isset($values[$association])) {
$values[$association][$key] = $this->id;
$isEmpty = empty($values) || (isset($values[$association]) && empty($values[$association]));
if ($isEmpty || !isset($associations[$association])) {
continue;
}
$Model = $this->{$association};
$type = $associations[$association];
$key = $this->{$type}[$association]['foreignKey'];
switch ($type) {
case 'hasOne':
if (isset($values[$association])) {
$values[$association][$key] = $this->id;
} else {
$values = array_merge(array($key => $this->id), $values, array($key => $this->id));
}
$validates = $Model->create(null) !== null;
$saved = false;
if ($validates) {
$options = $Model->_addToWhiteList($key, $options);
if ($options['deep']) {
$saved = $Model->saveAssociated($values, array_merge($options, array('atomic' => false)));
} else {
$values = array_merge(array($key => $this->id), $values, array($key => $this->id));
$saved = $Model->save($values, $options);
}
}
$validates = $this->{$association}->create(null) !== null;
$saved = false;
$validates = ($validates && ($saved === true || (is_array($saved) && !in_array(false, $saved, true))));
if (!$validates) {
$validationErrors[$association] = $Model->validationErrors;
}
if ($validates) {
$options = $this->{$association}->_addToWhiteList($key, $options);
if ($options['deep']) {
$saved = $this->{$association}->saveAssociated($values, array_merge($options, array('atomic' => false)));
} else {
$saved = $this->{$association}->save($values, $options);
}
$return[$association] = $validates;
break;
case 'hasMany':
foreach ($values as $i => $value) {
if (isset($values[$i][$association])) {
$values[$i][$association][$key] = $this->id;
} else {
$values[$i] = array_merge(array($key => $this->id), $value, array($key => $this->id));
}
}
$validates = ($validates && ($saved === true || (is_array($saved) && !in_array(false, $saved, true))));
if (!$validates) {
$validationErrors[$association] = $this->{$association}->validationErrors;
}
$options = $Model->_addToWhiteList($key, $options);
$_return = $Model->saveMany($values, array_merge($options, array('atomic' => false)));
if (in_array(false, $_return, true)) {
$validationErrors[$association] = $Model->validationErrors;
$validates = false;
}
$return[$association] = $validates;
break;
case 'hasMany':
foreach ($values as $i => $value) {
if (isset($values[$i][$association])) {
$values[$i][$association][$key] = $this->id;
} else {
$values[$i] = array_merge(array($key => $this->id), $value, array($key => $this->id));
}
}
$options = $this->{$association}->_addToWhiteList($key, $options);
$_return = $this->{$association}->saveMany($values, array_merge($options, array('atomic' => false)));
if (in_array(false, $_return, true)) {
$validationErrors[$association] = $this->{$association}->validationErrors;
$validates = false;
}
$return[$association] = $_return;
break;
}
$return[$association] = $_return;
break;
}
}
$this->validationErrors = $validationErrors;
@ -2477,10 +2495,7 @@ class Model extends Object implements CakeEventListener {
return $options;
}
if (!empty($options['fieldList']) &&
is_array($options['fieldList']) &&
Hash::dimensions($options['fieldList']) < 2
) {
if (!empty($options['fieldList']) && is_array($options['fieldList']) && Hash::dimensions($options['fieldList']) < 2) {
$options['fieldList'][] = $key;
}
@ -2606,29 +2621,29 @@ class Model extends Object implements CakeEventListener {
continue;
}
$model = $this->{$assoc};
$Model = $this->{$assoc};
if ($data['foreignKey'] === false && $data['conditions'] && in_array($this->name, $model->getAssociated('belongsTo'))) {
$model->recursive = 0;
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);
$Model->recursive = -1;
$conditions = array($Model->escapeField($data['foreignKey']) => $id);
if ($data['conditions']) {
$conditions = array_merge((array)$data['conditions'], $conditions);
}
}
if (isset($data['exclusive']) && $data['exclusive']) {
$model->deleteAll($conditions);
$Model->deleteAll($conditions);
} else {
$records = $model->find('all', array(
'conditions' => $conditions, 'fields' => $model->primaryKey
$records = $Model->find('all', array(
'conditions' => $conditions, 'fields' => $Model->primaryKey
));
if (!empty($records)) {
foreach ($records as $record) {
$model->delete($record[$model->alias][$model->primaryKey]);
$Model->delete($record[$Model->alias][$Model->primaryKey]);
}
}
}
@ -2648,16 +2663,17 @@ class Model extends Object implements CakeEventListener {
protected function _deleteLinks($id) {
foreach ($this->hasAndBelongsToMany as $data) {
list(, $joinModel) = pluginSplit($data['with']);
$records = $this->{$joinModel}->find('all', array(
'conditions' => array($this->{$joinModel}->escapeField($data['foreignKey']) => $id),
'fields' => $this->{$joinModel}->primaryKey,
$Model = $this->{$joinModel};
$records = $Model->find('all', array(
'conditions' => array($Model->escapeField($data['foreignKey']) => $id),
'fields' => $Model->primaryKey,
'recursive' => -1,
'callbacks' => false
));
if (!empty($records)) {
foreach ($records as $record) {
$this->{$joinModel}->delete($record[$this->{$joinModel}->alias][$this->{$joinModel}->primaryKey]);
$Model->delete($record[$Model->alias][$Model->primaryKey]);
}
}
}
@ -2779,7 +2795,7 @@ class Model extends Object implements CakeEventListener {
*
* Used to perform find operations, where the first argument is type of find operation to perform
* (all / first / count / neighbors / list / threaded),
* second parameter options for finding ( indexed array, including: 'conditions', 'limit',
* second parameter options for finding (indexed array, including: 'conditions', 'limit',
* 'recursive', 'page', 'fields', 'offset', 'order', 'callbacks')
*
* Eg:
@ -3304,7 +3320,7 @@ class Model extends Object implements CakeEventListener {
*
* Additionally it populates the validationErrors property of the model with the same array.
*
* @param string $options An optional array of custom options to be made available in the beforeValidate callback
* @param array|string $options An optional array of custom options to be made available in the beforeValidate callback
* @return array Array of invalid fields and their error messages
* @see Model::validates()
*/
@ -3671,25 +3687,29 @@ class Model extends Object implements CakeEventListener {
*
* @param string $type If null this deletes cached views if Cache.check is true
* Will be used to allow deleting query cache also
* @return boolean true on delete
* @return mixed True on delete, null otherwise
*/
protected function _clearCache($type = null) {
if ($type !== null || Configure::read('Cache.check') !== true) {
return;
}
$assoc[] = strtolower(Inflector::pluralize($this->alias));
$assoc[] = Inflector::underscore(Inflector::pluralize($this->alias));
$pluralized = Inflector::pluralize($this->alias);
$assoc = array(
strtolower($pluralized),
Inflector::underscore($pluralized)
);
foreach ($this->_associations as $association) {
foreach ($this->$association as $className) {
$pluralized = strtolower(Inflector::pluralize($className['className']));
if (!in_array($pluralized, $assoc)) {
$assoc[] = $pluralized;
$assoc[] = Inflector::underscore(Inflector::pluralize($className['className']));
foreach ($this->{$association} as $className) {
$pluralizedAssociation = Inflector::pluralize($className['className']);
if (!in_array(strtolower($pluralizedAssociation), $assoc)) {
$assoc = array_merge($assoc, array(
strtolower($pluralizedAssociation),
Inflector::underscore($pluralizedAssociation)
));
}
}
}
$assoc = array_unique($assoc);
clearCache($assoc);
clearCache(array_unique($assoc));
return true;
}

View file

@ -141,7 +141,7 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
if (!empty($options['deep']) && isset($data[$model->alias])) {
$recordData = $data[$model->alias];
unset($data[$model->alias]);
$data = array_merge($data, $recordData);
$data += $recordData;
}
$associations = $model->getAssociated();

View file

@ -300,6 +300,7 @@ class CakeResponse {
'webapp' => 'application/x-web-app-manifest+json',
'vcf' => 'text/x-vcard',
'vtt' => 'text/vtt',
'mkv' => 'video/x-matroska',
);
/**
@ -1281,7 +1282,7 @@ class CakeResponse {
$agent = env('HTTP_USER_AGENT');
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent)) {
$contentType = 'application/octetstream';
$contentType = 'application/octet-stream';
} elseif (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
$contentType = 'application/force-download';
}
@ -1296,6 +1297,7 @@ class CakeResponse {
}
$this->download($name);
$this->header('Accept-Ranges', 'bytes');
$this->header('Content-Transfer-Encoding', 'binary');
$httpRange = env('HTTP_RANGE');
if (isset($httpRange)) {
@ -1373,6 +1375,7 @@ class CakeResponse {
$bufferSize = 8192;
set_time_limit(0);
session_write_close();
while (!feof($file->handle)) {
if (!$this->_isActive()) {
$file->close();

View file

@ -326,7 +326,7 @@ class CakeEmail {
protected $_emailPattern = null;
/**
* The classname used for email configuration.
* The class name used for email configuration.
*
* @var string
*/

View file

@ -42,9 +42,10 @@ class MailTransport extends AbstractTransport {
unset($headers['To']);
$headers = $this->_headersToString($headers, $eol);
$message = implode($eol, $email->message());
$subject = str_replace(array("\r", "\n"), '', $email->subject());
$params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null;
$this->_mail($to, $email->subject(), $message, $headers, $params);
$this->_mail($to, $subject, $message, $headers, $params);
return array('headers' => $headers, 'message' => $message);
}

View file

@ -78,7 +78,7 @@ class HttpSocket extends CakeSocket {
public $response = null;
/**
* Response classname
* Response class name
*
* @var string
*/
@ -134,7 +134,7 @@ class HttpSocket extends CakeSocket {
/**
* Build an HTTP Socket using the specified configuration.
*
* You can use an URL string to set the URL and use default configurations for
* You can use a URL string to set the URL and use default configurations for
* all other options:
*
* `$http = new HttpSocket('http://cakephp.org/');`
@ -464,7 +464,7 @@ class HttpSocket extends CakeSocket {
/**
* Issues a POST request to the specified URI, query, and request.
*
* `post()` can be used to post simple data arrays to an URL:
* `post()` can be used to post simple data arrays to a URL:
*
* {{{
* $response = $http->post('http://example.com', array(
@ -545,7 +545,7 @@ class HttpSocket extends CakeSocket {
*
* Would return `/search?q=socket`.
*
* @param string|array Either a string or array of URL options to create an URL with.
* @param string|array Either a string or array of URL options to create a URL with.
* @param string $uriTemplate A template string to use for URL formatting.
* @return mixed Either false on failure or a string containing the composed URL.
*/

View file

@ -192,9 +192,7 @@ class Dispatcher implements CakeEventListener {
if ($render && $controller->autoRender) {
$response = $controller->render();
} elseif (!($result instanceof CakeResponse) &&
$response->body() === null
) {
} elseif (!($result instanceof CakeResponse) && $response->body() === null) {
$response->body($result);
}
$controller->shutdownProcess();
@ -240,7 +238,7 @@ class Dispatcher implements CakeEventListener {
}
/**
* Load controller and return controller classname
* Load controller and return controller class name
*
* @param CakeRequest $request
* @return string|boolean Name of controller class name

View file

@ -369,9 +369,9 @@ class CakeRoute {
}
/**
* Apply persistent parameters to an URL array. Persistent 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
* an URL array.
* a URL array.
*
* @param array $url The array to apply persistent parameters to.
* @param array $params An array of persistent values to replace persistent ones.
@ -390,7 +390,7 @@ class CakeRoute {
}
/**
* Check if an URL array matches this route instance.
* Check if a URL array matches this route instance.
*
* If the URL matches the route parameters and settings, then
* return a generated string URL. If the URL doesn't match the route parameters, false will be returned.
@ -485,7 +485,7 @@ class CakeRoute {
}
/**
* Converts a matching route array into an URL string.
* Converts a matching route array into a URL string.
*
* Composes the string URL using the template
* used to create the route.

View file

@ -41,7 +41,7 @@ class RedirectRoute extends CakeRoute {
public $redirect;
/**
* Flag for disabling exit() when this route parses an URL.
* Flag for disabling exit() when this route parses a URL.
*
* @var boolean
*/

View file

@ -80,7 +80,7 @@ class Router {
protected static $_parseExtensions = false;
/**
* List of valid extensions to parse from an URL. If null, any extension is allowed.
* List of valid extensions to parse from a URL. If null, any extension is allowed.
*
* @var array
*/
@ -278,7 +278,7 @@ class Router {
* - `pass` is used to define which of the routed parameters should be shifted into the pass array. Adding a
* parameter to pass will remove it from the regular route array. Ex. `'pass' => array('slug')`
* - `persist` is used to define which route parameters should be automatically included when generating
* new URLs. You can override persistent parameters by redefining them in an URL or remove them by
* new URLs. You can override persistent parameters by redefining them in a URL or remove them by
* setting the parameter to `false`. Ex. `'persist' => array('lang')`
* - `routeClass` is used to extend and change how individual routes parse requests and handle reverse routing,
* via a custom routing class. Ex. `'routeClass' => 'SlugRoute'`
@ -359,7 +359,7 @@ class Router {
* `Router::redirect('/home/*', array('controller' => 'posts', 'action' => 'view'), array('persist' => true));`
*
* Redirects /home/* to /posts/view and passes the parameters to /posts/view. Using an array as the
* redirect destination allows you to use other routes to define where an URL string should be redirected to.
* redirect destination allows you to use other routes to define where a URL string should be redirected to.
*
* `Router::redirect('/posts/*', 'http://google.com', array('status' => 302));`
*
@ -595,7 +595,7 @@ class Router {
}
/**
* Parses a file extension out of an URL, if Router::parseExtensions() is enabled.
* Parses a file extension out of a URL, if Router::parseExtensions() is enabled.
*
* @param string $url
* @return array Returns an array containing the altered URL and the parsed extension.
@ -764,7 +764,7 @@ class Router {
/**
* Finds URL for specified action.
*
* Returns an URL pointing to a combination of controller and action. Param
* Returns a URL pointing to a combination of controller and action. Param
* $url can be:
*
* - Empty - the method will find address to actual controller/action.
@ -944,7 +944,7 @@ class Router {
* A special fallback method that handles URL arrays that cannot match
* any defined routes.
*
* @param array $url An URL that didn't match any routes
* @param array $url A URL that didn't match any routes
* @return string A generated URL for the array
* @see Router::url()
*/
@ -1091,7 +1091,7 @@ class Router {
}
/**
* Normalizes an URL for purposes of comparison.
* Normalizes a URL for purposes of comparison.
*
* Will strip the base path off and replace any double /'s.
* It will not unify the casing and underscoring of the input value.

View file

@ -637,7 +637,7 @@ class SchemaShellTest extends CakeTestCase {
/**
* test that passing name and file creates the passed filename with the
* passed classname
* passed class name
*
* @return void
*/

View file

@ -149,7 +149,7 @@ class ExtractTaskTest extends CakeTestCase {
$this->assertRegExp($pattern, $result);
$pattern = '/\#: (\\\\|\/)extract\.ctp:14\n';
$pattern .= '\#: (\\\\|\/)home\.ctp:83\n';
$pattern .= '\#: (\\\\|\/)home\.ctp:68\n';
$pattern .= 'msgid "Editing this Page"\nmsgstr ""/';
$this->assertRegExp($pattern, $result);

View file

@ -324,7 +324,7 @@ class TestTaskTest extends CakeTestCase {
}
/**
* test that getClassName returns the user choice as a classname.
* test that getClassName returns the user choice as a class name.
*
* @return void
*/
@ -359,7 +359,7 @@ class TestTaskTest extends CakeTestCase {
}
/**
* test that resolving classnames works
* test that resolving class names works
*
* @return void
*/
@ -394,7 +394,7 @@ class TestTaskTest extends CakeTestCase {
/**
* test baking files. The conditionally run tests are known to fail in PHP4
* as PHP4 classnames are all lower case, breaking the plugin path inflection.
* as PHP4 class names are all lower case, breaking the plugin path inflection.
*
* @return void
*/

View file

@ -327,6 +327,44 @@ class CookieComponentTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
/**
* Test that writing mixed arrays results in the correct data.
*
* @return void
*/
public function testWriteMixedArray() {
$this->Cookie->encrypt = false;
$this->Cookie->write('User', array('name' => 'mark'), false);
$this->Cookie->write('User.email', 'mark@example.com', false);
$expected = array(
'name' => $this->Cookie->name . '[User]',
'value' => '{"name":"mark","email":"mark@example.com"}',
'path' => '/',
'domain' => '',
'secure' => false,
'httpOnly' => false
);
$result = $this->Controller->response->cookie($this->Cookie->name . '[User]');
unset($result['expire']);
$this->assertEquals($expected, $result);
$this->Cookie->write('User.email', 'mark@example.com', false);
$this->Cookie->write('User', array('name' => 'mark'), false);
$expected = array(
'name' => $this->Cookie->name . '[User]',
'value' => '{"name":"mark"}',
'path' => '/',
'domain' => '',
'secure' => false,
'httpOnly' => false
);
$result = $this->Controller->response->cookie($this->Cookie->name . '[User]');
unset($result['expire']);
$this->assertEquals($expected, $result);
}
/**
* testReadingCookieValue
*

View file

@ -682,6 +682,65 @@ class ContainableBehaviorTest extends CakeTestCase {
);
$this->assertEquals($expected, $result);
$this->Article->contain(array('User' => array('id', 'ArticleFeatured')));
$result = $this->Article->find('all', array('recursive' => 2));
$expected = array(
array(
'Article' => array(
'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
),
'User' => array(
'id' => 1,
'ArticleFeatured' => array(
array(
'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
),
array(
'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'
)
)
)
),
array(
'Article' => array(
'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'
),
'User' => array(
'id' => 3,
'ArticleFeatured' => array(
array(
'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'
)
)
)
),
array(
'Article' => array(
'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'
),
'User' => array(
'id' => 1,
'ArticleFeatured' => array(
array(
'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'
),
array(
'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body',
'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'
)
)
)
)
);
$this->assertEquals($expected, $result);
$this->Article->contain(array('User' => array('ArticleFeatured', 'Comment')));
$result = $this->Article->find('all', array('recursive' => 2));
$expected = array(

View file

@ -1206,7 +1206,7 @@ class MysqlTest extends CakeTestCase {
$this->assertRegExp('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel4Parent`\.`id`, `TestModel4Parent`\.`name`, `TestModel4Parent`\.`created`, `TestModel4Parent`\.`updated`\s+/', $result);
$this->assertRegExp('/FROM\s+\S+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+\S+`test_model4` AS `TestModel4Parent`/', $result);
$this->assertRegExp('/\s+ON\s+\(`TestModel4`.`parent_id` = `TestModel4Parent`.`id`\)\s+WHERE/', $result);
$this->assertRegExp('/\s+WHERE\s+1 = 1\s+$/', $result);
$this->assertRegExp('/\s+WHERE\s+1 = 1$/', $result);
$params['assocData']['type'] = 'INNER';
$this->Model->belongsTo['TestModel4Parent']['type'] = 'INNER';

View file

@ -1143,7 +1143,7 @@ class DboSourceTest extends CakeTestCase {
),
$this->Model
);
$expected = 'SELECT DISTINCT(AssetsTag.asset_id) FROM assets_tags AS AssetsTag WHERE Tag.name = foo bar GROUP BY AssetsTag.asset_id ';
$expected = 'SELECT DISTINCT(AssetsTag.asset_id) FROM assets_tags AS AssetsTag WHERE Tag.name = foo bar GROUP BY AssetsTag.asset_id';
$this->assertEquals($expected, $subQuery);
}

View file

@ -1132,6 +1132,10 @@ class CakeResponseTest extends CakeTestCase {
->with('Accept-Ranges', 'bytes');
$response->expects($this->at(3))
->method('header')
->with('Content-Transfer-Encoding', 'binary');
$response->expects($this->at(4))
->method('header')
->with('Content-Length', 35);
@ -1181,7 +1185,7 @@ class CakeResponseTest extends CakeTestCase {
$response->expects($this->at(1))
->method('type')
->with('application/octetstream')
->with('application/octet-stream')
->will($this->returnValue(false));
$response->expects($this->once())
@ -1193,6 +1197,10 @@ class CakeResponseTest extends CakeTestCase {
->with('Accept-Ranges', 'bytes');
$response->expects($this->at(4))
->method('header')
->with('Content-Transfer-Encoding', 'binary');
$response->expects($this->at(5))
->method('header')
->with('Content-Length', 35);
@ -1253,6 +1261,10 @@ class CakeResponseTest extends CakeTestCase {
->with('Accept-Ranges', 'bytes');
$response->expects($this->at(4))
->method('header')
->with('Content-Transfer-Encoding', 'binary');
$response->expects($this->at(5))
->method('header')
->with('Content-Length', 35);
@ -1455,6 +1467,10 @@ class CakeResponseTest extends CakeTestCase {
->with('Accept-Ranges', 'bytes');
$response->expects($this->at(3))
->method('header')
->with('Content-Transfer-Encoding', 'binary');
$response->expects($this->at(4))
->method('header')
->with(array(
'Content-Length' => $length,
@ -1506,6 +1522,10 @@ class CakeResponseTest extends CakeTestCase {
->with('Accept-Ranges', 'bytes');
$response->expects($this->at(3))
->method('header')
->with('Content-Transfer-Encoding', 'binary');
$response->expects($this->at(4))
->method('header')
->with(array(
'Content-Length' => 18,
@ -1557,6 +1577,10 @@ class CakeResponseTest extends CakeTestCase {
->with('Accept-Ranges', 'bytes');
$response->expects($this->at(3))
->method('header')
->with('Content-Transfer-Encoding', 'binary');
$response->expects($this->at(4))
->method('header')
->with(array(
'Content-Range' => 'bytes 0-37/38',

View file

@ -27,7 +27,7 @@ App::uses('CakeEmail', 'Network/Email');
class TestCakeEmail extends CakeEmail {
/**
* Config classname.
* Config class name.
*
* Use a the testing config class in this file.
*

View file

@ -69,7 +69,7 @@ class MailTransportTest extends CakeTestCase {
$data .= "Content-Transfer-Encoding: 8bit";
$subject = '=?UTF-8?B?Rm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXog?=';
$subject .= "\r\n" . ' =?UTF-8?B?Rm/DuCBCw6VyIELDqXo=?=';
$subject .= ' =?UTF-8?B?Rm/DuCBCw6VyIELDqXo=?=';
$this->MailTransport->expects($this->once())->method('_mail')
->with(
'CakePHP <cake@cakephp.org>',

View file

@ -396,7 +396,7 @@ class FileTest extends CakeTestCase {
public function testWrite() {
if (!$tmpFile = $this->_getTmpFile()) {
return false;
};
}
if (file_exists($tmpFile)) {
unlink($tmpFile);
}
@ -426,7 +426,7 @@ class FileTest extends CakeTestCase {
public function testAppend() {
if (!$tmpFile = $this->_getTmpFile()) {
return false;
};
}
if (file_exists($tmpFile)) {
unlink($tmpFile);
}

View file

@ -120,6 +120,9 @@ class InflectorTest extends CakeTestCase {
$this->assertEquals(Inflector::singularize('objectives'), 'objective');
$this->assertEquals(Inflector::singularize('archives'), 'archive');
$this->assertEquals(Inflector::singularize('briefs'), 'brief');
$this->assertEquals(Inflector::singularize('quotas'), 'quota');
$this->assertEquals(Inflector::singularize('curves'), 'curve');
$this->assertEquals(Inflector::singularize('body_curves'), 'body_curve');
$this->assertEquals(Inflector::singularize(''), '');
}
@ -181,6 +184,9 @@ class InflectorTest extends CakeTestCase {
$this->assertEquals(Inflector::pluralize('foot'), 'feet');
$this->assertEquals(Inflector::pluralize('objective'), 'objectives');
$this->assertEquals(Inflector::pluralize('brief'), 'briefs');
$this->assertEquals(Inflector::pluralize('quota'), 'quotas');
$this->assertEquals(Inflector::pluralize('curve'), 'curves');
$this->assertEquals(Inflector::pluralize('body_curve'), 'body_curves');
$this->assertEquals(Inflector::pluralize(''), '');
}

View file

@ -219,6 +219,17 @@ class JqueryEngineHelperTest extends CakeTestCase {
));
$expected = '$.ajax({beforeSend:function (XMLHttpRequest) {doBefore}, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEquals($expected, $result);
$result = $this->Jquery->request('/people/edit/1', array(
'success' => 'doFoo',
'xhr' => 'return jQuery.ajaxSettings.xhr();',
'async' => true,
'method' => 'post',
'dataExpression' => true,
'data' => '$("#someId").serialize()',
));
$expected = '$.ajax({async:true, data:$("#someId").serialize(), success:function (data, textStatus) {doFoo}, type:"post", url:"\/people\/edit\/1", xhr:function () {return jQuery.ajaxSettings.xhr();}});';
$this->assertEquals($expected, $result);
}
/**

View file

@ -1515,6 +1515,20 @@ class ViewTest extends CakeTestCase {
$this->assertEquals('In second', $this->View->fetch('second'));
}
/**
* Test that starting the same block twice throws an exception
*
* @expectedException CakeException
* @return void
*/
public function testStartBlocksTwice() {
$this->View->start('first');
echo 'In first ';
$this->View->start('second');
echo 'In second';
$this->View->start('first');
}
/**
* Test that an exception gets thrown when you leave a block open at the end
* of a view.

View file

@ -1,8 +1,3 @@
<?php
App::uses('Debugger', 'Utility');
?>
<h2><?php echo __d('cake_dev', 'Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<a href="http://cakephp.org/changelogs/1.3.6"><?php echo __d('cake_dev', 'Read the changelog'); ?> </a>
<p>
<?php
if (is_writable(TMP)):
@ -70,78 +65,8 @@ if (isset($filePresent)):
?>
</p>
<?php endif; ?>
<?php
App::uses('Validation', 'Utility');
if (!Validation::alphaNumeric('cakephp')) {
echo '<p><span class="notice">';
__('PCRE has not been compiled with Unicode support.');
echo '<br/>';
__('Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
echo '</span></p>';
}
?>
<h3><?php echo __d('cake_dev', 'Editing this Page'); ?></h3>
<p>
<?php
echo __d('cake_dev', 'To change the content of this page, create: APP/views/pages/home.ctp.<br />
To change its layout, create: APP/views/layouts/default.ctp.<br />
You can also add some CSS styles for your pages at: APP/webroot/css.');
?>
</p>
<h3><?php echo __d('cake_dev', 'Getting Started'); ?></h3>
<p>
<?php
echo $this->Html->link(
sprintf('<strong>%s</strong> %s', __d('cake_dev', 'New'), __d('cake_dev', 'CakePHP 1.3 Docs')),
'http://book.cakephp.org/view/875/x1-3-Collection',
array('target' => '_blank', 'escape' => false)
);
?>
</p>
<p>
<?php
echo $this->Html->link(
__d('cake_dev', 'The 15 min Blog Tutorial'),
'http://book.cakephp.org/view/1528/Blog',
array('target' => '_blank', 'escape' => false)
);
?>
</p>
<h3><?php echo __d('cake_dev', 'More about Cake'); ?></h3>
<p>
<?php echo __d('cake_dev', 'CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?>
</p>
<p>
<?php echo __d('cake_dev', 'Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.'); ?>
</p>
<ul>
<li><a href="http://cakefoundation.org/"><?php echo __d('cake_dev', 'Cake Software Foundation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Promoting development related to CakePHP'); ?></li></ul></li>
<li><a href="http://www.cakephp.org"><?php echo __d('cake_dev', 'CakePHP'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'The Rapid Development Framework'); ?></li></ul></li>
<li><a href="http://book.cakephp.org"><?php echo __d('cake_dev', 'CakePHP Documentation'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Your Rapid Development Cookbook'); ?></li></ul></li>
<li><a href="http://api.cakephp.org"><?php echo __d('cake_dev', 'CakePHP API'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Quick Reference'); ?></li></ul></li>
<li><a href="http://bakery.cakephp.org"><?php echo __d('cake_dev', 'The Bakery'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Everything CakePHP'); ?></li></ul></li>
<li><a href="http://live.cakephp.org"><?php echo __d('cake_dev', 'The Show'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'The Show is a live and archived internet radio broadcast CakePHP-related topics and answer questions live via IRC, Skype, and telephone.'); ?></li></ul></li>
<li><a href="http://groups.google.com/group/cake-php"><?php echo __d('cake_dev', 'CakePHP Google Group'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Community mailing list'); ?></li></ul></li>
<li><a href="irc://irc.freenode.net/cakephp">irc.freenode.net #cakephp</a>
<ul><li><?php echo __d('cake_dev', 'Live chat about CakePHP'); ?></li></ul></li>
<li><a href="https://github.com/cakephp/"><?php echo __d('cake_dev', 'CakePHP Code'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'For the Development of CakePHP Git repository, Downloads'); ?></li></ul></li>
<li><a href="https://cakephp.lighthouseapp.com/"><?php echo __d('cake_dev', 'CakePHP Lighthouse'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'CakePHP Tickets, Wiki pages, Roadmap'); ?></li></ul></li>
<li><a href="http://www.cakeforge.org"><?php echo __d('cake_dev', 'CakeForge'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Open Development for CakePHP'); ?></li></ul></li>
<li><a href="http://astore.amazon.com/cakesoftwaref-20/"><?php echo __d('cake_dev', 'Book Store'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Recommended Software Books'); ?></li></ul></li>
<li><a href="http://www.cafepress.com/cakefoundation"><?php echo __d('cake_dev', 'CakePHP gear'); ?> </a>
<ul><li><?php echo __d('cake_dev', 'Get your own CakePHP gear - Doughnate to Cake'); ?></li></ul></li>
</ul>

View file

@ -91,7 +91,7 @@ if (!empty($filePresent)):
<a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-cake1.html"><?php echo __d('cake', 'Cook up Web sites fast with CakePHP'); ?></a><br />
<a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-wiki1.html"><?php echo __d('cake', 'Create an interactive production wiki using PHP'); ?></a>
</p>
<h2><?php echo __d('cake', 'More about Cake'); ?></h2>
<h2><?php echo __d('cake', 'More about CakePHP'); ?></h2>
<p>
<?php echo __d('cake', 'CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC.'); ?>
</p>

View file

@ -55,7 +55,7 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
}
/**
* Ugly hack to get around PHPUnit having a hard coded classname for the Runner. :(
* Ugly hack to get around PHPUnit having a hard coded class name for the Runner. :(
*
* @param array $argv
* @param boolean $exit

View file

@ -125,7 +125,7 @@ HTML;
}
/**
* Guess the classname the test was for based on the test case filename.
* Guess the class name the test was for based on the test case filename.
*
* @param ReflectionClass $testReflection.
* @return string Possible test subject name.

View file

@ -805,7 +805,7 @@ class Debugger {
}
/**
* Get the type of the given variable. Will return the classname
* Get the type of the given variable. Will return the class name
* for objects.
*
* @param mixed $var The variable to get the type of

View file

@ -593,7 +593,7 @@ class Hash {
}
/**
* Expand/unflattens an string to an array
* Expands a flat array to a nested array.
*
* For example, unflattens an array that was collapsed with `Hash::flatten()`
* into a multi-dimensional array. So, `array('0.Foo.Bar' => 'Far')` becomes

View file

@ -129,8 +129,8 @@ class Inflector {
'/(tive)s$/i' => '\1',
'/(hive)s$/i' => '\1',
'/(drive)s$/i' => '\1',
'/([lre])ves$/i' => '\1f',
'/([^fo])ves$/i' => '\1fe',
'/([le])ves$/i' => '\1f',
'/([^rfo])ves$/i' => '\1fe',
'/(^analy)ses$/i' => '\1sis',
'/(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
'/([ti])a$/i' => '\1um',
@ -148,7 +148,6 @@ class Inflector {
'irregular' => array(
'foes' => 'foe',
'waves' => 'wave',
'curves' => 'curve'
)
);

View file

@ -81,7 +81,7 @@ class Xml {
* is disabled by default for security reasons.
* - If using array as input, you can pass `options` from Xml::fromArray.
*
* @param string|array $input XML string, a path to a file, an URL or an array
* @param string|array $input XML string, a path to a file, a URL or an array
* @param array $options The options to use
* @return SimpleXMLElement|DOMDocument SimpleXMLElement or DOMDocument
* @throws XmlException

View file

@ -196,6 +196,7 @@ class Helper extends Object {
*
* @param string $name Name of the property being accessed.
* @return mixed Helper or property found at $name
* @deprecated Accessing request properties through this method is deprecated and will be removed in 3.0.
*/
public function __get($name) {
if (isset($this->_helperMap[$name]) && !isset($this->{$name})) {
@ -224,6 +225,7 @@ class Helper extends Object {
* @param string $name Name of the property being accessed.
* @param mixed $value
* @return void
* @deprecated This method will be removed in 3.0
*/
public function __set($name, $value) {
switch ($name) {
@ -243,7 +245,7 @@ class Helper extends Object {
/**
* Finds URL for specified action.
*
* Returns an URL pointing at the provided parameters.
* Returns a URL pointing at the provided parameters.
*
* @param string|array $url Either a relative string url like `/products/view/23` or
* an array of URL parameters. Using an array for URLs will allow you to leverage
@ -339,7 +341,7 @@ class Helper extends Object {
}
/**
* Encodes an URL for use in HTML attributes.
* Encodes a URL for use in HTML attributes.
*
* @param string $url The URL to encode.
* @return string The URL encoded for both URL & HTML contexts.
@ -404,6 +406,7 @@ class Helper extends Object {
*
* @param string|array $output Either an array of strings to clean or a single string to clean.
* @return string|array cleaned content for output
* @deprecated This method will be removed in 3.0
*/
public function clean($output) {
$this->_reset();
@ -777,7 +780,7 @@ class Helper extends Object {
* Adds the given class to the element options
*
* @param array $options Array options/attributes to add a class to
* @param string $class The classname being added.
* @param string $class The class name being added.
* @param string $key the key to use for class.
* @return array Array of options with $key set.
*/

View file

@ -297,7 +297,7 @@ class FormHelper extends AppHelper {
*
* - `type` Form method defaults to POST
* - `action` The controller action the form submits to, (optional).
* - `url` The URL the form submits to. Can be a string or an URL array. If you use 'url'
* - `url` The URL the form submits to. Can be a string or a URL array. If you use 'url'
* you should leave 'action' undefined.
* - `default` Allows for the creation of Ajax forms. Set this to false to prevent the default event handler.
* Will create an onsubmit attribute if it doesn't not exist. If it does, default action suppression
@ -650,7 +650,7 @@ class FormHelper extends AppHelper {
* - `escape` boolean - Whether or not to html escape the contents of the error.
* - `wrap` mixed - Whether or not the error message should be wrapped in a div. If a
* string, will be used as the HTML tag to use.
* - `class` string - The classname for the error message
* - `class` string - The class name for the error message
*
* @param string $field A field name, like "Modelname.fieldname"
* @param string|array $text Error message as string or array of messages.
@ -836,7 +836,7 @@ class FormHelper extends AppHelper {
* @param array $blacklist A simple array of fields to not create inputs for.
* @param array $options Options array. Valid keys are:
* - `fieldset` Set to false to disable the fieldset. If a string is supplied it will be used as
* the classname for the fieldset element.
* the class name for the fieldset element.
* - `legend` Set to false to disable the legend for the generated input set. Or supply a string
* to customize the legend text.
* @return string Completed form inputs.
@ -1917,7 +1917,7 @@ class FormHelper extends AppHelper {
* that string is displayed as the empty element.
* - `escape` - If true contents of options will be HTML entity encoded. Defaults to true.
* - `value` The selected value of the input.
* - `class` - When using multiple = checkbox the classname to apply to the divs. Defaults to 'checkbox'.
* - `class` - When using multiple = checkbox the class name to apply to the divs. Defaults to 'checkbox'.
* - `disabled` - Control the disabled attribute. When creating a select box, set to true to disable the
* select box. When creating checkboxes, `true` will disable all checkboxes. You can also set disabled
* to a list of values you want to disable when creating checkboxes.

View file

@ -271,7 +271,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
$options['success'] = $success;
unset($options['update']);
}
$callbacks = array('success', 'error', 'beforeSend', 'complete');
$callbacks = array('success', 'error', 'beforeSend', 'complete', 'xhr');
if (!empty($options['dataExpression'])) {
$callbacks[] = 'data';
unset($options['dataExpression']);

View file

@ -67,7 +67,7 @@ abstract class JsBaseEngineHelper extends AppHelper {
}
/**
* Redirects to an URL. Creates a window.location modification snippet
* Redirects to a URL. Creates a window.location modification snippet
* that can be used to trigger 'redirects' from JavaScript.
*
* @param string|array $url URL

View file

@ -68,6 +68,7 @@ class NumberHelper extends AppHelper {
/**
* Call methods from CakeNumber utility class
* @return mixed Whatever is returned by called method, or false on failure
*/
public function __call($method, $params) {
return call_user_func_array(array($this->_engine, $method), $params);

View file

@ -83,6 +83,7 @@ class TextHelper extends AppHelper {
/**
* Call methods from String utility class
* @return mixed Whatever is returned by called method, or false on failure
*/
public function __call($method, $params) {
return call_user_func_array(array($this->_engine, $method), $params);

View file

@ -117,6 +117,7 @@ class TimeHelper extends AppHelper {
/**
* Call methods from CakeTime utility class
* @return mixed Whatever is returned by called method, or false on failure
*/
public function __call($method, $params) {
return call_user_func_array(array($this->_engine, $method), $params);
@ -350,7 +351,7 @@ class TimeHelper extends AppHelper {
* - `element` - The element to wrap the formatted time in.
* Has a few additional options:
* - `tag` - The tag to use, defaults to 'span'.
* - `class` - The classname to use, defaults to `time-ago-in-words`.
* - `class` - The class name to use, defaults to `time-ago-in-words`.
* - `title` - Defaults to the $dateTime input.
*
* @param integer|string|DateTime $dateTime UNIX timestamp, strtotime() valid string or DateTime object

View file

@ -539,7 +539,7 @@ class View extends Object {
public function renderCache($filename, $timeStart) {
$response = $this->response;
ob_start();
include ($filename);
include $filename;
$type = $response->mapType($response->type());
if (Configure::read('debug') > 0 && $type === 'html') {

View file

@ -72,9 +72,13 @@ class ViewBlock {
* using View::get();
*
* @param string $name The name of the block to capture for.
* @throws CakeException When starting a block twice
* @return void
*/
public function start($name) {
if (in_array($name, $this->_active)) {
throw new CakeException(__("A view block with the name '%s' is already/still open.", $name));
}
$this->_active[] = $name;
ob_start();
}

View file

@ -125,22 +125,22 @@ TEXT;
if (!function_exists('sortByKey')) {
/**
* Sorts given $array by key $sortby.
* Sorts given $array by key $sortBy.
*
* @param array $array Array to sort
* @param string $sortby Sort by this key
* @param string $sortBy Sort by this key
* @param string $order Sort order asc/desc (ascending or descending).
* @param integer $type Type of sorting to perform
* @return mixed Sorted array
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#sortByKey
*/
function sortByKey(&$array, $sortby, $order = 'asc', $type = SORT_NUMERIC) {
function sortByKey(&$array, $sortBy, $order = 'asc', $type = SORT_NUMERIC) {
if (!is_array($array)) {
return null;
}
foreach ($array as $key => $val) {
$sa[$key] = $val[$sortby];
$sa[$key] = $val[$sortBy];
}
if ($order === 'asc') {
@ -205,7 +205,7 @@ if (!function_exists('h')) {
if (!function_exists('pluginSplit')) {
/**
* Splits a dot syntax plugin name into its plugin and classname.
* Splits a dot syntax plugin name into its plugin and class name.
* If $name does not have a dot, then index 0 will be null.
*
* Commonly used like `list($plugin, $name) = pluginSplit($name);`
@ -213,7 +213,7 @@ if (!function_exists('pluginSplit')) {
* @param string $name The name you want to plugin split.
* @param boolean $dotAppend Set to true if you want the plugin to have a '.' appended to it.
* @param string $plugin Optional default plugin to use if no plugin is found. Defaults to null.
* @return array Array with 2 indexes. 0 => plugin name, 1 => classname
* @return array Array with 2 indexes. 0 => plugin name, 1 => class name
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#pluginSplit
*/
function pluginSplit($name, $dotAppend = false, $plugin = null) {