mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-05 15:43:53 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -1,16 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Controller
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('CakeResponse', 'Network');
|
||||
|
@ -26,20 +27,20 @@ App::uses('CakeEventManager', 'Event');
|
|||
* Provides basic functionality, such as rendering views inside layouts,
|
||||
* automatic model availability, redirection, callbacks, and more.
|
||||
*
|
||||
* Controllers should provide a number of 'action' methods. These are public methods on the controller
|
||||
* that are not prefixed with a '_' and not part of Controller. Each action serves as an endpoint for
|
||||
* performing a specific action on a resource or collection of resources. For example adding or editing a new
|
||||
* Controllers should provide a number of 'action' methods. These are public methods on the controller
|
||||
* that are not prefixed with a '_' and not part of Controller. Each action serves as an endpoint for
|
||||
* performing a specific action on a resource or collection of resources. For example: adding or editing a new
|
||||
* object, or listing a set of objects.
|
||||
*
|
||||
* You can access request parameters, using `$this->request`. The request object contains all the POST, GET and FILES
|
||||
* You can access request parameters, using `$this->request`. The request object contains all the POST, GET and FILES
|
||||
* that were part of the request.
|
||||
*
|
||||
* After performing the required actions, controllers are responsible for creating a response. This usually
|
||||
* takes the form of a generated View, or possibly a redirection to another controller action. In either case
|
||||
* After performing the required actions, controllers are responsible for creating a response. This usually
|
||||
* takes the form of a generated View, or possibly a redirection to another controller action. In either case
|
||||
* `$this->response` allows you to manipulate all aspects of the response.
|
||||
*
|
||||
* Controllers are created by Dispatcher based on request parameters and routing. By default controllers and actions
|
||||
* use conventional names. For example `/posts/index` maps to `PostsController::index()`. You can re-map urls
|
||||
* use conventional names. For example `/posts/index` maps to `PostsController::index()`. You can re-map URLs
|
||||
* using Router::connect().
|
||||
*
|
||||
* @package Cake.Controller
|
||||
|
@ -51,9 +52,10 @@ App::uses('CakeEventManager', 'Event');
|
|||
* @property RequestHandlerComponent $RequestHandler
|
||||
* @property SecurityComponent $Security
|
||||
* @property SessionComponent $Session
|
||||
* @property FlashComponent $Flash
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html
|
||||
*/
|
||||
class Controller extends Object implements CakeEventListener {
|
||||
class Controller extends CakeObject implements CakeEventListener {
|
||||
|
||||
/**
|
||||
* The name of this controller. Controller names are plural, named after the model they manipulate.
|
||||
|
@ -78,18 +80,18 @@ class Controller extends Object implements CakeEventListener {
|
|||
*
|
||||
* The default value is `true`.
|
||||
*
|
||||
* @var mixed A single name as a string or a list of names as an array.
|
||||
* @var mixed
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#components-helpers-and-uses
|
||||
*/
|
||||
public $uses = true;
|
||||
|
||||
/**
|
||||
* An array containing the names of helpers this controller uses. The array elements should
|
||||
* not contain the "Helper" part of the classname.
|
||||
* not contain the "Helper" part of the class name.
|
||||
*
|
||||
* Example: `public $helpers = array('Html', 'Javascript', 'Time', 'Ajax');`
|
||||
* Example: `public $helpers = array('Html', 'Js', 'Time', 'Ajax');`
|
||||
*
|
||||
* @var mixed A single name as a string or a list of names as an array.
|
||||
* @var mixed
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#components-helpers-and-uses
|
||||
*/
|
||||
public $helpers = array();
|
||||
|
@ -113,7 +115,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
public $response;
|
||||
|
||||
/**
|
||||
* The classname to use for creating the response object.
|
||||
* The class name to use for creating the response object.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@ -161,14 +163,14 @@ class Controller extends Object implements CakeEventListener {
|
|||
* Set to true to automatically render the view
|
||||
* after action logic.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
public $autoRender = true;
|
||||
|
||||
/**
|
||||
* Set to true to automatically render the layout around views.
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
public $autoLayout = true;
|
||||
|
||||
|
@ -181,14 +183,14 @@ class Controller extends Object implements CakeEventListener {
|
|||
|
||||
/**
|
||||
* Array containing the names of components this controller uses. Component names
|
||||
* should not contain the "Component" portion of the classname.
|
||||
* should not contain the "Component" portion of the class name.
|
||||
*
|
||||
* Example: `public $components = array('Session', 'RequestHandler', 'Acl');`
|
||||
*
|
||||
* @var array
|
||||
* @link http://book.cakephp.org/2.0/en/controllers/components.html
|
||||
*/
|
||||
public $components = array('Session');
|
||||
public $components = array('Session', 'Flash');
|
||||
|
||||
/**
|
||||
* The name of the View class this controller sends output to.
|
||||
|
@ -206,7 +208,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
public $View;
|
||||
|
||||
/**
|
||||
* File extension for view templates. Defaults to Cake's conventional ".ctp".
|
||||
* File extension for view templates. Defaults to CakePHP's conventional ".ctp".
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@ -226,12 +228,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.
|
||||
|
@ -258,7 +260,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
|
||||
/**
|
||||
* Holds current methods of the controller. This is a list of all the methods reachable
|
||||
* via url. Modifying this array, will allow you to change which methods can be reached.
|
||||
* via URL. Modifying this array will allow you to change which methods can be reached.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
|
@ -284,9 +286,9 @@ class Controller extends Object implements CakeEventListener {
|
|||
public $modelKey = null;
|
||||
|
||||
/**
|
||||
* Holds any validation errors produced by the last call of the validateErrors() method/
|
||||
* Holds any validation errors produced by the last call of the validateErrors() method.
|
||||
*
|
||||
* @var array Validation errors, or false if none
|
||||
* @var array
|
||||
*/
|
||||
public $validationErrors = null;
|
||||
|
||||
|
@ -319,7 +321,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
$this->name = substr(get_class($this), 0, -10);
|
||||
}
|
||||
|
||||
if ($this->viewPath == null) {
|
||||
if (!$this->viewPath) {
|
||||
$this->viewPath = $this->name;
|
||||
}
|
||||
|
||||
|
@ -345,8 +347,8 @@ class Controller extends Object implements CakeEventListener {
|
|||
* Provides backwards compatibility to avoid problems with empty and isset to alias properties.
|
||||
* Lazy loads models using the loadModel() method if declared in $uses
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
* @param string $name Property name to check.
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($name) {
|
||||
switch ($name) {
|
||||
|
@ -383,8 +385,8 @@ class Controller extends Object implements CakeEventListener {
|
|||
* Provides backwards compatibility access to the request object properties.
|
||||
* Also provides the params alias.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
* @param string $name The name of the requested value
|
||||
* @return mixed The requested value for valid variables/aliases else null
|
||||
*/
|
||||
public function __get($name) {
|
||||
switch ($name) {
|
||||
|
@ -411,8 +413,8 @@ class Controller extends Object implements CakeEventListener {
|
|||
/**
|
||||
* Provides backwards compatibility access for setting values to the request object.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param string $name Property name to set.
|
||||
* @param mixed $value Value to set.
|
||||
* @return void
|
||||
*/
|
||||
public function __set($name, $value) {
|
||||
|
@ -421,20 +423,24 @@ class Controller extends Object implements CakeEventListener {
|
|||
case 'here':
|
||||
case 'webroot':
|
||||
case 'data':
|
||||
return $this->request->{$name} = $value;
|
||||
$this->request->{$name} = $value;
|
||||
return;
|
||||
case 'action':
|
||||
return $this->request->params['action'] = $value;
|
||||
$this->request->params['action'] = $value;
|
||||
return;
|
||||
case 'params':
|
||||
return $this->request->params = $value;
|
||||
$this->request->params = $value;
|
||||
return;
|
||||
case 'paginate':
|
||||
return $this->Components->load('Paginator')->settings = $value;
|
||||
$this->Components->load('Paginator')->settings = $value;
|
||||
return;
|
||||
}
|
||||
return $this->{$name} = $value;
|
||||
$this->{$name} = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the request objects and configures a number of controller properties
|
||||
* based on the contents of the request. The properties that get set are
|
||||
* based on the contents of the request. The properties that get set are
|
||||
*
|
||||
* - $this->request - To the $request parameter
|
||||
* - $this->plugin - To the $request->params['plugin']
|
||||
|
@ -443,7 +449,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
* - $this->autoRender - To false if $request->params['return'] == 1
|
||||
* - $this->passedArgs - The the combined results of params['named'] and params['pass]
|
||||
*
|
||||
* @param CakeRequest $request
|
||||
* @param CakeRequest $request Request instance.
|
||||
* @return void
|
||||
*/
|
||||
public function setRequest(CakeRequest $request) {
|
||||
|
@ -454,7 +460,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
$this->passedArgs = array_merge($request->params['pass'], $request->params['named']);
|
||||
}
|
||||
|
||||
if (array_key_exists('return', $request->params) && $request->params['return'] == 1) {
|
||||
if (!empty($request->params['return']) && $request->params['return'] == 1) {
|
||||
$this->autoRender = false;
|
||||
}
|
||||
if (!empty($request->params['bare'])) {
|
||||
|
@ -463,10 +469,10 @@ class Controller extends Object implements CakeEventListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Dispatches the controller action. Checks that the action
|
||||
* Dispatches the controller action. Checks that the action
|
||||
* exists and isn't private.
|
||||
*
|
||||
* @param CakeRequest $request
|
||||
* @param CakeRequest $request Request instance.
|
||||
* @return mixed The resulting response.
|
||||
* @throws PrivateActionException When actions are not public or prefixed by _
|
||||
* @throws MissingActionException When actions are not defined and scaffolding is
|
||||
|
@ -501,20 +507,20 @@ class Controller extends Object implements CakeEventListener {
|
|||
*
|
||||
* @param ReflectionMethod $method The method to be invoked.
|
||||
* @param CakeRequest $request The request to check.
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function _isPrivateAction(ReflectionMethod $method, CakeRequest $request) {
|
||||
$privateAction = (
|
||||
$method->name[0] === '_' ||
|
||||
!$method->isPublic() ||
|
||||
!in_array($method->name, $this->methods)
|
||||
!in_array($method->name, $this->methods)
|
||||
);
|
||||
$prefixes = Router::prefixes();
|
||||
$prefixes = array_map('strtolower', Router::prefixes());
|
||||
|
||||
if (!$privateAction && !empty($prefixes)) {
|
||||
if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) {
|
||||
list($prefix) = explode('_', $request->params['action']);
|
||||
$privateAction = in_array($prefix, $prefixes);
|
||||
$privateAction = in_array(strtolower($prefix), $prefixes);
|
||||
}
|
||||
}
|
||||
return $privateAction;
|
||||
|
@ -523,7 +529,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
/**
|
||||
* Returns a scaffold object to use for dynamically scaffolded controllers.
|
||||
*
|
||||
* @param CakeRequest $request
|
||||
* @param CakeRequest $request Request instance.
|
||||
* @return Scaffold
|
||||
*/
|
||||
protected function _getScaffold(CakeRequest $request) {
|
||||
|
@ -605,8 +611,8 @@ class Controller extends Object implements CakeEventListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all events that will fire in the controller during it's lifecycle.
|
||||
* You can override this function to add you own listener callbacks
|
||||
* Returns a list of all events that will fire in the controller during its lifecycle.
|
||||
* You can override this function to add your own listener callbacks
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
@ -631,11 +637,11 @@ class Controller extends Object implements CakeEventListener {
|
|||
*/
|
||||
public function constructClasses() {
|
||||
$this->_mergeControllerVars();
|
||||
$this->Components->init($this);
|
||||
if ($this->uses) {
|
||||
$this->uses = (array)$this->uses;
|
||||
list(, $this->modelClass) = pluginSplit(current($this->uses));
|
||||
list(, $this->modelClass) = pluginSplit(reset($this->uses));
|
||||
}
|
||||
$this->Components->init($this);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -664,6 +670,8 @@ class Controller extends Object implements CakeEventListener {
|
|||
* - triggers Component `startup` methods.
|
||||
*
|
||||
* @return void
|
||||
* @triggers Controller.initialize $this
|
||||
* @triggers Controller.startup $this
|
||||
*/
|
||||
public function startupProcess() {
|
||||
$this->getEventManager()->dispatch(new CakeEvent('Controller.initialize', $this));
|
||||
|
@ -678,6 +686,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
* - calls the Controller's `afterFilter` method.
|
||||
*
|
||||
* @return void
|
||||
* @triggers Controller.shutdown $this
|
||||
*/
|
||||
public function shutdownProcess() {
|
||||
$this->getEventManager()->dispatch(new CakeEvent('Controller.shutdown', $this));
|
||||
|
@ -686,7 +695,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
/**
|
||||
* Queries & sets valid HTTP response codes & messages.
|
||||
*
|
||||
* @param integer|array $code If $code is an integer, then the corresponding code/message is
|
||||
* @param int|array $code If $code is an integer, then the corresponding code/message is
|
||||
* returned if it exists, null if it does not exist. If $code is an array,
|
||||
* then the 'code' and 'message' keys of each nested array are added to the default
|
||||
* HTTP codes. Example:
|
||||
|
@ -700,7 +709,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
*
|
||||
* @return array Associative array of the HTTP codes as keys, and the message
|
||||
* strings as values, or null of the given $code does not exist.
|
||||
* @deprecated Use CakeResponse::httpCodes();
|
||||
* @deprecated 3.0.0 Since 2.4. Will be removed in 3.0. Use CakeResponse::httpCodes().
|
||||
*/
|
||||
public function httpCodes($code = null) {
|
||||
return $this->response->httpCodes($code);
|
||||
|
@ -708,12 +717,12 @@ class Controller extends Object implements CakeEventListener {
|
|||
|
||||
/**
|
||||
* Loads and instantiates models required by this controller.
|
||||
* If the model is non existent, it will throw a missing database table error, as Cake generates
|
||||
* If the model is non existent, it will throw a missing database table error, as CakePHP generates
|
||||
* dynamic models for the time being.
|
||||
*
|
||||
* @param string $modelClass Name of model class to load
|
||||
* @param integer|string $id Initial ID the instanced model class should have
|
||||
* @return mixed true when single model found and instance created, error returned if model not found.
|
||||
* @param int|string $id Initial ID the instanced model class should have
|
||||
* @return bool True if the model was found
|
||||
* @throws MissingModelException if the model class cannot be found.
|
||||
*/
|
||||
public function loadModel($modelClass = null, $id = null) {
|
||||
|
@ -722,7 +731,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
}
|
||||
|
||||
$this->uses = ($this->uses) ? (array)$this->uses : array();
|
||||
if (!in_array($modelClass, $this->uses)) {
|
||||
if (!in_array($modelClass, $this->uses, true)) {
|
||||
$this->uses[] = $modelClass;
|
||||
}
|
||||
|
||||
|
@ -743,9 +752,10 @@ class Controller extends Object implements CakeEventListener {
|
|||
*
|
||||
* @param string|array $url A string or array-based URL pointing to another location within the app,
|
||||
* 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
|
||||
* @param int|array|null $status HTTP status code (eg: 301). Defaults to 302 when null is passed.
|
||||
* @param bool $exit If true, exit() will be called after the redirect
|
||||
* @return \Cake\Network\Response|null
|
||||
* @triggers Controller.beforeRedirect $this, array($url, $status, $exit)
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#Controller::redirect
|
||||
*/
|
||||
public function redirect($url, $status = null, $exit = true) {
|
||||
|
@ -760,7 +770,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
$this->getEventManager()->dispatch($event);
|
||||
|
||||
if ($event->isStopped()) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
$response = $event->result;
|
||||
extract($this->_parseBeforeRedirect($response, $url, $status, $exit), EXTR_OVERWRITE);
|
||||
|
@ -776,14 +786,17 @@ class Controller extends Object implements CakeEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
$this->response->statusCode($status);
|
||||
if ($status === null) {
|
||||
$status = 302;
|
||||
}
|
||||
$this->response->statusCode($status);
|
||||
|
||||
if ($exit) {
|
||||
$this->response->send();
|
||||
$this->_stop();
|
||||
}
|
||||
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -791,8 +804,8 @@ class Controller extends Object implements CakeEventListener {
|
|||
*
|
||||
* @param mixed $response Response from beforeRedirect callback
|
||||
* @param string|array $url The same value of beforeRedirect
|
||||
* @param integer $status The same value of beforeRedirect
|
||||
* @param boolean $exit The same value of beforeRedirect
|
||||
* @param int $status The same value of beforeRedirect
|
||||
* @param bool $exit The same value of beforeRedirect
|
||||
* @return array Array with keys url, status and exit
|
||||
*/
|
||||
protected function _parseBeforeRedirect($response, $url, $status, $exit) {
|
||||
|
@ -815,7 +828,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
*
|
||||
* @param string $status The header message that is being set.
|
||||
* @return void
|
||||
* @deprecated Use CakeResponse::header()
|
||||
* @deprecated 3.0.0 Will be removed in 3.0. Use CakeResponse::header().
|
||||
*/
|
||||
public function header($status) {
|
||||
$this->response->header($status);
|
||||
|
@ -848,14 +861,13 @@ 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
|
||||
* @param mixed Any other parameters passed to this method will be passed as
|
||||
* parameters to the new action.
|
||||
* @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.
|
||||
* @return mixed Returns the return value of the called action
|
||||
*/
|
||||
public function setAction($action) {
|
||||
|
@ -869,7 +881,8 @@ class Controller extends Object implements CakeEventListener {
|
|||
/**
|
||||
* Returns number of errors in a submitted FORM.
|
||||
*
|
||||
* @return integer Number of errors
|
||||
* @return int Number of errors
|
||||
* @deprecated 3.0.0 This method will be removed in 3.0
|
||||
*/
|
||||
public function validate() {
|
||||
$args = func_get_args();
|
||||
|
@ -882,12 +895,13 @@ class Controller extends Object implements CakeEventListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* Validates models passed by parameters. Example:
|
||||
* Validates models passed by parameters. Takes a list of models as a variable argument.
|
||||
* Example:
|
||||
*
|
||||
* `$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
|
||||
* @deprecated 3.0.0 This method will be removed in 3.0
|
||||
*/
|
||||
public function validateErrors() {
|
||||
$objects = func_get_args();
|
||||
|
@ -914,6 +928,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
* @param string $view View to use for rendering
|
||||
* @param string $layout Layout to use
|
||||
* @return CakeResponse A response object containing the rendered view.
|
||||
* @triggers Controller.beforeRender $this
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#Controller::render
|
||||
*/
|
||||
public function render($view = null, $layout = null) {
|
||||
|
@ -931,29 +946,21 @@ class Controller extends Object implements CakeEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
$viewClass = $this->viewClass;
|
||||
if ($this->viewClass != 'View') {
|
||||
list($plugin, $viewClass) = pluginSplit($viewClass, true);
|
||||
$viewClass = $viewClass . 'View';
|
||||
App::uses($viewClass, $plugin . 'View');
|
||||
}
|
||||
|
||||
$View = new $viewClass($this);
|
||||
$this->View = $this->_getViewObject();
|
||||
|
||||
$models = ClassRegistry::keys();
|
||||
foreach ($models as $currentModel) {
|
||||
$currentObject = ClassRegistry::getObject($currentModel);
|
||||
if (is_a($currentObject, 'Model')) {
|
||||
if ($currentObject instanceof Model) {
|
||||
$className = get_class($currentObject);
|
||||
list($plugin) = pluginSplit(App::location($className));
|
||||
$this->request->params['models'][$currentObject->alias] = compact('plugin', 'className');
|
||||
$View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors;
|
||||
$this->View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors;
|
||||
}
|
||||
}
|
||||
|
||||
$this->autoRender = false;
|
||||
$this->View = $View;
|
||||
$this->response->body($View->render($view, $layout));
|
||||
$this->response->body($this->View->render($view, $layout));
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
|
@ -961,19 +968,20 @@ class Controller extends Object implements CakeEventListener {
|
|||
* Returns the referring URL for this request.
|
||||
*
|
||||
* @param string $default Default URL to use if HTTP_REFERER cannot be read from headers
|
||||
* @param boolean $local If true, restrict referring URLs to local server
|
||||
* @param bool $local If true, restrict referring URLs to local server
|
||||
* @return string Referring URL
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#Controller::referer
|
||||
*/
|
||||
public function referer($default = null, $local = false) {
|
||||
if ($this->request) {
|
||||
$referer = $this->request->referer($local);
|
||||
if ($referer == '/' && $default != null) {
|
||||
return Router::url($default, true);
|
||||
}
|
||||
return $referer;
|
||||
if (!$this->request) {
|
||||
return '/';
|
||||
}
|
||||
return '/';
|
||||
|
||||
$referer = $this->request->referer($local);
|
||||
if ($referer === '/' && $default && $default !== $referer) {
|
||||
return Router::url($default, !$local);
|
||||
}
|
||||
return $referer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -981,7 +989,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
*
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#Controller::disableCache
|
||||
* @deprecated Use CakeResponse::disableCache()
|
||||
* @deprecated 3.0.0 Will be removed in 3.0. Use CakeResponse::disableCache().
|
||||
*/
|
||||
public function disableCache() {
|
||||
$this->response->disableCache();
|
||||
|
@ -994,17 +1002,18 @@ class Controller extends Object implements CakeEventListener {
|
|||
*
|
||||
* @param string $message Message to display to the user
|
||||
* @param string|array $url Relative string or array-based URL to redirect to after the time expires
|
||||
* @param integer $pause Time to show the message
|
||||
* @param int $pause Time to show the message
|
||||
* @param string $layout Layout you want to use, defaults to 'flash'
|
||||
* @return void Renders flash layout
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#Controller::flash
|
||||
* @deprecated 3.0.0 Will be removed in 3.0. Use Flash::set() with version 2.7+ or Session::setFlash() prior to 2.7.
|
||||
*/
|
||||
public function flash($message, $url, $pause = 1, $layout = 'flash') {
|
||||
$this->autoRender = false;
|
||||
$this->set('url', Router::url($url));
|
||||
$this->set('message', $message);
|
||||
$this->set('pause', $pause);
|
||||
$this->set('page_title', $message);
|
||||
$this->set('pageTitle', $message);
|
||||
$this->render(false, $layout);
|
||||
}
|
||||
|
||||
|
@ -1015,10 +1024,10 @@ class Controller extends Object implements CakeEventListener {
|
|||
* @param string|array $op A string containing an SQL comparison operator, or an array matching operators
|
||||
* to fields
|
||||
* @param string $bool SQL boolean operator: AND, OR, XOR, etc.
|
||||
* @param boolean $exclusive If true, and $op is an array, fields not included in $op will not be
|
||||
* @param bool $exclusive If true, and $op is an array, fields not included in $op will not be
|
||||
* included in the returned conditions
|
||||
* @return array An array of model conditions
|
||||
* @deprecated
|
||||
* @return array|null An array of model conditions
|
||||
* @deprecated 3.0.0 Will be removed in 3.0.
|
||||
*/
|
||||
public function postConditions($data = array(), $op = null, $bool = 'AND', $exclusive = false) {
|
||||
if (!is_array($data) || empty($data)) {
|
||||
|
@ -1055,13 +1064,13 @@ class Controller extends Object implements CakeEventListener {
|
|||
if ($fieldOp === 'LIKE') {
|
||||
$key = $key . ' LIKE';
|
||||
$value = '%' . $value . '%';
|
||||
} elseif ($fieldOp && $fieldOp != '=') {
|
||||
} elseif ($fieldOp && $fieldOp !== '=') {
|
||||
$key = $key . ' ' . $fieldOp;
|
||||
}
|
||||
$cond[$key] = $value;
|
||||
}
|
||||
}
|
||||
if ($bool != null && strtoupper($bool) != 'AND') {
|
||||
if ($bool && strtoupper($bool) !== 'AND') {
|
||||
$cond = array($bool => $cond);
|
||||
}
|
||||
return $cond;
|
||||
|
@ -1075,14 +1084,13 @@ class Controller extends Object implements CakeEventListener {
|
|||
* @param array $whitelist List of allowed options for paging
|
||||
* @return array Model query results
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#Controller::paginate
|
||||
* @deprecated Use PaginatorComponent instead
|
||||
*/
|
||||
public function paginate($object = null, $scope = array(), $whitelist = array()) {
|
||||
return $this->Components->load('Paginator', $this->paginate)->paginate($object, $scope, $whitelist);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before the controller action. You can use this method to configure and customize components
|
||||
* Called before the controller action. You can use this method to configure and customize components
|
||||
* or perform logic that needs to happen before each controller action.
|
||||
*
|
||||
* @return void
|
||||
|
@ -1103,18 +1111,20 @@ class Controller extends Object implements CakeEventListener {
|
|||
|
||||
/**
|
||||
* The beforeRedirect method is invoked when the controller's redirect method is called but before any
|
||||
* further action. If this method returns false the controller will not continue on to redirect the request.
|
||||
* further action.
|
||||
*
|
||||
* If this method returns false the controller will not continue on to redirect the request.
|
||||
* The $url, $status and $exit variables have same meaning as for the controller's method. You can also
|
||||
* return a string which will be interpreted as the url to redirect to or return associative array with
|
||||
* return a string which will be interpreted as the URL to redirect to or return associative array with
|
||||
* key 'url' and optionally 'status' and 'exit'.
|
||||
*
|
||||
* @param string|array $url A string or array-based URL pointing to another location within the app,
|
||||
* 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
|
||||
* @param int $status Optional HTTP status code (eg: 404)
|
||||
* @param bool $exit If true, exit() will be called after the redirect
|
||||
* @return mixed
|
||||
* false to stop redirection event,
|
||||
* string controllers a new redirection url or
|
||||
* string controllers a new redirection URL or
|
||||
* array with the keys url, status and exit to be used by the redirect method.
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#request-life-cycle-callbacks
|
||||
*/
|
||||
|
@ -1134,7 +1144,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
* This method should be overridden in child classes.
|
||||
*
|
||||
* @param string $method name of method called example index, edit, etc.
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#callbacks
|
||||
*/
|
||||
public function beforeScaffold($method) {
|
||||
|
@ -1144,10 +1154,10 @@ class Controller extends Object implements CakeEventListener {
|
|||
/**
|
||||
* Alias to beforeScaffold()
|
||||
*
|
||||
* @param string $method
|
||||
* @return boolean
|
||||
* @param string $method Method name.
|
||||
* @return bool
|
||||
* @see Controller::beforeScaffold()
|
||||
* @deprecated
|
||||
* @deprecated 3.0.0 Will be removed in 3.0.
|
||||
*/
|
||||
protected function _beforeScaffold($method) {
|
||||
return $this->beforeScaffold($method);
|
||||
|
@ -1157,7 +1167,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
* This method should be overridden in child classes.
|
||||
*
|
||||
* @param string $method name of method called either edit or update.
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#callbacks
|
||||
*/
|
||||
public function afterScaffoldSave($method) {
|
||||
|
@ -1167,10 +1177,10 @@ class Controller extends Object implements CakeEventListener {
|
|||
/**
|
||||
* Alias to afterScaffoldSave()
|
||||
*
|
||||
* @param string $method
|
||||
* @return boolean
|
||||
* @param string $method Method name.
|
||||
* @return bool
|
||||
* @see Controller::afterScaffoldSave()
|
||||
* @deprecated
|
||||
* @deprecated 3.0.0 Will be removed in 3.0.
|
||||
*/
|
||||
protected function _afterScaffoldSave($method) {
|
||||
return $this->afterScaffoldSave($method);
|
||||
|
@ -1180,7 +1190,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
* This method should be overridden in child classes.
|
||||
*
|
||||
* @param string $method name of method called either edit or update.
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#callbacks
|
||||
*/
|
||||
public function afterScaffoldSaveError($method) {
|
||||
|
@ -1190,10 +1200,10 @@ class Controller extends Object implements CakeEventListener {
|
|||
/**
|
||||
* Alias to afterScaffoldSaveError()
|
||||
*
|
||||
* @param string $method
|
||||
* @return boolean
|
||||
* @param string $method Method name.
|
||||
* @return bool
|
||||
* @see Controller::afterScaffoldSaveError()
|
||||
* @deprecated
|
||||
* @deprecated 3.0.0 Will be removed in 3.0.
|
||||
*/
|
||||
protected function _afterScaffoldSaveError($method) {
|
||||
return $this->afterScaffoldSaveError($method);
|
||||
|
@ -1205,7 +1215,7 @@ class Controller extends Object implements CakeEventListener {
|
|||
* Method MUST return true in child classes
|
||||
*
|
||||
* @param string $method name of method called example index, edit, etc.
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#callbacks
|
||||
*/
|
||||
public function scaffoldError($method) {
|
||||
|
@ -1215,13 +1225,29 @@ class Controller extends Object implements CakeEventListener {
|
|||
/**
|
||||
* Alias to scaffoldError()
|
||||
*
|
||||
* @param string $method
|
||||
* @return boolean
|
||||
* @param string $method Method name.
|
||||
* @return bool
|
||||
* @see Controller::scaffoldError()
|
||||
* @deprecated
|
||||
* @deprecated 3.0.0 Will be removed in 3.0.
|
||||
*/
|
||||
protected function _scaffoldError($method) {
|
||||
return $this->scaffoldError($method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the view class instance based on the controller property
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
protected function _getViewObject() {
|
||||
$viewClass = $this->viewClass;
|
||||
if ($this->viewClass !== 'View') {
|
||||
list($plugin, $viewClass) = pluginSplit($viewClass, true);
|
||||
$viewClass = $viewClass . 'View';
|
||||
App::uses($viewClass, $plugin . 'View');
|
||||
}
|
||||
|
||||
return new $viewClass($this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue