diff --git a/cake/basics.php b/cake/basics.php index 0df4069e4..e58eec6e6 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -98,7 +98,7 @@ if (!function_exists('clone')) { * @param boolean $var Variable to show debug information for. * @param boolean $showHtml If set to true, the method prints the debug data in a screen-friendly way. * @param boolean $showFrom If set to true, the method prints from where the function was called. - * @link http://book.cakephp.org/view/458/Basic-Debugging + * @link http://book.cakephp.org/view/1190/Basic-Debugging */ function debug($var = false, $showHtml = false, $showFrom = true) { if (Configure::read() > 0) { @@ -198,7 +198,7 @@ if (!function_exists('array_combine')) { * @param string $text Text to wrap through htmlspecialchars * @param string $charset Character set to use when escaping. Defaults to config value in 'App.encoding' or 'UTF-8' * @return string Wrapped text - * @link http://book.cakephp.org/view/703/h + * @link http://book.cakephp.org/view/1132/h */ function h($text, $charset = null) { if (is_array($text)) { @@ -253,7 +253,7 @@ if (!function_exists('array_combine')) { * `array('a', 'b')` * * @return array Array of given parameters - * @link http://book.cakephp.org/view/694/a + * @link http://book.cakephp.org/view/1122/a * @deprecated Will be removed in 2.0 */ function a() { @@ -273,7 +273,7 @@ if (!function_exists('array_combine')) { * `array('a'=>'b')` * * @return array Associative array - * @link http://book.cakephp.org/view/695/aa + * @link http://book.cakephp.org/view/1123/aa * @deprecated Will be removed in 2.0 */ function aa() { @@ -294,7 +294,7 @@ if (!function_exists('array_combine')) { * Convenience method for echo(). * * @param string $text String to echo - * @link http://book.cakephp.org/view/700/e + * @link http://book.cakephp.org/view/1129/e * @deprecated Will be removed in 2.0 */ function e($text) { @@ -306,7 +306,7 @@ if (!function_exists('array_combine')) { * * @param string $str String to lowercase * @return string Lowercased string - * @link http://book.cakephp.org/view/705/low + * @link http://book.cakephp.org/view/1134/low * @deprecated Will be removed in 2.0 */ function low($str) { @@ -318,7 +318,7 @@ if (!function_exists('array_combine')) { * * @param string $str String to uppercase * @return string Uppercased string - * @link http://book.cakephp.org/view/710/up + * @link http://book.cakephp.org/view/1139/up * @deprecated Will be removed in 2.0 */ function up($str) { @@ -332,7 +332,7 @@ if (!function_exists('array_combine')) { * @param string $replace String to insert * @param string $subject String to search * @return string Replaced string - * @link http://book.cakephp.org/view/708/r + * @link http://book.cakephp.org/view/1137/r * @deprecated Will be removed in 2.0 */ function r($search, $replace, $subject) { @@ -345,7 +345,7 @@ if (!function_exists('array_combine')) { * * @see debug() * @param array $var Variable to print out - * @link http://book.cakephp.org/view/707/pr + * @link http://book.cakephp.org/view/1136/pr */ function pr($var) { if (Configure::read() > 0) { @@ -380,7 +380,7 @@ if (!function_exists('array_combine')) { * @param array Third array * @param array Etc... * @return array All array parameters merged into one - * @link http://book.cakephp.org/view/696/am + * @link http://book.cakephp.org/view/1124/am */ function am() { $r = array(); @@ -402,7 +402,7 @@ if (!function_exists('array_combine')) { * * @param string $key Environment variable name. * @return string Environment variable setting. - * @link http://book.cakephp.org/view/701/env + * @link http://book.cakephp.org/view/1130/env */ function env($key) { if ($key == 'HTTPS') { @@ -619,7 +619,7 @@ if (!function_exists('file_put_contents')) { * * @param array $values Array of values to strip slashes * @return mixed What is returned from calling stripslashes - * @link http://book.cakephp.org/view/709/stripslashes_deep + * @link http://book.cakephp.org/view/1138/stripslashes_deep */ function stripslashes_deep($values) { if (is_array($values)) { @@ -638,7 +638,7 @@ if (!function_exists('file_put_contents')) { * @param string $singular Text to translate * @param boolean $return Set to true to return translated string, or false to echo * @return mixed translated string if $return is false string will be echoed - * @link http://book.cakephp.org/view/693/__ + * @link http://book.cakephp.org/view/1121/__ */ function __($singular, $return = false) { if (!$singular) { @@ -919,7 +919,7 @@ if (!function_exists('file_put_contents')) { * * @param string $file File to look for * @return Full path to file if exists, otherwise false - * @link http://book.cakephp.org/view/702/fileExistsInPath + * @link http://book.cakephp.org/view/1131/fileExistsInPath */ function fileExistsInPath($file) { $paths = explode(PATH_SEPARATOR, ini_get('include_path')); @@ -940,7 +940,7 @@ if (!function_exists('file_put_contents')) { * * @param string String to convert * @return string with underscore remove from start and end of string - * @link http://book.cakephp.org/view/697/convertSlash + * @link http://book.cakephp.org/view/1126/convertSlash */ function convertSlash($string) { $string = trim($string, '/'); @@ -1001,7 +1001,7 @@ if (!function_exists('file_put_contents')) { * @param mixed $val1 Value to return in case condition matches * @param mixed $val2 Value to return if condition doesn't match * @return mixed $val1 or $val2, depending on whether $condition evaluates to a non-empty expression. - * @link http://book.cakephp.org/view/704/ife + * @link http://book.cakephp.org/view/1133/ife * @deprecated Will be removed in 2.0 */ function ife($condition, $val1 = null, $val2 = null) { diff --git a/cake/dispatcher.php b/cake/dispatcher.php index f3edc7050..d04826593 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -82,7 +82,8 @@ class Dispatcher extends Object { } /** - * Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set). + * Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the + * results (if autoRender is set). * * If no controller of given name can be found, invoke() shows error messages in * the form of Missing Controllers information. It does the same with Actions (methods of Controllers are called @@ -171,8 +172,9 @@ class Dispatcher extends Object { } /** - * Invokes given controller's render action if autoRender option is set. Otherwise the - * contents of the operation are returned as a string. + * Initializes the components and models a controller will be using. + * Triggers the controller action, and invokes the rendering if Controller::$autoRender is true and echo's the output. + * Otherwise the return value of the controller action are returned. * * @param object $controller Controller to invoke * @param array $params Parameters with at least the 'action' to invoke @@ -216,10 +218,11 @@ class Dispatcher extends Object { /** * Sets the params when $url is passed as an array to Object::requestAction(); + * Merges the $url and $additionalParams and creates a string url. * - * @param array $url - * @param array $additionalParams - * @return string $url + * @param array $url Array or request parameters + * @param array $additionalParams Array of additional parameters. + * @return string $url The generated url string. * @access private */ function __extractParams($url, $additionalParams = array()) { @@ -414,7 +417,10 @@ class Dispatcher extends Object { $name = $ctrlClass; $ctrlClass .= 'Controller'; if (class_exists($ctrlClass)) { - if (empty($params['plugin']) && strtolower(get_parent_class($ctrlClass)) === strtolower($name . 'AppController')) { + if ( + empty($params['plugin']) && + strtolower(get_parent_class($ctrlClass)) === strtolower($name . 'AppController') + ) { $params = $this->_restructureParams($params); } $this->params = $params; @@ -424,7 +430,7 @@ class Dispatcher extends Object { } /** - * Load controller and return controller class + * Load controller and return controller classname * * @param array $params Array of parameters * @return string|bool Name of controller class name @@ -580,7 +586,6 @@ class Dispatcher extends Object { return $return; } } - return false; } diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index b76b9f050..f2cfcce9c 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -32,7 +32,7 @@ App::import('View', 'View', false); * * @package cake * @subpackage cake.cake.libs.controller - * @link http://book.cakephp.org/view/49/Controllers + * @link http://book.cakephp.org/view/956/Introduction */ class Controller extends Object { @@ -41,7 +41,7 @@ class Controller extends Object { * * @var string * @access public - * @link http://book.cakephp.org/view/52/name + * @link http://book.cakephp.org/view/959/Controller-Attributes */ var $name = null; @@ -72,14 +72,14 @@ class Controller extends Object { /** * An array containing the class names of models this controller uses. * - * Example: var $uses = array('Product', 'Post', 'Comment'); + * Example: `var $uses = array('Product', 'Post', 'Comment');` * * Can be set to array() to use no models. Can be set to false to * use no models and prevent the merging of $uses with AppController * * @var mixed A single name as a string or a list of names as an array. * @access protected - * @link http://book.cakephp.org/view/53/components-helpers-and-uses + * @link http://book.cakephp.org/view/961/components-helpers-and-uses */ var $uses = false; @@ -87,11 +87,11 @@ class Controller extends Object { * An array containing the names of helpers this controller uses. The array elements should * not contain the "Helper" part of the classname. * - * Example: var $helpers = array('Html', 'Javascript', 'Time', 'Ajax'); + * Example: `var $helpers = array('Html', 'Javascript', 'Time', 'Ajax');` * * @var mixed A single name as a string or a list of names as an array. * @access protected - * @link http://book.cakephp.org/view/53/components-helpers-and-uses + * @link http://book.cakephp.org/view/961/components-helpers-and-uses */ var $helpers = array('Session', 'Html', 'Form'); @@ -101,13 +101,13 @@ class Controller extends Object { * * @var array * @access public - * @link http://book.cakephp.org/view/55/The-Parameters-Attribute-params + * @link http://book.cakephp.org/view/963/The-Parameters-Attribute-params */ var $params = array(); /** * Data POSTed to the controller using the HtmlHelper. Data here is accessible - * using the $this->data['ModelName']['fieldName'] pattern. + * using the `$this->data['ModelName']['fieldName']` pattern. * * @var array * @access public @@ -122,14 +122,16 @@ class Controller extends Object { * Pagination defaults can also be supplied in a model-by-model basis by using * the name of the model as a key for a pagination array: * + * {{{ * var $paginate = array( * 'Post' => array(...), * 'Comment' => array(...) * ); + * }}} * * @var array * @access public - * @link http://book.cakephp.org/view/164/Pagination + * @link http://book.cakephp.org/view/1231/Pagination */ var $paginate = array('limit' => 20, 'page' => 1); @@ -157,16 +159,6 @@ class Controller extends Object { */ var $viewVars = array(); -/** - * Text to be used for the $title_for_layout layout variable (usually - * placed inside tags.) - * - * @var boolean - * @access public - * @link http://book.cakephp.org/view/54/Page-related-Attributes-layout-and-pageTitle - */ - var $pageTitle = false; - /** * An array containing the class names of the models this controller uses. * @@ -190,7 +182,7 @@ class Controller extends Object { * * @var string * @access public - * @link http://book.cakephp.org/view/54/Page-related-Attributes-layout-and-pageTitle + * @link http://book.cakephp.org/view/962/Page-related-Attributes-layout-and-pageTitle */ var $layout = 'default'; @@ -223,11 +215,11 @@ class Controller extends Object { * Array containing the names of components this controller uses. Component names * should not contain the "Component" portion of the classname. * - * Example: var $components = array('Session', 'RequestHandler', 'Acl'); + * Example: `var $components = array('Session', 'RequestHandler', 'Acl');` * * @var array * @access public - * @link http://book.cakephp.org/view/53/components-helpers-and-uses + * @link http://book.cakephp.org/view/961/components-helpers-and-uses */ var $components = array('Session'); @@ -270,17 +262,21 @@ class Controller extends Object { * single action, the value is set to an array containing keys that match * action names and values that denote cache expiration times (in seconds). * - * Example: var $cacheAction = array( + * Example: + * + * {{{ + * var $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. * * @var mixed * @access public - * @link http://book.cakephp.org/view/346/Caching-in-the-Controller + * @link http://book.cakephp.org/view/1380/Caching-in-the-Controller */ var $cacheAction = false; @@ -307,7 +303,7 @@ class Controller extends Object { * * @var mixed * @access public - * @link http://book.cakephp.org/view/105/Scaffolding + * @link http://book.cakephp.org/view/1103/Scaffolding */ var $scaffold = false; @@ -484,7 +480,7 @@ class Controller extends Object { * @return mixed true if models found and instance created, or cakeError if models not found. * @access public * @see Controller::loadModel() - * @link http://book.cakephp.org/view/429/constructClasses + * @link http://book.cakephp.org/view/977/Controller-Methods#constructClasses-986 */ function constructClasses() { $this->__mergeVars(); @@ -562,7 +558,7 @@ class Controller extends Object { * )); // sets these new values, and returns true * * @return mixed Associative array of the HTTP codes as keys, and the message - * strings as values, or null of the given $code does not exist. + * strings as values, or null of the given $code does not exist. */ function httpCodes($code = null) { if (empty($this->__httpCodes)) { @@ -604,7 +600,7 @@ class Controller extends Object { /** * Loads and instantiates models required by this controller. - * If Controller::persistModel; is true, controller will cache model instances on first request, + * If Controller::$persistModel; is true, controller will cache model instances on first request, * additional request will used cached models. * If the model is non existent, it will throw a missing database table error, as Cake generates * dynamic models for the time being. @@ -668,12 +664,12 @@ class Controller extends Object { * Script execution is halted after the redirect. * * @param mixed $url A string or array-based URL pointing to another location within the app, - * or an absolute URL + * or an absolute URL * @param integer $status Optional HTTP status code (eg: 404) * @param boolean $exit If true, exit() will be called after the redirect * @return mixed void if $exit = false. Terminates script if $exit = true * @access public - * @link http://book.cakephp.org/view/425/redirect + * @link http://book.cakephp.org/view/982/redirect */ function redirect($url, $status = null, $exit = true) { $this->autoRender = false; @@ -737,9 +733,10 @@ class Controller extends Object { } /** - * Convenience method for header() + * Convenience and object wrapper method for header(). Useful when doing tests and + * asserting that particular headers have been set. * - * @param string $status + * @param string $status The header message that is being set. * @return void * @access public */ @@ -755,7 +752,7 @@ class Controller extends Object { * Unused if $one is an associative array, otherwise serves as the values to $one's keys. * @return void * @access public - * @link http://book.cakephp.org/view/427/set + * @link http://book.cakephp.org/view/979/set */ function set($one, $two = null) { $data = array(); @@ -773,14 +770,18 @@ class Controller extends Object { } /** - * Internally redirects one action to another. Examples: + * Internally redirects one action to another. Does not perform another HTTP request unlike Controller::redirect() * + * Examples: + * + * {{{ * setAction('another_action'); * setAction('action_with_parameters', $parameter1); + * }}} * - * @param string $action The new action to be redirected to + * @param string $action The new action to be 'redirected' to * @param mixed Any other parameters passed to this method will be passed as - * parameters to the new action. + * parameters to the new action. * @return mixed Returns the return value of the called action * @access public */ @@ -793,11 +794,11 @@ class Controller extends Object { /** * Controller callback to tie into Auth component. - * Only called when AuthComponent::authorize is set to 'controller'. + * Only called when AuthComponent::$authorize is set to 'controller'. * * @return bool true if authorized, false otherwise * @access public - * @link http://book.cakephp.org/view/396/authorize + * @link http://book.cakephp.org/view/1275/authorize */ function isAuthorized() { trigger_error(sprintf( @@ -825,7 +826,7 @@ class Controller extends Object { /** * Validates models passed by parameters. Example: * - * $errors = $this->validateErrors($this->Article, $this->User); + * `$errors = $this->validateErrors($this->Article, $this->User);` * * @param mixed A list of models as a variable argument * @return array Validation errors, or false if none @@ -855,7 +856,7 @@ class Controller extends Object { * @param string $file File to use for rendering * @return string Full output string of view contents * @access public - * @link http://book.cakephp.org/view/428/render + * @link http://book.cakephp.org/view/980/render */ function render($action = null, $layout = null, $file = null) { $this->beforeRender(); @@ -917,7 +918,7 @@ class Controller extends Object { * @param boolean $local If true, restrict referring URLs to local server * @return string Referring URL * @access public - * @link http://book.cakephp.org/view/430/referer + * @link http://book.cakephp.org/view/987/referer */ function referer($default = null, $local = false) { $ref = env('HTTP_REFERER'); @@ -946,7 +947,7 @@ class Controller extends Object { * * @return void * @access public - * @link http://book.cakephp.org/view/431/disableCache + * @link http://book.cakephp.org/view/988/disableCache */ function disableCache() { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); @@ -967,7 +968,7 @@ class Controller extends Object { * @param string $layout Layout you want to use, defaults to 'flash' * @return void Renders flash layout * @access public - * @link http://book.cakephp.org/view/426/flash + * @link http://book.cakephp.org/view/983/flash */ function flash($message, $url, $pause = 1, $layout = 'flash') { $this->autoRender = false; @@ -989,7 +990,7 @@ class Controller extends Object { * included in the returned conditions * @return array An array of model conditions * @access public - * @link http://book.cakephp.org/view/432/postConditions + * @link http://book.cakephp.org/view/989/postConditions */ function postConditions($data = array(), $op = null, $bool = 'AND', $exclusive = false) { if (!is_array($data) || empty($data)) { @@ -1046,7 +1047,7 @@ class Controller extends Object { * @param array $whitelist List of allowed options for paging * @return array Model query results * @access public - * @link http://book.cakephp.org/view/165/Controller-Setup + * @link http://book.cakephp.org/view/1232/Controller-Setup */ function paginate($object = null, $scope = array(), $whitelist = array()) { if (is_array($object)) { @@ -1244,7 +1245,7 @@ class Controller extends Object { * Called before the controller action. * * @access public - * @link http://book.cakephp.org/view/60/Callbacks + * @link http://book.cakephp.org/view/984/Callbacks */ function beforeFilter() { } @@ -1253,7 +1254,7 @@ class Controller extends Object { * Called after the controller action is run, but before the view is rendered. * * @access public - * @link http://book.cakephp.org/view/60/Callbacks + * @link http://book.cakephp.org/view/984/Callbacks */ function beforeRender() { } @@ -1262,7 +1263,7 @@ class Controller extends Object { * Called after the controller action is run and rendered. * * @access public - * @link http://book.cakephp.org/view/60/Callbacks + * @link http://book.cakephp.org/view/984/Callbacks */ function afterFilter() { } @@ -1273,7 +1274,7 @@ class Controller extends Object { * @param string $method name of method called example index, edit, etc. * @return boolean Success * @access protected - * @link http://book.cakephp.org/view/60/Callbacks + * @link http://book.cakephp.org/view/984/Callbacks */ function _beforeScaffold($method) { return true; @@ -1285,7 +1286,7 @@ class Controller extends Object { * @param string $method name of method called either edit or update. * @return boolean Success * @access protected - * @link http://book.cakephp.org/view/60/Callbacks + * @link http://book.cakephp.org/view/984/Callbacks */ function _afterScaffoldSave($method) { return true; @@ -1297,7 +1298,7 @@ class Controller extends Object { * @param string $method name of method called either edit or update. * @return boolean Success * @access protected - * @link http://book.cakephp.org/view/60/Callbacks + * @link http://book.cakephp.org/view/984/Callbacks */ function _afterScaffoldSaveError($method) { return true; @@ -1311,7 +1312,7 @@ class Controller extends Object { * @param string $method name of method called example index, edit, etc. * @return boolean Success * @access protected - * @link http://book.cakephp.org/view/60/Callbacks + * @link http://book.cakephp.org/view/984/Callbacks */ function _scaffoldError($method) { return false;