mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +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.
|
||||
*
|
||||
* @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) {
|
||||
$config = self::$_config[$name];
|
||||
|
@ -186,7 +187,7 @@ class Cache {
|
|||
* the Engine instance is also unset.
|
||||
*
|
||||
* @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) {
|
||||
if (!isset(self::$_config[$name])) {
|
||||
|
@ -456,7 +457,7 @@ class Cache {
|
|||
* Check if Cache has initialized a working config for the given name.
|
||||
*
|
||||
* @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') {
|
||||
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'
|
||||
* @return array list of settings for this engine
|
||||
* @see Cache::config()
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
public static function settings($name = 'default') {
|
||||
if (!empty(self::$_engines[$name])) {
|
||||
|
@ -492,8 +491,7 @@ abstract class CacheEngine {
|
|||
/**
|
||||
* Settings of current engine instance
|
||||
*
|
||||
* @var int
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $settings = array();
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ class FileEngine extends CacheEngine {
|
|||
/**
|
||||
* Instance of SplFileObject class
|
||||
*
|
||||
* @var _File
|
||||
* @access protected
|
||||
* @var File
|
||||
*/
|
||||
protected $_File = null;
|
||||
|
||||
|
@ -45,7 +44,6 @@ class FileEngine extends CacheEngine {
|
|||
*
|
||||
* @var array
|
||||
* @see CacheEngine::__defaults
|
||||
* @access public
|
||||
*/
|
||||
public $settings = array();
|
||||
|
||||
|
@ -53,7 +51,6 @@ class FileEngine extends CacheEngine {
|
|||
* True unless FileEngine::__active(); fails
|
||||
*
|
||||
* @var boolean
|
||||
* @access protected
|
||||
*/
|
||||
protected $_init = true;
|
||||
|
||||
|
@ -252,6 +249,8 @@ class FileEngine extends CacheEngine {
|
|||
/**
|
||||
* Not implemented
|
||||
*
|
||||
* @param string $key
|
||||
* @param integer $offset
|
||||
* @return void
|
||||
* @throws CacheException
|
||||
*/
|
||||
|
@ -262,6 +261,8 @@ class FileEngine extends CacheEngine {
|
|||
/**
|
||||
* Not implemented
|
||||
*
|
||||
* @param string $key
|
||||
* @param integer $offset
|
||||
* @return void
|
||||
* @throws CacheException
|
||||
*/
|
||||
|
@ -275,7 +276,6 @@ class FileEngine extends CacheEngine {
|
|||
* @param string $key The key
|
||||
* @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
|
||||
* @access protected
|
||||
*/
|
||||
protected function _setKey($key, $createKey = false) {
|
||||
$path = new SplFileInfo($this->settings['path'] . $key);
|
||||
|
@ -296,7 +296,6 @@ class FileEngine extends CacheEngine {
|
|||
* Determine is cache directory is writable
|
||||
*
|
||||
* @return boolean
|
||||
* @access protected
|
||||
*/
|
||||
protected function _active() {
|
||||
$dir = new SplFileInfo($this->settings['path']);
|
||||
|
|
|
@ -31,7 +31,6 @@ class MemcacheEngine extends CacheEngine {
|
|||
* Memcache wrapper.
|
||||
*
|
||||
* @var Memcache
|
||||
* @access private
|
||||
*/
|
||||
protected $_Memcache = null;
|
||||
|
||||
|
@ -43,7 +42,6 @@ class MemcacheEngine extends CacheEngine {
|
|||
* - compress = boolean, default => false
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $settings = array();
|
||||
|
||||
|
@ -96,7 +94,7 @@ class MemcacheEngine extends CacheEngine {
|
|||
* @param string $server The server address string.
|
||||
* @return array Array containing host, port
|
||||
*/
|
||||
function _parseServerString($server) {
|
||||
protected function _parseServerString($server) {
|
||||
if (substr($server, 0, 1) == '[') {
|
||||
$position = strpos($server, ']:');
|
||||
if ($position !== false) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Wincache storage engine for cache.
|
||||
* Wincache storage engine for cache.
|
||||
*
|
||||
* Supports wincache 1.1.0 and higher.
|
||||
*
|
||||
|
@ -67,7 +67,7 @@ class WincacheEngine extends CacheEngine {
|
|||
* Read a key from the cache
|
||||
*
|
||||
* @param string $key Identifier for the data
|
||||
* @return mixed The cached data, or false if the data doesn't exist, has expired, or if
|
||||
* @return mixed The cached data, or false if the data doesn't exist, has expired, or if
|
||||
* there was an error fetching it
|
||||
*/
|
||||
public function read($key) {
|
||||
|
@ -115,7 +115,6 @@ class WincacheEngine extends CacheEngine {
|
|||
* Delete all keys from the cache. This will clear every
|
||||
* item in the cache matching the cache config prefix.
|
||||
*
|
||||
*
|
||||
* @param boolean $check If true, nothing will be cleared, as entries will
|
||||
* naturally expire in wincache..
|
||||
* @return boolean True Returns true.
|
||||
|
|
|
@ -32,7 +32,6 @@ class XcacheEngine extends CacheEngine {
|
|||
* - PHP_AUTH_PW = xcache.admin.password, default cake
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $settings = array();
|
||||
|
||||
|
@ -45,7 +44,7 @@ class XcacheEngine extends CacheEngine {
|
|||
* @param array $settings array of setting for the engine
|
||||
* @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(
|
||||
'engine' => 'Xcache',
|
||||
'prefix' => Inflector::slug(APP_DIR) . '_',
|
||||
|
@ -124,15 +123,16 @@ class XcacheEngine extends CacheEngine {
|
|||
/**
|
||||
* Delete all keys from the cache
|
||||
*
|
||||
* @param boolean $check
|
||||
* @return boolean True if the cache was successfully cleared, false otherwise
|
||||
*/
|
||||
public function clear($check) {
|
||||
$this->__auth();
|
||||
$this->_auth();
|
||||
$max = xcache_count(XC_TYPE_VAR);
|
||||
for ($i = 0; $i < $max; $i++) {
|
||||
xcache_clear_cache(XC_TYPE_VAR, $i);
|
||||
}
|
||||
$this->__auth(true);
|
||||
$this->_auth(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -144,9 +144,9 @@ class XcacheEngine extends CacheEngine {
|
|||
* (see xcache.admin configuration settings)
|
||||
*
|
||||
* @param boolean $reverse Revert changes
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __auth($reverse = false) {
|
||||
protected function _auth($reverse = false) {
|
||||
static $backup = array();
|
||||
$keys = array('PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password');
|
||||
foreach ($keys as $key => $setting) {
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
* You can combine `.` separated values with sections to create more deeply
|
||||
* nested structures.
|
||||
*
|
||||
* IniReader also manipulates how the special ini values of
|
||||
* 'yes', 'no', 'on', 'off', 'null' are handled. These values will be
|
||||
* IniReader also manipulates how the special ini values of
|
||||
* 'yes', 'no', 'on', 'off', 'null' are handled. These values will be
|
||||
* converted to their boolean equivalents.
|
||||
*
|
||||
* @package Cake.Configure
|
||||
|
@ -85,6 +85,7 @@ class IniReader implements ConfigReaderInterface {
|
|||
* @param string $file Name of the file to read. The chosen file
|
||||
* must be on the reader's path.
|
||||
* @return array
|
||||
* @throws ConfigureException
|
||||
*/
|
||||
public function read($file) {
|
||||
$filename = $this->_path . $file;
|
||||
|
|
|
@ -58,6 +58,7 @@ class AclShell extends Shell {
|
|||
/**
|
||||
* Override startup of the Shell
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startup() {
|
||||
parent::startup();
|
||||
|
@ -96,6 +97,7 @@ class AclShell extends Shell {
|
|||
/**
|
||||
* Override main() for help message hook
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function main() {
|
||||
$this->out($this->OptionParser->help());
|
||||
|
@ -104,9 +106,10 @@ class AclShell extends Shell {
|
|||
/**
|
||||
* Creates an ARO/ACO node
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function create() {
|
||||
extract($this->__dataVars());
|
||||
extract($this->_dataVars());
|
||||
|
||||
$class = ucfirst($this->args[0]);
|
||||
$parent = $this->parseIdentifier($this->args[1]);
|
||||
|
@ -136,9 +139,10 @@ class AclShell extends Shell {
|
|||
/**
|
||||
* Delete an ARO/ACO node.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete() {
|
||||
extract($this->__dataVars());
|
||||
extract($this->_dataVars());
|
||||
|
||||
$identifier = $this->parseIdentifier($this->args[1]);
|
||||
$nodeId = $this->_getNodeId($class, $identifier);
|
||||
|
@ -152,9 +156,10 @@ class AclShell extends Shell {
|
|||
/**
|
||||
* Set parent for an ARO/ACO node.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setParent() {
|
||||
extract($this->__dataVars());
|
||||
extract($this->_dataVars());
|
||||
$target = $this->parseIdentifier($this->args[1]);
|
||||
$parent = $this->parseIdentifier($this->args[2]);
|
||||
|
||||
|
@ -175,9 +180,10 @@ class AclShell extends Shell {
|
|||
/**
|
||||
* Get path to specified ARO/ACO node.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getPath() {
|
||||
extract($this->__dataVars());
|
||||
extract($this->_dataVars());
|
||||
$identifier = $this->parseIdentifier($this->args[1]);
|
||||
|
||||
$id = $this->_getNodeId($class, $identifier);
|
||||
|
@ -217,9 +223,10 @@ class AclShell extends Shell {
|
|||
/**
|
||||
* Check permission for a given ARO to a given ACO.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function check() {
|
||||
extract($this->__getParams());
|
||||
extract($this->_getParams());
|
||||
|
||||
if ($this->Acl->check($aro, $aco, $action)) {
|
||||
$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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function grant() {
|
||||
extract($this->__getParams());
|
||||
extract($this->_getParams());
|
||||
|
||||
if ($this->Acl->allow($aro, $aco, $action)) {
|
||||
$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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deny() {
|
||||
extract($this->__getParams());
|
||||
extract($this->_getParams());
|
||||
|
||||
if ($this->Acl->deny($aro, $aco, $action)) {
|
||||
$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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function inherit() {
|
||||
extract($this->__getParams());
|
||||
extract($this->_getParams());
|
||||
|
||||
if ($this->Acl->inherit($aro, $aco, $action)) {
|
||||
$this->out(__d('cake_console', 'Permission inherited.'), true);
|
||||
|
@ -273,9 +283,10 @@ class AclShell extends Shell {
|
|||
/**
|
||||
* Show a specific ARO/ACO node.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function view() {
|
||||
extract($this->__dataVars());
|
||||
extract($this->_dataVars());
|
||||
|
||||
if (isset($this->args[1])) {
|
||||
$identity = $this->parseIdentifier($this->args[1]);
|
||||
|
@ -332,6 +343,7 @@ class AclShell extends Shell {
|
|||
/**
|
||||
* Initialize ACL database.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function initdb() {
|
||||
return $this->dispatchShell('schema create DbAcl');
|
||||
|
@ -493,15 +505,13 @@ class AclShell extends Shell {
|
|||
/**
|
||||
* Checks that given node exists
|
||||
*
|
||||
* @param string $type Node type (ARO/ACO)
|
||||
* @param integer $id Node id
|
||||
* @return boolean Success
|
||||
*/
|
||||
public function nodeExists() {
|
||||
if (!isset($this->args[0]) || !isset($this->args[1])) {
|
||||
return false;
|
||||
}
|
||||
extract($this->__dataVars($this->args[0]));
|
||||
extract($this->_dataVars($this->args[0]));
|
||||
$key = is_numeric($this->args[1]) ? $secondary_id : 'alias';
|
||||
$conditions = array($class . '.' . $key => $this->args[1]);
|
||||
$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 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);
|
||||
if (empty($node)) {
|
||||
if (is_array($identifier)) {
|
||||
|
@ -552,7 +562,7 @@ class AclShell extends Shell {
|
|||
*
|
||||
* @return array aro, aco, action
|
||||
*/
|
||||
function __getParams() {
|
||||
protected function _getParams() {
|
||||
$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];
|
||||
$aroName = $aro;
|
||||
|
@ -580,7 +590,7 @@ class AclShell extends Shell {
|
|||
* @param string $type Node type (ARO/ACO)
|
||||
* @return array Variables
|
||||
*/
|
||||
function __dataVars($type = null) {
|
||||
protected function _dataVars($type = null) {
|
||||
if ($type == null) {
|
||||
$type = $this->args[0];
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class ApiShell extends Shell {
|
|||
/**
|
||||
* Override initialize of the Shell
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initialize() {
|
||||
$this->paths = array_merge($this->paths, array(
|
||||
|
@ -53,6 +54,7 @@ class ApiShell extends Shell {
|
|||
/**
|
||||
* Override main() to handle action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function main() {
|
||||
if (empty($this->args)) {
|
||||
|
@ -86,7 +88,7 @@ class ApiShell extends Shell {
|
|||
$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 (isset($this->params['method'])) {
|
||||
|
@ -150,6 +152,7 @@ class ApiShell extends Shell {
|
|||
/**
|
||||
* Show help for this shell.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function help() {
|
||||
$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
|
||||
* signatures.
|
||||
*
|
||||
* @param object $File File object
|
||||
* @param string $path File path
|
||||
* @param string $class Class name
|
||||
* @return array Methods and signatures indexed by method name
|
||||
*/
|
||||
private function __parseClass($path, $class) {
|
||||
protected function _parseClass($path, $class) {
|
||||
$parsed = array();
|
||||
|
||||
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.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startup() {
|
||||
parent::startup();
|
||||
|
@ -61,6 +62,7 @@ class BakeShell extends Shell {
|
|||
/**
|
||||
* Override main() to handle action
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function main() {
|
||||
if (!is_dir($this->DbConfig->path)) {
|
||||
|
@ -124,6 +126,7 @@ class BakeShell extends Shell {
|
|||
/**
|
||||
* Quickly bake the MVC
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function all() {
|
||||
$this->out('Bake All');
|
||||
|
|
|
@ -4,14 +4,15 @@
|
|||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2011, Cake Software Foundation, Inc.
|
||||
* 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.
|
||||
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP Project
|
||||
* @package Cake.Console.Command
|
||||
* @since CakePHP v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
@ -75,7 +76,7 @@ class CommandListShell extends Shell {
|
|||
/**
|
||||
* Gets the shell command listing.
|
||||
*
|
||||
* @return array
|
||||
* @return array
|
||||
*/
|
||||
protected function _getShellList() {
|
||||
$shellList = array();
|
||||
|
@ -98,6 +99,9 @@ class CommandListShell extends Shell {
|
|||
/**
|
||||
* Scan the provided paths for shells, and append them into $shellList
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $shells
|
||||
* @param array $shellList
|
||||
* @return array
|
||||
*/
|
||||
protected function _appendShells($type, $shells, $shellList) {
|
||||
|
@ -111,6 +115,7 @@ class CommandListShell extends Shell {
|
|||
/**
|
||||
* Output text.
|
||||
*
|
||||
* @param array $shellList
|
||||
* @return void
|
||||
*/
|
||||
protected function _asText($shellList) {
|
||||
|
@ -146,6 +151,7 @@ class CommandListShell extends Shell {
|
|||
/**
|
||||
* Generates the shell list sorted by where the shells are found.
|
||||
*
|
||||
* @param array $shellList
|
||||
* @return void
|
||||
*/
|
||||
protected function _asSorted($shellList) {
|
||||
|
@ -184,6 +190,7 @@ class CommandListShell extends Shell {
|
|||
/**
|
||||
* Output as XML
|
||||
*
|
||||
* @param array $shellList
|
||||
* @return void
|
||||
*/
|
||||
protected function _asXml($shellList) {
|
||||
|
|
|
@ -47,6 +47,7 @@ class ConsoleShell extends Shell {
|
|||
/**
|
||||
* Override initialize of the Shell
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initialize() {
|
||||
App::uses('Dispatcher', 'Routing');
|
||||
|
@ -71,6 +72,7 @@ class ConsoleShell extends Shell {
|
|||
/**
|
||||
* Prints the help message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function help() {
|
||||
$out = 'Console help:';
|
||||
|
@ -133,6 +135,8 @@ class ConsoleShell extends Shell {
|
|||
/**
|
||||
* Override main() to handle action
|
||||
*
|
||||
* @param string $command
|
||||
* @return void
|
||||
*/
|
||||
public function main($command = null) {
|
||||
while (true) {
|
||||
|
|
|
@ -40,6 +40,7 @@ class I18nShell extends Shell {
|
|||
/**
|
||||
* Override startup of the Shell
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function startup() {
|
||||
$this->_welcome();
|
||||
|
@ -58,6 +59,7 @@ class I18nShell extends Shell {
|
|||
/**
|
||||
* Override main() for help message hook
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function main() {
|
||||
$this->out(__d('cake_console', '<info>I18n Shell</info>'));
|
||||
|
@ -91,6 +93,7 @@ class I18nShell extends Shell {
|
|||
/**
|
||||
* Initialize I18N database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initdb() {
|
||||
$this->dispatchShell('schema create i18n');
|
||||
|
|
|
@ -30,13 +30,6 @@ App::uses('CakeSchema', 'Model');
|
|||
*/
|
||||
class SchemaShell extends Shell {
|
||||
|
||||
/**
|
||||
* is this a dry run?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $__dry = null;
|
||||
|
||||
/**
|
||||
* Schema class being used.
|
||||
*
|
||||
|
@ -44,9 +37,17 @@ class SchemaShell extends Shell {
|
|||
*/
|
||||
public $Schema;
|
||||
|
||||
/**
|
||||
* is this a dry run?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_dry = null;
|
||||
|
||||
/**
|
||||
* Override initialize
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function initialize() {
|
||||
$this->_welcome();
|
||||
|
@ -57,6 +58,7 @@ class SchemaShell extends Shell {
|
|||
/**
|
||||
* Override startup
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function startup() {
|
||||
$name = $path = $connection = $plugin = null;
|
||||
|
@ -103,6 +105,7 @@ class SchemaShell extends Shell {
|
|||
* Read and output contents of schema object
|
||||
* path to read as second arg
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function view() {
|
||||
$File = new File($this->Schema->path . DS . $this->params['file']);
|
||||
|
@ -120,6 +123,7 @@ class SchemaShell extends Shell {
|
|||
* Read database and Write schema object
|
||||
* accepts a connection as first arg or path to save as second arg
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function generate() {
|
||||
$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
|
||||
* contains no DS, that will be used as the file name, in the same dir as the schema file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function dump() {
|
||||
$write = false;
|
||||
|
@ -245,7 +250,7 @@ class SchemaShell extends Shell {
|
|||
*/
|
||||
public function create() {
|
||||
list($Schema, $table) = $this->_loadSchema();
|
||||
$this->__create($Schema, $table);
|
||||
$this->_create($Schema, $table);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -255,7 +260,7 @@ class SchemaShell extends Shell {
|
|||
*/
|
||||
public function update() {
|
||||
list($Schema, $table) = $this->_loadSchema();
|
||||
$this->__update($Schema, $table);
|
||||
$this->_update($Schema, $table);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -263,7 +268,7 @@ class SchemaShell extends Shell {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function _loadSchema() {
|
||||
protected function _loadSchema() {
|
||||
$name = $plugin = null;
|
||||
if (!empty($this->params['name'])) {
|
||||
$name = $this->params['name'];
|
||||
|
@ -273,7 +278,7 @@ class SchemaShell extends Shell {
|
|||
}
|
||||
|
||||
if (!empty($this->params['dry'])) {
|
||||
$this->__dry = true;
|
||||
$this->_dry = true;
|
||||
$this->out(__d('cake_console', 'Performing a dry run.'));
|
||||
}
|
||||
|
||||
|
@ -300,8 +305,11 @@ class SchemaShell extends Shell {
|
|||
* Create database from Schema object
|
||||
* 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);
|
||||
|
||||
$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')) {
|
||||
$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.'));
|
||||
|
@ -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')) {
|
||||
$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.'));
|
||||
}
|
||||
|
@ -342,8 +350,11 @@ class SchemaShell extends Shell {
|
|||
* Update database with Schema object
|
||||
* 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);
|
||||
|
||||
$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')) {
|
||||
$this->out();
|
||||
$this->out(__d('cake_console', 'Updating Database...'));
|
||||
$this->__run($contents, 'update', $Schema);
|
||||
$this->_run($contents, 'update', $Schema);
|
||||
}
|
||||
|
||||
$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)) {
|
||||
$this->err(__d('cake_console', 'Sql could not be run'));
|
||||
return;
|
||||
|
@ -396,7 +411,7 @@ class SchemaShell extends Shell {
|
|||
if (empty($sql)) {
|
||||
$this->out(__d('cake_console', '%s is up to date.', $table));
|
||||
} else {
|
||||
if ($this->__dry === true) {
|
||||
if ($this->_dry === true) {
|
||||
$this->out(__d('cake_console', 'Dry run for %s :', $table));
|
||||
$this->out($sql);
|
||||
} else {
|
||||
|
|
|
@ -26,7 +26,6 @@ class BakeTask extends Shell {
|
|||
* Name of plugin
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $plugin = null;
|
||||
|
||||
|
@ -34,7 +33,6 @@ class BakeTask extends Shell {
|
|||
* The db connection being used for baking
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $connection = null;
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ class ControllerTask extends BakeTask {
|
|||
/**
|
||||
* Override initialize
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initialize() {
|
||||
$this->path = current(App::path('Controller'));
|
||||
|
@ -51,6 +52,7 @@ class ControllerTask extends BakeTask {
|
|||
/**
|
||||
* Execution method always used for tasks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute() {
|
||||
parent::execute();
|
||||
|
@ -203,6 +205,10 @@ class ControllerTask extends BakeTask {
|
|||
/**
|
||||
* Confirm a to be baked controller with the user
|
||||
*
|
||||
* @param string $controllerName
|
||||
* @param string $useDynamicScaffold
|
||||
* @param array $helpers
|
||||
* @param array $components
|
||||
* @return void
|
||||
*/
|
||||
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 array $helpers Helpers to use in controller
|
||||
* @param array $components Components to use in controller
|
||||
* @param array $uses Models to use in controller
|
||||
* @return string Baked controller
|
||||
*/
|
||||
public function bake($controllerName, $actions = '', $helpers = null, $components = null) {
|
||||
|
@ -360,7 +365,7 @@ class ControllerTask extends BakeTask {
|
|||
* Common code for property choice handling.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
protected function _doPropertyChoices($prompt, $example) {
|
||||
|
@ -378,7 +383,6 @@ class ControllerTask extends BakeTask {
|
|||
* Outputs and gets the list of possible controllers from database
|
||||
*
|
||||
* @param string $useDbConfig Database configuration name
|
||||
* @param boolean $interactive Whether you are using listAll interactively and want options output.
|
||||
* @return array Set of controllers
|
||||
*/
|
||||
public function listAll($useDbConfig = null) {
|
||||
|
@ -462,6 +466,7 @@ class ControllerTask extends BakeTask {
|
|||
/**
|
||||
* Displays help contents
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function help() {
|
||||
$this->hr();
|
||||
|
|
|
@ -60,7 +60,7 @@ class DbConfigTask extends Shell {
|
|||
/**
|
||||
* initialization callback
|
||||
*
|
||||
* @var string
|
||||
* @return void
|
||||
*/
|
||||
public function initialize() {
|
||||
$this->path = APP . 'Config' . DS;
|
||||
|
@ -69,6 +69,7 @@ class DbConfigTask extends Shell {
|
|||
/**
|
||||
* Execution method always used for tasks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute() {
|
||||
if (empty($this->args)) {
|
||||
|
@ -197,6 +198,7 @@ class DbConfigTask extends Shell {
|
|||
/**
|
||||
* Output verification message and bake if it looks good
|
||||
*
|
||||
* @param array $config
|
||||
* @return boolean True if user says it looks good, false otherwise
|
||||
*/
|
||||
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 array $rules the set of validation rules for the field
|
||||
* @param string $file the file name where this validation rule was found
|
||||
* @param string domain default domain to bind the validations to
|
||||
* @param string $domain default domain to bind the validations to
|
||||
* @return void
|
||||
*/
|
||||
protected function _processValidationRules($field, $rules, $file, $domain) {
|
||||
|
@ -438,6 +438,9 @@ class ExtractTask extends Shell {
|
|||
/**
|
||||
* Prepare a file to be stored
|
||||
*
|
||||
* @param string $domain
|
||||
* @param string $header
|
||||
* @param string $sentence
|
||||
* @return void
|
||||
*/
|
||||
protected function _store($domain, $header, $sentence) {
|
||||
|
@ -513,8 +516,8 @@ class ExtractTask extends Shell {
|
|||
/**
|
||||
* Get the strings from the position forward
|
||||
*
|
||||
* @param int $position Actual position on tokens array
|
||||
* @param int $target Number of strings to extract
|
||||
* @param integer $position Actual position on tokens array
|
||||
* @param integer $target Number of strings to extract
|
||||
* @return array Strings extracted
|
||||
*/
|
||||
protected function _getStrings(&$position, $target) {
|
||||
|
|
|
@ -43,13 +43,16 @@ class FixtureTask extends BakeTask {
|
|||
/**
|
||||
* Schema instance
|
||||
*
|
||||
* @var object
|
||||
* @var CakeSchema
|
||||
*/
|
||||
protected $_Schema = null;
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
parent::__construct($stdout, $stderr, $stdin);
|
||||
|
@ -236,7 +239,7 @@ class FixtureTask extends BakeTask {
|
|||
* Generate the fixture file, and write to disk
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public function generateFixtureFile($model, $otherVars) {
|
||||
|
@ -271,7 +274,7 @@ class FixtureTask extends BakeTask {
|
|||
/**
|
||||
* Generates a string representation of a schema.
|
||||
*
|
||||
* @param array $table Table schema array
|
||||
* @param array $tableInfo Table schema array
|
||||
* @return string fields definitions
|
||||
*/
|
||||
protected function _generateSchema($tableInfo) {
|
||||
|
@ -282,7 +285,8 @@ class FixtureTask extends BakeTask {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
protected function _generateRecords($tableInfo, $recordCount = 1) {
|
||||
|
|
|
@ -66,6 +66,7 @@ class ModelTask extends BakeTask {
|
|||
/**
|
||||
* Override initialize
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initialize() {
|
||||
$this->path = current(App::path('Model'));
|
||||
|
@ -74,6 +75,7 @@ class ModelTask extends BakeTask {
|
|||
/**
|
||||
* Execution method always used for tasks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute() {
|
||||
parent::execute();
|
||||
|
@ -127,7 +129,8 @@ class ModelTask extends BakeTask {
|
|||
* Get a model object for a class name.
|
||||
*
|
||||
* @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) {
|
||||
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 string $prompt Prompt to use for options list.
|
||||
* @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) {
|
||||
$valid = false;
|
||||
|
@ -166,6 +169,7 @@ class ModelTask extends BakeTask {
|
|||
/**
|
||||
* Handles interactive baking
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _interactive() {
|
||||
$this->hr();
|
||||
|
@ -308,7 +312,7 @@ class ModelTask extends BakeTask {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function doValidation($model) {
|
||||
|
@ -359,6 +363,7 @@ class ModelTask extends BakeTask {
|
|||
*
|
||||
* @param string $fieldName Name of field to be validated.
|
||||
* @param array $metaData metadata for field
|
||||
* @param string $primaryKey
|
||||
* @return array Array of validation for the field.
|
||||
*/
|
||||
public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') {
|
||||
|
@ -443,7 +448,7 @@ class ModelTask extends BakeTask {
|
|||
/**
|
||||
* Handles associations
|
||||
*
|
||||
* @param object $model
|
||||
* @param Model $model
|
||||
* @return array $assocaitons
|
||||
*/
|
||||
public function doAssociations($model) {
|
||||
|
@ -492,7 +497,7 @@ class ModelTask extends BakeTask {
|
|||
/**
|
||||
* 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
|
||||
* @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
|
||||
*
|
||||
* @param object $model Model instance being generated
|
||||
* @param Model $model Model instance being generated
|
||||
* @param array $associations Array of inprogress associations
|
||||
* @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
|
||||
*
|
||||
* @param object $model Model instance being generated
|
||||
* @param Model $model Model instance being generated
|
||||
* @param array $associations Array of in-progress associations
|
||||
* @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
|
||||
*
|
||||
* @param object $model Temporary model instance
|
||||
* @param Model $model Temporary model instance
|
||||
* @param array $associations 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 $data if array and $name is not an object assume bake data, otherwise boolean.
|
||||
* @return string
|
||||
*/
|
||||
public function bake($name, $data = array()) {
|
||||
if (is_object($name)) {
|
||||
|
@ -752,6 +758,7 @@ class ModelTask extends BakeTask {
|
|||
* Assembles and writes a unit test file
|
||||
*
|
||||
* @param string $className Model class name
|
||||
* @return string
|
||||
*/
|
||||
public function bakeTest($className) {
|
||||
$this->Test->interactive = $this->interactive;
|
||||
|
@ -764,6 +771,7 @@ class ModelTask extends BakeTask {
|
|||
* outputs the a list of possible models or controllers from database
|
||||
*
|
||||
* @param string $useDbConfig Database configuration name
|
||||
* @return array
|
||||
*/
|
||||
public function listAll($useDbConfig = null) {
|
||||
$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.
|
||||
*
|
||||
* @param string $useDbConfig Database config name
|
||||
* @return string the model name
|
||||
*/
|
||||
public function getName($useDbConfig = null) {
|
||||
|
|
|
@ -65,6 +65,7 @@ class PluginTask extends Shell {
|
|||
/**
|
||||
* Interactive interface
|
||||
*
|
||||
* @param string $plugin
|
||||
* @return void
|
||||
*/
|
||||
protected function _interactive($plugin = null) {
|
||||
|
@ -80,8 +81,8 @@ class PluginTask extends Shell {
|
|||
/**
|
||||
* Bake the plugin, create directories and files
|
||||
*
|
||||
* @params $plugin name of the plugin in CamelCased format
|
||||
* @return bool
|
||||
* @param string $plugin Name of the plugin in CamelCased format
|
||||
* @return boolean
|
||||
*/
|
||||
public function bake($plugin) {
|
||||
$pathOptions = App::path('plugins');
|
||||
|
@ -154,6 +155,7 @@ class PluginTask extends Shell {
|
|||
/**
|
||||
* find and change $this->path to the user selection
|
||||
*
|
||||
* @param array $pathOptions
|
||||
* @return string plugin path
|
||||
*/
|
||||
public function findPath($pathOptions) {
|
||||
|
|
|
@ -40,7 +40,7 @@ class ProjectTask extends Shell {
|
|||
* Checks that given project path does not already exist, and
|
||||
* finds the app directory in it. Then it calls bake() with that information.
|
||||
*
|
||||
* @param string $project Project path
|
||||
* @return mixed
|
||||
*/
|
||||
public function execute() {
|
||||
$project = null;
|
||||
|
@ -52,7 +52,7 @@ class ProjectTask extends Shell {
|
|||
$prompt = __d('cake_console', "What is the path to the project you want to bake?");
|
||||
$project = $this->in($prompt, null, APP . 'myapp');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($project && !Folder::isAbsolute($project) && isset($_SERVER['PWD'])) {
|
||||
$project = $_SERVER['PWD'] . DS . $project;
|
||||
|
@ -136,7 +136,7 @@ class ProjectTask extends Shell {
|
|||
/**
|
||||
* 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() {
|
||||
$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
|
||||
|
@ -157,6 +157,7 @@ class ProjectTask extends Shell {
|
|||
* @param string $path Project path
|
||||
* @param string $skel Path to copy from
|
||||
* @param string $skip array of directories to skip when copying
|
||||
* @return mixed
|
||||
*/
|
||||
public function bake($path, $skel = null, $skip = array('empty')) {
|
||||
if (!$skel && !empty($this->params['skel'])) {
|
||||
|
@ -303,7 +304,7 @@ class ProjectTask extends Shell {
|
|||
* Generates and writes CAKE_CORE_INCLUDE_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
|
||||
*/
|
||||
public function corePath($path, $hardCode = true) {
|
||||
|
@ -325,7 +326,7 @@ class ProjectTask extends Shell {
|
|||
*
|
||||
* @param string $filename The filename to operate on.
|
||||
* @param boolean $hardCode Whether or not the define should be uncommented.
|
||||
* @retun bool Success
|
||||
* @return boolean Success
|
||||
*/
|
||||
protected function _replaceCorePath($filename, $hardCode) {
|
||||
$contents = file_get_contents($filename);
|
||||
|
|
|
@ -102,7 +102,7 @@ class TemplateTask extends Shell {
|
|||
/**
|
||||
* 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).
|
||||
* Unused if $one is an associative array, otherwise serves as the values to $one's keys.
|
||||
* @return void
|
||||
|
@ -129,8 +129,8 @@ class TemplateTask extends Shell {
|
|||
*
|
||||
* @param string $directory directory / type of thing you want
|
||||
* @param string $filename template name
|
||||
* @param string $vars Additional vars to set to template scope.
|
||||
* @return contents of generated code template
|
||||
* @param array $vars Additional vars to set to template scope.
|
||||
* @return string contents of generated code template
|
||||
*/
|
||||
public function generate($directory, $filename, $vars = null) {
|
||||
if ($vars !== null) {
|
||||
|
|
|
@ -56,13 +56,14 @@ class TestTask extends BakeTask {
|
|||
/**
|
||||
* Internal list of fixtures that have been added so far.
|
||||
*
|
||||
* @var string
|
||||
* @var array
|
||||
*/
|
||||
protected $_fixtures = array();
|
||||
|
||||
/**
|
||||
* Execution method always used for tasks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute() {
|
||||
parent::execute();
|
||||
|
@ -85,6 +86,8 @@ class TestTask extends BakeTask {
|
|||
/**
|
||||
* Handles interactive baking
|
||||
*
|
||||
* @param string $type
|
||||
* @return string|boolean
|
||||
*/
|
||||
protected function _interactive($type = null) {
|
||||
$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 $className the 'cake name' for the class ie. Posts for the PostsController
|
||||
* @return string|boolean
|
||||
*/
|
||||
public function bake($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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public function isLoadableClass($type, $class) {
|
||||
|
@ -398,7 +401,7 @@ class TestTask extends BakeTask {
|
|||
* 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 $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.
|
||||
*/
|
||||
public function generateConstructor($type, $fullClassName) {
|
||||
|
|
|
@ -72,6 +72,7 @@ class ViewTask extends BakeTask {
|
|||
/**
|
||||
* Override initialize
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initialize() {
|
||||
$this->path = current(App::path('View'));
|
||||
|
@ -80,6 +81,7 @@ class ViewTask extends BakeTask {
|
|||
/**
|
||||
* Execution method always used for tasks
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function execute() {
|
||||
parent::execute();
|
||||
|
@ -113,7 +115,7 @@ class ViewTask extends BakeTask {
|
|||
return $this->bake($action, true);
|
||||
}
|
||||
|
||||
$vars = $this->__loadController();
|
||||
$vars = $this->_loadController();
|
||||
$methods = $this->_methodsToBake();
|
||||
|
||||
foreach ($methods as $method) {
|
||||
|
@ -175,7 +177,7 @@ class ViewTask extends BakeTask {
|
|||
$this->controllerName = $this->_controllerName($model);
|
||||
App::uses($model, 'Model');
|
||||
if (class_exists($model)) {
|
||||
$vars = $this->__loadController();
|
||||
$vars = $this->_loadController();
|
||||
if (!$actions) {
|
||||
$actions = $this->_methodsToBake();
|
||||
}
|
||||
|
@ -188,6 +190,7 @@ class ViewTask extends BakeTask {
|
|||
/**
|
||||
* Handles interactive baking
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _interactive() {
|
||||
$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');
|
||||
|
||||
if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoAdmin) == 'y') {
|
||||
$vars = $this->__loadController();
|
||||
$vars = $this->_loadController();
|
||||
if (strtolower($wannaDoScaffold) == 'y') {
|
||||
$actions = $this->scaffoldActions;
|
||||
$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
|
||||
*/
|
||||
private function __loadController() {
|
||||
protected function _loadController() {
|
||||
if (!$this->controllerName) {
|
||||
$this->err(__d('cake_console', 'Controller not found'));
|
||||
}
|
||||
|
@ -277,7 +280,7 @@ class ViewTask extends BakeTask {
|
|||
$singularHumanName = $this->_singularHumanName($this->controllerName);
|
||||
$schema = $modelObj->schema(true);
|
||||
$fields = array_keys($schema);
|
||||
$associations = $this->__associations($modelObj);
|
||||
$associations = $this->_associations($modelObj);
|
||||
} else {
|
||||
$primaryKey = $displayField = null;
|
||||
$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
|
||||
*
|
||||
* @param array $actions Array of actions to make files for.
|
||||
* @param array $vars
|
||||
* @return void
|
||||
*/
|
||||
public function bakeActions($actions, $vars) {
|
||||
|
@ -363,7 +367,7 @@ class ViewTask extends BakeTask {
|
|||
*/
|
||||
public function getContent($action, $vars = null) {
|
||||
if (!$vars) {
|
||||
$vars = $this->__loadController();
|
||||
$vars = $this->_loadController();
|
||||
}
|
||||
|
||||
$this->Template->set('action', $action);
|
||||
|
@ -436,9 +440,10 @@ class ViewTask extends BakeTask {
|
|||
/**
|
||||
* Returns associations for controllers models.
|
||||
*
|
||||
* @return array $associations
|
||||
* @param Model $model
|
||||
* @return array $associations
|
||||
*/
|
||||
private function __associations($model) {
|
||||
protected function _associations($model) {
|
||||
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||
$associations = array();
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@ class TestsuiteShell extends Shell {
|
|||
* Initialization method installs PHPUnit and loads all plugins
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function initialize() {
|
||||
$this->_dispatcher = new CakeTestSuiteDispatcher();
|
||||
|
@ -181,7 +182,7 @@ class TestsuiteShell extends Shell {
|
|||
*
|
||||
* @return array Array of params for CakeTestDispatcher
|
||||
*/
|
||||
protected function parseArgs() {
|
||||
protected function _parseArgs() {
|
||||
if (empty($this->args)) {
|
||||
return;
|
||||
}
|
||||
|
@ -213,7 +214,7 @@ class TestsuiteShell extends Shell {
|
|||
*
|
||||
* @return array Array of params for CakeTestDispatcher
|
||||
*/
|
||||
protected function runnerOptions() {
|
||||
protected function _runnerOptions() {
|
||||
$options = array();
|
||||
$params = $this->params;
|
||||
unset($params['help']);
|
||||
|
@ -245,23 +246,23 @@ class TestsuiteShell extends Shell {
|
|||
$this->out(__d('cake_console', 'CakePHP Test Shell'));
|
||||
$this->hr();
|
||||
|
||||
$args = $this->parseArgs();
|
||||
$args = $this->_parseArgs();
|
||||
|
||||
if (empty($args['case'])) {
|
||||
return $this->available();
|
||||
}
|
||||
|
||||
$this->run($args, $this->runnerOptions());
|
||||
$this->_run($args, $this->_runnerOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the test case from $runnerArgs
|
||||
*
|
||||
* @param array $runnerArgs list of arguments as obtained from parseArgs()
|
||||
* @param array $options list of options as constructed by runnerOptions()
|
||||
* @param array $runnerArgs list of arguments as obtained from _parseArgs()
|
||||
* @param array $options list of options as constructed by _runnerOptions()
|
||||
* @return void
|
||||
*/
|
||||
protected function run($runnerArgs, $options = array()) {
|
||||
protected function _run($runnerArgs, $options = array()) {
|
||||
restore_error_handler();
|
||||
restore_error_handler();
|
||||
|
||||
|
@ -275,7 +276,7 @@ class TestsuiteShell extends Shell {
|
|||
* @return void
|
||||
*/
|
||||
public function available() {
|
||||
$params = $this->parseArgs();
|
||||
$params = $this->_parseArgs();
|
||||
$testCases = CakeTestLoader::generateTestList($params);
|
||||
$app = $params['app'];
|
||||
$plugin = $params['plugin'];
|
||||
|
@ -309,14 +310,14 @@ class TestsuiteShell extends Shell {
|
|||
if (is_numeric($choice) && isset($cases[$choice])) {
|
||||
$this->args[0] = $category;
|
||||
$this->args[1] = $cases[$choice];
|
||||
$this->run($this->parseArgs(), $this->runnerOptions());
|
||||
$this->_run($this->_parseArgs(), $this->_runnerOptions());
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_string($choice) && in_array($choice, $cases)) {
|
||||
$this->args[0] = $category;
|
||||
$this->args[1] = $choice;
|
||||
$this->run($this->parseArgs(), $this->runnerOptions());
|
||||
$this->_run($this->_parseArgs(), $this->_runnerOptions());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,22 @@
|
|||
<?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');
|
||||
|
||||
/**
|
||||
|
@ -8,10 +26,25 @@ App::uses('Folder', 'Utility');
|
|||
*/
|
||||
class UpgradeShell extends Shell {
|
||||
|
||||
/**
|
||||
* Files
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_files = array();
|
||||
|
||||
/**
|
||||
* Paths
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_paths = array();
|
||||
|
||||
/**
|
||||
* Map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_map = array(
|
||||
'Controller' => 'Controller',
|
||||
'Component' => 'Controller/Component',
|
||||
|
|
|
@ -20,7 +20,7 @@ App::uses('ConsoleOutput', 'Console');
|
|||
App::uses('CakeLog', 'Log');
|
||||
|
||||
/**
|
||||
* Error Handler for Cake console. Does simple printing of the
|
||||
* Error Handler for Cake console. Does simple printing of the
|
||||
* exception that occurred and the stack trace of the error.
|
||||
*
|
||||
* @package Cake.Console
|
||||
|
@ -30,16 +30,14 @@ class ConsoleErrorHandler extends ErrorHandler {
|
|||
/**
|
||||
* Standard error stream.
|
||||
*
|
||||
* @var filehandle
|
||||
* @access public
|
||||
* @var ConsoleOutput
|
||||
*/
|
||||
public static $stderr;
|
||||
|
||||
/**
|
||||
* Get the stderr object for the console error handling.
|
||||
*
|
||||
* @param Exception $error Exception to handle.
|
||||
* @param array $messages Error messages
|
||||
* @return ConsoleOutput
|
||||
*/
|
||||
public static function getStderr() {
|
||||
if (empty(self::$stderr)) {
|
||||
|
@ -57,7 +55,7 @@ class ConsoleErrorHandler extends ErrorHandler {
|
|||
public static function handleException(Exception $exception) {
|
||||
$stderr = self::getStderr();
|
||||
$stderr->write(__d('cake_console', "<error>Error:</error> %s\n%s",
|
||||
$exception->getMessage(),
|
||||
$exception->getMessage(),
|
||||
$exception->getTraceAsString()
|
||||
));
|
||||
}
|
||||
|
@ -66,10 +64,10 @@ class ConsoleErrorHandler extends ErrorHandler {
|
|||
* Handle errors in the console environment. Writes errors to stderr,
|
||||
* 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 $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.
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
/**
|
||||
* Object wrapper for interacting with stdin
|
||||
* Object wrapper for interacting with stdin
|
||||
*
|
||||
* @package Cake.Console
|
||||
*/
|
||||
|
|
|
@ -84,8 +84,8 @@ class ConsoleInputArgument {
|
|||
/**
|
||||
* Generate the help for this argument.
|
||||
*
|
||||
* @param int $width The width to make the name of the option.
|
||||
* @return string
|
||||
* @param integer $width The width to make the name of the option.
|
||||
* @return string
|
||||
*/
|
||||
public function help($width = 0) {
|
||||
$name = $this->_name;
|
||||
|
@ -131,7 +131,9 @@ class ConsoleInputArgument {
|
|||
/**
|
||||
* Check that $value is a valid choice for this argument.
|
||||
*
|
||||
* @param string $value
|
||||
* @return boolean
|
||||
* @throws ConsoleException
|
||||
*/
|
||||
public function validChoice($value) {
|
||||
if (empty($this->_choices)) {
|
||||
|
@ -139,7 +141,7 @@ class ConsoleInputArgument {
|
|||
}
|
||||
if (!in_array($value, $this->_choices)) {
|
||||
throw new ConsoleException(
|
||||
__d('cake_console', '"%s" is not a valid value for %s. Please use one of "%s"',
|
||||
__d('cake_console', '"%s" is not a valid value for %s. Please use one of "%s"',
|
||||
$value, $this->_name, implode(', ', $this->_choices)
|
||||
));
|
||||
}
|
||||
|
@ -149,7 +151,7 @@ class ConsoleInputArgument {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
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 string $default The default value 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()) {
|
||||
if (is_array($name) && isset($name['name'])) {
|
||||
|
@ -117,8 +118,8 @@ class ConsoleInputOption {
|
|||
/**
|
||||
* Generate the help for this this option.
|
||||
*
|
||||
* @param int $width The width to make the name of the option.
|
||||
* @return string
|
||||
* @param integer $width The width to make the name of the option.
|
||||
* @return string
|
||||
*/
|
||||
public function help($width = 0) {
|
||||
$default = $short = '';
|
||||
|
@ -176,7 +177,9 @@ class ConsoleInputOption {
|
|||
/**
|
||||
* Check that a value is a valid choice for this option.
|
||||
*
|
||||
* @param string $value
|
||||
* @return boolean
|
||||
* @throws ConsoleException
|
||||
*/
|
||||
public function validChoice($value) {
|
||||
if (empty($this->_choices)) {
|
||||
|
@ -194,7 +197,7 @@ class ConsoleInputOption {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function xml(SimpleXmlElement $parent) {
|
||||
|
|
|
@ -37,7 +37,7 @@ class ConsoleInputSubcommand {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_help;
|
||||
protected $_help;
|
||||
|
||||
/**
|
||||
* The ConsoleOptionParser for this subcommand.
|
||||
|
@ -51,7 +51,7 @@ class ConsoleInputSubcommand {
|
|||
*
|
||||
* @param mixed $name The long name of the subcommand, or an array with all the properties.
|
||||
* @param string $help The help text for this option
|
||||
* @param mixed $parser A parser for this subcommand. Either a ConsoleOptionParser, or an array that can be
|
||||
* @param mixed $parser A parser for this subcommand. Either a ConsoleOptionParser, or an array that can be
|
||||
* used with ConsoleOptionParser::buildFromArray()
|
||||
*/
|
||||
public function __construct($name, $help = '', $parser = null) {
|
||||
|
@ -82,8 +82,8 @@ class ConsoleInputSubcommand {
|
|||
/**
|
||||
* Generate the help for this this subcommand.
|
||||
*
|
||||
* @param int $width The width to make the name of the subcommand.
|
||||
* @return string
|
||||
* @param integer $width The width to make the name of the subcommand.
|
||||
* @return string
|
||||
*/
|
||||
public function help($width = 0) {
|
||||
$name = $this->_name;
|
||||
|
@ -108,7 +108,7 @@ class ConsoleInputSubcommand {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function xml(SimpleXmlElement $parent) {
|
||||
|
|
|
@ -232,7 +232,7 @@ class ConsoleOptionParser {
|
|||
/**
|
||||
* Get or set the description text for shell/task.
|
||||
*
|
||||
* @param mixed $text The text to set, or null if you want to read. If an array the
|
||||
* @param mixed $text The text to set, or null if you want to read. If an array the
|
||||
* text will be imploded with "\n"
|
||||
* @return mixed If reading, the value of the description. If setting $this will be returned
|
||||
*/
|
||||
|
@ -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.
|
||||
* Will also accept an instance of ConsoleInputOption
|
||||
* @param array $params An array of parameters that define the behavior of the option
|
||||
* @return returns $this.
|
||||
* @param array $options An array of parameters that define the behavior of the option
|
||||
* @return ConsoleOptionParser $this.
|
||||
*/
|
||||
public function addOption($name, $options = array()) {
|
||||
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 array $params Parameters for the argument, see above.
|
||||
* @return $this.
|
||||
* @return ConsoleOptionParser $this.
|
||||
*/
|
||||
public function addArgument($name, $params = array()) {
|
||||
if (is_object($name) && $name instanceof ConsoleInputArgument) {
|
||||
|
@ -354,7 +354,7 @@ class ConsoleOptionParser {
|
|||
*
|
||||
* @param array $args Array of arguments to add.
|
||||
* @see ConsoleOptionParser::addArgument()
|
||||
* @return $this
|
||||
* @return ConsoleOptionParser $this
|
||||
*/
|
||||
public function addArguments(array $args) {
|
||||
foreach ($args as $name => $params) {
|
||||
|
@ -369,7 +369,7 @@ class ConsoleOptionParser {
|
|||
*
|
||||
* @param array $options Array of options to add.
|
||||
* @see ConsoleOptionParser::addOption()
|
||||
* @return $this
|
||||
* @return ConsoleOptionParser $this
|
||||
*/
|
||||
public function addOptions(array $options) {
|
||||
foreach ($options as $name => $params) {
|
||||
|
@ -390,8 +390,8 @@ class ConsoleOptionParser {
|
|||
* it will be used.
|
||||
*
|
||||
* @param mixed $name Name of the subcommand. Will also accept an instance of ConsoleInputSubcommand
|
||||
* @param array $params Array of params, see above.
|
||||
* @return $this.
|
||||
* @param array $options Array of params, see above.
|
||||
* @return ConsoleOptionParser $this.
|
||||
*/
|
||||
public function addSubcommand($name, $options = array()) {
|
||||
if (is_object($name) && $name instanceof ConsoleInputSubcommand) {
|
||||
|
@ -414,7 +414,7 @@ class ConsoleOptionParser {
|
|||
* Add multiple subcommands at once.
|
||||
*
|
||||
* @param array $commands Array of subcommands.
|
||||
* @return $this
|
||||
* @return ConsoleOptionParser $this
|
||||
*/
|
||||
public function addSubcommands(array $commands) {
|
||||
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,
|
||||
* That parser will be used to parse $argv instead.
|
||||
* @return Array array($params, $args)
|
||||
* @throws InvalidArgumentException When an invalid parameter is encountered.
|
||||
* RuntimeException when required arguments are not supplied.
|
||||
* @throws ConsoleException When an invalid parameter is encountered.
|
||||
*/
|
||||
public function parse($argv, $command = null) {
|
||||
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.
|
||||
* 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.
|
||||
*/
|
||||
public function help($subcommand = null, $format = 'text', $width = 72) {
|
||||
|
@ -568,9 +568,10 @@ class ConsoleOptionParser {
|
|||
/**
|
||||
* 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
|
||||
* @return array Params with $option added in.
|
||||
* @throws ConsoleException
|
||||
*/
|
||||
protected function _parseOption($name, $params) {
|
||||
if (!isset($this->_options[$name])) {
|
||||
|
@ -617,6 +618,7 @@ class ConsoleOptionParser {
|
|||
* @param string $argument The argument to append
|
||||
* @param array $args The array of parsed args to append to.
|
||||
* @return array Args
|
||||
* @throws ConsoleException
|
||||
*/
|
||||
protected function _parseArg($argument, $args) {
|
||||
if (empty($this->_args)) {
|
||||
|
@ -637,8 +639,7 @@ class ConsoleOptionParser {
|
|||
/**
|
||||
* Find the next token in the argv set.
|
||||
*
|
||||
* @param string
|
||||
* @return next token or ''
|
||||
* @return string next token or ''
|
||||
*/
|
||||
protected function _nextToken() {
|
||||
return isset($this->_tokens[0]) ? $this->_tokens[0] : '';
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
/**
|
||||
* Object wrapper for outputting information from a shell application.
|
||||
* Can be connected to any stream resource that can be used with fopen()
|
||||
*
|
||||
* Can generate colorized output on consoles that support it. There are a few
|
||||
*
|
||||
* Can generate colorized output on consoles that support it. There are a few
|
||||
* built in styles
|
||||
*
|
||||
* - `error` Error messages.
|
||||
|
@ -141,7 +141,7 @@ class ConsoleOutput {
|
|||
*
|
||||
* Checks for a pretty console environment. Ansicon allows pretty consoles
|
||||
* on windows, and is supported.
|
||||
*
|
||||
*
|
||||
* @param string $stream The identifier of the stream to write output to.
|
||||
*/
|
||||
public function __construct($stream = 'php://stdout') {
|
||||
|
@ -265,8 +265,8 @@ class ConsoleOutput {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function outputAs($type = null) {
|
||||
|
@ -279,7 +279,6 @@ class ConsoleOutput {
|
|||
/**
|
||||
* clean up and close handles
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct() {
|
||||
fclose($this->_output);
|
||||
|
|
|
@ -158,6 +158,7 @@ class HelpFormatter {
|
|||
/**
|
||||
* Iterate over a collection and find the longest named thing.
|
||||
*
|
||||
* @param array $collection
|
||||
* @return integer
|
||||
*/
|
||||
protected function _getMaxLength($collection) {
|
||||
|
@ -179,7 +180,7 @@ class HelpFormatter {
|
|||
$xml = new SimpleXmlElement('<shell></shell>');
|
||||
$xml->addChild('command', $parser->command());
|
||||
$xml->addChild('description', $parser->description());
|
||||
|
||||
|
||||
$xml->addChild('epilog', $parser->epilog());
|
||||
$subcommands = $xml->addChild('subcommands');
|
||||
foreach ($parser->subcommands() as $command) {
|
||||
|
|
|
@ -48,7 +48,6 @@ class Shell extends Object {
|
|||
* If true, the script will ask for permission to perform actions.
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
public $interactive = true;
|
||||
|
||||
|
@ -56,7 +55,6 @@ class Shell extends Object {
|
|||
* Contains command switches parsed from the command line.
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $params = array();
|
||||
|
||||
|
@ -144,7 +142,7 @@ class Shell extends Object {
|
|||
* @param ConsoleOutput $stderr A ConsoleOutput object for stderr.
|
||||
* @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) {
|
||||
$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
|
||||
* If public $uses is an array of models will load those models
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _loadModels() {
|
||||
if ($this->uses === null || $this->uses === false) {
|
||||
|
@ -245,7 +243,7 @@ class Shell extends Object {
|
|||
/**
|
||||
* Loads tasks defined in public $tasks
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function loadTasks() {
|
||||
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');`
|
||||
*
|
||||
* @param mixed $command Either an array of args similar to $argv. Or a string command, that can be
|
||||
* exploded on space to simulate argv.
|
||||
* @return mixed. The return of the other shell.
|
||||
* @return mixed The return of the other shell.
|
||||
*/
|
||||
public function dispatchShell() {
|
||||
$args = func_get_args();
|
||||
|
@ -357,7 +353,7 @@ class Shell extends Object {
|
|||
} catch (ConsoleException $e) {
|
||||
return $this->out($this->OptionParser->help($command));
|
||||
}
|
||||
|
||||
|
||||
$this->command = $command;
|
||||
if (!empty($this->params['help'])) {
|
||||
return $this->_displayHelp($command);
|
||||
|
@ -383,6 +379,7 @@ class Shell extends Object {
|
|||
/**
|
||||
* Display the help in the correct format
|
||||
*
|
||||
* @param string $command
|
||||
* @return void
|
||||
*/
|
||||
protected function _displayHelp($command) {
|
||||
|
@ -410,7 +407,8 @@ class Shell extends Object {
|
|||
/**
|
||||
* Overload get for lazy building of tasks
|
||||
*
|
||||
* @return void
|
||||
* @param string $name
|
||||
* @return Shell Object of Task
|
||||
*/
|
||||
public function __get($name) {
|
||||
if (empty($this->{$name}) && in_array($name, $this->taskNames)) {
|
||||
|
@ -430,7 +428,7 @@ class Shell extends Object {
|
|||
* @param string $prompt Prompt text.
|
||||
* @param mixed $options Array or string of options.
|
||||
* @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) {
|
||||
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 integer $newlines Number of newlines to append
|
||||
* @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) {
|
||||
$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 integer $newlines Number of newlines to append
|
||||
* @return void
|
||||
*/
|
||||
public function err($message = null, $newlines = 1) {
|
||||
$this->stderr->write($message, $newlines);
|
||||
|
@ -554,7 +553,6 @@ class Shell extends Object {
|
|||
* Returns a single or multiple linefeeds sequences.
|
||||
*
|
||||
* @param integer $multiplier Number of times the linefeed sequence should be repeated
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
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 $width Width of the line, defaults to 63
|
||||
* @return void
|
||||
*/
|
||||
public function hr($newlines = 0, $width = 63) {
|
||||
$this->out(null, $newlines);
|
||||
|
@ -579,6 +578,7 @@ class Shell extends Object {
|
|||
*
|
||||
* @param string $title Title of the error
|
||||
* @param string $message An optional error message
|
||||
* @return void
|
||||
*/
|
||||
public function error($title, $message = null) {
|
||||
$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
|
||||
*
|
||||
* @param string $file Absolute file path
|
||||
* @return sting short path
|
||||
* @return string short path
|
||||
*/
|
||||
public function shortPath($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
|
||||
* @return string $path path to the correct plugin.
|
||||
*/
|
||||
function _pluginPath($pluginName) {
|
||||
protected function _pluginPath($pluginName) {
|
||||
if (CakePlugin::loaded($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.
|
||||
*
|
||||
* @param array $args the argv from PHP
|
||||
* @param bool $bootstrap Should the environment be bootstrapped.
|
||||
* @return void
|
||||
* @param boolean $bootstrap Should the environment be bootstrapped.
|
||||
*/
|
||||
public function __construct($args = array(), $bootstrap = true) {
|
||||
set_time_limit(0);
|
||||
|
@ -96,9 +95,10 @@ class ShellDispatcher {
|
|||
* Defines current working environment.
|
||||
*
|
||||
* @return void
|
||||
* @throws CakeException
|
||||
*/
|
||||
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;
|
||||
throw new CakeException($message);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class ShellDispatcher {
|
|||
*
|
||||
* @return boolean Success.
|
||||
*/
|
||||
private function __bootstrap() {
|
||||
protected function _bootstrap() {
|
||||
define('ROOT', $this->params['root']);
|
||||
define('APP_DIR', $this->params['app']);
|
||||
define('APP', $this->params['working'] . DS);
|
||||
|
@ -149,6 +149,7 @@ class ShellDispatcher {
|
|||
* Dispatches a CLI request
|
||||
*
|
||||
* @return boolean
|
||||
* @throws MissingShellMethodException
|
||||
*/
|
||||
public function dispatch() {
|
||||
$shell = $this->shiftArgs();
|
||||
|
@ -198,8 +199,8 @@ class ShellDispatcher {
|
|||
* All paths in the loaded shell paths are searched.
|
||||
*
|
||||
* @param string $shell Optionally the name of a plugin
|
||||
* @return mixed False if no shell could be found or an object on success
|
||||
* @throws MissingShellFileException, MissingShellClassException when errors are encountered.
|
||||
* @return mixed An object
|
||||
* @throws MissingShellFileException when errors are encountered.
|
||||
*/
|
||||
protected function _getShell($shell) {
|
||||
list($plugin, $shell) = pluginSplit($shell, true);
|
||||
|
@ -221,7 +222,8 @@ class ShellDispatcher {
|
|||
/**
|
||||
* 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) {
|
||||
$this->_parsePaths($args);
|
||||
|
@ -276,6 +278,7 @@ class ShellDispatcher {
|
|||
/**
|
||||
* Parses out the paths from from the argv
|
||||
*
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
protected function _parsePaths($args) {
|
||||
|
@ -316,7 +319,7 @@ class ShellDispatcher {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
protected function _stop($status = 0) {
|
||||
|
|
|
@ -27,7 +27,7 @@ class TaskCollection extends ObjectCollection {
|
|||
/**
|
||||
* Shell to use to set params to tasks.
|
||||
*
|
||||
* @var array
|
||||
* @var Shell
|
||||
*/
|
||||
protected $_Shell;
|
||||
|
||||
|
@ -41,8 +41,7 @@ class TaskCollection extends ObjectCollection {
|
|||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $paths Array of paths to search for tasks on .
|
||||
* @return void
|
||||
* @param Shell $Shell
|
||||
*/
|
||||
public function __construct(Shell $Shell) {
|
||||
$this->_Shell = $Shell;
|
||||
|
@ -51,7 +50,7 @@ class TaskCollection extends ObjectCollection {
|
|||
/**
|
||||
* Loads/constructs a task. Will return the instance in the collection
|
||||
* if it already exists.
|
||||
*
|
||||
*
|
||||
* @param string $task Task name to load
|
||||
* @param array $settings Settings for the task.
|
||||
* @return Task A task object, Either the existing loaded task or a new one.
|
||||
|
|
|
@ -24,6 +24,17 @@ echo "<?php\n";
|
|||
/**
|
||||
* <?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 {
|
||||
|
||||
|
|
|
@ -23,6 +23,15 @@ echo "<?php\n"; ?>
|
|||
/**
|
||||
* <?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 {
|
||||
<?php if ($useDbConfig != 'default'): ?>
|
||||
|
|
|
@ -32,7 +32,6 @@ class PagesController extends AppController {
|
|||
* Controller name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $name = 'Pages';
|
||||
|
||||
|
@ -40,7 +39,6 @@ class PagesController extends AppController {
|
|||
* Default helper
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $helpers = array('Html');
|
||||
|
||||
|
@ -48,7 +46,6 @@ class PagesController extends AppController {
|
|||
* This controller does not use a model
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $uses = array();
|
||||
|
||||
|
@ -56,7 +53,6 @@ class PagesController extends AppController {
|
|||
* Displays a view
|
||||
*
|
||||
* @param mixed What page to display
|
||||
* @access public
|
||||
*/
|
||||
public function display() {
|
||||
$path = func_get_args();
|
||||
|
|
|
@ -4,9 +4,27 @@
|
|||
*
|
||||
* 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
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
class CakeErrorController extends AppController {
|
||||
|
||||
/**
|
||||
* Controller name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name = 'CakeError';
|
||||
|
||||
/**
|
||||
|
@ -19,8 +37,8 @@ class CakeErrorController extends AppController {
|
|||
/**
|
||||
* __construct
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @param CakeRequest $request
|
||||
* @param CakeResponse $response
|
||||
*/
|
||||
public function __construct($request = null, $response = null) {
|
||||
parent::__construct($request, $response);
|
||||
|
|
|
@ -86,7 +86,7 @@ class Component extends Object {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function __get($name) {
|
||||
|
@ -102,7 +102,7 @@ class Component extends Object {
|
|||
/**
|
||||
* Called before the Controller::beforeFilter().
|
||||
*
|
||||
* @param object $controller Controller with components to initialize
|
||||
* @param Controller $controller Controller with components to initialize
|
||||
* @return void
|
||||
* @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
|
||||
*
|
||||
* @param object $controller Controller with components to startup
|
||||
* @param Controller $controller Controller with components to startup
|
||||
* @return void
|
||||
* @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
|
||||
* Controller::render()
|
||||
*
|
||||
* @param object $controller Controller with components to beforeRender
|
||||
* @param Controller $controller Controller with components to beforeRender
|
||||
* @return void
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param object $controller Controller with components to shutdown
|
||||
* @param Controller $controller Controller with components to shutdown
|
||||
* @return void
|
||||
*/
|
||||
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
|
||||
* be used as the new url to redirect to.
|
||||
*
|
||||
* @param object $controller Controller with components to beforeRedirect
|
||||
* @param mixed $url Either the string or url array that is being redirected to.
|
||||
* @param int $status The status code of the redirect
|
||||
* @param bool $exit Will the script exit.
|
||||
* @return mixed Either an array or null.
|
||||
* @param Controller $controller Controller with components to beforeRedirect
|
||||
* @param string|array $url Either the string or url array that is being redirected to.
|
||||
* @param integer $status The status code of the redirect
|
||||
* @param boolean $exit Will the script exit.
|
||||
* @return array|null Either an array or null.
|
||||
*/
|
||||
public function beforeRedirect($controller, $url, $status = null, $exit = true) {}
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ class AclComponent extends Component {
|
|||
/**
|
||||
* Instance of an ACL class
|
||||
*
|
||||
* @var object
|
||||
* @access protected
|
||||
* @var AclInterface
|
||||
*/
|
||||
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')`
|
||||
*
|
||||
* @param ComponentCollection $collection
|
||||
* @param array $settings
|
||||
* @throws CakeException when Acl.classname could not be loaded.
|
||||
*/
|
||||
public function __construct(ComponentCollection $collection, $settings = array()) {
|
||||
|
@ -262,7 +263,7 @@ class DbAcl extends Object implements AclInterface {
|
|||
* Constructor
|
||||
*
|
||||
*/
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
App::uses('AclNode', 'Model');
|
||||
$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 $aco ACO The controlled object identifier.
|
||||
* @param string $actions Action (defaults to *)
|
||||
* @param string $action Action (defaults to *)
|
||||
* @return boolean Success
|
||||
* @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 $aco ACO The controlled object identifier.
|
||||
* @param string $actions Action (defaults to *)
|
||||
* @param string $action Action (defaults to *)
|
||||
* @return boolean Success
|
||||
*/
|
||||
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 $aco ACO The controlled object identifier.
|
||||
* @param string $actions Action (defaults to *)
|
||||
* @param string $action Action (defaults to *)
|
||||
* @return boolean Success
|
||||
* @see allow()
|
||||
*/
|
||||
|
@ -462,7 +463,7 @@ class DbAcl extends Object implements AclInterface {
|
|||
*
|
||||
* @param string $aro ARO The requesting 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
|
||||
* @see deny()
|
||||
*/
|
||||
|
@ -526,7 +527,6 @@ class IniAcl extends Object implements AclInterface {
|
|||
* Array with configuration, parsed from ini file
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $config = null;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
|
||||
App::uses('BaseAuthorize', 'Controller/Component/Auth');
|
||||
|
||||
/**
|
||||
|
|
|
@ -99,10 +99,10 @@ abstract class BaseAuthenticate {
|
|||
abstract public function authenticate(CakeRequest $request, CakeResponse $response);
|
||||
|
||||
/**
|
||||
* Allows you to hook into AuthComponent::logout(),
|
||||
* Allows you to hook into AuthComponent::logout(),
|
||||
* and implement specialized logout behaviour.
|
||||
*
|
||||
* All attached authentication objects will have this method
|
||||
*
|
||||
* All attached authentication objects will have this method
|
||||
* called when a user logs out.
|
||||
*
|
||||
* @param array $user The user about to be logged out.
|
||||
|
|
|
@ -34,7 +34,7 @@ abstract class BaseAuthorize {
|
|||
* @var ComponentCollection
|
||||
*/
|
||||
protected $_Collection;
|
||||
|
||||
|
||||
/**
|
||||
* Settings for authorize objects.
|
||||
*
|
||||
|
@ -61,7 +61,7 @@ abstract class BaseAuthorize {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function __construct(ComponentCollection $collection, $settings = array()) {
|
||||
|
@ -75,7 +75,7 @@ abstract class BaseAuthorize {
|
|||
* Checks user authorization.
|
||||
*
|
||||
* @param array $user Active user data
|
||||
* @param CakeRequest $request
|
||||
* @param CakeRequest $request
|
||||
* @return boolean
|
||||
*/
|
||||
abstract public function authorize($user, CakeRequest $request);
|
||||
|
@ -84,7 +84,8 @@ abstract class BaseAuthorize {
|
|||
* Accessor to the controller object.
|
||||
*
|
||||
* @param mixed $controller null to get, a controller to set.
|
||||
* @return mixed.
|
||||
* @return mixed
|
||||
* @throws CakeException
|
||||
*/
|
||||
public function controller($controller = null) {
|
||||
if ($controller) {
|
||||
|
@ -102,6 +103,7 @@ abstract class BaseAuthorize {
|
|||
* that need to get information about the plugin, controller, and action being invoked.
|
||||
*
|
||||
* @param CakeRequest $request The request a path is needed for.
|
||||
* @param string $path
|
||||
* @return string the action path for the given request.
|
||||
*/
|
||||
public function action($request, $path = '/:plugin/:controller/:action') {
|
||||
|
|
|
@ -24,10 +24,10 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
|
|||
* Auth must support cookies.
|
||||
*
|
||||
* ### Using Basic auth
|
||||
*
|
||||
*
|
||||
* In your controller's components array, add auth + the required settings.
|
||||
* {{{
|
||||
* var $components = array(
|
||||
* public $components = array(
|
||||
* 'Auth' => array(
|
||||
* 'authenticate' => array('Basic')
|
||||
* )
|
||||
|
@ -76,7 +76,7 @@ class BasicAuthenticate extends BaseAuthenticate {
|
|||
}
|
||||
|
||||
/**
|
||||
* Authenticate a user using basic HTTP auth. Will use the configured User model and attempt a
|
||||
* Authenticate a user using basic HTTP auth. Will use the configured User model and attempt a
|
||||
* login using basic HTTP auth.
|
||||
*
|
||||
* @param CakeRequest $request The request to authenticate with.
|
||||
|
@ -104,7 +104,7 @@ class BasicAuthenticate extends BaseAuthenticate {
|
|||
public function getUser($request) {
|
||||
$username = env('PHP_AUTH_USER');
|
||||
$pass = env('PHP_AUTH_PW');
|
||||
|
||||
|
||||
if (empty($username) || empty($pass)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
* @param mixed $controller null to get, a controller to set.
|
||||
* @return mixed.
|
||||
* @return mixed
|
||||
* @throws CakeException
|
||||
*/
|
||||
public function controller($controller = null) {
|
||||
if ($controller) {
|
||||
|
@ -56,7 +57,7 @@ class ControllerAuthorize extends BaseAuthorize {
|
|||
* Checks user authorization using a controller callback.
|
||||
*
|
||||
* @param array $user Active user data
|
||||
* @param CakeRequest $request
|
||||
* @param CakeRequest $request
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize($user, CakeRequest $request) {
|
||||
|
|
|
@ -81,9 +81,9 @@ class CrudAuthorize extends BaseAuthorize {
|
|||
*/
|
||||
public function authorize($user, CakeRequest $request) {
|
||||
if (!isset($this->settings['actionMap'][$request->params['action']])) {
|
||||
trigger_error(__d('cake_dev',
|
||||
trigger_error(__d('cake_dev',
|
||||
'CrudAuthorize::authorize() - Attempted access of un-mapped action "%1$s" in controller "%2$s"',
|
||||
$request->action,
|
||||
$request->action,
|
||||
$request->controller
|
||||
),
|
||||
E_USER_WARNING
|
||||
|
|
|
@ -20,17 +20,17 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
|
|||
*
|
||||
* Provides Digest HTTP authentication support for AuthComponent. Unlike most AuthComponent adapters,
|
||||
* DigestAuthenticate requires a special password hash that conforms to RFC2617. You can create this
|
||||
* password using `DigestAuthenticate::password()`. If you wish to use digest authentication alongside other
|
||||
* password using `DigestAuthenticate::password()`. If you wish to use digest authentication alongside other
|
||||
* authentication methods, its recommended that you store the digest authentication separately.
|
||||
*
|
||||
* Clients using Digest Authentication must support cookies. Since AuthComponent identifies users based
|
||||
* on Session contents, clients without support for cookies will not function properly.
|
||||
*
|
||||
* ### Using Digest auth
|
||||
*
|
||||
*
|
||||
* In your controller's components array, add auth + the required settings.
|
||||
* {{{
|
||||
* var $components = array(
|
||||
* public $components = array(
|
||||
* 'Auth' => array(
|
||||
* 'authenticate' => array('Digest')
|
||||
* )
|
||||
|
@ -47,7 +47,7 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
|
|||
*
|
||||
* `$digestPass = DigestAuthenticate::password($username, env('SERVER_NAME'), $password);`
|
||||
*
|
||||
* Its recommended that you store this digest auth only password separate from password hashes used for other
|
||||
* Its recommended that you store this digest auth only password separate from password hashes used for other
|
||||
* login methods. For example `User.digest_pass` could be used for a digest password, while `User.password` would
|
||||
* store the password hash for use with other methods like Basic or Form.
|
||||
*
|
||||
|
@ -101,7 +101,7 @@ class DigestAuthenticate extends BaseAuthenticate {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* Authenticate a user using Digest HTTP auth. Will use the configured User model and attempt a
|
||||
* Authenticate a user using Digest HTTP auth. Will use the configured User model and attempt a
|
||||
* login using Digest HTTP auth.
|
||||
*
|
||||
* @param CakeRequest $request The request to authenticate with.
|
||||
|
@ -230,7 +230,7 @@ class DigestAuthenticate extends BaseAuthenticate {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates an auth digest password hash to store
|
||||
* Creates an auth digest password hash to store
|
||||
*
|
||||
* @param string $username The username to use in the digest hash.
|
||||
* @param string $password The unhashed password to make a digest hash for.
|
||||
|
|
|
@ -38,7 +38,7 @@ class FormAuthenticate extends BaseAuthenticate {
|
|||
|
||||
/**
|
||||
* Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields`
|
||||
* to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if
|
||||
* to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if
|
||||
* there is no post data, either username or password is missing, of if the scope conditions have not been met.
|
||||
*
|
||||
* @param CakeRequest $request The request that contains login information.
|
||||
|
|
|
@ -240,7 +240,7 @@ class AuthComponent extends Component {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
public function initialize($controller) {
|
||||
|
@ -257,7 +257,7 @@ class AuthComponent extends Component {
|
|||
* Main execution method. Handles redirecting of invalid users, and processing
|
||||
* 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
|
||||
*/
|
||||
public function startup($controller) {
|
||||
|
@ -277,7 +277,7 @@ class AuthComponent extends Component {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!$this->__setDefaults()) {
|
||||
if (!$this->_setDefaults()) {
|
||||
return false;
|
||||
}
|
||||
$request = $controller->request;
|
||||
|
@ -337,11 +337,9 @@ class AuthComponent extends Component {
|
|||
* Attempts to introspect the correct values for object properties including
|
||||
* $userModel and $sessionKey.
|
||||
*
|
||||
* @param object $controller A reference to the instantiating controller object
|
||||
* @return boolean
|
||||
* @access private
|
||||
*/
|
||||
function __setDefaults() {
|
||||
protected function _setDefaults() {
|
||||
$defaults = array(
|
||||
'logoutRedirect' => $this->loginAction,
|
||||
'authError' => __d('cake', 'You are not authorized to access that location.')
|
||||
|
@ -387,6 +385,7 @@ class AuthComponent extends Component {
|
|||
* Loads the authorization objects configured.
|
||||
*
|
||||
* @return mixed Either null when authorize is empty, or the loaded authorization objects.
|
||||
* @throws CakeException
|
||||
*/
|
||||
public function constructAuthorize() {
|
||||
if (empty($this->authorize)) {
|
||||
|
@ -428,13 +427,11 @@ class AuthComponent extends Component {
|
|||
*
|
||||
* `$this->Auth->allow('*');`
|
||||
*
|
||||
* @param mixed $action Controller action name or array of actions
|
||||
* @param string $action Controller action name
|
||||
* @param string ... etc.
|
||||
* @param mixed $action,... Controller action name or array of actions
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/1257/allow
|
||||
*/
|
||||
public function allow() {
|
||||
public function allow($action) {
|
||||
$args = func_get_args();
|
||||
if (empty($args) || $args == array('*')) {
|
||||
$this->allowedActions = $this->_methods;
|
||||
|
@ -454,14 +451,12 @@ class AuthComponent extends Component {
|
|||
* `$this->Auth->deny(array('edit', 'add'));` or
|
||||
* `$this->Auth->deny('edit', 'add');`
|
||||
*
|
||||
* @param mixed $action Controller action name or array of actions
|
||||
* @param string $action Controller action name
|
||||
* @param string ... etc.
|
||||
* @param mixed $action,... Controller action name or array of actions
|
||||
* @return void
|
||||
* @see AuthComponent::allow()
|
||||
* @link http://book.cakephp.org/view/1258/deny
|
||||
*/
|
||||
public function deny() {
|
||||
public function deny($action) {
|
||||
$args = func_get_args();
|
||||
if (isset($args[0]) && is_array($args[0])) {
|
||||
$args = $args[0];
|
||||
|
@ -503,7 +498,7 @@ class AuthComponent extends Component {
|
|||
* @link http://book.cakephp.org/view/1261/login
|
||||
*/
|
||||
public function login($user = null) {
|
||||
$this->__setDefaults();
|
||||
$this->_setDefaults();
|
||||
|
||||
if (empty($user)) {
|
||||
$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
|
||||
* 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::$loginAction
|
||||
* @see AuthComponent::$loginAction
|
||||
* @return string AuthComponent::$logoutRedirect
|
||||
* @see AuthComponent::$logoutRedirect
|
||||
* @link http://book.cakephp.org/view/1262/logout
|
||||
*/
|
||||
public function logout() {
|
||||
$this->__setDefaults();
|
||||
$this->_setDefaults();
|
||||
if (empty($this->_authenticateObjects)) {
|
||||
$this->constructAuthenticate();
|
||||
}
|
||||
|
@ -615,6 +609,7 @@ class AuthComponent extends Component {
|
|||
* by credentials contained in $request.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public function identify(CakeRequest $request, CakeResponse $response) {
|
||||
|
@ -634,6 +629,7 @@ class AuthComponent extends Component {
|
|||
* loads the configured authentication objects.
|
||||
*
|
||||
* @return mixed either null on empty authenticate value, or an array of loaded objects.
|
||||
* @throws CakeException
|
||||
*/
|
||||
public function constructAuthenticate() {
|
||||
if (empty($this->authenticate)) {
|
||||
|
@ -676,7 +672,8 @@ class AuthComponent extends Component {
|
|||
/**
|
||||
* 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) {
|
||||
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.
|
||||
*
|
||||
* @return boolean true if the user is logged in, false otherwise
|
||||
* @access public
|
||||
*/
|
||||
public function loggedIn() {
|
||||
return $this->user() != array();
|
||||
|
|
|
@ -38,7 +38,6 @@ class CookieComponent extends Component {
|
|||
* $this->Cookie->name = 'CookieName';
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $name = 'CakeCookie';
|
||||
|
||||
|
@ -51,7 +50,6 @@ class CookieComponent extends Component {
|
|||
* $this->Cookie->time = '5 Days';
|
||||
*
|
||||
* @var mixed
|
||||
* @access public
|
||||
*/
|
||||
public $time = null;
|
||||
|
||||
|
@ -67,7 +65,6 @@ class CookieComponent extends Component {
|
|||
* The default value is the entire domain.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $path = '/';
|
||||
|
||||
|
@ -83,7 +80,6 @@ class CookieComponent extends Component {
|
|||
* Set $this->Cookie->domain = '.example.com'; in your controller beforeFilter
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
public $secure = false;
|
||||
|
||||
|
@ -108,14 +103,13 @@ class CookieComponent extends Component {
|
|||
* $this->Cookie->key = 'SomeRandomString';
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
public $key = null;
|
||||
|
||||
/**
|
||||
* HTTP only cookie
|
||||
*
|
||||
* Set to true to make HTTP only cookies. Cookies that are HTTP only
|
||||
* Set to true to make HTTP only cookies. Cookies that are HTTP only
|
||||
* are not accessible in Javascript.
|
||||
*
|
||||
* @var boolean
|
||||
|
@ -129,7 +123,6 @@ class CookieComponent extends Component {
|
|||
*
|
||||
* @see CookieComponent::read();
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $_values = array();
|
||||
|
||||
|
@ -140,7 +133,6 @@ class CookieComponent extends Component {
|
|||
* Defaults to Security::cipher();
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @todo add additional encryption methods
|
||||
*/
|
||||
protected $_type = 'cipher';
|
||||
|
@ -149,7 +141,6 @@ class CookieComponent extends Component {
|
|||
* Used to reset cookie time if $expire is passed to CookieComponent::write()
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $_reset = null;
|
||||
|
||||
|
@ -159,7 +150,6 @@ class CookieComponent extends Component {
|
|||
* This is controlled by CookieComponent::time;
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
protected $_expires = 0;
|
||||
|
||||
|
@ -180,6 +170,8 @@ class CookieComponent extends Component {
|
|||
/**
|
||||
* Start CookieComponent for use in the controller
|
||||
*
|
||||
* @param Controller $controller
|
||||
* @return void
|
||||
*/
|
||||
public function startup($controller) {
|
||||
$this->_expire($this->time);
|
||||
|
@ -205,6 +197,7 @@ class CookieComponent extends Component {
|
|||
* @param mixed $value Value
|
||||
* @param boolean $encrypt Set to true to encrypt value, false otherwise
|
||||
* @param string $expires Can be either Unix timestamp, or date string
|
||||
* @return void
|
||||
*/
|
||||
public function write($key, $value = null, $encrypt = true, $expires = null) {
|
||||
if (is_null($encrypt)) {
|
||||
|
@ -212,7 +205,7 @@ class CookieComponent extends Component {
|
|||
}
|
||||
$this->_encrypted = $encrypt;
|
||||
$this->_expire($expires);
|
||||
|
||||
|
||||
if (!is_array($key)) {
|
||||
$key = array($key => $value);
|
||||
}
|
||||
|
@ -327,7 +320,7 @@ class CookieComponent extends Component {
|
|||
* Will allow overriding default encryption method.
|
||||
*
|
||||
* @param string $type Encryption method
|
||||
* @access public
|
||||
* @return void
|
||||
* @todo NOT IMPLEMENTED
|
||||
*/
|
||||
public function type($type = 'cipher') {
|
||||
|
@ -345,7 +338,7 @@ class CookieComponent extends Component {
|
|||
* CookieComponent::write(string, string, boolean, '5 Days');
|
||||
*
|
||||
* @param mixed $expires Can be either Unix timestamp, or date string
|
||||
* @return int Unix timestamp
|
||||
* @return integer Unix timestamp
|
||||
*/
|
||||
protected function _expire($expires = null) {
|
||||
$now = time();
|
||||
|
@ -369,10 +362,11 @@ class CookieComponent extends Component {
|
|||
*
|
||||
* @param string $name Name for cookie
|
||||
* @param string $value Value for cookie
|
||||
* @return void
|
||||
*/
|
||||
protected function _write($name, $value) {
|
||||
$this->_setcookie(
|
||||
$this->name . $name, $this->_encrypt($value),
|
||||
$this->name . $name, $this->_encrypt($value),
|
||||
$this->_expires, $this->path, $this->domain, $this->secure, $this->httpOnly
|
||||
);
|
||||
|
||||
|
@ -390,7 +384,7 @@ class CookieComponent extends Component {
|
|||
*/
|
||||
protected function _delete($name) {
|
||||
$this->_setcookie(
|
||||
$this->name . $name, '',
|
||||
$this->name . $name, '',
|
||||
time() - 42000, $this->path, $this->domain, $this->secure, $this->httpOnly
|
||||
);
|
||||
}
|
||||
|
@ -402,6 +396,7 @@ class CookieComponent extends Component {
|
|||
* of the HTTP response, and should be handled there.
|
||||
*
|
||||
* @param string $name Name of the cookie
|
||||
* @param string $value Value of the cookie
|
||||
* @param integer $expire Time the cookie expires in
|
||||
* @param string $path Path the cookie applies to
|
||||
* @param string $domain Domain the cookie is for.
|
||||
|
|
|
@ -37,7 +37,6 @@ class EmailComponent extends Component {
|
|||
* Recipient of the email
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $to = null;
|
||||
|
||||
|
@ -45,7 +44,6 @@ class EmailComponent extends Component {
|
|||
* The mail which the email is sent from
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $from = null;
|
||||
|
||||
|
@ -53,7 +51,6 @@ class EmailComponent extends Component {
|
|||
* The email the recipient will reply to
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $replyTo = null;
|
||||
|
||||
|
@ -61,7 +58,6 @@ class EmailComponent extends Component {
|
|||
* The read receipt email
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $readReceipt = null;
|
||||
|
||||
|
@ -72,7 +68,6 @@ class EmailComponent extends Component {
|
|||
* - Unknown user
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $return = null;
|
||||
|
||||
|
@ -83,7 +78,6 @@ class EmailComponent extends Component {
|
|||
* The Recipient WILL be able to see this list
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $cc = array();
|
||||
|
||||
|
@ -94,7 +88,6 @@ class EmailComponent extends Component {
|
|||
* The Recipient WILL NOT be able to see this list
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $bcc = array();
|
||||
|
||||
|
@ -105,13 +98,12 @@ class EmailComponent extends Component {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
var $date = null;
|
||||
public $date = null;
|
||||
|
||||
/**
|
||||
* The subject of the email
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $subject = null;
|
||||
|
||||
|
@ -120,7 +112,6 @@ class EmailComponent extends Component {
|
|||
* Keys will be prefixed 'X-' as per RFC2822 Section 4.7.5
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $headers = array();
|
||||
|
||||
|
@ -130,7 +121,6 @@ class EmailComponent extends Component {
|
|||
* These will NOT be used if you are using safemode and mail()
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $additionalParams = null;
|
||||
|
||||
|
@ -138,7 +128,6 @@ class EmailComponent extends Component {
|
|||
* Layout for the View
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $layout = 'default';
|
||||
|
||||
|
@ -146,7 +135,6 @@ class EmailComponent extends Component {
|
|||
* Template for the view
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $template = null;
|
||||
|
||||
|
@ -158,7 +146,6 @@ class EmailComponent extends Component {
|
|||
* (which leads to doubling CR if CRLF is used).
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $lineFeed = PHP_EOL;
|
||||
|
||||
|
@ -171,7 +158,6 @@ class EmailComponent extends Component {
|
|||
* - both
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $sendAs = 'text';
|
||||
|
||||
|
@ -184,7 +170,6 @@ class EmailComponent extends Component {
|
|||
* - debug
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $delivery = 'mail';
|
||||
|
||||
|
@ -192,7 +177,6 @@ class EmailComponent extends Component {
|
|||
* charset the email is sent in
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $charset = 'utf-8';
|
||||
|
||||
|
@ -202,7 +186,6 @@ class EmailComponent extends Component {
|
|||
* Can be both absolute and relative paths
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $attachments = array();
|
||||
|
||||
|
@ -210,7 +193,6 @@ class EmailComponent extends Component {
|
|||
* What mailer should EmailComponent identify itself as
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $xMailer = 'CakePHP Email Component';
|
||||
|
||||
|
@ -218,7 +200,6 @@ class EmailComponent extends Component {
|
|||
* The list of paths to search if an attachment isnt absolute
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $filePaths = array();
|
||||
|
||||
|
@ -234,7 +215,6 @@ class EmailComponent extends Component {
|
|||
* - client
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1290/Sending-A-Message-Using-SMTP
|
||||
*/
|
||||
public $smtpOptions = array();
|
||||
|
@ -243,7 +223,6 @@ class EmailComponent extends Component {
|
|||
* Contains the rendered plain text message if one was sent.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $textMessage = null;
|
||||
|
||||
|
@ -251,7 +230,6 @@ class EmailComponent extends Component {
|
|||
* Contains the rendered HTML message if one was sent.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $htmlMessage = null;
|
||||
|
||||
|
@ -265,14 +243,13 @@ class EmailComponent extends Component {
|
|||
* could encounter delivery issues if you do not.
|
||||
*
|
||||
* @var mixed
|
||||
* @access public
|
||||
*/
|
||||
public $messageId = true;
|
||||
|
||||
/**
|
||||
* Controller reference
|
||||
*
|
||||
* @var object Controller
|
||||
* @var Controller
|
||||
*/
|
||||
protected $_controller = null;
|
||||
|
||||
|
@ -290,7 +267,8 @@ class EmailComponent extends Component {
|
|||
/**
|
||||
* Initialize component
|
||||
*
|
||||
* @param object $controller Instantiating controller
|
||||
* @param Controller $controller Instantiating controller
|
||||
* @return void
|
||||
*/
|
||||
public function initialize($controller) {
|
||||
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.
|
||||
*
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/1285/Sending-Multiple-Emails-in-a-loop
|
||||
*/
|
||||
public function reset() {
|
||||
|
@ -427,9 +406,8 @@ class EmailComponent extends Component {
|
|||
*
|
||||
* @param string $attachment Attachment file name to find
|
||||
* @return string Path to located file
|
||||
* @access private
|
||||
*/
|
||||
function _findFiles($attachment) {
|
||||
protected function _findFiles($attachment) {
|
||||
if (file_exists($attachment)) {
|
||||
return $attachment;
|
||||
}
|
||||
|
@ -447,9 +425,8 @@ class EmailComponent extends Component {
|
|||
*
|
||||
* @param string $subject String to encode
|
||||
* @return string Encoded string
|
||||
* @access private
|
||||
*/
|
||||
function _encode($subject) {
|
||||
protected function _encode($subject) {
|
||||
$subject = $this->_strip($subject);
|
||||
|
||||
$nl = "\r\n";
|
||||
|
@ -494,9 +471,8 @@ class EmailComponent extends Component {
|
|||
* @param string $value Value to strip
|
||||
* @param boolean $message Set to true to indicate main message content
|
||||
* @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 .= '|charset\=|mime-version\:|multipart/mixed|(?:[^a-z]to|b?cc)\:.*';
|
||||
|
||||
|
|
|
@ -101,9 +101,10 @@ class PaginatorComponent extends Component {
|
|||
*
|
||||
* @param mixed $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel')
|
||||
* @param mixed $scope Additional find conditions to use while paginating
|
||||
* @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.
|
||||
* @return array Model query results
|
||||
* @throws MissingModelException
|
||||
*/
|
||||
public function paginate($object = null, $scope = array(), $whitelist = array()) {
|
||||
if (is_array($object)) {
|
||||
|
@ -307,7 +308,7 @@ class PaginatorComponent extends Component {
|
|||
}
|
||||
|
||||
/**
|
||||
* Validate that the desired sorting can be performed on the $object. Only fields or
|
||||
* Validate that the desired sorting can be performed on the $object. Only fields or
|
||||
* virtualFields can be sorted on. The direction param will also be sanitized. Lastly
|
||||
* sort + direction keys will be converted into the model friendly order key.
|
||||
*
|
||||
|
@ -330,14 +331,14 @@ class PaginatorComponent extends Component {
|
|||
}
|
||||
$options['order'] = array($options['sort'] => $direction);
|
||||
}
|
||||
|
||||
|
||||
if (!empty($whitelist)) {
|
||||
$field = key($options['order']);
|
||||
if (!in_array($field, $whitelist)) {
|
||||
$options['order'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($options['order']) && is_array($options['order'])) {
|
||||
$alias = $object->alias ;
|
||||
$key = $field = key($options['order']);
|
||||
|
@ -356,7 +357,7 @@ class PaginatorComponent extends Component {
|
|||
$options['order'][$alias . '.' . $field] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class RequestHandlerComponent extends Component {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $__renderType = null;
|
||||
protected $_renderType = null;
|
||||
|
||||
/**
|
||||
* A mapping between extensions and deserializers for request bodies of that type.
|
||||
|
@ -80,7 +80,7 @@ class RequestHandlerComponent extends Component {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $__inputTypeMap = array(
|
||||
protected $_inputTypeMap = array(
|
||||
'json' => array('json_decode', true)
|
||||
);
|
||||
|
||||
|
@ -90,18 +90,18 @@ class RequestHandlerComponent extends Component {
|
|||
* @param ComponentCollection $collection ComponentCollection object.
|
||||
* @param array $settings Array of settings.
|
||||
*/
|
||||
function __construct(ComponentCollection $collection, $settings = array()) {
|
||||
$this->addInputType('xml', array(array($this, '_convertXml')));
|
||||
public function __construct(ComponentCollection $collection, $settings = array()) {
|
||||
$this->addInputType('xml', array(array($this, 'convertXml')));
|
||||
parent::__construct($collection, $settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the component, gets a reference to Controller::$parameters, and
|
||||
* checks to see if a file extension has been parsed by the Router. Or if the
|
||||
* checks to see if a file extension has been parsed by the Router. Or if the
|
||||
* 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
|
||||
*
|
||||
* @param object $controller A reference to the controller
|
||||
* @param Controller $controller A reference to the controller
|
||||
* @param array $settings Array of settings to _set().
|
||||
* @return void
|
||||
* @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
|
||||
* 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
|
||||
*/
|
||||
public function startup($controller) {
|
||||
|
@ -160,7 +160,7 @@ class RequestHandlerComponent extends Component {
|
|||
$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)) {
|
||||
$input = call_user_func_array(array($controller->request, 'input'), $handler);
|
||||
$controller->request->data = $input;
|
||||
|
@ -172,11 +172,10 @@ class RequestHandlerComponent extends Component {
|
|||
* Helper method to parse xml input data, due to lack of anonymous functions
|
||||
* this lives here.
|
||||
*
|
||||
* @param string $xml
|
||||
* @param string $xml
|
||||
* @return array Xml array data
|
||||
* @access protected
|
||||
*/
|
||||
public function _convertXml($xml) {
|
||||
public function convertXml($xml) {
|
||||
try {
|
||||
$xml = Xml::build($xml);
|
||||
if (isset($xml->data)) {
|
||||
|
@ -191,9 +190,11 @@ class RequestHandlerComponent extends Component {
|
|||
/**
|
||||
* Handles (fakes) redirects for Ajax requests using requestAction()
|
||||
*
|
||||
* @param object $controller A reference to the controller
|
||||
* @param mixed $url A string or array containing the redirect location
|
||||
* @param mixed HTTP Status for redirect
|
||||
* @param Controller $controller A reference to the controller
|
||||
* @param string|array $url A string or array containing the redirect location
|
||||
* @param mixed $status HTTP Status for redirect
|
||||
* @param boolean $exit
|
||||
* @return void
|
||||
*/
|
||||
public function beforeRedirect($controller, $url, $status = null, $exit = true) {
|
||||
if (!$this->request->is('ajax')) {
|
||||
|
@ -238,7 +239,7 @@ class RequestHandlerComponent extends Component {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function isSSL() {
|
||||
|
@ -285,7 +286,7 @@ class RequestHandlerComponent extends Component {
|
|||
/**
|
||||
* Returns true if the client accepts WAP content
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function isWap() {
|
||||
return $this->prefers('wap');
|
||||
|
@ -373,6 +374,7 @@ class RequestHandlerComponent extends Component {
|
|||
/**
|
||||
* Gets remote client IP
|
||||
*
|
||||
* @param boolean $safe
|
||||
* @return string Client IP address
|
||||
* @deprecated use $this->request->clientIp() from your, controller instead.
|
||||
*/
|
||||
|
@ -435,7 +437,7 @@ class RequestHandlerComponent extends Component {
|
|||
if (!$this->request->is('post') && !$this->request->is('put')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
list($contentType) = explode(';', env('CONTENT_TYPE'));
|
||||
if ($type == null) {
|
||||
return $this->mapType($contentType);
|
||||
|
@ -496,7 +498,7 @@ class RequestHandlerComponent extends Component {
|
|||
|
||||
/**
|
||||
* Sets the layout and template paths for the content type defined by $type.
|
||||
*
|
||||
*
|
||||
* ### Usage:
|
||||
*
|
||||
* Render the response as an 'ajax' response.
|
||||
|
@ -507,7 +509,7 @@ class RequestHandlerComponent extends Component {
|
|||
*
|
||||
* `$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 array $options Array of options to use
|
||||
* @return void
|
||||
|
@ -528,13 +530,13 @@ class RequestHandlerComponent extends Component {
|
|||
}
|
||||
$controller->ext = '.ctp';
|
||||
|
||||
if (empty($this->__renderType)) {
|
||||
if (empty($this->_renderType)) {
|
||||
$controller->viewPath .= DS . $type;
|
||||
} else {
|
||||
$remove = preg_replace("/([\/\\\\]{$this->__renderType})$/", DS . $type, $controller->viewPath);
|
||||
$remove = preg_replace("/([\/\\\\]{$this->_renderType})$/", DS . $type, $controller->viewPath);
|
||||
$controller->viewPath = $remove;
|
||||
}
|
||||
$this->__renderType = $type;
|
||||
$this->_renderType = $type;
|
||||
$controller->layoutPath = $type;
|
||||
|
||||
if ($this->response->getMimeType($type)) {
|
||||
|
@ -650,7 +652,7 @@ class RequestHandlerComponent extends Component {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add a new mapped input type. Mapped input types are automatically
|
||||
* Add a new mapped input type. Mapped input types are automatically
|
||||
* converted by RequestHandlerComponent during the startup() callback.
|
||||
*
|
||||
* @param string $type The type alias being converted, ie. json
|
||||
|
@ -658,11 +660,12 @@ class RequestHandlerComponent extends Component {
|
|||
* be the handling callback, all other arguments should be additional parameters
|
||||
* for the handler.
|
||||
* @return void
|
||||
* @throws CakeException
|
||||
*/
|
||||
public function addInputType($type, $handler) {
|
||||
if (!is_array($handler) || !isset($handler[0]) || !is_callable($handler[0])) {
|
||||
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
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $blackHoleCallback = null;
|
||||
|
||||
|
@ -41,7 +40,6 @@ class SecurityComponent extends Component {
|
|||
* List of controller actions for which a POST request is required
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @see SecurityComponent::requirePost()
|
||||
*/
|
||||
public $requirePost = array();
|
||||
|
@ -50,7 +48,6 @@ class SecurityComponent extends Component {
|
|||
* List of controller actions for which a GET request is required
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @see SecurityComponent::requireGet()
|
||||
*/
|
||||
public $requireGet = array();
|
||||
|
@ -59,7 +56,6 @@ class SecurityComponent extends Component {
|
|||
* List of controller actions for which a PUT request is required
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @see SecurityComponent::requirePut()
|
||||
*/
|
||||
public $requirePut = array();
|
||||
|
@ -68,7 +64,6 @@ class SecurityComponent extends Component {
|
|||
* List of controller actions for which a DELETE request is required
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @see SecurityComponent::requireDelete()
|
||||
*/
|
||||
public $requireDelete = array();
|
||||
|
@ -77,7 +72,6 @@ class SecurityComponent extends Component {
|
|||
* List of actions that require an SSL-secured connection
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @see SecurityComponent::requireSecure()
|
||||
*/
|
||||
public $requireSecure = array();
|
||||
|
@ -86,7 +80,6 @@ class SecurityComponent extends Component {
|
|||
* List of actions that require a valid authentication key
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @see SecurityComponent::requireAuth()
|
||||
*/
|
||||
public $requireAuth = array();
|
||||
|
@ -96,7 +89,6 @@ class SecurityComponent extends Component {
|
|||
* requests.
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @see SecurityComponent::requireAuth()
|
||||
*/
|
||||
public $allowedControllers = array();
|
||||
|
@ -106,7 +98,6 @@ class SecurityComponent extends Component {
|
|||
* requests.
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
* @see SecurityComponent::requireAuth()
|
||||
*/
|
||||
public $allowedActions = array();
|
||||
|
@ -135,7 +126,6 @@ class SecurityComponent extends Component {
|
|||
* services, etc.
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
public $validatePost = true;
|
||||
|
||||
|
@ -150,7 +140,7 @@ class SecurityComponent extends Component {
|
|||
|
||||
/**
|
||||
* The duration from when a CSRF token is created that it will expire on.
|
||||
* Each form/page request will generate a new token that can only be submitted once unless
|
||||
* Each form/page request will generate a new token that can only be submitted once unless
|
||||
* it expires. Can be any value compatible with strtotime()
|
||||
*
|
||||
* @var string
|
||||
|
@ -171,7 +161,6 @@ class SecurityComponent extends Component {
|
|||
* Other components used by the Security component
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $components = array('Session');
|
||||
|
||||
|
@ -192,7 +181,7 @@ class SecurityComponent extends Component {
|
|||
/**
|
||||
* Component startup. All security checking happens here.
|
||||
*
|
||||
* @param object $controller Instantiating controller
|
||||
* @param Controller $controller Instantiating controller
|
||||
* @return void
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
|
||||
* @access public
|
||||
* @see SecurityComponent::$blackHoleCallback
|
||||
* @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
|
||||
*
|
||||
* @param object $controller Instantiating controller
|
||||
* @return bool true if $method is required
|
||||
* @param Controller $controller Instantiating controller
|
||||
* @return boolean true if $method is required
|
||||
*/
|
||||
protected function _methodsRequired($controller) {
|
||||
foreach (array('Post', 'Get', 'Put', 'Delete') as $method) {
|
||||
|
@ -348,8 +336,8 @@ class SecurityComponent extends Component {
|
|||
/**
|
||||
* Check if access requires secure connection
|
||||
*
|
||||
* @param object $controller Instantiating controller
|
||||
* @return bool true if secure connection required
|
||||
* @param Controller $controller Instantiating controller
|
||||
* @return boolean true if secure connection required
|
||||
*/
|
||||
protected function _secureRequired($controller) {
|
||||
if (is_array($this->requireSecure) && !empty($this->requireSecure)) {
|
||||
|
@ -369,8 +357,8 @@ class SecurityComponent extends Component {
|
|||
/**
|
||||
* Check if authentication is required
|
||||
*
|
||||
* @param object $controller Instantiating controller
|
||||
* @return bool true if authentication required
|
||||
* @param Controller $controller Instantiating controller
|
||||
* @return boolean true if authentication required
|
||||
*/
|
||||
protected function _authRequired($controller) {
|
||||
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) {
|
||||
|
@ -404,8 +392,8 @@ class SecurityComponent extends Component {
|
|||
/**
|
||||
* Validate submitted form
|
||||
*
|
||||
* @param object $controller Instantiating controller
|
||||
* @return bool true if submitted form is valid
|
||||
* @param Controller $controller Instantiating controller
|
||||
* @return boolean true if submitted form is valid
|
||||
*/
|
||||
protected function _validatePost($controller) {
|
||||
if (empty($controller->request->data)) {
|
||||
|
@ -484,8 +472,8 @@ class SecurityComponent extends Component {
|
|||
/**
|
||||
* Add authentication key for new form posts
|
||||
*
|
||||
* @param object $controller Instantiating controller
|
||||
* @return bool Success
|
||||
* @param Controller $controller Instantiating controller
|
||||
* @return boolean Success
|
||||
*/
|
||||
protected function _generateToken($controller) {
|
||||
if (isset($controller->request->params['requested']) && $controller->request->params['requested'] === 1) {
|
||||
|
@ -510,7 +498,7 @@ class SecurityComponent extends Component {
|
|||
if (!empty($tokenData['csrfTokens']) && is_array($tokenData['csrfTokens'])) {
|
||||
$token['csrfTokens'] = $this->_expireTokens($tokenData['csrfTokens']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->csrfCheck && ($this->csrfUseOnce || empty($token['csrfTokens'])) ) {
|
||||
$token['csrfTokens'][$authKey] = strtotime($this->csrfExpires);
|
||||
}
|
||||
|
@ -551,7 +539,7 @@ class SecurityComponent extends Component {
|
|||
* Uses a simple timeout to expire the tokens.
|
||||
*
|
||||
* @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) {
|
||||
$now = time();
|
||||
|
@ -566,7 +554,7 @@ class SecurityComponent extends Component {
|
|||
/**
|
||||
* 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 array $params Parameters to send to method
|
||||
* @return mixed Controller callback method's response
|
||||
|
|
|
@ -32,7 +32,7 @@ App::uses('CakeSession', 'Model/Datasource');
|
|||
class SessionComponent extends Component {
|
||||
|
||||
/**
|
||||
* Get / Set the userAgent
|
||||
* Get / Set the userAgent
|
||||
*
|
||||
* @param string $userAgent Set the userAgent
|
||||
* @return void
|
||||
|
@ -121,6 +121,7 @@ class SessionComponent extends Component {
|
|||
* @param string $element Element to wrap flash message in.
|
||||
* @param array $params Parameters to be sent to layout as view variables
|
||||
* @param string $key Message key, default is 'flash'
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/1313/setFlash
|
||||
*/
|
||||
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
|
||||
* with the specified id
|
||||
*
|
||||
* @param $id string
|
||||
* @param string $id
|
||||
* @return string
|
||||
*/
|
||||
public function id($id = null) {
|
||||
|
|
|
@ -69,7 +69,7 @@ class ComponentCollection extends ObjectCollection {
|
|||
* );
|
||||
* }}}
|
||||
* All calls to the `Email` component would use `AliasedEmail` instead.
|
||||
*
|
||||
*
|
||||
* @param string $component Component name to load
|
||||
* @param array $settings Settings for the component.
|
||||
* @return Component A component object, Either the existing loaded component or a new one.
|
||||
|
|
|
@ -47,7 +47,15 @@ App::uses('View', 'View');
|
|||
* using Router::connect().
|
||||
*
|
||||
* @package Cake.Controller
|
||||
* @link http://book.cakephp.org/view/956/Introduction
|
||||
* @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
|
||||
*/
|
||||
class Controller extends Object {
|
||||
|
||||
|
@ -293,7 +301,7 @@ class Controller extends Object {
|
|||
*
|
||||
* @param CakeRequest $request Request object for this controller. Can be null for testing,
|
||||
* but expect that features that use the request parameters will not work.
|
||||
* @param CakeResponse $response Response object for this controller.
|
||||
* @param CakeResponse $response Response object for this controller.
|
||||
*/
|
||||
public function __construct($request = null, $response = null) {
|
||||
if ($this->name === null) {
|
||||
|
@ -326,6 +334,7 @@ class Controller extends Object {
|
|||
* Provides backwards compatibility to avoid problems with empty and isset to alias properties.
|
||||
* Lazy loads models using the loadModel() method if declared in $uses
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function __isset($name) {
|
||||
|
@ -366,6 +375,7 @@ class Controller extends Object {
|
|||
* Provides backwards compatibility access to the request object properties.
|
||||
* Also provides the params alias.
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function __get($name) {
|
||||
|
@ -393,6 +403,8 @@ class Controller extends Object {
|
|||
/**
|
||||
* Provides backwards compatibility access for setting values to the request object.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function __set($name, $value) {
|
||||
|
@ -443,11 +455,12 @@ class Controller extends Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* Dispatches the controller action. Checks that the action
|
||||
* Dispatches the controller action. Checks that the action
|
||||
* exists and isn't private.
|
||||
*
|
||||
* @param CakeRequest $request
|
||||
* @return The resulting response.
|
||||
* @return mixed The resulting response.
|
||||
* @throws PrivateActionException, MissingActionException
|
||||
*/
|
||||
public function invokeAction(CakeRequest $request) {
|
||||
$reflection = new ReflectionClass($this);
|
||||
|
@ -474,7 +487,7 @@ class Controller extends Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if the request's action is marked as private, with an underscore,
|
||||
* Check if the request's action is marked as private, with an underscore,
|
||||
* or if the request is attempting to directly accessing a prefixed action.
|
||||
*
|
||||
* @param ReflectionMethod $method The method to be invoked.
|
||||
|
@ -483,7 +496,7 @@ class Controller extends Object {
|
|||
*/
|
||||
protected function _isPrivateAction(ReflectionMethod $method, CakeRequest $request) {
|
||||
$privateAction = (
|
||||
$method->name[0] === '_' ||
|
||||
$method->name[0] === '_' ||
|
||||
!$method->isPublic() ||
|
||||
!in_array($method->name, $this->methods)
|
||||
);
|
||||
|
@ -513,7 +526,7 @@ class Controller extends Object {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function __mergeVars() {
|
||||
protected function _mergeControllerVars() {
|
||||
$pluginController = $pluginDot = null;
|
||||
|
||||
if (!empty($this->plugin)) {
|
||||
|
@ -571,7 +584,7 @@ class Controller extends Object {
|
|||
* @throws MissingModelException
|
||||
*/
|
||||
public function constructClasses() {
|
||||
$this->__mergeVars();
|
||||
$this->_mergeControllerVars();
|
||||
$this->Components->init($this);
|
||||
if ($this->uses) {
|
||||
$this->uses = (array) $this->uses;
|
||||
|
@ -869,7 +882,7 @@ class Controller extends Object {
|
|||
$this->request->params['models'][$className] = compact('plugin', 'className');
|
||||
}
|
||||
} if (!empty($this->modelClass) && ($this->uses === false || $this->uses === array())) {
|
||||
$this->request->params['models'][$this->modelClass] = array('plugin' => $this->plugin, 'className' => $this->modelClass);
|
||||
$this->request->params['models'][$this->modelClass] = array('plugin' => $this->plugin, 'className' => $this->modelClass);
|
||||
}
|
||||
|
||||
$models = ClassRegistry::keys();
|
||||
|
@ -1017,6 +1030,7 @@ class Controller extends Object {
|
|||
* Called before the controller action. You can use this method to configure and customize components
|
||||
* or perform logic that needs to happen before each controller action.
|
||||
*
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/984/Callbacks
|
||||
*/
|
||||
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
|
||||
* to perform logic or set view variables that are required on every request.
|
||||
*
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/984/Callbacks
|
||||
*/
|
||||
public function beforeRender() {
|
||||
|
@ -1051,6 +1066,7 @@ class Controller extends Object {
|
|||
/**
|
||||
* Called after the controller action is run and rendered.
|
||||
*
|
||||
* @return void
|
||||
* @link http://book.cakephp.org/view/984/Callbacks
|
||||
*/
|
||||
public function afterFilter() {
|
||||
|
@ -1063,10 +1079,22 @@ class Controller extends Object {
|
|||
* @return boolean Success
|
||||
* @link http://book.cakephp.org/view/984/Callbacks
|
||||
*/
|
||||
public function _beforeScaffold($method) {
|
||||
public function beforeScaffold($method) {
|
||||
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.
|
||||
*
|
||||
|
@ -1074,10 +1102,22 @@ class Controller extends Object {
|
|||
* @return boolean Success
|
||||
* @link http://book.cakephp.org/view/984/Callbacks
|
||||
*/
|
||||
public function _afterScaffoldSave($method) {
|
||||
public function afterScaffoldSave($method) {
|
||||
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.
|
||||
*
|
||||
|
@ -1085,10 +1125,22 @@ class Controller extends Object {
|
|||
* @return boolean Success
|
||||
* @link http://book.cakephp.org/view/984/Callbacks
|
||||
*/
|
||||
public function _afterScaffoldSaveError($method) {
|
||||
public function afterScaffoldSaveError($method) {
|
||||
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.
|
||||
* If not it will render a scaffold error.
|
||||
|
@ -1098,7 +1150,20 @@ class Controller extends Object {
|
|||
* @return boolean Success
|
||||
* @link http://book.cakephp.org/view/984/Callbacks
|
||||
*/
|
||||
public function _scaffoldError($method) {
|
||||
public function scaffoldError($method) {
|
||||
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
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $name = 'Pages';
|
||||
|
||||
|
@ -43,7 +42,6 @@ class PagesController extends AppController {
|
|||
* Default helper
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $helpers = array('Html', 'Session');
|
||||
|
||||
|
@ -51,7 +49,6 @@ class PagesController extends AppController {
|
|||
* This controller does not use a model
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $uses = array();
|
||||
|
||||
|
@ -59,6 +56,7 @@ class PagesController extends AppController {
|
|||
* Displays a view
|
||||
*
|
||||
* @param mixed What page to display
|
||||
* @return void
|
||||
*/
|
||||
public function display() {
|
||||
$path = func_get_args();
|
||||
|
|
|
@ -78,7 +78,6 @@ class Scaffold {
|
|||
* valid session.
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
protected $_validSession = null;
|
||||
|
||||
|
@ -86,9 +85,8 @@ class Scaffold {
|
|||
* List of variables to collect from the associated controller
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $__passedVars = array(
|
||||
protected $_passedVars = array(
|
||||
'layout', 'name', 'viewPath', 'request'
|
||||
);
|
||||
|
||||
|
@ -96,7 +94,6 @@ class Scaffold {
|
|||
* Title HTML element for current scaffolded view
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $scaffoldTitle = null;
|
||||
|
||||
|
@ -105,13 +102,14 @@ class Scaffold {
|
|||
*
|
||||
* @param Controller $controller Controller to scaffold
|
||||
* @param CakeRequest $request Request parameters.
|
||||
* @throws MissingModelException
|
||||
*/
|
||||
public function __construct(Controller $controller, CakeRequest $request) {
|
||||
$this->controller = $controller;
|
||||
|
||||
$count = count($this->__passedVars);
|
||||
$count = count($this->_passedVars);
|
||||
for ($j = 0; $j < $count; $j++) {
|
||||
$var = $this->__passedVars[$j];
|
||||
$var = $this->_passedVars[$j];
|
||||
$this->{$var} = $controller->{$var};
|
||||
}
|
||||
|
||||
|
@ -157,9 +155,10 @@ class Scaffold {
|
|||
*
|
||||
* @param CakeRequest $request Request Object for scaffolding
|
||||
* @return mixed A rendered view of a row from Models database table
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
protected function _scaffoldView(CakeRequest $request) {
|
||||
if ($this->controller->_beforeScaffold('view')) {
|
||||
if ($this->controller->beforeScaffold('view')) {
|
||||
if (isset($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
|
||||
);
|
||||
$this->controller->render($this->request['action'], $this->layout);
|
||||
} elseif ($this->controller->_scaffoldError('view') === false) {
|
||||
} elseif ($this->controller->scaffoldError('view') === false) {
|
||||
return $this->_scaffoldError();
|
||||
}
|
||||
}
|
||||
|
@ -184,13 +183,13 @@ class Scaffold {
|
|||
* @return mixed A rendered view listing rows from Models database table
|
||||
*/
|
||||
protected function _scaffoldIndex($params) {
|
||||
if ($this->controller->_beforeScaffold('index')) {
|
||||
if ($this->controller->beforeScaffold('index')) {
|
||||
$this->ScaffoldModel->recursive = 0;
|
||||
$this->controller->set(
|
||||
Inflector::variable($this->controller->name), $this->controller->paginate()
|
||||
);
|
||||
$this->controller->render($this->request['action'], $this->layout);
|
||||
} elseif ($this->controller->_scaffoldError('index') === false) {
|
||||
} elseif ($this->controller->scaffoldError('index') === false) {
|
||||
return $this->_scaffoldError();
|
||||
}
|
||||
}
|
||||
|
@ -215,6 +214,7 @@ class Scaffold {
|
|||
* @param CakeRequest $request Request Object for scaffolding
|
||||
* @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
|
||||
* @throws NotFoundException
|
||||
*/
|
||||
protected function _scaffoldSave(CakeRequest $request, $action = 'edit') {
|
||||
$formAction = 'edit';
|
||||
|
@ -224,7 +224,7 @@ class Scaffold {
|
|||
$success = __d('cake', 'saved');
|
||||
}
|
||||
|
||||
if ($this->controller->_beforeScaffold($action)) {
|
||||
if ($this->controller->beforeScaffold($action)) {
|
||||
if ($action == 'edit') {
|
||||
if (isset($request->params['pass'][0])) {
|
||||
$this->ScaffoldModel->id = $request['pass'][0];
|
||||
|
@ -240,7 +240,7 @@ class Scaffold {
|
|||
}
|
||||
|
||||
if ($this->ScaffoldModel->save($request->data)) {
|
||||
if ($this->controller->_afterScaffoldSave($action)) {
|
||||
if ($this->controller->afterScaffoldSave($action)) {
|
||||
$message = __d('cake',
|
||||
'The %1$s has been %2$s',
|
||||
Inflector::humanize($this->modelKey),
|
||||
|
@ -248,7 +248,7 @@ class Scaffold {
|
|||
);
|
||||
return $this->_sendMessage($message);
|
||||
} else {
|
||||
return $this->controller->_afterScaffoldSaveError($action);
|
||||
return $this->controller->afterScaffoldSaveError($action);
|
||||
}
|
||||
} else {
|
||||
if ($this->_validSession) {
|
||||
|
@ -277,7 +277,7 @@ class Scaffold {
|
|||
}
|
||||
|
||||
return $this->_scaffoldForm($formAction);
|
||||
} elseif ($this->controller->_scaffoldError($action) === false) {
|
||||
} elseif ($this->controller->scaffoldError($action) === false) {
|
||||
return $this->_scaffoldError();
|
||||
}
|
||||
}
|
||||
|
@ -285,11 +285,12 @@ class Scaffold {
|
|||
/**
|
||||
* 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
|
||||
* @throws MethodNotAllowedException, NotFoundException
|
||||
*/
|
||||
protected function _scaffoldDelete(CakeRequest $request) {
|
||||
if ($this->controller->_beforeScaffold('delete')) {
|
||||
if ($this->controller->beforeScaffold('delete')) {
|
||||
if (!$request->is('post')) {
|
||||
throw new MethodNotAllowedException();
|
||||
}
|
||||
|
@ -312,7 +313,7 @@ class Scaffold {
|
|||
);
|
||||
return $this->_sendMessage($message);
|
||||
}
|
||||
} elseif ($this->controller->_scaffoldError('delete') === false) {
|
||||
} elseif ($this->controller->scaffoldError('delete') === false) {
|
||||
return $this->_scaffoldError();
|
||||
}
|
||||
}
|
||||
|
@ -349,6 +350,7 @@ class Scaffold {
|
|||
*
|
||||
* @param CakeRequest $request Request object for scaffolding
|
||||
* @return mixed A rendered view of scaffold action, or showing the error
|
||||
* @throws MissingActionException, MissingDatabaseException
|
||||
*/
|
||||
protected function _scaffold(CakeRequest $request) {
|
||||
$db = ConnectionManager::getDataSource($this->ScaffoldModel->useDbConfig);
|
||||
|
|
|
@ -122,50 +122,40 @@ class App {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private 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();
|
||||
protected static $_map = array();
|
||||
|
||||
/**
|
||||
* Holds and key => value array of object types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $__objects = array();
|
||||
protected static $_objects = array();
|
||||
|
||||
/**
|
||||
* Holds the location of each class
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $__classMap = array();
|
||||
protected static $_classMap = array();
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $__packageFormat = array();
|
||||
protected static $_packageFormat = array();
|
||||
|
||||
/**
|
||||
* Maps an old style CakePHP class type to the corresponding package
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $legacy = array(
|
||||
'models' => 'Model',
|
||||
|
@ -182,19 +172,22 @@ class App {
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $_objectCacheChange = false;
|
||||
protected static $_objectCacheChange = false;
|
||||
|
||||
/**
|
||||
* Indicates the the Application is in the bootstrapping process. Used to better cache
|
||||
* loaded classes while the cache libraries have not been yet initialized
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public static $bootstrapping = false;
|
||||
|
||||
|
@ -219,8 +212,8 @@ class App {
|
|||
if (!empty($plugin)) {
|
||||
$path = array();
|
||||
$pluginPath = self::pluginPath($plugin);
|
||||
if (!empty(self::$__packageFormat[$type])) {
|
||||
foreach (self::$__packageFormat[$type] as $f) {
|
||||
if (!empty(self::$_packageFormat[$type])) {
|
||||
foreach (self::$_packageFormat[$type] as $f) {
|
||||
$path[] = sprintf($f, $pluginPath);
|
||||
}
|
||||
}
|
||||
|
@ -228,10 +221,10 @@ class App {
|
|||
return $path;
|
||||
}
|
||||
|
||||
if (!isset(self::$__packages[$type])) {
|
||||
if (!isset(self::$_packages[$type])) {
|
||||
return array();
|
||||
}
|
||||
return self::$__packages[$type];
|
||||
return self::$_packages[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,8 +247,8 @@ class App {
|
|||
* @return void
|
||||
*/
|
||||
public static function build($paths = array(), $mode = App::PREPEND) {
|
||||
if (empty(self::$__packageFormat)) {
|
||||
self::$__packageFormat = array(
|
||||
if (empty(self::$_packageFormat)) {
|
||||
self::$_packageFormat = array(
|
||||
'Model' => array(
|
||||
'%s' . 'Model' . DS,
|
||||
'%s' . 'models' . DS
|
||||
|
@ -330,7 +323,7 @@ class App {
|
|||
if (!empty(self::$legacy[$type])) {
|
||||
$type = self::$legacy[$type];
|
||||
}
|
||||
self::$__packages[$type] = (array)$new;
|
||||
self::$_packages[$type] = (array)$new;
|
||||
self::objects($type, null, false);
|
||||
}
|
||||
return $paths;
|
||||
|
@ -347,28 +340,28 @@ class App {
|
|||
|
||||
$paths = $legacyPaths;
|
||||
$defaults = array();
|
||||
foreach (self::$__packageFormat as $package => $format) {
|
||||
foreach (self::$_packageFormat as $package => $format) {
|
||||
foreach ($format as $f) {
|
||||
$defaults[$package][] = sprintf($f, APP);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($defaults as $type => $default) {
|
||||
if (empty(self::$__packages[$type]) || empty($paths)) {
|
||||
self::$__packages[$type] = $default;
|
||||
if (empty(self::$_packages[$type]) || empty($paths)) {
|
||||
self::$_packages[$type] = $default;
|
||||
}
|
||||
|
||||
if (!empty($paths[$type])) {
|
||||
if ($mode === App::PREPEND) {
|
||||
$path = array_merge((array)$paths[$type], self::$__packages[$type]);
|
||||
$path = array_merge((array)$paths[$type], self::$_packages[$type]);
|
||||
} else {
|
||||
$path = array_merge(self::$__packages[$type], (array)$paths[$type]);
|
||||
$path = array_merge(self::$_packages[$type], (array)$paths[$type]);
|
||||
}
|
||||
} 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) {
|
||||
$themeDir = 'Themed' . DS . Inflector::camelize($theme);
|
||||
foreach (self::$__packages['View'] as $path) {
|
||||
foreach (self::$_packages['View'] as $path) {
|
||||
if (is_dir($path . $themeDir)) {
|
||||
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);
|
||||
}
|
||||
|
||||
if (empty(self::$__objects) && $cache === true) {
|
||||
self::$__objects = Cache::read('object_map', '_cake_core_');
|
||||
if (empty(self::$_objects) && $cache === true) {
|
||||
self::$_objects = Cache::read('object_map', '_cake_core_');
|
||||
}
|
||||
|
||||
$cacheLocation = empty($plugin) ? 'app' : $plugin;
|
||||
|
||||
if ($cache !== true || !isset(self::$__objects[$cacheLocation][$name])) {
|
||||
if ($cache !== true || !isset(self::$_objects[$cacheLocation][$name])) {
|
||||
$objects = array();
|
||||
|
||||
if (empty($path)) {
|
||||
|
@ -506,13 +499,13 @@ class App {
|
|||
return $objects;
|
||||
}
|
||||
|
||||
self::$__objects[$cacheLocation][$name] = $objects;
|
||||
self::$_objects[$cacheLocation][$name] = $objects;
|
||||
if ($cache) {
|
||||
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 $location the package name
|
||||
* @return void
|
||||
*/
|
||||
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`
|
||||
*
|
||||
* @param string $className the name of the class to load
|
||||
* @return boolean
|
||||
*/
|
||||
public static function load($className) {
|
||||
if (!isset(self::$__classMap[$className])) {
|
||||
if (!isset(self::$_classMap[$className])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($file = self::__mapped($className)) {
|
||||
if ($file = self::_mapped($className)) {
|
||||
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));
|
||||
$paths = self::path($package, $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[] = CAKE . $package . DS;
|
||||
}
|
||||
|
@ -562,7 +557,7 @@ class App {
|
|||
foreach ($paths as $path) {
|
||||
$file = $path . $className . '.php';
|
||||
if (file_exists($file)) {
|
||||
self::__map($file, $className);
|
||||
self::_map($file, $className);
|
||||
return include $file;
|
||||
}
|
||||
}
|
||||
|
@ -578,7 +573,7 @@ class App {
|
|||
}
|
||||
foreach ($tries as $file) {
|
||||
if (file_exists($file)) {
|
||||
self::__map($file, $className);
|
||||
self::_map($file, $className);
|
||||
return include $file;
|
||||
}
|
||||
}
|
||||
|
@ -594,8 +589,8 @@ class App {
|
|||
* @return string package name or null if not declared
|
||||
*/
|
||||
public static function location($className) {
|
||||
if (!empty(self::$__classMap[$className])) {
|
||||
return self::$__classMap[$className];
|
||||
if (!empty(self::$_classMap[$className])) {
|
||||
return self::$_classMap[$className];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -676,12 +671,11 @@ class App {
|
|||
* @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 $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 boolean $parent whether to load the class parent or not
|
||||
* @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') {
|
||||
$type = 'Console';
|
||||
} 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 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
|
||||
* @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) {
|
||||
$mapped = self::__mapped($name, $plugin);
|
||||
protected function _loadFile($name, $plugin, $search, $file, $return) {
|
||||
$mapped = self::_mapped($name, $plugin);
|
||||
if ($mapped) {
|
||||
$file = $mapped;
|
||||
} else if (!empty($search)) {
|
||||
|
@ -737,7 +731,7 @@ class App {
|
|||
}
|
||||
}
|
||||
if (!empty($file) && file_exists($file)) {
|
||||
self::__map($file, $name, $plugin);
|
||||
self::_map($file, $name, $plugin);
|
||||
$returnValue = include $file;
|
||||
if ($return) {
|
||||
return $returnValue;
|
||||
|
@ -756,8 +750,8 @@ class App {
|
|||
* @param string $ext file extension if known
|
||||
* @return boolean true if the file was loaded successfully, false otherwise
|
||||
*/
|
||||
private function _loadVendor($name, $plugin, $file, $ext) {
|
||||
if ($mapped = self::__mapped($name, $plugin)) {
|
||||
protected function _loadVendor($name, $plugin, $file, $ext) {
|
||||
if ($mapped = self::_mapped($name, $plugin)) {
|
||||
return (bool) include_once($mapped);
|
||||
}
|
||||
$fileTries = array();
|
||||
|
@ -775,7 +769,7 @@ class App {
|
|||
foreach ($fileTries as $file) {
|
||||
foreach ($paths as $path) {
|
||||
if (file_exists($path . $file)) {
|
||||
self::__map($path . $file, $name, $plugin);
|
||||
self::_map($path . $file, $name, $plugin);
|
||||
return (bool) include($path . $file);
|
||||
}
|
||||
}
|
||||
|
@ -789,8 +783,8 @@ class App {
|
|||
* @return void
|
||||
*/
|
||||
public static function init() {
|
||||
self::$__map += (array)Cache::read('file_map', '_cake_core_');
|
||||
self::$__objects += (array)Cache::read('object_map', '_cake_core_');
|
||||
self::$_map += (array)Cache::read('file_map', '_cake_core_');
|
||||
self::$_objects += (array)Cache::read('object_map', '_cake_core_');
|
||||
register_shutdown_function(array('App', 'shutdown'));
|
||||
self::uses('CakePlugin', 'Core');
|
||||
}
|
||||
|
@ -802,13 +796,12 @@ class App {
|
|||
* @param string $name unique name for this map
|
||||
* @param string $plugin camelized if object is from a plugin, the name of the plugin
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
private static function __map($file, $name, $plugin = null) {
|
||||
protected static function _map($file, $name, $plugin = null) {
|
||||
if ($plugin) {
|
||||
self::$__map['Plugin'][$plugin][$name] = $file;
|
||||
self::$_map['Plugin'][$plugin][$name] = $file;
|
||||
} else {
|
||||
self::$__map[$name] = $file;
|
||||
self::$_map[$name] = $file;
|
||||
}
|
||||
if (!self::$bootstrapping) {
|
||||
self::$_cacheChange = true;
|
||||
|
@ -820,19 +813,18 @@ class App {
|
|||
*
|
||||
* @param string $name unique name
|
||||
* @param string $plugin camelized if object is from a plugin, the name of the plugin
|
||||
* @return mixed, file path if found, false otherwise
|
||||
* @access private
|
||||
* @return mixed file path if found, false otherwise
|
||||
*/
|
||||
private static function __mapped($name, $plugin = null) {
|
||||
protected static function _mapped($name, $plugin = null) {
|
||||
if ($plugin) {
|
||||
if (isset(self::$__map['Plugin'][$plugin][$name])) {
|
||||
return self::$__map['Plugin'][$plugin][$name];
|
||||
if (isset(self::$_map['Plugin'][$plugin][$name])) {
|
||||
return self::$_map['Plugin'][$plugin][$name];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset(self::$__map[$name])) {
|
||||
return self::$__map[$name];
|
||||
if (isset(self::$_map[$name])) {
|
||||
return self::$_map[$name];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -840,16 +832,16 @@ class App {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
public static function shutdown() {
|
||||
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) {
|
||||
Cache::write('object_map', self::$__objects, '_cake_core_');
|
||||
Cache::write('object_map', self::$_objects, '_cake_core_');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,35 @@
|
|||
<?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 {
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -173,6 +196,7 @@ class CakePlugin {
|
|||
* Retruns true if the plugin $plugin is already loaded
|
||||
* 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.
|
||||
* If $plugin is null, returns a list of plugins that have been loaded
|
||||
*/
|
||||
|
|
|
@ -59,6 +59,7 @@ class Configure {
|
|||
* - Include app/Config/bootstrap.php.
|
||||
* - Setup error/exception handlers.
|
||||
*
|
||||
* @param boolean $boot
|
||||
* @return void
|
||||
*/
|
||||
public static function bootstrap($boot = true) {
|
||||
|
@ -246,6 +247,7 @@ class Configure {
|
|||
/**
|
||||
* Gets the names of the configured reader objects.
|
||||
*
|
||||
* @param string $name
|
||||
* @return array Array of the configured reader objects.
|
||||
*/
|
||||
public static function configured($name = null) {
|
||||
|
|
|
@ -35,10 +35,8 @@ class Object {
|
|||
/**
|
||||
* constructor, no-op
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,7 +122,7 @@ class Object {
|
|||
* Stop execution of the current script. Wraps exit() making
|
||||
* testing easier.
|
||||
*
|
||||
* @param $status see http://php.net/exit for values
|
||||
* @param integer|string $status see http://php.net/exit for values
|
||||
* @return void
|
||||
*/
|
||||
protected function _stop($status = 0) {
|
||||
|
@ -175,7 +173,7 @@ class Object {
|
|||
* this method as an empty function.
|
||||
*
|
||||
* @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.
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -26,7 +26,7 @@ App::uses('AppController', 'Controller');
|
|||
|
||||
/**
|
||||
*
|
||||
* Error Handler provides basic error and exception handling for your application. It captures and
|
||||
* Error Handler provides basic error and exception handling for your application. It captures and
|
||||
* handles all unhandled exceptions and errors. Displays helpful framework errors when debug > 1.
|
||||
*
|
||||
* ### Uncaught exceptions
|
||||
|
@ -47,7 +47,7 @@ App::uses('AppController', 'Controller');
|
|||
*
|
||||
* This gives you full control over the exception handling process. The class you choose should be
|
||||
* loaded in your app/Config/bootstrap.php, so its available to handle any exceptions. You can
|
||||
* define the handler as any callback type. Using Exception.handler overrides all other exception
|
||||
* define the handler as any callback type. Using Exception.handler overrides all other exception
|
||||
* handling settings and logic.
|
||||
*
|
||||
* #### Using `AppController::appError();`
|
||||
|
@ -67,8 +67,8 @@ App::uses('AppController', 'Controller');
|
|||
*
|
||||
* #### Logging exceptions
|
||||
*
|
||||
* Using the built-in exception handling, you can log all the exceptions
|
||||
* that are dealt with by ErrorHandler by setting `Exception.log` to true in your core.php.
|
||||
* Using the built-in exception handling, you can log all the exceptions
|
||||
* that are dealt with by ErrorHandler by setting `Exception.log` to true in your core.php.
|
||||
* Enabling this will log every exception to CakeLog and the configured loggers.
|
||||
*
|
||||
* ### PHP errors
|
||||
|
@ -103,6 +103,7 @@ class ErrorHandler {
|
|||
* This will either use an AppError class if your application has one,
|
||||
* or use the default ExceptionRenderer.
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @return void
|
||||
* @see http://php.net/manual/en/function.set-exception-handler.php
|
||||
*/
|
||||
|
@ -138,7 +139,7 @@ class ErrorHandler {
|
|||
|
||||
/**
|
||||
* Set as the default error handler by CakePHP. Use Configure::write('Error.handler', $callback), to use your own
|
||||
* error handling methods. This function will use Debugger to display errors when debug > 0. And
|
||||
* error handling methods. This function will use Debugger to display errors when debug > 0. And
|
||||
* will log errors to CakeLog, when debug == 0.
|
||||
*
|
||||
* You can use Configure::write('Error.level', $value); to set what type of errors will be handled here.
|
||||
|
@ -185,7 +186,7 @@ class ErrorHandler {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
protected static function _mapErrorCode($code) {
|
||||
|
|
|
@ -57,7 +57,6 @@ class ExceptionRenderer {
|
|||
* Controller instance.
|
||||
*
|
||||
* @var Controller
|
||||
* @access public
|
||||
*/
|
||||
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
|
||||
* code error depending on the code used to construct the error.
|
||||
*
|
||||
* @param string $method Method producing the error
|
||||
* @param array $messages Error messages
|
||||
* @param Exception $exception Exception
|
||||
*/
|
||||
public function __construct(Exception $exception) {
|
||||
$this->controller = $this->_getController($exception);
|
||||
|
@ -142,7 +140,6 @@ class ExceptionRenderer {
|
|||
*
|
||||
* @param Exception $exception The exception to get a controller for.
|
||||
* @return Controller
|
||||
* @access protected
|
||||
*/
|
||||
protected function _getController($exception) {
|
||||
App::uses('CakeErrorController', 'Controller');
|
||||
|
@ -173,7 +170,7 @@ class ExceptionRenderer {
|
|||
/**
|
||||
* Generic handler for the internal framework errors CakePHP can generate.
|
||||
*
|
||||
* @param CakeExeption $error
|
||||
* @param CakeException $error
|
||||
* @return void
|
||||
*/
|
||||
protected function _cakeError(CakeException $error) {
|
||||
|
@ -197,7 +194,8 @@ class ExceptionRenderer {
|
|||
/**
|
||||
* Convenience method to display a 400 series page.
|
||||
*
|
||||
* @param array $params Parameters for controller
|
||||
* @param Exception $error
|
||||
* @return void
|
||||
*/
|
||||
public function error400($error) {
|
||||
$message = $error->getMessage();
|
||||
|
@ -217,7 +215,8 @@ class ExceptionRenderer {
|
|||
/**
|
||||
* Convenience method to display a 500 page.
|
||||
*
|
||||
* @param array $params Parameters for controller
|
||||
* @param Exception $error
|
||||
* @return void
|
||||
*/
|
||||
public function error500($error) {
|
||||
$url = $this->controller->request->here();
|
||||
|
@ -235,6 +234,7 @@ class ExceptionRenderer {
|
|||
* Generate the response using the controller object.
|
||||
*
|
||||
* @param string $template The template to render.
|
||||
* @return void
|
||||
*/
|
||||
protected function _outputMessage($template) {
|
||||
$this->controller->render($template);
|
||||
|
@ -247,6 +247,7 @@ class ExceptionRenderer {
|
|||
* and doesn't call component methods.
|
||||
*
|
||||
* @param string $template The template to render
|
||||
* @return void
|
||||
*/
|
||||
protected function _outputMessageSafe($template) {
|
||||
$this->controller->helpers = array('Form', 'Html', 'Session');
|
||||
|
|
|
@ -64,37 +64,37 @@ class I18n {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $__lang = null;
|
||||
protected $_lang = null;
|
||||
|
||||
/**
|
||||
* Translation strings for a specific domain read from the .mo or .po files
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $__categories = array(
|
||||
'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'
|
||||
protected $_categories = array(
|
||||
'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'
|
||||
);
|
||||
|
||||
/**
|
||||
* Return a static instance of the I18n class
|
||||
*
|
||||
* @return object I18n
|
||||
* @return I18n
|
||||
*/
|
||||
public static function &getInstance() {
|
||||
static $instance = array();
|
||||
|
@ -127,7 +127,7 @@ class I18n {
|
|||
}
|
||||
|
||||
if (is_numeric($category)) {
|
||||
$_this->category = $_this->__categories[$category];
|
||||
$_this->category = $_this->_categories[$category];
|
||||
}
|
||||
$language = Configure::read('Config.language');
|
||||
|
||||
|
@ -135,9 +135,9 @@ class I18n {
|
|||
$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);
|
||||
$_this->__lang = $lang;
|
||||
$_this->_lang = $lang;
|
||||
}
|
||||
|
||||
if (is_null($domain)) {
|
||||
|
@ -146,24 +146,24 @@ class I18n {
|
|||
|
||||
$_this->domain = $domain . '_' . $_this->l10n->lang;
|
||||
|
||||
if (!isset($_this->__domains[$domain][$_this->__lang])) {
|
||||
$_this->__domains[$domain][$_this->__lang] = Cache::read($_this->domain, '_cake_core_');
|
||||
if (!isset($_this->_domains[$domain][$_this->_lang])) {
|
||||
$_this->_domains[$domain][$_this->_lang] = Cache::read($_this->domain, '_cake_core_');
|
||||
}
|
||||
|
||||
if (!isset($_this->__domains[$domain][$_this->__lang][$_this->category])) {
|
||||
$_this->__bindTextDomain($domain);
|
||||
Cache::write($_this->domain, $_this->__domains[$domain][$_this->__lang], '_cake_core_');
|
||||
if (!isset($_this->_domains[$domain][$_this->_lang][$_this->category])) {
|
||||
$_this->_bindTextDomain($domain);
|
||||
Cache::write($_this->domain, $_this->_domains[$domain][$_this->_lang], '_cake_core_');
|
||||
}
|
||||
|
||||
if ($_this->category == 'LC_TIME') {
|
||||
return $_this->__translateTime($singular,$domain);
|
||||
return $_this->_translateTime($singular,$domain);
|
||||
}
|
||||
|
||||
if (!isset($count)) {
|
||||
$plurals = 0;
|
||||
} elseif (!empty($_this->__domains[$domain][$_this->__lang][$_this->category]["%plural-c"]) && $_this->__noLocale === false) {
|
||||
$header = $_this->__domains[$domain][$_this->__lang][$_this->category]["%plural-c"];
|
||||
$plurals = $_this->__pluralGuess($header, $count);
|
||||
} elseif (!empty($_this->_domains[$domain][$_this->_lang][$_this->category]["%plural-c"]) && $_this->_noLocale === false) {
|
||||
$header = $_this->_domains[$domain][$_this->_lang][$_this->category]["%plural-c"];
|
||||
$plurals = $_this->_pluralGuess($header, $count);
|
||||
} else {
|
||||
if ($count != 1) {
|
||||
$plurals = 1;
|
||||
|
@ -172,8 +172,8 @@ class I18n {
|
|||
}
|
||||
}
|
||||
|
||||
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 (!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 (is_array($trans)) {
|
||||
if (isset($trans[$plurals])) {
|
||||
$trans = $trans[$plurals];
|
||||
|
@ -198,7 +198,7 @@ class I18n {
|
|||
*/
|
||||
public static function clear() {
|
||||
$self = I18n::getInstance();
|
||||
$self->__domains = array();
|
||||
$self->_domains = array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,17 +208,17 @@ class I18n {
|
|||
*/
|
||||
public static function domains() {
|
||||
$self = I18n::getInstance();
|
||||
return $self->__domains;
|
||||
return $self->_domains;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to find the plural form of a string.
|
||||
*
|
||||
* @param string $header Type
|
||||
* @param integrer $n Number
|
||||
* @param integer $n Number
|
||||
* @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])) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -266,8 +266,8 @@ class I18n {
|
|||
* @param string $domain Domain to bind
|
||||
* @return string Domain binded
|
||||
*/
|
||||
private function __bindTextDomain($domain) {
|
||||
$this->__noLocale = true;
|
||||
protected function _bindTextDomain($domain) {
|
||||
$this->_noLocale = true;
|
||||
$core = true;
|
||||
$merge = array();
|
||||
$searchPaths = App::path('locales');
|
||||
|
@ -295,69 +295,70 @@ class I18n {
|
|||
$app = $directory . $lang . DS . $this->category . DS . 'core';
|
||||
|
||||
if (file_exists($fn = "$app.mo")) {
|
||||
$this->__loadMo($fn, $domain);
|
||||
$this->__noLocale = false;
|
||||
$merge[$domain][$this->__lang][$this->category] = $this->__domains[$domain][$this->__lang][$this->category];
|
||||
$this->_loadMo($fn, $domain);
|
||||
$this->_noLocale = false;
|
||||
$merge[$domain][$this->_lang][$this->category] = $this->_domains[$domain][$this->_lang][$this->category];
|
||||
$core = null;
|
||||
} elseif (file_exists($fn = "$app.po") && ($f = fopen($fn, "r"))) {
|
||||
$this->__loadPo($f, $domain);
|
||||
$this->__noLocale = false;
|
||||
$merge[$domain][$this->__lang][$this->category] = $this->__domains[$domain][$this->__lang][$this->category];
|
||||
$this->_loadPo($f, $domain);
|
||||
$this->_noLocale = false;
|
||||
$merge[$domain][$this->_lang][$this->category] = $this->_domains[$domain][$this->_lang][$this->category];
|
||||
$core = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($fn = "$file.mo")) {
|
||||
$this->__loadMo($fn, $domain);
|
||||
$this->__noLocale = false;
|
||||
$this->_loadMo($fn, $domain);
|
||||
$this->_noLocale = false;
|
||||
break 2;
|
||||
} elseif (file_exists($fn = "$file.po") && ($f = fopen($fn, "r"))) {
|
||||
$this->__loadPo($f, $domain);
|
||||
$this->__noLocale = false;
|
||||
$this->_loadPo($f, $domain);
|
||||
$this->_noLocale = false;
|
||||
break 2;
|
||||
} elseif (is_file($localeDef) && ($f = fopen($localeDef, "r"))) {
|
||||
$this->__loadLocaleDefinition($f, $domain);
|
||||
$this->__noLocale = false;
|
||||
$this->_loadLocaleDefinition($f, $domain);
|
||||
$this->_noLocale = false;
|
||||
return $domain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($this->__domains[$domain][$this->__lang][$this->category])) {
|
||||
$this->__domains[$domain][$this->__lang][$this->category] = array();
|
||||
if (empty($this->_domains[$domain][$this->_lang][$this->category])) {
|
||||
$this->_domains[$domain][$this->_lang][$this->category] = array();
|
||||
return $domain;
|
||||
}
|
||||
|
||||
if (isset($this->__domains[$domain][$this->__lang][$this->category][""])) {
|
||||
$head = $this->__domains[$domain][$this->__lang][$this->category][""];
|
||||
if (isset($this->_domains[$domain][$this->_lang][$this->category][""])) {
|
||||
$head = $this->_domains[$domain][$this->_lang][$this->category][""];
|
||||
|
||||
foreach (explode("\n", $head) as $line) {
|
||||
$header = strtok($line,":");
|
||||
$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"])) {
|
||||
$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;
|
||||
unset($this->__domains[$domain][$this->__lang][$this->category]["%po-header"]);
|
||||
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"]);
|
||||
$this->_domains[$domain][$this->_lang][$this->category]["%plural-c"] = $switch;
|
||||
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])) {
|
||||
unset($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]);
|
||||
}
|
||||
}
|
||||
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 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);
|
||||
|
||||
if ($data) {
|
||||
|
@ -380,10 +381,10 @@ class I18n {
|
|||
if (strpos($msgstr, "\000")) {
|
||||
$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)) {
|
||||
$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 string $domain Domain to load file in
|
||||
* @return array Binded domain elements
|
||||
*/
|
||||
private function __loadPo($file, $domain) {
|
||||
protected function _loadPo($file, $domain) {
|
||||
$type = 0;
|
||||
$translations = array();
|
||||
$translationKey = "";
|
||||
|
@ -457,7 +458,7 @@ class I18n {
|
|||
} while (!feof($file));
|
||||
fclose($file);
|
||||
$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
|
||||
* @return void
|
||||
*/
|
||||
private function __loadLocaleDefinition($file, $domain = null) {
|
||||
protected function _loadLocaleDefinition($file, $domain = null) {
|
||||
$comment = '#';
|
||||
$escape = '\\';
|
||||
$currentToken = false;
|
||||
|
@ -509,14 +510,14 @@ class I18n {
|
|||
$this->__escape = $escape;
|
||||
foreach ($value as $i => $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);
|
||||
$value[$i] = $val;
|
||||
}
|
||||
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 {
|
||||
$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
|
||||
* @return string parsed symbol
|
||||
*/
|
||||
private function __parseLiteralValue($string) {
|
||||
protected function _parseLiteralValue($string) {
|
||||
$string = $string[1];
|
||||
if (substr($string, 0, 2) === $this->__escape . 'x') {
|
||||
$delimiter = $this->__escape . 'x';
|
||||
|
@ -558,9 +559,9 @@ class I18n {
|
|||
* @param string $domain Domain where format is stored
|
||||
* @return mixed translated format string if only value or array of translated strings for corresponding format.
|
||||
*/
|
||||
private function __translateTime($format, $domain) {
|
||||
if (!empty($this->__domains[$domain][$this->__lang]['LC_TIME'][$format])) {
|
||||
if (($trans = $this->__domains[$domain][$this->__lang][$this->category][$format])) {
|
||||
protected function _translateTime($format, $domain) {
|
||||
if (!empty($this->_domains[$domain][$this->_lang]['LC_TIME'][$format])) {
|
||||
if (($trans = $this->_domains[$domain][$this->_lang][$this->category][$format])) {
|
||||
return $trans;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ class L10n {
|
|||
* The language for current locale
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $language = 'English (United States)';
|
||||
|
||||
|
@ -37,7 +36,6 @@ class L10n {
|
|||
* Locale search paths
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $languagePath = array('eng');
|
||||
|
||||
|
@ -45,7 +43,6 @@ class L10n {
|
|||
* ISO 639-3 for current locale
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $lang = 'eng';
|
||||
|
||||
|
@ -53,7 +50,6 @@ class L10n {
|
|||
* Locale
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $default = null;
|
||||
|
||||
|
@ -71,7 +66,6 @@ class L10n {
|
|||
* Encoding used for current locale
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $charset = 'utf-8';
|
||||
|
||||
|
@ -79,7 +73,6 @@ class L10n {
|
|||
* Text direction for current locale
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $direction = 'ltr';
|
||||
|
||||
|
@ -87,17 +80,15 @@ class L10n {
|
|||
* Set to true if a locale is found
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $found = false;
|
||||
|
||||
/**
|
||||
* Maps ISO 639-3 to I10n::__l10nCatalog
|
||||
* Maps ISO 639-3 to I10n::_l10nCatalog
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $__l10nMap = array(/* Afrikaans */ 'afr' => 'af',
|
||||
protected $_l10nMap = array(/* Afrikaans */ 'afr' => 'af',
|
||||
/* Albanian */ 'alb' => 'sq',
|
||||
/* Arabic */ 'ara' => 'ar',
|
||||
/* Armenian - Armenia */ 'hye' => 'hy',
|
||||
|
@ -182,9 +173,8 @@ class L10n {
|
|||
* holds all information related to a language
|
||||
*
|
||||
* @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-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'),
|
||||
|
@ -336,16 +326,17 @@ class L10n {
|
|||
|
||||
/**
|
||||
* Gets the settings for $language.
|
||||
* If $language is null it attempt to get settings from L10n::__autoLanguage(); if this fails
|
||||
* the method will get the settings from L10n::__setLanguage();
|
||||
* If $language is null it attempt to get settings from L10n::_autoLanguage(); if this fails
|
||||
* the method will get the settings from L10n::_setLanguage();
|
||||
*
|
||||
* @param string $language Language (if null will use DEFAULT_LANGUAGE if defined)
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($language = null) {
|
||||
if ($language !== null) {
|
||||
return $this->__setLanguage($language);
|
||||
} elseif ($this->__autoLanguage() === false) {
|
||||
return $this->__setLanguage();
|
||||
return $this->_setLanguage($language);
|
||||
} elseif ($this->_autoLanguage() === false) {
|
||||
return $this->_setLanguage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,38 +345,38 @@ class L10n {
|
|||
* If $language is null it will use the 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;
|
||||
if ($language !== null && isset($this->__l10nMap[$language]) && isset($this->__l10nCatalog[$this->__l10nMap[$language]])) {
|
||||
$langKey = $this->__l10nMap[$language];
|
||||
} else if ($language !== null && isset($this->__l10nCatalog[$language])) {
|
||||
if ($language !== null && isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
|
||||
$langKey = $this->_l10nMap[$language];
|
||||
} else if ($language !== null && isset($this->_l10nCatalog[$language])) {
|
||||
$langKey = $language;
|
||||
} else if (defined('DEFAULT_LANGUAGE')) {
|
||||
$langKey = $language = DEFAULT_LANGUAGE;
|
||||
}
|
||||
|
||||
if ($langKey !== null && isset($this->__l10nCatalog[$langKey])) {
|
||||
$this->language = $this->__l10nCatalog[$langKey]['language'];
|
||||
if ($langKey !== null && isset($this->_l10nCatalog[$langKey])) {
|
||||
$this->language = $this->_l10nCatalog[$langKey]['language'];
|
||||
$this->languagePath = array(
|
||||
$this->__l10nCatalog[$langKey]['locale'],
|
||||
$this->__l10nCatalog[$langKey]['localeFallback']
|
||||
$this->_l10nCatalog[$langKey]['locale'],
|
||||
$this->_l10nCatalog[$langKey]['localeFallback']
|
||||
);
|
||||
$this->lang = $language;
|
||||
$this->locale = $this->__l10nCatalog[$langKey]['locale'];
|
||||
$this->charset = $this->__l10nCatalog[$langKey]['charset'];
|
||||
$this->direction = $this->__l10nCatalog[$langKey]['direction'];
|
||||
$this->locale = $this->_l10nCatalog[$langKey]['locale'];
|
||||
$this->charset = $this->_l10nCatalog[$langKey]['charset'];
|
||||
$this->direction = $this->_l10nCatalog[$langKey]['direction'];
|
||||
} else {
|
||||
$this->lang = $language;
|
||||
$this->languagePath = array($language);
|
||||
}
|
||||
|
||||
if ($this->default) {
|
||||
if (isset($this->__l10nMap[$this->default]) && isset($this->__l10nCatalog[$this->__l10nMap[$this->default]])) {
|
||||
$this->languagePath[] = $this->__l10nCatalog[$this->__l10nMap[$this->default]]['localeFallback'];
|
||||
} else if (isset($this->__l10nCatalog[$this->default])) {
|
||||
$this->languagePath[] = $this->__l10nCatalog[$this->default]['localeFallback'];
|
||||
if (isset($this->_l10nMap[$this->default]) && isset($this->_l10nCatalog[$this->_l10nMap[$this->default]])) {
|
||||
$this->languagePath[] = $this->_l10nCatalog[$this->_l10nMap[$this->default]]['localeFallback'];
|
||||
} else if (isset($this->_l10nCatalog[$this->default])) {
|
||||
$this->languagePath[] = $this->_l10nCatalog[$this->default]['localeFallback'];
|
||||
}
|
||||
}
|
||||
$this->found = true;
|
||||
|
@ -403,18 +394,17 @@ class L10n {
|
|||
* Attempts to find the locale settings based on the HTTP_ACCEPT_LANGUAGE variable
|
||||
*
|
||||
* @return boolean Success
|
||||
* @access private
|
||||
*/
|
||||
private function __autoLanguage() {
|
||||
protected function _autoLanguage() {
|
||||
$_detectableLanguages = CakeRequest::acceptLanguage();
|
||||
foreach ($_detectableLanguages as $key => $langKey) {
|
||||
if (isset($this->__l10nCatalog[$langKey])) {
|
||||
$this->__setLanguage($langKey);
|
||||
if (isset($this->_l10nCatalog[$langKey])) {
|
||||
$this->_setLanguage($langKey);
|
||||
return true;
|
||||
} else if (strpos($langKey, '-') !== false) {
|
||||
$langKey = substr($langKey, 0, 2);
|
||||
if (isset($this->__l10nCatalog[$langKey])) {
|
||||
$this->__setLanguage($langKey);
|
||||
if (isset($this->_l10nCatalog[$langKey])) {
|
||||
$this->_setLanguage($langKey);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -439,14 +429,14 @@ class L10n {
|
|||
}
|
||||
return $result;
|
||||
} else if (is_string($mixed)) {
|
||||
if (strlen($mixed) === 2 && in_array($mixed, $this->__l10nMap)) {
|
||||
return array_search($mixed, $this->__l10nMap);
|
||||
} else if (isset($this->__l10nMap[$mixed])) {
|
||||
return $this->__l10nMap[$mixed];
|
||||
if (strlen($mixed) === 2 && in_array($mixed, $this->_l10nMap)) {
|
||||
return array_search($mixed, $this->_l10nMap);
|
||||
} else if (isset($this->_l10nMap[$mixed])) {
|
||||
return $this->_l10nMap[$mixed];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return $this->__l10nMap;
|
||||
return $this->_l10nMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -466,13 +456,13 @@ class L10n {
|
|||
}
|
||||
return $result;
|
||||
} else if (is_string($language)) {
|
||||
if (isset($this->__l10nCatalog[$language])) {
|
||||
return $this->__l10nCatalog[$language];
|
||||
} else if (isset($this->__l10nMap[$language]) && isset($this->__l10nCatalog[$this->__l10nMap[$language]])) {
|
||||
return $this->__l10nCatalog[$this->__l10nMap[$language]];
|
||||
if (isset($this->_l10nCatalog[$language])) {
|
||||
return $this->_l10nCatalog[$language];
|
||||
} else if (isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
|
||||
return $this->_l10nCatalog[$this->_l10nMap[$language]];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return $this->__l10nCatalog;
|
||||
return $this->_l10nCatalog;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -258,27 +258,27 @@ class Multibyte {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $__caseFold = array();
|
||||
protected static $_caseFold = array();
|
||||
|
||||
/**
|
||||
* Holds an array of Unicode code point ranges
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $__codeRange = array();
|
||||
protected static $_codeRange = array();
|
||||
|
||||
/**
|
||||
* Holds the current code point range
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $__table = null;
|
||||
protected static $_table = null;
|
||||
|
||||
/**
|
||||
* Converts a multibyte character string
|
||||
* to the decimal value of the character
|
||||
*
|
||||
* @param multibyte string $string
|
||||
* @param string $string
|
||||
* @return array
|
||||
*/
|
||||
public static function utf8($string) {
|
||||
|
@ -341,8 +341,8 @@ class Multibyte {
|
|||
/**
|
||||
* 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 multi-byte string $needle The string to find in $haystack.
|
||||
* @param string $haystack The string from which to get the position of the first occurrence of $needle.
|
||||
* @param string $needle The string to find in $haystack.
|
||||
* @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,
|
||||
* 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 false, it returns all of $haystack from the first occurrence of $needle to the end,
|
||||
* 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) {
|
||||
$php = (PHP_VERSION < 5.3);
|
||||
|
@ -780,7 +780,7 @@ class Multibyte {
|
|||
$matched = true;
|
||||
} else {
|
||||
$matched = false;
|
||||
$keys = self::__find($char, 'upper');
|
||||
$keys = self::_find($char, 'upper');
|
||||
|
||||
if (!empty($keys)) {
|
||||
foreach ($keys as $key => $value) {
|
||||
|
@ -803,10 +803,7 @@ class Multibyte {
|
|||
* Make a string uppercase
|
||||
*
|
||||
* @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.
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
public static function strtoupper($string) {
|
||||
$utf8Map = Multibyte::utf8($string);
|
||||
|
@ -829,7 +826,7 @@ class Multibyte {
|
|||
|
||||
} else {
|
||||
$matched = false;
|
||||
$keys = self::__find($char);
|
||||
$keys = self::_find($char);
|
||||
$keyCount = count($keys);
|
||||
|
||||
if (!empty($keys)) {
|
||||
|
@ -1006,10 +1003,10 @@ class Multibyte {
|
|||
/**
|
||||
* Return the Code points range for Unicode characters
|
||||
*
|
||||
* @param interger $decimal
|
||||
* @param integer $decimal
|
||||
* @return string
|
||||
*/
|
||||
private static function __codepoint($decimal) {
|
||||
protected static function _codepoint($decimal) {
|
||||
if ($decimal > 128 && $decimal < 256) {
|
||||
$return = '0080_00ff'; // Latin-1 Supplement
|
||||
} elseif ($decimal < 384) {
|
||||
|
@ -1047,7 +1044,7 @@ class Multibyte {
|
|||
} else {
|
||||
$return = false;
|
||||
}
|
||||
self::$__codeRange[$decimal] = $return;
|
||||
self::$_codeRange[$decimal] = $return;
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -1058,10 +1055,10 @@ class Multibyte {
|
|||
* @param string $type
|
||||
* @return array
|
||||
*/
|
||||
private static function __find($char, $type = 'lower') {
|
||||
protected static function _find($char, $type = 'lower') {
|
||||
$found = array();
|
||||
if (!isset(self::$__codeRange[$char])) {
|
||||
$range = self::__codepoint($char);
|
||||
if (!isset(self::$_codeRange[$char])) {
|
||||
$range = self::_codepoint($char);
|
||||
if ($range === false) {
|
||||
return null;
|
||||
}
|
||||
|
@ -1070,21 +1067,21 @@ class Multibyte {
|
|||
Configure::config('_cake_core_', new PhpReader(CAKE . 'Config' . DS));
|
||||
}
|
||||
Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_');
|
||||
self::$__caseFold[$range] = Configure::read($range);
|
||||
self::$_caseFold[$range] = Configure::read($range);
|
||||
Configure::delete($range);
|
||||
}
|
||||
|
||||
if (!self::$__codeRange[$char]) {
|
||||
if (!self::$_codeRange[$char]) {
|
||||
return null;
|
||||
}
|
||||
self::$__table = self::$__codeRange[$char];
|
||||
$count = count(self::$__caseFold[self::$__table]);
|
||||
self::$_table = self::$_codeRange[$char];
|
||||
$count = count(self::$_caseFold[self::$_table]);
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($type === 'lower' && self::$__caseFold[self::$__table][$i][$type][0] === $char) {
|
||||
$found[] = self::$__caseFold[self::$__table][$i];
|
||||
} elseif ($type === 'upper' && self::$__caseFold[self::$__table][$i][$type] === $char) {
|
||||
$found[] = self::$__caseFold[self::$__table][$i];
|
||||
if ($type === 'lower' && self::$_caseFold[self::$_table][$i][$type][0] === $char) {
|
||||
$found[] = self::$_caseFold[self::$_table][$i];
|
||||
} elseif ($type === 'upper' && self::$_caseFold[self::$_table][$i][$type] === $char) {
|
||||
$found[] = self::$_caseFold[self::$_table][$i];
|
||||
}
|
||||
}
|
||||
return $found;
|
||||
|
|
|
@ -112,6 +112,7 @@ class CakeLog {
|
|||
*
|
||||
* @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.
|
||||
* @throws CakeLogException
|
||||
*/
|
||||
protected static function _getLogger($loggerName) {
|
||||
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
|
||||
* 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
|
||||
*/
|
||||
public static function drop($streamName) {
|
||||
|
@ -170,7 +171,7 @@ class CakeLog {
|
|||
* ### Usage:
|
||||
*
|
||||
* Write a message to the 'warning' log:
|
||||
*
|
||||
*
|
||||
* `CakeLog::write('warning', 'Stuff is broken here');`
|
||||
*
|
||||
* @param string $type Type of message being written
|
||||
|
|
|
@ -1,4 +1,21 @@
|
|||
<?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
|
||||
|
@ -10,8 +27,8 @@ interface CakeLogInterface {
|
|||
/**
|
||||
* Write method to handle writes being made to the Logger
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $message
|
||||
* @param string $type
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
public function write($type, $message);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
App::uses('CakeLogInterface', 'Log');
|
||||
|
||||
|
||||
/**
|
||||
* File Storage stream for Logging. Writes logs to different files
|
||||
* based on the type of log it is.
|
||||
|
@ -37,15 +36,14 @@ class FileLog implements CakeLogInterface {
|
|||
|
||||
/**
|
||||
* Constructs a new File Logger.
|
||||
*
|
||||
*
|
||||
* Options
|
||||
*
|
||||
* - `path` the path to save logs on.
|
||||
*
|
||||
* @param array $options Options for the FileLog, see above.
|
||||
* @return void
|
||||
*/
|
||||
function __construct($options = array()) {
|
||||
public function __construct($options = array()) {
|
||||
$options += array('path' => LOGS);
|
||||
$this->_path = $options['path'];
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ class AclNode extends AppModel {
|
|||
* Explicitly disable in-memory query caching for ACL models
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
public $cacheQueries = false;
|
||||
|
||||
|
@ -41,7 +40,6 @@ class AclNode extends AppModel {
|
|||
* ACL models use the Tree behavior
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $actsAs = array('Tree' => array('nested'));
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ class Aco extends AclNode {
|
|||
* Model name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $name = 'Aco';
|
||||
|
||||
|
@ -42,7 +41,6 @@ class Aco extends AclNode {
|
|||
* Binds to ARO nodes through permissions settings
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $hasAndBelongsToMany = array('Aro' => array('with' => 'Permission'));
|
||||
}
|
|
@ -34,7 +34,6 @@ class AcoAction extends AppModel {
|
|||
* Model name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $name = 'AcoAction';
|
||||
|
||||
|
@ -42,7 +41,6 @@ class AcoAction extends AppModel {
|
|||
* ACO Actions belong to ACOs
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $belongsTo = array('Aco');
|
||||
}
|
|
@ -32,7 +32,6 @@ class Aro extends AclNode {
|
|||
* Model name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $name = 'Aro';
|
||||
|
||||
|
@ -40,7 +39,6 @@ class Aro extends AclNode {
|
|||
* AROs are linked to ACOs by means of Permission
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $hasAndBelongsToMany = array('Aco' => array('with' => 'Permission'));
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* Licensed under The MIT License
|
||||
* 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
|
||||
* @package Cake.Model.Behavior
|
||||
* @since CakePHP v 1.2.0.4487
|
||||
|
@ -33,12 +33,13 @@ class AclBehavior extends ModelBehavior {
|
|||
*
|
||||
* @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
|
||||
*
|
||||
* @param mixed $config
|
||||
* @param Model $model
|
||||
* @param array $config
|
||||
* @return void
|
||||
*/
|
||||
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]['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)) {
|
||||
$types = array($types);
|
||||
|
@ -64,6 +65,7 @@ class AclBehavior extends ModelBehavior {
|
|||
/**
|
||||
* Retrieves the Aro/Aco node for this model
|
||||
*
|
||||
* @param Model $model
|
||||
* @param mixed $ref
|
||||
* @param string $type Only needed when Acl is set up as 'both', specify 'Aro' or 'Aco' to get the correct node
|
||||
* @return array
|
||||
|
@ -71,7 +73,7 @@ class AclBehavior extends ModelBehavior {
|
|||
*/
|
||||
public function node($model, $ref = null, $type = null) {
|
||||
if (empty($type)) {
|
||||
$type = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
$type = $this->_typeMaps[$this->settings[$model->name]['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);
|
||||
return null;
|
||||
|
@ -86,11 +88,12 @@ class AclBehavior extends ModelBehavior {
|
|||
/**
|
||||
* Creates a new ARO/ACO node bound to this record
|
||||
*
|
||||
* @param Model $model
|
||||
* @param boolean $created True if this is a new record
|
||||
* @return void
|
||||
*/
|
||||
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)) {
|
||||
$types = array($types);
|
||||
}
|
||||
|
@ -116,10 +119,11 @@ class AclBehavior extends ModelBehavior {
|
|||
/**
|
||||
* Destroys the ARO/ACO node bound to the deleted record
|
||||
*
|
||||
* @param Model $model
|
||||
* @return void
|
||||
*/
|
||||
public function afterDelete($model) {
|
||||
$types = $this->__typeMaps[$this->settings[$model->name]['type']];
|
||||
$types = $this->_typeMaps[$this->settings[$model->name]['type']];
|
||||
if (!is_array($types)) {
|
||||
$types = array($types);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ class ContainableBehavior extends ModelBehavior {
|
|||
* Types of relationships available for models
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
public $types = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||
|
||||
|
@ -40,7 +39,6 @@ class ContainableBehavior extends ModelBehavior {
|
|||
* Runtime configuration for this behavior
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
public $runtime = array();
|
||||
|
||||
|
@ -58,8 +56,9 @@ class ContainableBehavior extends ModelBehavior {
|
|||
* - autoFields: (boolean, optional) auto-add needed fields to fetch requested
|
||||
* 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.
|
||||
* @return void
|
||||
*/
|
||||
public function setup($Model, $settings = array()) {
|
||||
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
|
||||
* @return array
|
||||
*/
|
||||
|
@ -107,7 +106,7 @@ class ContainableBehavior extends ModelBehavior {
|
|||
$contain = array_merge($contain, (array)$query['contain']);
|
||||
}
|
||||
if (
|
||||
$noContain || !$contain || in_array($contain, array(null, false), true) ||
|
||||
$noContain || !$contain || in_array($contain, array(null, false), true) ||
|
||||
(isset($contain[0]) && $contain[0] === null)
|
||||
) {
|
||||
if ($noContain) {
|
||||
|
@ -226,9 +225,10 @@ class ContainableBehavior extends ModelBehavior {
|
|||
* Resets original associations on models that may have receive multiple,
|
||||
* 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 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) {
|
||||
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
|
||||
* 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
|
||||
* @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
|
||||
* contain call.
|
||||
*
|
||||
* @param object $Model Model on which to reset bindings
|
||||
* @param Model $Model Model on which to reset bindings
|
||||
* @return void
|
||||
*/
|
||||
public function resetBindings($Model) {
|
||||
|
@ -279,10 +279,10 @@ class ContainableBehavior extends ModelBehavior {
|
|||
/**
|
||||
* 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 $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
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param object $Model Model
|
||||
* @param Model $Model 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
|
||||
* @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.
|
||||
*
|
||||
* @param Model $model Model to get a translatemodel for.
|
||||
* @return object
|
||||
* @return Model
|
||||
*/
|
||||
public function translateModel($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
|
||||
* fake field
|
||||
*
|
||||
* @param object instance of model
|
||||
* @param mixed string with field or array(field1, field2=>AssocName, field3)
|
||||
* @param Model $model instance of model
|
||||
* @param string|array $fields string with field or array(field1, field2=>AssocName, field3)
|
||||
* @param boolean $reset
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindTranslation($model, $fields, $reset = true) {
|
||||
if (is_string($fields)) {
|
||||
|
@ -449,10 +449,10 @@ class TranslateBehavior extends ModelBehavior {
|
|||
* Unbind translation for fields, optionally unbinds hasMany association for
|
||||
* 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
|
||||
* unbind all original translations
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function unbindTranslation($model, $fields = null) {
|
||||
if (empty($fields) && empty($this->settings[$model->alias])) {
|
||||
|
@ -505,7 +505,26 @@ class TranslateBehavior extends ModelBehavior {
|
|||
* @package Cake.Model.Behavior
|
||||
*/
|
||||
class I18nModel extends AppModel {
|
||||
|
||||
/**
|
||||
* Model name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name = 'I18nModel';
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $useTable = 'i18n';
|
||||
|
||||
/**
|
||||
* Display field
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $displayField = 'field';
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* Licensed under The MIT License
|
||||
* 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
|
||||
* @package Cake.Model.Behavior
|
||||
* @since CakePHP v 1.2.0.4487
|
||||
|
@ -41,7 +41,6 @@ class TreeBehavior extends ModelBehavior {
|
|||
* Defaults
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $_defaults = array(
|
||||
'parent' => 'parent_id', 'left' => 'lft', 'right' => 'rght',
|
||||
|
@ -51,7 +50,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
/**
|
||||
* Initiate Tree behavior
|
||||
*
|
||||
* @param object $Model instance of model
|
||||
* @param Model $Model instance of model
|
||||
* @param array $config array of configuration settings.
|
||||
* @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
|
||||
* 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
|
||||
* @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
|
||||
*
|
||||
* @param AppModel $Model Model instance
|
||||
* @param Model $Model Model instance
|
||||
* @param boolean $cascade
|
||||
* @return boolean true to continue, false to abort the delete
|
||||
*/
|
||||
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);
|
||||
$Model->deleteAll($scope);
|
||||
}
|
||||
$this->__sync($Model, $diff, '-', '> ' . $data[$right]);
|
||||
$this->_sync($Model, $diff, '-', '> ' . $data[$right]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* this method bypassing the setParent logic.
|
||||
*
|
||||
* @since 1.2
|
||||
* @param AppModel $Model Model instance
|
||||
* @param Model $Model Model instance
|
||||
* @return boolean true to continue, false to abort the save
|
||||
*/
|
||||
public function beforeSave($Model) {
|
||||
|
@ -149,7 +149,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
$Model->data[$Model->alias][$left] = 0; //$parentNode[$right];
|
||||
$Model->data[$Model->alias][$right] = 0; //$parentNode[$right] + 1;
|
||||
} 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][$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 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 boolean $direct whether to count direct, or all, children
|
||||
* @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 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 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
|
||||
|
@ -296,7 +296,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
/**
|
||||
* 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 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"
|
||||
|
@ -354,10 +354,11 @@ class TreeBehavior extends ModelBehavior {
|
|||
*
|
||||
* 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 string|array $fields
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param AppModel $Model Model instance
|
||||
* @param Model $Model Model instance
|
||||
* @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 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
|
||||
*
|
||||
* @param AppModel $Model Model instance
|
||||
* @param Model $Model Model instance
|
||||
* @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
|
||||
* @link http://book.cakephp.org/view/1352/moveDown
|
||||
*/
|
||||
|
@ -463,10 +464,10 @@ class TreeBehavior extends ModelBehavior {
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
$edge = $this->__getMax($Model, $scope, $right, $recursive);
|
||||
$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, $edge - $node[$left] - ($nextNode[$right] - $nextNode[$left]), '-', '> ' . $edge);
|
||||
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
||||
$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, $edge - $node[$left] - ($nextNode[$right] - $nextNode[$left]), '-', '> ' . $edge);
|
||||
|
||||
if (is_int($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
|
||||
*
|
||||
* @param AppModel $Model Model instance
|
||||
* @param Model $Model Model instance
|
||||
* @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
|
||||
* @link http://book.cakephp.org/view/1353/moveUp
|
||||
*/
|
||||
|
@ -523,10 +524,10 @@ class TreeBehavior extends ModelBehavior {
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
$edge = $this->__getMax($Model, $scope, $right, $recursive);
|
||||
$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, $edge - $previousNode[$left] - ($node[$right] - $node[$left]), '-', '> ' . $edge);
|
||||
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
||||
$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, $edge - $previousNode[$left] - ($node[$right] - $node[$left]), '-', '> ' . $edge);
|
||||
if (is_int($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.
|
||||
*
|
||||
* @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 mixed $missingParentAction 'return' to do nothing and return, 'delete' to
|
||||
* 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)
|
||||
* - '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.
|
||||
* @return boolean true on success, false on failure
|
||||
* @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
|
||||
* 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 boolean $delete whether to delete the node after reparenting children (if any)
|
||||
* @return boolean true on success, false on failure
|
||||
|
@ -705,8 +706,8 @@ class TreeBehavior extends ModelBehavior {
|
|||
array($parent => $db->value($node[$parent], $parent)),
|
||||
array($Model->escapeField($parent) => $node[$Model->primaryKey])
|
||||
);
|
||||
$this->__sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
|
||||
$this->__sync($Model, 2, '-', '> ' . ($node[$right]));
|
||||
$this->_sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1));
|
||||
$this->_sync($Model, 2, '-', '> ' . ($node[$right]));
|
||||
$Model->id = $id;
|
||||
|
||||
if ($delete) {
|
||||
|
@ -720,7 +721,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
);
|
||||
return $Model->delete($id);
|
||||
} else {
|
||||
$edge = $this->__getMax($Model, $scope, $right, $recursive);
|
||||
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
||||
if ($node[$right] == $edge) {
|
||||
$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)
|
||||
*
|
||||
* @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],
|
||||
* [incorrect left/right index,node id], message)
|
||||
* @link http://book.cakephp.org/view/1630/Verify
|
||||
|
@ -747,8 +748,8 @@ class TreeBehavior extends ModelBehavior {
|
|||
if (!$Model->find('count', array('conditions' => $scope))) {
|
||||
return true;
|
||||
}
|
||||
$min = $this->__getMin($Model, $scope, $left, $recursive);
|
||||
$edge = $this->__getMax($Model, $scope, $right, $recursive);
|
||||
$min = $this->_getMin($Model, $scope, $left, $recursive);
|
||||
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
||||
$errors = array();
|
||||
|
||||
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
|
||||
* 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 boolean $created
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function _setParent($Model, $parentId = null, $created = false) {
|
||||
|
@ -820,11 +822,11 @@ class TreeBehavior extends ModelBehavior {
|
|||
'fields' => array($Model->primaryKey, $parent, $left, $right),
|
||||
'recursive' => $recursive
|
||||
)));
|
||||
$edge = $this->__getMax($Model, $scope, $right, $recursive, $created);
|
||||
$edge = $this->_getMax($Model, $scope, $right, $recursive, $created);
|
||||
|
||||
if (empty ($parentId)) {
|
||||
$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, $edge - $node[$left] + 1, '+', 'BETWEEN ' . $node[$left] . ' AND ' . $node[$right], $created);
|
||||
$this->_sync($Model, $node[$right] - $node[$left] + 1, '-', '> ' . $node[$left], $created);
|
||||
} else {
|
||||
$values = $Model->find('first', array(
|
||||
'conditions' => array($scope, $Model->escapeField() => $parentId),
|
||||
|
@ -849,27 +851,27 @@ class TreeBehavior extends ModelBehavior {
|
|||
return false;
|
||||
}
|
||||
if (empty ($node[$left]) && empty ($node[$right])) {
|
||||
$this->__sync($Model, 2, '+', '>= ' . $parentNode[$right], $created);
|
||||
$this->_sync($Model, 2, '+', '>= ' . $parentNode[$right], $created);
|
||||
$result = $Model->save(
|
||||
array($left => $parentNode[$right], $right => $parentNode[$right] + 1, $parent => $parentId),
|
||||
array('validate' => false, 'callbacks' => false)
|
||||
);
|
||||
$Model->data = $result;
|
||||
} 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;
|
||||
|
||||
if ($node[$left] > $parentNode[$left]) {
|
||||
if ($node[$right] < $parentNode[$right]) {
|
||||
$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, $diff, '-', 'BETWEEN ' . $node[$right] . ' AND ' . ($parentNode[$right] - 1), $created);
|
||||
$this->_sync($Model, $edge - $parentNode[$right] + $diff + 1, '-', '> ' . $edge, $created);
|
||||
} else {
|
||||
$this->__sync($Model, $diff, '+', 'BETWEEN ' . $parentNode[$right] . ' AND ' . $node[$right], $created);
|
||||
$this->__sync($Model, $edge - $parentNode[$right] + 1, '-', '> ' . $edge, $created);
|
||||
$this->_sync($Model, $diff, '+', 'BETWEEN ' . $parentNode[$right] . ' AND ' . $node[$right], $created);
|
||||
$this->_sync($Model, $edge - $parentNode[$right] + 1, '-', '> ' . $edge, $created);
|
||||
}
|
||||
} else {
|
||||
$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, $diff, '-', 'BETWEEN ' . $node[$right] . ' AND ' . ($parentNode[$right] - 1), $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.
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param Model $Model
|
||||
* @param string $scope
|
||||
* @param string $right
|
||||
* @return int
|
||||
* @access private
|
||||
* @param integer $recursive
|
||||
* @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);
|
||||
if ($created) {
|
||||
if (is_string($scope)) {
|
||||
|
@ -907,13 +910,13 @@ class TreeBehavior extends ModelBehavior {
|
|||
/**
|
||||
* get the minimum index value in the table.
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param Model $Model
|
||||
* @param string $scope
|
||||
* @param string $right
|
||||
* @return int
|
||||
* @access private
|
||||
* @param string $left
|
||||
* @param integer $recursive
|
||||
* @return integer
|
||||
*/
|
||||
private function __getMin($Model, $scope, $left, $recursive = -1) {
|
||||
protected function _getMin($Model, $scope, $left, $recursive = -1) {
|
||||
$db = ConnectionManager::getDataSource($Model->useDbConfig);
|
||||
$name = $Model->alias . '.' . $left;
|
||||
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.
|
||||
*
|
||||
* @param AppModel $Model
|
||||
* @param Model $Model
|
||||
* @param integer $shift
|
||||
* @param string $direction
|
||||
* @param string $dir
|
||||
* @param array $conditions
|
||||
* @param boolean $created
|
||||
* @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;
|
||||
extract($this->settings[$Model->alias]);
|
||||
$Model->recursive = $recursive;
|
||||
|
||||
if ($field == 'both') {
|
||||
$this->__sync($Model, $shift, $dir, $conditions, $created, $left);
|
||||
$this->_sync($Model, $shift, $dir, $conditions, $created, $left);
|
||||
$field = $right;
|
||||
}
|
||||
if (is_string($conditions)) {
|
||||
|
|
|
@ -34,7 +34,6 @@ class BehaviorCollection extends ObjectCollection {
|
|||
* Stores a reference to the attached name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $modelName = null;
|
||||
|
||||
|
@ -56,7 +55,8 @@ class BehaviorCollection extends ObjectCollection {
|
|||
* Attaches a model object and loads a list of behaviors
|
||||
*
|
||||
* @todo Make this method a constructor instead..
|
||||
* @access public
|
||||
* @param string $modelName
|
||||
* @param array $behaviors
|
||||
* @return void
|
||||
*/
|
||||
public function init($modelName, $behaviors = array()) {
|
||||
|
@ -72,6 +72,8 @@ class BehaviorCollection extends ObjectCollection {
|
|||
/**
|
||||
* Backwards compatible alias for load()
|
||||
*
|
||||
* @param string $behavior
|
||||
* @param array $config
|
||||
* @return void
|
||||
* @deprecated Replaced with load()
|
||||
*/
|
||||
|
|
|
@ -31,7 +31,6 @@ class CakeSchema extends Object {
|
|||
* Name of the schema
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $name = null;
|
||||
|
||||
|
@ -39,7 +38,6 @@ class CakeSchema extends Object {
|
|||
* Path to write location
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $path = null;
|
||||
|
||||
|
@ -47,7 +45,6 @@ class CakeSchema extends Object {
|
|||
* File to write
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $file = 'schema.php';
|
||||
|
||||
|
@ -55,7 +52,6 @@ class CakeSchema extends Object {
|
|||
* Connection used for read
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $connection = 'default';
|
||||
|
||||
|
@ -70,7 +66,6 @@ class CakeSchema extends Object {
|
|||
* Set of tables
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $tables = array();
|
||||
|
||||
|
@ -135,7 +130,7 @@ class CakeSchema extends Object {
|
|||
/**
|
||||
* Before callback to be implemented in subclasses
|
||||
*
|
||||
* @param array $events schema object properties
|
||||
* @param array $event schema object properties
|
||||
* @return boolean Should process continue
|
||||
*/
|
||||
public function before($event = array()) {
|
||||
|
@ -145,7 +140,8 @@ class CakeSchema extends Object {
|
|||
/**
|
||||
* 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()) {
|
||||
}
|
||||
|
@ -263,7 +259,7 @@ class CakeSchema extends Object {
|
|||
if (in_array($fulltable, $currentTables)) {
|
||||
$key = array_search($fulltable, $currentTables);
|
||||
if (empty($tables[$table])) {
|
||||
$tables[$table] = $this->__columns($Object);
|
||||
$tables[$table] = $this->_columns($Object);
|
||||
$tables[$table]['indexes'] = $db->index($Object);
|
||||
$tables[$table]['tableParameters'] = $db->readTableParameters($fulltable);
|
||||
unset($currentTables[$key]);
|
||||
|
@ -281,8 +277,8 @@ class CakeSchema extends Object {
|
|||
if (in_array($withTable, $currentTables)) {
|
||||
$key = array_search($withTable, $currentTables);
|
||||
$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]['tableParameters'] = $db->readTableParameters($withTable);
|
||||
unset($currentTables[$key]);
|
||||
|
@ -311,15 +307,15 @@ class CakeSchema extends Object {
|
|||
'aros', 'acos', 'aros_acos', Configure::read('Session.table'), 'i18n'
|
||||
);
|
||||
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]['tableParameters'] = $db->readTableParameters($table);
|
||||
} elseif ($models === false) {
|
||||
$tables[$table] = $this->__columns($Object);
|
||||
$tables[$table] = $this->_columns($Object);
|
||||
$tables[$table]['indexes'] = $db->index($Object);
|
||||
$tables[$table]['tableParameters'] = $db->readTableParameters($table);
|
||||
} else {
|
||||
$tables['missing'][$table] = $this->__columns($Object);
|
||||
$tables['missing'][$table] = $this->_columns($Object);
|
||||
$tables['missing'][$table]['indexes'] = $db->index($Object);
|
||||
$tables['missing'][$table]['tableParameters'] = $db->readTableParameters($table);
|
||||
}
|
||||
|
@ -407,12 +403,12 @@ class CakeSchema extends Object {
|
|||
}
|
||||
$col = "\t\t'{$field}' => array('type' => '" . $value['type'] . "', ";
|
||||
unset($value['type']);
|
||||
$col .= join(', ', $this->__values($value));
|
||||
$col .= join(', ', $this->_values($value));
|
||||
} elseif ($field == 'indexes') {
|
||||
$col = "\t\t'indexes' => array(";
|
||||
$props = array();
|
||||
foreach ((array)$value as $key => $index) {
|
||||
$props[] = "'{$key}' => array(" . join(', ', $this->__values($index)) . ")";
|
||||
$props[] = "'{$key}' => array(" . join(', ', $this->_values($index)) . ")";
|
||||
}
|
||||
$col .= join(', ', $props);
|
||||
} elseif ($field == 'tableParameters') {
|
||||
|
@ -531,7 +527,6 @@ class CakeSchema extends Object {
|
|||
* @param array $array2 Corresponding array checked for equality
|
||||
* @return array Difference as array with array(keys => values) from input array
|
||||
* where match was not found.
|
||||
* @access protected
|
||||
*/
|
||||
protected function _arrayDiffAssoc($array1, $array2) {
|
||||
$difference = array();
|
||||
|
@ -565,7 +560,7 @@ class CakeSchema extends Object {
|
|||
* @param array $values options keys(type, null, default, key, length, extra)
|
||||
* @return array Formatted values
|
||||
*/
|
||||
public function __values($values) {
|
||||
protected function _values($values) {
|
||||
$vals = array();
|
||||
if (is_array($values)) {
|
||||
foreach ($values as $key => $val) {
|
||||
|
@ -586,7 +581,7 @@ class CakeSchema extends Object {
|
|||
* @param array $Obj model object
|
||||
* @return array Formatted columns
|
||||
*/
|
||||
public function __columns(&$Obj) {
|
||||
protected function _columns(&$Obj) {
|
||||
$db = $Obj->getDataSource();
|
||||
$fields = $Obj->schema(true);
|
||||
|
||||
|
@ -696,7 +691,7 @@ class CakeSchema extends Object {
|
|||
* @param string $table Full table name
|
||||
* @return string Prefix-less table name
|
||||
*/
|
||||
function _noPrefixTable($prefix, $table) {
|
||||
protected function _noPrefixTable($prefix, $table) {
|
||||
return preg_replace('/^' . preg_quote($prefix) . '/', '', $table);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ class ConnectionManager {
|
|||
* Holds a loaded instance of the Connections object
|
||||
*
|
||||
* @var DATABASE_CONFIG
|
||||
* @access public
|
||||
*/
|
||||
public static $config = null;
|
||||
|
||||
|
@ -40,7 +39,6 @@ class ConnectionManager {
|
|||
* Holds instances DataSource objects
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected static $_dataSources = array();
|
||||
|
||||
|
@ -48,7 +46,6 @@ class ConnectionManager {
|
|||
* Contains a list of all file and class names used in Connection settings
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected static $_connectionsEnum = array();
|
||||
|
||||
|
@ -57,13 +54,14 @@ class ConnectionManager {
|
|||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private static $_init = false;
|
||||
protected static $_init = false;
|
||||
|
||||
/**
|
||||
* Loads connections configuration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function init() {
|
||||
protected static function _init() {
|
||||
include_once APP . 'Config' . DS . 'database.php';
|
||||
if (class_exists('DATABASE_CONFIG')) {
|
||||
self::$config = new DATABASE_CONFIG();
|
||||
|
@ -76,13 +74,13 @@ class ConnectionManager {
|
|||
* Gets a reference to a DataSource object
|
||||
*
|
||||
* @param string $name The name of the DataSource, as defined in app/Config/database.php
|
||||
* @return object Instance
|
||||
* @return DataSource Instance
|
||||
* @throws MissingDatasourceConfigException
|
||||
* @throws MissingDatasourceFileException
|
||||
*/
|
||||
public static function getDataSource($name) {
|
||||
if (empty(self::$_init)) {
|
||||
self::init();
|
||||
self::_init();
|
||||
}
|
||||
|
||||
if (!empty(self::$_dataSources[$name])) {
|
||||
|
@ -113,7 +111,7 @@ class ConnectionManager {
|
|||
*/
|
||||
public static function sourceList() {
|
||||
if (empty(self::$_init)) {
|
||||
self::init();
|
||||
self::_init();
|
||||
}
|
||||
return array_keys(self::$_dataSources);
|
||||
}
|
||||
|
@ -121,13 +119,13 @@ class ConnectionManager {
|
|||
/**
|
||||
* 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
|
||||
* in the ConnectionManager.
|
||||
*/
|
||||
public static function getSourceName($source) {
|
||||
if (empty(self::$_init)) {
|
||||
self::init();
|
||||
self::_init();
|
||||
}
|
||||
foreach (self::$_dataSources as $name => $ds) {
|
||||
if ($ds === $source) {
|
||||
|
@ -148,7 +146,7 @@ class ConnectionManager {
|
|||
*/
|
||||
public static function loadDataSource($connName) {
|
||||
if (empty(self::$_init)) {
|
||||
self::init();
|
||||
self::_init();
|
||||
}
|
||||
|
||||
if (is_array($connName)) {
|
||||
|
@ -184,7 +182,7 @@ class ConnectionManager {
|
|||
*/
|
||||
public static function enumConnectionObjects() {
|
||||
if (empty(self::$_init)) {
|
||||
self::init();
|
||||
self::_init();
|
||||
}
|
||||
return (array) self::$config;
|
||||
}
|
||||
|
@ -194,11 +192,11 @@ class ConnectionManager {
|
|||
*
|
||||
* @param string $name The DataSource name
|
||||
* @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()) {
|
||||
if (empty(self::$_init)) {
|
||||
self::init();
|
||||
self::_init();
|
||||
}
|
||||
|
||||
if (empty($name) || empty($config) || array_key_exists($name, self::$_connectionsEnum)) {
|
||||
|
@ -218,7 +216,7 @@ class ConnectionManager {
|
|||
*/
|
||||
public static function drop($name) {
|
||||
if (empty(self::$_init)) {
|
||||
self::init();
|
||||
self::_init();
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
* @param string $name Connection name
|
||||
* @return void
|
||||
* @throws MissingDatasourceConfigException
|
||||
*/
|
||||
protected static function _getConnectionObject($name) {
|
||||
if (!empty(self::$config->{$name})) {
|
||||
|
@ -244,9 +244,10 @@ class ConnectionManager {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
private static function _connectionData($config) {
|
||||
protected static function _connectionData($config) {
|
||||
$package = $classname = $plugin = null;
|
||||
|
||||
list($plugin, $classname) = pluginSplit($config['datasource']);
|
||||
|
@ -260,6 +261,7 @@ class ConnectionManager {
|
|||
/**
|
||||
* Destructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function shutdown() {
|
||||
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 boolean $start Should session be started right now
|
||||
* @return void
|
||||
*/
|
||||
public static function init($base = null, $start = true) {
|
||||
self::$time = time();
|
||||
|
@ -229,7 +230,7 @@ class CakeSession {
|
|||
/**
|
||||
* Returns the Session id
|
||||
*
|
||||
* @param id $name string
|
||||
* @param string $id
|
||||
* @return string Session id
|
||||
*/
|
||||
public static function id($id = null) {
|
||||
|
@ -251,10 +252,10 @@ class CakeSession {
|
|||
*/
|
||||
public static function delete($name) {
|
||||
if (self::check($name)) {
|
||||
self::__overwrite($_SESSION, Set::remove($_SESSION, $name));
|
||||
self::_overwrite($_SESSION, Set::remove($_SESSION, $name));
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -263,9 +264,9 @@ class CakeSession {
|
|||
*
|
||||
* @param array $old Set of old variables => values
|
||||
* @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)) {
|
||||
foreach ($old as $key => $var) {
|
||||
if (!isset($new[$key])) {
|
||||
|
@ -283,9 +284,8 @@ class CakeSession {
|
|||
*
|
||||
* @param integer $errorNumber Error to set
|
||||
* @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)) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -300,7 +300,7 @@ class CakeSession {
|
|||
*/
|
||||
public static function error() {
|
||||
if (self::$lastError) {
|
||||
return self::__error(self::$lastError);
|
||||
return self::_error(self::$lastError);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ class CakeSession {
|
|||
self::$valid = true;
|
||||
} else {
|
||||
self::$valid = false;
|
||||
self::__setError(1, 'Session Highjacking Attempted !!!');
|
||||
self::_setError(1, 'Session Highjacking Attempted !!!');
|
||||
}
|
||||
}
|
||||
return self::$valid;
|
||||
|
@ -325,7 +325,7 @@ class CakeSession {
|
|||
/**
|
||||
* Tests that the user agent is valid and that the session hasn't 'timed out'.
|
||||
* Since timeouts are implemented in CakeSession it checks the current self::$time
|
||||
* against the time the session is set to expire. The User agent is only checked
|
||||
* against the time the session is set to expire. The User agent is only checked
|
||||
* if Session.checkAgent == true.
|
||||
*
|
||||
* @return boolean
|
||||
|
@ -363,7 +363,7 @@ class CakeSession {
|
|||
return false;
|
||||
}
|
||||
if (is_null($name)) {
|
||||
return self::__returnSessionVars();
|
||||
return self::_returnSessionVars();
|
||||
}
|
||||
if (empty($name)) {
|
||||
return false;
|
||||
|
@ -373,7 +373,7 @@ class CakeSession {
|
|||
if (!is_null($result)) {
|
||||
return $result;
|
||||
}
|
||||
self::__setError(2, "$name doesn't exist");
|
||||
self::_setError(2, "$name doesn't exist");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -382,11 +382,11 @@ class CakeSession {
|
|||
*
|
||||
* @return mixed Full $_SESSION array, or false on error.
|
||||
*/
|
||||
private static function __returnSessionVars() {
|
||||
protected static function _returnSessionVars() {
|
||||
if (!empty($_SESSION)) {
|
||||
return $_SESSION;
|
||||
}
|
||||
self::__setError(2, 'No Session vars set');
|
||||
self::_setError(2, 'No Session vars set');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ class CakeSession {
|
|||
$write = array($name => $value);
|
||||
}
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
@ -508,7 +508,9 @@ class CakeSession {
|
|||
/**
|
||||
* Find the handler class and make sure it implements the correct interface.
|
||||
*
|
||||
* @param string $handler
|
||||
* @return void
|
||||
* @throws CakeSessionException
|
||||
*/
|
||||
protected static function _getHandler($handler) {
|
||||
list($plugin, $class) = pluginSplit($handler, true);
|
||||
|
@ -526,7 +528,8 @@ class CakeSession {
|
|||
/**
|
||||
* Get one of the prebaked default session configurations.
|
||||
*
|
||||
* @return void
|
||||
* @param string $name
|
||||
* @return boolean|array
|
||||
*/
|
||||
protected static function _defaultConfig($name) {
|
||||
$defaults = array(
|
||||
|
@ -647,7 +650,7 @@ class CakeSession {
|
|||
} else {
|
||||
self::destroy();
|
||||
self::$valid = false;
|
||||
self::__setError(1, 'Session Highjacking Attempted !!!');
|
||||
self::_setError(1, 'Session Highjacking Attempted !!!');
|
||||
}
|
||||
} else {
|
||||
self::write('Config.userAgent', self::$_userAgent);
|
||||
|
@ -677,9 +680,8 @@ class CakeSession {
|
|||
* @param integer $errorNumber Number of the error
|
||||
* @param string $errorMessage Description of the error
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
private static function __setError($errorNumber, $errorMessage) {
|
||||
protected static function _setError($errorNumber, $errorMessage) {
|
||||
if (self::$error === false) {
|
||||
self::$error = array();
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ class DataSource extends Object {
|
|||
* Are we connected to the DataSource?
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
public $connected = false;
|
||||
|
||||
|
@ -36,7 +35,6 @@ class DataSource extends Object {
|
|||
* The default configuration of a specific DataSource
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $_baseConfig = array();
|
||||
|
||||
|
@ -44,15 +42,13 @@ class DataSource extends Object {
|
|||
* Holds references to descriptions loaded by the DataSource
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $__descriptions = array();
|
||||
protected $_descriptions = array();
|
||||
|
||||
/**
|
||||
* Holds a list of sources (tables) contained in the DataSource
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $_sources = null;
|
||||
|
||||
|
@ -60,7 +56,6 @@ class DataSource extends Object {
|
|||
* The DataSource configuration
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $config = array();
|
||||
|
||||
|
@ -68,7 +63,6 @@ class DataSource extends Object {
|
|||
* Whether or not this DataSource is in the middle of a transaction
|
||||
*
|
||||
* @var boolean
|
||||
* @access protected
|
||||
*/
|
||||
protected $_transactionStarted = false;
|
||||
|
||||
|
@ -77,7 +71,6 @@ class DataSource extends Object {
|
|||
* should be cached
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
public $cacheSources = true;
|
||||
|
||||
|
@ -85,7 +78,6 @@ class DataSource extends Object {
|
|||
* Constructor.
|
||||
*
|
||||
* @param array $config Array of configuration information for the datasource.
|
||||
* @return void.
|
||||
*/
|
||||
public function __construct($config = array()) {
|
||||
parent::__construct();
|
||||
|
@ -131,13 +123,13 @@ class DataSource extends Object {
|
|||
}
|
||||
$table = $model->tablePrefix . $model->table;
|
||||
|
||||
if (isset($this->__descriptions[$table])) {
|
||||
return $this->__descriptions[$table];
|
||||
if (isset($this->_descriptions[$table])) {
|
||||
return $this->_descriptions[$table];
|
||||
}
|
||||
$cache = $this->__cacheDescription($table);
|
||||
$cache = $this->_cacheDescription($table);
|
||||
|
||||
if ($cache !== null) {
|
||||
$this->__descriptions[$table] =& $cache;
|
||||
$this->_descriptions[$table] =& $cache;
|
||||
return $cache;
|
||||
}
|
||||
return null;
|
||||
|
@ -228,6 +220,7 @@ class DataSource extends Object {
|
|||
*
|
||||
* @param Model $model The model class having record(s) deleted
|
||||
* @param mixed $id Primary key of the model
|
||||
* @return void
|
||||
*/
|
||||
public function delete(Model $model, $id = null) {
|
||||
if ($id == null) {
|
||||
|
@ -238,7 +231,7 @@ class DataSource extends Object {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
public function lastInsertId($source = null) {
|
||||
|
@ -248,7 +241,7 @@ class DataSource extends Object {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
public function lastNumRows($source = null) {
|
||||
|
@ -258,7 +251,7 @@ class DataSource extends Object {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
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 mixed $data The description of the model, usually a string or array
|
||||
* @return mixed
|
||||
* @access private
|
||||
*/
|
||||
function __cacheDescription($object, $data = null) {
|
||||
protected function _cacheDescription($object, $data = null) {
|
||||
if ($this->cacheSources === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($data !== null) {
|
||||
$this->__descriptions[$object] =& $data;
|
||||
$this->_descriptions[$object] =& $data;
|
||||
}
|
||||
|
||||
$key = ConnectionManager::getSourceName($this) . '_' . $object;
|
||||
|
@ -321,12 +313,11 @@ class DataSource extends Object {
|
|||
* @param string $query Query string needing replacements done.
|
||||
* @param array $data Array of data with values that will be inserted in placeholders.
|
||||
* @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 $linkModel Instance of model to replace $__cakeForeignKey__$
|
||||
* @param array $stack
|
||||
* @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.
|
||||
*/
|
||||
public function insertQueryData($query, $data, $association, $assocData, Model $model, Model $linkModel, $stack) {
|
||||
|
@ -416,7 +407,6 @@ class DataSource extends Object {
|
|||
/**
|
||||
* Closes the current datasource.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct() {
|
||||
if ($this->_transactionStarted) {
|
||||
|
|
|
@ -74,7 +74,6 @@ class Mysql extends DboSource {
|
|||
* use alias for update and delete. Set to true if version >= 4.1
|
||||
*
|
||||
* @var boolean
|
||||
* @access protected
|
||||
*/
|
||||
protected $_useAlias = true;
|
||||
|
||||
|
@ -82,7 +81,6 @@ class Mysql extends DboSource {
|
|||
* Index of basic SQL commands
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $_commands = array(
|
||||
'begin' => 'START TRANSACTION',
|
||||
|
@ -94,7 +92,6 @@ class Mysql extends DboSource {
|
|||
* List of engine specific additional field parameters used on table creating
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $fieldParameters = array(
|
||||
'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
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $tableParameters = array(
|
||||
'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.
|
||||
*
|
||||
* @return boolean True if the database could be connected, else false
|
||||
* @throws MissingConnectionException
|
||||
*/
|
||||
public function connect() {
|
||||
$config = $this->config;
|
||||
|
@ -177,6 +174,7 @@ class Mysql extends DboSource {
|
|||
/**
|
||||
* Returns an array of sources (tables) in the database.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return array Array of tablenames in the database
|
||||
*/
|
||||
public function listSources($data = null) {
|
||||
|
@ -206,6 +204,7 @@ class Mysql extends DboSource {
|
|||
* Builds a map of the columns contained in a result
|
||||
*
|
||||
* @param PDOStatement $results
|
||||
* @return void
|
||||
*/
|
||||
public function resultSet($results) {
|
||||
$this->map = array();
|
||||
|
@ -287,10 +286,11 @@ class Mysql extends DboSource {
|
|||
/**
|
||||
* 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
|
||||
* @throws CakeException
|
||||
*/
|
||||
public function describe($model) {
|
||||
public function describe(Model $model) {
|
||||
$cache = parent::describe($model);
|
||||
if ($cache != null) {
|
||||
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();
|
||||
return $fields;
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ class Mysql extends DboSource {
|
|||
* @param mixed $conditions
|
||||
* @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) {
|
||||
return parent::update($model, $fields, $values, $conditions);
|
||||
}
|
||||
|
@ -379,7 +379,7 @@ class Mysql extends DboSource {
|
|||
* @param mixed $conditions
|
||||
* @return boolean Success
|
||||
*/
|
||||
public function delete($model, $conditions = null) {
|
||||
public function delete(Model $model, $conditions = null) {
|
||||
if (!$this->_useAlias) {
|
||||
return parent::delete($model, $conditions);
|
||||
}
|
||||
|
@ -416,6 +416,7 @@ class Mysql extends DboSource {
|
|||
* Sets the database encoding
|
||||
*
|
||||
* @param string $enc Database encoding
|
||||
* @return boolean
|
||||
*/
|
||||
public function setEncoding($enc) {
|
||||
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
|
||||
*
|
||||
* @param array $compare Result of a CakeSchema::compare()
|
||||
* @param string $table
|
||||
* @return array Array of alter statements to make.
|
||||
*/
|
||||
public function alterSchema($compare, $table = null) {
|
||||
|
@ -551,7 +553,7 @@ class Mysql extends DboSource {
|
|||
* Generate MySQL index alteration statements for a table.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
protected function _alterIndexes($table, $indexes) {
|
||||
|
|
|
@ -30,7 +30,6 @@ class DboOracle extends DboSource {
|
|||
* Configuration options
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $config = array();
|
||||
|
||||
|
@ -43,6 +42,8 @@ class DboOracle extends DboSource {
|
|||
|
||||
/**
|
||||
* Sequence names as introspected from the database
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_sequences = array();
|
||||
|
||||
|
@ -51,13 +52,12 @@ class DboOracle extends DboSource {
|
|||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $__transactionStarted = false;
|
||||
protected $_transactionStarted = false;
|
||||
|
||||
/**
|
||||
* Column definitions
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $columns = array(
|
||||
'primary_key' => array('name' => ''),
|
||||
|
@ -78,31 +78,27 @@ class DboOracle extends DboSource {
|
|||
* Connection object
|
||||
*
|
||||
* @var mixed
|
||||
* @access protected
|
||||
*/
|
||||
public $connection;
|
||||
|
||||
/**
|
||||
* Query limit
|
||||
*
|
||||
* @var int
|
||||
* @access protected
|
||||
* @var integer
|
||||
*/
|
||||
protected $_limit = -1;
|
||||
|
||||
/**
|
||||
* Query offset
|
||||
*
|
||||
* @var int
|
||||
* @access protected
|
||||
* @var integer
|
||||
*/
|
||||
protected $_offset = 0;
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
* Map
|
||||
*
|
||||
* @var unknown_type
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $_map;
|
||||
|
||||
|
@ -110,15 +106,13 @@ class DboOracle extends DboSource {
|
|||
* Current Row
|
||||
*
|
||||
* @var mixed
|
||||
* @access protected
|
||||
*/
|
||||
protected $_currentRow;
|
||||
|
||||
/**
|
||||
* Number of rows
|
||||
*
|
||||
* @var int
|
||||
* @access protected
|
||||
* @var integer
|
||||
*/
|
||||
protected $_numRows;
|
||||
|
||||
|
@ -126,14 +120,13 @@ class DboOracle extends DboSource {
|
|||
* Query results
|
||||
*
|
||||
* @var mixed
|
||||
* @access protected
|
||||
*/
|
||||
protected $_results;
|
||||
|
||||
/**
|
||||
* Last error issued by oci extension
|
||||
*
|
||||
* @var unknown_type
|
||||
* @var string
|
||||
*/
|
||||
protected $_error;
|
||||
|
||||
|
@ -155,7 +148,7 @@ class DboOracle extends DboSource {
|
|||
/**
|
||||
* Table-sequence map
|
||||
*
|
||||
* @var unknown_type
|
||||
* @var array
|
||||
*/
|
||||
protected $_sequenceMap = array();
|
||||
|
||||
|
@ -196,6 +189,9 @@ class DboOracle extends DboSource {
|
|||
/**
|
||||
* Keeps track of the most recent Oracle error
|
||||
*
|
||||
* @param mixed $source
|
||||
* @param boolean $clear
|
||||
* @return void
|
||||
*/
|
||||
protected function _setError($source = null, $clear = false) {
|
||||
if ($source) {
|
||||
|
@ -213,7 +209,7 @@ class DboOracle extends DboSource {
|
|||
* Sets the encoding language of the session
|
||||
*
|
||||
* @param string $lang language constant
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function setEncoding($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.
|
||||
*
|
||||
* @param string $sql
|
||||
* @return false if sql is nor a SELECT
|
||||
* @return void
|
||||
*/
|
||||
protected function _scrapeSQL($sql) {
|
||||
$sql = str_replace("\"", '', $sql);
|
||||
|
@ -305,7 +301,7 @@ class DboOracle extends DboSource {
|
|||
*
|
||||
* @param integer $limit Maximum number of rows to return
|
||||
* @param integer $offset Row to begin returning
|
||||
* @return modified SQL Query
|
||||
* @return void
|
||||
*/
|
||||
public function limit($limit = -1, $offset = 0) {
|
||||
$this->_limit = (int) $limit;
|
||||
|
@ -316,9 +312,10 @@ class DboOracle extends DboSource {
|
|||
* Returns number of rows in previous resultset. If no previous resultset exists,
|
||||
* this returns false.
|
||||
*
|
||||
* @param mixed $source
|
||||
* @return integer Number of rows in resultset
|
||||
*/
|
||||
public function lastNumRows() {
|
||||
public function lastNumRows($source = null) {
|
||||
return $this->_numRows;
|
||||
}
|
||||
|
||||
|
@ -326,16 +323,18 @@ class DboOracle extends DboSource {
|
|||
* Executes given SQL statement. This is an overloaded method.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
protected function _execute($sql) {
|
||||
protected function _execute($sql, $params = array(), $prepareOptions = array()) {
|
||||
$this->_statementId = @ociparse($this->connection, $sql);
|
||||
if (!$this->_statementId) {
|
||||
$this->_setError($this->connection);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->__transactionStarted) {
|
||||
if ($this->_transactionStarted) {
|
||||
$mode = OCI_DEFAULT;
|
||||
} else {
|
||||
$mode = OCI_COMMIT_ON_SUCCESS;
|
||||
|
@ -372,10 +371,10 @@ class DboOracle extends DboSource {
|
|||
/**
|
||||
* Fetch result row
|
||||
*
|
||||
* @param string $sql
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
public function fetchRow() {
|
||||
public function fetchRow($sql = null) {
|
||||
if ($this->_currentRow >= $this->_numRows) {
|
||||
ocifreestatement($this->_statementId);
|
||||
$this->_map = null;
|
||||
|
@ -402,7 +401,7 @@ class DboOracle extends DboSource {
|
|||
/**
|
||||
* Fetches the next row from the current result set
|
||||
*
|
||||
* @return unknown
|
||||
* @return array
|
||||
*/
|
||||
public function fetchResult() {
|
||||
return $this->fetchRow();
|
||||
|
@ -412,7 +411,7 @@ class DboOracle extends DboSource {
|
|||
* Checks to see if a named sequence exists
|
||||
*
|
||||
* @param string $sequence
|
||||
* @return bool
|
||||
* @return boolean|array
|
||||
*/
|
||||
public function sequenceExists($sequence) {
|
||||
$sql = "SELECT SEQUENCE_NAME FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '$sequence'";
|
||||
|
@ -426,7 +425,7 @@ class DboOracle extends DboSource {
|
|||
* Creates a database sequence
|
||||
*
|
||||
* @param string $sequence
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function createSequence($sequence) {
|
||||
$sql = "CREATE SEQUENCE $sequence";
|
||||
|
@ -438,7 +437,6 @@ class DboOracle extends DboSource {
|
|||
*
|
||||
* @param string $table
|
||||
* @return mixed
|
||||
* @access public
|
||||
*/
|
||||
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;";
|
||||
|
@ -449,9 +447,10 @@ class DboOracle extends DboSource {
|
|||
* Returns an array of tables in the database. If there are no tables, an error is
|
||||
* raised and the application exits.
|
||||
*
|
||||
* @param mixed $source
|
||||
* @return array tablenames in the database
|
||||
*/
|
||||
public function listSources() {
|
||||
public function listSources($source = null) {
|
||||
$cache = parent::listSources();
|
||||
if ($cache != null) {
|
||||
return $cache;
|
||||
|
@ -473,10 +472,10 @@ class DboOracle extends DboSource {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
public function describe($model) {
|
||||
public function describe(Model $model) {
|
||||
$table = $this->fullTableName($model, false);
|
||||
|
||||
if (!empty($model->sequence)) {
|
||||
|
@ -506,7 +505,7 @@ class DboOracle extends DboSource {
|
|||
'length'=> $row[0]['DATA_LENGTH']
|
||||
);
|
||||
}
|
||||
$this->__cacheDescription($this->fullTableName($model, false), $fields);
|
||||
$this->_cacheDescription($this->fullTableName($model, false), $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,
|
||||
* and if 1, sequences are not modified
|
||||
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param unknown_type $schema
|
||||
* @return unknown
|
||||
* @param mixed $compare
|
||||
* @param mixed $table
|
||||
* @return boolean|string
|
||||
*/
|
||||
public function alterSchema($compare, $table = null) {
|
||||
if (!is_array($compare)) {
|
||||
|
@ -730,8 +729,8 @@ class DboOracle extends DboSource {
|
|||
* This method should quote Oracle identifiers. Well it doesn't.
|
||||
* It would break all scaffolding and all of Cake's default assumptions.
|
||||
*
|
||||
* @param unknown_type $var
|
||||
* @return unknown
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function name($name) {
|
||||
if (strpos($name, '.') !== false && strpos($name, '"') === false) {
|
||||
|
@ -750,19 +749,17 @@ class DboOracle extends DboSource {
|
|||
/**
|
||||
* Begin a transaction
|
||||
*
|
||||
* @param unknown_type $model
|
||||
* @return boolean True on success, false on fail
|
||||
* (i.e. if the database/model does not support transactions).
|
||||
*/
|
||||
public function begin() {
|
||||
$this->__transactionStarted = true;
|
||||
$this->_transactionStarted = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback a transaction
|
||||
*
|
||||
* @param unknown_type $model
|
||||
* @return boolean True on success, false on fail
|
||||
* (i.e. if the database/model does not support transactions,
|
||||
* or a transaction has not started).
|
||||
|
@ -774,13 +771,12 @@ class DboOracle extends DboSource {
|
|||
/**
|
||||
* Commit a transaction
|
||||
*
|
||||
* @param unknown_type $model
|
||||
* @return boolean True on success, false on fail
|
||||
* (i.e. if the database/model does not support transactions,
|
||||
* or a transaction has not started).
|
||||
*/
|
||||
public function commit() {
|
||||
$this->__transactionStarted = false;
|
||||
$this->_transactionStarted = false;
|
||||
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.
|
||||
*
|
||||
* @param string $data String to be prepared for use in an SQL statement
|
||||
* @param string $column
|
||||
* @return string Quoted and escaped
|
||||
*/
|
||||
public function value($data, $column = null) {
|
||||
|
@ -877,10 +874,10 @@ class DboOracle extends DboSource {
|
|||
/**
|
||||
* Returns the ID generated from the previous INSERT operation.
|
||||
*
|
||||
* @param string
|
||||
* @return integer
|
||||
* @param string $source
|
||||
* @return integer|boolean
|
||||
*/
|
||||
public function lastInsertId($source) {
|
||||
public function lastInsertId($source = null) {
|
||||
$sequence = $this->_sequenceMap[$source];
|
||||
$sql = "SELECT $sequence.currval FROM dual";
|
||||
|
||||
|
@ -897,18 +894,20 @@ class DboOracle extends DboSource {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
public function lastError() {
|
||||
public function lastError(PDOStatement $query = null) {
|
||||
return $this->_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
@ -959,18 +958,19 @@ class DboOracle extends DboSource {
|
|||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
* queryAssociation method
|
||||
*
|
||||
* @param Model $model
|
||||
* @param unknown_type $linkModel
|
||||
* @param Model $linkModel
|
||||
* @param string $type Association type
|
||||
* @param unknown_type $association
|
||||
* @param unknown_type $assocData
|
||||
* @param unknown_type $queryData
|
||||
* @param unknown_type $external
|
||||
* @param unknown_type $resultSet
|
||||
* @param string $association
|
||||
* @param array $assocData
|
||||
* @param array $queryData
|
||||
* @param boolean $external
|
||||
* @param array $resultSet
|
||||
* @param integer $recursive Number of levels of association
|
||||
* @param array $stack
|
||||
* @return void
|
||||
*/
|
||||
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)) {
|
||||
|
@ -1101,16 +1101,16 @@ class DboOracle extends DboSource {
|
|||
if (empty($merge) && !isset($row[$association])) {
|
||||
$row[$association] = $merge;
|
||||
} else {
|
||||
$this->__mergeAssociation($resultSet[$i], $merge, $association, $type);
|
||||
$this->_mergeAssociation($resultSet[$i], $merge, $association, $type);
|
||||
}
|
||||
} else {
|
||||
$this->__mergeAssociation($resultSet[$i], $fetch, $association, $type);
|
||||
$this->_mergeAssociation($resultSet[$i], $fetch, $association, $type);
|
||||
}
|
||||
$resultSet[$i][$association] = $linkModel->afterfind($resultSet[$i][$association]);
|
||||
|
||||
} else {
|
||||
$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
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $description = "PostgreSQL DBO Driver";
|
||||
|
||||
|
@ -40,7 +39,6 @@ class Postgres extends DboSource {
|
|||
* Index of basic SQL commands
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $_commands = array(
|
||||
'begin' => 'BEGIN',
|
||||
|
@ -52,7 +50,6 @@ class Postgres extends DboSource {
|
|||
* Base driver configuration settings. Merged with user settings.
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $_baseConfig = array(
|
||||
'persistent' => true,
|
||||
|
@ -65,6 +62,11 @@ class Postgres extends DboSource {
|
|||
'encoding' => ''
|
||||
);
|
||||
|
||||
/**
|
||||
* Columns
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $columns = array(
|
||||
'primary_key' => array('name' => 'serial NOT NULL'),
|
||||
'string' => array('name' => 'varchar', 'limit' => '255'),
|
||||
|
@ -85,7 +87,6 @@ class Postgres extends DboSource {
|
|||
* Starting Quote
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $startQuote = '"';
|
||||
|
||||
|
@ -93,7 +94,6 @@ class Postgres extends DboSource {
|
|||
* Ending Quote
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $endQuote = '"';
|
||||
|
||||
|
@ -108,7 +108,8 @@ class Postgres extends DboSource {
|
|||
/**
|
||||
* 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() {
|
||||
$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.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return array Array of tablenames in the database
|
||||
*/
|
||||
public function listSources($data = null) {
|
||||
|
@ -181,10 +183,10 @@ class Postgres extends DboSource {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
public function describe($model) {
|
||||
public function describe(Model $model) {
|
||||
$fields = parent::describe($model);
|
||||
$table = $this->fullTableName($model, false);
|
||||
$this->_sequenceMap[$table] = array();
|
||||
|
@ -247,7 +249,7 @@ class Postgres extends DboSource {
|
|||
$fields[$c->name]['default'] = constant($fields[$c->name]['default']);
|
||||
}
|
||||
}
|
||||
$this->__cacheDescription($table, $fields);
|
||||
$this->_cacheDescription($table, $fields);
|
||||
}
|
||||
if (isset($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"
|
||||
* @return integer
|
||||
*/
|
||||
public function lastInsertId($source, $field = 'id') {
|
||||
public function lastInsertId($source = null, $field = 'id') {
|
||||
$seq = $this->getSequence($source, $field);
|
||||
return $this->_connection->lastInsertId($seq);
|
||||
}
|
||||
|
@ -336,6 +338,7 @@ class Postgres extends DboSource {
|
|||
* @param Model $model
|
||||
* @param string $alias Alias tablename
|
||||
* @param mixed $fields
|
||||
* @param boolean $quote
|
||||
* @return array
|
||||
*/
|
||||
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]);
|
||||
}
|
||||
} 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];
|
||||
}
|
||||
|
@ -391,11 +394,10 @@ class Postgres extends DboSource {
|
|||
/**
|
||||
* 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
|
||||
* @access private
|
||||
*/
|
||||
private function __quoteFunctionField($match) {
|
||||
protected function _quoteFunctionField($match) {
|
||||
$prepend = '';
|
||||
if (strpos($match[1], 'DISTINCT') !== false) {
|
||||
$prepend = 'DISTINCT ';
|
||||
|
@ -456,7 +458,6 @@ class Postgres extends DboSource {
|
|||
*
|
||||
* @param array $compare Results of CakeSchema::compare()
|
||||
* @param string $table name of the table
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function alterSchema($compare, $table = null) {
|
||||
|
@ -544,7 +545,7 @@ class Postgres extends DboSource {
|
|||
* Generate PostgreSQL index alteration statements for a table.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @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) {
|
||||
$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) {
|
||||
$this->map = array();
|
||||
|
@ -703,7 +705,7 @@ class Postgres extends DboSource {
|
|||
/**
|
||||
* Fetches the next row from the current result set
|
||||
*
|
||||
* @return unknown
|
||||
* @return array
|
||||
*/
|
||||
public function fetchResult() {
|
||||
if ($row = $this->_result->fetch()) {
|
||||
|
|
|
@ -32,33 +32,29 @@ class Sqlite extends DboSource {
|
|||
* Datasource Description
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $description = "SQLite DBO Driver";
|
||||
public $description = "SQLite DBO Driver";
|
||||
|
||||
/**
|
||||
* Quote Start
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $startQuote = '"';
|
||||
public $startQuote = '"';
|
||||
|
||||
/**
|
||||
* Quote End
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $endQuote = '"';
|
||||
public $endQuote = '"';
|
||||
|
||||
/**
|
||||
* Base configuration settings for SQLite3 driver
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $_baseConfig = array(
|
||||
protected $_baseConfig = array(
|
||||
'persistent' => false,
|
||||
'database' => null
|
||||
);
|
||||
|
@ -67,9 +63,8 @@ class Sqlite extends DboSource {
|
|||
* SQLite3 column definition
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $columns = array(
|
||||
public $columns = array(
|
||||
'primary_key' => array('name' => 'integer primary key autoincrement'),
|
||||
'string' => array('name' => 'varchar', 'limit' => '255'),
|
||||
'text' => array('name' => 'text'),
|
||||
|
@ -87,9 +82,8 @@ class Sqlite extends DboSource {
|
|||
* List of engine specific additional field parameters used on table creating
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $fieldParameters = array(
|
||||
public $fieldParameters = array(
|
||||
'collate' => array(
|
||||
'value' => 'COLLATE',
|
||||
'quote' => false,
|
||||
|
@ -105,9 +99,8 @@ class Sqlite extends DboSource {
|
|||
/**
|
||||
* Connects to the database using config['database'] as a filename.
|
||||
*
|
||||
* @param array $config Configuration array for connecting
|
||||
* @return mixed
|
||||
* @access public
|
||||
* @return boolean
|
||||
* @throws MissingConnectionException
|
||||
*/
|
||||
public function connect() {
|
||||
$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.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return array Array of tablenames in the database
|
||||
* @access public
|
||||
*/
|
||||
public function listSources($data = null) {
|
||||
$cache = parent::listSources();
|
||||
|
@ -161,11 +154,10 @@ class Sqlite extends DboSource {
|
|||
/**
|
||||
* 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
|
||||
* @access public
|
||||
*/
|
||||
public function describe($model) {
|
||||
public function describe(Model $model) {
|
||||
$cache = parent::describe($model);
|
||||
if ($cache != null) {
|
||||
return $cache;
|
||||
|
@ -193,7 +185,7 @@ class Sqlite extends DboSource {
|
|||
}
|
||||
|
||||
$result->closeCursor();
|
||||
$this->__cacheDescription($model->tablePrefix . $model->table, $fields);
|
||||
$this->_cacheDescription($model->tablePrefix . $model->table, $fields);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
@ -205,9 +197,8 @@ class Sqlite extends DboSource {
|
|||
* @param array $values
|
||||
* @param mixed $conditions
|
||||
* @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)) {
|
||||
foreach ($fields as $field => $value) {
|
||||
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
|
||||
* @return boolean SQL TRUNCATE TABLE statement, false if not applicable.
|
||||
* @access public
|
||||
*/
|
||||
public function truncate($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)")
|
||||
* @return string Abstract column type (i.e. "string")
|
||||
* @access public
|
||||
*/
|
||||
public function column($real) {
|
||||
if (is_array($real)) {
|
||||
|
@ -273,7 +262,7 @@ class Sqlite extends DboSource {
|
|||
* Generate ResultSet
|
||||
*
|
||||
* @param mixed $results
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function resultSet($results) {
|
||||
$this->results = $results;
|
||||
|
@ -356,7 +345,6 @@ class Sqlite extends DboSource {
|
|||
* @param integer $limit Limit of results returned
|
||||
* @param integer $offset Offset from which to start results
|
||||
* @return string SQL limit/offset statement
|
||||
* @access public
|
||||
*/
|
||||
public function limit($limit, $offset = null) {
|
||||
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]),
|
||||
* where options can be 'default', 'length', or 'key'.
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
public function buildColumn($column) {
|
||||
$name = $type = null;
|
||||
|
@ -408,7 +395,7 @@ class Sqlite extends DboSource {
|
|||
* Sets the database encoding
|
||||
*
|
||||
* @param string $enc Database encoding
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public function setEncoding($enc) {
|
||||
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
|
||||
*
|
||||
* @return string The database encoding
|
||||
* @access public
|
||||
*/
|
||||
public function getEncoding() {
|
||||
return $this->fetchRow('PRAGMA encoding');
|
||||
|
@ -433,7 +419,6 @@ class Sqlite extends DboSource {
|
|||
* @param array $indexes
|
||||
* @param string $table
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
public function buildIndex($indexes, $table = null) {
|
||||
$join = array();
|
||||
|
@ -466,7 +451,6 @@ class Sqlite extends DboSource {
|
|||
*
|
||||
* @param string $model Name of model to inspect
|
||||
* @return array Fields in table. Keys are column and unique
|
||||
* @access public
|
||||
*/
|
||||
public function index($model) {
|
||||
$index = array();
|
||||
|
@ -507,7 +491,6 @@ class Sqlite extends DboSource {
|
|||
* @param string $type
|
||||
* @param array $data
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
public function renderStatement($type, $data) {
|
||||
switch (strtolower($type)) {
|
||||
|
@ -531,7 +514,6 @@ class Sqlite extends DboSource {
|
|||
* PDO deals in objects, not resources, so overload accordingly.
|
||||
*
|
||||
* @return boolean
|
||||
* @access public
|
||||
*/
|
||||
public function hasResult() {
|
||||
return is_object($this->_result);
|
||||
|
@ -540,7 +522,7 @@ class Sqlite extends DboSource {
|
|||
/**
|
||||
* 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.
|
||||
* Otherwise, all tables defined in the schema are generated.
|
||||
* @return string
|
||||
|
|
|
@ -108,13 +108,6 @@ class Sqlserver extends DboSource {
|
|||
'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
|
||||
* 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.
|
||||
*
|
||||
* @return boolean True if the database could be connected, else false
|
||||
* @throws MissingConnectionException
|
||||
*/
|
||||
public function connect() {
|
||||
$config = $this->config;
|
||||
|
@ -169,9 +163,10 @@ class Sqlserver extends DboSource {
|
|||
/**
|
||||
* Returns an array of sources (tables) in the database.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return array Array of tablenames in the database
|
||||
*/
|
||||
public function listSources() {
|
||||
public function listSources($data = null) {
|
||||
$cache = parent::listSources();
|
||||
if ($cache !== null) {
|
||||
return $cache;
|
||||
|
@ -199,8 +194,9 @@ class Sqlserver extends DboSource {
|
|||
*
|
||||
* @param Model $model Model object to describe
|
||||
* @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);
|
||||
if ($cache != null) {
|
||||
return $cache;
|
||||
|
@ -208,15 +204,15 @@ class Sqlserver extends DboSource {
|
|||
$fields = array();
|
||||
$table = $this->fullTableName($model, false);
|
||||
$cols = $this->_execute(
|
||||
"SELECT
|
||||
"SELECT
|
||||
COLUMN_NAME as Field,
|
||||
DATA_TYPE as Type,
|
||||
COL_LENGTH('" . $table . "', COLUMN_NAME) as Length,
|
||||
IS_NULLABLE As [Null],
|
||||
COLUMN_DEFAULT as [Default],
|
||||
DATA_TYPE as Type,
|
||||
COL_LENGTH('" . $table . "', COLUMN_NAME) as Length,
|
||||
IS_NULLABLE As [Null],
|
||||
COLUMN_DEFAULT as [Default],
|
||||
COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key],
|
||||
NUMERIC_SCALE as Size
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
NUMERIC_SCALE as Size
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_NAME = '" . $table . "'"
|
||||
);
|
||||
if (!$cols) {
|
||||
|
@ -251,7 +247,7 @@ class Sqlserver extends DboSource {
|
|||
$fields[$field]['length'] = $fields[$field]['length'] . ',' . $column->Size;
|
||||
}
|
||||
}
|
||||
$this->__cacheDescription($table, $fields);
|
||||
$this->_cacheDescription($table, $fields);
|
||||
$cols->closeCursor();
|
||||
return $fields;
|
||||
}
|
||||
|
@ -262,7 +258,8 @@ class Sqlserver extends DboSource {
|
|||
*
|
||||
* @param Model $model
|
||||
* @param string $alias Alias tablename
|
||||
* @param mixed $fields
|
||||
* @param array $fields
|
||||
* @param boolean $quote
|
||||
* @return array
|
||||
*/
|
||||
public function fields($model, $alias = null, $fields = array(), $quote = true) {
|
||||
|
@ -327,10 +324,9 @@ class Sqlserver extends DboSource {
|
|||
* @param Model $model
|
||||
* @param array $fields
|
||||
* @param array $values
|
||||
* @param mixed $conditions
|
||||
* @return array
|
||||
*/
|
||||
public function create($model, $fields = null, $values = null) {
|
||||
public function create(Model $model, $fields = null, $values = null) {
|
||||
if (!empty($values)) {
|
||||
$fields = array_combine($fields, $values);
|
||||
}
|
||||
|
@ -360,7 +356,7 @@ class Sqlserver extends DboSource {
|
|||
* @param mixed $conditions
|
||||
* @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)) {
|
||||
$fields = array_combine($fields, $values);
|
||||
}
|
||||
|
@ -464,6 +460,7 @@ class Sqlserver extends DboSource {
|
|||
* Builds a map of the columns contained in a result
|
||||
*
|
||||
* @param PDOStatement $results
|
||||
* @return void
|
||||
*/
|
||||
public function resultSet($results) {
|
||||
$this->map = array();
|
||||
|
@ -589,11 +586,12 @@ class Sqlserver extends DboSource {
|
|||
* Returns an array of all result rows for a given SQL query.
|
||||
* Returns false if no rows matched.
|
||||
*
|
||||
* @param string $sql SQL statement
|
||||
* @param boolean $cache Enables returning/storing cached query results
|
||||
* @param Model $model
|
||||
* @param array $queryData
|
||||
* @param integer $recursive
|
||||
* @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);
|
||||
$this->_fieldMappings = array();
|
||||
return $results;
|
||||
|
@ -630,6 +628,7 @@ class Sqlserver extends DboSource {
|
|||
* @param string $table
|
||||
* @param string $fields
|
||||
* @param array $values
|
||||
* @return void
|
||||
*/
|
||||
public function insertMulti($table, $fields, $values) {
|
||||
$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,
|
||||
* this returns false.
|
||||
*
|
||||
* @param mixed $source
|
||||
* @return integer Number of affected rows
|
||||
*/
|
||||
public function lastAffected() {
|
||||
public function lastAffected($source = null) {
|
||||
$affected = parent::lastAffected();
|
||||
if ($affected === null && $this->_lastAffected !== false) {
|
||||
return $this->_lastAffected;
|
||||
|
|
|
@ -34,7 +34,6 @@ class DboSource extends DataSource {
|
|||
* Description string for this Database Data Source.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $description = "Database Data Source";
|
||||
|
||||
|
@ -49,7 +48,6 @@ class DboSource extends DataSource {
|
|||
* Database keyword used to assign aliases to identifiers.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $alias = 'AS ';
|
||||
|
||||
|
@ -60,7 +58,6 @@ class DboSource extends DataSource {
|
|||
* with collisions, set DboSource::$cacheMethods to false.
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @var boolean.
|
||||
* @access public
|
||||
*/
|
||||
public $cacheMethods = true;
|
||||
|
||||
|
@ -77,15 +73,13 @@ class DboSource extends DataSource {
|
|||
* Print full query debug info?
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
public $fullDebug = false;
|
||||
|
||||
/**
|
||||
* Error description of last query
|
||||
*
|
||||
* @var unknown_type
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $error = null;
|
||||
|
||||
|
@ -93,23 +87,20 @@ class DboSource extends DataSource {
|
|||
* String to hold how many rows were affected by the last SQL operation.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $affected = null;
|
||||
|
||||
/**
|
||||
* Number of rows in current resultset
|
||||
*
|
||||
* @var int
|
||||
* @access public
|
||||
* @var integer
|
||||
*/
|
||||
public $numRows = null;
|
||||
|
||||
/**
|
||||
* Time the last query took
|
||||
*
|
||||
* @var int
|
||||
* @access public
|
||||
* @var integer
|
||||
*/
|
||||
public $took = null;
|
||||
|
||||
|
@ -117,31 +108,27 @@ class DboSource extends DataSource {
|
|||
* Result
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $_result = null;
|
||||
|
||||
/**
|
||||
* Queries count.
|
||||
*
|
||||
* @var int
|
||||
* @access protected
|
||||
* @var integer
|
||||
*/
|
||||
protected $_queriesCnt = 0;
|
||||
|
||||
/**
|
||||
* Total duration of all queries.
|
||||
*
|
||||
* @var unknown_type
|
||||
* @access protected
|
||||
* @var integer
|
||||
*/
|
||||
protected $_queriesTime = null;
|
||||
|
||||
/**
|
||||
* Log of queries executed by this DataSource
|
||||
*
|
||||
* @var unknown_type
|
||||
* @access protected
|
||||
* @var array
|
||||
*/
|
||||
protected $_queriesLog = array();
|
||||
|
||||
|
@ -150,8 +137,7 @@ class DboSource extends DataSource {
|
|||
*
|
||||
* This is to prevent query log taking over too much memory.
|
||||
*
|
||||
* @var int Maximum number of queries in the queries log.
|
||||
* @access protected
|
||||
* @var integer Maximum number of queries in the queries log.
|
||||
*/
|
||||
protected $_queriesLogMax = 200;
|
||||
|
||||
|
@ -159,7 +145,6 @@ class DboSource extends DataSource {
|
|||
* Caches serialzed results of executed queries
|
||||
*
|
||||
* @var array Maximum number of queries in the queries log.
|
||||
* @access protected
|
||||
*/
|
||||
protected $_queryCache = array();
|
||||
|
||||
|
@ -167,7 +152,6 @@ class DboSource extends DataSource {
|
|||
* A reference to the physical connection of this DataSource
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $connection = null;
|
||||
|
||||
|
@ -175,7 +159,6 @@ class DboSource extends DataSource {
|
|||
* The DataSource configuration key name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $configKeyName = null;
|
||||
|
||||
|
@ -183,7 +166,6 @@ class DboSource extends DataSource {
|
|||
* The starting character that this DataSource uses for quoted identifiers.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $startQuote = null;
|
||||
|
||||
|
@ -191,7 +173,6 @@ class DboSource extends DataSource {
|
|||
* The ending character that this DataSource uses for quoted identifiers.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $endQuote = null;
|
||||
|
||||
|
@ -199,15 +180,13 @@ class DboSource extends DataSource {
|
|||
* The set of valid SQL operations usable in a WHERE statement
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* @var integer
|
||||
* @access protected
|
||||
*/
|
||||
protected $_transactionNesting = 0;
|
||||
|
||||
|
@ -215,7 +194,6 @@ class DboSource extends DataSource {
|
|||
* Index of basic SQL commands
|
||||
*
|
||||
* @var array
|
||||
* @access protected
|
||||
*/
|
||||
protected $_commands = array(
|
||||
'begin' => 'BEGIN',
|
||||
|
@ -234,7 +212,6 @@ class DboSource extends DataSource {
|
|||
* List of table engine specific parameters used on table creating
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $tableParameters = array();
|
||||
|
||||
|
@ -242,7 +219,6 @@ class DboSource extends DataSource {
|
|||
* List of engine specific additional field parameters used on table creating
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $fieldParameters = array();
|
||||
|
||||
|
@ -376,7 +352,7 @@ class DboSource extends DataSource {
|
|||
* are not sanitized or esacped.
|
||||
*
|
||||
* @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) {
|
||||
$obj = new stdClass();
|
||||
|
@ -390,7 +366,7 @@ class DboSource extends DataSource {
|
|||
* are not sanitized or esacped.
|
||||
*
|
||||
* @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) {
|
||||
$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,
|
||||
* this returns false.
|
||||
*
|
||||
* @param mixed $source
|
||||
* @return integer Number of affected rows
|
||||
*/
|
||||
public function lastAffected() {
|
||||
public function lastAffected($source = null) {
|
||||
if ($this->hasResult()) {
|
||||
return $this->_result->rowCount();
|
||||
}
|
||||
|
@ -516,9 +493,10 @@ class DboSource extends DataSource {
|
|||
* Returns number of rows in previous resultset. If no previous resultset exists,
|
||||
* this returns false.
|
||||
*
|
||||
* @param mixed $source Not used
|
||||
* @return integer Number of rows in resultset
|
||||
*/
|
||||
public function lastNumRows() {
|
||||
public function lastNumRows($source = null) {
|
||||
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
|
||||
*
|
||||
* @param array $resut Reference to the fetched row
|
||||
* @param array $result Reference to the fetched row
|
||||
* @return void
|
||||
*/
|
||||
public function fetchVirtualField(&$result) {
|
||||
|
@ -913,6 +891,7 @@ class DboSource extends DataSource {
|
|||
* Log given SQL query.
|
||||
*
|
||||
* @param string $sql SQL statement
|
||||
* @return void|boolean
|
||||
* @todo: Add hook to log errors instead of returning false
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param string $sql Query to show information on.
|
||||
* @return void
|
||||
*/
|
||||
public function showQuery($sql) {
|
||||
$error = $this->error;
|
||||
|
@ -988,7 +968,7 @@ class DboSource extends DataSource {
|
|||
* be used to generate values.
|
||||
* @return boolean Success
|
||||
*/
|
||||
public function create($model, $fields = null, $values = null) {
|
||||
public function create(Model $model, $fields = null, $values = null) {
|
||||
$id = null;
|
||||
|
||||
if ($fields == null) {
|
||||
|
@ -1035,8 +1015,8 @@ class DboSource extends DataSource {
|
|||
* @param integer $recursive Number of levels of association
|
||||
* @return mixed boolean false on error/failure. An array of results on success.
|
||||
*/
|
||||
public function read($model, $queryData = array(), $recursive = null) {
|
||||
$queryData = $this->__scrubQueryData($queryData);
|
||||
public function read(Model $model, $queryData = array(), $recursive = null) {
|
||||
$queryData = $this->_scrubQueryData($queryData);
|
||||
|
||||
$null = null;
|
||||
$array = array();
|
||||
|
@ -1133,7 +1113,7 @@ class DboSource extends DataSource {
|
|||
* Passes association results thru afterFind filters of corresponding model
|
||||
*
|
||||
* @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
|
||||
* @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 $linkModel Linked model that
|
||||
* @param string $type Association type, one of the model association types ie. hasMany
|
||||
* @param unknown_type $association
|
||||
* @param unknown_type $assocData
|
||||
* @param string $association
|
||||
* @param array $assocData
|
||||
* @param array $queryData
|
||||
* @param boolean $external Whether or not the association query is on an external datasource.
|
||||
* @param array $resultSet Existing results
|
||||
* @param integer $recursive Number of levels of association
|
||||
* @param array $stack
|
||||
* @return mixed
|
||||
*/
|
||||
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)) {
|
||||
|
@ -1219,7 +1200,7 @@ class DboSource extends DataSource {
|
|||
}
|
||||
}
|
||||
$this->_filterResults($fetch, $model);
|
||||
return $this->__mergeHasMany($resultSet, $fetch, $association, $model, $linkModel);
|
||||
return $this->_mergeHasMany($resultSet, $fetch, $association, $model, $linkModel);
|
||||
} elseif ($type === 'hasAndBelongsToMany') {
|
||||
$ins = $fetch = array();
|
||||
foreach ($resultSet as &$result) {
|
||||
|
@ -1298,17 +1279,17 @@ class DboSource extends DataSource {
|
|||
if (empty($merge) && !isset($row[$association])) {
|
||||
$row[$association] = $merge;
|
||||
} else {
|
||||
$this->__mergeAssociation($row, $merge, $association, $type);
|
||||
$this->_mergeAssociation($row, $merge, $association, $type);
|
||||
}
|
||||
} else {
|
||||
$this->__mergeAssociation($row, $fetch, $association, $type, $selfJoin);
|
||||
$this->_mergeAssociation($row, $fetch, $association, $type, $selfJoin);
|
||||
}
|
||||
if (isset($row[$association])) {
|
||||
$row[$association] = $linkModel->afterFind($row[$association], false);
|
||||
}
|
||||
} else {
|
||||
$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!
|
||||
*
|
||||
* @param model $model Primary model object
|
||||
* @param Model $model Primary model object
|
||||
* @param string $query Association query
|
||||
* @param array $ids Array of IDs of associated records
|
||||
* @return array Association results
|
||||
|
@ -1337,11 +1318,11 @@ class DboSource extends DataSource {
|
|||
* @param array $resultSet Data to merge into
|
||||
* @param array $merge Data to merge
|
||||
* @param string $association Name of Model being Merged
|
||||
* @param object $model Model being merged onto
|
||||
* @param object $linkModel Model being merged
|
||||
* @param Model $model Model being merged onto
|
||||
* @param Model $linkModel Model being merged
|
||||
* @return void
|
||||
*/
|
||||
private function __mergeHasMany(&$resultSet, $merge, $association, $model, $linkModel) {
|
||||
protected function _mergeHasMany(&$resultSet, $merge, $association, $model, $linkModel) {
|
||||
$modelAlias = $model->alias;
|
||||
$modelPK = $model->primaryKey;
|
||||
$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 unknown_type $merge
|
||||
* @param unknown_type $association
|
||||
* @param unknown_type $type
|
||||
* @param array $data
|
||||
* @param array $merge
|
||||
* @param string $association
|
||||
* @param string $type
|
||||
* @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])) {
|
||||
$association = Inflector::pluralize($association);
|
||||
}
|
||||
|
@ -1465,8 +1446,8 @@ class DboSource extends DataSource {
|
|||
* @return mixed
|
||||
*/
|
||||
public function generateAssociationQuery($model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) {
|
||||
$queryData = $this->__scrubQueryData($queryData);
|
||||
$assocData = $this->__scrubQueryData($assocData);
|
||||
$queryData = $this->_scrubQueryData($queryData);
|
||||
$assocData = $this->_scrubQueryData($assocData);
|
||||
$modelAlias = $model->alias;
|
||||
|
||||
if (empty($queryData['fields'])) {
|
||||
|
@ -1520,7 +1501,7 @@ class DboSource extends DataSource {
|
|||
switch ($type) {
|
||||
case 'hasOne':
|
||||
case 'belongsTo':
|
||||
$conditions = $this->__mergeConditions(
|
||||
$conditions = $this->_mergeConditions(
|
||||
$assocData['conditions'],
|
||||
$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']}")));
|
||||
}
|
||||
$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']),
|
||||
'table' => $this->fullTableName($linkModel),
|
||||
'alias' => $association,
|
||||
|
@ -1622,8 +1603,11 @@ class DboSource extends DataSource {
|
|||
* Returns a conditions array for the constraint between two models
|
||||
*
|
||||
* @param string $type Association type
|
||||
* @param object $model Model object
|
||||
* @param array $association Association array
|
||||
* @param Model $model Model object
|
||||
* @param string $linkModel
|
||||
* @param string $alias
|
||||
* @param array $assoc
|
||||
* @param string $alias2
|
||||
* @return array Conditions array defining the constraint between $model and $association
|
||||
*/
|
||||
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
|
||||
* @return string An SQL JOIN statement to be used in a query
|
||||
* @access public
|
||||
* @see DboSource::renderJoinStatement()
|
||||
* @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.
|
||||
*
|
||||
* @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
|
||||
* @access public
|
||||
* @see DboSource::renderStatement()
|
||||
*/
|
||||
public function buildStatement($query, $model) {
|
||||
|
@ -1771,7 +1753,7 @@ class DboSource extends DataSource {
|
|||
* @param mixed $assoc
|
||||
* @return array
|
||||
*/
|
||||
private function __mergeConditions($query, $assoc) {
|
||||
protected function _mergeConditions($query, $assoc) {
|
||||
if (empty($assoc)) {
|
||||
return $query;
|
||||
}
|
||||
|
@ -1803,7 +1785,7 @@ class DboSource extends DataSource {
|
|||
* @param mixed $conditions
|
||||
* @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) {
|
||||
$combined = $fields;
|
||||
} else {
|
||||
|
@ -1880,7 +1862,7 @@ class DboSource extends DataSource {
|
|||
* @param mixed $conditions
|
||||
* @return boolean Success
|
||||
*/
|
||||
public function delete($model, $conditions = null) {
|
||||
public function delete(Model $model, $conditions = null) {
|
||||
$alias = $joins = null;
|
||||
$table = $this->fullTableName($model);
|
||||
$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
|
||||
*
|
||||
* @param object $model
|
||||
* @param Model $model
|
||||
* @return array
|
||||
*/
|
||||
protected function _getJoins($model) {
|
||||
|
@ -1963,7 +1945,7 @@ class DboSource extends DataSource {
|
|||
'alias' => $assoc,
|
||||
'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT',
|
||||
'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
|
||||
))
|
||||
));
|
||||
|
@ -1975,7 +1957,7 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* 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 array $params Function parameters (any values must be quoted manually)
|
||||
* @return string An SQL calculation function
|
||||
|
@ -1992,7 +1974,7 @@ class DboSource extends DataSource {
|
|||
$params[1] = 'count';
|
||||
}
|
||||
if (is_object($model) && $model->isVirtualField($params[0])){
|
||||
$arg = $this->__quoteFields($model->getVirtualField($params[0]));
|
||||
$arg = $this->_quoteFields($model->getVirtualField($params[0]));
|
||||
} else {
|
||||
$arg = $this->name($params[0]);
|
||||
}
|
||||
|
@ -2003,7 +1985,7 @@ class DboSource extends DataSource {
|
|||
$params[1] = $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 {
|
||||
$arg = $this->name($params[0]);
|
||||
}
|
||||
|
@ -2078,8 +2060,8 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* Returns the ID generated from the previous INSERT operation.
|
||||
*
|
||||
* @param unknown_type $source
|
||||
* @return in
|
||||
* @param mixed $source
|
||||
* @return mixed
|
||||
*/
|
||||
public function lastInsertId($source = null) {
|
||||
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
|
||||
* 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,
|
||||
* 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.
|
||||
|
@ -2120,12 +2102,12 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* Returns a key formatted like a string Model.fieldname(i.e. Post.title, or Country.name)
|
||||
*
|
||||
* @param unknown_type $model
|
||||
* @param unknown_type $key
|
||||
* @param unknown_type $assoc
|
||||
* @param Model $model
|
||||
* @param string $key
|
||||
* @param string $assoc
|
||||
* @return string
|
||||
*/
|
||||
public function resolveKey($model, $key, $assoc = null) {
|
||||
public function resolveKey(Model $model, $key, $assoc = null) {
|
||||
if (empty($assoc)) {
|
||||
$assoc = $model->alias;
|
||||
}
|
||||
|
@ -2141,7 +2123,7 @@ class DboSource extends DataSource {
|
|||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
function __scrubQueryData($data) {
|
||||
protected function _scrubQueryData($data) {
|
||||
static $base = null;
|
||||
if ($base === null) {
|
||||
$base = array_fill_keys(array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'), array());
|
||||
|
@ -2161,7 +2143,7 @@ class DboSource extends DataSource {
|
|||
$virtual = array();
|
||||
foreach ($fields as $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}";
|
||||
}
|
||||
return $virtual;
|
||||
|
@ -2324,7 +2306,7 @@ class DboSource extends DataSource {
|
|||
if (preg_match($clauses, $conditions, $match)) {
|
||||
$clause = '';
|
||||
}
|
||||
$conditions = $this->__quoteFields($conditions);
|
||||
$conditions = $this->_quoteFields($conditions);
|
||||
return $clause . $conditions;
|
||||
}
|
||||
|
||||
|
@ -2355,7 +2337,7 @@ class DboSource extends DataSource {
|
|||
if (is_numeric($key) && empty($value)) {
|
||||
continue;
|
||||
} 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)) {
|
||||
if (in_array(strtolower(trim($key)), $bool)) {
|
||||
$join = ' ' . strtoupper($key) . ' ';
|
||||
|
@ -2396,9 +2378,9 @@ class DboSource extends DataSource {
|
|||
if ($keys === array_values($keys)) {
|
||||
$count = count($value);
|
||||
if ($count === 1) {
|
||||
$data = $this->__quoteFields($key) . ' = (';
|
||||
$data = $this->_quoteFields($key) . ' = (';
|
||||
} else {
|
||||
$data = $this->__quoteFields($key) . ' IN (';
|
||||
$data = $this->_quoteFields($key) . ' IN (';
|
||||
}
|
||||
if ($quoteValues) {
|
||||
if (is_object($model)) {
|
||||
|
@ -2416,9 +2398,9 @@ class DboSource extends DataSource {
|
|||
}
|
||||
}
|
||||
} elseif (is_numeric($key) && !empty($value)) {
|
||||
$data = $this->__quoteFields($value);
|
||||
$data = $this->_quoteFields($value);
|
||||
} else {
|
||||
$data = $this->__parseKey($model, trim($key), $value);
|
||||
$data = $this->_parseKey($model, trim($key), $value);
|
||||
}
|
||||
|
||||
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 mixed $value The value(s) to be inserted in the string
|
||||
* @return string
|
||||
* @access private
|
||||
*/
|
||||
private function __parseKey($model, $key, $value) {
|
||||
$operatorMatch = '/^((' . implode(')|(', $this->__sqlOps);
|
||||
protected function _parseKey($model, $key, $value) {
|
||||
$operatorMatch = '/^((' . implode(')|(', $this->_sqlOps);
|
||||
$operatorMatch .= '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is';
|
||||
$bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false));
|
||||
|
||||
|
@ -2460,7 +2441,7 @@ class DboSource extends DataSource {
|
|||
|
||||
$virtual = false;
|
||||
if (is_object($model) && $model->isVirtualField($key)) {
|
||||
$key = $this->__quoteFields($model->getVirtualField($key));
|
||||
$key = $this->_quoteFields($model->getVirtualField($key));
|
||||
$virtual = true;
|
||||
}
|
||||
|
||||
|
@ -2478,7 +2459,7 @@ class DboSource extends DataSource {
|
|||
|
||||
if (!$virtual && $key !== '?') {
|
||||
$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) {
|
||||
|
@ -2525,9 +2506,8 @@ class DboSource extends DataSource {
|
|||
*
|
||||
* @param string $conditions
|
||||
* @return string or false if no match
|
||||
* @access private
|
||||
*/
|
||||
private function __quoteFields($conditions) {
|
||||
protected function _quoteFields($conditions) {
|
||||
$start = $end = null;
|
||||
$original = $conditions;
|
||||
|
||||
|
@ -2538,7 +2518,7 @@ class DboSource extends DataSource {
|
|||
$end = preg_quote($this->endQuote);
|
||||
}
|
||||
$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) {
|
||||
return $conditions;
|
||||
|
@ -2549,11 +2529,10 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* 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
|
||||
* @access private
|
||||
*/
|
||||
private function __quoteMatchedField($match) {
|
||||
protected function _quoteMatchedField($match) {
|
||||
if (is_numeric($match[0])) {
|
||||
return $match[0];
|
||||
}
|
||||
|
@ -2587,9 +2566,9 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* 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 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
|
||||
*/
|
||||
public function order($keys, $direction = 'ASC', $model = null) {
|
||||
|
@ -2634,11 +2613,11 @@ class DboSource extends DataSource {
|
|||
$key = trim($key);
|
||||
|
||||
if (is_object($model) && $model->isVirtualField($key)) {
|
||||
$key = '(' . $this->__quoteFields($model->getVirtualField($key)) . ')';
|
||||
$key = '(' . $this->_quoteFields($model->getVirtualField($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) {
|
||||
$key = $this->name($key);
|
||||
|
@ -2656,7 +2635,8 @@ class DboSource extends DataSource {
|
|||
* Create a GROUP BY SQL clause
|
||||
*
|
||||
* @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) {
|
||||
if ($group) {
|
||||
|
@ -2669,7 +2649,7 @@ class DboSource extends DataSource {
|
|||
}
|
||||
}
|
||||
$group = implode(', ', $group);
|
||||
return ' GROUP BY ' . $this->__quoteFields($group);
|
||||
return ' GROUP BY ' . $this->_quoteFields($group);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -2686,7 +2666,7 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* 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)
|
||||
* @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
|
||||
*
|
||||
* @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) {
|
||||
if ($quote) {
|
||||
|
@ -2784,6 +2765,7 @@ class DboSource extends DataSource {
|
|||
* @param string $table
|
||||
* @param string $fields
|
||||
* @param array $values
|
||||
* @return boolean
|
||||
*/
|
||||
public function insertMulti($table, $fields, $values) {
|
||||
$table = $this->fullTableName($table);
|
||||
|
@ -2814,7 +2796,7 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* 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.
|
||||
* Otherwise, all tables defined in the schema are generated.
|
||||
* @return string
|
||||
|
@ -2863,9 +2845,10 @@ 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
|
||||
*/
|
||||
public function alterSchema($compare, $table = null) {
|
||||
|
@ -3011,8 +2994,7 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* Read additional table parameters
|
||||
*
|
||||
* @param array $parameters
|
||||
* @param string $table
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function readTableParameters($name) {
|
||||
|
@ -3137,7 +3119,6 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* Used for storing in cache the results of the in-memory methodCache
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct() {
|
||||
if ($this->_methodCacheChange) {
|
||||
|
|
|
@ -30,7 +30,6 @@ class CacheSession implements CakeSessionHandlerInterface {
|
|||
* Method called on open of a database session.
|
||||
*
|
||||
* @return boolean Success
|
||||
* @access private
|
||||
*/
|
||||
public function open() {
|
||||
return true;
|
||||
|
@ -40,7 +39,6 @@ class CacheSession implements CakeSessionHandlerInterface {
|
|||
* Method called on close of a database session.
|
||||
*
|
||||
* @return boolean Success
|
||||
* @access private
|
||||
*/
|
||||
public function close() {
|
||||
$probability = mt_rand(1, 150);
|
||||
|
@ -55,7 +53,6 @@ class CacheSession implements CakeSessionHandlerInterface {
|
|||
*
|
||||
* @param mixed $id The key of the value to read
|
||||
* @return mixed The value of the key or false if it does not exist
|
||||
* @access private
|
||||
*/
|
||||
public function read($id) {
|
||||
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 mixed $data The value of the data to be saved.
|
||||
* @return boolean True for successful write, false otherwise.
|
||||
* @access private
|
||||
*/
|
||||
public function write($id, $data) {
|
||||
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
|
||||
* @return boolean True for successful delete, false otherwise.
|
||||
* @access private
|
||||
*/
|
||||
public function destroy($id) {
|
||||
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)
|
||||
* @return boolean Success
|
||||
* @access private
|
||||
*/
|
||||
public function gc($expires = null) {
|
||||
return Cache::gc();
|
||||
|
|
|
@ -27,11 +27,10 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
* Constructor. Looks at Session configuration information and
|
||||
* sets up the session model.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$modelName = Configure::read('Session.handler.model');
|
||||
|
||||
|
||||
if (empty($modelName)) {
|
||||
$settings = array(
|
||||
'class' =>'Session',
|
||||
|
@ -51,7 +50,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
* Method called on open of a database session.
|
||||
*
|
||||
* @return boolean Success
|
||||
* @access private
|
||||
*/
|
||||
public function open() {
|
||||
return true;
|
||||
|
@ -61,7 +59,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
* Method called on close of a database session.
|
||||
*
|
||||
* @return boolean Success
|
||||
* @access private
|
||||
*/
|
||||
public function close() {
|
||||
$probability = mt_rand(1, 150);
|
||||
|
@ -76,7 +73,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
*
|
||||
* @param mixed $id The key of the value to read
|
||||
* @return mixed The value of the key or false if it does not exist
|
||||
* @access private
|
||||
*/
|
||||
public function read($id) {
|
||||
$model = ClassRegistry::getObject('Session');
|
||||
|
@ -98,7 +94,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
* @param integer $id ID that uniquely identifies session in database
|
||||
* @param mixed $data The value of the data to be saved.
|
||||
* @return boolean True for successful write, false otherwise.
|
||||
* @access private
|
||||
*/
|
||||
public function write($id, $data) {
|
||||
if (!$id) {
|
||||
|
@ -116,7 +111,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
*
|
||||
* @param integer $id ID that uniquely identifies session in database
|
||||
* @return boolean True for successful delete, false otherwise.
|
||||
* @access private
|
||||
*/
|
||||
public function destroy($id) {
|
||||
return ClassRegistry::getObject('Session')->delete($id);
|
||||
|
@ -127,7 +121,6 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
|||
*
|
||||
* @param integer $expires Timestamp (defaults to current time)
|
||||
* @return boolean Success
|
||||
* @access private
|
||||
*/
|
||||
public function gc($expires = null) {
|
||||
if (!$expires) {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -47,7 +47,7 @@
|
|||
* than a normal behavior mixin method.
|
||||
*
|
||||
* {{{
|
||||
* var $mapMethods = array('/do(\w+)/' => 'doSomething');
|
||||
* public $mapMethods = array('/do(\w+)/' => 'doSomething');
|
||||
*
|
||||
* function doSomething($model, $method, $arg1, $arg2) {
|
||||
* //do something
|
||||
|
@ -88,8 +88,9 @@ class ModelBehavior extends Object {
|
|||
/**
|
||||
* 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
|
||||
* @return void
|
||||
*/
|
||||
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
|
||||
* 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()
|
||||
*/
|
||||
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
|
||||
* that is going to be run.
|
||||
*
|
||||
* @param object $model Model using this behavior
|
||||
* @param array $queryData 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
|
||||
* @param Model $model Model using this behavior
|
||||
* @param array $query Data used to execute this query, i.e. conditions, order, etc.
|
||||
* @return boolean|array False or null will abort the operation. You can return an array to replace the
|
||||
* $query that will be eventually run.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param object $model Model using this behavior
|
||||
* @param Model $model Model using this behavior
|
||||
* @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)
|
||||
* @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
|
||||
* 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.
|
||||
* @access public
|
||||
*/
|
||||
public function beforeValidate($model) {
|
||||
return true;
|
||||
|
@ -147,7 +148,7 @@ class ModelBehavior extends Object {
|
|||
* beforeSave is called before a model is saved. Returning false from a beforeSave callback
|
||||
* 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.
|
||||
*/
|
||||
public function beforeSave($model) {
|
||||
|
@ -157,8 +158,9 @@ class ModelBehavior extends Object {
|
|||
/**
|
||||
* 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
|
||||
* @return boolean
|
||||
*/
|
||||
public function afterSave($model, $created) {
|
||||
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
|
||||
* 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
|
||||
* @return mixed False if the operation should abort. Any other result will continue.
|
||||
* @access public
|
||||
*/
|
||||
public function beforeDelete($model, $cascade = true) {
|
||||
return true;
|
||||
|
@ -180,15 +181,17 @@ class ModelBehavior extends Object {
|
|||
/**
|
||||
* 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) { }
|
||||
|
||||
/**
|
||||
* DataSource error callback
|
||||
*
|
||||
* @param object $model Model using this behavior
|
||||
* @param Model $model Model using this behavior
|
||||
* @param string $error Error generated in DataSource
|
||||
* @return void
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -34,7 +34,6 @@ class Permission extends AppModel {
|
|||
* Model name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $name = 'Permission';
|
||||
|
||||
|
@ -42,7 +41,6 @@ class Permission extends AppModel {
|
|||
* Explicitly disable in-memory query caching
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
public $cacheQueries = false;
|
||||
|
||||
|
@ -50,7 +48,6 @@ class Permission extends AppModel {
|
|||
* Override default table name
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
public $useTable = 'aros_acos';
|
||||
|
||||
|
@ -58,7 +55,6 @@ class Permission extends AppModel {
|
|||
* Permissions link AROs with ACOs
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $belongsTo = array('Aro', 'Aco');
|
||||
|
||||
|
@ -66,7 +62,6 @@ class Permission extends AppModel {
|
|||
* No behaviors for this model
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $actsAs = null;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* CakeRequest
|
||||
* CakeRequest
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
|
@ -21,7 +21,7 @@ App::uses('Set', 'Utility');
|
|||
/**
|
||||
* A class that helps wrap Request information and particulars about a single request.
|
||||
* Provides methods commonly used to introspect on the request headers and request body.
|
||||
*
|
||||
*
|
||||
* Has both an Array and Object interface. You can access framework parameters using indexes:
|
||||
*
|
||||
* `$request['controller']` or `$request->controller`.
|
||||
|
@ -84,7 +84,7 @@ class CakeRequest implements ArrayAccess {
|
|||
/**
|
||||
* The built in detectors used with `is()` can be modified with `addDetector()`.
|
||||
*
|
||||
* There are several ways to specify a detector, see CakeRequest::addDetector() for the
|
||||
* There are several ways to specify a detector, see CakeRequest::addDetector() for the
|
||||
* various formats and ways to define detectors.
|
||||
*
|
||||
* @var array
|
||||
|
@ -113,14 +113,13 @@ class CakeRequest implements ArrayAccess {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
private $__input = '';
|
||||
protected $_input = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor
|
||||
*
|
||||
* @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.
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($url = null, $parseEnvironment = true) {
|
||||
$this->_base();
|
||||
|
@ -384,7 +383,7 @@ class CakeRequest implements ArrayAccess {
|
|||
* @param string $name The method called
|
||||
* @param array $params Array of parameters for the method call
|
||||
* @return mixed
|
||||
* @throws BadMethodCallException when an invalid method is called.
|
||||
* @throws CakeException when an invalid method is called.
|
||||
*/
|
||||
public function __call($name, $params) {
|
||||
if (strpos($name, 'is') === 0) {
|
||||
|
@ -411,7 +410,7 @@ class CakeRequest implements ArrayAccess {
|
|||
|
||||
/**
|
||||
* Check whether or not a Request is a certain type. Uses the built in detection rules
|
||||
* as well as additional rules defined with CakeRequest::addDetector(). Any detector can be called
|
||||
* as well as additional rules defined with CakeRequest::addDetector(). Any detector can be called
|
||||
* as `is($type)` or `is$Type()`.
|
||||
*
|
||||
* @param string $type The type of request you want to check.
|
||||
|
@ -455,7 +454,7 @@ class CakeRequest implements ArrayAccess {
|
|||
* ### Pattern value comparison
|
||||
*
|
||||
* Pattern value comparison allows you to compare a value fetched from `env()` to a regular expression.
|
||||
*
|
||||
*
|
||||
* e.g `addDetector('iphone', array('env' => 'HTTP_USER_AGENT', 'pattern' => '/iPhone/i'));`
|
||||
*
|
||||
* ### Option based comparison
|
||||
|
@ -500,7 +499,7 @@ class CakeRequest implements ArrayAccess {
|
|||
* Provides an easy way to modify, here, webroot and base.
|
||||
*
|
||||
* @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) {
|
||||
foreach (array('webroot', 'here', 'base') as $element) {
|
||||
|
@ -544,10 +543,10 @@ class CakeRequest implements ArrayAccess {
|
|||
|
||||
/**
|
||||
* Get the HTTP method used for this request.
|
||||
* There are a few ways to specify a method.
|
||||
* There are a few ways to specify a method.
|
||||
*
|
||||
* - If your client supports it you can use native HTTP methods.
|
||||
* - You can set the HTTP-X-Method-Override header.
|
||||
* - You can set the HTTP-X-Method-Override header.
|
||||
* - You can submit an input with the name `_method`
|
||||
*
|
||||
* Any of these 3 approaches can be used to set the HTTP method used
|
||||
|
@ -571,7 +570,7 @@ class CakeRequest implements ArrayAccess {
|
|||
/**
|
||||
* 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.
|
||||
* @return string Domain name without subdomains.
|
||||
*/
|
||||
|
@ -584,7 +583,7 @@ class CakeRequest implements ArrayAccess {
|
|||
/**
|
||||
* 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.
|
||||
* @return array of subdomains.
|
||||
*/
|
||||
|
@ -594,7 +593,7 @@ class CakeRequest implements ArrayAccess {
|
|||
}
|
||||
|
||||
/**
|
||||
* Find out which content types the client accepts or check if they accept a
|
||||
* Find out which content types the client accepts or check if they accept a
|
||||
* particular type of content.
|
||||
*
|
||||
* #### Get all types:
|
||||
|
@ -669,8 +668,7 @@ class CakeRequest implements ArrayAccess {
|
|||
* You can write to any value, even paths/keys that do not exist, and the arrays
|
||||
* will be created for you.
|
||||
*
|
||||
* @param string $name Dot separated name of the value to read/write
|
||||
* @param mixed $value Value to write to the data array.
|
||||
* @param string $name,... Dot separated name of the value to read/write
|
||||
* @return mixed Either the value being read, or this so you can chain consecutive writes.
|
||||
*/
|
||||
public function data($name) {
|
||||
|
@ -685,7 +683,7 @@ class CakeRequest implements ArrayAccess {
|
|||
/**
|
||||
* Read data from `php://stdin`. Useful when interacting with XML or JSON
|
||||
* request body content.
|
||||
*
|
||||
*
|
||||
* Getting input with a decoding function:
|
||||
*
|
||||
* `$this->request->input('json_decode');`
|
||||
|
@ -718,13 +716,13 @@ class CakeRequest implements ArrayAccess {
|
|||
* @return string contents of stdin
|
||||
*/
|
||||
protected function _readStdin() {
|
||||
if (empty($this->__input)) {
|
||||
if (empty($this->_input)) {
|
||||
$fh = fopen('php://input', 'r');
|
||||
$content = stream_get_contents($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
|
||||
*
|
||||
* @param $name Name to unset.
|
||||
* @param string $name Name to unset.
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($name) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* CakeResponse
|
||||
* CakeResponse
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
/**
|
||||
* CakeResponse is responsible for managing the response text, status and headers of a HTTP response.
|
||||
*
|
||||
* By default controllers will use this class to render their response. If you are going to use
|
||||
*
|
||||
* By default controllers will use this class to render their response. If you are going to use
|
||||
* a custom response class it should subclass this object in order to ensure compatibility.
|
||||
*
|
||||
* @package Cake.Network
|
||||
|
@ -317,7 +317,6 @@ class CakeResponse {
|
|||
* - status: the HTTP status code to respond with
|
||||
* - type: a complete mime-type string or an extension mapepd in this class
|
||||
* - charset: the charset for the response body
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $options = array()) {
|
||||
if (isset($options['body'])) {
|
||||
|
@ -358,8 +357,8 @@ class CakeResponse {
|
|||
/**
|
||||
* Sends a header to the client.
|
||||
*
|
||||
* @param $name the header name
|
||||
* @param $value the header value
|
||||
* @param string $name the header name
|
||||
* @param string $value the header value
|
||||
* @return void
|
||||
*/
|
||||
protected function _sendHeader($name, $value = null) {
|
||||
|
@ -375,7 +374,7 @@ class CakeResponse {
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
protected function _sendContent($content) {
|
||||
|
@ -565,7 +564,7 @@ class CakeResponse {
|
|||
*
|
||||
* 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.
|
||||
*/
|
||||
public function mapType($ctype) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue