From 9670a5af88c65e662d4e3d602ae789107c0e293f Mon Sep 17 00:00:00 2001 From: ukk1337 Date: Tue, 4 Feb 2014 13:35:48 +0100 Subject: [PATCH 01/12] Added missing 'Session'-Compomnent in bake If a Controller was baked interactively and one want to use Session flash messages, the required 'Session'-Component wasn't added to the $components-Array --- lib/Cake/Console/Command/Task/ControllerTask.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 3c1079b8b..d80bb35f3 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -184,6 +184,10 @@ class ControllerTask extends BakeTask { $wannaUseSession = $this->in( __d('cake_console', "Would you like to use Session flash messages?"), array('y', 'n'), 'y' ); + + if (strtolower($wannaUseSession) === 'y') { + array_push($components, 'Session'); + } } } else { list($wannaBakeCrud, $wannaBakeAdminCrud) = $this->_askAboutMethods(); From 60c289fd68b237e921bbc53be2e15e4004cb9a3a Mon Sep 17 00:00:00 2001 From: ukk1337 Date: Tue, 4 Feb 2014 13:47:50 +0100 Subject: [PATCH 02/12] removed indentation --- lib/Cake/Console/Command/Task/ControllerTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index d80bb35f3..fd9e969b0 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -186,7 +186,7 @@ class ControllerTask extends BakeTask { ); if (strtolower($wannaUseSession) === 'y') { - array_push($components, 'Session'); + array_push($components, 'Session'); } } } else { From 3cd6bb39bd59399be38d39ec7cbc380bfc024678 Mon Sep 17 00:00:00 2001 From: ukk1337 Date: Tue, 4 Feb 2014 15:37:23 +0100 Subject: [PATCH 03/12] fixed coding standard errors --- lib/Cake/Console/Command/Task/ControllerTask.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index fd9e969b0..c3d889a3c 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -184,10 +184,10 @@ class ControllerTask extends BakeTask { $wannaUseSession = $this->in( __d('cake_console', "Would you like to use Session flash messages?"), array('y', 'n'), 'y' ); - - if (strtolower($wannaUseSession) === 'y') { + + if (strtolower($wannaUseSession) === 'y') { array_push($components, 'Session'); - } + } } } else { list($wannaBakeCrud, $wannaBakeAdminCrud) = $this->_askAboutMethods(); From fcd41e45a784345984deef5b845f54c9e1a62b42 Mon Sep 17 00:00:00 2001 From: Jimmy Madon Date: Wed, 5 Feb 2014 18:25:14 +0000 Subject: [PATCH 04/12] Clarified ACL node lookup failed error. Original error was ambiguous in stating whether the ARO node lookup failed or the ACO node lookup failed. --- lib/Cake/Model/Permission.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Model/Permission.php b/lib/Cake/Model/Permission.php index 5a781ff16..4268f3ad2 100644 --- a/lib/Cake/Model/Permission.php +++ b/lib/Cake/Model/Permission.php @@ -82,9 +82,9 @@ class Permission extends AppModel { $aroPath = $this->Aro->node($aro); $acoPath = $this->Aco->node($aco); - if (!$aroPath || !$acoPath) { + if (!$aroPath) { trigger_error(__d('cake_dev', - "%s - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: %s\nAco: %s", + "%s - Failed ARO node lookup in permissions check. Node references:\nAro: %s\nAco: %s", 'DbAcl::check()', print_r($aro, true), print_r($aco, true)), From d9489257d34de4fdfd3ea57be908269a4ab56c87 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 6 Feb 2014 02:41:36 +0530 Subject: [PATCH 05/12] Don't return `true` from view classes' render() method. It cause's Controller:render() to set the response body as `true`. Refs #2780 --- lib/Cake/Test/Case/View/MediaViewTest.php | 6 ++---- lib/Cake/Test/Case/View/ViewTest.php | 2 +- lib/Cake/View/MediaView.php | 3 +-- lib/Cake/View/View.php | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Test/Case/View/MediaViewTest.php b/lib/Cake/Test/Case/View/MediaViewTest.php index 514a6f434..d3b8dc70d 100644 --- a/lib/Cake/Test/Case/View/MediaViewTest.php +++ b/lib/Cake/Test/Case/View/MediaViewTest.php @@ -80,8 +80,7 @@ class MediaViewTest extends CakeTestCase { $this->MediaView->response->expects($this->once()) ->method('send'); - $result = $this->MediaView->render(); - $this->assertTrue($result); + $this->MediaView->render(); } /** @@ -119,8 +118,7 @@ class MediaViewTest extends CakeTestCase { $this->MediaView->response->expects($this->once()) ->method('send'); - $result = $this->MediaView->render(); - $this->assertTrue($result); + $this->MediaView->render(); } /** diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index b7fc2609c..2d2875286 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -1024,7 +1024,7 @@ class ViewTest extends CakeTestCase { $this->assertRegExp("/yo what up<\/title>/", $result); $this->assertRegExp("/<p><a href=\"flash\">yo what up<\/a><\/p>/", $result); - $this->assertTrue($View->render(false, 'flash')); + $this->assertNull($View->render(false, 'flash')); $this->PostsController->helpers = array('Session', 'Cache', 'Html'); $this->PostsController->constructClasses(); diff --git a/lib/Cake/View/MediaView.php b/lib/Cake/View/MediaView.php index 7a407dd96..4a7985086 100644 --- a/lib/Cake/View/MediaView.php +++ b/lib/Cake/View/MediaView.php @@ -62,7 +62,7 @@ class MediaView extends View { * * @param string $view Not used * @param string $layout Not used - * @return boolean + * @return void */ public function render($view = null, $layout = null) { $name = $download = $id = $modified = $path = $cache = $mimeType = $compress = null; @@ -94,7 +94,6 @@ class MediaView extends View { $this->response->compress(); } $this->response->send(); - return true; } } diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index f7153bc13..dfc1b4654 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -445,12 +445,12 @@ class View extends Object { * * @param string $view Name of view file to use * @param string $layout Layout to use. - * @return string Rendered Element + * @return string|null Rendered content or null if content already rendered and returned earlier. * @throws CakeException If there is an error in the view. */ public function render($view = null, $layout = null) { if ($this->hasRendered) { - return true; + return; } $this->Blocks->set('content', ''); From ae3c791b6c0361cbce609b9945de3593fe1312bd Mon Sep 17 00:00:00 2001 From: Sam <sgpinkus@gmail.com> Date: Thu, 6 Feb 2014 18:41:37 +1100 Subject: [PATCH 06/12] Minor documentation corrections about Router::connect(). --- lib/Cake/Routing/Router.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index f5ae3847d..7ec7f44f8 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -245,19 +245,19 @@ class Router { * Connects a new Route in the router. * * Routes are a way of connecting request URLs to objects in your application. At their core routes - * are a set or regular expressions that are used to match requests to destinations. + * are a set of regular expressions that are used to match requests to destinations. * * Examples: * * `Router::connect('/:controller/:action/*');` * - * The first parameter will be used as a controller name while the second is used as the action name. + * The first token ':controller' will be used as a controller name while the second is used as the action name. * the '/*' syntax makes this route greedy in that it will match requests like `/posts/index` as well as requests * like `/posts/edit/1/foo/bar`. * * `Router::connect('/home-page', array('controller' => 'pages', 'action' => 'display', 'home'));` * - * The above shows the use of route parameter defaults. And providing routing parameters for a static route. + * The above shows the use of route parameter defaults, and providing routing parameters for a static route. * * {{{ * Router::connect( From 9691e54248fe9457dd1afc94876eef2ed2ba6c59 Mon Sep 17 00:00:00 2001 From: Sam <sgpinkus@gmail.com> Date: Thu, 6 Feb 2014 20:34:02 +1100 Subject: [PATCH 07/12] Minor comments only. Added more explanation of $defaults parameter to Router::connect(). Trying to clarify how it relates to the routing destination and the template string tokens. --- lib/Cake/Routing/Router.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 7ec7f44f8..489e178a3 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -269,6 +269,9 @@ class Router { * * 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. + * + * $defaults is merged with the results of parsing the request URL to form the final routing destination and its + * parameters. This destination is expressed as an associative array by Router. See the output of {@link parse()}. * * $options offers four 'special' keys. `pass`, `named`, `persist` and `routeClass` * have special meaning in the $options array. @@ -304,6 +307,7 @@ class Router { * shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a * custom routing class. * @see routes + * @see parse(). * @return array Array of routes * @throws RouterException */ From 2793dca6710ce1d83d6215e4e63cbee3d15fc394 Mon Sep 17 00:00:00 2001 From: Eric Martins <3ricm2@gmail.com> Date: Fri, 7 Feb 2014 12:45:00 -0200 Subject: [PATCH 08/12] Fix ApiGen errors --- lib/Cake/Console/Command/ServerShell.php | 4 ++ lib/Cake/Console/Command/Task/ExtractTask.php | 1 + lib/Cake/Console/ConsoleOutput.php | 8 +++ lib/Cake/Console/Shell.php | 6 ++ lib/Cake/Controller/Component/Acl/PhpAcl.php | 6 ++ .../Controller/Component/AuthComponent.php | 2 + lib/Cake/Core/App.php | 8 +-- lib/Cake/Core/Object.php | 2 + lib/Cake/Error/ErrorHandler.php | 2 +- .../Model/Datasource/Database/Sqlserver.php | 2 + lib/Cake/Network/Email/CakeEmail.php | 11 ++-- lib/Cake/Routing/Router.php | 35 +++++++++- lib/Cake/Utility/Folder.php | 6 +- lib/Cake/View/Helper/NumberHelper.php | 24 +++++++ lib/Cake/View/Helper/TextHelper.php | 20 ++++++ lib/Cake/View/Helper/TimeHelper.php | 64 +++++++++++++++++++ lib/Cake/View/View.php | 6 ++ lib/Cake/View/ViewBlock.php | 4 +- 18 files changed, 194 insertions(+), 17 deletions(-) diff --git a/lib/Cake/Console/Command/ServerShell.php b/lib/Cake/Console/Command/ServerShell.php index 58f35fe85..7247973c0 100644 --- a/lib/Cake/Console/Command/ServerShell.php +++ b/lib/Cake/Console/Command/ServerShell.php @@ -26,11 +26,15 @@ class ServerShell extends AppShell { /** * Default ServerHost + * + * @var string */ const DEFAULT_HOST = 'localhost'; /** * Default ListenPort + * + * @var integer */ const DEFAULT_PORT = 80; diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index 608e091ee..8180570b5 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -501,6 +501,7 @@ class ExtractTask extends AppShell { * @param array $rules the set of validation rules for the field * @param string $file the file name where this validation rule was found * @param string $domain default domain to bind the validations to + * @param string $category the translation category * @return void */ protected function _processValidationRules($field, $rules, $file, $domain, $category = 'LC_MESSAGES') { diff --git a/lib/Cake/Console/ConsoleOutput.php b/lib/Cake/Console/ConsoleOutput.php index ca4037e3c..fa021b565 100644 --- a/lib/Cake/Console/ConsoleOutput.php +++ b/lib/Cake/Console/ConsoleOutput.php @@ -46,21 +46,29 @@ class ConsoleOutput { /** * Raw output constant - no modification of output text. + * + * @var integer */ const RAW = 0; /** * Plain output - tags will be stripped. + * + * @var integer */ const PLAIN = 1; /** * Color output - Convert known tags in to ANSI color escape codes. + * + * @var integer */ const COLOR = 2; /** * Constant for a newline. + * + * @var string */ const LF = PHP_EOL; diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 7a6bb5af3..d7b1d1ad9 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -33,16 +33,22 @@ class Shell extends Object { /** * Output constant making verbose shells. + * + * @var integer */ const VERBOSE = 2; /** * Output constant for making normal shells. + * + * @var integer */ const NORMAL = 1; /** * Output constants for making quiet shells. + * + * @var integer */ const QUIET = 0; diff --git a/lib/Cake/Controller/Component/Acl/PhpAcl.php b/lib/Cake/Controller/Component/Acl/PhpAcl.php index d9120a9b9..d8f757333 100644 --- a/lib/Cake/Controller/Component/Acl/PhpAcl.php +++ b/lib/Cake/Controller/Component/Acl/PhpAcl.php @@ -26,11 +26,15 @@ class PhpAcl extends Object implements AclInterface { /** * Constant for deny + * + * @var boolean */ const DENY = false; /** * Constant for allow + * + * @var boolean */ const ALLOW = true; @@ -364,6 +368,8 @@ class PhpAro { /** * role to resolve to when a provided ARO is not listed in * the internal tree + * + * @var string */ const DEFAULT_ROLE = 'Role/default'; diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index f2dc7b2ff..42bf84839 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -39,6 +39,8 @@ class AuthComponent extends Component { /** * Constant for 'all' + * + * @var string */ const ALL = 'all'; diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 558de586d..c5674b3ec 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -66,28 +66,28 @@ class App { /** * Append paths * - * @constant APPEND + * @var string */ const APPEND = 'append'; /** * Prepend paths * - * @constant PREPEND + * @var string */ const PREPEND = 'prepend'; /** * Register package * - * @constant REGISTER + * @var string */ const REGISTER = 'register'; /** * Reset paths instead of merging * - * @constant RESET + * @var boolean */ const RESET = true; diff --git a/lib/Cake/Core/Object.php b/lib/Cake/Core/Object.php index 1e35c6ba1..3e3cf9a2e 100644 --- a/lib/Cake/Core/Object.php +++ b/lib/Cake/Core/Object.php @@ -152,6 +152,8 @@ class Object { * * @param string $msg Log message * @param integer $type Error type constant. Defined in app/Config/core.php. + * @param null|string|array $scope The scope(s) a log message is being created in. + * See CakeLog::config() for more information on logging scopes. * @return boolean Success of log write */ public function log($msg, $type = LOG_ERR, $scope = null) { diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index c2672c6b9..3e6eca2a7 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -1,6 +1,6 @@ <?php /** - * Error handler + * ErrorHandler class * * Provides Error Capturing for Framework errors. * diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 4895bb831..d99f8765a 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -103,6 +103,8 @@ class Sqlserver extends DboSource { /** * Magic column name used to provide pagination support for SQLServer 2008 * which lacks proper limit/offset support. + * + * @var string */ const ROW_COUNTER = '_cake_page_rownum_'; diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index bc925d27f..3b54fee86 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -36,35 +36,35 @@ class CakeEmail { /** * Default X-Mailer * - * @constant EMAIL_CLIENT + * @var string */ const EMAIL_CLIENT = 'CakePHP Email'; /** * Line length - no should more - RFC 2822 - 2.1.1 * - * @constant LINE_LENGTH_SHOULD + * @var integer */ const LINE_LENGTH_SHOULD = 78; /** * Line length - no must more - RFC 2822 - 2.1.1 * - * @constant LINE_LENGTH_MUST + * @var integer */ const LINE_LENGTH_MUST = 998; /** * Type of message - HTML * - * @constant MESSAGE_HTML + * @var string */ const MESSAGE_HTML = 'html'; /** * Type of message - TEXT * - * @constant MESSAGE_TEXT + * @var string */ const MESSAGE_TEXT = 'text'; @@ -1308,6 +1308,7 @@ class CakeEmail { * Wrap the message to follow the RFC 2822 - 2.1.1 * * @param string $message Message to wrap + * @param integer $wrapLength The line length * @return array Wrapped message */ protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) { diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 489e178a3..7d8ae9c11 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -85,14 +85,45 @@ class Router { protected static $_validExtensions = array(); /** - * 'Constant' regular expression definitions for named route elements + * Regular expression for action names * + * @var string */ const ACTION = 'index|show|add|create|edit|update|remove|del|delete|view|item'; + +/** + * Regular expression for years + * + * @var string + */ const YEAR = '[12][0-9]{3}'; + +/** + * Regular expression for months + * + * @var string + */ const MONTH = '0[1-9]|1[012]'; + +/** + * Regular expression for days + * + * @var string + */ const DAY = '0[1-9]|[12][0-9]|3[01]'; + +/** + * Regular expression for auto increment IDs + * + * @var string + */ const ID = '[0-9]+'; + +/** + * Regular expression for UUIDs + * + * @var string + */ const UUID = '[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}'; /** @@ -269,7 +300,7 @@ class Router { * * 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. - * + * * $defaults is merged with the results of parsing the request URL to form the final routing destination and its * parameters. This destination is expressed as an associative array by Router. See the output of {@link parse()}. * diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index ca6c4128d..c0da62a54 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -26,7 +26,7 @@ class Folder { * Default scheme for Folder::copy * Recursively merges subfolders with the same name * - * @constant MERGE + * @var string */ const MERGE = 'merge'; @@ -34,7 +34,7 @@ class Folder { * Overwrite scheme for Folder::copy * subfolders with the same name will be replaced * - * @constant OVERWRITE + * @var string */ const OVERWRITE = 'overwrite'; @@ -42,7 +42,7 @@ class Folder { * Skip scheme for Folder::copy * if a subfolder with the same name exists it will be skipped * - * @constant SKIP + * @var string */ const SKIP = 'skip'; diff --git a/lib/Cake/View/Helper/NumberHelper.php b/lib/Cake/View/Helper/NumberHelper.php index b8303f6bc..795d0cc21 100644 --- a/lib/Cake/View/Helper/NumberHelper.php +++ b/lib/Cake/View/Helper/NumberHelper.php @@ -73,6 +73,8 @@ class NumberHelper extends AppHelper { } /** + * Formats a number with a level of precision. + * * @see CakeNumber::precision() * * @param float $number A floating point number. @@ -85,6 +87,8 @@ class NumberHelper extends AppHelper { } /** + * Returns a formatted-for-humans file size. + * * @see CakeNumber::toReadableSize() * * @param integer $size Size in bytes @@ -96,6 +100,8 @@ class NumberHelper extends AppHelper { } /** + * - `multiply`: Multiply the input value by 100 for decimal percentages. + * * @see CakeNumber::toPercentage() * * @param float $number A floating point number @@ -109,6 +115,8 @@ class NumberHelper extends AppHelper { } /** + * Formats a number into a currency format. + * * @see CakeNumber::format() * * @param float $number A floating point number @@ -122,6 +130,8 @@ class NumberHelper extends AppHelper { } /** + * Formats a number into a currency format. + * * @see CakeNumber::currency() * * @param float $number @@ -137,6 +147,18 @@ class NumberHelper extends AppHelper { } /** + * Add a currency format to the Number helper. Makes reusing + * currency formats easier. + * + * {{{ $this->Number->addFormat('NOK', array('before' => 'Kr. ')); }}} + * + * You can now use `NOK` as a shortform when formatting currency amounts. + * + * {{{ $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. + * * @see CakeNumber::addFormat() * * @param string $formatName The format name to be used in the future. @@ -150,6 +172,8 @@ class NumberHelper extends AppHelper { } /** + * Getter/setter for default currency + * * @see CakeNumber::defaultCurrency() * * @param string $currency The currency to be used in the future. diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index a3f07856c..451aa17b6 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -215,6 +215,9 @@ class TextHelper extends AppHelper { } /** + * Highlights a given phrase in a text. You can specify any expression in highlighter that + * may include the \1 expression to include the $phrase found. + * * @see String::highlight() * * @param string $text Text to search the phrase in @@ -251,6 +254,8 @@ class TextHelper extends AppHelper { } /** + * Strips given text of all links (<a href=....) + * * @see String::stripLinks() * * @param string $text Text @@ -262,6 +267,16 @@ class TextHelper extends AppHelper { } /** + * Truncates text starting from the end. + * + * Cuts a string to the length of $length and replaces the first characters + * with the ellipsis if the text is longer than length. + * + * ### Options: + * + * - `ellipsis` Will be used as Beginning and prepended to the trimmed string + * - `exact` If false, $text will not be cut mid-word + * * @see String::truncate() * * @param string $text String to truncate. @@ -275,6 +290,9 @@ class TextHelper extends AppHelper { } /** + * Extracts an excerpt from the text surrounding the phrase with a number of characters on each side + * determined by radius. + * * @see String::excerpt() * * @param string $text String to search the phrase in @@ -289,6 +307,8 @@ class TextHelper extends AppHelper { } /** + * Creates a comma separated list where the last two items are joined with 'and', forming natural English + * * @see String::toList() * * @param array $list The list to be joined diff --git a/lib/Cake/View/Helper/TimeHelper.php b/lib/Cake/View/Helper/TimeHelper.php index 481d82159..dfbfe0778 100644 --- a/lib/Cake/View/Helper/TimeHelper.php +++ b/lib/Cake/View/Helper/TimeHelper.php @@ -122,6 +122,9 @@ class TimeHelper extends AppHelper { } /** + * Converts a string representing the format for the function strftime and returns a + * windows safe and i18n aware format. + * * @see CakeTime::convertSpecifiers() * * @param string $format Format with specifiers for strftime function. @@ -135,6 +138,8 @@ class TimeHelper extends AppHelper { } /** + * Converts given time (in server's time zone) to user's local time, given his/her timezone. + * * @see CakeTime::convert() * * @param string $serverTime UNIX timestamp @@ -147,6 +152,8 @@ class TimeHelper extends AppHelper { } /** + * Returns server's offset + * * @see CakeTime::serverOffset() * * @return integer Offset @@ -157,6 +164,8 @@ class TimeHelper extends AppHelper { } /** + * Returns a UNIX timestamp, given either a UNIX timestamp or a valid strtotime() date string. + * * @see CakeTime::fromString() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -169,6 +178,8 @@ class TimeHelper extends AppHelper { } /** + * Returns a nicely formatted date string for given Datetime string. + * * @see CakeTime::nice() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -182,6 +193,8 @@ class TimeHelper extends AppHelper { } /** + * Returns a formatted descriptive date string for given datetime string. + * * @see CakeTime::niceShort() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime objectp @@ -194,6 +207,8 @@ class TimeHelper extends AppHelper { } /** + * Returns a partial SQL string to search for all records between two dates. + * * @see CakeTime::daysAsSql() * * @param integer|string|DateTime $begin UNIX timestamp, strtotime() valid string or DateTime object @@ -208,6 +223,9 @@ class TimeHelper extends AppHelper { } /** + * Returns a partial SQL string to search for all records between two times + * occurring on the same day. + * * @see CakeTime::dayAsSql() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -221,6 +239,8 @@ class TimeHelper extends AppHelper { } /** + * Returns true if given datetime string is today. + * * @see CakeTime::isToday() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -233,6 +253,8 @@ class TimeHelper extends AppHelper { } /** + * Returns true if given datetime string is within this week. + * * @see CakeTime::isThisWeek() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -245,6 +267,8 @@ class TimeHelper extends AppHelper { } /** + * Returns true if given datetime string is within this month + * * @see CakeTime::isThisMonth() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -257,6 +281,8 @@ class TimeHelper extends AppHelper { } /** + * Returns true if given datetime string is within current year. + * * @see CakeTime::isThisYear() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -269,6 +295,8 @@ class TimeHelper extends AppHelper { } /** + * Returns true if given datetime string was yesterday. + * * @see CakeTime::wasYesterday() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -282,6 +310,8 @@ class TimeHelper extends AppHelper { } /** + * Returns true if given datetime string is tomorrow. + * * @see CakeTime::isTomorrow() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -294,6 +324,8 @@ class TimeHelper extends AppHelper { } /** + * Returns the quarter + * * @see CakeTime::toQuarter() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -306,6 +338,8 @@ class TimeHelper extends AppHelper { } /** + * Returns a UNIX timestamp from a textual datetime description. Wrapper for PHP function strtotime(). + * * @see CakeTime::toUnix() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -318,6 +352,8 @@ class TimeHelper extends AppHelper { } /** + * Returns a date formatted for Atom RSS feeds. + * * @see CakeTime::toAtom() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -330,6 +366,8 @@ class TimeHelper extends AppHelper { } /** + * Formats date for RSS feeds + * * @see CakeTime::toRSS() * * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object @@ -342,6 +380,8 @@ class TimeHelper extends AppHelper { } /** + * Formats date for RSS feeds + * * @see CakeTime::timeAgoInWords() * * ## Addition options @@ -389,6 +429,8 @@ class TimeHelper extends AppHelper { } /** + * Returns true if specified datetime was within the interval specified, else false. + * * @see CakeTime::wasWithinLast() * * @param string|integer $timeInterval the numeric value with space then time type. @@ -403,6 +445,8 @@ class TimeHelper extends AppHelper { } /** + * Returns true if specified datetime is within the interval specified, else false. + * * @see CakeTime::isWithinLast() * * @param string|integer $timeInterval the numeric value with space then time type. @@ -417,6 +461,8 @@ class TimeHelper extends AppHelper { } /** + * Returns gmt as a UNIX timestamp. + * * @see CakeTime::gmt() * * @param integer|string|DateTime $string UNIX timestamp, strtotime() valid string or DateTime object @@ -428,6 +474,21 @@ class TimeHelper extends AppHelper { } /** + * Returns a formatted date string, given either a UNIX timestamp or a valid strtotime() date string. + * This function also accepts a time string and a format string as first and second parameters. + * In that case this function behaves as a wrapper for TimeHelper::i18nFormat() + * + * ## Examples + * + * 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 + * }}} + * * @see CakeTime::format() * * @param integer|string|DateTime $format date format string (or a UNIX timestamp, strtotime() valid string or DateTime object) @@ -442,6 +503,9 @@ class TimeHelper extends AppHelper { } /** + * Returns a formatted date string, given either a UNIX timestamp or a valid strtotime() date string. + * It takes into account the default date format for the current language if a LC_TIME file is used. + * * @see CakeTime::i18nFormat() * * @param integer|string|DateTime $date UNIX timestamp, strtotime() valid string or DateTime object diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index dfc1b4654..d6d7a9108 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -299,16 +299,22 @@ class View extends Object { /** * Constant for view file type 'view' + * + * @var string */ const TYPE_VIEW = 'view'; /** * Constant for view file type 'element' + * + * @var string */ const TYPE_ELEMENT = 'element'; /** * Constant for view file type 'layout' + * + * @var string */ const TYPE_LAYOUT = 'layout'; diff --git a/lib/Cake/View/ViewBlock.php b/lib/Cake/View/ViewBlock.php index f0c74c5ca..28667c8c3 100644 --- a/lib/Cake/View/ViewBlock.php +++ b/lib/Cake/View/ViewBlock.php @@ -28,14 +28,14 @@ class ViewBlock { /** * Append content * - * @constant APPEND + * @var string */ const APPEND = 'append'; /** * Prepend content * - * @constant PREPEND + * @var string */ const PREPEND = 'prepend'; From 7fd13d406c9506def92708ad0b230fea5c04d6c5 Mon Sep 17 00:00:00 2001 From: Sam <sgpinkus@gmail.com> Date: Mon, 10 Feb 2014 01:38:32 +1100 Subject: [PATCH 09/12] Fixed prefixed action prefix reverse routing match. One liner. --- lib/Cake/Routing/Route/CakeRoute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Routing/Route/CakeRoute.php b/lib/Cake/Routing/Route/CakeRoute.php index bab5c23a5..43a3fd168 100644 --- a/lib/Cake/Routing/Route/CakeRoute.php +++ b/lib/Cake/Routing/Route/CakeRoute.php @@ -490,7 +490,7 @@ class CakeRoute { $prefixed = $params['prefix'] . '_'; } if (isset($prefixed, $params['action']) && strpos($params['action'], $prefixed) === 0) { - $params['action'] = substr($params['action'], strlen($prefixed) * -1); + $params['action'] = substr($params['action'], strlen($prefixed) ); unset($params['prefix']); } From a9059d4a4f5b9e8a9e5861f21eb672eb68ff770e Mon Sep 17 00:00:00 2001 From: Sam <sgpinkus@gmail.com> Date: Mon, 10 Feb 2014 02:02:41 +1100 Subject: [PATCH 10/12] Fix formatting - one space too much. Refs #2799. --- lib/Cake/Routing/Route/CakeRoute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Routing/Route/CakeRoute.php b/lib/Cake/Routing/Route/CakeRoute.php index 43a3fd168..cc9b0ff73 100644 --- a/lib/Cake/Routing/Route/CakeRoute.php +++ b/lib/Cake/Routing/Route/CakeRoute.php @@ -490,7 +490,7 @@ class CakeRoute { $prefixed = $params['prefix'] . '_'; } if (isset($prefixed, $params['action']) && strpos($params['action'], $prefixed) === 0) { - $params['action'] = substr($params['action'], strlen($prefixed) ); + $params['action'] = substr($params['action'], strlen($prefixed)); unset($params['prefix']); } From f3cd0fc8082ea43754483b6a47a2a1597f03f12b Mon Sep 17 00:00:00 2001 From: Sam <sgpinkus@gmail.com> Date: Mon, 10 Feb 2014 02:20:00 +1100 Subject: [PATCH 11/12] Test added for previous fix in CakeRoute.php. Refs #2797. --- lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php index 32dbed19d..c0995dc8f 100644 --- a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php @@ -308,6 +308,11 @@ class CakeRouteTest extends CakeTestCase { $result = $route->match($url); $expected = '/admin/subscriptions/edit_admin_e/1'; $this->assertEquals($expected, $result); + + $url = array('controller' => 'subscribe', 'admin' => true, 'action' => 'admin_edit', 1); + $result = $route->match($url); + $expected = '/admin/subscriptions/edit/1'; + $this->assertEquals($expected, $result); } /** From 91349c306e9f6f629235dbc12f472178f2df191d Mon Sep 17 00:00:00 2001 From: mark_story <mark@mark-story.com> Date: Sun, 9 Feb 2014 16:03:37 -0500 Subject: [PATCH 12/12] Remove trailing whitespace. Refs #2799 --- lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php index c0995dc8f..1f0e283ca 100644 --- a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php @@ -308,7 +308,7 @@ class CakeRouteTest extends CakeTestCase { $result = $route->match($url); $expected = '/admin/subscriptions/edit_admin_e/1'; $this->assertEquals($expected, $result); - + $url = array('controller' => 'subscribe', 'admin' => true, 'action' => 'admin_edit', 1); $result = $route->match($url); $expected = '/admin/subscriptions/edit/1';