mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
coding standards and simplification of else cases as well as some minor fixes
This commit is contained in:
parent
58149f2315
commit
7cb19b97db
31 changed files with 142 additions and 169 deletions
|
@ -123,8 +123,7 @@ class BakeShell extends AppShell {
|
||||||
$this->Test->execute();
|
$this->Test->execute();
|
||||||
break;
|
break;
|
||||||
case 'Q':
|
case 'Q':
|
||||||
exit(0);
|
return $this->_stop();
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
$this->out(__d('cake_console', 'You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.'));
|
$this->out(__d('cake_console', 'You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ class ConsoleShell extends AppShell {
|
||||||
switch ($command) {
|
switch ($command) {
|
||||||
case 'help':
|
case 'help':
|
||||||
$this->help();
|
$this->help();
|
||||||
break;
|
break;
|
||||||
case 'quit':
|
case 'quit':
|
||||||
case 'exit':
|
case 'exit':
|
||||||
return true;
|
return true;
|
||||||
|
@ -182,7 +182,7 @@ class ConsoleShell extends AppShell {
|
||||||
foreach ($this->models as $model) {
|
foreach ($this->models as $model) {
|
||||||
$this->out(" - {$model}");
|
$this->out(" - {$model}");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp):
|
case preg_match("/^(\w+) bind (\w+) (\w+)/", $command, $tmp):
|
||||||
foreach ($tmp as $data) {
|
foreach ($tmp as $data) {
|
||||||
$data = strip_tags($data);
|
$data = strip_tags($data);
|
||||||
|
@ -200,7 +200,7 @@ class ConsoleShell extends AppShell {
|
||||||
} else {
|
} else {
|
||||||
$this->out(__d('cake_console', "Please verify you are using valid models and association types"));
|
$this->out(__d('cake_console', "Please verify you are using valid models and association types"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp):
|
case preg_match("/^(\w+) unbind (\w+) (\w+)/", $command, $tmp):
|
||||||
foreach ($tmp as $data) {
|
foreach ($tmp as $data) {
|
||||||
$data = strip_tags($data);
|
$data = strip_tags($data);
|
||||||
|
@ -228,7 +228,7 @@ class ConsoleShell extends AppShell {
|
||||||
} else {
|
} else {
|
||||||
$this->out(__d('cake_console', "Please verify you are using valid models, valid current association, and valid association types"));
|
$this->out(__d('cake_console', "Please verify you are using valid models, valid current association, and valid association types"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case (strpos($command, "->find") > 0):
|
case (strpos($command, "->find") > 0):
|
||||||
// Remove any bad info
|
// Remove any bad info
|
||||||
$command = strip_tags($command);
|
$command = strip_tags($command);
|
||||||
|
@ -285,7 +285,7 @@ class ConsoleShell extends AppShell {
|
||||||
$this->out(__d('cake_console', "%s is not a valid model", $modelToCheck));
|
$this->out(__d('cake_console', "%s is not a valid model", $modelToCheck));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case (strpos($command, '->save') > 0):
|
case (strpos($command, '->save') > 0):
|
||||||
// Validate the model we're trying to save here
|
// Validate the model we're trying to save here
|
||||||
$command = strip_tags($command);
|
$command = strip_tags($command);
|
||||||
|
@ -302,7 +302,7 @@ class ConsoleShell extends AppShell {
|
||||||
//@codingStandardsIgnoreEnd
|
//@codingStandardsIgnoreEnd
|
||||||
$this->out(__d('cake_console', 'Saved record for %s', $modelToSave));
|
$this->out(__d('cake_console', 'Saved record for %s', $modelToSave));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case preg_match("/^(\w+) columns/", $command, $tmp):
|
case preg_match("/^(\w+) columns/", $command, $tmp):
|
||||||
$modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1]));
|
$modelToCheck = strip_tags(str_replace($this->badCommandChars, "", $tmp[1]));
|
||||||
|
|
||||||
|
@ -321,31 +321,30 @@ class ConsoleShell extends AppShell {
|
||||||
} else {
|
} else {
|
||||||
$this->out(__d('cake_console', "Please verify that you selected a valid model"));
|
$this->out(__d('cake_console', "Please verify that you selected a valid model"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case preg_match("/^routes\s+reload/i", $command, $tmp):
|
case preg_match("/^routes\s+reload/i", $command, $tmp):
|
||||||
if (!$this->_loadRoutes()) {
|
if (!$this->_loadRoutes()) {
|
||||||
$this->err(__d('cake_console', "There was an error loading the routes config. Please check that the file exists and is free of parse errors."));
|
$this->err(__d('cake_console', "There was an error loading the routes config. Please check that the file exists and is free of parse errors."));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count(Router::$routes)));
|
$this->out(__d('cake_console', "Routes configuration reloaded, %d routes connected", count(Router::$routes)));
|
||||||
break;
|
break;
|
||||||
case preg_match("/^routes\s+show/i", $command, $tmp):
|
case preg_match("/^routes\s+show/i", $command, $tmp):
|
||||||
$this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true));
|
$this->out(print_r(Hash::combine(Router::$routes, '{n}.template', '{n}.defaults'), true));
|
||||||
break;
|
break;
|
||||||
case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
|
case (preg_match("/^route\s+(\(.*\))$/i", $command, $tmp) == true):
|
||||||
//@codingStandardsIgnoreStart
|
//@codingStandardsIgnoreStart
|
||||||
if ($url = eval('return array' . $tmp[1] . ';')) {
|
if ($url = eval('return array' . $tmp[1] . ';')) {
|
||||||
//@codingStandardsIgnoreEnd
|
//@codingStandardsIgnoreEnd
|
||||||
$this->out(Router::url($url));
|
$this->out(Router::url($url));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case preg_match("/^route\s+(.*)/i", $command, $tmp):
|
case preg_match("/^route\s+(.*)/i", $command, $tmp):
|
||||||
$this->out(var_export(Router::parse($tmp[1]), true));
|
$this->out(var_export(Router::parse($tmp[1]), true));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->out(__d('cake_console', "Invalid command"));
|
$this->out(__d('cake_console', "Invalid command"));
|
||||||
$this->out();
|
$this->out();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
$command = '';
|
$command = '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,16 +76,15 @@ class I18nShell extends AppShell {
|
||||||
switch ($choice) {
|
switch ($choice) {
|
||||||
case 'e':
|
case 'e':
|
||||||
$this->Extract->execute();
|
$this->Extract->execute();
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
$this->initdb();
|
$this->initdb();
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
$this->out($this->OptionParser->help());
|
$this->out($this->OptionParser->help());
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
exit(0);
|
return $this->_stop();
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
$this->out(__d('cake_console', 'You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.'));
|
$this->out(__d('cake_console', 'You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,11 +107,10 @@ class SchemaShell extends AppShell {
|
||||||
if ($File->exists()) {
|
if ($File->exists()) {
|
||||||
$this->out($File->read());
|
$this->out($File->read());
|
||||||
return $this->_stop();
|
return $this->_stop();
|
||||||
} else {
|
|
||||||
$file = $this->Schema->path . DS . $this->params['file'];
|
|
||||||
$this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file));
|
|
||||||
return $this->_stop();
|
|
||||||
}
|
}
|
||||||
|
$file = $this->Schema->path . DS . $this->params['file'];
|
||||||
|
$this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file));
|
||||||
|
return $this->_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,10 +184,9 @@ class SchemaShell extends AppShell {
|
||||||
if ($this->Schema->write($content)) {
|
if ($this->Schema->write($content)) {
|
||||||
$this->out(__d('cake_console', 'Schema file: %s generated', $content['file']));
|
$this->out(__d('cake_console', 'Schema file: %s generated', $content['file']));
|
||||||
return $this->_stop();
|
return $this->_stop();
|
||||||
} else {
|
|
||||||
$this->err(__d('cake_console', 'Schema file: %s generated'));
|
|
||||||
return $this->_stop();
|
|
||||||
}
|
}
|
||||||
|
$this->err(__d('cake_console', 'Schema file: %s generated'));
|
||||||
|
return $this->_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -304,7 +304,7 @@ class FixtureTask extends BakeTask {
|
||||||
case 'integer':
|
case 'integer':
|
||||||
case 'float':
|
case 'float':
|
||||||
$insert = $i + 1;
|
$insert = $i + 1;
|
||||||
break;
|
break;
|
||||||
case 'string':
|
case 'string':
|
||||||
case 'binary':
|
case 'binary':
|
||||||
$isPrimaryUuid = (
|
$isPrimaryUuid = (
|
||||||
|
@ -319,22 +319,22 @@ class FixtureTask extends BakeTask {
|
||||||
$insert = substr($insert, 0, (int)$fieldInfo['length'] - 2);
|
$insert = substr($insert, 0, (int)$fieldInfo['length'] - 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'timestamp':
|
case 'timestamp':
|
||||||
$insert = time();
|
$insert = time();
|
||||||
break;
|
break;
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
$insert = date('Y-m-d H:i:s');
|
$insert = date('Y-m-d H:i:s');
|
||||||
break;
|
break;
|
||||||
case 'date':
|
case 'date':
|
||||||
$insert = date('Y-m-d');
|
$insert = date('Y-m-d');
|
||||||
break;
|
break;
|
||||||
case 'time':
|
case 'time':
|
||||||
$insert = date('H:i:s');
|
$insert = date('H:i:s');
|
||||||
break;
|
break;
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
$insert = 1;
|
$insert = 1;
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
$insert = "Lorem ipsum dolor sit amet, aliquet feugiat.";
|
$insert = "Lorem ipsum dolor sit amet, aliquet feugiat.";
|
||||||
$insert .= " Convallis morbi fringilla gravida,";
|
$insert .= " Convallis morbi fringilla gravida,";
|
||||||
|
@ -343,7 +343,7 @@ class FixtureTask extends BakeTask {
|
||||||
$insert .= " vestibulum massa neque ut et, id hendrerit sit,";
|
$insert .= " vestibulum massa neque ut et, id hendrerit sit,";
|
||||||
$insert .= " feugiat in taciti enim proin nibh, tempor dignissim, rhoncus";
|
$insert .= " feugiat in taciti enim proin nibh, tempor dignissim, rhoncus";
|
||||||
$insert .= " duis vestibulum nunc mattis convallis.";
|
$insert .= " duis vestibulum nunc mattis convallis.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$record[$field] = $insert;
|
$record[$field] = $insert;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,8 @@ class PluginTask extends AppShell {
|
||||||
$this->out(__d('cake_console', 'Plugin: %s already exists, no action taken', $plugin));
|
$this->out(__d('cake_console', 'Plugin: %s already exists, no action taken', $plugin));
|
||||||
$this->out(__d('cake_console', 'Path: %s', $pluginPath));
|
$this->out(__d('cake_console', 'Path: %s', $pluginPath));
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
$this->_interactive($plugin);
|
|
||||||
}
|
}
|
||||||
|
$this->_interactive($plugin);
|
||||||
} else {
|
} else {
|
||||||
return $this->_interactive();
|
return $this->_interactive();
|
||||||
}
|
}
|
||||||
|
|
|
@ -368,12 +368,9 @@ class ProjectTask extends AppShell {
|
||||||
if ($File->write($result)) {
|
if ($File->write($result)) {
|
||||||
Configure::write('Routing.prefixes', array($name));
|
Configure::write('Routing.prefixes', array($name));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -250,9 +250,8 @@ class Scaffold {
|
||||||
$success
|
$success
|
||||||
);
|
);
|
||||||
return $this->_sendMessage($message);
|
return $this->_sendMessage($message);
|
||||||
} else {
|
|
||||||
return $this->controller->afterScaffoldSaveError($action);
|
|
||||||
}
|
}
|
||||||
|
return $this->controller->afterScaffoldSaveError($action);
|
||||||
} else {
|
} else {
|
||||||
if ($this->_validSession) {
|
if ($this->_validSession) {
|
||||||
$this->controller->Session->setFlash(__d('cake', 'Please correct errors below.'));
|
$this->controller->Session->setFlash(__d('cake', 'Please correct errors below.'));
|
||||||
|
@ -309,14 +308,13 @@ class Scaffold {
|
||||||
if ($this->ScaffoldModel->delete()) {
|
if ($this->ScaffoldModel->delete()) {
|
||||||
$message = __d('cake', 'The %1$s with id: %2$s has been deleted.', Inflector::humanize($this->modelClass), $id);
|
$message = __d('cake', 'The %1$s with id: %2$s has been deleted.', Inflector::humanize($this->modelClass), $id);
|
||||||
return $this->_sendMessage($message);
|
return $this->_sendMessage($message);
|
||||||
} else {
|
|
||||||
$message = __d('cake',
|
|
||||||
'There was an error deleting the %1$s with id: %2$s',
|
|
||||||
Inflector::humanize($this->modelClass),
|
|
||||||
$id
|
|
||||||
);
|
|
||||||
return $this->_sendMessage($message);
|
|
||||||
}
|
}
|
||||||
|
$message = __d('cake',
|
||||||
|
'There was an error deleting the %1$s with id: %2$s',
|
||||||
|
Inflector::humanize($this->modelClass),
|
||||||
|
$id
|
||||||
|
);
|
||||||
|
return $this->_sendMessage($message);
|
||||||
} elseif ($this->controller->scaffoldError('delete') === false) {
|
} elseif ($this->controller->scaffoldError('delete') === false) {
|
||||||
return $this->_scaffoldError();
|
return $this->_scaffoldError();
|
||||||
}
|
}
|
||||||
|
@ -388,21 +386,21 @@ class Scaffold {
|
||||||
case 'index':
|
case 'index':
|
||||||
case 'list':
|
case 'list':
|
||||||
$this->_scaffoldIndex($request);
|
$this->_scaffoldIndex($request);
|
||||||
break;
|
break;
|
||||||
case 'view':
|
case 'view':
|
||||||
$this->_scaffoldView($request);
|
$this->_scaffoldView($request);
|
||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
case 'create':
|
case 'create':
|
||||||
$this->_scaffoldSave($request, 'add');
|
$this->_scaffoldSave($request, 'add');
|
||||||
break;
|
break;
|
||||||
case 'edit':
|
case 'edit':
|
||||||
case 'update':
|
case 'update':
|
||||||
$this->_scaffoldSave($request, 'edit');
|
$this->_scaffoldSave($request, 'edit');
|
||||||
break;
|
break;
|
||||||
case 'delete':
|
case 'delete':
|
||||||
$this->_scaffoldDelete($request);
|
$this->_scaffoldDelete($request);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new MissingActionException(array(
|
throw new MissingActionException(array(
|
||||||
|
|
|
@ -198,14 +198,13 @@ class ErrorHandler {
|
||||||
'path' => Debugger::trimPath($file)
|
'path' => Debugger::trimPath($file)
|
||||||
);
|
);
|
||||||
return Debugger::getInstance()->outputError($data);
|
return Debugger::getInstance()->outputError($data);
|
||||||
} else {
|
|
||||||
$message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
|
|
||||||
if (!empty($errorConfig['trace'])) {
|
|
||||||
$trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
|
|
||||||
$message .= "\nTrace:\n" . $trace . "\n";
|
|
||||||
}
|
|
||||||
return CakeLog::write($log, $message);
|
|
||||||
}
|
}
|
||||||
|
$message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
|
||||||
|
if (!empty($errorConfig['trace'])) {
|
||||||
|
$trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
|
||||||
|
$message .= "\nTrace:\n" . $trace . "\n";
|
||||||
|
}
|
||||||
|
return CakeLog::write($log, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,28 +253,28 @@ class ErrorHandler {
|
||||||
case E_USER_ERROR:
|
case E_USER_ERROR:
|
||||||
$error = 'Fatal Error';
|
$error = 'Fatal Error';
|
||||||
$log = LOG_ERR;
|
$log = LOG_ERR;
|
||||||
break;
|
break;
|
||||||
case E_WARNING:
|
case E_WARNING:
|
||||||
case E_USER_WARNING:
|
case E_USER_WARNING:
|
||||||
case E_COMPILE_WARNING:
|
case E_COMPILE_WARNING:
|
||||||
case E_RECOVERABLE_ERROR:
|
case E_RECOVERABLE_ERROR:
|
||||||
$error = 'Warning';
|
$error = 'Warning';
|
||||||
$log = LOG_WARNING;
|
$log = LOG_WARNING;
|
||||||
break;
|
break;
|
||||||
case E_NOTICE:
|
case E_NOTICE:
|
||||||
case E_USER_NOTICE:
|
case E_USER_NOTICE:
|
||||||
$error = 'Notice';
|
$error = 'Notice';
|
||||||
$log = LOG_NOTICE;
|
$log = LOG_NOTICE;
|
||||||
break;
|
break;
|
||||||
case E_STRICT:
|
case E_STRICT:
|
||||||
$error = 'Strict';
|
$error = 'Strict';
|
||||||
$log = LOG_NOTICE;
|
$log = LOG_NOTICE;
|
||||||
break;
|
break;
|
||||||
case E_DEPRECATED:
|
case E_DEPRECATED:
|
||||||
case E_USER_DEPRECATED:
|
case E_USER_DEPRECATED:
|
||||||
$error = 'Deprecated';
|
$error = 'Deprecated';
|
||||||
$log = LOG_NOTICE;
|
$log = LOG_NOTICE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return array($error, $log);
|
return array($error, $log);
|
||||||
}
|
}
|
||||||
|
|
|
@ -762,17 +762,16 @@ class TreeBehavior extends ModelBehavior {
|
||||||
array($Model->escapeField() => $id)
|
array($Model->escapeField() => $id)
|
||||||
);
|
);
|
||||||
return $Model->delete($id);
|
return $Model->delete($id);
|
||||||
} else {
|
|
||||||
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
|
||||||
if ($node[$right] == $edge) {
|
|
||||||
$edge = $edge - 2;
|
|
||||||
}
|
|
||||||
$Model->id = $id;
|
|
||||||
return $Model->save(
|
|
||||||
array($left => $edge + 1, $right => $edge + 2, $parent => null),
|
|
||||||
array('callbacks' => false, 'validate' => false)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
$edge = $this->_getMax($Model, $scope, $right, $recursive);
|
||||||
|
if ($node[$right] == $edge) {
|
||||||
|
$edge = $edge - 2;
|
||||||
|
}
|
||||||
|
$Model->id = $id;
|
||||||
|
return $Model->save(
|
||||||
|
array($left => $edge + 1, $right => $edge + 2, $parent => null),
|
||||||
|
array('callbacks' => false, 'validate' => false)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -357,7 +357,7 @@ class DataSource extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$type = $model->getColumnType($model->primaryKey);
|
$type = $model->getColumnType($model->primaryKey);
|
||||||
break;
|
break;
|
||||||
case '{$__cakeForeignKey__$}':
|
case '{$__cakeForeignKey__$}':
|
||||||
foreach ($model->associations() as $name) {
|
foreach ($model->associations() as $name) {
|
||||||
foreach ($model->$name as $assocName => $assoc) {
|
foreach ($model->$name as $assocName => $assoc) {
|
||||||
|
@ -389,7 +389,7 @@ class DataSource extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (empty($val) && $val !== '0') {
|
if (empty($val) && $val !== '0') {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -516,13 +516,13 @@ class Mysql extends DboSource {
|
||||||
}
|
}
|
||||||
$colList[] = $alter;
|
$colList[] = $alter;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'drop':
|
case 'drop':
|
||||||
foreach ($column as $field => $col) {
|
foreach ($column as $field => $col) {
|
||||||
$col['name'] = $field;
|
$col['name'] = $field;
|
||||||
$colList[] = 'DROP ' . $this->name($field);
|
$colList[] = 'DROP ' . $this->name($field);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'change':
|
case 'change':
|
||||||
foreach ($column as $field => $col) {
|
foreach ($column as $field => $col) {
|
||||||
if (!isset($col['name'])) {
|
if (!isset($col['name'])) {
|
||||||
|
@ -530,7 +530,7 @@ class Mysql extends DboSource {
|
||||||
}
|
}
|
||||||
$colList[] = 'CHANGE ' . $this->name($field) . ' ' . $this->buildColumn($col);
|
$colList[] = 'CHANGE ' . $this->name($field) . ' ' . $this->buildColumn($col);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes));
|
$colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes));
|
||||||
|
|
|
@ -516,13 +516,13 @@ class Postgres extends DboSource {
|
||||||
$col['name'] = $field;
|
$col['name'] = $field;
|
||||||
$colList[] = 'ADD COLUMN ' . $this->buildColumn($col);
|
$colList[] = 'ADD COLUMN ' . $this->buildColumn($col);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'drop':
|
case 'drop':
|
||||||
foreach ($column as $field => $col) {
|
foreach ($column as $field => $col) {
|
||||||
$col['name'] = $field;
|
$col['name'] = $field;
|
||||||
$colList[] = 'DROP COLUMN ' . $this->name($field);
|
$colList[] = 'DROP COLUMN ' . $this->name($field);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'change':
|
case 'change':
|
||||||
foreach ($column as $field => $col) {
|
foreach ($column as $field => $col) {
|
||||||
if (!isset($col['name'])) {
|
if (!isset($col['name'])) {
|
||||||
|
@ -552,7 +552,7 @@ class Postgres extends DboSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($indexes['drop']['PRIMARY'])) {
|
if (isset($indexes['drop']['PRIMARY'])) {
|
||||||
|
@ -748,21 +748,19 @@ class Postgres extends DboSource {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'bool':
|
case 'bool':
|
||||||
$resultRow[$table][$column] = is_null($row[$index]) ? null : $this->boolean($row[$index]);
|
$resultRow[$table][$column] = is_null($row[$index]) ? null : $this->boolean($row[$index]);
|
||||||
break;
|
break;
|
||||||
case 'binary':
|
case 'binary':
|
||||||
case 'bytea':
|
case 'bytea':
|
||||||
$resultRow[$table][$column] = is_null($row[$index]) ? null : stream_get_contents($row[$index]);
|
$resultRow[$table][$column] = is_null($row[$index]) ? null : stream_get_contents($row[$index]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$resultRow[$table][$column] = $row[$index];
|
$resultRow[$table][$column] = $row[$index];
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $resultRow;
|
return $resultRow;
|
||||||
} else {
|
|
||||||
$this->_result->closeCursor();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
$this->_result->closeCursor();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -788,7 +786,6 @@ class Postgres extends DboSource {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$result = (bool)$data;
|
$result = (bool)$data;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($quote) {
|
if ($quote) {
|
||||||
|
|
|
@ -1569,7 +1569,7 @@ class DboSource extends DataSource {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'hasMany':
|
case 'hasMany':
|
||||||
$assocData['fields'] = $this->fields($linkModel, $association, $assocData['fields']);
|
$assocData['fields'] = $this->fields($linkModel, $association, $assocData['fields']);
|
||||||
if (!empty($assocData['foreignKey'])) {
|
if (!empty($assocData['foreignKey'])) {
|
||||||
|
@ -1585,7 +1585,7 @@ class DboSource extends DataSource {
|
||||||
'offset' => $assocData['offset'],
|
'offset' => $assocData['offset'],
|
||||||
'group' => null
|
'group' => null
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'hasAndBelongsToMany':
|
case 'hasAndBelongsToMany':
|
||||||
$joinFields = array();
|
$joinFields = array();
|
||||||
$joinAssoc = null;
|
$joinAssoc = null;
|
||||||
|
@ -1622,7 +1622,7 @@ class DboSource extends DataSource {
|
||||||
'conditions' => $this->getConstraint('hasAndBelongsToMany', $model, $linkModel, $joinAlias, $assocData, $association)
|
'conditions' => $this->getConstraint('hasAndBelongsToMany', $model, $linkModel, $joinAlias, $assocData, $association)
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isset($query)) {
|
if (isset($query)) {
|
||||||
return $this->buildStatement($query, $model);
|
return $this->buildStatement($query, $model);
|
||||||
|
@ -2596,22 +2596,22 @@ class DboSource extends DataSource {
|
||||||
switch ($operator) {
|
switch ($operator) {
|
||||||
case '=':
|
case '=':
|
||||||
$operator = 'IN';
|
$operator = 'IN';
|
||||||
break;
|
break;
|
||||||
case '!=':
|
case '!=':
|
||||||
case '<>':
|
case '<>':
|
||||||
$operator = 'NOT IN';
|
$operator = 'NOT IN';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$value = "({$value})";
|
$value = "({$value})";
|
||||||
} elseif ($null || $value === 'NULL') {
|
} elseif ($null || $value === 'NULL') {
|
||||||
switch ($operator) {
|
switch ($operator) {
|
||||||
case '=':
|
case '=':
|
||||||
$operator = 'IS';
|
$operator = 'IS';
|
||||||
break;
|
break;
|
||||||
case '!=':
|
case '!=':
|
||||||
case '<>':
|
case '<>':
|
||||||
$operator = 'IS NOT';
|
$operator = 'IS NOT';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($virtual) {
|
if ($virtual) {
|
||||||
|
|
|
@ -1058,34 +1058,34 @@ class Model extends Object implements CakeEventListener {
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'fields':
|
case 'fields':
|
||||||
$data = '';
|
$data = '';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'foreignKey':
|
case 'foreignKey':
|
||||||
$data = (($type === 'belongsTo') ? Inflector::underscore($assocKey) : Inflector::singularize($this->table)) . '_id';
|
$data = (($type === 'belongsTo') ? Inflector::underscore($assocKey) : Inflector::singularize($this->table)) . '_id';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'associationForeignKey':
|
case 'associationForeignKey':
|
||||||
$data = Inflector::singularize($this->{$class}->table) . '_id';
|
$data = Inflector::singularize($this->{$class}->table) . '_id';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'with':
|
case 'with':
|
||||||
$data = Inflector::camelize(Inflector::singularize($this->{$type}[$assocKey]['joinTable']));
|
$data = Inflector::camelize(Inflector::singularize($this->{$type}[$assocKey]['joinTable']));
|
||||||
$dynamicWith = true;
|
$dynamicWith = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'joinTable':
|
case 'joinTable':
|
||||||
$tables = array($this->table, $this->{$class}->table);
|
$tables = array($this->table, $this->{$class}->table);
|
||||||
sort($tables);
|
sort($tables);
|
||||||
$data = $tables[0] . '_' . $tables[1];
|
$data = $tables[0] . '_' . $tables[1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'className':
|
case 'className':
|
||||||
$data = $class;
|
$data = $class;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'unique':
|
case 'unique':
|
||||||
$data = true;
|
$data = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->{$type}[$assocKey][$key] = $data;
|
$this->{$type}[$assocKey][$key] = $data;
|
||||||
}
|
}
|
||||||
|
@ -2281,7 +2281,7 @@ class Model extends Object implements CakeEventListener {
|
||||||
$validationErrors[$association] = $this->{$association}->validationErrors;
|
$validationErrors[$association] = $this->{$association}->validationErrors;
|
||||||
}
|
}
|
||||||
$return[$association] = $validates;
|
$return[$association] = $validates;
|
||||||
break;
|
break;
|
||||||
case 'hasMany':
|
case 'hasMany':
|
||||||
foreach ($values as $i => $value) {
|
foreach ($values as $i => $value) {
|
||||||
if (isset($values[$i][$association])) {
|
if (isset($values[$i][$association])) {
|
||||||
|
@ -2297,7 +2297,7 @@ class Model extends Object implements CakeEventListener {
|
||||||
$validates = false;
|
$validates = false;
|
||||||
}
|
}
|
||||||
$return[$association] = $_return;
|
$return[$association] = $_return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,15 +142,15 @@ class TestBehavior extends ModelBehavior {
|
||||||
switch ($settings['afterSave']) {
|
switch ($settings['afterSave']) {
|
||||||
case 'on':
|
case 'on':
|
||||||
$model->data[$model->alias]['aftersave'] = $string;
|
$model->data[$model->alias]['aftersave'] = $string;
|
||||||
break;
|
break;
|
||||||
case 'test':
|
case 'test':
|
||||||
unset($model->data[$model->alias]['name']);
|
unset($model->data[$model->alias]['name']);
|
||||||
break;
|
break;
|
||||||
case 'test2':
|
case 'test2':
|
||||||
return false;
|
return false;
|
||||||
case 'modify':
|
case 'modify':
|
||||||
$model->data[$model->alias]['name'] .= ' ' . $string;
|
$model->data[$model->alias]['name'] .= ' ' . $string;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ class TestBehavior extends ModelBehavior {
|
||||||
switch ($settings['afterDelete']) {
|
switch ($settings['afterDelete']) {
|
||||||
case 'on':
|
case 'on':
|
||||||
echo 'afterDelete success';
|
echo 'afterDelete success';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,9 @@ class CakeTestModel extends Model {
|
||||||
case
|
case
|
||||||
(is_string($queryData['fields']) && !($queryData['fields'] == $pk || $queryData['fields'] == $aliasedPk)) ||
|
(is_string($queryData['fields']) && !($queryData['fields'] == $pk || $queryData['fields'] == $aliasedPk)) ||
|
||||||
(is_array($queryData['fields']) && !(array_key_exists($pk, $queryData['fields']) || array_key_exists($aliasedPk, $queryData['fields']))):
|
(is_array($queryData['fields']) && !(array_key_exists($pk, $queryData['fields']) || array_key_exists($aliasedPk, $queryData['fields']))):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$queryData['order'] = array($this->alias . '.' . $this->primaryKey => 'ASC');
|
$queryData['order'] = array($this->alias . '.' . $this->primaryKey => 'ASC');
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return $queryData;
|
return $queryData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,14 +97,13 @@ class CakeTime {
|
||||||
*
|
*
|
||||||
* @param string $name Variable name
|
* @param string $name Variable name
|
||||||
* @param mixes $value Variable value
|
* @param mixes $value Variable value
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __set($name, $value) {
|
public function __set($name, $value) {
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
case 'niceFormat':
|
case 'niceFormat':
|
||||||
self::${$name} = $value;
|
self::${$name} = $value;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,24 +230,24 @@ class Debugger {
|
||||||
case E_USER_ERROR:
|
case E_USER_ERROR:
|
||||||
$error = 'Fatal Error';
|
$error = 'Fatal Error';
|
||||||
$level = LOG_ERR;
|
$level = LOG_ERR;
|
||||||
break;
|
break;
|
||||||
case E_WARNING:
|
case E_WARNING:
|
||||||
case E_USER_WARNING:
|
case E_USER_WARNING:
|
||||||
case E_COMPILE_WARNING:
|
case E_COMPILE_WARNING:
|
||||||
case E_RECOVERABLE_ERROR:
|
case E_RECOVERABLE_ERROR:
|
||||||
$error = 'Warning';
|
$error = 'Warning';
|
||||||
$level = LOG_WARNING;
|
$level = LOG_WARNING;
|
||||||
break;
|
break;
|
||||||
case E_NOTICE:
|
case E_NOTICE:
|
||||||
case E_USER_NOTICE:
|
case E_USER_NOTICE:
|
||||||
$error = 'Notice';
|
$error = 'Notice';
|
||||||
$level = LOG_NOTICE;
|
$level = LOG_NOTICE;
|
||||||
break;
|
break;
|
||||||
case E_DEPRECATED:
|
case E_DEPRECATED:
|
||||||
case E_USER_DEPRECATED:
|
case E_USER_DEPRECATED:
|
||||||
$error = 'Deprecated';
|
$error = 'Deprecated';
|
||||||
$level = LOG_NOTICE;
|
$level = LOG_NOTICE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,7 @@ class Inflector {
|
||||||
} else {
|
} else {
|
||||||
self::$_transliteration = $rules + self::$_transliteration;
|
self::$_transliteration = $rules + self::$_transliteration;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
foreach ($rules as $rule => $pattern) {
|
foreach ($rules as $rule => $pattern) {
|
||||||
|
@ -334,7 +334,6 @@ class Inflector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self::${$var}['rules'] = $rules + self::${$var}['rules'];
|
self::${$var}['rules'] = $rules + self::${$var}['rules'];
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,6 @@ class Validation {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for Validation::comparison()');
|
self::$errors[] = __d('cake_dev', 'You must define the $operator parameter for Validation::comparison()');
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -662,18 +662,16 @@ class Helper extends Object {
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case '_method':
|
case '_method':
|
||||||
$name = $field;
|
$name = $field;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$name = 'data[' . implode('][', $this->entity()) . ']';
|
$name = 'data[' . implode('][', $this->entity()) . ']';
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($options)) {
|
if (is_array($options)) {
|
||||||
$options[$key] = $name;
|
$options[$key] = $name;
|
||||||
return $options;
|
return $options;
|
||||||
} else {
|
|
||||||
return $name;
|
|
||||||
}
|
}
|
||||||
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -729,9 +727,8 @@ class Helper extends Object {
|
||||||
if (is_array($options)) {
|
if (is_array($options)) {
|
||||||
$options[$key] = $result;
|
$options[$key] = $result;
|
||||||
return $options;
|
return $options;
|
||||||
} else {
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -920,7 +917,7 @@ class Helper extends Object {
|
||||||
do {
|
do {
|
||||||
$oldstring = $this->_cleaned;
|
$oldstring = $this->_cleaned;
|
||||||
$this->_cleaned = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->_cleaned);
|
$this->_cleaned = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->_cleaned);
|
||||||
} while ($oldstring != $this->_cleaned);
|
} while ($oldstring !== $this->_cleaned);
|
||||||
$this->_cleaned = str_replace(array("&", "<", ">"), array("&amp;", "&lt;", "&gt;"), $this->_cleaned);
|
$this->_cleaned = str_replace(array("&", "<", ">"), array("&amp;", "&lt;", "&gt;"), $this->_cleaned);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -407,7 +407,7 @@ class FormHelper extends AppHelper {
|
||||||
switch (strtolower($options['type'])) {
|
switch (strtolower($options['type'])) {
|
||||||
case 'get':
|
case 'get':
|
||||||
$htmlAttributes['method'] = 'get';
|
$htmlAttributes['method'] = 'get';
|
||||||
break;
|
break;
|
||||||
case 'file':
|
case 'file':
|
||||||
$htmlAttributes['enctype'] = 'multipart/form-data';
|
$htmlAttributes['enctype'] = 'multipart/form-data';
|
||||||
$options['type'] = ($created) ? 'put' : 'post';
|
$options['type'] = ($created) ? 'put' : 'post';
|
||||||
|
@ -420,7 +420,6 @@ class FormHelper extends AppHelper {
|
||||||
));
|
));
|
||||||
default:
|
default:
|
||||||
$htmlAttributes['method'] = 'post';
|
$htmlAttributes['method'] = 'post';
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
$this->requestType = strtolower($options['type']);
|
$this->requestType = strtolower($options['type']);
|
||||||
|
|
||||||
|
@ -2456,16 +2455,16 @@ class FormHelper extends AppHelper {
|
||||||
$selects[] = $this->year(
|
$selects[] = $this->year(
|
||||||
$fieldName, $minYear, $maxYear, $attrs['Year']
|
$fieldName, $minYear, $maxYear, $attrs['Year']
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
$attrs['Month']['value'] = $month;
|
$attrs['Month']['value'] = $month;
|
||||||
$attrs['Month']['monthNames'] = $monthNames;
|
$attrs['Month']['monthNames'] = $monthNames;
|
||||||
$selects[] = $this->month($fieldName, $attrs['Month']);
|
$selects[] = $this->month($fieldName, $attrs['Month']);
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
$attrs['Day']['value'] = $day;
|
$attrs['Day']['value'] = $day;
|
||||||
$selects[] = $this->day($fieldName, $attrs['Day']);
|
$selects[] = $this->day($fieldName, $attrs['Day']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$opt = implode($separator, $selects);
|
$opt = implode($separator, $selects);
|
||||||
|
@ -2477,7 +2476,7 @@ class FormHelper extends AppHelper {
|
||||||
$attrs['Minute']['value'] = $min;
|
$attrs['Minute']['value'] = $min;
|
||||||
$opt .= $this->hour($fieldName, true, $attrs['Hour']) . ':' .
|
$opt .= $this->hour($fieldName, true, $attrs['Hour']) . ':' .
|
||||||
$this->minute($fieldName, $attrs['Minute']);
|
$this->minute($fieldName, $attrs['Minute']);
|
||||||
break;
|
break;
|
||||||
case '12':
|
case '12':
|
||||||
$attrs['Hour']['value'] = $hour;
|
$attrs['Hour']['value'] = $hour;
|
||||||
$attrs['Minute']['value'] = $min;
|
$attrs['Minute']['value'] = $min;
|
||||||
|
@ -2485,7 +2484,7 @@ class FormHelper extends AppHelper {
|
||||||
$opt .= $this->hour($fieldName, false, $attrs['Hour']) . ':' .
|
$opt .= $this->hour($fieldName, false, $attrs['Hour']) . ':' .
|
||||||
$this->minute($fieldName, $attrs['Minute']) . ' ' .
|
$this->minute($fieldName, $attrs['Minute']) . ' ' .
|
||||||
$this->meridian($fieldName, $attrs['Meridian']);
|
$this->meridian($fieldName, $attrs['Meridian']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $opt;
|
return $opt;
|
||||||
}
|
}
|
||||||
|
@ -2719,20 +2718,20 @@ class FormHelper extends AppHelper {
|
||||||
$data[sprintf('%02d', $i)] = sprintf('%02d', $i);
|
$data[sprintf('%02d', $i)] = sprintf('%02d', $i);
|
||||||
$i += $interval;
|
$i += $interval;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'hour':
|
case 'hour':
|
||||||
for ($i = 1; $i <= 12; $i++) {
|
for ($i = 1; $i <= 12; $i++) {
|
||||||
$data[sprintf('%02d', $i)] = $i;
|
$data[sprintf('%02d', $i)] = $i;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'hour24':
|
case 'hour24':
|
||||||
for ($i = 0; $i <= 23; $i++) {
|
for ($i = 0; $i <= 23; $i++) {
|
||||||
$data[sprintf('%02d', $i)] = $i;
|
$data[sprintf('%02d', $i)] = $i;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'meridian':
|
case 'meridian':
|
||||||
$data = array('am' => 'am', 'pm' => 'pm');
|
$data = array('am' => 'am', 'pm' => 'pm');
|
||||||
break;
|
break;
|
||||||
case 'day':
|
case 'day':
|
||||||
$min = 1;
|
$min = 1;
|
||||||
$max = 31;
|
$max = 31;
|
||||||
|
@ -2747,7 +2746,7 @@ class FormHelper extends AppHelper {
|
||||||
for ($i = $min; $i <= $max; $i++) {
|
for ($i = $min; $i <= $max; $i++) {
|
||||||
$data[sprintf('%02d', $i)] = $i;
|
$data[sprintf('%02d', $i)] = $i;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'month':
|
case 'month':
|
||||||
if ($options['monthNames'] === true) {
|
if ($options['monthNames'] === true) {
|
||||||
$data['01'] = __d('cake', 'January');
|
$data['01'] = __d('cake', 'January');
|
||||||
|
@ -2769,7 +2768,7 @@ class FormHelper extends AppHelper {
|
||||||
$data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999));
|
$data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'year':
|
case 'year':
|
||||||
$current = intval(date('Y'));
|
$current = intval(date('Y'));
|
||||||
|
|
||||||
|
@ -2791,7 +2790,7 @@ class FormHelper extends AppHelper {
|
||||||
if ($options['order'] !== 'asc') {
|
if ($options['order'] !== 'asc') {
|
||||||
$data = array_reverse($data, true);
|
$data = array_reverse($data, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->_options[$name] = $data;
|
$this->_options[$name] = $data;
|
||||||
return $this->_options[$name];
|
return $this->_options[$name];
|
||||||
|
|
|
@ -235,7 +235,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
|
||||||
case 'slideDown':
|
case 'slideDown':
|
||||||
case 'slideUp':
|
case 'slideUp':
|
||||||
$effect = ".$name($speed);";
|
$effect = ".$name($speed);";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $this->selection . $effect;
|
return $this->selection . $effect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,25 +147,24 @@ abstract class JsBaseEngineHelper extends AppHelper {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case (is_array($val) || is_object($val)):
|
case (is_array($val) || is_object($val)):
|
||||||
$val = $this->object($val);
|
$val = $this->object($val);
|
||||||
break;
|
break;
|
||||||
case ($val === null):
|
case ($val === null):
|
||||||
$val = 'null';
|
$val = 'null';
|
||||||
break;
|
break;
|
||||||
case (is_bool($val)):
|
case (is_bool($val)):
|
||||||
$val = ($val === true) ? 'true' : 'false';
|
$val = ($val === true) ? 'true' : 'false';
|
||||||
break;
|
break;
|
||||||
case (is_int($val)):
|
case (is_int($val)):
|
||||||
$val = $val;
|
$val = $val;
|
||||||
break;
|
break;
|
||||||
case (is_float($val)):
|
case (is_float($val)):
|
||||||
$val = sprintf("%.11f", $val);
|
$val = sprintf("%.11f", $val);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$val = $this->escape($val);
|
$val = $this->escape($val);
|
||||||
if ($quoteString) {
|
if ($quoteString) {
|
||||||
$val = '"' . $val . '"';
|
$val = '"' . $val . '"';
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,10 +205,10 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
case 'hide':
|
case 'hide':
|
||||||
$effect = 'setStyle("display", "none")';
|
$effect = 'setStyle("display", "none")';
|
||||||
break;
|
break;
|
||||||
case 'show':
|
case 'show':
|
||||||
$effect = 'setStyle("display", "")';
|
$effect = 'setStyle("display", "")';
|
||||||
break;
|
break;
|
||||||
case 'fadeIn':
|
case 'fadeIn':
|
||||||
case 'fadeOut':
|
case 'fadeOut':
|
||||||
case 'slideIn':
|
case 'slideIn':
|
||||||
|
@ -219,7 +219,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper {
|
||||||
$effect .= "set(\"$effectName\", {duration:$speed}).";
|
$effect .= "set(\"$effectName\", {duration:$speed}).";
|
||||||
}
|
}
|
||||||
$effect .= "$effectName(\"$direction\")";
|
$effect .= "$effectName(\"$direction\")";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $this->selection . '.' . $effect . ';';
|
return $this->selection . '.' . $effect . ';';
|
||||||
}
|
}
|
||||||
|
|
|
@ -628,10 +628,10 @@ class PaginatorHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
$out = $start . $options['separator'][0] . $end . $options['separator'][1];
|
$out = $start . $options['separator'][0] . $end . $options['separator'][1];
|
||||||
$out .= $paging['count'];
|
$out .= $paging['count'];
|
||||||
break;
|
break;
|
||||||
case 'pages':
|
case 'pages':
|
||||||
$out = $paging['page'] . $options['separator'] . $paging['pageCount'];
|
$out = $paging['page'] . $options['separator'] . $paging['pageCount'];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$map = array(
|
$map = array(
|
||||||
'%page%' => $paging['page'],
|
'%page%' => $paging['page'],
|
||||||
|
@ -648,7 +648,6 @@ class PaginatorHelper extends AppHelper {
|
||||||
'{:page}', '{:pages}', '{:current}', '{:count}', '{:start}', '{:end}', '{:model}'
|
'{:page}', '{:pages}', '{:current}', '{:count}', '{:start}', '{:end}', '{:model}'
|
||||||
);
|
);
|
||||||
$out = str_replace($newKeys, array_values($map), $out);
|
$out = str_replace($newKeys, array_values($map), $out);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,17 +212,17 @@ class PrototypeEngineHelper extends JsBaseEngineHelper {
|
||||||
case 'hide':
|
case 'hide':
|
||||||
case 'show':
|
case 'show':
|
||||||
$effect = $this->selection . '.' . $name . '();';
|
$effect = $this->selection . '.' . $name . '();';
|
||||||
break;
|
break;
|
||||||
case 'slideIn':
|
case 'slideIn':
|
||||||
case 'slideOut':
|
case 'slideOut':
|
||||||
$name = ($name === 'slideIn') ? 'slideDown' : 'slideUp';
|
$name = ($name === 'slideIn') ? 'slideDown' : 'slideUp';
|
||||||
$effect = 'Effect.' . $name . '(' . $this->selection . $optionString . ');';
|
$effect = 'Effect.' . $name . '(' . $this->selection . $optionString . ');';
|
||||||
break;
|
break;
|
||||||
case 'fadeIn':
|
case 'fadeIn':
|
||||||
case 'fadeOut':
|
case 'fadeOut':
|
||||||
$name = ($name === 'fadeIn') ? 'appear' : 'fade';
|
$name = ($name === 'fadeIn') ? 'appear' : 'fade';
|
||||||
$effect = $this->selection . '.' . $name . '(' . substr($optionString, 2) . ');';
|
$effect = $this->selection . '.' . $name . '(' . substr($optionString, 2) . ');';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $effect;
|
return $effect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,7 +208,7 @@ class RssHelper extends AppHelper {
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'pubDate' :
|
case 'pubDate' :
|
||||||
$val = $this->time($val);
|
$val = $this->time($val);
|
||||||
break;
|
break;
|
||||||
case 'category' :
|
case 'category' :
|
||||||
if (is_array($val) && !empty($val[0])) {
|
if (is_array($val) && !empty($val[0])) {
|
||||||
foreach ($val as $category) {
|
foreach ($val as $category) {
|
||||||
|
@ -224,7 +224,7 @@ class RssHelper extends AppHelper {
|
||||||
} elseif (is_array($val) && isset($val['domain'])) {
|
} elseif (is_array($val) && isset($val['domain'])) {
|
||||||
$attrib['domain'] = $val['domain'];
|
$attrib['domain'] = $val['domain'];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'link':
|
case 'link':
|
||||||
case 'guid':
|
case 'guid':
|
||||||
case 'comments':
|
case 'comments':
|
||||||
|
@ -234,7 +234,7 @@ class RssHelper extends AppHelper {
|
||||||
$val = $val['url'];
|
$val = $val['url'];
|
||||||
}
|
}
|
||||||
$val = $this->url($val, true);
|
$val = $this->url($val, true);
|
||||||
break;
|
break;
|
||||||
case 'source':
|
case 'source':
|
||||||
if (is_array($val) && isset($val['url'])) {
|
if (is_array($val) && isset($val['url'])) {
|
||||||
$attrib['url'] = $this->url($val['url'], true);
|
$attrib['url'] = $this->url($val['url'], true);
|
||||||
|
@ -243,7 +243,7 @@ class RssHelper extends AppHelper {
|
||||||
$attrib['url'] = $this->url($val[0], true);
|
$attrib['url'] = $this->url($val[0], true);
|
||||||
$val = $val[1];
|
$val = $val[1];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'enclosure':
|
case 'enclosure':
|
||||||
if (is_string($val['url']) && is_file(WWW_ROOT . $val['url']) && file_exists(WWW_ROOT . $val['url'])) {
|
if (is_string($val['url']) && is_file(WWW_ROOT . $val['url']) && file_exists(WWW_ROOT . $val['url'])) {
|
||||||
if (!isset($val['length']) && strpos($val['url'], '://') === false) {
|
if (!isset($val['length']) && strpos($val['url'], '://') === false) {
|
||||||
|
@ -256,7 +256,7 @@ class RssHelper extends AppHelper {
|
||||||
$val['url'] = $this->url($val['url'], true);
|
$val['url'] = $this->url($val['url'], true);
|
||||||
$attrib = $val;
|
$attrib = $val;
|
||||||
$val = null;
|
$val = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$attrib = $att;
|
$attrib = $att;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,10 +75,9 @@ class TimeHelper extends AppHelper {
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
case 'niceFormat':
|
case 'niceFormat':
|
||||||
$this->_engine->{$name} = $value;
|
$this->_engine->{$name} = $value;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->{$name} = $value;
|
$this->{$name} = $value;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -402,13 +402,13 @@ if (!function_exists('cache')) {
|
||||||
switch (strtolower($target)) {
|
switch (strtolower($target)) {
|
||||||
case 'cache':
|
case 'cache':
|
||||||
$filename = CACHE . $path;
|
$filename = CACHE . $path;
|
||||||
break;
|
break;
|
||||||
case 'public':
|
case 'public':
|
||||||
$filename = WWW_ROOT . $path;
|
$filename = WWW_ROOT . $path;
|
||||||
break;
|
break;
|
||||||
case 'tmp':
|
case 'tmp':
|
||||||
$filename = TMP . $path;
|
$filename = TMP . $path;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$timediff = $expires - $now;
|
$timediff = $expires - $now;
|
||||||
$filetime = false;
|
$filetime = false;
|
||||||
|
|
Loading…
Reference in a new issue