Applying patch from 'davidpersson' fixing code spacing. Closes #5643

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7772 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2008-10-23 00:10:44 +00:00
parent 6da2040b45
commit 1b456f2cf1
70 changed files with 233 additions and 233 deletions

View file

@ -387,7 +387,7 @@ if (!function_exists('array_combine')) {
switch ($key) {
case 'SCRIPT_FILENAME':
if (defined('SERVER_IIS') && SERVER_IIS === true){
if (defined('SERVER_IIS') && SERVER_IIS === true) {
return str_replace('\\\\', '\\', env('PATH_TRANSLATED'));
}
break;
@ -464,7 +464,7 @@ if (!function_exists('file_put_contents')) {
$expires = strtotime($expires, $now);
}
switch(low($target)) {
switch (low($target)) {
case 'cache':
$filename = CACHE . $path;
break;

View file

@ -383,19 +383,19 @@ class ShellDispatcher {
*/
function getInput($prompt, $options = null, $default = null) {
if (!is_array($options)) {
$print_options = '';
$printOptions = '';
} else {
$print_options = '(' . implode('/', $options) . ')';
$printOptions = '(' . implode('/', $options) . ')';
}
if ($default == null) {
$this->stdout($prompt . " $print_options \n" . '> ', false);
$this->stdout($prompt . " $printOptions \n" . '> ', false);
} else {
$this->stdout($prompt . " $print_options \n" . "[$default] > ", false);
$this->stdout($prompt . " $printOptions \n" . "[$default] > ", false);
}
$result = fgets($this->stdin);
if ($result === false){
if ($result === false) {
exit;
}
$result = trim($result);
@ -454,7 +454,7 @@ class ShellDispatcher {
}
}
if($params['app'][0] == '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) {
if ($params['app'][0] == '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) {
$params['root'] = dirname($params['app']);
} elseif (strpos($params['app'], '/')) {
$params['root'] .= '/' . dirname($params['app']);

View file

@ -199,7 +199,7 @@ class ApiShell extends Shell {
$contents = $File->read();
if (preg_match_all('%(/\\*\\*[\\s\\S]*?\\*/)(\\s+function\\s+\\w+)(\\(.+\\))%', $contents, $result, PREG_PATTERN_ORDER)) {
foreach($result[2] as $key => $method) {
foreach ($result[2] as $key => $method) {
$method = str_replace('function ', '', trim($method));
if (strpos($method, '__') === false && $method[0] != '_') {

View file

@ -86,7 +86,7 @@ class BakeShell extends Shell {
$this->out('[Q]uit');
$classToBake = strtoupper($this->in(__('What would you like to Bake?', true), array('D', 'M', 'V', 'C', 'P', 'Q')));
switch($classToBake) {
switch ($classToBake) {
case 'D':
$this->DbConfig->execute();
break;

View file

@ -95,7 +95,7 @@ class ConsoleShell extends Shell {
$command = trim($this->in(''));
}
switch($command) {
switch ($command) {
case 'help':
$this->out('Console help:');
$this->out('-------------');

View file

@ -80,7 +80,7 @@ class I18nShell extends Shell {
$this->out(__('[Q]uit', true));
$choice = strtoupper($this->in(__('What would you like to do?', true), array('E', 'I', 'H', 'Q')));
switch($choice) {
switch ($choice) {
case 'E':
$this->Extract->execute();
break;

View file

@ -264,7 +264,7 @@ class SchemaShell extends Shell {
$table = $this->args[1];
}
switch($command) {
switch ($command) {
case 'create':
$this->__create($Schema, $table);
break;
@ -372,7 +372,7 @@ class SchemaShell extends Shell {
$db->fullDebug = true;
$errors = array();
foreach($contents as $table => $sql) {
foreach ($contents as $table => $sql) {
if (empty($sql)) {
$this->out(sprintf(__('%s is up to date.', true), $table));
} else {

View file

@ -143,7 +143,7 @@ class Shell extends Object {
ClassRegistry::map($shellKey, $shellKey);
if (!PHP5 && isset($this->args[0])) {
if(strpos($this->className, low(Inflector::camelize($this->args[0]))) !== false) {
if (strpos($this->className, low(Inflector::camelize($this->args[0]))) !== false) {
$dispatch->shiftArgs();
}
if (low($this->command) == low(Inflector::variable($this->args[0])) && method_exists($this, $this->command)) {
@ -348,7 +348,7 @@ class Shell extends Object {
function out($string, $newline = true) {
if (is_array($string)) {
$str = '';
foreach($string as $message) {
foreach ($string as $message) {
$str .= $message ."\n";
}
$string = $str;
@ -364,7 +364,7 @@ class Shell extends Object {
function err($string) {
if (is_array($string)) {
$str = '';
foreach($string as $message) {
foreach ($string as $message) {
$str .= $message ."\n";
}
$string = $str;

View file

@ -280,7 +280,7 @@ class DbConfigTask extends Shell {
$info['port'] = null;
}
if($info['persistent'] === false) {
if ($info['persistent'] === false) {
$info['persistent'] = 'false';
} else {
$info['persistent'] = 'false';

View file

@ -411,7 +411,7 @@ class ModelTask extends Shell {
if ($type === 'belongsTo') {
$alias = 'Parent' . $associations[$type][$i]['alias'];
}
if($type === 'hasOne' || $type === 'hasMany') {
if ($type === 'hasOne' || $type === 'hasMany') {
$alias = 'Child' . $associations[$type][$i]['alias'];
}

View file

@ -71,7 +71,7 @@ class PluginTask extends Shell {
$plugin = null;
if(isset($this->args[0])) {
if (isset($this->args[0])) {
$plugin = Inflector::camelize($this->args[0]);
$pluginPath = Inflector::underscore($plugin) . DS;
$this->Dispatch->shiftArgs();
@ -87,7 +87,7 @@ class PluginTask extends Shell {
}
}
if(isset($this->args[0])) {
if (isset($this->args[0])) {
$task = Inflector::classify($this->args[0]);
$this->Dispatch->shiftArgs();
if (in_array($task, $this->tasks)) {

View file

@ -77,7 +77,7 @@ class ProjectTask extends Shell {
}
}
if($this->bake($project)) {
if ($this->bake($project)) {
$path = Folder::slashTerm($project);
if ($this->createHome($path)) {
$this->out(__('Welcome page created', true));
@ -122,7 +122,7 @@ class ProjectTask extends Shell {
* @access private
*/
function bake($path, $skel = null, $skip = array('empty')) {
if(!$skel) {
if (!$skel) {
$skel = $this->params['skel'];
}

View file

@ -375,7 +375,7 @@ class ViewTask extends Shell {
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
$associations = array();
foreach ($keys as $key => $type){
foreach ($keys as $key => $type) {
foreach ($model->{$type} as $assocKey => $assocData) {
$associations[$type][$assocKey]['primaryKey'] = $model->{$assocKey}->primaryKey;
$associations[$type][$assocKey]['displayField'] = $model->{$assocKey}->displayField;

View file

@ -27,7 +27,7 @@
<?php
$content = explode("\n", $content);
foreach($content as $line):
foreach ($content as $line):
echo '<p> ' . $line . '</p>';
endforeach;
?>

View file

@ -37,7 +37,7 @@
echo "\t\techo \$form->input('{$field}');\n";
}
}
if(!empty($associations['hasAndBelongsToMany'])) {
if (!empty($associations['hasAndBelongsToMany'])) {
foreach ($associations['hasAndBelongsToMany'] as $assocName => $assocData) {
echo "\t\techo \$form->input('{$assocName}');\n";
}
@ -58,7 +58,7 @@
<?php
$done = array();
foreach ($associations as $type => $data) {
foreach($data as $alias => $details) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";

View file

@ -2,7 +2,7 @@
$output = "<h2>Sweet, \"".Inflector::humanize($app)."\" got Baked by CakePHP!</h2>\n";
$output .="
<?php
if(Configure::read() > 0):
if (Configure::read() > 0):
Debugger::checkSessionKey();
endif;
?>

View file

@ -52,16 +52,16 @@ foreach (\${$pluralVar} as \${$singularVar}):
echo "\t<tr<?php echo \$class;?>>\n";
foreach ($fields as $field) {
$isKey = false;
if(!empty($associations['belongsTo'])) {
if (!empty($associations['belongsTo'])) {
foreach ($associations['belongsTo'] as $alias => $details) {
if($field === $details['foreignKey']) {
if ($field === $details['foreignKey']) {
$isKey = true;
echo "\t\t<td>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller'=> '{$details['controller']}', 'action'=>'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t</td>\n";
break;
}
}
}
if($isKey !== true) {
if ($isKey !== true) {
echo "\t\t<td>\n\t\t\t<?php echo \${$singularVar}['{$modelClass}']['{$field}']; ?>\n\t\t</td>\n";
}
}
@ -88,7 +88,7 @@ echo "<?php endforeach; ?>\n";
<?php
$done = array();
foreach ($associations as $type => $data) {
foreach($data as $alias => $details) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";

View file

@ -30,9 +30,9 @@
<?php
foreach ($fields as $field) {
$isKey = false;
if(!empty($associations['belongsTo'])) {
if (!empty($associations['belongsTo'])) {
foreach ($associations['belongsTo'] as $alias => $details) {
if($field === $details['foreignKey']) {
if ($field === $details['foreignKey']) {
$isKey = true;
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize(Inflector::underscore($alias))."'); ?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller'=> '{$details['controller']}', 'action'=>'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
@ -40,7 +40,7 @@ foreach ($fields as $field) {
}
}
}
if($isKey !== true) {
if ($isKey !== true) {
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize($field)."'); ?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \${$singularVar}['{$modelClass}']['{$field}']; ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
}
@ -58,7 +58,7 @@ foreach ($fields as $field) {
$done = array();
foreach ($associations as $type => $data) {
foreach($data as $alias => $details) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";
@ -70,7 +70,7 @@ foreach ($fields as $field) {
</ul>
</div>
<?php
if(!empty($associations['hasOne'])) :
if (!empty($associations['hasOne'])) :
foreach ($associations['hasOne'] as $alias => $details): ?>
<div class="related">
<h3><?php echo "<?php __('Related ".Inflector::humanize($details['controller'])."');?>";?></h3>
@ -93,10 +93,10 @@ if(!empty($associations['hasOne'])) :
<?php
endforeach;
endif;
if(empty($associations['hasMany'])) {
if (empty($associations['hasMany'])) {
$associations['hasMany'] = array();
}
if(empty($associations['hasAndBelongsToMany'])) {
if (empty($associations['hasAndBelongsToMany'])) {
$associations['hasAndBelongsToMany'] = array();
}
$relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']);

View file

@ -430,7 +430,7 @@ class Dispatcher extends Object {
* @access protected
*/
function _restructureParams($params, $reverse = false) {
if($reverse === true) {
if ($reverse === true) {
extract(Router::getArgs($params['action']));
$params = array_merge($params, array('controller'=> $params['plugin'],
'action'=> $params['controller'],
@ -688,7 +688,7 @@ class Dispatcher extends Object {
readfile($assetFile);
}
if(Configure::read('Asset.compress')) {
if (Configure::read('Asset.compress')) {
ob_end_flush();
}
return true;

View file

@ -84,7 +84,7 @@ class FileEngine extends CacheEngine {
),
$settings
));
if(!isset($this->__File)) {
if (!isset($this->__File)) {
if (!class_exists('File')) {
require LIBS . 'file.php';
}
@ -96,7 +96,7 @@ class FileEngine extends CacheEngine {
}
$this->settings['path'] = $this->__File->Folder->cd($this->settings['path']);
if(empty($this->settings['path'])) {
if (empty($this->settings['path'])) {
return false;
}
return $this->__active();
@ -124,7 +124,7 @@ class FileEngine extends CacheEngine {
return false;
}
if($this->__setKey($key) === false) {
if ($this->__setKey($key) === false) {
return false;
}
@ -159,7 +159,7 @@ class FileEngine extends CacheEngine {
* @access public
*/
function read($key) {
if($this->__setKey($key) === false || !$this->__init || !$this->__File->exists()) {
if ($this->__setKey($key) === false || !$this->__init || !$this->__File->exists()) {
return false;
}
if ($this->settings['lock']) {
@ -192,7 +192,7 @@ class FileEngine extends CacheEngine {
* @access public
*/
function delete($key) {
if($this->__setKey($key) === false || !$this->__init) {
if ($this->__setKey($key) === false || !$this->__init) {
return false;
}
return $this->__File->delete();
@ -214,7 +214,7 @@ class FileEngine extends CacheEngine {
$threshold = $now - $this->settings['duration'];
}
while (($entry = $dir->read()) !== false) {
if($this->__setKey($entry) === false) {
if ($this->__setKey($entry) === false) {
continue;
}
if ($check) {

View file

@ -232,7 +232,7 @@ class Configure extends Object {
if (!$suffix) {
return $contents[0];
} else {
foreach($contents[1] as $item) {
foreach ($contents[1] as $item) {
if (substr($item, - strlen($suffix)) === $suffix) {
if ($extension) {
$items[] = $item;

View file

@ -292,7 +292,7 @@ class DbAcl extends AclBase {
return true;
}
} else {
switch($perm['_' . $action]) {
switch ($perm['_' . $action]) {
case -1:
return false;
case 0:

View file

@ -283,7 +283,7 @@ class AuthComponent extends Object {
$keys = array('pass', 'named', 'controller', 'action', 'plugin');
$url = array();
foreach($keys as $key) {
foreach ($keys as $key) {
if (!empty($params[$key])) {
if (is_array($params[$key])) {
foreach ($params[$key] as $name => $value) {
@ -491,7 +491,7 @@ class AuthComponent extends Object {
case 'model':
$this->mapActions();
$action = $this->params['action'];
if(isset($this->actionMap[$action])) {
if (isset($this->actionMap[$action])) {
$action = $this->actionMap[$action];
}
if (is_string($object)) {
@ -507,7 +507,7 @@ class AuthComponent extends Object {
}
if (method_exists($object, 'isAuthorized')) {
$valid = $object->isAuthorized($user, $this->action(':controller'), $action);
} elseif ($object){
} elseif ($object) {
trigger_error(sprintf(__('%s::isAuthorized() is not defined.', true), get_class($object)), E_USER_WARNING);
}
break;

View file

@ -247,7 +247,7 @@ class CookieComponent extends Object {
if (count($name) > 1) {
if (isset($this->__values[$name[0]])) {
if(isset($this->__values[$name[0]][$name[1]])) {
if (isset($this->__values[$name[0]][$name[1]])) {
return $this->__values[$name[0]][$name[1]];
}
}

View file

@ -574,7 +574,7 @@ class EmailComponent extends Object{
}
foreach ($lines as $line) {
if(substr($line, 0, 1) == '.') {
if (substr($line, 0, 1) == '.') {
$line = '.' . $line;
}
$formatted = array_merge($formatted, explode("\n", wordwrap($line, $this->lineLength, "\n", true)));

View file

@ -389,13 +389,13 @@ class RequestHandlerComponent extends Object {
*/
function getReferrer() {
if (env('HTTP_HOST') != null) {
$sess_host = env('HTTP_HOST');
$sessHost = env('HTTP_HOST');
}
if (env('HTTP_X_FORWARDED_HOST') != null) {
$sess_host = env('HTTP_X_FORWARDED_HOST');
$sessHost = env('HTTP_X_FORWARDED_HOST');
}
return trim(preg_replace('/(?:\:.*)/', '', $sess_host));
return trim(preg_replace('/(?:\:.*)/', '', $sessHost));
}
/**
* Gets remote client IP

View file

@ -260,11 +260,11 @@ class Scaffold extends Object {
if ($this->controller->_beforeScaffold($action)) {
if ($action == 'edit') {
if(isset($params['pass'][0])) {
if (isset($params['pass'][0])) {
$this->ScaffoldModel->id = $params['pass'][0];
}
if(!$this->ScaffoldModel->exists()) {
if (!$this->ScaffoldModel->exists()) {
if (isset($this->controller->Session) && $this->controller->Session->valid() != false) {
$this->controller->Session->setFlash(sprintf(__("Invalid id for %s::edit()", true), Inflector::humanize($this->modelKey)));
$this->controller->redirect($this->redirect);
@ -394,7 +394,7 @@ class Scaffold extends Object {
if (!empty($admin)) {
$params['action'] = str_replace($admin . '_', '', $params['action']);
}
switch($params['action']) {
switch ($params['action']) {
case 'index':
$this->__scaffoldIndex($params);
break;
@ -440,7 +440,7 @@ class Scaffold extends Object {
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
$associations = array();
foreach ($keys as $key => $type){
foreach ($keys as $key => $type) {
foreach ($this->ScaffoldModel->{$type} as $assocKey => $assocData) {
$associations[$type][$assocKey]['primaryKey'] = $this->ScaffoldModel->{$assocKey}->primaryKey;
$associations[$type][$assocKey]['displayField'] = $this->ScaffoldModel->{$assocKey}->displayField;

View file

@ -367,7 +367,7 @@ class Debugger extends Object {
*/
function exportVar($var, $recursion = 0) {
$_this = Debugger::getInstance();
switch(strtolower(gettype($var))) {
switch (strtolower(gettype($var))) {
case 'boolean':
return ($var) ? 'true' : 'false';
break;
@ -420,12 +420,12 @@ class Debugger extends Object {
function __object($var) {
$out = array();
if(is_object($var)) {
if (is_object($var)) {
$className = get_class($var);
$objectVars = get_object_vars($var);
foreach($objectVars as $key => $value) {
if(is_object($value)) {
foreach ($objectVars as $key => $value) {
if (is_object($value)) {
$value = get_class($value) . ' object';
} elseif (is_array($value)) {
$value = 'array';

View file

@ -110,9 +110,9 @@ class ErrorHandler extends Object {
}
if ($method !== 'error') {
if (Configure::read() == 0){
if (Configure::read() == 0) {
$method = 'error404';
if(isset($code) && $code == 500) {
if (isset($code) && $code == 500) {
$method = 'error500';
}
}

View file

@ -234,8 +234,8 @@ class File extends Object {
function write($data, $mode = 'w', $force = false) {
$success = false;
if ($this->open($mode, $force) === true) {
if($this->lock !== null) {
if(flock($this->handle, LOCK_EX) === false) {
if ($this->lock !== null) {
if (flock($this->handle, LOCK_EX) === false) {
return false;
}
}

View file

@ -125,9 +125,9 @@ class Folder extends Object {
return $this->path;
}
/**
* Change directory to $desired_path.
* Change directory to $path.
*
* @param string $desired_path Path to the directory to change to
* @param string $path Path to the directory to change to
* @return string The new path. Returns false on failure
* @access public
*/
@ -189,12 +189,12 @@ class Folder extends Object {
* @return array Files that match given pattern
* @access public
*/
function find($regexp_pattern = '.*', $sort = false) {
function find($regexpPattern = '.*', $sort = false) {
list($dirs, $files) = $this->read($sort);
$found = array();
foreach ($files as $file) {
if (preg_match("/^{$regexp_pattern}$/i", $file)) {
if (preg_match("/^{$regexpPattern}$/i", $file)) {
$found[] = $file;
}
}
@ -536,9 +536,9 @@ class Folder extends Object {
$path = $this->slashTerm($path);
if (is_dir($path) === true) {
$files = glob($path . "*", GLOB_NOSORT);
$normal_files = glob($path . "*");
$hidden_files = glob($path . "\.?*");
$files = array_merge($normal_files, $hidden_files);
$normalFiles = glob($path . "*");
$hiddenFiles = glob($path . "\.?*");
$files = array_merge($normalFiles, $hiddenFiles);
if (is_array($files)) {
foreach ($files as $file) {
if (preg_match("/(\.|\.\.)$/", $file)) {

View file

@ -417,10 +417,10 @@ class Inflector extends Object {
return $replace;
}
/**
* Returns an underscore-syntaxed ($like_this_dear_reader) version of the $camel_cased_word.
* Returns an underscore-syntaxed (like_this_dear_reader) version of the $camel_cased_word.
*
* @param string $camel_cased_word Camel-cased word to be "underscorized"
* @return string Underscore-syntaxed version of the $camel_cased_word
* @param string $camelCasedWord Camel-cased word to be "underscorized"
* @return string Underscore-syntaxed version of the $camelCasedWord
* @access public
* @static
*/
@ -442,9 +442,9 @@ class Inflector extends Object {
return $replace;
}
/**
* Returns corresponding table name for given $class_name. ("posts" for the model class "Post").
* Returns corresponding table name for given $className. ("posts" for the model class "Post").
*
* @param string $class_name Name of class to get database table name for
* @param string $className Name of class to get database table name for
* @return string Name of the database table for given class
* @access public
* @static

View file

@ -245,7 +245,7 @@ class MagicFileResource extends Object{
* @access public
*/
function read($length = null) {
if (!is_object($this->resource)){
if (!is_object($this->resource)) {
return substr($this->resource, $this->offset, $length);
}
return $this->resource->read($length);

View file

@ -129,7 +129,7 @@ class ContainableBehavior extends ModelBehavior {
}
if ($contain) {
$backupBindings = array();
foreach($this->types as $relation) {
foreach ($this->types as $relation) {
$backupBindings[$relation] = $instance->{$relation};
}
foreach ($this->types as $type) {
@ -180,16 +180,16 @@ class ContainableBehavior extends ModelBehavior {
$query['fields'] = (array)$query['fields'];
if (!empty($Model->belongsTo)) {
foreach($Model->belongsTo as $assoc => $data) {
foreach ($Model->belongsTo as $assoc => $data) {
if (!empty($data['fields'])) {
foreach((array) $data['fields'] as $field) {
foreach ((array) $data['fields'] as $field) {
$query['fields'][] = (strpos($field, '.') === false ? $assoc . '.' : '') . $field;
}
}
}
}
if (!empty($mandatory[$Model->alias])) {
foreach($mandatory[$Model->alias] as $field) {
foreach ($mandatory[$Model->alias] as $field) {
if ($field == '--primaryKey--') {
$field = $Model->primaryKey;
} else if (preg_match('/^.+\.\-\-[^-]+\-\-$/', $field)) {
@ -213,7 +213,7 @@ class ContainableBehavior extends ModelBehavior {
*/
function afterFind(&$Model, $results, $primary) {
if (!empty($Model->__backContainableAssociation)) {
foreach($Model->__backContainableAssociation as $relation => $bindings) {
foreach ($Model->__backContainableAssociation as $relation => $bindings) {
$Model->{$relation} = $bindings;
unset($Model->__backContainableAssociation);
}
@ -250,7 +250,7 @@ class ContainableBehavior extends ModelBehavior {
if (!empty($Model->__backInnerAssociation)) {
$assocs = $Model->__backInnerAssociation;
unset($Model->__backInnerAssociation);
foreach($assocs as $currentModel) {
foreach ($assocs as $currentModel) {
$this->resetBindings($Model->$currentModel);
}
}
@ -370,9 +370,9 @@ class ContainableBehavior extends ModelBehavior {
*/
function fieldDependencies(&$Model, $map, $fields = array()) {
if ($fields === false) {
foreach($map as $parent => $children) {
foreach($children as $type => $bindings) {
foreach($bindings as $dependency) {
foreach ($map as $parent => $children) {
foreach ($children as $type => $bindings) {
foreach ($bindings as $dependency) {
if ($type == 'hasAndBelongsToMany') {
$fields[$parent][] = '--primaryKey--';
} else if ($type == 'belongsTo') {
@ -386,10 +386,10 @@ class ContainableBehavior extends ModelBehavior {
if (empty($map[$Model->alias])) {
return $fields;
}
foreach($map[$Model->alias] as $type => $bindings) {
foreach($bindings as $dependency) {
foreach ($map[$Model->alias] as $type => $bindings) {
foreach ($bindings as $dependency) {
$innerFields = array();
switch($type) {
switch ($type) {
case 'belongsTo':
$fields[] = $Model->{$type}[$dependency]['foreignKey'];
break;

View file

@ -754,7 +754,7 @@ class TreeBehavior extends ModelBehavior {
if (is_null($instance[$model->alias][$left]) || is_null($instance[$model->alias][$right])) {
$errors[] = array('node', $instance[$model->alias][$model->primaryKey],
'has invalid left or right values');
} elseif ($instance[$model->alias][$left] == $instance[$model->alias][$right]){
} elseif ($instance[$model->alias][$left] == $instance[$model->alias][$right]) {
$errors[] = array('node', $instance[$model->alias][$model->primaryKey],
'left and right values identical');
} elseif ($instance[$model->alias][$parent]) {

View file

@ -411,7 +411,7 @@ class DataSource extends Object {
$val = null;
if (strpos($query, $key) !== false) {
switch($key) {
switch ($key) {
case '{$__cakeID__$}':
if (isset($data[$model->alias]) || isset($data[$association])) {
if (isset($data[$model->alias][$model->primaryKey])) {

View file

@ -118,7 +118,7 @@ class DboDb2 extends DboSource {
if ($config['cataloged']) {
$this->connection = $connect($config['database'], $config['login'], $config['password']);
} else {
$conn_string = sprintf(
$connString = sprintf(
"DRIVER={IBM DB2 ODBC DRIVER};DATABASE=%s;HOSTNAME=%s;PORT=%d;PROTOCOL=TCPIP;UID=%s;PWD=%s;",
$config['database'],
$config['hostname'],
@ -126,7 +126,7 @@ class DboDb2 extends DboSource {
$config['login'],
$config['password']
);
$this->connection = db2_connect($conn_string, '', '');
$this->connection = db2_connect($connString, '', '');
}
if ($this->connection) {
@ -161,15 +161,15 @@ class DboDb2 extends DboSource {
// get result from db
$result = db2_exec($this->connection, $sql);
if(!is_bool($result)){
if (!is_bool($result)) {
// build table/column map for this result
$map = array();
$num_fields = db2_num_fields($result);
$numFields = db2_num_fields($result);
$index = 0;
$j = 0;
$offset = 0;
while ($j < $num_fields) {
while ($j < $numFields) {
$columnName = strtolower(db2_field_name($result, $j));
$tmp = strpos($sql, '.' . $columnName, $offset);
$tableName = substr($sql, $offset, ($tmp-$offset));

View file

@ -265,7 +265,7 @@ class DboMssql extends DboSource {
return "''";
}
switch($column) {
switch ($column) {
case 'boolean':
$data = $this->boolean((bool)$data);
break;
@ -500,11 +500,11 @@ class DboMssql extends DboSource {
function resultSet(&$results) {
$this->results =& $results;
$this->map = array();
$num_fields = mssql_num_fields($results);
$numFields = mssql_num_fields($results);
$index = 0;
$j = 0;
while ($j < $num_fields) {
while ($j < $numFields) {
$column = mssql_field_name($results, $j);
if (strpos($column, '__')) {

View file

@ -203,7 +203,7 @@ class DboMysql extends DboSource {
'default' => $column[0]['Default'],
'length' => $this->length($column[0]['Type']),
);
if(!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) {
if (!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) {
$fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']];
}
}
@ -436,11 +436,11 @@ class DboMysql extends DboSource {
}
$this->results =& $results;
$this->map = array();
$num_fields = mysql_num_fields($results);
$numFields = mysql_num_fields($results);
$index = 0;
$j = 0;
while ($j < $num_fields) {
while ($j < $numFields) {
$column = mysql_fetch_field($results,$j);
if (!empty($column->table)) {
@ -510,15 +510,15 @@ class DboMysql extends DboSource {
function index($model) {
$index = array();
$table = $this->fullTableName($model);
if($table) {
if ($table) {
$indexes = $this->query('SHOW INDEX FROM ' . $table);
$keys = Set::extract($indexes, '{n}.STATISTICS');
foreach ($keys as $i => $key) {
if(!isset($index[$key['Key_name']])) {
if (!isset($index[$key['Key_name']])) {
$index[$key['Key_name']]['column'] = $key['Column_name'];
$index[$key['Key_name']]['unique'] = intval($key['Non_unique'] == 0);
} else {
if(!is_array($index[$key['Key_name']]['column'])) {
if (!is_array($index[$key['Key_name']]['column'])) {
$col[] = $index[$key['Key_name']]['column'];
}
$col[] = $key['Column_name'];
@ -535,35 +535,35 @@ class DboMysql extends DboSource {
* @return unknown
*/
function alterSchema($compare, $table = null) {
if(!is_array($compare)) {
if (!is_array($compare)) {
return false;
}
$out = '';
$colList = array();
foreach($compare as $curTable => $types) {
foreach ($compare as $curTable => $types) {
if (!$table || $table == $curTable) {
$out .= 'ALTER TABLE ' . $this->fullTableName($curTable) . " \n";
foreach($types as $type => $column) {
switch($type) {
foreach ($types as $type => $column) {
switch ($type) {
case 'add':
foreach($column as $field => $col) {
foreach ($column as $field => $col) {
$col['name'] = $field;
$alter = 'ADD '.$this->buildColumn($col);
if(isset($col['after'])) {
if (isset($col['after'])) {
$alter .= ' AFTER '. $this->name($col['after']);
}
$colList[] = $alter;
}
break;
case 'drop':
foreach($column as $field => $col) {
foreach ($column as $field => $col) {
$col['name'] = $field;
$colList[] = 'DROP '.$this->name($field);
}
break;
case 'change':
foreach($column as $field => $col) {
if(!isset($col['name'])) {
foreach ($column as $field => $col) {
if (!isset($col['name'])) {
$col['name'] = $field;
}
$colList[] = 'CHANGE '. $this->name($field).' '.$this->buildColumn($col);

View file

@ -159,7 +159,7 @@ class DboMysqli extends DboSource {
$firstResult = mysqli_store_result($this->connection);
if (mysqli_more_results($this->connection)) {
while($lastResult = mysqli_next_result($this->connection));
while ($lastResult = mysqli_next_result($this->connection));
}
return $firstResult;
}
@ -215,7 +215,7 @@ class DboMysqli extends DboSource {
'default' => $column[0]['Default'],
'length' => $this->length($column[0]['Type'])
);
if(!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) {
if (!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) {
$fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']];
}
}
@ -412,10 +412,10 @@ class DboMysqli extends DboSource {
}
$this->results =& $results;
$this->map = array();
$num_fields = mysqli_num_fields($results);
$numFields = mysqli_num_fields($results);
$index = 0;
$j = 0;
while ($j < $num_fields) {
while ($j < $numFields) {
$column = mysqli_fetch_field_direct($results, $j);
if (!empty($column->table)) {
$this->map[$index++] = array($column->table, $column->name);

View file

@ -199,7 +199,7 @@ class DboSqlite extends DboSource {
'default' => $column[0]['dflt_value'],
'length' => $this->length($column[0]['type'])
);
if($column[0]['pk'] == 1) {
if ($column[0]['pk'] == 1) {
$fields[$column[0]['name']] = array(
'type' => $fields[$column[0]['name']]['type'],
'null' => false,

View file

@ -345,7 +345,7 @@ class DboSource extends DataSource {
$out = array();
$first = $this->fetchRow();
if ($first != null){
if ($first != null) {
$out[] = $first;
}
while ($this->hasResult() && $item = $this->fetchResult()) {
@ -397,7 +397,7 @@ class DboSource extends DataSource {
$data = (array)$data;
$count = count($data);
for($i = 0; $i < $count; $i++) {
for ($i = 0; $i < $count; $i++) {
if ($data[$i] == '*') {
continue;
}
@ -841,7 +841,7 @@ class DboSource extends DataSource {
if ($type == 'hasAndBelongsToMany') {
$uniqueIds = $merge = array();
foreach($fetch as $j => $data) {
foreach ($fetch as $j => $data) {
if (
(isset($data[$with]) && $data[$with][$foreignKey] === $row[$model->alias][$model->primaryKey]) &&
(!in_array($data[$with][$joinKeys[1]], $uniqueIds))
@ -1074,7 +1074,7 @@ class DboSource extends DataSource {
}
$assocData['limit'] = $this->limit($assocData['limit'], $assocData['offset']);
switch($type) {
switch ($type) {
case 'hasOne':
case 'belongsTo':
$conditions = $this->__mergeConditions(

View file

@ -63,7 +63,7 @@ class AclNode extends AppModel {
*/
function __construct() {
$config = Configure::read('Acl.database');
if(isset($config)) {
if (isset($config)) {
$this->useDbConfig = $config;
}
parent::__construct();

View file

@ -593,7 +593,7 @@ class Model extends Overloadable {
* @access private
*/
function __constructLinkedModel($assoc, $className = null) {
if(empty($className)) {
if (empty($className)) {
$className = $assoc;
}
@ -626,7 +626,7 @@ class Model extends Overloadable {
if (!isset($this->{$type}[$assocKey][$key]) || $this->{$type}[$assocKey][$key] === null) {
$data = '';
switch($key) {
switch ($key) {
case 'fields':
$data = '';
break;

View file

@ -221,7 +221,7 @@ class CakeSchema extends Object {
unset($currentTables[$key]);
}
if (!empty($Object->hasAndBelongsToMany)) {
foreach($Object->hasAndBelongsToMany as $Assoc => $assocData) {
foreach ($Object->hasAndBelongsToMany as $Assoc => $assocData) {
if (isset($assocData['with'])) {
$class = $assocData['with'];
} elseif ($assocData['_with']) {
@ -243,7 +243,7 @@ class CakeSchema extends Object {
}
}
if (!empty($currentTables)) {
foreach($currentTables as $table) {
foreach ($currentTables as $table) {
if ($prefix) {
if (strpos($table, $prefix) !== 0) {
continue;

View file

@ -1077,7 +1077,7 @@ class Multibyte extends Object {
function __find($char, $type = 'lower') {
$value = false;
$found = array();
if(!isset($this->__codeRange[$char])) {
if (!isset($this->__codeRange[$char])) {
$range = $this->__codepoint($char);
if ($range === false) {
return null;
@ -1093,7 +1093,7 @@ class Multibyte extends Object {
$this->__table = $this->__codeRange[$char];
$count = count($this->__caseFold[$this->__table]);
for($i = 0; $i < $count; $i++) {
for ($i = 0; $i < $count; $i++) {
if ($type === 'lower' && $this->__caseFold[$this->__table][$i][$type][0] === $char) {
$found[] = $this->__caseFold[$this->__table][$i];
} elseif ($type === 'upper' && $this->__caseFold[$this->__table][$i][$type] === $char) {

View file

@ -265,7 +265,7 @@ class Object {
$file = CACHE . 'persistent' . DS . strtolower($name) . '.php';
include($file);
switch($type) {
switch ($type) {
case 'registry':
$vars = unserialize(${$name});
foreach ($vars['0'] as $key => $value) {

View file

@ -870,7 +870,7 @@ class Router extends Object {
array_unshift($urlOut, $url['plugin']);
}
if($_this->__admin && isset($url[$_this->__admin])) {
if ($_this->__admin && isset($url[$_this->__admin])) {
array_unshift($urlOut, $_this->__admin);
}
$output = join('/', $urlOut) . '/';
@ -1036,7 +1036,7 @@ class Router extends Object {
* @access private
*/
function __mapRoute($route, $params = array()) {
if(isset($params['plugin']) && isset($params['controller']) && $params['plugin'] === $params['controller']) {
if (isset($params['plugin']) && isset($params['controller']) && $params['plugin'] === $params['controller']) {
unset($params['controller']);
}

View file

@ -267,7 +267,7 @@ class Sanitize {
if (isset($colData['formatter']) || isset($colData['format'])) {
switch(strtolower($colData['formatter'])) {
switch (strtolower($colData['formatter'])) {
case 'date':
$data = date($colData['format'], strtotime($data));
break;
@ -284,7 +284,7 @@ class Sanitize {
}
$model->data[$name][$column]=$data;
/*
switch($colType) {
switch ($colType) {
case 'integer':
case 'int':
return $data;

View file

@ -66,7 +66,7 @@ class Security extends Object {
*/
function inactiveMins() {
$_this =& Security::getInstance();
switch(Configure::read('Security.level')) {
switch (Configure::read('Security.level')) {
case 'high':
return 10;
break;
@ -87,7 +87,7 @@ class Security extends Object {
* @static
*/
function generateAuthKey() {
if(!class_exists('String')) {
if (!class_exists('String')) {
App::import('Core', 'String');
}
return Security::hash(String::uuid());

View file

@ -247,7 +247,7 @@ class CakeSession extends Object {
* @access private
*/
function __overwrite(&$old, $new) {
if(!empty($old)) {
if (!empty($old)) {
foreach ($old as $key => $var) {
if (!isset($new[$key])) {
unset($old[$key]);
@ -422,22 +422,22 @@ class CakeSession extends Object {
* @access private
*/
function __initSession() {
$ini_set = function_exists('ini_set');
$iniSet = function_exists('ini_set');
if ($ini_set && env('HTTPS')) {
if ($iniSet && env('HTTPS')) {
ini_set('session.cookie_secure', 1);
}
switch($this->security) {
switch ($this->security) {
case 'high':
$this->cookieLifeTime = 0;
if ($ini_set) {
if ($iniSet) {
ini_set('session.referer_check', $this->host);
}
break;
case 'medium':
$this->cookieLifeTime = 7 * 86400;
if ($ini_set) {
if ($iniSet) {
ini_set('session.referer_check', $this->host);
}
break;
@ -447,10 +447,10 @@ class CakeSession extends Object {
break;
}
switch(Configure::read('Session.save')) {
switch (Configure::read('Session.save')) {
case 'cake':
if (!isset($_SESSION)) {
if ($ini_set) {
if ($iniSet) {
ini_set('session.use_trans_sid', 0);
ini_set('url_rewriter.tags', '');
ini_set('session.serialize_handler', 'php');
@ -471,7 +471,7 @@ class CakeSession extends Object {
} elseif (Configure::read('Session.database') === null) {
Configure::write('Session.database', 'default');
}
if ($ini_set) {
if ($iniSet) {
ini_set('session.use_trans_sid', 0);
ini_set('url_rewriter.tags', '');
ini_set('session.save_handler', 'user');
@ -492,7 +492,7 @@ class CakeSession extends Object {
break;
case 'php':
if (!isset($_SESSION)) {
if ($ini_set) {
if ($iniSet) {
ini_set('session.use_trans_sid', 0);
ini_set('session.name', Configure::read('Session.cookie'));
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
@ -505,7 +505,7 @@ class CakeSession extends Object {
if (!class_exists('Cache')) {
uses('Cache');
}
if ($ini_set) {
if ($iniSet) {
ini_set('session.use_trans_sid', 0);
ini_set('url_rewriter.tags', '');
ini_set('session.save_handler', 'user');
@ -683,7 +683,7 @@ class CakeSession extends Object {
function __close() {
$probability = mt_rand(1, 150);
if ($probability <= 3) {
switch(Configure::read('Session.save')) {
switch (Configure::read('Session.save')) {
case 'cache':
Cache::gc();
break;
@ -728,7 +728,7 @@ class CakeSession extends Object {
$db =& ConnectionManager::getDataSource(Configure::read('Session.database'));
$table = $db->fullTableName(Configure::read('Session.table'));
switch(Configure::read('Security.level')) {
switch (Configure::read('Security.level')) {
case 'high':
$factor = 10;
break;

View file

@ -191,25 +191,25 @@ class Set extends Object {
$out[$key] = Set::__map($value, $class);
if (is_object($out[$key])) {
if ($primary !== true && is_array($value) && Set::countDim($value, true) === 2) {
if(!isset($out[$key]->_name_)) {
if (!isset($out[$key]->_name_)) {
$out[$key]->_name_ = $primary;
}
}
}
} elseif (is_array($value)) {
if ($primary === true) {
if(!isset($out->_name_)) {
if (!isset($out->_name_)) {
$out->_name_ = $key;
}
$primary = false;
foreach($value as $key2 => $value2) {
foreach ($value as $key2 => $value2) {
$out->{$key2} = Set::__map($value2, true);
}
} else {
if (!is_numeric($key)) {
$out->{$key} = Set::__map($value, true, $key);
if (is_object($out->{$key}) && !is_numeric($key)) {
if(!isset($out->{$key}->_name_)) {
if (!isset($out->{$key}->_name_)) {
$out->{$key}->_name_ = $key;
}
}

View file

@ -129,7 +129,7 @@ class String extends Object {
* @static
*/
function tokenize($data, $separator = ',', $leftBound = '(', $rightBound = ')') {
if(empty($data) || is_array($data)) {
if (empty($data) || is_array($data)) {
return $data;
}

View file

@ -313,7 +313,7 @@ class Validation extends Object {
}
$operator = str_replace(array(" ", "\t", "\n", "\r", "\0", "\x0B"), "", strtolower($operator));
switch($operator) {
switch ($operator) {
case 'isgreater':
case '>':
if ($check1 > $check2) {

View file

@ -27,7 +27,7 @@
<?php
$content = explode("\n", $content);
foreach($content as $line):
foreach ($content as $line):
echo '<p> ' . $line . '</p>';
endforeach;
?>

View file

@ -371,11 +371,11 @@ class Helper extends Overloadable {
switch (count($parts)) {
case 1:
if($view->modelScope === false) {
if ($view->modelScope === false) {
$view->model = $parts[0];
} else {
$view->field = $parts[0];
if($sameScope === false) {
if ($sameScope === false) {
$view->association = $parts[0];
}
}
@ -585,7 +585,7 @@ class Helper extends Overloadable {
if (is_array($result)) {
$view =& ClassRegistry::getObject('view');
if(isset($result[$view->fieldSuffix])) {
if (isset($result[$view->fieldSuffix])) {
$result = $result[$view->fieldSuffix];
}
}

View file

@ -559,7 +559,7 @@ class AjaxHelper extends AppHelper {
$options = $this->_optionsToString($options, array('axis', 'handleImage', 'handleDisabled'));
$callbacks = array('change', 'slide');
foreach($callbacks as $callback) {
foreach ($callbacks as $callback) {
if (isset($options[$callback])) {
$options['on' . ucfirst($callback)] = 'function(value) {' . $options[$callback] . '}';
unset($options[$callback]);
@ -680,7 +680,7 @@ class AjaxHelper extends AppHelper {
$jsOptions = array_merge($jsOptions, array_intersect_key($options, array_flip(array('contentType', 'encoding', 'method', 'postBody'))));
foreach ($options as $key => $value) {
switch($key) {
switch ($key) {
case 'type':
$jsOptions['asynchronous'] = ($value == 'synchronous') ? 'false' : 'true';
break;
@ -787,7 +787,7 @@ class AjaxHelper extends AppHelper {
if (isset($options[$callback])) {
$name = 'on' . ucfirst($callback);
$code = $options[$callback];
switch($name) {
switch ($name) {
case 'onComplete':
$callbacks[$name] = "function(request, json) {" . $code . "}";
break;

View file

@ -1567,7 +1567,7 @@ class FormHelper extends AppHelper {
$opt = implode($separator, $selects);
}
switch($timeFormat) {
switch ($timeFormat) {
case '24':
$selectMinuteAttr['interval'] = $interval;
$opt .= $this->hour($fieldName, true, $hour, $selectHourAttr, $showEmpty) . ':' .

View file

@ -624,7 +624,7 @@ class HtmlHelper extends AppHelper {
$out = '';
$index = 1;
foreach($items as $key => $item) {
foreach ($items as $key => $item) {
if (is_array($item)) {
$item = $key . $this->nestedList($item, $attributes, $itemAttributes, $tag);
}

View file

@ -81,7 +81,7 @@ class JsHelper extends Overloadable2 {
return 'alert("' . $this->escape($message) . '");';
}
function if_($if, $then, $else = null, $elseif = array()) {
function if_($if, $then, $else = null, $elseIf = array()) {
$len = strlen($if) - 1;
if ($if{$len} == ';') {
$if{$len} = null;
@ -89,7 +89,7 @@ class JsHelper extends Overloadable2 {
$out = 'if (' . $if . ') { ' . $then . ' }';
foreach ($elseif as $cond => $exec) {
foreach ($elseIf as $cond => $exec) {
//$out .=
}

View file

@ -57,7 +57,7 @@ class NumberHelper extends AppHelper {
* @static
*/
function toReadableSize($size) {
switch($size) {
switch ($size) {
case 0:
return '0 Bytes';
case 1:
@ -185,7 +185,7 @@ class NumberHelper extends AppHelper {
$result = $this->format($abs, $options);
if ($number < 0 ) {
if($options['negative'] == '()') {
if ($options['negative'] == '()') {
$result = '(' . $result .')';
} else {
$result = $options['negative'] . $result;

View file

@ -195,7 +195,7 @@ class SessionHelper extends CakeSession {
* @access public
*/
function __start() {
if(!parent::started()) {
if (!parent::started()) {
parent::start();
}
return true;

View file

@ -38,8 +38,8 @@ class TimeHelper extends AppHelper {
/**
* Converts given time (in server's time zone) to user's local time, given his/her offset from GMT.
*
* @param string $server_time UNIX timestamp
* @param int $user_offset User's offset from GMT (in hours)
* @param string $serverTime UNIX timestamp
* @param int $userOffset User's offset from GMT (in hours)
* @return string UNIX timestamp
*/
function convert($serverTime, $userOffset) {
@ -317,8 +317,8 @@ class TimeHelper extends AppHelper {
if (!is_null($userOffset)) {
$now = $this->convert(time(), $userOffset);
}
$in_seconds = $this->fromString($dateTime, $userOffset);
$backwards = ($in_seconds > $now);
$inSeconds = $this->fromString($dateTime, $userOffset);
$backwards = ($inSeconds > $now);
$format = 'j/n/y';
$end = '+1 month';
@ -337,22 +337,22 @@ class TimeHelper extends AppHelper {
}
if ($backwards) {
$future_time = $in_seconds;
$past_time = $now;
$futureTime = $inSeconds;
$pastTime = $now;
} else {
$future_time = $now;
$past_time = $in_seconds;
$futureTime = $now;
$pastTime = $inSeconds;
}
$diff = $future_time - $past_time;
$diff = $futureTime - $pastTime;
// If more than a week, then take into account the length of months
if ($diff >= 604800) {
$current = array();
$date = array();
list($future['H'], $future['i'], $future['s'], $future['d'], $future['m'], $future['Y']) = explode('/', date('H/i/s/d/m/Y', $future_time));
list($future['H'], $future['i'], $future['s'], $future['d'], $future['m'], $future['Y']) = explode('/', date('H/i/s/d/m/Y', $futureTime));
list($past['H'], $past['i'], $past['s'], $past['d'], $past['m'], $past['Y']) = explode('/', date('H/i/s/d/m/Y', $past_time));
list($past['H'], $past['i'], $past['s'], $past['d'], $past['m'], $past['Y']) = explode('/', date('H/i/s/d/m/Y', $pastTime));
$years = $months = $weeks = $days = $hours = $minutes = $seconds = 0;
if ($future['Y'] == $past['Y'] && $future['m'] == $past['m']) {
@ -379,13 +379,13 @@ class TimeHelper extends AppHelper {
if ($future['d'] >= $past['d']) {
$days = $future['d'] - $past['d'];
} else {
$days_in_past_month = date('t', $past_time);
$days_in_future_month = date('t', mktime(0, 0, 0, $future['m'] - 1, 1, $future['Y']));
$daysInPastMonth = date('t', $pastTime);
$daysInFutureMonth = date('t', mktime(0, 0, 0, $future['m'] - 1, 1, $future['Y']));
if (!$backwards) {
$days = ($days_in_past_month - $past['d']) + $future['d'];
$days = ($daysInPastMonth - $past['d']) + $future['d'];
} else {
$days = ($days_in_future_month - $past['d']) + $future['d'];
$days = ($daysInFutureMonth - $past['d']) + $future['d'];
}
if ($future['m'] != $past['m']) {
@ -393,7 +393,7 @@ class TimeHelper extends AppHelper {
}
}
if ($months == 0 && $years >= 1 && $diff < ($years * 31536000)){
if ($months == 0 && $years >= 1 && $diff < ($years * 31536000)) {
$months = 11;
$years --;
}
@ -420,48 +420,48 @@ class TimeHelper extends AppHelper {
$diff = $diff - ($minutes * 60);
$seconds = $diff;
}
$relative_date = '';
$diff = $future_time - $past_time;
$relativeDate = '';
$diff = $futureTime - $pastTime;
if ($diff > abs($now - $this->fromString($end))) {
$relative_date = sprintf(__('on %s',true), date($format, $in_seconds));
$relativeDate = sprintf(__('on %s',true), date($format, $inSeconds));
} else {
if ($years > 0) {
// years and months and days
$relative_date .= ($relative_date ? ', ' : '') . $years . ' ' . __n('year', 'years', $years, true);
$relative_date .= $months > 0 ? ($relative_date ? ', ' : '') . $months . ' ' . __n('month', 'months', $months, true) : '';
$relative_date .= $weeks > 0 ? ($relative_date ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true) : '';
$relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : '';
$relativeDate .= ($relativeDate ? ', ' : '') . $years . ' ' . __n('year', 'years', $years, true);
$relativeDate .= $months > 0 ? ($relativeDate ? ', ' : '') . $months . ' ' . __n('month', 'months', $months, true) : '';
$relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true) : '';
$relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : '';
} elseif (abs($months) > 0) {
// months, weeks and days
$relative_date .= ($relative_date ? ', ' : '') . $months . ' ' . __n('month', 'months', $months, true);
$relative_date .= $weeks > 0 ? ($relative_date ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true) : '';
$relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : '';
$relativeDate .= ($relativeDate ? ', ' : '') . $months . ' ' . __n('month', 'months', $months, true);
$relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true) : '';
$relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : '';
} elseif (abs($weeks) > 0) {
// weeks and days
$relative_date .= ($relative_date ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true);
$relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : '';
$relativeDate .= ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks, true);
$relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true) : '';
} elseif (abs($days) > 0) {
// days and hours
$relative_date .= ($relative_date ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true);
$relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' ' . __n('hour', 'hours', $hours, true) : '';
$relativeDate .= ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days, true);
$relativeDate .= $hours > 0 ? ($relativeDate ? ', ' : '') . $hours . ' ' . __n('hour', 'hours', $hours, true) : '';
} elseif (abs($hours) > 0) {
// hours and minutes
$relative_date .= ($relative_date ? ', ' : '') . $hours . ' ' . __n('hour', 'hours', $hours, true);
$relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' ' . __n('minute', 'minutes', $minutes, true) : '';
$relativeDate .= ($relativeDate ? ', ' : '') . $hours . ' ' . __n('hour', 'hours', $hours, true);
$relativeDate .= $minutes > 0 ? ($relativeDate ? ', ' : '') . $minutes . ' ' . __n('minute', 'minutes', $minutes, true) : '';
} elseif (abs($minutes) > 0) {
// minutes only
$relative_date .= ($relative_date ? ', ' : '') . $minutes . ' ' . __n('minute', 'minutes', $minutes, true);
$relativeDate .= ($relativeDate ? ', ' : '') . $minutes . ' ' . __n('minute', 'minutes', $minutes, true);
} else {
// seconds only
$relative_date .= ($relative_date ? ', ' : '') . $seconds . ' ' . __n('second', 'seconds', $seconds, true);
$relativeDate .= ($relativeDate ? ', ' : '') . $seconds . ' ' . __n('second', 'seconds', $seconds, true);
}
if (!$backwards) {
$relative_date = sprintf(__('%s ago', true), $relative_date);
$relativeDate = sprintf(__('%s ago', true), $relativeDate);
}
}
return $this->output($relative_date);
return $this->output($relativeDate);
}
/**
* Alias for timeAgoInWords

View file

@ -27,7 +27,7 @@
<h2><?php echo sprintf(__('Release Notes for CakePHP %s.', true), Configure::version()); ?></h2>
<a href="https://trac.cakephp.org/wiki/notes/1.2.x.x"><?php __('Read the release notes and get the latest version'); ?> </a>
<?php
if(Configure::read() > 0):
if (Configure::read() > 0):
Debugger::checkSessionKey();
endif;
?>

View file

@ -40,7 +40,7 @@
<?php
$done = array();
foreach ($associations as $_type => $_data) {
foreach($_data as $_alias => $_details) {
foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller'=> $_details['controller'], 'action'=>'index'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'))."</li>\n";

View file

@ -49,16 +49,16 @@ echo "\n";
echo "\t<tr{$class}>\n";
foreach ($scaffoldFields as $_field) {
$isKey = false;
if(!empty($associations['belongsTo'])) {
if (!empty($associations['belongsTo'])) {
foreach ($associations['belongsTo'] as $_alias => $_details) {
if($_field === $_details['foreignKey']) {
if ($_field === $_details['foreignKey']) {
$isKey = true;
echo "\t\t<td>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller'=> $_details['controller'], 'action'=>'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t</td>\n";
break;
}
}
}
if($isKey !== true) {
if ($isKey !== true) {
echo "\t\t<td>\n\t\t\t" . ${$singularVar}[$modelClass][$_field] . " \n\t\t</td>\n";
}
}
@ -86,7 +86,7 @@ echo "\n";
<?php
$done = array();
foreach ($associations as $_type => $_data) {
foreach($_data as $_alias => $_details) {
foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller'=> $_details['controller'], 'action'=>'index'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'))."</li>\n";

View file

@ -35,9 +35,9 @@ foreach ($scaffoldFields as $_field) {
$class = ' class="altrow"';
}
$isKey = false;
if(!empty($associations['belongsTo'])) {
if (!empty($associations['belongsTo'])) {
foreach ($associations['belongsTo'] as $_alias => $_details) {
if($_field === $_details['foreignKey']) {
if ($_field === $_details['foreignKey']) {
$isKey = true;
echo "\t\t<dt{$class}>".Inflector::humanize($_alias)."</dt>\n";
echo "\t\t<dd{$class}>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller'=> $_details['controller'], 'action'=>'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t&nbsp;</dd>\n";
@ -45,7 +45,7 @@ foreach ($scaffoldFields as $_field) {
}
}
}
if($isKey !== true) {
if ($isKey !== true) {
echo "\t\t<dt{$class}>".Inflector::humanize($_field)."</dt>\n";
echo "\t\t<dd{$class}>\n\t\t\t{${$singularVar}[$modelClass][$_field]}\n&nbsp;\t\t</dd>\n";
}
@ -63,7 +63,7 @@ foreach ($scaffoldFields as $_field) {
$done = array();
foreach ($associations as $_type => $_data) {
foreach($_data as $_alias => $_details) {
foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller'=> $_details['controller'], 'action'=>'index'))."</li>\n";
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'))."</li>\n";
@ -75,7 +75,7 @@ foreach ($scaffoldFields as $_field) {
</ul>
</div>
<?php
if(!empty($associations['hasOne'])) :
if (!empty($associations['hasOne'])) :
foreach ($associations['hasOne'] as $_alias => $_details): ?>
<div class="related">
<h3><?php echo sprintf(__("Related %s", true), Inflector::humanize($_details['controller']));?></h3>
@ -105,10 +105,10 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?>
endforeach;
endif;
if(empty($associations['hasMany'])) {
if (empty($associations['hasMany'])) {
$associations['hasMany'] = array();
}
if(empty($associations['hasAndBelongsToMany'])) {
if (empty($associations['hasAndBelongsToMany'])) {
$associations['hasAndBelongsToMany'] = array();
}
$relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']);

View file

@ -89,7 +89,7 @@ class ThemeView extends View {
$paths = array_merge($themePaths, $paths);
}
if(empty($this->__paths)) {
if (empty($this->__paths)) {
$this->__paths = $paths;
}

View file

@ -406,7 +406,7 @@ class View extends Object {
* @return mixed Rendered output, or false on error
*/
function renderLayout($content_for_layout, $layout = null) {
$layout_fn = $this->_getLayoutFileName($layout);
$layoutFileName = $this->_getLayoutFileName($layout);
$debug = '';
if (isset($this->viewVars['cakeDebug']) && Configure::read() > 2) {
@ -447,15 +447,15 @@ class View extends Object {
}
}
if (substr($layout_fn, -3) === 'ctp' || substr($layout_fn, -5) === 'thtml') {
$this->output = View::_render($layout_fn, $data_for_layout, $loadHelpers, true);
if (substr($layoutFileName, -3) === 'ctp' || substr($layoutFileName, -5) === 'thtml') {
$this->output = View::_render($layoutFileName, $data_for_layout, $loadHelpers, true);
} else {
$this->output = $this->_render($layout_fn, $data_for_layout, $loadHelpers);
$this->output = $this->_render($layoutFileName, $data_for_layout, $loadHelpers);
}
if ($this->output === false) {
$this->output = $this->_render($layout_fn, $data_for_layout);
trigger_error(sprintf(__("Error in layout %s, got: <blockquote>%s</blockquote>", true), $layout_fn, $this->output), E_USER_ERROR);
$this->output = $this->_render($layoutFileName, $data_for_layout);
trigger_error(sprintf(__("Error in layout %s, got: <blockquote>%s</blockquote>", true), $layoutFileName, $this->output), E_USER_ERROR);
return false;
}

View file

@ -110,7 +110,7 @@ class XmlNode extends Object {
if (is_array($value) || is_object($value)) {
$this->normalize($value);
} elseif(!empty($value) || $value === 0 || $value === '0') {
} elseif (!empty($value) || $value === 0 || $value === '0') {
$this->createTextNode($value);
}
}
@ -876,7 +876,7 @@ class Xml extends XmlNode {
for ($i = 0; $i < $count; $i++) {
$data = $vals[$i];
$data = array_merge(array('tag' => null, 'value' => null, 'attributes' => array()), $data);
switch($data['type']) {
switch ($data['type']) {
case "open" :
$xml =& $xml->createElement($data['tag'], $data['value'], $data['attributes']);
break;