mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '2.0-api-doc' into 2.0
This commit is contained in:
commit
7d0250ff47
362 changed files with 2186 additions and 4234 deletions
|
@ -146,7 +146,8 @@ class Cache {
|
||||||
* Finds and builds the instance of the required engine class.
|
* Finds and builds the instance of the required engine class.
|
||||||
*
|
*
|
||||||
* @param string $name Name of the config array that needs an engine instance built
|
* @param string $name Name of the config array that needs an engine instance built
|
||||||
* @return void
|
* @return boolean
|
||||||
|
* @throws CacheException
|
||||||
*/
|
*/
|
||||||
protected static function _buildEngine($name) {
|
protected static function _buildEngine($name) {
|
||||||
$config = self::$_config[$name];
|
$config = self::$_config[$name];
|
||||||
|
@ -186,7 +187,7 @@ class Cache {
|
||||||
* the Engine instance is also unset.
|
* the Engine instance is also unset.
|
||||||
*
|
*
|
||||||
* @param string $name A currently configured cache config you wish to remove.
|
* @param string $name A currently configured cache config you wish to remove.
|
||||||
* @return boolen success of the removal, returns false when the config does not exist.
|
* @return boolean success of the removal, returns false when the config does not exist.
|
||||||
*/
|
*/
|
||||||
public static function drop($name) {
|
public static function drop($name) {
|
||||||
if (!isset(self::$_config[$name])) {
|
if (!isset(self::$_config[$name])) {
|
||||||
|
@ -456,7 +457,7 @@ class Cache {
|
||||||
* Check if Cache has initialized a working config for the given name.
|
* Check if Cache has initialized a working config for the given name.
|
||||||
*
|
*
|
||||||
* @param string $config name of the configuration to use. Defaults to 'default'
|
* @param string $config name of the configuration to use. Defaults to 'default'
|
||||||
* @return bool Whether or not the config name has been initialized.
|
* @return boolean Whether or not the config name has been initialized.
|
||||||
*/
|
*/
|
||||||
public static function isInitialized($config = 'default') {
|
public static function isInitialized($config = 'default') {
|
||||||
if (Configure::read('Cache.disable')) {
|
if (Configure::read('Cache.disable')) {
|
||||||
|
@ -471,8 +472,6 @@ class Cache {
|
||||||
* @param string $name Name of the configuration to get settings for. Defaults to 'default'
|
* @param string $name Name of the configuration to get settings for. Defaults to 'default'
|
||||||
* @return array list of settings for this engine
|
* @return array list of settings for this engine
|
||||||
* @see Cache::config()
|
* @see Cache::config()
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
*/
|
||||||
public static function settings($name = 'default') {
|
public static function settings($name = 'default') {
|
||||||
if (!empty(self::$_engines[$name])) {
|
if (!empty(self::$_engines[$name])) {
|
||||||
|
@ -492,8 +491,7 @@ abstract class CacheEngine {
|
||||||
/**
|
/**
|
||||||
* Settings of current engine instance
|
* Settings of current engine instance
|
||||||
*
|
*
|
||||||
* @var int
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $settings = array();
|
public $settings = array();
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,7 @@ class FileEngine extends CacheEngine {
|
||||||
/**
|
/**
|
||||||
* Instance of SplFileObject class
|
* Instance of SplFileObject class
|
||||||
*
|
*
|
||||||
* @var _File
|
* @var File
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_File = null;
|
protected $_File = null;
|
||||||
|
|
||||||
|
@ -45,7 +44,6 @@ class FileEngine extends CacheEngine {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @see CacheEngine::__defaults
|
* @see CacheEngine::__defaults
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $settings = array();
|
public $settings = array();
|
||||||
|
|
||||||
|
@ -53,7 +51,6 @@ class FileEngine extends CacheEngine {
|
||||||
* True unless FileEngine::__active(); fails
|
* True unless FileEngine::__active(); fails
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_init = true;
|
protected $_init = true;
|
||||||
|
|
||||||
|
@ -252,6 +249,8 @@ class FileEngine extends CacheEngine {
|
||||||
/**
|
/**
|
||||||
* Not implemented
|
* Not implemented
|
||||||
*
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param integer $offset
|
||||||
* @return void
|
* @return void
|
||||||
* @throws CacheException
|
* @throws CacheException
|
||||||
*/
|
*/
|
||||||
|
@ -262,6 +261,8 @@ class FileEngine extends CacheEngine {
|
||||||
/**
|
/**
|
||||||
* Not implemented
|
* Not implemented
|
||||||
*
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param integer $offset
|
||||||
* @return void
|
* @return void
|
||||||
* @throws CacheException
|
* @throws CacheException
|
||||||
*/
|
*/
|
||||||
|
@ -275,7 +276,6 @@ class FileEngine extends CacheEngine {
|
||||||
* @param string $key The key
|
* @param string $key The key
|
||||||
* @param boolean $createKey Whether the key should be created if it doesn't exists, or not
|
* @param boolean $createKey Whether the key should be created if it doesn't exists, or not
|
||||||
* @return boolean true if the cache key could be set, false otherwise
|
* @return boolean true if the cache key could be set, false otherwise
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected function _setKey($key, $createKey = false) {
|
protected function _setKey($key, $createKey = false) {
|
||||||
$path = new SplFileInfo($this->settings['path'] . $key);
|
$path = new SplFileInfo($this->settings['path'] . $key);
|
||||||
|
@ -296,7 +296,6 @@ class FileEngine extends CacheEngine {
|
||||||
* Determine is cache directory is writable
|
* Determine is cache directory is writable
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected function _active() {
|
protected function _active() {
|
||||||
$dir = new SplFileInfo($this->settings['path']);
|
$dir = new SplFileInfo($this->settings['path']);
|
||||||
|
|
|
@ -31,7 +31,6 @@ class MemcacheEngine extends CacheEngine {
|
||||||
* Memcache wrapper.
|
* Memcache wrapper.
|
||||||
*
|
*
|
||||||
* @var Memcache
|
* @var Memcache
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
protected $_Memcache = null;
|
protected $_Memcache = null;
|
||||||
|
|
||||||
|
@ -43,7 +42,6 @@ class MemcacheEngine extends CacheEngine {
|
||||||
* - compress = boolean, default => false
|
* - compress = boolean, default => false
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $settings = array();
|
public $settings = array();
|
||||||
|
|
||||||
|
@ -96,7 +94,7 @@ class MemcacheEngine extends CacheEngine {
|
||||||
* @param string $server The server address string.
|
* @param string $server The server address string.
|
||||||
* @return array Array containing host, port
|
* @return array Array containing host, port
|
||||||
*/
|
*/
|
||||||
function _parseServerString($server) {
|
protected function _parseServerString($server) {
|
||||||
if (substr($server, 0, 1) == '[') {
|
if (substr($server, 0, 1) == '[') {
|
||||||
$position = strpos($server, ']:');
|
$position = strpos($server, ']:');
|
||||||
if ($position !== false) {
|
if ($position !== false) {
|
||||||
|
|
|
@ -115,7 +115,6 @@ class WincacheEngine extends CacheEngine {
|
||||||
* Delete all keys from the cache. This will clear every
|
* Delete all keys from the cache. This will clear every
|
||||||
* item in the cache matching the cache config prefix.
|
* item in the cache matching the cache config prefix.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param boolean $check If true, nothing will be cleared, as entries will
|
* @param boolean $check If true, nothing will be cleared, as entries will
|
||||||
* naturally expire in wincache..
|
* naturally expire in wincache..
|
||||||
* @return boolean True Returns true.
|
* @return boolean True Returns true.
|
||||||
|
|
|
@ -32,7 +32,6 @@ class XcacheEngine extends CacheEngine {
|
||||||
* - PHP_AUTH_PW = xcache.admin.password, default cake
|
* - PHP_AUTH_PW = xcache.admin.password, default cake
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $settings = array();
|
public $settings = array();
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ class XcacheEngine extends CacheEngine {
|
||||||
* @param array $settings array of setting for the engine
|
* @param array $settings array of setting for the engine
|
||||||
* @return boolean True if the engine has been successfully initialized, false if not
|
* @return boolean True if the engine has been successfully initialized, false if not
|
||||||
*/
|
*/
|
||||||
public function init($settings) {
|
public function init($settings = array()) {
|
||||||
parent::init(array_merge(array(
|
parent::init(array_merge(array(
|
||||||
'engine' => 'Xcache',
|
'engine' => 'Xcache',
|
||||||
'prefix' => Inflector::slug(APP_DIR) . '_',
|
'prefix' => Inflector::slug(APP_DIR) . '_',
|
||||||
|
@ -124,15 +123,16 @@ class XcacheEngine extends CacheEngine {
|
||||||
/**
|
/**
|
||||||
* Delete all keys from the cache
|
* Delete all keys from the cache
|
||||||
*
|
*
|
||||||
|
* @param boolean $check
|
||||||
* @return boolean True if the cache was successfully cleared, false otherwise
|
* @return boolean True if the cache was successfully cleared, false otherwise
|
||||||
*/
|
*/
|
||||||
public function clear($check) {
|
public function clear($check) {
|
||||||
$this->__auth();
|
$this->_auth();
|
||||||
$max = xcache_count(XC_TYPE_VAR);
|
$max = xcache_count(XC_TYPE_VAR);
|
||||||
for ($i = 0; $i < $max; $i++) {
|
for ($i = 0; $i < $max; $i++) {
|
||||||
xcache_clear_cache(XC_TYPE_VAR, $i);
|
xcache_clear_cache(XC_TYPE_VAR, $i);
|
||||||
}
|
}
|
||||||
$this->__auth(true);
|
$this->_auth(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,9 +144,9 @@ class XcacheEngine extends CacheEngine {
|
||||||
* (see xcache.admin configuration settings)
|
* (see xcache.admin configuration settings)
|
||||||
*
|
*
|
||||||
* @param boolean $reverse Revert changes
|
* @param boolean $reverse Revert changes
|
||||||
* @access private
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __auth($reverse = false) {
|
protected function _auth($reverse = false) {
|
||||||
static $backup = array();
|
static $backup = array();
|
||||||
$keys = array('PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password');
|
$keys = array('PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password');
|
||||||
foreach ($keys as $key => $setting) {
|
foreach ($keys as $key => $setting) {
|
||||||
|
|
|
@ -85,6 +85,7 @@ class IniReader implements ConfigReaderInterface {
|
||||||
* @param string $file Name of the file to read. The chosen file
|
* @param string $file Name of the file to read. The chosen file
|
||||||
* must be on the reader's path.
|
* must be on the reader's path.
|
||||||
* @return array
|
* @return array
|
||||||
|
* @throws ConfigureException
|
||||||
*/
|
*/
|
||||||
public function read($file) {
|
public function read($file) {
|
||||||
$filename = $this->_path . $file;
|
$filename = $this->_path . $file;
|
||||||
|
|
|
@ -58,6 +58,7 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Override startup of the Shell
|
* Override startup of the Shell
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startup() {
|
public function startup() {
|
||||||
parent::startup();
|
parent::startup();
|
||||||
|
@ -96,6 +97,7 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Override main() for help message hook
|
* Override main() for help message hook
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function main() {
|
public function main() {
|
||||||
$this->out($this->OptionParser->help());
|
$this->out($this->OptionParser->help());
|
||||||
|
@ -104,9 +106,10 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Creates an ARO/ACO node
|
* Creates an ARO/ACO node
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function create() {
|
public function create() {
|
||||||
extract($this->__dataVars());
|
extract($this->_dataVars());
|
||||||
|
|
||||||
$class = ucfirst($this->args[0]);
|
$class = ucfirst($this->args[0]);
|
||||||
$parent = $this->parseIdentifier($this->args[1]);
|
$parent = $this->parseIdentifier($this->args[1]);
|
||||||
|
@ -136,9 +139,10 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Delete an ARO/ACO node.
|
* Delete an ARO/ACO node.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function delete() {
|
public function delete() {
|
||||||
extract($this->__dataVars());
|
extract($this->_dataVars());
|
||||||
|
|
||||||
$identifier = $this->parseIdentifier($this->args[1]);
|
$identifier = $this->parseIdentifier($this->args[1]);
|
||||||
$nodeId = $this->_getNodeId($class, $identifier);
|
$nodeId = $this->_getNodeId($class, $identifier);
|
||||||
|
@ -152,9 +156,10 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Set parent for an ARO/ACO node.
|
* Set parent for an ARO/ACO node.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setParent() {
|
public function setParent() {
|
||||||
extract($this->__dataVars());
|
extract($this->_dataVars());
|
||||||
$target = $this->parseIdentifier($this->args[1]);
|
$target = $this->parseIdentifier($this->args[1]);
|
||||||
$parent = $this->parseIdentifier($this->args[2]);
|
$parent = $this->parseIdentifier($this->args[2]);
|
||||||
|
|
||||||
|
@ -175,9 +180,10 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Get path to specified ARO/ACO node.
|
* Get path to specified ARO/ACO node.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function getPath() {
|
public function getPath() {
|
||||||
extract($this->__dataVars());
|
extract($this->_dataVars());
|
||||||
$identifier = $this->parseIdentifier($this->args[1]);
|
$identifier = $this->parseIdentifier($this->args[1]);
|
||||||
|
|
||||||
$id = $this->_getNodeId($class, $identifier);
|
$id = $this->_getNodeId($class, $identifier);
|
||||||
|
@ -217,9 +223,10 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Check permission for a given ARO to a given ACO.
|
* Check permission for a given ARO to a given ACO.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function check() {
|
public function check() {
|
||||||
extract($this->__getParams());
|
extract($this->_getParams());
|
||||||
|
|
||||||
if ($this->Acl->check($aro, $aco, $action)) {
|
if ($this->Acl->check($aro, $aco, $action)) {
|
||||||
$this->out(__d('cake_console', '%s is <success>allowed</success>.', $aroName), true);
|
$this->out(__d('cake_console', '%s is <success>allowed</success>.', $aroName), true);
|
||||||
|
@ -231,9 +238,10 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Grant permission for a given ARO to a given ACO.
|
* Grant permission for a given ARO to a given ACO.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function grant() {
|
public function grant() {
|
||||||
extract($this->__getParams());
|
extract($this->_getParams());
|
||||||
|
|
||||||
if ($this->Acl->allow($aro, $aco, $action)) {
|
if ($this->Acl->allow($aro, $aco, $action)) {
|
||||||
$this->out(__d('cake_console', 'Permission <success>granted</success>.'), true);
|
$this->out(__d('cake_console', 'Permission <success>granted</success>.'), true);
|
||||||
|
@ -245,9 +253,10 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Deny access for an ARO to an ACO.
|
* Deny access for an ARO to an ACO.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function deny() {
|
public function deny() {
|
||||||
extract($this->__getParams());
|
extract($this->_getParams());
|
||||||
|
|
||||||
if ($this->Acl->deny($aro, $aco, $action)) {
|
if ($this->Acl->deny($aro, $aco, $action)) {
|
||||||
$this->out(__d('cake_console', 'Permission denied.'), true);
|
$this->out(__d('cake_console', 'Permission denied.'), true);
|
||||||
|
@ -259,9 +268,10 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Set an ARO to inherit permission to an ACO.
|
* Set an ARO to inherit permission to an ACO.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function inherit() {
|
public function inherit() {
|
||||||
extract($this->__getParams());
|
extract($this->_getParams());
|
||||||
|
|
||||||
if ($this->Acl->inherit($aro, $aco, $action)) {
|
if ($this->Acl->inherit($aro, $aco, $action)) {
|
||||||
$this->out(__d('cake_console', 'Permission inherited.'), true);
|
$this->out(__d('cake_console', 'Permission inherited.'), true);
|
||||||
|
@ -273,9 +283,10 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Show a specific ARO/ACO node.
|
* Show a specific ARO/ACO node.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function view() {
|
public function view() {
|
||||||
extract($this->__dataVars());
|
extract($this->_dataVars());
|
||||||
|
|
||||||
if (isset($this->args[1])) {
|
if (isset($this->args[1])) {
|
||||||
$identity = $this->parseIdentifier($this->args[1]);
|
$identity = $this->parseIdentifier($this->args[1]);
|
||||||
|
@ -332,6 +343,7 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Initialize ACL database.
|
* Initialize ACL database.
|
||||||
*
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function initdb() {
|
public function initdb() {
|
||||||
return $this->dispatchShell('schema create DbAcl');
|
return $this->dispatchShell('schema create DbAcl');
|
||||||
|
@ -493,15 +505,13 @@ class AclShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Checks that given node exists
|
* Checks that given node exists
|
||||||
*
|
*
|
||||||
* @param string $type Node type (ARO/ACO)
|
|
||||||
* @param integer $id Node id
|
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function nodeExists() {
|
public function nodeExists() {
|
||||||
if (!isset($this->args[0]) || !isset($this->args[1])) {
|
if (!isset($this->args[0]) || !isset($this->args[1])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
extract($this->__dataVars($this->args[0]));
|
extract($this->_dataVars($this->args[0]));
|
||||||
$key = is_numeric($this->args[1]) ? $secondary_id : 'alias';
|
$key = is_numeric($this->args[1]) ? $secondary_id : 'alias';
|
||||||
$conditions = array($class . '.' . $key => $this->args[1]);
|
$conditions = array($class . '.' . $key => $this->args[1]);
|
||||||
$possibility = $this->Acl->{$class}->find('all', compact('conditions'));
|
$possibility = $this->Acl->{$class}->find('all', compact('conditions'));
|
||||||
|
@ -534,9 +544,9 @@ class AclShell extends Shell {
|
||||||
*
|
*
|
||||||
* @param string $class Class type you want (Aro/Aco)
|
* @param string $class Class type you want (Aro/Aco)
|
||||||
* @param mixed $identifier A mixed identifier for finding the node.
|
* @param mixed $identifier A mixed identifier for finding the node.
|
||||||
* @return int Integer of NodeId. Will trigger an error if nothing is found.
|
* @return integer Integer of NodeId. Will trigger an error if nothing is found.
|
||||||
*/
|
*/
|
||||||
function _getNodeId($class, $identifier) {
|
protected function _getNodeId($class, $identifier) {
|
||||||
$node = $this->Acl->{$class}->node($identifier);
|
$node = $this->Acl->{$class}->node($identifier);
|
||||||
if (empty($node)) {
|
if (empty($node)) {
|
||||||
if (is_array($identifier)) {
|
if (is_array($identifier)) {
|
||||||
|
@ -552,7 +562,7 @@ class AclShell extends Shell {
|
||||||
*
|
*
|
||||||
* @return array aro, aco, action
|
* @return array aro, aco, action
|
||||||
*/
|
*/
|
||||||
function __getParams() {
|
protected function _getParams() {
|
||||||
$aro = is_numeric($this->args[0]) ? intval($this->args[0]) : $this->args[0];
|
$aro = is_numeric($this->args[0]) ? intval($this->args[0]) : $this->args[0];
|
||||||
$aco = is_numeric($this->args[1]) ? intval($this->args[1]) : $this->args[1];
|
$aco = is_numeric($this->args[1]) ? intval($this->args[1]) : $this->args[1];
|
||||||
$aroName = $aro;
|
$aroName = $aro;
|
||||||
|
@ -580,7 +590,7 @@ class AclShell extends Shell {
|
||||||
* @param string $type Node type (ARO/ACO)
|
* @param string $type Node type (ARO/ACO)
|
||||||
* @return array Variables
|
* @return array Variables
|
||||||
*/
|
*/
|
||||||
function __dataVars($type = null) {
|
protected function _dataVars($type = null) {
|
||||||
if ($type == null) {
|
if ($type == null) {
|
||||||
$type = $this->args[0];
|
$type = $this->args[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ class ApiShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Override initialize of the Shell
|
* Override initialize of the Shell
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
$this->paths = array_merge($this->paths, array(
|
$this->paths = array_merge($this->paths, array(
|
||||||
|
@ -53,6 +54,7 @@ class ApiShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Override main() to handle action
|
* Override main() to handle action
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function main() {
|
public function main() {
|
||||||
if (empty($this->args)) {
|
if (empty($this->args)) {
|
||||||
|
@ -86,7 +88,7 @@ class ApiShell extends Shell {
|
||||||
$this->error(__d('cake_console', '%s not found', $class));
|
$this->error(__d('cake_console', '%s not found', $class));
|
||||||
}
|
}
|
||||||
|
|
||||||
$parsed = $this->__parseClass($path . $class .'.php', $class);
|
$parsed = $this->_parseClass($path . $class .'.php', $class);
|
||||||
|
|
||||||
if (!empty($parsed)) {
|
if (!empty($parsed)) {
|
||||||
if (isset($this->params['method'])) {
|
if (isset($this->params['method'])) {
|
||||||
|
@ -150,6 +152,7 @@ class ApiShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Show help for this shell.
|
* Show help for this shell.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function help() {
|
public function help() {
|
||||||
$head = "Usage: cake api [<type>] <className> [-m <method>]\n";
|
$head = "Usage: cake api [<type>] <className> [-m <method>]\n";
|
||||||
|
@ -187,11 +190,11 @@ class ApiShell extends Shell {
|
||||||
* Parse a given class (located on given file) and get public methods and their
|
* Parse a given class (located on given file) and get public methods and their
|
||||||
* signatures.
|
* signatures.
|
||||||
*
|
*
|
||||||
* @param object $File File object
|
* @param string $path File path
|
||||||
* @param string $class Class name
|
* @param string $class Class name
|
||||||
* @return array Methods and signatures indexed by method name
|
* @return array Methods and signatures indexed by method name
|
||||||
*/
|
*/
|
||||||
private function __parseClass($path, $class) {
|
protected function _parseClass($path, $class) {
|
||||||
$parsed = array();
|
$parsed = array();
|
||||||
|
|
||||||
if (!class_exists($class)) {
|
if (!class_exists($class)) {
|
||||||
|
|
|
@ -47,6 +47,7 @@ class BakeShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Assign $this->connection to the active task if a connection param is set.
|
* Assign $this->connection to the active task if a connection param is set.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startup() {
|
public function startup() {
|
||||||
parent::startup();
|
parent::startup();
|
||||||
|
@ -61,6 +62,7 @@ class BakeShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Override main() to handle action
|
* Override main() to handle action
|
||||||
*
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function main() {
|
public function main() {
|
||||||
if (!is_dir($this->DbConfig->path)) {
|
if (!is_dir($this->DbConfig->path)) {
|
||||||
|
@ -124,6 +126,7 @@ class BakeShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Quickly bake the MVC
|
* Quickly bake the MVC
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function all() {
|
public function all() {
|
||||||
$this->out('Bake All');
|
$this->out('Bake All');
|
||||||
|
|
|
@ -4,14 +4,15 @@
|
||||||
*
|
*
|
||||||
* PHP 5
|
* PHP 5
|
||||||
*
|
*
|
||||||
* CakePHP : Rapid Development Framework (http://cakephp.org)
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||||
* Copyright 2005-2011, Cake Software Foundation, Inc.
|
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
* Redistributions of files must retain the above copyright notice.
|
* Redistributions of files must retain the above copyright notice.
|
||||||
*
|
*
|
||||||
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc.
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
* @link http://cakephp.org CakePHP Project
|
* @link http://cakephp.org CakePHP Project
|
||||||
|
* @package Cake.Console.Command
|
||||||
* @since CakePHP v 2.0
|
* @since CakePHP v 2.0
|
||||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
*/
|
*/
|
||||||
|
@ -98,6 +99,9 @@ class CommandListShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Scan the provided paths for shells, and append them into $shellList
|
* Scan the provided paths for shells, and append them into $shellList
|
||||||
*
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @param array $shells
|
||||||
|
* @param array $shellList
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function _appendShells($type, $shells, $shellList) {
|
protected function _appendShells($type, $shells, $shellList) {
|
||||||
|
@ -111,6 +115,7 @@ class CommandListShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Output text.
|
* Output text.
|
||||||
*
|
*
|
||||||
|
* @param array $shellList
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _asText($shellList) {
|
protected function _asText($shellList) {
|
||||||
|
@ -146,6 +151,7 @@ class CommandListShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Generates the shell list sorted by where the shells are found.
|
* Generates the shell list sorted by where the shells are found.
|
||||||
*
|
*
|
||||||
|
* @param array $shellList
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _asSorted($shellList) {
|
protected function _asSorted($shellList) {
|
||||||
|
@ -184,6 +190,7 @@ class CommandListShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Output as XML
|
* Output as XML
|
||||||
*
|
*
|
||||||
|
* @param array $shellList
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _asXml($shellList) {
|
protected function _asXml($shellList) {
|
||||||
|
|
|
@ -47,6 +47,7 @@ class ConsoleShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Override initialize of the Shell
|
* Override initialize of the Shell
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
App::uses('Dispatcher', 'Routing');
|
App::uses('Dispatcher', 'Routing');
|
||||||
|
@ -71,6 +72,7 @@ class ConsoleShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Prints the help message
|
* Prints the help message
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function help() {
|
public function help() {
|
||||||
$out = 'Console help:';
|
$out = 'Console help:';
|
||||||
|
@ -133,6 +135,8 @@ class ConsoleShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Override main() to handle action
|
* Override main() to handle action
|
||||||
*
|
*
|
||||||
|
* @param string $command
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function main($command = null) {
|
public function main($command = null) {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -40,6 +40,7 @@ class I18nShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Override startup of the Shell
|
* Override startup of the Shell
|
||||||
*
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function startup() {
|
public function startup() {
|
||||||
$this->_welcome();
|
$this->_welcome();
|
||||||
|
@ -58,6 +59,7 @@ class I18nShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Override main() for help message hook
|
* Override main() for help message hook
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function main() {
|
public function main() {
|
||||||
$this->out(__d('cake_console', '<info>I18n Shell</info>'));
|
$this->out(__d('cake_console', '<info>I18n Shell</info>'));
|
||||||
|
@ -91,6 +93,7 @@ class I18nShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Initialize I18N database.
|
* Initialize I18N database.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initdb() {
|
public function initdb() {
|
||||||
$this->dispatchShell('schema create i18n');
|
$this->dispatchShell('schema create i18n');
|
||||||
|
|
|
@ -30,13 +30,6 @@ App::uses('CakeSchema', 'Model');
|
||||||
*/
|
*/
|
||||||
class SchemaShell extends Shell {
|
class SchemaShell extends Shell {
|
||||||
|
|
||||||
/**
|
|
||||||
* is this a dry run?
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private $__dry = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schema class being used.
|
* Schema class being used.
|
||||||
*
|
*
|
||||||
|
@ -44,9 +37,17 @@ class SchemaShell extends Shell {
|
||||||
*/
|
*/
|
||||||
public $Schema;
|
public $Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is this a dry run?
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected $_dry = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override initialize
|
* Override initialize
|
||||||
*
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
$this->_welcome();
|
$this->_welcome();
|
||||||
|
@ -57,6 +58,7 @@ class SchemaShell extends Shell {
|
||||||
/**
|
/**
|
||||||
* Override startup
|
* Override startup
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startup() {
|
public function startup() {
|
||||||
$name = $path = $connection = $plugin = null;
|
$name = $path = $connection = $plugin = null;
|
||||||
|
@ -103,6 +105,7 @@ class SchemaShell extends Shell {
|
||||||
* Read and output contents of schema object
|
* Read and output contents of schema object
|
||||||
* path to read as second arg
|
* path to read as second arg
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function view() {
|
public function view() {
|
||||||
$File = new File($this->Schema->path . DS . $this->params['file']);
|
$File = new File($this->Schema->path . DS . $this->params['file']);
|
||||||
|
@ -120,6 +123,7 @@ class SchemaShell extends Shell {
|
||||||
* Read database and Write schema object
|
* Read database and Write schema object
|
||||||
* accepts a connection as first arg or path to save as second arg
|
* accepts a connection as first arg or path to save as second arg
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function generate() {
|
public function generate() {
|
||||||
$this->out(__d('cake_console', 'Generating Schema...'));
|
$this->out(__d('cake_console', 'Generating Schema...'));
|
||||||
|
@ -197,6 +201,7 @@ class SchemaShell extends Shell {
|
||||||
* If -write contains a full path name the file will be saved there. If -write only
|
* If -write contains a full path name the file will be saved there. If -write only
|
||||||
* contains no DS, that will be used as the file name, in the same dir as the schema file.
|
* contains no DS, that will be used as the file name, in the same dir as the schema file.
|
||||||
*
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function dump() {
|
public function dump() {
|
||||||
$write = false;
|
$write = false;
|
||||||
|
@ -245,7 +250,7 @@ class SchemaShell extends Shell {
|
||||||
*/
|
*/
|
||||||
public function create() {
|
public function create() {
|
||||||
list($Schema, $table) = $this->_loadSchema();
|
list($Schema, $table) = $this->_loadSchema();
|
||||||
$this->__create($Schema, $table);
|
$this->_create($Schema, $table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -255,7 +260,7 @@ class SchemaShell extends Shell {
|
||||||
*/
|
*/
|
||||||
public function update() {
|
public function update() {
|
||||||
list($Schema, $table) = $this->_loadSchema();
|
list($Schema, $table) = $this->_loadSchema();
|
||||||
$this->__update($Schema, $table);
|
$this->_update($Schema, $table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,7 +268,7 @@ class SchemaShell extends Shell {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _loadSchema() {
|
protected function _loadSchema() {
|
||||||
$name = $plugin = null;
|
$name = $plugin = null;
|
||||||
if (!empty($this->params['name'])) {
|
if (!empty($this->params['name'])) {
|
||||||
$name = $this->params['name'];
|
$name = $this->params['name'];
|
||||||
|
@ -273,7 +278,7 @@ class SchemaShell extends Shell {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->params['dry'])) {
|
if (!empty($this->params['dry'])) {
|
||||||
$this->__dry = true;
|
$this->_dry = true;
|
||||||
$this->out(__d('cake_console', 'Performing a dry run.'));
|
$this->out(__d('cake_console', 'Performing a dry run.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,8 +305,11 @@ class SchemaShell extends Shell {
|
||||||
* Create database from Schema object
|
* Create database from Schema object
|
||||||
* Should be called via the run method
|
* Should be called via the run method
|
||||||
*
|
*
|
||||||
|
* @param CakeSchema $Schema
|
||||||
|
* @param string $table
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __create($Schema, $table = null) {
|
protected function _create($Schema, $table = null) {
|
||||||
$db = ConnectionManager::getDataSource($this->Schema->connection);
|
$db = ConnectionManager::getDataSource($this->Schema->connection);
|
||||||
|
|
||||||
$drop = $create = array();
|
$drop = $create = array();
|
||||||
|
@ -325,7 +333,7 @@ class SchemaShell extends Shell {
|
||||||
|
|
||||||
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n')) {
|
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n')) {
|
||||||
$this->out(__d('cake_console', 'Dropping table(s).'));
|
$this->out(__d('cake_console', 'Dropping table(s).'));
|
||||||
$this->__run($drop, 'drop', $Schema);
|
$this->_run($drop, 'drop', $Schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->out("\n" . __d('cake_console', 'The following table(s) will be created.'));
|
$this->out("\n" . __d('cake_console', 'The following table(s) will be created.'));
|
||||||
|
@ -333,7 +341,7 @@ class SchemaShell extends Shell {
|
||||||
|
|
||||||
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y')) {
|
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y')) {
|
||||||
$this->out(__d('cake_console', 'Creating table(s).'));
|
$this->out(__d('cake_console', 'Creating table(s).'));
|
||||||
$this->__run($create, 'create', $Schema);
|
$this->_run($create, 'create', $Schema);
|
||||||
}
|
}
|
||||||
$this->out(__d('cake_console', 'End create.'));
|
$this->out(__d('cake_console', 'End create.'));
|
||||||
}
|
}
|
||||||
|
@ -342,8 +350,11 @@ class SchemaShell extends Shell {
|
||||||
* Update database with Schema object
|
* Update database with Schema object
|
||||||
* Should be called via the run method
|
* Should be called via the run method
|
||||||
*
|
*
|
||||||
|
* @param CakeSchema $Schema
|
||||||
|
* @param string $table
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __update(&$Schema, $table = null) {
|
protected function _update(&$Schema, $table = null) {
|
||||||
$db = ConnectionManager::getDataSource($this->Schema->connection);
|
$db = ConnectionManager::getDataSource($this->Schema->connection);
|
||||||
|
|
||||||
$this->out(__d('cake_console', 'Comparing Database to Schema...'));
|
$this->out(__d('cake_console', 'Comparing Database to Schema...'));
|
||||||
|
@ -374,17 +385,21 @@ class SchemaShell extends Shell {
|
||||||
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n')) {
|
if ('y' == $this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n')) {
|
||||||
$this->out();
|
$this->out();
|
||||||
$this->out(__d('cake_console', 'Updating Database...'));
|
$this->out(__d('cake_console', 'Updating Database...'));
|
||||||
$this->__run($contents, 'update', $Schema);
|
$this->_run($contents, 'update', $Schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->out(__d('cake_console', 'End update.'));
|
$this->out(__d('cake_console', 'End update.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs sql from __create() or __update()
|
* Runs sql from _create() or _update()
|
||||||
*
|
*
|
||||||
|
* @param array $contents
|
||||||
|
* @param string $event
|
||||||
|
* @param CakeSchema $Schema
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __run($contents, $event, &$Schema) {
|
protected function _run($contents, $event, &$Schema) {
|
||||||
if (empty($contents)) {
|
if (empty($contents)) {
|
||||||
$this->err(__d('cake_console', 'Sql could not be run'));
|
$this->err(__d('cake_console', 'Sql could not be run'));
|
||||||
return;
|
return;
|
||||||
|
@ -396,7 +411,7 @@ class SchemaShell extends Shell {
|
||||||
if (empty($sql)) {
|
if (empty($sql)) {
|
||||||
$this->out(__d('cake_console', '%s is up to date.', $table));
|
$this->out(__d('cake_console', '%s is up to date.', $table));
|
||||||
} else {
|
} else {
|
||||||
if ($this->__dry === true) {
|
if ($this->_dry === true) {
|
||||||
$this->out(__d('cake_console', 'Dry run for %s :', $table));
|
$this->out(__d('cake_console', 'Dry run for %s :', $table));
|
||||||
$this->out($sql);
|
$this->out($sql);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,7 +26,6 @@ class BakeTask extends Shell {
|
||||||
* Name of plugin
|
* Name of plugin
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $plugin = null;
|
public $plugin = null;
|
||||||
|
|
||||||
|
@ -34,7 +33,6 @@ class BakeTask extends Shell {
|
||||||
* The db connection being used for baking
|
* The db connection being used for baking
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $connection = null;
|
public $connection = null;
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ class ControllerTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Override initialize
|
* Override initialize
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
$this->path = current(App::path('Controller'));
|
$this->path = current(App::path('Controller'));
|
||||||
|
@ -51,6 +52,7 @@ class ControllerTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Execution method always used for tasks
|
* Execution method always used for tasks
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function execute() {
|
public function execute() {
|
||||||
parent::execute();
|
parent::execute();
|
||||||
|
@ -203,6 +205,10 @@ class ControllerTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Confirm a to be baked controller with the user
|
* Confirm a to be baked controller with the user
|
||||||
*
|
*
|
||||||
|
* @param string $controllerName
|
||||||
|
* @param string $useDynamicScaffold
|
||||||
|
* @param array $helpers
|
||||||
|
* @param array $components
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) {
|
public function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) {
|
||||||
|
@ -299,7 +305,6 @@ class ControllerTask extends BakeTask {
|
||||||
* @param string $actions Actions to add, or set the whole controller to use $scaffold (set $actions to 'scaffold')
|
* @param string $actions Actions to add, or set the whole controller to use $scaffold (set $actions to 'scaffold')
|
||||||
* @param array $helpers Helpers to use in controller
|
* @param array $helpers Helpers to use in controller
|
||||||
* @param array $components Components to use in controller
|
* @param array $components Components to use in controller
|
||||||
* @param array $uses Models to use in controller
|
|
||||||
* @return string Baked controller
|
* @return string Baked controller
|
||||||
*/
|
*/
|
||||||
public function bake($controllerName, $actions = '', $helpers = null, $components = null) {
|
public function bake($controllerName, $actions = '', $helpers = null, $components = null) {
|
||||||
|
@ -360,7 +365,7 @@ class ControllerTask extends BakeTask {
|
||||||
* Common code for property choice handling.
|
* Common code for property choice handling.
|
||||||
*
|
*
|
||||||
* @param string $prompt A yes/no question to precede the list
|
* @param string $prompt A yes/no question to precede the list
|
||||||
* @param sting $example A question for a comma separated list, with examples.
|
* @param string $example A question for a comma separated list, with examples.
|
||||||
* @return array Array of values for property.
|
* @return array Array of values for property.
|
||||||
*/
|
*/
|
||||||
protected function _doPropertyChoices($prompt, $example) {
|
protected function _doPropertyChoices($prompt, $example) {
|
||||||
|
@ -378,7 +383,6 @@ class ControllerTask extends BakeTask {
|
||||||
* Outputs and gets the list of possible controllers from database
|
* Outputs and gets the list of possible controllers from database
|
||||||
*
|
*
|
||||||
* @param string $useDbConfig Database configuration name
|
* @param string $useDbConfig Database configuration name
|
||||||
* @param boolean $interactive Whether you are using listAll interactively and want options output.
|
|
||||||
* @return array Set of controllers
|
* @return array Set of controllers
|
||||||
*/
|
*/
|
||||||
public function listAll($useDbConfig = null) {
|
public function listAll($useDbConfig = null) {
|
||||||
|
@ -462,6 +466,7 @@ class ControllerTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Displays help contents
|
* Displays help contents
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function help() {
|
public function help() {
|
||||||
$this->hr();
|
$this->hr();
|
||||||
|
|
|
@ -60,7 +60,7 @@ class DbConfigTask extends Shell {
|
||||||
/**
|
/**
|
||||||
* initialization callback
|
* initialization callback
|
||||||
*
|
*
|
||||||
* @var string
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
$this->path = APP . 'Config' . DS;
|
$this->path = APP . 'Config' . DS;
|
||||||
|
@ -69,6 +69,7 @@ class DbConfigTask extends Shell {
|
||||||
/**
|
/**
|
||||||
* Execution method always used for tasks
|
* Execution method always used for tasks
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function execute() {
|
public function execute() {
|
||||||
if (empty($this->args)) {
|
if (empty($this->args)) {
|
||||||
|
@ -197,6 +198,7 @@ class DbConfigTask extends Shell {
|
||||||
/**
|
/**
|
||||||
* Output verification message and bake if it looks good
|
* Output verification message and bake if it looks good
|
||||||
*
|
*
|
||||||
|
* @param array $config
|
||||||
* @return boolean True if user says it looks good, false otherwise
|
* @return boolean True if user says it looks good, false otherwise
|
||||||
*/
|
*/
|
||||||
protected function _verify($config) {
|
protected function _verify($config) {
|
||||||
|
|
|
@ -377,7 +377,7 @@ class ExtractTask extends Shell {
|
||||||
* @param string $field the name of the field that is being processed
|
* @param string $field the name of the field that is being processed
|
||||||
* @param array $rules the set of validation rules for the field
|
* @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 $file the file name where this validation rule was found
|
||||||
* @param string domain default domain to bind the validations to
|
* @param string $domain default domain to bind the validations to
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _processValidationRules($field, $rules, $file, $domain) {
|
protected function _processValidationRules($field, $rules, $file, $domain) {
|
||||||
|
@ -438,6 +438,9 @@ class ExtractTask extends Shell {
|
||||||
/**
|
/**
|
||||||
* Prepare a file to be stored
|
* Prepare a file to be stored
|
||||||
*
|
*
|
||||||
|
* @param string $domain
|
||||||
|
* @param string $header
|
||||||
|
* @param string $sentence
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _store($domain, $header, $sentence) {
|
protected function _store($domain, $header, $sentence) {
|
||||||
|
@ -513,8 +516,8 @@ class ExtractTask extends Shell {
|
||||||
/**
|
/**
|
||||||
* Get the strings from the position forward
|
* Get the strings from the position forward
|
||||||
*
|
*
|
||||||
* @param int $position Actual position on tokens array
|
* @param integer $position Actual position on tokens array
|
||||||
* @param int $target Number of strings to extract
|
* @param integer $target Number of strings to extract
|
||||||
* @return array Strings extracted
|
* @return array Strings extracted
|
||||||
*/
|
*/
|
||||||
protected function _getStrings(&$position, $target) {
|
protected function _getStrings(&$position, $target) {
|
||||||
|
|
|
@ -43,13 +43,16 @@ class FixtureTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Schema instance
|
* Schema instance
|
||||||
*
|
*
|
||||||
* @var object
|
* @var CakeSchema
|
||||||
*/
|
*/
|
||||||
protected $_Schema = null;
|
protected $_Schema = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override initialize
|
* Override initialize
|
||||||
*
|
*
|
||||||
|
* @param ConsoleOutput $stdout A ConsoleOutput object for stdout.
|
||||||
|
* @param ConsoleOutput $stderr A ConsoleOutput object for stderr.
|
||||||
|
* @param ConsoleInput $stdin A ConsoleInput object for stdin.
|
||||||
*/
|
*/
|
||||||
public function __construct($stdout = null, $stderr = null, $stdin = null) {
|
public function __construct($stdout = null, $stderr = null, $stdin = null) {
|
||||||
parent::__construct($stdout, $stderr, $stdin);
|
parent::__construct($stdout, $stderr, $stdin);
|
||||||
|
@ -236,7 +239,7 @@ class FixtureTask extends BakeTask {
|
||||||
* Generate the fixture file, and write to disk
|
* Generate the fixture file, and write to disk
|
||||||
*
|
*
|
||||||
* @param string $model name of the model being generated
|
* @param string $model name of the model being generated
|
||||||
* @param string $fixture Contents of the fixture file.
|
* @param string $otherVars Contents of the fixture file.
|
||||||
* @return string Content saved into fixture file.
|
* @return string Content saved into fixture file.
|
||||||
*/
|
*/
|
||||||
public function generateFixtureFile($model, $otherVars) {
|
public function generateFixtureFile($model, $otherVars) {
|
||||||
|
@ -271,7 +274,7 @@ class FixtureTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Generates a string representation of a schema.
|
* Generates a string representation of a schema.
|
||||||
*
|
*
|
||||||
* @param array $table Table schema array
|
* @param array $tableInfo Table schema array
|
||||||
* @return string fields definitions
|
* @return string fields definitions
|
||||||
*/
|
*/
|
||||||
protected function _generateSchema($tableInfo) {
|
protected function _generateSchema($tableInfo) {
|
||||||
|
@ -282,7 +285,8 @@ class FixtureTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Generate String representation of Records
|
* Generate String representation of Records
|
||||||
*
|
*
|
||||||
* @param array $table Table schema array
|
* @param array $tableInfo Table schema array
|
||||||
|
* @param integer $recordCount
|
||||||
* @return array Array of records to use in the fixture.
|
* @return array Array of records to use in the fixture.
|
||||||
*/
|
*/
|
||||||
protected function _generateRecords($tableInfo, $recordCount = 1) {
|
protected function _generateRecords($tableInfo, $recordCount = 1) {
|
||||||
|
|
|
@ -66,6 +66,7 @@ class ModelTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Override initialize
|
* Override initialize
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
$this->path = current(App::path('Model'));
|
$this->path = current(App::path('Model'));
|
||||||
|
@ -74,6 +75,7 @@ class ModelTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Execution method always used for tasks
|
* Execution method always used for tasks
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function execute() {
|
public function execute() {
|
||||||
parent::execute();
|
parent::execute();
|
||||||
|
@ -127,7 +129,8 @@ class ModelTask extends BakeTask {
|
||||||
* Get a model object for a class name.
|
* Get a model object for a class name.
|
||||||
*
|
*
|
||||||
* @param string $className Name of class you want model to be.
|
* @param string $className Name of class you want model to be.
|
||||||
* @return object Model instance
|
* @param string $table Table name
|
||||||
|
* @return Model Model instance
|
||||||
*/
|
*/
|
||||||
protected function &_getModelObject($className, $table = null) {
|
protected function &_getModelObject($className, $table = null) {
|
||||||
if (!$table) {
|
if (!$table) {
|
||||||
|
@ -143,7 +146,7 @@ class ModelTask extends BakeTask {
|
||||||
* @param array $options Array of options to use for the selections. indexes must start at 0
|
* @param array $options Array of options to use for the selections. indexes must start at 0
|
||||||
* @param string $prompt Prompt to use for options list.
|
* @param string $prompt Prompt to use for options list.
|
||||||
* @param integer $default The default option for the given prompt.
|
* @param integer $default The default option for the given prompt.
|
||||||
* @return result of user choice.
|
* @return integer result of user choice.
|
||||||
*/
|
*/
|
||||||
public function inOptions($options, $prompt = null, $default = null) {
|
public function inOptions($options, $prompt = null, $default = null) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
|
@ -166,6 +169,7 @@ class ModelTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Handles interactive baking
|
* Handles interactive baking
|
||||||
*
|
*
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function _interactive() {
|
protected function _interactive() {
|
||||||
$this->hr();
|
$this->hr();
|
||||||
|
@ -308,7 +312,7 @@ class ModelTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Handles Generation and user interaction for creating validation.
|
* Handles Generation and user interaction for creating validation.
|
||||||
*
|
*
|
||||||
* @param object $model Model to have validations generated for.
|
* @param Model $model Model to have validations generated for.
|
||||||
* @return array $validate Array of user selected validations.
|
* @return array $validate Array of user selected validations.
|
||||||
*/
|
*/
|
||||||
public function doValidation($model) {
|
public function doValidation($model) {
|
||||||
|
@ -359,6 +363,7 @@ class ModelTask extends BakeTask {
|
||||||
*
|
*
|
||||||
* @param string $fieldName Name of field to be validated.
|
* @param string $fieldName Name of field to be validated.
|
||||||
* @param array $metaData metadata for field
|
* @param array $metaData metadata for field
|
||||||
|
* @param string $primaryKey
|
||||||
* @return array Array of validation for the field.
|
* @return array Array of validation for the field.
|
||||||
*/
|
*/
|
||||||
public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') {
|
public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') {
|
||||||
|
@ -443,7 +448,7 @@ class ModelTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Handles associations
|
* Handles associations
|
||||||
*
|
*
|
||||||
* @param object $model
|
* @param Model $model
|
||||||
* @return array $assocaitons
|
* @return array $assocaitons
|
||||||
*/
|
*/
|
||||||
public function doAssociations($model) {
|
public function doAssociations($model) {
|
||||||
|
@ -492,7 +497,7 @@ class ModelTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Find belongsTo relations and add them to the associations list.
|
* Find belongsTo relations and add them to the associations list.
|
||||||
*
|
*
|
||||||
* @param object $model Model instance of model being generated.
|
* @param Model $model Model instance of model being generated.
|
||||||
* @param array $associations Array of inprogress associations
|
* @param array $associations Array of inprogress associations
|
||||||
* @return array $associations with belongsTo added in.
|
* @return array $associations with belongsTo added in.
|
||||||
*/
|
*/
|
||||||
|
@ -521,7 +526,7 @@ class ModelTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Find the hasOne and HasMany relations and add them to associations list
|
* Find the hasOne and HasMany relations and add them to associations list
|
||||||
*
|
*
|
||||||
* @param object $model Model instance being generated
|
* @param Model $model Model instance being generated
|
||||||
* @param array $associations Array of inprogress associations
|
* @param array $associations Array of inprogress associations
|
||||||
* @return array $associations with hasOne and hasMany added in.
|
* @return array $associations with hasOne and hasMany added in.
|
||||||
*/
|
*/
|
||||||
|
@ -564,7 +569,7 @@ class ModelTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Find the hasAndBelongsToMany relations and add them to associations list
|
* Find the hasAndBelongsToMany relations and add them to associations list
|
||||||
*
|
*
|
||||||
* @param object $model Model instance being generated
|
* @param Model $model Model instance being generated
|
||||||
* @param array $associations Array of in-progress associations
|
* @param array $associations Array of in-progress associations
|
||||||
* @return array $associations with hasAndBelongsToMany added in.
|
* @return array $associations with hasAndBelongsToMany added in.
|
||||||
*/
|
*/
|
||||||
|
@ -630,7 +635,7 @@ class ModelTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Interact with the user and generate additional non-conventional associations
|
* Interact with the user and generate additional non-conventional associations
|
||||||
*
|
*
|
||||||
* @param object $model Temporary model instance
|
* @param Model $model Temporary model instance
|
||||||
* @param array $associations Array of associations.
|
* @param array $associations Array of associations.
|
||||||
* @return array Array of associations.
|
* @return array Array of associations.
|
||||||
*/
|
*/
|
||||||
|
@ -717,6 +722,7 @@ class ModelTask extends BakeTask {
|
||||||
*
|
*
|
||||||
* @param mixed $name Model name or object
|
* @param mixed $name Model name or object
|
||||||
* @param mixed $data if array and $name is not an object assume bake data, otherwise boolean.
|
* @param mixed $data if array and $name is not an object assume bake data, otherwise boolean.
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function bake($name, $data = array()) {
|
public function bake($name, $data = array()) {
|
||||||
if (is_object($name)) {
|
if (is_object($name)) {
|
||||||
|
@ -752,6 +758,7 @@ class ModelTask extends BakeTask {
|
||||||
* Assembles and writes a unit test file
|
* Assembles and writes a unit test file
|
||||||
*
|
*
|
||||||
* @param string $className Model class name
|
* @param string $className Model class name
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function bakeTest($className) {
|
public function bakeTest($className) {
|
||||||
$this->Test->interactive = $this->interactive;
|
$this->Test->interactive = $this->interactive;
|
||||||
|
@ -764,6 +771,7 @@ class ModelTask extends BakeTask {
|
||||||
* outputs the a list of possible models or controllers from database
|
* outputs the a list of possible models or controllers from database
|
||||||
*
|
*
|
||||||
* @param string $useDbConfig Database configuration name
|
* @param string $useDbConfig Database configuration name
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function listAll($useDbConfig = null) {
|
public function listAll($useDbConfig = null) {
|
||||||
$this->_tables = $this->getAllTables($useDbConfig);
|
$this->_tables = $this->getAllTables($useDbConfig);
|
||||||
|
@ -843,6 +851,7 @@ class ModelTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Forces the user to specify the model he wants to bake, and returns the selected model name.
|
* Forces the user to specify the model he wants to bake, and returns the selected model name.
|
||||||
*
|
*
|
||||||
|
* @param string $useDbConfig Database config name
|
||||||
* @return string the model name
|
* @return string the model name
|
||||||
*/
|
*/
|
||||||
public function getName($useDbConfig = null) {
|
public function getName($useDbConfig = null) {
|
||||||
|
|
|
@ -65,6 +65,7 @@ class PluginTask extends Shell {
|
||||||
/**
|
/**
|
||||||
* Interactive interface
|
* Interactive interface
|
||||||
*
|
*
|
||||||
|
* @param string $plugin
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _interactive($plugin = null) {
|
protected function _interactive($plugin = null) {
|
||||||
|
@ -80,8 +81,8 @@ class PluginTask extends Shell {
|
||||||
/**
|
/**
|
||||||
* Bake the plugin, create directories and files
|
* Bake the plugin, create directories and files
|
||||||
*
|
*
|
||||||
* @params $plugin name of the plugin in CamelCased format
|
* @param string $plugin Name of the plugin in CamelCased format
|
||||||
* @return bool
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function bake($plugin) {
|
public function bake($plugin) {
|
||||||
$pathOptions = App::path('plugins');
|
$pathOptions = App::path('plugins');
|
||||||
|
@ -154,6 +155,7 @@ class PluginTask extends Shell {
|
||||||
/**
|
/**
|
||||||
* find and change $this->path to the user selection
|
* find and change $this->path to the user selection
|
||||||
*
|
*
|
||||||
|
* @param array $pathOptions
|
||||||
* @return string plugin path
|
* @return string plugin path
|
||||||
*/
|
*/
|
||||||
public function findPath($pathOptions) {
|
public function findPath($pathOptions) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ProjectTask extends Shell {
|
||||||
* Checks that given project path does not already exist, and
|
* Checks that given project path does not already exist, and
|
||||||
* finds the app directory in it. Then it calls bake() with that information.
|
* finds the app directory in it. Then it calls bake() with that information.
|
||||||
*
|
*
|
||||||
* @param string $project Project path
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function execute() {
|
public function execute() {
|
||||||
$project = null;
|
$project = null;
|
||||||
|
@ -136,7 +136,7 @@ class ProjectTask extends Shell {
|
||||||
/**
|
/**
|
||||||
* Checks PHP's include_path for CakePHP.
|
* Checks PHP's include_path for CakePHP.
|
||||||
*
|
*
|
||||||
* @return bool Indicates whether or not CakePHP exists on include_path
|
* @return boolean Indicates whether or not CakePHP exists on include_path
|
||||||
*/
|
*/
|
||||||
public function cakeOnIncludePath() {
|
public function cakeOnIncludePath() {
|
||||||
$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
|
$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
|
||||||
|
@ -157,6 +157,7 @@ class ProjectTask extends Shell {
|
||||||
* @param string $path Project path
|
* @param string $path Project path
|
||||||
* @param string $skel Path to copy from
|
* @param string $skel Path to copy from
|
||||||
* @param string $skip array of directories to skip when copying
|
* @param string $skip array of directories to skip when copying
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function bake($path, $skel = null, $skip = array('empty')) {
|
public function bake($path, $skel = null, $skip = array('empty')) {
|
||||||
if (!$skel && !empty($this->params['skel'])) {
|
if (!$skel && !empty($this->params['skel'])) {
|
||||||
|
@ -303,7 +304,7 @@ class ProjectTask extends Shell {
|
||||||
* Generates and writes CAKE_CORE_INCLUDE_PATH
|
* Generates and writes CAKE_CORE_INCLUDE_PATH
|
||||||
*
|
*
|
||||||
* @param string $path Project path
|
* @param string $path Project path
|
||||||
* @param bool $hardCode Wether or not define calls should be hardcoded.
|
* @param boolean $hardCode Wether or not define calls should be hardcoded.
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function corePath($path, $hardCode = true) {
|
public function corePath($path, $hardCode = true) {
|
||||||
|
@ -325,7 +326,7 @@ class ProjectTask extends Shell {
|
||||||
*
|
*
|
||||||
* @param string $filename The filename to operate on.
|
* @param string $filename The filename to operate on.
|
||||||
* @param boolean $hardCode Whether or not the define should be uncommented.
|
* @param boolean $hardCode Whether or not the define should be uncommented.
|
||||||
* @retun bool Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
protected function _replaceCorePath($filename, $hardCode) {
|
protected function _replaceCorePath($filename, $hardCode) {
|
||||||
$contents = file_get_contents($filename);
|
$contents = file_get_contents($filename);
|
||||||
|
|
|
@ -102,7 +102,7 @@ class TemplateTask extends Shell {
|
||||||
/**
|
/**
|
||||||
* Set variable values to the template scope
|
* Set variable values to the template scope
|
||||||
*
|
*
|
||||||
* @param mixed $one A string or an array of data.
|
* @param string|array $one A string or an array of data.
|
||||||
* @param mixed $two Value in case $one is a string (which then works as the key).
|
* @param mixed $two Value in case $one is a string (which then works as the key).
|
||||||
* Unused if $one is an associative array, otherwise serves as the values to $one's keys.
|
* Unused if $one is an associative array, otherwise serves as the values to $one's keys.
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -129,8 +129,8 @@ class TemplateTask extends Shell {
|
||||||
*
|
*
|
||||||
* @param string $directory directory / type of thing you want
|
* @param string $directory directory / type of thing you want
|
||||||
* @param string $filename template name
|
* @param string $filename template name
|
||||||
* @param string $vars Additional vars to set to template scope.
|
* @param array $vars Additional vars to set to template scope.
|
||||||
* @return contents of generated code template
|
* @return string contents of generated code template
|
||||||
*/
|
*/
|
||||||
public function generate($directory, $filename, $vars = null) {
|
public function generate($directory, $filename, $vars = null) {
|
||||||
if ($vars !== null) {
|
if ($vars !== null) {
|
||||||
|
|
|
@ -56,13 +56,14 @@ class TestTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Internal list of fixtures that have been added so far.
|
* Internal list of fixtures that have been added so far.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $_fixtures = array();
|
protected $_fixtures = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execution method always used for tasks
|
* Execution method always used for tasks
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function execute() {
|
public function execute() {
|
||||||
parent::execute();
|
parent::execute();
|
||||||
|
@ -85,6 +86,8 @@ class TestTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Handles interactive baking
|
* Handles interactive baking
|
||||||
*
|
*
|
||||||
|
* @param string $type
|
||||||
|
* @return string|boolean
|
||||||
*/
|
*/
|
||||||
protected function _interactive($type = null) {
|
protected function _interactive($type = null) {
|
||||||
$this->interactive = true;
|
$this->interactive = true;
|
||||||
|
@ -110,6 +113,7 @@ class TestTask extends BakeTask {
|
||||||
*
|
*
|
||||||
* @param string $type Type of object to bake test case for ie. Model, Controller
|
* @param string $type Type of object to bake test case for ie. Model, Controller
|
||||||
* @param string $className the 'cake name' for the class ie. Posts for the PostsController
|
* @param string $className the 'cake name' for the class ie. Posts for the PostsController
|
||||||
|
* @return string|boolean
|
||||||
*/
|
*/
|
||||||
public function bake($type, $className) {
|
public function bake($type, $className) {
|
||||||
if ($this->typeCanDetectFixtures($type) && $this->isLoadableClass($type, $className)) {
|
if ($this->typeCanDetectFixtures($type) && $this->isLoadableClass($type, $className)) {
|
||||||
|
@ -215,7 +219,6 @@ class TestTask extends BakeTask {
|
||||||
* Currently only model, and controller are supported
|
* Currently only model, and controller are supported
|
||||||
*
|
*
|
||||||
* @param string $type The Type of object you are generating tests for eg. controller
|
* @param string $type The Type of object you are generating tests for eg. controller
|
||||||
* @param string $className the Classname of the class the test is being generated for.
|
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function typeCanDetectFixtures($type) {
|
public function typeCanDetectFixtures($type) {
|
||||||
|
@ -227,7 +230,7 @@ class TestTask extends BakeTask {
|
||||||
* Check if a class with the given type is loaded or can be loaded.
|
* Check if a class with the given type is loaded or can be loaded.
|
||||||
*
|
*
|
||||||
* @param string $type The Type of object you are generating tests for eg. controller
|
* @param string $type The Type of object you are generating tests for eg. controller
|
||||||
* @param string $className the Classname of the class the test is being generated for.
|
* @param string $class the Classname of the class the test is being generated for.
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isLoadableClass($type, $class) {
|
public function isLoadableClass($type, $class) {
|
||||||
|
@ -398,7 +401,7 @@ class TestTask extends BakeTask {
|
||||||
* Generate a constructor code snippet for the type and classname
|
* Generate a constructor code snippet for the type and classname
|
||||||
*
|
*
|
||||||
* @param string $type The Type of object you are generating tests for eg. controller
|
* @param string $type The Type of object you are generating tests for eg. controller
|
||||||
* @param string $className the Classname of the class the test is being generated for.
|
* @param string $fullClassName The Classname of the class the test is being generated for.
|
||||||
* @return string Constructor snippet for the thing you are building.
|
* @return string Constructor snippet for the thing you are building.
|
||||||
*/
|
*/
|
||||||
public function generateConstructor($type, $fullClassName) {
|
public function generateConstructor($type, $fullClassName) {
|
||||||
|
|
|
@ -72,6 +72,7 @@ class ViewTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Override initialize
|
* Override initialize
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
$this->path = current(App::path('View'));
|
$this->path = current(App::path('View'));
|
||||||
|
@ -80,6 +81,7 @@ class ViewTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Execution method always used for tasks
|
* Execution method always used for tasks
|
||||||
*
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function execute() {
|
public function execute() {
|
||||||
parent::execute();
|
parent::execute();
|
||||||
|
@ -113,7 +115,7 @@ class ViewTask extends BakeTask {
|
||||||
return $this->bake($action, true);
|
return $this->bake($action, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$vars = $this->__loadController();
|
$vars = $this->_loadController();
|
||||||
$methods = $this->_methodsToBake();
|
$methods = $this->_methodsToBake();
|
||||||
|
|
||||||
foreach ($methods as $method) {
|
foreach ($methods as $method) {
|
||||||
|
@ -175,7 +177,7 @@ class ViewTask extends BakeTask {
|
||||||
$this->controllerName = $this->_controllerName($model);
|
$this->controllerName = $this->_controllerName($model);
|
||||||
App::uses($model, 'Model');
|
App::uses($model, 'Model');
|
||||||
if (class_exists($model)) {
|
if (class_exists($model)) {
|
||||||
$vars = $this->__loadController();
|
$vars = $this->_loadController();
|
||||||
if (!$actions) {
|
if (!$actions) {
|
||||||
$actions = $this->_methodsToBake();
|
$actions = $this->_methodsToBake();
|
||||||
}
|
}
|
||||||
|
@ -188,6 +190,7 @@ class ViewTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Handles interactive baking
|
* Handles interactive baking
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _interactive() {
|
protected function _interactive() {
|
||||||
$this->hr();
|
$this->hr();
|
||||||
|
@ -216,7 +219,7 @@ class ViewTask extends BakeTask {
|
||||||
$wannaDoAdmin = $this->in(__d('cake_console', "Would you like to create the views for admin routing?"), array('y','n'), 'n');
|
$wannaDoAdmin = $this->in(__d('cake_console', "Would you like to create the views for admin routing?"), array('y','n'), 'n');
|
||||||
|
|
||||||
if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoAdmin) == 'y') {
|
if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoAdmin) == 'y') {
|
||||||
$vars = $this->__loadController();
|
$vars = $this->_loadController();
|
||||||
if (strtolower($wannaDoScaffold) == 'y') {
|
if (strtolower($wannaDoScaffold) == 'y') {
|
||||||
$actions = $this->scaffoldActions;
|
$actions = $this->scaffoldActions;
|
||||||
$this->bakeActions($actions, $vars);
|
$this->bakeActions($actions, $vars);
|
||||||
|
@ -247,7 +250,7 @@ class ViewTask extends BakeTask {
|
||||||
*
|
*
|
||||||
* @return array Returns an variables to be made available to a view template
|
* @return array Returns an variables to be made available to a view template
|
||||||
*/
|
*/
|
||||||
private function __loadController() {
|
protected function _loadController() {
|
||||||
if (!$this->controllerName) {
|
if (!$this->controllerName) {
|
||||||
$this->err(__d('cake_console', 'Controller not found'));
|
$this->err(__d('cake_console', 'Controller not found'));
|
||||||
}
|
}
|
||||||
|
@ -277,7 +280,7 @@ class ViewTask extends BakeTask {
|
||||||
$singularHumanName = $this->_singularHumanName($this->controllerName);
|
$singularHumanName = $this->_singularHumanName($this->controllerName);
|
||||||
$schema = $modelObj->schema(true);
|
$schema = $modelObj->schema(true);
|
||||||
$fields = array_keys($schema);
|
$fields = array_keys($schema);
|
||||||
$associations = $this->__associations($modelObj);
|
$associations = $this->_associations($modelObj);
|
||||||
} else {
|
} else {
|
||||||
$primaryKey = $displayField = null;
|
$primaryKey = $displayField = null;
|
||||||
$singularVar = Inflector::variable(Inflector::singularize($this->controllerName));
|
$singularVar = Inflector::variable(Inflector::singularize($this->controllerName));
|
||||||
|
@ -295,6 +298,7 @@ class ViewTask extends BakeTask {
|
||||||
* Bake a view file for each of the supplied actions
|
* Bake a view file for each of the supplied actions
|
||||||
*
|
*
|
||||||
* @param array $actions Array of actions to make files for.
|
* @param array $actions Array of actions to make files for.
|
||||||
|
* @param array $vars
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function bakeActions($actions, $vars) {
|
public function bakeActions($actions, $vars) {
|
||||||
|
@ -363,7 +367,7 @@ class ViewTask extends BakeTask {
|
||||||
*/
|
*/
|
||||||
public function getContent($action, $vars = null) {
|
public function getContent($action, $vars = null) {
|
||||||
if (!$vars) {
|
if (!$vars) {
|
||||||
$vars = $this->__loadController();
|
$vars = $this->_loadController();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Template->set('action', $action);
|
$this->Template->set('action', $action);
|
||||||
|
@ -436,9 +440,10 @@ class ViewTask extends BakeTask {
|
||||||
/**
|
/**
|
||||||
* Returns associations for controllers models.
|
* Returns associations for controllers models.
|
||||||
*
|
*
|
||||||
|
* @param Model $model
|
||||||
* @return array $associations
|
* @return array $associations
|
||||||
*/
|
*/
|
||||||
private function __associations($model) {
|
protected function _associations($model) {
|
||||||
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||||
$associations = array();
|
$associations = array();
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,7 @@ class TestsuiteShell extends Shell {
|
||||||
* Initialization method installs PHPUnit and loads all plugins
|
* Initialization method installs PHPUnit and loads all plugins
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
$this->_dispatcher = new CakeTestSuiteDispatcher();
|
$this->_dispatcher = new CakeTestSuiteDispatcher();
|
||||||
|
@ -181,7 +182,7 @@ class TestsuiteShell extends Shell {
|
||||||
*
|
*
|
||||||
* @return array Array of params for CakeTestDispatcher
|
* @return array Array of params for CakeTestDispatcher
|
||||||
*/
|
*/
|
||||||
protected function parseArgs() {
|
protected function _parseArgs() {
|
||||||
if (empty($this->args)) {
|
if (empty($this->args)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +214,7 @@ class TestsuiteShell extends Shell {
|
||||||
*
|
*
|
||||||
* @return array Array of params for CakeTestDispatcher
|
* @return array Array of params for CakeTestDispatcher
|
||||||
*/
|
*/
|
||||||
protected function runnerOptions() {
|
protected function _runnerOptions() {
|
||||||
$options = array();
|
$options = array();
|
||||||
$params = $this->params;
|
$params = $this->params;
|
||||||
unset($params['help']);
|
unset($params['help']);
|
||||||
|
@ -245,23 +246,23 @@ class TestsuiteShell extends Shell {
|
||||||
$this->out(__d('cake_console', 'CakePHP Test Shell'));
|
$this->out(__d('cake_console', 'CakePHP Test Shell'));
|
||||||
$this->hr();
|
$this->hr();
|
||||||
|
|
||||||
$args = $this->parseArgs();
|
$args = $this->_parseArgs();
|
||||||
|
|
||||||
if (empty($args['case'])) {
|
if (empty($args['case'])) {
|
||||||
return $this->available();
|
return $this->available();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->run($args, $this->runnerOptions());
|
$this->_run($args, $this->_runnerOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the test case from $runnerArgs
|
* Runs the test case from $runnerArgs
|
||||||
*
|
*
|
||||||
* @param array $runnerArgs list of arguments as obtained from parseArgs()
|
* @param array $runnerArgs list of arguments as obtained from _parseArgs()
|
||||||
* @param array $options list of options as constructed by runnerOptions()
|
* @param array $options list of options as constructed by _runnerOptions()
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function run($runnerArgs, $options = array()) {
|
protected function _run($runnerArgs, $options = array()) {
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
|
|
||||||
|
@ -275,7 +276,7 @@ class TestsuiteShell extends Shell {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function available() {
|
public function available() {
|
||||||
$params = $this->parseArgs();
|
$params = $this->_parseArgs();
|
||||||
$testCases = CakeTestLoader::generateTestList($params);
|
$testCases = CakeTestLoader::generateTestList($params);
|
||||||
$app = $params['app'];
|
$app = $params['app'];
|
||||||
$plugin = $params['plugin'];
|
$plugin = $params['plugin'];
|
||||||
|
@ -309,14 +310,14 @@ class TestsuiteShell extends Shell {
|
||||||
if (is_numeric($choice) && isset($cases[$choice])) {
|
if (is_numeric($choice) && isset($cases[$choice])) {
|
||||||
$this->args[0] = $category;
|
$this->args[0] = $category;
|
||||||
$this->args[1] = $cases[$choice];
|
$this->args[1] = $cases[$choice];
|
||||||
$this->run($this->parseArgs(), $this->runnerOptions());
|
$this->_run($this->_parseArgs(), $this->_runnerOptions());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($choice) && in_array($choice, $cases)) {
|
if (is_string($choice) && in_array($choice, $cases)) {
|
||||||
$this->args[0] = $category;
|
$this->args[0] = $category;
|
||||||
$this->args[1] = $choice;
|
$this->args[1] = $choice;
|
||||||
$this->run($this->parseArgs(), $this->runnerOptions());
|
$this->_run($this->_parseArgs(), $this->_runnerOptions());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Upgrade Shell
|
||||||
|
*
|
||||||
|
* PHP 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||||
|
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
|
* @link http://cakephp.org CakePHP(tm) Project
|
||||||
|
* @package Cake.Console.Command
|
||||||
|
* @since CakePHP(tm) v 2.0
|
||||||
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
|
*/
|
||||||
|
|
||||||
App::uses('Folder', 'Utility');
|
App::uses('Folder', 'Utility');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,10 +26,25 @@ App::uses('Folder', 'Utility');
|
||||||
*/
|
*/
|
||||||
class UpgradeShell extends Shell {
|
class UpgradeShell extends Shell {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Files
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
protected $_files = array();
|
protected $_files = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paths
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
protected $_paths = array();
|
protected $_paths = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
protected $_map = array(
|
protected $_map = array(
|
||||||
'Controller' => 'Controller',
|
'Controller' => 'Controller',
|
||||||
'Component' => 'Controller/Component',
|
'Component' => 'Controller/Component',
|
||||||
|
|
|
@ -30,16 +30,14 @@ class ConsoleErrorHandler extends ErrorHandler {
|
||||||
/**
|
/**
|
||||||
* Standard error stream.
|
* Standard error stream.
|
||||||
*
|
*
|
||||||
* @var filehandle
|
* @var ConsoleOutput
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public static $stderr;
|
public static $stderr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the stderr object for the console error handling.
|
* Get the stderr object for the console error handling.
|
||||||
*
|
*
|
||||||
* @param Exception $error Exception to handle.
|
* @return ConsoleOutput
|
||||||
* @param array $messages Error messages
|
|
||||||
*/
|
*/
|
||||||
public static function getStderr() {
|
public static function getStderr() {
|
||||||
if (empty(self::$stderr)) {
|
if (empty(self::$stderr)) {
|
||||||
|
@ -66,10 +64,10 @@ class ConsoleErrorHandler extends ErrorHandler {
|
||||||
* Handle errors in the console environment. Writes errors to stderr,
|
* Handle errors in the console environment. Writes errors to stderr,
|
||||||
* and logs messages if Configure::read('debug') is 0.
|
* and logs messages if Configure::read('debug') is 0.
|
||||||
*
|
*
|
||||||
* @param int $code Error code
|
* @param integer $code Error code
|
||||||
* @param string $description Description of the error.
|
* @param string $description Description of the error.
|
||||||
* @param string $file The file the error occurred in.
|
* @param string $file The file the error occurred in.
|
||||||
* @param int $line The line the error occurred on.
|
* @param integer $line The line the error occurred on.
|
||||||
* @param array $context The backtrace of the error.
|
* @param array $context The backtrace of the error.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -84,7 +84,7 @@ class ConsoleInputArgument {
|
||||||
/**
|
/**
|
||||||
* Generate the help for this argument.
|
* Generate the help for this argument.
|
||||||
*
|
*
|
||||||
* @param int $width The width to make the name of the option.
|
* @param integer $width The width to make the name of the option.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function help($width = 0) {
|
public function help($width = 0) {
|
||||||
|
@ -131,7 +131,9 @@ class ConsoleInputArgument {
|
||||||
/**
|
/**
|
||||||
* Check that $value is a valid choice for this argument.
|
* Check that $value is a valid choice for this argument.
|
||||||
*
|
*
|
||||||
|
* @param string $value
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
* @throws ConsoleException
|
||||||
*/
|
*/
|
||||||
public function validChoice($value) {
|
public function validChoice($value) {
|
||||||
if (empty($this->_choices)) {
|
if (empty($this->_choices)) {
|
||||||
|
@ -149,7 +151,7 @@ class ConsoleInputArgument {
|
||||||
/**
|
/**
|
||||||
* Append this arguments XML representation to the passed in SimpleXml object.
|
* Append this arguments XML representation to the passed in SimpleXml object.
|
||||||
*
|
*
|
||||||
* @param SimpleXmlElement The parent element.
|
* @param SimpleXmlElement $parent The parent element.
|
||||||
* @return SimpleXmlElement The parent with this argument appended.
|
* @return SimpleXmlElement The parent with this argument appended.
|
||||||
*/
|
*/
|
||||||
public function xml(SimpleXmlElement $parent) {
|
public function xml(SimpleXmlElement $parent) {
|
||||||
|
|
|
@ -75,6 +75,7 @@ class ConsoleInputOption {
|
||||||
* @param boolean $boolean Whether this option is a boolean option. Boolean options don't consume extra tokens
|
* @param boolean $boolean Whether this option is a boolean option. Boolean options don't consume extra tokens
|
||||||
* @param string $default The default value for this option.
|
* @param string $default The default value for this option.
|
||||||
* @param array $choices Valid choices for this option.
|
* @param array $choices Valid choices for this option.
|
||||||
|
* @throws ConsoleException
|
||||||
*/
|
*/
|
||||||
public function __construct($name, $short = null, $help = '', $boolean = false, $default = '', $choices = array()) {
|
public function __construct($name, $short = null, $help = '', $boolean = false, $default = '', $choices = array()) {
|
||||||
if (is_array($name) && isset($name['name'])) {
|
if (is_array($name) && isset($name['name'])) {
|
||||||
|
@ -117,7 +118,7 @@ class ConsoleInputOption {
|
||||||
/**
|
/**
|
||||||
* Generate the help for this this option.
|
* Generate the help for this this option.
|
||||||
*
|
*
|
||||||
* @param int $width The width to make the name of the option.
|
* @param integer $width The width to make the name of the option.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function help($width = 0) {
|
public function help($width = 0) {
|
||||||
|
@ -176,7 +177,9 @@ class ConsoleInputOption {
|
||||||
/**
|
/**
|
||||||
* Check that a value is a valid choice for this option.
|
* Check that a value is a valid choice for this option.
|
||||||
*
|
*
|
||||||
|
* @param string $value
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
* @throws ConsoleException
|
||||||
*/
|
*/
|
||||||
public function validChoice($value) {
|
public function validChoice($value) {
|
||||||
if (empty($this->_choices)) {
|
if (empty($this->_choices)) {
|
||||||
|
@ -194,7 +197,7 @@ class ConsoleInputOption {
|
||||||
/**
|
/**
|
||||||
* Append the option's xml into the parent.
|
* Append the option's xml into the parent.
|
||||||
*
|
*
|
||||||
* @param SimpleXmlElement The parent element.
|
* @param SimpleXmlElement $parent The parent element.
|
||||||
* @return SimpleXmlElement The parent with this option appended.
|
* @return SimpleXmlElement The parent with this option appended.
|
||||||
*/
|
*/
|
||||||
public function xml(SimpleXmlElement $parent) {
|
public function xml(SimpleXmlElement $parent) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ class ConsoleInputSubcommand {
|
||||||
/**
|
/**
|
||||||
* Generate the help for this this subcommand.
|
* Generate the help for this this subcommand.
|
||||||
*
|
*
|
||||||
* @param int $width The width to make the name of the subcommand.
|
* @param integer $width The width to make the name of the subcommand.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function help($width = 0) {
|
public function help($width = 0) {
|
||||||
|
@ -108,7 +108,7 @@ class ConsoleInputSubcommand {
|
||||||
/**
|
/**
|
||||||
* Append this subcommand to the Parent element
|
* Append this subcommand to the Parent element
|
||||||
*
|
*
|
||||||
* @param SimpleXmlElement The parent element.
|
* @param SimpleXmlElement $parent The parent element.
|
||||||
* @return SimpleXmlElement The parent with this subcommand appended.
|
* @return SimpleXmlElement The parent with this subcommand appended.
|
||||||
*/
|
*/
|
||||||
public function xml(SimpleXmlElement $parent) {
|
public function xml(SimpleXmlElement $parent) {
|
||||||
|
|
|
@ -284,8 +284,8 @@ class ConsoleOptionParser {
|
||||||
*
|
*
|
||||||
* @param mixed $name The long name you want to the value to be parsed out as when options are parsed.
|
* @param mixed $name The long name you want to the value to be parsed out as when options are parsed.
|
||||||
* Will also accept an instance of ConsoleInputOption
|
* Will also accept an instance of ConsoleInputOption
|
||||||
* @param array $params An array of parameters that define the behavior of the option
|
* @param array $options An array of parameters that define the behavior of the option
|
||||||
* @return returns $this.
|
* @return ConsoleOptionParser $this.
|
||||||
*/
|
*/
|
||||||
public function addOption($name, $options = array()) {
|
public function addOption($name, $options = array()) {
|
||||||
if (is_object($name) && $name instanceof ConsoleInputOption) {
|
if (is_object($name) && $name instanceof ConsoleInputOption) {
|
||||||
|
@ -325,7 +325,7 @@ class ConsoleOptionParser {
|
||||||
*
|
*
|
||||||
* @param mixed $name The name of the argument. Will also accept an instance of ConsoleInputArgument
|
* @param mixed $name The name of the argument. Will also accept an instance of ConsoleInputArgument
|
||||||
* @param array $params Parameters for the argument, see above.
|
* @param array $params Parameters for the argument, see above.
|
||||||
* @return $this.
|
* @return ConsoleOptionParser $this.
|
||||||
*/
|
*/
|
||||||
public function addArgument($name, $params = array()) {
|
public function addArgument($name, $params = array()) {
|
||||||
if (is_object($name) && $name instanceof ConsoleInputArgument) {
|
if (is_object($name) && $name instanceof ConsoleInputArgument) {
|
||||||
|
@ -354,7 +354,7 @@ class ConsoleOptionParser {
|
||||||
*
|
*
|
||||||
* @param array $args Array of arguments to add.
|
* @param array $args Array of arguments to add.
|
||||||
* @see ConsoleOptionParser::addArgument()
|
* @see ConsoleOptionParser::addArgument()
|
||||||
* @return $this
|
* @return ConsoleOptionParser $this
|
||||||
*/
|
*/
|
||||||
public function addArguments(array $args) {
|
public function addArguments(array $args) {
|
||||||
foreach ($args as $name => $params) {
|
foreach ($args as $name => $params) {
|
||||||
|
@ -369,7 +369,7 @@ class ConsoleOptionParser {
|
||||||
*
|
*
|
||||||
* @param array $options Array of options to add.
|
* @param array $options Array of options to add.
|
||||||
* @see ConsoleOptionParser::addOption()
|
* @see ConsoleOptionParser::addOption()
|
||||||
* @return $this
|
* @return ConsoleOptionParser $this
|
||||||
*/
|
*/
|
||||||
public function addOptions(array $options) {
|
public function addOptions(array $options) {
|
||||||
foreach ($options as $name => $params) {
|
foreach ($options as $name => $params) {
|
||||||
|
@ -390,8 +390,8 @@ class ConsoleOptionParser {
|
||||||
* it will be used.
|
* it will be used.
|
||||||
*
|
*
|
||||||
* @param mixed $name Name of the subcommand. Will also accept an instance of ConsoleInputSubcommand
|
* @param mixed $name Name of the subcommand. Will also accept an instance of ConsoleInputSubcommand
|
||||||
* @param array $params Array of params, see above.
|
* @param array $options Array of params, see above.
|
||||||
* @return $this.
|
* @return ConsoleOptionParser $this.
|
||||||
*/
|
*/
|
||||||
public function addSubcommand($name, $options = array()) {
|
public function addSubcommand($name, $options = array()) {
|
||||||
if (is_object($name) && $name instanceof ConsoleInputSubcommand) {
|
if (is_object($name) && $name instanceof ConsoleInputSubcommand) {
|
||||||
|
@ -414,7 +414,7 @@ class ConsoleOptionParser {
|
||||||
* Add multiple subcommands at once.
|
* Add multiple subcommands at once.
|
||||||
*
|
*
|
||||||
* @param array $commands Array of subcommands.
|
* @param array $commands Array of subcommands.
|
||||||
* @return $this
|
* @return ConsoleOptionParser $this
|
||||||
*/
|
*/
|
||||||
public function addSubcommands(array $commands) {
|
public function addSubcommands(array $commands) {
|
||||||
foreach ($commands as $name => $params) {
|
foreach ($commands as $name => $params) {
|
||||||
|
@ -459,8 +459,7 @@ class ConsoleOptionParser {
|
||||||
* @param string $command The subcommand to use. If this parameter is a subcommand, that has a parser,
|
* @param string $command The subcommand to use. If this parameter is a subcommand, that has a parser,
|
||||||
* That parser will be used to parse $argv instead.
|
* That parser will be used to parse $argv instead.
|
||||||
* @return Array array($params, $args)
|
* @return Array array($params, $args)
|
||||||
* @throws InvalidArgumentException When an invalid parameter is encountered.
|
* @throws ConsoleException When an invalid parameter is encountered.
|
||||||
* RuntimeException when required arguments are not supplied.
|
|
||||||
*/
|
*/
|
||||||
public function parse($argv, $command = null) {
|
public function parse($argv, $command = null) {
|
||||||
if (isset($this->_subcommands[$command]) && $this->_subcommands[$command]->parser()) {
|
if (isset($this->_subcommands[$command]) && $this->_subcommands[$command]->parser()) {
|
||||||
|
@ -506,7 +505,8 @@ class ConsoleOptionParser {
|
||||||
*
|
*
|
||||||
* @param string $subcommand If present and a valid subcommand that has a linked parser.
|
* @param string $subcommand If present and a valid subcommand that has a linked parser.
|
||||||
* That subcommands help will be shown instead.
|
* That subcommands help will be shown instead.
|
||||||
* @param int $width The width to format user content to. Defaults to 72
|
* @param string $format Define the output format, can be text or xml
|
||||||
|
* @param integer $width The width to format user content to. Defaults to 72
|
||||||
* @return string Generated help.
|
* @return string Generated help.
|
||||||
*/
|
*/
|
||||||
public function help($subcommand = null, $format = 'text', $width = 72) {
|
public function help($subcommand = null, $format = 'text', $width = 72) {
|
||||||
|
@ -568,9 +568,10 @@ class ConsoleOptionParser {
|
||||||
/**
|
/**
|
||||||
* Parse an option by its name index.
|
* Parse an option by its name index.
|
||||||
*
|
*
|
||||||
* @param string $option The option to parse.
|
* @param string $name The name to parse.
|
||||||
* @param array $params The params to append the parsed value into
|
* @param array $params The params to append the parsed value into
|
||||||
* @return array Params with $option added in.
|
* @return array Params with $option added in.
|
||||||
|
* @throws ConsoleException
|
||||||
*/
|
*/
|
||||||
protected function _parseOption($name, $params) {
|
protected function _parseOption($name, $params) {
|
||||||
if (!isset($this->_options[$name])) {
|
if (!isset($this->_options[$name])) {
|
||||||
|
@ -617,6 +618,7 @@ class ConsoleOptionParser {
|
||||||
* @param string $argument The argument to append
|
* @param string $argument The argument to append
|
||||||
* @param array $args The array of parsed args to append to.
|
* @param array $args The array of parsed args to append to.
|
||||||
* @return array Args
|
* @return array Args
|
||||||
|
* @throws ConsoleException
|
||||||
*/
|
*/
|
||||||
protected function _parseArg($argument, $args) {
|
protected function _parseArg($argument, $args) {
|
||||||
if (empty($this->_args)) {
|
if (empty($this->_args)) {
|
||||||
|
@ -637,8 +639,7 @@ class ConsoleOptionParser {
|
||||||
/**
|
/**
|
||||||
* Find the next token in the argv set.
|
* Find the next token in the argv set.
|
||||||
*
|
*
|
||||||
* @param string
|
* @return string next token or ''
|
||||||
* @return next token or ''
|
|
||||||
*/
|
*/
|
||||||
protected function _nextToken() {
|
protected function _nextToken() {
|
||||||
return isset($this->_tokens[0]) ? $this->_tokens[0] : '';
|
return isset($this->_tokens[0]) ? $this->_tokens[0] : '';
|
||||||
|
|
|
@ -266,7 +266,7 @@ class ConsoleOutput {
|
||||||
/**
|
/**
|
||||||
* Get/Set the output type to use. The output type how formatting tags are treated.
|
* Get/Set the output type to use. The output type how formatting tags are treated.
|
||||||
*
|
*
|
||||||
* @param int $type The output type to use. Should be one of the class constants.
|
* @param integer $type The output type to use. Should be one of the class constants.
|
||||||
* @return mixed Either null or the value if getting.
|
* @return mixed Either null or the value if getting.
|
||||||
*/
|
*/
|
||||||
public function outputAs($type = null) {
|
public function outputAs($type = null) {
|
||||||
|
@ -279,7 +279,6 @@ class ConsoleOutput {
|
||||||
/**
|
/**
|
||||||
* clean up and close handles
|
* clean up and close handles
|
||||||
*
|
*
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
fclose($this->_output);
|
fclose($this->_output);
|
||||||
|
|
|
@ -158,6 +158,7 @@ class HelpFormatter {
|
||||||
/**
|
/**
|
||||||
* Iterate over a collection and find the longest named thing.
|
* Iterate over a collection and find the longest named thing.
|
||||||
*
|
*
|
||||||
|
* @param array $collection
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
protected function _getMaxLength($collection) {
|
protected function _getMaxLength($collection) {
|
||||||
|
|
|
@ -48,7 +48,6 @@ class Shell extends Object {
|
||||||
* If true, the script will ask for permission to perform actions.
|
* If true, the script will ask for permission to perform actions.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $interactive = true;
|
public $interactive = true;
|
||||||
|
|
||||||
|
@ -56,7 +55,6 @@ class Shell extends Object {
|
||||||
* Contains command switches parsed from the command line.
|
* Contains command switches parsed from the command line.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $params = array();
|
public $params = array();
|
||||||
|
|
||||||
|
@ -144,7 +142,7 @@ class Shell extends Object {
|
||||||
* @param ConsoleOutput $stderr A ConsoleOutput object for stderr.
|
* @param ConsoleOutput $stderr A ConsoleOutput object for stderr.
|
||||||
* @param ConsoleInput $stdin A ConsoleInput object for stdin.
|
* @param ConsoleInput $stdin A ConsoleInput object for stdin.
|
||||||
*/
|
*/
|
||||||
function __construct($stdout = null, $stderr = null, $stdin = null) {
|
public function __construct($stdout = null, $stderr = null, $stdin = null) {
|
||||||
if ($this->name == null) {
|
if ($this->name == null) {
|
||||||
$this->name = Inflector::camelize(str_replace(array('Shell', 'Task'), '', get_class($this)));
|
$this->name = Inflector::camelize(str_replace(array('Shell', 'Task'), '', get_class($this)));
|
||||||
}
|
}
|
||||||
|
@ -216,7 +214,7 @@ class Shell extends Object {
|
||||||
* makes $this->AppModel available to subclasses
|
* makes $this->AppModel available to subclasses
|
||||||
* If public $uses is an array of models will load those models
|
* If public $uses is an array of models will load those models
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function _loadModels() {
|
protected function _loadModels() {
|
||||||
if ($this->uses === null || $this->uses === false) {
|
if ($this->uses === null || $this->uses === false) {
|
||||||
|
@ -245,7 +243,7 @@ class Shell extends Object {
|
||||||
/**
|
/**
|
||||||
* Loads tasks defined in public $tasks
|
* Loads tasks defined in public $tasks
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function loadTasks() {
|
public function loadTasks() {
|
||||||
if ($this->tasks === true || empty($this->tasks) || empty($this->Tasks)) {
|
if ($this->tasks === true || empty($this->tasks) || empty($this->Tasks)) {
|
||||||
|
@ -310,9 +308,7 @@ class Shell extends Object {
|
||||||
*
|
*
|
||||||
* `return $this->dispatchShell('schema', 'create', 'i18n', '--dry');`
|
* `return $this->dispatchShell('schema', 'create', 'i18n', '--dry');`
|
||||||
*
|
*
|
||||||
* @param mixed $command Either an array of args similar to $argv. Or a string command, that can be
|
* @return mixed The return of the other shell.
|
||||||
* exploded on space to simulate argv.
|
|
||||||
* @return mixed. The return of the other shell.
|
|
||||||
*/
|
*/
|
||||||
public function dispatchShell() {
|
public function dispatchShell() {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
@ -383,6 +379,7 @@ class Shell extends Object {
|
||||||
/**
|
/**
|
||||||
* Display the help in the correct format
|
* Display the help in the correct format
|
||||||
*
|
*
|
||||||
|
* @param string $command
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _displayHelp($command) {
|
protected function _displayHelp($command) {
|
||||||
|
@ -410,7 +407,8 @@ class Shell extends Object {
|
||||||
/**
|
/**
|
||||||
* Overload get for lazy building of tasks
|
* Overload get for lazy building of tasks
|
||||||
*
|
*
|
||||||
* @return void
|
* @param string $name
|
||||||
|
* @return Shell Object of Task
|
||||||
*/
|
*/
|
||||||
public function __get($name) {
|
public function __get($name) {
|
||||||
if (empty($this->{$name}) && in_array($name, $this->taskNames)) {
|
if (empty($this->{$name}) && in_array($name, $this->taskNames)) {
|
||||||
|
@ -430,7 +428,7 @@ class Shell extends Object {
|
||||||
* @param string $prompt Prompt text.
|
* @param string $prompt Prompt text.
|
||||||
* @param mixed $options Array or string of options.
|
* @param mixed $options Array or string of options.
|
||||||
* @param string $default Default input value.
|
* @param string $default Default input value.
|
||||||
* @return Either the default value, or the user-provided input.
|
* @return mixed Either the default value, or the user-provided input.
|
||||||
*/
|
*/
|
||||||
public function in($prompt, $options = null, $default = null) {
|
public function in($prompt, $options = null, $default = null) {
|
||||||
if (!$this->interactive) {
|
if (!$this->interactive) {
|
||||||
|
@ -523,7 +521,7 @@ class Shell extends Object {
|
||||||
* @param mixed $message A string or a an array of strings to output
|
* @param mixed $message A string or a an array of strings to output
|
||||||
* @param integer $newlines Number of newlines to append
|
* @param integer $newlines Number of newlines to append
|
||||||
* @param integer $level The message's output level, see above.
|
* @param integer $level The message's output level, see above.
|
||||||
* @return integer Returns the number of bytes returned from writing to stdout.
|
* @return integer|boolean Returns the number of bytes returned from writing to stdout.
|
||||||
*/
|
*/
|
||||||
public function out($message = null, $newlines = 1, $level = Shell::NORMAL) {
|
public function out($message = null, $newlines = 1, $level = Shell::NORMAL) {
|
||||||
$currentLevel = Shell::NORMAL;
|
$currentLevel = Shell::NORMAL;
|
||||||
|
@ -545,6 +543,7 @@ class Shell extends Object {
|
||||||
*
|
*
|
||||||
* @param mixed $message A string or a an array of strings to output
|
* @param mixed $message A string or a an array of strings to output
|
||||||
* @param integer $newlines Number of newlines to append
|
* @param integer $newlines Number of newlines to append
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function err($message = null, $newlines = 1) {
|
public function err($message = null, $newlines = 1) {
|
||||||
$this->stderr->write($message, $newlines);
|
$this->stderr->write($message, $newlines);
|
||||||
|
@ -554,7 +553,6 @@ class Shell extends Object {
|
||||||
* Returns a single or multiple linefeeds sequences.
|
* Returns a single or multiple linefeeds sequences.
|
||||||
*
|
*
|
||||||
* @param integer $multiplier Number of times the linefeed sequence should be repeated
|
* @param integer $multiplier Number of times the linefeed sequence should be repeated
|
||||||
* @access public
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function nl($multiplier = 1) {
|
public function nl($multiplier = 1) {
|
||||||
|
@ -566,6 +564,7 @@ class Shell extends Object {
|
||||||
*
|
*
|
||||||
* @param integer $newlines Number of newlines to pre- and append
|
* @param integer $newlines Number of newlines to pre- and append
|
||||||
* @param integer $width Width of the line, defaults to 63
|
* @param integer $width Width of the line, defaults to 63
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function hr($newlines = 0, $width = 63) {
|
public function hr($newlines = 0, $width = 63) {
|
||||||
$this->out(null, $newlines);
|
$this->out(null, $newlines);
|
||||||
|
@ -579,6 +578,7 @@ class Shell extends Object {
|
||||||
*
|
*
|
||||||
* @param string $title Title of the error
|
* @param string $title Title of the error
|
||||||
* @param string $message An optional error message
|
* @param string $message An optional error message
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function error($title, $message = null) {
|
public function error($title, $message = null) {
|
||||||
$this->err(__d('cake_console', '<error>Error:</error> %s', $title));
|
$this->err(__d('cake_console', '<error>Error:</error> %s', $title));
|
||||||
|
@ -670,7 +670,7 @@ class Shell extends Object {
|
||||||
* Makes absolute file path easier to read
|
* Makes absolute file path easier to read
|
||||||
*
|
*
|
||||||
* @param string $file Absolute file path
|
* @param string $file Absolute file path
|
||||||
* @return sting short path
|
* @return string short path
|
||||||
*/
|
*/
|
||||||
public function shortPath($file) {
|
public function shortPath($file) {
|
||||||
$shortPath = str_replace(ROOT, null, $file);
|
$shortPath = str_replace(ROOT, null, $file);
|
||||||
|
@ -774,7 +774,7 @@ class Shell extends Object {
|
||||||
* @param string $pluginName Name of the plugin you want ie. DebugKit
|
* @param string $pluginName Name of the plugin you want ie. DebugKit
|
||||||
* @return string $path path to the correct plugin.
|
* @return string $path path to the correct plugin.
|
||||||
*/
|
*/
|
||||||
function _pluginPath($pluginName) {
|
protected function _pluginPath($pluginName) {
|
||||||
if (CakePlugin::loaded($pluginName)) {
|
if (CakePlugin::loaded($pluginName)) {
|
||||||
return CakePlugin::path($pluginName);
|
return CakePlugin::path($pluginName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,7 @@ class ShellDispatcher {
|
||||||
* a status code of either 0 or 1 according to the result of the dispatch.
|
* a status code of either 0 or 1 according to the result of the dispatch.
|
||||||
*
|
*
|
||||||
* @param array $args the argv from PHP
|
* @param array $args the argv from PHP
|
||||||
* @param bool $bootstrap Should the environment be bootstrapped.
|
* @param boolean $bootstrap Should the environment be bootstrapped.
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct($args = array(), $bootstrap = true) {
|
public function __construct($args = array(), $bootstrap = true) {
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
@ -96,9 +95,10 @@ class ShellDispatcher {
|
||||||
* Defines current working environment.
|
* Defines current working environment.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws CakeException
|
||||||
*/
|
*/
|
||||||
protected function _initEnvironment() {
|
protected function _initEnvironment() {
|
||||||
if (!$this->__bootstrap()) {
|
if (!$this->_bootstrap()) {
|
||||||
$message = "Unable to load CakePHP core.\nMake sure " . DS . 'lib' . DS . 'Cake exists in ' . CAKE_CORE_INCLUDE_PATH;
|
$message = "Unable to load CakePHP core.\nMake sure " . DS . 'lib' . DS . 'Cake exists in ' . CAKE_CORE_INCLUDE_PATH;
|
||||||
throw new CakeException($message);
|
throw new CakeException($message);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ class ShellDispatcher {
|
||||||
*
|
*
|
||||||
* @return boolean Success.
|
* @return boolean Success.
|
||||||
*/
|
*/
|
||||||
private function __bootstrap() {
|
protected function _bootstrap() {
|
||||||
define('ROOT', $this->params['root']);
|
define('ROOT', $this->params['root']);
|
||||||
define('APP_DIR', $this->params['app']);
|
define('APP_DIR', $this->params['app']);
|
||||||
define('APP', $this->params['working'] . DS);
|
define('APP', $this->params['working'] . DS);
|
||||||
|
@ -149,6 +149,7 @@ class ShellDispatcher {
|
||||||
* Dispatches a CLI request
|
* Dispatches a CLI request
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
* @throws MissingShellMethodException
|
||||||
*/
|
*/
|
||||||
public function dispatch() {
|
public function dispatch() {
|
||||||
$shell = $this->shiftArgs();
|
$shell = $this->shiftArgs();
|
||||||
|
@ -198,8 +199,8 @@ class ShellDispatcher {
|
||||||
* All paths in the loaded shell paths are searched.
|
* All paths in the loaded shell paths are searched.
|
||||||
*
|
*
|
||||||
* @param string $shell Optionally the name of a plugin
|
* @param string $shell Optionally the name of a plugin
|
||||||
* @return mixed False if no shell could be found or an object on success
|
* @return mixed An object
|
||||||
* @throws MissingShellFileException, MissingShellClassException when errors are encountered.
|
* @throws MissingShellFileException when errors are encountered.
|
||||||
*/
|
*/
|
||||||
protected function _getShell($shell) {
|
protected function _getShell($shell) {
|
||||||
list($plugin, $shell) = pluginSplit($shell, true);
|
list($plugin, $shell) = pluginSplit($shell, true);
|
||||||
|
@ -221,7 +222,8 @@ class ShellDispatcher {
|
||||||
/**
|
/**
|
||||||
* Parses command line options and extracts the directory paths from $params
|
* Parses command line options and extracts the directory paths from $params
|
||||||
*
|
*
|
||||||
* @param array $params Parameters to parse
|
* @param array $args Parameters to parse
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function parseParams($args) {
|
public function parseParams($args) {
|
||||||
$this->_parsePaths($args);
|
$this->_parsePaths($args);
|
||||||
|
@ -276,6 +278,7 @@ class ShellDispatcher {
|
||||||
/**
|
/**
|
||||||
* Parses out the paths from from the argv
|
* Parses out the paths from from the argv
|
||||||
*
|
*
|
||||||
|
* @param array $args
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _parsePaths($args) {
|
protected function _parsePaths($args) {
|
||||||
|
@ -316,7 +319,7 @@ class ShellDispatcher {
|
||||||
/**
|
/**
|
||||||
* Stop execution of the current script
|
* Stop execution of the current script
|
||||||
*
|
*
|
||||||
* @param $status see http://php.net/exit for values
|
* @param integer|string $status see http://php.net/exit for values
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _stop($status = 0) {
|
protected function _stop($status = 0) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TaskCollection extends ObjectCollection {
|
||||||
/**
|
/**
|
||||||
* Shell to use to set params to tasks.
|
* Shell to use to set params to tasks.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var Shell
|
||||||
*/
|
*/
|
||||||
protected $_Shell;
|
protected $_Shell;
|
||||||
|
|
||||||
|
@ -41,8 +41,7 @@ class TaskCollection extends ObjectCollection {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param array $paths Array of paths to search for tasks on .
|
* @param Shell $Shell
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Shell $Shell) {
|
public function __construct(Shell $Shell) {
|
||||||
$this->_Shell = $Shell;
|
$this->_Shell = $Shell;
|
||||||
|
|
|
@ -24,6 +24,17 @@ echo "<?php\n";
|
||||||
/**
|
/**
|
||||||
* <?php echo $controllerName; ?> Controller
|
* <?php echo $controllerName; ?> Controller
|
||||||
*
|
*
|
||||||
|
<?php
|
||||||
|
if (!$isScaffold) {
|
||||||
|
$defaultModel = Inflector::singularize($controllerName);
|
||||||
|
echo " * @property {$defaultModel} \${$defaultModel}\n";
|
||||||
|
if (!empty($components)) {
|
||||||
|
foreach ($components as $component) {
|
||||||
|
echo " * @property {$component}Component \${$component}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
*/
|
*/
|
||||||
class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>AppController {
|
class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>AppController {
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,15 @@ echo "<?php\n"; ?>
|
||||||
/**
|
/**
|
||||||
* <?php echo $name ?> Model
|
* <?php echo $name ?> Model
|
||||||
*
|
*
|
||||||
|
<?php
|
||||||
|
foreach (array('hasOne', 'belongsTo', 'hasMany', 'hasAndBelongsToMany') as $assocType) {
|
||||||
|
if (!empty($associations[$assocType])) {
|
||||||
|
foreach ($associations[$assocType] as $relation) {
|
||||||
|
echo " * @property {$relation['className']} \${$relation['alias']}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
*/
|
*/
|
||||||
class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
|
class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
|
||||||
<?php if ($useDbConfig != 'default'): ?>
|
<?php if ($useDbConfig != 'default'): ?>
|
||||||
|
|
|
@ -32,7 +32,6 @@ class PagesController extends AppController {
|
||||||
* Controller name
|
* Controller name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $name = 'Pages';
|
public $name = 'Pages';
|
||||||
|
|
||||||
|
@ -40,7 +39,6 @@ class PagesController extends AppController {
|
||||||
* Default helper
|
* Default helper
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $helpers = array('Html');
|
public $helpers = array('Html');
|
||||||
|
|
||||||
|
@ -48,7 +46,6 @@ class PagesController extends AppController {
|
||||||
* This controller does not use a model
|
* This controller does not use a model
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $uses = array();
|
public $uses = array();
|
||||||
|
|
||||||
|
@ -56,7 +53,6 @@ class PagesController extends AppController {
|
||||||
* Displays a view
|
* Displays a view
|
||||||
*
|
*
|
||||||
* @param mixed What page to display
|
* @param mixed What page to display
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function display() {
|
public function display() {
|
||||||
$path = func_get_args();
|
$path = func_get_args();
|
||||||
|
|
|
@ -4,9 +4,27 @@
|
||||||
*
|
*
|
||||||
* Controller used by ErrorHandler to render error views.
|
* Controller used by ErrorHandler to render error views.
|
||||||
*
|
*
|
||||||
|
* PHP 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||||
|
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
|
* @link http://cakephp.org CakePHP(tm) Project
|
||||||
* @package Cake.Controller
|
* @package Cake.Controller
|
||||||
|
* @since CakePHP(tm) v 2.0
|
||||||
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
*/
|
*/
|
||||||
class CakeErrorController extends AppController {
|
class CakeErrorController extends AppController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $name = 'CakeError';
|
public $name = 'CakeError';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,8 +37,8 @@ class CakeErrorController extends AppController {
|
||||||
/**
|
/**
|
||||||
* __construct
|
* __construct
|
||||||
*
|
*
|
||||||
* @access public
|
* @param CakeRequest $request
|
||||||
* @return void
|
* @param CakeResponse $response
|
||||||
*/
|
*/
|
||||||
public function __construct($request = null, $response = null) {
|
public function __construct($request = null, $response = null) {
|
||||||
parent::__construct($request, $response);
|
parent::__construct($request, $response);
|
||||||
|
|
|
@ -86,7 +86,7 @@ class Component extends Object {
|
||||||
/**
|
/**
|
||||||
* Magic method for lazy loading $components.
|
* Magic method for lazy loading $components.
|
||||||
*
|
*
|
||||||
* @param sting $name Name of component to get.
|
* @param string $name Name of component to get.
|
||||||
* @return mixed A Component object or null.
|
* @return mixed A Component object or null.
|
||||||
*/
|
*/
|
||||||
public function __get($name) {
|
public function __get($name) {
|
||||||
|
@ -102,7 +102,7 @@ class Component extends Object {
|
||||||
/**
|
/**
|
||||||
* Called before the Controller::beforeFilter().
|
* Called before the Controller::beforeFilter().
|
||||||
*
|
*
|
||||||
* @param object $controller Controller with components to initialize
|
* @param Controller $controller Controller with components to initialize
|
||||||
* @return void
|
* @return void
|
||||||
* @link http://book.cakephp.org/view/998/MVC-Class-Access-Within-Components
|
* @link http://book.cakephp.org/view/998/MVC-Class-Access-Within-Components
|
||||||
*/
|
*/
|
||||||
|
@ -111,7 +111,7 @@ class Component extends Object {
|
||||||
/**
|
/**
|
||||||
* Called after the Controller::beforeFilter() and before the controller action
|
* Called after the Controller::beforeFilter() and before the controller action
|
||||||
*
|
*
|
||||||
* @param object $controller Controller with components to startup
|
* @param Controller $controller Controller with components to startup
|
||||||
* @return void
|
* @return void
|
||||||
* @link http://book.cakephp.org/view/998/MVC-Class-Access-Within-Components
|
* @link http://book.cakephp.org/view/998/MVC-Class-Access-Within-Components
|
||||||
*/
|
*/
|
||||||
|
@ -121,7 +121,7 @@ class Component extends Object {
|
||||||
* Called after the Controller::beforeRender(), after the view class is loaded, and before the
|
* Called after the Controller::beforeRender(), after the view class is loaded, and before the
|
||||||
* Controller::render()
|
* Controller::render()
|
||||||
*
|
*
|
||||||
* @param object $controller Controller with components to beforeRender
|
* @param Controller $controller Controller with components to beforeRender
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function beforeRender($controller) { }
|
public function beforeRender($controller) { }
|
||||||
|
@ -129,7 +129,7 @@ class Component extends Object {
|
||||||
/**
|
/**
|
||||||
* Called after Controller::render() and before the output is printed to the browser.
|
* Called after Controller::render() and before the output is printed to the browser.
|
||||||
*
|
*
|
||||||
* @param object $controller Controller with components to shutdown
|
* @param Controller $controller Controller with components to shutdown
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function shutdown($controller) { }
|
public function shutdown($controller) { }
|
||||||
|
@ -146,11 +146,11 @@ class Component extends Object {
|
||||||
* If your response is a string or an array that does not contain a 'url' key it will
|
* If your response is a string or an array that does not contain a 'url' key it will
|
||||||
* be used as the new url to redirect to.
|
* be used as the new url to redirect to.
|
||||||
*
|
*
|
||||||
* @param object $controller Controller with components to beforeRedirect
|
* @param Controller $controller Controller with components to beforeRedirect
|
||||||
* @param mixed $url Either the string or url array that is being redirected to.
|
* @param string|array $url Either the string or url array that is being redirected to.
|
||||||
* @param int $status The status code of the redirect
|
* @param integer $status The status code of the redirect
|
||||||
* @param bool $exit Will the script exit.
|
* @param boolean $exit Will the script exit.
|
||||||
* @return mixed Either an array or null.
|
* @return array|null Either an array or null.
|
||||||
*/
|
*/
|
||||||
public function beforeRedirect($controller, $url, $status = null, $exit = true) {}
|
public function beforeRedirect($controller, $url, $status = null, $exit = true) {}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,7 @@ class AclComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Instance of an ACL class
|
* Instance of an ACL class
|
||||||
*
|
*
|
||||||
* @var object
|
* @var AclInterface
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_Instance = null;
|
protected $_Instance = null;
|
||||||
|
|
||||||
|
@ -58,6 +57,8 @@ class AclComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Constructor. Will return an instance of the correct ACL class as defined in `Configure::read('Acl.classname')`
|
* Constructor. Will return an instance of the correct ACL class as defined in `Configure::read('Acl.classname')`
|
||||||
*
|
*
|
||||||
|
* @param ComponentCollection $collection
|
||||||
|
* @param array $settings
|
||||||
* @throws CakeException when Acl.classname could not be loaded.
|
* @throws CakeException when Acl.classname could not be loaded.
|
||||||
*/
|
*/
|
||||||
public function __construct(ComponentCollection $collection, $settings = array()) {
|
public function __construct(ComponentCollection $collection, $settings = array()) {
|
||||||
|
@ -262,7 +263,7 @@ class DbAcl extends Object implements AclInterface {
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
App::uses('AclNode', 'Model');
|
App::uses('AclNode', 'Model');
|
||||||
$this->Aro = ClassRegistry::init(array('class' => 'Aro', 'alias' => 'Aro'));
|
$this->Aro = ClassRegistry::init(array('class' => 'Aro', 'alias' => 'Aro'));
|
||||||
|
@ -424,7 +425,7 @@ class DbAcl extends Object implements AclInterface {
|
||||||
*
|
*
|
||||||
* @param string $aro ARO The requesting object identifier.
|
* @param string $aro ARO The requesting object identifier.
|
||||||
* @param string $aco ACO The controlled object identifier.
|
* @param string $aco ACO The controlled object identifier.
|
||||||
* @param string $actions Action (defaults to *)
|
* @param string $action Action (defaults to *)
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @link http://book.cakephp.org/view/1248/Assigning-Permissions
|
* @link http://book.cakephp.org/view/1248/Assigning-Permissions
|
||||||
*/
|
*/
|
||||||
|
@ -437,7 +438,7 @@ class DbAcl extends Object implements AclInterface {
|
||||||
*
|
*
|
||||||
* @param string $aro ARO The requesting object identifier.
|
* @param string $aro ARO The requesting object identifier.
|
||||||
* @param string $aco ACO The controlled object identifier.
|
* @param string $aco ACO The controlled object identifier.
|
||||||
* @param string $actions Action (defaults to *)
|
* @param string $action Action (defaults to *)
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function inherit($aro, $aco, $action = "*") {
|
public function inherit($aro, $aco, $action = "*") {
|
||||||
|
@ -449,7 +450,7 @@ class DbAcl extends Object implements AclInterface {
|
||||||
*
|
*
|
||||||
* @param string $aro ARO The requesting object identifier.
|
* @param string $aro ARO The requesting object identifier.
|
||||||
* @param string $aco ACO The controlled object identifier.
|
* @param string $aco ACO The controlled object identifier.
|
||||||
* @param string $actions Action (defaults to *)
|
* @param string $action Action (defaults to *)
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @see allow()
|
* @see allow()
|
||||||
*/
|
*/
|
||||||
|
@ -462,7 +463,7 @@ class DbAcl extends Object implements AclInterface {
|
||||||
*
|
*
|
||||||
* @param string $aro ARO The requesting object identifier.
|
* @param string $aro ARO The requesting object identifier.
|
||||||
* @param string $aco ACO The controlled object identifier.
|
* @param string $aco ACO The controlled object identifier.
|
||||||
* @param string $actions Action (defaults to *)
|
* @param string $action Action (defaults to *)
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @see deny()
|
* @see deny()
|
||||||
*/
|
*/
|
||||||
|
@ -526,7 +527,6 @@ class IniAcl extends Object implements AclInterface {
|
||||||
* Array with configuration, parsed from ini file
|
* Array with configuration, parsed from ini file
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $config = null;
|
public $config = null;
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ abstract class BaseAuthorize {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param Controller $controller The controller for this request.
|
* @param ComponentCollection $collection The controller for this request.
|
||||||
* @param string $settings An array of settings. This class does not use any settings.
|
* @param string $settings An array of settings. This class does not use any settings.
|
||||||
*/
|
*/
|
||||||
public function __construct(ComponentCollection $collection, $settings = array()) {
|
public function __construct(ComponentCollection $collection, $settings = array()) {
|
||||||
|
@ -84,7 +84,8 @@ abstract class BaseAuthorize {
|
||||||
* Accessor to the controller object.
|
* Accessor to the controller object.
|
||||||
*
|
*
|
||||||
* @param mixed $controller null to get, a controller to set.
|
* @param mixed $controller null to get, a controller to set.
|
||||||
* @return mixed.
|
* @return mixed
|
||||||
|
* @throws CakeException
|
||||||
*/
|
*/
|
||||||
public function controller($controller = null) {
|
public function controller($controller = null) {
|
||||||
if ($controller) {
|
if ($controller) {
|
||||||
|
@ -102,6 +103,7 @@ abstract class BaseAuthorize {
|
||||||
* that need to get information about the plugin, controller, and action being invoked.
|
* that need to get information about the plugin, controller, and action being invoked.
|
||||||
*
|
*
|
||||||
* @param CakeRequest $request The request a path is needed for.
|
* @param CakeRequest $request The request a path is needed for.
|
||||||
|
* @param string $path
|
||||||
* @return string the action path for the given request.
|
* @return string the action path for the given request.
|
||||||
*/
|
*/
|
||||||
public function action($request, $path = '/:plugin/:controller/:action') {
|
public function action($request, $path = '/:plugin/:controller/:action') {
|
||||||
|
|
|
@ -27,7 +27,7 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
|
||||||
*
|
*
|
||||||
* In your controller's components array, add auth + the required settings.
|
* In your controller's components array, add auth + the required settings.
|
||||||
* {{{
|
* {{{
|
||||||
* var $components = array(
|
* public $components = array(
|
||||||
* 'Auth' => array(
|
* 'Auth' => array(
|
||||||
* 'authenticate' => array('Basic')
|
* 'authenticate' => array('Basic')
|
||||||
* )
|
* )
|
||||||
|
|
|
@ -41,7 +41,8 @@ class ControllerAuthorize extends BaseAuthorize {
|
||||||
* Get/set the controller this authorize object will be working with. Also checks that isAuthorized is implemented.
|
* Get/set the controller this authorize object will be working with. Also checks that isAuthorized is implemented.
|
||||||
*
|
*
|
||||||
* @param mixed $controller null to get, a controller to set.
|
* @param mixed $controller null to get, a controller to set.
|
||||||
* @return mixed.
|
* @return mixed
|
||||||
|
* @throws CakeException
|
||||||
*/
|
*/
|
||||||
public function controller($controller = null) {
|
public function controller($controller = null) {
|
||||||
if ($controller) {
|
if ($controller) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
|
||||||
*
|
*
|
||||||
* In your controller's components array, add auth + the required settings.
|
* In your controller's components array, add auth + the required settings.
|
||||||
* {{{
|
* {{{
|
||||||
* var $components = array(
|
* public $components = array(
|
||||||
* 'Auth' => array(
|
* 'Auth' => array(
|
||||||
* 'authenticate' => array('Digest')
|
* 'authenticate' => array('Digest')
|
||||||
* )
|
* )
|
||||||
|
|
|
@ -240,7 +240,7 @@ class AuthComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Initializes AuthComponent for use in the controller
|
* Initializes AuthComponent for use in the controller
|
||||||
*
|
*
|
||||||
* @param object $controller A reference to the instantiating controller object
|
* @param Controller $controller A reference to the instantiating controller object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize($controller) {
|
public function initialize($controller) {
|
||||||
|
@ -257,7 +257,7 @@ class AuthComponent extends Component {
|
||||||
* Main execution method. Handles redirecting of invalid users, and processing
|
* Main execution method. Handles redirecting of invalid users, and processing
|
||||||
* of login form data.
|
* of login form data.
|
||||||
*
|
*
|
||||||
* @param object $controller A reference to the instantiating controller object
|
* @param Controller $controller A reference to the instantiating controller object
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function startup($controller) {
|
public function startup($controller) {
|
||||||
|
@ -277,7 +277,7 @@ class AuthComponent extends Component {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->__setDefaults()) {
|
if (!$this->_setDefaults()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$request = $controller->request;
|
$request = $controller->request;
|
||||||
|
@ -337,11 +337,9 @@ class AuthComponent extends Component {
|
||||||
* Attempts to introspect the correct values for object properties including
|
* Attempts to introspect the correct values for object properties including
|
||||||
* $userModel and $sessionKey.
|
* $userModel and $sessionKey.
|
||||||
*
|
*
|
||||||
* @param object $controller A reference to the instantiating controller object
|
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __setDefaults() {
|
protected function _setDefaults() {
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'logoutRedirect' => $this->loginAction,
|
'logoutRedirect' => $this->loginAction,
|
||||||
'authError' => __d('cake', 'You are not authorized to access that location.')
|
'authError' => __d('cake', 'You are not authorized to access that location.')
|
||||||
|
@ -387,6 +385,7 @@ class AuthComponent extends Component {
|
||||||
* Loads the authorization objects configured.
|
* Loads the authorization objects configured.
|
||||||
*
|
*
|
||||||
* @return mixed Either null when authorize is empty, or the loaded authorization objects.
|
* @return mixed Either null when authorize is empty, or the loaded authorization objects.
|
||||||
|
* @throws CakeException
|
||||||
*/
|
*/
|
||||||
public function constructAuthorize() {
|
public function constructAuthorize() {
|
||||||
if (empty($this->authorize)) {
|
if (empty($this->authorize)) {
|
||||||
|
@ -428,13 +427,11 @@ class AuthComponent extends Component {
|
||||||
*
|
*
|
||||||
* `$this->Auth->allow('*');`
|
* `$this->Auth->allow('*');`
|
||||||
*
|
*
|
||||||
* @param mixed $action Controller action name or array of actions
|
* @param mixed $action,... Controller action name or array of actions
|
||||||
* @param string $action Controller action name
|
|
||||||
* @param string ... etc.
|
|
||||||
* @return void
|
* @return void
|
||||||
* @link http://book.cakephp.org/view/1257/allow
|
* @link http://book.cakephp.org/view/1257/allow
|
||||||
*/
|
*/
|
||||||
public function allow() {
|
public function allow($action) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
if (empty($args) || $args == array('*')) {
|
if (empty($args) || $args == array('*')) {
|
||||||
$this->allowedActions = $this->_methods;
|
$this->allowedActions = $this->_methods;
|
||||||
|
@ -454,14 +451,12 @@ class AuthComponent extends Component {
|
||||||
* `$this->Auth->deny(array('edit', 'add'));` or
|
* `$this->Auth->deny(array('edit', 'add'));` or
|
||||||
* `$this->Auth->deny('edit', 'add');`
|
* `$this->Auth->deny('edit', 'add');`
|
||||||
*
|
*
|
||||||
* @param mixed $action Controller action name or array of actions
|
* @param mixed $action,... Controller action name or array of actions
|
||||||
* @param string $action Controller action name
|
|
||||||
* @param string ... etc.
|
|
||||||
* @return void
|
* @return void
|
||||||
* @see AuthComponent::allow()
|
* @see AuthComponent::allow()
|
||||||
* @link http://book.cakephp.org/view/1258/deny
|
* @link http://book.cakephp.org/view/1258/deny
|
||||||
*/
|
*/
|
||||||
public function deny() {
|
public function deny($action) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
if (isset($args[0]) && is_array($args[0])) {
|
if (isset($args[0]) && is_array($args[0])) {
|
||||||
$args = $args[0];
|
$args = $args[0];
|
||||||
|
@ -503,7 +498,7 @@ class AuthComponent extends Component {
|
||||||
* @link http://book.cakephp.org/view/1261/login
|
* @link http://book.cakephp.org/view/1261/login
|
||||||
*/
|
*/
|
||||||
public function login($user = null) {
|
public function login($user = null) {
|
||||||
$this->__setDefaults();
|
$this->_setDefaults();
|
||||||
|
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
$user = $this->identify($this->request, $this->response);
|
$user = $this->identify($this->request, $this->response);
|
||||||
|
@ -520,13 +515,12 @@ class AuthComponent extends Component {
|
||||||
* custom logout logic. AuthComponent will remove the session data, so
|
* custom logout logic. AuthComponent will remove the session data, so
|
||||||
* there is no need to do that in an authentication object.
|
* there is no need to do that in an authentication object.
|
||||||
*
|
*
|
||||||
* @param mixed $url Optional URL to redirect the user to after logout
|
* @return string AuthComponent::$logoutRedirect
|
||||||
* @return string AuthComponent::$loginAction
|
* @see AuthComponent::$logoutRedirect
|
||||||
* @see AuthComponent::$loginAction
|
|
||||||
* @link http://book.cakephp.org/view/1262/logout
|
* @link http://book.cakephp.org/view/1262/logout
|
||||||
*/
|
*/
|
||||||
public function logout() {
|
public function logout() {
|
||||||
$this->__setDefaults();
|
$this->_setDefaults();
|
||||||
if (empty($this->_authenticateObjects)) {
|
if (empty($this->_authenticateObjects)) {
|
||||||
$this->constructAuthenticate();
|
$this->constructAuthenticate();
|
||||||
}
|
}
|
||||||
|
@ -615,6 +609,7 @@ class AuthComponent extends Component {
|
||||||
* by credentials contained in $request.
|
* by credentials contained in $request.
|
||||||
*
|
*
|
||||||
* @param CakeRequest $request The request that contains authentication data.
|
* @param CakeRequest $request The request that contains authentication data.
|
||||||
|
* @param CakeResponse $response The response
|
||||||
* @return array User record data, or false, if the user could not be identified.
|
* @return array User record data, or false, if the user could not be identified.
|
||||||
*/
|
*/
|
||||||
public function identify(CakeRequest $request, CakeResponse $response) {
|
public function identify(CakeRequest $request, CakeResponse $response) {
|
||||||
|
@ -634,6 +629,7 @@ class AuthComponent extends Component {
|
||||||
* loads the configured authentication objects.
|
* loads the configured authentication objects.
|
||||||
*
|
*
|
||||||
* @return mixed either null on empty authenticate value, or an array of loaded objects.
|
* @return mixed either null on empty authenticate value, or an array of loaded objects.
|
||||||
|
* @throws CakeException
|
||||||
*/
|
*/
|
||||||
public function constructAuthenticate() {
|
public function constructAuthenticate() {
|
||||||
if (empty($this->authenticate)) {
|
if (empty($this->authenticate)) {
|
||||||
|
@ -676,7 +672,8 @@ class AuthComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Component shutdown. If user is logged in, wipe out redirect.
|
* Component shutdown. If user is logged in, wipe out redirect.
|
||||||
*
|
*
|
||||||
* @param object $controller Instantiating controller
|
* @param Controller $controller Instantiating controller
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function shutdown($controller) {
|
public function shutdown($controller) {
|
||||||
if ($this->loggedIn()) {
|
if ($this->loggedIn()) {
|
||||||
|
@ -688,7 +685,6 @@ class AuthComponent extends Component {
|
||||||
* Check whether or not the current user has data in the session, and is considered logged in.
|
* Check whether or not the current user has data in the session, and is considered logged in.
|
||||||
*
|
*
|
||||||
* @return boolean true if the user is logged in, false otherwise
|
* @return boolean true if the user is logged in, false otherwise
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function loggedIn() {
|
public function loggedIn() {
|
||||||
return $this->user() != array();
|
return $this->user() != array();
|
||||||
|
|
|
@ -38,7 +38,6 @@ class CookieComponent extends Component {
|
||||||
* $this->Cookie->name = 'CookieName';
|
* $this->Cookie->name = 'CookieName';
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $name = 'CakeCookie';
|
public $name = 'CakeCookie';
|
||||||
|
|
||||||
|
@ -51,7 +50,6 @@ class CookieComponent extends Component {
|
||||||
* $this->Cookie->time = '5 Days';
|
* $this->Cookie->time = '5 Days';
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var mixed
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $time = null;
|
public $time = null;
|
||||||
|
|
||||||
|
@ -67,7 +65,6 @@ class CookieComponent extends Component {
|
||||||
* The default value is the entire domain.
|
* The default value is the entire domain.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $path = '/';
|
public $path = '/';
|
||||||
|
|
||||||
|
@ -83,7 +80,6 @@ class CookieComponent extends Component {
|
||||||
* Set $this->Cookie->domain = '.example.com'; in your controller beforeFilter
|
* Set $this->Cookie->domain = '.example.com'; in your controller beforeFilter
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $domain = '';
|
public $domain = '';
|
||||||
|
|
||||||
|
@ -97,7 +93,6 @@ class CookieComponent extends Component {
|
||||||
* When set to true, the cookie will only be set if a secure connection exists.
|
* When set to true, the cookie will only be set if a secure connection exists.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $secure = false;
|
public $secure = false;
|
||||||
|
|
||||||
|
@ -108,7 +103,6 @@ class CookieComponent extends Component {
|
||||||
* $this->Cookie->key = 'SomeRandomString';
|
* $this->Cookie->key = 'SomeRandomString';
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
public $key = null;
|
public $key = null;
|
||||||
|
|
||||||
|
@ -129,7 +123,6 @@ class CookieComponent extends Component {
|
||||||
*
|
*
|
||||||
* @see CookieComponent::read();
|
* @see CookieComponent::read();
|
||||||
* @var string
|
* @var string
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
protected $_values = array();
|
protected $_values = array();
|
||||||
|
|
||||||
|
@ -140,7 +133,6 @@ class CookieComponent extends Component {
|
||||||
* Defaults to Security::cipher();
|
* Defaults to Security::cipher();
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access private
|
|
||||||
* @todo add additional encryption methods
|
* @todo add additional encryption methods
|
||||||
*/
|
*/
|
||||||
protected $_type = 'cipher';
|
protected $_type = 'cipher';
|
||||||
|
@ -149,7 +141,6 @@ class CookieComponent extends Component {
|
||||||
* Used to reset cookie time if $expire is passed to CookieComponent::write()
|
* Used to reset cookie time if $expire is passed to CookieComponent::write()
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
protected $_reset = null;
|
protected $_reset = null;
|
||||||
|
|
||||||
|
@ -159,7 +150,6 @@ class CookieComponent extends Component {
|
||||||
* This is controlled by CookieComponent::time;
|
* This is controlled by CookieComponent::time;
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
protected $_expires = 0;
|
protected $_expires = 0;
|
||||||
|
|
||||||
|
@ -180,6 +170,8 @@ class CookieComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Start CookieComponent for use in the controller
|
* Start CookieComponent for use in the controller
|
||||||
*
|
*
|
||||||
|
* @param Controller $controller
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startup($controller) {
|
public function startup($controller) {
|
||||||
$this->_expire($this->time);
|
$this->_expire($this->time);
|
||||||
|
@ -205,6 +197,7 @@ class CookieComponent extends Component {
|
||||||
* @param mixed $value Value
|
* @param mixed $value Value
|
||||||
* @param boolean $encrypt Set to true to encrypt value, false otherwise
|
* @param boolean $encrypt Set to true to encrypt value, false otherwise
|
||||||
* @param string $expires Can be either Unix timestamp, or date string
|
* @param string $expires Can be either Unix timestamp, or date string
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function write($key, $value = null, $encrypt = true, $expires = null) {
|
public function write($key, $value = null, $encrypt = true, $expires = null) {
|
||||||
if (is_null($encrypt)) {
|
if (is_null($encrypt)) {
|
||||||
|
@ -327,7 +320,7 @@ class CookieComponent extends Component {
|
||||||
* Will allow overriding default encryption method.
|
* Will allow overriding default encryption method.
|
||||||
*
|
*
|
||||||
* @param string $type Encryption method
|
* @param string $type Encryption method
|
||||||
* @access public
|
* @return void
|
||||||
* @todo NOT IMPLEMENTED
|
* @todo NOT IMPLEMENTED
|
||||||
*/
|
*/
|
||||||
public function type($type = 'cipher') {
|
public function type($type = 'cipher') {
|
||||||
|
@ -345,7 +338,7 @@ class CookieComponent extends Component {
|
||||||
* CookieComponent::write(string, string, boolean, '5 Days');
|
* CookieComponent::write(string, string, boolean, '5 Days');
|
||||||
*
|
*
|
||||||
* @param mixed $expires Can be either Unix timestamp, or date string
|
* @param mixed $expires Can be either Unix timestamp, or date string
|
||||||
* @return int Unix timestamp
|
* @return integer Unix timestamp
|
||||||
*/
|
*/
|
||||||
protected function _expire($expires = null) {
|
protected function _expire($expires = null) {
|
||||||
$now = time();
|
$now = time();
|
||||||
|
@ -369,6 +362,7 @@ class CookieComponent extends Component {
|
||||||
*
|
*
|
||||||
* @param string $name Name for cookie
|
* @param string $name Name for cookie
|
||||||
* @param string $value Value for cookie
|
* @param string $value Value for cookie
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _write($name, $value) {
|
protected function _write($name, $value) {
|
||||||
$this->_setcookie(
|
$this->_setcookie(
|
||||||
|
@ -402,6 +396,7 @@ class CookieComponent extends Component {
|
||||||
* of the HTTP response, and should be handled there.
|
* of the HTTP response, and should be handled there.
|
||||||
*
|
*
|
||||||
* @param string $name Name of the cookie
|
* @param string $name Name of the cookie
|
||||||
|
* @param string $value Value of the cookie
|
||||||
* @param integer $expire Time the cookie expires in
|
* @param integer $expire Time the cookie expires in
|
||||||
* @param string $path Path the cookie applies to
|
* @param string $path Path the cookie applies to
|
||||||
* @param string $domain Domain the cookie is for.
|
* @param string $domain Domain the cookie is for.
|
||||||
|
|
|
@ -37,7 +37,6 @@ class EmailComponent extends Component {
|
||||||
* Recipient of the email
|
* Recipient of the email
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $to = null;
|
public $to = null;
|
||||||
|
|
||||||
|
@ -45,7 +44,6 @@ class EmailComponent extends Component {
|
||||||
* The mail which the email is sent from
|
* The mail which the email is sent from
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $from = null;
|
public $from = null;
|
||||||
|
|
||||||
|
@ -53,7 +51,6 @@ class EmailComponent extends Component {
|
||||||
* The email the recipient will reply to
|
* The email the recipient will reply to
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $replyTo = null;
|
public $replyTo = null;
|
||||||
|
|
||||||
|
@ -61,7 +58,6 @@ class EmailComponent extends Component {
|
||||||
* The read receipt email
|
* The read receipt email
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $readReceipt = null;
|
public $readReceipt = null;
|
||||||
|
|
||||||
|
@ -72,7 +68,6 @@ class EmailComponent extends Component {
|
||||||
* - Unknown user
|
* - Unknown user
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $return = null;
|
public $return = null;
|
||||||
|
|
||||||
|
@ -83,7 +78,6 @@ class EmailComponent extends Component {
|
||||||
* The Recipient WILL be able to see this list
|
* The Recipient WILL be able to see this list
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $cc = array();
|
public $cc = array();
|
||||||
|
|
||||||
|
@ -94,7 +88,6 @@ class EmailComponent extends Component {
|
||||||
* The Recipient WILL NOT be able to see this list
|
* The Recipient WILL NOT be able to see this list
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $bcc = array();
|
public $bcc = array();
|
||||||
|
|
||||||
|
@ -105,13 +98,12 @@ class EmailComponent extends Component {
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $date = null;
|
public $date = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The subject of the email
|
* The subject of the email
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $subject = null;
|
public $subject = null;
|
||||||
|
|
||||||
|
@ -120,7 +112,6 @@ class EmailComponent extends Component {
|
||||||
* Keys will be prefixed 'X-' as per RFC2822 Section 4.7.5
|
* Keys will be prefixed 'X-' as per RFC2822 Section 4.7.5
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $headers = array();
|
public $headers = array();
|
||||||
|
|
||||||
|
@ -130,7 +121,6 @@ class EmailComponent extends Component {
|
||||||
* These will NOT be used if you are using safemode and mail()
|
* These will NOT be used if you are using safemode and mail()
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $additionalParams = null;
|
public $additionalParams = null;
|
||||||
|
|
||||||
|
@ -138,7 +128,6 @@ class EmailComponent extends Component {
|
||||||
* Layout for the View
|
* Layout for the View
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $layout = 'default';
|
public $layout = 'default';
|
||||||
|
|
||||||
|
@ -146,7 +135,6 @@ class EmailComponent extends Component {
|
||||||
* Template for the view
|
* Template for the view
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $template = null;
|
public $template = null;
|
||||||
|
|
||||||
|
@ -158,7 +146,6 @@ class EmailComponent extends Component {
|
||||||
* (which leads to doubling CR if CRLF is used).
|
* (which leads to doubling CR if CRLF is used).
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $lineFeed = PHP_EOL;
|
public $lineFeed = PHP_EOL;
|
||||||
|
|
||||||
|
@ -171,7 +158,6 @@ class EmailComponent extends Component {
|
||||||
* - both
|
* - both
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $sendAs = 'text';
|
public $sendAs = 'text';
|
||||||
|
|
||||||
|
@ -184,7 +170,6 @@ class EmailComponent extends Component {
|
||||||
* - debug
|
* - debug
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $delivery = 'mail';
|
public $delivery = 'mail';
|
||||||
|
|
||||||
|
@ -192,7 +177,6 @@ class EmailComponent extends Component {
|
||||||
* charset the email is sent in
|
* charset the email is sent in
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $charset = 'utf-8';
|
public $charset = 'utf-8';
|
||||||
|
|
||||||
|
@ -202,7 +186,6 @@ class EmailComponent extends Component {
|
||||||
* Can be both absolute and relative paths
|
* Can be both absolute and relative paths
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $attachments = array();
|
public $attachments = array();
|
||||||
|
|
||||||
|
@ -210,7 +193,6 @@ class EmailComponent extends Component {
|
||||||
* What mailer should EmailComponent identify itself as
|
* What mailer should EmailComponent identify itself as
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $xMailer = 'CakePHP Email Component';
|
public $xMailer = 'CakePHP Email Component';
|
||||||
|
|
||||||
|
@ -218,7 +200,6 @@ class EmailComponent extends Component {
|
||||||
* The list of paths to search if an attachment isnt absolute
|
* The list of paths to search if an attachment isnt absolute
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $filePaths = array();
|
public $filePaths = array();
|
||||||
|
|
||||||
|
@ -234,7 +215,6 @@ class EmailComponent extends Component {
|
||||||
* - client
|
* - client
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
* @link http://book.cakephp.org/view/1290/Sending-A-Message-Using-SMTP
|
* @link http://book.cakephp.org/view/1290/Sending-A-Message-Using-SMTP
|
||||||
*/
|
*/
|
||||||
public $smtpOptions = array();
|
public $smtpOptions = array();
|
||||||
|
@ -243,7 +223,6 @@ class EmailComponent extends Component {
|
||||||
* Contains the rendered plain text message if one was sent.
|
* Contains the rendered plain text message if one was sent.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $textMessage = null;
|
public $textMessage = null;
|
||||||
|
|
||||||
|
@ -251,7 +230,6 @@ class EmailComponent extends Component {
|
||||||
* Contains the rendered HTML message if one was sent.
|
* Contains the rendered HTML message if one was sent.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $htmlMessage = null;
|
public $htmlMessage = null;
|
||||||
|
|
||||||
|
@ -265,14 +243,13 @@ class EmailComponent extends Component {
|
||||||
* could encounter delivery issues if you do not.
|
* could encounter delivery issues if you do not.
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var mixed
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $messageId = true;
|
public $messageId = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller reference
|
* Controller reference
|
||||||
*
|
*
|
||||||
* @var object Controller
|
* @var Controller
|
||||||
*/
|
*/
|
||||||
protected $_controller = null;
|
protected $_controller = null;
|
||||||
|
|
||||||
|
@ -290,7 +267,8 @@ class EmailComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Initialize component
|
* Initialize component
|
||||||
*
|
*
|
||||||
* @param object $controller Instantiating controller
|
* @param Controller $controller Instantiating controller
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize($controller) {
|
public function initialize($controller) {
|
||||||
if (Configure::read('App.encoding') !== null) {
|
if (Configure::read('App.encoding') !== null) {
|
||||||
|
@ -384,6 +362,7 @@ class EmailComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Reset all EmailComponent internal variables to be able to send out a new email.
|
* Reset all EmailComponent internal variables to be able to send out a new email.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
* @link http://book.cakephp.org/view/1285/Sending-Multiple-Emails-in-a-loop
|
* @link http://book.cakephp.org/view/1285/Sending-Multiple-Emails-in-a-loop
|
||||||
*/
|
*/
|
||||||
public function reset() {
|
public function reset() {
|
||||||
|
@ -427,9 +406,8 @@ class EmailComponent extends Component {
|
||||||
*
|
*
|
||||||
* @param string $attachment Attachment file name to find
|
* @param string $attachment Attachment file name to find
|
||||||
* @return string Path to located file
|
* @return string Path to located file
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function _findFiles($attachment) {
|
protected function _findFiles($attachment) {
|
||||||
if (file_exists($attachment)) {
|
if (file_exists($attachment)) {
|
||||||
return $attachment;
|
return $attachment;
|
||||||
}
|
}
|
||||||
|
@ -447,9 +425,8 @@ class EmailComponent extends Component {
|
||||||
*
|
*
|
||||||
* @param string $subject String to encode
|
* @param string $subject String to encode
|
||||||
* @return string Encoded string
|
* @return string Encoded string
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function _encode($subject) {
|
protected function _encode($subject) {
|
||||||
$subject = $this->_strip($subject);
|
$subject = $this->_strip($subject);
|
||||||
|
|
||||||
$nl = "\r\n";
|
$nl = "\r\n";
|
||||||
|
@ -494,9 +471,8 @@ class EmailComponent extends Component {
|
||||||
* @param string $value Value to strip
|
* @param string $value Value to strip
|
||||||
* @param boolean $message Set to true to indicate main message content
|
* @param boolean $message Set to true to indicate main message content
|
||||||
* @return string Stripped value
|
* @return string Stripped value
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function _strip($value, $message = false) {
|
protected function _strip($value, $message = false) {
|
||||||
$search = '%0a|%0d|Content-(?:Type|Transfer-Encoding)\:';
|
$search = '%0a|%0d|Content-(?:Type|Transfer-Encoding)\:';
|
||||||
$search .= '|charset\=|mime-version\:|multipart/mixed|(?:[^a-z]to|b?cc)\:.*';
|
$search .= '|charset\=|mime-version\:|multipart/mixed|(?:[^a-z]to|b?cc)\:.*';
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@ class PaginatorComponent extends Component {
|
||||||
* @param array $whitelist List of allowed fields for ordering. This allows you to prevent ordering
|
* @param array $whitelist List of allowed fields for ordering. This allows you to prevent ordering
|
||||||
* on non-indexed, or undesirable columns.
|
* on non-indexed, or undesirable columns.
|
||||||
* @return array Model query results
|
* @return array Model query results
|
||||||
|
* @throws MissingModelException
|
||||||
*/
|
*/
|
||||||
public function paginate($object = null, $scope = array(), $whitelist = array()) {
|
public function paginate($object = null, $scope = array(), $whitelist = array()) {
|
||||||
if (is_array($object)) {
|
if (is_array($object)) {
|
||||||
|
|
|
@ -72,7 +72,7 @@ class RequestHandlerComponent extends Component {
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $__renderType = null;
|
protected $_renderType = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mapping between extensions and deserializers for request bodies of that type.
|
* A mapping between extensions and deserializers for request bodies of that type.
|
||||||
|
@ -80,7 +80,7 @@ class RequestHandlerComponent extends Component {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $__inputTypeMap = array(
|
protected $_inputTypeMap = array(
|
||||||
'json' => array('json_decode', true)
|
'json' => array('json_decode', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -90,8 +90,8 @@ class RequestHandlerComponent extends Component {
|
||||||
* @param ComponentCollection $collection ComponentCollection object.
|
* @param ComponentCollection $collection ComponentCollection object.
|
||||||
* @param array $settings Array of settings.
|
* @param array $settings Array of settings.
|
||||||
*/
|
*/
|
||||||
function __construct(ComponentCollection $collection, $settings = array()) {
|
public function __construct(ComponentCollection $collection, $settings = array()) {
|
||||||
$this->addInputType('xml', array(array($this, '_convertXml')));
|
$this->addInputType('xml', array(array($this, 'convertXml')));
|
||||||
parent::__construct($collection, $settings);
|
parent::__construct($collection, $settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ class RequestHandlerComponent extends Component {
|
||||||
* HTTP_ACCEPT_TYPE is set to a single value that is a supported extension and mapped type.
|
* HTTP_ACCEPT_TYPE is set to a single value that is a supported extension and mapped type.
|
||||||
* If yes, RequestHandler::$ext is set to that value
|
* If yes, RequestHandler::$ext is set to that value
|
||||||
*
|
*
|
||||||
* @param object $controller A reference to the controller
|
* @param Controller $controller A reference to the controller
|
||||||
* @param array $settings Array of settings to _set().
|
* @param array $settings Array of settings to _set().
|
||||||
* @return void
|
* @return void
|
||||||
* @see Router::parseExtensions()
|
* @see Router::parseExtensions()
|
||||||
|
@ -142,7 +142,7 @@ class RequestHandlerComponent extends Component {
|
||||||
* - If the XML data is POSTed, the data is parsed into an XML object, which is assigned
|
* - If the XML data is POSTed, the data is parsed into an XML object, which is assigned
|
||||||
* to the $data property of the controller, which can then be saved to a model object.
|
* to the $data property of the controller, which can then be saved to a model object.
|
||||||
*
|
*
|
||||||
* @param object $controller A reference to the controller
|
* @param Controller $controller A reference to the controller
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startup($controller) {
|
public function startup($controller) {
|
||||||
|
@ -160,7 +160,7 @@ class RequestHandlerComponent extends Component {
|
||||||
$this->respondAs('html', array('charset' => Configure::read('App.encoding')));
|
$this->respondAs('html', array('charset' => Configure::read('App.encoding')));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->__inputTypeMap as $type => $handler) {
|
foreach ($this->_inputTypeMap as $type => $handler) {
|
||||||
if ($this->requestedWith($type)) {
|
if ($this->requestedWith($type)) {
|
||||||
$input = call_user_func_array(array($controller->request, 'input'), $handler);
|
$input = call_user_func_array(array($controller->request, 'input'), $handler);
|
||||||
$controller->request->data = $input;
|
$controller->request->data = $input;
|
||||||
|
@ -174,9 +174,8 @@ class RequestHandlerComponent extends Component {
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param string $xml
|
||||||
* @return array Xml array data
|
* @return array Xml array data
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
public function _convertXml($xml) {
|
public function convertXml($xml) {
|
||||||
try {
|
try {
|
||||||
$xml = Xml::build($xml);
|
$xml = Xml::build($xml);
|
||||||
if (isset($xml->data)) {
|
if (isset($xml->data)) {
|
||||||
|
@ -191,9 +190,11 @@ class RequestHandlerComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Handles (fakes) redirects for Ajax requests using requestAction()
|
* Handles (fakes) redirects for Ajax requests using requestAction()
|
||||||
*
|
*
|
||||||
* @param object $controller A reference to the controller
|
* @param Controller $controller A reference to the controller
|
||||||
* @param mixed $url A string or array containing the redirect location
|
* @param string|array $url A string or array containing the redirect location
|
||||||
* @param mixed HTTP Status for redirect
|
* @param mixed $status HTTP Status for redirect
|
||||||
|
* @param boolean $exit
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function beforeRedirect($controller, $url, $status = null, $exit = true) {
|
public function beforeRedirect($controller, $url, $status = null, $exit = true) {
|
||||||
if (!$this->request->is('ajax')) {
|
if (!$this->request->is('ajax')) {
|
||||||
|
@ -238,7 +239,7 @@ class RequestHandlerComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Returns true if the current request is over HTTPS, false otherwise.
|
* Returns true if the current request is over HTTPS, false otherwise.
|
||||||
*
|
*
|
||||||
* @return bool True if call is over HTTPS
|
* @return boolean True if call is over HTTPS
|
||||||
* @deprecated use `$this->request->is('ssl')` instead.
|
* @deprecated use `$this->request->is('ssl')` instead.
|
||||||
*/
|
*/
|
||||||
public function isSSL() {
|
public function isSSL() {
|
||||||
|
@ -285,7 +286,7 @@ class RequestHandlerComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Returns true if the client accepts WAP content
|
* Returns true if the client accepts WAP content
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isWap() {
|
public function isWap() {
|
||||||
return $this->prefers('wap');
|
return $this->prefers('wap');
|
||||||
|
@ -373,6 +374,7 @@ class RequestHandlerComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Gets remote client IP
|
* Gets remote client IP
|
||||||
*
|
*
|
||||||
|
* @param boolean $safe
|
||||||
* @return string Client IP address
|
* @return string Client IP address
|
||||||
* @deprecated use $this->request->clientIp() from your, controller instead.
|
* @deprecated use $this->request->clientIp() from your, controller instead.
|
||||||
*/
|
*/
|
||||||
|
@ -507,7 +509,7 @@ class RequestHandlerComponent extends Component {
|
||||||
*
|
*
|
||||||
* `$this->RequestHandler->renderAs($this, 'xml', array('attachment' => 'myfile.xml');`
|
* `$this->RequestHandler->renderAs($this, 'xml', array('attachment' => 'myfile.xml');`
|
||||||
*
|
*
|
||||||
* @param object $controller A reference to a controller object
|
* @param Controller $controller A reference to a controller object
|
||||||
* @param string $type Type of response to send (e.g: 'ajax')
|
* @param string $type Type of response to send (e.g: 'ajax')
|
||||||
* @param array $options Array of options to use
|
* @param array $options Array of options to use
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -528,13 +530,13 @@ class RequestHandlerComponent extends Component {
|
||||||
}
|
}
|
||||||
$controller->ext = '.ctp';
|
$controller->ext = '.ctp';
|
||||||
|
|
||||||
if (empty($this->__renderType)) {
|
if (empty($this->_renderType)) {
|
||||||
$controller->viewPath .= DS . $type;
|
$controller->viewPath .= DS . $type;
|
||||||
} else {
|
} else {
|
||||||
$remove = preg_replace("/([\/\\\\]{$this->__renderType})$/", DS . $type, $controller->viewPath);
|
$remove = preg_replace("/([\/\\\\]{$this->_renderType})$/", DS . $type, $controller->viewPath);
|
||||||
$controller->viewPath = $remove;
|
$controller->viewPath = $remove;
|
||||||
}
|
}
|
||||||
$this->__renderType = $type;
|
$this->_renderType = $type;
|
||||||
$controller->layoutPath = $type;
|
$controller->layoutPath = $type;
|
||||||
|
|
||||||
if ($this->response->getMimeType($type)) {
|
if ($this->response->getMimeType($type)) {
|
||||||
|
@ -658,11 +660,12 @@ class RequestHandlerComponent extends Component {
|
||||||
* be the handling callback, all other arguments should be additional parameters
|
* be the handling callback, all other arguments should be additional parameters
|
||||||
* for the handler.
|
* for the handler.
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws CakeException
|
||||||
*/
|
*/
|
||||||
public function addInputType($type, $handler) {
|
public function addInputType($type, $handler) {
|
||||||
if (!is_array($handler) || !isset($handler[0]) || !is_callable($handler[0])) {
|
if (!is_array($handler) || !isset($handler[0]) || !is_callable($handler[0])) {
|
||||||
throw new CakeException(__d('cake_dev', 'You must give a handler callback.'));
|
throw new CakeException(__d('cake_dev', 'You must give a handler callback.'));
|
||||||
}
|
}
|
||||||
$this->__inputTypeMap[$type] = $handler;
|
$this->_inputTypeMap[$type] = $handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ class SecurityComponent extends Component {
|
||||||
* The controller method that will be called if this request is black-hole'd
|
* The controller method that will be called if this request is black-hole'd
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $blackHoleCallback = null;
|
public $blackHoleCallback = null;
|
||||||
|
|
||||||
|
@ -41,7 +40,6 @@ class SecurityComponent extends Component {
|
||||||
* List of controller actions for which a POST request is required
|
* List of controller actions for which a POST request is required
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
* @see SecurityComponent::requirePost()
|
* @see SecurityComponent::requirePost()
|
||||||
*/
|
*/
|
||||||
public $requirePost = array();
|
public $requirePost = array();
|
||||||
|
@ -50,7 +48,6 @@ class SecurityComponent extends Component {
|
||||||
* List of controller actions for which a GET request is required
|
* List of controller actions for which a GET request is required
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
* @see SecurityComponent::requireGet()
|
* @see SecurityComponent::requireGet()
|
||||||
*/
|
*/
|
||||||
public $requireGet = array();
|
public $requireGet = array();
|
||||||
|
@ -59,7 +56,6 @@ class SecurityComponent extends Component {
|
||||||
* List of controller actions for which a PUT request is required
|
* List of controller actions for which a PUT request is required
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
* @see SecurityComponent::requirePut()
|
* @see SecurityComponent::requirePut()
|
||||||
*/
|
*/
|
||||||
public $requirePut = array();
|
public $requirePut = array();
|
||||||
|
@ -68,7 +64,6 @@ class SecurityComponent extends Component {
|
||||||
* List of controller actions for which a DELETE request is required
|
* List of controller actions for which a DELETE request is required
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
* @see SecurityComponent::requireDelete()
|
* @see SecurityComponent::requireDelete()
|
||||||
*/
|
*/
|
||||||
public $requireDelete = array();
|
public $requireDelete = array();
|
||||||
|
@ -77,7 +72,6 @@ class SecurityComponent extends Component {
|
||||||
* List of actions that require an SSL-secured connection
|
* List of actions that require an SSL-secured connection
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
* @see SecurityComponent::requireSecure()
|
* @see SecurityComponent::requireSecure()
|
||||||
*/
|
*/
|
||||||
public $requireSecure = array();
|
public $requireSecure = array();
|
||||||
|
@ -86,7 +80,6 @@ class SecurityComponent extends Component {
|
||||||
* List of actions that require a valid authentication key
|
* List of actions that require a valid authentication key
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
* @see SecurityComponent::requireAuth()
|
* @see SecurityComponent::requireAuth()
|
||||||
*/
|
*/
|
||||||
public $requireAuth = array();
|
public $requireAuth = array();
|
||||||
|
@ -96,7 +89,6 @@ class SecurityComponent extends Component {
|
||||||
* requests.
|
* requests.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
* @see SecurityComponent::requireAuth()
|
* @see SecurityComponent::requireAuth()
|
||||||
*/
|
*/
|
||||||
public $allowedControllers = array();
|
public $allowedControllers = array();
|
||||||
|
@ -106,7 +98,6 @@ class SecurityComponent extends Component {
|
||||||
* requests.
|
* requests.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
* @see SecurityComponent::requireAuth()
|
* @see SecurityComponent::requireAuth()
|
||||||
*/
|
*/
|
||||||
public $allowedActions = array();
|
public $allowedActions = array();
|
||||||
|
@ -135,7 +126,6 @@ class SecurityComponent extends Component {
|
||||||
* services, etc.
|
* services, etc.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $validatePost = true;
|
public $validatePost = true;
|
||||||
|
|
||||||
|
@ -171,7 +161,6 @@ class SecurityComponent extends Component {
|
||||||
* Other components used by the Security component
|
* Other components used by the Security component
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $components = array('Session');
|
public $components = array('Session');
|
||||||
|
|
||||||
|
@ -192,7 +181,7 @@ class SecurityComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Component startup. All security checking happens here.
|
* Component startup. All security checking happens here.
|
||||||
*
|
*
|
||||||
* @param object $controller Instantiating controller
|
* @param Controller $controller Instantiating controller
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startup($controller) {
|
public function startup($controller) {
|
||||||
|
@ -288,10 +277,9 @@ class SecurityComponent extends Component {
|
||||||
* Black-hole an invalid request with a 404 error or custom callback. If SecurityComponent::$blackHoleCallback
|
* Black-hole an invalid request with a 404 error or custom callback. If SecurityComponent::$blackHoleCallback
|
||||||
* is specified, it will use this callback by executing the method indicated in $error
|
* is specified, it will use this callback by executing the method indicated in $error
|
||||||
*
|
*
|
||||||
* @param object $controller Instantiating controller
|
* @param Controller $controller Instantiating controller
|
||||||
* @param string $error Error method
|
* @param string $error Error method
|
||||||
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
|
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
|
||||||
* @access public
|
|
||||||
* @see SecurityComponent::$blackHoleCallback
|
* @see SecurityComponent::$blackHoleCallback
|
||||||
* @link http://book.cakephp.org/view/1307/blackHole-object-controller-string-error
|
* @link http://book.cakephp.org/view/1307/blackHole-object-controller-string-error
|
||||||
*/
|
*/
|
||||||
|
@ -325,8 +313,8 @@ class SecurityComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Check if HTTP methods are required
|
* Check if HTTP methods are required
|
||||||
*
|
*
|
||||||
* @param object $controller Instantiating controller
|
* @param Controller $controller Instantiating controller
|
||||||
* @return bool true if $method is required
|
* @return boolean true if $method is required
|
||||||
*/
|
*/
|
||||||
protected function _methodsRequired($controller) {
|
protected function _methodsRequired($controller) {
|
||||||
foreach (array('Post', 'Get', 'Put', 'Delete') as $method) {
|
foreach (array('Post', 'Get', 'Put', 'Delete') as $method) {
|
||||||
|
@ -348,8 +336,8 @@ class SecurityComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Check if access requires secure connection
|
* Check if access requires secure connection
|
||||||
*
|
*
|
||||||
* @param object $controller Instantiating controller
|
* @param Controller $controller Instantiating controller
|
||||||
* @return bool true if secure connection required
|
* @return boolean true if secure connection required
|
||||||
*/
|
*/
|
||||||
protected function _secureRequired($controller) {
|
protected function _secureRequired($controller) {
|
||||||
if (is_array($this->requireSecure) && !empty($this->requireSecure)) {
|
if (is_array($this->requireSecure) && !empty($this->requireSecure)) {
|
||||||
|
@ -369,8 +357,8 @@ class SecurityComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Check if authentication is required
|
* Check if authentication is required
|
||||||
*
|
*
|
||||||
* @param object $controller Instantiating controller
|
* @param Controller $controller Instantiating controller
|
||||||
* @return bool true if authentication required
|
* @return boolean true if authentication required
|
||||||
*/
|
*/
|
||||||
protected function _authRequired($controller) {
|
protected function _authRequired($controller) {
|
||||||
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) {
|
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) {
|
||||||
|
@ -404,8 +392,8 @@ class SecurityComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Validate submitted form
|
* Validate submitted form
|
||||||
*
|
*
|
||||||
* @param object $controller Instantiating controller
|
* @param Controller $controller Instantiating controller
|
||||||
* @return bool true if submitted form is valid
|
* @return boolean true if submitted form is valid
|
||||||
*/
|
*/
|
||||||
protected function _validatePost($controller) {
|
protected function _validatePost($controller) {
|
||||||
if (empty($controller->request->data)) {
|
if (empty($controller->request->data)) {
|
||||||
|
@ -484,8 +472,8 @@ class SecurityComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Add authentication key for new form posts
|
* Add authentication key for new form posts
|
||||||
*
|
*
|
||||||
* @param object $controller Instantiating controller
|
* @param Controller $controller Instantiating controller
|
||||||
* @return bool Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
protected function _generateToken($controller) {
|
protected function _generateToken($controller) {
|
||||||
if (isset($controller->request->params['requested']) && $controller->request->params['requested'] === 1) {
|
if (isset($controller->request->params['requested']) && $controller->request->params['requested'] === 1) {
|
||||||
|
@ -551,7 +539,7 @@ class SecurityComponent extends Component {
|
||||||
* Uses a simple timeout to expire the tokens.
|
* Uses a simple timeout to expire the tokens.
|
||||||
*
|
*
|
||||||
* @param array $tokens An array of nonce => expires.
|
* @param array $tokens An array of nonce => expires.
|
||||||
* @return An array of nonce => expires.
|
* @return array An array of nonce => expires.
|
||||||
*/
|
*/
|
||||||
protected function _expireTokens($tokens) {
|
protected function _expireTokens($tokens) {
|
||||||
$now = time();
|
$now = time();
|
||||||
|
@ -566,7 +554,7 @@ class SecurityComponent extends Component {
|
||||||
/**
|
/**
|
||||||
* Calls a controller callback method
|
* Calls a controller callback method
|
||||||
*
|
*
|
||||||
* @param object $controller Controller to run callback on
|
* @param Controller $controller Controller to run callback on
|
||||||
* @param string $method Method to execute
|
* @param string $method Method to execute
|
||||||
* @param array $params Parameters to send to method
|
* @param array $params Parameters to send to method
|
||||||
* @return mixed Controller callback method's response
|
* @return mixed Controller callback method's response
|
||||||
|
|
|
@ -121,6 +121,7 @@ class SessionComponent extends Component {
|
||||||
* @param string $element Element to wrap flash message in.
|
* @param string $element Element to wrap flash message in.
|
||||||
* @param array $params Parameters to be sent to layout as view variables
|
* @param array $params Parameters to be sent to layout as view variables
|
||||||
* @param string $key Message key, default is 'flash'
|
* @param string $key Message key, default is 'flash'
|
||||||
|
* @return void
|
||||||
* @link http://book.cakephp.org/view/1313/setFlash
|
* @link http://book.cakephp.org/view/1313/setFlash
|
||||||
*/
|
*/
|
||||||
public function setFlash($message, $element = 'default', $params = array(), $key = 'flash') {
|
public function setFlash($message, $element = 'default', $params = array(), $key = 'flash') {
|
||||||
|
@ -167,7 +168,7 @@ class SessionComponent extends Component {
|
||||||
* If $id is passed in a beforeFilter, the Session will be started
|
* If $id is passed in a beforeFilter, the Session will be started
|
||||||
* with the specified id
|
* with the specified id
|
||||||
*
|
*
|
||||||
* @param $id string
|
* @param string $id
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function id($id = null) {
|
public function id($id = null) {
|
||||||
|
|
|
@ -47,6 +47,14 @@ App::uses('View', 'View');
|
||||||
* using Router::connect().
|
* using Router::connect().
|
||||||
*
|
*
|
||||||
* @package Cake.Controller
|
* @package Cake.Controller
|
||||||
|
* @property AclComponent $Acl
|
||||||
|
* @property AuthComponent $Auth
|
||||||
|
* @property CookieComponent $Cookie
|
||||||
|
* @property EmailComponent $Email
|
||||||
|
* @property PaginatorComponent $Paginator
|
||||||
|
* @property RequestHandlerComponent $RequestHandler
|
||||||
|
* @property SecurityComponent $Security
|
||||||
|
* @property SessionComponent $Session
|
||||||
* @link http://book.cakephp.org/view/956/Introduction
|
* @link http://book.cakephp.org/view/956/Introduction
|
||||||
*/
|
*/
|
||||||
class Controller extends Object {
|
class Controller extends Object {
|
||||||
|
@ -326,6 +334,7 @@ class Controller extends Object {
|
||||||
* Provides backwards compatibility to avoid problems with empty and isset to alias properties.
|
* Provides backwards compatibility to avoid problems with empty and isset to alias properties.
|
||||||
* Lazy loads models using the loadModel() method if declared in $uses
|
* Lazy loads models using the loadModel() method if declared in $uses
|
||||||
*
|
*
|
||||||
|
* @param string $name
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __isset($name) {
|
public function __isset($name) {
|
||||||
|
@ -366,6 +375,7 @@ class Controller extends Object {
|
||||||
* Provides backwards compatibility access to the request object properties.
|
* Provides backwards compatibility access to the request object properties.
|
||||||
* Also provides the params alias.
|
* Also provides the params alias.
|
||||||
*
|
*
|
||||||
|
* @param string $name
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __get($name) {
|
public function __get($name) {
|
||||||
|
@ -393,6 +403,8 @@ class Controller extends Object {
|
||||||
/**
|
/**
|
||||||
* Provides backwards compatibility access for setting values to the request object.
|
* Provides backwards compatibility access for setting values to the request object.
|
||||||
*
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param mixed $value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __set($name, $value) {
|
public function __set($name, $value) {
|
||||||
|
@ -447,7 +459,8 @@ class Controller extends Object {
|
||||||
* exists and isn't private.
|
* exists and isn't private.
|
||||||
*
|
*
|
||||||
* @param CakeRequest $request
|
* @param CakeRequest $request
|
||||||
* @return The resulting response.
|
* @return mixed The resulting response.
|
||||||
|
* @throws PrivateActionException, MissingActionException
|
||||||
*/
|
*/
|
||||||
public function invokeAction(CakeRequest $request) {
|
public function invokeAction(CakeRequest $request) {
|
||||||
$reflection = new ReflectionClass($this);
|
$reflection = new ReflectionClass($this);
|
||||||
|
@ -513,7 +526,7 @@ class Controller extends Object {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function __mergeVars() {
|
protected function _mergeControllerVars() {
|
||||||
$pluginController = $pluginDot = null;
|
$pluginController = $pluginDot = null;
|
||||||
|
|
||||||
if (!empty($this->plugin)) {
|
if (!empty($this->plugin)) {
|
||||||
|
@ -571,7 +584,7 @@ class Controller extends Object {
|
||||||
* @throws MissingModelException
|
* @throws MissingModelException
|
||||||
*/
|
*/
|
||||||
public function constructClasses() {
|
public function constructClasses() {
|
||||||
$this->__mergeVars();
|
$this->_mergeControllerVars();
|
||||||
$this->Components->init($this);
|
$this->Components->init($this);
|
||||||
if ($this->uses) {
|
if ($this->uses) {
|
||||||
$this->uses = (array) $this->uses;
|
$this->uses = (array) $this->uses;
|
||||||
|
@ -1017,6 +1030,7 @@ class Controller extends Object {
|
||||||
* 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.
|
* or perform logic that needs to happen before each controller action.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
* @link http://book.cakephp.org/view/984/Callbacks
|
* @link http://book.cakephp.org/view/984/Callbacks
|
||||||
*/
|
*/
|
||||||
public function beforeFilter() {
|
public function beforeFilter() {
|
||||||
|
@ -1026,6 +1040,7 @@ class Controller extends Object {
|
||||||
* Called after the controller action is run, but before the view is rendered. You can use this method
|
* Called after the controller action is run, but before the view is rendered. You can use this method
|
||||||
* to perform logic or set view variables that are required on every request.
|
* to perform logic or set view variables that are required on every request.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
* @link http://book.cakephp.org/view/984/Callbacks
|
* @link http://book.cakephp.org/view/984/Callbacks
|
||||||
*/
|
*/
|
||||||
public function beforeRender() {
|
public function beforeRender() {
|
||||||
|
@ -1051,6 +1066,7 @@ class Controller extends Object {
|
||||||
/**
|
/**
|
||||||
* Called after the controller action is run and rendered.
|
* Called after the controller action is run and rendered.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
* @link http://book.cakephp.org/view/984/Callbacks
|
* @link http://book.cakephp.org/view/984/Callbacks
|
||||||
*/
|
*/
|
||||||
public function afterFilter() {
|
public function afterFilter() {
|
||||||
|
@ -1063,10 +1079,22 @@ class Controller extends Object {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @link http://book.cakephp.org/view/984/Callbacks
|
* @link http://book.cakephp.org/view/984/Callbacks
|
||||||
*/
|
*/
|
||||||
public function _beforeScaffold($method) {
|
public function beforeScaffold($method) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias to beforeScaffold()
|
||||||
|
*
|
||||||
|
* @param string $method
|
||||||
|
* @return boolean
|
||||||
|
* @see Controller::beforeScaffold()
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
protected function _beforeScaffold($method) {
|
||||||
|
return $this->beforeScaffold($method);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should be overridden in child classes.
|
* This method should be overridden in child classes.
|
||||||
*
|
*
|
||||||
|
@ -1074,10 +1102,22 @@ class Controller extends Object {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @link http://book.cakephp.org/view/984/Callbacks
|
* @link http://book.cakephp.org/view/984/Callbacks
|
||||||
*/
|
*/
|
||||||
public function _afterScaffoldSave($method) {
|
public function afterScaffoldSave($method) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias to afterScaffoldSave()
|
||||||
|
*
|
||||||
|
* @param string $method
|
||||||
|
* @return boolean
|
||||||
|
* @see Controller::afterScaffoldSave()
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
protected function _afterScaffoldSave($method) {
|
||||||
|
return $this->afterScaffoldSave($method);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should be overridden in child classes.
|
* This method should be overridden in child classes.
|
||||||
*
|
*
|
||||||
|
@ -1085,10 +1125,22 @@ class Controller extends Object {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @link http://book.cakephp.org/view/984/Callbacks
|
* @link http://book.cakephp.org/view/984/Callbacks
|
||||||
*/
|
*/
|
||||||
public function _afterScaffoldSaveError($method) {
|
public function afterScaffoldSaveError($method) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias to afterScaffoldSaveError()
|
||||||
|
*
|
||||||
|
* @param string $method
|
||||||
|
* @return boolean
|
||||||
|
* @see Controller::afterScaffoldSaveError()
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
protected function _afterScaffoldSaveError($method) {
|
||||||
|
return $this->afterScaffoldSaveError($method);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should be overridden in child classes.
|
* This method should be overridden in child classes.
|
||||||
* If not it will render a scaffold error.
|
* If not it will render a scaffold error.
|
||||||
|
@ -1098,7 +1150,20 @@ class Controller extends Object {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @link http://book.cakephp.org/view/984/Callbacks
|
* @link http://book.cakephp.org/view/984/Callbacks
|
||||||
*/
|
*/
|
||||||
public function _scaffoldError($method) {
|
public function scaffoldError($method) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias to scaffoldError()
|
||||||
|
*
|
||||||
|
* @param string $method
|
||||||
|
* @return boolean
|
||||||
|
* @see Controller::scaffoldError()
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
protected function _scaffoldError($method) {
|
||||||
|
return $this->scaffoldError($method);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ class PagesController extends AppController {
|
||||||
* Controller name
|
* Controller name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $name = 'Pages';
|
public $name = 'Pages';
|
||||||
|
|
||||||
|
@ -43,7 +42,6 @@ class PagesController extends AppController {
|
||||||
* Default helper
|
* Default helper
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $helpers = array('Html', 'Session');
|
public $helpers = array('Html', 'Session');
|
||||||
|
|
||||||
|
@ -51,7 +49,6 @@ class PagesController extends AppController {
|
||||||
* This controller does not use a model
|
* This controller does not use a model
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $uses = array();
|
public $uses = array();
|
||||||
|
|
||||||
|
@ -59,6 +56,7 @@ class PagesController extends AppController {
|
||||||
* Displays a view
|
* Displays a view
|
||||||
*
|
*
|
||||||
* @param mixed What page to display
|
* @param mixed What page to display
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function display() {
|
public function display() {
|
||||||
$path = func_get_args();
|
$path = func_get_args();
|
||||||
|
|
|
@ -78,7 +78,6 @@ class Scaffold {
|
||||||
* valid session.
|
* valid session.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
protected $_validSession = null;
|
protected $_validSession = null;
|
||||||
|
|
||||||
|
@ -86,9 +85,8 @@ class Scaffold {
|
||||||
* List of variables to collect from the associated controller
|
* List of variables to collect from the associated controller
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private $__passedVars = array(
|
protected $_passedVars = array(
|
||||||
'layout', 'name', 'viewPath', 'request'
|
'layout', 'name', 'viewPath', 'request'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -96,7 +94,6 @@ class Scaffold {
|
||||||
* Title HTML element for current scaffolded view
|
* Title HTML element for current scaffolded view
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $scaffoldTitle = null;
|
public $scaffoldTitle = null;
|
||||||
|
|
||||||
|
@ -105,13 +102,14 @@ class Scaffold {
|
||||||
*
|
*
|
||||||
* @param Controller $controller Controller to scaffold
|
* @param Controller $controller Controller to scaffold
|
||||||
* @param CakeRequest $request Request parameters.
|
* @param CakeRequest $request Request parameters.
|
||||||
|
* @throws MissingModelException
|
||||||
*/
|
*/
|
||||||
public function __construct(Controller $controller, CakeRequest $request) {
|
public function __construct(Controller $controller, CakeRequest $request) {
|
||||||
$this->controller = $controller;
|
$this->controller = $controller;
|
||||||
|
|
||||||
$count = count($this->__passedVars);
|
$count = count($this->_passedVars);
|
||||||
for ($j = 0; $j < $count; $j++) {
|
for ($j = 0; $j < $count; $j++) {
|
||||||
$var = $this->__passedVars[$j];
|
$var = $this->_passedVars[$j];
|
||||||
$this->{$var} = $controller->{$var};
|
$this->{$var} = $controller->{$var};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,9 +155,10 @@ class Scaffold {
|
||||||
*
|
*
|
||||||
* @param CakeRequest $request Request Object for scaffolding
|
* @param CakeRequest $request Request Object for scaffolding
|
||||||
* @return mixed A rendered view of a row from Models database table
|
* @return mixed A rendered view of a row from Models database table
|
||||||
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
protected function _scaffoldView(CakeRequest $request) {
|
protected function _scaffoldView(CakeRequest $request) {
|
||||||
if ($this->controller->_beforeScaffold('view')) {
|
if ($this->controller->beforeScaffold('view')) {
|
||||||
if (isset($request->params['pass'][0])) {
|
if (isset($request->params['pass'][0])) {
|
||||||
$this->ScaffoldModel->id = $request->params['pass'][0];
|
$this->ScaffoldModel->id = $request->params['pass'][0];
|
||||||
}
|
}
|
||||||
|
@ -172,7 +171,7 @@ class Scaffold {
|
||||||
Inflector::variable($this->controller->modelClass), $this->request->data
|
Inflector::variable($this->controller->modelClass), $this->request->data
|
||||||
);
|
);
|
||||||
$this->controller->render($this->request['action'], $this->layout);
|
$this->controller->render($this->request['action'], $this->layout);
|
||||||
} elseif ($this->controller->_scaffoldError('view') === false) {
|
} elseif ($this->controller->scaffoldError('view') === false) {
|
||||||
return $this->_scaffoldError();
|
return $this->_scaffoldError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,13 +183,13 @@ class Scaffold {
|
||||||
* @return mixed A rendered view listing rows from Models database table
|
* @return mixed A rendered view listing rows from Models database table
|
||||||
*/
|
*/
|
||||||
protected function _scaffoldIndex($params) {
|
protected function _scaffoldIndex($params) {
|
||||||
if ($this->controller->_beforeScaffold('index')) {
|
if ($this->controller->beforeScaffold('index')) {
|
||||||
$this->ScaffoldModel->recursive = 0;
|
$this->ScaffoldModel->recursive = 0;
|
||||||
$this->controller->set(
|
$this->controller->set(
|
||||||
Inflector::variable($this->controller->name), $this->controller->paginate()
|
Inflector::variable($this->controller->name), $this->controller->paginate()
|
||||||
);
|
);
|
||||||
$this->controller->render($this->request['action'], $this->layout);
|
$this->controller->render($this->request['action'], $this->layout);
|
||||||
} elseif ($this->controller->_scaffoldError('index') === false) {
|
} elseif ($this->controller->scaffoldError('index') === false) {
|
||||||
return $this->_scaffoldError();
|
return $this->_scaffoldError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,6 +214,7 @@ class Scaffold {
|
||||||
* @param CakeRequest $request Request Object for scaffolding
|
* @param CakeRequest $request Request Object for scaffolding
|
||||||
* @param string $action add or edt
|
* @param string $action add or edt
|
||||||
* @return mixed Success on save/update, add/edit form if data is empty or error if save or update fails
|
* @return mixed Success on save/update, add/edit form if data is empty or error if save or update fails
|
||||||
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
protected function _scaffoldSave(CakeRequest $request, $action = 'edit') {
|
protected function _scaffoldSave(CakeRequest $request, $action = 'edit') {
|
||||||
$formAction = 'edit';
|
$formAction = 'edit';
|
||||||
|
@ -224,7 +224,7 @@ class Scaffold {
|
||||||
$success = __d('cake', 'saved');
|
$success = __d('cake', 'saved');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->controller->_beforeScaffold($action)) {
|
if ($this->controller->beforeScaffold($action)) {
|
||||||
if ($action == 'edit') {
|
if ($action == 'edit') {
|
||||||
if (isset($request->params['pass'][0])) {
|
if (isset($request->params['pass'][0])) {
|
||||||
$this->ScaffoldModel->id = $request['pass'][0];
|
$this->ScaffoldModel->id = $request['pass'][0];
|
||||||
|
@ -240,7 +240,7 @@ class Scaffold {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->ScaffoldModel->save($request->data)) {
|
if ($this->ScaffoldModel->save($request->data)) {
|
||||||
if ($this->controller->_afterScaffoldSave($action)) {
|
if ($this->controller->afterScaffoldSave($action)) {
|
||||||
$message = __d('cake',
|
$message = __d('cake',
|
||||||
'The %1$s has been %2$s',
|
'The %1$s has been %2$s',
|
||||||
Inflector::humanize($this->modelKey),
|
Inflector::humanize($this->modelKey),
|
||||||
|
@ -248,7 +248,7 @@ class Scaffold {
|
||||||
);
|
);
|
||||||
return $this->_sendMessage($message);
|
return $this->_sendMessage($message);
|
||||||
} else {
|
} else {
|
||||||
return $this->controller->_afterScaffoldSaveError($action);
|
return $this->controller->afterScaffoldSaveError($action);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($this->_validSession) {
|
if ($this->_validSession) {
|
||||||
|
@ -277,7 +277,7 @@ class Scaffold {
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_scaffoldForm($formAction);
|
return $this->_scaffoldForm($formAction);
|
||||||
} elseif ($this->controller->_scaffoldError($action) === false) {
|
} elseif ($this->controller->scaffoldError($action) === false) {
|
||||||
return $this->_scaffoldError();
|
return $this->_scaffoldError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,11 +285,12 @@ class Scaffold {
|
||||||
/**
|
/**
|
||||||
* Performs a delete on given scaffolded Model.
|
* Performs a delete on given scaffolded Model.
|
||||||
*
|
*
|
||||||
* @param array $params Parameters for scaffolding
|
* @param CakeRequest $request Request for scaffolding
|
||||||
* @return mixed Success on delete, error if delete fails
|
* @return mixed Success on delete, error if delete fails
|
||||||
|
* @throws MethodNotAllowedException, NotFoundException
|
||||||
*/
|
*/
|
||||||
protected function _scaffoldDelete(CakeRequest $request) {
|
protected function _scaffoldDelete(CakeRequest $request) {
|
||||||
if ($this->controller->_beforeScaffold('delete')) {
|
if ($this->controller->beforeScaffold('delete')) {
|
||||||
if (!$request->is('post')) {
|
if (!$request->is('post')) {
|
||||||
throw new MethodNotAllowedException();
|
throw new MethodNotAllowedException();
|
||||||
}
|
}
|
||||||
|
@ -312,7 +313,7 @@ class Scaffold {
|
||||||
);
|
);
|
||||||
return $this->_sendMessage($message);
|
return $this->_sendMessage($message);
|
||||||
}
|
}
|
||||||
} elseif ($this->controller->_scaffoldError('delete') === false) {
|
} elseif ($this->controller->scaffoldError('delete') === false) {
|
||||||
return $this->_scaffoldError();
|
return $this->_scaffoldError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,6 +350,7 @@ class Scaffold {
|
||||||
*
|
*
|
||||||
* @param CakeRequest $request Request object for scaffolding
|
* @param CakeRequest $request Request object for scaffolding
|
||||||
* @return mixed A rendered view of scaffold action, or showing the error
|
* @return mixed A rendered view of scaffold action, or showing the error
|
||||||
|
* @throws MissingActionException, MissingDatabaseException
|
||||||
*/
|
*/
|
||||||
protected function _scaffold(CakeRequest $request) {
|
protected function _scaffold(CakeRequest $request) {
|
||||||
$db = ConnectionManager::getDataSource($this->ScaffoldModel->useDbConfig);
|
$db = ConnectionManager::getDataSource($this->ScaffoldModel->useDbConfig);
|
||||||
|
|
|
@ -122,50 +122,40 @@ class App {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $__map = array();
|
protected static $_map = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds paths for deep searching of files.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $__paths = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds loaded files.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $__loaded = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds and key => value array of object types.
|
* Holds and key => value array of object types.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $__objects = array();
|
protected static $_objects = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the location of each class
|
* Holds the location of each class
|
||||||
*
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $__classMap = array();
|
protected static $_classMap = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the possible paths for each package name
|
* Holds the possible paths for each package name
|
||||||
*
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $__packages = array();
|
protected static $_packages = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the templates for each customizable package path in the application
|
* Holds the templates for each customizable package path in the application
|
||||||
*
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $__packageFormat = array();
|
protected static $_packageFormat = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps an old style CakePHP class type to the corresponding package
|
* Maps an old style CakePHP class type to the corresponding package
|
||||||
*
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $legacy = array(
|
public static $legacy = array(
|
||||||
'models' => 'Model',
|
'models' => 'Model',
|
||||||
|
@ -182,19 +172,22 @@ class App {
|
||||||
/**
|
/**
|
||||||
* Indicates whether the class cache should be stored again because of an addition to it
|
* Indicates whether the class cache should be stored again because of an addition to it
|
||||||
*
|
*
|
||||||
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private static $_cacheChange = false;
|
protected static $_cacheChange = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether the object cache should be stored again because of an addition to it
|
* Indicates whether the object cache should be stored again because of an addition to it
|
||||||
*
|
*
|
||||||
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private static $_objectCacheChange = false;
|
protected static $_objectCacheChange = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the the Application is in the bootstrapping process. Used to better cache
|
* Indicates the the Application is in the bootstrapping process. Used to better cache
|
||||||
* loaded classes while the cache libraries have not been yet initialized
|
* loaded classes while the cache libraries have not been yet initialized
|
||||||
*
|
*
|
||||||
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
public static $bootstrapping = false;
|
public static $bootstrapping = false;
|
||||||
|
|
||||||
|
@ -219,8 +212,8 @@ class App {
|
||||||
if (!empty($plugin)) {
|
if (!empty($plugin)) {
|
||||||
$path = array();
|
$path = array();
|
||||||
$pluginPath = self::pluginPath($plugin);
|
$pluginPath = self::pluginPath($plugin);
|
||||||
if (!empty(self::$__packageFormat[$type])) {
|
if (!empty(self::$_packageFormat[$type])) {
|
||||||
foreach (self::$__packageFormat[$type] as $f) {
|
foreach (self::$_packageFormat[$type] as $f) {
|
||||||
$path[] = sprintf($f, $pluginPath);
|
$path[] = sprintf($f, $pluginPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,10 +221,10 @@ class App {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset(self::$__packages[$type])) {
|
if (!isset(self::$_packages[$type])) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
return self::$__packages[$type];
|
return self::$_packages[$type];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,8 +247,8 @@ class App {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function build($paths = array(), $mode = App::PREPEND) {
|
public static function build($paths = array(), $mode = App::PREPEND) {
|
||||||
if (empty(self::$__packageFormat)) {
|
if (empty(self::$_packageFormat)) {
|
||||||
self::$__packageFormat = array(
|
self::$_packageFormat = array(
|
||||||
'Model' => array(
|
'Model' => array(
|
||||||
'%s' . 'Model' . DS,
|
'%s' . 'Model' . DS,
|
||||||
'%s' . 'models' . DS
|
'%s' . 'models' . DS
|
||||||
|
@ -330,7 +323,7 @@ class App {
|
||||||
if (!empty(self::$legacy[$type])) {
|
if (!empty(self::$legacy[$type])) {
|
||||||
$type = self::$legacy[$type];
|
$type = self::$legacy[$type];
|
||||||
}
|
}
|
||||||
self::$__packages[$type] = (array)$new;
|
self::$_packages[$type] = (array)$new;
|
||||||
self::objects($type, null, false);
|
self::objects($type, null, false);
|
||||||
}
|
}
|
||||||
return $paths;
|
return $paths;
|
||||||
|
@ -347,28 +340,28 @@ class App {
|
||||||
|
|
||||||
$paths = $legacyPaths;
|
$paths = $legacyPaths;
|
||||||
$defaults = array();
|
$defaults = array();
|
||||||
foreach (self::$__packageFormat as $package => $format) {
|
foreach (self::$_packageFormat as $package => $format) {
|
||||||
foreach ($format as $f) {
|
foreach ($format as $f) {
|
||||||
$defaults[$package][] = sprintf($f, APP);
|
$defaults[$package][] = sprintf($f, APP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($defaults as $type => $default) {
|
foreach ($defaults as $type => $default) {
|
||||||
if (empty(self::$__packages[$type]) || empty($paths)) {
|
if (empty(self::$_packages[$type]) || empty($paths)) {
|
||||||
self::$__packages[$type] = $default;
|
self::$_packages[$type] = $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($paths[$type])) {
|
if (!empty($paths[$type])) {
|
||||||
if ($mode === App::PREPEND) {
|
if ($mode === App::PREPEND) {
|
||||||
$path = array_merge((array)$paths[$type], self::$__packages[$type]);
|
$path = array_merge((array)$paths[$type], self::$_packages[$type]);
|
||||||
} else {
|
} else {
|
||||||
$path = array_merge(self::$__packages[$type], (array)$paths[$type]);
|
$path = array_merge(self::$_packages[$type], (array)$paths[$type]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$path = self::$__packages[$type];
|
$path = self::$_packages[$type];
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$__packages[$type] = array_values(array_unique($path));
|
self::$_packages[$type] = array_values(array_unique($path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,12 +391,12 @@ class App {
|
||||||
*/
|
*/
|
||||||
public static function themePath($theme) {
|
public static function themePath($theme) {
|
||||||
$themeDir = 'Themed' . DS . Inflector::camelize($theme);
|
$themeDir = 'Themed' . DS . Inflector::camelize($theme);
|
||||||
foreach (self::$__packages['View'] as $path) {
|
foreach (self::$_packages['View'] as $path) {
|
||||||
if (is_dir($path . $themeDir)) {
|
if (is_dir($path . $themeDir)) {
|
||||||
return $path . $themeDir . DS ;
|
return $path . $themeDir . DS ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self::$__packages['View'][0] . $themeDir . DS;
|
return self::$_packages['View'][0] . $themeDir . DS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -466,13 +459,13 @@ class App {
|
||||||
$name = $type . str_replace(DS, '', $path);
|
$name = $type . str_replace(DS, '', $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty(self::$__objects) && $cache === true) {
|
if (empty(self::$_objects) && $cache === true) {
|
||||||
self::$__objects = Cache::read('object_map', '_cake_core_');
|
self::$_objects = Cache::read('object_map', '_cake_core_');
|
||||||
}
|
}
|
||||||
|
|
||||||
$cacheLocation = empty($plugin) ? 'app' : $plugin;
|
$cacheLocation = empty($plugin) ? 'app' : $plugin;
|
||||||
|
|
||||||
if ($cache !== true || !isset(self::$__objects[$cacheLocation][$name])) {
|
if ($cache !== true || !isset(self::$_objects[$cacheLocation][$name])) {
|
||||||
$objects = array();
|
$objects = array();
|
||||||
|
|
||||||
if (empty($path)) {
|
if (empty($path)) {
|
||||||
|
@ -506,13 +499,13 @@ class App {
|
||||||
return $objects;
|
return $objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$__objects[$cacheLocation][$name] = $objects;
|
self::$_objects[$cacheLocation][$name] = $objects;
|
||||||
if ($cache) {
|
if ($cache) {
|
||||||
self::$_objectCacheChange = true;
|
self::$_objectCacheChange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$__objects[$cacheLocation][$name];
|
return self::$_objects[$cacheLocation][$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -527,9 +520,10 @@ class App {
|
||||||
*
|
*
|
||||||
* @param string $className the name of the class to configure package for
|
* @param string $className the name of the class to configure package for
|
||||||
* @param string $location the package name
|
* @param string $location the package name
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function uses($className, $location) {
|
public static function uses($className, $location) {
|
||||||
self::$__classMap[$className] = $location;
|
self::$_classMap[$className] = $location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -539,22 +533,23 @@ class App {
|
||||||
* if a class is name `MyCustomClass` the file name should be `MyCustomClass.php`
|
* if a class is name `MyCustomClass` the file name should be `MyCustomClass.php`
|
||||||
*
|
*
|
||||||
* @param string $className the name of the class to load
|
* @param string $className the name of the class to load
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function load($className) {
|
public static function load($className) {
|
||||||
if (!isset(self::$__classMap[$className])) {
|
if (!isset(self::$_classMap[$className])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($file = self::__mapped($className)) {
|
if ($file = self::_mapped($className)) {
|
||||||
return include $file;
|
return include $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parts = explode('.', self::$__classMap[$className], 2);
|
$parts = explode('.', self::$_classMap[$className], 2);
|
||||||
list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts));
|
list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts));
|
||||||
$paths = self::path($package, $plugin);
|
$paths = self::path($package, $plugin);
|
||||||
|
|
||||||
if (empty($plugin)) {
|
if (empty($plugin)) {
|
||||||
$appLibs = empty(self::$__packages['Lib']) ? APPLIBS : current(self::$__packages['Lib']);
|
$appLibs = empty(self::$_packages['Lib']) ? APPLIBS : current(self::$_packages['Lib']);
|
||||||
$paths[] = $appLibs . $package . DS;
|
$paths[] = $appLibs . $package . DS;
|
||||||
$paths[] = CAKE . $package . DS;
|
$paths[] = CAKE . $package . DS;
|
||||||
}
|
}
|
||||||
|
@ -562,7 +557,7 @@ class App {
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
$file = $path . $className . '.php';
|
$file = $path . $className . '.php';
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
self::__map($file, $className);
|
self::_map($file, $className);
|
||||||
return include $file;
|
return include $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,7 +573,7 @@ class App {
|
||||||
}
|
}
|
||||||
foreach ($tries as $file) {
|
foreach ($tries as $file) {
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
self::__map($file, $className);
|
self::_map($file, $className);
|
||||||
return include $file;
|
return include $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -594,8 +589,8 @@ class App {
|
||||||
* @return string package name or null if not declared
|
* @return string package name or null if not declared
|
||||||
*/
|
*/
|
||||||
public static function location($className) {
|
public static function location($className) {
|
||||||
if (!empty(self::$__classMap[$className])) {
|
if (!empty(self::$_classMap[$className])) {
|
||||||
return self::$__classMap[$className];
|
return self::$_classMap[$className];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -676,12 +671,11 @@ class App {
|
||||||
* @param string $name unique name of the file for identifying it inside the application
|
* @param string $name unique name of the file for identifying it inside the application
|
||||||
* @param string $plugin camel cased plugin name if any
|
* @param string $plugin camel cased plugin name if any
|
||||||
* @param string $type name of the packed where the class is located
|
* @param string $type name of the packed where the class is located
|
||||||
* @param string $file filename if known, the $name param will be used otherwise
|
|
||||||
* @param string $originalType type name as supplied initially by the user
|
* @param string $originalType type name as supplied initially by the user
|
||||||
* @param boolean $parent whether to load the class parent or not
|
* @param boolean $parent whether to load the class parent or not
|
||||||
* @return boolean true indicating the successful load and existence of the class
|
* @return boolean true indicating the successful load and existence of the class
|
||||||
*/
|
*/
|
||||||
private function _loadClass($name, $plugin, $type, $originalType, $parent) {
|
protected static function _loadClass($name, $plugin, $type, $originalType, $parent) {
|
||||||
if ($type == 'Console/Command' && $name == 'Shell') {
|
if ($type == 'Console/Command' && $name == 'Shell') {
|
||||||
$type = 'Console';
|
$type = 'Console';
|
||||||
} else if (isset(self::$types[$originalType]['suffix'])) {
|
} else if (isset(self::$types[$originalType]['suffix'])) {
|
||||||
|
@ -717,10 +711,10 @@ class App {
|
||||||
* @param array $search list of paths to search the file into
|
* @param array $search list of paths to search the file into
|
||||||
* @param string $file filename if known, the $name param will be used otherwise
|
* @param string $file filename if known, the $name param will be used otherwise
|
||||||
* @param boolean $return whether this function should return the contents of the file after being parsed by php or just a success notice
|
* @param boolean $return whether this function should return the contents of the file after being parsed by php or just a success notice
|
||||||
* @return mixed, if $return contents of the file after php parses it, boolean indicating success otherwise
|
* @return mixed if $return contents of the file after php parses it, boolean indicating success otherwise
|
||||||
*/
|
*/
|
||||||
private function _loadFile($name, $plugin, $search, $file, $return) {
|
protected function _loadFile($name, $plugin, $search, $file, $return) {
|
||||||
$mapped = self::__mapped($name, $plugin);
|
$mapped = self::_mapped($name, $plugin);
|
||||||
if ($mapped) {
|
if ($mapped) {
|
||||||
$file = $mapped;
|
$file = $mapped;
|
||||||
} else if (!empty($search)) {
|
} else if (!empty($search)) {
|
||||||
|
@ -737,7 +731,7 @@ class App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($file) && file_exists($file)) {
|
if (!empty($file) && file_exists($file)) {
|
||||||
self::__map($file, $name, $plugin);
|
self::_map($file, $name, $plugin);
|
||||||
$returnValue = include $file;
|
$returnValue = include $file;
|
||||||
if ($return) {
|
if ($return) {
|
||||||
return $returnValue;
|
return $returnValue;
|
||||||
|
@ -756,8 +750,8 @@ class App {
|
||||||
* @param string $ext file extension if known
|
* @param string $ext file extension if known
|
||||||
* @return boolean true if the file was loaded successfully, false otherwise
|
* @return boolean true if the file was loaded successfully, false otherwise
|
||||||
*/
|
*/
|
||||||
private function _loadVendor($name, $plugin, $file, $ext) {
|
protected function _loadVendor($name, $plugin, $file, $ext) {
|
||||||
if ($mapped = self::__mapped($name, $plugin)) {
|
if ($mapped = self::_mapped($name, $plugin)) {
|
||||||
return (bool) include_once($mapped);
|
return (bool) include_once($mapped);
|
||||||
}
|
}
|
||||||
$fileTries = array();
|
$fileTries = array();
|
||||||
|
@ -775,7 +769,7 @@ class App {
|
||||||
foreach ($fileTries as $file) {
|
foreach ($fileTries as $file) {
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
if (file_exists($path . $file)) {
|
if (file_exists($path . $file)) {
|
||||||
self::__map($path . $file, $name, $plugin);
|
self::_map($path . $file, $name, $plugin);
|
||||||
return (bool) include($path . $file);
|
return (bool) include($path . $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -789,8 +783,8 @@ class App {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function init() {
|
public static function init() {
|
||||||
self::$__map += (array)Cache::read('file_map', '_cake_core_');
|
self::$_map += (array)Cache::read('file_map', '_cake_core_');
|
||||||
self::$__objects += (array)Cache::read('object_map', '_cake_core_');
|
self::$_objects += (array)Cache::read('object_map', '_cake_core_');
|
||||||
register_shutdown_function(array('App', 'shutdown'));
|
register_shutdown_function(array('App', 'shutdown'));
|
||||||
self::uses('CakePlugin', 'Core');
|
self::uses('CakePlugin', 'Core');
|
||||||
}
|
}
|
||||||
|
@ -802,13 +796,12 @@ class App {
|
||||||
* @param string $name unique name for this map
|
* @param string $name unique name for this map
|
||||||
* @param string $plugin camelized if object is from a plugin, the name of the plugin
|
* @param string $plugin camelized if object is from a plugin, the name of the plugin
|
||||||
* @return void
|
* @return void
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private static function __map($file, $name, $plugin = null) {
|
protected static function _map($file, $name, $plugin = null) {
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
self::$__map['Plugin'][$plugin][$name] = $file;
|
self::$_map['Plugin'][$plugin][$name] = $file;
|
||||||
} else {
|
} else {
|
||||||
self::$__map[$name] = $file;
|
self::$_map[$name] = $file;
|
||||||
}
|
}
|
||||||
if (!self::$bootstrapping) {
|
if (!self::$bootstrapping) {
|
||||||
self::$_cacheChange = true;
|
self::$_cacheChange = true;
|
||||||
|
@ -820,19 +813,18 @@ class App {
|
||||||
*
|
*
|
||||||
* @param string $name unique name
|
* @param string $name unique name
|
||||||
* @param string $plugin camelized if object is from a plugin, the name of the plugin
|
* @param string $plugin camelized if object is from a plugin, the name of the plugin
|
||||||
* @return mixed, file path if found, false otherwise
|
* @return mixed file path if found, false otherwise
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private static function __mapped($name, $plugin = null) {
|
protected static function _mapped($name, $plugin = null) {
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
if (isset(self::$__map['Plugin'][$plugin][$name])) {
|
if (isset(self::$_map['Plugin'][$plugin][$name])) {
|
||||||
return self::$__map['Plugin'][$plugin][$name];
|
return self::$_map['Plugin'][$plugin][$name];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset(self::$__map[$name])) {
|
if (isset(self::$_map[$name])) {
|
||||||
return self::$__map[$name];
|
return self::$_map[$name];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -840,16 +832,16 @@ class App {
|
||||||
/**
|
/**
|
||||||
* Object destructor.
|
* Object destructor.
|
||||||
*
|
*
|
||||||
* Writes cache file if changes have been made to the $__map or $__paths
|
* Writes cache file if changes have been made to the $_map
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function shutdown() {
|
public static function shutdown() {
|
||||||
if (self::$_cacheChange) {
|
if (self::$_cacheChange) {
|
||||||
Cache::write('file_map', array_filter(self::$__map), '_cake_core_');
|
Cache::write('file_map', array_filter(self::$_map), '_cake_core_');
|
||||||
}
|
}
|
||||||
if (self::$_objectCacheChange) {
|
if (self::$_objectCacheChange) {
|
||||||
Cache::write('object_map', self::$__objects, '_cake_core_');
|
Cache::write('object_map', self::$_objects, '_cake_core_');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,35 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* CakePlugin class
|
||||||
|
*
|
||||||
|
* PHP 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||||
|
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
|
* @link http://cakephp.org CakePHP(tm) Project
|
||||||
|
* @package Cake.Core
|
||||||
|
* @since CakePHP(tm) v 2.0.0
|
||||||
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CakePlugin class
|
||||||
|
*
|
||||||
|
* @package Cake.Core
|
||||||
|
*/
|
||||||
class CakePlugin {
|
class CakePlugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds a list of all loaded plugins and their configuration
|
* Holds a list of all loaded plugins and their configuration
|
||||||
*
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $_plugins = array();
|
protected static $_plugins = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a plugin and optionally loads bootstrapping, routing files or loads a initialization function
|
* Loads a plugin and optionally loads bootstrapping, routing files or loads a initialization function
|
||||||
|
@ -173,6 +196,7 @@ class CakePlugin {
|
||||||
* Retruns true if the plugin $plugin is already loaded
|
* Retruns true if the plugin $plugin is already loaded
|
||||||
* If plugin is null, it will return a list of all loaded plugins
|
* If plugin is null, it will return a list of all loaded plugins
|
||||||
*
|
*
|
||||||
|
* @param string $plugin
|
||||||
* @return mixed boolean true if $plugin is already loaded.
|
* @return mixed boolean true if $plugin is already loaded.
|
||||||
* If $plugin is null, returns a list of plugins that have been loaded
|
* If $plugin is null, returns a list of plugins that have been loaded
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -59,6 +59,7 @@ class Configure {
|
||||||
* - Include app/Config/bootstrap.php.
|
* - Include app/Config/bootstrap.php.
|
||||||
* - Setup error/exception handlers.
|
* - Setup error/exception handlers.
|
||||||
*
|
*
|
||||||
|
* @param boolean $boot
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function bootstrap($boot = true) {
|
public static function bootstrap($boot = true) {
|
||||||
|
@ -246,6 +247,7 @@ class Configure {
|
||||||
/**
|
/**
|
||||||
* Gets the names of the configured reader objects.
|
* Gets the names of the configured reader objects.
|
||||||
*
|
*
|
||||||
|
* @param string $name
|
||||||
* @return array Array of the configured reader objects.
|
* @return array Array of the configured reader objects.
|
||||||
*/
|
*/
|
||||||
public static function configured($name = null) {
|
public static function configured($name = null) {
|
||||||
|
|
|
@ -35,10 +35,8 @@ class Object {
|
||||||
/**
|
/**
|
||||||
* constructor, no-op
|
* constructor, no-op
|
||||||
*
|
*
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,7 +122,7 @@ class Object {
|
||||||
* Stop execution of the current script. Wraps exit() making
|
* Stop execution of the current script. Wraps exit() making
|
||||||
* testing easier.
|
* testing easier.
|
||||||
*
|
*
|
||||||
* @param $status see http://php.net/exit for values
|
* @param integer|string $status see http://php.net/exit for values
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _stop($status = 0) {
|
protected function _stop($status = 0) {
|
||||||
|
@ -175,7 +173,7 @@ class Object {
|
||||||
* this method as an empty function.
|
* this method as an empty function.
|
||||||
*
|
*
|
||||||
* @param array $properties The name of the properties to merge.
|
* @param array $properties The name of the properties to merge.
|
||||||
* @param sting $class The class to merge the property with.
|
* @param string $class The class to merge the property with.
|
||||||
* @param boolean $normalize Set to true to run the properties through Set::normalize() before merging.
|
* @param boolean $normalize Set to true to run the properties through Set::normalize() before merging.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -103,6 +103,7 @@ class ErrorHandler {
|
||||||
* This will either use an AppError class if your application has one,
|
* This will either use an AppError class if your application has one,
|
||||||
* or use the default ExceptionRenderer.
|
* or use the default ExceptionRenderer.
|
||||||
*
|
*
|
||||||
|
* @param Exception $exception
|
||||||
* @return void
|
* @return void
|
||||||
* @see http://php.net/manual/en/function.set-exception-handler.php
|
* @see http://php.net/manual/en/function.set-exception-handler.php
|
||||||
*/
|
*/
|
||||||
|
@ -185,7 +186,7 @@ class ErrorHandler {
|
||||||
/**
|
/**
|
||||||
* Map an error code into an Error word, and log location.
|
* Map an error code into an Error word, and log location.
|
||||||
*
|
*
|
||||||
* @param int $code Error code to map
|
* @param integer $code Error code to map
|
||||||
* @return array Array of error word, and log location.
|
* @return array Array of error word, and log location.
|
||||||
*/
|
*/
|
||||||
protected static function _mapErrorCode($code) {
|
protected static function _mapErrorCode($code) {
|
||||||
|
|
|
@ -57,7 +57,6 @@ class ExceptionRenderer {
|
||||||
* Controller instance.
|
* Controller instance.
|
||||||
*
|
*
|
||||||
* @var Controller
|
* @var Controller
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $controller = null;
|
public $controller = null;
|
||||||
|
|
||||||
|
@ -87,8 +86,7 @@ class ExceptionRenderer {
|
||||||
* If the error is a CakeException it will be converted to either a 400 or a 500
|
* If the error is a CakeException it will be converted to either a 400 or a 500
|
||||||
* code error depending on the code used to construct the error.
|
* code error depending on the code used to construct the error.
|
||||||
*
|
*
|
||||||
* @param string $method Method producing the error
|
* @param Exception $exception Exception
|
||||||
* @param array $messages Error messages
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Exception $exception) {
|
public function __construct(Exception $exception) {
|
||||||
$this->controller = $this->_getController($exception);
|
$this->controller = $this->_getController($exception);
|
||||||
|
@ -142,7 +140,6 @@ class ExceptionRenderer {
|
||||||
*
|
*
|
||||||
* @param Exception $exception The exception to get a controller for.
|
* @param Exception $exception The exception to get a controller for.
|
||||||
* @return Controller
|
* @return Controller
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected function _getController($exception) {
|
protected function _getController($exception) {
|
||||||
App::uses('CakeErrorController', 'Controller');
|
App::uses('CakeErrorController', 'Controller');
|
||||||
|
@ -173,7 +170,7 @@ class ExceptionRenderer {
|
||||||
/**
|
/**
|
||||||
* Generic handler for the internal framework errors CakePHP can generate.
|
* Generic handler for the internal framework errors CakePHP can generate.
|
||||||
*
|
*
|
||||||
* @param CakeExeption $error
|
* @param CakeException $error
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _cakeError(CakeException $error) {
|
protected function _cakeError(CakeException $error) {
|
||||||
|
@ -197,7 +194,8 @@ class ExceptionRenderer {
|
||||||
/**
|
/**
|
||||||
* Convenience method to display a 400 series page.
|
* Convenience method to display a 400 series page.
|
||||||
*
|
*
|
||||||
* @param array $params Parameters for controller
|
* @param Exception $error
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function error400($error) {
|
public function error400($error) {
|
||||||
$message = $error->getMessage();
|
$message = $error->getMessage();
|
||||||
|
@ -217,7 +215,8 @@ class ExceptionRenderer {
|
||||||
/**
|
/**
|
||||||
* Convenience method to display a 500 page.
|
* Convenience method to display a 500 page.
|
||||||
*
|
*
|
||||||
* @param array $params Parameters for controller
|
* @param Exception $error
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function error500($error) {
|
public function error500($error) {
|
||||||
$url = $this->controller->request->here();
|
$url = $this->controller->request->here();
|
||||||
|
@ -235,6 +234,7 @@ class ExceptionRenderer {
|
||||||
* Generate the response using the controller object.
|
* Generate the response using the controller object.
|
||||||
*
|
*
|
||||||
* @param string $template The template to render.
|
* @param string $template The template to render.
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _outputMessage($template) {
|
protected function _outputMessage($template) {
|
||||||
$this->controller->render($template);
|
$this->controller->render($template);
|
||||||
|
@ -247,6 +247,7 @@ class ExceptionRenderer {
|
||||||
* and doesn't call component methods.
|
* and doesn't call component methods.
|
||||||
*
|
*
|
||||||
* @param string $template The template to render
|
* @param string $template The template to render
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _outputMessageSafe($template) {
|
protected function _outputMessageSafe($template) {
|
||||||
$this->controller->helpers = array('Form', 'Html', 'Session');
|
$this->controller->helpers = array('Form', 'Html', 'Session');
|
||||||
|
|
|
@ -64,37 +64,37 @@ class I18n {
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $__lang = null;
|
protected $_lang = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translation strings for a specific domain read from the .mo or .po files
|
* Translation strings for a specific domain read from the .mo or .po files
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $__domains = array();
|
protected $_domains = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to true when I18N::__bindTextDomain() is called for the first time.
|
* Set to true when I18N::_bindTextDomain() is called for the first time.
|
||||||
* If a translation file is found it is set to false again
|
* If a translation file is found it is set to false again
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $__noLocale = false;
|
protected $_noLocale = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to true when I18N::__bindTextDomain() is called for the first time.
|
* Set to true when I18N::_bindTextDomain() is called for the first time.
|
||||||
* If a translation file is found it is set to false again
|
* If a translation file is found it is set to false again
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $__categories = array(
|
protected $_categories = array(
|
||||||
'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'
|
'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a static instance of the I18n class
|
* Return a static instance of the I18n class
|
||||||
*
|
*
|
||||||
* @return object I18n
|
* @return I18n
|
||||||
*/
|
*/
|
||||||
public static function &getInstance() {
|
public static function &getInstance() {
|
||||||
static $instance = array();
|
static $instance = array();
|
||||||
|
@ -127,7 +127,7 @@ class I18n {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($category)) {
|
if (is_numeric($category)) {
|
||||||
$_this->category = $_this->__categories[$category];
|
$_this->category = $_this->_categories[$category];
|
||||||
}
|
}
|
||||||
$language = Configure::read('Config.language');
|
$language = Configure::read('Config.language');
|
||||||
|
|
||||||
|
@ -135,9 +135,9 @@ class I18n {
|
||||||
$language = $_SESSION['Config']['language'];
|
$language = $_SESSION['Config']['language'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($_this->__lang && $_this->__lang !== $language) || !$_this->__lang) {
|
if (($_this->_lang && $_this->_lang !== $language) || !$_this->_lang) {
|
||||||
$lang = $_this->l10n->get($language);
|
$lang = $_this->l10n->get($language);
|
||||||
$_this->__lang = $lang;
|
$_this->_lang = $lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($domain)) {
|
if (is_null($domain)) {
|
||||||
|
@ -146,24 +146,24 @@ class I18n {
|
||||||
|
|
||||||
$_this->domain = $domain . '_' . $_this->l10n->lang;
|
$_this->domain = $domain . '_' . $_this->l10n->lang;
|
||||||
|
|
||||||
if (!isset($_this->__domains[$domain][$_this->__lang])) {
|
if (!isset($_this->_domains[$domain][$_this->_lang])) {
|
||||||
$_this->__domains[$domain][$_this->__lang] = Cache::read($_this->domain, '_cake_core_');
|
$_this->_domains[$domain][$_this->_lang] = Cache::read($_this->domain, '_cake_core_');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($_this->__domains[$domain][$_this->__lang][$_this->category])) {
|
if (!isset($_this->_domains[$domain][$_this->_lang][$_this->category])) {
|
||||||
$_this->__bindTextDomain($domain);
|
$_this->_bindTextDomain($domain);
|
||||||
Cache::write($_this->domain, $_this->__domains[$domain][$_this->__lang], '_cake_core_');
|
Cache::write($_this->domain, $_this->_domains[$domain][$_this->_lang], '_cake_core_');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_this->category == 'LC_TIME') {
|
if ($_this->category == 'LC_TIME') {
|
||||||
return $_this->__translateTime($singular,$domain);
|
return $_this->_translateTime($singular,$domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($count)) {
|
if (!isset($count)) {
|
||||||
$plurals = 0;
|
$plurals = 0;
|
||||||
} elseif (!empty($_this->__domains[$domain][$_this->__lang][$_this->category]["%plural-c"]) && $_this->__noLocale === false) {
|
} elseif (!empty($_this->_domains[$domain][$_this->_lang][$_this->category]["%plural-c"]) && $_this->_noLocale === false) {
|
||||||
$header = $_this->__domains[$domain][$_this->__lang][$_this->category]["%plural-c"];
|
$header = $_this->_domains[$domain][$_this->_lang][$_this->category]["%plural-c"];
|
||||||
$plurals = $_this->__pluralGuess($header, $count);
|
$plurals = $_this->_pluralGuess($header, $count);
|
||||||
} else {
|
} else {
|
||||||
if ($count != 1) {
|
if ($count != 1) {
|
||||||
$plurals = 1;
|
$plurals = 1;
|
||||||
|
@ -172,8 +172,8 @@ class I18n {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_this->__domains[$domain][$_this->__lang][$_this->category][$singular])) {
|
if (!empty($_this->_domains[$domain][$_this->_lang][$_this->category][$singular])) {
|
||||||
if (($trans = $_this->__domains[$domain][$_this->__lang][$_this->category][$singular]) || ($plurals) && ($trans = $_this->__domains[$domain][$_this->__lang][$_this->category][$plural])) {
|
if (($trans = $_this->_domains[$domain][$_this->_lang][$_this->category][$singular]) || ($plurals) && ($trans = $_this->_domains[$domain][$_this->_lang][$_this->category][$plural])) {
|
||||||
if (is_array($trans)) {
|
if (is_array($trans)) {
|
||||||
if (isset($trans[$plurals])) {
|
if (isset($trans[$plurals])) {
|
||||||
$trans = $trans[$plurals];
|
$trans = $trans[$plurals];
|
||||||
|
@ -198,7 +198,7 @@ class I18n {
|
||||||
*/
|
*/
|
||||||
public static function clear() {
|
public static function clear() {
|
||||||
$self = I18n::getInstance();
|
$self = I18n::getInstance();
|
||||||
$self->__domains = array();
|
$self->_domains = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -208,17 +208,17 @@ class I18n {
|
||||||
*/
|
*/
|
||||||
public static function domains() {
|
public static function domains() {
|
||||||
$self = I18n::getInstance();
|
$self = I18n::getInstance();
|
||||||
return $self->__domains;
|
return $self->_domains;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to find the plural form of a string.
|
* Attempts to find the plural form of a string.
|
||||||
*
|
*
|
||||||
* @param string $header Type
|
* @param string $header Type
|
||||||
* @param integrer $n Number
|
* @param integer $n Number
|
||||||
* @return integer plural match
|
* @return integer plural match
|
||||||
*/
|
*/
|
||||||
private function __pluralGuess($header, $n) {
|
protected function _pluralGuess($header, $n) {
|
||||||
if (!is_string($header) || $header === "nplurals=1;plural=0;" || !isset($header[0])) {
|
if (!is_string($header) || $header === "nplurals=1;plural=0;" || !isset($header[0])) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -266,8 +266,8 @@ class I18n {
|
||||||
* @param string $domain Domain to bind
|
* @param string $domain Domain to bind
|
||||||
* @return string Domain binded
|
* @return string Domain binded
|
||||||
*/
|
*/
|
||||||
private function __bindTextDomain($domain) {
|
protected function _bindTextDomain($domain) {
|
||||||
$this->__noLocale = true;
|
$this->_noLocale = true;
|
||||||
$core = true;
|
$core = true;
|
||||||
$merge = array();
|
$merge = array();
|
||||||
$searchPaths = App::path('locales');
|
$searchPaths = App::path('locales');
|
||||||
|
@ -295,69 +295,70 @@ class I18n {
|
||||||
$app = $directory . $lang . DS . $this->category . DS . 'core';
|
$app = $directory . $lang . DS . $this->category . DS . 'core';
|
||||||
|
|
||||||
if (file_exists($fn = "$app.mo")) {
|
if (file_exists($fn = "$app.mo")) {
|
||||||
$this->__loadMo($fn, $domain);
|
$this->_loadMo($fn, $domain);
|
||||||
$this->__noLocale = false;
|
$this->_noLocale = false;
|
||||||
$merge[$domain][$this->__lang][$this->category] = $this->__domains[$domain][$this->__lang][$this->category];
|
$merge[$domain][$this->_lang][$this->category] = $this->_domains[$domain][$this->_lang][$this->category];
|
||||||
$core = null;
|
$core = null;
|
||||||
} elseif (file_exists($fn = "$app.po") && ($f = fopen($fn, "r"))) {
|
} elseif (file_exists($fn = "$app.po") && ($f = fopen($fn, "r"))) {
|
||||||
$this->__loadPo($f, $domain);
|
$this->_loadPo($f, $domain);
|
||||||
$this->__noLocale = false;
|
$this->_noLocale = false;
|
||||||
$merge[$domain][$this->__lang][$this->category] = $this->__domains[$domain][$this->__lang][$this->category];
|
$merge[$domain][$this->_lang][$this->category] = $this->_domains[$domain][$this->_lang][$this->category];
|
||||||
$core = null;
|
$core = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($fn = "$file.mo")) {
|
if (file_exists($fn = "$file.mo")) {
|
||||||
$this->__loadMo($fn, $domain);
|
$this->_loadMo($fn, $domain);
|
||||||
$this->__noLocale = false;
|
$this->_noLocale = false;
|
||||||
break 2;
|
break 2;
|
||||||
} elseif (file_exists($fn = "$file.po") && ($f = fopen($fn, "r"))) {
|
} elseif (file_exists($fn = "$file.po") && ($f = fopen($fn, "r"))) {
|
||||||
$this->__loadPo($f, $domain);
|
$this->_loadPo($f, $domain);
|
||||||
$this->__noLocale = false;
|
$this->_noLocale = false;
|
||||||
break 2;
|
break 2;
|
||||||
} elseif (is_file($localeDef) && ($f = fopen($localeDef, "r"))) {
|
} elseif (is_file($localeDef) && ($f = fopen($localeDef, "r"))) {
|
||||||
$this->__loadLocaleDefinition($f, $domain);
|
$this->_loadLocaleDefinition($f, $domain);
|
||||||
$this->__noLocale = false;
|
$this->_noLocale = false;
|
||||||
return $domain;
|
return $domain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->__domains[$domain][$this->__lang][$this->category])) {
|
if (empty($this->_domains[$domain][$this->_lang][$this->category])) {
|
||||||
$this->__domains[$domain][$this->__lang][$this->category] = array();
|
$this->_domains[$domain][$this->_lang][$this->category] = array();
|
||||||
return $domain;
|
return $domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->__domains[$domain][$this->__lang][$this->category][""])) {
|
if (isset($this->_domains[$domain][$this->_lang][$this->category][""])) {
|
||||||
$head = $this->__domains[$domain][$this->__lang][$this->category][""];
|
$head = $this->_domains[$domain][$this->_lang][$this->category][""];
|
||||||
|
|
||||||
foreach (explode("\n", $head) as $line) {
|
foreach (explode("\n", $head) as $line) {
|
||||||
$header = strtok($line,":");
|
$header = strtok($line,":");
|
||||||
$line = trim(strtok("\n"));
|
$line = trim(strtok("\n"));
|
||||||
$this->__domains[$domain][$this->__lang][$this->category]["%po-header"][strtolower($header)] = $line;
|
$this->_domains[$domain][$this->_lang][$this->category]["%po-header"][strtolower($header)] = $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->__domains[$domain][$this->__lang][$this->category]["%po-header"]["plural-forms"])) {
|
if (isset($this->_domains[$domain][$this->_lang][$this->category]["%po-header"]["plural-forms"])) {
|
||||||
$switch = preg_replace("/(?:[() {}\\[\\]^\\s*\\]]+)/", "", $this->__domains[$domain][$this->__lang][$this->category]["%po-header"]["plural-forms"]);
|
$switch = preg_replace("/(?:[() {}\\[\\]^\\s*\\]]+)/", "", $this->_domains[$domain][$this->_lang][$this->category]["%po-header"]["plural-forms"]);
|
||||||
$this->__domains[$domain][$this->__lang][$this->category]["%plural-c"] = $switch;
|
$this->_domains[$domain][$this->_lang][$this->category]["%plural-c"] = $switch;
|
||||||
unset($this->__domains[$domain][$this->__lang][$this->category]["%po-header"]);
|
unset($this->_domains[$domain][$this->_lang][$this->category]["%po-header"]);
|
||||||
}
|
}
|
||||||
$this->__domains = Set::pushDiff($this->__domains, $merge);
|
$this->_domains = Set::pushDiff($this->_domains, $merge);
|
||||||
|
|
||||||
if (isset($this->__domains[$domain][$this->__lang][$this->category][null])) {
|
if (isset($this->_domains[$domain][$this->_lang][$this->category][null])) {
|
||||||
unset($this->__domains[$domain][$this->__lang][$this->category][null]);
|
unset($this->_domains[$domain][$this->_lang][$this->category][null]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $domain;
|
return $domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the binary .mo file for translation and sets the values for this translation in the var I18n::__domains
|
* Loads the binary .mo file for translation and sets the values for this translation in the var I18n::_domains
|
||||||
*
|
*
|
||||||
* @param resource $file Binary .mo file to load
|
* @param resource $file Binary .mo file to load
|
||||||
* @param string $domain Domain where to load file in
|
* @param string $domain Domain where to load file in
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function __loadMo($file, $domain) {
|
protected function _loadMo($file, $domain) {
|
||||||
$data = file_get_contents($file);
|
$data = file_get_contents($file);
|
||||||
|
|
||||||
if ($data) {
|
if ($data) {
|
||||||
|
@ -380,10 +381,10 @@ class I18n {
|
||||||
if (strpos($msgstr, "\000")) {
|
if (strpos($msgstr, "\000")) {
|
||||||
$msgstr = explode("\000", $msgstr);
|
$msgstr = explode("\000", $msgstr);
|
||||||
}
|
}
|
||||||
$this->__domains[$domain][$this->__lang][$this->category][$msgid] = $msgstr;
|
$this->_domains[$domain][$this->_lang][$this->category][$msgid] = $msgstr;
|
||||||
|
|
||||||
if (isset($msgid_plural)) {
|
if (isset($msgid_plural)) {
|
||||||
$this->__domains[$domain][$this->__lang][$this->category][$msgid_plural] =& $this->__domains[$domain][$this->__lang][$this->category][$msgid];
|
$this->_domains[$domain][$this->_lang][$this->category][$msgid_plural] =& $this->_domains[$domain][$this->_lang][$this->category][$msgid];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -391,13 +392,13 @@ class I18n {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the text .po file for translation and sets the values for this translation in the var I18n::__domains
|
* Loads the text .po file for translation and sets the values for this translation in the var I18n::_domains
|
||||||
*
|
*
|
||||||
* @param resource $file Text .po file to load
|
* @param resource $file Text .po file to load
|
||||||
* @param string $domain Domain to load file in
|
* @param string $domain Domain to load file in
|
||||||
* @return array Binded domain elements
|
* @return array Binded domain elements
|
||||||
*/
|
*/
|
||||||
private function __loadPo($file, $domain) {
|
protected function _loadPo($file, $domain) {
|
||||||
$type = 0;
|
$type = 0;
|
||||||
$translations = array();
|
$translations = array();
|
||||||
$translationKey = "";
|
$translationKey = "";
|
||||||
|
@ -457,7 +458,7 @@ class I18n {
|
||||||
} while (!feof($file));
|
} while (!feof($file));
|
||||||
fclose($file);
|
fclose($file);
|
||||||
$merge[""] = $header;
|
$merge[""] = $header;
|
||||||
return $this->__domains[$domain][$this->__lang][$this->category] = array_merge($merge ,$translations);
|
return $this->_domains[$domain][$this->_lang][$this->category] = array_merge($merge ,$translations);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -467,7 +468,7 @@ class I18n {
|
||||||
* @param string $domain Domain where locale definitions will be stored
|
* @param string $domain Domain where locale definitions will be stored
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function __loadLocaleDefinition($file, $domain = null) {
|
protected function _loadLocaleDefinition($file, $domain = null) {
|
||||||
$comment = '#';
|
$comment = '#';
|
||||||
$escape = '\\';
|
$escape = '\\';
|
||||||
$currentToken = false;
|
$currentToken = false;
|
||||||
|
@ -509,14 +510,14 @@ class I18n {
|
||||||
$this->__escape = $escape;
|
$this->__escape = $escape;
|
||||||
foreach ($value as $i => $val) {
|
foreach ($value as $i => $val) {
|
||||||
$val = trim($val, '"');
|
$val = trim($val, '"');
|
||||||
$val = preg_replace_callback('/(?:<)?(.[^>]*)(?:>)?/', array(&$this, '__parseLiteralValue'), $val);
|
$val = preg_replace_callback('/(?:<)?(.[^>]*)(?:>)?/', array(&$this, '_parseLiteralValue'), $val);
|
||||||
$val = str_replace($replacements, $mustEscape, $val);
|
$val = str_replace($replacements, $mustEscape, $val);
|
||||||
$value[$i] = $val;
|
$value[$i] = $val;
|
||||||
}
|
}
|
||||||
if (count($value) == 1) {
|
if (count($value) == 1) {
|
||||||
$this->__domains[$domain][$this->__lang][$this->category][$currentToken] = array_pop($value);
|
$this->_domains[$domain][$this->_lang][$this->category][$currentToken] = array_pop($value);
|
||||||
} else {
|
} else {
|
||||||
$this->__domains[$domain][$this->__lang][$this->category][$currentToken] = $value;
|
$this->_domains[$domain][$this->_lang][$this->category][$currentToken] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,7 +528,7 @@ class I18n {
|
||||||
* @param string $string Symbol to be parsed
|
* @param string $string Symbol to be parsed
|
||||||
* @return string parsed symbol
|
* @return string parsed symbol
|
||||||
*/
|
*/
|
||||||
private function __parseLiteralValue($string) {
|
protected function _parseLiteralValue($string) {
|
||||||
$string = $string[1];
|
$string = $string[1];
|
||||||
if (substr($string, 0, 2) === $this->__escape . 'x') {
|
if (substr($string, 0, 2) === $this->__escape . 'x') {
|
||||||
$delimiter = $this->__escape . 'x';
|
$delimiter = $this->__escape . 'x';
|
||||||
|
@ -558,9 +559,9 @@ class I18n {
|
||||||
* @param string $domain Domain where format is stored
|
* @param string $domain Domain where format is stored
|
||||||
* @return mixed translated format string if only value or array of translated strings for corresponding format.
|
* @return mixed translated format string if only value or array of translated strings for corresponding format.
|
||||||
*/
|
*/
|
||||||
private function __translateTime($format, $domain) {
|
protected function _translateTime($format, $domain) {
|
||||||
if (!empty($this->__domains[$domain][$this->__lang]['LC_TIME'][$format])) {
|
if (!empty($this->_domains[$domain][$this->_lang]['LC_TIME'][$format])) {
|
||||||
if (($trans = $this->__domains[$domain][$this->__lang][$this->category][$format])) {
|
if (($trans = $this->_domains[$domain][$this->_lang][$this->category][$format])) {
|
||||||
return $trans;
|
return $trans;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ class L10n {
|
||||||
* The language for current locale
|
* The language for current locale
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $language = 'English (United States)';
|
public $language = 'English (United States)';
|
||||||
|
|
||||||
|
@ -37,7 +36,6 @@ class L10n {
|
||||||
* Locale search paths
|
* Locale search paths
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $languagePath = array('eng');
|
public $languagePath = array('eng');
|
||||||
|
|
||||||
|
@ -45,7 +43,6 @@ class L10n {
|
||||||
* ISO 639-3 for current locale
|
* ISO 639-3 for current locale
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $lang = 'eng';
|
public $lang = 'eng';
|
||||||
|
|
||||||
|
@ -53,7 +50,6 @@ class L10n {
|
||||||
* Locale
|
* Locale
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $locale = 'en_us';
|
public $locale = 'en_us';
|
||||||
|
|
||||||
|
@ -63,7 +59,6 @@ class L10n {
|
||||||
* DEFAULT_LANGUAGE is defined in an application this will be set as a fall back
|
* DEFAULT_LANGUAGE is defined in an application this will be set as a fall back
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $default = null;
|
public $default = null;
|
||||||
|
|
||||||
|
@ -71,7 +66,6 @@ class L10n {
|
||||||
* Encoding used for current locale
|
* Encoding used for current locale
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $charset = 'utf-8';
|
public $charset = 'utf-8';
|
||||||
|
|
||||||
|
@ -79,7 +73,6 @@ class L10n {
|
||||||
* Text direction for current locale
|
* Text direction for current locale
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $direction = 'ltr';
|
public $direction = 'ltr';
|
||||||
|
|
||||||
|
@ -87,17 +80,15 @@ class L10n {
|
||||||
* Set to true if a locale is found
|
* Set to true if a locale is found
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $found = false;
|
public $found = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps ISO 639-3 to I10n::__l10nCatalog
|
* Maps ISO 639-3 to I10n::_l10nCatalog
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private $__l10nMap = array(/* Afrikaans */ 'afr' => 'af',
|
protected $_l10nMap = array(/* Afrikaans */ 'afr' => 'af',
|
||||||
/* Albanian */ 'alb' => 'sq',
|
/* Albanian */ 'alb' => 'sq',
|
||||||
/* Arabic */ 'ara' => 'ar',
|
/* Arabic */ 'ara' => 'ar',
|
||||||
/* Armenian - Armenia */ 'hye' => 'hy',
|
/* Armenian - Armenia */ 'hye' => 'hy',
|
||||||
|
@ -182,9 +173,8 @@ class L10n {
|
||||||
* holds all information related to a language
|
* holds all information related to a language
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private $__l10nCatalog = array('af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
protected $_l10nCatalog = array('af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr'),
|
||||||
'ar' => array('language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
|
'ar' => array('language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
|
||||||
'ar-ae' => array('language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
|
'ar-ae' => array('language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
|
||||||
'ar-bh' => array('language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
|
'ar-bh' => array('language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'),
|
||||||
|
@ -336,16 +326,17 @@ class L10n {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the settings for $language.
|
* Gets the settings for $language.
|
||||||
* If $language is null it attempt to get settings from L10n::__autoLanguage(); if this fails
|
* If $language is null it attempt to get settings from L10n::_autoLanguage(); if this fails
|
||||||
* the method will get the settings from L10n::__setLanguage();
|
* the method will get the settings from L10n::_setLanguage();
|
||||||
*
|
*
|
||||||
* @param string $language Language (if null will use DEFAULT_LANGUAGE if defined)
|
* @param string $language Language (if null will use DEFAULT_LANGUAGE if defined)
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get($language = null) {
|
public function get($language = null) {
|
||||||
if ($language !== null) {
|
if ($language !== null) {
|
||||||
return $this->__setLanguage($language);
|
return $this->_setLanguage($language);
|
||||||
} elseif ($this->__autoLanguage() === false) {
|
} elseif ($this->_autoLanguage() === false) {
|
||||||
return $this->__setLanguage();
|
return $this->_setLanguage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,38 +345,38 @@ class L10n {
|
||||||
* If $language is null it will use the DEFAULT_LANGUAGE if defined
|
* If $language is null it will use the DEFAULT_LANGUAGE if defined
|
||||||
*
|
*
|
||||||
* @param string $language Language (if null will use DEFAULT_LANGUAGE if defined)
|
* @param string $language Language (if null will use DEFAULT_LANGUAGE if defined)
|
||||||
* @access private
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private function __setLanguage($language = null) {
|
protected function _setLanguage($language = null) {
|
||||||
$langKey = null;
|
$langKey = null;
|
||||||
if ($language !== null && isset($this->__l10nMap[$language]) && isset($this->__l10nCatalog[$this->__l10nMap[$language]])) {
|
if ($language !== null && isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
|
||||||
$langKey = $this->__l10nMap[$language];
|
$langKey = $this->_l10nMap[$language];
|
||||||
} else if ($language !== null && isset($this->__l10nCatalog[$language])) {
|
} else if ($language !== null && isset($this->_l10nCatalog[$language])) {
|
||||||
$langKey = $language;
|
$langKey = $language;
|
||||||
} else if (defined('DEFAULT_LANGUAGE')) {
|
} else if (defined('DEFAULT_LANGUAGE')) {
|
||||||
$langKey = $language = DEFAULT_LANGUAGE;
|
$langKey = $language = DEFAULT_LANGUAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($langKey !== null && isset($this->__l10nCatalog[$langKey])) {
|
if ($langKey !== null && isset($this->_l10nCatalog[$langKey])) {
|
||||||
$this->language = $this->__l10nCatalog[$langKey]['language'];
|
$this->language = $this->_l10nCatalog[$langKey]['language'];
|
||||||
$this->languagePath = array(
|
$this->languagePath = array(
|
||||||
$this->__l10nCatalog[$langKey]['locale'],
|
$this->_l10nCatalog[$langKey]['locale'],
|
||||||
$this->__l10nCatalog[$langKey]['localeFallback']
|
$this->_l10nCatalog[$langKey]['localeFallback']
|
||||||
);
|
);
|
||||||
$this->lang = $language;
|
$this->lang = $language;
|
||||||
$this->locale = $this->__l10nCatalog[$langKey]['locale'];
|
$this->locale = $this->_l10nCatalog[$langKey]['locale'];
|
||||||
$this->charset = $this->__l10nCatalog[$langKey]['charset'];
|
$this->charset = $this->_l10nCatalog[$langKey]['charset'];
|
||||||
$this->direction = $this->__l10nCatalog[$langKey]['direction'];
|
$this->direction = $this->_l10nCatalog[$langKey]['direction'];
|
||||||
} else {
|
} else {
|
||||||
$this->lang = $language;
|
$this->lang = $language;
|
||||||
$this->languagePath = array($language);
|
$this->languagePath = array($language);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->default) {
|
if ($this->default) {
|
||||||
if (isset($this->__l10nMap[$this->default]) && isset($this->__l10nCatalog[$this->__l10nMap[$this->default]])) {
|
if (isset($this->_l10nMap[$this->default]) && isset($this->_l10nCatalog[$this->_l10nMap[$this->default]])) {
|
||||||
$this->languagePath[] = $this->__l10nCatalog[$this->__l10nMap[$this->default]]['localeFallback'];
|
$this->languagePath[] = $this->_l10nCatalog[$this->_l10nMap[$this->default]]['localeFallback'];
|
||||||
} else if (isset($this->__l10nCatalog[$this->default])) {
|
} else if (isset($this->_l10nCatalog[$this->default])) {
|
||||||
$this->languagePath[] = $this->__l10nCatalog[$this->default]['localeFallback'];
|
$this->languagePath[] = $this->_l10nCatalog[$this->default]['localeFallback'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->found = true;
|
$this->found = true;
|
||||||
|
@ -403,18 +394,17 @@ class L10n {
|
||||||
* Attempts to find the locale settings based on the HTTP_ACCEPT_LANGUAGE variable
|
* Attempts to find the locale settings based on the HTTP_ACCEPT_LANGUAGE variable
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private function __autoLanguage() {
|
protected function _autoLanguage() {
|
||||||
$_detectableLanguages = CakeRequest::acceptLanguage();
|
$_detectableLanguages = CakeRequest::acceptLanguage();
|
||||||
foreach ($_detectableLanguages as $key => $langKey) {
|
foreach ($_detectableLanguages as $key => $langKey) {
|
||||||
if (isset($this->__l10nCatalog[$langKey])) {
|
if (isset($this->_l10nCatalog[$langKey])) {
|
||||||
$this->__setLanguage($langKey);
|
$this->_setLanguage($langKey);
|
||||||
return true;
|
return true;
|
||||||
} else if (strpos($langKey, '-') !== false) {
|
} else if (strpos($langKey, '-') !== false) {
|
||||||
$langKey = substr($langKey, 0, 2);
|
$langKey = substr($langKey, 0, 2);
|
||||||
if (isset($this->__l10nCatalog[$langKey])) {
|
if (isset($this->_l10nCatalog[$langKey])) {
|
||||||
$this->__setLanguage($langKey);
|
$this->_setLanguage($langKey);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,14 +429,14 @@ class L10n {
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
} else if (is_string($mixed)) {
|
} else if (is_string($mixed)) {
|
||||||
if (strlen($mixed) === 2 && in_array($mixed, $this->__l10nMap)) {
|
if (strlen($mixed) === 2 && in_array($mixed, $this->_l10nMap)) {
|
||||||
return array_search($mixed, $this->__l10nMap);
|
return array_search($mixed, $this->_l10nMap);
|
||||||
} else if (isset($this->__l10nMap[$mixed])) {
|
} else if (isset($this->_l10nMap[$mixed])) {
|
||||||
return $this->__l10nMap[$mixed];
|
return $this->_l10nMap[$mixed];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $this->__l10nMap;
|
return $this->_l10nMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -466,13 +456,13 @@ class L10n {
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
} else if (is_string($language)) {
|
} else if (is_string($language)) {
|
||||||
if (isset($this->__l10nCatalog[$language])) {
|
if (isset($this->_l10nCatalog[$language])) {
|
||||||
return $this->__l10nCatalog[$language];
|
return $this->_l10nCatalog[$language];
|
||||||
} else if (isset($this->__l10nMap[$language]) && isset($this->__l10nCatalog[$this->__l10nMap[$language]])) {
|
} else if (isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
|
||||||
return $this->__l10nCatalog[$this->__l10nMap[$language]];
|
return $this->_l10nCatalog[$this->_l10nMap[$language]];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $this->__l10nCatalog;
|
return $this->_l10nCatalog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,27 +258,27 @@ class Multibyte {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $__caseFold = array();
|
protected static $_caseFold = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds an array of Unicode code point ranges
|
* Holds an array of Unicode code point ranges
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $__codeRange = array();
|
protected static $_codeRange = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the current code point range
|
* Holds the current code point range
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $__table = null;
|
protected static $_table = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a multibyte character string
|
* Converts a multibyte character string
|
||||||
* to the decimal value of the character
|
* to the decimal value of the character
|
||||||
*
|
*
|
||||||
* @param multibyte string $string
|
* @param string $string
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function utf8($string) {
|
public static function utf8($string) {
|
||||||
|
@ -341,8 +341,8 @@ class Multibyte {
|
||||||
/**
|
/**
|
||||||
* Find position of first occurrence of a case-insensitive string.
|
* Find position of first occurrence of a case-insensitive string.
|
||||||
*
|
*
|
||||||
* @param multi-byte string $haystack The string from which to get the position of the first occurrence of $needle.
|
* @param string $haystack The string from which to get the position of the first occurrence of $needle.
|
||||||
* @param multi-byte string $needle The string to find in $haystack.
|
* @param string $needle The string to find in $haystack.
|
||||||
* @param integer $offset The position in $haystack to start searching.
|
* @param integer $offset The position in $haystack to start searching.
|
||||||
* @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string,
|
* @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string,
|
||||||
* or false if $needle is not found.
|
* or false if $needle is not found.
|
||||||
|
@ -365,7 +365,7 @@ class Multibyte {
|
||||||
* If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
|
* If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle.
|
||||||
* If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
|
* If set to false, it returns all of $haystack from the first occurrence of $needle to the end,
|
||||||
* Default value is false.
|
* Default value is false.
|
||||||
* @return int|boolean The portion of $haystack, or false if $needle is not found.
|
* @return integer|boolean The portion of $haystack, or false if $needle is not found.
|
||||||
*/
|
*/
|
||||||
public static function stristr($haystack, $needle, $part = false) {
|
public static function stristr($haystack, $needle, $part = false) {
|
||||||
$php = (PHP_VERSION < 5.3);
|
$php = (PHP_VERSION < 5.3);
|
||||||
|
@ -780,7 +780,7 @@ class Multibyte {
|
||||||
$matched = true;
|
$matched = true;
|
||||||
} else {
|
} else {
|
||||||
$matched = false;
|
$matched = false;
|
||||||
$keys = self::__find($char, 'upper');
|
$keys = self::_find($char, 'upper');
|
||||||
|
|
||||||
if (!empty($keys)) {
|
if (!empty($keys)) {
|
||||||
foreach ($keys as $key => $value) {
|
foreach ($keys as $key => $value) {
|
||||||
|
@ -803,10 +803,7 @@ class Multibyte {
|
||||||
* Make a string uppercase
|
* Make a string uppercase
|
||||||
*
|
*
|
||||||
* @param string $string The string being uppercased.
|
* @param string $string The string being uppercased.
|
||||||
* @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used.
|
|
||||||
* @return string with all alphabetic characters converted to uppercase.
|
* @return string with all alphabetic characters converted to uppercase.
|
||||||
* @access public
|
|
||||||
* @static
|
|
||||||
*/
|
*/
|
||||||
public static function strtoupper($string) {
|
public static function strtoupper($string) {
|
||||||
$utf8Map = Multibyte::utf8($string);
|
$utf8Map = Multibyte::utf8($string);
|
||||||
|
@ -829,7 +826,7 @@ class Multibyte {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$matched = false;
|
$matched = false;
|
||||||
$keys = self::__find($char);
|
$keys = self::_find($char);
|
||||||
$keyCount = count($keys);
|
$keyCount = count($keys);
|
||||||
|
|
||||||
if (!empty($keys)) {
|
if (!empty($keys)) {
|
||||||
|
@ -1006,10 +1003,10 @@ class Multibyte {
|
||||||
/**
|
/**
|
||||||
* Return the Code points range for Unicode characters
|
* Return the Code points range for Unicode characters
|
||||||
*
|
*
|
||||||
* @param interger $decimal
|
* @param integer $decimal
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function __codepoint($decimal) {
|
protected static function _codepoint($decimal) {
|
||||||
if ($decimal > 128 && $decimal < 256) {
|
if ($decimal > 128 && $decimal < 256) {
|
||||||
$return = '0080_00ff'; // Latin-1 Supplement
|
$return = '0080_00ff'; // Latin-1 Supplement
|
||||||
} elseif ($decimal < 384) {
|
} elseif ($decimal < 384) {
|
||||||
|
@ -1047,7 +1044,7 @@ class Multibyte {
|
||||||
} else {
|
} else {
|
||||||
$return = false;
|
$return = false;
|
||||||
}
|
}
|
||||||
self::$__codeRange[$decimal] = $return;
|
self::$_codeRange[$decimal] = $return;
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,10 +1055,10 @@ class Multibyte {
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private static function __find($char, $type = 'lower') {
|
protected static function _find($char, $type = 'lower') {
|
||||||
$found = array();
|
$found = array();
|
||||||
if (!isset(self::$__codeRange[$char])) {
|
if (!isset(self::$_codeRange[$char])) {
|
||||||
$range = self::__codepoint($char);
|
$range = self::_codepoint($char);
|
||||||
if ($range === false) {
|
if ($range === false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1070,21 +1067,21 @@ class Multibyte {
|
||||||
Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS));
|
Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS));
|
||||||
}
|
}
|
||||||
Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_');
|
Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_');
|
||||||
self::$__caseFold[$range] = Configure::read($range);
|
self::$_caseFold[$range] = Configure::read($range);
|
||||||
Configure::delete($range);
|
Configure::delete($range);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::$__codeRange[$char]) {
|
if (!self::$_codeRange[$char]) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
self::$__table = self::$__codeRange[$char];
|
self::$_table = self::$_codeRange[$char];
|
||||||
$count = count(self::$__caseFold[self::$__table]);
|
$count = count(self::$_caseFold[self::$_table]);
|
||||||
|
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
if ($type === 'lower' && self::$__caseFold[self::$__table][$i][$type][0] === $char) {
|
if ($type === 'lower' && self::$_caseFold[self::$_table][$i][$type][0] === $char) {
|
||||||
$found[] = self::$__caseFold[self::$__table][$i];
|
$found[] = self::$_caseFold[self::$_table][$i];
|
||||||
} elseif ($type === 'upper' && self::$__caseFold[self::$__table][$i][$type] === $char) {
|
} elseif ($type === 'upper' && self::$_caseFold[self::$_table][$i][$type] === $char) {
|
||||||
$found[] = self::$__caseFold[self::$__table][$i];
|
$found[] = self::$_caseFold[self::$_table][$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $found;
|
return $found;
|
||||||
|
|
|
@ -112,6 +112,7 @@ class CakeLog {
|
||||||
*
|
*
|
||||||
* @param string $loggerName the plugin.className of the logger class you want to build.
|
* @param string $loggerName the plugin.className of the logger class you want to build.
|
||||||
* @return mixed boolean false on any failures, string of classname to use if search was successful.
|
* @return mixed boolean false on any failures, string of classname to use if search was successful.
|
||||||
|
* @throws CakeLogException
|
||||||
*/
|
*/
|
||||||
protected static function _getLogger($loggerName) {
|
protected static function _getLogger($loggerName) {
|
||||||
list($plugin, $loggerName) = pluginSplit($loggerName, true);
|
list($plugin, $loggerName) = pluginSplit($loggerName, true);
|
||||||
|
@ -136,7 +137,7 @@ class CakeLog {
|
||||||
* Removes a stream from the active streams. Once a stream has been removed
|
* Removes a stream from the active streams. Once a stream has been removed
|
||||||
* it will no longer have messages sent to it.
|
* it will no longer have messages sent to it.
|
||||||
*
|
*
|
||||||
* @param string $keyname Key name of a configured stream to remove.
|
* @param string $streamName Key name of a configured stream to remove.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function drop($streamName) {
|
public static function drop($streamName) {
|
||||||
|
|
|
@ -1,4 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* CakeLogInterface
|
||||||
|
*
|
||||||
|
* PHP 5
|
||||||
|
*
|
||||||
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||||
|
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
|
*
|
||||||
|
* Licensed under The MIT License
|
||||||
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
*
|
||||||
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
|
* @link http://cakephp.org CakePHP(tm) Project
|
||||||
|
* @package Cake.Log
|
||||||
|
* @since CakePHP(tm) v 2.0
|
||||||
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CakeLogStreamInterface is the interface that should be implemented
|
* CakeLogStreamInterface is the interface that should be implemented
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
App::uses('CakeLogInterface', 'Log');
|
App::uses('CakeLogInterface', 'Log');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File Storage stream for Logging. Writes logs to different files
|
* File Storage stream for Logging. Writes logs to different files
|
||||||
* based on the type of log it is.
|
* based on the type of log it is.
|
||||||
|
@ -43,9 +42,8 @@ class FileLog implements CakeLogInterface {
|
||||||
* - `path` the path to save logs on.
|
* - `path` the path to save logs on.
|
||||||
*
|
*
|
||||||
* @param array $options Options for the FileLog, see above.
|
* @param array $options Options for the FileLog, see above.
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
function __construct($options = array()) {
|
public function __construct($options = array()) {
|
||||||
$options += array('path' => LOGS);
|
$options += array('path' => LOGS);
|
||||||
$this->_path = $options['path'];
|
$this->_path = $options['path'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ class AclNode extends AppModel {
|
||||||
* Explicitly disable in-memory query caching for ACL models
|
* Explicitly disable in-memory query caching for ACL models
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $cacheQueries = false;
|
public $cacheQueries = false;
|
||||||
|
|
||||||
|
@ -41,7 +40,6 @@ class AclNode extends AppModel {
|
||||||
* ACL models use the Tree behavior
|
* ACL models use the Tree behavior
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $actsAs = array('Tree' => array('nested'));
|
public $actsAs = array('Tree' => array('nested'));
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ class Aco extends AclNode {
|
||||||
* Model name
|
* Model name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $name = 'Aco';
|
public $name = 'Aco';
|
||||||
|
|
||||||
|
@ -42,7 +41,6 @@ class Aco extends AclNode {
|
||||||
* Binds to ARO nodes through permissions settings
|
* Binds to ARO nodes through permissions settings
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $hasAndBelongsToMany = array('Aro' => array('with' => 'Permission'));
|
public $hasAndBelongsToMany = array('Aro' => array('with' => 'Permission'));
|
||||||
}
|
}
|
|
@ -34,7 +34,6 @@ class AcoAction extends AppModel {
|
||||||
* Model name
|
* Model name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $name = 'AcoAction';
|
public $name = 'AcoAction';
|
||||||
|
|
||||||
|
@ -42,7 +41,6 @@ class AcoAction extends AppModel {
|
||||||
* ACO Actions belong to ACOs
|
* ACO Actions belong to ACOs
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $belongsTo = array('Aco');
|
public $belongsTo = array('Aco');
|
||||||
}
|
}
|
|
@ -32,7 +32,6 @@ class Aro extends AclNode {
|
||||||
* Model name
|
* Model name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $name = 'Aro';
|
public $name = 'Aro';
|
||||||
|
|
||||||
|
@ -40,7 +39,6 @@ class Aro extends AclNode {
|
||||||
* AROs are linked to ACOs by means of Permission
|
* AROs are linked to ACOs by means of Permission
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $hasAndBelongsToMany = array('Aco' => array('with' => 'Permission'));
|
public $hasAndBelongsToMany = array('Aco' => array('with' => 'Permission'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
* Redistributions of files must retain the above copyright notice.
|
* Redistributions of files must retain the above copyright notice.
|
||||||
*
|
*
|
||||||
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc.
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
* @link http://cakephp.org CakePHP Project
|
* @link http://cakephp.org CakePHP Project
|
||||||
* @package Cake.Model.Behavior
|
* @package Cake.Model.Behavior
|
||||||
* @since CakePHP v 1.2.0.4487
|
* @since CakePHP v 1.2.0.4487
|
||||||
|
@ -33,12 +33,13 @@ class AclBehavior extends ModelBehavior {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $__typeMaps = array('requester' => 'Aro', 'controlled' => 'Aco', 'both' => array('Aro', 'Aco'));
|
protected $_typeMaps = array('requester' => 'Aro', 'controlled' => 'Aco', 'both' => array('Aro', 'Aco'));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the configuation for the model, and loads ACL models if they haven't been already
|
* Sets up the configuation for the model, and loads ACL models if they haven't been already
|
||||||
*
|
*
|
||||||
* @param mixed $config
|
* @param Model $model
|
||||||
|
* @param array $config
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setup($model, $config = array()) {
|
public function setup($model, $config = array()) {
|
||||||
|
@ -48,7 +49,7 @@ class AclBehavior extends ModelBehavior {
|
||||||
$this->settings[$model->name] = array_merge(array('type' => 'controlled'), (array)$config);
|
$this->settings[$model->name] = array_merge(array('type' => 'controlled'), (array)$config);
|
||||||
$this->settings[$model->name]['type'] = strtolower($this->settings[$model->name]['type']);
|
$this->settings[$model->name]['type'] = strtolower($this->settings[$model->name]['type']);
|
||||||
|
|
||||||
$types = $this->__typeMaps[$this->settings[$model->name]['type']];
|
$types = $this->_typeMaps[$this->settings[$model->name]['type']];
|
||||||
|
|
||||||
if (!is_array($types)) {
|
if (!is_array($types)) {
|
||||||
$types = array($types);
|
$types = array($types);
|
||||||
|
@ -64,6 +65,7 @@ class AclBehavior extends ModelBehavior {
|
||||||
/**
|
/**
|
||||||
* Retrieves the Aro/Aco node for this model
|
* Retrieves the Aro/Aco node for this model
|
||||||
*
|
*
|
||||||
|
* @param Model $model
|
||||||
* @param mixed $ref
|
* @param mixed $ref
|
||||||
* @param string $type Only needed when Acl is set up as 'both', specify 'Aro' or 'Aco' to get the correct node
|
* @param string $type Only needed when Acl is set up as 'both', specify 'Aro' or 'Aco' to get the correct node
|
||||||
* @return array
|
* @return array
|
||||||
|
@ -71,7 +73,7 @@ class AclBehavior extends ModelBehavior {
|
||||||
*/
|
*/
|
||||||
public function node($model, $ref = null, $type = null) {
|
public function node($model, $ref = null, $type = null) {
|
||||||
if (empty($type)) {
|
if (empty($type)) {
|
||||||
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
|
$type = $this->_typeMaps[$this->settings[$model->name]['type']];
|
||||||
if (is_array($type)) {
|
if (is_array($type)) {
|
||||||
trigger_error(__d('cake_dev', 'AclBehavior is setup with more then one type, please specify type parameter for node()'), E_USER_WARNING);
|
trigger_error(__d('cake_dev', 'AclBehavior is setup with more then one type, please specify type parameter for node()'), E_USER_WARNING);
|
||||||
return null;
|
return null;
|
||||||
|
@ -86,11 +88,12 @@ class AclBehavior extends ModelBehavior {
|
||||||
/**
|
/**
|
||||||
* Creates a new ARO/ACO node bound to this record
|
* Creates a new ARO/ACO node bound to this record
|
||||||
*
|
*
|
||||||
|
* @param Model $model
|
||||||
* @param boolean $created True if this is a new record
|
* @param boolean $created True if this is a new record
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterSave($model, $created) {
|
public function afterSave($model, $created) {
|
||||||
$types = $this->__typeMaps[$this->settings[$model->name]['type']];
|
$types = $this->_typeMaps[$this->settings[$model->name]['type']];
|
||||||
if (!is_array($types)) {
|
if (!is_array($types)) {
|
||||||
$types = array($types);
|
$types = array($types);
|
||||||
}
|
}
|
||||||
|
@ -116,10 +119,11 @@ class AclBehavior extends ModelBehavior {
|
||||||
/**
|
/**
|
||||||
* Destroys the ARO/ACO node bound to the deleted record
|
* Destroys the ARO/ACO node bound to the deleted record
|
||||||
*
|
*
|
||||||
|
* @param Model $model
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterDelete($model) {
|
public function afterDelete($model) {
|
||||||
$types = $this->__typeMaps[$this->settings[$model->name]['type']];
|
$types = $this->_typeMaps[$this->settings[$model->name]['type']];
|
||||||
if (!is_array($types)) {
|
if (!is_array($types)) {
|
||||||
$types = array($types);
|
$types = array($types);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* Types of relationships available for models
|
* Types of relationships available for models
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public $types = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
public $types = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||||
|
|
||||||
|
@ -40,7 +39,6 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* Runtime configuration for this behavior
|
* Runtime configuration for this behavior
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public $runtime = array();
|
public $runtime = array();
|
||||||
|
|
||||||
|
@ -58,8 +56,9 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* - autoFields: (boolean, optional) auto-add needed fields to fetch requested
|
* - autoFields: (boolean, optional) auto-add needed fields to fetch requested
|
||||||
* bindings. DEFAULTS TO: true
|
* bindings. DEFAULTS TO: true
|
||||||
*
|
*
|
||||||
* @param object $Model Model using the behavior
|
* @param Model $Model Model using the behavior
|
||||||
* @param array $settings Settings to override for model.
|
* @param array $settings Settings to override for model.
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setup($Model, $settings = array()) {
|
public function setup($Model, $settings = array()) {
|
||||||
if (!isset($this->settings[$Model->alias])) {
|
if (!isset($this->settings[$Model->alias])) {
|
||||||
|
@ -88,7 +87,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* )));
|
* )));
|
||||||
* }}}
|
* }}}
|
||||||
*
|
*
|
||||||
* @param object $Model Model using the behavior
|
* @param Model $Model Model using the behavior
|
||||||
* @param array $query Query parameters as set by cake
|
* @param array $query Query parameters as set by cake
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -226,9 +225,10 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* Resets original associations on models that may have receive multiple,
|
* Resets original associations on models that may have receive multiple,
|
||||||
* subsequent unbindings.
|
* subsequent unbindings.
|
||||||
*
|
*
|
||||||
* @param object $Model Model on which we are resetting
|
* @param Model $Model Model on which we are resetting
|
||||||
* @param array $results Results of the find operation
|
* @param array $results Results of the find operation
|
||||||
* @param bool $primary true if this is the primary model that issued the find operation, false otherwise
|
* @param boolean $primary true if this is the primary model that issued the find operation, false otherwise
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterFind($Model, $results, $primary) {
|
public function afterFind($Model, $results, $primary) {
|
||||||
if (!empty($Model->__backContainableAssociation)) {
|
if (!empty($Model->__backContainableAssociation)) {
|
||||||
|
@ -243,7 +243,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* Unbinds all relations from a model except the specified ones. Calling this function without
|
* Unbinds all relations from a model except the specified ones. Calling this function without
|
||||||
* parameters unbinds all related models.
|
* parameters unbinds all related models.
|
||||||
*
|
*
|
||||||
* @param object $Model Model on which binding restriction is being applied
|
* @param Model $Model Model on which binding restriction is being applied
|
||||||
* @return void
|
* @return void
|
||||||
* @link http://book.cakephp.org/view/1323/Containable#Using-Containable-1324
|
* @link http://book.cakephp.org/view/1323/Containable#Using-Containable-1324
|
||||||
*/
|
*/
|
||||||
|
@ -258,7 +258,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
* for restoring the bindings after using 'reset' => false as part of the
|
* for restoring the bindings after using 'reset' => false as part of the
|
||||||
* contain call.
|
* contain call.
|
||||||
*
|
*
|
||||||
* @param object $Model Model on which to reset bindings
|
* @param Model $Model Model on which to reset bindings
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function resetBindings($Model) {
|
public function resetBindings($Model) {
|
||||||
|
@ -279,10 +279,10 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
/**
|
/**
|
||||||
* Process containments for model.
|
* Process containments for model.
|
||||||
*
|
*
|
||||||
* @param object $Model Model on which binding restriction is being applied
|
* @param Model $Model Model on which binding restriction is being applied
|
||||||
* @param array $contain Parameters to use for restricting this model
|
* @param array $contain Parameters to use for restricting this model
|
||||||
* @param array $containments Current set of containments
|
* @param array $containments Current set of containments
|
||||||
* @param bool $throwErrors Wether unexisting bindings show throw errors
|
* @param boolean $throwErrors Wether unexisting bindings show throw errors
|
||||||
* @return array Containments
|
* @return array Containments
|
||||||
*/
|
*/
|
||||||
public function containments($Model, $contain, $containments = array(), $throwErrors = null) {
|
public function containments($Model, $contain, $containments = array(), $throwErrors = null) {
|
||||||
|
@ -383,7 +383,7 @@ class ContainableBehavior extends ModelBehavior {
|
||||||
/**
|
/**
|
||||||
* Calculate needed fields to fetch the required bindings for the given model.
|
* Calculate needed fields to fetch the required bindings for the given model.
|
||||||
*
|
*
|
||||||
* @param object $Model Model
|
* @param Model $Model Model
|
||||||
* @param array $map Map of relations for given model
|
* @param array $map Map of relations for given model
|
||||||
* @param mixed $fields If array, fields to initially load, if false use $Model as primary model
|
* @param mixed $fields If array, fields to initially load, if false use $Model as primary model
|
||||||
* @return array Fields
|
* @return array Fields
|
||||||
|
|
|
@ -352,7 +352,7 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* name to find/use. If no translateModel property is found 'I18nModel' will be used.
|
* name to find/use. If no translateModel property is found 'I18nModel' will be used.
|
||||||
*
|
*
|
||||||
* @param Model $model Model to get a translatemodel for.
|
* @param Model $model Model to get a translatemodel for.
|
||||||
* @return object
|
* @return Model
|
||||||
*/
|
*/
|
||||||
public function translateModel($model) {
|
public function translateModel($model) {
|
||||||
if (!isset($this->runtime[$model->alias]['model'])) {
|
if (!isset($this->runtime[$model->alias]['model'])) {
|
||||||
|
@ -376,10 +376,10 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* Bind translation for fields, optionally with hasMany association for
|
* Bind translation for fields, optionally with hasMany association for
|
||||||
* fake field
|
* fake field
|
||||||
*
|
*
|
||||||
* @param object instance of model
|
* @param Model $model instance of model
|
||||||
* @param mixed string with field or array(field1, field2=>AssocName, field3)
|
* @param string|array $fields string with field or array(field1, field2=>AssocName, field3)
|
||||||
* @param boolean $reset
|
* @param boolean $reset
|
||||||
* @return bool
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function bindTranslation($model, $fields, $reset = true) {
|
public function bindTranslation($model, $fields, $reset = true) {
|
||||||
if (is_string($fields)) {
|
if (is_string($fields)) {
|
||||||
|
@ -449,10 +449,10 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* Unbind translation for fields, optionally unbinds hasMany association for
|
* Unbind translation for fields, optionally unbinds hasMany association for
|
||||||
* fake field
|
* fake field
|
||||||
*
|
*
|
||||||
* @param object $model instance of model
|
* @param Model $model instance of model
|
||||||
* @param mixed $fields string with field, or array(field1, field2=>AssocName, field3), or null for
|
* @param mixed $fields string with field, or array(field1, field2=>AssocName, field3), or null for
|
||||||
* unbind all original translations
|
* unbind all original translations
|
||||||
* @return bool
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function unbindTranslation($model, $fields = null) {
|
public function unbindTranslation($model, $fields = null) {
|
||||||
if (empty($fields) && empty($this->settings[$model->alias])) {
|
if (empty($fields) && empty($this->settings[$model->alias])) {
|
||||||
|
@ -505,7 +505,26 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
* @package Cake.Model.Behavior
|
* @package Cake.Model.Behavior
|
||||||
*/
|
*/
|
||||||
class I18nModel extends AppModel {
|
class I18nModel extends AppModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $name = 'I18nModel';
|
public $name = 'I18nModel';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $useTable = 'i18n';
|
public $useTable = 'i18n';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display field
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $displayField = 'field';
|
public $displayField = 'field';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
* Redistributions of files must retain the above copyright notice.
|
* Redistributions of files must retain the above copyright notice.
|
||||||
*
|
*
|
||||||
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc.
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
* @link http://cakephp.org CakePHP Project
|
* @link http://cakephp.org CakePHP Project
|
||||||
* @package Cake.Model.Behavior
|
* @package Cake.Model.Behavior
|
||||||
* @since CakePHP v 1.2.0.4487
|
* @since CakePHP v 1.2.0.4487
|
||||||
|
@ -41,7 +41,6 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* Defaults
|
* Defaults
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_defaults = array(
|
protected $_defaults = array(
|
||||||
'parent' => 'parent_id', 'left' => 'lft', 'right' => 'rght',
|
'parent' => 'parent_id', 'left' => 'lft', 'right' => 'rght',
|
||||||
|
@ -51,7 +50,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
/**
|
/**
|
||||||
* Initiate Tree behavior
|
* Initiate Tree behavior
|
||||||
*
|
*
|
||||||
* @param object $Model instance of model
|
* @param Model $Model instance of model
|
||||||
* @param array $config array of configuration settings.
|
* @param array $config array of configuration settings.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -76,7 +75,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* Overriden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
|
* Overriden to transparently manage setting the lft and rght fields if and only if the parent field is included in the
|
||||||
* parameters to be saved.
|
* parameters to be saved.
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance.
|
* @param Model $Model Model instance.
|
||||||
* @param boolean $created indicates whether the node just saved was created or updated
|
* @param boolean $created indicates whether the node just saved was created or updated
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
|
@ -97,7 +96,8 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*
|
*
|
||||||
* Will delete the current node and all children using the deleteAll method and sync the table
|
* Will delete the current node and all children using the deleteAll method and sync the table
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
|
* @param boolean $cascade
|
||||||
* @return boolean true to continue, false to abort the delete
|
* @return boolean true to continue, false to abort the delete
|
||||||
*/
|
*/
|
||||||
public function beforeDelete($Model, $cascade = true) {
|
public function beforeDelete($Model, $cascade = true) {
|
||||||
|
@ -117,7 +117,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
$scope[]["{$Model->alias}.{$left} BETWEEN ? AND ?"] = array($data[$left] + 1, $data[$right] - 1);
|
$scope[]["{$Model->alias}.{$left} BETWEEN ? AND ?"] = array($data[$left] + 1, $data[$right] - 1);
|
||||||
$Model->deleteAll($scope);
|
$Model->deleteAll($scope);
|
||||||
}
|
}
|
||||||
$this->__sync($Model, $diff, '-', '> ' . $data[$right]);
|
$this->_sync($Model, $diff, '-', '> ' . $data[$right]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* this method bypassing the setParent logic.
|
* this method bypassing the setParent logic.
|
||||||
*
|
*
|
||||||
* @since 1.2
|
* @since 1.2
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @return boolean true to continue, false to abort the save
|
* @return boolean true to continue, false to abort the save
|
||||||
*/
|
*/
|
||||||
public function beforeSave($Model) {
|
public function beforeSave($Model) {
|
||||||
|
@ -149,7 +149,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
$Model->data[$Model->alias][$left] = 0; //$parentNode[$right];
|
$Model->data[$Model->alias][$left] = 0; //$parentNode[$right];
|
||||||
$Model->data[$Model->alias][$right] = 0; //$parentNode[$right] + 1;
|
$Model->data[$Model->alias][$right] = 0; //$parentNode[$right] + 1;
|
||||||
} else {
|
} else {
|
||||||
$edge = $this->__getMax($Model, $scope, $right, $recursive);
|
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
||||||
$Model->data[$Model->alias][$left] = $edge + 1;
|
$Model->data[$Model->alias][$left] = $edge + 1;
|
||||||
$Model->data[$Model->alias][$right] = $edge + 2;
|
$Model->data[$Model->alias][$right] = $edge + 2;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* If the direct parameter is set to true, only the direct children are counted (based upon the parent_id field)
|
* If the direct parameter is set to true, only the direct children are counted (based upon the parent_id field)
|
||||||
* If false is passed for the id parameter, all top level nodes are counted, or all nodes are counted.
|
* If false is passed for the id parameter, all top level nodes are counted, or all nodes are counted.
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param mixed $id The ID of the record to read or false to read all top level nodes
|
* @param mixed $id The ID of the record to read or false to read all top level nodes
|
||||||
* @param boolean $direct whether to count direct, or all, children
|
* @param boolean $direct whether to count direct, or all, children
|
||||||
* @return integer number of child nodes
|
* @return integer number of child nodes
|
||||||
|
@ -237,7 +237,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* If the direct parameter is set to true, only the direct children are returned (based upon the parent_id field)
|
* If the direct parameter is set to true, only the direct children are returned (based upon the parent_id field)
|
||||||
* If false is passed for the id parameter, top level, or all (depending on direct parameter appropriate) are counted.
|
* If false is passed for the id parameter, top level, or all (depending on direct parameter appropriate) are counted.
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param mixed $id The ID of the record to read
|
* @param mixed $id The ID of the record to read
|
||||||
* @param boolean $direct whether to return only the direct, or all, children
|
* @param boolean $direct whether to return only the direct, or all, children
|
||||||
* @param mixed $fields Either a single string of a field name, or an array of field names
|
* @param mixed $fields Either a single string of a field name, or an array of field names
|
||||||
|
@ -296,7 +296,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
/**
|
/**
|
||||||
* A convenience method for returning a hierarchical array used for HTML select boxes
|
* A convenience method for returning a hierarchical array used for HTML select boxes
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param mixed $conditions SQL conditions as a string or as an array('field' =>'value',...)
|
* @param mixed $conditions SQL conditions as a string or as an array('field' =>'value',...)
|
||||||
* @param string $keyPath A string path to the key, i.e. "{n}.Post.id"
|
* @param string $keyPath A string path to the key, i.e. "{n}.Post.id"
|
||||||
* @param string $valuePath A string path to the value, i.e. "{n}.Post.title"
|
* @param string $valuePath A string path to the value, i.e. "{n}.Post.title"
|
||||||
|
@ -354,10 +354,11 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*
|
*
|
||||||
* reads the parent id and returns this node
|
* reads the parent id and returns this node
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param mixed $id The ID of the record to read
|
* @param mixed $id The ID of the record to read
|
||||||
|
* @param string|array $fields
|
||||||
* @param integer $recursive The number of levels deep to fetch associated records
|
* @param integer $recursive The number of levels deep to fetch associated records
|
||||||
* @return array Array of data for the parent node
|
* @return array|boolean Array of data for the parent node
|
||||||
* @link http://book.cakephp.org/view/1349/getparentnode
|
* @link http://book.cakephp.org/view/1349/getparentnode
|
||||||
*/
|
*/
|
||||||
public function getParentNode($Model, $id = null, $fields = null, $recursive = null) {
|
public function getParentNode($Model, $id = null, $fields = null, $recursive = null) {
|
||||||
|
@ -386,7 +387,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
/**
|
/**
|
||||||
* Get the path to the given node
|
* Get the path to the given node
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param mixed $id The ID of the record to read
|
* @param mixed $id The ID of the record to read
|
||||||
* @param mixed $fields Either a single string of a field name, or an array of field names
|
* @param mixed $fields Either a single string of a field name, or an array of field names
|
||||||
* @param integer $recursive The number of levels deep to fetch associated records
|
* @param integer $recursive The number of levels deep to fetch associated records
|
||||||
|
@ -424,9 +425,9 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*
|
*
|
||||||
* If the node is the last child, or is a top level node with no subsequent node this method will return false
|
* If the node is the last child, or is a top level node with no subsequent node this method will return false
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param mixed $id The ID of the record to move
|
* @param mixed $id The ID of the record to move
|
||||||
* @param int|bool $number how many places to move the node or true to move to last position
|
* @param integer|boolean $number how many places to move the node or true to move to last position
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
* @link http://book.cakephp.org/view/1352/moveDown
|
* @link http://book.cakephp.org/view/1352/moveDown
|
||||||
*/
|
*/
|
||||||
|
@ -463,10 +464,10 @@ class TreeBehavior extends ModelBehavior {
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$edge = $this->__getMax($Model, $scope, $right, $recursive);
|
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
||||||
$this->__sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right]);
|
$this->_sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right]);
|
||||||
$this->__sync($Model, $nextNode[$left] - $node[$left], '-', 'BETWEEN ' . $nextNode[$left] . ' AND ' . $nextNode[$right]);
|
$this->_sync($Model, $nextNode[$left] - $node[$left], '-', 'BETWEEN ' . $nextNode[$left] . ' AND ' . $nextNode[$right]);
|
||||||
$this->__sync($Model, $edge - $node[$left] - ($nextNode[$right] - $nextNode[$left]), '-', '> ' . $edge);
|
$this->_sync($Model, $edge - $node[$left] - ($nextNode[$right] - $nextNode[$left]), '-', '> ' . $edge);
|
||||||
|
|
||||||
if (is_int($number)) {
|
if (is_int($number)) {
|
||||||
$number--;
|
$number--;
|
||||||
|
@ -482,9 +483,9 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*
|
*
|
||||||
* If the node is the first child, or is a top level node with no previous node this method will return false
|
* If the node is the first child, or is a top level node with no previous node this method will return false
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param mixed $id The ID of the record to move
|
* @param mixed $id The ID of the record to move
|
||||||
* @param int|bool $number how many places to move the node, or true to move to first position
|
* @param integer|boolean $number how many places to move the node, or true to move to first position
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
* @link http://book.cakephp.org/view/1353/moveUp
|
* @link http://book.cakephp.org/view/1353/moveUp
|
||||||
*/
|
*/
|
||||||
|
@ -523,10 +524,10 @@ class TreeBehavior extends ModelBehavior {
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$edge = $this->__getMax($Model, $scope, $right, $recursive);
|
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
||||||
$this->__sync($Model, $edge - $previousNode[$left] +1, '+', 'BETWEEN ' . $previousNode[$left] . ' AND ' . $previousNode[$right]);
|
$this->_sync($Model, $edge - $previousNode[$left] +1, '+', 'BETWEEN ' . $previousNode[$left] . ' AND ' . $previousNode[$right]);
|
||||||
$this->__sync($Model, $node[$left] - $previousNode[$left], '-', 'BETWEEN ' .$node[$left] . ' AND ' . $node[$right]);
|
$this->_sync($Model, $node[$left] - $previousNode[$left], '-', 'BETWEEN ' .$node[$left] . ' AND ' . $node[$right]);
|
||||||
$this->__sync($Model, $edge - $previousNode[$left] - ($node[$right] - $node[$left]), '-', '> ' . $edge);
|
$this->_sync($Model, $edge - $previousNode[$left] - ($node[$right] - $node[$left]), '-', '> ' . $edge);
|
||||||
if (is_int($number)) {
|
if (is_int($number)) {
|
||||||
$number--;
|
$number--;
|
||||||
}
|
}
|
||||||
|
@ -545,7 +546,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* parameter only applies to "parent" mode and determines what to do if the parent field contains an id that is not present.
|
* parameter only applies to "parent" mode and determines what to do if the parent field contains an id that is not present.
|
||||||
*
|
*
|
||||||
* @todo Could be written to be faster, *maybe*. Ideally using a subquery and putting all the logic burden on the DB.
|
* @todo Could be written to be faster, *maybe*. Ideally using a subquery and putting all the logic burden on the DB.
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param string $mode parent or tree
|
* @param string $mode parent or tree
|
||||||
* @param mixed $missingParentAction 'return' to do nothing and return, 'delete' to
|
* @param mixed $missingParentAction 'return' to do nothing and return, 'delete' to
|
||||||
* delete, or the id of the parent to set as the parent_id
|
* delete, or the id of the parent to set as the parent_id
|
||||||
|
@ -626,7 +627,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* - 'order' Direction to order either DESC or ASC (defaults to ASC)
|
* - 'order' Direction to order either DESC or ASC (defaults to ASC)
|
||||||
* - 'verify' Whether or not to verify the tree before reorder. defaults to true.
|
* - 'verify' Whether or not to verify the tree before reorder. defaults to true.
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param array $options array of options to use in reordering.
|
* @param array $options array of options to use in reordering.
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
* @link http://book.cakephp.org/view/1355/reorder
|
* @link http://book.cakephp.org/view/1355/reorder
|
||||||
|
@ -665,7 +666,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* If the parameter delete is false, the node will become a new top level node. Otherwise the node will be deleted
|
* If the parameter delete is false, the node will become a new top level node. Otherwise the node will be deleted
|
||||||
* after the children are reparented.
|
* after the children are reparented.
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param mixed $id The ID of the record to remove
|
* @param mixed $id The ID of the record to remove
|
||||||
* @param boolean $delete whether to delete the node after reparenting children (if any)
|
* @param boolean $delete whether to delete the node after reparenting children (if any)
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
|
@ -705,8 +706,8 @@ class TreeBehavior extends ModelBehavior {
|
||||||
array($parent => $db->value($node[$parent], $parent)),
|
array($parent => $db->value($node[$parent], $parent)),
|
||||||
array($Model->escapeField($parent) => $node[$Model->primaryKey])
|
array($Model->escapeField($parent) => $node[$Model->primaryKey])
|
||||||
);
|
);
|
||||||
$this->__sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
|
$this->_sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
|
||||||
$this->__sync($Model, 2, '-', '> ' . ($node[$right]));
|
$this->_sync($Model, 2, '-', '> ' . ($node[$right]));
|
||||||
$Model->id = $id;
|
$Model->id = $id;
|
||||||
|
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
|
@ -720,7 +721,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
);
|
);
|
||||||
return $Model->delete($id);
|
return $Model->delete($id);
|
||||||
} else {
|
} else {
|
||||||
$edge = $this->__getMax($Model, $scope, $right, $recursive);
|
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
||||||
if ($node[$right] == $edge) {
|
if ($node[$right] == $edge) {
|
||||||
$edge = $edge - 2;
|
$edge = $edge - 2;
|
||||||
}
|
}
|
||||||
|
@ -737,7 +738,7 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*
|
*
|
||||||
* Returns true if the tree is valid otherwise an array of (type, incorrect left/right index, message)
|
* Returns true if the tree is valid otherwise an array of (type, incorrect left/right index, message)
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @return mixed true if the tree is valid or empty, otherwise an array of (error type [index, node],
|
* @return mixed true if the tree is valid or empty, otherwise an array of (error type [index, node],
|
||||||
* [incorrect left/right index,node id], message)
|
* [incorrect left/right index,node id], message)
|
||||||
* @link http://book.cakephp.org/view/1630/Verify
|
* @link http://book.cakephp.org/view/1630/Verify
|
||||||
|
@ -747,8 +748,8 @@ class TreeBehavior extends ModelBehavior {
|
||||||
if (!$Model->find('count', array('conditions' => $scope))) {
|
if (!$Model->find('count', array('conditions' => $scope))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$min = $this->__getMin($Model, $scope, $left, $recursive);
|
$min = $this->_getMin($Model, $scope, $left, $recursive);
|
||||||
$edge = $this->__getMax($Model, $scope, $right, $recursive);
|
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
for ($i = $min; $i <= $edge; $i++) {
|
for ($i = $min; $i <= $edge; $i++) {
|
||||||
|
@ -809,8 +810,9 @@ class TreeBehavior extends ModelBehavior {
|
||||||
* of recovering a corrupted table, or creating new nodes. Otherwise it should always be false. In reality this
|
* of recovering a corrupted table, or creating new nodes. Otherwise it should always be false. In reality this
|
||||||
* method could be private, since calling save with parent_id set also calls setParent
|
* method could be private, since calling save with parent_id set also calls setParent
|
||||||
*
|
*
|
||||||
* @param AppModel $Model Model instance
|
* @param Model $Model Model instance
|
||||||
* @param mixed $parentId
|
* @param mixed $parentId
|
||||||
|
* @param boolean $created
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
protected function _setParent($Model, $parentId = null, $created = false) {
|
protected function _setParent($Model, $parentId = null, $created = false) {
|
||||||
|
@ -820,11 +822,11 @@ class TreeBehavior extends ModelBehavior {
|
||||||
'fields' => array($Model->primaryKey, $parent, $left, $right),
|
'fields' => array($Model->primaryKey, $parent, $left, $right),
|
||||||
'recursive' => $recursive
|
'recursive' => $recursive
|
||||||
)));
|
)));
|
||||||
$edge = $this->__getMax($Model, $scope, $right, $recursive, $created);
|
$edge = $this->_getMax($Model, $scope, $right, $recursive, $created);
|
||||||
|
|
||||||
if (empty ($parentId)) {
|
if (empty ($parentId)) {
|
||||||
$this->__sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created);
|
$this->_sync($Model, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created);
|
||||||
$this->__sync($Model, $node[$right] - $node[$left] + 1, '-', '> ' . $node[$left], $created);
|
$this->_sync($Model, $node[$right] - $node[$left] + 1, '-', '> ' . $node[$left], $created);
|
||||||
} else {
|
} else {
|
||||||
$values = $Model->find('first', array(
|
$values = $Model->find('first', array(
|
||||||
'conditions' => array($scope, $Model->escapeField() => $parentId),
|
'conditions' => array($scope, $Model->escapeField() => $parentId),
|
||||||
|
@ -849,27 +851,27 @@ class TreeBehavior extends ModelBehavior {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (empty ($node[$left]) && empty ($node[$right])) {
|
if (empty ($node[$left]) && empty ($node[$right])) {
|
||||||
$this->__sync($Model, 2, '+', '>= ' . $parentNode[$right], $created);
|
$this->_sync($Model, 2, '+', '>= ' . $parentNode[$right], $created);
|
||||||
$result = $Model->save(
|
$result = $Model->save(
|
||||||
array($left => $parentNode[$right], $right => $parentNode[$right] + 1, $parent => $parentId),
|
array($left => $parentNode[$right], $right => $parentNode[$right] + 1, $parent => $parentId),
|
||||||
array('validate' => false, 'callbacks' => false)
|
array('validate' => false, 'callbacks' => false)
|
||||||
);
|
);
|
||||||
$Model->data = $result;
|
$Model->data = $result;
|
||||||
} else {
|
} else {
|
||||||
$this->__sync($Model, $edge - $node[$left] +1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created);
|
$this->_sync($Model, $edge - $node[$left] +1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created);
|
||||||
$diff = $node[$right] - $node[$left] + 1;
|
$diff = $node[$right] - $node[$left] + 1;
|
||||||
|
|
||||||
if ($node[$left] > $parentNode[$left]) {
|
if ($node[$left] > $parentNode[$left]) {
|
||||||
if ($node[$right] < $parentNode[$right]) {
|
if ($node[$right] < $parentNode[$right]) {
|
||||||
$this->__sync($Model, $diff, '-', 'BETWEEN ' . $node[$right] . ' AND ' . ($parentNode[$right] - 1), $created);
|
$this->_sync($Model, $diff, '-', 'BETWEEN ' . $node[$right] . ' AND ' . ($parentNode[$right] - 1), $created);
|
||||||
$this->__sync($Model, $edge - $parentNode[$right] + $diff + 1, '-', '> ' . $edge, $created);
|
$this->_sync($Model, $edge - $parentNode[$right] + $diff + 1, '-', '> ' . $edge, $created);
|
||||||
} else {
|
} else {
|
||||||
$this->__sync($Model, $diff, '+', 'BETWEEN ' . $parentNode[$right] . ' AND ' . $node[$right], $created);
|
$this->_sync($Model, $diff, '+', 'BETWEEN ' . $parentNode[$right] . ' AND ' . $node[$right], $created);
|
||||||
$this->__sync($Model, $edge - $parentNode[$right] + 1, '-', '> ' . $edge, $created);
|
$this->_sync($Model, $edge - $parentNode[$right] + 1, '-', '> ' . $edge, $created);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->__sync($Model, $diff, '-', 'BETWEEN ' . $node[$right] . ' AND ' . ($parentNode[$right] - 1), $created);
|
$this->_sync($Model, $diff, '-', 'BETWEEN ' . $node[$right] . ' AND ' . ($parentNode[$right] - 1), $created);
|
||||||
$this->__sync($Model, $edge - $parentNode[$right] + $diff + 1, '-', '> ' . $edge, $created);
|
$this->_sync($Model, $edge - $parentNode[$right] + $diff + 1, '-', '> ' . $edge, $created);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -879,13 +881,14 @@ class TreeBehavior extends ModelBehavior {
|
||||||
/**
|
/**
|
||||||
* get the maximum index value in the table.
|
* get the maximum index value in the table.
|
||||||
*
|
*
|
||||||
* @param AppModel $Model
|
* @param Model $Model
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param string $right
|
* @param string $right
|
||||||
* @return int
|
* @param integer $recursive
|
||||||
* @access private
|
* @param boolean $created
|
||||||
|
* @return integer
|
||||||
*/
|
*/
|
||||||
private function __getMax($Model, $scope, $right, $recursive = -1, $created = false) {
|
protected function _getMax($Model, $scope, $right, $recursive = -1, $created = false) {
|
||||||
$db = ConnectionManager::getDataSource($Model->useDbConfig);
|
$db = ConnectionManager::getDataSource($Model->useDbConfig);
|
||||||
if ($created) {
|
if ($created) {
|
||||||
if (is_string($scope)) {
|
if (is_string($scope)) {
|
||||||
|
@ -907,13 +910,13 @@ class TreeBehavior extends ModelBehavior {
|
||||||
/**
|
/**
|
||||||
* get the minimum index value in the table.
|
* get the minimum index value in the table.
|
||||||
*
|
*
|
||||||
* @param AppModel $Model
|
* @param Model $Model
|
||||||
* @param string $scope
|
* @param string $scope
|
||||||
* @param string $right
|
* @param string $left
|
||||||
* @return int
|
* @param integer $recursive
|
||||||
* @access private
|
* @return integer
|
||||||
*/
|
*/
|
||||||
private function __getMin($Model, $scope, $left, $recursive = -1) {
|
protected function _getMin($Model, $scope, $left, $recursive = -1) {
|
||||||
$db = ConnectionManager::getDataSource($Model->useDbConfig);
|
$db = ConnectionManager::getDataSource($Model->useDbConfig);
|
||||||
$name = $Model->alias . '.' . $left;
|
$name = $Model->alias . '.' . $left;
|
||||||
list($edge) = array_values($Model->find('first', array(
|
list($edge) = array_values($Model->find('first', array(
|
||||||
|
@ -929,20 +932,21 @@ class TreeBehavior extends ModelBehavior {
|
||||||
*
|
*
|
||||||
* Handles table sync operations, Taking account of the behavior scope.
|
* Handles table sync operations, Taking account of the behavior scope.
|
||||||
*
|
*
|
||||||
* @param AppModel $Model
|
* @param Model $Model
|
||||||
* @param integer $shift
|
* @param integer $shift
|
||||||
* @param string $direction
|
* @param string $dir
|
||||||
* @param array $conditions
|
* @param array $conditions
|
||||||
|
* @param boolean $created
|
||||||
* @param string $field
|
* @param string $field
|
||||||
* @access private
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function __sync($Model, $shift, $dir = '+', $conditions = array(), $created = false, $field = 'both') {
|
protected function _sync($Model, $shift, $dir = '+', $conditions = array(), $created = false, $field = 'both') {
|
||||||
$ModelRecursive = $Model->recursive;
|
$ModelRecursive = $Model->recursive;
|
||||||
extract($this->settings[$Model->alias]);
|
extract($this->settings[$Model->alias]);
|
||||||
$Model->recursive = $recursive;
|
$Model->recursive = $recursive;
|
||||||
|
|
||||||
if ($field == 'both') {
|
if ($field == 'both') {
|
||||||
$this->__sync($Model, $shift, $dir, $conditions, $created, $left);
|
$this->_sync($Model, $shift, $dir, $conditions, $created, $left);
|
||||||
$field = $right;
|
$field = $right;
|
||||||
}
|
}
|
||||||
if (is_string($conditions)) {
|
if (is_string($conditions)) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ class BehaviorCollection extends ObjectCollection {
|
||||||
* Stores a reference to the attached name
|
* Stores a reference to the attached name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $modelName = null;
|
public $modelName = null;
|
||||||
|
|
||||||
|
@ -56,7 +55,8 @@ class BehaviorCollection extends ObjectCollection {
|
||||||
* Attaches a model object and loads a list of behaviors
|
* Attaches a model object and loads a list of behaviors
|
||||||
*
|
*
|
||||||
* @todo Make this method a constructor instead..
|
* @todo Make this method a constructor instead..
|
||||||
* @access public
|
* @param string $modelName
|
||||||
|
* @param array $behaviors
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function init($modelName, $behaviors = array()) {
|
public function init($modelName, $behaviors = array()) {
|
||||||
|
@ -72,6 +72,8 @@ class BehaviorCollection extends ObjectCollection {
|
||||||
/**
|
/**
|
||||||
* Backwards compatible alias for load()
|
* Backwards compatible alias for load()
|
||||||
*
|
*
|
||||||
|
* @param string $behavior
|
||||||
|
* @param array $config
|
||||||
* @return void
|
* @return void
|
||||||
* @deprecated Replaced with load()
|
* @deprecated Replaced with load()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,7 +31,6 @@ class CakeSchema extends Object {
|
||||||
* Name of the schema
|
* Name of the schema
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $name = null;
|
public $name = null;
|
||||||
|
|
||||||
|
@ -39,7 +38,6 @@ class CakeSchema extends Object {
|
||||||
* Path to write location
|
* Path to write location
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $path = null;
|
public $path = null;
|
||||||
|
|
||||||
|
@ -47,7 +45,6 @@ class CakeSchema extends Object {
|
||||||
* File to write
|
* File to write
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $file = 'schema.php';
|
public $file = 'schema.php';
|
||||||
|
|
||||||
|
@ -55,7 +52,6 @@ class CakeSchema extends Object {
|
||||||
* Connection used for read
|
* Connection used for read
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $connection = 'default';
|
public $connection = 'default';
|
||||||
|
|
||||||
|
@ -70,7 +66,6 @@ class CakeSchema extends Object {
|
||||||
* Set of tables
|
* Set of tables
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $tables = array();
|
public $tables = array();
|
||||||
|
|
||||||
|
@ -135,7 +130,7 @@ class CakeSchema extends Object {
|
||||||
/**
|
/**
|
||||||
* Before callback to be implemented in subclasses
|
* Before callback to be implemented in subclasses
|
||||||
*
|
*
|
||||||
* @param array $events schema object properties
|
* @param array $event schema object properties
|
||||||
* @return boolean Should process continue
|
* @return boolean Should process continue
|
||||||
*/
|
*/
|
||||||
public function before($event = array()) {
|
public function before($event = array()) {
|
||||||
|
@ -145,7 +140,8 @@ class CakeSchema extends Object {
|
||||||
/**
|
/**
|
||||||
* After callback to be implemented in subclasses
|
* After callback to be implemented in subclasses
|
||||||
*
|
*
|
||||||
* @param array $events schema object properties
|
* @param array $event schema object properties
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function after($event = array()) {
|
public function after($event = array()) {
|
||||||
}
|
}
|
||||||
|
@ -263,7 +259,7 @@ class CakeSchema extends Object {
|
||||||
if (in_array($fulltable, $currentTables)) {
|
if (in_array($fulltable, $currentTables)) {
|
||||||
$key = array_search($fulltable, $currentTables);
|
$key = array_search($fulltable, $currentTables);
|
||||||
if (empty($tables[$table])) {
|
if (empty($tables[$table])) {
|
||||||
$tables[$table] = $this->__columns($Object);
|
$tables[$table] = $this->_columns($Object);
|
||||||
$tables[$table]['indexes'] = $db->index($Object);
|
$tables[$table]['indexes'] = $db->index($Object);
|
||||||
$tables[$table]['tableParameters'] = $db->readTableParameters($fulltable);
|
$tables[$table]['tableParameters'] = $db->readTableParameters($fulltable);
|
||||||
unset($currentTables[$key]);
|
unset($currentTables[$key]);
|
||||||
|
@ -282,7 +278,7 @@ class CakeSchema extends Object {
|
||||||
$key = array_search($withTable, $currentTables);
|
$key = array_search($withTable, $currentTables);
|
||||||
$noPrefixWith = $this->_noPrefixTable($prefix, $withTable);
|
$noPrefixWith = $this->_noPrefixTable($prefix, $withTable);
|
||||||
|
|
||||||
$tables[$noPrefixWith] = $this->__columns($Object->$class);
|
$tables[$noPrefixWith] = $this->_columns($Object->$class);
|
||||||
$tables[$noPrefixWith]['indexes'] = $db->index($Object->$class);
|
$tables[$noPrefixWith]['indexes'] = $db->index($Object->$class);
|
||||||
$tables[$noPrefixWith]['tableParameters'] = $db->readTableParameters($withTable);
|
$tables[$noPrefixWith]['tableParameters'] = $db->readTableParameters($withTable);
|
||||||
unset($currentTables[$key]);
|
unset($currentTables[$key]);
|
||||||
|
@ -311,15 +307,15 @@ class CakeSchema extends Object {
|
||||||
'aros', 'acos', 'aros_acos', Configure::read('Session.table'), 'i18n'
|
'aros', 'acos', 'aros_acos', Configure::read('Session.table'), 'i18n'
|
||||||
);
|
);
|
||||||
if (in_array($table, $systemTables)) {
|
if (in_array($table, $systemTables)) {
|
||||||
$tables[$Object->table] = $this->__columns($Object);
|
$tables[$Object->table] = $this->_columns($Object);
|
||||||
$tables[$Object->table]['indexes'] = $db->index($Object);
|
$tables[$Object->table]['indexes'] = $db->index($Object);
|
||||||
$tables[$Object->table]['tableParameters'] = $db->readTableParameters($table);
|
$tables[$Object->table]['tableParameters'] = $db->readTableParameters($table);
|
||||||
} elseif ($models === false) {
|
} elseif ($models === false) {
|
||||||
$tables[$table] = $this->__columns($Object);
|
$tables[$table] = $this->_columns($Object);
|
||||||
$tables[$table]['indexes'] = $db->index($Object);
|
$tables[$table]['indexes'] = $db->index($Object);
|
||||||
$tables[$table]['tableParameters'] = $db->readTableParameters($table);
|
$tables[$table]['tableParameters'] = $db->readTableParameters($table);
|
||||||
} else {
|
} else {
|
||||||
$tables['missing'][$table] = $this->__columns($Object);
|
$tables['missing'][$table] = $this->_columns($Object);
|
||||||
$tables['missing'][$table]['indexes'] = $db->index($Object);
|
$tables['missing'][$table]['indexes'] = $db->index($Object);
|
||||||
$tables['missing'][$table]['tableParameters'] = $db->readTableParameters($table);
|
$tables['missing'][$table]['tableParameters'] = $db->readTableParameters($table);
|
||||||
}
|
}
|
||||||
|
@ -407,12 +403,12 @@ class CakeSchema extends Object {
|
||||||
}
|
}
|
||||||
$col = "\t\t'{$field}' => array('type' => '" . $value['type'] . "', ";
|
$col = "\t\t'{$field}' => array('type' => '" . $value['type'] . "', ";
|
||||||
unset($value['type']);
|
unset($value['type']);
|
||||||
$col .= join(', ', $this->__values($value));
|
$col .= join(', ', $this->_values($value));
|
||||||
} elseif ($field == 'indexes') {
|
} elseif ($field == 'indexes') {
|
||||||
$col = "\t\t'indexes' => array(";
|
$col = "\t\t'indexes' => array(";
|
||||||
$props = array();
|
$props = array();
|
||||||
foreach ((array)$value as $key => $index) {
|
foreach ((array)$value as $key => $index) {
|
||||||
$props[] = "'{$key}' => array(" . join(', ', $this->__values($index)) . ")";
|
$props[] = "'{$key}' => array(" . join(', ', $this->_values($index)) . ")";
|
||||||
}
|
}
|
||||||
$col .= join(', ', $props);
|
$col .= join(', ', $props);
|
||||||
} elseif ($field == 'tableParameters') {
|
} elseif ($field == 'tableParameters') {
|
||||||
|
@ -531,7 +527,6 @@ class CakeSchema extends Object {
|
||||||
* @param array $array2 Corresponding array checked for equality
|
* @param array $array2 Corresponding array checked for equality
|
||||||
* @return array Difference as array with array(keys => values) from input array
|
* @return array Difference as array with array(keys => values) from input array
|
||||||
* where match was not found.
|
* where match was not found.
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected function _arrayDiffAssoc($array1, $array2) {
|
protected function _arrayDiffAssoc($array1, $array2) {
|
||||||
$difference = array();
|
$difference = array();
|
||||||
|
@ -565,7 +560,7 @@ class CakeSchema extends Object {
|
||||||
* @param array $values options keys(type, null, default, key, length, extra)
|
* @param array $values options keys(type, null, default, key, length, extra)
|
||||||
* @return array Formatted values
|
* @return array Formatted values
|
||||||
*/
|
*/
|
||||||
public function __values($values) {
|
protected function _values($values) {
|
||||||
$vals = array();
|
$vals = array();
|
||||||
if (is_array($values)) {
|
if (is_array($values)) {
|
||||||
foreach ($values as $key => $val) {
|
foreach ($values as $key => $val) {
|
||||||
|
@ -586,7 +581,7 @@ class CakeSchema extends Object {
|
||||||
* @param array $Obj model object
|
* @param array $Obj model object
|
||||||
* @return array Formatted columns
|
* @return array Formatted columns
|
||||||
*/
|
*/
|
||||||
public function __columns(&$Obj) {
|
protected function _columns(&$Obj) {
|
||||||
$db = $Obj->getDataSource();
|
$db = $Obj->getDataSource();
|
||||||
$fields = $Obj->schema(true);
|
$fields = $Obj->schema(true);
|
||||||
|
|
||||||
|
@ -696,7 +691,7 @@ class CakeSchema extends Object {
|
||||||
* @param string $table Full table name
|
* @param string $table Full table name
|
||||||
* @return string Prefix-less table name
|
* @return string Prefix-less table name
|
||||||
*/
|
*/
|
||||||
function _noPrefixTable($prefix, $table) {
|
protected function _noPrefixTable($prefix, $table) {
|
||||||
return preg_replace('/^' . preg_quote($prefix) . '/', '', $table);
|
return preg_replace('/^' . preg_quote($prefix) . '/', '', $table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ class ConnectionManager {
|
||||||
* Holds a loaded instance of the Connections object
|
* Holds a loaded instance of the Connections object
|
||||||
*
|
*
|
||||||
* @var DATABASE_CONFIG
|
* @var DATABASE_CONFIG
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public static $config = null;
|
public static $config = null;
|
||||||
|
|
||||||
|
@ -40,7 +39,6 @@ class ConnectionManager {
|
||||||
* Holds instances DataSource objects
|
* Holds instances DataSource objects
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected static $_dataSources = array();
|
protected static $_dataSources = array();
|
||||||
|
|
||||||
|
@ -48,7 +46,6 @@ class ConnectionManager {
|
||||||
* Contains a list of all file and class names used in Connection settings
|
* Contains a list of all file and class names used in Connection settings
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected static $_connectionsEnum = array();
|
protected static $_connectionsEnum = array();
|
||||||
|
|
||||||
|
@ -57,13 +54,14 @@ class ConnectionManager {
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private static $_init = false;
|
protected static $_init = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads connections configuration.
|
* Loads connections configuration.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function init() {
|
protected static function _init() {
|
||||||
include_once APP . 'Config' . DS . 'database.php';
|
include_once APP . 'Config' . DS . 'database.php';
|
||||||
if (class_exists('DATABASE_CONFIG')) {
|
if (class_exists('DATABASE_CONFIG')) {
|
||||||
self::$config = new DATABASE_CONFIG();
|
self::$config = new DATABASE_CONFIG();
|
||||||
|
@ -76,13 +74,13 @@ class ConnectionManager {
|
||||||
* Gets a reference to a DataSource object
|
* Gets a reference to a DataSource object
|
||||||
*
|
*
|
||||||
* @param string $name The name of the DataSource, as defined in app/Config/database.php
|
* @param string $name The name of the DataSource, as defined in app/Config/database.php
|
||||||
* @return object Instance
|
* @return DataSource Instance
|
||||||
* @throws MissingDatasourceConfigException
|
* @throws MissingDatasourceConfigException
|
||||||
* @throws MissingDatasourceFileException
|
* @throws MissingDatasourceFileException
|
||||||
*/
|
*/
|
||||||
public static function getDataSource($name) {
|
public static function getDataSource($name) {
|
||||||
if (empty(self::$_init)) {
|
if (empty(self::$_init)) {
|
||||||
self::init();
|
self::_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty(self::$_dataSources[$name])) {
|
if (!empty(self::$_dataSources[$name])) {
|
||||||
|
@ -113,7 +111,7 @@ class ConnectionManager {
|
||||||
*/
|
*/
|
||||||
public static function sourceList() {
|
public static function sourceList() {
|
||||||
if (empty(self::$_init)) {
|
if (empty(self::$_init)) {
|
||||||
self::init();
|
self::_init();
|
||||||
}
|
}
|
||||||
return array_keys(self::$_dataSources);
|
return array_keys(self::$_dataSources);
|
||||||
}
|
}
|
||||||
|
@ -121,13 +119,13 @@ class ConnectionManager {
|
||||||
/**
|
/**
|
||||||
* Gets a DataSource name from an object reference.
|
* Gets a DataSource name from an object reference.
|
||||||
*
|
*
|
||||||
* @param object $source DataSource object
|
* @param DataSource $source DataSource object
|
||||||
* @return string Datasource name, or null if source is not present
|
* @return string Datasource name, or null if source is not present
|
||||||
* in the ConnectionManager.
|
* in the ConnectionManager.
|
||||||
*/
|
*/
|
||||||
public static function getSourceName($source) {
|
public static function getSourceName($source) {
|
||||||
if (empty(self::$_init)) {
|
if (empty(self::$_init)) {
|
||||||
self::init();
|
self::_init();
|
||||||
}
|
}
|
||||||
foreach (self::$_dataSources as $name => $ds) {
|
foreach (self::$_dataSources as $name => $ds) {
|
||||||
if ($ds === $source) {
|
if ($ds === $source) {
|
||||||
|
@ -148,7 +146,7 @@ class ConnectionManager {
|
||||||
*/
|
*/
|
||||||
public static function loadDataSource($connName) {
|
public static function loadDataSource($connName) {
|
||||||
if (empty(self::$_init)) {
|
if (empty(self::$_init)) {
|
||||||
self::init();
|
self::_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($connName)) {
|
if (is_array($connName)) {
|
||||||
|
@ -184,7 +182,7 @@ class ConnectionManager {
|
||||||
*/
|
*/
|
||||||
public static function enumConnectionObjects() {
|
public static function enumConnectionObjects() {
|
||||||
if (empty(self::$_init)) {
|
if (empty(self::$_init)) {
|
||||||
self::init();
|
self::_init();
|
||||||
}
|
}
|
||||||
return (array) self::$config;
|
return (array) self::$config;
|
||||||
}
|
}
|
||||||
|
@ -194,11 +192,11 @@ class ConnectionManager {
|
||||||
*
|
*
|
||||||
* @param string $name The DataSource name
|
* @param string $name The DataSource name
|
||||||
* @param array $config The DataSource configuration settings
|
* @param array $config The DataSource configuration settings
|
||||||
* @return object A reference to the DataSource object, or null if creation failed
|
* @return DataSource A reference to the DataSource object, or null if creation failed
|
||||||
*/
|
*/
|
||||||
public static function create($name = '', $config = array()) {
|
public static function create($name = '', $config = array()) {
|
||||||
if (empty(self::$_init)) {
|
if (empty(self::$_init)) {
|
||||||
self::init();
|
self::_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($name) || empty($config) || array_key_exists($name, self::$_connectionsEnum)) {
|
if (empty($name) || empty($config) || array_key_exists($name, self::$_connectionsEnum)) {
|
||||||
|
@ -218,7 +216,7 @@ class ConnectionManager {
|
||||||
*/
|
*/
|
||||||
public static function drop($name) {
|
public static function drop($name) {
|
||||||
if (empty(self::$_init)) {
|
if (empty(self::$_init)) {
|
||||||
self::init();
|
self::_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset(self::$config->{$name})) {
|
if (!isset(self::$config->{$name})) {
|
||||||
|
@ -231,7 +229,9 @@ class ConnectionManager {
|
||||||
/**
|
/**
|
||||||
* Gets a list of class and file names associated with the user-defined DataSource connections
|
* Gets a list of class and file names associated with the user-defined DataSource connections
|
||||||
*
|
*
|
||||||
|
* @param string $name Connection name
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws MissingDatasourceConfigException
|
||||||
*/
|
*/
|
||||||
protected static function _getConnectionObject($name) {
|
protected static function _getConnectionObject($name) {
|
||||||
if (!empty(self::$config->{$name})) {
|
if (!empty(self::$config->{$name})) {
|
||||||
|
@ -244,9 +244,10 @@ class ConnectionManager {
|
||||||
/**
|
/**
|
||||||
* Returns the file, class name, and parent for the given driver.
|
* Returns the file, class name, and parent for the given driver.
|
||||||
*
|
*
|
||||||
|
* @param array $config Array with connection configuration. Key 'datasource' is required
|
||||||
* @return array An indexed array with: filename, classname, plugin and parent
|
* @return array An indexed array with: filename, classname, plugin and parent
|
||||||
*/
|
*/
|
||||||
private static function _connectionData($config) {
|
protected static function _connectionData($config) {
|
||||||
$package = $classname = $plugin = null;
|
$package = $classname = $plugin = null;
|
||||||
|
|
||||||
list($plugin, $classname) = pluginSplit($config['datasource']);
|
list($plugin, $classname) = pluginSplit($config['datasource']);
|
||||||
|
@ -260,6 +261,7 @@ class ConnectionManager {
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function shutdown() {
|
public static function shutdown() {
|
||||||
if (Configure::read('Session.defaults') == 'database' && function_exists('session_write_close')) {
|
if (Configure::read('Session.defaults') == 'database' && function_exists('session_write_close')) {
|
||||||
|
|
|
@ -133,6 +133,7 @@ class CakeSession {
|
||||||
*
|
*
|
||||||
* @param string $base The base path for the Session
|
* @param string $base The base path for the Session
|
||||||
* @param boolean $start Should session be started right now
|
* @param boolean $start Should session be started right now
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function init($base = null, $start = true) {
|
public static function init($base = null, $start = true) {
|
||||||
self::$time = time();
|
self::$time = time();
|
||||||
|
@ -229,7 +230,7 @@ class CakeSession {
|
||||||
/**
|
/**
|
||||||
* Returns the Session id
|
* Returns the Session id
|
||||||
*
|
*
|
||||||
* @param id $name string
|
* @param string $id
|
||||||
* @return string Session id
|
* @return string Session id
|
||||||
*/
|
*/
|
||||||
public static function id($id = null) {
|
public static function id($id = null) {
|
||||||
|
@ -251,10 +252,10 @@ class CakeSession {
|
||||||
*/
|
*/
|
||||||
public static function delete($name) {
|
public static function delete($name) {
|
||||||
if (self::check($name)) {
|
if (self::check($name)) {
|
||||||
self::__overwrite($_SESSION, Set::remove($_SESSION, $name));
|
self::_overwrite($_SESSION, Set::remove($_SESSION, $name));
|
||||||
return (self::check($name) == false);
|
return (self::check($name) == false);
|
||||||
}
|
}
|
||||||
self::__setError(2, __d('cake_dev', "%s doesn't exist", $name));
|
self::_setError(2, __d('cake_dev', "%s doesn't exist", $name));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,9 +264,9 @@ class CakeSession {
|
||||||
*
|
*
|
||||||
* @param array $old Set of old variables => values
|
* @param array $old Set of old variables => values
|
||||||
* @param array $new New set of variable => value
|
* @param array $new New set of variable => value
|
||||||
* @access private
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function __overwrite(&$old, $new) {
|
protected static function _overwrite(&$old, $new) {
|
||||||
if (!empty($old)) {
|
if (!empty($old)) {
|
||||||
foreach ($old as $key => $var) {
|
foreach ($old as $key => $var) {
|
||||||
if (!isset($new[$key])) {
|
if (!isset($new[$key])) {
|
||||||
|
@ -283,9 +284,8 @@ class CakeSession {
|
||||||
*
|
*
|
||||||
* @param integer $errorNumber Error to set
|
* @param integer $errorNumber Error to set
|
||||||
* @return string Error as string
|
* @return string Error as string
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private static function __error($errorNumber) {
|
protected static function _error($errorNumber) {
|
||||||
if (!is_array(self::$error) || !array_key_exists($errorNumber, self::$error)) {
|
if (!is_array(self::$error) || !array_key_exists($errorNumber, self::$error)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -300,7 +300,7 @@ class CakeSession {
|
||||||
*/
|
*/
|
||||||
public static function error() {
|
public static function error() {
|
||||||
if (self::$lastError) {
|
if (self::$lastError) {
|
||||||
return self::__error(self::$lastError);
|
return self::_error(self::$lastError);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ class CakeSession {
|
||||||
self::$valid = true;
|
self::$valid = true;
|
||||||
} else {
|
} else {
|
||||||
self::$valid = false;
|
self::$valid = false;
|
||||||
self::__setError(1, 'Session Highjacking Attempted !!!');
|
self::_setError(1, 'Session Highjacking Attempted !!!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self::$valid;
|
return self::$valid;
|
||||||
|
@ -363,7 +363,7 @@ class CakeSession {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (is_null($name)) {
|
if (is_null($name)) {
|
||||||
return self::__returnSessionVars();
|
return self::_returnSessionVars();
|
||||||
}
|
}
|
||||||
if (empty($name)) {
|
if (empty($name)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -373,7 +373,7 @@ class CakeSession {
|
||||||
if (!is_null($result)) {
|
if (!is_null($result)) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
self::__setError(2, "$name doesn't exist");
|
self::_setError(2, "$name doesn't exist");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,11 +382,11 @@ class CakeSession {
|
||||||
*
|
*
|
||||||
* @return mixed Full $_SESSION array, or false on error.
|
* @return mixed Full $_SESSION array, or false on error.
|
||||||
*/
|
*/
|
||||||
private static function __returnSessionVars() {
|
protected static function _returnSessionVars() {
|
||||||
if (!empty($_SESSION)) {
|
if (!empty($_SESSION)) {
|
||||||
return $_SESSION;
|
return $_SESSION;
|
||||||
}
|
}
|
||||||
self::__setError(2, 'No Session vars set');
|
self::_setError(2, 'No Session vars set');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ class CakeSession {
|
||||||
$write = array($name => $value);
|
$write = array($name => $value);
|
||||||
}
|
}
|
||||||
foreach ($write as $key => $val) {
|
foreach ($write as $key => $val) {
|
||||||
self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val));
|
self::_overwrite($_SESSION, Set::insert($_SESSION, $key, $val));
|
||||||
if (Set::classicExtract($_SESSION, $key) !== $val) {
|
if (Set::classicExtract($_SESSION, $key) !== $val) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -508,7 +508,9 @@ class CakeSession {
|
||||||
/**
|
/**
|
||||||
* Find the handler class and make sure it implements the correct interface.
|
* Find the handler class and make sure it implements the correct interface.
|
||||||
*
|
*
|
||||||
|
* @param string $handler
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws CakeSessionException
|
||||||
*/
|
*/
|
||||||
protected static function _getHandler($handler) {
|
protected static function _getHandler($handler) {
|
||||||
list($plugin, $class) = pluginSplit($handler, true);
|
list($plugin, $class) = pluginSplit($handler, true);
|
||||||
|
@ -526,7 +528,8 @@ class CakeSession {
|
||||||
/**
|
/**
|
||||||
* Get one of the prebaked default session configurations.
|
* Get one of the prebaked default session configurations.
|
||||||
*
|
*
|
||||||
* @return void
|
* @param string $name
|
||||||
|
* @return boolean|array
|
||||||
*/
|
*/
|
||||||
protected static function _defaultConfig($name) {
|
protected static function _defaultConfig($name) {
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
|
@ -647,7 +650,7 @@ class CakeSession {
|
||||||
} else {
|
} else {
|
||||||
self::destroy();
|
self::destroy();
|
||||||
self::$valid = false;
|
self::$valid = false;
|
||||||
self::__setError(1, 'Session Highjacking Attempted !!!');
|
self::_setError(1, 'Session Highjacking Attempted !!!');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self::write('Config.userAgent', self::$_userAgent);
|
self::write('Config.userAgent', self::$_userAgent);
|
||||||
|
@ -677,9 +680,8 @@ class CakeSession {
|
||||||
* @param integer $errorNumber Number of the error
|
* @param integer $errorNumber Number of the error
|
||||||
* @param string $errorMessage Description of the error
|
* @param string $errorMessage Description of the error
|
||||||
* @return void
|
* @return void
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private static function __setError($errorNumber, $errorMessage) {
|
protected static function _setError($errorNumber, $errorMessage) {
|
||||||
if (self::$error === false) {
|
if (self::$error === false) {
|
||||||
self::$error = array();
|
self::$error = array();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ class DataSource extends Object {
|
||||||
* Are we connected to the DataSource?
|
* Are we connected to the DataSource?
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $connected = false;
|
public $connected = false;
|
||||||
|
|
||||||
|
@ -36,7 +35,6 @@ class DataSource extends Object {
|
||||||
* The default configuration of a specific DataSource
|
* The default configuration of a specific DataSource
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_baseConfig = array();
|
protected $_baseConfig = array();
|
||||||
|
|
||||||
|
@ -44,15 +42,13 @@ class DataSource extends Object {
|
||||||
* Holds references to descriptions loaded by the DataSource
|
* Holds references to descriptions loaded by the DataSource
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private $__descriptions = array();
|
protected $_descriptions = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds a list of sources (tables) contained in the DataSource
|
* Holds a list of sources (tables) contained in the DataSource
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_sources = null;
|
protected $_sources = null;
|
||||||
|
|
||||||
|
@ -60,7 +56,6 @@ class DataSource extends Object {
|
||||||
* The DataSource configuration
|
* The DataSource configuration
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $config = array();
|
public $config = array();
|
||||||
|
|
||||||
|
@ -68,7 +63,6 @@ class DataSource extends Object {
|
||||||
* Whether or not this DataSource is in the middle of a transaction
|
* Whether or not this DataSource is in the middle of a transaction
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_transactionStarted = false;
|
protected $_transactionStarted = false;
|
||||||
|
|
||||||
|
@ -77,7 +71,6 @@ class DataSource extends Object {
|
||||||
* should be cached
|
* should be cached
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $cacheSources = true;
|
public $cacheSources = true;
|
||||||
|
|
||||||
|
@ -85,7 +78,6 @@ class DataSource extends Object {
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param array $config Array of configuration information for the datasource.
|
* @param array $config Array of configuration information for the datasource.
|
||||||
* @return void.
|
|
||||||
*/
|
*/
|
||||||
public function __construct($config = array()) {
|
public function __construct($config = array()) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
@ -131,13 +123,13 @@ class DataSource extends Object {
|
||||||
}
|
}
|
||||||
$table = $model->tablePrefix . $model->table;
|
$table = $model->tablePrefix . $model->table;
|
||||||
|
|
||||||
if (isset($this->__descriptions[$table])) {
|
if (isset($this->_descriptions[$table])) {
|
||||||
return $this->__descriptions[$table];
|
return $this->_descriptions[$table];
|
||||||
}
|
}
|
||||||
$cache = $this->__cacheDescription($table);
|
$cache = $this->_cacheDescription($table);
|
||||||
|
|
||||||
if ($cache !== null) {
|
if ($cache !== null) {
|
||||||
$this->__descriptions[$table] =& $cache;
|
$this->_descriptions[$table] =& $cache;
|
||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -228,6 +220,7 @@ class DataSource extends Object {
|
||||||
*
|
*
|
||||||
* @param Model $model The model class having record(s) deleted
|
* @param Model $model The model class having record(s) deleted
|
||||||
* @param mixed $id Primary key of the model
|
* @param mixed $id Primary key of the model
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function delete(Model $model, $id = null) {
|
public function delete(Model $model, $id = null) {
|
||||||
if ($id == null) {
|
if ($id == null) {
|
||||||
|
@ -238,7 +231,7 @@ class DataSource extends Object {
|
||||||
/**
|
/**
|
||||||
* Returns the ID generated from the previous INSERT operation.
|
* Returns the ID generated from the previous INSERT operation.
|
||||||
*
|
*
|
||||||
* @param unknown_type $source
|
* @param mixed $source
|
||||||
* @return mixed Last ID key generated in previous INSERT
|
* @return mixed Last ID key generated in previous INSERT
|
||||||
*/
|
*/
|
||||||
public function lastInsertId($source = null) {
|
public function lastInsertId($source = null) {
|
||||||
|
@ -248,7 +241,7 @@ class DataSource extends Object {
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows returned by last operation.
|
* Returns the number of rows returned by last operation.
|
||||||
*
|
*
|
||||||
* @param unknown_type $source
|
* @param mixed $source
|
||||||
* @return integer Number of rows returned by last operation
|
* @return integer Number of rows returned by last operation
|
||||||
*/
|
*/
|
||||||
public function lastNumRows($source = null) {
|
public function lastNumRows($source = null) {
|
||||||
|
@ -258,7 +251,7 @@ class DataSource extends Object {
|
||||||
/**
|
/**
|
||||||
* Returns the number of rows affected by last query.
|
* Returns the number of rows affected by last query.
|
||||||
*
|
*
|
||||||
* @param unknown_type $source
|
* @param mixed $source
|
||||||
* @return integer Number of rows affected by last query.
|
* @return integer Number of rows affected by last query.
|
||||||
*/
|
*/
|
||||||
public function lastAffected($source = null) {
|
public function lastAffected($source = null) {
|
||||||
|
@ -293,15 +286,14 @@ class DataSource extends Object {
|
||||||
* @param string $object The name of the object (model) to cache
|
* @param string $object The name of the object (model) to cache
|
||||||
* @param mixed $data The description of the model, usually a string or array
|
* @param mixed $data The description of the model, usually a string or array
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __cacheDescription($object, $data = null) {
|
protected function _cacheDescription($object, $data = null) {
|
||||||
if ($this->cacheSources === false) {
|
if ($this->cacheSources === false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data !== null) {
|
if ($data !== null) {
|
||||||
$this->__descriptions[$object] =& $data;
|
$this->_descriptions[$object] =& $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = ConnectionManager::getSourceName($this) . '_' . $object;
|
$key = ConnectionManager::getSourceName($this) . '_' . $object;
|
||||||
|
@ -321,12 +313,11 @@ class DataSource extends Object {
|
||||||
* @param string $query Query string needing replacements done.
|
* @param string $query Query string needing replacements done.
|
||||||
* @param array $data Array of data with values that will be inserted in placeholders.
|
* @param array $data Array of data with values that will be inserted in placeholders.
|
||||||
* @param string $association Name of association model being replaced
|
* @param string $association Name of association model being replaced
|
||||||
* @param unknown_type $assocData
|
* @param array $assocData
|
||||||
* @param Model $model Instance of the model to replace $__cakeID__$
|
* @param Model $model Instance of the model to replace $__cakeID__$
|
||||||
* @param Model $linkModel Instance of model to replace $__cakeForeignKey__$
|
* @param Model $linkModel Instance of model to replace $__cakeForeignKey__$
|
||||||
* @param array $stack
|
* @param array $stack
|
||||||
* @return string String of query data with placeholders replaced.
|
* @return string String of query data with placeholders replaced.
|
||||||
* @access public
|
|
||||||
* @todo Remove and refactor $assocData, ensure uses of the method have the param removed too.
|
* @todo Remove and refactor $assocData, ensure uses of the method have the param removed too.
|
||||||
*/
|
*/
|
||||||
public function insertQueryData($query, $data, $association, $assocData, Model $model, Model $linkModel, $stack) {
|
public function insertQueryData($query, $data, $association, $assocData, Model $model, Model $linkModel, $stack) {
|
||||||
|
@ -416,7 +407,6 @@ class DataSource extends Object {
|
||||||
/**
|
/**
|
||||||
* Closes the current datasource.
|
* Closes the current datasource.
|
||||||
*
|
*
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
if ($this->_transactionStarted) {
|
if ($this->_transactionStarted) {
|
||||||
|
|
|
@ -74,7 +74,6 @@ class Mysql extends DboSource {
|
||||||
* use alias for update and delete. Set to true if version >= 4.1
|
* use alias for update and delete. Set to true if version >= 4.1
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_useAlias = true;
|
protected $_useAlias = true;
|
||||||
|
|
||||||
|
@ -82,7 +81,6 @@ class Mysql extends DboSource {
|
||||||
* Index of basic SQL commands
|
* Index of basic SQL commands
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_commands = array(
|
protected $_commands = array(
|
||||||
'begin' => 'START TRANSACTION',
|
'begin' => 'START TRANSACTION',
|
||||||
|
@ -94,7 +92,6 @@ class Mysql extends DboSource {
|
||||||
* List of engine specific additional field parameters used on table creating
|
* List of engine specific additional field parameters used on table creating
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $fieldParameters = array(
|
public $fieldParameters = array(
|
||||||
'charset' => array('value' => 'CHARACTER SET', 'quote' => false, 'join' => ' ', 'column' => false, 'position' => 'beforeDefault'),
|
'charset' => array('value' => 'CHARACTER SET', 'quote' => false, 'join' => ' ', 'column' => false, 'position' => 'beforeDefault'),
|
||||||
|
@ -106,7 +103,6 @@ class Mysql extends DboSource {
|
||||||
* List of table engine specific parameters used on table creating
|
* List of table engine specific parameters used on table creating
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $tableParameters = array(
|
public $tableParameters = array(
|
||||||
'charset' => array('value' => 'DEFAULT CHARSET', 'quote' => false, 'join' => '=', 'column' => 'charset'),
|
'charset' => array('value' => 'DEFAULT CHARSET', 'quote' => false, 'join' => '=', 'column' => 'charset'),
|
||||||
|
@ -137,6 +133,7 @@ class Mysql extends DboSource {
|
||||||
* Connects to the database using options in the given configuration array.
|
* Connects to the database using options in the given configuration array.
|
||||||
*
|
*
|
||||||
* @return boolean True if the database could be connected, else false
|
* @return boolean True if the database could be connected, else false
|
||||||
|
* @throws MissingConnectionException
|
||||||
*/
|
*/
|
||||||
public function connect() {
|
public function connect() {
|
||||||
$config = $this->config;
|
$config = $this->config;
|
||||||
|
@ -177,6 +174,7 @@ class Mysql extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns an array of sources (tables) in the database.
|
* Returns an array of sources (tables) in the database.
|
||||||
*
|
*
|
||||||
|
* @param mixed $data
|
||||||
* @return array Array of tablenames in the database
|
* @return array Array of tablenames in the database
|
||||||
*/
|
*/
|
||||||
public function listSources($data = null) {
|
public function listSources($data = null) {
|
||||||
|
@ -206,6 +204,7 @@ class Mysql extends DboSource {
|
||||||
* Builds a map of the columns contained in a result
|
* Builds a map of the columns contained in a result
|
||||||
*
|
*
|
||||||
* @param PDOStatement $results
|
* @param PDOStatement $results
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function resultSet($results) {
|
public function resultSet($results) {
|
||||||
$this->map = array();
|
$this->map = array();
|
||||||
|
@ -287,10 +286,11 @@ class Mysql extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns an array of the fields in given table name.
|
* Returns an array of the fields in given table name.
|
||||||
*
|
*
|
||||||
* @param mixed $tableName Name of database table to inspect or model instance
|
* @param Model $model Name of database table to inspect or model instance
|
||||||
* @return array Fields in table. Keys are name and type
|
* @return array Fields in table. Keys are name and type
|
||||||
|
* @throws CakeException
|
||||||
*/
|
*/
|
||||||
public function describe($model) {
|
public function describe(Model $model) {
|
||||||
$cache = parent::describe($model);
|
$cache = parent::describe($model);
|
||||||
if ($cache != null) {
|
if ($cache != null) {
|
||||||
return $cache;
|
return $cache;
|
||||||
|
@ -323,7 +323,7 @@ class Mysql extends DboSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->__cacheDescription($this->fullTableName($model, false), $fields);
|
$this->_cacheDescription($this->fullTableName($model, false), $fields);
|
||||||
$cols->closeCursor();
|
$cols->closeCursor();
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ class Mysql extends DboSource {
|
||||||
* @param mixed $conditions
|
* @param mixed $conditions
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function update($model, $fields = array(), $values = null, $conditions = null) {
|
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
|
||||||
if (!$this->_useAlias) {
|
if (!$this->_useAlias) {
|
||||||
return parent::update($model, $fields, $values, $conditions);
|
return parent::update($model, $fields, $values, $conditions);
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,7 @@ class Mysql extends DboSource {
|
||||||
* @param mixed $conditions
|
* @param mixed $conditions
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function delete($model, $conditions = null) {
|
public function delete(Model $model, $conditions = null) {
|
||||||
if (!$this->_useAlias) {
|
if (!$this->_useAlias) {
|
||||||
return parent::delete($model, $conditions);
|
return parent::delete($model, $conditions);
|
||||||
}
|
}
|
||||||
|
@ -416,6 +416,7 @@ class Mysql extends DboSource {
|
||||||
* Sets the database encoding
|
* Sets the database encoding
|
||||||
*
|
*
|
||||||
* @param string $enc Database encoding
|
* @param string $enc Database encoding
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function setEncoding($enc) {
|
public function setEncoding($enc) {
|
||||||
return $this->_execute('SET NAMES ' . $enc) !== false;
|
return $this->_execute('SET NAMES ' . $enc) !== false;
|
||||||
|
@ -458,6 +459,7 @@ class Mysql extends DboSource {
|
||||||
* Generate a MySQL Alter Table syntax for the given Schema comparison
|
* Generate a MySQL Alter Table syntax for the given Schema comparison
|
||||||
*
|
*
|
||||||
* @param array $compare Result of a CakeSchema::compare()
|
* @param array $compare Result of a CakeSchema::compare()
|
||||||
|
* @param string $table
|
||||||
* @return array Array of alter statements to make.
|
* @return array Array of alter statements to make.
|
||||||
*/
|
*/
|
||||||
public function alterSchema($compare, $table = null) {
|
public function alterSchema($compare, $table = null) {
|
||||||
|
@ -551,7 +553,7 @@ class Mysql extends DboSource {
|
||||||
* Generate MySQL index alteration statements for a table.
|
* Generate MySQL index alteration statements for a table.
|
||||||
*
|
*
|
||||||
* @param string $table Table to alter indexes for
|
* @param string $table Table to alter indexes for
|
||||||
* @param array $new Indexes to add and drop
|
* @param array $indexes Indexes to add and drop
|
||||||
* @return array Index alteration statements
|
* @return array Index alteration statements
|
||||||
*/
|
*/
|
||||||
protected function _alterIndexes($table, $indexes) {
|
protected function _alterIndexes($table, $indexes) {
|
||||||
|
|
|
@ -30,7 +30,6 @@ class DboOracle extends DboSource {
|
||||||
* Configuration options
|
* Configuration options
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $config = array();
|
public $config = array();
|
||||||
|
|
||||||
|
@ -43,6 +42,8 @@ class DboOracle extends DboSource {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sequence names as introspected from the database
|
* Sequence names as introspected from the database
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $_sequences = array();
|
protected $_sequences = array();
|
||||||
|
|
||||||
|
@ -51,13 +52,12 @@ class DboOracle extends DboSource {
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $__transactionStarted = false;
|
protected $_transactionStarted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Column definitions
|
* Column definitions
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $columns = array(
|
public $columns = array(
|
||||||
'primary_key' => array('name' => ''),
|
'primary_key' => array('name' => ''),
|
||||||
|
@ -78,31 +78,27 @@ class DboOracle extends DboSource {
|
||||||
* Connection object
|
* Connection object
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var mixed
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
public $connection;
|
public $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query limit
|
* Query limit
|
||||||
*
|
*
|
||||||
* @var int
|
* @var integer
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_limit = -1;
|
protected $_limit = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query offset
|
* Query offset
|
||||||
*
|
*
|
||||||
* @var int
|
* @var integer
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_offset = 0;
|
protected $_offset = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Map
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_map;
|
protected $_map;
|
||||||
|
|
||||||
|
@ -110,15 +106,13 @@ class DboOracle extends DboSource {
|
||||||
* Current Row
|
* Current Row
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var mixed
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_currentRow;
|
protected $_currentRow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of rows
|
* Number of rows
|
||||||
*
|
*
|
||||||
* @var int
|
* @var integer
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_numRows;
|
protected $_numRows;
|
||||||
|
|
||||||
|
@ -126,14 +120,13 @@ class DboOracle extends DboSource {
|
||||||
* Query results
|
* Query results
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var mixed
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_results;
|
protected $_results;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Last error issued by oci extension
|
* Last error issued by oci extension
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $_error;
|
protected $_error;
|
||||||
|
|
||||||
|
@ -155,7 +148,7 @@ class DboOracle extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Table-sequence map
|
* Table-sequence map
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $_sequenceMap = array();
|
protected $_sequenceMap = array();
|
||||||
|
|
||||||
|
@ -196,6 +189,9 @@ class DboOracle extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Keeps track of the most recent Oracle error
|
* Keeps track of the most recent Oracle error
|
||||||
*
|
*
|
||||||
|
* @param mixed $source
|
||||||
|
* @param boolean $clear
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _setError($source = null, $clear = false) {
|
protected function _setError($source = null, $clear = false) {
|
||||||
if ($source) {
|
if ($source) {
|
||||||
|
@ -213,7 +209,7 @@ class DboOracle extends DboSource {
|
||||||
* Sets the encoding language of the session
|
* Sets the encoding language of the session
|
||||||
*
|
*
|
||||||
* @param string $lang language constant
|
* @param string $lang language constant
|
||||||
* @return bool
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function setEncoding($lang) {
|
public function setEncoding($lang) {
|
||||||
if (!$this->execute('ALTER SESSION SET NLS_LANGUAGE='.$lang)) {
|
if (!$this->execute('ALTER SESSION SET NLS_LANGUAGE='.$lang)) {
|
||||||
|
@ -256,7 +252,7 @@ class DboOracle extends DboSource {
|
||||||
* experimental method that creates the association maps since Oracle will not tell us.
|
* experimental method that creates the association maps since Oracle will not tell us.
|
||||||
*
|
*
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @return false if sql is nor a SELECT
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _scrapeSQL($sql) {
|
protected function _scrapeSQL($sql) {
|
||||||
$sql = str_replace("\"", '', $sql);
|
$sql = str_replace("\"", '', $sql);
|
||||||
|
@ -305,7 +301,7 @@ class DboOracle extends DboSource {
|
||||||
*
|
*
|
||||||
* @param integer $limit Maximum number of rows to return
|
* @param integer $limit Maximum number of rows to return
|
||||||
* @param integer $offset Row to begin returning
|
* @param integer $offset Row to begin returning
|
||||||
* @return modified SQL Query
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function limit($limit = -1, $offset = 0) {
|
public function limit($limit = -1, $offset = 0) {
|
||||||
$this->_limit = (int) $limit;
|
$this->_limit = (int) $limit;
|
||||||
|
@ -316,9 +312,10 @@ class DboOracle extends DboSource {
|
||||||
* Returns number of rows in previous resultset. If no previous resultset exists,
|
* Returns number of rows in previous resultset. If no previous resultset exists,
|
||||||
* this returns false.
|
* this returns false.
|
||||||
*
|
*
|
||||||
|
* @param mixed $source
|
||||||
* @return integer Number of rows in resultset
|
* @return integer Number of rows in resultset
|
||||||
*/
|
*/
|
||||||
public function lastNumRows() {
|
public function lastNumRows($source = null) {
|
||||||
return $this->_numRows;
|
return $this->_numRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,16 +323,18 @@ class DboOracle extends DboSource {
|
||||||
* Executes given SQL statement. This is an overloaded method.
|
* Executes given SQL statement. This is an overloaded method.
|
||||||
*
|
*
|
||||||
* @param string $sql SQL statement
|
* @param string $sql SQL statement
|
||||||
|
* @param array $params list of params to be bound to query
|
||||||
|
* @param array $prepareOptions Options to be used in the prepare statement
|
||||||
* @return resource Result resource identifier or null
|
* @return resource Result resource identifier or null
|
||||||
*/
|
*/
|
||||||
protected function _execute($sql) {
|
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
|
||||||
$this->_statementId = @ociparse($this->connection, $sql);
|
$this->_statementId = @ociparse($this->connection, $sql);
|
||||||
if (!$this->_statementId) {
|
if (!$this->_statementId) {
|
||||||
$this->_setError($this->connection);
|
$this->_setError($this->connection);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->__transactionStarted) {
|
if ($this->_transactionStarted) {
|
||||||
$mode = OCI_DEFAULT;
|
$mode = OCI_DEFAULT;
|
||||||
} else {
|
} else {
|
||||||
$mode = OCI_COMMIT_ON_SUCCESS;
|
$mode = OCI_COMMIT_ON_SUCCESS;
|
||||||
|
@ -372,10 +371,10 @@ class DboOracle extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Fetch result row
|
* Fetch result row
|
||||||
*
|
*
|
||||||
|
* @param string $sql
|
||||||
* @return array
|
* @return array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function fetchRow() {
|
public function fetchRow($sql = null) {
|
||||||
if ($this->_currentRow >= $this->_numRows) {
|
if ($this->_currentRow >= $this->_numRows) {
|
||||||
ocifreestatement($this->_statementId);
|
ocifreestatement($this->_statementId);
|
||||||
$this->_map = null;
|
$this->_map = null;
|
||||||
|
@ -402,7 +401,7 @@ class DboOracle extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Fetches the next row from the current result set
|
* Fetches the next row from the current result set
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fetchResult() {
|
public function fetchResult() {
|
||||||
return $this->fetchRow();
|
return $this->fetchRow();
|
||||||
|
@ -412,7 +411,7 @@ class DboOracle extends DboSource {
|
||||||
* Checks to see if a named sequence exists
|
* Checks to see if a named sequence exists
|
||||||
*
|
*
|
||||||
* @param string $sequence
|
* @param string $sequence
|
||||||
* @return bool
|
* @return boolean|array
|
||||||
*/
|
*/
|
||||||
public function sequenceExists($sequence) {
|
public function sequenceExists($sequence) {
|
||||||
$sql = "SELECT SEQUENCE_NAME FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '$sequence'";
|
$sql = "SELECT SEQUENCE_NAME FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '$sequence'";
|
||||||
|
@ -426,7 +425,7 @@ class DboOracle extends DboSource {
|
||||||
* Creates a database sequence
|
* Creates a database sequence
|
||||||
*
|
*
|
||||||
* @param string $sequence
|
* @param string $sequence
|
||||||
* @return bool
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function createSequence($sequence) {
|
public function createSequence($sequence) {
|
||||||
$sql = "CREATE SEQUENCE $sequence";
|
$sql = "CREATE SEQUENCE $sequence";
|
||||||
|
@ -438,7 +437,6 @@ class DboOracle extends DboSource {
|
||||||
*
|
*
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function createTrigger($table) {
|
public function createTrigger($table) {
|
||||||
$sql = "CREATE OR REPLACE TRIGGER pk_$table" . "_trigger BEFORE INSERT ON $table FOR EACH ROW BEGIN SELECT pk_$table.NEXTVAL INTO :NEW.ID FROM DUAL; END;";
|
$sql = "CREATE OR REPLACE TRIGGER pk_$table" . "_trigger BEFORE INSERT ON $table FOR EACH ROW BEGIN SELECT pk_$table.NEXTVAL INTO :NEW.ID FROM DUAL; END;";
|
||||||
|
@ -449,9 +447,10 @@ class DboOracle extends DboSource {
|
||||||
* Returns an array of tables in the database. If there are no tables, an error is
|
* Returns an array of tables in the database. If there are no tables, an error is
|
||||||
* raised and the application exits.
|
* raised and the application exits.
|
||||||
*
|
*
|
||||||
|
* @param mixed $source
|
||||||
* @return array tablenames in the database
|
* @return array tablenames in the database
|
||||||
*/
|
*/
|
||||||
public function listSources() {
|
public function listSources($source = null) {
|
||||||
$cache = parent::listSources();
|
$cache = parent::listSources();
|
||||||
if ($cache != null) {
|
if ($cache != null) {
|
||||||
return $cache;
|
return $cache;
|
||||||
|
@ -473,10 +472,10 @@ class DboOracle extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns an array of the fields in given table name.
|
* Returns an array of the fields in given table name.
|
||||||
*
|
*
|
||||||
* @param object instance of a model to inspect
|
* @param Model $model instance of a model to inspect
|
||||||
* @return array Fields in table. Keys are name and type
|
* @return array Fields in table. Keys are name and type
|
||||||
*/
|
*/
|
||||||
public function describe($model) {
|
public function describe(Model $model) {
|
||||||
$table = $this->fullTableName($model, false);
|
$table = $this->fullTableName($model, false);
|
||||||
|
|
||||||
if (!empty($model->sequence)) {
|
if (!empty($model->sequence)) {
|
||||||
|
@ -506,7 +505,7 @@ class DboOracle extends DboSource {
|
||||||
'length'=> $row[0]['DATA_LENGTH']
|
'length'=> $row[0]['DATA_LENGTH']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->__cacheDescription($this->fullTableName($model, false), $fields);
|
$this->_cacheDescription($this->fullTableName($model, false), $fields);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
@ -519,7 +518,6 @@ class DboOracle extends DboSource {
|
||||||
* @param integer $reset If -1, sequences are dropped, if 0 (default), sequences are reset,
|
* @param integer $reset If -1, sequences are dropped, if 0 (default), sequences are reset,
|
||||||
* and if 1, sequences are not modified
|
* and if 1, sequences are not modified
|
||||||
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
|
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
|
||||||
* @access public
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function truncate($table, $reset = 0) {
|
public function truncate($table, $reset = 0) {
|
||||||
|
@ -680,8 +678,9 @@ class DboOracle extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Generate a Oracle Alter Table syntax for the given Schema comparison
|
* Generate a Oracle Alter Table syntax for the given Schema comparison
|
||||||
*
|
*
|
||||||
* @param unknown_type $schema
|
* @param mixed $compare
|
||||||
* @return unknown
|
* @param mixed $table
|
||||||
|
* @return boolean|string
|
||||||
*/
|
*/
|
||||||
public function alterSchema($compare, $table = null) {
|
public function alterSchema($compare, $table = null) {
|
||||||
if (!is_array($compare)) {
|
if (!is_array($compare)) {
|
||||||
|
@ -730,8 +729,8 @@ class DboOracle extends DboSource {
|
||||||
* This method should quote Oracle identifiers. Well it doesn't.
|
* This method should quote Oracle identifiers. Well it doesn't.
|
||||||
* It would break all scaffolding and all of Cake's default assumptions.
|
* It would break all scaffolding and all of Cake's default assumptions.
|
||||||
*
|
*
|
||||||
* @param unknown_type $var
|
* @param string $name
|
||||||
* @return unknown
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function name($name) {
|
public function name($name) {
|
||||||
if (strpos($name, '.') !== false && strpos($name, '"') === false) {
|
if (strpos($name, '.') !== false && strpos($name, '"') === false) {
|
||||||
|
@ -750,19 +749,17 @@ class DboOracle extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Begin a transaction
|
* Begin a transaction
|
||||||
*
|
*
|
||||||
* @param unknown_type $model
|
|
||||||
* @return boolean True on success, false on fail
|
* @return boolean True on success, false on fail
|
||||||
* (i.e. if the database/model does not support transactions).
|
* (i.e. if the database/model does not support transactions).
|
||||||
*/
|
*/
|
||||||
public function begin() {
|
public function begin() {
|
||||||
$this->__transactionStarted = true;
|
$this->_transactionStarted = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback a transaction
|
* Rollback a transaction
|
||||||
*
|
*
|
||||||
* @param unknown_type $model
|
|
||||||
* @return boolean True on success, false on fail
|
* @return boolean True on success, false on fail
|
||||||
* (i.e. if the database/model does not support transactions,
|
* (i.e. if the database/model does not support transactions,
|
||||||
* or a transaction has not started).
|
* or a transaction has not started).
|
||||||
|
@ -774,13 +771,12 @@ class DboOracle extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Commit a transaction
|
* Commit a transaction
|
||||||
*
|
*
|
||||||
* @param unknown_type $model
|
|
||||||
* @return boolean True on success, false on fail
|
* @return boolean True on success, false on fail
|
||||||
* (i.e. if the database/model does not support transactions,
|
* (i.e. if the database/model does not support transactions,
|
||||||
* or a transaction has not started).
|
* or a transaction has not started).
|
||||||
*/
|
*/
|
||||||
public function commit() {
|
public function commit() {
|
||||||
$this->__transactionStarted = false;
|
$this->_transactionStarted = false;
|
||||||
return ocicommit($this->connection);
|
return ocicommit($this->connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,6 +834,7 @@ class DboOracle extends DboSource {
|
||||||
* Returns a quoted and escaped string of $data for use in an SQL statement.
|
* Returns a quoted and escaped string of $data for use in an SQL statement.
|
||||||
*
|
*
|
||||||
* @param string $data String to be prepared for use in an SQL statement
|
* @param string $data String to be prepared for use in an SQL statement
|
||||||
|
* @param string $column
|
||||||
* @return string Quoted and escaped
|
* @return string Quoted and escaped
|
||||||
*/
|
*/
|
||||||
public function value($data, $column = null) {
|
public function value($data, $column = null) {
|
||||||
|
@ -877,10 +874,10 @@ class DboOracle extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns the ID generated from the previous INSERT operation.
|
* Returns the ID generated from the previous INSERT operation.
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string $source
|
||||||
* @return integer
|
* @return integer|boolean
|
||||||
*/
|
*/
|
||||||
public function lastInsertId($source) {
|
public function lastInsertId($source = null) {
|
||||||
$sequence = $this->_sequenceMap[$source];
|
$sequence = $this->_sequenceMap[$source];
|
||||||
$sql = "SELECT $sequence.currval FROM dual";
|
$sql = "SELECT $sequence.currval FROM dual";
|
||||||
|
|
||||||
|
@ -897,18 +894,20 @@ class DboOracle extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns a formatted error message from previous database operation.
|
* Returns a formatted error message from previous database operation.
|
||||||
*
|
*
|
||||||
|
* @param PDOStatement $query the query to extract the error from if any
|
||||||
* @return string Error message with error number
|
* @return string Error message with error number
|
||||||
*/
|
*/
|
||||||
public function lastError() {
|
public function lastError(PDOStatement $query = null) {
|
||||||
return $this->_error;
|
return $this->_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.
|
* Returns number of affected rows in previous database operation. If no previous operation exists, this returns false.
|
||||||
*
|
*
|
||||||
* @return int Number of affected rows
|
* @param mixed $source
|
||||||
|
* @return integer Number of affected rows
|
||||||
*/
|
*/
|
||||||
public function lastAffected() {
|
public function lastAffected($source = null) {
|
||||||
return $this->_statementId ? ocirowcount($this->_statementId): false;
|
return $this->_statementId ? ocirowcount($this->_statementId): false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,18 +958,19 @@ class DboOracle extends DboSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* queryAssociation method
|
||||||
*
|
*
|
||||||
* @param Model $model
|
* @param Model $model
|
||||||
* @param unknown_type $linkModel
|
* @param Model $linkModel
|
||||||
* @param string $type Association type
|
* @param string $type Association type
|
||||||
* @param unknown_type $association
|
* @param string $association
|
||||||
* @param unknown_type $assocData
|
* @param array $assocData
|
||||||
* @param unknown_type $queryData
|
* @param array $queryData
|
||||||
* @param unknown_type $external
|
* @param boolean $external
|
||||||
* @param unknown_type $resultSet
|
* @param array $resultSet
|
||||||
* @param integer $recursive Number of levels of association
|
* @param integer $recursive Number of levels of association
|
||||||
* @param array $stack
|
* @param array $stack
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
|
public function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
|
||||||
if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
|
if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
|
||||||
|
@ -1101,16 +1101,16 @@ class DboOracle extends DboSource {
|
||||||
if (empty($merge) && !isset($row[$association])) {
|
if (empty($merge) && !isset($row[$association])) {
|
||||||
$row[$association] = $merge;
|
$row[$association] = $merge;
|
||||||
} else {
|
} else {
|
||||||
$this->__mergeAssociation($resultSet[$i], $merge, $association, $type);
|
$this->_mergeAssociation($resultSet[$i], $merge, $association, $type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->__mergeAssociation($resultSet[$i], $fetch, $association, $type);
|
$this->_mergeAssociation($resultSet[$i], $fetch, $association, $type);
|
||||||
}
|
}
|
||||||
$resultSet[$i][$association] = $linkModel->afterfind($resultSet[$i][$association]);
|
$resultSet[$i][$association] = $linkModel->afterfind($resultSet[$i][$association]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$tempArray[0][$association] = false;
|
$tempArray[0][$association] = false;
|
||||||
$this->__mergeAssociation($resultSet[$i], $tempArray, $association, $type);
|
$this->_mergeAssociation($resultSet[$i], $tempArray, $association, $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ class Postgres extends DboSource {
|
||||||
* Driver description
|
* Driver description
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $description = "PostgreSQL DBO Driver";
|
public $description = "PostgreSQL DBO Driver";
|
||||||
|
|
||||||
|
@ -40,7 +39,6 @@ class Postgres extends DboSource {
|
||||||
* Index of basic SQL commands
|
* Index of basic SQL commands
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_commands = array(
|
protected $_commands = array(
|
||||||
'begin' => 'BEGIN',
|
'begin' => 'BEGIN',
|
||||||
|
@ -52,7 +50,6 @@ class Postgres extends DboSource {
|
||||||
* Base driver configuration settings. Merged with user settings.
|
* Base driver configuration settings. Merged with user settings.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_baseConfig = array(
|
protected $_baseConfig = array(
|
||||||
'persistent' => true,
|
'persistent' => true,
|
||||||
|
@ -65,6 +62,11 @@ class Postgres extends DboSource {
|
||||||
'encoding' => ''
|
'encoding' => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Columns
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
public $columns = array(
|
public $columns = array(
|
||||||
'primary_key' => array('name' => 'serial NOT NULL'),
|
'primary_key' => array('name' => 'serial NOT NULL'),
|
||||||
'string' => array('name' => 'varchar', 'limit' => '255'),
|
'string' => array('name' => 'varchar', 'limit' => '255'),
|
||||||
|
@ -85,7 +87,6 @@ class Postgres extends DboSource {
|
||||||
* Starting Quote
|
* Starting Quote
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $startQuote = '"';
|
public $startQuote = '"';
|
||||||
|
|
||||||
|
@ -93,7 +94,6 @@ class Postgres extends DboSource {
|
||||||
* Ending Quote
|
* Ending Quote
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $endQuote = '"';
|
public $endQuote = '"';
|
||||||
|
|
||||||
|
@ -108,7 +108,8 @@ class Postgres extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Connects to the database using options in the given configuration array.
|
* Connects to the database using options in the given configuration array.
|
||||||
*
|
*
|
||||||
* @return True if successfully connected.
|
* @return boolean True if successfully connected.
|
||||||
|
* @throws MissingConnectionException
|
||||||
*/
|
*/
|
||||||
public function connect() {
|
public function connect() {
|
||||||
$config = $this->config;
|
$config = $this->config;
|
||||||
|
@ -150,6 +151,7 @@ class Postgres extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
|
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
|
||||||
*
|
*
|
||||||
|
* @param mixed $data
|
||||||
* @return array Array of tablenames in the database
|
* @return array Array of tablenames in the database
|
||||||
*/
|
*/
|
||||||
public function listSources($data = null) {
|
public function listSources($data = null) {
|
||||||
|
@ -181,10 +183,10 @@ class Postgres extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns an array of the fields in given table name.
|
* Returns an array of the fields in given table name.
|
||||||
*
|
*
|
||||||
* @param string $tableName Name of database table to inspect
|
* @param Model $model Name of database table to inspect
|
||||||
* @return array Fields in table. Keys are name and type
|
* @return array Fields in table. Keys are name and type
|
||||||
*/
|
*/
|
||||||
public function describe($model) {
|
public function describe(Model $model) {
|
||||||
$fields = parent::describe($model);
|
$fields = parent::describe($model);
|
||||||
$table = $this->fullTableName($model, false);
|
$table = $this->fullTableName($model, false);
|
||||||
$this->_sequenceMap[$table] = array();
|
$this->_sequenceMap[$table] = array();
|
||||||
|
@ -247,7 +249,7 @@ class Postgres extends DboSource {
|
||||||
$fields[$c->name]['default'] = constant($fields[$c->name]['default']);
|
$fields[$c->name]['default'] = constant($fields[$c->name]['default']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->__cacheDescription($table, $fields);
|
$this->_cacheDescription($table, $fields);
|
||||||
}
|
}
|
||||||
if (isset($model->sequence)) {
|
if (isset($model->sequence)) {
|
||||||
$this->_sequenceMap[$table][$model->primaryKey] = $model->sequence;
|
$this->_sequenceMap[$table][$model->primaryKey] = $model->sequence;
|
||||||
|
@ -266,7 +268,7 @@ class Postgres extends DboSource {
|
||||||
* @param string $field Name of the ID database field. Defaults to "id"
|
* @param string $field Name of the ID database field. Defaults to "id"
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function lastInsertId($source, $field = 'id') {
|
public function lastInsertId($source = null, $field = 'id') {
|
||||||
$seq = $this->getSequence($source, $field);
|
$seq = $this->getSequence($source, $field);
|
||||||
return $this->_connection->lastInsertId($seq);
|
return $this->_connection->lastInsertId($seq);
|
||||||
}
|
}
|
||||||
|
@ -336,6 +338,7 @@ class Postgres extends DboSource {
|
||||||
* @param Model $model
|
* @param Model $model
|
||||||
* @param string $alias Alias tablename
|
* @param string $alias Alias tablename
|
||||||
* @param mixed $fields
|
* @param mixed $fields
|
||||||
|
* @param boolean $quote
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fields($model, $alias = null, $fields = array(), $quote = true) {
|
public function fields($model, $alias = null, $fields = array(), $quote = true) {
|
||||||
|
@ -379,7 +382,7 @@ class Postgres extends DboSource {
|
||||||
$fields[$i] = $prepend . $this->name($build[0]) . '.' . $this->name($build[1]) . ' AS ' . $this->name($build[0] . '__' . $build[1]);
|
$fields[$i] = $prepend . $this->name($build[0]) . '.' . $this->name($build[1]) . ' AS ' . $this->name($build[0] . '__' . $build[1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$fields[$i] = preg_replace_callback('/\(([\s\.\w]+)\)/', array(&$this, '__quoteFunctionField'), $fields[$i]);
|
$fields[$i] = preg_replace_callback('/\(([\s\.\w]+)\)/', array(&$this, '_quoteFunctionField'), $fields[$i]);
|
||||||
}
|
}
|
||||||
$result[] = $fields[$i];
|
$result[] = $fields[$i];
|
||||||
}
|
}
|
||||||
|
@ -391,11 +394,10 @@ class Postgres extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Auxiliary function to quote matched `(Model.fields)` from a preg_replace_callback call
|
* Auxiliary function to quote matched `(Model.fields)` from a preg_replace_callback call
|
||||||
*
|
*
|
||||||
* @param string matched string
|
* @param string $match matched string
|
||||||
* @return string quoted strig
|
* @return string quoted strig
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private function __quoteFunctionField($match) {
|
protected function _quoteFunctionField($match) {
|
||||||
$prepend = '';
|
$prepend = '';
|
||||||
if (strpos($match[1], 'DISTINCT') !== false) {
|
if (strpos($match[1], 'DISTINCT') !== false) {
|
||||||
$prepend = 'DISTINCT ';
|
$prepend = 'DISTINCT ';
|
||||||
|
@ -456,7 +458,6 @@ class Postgres extends DboSource {
|
||||||
*
|
*
|
||||||
* @param array $compare Results of CakeSchema::compare()
|
* @param array $compare Results of CakeSchema::compare()
|
||||||
* @param string $table name of the table
|
* @param string $table name of the table
|
||||||
* @access public
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function alterSchema($compare, $table = null) {
|
public function alterSchema($compare, $table = null) {
|
||||||
|
@ -544,7 +545,7 @@ class Postgres extends DboSource {
|
||||||
* Generate PostgreSQL index alteration statements for a table.
|
* Generate PostgreSQL index alteration statements for a table.
|
||||||
*
|
*
|
||||||
* @param string $table Table to alter indexes for
|
* @param string $table Table to alter indexes for
|
||||||
* @param array $new Indexes to add and drop
|
* @param array $indexes Indexes to add and drop
|
||||||
* @return array Index alteration statements
|
* @return array Index alteration statements
|
||||||
*/
|
*/
|
||||||
protected function _alterIndexes($table, $indexes) {
|
protected function _alterIndexes($table, $indexes) {
|
||||||
|
@ -659,7 +660,7 @@ class Postgres extends DboSource {
|
||||||
* Gets the length of a database-native column description, or null if no length
|
* Gets the length of a database-native column description, or null if no length
|
||||||
*
|
*
|
||||||
* @param string $real Real database-layer column type (i.e. "varchar(255)")
|
* @param string $real Real database-layer column type (i.e. "varchar(255)")
|
||||||
* @return int An integer representing the length of the column
|
* @return integer An integer representing the length of the column
|
||||||
*/
|
*/
|
||||||
public function length($real) {
|
public function length($real) {
|
||||||
$col = str_replace(array(')', 'unsigned'), '', $real);
|
$col = str_replace(array(')', 'unsigned'), '', $real);
|
||||||
|
@ -678,9 +679,10 @@ class Postgres extends DboSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* resultSet method
|
||||||
*
|
*
|
||||||
* @param unknown_type $results
|
* @param array $results
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function resultSet(&$results) {
|
public function resultSet(&$results) {
|
||||||
$this->map = array();
|
$this->map = array();
|
||||||
|
@ -703,7 +705,7 @@ class Postgres extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Fetches the next row from the current result set
|
* Fetches the next row from the current result set
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fetchResult() {
|
public function fetchResult() {
|
||||||
if ($row = $this->_result->fetch()) {
|
if ($row = $this->_result->fetch()) {
|
||||||
|
|
|
@ -32,33 +32,29 @@ class Sqlite extends DboSource {
|
||||||
* Datasource Description
|
* Datasource Description
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $description = "SQLite DBO Driver";
|
public $description = "SQLite DBO Driver";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quote Start
|
* Quote Start
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $startQuote = '"';
|
public $startQuote = '"';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quote End
|
* Quote End
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $endQuote = '"';
|
public $endQuote = '"';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base configuration settings for SQLite3 driver
|
* Base configuration settings for SQLite3 driver
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $_baseConfig = array(
|
protected $_baseConfig = array(
|
||||||
'persistent' => false,
|
'persistent' => false,
|
||||||
'database' => null
|
'database' => null
|
||||||
);
|
);
|
||||||
|
@ -67,9 +63,8 @@ class Sqlite extends DboSource {
|
||||||
* SQLite3 column definition
|
* SQLite3 column definition
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $columns = array(
|
public $columns = array(
|
||||||
'primary_key' => array('name' => 'integer primary key autoincrement'),
|
'primary_key' => array('name' => 'integer primary key autoincrement'),
|
||||||
'string' => array('name' => 'varchar', 'limit' => '255'),
|
'string' => array('name' => 'varchar', 'limit' => '255'),
|
||||||
'text' => array('name' => 'text'),
|
'text' => array('name' => 'text'),
|
||||||
|
@ -87,9 +82,8 @@ class Sqlite extends DboSource {
|
||||||
* List of engine specific additional field parameters used on table creating
|
* List of engine specific additional field parameters used on table creating
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $fieldParameters = array(
|
public $fieldParameters = array(
|
||||||
'collate' => array(
|
'collate' => array(
|
||||||
'value' => 'COLLATE',
|
'value' => 'COLLATE',
|
||||||
'quote' => false,
|
'quote' => false,
|
||||||
|
@ -105,9 +99,8 @@ class Sqlite extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Connects to the database using config['database'] as a filename.
|
* Connects to the database using config['database'] as a filename.
|
||||||
*
|
*
|
||||||
* @param array $config Configuration array for connecting
|
* @return boolean
|
||||||
* @return mixed
|
* @throws MissingConnectionException
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function connect() {
|
public function connect() {
|
||||||
$config = $this->config;
|
$config = $this->config;
|
||||||
|
@ -134,8 +127,8 @@ class Sqlite extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
|
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
|
||||||
*
|
*
|
||||||
|
* @param mixed $data
|
||||||
* @return array Array of tablenames in the database
|
* @return array Array of tablenames in the database
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function listSources($data = null) {
|
public function listSources($data = null) {
|
||||||
$cache = parent::listSources();
|
$cache = parent::listSources();
|
||||||
|
@ -161,11 +154,10 @@ class Sqlite extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns an array of the fields in given table name.
|
* Returns an array of the fields in given table name.
|
||||||
*
|
*
|
||||||
* @param string $tableName Name of database table to inspect
|
* @param Model $model
|
||||||
* @return array Fields in table. Keys are name and type
|
* @return array Fields in table. Keys are name and type
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function describe($model) {
|
public function describe(Model $model) {
|
||||||
$cache = parent::describe($model);
|
$cache = parent::describe($model);
|
||||||
if ($cache != null) {
|
if ($cache != null) {
|
||||||
return $cache;
|
return $cache;
|
||||||
|
@ -193,7 +185,7 @@ class Sqlite extends DboSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
$this->__cacheDescription($model->tablePrefix . $model->table, $fields);
|
$this->_cacheDescription($model->tablePrefix . $model->table, $fields);
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,9 +197,8 @@ class Sqlite extends DboSource {
|
||||||
* @param array $values
|
* @param array $values
|
||||||
* @param mixed $conditions
|
* @param mixed $conditions
|
||||||
* @return array
|
* @return array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function update($model, $fields = array(), $values = null, $conditions = null) {
|
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
|
||||||
if (empty($values) && !empty($fields)) {
|
if (empty($values) && !empty($fields)) {
|
||||||
foreach ($fields as $field => $value) {
|
foreach ($fields as $field => $value) {
|
||||||
if (strpos($field, $model->alias . '.') !== false) {
|
if (strpos($field, $model->alias . '.') !== false) {
|
||||||
|
@ -227,7 +218,6 @@ class Sqlite extends DboSource {
|
||||||
*
|
*
|
||||||
* @param mixed $table A string or model class representing the table to be truncated
|
* @param mixed $table A string or model class representing the table to be truncated
|
||||||
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
|
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function truncate($table) {
|
public function truncate($table) {
|
||||||
$this->_execute('DELETE FROM sqlite_sequence where name=' . $this->fullTableName($table));
|
$this->_execute('DELETE FROM sqlite_sequence where name=' . $this->fullTableName($table));
|
||||||
|
@ -239,7 +229,6 @@ class Sqlite extends DboSource {
|
||||||
*
|
*
|
||||||
* @param string $real Real database-layer column type (i.e. "varchar(255)")
|
* @param string $real Real database-layer column type (i.e. "varchar(255)")
|
||||||
* @return string Abstract column type (i.e. "string")
|
* @return string Abstract column type (i.e. "string")
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function column($real) {
|
public function column($real) {
|
||||||
if (is_array($real)) {
|
if (is_array($real)) {
|
||||||
|
@ -273,7 +262,7 @@ class Sqlite extends DboSource {
|
||||||
* Generate ResultSet
|
* Generate ResultSet
|
||||||
*
|
*
|
||||||
* @param mixed $results
|
* @param mixed $results
|
||||||
* @access public
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function resultSet($results) {
|
public function resultSet($results) {
|
||||||
$this->results = $results;
|
$this->results = $results;
|
||||||
|
@ -356,7 +345,6 @@ class Sqlite extends DboSource {
|
||||||
* @param integer $limit Limit of results returned
|
* @param integer $limit Limit of results returned
|
||||||
* @param integer $offset Offset from which to start results
|
* @param integer $offset Offset from which to start results
|
||||||
* @return string SQL limit/offset statement
|
* @return string SQL limit/offset statement
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function limit($limit, $offset = null) {
|
public function limit($limit, $offset = null) {
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
|
@ -379,7 +367,6 @@ class Sqlite extends DboSource {
|
||||||
* @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]),
|
* @param array $column An array structured like the following: array('name'=>'value', 'type'=>'value'[, options]),
|
||||||
* where options can be 'default', 'length', or 'key'.
|
* where options can be 'default', 'length', or 'key'.
|
||||||
* @return string
|
* @return string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function buildColumn($column) {
|
public function buildColumn($column) {
|
||||||
$name = $type = null;
|
$name = $type = null;
|
||||||
|
@ -408,7 +395,7 @@ class Sqlite extends DboSource {
|
||||||
* Sets the database encoding
|
* Sets the database encoding
|
||||||
*
|
*
|
||||||
* @param string $enc Database encoding
|
* @param string $enc Database encoding
|
||||||
* @access public
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function setEncoding($enc) {
|
public function setEncoding($enc) {
|
||||||
if (!in_array($enc, array("UTF-8", "UTF-16", "UTF-16le", "UTF-16be"))) {
|
if (!in_array($enc, array("UTF-8", "UTF-16", "UTF-16le", "UTF-16be"))) {
|
||||||
|
@ -421,7 +408,6 @@ class Sqlite extends DboSource {
|
||||||
* Gets the database encoding
|
* Gets the database encoding
|
||||||
*
|
*
|
||||||
* @return string The database encoding
|
* @return string The database encoding
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function getEncoding() {
|
public function getEncoding() {
|
||||||
return $this->fetchRow('PRAGMA encoding');
|
return $this->fetchRow('PRAGMA encoding');
|
||||||
|
@ -433,7 +419,6 @@ class Sqlite extends DboSource {
|
||||||
* @param array $indexes
|
* @param array $indexes
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* @return string
|
* @return string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function buildIndex($indexes, $table = null) {
|
public function buildIndex($indexes, $table = null) {
|
||||||
$join = array();
|
$join = array();
|
||||||
|
@ -466,7 +451,6 @@ class Sqlite extends DboSource {
|
||||||
*
|
*
|
||||||
* @param string $model Name of model to inspect
|
* @param string $model Name of model to inspect
|
||||||
* @return array Fields in table. Keys are column and unique
|
* @return array Fields in table. Keys are column and unique
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function index($model) {
|
public function index($model) {
|
||||||
$index = array();
|
$index = array();
|
||||||
|
@ -507,7 +491,6 @@ class Sqlite extends DboSource {
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return string
|
* @return string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function renderStatement($type, $data) {
|
public function renderStatement($type, $data) {
|
||||||
switch (strtolower($type)) {
|
switch (strtolower($type)) {
|
||||||
|
@ -531,7 +514,6 @@ class Sqlite extends DboSource {
|
||||||
* PDO deals in objects, not resources, so overload accordingly.
|
* PDO deals in objects, not resources, so overload accordingly.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function hasResult() {
|
public function hasResult() {
|
||||||
return is_object($this->_result);
|
return is_object($this->_result);
|
||||||
|
@ -540,7 +522,7 @@ class Sqlite extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Generate a "drop table" statement for the given Schema object
|
* Generate a "drop table" statement for the given Schema object
|
||||||
*
|
*
|
||||||
* @param object $schema An instance of a subclass of CakeSchema
|
* @param CakeSchema $schema An instance of a subclass of CakeSchema
|
||||||
* @param string $table Optional. If specified only the table name given will be generated.
|
* @param string $table Optional. If specified only the table name given will be generated.
|
||||||
* Otherwise, all tables defined in the schema are generated.
|
* Otherwise, all tables defined in the schema are generated.
|
||||||
* @return string
|
* @return string
|
||||||
|
|
|
@ -108,13 +108,6 @@ class Sqlserver extends DboSource {
|
||||||
'rollback' => 'ROLLBACK'
|
'rollback' => 'ROLLBACK'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* Define if the last query had error
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $__lastQueryHadError = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic column name used to provide pagination support for SQLServer 2008
|
* Magic column name used to provide pagination support for SQLServer 2008
|
||||||
* which lacks proper limit/offset support.
|
* which lacks proper limit/offset support.
|
||||||
|
@ -133,6 +126,7 @@ class Sqlserver extends DboSource {
|
||||||
* Connects to the database using options in the given configuration array.
|
* Connects to the database using options in the given configuration array.
|
||||||
*
|
*
|
||||||
* @return boolean True if the database could be connected, else false
|
* @return boolean True if the database could be connected, else false
|
||||||
|
* @throws MissingConnectionException
|
||||||
*/
|
*/
|
||||||
public function connect() {
|
public function connect() {
|
||||||
$config = $this->config;
|
$config = $this->config;
|
||||||
|
@ -169,9 +163,10 @@ class Sqlserver extends DboSource {
|
||||||
/**
|
/**
|
||||||
* Returns an array of sources (tables) in the database.
|
* Returns an array of sources (tables) in the database.
|
||||||
*
|
*
|
||||||
|
* @param mixed $data
|
||||||
* @return array Array of tablenames in the database
|
* @return array Array of tablenames in the database
|
||||||
*/
|
*/
|
||||||
public function listSources() {
|
public function listSources($data = null) {
|
||||||
$cache = parent::listSources();
|
$cache = parent::listSources();
|
||||||
if ($cache !== null) {
|
if ($cache !== null) {
|
||||||
return $cache;
|
return $cache;
|
||||||
|
@ -199,8 +194,9 @@ class Sqlserver extends DboSource {
|
||||||
*
|
*
|
||||||
* @param Model $model Model object to describe
|
* @param Model $model Model object to describe
|
||||||
* @return array Fields in table. Keys are name and type
|
* @return array Fields in table. Keys are name and type
|
||||||
|
* @throws CakeException
|
||||||
*/
|
*/
|
||||||
public function describe($model) {
|
public function describe(Model $model) {
|
||||||
$cache = parent::describe($model);
|
$cache = parent::describe($model);
|
||||||
if ($cache != null) {
|
if ($cache != null) {
|
||||||
return $cache;
|
return $cache;
|
||||||
|
@ -251,7 +247,7 @@ class Sqlserver extends DboSource {
|
||||||
$fields[$field]['length'] = $fields[$field]['length'] . ',' . $column->Size;
|
$fields[$field]['length'] = $fields[$field]['length'] . ',' . $column->Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->__cacheDescription($table, $fields);
|
$this->_cacheDescription($table, $fields);
|
||||||
$cols->closeCursor();
|
$cols->closeCursor();
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
@ -262,7 +258,8 @@ class Sqlserver extends DboSource {
|
||||||
*
|
*
|
||||||
* @param Model $model
|
* @param Model $model
|
||||||
* @param string $alias Alias tablename
|
* @param string $alias Alias tablename
|
||||||
* @param mixed $fields
|
* @param array $fields
|
||||||
|
* @param boolean $quote
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fields($model, $alias = null, $fields = array(), $quote = true) {
|
public function fields($model, $alias = null, $fields = array(), $quote = true) {
|
||||||
|
@ -327,10 +324,9 @@ class Sqlserver extends DboSource {
|
||||||
* @param Model $model
|
* @param Model $model
|
||||||
* @param array $fields
|
* @param array $fields
|
||||||
* @param array $values
|
* @param array $values
|
||||||
* @param mixed $conditions
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function create($model, $fields = null, $values = null) {
|
public function create(Model $model, $fields = null, $values = null) {
|
||||||
if (!empty($values)) {
|
if (!empty($values)) {
|
||||||
$fields = array_combine($fields, $values);
|
$fields = array_combine($fields, $values);
|
||||||
}
|
}
|
||||||
|
@ -360,7 +356,7 @@ class Sqlserver extends DboSource {
|
||||||
* @param mixed $conditions
|
* @param mixed $conditions
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function update($model, $fields = array(), $values = null, $conditions = null) {
|
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
|
||||||
if (!empty($values)) {
|
if (!empty($values)) {
|
||||||
$fields = array_combine($fields, $values);
|
$fields = array_combine($fields, $values);
|
||||||
}
|
}
|
||||||
|
@ -464,6 +460,7 @@ class Sqlserver extends DboSource {
|
||||||
* Builds a map of the columns contained in a result
|
* Builds a map of the columns contained in a result
|
||||||
*
|
*
|
||||||
* @param PDOStatement $results
|
* @param PDOStatement $results
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function resultSet($results) {
|
public function resultSet($results) {
|
||||||
$this->map = array();
|
$this->map = array();
|
||||||
|
@ -589,11 +586,12 @@ class Sqlserver extends DboSource {
|
||||||
* Returns an array of all result rows for a given SQL query.
|
* Returns an array of all result rows for a given SQL query.
|
||||||
* Returns false if no rows matched.
|
* Returns false if no rows matched.
|
||||||
*
|
*
|
||||||
* @param string $sql SQL statement
|
* @param Model $model
|
||||||
* @param boolean $cache Enables returning/storing cached query results
|
* @param array $queryData
|
||||||
|
* @param integer $recursive
|
||||||
* @return array Array of resultset rows, or false if no rows matched
|
* @return array Array of resultset rows, or false if no rows matched
|
||||||
*/
|
*/
|
||||||
public function read($model, $queryData = array(), $recursive = null) {
|
public function read(Model $model, $queryData = array(), $recursive = null) {
|
||||||
$results = parent::read($model, $queryData, $recursive);
|
$results = parent::read($model, $queryData, $recursive);
|
||||||
$this->_fieldMappings = array();
|
$this->_fieldMappings = array();
|
||||||
return $results;
|
return $results;
|
||||||
|
@ -630,6 +628,7 @@ class Sqlserver extends DboSource {
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* @param string $fields
|
* @param string $fields
|
||||||
* @param array $values
|
* @param array $values
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function insertMulti($table, $fields, $values) {
|
public function insertMulti($table, $fields, $values) {
|
||||||
$primaryKey = $this->_getPrimaryKey($table);
|
$primaryKey = $this->_getPrimaryKey($table);
|
||||||
|
@ -730,9 +729,10 @@ class Sqlserver extends DboSource {
|
||||||
* Returns number of affected rows in previous database operation. If no previous operation exists,
|
* Returns number of affected rows in previous database operation. If no previous operation exists,
|
||||||
* this returns false.
|
* this returns false.
|
||||||
*
|
*
|
||||||
|
* @param mixed $source
|
||||||
* @return integer Number of affected rows
|
* @return integer Number of affected rows
|
||||||
*/
|
*/
|
||||||
public function lastAffected() {
|
public function lastAffected($source = null) {
|
||||||
$affected = parent::lastAffected();
|
$affected = parent::lastAffected();
|
||||||
if ($affected === null && $this->_lastAffected !== false) {
|
if ($affected === null && $this->_lastAffected !== false) {
|
||||||
return $this->_lastAffected;
|
return $this->_lastAffected;
|
||||||
|
|
|
@ -34,7 +34,6 @@ class DboSource extends DataSource {
|
||||||
* Description string for this Database Data Source.
|
* Description string for this Database Data Source.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $description = "Database Data Source";
|
public $description = "Database Data Source";
|
||||||
|
|
||||||
|
@ -49,7 +48,6 @@ class DboSource extends DataSource {
|
||||||
* Database keyword used to assign aliases to identifiers.
|
* Database keyword used to assign aliases to identifiers.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $alias = 'AS ';
|
public $alias = 'AS ';
|
||||||
|
|
||||||
|
@ -60,7 +58,6 @@ class DboSource extends DataSource {
|
||||||
* with collisions, set DboSource::$cacheMethods to false.
|
* with collisions, set DboSource::$cacheMethods to false.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public static $methodCache = array();
|
public static $methodCache = array();
|
||||||
|
|
||||||
|
@ -69,7 +66,6 @@ class DboSource extends DataSource {
|
||||||
* into the memory cache. Set to false to disable the use of the memory cache.
|
* into the memory cache. Set to false to disable the use of the memory cache.
|
||||||
*
|
*
|
||||||
* @var boolean.
|
* @var boolean.
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $cacheMethods = true;
|
public $cacheMethods = true;
|
||||||
|
|
||||||
|
@ -77,15 +73,13 @@ class DboSource extends DataSource {
|
||||||
* Print full query debug info?
|
* Print full query debug info?
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $fullDebug = false;
|
public $fullDebug = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error description of last query
|
* Error description of last query
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $error = null;
|
public $error = null;
|
||||||
|
|
||||||
|
@ -93,23 +87,20 @@ class DboSource extends DataSource {
|
||||||
* String to hold how many rows were affected by the last SQL operation.
|
* String to hold how many rows were affected by the last SQL operation.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $affected = null;
|
public $affected = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of rows in current resultset
|
* Number of rows in current resultset
|
||||||
*
|
*
|
||||||
* @var int
|
* @var integer
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $numRows = null;
|
public $numRows = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time the last query took
|
* Time the last query took
|
||||||
*
|
*
|
||||||
* @var int
|
* @var integer
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $took = null;
|
public $took = null;
|
||||||
|
|
||||||
|
@ -117,31 +108,27 @@ class DboSource extends DataSource {
|
||||||
* Result
|
* Result
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_result = null;
|
protected $_result = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries count.
|
* Queries count.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var integer
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_queriesCnt = 0;
|
protected $_queriesCnt = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Total duration of all queries.
|
* Total duration of all queries.
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var integer
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_queriesTime = null;
|
protected $_queriesTime = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log of queries executed by this DataSource
|
* Log of queries executed by this DataSource
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_queriesLog = array();
|
protected $_queriesLog = array();
|
||||||
|
|
||||||
|
@ -150,8 +137,7 @@ class DboSource extends DataSource {
|
||||||
*
|
*
|
||||||
* This is to prevent query log taking over too much memory.
|
* This is to prevent query log taking over too much memory.
|
||||||
*
|
*
|
||||||
* @var int Maximum number of queries in the queries log.
|
* @var integer Maximum number of queries in the queries log.
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_queriesLogMax = 200;
|
protected $_queriesLogMax = 200;
|
||||||
|
|
||||||
|
@ -159,7 +145,6 @@ class DboSource extends DataSource {
|
||||||
* Caches serialzed results of executed queries
|
* Caches serialzed results of executed queries
|
||||||
*
|
*
|
||||||
* @var array Maximum number of queries in the queries log.
|
* @var array Maximum number of queries in the queries log.
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_queryCache = array();
|
protected $_queryCache = array();
|
||||||
|
|
||||||
|
@ -167,7 +152,6 @@ class DboSource extends DataSource {
|
||||||
* A reference to the physical connection of this DataSource
|
* A reference to the physical connection of this DataSource
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $connection = null;
|
public $connection = null;
|
||||||
|
|
||||||
|
@ -175,7 +159,6 @@ class DboSource extends DataSource {
|
||||||
* The DataSource configuration key name
|
* The DataSource configuration key name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $configKeyName = null;
|
public $configKeyName = null;
|
||||||
|
|
||||||
|
@ -183,7 +166,6 @@ class DboSource extends DataSource {
|
||||||
* The starting character that this DataSource uses for quoted identifiers.
|
* The starting character that this DataSource uses for quoted identifiers.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $startQuote = null;
|
public $startQuote = null;
|
||||||
|
|
||||||
|
@ -191,7 +173,6 @@ class DboSource extends DataSource {
|
||||||
* The ending character that this DataSource uses for quoted identifiers.
|
* The ending character that this DataSource uses for quoted identifiers.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $endQuote = null;
|
public $endQuote = null;
|
||||||
|
|
||||||
|
@ -199,15 +180,13 @@ class DboSource extends DataSource {
|
||||||
* The set of valid SQL operations usable in a WHERE statement
|
* The set of valid SQL operations usable in a WHERE statement
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private $__sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to');
|
protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates the level of nested transactions
|
* Indicates the level of nested transactions
|
||||||
*
|
*
|
||||||
* @var integer
|
* @var integer
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_transactionNesting = 0;
|
protected $_transactionNesting = 0;
|
||||||
|
|
||||||
|
@ -215,7 +194,6 @@ class DboSource extends DataSource {
|
||||||
* Index of basic SQL commands
|
* Index of basic SQL commands
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_commands = array(
|
protected $_commands = array(
|
||||||
'begin' => 'BEGIN',
|
'begin' => 'BEGIN',
|
||||||
|
@ -234,7 +212,6 @@ class DboSource extends DataSource {
|
||||||
* List of table engine specific parameters used on table creating
|
* List of table engine specific parameters used on table creating
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $tableParameters = array();
|
public $tableParameters = array();
|
||||||
|
|
||||||
|
@ -242,7 +219,6 @@ class DboSource extends DataSource {
|
||||||
* List of engine specific additional field parameters used on table creating
|
* List of engine specific additional field parameters used on table creating
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $fieldParameters = array();
|
public $fieldParameters = array();
|
||||||
|
|
||||||
|
@ -376,7 +352,7 @@ class DboSource extends DataSource {
|
||||||
* are not sanitized or esacped.
|
* are not sanitized or esacped.
|
||||||
*
|
*
|
||||||
* @param string $identifier A SQL expression to be used as an identifier
|
* @param string $identifier A SQL expression to be used as an identifier
|
||||||
* @return object An object representing a database identifier to be used in a query
|
* @return stdClass An object representing a database identifier to be used in a query
|
||||||
*/
|
*/
|
||||||
public function identifier($identifier) {
|
public function identifier($identifier) {
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
|
@ -390,7 +366,7 @@ class DboSource extends DataSource {
|
||||||
* are not sanitized or esacped.
|
* are not sanitized or esacped.
|
||||||
*
|
*
|
||||||
* @param string $expression An arbitrary SQL expression to be inserted into a query.
|
* @param string $expression An arbitrary SQL expression to be inserted into a query.
|
||||||
* @return object An object representing a database expression to be used in a query
|
* @return stdClass An object representing a database expression to be used in a query
|
||||||
*/
|
*/
|
||||||
public function expression($expression) {
|
public function expression($expression) {
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
|
@ -503,9 +479,10 @@ class DboSource extends DataSource {
|
||||||
* Returns number of affected rows in previous database operation. If no previous operation exists,
|
* Returns number of affected rows in previous database operation. If no previous operation exists,
|
||||||
* this returns false.
|
* this returns false.
|
||||||
*
|
*
|
||||||
|
* @param mixed $source
|
||||||
* @return integer Number of affected rows
|
* @return integer Number of affected rows
|
||||||
*/
|
*/
|
||||||
public function lastAffected() {
|
public function lastAffected($source = null) {
|
||||||
if ($this->hasResult()) {
|
if ($this->hasResult()) {
|
||||||
return $this->_result->rowCount();
|
return $this->_result->rowCount();
|
||||||
}
|
}
|
||||||
|
@ -516,9 +493,10 @@ class DboSource extends DataSource {
|
||||||
* Returns number of rows in previous resultset. If no previous resultset exists,
|
* Returns number of rows in previous resultset. If no previous resultset exists,
|
||||||
* this returns false.
|
* this returns false.
|
||||||
*
|
*
|
||||||
|
* @param mixed $source Not used
|
||||||
* @return integer Number of rows in resultset
|
* @return integer Number of rows in resultset
|
||||||
*/
|
*/
|
||||||
public function lastNumRows() {
|
public function lastNumRows($source = null) {
|
||||||
return $this->lastAffected();
|
return $this->lastAffected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,7 +683,7 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Modifies $result array to place virtual fields in model entry where they belongs to
|
* Modifies $result array to place virtual fields in model entry where they belongs to
|
||||||
*
|
*
|
||||||
* @param array $resut Reference to the fetched row
|
* @param array $result Reference to the fetched row
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function fetchVirtualField(&$result) {
|
public function fetchVirtualField(&$result) {
|
||||||
|
@ -913,6 +891,7 @@ class DboSource extends DataSource {
|
||||||
* Log given SQL query.
|
* Log given SQL query.
|
||||||
*
|
*
|
||||||
* @param string $sql SQL statement
|
* @param string $sql SQL statement
|
||||||
|
* @return void|boolean
|
||||||
* @todo: Add hook to log errors instead of returning false
|
* @todo: Add hook to log errors instead of returning false
|
||||||
*/
|
*/
|
||||||
public function logQuery($sql) {
|
public function logQuery($sql) {
|
||||||
|
@ -938,6 +917,7 @@ class DboSource extends DataSource {
|
||||||
* and execution time in microseconds. If the query fails, an error is output instead.
|
* and execution time in microseconds. If the query fails, an error is output instead.
|
||||||
*
|
*
|
||||||
* @param string $sql Query to show information on.
|
* @param string $sql Query to show information on.
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function showQuery($sql) {
|
public function showQuery($sql) {
|
||||||
$error = $this->error;
|
$error = $this->error;
|
||||||
|
@ -988,7 +968,7 @@ class DboSource extends DataSource {
|
||||||
* be used to generate values.
|
* be used to generate values.
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function create($model, $fields = null, $values = null) {
|
public function create(Model $model, $fields = null, $values = null) {
|
||||||
$id = null;
|
$id = null;
|
||||||
|
|
||||||
if ($fields == null) {
|
if ($fields == null) {
|
||||||
|
@ -1035,8 +1015,8 @@ class DboSource extends DataSource {
|
||||||
* @param integer $recursive Number of levels of association
|
* @param integer $recursive Number of levels of association
|
||||||
* @return mixed boolean false on error/failure. An array of results on success.
|
* @return mixed boolean false on error/failure. An array of results on success.
|
||||||
*/
|
*/
|
||||||
public function read($model, $queryData = array(), $recursive = null) {
|
public function read(Model $model, $queryData = array(), $recursive = null) {
|
||||||
$queryData = $this->__scrubQueryData($queryData);
|
$queryData = $this->_scrubQueryData($queryData);
|
||||||
|
|
||||||
$null = null;
|
$null = null;
|
||||||
$array = array();
|
$array = array();
|
||||||
|
@ -1133,7 +1113,7 @@ class DboSource extends DataSource {
|
||||||
* Passes association results thru afterFind filters of corresponding model
|
* Passes association results thru afterFind filters of corresponding model
|
||||||
*
|
*
|
||||||
* @param array $results Reference of resultset to be filtered
|
* @param array $results Reference of resultset to be filtered
|
||||||
* @param object $model Instance of model to operate against
|
* @param Model $model Instance of model to operate against
|
||||||
* @param array $filtered List of classes already filtered, to be skipped
|
* @param array $filtered List of classes already filtered, to be skipped
|
||||||
* @return array Array of results that have been filtered through $model->afterFind
|
* @return array Array of results that have been filtered through $model->afterFind
|
||||||
*/
|
*/
|
||||||
|
@ -1166,13 +1146,14 @@ class DboSource extends DataSource {
|
||||||
* @param Model $model Primary Model object
|
* @param Model $model Primary Model object
|
||||||
* @param Model $linkModel Linked model that
|
* @param Model $linkModel Linked model that
|
||||||
* @param string $type Association type, one of the model association types ie. hasMany
|
* @param string $type Association type, one of the model association types ie. hasMany
|
||||||
* @param unknown_type $association
|
* @param string $association
|
||||||
* @param unknown_type $assocData
|
* @param array $assocData
|
||||||
* @param array $queryData
|
* @param array $queryData
|
||||||
* @param boolean $external Whether or not the association query is on an external datasource.
|
* @param boolean $external Whether or not the association query is on an external datasource.
|
||||||
* @param array $resultSet Existing results
|
* @param array $resultSet Existing results
|
||||||
* @param integer $recursive Number of levels of association
|
* @param integer $recursive Number of levels of association
|
||||||
* @param array $stack
|
* @param array $stack
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
|
public function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) {
|
||||||
if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
|
if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) {
|
||||||
|
@ -1219,7 +1200,7 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->_filterResults($fetch, $model);
|
$this->_filterResults($fetch, $model);
|
||||||
return $this->__mergeHasMany($resultSet, $fetch, $association, $model, $linkModel);
|
return $this->_mergeHasMany($resultSet, $fetch, $association, $model, $linkModel);
|
||||||
} elseif ($type === 'hasAndBelongsToMany') {
|
} elseif ($type === 'hasAndBelongsToMany') {
|
||||||
$ins = $fetch = array();
|
$ins = $fetch = array();
|
||||||
foreach ($resultSet as &$result) {
|
foreach ($resultSet as &$result) {
|
||||||
|
@ -1298,17 +1279,17 @@ class DboSource extends DataSource {
|
||||||
if (empty($merge) && !isset($row[$association])) {
|
if (empty($merge) && !isset($row[$association])) {
|
||||||
$row[$association] = $merge;
|
$row[$association] = $merge;
|
||||||
} else {
|
} else {
|
||||||
$this->__mergeAssociation($row, $merge, $association, $type);
|
$this->_mergeAssociation($row, $merge, $association, $type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->__mergeAssociation($row, $fetch, $association, $type, $selfJoin);
|
$this->_mergeAssociation($row, $fetch, $association, $type, $selfJoin);
|
||||||
}
|
}
|
||||||
if (isset($row[$association])) {
|
if (isset($row[$association])) {
|
||||||
$row[$association] = $linkModel->afterFind($row[$association], false);
|
$row[$association] = $linkModel->afterFind($row[$association], false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$tempArray[0][$association] = false;
|
$tempArray[0][$association] = false;
|
||||||
$this->__mergeAssociation($row, $tempArray, $association, $type, $selfJoin);
|
$this->_mergeAssociation($row, $tempArray, $association, $type, $selfJoin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1317,7 +1298,7 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* A more efficient way to fetch associations. Woohoo!
|
* A more efficient way to fetch associations. Woohoo!
|
||||||
*
|
*
|
||||||
* @param model $model Primary model object
|
* @param Model $model Primary model object
|
||||||
* @param string $query Association query
|
* @param string $query Association query
|
||||||
* @param array $ids Array of IDs of associated records
|
* @param array $ids Array of IDs of associated records
|
||||||
* @return array Association results
|
* @return array Association results
|
||||||
|
@ -1337,11 +1318,11 @@ class DboSource extends DataSource {
|
||||||
* @param array $resultSet Data to merge into
|
* @param array $resultSet Data to merge into
|
||||||
* @param array $merge Data to merge
|
* @param array $merge Data to merge
|
||||||
* @param string $association Name of Model being Merged
|
* @param string $association Name of Model being Merged
|
||||||
* @param object $model Model being merged onto
|
* @param Model $model Model being merged onto
|
||||||
* @param object $linkModel Model being merged
|
* @param Model $linkModel Model being merged
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function __mergeHasMany(&$resultSet, $merge, $association, $model, $linkModel) {
|
protected function _mergeHasMany(&$resultSet, $merge, $association, $model, $linkModel) {
|
||||||
$modelAlias = $model->alias;
|
$modelAlias = $model->alias;
|
||||||
$modelPK = $model->primaryKey;
|
$modelPK = $model->primaryKey;
|
||||||
$modelFK = $model->hasMany[$association]['foreignKey'];
|
$modelFK = $model->hasMany[$association]['foreignKey'];
|
||||||
|
@ -1372,16 +1353,16 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Merge association of merge into data
|
||||||
*
|
*
|
||||||
* @param unknown_type $data
|
* @param array $data
|
||||||
* @param unknown_type $merge
|
* @param array $merge
|
||||||
* @param unknown_type $association
|
* @param string $association
|
||||||
* @param unknown_type $type
|
* @param string $type
|
||||||
* @param boolean $selfJoin
|
* @param boolean $selfJoin
|
||||||
* @access private
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __mergeAssociation(&$data, &$merge, $association, $type, $selfJoin = false) {
|
protected function _mergeAssociation(&$data, &$merge, $association, $type, $selfJoin = false) {
|
||||||
if (isset($merge[0]) && !isset($merge[0][$association])) {
|
if (isset($merge[0]) && !isset($merge[0][$association])) {
|
||||||
$association = Inflector::pluralize($association);
|
$association = Inflector::pluralize($association);
|
||||||
}
|
}
|
||||||
|
@ -1465,8 +1446,8 @@ class DboSource extends DataSource {
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function generateAssociationQuery($model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
|
public function generateAssociationQuery($model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
|
||||||
$queryData = $this->__scrubQueryData($queryData);
|
$queryData = $this->_scrubQueryData($queryData);
|
||||||
$assocData = $this->__scrubQueryData($assocData);
|
$assocData = $this->_scrubQueryData($assocData);
|
||||||
$modelAlias = $model->alias;
|
$modelAlias = $model->alias;
|
||||||
|
|
||||||
if (empty($queryData['fields'])) {
|
if (empty($queryData['fields'])) {
|
||||||
|
@ -1520,7 +1501,7 @@ class DboSource extends DataSource {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'hasOne':
|
case 'hasOne':
|
||||||
case 'belongsTo':
|
case 'belongsTo':
|
||||||
$conditions = $this->__mergeConditions(
|
$conditions = $this->_mergeConditions(
|
||||||
$assocData['conditions'],
|
$assocData['conditions'],
|
||||||
$this->getConstraint($type, $model, $linkModel, $association, array_merge($assocData, compact('external', 'self')))
|
$this->getConstraint($type, $model, $linkModel, $association, array_merge($assocData, compact('external', 'self')))
|
||||||
);
|
);
|
||||||
|
@ -1566,7 +1547,7 @@ class DboSource extends DataSource {
|
||||||
$assocData['fields'] = array_merge($assocData['fields'], $this->fields($linkModel, $association, array("{$association}.{$assocData['foreignKey']}")));
|
$assocData['fields'] = array_merge($assocData['fields'], $this->fields($linkModel, $association, array("{$association}.{$assocData['foreignKey']}")));
|
||||||
}
|
}
|
||||||
$query = array(
|
$query = array(
|
||||||
'conditions' => $this->__mergeConditions($this->getConstraint('hasMany', $model, $linkModel, $association, $assocData), $assocData['conditions']),
|
'conditions' => $this->_mergeConditions($this->getConstraint('hasMany', $model, $linkModel, $association, $assocData), $assocData['conditions']),
|
||||||
'fields' => array_unique($assocData['fields']),
|
'fields' => array_unique($assocData['fields']),
|
||||||
'table' => $this->fullTableName($linkModel),
|
'table' => $this->fullTableName($linkModel),
|
||||||
'alias' => $association,
|
'alias' => $association,
|
||||||
|
@ -1622,8 +1603,11 @@ class DboSource extends DataSource {
|
||||||
* Returns a conditions array for the constraint between two models
|
* Returns a conditions array for the constraint between two models
|
||||||
*
|
*
|
||||||
* @param string $type Association type
|
* @param string $type Association type
|
||||||
* @param object $model Model object
|
* @param Model $model Model object
|
||||||
* @param array $association Association array
|
* @param string $linkModel
|
||||||
|
* @param string $alias
|
||||||
|
* @param array $assoc
|
||||||
|
* @param string $alias2
|
||||||
* @return array Conditions array defining the constraint between $model and $association
|
* @return array Conditions array defining the constraint between $model and $association
|
||||||
*/
|
*/
|
||||||
public function getConstraint($type, $model, $linkModel, $alias, $assoc, $alias2 = null) {
|
public function getConstraint($type, $model, $linkModel, $alias, $assoc, $alias2 = null) {
|
||||||
|
@ -1658,7 +1642,6 @@ class DboSource extends DataSource {
|
||||||
*
|
*
|
||||||
* @param array $join An array defining a JOIN statement in a query
|
* @param array $join An array defining a JOIN statement in a query
|
||||||
* @return string An SQL JOIN statement to be used in a query
|
* @return string An SQL JOIN statement to be used in a query
|
||||||
* @access public
|
|
||||||
* @see DboSource::renderJoinStatement()
|
* @see DboSource::renderJoinStatement()
|
||||||
* @see DboSource::buildStatement()
|
* @see DboSource::buildStatement()
|
||||||
*/
|
*/
|
||||||
|
@ -1683,9 +1666,8 @@ class DboSource extends DataSource {
|
||||||
* Builds and generates an SQL statement from an array. Handles final clean-up before conversion.
|
* Builds and generates an SQL statement from an array. Handles final clean-up before conversion.
|
||||||
*
|
*
|
||||||
* @param array $query An array defining an SQL query
|
* @param array $query An array defining an SQL query
|
||||||
* @param object $model The model object which initiated the query
|
* @param Model $model The model object which initiated the query
|
||||||
* @return string An executable SQL statement
|
* @return string An executable SQL statement
|
||||||
* @access public
|
|
||||||
* @see DboSource::renderStatement()
|
* @see DboSource::renderStatement()
|
||||||
*/
|
*/
|
||||||
public function buildStatement($query, $model) {
|
public function buildStatement($query, $model) {
|
||||||
|
@ -1771,7 +1753,7 @@ class DboSource extends DataSource {
|
||||||
* @param mixed $assoc
|
* @param mixed $assoc
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function __mergeConditions($query, $assoc) {
|
protected function _mergeConditions($query, $assoc) {
|
||||||
if (empty($assoc)) {
|
if (empty($assoc)) {
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
@ -1803,7 +1785,7 @@ class DboSource extends DataSource {
|
||||||
* @param mixed $conditions
|
* @param mixed $conditions
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function update($model, $fields = array(), $values = null, $conditions = null) {
|
public function update(Model $model, $fields = array(), $values = null, $conditions = null) {
|
||||||
if ($values == null) {
|
if ($values == null) {
|
||||||
$combined = $fields;
|
$combined = $fields;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1880,7 +1862,7 @@ class DboSource extends DataSource {
|
||||||
* @param mixed $conditions
|
* @param mixed $conditions
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function delete($model, $conditions = null) {
|
public function delete(Model $model, $conditions = null) {
|
||||||
$alias = $joins = null;
|
$alias = $joins = null;
|
||||||
$table = $this->fullTableName($model);
|
$table = $this->fullTableName($model);
|
||||||
$conditions = $this->_matchRecords($model, $conditions);
|
$conditions = $this->_matchRecords($model, $conditions);
|
||||||
|
@ -1948,7 +1930,7 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Returns an array of SQL JOIN fragments from a model's associations
|
* Returns an array of SQL JOIN fragments from a model's associations
|
||||||
*
|
*
|
||||||
* @param object $model
|
* @param Model $model
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function _getJoins($model) {
|
protected function _getJoins($model) {
|
||||||
|
@ -1963,7 +1945,7 @@ class DboSource extends DataSource {
|
||||||
'alias' => $assoc,
|
'alias' => $assoc,
|
||||||
'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT',
|
'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT',
|
||||||
'conditions' => trim($this->conditions(
|
'conditions' => trim($this->conditions(
|
||||||
$this->__mergeConditions($assocData['conditions'], $this->getConstraint($assocData['association'], $model, $model->{$assoc}, $assoc, $assocData)),
|
$this->_mergeConditions($assocData['conditions'], $this->getConstraint($assocData['association'], $model, $model->{$assoc}, $assoc, $assocData)),
|
||||||
true, false, $model
|
true, false, $model
|
||||||
))
|
))
|
||||||
));
|
));
|
||||||
|
@ -1975,7 +1957,7 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Returns an SQL calculation, i.e. COUNT() or MAX()
|
* Returns an SQL calculation, i.e. COUNT() or MAX()
|
||||||
*
|
*
|
||||||
* @param model $model
|
* @param Model $model
|
||||||
* @param string $func Lowercase name of SQL function, i.e. 'count' or 'max'
|
* @param string $func Lowercase name of SQL function, i.e. 'count' or 'max'
|
||||||
* @param array $params Function parameters (any values must be quoted manually)
|
* @param array $params Function parameters (any values must be quoted manually)
|
||||||
* @return string An SQL calculation function
|
* @return string An SQL calculation function
|
||||||
|
@ -1992,7 +1974,7 @@ class DboSource extends DataSource {
|
||||||
$params[1] = 'count';
|
$params[1] = 'count';
|
||||||
}
|
}
|
||||||
if (is_object($model) && $model->isVirtualField($params[0])){
|
if (is_object($model) && $model->isVirtualField($params[0])){
|
||||||
$arg = $this->__quoteFields($model->getVirtualField($params[0]));
|
$arg = $this->_quoteFields($model->getVirtualField($params[0]));
|
||||||
} else {
|
} else {
|
||||||
$arg = $this->name($params[0]);
|
$arg = $this->name($params[0]);
|
||||||
}
|
}
|
||||||
|
@ -2003,7 +1985,7 @@ class DboSource extends DataSource {
|
||||||
$params[1] = $params[0];
|
$params[1] = $params[0];
|
||||||
}
|
}
|
||||||
if (is_object($model) && $model->isVirtualField($params[0])) {
|
if (is_object($model) && $model->isVirtualField($params[0])) {
|
||||||
$arg = $this->__quoteFields($model->getVirtualField($params[0]));
|
$arg = $this->_quoteFields($model->getVirtualField($params[0]));
|
||||||
} else {
|
} else {
|
||||||
$arg = $this->name($params[0]);
|
$arg = $this->name($params[0]);
|
||||||
}
|
}
|
||||||
|
@ -2078,8 +2060,8 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Returns the ID generated from the previous INSERT operation.
|
* Returns the ID generated from the previous INSERT operation.
|
||||||
*
|
*
|
||||||
* @param unknown_type $source
|
* @param mixed $source
|
||||||
* @return in
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function lastInsertId($source = null) {
|
public function lastInsertId($source = null) {
|
||||||
return $this->_connection->lastInsertId();
|
return $this->_connection->lastInsertId();
|
||||||
|
@ -2090,7 +2072,7 @@ class DboSource extends DataSource {
|
||||||
* If conditions are supplied then they will be returned. If a model doesn't exist and no conditions
|
* If conditions are supplied then they will be returned. If a model doesn't exist and no conditions
|
||||||
* were provided either null or false will be returned based on what was input.
|
* were provided either null or false will be returned based on what was input.
|
||||||
*
|
*
|
||||||
* @param object $model
|
* @param Model $model
|
||||||
* @param mixed $conditions Array of conditions, conditions string, null or false. If an array of conditions,
|
* @param mixed $conditions Array of conditions, conditions string, null or false. If an array of conditions,
|
||||||
* or string conditions those conditions will be returned. With other values the model's existance will be checked.
|
* or string conditions those conditions will be returned. With other values the model's existance will be checked.
|
||||||
* If the model doesn't exist a null or false will be returned depending on the input value.
|
* If the model doesn't exist a null or false will be returned depending on the input value.
|
||||||
|
@ -2120,12 +2102,12 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Returns a key formatted like a string Model.fieldname(i.e. Post.title, or Country.name)
|
* Returns a key formatted like a string Model.fieldname(i.e. Post.title, or Country.name)
|
||||||
*
|
*
|
||||||
* @param unknown_type $model
|
* @param Model $model
|
||||||
* @param unknown_type $key
|
* @param string $key
|
||||||
* @param unknown_type $assoc
|
* @param string $assoc
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function resolveKey($model, $key, $assoc = null) {
|
public function resolveKey(Model $model, $key, $assoc = null) {
|
||||||
if (empty($assoc)) {
|
if (empty($assoc)) {
|
||||||
$assoc = $model->alias;
|
$assoc = $model->alias;
|
||||||
}
|
}
|
||||||
|
@ -2141,7 +2123,7 @@ class DboSource extends DataSource {
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function __scrubQueryData($data) {
|
protected function _scrubQueryData($data) {
|
||||||
static $base = null;
|
static $base = null;
|
||||||
if ($base === null) {
|
if ($base === null) {
|
||||||
$base = array_fill_keys(array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'), array());
|
$base = array_fill_keys(array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'), array());
|
||||||
|
@ -2161,7 +2143,7 @@ class DboSource extends DataSource {
|
||||||
$virtual = array();
|
$virtual = array();
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$virtualField = $this->name($alias . $this->virtualFieldSeparator . $field);
|
$virtualField = $this->name($alias . $this->virtualFieldSeparator . $field);
|
||||||
$expression = $this->__quoteFields($model->getVirtualField($field));
|
$expression = $this->_quoteFields($model->getVirtualField($field));
|
||||||
$virtual[] = '(' . $expression . ") {$this->alias} {$virtualField}";
|
$virtual[] = '(' . $expression . ") {$this->alias} {$virtualField}";
|
||||||
}
|
}
|
||||||
return $virtual;
|
return $virtual;
|
||||||
|
@ -2324,7 +2306,7 @@ class DboSource extends DataSource {
|
||||||
if (preg_match($clauses, $conditions, $match)) {
|
if (preg_match($clauses, $conditions, $match)) {
|
||||||
$clause = '';
|
$clause = '';
|
||||||
}
|
}
|
||||||
$conditions = $this->__quoteFields($conditions);
|
$conditions = $this->_quoteFields($conditions);
|
||||||
return $clause . $conditions;
|
return $clause . $conditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2355,7 +2337,7 @@ class DboSource extends DataSource {
|
||||||
if (is_numeric($key) && empty($value)) {
|
if (is_numeric($key) && empty($value)) {
|
||||||
continue;
|
continue;
|
||||||
} elseif (is_numeric($key) && is_string($value)) {
|
} elseif (is_numeric($key) && is_string($value)) {
|
||||||
$out[] = $not . $this->__quoteFields($value);
|
$out[] = $not . $this->_quoteFields($value);
|
||||||
} elseif ((is_numeric($key) && is_array($value)) || in_array(strtolower(trim($key)), $bool)) {
|
} elseif ((is_numeric($key) && is_array($value)) || in_array(strtolower(trim($key)), $bool)) {
|
||||||
if (in_array(strtolower(trim($key)), $bool)) {
|
if (in_array(strtolower(trim($key)), $bool)) {
|
||||||
$join = ' ' . strtoupper($key) . ' ';
|
$join = ' ' . strtoupper($key) . ' ';
|
||||||
|
@ -2396,9 +2378,9 @@ class DboSource extends DataSource {
|
||||||
if ($keys === array_values($keys)) {
|
if ($keys === array_values($keys)) {
|
||||||
$count = count($value);
|
$count = count($value);
|
||||||
if ($count === 1) {
|
if ($count === 1) {
|
||||||
$data = $this->__quoteFields($key) . ' = (';
|
$data = $this->_quoteFields($key) . ' = (';
|
||||||
} else {
|
} else {
|
||||||
$data = $this->__quoteFields($key) . ' IN (';
|
$data = $this->_quoteFields($key) . ' IN (';
|
||||||
}
|
}
|
||||||
if ($quoteValues) {
|
if ($quoteValues) {
|
||||||
if (is_object($model)) {
|
if (is_object($model)) {
|
||||||
|
@ -2416,9 +2398,9 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (is_numeric($key) && !empty($value)) {
|
} elseif (is_numeric($key) && !empty($value)) {
|
||||||
$data = $this->__quoteFields($value);
|
$data = $this->_quoteFields($value);
|
||||||
} else {
|
} else {
|
||||||
$data = $this->__parseKey($model, trim($key), $value);
|
$data = $this->_parseKey($model, trim($key), $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($data != null) {
|
if ($data != null) {
|
||||||
|
@ -2438,10 +2420,9 @@ class DboSource extends DataSource {
|
||||||
* @param string $key An SQL key snippet containing a field and optional SQL operator
|
* @param string $key An SQL key snippet containing a field and optional SQL operator
|
||||||
* @param mixed $value The value(s) to be inserted in the string
|
* @param mixed $value The value(s) to be inserted in the string
|
||||||
* @return string
|
* @return string
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private function __parseKey($model, $key, $value) {
|
protected function _parseKey($model, $key, $value) {
|
||||||
$operatorMatch = '/^((' . implode(')|(', $this->__sqlOps);
|
$operatorMatch = '/^((' . implode(')|(', $this->_sqlOps);
|
||||||
$operatorMatch .= '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is';
|
$operatorMatch .= '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is';
|
||||||
$bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false));
|
$bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false));
|
||||||
|
|
||||||
|
@ -2460,7 +2441,7 @@ class DboSource extends DataSource {
|
||||||
|
|
||||||
$virtual = false;
|
$virtual = false;
|
||||||
if (is_object($model) && $model->isVirtualField($key)) {
|
if (is_object($model) && $model->isVirtualField($key)) {
|
||||||
$key = $this->__quoteFields($model->getVirtualField($key));
|
$key = $this->_quoteFields($model->getVirtualField($key));
|
||||||
$virtual = true;
|
$virtual = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2478,7 +2459,7 @@ class DboSource extends DataSource {
|
||||||
|
|
||||||
if (!$virtual && $key !== '?') {
|
if (!$virtual && $key !== '?') {
|
||||||
$isKey = (strpos($key, '(') !== false || strpos($key, ')') !== false);
|
$isKey = (strpos($key, '(') !== false || strpos($key, ')') !== false);
|
||||||
$key = $isKey ? $this->__quoteFields($key) : $this->name($key);
|
$key = $isKey ? $this->_quoteFields($key) : $this->name($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bound) {
|
if ($bound) {
|
||||||
|
@ -2525,9 +2506,8 @@ class DboSource extends DataSource {
|
||||||
*
|
*
|
||||||
* @param string $conditions
|
* @param string $conditions
|
||||||
* @return string or false if no match
|
* @return string or false if no match
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private function __quoteFields($conditions) {
|
protected function _quoteFields($conditions) {
|
||||||
$start = $end = null;
|
$start = $end = null;
|
||||||
$original = $conditions;
|
$original = $conditions;
|
||||||
|
|
||||||
|
@ -2538,7 +2518,7 @@ class DboSource extends DataSource {
|
||||||
$end = preg_quote($this->endQuote);
|
$end = preg_quote($this->endQuote);
|
||||||
}
|
}
|
||||||
$conditions = str_replace(array($start, $end), '', $conditions);
|
$conditions = str_replace(array($start, $end), '', $conditions);
|
||||||
$conditions = preg_replace_callback('/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9_' . $start . $end . ']*\\.[a-z0-9_' . $start . $end . ']*)/i', array(&$this, '__quoteMatchedField'), $conditions);
|
$conditions = preg_replace_callback('/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9_' . $start . $end . ']*\\.[a-z0-9_' . $start . $end . ']*)/i', array(&$this, '_quoteMatchedField'), $conditions);
|
||||||
|
|
||||||
if ($conditions !== null) {
|
if ($conditions !== null) {
|
||||||
return $conditions;
|
return $conditions;
|
||||||
|
@ -2549,11 +2529,10 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Auxiliary function to quote matches `Model.fields` from a preg_replace_callback call
|
* Auxiliary function to quote matches `Model.fields` from a preg_replace_callback call
|
||||||
*
|
*
|
||||||
* @param string matched string
|
* @param string $match matched string
|
||||||
* @return string quoted strig
|
* @return string quoted strig
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
private function __quoteMatchedField($match) {
|
protected function _quoteMatchedField($match) {
|
||||||
if (is_numeric($match[0])) {
|
if (is_numeric($match[0])) {
|
||||||
return $match[0];
|
return $match[0];
|
||||||
}
|
}
|
||||||
|
@ -2587,9 +2566,9 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Returns an ORDER BY clause as a string.
|
* Returns an ORDER BY clause as a string.
|
||||||
*
|
*
|
||||||
* @param string $key Field reference, as a key (i.e. Post.title)
|
* @param array|string $keys Field reference, as a key (i.e. Post.title)
|
||||||
* @param string $direction Direction (ASC or DESC)
|
* @param string $direction Direction (ASC or DESC)
|
||||||
* @param object $model model reference (used to look for virtual field)
|
* @param Model $model model reference (used to look for virtual field)
|
||||||
* @return string ORDER BY clause
|
* @return string ORDER BY clause
|
||||||
*/
|
*/
|
||||||
public function order($keys, $direction = 'ASC', $model = null) {
|
public function order($keys, $direction = 'ASC', $model = null) {
|
||||||
|
@ -2634,11 +2613,11 @@ class DboSource extends DataSource {
|
||||||
$key = trim($key);
|
$key = trim($key);
|
||||||
|
|
||||||
if (is_object($model) && $model->isVirtualField($key)) {
|
if (is_object($model) && $model->isVirtualField($key)) {
|
||||||
$key = '(' . $this->__quoteFields($model->getVirtualField($key)) . ')';
|
$key = '(' . $this->_quoteFields($model->getVirtualField($key)) . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($key, '.')) {
|
if (strpos($key, '.')) {
|
||||||
$key = preg_replace_callback('/([a-zA-Z0-9_-]{1,})\\.([a-zA-Z0-9_-]{1,})/', array(&$this, '__quoteMatchedField'), $key);
|
$key = preg_replace_callback('/([a-zA-Z0-9_-]{1,})\\.([a-zA-Z0-9_-]{1,})/', array(&$this, '_quoteMatchedField'), $key);
|
||||||
}
|
}
|
||||||
if (!preg_match('/\s/', $key) && strpos($key, '.') === false) {
|
if (!preg_match('/\s/', $key) && strpos($key, '.') === false) {
|
||||||
$key = $this->name($key);
|
$key = $this->name($key);
|
||||||
|
@ -2656,7 +2635,8 @@ class DboSource extends DataSource {
|
||||||
* Create a GROUP BY SQL clause
|
* Create a GROUP BY SQL clause
|
||||||
*
|
*
|
||||||
* @param string $group Group By Condition
|
* @param string $group Group By Condition
|
||||||
* @return mixed string condition or null
|
* @param Model $model
|
||||||
|
* @return string string condition or null
|
||||||
*/
|
*/
|
||||||
public function group($group, $model = null) {
|
public function group($group, $model = null) {
|
||||||
if ($group) {
|
if ($group) {
|
||||||
|
@ -2669,7 +2649,7 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$group = implode(', ', $group);
|
$group = implode(', ', $group);
|
||||||
return ' GROUP BY ' . $this->__quoteFields($group);
|
return ' GROUP BY ' . $this->_quoteFields($group);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -2686,7 +2666,7 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Checks if the specified table contains any record matching specified SQL
|
* Checks if the specified table contains any record matching specified SQL
|
||||||
*
|
*
|
||||||
* @param Model $model Model to search
|
* @param Model $Model Model to search
|
||||||
* @param string $sql SQL WHERE clause (condition only, not the "WHERE" part)
|
* @param string $sql SQL WHERE clause (condition only, not the "WHERE" part)
|
||||||
* @return boolean True if the table has a matching record, else false
|
* @return boolean True if the table has a matching record, else false
|
||||||
*/
|
*/
|
||||||
|
@ -2769,7 +2749,8 @@ class DboSource extends DataSource {
|
||||||
* Translates between PHP boolean values and Database (faked) boolean values
|
* Translates between PHP boolean values and Database (faked) boolean values
|
||||||
*
|
*
|
||||||
* @param mixed $data Value to be translated
|
* @param mixed $data Value to be translated
|
||||||
* @return int Converted boolean value
|
* @param boolean $quote
|
||||||
|
* @return string|boolean Converted boolean value
|
||||||
*/
|
*/
|
||||||
public function boolean($data, $quote = false) {
|
public function boolean($data, $quote = false) {
|
||||||
if ($quote) {
|
if ($quote) {
|
||||||
|
@ -2784,6 +2765,7 @@ class DboSource extends DataSource {
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* @param string $fields
|
* @param string $fields
|
||||||
* @param array $values
|
* @param array $values
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function insertMulti($table, $fields, $values) {
|
public function insertMulti($table, $fields, $values) {
|
||||||
$table = $this->fullTableName($table);
|
$table = $this->fullTableName($table);
|
||||||
|
@ -2814,7 +2796,7 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Generate a database-native schema for the given Schema object
|
* Generate a database-native schema for the given Schema object
|
||||||
*
|
*
|
||||||
* @param object $schema An instance of a subclass of CakeSchema
|
* @param Model $schema An instance of a subclass of CakeSchema
|
||||||
* @param string $tableName Optional. If specified only the table name given will be generated.
|
* @param string $tableName Optional. If specified only the table name given will be generated.
|
||||||
* Otherwise, all tables defined in the schema are generated.
|
* Otherwise, all tables defined in the schema are generated.
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -2865,7 +2847,8 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Generate a alter syntax from CakeSchema::compare()
|
* Generate a alter syntax from CakeSchema::compare()
|
||||||
*
|
*
|
||||||
* @param unknown_type $schema
|
* @param mixed $compare
|
||||||
|
* @param string $table
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function alterSchema($compare, $table = null) {
|
public function alterSchema($compare, $table = null) {
|
||||||
|
@ -3011,8 +2994,7 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Read additional table parameters
|
* Read additional table parameters
|
||||||
*
|
*
|
||||||
* @param array $parameters
|
* @param string $name
|
||||||
* @param string $table
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function readTableParameters($name) {
|
public function readTableParameters($name) {
|
||||||
|
@ -3137,7 +3119,6 @@ class DboSource extends DataSource {
|
||||||
/**
|
/**
|
||||||
* Used for storing in cache the results of the in-memory methodCache
|
* Used for storing in cache the results of the in-memory methodCache
|
||||||
*
|
*
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
if ($this->_methodCacheChange) {
|
if ($this->_methodCacheChange) {
|
||||||
|
|
|
@ -30,7 +30,6 @@ class CacheSession implements CakeSessionHandlerInterface {
|
||||||
* Method called on open of a database session.
|
* Method called on open of a database session.
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function open() {
|
public function open() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -40,7 +39,6 @@ class CacheSession implements CakeSessionHandlerInterface {
|
||||||
* Method called on close of a database session.
|
* Method called on close of a database session.
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function close() {
|
public function close() {
|
||||||
$probability = mt_rand(1, 150);
|
$probability = mt_rand(1, 150);
|
||||||
|
@ -55,7 +53,6 @@ class CacheSession implements CakeSessionHandlerInterface {
|
||||||
*
|
*
|
||||||
* @param mixed $id The key of the value to read
|
* @param mixed $id The key of the value to read
|
||||||
* @return mixed The value of the key or false if it does not exist
|
* @return mixed The value of the key or false if it does not exist
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function read($id) {
|
public function read($id) {
|
||||||
return Cache::read($id, Configure::read('Session.handler.config'));
|
return Cache::read($id, Configure::read('Session.handler.config'));
|
||||||
|
@ -67,7 +64,6 @@ class CacheSession implements CakeSessionHandlerInterface {
|
||||||
* @param integer $id ID that uniquely identifies session in database
|
* @param integer $id ID that uniquely identifies session in database
|
||||||
* @param mixed $data The value of the data to be saved.
|
* @param mixed $data The value of the data to be saved.
|
||||||
* @return boolean True for successful write, false otherwise.
|
* @return boolean True for successful write, false otherwise.
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function write($id, $data) {
|
public function write($id, $data) {
|
||||||
return Cache::write($id, $data, Configure::read('Session.handler.config'));
|
return Cache::write($id, $data, Configure::read('Session.handler.config'));
|
||||||
|
@ -78,7 +74,6 @@ class CacheSession implements CakeSessionHandlerInterface {
|
||||||
*
|
*
|
||||||
* @param integer $id ID that uniquely identifies session in database
|
* @param integer $id ID that uniquely identifies session in database
|
||||||
* @return boolean True for successful delete, false otherwise.
|
* @return boolean True for successful delete, false otherwise.
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function destroy($id) {
|
public function destroy($id) {
|
||||||
return Cache::delete($id, Configure::read('Session.handler.config'));
|
return Cache::delete($id, Configure::read('Session.handler.config'));
|
||||||
|
@ -89,7 +84,6 @@ class CacheSession implements CakeSessionHandlerInterface {
|
||||||
*
|
*
|
||||||
* @param integer $expires Timestamp (defaults to current time)
|
* @param integer $expires Timestamp (defaults to current time)
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function gc($expires = null) {
|
public function gc($expires = null) {
|
||||||
return Cache::gc();
|
return Cache::gc();
|
||||||
|
|
|
@ -27,7 +27,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
||||||
* Constructor. Looks at Session configuration information and
|
* Constructor. Looks at Session configuration information and
|
||||||
* sets up the session model.
|
* sets up the session model.
|
||||||
*
|
*
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$modelName = Configure::read('Session.handler.model');
|
$modelName = Configure::read('Session.handler.model');
|
||||||
|
@ -51,7 +50,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
||||||
* Method called on open of a database session.
|
* Method called on open of a database session.
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function open() {
|
public function open() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -61,7 +59,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
||||||
* Method called on close of a database session.
|
* Method called on close of a database session.
|
||||||
*
|
*
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function close() {
|
public function close() {
|
||||||
$probability = mt_rand(1, 150);
|
$probability = mt_rand(1, 150);
|
||||||
|
@ -76,7 +73,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
||||||
*
|
*
|
||||||
* @param mixed $id The key of the value to read
|
* @param mixed $id The key of the value to read
|
||||||
* @return mixed The value of the key or false if it does not exist
|
* @return mixed The value of the key or false if it does not exist
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function read($id) {
|
public function read($id) {
|
||||||
$model = ClassRegistry::getObject('Session');
|
$model = ClassRegistry::getObject('Session');
|
||||||
|
@ -98,7 +94,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
||||||
* @param integer $id ID that uniquely identifies session in database
|
* @param integer $id ID that uniquely identifies session in database
|
||||||
* @param mixed $data The value of the data to be saved.
|
* @param mixed $data The value of the data to be saved.
|
||||||
* @return boolean True for successful write, false otherwise.
|
* @return boolean True for successful write, false otherwise.
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function write($id, $data) {
|
public function write($id, $data) {
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
|
@ -116,7 +111,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
||||||
*
|
*
|
||||||
* @param integer $id ID that uniquely identifies session in database
|
* @param integer $id ID that uniquely identifies session in database
|
||||||
* @return boolean True for successful delete, false otherwise.
|
* @return boolean True for successful delete, false otherwise.
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function destroy($id) {
|
public function destroy($id) {
|
||||||
return ClassRegistry::getObject('Session')->delete($id);
|
return ClassRegistry::getObject('Session')->delete($id);
|
||||||
|
@ -127,7 +121,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
||||||
*
|
*
|
||||||
* @param integer $expires Timestamp (defaults to current time)
|
* @param integer $expires Timestamp (defaults to current time)
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function gc($expires = null) {
|
public function gc($expires = null) {
|
||||||
if (!$expires) {
|
if (!$expires) {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -47,7 +47,7 @@
|
||||||
* than a normal behavior mixin method.
|
* than a normal behavior mixin method.
|
||||||
*
|
*
|
||||||
* {{{
|
* {{{
|
||||||
* var $mapMethods = array('/do(\w+)/' => 'doSomething');
|
* public $mapMethods = array('/do(\w+)/' => 'doSomething');
|
||||||
*
|
*
|
||||||
* function doSomething($model, $method, $arg1, $arg2) {
|
* function doSomething($model, $method, $arg1, $arg2) {
|
||||||
* //do something
|
* //do something
|
||||||
|
@ -88,8 +88,9 @@ class ModelBehavior extends Object {
|
||||||
/**
|
/**
|
||||||
* Setup this behavior with the specified configuration settings.
|
* Setup this behavior with the specified configuration settings.
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @param array $config Configuration settings for $model
|
* @param array $config Configuration settings for $model
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setup($model, $config = array()) { }
|
public function setup($model, $config = array()) { }
|
||||||
|
|
||||||
|
@ -97,7 +98,8 @@ class ModelBehavior extends Object {
|
||||||
* Clean up any initialization this behavior has done on a model. Called when a behavior is dynamically
|
* Clean up any initialization this behavior has done on a model. Called when a behavior is dynamically
|
||||||
* detached from a model using Model::detach().
|
* detached from a model using Model::detach().
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
|
* @return void
|
||||||
* @see BehaviorCollection::detach()
|
* @see BehaviorCollection::detach()
|
||||||
*/
|
*/
|
||||||
public function cleanup($model) {
|
public function cleanup($model) {
|
||||||
|
@ -111,9 +113,9 @@ class ModelBehavior extends Object {
|
||||||
* By returning null/false you can abort a find. By returning an array you can modify/replace the query
|
* By returning null/false you can abort a find. By returning an array you can modify/replace the query
|
||||||
* that is going to be run.
|
* that is going to be run.
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @param array $queryData Data used to execute this query, i.e. conditions, order, etc.
|
* @param array $query Data used to execute this query, i.e. conditions, order, etc.
|
||||||
* @return mixed False or null will abort the operation. You can return an array to replace the
|
* @return boolean|array False or null will abort the operation. You can return an array to replace the
|
||||||
* $query that will be eventually run.
|
* $query that will be eventually run.
|
||||||
*/
|
*/
|
||||||
public function beforeFind($model, $query) {
|
public function beforeFind($model, $query) {
|
||||||
|
@ -123,7 +125,7 @@ class ModelBehavior extends Object {
|
||||||
/**
|
/**
|
||||||
* After find callback. Can be used to modify any results returned by find.
|
* After find callback. Can be used to modify any results returned by find.
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @param mixed $results The results of the find operation
|
* @param mixed $results The results of the find operation
|
||||||
* @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
|
* @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
|
||||||
* @return mixed An array value will replace the value of $results - any other value will be ignored.
|
* @return mixed An array value will replace the value of $results - any other value will be ignored.
|
||||||
|
@ -135,9 +137,8 @@ class ModelBehavior extends Object {
|
||||||
* add behavior validation rules into a models validate array. Returning false
|
* add behavior validation rules into a models validate array. Returning false
|
||||||
* will allow you to make the validation fail.
|
* will allow you to make the validation fail.
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @return mixed False or null will abort the operation. Any other result will continue.
|
* @return mixed False or null will abort the operation. Any other result will continue.
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function beforeValidate($model) {
|
public function beforeValidate($model) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -147,7 +148,7 @@ class ModelBehavior extends Object {
|
||||||
* beforeSave is called before a model is saved. Returning false from a beforeSave callback
|
* beforeSave is called before a model is saved. Returning false from a beforeSave callback
|
||||||
* will abort the save operation.
|
* will abort the save operation.
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @return mixed False if the operation should abort. Any other result will continue.
|
* @return mixed False if the operation should abort. Any other result will continue.
|
||||||
*/
|
*/
|
||||||
public function beforeSave($model) {
|
public function beforeSave($model) {
|
||||||
|
@ -157,8 +158,9 @@ class ModelBehavior extends Object {
|
||||||
/**
|
/**
|
||||||
* afterSave is called after a model is saved.
|
* afterSave is called after a model is saved.
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @param boolean $created True if this save created a new record
|
* @param boolean $created True if this save created a new record
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function afterSave($model, $created) {
|
public function afterSave($model, $created) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -168,10 +170,9 @@ class ModelBehavior extends Object {
|
||||||
* Before delete is called before any delete occurs on the attached model, but after the model's
|
* Before delete is called before any delete occurs on the attached model, but after the model's
|
||||||
* beforeDelete is called. Returning false from a beforeDelete will abort the delete.
|
* beforeDelete is called. Returning false from a beforeDelete will abort the delete.
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @param boolean $cascade If true records that depend on this record will also be deleted
|
* @param boolean $cascade If true records that depend on this record will also be deleted
|
||||||
* @return mixed False if the operation should abort. Any other result will continue.
|
* @return mixed False if the operation should abort. Any other result will continue.
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public function beforeDelete($model, $cascade = true) {
|
public function beforeDelete($model, $cascade = true) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -180,15 +181,17 @@ class ModelBehavior extends Object {
|
||||||
/**
|
/**
|
||||||
* After delete is called after any delete occurs on the attached model.
|
* After delete is called after any delete occurs on the attached model.
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterDelete($model) { }
|
public function afterDelete($model) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DataSource error callback
|
* DataSource error callback
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @param string $error Error generated in DataSource
|
* @param string $error Error generated in DataSource
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function onError($model, $error) { }
|
public function onError($model, $error) { }
|
||||||
|
|
||||||
|
@ -198,7 +201,7 @@ class ModelBehavior extends Object {
|
||||||
* that it only modifies the whitelist for the current save operation. Also make sure
|
* that it only modifies the whitelist for the current save operation. Also make sure
|
||||||
* you explicitly set the value of the field which you are allowing.
|
* you explicitly set the value of the field which you are allowing.
|
||||||
*
|
*
|
||||||
* @param object $model Model using this behavior
|
* @param Model $model Model using this behavior
|
||||||
* @param string $field Field to be added to $model's whitelist
|
* @param string $field Field to be added to $model's whitelist
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -34,7 +34,6 @@ class Permission extends AppModel {
|
||||||
* Model name
|
* Model name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $name = 'Permission';
|
public $name = 'Permission';
|
||||||
|
|
||||||
|
@ -42,7 +41,6 @@ class Permission extends AppModel {
|
||||||
* Explicitly disable in-memory query caching
|
* Explicitly disable in-memory query caching
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $cacheQueries = false;
|
public $cacheQueries = false;
|
||||||
|
|
||||||
|
@ -50,7 +48,6 @@ class Permission extends AppModel {
|
||||||
* Override default table name
|
* Override default table name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $useTable = 'aros_acos';
|
public $useTable = 'aros_acos';
|
||||||
|
|
||||||
|
@ -58,7 +55,6 @@ class Permission extends AppModel {
|
||||||
* Permissions link AROs with ACOs
|
* Permissions link AROs with ACOs
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $belongsTo = array('Aro', 'Aco');
|
public $belongsTo = array('Aro', 'Aco');
|
||||||
|
|
||||||
|
@ -66,7 +62,6 @@ class Permission extends AppModel {
|
||||||
* No behaviors for this model
|
* No behaviors for this model
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $actsAs = null;
|
public $actsAs = null;
|
||||||
|
|
||||||
|
|
|
@ -113,14 +113,13 @@ class CakeRequest implements ArrayAccess {
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $__input = '';
|
protected $_input = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param string $url Trimmed url string to use. Should not contain the application base path.
|
* @param string $url Trimmed url string to use. Should not contain the application base path.
|
||||||
* @param boolean $parseEnvironment Set to false to not auto parse the environment. ie. GET, POST and FILES.
|
* @param boolean $parseEnvironment Set to false to not auto parse the environment. ie. GET, POST and FILES.
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct($url = null, $parseEnvironment = true) {
|
public function __construct($url = null, $parseEnvironment = true) {
|
||||||
$this->_base();
|
$this->_base();
|
||||||
|
@ -384,7 +383,7 @@ class CakeRequest implements ArrayAccess {
|
||||||
* @param string $name The method called
|
* @param string $name The method called
|
||||||
* @param array $params Array of parameters for the method call
|
* @param array $params Array of parameters for the method call
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws BadMethodCallException when an invalid method is called.
|
* @throws CakeException when an invalid method is called.
|
||||||
*/
|
*/
|
||||||
public function __call($name, $params) {
|
public function __call($name, $params) {
|
||||||
if (strpos($name, 'is') === 0) {
|
if (strpos($name, 'is') === 0) {
|
||||||
|
@ -500,7 +499,7 @@ class CakeRequest implements ArrayAccess {
|
||||||
* Provides an easy way to modify, here, webroot and base.
|
* Provides an easy way to modify, here, webroot and base.
|
||||||
*
|
*
|
||||||
* @param array $paths Array of paths to merge in
|
* @param array $paths Array of paths to merge in
|
||||||
* @return the current object, you can chain this method.
|
* @return CakeRequest the current object, you can chain this method.
|
||||||
*/
|
*/
|
||||||
public function addPaths($paths) {
|
public function addPaths($paths) {
|
||||||
foreach (array('webroot', 'here', 'base') as $element) {
|
foreach (array('webroot', 'here', 'base') as $element) {
|
||||||
|
@ -571,7 +570,7 @@ class CakeRequest implements ArrayAccess {
|
||||||
/**
|
/**
|
||||||
* Get the domain name and include $tldLength segments of the tld.
|
* Get the domain name and include $tldLength segments of the tld.
|
||||||
*
|
*
|
||||||
* @param int $tldLength Number of segments your tld contains. For example: `example.com` contains 1 tld.
|
* @param integer $tldLength Number of segments your tld contains. For example: `example.com` contains 1 tld.
|
||||||
* While `example.co.uk` contains 2.
|
* While `example.co.uk` contains 2.
|
||||||
* @return string Domain name without subdomains.
|
* @return string Domain name without subdomains.
|
||||||
*/
|
*/
|
||||||
|
@ -584,7 +583,7 @@ class CakeRequest implements ArrayAccess {
|
||||||
/**
|
/**
|
||||||
* Get the subdomains for a host.
|
* Get the subdomains for a host.
|
||||||
*
|
*
|
||||||
* @param int $tldLength Number of segments your tld contains. For example: `example.com` contains 1 tld.
|
* @param integer $tldLength Number of segments your tld contains. For example: `example.com` contains 1 tld.
|
||||||
* While `example.co.uk` contains 2.
|
* While `example.co.uk` contains 2.
|
||||||
* @return array of subdomains.
|
* @return array of subdomains.
|
||||||
*/
|
*/
|
||||||
|
@ -669,8 +668,7 @@ class CakeRequest implements ArrayAccess {
|
||||||
* You can write to any value, even paths/keys that do not exist, and the arrays
|
* You can write to any value, even paths/keys that do not exist, and the arrays
|
||||||
* will be created for you.
|
* will be created for you.
|
||||||
*
|
*
|
||||||
* @param string $name Dot separated name of the value to read/write
|
* @param string $name,... Dot separated name of the value to read/write
|
||||||
* @param mixed $value Value to write to the data array.
|
|
||||||
* @return mixed Either the value being read, or this so you can chain consecutive writes.
|
* @return mixed Either the value being read, or this so you can chain consecutive writes.
|
||||||
*/
|
*/
|
||||||
public function data($name) {
|
public function data($name) {
|
||||||
|
@ -718,13 +716,13 @@ class CakeRequest implements ArrayAccess {
|
||||||
* @return string contents of stdin
|
* @return string contents of stdin
|
||||||
*/
|
*/
|
||||||
protected function _readStdin() {
|
protected function _readStdin() {
|
||||||
if (empty($this->__input)) {
|
if (empty($this->_input)) {
|
||||||
$fh = fopen('php://input', 'r');
|
$fh = fopen('php://input', 'r');
|
||||||
$content = stream_get_contents($fh);
|
$content = stream_get_contents($fh);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
$this->__input = $content;
|
$this->_input = $content;
|
||||||
}
|
}
|
||||||
return $this->__input;
|
return $this->_input;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -770,7 +768,7 @@ class CakeRequest implements ArrayAccess {
|
||||||
/**
|
/**
|
||||||
* Array access unset() implementation
|
* Array access unset() implementation
|
||||||
*
|
*
|
||||||
* @param $name Name to unset.
|
* @param string $name Name to unset.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function offsetUnset($name) {
|
public function offsetUnset($name) {
|
||||||
|
|
|
@ -317,7 +317,6 @@ class CakeResponse {
|
||||||
* - status: the HTTP status code to respond with
|
* - status: the HTTP status code to respond with
|
||||||
* - type: a complete mime-type string or an extension mapepd in this class
|
* - type: a complete mime-type string or an extension mapepd in this class
|
||||||
* - charset: the charset for the response body
|
* - charset: the charset for the response body
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct(array $options = array()) {
|
public function __construct(array $options = array()) {
|
||||||
if (isset($options['body'])) {
|
if (isset($options['body'])) {
|
||||||
|
@ -358,8 +357,8 @@ class CakeResponse {
|
||||||
/**
|
/**
|
||||||
* Sends a header to the client.
|
* Sends a header to the client.
|
||||||
*
|
*
|
||||||
* @param $name the header name
|
* @param string $name the header name
|
||||||
* @param $value the header value
|
* @param string $value the header value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _sendHeader($name, $value = null) {
|
protected function _sendHeader($name, $value = null) {
|
||||||
|
@ -375,7 +374,7 @@ class CakeResponse {
|
||||||
/**
|
/**
|
||||||
* Sends a content string to the client.
|
* Sends a content string to the client.
|
||||||
*
|
*
|
||||||
* @param $content string to send as response body
|
* @param string $content string to send as response body
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function _sendContent($content) {
|
protected function _sendContent($content) {
|
||||||
|
@ -565,7 +564,7 @@ class CakeResponse {
|
||||||
*
|
*
|
||||||
* e.g `mapType('application/pdf'); // returns 'pdf'`
|
* e.g `mapType('application/pdf'); // returns 'pdf'`
|
||||||
*
|
*
|
||||||
* @param mixed $type Either a string content type to map, or an array of types.
|
* @param mixed $ctype Either a string content type to map, or an array of types.
|
||||||
* @return mixed Aliases for the types provided.
|
* @return mixed Aliases for the types provided.
|
||||||
*/
|
*/
|
||||||
public function mapType($ctype) {
|
public function mapType($ctype) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ class CakeSocket {
|
||||||
* Object description
|
* Object description
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $description = 'Remote DataSource Network Socket Interface';
|
public $description = 'Remote DataSource Network Socket Interface';
|
||||||
|
|
||||||
|
@ -39,7 +38,6 @@ class CakeSocket {
|
||||||
* Base configuration settings for the socket connection
|
* Base configuration settings for the socket connection
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access protected
|
|
||||||
*/
|
*/
|
||||||
protected $_baseConfig = array(
|
protected $_baseConfig = array(
|
||||||
'persistent' => false,
|
'persistent' => false,
|
||||||
|
@ -53,7 +51,6 @@ class CakeSocket {
|
||||||
* Configuration settings for the socket connection
|
* Configuration settings for the socket connection
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $config = array();
|
public $config = array();
|
||||||
|
|
||||||
|
@ -61,7 +58,6 @@ class CakeSocket {
|
||||||
* Reference to socket connection resource
|
* Reference to socket connection resource
|
||||||
*
|
*
|
||||||
* @var resource
|
* @var resource
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $connection = null;
|
public $connection = null;
|
||||||
|
|
||||||
|
@ -69,7 +65,6 @@ class CakeSocket {
|
||||||
* This boolean contains the current state of the CakeSocket class
|
* This boolean contains the current state of the CakeSocket class
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $connected = false;
|
public $connected = false;
|
||||||
|
|
||||||
|
@ -77,7 +72,6 @@ class CakeSocket {
|
||||||
* This variable contains an array with the last error number (num) and string (str)
|
* This variable contains an array with the last error number (num) and string (str)
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
public $lastError = array();
|
public $lastError = array();
|
||||||
|
|
||||||
|
@ -256,7 +250,6 @@ class CakeSocket {
|
||||||
/**
|
/**
|
||||||
* Destructor, used to disconnect from current connection.
|
* Destructor, used to disconnect from current connection.
|
||||||
*
|
*
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
$this->disconnect();
|
$this->disconnect();
|
||||||
|
|
|
@ -34,7 +34,7 @@ abstract class AbstractTransport {
|
||||||
/**
|
/**
|
||||||
* Send mail
|
* Send mail
|
||||||
*
|
*
|
||||||
* @params object $email CakeEmail
|
* @param CakeEmail $email CakeEmail
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
abstract public function send(CakeEmail $email);
|
abstract public function send(CakeEmail $email);
|
||||||
|
@ -43,7 +43,7 @@ abstract class AbstractTransport {
|
||||||
* Set the config
|
* Set the config
|
||||||
*
|
*
|
||||||
* @param array $config
|
* @param array $config
|
||||||
* @return object $this
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function config($config = array()) {
|
public function config($config = array()) {
|
||||||
if (!empty($config)) {
|
if (!empty($config)) {
|
||||||
|
|
|
@ -234,7 +234,7 @@ class CakeEmail {
|
||||||
/**
|
/**
|
||||||
* Instance of transport class
|
* Instance of transport class
|
||||||
*
|
*
|
||||||
* @var object
|
* @var AbstractTransport
|
||||||
*/
|
*/
|
||||||
protected $_transportClass = null;
|
protected $_transportClass = null;
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ class CakeEmail {
|
||||||
*
|
*
|
||||||
* @param mixed $email String with email, Array with email as key, name as value or email as value (without name)
|
* @param mixed $email String with email, Array with email as key, name as value or email as value (without name)
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return object $this
|
* @return CakeEmail $this
|
||||||
*/
|
*/
|
||||||
public function addTo($email, $name = null) {
|
public function addTo($email, $name = null) {
|
||||||
return $this->_addEmail('_to', $email, $name);
|
return $this->_addEmail('_to', $email, $name);
|
||||||
|
@ -398,7 +398,7 @@ class CakeEmail {
|
||||||
*
|
*
|
||||||
* @param mixed $email String with email, Array with email as key, name as value or email as value (without name)
|
* @param mixed $email String with email, Array with email as key, name as value or email as value (without name)
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return object $this
|
* @return CakeEmail $this
|
||||||
*/
|
*/
|
||||||
public function addCc($email, $name = null) {
|
public function addCc($email, $name = null) {
|
||||||
return $this->_addEmail('_cc', $email, $name);
|
return $this->_addEmail('_cc', $email, $name);
|
||||||
|
@ -423,7 +423,7 @@ class CakeEmail {
|
||||||
*
|
*
|
||||||
* @param mixed $email String with email, Array with email as key, name as value or email as value (without name)
|
* @param mixed $email String with email, Array with email as key, name as value or email as value (without name)
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return object $this
|
* @return CakeEmail $this
|
||||||
*/
|
*/
|
||||||
public function addBcc($email, $name = null) {
|
public function addBcc($email, $name = null) {
|
||||||
return $this->_addEmail('_bcc', $email, $name);
|
return $this->_addEmail('_bcc', $email, $name);
|
||||||
|
@ -435,7 +435,7 @@ class CakeEmail {
|
||||||
* @param string $varName
|
* @param string $varName
|
||||||
* @param mixed $email
|
* @param mixed $email
|
||||||
* @param mixed $name
|
* @param mixed $name
|
||||||
* @return object $this
|
* @return CakeEmail $this
|
||||||
* @throws SocketException
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
protected function _setEmail($varName, $email, $name) {
|
protected function _setEmail($varName, $email, $name) {
|
||||||
|
@ -470,8 +470,8 @@ class CakeEmail {
|
||||||
* @param mixed $email
|
* @param mixed $email
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $throwMessage
|
* @param string $throwMessage
|
||||||
* @return object $this
|
* @return CakeEmail $this
|
||||||
* @throws SocketExpceiton
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
protected function _setEmailSingle($varName, $email, $name, $throwMessage) {
|
protected function _setEmailSingle($varName, $email, $name, $throwMessage) {
|
||||||
$current = $this->{$varName};
|
$current = $this->{$varName};
|
||||||
|
@ -489,7 +489,8 @@ class CakeEmail {
|
||||||
* @param string $varName
|
* @param string $varName
|
||||||
* @param mixed $email
|
* @param mixed $email
|
||||||
* @param mixed $name
|
* @param mixed $name
|
||||||
* @return object $this
|
* @return CakeEmail $this
|
||||||
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
protected function _addEmail($varName, $email, $name) {
|
protected function _addEmail($varName, $email, $name) {
|
||||||
if (!is_array($email)) {
|
if (!is_array($email)) {
|
||||||
|
@ -533,8 +534,8 @@ class CakeEmail {
|
||||||
/**
|
/**
|
||||||
* Sets headers for the message
|
* Sets headers for the message
|
||||||
*
|
*
|
||||||
* @param array Associative array containing headers to be set.
|
* @param array $headers Associative array containing headers to be set.
|
||||||
* @return object $this
|
* @return CakeEmail $this
|
||||||
* @throws SocketException
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
public function setHeaders($headers) {
|
public function setHeaders($headers) {
|
||||||
|
@ -773,7 +774,7 @@ class CakeEmail {
|
||||||
/**
|
/**
|
||||||
* Return the transport class
|
* Return the transport class
|
||||||
*
|
*
|
||||||
* @return object
|
* @return CakeEmail
|
||||||
* @throws SocketException
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
public function transportClass() {
|
public function transportClass() {
|
||||||
|
@ -853,7 +854,7 @@ class CakeEmail {
|
||||||
* Add attachments
|
* Add attachments
|
||||||
*
|
*
|
||||||
* @param mixed $attachments String with the filename or array with filenames
|
* @param mixed $attachments String with the filename or array with filenames
|
||||||
* @return object $this
|
* @return CakeEmail $this
|
||||||
* @throws SocketException
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
public function addAttachments($attachments) {
|
public function addAttachments($attachments) {
|
||||||
|
@ -906,6 +907,7 @@ class CakeEmail {
|
||||||
/**
|
/**
|
||||||
* Send an email using the specified content, template and layout
|
* Send an email using the specified content, template and layout
|
||||||
*
|
*
|
||||||
|
* @param string|array $content
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
* @throws SocketException
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
|
@ -985,7 +987,8 @@ class CakeEmail {
|
||||||
* @param mixed $message String with message or array with variables to be used in render
|
* @param mixed $message String with message or array with variables to be used in render
|
||||||
* @param mixed $transportConfig String to use config from EmailConfig or array with configs
|
* @param mixed $transportConfig String to use config from EmailConfig or array with configs
|
||||||
* @param boolean $send Send the email or just return the instance pre-configured
|
* @param boolean $send Send the email or just return the instance pre-configured
|
||||||
* @return object Instance of CakeEmail
|
* @return CakeEmail Instance of CakeEmail
|
||||||
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
public static function deliver($to = null, $subject = null, $message = null, $transportConfig = 'fast', $send = true) {
|
public static function deliver($to = null, $subject = null, $message = null, $transportConfig = 'fast', $send = true) {
|
||||||
$class = __CLASS__;
|
$class = __CLASS__;
|
||||||
|
@ -1026,7 +1029,7 @@ class CakeEmail {
|
||||||
/**
|
/**
|
||||||
* Apply the config to an instance
|
* Apply the config to an instance
|
||||||
*
|
*
|
||||||
* @param object $obj CakeEmail
|
* @param CakeEmail $obj CakeEmail
|
||||||
* @param array $config
|
* @param array $config
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -1061,7 +1064,7 @@ class CakeEmail {
|
||||||
/**
|
/**
|
||||||
* Reset all EmailComponent internal variables to be able to send out a new email.
|
* Reset all EmailComponent internal variables to be able to send out a new email.
|
||||||
*
|
*
|
||||||
* @return object $this
|
* @return CakeEmail $this
|
||||||
*/
|
*/
|
||||||
public function reset() {
|
public function reset() {
|
||||||
$this->_to = array();
|
$this->_to = array();
|
||||||
|
@ -1270,7 +1273,6 @@ class CakeEmail {
|
||||||
*
|
*
|
||||||
* @param string $content Content to render
|
* @param string $content Content to render
|
||||||
* @return array Email ready to be sent
|
* @return array Email ready to be sent
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
protected function _render($content) {
|
protected function _render($content) {
|
||||||
$viewClass = $this->_viewRender;
|
$viewClass = $this->_viewRender;
|
||||||
|
|
|
@ -28,7 +28,7 @@ class DebugTransport extends AbstractTransport {
|
||||||
/**
|
/**
|
||||||
* Send mail
|
* Send mail
|
||||||
*
|
*
|
||||||
* @params object $email CakeEmail
|
* @param CakeEmail $email CakeEmail
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function send(CakeEmail $email) {
|
public function send(CakeEmail $email) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ class MailTransport extends AbstractTransport {
|
||||||
/**
|
/**
|
||||||
* Send mail
|
* Send mail
|
||||||
*
|
*
|
||||||
* @params object $email CakeEmail
|
* @param CakeEmail $email CakeEmail
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function send(CakeEmail $email) {
|
public function send(CakeEmail $email) {
|
||||||
|
|
|
@ -28,21 +28,21 @@ class SmtpTransport extends AbstractTransport {
|
||||||
/**
|
/**
|
||||||
* Socket to SMTP server
|
* Socket to SMTP server
|
||||||
*
|
*
|
||||||
* @var object CakeScoket
|
* @var CakeSocket
|
||||||
*/
|
*/
|
||||||
protected $_socket;
|
protected $_socket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CakeEmail
|
* CakeEmail
|
||||||
*
|
*
|
||||||
* @var object CakeEmail
|
* @var CakeEmail
|
||||||
*/
|
*/
|
||||||
protected $_cakeEmail;
|
protected $_cakeEmail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send mail
|
* Send mail
|
||||||
*
|
*
|
||||||
* @params object $email CakeEmail
|
* @param CakeEmail $email CakeEmail
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws SocketException
|
* @throws SocketException
|
||||||
*/
|
*/
|
||||||
|
@ -62,7 +62,7 @@ class SmtpTransport extends AbstractTransport {
|
||||||
* Set the configuration
|
* Set the configuration
|
||||||
*
|
*
|
||||||
* @param array $config
|
* @param array $config
|
||||||
* @return object $this
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function config($config = array()) {
|
public function config($config = array()) {
|
||||||
$default = array(
|
$default = array(
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue