Correcting code structure to standards

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5315 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-06-20 07:51:52 +00:00
parent 20dfa51702
commit dac1bd0913
42 changed files with 169 additions and 169 deletions

View file

@ -74,7 +74,7 @@ if (empty( $_GET['output'])) {
$_GET['output'] = 'html'; $_GET['output'] = 'html';
} }
if (!defined('BASE_URL')){ if (!defined('BASE_URL')) {
$dispatch =& new Dispatcher(); $dispatch =& new Dispatcher();
define('BASE_URL', $dispatch->baseUrl()); define('BASE_URL', $dispatch->baseUrl());
} }

View file

@ -50,7 +50,7 @@
* Loads all models. * Loads all models.
*/ */
function loadModels() { function loadModels() {
if (!class_exists('Model')){ if (!class_exists('Model')) {
require LIBS . 'model' . DS . 'model.php'; require LIBS . 'model' . DS . 'model.php';
} }
$path = Configure::getInstance(); $path = Configure::getInstance();
@ -86,7 +86,7 @@
* @deprecated * @deprecated
*/ */
function loadPluginModels($plugin) { function loadPluginModels($plugin) {
if (!class_exists('AppModel')){ if (!class_exists('AppModel')) {
loadModel(); loadModel();
} }
@ -120,7 +120,7 @@
* @return boolean Success * @return boolean Success
*/ */
function loadView($viewClass) { function loadView($viewClass) {
if (strpos($viewClass, '.') !== false){ if (strpos($viewClass, '.') !== false) {
list($plugin, $viewClass) = explode('.', $viewClass); list($plugin, $viewClass) = explode('.', $viewClass);
$file = APP . 'plugins' . DS . Inflector::underscore($plugin) . DS . 'views' . DS . Inflector::underscore($viewClass) . '.php'; $file = APP . 'plugins' . DS . Inflector::underscore($plugin) . DS . 'views' . DS . Inflector::underscore($viewClass) . '.php';
if (file_exists($file)) { if (file_exists($file)) {
@ -159,7 +159,7 @@
* @return boolean Success * @return boolean Success
*/ */
function loadModel($name = null) { function loadModel($name = null) {
if (!class_exists('Model')){ if (!class_exists('Model')) {
require LIBS . 'model' . DS . 'model.php'; require LIBS . 'model' . DS . 'model.php';
} }
if (!class_exists('AppModel')) { if (!class_exists('AppModel')) {
@ -171,7 +171,7 @@
Overloadable::overload('AppModel'); Overloadable::overload('AppModel');
} }
if (strpos($name, '.') !== false){ if (strpos($name, '.') !== false) {
list($plugin, $name) = explode('.', $name); list($plugin, $name) = explode('.', $name);
$pluginAppModel = Inflector::camelize($plugin . '_app_model'); $pluginAppModel = Inflector::camelize($plugin . '_app_model');
@ -234,7 +234,7 @@
* *
* @return array Array of paths indexed by type * @return array Array of paths indexed by type
*/ */
function paths(){ function paths() {
$directories = Configure::getInstance(); $directories = Configure::getInstance();
$paths = array(); $paths = array();
@ -254,7 +254,7 @@
$paths['Helpers'][] = $path; $paths['Helpers'][] = $path;
} }
if (!class_exists('Folder')){ if (!class_exists('Folder')) {
uses('Folder'); uses('Folder');
} }
@ -262,9 +262,9 @@
$plugins = $folder->ls(); $plugins = $folder->ls();
$classPaths = array('models', 'models'.DS.'behaviors', 'controllers', 'controllers'.DS.'components', 'views'.DS.'helpers'); $classPaths = array('models', 'models'.DS.'behaviors', 'controllers', 'controllers'.DS.'components', 'views'.DS.'helpers');
foreach ($plugins[0] as $plugin){ foreach ($plugins[0] as $plugin) {
foreach ($classPaths as $path){ foreach ($classPaths as $path) {
if (strpos($path, DS) !== false){ if (strpos($path, DS) !== false) {
$key = explode(DS, $path); $key = explode(DS, $path);
$key = $key[1]; $key = $key[1];
} else { } else {
@ -320,7 +320,7 @@
if ($name === null) { if ($name === null) {
return true; return true;
} }
if (strpos($name, '.') !== false){ if (strpos($name, '.') !== false) {
list($plugin, $name) = explode('.', $name); list($plugin, $name) = explode('.', $name);
$pluginAppController = Inflector::camelize($plugin . '_app_controller'); $pluginAppController = Inflector::camelize($plugin . '_app_controller');
@ -351,7 +351,7 @@
if (file_exists($file)) { if (file_exists($file)) {
require($file); require($file);
return true; return true;
} elseif (!class_exists(Inflector::camelize($plugin) . 'Controller')){ } elseif (!class_exists(Inflector::camelize($plugin) . 'Controller')) {
if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) { if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) {
require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php'); require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php');
return true; return true;
@ -434,7 +434,7 @@
if (file_exists($file)) { if (file_exists($file)) {
require($file); require($file);
return true; return true;
} elseif (!class_exists(Inflector::camelize($plugin) . 'Controller')){ } elseif (!class_exists(Inflector::camelize($plugin) . 'Controller')) {
if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) { if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) {
require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php'); require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php');
return true; return true;
@ -464,7 +464,7 @@
if ($name === null) { if ($name === null) {
return true; return true;
} }
if (strpos($name, '.') !== false){ if (strpos($name, '.') !== false) {
list($plugin, $name) = explode('.', $name); list($plugin, $name) = explode('.', $name);
} }
@ -538,7 +538,7 @@
return true; return true;
} }
if (strpos($name, '.') !== false){ if (strpos($name, '.') !== false) {
list($plugin, $name) = explode('.', $name); list($plugin, $name) = explode('.', $name);
} }
@ -609,7 +609,7 @@
if ($name === null) { if ($name === null) {
return true; return true;
} }
if (strpos($name, '.') !== false){ if (strpos($name, '.') !== false) {
list($plugin, $name) = explode('.', $name); list($plugin, $name) = explode('.', $name);
} }
@ -712,7 +712,7 @@
for ($i = 0; $i < $c; $i++) { for ($i = 0; $i < $c; $i++) {
$arg = $args[$i]; $arg = $args[$i];
if (strpos($arg, '.') !== false){ if (strpos($arg, '.') !== false) {
$file = explode('.', $arg); $file = explode('.', $arg);
$plugin = Inflector::underscore($file[0]); $plugin = Inflector::underscore($file[0]);
unset($file[0]); unset($file[0]);

View file

@ -199,7 +199,7 @@ class AclShell extends Shell {
$this->_checkArgs(3, 'setParent'); $this->_checkArgs(3, 'setParent');
$this->checkNodeType(); $this->checkNodeType();
extract($this->__dataVars()); extract($this->__dataVars());
if (!$this->Acl->{$class}->setParent($this->args[2], $this->args[1])){ if (!$this->Acl->{$class}->setParent($this->args[2], $this->args[1])) {
$this->out(__("Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.", true), true); $this->out(__("Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.", true), true);
} else { } else {
$this->out(sprintf(__("Node parent set to %s", true), $this->args[2]) . "\n", true); $this->out(sprintf(__("Node parent set to %s", true), $this->args[2]) . "\n", true);

View file

@ -79,7 +79,7 @@ class ApiShell extends Shell {
if (!preg_match('/' . Inflector::camelize($path) . '$/', $class)) { if (!preg_match('/' . Inflector::camelize($path) . '$/', $class)) {
$class .= Inflector::camelize($path); $class .= Inflector::camelize($path);
} }
} elseif (low($path) === low($class)){ } elseif (low($path) === low($class)) {
$class = Inflector::camelize($path); $class = Inflector::camelize($path);
} }

View file

@ -69,7 +69,7 @@ class ExtractShell extends Shell{
var $__output = null; var $__output = null;
function initialize() { function initialize() {
if (isset($this->params['files']) && !is_array($this->params['files'])){ if (isset($this->params['files']) && !is_array($this->params['files'])) {
$this->files = explode(',', $this->params['files']); $this->files = explode(',', $this->params['files']);
} }
@ -90,7 +90,7 @@ class ExtractShell extends Shell{
$this->__output = APP . 'locale' . DS; $this->__output = APP . 'locale' . DS;
} }
if (empty($this->files)){ if (empty($this->files)) {
$this->files = $this->__searchDirectory(); $this->files = $this->__searchDirectory();
} }
} }
@ -142,7 +142,7 @@ class ExtractShell extends Shell{
$this->out(' -debug: Perform self test.'); $this->out(' -debug: Perform self test.');
$this->out(''); $this->out('');
} }
function __extractTokens(){ function __extractTokens() {
foreach ($this->files as $file) { foreach ($this->files as $file) {
$this->__file = $file; $this->__file = $file;
$this->out("Processing $file..."); $this->out("Processing $file...");
@ -400,7 +400,7 @@ class ExtractShell extends Shell{
fclose($fp); fclose($fp);
} }
} }
function __mergeFiles($output){ function __mergeFiles($output) {
foreach ($output as $file => $content) { foreach ($output as $file => $content) {
if (count($content) <= 1 && $file != $this->__filename) { if (count($content) <= 1 && $file != $this->__filename) {
@$output[$this->__filename][1] = array_unique(array_merge($output[$this->__filename][1], $content[1])); @$output[$this->__filename][1] = array_unique(array_merge($output[$this->__filename][1], $content[1]));
@ -479,7 +479,7 @@ class ExtractShell extends Shell{
$this->out("\n", true); $this->out("\n", true);
} }
function __searchDirectory($path = null) { function __searchDirectory($path = null) {
if ($path === null){ if ($path === null) {
$path = $this->path .DS; $path = $this->path .DS;
} }
$files = glob("$path*.{php,ctp,thtml,inc,tpl}", GLOB_BRACE); $files = glob("$path*.{php,ctp,thtml,inc,tpl}", GLOB_BRACE);

View file

@ -115,7 +115,7 @@ class Shell extends Object {
function __construct(&$dispatch) { function __construct(&$dispatch) {
$vars = array('params', 'args', 'shell', 'shellName'=> 'name', 'shellClass'=> 'className', 'shellCommand'=> 'command'); $vars = array('params', 'args', 'shell', 'shellName'=> 'name', 'shellClass'=> 'className', 'shellCommand'=> 'command');
foreach ($vars as $key => $var) { foreach ($vars as $key => $var) {
if (is_string($key)){ if (is_string($key)) {
$this->{$var} =& $dispatch->{$key}; $this->{$var} =& $dispatch->{$key};
} else { } else {
$this->{$var} =& $dispatch->{$var}; $this->{$var} =& $dispatch->{$var};
@ -210,7 +210,7 @@ class Shell extends Object {
foreach ($uses as $modelClass) { foreach ($uses as $modelClass) {
$modelKey = Inflector::underscore($modelClass); $modelKey = Inflector::underscore($modelClass);
if (!class_exists($modelClass)){ if (!class_exists($modelClass)) {
loadModel($modelClass); loadModel($modelClass);
} }
if (class_exists($modelClass)) { if (class_exists($modelClass)) {
@ -416,7 +416,7 @@ class Shell extends Object {
function help() { function help() {
if ($this->command != null) { if ($this->command != null) {
$this->err("Unknown {$this->name} command '$this->command'.\nFor usage, try 'cake {$this->shell} help'.\n\n"); $this->err("Unknown {$this->name} command '$this->command'.\nFor usage, try 'cake {$this->shell} help'.\n\n");
} else{ } else {
$this->Dispatch->help(); $this->Dispatch->help();
} }
} }

View file

@ -545,7 +545,7 @@ class ControllerTask extends Shell {
while ($admin == '') { while ($admin == '') {
$admin = $this->in("What would you like the admin route to be?", null, 'admin'); $admin = $this->in("What would you like the admin route to be?", null, 'admin');
} }
if ($this->Project->cakeAdmin($admin) !== true){ if ($this->Project->cakeAdmin($admin) !== true) {
$this->out('Unable to write to /app/config/core.php.'); $this->out('Unable to write to /app/config/core.php.');
$this->out('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.'); $this->out('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
exit(); exit();

View file

@ -150,16 +150,16 @@ class ProjectTask extends Shell {
$this->out('The Welcome page was NOT created'); $this->out('The Welcome page was NOT created');
} }
if ($this->cakeSessionString($path) === true ){ if ($this->cakeSessionString($path) === true ) {
$this->out('Random hash key created for CAKE_SESSION_STRING'); $this->out('Random hash key created for CAKE_SESSION_STRING');
} else { } else {
$this->err('Unable to generate random hash for CAKE_SESSION_STRING, please change this yourself in ' . CONFIGS . 'core.php'); $this->err('Unable to generate random hash for CAKE_SESSION_STRING, please change this yourself in ' . CONFIGS . 'core.php');
} }
$corePath = $this->corePath($path); $corePath = $this->corePath($path);
if ($corePath === true ){ if ($corePath === true ) {
$this->out('CAKE_CORE_INCLUDE_PATH set to ' . CAKE_CORE_INCLUDE_PATH); $this->out('CAKE_CORE_INCLUDE_PATH set to ' . CAKE_CORE_INCLUDE_PATH);
} elseif ($corePath === false){ } elseif ($corePath === false) {
$this->err('Unable to to set CAKE_CORE_INCLUDE_PATH, please change this yourself in ' . $path . 'webroot' .DS .'index.php'); $this->err('Unable to to set CAKE_CORE_INCLUDE_PATH, please change this yourself in ' . $path . 'webroot' .DS .'index.php');
} }
@ -200,14 +200,14 @@ class ProjectTask extends Shell {
* *
* @return bool * @return bool
*/ */
function cakeSessionString($path){ function cakeSessionString($path) {
$File =& new File($path . 'config' . DS . 'core.php'); $File =& new File($path . 'config' . DS . 'core.php');
$contents = $File->read(); $contents = $File->read();
if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_SESSION_STRING\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) { if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_SESSION_STRING\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
uses('Security'); uses('Security');
$string = Security::generateAuthKey(); $string = Security::generateAuthKey();
$result = str_replace($match[0], 'define(\'CAKE_SESSION_STRING\', \''.$string.'\');', $contents); $result = str_replace($match[0], 'define(\'CAKE_SESSION_STRING\', \''.$string.'\');', $contents);
if ($File->write($result)){ if ($File->write($result)) {
return true; return true;
} else { } else {
return false; return false;
@ -221,13 +221,13 @@ class ProjectTask extends Shell {
* *
* @return bool * @return bool
*/ */
function corePath($path){ function corePath($path) {
if (dirname($path) !== CAKE_CORE_INCLUDE_PATH) { if (dirname($path) !== CAKE_CORE_INCLUDE_PATH) {
$File =& new File($path . 'webroot' . DS . 'index.php'); $File =& new File($path . 'webroot' . DS . 'index.php');
$contents = $File->read(); $contents = $File->read();
if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) { if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
$result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '".CAKE_CORE_INCLUDE_PATH."');", $contents); $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '".CAKE_CORE_INCLUDE_PATH."');", $contents);
if ($File->write($result)){ if ($File->write($result)) {
return true; return true;
} else { } else {
return false; return false;
@ -242,12 +242,12 @@ class ProjectTask extends Shell {
* *
* @return bool * @return bool
*/ */
function cakeAdmin($name){ function cakeAdmin($name) {
$File =& new File($path . 'webroot' . DS . 'index.php'); $File =& new File($path . 'webroot' . DS . 'index.php');
$contents = $File->read(); $contents = $File->read();
if (preg_match('%([/\\t\\x20]*define\\(\'CAKE_ADMIN\',[\\t\\x20\'a-z]*\\);)%', $contents, $match)) { if (preg_match('%([/\\t\\x20]*define\\(\'CAKE_ADMIN\',[\\t\\x20\'a-z]*\\);)%', $contents, $match)) {
$result = str_replace($match[0], 'define(\'CAKE_ADMIN\', \''.$name.'\');', $contents); $result = str_replace($match[0], 'define(\'CAKE_ADMIN\', \''.$name.'\');', $contents);
if ($File->write($result)){ if ($File->write($result)) {
return true; return true;
} else { } else {
return false; return false;

View file

@ -162,7 +162,7 @@ class ViewTask extends Shell {
while ($admin == '') { while ($admin == '') {
$admin = $this->in("What would you like the admin route to be?", null, 'admin'); $admin = $this->in("What would you like the admin route to be?", null, 'admin');
} }
if ($this->Project->cakeAdmin($admin) !== true){ if ($this->Project->cakeAdmin($admin) !== true) {
$this->err('Unable to write to /app/config/core.php.'); $this->err('Unable to write to /app/config/core.php.');
$this->err('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.'); $this->err('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
exit(); exit();

View file

@ -74,7 +74,7 @@ if (empty( $_GET['output'])) {
$_GET['output'] = 'html'; $_GET['output'] = 'html';
} }
if (!defined('BASE_URL')){ if (!defined('BASE_URL')) {
$dispatch =& new Dispatcher(); $dispatch =& new Dispatcher();
define('BASE_URL', $dispatch->baseUrl()); define('BASE_URL', $dispatch->baseUrl());
} }

View file

@ -33,7 +33,7 @@
foreach ($fields as $field) { foreach ($fields as $field) {
if ($action == 'add' && $field['name'] == $primaryKey) { if ($action == 'add' && $field['name'] == $primaryKey) {
continue; continue;
} elseif (!in_array($field['name'], array('created', 'modified', 'updated'))){ } elseif (!in_array($field['name'], array('created', 'modified', 'updated'))) {
echo "\t\techo \$form->input('{$field['name']}');\n"; echo "\t\techo \$form->input('{$field['name']}');\n";
} }
} }

View file

@ -308,7 +308,7 @@ class Dispatcher extends Object {
$controller->_initComponents(); $controller->_initComponents();
$controller->constructClasses(); $controller->constructClasses();
if ($missingAction && !in_array('scaffold', array_keys($classVars))){ if ($missingAction && !in_array('scaffold', array_keys($classVars))) {
$this->start($controller); $this->start($controller);
return $this->cakeError('missingAction', array( return $this->cakeError('missingAction', array(
array( array(

View file

@ -129,11 +129,11 @@ class ClassRegistry {
$_this =& ClassRegistry::getInstance(); $_this =& ClassRegistry::getInstance();
$key = Inflector::underscore($key); $key = Inflector::underscore($key);
if (isset($_this->__objects[$key])){ if (isset($_this->__objects[$key])) {
return $_this->__objects[$key]; return $_this->__objects[$key];
} else { } else {
$key = $_this->__getMap($key); $key = $_this->__getMap($key);
if (isset($_this->__objects[$key])){ if (isset($_this->__objects[$key])) {
return $_this->__objects[$key]; return $_this->__objects[$key];
} }
} }

View file

@ -111,22 +111,22 @@ class Configure extends Object {
* @param mixed $value Value to set for var * @param mixed $value Value to set for var
* @access public * @access public
*/ */
function write($config, $value = null){ function write($config, $value = null) {
$_this =& Configure::getInstance(); $_this =& Configure::getInstance();
if (!is_array($config) && $value !== null) { if (!is_array($config) && $value !== null) {
$name = $_this->__configVarNames($config); $name = $_this->__configVarNames($config);
if (count($name) > 1){ if (count($name) > 1) {
$_this->{$name[0]}[$name[1]] = $value; $_this->{$name[0]}[$name[1]] = $value;
} else { } else {
$_this->{$name[0]} = $value; $_this->{$name[0]} = $value;
} }
} else { } else {
foreach ($config as $names => $value){ foreach ($config as $names => $value) {
$name = $_this->__configVarNames($names); $name = $_this->__configVarNames($names);
if (count($name) > 1){ if (count($name) > 1) {
$_this->{$name[0]}[$name[1]] = $value; $_this->{$name[0]}[$name[1]] = $value;
} else { } else {
$_this->{$name[0]} = $value; $_this->{$name[0]} = $value;
@ -166,17 +166,17 @@ class Configure extends Object {
* @return string value of Configure::$var * @return string value of Configure::$var
* @access public * @access public
*/ */
function read($var = 'debug'){ function read($var = 'debug') {
$_this =& Configure::getInstance(); $_this =& Configure::getInstance();
if ($var === 'debug') { if ($var === 'debug') {
if (!isset($_this->debug)){ if (!isset($_this->debug)) {
$_this->debug = DEBUG; $_this->debug = DEBUG;
} }
return $_this->debug; return $_this->debug;
} }
$name = $_this->__configVarNames($var); $name = $_this->__configVarNames($var);
if (count($name) > 1){ if (count($name) > 1) {
if (isset($_this->{$name[0]}[$name[1]])) { if (isset($_this->{$name[0]}[$name[1]])) {
return $_this->{$name[0]}[$name[1]]; return $_this->{$name[0]}[$name[1]];
} }
@ -198,11 +198,11 @@ class Configure extends Object {
* @param string $var the var to be deleted * @param string $var the var to be deleted
* @access public * @access public
*/ */
function delete($var = null){ function delete($var = null) {
$_this =& Configure::getInstance(); $_this =& Configure::getInstance();
$name = $_this->__configVarNames($var); $name = $_this->__configVarNames($var);
if (count($name) > 1){ if (count($name) > 1) {
unset($_this->{$name[0]}[$name[1]]); unset($_this->{$name[0]}[$name[1]]);
} else { } else {
unset($_this->{$name[0]}); unset($_this->{$name[0]});
@ -230,7 +230,7 @@ class Configure extends Object {
return false; return false;
} }
if (!isset($config)){ if (!isset($config)) {
trigger_error(sprintf(__("Configure::load() - no variable \$config found in %s.php", true), $fileName), E_USER_WARNING); trigger_error(sprintf(__("Configure::load() - no variable \$config found in %s.php", true), $fileName), E_USER_WARNING);
return false; return false;
} }
@ -268,9 +268,9 @@ class Configure extends Object {
$content = ''; $content = '';
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$content .= "\$config['$type']['$key']"; $content .= "\$config['$type']['$key']";
if (is_array($value)){ if (is_array($value)) {
$content .= " = array("; $content .= " = array(";
foreach ($value as $key1 => $value2){ foreach ($value as $key1 => $value2) {
$value2 = addslashes($value2); $value2 = addslashes($value2);
$content .= "'$key1' => '$value2', "; $content .= "'$key1' => '$value2', ";
} }
@ -294,7 +294,7 @@ class Configure extends Object {
* @param boolean $write true if content should be written, false otherwise * @param boolean $write true if content should be written, false otherwise
* @access private * @access private
*/ */
function __writeConfig($content, $name, $write = true){ function __writeConfig($content, $name, $write = true) {
$file = CACHE . 'persistent' . DS . $name . '.php'; $file = CACHE . 'persistent' . DS . $name . '.php';
$_this =& Configure::getInstance(); $_this =& Configure::getInstance();
if ($_this->read() > 0) { if ($_this->read() > 0) {
@ -304,12 +304,12 @@ class Configure extends Object {
} }
$cache = cache('persistent' . DS . $name . '.php', null, $expires); $cache = cache('persistent' . DS . $name . '.php', null, $expires);
if ($cache === null){ if ($cache === null) {
cache('persistent' . DS . $name . '.php', "<?php\n\$config = array();\n", $expires); cache('persistent' . DS . $name . '.php', "<?php\n\$config = array();\n", $expires);
} }
if ($write === true){ if ($write === true) {
if (!class_exists('File')){ if (!class_exists('File')) {
uses('File'); uses('File');
} }
$fileClass = new File($file); $fileClass = new File($file);

View file

@ -29,7 +29,7 @@
/** /**
* Load Security class * Load Security class
*/ */
if (!class_exists('Security')){ if (!class_exists('Security')) {
uses('Security'); uses('Security');
} }
/** /**
@ -162,14 +162,14 @@ class CookieComponent extends Object {
* @deprecated use Controller::beforeFilter() to set the properties of the CookieComponent * @deprecated use Controller::beforeFilter() to set the properties of the CookieComponent
*/ */
function initialize(&$controller) { function initialize(&$controller) {
if (is_object($controller)){ if (is_object($controller)) {
if (isset($controller->cookieName)) { if (isset($controller->cookieName)) {
$this->name = $controller->cookieName; $this->name = $controller->cookieName;
} }
if (isset($controller->cookieTime)){ if (isset($controller->cookieTime)) {
$this->time = $controller->cookieTime; $this->time = $controller->cookieTime;
} }
if (isset($controller->cookieKey)){ if (isset($controller->cookieKey)) {
$this->key = $controller->cookieKey; $this->key = $controller->cookieKey;
} }
if (isset($controller->cookiePath)) { if (isset($controller->cookiePath)) {
@ -214,7 +214,7 @@ class CookieComponent extends Object {
* @access public * @access public
*/ */
function write($key, $value = null, $encrypt = true, $expires = null) { function write($key, $value = null, $encrypt = true, $expires = null) {
if (is_null($encrypt)){ if (is_null($encrypt)) {
$encrypt = true; $encrypt = true;
} }
@ -224,7 +224,7 @@ class CookieComponent extends Object {
if (!is_array($key) && $value !== null) { if (!is_array($key) && $value !== null) {
$name = $this->__cookieVarNames($key); $name = $this->__cookieVarNames($key);
if (count($name) > 1){ if (count($name) > 1) {
$this->__values[$name[0]][$name[1]] = $value; $this->__values[$name[0]][$name[1]] = $value;
$this->__write("[".$name[0]."][".$name[1]."]", $value); $this->__write("[".$name[0]."][".$name[1]."]", $value);
} else { } else {
@ -232,10 +232,10 @@ class CookieComponent extends Object {
$this->__write("[".$name[0]."]", $value); $this->__write("[".$name[0]."]", $value);
} }
} else { } else {
foreach ($key as $names => $value){ foreach ($key as $names => $value) {
$name = $this->__cookieVarNames($names); $name = $this->__cookieVarNames($names);
if (count($name) > 1){ if (count($name) > 1) {
$this->__values[$name[0]][$name[1]] = $value; $this->__values[$name[0]][$name[1]] = $value;
$this->__write("[".$name[0]."][".$name[1]."]", $value); $this->__write("[".$name[0]."][".$name[1]."]", $value);
} else { } else {
@ -260,12 +260,12 @@ class CookieComponent extends Object {
$this->__values = $this->__decrypt($_COOKIE[$this->name]); $this->__values = $this->__decrypt($_COOKIE[$this->name]);
} }
if (is_null($key)){ if (is_null($key)) {
return $this->__values; return $this->__values;
} }
$name = $this->__cookieVarNames($key); $name = $this->__cookieVarNames($key);
if (count($name) > 1){ if (count($name) > 1) {
if (isset($this->__values[$name[0]])) { if (isset($this->__values[$name[0]])) {
$value = $this->__values[$name[0]][$name[1]]; $value = $this->__values[$name[0]][$name[1]];
return $value; return $value;
@ -294,7 +294,7 @@ class CookieComponent extends Object {
function del($key) { function del($key) {
$name = $this->__cookieVarNames($key); $name = $this->__cookieVarNames($key);
if (count($name) > 1){ if (count($name) > 1) {
if (isset($this->__values[$name[0]])) { if (isset($this->__values[$name[0]])) {
unset($this->__values[$name[0]][$name[1]]); unset($this->__values[$name[0]][$name[1]]);
$this->__delete("[".$name[0]."][".$name[1]."]"); $this->__delete("[".$name[0]."][".$name[1]."]");
@ -360,9 +360,9 @@ class CookieComponent extends Object {
* @return integer * @return integer
* @access private * @access private
*/ */
function __expire($expires = null){ function __expire($expires = null) {
$now = time(); $now = time();
if (is_null($expires)){ if (is_null($expires)) {
return $this->__expires; return $this->__expires;
} }
$this->__reset = $this->__expires; $this->__reset = $this->__expires;
@ -382,7 +382,7 @@ class CookieComponent extends Object {
function __write($name, $value) { function __write($name, $value) {
setcookie($this->name . "$name", $this->__encrypt($value), $this->__expires, $this->path, $this->domain, $this->secure); setcookie($this->name . "$name", $this->__encrypt($value), $this->__expires, $this->path, $this->domain, $this->secure);
if (!is_null($this->__reset)){ if (!is_null($this->__reset)) {
$this->__expires = $this->__reset; $this->__expires = $this->__reset;
$this->__reset = null; $this->__reset = null;
} }
@ -405,7 +405,7 @@ class CookieComponent extends Object {
* @access private * @access private
*/ */
function __encrypt($value) { function __encrypt($value) {
if (is_array($value)){ if (is_array($value)) {
$value = $this->__implode($value); $value = $this->__implode($value);
} }
@ -427,7 +427,7 @@ class CookieComponent extends Object {
$type = $this->__type; $type = $this->__type;
foreach ($values as $name => $value) { foreach ($values as $name => $value) {
if (is_array($value)){ if (is_array($value)) {
foreach ($value as $key => $val) { foreach ($value as $key => $val) {
$pos = strpos($val, 'Q2FrZQ==.'); $pos = strpos($val, 'Q2FrZQ==.');
$decrypted[$name][$key] = $this->__explode($val); $decrypted[$name][$key] = $this->__explode($val);
@ -494,7 +494,7 @@ class CookieComponent extends Object {
$array = array(); $array = array();
foreach (explode(',', $string) as $pair) { foreach (explode(',', $string) as $pair) {
$key = explode('|', $pair); $key = explode('|', $pair);
if (!isset($key[1])){ if (!isset($key[1])) {
return $key[0]; return $key[0];
} }
$array[$key[0]] = $key[1]; $array[$key[0]] = $key[1];

View file

@ -203,7 +203,7 @@ class EmailComponent extends Object{
* @param unknown_type $controller * @param unknown_type $controller
* @access public * @access public
*/ */
function startup(&$controller){ function startup(&$controller) {
$this->Controller = & $controller; $this->Controller = & $controller;
} }
/** /**
@ -213,14 +213,14 @@ class EmailComponent extends Object{
* @return unknown * @return unknown
* @access public * @access public
*/ */
function send($content = null){ function send($content = null) {
$this->__createHeader(); $this->__createHeader();
$this->subject = $this->__encode($this->subject); $this->subject = $this->__encode($this->subject);
if ($this->template === null) { if ($this->template === null) {
if (is_array($content)){ if (is_array($content)) {
$message = null; $message = null;
foreach ($content as $key => $value){ foreach ($content as $key => $value) {
$message .= $value . $this->_newLine; $message .= $value . $this->_newLine;
} }
} else { } else {
@ -239,7 +239,7 @@ class EmailComponent extends Object{
$this->__message .= $this->_newLine .'--' . $this->__boundary . '--' . $this->_newLine . $this->_newLine; $this->__message .= $this->_newLine .'--' . $this->__boundary . '--' . $this->_newLine . $this->_newLine;
} }
if ($this->_debug){ if ($this->_debug) {
$this->delivery = 'debug'; $this->delivery = 'debug';
} }
$__method = '__'.$this->delivery; $__method = '__'.$this->delivery;
@ -274,7 +274,7 @@ class EmailComponent extends Object{
function __renderTemplate($content) { function __renderTemplate($content) {
$View = new View($this->Controller); $View = new View($this->Controller);
$View->layout = $this->layout; $View->layout = $this->layout;
if ($this->sendAs === 'both'){ if ($this->sendAs === 'both') {
$htmlContent = $content; $htmlContent = $content;
$msg = '--' . $this->__boundary . $this->_newLine; $msg = '--' . $this->__boundary . $this->_newLine;
$msg .= 'Content-Type: text/plain; charset=' . $this->charset . $this->_newLine; $msg .= 'Content-Type: text/plain; charset=' . $this->charset . $this->_newLine;
@ -302,7 +302,7 @@ class EmailComponent extends Object{
* *
* @access private * @access private
*/ */
function __createBoundary(){ function __createBoundary() {
$this->__boundary = md5(uniqid(time())); $this->__boundary = md5(uniqid(time()));
} }
/** /**
@ -310,7 +310,7 @@ class EmailComponent extends Object{
* *
* @access private * @access private
*/ */
function __createHeader(){ function __createHeader() {
$this->__header .= 'From: ' . $this->__formatAddress($this->from) . $this->_newLine; $this->__header .= 'From: ' . $this->__formatAddress($this->from) . $this->_newLine;
if (!empty($this->replyTo)) { if (!empty($this->replyTo)) {
$this->__header .= 'Reply-To: ' . $this->__formatAddress($this->replyTo) . $this->_newLine; $this->__header .= 'Reply-To: ' . $this->__formatAddress($this->replyTo) . $this->_newLine;
@ -359,10 +359,10 @@ class EmailComponent extends Object{
* @param string $message * @param string $message
* @access private * @access private
*/ */
function __formatMessage($message){ function __formatMessage($message) {
$message = $this->__wrap($message); $message = $this->__wrap($message);
if ($this->sendAs === 'both'){ if ($this->sendAs === 'both') {
$this->__message = '--' . $this->__boundary . $this->_newLine; $this->__message = '--' . $this->__boundary . $this->_newLine;
$this->__message .= 'Content-Type: text/plain; charset=' . $this->charset . $this->_newLine; $this->__message .= 'Content-Type: text/plain; charset=' . $this->charset . $this->_newLine;
$this->__message .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine; $this->__message .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
@ -384,7 +384,7 @@ class EmailComponent extends Object{
* *
* @access private * @access private
*/ */
function __attachFiles(){ function __attachFiles() {
foreach ($this->attachments as $attachment) { foreach ($this->attachments as $attachment) {
$files[] = $this->__findFiles($attachment); $files[] = $this->__findFiles($attachment);
} }
@ -409,7 +409,7 @@ class EmailComponent extends Object{
* @return unknown * @return unknown
* @access private * @access private
*/ */
function __findFiles($attachment){ function __findFiles($attachment) {
foreach ($this->filePaths as $path) { foreach ($this->filePaths as $path) {
if (file_exists($path . DS . $attachment)) { if (file_exists($path . DS . $attachment)) {
$file = $path . DS . $attachment; $file = $path . DS . $attachment;
@ -466,8 +466,8 @@ class EmailComponent extends Object{
* @return unknown * @return unknown
* @access private * @access private
*/ */
function __formatAddress($string){ function __formatAddress($string) {
if (strpos($string, '<') !== false){ if (strpos($string, '<') !== false) {
$value = explode('<', $string); $value = explode('<', $string);
$string = $this->__encode($value[0]) . ' <' . $value[1]; $string = $this->__encode($value[0]) . ' <' . $value[1];
} }
@ -479,7 +479,7 @@ class EmailComponent extends Object{
* @return unknown * @return unknown
* @access private * @access private
*/ */
function __mail(){ function __mail() {
return @mail($this->to, $this->subject, $this->__message, $this->__header, $this->additionalParams); return @mail($this->to, $this->subject, $this->__message, $this->__header, $this->additionalParams);
} }
/** /**
@ -487,7 +487,7 @@ class EmailComponent extends Object{
* *
* @access private * @access private
*/ */
function __smtp(){ function __smtp() {
} }
/** /**

View file

@ -506,7 +506,7 @@ class SecurityComponent extends Object {
} }
foreach ($k as $lookup) { foreach ($k as $lookup) {
if (isset($controller->data[$newKey][$lookup])){ if (isset($controller->data[$newKey][$lookup])) {
unset($controller->data[$key][$lookup]); unset($controller->data[$key][$lookup]);
} elseif ($controller->data[$key][$lookup] === '0') { } elseif ($controller->data[$key][$lookup] === '0') {
$merge[] = $lookup; $merge[] = $lookup;

View file

@ -342,7 +342,7 @@ class Controller extends Object {
* @access public * @access public
*/ */
function constructClasses() { function constructClasses() {
if ($this->uses === null || ($this->uses === array())){ if ($this->uses === null || ($this->uses === array())) {
return false; return false;
} }
if (empty($this->passedArgs) || !isset($this->passedArgs['0'])) { if (empty($this->passedArgs) || !isset($this->passedArgs['0'])) {
@ -359,7 +359,7 @@ class Controller extends Object {
} }
if ($this->uses === false) { if ($this->uses === false) {
if (!class_exists($this->modelClass)){ if (!class_exists($this->modelClass)) {
loadModel($plugin . $this->modelClass); loadModel($plugin . $this->modelClass);
} }
} }
@ -399,7 +399,7 @@ class Controller extends Object {
$object = null; $object = null;
$modelKey = Inflector::underscore($modelClass); $modelKey = Inflector::underscore($modelClass);
if (!class_exists($modelClass)){ if (!class_exists($modelClass)) {
loadModel($plugin . $modelClass); loadModel($plugin . $modelClass);
} }
@ -610,7 +610,7 @@ class Controller extends Object {
$viewClass = $this->view; $viewClass = $this->view;
if ($this->view != 'View') { if ($this->view != 'View') {
if (strpos($viewClass, '.') !== false){ if (strpos($viewClass, '.') !== false) {
list($plugin, $viewClass) = explode('.', $viewClass); list($plugin, $viewClass) = explode('.', $viewClass);
} }
$viewClass = $viewClass . 'View'; $viewClass = $viewClass . 'View';

View file

@ -207,7 +207,7 @@ class Scaffold extends Object {
function __scaffoldView($params) { function __scaffoldView($params) {
if ($this->controller->_beforeScaffold('view')) { if ($this->controller->_beforeScaffold('view')) {
if (isset($params['pass'][0])){ if (isset($params['pass'][0])) {
$this->ScaffoldModel->id = $params['pass'][0]; $this->ScaffoldModel->id = $params['pass'][0];
} elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) { } elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) {
$this->controller->Session->setFlash(sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey))); $this->controller->Session->setFlash(sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey)));
@ -334,7 +334,7 @@ class Scaffold extends Object {
function __scaffoldDelete($params = array()) { function __scaffoldDelete($params = array()) {
if ($this->controller->_beforeScaffold('delete')) { if ($this->controller->_beforeScaffold('delete')) {
if (isset($params['pass'][0])){ if (isset($params['pass'][0])) {
$id = $params['pass'][0]; $id = $params['pass'][0];
} elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) { } elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) {
$this->controller->Session->setFlash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey))); $this->controller->Session->setFlash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)));

View file

@ -361,7 +361,7 @@ class I18n extends Object {
} }
if (isset($_this->__domains[$_this->category][$domain]["%po-header"]["plural-forms"])) { if (isset($_this->__domains[$_this->category][$domain]["%po-header"]["plural-forms"])) {
$switch = preg_replace("/[(){}\\[\\]^\\s*\\]]+/", "", $_this->__domains[$_this->category][$domain]["%po-header"]["plural-forms"]); $switch = preg_replace("/[() {}\\[\\]^\\s*\\]]+/", "", $_this->__domains[$_this->category][$domain]["%po-header"]["plural-forms"]);
$_this->__domains[$_this->category][$domain]["%plural-c"] = $switch; $_this->__domains[$_this->category][$domain]["%plural-c"] = $switch;
} }
} }

View file

@ -335,7 +335,7 @@ class L10n extends Object {
function get($language = null) { function get($language = null) {
if (!is_null($language)) { if (!is_null($language)) {
return $this->__setLanguage($language); return $this->__setLanguage($language);
} elseif ($this->__autoLanguage() === false){ } elseif ($this->__autoLanguage() === false) {
return $this->__setLanguage($language); return $this->__setLanguage($language);
} }
} }

View file

@ -227,7 +227,7 @@ class DataSource extends Object {
* @return void * @return void
*/ */
function __cacheDescription($object, $data = null) { function __cacheDescription($object, $data = null) {
if ($this->cacheSources === false){ if ($this->cacheSources === false) {
return null; return null;
} }
if (Configure::read() > 0) { if (Configure::read() > 0) {
@ -282,7 +282,7 @@ class DataSource extends Object {
* @return mixed * @return mixed
*/ */
function describe($model) { function describe($model) {
if ($this->cacheSources === false){ if ($this->cacheSources === false) {
return null; return null;
} }

View file

@ -139,7 +139,7 @@ class DboFirebird extends DboSource {
* @access protected * @access protected
*/ */
function _execute($sql) { function _execute($sql) {
if (strpos(strtolower($sql),"update") > 0){ if (strpos(strtolower($sql),"update") > 0) {
break; break;
} }
return @ibase_query($this->connection, $sql ); return @ibase_query($this->connection, $sql );

View file

@ -222,7 +222,7 @@ class DboPostgres extends DboSource {
switch($column) { switch($column) {
case 'inet': case 'inet':
if (!strlen($data)){ if (!strlen($data)) {
return 'DEFAULT'; return 'DEFAULT';
} else { } else {
$data = pg_escape_string($data); $data = pg_escape_string($data);

View file

@ -132,7 +132,7 @@ class DboSource extends DataSource {
* @return array * @return array
*/ */
function listSources($data = null) { function listSources($data = null) {
if ($this->cacheSources === false){ if ($this->cacheSources === false) {
return null; return null;
} }
if ($this->_sources != null) { if ($this->_sources != null) {
@ -249,7 +249,7 @@ class DboSource extends DataSource {
return $args[2]->find($query, $fields, $order, $recursive); return $args[2]->find($query, $fields, $order, $recursive);
} }
} else { } else {
if (isset($args[1]) && $args[1] === true){ if (isset($args[1]) && $args[1] === true) {
return $this->fetchAll($args[0], true); return $this->fetchAll($args[0], true);
} }
return $this->fetchAll($args[0], false); return $this->fetchAll($args[0], false);
@ -716,7 +716,7 @@ class DboSource extends DataSource {
} }
} }
if (!empty($ins)){ if (!empty($ins)) {
$query = r('{$__cakeID__$}', join(', ',$ins), $query); $query = r('{$__cakeID__$}', join(', ',$ins), $query);
$fetch = $this->fetchAll($query, $model->cacheQueries, $model->name); $fetch = $this->fetchAll($query, $model->cacheQueries, $model->name);
} else { } else {
@ -751,7 +751,7 @@ class DboSource extends DataSource {
$row =& $resultSet[$i]; $row =& $resultSet[$i];
$q = $this->insertQueryData($query, $resultSet[$i], $association, $assocData, $model, $linkModel, $stack); $q = $this->insertQueryData($query, $resultSet[$i], $association, $assocData, $model, $linkModel, $stack);
if ($q != false){ if ($q != false) {
$fetch = $this->fetchAll($q, $model->cacheQueries, $model->name); $fetch = $this->fetchAll($q, $model->cacheQueries, $model->name);
} else { } else {
$fetch = null; $fetch = null;
@ -788,7 +788,7 @@ class DboSource extends DataSource {
} }
} }
function __mergeHasMany(&$resultSet, $merge, $association, &$model, &$linkModel){ function __mergeHasMany(&$resultSet, $merge, $association, &$model, &$linkModel) {
foreach ($resultSet as $key => $value) { foreach ($resultSet as $key => $value) {
$merged[$association] = array(); $merged[$association] = array();
$count = 0; $count = 0;
@ -804,7 +804,7 @@ class DboSource extends DataSource {
} }
$count++; $count++;
} }
if (isset($value[$model->name])){ if (isset($value[$model->name])) {
$resultSet[$key] = Set::pushDiff($resultSet[$key], $merged); $resultSet[$key] = Set::pushDiff($resultSet[$key], $merged);
unset($merged); unset($merged);
unset($temp); unset($temp);
@ -844,15 +844,15 @@ class DboSource extends DataSource {
$data[$association] = array(); $data[$association] = array();
} }
} else { } else {
if (is_array($merge[0][$association])){ if (is_array($merge[0][$association])) {
foreach ($data[$association] as $k => $v) { foreach ($data[$association] as $k => $v) {
if (!is_array($v)){ if (!is_array($v)) {
$dataAssocTmp[$k] = $v; $dataAssocTmp[$k] = $v;
} }
} }
foreach ($merge[0][$association] as $k => $v) { foreach ($merge[0][$association] as $k => $v) {
if (!is_array($v)){ if (!is_array($v)) {
$mergeAssocTmp[$k] = $v; $mergeAssocTmp[$k] = $v;
} }
} }
@ -868,7 +868,7 @@ class DboSource extends DataSource {
} }
} else { } else {
if ($merge[0][$association] === false) { if ($merge[0][$association] === false) {
if (!isset($data[$association])){ if (!isset($data[$association])) {
$data[$association] = array(); $data[$association] = array();
} }
} else { } else {
@ -987,7 +987,7 @@ class DboSource extends DataSource {
if (count($passedFields) === 1) { if (count($passedFields) === 1) {
$match = strpos($passedFields[0], $assocFields[0]); $match = strpos($passedFields[0], $assocFields[0]);
$match1 = strpos($passedFields[0], 'COUNT('); $match1 = strpos($passedFields[0], 'COUNT(');
if ($match === false && $match1 === false){ if ($match === false && $match1 === false) {
$queryData['fields'] = array_unique(array_merge($passedFields, $assocFields)); $queryData['fields'] = array_unique(array_merge($passedFields, $assocFields));
} else { } else {
$queryData['fields'] = $passedFields; $queryData['fields'] = $passedFields;
@ -1524,7 +1524,7 @@ function conditionKeysToString($conditions, $quoteValues = true) {
$keys = array_keys($value); $keys = array_keys($value);
if ($keys[0] === 0) { if ($keys[0] === 0) {
$data = $this->name($key) . ' IN ('; $data = $this->name($key) . ' IN (';
if (strpos($value[0], '-!') === 0){ if (strpos($value[0], '-!') === 0) {
$value[0] = str_replace('-!', '', $value[0]); $value[0] = str_replace('-!', '', $value[0]);
$data .= $value[0]; $data .= $value[0];
$data .= ')'; $data .= ')';

View file

@ -1824,7 +1824,7 @@ class Model extends Overloadable {
if ($groupPath == null && $recursive >= 1) { if ($groupPath == null && $recursive >= 1) {
$this->recursive = -1; $this->recursive = -1;
} elseif ($groupPath && $recursive >= 1){ } elseif ($groupPath && $recursive >= 1) {
$this->recursive = 0; $this->recursive = 0;
} }
$result = $this->findAll($conditions, $fields, $order, $limit); $result = $this->findAll($conditions, $fields, $order, $limit);

View file

@ -90,7 +90,7 @@ class Object {
require CAKE . 'dispatcher.php'; require CAKE . 'dispatcher.php';
} }
$dispatcher =& new Dispatcher(); $dispatcher =& new Dispatcher();
if (isset($this->plugin)){ if (isset($this->plugin)) {
$extra['plugin'] = $this->plugin; $extra['plugin'] = $this->plugin;
} }
if (in_array('return', $extra, true)) { if (in_array('return', $extra, true)) {

View file

@ -486,7 +486,7 @@ class Set extends Object {
foreach ($val1 as $key => $val) { foreach ($val1 as $key => $val) {
if (isset($val2[$key]) && $val2[$key] != $val) { if (isset($val2[$key]) && $val2[$key] != $val) {
$out[$key] = $val; $out[$key] = $val;
} elseif (!array_key_exists($key, $val2)){ } elseif (!array_key_exists($key, $val2)) {
$out[$key] = $val; $out[$key] = $val;
} }
} }

View file

@ -131,7 +131,7 @@ class Validation extends Object {
} }
$this->regex = '/[^\\dA-Z]/i'; $this->regex = '/[^\\dA-Z]/i';
if ($this->_check() === true){ if ($this->_check() === true) {
return false; return false;
} else { } else {
return true; return true;
@ -177,7 +177,7 @@ class Validation extends Object {
} }
$this->regex = '/[^\\s]/'; $this->regex = '/[^\\s]/';
if ($this->_check() === true){ if ($this->_check() === true) {
return false; return false;
} else { } else {
return true; return true;
@ -210,7 +210,7 @@ class Validation extends Object {
$this->check = str_replace(array('-', ' '), '', $this->check); $this->check = str_replace(array('-', ' '), '', $this->check);
if (strlen($this->check) < 13){ if (strlen($this->check) < 13) {
return false; return false;
} }
@ -341,7 +341,7 @@ class Validation extends Object {
if (is_array($check)) { if (is_array($check)) {
$this->_extract($check); $this->_extract($check);
} }
if ($this->regex === null){ if ($this->regex === null) {
$this->errors[] = __('You must define a regular expression for Validation::custom()', true); $this->errors[] = __('You must define a regular expression for Validation::custom()', true);
return false; return false;
} }
@ -375,8 +375,8 @@ class Validation extends Object {
$search = array(); $search = array();
if (is_array($format)){ if (is_array($format)) {
foreach ($format as $key => $value){ foreach ($format as $key => $value) {
$search[$value] = $value; $search[$value] = $value;
} }
} else { } else {
@ -390,10 +390,10 @@ class Validation extends Object {
$regex['My'] = '%^(Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)[ /]((1[6-9]|[2-9]\\d)\\d{2})$%'; $regex['My'] = '%^(Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)[ /]((1[6-9]|[2-9]\\d)\\d{2})$%';
$regex['my'] = '%^(((0[123456789]|10|11|12)([- /.])(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))))$%'; $regex['my'] = '%^(((0[123456789]|10|11|12)([- /.])(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))))$%';
foreach ($search as $key){ foreach ($search as $key) {
$this->regex = $regex[$key]; $this->regex = $regex[$key];
if ($this->_check() === true){ if ($this->_check() === true) {
return true; return true;
} }
} }
@ -768,7 +768,7 @@ class Validation extends Object {
* @access protected * @access protected
*/ */
function _luhn() { function _luhn() {
if ($this->deep === true){ if ($this->deep === true) {
if ($this->check == 0) { if ($this->check == 0) {
return false; return false;
} }
@ -800,7 +800,7 @@ class Validation extends Object {
* *
* @access private * @access private
*/ */
function __reset(){ function __reset() {
$this->check = null; $this->check = null;
$this->regex = null; $this->regex = null;
$this->country = null; $this->country = null;

View file

@ -197,7 +197,7 @@ class Helper extends Overloadable {
} else { } else {
$path = WWW_ROOT . $this->themeWeb . $file; $path = WWW_ROOT . $this->themeWeb . $file;
} }
if (file_exists($path)){ if (file_exists($path)) {
$webPath = "{$this->webroot}" . $this->themeWeb . $file; $webPath = "{$this->webroot}" . $this->themeWeb . $file;
} }
} }
@ -211,7 +211,7 @@ class Helper extends Overloadable {
* @return cleaned content for output * @return cleaned content for output
* @access public * @access public
*/ */
function clean($output){ function clean($output) {
$this->__reset(); $this->__reset();
if (is_array($output)) { if (is_array($output)) {
foreach ($output as $key => $value) { foreach ($output as $key => $value) {
@ -614,7 +614,7 @@ class Helper extends Overloadable {
* @return void * @return void
* @access private * @access private
*/ */
function __reset(){ function __reset() {
$this->__tainted = null; $this->__tainted = null;
$this->__cleaned = null; $this->__cleaned = null;
} }
@ -624,7 +624,7 @@ class Helper extends Overloadable {
* @return void * @return void
* @access private * @access private
*/ */
function __clean(){ function __clean() {
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {
$this->__cleaned = stripslashes($this->__tainted); $this->__cleaned = stripslashes($this->__tainted);
} else { } else {

View file

@ -552,7 +552,7 @@ class AjaxHelper extends AppHelper {
* @return string JavaScript block to create a droppable element * @return string JavaScript block to create a droppable element
*/ */
function dropRemote($id, $options = array(), $ajaxOptions = array()) { function dropRemote($id, $options = array(), $ajaxOptions = array()) {
$options['onDrop'] = "function(element, droppable){" . $this->remoteFunction($ajaxOptions) . "}"; $options['onDrop'] = "function(element, droppable) {" . $this->remoteFunction($ajaxOptions) . "}";
$options = $this->_optionsToString($options, array('accept', 'overlap', 'hoverclass')); $options = $this->_optionsToString($options, array('accept', 'overlap', 'hoverclass'));
$options = $this->_buildOptions($options, $this->dropOptions); $options = $this->_buildOptions($options, $this->dropOptions);
return $this->Javascript->codeBlock("Droppables.add('{$id}', {$options});"); return $this->Javascript->codeBlock("Droppables.add('{$id}', {$options});");
@ -643,7 +643,7 @@ class AjaxHelper extends AppHelper {
if (empty($options['with'])) { if (empty($options['with'])) {
$options['with'] = "Sortable.serialize('$id')"; $options['with'] = "Sortable.serialize('$id')";
} }
$options['onUpdate'] = 'function(sortable){' . $this->remoteFunction($options) . '}'; $options['onUpdate'] = 'function(sortable) {' . $this->remoteFunction($options) . '}';
} }
$options = $this->_optionsToString($options, array('tag', 'constraint', 'only', 'handle', 'hoverclass', 'scroll', 'tree', 'treeTag')); $options = $this->_optionsToString($options, array('tag', 'constraint', 'only', 'handle', 'hoverclass', 'scroll', 'tree', 'treeTag'));
@ -794,9 +794,9 @@ class AjaxHelper extends AppHelper {
$name = 'on' . ucfirst($callback); $name = 'on' . ucfirst($callback);
$code = $options[$callback]; $code = $options[$callback];
if ($name == 'onComplete') { if ($name == 'onComplete') {
$callbacks[$name] = "function(request, json){" . $code . "}"; $callbacks[$name] = "function(request, json) {" . $code . "}";
} else { } else {
$callbacks[$name] = "function(request){" . $code . "}"; $callbacks[$name] = "function(request) {" . $code . "}";
} }
if (isset($options['bind'])) { if (isset($options['bind'])) {
if ((is_array($options['bind']) && in_array($callback, $options['bind'])) || (is_string($options['bind']) && strpos($options['bind'], $callback) !== false)) { if ((is_array($options['bind']) && in_array($callback, $options['bind'])) || (is_string($options['bind']) && strpos($options['bind'], $callback) !== false)) {

View file

@ -203,7 +203,7 @@ class CacheHelper extends AppHelper {
} }
$cache = convertSlash($this->here); $cache = convertSlash($this->here);
if (empty($cache)){ if (empty($cache)) {
return; return;
} }

View file

@ -404,7 +404,7 @@ class FormHelper extends AppHelper {
$legend = 'Edit '; $legend = 'Edit ';
} }
$legend .= Inflector::humanize(Inflector::underscore($this->model())); $legend .= Inflector::humanize(Inflector::underscore($this->model()));
} elseif (is_string($fieldset)){ } elseif (is_string($fieldset)) {
$legend = $fieldset; $legend = $fieldset;
} elseif (isset($fieldset['legend'])) { } elseif (isset($fieldset['legend'])) {
$legend = $fields['legend']; $legend = $fields['legend'];
@ -1082,7 +1082,7 @@ class FormHelper extends AppHelper {
$meridian = 'am'; $meridian = 'am';
$pos = strpos($selected, '-'); $pos = strpos($selected, '-');
if ($pos !== false){ if ($pos !== false) {
$date = explode('-', $selected); $date = explode('-', $selected);
$days = explode(' ', $date[2]); $days = explode(' ', $date[2]);
$day = $days[0]; $day = $days[0];

View file

@ -226,9 +226,9 @@ class HtmlHelper extends AppHelper {
* @return string A meta tag containing the specified character set. * @return string A meta tag containing the specified character set.
*/ */
function charset($charset = null) { function charset($charset = null) {
if (is_null($charset)){ if (is_null($charset)) {
$charset = Configure::read('charset'); $charset = Configure::read('charset');
if (is_null($charset)){ if (is_null($charset)) {
$charset = 'utf-8'; $charset = 'utf-8';
} }
} }
@ -362,7 +362,7 @@ class HtmlHelper extends AppHelper {
} }
foreach ($this->_crumbs as $crumb) { foreach ($this->_crumbs as $crumb) {
if (!empty($crumb[1])){ if (!empty($crumb[1])) {
$out[] = $this->link($crumb[0], $crumb[1]); $out[] = $this->link($crumb[0], $crumb[1]);
} else { } else {
$out[] = $crumb[0]; $out[] = $crumb[0];
@ -568,7 +568,7 @@ class HtmlHelper extends AppHelper {
} else { } else {
$model = $this->model(); $model = $this->model();
if (isset($htmlAttributes['value']) || (!class_exists($model) && !loadModel($model))) { if (isset($htmlAttributes['value']) || (!class_exists($model) && !loadModel($model))) {
if (isset($htmlAttributes['value']) && $htmlAttributes['value'] == $value){ if (isset($htmlAttributes['value']) && $htmlAttributes['value'] == $value) {
$htmlAttributes['checked'] = 'checked'; $htmlAttributes['checked'] = 'checked';
} else { } else {
$htmlAttributes['checked'] = null; $htmlAttributes['checked'] = null;

View file

@ -190,9 +190,9 @@ class JavascriptHelper extends AppHelper {
} }
if (strpos($object, 'window') !== false || strpos($object, 'document') !== false || strpos($object, '$(') !== false || strpos($object, '"') !== false || strpos($object, '\'') !== false) { if (strpos($object, 'window') !== false || strpos($object, 'document') !== false || strpos($object, '$(') !== false || strpos($object, '"') !== false || strpos($object, '\'') !== false) {
$b = "Event.observe({$object}, '{$event}', function(event){ {$observer} }, {$useCapture});"; $b = "Event.observe({$object}, '{$event}', function(event) { {$observer} }, {$useCapture});";
} elseif (strpos($object, '\'') === 0) { } elseif (strpos($object, '\'') === 0) {
$b = "Event.observe(" . substr($object, 1) . ", '{$event}', function(event){ {$observer} }, {$useCapture});"; $b = "Event.observe(" . substr($object, 1) . ", '{$event}', function(event) { {$observer} }, {$useCapture});";
} else { } else {
$chars = array('#', ' ', ', ', '.', ':'); $chars = array('#', ' ', ', ', '.', ':');
$found = false; $found = false;
@ -205,7 +205,7 @@ class JavascriptHelper extends AppHelper {
if ($found) { if ($found) {
$this->_rules[$object] = $event; $this->_rules[$object] = $event;
} else { } else {
$b = "Event.observe(\$('{$object}'), '{$event}', function(event){ {$observer} }, {$useCapture});"; $b = "Event.observe(\$('{$object}'), '{$event}', function(event) { {$observer} }, {$useCapture});";
} }
} }
@ -355,7 +355,7 @@ class JavascriptHelper extends AppHelper {
if ($val === null) { if ($val === null) {
$val = 'null'; $val = 'null';
} }
if (is_bool($val)){ if (is_bool($val)) {
$val = ife($val, 'true', 'false'); $val = ife($val, 'true', 'false');
} }
} }

View file

@ -32,7 +32,7 @@
foreach ($fields as $field) { foreach ($fields as $field) {
if ($this->action == 'add' && $field['name'] == $primaryKey) { if ($this->action == 'add' && $field['name'] == $primaryKey) {
continue; continue;
} elseif (!in_array($field['name'], array('created', 'modified', 'updated'))){ } elseif (!in_array($field['name'], array('created', 'modified', 'updated'))) {
echo "\t\t".$form->input($field['name'])."\n"; echo "\t\t".$form->input($field['name'])."\n";
} }
} }

View file

@ -61,7 +61,7 @@ class ThemeView extends View {
$this->theme =& $controller->theme; $this->theme =& $controller->theme;
if (!empty($this->theme)) { if (!empty($this->theme)) {
if (is_dir(WWW_ROOT . 'themed' . DS . $this->theme)){ if (is_dir(WWW_ROOT . 'themed' . DS . $this->theme)) {
$this->themeWeb = 'themed/'. $this->theme .'/'; $this->themeWeb = 'themed/'. $this->theme .'/';
} }
$this->themeElement = 'themed'. DS . $this->theme . DS .'elements'. DS; $this->themeElement = 'themed'. DS . $this->theme . DS .'elements'. DS;

View file

@ -892,7 +892,7 @@ class View extends Object {
unset ($out); unset ($out);
return; return;
} else { } else {
if ($this->layout === 'xml'){ if ($this->layout === 'xml') {
header('Content-type: text/xml'); header('Content-type: text/xml');
} }
$out = str_replace('<!--cachetime:'.$match['1'].'-->', '', $out); $out = str_replace('<!--cachetime:'.$match['1'].'-->', '', $out);

View file

@ -1618,7 +1618,7 @@ class DboSourceTest extends UnitTestCase {
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testMixedConditionsParsing(){ function testMixedConditionsParsing() {
$conditions[] = 'User.first_name = \'Firstname\''; $conditions[] = 'User.first_name = \'Firstname\'';
$conditions[] = array('User.last_name' => 'Lastname'); $conditions[] = array('User.last_name' => 'Lastname');
$result = $this->db->conditions($conditions); $result = $this->db->conditions($conditions);

View file

@ -35,7 +35,7 @@ uses('Validation');
*/ */
class ValidationTestCase extends UnitTestCase { class ValidationTestCase extends UnitTestCase {
function testAlphaNumeric(){ function testAlphaNumeric() {
$validation = new Validation(); $validation = new Validation();
$this->assertTrue($validation->alphaNumeric('frferrf')); $this->assertTrue($validation->alphaNumeric('frferrf'));
@ -50,7 +50,7 @@ class ValidationTestCase extends UnitTestCase {
$this->assertFalse($validation->alphaNumeric('')); $this->assertFalse($validation->alphaNumeric(''));
} }
function testAlphaNumericPassedAsArray(){ function testAlphaNumericPassedAsArray() {
$validation = new Validation(); $validation = new Validation();
$this->assertTrue($validation->alphaNumeric(array('check' => 'frferrf'))); $this->assertTrue($validation->alphaNumeric(array('check' => 'frferrf')));
@ -65,14 +65,14 @@ class ValidationTestCase extends UnitTestCase {
$this->assertFalse($validation->alphaNumeric(array('check' => ''))); $this->assertFalse($validation->alphaNumeric(array('check' => '')));
} }
function testBetween(){ function testBetween() {
$validation = new Validation(); $validation = new Validation();
$this->assertTrue($validation->between('abcdefg', 1, 7)); $this->assertTrue($validation->between('abcdefg', 1, 7));
$this->assertTrue($validation->between('', 0, 7)); $this->assertTrue($validation->between('', 0, 7));
$this->assertFalse($validation->between('abcdefg', 1, 6)); $this->assertFalse($validation->between('abcdefg', 1, 6));
} }
function testBlank(){ function testBlank() {
$validation = new Validation(); $validation = new Validation();
$this->assertTrue($validation->blank('')); $this->assertTrue($validation->blank(''));
$this->assertTrue($validation->blank(' ')); $this->assertTrue($validation->blank(' '));
@ -83,7 +83,7 @@ class ValidationTestCase extends UnitTestCase {
$this->assertFalse($validation->blank('Blank')); $this->assertFalse($validation->blank('Blank'));
} }
function testBlankAsArray(){ function testBlankAsArray() {
$validation = new Validation(); $validation = new Validation();
$this->assertTrue($validation->blank(array('check' => ''))); $this->assertTrue($validation->blank(array('check' => '')));
$this->assertTrue($validation->blank(array('check' => ' '))); $this->assertTrue($validation->blank(array('check' => ' ')));
@ -94,7 +94,7 @@ class ValidationTestCase extends UnitTestCase {
$this->assertFalse($validation->blank(array('check' => 'Blank'))); $this->assertFalse($validation->blank(array('check' => 'Blank')));
} }
function testcc(){ function testcc() {
$validation = new Validation(); $validation = new Validation();
//American Express //American Express
$this->assertTrue($validation->cc('370482756063980', array('amex'))); $this->assertTrue($validation->cc('370482756063980', array('amex')));
@ -534,7 +534,7 @@ class ValidationTestCase extends UnitTestCase {
$this->assertTrue($validation->cc('869972521242198', array('voyager'))); $this->assertTrue($validation->cc('869972521242198', array('voyager')));
} }
function testLuhn(){ function testLuhn() {
$validation = new Validation(); $validation = new Validation();
$validation->deep = true; $validation->deep = true;

View file

@ -84,11 +84,11 @@ class AjaxTest extends UnitTestCase {
function testEvalScripts() { function testEvalScripts() {
$result = $this->Ajax->link('Test Link', '/', array('id' => 'link1', 'update' => 'content', 'evalScripts' => false)); $result = $this->Ajax->link('Test Link', '/', array('id' => 'link1', 'update' => 'content', 'evalScripts' => false));
$expected = '<a href="/" id="link1" onclick=" return false;">Test Link</a><script type="text/javascript">Event.observe(\'link1\', \'click\', function(event){ new Ajax.Updater(\'content\',\'/\', {asynchronous:true, evalScripts:false, requestHeaders:[\'X-Update\', \'content\']}) }, false);</script>'; $expected = '<a href="/" id="link1" onclick=" return false;">Test Link</a><script type="text/javascript">Event.observe(\'link1\', \'click\', function(event) { new Ajax.Updater(\'content\',\'/\', {asynchronous:true, evalScripts:false, requestHeaders:[\'X-Update\', \'content\']}) }, false);</script>';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->Ajax->link('Test Link', '/', array('id' => 'link1', 'update' => 'content')); $result = $this->Ajax->link('Test Link', '/', array('id' => 'link1', 'update' => 'content'));
$expected = '<a href="/" id="link1" onclick=" return false;">Test Link</a><script type="text/javascript">Event.observe(\'link1\', \'click\', function(event){ new Ajax.Updater(\'content\',\'/\', {asynchronous:true, evalScripts:true, requestHeaders:[\'X-Update\', \'content\']}) }, false);</script>'; $expected = '<a href="/" id="link1" onclick=" return false;">Test Link</a><script type="text/javascript">Event.observe(\'link1\', \'click\', function(event) { new Ajax.Updater(\'content\',\'/\', {asynchronous:true, evalScripts:true, requestHeaders:[\'X-Update\', \'content\']}) }, false);</script>';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
@ -99,13 +99,13 @@ class AjaxTest extends UnitTestCase {
$this->assertPattern('/<div[^<>]+id="PostTitle_autoComplete"[^<>]*><\/div>/', $result); $this->assertPattern('/<div[^<>]+id="PostTitle_autoComplete"[^<>]*><\/div>/', $result);
$this->assertPattern('/<div[^<>]+class="auto_complete"[^<>]*><\/div>/', $result); $this->assertPattern('/<div[^<>]+class="auto_complete"[^<>]*><\/div>/', $result);
$this->assertPattern('/<\/div>\s+<script type="text\/javascript">new Ajax\.Autocompleter\(\'PostTitle\', \'PostTitle_autoComplete\', \'\/posts\',/', $result); $this->assertPattern('/<\/div>\s+<script type="text\/javascript">new Ajax\.Autocompleter\(\'PostTitle\', \'PostTitle_autoComplete\', \'\/posts\',/', $result);
$this->assertPattern('/<script(.*)>(.*){minChars:2}\);/', $result); $this->assertPattern('/<script(.*)>(.*) {minChars:2}\);/', $result);
$this->assertPattern('/<\/script>$/', $result); $this->assertPattern('/<\/script>$/', $result);
} }
function testAsynchronous() { function testAsynchronous() {
$result = $this->Ajax->link('Test Link', '/', array('id' => 'link1', 'update' => 'content', 'type' => 'synchronous')); $result = $this->Ajax->link('Test Link', '/', array('id' => 'link1', 'update' => 'content', 'type' => 'synchronous'));
$expected = '<a href="/" id="link1" onclick=" return false;">Test Link</a><script type="text/javascript">Event.observe(\'link1\', \'click\', function(event){ new Ajax.Updater(\'content\',\'/\', {asynchronous:false, evalScripts:true, requestHeaders:[\'X-Update\', \'content\']}) }, false);</script>'; $expected = '<a href="/" id="link1" onclick=" return false;">Test Link</a><script type="text/javascript">Event.observe(\'link1\', \'click\', function(event) { new Ajax.Updater(\'content\',\'/\', {asynchronous:false, evalScripts:true, requestHeaders:[\'X-Update\', \'content\']}) }, false);</script>';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
@ -121,14 +121,14 @@ class AjaxTest extends UnitTestCase {
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->Ajax->dropRemote('droppable', array('accept' => 'crap'), array('url' => '/posts')); $result = $this->Ajax->dropRemote('droppable', array('accept' => 'crap'), array('url' => '/posts'));
$expected = '<script type="text/javascript">Droppables.add(\'droppable\', {accept:\'crap\', onDrop:function(element, droppable){new Ajax.Request(\'/posts\', {asynchronous:true, evalScripts:true})}});</script>'; $expected = '<script type="text/javascript">Droppables.add(\'droppable\', {accept:\'crap\', onDrop:function(element, droppable) {new Ajax.Request(\'/posts\', {asynchronous:true, evalScripts:true})}});</script>';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
function testSubmitWithIndicator() { function testSubmitWithIndicator() {
$result = $this->Ajax->submit('Add', array('div' => false, 'url' => "/controller/action", 'indicator' => 'loading', 'loading' => "doSomething()", 'complete' => 'doSomethingElse() ')); $result = $this->Ajax->submit('Add', array('div' => false, 'url' => "/controller/action", 'indicator' => 'loading', 'loading' => "doSomething()", 'complete' => 'doSomethingElse() '));
$this->assertPattern('/onLoading:function\(request\){doSomething\(\);\s+Element.show\(\'loading\'\);}/', $result); $this->assertPattern('/onLoading:function\(request\) {doSomething\(\);\s+Element.show\(\'loading\'\);}/', $result);
$this->assertPattern('/onComplete:function\(request, json\){doSomethingElse\(\) ;\s+Element.hide\(\'loading\'\);}/', $result); $this->assertPattern('/onComplete:function\(request, json\) {doSomethingElse\(\) ;\s+Element.hide\(\'loading\'\);}/', $result);
} }
function tearDown() { function tearDown() {

View file

@ -327,7 +327,7 @@ class HtmlTestManager extends TestManager {
return $noGroupTests; return $noGroupTests;
} }
if (isset($_GET['app'])){ if (isset($_GET['app'])) {
$buffer = "<h3>Available App Test Groups:</h3>\n<ul>"; $buffer = "<h3>Available App Test Groups:</h3>\n<ul>";
} else { } else {
$buffer = "<h3>Available Core Test Groups:</h3>\n<ul>"; $buffer = "<h3>Available Core Test Groups:</h3>\n<ul>";