Merge branch 'master' into 2.7

Conflicts:
	lib/Cake/Utility/String.php
This commit is contained in:
mark_story 2015-01-11 15:25:18 -05:00
commit ac9a212d44
59 changed files with 346 additions and 263 deletions

View file

@ -34,41 +34,41 @@
* will ask the configured ACL interface if access is granted. Under the assumptions 1. and 2. this will be
* done via a call to Acl->check() with
*
* {{{
* ```
* array('User' => array('username' => 'jeff', 'group_id' => 4, ...))
* }}}
* ```
*
* as ARO and
*
* {{{
* ```
* '/controllers/invoices/delete'
* }}}
* ```
*
* as ACO.
*
* If the configured map looks like
*
* {{{
* ```
* $config['map'] = array(
* 'User' => 'User/username',
* 'Role' => 'User/group_id',
* );
* }}}
* ```
*
* then PhpAcl will lookup if we defined a role like User/jeff. If that role is not found, PhpAcl will try to
* find a definition for Role/4. If the definition isn't found then a default role (Role/default) will be used to
* check rules for the given ACO. The search can be expanded by defining aliases in the alias configuration.
* E.g. if you want to use a more readable name than Role/4 in your definitions you can define an alias like
*
* {{{
* ```
* $config['alias'] = array(
* 'Role/4' => 'Role/editor',
* );
* }}}
* ```
*
* In the roles configuration you can define roles on the lhs and inherited roles on the rhs:
*
* {{{
* ```
* $config['roles'] = array(
* 'Role/admin' => null,
* 'Role/accountant' => null,
@ -76,12 +76,12 @@
* 'Role/manager' => 'Role/editor, Role/accountant',
* 'User/jeff' => 'Role/manager',
* );
* }}}
* ```
*
* In this example manager inherits all rules from editor and accountant. Role/admin doesn't inherit from any role.
* Lets define some rules:
*
* {{{
* ```
* $config['rules'] = array(
* 'allow' => array(
* '*' => 'Role/admin',
@ -96,7 +96,7 @@
* 'controllers/articles/(delete|publish)' => 'Role/editor',
* ),
* );
* }}}
* ```
*
* Ok, so as jeff inherits from Role/manager he's matched every rule that references User/jeff, Role/manager,
* Role/editor, and Role/accountant. However, for jeff, rules for User/jeff are more specific than

View file

@ -26,12 +26,12 @@ App::uses('CacheEngine', 'Cache');
* You can configure Cache engines in your application's `bootstrap.php` file. A sample configuration would
* be
*
* {{{
* ```
* Cache::config('shared', array(
* 'engine' => 'Apc',
* 'prefix' => 'my_app_'
* ));
* }}}
* ```
*
* This would configure an APC cache engine to the 'shared' alias. You could then read and write
* to that cache alias by using it for the `$config` parameter in the various Cache methods. In
@ -178,7 +178,12 @@ class Cache {
}
self::$_engines[$name] = new $cacheClass();
if (!self::$_engines[$name]->init($config)) {
throw new CacheException(__d('cake_dev', 'Cache engine %s is not properly configured.', $name));
$msg = __d(
'cake_dev',
'Cache engine "%s" is not properly configured. Ensure required extensions are installed, and credentials/permissions are correct',
$name
);
throw new CacheException($msg);
}
if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) {
self::$_engines[$name]->gc();
@ -512,7 +517,7 @@ class Cache {
/**
* Retrieve group names to config mapping.
*
* {{{
* ```
* Cache::config('daily', array(
* 'duration' => '1 day', 'groups' => array('posts')
* ));
@ -520,7 +525,7 @@ class Cache {
* 'duration' => '1 week', 'groups' => array('posts', 'archive')
* ));
* $configs = Cache::groupConfigs('posts');
* }}}
* ```
*
* $config will equal to `array('posts' => array('daily', 'weekly'))`
*
@ -549,12 +554,12 @@ class Cache {
*
* Using a Closure to provide data, assume $this is a Model:
*
* {{{
* ```
* $model = $this;
* $results = Cache::remember('all_articles', function() use ($model) {
* return $model->find('all');
* });
* }}}
* ```
*
* @param string $key The cache key to read/store data at.
* @param callable $callable The callable that provides data in the case when

View file

@ -34,10 +34,10 @@ App::uses('CakePlugin', 'Core');
* You can nest properties as deeply as needed using `.`'s. In addition to using `.` you
* can use standard ini section notation to create nested structures:
*
* {{{
* ```
* [section]
* key = value
* }}}
* ```
*
* Once loaded into Configure, the above would be accessed using:
*

View file

@ -175,7 +175,7 @@ class ConsoleOptionParser {
/**
* Build a parser from an array. Uses an array like
*
* {{{
* ```
* $spec = array(
* 'description' => 'text',
* 'epilog' => 'text',
@ -189,7 +189,7 @@ class ConsoleOptionParser {
* // list of subcommands to add.
* )
* );
* }}}
* ```
*
* @param array $spec The spec to build the OptionParser with.
* @return ConsoleOptionParser

View file

@ -53,13 +53,13 @@ class TaskCollection extends ObjectCollection {
* Loads/constructs a task. Will return the instance in the registry if it already exists.
*
* You can alias your task as an existing task by setting the 'className' key, i.e.,
* {{{
* ```
* public $tasks = array(
* 'DbConfig' => array(
* 'className' => 'Bakeplus.DbConfigure'
* );
* );
* }}}
* ```
* All calls to the `DbConfig` task would use `DbConfigure` found in the `Bakeplus` plugin instead.
*
* @param string $task Task name to load

View file

@ -29,11 +29,11 @@ App::uses('ClassRegistry', 'Utility');
*
* Would point to a tree structure like
*
* {{{
* ```
* controllers
* Users
* edit
* }}}
* ```
*
* @package Cake.Controller.Component.Acl
*/

View file

@ -124,21 +124,21 @@ abstract class BaseAuthorize {
*
* Create additional mappings for a standard CRUD operation:
*
* {{{
* ```
* $this->Auth->mapActions(array('create' => array('add', 'register'));
* }}}
* ```
*
* Or equivalently:
*
* {{{
* ```
* $this->Auth->mapActions(array('register' => 'create', 'add' => 'create'));
* }}}
* ```
*
* Create mappings for custom CRUD operations:
*
* {{{
* ```
* $this->Auth->mapActions(array('range' => 'search'));
* }}}
* ```
*
* You can use the custom CRUD operations to create additional generic permissions
* that behave like CRUD operations. Doing this will require additional columns on the

View file

@ -24,13 +24,13 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
* ### Using Basic auth
*
* In your controller's components array, add auth + the required settings.
* {{{
* ```
* public $components = array(
* 'Auth' => array(
* 'authenticate' => array('Basic')
* )
* );
* }}}
* ```
*
* You should also set `AuthComponent::$sessionKey = false;` in your AppController's
* beforeFilter() to prevent CakePHP from sending a session cookie to the client.

View file

@ -18,13 +18,13 @@ App::uses('FormAuthenticate', 'Controller/Component/Auth');
* An authentication adapter for AuthComponent. Provides the ability to authenticate using POST data using Blowfish
* hashing. Can be used by configuring AuthComponent to use it via the AuthComponent::$authenticate setting.
*
* {{{
* ```
* $this->Auth->authenticate = array(
* 'Blowfish' => array(
* 'scope' => array('User.active' => 1)
* )
* )
* }}}
* ```
*
* When configuring BlowfishAuthenticate you can pass in settings to which fields, model and additional conditions
* are used. See FormAuthenticate::$settings for more information.

View file

@ -18,14 +18,14 @@ App::uses('BaseAuthorize', 'Controller/Component/Auth');
* An authorization adapter for AuthComponent. Provides the ability to authorize using a controller callback.
* Your controller's isAuthorized() method should return a boolean to indicate whether or not the user is authorized.
*
* {{{
* ```
* public function isAuthorized($user) {
* if (!empty($this->request->params['admin'])) {
* return $user['role'] === 'admin';
* }
* return !empty($user);
* }
* }}}
* ```
*
* the above is simple implementation that would only authorize users of the 'admin' role to access
* admin routing.

View file

@ -28,13 +28,13 @@ App::uses('BasicAuthenticate', 'Controller/Component/Auth');
* ### Using Digest auth
*
* In your controller's components array, add auth + the required settings.
* {{{
* ```
* public $components = array(
* 'Auth' => array(
* 'authenticate' => array('Digest')
* )
* );
* }}}
* ```
*
* In your login function just call `$this->Auth->login()` without any checks for POST data. This
* will send the authentication headers, and trigger the login dialog in the browser/client.

View file

@ -18,13 +18,13 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
* An authentication adapter for AuthComponent. Provides the ability to authenticate using POST
* data. Can be used by configuring AuthComponent to use it via the AuthComponent::$authenticate setting.
*
* {{{
* ```
* $this->Auth->authenticate = array(
* 'Form' => array(
* 'scope' => array('User.active' => 1)
* )
* )
* }}}
* ```
*
* When configuring FormAuthenticate you can pass in settings to which fields, model and additional conditions
* are used. See FormAuthenticate::$settings for more information.

View file

@ -56,19 +56,19 @@ class AuthComponent extends Component {
* An array of authentication objects to use for authenticating users. You can configure
* multiple adapters and they will be checked sequentially when users are identified.
*
* {{{
* ```
* $this->Auth->authenticate = array(
* 'Form' => array(
* 'userModel' => 'Users.User'
* )
* );
* }}}
* ```
*
* Using the class name without 'Authenticate' as the key, you can pass in an array of settings for each
* authentication object. Additionally you can define settings that should be set to all authentications objects
* using the 'all' key:
*
* {{{
* ```
* $this->Auth->authenticate = array(
* 'all' => array(
* 'userModel' => 'Users.User',
@ -77,7 +77,7 @@ class AuthComponent extends Component {
* 'Form',
* 'Basic'
* );
* }}}
* ```
*
* You can also use AuthComponent::ALL instead of the string 'all'.
*
@ -97,19 +97,19 @@ class AuthComponent extends Component {
* An array of authorization objects to use for authorizing users. You can configure
* multiple adapters and they will be checked sequentially when authorization checks are done.
*
* {{{
* ```
* $this->Auth->authorize = array(
* 'Crud' => array(
* 'actionPath' => 'controllers/'
* )
* );
* }}}
* ```
*
* Using the class name without 'Authorize' as the key, you can pass in an array of settings for each
* authorization object. Additionally you can define settings that should be set to all authorization objects
* using the 'all' key:
*
* {{{
* ```
* $this->Auth->authorize = array(
* 'all' => array(
* 'actionPath' => 'controllers/'
@ -117,7 +117,7 @@ class AuthComponent extends Component {
* 'Crud',
* 'CustomAuth'
* );
* }}}
* ```
*
* You can also use AuthComponent::ALL instead of the string 'all'
*

View file

@ -29,17 +29,17 @@ App::uses('Hash', 'Utility');
* the default pagination behavior in general or for a specific model. General settings are used when there
* are no specific model configuration, or the model you are paginating does not have specific settings.
*
* {{{
* ```
* $this->Paginator->settings = array(
* 'limit' => 20,
* 'maxLimit' => 100
* );
* }}}
* ```
*
* The above settings will be used to paginate any model. You can configure model specific settings by
* keying the settings with the model name.
*
* {{{
* ```
* $this->Paginator->settings = array(
* 'Post' => array(
* 'limit' => 20,
@ -47,7 +47,7 @@ App::uses('Hash', 'Utility');
* ),
* 'Comment' => array( ... )
* );
* }}}
* ```
*
* This would allow you to have different pagination settings for `Comment` and `Post` models.
*
@ -55,13 +55,13 @@ App::uses('Hash', 'Utility');
*
* You can paginate with any find type defined on your model using the `findType` option.
*
* {{{
* ```
* $this->Paginator->settings = array(
* 'Post' => array(
* 'findType' => 'popular'
* )
* );
* }}}
* ```
*
* Would paginate using the `find('popular')` method.
*

View file

@ -79,13 +79,13 @@ class ComponentCollection extends ObjectCollection implements CakeEventListener
* Callbacks default to on. Disabled component methods work as normal, only callbacks are disabled.
*
* You can alias your component as an existing component by setting the 'className' key, i.e.,
* {{{
* ```
* public $components = array(
* 'Email' => array(
* 'className' => 'AliasedEmail'
* );
* );
* }}}
* ```
* All calls to the `Email` component would use `AliasedEmail` instead.
*
* @param string $component Component name to load

View file

@ -227,12 +227,12 @@ class Controller extends Object implements CakeEventListener {
*
* Example:
*
* {{{
* ```
* public $cacheAction = array(
* 'view/23/' => 21600,
* 'recalled/' => 86400
* );
* }}}
* ```
*
* $cacheAction can also be set to a strtotime() compatible string. This
* marks all the actions in the controller for view caching.
@ -857,10 +857,10 @@ class Controller extends Object implements CakeEventListener {
*
* Examples:
*
* {{{
* ```
* setAction('another_action');
* setAction('action_with_parameters', $parameter1);
* }}}
* ```
*
* @param string $action The new action to be 'redirected' to.
* Any other parameters passed to this method will be passed as parameters to the new action.

View file

@ -51,12 +51,12 @@ class CakePlugin {
* `CakePlugin::load(array('DebugKit', 'ApiGenerator'))` will load the DebugKit and ApiGenerator plugins
* `CakePlugin::load(array('DebugKit', 'ApiGenerator'), array('bootstrap' => true))` will load bootstrap file for both plugins
*
* {{{
* ```
* CakePlugin::load(array(
* 'DebugKit' => array('routes' => true),
* 'ApiGenerator'
* ), array('bootstrap' => true))
* }}}
* ```
*
* Will only load the bootstrap for ApiGenerator and only the routes for DebugKit
*
@ -105,12 +105,12 @@ class CakePlugin {
* If passed an options array, it will be used as a common default for all plugins to be loaded
* It is possible to set specific defaults for each plugins in the options array. Examples:
*
* {{{
* ```
* CakePlugin::loadAll(array(
* array('bootstrap' => true),
* 'DebugKit' => array('routes' => true, 'bootstrap' => false),
* ))
* }}}
* ```
*
* The above example will load the bootstrap file for all plugins, but for DebugKit it will only load
* the routes file and will not look for any bootstrap script.

View file

@ -130,7 +130,7 @@ class Configure {
* Used to store a dynamic variable in Configure.
*
* Usage:
* {{{
* ```
* Configure::write('One.key1', 'value of the Configure::One[key1]');
* Configure::write(array('One.key1' => 'value of the Configure::One[key1]'));
* Configure::write('One', array(
@ -142,7 +142,7 @@ class Configure {
* 'One.key1' => 'value of the Configure::One[key1]',
* 'One.key2' => 'value of the Configure::One[key2]'
* ));
* }}}
* ```
*
* @param string|array $config The key to write, can be a dot notation value.
* Alternatively can be an array containing key(s) and value(s).
@ -174,10 +174,10 @@ class Configure {
* possible to store `null` values in Configure.
*
* Usage:
* {{{
* ```
* Configure::read('Name'); will return all values for Name
* Configure::read('Name.key'); will return only the value of Configure::Name[key]
* }}}
* ```
*
* @param string|null $var Variable to obtain. Use '.' to access array elements.
* @return mixed value stored in configure, or null.
@ -231,10 +231,10 @@ class Configure {
* Used to delete a variable from Configure.
*
* Usage:
* {{{
* ```
* Configure::delete('Name'); will delete the entire Configure::Name
* Configure::delete('Name.key'); will delete only the Configure::Name[key]
* }}}
* ```
*
* @param string $var the var to be deleted
* @return void

View file

@ -67,10 +67,10 @@ class CakeEvent {
*
* ## Examples of usage:
*
* {{{
* ```
* $event = new CakeEvent('Order.afterBuy', $this, array('buyer' => $userData));
* $event = new CakeEvent('User.afterRegister', $UserModel);
* }}}
* ```
*
*/
public function __construct($name, $subject = null, $data = null) {

View file

@ -28,7 +28,7 @@ interface CakeEventListener {
*
* ## Example:
*
* {{{
* ```
* public function implementedEvents() {
* return array(
* 'Order.complete' => 'sendEmail',
@ -36,7 +36,7 @@ interface CakeEventListener {
* 'User.onRegister' => array('callable' => 'logRegistration', 'priority' => 20, 'passParams' => true)
* );
* }
* }}}
* ```
*
* @return array associative array or event key names pointing to the function
* that should be called in the object when the respective event is fired

View file

@ -93,9 +93,9 @@ class I18n {
* The constants may be used in translation fetching
* instead of hardcoded integers.
* Example:
* {{{
* ```
* I18n::translate('CakePHP is awesome.', null, null, I18n::LC_MESSAGES)
* }}}
* ```
*
* To keep the code more readable, I18n constants are preferred over
* hardcoded integers.

View file

@ -31,9 +31,9 @@ App::uses('LogEngineCollection', 'Log');
* You can configure log adapters in your applications `bootstrap.php` file.
* A sample configuration would look like:
*
* {{{
* ```
* CakeLog::config('my_log', array('engine' => 'File'));
* }}}
* ```
*
* See the documentation on CakeLog::config() for more detail.
*
@ -48,10 +48,10 @@ App::uses('LogEngineCollection', 'Log');
* RFC 5424. When logging messages you can either use the named methods,
* or the correct constants with `write()`:
*
* {{{
* ```
* CakeLog::error('Something horrible happened');
* CakeLog::write(LOG_ERR, 'Something horrible happened');
* }}}
* ```
*
* If you require custom logging levels, you can use CakeLog::levels() to
* append additional logging levels.
@ -129,12 +129,12 @@ class CakeLog {
*
* ### Usage:
*
* {{{
* ```
* CakeLog::config('second_file', array(
* 'engine' => 'File',
* 'path' => '/var/logs/my_app/'
* ));
* }}}
* ```
*
* Will configure a FileLog instance to use the specified path.
* All options that are not `engine` are passed onto the logging adapter,
@ -146,13 +146,13 @@ class CakeLog {
* When configuring loggers, you can set which levels a logger will handle.
* This allows you to disable debug messages in production for example:
*
* {{{
* ```
* CakeLog::config('default', array(
* 'engine' => 'File',
* 'path' => LOGS,
* 'levels' => array('error', 'critical', 'alert', 'emergency')
* ));
* }}}
* ```
*
* The above logger would only log error messages or higher. Any
* other log messages would be discarded.
@ -164,13 +164,13 @@ class CakeLog {
* logger. If you don't define any scopes an adapter will catch
* all scopes that match the handled levels.
*
* {{{
* ```
* CakeLog::config('payments', array(
* 'engine' => 'File',
* 'types' => array('info', 'error', 'warning'),
* 'scopes' => array('payment', 'order')
* ));
* }}}
* ```
*
* The above logger will only capture log entries made in the
* `payment` and `order` scopes. All other scopes including the
@ -220,15 +220,15 @@ class CakeLog {
*
* To append additional level 'user0' and 'user1' to to default log levels:
*
* {{{
* ```
* CakeLog::levels(array('user0, 'user1'));
* // or
* CakeLog::levels(array('user0, 'user1'), true);
* }}}
* ```
*
* will result in:
*
* {{{
* ```
* array(
* 0 => 'emergency',
* 1 => 'alert',
@ -236,23 +236,23 @@ class CakeLog {
* 8 => 'user0',
* 9 => 'user1',
* );
* }}}
* ```
*
* To set/replace existing configuration, pass an array with the second argument
* set to false.
*
* {{{
* ```
* CakeLog::levels(array('user0, 'user1'), false);
* }}}
* ```
*
* will result in:
*
* {{{
* ```
* array(
* 0 => 'user0',
* 1 => 'user1',
* );
* }}}
* ```
*
* @param array $levels array
* @param bool $append true to append, false to replace

View file

@ -40,14 +40,14 @@ class SyslogLog extends BaseLog {
*
* ## Example:
*
* {{{
* ```
* CakeLog::config('error', array(
* 'engine' => 'Syslog',
* 'types' => array('emergency', 'alert', 'critical', 'error'),
* 'format' => "%s: My-App - %s",
* 'prefix' => 'Web Server 01'
* ));
* }}}
* ```
*
* @var array
*/

View file

@ -75,7 +75,7 @@ class ContainableBehavior extends ModelBehavior {
*
* `Model->find('all', array('contain' => array('Model1', 'Model2')));`
*
* {{{
* ```
* Model->find('all', array('contain' => array(
* 'Model1' => array('Model11', 'Model12'),
* 'Model2',
@ -84,7 +84,7 @@ class ContainableBehavior extends ModelBehavior {
* 'Model32',
* 'Model33' => array('Model331', 'Model332')
* )));
* }}}
* ```
*
* @param Model $Model Model using the behavior
* @param array $query Query parameters as set by cake

View file

@ -86,13 +86,13 @@ class BehaviorCollection extends ObjectCollection implements CakeEventListener {
* can still be used as normal.
*
* You can alias your behavior as an existing behavior by setting the 'className' key, i.e.,
* {{{
* ```
* public $actsAs = array(
* 'Tree' => array(
* 'className' => 'AliasedTree'
* );
* );
* }}}
* ```
* All calls to the `Tree` behavior would use `AliasedTree` instead.
*
* @param string $behavior CamelCased name of the behavior to load

View file

@ -124,33 +124,33 @@ class Model extends Object implements CakeEventListener {
*
* ### Validating using regular expressions
*
* {{{
* ```
* public $validate = array(
* 'name' => '/^[a-z].+$/i'
* );
* }}}
* ```
*
* ### Validating using methods (no parameters)
*
* {{{
* ```
* public $validate = array(
* 'name' => 'notEmpty'
* );
* }}}
* ```
*
* ### Validating using methods (with parameters)
*
* {{{
* ```
* public $validate = array(
* 'length' => array(
* 'rule' => array('lengthBetween', 5, 25)
* )
* );
* }}}
* ```
*
* ### Validating using custom method
*
* {{{
* ```
* public $validate = array(
* 'password' => array(
* 'rule' => array('customValidation')
@ -163,24 +163,24 @@ class Model extends Object implements CakeEventListener {
* }
* return true;
* }
* }}}
* ```
*
* ### Validations with messages
*
* The messages will be used in Model::$validationErrors and can be used in the FormHelper
*
* {{{
* ```
* public $validate = array(
* 'length' => array(
* 'rule' => array('lengthBetween', 5, 15),
* 'message' => array('Between %d to %d characters')
* )
* );
* }}}
* ```
*
* ### Multiple validations to the same field
*
* {{{
* ```
* public $validate = array(
* 'login' => array(
* array(
@ -194,7 +194,7 @@ class Model extends Object implements CakeEventListener {
* )
* )
* );
* }}}
* ```
*
* ### Valid keys in validations
*
@ -280,7 +280,7 @@ class Model extends Object implements CakeEventListener {
*
* ### Detailed configuration
*
* {{{
* ```
* public $belongsTo = array(
* 'Group',
* 'Department' => array(
@ -288,7 +288,7 @@ class Model extends Object implements CakeEventListener {
* 'foreignKey' => 'department_id'
* )
* );
* }}}
* ```
*
* ### Possible keys in association
*
@ -327,7 +327,7 @@ class Model extends Object implements CakeEventListener {
*
* ### Detailed configuration
*
* {{{
* ```
* public $hasOne = array(
* 'Profile',
* 'Address' => array(
@ -335,7 +335,7 @@ class Model extends Object implements CakeEventListener {
* 'foreignKey' => 'user_id'
* )
* );
* }}}
* ```
*
* ### Possible keys in association
*
@ -370,7 +370,7 @@ class Model extends Object implements CakeEventListener {
*
* ### Detailed configuration
*
* {{{
* ```
* public $hasMany = array(
* 'Comment',
* 'Task' => array(
@ -378,7 +378,7 @@ class Model extends Object implements CakeEventListener {
* 'foreignKey' => 'user_id'
* )
* );
* }}}
* ```
*
* ### Possible keys in association
*
@ -419,7 +419,7 @@ class Model extends Object implements CakeEventListener {
*
* ### Detailed configuration
*
* {{{
* ```
* public $hasAndBelongsToMany = array(
* 'Role',
* 'Address' => array(
@ -429,7 +429,7 @@ class Model extends Object implements CakeEventListener {
* 'joinTable' => 'addresses_users'
* )
* );
* }}}
* ```
*
* ### Possible keys in association
*
@ -607,7 +607,7 @@ class Model extends Object implements CakeEventListener {
* If true, afterFind will be passed consistent formatted $results in case of $primary is false.
* The format will be such as the following.
*
* {{{
* ```
* $results = array(
* 0 => array(
* 'ModelName' => array(
@ -616,7 +616,7 @@ class Model extends Object implements CakeEventListener {
* )
* )
* );
* }}}
* ```
*
* @var bool
*/
@ -683,9 +683,9 @@ class Model extends Object implements CakeEventListener {
*
* You can dynamically create model instances using the $id array syntax.
*
* {{{
* ```
* $Post = new Model(array('table' => 'posts', 'name' => 'Post', 'ds' => 'connection2'));
* }}}
* ```
*
* 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.
@ -2233,12 +2233,12 @@ class Model extends Object implements CakeEventListener {
* Should be set to false if database/table does not support transactions.
* - `fieldList`: Equivalent to the $fieldList parameter in Model::save().
* It should be an associate array with model name as key and array of fields as value. Eg.
* {{{
* ```
* array(
* 'SomeModel' => array('field'),
* 'AssociatedModel' => array('field', 'otherfield')
* )
* }}}
* ```
* - `deep`: See saveMany/saveAssociated
* - `callbacks`: See Model::save()
* - `counterCache`: See Model::save()
@ -2406,12 +2406,12 @@ class Model extends Object implements CakeEventListener {
* Should be set to false if database/table does not support transactions.
* - `fieldList`: Equivalent to the $fieldList parameter in Model::save().
* It should be an associate array with model name as key and array of fields as value. Eg.
* {{{
* ```
* array(
* 'SomeModel' => array('field'),
* 'AssociatedModel' => array('field', 'otherfield')
* )
* }}}
* ```
* - `deep`: If set to true, not only directly associated data is saved, but deeper nested associated data as well.
* - `callbacks`: See Model::save()
* - `counterCache`: See Model::save()
@ -2919,7 +2919,7 @@ class Model extends Object implements CakeEventListener {
* 'recursive', 'page', 'fields', 'offset', 'order', 'callbacks')
*
* Eg:
* {{{
* ```
* $model->find('all', array(
* 'conditions' => array('name' => 'Thomas Anderson'),
* 'fields' => array('name', 'email'),
@ -2928,13 +2928,13 @@ class Model extends Object implements CakeEventListener {
* 'group' => 'type',
* 'callbacks' => false,
* ));
* }}}
* ```
*
* In addition to the standard query keys above, you can provide Datasource, and behavior specific
* keys. For example, when using a SQL based datasource you can use the joins key to specify additional
* joins that should be part of the query.
*
* {{{
* ```
* $model->find('all', array(
* 'conditions' => array('name' => 'Thomas Anderson'),
* 'joins' => array(
@ -2946,7 +2946,7 @@ class Model extends Object implements CakeEventListener {
* )
* )
* ));
* }}}
* ```
*
* ### Disabling callbacks
*
@ -2996,7 +2996,7 @@ class Model extends Object implements CakeEventListener {
* Model::_readDataSource() is used by all find() calls to read from the data source and can be overloaded to allow
* caching of datasource calls.
*
* {{{
* ```
* protected function _readDataSource($type, $query) {
* $cacheName = md5(json_encode($query));
* $cache = Cache::read($cacheName, 'cache-config-name');
@ -3008,7 +3008,7 @@ class Model extends Object implements CakeEventListener {
* Cache::write($cacheName, $results, 'cache-config-name');
* return $results;
* }
* }}}
* ```
*
* @param string $type Type of find operation (all / first / count / neighbors / list / threaded)
* @param array $query Option fields (conditions / fields / joins / limit / offset / order / page / group / callbacks)

View file

@ -30,11 +30,11 @@
* Behaviors can provide mixin like features by declaring public methods. These methods should expect
* the model instance to be shifted onto the parameter list.
*
* {{{
* ```
* function doSomething(Model $model, $arg1, $arg2) {
* //do something
* }
* }}}
* ```
*
* Would be called like `$this->Model->doSomething($arg1, $arg2);`.
*
@ -45,13 +45,13 @@
* be declared in your behaviors `$mapMethods` array. The method signature for a mapped method is slightly different
* than a normal behavior mixin method.
*
* {{{
* ```
* public $mapMethods = array('/do(\w+)/' => 'doSomething');
*
* function doSomething(Model $model, $method, $arg1, $arg2) {
* //do something
* }
* }}}
* ```
*
* The above will map every doXXX() method call to the behavior. As you can see, the model is
* still the first parameter, but the called method name will be the 2nd parameter. This allows

View file

@ -535,7 +535,7 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
*
* ## Example:
*
* {{{
* ```
* $validator
* ->add('title', 'required', array('rule' => 'notEmpty', 'required' => true))
* ->add('user_id', 'valid', array('rule' => 'numeric', 'message' => 'Invalid User'))
@ -544,7 +544,7 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
* 'size' => array('rule' => array('lengthBetween', 8, 20)),
* 'hasSpecialCharacter' => array('rule' => 'validateSpecialchar', 'message' => 'not valid')
* ));
* }}}
* ```
*
* @param string $field The name of the field where the rule is to be added
* @param string|array|CakeValidationSet $name name of the rule to be added or list of rules for the field
@ -580,11 +580,11 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
*
* ## Example:
*
* {{{
* ```
* $validator
* ->remove('title', 'required')
* ->remove('user_id')
* }}}
* ```
*
* @param string $field The name of the field from which the rule will be removed
* @param string $rule the name of the rule to be removed

View file

@ -183,11 +183,11 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
*
* ## Example:
*
* {{{
* ```
* $set
* ->setRule('required', array('rule' => 'notEmpty', 'required' => true))
* ->setRule('between', array('rule' => array('lengthBetween', 4, 10))
* }}}
* ```
*
* @param string $name The name under which the rule should be set
* @param CakeValidationRule|array $rule The validation rule to be set
@ -206,11 +206,11 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
*
* ## Example:
*
* {{{
* ```
* $set
* ->removeRule('required')
* ->removeRule('inRange')
* }}}
* ```
*
* @param string $name The name under which the rule should be unset
* @return $this
@ -225,12 +225,12 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
*
* ## Example:
*
* {{{
* ```
* $set->setRules(array(
* 'required' => array('rule' => 'notEmpty', 'required' => true),
* 'inRange' => array('rule' => array('between', 4, 10)
* ));
* }}}
* ```
*
* @param array $rules The rules to be set
* @param bool $mergeVars [optional] If true, merges vars instead of replace. Defaults to true.

View file

@ -841,11 +841,11 @@ class CakeRequest implements ArrayAccess {
*
* Get the list of accepted languages:
*
* {{{ CakeRequest::acceptLanguage(); }}}
* ``` CakeRequest::acceptLanguage(); ```
*
* Check if a specific language is accepted:
*
* {{{ CakeRequest::acceptLanguage('es-es'); }}}
* ``` CakeRequest::acceptLanguage('es-es'); ```
*
* @param string $language The language to test.
* @return mixed If a $language is provided, a boolean. Otherwise the array of accepted languages.

View file

@ -513,16 +513,15 @@ class CakeResponse {
/**
* Sends a header to the client.
*
* Will skip sending headers if headers have already been sent.
*
* @param string $name the header name
* @param string $value the header value
* @return void
* @throws CakeException When headers have already been sent
*/
protected function _sendHeader($name, $value = null) {
if (headers_sent($filename, $linenum)) {
throw new CakeException(
__d('cake_dev', 'Headers already sent in %s on line %s', $filename, $linenum)
);
return;
}
if ($value === null) {
header($name);

View file

@ -1002,35 +1002,35 @@ class CakeEmail {
*
* Attach a single file:
*
* {{{
* ```
* $email->attachments('path/to/file');
* }}}
* ```
*
* Attach a file with a different filename:
*
* {{{
* ```
* $email->attachments(array('custom_name.txt' => 'path/to/file.txt'));
* }}}
* ```
*
* Attach a file and specify additional properties:
*
* {{{
* ```
* $email->attachments(array('custom_name.png' => array(
* 'file' => 'path/to/file',
* 'mimetype' => 'image/png',
* 'contentId' => 'abc123',
* 'contentDisposition' => false
* ));
* }}}
* ```
*
* Attach a file from string and specify additional properties:
*
* {{{
* ```
* $email->attachments(array('custom_name.png' => array(
* 'data' => file_get_contents('path/to/file'),
* 'mimetype' => 'image/png'
* ));
* }}}
* ```
*
* The `contentId` key allows you to specify an inline attachment. In your email text, you
* can use `<img src="cid:abc123" />` to display the image inline.

View file

@ -58,7 +58,7 @@ class SmtpTransport extends AbstractTransport {
*
* A response consists of one or more lines containing a response
* code and an optional response message text:
* {{{
* ```
* array(
* array(
* 'code' => '250',
@ -74,7 +74,7 @@ class SmtpTransport extends AbstractTransport {
* ),
* // etc...
* )
* }}}
* ```
*
* @return array
*/

View file

@ -139,12 +139,12 @@ class HttpSocket extends CakeSocket {
*
* Or use an array to configure multiple options:
*
* {{{
* ```
* $http = new HttpSocket(array(
* 'host' => 'cakephp.org',
* 'timeout' => 20
* ));
* }}}
* ```
*
* See HttpSocket::$config for options that can be used.
*
@ -169,21 +169,21 @@ class HttpSocket extends CakeSocket {
* Accepts two forms of parameters. If all you need is a username + password, as with
* Basic authentication you can do the following:
*
* {{{
* ```
* $http->configAuth('Basic', 'mark', 'secret');
* }}}
* ```
*
* If you are using an authentication strategy that requires more inputs, like Digest authentication
* you can call `configAuth()` with an array of user information.
*
* {{{
* ```
* $http->configAuth('Digest', array(
* 'user' => 'mark',
* 'pass' => 'secret',
* 'realm' => 'my-realm',
* 'nonce' => 1235
* ));
* }}}
* ```
*
* To remove any set authentication strategy, call `configAuth()` with no parameters:
*
@ -439,12 +439,12 @@ class HttpSocket extends CakeSocket {
*
* You could express the same thing using a uri array and query string parameters:
*
* {{{
* ```
* $response = $http->get(
* array('host' => 'google.com', 'path' => '/search'),
* array('q' => 'cakephp', 'client' => 'safari')
* );
* }}}
* ```
*
* @param string|array $uri URI to request. Either a string uri, or a uri array, see HttpSocket::_parseUri()
* @param array $query Querystring parameters to append to URI
@ -497,12 +497,12 @@ class HttpSocket extends CakeSocket {
*
* `post()` can be used to post simple data arrays to a URL:
*
* {{{
* ```
* $response = $http->post('http://example.com', array(
* 'username' => 'batman',
* 'password' => 'bruce_w4yne'
* ));
* }}}
* ```
*
* @param string|array $uri URI to request. See HttpSocket::_parseUri()
* @param array $data Array of request body data keys and values.
@ -563,10 +563,10 @@ class HttpSocket extends CakeSocket {
* After configuring part of the request parameters, you can use url() to generate
* URLs.
*
* {{{
* ```
* $http = new HttpSocket('http://www.cakephp.org');
* $url = $http->url('/search?q=bar');
* }}}
* ```
*
* Would return `http://www.cakephp.org/search?q=bar`
*

View file

@ -289,13 +289,13 @@ class Router {
*
* The above shows the use of route parameter defaults, and providing routing parameters for a static route.
*
* {{{
* ```
* Router::connect(
* '/:lang/:controller/:action/:id',
* array(),
* array('id' => '[0-9]+', 'lang' => '[a-z]{3}')
* );
* }}}
* ```
*
* Shows connecting a route with custom route parameters as well as providing patterns for those parameters.
* Patterns for routing parameters do not need capturing groups, as one will be added for each route params.
@ -426,37 +426,37 @@ class Router {
*
* Do not parse any named parameters:
*
* {{{ Router::connectNamed(false); }}}
* ``` Router::connectNamed(false); ```
*
* Parse only default parameters used for CakePHP's pagination:
*
* {{{ Router::connectNamed(false, array('default' => true)); }}}
* ``` Router::connectNamed(false, array('default' => true)); ```
*
* Parse only the page parameter if its value is a number:
*
* {{{ Router::connectNamed(array('page' => '[\d]+'), array('default' => false, 'greedy' => false)); }}}
* ``` Router::connectNamed(array('page' => '[\d]+'), array('default' => false, 'greedy' => false)); ```
*
* Parse only the page parameter no matter what.
*
* {{{ Router::connectNamed(array('page'), array('default' => false, 'greedy' => false)); }}}
* ``` Router::connectNamed(array('page'), array('default' => false, 'greedy' => false)); ```
*
* Parse only the page parameter if the current action is 'index'.
*
* {{{
* ```
* Router::connectNamed(
* array('page' => array('action' => 'index')),
* array('default' => false, 'greedy' => false)
* );
* }}}
* ```
*
* Parse only the page parameter if the current action is 'index' and the controller is 'pages'.
*
* {{{
* ```
* Router::connectNamed(
* array('page' => array('action' => 'index', 'controller' => 'pages')),
* array('default' => false, 'greedy' => false)
* );
* }}}
* ```
*
* ### Options
*

View file

@ -3031,7 +3031,7 @@ SQL;
$this->assertSame($expected, $result);
$result = $this->Dbo->length(false);
$this->assertTrue($result === null);
$this->assertNull($result);
$result = $this->Dbo->length('datetime');
$expected = null;

View file

@ -382,6 +382,23 @@ TEXT;
$this->assertTextEquals($expected, $result, 'Text not wrapped.');
}
/**
* test that wordWrap() properly handle newline characters.
*
* @return void
*/
public function testWordWrapNewlineAware() {
$text = 'This is a line that is almost the 55 chars long.
This is a new sentence which is manually newlined, but is so long it needs two lines.';
$result = String::wordWrap($text, 55);
$expected = <<<TEXT
This is a line that is almost the 55 chars long.
This is a new sentence which is manually newlined, but
is so long it needs two lines.
TEXT;
$this->assertTextEquals($expected, $result, 'Text not wrapped.');
}
/**
* test wrap method.
*

View file

@ -597,4 +597,17 @@ class FileTest extends CakeTestCase {
$TmpFile->delete();
}
/**
* Tests that no path is being set for passed file paths that
* do not exist.
*
* @return void
*/
public function testNoPartialPathBeingSetForNonExistentPath()
{
$tmpFile = new File('/non/existent/file');
$this->assertNull($tmpFile->pwd());
$this->assertNull($tmpFile->path);
}
}

View file

@ -1338,6 +1338,18 @@ class FormHelperTest extends CakeTestCase {
$this->Form->radio('Test.test', $options);
$expected = array('Test.test');
$this->assertEquals($expected, $this->Form->fields);
$this->Form->radio('Test.all', $options, array(
'disabled' => array('option1', 'option2')
));
$expected = array('Test.test', 'Test.all' => '');
$this->assertEquals($expected, $this->Form->fields);
$this->Form->radio('Test.some', $options, array(
'disabled' => array('option1')
));
$expected = array('Test.test', 'Test.all' => '', 'Test.some');
$this->assertEquals($expected, $this->Form->fields);
}
/**
@ -1372,9 +1384,11 @@ class FormHelperTest extends CakeTestCase {
$this->Form->checkbox('Model.checkbox', array('disabled' => true));
$this->Form->text('Model.text', array('disabled' => true));
$this->Form->password('Model.text', array('disabled' => true));
$this->Form->text('Model.text2', array('disabled' => 'disabled'));
$this->Form->password('Model.password', array('disabled' => true));
$this->Form->textarea('Model.textarea', array('disabled' => true));
$this->Form->select('Model.select', array(1, 2), array('disabled' => true));
$this->Form->select('Model.select', array(1, 2), array('disabled' => array(1, 2)));
$this->Form->radio('Model.radio', array(1, 2), array('disabled' => array(1, 2)));
$this->Form->year('Model.year', null, null, array('disabled' => true));
$this->Form->month('Model.month', array('disabled' => true));

View file

@ -341,13 +341,13 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
* Checks for an input tag with a name attribute (contains any non-empty value) and an id
* attribute that contains 'my-input':
*
* {{{
* ```
* array('input' => array('name', 'id' => 'my-input'))
* }}}
* ```
*
* Checks for two p elements with some text in them:
*
* {{{
* ```
* array(
* array('p' => true),
* 'textA',
@ -356,17 +356,17 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
* 'textB',
* '/p'
* )
* }}}
* ```
*
* You can also specify a pattern expression as part of the attribute values, or the tag
* being defined, if you prepend the value with preg: and enclose it with slashes, like so:
*
* {{{
* ```
* array(
* array('input' => array('name', 'id' => 'preg:/FieldName\d+/')),
* 'preg:/My\s+field/'
* )
* }}}
* ```
*
* Important: This function is very forgiving about whitespace and also accepts any
* permutation of attribute order. It will also allow whitespace between specified tags.
@ -733,6 +733,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
$availableDs = array_keys(ConnectionManager::enumConnectionObjects());
if ($mock->useDbConfig === 'default') {
$mock->useDbConfig = null;
$mock->setDataSource('test');
}
if ($mock->useDbConfig !== 'test' && in_array('test_' . $mock->useDbConfig, $availableDs)) {

View file

@ -380,11 +380,11 @@ class CakeNumber {
* Add a currency format to the Number helper. Makes reusing
* currency formats easier.
*
* {{{ $number->addFormat('NOK', array('before' => 'Kr. ')); }}}
* ``` $number->addFormat('NOK', array('before' => 'Kr. ')); ```
*
* You can now use `NOK` as a shortform when formatting currency amounts.
*
* {{{ $number->currency($value, 'NOK'); }}}
* ``` $number->currency($value, 'NOK'); ```
*
* Added formats are merged with the defaults defined in CakeNumber::$_currencyDefaults
* See CakeNumber::currency() for more information on the various options and their function.

View file

@ -355,6 +355,23 @@ class CakeText {
* @return string Formatted text.
*/
public static function wordWrap($text, $width = 72, $break = "\n", $cut = false) {
$paragraphs = explode($break, $text);
foreach ($paragraphs as &$paragraph) {
$paragraph = self::_wordWrap($paragraph, $width, $break, $cut);
}
return implode($break, $paragraphs);
}
/**
* Helper method for wordWrap().
*
* @param string $text The text to format.
* @param int $width The width to wrap to. Defaults to 72.
* @param string $break The line is broken using the optional break parameter. Defaults to '\n'.
* @param bool $cut If the cut is set to true, the string is always wrapped at the specified width.
* @return string Formatted text.
*/
protected static function _wordWrap($text, $width = 72, $break = "\n", $cut = false) {
if ($cut) {
$parts = array();
while (mb_strlen($text) > 0) {

View file

@ -1018,12 +1018,12 @@ class CakeTime {
*
* Create localized & formatted time:
*
* {{{
* ```
* CakeTime::format('2012-02-15', '%m-%d-%Y'); // returns 02-15-2012
* CakeTime::format('2012-02-15 23:01:01', '%c'); // returns preferred date and time based on configured locale
* CakeTime::format('0000-00-00', '%d-%m-%Y', 'N/A'); // return N/A becuase an invalid date was passed
* CakeTime::format('2012-02-15 23:01:01', '%c', 'N/A', 'America/New_York'); // converts passed date to timezone
* }}}
* ```
*
* @param int|string|DateTime $date UNIX timestamp, strtotime() valid string or DateTime object (or a date format string)
* @param int|string|DateTime $format date format string (or UNIX timestamp, strtotime() valid string or DateTime object)
@ -1138,7 +1138,7 @@ class CakeTime {
if (function_exists('mb_check_encoding')) {
$valid = mb_check_encoding($format, $encoding);
} else {
$valid = !Multibyte::checkMultibyte($format);
$valid = Multibyte::checkMultibyte($format);
}
if (!$valid) {
$format = utf8_encode($format);

View file

@ -79,13 +79,13 @@ class ClassRegistry {
*
* When $class is a numeric keyed array, multiple class instances will be stored in the registry,
* no instance of the object will be returned
* {{{
* ```
* array(
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry'),
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry'),
* array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry')
* );
* }}}
* ```
*
* @param string|array $class as a string or a single key => value array instance will be created,
* stored in the registry and returned.

View file

@ -393,7 +393,10 @@ class File {
*/
public function pwd() {
if ($this->path === null) {
$this->path = $this->Folder->slashTerm($this->Folder->pwd()) . $this->name;
$dir = $this->Folder->pwd();
if (is_dir($dir)) {
$this->path = $this->Folder->slashTerm($dir) . $this->name;
}
}
return $this->path;
}

View file

@ -445,9 +445,9 @@ class Hash {
*
* Usage:
*
* {{{
* ```
* $result = Hash::format($users, array('{n}.User.id', '{n}.User.name'), '%s : %s');
* }}}
* ```
*
* The `$format` string can use any format options that `vsprintf()` and `sprintf()` do.
*

View file

@ -78,6 +78,7 @@ class Inflector {
'cookie' => 'cookies',
'corpus' => 'corpuses',
'cow' => 'cows',
'criterion' => 'criteria',
'ganglion' => 'ganglions',
'genie' => 'genies',
'genus' => 'genera',
@ -304,7 +305,7 @@ class Inflector {
*
* ### Usage:
*
* {{{
* ```
* Inflector::rules('plural', array('/^(inflect)or$/i' => '\1ables'));
* Inflector::rules('plural', array(
* 'rules' => array('/^(inflect)ors$/i' => '\1ables'),
@ -312,7 +313,7 @@ class Inflector {
* 'irregular' => array('red' => 'redlings')
* ));
* Inflector::rules('transliteration', array('/å/' => 'aa'));
* }}}
* ```
*
* @param string $type The type of inflection, either 'plural', 'singular' or 'transliteration'
* @param array $rules Array of rules to be added.

View file

@ -91,9 +91,9 @@ class Security {
*
* Creating a blowfish/bcrypt hash:
*
* {{{
* ```
* $hash = Security::hash($password, 'blowfish');
* }}}
* ```
*
* @param string $string String to hash
* @param string $type Method to use (sha1/sha256/md5/blowfish)

View file

@ -52,7 +52,7 @@ class Xml {
*
* Building from an array:
*
* {{{
* ```
* $value = array(
* 'tags' => array(
* 'tag' => array(
@ -68,7 +68,7 @@ class Xml {
* )
* );
* $xml = Xml::build($value);
* }}}
* ```
*
* When building XML from an array ensure that there is only one top level element.
*
@ -164,7 +164,7 @@ class Xml {
*
* Using the following data:
*
* {{{
* ```
* $value = array(
* 'root' => array(
* 'tag' => array(
@ -174,7 +174,7 @@ class Xml {
* )
* )
* );
* }}}
* ```
*
* Calling `Xml::fromArray($value, 'tags');` Will generate:
*

View file

@ -498,7 +498,7 @@ class FormHelper extends AppHelper {
*
* If $options is set a form submit button will be created. Options can be either a string or an array.
*
* {{{
* ```
* array usage:
*
* array('label' => 'save'); value="save"
@ -506,7 +506,7 @@ class FormHelper extends AppHelper {
* array('name' => 'Whatever'); value="Submit" name="Whatever"
* array('label' => 'save', 'name' => 'Whatever', 'div' => 'good') <div class="good"> value="save" name="Whatever"
* array('label' => 'save', 'name' => 'Whatever', 'div' => array('class' => 'good')); <div class="good"> value="save" name="Whatever"
* }}}
* ```
*
* If $secureAttributes is set, these html attributes will be merged into the hidden input tags generated for the
* Security Component. This is especially useful to set HTML5 attributes like 'form'
@ -786,33 +786,33 @@ class FormHelper extends AppHelper {
*
* The text and for attribute are generated off of the fieldname
*
* {{{
* ```
* echo $this->Form->label('Post.published');
* <label for="PostPublished">Published</label>
* }}}
* ```
*
* Custom text:
*
* {{{
* ```
* echo $this->Form->label('Post.published', 'Publish');
* <label for="PostPublished">Publish</label>
* }}}
* ```
*
* Custom class name:
*
* {{{
* ```
* echo $this->Form->label('Post.published', 'Publish', 'required');
* <label for="PostPublished" class="required">Publish</label>
* }}}
* ```
*
* Custom attributes:
*
* {{{
* ```
* echo $this->Form->label('Post.published', 'Publish', array(
* 'for' => 'post-publish'
* ));
* <label for="post-publish">Publish</label>
* }}}
* ```
*
* @param string $fieldName This should be "Modelname.fieldname"
* @param string $text Text that will appear in the label field. If
@ -859,11 +859,11 @@ class FormHelper extends AppHelper {
* will be used.
*
* You can customize individual inputs through `$fields`.
* {{{
* ```
* $this->Form->inputs(array(
* 'name' => array('label' => 'custom label')
* ));
* }}}
* ```
*
* In addition to controller fields output, `$fields` can be used to control legend
* and fieldset rendering.
@ -1491,7 +1491,9 @@ class FormHelper extends AppHelper {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options-for-select-checkbox-and-radio-inputs
*/
public function radio($fieldName, $options = array(), $attributes = array()) {
$attributes['options'] = $options;
$attributes = $this->_initInputField($fieldName, $attributes);
unset($attributes['options']);
$showEmpty = $this->_extractOption('empty', $attributes);
if ($showEmpty) {
@ -1986,13 +1988,13 @@ class FormHelper extends AppHelper {
*
* A simple array will create normal options:
*
* {{{
* ```
* $options = array(1 => 'one', 2 => 'two);
* $this->Form->select('Model.field', $options));
* }}}
* ```
*
* While a nested options array will create optgroups with options inside them.
* {{{
* ```
* $options = array(
* 1 => 'bill',
* 'fred' => array(
@ -2001,7 +2003,7 @@ class FormHelper extends AppHelper {
* )
* );
* $this->Form->select('Model.field', $options);
* }}}
* ```
*
* In the above `2 => 'fred'` will not generate an option element. You should enable the `showParents`
* attribute to show the fred option.
@ -2009,12 +2011,12 @@ class FormHelper extends AppHelper {
* If you have multiple options that need to have the same value attribute, you can
* use an array of arrays to express this:
*
* {{{
* ```
* $options = array(
* array('name' => 'United states', 'value' => 'USA'),
* array('name' => 'USA', 'value' => 'USA'),
* );
* }}}
* ```
*
* @param string $fieldName Name attribute of the SELECT
* @param array $options Array of the OPTION elements (as 'value'=>'Text' pairs) to be used in the
@ -2955,7 +2957,18 @@ class FormHelper extends AppHelper {
$result = $this->addClass($result, 'form-error');
}
if (!empty($result['disabled'])) {
$isDisabled = false;
if (isset($result['disabled'])) {
$isDisabled = (
$result['disabled'] === true ||
$result['disabled'] === 'disabled' ||
(is_array($result['disabled']) &&
!empty($result['options']) &&
array_diff($result['options'], $result['disabled']) === array()
)
);
}
if ($isDisabled) {
return $result;
}

View file

@ -650,12 +650,12 @@ class HtmlHelper extends AppHelper {
*
* ### Usage:
*
* {{{
* ```
* echo $this->Html->style(array('margin' => '10px', 'padding' => '10px'), true);
*
* // creates
* 'margin:10px;padding:10px;'
* }}}
* ```
*
* @param array $data Style data array, keys will be used as property names, values as property values.
* @param bool $oneline Whether or not the style block should be displayed on one line.
@ -1034,21 +1034,21 @@ class HtmlHelper extends AppHelper {
*
* Using multiple video files:
*
* {{{
* ```
* echo $this->Html->media(
* array('video.mp4', array('src' => 'video.ogv', 'type' => "video/ogg; codecs='theora, vorbis'")),
* array('tag' => 'video', 'autoplay')
* );
* }}}
* ```
*
* Outputs:
*
* {{{
* ```
* <video autoplay="autoplay">
* <source src="/files/video.mp4" type="video/mp4"/>
* <source src="/files/video.ogv" type="video/ogv; codecs='theora, vorbis'"/>
* </video>
* }}}
* ```
*
* ### Options
*
@ -1186,11 +1186,11 @@ class HtmlHelper extends AppHelper {
*
* tags.php could look like:
*
* {{{
* ```
* $tags = array(
* 'meta' => '<meta %s>'
* );
* }}}
* ```
*
* If you wish to store tag definitions in another format you can give an array
* containing the file name, and reader class name:

View file

@ -152,11 +152,11 @@ class NumberHelper extends AppHelper {
* Add a currency format to the Number helper. Makes reusing
* currency formats easier.
*
* {{{ $this->Number->addFormat('NOK', array('before' => 'Kr. ')); }}}
* ``` $this->Number->addFormat('NOK', array('before' => 'Kr. ')); ```
*
* You can now use `NOK` as a shortform when formatting currency amounts.
*
* {{{ $this->Number->currency($value, 'NOK'); }}}
* ``` $this->Number->currency($value, 'NOK'); ```
*
* Added formats are merged with the defaults defined in Cake\Utility\Number::$_currencyDefaults
* See Cake\Utility\Number::currency() for more information on the various options and their function.

View file

@ -89,17 +89,17 @@ class SessionHelper extends AppHelper {
* You can pass additional information into the flash message generation. This allows you
* to consolidate all the parameters for a given type of flash message into the view.
*
* {{{
* ```
* echo $this->Session->flash('flash', array('params' => array('class' => 'new-flash')));
* }}}
* ```
*
* The above would generate a flash message with a custom class name. Using $attrs['params'] you
* can pass additional data into the element rendering that will be made available as local variables
* when the element is rendered:
*
* {{{
* ```
* echo $this->Session->flash('flash', array('params' => array('name' => $user['User']['name'])));
* }}}
* ```
*
* This would pass the current user's name into the flash message, so you could create personalized
* messages without the controller needing access to that data.
@ -107,19 +107,19 @@ class SessionHelper extends AppHelper {
* Lastly you can choose the element that is rendered when creating the flash message. Using
* custom elements allows you to fully customize how flash messages are generated.
*
* {{{
* ```
* echo $this->Session->flash('flash', array('element' => 'my_custom_element'));
* }}}
* ```
*
* If you want to use an element from a plugin for rendering your flash message you can do that using the
* plugin param:
*
* {{{
* ```
* echo $this->Session->flash('flash', array(
* 'element' => 'my_custom_element',
* 'params' => array('plugin' => 'my_plugin')
* ));
* }}}
* ```
*
* @param string $key The [Message.]key you are rendering in the view.
* @param array $attrs Additional attributes to use for the creation of this flash message.

View file

@ -462,12 +462,12 @@ class TimeHelper extends AppHelper {
*
* Create localized & formatted time:
*
* {{{
* ```
* $this->Time->format('2012-02-15', '%m-%d-%Y'); // returns 02-15-2012
* $this->Time->format('2012-02-15 23:01:01', '%c'); // returns preferred date and time based on configured locale
* $this->Time->format('0000-00-00', '%d-%m-%Y', 'N/A'); // return N/A becuase an invalid date was passed
* $this->Time->format('2012-02-15 23:01:01', '%c', 'N/A', 'America/New_York'); // converts passed date to timezone
* }}}
* ```
*
* @param int|string|DateTime $format date format string (or a UNIX timestamp, strtotime() valid string or DateTime object)
* @param int|string|DateTime $date UNIX timestamp, strtotime() valid string or DateTime object (or a date format string)

View file

@ -98,13 +98,13 @@ class HelperCollection extends ObjectCollection implements CakeEventListener {
* declaring $helpers arrays you can disable callbacks on helpers.
*
* You can alias your helper as an existing helper by setting the 'className' key, i.e.,
* {{{
* ```
* public $helpers = array(
* 'Html' => array(
* 'className' => 'AliasedHtml'
* );
* );
* }}}
* ```
* All calls to the `Html` helper would use `AliasedHtml` instead.
*
* @param string $helper Helper name to load

View file

@ -32,10 +32,10 @@ App::uses('View', 'View');
* You can also define `'_serialize'` as an array. This will create a top level object containing
* all the named view variables:
*
* {{{
* ```
* $this->set(compact('posts', 'users', 'stuff'));
* $this->set('_serialize', array('posts', 'users'));
* }}}
* ```
*
* The above would generate a JSON object that looks like:
*

View file

@ -36,7 +36,7 @@ App::uses('CakeRequest', 'Network');
*
* ### Usage
*
* {{{
* ```
* class ExampleController extends AppController {
* public function download() {
* $this->viewClass = 'Media';
@ -50,7 +50,7 @@ App::uses('CakeRequest', 'Network');
* $this->set($params);
* }
* }
* }}}
* ```
*
* @package Cake.View
* @deprecated 3.0.0 Deprecated since version 2.3, use CakeResponse::file() instead

View file

@ -36,10 +36,10 @@ App::uses('Hash', 'Utility');
* You can also define `'_serialize'` as an array. This will create an additional
* top level element named `<response>` containing all the named view variables:
*
* {{{
* ```
* $this->set(compact('posts', 'users', 'stuff'));
* $this->set('_serialize', array('posts', 'users'));
* }}}
* ```
*
* The above would generate a XML object that looks like:
*