mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Correcting code structure to standards
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5313 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a9c0b7e406
commit
23dfd90b29
102 changed files with 1401 additions and 1401 deletions
|
@ -33,7 +33,7 @@
|
|||
$file = $_GET['file'];
|
||||
$pos = strpos($file, '..');
|
||||
if ($pos === false) {
|
||||
if(is_file('../../vendors/javascript/'.$file) && (preg_match('/(\/.+)\\.js/', $file)))
|
||||
if (is_file('../../vendors/javascript/'.$file) && (preg_match('/(\/.+)\\.js/', $file)))
|
||||
{
|
||||
readfile('../../vendors/javascript/'.$file);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ require_once CORE_PATH . 'cake' . DS . 'bootstrap.php';
|
|||
require_once CAKE . 'basics.php';
|
||||
require_once CAKE . 'config' . DS . 'paths.php';
|
||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php';
|
||||
if(DEBUG < 1) {
|
||||
if (DEBUG < 1) {
|
||||
die('Invalid url.');
|
||||
}
|
||||
|
||||
|
@ -85,13 +85,13 @@ if (!defined('BASE_URL')){
|
|||
define('CAKE_TEST_OUTPUT_HTML',1);
|
||||
define('CAKE_TEST_OUTPUT_TEXT',2);
|
||||
|
||||
if(isset($_GET['output']) && $_GET['output'] == 'html') {
|
||||
if (isset($_GET['output']) && $_GET['output'] == 'html') {
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML);
|
||||
} else {
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT);
|
||||
}
|
||||
|
||||
if(!vendor('simpletest' . DS . 'reporter')) {
|
||||
if (!vendor('simpletest' . DS . 'reporter')) {
|
||||
CakePHPTestHeader();
|
||||
include CAKE . 'tests' . DS . 'lib' . DS . 'simpletest.php';
|
||||
CakePHPTestSuiteFooter();
|
||||
|
@ -118,14 +118,14 @@ if(!vendor('simpletest' . DS . 'reporter')) {
|
|||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['group'])) {
|
||||
if(isset($_GET['app'])) {
|
||||
if (isset($_GET['app'])) {
|
||||
$show = '?show=groups&app=true';
|
||||
} else {
|
||||
$show = '?show=groups';
|
||||
}
|
||||
}
|
||||
if (isset($_GET['case'])) {
|
||||
if(isset($_GET['app'])) {
|
||||
if (isset($_GET['app'])) {
|
||||
$show = '??show=cases&app=truee';
|
||||
} else {
|
||||
$show = '?show=cases';
|
||||
|
|
160
cake/basics.php
160
cake/basics.php
|
@ -50,7 +50,7 @@
|
|||
* Loads all models.
|
||||
*/
|
||||
function loadModels() {
|
||||
if(!class_exists('Model')){
|
||||
if (!class_exists('Model')){
|
||||
require LIBS . 'model' . DS . 'model.php';
|
||||
}
|
||||
$path = Configure::getInstance();
|
||||
|
@ -64,8 +64,8 @@
|
|||
}
|
||||
$loadedModels = array();
|
||||
|
||||
foreach($path->modelPaths as $path) {
|
||||
foreach(listClasses($path) as $model_fn) {
|
||||
foreach ($path->modelPaths as $path) {
|
||||
foreach (listClasses($path) as $model_fn) {
|
||||
list($name) = explode('.', $model_fn);
|
||||
$className = Inflector::camelize($name);
|
||||
$loadedModels[$model_fn] = $model_fn;
|
||||
|
@ -86,7 +86,7 @@
|
|||
* @deprecated
|
||||
*/
|
||||
function loadPluginModels($plugin) {
|
||||
if(!class_exists('AppModel')){
|
||||
if (!class_exists('AppModel')){
|
||||
loadModel();
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,8 @@
|
|||
}
|
||||
|
||||
$pluginModelDir = APP . 'plugins' . DS . $plugin . DS . 'models' . DS;
|
||||
if(is_dir($pluginModelDir)) {
|
||||
foreach(listClasses($pluginModelDir)as $modelFileName) {
|
||||
if (is_dir($pluginModelDir)) {
|
||||
foreach (listClasses($pluginModelDir)as $modelFileName) {
|
||||
list($name) = explode('.', $modelFileName);
|
||||
$className = Inflector::camelize($name);
|
||||
|
||||
|
@ -120,7 +120,7 @@
|
|||
* @return boolean Success
|
||||
*/
|
||||
function loadView($viewClass) {
|
||||
if(strpos($viewClass, '.') !== false){
|
||||
if (strpos($viewClass, '.') !== false){
|
||||
list($plugin, $viewClass) = explode('.', $viewClass);
|
||||
$file = APP . 'plugins' . DS . Inflector::underscore($plugin) . DS . 'views' . DS . Inflector::underscore($viewClass) . '.php';
|
||||
if (file_exists($file)) {
|
||||
|
@ -133,7 +133,7 @@
|
|||
$paths = Configure::getInstance();
|
||||
$file = Inflector::underscore($viewClass) . '.php';
|
||||
|
||||
foreach($paths->viewPaths as $path) {
|
||||
foreach ($paths->viewPaths as $path) {
|
||||
if (file_exists($path . $file)) {
|
||||
return require($path . $file);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@
|
|||
* @return boolean Success
|
||||
*/
|
||||
function loadModel($name = null) {
|
||||
if(!class_exists('Model')){
|
||||
if (!class_exists('Model')){
|
||||
require LIBS . 'model' . DS . 'model.php';
|
||||
}
|
||||
if (!class_exists('AppModel')) {
|
||||
|
@ -171,7 +171,7 @@
|
|||
Overloadable::overload('AppModel');
|
||||
}
|
||||
|
||||
if(strpos($name, '.') !== false){
|
||||
if (strpos($name, '.') !== false){
|
||||
list($plugin, $name) = explode('.', $name);
|
||||
|
||||
$pluginAppModel = Inflector::camelize($plugin . '_app_model');
|
||||
|
@ -200,12 +200,12 @@
|
|||
$className = $name;
|
||||
$name = Inflector::underscore($name);
|
||||
$models = Configure::read('Models');
|
||||
if(is_array($models)) {
|
||||
if(array_key_exists($className, $models)) {
|
||||
if (is_array($models)) {
|
||||
if (array_key_exists($className, $models)) {
|
||||
require($models[$className]['path']);
|
||||
Overloadable::overload($className);
|
||||
return true;
|
||||
} elseif(isset($models['Core']) && array_key_exists($className, $models['Core'])) {
|
||||
} elseif (isset($models['Core']) && array_key_exists($className, $models['Core'])) {
|
||||
require($models['Core'][$className]['path']);
|
||||
Overloadable::overload($className);
|
||||
return true;
|
||||
|
@ -213,7 +213,7 @@
|
|||
}
|
||||
|
||||
$paths = Configure::getInstance();
|
||||
foreach($paths->modelPaths as $path) {
|
||||
foreach ($paths->modelPaths as $path) {
|
||||
if (file_exists($path . $name . '.php')) {
|
||||
Configure::store('Models', 'class.paths', array($className => array('path' => $path . $name . '.php')));
|
||||
require($path . $name . '.php');
|
||||
|
@ -238,23 +238,23 @@
|
|||
$directories = Configure::getInstance();
|
||||
$paths = array();
|
||||
|
||||
foreach($directories->modelPaths as $path) {
|
||||
foreach ($directories->modelPaths as $path) {
|
||||
$paths['Models'][] = $path;
|
||||
}
|
||||
foreach($directories->behaviorPaths as $path) {
|
||||
foreach ($directories->behaviorPaths as $path) {
|
||||
$paths['Behaviors'][] = $path;
|
||||
}
|
||||
foreach($directories->controllerPaths as $path) {
|
||||
foreach ($directories->controllerPaths as $path) {
|
||||
$paths['Controllers'][] = $path;
|
||||
}
|
||||
foreach($directories->componentPaths as $path) {
|
||||
foreach ($directories->componentPaths as $path) {
|
||||
$paths['Components'][] = $path;
|
||||
}
|
||||
foreach($directories->helperPaths as $path) {
|
||||
foreach ($directories->helperPaths as $path) {
|
||||
$paths['Helpers'][] = $path;
|
||||
}
|
||||
|
||||
if(!class_exists('Folder')){
|
||||
if (!class_exists('Folder')){
|
||||
uses('Folder');
|
||||
}
|
||||
|
||||
|
@ -262,9 +262,9 @@
|
|||
$plugins = $folder->ls();
|
||||
$classPaths = array('models', 'models'.DS.'behaviors', 'controllers', 'controllers'.DS.'components', 'views'.DS.'helpers');
|
||||
|
||||
foreach($plugins[0] as $plugin){
|
||||
foreach($classPaths as $path){
|
||||
if(strpos($path, DS) !== false){
|
||||
foreach ($plugins[0] as $plugin){
|
||||
foreach ($classPaths as $path){
|
||||
if (strpos($path, DS) !== false){
|
||||
$key = explode(DS, $path);
|
||||
$key = $key[1];
|
||||
} else {
|
||||
|
@ -292,8 +292,8 @@
|
|||
}
|
||||
$loadedControllers = array();
|
||||
|
||||
foreach($paths->controllerPaths as $path) {
|
||||
foreach(listClasses($path) as $controller) {
|
||||
foreach ($paths->controllerPaths as $path) {
|
||||
foreach (listClasses($path) as $controller) {
|
||||
list($name) = explode('.', $controller);
|
||||
$className = Inflector::camelize($name);
|
||||
if (loadController($name)) {
|
||||
|
@ -320,7 +320,7 @@
|
|||
if ($name === null) {
|
||||
return true;
|
||||
}
|
||||
if(strpos($name, '.') !== false){
|
||||
if (strpos($name, '.') !== false){
|
||||
list($plugin, $name) = explode('.', $name);
|
||||
|
||||
$pluginAppController = Inflector::camelize($plugin . '_app_controller');
|
||||
|
@ -352,7 +352,7 @@
|
|||
require($file);
|
||||
return true;
|
||||
} elseif (!class_exists(Inflector::camelize($plugin) . 'Controller')){
|
||||
if(file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) {
|
||||
if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) {
|
||||
require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php');
|
||||
return true;
|
||||
} else {
|
||||
|
@ -367,18 +367,18 @@
|
|||
if (!class_exists($className)) {
|
||||
$name = Inflector::underscore($className);
|
||||
$controllers = Configure::read('Controllers');
|
||||
if(is_array($controllers)) {
|
||||
if(array_key_exists($className, $controllers)) {
|
||||
if (is_array($controllers)) {
|
||||
if (array_key_exists($className, $controllers)) {
|
||||
require($controllers[$className]['path']);
|
||||
return true;
|
||||
} elseif(isset($controllers['Core']) && array_key_exists($className, $controllers['Core'])) {
|
||||
} elseif (isset($controllers['Core']) && array_key_exists($className, $controllers['Core'])) {
|
||||
require($controllers['Core'][$className]['path']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$paths = Configure::getInstance();
|
||||
foreach($paths->controllerPaths as $path) {
|
||||
foreach ($paths->controllerPaths as $path) {
|
||||
if (file_exists($path . $name . '.php')) {
|
||||
Configure::store('Controllers', 'class.paths', array($className => array('path' => $path . $name . '.php')));
|
||||
require($path . $name . '.php');
|
||||
|
@ -435,7 +435,7 @@
|
|||
require($file);
|
||||
return true;
|
||||
} elseif (!class_exists(Inflector::camelize($plugin) . 'Controller')){
|
||||
if(file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) {
|
||||
if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) {
|
||||
require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php');
|
||||
return true;
|
||||
} else {
|
||||
|
@ -464,7 +464,7 @@
|
|||
if ($name === null) {
|
||||
return true;
|
||||
}
|
||||
if(strpos($name, '.') !== false){
|
||||
if (strpos($name, '.') !== false){
|
||||
list($plugin, $name) = explode('.', $name);
|
||||
}
|
||||
|
||||
|
@ -473,18 +473,18 @@
|
|||
$name = Inflector::underscore($name);
|
||||
$helpers = Configure::read('Helpers');
|
||||
|
||||
if(is_array($helpers)) {
|
||||
if(array_key_exists($className, $helpers)) {
|
||||
if (is_array($helpers)) {
|
||||
if (array_key_exists($className, $helpers)) {
|
||||
require($helpers[$className]['path']);
|
||||
return true;
|
||||
} elseif(isset($helpers['Core']) && array_key_exists($className, $helpers['Core'])) {
|
||||
} elseif (isset($helpers['Core']) && array_key_exists($className, $helpers['Core'])) {
|
||||
require($helpers['Core'][$className]['path']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$paths = Configure::getInstance();
|
||||
foreach($paths->helperPaths as $path) {
|
||||
foreach ($paths->helperPaths as $path) {
|
||||
if (file_exists($path . $name . '.php')) {
|
||||
Configure::store('Helpers', 'class.paths', array($className => array('path' => $path . $name . '.php')));
|
||||
require($path . $name . '.php');
|
||||
|
@ -538,7 +538,7 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
if(strpos($name, '.') !== false){
|
||||
if (strpos($name, '.') !== false){
|
||||
list($plugin, $name) = explode('.', $name);
|
||||
}
|
||||
|
||||
|
@ -547,18 +547,18 @@
|
|||
$name = Inflector::underscore($name);
|
||||
$components = Configure::read('Components');
|
||||
|
||||
if(is_array($components)) {
|
||||
if(array_key_exists($className, $components)) {
|
||||
if (is_array($components)) {
|
||||
if (array_key_exists($className, $components)) {
|
||||
require($components[$className]['path']);
|
||||
return true;
|
||||
} elseif(isset($components['Core']) && array_key_exists($className, $components['Core'])) {
|
||||
} elseif (isset($components['Core']) && array_key_exists($className, $components['Core'])) {
|
||||
require($components['Core'][$className]['path']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$paths = Configure::getInstance();
|
||||
|
||||
foreach($paths->componentPaths as $path) {
|
||||
foreach ($paths->componentPaths as $path) {
|
||||
if (file_exists($path . $name . '.php')) {
|
||||
Configure::store('Components', 'class.paths', array($className => array('path' => $path . $name . '.php')));
|
||||
require($path . $name . '.php');
|
||||
|
@ -609,7 +609,7 @@
|
|||
if ($name === null) {
|
||||
return true;
|
||||
}
|
||||
if(strpos($name, '.') !== false){
|
||||
if (strpos($name, '.') !== false){
|
||||
list($plugin, $name) = explode('.', $name);
|
||||
}
|
||||
|
||||
|
@ -618,7 +618,7 @@
|
|||
if (!class_exists($name . 'Behavior')) {
|
||||
$name = Inflector::underscore($name);
|
||||
|
||||
foreach($paths->behaviorPaths as $path) {
|
||||
foreach ($paths->behaviorPaths as $path) {
|
||||
if (file_exists($path . $name . '.php')) {
|
||||
require($path . $name . '.php');
|
||||
return true;
|
||||
|
@ -645,7 +645,7 @@
|
|||
function listClasses($path) {
|
||||
$dir = opendir($path);
|
||||
$classes=array();
|
||||
while(false !== ($file = readdir($dir))) {
|
||||
while (false !== ($file = readdir($dir))) {
|
||||
if ((substr($file, -3, 3) == 'php') && substr($file, 0, 1) != '.') {
|
||||
$classes[] = $file;
|
||||
}
|
||||
|
@ -665,7 +665,7 @@
|
|||
*/
|
||||
function config() {
|
||||
$args = func_get_args();
|
||||
foreach($args as $arg) {
|
||||
foreach ($args as $arg) {
|
||||
if (('database' == $arg) && file_exists(CONFIGS . $arg . '.php')) {
|
||||
include_once(CONFIGS . $arg . '.php');
|
||||
} elseif (file_exists(CONFIGS . $arg . '.php')) {
|
||||
|
@ -712,7 +712,7 @@
|
|||
for ($i = 0; $i < $c; $i++) {
|
||||
$arg = $args[$i];
|
||||
|
||||
if(strpos($arg, '.') !== false){
|
||||
if (strpos($arg, '.') !== false){
|
||||
$file = explode('.', $arg);
|
||||
$plugin = Inflector::underscore($file[0]);
|
||||
unset($file[0]);
|
||||
|
@ -780,7 +780,7 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
foreach($array as $key => $val) {
|
||||
foreach ($array as $key => $val) {
|
||||
$sa[$key] = $val[$sortby];
|
||||
}
|
||||
|
||||
|
@ -790,7 +790,7 @@
|
|||
arsort($sa, $type);
|
||||
}
|
||||
|
||||
foreach($sa as $key => $val) {
|
||||
foreach ($sa as $key => $val) {
|
||||
$out[] = $array[$key];
|
||||
}
|
||||
return $out;
|
||||
|
@ -819,7 +819,7 @@
|
|||
}
|
||||
|
||||
$output=array();
|
||||
for($i = 0; $i < $c1; $i++) {
|
||||
for ($i = 0; $i < $c1; $i++) {
|
||||
$output[$a1[$i]] = $a2[$i];
|
||||
}
|
||||
return $output;
|
||||
|
@ -873,7 +873,7 @@
|
|||
*/
|
||||
function aa() {
|
||||
$args = func_get_args();
|
||||
for($l = 0, $c = count($args); $l < $c; $l++) {
|
||||
for ($l = 0, $c = count($args); $l < $c; $l++) {
|
||||
if ($l + 1 < count($args)) {
|
||||
$a[$args[$l]] = $args[$l + 1];
|
||||
} else {
|
||||
|
@ -962,7 +962,7 @@
|
|||
*/
|
||||
function am() {
|
||||
$r = array();
|
||||
foreach(func_get_args()as $a) {
|
||||
foreach (func_get_args()as $a) {
|
||||
if (!is_array($a)) {
|
||||
$a = array($a);
|
||||
}
|
||||
|
@ -979,7 +979,7 @@
|
|||
function setUri() {
|
||||
if (env('HTTP_X_REWRITE_URL')) {
|
||||
$uri = env('HTTP_X_REWRITE_URL');
|
||||
} elseif(env('REQUEST_URI')) {
|
||||
} elseif (env('REQUEST_URI')) {
|
||||
$uri = env('REQUEST_URI');
|
||||
} else {
|
||||
if ($uri = env('argv')) {
|
||||
|
@ -1086,7 +1086,7 @@
|
|||
$res = @fopen($fileName, 'w+b');
|
||||
if ($res) {
|
||||
$write = @fwrite($res, $data);
|
||||
if($write === false) {
|
||||
if ($write === false) {
|
||||
return false;
|
||||
} else {
|
||||
return $write;
|
||||
|
@ -1129,7 +1129,7 @@
|
|||
|
||||
$timediff = $expires - $now;
|
||||
$filetime = false;
|
||||
if(file_exists($filename)) {
|
||||
if (file_exists($filename)) {
|
||||
$filetime = @filemtime($filename);
|
||||
}
|
||||
|
||||
|
@ -1143,7 +1143,7 @@
|
|||
$data = file_get_contents($filename);
|
||||
}
|
||||
}
|
||||
} else if(is_writable(dirname($filename))) {
|
||||
} elseif (is_writable(dirname($filename))) {
|
||||
file_put_contents($filename, $data);
|
||||
}
|
||||
return $data;
|
||||
|
@ -1167,14 +1167,14 @@
|
|||
if (is_file($cache . $ext)) {
|
||||
@unlink($cache . $ext);
|
||||
return true;
|
||||
} else if(is_dir($cache)) {
|
||||
} elseif (is_dir($cache)) {
|
||||
$files = glob("$cache*");
|
||||
|
||||
if ($files === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($files as $file) {
|
||||
foreach ($files as $file) {
|
||||
if (is_file($file)) {
|
||||
@unlink($file);
|
||||
}
|
||||
|
@ -1187,7 +1187,7 @@
|
|||
if ($files === false) {
|
||||
return false;
|
||||
}
|
||||
foreach($files as $file) {
|
||||
foreach ($files as $file) {
|
||||
if (is_file($file)) {
|
||||
@unlink($file);
|
||||
}
|
||||
|
@ -1195,16 +1195,16 @@
|
|||
return true;
|
||||
}
|
||||
} elseif (is_array($params)) {
|
||||
foreach($params as $key => $file) {
|
||||
foreach ($params as $key => $file) {
|
||||
$file = preg_replace('/\/\//', '/', $file);
|
||||
$cache = CACHE . $type . DS . '*' . $file . '*' . $ext;
|
||||
$files[] = glob($cache);
|
||||
}
|
||||
|
||||
if (!empty($files)) {
|
||||
foreach($files as $key => $delete) {
|
||||
foreach ($files as $key => $delete) {
|
||||
if (is_array($delete)) {
|
||||
foreach($delete as $file) {
|
||||
foreach ($delete as $file) {
|
||||
if (is_file($file)) {
|
||||
@unlink($file);
|
||||
}
|
||||
|
@ -1243,13 +1243,13 @@
|
|||
* @return mixed translated string if $return is false string will be echoed
|
||||
*/
|
||||
function __($singular, $return = false) {
|
||||
if(!class_exists('I18n')) {
|
||||
if (!class_exists('I18n')) {
|
||||
uses('i18n');
|
||||
}
|
||||
$calledFrom = debug_backtrace();
|
||||
$dir = dirname($calledFrom[0]['file']);
|
||||
|
||||
if($return === false) {
|
||||
if ($return === false) {
|
||||
echo I18n::translate($singular, null, null, 5, null, $dir);
|
||||
} else {
|
||||
return I18n::translate($singular, null, null, 5, null, $dir);
|
||||
|
@ -1267,13 +1267,13 @@
|
|||
* @return mixed plural form of translated string if $return is false string will be echoed
|
||||
*/
|
||||
function __n($singular, $plural, $count, $return = false) {
|
||||
if(!class_exists('I18n')) {
|
||||
if (!class_exists('I18n')) {
|
||||
uses('i18n');
|
||||
}
|
||||
$calledFrom = debug_backtrace();
|
||||
$dir = dirname($calledFrom[0]['file']);
|
||||
|
||||
if($return === false) {
|
||||
if ($return === false) {
|
||||
echo I18n::translate($singular, $plural, null, 5, $count, $dir);
|
||||
} else {
|
||||
return I18n::translate($singular, $plural, null, 5, $count, $dir);
|
||||
|
@ -1289,11 +1289,11 @@
|
|||
* @return translated string if $return is false string will be echoed
|
||||
*/
|
||||
function __d($domain, $msg, $return = false) {
|
||||
if(!class_exists('I18n')) {
|
||||
if (!class_exists('I18n')) {
|
||||
uses('i18n');
|
||||
}
|
||||
|
||||
if($return === false) {
|
||||
if ($return === false) {
|
||||
echo I18n::translate($msg, null, $domain);
|
||||
} else {
|
||||
return I18n::translate($msg, null, $domain);
|
||||
|
@ -1313,11 +1313,11 @@
|
|||
* @return plural form of translated string if $return is false string will be echoed
|
||||
*/
|
||||
function __dn($domain, $singular, $plural, $count, $return = false) {
|
||||
if(!class_exists('I18n')) {
|
||||
if (!class_exists('I18n')) {
|
||||
uses('i18n');
|
||||
}
|
||||
|
||||
if($return === false) {
|
||||
if ($return === false) {
|
||||
echo I18n::translate($singular, $plural, $domain, 5, $count);
|
||||
} else {
|
||||
return I18n::translate($singular, $plural, $domain, 5, $count);
|
||||
|
@ -1347,11 +1347,11 @@
|
|||
* @return translated string if $return is false string will be echoed
|
||||
*/
|
||||
function __dc($domain, $msg, $category, $return = false) {
|
||||
if(!class_exists('I18n')) {
|
||||
if (!class_exists('I18n')) {
|
||||
uses('i18n');
|
||||
}
|
||||
|
||||
if($return === false) {
|
||||
if ($return === false) {
|
||||
echo I18n::translate($msg, null, $domain, $category);
|
||||
} else {
|
||||
return I18n::translate($msg, null, $domain, $category);
|
||||
|
@ -1385,11 +1385,11 @@
|
|||
* @return plural form of translated string if $return is false string will be echoed
|
||||
*/
|
||||
function __dcn($domain, $singular, $plural, $count, $category, $return = false) {
|
||||
if(!class_exists('I18n')) {
|
||||
if (!class_exists('I18n')) {
|
||||
uses('i18n');
|
||||
}
|
||||
|
||||
if($return === false) {
|
||||
if ($return === false) {
|
||||
echo I18n::translate($singular, $plural, $domain, $category, $count);
|
||||
} else {
|
||||
return I18n::translate($singular, $plural, $domain, $category, $count);
|
||||
|
@ -1415,13 +1415,13 @@
|
|||
* @return translated string if $return is false string will be echoed
|
||||
*/
|
||||
function __c($msg, $category, $return = false) {
|
||||
if(!class_exists('I18n')) {
|
||||
if (!class_exists('I18n')) {
|
||||
uses('i18n');
|
||||
}
|
||||
$calledFrom = debug_backtrace();
|
||||
$dir = dirname($calledFrom[0]['file']);
|
||||
|
||||
if($return === false) {
|
||||
if ($return === false) {
|
||||
echo I18n::translate($msg, null, null, $category, null, $dir);
|
||||
} else {
|
||||
return I18n::translate($msg, null, null, $category, null, $dir);
|
||||
|
@ -1470,8 +1470,8 @@
|
|||
if (!function_exists('array_intersect_key')) {
|
||||
function array_intersect_key($arr1, $arr2) {
|
||||
$res = array();
|
||||
foreach($arr1 as $key=>$value) {
|
||||
if(array_key_exists($key, $arr2)) {
|
||||
foreach ($arr1 as $key=>$value) {
|
||||
if (array_key_exists($key, $arr2)) {
|
||||
$res[$key] = $arr1[$key];
|
||||
}
|
||||
}
|
||||
|
@ -1499,7 +1499,7 @@
|
|||
*/
|
||||
function fileExistsInPath($file) {
|
||||
$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
|
||||
foreach($paths as $path) {
|
||||
foreach ($paths as $path) {
|
||||
$fullPath = $path . DIRECTORY_SEPARATOR . $file;
|
||||
|
||||
if (file_exists($fullPath)) {
|
||||
|
@ -1535,7 +1535,7 @@
|
|||
}
|
||||
$dir = opendir($path);
|
||||
|
||||
while($file = readdir($dir)) {
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$fullpath = $path . '/' . $file;
|
||||
|
||||
|
|
|
@ -46,14 +46,14 @@ if (!defined('PHP5')) {
|
|||
require LIBS . 'configure.php';
|
||||
$paths = Configure::getInstance();
|
||||
|
||||
if(isset($cakeCache)) {
|
||||
if (isset($cakeCache)) {
|
||||
$cache = 'File';
|
||||
$settings = array();
|
||||
|
||||
if(isset($cakeCache[0])) {
|
||||
if (isset($cakeCache[0])) {
|
||||
$cache = $cakeCache[0];
|
||||
}
|
||||
if(isset($cakeCache[1])) {
|
||||
if (isset($cakeCache[1])) {
|
||||
$settings = $cakeCache[1];
|
||||
}
|
||||
Cache::engine($cache, $settings);
|
||||
|
@ -135,7 +135,7 @@ if (!defined('PHP5')) {
|
|||
$v = null;
|
||||
$view = new View($v);
|
||||
$view->renderCache($filename, $TIME_START);
|
||||
} elseif(file_exists(CACHE . 'views' . DS . convertSlash($uri) . '_index.php')) {
|
||||
} elseif (file_exists(CACHE . 'views' . DS . convertSlash($uri) . '_index.php')) {
|
||||
uses('controller' . DS . 'component', DS . 'view' . DS . 'view');
|
||||
$v = null;
|
||||
$view = new View($v);
|
||||
|
|
|
@ -32,10 +32,10 @@
|
|||
* directory we will define ROOT there, otherwise we set it
|
||||
* here.
|
||||
*/
|
||||
if(!defined('ROOT')) {
|
||||
if (!defined('ROOT')) {
|
||||
define ('ROOT', '../');
|
||||
}
|
||||
if(!defined('WEBROOT_DIR')) {
|
||||
if (!defined('WEBROOT_DIR')) {
|
||||
define ('WEBROOT_DIR', 'webroot');
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -211,7 +211,7 @@ class ShellDispatcher {
|
|||
CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php',
|
||||
);
|
||||
|
||||
if(!file_exists(APP_PATH . 'config' . DS . 'core.php')) {
|
||||
if (!file_exists(APP_PATH . 'config' . DS . 'core.php')) {
|
||||
$includes[] = CORE_PATH . 'cake' . DS . 'console' . DS . 'libs' . DS . 'templates' . DS . 'skel' . DS . 'config' . DS . 'core.php';
|
||||
} else {
|
||||
$includes[] = APP_PATH . 'config' . DS . 'core.php';
|
||||
|
@ -257,7 +257,7 @@ class ShellDispatcher {
|
|||
$this->help();
|
||||
} else {
|
||||
$loaded = false;
|
||||
foreach($this->shellPaths as $path) {
|
||||
foreach ($this->shellPaths as $path) {
|
||||
$this->shellPath = $path . $this->shell . ".php";
|
||||
if (file_exists($this->shellPath)) {
|
||||
$loaded = true;
|
||||
|
@ -268,18 +268,18 @@ class ShellDispatcher {
|
|||
if ($loaded) {
|
||||
require CONSOLE_LIBS . 'shell.php';
|
||||
require $this->shellPath;
|
||||
if(class_exists($this->shellClass)) {
|
||||
if (class_exists($this->shellClass)) {
|
||||
|
||||
$command = null;
|
||||
if(isset($this->args[0])) {
|
||||
if (isset($this->args[0])) {
|
||||
$command = $this->args[0];
|
||||
}
|
||||
$this->shellCommand = Inflector::variable($command);
|
||||
$shell = new $this->shellClass($this);
|
||||
$this->shiftArgs();
|
||||
|
||||
if($command == 'help') {
|
||||
if(method_exists($shell, 'help')) {
|
||||
if ($command == 'help') {
|
||||
if (method_exists($shell, 'help')) {
|
||||
$shell->help();
|
||||
exit();
|
||||
} else {
|
||||
|
@ -290,16 +290,16 @@ class ShellDispatcher {
|
|||
$shell->initialize();
|
||||
$shell->loadTasks();
|
||||
|
||||
foreach($shell->taskNames as $task) {
|
||||
foreach ($shell->taskNames as $task) {
|
||||
$shell->{$task}->initialize();
|
||||
$shell->{$task}->loadTasks();
|
||||
}
|
||||
|
||||
$task = Inflector::camelize($command);
|
||||
if(in_array($task, $shell->taskNames)) {
|
||||
if (in_array($task, $shell->taskNames)) {
|
||||
$shell->{$task}->startup();
|
||||
if(isset($this->args[0]) && $this->args[0] == 'help') {
|
||||
if(method_exists($shell->{$task}, 'help')) {
|
||||
if (isset($this->args[0]) && $this->args[0] == 'help') {
|
||||
if (method_exists($shell->{$task}, 'help')) {
|
||||
$shell->{$task}->help();
|
||||
exit();
|
||||
} else {
|
||||
|
@ -313,11 +313,11 @@ class ShellDispatcher {
|
|||
$classMethods = get_class_methods($shell);
|
||||
|
||||
$privateMethod = $missingCommand = false;
|
||||
if((in_array($command, $classMethods) || in_array(strtolower($command), $classMethods)) && strpos($command, '_', 0) === 0) {
|
||||
if ((in_array($command, $classMethods) || in_array(strtolower($command), $classMethods)) && strpos($command, '_', 0) === 0) {
|
||||
$privateMethod = true;
|
||||
}
|
||||
|
||||
if(!in_array($command, $classMethods) && !in_array(strtolower($command), $classMethods)) {
|
||||
if (!in_array($command, $classMethods) && !in_array(strtolower($command), $classMethods)) {
|
||||
$missingCommand = true;
|
||||
}
|
||||
|
||||
|
@ -331,12 +331,12 @@ class ShellDispatcher {
|
|||
$missingCommand = true;
|
||||
}
|
||||
|
||||
if($missingCommand && method_exists($shell, 'main')) {
|
||||
if ($missingCommand && method_exists($shell, 'main')) {
|
||||
$shell->startup();
|
||||
$shell->main();
|
||||
} else if($missingCommand && method_exists($shell, 'help')) {
|
||||
} elseif ($missingCommand && method_exists($shell, 'help')) {
|
||||
$shell->help();
|
||||
} else if(!$privateMethod && method_exists($shell, $command)) {
|
||||
} elseif (!$privateMethod && method_exists($shell, $command)) {
|
||||
$shell->startup();
|
||||
$shell->{$command}();
|
||||
} else {
|
||||
|
@ -369,14 +369,14 @@ class ShellDispatcher {
|
|||
$print_options = '(' . implode('/', $options) . ')';
|
||||
}
|
||||
|
||||
if($default == null) {
|
||||
if ($default == null) {
|
||||
$this->stdout($prompt . " $print_options \n" . '> ', false);
|
||||
} else {
|
||||
$this->stdout($prompt . " $print_options \n" . "[$default] > ", false);
|
||||
}
|
||||
$result = trim(fgets($this->stdin));
|
||||
|
||||
if($default != null && empty($result)) {
|
||||
if ($default != null && empty($result)) {
|
||||
return $default;
|
||||
} else {
|
||||
return $result;
|
||||
|
@ -425,15 +425,15 @@ class ShellDispatcher {
|
|||
$root = dirname(dirname(dirname(__FILE__)));
|
||||
$working = $root;
|
||||
|
||||
if(!empty($this->params['working'])) {
|
||||
if (!empty($this->params['working'])) {
|
||||
$root = dirname($this->params['working']);
|
||||
$app = basename($this->params['working']);
|
||||
} else {
|
||||
$this->params['working'] = $root;
|
||||
}
|
||||
|
||||
if(!empty($this->params['app'])) {
|
||||
if($this->params['app']{0} == '/') {
|
||||
if (!empty($this->params['app'])) {
|
||||
if ($this->params['app']{0} == '/') {
|
||||
$root = dirname($this->params['app']);
|
||||
$app = basename($this->params['app']);
|
||||
} else {
|
||||
|
@ -443,7 +443,7 @@ class ShellDispatcher {
|
|||
unset($this->params['app']);
|
||||
}
|
||||
|
||||
if(in_array($app, array('cake', 'console')) || realpath($root.DS.$app) === dirname(dirname(dirname(__FILE__)))) {
|
||||
if (in_array($app, array('cake', 'console')) || realpath($root.DS.$app) === dirname(dirname(dirname(__FILE__)))) {
|
||||
$root = dirname(dirname(dirname(__FILE__)));
|
||||
$app = 'app';
|
||||
}
|
||||
|
@ -484,12 +484,12 @@ class ShellDispatcher {
|
|||
$this->stdout("Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp");
|
||||
|
||||
$this->stdout("\nAvailable Shells:");
|
||||
foreach($this->shellPaths as $path) {
|
||||
if(is_dir($path)) {
|
||||
foreach ($this->shellPaths as $path) {
|
||||
if (is_dir($path)) {
|
||||
$shells = listClasses($path);
|
||||
$path = r(CORE_PATH, '', $path);
|
||||
$this->stdout("\n " . $path . ":");
|
||||
if(empty($shells)) {
|
||||
if (empty($shells)) {
|
||||
$this->stdout("\t - none");
|
||||
} else {
|
||||
foreach ($shells as $shell) {
|
||||
|
|
|
@ -88,15 +88,15 @@ class AclShell extends Shell {
|
|||
exit();
|
||||
}
|
||||
|
||||
if($this->command && !in_array($this->command, array('help'))) {
|
||||
if(!config('database')) {
|
||||
if ($this->command && !in_array($this->command, array('help'))) {
|
||||
if (!config('database')) {
|
||||
$this->out(__("Your database configuration was not found. Take a moment to create one.", true), true);
|
||||
$this->args = null;
|
||||
return $this->DbConfig->execute();
|
||||
}
|
||||
require_once (CONFIGS.'database.php');
|
||||
|
||||
if(!in_array($this->command, array('initdb'))) {
|
||||
if (!in_array($this->command, array('initdb'))) {
|
||||
$this->Acl = new AclComponent();
|
||||
$this->db =& ConnectionManager::getDataSource($this->dataSource);
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ class AclShell extends Shell {
|
|||
$data['parent_id'] = $parent;
|
||||
$object->create();
|
||||
|
||||
if($object->save($data)) {
|
||||
if ($object->save($data)) {
|
||||
$this->out(sprintf(__("New %s '%s' created.\n", true), $class, $this->args[2]), true);
|
||||
} else {
|
||||
$this->err(sprintf(__("There was a problem creating a new %s '%s'.", true), $class, $this->args[2]));
|
||||
|
@ -184,7 +184,7 @@ class AclShell extends Shell {
|
|||
$this->_checkArgs(2, 'delete');
|
||||
$this->checkNodeType();
|
||||
extract($this->__dataVars());
|
||||
if(!$this->Acl->{$class}->delete($this->args[1])) {
|
||||
if (!$this->Acl->{$class}->delete($this->args[1])) {
|
||||
$this->error(__("Node Not Deleted", true), sprintf(__("There was an error deleting the %s. Check that the node exists", true), $class) . ".\n");
|
||||
}
|
||||
$this->out(sprintf(__("%s deleted", true), $class) . ".\n", true);
|
||||
|
@ -233,7 +233,7 @@ class AclShell extends Shell {
|
|||
//add existence checks for nodes involved
|
||||
$aro = (is_numeric($this->args[0])) ? intval($this->args[0]) : $this->args[0];
|
||||
$aco = (is_numeric($this->args[1])) ? intval($this->args[1]) : $this->args[1];
|
||||
if($this->Acl->allow($aro, $aco, $this->args[2])) {
|
||||
if ($this->Acl->allow($aro, $aco, $this->args[2])) {
|
||||
$this->out(__("Permission granted.", true), true);
|
||||
}
|
||||
}
|
||||
|
@ -284,15 +284,15 @@ class AclShell extends Shell {
|
|||
$this->hr();
|
||||
$nodeCount = count($nodes);
|
||||
$right = $left = array();
|
||||
for($i = 0; $i < $nodeCount; $i++) {
|
||||
for ($i = 0; $i < $nodeCount; $i++) {
|
||||
$count = 0;
|
||||
$right[$i] = $nodes[$i][$class]['rght'];
|
||||
$left[$i] = $nodes[$i][$class]['lft'];
|
||||
if(isset($left[$i]) && isset($left[$i-1]) && $left[$i] > $left[$i-1]) {
|
||||
if (isset($left[$i]) && isset($left[$i-1]) && $left[$i] > $left[$i-1]) {
|
||||
array_pop($left);
|
||||
$count = count($left);
|
||||
}
|
||||
if(isset($right[$i]) && isset($right[$i-1]) && $right[$i] < $right[$i-1]) {
|
||||
if (isset($right[$i]) && isset($right[$i-1]) && $right[$i] < $right[$i-1]) {
|
||||
array_pop($right);
|
||||
$count = count($right);
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ class AclShell extends Shell {
|
|||
* @access public
|
||||
*/
|
||||
function checkNodeType() {
|
||||
if(!isset($this->args[0])) {
|
||||
if (!isset($this->args[0])) {
|
||||
return false;
|
||||
}
|
||||
if ($this->args[0] != 'aco' && $this->args[0] != 'aro') {
|
||||
|
|
|
@ -79,7 +79,7 @@ class ApiShell extends Shell {
|
|||
if (!preg_match('/' . Inflector::camelize($path) . '$/', $class)) {
|
||||
$class .= Inflector::camelize($path);
|
||||
}
|
||||
} else if(low($path) === low($class)){
|
||||
} elseif (low($path) === low($class)){
|
||||
$class = Inflector::camelize($path);
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ class ApiShell extends Shell {
|
|||
substr(Inflector::underscore($class), 0, strpos(Inflector::underscore($class), '_'))
|
||||
);
|
||||
|
||||
foreach($candidates as $candidate) {
|
||||
foreach ($candidates as $candidate) {
|
||||
$File =& new File($path . $candidate . '.php');
|
||||
|
||||
if ($File->exists()) {
|
||||
|
@ -129,7 +129,7 @@ class ApiShell extends Shell {
|
|||
$this->out(ucwords($class));
|
||||
$this->hr();
|
||||
|
||||
foreach($parsed as $method) {
|
||||
foreach ($parsed as $method) {
|
||||
$this->out("\t" . $method['method'] . "(" . $method['parameters'] . ")", true);
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ class ApiShell extends Shell {
|
|||
|
||||
$contents = $File->read();
|
||||
|
||||
foreach($methods as $method) {
|
||||
foreach ($methods as $method) {
|
||||
if (strpos($method, '__') !== 0 && strpos($method, '_') !== 0) {
|
||||
$regex = '/\s+function\s+(' . preg_quote($method, '/') . ')\s*\(([^{]*)\)\s*{/is';
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
* @package cake
|
||||
* @subpackage cake.cake.console.libs
|
||||
*/
|
||||
if(!defined('CAKE_ADMIN')) {
|
||||
if (!defined('CAKE_ADMIN')) {
|
||||
define('CAKE_ADMIN', null);
|
||||
}
|
||||
class BakeShell extends Shell {
|
||||
|
@ -43,11 +43,11 @@ class BakeShell extends Shell {
|
|||
|
||||
function main() {
|
||||
|
||||
if(!is_dir(CONFIGS)) {
|
||||
if (!is_dir(CONFIGS)) {
|
||||
$this->Project->execute();
|
||||
}
|
||||
|
||||
if(!config('database')) {
|
||||
if (!config('database')) {
|
||||
$this->out("Your database configuration was not found. Take a moment to create one.\n");
|
||||
$this->args = null;
|
||||
return $this->DbConfig->execute();
|
||||
|
|
|
@ -155,7 +155,7 @@ class ConsoleShell extends Shell {
|
|||
|
||||
foreach ($result as $field => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach($value as $field2 => $value2) {
|
||||
foreach ($value as $field2 => $value2) {
|
||||
$this->out("\t$field2: $value2");
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ class ConsoleShell extends Shell {
|
|||
} else { // find() output
|
||||
$this->out($idx);
|
||||
|
||||
foreach($results as $field => $value) {
|
||||
foreach ($results as $field => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $field2 => $value2) {
|
||||
$this->out("\t$field2: $value2");
|
||||
|
|
|
@ -69,28 +69,28 @@ class ExtractShell extends Shell{
|
|||
var $__output = null;
|
||||
|
||||
function initialize() {
|
||||
if(isset($this->params['files']) && !is_array($this->params['files'])){
|
||||
if (isset($this->params['files']) && !is_array($this->params['files'])){
|
||||
$this->files = explode(',', $this->params['files']);
|
||||
}
|
||||
|
||||
if(isset($this->params['path'])) {
|
||||
if (isset($this->params['path'])) {
|
||||
$this->path = $this->params['path'];
|
||||
} else {
|
||||
$this->path = ROOT . DS . APP_DIR;
|
||||
}
|
||||
|
||||
if(isset($this->params['debug'])) {
|
||||
if (isset($this->params['debug'])) {
|
||||
$this->path = ROOT;
|
||||
$this->files = array(__FILE__);
|
||||
}
|
||||
|
||||
if(isset($this->params['output'])) {
|
||||
if (isset($this->params['output'])) {
|
||||
$this->__output = $this->params['output'];
|
||||
} else {
|
||||
$this->__output = APP . 'locale' . DS;
|
||||
}
|
||||
|
||||
if(empty($this->files)){
|
||||
if (empty($this->files)){
|
||||
$this->files = $this->__searchDirectory();
|
||||
}
|
||||
}
|
||||
|
@ -105,12 +105,12 @@ class ExtractShell extends Shell{
|
|||
|
||||
$response = '';
|
||||
$filename = '';
|
||||
while($response == '') {
|
||||
while ($response == '') {
|
||||
$response = $this->in('Would you like to merge all translations into one file?', array('y','n'), 'y');
|
||||
if(strtolower($response) == 'n') {
|
||||
if (strtolower($response) == 'n') {
|
||||
$this->__oneFile = false;
|
||||
} else {
|
||||
while($filename == '') {
|
||||
while ($filename == '') {
|
||||
$filename = $this->in('What should we name this file?', null, $this->__filename);
|
||||
if ($filename == '') {
|
||||
$this->out('The filesname you supplied was empty. Please try again.');
|
||||
|
@ -154,15 +154,15 @@ class ExtractShell extends Shell{
|
|||
$this->__tokens = array();
|
||||
$lineNumber = 1;
|
||||
|
||||
foreach($allTokens as $token) {
|
||||
if((!is_array($token)) || (($token[0] != T_WHITESPACE) && ($token[0] != T_INLINE_HTML))) {
|
||||
if(is_array($token)) {
|
||||
foreach ($allTokens as $token) {
|
||||
if ((!is_array($token)) || (($token[0] != T_WHITESPACE) && ($token[0] != T_INLINE_HTML))) {
|
||||
if (is_array($token)) {
|
||||
$token[] = $lineNumber;
|
||||
}
|
||||
$this->__tokens[] = $token;
|
||||
}
|
||||
|
||||
if(is_array($token)) {
|
||||
if (is_array($token)) {
|
||||
$lineNumber += count(split("\n", $token[1])) - 1;
|
||||
} else {
|
||||
$lineNumber += count(split("\n", $token)) - 1;
|
||||
|
@ -190,7 +190,7 @@ class ExtractShell extends Shell{
|
|||
$count = 0;
|
||||
$tokenCount = count($this->__tokens);
|
||||
|
||||
while(($tokenCount - $count) > 3) {
|
||||
while (($tokenCount - $count) > 3) {
|
||||
list($countToken, $parenthesis, $middle, $right) = array($this->__tokens[$count], $this->__tokens[$count + 1], $this->__tokens[$count + 2], $this->__tokens[$count + 3]);
|
||||
if (!is_array($countToken)) {
|
||||
$count++;
|
||||
|
@ -198,9 +198,9 @@ class ExtractShell extends Shell{
|
|||
}
|
||||
|
||||
list($type, $string, $line) = $countToken;
|
||||
if(($type == T_STRING) && ($string == $functionname) && ($parenthesis == "(")) {
|
||||
if (($type == T_STRING) && ($string == $functionname) && ($parenthesis == "(")) {
|
||||
|
||||
if(in_array($right, array(")", ","))
|
||||
if (in_array($right, array(")", ","))
|
||||
&& (is_array($middle) && ($middle[0] == T_CONSTANT_ENCAPSED_STRING))) {
|
||||
|
||||
if ($this->__oneFile === true) {
|
||||
|
@ -226,9 +226,9 @@ class ExtractShell extends Shell{
|
|||
$count = 0;
|
||||
$tokenCount = count($this->__tokens);
|
||||
|
||||
while(($tokenCount - $count) > 7) {
|
||||
while (($tokenCount - $count) > 7) {
|
||||
list($countToken, $firstParenthesis) = array($this->__tokens[$count], $this->__tokens[$count + 1]);
|
||||
if(!is_array($countToken)) {
|
||||
if (!is_array($countToken)) {
|
||||
$count++;
|
||||
continue;
|
||||
}
|
||||
|
@ -238,23 +238,23 @@ class ExtractShell extends Shell{
|
|||
$position = $count;
|
||||
$depth = 0;
|
||||
|
||||
while($depth == 0) {
|
||||
while ($depth == 0) {
|
||||
if ($this->__tokens[$position] == "(") {
|
||||
$depth++;
|
||||
} elseif($this->__tokens[$position] == ")") {
|
||||
} elseif ($this->__tokens[$position] == ")") {
|
||||
$depth--;
|
||||
}
|
||||
$position++;
|
||||
}
|
||||
|
||||
if($plural) {
|
||||
if ($plural) {
|
||||
$end = $position + $shift + 7;
|
||||
|
||||
if($this->__tokens[$position + $shift + 5] === ')') {
|
||||
if ($this->__tokens[$position + $shift + 5] === ')') {
|
||||
$end = $position + $shift + 5;
|
||||
}
|
||||
|
||||
if(empty($shift)) {
|
||||
if (empty($shift)) {
|
||||
list($singular, $firstComma, $plural, $seoncdComma, $endParenthesis) = array($this->__tokens[$position], $this->__tokens[$position + 1], $this->__tokens[$position + 2], $this->__tokens[$position + 3], $this->__tokens[$end]);
|
||||
$condition = ($seoncdComma == ",");
|
||||
} else {
|
||||
|
@ -265,7 +265,7 @@ class ExtractShell extends Shell{
|
|||
(is_array($singular) && ($singular[0] == T_CONSTANT_ENCAPSED_STRING)) &&
|
||||
(is_array($plural) && ($plural[0] == T_CONSTANT_ENCAPSED_STRING));
|
||||
} else {
|
||||
if($this->__tokens[$position + $shift + 5] === ')') {
|
||||
if ($this->__tokens[$position + $shift + 5] === ')') {
|
||||
$comma = $this->__tokens[$position + $shift + 3];
|
||||
$end = $position + $shift + 5;
|
||||
} else {
|
||||
|
@ -279,15 +279,15 @@ class ExtractShell extends Shell{
|
|||
(is_array($text) && ($text[0] == T_CONSTANT_ENCAPSED_STRING));
|
||||
}
|
||||
|
||||
if(($endParenthesis == ")") && $condition) {
|
||||
if($this->__oneFile === true) {
|
||||
if($plural) {
|
||||
if (($endParenthesis == ")") && $condition) {
|
||||
if ($this->__oneFile === true) {
|
||||
if ($plural) {
|
||||
$this->__strings[$this->__formatString($singular[1]) . "\0" . $this->__formatString($plural[1])][$this->__file][] = $line;
|
||||
} else {
|
||||
$this->__strings[$this->__formatString($text[1])][$this->__file][] = $line;
|
||||
}
|
||||
} else {
|
||||
if($plural) {
|
||||
if ($plural) {
|
||||
$this->__strings[$this->__file][$this->__formatString($singular[1]) . "\0" . $this->__formatString($plural[1])][] = $line;
|
||||
} else {
|
||||
$this->__strings[$this->__file][$this->__formatString($text[1])][] = $line;
|
||||
|
@ -302,14 +302,14 @@ class ExtractShell extends Shell{
|
|||
}
|
||||
function __buildFiles() {
|
||||
$output = '';
|
||||
foreach($this->__strings as $str => $fileInfo) {
|
||||
foreach ($this->__strings as $str => $fileInfo) {
|
||||
$occured = $fileList = array();
|
||||
|
||||
if($this->__oneFile === true) {
|
||||
foreach($fileInfo as $file => $lines) {
|
||||
if ($this->__oneFile === true) {
|
||||
foreach ($fileInfo as $file => $lines) {
|
||||
$occured[] = "$file:" . join(";", $lines);
|
||||
|
||||
if(isset($this->__fileVersions[$file])) {
|
||||
if (isset($this->__fileVersions[$file])) {
|
||||
$fileList[] = $this->__fileVersions[$file];
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ class ExtractShell extends Shell{
|
|||
$output = "#: $occurances\n";
|
||||
$filename = $this->__filename;
|
||||
|
||||
if(strpos($str, "\0") === false) {
|
||||
if (strpos($str, "\0") === false) {
|
||||
$output .= "msgid \"$str\"\n";
|
||||
$output .= "msgstr \"\"\n";
|
||||
} else {
|
||||
|
@ -330,18 +330,18 @@ class ExtractShell extends Shell{
|
|||
}
|
||||
$output .= "\n";
|
||||
} else {
|
||||
foreach($fileInfo as $file => $lines) {
|
||||
foreach ($fileInfo as $file => $lines) {
|
||||
$filename = $str;
|
||||
$occured = array("$str:" . join(";", $lines));
|
||||
|
||||
if(isset($this->__fileVersions[$str])) {
|
||||
if (isset($this->__fileVersions[$str])) {
|
||||
$fileList[] = $this->__fileVersions[$str];
|
||||
}
|
||||
$occurances = join("\n#: ", $occured);
|
||||
$occurances = str_replace($this->path, '', $occurances);
|
||||
$output .= "#: $occurances\n";
|
||||
|
||||
if(strpos($file, "\0") === false) {
|
||||
if (strpos($file, "\0") === false) {
|
||||
$output .= "msgid \"$file\"\n";
|
||||
$output .= "msgstr \"\"\n";
|
||||
} else {
|
||||
|
@ -360,8 +360,8 @@ class ExtractShell extends Shell{
|
|||
function __store($file = 0, $input = 0, $fileList = array(), $get = 0) {
|
||||
static $storage = array();
|
||||
|
||||
if(!$get) {
|
||||
if(isset($storage[$file])) {
|
||||
if (!$get) {
|
||||
if (isset($storage[$file])) {
|
||||
$storage[$file][1] = array_unique(array_merge($storage[$file][1], $fileList));
|
||||
$storage[$file][] = $input;
|
||||
} else {
|
||||
|
@ -378,7 +378,7 @@ class ExtractShell extends Shell{
|
|||
$output = $this->__store(0, 0, array(), 1);
|
||||
$output = $this->__mergeFiles($output);
|
||||
|
||||
foreach($output as $file => $content) {
|
||||
foreach ($output as $file => $content) {
|
||||
$tmp = str_replace(array($this->path, '.php','.ctp','.thtml', '.inc','.tpl' ), '', $file);
|
||||
$tmp = str_replace(DS, '.', $tmp);
|
||||
$file = str_replace('.', '-', $tmp) .'.pot';
|
||||
|
@ -388,9 +388,9 @@ class ExtractShell extends Shell{
|
|||
|
||||
$fileList = str_replace(array($this->path), '', $fileList);
|
||||
|
||||
if(count($fileList) > 1) {
|
||||
if (count($fileList) > 1) {
|
||||
$fileList = "Generated from files:\n# " . join("\n# ", $fileList);
|
||||
} elseif(count($fileList) == 1) {
|
||||
} elseif (count($fileList) == 1) {
|
||||
$fileList = "Generated from file: " . join("", $fileList);
|
||||
} else {
|
||||
$fileList = "No version information was available in the source files.";
|
||||
|
@ -401,17 +401,17 @@ class ExtractShell extends Shell{
|
|||
}
|
||||
}
|
||||
function __mergeFiles($output){
|
||||
foreach($output as $file => $content) {
|
||||
if(count($content) <= 1 && $file != $this->__filename) {
|
||||
foreach ($output as $file => $content) {
|
||||
if (count($content) <= 1 && $file != $this->__filename) {
|
||||
@$output[$this->__filename][1] = array_unique(array_merge($output[$this->__filename][1], $content[1]));
|
||||
|
||||
if(!isset($output[$this->__filename][0])) {
|
||||
if (!isset($output[$this->__filename][0])) {
|
||||
$output[$this->__filename][0] = $content[0];
|
||||
}
|
||||
unset($content[0]);
|
||||
unset($content[1]);
|
||||
|
||||
foreach($content as $msgid) {
|
||||
foreach ($content as $msgid) {
|
||||
$output[$this->__filename][] = $msgid;
|
||||
}
|
||||
unset($output[$file]);
|
||||
|
@ -448,7 +448,7 @@ class ExtractShell extends Shell{
|
|||
function __formatString($string) {
|
||||
$quote = substr($string, 0, 1);
|
||||
$string = substr($string, 1, -1);
|
||||
if($quote == '"') {
|
||||
if ($quote == '"') {
|
||||
$string = stripcslashes($string);
|
||||
} else {
|
||||
$string = strtr($string, array("\\'" => "'", "\\\\" => "\\"));
|
||||
|
@ -461,16 +461,16 @@ class ExtractShell extends Shell{
|
|||
$tokenCount = count($this->__tokens);
|
||||
$parenthesis = 1;
|
||||
|
||||
while((($tokenCount - $count) > 0) && $parenthesis) {
|
||||
if(is_array($this->__tokens[$count])) {
|
||||
while ((($tokenCount - $count) > 0) && $parenthesis) {
|
||||
if (is_array($this->__tokens[$count])) {
|
||||
$this->out($this->__tokens[$count][1], false);
|
||||
} else {
|
||||
$this->out($this->__tokens[$count], false);
|
||||
if($this->__tokens[$count] == "(") {
|
||||
if ($this->__tokens[$count] == "(") {
|
||||
$parenthesis++;
|
||||
}
|
||||
|
||||
if($this->__tokens[$count] == ")") {
|
||||
if ($this->__tokens[$count] == ")") {
|
||||
$parenthesis--;
|
||||
}
|
||||
}
|
||||
|
@ -479,16 +479,16 @@ class ExtractShell extends Shell{
|
|||
$this->out("\n", true);
|
||||
}
|
||||
function __searchDirectory($path = null) {
|
||||
if($path === null){
|
||||
if ($path === null){
|
||||
$path = $this->path .DS;
|
||||
}
|
||||
$files = glob("$path*.{php,ctp,thtml,inc,tpl}", GLOB_BRACE);
|
||||
$dirs = glob("$path*", GLOB_ONLYDIR);
|
||||
|
||||
foreach($dirs as $dir) {
|
||||
if(!preg_match("!(^|.+/)(CVS|.svn)$!", $dir)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (!preg_match("!(^|.+/)(CVS|.svn)$!", $dir)) {
|
||||
$files = array_merge($files, $this->__searchDirectory("$dir" . DS));
|
||||
if(($id = array_search($dir . DS . 'extract.php', $files)) !== FALSE) {
|
||||
if (($id = array_search($dir . DS . 'extract.php', $files)) !== FALSE) {
|
||||
unset($files[$id]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,8 @@ class Shell extends Object {
|
|||
*/
|
||||
function __construct(&$dispatch) {
|
||||
$vars = array('params', 'args', 'shell', 'shellName'=> 'name', 'shellClass'=> 'className', 'shellCommand'=> 'command');
|
||||
foreach($vars as $key => $var) {
|
||||
if(is_string($key)){
|
||||
foreach ($vars as $key => $var) {
|
||||
if (is_string($key)){
|
||||
$this->{$var} =& $dispatch->{$key};
|
||||
} else {
|
||||
$this->{$var} =& $dispatch->{$var};
|
||||
|
@ -125,10 +125,10 @@ class Shell extends Object {
|
|||
$shellKey = Inflector::underscore($this->name);
|
||||
ClassRegistry::addObject($shellKey, $this);
|
||||
ClassRegistry::map($shellKey, $shellKey);
|
||||
if(!PHP5 && isset($this->args[0]) && strpos(low(get_class($this)), low(Inflector::camelize($this->args[0]))) !== false) {
|
||||
if (!PHP5 && isset($this->args[0]) && strpos(low(get_class($this)), low(Inflector::camelize($this->args[0]))) !== false) {
|
||||
$dispatch->shiftArgs();
|
||||
}
|
||||
if(!PHP5 && isset($this->args[0]) && low($this->command) == low(Inflector::variable($this->args[0])) && method_exists($this, $this->command)) {
|
||||
if (!PHP5 && isset($this->args[0]) && low($this->command) == low(Inflector::variable($this->args[0])) && method_exists($this, $this->command)) {
|
||||
$dispatch->shiftArgs();
|
||||
}
|
||||
$this->Dispatch =& $dispatch;
|
||||
|
@ -170,7 +170,7 @@ class Shell extends Object {
|
|||
* @return bool
|
||||
*/
|
||||
function _loadDbConfig() {
|
||||
if(config('database')) {
|
||||
if (config('database')) {
|
||||
if (class_exists('DATABASE_CONFIG')) {
|
||||
$this->dbConfig = new DATABASE_CONFIG();
|
||||
return true;
|
||||
|
@ -190,7 +190,7 @@ class Shell extends Object {
|
|||
*/
|
||||
function _loadModels() {
|
||||
|
||||
if($this->uses === null || $this->uses === false) {
|
||||
if ($this->uses === null || $this->uses === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ class Shell extends Object {
|
|||
'model'.DS.'datasources'.DS.'dbo_source', 'model'.DS.'model'
|
||||
);
|
||||
|
||||
if($this->uses === true && loadModel()) {
|
||||
if ($this->uses === true && loadModel()) {
|
||||
$this->AppModel = & new AppModel(false, false, false);
|
||||
return true;
|
||||
}
|
||||
|
@ -207,13 +207,13 @@ class Shell extends Object {
|
|||
$uses = is_array($this->uses) ? $this->uses : array($this->uses);
|
||||
$this->modelClass = $uses[0];
|
||||
|
||||
foreach($uses as $modelClass) {
|
||||
foreach ($uses as $modelClass) {
|
||||
$modelKey = Inflector::underscore($modelClass);
|
||||
|
||||
if(!class_exists($modelClass)){
|
||||
if (!class_exists($modelClass)){
|
||||
loadModel($modelClass);
|
||||
}
|
||||
if(class_exists($modelClass)) {
|
||||
if (class_exists($modelClass)) {
|
||||
$model =& new $modelClass();
|
||||
$this->modelNames[] = $modelClass;
|
||||
$this->{$modelClass} =& $model;
|
||||
|
@ -232,20 +232,20 @@ class Shell extends Object {
|
|||
* @return bool
|
||||
*/
|
||||
function loadTasks() {
|
||||
if($this->tasks === null || $this->tasks === false) {
|
||||
if ($this->tasks === null || $this->tasks === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->tasks !== true && !empty($this->tasks)) {
|
||||
|
||||
$tasks = $this->tasks;
|
||||
if(!is_array($tasks)) {
|
||||
if (!is_array($tasks)) {
|
||||
$tasks = array($tasks);
|
||||
}
|
||||
|
||||
foreach($tasks as $taskName) {
|
||||
foreach ($tasks as $taskName) {
|
||||
$loaded = false;
|
||||
foreach($this->Dispatch->shellPaths as $path) {
|
||||
foreach ($this->Dispatch->shellPaths as $path) {
|
||||
$taskPath = $path . 'tasks' . DS . Inflector::underscore($taskName).'.php';
|
||||
if (file_exists($taskPath)) {
|
||||
$loaded = true;
|
||||
|
@ -256,7 +256,7 @@ class Shell extends Object {
|
|||
if ($loaded) {
|
||||
$taskKey = Inflector::underscore($taskName);
|
||||
$taskClass = Inflector::camelize($taskName.'Task');
|
||||
if(!class_exists($taskClass)) {
|
||||
if (!class_exists($taskClass)) {
|
||||
require_once $taskPath;
|
||||
}
|
||||
if (ClassRegistry::isKeySet($taskKey)) {
|
||||
|
@ -277,7 +277,7 @@ class Shell extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if(!isset($this->{$taskName})) {
|
||||
if (!isset($this->{$taskName})) {
|
||||
$this->err("Task '".$taskName."' could not be loaded");
|
||||
exit();
|
||||
}
|
||||
|
@ -300,21 +300,21 @@ class Shell extends Object {
|
|||
*/
|
||||
function in($prompt, $options = null, $default = null) {
|
||||
$in = $this->Dispatch->getInput($prompt, $options, $default);
|
||||
if($options && is_string($options)) {
|
||||
if(strpos($options, ',')) {
|
||||
if ($options && is_string($options)) {
|
||||
if (strpos($options, ',')) {
|
||||
$options = explode(',', $options);
|
||||
} else if(strpos($options, '/')) {
|
||||
} elseif (strpos($options, '/')) {
|
||||
$options = explode('/', $options);
|
||||
} else {
|
||||
$options = array($options);
|
||||
}
|
||||
}
|
||||
if(is_array($options)) {
|
||||
while($in == '' || ($in && (!in_array(low($in), $options) && !in_array(up($in), $options)) && !in_array($in, $options))) {
|
||||
if (is_array($options)) {
|
||||
while ($in == '' || ($in && (!in_array(low($in), $options) && !in_array(up($in), $options)) && !in_array($in, $options))) {
|
||||
$in = $this->Dispatch->getInput($prompt, $options, $default);
|
||||
}
|
||||
}
|
||||
if($in) {
|
||||
if ($in) {
|
||||
return $in;
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ class Shell extends Object {
|
|||
* @param unknown_type $command
|
||||
*/
|
||||
function _checkArgs($expectedNum, $command = null) {
|
||||
if(!$command) {
|
||||
if (!$command) {
|
||||
$command = $this->command;
|
||||
}
|
||||
if (count($this->args) < $expectedNum) {
|
||||
|
@ -390,14 +390,14 @@ class Shell extends Object {
|
|||
if (low($key) == 'q') {
|
||||
$this->out(__("Quitting.", true) ."\n");
|
||||
exit;
|
||||
} else if (low($key) == 'a') {
|
||||
} elseif (low($key) == 'a') {
|
||||
$this->dont_ask = true;
|
||||
} else if (low($key) != 'y') {
|
||||
} elseif (low($key) != 'y') {
|
||||
$this->out(__("Skip", true) ." {$path}\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(!class_exists('File')) {
|
||||
if (!class_exists('File')) {
|
||||
uses('file');
|
||||
}
|
||||
if ($File = new File($path, true)) {
|
||||
|
@ -414,7 +414,7 @@ class Shell extends Object {
|
|||
*
|
||||
*/
|
||||
function help() {
|
||||
if($this->command != null) {
|
||||
if ($this->command != null) {
|
||||
$this->err("Unknown {$this->name} command '$this->command'.\nFor usage, try 'cake {$this->shell} help'.\n\n");
|
||||
} else{
|
||||
$this->Dispatch->help();
|
||||
|
|
|
@ -51,21 +51,21 @@ class ControllerTask extends Shell {
|
|||
* @return void
|
||||
*/
|
||||
function execute() {
|
||||
if(empty($this->args)) {
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
}
|
||||
|
||||
if(isset($this->args[0])) {
|
||||
if (isset($this->args[0])) {
|
||||
$controller = Inflector::camelize($this->args[0]);
|
||||
$actions = null;
|
||||
if(isset($this->args[1]) && $this->args[1] == 'scaffold') {
|
||||
if (isset($this->args[1]) && $this->args[1] == 'scaffold') {
|
||||
$this->out('Baking scaffold for ' . $controller);
|
||||
$actions = $this->__bakeActions($controller);
|
||||
} else {
|
||||
$actions = 'scaffold';
|
||||
}
|
||||
if(isset($this->args[2]) && $this->args[2] == 'admin') {
|
||||
if($admin = $this->getAdmin()) {
|
||||
if (isset($this->args[2]) && $this->args[2] == 'admin') {
|
||||
if ($admin = $this->getAdmin()) {
|
||||
$this->out('Adding ' . CAKE_ADMIN .' methods');
|
||||
if ($actions == 'scaffold') {
|
||||
$actions = $this->__bakeActions($controller, $admin);
|
||||
|
@ -155,12 +155,12 @@ class ControllerTask extends Shell {
|
|||
|
||||
if (low($wannaDoScaffolding) == 'y' || low($wannaDoScaffolding) == 'yes') {
|
||||
$actions = $this->__bakeActions($controllerName, null, $wannaUseSession);
|
||||
if($admin) {
|
||||
if ($admin) {
|
||||
$actions .= $this->__bakeActions($controllerName, $admin, $wannaUseSession);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->interactive === true) {
|
||||
if ($this->interactive === true) {
|
||||
$this->out('');
|
||||
$this->hr();
|
||||
$this->out('The following controller will be created:');
|
||||
|
@ -171,10 +171,10 @@ class ControllerTask extends Shell {
|
|||
$this->out(" var \$scaffold;");
|
||||
$actions = 'scaffold';
|
||||
}
|
||||
if(count($uses)) {
|
||||
if (count($uses)) {
|
||||
$this->out("Uses: ", false);
|
||||
|
||||
foreach($uses as $use) {
|
||||
foreach ($uses as $use) {
|
||||
if ($use != $uses[count($uses) - 1]) {
|
||||
$this->out(ucfirst($use) . ", ", false);
|
||||
} else {
|
||||
|
@ -183,10 +183,10 @@ class ControllerTask extends Shell {
|
|||
}
|
||||
}
|
||||
|
||||
if(count($helpers)) {
|
||||
if (count($helpers)) {
|
||||
$this->out("Helpers: ", false);
|
||||
|
||||
foreach($helpers as $help) {
|
||||
foreach ($helpers as $help) {
|
||||
if ($help != $helpers[count($helpers) - 1]) {
|
||||
$this->out(ucfirst($help) . ", ", false);
|
||||
} else {
|
||||
|
@ -195,10 +195,10 @@ class ControllerTask extends Shell {
|
|||
}
|
||||
}
|
||||
|
||||
if(count($components)) {
|
||||
if (count($components)) {
|
||||
$this->out("Components: ", false);
|
||||
|
||||
foreach($components as $comp) {
|
||||
foreach ($components as $comp) {
|
||||
if ($comp != $components[count($components) - 1]) {
|
||||
$this->out(ucfirst($comp) . ", ", false);
|
||||
} else {
|
||||
|
@ -228,7 +228,7 @@ class ControllerTask extends Shell {
|
|||
|
||||
function __bakeActions($controllerName, $admin = null, $wannaUseSession = 'y') {
|
||||
$currentModelName = $this->_modelName($controllerName);
|
||||
if(!loadModel($currentModelName)) {
|
||||
if (!loadModel($currentModelName)) {
|
||||
$this->out('You must have a model for this class to build scaffold methods. Please try again.');
|
||||
exit;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ class ControllerTask extends Shell {
|
|||
$actions .= "\t}\n";
|
||||
$actions .= "\n";
|
||||
$actions .= "\tfunction {$admin}view(\$id = null) {\n";
|
||||
$actions .= "\t\tif(!\$id) {\n";
|
||||
$actions .= "\t\tif (!\$id) {\n";
|
||||
if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
|
||||
$actions .= "\t\t\t\$this->Session->setFlash('Invalid {$singularHumanName}.');\n";
|
||||
$actions .= "\t\t\t\$this->redirect(array('action'=>'index'), null, true);\n";
|
||||
|
@ -261,10 +261,10 @@ class ControllerTask extends Shell {
|
|||
/* ADD ACTION */
|
||||
$compact = array();
|
||||
$actions .= "\tfunction {$admin}add() {\n";
|
||||
$actions .= "\t\tif(!empty(\$this->data)) {\n";
|
||||
$actions .= "\t\tif (!empty(\$this->data)) {\n";
|
||||
$actions .= "\t\t\t\$this->cleanUpFields();\n";
|
||||
$actions .= "\t\t\t\$this->{$currentModelName}->create();\n";
|
||||
$actions .= "\t\t\tif(\$this->{$currentModelName}->save(\$this->data)) {\n";
|
||||
$actions .= "\t\t\tif (\$this->{$currentModelName}->save(\$this->data)) {\n";
|
||||
if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
|
||||
$actions .= "\t\t\t\t\$this->Session->setFlash('The ".$singularHumanName." has been saved');\n";
|
||||
$actions .= "\t\t\t\t\$this->redirect(array('action'=>'index'), null, true);\n";
|
||||
|
@ -278,8 +278,8 @@ class ControllerTask extends Shell {
|
|||
}
|
||||
$actions .= "\t\t\t}\n";
|
||||
$actions .= "\t\t}\n";
|
||||
foreach($modelObj->hasAndBelongsToMany as $associationName => $relation) {
|
||||
if(!empty($associationName)) {
|
||||
foreach ($modelObj->hasAndBelongsToMany as $associationName => $relation) {
|
||||
if (!empty($associationName)) {
|
||||
$habtmModelName = $this->_modelName($associationName);
|
||||
$habtmSingularName = $this->_singularName($associationName);
|
||||
$habtmPluralName = $this->_pluralName($associationName);
|
||||
|
@ -287,15 +287,15 @@ class ControllerTask extends Shell {
|
|||
$compact[] = "'{$habtmPluralName}'";
|
||||
}
|
||||
}
|
||||
foreach($modelObj->belongsTo as $associationName => $relation) {
|
||||
if(!empty($associationName)) {
|
||||
foreach ($modelObj->belongsTo as $associationName => $relation) {
|
||||
if (!empty($associationName)) {
|
||||
$belongsToModelName = $this->_modelName($associationName);
|
||||
$belongsToPluralName = $this->_pluralName($associationName);
|
||||
$actions .= "\t\t\${$belongsToPluralName} = \$this->{$currentModelName}->{$belongsToModelName}->generateList();\n";
|
||||
$compact[] = "'{$belongsToPluralName}'";
|
||||
}
|
||||
}
|
||||
if(!empty($compact)) {
|
||||
if (!empty($compact)) {
|
||||
$actions .= "\t\t\$this->set(compact(".join(', ', $compact)."));\n";
|
||||
}
|
||||
$actions .= "\t}\n";
|
||||
|
@ -304,7 +304,7 @@ class ControllerTask extends Shell {
|
|||
/* EDIT ACTION */
|
||||
$compact = array();
|
||||
$actions .= "\tfunction {$admin}edit(\$id = null) {\n";
|
||||
$actions .= "\t\tif(!\$id && empty(\$this->data)) {\n";
|
||||
$actions .= "\t\tif (!\$id && empty(\$this->data)) {\n";
|
||||
if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
|
||||
$actions .= "\t\t\t\$this->Session->setFlash('Invalid {$singularHumanName}');\n";
|
||||
$actions .= "\t\t\t\$this->redirect(array('action'=>'index'), null, true);\n";
|
||||
|
@ -313,9 +313,9 @@ class ControllerTask extends Shell {
|
|||
$actions .= "\t\t\texit();\n";
|
||||
}
|
||||
$actions .= "\t\t}\n";
|
||||
$actions .= "\t\tif(!empty(\$this->data)) {\n";
|
||||
$actions .= "\t\tif (!empty(\$this->data)) {\n";
|
||||
$actions .= "\t\t\t\$this->cleanUpFields();\n";
|
||||
$actions .= "\t\t\tif(\$this->{$currentModelName}->save(\$this->data)) {\n";
|
||||
$actions .= "\t\t\tif (\$this->{$currentModelName}->save(\$this->data)) {\n";
|
||||
if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
|
||||
$actions .= "\t\t\t\t\$this->Session->setFlash('The ".$singularHumanName." saved');\n";
|
||||
$actions .= "\t\t\t\t\$this->redirect(array('action'=>'index'), null, true);\n";
|
||||
|
@ -329,12 +329,12 @@ class ControllerTask extends Shell {
|
|||
}
|
||||
$actions .= "\t\t\t}\n";
|
||||
$actions .= "\t\t}\n";
|
||||
$actions .= "\t\tif(empty(\$this->data)) {\n";
|
||||
$actions .= "\t\tif (empty(\$this->data)) {\n";
|
||||
$actions .= "\t\t\t\$this->data = \$this->{$currentModelName}->read(null, \$id);\n";
|
||||
$actions .= "\t\t}\n";
|
||||
|
||||
foreach($modelObj->hasAndBelongsToMany as $associationName => $relation) {
|
||||
if(!empty($associationName)) {
|
||||
foreach ($modelObj->hasAndBelongsToMany as $associationName => $relation) {
|
||||
if (!empty($associationName)) {
|
||||
$habtmModelName = $this->_modelName($associationName);
|
||||
$habtmSingularName = $this->_singularName($associationName);
|
||||
$habtmPluralName = $this->_pluralName($associationName);
|
||||
|
@ -342,21 +342,21 @@ class ControllerTask extends Shell {
|
|||
$compact[] = "'{$habtmPluralName}'";
|
||||
}
|
||||
}
|
||||
foreach($modelObj->belongsTo as $associationName => $relation) {
|
||||
if(!empty($associationName)) {
|
||||
foreach ($modelObj->belongsTo as $associationName => $relation) {
|
||||
if (!empty($associationName)) {
|
||||
$belongsToModelName = $this->_modelName($associationName);
|
||||
$belongsToPluralName = $this->_pluralName($associationName);
|
||||
$actions .= "\t\t\${$belongsToPluralName} = \$this->{$currentModelName}->{$belongsToModelName}->generateList();\n";
|
||||
$compact[] = "'{$belongsToPluralName}'";
|
||||
}
|
||||
}
|
||||
if(!empty($compact)) {
|
||||
if (!empty($compact)) {
|
||||
$actions .= "\t\t\$this->set(compact(".join(',', $compact)."));\n";
|
||||
}
|
||||
$actions .= "\t}\n";
|
||||
$actions .= "\n";
|
||||
$actions .= "\tfunction {$admin}delete(\$id = null) {\n";
|
||||
$actions .= "\t\tif(!\$id) {\n";
|
||||
$actions .= "\t\tif (!\$id) {\n";
|
||||
if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
|
||||
$actions .= "\t\t\t\$this->Session->setFlash('Invalid id for {$singularHumanName}');\n";
|
||||
$actions .= "\t\t\t\$this->redirect(array('action'=>'index'), null, true);\n";
|
||||
|
@ -364,7 +364,7 @@ class ControllerTask extends Shell {
|
|||
$actions .= "\t\t\t\$this->flash('Invalid {$singularHumanName}', array('action'=>'index'));\n";
|
||||
}
|
||||
$actions .= "\t\t}\n";
|
||||
$actions .= "\t\tif(\$this->{$currentModelName}->del(\$id)) {\n";
|
||||
$actions .= "\t\tif (\$this->{$currentModelName}->del(\$id)) {\n";
|
||||
if (low($wannaUseSession) == 'y' || low($wannaUseSession) == 'yes') {
|
||||
$actions .= "\t\t\t\$this->Session->setFlash('".$singularHumanName." #'.\$id.' deleted');\n";
|
||||
$actions .= "\t\t\t\$this->redirect(array('action'=>'index'), null, true);\n";
|
||||
|
@ -392,14 +392,14 @@ class ControllerTask extends Shell {
|
|||
$out .= "class $controllerName" . "Controller extends AppController {\n\n";
|
||||
$out .= "\tvar \$name = '$controllerName';\n";
|
||||
|
||||
if(low($actions) == 'scaffold') {
|
||||
if (low($actions) == 'scaffold') {
|
||||
$out .= "\tvar \$scaffold;\n";
|
||||
} else {
|
||||
|
||||
if (count($uses)) {
|
||||
$out .= "\tvar \$uses = array('" . $this->_modelName($controllerName) . "', ";
|
||||
|
||||
foreach($uses as $use) {
|
||||
foreach ($uses as $use) {
|
||||
if ($use != $uses[count($uses) - 1]) {
|
||||
$out .= "'" . $this->_modelName($use) . "', ";
|
||||
} else {
|
||||
|
@ -411,7 +411,7 @@ class ControllerTask extends Shell {
|
|||
|
||||
$out .= "\tvar \$helpers = array('Html', 'Form' ";
|
||||
if (count($helpers)) {
|
||||
foreach($helpers as $help) {
|
||||
foreach ($helpers as $help) {
|
||||
if ($help != $helpers[count($helpers) - 1]) {
|
||||
$out .= ", '" . Inflector::camelize($help) . "'";
|
||||
} else {
|
||||
|
@ -424,7 +424,7 @@ class ControllerTask extends Shell {
|
|||
if (count($components)) {
|
||||
$out .= "\tvar \$components = array(";
|
||||
|
||||
foreach($components as $comp) {
|
||||
foreach ($components as $comp) {
|
||||
if ($comp != $components[count($components) - 1]) {
|
||||
$out .= "'" . Inflector::camelize($comp) . "', ";
|
||||
} else {
|
||||
|
@ -463,7 +463,7 @@ class ControllerTask extends Shell {
|
|||
|
||||
$this->out("Baking unit test for $className...");
|
||||
$Folder =& new Folder($path, true);
|
||||
if($path = $Folder->cd($path)) {
|
||||
if ($path = $Folder->cd($path)) {
|
||||
$path = $Folder->slashTerm($path);
|
||||
return $this->createFile($path . $filename, $out);
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ class ControllerTask extends Shell {
|
|||
*/
|
||||
function getAdmin() {
|
||||
$admin = null;
|
||||
if(defined('CAKE_ADMIN')) {
|
||||
if (defined('CAKE_ADMIN')) {
|
||||
$admin = CAKE_ADMIN.'_';
|
||||
} else {
|
||||
$this->out('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
|
||||
|
@ -545,7 +545,7 @@ class ControllerTask extends Shell {
|
|||
while ($admin == '') {
|
||||
$admin = $this->in("What would you like the admin route to be?", null, 'admin');
|
||||
}
|
||||
if($this->Project->cakeAdmin($admin) !== true){
|
||||
if ($this->Project->cakeAdmin($admin) !== true){
|
||||
$this->out('Unable to write to /app/config/core.php.');
|
||||
$this->out('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
|
||||
exit();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
if(!class_exists('File')) {
|
||||
if (!class_exists('File')) {
|
||||
uses('file');
|
||||
}
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ class DbConfigTask extends Shell {
|
|||
* @return void
|
||||
*/
|
||||
function execute() {
|
||||
if(empty($this->args)) {
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class DbConfigTask extends Shell {
|
|||
while ($persistent == '') {
|
||||
$persistent = $this->in('Persistent Connection?', array('y', 'n'), 'n');
|
||||
}
|
||||
if(low($persistent) == 'n') {
|
||||
if (low($persistent) == 'n') {
|
||||
$persistent = 'false';
|
||||
} else {
|
||||
$persistent = 'true';
|
||||
|
@ -87,7 +87,7 @@ class DbConfigTask extends Shell {
|
|||
$password = $this->in('Password:');
|
||||
if ($password == '') {
|
||||
$blank = $this->in('The password you supplied was empty. Use an empty password?', array('y', 'n'), 'n');
|
||||
if($blank == 'y')
|
||||
if ($blank == 'y')
|
||||
{
|
||||
$blankPassword = true;
|
||||
}
|
||||
|
@ -103,12 +103,12 @@ class DbConfigTask extends Shell {
|
|||
while ($prefix == '') {
|
||||
$prefix = $this->in('Table Prefix?', null, 'n');
|
||||
}
|
||||
if(low($prefix) == 'n') {
|
||||
if (low($prefix) == 'n') {
|
||||
$prefix = null;
|
||||
}
|
||||
|
||||
$config = compact('driver', 'persistent', 'host', 'login', 'password', 'database', 'prefix');
|
||||
while($this->__verify($config) == false) {
|
||||
while ($this->__verify($config) == false) {
|
||||
$this->__interactive();
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ class DbConfigTask extends Shell {
|
|||
$config = am($defaults, $config);
|
||||
extract($config);
|
||||
|
||||
if(is_dir(CONFIGS)) {
|
||||
if (is_dir(CONFIGS)) {
|
||||
$out = "<?php\n";
|
||||
$out .= "class DATABASE_CONFIG {\n\n";
|
||||
$out .= "\tvar \$default = array(\n";
|
||||
|
@ -172,7 +172,7 @@ class DbConfigTask extends Shell {
|
|||
$out .= "\t\t'login' => '{$login}',\n";
|
||||
$out .= "\t\t'password' => '{$password}',\n";
|
||||
$out .= "\t\t'database' => '{$database}', \n";
|
||||
if($schema) {
|
||||
if ($schema) {
|
||||
$out .= "\t\t'schema' => '{$schema}', \n";
|
||||
}
|
||||
$out .= "\t\t'prefix' => '{$prefix}' \n";
|
||||
|
|
|
@ -40,7 +40,7 @@ class ModelTask extends Shell {
|
|||
* @return void
|
||||
*/
|
||||
function execute() {
|
||||
if(empty($this->args)) {
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class ModelTask extends Shell {
|
|||
$tableIsGood = false;
|
||||
$useTable = Inflector::tableize($currentModelName);
|
||||
$fullTableName = $db->fullTableName($useTable, false);
|
||||
if(array_search($useTable, $this->__tables) === false) {
|
||||
if (array_search($useTable, $this->__tables) === false) {
|
||||
$this->out("\nGiven your model named '$currentModelName', Cake would expect a database table named '" . $fullTableName . "'.");
|
||||
$tableIsGood = $this->in('do you want to use this table?', array('y','n'), 'y');
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class ModelTask extends Shell {
|
|||
if (low($tableIsGood) == 'n' || low($tableIsGood) == 'no') {
|
||||
$useTable = $this->in('What is the name of the table (enter "null" to use NO table)?');
|
||||
}
|
||||
while($tableIsGood == false && low($useTable) != 'null') {
|
||||
while ($tableIsGood == false && low($useTable) != 'null') {
|
||||
if (is_array($this->__tables) && !in_array($useTable, $this->__tables)) {
|
||||
$fullTableName = $db->fullTableName($useTable, false);
|
||||
$this->out($fullTableName . ' does not exist.');
|
||||
|
@ -92,18 +92,18 @@ class ModelTask extends Shell {
|
|||
}
|
||||
$wannaDoValidation = $this->in('Would you like to supply validation criteria for the fields in your model?', array('y','n'), 'y');
|
||||
|
||||
if(in_array($useTable, $this->__tables)) {
|
||||
if (in_array($useTable, $this->__tables)) {
|
||||
loadModel();
|
||||
$tempModel = new Model(false, $useTable);
|
||||
$modelFields = $db->describe($tempModel);
|
||||
if(isset($modelFields[0]['name']) && $modelFields[0]['name'] != 'id') {
|
||||
if (isset($modelFields[0]['name']) && $modelFields[0]['name'] != 'id') {
|
||||
$primaryKey = $this->in('What is the primaryKey?', null, $modelFields[0]['name']);
|
||||
}
|
||||
}
|
||||
$validate = array();
|
||||
|
||||
if (array_search($useTable, $this->__tables) !== false && (low($wannaDoValidation) == 'y' || low($wannaDoValidation) == 'yes')) {
|
||||
foreach($modelFields as $field) {
|
||||
foreach ($modelFields as $field) {
|
||||
$this->out('');
|
||||
$prompt = 'Name: ' . $field['name'] . "\n";
|
||||
$prompt .= 'Type: ' . $field['type'] . "\n";
|
||||
|
@ -117,7 +117,7 @@ class ModelTask extends Shell {
|
|||
$prompt .= "5- Do not do any validation on this field.\n\n";
|
||||
$prompt .= "... or enter in a valid regex validation string.\n\n";
|
||||
|
||||
if($field['null'] == 1 || $field['name'] == $primaryKey || $field['name'] == 'created' || $field['name'] == 'modified') {
|
||||
if ($field['null'] == 1 || $field['name'] == $primaryKey || $field['name'] == 'created' || $field['name'] == 'modified') {
|
||||
$validation = $this->in($prompt, null, '5');
|
||||
} else {
|
||||
$validation = $this->in($prompt, null, '1');
|
||||
|
@ -147,14 +147,14 @@ class ModelTask extends Shell {
|
|||
|
||||
$wannaDoAssoc = $this->in('Would you like to define model associations (hasMany, hasOne, belongsTo, etc.)?', array('y','n'), 'y');
|
||||
|
||||
if((low($wannaDoAssoc) == 'y' || low($wannaDoAssoc) == 'yes')) {
|
||||
if ((low($wannaDoAssoc) == 'y' || low($wannaDoAssoc) == 'yes')) {
|
||||
$this->out('One moment while I try to detect any associations...');
|
||||
$possibleKeys = array();
|
||||
//Look for belongsTo
|
||||
$i = 0;
|
||||
foreach($modelFields as $field) {
|
||||
foreach ($modelFields as $field) {
|
||||
$offset = strpos($field['name'], '_id');
|
||||
if($field['name'] != $primaryKey && $offset !== false) {
|
||||
if ($field['name'] != $primaryKey && $offset !== false) {
|
||||
$tmpModelName = $this->_modelNameFromKey($field['name']);
|
||||
$associations['belongsTo'][$i]['alias'] = $tmpModelName;
|
||||
$associations['belongsTo'][$i]['className'] = $tmpModelName;
|
||||
|
@ -165,14 +165,14 @@ class ModelTask extends Shell {
|
|||
//Look for hasOne and hasMany and hasAndBelongsToMany
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
foreach($this->__tables as $otherTable) {
|
||||
foreach ($this->__tables as $otherTable) {
|
||||
$tempOtherModel = & new Model(false, $otherTable);
|
||||
$modelFieldsTemp = $db->describe($tempOtherModel);
|
||||
foreach($modelFieldsTemp as $field) {
|
||||
if($field['type'] == 'integer' || $field['type'] == 'string') {
|
||||
foreach ($modelFieldsTemp as $field) {
|
||||
if ($field['type'] == 'integer' || $field['type'] == 'string') {
|
||||
$possibleKeys[$otherTable][] = $field['name'];
|
||||
}
|
||||
if($field['name'] != $primaryKey && $field['name'] == $this->_modelKey($currentModelName)) {
|
||||
if ($field['name'] != $primaryKey && $field['name'] == $this->_modelKey($currentModelName)) {
|
||||
$tmpModelName = $this->_modelName($otherTable);
|
||||
$associations['hasOne'][$j]['alias'] = $tmpModelName;
|
||||
$associations['hasOne'][$j]['className'] = $tmpModelName;
|
||||
|
@ -185,7 +185,7 @@ class ModelTask extends Shell {
|
|||
}
|
||||
}
|
||||
$offset = strpos($otherTable, $useTable . '_');
|
||||
if($offset !== false) {
|
||||
if ($offset !== false) {
|
||||
$offset = strlen($useTable . '_');
|
||||
$tmpModelName = $this->_modelName(substr($otherTable, $offset));
|
||||
$associations['hasAndBelongsToMany'][$i]['alias'] = $tmpModelName;
|
||||
|
@ -209,20 +209,20 @@ class ModelTask extends Shell {
|
|||
$this->out('Done.');
|
||||
$this->hr();
|
||||
//if none found...
|
||||
if(empty($associations)) {
|
||||
if (empty($associations)) {
|
||||
$this->out('None found.');
|
||||
} else {
|
||||
$this->out('Please confirm the following associations:');
|
||||
$this->hr();
|
||||
if(!empty($associations['belongsTo'])) {
|
||||
if (!empty($associations['belongsTo'])) {
|
||||
$count = count($associations['belongsTo']);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
if($currentModelName == $associations['belongsTo'][$i]['alias']) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($currentModelName == $associations['belongsTo'][$i]['alias']) {
|
||||
$response = $this->in("{$currentModelName} belongsTo {$associations['belongsTo'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y');
|
||||
if('y' == low($response) || 'yes' == low($response)) {
|
||||
if ('y' == low($response) || 'yes' == low($response)) {
|
||||
$associations['belongsTo'][$i]['alias'] = $this->in("So what is the alias?", null, $associations['belongsTo'][$i]['alias']);
|
||||
}
|
||||
if($currentModelName != $associations['belongsTo'][$i]['alias']) {
|
||||
if ($currentModelName != $associations['belongsTo'][$i]['alias']) {
|
||||
$response = $this->in("$currentModelName belongsTo {$associations['belongsTo'][$i]['alias']}?", array('y','n'), 'y');
|
||||
} else {
|
||||
$response = 'n';
|
||||
|
@ -230,22 +230,22 @@ class ModelTask extends Shell {
|
|||
} else {
|
||||
$response = $this->in("$currentModelName belongsTo {$associations['belongsTo'][$i]['alias']}?", array('y','n'), 'y');
|
||||
}
|
||||
if('n' == low($response) || 'no' == low($response)) {
|
||||
if ('n' == low($response) || 'no' == low($response)) {
|
||||
unset($associations['belongsTo'][$i]);
|
||||
}
|
||||
}
|
||||
$associations['belongsTo'] = array_merge($associations['belongsTo']);
|
||||
}
|
||||
|
||||
if(!empty($associations['hasOne'])) {
|
||||
if (!empty($associations['hasOne'])) {
|
||||
$count = count($associations['hasOne']);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
if($currentModelName == $associations['hasOne'][$i]['alias']) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($currentModelName == $associations['hasOne'][$i]['alias']) {
|
||||
$response = $this->in("{$currentModelName} hasOne {$associations['hasOne'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y');
|
||||
if('y' == low($response) || 'yes' == low($response)) {
|
||||
if ('y' == low($response) || 'yes' == low($response)) {
|
||||
$associations['hasOne'][$i]['alias'] = $this->in("So what is the alias?", null, $associations['hasOne'][$i]['alias']);
|
||||
}
|
||||
if($currentModelName != $associations['hasOne'][$i]['alias']) {
|
||||
if ($currentModelName != $associations['hasOne'][$i]['alias']) {
|
||||
$response = $this->in("$currentModelName hasOne {$associations['hasOne'][$i]['alias']}?", array('y','n'), 'y');
|
||||
} else {
|
||||
$response = 'n';
|
||||
|
@ -253,22 +253,22 @@ class ModelTask extends Shell {
|
|||
} else {
|
||||
$response = $this->in("$currentModelName hasOne {$associations['hasOne'][$i]['alias']}?", array('y','n'), 'y');
|
||||
}
|
||||
if('n' == low($response) || 'no' == low($response)) {
|
||||
if ('n' == low($response) || 'no' == low($response)) {
|
||||
unset($associations['hasOne'][$i]);
|
||||
}
|
||||
}
|
||||
$associations['hasOne'] = array_merge($associations['hasOne']);
|
||||
}
|
||||
|
||||
if(!empty($associations['hasMany'])) {
|
||||
if (!empty($associations['hasMany'])) {
|
||||
$count = count($associations['hasMany']);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
if($currentModelName == $associations['hasMany'][$i]['alias']) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($currentModelName == $associations['hasMany'][$i]['alias']) {
|
||||
$response = $this->in("{$currentModelName} hasMany {$associations['hasMany'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y');
|
||||
if('y' == low($response) || 'yes' == low($response)) {
|
||||
if ('y' == low($response) || 'yes' == low($response)) {
|
||||
$associations['hasMany'][$i]['alias'] = $this->in("So what is the alias?", null, $associations['hasMany'][$i]['alias']);
|
||||
}
|
||||
if($currentModelName != $associations['hasMany'][$i]['alias']) {
|
||||
if ($currentModelName != $associations['hasMany'][$i]['alias']) {
|
||||
$response = $this->in("$currentModelName hasMany {$associations['hasMany'][$i]['alias']}?", array('y','n'), 'y');
|
||||
} else {
|
||||
$response = 'n';
|
||||
|
@ -276,22 +276,22 @@ class ModelTask extends Shell {
|
|||
} else {
|
||||
$response = $this->in("$currentModelName hasMany {$associations['hasMany'][$i]['alias']}?", array('y','n'), 'y');
|
||||
}
|
||||
if('n' == low($response) || 'no' == low($response)) {
|
||||
if ('n' == low($response) || 'no' == low($response)) {
|
||||
unset($associations['hasMany'][$i]);
|
||||
}
|
||||
}
|
||||
$associations['hasMany'] = array_merge($associations['hasMany']);
|
||||
}
|
||||
|
||||
if(!empty($associations['hasAndBelongsToMany'])) {
|
||||
if (!empty($associations['hasAndBelongsToMany'])) {
|
||||
$count = count($associations['hasAndBelongsToMany']);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
if($currentModelName == $associations['hasAndBelongsToMany'][$i]['alias']) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($currentModelName == $associations['hasAndBelongsToMany'][$i]['alias']) {
|
||||
$response = $this->in("{$currentModelName} hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}\nThis looks like a self join. Do you want to specify an alternate association alias?", array('y','n'), 'y');
|
||||
if('y' == low($response) || 'yes' == low($response)) {
|
||||
if ('y' == low($response) || 'yes' == low($response)) {
|
||||
$associations['hasAndBelongsToMany'][$i]['alias'] = $this->in("So what is the alias?", null, $associations['hasAndBelongsToMany'][$i]['alias']);
|
||||
}
|
||||
if($currentModelName != $associations['hasAndBelongsToMany'][$i]['alias']) {
|
||||
if ($currentModelName != $associations['hasAndBelongsToMany'][$i]['alias']) {
|
||||
$response = $this->in("$currentModelName hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}?", array('y','n'), 'y');
|
||||
} else {
|
||||
$response = 'n';
|
||||
|
@ -299,7 +299,7 @@ class ModelTask extends Shell {
|
|||
} else {
|
||||
$response = $this->in("$currentModelName hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}?", array('y','n'), 'y');
|
||||
}
|
||||
if('n' == low($response) || 'no' == low($response)) {
|
||||
if ('n' == low($response) || 'no' == low($response)) {
|
||||
unset($associations['hasAndBelongsToMany'][$i]);
|
||||
}
|
||||
}
|
||||
|
@ -308,10 +308,10 @@ class ModelTask extends Shell {
|
|||
}
|
||||
$wannaDoMoreAssoc = $this->in('Would you like to define some additional model associations?', array('y','n'), 'n');
|
||||
|
||||
while((low($wannaDoMoreAssoc) == 'y' || low($wannaDoMoreAssoc) == 'yes')) {
|
||||
while ((low($wannaDoMoreAssoc) == 'y' || low($wannaDoMoreAssoc) == 'yes')) {
|
||||
$assocs = array(1 => 'belongsTo', 2 => 'hasOne', 3 => 'hasMany', 4 => 'hasAndBelongsToMany');
|
||||
$bad = true;
|
||||
while($bad) {
|
||||
while ($bad) {
|
||||
$this->out('What is the association type?');
|
||||
$prompt = "1- belongsTo\n";
|
||||
$prompt .= "2- hasOne\n";
|
||||
|
@ -319,7 +319,7 @@ class ModelTask extends Shell {
|
|||
$prompt .= "4- hasAndBelongsToMany\n";
|
||||
$assocType = intval($this->in($prompt, null, null));
|
||||
|
||||
if(intval($assocType) < 1 || intval($assocType) > 4) {
|
||||
if (intval($assocType) < 1 || intval($assocType) > 4) {
|
||||
$this->out('The selection you entered was invalid. Please enter a number between 1 and 4.');
|
||||
} else {
|
||||
$bad = false;
|
||||
|
@ -330,13 +330,13 @@ class ModelTask extends Shell {
|
|||
$associationName = $this->in('What is the name of this association?');
|
||||
$className = $this->in('What className will '.$associationName.' use?', null, $associationName );
|
||||
$suggestedForeignKey = null;
|
||||
if($assocType == '1') {
|
||||
if ($assocType == '1') {
|
||||
$showKeys = $possibleKeys[$useTable];
|
||||
$suggestedForeignKey = $this->_modelKey($associationName);
|
||||
} else {
|
||||
$otherTable = Inflector::tableize($className);
|
||||
if(in_array($otherTable, $this->__tables)) {
|
||||
if($assocType < '4') {
|
||||
if (in_array($otherTable, $this->__tables)) {
|
||||
if ($assocType < '4') {
|
||||
$showKeys = $possibleKeys[$otherTable];
|
||||
} else {
|
||||
$showKeys = null;
|
||||
|
@ -347,7 +347,7 @@ class ModelTask extends Shell {
|
|||
}
|
||||
$suggestedForeignKey = $this->_modelKey($currentModelName);
|
||||
}
|
||||
if(!empty($showKeys)) {
|
||||
if (!empty($showKeys)) {
|
||||
$this->out('A helpful List of possible keys');
|
||||
for ($i = 0; $i < count($showKeys); $i++) {
|
||||
$this->out($i + 1 . ". " . $showKeys[$i]);
|
||||
|
@ -357,10 +357,10 @@ class ModelTask extends Shell {
|
|||
$foreignKey = $showKeys[intval($foreignKey) - 1];
|
||||
}
|
||||
}
|
||||
if(!isset($foreignKey)) {
|
||||
if (!isset($foreignKey)) {
|
||||
$foreignKey = $this->in('What is the foreignKey? Specify your own.', null, $suggestedForeignKey);
|
||||
}
|
||||
if($assocType == '4') {
|
||||
if ($assocType == '4') {
|
||||
$associationForeignKey = $this->in('What is the associationForeignKey?', null, $this->_modelKey($currentModelName));
|
||||
$joinTable = $this->in('What is the joinTable?');
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ class ModelTask extends Shell {
|
|||
$associations[$assocs[$assocType]][$i]['alias'] = $associationName;
|
||||
$associations[$assocs[$assocType]][$i]['className'] = $className;
|
||||
$associations[$assocs[$assocType]][$i]['foreignKey'] = $foreignKey;
|
||||
if($assocType == '4') {
|
||||
if ($assocType == '4') {
|
||||
$associations[$assocs[$assocType]][$i]['associationForeignKey'] = $associationForeignKey;
|
||||
$associations[$assocs[$assocType]][$i]['joinTable'] = $joinTable;
|
||||
}
|
||||
|
@ -384,34 +384,34 @@ class ModelTask extends Shell {
|
|||
$this->out("Model Name: $currentModelName");
|
||||
$this->out("DB Connection: " . $useDbConfig);
|
||||
$this->out("DB Table: " . $fullTableName);
|
||||
if($primaryKey != 'id') {
|
||||
if ($primaryKey != 'id') {
|
||||
$this->out("Primary Key: " . $primaryKey);
|
||||
}
|
||||
$this->out("Validation: " . print_r($validate, true));
|
||||
|
||||
if(!empty($associations)) {
|
||||
if (!empty($associations)) {
|
||||
$this->out("Associations:");
|
||||
|
||||
if(!empty($associations['belongsTo'])) {
|
||||
for($i = 0; $i < count($associations['belongsTo']); $i++) {
|
||||
if (!empty($associations['belongsTo'])) {
|
||||
for ($i = 0; $i < count($associations['belongsTo']); $i++) {
|
||||
$this->out(" $currentModelName belongsTo {$associations['belongsTo'][$i]['alias']}");
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($associations['hasOne'])) {
|
||||
for($i = 0; $i < count($associations['hasOne']); $i++) {
|
||||
if (!empty($associations['hasOne'])) {
|
||||
for ($i = 0; $i < count($associations['hasOne']); $i++) {
|
||||
$this->out(" $currentModelName hasOne {$associations['hasOne'][$i]['alias']}");
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($associations['hasMany'])) {
|
||||
for($i = 0; $i < count($associations['hasMany']); $i++) {
|
||||
if (!empty($associations['hasMany'])) {
|
||||
for ($i = 0; $i < count($associations['hasMany']); $i++) {
|
||||
$this->out(" $currentModelName hasMany {$associations['hasMany'][$i]['alias']}");
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($associations['hasAndBelongsToMany'])) {
|
||||
for($i = 0; $i < count($associations['hasAndBelongsToMany']); $i++) {
|
||||
if (!empty($associations['hasAndBelongsToMany'])) {
|
||||
for ($i = 0; $i < count($associations['hasAndBelongsToMany']); $i++) {
|
||||
$this->out(" $currentModelName hasAndBelongsToMany {$associations['hasAndBelongsToMany'][$i]['alias']}");
|
||||
}
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ class ModelTask extends Shell {
|
|||
// is unnecessary.
|
||||
$useTable = null;
|
||||
}
|
||||
if($this->__bake($currentModelName, $useDbConfig, $useTable, $primaryKey, $validate, $associations)) {
|
||||
if ($this->__bake($currentModelName, $useDbConfig, $useTable, $primaryKey, $validate, $associations)) {
|
||||
if ($this->_checkUnitTest()) {
|
||||
$this->__bakeTest($currentModelName);
|
||||
}
|
||||
|
@ -467,19 +467,19 @@ class ModelTask extends Shell {
|
|||
if (count($validate)) {
|
||||
$out .= "\tvar \$validate = array(\n";
|
||||
$keys = array_keys($validate);
|
||||
for($i = 0; $i < count($validate); $i++) {
|
||||
for ($i = 0; $i < count($validate); $i++) {
|
||||
$out .= "\t\t'" . $keys[$i] . "' => " . $validate[$keys[$i]] . ",\n";
|
||||
}
|
||||
$out .= "\t);\n";
|
||||
}
|
||||
$out .= "\n";
|
||||
|
||||
if(!empty($associations)) {
|
||||
if (!empty($associations)) {
|
||||
$out.= "\t//The Associations below have been created with all possible keys, those that are not needed can be removed\n";
|
||||
if(!empty($associations['belongsTo'])) {
|
||||
if (!empty($associations['belongsTo'])) {
|
||||
$out .= "\tvar \$belongsTo = array(\n";
|
||||
|
||||
for($i = 0; $i < count($associations['belongsTo']); $i++) {
|
||||
for ($i = 0; $i < count($associations['belongsTo']); $i++) {
|
||||
$out .= "\t\t\t'{$associations['belongsTo'][$i]['alias']}' => ";
|
||||
$out .= "array('className' => '{$associations['belongsTo'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'foreignKey' => '{$associations['belongsTo'][$i]['foreignKey']}',\n";
|
||||
|
@ -492,10 +492,10 @@ class ModelTask extends Shell {
|
|||
$out .= "\t);\n\n";
|
||||
}
|
||||
|
||||
if(!empty($associations['hasOne'])) {
|
||||
if (!empty($associations['hasOne'])) {
|
||||
$out .= "\tvar \$hasOne = array(\n";
|
||||
|
||||
for($i = 0; $i < count($associations['hasOne']); $i++) {
|
||||
for ($i = 0; $i < count($associations['hasOne']); $i++) {
|
||||
$out .= "\t\t\t'{$associations['hasOne'][$i]['alias']}' => ";
|
||||
$out .= "array('className' => '{$associations['hasOne'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'foreignKey' => '{$associations['hasOne'][$i]['foreignKey']}',\n";
|
||||
|
@ -508,10 +508,10 @@ class ModelTask extends Shell {
|
|||
$out .= "\t);\n\n";
|
||||
}
|
||||
|
||||
if(!empty($associations['hasMany'])) {
|
||||
if (!empty($associations['hasMany'])) {
|
||||
$out .= "\tvar \$hasMany = array(\n";
|
||||
|
||||
for($i = 0; $i < count($associations['hasMany']); $i++) {
|
||||
for ($i = 0; $i < count($associations['hasMany']); $i++) {
|
||||
$out .= "\t\t\t'{$associations['hasMany'][$i]['alias']}' => ";
|
||||
$out .= "array('className' => '{$associations['hasMany'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t\t\t\t\t\t'foreignKey' => '{$associations['hasMany'][$i]['foreignKey']}',\n";
|
||||
|
@ -529,10 +529,10 @@ class ModelTask extends Shell {
|
|||
$out .= "\t);\n\n";
|
||||
}
|
||||
|
||||
if(!empty($associations['hasAndBelongsToMany'])) {
|
||||
if (!empty($associations['hasAndBelongsToMany'])) {
|
||||
$out .= "\tvar \$hasAndBelongsToMany = array(\n";
|
||||
|
||||
for($i = 0; $i < count($associations['hasAndBelongsToMany']); $i++) {
|
||||
for ($i = 0; $i < count($associations['hasAndBelongsToMany']); $i++) {
|
||||
$out .= "\t\t\t'{$associations['hasAndBelongsToMany'][$i]['alias']}' => ";
|
||||
$out .= "array('className' => '{$associations['hasAndBelongsToMany'][$i]['className']}',\n";
|
||||
$out .= "\t\t\t\t\t\t'joinTable' => '{$associations['hasAndBelongsToMany'][$i]['joinTable']}',\n";
|
||||
|
@ -582,7 +582,7 @@ class ModelTask extends Shell {
|
|||
|
||||
$this->out("Baking unit test for $className...");
|
||||
$Folder =& new Folder($path, true);
|
||||
if($path = $Folder->cd($path)) {
|
||||
if ($path = $Folder->cd($path)) {
|
||||
$path = $Folder->slashTerm($path);
|
||||
return $this->createFile($path . $filename, $out);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
if(!class_exists('File')) {
|
||||
if (!class_exists('File')) {
|
||||
uses('file');
|
||||
}
|
||||
/**
|
||||
|
@ -51,9 +51,9 @@ class ProjectTask extends Shell {
|
|||
* @return bool
|
||||
*/
|
||||
function execute($project = null) {
|
||||
if($project === null) {
|
||||
if ($project === null) {
|
||||
$project = $this->params['app'];
|
||||
if(isset($this->args[0])) {
|
||||
if (isset($this->args[0])) {
|
||||
$project = $this->args[0];
|
||||
$this->Dispatch->shiftArgs();
|
||||
}
|
||||
|
@ -63,12 +63,12 @@ class ProjectTask extends Shell {
|
|||
$app = basename($working);
|
||||
$root = dirname($working) . DS;
|
||||
|
||||
if($project) {
|
||||
if($project{0} != '/') {
|
||||
if ($project) {
|
||||
if ($project{0} != '/') {
|
||||
$root = $working;
|
||||
$app = $project;
|
||||
}
|
||||
if($root{strlen($root) -1} != '/') {
|
||||
if ($root{strlen($root) -1} != '/') {
|
||||
$root = $root . DS;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ class ProjectTask extends Shell {
|
|||
$response = false;
|
||||
while ($response == false && is_dir($path) === true && config('database') === true) {
|
||||
$response = $this->in('A project already exists in this location: '.$project.' Overwrite?', array('y','n'), 'n');
|
||||
if(low($response) === 'n') {
|
||||
if (low($response) === 'n') {
|
||||
$this->out('Bake Aborted');
|
||||
exit();
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class ProjectTask extends Shell {
|
|||
*/
|
||||
function __buildDirLayout($path) {
|
||||
$skel = '';
|
||||
if(is_dir(CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'console'.DS.'libs'.DS.'templates'.DS.'skel') === true) {
|
||||
if (is_dir(CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'console'.DS.'libs'.DS.'templates'.DS.'skel') === true) {
|
||||
$skel = CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'console'.DS.'libs'.DS.'templates'.DS.'skel';
|
||||
} else {
|
||||
while ($skel == '') {
|
||||
|
@ -138,32 +138,32 @@ class ProjectTask extends Shell {
|
|||
}
|
||||
|
||||
$Folder = new Folder($skel);
|
||||
if($Folder->copy($path)) {
|
||||
if ($Folder->copy($path)) {
|
||||
$path = $Folder->slashTerm($path);
|
||||
$this->hr();
|
||||
$this->out(__(sprintf("Created: %s in %s", $app, $path), true));
|
||||
$this->hr();
|
||||
|
||||
if($this->createHome($path, $app)) {
|
||||
if ($this->createHome($path, $app)) {
|
||||
$this->out('Welcome page created');
|
||||
} else {
|
||||
$this->out('The Welcome page was NOT created');
|
||||
}
|
||||
|
||||
if($this->cakeSessionString($path) === true ){
|
||||
if ($this->cakeSessionString($path) === true ){
|
||||
$this->out('Random hash key created for CAKE_SESSION_STRING');
|
||||
} else {
|
||||
$this->err('Unable to generate random hash for CAKE_SESSION_STRING, please change this yourself in ' . CONFIGS . 'core.php');
|
||||
}
|
||||
|
||||
$corePath = $this->corePath($path);
|
||||
if($corePath === true ){
|
||||
if ($corePath === true ){
|
||||
$this->out('CAKE_CORE_INCLUDE_PATH set to ' . CAKE_CORE_INCLUDE_PATH);
|
||||
} else if($corePath === false){
|
||||
} elseif ($corePath === false){
|
||||
$this->err('Unable to to set CAKE_CORE_INCLUDE_PATH, please change this yourself in ' . $path . 'webroot' .DS .'index.php');
|
||||
}
|
||||
|
||||
if($Folder->chmod($path . DS . 'tmp', 0777) === false) {
|
||||
if ($Folder->chmod($path . DS . 'tmp', 0777) === false) {
|
||||
$this->err('Could path set permissions on '. $project . DS .'tmp' . DS . '*');
|
||||
$this->out('You must manually check that these directories can be wrote to by the server');
|
||||
}
|
||||
|
@ -171,8 +171,8 @@ class ProjectTask extends Shell {
|
|||
$this->err(" '".$app."' could not be created properly");
|
||||
}
|
||||
|
||||
if($verbose) {
|
||||
foreach($Folder->messages() as $message) {
|
||||
if ($verbose) {
|
||||
foreach ($Folder->messages() as $message) {
|
||||
$this->out($message);
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ class ProjectTask extends Shell {
|
|||
uses('Security');
|
||||
$string = Security::generateAuthKey();
|
||||
$result = str_replace($match[0], 'define(\'CAKE_SESSION_STRING\', \''.$string.'\');', $contents);
|
||||
if($File->write($result)){
|
||||
if ($File->write($result)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -222,12 +222,12 @@ class ProjectTask extends Shell {
|
|||
* @return bool
|
||||
*/
|
||||
function corePath($path){
|
||||
if(dirname($path) !== CAKE_CORE_INCLUDE_PATH) {
|
||||
if (dirname($path) !== CAKE_CORE_INCLUDE_PATH) {
|
||||
$File =& new File($path . 'webroot' . DS . 'index.php');
|
||||
$contents = $File->read();
|
||||
if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
|
||||
$result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '".CAKE_CORE_INCLUDE_PATH."');", $contents);
|
||||
if($File->write($result)){
|
||||
if ($File->write($result)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -247,7 +247,7 @@ class ProjectTask extends Shell {
|
|||
$contents = $File->read();
|
||||
if (preg_match('%([/\\t\\x20]*define\\(\'CAKE_ADMIN\',[\\t\\x20\'a-z]*\\);)%', $contents, $match)) {
|
||||
$result = str_replace($match[0], 'define(\'CAKE_ADMIN\', \''.$name.'\');', $contents);
|
||||
if($File->write($result)){
|
||||
if ($File->write($result)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -75,48 +75,48 @@ class ViewTask extends Shell {
|
|||
* @return void
|
||||
*/
|
||||
function execute() {
|
||||
if(empty($this->args)) {
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
}
|
||||
|
||||
$controller = $action = $alias = null;
|
||||
if(isset($this->args[0])) {
|
||||
if (isset($this->args[0])) {
|
||||
$this->controllerName = Inflector::camelize($this->args[0]);
|
||||
$this->controllerPath = Inflector::underscore($this->controllerName);
|
||||
}
|
||||
|
||||
if(isset($this->args[1])) {
|
||||
if (isset($this->args[1])) {
|
||||
$this->template = $this->args[1];
|
||||
}
|
||||
|
||||
if(isset($this->args[2])) {
|
||||
if (isset($this->args[2])) {
|
||||
$action = $this->args[2];
|
||||
}
|
||||
|
||||
if(!$action) {
|
||||
if (!$action) {
|
||||
$action = $this->template;
|
||||
}
|
||||
|
||||
if(in_array($action, $this->scaffoldActions)) {
|
||||
if (in_array($action, $this->scaffoldActions)) {
|
||||
$this->bake($action, true);
|
||||
} else if($action) {
|
||||
} elseif ($action) {
|
||||
$this->bake($action, true);
|
||||
} else {
|
||||
$vars = $this->__loadController();
|
||||
if($vars) {
|
||||
if ($vars) {
|
||||
$protected = array( 'object', low($this->controllerName. 'Controller'), 'controller', 'appcontroller',
|
||||
'tostring', 'requestaction', 'log', 'cakeerror', 'constructclasses', 'redirect', 'set', 'setaction',
|
||||
'validate', 'validateerrors', 'render', 'referer', 'flash', 'flashout', 'generatefieldnames',
|
||||
'postconditions', 'cleanupfields', 'beforefilter', 'beforerender', 'afterfilter', 'disablecache', 'paginate');
|
||||
|
||||
$classVars = get_class_vars($this->controllerName . 'Controller');
|
||||
if(array_key_exists('scaffold', $classVars)) {
|
||||
if (array_key_exists('scaffold', $classVars)) {
|
||||
$methods = $this->scaffoldActions;
|
||||
} else {
|
||||
$methods = get_class_methods($this->controllerName . 'Controller');
|
||||
}
|
||||
foreach($methods as $method) {
|
||||
if($method{0} != '_' && !in_array(low($method), am($protected, array('delete', CAKE_ADMIN.'_delete')))) {
|
||||
foreach ($methods as $method) {
|
||||
if ($method{0} != '_' && !in_array(low($method), am($protected, array('delete', CAKE_ADMIN.'_delete')))) {
|
||||
$content = $this->getContent($method, $vars);
|
||||
$this->bake($method, $content);
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ class ViewTask extends Shell {
|
|||
|
||||
$admin = '';
|
||||
if ((low($wannaDoAdmin) == 'y' || low($wannaDoAdmin) == 'yes')) {
|
||||
if(defined('CAKE_ADMIN')) {
|
||||
if (defined('CAKE_ADMIN')) {
|
||||
$admin = CAKE_ADMIN . '_';
|
||||
} else {
|
||||
$this->out('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
|
||||
|
@ -162,7 +162,7 @@ class ViewTask extends Shell {
|
|||
while ($admin == '') {
|
||||
$admin = $this->in("What would you like the admin route to be?", null, 'admin');
|
||||
}
|
||||
if($this->Project->cakeAdmin($admin) !== true){
|
||||
if ($this->Project->cakeAdmin($admin) !== true){
|
||||
$this->err('Unable to write to /app/config/core.php.');
|
||||
$this->err('You need to enable CAKE_ADMIN in /app/config/core.php to use admin routing.');
|
||||
exit();
|
||||
|
@ -174,14 +174,14 @@ class ViewTask extends Shell {
|
|||
if (low($wannaDoScaffold) == 'y' || low($wannaDoScaffold) == 'yes') {
|
||||
$file = CONTROLLERS . $this->controllerPath . '_controller.php';
|
||||
|
||||
if($admin) {
|
||||
foreach($this->scaffoldActions as $action) {
|
||||
if ($admin) {
|
||||
foreach ($this->scaffoldActions as $action) {
|
||||
$this->scaffoldActions[] = $admin . $action;
|
||||
}
|
||||
}
|
||||
$vars = $this->__loadController();
|
||||
if($vars) {
|
||||
foreach($this->scaffoldActions as $action) {
|
||||
if ($vars) {
|
||||
foreach ($this->scaffoldActions as $action) {
|
||||
$content = $this->getContent($action, $vars);
|
||||
$this->bake($action, $content);
|
||||
}
|
||||
|
@ -226,11 +226,11 @@ class ViewTask extends Shell {
|
|||
* @return array Returns an variables to be made available to a view template
|
||||
*/
|
||||
function __loadController() {
|
||||
if(!$this->controllerName) {
|
||||
if (!$this->controllerName) {
|
||||
$this->err('could not find the controller');
|
||||
}
|
||||
|
||||
if(!loadController($this->controllerName)) {
|
||||
if (!loadController($this->controllerName)) {
|
||||
$file = CONTROLLERS . $this->controllerPath . '_controller.php';
|
||||
$shortPath = $this->shortPath($file);
|
||||
$this->err("The file '{$shortPath}' could not be found.\nIn order to bake a view, you'll need to first create the controller.");
|
||||
|
@ -268,17 +268,17 @@ class ViewTask extends Shell {
|
|||
* @return bool
|
||||
*/
|
||||
function bake($action, $content = '') {
|
||||
if($content === true) {
|
||||
if ($content === true) {
|
||||
$content = $this->getContent();
|
||||
}
|
||||
$filename = VIEWS . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp';
|
||||
$Folder =& new Folder(VIEWS . $this->controllerPath, true);
|
||||
$errors = $Folder->errors();
|
||||
if(empty($errors)) {
|
||||
if (empty($errors)) {
|
||||
$path = $Folder->slashTerm($Folder->pwd());
|
||||
return $this->createFile($filename, $content);
|
||||
} else {
|
||||
foreach($errors as $error) {
|
||||
foreach ($errors as $error) {
|
||||
$this->err($error);
|
||||
}
|
||||
}
|
||||
|
@ -292,32 +292,32 @@ class ViewTask extends Shell {
|
|||
* @return string content from template
|
||||
*/
|
||||
function getContent($template = null, $vars = null) {
|
||||
if(!$template) {
|
||||
if (!$template) {
|
||||
$template = $this->template;
|
||||
}
|
||||
$action = $template;
|
||||
|
||||
if(strpos($template, CAKE_ADMIN) !== false) {
|
||||
if (strpos($template, CAKE_ADMIN) !== false) {
|
||||
$template = str_replace(CAKE_ADMIN.'_', '', $template);
|
||||
}
|
||||
|
||||
if(in_array($template, array('add', 'edit'))) {
|
||||
if (in_array($template, array('add', 'edit'))) {
|
||||
$action = $template;
|
||||
$template = 'form';
|
||||
}
|
||||
$loaded = false;
|
||||
foreach($this->Dispatch->shellPaths as $path) {
|
||||
foreach ($this->Dispatch->shellPaths as $path) {
|
||||
$templatePath = $path . 'templates' . DS . 'views' . DS .Inflector::underscore($template).'.ctp';
|
||||
if (file_exists($templatePath) && is_file($templatePath)) {
|
||||
$loaded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$vars) {
|
||||
if (!$vars) {
|
||||
$vars = $this->__loadController();
|
||||
}
|
||||
|
||||
if($loaded) {
|
||||
if ($loaded) {
|
||||
extract($vars);
|
||||
ob_start();
|
||||
ob_implicit_flush(0);
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
</div>
|
||||
<div id="content">
|
||||
<?php
|
||||
if($session->check('Message.flash')):
|
||||
if ($session->check('Message.flash')):
|
||||
$session->flash();
|
||||
endif;
|
||||
?>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<title><?php echo $page_title?></title>
|
||||
<?php echo $html->charset(); ?>
|
||||
|
||||
<?php if(Configure::read() == 0) { ?>
|
||||
<?php if (Configure::read() == 0) { ?>
|
||||
<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>"/>
|
||||
<?php } ?>
|
||||
<style><!--
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
$file = $_GET['file'];
|
||||
$pos = strpos($file, '..');
|
||||
if ($pos === false) {
|
||||
if(is_file('../../vendors/javascript/'.$file) && (preg_match('/(\/.+)\\.js/', $file)))
|
||||
if (is_file('../../vendors/javascript/'.$file) && (preg_match('/(\/.+)\\.js/', $file)))
|
||||
{
|
||||
readfile('../../vendors/javascript/'.$file);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ require_once CORE_PATH . 'cake' . DS . 'bootstrap.php';
|
|||
require_once CAKE . 'basics.php';
|
||||
require_once CAKE . 'config' . DS . 'paths.php';
|
||||
require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php';
|
||||
if(DEBUG < 1) {
|
||||
if (DEBUG < 1) {
|
||||
die('Invalid url.');
|
||||
}
|
||||
|
||||
|
@ -85,13 +85,13 @@ if (!defined('BASE_URL')){
|
|||
define('CAKE_TEST_OUTPUT_HTML',1);
|
||||
define('CAKE_TEST_OUTPUT_TEXT',2);
|
||||
|
||||
if(isset($_GET['output']) && $_GET['output'] == 'html') {
|
||||
if (isset($_GET['output']) && $_GET['output'] == 'html') {
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML);
|
||||
} else {
|
||||
define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT);
|
||||
}
|
||||
|
||||
if(!vendor('simpletest' . DS . 'reporter')) {
|
||||
if (!vendor('simpletest' . DS . 'reporter')) {
|
||||
CakePHPTestHeader();
|
||||
include CAKE . 'tests' . DS . 'lib' . DS . 'simpletest.php';
|
||||
CakePHPTestSuiteFooter();
|
||||
|
@ -118,14 +118,14 @@ if(!vendor('simpletest' . DS . 'reporter')) {
|
|||
switch (CAKE_TEST_OUTPUT) {
|
||||
case CAKE_TEST_OUTPUT_HTML:
|
||||
if (isset($_GET['group'])) {
|
||||
if(isset($_GET['app'])) {
|
||||
if (isset($_GET['app'])) {
|
||||
$show = '?show=groups&app=true';
|
||||
} else {
|
||||
$show = '?show=groups';
|
||||
}
|
||||
}
|
||||
if (isset($_GET['case'])) {
|
||||
if(isset($_GET['app'])) {
|
||||
if (isset($_GET['app'])) {
|
||||
$show = '??show=cases&app=truee';
|
||||
} else {
|
||||
$show = '?show=cases';
|
||||
|
|
|
@ -30,14 +30,14 @@
|
|||
<legend><?php echo "<?php __('".Inflector::humanize($action)."', true);?> <?php __('{$singularHumanName}');?>";?></legend>
|
||||
<?php
|
||||
echo "\t<?php\n";
|
||||
foreach($fields as $field) {
|
||||
if($action == 'add' && $field['name'] == $primaryKey) {
|
||||
foreach ($fields as $field) {
|
||||
if ($action == 'add' && $field['name'] == $primaryKey) {
|
||||
continue;
|
||||
} else if(!in_array($field['name'], array('created', 'modified', 'updated'))){
|
||||
} elseif (!in_array($field['name'], array('created', 'modified', 'updated'))){
|
||||
echo "\t\techo \$form->input('{$field['name']}');\n";
|
||||
}
|
||||
}
|
||||
foreach($hasAndBelongsToMany as $assocName => $assocData) {
|
||||
foreach ($hasAndBelongsToMany as $assocName => $assocData) {
|
||||
echo "\t\techo \$form->input('{$assocName}');\n";
|
||||
}
|
||||
echo "\t?>\n";
|
||||
|
@ -49,14 +49,14 @@
|
|||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<?php if($action != 'add'):?>
|
||||
<?php if ($action != 'add'):?>
|
||||
<li><?php echo "<?php echo \$html->link(__('Delete', true), array('action'=>'delete', \$form->value('{$modelClass}.{$primaryKey}')), null, __('Are you sure you want to delete', true).' #' . \$form->value('{$modelClass}.{$primaryKey}')); ?>";?></li>
|
||||
<?php endif;?>
|
||||
<li><?php echo "<?php echo \$html->link(__('List', true).' '.__('{$pluralHumanName}', true), array('action'=>'index'));?>";?></li>
|
||||
<?php
|
||||
foreach($foreignKeys as $field => $value) {
|
||||
foreach ($foreignKeys as $field => $value) {
|
||||
$otherModelClass = $value['1'];
|
||||
if($otherModelClass != $modelClass) {
|
||||
if ($otherModelClass != $modelClass) {
|
||||
$otherModelKey = Inflector::underscore($otherModelClass);
|
||||
$otherControllerName = Inflector::pluralize($otherModelClass);
|
||||
$otherControllerPath = Inflector::underscore($otherControllerName);
|
||||
|
|
|
@ -6,7 +6,7 @@ $output .="
|
|||
<span class=\"notice\">
|
||||
<?php
|
||||
__('Your tmp directory is ');
|
||||
if(is_writable(TMP)):
|
||||
if (is_writable(TMP)):
|
||||
__('writable.');
|
||||
else:
|
||||
__('NOT writable.');
|
||||
|
@ -34,7 +34,7 @@ $output .="
|
|||
else:
|
||||
__('NOT working.');
|
||||
echo '<br />';
|
||||
if(is_writable(TMP)):
|
||||
if (is_writable(TMP)):
|
||||
__('Edit: config/core.php to insure you have the newset version of this file and the variable \$cakeCache set properly');
|
||||
endif;
|
||||
endif;
|
||||
|
@ -46,7 +46,7 @@ $output .="
|
|||
<?php
|
||||
__('Your database configuration file is ');
|
||||
\$filePresent = null;
|
||||
if(file_exists(CONFIGS.'database.php')):
|
||||
if (file_exists(CONFIGS.'database.php')):
|
||||
__('present.');
|
||||
\$filePresent = true;
|
||||
else:
|
||||
|
@ -67,7 +67,7 @@ if (!empty(\$filePresent)):
|
|||
<span class=\"notice\">
|
||||
<?php
|
||||
__('Cake');
|
||||
if(\$connected->isConnected()):
|
||||
if (\$connected->isConnected()):
|
||||
__(' is able to ');
|
||||
else:
|
||||
__(' is NOT able to ');
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<h2><?php echo "<?php __('{$pluralHumanName}');?>";?></h2>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<?php foreach($fields as $field):?>
|
||||
<?php foreach ($fields as $field):?>
|
||||
<th><?php echo "<?php echo \$paginator->sort('{$field['name']}');?>";?></th>
|
||||
<?php endforeach;?>
|
||||
<th class="actions"><?php echo "<?php __('Actions');?>";?></th>
|
||||
|
@ -36,21 +36,21 @@
|
|||
<?php
|
||||
echo "<?php
|
||||
\$i = 0;
|
||||
foreach(\${$pluralVar} as \${$singularVar}):
|
||||
foreach (\${$pluralVar} as \${$singularVar}):
|
||||
\$class = null;
|
||||
if(\$i++ % 2 == 0) {
|
||||
if (\$i++ % 2 == 0) {
|
||||
\$class = ' class=\"altrow\"';
|
||||
}
|
||||
?>\n";
|
||||
echo "\t<tr<?php echo \$class;?>>\n";
|
||||
|
||||
foreach($fields as $field) {
|
||||
if(in_array($field['name'], array_keys($foreignKeys))) {
|
||||
foreach ($fields as $field) {
|
||||
if (in_array($field['name'], array_keys($foreignKeys))) {
|
||||
$otherModelClass = $foreignKeys[$field['name']][1];
|
||||
$otherModelKey = Inflector::underscore($otherModelClass);
|
||||
$otherControllerName = Inflector::pluralize($otherModelClass);
|
||||
$otherControllerPath = Inflector::underscore($otherControllerName);
|
||||
if(isset($foreignKeys[$field['name']][2])) {
|
||||
if (isset($foreignKeys[$field['name']][2])) {
|
||||
$otherModelClass = $foreignKeys[$field['name']][2];
|
||||
}
|
||||
$otherVariableName = Inflector::variable($otherModelClass);
|
||||
|
@ -83,9 +83,9 @@ echo "<?php endforeach; ?>\n";
|
|||
<ul>
|
||||
<li><?php echo "<?php echo \$html->link(__('New', true).' '.__('{$singularHumanName}', true), array('action'=>'add')); ?>";?></li>
|
||||
<?php
|
||||
foreach($foreignKeys as $field => $value) {
|
||||
foreach ($foreignKeys as $field => $value) {
|
||||
$otherModelClass = $value['1'];
|
||||
if($otherModelClass != $modelClass) {
|
||||
if ($otherModelClass != $modelClass) {
|
||||
$otherModelKey = Inflector::underscore($otherModelClass);
|
||||
$otherControllerName = Inflector::pluralize($otherModelClass);
|
||||
$otherControllerPath = Inflector::underscore($otherControllerName);
|
||||
|
|
|
@ -29,18 +29,18 @@
|
|||
<dl>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach($fields as $field) {
|
||||
foreach ($fields as $field) {
|
||||
$class = null;
|
||||
if($i++ % 2 == 0) {
|
||||
if ($i++ % 2 == 0) {
|
||||
$class = ' class="altrow"';
|
||||
}
|
||||
|
||||
if(in_array($field['name'], array_keys($foreignKeys))) {
|
||||
if (in_array($field['name'], array_keys($foreignKeys))) {
|
||||
$otherModelClass = $foreignKeys[$field['name']][1];
|
||||
$otherModelKey = Inflector::underscore($otherModelClass);
|
||||
$otherControllerName = Inflector::pluralize($otherModelClass);
|
||||
$otherControllerPath = Inflector::underscore($otherControllerName);
|
||||
if(isset($foreignKeys[$field['name']][2])) {
|
||||
if (isset($foreignKeys[$field['name']][2])) {
|
||||
$otherModelClass = $foreignKeys[$field['name']][2];
|
||||
}
|
||||
$otherSingularVar = Inflector::variable($otherModelClass);
|
||||
|
@ -65,9 +65,9 @@ foreach($fields as $field) {
|
|||
echo "\t\t<li><?php echo \$html->link(__('List', true).' '.__('{$pluralHumanName}', true), array('action'=>'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$html->link(__('New', true).' '.__('{$singularHumanName}', true), array('action'=>'add')); ?> </li>\n";
|
||||
|
||||
foreach($foreignKeys as $field => $value) {
|
||||
foreach ($foreignKeys as $field => $value) {
|
||||
$otherModelClass = $value['1'];
|
||||
if($otherModelClass != $modelClass) {
|
||||
if ($otherModelClass != $modelClass) {
|
||||
$otherModelKey = Inflector::underscore($otherModelClass);
|
||||
$otherControllerName = Inflector::pluralize($otherModelClass);
|
||||
$otherControllerPath = Inflector::underscore($otherControllerName);
|
||||
|
@ -96,13 +96,13 @@ foreach ($hasOne as $assocName => $assocData):
|
|||
?>
|
||||
<div class="related">
|
||||
<h3><?php echo "<?php __('Related');?> <?php __('{$otherSingularHumanName}');?>";?></h3>
|
||||
<?php echo "<?php if(!empty(\${$singularVar}['{$assocName}'])):?>\n";?>
|
||||
<?php echo "<?php if (!empty(\${$singularVar}['{$assocName}'])):?>\n";?>
|
||||
<dl>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach($otherFields as $field) {
|
||||
foreach ($otherFields as $field) {
|
||||
$class = null;
|
||||
if($i++ % 2 == 0) {
|
||||
if ($i++ % 2 == 0) {
|
||||
$class = ' class="altrow"';
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ endforeach;
|
|||
|
||||
$relations = array_merge($hasMany, $hasAndBelongsToMany);
|
||||
$i = 0;
|
||||
foreach($relations as $assocName => $assocData):
|
||||
foreach ($relations as $assocName => $assocData):
|
||||
$otherModelKey = Inflector::underscore($assocData['className']);
|
||||
$otherModelObj =& ClassRegistry::getObject($otherModelKey);
|
||||
$otherControllerPath = Inflector::pluralize($otherModelKey);
|
||||
|
@ -138,11 +138,11 @@ foreach($relations as $assocName => $assocData):
|
|||
?>
|
||||
<div class="related">
|
||||
<h3><?php echo "<?php __('Related');?> <?php __('{$otherPluralHumanName}');?>";?></h3>
|
||||
<?php echo "<?php if(!empty(\${$singularVar}['{$assocName}'])):?>\n";?>
|
||||
<?php echo "<?php if (!empty(\${$singularVar}['{$assocName}'])):?>\n";?>
|
||||
<table cellpadding = "0" cellspacing = "0">
|
||||
<tr>
|
||||
<?php
|
||||
foreach($otherFields as $field) {
|
||||
foreach ($otherFields as $field) {
|
||||
echo "\t\t<th>".Inflector::humanize($field['name'])."</th>\n";
|
||||
}
|
||||
?>
|
||||
|
@ -151,15 +151,15 @@ foreach($relations as $assocName => $assocData):
|
|||
<?php
|
||||
echo "\t<?php
|
||||
\$i = 0;
|
||||
foreach(\${$singularVar}['{$assocName}'] as \${$otherSingularVar}):
|
||||
foreach (\${$singularVar}['{$assocName}'] as \${$otherSingularVar}):
|
||||
\$class = null;
|
||||
if(\$i++ % 2 == 0) {
|
||||
if (\$i++ % 2 == 0) {
|
||||
\$class = ' class=\"altrow\"';
|
||||
}
|
||||
?>\n";
|
||||
echo "\t\t<tr<?php echo \$class;?>>\n";
|
||||
|
||||
foreach($otherFields as $field) {
|
||||
foreach ($otherFields as $field) {
|
||||
echo "\t\t\t<td><?php echo \${$otherSingularVar}['{$field['name']}'];?></td>\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -111,14 +111,14 @@ class Dispatcher extends Object {
|
|||
if (!loadController($ctrlName)) {
|
||||
$pluginName = Inflector::camelize($params['action']);
|
||||
if (!loadController($ctrlName . '.' . $pluginName)) {
|
||||
if(preg_match('/([\\.]+)/', $ctrlName)) {
|
||||
if (preg_match('/([\\.]+)/', $ctrlName)) {
|
||||
Router::setRequestInfo(array($params, array('base' => $this->base, 'webroot' => $this->webroot)));
|
||||
|
||||
return $this->cakeError('error404',
|
||||
array(array('url' => strtolower($ctrlName),
|
||||
'message' => 'Was not found on this server',
|
||||
'base' => $this->base)));
|
||||
} elseif(!class_exists($ctrlClass)) {
|
||||
} elseif (!class_exists($ctrlClass)) {
|
||||
$missingController = true;
|
||||
} else {
|
||||
$params['plugin'] = null;
|
||||
|
@ -133,7 +133,7 @@ class Dispatcher extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if(isset($params['plugin'])) {
|
||||
if (isset($params['plugin'])) {
|
||||
$plugin = $params['plugin'];
|
||||
$pluginName = Inflector::camelize($params['action']);
|
||||
$pluginClass = $pluginName.'Controller';
|
||||
|
@ -144,7 +144,7 @@ class Dispatcher extends Object {
|
|||
loadPluginModels($plugin);
|
||||
$this->base = $this->base.'/'.Inflector::underscore($ctrlName);
|
||||
|
||||
if(empty($params['controller']) || !class_exists($pluginClass)) {
|
||||
if (empty($params['controller']) || !class_exists($pluginClass)) {
|
||||
$params['controller'] = Inflector::underscore($ctrlName);
|
||||
$ctrlClass = $ctrlName.'Controller';
|
||||
if (!is_null($params['action'])) {
|
||||
|
@ -158,8 +158,8 @@ class Dispatcher extends Object {
|
|||
$params['action'] = 'index';
|
||||
}
|
||||
|
||||
if(defined('CAKE_ADMIN')) {
|
||||
if(isset($params[CAKE_ADMIN])) {
|
||||
if (defined('CAKE_ADMIN')) {
|
||||
if (isset($params[CAKE_ADMIN])) {
|
||||
$this->admin = '/'.CAKE_ADMIN ;
|
||||
$url = preg_replace('/'.CAKE_ADMIN.'\/?/', '', $url);
|
||||
$params['action'] = CAKE_ADMIN.'_'.$params['action'];
|
||||
|
@ -168,7 +168,7 @@ class Dispatcher extends Object {
|
|||
}
|
||||
}
|
||||
$base = Router::stripPlugin($this->base, $this->plugin);
|
||||
if(defined('BASE_URL')) {
|
||||
if (defined('BASE_URL')) {
|
||||
$this->here = $base . $this->admin . $url;
|
||||
} else {
|
||||
$this->here = $base . $this->admin . '/' . $url;
|
||||
|
@ -191,11 +191,11 @@ class Dispatcher extends Object {
|
|||
$classMethods = get_class_methods($controller);
|
||||
$classVars = get_object_vars($controller);
|
||||
|
||||
if((in_array($params['action'], $classMethods) || in_array(strtolower($params['action']), $classMethods)) && strpos($params['action'], '_', 0) === 0) {
|
||||
if ((in_array($params['action'], $classMethods) || in_array(strtolower($params['action']), $classMethods)) && strpos($params['action'], '_', 0) === 0) {
|
||||
$privateAction = true;
|
||||
}
|
||||
|
||||
if(!in_array($params['action'], $classMethods) && !in_array(strtolower($params['action']), $classMethods)) {
|
||||
if (!in_array($params['action'], $classMethods) && !in_array(strtolower($params['action']), $classMethods)) {
|
||||
$missingAction = true;
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ class Dispatcher extends Object {
|
|||
$missingAction = true;
|
||||
}
|
||||
|
||||
if(in_array('return', array_keys($params)) && $params['return'] == 1) {
|
||||
if (in_array('return', array_keys($params)) && $params['return'] == 1) {
|
||||
$controller->autoRender = false;
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ class Dispatcher extends Object {
|
|||
|
||||
$namedArgs = array();
|
||||
if (is_array($controller->namedArgs)) {
|
||||
if(array_key_exists($params['action'], $controller->namedArgs)) {
|
||||
if (array_key_exists($params['action'], $controller->namedArgs)) {
|
||||
$namedArgs = $controller->namedArgs[$params['action']];
|
||||
} else {
|
||||
$namedArgs = $controller->namedArgs;
|
||||
|
@ -241,18 +241,18 @@ class Dispatcher extends Object {
|
|||
for ($i = 0; $i <= $c; $i++) {
|
||||
if (isset($controller->passedArgs[$i]) && strpos($controller->passedArgs[$i], $controller->argSeparator) !== false) {
|
||||
list($argKey, $argVal) = explode($controller->argSeparator, $controller->passedArgs[$i]);
|
||||
if(empty($namedArgs) || (!empty($namedArgs) && in_array($argKey, array_keys($namedArgs)))) {
|
||||
if (empty($namedArgs) || (!empty($namedArgs) && in_array($argKey, array_keys($namedArgs)))) {
|
||||
$controller->passedArgs[$argKey] = $argVal;
|
||||
$controller->namedArgs[$argKey] = $argVal;
|
||||
unset($controller->passedArgs[$i]);
|
||||
unset($params['pass'][$i]);
|
||||
}
|
||||
} else if($controller->argSeparator === '/') {
|
||||
} elseif ($controller->argSeparator === '/') {
|
||||
$ii = $i + 1;
|
||||
if(isset($controller->passedArgs[$i]) && isset($controller->passedArgs[$ii])) {
|
||||
if (isset($controller->passedArgs[$i]) && isset($controller->passedArgs[$ii])) {
|
||||
$argKey = $controller->passedArgs[$i];
|
||||
$argVal = $controller->passedArgs[$ii];
|
||||
if(empty($namedArgs) || (!empty($namedArgs) && in_array($argKey, array_keys($namedArgs)))) {
|
||||
if (empty($namedArgs) || (!empty($namedArgs) && in_array($argKey, array_keys($namedArgs)))) {
|
||||
$controller->passedArgs[$argKey] = $argVal;
|
||||
$controller->namedArgs[$argKey] = $argVal;
|
||||
unset($controller->passedArgs[$i], $controller->passedArgs[$ii]);
|
||||
|
@ -292,14 +292,14 @@ class Dispatcher extends Object {
|
|||
$controller->layout = $params['layout'];
|
||||
}
|
||||
}
|
||||
foreach(array('components', 'helpers') as $var) {
|
||||
foreach (array('components', 'helpers') as $var) {
|
||||
if (isset($params[$var]) && !empty($params[$var]) && is_array($controller->{$var})) {
|
||||
$diff = array_diff($params[$var], $controller->{$var});
|
||||
$controller->{$var} = array_merge($controller->{$var}, $diff);
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_null($controller->webservices)) {
|
||||
if (!is_null($controller->webservices)) {
|
||||
array_push($controller->components, $controller->webservices);
|
||||
array_push($controller->helpers, $controller->webservices);
|
||||
$component =& new Component($controller);
|
||||
|
@ -361,7 +361,7 @@ class Dispatcher extends Object {
|
|||
}
|
||||
$controller->output =& $output;
|
||||
|
||||
foreach($controller->components as $c) {
|
||||
foreach ($controller->components as $c) {
|
||||
$path = preg_split('/\/|\./', $c);
|
||||
$c = $path[count($path) - 1];
|
||||
if (isset($controller->{$c}) && is_object($controller->{$c}) && is_callable(array($controller->{$c}, 'shutdown'))) {
|
||||
|
@ -382,22 +382,22 @@ class Dispatcher extends Object {
|
|||
*/
|
||||
function start(&$controller) {
|
||||
if (!empty($controller->beforeFilter)) {
|
||||
if(is_array($controller->beforeFilter)) {
|
||||
if (is_array($controller->beforeFilter)) {
|
||||
|
||||
foreach($controller->beforeFilter as $filter) {
|
||||
if(is_callable(array($controller,$filter)) && $filter != 'beforeFilter') {
|
||||
foreach ($controller->beforeFilter as $filter) {
|
||||
if (is_callable(array($controller,$filter)) && $filter != 'beforeFilter') {
|
||||
$controller->$filter();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(is_callable(array($controller, $controller->beforeFilter)) && $controller->beforeFilter != 'beforeFilter') {
|
||||
if (is_callable(array($controller, $controller->beforeFilter)) && $controller->beforeFilter != 'beforeFilter') {
|
||||
$controller->{$controller->beforeFilter}();
|
||||
}
|
||||
}
|
||||
}
|
||||
$controller->beforeFilter();
|
||||
|
||||
foreach($controller->components as $c) {
|
||||
foreach ($controller->components as $c) {
|
||||
$path = preg_split('/\/|\./', $c);
|
||||
$c = $path[count($path) - 1];
|
||||
if (isset($controller->{$c}) && is_object($controller->{$c}) && is_callable(array($controller->{$c}, 'startup'))) {
|
||||
|
@ -422,7 +422,7 @@ class Dispatcher extends Object {
|
|||
$params = Router::parse($fromUrl);
|
||||
|
||||
if (ini_get('magic_quotes_gpc') == 1) {
|
||||
if(!empty($_POST)) {
|
||||
if (!empty($_POST)) {
|
||||
$params['form'] = stripslashes_deep($_POST);
|
||||
}
|
||||
} else {
|
||||
|
@ -492,7 +492,7 @@ class Dispatcher extends Object {
|
|||
|
||||
if (preg_match('/^(.*)\/index\.php$/', $scriptName, $r)) {
|
||||
|
||||
if(!empty($r[1])) {
|
||||
if (!empty($r[1])) {
|
||||
return $base.$r[1];
|
||||
}
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ class Dispatcher extends Object {
|
|||
|
||||
if (preg_match('/^(.*)\\/'.$appDirName.'\\/'.$webrootDirName.'\\/index\\.php$/', $scriptName, $regs)) {
|
||||
|
||||
if(APP_DIR === 'app') {
|
||||
if (APP_DIR === 'app') {
|
||||
$appDir = null;
|
||||
} else {
|
||||
$appDir = '/'.APP_DIR;
|
||||
|
@ -533,7 +533,7 @@ class Dispatcher extends Object {
|
|||
function _restructureParams($params) {
|
||||
$params['controller'] = $params['action'];
|
||||
|
||||
if(isset($params['pass'][0])) {
|
||||
if (isset($params['pass'][0])) {
|
||||
$params['action'] = $params['pass'][0];
|
||||
array_shift($params['pass']);
|
||||
} else {
|
||||
|
|
|
@ -28,16 +28,16 @@
|
|||
/**
|
||||
* Included libraries.
|
||||
*/
|
||||
if(!class_exists('Object')) {
|
||||
if (!class_exists('Object')) {
|
||||
uses('object');
|
||||
}
|
||||
/**
|
||||
* Set defines if not set in core.php
|
||||
*/
|
||||
if(!defined('CACHE_DEFAULT_DURATION')) {
|
||||
if (!defined('CACHE_DEFAULT_DURATION')) {
|
||||
define('CACHE_DEFAULT_DURATION', 3600);
|
||||
}
|
||||
if(!defined('CACHE_GC_PROBABILITY')) {
|
||||
if (!defined('CACHE_GC_PROBABILITY')) {
|
||||
define('CACHE_GC_PROBABILITY', 100);
|
||||
}
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ class Cache extends Object {
|
|||
*/
|
||||
function &getInstance() {
|
||||
static $instance = array();
|
||||
if(!isset($instance[0]) || !$instance[0]) {
|
||||
if (!isset($instance[0]) || !$instance[0]) {
|
||||
$instance[0] =& new Cache();
|
||||
}
|
||||
return $instance[0];
|
||||
|
@ -85,12 +85,12 @@ class Cache extends Object {
|
|||
}
|
||||
$fileName = strtolower($name);
|
||||
|
||||
if(vendor('cache_engines/'.$fileName)) {
|
||||
if (vendor('cache_engines/'.$fileName)) {
|
||||
return true;
|
||||
}
|
||||
$fileName = dirname(__FILE__) . DS . 'cache' . DS . $fileName . '.php';
|
||||
|
||||
if(is_readable($fileName)) {
|
||||
if (is_readable($fileName)) {
|
||||
include $fileName;
|
||||
return true;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class Cache extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function engine($name = 'File', $params = array()) {
|
||||
if(defined('DISABLE_CACHE')) {
|
||||
if (defined('DISABLE_CACHE')) {
|
||||
return false;
|
||||
}
|
||||
$_this =& Cache::getInstance();
|
||||
|
@ -117,7 +117,7 @@ class Cache extends Object {
|
|||
$_this->_Engine =& new $cacheClass();
|
||||
|
||||
if ($_this->_Engine->init($params)) {
|
||||
if(time() % CACHE_GC_PROBABILITY == 0) {
|
||||
if (time() % CACHE_GC_PROBABILITY == 0) {
|
||||
$_this->_Engine->gc();
|
||||
}
|
||||
return true;
|
||||
|
@ -140,21 +140,21 @@ class Cache extends Object {
|
|||
}
|
||||
$key = strval($key);
|
||||
|
||||
if(empty($key)) {
|
||||
if (empty($key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(is_resource($value)) {
|
||||
if (is_resource($value)) {
|
||||
return false;
|
||||
}
|
||||
$duration = ife(is_string($duration), strtotime($duration), intval($duration));
|
||||
|
||||
if($duration < 1) {
|
||||
if ($duration < 1) {
|
||||
return false;
|
||||
}
|
||||
$_this =& Cache::getInstance();
|
||||
|
||||
if(!isset($_this->_Engine)) {
|
||||
if (!isset($_this->_Engine)) {
|
||||
return false;
|
||||
}
|
||||
return $_this->_Engine->write($key, $value, $duration);
|
||||
|
@ -167,18 +167,18 @@ class Cache extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function read($key) {
|
||||
if(defined('DISABLE_CACHE')) {
|
||||
if (defined('DISABLE_CACHE')) {
|
||||
return false;
|
||||
}
|
||||
$key = strval($key);
|
||||
|
||||
if(empty($key)) {
|
||||
if (empty($key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$_this =& Cache::getInstance();
|
||||
|
||||
if(!isset($_this->_Engine)) {
|
||||
if (!isset($_this->_Engine)) {
|
||||
return false;
|
||||
}
|
||||
return $_this->_Engine->read($key);
|
||||
|
@ -191,17 +191,17 @@ class Cache extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function delete($key) {
|
||||
if(defined('DISABLE_CACHE')) {
|
||||
if (defined('DISABLE_CACHE')) {
|
||||
return false;
|
||||
}
|
||||
$key = strval($key);
|
||||
|
||||
if(empty($key)) {
|
||||
if (empty($key)) {
|
||||
return false;
|
||||
}
|
||||
$_this =& Cache::getInstance();
|
||||
|
||||
if(!isset($_this->_Engine)) {
|
||||
if (!isset($_this->_Engine)) {
|
||||
return false;
|
||||
}
|
||||
return $_this->_Engine->delete($key);
|
||||
|
@ -213,12 +213,12 @@ class Cache extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function clear() {
|
||||
if(defined('DISABLE_CACHE')) {
|
||||
if (defined('DISABLE_CACHE')) {
|
||||
return false;
|
||||
}
|
||||
$_this =& Cache::getInstance();
|
||||
|
||||
if(!isset($_this->_Engine)) {
|
||||
if (!isset($_this->_Engine)) {
|
||||
return false;
|
||||
}
|
||||
return $_this->_Engine->clear();
|
||||
|
@ -230,7 +230,7 @@ class Cache extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function isInitialized() {
|
||||
if(defined('DISABLE_CACHE')) {
|
||||
if (defined('DISABLE_CACHE')) {
|
||||
return false;
|
||||
}
|
||||
$_this =& Cache::getInstance();
|
||||
|
@ -245,7 +245,7 @@ class Cache extends Object {
|
|||
*/
|
||||
function settings() {
|
||||
$_this =& Cache::getInstance();
|
||||
if(!is_null($_this->_Engine)) {
|
||||
if (!is_null($_this->_Engine)) {
|
||||
return $_this->_Engine->settings();
|
||||
}
|
||||
}
|
||||
|
|
30
cake/libs/cache/file.php
vendored
30
cake/libs/cache/file.php
vendored
|
@ -82,7 +82,7 @@ class FileEngine extends CacheEngine {
|
|||
$dir = $folder->slashTerm($dir);
|
||||
}
|
||||
|
||||
if(empty($dir) || !$folder->isAbsolute($dir) || !is_writable($dir)) {
|
||||
if (empty($dir) || !$folder->isAbsolute($dir) || !is_writable($dir)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ class FileEngine extends CacheEngine {
|
|||
function write($key, &$value, $duration = CACHE_DEFAULT_DURATION) {
|
||||
$serialized = serialize($value);
|
||||
|
||||
if(!$serialized) {
|
||||
if (!$serialized) {
|
||||
return false;
|
||||
}
|
||||
$expires = time() + $duration;
|
||||
|
@ -152,28 +152,28 @@ class FileEngine extends CacheEngine {
|
|||
function read($key) {
|
||||
$filename = $this->_getFilename($key);
|
||||
|
||||
if(!is_file($filename) || !is_readable($filename)) {
|
||||
if (!is_file($filename) || !is_readable($filename)) {
|
||||
return false;
|
||||
}
|
||||
$fp = fopen($filename, 'r');
|
||||
|
||||
if(!$fp) {
|
||||
if (!$fp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->_lock && !flock($fp, LOCK_SH)) {
|
||||
if ($this->_lock && !flock($fp, LOCK_SH)) {
|
||||
return false;
|
||||
}
|
||||
$expires = fgets($fp, 11);
|
||||
|
||||
if(intval($expires) < time()) {
|
||||
if (intval($expires) < time()) {
|
||||
fclose($fp);
|
||||
unlink($filename);
|
||||
return false;
|
||||
}
|
||||
$data = '';
|
||||
|
||||
while(!feof($fp)) {
|
||||
while (!feof($fp)) {
|
||||
$data .= fgets($fp, 4096);
|
||||
}
|
||||
$data = trim($data);
|
||||
|
@ -189,11 +189,11 @@ class FileEngine extends CacheEngine {
|
|||
function _getExpiry($filename) {
|
||||
$fp = fopen($filename, 'r');
|
||||
|
||||
if(!$fp) {
|
||||
if (!$fp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->_lock && !flock($fp, LOCK_SH)) {
|
||||
if ($this->_lock && !flock($fp, LOCK_SH)) {
|
||||
return false;
|
||||
}
|
||||
$expires = intval(fgets($fp, 11));
|
||||
|
@ -226,21 +226,21 @@ class FileEngine extends CacheEngine {
|
|||
$threshold = $now - 86400;
|
||||
}
|
||||
|
||||
while(($entry = $dir->read()) !== false) {
|
||||
if(strpos($entry, $this->_prefix) !== 0) {
|
||||
while (($entry = $dir->read()) !== false) {
|
||||
if (strpos($entry, $this->_prefix) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$filename = $this->_dir.$entry;
|
||||
|
||||
if($checkExpiry) {
|
||||
if ($checkExpiry) {
|
||||
$mtime = filemtime($filename);
|
||||
|
||||
if($mtime === false || $mtime > $threshold) {
|
||||
if ($mtime === false || $mtime > $threshold) {
|
||||
continue;
|
||||
}
|
||||
$expires = $this->_getExpiry($filename);
|
||||
|
||||
if($expires > $now) {
|
||||
if ($expires > $now) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ class FileEngine extends CacheEngine {
|
|||
*/
|
||||
function settings() {
|
||||
$lock = 'false';
|
||||
if($this->_lock) {
|
||||
if ($this->_lock) {
|
||||
$lock = 'true';
|
||||
}
|
||||
return array('class' => get_class($this),
|
||||
|
|
10
cake/libs/cache/memcache.php
vendored
10
cake/libs/cache/memcache.php
vendored
|
@ -56,31 +56,31 @@ class MemcacheEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function init(&$params) {
|
||||
if(!class_exists('Memcache')) {
|
||||
if (!class_exists('Memcache')) {
|
||||
return false;
|
||||
}
|
||||
$servers = array('127.0.0.1');
|
||||
$compress = false;
|
||||
extract($params);
|
||||
|
||||
if($compress) {
|
||||
if ($compress) {
|
||||
$this->_compress = MEMCACHE_COMPRESSED;
|
||||
} else {
|
||||
$this->_compress = 0;
|
||||
}
|
||||
|
||||
if(!is_array($servers)) {
|
||||
if (!is_array($servers)) {
|
||||
$servers = array($servers);
|
||||
}
|
||||
$this->__Memcache =& new Memcache();
|
||||
$connected = false;
|
||||
|
||||
foreach($servers as $server) {
|
||||
foreach ($servers as $server) {
|
||||
$parts = explode(':', $server);
|
||||
$host = $parts[0];
|
||||
$port = isset($parts[1]) ? $parts[1] : 11211;
|
||||
|
||||
if($this->__Memcache->addServer($host, $port)) {
|
||||
if ($this->__Memcache->addServer($host, $port)) {
|
||||
$connected = true;
|
||||
}
|
||||
}
|
||||
|
|
6
cake/libs/cache/model.php
vendored
6
cake/libs/cache/model.php
vendored
|
@ -72,7 +72,7 @@ class ModelEngine extends CacheEngine {
|
|||
$expiryField = 'expires';
|
||||
extract($params);
|
||||
|
||||
if(!class_exists($modelName) && !loadModel($modelName)) {
|
||||
if (!class_exists($modelName) && !loadModel($modelName)) {
|
||||
return false;
|
||||
}
|
||||
$this->_Model = new $modelName;
|
||||
|
@ -99,7 +99,7 @@ class ModelEngine extends CacheEngine {
|
|||
function write($key, &$value, $duration = CACHE_DEFAULT_DURATION) {
|
||||
$serialized = serialize($value);
|
||||
|
||||
if(!$serialized) {
|
||||
if (!$serialized) {
|
||||
return false;
|
||||
}
|
||||
$data = array($this->_Model->name => array(
|
||||
|
@ -150,7 +150,7 @@ class ModelEngine extends CacheEngine {
|
|||
*/
|
||||
function settings() {
|
||||
$class = null;
|
||||
if(is_a($this->_Model, 'Model')) {
|
||||
if (is_a($this->_Model, 'Model')) {
|
||||
$class = get_class($this->_Model);
|
||||
}
|
||||
return array('class' => get_class($this),
|
||||
|
|
14
cake/libs/cache/xcache.php
vendored
14
cake/libs/cache/xcache.php
vendored
|
@ -81,7 +81,7 @@ class XcacheEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function read($key) {
|
||||
if(xcache_isset($key)) {
|
||||
if (xcache_isset($key)) {
|
||||
return xcache_get($key);
|
||||
}
|
||||
return false;
|
||||
|
@ -106,8 +106,8 @@ class XcacheEngine extends CacheEngine {
|
|||
$result = true;
|
||||
$this->_phpAuth();
|
||||
|
||||
for($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
|
||||
if(!xcache_clear_cache(XC_TYPE_VAR, $i)) {
|
||||
for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
|
||||
if (!xcache_clear_cache(XC_TYPE_VAR, $i)) {
|
||||
$result = false;
|
||||
break;
|
||||
}
|
||||
|
@ -137,9 +137,9 @@ class XcacheEngine extends CacheEngine {
|
|||
static $backup = array();
|
||||
$keys = array('PHP_AUTH_USER', 'PHP_AUTH_PW');
|
||||
|
||||
foreach($keys as $key) {
|
||||
if($reverse) {
|
||||
if(isset($backup[$key])) {
|
||||
foreach ($keys as $key) {
|
||||
if ($reverse) {
|
||||
if (isset($backup[$key])) {
|
||||
$_SERVER[$key] = $backup[$key];
|
||||
unset($backup[$key]);
|
||||
} else {
|
||||
|
@ -147,7 +147,7 @@ class XcacheEngine extends CacheEngine {
|
|||
}
|
||||
} else {
|
||||
$value = env($key);
|
||||
if(!empty($value)) {
|
||||
if (!empty($value)) {
|
||||
$backup[$key] = $value;
|
||||
}
|
||||
$varName = '_' . low($key);
|
||||
|
|
|
@ -101,7 +101,7 @@ class ClassRegistry {
|
|||
function isKeySet($key) {
|
||||
$_this =& ClassRegistry::getInstance();
|
||||
$key = Inflector::underscore($key);
|
||||
if(array_key_exists($key, $_this->__objects)) {
|
||||
if (array_key_exists($key, $_this->__objects)) {
|
||||
return true;
|
||||
} elseif (array_key_exists($key, $_this->__map)) {
|
||||
return true;
|
||||
|
@ -129,11 +129,11 @@ class ClassRegistry {
|
|||
$_this =& ClassRegistry::getInstance();
|
||||
$key = Inflector::underscore($key);
|
||||
|
||||
if(isset($_this->__objects[$key])){
|
||||
if (isset($_this->__objects[$key])){
|
||||
return $_this->__objects[$key];
|
||||
} else {
|
||||
$key = $_this->__getMap($key);
|
||||
if(isset($_this->__objects[$key])){
|
||||
if (isset($_this->__objects[$key])){
|
||||
return $_this->__objects[$key];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,19 +114,19 @@ class Configure extends Object {
|
|||
function write($config, $value = null){
|
||||
$_this =& Configure::getInstance();
|
||||
|
||||
if(!is_array($config) && $value !== null) {
|
||||
if (!is_array($config) && $value !== null) {
|
||||
$name = $_this->__configVarNames($config);
|
||||
|
||||
if(count($name) > 1){
|
||||
if (count($name) > 1){
|
||||
$_this->{$name[0]}[$name[1]] = $value;
|
||||
} else {
|
||||
$_this->{$name[0]} = $value;
|
||||
}
|
||||
} else {
|
||||
|
||||
foreach($config as $names => $value){
|
||||
foreach ($config as $names => $value){
|
||||
$name = $_this->__configVarNames($names);
|
||||
if(count($name) > 1){
|
||||
if (count($name) > 1){
|
||||
$_this->{$name[0]}[$name[1]] = $value;
|
||||
} else {
|
||||
$_this->{$name[0]} = $value;
|
||||
|
@ -142,7 +142,7 @@ class Configure extends Object {
|
|||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
if(!class_exists('Debugger')) {
|
||||
if (!class_exists('Debugger')) {
|
||||
require LIBS . 'debugger.php';
|
||||
}
|
||||
if (!class_exists('CakeLog')) {
|
||||
|
@ -168,21 +168,21 @@ class Configure extends Object {
|
|||
*/
|
||||
function read($var = 'debug'){
|
||||
$_this =& Configure::getInstance();
|
||||
if($var === 'debug') {
|
||||
if(!isset($_this->debug)){
|
||||
if ($var === 'debug') {
|
||||
if (!isset($_this->debug)){
|
||||
$_this->debug = DEBUG;
|
||||
}
|
||||
return $_this->debug;
|
||||
}
|
||||
|
||||
$name = $_this->__configVarNames($var);
|
||||
if(count($name) > 1){
|
||||
if(isset($_this->{$name[0]}[$name[1]])) {
|
||||
if (count($name) > 1){
|
||||
if (isset($_this->{$name[0]}[$name[1]])) {
|
||||
return $_this->{$name[0]}[$name[1]];
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
if(isset($_this->{$name[0]})) {
|
||||
if (isset($_this->{$name[0]})) {
|
||||
return $_this->{$name[0]};
|
||||
}
|
||||
return null;
|
||||
|
@ -202,7 +202,7 @@ class Configure extends Object {
|
|||
$_this =& Configure::getInstance();
|
||||
|
||||
$name = $_this->__configVarNames($var);
|
||||
if(count($name) > 1){
|
||||
if (count($name) > 1){
|
||||
unset($_this->{$name[0]}[$name[1]]);
|
||||
} else {
|
||||
unset($_this->{$name[0]});
|
||||
|
@ -230,7 +230,7 @@ class Configure extends Object {
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!isset($config)){
|
||||
if (!isset($config)){
|
||||
trigger_error(sprintf(__("Configure::load() - no variable \$config found in %s.php", true), $fileName), E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ class Configure extends Object {
|
|||
*/
|
||||
function version() {
|
||||
$_this =& Configure::getInstance();
|
||||
if(!isset($_this->Cake['version'])) {
|
||||
if (!isset($_this->Cake['version'])) {
|
||||
require(CORE_PATH . 'cake' . DS . 'config' . DS . 'config.php');
|
||||
$_this->write($config);
|
||||
}
|
||||
|
@ -268,9 +268,9 @@ class Configure extends Object {
|
|||
$content = '';
|
||||
foreach ($data as $key => $value) {
|
||||
$content .= "\$config['$type']['$key']";
|
||||
if(is_array($value)){
|
||||
if (is_array($value)){
|
||||
$content .= " = array(";
|
||||
foreach($value as $key1 => $value2){
|
||||
foreach ($value as $key1 => $value2){
|
||||
$value2 = addslashes($value2);
|
||||
$content .= "'$key1' => '$value2', ";
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ class Configure extends Object {
|
|||
$content .= " = '$value';\n";
|
||||
}
|
||||
}
|
||||
if(is_null($type)) {
|
||||
if (is_null($type)) {
|
||||
$write = false;
|
||||
}
|
||||
$_this->__writeConfig($content, $name, $write);
|
||||
|
@ -304,16 +304,16 @@ class Configure extends Object {
|
|||
}
|
||||
|
||||
$cache = cache('persistent' . DS . $name . '.php', null, $expires);
|
||||
if($cache === null){
|
||||
if ($cache === null){
|
||||
cache('persistent' . DS . $name . '.php', "<?php\n\$config = array();\n", $expires);
|
||||
}
|
||||
|
||||
if($write === true){
|
||||
if(!class_exists('File')){
|
||||
if ($write === true){
|
||||
if (!class_exists('File')){
|
||||
uses('File');
|
||||
}
|
||||
$fileClass = new File($file);
|
||||
if($fileClass->writable()) {
|
||||
if ($fileClass->writable()) {
|
||||
$fileClass->append($content);
|
||||
}
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ class Configure extends Object {
|
|||
$_this =& Configure::getInstance();
|
||||
$_this->modelPaths[] = MODELS;
|
||||
if (isset($modelPaths)) {
|
||||
foreach($modelPaths as $value) {
|
||||
foreach ($modelPaths as $value) {
|
||||
$_this->modelPaths[] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ class Configure extends Object {
|
|||
$_this =& Configure::getInstance();
|
||||
$_this->viewPaths[] = VIEWS;
|
||||
if (isset($viewPaths)) {
|
||||
foreach($viewPaths as $value) {
|
||||
foreach ($viewPaths as $value) {
|
||||
$_this->viewPaths[] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ class Configure extends Object {
|
|||
$_this =& Configure::getInstance();
|
||||
$_this->controllerPaths[] = CONTROLLERS;
|
||||
if (isset($controllerPaths)) {
|
||||
foreach($controllerPaths as $value) {
|
||||
foreach ($controllerPaths as $value) {
|
||||
$_this->controllerPaths[] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ class Configure extends Object {
|
|||
$_this =& Configure::getInstance();
|
||||
$_this->helperPaths[] = HELPERS;
|
||||
if (isset($helperPaths)) {
|
||||
foreach($helperPaths as $value) {
|
||||
foreach ($helperPaths as $value) {
|
||||
$_this->helperPaths[] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ class Configure extends Object {
|
|||
$_this =& Configure::getInstance();
|
||||
$_this->componentPaths[] = COMPONENTS;
|
||||
if (isset($componentPaths)) {
|
||||
foreach($componentPaths as $value) {
|
||||
foreach ($componentPaths as $value) {
|
||||
$_this->componentPaths[] = $value;
|
||||
}
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ class Configure extends Object {
|
|||
$_this =& Configure::getInstance();
|
||||
$_this->behaviorPaths[] = BEHAVIORS;
|
||||
if (isset($behaviorPaths)) {
|
||||
foreach($behaviorPaths as $value) {
|
||||
foreach ($behaviorPaths as $value) {
|
||||
$_this->behaviorPaths[] = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,10 +64,10 @@ class Component extends Object {
|
|||
$this->controller->components = array_merge($this->controller->components, array('Session'));
|
||||
$loaded = $this->_loadComponents($loaded, $this->controller->components);
|
||||
|
||||
foreach(array_keys($loaded) as $component) {
|
||||
foreach (array_keys($loaded) as $component) {
|
||||
$tempComponent =& $loaded[$component];
|
||||
if (isset($tempComponent->components) && is_array($tempComponent->components)) {
|
||||
foreach($tempComponent->components as $subComponent) {
|
||||
foreach ($tempComponent->components as $subComponent) {
|
||||
$this->controller->{$component}->{$subComponent} =& $loaded[$subComponent];
|
||||
}
|
||||
}
|
||||
|
@ -88,10 +88,10 @@ class Component extends Object {
|
|||
function &_loadComponents(&$loaded, $components) {
|
||||
$components[] = 'Session';
|
||||
|
||||
foreach($components as $component) {
|
||||
foreach ($components as $component) {
|
||||
$parts = preg_split('/\/|\./', $component);
|
||||
|
||||
if(count($parts) === 1) {
|
||||
if (count($parts) === 1) {
|
||||
$plugin = $this->controller->plugin;
|
||||
} else {
|
||||
$plugin = Inflector::underscore($parts['0']);
|
||||
|
|
|
@ -52,7 +52,7 @@ class AclComponent extends Object {
|
|||
* @return MyACL
|
||||
*/
|
||||
function &getACL() {
|
||||
if($this->_instance == null) {
|
||||
if ($this->_instance == null) {
|
||||
$classname = ACL_CLASSNAME;
|
||||
$this->_instance = new $classname;
|
||||
$this->_instance->initialize($this);
|
||||
|
@ -268,7 +268,7 @@ class DB_ACL extends AclBase {
|
|||
return false;
|
||||
}
|
||||
|
||||
for($i = count($aroPath) - 1; $i >= 0; $i--) {
|
||||
for ($i = count($aroPath) - 1; $i >= 0; $i--) {
|
||||
$perms = $this->Aro->Permission->findAll(
|
||||
array(
|
||||
'Permission.aro_id' => $aroPath[$i]['Aro']['id'],
|
||||
|
@ -280,10 +280,10 @@ class DB_ACL extends AclBase {
|
|||
if (empty($perms)) {
|
||||
continue;
|
||||
} else {
|
||||
foreach(Set::extract($perms, '{n}.Permission') as $perm) {
|
||||
foreach (Set::extract($perms, '{n}.Permission') as $perm) {
|
||||
if ($action == '*') {
|
||||
// ARO must be cleared for ALL ACO actions
|
||||
foreach($permKeys as $key) {
|
||||
foreach ($permKeys as $key) {
|
||||
if (!empty($perm)) {
|
||||
if ($perm[$key] != 1) {
|
||||
return false;
|
||||
|
@ -330,16 +330,16 @@ class DB_ACL extends AclBase {
|
|||
if ($actions == "*") {
|
||||
$permKeys = $this->_getAcoKeys($this->Aro->Permission->loadInfo());
|
||||
|
||||
foreach($permKeys as $key) {
|
||||
foreach ($permKeys as $key) {
|
||||
$save[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
if(!is_array($actions)) {
|
||||
if (!is_array($actions)) {
|
||||
$actions = array('_' . $actions);
|
||||
$actions = am($permKeys, $actions);
|
||||
}
|
||||
if(is_array($actions)) {
|
||||
foreach($actions as $action) {
|
||||
if (is_array($actions)) {
|
||||
foreach ($actions as $action) {
|
||||
if ($action{0} != '_') {
|
||||
$action = '_' . $action;
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ class DB_ACL extends AclBase {
|
|||
$newKeys = array();
|
||||
$keys = $keys->extract('{n}.name');
|
||||
|
||||
foreach($keys as $key) {
|
||||
foreach ($keys as $key) {
|
||||
if (!in_array($key, array('id', 'aro_id', 'aco_id'))) {
|
||||
$newKeys[] = $key;
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ class INI_ACL extends AclBase {
|
|||
if (isset($aclConfig[$aro]['groups'])) {
|
||||
$userGroups = $this->arrayTrim(explode(",", $aclConfig[$aro]['groups']));
|
||||
|
||||
foreach($userGroups as $group) {
|
||||
foreach ($userGroups as $group) {
|
||||
//If such a group exists,
|
||||
if (array_key_exists($group, $aclConfig)) {
|
||||
//If the group is specifically denied, then DENY
|
||||
|
@ -550,7 +550,7 @@ class INI_ACL extends AclBase {
|
|||
function readConfigFile($fileName) {
|
||||
$fileLineArray = file($fileName);
|
||||
|
||||
foreach($fileLineArray as $fileLine) {
|
||||
foreach ($fileLineArray as $fileLine) {
|
||||
$dataLine = trim($fileLine);
|
||||
$firstChar = substr($dataLine, 0, 1);
|
||||
|
||||
|
@ -590,7 +590,7 @@ class INI_ACL extends AclBase {
|
|||
* @return array
|
||||
*/
|
||||
function arrayTrim($array) {
|
||||
foreach($array as $element) {
|
||||
foreach ($array as $element) {
|
||||
$element = trim($element);
|
||||
}
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ class AuthComponent extends Object {
|
|||
CAKE_ADMIN . '_delete' => 'delete'
|
||||
));
|
||||
}
|
||||
if(Configure::read() > 0) {
|
||||
if (Configure::read() > 0) {
|
||||
uses('debugger');
|
||||
Debugger::checkSessionKey();
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ class AuthComponent extends Object {
|
|||
if ($this->_normalizeURL($this->loginAction) == $this->_normalizeURL($url)) {
|
||||
// We're already at the login action
|
||||
if (empty($controller->data) || !isset($controller->data[$this->userModel])) {
|
||||
if(!$this->Session->check('Auth.redirect')) {
|
||||
if (!$this->Session->check('Auth.redirect')) {
|
||||
$this->Session->write('Auth.redirect', $controller->referer());
|
||||
}
|
||||
return;
|
||||
|
@ -537,7 +537,7 @@ class AuthComponent extends Object {
|
|||
* @return string Redirect URL
|
||||
*/
|
||||
function redirect($url = null) {
|
||||
if(!is_null($url)) {
|
||||
if (!is_null($url)) {
|
||||
return $this->Session->write('Auth.redirect', $url);
|
||||
}
|
||||
if ($this->Session->check('Auth.redirect')) {
|
||||
|
@ -638,13 +638,13 @@ class AuthComponent extends Object {
|
|||
if (empty($user)) {
|
||||
return null;
|
||||
}
|
||||
} else if (is_object($user) && is_a($user, 'Model')) {
|
||||
} elseif (is_object($user) && is_a($user, 'Model')) {
|
||||
if (!$user->exists()) {
|
||||
return null;
|
||||
}
|
||||
$user = $user->read();
|
||||
$user = $user[$this->userModel];
|
||||
} else if (is_array($user) && isset($user[$this->userModel])) {
|
||||
} elseif (is_array($user) && isset($user[$this->userModel])) {
|
||||
$user = $user[$this->userModel];
|
||||
}
|
||||
|
||||
|
@ -673,7 +673,7 @@ class AuthComponent extends Object {
|
|||
if (empty($data) || empty($data[$this->userModel])) {
|
||||
return null;
|
||||
}
|
||||
} else if (is_numeric($user)) {
|
||||
} elseif (is_numeric($user)) {
|
||||
// Assume it's a user's ID
|
||||
$model =& $this->getUserModel();
|
||||
$data = $model->find(am(array($model->escapeField() => $user), $this->userScope));
|
||||
|
@ -683,7 +683,7 @@ class AuthComponent extends Object {
|
|||
}
|
||||
}
|
||||
if (isset($data) && !empty($data)) {
|
||||
if(!empty($data[$this->userModel][$this->fields['password']])) {
|
||||
if (!empty($data[$this->userModel][$this->fields['password']])) {
|
||||
unset($data[$this->userModel][$this->fields['password']]);
|
||||
}
|
||||
return $data[$this->userModel];
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
/**
|
||||
* Load Security class
|
||||
*/
|
||||
if(!class_exists('Security')){
|
||||
if (!class_exists('Security')){
|
||||
uses('Security');
|
||||
}
|
||||
/**
|
||||
|
@ -162,23 +162,23 @@ class CookieComponent extends Object {
|
|||
* @deprecated use Controller::beforeFilter() to set the properties of the CookieComponent
|
||||
*/
|
||||
function initialize(&$controller) {
|
||||
if(is_object($controller)){
|
||||
if(isset($controller->cookieName)) {
|
||||
if (is_object($controller)){
|
||||
if (isset($controller->cookieName)) {
|
||||
$this->name = $controller->cookieName;
|
||||
}
|
||||
if(isset($controller->cookieTime)){
|
||||
if (isset($controller->cookieTime)){
|
||||
$this->time = $controller->cookieTime;
|
||||
}
|
||||
if(isset($controller->cookieKey)){
|
||||
if (isset($controller->cookieKey)){
|
||||
$this->key = $controller->cookieKey;
|
||||
}
|
||||
if(isset($controller->cookiePath)) {
|
||||
if (isset($controller->cookiePath)) {
|
||||
$this->path = $controller->cookiePath;
|
||||
}
|
||||
if(isset($controller->cookieDomain)) {
|
||||
if (isset($controller->cookieDomain)) {
|
||||
$this->domain = $controller->cookieDomain;
|
||||
}
|
||||
if(isset($controller->cookieSecure)) {
|
||||
if (isset($controller->cookieSecure)) {
|
||||
$this->secure = $controller->cookieSecure;
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ class CookieComponent extends Object {
|
|||
function startup() {
|
||||
$this->__expire($this->time);
|
||||
|
||||
if(isset($_COOKIE[$this->name])) {
|
||||
if (isset($_COOKIE[$this->name])) {
|
||||
$this->__values = $this->__decrypt($_COOKIE[$this->name]);
|
||||
}
|
||||
}
|
||||
|
@ -214,17 +214,17 @@ class CookieComponent extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function write($key, $value = null, $encrypt = true, $expires = null) {
|
||||
if(is_null($encrypt)){
|
||||
if (is_null($encrypt)){
|
||||
$encrypt = true;
|
||||
}
|
||||
|
||||
$this->__encrypted = $encrypt;
|
||||
$this->__expire($expires);
|
||||
|
||||
if(!is_array($key) && $value !== null) {
|
||||
if (!is_array($key) && $value !== null) {
|
||||
$name = $this->__cookieVarNames($key);
|
||||
|
||||
if(count($name) > 1){
|
||||
if (count($name) > 1){
|
||||
$this->__values[$name[0]][$name[1]] = $value;
|
||||
$this->__write("[".$name[0]."][".$name[1]."]", $value);
|
||||
} else {
|
||||
|
@ -232,10 +232,10 @@ class CookieComponent extends Object {
|
|||
$this->__write("[".$name[0]."]", $value);
|
||||
}
|
||||
} else {
|
||||
foreach($key as $names => $value){
|
||||
foreach ($key as $names => $value){
|
||||
$name = $this->__cookieVarNames($names);
|
||||
|
||||
if(count($name) > 1){
|
||||
if (count($name) > 1){
|
||||
$this->__values[$name[0]][$name[1]] = $value;
|
||||
$this->__write("[".$name[0]."][".$name[1]."]", $value);
|
||||
} else {
|
||||
|
@ -256,23 +256,23 @@ class CookieComponent extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function read($key = null) {
|
||||
if(empty($this->__values) && isset($_COOKIE[$this->name])) {
|
||||
if (empty($this->__values) && isset($_COOKIE[$this->name])) {
|
||||
$this->__values = $this->__decrypt($_COOKIE[$this->name]);
|
||||
}
|
||||
|
||||
if(is_null($key)){
|
||||
if (is_null($key)){
|
||||
return $this->__values;
|
||||
}
|
||||
$name = $this->__cookieVarNames($key);
|
||||
|
||||
if(count($name) > 1){
|
||||
if(isset($this->__values[$name[0]])) {
|
||||
if (count($name) > 1){
|
||||
if (isset($this->__values[$name[0]])) {
|
||||
$value = $this->__values[$name[0]][$name[1]];
|
||||
return $value;
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
if(isset($this->__values[$name[0]])) {
|
||||
if (isset($this->__values[$name[0]])) {
|
||||
$value = $this->__values[$name[0]];
|
||||
return $value;
|
||||
}
|
||||
|
@ -294,14 +294,14 @@ class CookieComponent extends Object {
|
|||
function del($key) {
|
||||
$name = $this->__cookieVarNames($key);
|
||||
|
||||
if(count($name) > 1){
|
||||
if(isset($this->__values[$name[0]])) {
|
||||
if (count($name) > 1){
|
||||
if (isset($this->__values[$name[0]])) {
|
||||
unset($this->__values[$name[0]][$name[1]]);
|
||||
$this->__delete("[".$name[0]."][".$name[1]."]");
|
||||
}
|
||||
} else {
|
||||
if(isset($this->__values[$name[0]])) {
|
||||
if(is_array($this->__values[$name[0]])) {
|
||||
if (isset($this->__values[$name[0]])) {
|
||||
if (is_array($this->__values[$name[0]])) {
|
||||
foreach ($this->__values[$name[0]] as $key => $value) {
|
||||
$this->__delete("[".$name[0]."][".$key."]");
|
||||
}
|
||||
|
@ -320,12 +320,12 @@ class CookieComponent extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function destroy() {
|
||||
if(isset($_COOKIE[$this->name])) {
|
||||
if (isset($_COOKIE[$this->name])) {
|
||||
$this->__values = $this->__decrypt($_COOKIE[$this->name]);
|
||||
}
|
||||
|
||||
foreach ($this->__values as $name => $value) {
|
||||
if(is_array($value)) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $key => $val) {
|
||||
unset($this->__values[$name][$key]);
|
||||
$this->__delete("[$name][$key]");
|
||||
|
@ -362,7 +362,7 @@ class CookieComponent extends Object {
|
|||
*/
|
||||
function __expire($expires = null){
|
||||
$now = time();
|
||||
if(is_null($expires)){
|
||||
if (is_null($expires)){
|
||||
return $this->__expires;
|
||||
}
|
||||
$this->__reset = $this->__expires;
|
||||
|
@ -382,7 +382,7 @@ class CookieComponent extends Object {
|
|||
function __write($name, $value) {
|
||||
setcookie($this->name . "$name", $this->__encrypt($value), $this->__expires, $this->path, $this->domain, $this->secure);
|
||||
|
||||
if(!is_null($this->__reset)){
|
||||
if (!is_null($this->__reset)){
|
||||
$this->__expires = $this->__reset;
|
||||
$this->__reset = null;
|
||||
}
|
||||
|
@ -405,11 +405,11 @@ class CookieComponent extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __encrypt($value) {
|
||||
if(is_array($value)){
|
||||
if (is_array($value)){
|
||||
$value = $this->__implode($value);
|
||||
}
|
||||
|
||||
if($this->__encrypted === true) {
|
||||
if ($this->__encrypted === true) {
|
||||
$type = $this->__type;
|
||||
$value = "Q2FrZQ==." .base64_encode(Security::$type($value, $this->key));
|
||||
}
|
||||
|
@ -426,8 +426,8 @@ class CookieComponent extends Object {
|
|||
$decrypted = array();
|
||||
$type = $this->__type;
|
||||
|
||||
foreach($values as $name => $value) {
|
||||
if(is_array($value)){
|
||||
foreach ($values as $name => $value) {
|
||||
if (is_array($value)){
|
||||
foreach ($value as $key => $val) {
|
||||
$pos = strpos($val, 'Q2FrZQ==.');
|
||||
$decrypted[$name][$key] = $this->__explode($val);
|
||||
|
@ -494,7 +494,7 @@ class CookieComponent extends Object {
|
|||
$array = array();
|
||||
foreach (explode(',', $string) as $pair) {
|
||||
$key = explode('|', $pair);
|
||||
if(!isset($key[1])){
|
||||
if (!isset($key[1])){
|
||||
return $key[0];
|
||||
}
|
||||
$array[$key[0]] = $key[1];
|
||||
|
|
|
@ -217,8 +217,8 @@ class EmailComponent extends Object{
|
|||
$this->__createHeader();
|
||||
$this->subject = $this->__encode($this->subject);
|
||||
|
||||
if($this->template === null) {
|
||||
if(is_array($content)){
|
||||
if ($this->template === null) {
|
||||
if (is_array($content)){
|
||||
$message = null;
|
||||
foreach ($content as $key => $value){
|
||||
$message .= $value . $this->_newLine;
|
||||
|
@ -231,7 +231,7 @@ class EmailComponent extends Object{
|
|||
$this->__message = $this->__renderTemplate($content);
|
||||
}
|
||||
|
||||
if(!empty($this->attachments)) {
|
||||
if (!empty($this->attachments)) {
|
||||
$this->__attachFiles();
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ class EmailComponent extends Object{
|
|||
function __renderTemplate($content) {
|
||||
$View = new View($this->Controller);
|
||||
$View->layout = $this->layout;
|
||||
if($this->sendAs === 'both'){
|
||||
if ($this->sendAs === 'both'){
|
||||
$htmlContent = $content;
|
||||
$msg = '--' . $this->__boundary . $this->_newLine;
|
||||
$msg .= 'Content-Type: text/plain; charset=' . $this->charset . $this->_newLine;
|
||||
|
@ -320,14 +320,14 @@ class EmailComponent extends Object{
|
|||
}
|
||||
|
||||
$addresses = null;
|
||||
if(!empty($this->cc)) {
|
||||
if (!empty($this->cc)) {
|
||||
foreach ($this->cc as $cc) {
|
||||
$addresses .= $this->__formatAddress($cc) . ', ';
|
||||
}
|
||||
$this->__header .= 'cc: ' . $addresses . $this->_newLine;
|
||||
}
|
||||
$addresses = null;
|
||||
if(!empty($this->bcc)) {
|
||||
if (!empty($this->bcc)) {
|
||||
foreach ($this->bcc as $bcc) {
|
||||
$addresses .= $this->__formatAddress($bcc) . ', ';
|
||||
}
|
||||
|
@ -336,18 +336,18 @@ class EmailComponent extends Object{
|
|||
|
||||
$this->__header .= 'X-Mailer: ' . $this->xMailer . $this->_newLine;
|
||||
|
||||
if(!empty($this->attachments) && $this->sendAs === 'text') {
|
||||
if (!empty($this->attachments) && $this->sendAs === 'text') {
|
||||
$this->__createBoundary();
|
||||
$this->__header .= 'MIME-Version: 1.0' . $this->_newLine;
|
||||
$this->__header .= 'Content-Type: multipart/mixed; boundary="' . $this->__boundary . '"' . $this->_newLine;
|
||||
} elseif(!empty($this->attachments) && $this->sendAs === 'html') {
|
||||
} elseif (!empty($this->attachments) && $this->sendAs === 'html') {
|
||||
$this->__createBoundary();
|
||||
$this->__header .= 'MIME-Version: 1.0' . $this->_newLine;
|
||||
$this->__header .= 'Content-Type: multipart/related; boundary="' . $this->__boundary . '"' . $this->_newLine;
|
||||
} elseif($this->sendAs === 'html') {
|
||||
} elseif ($this->sendAs === 'html') {
|
||||
$this->__header .= 'Content-Type: text/html; charset=' . $this->charset . $this->_newLine;
|
||||
$this->__header .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
|
||||
} elseif($this->sendAs === 'both') {
|
||||
} elseif ($this->sendAs === 'both') {
|
||||
$this->__createBoundary();
|
||||
$this->__header .= 'MIME-Version: 1.0' . $this->_newLine;
|
||||
$this->__header .= 'Content-Type: multipart/alternative; boundary="' . $this->__boundary . '"' . $this->_newLine;
|
||||
|
@ -362,7 +362,7 @@ class EmailComponent extends Object{
|
|||
function __formatMessage($message){
|
||||
$message = $this->__wrap($message);
|
||||
|
||||
if($this->sendAs === 'both'){
|
||||
if ($this->sendAs === 'both'){
|
||||
$this->__message = '--' . $this->__boundary . $this->_newLine;
|
||||
$this->__message .= 'Content-Type: text/plain; charset=' . $this->charset . $this->_newLine;
|
||||
$this->__message .= 'Content-Transfer-Encoding: 8bit' . $this->_newLine;
|
||||
|
@ -385,11 +385,11 @@ class EmailComponent extends Object{
|
|||
* @access private
|
||||
*/
|
||||
function __attachFiles(){
|
||||
foreach($this->attachments as $attachment) {
|
||||
foreach ($this->attachments as $attachment) {
|
||||
$files[] = $this->__findFiles($attachment);
|
||||
}
|
||||
|
||||
foreach($files as $file) {
|
||||
foreach ($files as $file) {
|
||||
$handle = fopen($file, 'rb');
|
||||
$data = fread($handle, filesize($file));
|
||||
$data = chunk_split(base64_encode($data)) ;
|
||||
|
@ -410,7 +410,7 @@ class EmailComponent extends Object{
|
|||
* @access private
|
||||
*/
|
||||
function __findFiles($attachment){
|
||||
foreach($this->filePaths as $path) {
|
||||
foreach ($this->filePaths as $path) {
|
||||
if (file_exists($path . DS . $attachment)) {
|
||||
$file = $path . DS . $attachment;
|
||||
return $file;
|
||||
|
@ -442,7 +442,7 @@ class EmailComponent extends Object{
|
|||
* @access private
|
||||
*/
|
||||
function __encode($subject) {
|
||||
if(low($this->charset) !== 'iso-8859-15') {
|
||||
if (low($this->charset) !== 'iso-8859-15') {
|
||||
$start = "=?" . $this->charset . "?B?";
|
||||
$end = "?=";
|
||||
$spacer = $end . "\n " . $start;
|
||||
|
@ -467,7 +467,7 @@ class EmailComponent extends Object{
|
|||
* @access private
|
||||
*/
|
||||
function __formatAddress($string){
|
||||
if(strpos($string, '<') !== false){
|
||||
if (strpos($string, '<') !== false){
|
||||
$value = explode('<', $string);
|
||||
$string = $this->__encode($value[0]) . ' <' . $value[1];
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ class RequestHandlerComponent extends Object {
|
|||
function __construct() {
|
||||
$this->__acceptTypes = explode(',', env('HTTP_ACCEPT'));
|
||||
|
||||
foreach($this->__acceptTypes as $i => $type) {
|
||||
foreach ($this->__acceptTypes as $i => $type) {
|
||||
if (strpos($type, ';')) {
|
||||
$type = explode(';', $type);
|
||||
$this->__acceptTypes[$i] = $type[0];
|
||||
|
@ -389,14 +389,14 @@ class RequestHandlerComponent extends Object {
|
|||
if ($type == null) {
|
||||
return $this->mapType($this->__acceptTypes);
|
||||
|
||||
} else if(is_array($type)) {
|
||||
foreach($type as $t) {
|
||||
} elseif (is_array($type)) {
|
||||
foreach ($type as $t) {
|
||||
if ($this->accepts($t) == true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if(is_string($type)) {
|
||||
} elseif (is_string($type)) {
|
||||
|
||||
if (!in_array($type, array_keys($this->__requestContent))) {
|
||||
return false;
|
||||
|
@ -405,7 +405,7 @@ class RequestHandlerComponent extends Object {
|
|||
$content = $this->__requestContent[$type];
|
||||
|
||||
if (is_array($content)) {
|
||||
foreach($content as $c) {
|
||||
foreach ($content as $c) {
|
||||
if (in_array($c, $this->__acceptTypes)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -433,14 +433,14 @@ class RequestHandlerComponent extends Object {
|
|||
if ($type == null) {
|
||||
return $this->mapType(env('CONTENT_TYPE'));
|
||||
|
||||
} else if(is_array($type)) {
|
||||
foreach($type as $t) {
|
||||
} elseif (is_array($type)) {
|
||||
foreach ($type as $t) {
|
||||
if ($this->requestedWith($t)) {
|
||||
return $this->mapType($t);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if(is_string($type)) {
|
||||
} elseif (is_string($type)) {
|
||||
|
||||
return ($type == $this->mapType(env('CONTENT_TYPE')));
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ class SecurityComponent extends Object {
|
|||
$this->__authRequired($controller);
|
||||
$this->__loginRequired($controller);
|
||||
|
||||
if((!isset($controller->params['requested']) || $controller->params['requested'] != 1) && $this->RequestHandler->isPost()) {
|
||||
if ((!isset($controller->params['requested']) || $controller->params['requested'] != 1) && $this->RequestHandler->isPost()) {
|
||||
$this->__validatePost($controller);
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ class SecurityComponent extends Object {
|
|||
*/
|
||||
function requirePost() {
|
||||
$this->requirePost = func_get_args();
|
||||
if(empty($this->requirePost)) {
|
||||
if (empty($this->requirePost)) {
|
||||
$this->requirePost = array('*');
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ class SecurityComponent extends Object {
|
|||
*/
|
||||
function requireSecure() {
|
||||
$this->requireSecure = func_get_args();
|
||||
if(empty($this->requireSecure)) {
|
||||
if (empty($this->requireSecure)) {
|
||||
$this->requireSecure = array('*');
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ class SecurityComponent extends Object {
|
|||
*/
|
||||
function requireAuth() {
|
||||
$this->requireAuth = func_get_args();
|
||||
if(empty($this->requireAuth)) {
|
||||
if (empty($this->requireAuth)) {
|
||||
$this->requireAuth = array('*');
|
||||
}
|
||||
}
|
||||
|
@ -197,18 +197,18 @@ class SecurityComponent extends Object {
|
|||
function requireLogin() {
|
||||
$args = func_get_args();
|
||||
foreach ($args as $arg) {
|
||||
if(is_array($arg)) {
|
||||
if (is_array($arg)) {
|
||||
$this->loginOptions = $arg;
|
||||
} else {
|
||||
$this->requireLogin[] = $arg;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($this->requireLogin)) {
|
||||
if (empty($this->requireLogin)) {
|
||||
$this->requireLogin = array('*');
|
||||
}
|
||||
|
||||
if(isset($this->loginOptions['users'])) {
|
||||
if (isset($this->loginOptions['users'])) {
|
||||
$this->loginUsers =& $this->loginOptions['users'];
|
||||
}
|
||||
}
|
||||
|
@ -220,20 +220,20 @@ class SecurityComponent extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function loginCredentials($type = null) {
|
||||
if(empty($type) || low($type) == 'basic') {
|
||||
if (empty($type) || low($type) == 'basic') {
|
||||
$login = array('username' => env('PHP_AUTH_USER'), 'password' => env('PHP_AUTH_PW'));
|
||||
|
||||
if($login['username'] != null) {
|
||||
if ($login['username'] != null) {
|
||||
return $login;
|
||||
}
|
||||
}
|
||||
|
||||
if($type == '' || low($type) == 'digest') {
|
||||
if ($type == '' || low($type) == 'digest') {
|
||||
$digest = null;
|
||||
|
||||
if(version_compare(phpversion(), '5.1') != -1) {
|
||||
if (version_compare(phpversion(), '5.1') != -1) {
|
||||
$digest = env('PHP_AUTH_DIGEST');
|
||||
} elseif(function_exists('apache_request_headers')) {
|
||||
} elseif (function_exists('apache_request_headers')) {
|
||||
$headers = apache_request_headers();
|
||||
if (isset($headers['Authorization']) && !empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) == 'Digest ') {
|
||||
$digest = substr($headers['Authorization'], 7);
|
||||
|
@ -244,7 +244,7 @@ class SecurityComponent extends Object {
|
|||
return null;
|
||||
}
|
||||
|
||||
if($digest == null) {
|
||||
if ($digest == null) {
|
||||
return null;
|
||||
}
|
||||
$data = $this->parseDigestAuthData($digest);
|
||||
|
@ -272,7 +272,7 @@ class SecurityComponent extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function parseDigestAuthData($digest) {
|
||||
if(substr($digest, 0, 7) == 'Digest ') {
|
||||
if (substr($digest, 0, 7) == 'Digest ') {
|
||||
$digest = substr($digest, 7);
|
||||
}
|
||||
$keys = array();
|
||||
|
@ -280,12 +280,12 @@ class SecurityComponent extends Object {
|
|||
$req = array('nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1);
|
||||
preg_match_all('@(\w+)=([\'"]?)([a-zA-Z0-9=./\_-]+)\2@', $digest, $match, PREG_SET_ORDER);
|
||||
|
||||
foreach($match as $i) {
|
||||
foreach ($match as $i) {
|
||||
$keys[$i[1]] = $i[3];
|
||||
unset($req[$i[1]]);
|
||||
}
|
||||
|
||||
if(empty($req)) {
|
||||
if (empty($req)) {
|
||||
return $keys;
|
||||
} else {
|
||||
return null;
|
||||
|
@ -300,9 +300,9 @@ class SecurityComponent extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function blackHole(&$controller, $error = '') {
|
||||
if($this->blackHoleCallback == null) {
|
||||
if ($this->blackHoleCallback == null) {
|
||||
$code = 404;
|
||||
if($error == 'login') {
|
||||
if ($error == 'login') {
|
||||
$code = 401;
|
||||
}
|
||||
$controller->redirect(null, $code, true);
|
||||
|
@ -318,10 +318,10 @@ class SecurityComponent extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __postRequired(&$controller) {
|
||||
if(is_array($this->requirePost) && !empty($this->requirePost)) {
|
||||
if(in_array($controller->action, $this->requirePost) || $this->requirePost == array('*')) {
|
||||
if(!$this->RequestHandler->isPost()) {
|
||||
if(!$this->blackHole($controller, 'post')) {
|
||||
if (is_array($this->requirePost) && !empty($this->requirePost)) {
|
||||
if (in_array($controller->action, $this->requirePost) || $this->requirePost == array('*')) {
|
||||
if (!$this->RequestHandler->isPost()) {
|
||||
if (!$this->blackHole($controller, 'post')) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -337,10 +337,10 @@ class SecurityComponent extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __secureRequired(&$controller) {
|
||||
if(is_array($this->requireSecure) && !empty($this->requireSecure)) {
|
||||
if(in_array($controller->action, $this->requireSecure) || $this->requireSecure == array('*')) {
|
||||
if(!$this->RequestHandler->isSSL()) {
|
||||
if(!$this->blackHole($controller, 'secure')) {
|
||||
if (is_array($this->requireSecure) && !empty($this->requireSecure)) {
|
||||
if (in_array($controller->action, $this->requireSecure) || $this->requireSecure == array('*')) {
|
||||
if (!$this->RequestHandler->isSSL()) {
|
||||
if (!$this->blackHole($controller, 'secure')) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -356,25 +356,25 @@ class SecurityComponent extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __authRequired(&$controller) {
|
||||
if(is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($controller->data)) {
|
||||
if(in_array($controller->action, $this->requireAuth) || $this->requireAuth == array('*')) {
|
||||
if(!isset($controller->data['__Token'] )) {
|
||||
if(!$this->blackHole($controller, 'auth')) {
|
||||
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($controller->data)) {
|
||||
if (in_array($controller->action, $this->requireAuth) || $this->requireAuth == array('*')) {
|
||||
if (!isset($controller->data['__Token'] )) {
|
||||
if (!$this->blackHole($controller, 'auth')) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
$token = $controller->data['__Token']['key'];
|
||||
|
||||
if($this->Session->check('_Token')) {
|
||||
if ($this->Session->check('_Token')) {
|
||||
$tData = unserialize($this->Session->read('_Token'));
|
||||
|
||||
if(!empty($tData['allowedControllers']) && !in_array($controller->params['controller'], $tData['allowedControllers']) ||!empty($tData['allowedActions']) && !in_array($controller->params['action'], $tData['allowedActions'])) {
|
||||
if(!$this->blackHole($controller, 'auth')) {
|
||||
if (!empty($tData['allowedControllers']) && !in_array($controller->params['controller'], $tData['allowedControllers']) ||!empty($tData['allowedActions']) && !in_array($controller->params['action'], $tData['allowedActions'])) {
|
||||
if (!$this->blackHole($controller, 'auth')) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!$this->blackHole($controller, 'auth')) {
|
||||
if (!$this->blackHole($controller, 'auth')) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -390,24 +390,24 @@ class SecurityComponent extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __loginRequired(&$controller) {
|
||||
if(is_array($this->requireLogin) && !empty($this->requireLogin)) {
|
||||
if(in_array($controller->action, $this->requireLogin) || $this->requireLogin == array('*')) {
|
||||
if (is_array($this->requireLogin) && !empty($this->requireLogin)) {
|
||||
if (in_array($controller->action, $this->requireLogin) || $this->requireLogin == array('*')) {
|
||||
$login = $this->loginCredentials($this->loginOptions['type']);
|
||||
|
||||
if($login == null) {
|
||||
if ($login == null) {
|
||||
// User hasn't been authenticated yet
|
||||
header($this->loginRequest());
|
||||
|
||||
if(isset($this->loginOptions['prompt'])) {
|
||||
if (isset($this->loginOptions['prompt'])) {
|
||||
$this->__callback($controller, $this->loginOptions['prompt']);
|
||||
} else {
|
||||
$this->blackHole($controller, 'login');
|
||||
}
|
||||
} else {
|
||||
if(isset($this->loginOptions['login'])) {
|
||||
if (isset($this->loginOptions['login'])) {
|
||||
$this->__callback($controller, $this->loginOptions['login'], array($login));
|
||||
} else {
|
||||
if(low($this->loginOptions['type']) == 'digest') {
|
||||
if (low($this->loginOptions['type']) == 'digest') {
|
||||
// Do digest authentication
|
||||
} else {
|
||||
if (!(in_array($login['username'], array_keys($this->loginUsers)) && $this->loginUsers[$login['username']] == $login['password'])) {
|
||||
|
@ -428,26 +428,26 @@ class SecurityComponent extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __validatePost(&$controller) {
|
||||
if(!empty($controller->data)) {
|
||||
if (!empty($controller->data)) {
|
||||
if (!isset($controller->data['__Token'])) {
|
||||
if(!$this->blackHole($controller, 'auth')) {
|
||||
if (!$this->blackHole($controller, 'auth')) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
$token = $controller->data['__Token']['key'];
|
||||
|
||||
if($this->Session->check('_Token')) {
|
||||
if ($this->Session->check('_Token')) {
|
||||
$tData = unserialize($this->Session->read('_Token'));
|
||||
|
||||
if($tData['expires'] < time() || $tData['key'] !== $token) {
|
||||
if(!$this->blackHole($controller, 'auth')) {
|
||||
if ($tData['expires'] < time() || $tData['key'] !== $token) {
|
||||
if (!$this->blackHole($controller, 'auth')) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($controller->data['__Token']['fields'])) {
|
||||
if(!$this->blackHole($controller, 'auth')) {
|
||||
if (!isset($controller->data['__Token']['fields'])) {
|
||||
if (!$this->blackHole($controller, 'auth')) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -455,15 +455,15 @@ class SecurityComponent extends Object {
|
|||
$check = $controller->data;
|
||||
unset($check['__Token']['fields']);
|
||||
|
||||
if(!empty($this->disabledFields)) {
|
||||
foreach($check as $model => $fields) {
|
||||
foreach($fields as $field => $value) {
|
||||
if (!empty($this->disabledFields)) {
|
||||
foreach ($check as $model => $fields) {
|
||||
foreach ($fields as $field => $value) {
|
||||
$key[] = $model . '.' . $field;
|
||||
}
|
||||
unset($field);
|
||||
}
|
||||
|
||||
foreach($this->disabledFields as $value) {
|
||||
foreach ($this->disabledFields as $value) {
|
||||
$parts = preg_split('/\/|\./', $value);
|
||||
|
||||
if (count($parts) == 1) {
|
||||
|
@ -474,7 +474,7 @@ class SecurityComponent extends Object {
|
|||
}
|
||||
|
||||
foreach ($key1 as $value) {
|
||||
if(in_array($value, $key)) {
|
||||
if (in_array($value, $key)) {
|
||||
$remove = explode('.', $value);
|
||||
unset($check[$remove['0']][$remove['1']]);
|
||||
} elseif (in_array('_' . $value, $key)) {
|
||||
|
@ -485,28 +485,28 @@ class SecurityComponent extends Object {
|
|||
}
|
||||
}
|
||||
$merge = array();
|
||||
foreach($check as $key => $value) {
|
||||
if($key === '__Token') {
|
||||
foreach ($check as $key => $value) {
|
||||
if ($key === '__Token') {
|
||||
$field[$key] = $value;
|
||||
continue;
|
||||
}
|
||||
$string = substr($key, 0, 1);
|
||||
|
||||
if($string === '_') {
|
||||
if ($string === '_') {
|
||||
$newKey = substr($key, 1);
|
||||
$controller->data[$newKey] = array();
|
||||
|
||||
if(is_array($value)) {
|
||||
if (is_array($value)) {
|
||||
$values = array_values($value);
|
||||
$k = array_keys($value);
|
||||
$count = count($k);
|
||||
for($i = 0; $count > $i; $i++) {
|
||||
for ($i = 0; $count > $i; $i++) {
|
||||
$field[$key][$k[$i]] = $values[$i];
|
||||
}
|
||||
}
|
||||
|
||||
foreach($k as $lookup) {
|
||||
if(isset($controller->data[$newKey][$lookup])){
|
||||
foreach ($k as $lookup) {
|
||||
if (isset($controller->data[$newKey][$lookup])){
|
||||
unset($controller->data[$key][$lookup]);
|
||||
} elseif ($controller->data[$key][$lookup] === '0') {
|
||||
$merge[] = $lookup;
|
||||
|
@ -516,15 +516,15 @@ class SecurityComponent extends Object {
|
|||
unset($controller->data[$key]);
|
||||
continue;
|
||||
}
|
||||
if(!array_key_exists($key, $value)) {
|
||||
if (!array_key_exists($key, $value)) {
|
||||
$field[$key] = array_keys($value);
|
||||
$field[$key] = array_merge($merge, $field[$key]);
|
||||
}
|
||||
}
|
||||
$check = urlencode(Security::hash(serialize(sort($field)) . CAKE_SESSION_STRING));
|
||||
|
||||
if($form !== $check) {
|
||||
if(!$this->blackHole($controller, 'auth')) {
|
||||
if ($form !== $check) {
|
||||
if (!$this->blackHole($controller, 'auth')) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ class SecurityComponent extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __generateToken(&$controller) {
|
||||
if(!isset($controller->params['requested']) || $controller->params['requested'] != 1) {
|
||||
if (!isset($controller->params['requested']) || $controller->params['requested'] != 1) {
|
||||
$authKey = Security::generateAuthKey();
|
||||
$expires = strtotime('+'.Security::inactiveMins().' minutes');
|
||||
$token = array('key' => $authKey,
|
||||
|
@ -548,7 +548,7 @@ class SecurityComponent extends Object {
|
|||
'allowedActions' => $this->allowedActions,
|
||||
'disabledFields' => $this->disabledFields);
|
||||
|
||||
if(!isset($controller->data)) {
|
||||
if (!isset($controller->data)) {
|
||||
$controller->data = array();
|
||||
}
|
||||
$controller->params['_Token'] = $token;
|
||||
|
@ -580,7 +580,7 @@ class SecurityComponent extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __callback(&$controller, $method, $params = array()) {
|
||||
if(is_callable(array($controller, $method))) {
|
||||
if (is_callable(array($controller, $method))) {
|
||||
return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params);
|
||||
} else {
|
||||
// Debug::warning('Callback method ' . $method . ' in controller ' . get_class($controller)
|
||||
|
|
|
@ -95,8 +95,8 @@ class SessionComponent extends CakeSession {
|
|||
*/
|
||||
function write($name, $value = null) {
|
||||
if ($this->__active === true) {
|
||||
if(is_array($name)) {
|
||||
foreach($name as $key => $value) {
|
||||
if (is_array($name)) {
|
||||
foreach ($name as $key => $value) {
|
||||
if (parent::write($key, $value) === false) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -320,7 +320,7 @@ class Controller extends Object {
|
|||
$merge[] = 'uses';
|
||||
}
|
||||
|
||||
foreach($merge as $var) {
|
||||
foreach ($merge as $var) {
|
||||
if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
|
||||
$this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ class Controller extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function constructClasses() {
|
||||
if($this->uses === null || ($this->uses === array())){
|
||||
if ($this->uses === null || ($this->uses === array())){
|
||||
return false;
|
||||
}
|
||||
if (empty($this->passedArgs) || !isset($this->passedArgs['0'])) {
|
||||
|
@ -354,12 +354,12 @@ class Controller extends Object {
|
|||
$object = null;
|
||||
$plugin = null;
|
||||
|
||||
if($this->plugin) {
|
||||
if ($this->plugin) {
|
||||
$plugin = $this->plugin . '.';
|
||||
}
|
||||
|
||||
if($this->uses === false) {
|
||||
if(!class_exists($this->modelClass)){
|
||||
if ($this->uses === false) {
|
||||
if (!class_exists($this->modelClass)){
|
||||
loadModel($plugin . $this->modelClass);
|
||||
}
|
||||
}
|
||||
|
@ -393,13 +393,13 @@ class Controller extends Object {
|
|||
$uses = is_array($this->uses) ? $this->uses : array($this->uses);
|
||||
$this->modelClass = $uses[0];
|
||||
|
||||
foreach($uses as $modelClass) {
|
||||
foreach ($uses as $modelClass) {
|
||||
$id = false;
|
||||
$cached = false;
|
||||
$object = null;
|
||||
$modelKey = Inflector::underscore($modelClass);
|
||||
|
||||
if(!class_exists($modelClass)){
|
||||
if (!class_exists($modelClass)){
|
||||
loadModel($plugin . $modelClass);
|
||||
}
|
||||
|
||||
|
@ -538,11 +538,11 @@ class Controller extends Object {
|
|||
$data = array($one => $two);
|
||||
}
|
||||
|
||||
foreach($data as $name => $value) {
|
||||
foreach ($data as $name => $value) {
|
||||
if ($name == 'title') {
|
||||
$this->pageTitle = $value;
|
||||
} else {
|
||||
if($two === null) {
|
||||
if ($two === null) {
|
||||
$this->viewVars[Inflector::variable($name)] = $value;
|
||||
} else {
|
||||
$this->viewVars[$name] = $value;
|
||||
|
@ -589,7 +589,7 @@ class Controller extends Object {
|
|||
}
|
||||
|
||||
$errors = array();
|
||||
foreach($objects as $object) {
|
||||
foreach ($objects as $object) {
|
||||
$this->{$object->name}->set($object->data);
|
||||
$errors = array_merge($errors, $this->{$object->name}->invalidFields());
|
||||
}
|
||||
|
@ -610,14 +610,14 @@ class Controller extends Object {
|
|||
|
||||
$viewClass = $this->view;
|
||||
if ($this->view != 'View') {
|
||||
if(strpos($viewClass, '.') !== false){
|
||||
if (strpos($viewClass, '.') !== false){
|
||||
list($plugin, $viewClass) = explode('.', $viewClass);
|
||||
}
|
||||
$viewClass = $viewClass . 'View';
|
||||
loadView($this->view);
|
||||
}
|
||||
|
||||
foreach($this->components as $c) {
|
||||
foreach ($this->components as $c) {
|
||||
$path = preg_split('/\/|\./', $c);
|
||||
$c = $path[count($path) - 1];
|
||||
if (isset($this->{$c}) && is_object($this->{$c}) && is_callable(array($this->{$c}, 'beforeRender'))) {
|
||||
|
@ -631,7 +631,7 @@ class Controller extends Object {
|
|||
$this->__viewClass =& new $viewClass($this);
|
||||
if (!empty($this->modelNames)) {
|
||||
$models = array();
|
||||
foreach($this->modelNames as $currentModel) {
|
||||
foreach ($this->modelNames as $currentModel) {
|
||||
if (isset($this->$currentModel) && is_a($this->$currentModel, 'Model')) {
|
||||
$models[] = Inflector::underscore($currentModel);
|
||||
}
|
||||
|
@ -640,10 +640,10 @@ class Controller extends Object {
|
|||
}
|
||||
}
|
||||
$models = array_diff(ClassRegistry::keys(), $models);
|
||||
foreach($models as $currentModel) {
|
||||
foreach ($models as $currentModel) {
|
||||
if (ClassRegistry::isKeySet($currentModel)) {
|
||||
$currentObject =& ClassRegistry::getObject($currentModel);
|
||||
if(is_a($currentObject, 'Model') && !empty($currentObject->validationErrors)) {
|
||||
if (is_a($currentObject, 'Model') && !empty($currentObject->validationErrors)) {
|
||||
$this->__viewClass->validationErrors[Inflector::camelize($currentModel)] =& $currentObject->validationErrors;
|
||||
}
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ class Controller extends Object {
|
|||
if ($ref != null && defined('FULL_BASE_URL')) {
|
||||
if (strpos($ref, $base) === 0) {
|
||||
return substr($ref, strlen($base) - 1);
|
||||
} elseif(!$local) {
|
||||
} elseif (!$local) {
|
||||
return $ref;
|
||||
}
|
||||
}
|
||||
|
@ -726,11 +726,11 @@ class Controller extends Object {
|
|||
$modelKey = $this->modelKey;
|
||||
$modelObj =& ClassRegistry::getObject($modelKey);
|
||||
|
||||
foreach($modelObj->_tableInfo->value as $column) {
|
||||
foreach ($modelObj->_tableInfo->value as $column) {
|
||||
$humanName = $column['name'];
|
||||
if ($modelObj->isForeignKey($column['name'])) {
|
||||
foreach($modelObj->belongsTo as $associationName => $assoc) {
|
||||
if($column['name'] == $assoc['foreignKey']) {
|
||||
foreach ($modelObj->belongsTo as $associationName => $assoc) {
|
||||
if ($column['name'] == $assoc['foreignKey']) {
|
||||
$humanName = Inflector::underscore($associationName);
|
||||
$fkNames = $modelObj->keyToTable[$column['name']];
|
||||
$fieldNames[$column['name']]['table'] = $fkNames[0];
|
||||
|
@ -794,7 +794,7 @@ class Controller extends Object {
|
|||
case "float":
|
||||
if (strcmp($column['name'], $this->$model->primaryKey) == 0) {
|
||||
$fieldNames[$column['name']]['type'] = 'hidden';
|
||||
} else if(isset($fieldNames[$column['name']]['foreignKey'])) {
|
||||
} elseif (isset($fieldNames[$column['name']]['foreignKey'])) {
|
||||
$fieldNames[$column['name']]['type'] = 'select';
|
||||
$fieldNames[$column['name']]['options'] = array();
|
||||
|
||||
|
@ -815,7 +815,7 @@ class Controller extends Object {
|
|||
$fieldNames[$column['name']]['options'] = array();
|
||||
$enumValues = split(',', $fieldLength);
|
||||
|
||||
foreach($enumValues as $enum) {
|
||||
foreach ($enumValues as $enum) {
|
||||
$enum = trim($enum, "'");
|
||||
$fieldNames[$column['name']]['options'][$enum] = $enum;
|
||||
}
|
||||
|
@ -841,7 +841,7 @@ class Controller extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
foreach($modelObj->hasAndBelongsToMany as $associationName => $assocData) {
|
||||
foreach ($modelObj->hasAndBelongsToMany as $associationName => $assocData) {
|
||||
$otherModelKey = Inflector::underscore($assocData['className']);
|
||||
$otherModelObj = &ClassRegistry::getObject($otherModelKey);
|
||||
if ($doCreateOptions) {
|
||||
|
@ -886,8 +886,8 @@ class Controller extends Object {
|
|||
$op = '';
|
||||
}
|
||||
|
||||
foreach($data as $model => $fields) {
|
||||
foreach($fields as $field => $value) {
|
||||
foreach ($data as $model => $fields) {
|
||||
foreach ($fields as $field => $value) {
|
||||
$key = $model . '.' . $field;
|
||||
if (is_string($op)) {
|
||||
$cond[$key] = $this->__postConditionMatch($op, $value);
|
||||
|
@ -942,16 +942,16 @@ class Controller extends Object {
|
|||
if ($modelClass == null) {
|
||||
$modelClass = $this->modelClass;
|
||||
}
|
||||
foreach($this->{$modelClass}->_tableInfo->value as $field) {
|
||||
foreach ($this->{$modelClass}->_tableInfo->value as $field) {
|
||||
$useNewDate = false;
|
||||
$dateFields = array('Y'=>'_year', 'm'=>'_month', 'd'=>'_day', 'H'=>'_hour', 'i'=>'_min', 's'=>'_sec');
|
||||
foreach ($dateFields as $default => $var) {
|
||||
if(isset($this->data[$modelClass][$field['name'] . $var])) {
|
||||
if (isset($this->data[$modelClass][$field['name'] . $var])) {
|
||||
${$var} = $this->data[$modelClass][$field['name'] . $var];
|
||||
unset($this->data[$modelClass][$field['name'] . $var]);
|
||||
$useNewDate = true;
|
||||
} else {
|
||||
if($var == 'year') {
|
||||
if ($var == 'year') {
|
||||
${$var} = '0000';
|
||||
} else {
|
||||
${$var} = '00';
|
||||
|
@ -969,12 +969,12 @@ class Controller extends Object {
|
|||
$newDate = null;
|
||||
if (in_array($field['type'], array('datetime', 'timestamp')) && $useNewDate) {
|
||||
$newDate = "{$_year}-{$_month}-{$_day} {$_hour}:{$_min}:{$_sec}";
|
||||
} else if ('date' == $field['type'] && $useNewDate) {
|
||||
} elseif ('date' == $field['type'] && $useNewDate) {
|
||||
$newDate = "{$_year}-{$_month}-{$_day}";
|
||||
} else if ('time' == $field['type'] && $useNewDate) {
|
||||
} elseif ('time' == $field['type'] && $useNewDate) {
|
||||
$newDate = "{$_hour}:{$_min}:{$_sec}";
|
||||
}
|
||||
if($newDate && !in_array($field['name'], array('created', 'updated', 'modified'))) {
|
||||
if ($newDate && !in_array($field['name'], array('created', 'updated', 'modified'))) {
|
||||
$this->data[$modelClass][$field['name']] = $newDate;
|
||||
}
|
||||
}
|
||||
|
@ -1050,7 +1050,7 @@ class Controller extends Object {
|
|||
$keys = array_keys($options);
|
||||
$count = count($keys);
|
||||
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (!in_array($keys[$i], $vars)) {
|
||||
unset($options[$keys[$i]]);
|
||||
}
|
||||
|
@ -1081,7 +1081,7 @@ class Controller extends Object {
|
|||
}
|
||||
$pageCount = ceil($count / $limit);
|
||||
|
||||
if($page == 'last') {
|
||||
if ($page == 'last') {
|
||||
$options['page'] = $page = $pageCount;
|
||||
}
|
||||
|
||||
|
@ -1173,18 +1173,18 @@ class Controller extends Object {
|
|||
* @return unknown
|
||||
*/
|
||||
function _selectedArray($data, $key = 'id') {
|
||||
if(!is_array($data)) {
|
||||
if (!is_array($data)) {
|
||||
$model = $data;
|
||||
if(!empty($this->data[$model][$model])) {
|
||||
if (!empty($this->data[$model][$model])) {
|
||||
return $this->data[$model][$model];
|
||||
}
|
||||
if(!empty($this->data[$model])) {
|
||||
if (!empty($this->data[$model])) {
|
||||
$data = $this->data[$model];
|
||||
}
|
||||
}
|
||||
$array = array();
|
||||
if(!empty($data)) {
|
||||
foreach($data as $var) {
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $var) {
|
||||
$array[$var[$key]] = $var[$key];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ class Scaffold extends Object {
|
|||
$this->{$var} = $controller->{$var};
|
||||
}
|
||||
$this->redirect = array('action'=> 'index');
|
||||
if(!is_null($this->plugin)) {
|
||||
if (!is_null($this->plugin)) {
|
||||
$this->redirect = '/' . $this->plugin . '/' . $this->viewPath;
|
||||
}
|
||||
|
||||
|
@ -157,18 +157,18 @@ class Scaffold extends Object {
|
|||
$this->controller->helpers[] = 'Form';
|
||||
}
|
||||
|
||||
if($this->controller->constructClasses() === false) {
|
||||
if ($this->controller->constructClasses() === false) {
|
||||
return $this->cakeError('missingModel', array(array('className' => $this->modelKey, 'webroot' => '', 'base' => $this->controller->base)));
|
||||
}
|
||||
|
||||
if(!empty($controller->uses) && class_exists($controller->uses[0])) {
|
||||
if (!empty($controller->uses) && class_exists($controller->uses[0])) {
|
||||
$controller->modelClass = $controller->uses[0];
|
||||
$controller->modelKey = Inflector::underscore($controller->modelClass);
|
||||
}
|
||||
$this->modelClass = $controller->modelClass;
|
||||
$this->modelKey = $controller->modelKey;
|
||||
|
||||
if(!is_object($this->controller->{$this->modelClass})) {
|
||||
if (!is_object($this->controller->{$this->modelClass})) {
|
||||
return $this->cakeError('missingModel', array(array('className' => $this->modelClass, 'webroot' => '', 'base' => $controller->base)));
|
||||
}
|
||||
$this->ScaffoldModel =& $this->controller->{$this->modelClass};
|
||||
|
@ -207,7 +207,7 @@ class Scaffold extends Object {
|
|||
function __scaffoldView($params) {
|
||||
if ($this->controller->_beforeScaffold('view')) {
|
||||
|
||||
if(isset($params['pass'][0])){
|
||||
if (isset($params['pass'][0])){
|
||||
$this->ScaffoldModel->id = $params['pass'][0];
|
||||
} elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) {
|
||||
$this->controller->Session->setFlash(sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey)));
|
||||
|
@ -279,7 +279,7 @@ class Scaffold extends Object {
|
|||
$this->ScaffoldModel->id = $params['pass'][0];
|
||||
}
|
||||
|
||||
if(!empty($this->controller->data)) {
|
||||
if (!empty($this->controller->data)) {
|
||||
|
||||
$this->controller->cleanUpFields();
|
||||
|
||||
|
@ -307,20 +307,20 @@ class Scaffold extends Object {
|
|||
}
|
||||
|
||||
if (empty($this->controller->data)) {
|
||||
if($this->ScaffoldModel->id) {
|
||||
if ($this->ScaffoldModel->id) {
|
||||
$this->controller->data = $this->ScaffoldModel->read();
|
||||
} else {
|
||||
$this->controller->data = $this->ScaffoldModel->create();
|
||||
}
|
||||
}
|
||||
$associations = am($this->ScaffoldModel->belongsTo, $this->ScaffoldModel->hasAndBelongsToMany);
|
||||
foreach($associations as $assocName => $assocData) {
|
||||
foreach ($associations as $assocName => $assocData) {
|
||||
$this->controller->set(Inflector::pluralize(Inflector::variable($assocName)), $this->ScaffoldModel->{$assocName}->generateList());
|
||||
}
|
||||
|
||||
return $this->__scaffoldForm($formAction);
|
||||
|
||||
} else if($this->controller->_scaffoldError($action) === false) {
|
||||
} elseif ($this->controller->_scaffoldError($action) === false) {
|
||||
return $this->__scaffoldError();
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ class Scaffold extends Object {
|
|||
function __scaffoldDelete($params = array()) {
|
||||
if ($this->controller->_beforeScaffold('delete')) {
|
||||
|
||||
if(isset($params['pass'][0])){
|
||||
if (isset($params['pass'][0])){
|
||||
$id = $params['pass'][0];
|
||||
} elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) {
|
||||
$this->controller->Session->setFlash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)));
|
||||
|
@ -404,14 +404,14 @@ class Scaffold extends Object {
|
|||
$db = &ConnectionManager::getDataSource($this->ScaffoldModel->useDbConfig);
|
||||
|
||||
if (isset($db)) {
|
||||
if(empty($this->scaffoldActions)) {
|
||||
if (empty($this->scaffoldActions)) {
|
||||
$this->scaffoldActions = array('index', 'list', 'view', 'add', 'create', 'edit', 'update', 'delete');
|
||||
} else if(defined('CAKE_ADMIN') && $this->scaffoldActions == CAKE_ADMIN) {
|
||||
} elseif (defined('CAKE_ADMIN') && $this->scaffoldActions == CAKE_ADMIN) {
|
||||
$this->scaffoldActions = array(CAKE_ADMIN .'_index', CAKE_ADMIN .'_list', CAKE_ADMIN .'_view', CAKE_ADMIN .'_add', CAKE_ADMIN .'_create', CAKE_ADMIN .'_edit', CAKE_ADMIN .'_update', CAKE_ADMIN .'_delete');
|
||||
}
|
||||
|
||||
if (in_array($params['action'], $this->scaffoldActions)) {
|
||||
if(defined('CAKE_ADMIN')) {
|
||||
if (defined('CAKE_ADMIN')) {
|
||||
$params['action'] = str_replace(CAKE_ADMIN . '_', '', $params['action']);
|
||||
}
|
||||
switch($params['action']) {
|
||||
|
@ -491,7 +491,7 @@ class Scaffold extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
foreach($paths->viewPaths as $path) {
|
||||
foreach ($paths->viewPaths as $path) {
|
||||
if (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) {
|
||||
return $path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . $this->ext;
|
||||
} elseif (file_exists($path . $this->viewPath . DS . 'scaffolds' . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) {
|
||||
|
|
|
@ -55,12 +55,12 @@ class ErrorHandler extends Object{
|
|||
static $__previousError = null;
|
||||
|
||||
$allow = array('.', '/', '_', ' ', '-', '~');
|
||||
if(substr(PHP_OS,0,3) == "WIN") {
|
||||
if (substr(PHP_OS,0,3) == "WIN") {
|
||||
$allow = array_merge($allow, array('\\', ':') );
|
||||
}
|
||||
$clean = new Sanitize();
|
||||
$messages = $clean->paranoid($messages, $allow);
|
||||
if(!class_exists('dispatcher')) {
|
||||
if (!class_exists('dispatcher')) {
|
||||
require CAKE . 'dispatcher.php';
|
||||
}
|
||||
$this->__dispatch =& new Dispatcher();
|
||||
|
@ -73,7 +73,7 @@ class ErrorHandler extends Object{
|
|||
}
|
||||
|
||||
$this->controller =& new AppController();
|
||||
if(!empty($this->controller->uses)) {
|
||||
if (!empty($this->controller->uses)) {
|
||||
$this->controller->constructClasses();
|
||||
}
|
||||
$this->controller->_initComponents();
|
||||
|
|
|
@ -137,10 +137,10 @@ class File extends Object{
|
|||
* @access public
|
||||
*/
|
||||
function safe($name = null, $ext = null) {
|
||||
if(!$name) {
|
||||
if (!$name) {
|
||||
$name = $this->name;
|
||||
}
|
||||
if(!$ext) {
|
||||
if (!$ext) {
|
||||
$ext = $this->ext();
|
||||
}
|
||||
return preg_replace( "/[^\w\.-]+/", "_", basename($name, $ext));
|
||||
|
@ -177,10 +177,10 @@ class File extends Object{
|
|||
* @access public
|
||||
*/
|
||||
function info() {
|
||||
if($this->info == null) {
|
||||
if ($this->info == null) {
|
||||
$this->info = pathinfo($this->pwd());
|
||||
}
|
||||
if(!isset($this->info['filename'])) {
|
||||
if (!isset($this->info['filename'])) {
|
||||
$this->info['filename'] = $this->filename();
|
||||
}
|
||||
return $this->info;
|
||||
|
@ -192,10 +192,10 @@ class File extends Object{
|
|||
* @access public
|
||||
*/
|
||||
function ext() {
|
||||
if($this->info == null) {
|
||||
if ($this->info == null) {
|
||||
$this->info();
|
||||
}
|
||||
if(isset($this->info['extension'])) {
|
||||
if (isset($this->info['extension'])) {
|
||||
return $this->info['extension'];
|
||||
}
|
||||
return false;
|
||||
|
@ -207,10 +207,10 @@ class File extends Object{
|
|||
* @access public
|
||||
*/
|
||||
function filename() {
|
||||
if($this->info == null) {
|
||||
if ($this->info == null) {
|
||||
$this->info();
|
||||
}
|
||||
if(isset($this->info['extension'])) {
|
||||
if (isset($this->info['extension'])) {
|
||||
return basename($this->name, '.'.$this->info['extension']);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -98,14 +98,14 @@ class Flay extends Object{
|
|||
$text=preg_replace('#[\n]{1}#', "%LINEBREAK%", $text);
|
||||
$out ='';
|
||||
|
||||
foreach(split('%PARAGRAPH%', $text)as $line) {
|
||||
foreach (split('%PARAGRAPH%', $text)as $line) {
|
||||
if ($line) {
|
||||
if (!$bare) {
|
||||
$links = array();
|
||||
$regs = null;
|
||||
|
||||
if (preg_match_all('#\[([^\[]{4,})\]#', $line, $regs)) {
|
||||
foreach($regs[1] as $reg) {
|
||||
foreach ($regs[1] as $reg) {
|
||||
$links[] = $reg;
|
||||
$line = str_replace("[{$reg}]", '%LINK' . (count($links) - 1) . '%', $line);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ class Flay extends Object{
|
|||
// guess e-mails
|
||||
$emails = null;
|
||||
if (preg_match_all("#([_A-Za-z0-9+-+]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#", $line, $emails)) {
|
||||
foreach($emails[1] as $email) {
|
||||
foreach ($emails[1] as $email) {
|
||||
$line = str_replace($email, "<a href=\"mailto:{$email}\">{$email}</a>", $line);
|
||||
}
|
||||
}
|
||||
|
@ -132,19 +132,19 @@ class Flay extends Object{
|
|||
if (!$bare) {
|
||||
$urls = null;
|
||||
if (preg_match_all("#((?:http|https|ftp|nntp)://[^ ]+)#", $line, $urls)) {
|
||||
foreach($urls[1] as $url) {
|
||||
foreach ($urls[1] as $url) {
|
||||
$line = str_replace($url, "<a href=\"{$url}\">{$url}</a>", $line);
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match_all("#(www\.[^\n\%\ ]+[^\n\%\,\.\ ])#", $line, $urls)) {
|
||||
foreach($urls[1] as $url) {
|
||||
foreach ($urls[1] as $url) {
|
||||
$line = str_replace($url, "<a href=\"http://{$url}\">{$url}</a>", $line);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($links)) {
|
||||
for($ii = 0; $ii < count($links); $ii++) {
|
||||
for ($ii = 0; $ii < count($links); $ii++) {
|
||||
if (preg_match("#^(http|https|ftp|nntp)://#", $links[$ii])) {
|
||||
$prefix = null;
|
||||
} else {
|
||||
|
@ -207,9 +207,9 @@ class Flay extends Object{
|
|||
$string = strip_tags($string);
|
||||
$snips = array();
|
||||
$rest = $string;
|
||||
foreach($words as $word) {
|
||||
foreach ($words as $word) {
|
||||
if (preg_match_all("/[\s,]+.{0,40}{$word}.{0,40}[\s,]+/i", $rest, $r)) {
|
||||
foreach($r as $result) {
|
||||
foreach ($r as $result) {
|
||||
$rest = str_replace($result, '', $rest);
|
||||
}
|
||||
$snips = array_merge($snips, $r[0]);
|
||||
|
@ -234,7 +234,7 @@ class Flay extends Object{
|
|||
function colorMark($words, $string) {
|
||||
$colors=array('yl', 'gr', 'rd', 'bl', 'fu', 'cy');
|
||||
$nextColorIndex = 0;
|
||||
foreach($words as $word) {
|
||||
foreach ($words as $word) {
|
||||
$string = preg_replace("/({$word})/i", '<em class="' . $colors[$nextColorIndex % count($colors)] . "\">\\1</em>", $string);
|
||||
$nextColorIndex++;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ class Folder extends Object{
|
|||
$path = TMP;
|
||||
}
|
||||
|
||||
if($mode) {
|
||||
if ($mode) {
|
||||
$this->mode = strval($mode);
|
||||
}
|
||||
|
||||
|
@ -115,10 +115,10 @@ class Folder extends Object{
|
|||
*/
|
||||
function cd($path) {
|
||||
$path = realpath($path);
|
||||
if(!$this->isAbsolute($path)) {
|
||||
if (!$this->isAbsolute($path)) {
|
||||
$path = $this->addPathElement($this->path, $path);
|
||||
}
|
||||
if(is_dir($path) && file_exists($path)) {
|
||||
if (is_dir($path) && file_exists($path)) {
|
||||
return $this->path = $path;
|
||||
}
|
||||
return false;
|
||||
|
@ -136,18 +136,18 @@ class Folder extends Object{
|
|||
$dirs = $files = array();
|
||||
$dir = opendir($this->path);
|
||||
if ($dir) {
|
||||
while(false !== ($n = readdir($dir))) {
|
||||
while (false !== ($n = readdir($dir))) {
|
||||
$item = false;
|
||||
if(is_array($exceptions)) {
|
||||
if (is_array($exceptions)) {
|
||||
if (!in_array($n, $exceptions)) {
|
||||
$item = $n;
|
||||
}
|
||||
} else if ((!preg_match('#^\.+$#', $n) && $exceptions == false) || ($exceptions == true && !preg_match('#^\.(.*)$#', $n))) {
|
||||
} elseif ((!preg_match('#^\.+$#', $n) && $exceptions == false) || ($exceptions == true && !preg_match('#^\.(.*)$#', $n))) {
|
||||
$item = $n;
|
||||
}
|
||||
|
||||
if ($item) {
|
||||
if(is_dir($this->addPathElement($this->path, $item))) {
|
||||
if (is_dir($this->addPathElement($this->path, $item))) {
|
||||
$dirs[] = $item;
|
||||
} else {
|
||||
$files[] = $item;
|
||||
|
@ -180,7 +180,7 @@ class Folder extends Object{
|
|||
list($dirs, $files) = $data;
|
||||
$found = array();
|
||||
|
||||
foreach($files as $file) {
|
||||
foreach ($files as $file) {
|
||||
if (preg_match("/^{$regexp_pattern}$/i", $file)) {
|
||||
$found[] = $file;
|
||||
}
|
||||
|
@ -211,13 +211,13 @@ class Folder extends Object{
|
|||
list($dirs, $files) = $this->ls();
|
||||
|
||||
$found = array();
|
||||
foreach($files as $file) {
|
||||
foreach ($files as $file) {
|
||||
if (preg_match("/^{$pattern}$/i", $file)) {
|
||||
$found[] = $this->addPathElement($this->path, $file);
|
||||
}
|
||||
}
|
||||
$start = $this->path;
|
||||
foreach($dirs as $dir) {
|
||||
foreach ($dirs as $dir) {
|
||||
$this->cd($this->addPathElement($start, $dir));
|
||||
$found = array_merge($found, $this->findRecursive($pattern));
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ class Folder extends Object{
|
|||
* @static
|
||||
*/
|
||||
function isWindowsPath($path) {
|
||||
if(preg_match('#^[A-Z]:\\\#i', $path)) {
|
||||
if (preg_match('#^[A-Z]:\\\#i', $path)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -258,7 +258,7 @@ class Folder extends Object{
|
|||
* @static
|
||||
*/
|
||||
function isSlashTerm($path) {
|
||||
if(preg_match('#[\\\/]$#', $path)) {
|
||||
if (preg_match('#[\\\/]$#', $path)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -272,7 +272,7 @@ class Folder extends Object{
|
|||
* @static
|
||||
*/
|
||||
function normalizePath($path) {
|
||||
if($this->isWindowsPath($path)) {
|
||||
if ($this->isWindowsPath($path)) {
|
||||
return '\\';
|
||||
}
|
||||
return '/';
|
||||
|
@ -285,8 +285,8 @@ class Folder extends Object{
|
|||
* @access public
|
||||
* @static
|
||||
*/
|
||||
function correctSlashFor($path) {
|
||||
if($this->isWindowsPath($path)) {
|
||||
function correctSlashfor ($path) {
|
||||
if ($this->isWindowsPath($path)) {
|
||||
return '\\';
|
||||
}
|
||||
return '/';
|
||||
|
@ -300,10 +300,10 @@ class Folder extends Object{
|
|||
* @static
|
||||
*/
|
||||
function slashTerm($path) {
|
||||
if($this->isSlashTerm($path)) {
|
||||
if ($this->isSlashTerm($path)) {
|
||||
return $path;
|
||||
}
|
||||
return $path . $this->correctSlashFor($path);
|
||||
return $path . $this->correctSlashfor ($path);
|
||||
}
|
||||
/**
|
||||
* Returns $path with $element added, with correct slash in-between.
|
||||
|
@ -352,7 +352,7 @@ class Folder extends Object{
|
|||
*/
|
||||
function chmod($path, $mode = false, $exceptions = false) {
|
||||
|
||||
if(!$mode) {
|
||||
if (!$mode) {
|
||||
$mode = $this->mode;
|
||||
}
|
||||
|
||||
|
@ -361,14 +361,14 @@ class Folder extends Object{
|
|||
}
|
||||
|
||||
$dir = opendir($path);
|
||||
if($dir) {
|
||||
while(false !== ($n = readdir($dir))) {
|
||||
if ($dir) {
|
||||
while (false !== ($n = readdir($dir))) {
|
||||
$item = false;
|
||||
if(is_array($exceptions)) {
|
||||
if (is_array($exceptions)) {
|
||||
if (!in_array($n, $exceptions)) {
|
||||
$item = $n;
|
||||
}
|
||||
} else if ((!preg_match('#^\.+$#', $n) && $exceptions == false) || ($exceptions == true && !preg_match('#^\.(.*)$#', $n))) {
|
||||
} elseif ((!preg_match('#^\.+$#', $n) && $exceptions == false) || ($exceptions == true && !preg_match('#^\.(.*)$#', $n))) {
|
||||
$item = $n;
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ class Folder extends Object{
|
|||
return true;
|
||||
}
|
||||
|
||||
if(!$mode) {
|
||||
if (!$mode) {
|
||||
$mode = $this->mode;
|
||||
}
|
||||
|
||||
|
@ -449,13 +449,13 @@ class Folder extends Object{
|
|||
$directory = $this->slashTerm($this->path);
|
||||
$stack = array($directory);
|
||||
$count = count($stack);
|
||||
for($i = 0, $j = $count; $i < $j; ++$i) {
|
||||
for ($i = 0, $j = $count; $i < $j; ++$i) {
|
||||
if (is_file($stack[$i])) {
|
||||
$size += filesize($stack[$i]);
|
||||
} elseif (is_dir($stack[$i])) {
|
||||
$dir = dir($stack[$i]);
|
||||
if($dir) {
|
||||
while(false !== ($entry = $dir->read())) {
|
||||
if ($dir) {
|
||||
while (false !== ($entry = $dir->read())) {
|
||||
if ($entry == '.' || $entry == '..') {
|
||||
continue;
|
||||
}
|
||||
|
@ -487,26 +487,26 @@ class Folder extends Object{
|
|||
$normal_files = glob($path . "*");
|
||||
$hidden_files = glob($path . "\.?*");
|
||||
$files = array_merge($normal_files, $hidden_files);
|
||||
if(is_array($files)) {
|
||||
if (is_array($files)) {
|
||||
foreach ($files as $file) {
|
||||
if (preg_match("/(\.|\.\.)$/", $file)) {
|
||||
continue;
|
||||
}
|
||||
if (is_file($file) === true) {
|
||||
if(unlink($file)) {
|
||||
if (unlink($file)) {
|
||||
$this->__messages[] = sprintf(__('%s removed', true), $path);
|
||||
} else {
|
||||
$this->__errors[] = sprintf(__('%s NOT removed', true), $path);
|
||||
}
|
||||
} elseif (is_dir($file) === true) {
|
||||
if($this->delete($file) === false) {
|
||||
if ($this->delete($file) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$path = substr($path, 0, strlen($path) - 1);
|
||||
if(rmdir($path) === false) {
|
||||
if (rmdir($path) === false) {
|
||||
$this->__errors[] = sprintf(__('%s NOT removed', true), $path);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -524,7 +524,7 @@ class Folder extends Object{
|
|||
*/
|
||||
function copy($options = array()) {
|
||||
$to = null;
|
||||
if(is_string($options)) {
|
||||
if (is_string($options)) {
|
||||
$to = $options;
|
||||
$options = array();
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ class Folder extends Object{
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!is_dir($toDir)) {
|
||||
if (!is_dir($toDir)) {
|
||||
$this->mkdir($toDir, $mode);
|
||||
}
|
||||
|
||||
|
@ -550,7 +550,7 @@ class Folder extends Object{
|
|||
|
||||
$exceptions = am(array('.','..','.svn'), $options['skip']);
|
||||
$handle = opendir($fromDir);
|
||||
if($handle) {
|
||||
if ($handle) {
|
||||
while (false !== ($item = readdir($handle))) {
|
||||
if (!in_array($item, $exceptions)) {
|
||||
$from = $this->addPathElement($fromDir, $item);
|
||||
|
@ -582,7 +582,7 @@ class Folder extends Object{
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!empty($this->__errors)) {
|
||||
if (!empty($this->__errors)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -596,13 +596,13 @@ class Folder extends Object{
|
|||
*/
|
||||
function move($options) {
|
||||
$to = null;
|
||||
if(is_string($options)) {
|
||||
if (is_string($options)) {
|
||||
$to = $options;
|
||||
}
|
||||
$options = am(array('to'=> $to, 'from'=> $this->path, 'mode'=> $this->mode, 'skip'=> array()), $options);
|
||||
|
||||
if($this->copy($options)) {
|
||||
if($this->delete($options['from'])) {
|
||||
if ($this->copy($options)) {
|
||||
if ($this->delete($options['from'])) {
|
||||
return $this->cd($options['to']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -600,7 +600,7 @@ class HttpSocket extends CakeSocket {
|
|||
$value = (int)$value;
|
||||
}
|
||||
|
||||
if(preg_match_all('/\[([^\[\]]*)\]/iUs', $key, $matches)) {
|
||||
if (preg_match_all('/\[([^\[\]]*)\]/iUs', $key, $matches)) {
|
||||
$subKeys = $matches[1];
|
||||
$rootKey = substr($key, 0, strpos($key, '['));
|
||||
if (!empty($rootKey)) {
|
||||
|
|
|
@ -107,24 +107,24 @@ class I18n extends Object {
|
|||
$_this =& I18n::getInstance();
|
||||
$_this->category = $_this->__categories[$category];
|
||||
|
||||
if($_this->__l10n->found === false) {
|
||||
if ($_this->__l10n->found === false) {
|
||||
$language = Configure::read('Config.language');
|
||||
|
||||
if($language === null && !empty($_SESSION['Config']['language'])) {
|
||||
if ($language === null && !empty($_SESSION['Config']['language'])) {
|
||||
$language = $_SESSION['Config']['language'];
|
||||
}
|
||||
$_this->__l10n->get($language);
|
||||
$_this->locale = $_this->__l10n->locale;
|
||||
}
|
||||
|
||||
if(is_null($domain)) {
|
||||
if (is_null($domain)) {
|
||||
if (preg_match('/views{0,1}\\'.DS.'([^\/]*)/', $directory, $regs)) {
|
||||
$domain = $regs[1];
|
||||
} elseif (preg_match('/controllers{0,1}\\'.DS.'([^\/]*)/', $directory, $regs)) {
|
||||
$domain = $regs[1];
|
||||
}
|
||||
|
||||
if(isset($domain) && $domain == 'templates') {
|
||||
if (isset($domain) && $domain == 'templates') {
|
||||
if (preg_match('/templates{0,1}\\'.DS.'([^\/]*)/', $directory, $regs)) {
|
||||
$domain = $regs[1];
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ class I18n extends Object {
|
|||
$directory = null;
|
||||
}
|
||||
|
||||
if(!isset($_this->__domains[$_this->category][$domain])) {
|
||||
if (!isset($_this->__domains[$_this->category][$domain])) {
|
||||
$_this->__bindTextDomain($domain, $directory);
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ class I18n extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if(!empty($_this->__domains[$_this->category][$domain][$singular])) {
|
||||
if (!empty($_this->__domains[$_this->category][$domain][$singular])) {
|
||||
if (($trans = $_this->__domains[$_this->category][$domain][$singular]) || ($pli) && ($trans = $_this->__domains[$_this->category][$domain][$plural])) {
|
||||
if (is_array($trans)) {
|
||||
if (!isset($trans[$pli])) {
|
||||
|
@ -164,7 +164,7 @@ class I18n extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if(!empty($pli)) {
|
||||
if (!empty($pli)) {
|
||||
return($plural);
|
||||
}
|
||||
return($singular);
|
||||
|
@ -308,7 +308,7 @@ class I18n extends Object {
|
|||
function __bindTextDomain($domain, $directory = null) {
|
||||
$_this =& I18n::getInstance();
|
||||
$_this->__noLocale = true;
|
||||
if(is_null($directory)) {
|
||||
if (is_null($directory)) {
|
||||
$searchPath[] = APP . 'locale';
|
||||
$searchPath[] = CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'locale';
|
||||
} else {
|
||||
|
@ -349,7 +349,7 @@ class I18n extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if(empty($_this->__domains[$_this->category][$domain])) {
|
||||
if (empty($_this->__domains[$_this->category][$domain])) {
|
||||
return($domain);
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ class I18n extends Object {
|
|||
$_this->__domains[$_this->category][$domain]["%po-header"][strtolower($header)] = $line;
|
||||
}
|
||||
|
||||
if(isset($_this->__domains[$_this->category][$domain]["%po-header"]["plural-forms"])) {
|
||||
if (isset($_this->__domains[$_this->category][$domain]["%po-header"]["plural-forms"])) {
|
||||
$switch = preg_replace("/[(){}\\[\\]^\\s*\\]]+/", "", $_this->__domains[$_this->category][$domain]["%po-header"]["plural-forms"]);
|
||||
$_this->__domains[$_this->category][$domain]["%plural-c"] = $switch;
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ class Inflector extends Object {
|
|||
return $word;
|
||||
}
|
||||
|
||||
foreach($pluralRules as $rule => $replacement) {
|
||||
foreach ($pluralRules as $rule => $replacement) {
|
||||
if (preg_match($rule, $word)) {
|
||||
$_this->pluralized[$word] = preg_replace($rule, $replacement, $word);
|
||||
return $_this->pluralized[$word];
|
||||
|
@ -328,7 +328,7 @@ class Inflector extends Object {
|
|||
return $word;
|
||||
}
|
||||
|
||||
foreach($singularRules as $rule => $replacement) {
|
||||
foreach ($singularRules as $rule => $replacement) {
|
||||
if (preg_match($rule, $word)) {
|
||||
$_this->singularized[$word] = preg_replace($rule, $replacement, $word);
|
||||
return $_this->singularized[$word];
|
||||
|
|
|
@ -372,7 +372,7 @@ class L10n extends Object {
|
|||
$this->charset = $this->__l10nCatalog[$this->__l10nMap[DEFAULT_LANGUAGE]]['charset'];
|
||||
}
|
||||
|
||||
if($this->default) {
|
||||
if ($this->default) {
|
||||
$this->languagePath[2] = $this->__l10nCatalog[$this->default]['localeFallback'];
|
||||
}
|
||||
$this->found = true;
|
||||
|
@ -398,7 +398,7 @@ class L10n extends Object {
|
|||
$this->locale = $this->__l10nCatalog[$langKey]['locale'];
|
||||
$this->charset = $this->__l10nCatalog[$langKey]['charset'];
|
||||
|
||||
if($this->default) {
|
||||
if ($this->default) {
|
||||
$this->languagePath[2] = $this->__l10nCatalog[$this->default]['localeFallback'];
|
||||
}
|
||||
$this->found = true;
|
||||
|
|
|
@ -70,7 +70,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$this->runtime[$model->name] = array('fields' => array());
|
||||
$db =& ConnectionManager::getDataSource($model->useDbConfig);
|
||||
|
||||
if(!$db->connected) {
|
||||
if (!$db->connected) {
|
||||
trigger_error('Datasource '.$model->useDbConfig.' for I18nBehavior of model '.$model->name.' is not connected', E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
function beforeFind(&$model, $query) {
|
||||
$locale = $this->_getLocale($model);
|
||||
|
||||
if(is_string($query['fields']) && 'COUNT(*) AS count' == $query['fields']) {
|
||||
if (is_string($query['fields']) && 'COUNT(*) AS count' == $query['fields']) {
|
||||
$this->runtime[$model->name]['count'] = true;
|
||||
|
||||
$db =& ConnectionManager::getDataSource($model->useDbConfig);
|
||||
|
@ -103,21 +103,21 @@ class TranslateBehavior extends ModelBehavior {
|
|||
return $query;
|
||||
}
|
||||
|
||||
if(empty($locale) || is_array($locale)) {
|
||||
if (empty($locale) || is_array($locale)) {
|
||||
return $query;
|
||||
}
|
||||
$autoFields = false;
|
||||
|
||||
if(empty($query['fields'])) {
|
||||
if (empty($query['fields'])) {
|
||||
$query['fields'] = array($model->name.'.*');
|
||||
|
||||
foreach(array('hasOne', 'belongsTo') as $type) {
|
||||
foreach($model->{$type} as $key => $value) {
|
||||
foreach (array('hasOne', 'belongsTo') as $type) {
|
||||
foreach ($model->{$type} as $key => $value) {
|
||||
|
||||
if(empty($value['fields'])) {
|
||||
if (empty($value['fields'])) {
|
||||
$query['fields'][] = $key.'.*';
|
||||
} else {
|
||||
foreach($value['fields'] as $field) {
|
||||
foreach ($value['fields'] as $field) {
|
||||
$query['fields'][] = $key.'.'.$field;
|
||||
}
|
||||
}
|
||||
|
@ -130,27 +130,27 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$tablePrefix = $this->runtime[$model->name]['tablePrefix'];
|
||||
$addFields = array();
|
||||
|
||||
if(is_array($query['fields'])) {
|
||||
if(in_array($model->name.'.*', $query['fields'])) {
|
||||
foreach($fields as $key => $value) {
|
||||
if (is_array($query['fields'])) {
|
||||
if (in_array($model->name.'.*', $query['fields'])) {
|
||||
foreach ($fields as $key => $value) {
|
||||
$addFields[] = ife(is_numeric($key), $value, $key);
|
||||
}
|
||||
} else {
|
||||
foreach($fields as $key => $value) {
|
||||
foreach ($fields as $key => $value) {
|
||||
$field = ife(is_numeric($key), $value, $key);
|
||||
if($autoFields || in_array($model->name.'.'.$field, $query['fields']) || in_array($field, $query['fields'])) {
|
||||
if ($autoFields || in_array($model->name.'.'.$field, $query['fields']) || in_array($field, $query['fields'])) {
|
||||
$addFields[] = $field;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($addFields) {
|
||||
if ($addFields) {
|
||||
$db =& ConnectionManager::getDataSource($model->useDbConfig);
|
||||
|
||||
foreach($addFields as $field) {
|
||||
foreach ($addFields as $field) {
|
||||
$key = array_search($model->name.'.'.$field, $query['fields']);
|
||||
if(false !== $key) {
|
||||
if (false !== $key) {
|
||||
unset($query['fields'][$key]);
|
||||
}
|
||||
|
||||
|
@ -171,38 +171,38 @@ class TranslateBehavior extends ModelBehavior {
|
|||
* Callback
|
||||
*/
|
||||
function afterFind(&$model, $results, $primary) {
|
||||
if(!empty($this->runtime[$model->name]['count'])) {
|
||||
if (!empty($this->runtime[$model->name]['count'])) {
|
||||
unset($this->runtime[$model->name]['count']);
|
||||
return $results;
|
||||
}
|
||||
$this->runtime[$model->name]['fields'] = array();
|
||||
$locale = $this->_getLocale($model);
|
||||
|
||||
if(empty($locale) || empty($results)) {
|
||||
if (empty($locale) || empty($results)) {
|
||||
return $results;
|
||||
}
|
||||
|
||||
if(is_array($locale)) {
|
||||
if (is_array($locale)) {
|
||||
$fields = am($this->settings[$model->name], $this->runtime[$model->name]['fields']);
|
||||
$emptyFields = array('locale' => '');
|
||||
|
||||
foreach($fields as $key => $value) {
|
||||
foreach ($fields as $key => $value) {
|
||||
$field = ife(is_numeric($key), $value, $key);
|
||||
$emptyFields[$field] = '';
|
||||
}
|
||||
unset($fields);
|
||||
|
||||
foreach($results as $key => $row) {
|
||||
foreach ($results as $key => $row) {
|
||||
$results[$key][$model->name] = am($results[$key][$model->name], $emptyFields);
|
||||
}
|
||||
unset($emptyFields);
|
||||
} elseif(!empty($this->runtime[$model->name]['beforeFind'])) {
|
||||
} elseif (!empty($this->runtime[$model->name]['beforeFind'])) {
|
||||
$beforeFind = $this->runtime[$model->name]['beforeFind'];
|
||||
|
||||
foreach($results as $key => $row) {
|
||||
foreach ($results as $key => $row) {
|
||||
$results[$key][$model->name]['locale'] = $locale;
|
||||
|
||||
foreach($beforeFind as $field) {
|
||||
foreach ($beforeFind as $field) {
|
||||
$value = ife(empty($results[$key]['I18n__'.$field]['content']), '', $results[$key]['I18n__'.$field]['content']);
|
||||
$results[$key][$model->name][$field] = $value;
|
||||
unset($results[$key]['I18n__'.$field]);
|
||||
|
@ -217,16 +217,16 @@ class TranslateBehavior extends ModelBehavior {
|
|||
function beforeSave(&$model) {
|
||||
$locale = $this->_getLocale($model);
|
||||
|
||||
if(empty($locale) || is_array($locale)) {
|
||||
if (empty($locale) || is_array($locale)) {
|
||||
return true;
|
||||
}
|
||||
$fields = am($this->settings[$model->name], $this->runtime[$model->name]['fields']);
|
||||
$tempData = array();
|
||||
|
||||
foreach($fields as $key => $value) {
|
||||
foreach ($fields as $key => $value) {
|
||||
$field = ife(is_numeric($key), $value, $key);
|
||||
|
||||
if(isset($model->data[$model->name][$field])) {
|
||||
if (isset($model->data[$model->name][$field])) {
|
||||
$tempData[$field] = $model->data[$model->name][$field];
|
||||
unset($model->data[$model->name][$field]);
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
function afterSave(&$model, $created) {
|
||||
$locale = $this->_getLocale($model);
|
||||
|
||||
if(empty($locale) || is_array($locale) || empty($this->runtime[$model->name]['beforeSave'])) {
|
||||
if (empty($locale) || is_array($locale) || empty($this->runtime[$model->name]['beforeSave'])) {
|
||||
return true;
|
||||
}
|
||||
$tempData = $this->runtime[$model->name]['beforeSave'];
|
||||
|
@ -252,8 +252,8 @@ class TranslateBehavior extends ModelBehavior {
|
|||
'model' => $model->name,
|
||||
'row_id' => $model->id);
|
||||
|
||||
if($created) {
|
||||
foreach($tempData as $field => $value) {
|
||||
if ($created) {
|
||||
foreach ($tempData as $field => $value) {
|
||||
$this->_model->Content->create();
|
||||
$this->_model->Content->save(array('I18nContent' => array('content' => $value)));
|
||||
|
||||
|
@ -268,8 +268,8 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$fields = Set::extract($translations, '{n}.I18nModel.field');
|
||||
$ids = Set::extract($translations, '{n}.I18nModel.i18n_content_id');
|
||||
|
||||
foreach($fields as $key => $field) {
|
||||
if(array_key_exists($field, $tempData)) {
|
||||
foreach ($fields as $key => $field) {
|
||||
if (array_key_exists($field, $tempData)) {
|
||||
$this->_model->Content->create();
|
||||
$this->_model->Content->save(array('I18nContent' => array(
|
||||
'id' => $ids[$key],
|
||||
|
@ -322,7 +322,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
* @return mixed string or false
|
||||
*/
|
||||
function _getLocale(&$model) {
|
||||
if(!isset($model->locale) || is_null($model->locale)) {
|
||||
if (!isset($model->locale) || is_null($model->locale)) {
|
||||
$model->locale = $this->_autoDetectLocale();
|
||||
}
|
||||
return $model->locale;
|
||||
|
@ -338,11 +338,11 @@ class TranslateBehavior extends ModelBehavior {
|
|||
* @return boolean
|
||||
*/
|
||||
function bindTranslation(&$model, $fields, $reset = true) {
|
||||
if(empty($fields)) {
|
||||
if (empty($fields)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(is_string($fields)) {
|
||||
if (is_string($fields)) {
|
||||
$fields = array($fields);
|
||||
}
|
||||
$settings =& $this->settings[$model->name];
|
||||
|
@ -351,9 +351,9 @@ class TranslateBehavior extends ModelBehavior {
|
|||
|
||||
$default = array('className' => 'I18nModel', 'foreignKey' => 'row_id');
|
||||
|
||||
foreach($fields as $key => $value) {
|
||||
foreach ($fields as $key => $value) {
|
||||
|
||||
if(is_numeric($key)) {
|
||||
if (is_numeric($key)) {
|
||||
$field = $value;
|
||||
$association = null;
|
||||
} else {
|
||||
|
@ -361,33 +361,33 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$association = $value;
|
||||
}
|
||||
|
||||
if(in_array($field, $settings)) {
|
||||
if (in_array($field, $settings)) {
|
||||
$this->settings[$model->name] = array_diff_assoc($settings, array($field));
|
||||
} elseif(array_key_exists($field, $settings)) {
|
||||
} elseif (array_key_exists($field, $settings)) {
|
||||
unset($settings[$field]);
|
||||
}
|
||||
|
||||
if(in_array($field, $runtime)) {
|
||||
if (in_array($field, $runtime)) {
|
||||
$this->runtime[$model->name]['fields'] = array_diff_assoc($runtime, array($field));
|
||||
} elseif(array_key_exists($field, $runtime)) {
|
||||
} elseif (array_key_exists($field, $runtime)) {
|
||||
unset($runtime[$field]);
|
||||
}
|
||||
|
||||
if(is_null($association)) {
|
||||
if($reset) {
|
||||
if (is_null($association)) {
|
||||
if ($reset) {
|
||||
$runtime[] = $field;
|
||||
} else {
|
||||
$settings[] = $field;
|
||||
}
|
||||
} else {
|
||||
if($reset) {
|
||||
if ($reset) {
|
||||
$runtime[$field] = $association;
|
||||
} else {
|
||||
$settings[$field] = $association;
|
||||
}
|
||||
|
||||
foreach(array('hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany') as $type) {
|
||||
if(isset($model->{$type}[$association]) || isset($model->__backAssociation[$type][$association])) {
|
||||
foreach (array('hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany') as $type) {
|
||||
if (isset($model->{$type}[$association]) || isset($model->__backAssociation[$type][$association])) {
|
||||
trigger_error('Association '.$association.' is already binded to model '.$model->name, E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
}
|
||||
}
|
||||
|
||||
if(!empty($associations)) {
|
||||
if (!empty($associations)) {
|
||||
$model->bindModel(array('hasMany' => $associations), $reset);
|
||||
}
|
||||
return true;
|
||||
|
@ -412,11 +412,11 @@ class TranslateBehavior extends ModelBehavior {
|
|||
* @return boolean
|
||||
*/
|
||||
function unbindTranslation(&$model, $fields) {
|
||||
if(empty($fields)) {
|
||||
if (empty($fields)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(is_string($fields)) {
|
||||
if (is_string($fields)) {
|
||||
$fields = array($fields);
|
||||
}
|
||||
$settings =& $this->settings[$model->name];
|
||||
|
@ -425,8 +425,8 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$default = array('className' => 'I18nModel', 'foreignKey' => 'row_id');
|
||||
$associations = array();
|
||||
|
||||
foreach($fields as $key => $value) {
|
||||
if(is_numeric($key)) {
|
||||
foreach ($fields as $key => $value) {
|
||||
if (is_numeric($key)) {
|
||||
$field = $value;
|
||||
$association = null;
|
||||
} else {
|
||||
|
@ -434,24 +434,24 @@ class TranslateBehavior extends ModelBehavior {
|
|||
$association = $value;
|
||||
}
|
||||
|
||||
if(in_array($field, $settings)) {
|
||||
if (in_array($field, $settings)) {
|
||||
$this->settings[$model->name] = array_diff_assoc($settings, array($field));
|
||||
} elseif (array_key_exists($field, $settings)) {
|
||||
unset($settings[$field]);
|
||||
}
|
||||
|
||||
if(in_array($field, $runtime)) {
|
||||
if (in_array($field, $runtime)) {
|
||||
$this->runtime[$model->name]['fields'] = array_diff_assoc($runtime, array($field));
|
||||
} elseif(array_key_exists($field, $runtime)) {
|
||||
} elseif (array_key_exists($field, $runtime)) {
|
||||
unset($runtime[$field]);
|
||||
}
|
||||
|
||||
if(!is_null($association) && (isset($model->hasMany[$association]) || isset($model->__backAssociation['hasMany'][$association]))) {
|
||||
if (!is_null($association) && (isset($model->hasMany[$association]) || isset($model->__backAssociation['hasMany'][$association]))) {
|
||||
$associations[] = $association;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($associations)) {
|
||||
if (!empty($associations)) {
|
||||
$model->unbindModel(array('hasMany' => $associations), false);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -155,9 +155,9 @@ class ConnectionManager extends Object {
|
|||
return false;
|
||||
}
|
||||
|
||||
if(file_exists(MODELS . 'datasources' . DS . $conn['filename'] . '.php')) {
|
||||
if (file_exists(MODELS . 'datasources' . DS . $conn['filename'] . '.php')) {
|
||||
require (MODELS . 'datasources' . DS . $conn['filename'] . '.php');
|
||||
} else if (fileExistsInPath(LIBS . 'model' . DS . 'datasources' . DS . $conn['filename'] . '.php')) {
|
||||
} elseif (fileExistsInPath(LIBS . 'model' . DS . 'datasources' . DS . $conn['filename'] . '.php')) {
|
||||
require (LIBS . 'model' . DS . 'datasources' . DS . $conn['filename'] . '.php');
|
||||
} else {
|
||||
trigger_error(sprintf(__('Unable to load DataSource file %s.php', true), $conn['filename']), E_USER_ERROR);
|
||||
|
@ -179,7 +179,7 @@ class ConnectionManager extends Object {
|
|||
$connections = get_object_vars($_this->config);
|
||||
|
||||
if ($connections != null) {
|
||||
foreach($connections as $name => $config) {
|
||||
foreach ($connections as $name => $config) {
|
||||
$_this->_connectionsEnum[$name] = $_this->__getDriver($config);
|
||||
}
|
||||
return $_this->_connectionsEnum;
|
||||
|
|
|
@ -214,7 +214,7 @@ class DataSource extends Object {
|
|||
function setConfig($config) {
|
||||
if (is_array($this->_baseConfig)) {
|
||||
$this->config = $this->_baseConfig;
|
||||
foreach($config as $key => $val) {
|
||||
foreach ($config as $key => $val) {
|
||||
$this->config[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ class DataSource extends Object {
|
|||
* @return void
|
||||
*/
|
||||
function __cacheDescription($object, $data = null) {
|
||||
if($this->cacheSources === false){
|
||||
if ($this->cacheSources === false){
|
||||
return null;
|
||||
}
|
||||
if (Configure::read() > 0) {
|
||||
|
@ -282,7 +282,7 @@ class DataSource extends Object {
|
|||
* @return mixed
|
||||
*/
|
||||
function describe($model) {
|
||||
if($this->cacheSources === false){
|
||||
if ($this->cacheSources === false){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ class DataSource extends Object {
|
|||
function insertQueryData($query, $data, $association, $assocData, &$model, &$linkModel, $stack) {
|
||||
$keys = array('{$__cakeID__$}', '{$__cakeForeignKey__$}');
|
||||
|
||||
foreach($keys as $key) {
|
||||
foreach ($keys as $key) {
|
||||
$val = null;
|
||||
|
||||
if (strpos($query, $key) !== false) {
|
||||
|
@ -401,8 +401,8 @@ class DataSource extends Object {
|
|||
}
|
||||
break;
|
||||
case '{$__cakeForeignKey__$}':
|
||||
foreach($model->__associations as $id => $name) {
|
||||
foreach($model->$name as $assocName => $assoc) {
|
||||
foreach ($model->__associations as $id => $name) {
|
||||
foreach ($model->$name as $assocName => $assoc) {
|
||||
if ($assocName === $association) {
|
||||
if (isset($assoc['foreignKey'])) {
|
||||
$foreignKey = $assoc['foreignKey'];
|
||||
|
@ -431,7 +431,7 @@ class DataSource extends Object {
|
|||
}
|
||||
break;
|
||||
}
|
||||
if(empty($val) && $val !== '0') {
|
||||
if (empty($val) && $val !== '0') {
|
||||
return false;
|
||||
}
|
||||
$query = r($key, $this->value($val, $model->getColumnType($model->primaryKey)), $query);
|
||||
|
|
|
@ -220,7 +220,7 @@ class DboAdodb extends DboSource {
|
|||
$fields = false;
|
||||
$cols = $this->_adodb->MetaColumns($this->fullTableName($model, false));
|
||||
|
||||
foreach($cols as $column) {
|
||||
foreach ($cols as $column) {
|
||||
$fields[] = array('name' => $column->name,
|
||||
'type' => $this->column($column->type));
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ class DboAdodb extends DboSource {
|
|||
}
|
||||
$fields = array_map('trim', $fields);
|
||||
} else {
|
||||
foreach($model->_tableInfo->value as $field) {
|
||||
foreach ($model->_tableInfo->value as $field) {
|
||||
$fields[] = $field['name'];
|
||||
}
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ class DboAdodb extends DboSource {
|
|||
$count = count($fields);
|
||||
|
||||
if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) {
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (!preg_match('/^.+\\(.*\\)/', $fields[$i])) {
|
||||
$prepend = '';
|
||||
if (strpos($fields[$i], 'DISTINCT') !== false) {
|
||||
|
@ -389,7 +389,7 @@ class DboAdodb extends DboSource {
|
|||
$index = 0;
|
||||
$j = 0;
|
||||
|
||||
while($j < $num_fields) {
|
||||
while ($j < $num_fields) {
|
||||
$columnName = $fields[$j];
|
||||
|
||||
if (strpos($columnName, '__')) {
|
||||
|
|
|
@ -358,7 +358,7 @@ class DboDb2 extends DboSource {
|
|||
* @return array
|
||||
*/
|
||||
function update(&$model, $fields = array(), $values = array()) {
|
||||
foreach($fields as $i => $field) {
|
||||
foreach ($fields as $i => $field) {
|
||||
if ($field == $model->primaryKey) {
|
||||
unset ($fields[$i]);
|
||||
unset ($values[$i]);
|
||||
|
@ -377,7 +377,7 @@ class DboDb2 extends DboSource {
|
|||
function lastError() {
|
||||
if (db2_stmt_error()) {
|
||||
return db2_stmt_error() . ': ' . db2_stmt_errormsg();
|
||||
} else if (db2_conn_error()) {
|
||||
} elseif (db2_conn_error()) {
|
||||
return db2_conn_error() . ': ' . db2_conn_errormsg();
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -280,7 +280,7 @@ class DboFirebird extends DboSource {
|
|||
* @return array
|
||||
*/
|
||||
function update(&$model, $fields = array(), $values = array()) {
|
||||
foreach($fields as $i => $field) {
|
||||
foreach ($fields as $i => $field) {
|
||||
if ($field == $model->primaryKey) {
|
||||
unset ($fields[$i]);
|
||||
unset ($values[$i]);
|
||||
|
@ -445,7 +445,7 @@ class DboFirebird extends DboSource {
|
|||
$index = 0;
|
||||
$j = 0;
|
||||
|
||||
while($j < $num_fields) {
|
||||
while ($j < $num_fields) {
|
||||
$column = ibase_field_info($results, $j);
|
||||
$this->map[$index++] = array(ucfirst(strtolower($this->modeltmp)), strtolower($column[1]));
|
||||
$j++;
|
||||
|
@ -481,7 +481,7 @@ class DboFirebird extends DboSource {
|
|||
$resultRow = array();
|
||||
$i = 0;
|
||||
|
||||
foreach($row as $index => $field) {
|
||||
foreach ($row as $index => $field) {
|
||||
list($table, $column) = $this->map[$index];
|
||||
|
||||
if (trim($table) == "") {
|
||||
|
|
|
@ -180,7 +180,7 @@ class DboMssql extends DboSource {
|
|||
} else {
|
||||
$tables = array();
|
||||
|
||||
foreach($result as $table) {
|
||||
foreach ($result as $table) {
|
||||
$tables[] = $table[0]['TABLE_NAME'];
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ class DboMssql extends DboSource {
|
|||
$fields = false;
|
||||
$cols = $this->fetchAll("SELECT COLUMN_NAME as Field, DATA_TYPE as Type, COL_LENGTH('" . $this->fullTableName($model, false) . "', COLUMN_NAME) as Length, IS_NULLABLE As [Null], COLUMN_DEFAULT as [Default], COLUMNPROPERTY(OBJECT_ID('" . $this->fullTableName($model, false) . "'), COLUMN_NAME, 'IsIdentity') as [Key], NUMERIC_SCALE as Size FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . $this->fullTableName($model, false) . "'", false);
|
||||
|
||||
foreach($cols as $column) {
|
||||
foreach ($cols as $column) {
|
||||
$fields[] = array(
|
||||
'name' => $column[0]['Field'],
|
||||
'type' => $this->column($column[0]['Type']),
|
||||
|
@ -266,7 +266,7 @@ class DboMssql extends DboSource {
|
|||
$count = count($fields);
|
||||
|
||||
if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) {
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$dot = strrpos($fields[$i], '.');
|
||||
$fieldAlias = count($this->__fieldMappings);
|
||||
|
||||
|
@ -336,7 +336,7 @@ class DboMssql extends DboSource {
|
|||
* @return array
|
||||
*/
|
||||
function update(&$model, $fields = array(), $values = array()) {
|
||||
foreach($fields as $i => $field) {
|
||||
foreach ($fields as $i => $field) {
|
||||
if ($field == $model->primaryKey) {
|
||||
unset ($fields[$i]);
|
||||
unset ($values[$i]);
|
||||
|
@ -475,13 +475,13 @@ class DboMssql extends DboSource {
|
|||
$index = 0;
|
||||
$j = 0;
|
||||
|
||||
while($j < $num_fields) {
|
||||
while ($j < $num_fields) {
|
||||
$column = mssql_field_name($results, $j);
|
||||
|
||||
if (strpos($column, '__')) {
|
||||
if (isset($this->__fieldMappings[$column]) && strpos($this->__fieldMappings[$column], '.')) {
|
||||
$map = explode('.', $this->__fieldMappings[$column]);
|
||||
} elseif(isset($this->__fieldMappings[$column])) {
|
||||
} elseif (isset($this->__fieldMappings[$column])) {
|
||||
$map = array(0, $this->__fieldMappings[$column]);
|
||||
} else {
|
||||
$map = array(0, $column);
|
||||
|
@ -565,7 +565,7 @@ class DboMssql extends DboSource {
|
|||
$resultRow = array();
|
||||
$i = 0;
|
||||
|
||||
foreach($row as $index => $field) {
|
||||
foreach ($row as $index => $field) {
|
||||
list($table, $column) = $this->map[$index];
|
||||
$resultRow[$table][$column] = $row[$index];
|
||||
$i++;
|
||||
|
|
|
@ -210,7 +210,7 @@ class DboMysql extends DboSource {
|
|||
return 'NULL';
|
||||
}
|
||||
|
||||
if($data === '') {
|
||||
if ($data === '') {
|
||||
return "''";
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ class DboMysql extends DboSource {
|
|||
case 'integer' :
|
||||
case 'float' :
|
||||
case null :
|
||||
if(is_numeric($data)) {
|
||||
if (is_numeric($data)) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -199,7 +199,7 @@ class DboMysqli extends DboSource {
|
|||
return 'NULL';
|
||||
}
|
||||
|
||||
if($data === '') {
|
||||
if ($data === '') {
|
||||
return "''";
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ class DboMysqli extends DboSource {
|
|||
case 'integer' :
|
||||
case 'float' :
|
||||
case null :
|
||||
if(is_numeric($data)) {
|
||||
if (is_numeric($data)) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -154,7 +154,7 @@ class DboOdbc extends DboSource{
|
|||
array_push($tables, odbc_result($result, "TABLE_NAME"));
|
||||
}
|
||||
|
||||
foreach( $tables as $t ) {
|
||||
foreach ( $tables as $t ) {
|
||||
echo "$t\n";
|
||||
}
|
||||
|
||||
|
@ -180,11 +180,11 @@ class DboOdbc extends DboSource{
|
|||
|
||||
$count=odbc_num_fields($result);
|
||||
|
||||
for($i = 1; $i <= $count; $i++) {
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$cols[$i - 1] = odbc_field_name($result, $i);
|
||||
}
|
||||
|
||||
foreach($cols as $column) {
|
||||
foreach ($cols as $column) {
|
||||
$type
|
||||
= odbc_field_type(
|
||||
odbc_exec($this->connection, "SELECT " . $column . " FROM " . $this->fullTableName($model)),
|
||||
|
@ -402,7 +402,7 @@ class DboOdbc extends DboSource{
|
|||
$index =0;
|
||||
$j =0;
|
||||
|
||||
while($j < $num_fields) {
|
||||
while ($j < $num_fields) {
|
||||
$column = odbc_fetch_array($results, $j);
|
||||
|
||||
if (!empty($column->table)) {
|
||||
|
@ -430,7 +430,7 @@ class DboOdbc extends DboSource{
|
|||
$resultRow=array();
|
||||
$i=0;
|
||||
|
||||
foreach($row as $index => $field) {
|
||||
foreach ($row as $index => $field) {
|
||||
list($table, $column) = $this->map[$index];
|
||||
$resultRow[$table][$column]=$row[$index];
|
||||
$i++;
|
||||
|
|
|
@ -145,11 +145,11 @@ class DboOracle extends DboSource {
|
|||
|
||||
if ($this->connection) {
|
||||
$this->connected = true;
|
||||
if(!empty($config['nls_sort'])) {
|
||||
if (!empty($config['nls_sort'])) {
|
||||
$this->execute('ALTER SESSION SET NLS_SORT='.$config['nls_sort']);
|
||||
}
|
||||
|
||||
if(!empty($config['nls_comp'])) {
|
||||
if (!empty($config['nls_comp'])) {
|
||||
$this->execute('ALTER SESSION SET NLS_COMP='.$config['nls_comp']);
|
||||
}
|
||||
$this->execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
|
||||
|
@ -165,7 +165,7 @@ class DboOracle extends DboSource {
|
|||
* @return boolean
|
||||
*/
|
||||
function setEncoding($lang) {
|
||||
if(!$this->execute('ALTER SESSION SET NLS_LANGUAGE='.$lang)) {
|
||||
if (!$this->execute('ALTER SESSION SET NLS_LANGUAGE='.$lang)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -177,11 +177,11 @@ class DboOracle extends DboSource {
|
|||
*/
|
||||
function getEncoding() {
|
||||
$sql = 'SELECT VALUE FROM NLS_SESSION_PARAMETERS WHERE PARAMETER=\'NLS_LANGUAGE\'';
|
||||
if(!$this->execute($sql)) {
|
||||
if (!$this->execute($sql)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$row = $this->fetchRow()) {
|
||||
if (!$row = $this->fetchRow()) {
|
||||
return false;
|
||||
}
|
||||
return $row[0]['VALUE'];
|
||||
|
@ -193,7 +193,7 @@ class DboOracle extends DboSource {
|
|||
* @access public
|
||||
*/
|
||||
function disconnect() {
|
||||
if($this->connection) {
|
||||
if ($this->connection) {
|
||||
$this->connected = !ocilogoff($this->connection);
|
||||
return !$this->connected;
|
||||
}
|
||||
|
@ -216,18 +216,18 @@ class DboOracle extends DboSource {
|
|||
$fields = preg_split('/,\s+/', $fieldList);//explode(', ', $fieldList);
|
||||
$lastTableName = '';
|
||||
|
||||
foreach($fields as $key => $value) {
|
||||
if($value != 'COUNT(*) AS count') {
|
||||
if(preg_match('/\s+(\w+(\.\w+)*)$/', $value, $matches)) {
|
||||
foreach ($fields as $key => $value) {
|
||||
if ($value != 'COUNT(*) AS count') {
|
||||
if (preg_match('/\s+(\w+(\.\w+)*)$/', $value, $matches)) {
|
||||
$fields[$key] = $matches[1];
|
||||
|
||||
if(preg_match('/^(\w+\.)/', $value, $matches)) {
|
||||
if (preg_match('/^(\w+\.)/', $value, $matches)) {
|
||||
$fields[$key] = $matches[1] . $fields[$key];
|
||||
$lastTableName = $matches[1];
|
||||
}
|
||||
}
|
||||
/*
|
||||
if(preg_match('/(([[:alnum:]_]+)\.[[:alnum:]_]+)(\s+AS\s+(\w+))?$/i', $value, $matches)) {
|
||||
if (preg_match('/(([[:alnum:]_]+)\.[[:alnum:]_]+)(\s+AS\s+(\w+))?$/i', $value, $matches)) {
|
||||
$fields[$key] = isset($matches[4]) ? $matches[2] . '.' . $matches[4] : $matches[1];
|
||||
}
|
||||
*/
|
||||
|
@ -235,9 +235,9 @@ class DboOracle extends DboSource {
|
|||
}
|
||||
$this->_map = array();
|
||||
|
||||
foreach($fields as $f) {
|
||||
foreach ($fields as $f) {
|
||||
$e = explode('.', $f);
|
||||
if(count($e) > 1) {
|
||||
if (count($e) > 1) {
|
||||
$table = $e[0];
|
||||
$field = strtolower($e[1]);
|
||||
} else {
|
||||
|
@ -278,17 +278,17 @@ class DboOracle extends DboSource {
|
|||
*/
|
||||
function _execute($sql) {
|
||||
$this->_statementId = ociparse($this->connection, $sql);
|
||||
if(!$this->_statementId) {
|
||||
if (!$this->_statementId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if($this->__transactionStarted) {
|
||||
if ($this->__transactionStarted) {
|
||||
$mode = OCI_DEFAULT;
|
||||
} else {
|
||||
$mode = OCI_COMMIT_ON_SUCCESS;
|
||||
}
|
||||
|
||||
if(!ociexecute($this->_statementId, $mode)) {
|
||||
if (!ociexecute($this->_statementId, $mode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ class DboOracle extends DboSource {
|
|||
break;
|
||||
}
|
||||
|
||||
if($this->_limit >= 1) {
|
||||
if ($this->_limit >= 1) {
|
||||
ocisetprefetch($this->_statementId, $this->_limit);
|
||||
} else {
|
||||
ocisetprefetch($this->_statementId, 3000);
|
||||
|
@ -319,7 +319,7 @@ class DboOracle extends DboSource {
|
|||
* @access public
|
||||
*/
|
||||
function fetchRow() {
|
||||
if($this->_currentRow >= $this->_numRows) {
|
||||
if ($this->_currentRow >= $this->_numRows) {
|
||||
ocifreestatement($this->_statementId);
|
||||
$this->_map = null;
|
||||
$this->_results = null;
|
||||
|
@ -329,10 +329,10 @@ class DboOracle extends DboSource {
|
|||
}
|
||||
$resultRow = array();
|
||||
|
||||
foreach($this->_results[$this->_currentRow] as $index => $field) {
|
||||
foreach ($this->_results[$this->_currentRow] as $index => $field) {
|
||||
list($table, $column) = $this->_map[$index];
|
||||
|
||||
if(strpos($column, ' count')) {
|
||||
if (strpos($column, ' count')) {
|
||||
$resultRow[0]['count'] = $field;
|
||||
} else {
|
||||
$resultRow[$table][$column] = $this->_results[$this->_currentRow][$index];
|
||||
|
@ -350,7 +350,7 @@ class DboOracle extends DboSource {
|
|||
*/
|
||||
function sequenceExists($sequence) {
|
||||
$sql = "SELECT SEQUENCE_NAME FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '$sequence'";
|
||||
if(!$this->execute($sql)) {
|
||||
if (!$this->execute($sql)) {
|
||||
return false;
|
||||
}
|
||||
return $this->fetchRow();
|
||||
|
@ -386,17 +386,17 @@ class DboOracle extends DboSource {
|
|||
*/
|
||||
function listSources() {
|
||||
$cache = parent::listSources();
|
||||
if($cache != null) {
|
||||
if ($cache != null) {
|
||||
return $cache;
|
||||
}
|
||||
$sql = 'SELECT view_name AS name FROM user_views UNION SELECT table_name AS name FROM user_tables';
|
||||
|
||||
if(!$this->execute($sql)) {
|
||||
if (!$this->execute($sql)) {
|
||||
return false;
|
||||
}
|
||||
$sources = array();
|
||||
|
||||
while($r = $this->fetchRow()) {
|
||||
while ($r = $this->fetchRow()) {
|
||||
$sources[] = $r[0]['name'];
|
||||
}
|
||||
parent::listSources($sources);
|
||||
|
@ -412,18 +412,18 @@ class DboOracle extends DboSource {
|
|||
function describe(&$model) {
|
||||
$cache = parent::describe($model);
|
||||
|
||||
if($cache != null) {
|
||||
if ($cache != null) {
|
||||
return $cache;
|
||||
}
|
||||
$sql = 'SELECT COLUMN_NAME, DATA_TYPE FROM user_tab_columns WHERE table_name = \'';
|
||||
$sql .= strtoupper($this->fullTableName($model)) . '\'';
|
||||
|
||||
if(!$this->execute($sql)) {
|
||||
if (!$this->execute($sql)) {
|
||||
return false;
|
||||
}
|
||||
$fields = array();
|
||||
|
||||
for($i=0; $row = $this->fetchRow(); $i++) {
|
||||
for ($i=0; $row = $this->fetchRow(); $i++) {
|
||||
$fields[$i]['name'] = strtolower($row[0]['COLUMN_NAME']);
|
||||
$fields[$i]['type'] = $this->column($row[0]['DATA_TYPE']);
|
||||
}
|
||||
|
@ -493,10 +493,10 @@ class DboOracle extends DboSource {
|
|||
* @access public
|
||||
*/
|
||||
function column($real) {
|
||||
if(is_array($real)) {
|
||||
if (is_array($real)) {
|
||||
$col = $real['name'];
|
||||
|
||||
if(isset($real['limit'])) {
|
||||
if (isset($real['limit'])) {
|
||||
$col .= '('.$real['limit'].')';
|
||||
}
|
||||
return $col;
|
||||
|
@ -507,28 +507,28 @@ class DboOracle extends DboSource {
|
|||
$limit = null;
|
||||
|
||||
@list($col, $limit) = explode('(', $col);
|
||||
if(in_array($col, array('date', 'timestamp'))) {
|
||||
if (in_array($col, array('date', 'timestamp'))) {
|
||||
return $col;
|
||||
}
|
||||
if(strpos($col, 'number') !== false) {
|
||||
if (strpos($col, 'number') !== false) {
|
||||
return 'integer';
|
||||
}
|
||||
if(strpos($col, 'integer') !== false) {
|
||||
if (strpos($col, 'integer') !== false) {
|
||||
return 'integer';
|
||||
}
|
||||
if(strpos($col, 'char') !== false) {
|
||||
if (strpos($col, 'char') !== false) {
|
||||
return 'string';
|
||||
}
|
||||
if(strpos($col, 'text') !== false) {
|
||||
if (strpos($col, 'text') !== false) {
|
||||
return 'text';
|
||||
}
|
||||
if(strpos($col, 'blob') !== false) {
|
||||
if (strpos($col, 'blob') !== false) {
|
||||
return 'binary';
|
||||
}
|
||||
if(in_array($col, array('float', 'double', 'decimal'))) {
|
||||
if (in_array($col, array('float', 'double', 'decimal'))) {
|
||||
return 'float';
|
||||
}
|
||||
if($col == 'boolean') {
|
||||
if ($col == 'boolean') {
|
||||
return $col;
|
||||
}
|
||||
return 'text';
|
||||
|
@ -563,11 +563,11 @@ class DboOracle extends DboSource {
|
|||
$sequence = (!empty($this->sequence)) ? $this->sequence : $source . '_seq';
|
||||
$sql = "SELECT $sequence.currval FROM dual";
|
||||
|
||||
if(!$this->execute($sql)) {
|
||||
if (!$this->execute($sql)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while($row = $this->fetchRow()) {
|
||||
while ($row = $this->fetchRow()) {
|
||||
return $row[$sequence]['currval'];
|
||||
}
|
||||
return false;
|
||||
|
@ -581,7 +581,7 @@ class DboOracle extends DboSource {
|
|||
function lastError() {
|
||||
$errors = ocierror();
|
||||
|
||||
if(($errors != null) && (isset($errors["message"]))) {
|
||||
if (($errors != null) && (isset($errors["message"]))) {
|
||||
return($errors["message"]);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -122,14 +122,14 @@ class DboPear extends DboSource{
|
|||
|
||||
$result=$this->all($sql);
|
||||
|
||||
foreach($result as $item) {
|
||||
foreach ($result as $item) {
|
||||
$tables[] = $item['name'];
|
||||
}
|
||||
} elseif('mysql' == $driver) {
|
||||
} elseif ('mysql' == $driver) {
|
||||
$result=array();
|
||||
$result=mysql_list_tables($this->config['database']);
|
||||
|
||||
while($item = mysql_fetch_array($result)) {
|
||||
while ($item = mysql_fetch_array($result)) {
|
||||
$tables[] = $item[0];
|
||||
}
|
||||
} else {
|
||||
|
@ -154,7 +154,7 @@ class DboPear extends DboSource{
|
|||
$data =$this->_pear->tableInfo($tableName);
|
||||
$fields=false;
|
||||
|
||||
foreach($data as $item) {
|
||||
foreach ($data as $item) {
|
||||
$fields[] = array('name' => $item['name'],
|
||||
'type' => $item['type']);
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ class DboPostgres extends DboSource {
|
|||
} else {
|
||||
$tables = array();
|
||||
|
||||
foreach($result as $item) {
|
||||
foreach ($result as $item) {
|
||||
$tables[] = $item[0]['name'];
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ class DboPostgres extends DboSource {
|
|||
$fields = false;
|
||||
$cols = $this->fetchAll("SELECT DISTINCT column_name AS name, data_type AS type, is_nullable AS null, column_default AS default, ordinal_position AS position, character_maximum_length AS char_length, character_octet_length AS oct_length FROM information_schema.columns WHERE table_name =" . $this->value($model->tablePrefix . $model->table) . " ORDER BY position");
|
||||
|
||||
foreach($cols as $column) {
|
||||
foreach ($cols as $column) {
|
||||
$colKey = array_keys($column);
|
||||
|
||||
if (isset($column[$colKey[0]]) && !isset($column[0])) {
|
||||
|
@ -386,7 +386,7 @@ class DboPostgres extends DboSource {
|
|||
$count = count($fields);
|
||||
|
||||
if ($count >= 1 && $fields[0] != '*' && strpos($fields[0], 'COUNT(*)') === false) {
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (!preg_match('/^.+\\(.*\\)/', $fields[$i]) && !preg_match('/\s+AS\s+/', $fields[$i])) {
|
||||
$prepend = '';
|
||||
if (strpos($fields[$i], 'DISTINCT') !== false) {
|
||||
|
@ -512,7 +512,7 @@ class DboPostgres extends DboSource {
|
|||
$index = 0;
|
||||
$j = 0;
|
||||
|
||||
while($j < $num_fields) {
|
||||
while ($j < $num_fields) {
|
||||
$columnName = pg_field_name($results, $j);
|
||||
|
||||
if (strpos($columnName, '__')) {
|
||||
|
@ -534,7 +534,7 @@ class DboPostgres extends DboSource {
|
|||
$resultRow = array();
|
||||
$i = 0;
|
||||
|
||||
foreach($row as $index => $field) {
|
||||
foreach ($row as $index => $field) {
|
||||
list($table, $column) = $this->map[$index];
|
||||
$resultRow[$table][$column] = $row[$index];
|
||||
$i++;
|
||||
|
|
|
@ -188,7 +188,7 @@ class DboSqlite extends DboSource {
|
|||
return 'NULL';
|
||||
}
|
||||
|
||||
if($data === '') {
|
||||
if ($data === '') {
|
||||
return "''";
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ class DboSybase extends DboSource {
|
|||
return 'NULL';
|
||||
}
|
||||
|
||||
if($data === '') {
|
||||
if ($data === '') {
|
||||
return "''";
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ class DboSource extends DataSource {
|
|||
$out = array();
|
||||
$keys = array_keys($data);
|
||||
$count = count($data);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$out[$keys[$i]] = $this->value($data[$keys[$i]]);
|
||||
}
|
||||
return $out;
|
||||
|
@ -132,7 +132,7 @@ class DboSource extends DataSource {
|
|||
* @return array
|
||||
*/
|
||||
function listSources($data = null) {
|
||||
if($this->cacheSources === false){
|
||||
if ($this->cacheSources === false){
|
||||
return null;
|
||||
}
|
||||
if ($this->_sources != null) {
|
||||
|
@ -209,7 +209,7 @@ class DboSource extends DataSource {
|
|||
$order = $params[2 + $off];
|
||||
}
|
||||
|
||||
if(!array_key_exists(0, $params)) {
|
||||
if (!array_key_exists(0, $params)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ class DboSource extends DataSource {
|
|||
return $args[2]->find($query, $fields, $order, $recursive);
|
||||
}
|
||||
} else {
|
||||
if(isset($args[1]) && $args[1] === true){
|
||||
if (isset($args[1]) && $args[1] === true){
|
||||
return $this->fetchAll($args[0], true);
|
||||
}
|
||||
return $this->fetchAll($args[0], false);
|
||||
|
@ -281,7 +281,7 @@ class DboSource extends DataSource {
|
|||
$this->error = $this->lastError();
|
||||
$this->numRows = $this->lastNumRows($this->_result);
|
||||
|
||||
if($this->fullDebug && Configure::read() > 1) {
|
||||
if ($this->fullDebug && Configure::read() > 1) {
|
||||
$this->logQuery($sql);
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ class DboSource extends DataSource {
|
|||
if ($this->execute($sql)) {
|
||||
$out = array();
|
||||
|
||||
while($item = $this->fetchRow()) {
|
||||
while ($item = $this->fetchRow()) {
|
||||
$out[] = $item;
|
||||
}
|
||||
|
||||
|
@ -413,12 +413,12 @@ class DboSource extends DataSource {
|
|||
print ("<table class=\"cakeSqlLog\" id=\"cakeSqlLog_" . preg_replace('/[^A-Za-z0-9_]/', '_', uniqid(time(), true)) . "\" summary=\"Cake SQL Log\" cellspacing=\"0\" border = \"0\">\n<caption>{$this->_queriesCnt} {$text} took {$this->_queriesTime} ms</caption>\n");
|
||||
print ("<thead>\n<tr><th>Nr</th><th>Query</th><th>Error</th><th>Affected</th><th>Num. rows</th><th>Took (ms)</th></tr>\n</thead>\n<tbody>\n");
|
||||
|
||||
foreach($log as $k => $i) {
|
||||
foreach ($log as $k => $i) {
|
||||
print ("<tr><td>" . ($k + 1) . "</td><td>" . h($i['query']) . "</td><td>{$i['error']}</td><td style = \"text-align: right\">{$i['affected']}</td><td style = \"text-align: right\">{$i['numRows']}</td><td style = \"text-align: right\">{$i['took']}</td></tr>\n");
|
||||
}
|
||||
print ("</tbody></table>\n");
|
||||
} else {
|
||||
foreach($log as $k => $i) {
|
||||
foreach ($log as $k => $i) {
|
||||
print (($k + 1) . ". {$i['query']} {$i['error']}\n");
|
||||
}
|
||||
}
|
||||
|
@ -568,8 +568,8 @@ class DboSource extends DataSource {
|
|||
$queryData['fields'] = $this->fields($model);
|
||||
}
|
||||
|
||||
foreach($model->__associations as $type) {
|
||||
foreach($model->{$type} as $assoc => $assocData) {
|
||||
foreach ($model->__associations as $type) {
|
||||
foreach ($model->{$type} as $assoc => $assocData) {
|
||||
if ($model->recursive > -1) {
|
||||
$linkModel =& $model->{$assoc};
|
||||
|
||||
|
@ -600,8 +600,8 @@ class DboSource extends DataSource {
|
|||
$filtered = $this->__filterResults($resultSet, $model);
|
||||
|
||||
if ($model->recursive > 0) {
|
||||
foreach($model->__associations as $type) {
|
||||
foreach($model->{$type} as $assoc => $assocData) {
|
||||
foreach ($model->__associations as $type) {
|
||||
foreach ($model->{$type} as $assoc => $assocData) {
|
||||
$db = null;
|
||||
$linkModel =& $model->{$assoc};
|
||||
|
||||
|
@ -611,7 +611,7 @@ class DboSource extends DataSource {
|
|||
} else {
|
||||
$db =& ConnectionManager::getDataSource($linkModel->useDbConfig);
|
||||
}
|
||||
} elseif($model->recursive > 1 && ($type == 'belongsTo' || $type == 'hasOne')) {
|
||||
} elseif ($model->recursive > 1 && ($type == 'belongsTo' || $type == 'hasOne')) {
|
||||
// Do recursive joins on belongsTo and hasOne relationships
|
||||
$db =& $this;
|
||||
} else {
|
||||
|
@ -647,12 +647,12 @@ class DboSource extends DataSource {
|
|||
$associations = am($model->belongsTo, $model->hasOne, $model->hasMany, $model->hasAndBelongsToMany);
|
||||
$count = count($results);
|
||||
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (is_array($results[$i])) {
|
||||
$keys = array_keys($results[$i]);
|
||||
$count2 = count($keys);
|
||||
|
||||
for($j = 0; $j < $count2; $j++) {
|
||||
for ($j = 0; $j < $count2; $j++) {
|
||||
|
||||
$key = $keys[$j];
|
||||
if (isset($associations[$key])) {
|
||||
|
@ -707,16 +707,16 @@ class DboSource extends DataSource {
|
|||
return null;
|
||||
}
|
||||
$count = count($resultSet);
|
||||
if($type === 'hasMany' && !isset($assocData['limit'])) {
|
||||
if ($type === 'hasMany' && !isset($assocData['limit'])) {
|
||||
$ins = array();
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$in = $this->insertQueryData('{$__cakeID__$}', $resultSet[$i], $association, $assocData, $model, $linkModel, $stack);
|
||||
if ($in !== false) {
|
||||
$ins[] = $in;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($ins)){
|
||||
if (!empty($ins)){
|
||||
$query = r('{$__cakeID__$}', join(', ',$ins), $query);
|
||||
$fetch = $this->fetchAll($query, $model->cacheQueries, $model->name);
|
||||
} else {
|
||||
|
@ -726,8 +726,8 @@ class DboSource extends DataSource {
|
|||
if (!empty($fetch) && is_array($fetch)) {
|
||||
if ($recursive > 0) {
|
||||
|
||||
foreach($linkModel->__associations as $type1) {
|
||||
foreach($linkModel->{$type1} as $assoc1 => $assocData1) {
|
||||
foreach ($linkModel->__associations as $type1) {
|
||||
foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
|
||||
|
||||
$deepModel =& $linkModel->{$assocData1['className']};
|
||||
if ($deepModel->alias != $model->name) {
|
||||
|
@ -746,12 +746,12 @@ class DboSource extends DataSource {
|
|||
}
|
||||
return $this->__mergeHasMany($resultSet, $fetch, $association, $model, $linkModel, $recursive);
|
||||
}
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
|
||||
$row =& $resultSet[$i];
|
||||
$q = $this->insertQueryData($query, $resultSet[$i], $association, $assocData, $model, $linkModel, $stack);
|
||||
|
||||
if($q != false){
|
||||
if ($q != false){
|
||||
$fetch = $this->fetchAll($q, $model->cacheQueries, $model->name);
|
||||
} else {
|
||||
$fetch = null;
|
||||
|
@ -760,8 +760,8 @@ class DboSource extends DataSource {
|
|||
if (!empty($fetch) && is_array($fetch)) {
|
||||
if ($recursive > 0) {
|
||||
|
||||
foreach($linkModel->__associations as $type1) {
|
||||
foreach($linkModel->{$type1} as $assoc1 => $assocData1) {
|
||||
foreach ($linkModel->__associations as $type1) {
|
||||
foreach ($linkModel->{$type1} as $assoc1 => $assocData1) {
|
||||
|
||||
$deepModel =& $linkModel->{$assocData1['className']};
|
||||
if ($deepModel->alias != $model->name) {
|
||||
|
@ -789,12 +789,12 @@ class DboSource extends DataSource {
|
|||
}
|
||||
|
||||
function __mergeHasMany(&$resultSet, $merge, $association, &$model, &$linkModel){
|
||||
foreach($resultSet as $key => $value) {
|
||||
foreach ($resultSet as $key => $value) {
|
||||
$merged[$association] = array();
|
||||
$count = 0;
|
||||
foreach ($merge as $assoc => $data) {
|
||||
if(isset($value[$model->name]) && $value[$model->name][$model->primaryKey] === $data[$association][$model->hasMany[$association]['foreignKey']]) {
|
||||
if(count($data) > 1) {
|
||||
if (isset($value[$model->name]) && $value[$model->name][$model->primaryKey] === $data[$association][$model->hasMany[$association]['foreignKey']]) {
|
||||
if (count($data) > 1) {
|
||||
$temp[] = Set::pushDiff($data[$association], $data);
|
||||
unset($temp[$count][$association]);
|
||||
$merged[$association] = $temp;
|
||||
|
@ -804,7 +804,7 @@ class DboSource extends DataSource {
|
|||
}
|
||||
$count++;
|
||||
}
|
||||
if(isset($value[$model->name])){
|
||||
if (isset($value[$model->name])){
|
||||
$resultSet[$key] = Set::pushDiff($resultSet[$key], $merged);
|
||||
unset($merged);
|
||||
unset($temp);
|
||||
|
@ -831,33 +831,33 @@ class DboSource extends DataSource {
|
|||
$data[$association] = $merge[$association][0];
|
||||
} else {
|
||||
if (count($merge[0][$association]) > 1) {
|
||||
foreach($merge[0] as $assoc => $data2) {
|
||||
foreach ($merge[0] as $assoc => $data2) {
|
||||
if ($assoc != $association) {
|
||||
$merge[0][$association][$assoc] = $data2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isset($data[$association])) {
|
||||
if($merge[0][$association] != null) {
|
||||
if (!isset($data[$association])) {
|
||||
if ($merge[0][$association] != null) {
|
||||
$data[$association] = $merge[0][$association];
|
||||
} else {
|
||||
$data[$association] = array();
|
||||
}
|
||||
} else {
|
||||
if(is_array($merge[0][$association])){
|
||||
if (is_array($merge[0][$association])){
|
||||
foreach ($data[$association] as $k => $v) {
|
||||
if(!is_array($v)){
|
||||
if (!is_array($v)){
|
||||
$dataAssocTmp[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($merge[0][$association] as $k => $v) {
|
||||
if(!is_array($v)){
|
||||
if (!is_array($v)){
|
||||
$mergeAssocTmp[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if(array_keys($merge[0]) === array_keys($data)) {
|
||||
if (array_keys($merge[0]) === array_keys($data)) {
|
||||
$data[$association][$association] = $merge[0][$association];
|
||||
} else {
|
||||
$diff = Set::diff($dataAssocTmp, $mergeAssocTmp);
|
||||
|
@ -868,11 +868,11 @@ class DboSource extends DataSource {
|
|||
}
|
||||
} else {
|
||||
if ($merge[0][$association] === false) {
|
||||
if(!isset($data[$association])){
|
||||
if (!isset($data[$association])){
|
||||
$data[$association] = array();
|
||||
}
|
||||
} else {
|
||||
foreach($merge as $i => $row) {
|
||||
foreach ($merge as $i => $row) {
|
||||
if (count($row) == 1) {
|
||||
$data[$association][] = $row[$association];
|
||||
} else {
|
||||
|
@ -925,12 +925,12 @@ class DboSource extends DataSource {
|
|||
}
|
||||
|
||||
if (!empty($queryData['joins'])) {
|
||||
foreach($queryData['joins'] as $join) {
|
||||
foreach ($queryData['joins'] as $join) {
|
||||
$self['joins'][] = $join;
|
||||
}
|
||||
}
|
||||
|
||||
if($this->__bypass === false) {
|
||||
if ($this->__bypass === false) {
|
||||
$self['fields'] = am($self['fields'], $this->fields($linkModel, $alias, (isset($assocData['fields']) ? $assocData['fields'] : '')));
|
||||
}
|
||||
|
||||
|
@ -945,8 +945,8 @@ class DboSource extends DataSource {
|
|||
} else {
|
||||
$result = $queryData['selfJoin'][0];
|
||||
if (!empty($queryData['joins'])) {
|
||||
foreach($queryData['joins'] as $join) {
|
||||
if(!in_array($join, $result['joins'])) {
|
||||
foreach ($queryData['joins'] as $join) {
|
||||
if (!in_array($join, $result['joins'])) {
|
||||
$result['joins'][] = $join;
|
||||
}
|
||||
}
|
||||
|
@ -981,13 +981,13 @@ class DboSource extends DataSource {
|
|||
|
||||
if (empty($queryData['fields'])) {
|
||||
$queryData['fields'] = $this->fields($model, $model->name);
|
||||
} elseif(!empty($model->hasMany) && $model->recursive > -1) {
|
||||
} elseif (!empty($model->hasMany) && $model->recursive > -1) {
|
||||
$assocFields = $this->fields($model, $model->name, array("{$model->name}.{$model->primaryKey}"));
|
||||
$passedFields = $this->fields($model, $model->name, $queryData['fields']);
|
||||
if(count($passedFields) === 1) {
|
||||
if (count($passedFields) === 1) {
|
||||
$match = strpos($passedFields[0], $assocFields[0]);
|
||||
$match1 = strpos($passedFields[0], 'COUNT(');
|
||||
if($match === false && $match1 === false){
|
||||
if ($match === false && $match1 === false){
|
||||
$queryData['fields'] = array_unique(array_merge($passedFields, $assocFields));
|
||||
} else {
|
||||
$queryData['fields'] = $passedFields;
|
||||
|
@ -1227,7 +1227,7 @@ class DboSource extends DataSource {
|
|||
$combined = array_combine($fields, $values);
|
||||
}
|
||||
|
||||
foreach($combined as $field => $value) {
|
||||
foreach ($combined as $field => $value) {
|
||||
if ($value === null) {
|
||||
$updates[] = $this->name($field) . ' = NULL';
|
||||
} else {
|
||||
|
@ -1404,7 +1404,7 @@ class DboSource extends DataSource {
|
|||
$count = count($fields);
|
||||
|
||||
if ($count >= 1 && !in_array($fields[0], array('*', 'COUNT(*)'))) {
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (!preg_match('/^.+\\(.*\\)/', $fields[$i])) {
|
||||
$prepend = '';
|
||||
|
||||
|
@ -1464,7 +1464,7 @@ class DboSource extends DataSource {
|
|||
return ' WHERE 1 = 1';
|
||||
}
|
||||
if (!preg_match('/^WHERE\\x20|^GROUP\\x20BY\\x20|^HAVING\\x20|^ORDER\\x20BY\\x20/i', $conditions, $match)) {
|
||||
if($where) {
|
||||
if ($where) {
|
||||
$clause = ' WHERE ';
|
||||
}
|
||||
}
|
||||
|
@ -1475,7 +1475,7 @@ class DboSource extends DataSource {
|
|||
}
|
||||
return $clause . $conditions;
|
||||
} else {
|
||||
if($where) {
|
||||
if ($where) {
|
||||
$clause = ' WHERE ';
|
||||
}
|
||||
if (!empty($conditions)) {
|
||||
|
@ -1500,7 +1500,7 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
$bool = array('and', 'or', 'not', 'and not', 'or not', 'xor', '||', '&&');
|
||||
$join = ' AND ';
|
||||
|
||||
foreach($conditions as $key => $value) {
|
||||
foreach ($conditions as $key => $value) {
|
||||
if (is_numeric($key) && empty($value)) {
|
||||
continue;
|
||||
} elseif (is_numeric($key) && is_string($value)) {
|
||||
|
@ -1530,7 +1530,7 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
$data .= ')';
|
||||
} else {
|
||||
if ($quoteValues) {
|
||||
foreach($value as $valElement) {
|
||||
foreach ($value as $valElement) {
|
||||
$data .= $this->value($valElement) . ', ';
|
||||
}
|
||||
}
|
||||
|
@ -1564,7 +1564,7 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
} elseif (empty($mValue)) {
|
||||
$match['1'] = ' = ';
|
||||
$match['2'] = $match['0'];
|
||||
} elseif(!isset($match['2'])) {
|
||||
} elseif (!isset($match['2'])) {
|
||||
$match['1'] = ' = ';
|
||||
$match['2'] = $match['0'];
|
||||
}
|
||||
|
@ -1574,13 +1574,13 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
$data = $this->name($key) . ' ' . $match['1'] . ' ' . $match['2'];
|
||||
} else {
|
||||
if (!empty($match['2']) && $quoteValues) {
|
||||
if(!preg_match('/[A-Za-z]+\\([a-z0-9]*\\),?\\x20+/', $match['2'])) {
|
||||
if (!preg_match('/[A-Za-z]+\\([a-z0-9]*\\),?\\x20+/', $match['2'])) {
|
||||
$match['2'] = $this->value($match['2']);
|
||||
}
|
||||
$match['2'] = str_replace(' AND ', "' AND '", $match['2']);
|
||||
}
|
||||
$data = $this->__quoteFields($key);
|
||||
if($data === $key) {
|
||||
if ($data === $key) {
|
||||
$data = $this->name($key) . ' ' . $match['1'] . ' ' . $match['2'];
|
||||
} else {
|
||||
$data = $data . ' ' . $match['1'] . ' ' . $match['2'];
|
||||
|
@ -1609,21 +1609,21 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
$end = null;
|
||||
$original = $conditions;
|
||||
|
||||
if(!empty($this->startQuote)) {
|
||||
if (!empty($this->startQuote)) {
|
||||
$start = preg_quote($this->startQuote);
|
||||
}
|
||||
|
||||
if(!empty($this->endQuote)) {
|
||||
if (!empty($this->endQuote)) {
|
||||
$end = preg_quote($this->endQuote);
|
||||
}
|
||||
$conditions = str_replace(array($start, $end), '', $conditions);
|
||||
preg_match_all('/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9_' . $start . $end . ']*\\.[a-z0-9_' . $start . $end . ']*)/i', $conditions, $replace, PREG_PATTERN_ORDER);
|
||||
|
||||
if(isset($replace['1']['0'])) {
|
||||
if (isset($replace['1']['0'])) {
|
||||
$pregCount = count($replace['1']);
|
||||
|
||||
for($i = 0; $i < $pregCount; $i++) {
|
||||
if(!empty($replace['1'][$i]) && !is_numeric($replace['1'][$i])) {
|
||||
for ($i = 0; $i < $pregCount; $i++) {
|
||||
if (!empty($replace['1'][$i]) && !is_numeric($replace['1'][$i])) {
|
||||
$conditions = preg_replace('/\b' . preg_quote($replace['1'][$i]) . '\b/', $this->name($replace['1'][$i]), $conditions);
|
||||
}
|
||||
}
|
||||
|
@ -1668,7 +1668,7 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
}
|
||||
|
||||
if (is_array($keys)) {
|
||||
foreach($keys as $key => $val) {
|
||||
foreach ($keys as $key => $val) {
|
||||
if (is_numeric($key) && empty($val)) {
|
||||
unset ($keys[$key]);
|
||||
}
|
||||
|
@ -1683,7 +1683,7 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
if (Set::countDim($keys) > 1) {
|
||||
$new = array();
|
||||
|
||||
foreach($keys as $val) {
|
||||
foreach ($keys as $val) {
|
||||
$val = $this->order($val);
|
||||
$new[] = $val;
|
||||
}
|
||||
|
@ -1691,7 +1691,7 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
$keys = $new;
|
||||
}
|
||||
|
||||
foreach($keys as $key => $value) {
|
||||
foreach ($keys as $key => $value) {
|
||||
if (is_numeric($key)) {
|
||||
$value = ltrim(r('ORDER BY ', '', $this->order($value)));
|
||||
$key = $value;
|
||||
|
@ -1729,7 +1729,7 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
PREG_PATTERN_ORDER);
|
||||
$pregCount = count($result['0']);
|
||||
|
||||
for($i = 0; $i < $pregCount; $i++) {
|
||||
for ($i = 0; $i < $pregCount; $i++) {
|
||||
$keys = preg_replace('/' . $result['0'][$i] . '/', $this->name($result['0'][$i]), $keys);
|
||||
}
|
||||
|
||||
|
@ -1738,7 +1738,7 @@ function conditionKeysToString($conditions, $quoteValues = true) {
|
|||
} else {
|
||||
return ' ORDER BY ' . $keys . ' ' . $direction;
|
||||
}
|
||||
} elseif(preg_match('/(\\x20ASC|\\x20DESC)/i', $keys, $match)) {
|
||||
} elseif (preg_match('/(\\x20ASC|\\x20DESC)/i', $keys, $match)) {
|
||||
$direction = $match['1'];
|
||||
$keys = preg_replace('/' . $match['1'] . '/', '', $keys);
|
||||
return ' ORDER BY ' . $keys . $direction;
|
||||
|
|
|
@ -368,9 +368,9 @@ class Model extends Overloadable {
|
|||
|
||||
$this->id = $id;
|
||||
|
||||
if($table === false) {
|
||||
if ($table === false) {
|
||||
$this->useTable = false;
|
||||
} else if($table) {
|
||||
} elseif ($table) {
|
||||
$this->useTable = $table;
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ class Model extends Overloadable {
|
|||
return $this->behaviors[$it[1]]->{$it[0]}($this, $params);
|
||||
}
|
||||
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if (strpos($methods[$i], '/') === 0 && preg_match($methods[$i] . 'i', $method)) {
|
||||
return call_user_func_array(array($this->behaviors[$call[$i][1]], $call[$i][0]), $pass);
|
||||
}
|
||||
|
@ -514,16 +514,16 @@ class Model extends Overloadable {
|
|||
$model = array($model => $options);
|
||||
}
|
||||
|
||||
foreach($model as $name => $options) {
|
||||
foreach ($model as $name => $options) {
|
||||
if (isset($options['type'])) {
|
||||
$assoc = $options['type'];
|
||||
} elseif (isset($options[0])) {
|
||||
$assoc = $options[0];
|
||||
}
|
||||
if(!$permanent) {
|
||||
if (!$permanent) {
|
||||
$this->__backAssociation[$assoc] = $this->{$assoc};
|
||||
}
|
||||
foreach($model as $key => $value) {
|
||||
foreach ($model as $key => $value) {
|
||||
$assocName = $key;
|
||||
$modelName = $key;
|
||||
|
||||
|
@ -549,12 +549,12 @@ class Model extends Overloadable {
|
|||
*/
|
||||
function bindModel($params, $reset = true) {
|
||||
|
||||
foreach($params as $assoc => $model) {
|
||||
if($reset === true) {
|
||||
foreach ($params as $assoc => $model) {
|
||||
if ($reset === true) {
|
||||
$this->__backAssociation[$assoc] = $this->{$assoc};
|
||||
}
|
||||
|
||||
foreach($model as $key => $value) {
|
||||
foreach ($model as $key => $value) {
|
||||
$assocName = $key;
|
||||
|
||||
if (is_numeric($key)) {
|
||||
|
@ -585,12 +585,12 @@ class Model extends Overloadable {
|
|||
* @return boolean Always true
|
||||
*/
|
||||
function unbindModel($params, $reset = true) {
|
||||
foreach($params as $assoc => $models) {
|
||||
if($reset === true) {
|
||||
foreach ($params as $assoc => $models) {
|
||||
if ($reset === true) {
|
||||
$this->__backAssociation[$assoc] = $this->{$assoc};
|
||||
}
|
||||
|
||||
foreach($models as $model) {
|
||||
foreach ($models as $model) {
|
||||
$this->__backAssociation = array_merge($this->__backAssociation, $this->{$assoc});
|
||||
unset ($this->{$assoc}[$model]);
|
||||
}
|
||||
|
@ -605,18 +605,18 @@ class Model extends Overloadable {
|
|||
function __createLinks() {
|
||||
|
||||
// Convert all string-based associations to array based
|
||||
foreach($this->__associations as $type) {
|
||||
foreach ($this->__associations as $type) {
|
||||
if (!is_array($this->{$type})) {
|
||||
$this->{$type} = explode(',', $this->{$type});
|
||||
|
||||
foreach($this->{$type} as $i => $className) {
|
||||
foreach ($this->{$type} as $i => $className) {
|
||||
$className = trim($className);
|
||||
unset ($this->{$type}[$i]);
|
||||
$this->{$type}[$className] = array();
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->{$type} as $assoc => $value) {
|
||||
foreach ($this->{$type} as $assoc => $value) {
|
||||
if (is_numeric($assoc)) {
|
||||
unset ($this->{$type}[$assoc]);
|
||||
$assoc = $value;
|
||||
|
@ -649,7 +649,7 @@ class Model extends Overloadable {
|
|||
function __constructLinkedModel($assoc, $className, $id = false, $table = null, $ds = null) {
|
||||
$colKey = Inflector::underscore($className);
|
||||
|
||||
if(!class_exists($className)) {
|
||||
if (!class_exists($className)) {
|
||||
if (!loadModel($className)) {
|
||||
return $this->cakeError('missingModel', array(array('className' => $className)));
|
||||
}
|
||||
|
@ -686,10 +686,10 @@ class Model extends Overloadable {
|
|||
* @access private
|
||||
*/
|
||||
function __generateAssociation($type) {
|
||||
foreach($this->{$type} as $assocKey => $assocData) {
|
||||
foreach ($this->{$type} as $assocKey => $assocData) {
|
||||
$class = $assocKey;
|
||||
|
||||
foreach($this->__associationKeys[$type] as $key) {
|
||||
foreach ($this->__associationKeys[$type] as $key) {
|
||||
if (!isset($this->{$type}[$assocKey][$key]) || $this->{$type}[$assocKey][$key] == null) {
|
||||
$data = '';
|
||||
|
||||
|
@ -722,7 +722,7 @@ class Model extends Overloadable {
|
|||
if ($key == 'foreignKey' && !isset($this->keyToTable[$this->{$type}[$assocKey][$key]])) {
|
||||
$this->keyToTable[$this->{$type}[$assocKey][$key]][0] = $this->{$class}->table;
|
||||
$this->keyToTable[$this->{$type}[$assocKey][$key]][1] = $this->{$class}->name;
|
||||
if($this->{$class}->name != $class) {
|
||||
if ($this->{$class}->name != $class) {
|
||||
$this->keyToTable[$this->{$type}[$assocKey][$key]][2] = $class;
|
||||
}
|
||||
}
|
||||
|
@ -807,9 +807,9 @@ class Model extends Overloadable {
|
|||
$data = array($this->name => array($one => $two));
|
||||
}
|
||||
|
||||
foreach($data as $n => $v) {
|
||||
foreach ($data as $n => $v) {
|
||||
if (is_array($v)) {
|
||||
foreach($v as $x => $y) {
|
||||
foreach ($v as $x => $y) {
|
||||
if ($n == $this->name) {
|
||||
if (isset($this->validationErrors[$x])) {
|
||||
unset ($this->validationErrors[$x]);
|
||||
|
@ -965,7 +965,7 @@ class Model extends Overloadable {
|
|||
if ($conditions === null) {
|
||||
$conditions = array($this->name . '.' . $this->primaryKey => $this->id);
|
||||
}
|
||||
if($this->recursive >= 1) {
|
||||
if ($this->recursive >= 1) {
|
||||
$recursive = -1;
|
||||
} else {
|
||||
$recursive = $this->recursive;
|
||||
|
@ -1047,7 +1047,7 @@ class Model extends Overloadable {
|
|||
$weHaveMulti = false;
|
||||
}
|
||||
|
||||
foreach($this->data as $n => $v) {
|
||||
foreach ($this->data as $n => $v) {
|
||||
if (isset($weHaveMulti) && isset($v[$n]) && $count > 0 && count($this->hasAndBelongsToMany) > 0) {
|
||||
$joined[] = $v;
|
||||
} else {
|
||||
|
@ -1058,7 +1058,7 @@ class Model extends Overloadable {
|
|||
}
|
||||
}
|
||||
|
||||
foreach($v as $x => $y) {
|
||||
foreach ($v as $x => $y) {
|
||||
if ($this->hasField($x) && ($whitelist && in_array($x, $fieldList) || !$whitelist)) {
|
||||
$fields[] = $x;
|
||||
$values[] = $y;
|
||||
|
@ -1142,8 +1142,8 @@ class Model extends Overloadable {
|
|||
*/
|
||||
function __saveMulti($joined, $id) {
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
foreach($joined as $x => $y) {
|
||||
foreach($y as $assoc => $value) {
|
||||
foreach ($joined as $x => $y) {
|
||||
foreach ($y as $assoc => $value) {
|
||||
if (isset($this->hasAndBelongsToMany[$assoc])) {
|
||||
$joinTable[$assoc] = $this->hasAndBelongsToMany[$assoc]['joinTable'];
|
||||
$mainKey[$assoc] = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
|
||||
|
@ -1152,7 +1152,7 @@ class Model extends Overloadable {
|
|||
$fields[$assoc] = join(',', $keys);
|
||||
unset($keys);
|
||||
|
||||
foreach($value as $update) {
|
||||
foreach ($value as $update) {
|
||||
if (!empty($update)) {
|
||||
$values[] = $db->value($id, $this->getColumnType($this->primaryKey));
|
||||
$values[] = $db->value($update);
|
||||
|
@ -1175,7 +1175,7 @@ class Model extends Overloadable {
|
|||
if (isset($joinTable)) {
|
||||
$total = count($joinTable);
|
||||
|
||||
if(is_array($newValue)) {
|
||||
if (is_array($newValue)) {
|
||||
foreach ($newValue as $loopAssoc => $val) {
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
$table = $db->name($db->fullTableName($joinTable[$loopAssoc]));
|
||||
|
@ -1183,7 +1183,7 @@ class Model extends Overloadable {
|
|||
|
||||
if (!empty($newValue[$loopAssoc])) {
|
||||
$secondCount = count($newValue[$loopAssoc]);
|
||||
for($x = 0; $x < $secondCount; $x++) {
|
||||
for ($x = 0; $x < $secondCount; $x++) {
|
||||
$db->query("INSERT INTO {$table} ({$fields[$loopAssoc]}) VALUES {$newValue[$loopAssoc][$x]}");
|
||||
}
|
||||
}
|
||||
|
@ -1275,7 +1275,7 @@ class Model extends Overloadable {
|
|||
$savedAssociatons = $this->__backAssociation;
|
||||
$this->__backAssociation = array();
|
||||
}
|
||||
foreach(am($this->hasMany, $this->hasOne) as $assoc => $data) {
|
||||
foreach (am($this->hasMany, $this->hasOne) as $assoc => $data) {
|
||||
if ($data['dependent'] === true && $cascade === true) {
|
||||
|
||||
$model =& $this->{$assoc};
|
||||
|
@ -1283,8 +1283,8 @@ class Model extends Overloadable {
|
|||
$model->recursive = -1;
|
||||
$records = $model->findAll(array($field => $id), $model->primaryKey);
|
||||
|
||||
if(!empty($records)) {
|
||||
foreach($records as $record) {
|
||||
if (!empty($records)) {
|
||||
foreach ($records as $record) {
|
||||
$model->delete($record[$model->name][$model->primaryKey]);
|
||||
}
|
||||
}
|
||||
|
@ -1303,13 +1303,13 @@ class Model extends Overloadable {
|
|||
*/
|
||||
function _deleteLinks($id) {
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
foreach($this->hasAndBelongsToMany as $assoc => $data) {
|
||||
foreach ($this->hasAndBelongsToMany as $assoc => $data) {
|
||||
if (isset($data['with'])) {
|
||||
$model =& $this->{$data['with']};
|
||||
$records = $model->findAll(array($data['foreignKey'] => $id), $model->primaryKey, null, null, null, -1);
|
||||
|
||||
if (!empty($records)) {
|
||||
foreach($records as $record) {
|
||||
foreach ($records as $record) {
|
||||
$model->delete($record[$model->name][$model->primaryKey]);
|
||||
}
|
||||
}
|
||||
|
@ -1479,7 +1479,7 @@ class Model extends Overloadable {
|
|||
* @access private
|
||||
*/
|
||||
function __resetAssociations() {
|
||||
foreach($this->__associations as $type) {
|
||||
foreach ($this->__associations as $type) {
|
||||
if (isset($this->__backAssociation[$type])) {
|
||||
$this->{$type} = $this->__backAssociation[$type];
|
||||
}
|
||||
|
@ -1498,8 +1498,8 @@ class Model extends Overloadable {
|
|||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
$data = $db->fetchAll($data, $this->cacheQueries);
|
||||
|
||||
foreach($data as $key => $value) {
|
||||
foreach($this->tableToModel as $key1 => $value1) {
|
||||
foreach ($data as $key => $value) {
|
||||
foreach ($this->tableToModel as $key1 => $value1) {
|
||||
if (isset($data[$key][$key1])) {
|
||||
$newData[$key][$value1] = $data[$key][$key1];
|
||||
}
|
||||
|
@ -1594,7 +1594,7 @@ class Model extends Overloadable {
|
|||
$out = array();
|
||||
$sizeOf = sizeof($data);
|
||||
|
||||
for($ii = 0; $ii < $sizeOf; $ii++) {
|
||||
for ($ii = 0; $ii < $sizeOf; $ii++) {
|
||||
if (($data[$ii][$this->name]['parent_id'] == $root) || (($root === null) && ($data[$ii][$this->name]['parent_id'] == '0'))) {
|
||||
$tmp = $data[$ii];
|
||||
|
||||
|
@ -1692,7 +1692,7 @@ class Model extends Overloadable {
|
|||
|
||||
$Validation = new Validation();
|
||||
|
||||
foreach($this->validate as $fieldName => $ruleSet) {
|
||||
foreach ($this->validate as $fieldName => $ruleSet) {
|
||||
if (!is_array($ruleSet) || (is_array($ruleSet) && isset($ruleSet['rule']))) {
|
||||
$ruleSet = array($ruleSet);
|
||||
}
|
||||
|
@ -1722,7 +1722,7 @@ class Model extends Overloadable {
|
|||
if ((!isset($data[$fieldName]) && $validator['required'] === true) || (isset($data[$fieldName]) && (empty($data[$fieldName]) && !is_numeric($data[$fieldName])) && $validator['allowEmpty'] === false)) {
|
||||
$this->invalidate($fieldName, $message);
|
||||
} elseif (isset($data[$fieldName])) {
|
||||
if(empty($data[$fieldName]) && $data[$fieldName] != '0' && $validator['allowEmpty'] === true) {
|
||||
if (empty($data[$fieldName]) && $data[$fieldName] != '0' && $validator['allowEmpty'] === true) {
|
||||
break;
|
||||
}
|
||||
if (is_array($validator['rule'])) {
|
||||
|
@ -1788,7 +1788,7 @@ class Model extends Overloadable {
|
|||
$foreignKeys = array();
|
||||
|
||||
if (count($this->belongsTo)) {
|
||||
foreach($this->belongsTo as $assoc => $data) {
|
||||
foreach ($this->belongsTo as $assoc => $data) {
|
||||
$foreignKeys[] = $data['foreignKey'];
|
||||
}
|
||||
}
|
||||
|
@ -1822,15 +1822,15 @@ class Model extends Overloadable {
|
|||
}
|
||||
$recursive = $this->recursive;
|
||||
|
||||
if($groupPath == null && $recursive >= 1) {
|
||||
if ($groupPath == null && $recursive >= 1) {
|
||||
$this->recursive = -1;
|
||||
} else if($groupPath && $recursive >= 1){
|
||||
} elseif ($groupPath && $recursive >= 1){
|
||||
$this->recursive = 0;
|
||||
}
|
||||
$result = $this->findAll($conditions, $fields, $order, $limit);
|
||||
$this->recursive = $recursive;
|
||||
|
||||
if(!$result) {
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1853,7 +1853,7 @@ class Model extends Overloadable {
|
|||
if (!empty($group)) {
|
||||
$c = count($keys);
|
||||
for ($i = 0; $i < $c; $i++) {
|
||||
if(!isset($group[$i])) {
|
||||
if (!isset($group[$i])) {
|
||||
$group[$i] = 0;
|
||||
}
|
||||
if (!isset($out[$group[$i]])) {
|
||||
|
@ -1911,7 +1911,7 @@ class Model extends Overloadable {
|
|||
return false;
|
||||
}
|
||||
|
||||
foreach($this->id as $id) {
|
||||
foreach ($this->id as $id) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
@ -2107,8 +2107,8 @@ class Model extends Overloadable {
|
|||
if (defined('CACHE_CHECK') && CACHE_CHECK === true) {
|
||||
$assoc[] = strtolower(Inflector::pluralize($this->name));
|
||||
|
||||
foreach($this->__associations as $key => $association) {
|
||||
foreach($this->$association as $key => $className) {
|
||||
foreach ($this->__associations as $key => $association) {
|
||||
foreach ($this->$association as $key => $className) {
|
||||
$check = strtolower(Inflector::pluralize($className['className']));
|
||||
|
||||
if (!in_array($check, $assoc)) {
|
||||
|
|
|
@ -87,7 +87,7 @@ class NeatString{
|
|||
$chars = preg_split('//', $available_chars, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$char_count = count($chars);
|
||||
$out = '';
|
||||
for($ii = 0; $ii < $length; $ii++) {
|
||||
for ($ii = 0; $ii < $length; $ii++) {
|
||||
$out .= $chars[rand(1, $char_count)-1];
|
||||
}
|
||||
return $out;
|
||||
|
|
|
@ -86,11 +86,11 @@ class Object {
|
|||
*/
|
||||
function requestAction($url, $extra = array()) {
|
||||
if (!empty($url)) {
|
||||
if(!class_exists('dispatcher')) {
|
||||
if (!class_exists('dispatcher')) {
|
||||
require CAKE . 'dispatcher.php';
|
||||
}
|
||||
$dispatcher =& new Dispatcher();
|
||||
if(isset($this->plugin)){
|
||||
if (isset($this->plugin)){
|
||||
$extra['plugin'] = $this->plugin;
|
||||
}
|
||||
if (in_array('return', $extra, true)) {
|
||||
|
@ -242,12 +242,12 @@ class Object {
|
|||
switch($type) {
|
||||
case 'registry':
|
||||
$vars = unserialize(${$name});
|
||||
foreach($vars['0'] as $key => $value) {
|
||||
foreach ($vars['0'] as $key => $value) {
|
||||
loadModel(Inflector::classify($key));
|
||||
}
|
||||
unset($vars);
|
||||
$vars = unserialize(${$name});
|
||||
foreach($vars['0'] as $key => $value) {
|
||||
foreach ($vars['0'] as $key => $value) {
|
||||
ClassRegistry::addObject($key, $value);
|
||||
unset ($value);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class Overloadable extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __call($method, $params, &$return) {
|
||||
if(!method_exists($this, 'call__')) {
|
||||
if (!method_exists($this, 'call__')) {
|
||||
trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
|
||||
}
|
||||
$return = $this->call__($method, $params);
|
||||
|
@ -130,7 +130,7 @@ class Overloadable2 extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __call($method, $params, &$return) {
|
||||
if(!method_exists($this, 'call__')) {
|
||||
if (!method_exists($this, 'call__')) {
|
||||
trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
|
||||
}
|
||||
$return = $this->call__($method, $params);
|
||||
|
|
|
@ -53,7 +53,7 @@ class Overloadable extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __call($method, $params) {
|
||||
if(!method_exists($this, 'call__')) {
|
||||
if (!method_exists($this, 'call__')) {
|
||||
trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
|
||||
}
|
||||
return $this->call__($method, $params);
|
||||
|
@ -78,7 +78,7 @@ class Overloadable2 extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function __call($method, $params) {
|
||||
if(!method_exists($this, 'call__')) {
|
||||
if (!method_exists($this, 'call__')) {
|
||||
trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
|
||||
}
|
||||
return $this->call__($method, $params);
|
||||
|
|
|
@ -212,7 +212,7 @@ class Router extends Object {
|
|||
return false;
|
||||
}
|
||||
|
||||
foreach($elements as $element) {
|
||||
foreach ($elements as $element) {
|
||||
$q = null;
|
||||
|
||||
if (preg_match('/^:(.+)$/', $element, $r)) {
|
||||
|
@ -225,7 +225,7 @@ class Router extends Object {
|
|||
$parsed[] = '(?:\/([^\/]+))?';
|
||||
}
|
||||
$names[] = $r[1];
|
||||
} elseif(preg_match('/^\*$/', $element, $r)) {
|
||||
} elseif (preg_match('/^\*$/', $element, $r)) {
|
||||
$parsed[] = '(?:\/(.*))?';
|
||||
} else {
|
||||
$parsed[] = '/' . $element;
|
||||
|
@ -257,7 +257,7 @@ class Router extends Object {
|
|||
}
|
||||
extract($_this->__parseExtension($url));
|
||||
|
||||
foreach($_this->routes as $route) {
|
||||
foreach ($_this->routes as $route) {
|
||||
list($route, $regexp, $names, $defaults) = $route;
|
||||
|
||||
if (preg_match($regexp, $url, $r)) {
|
||||
|
@ -266,12 +266,12 @@ class Router extends Object {
|
|||
// remove the first element, which is the url
|
||||
array_shift ($r);
|
||||
// hack, pre-fill the default route names
|
||||
foreach($names as $name) {
|
||||
foreach ($names as $name) {
|
||||
$out[$name] = null;
|
||||
}
|
||||
|
||||
if (is_array($defaults)) {
|
||||
foreach($defaults as $name => $value) {
|
||||
foreach ($defaults as $name => $value) {
|
||||
if (preg_match('#[a-zA-Z_\-]#i', $name)) {
|
||||
$out[$name] = $_this->stripEscape($value);
|
||||
} else {
|
||||
|
@ -280,16 +280,16 @@ class Router extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
foreach(Set::filter($r, true) as $key => $found) {
|
||||
foreach (Set::filter($r, true) as $key => $found) {
|
||||
// if $found is a named url element (i.e. ':action')
|
||||
if (isset($names[$key])) {
|
||||
$out[$names[$key]] = $found;
|
||||
} else if (isset($names[$key]) && empty($names[$key]) && empty($out[$names[$key]])) {
|
||||
} elseif (isset($names[$key]) && empty($names[$key]) && empty($out[$names[$key]])) {
|
||||
break; //leave the default values;
|
||||
} else {
|
||||
// unnamed elements go in as 'pass'
|
||||
$search = explode('/', $found);
|
||||
foreach($search as $k => $value) {
|
||||
foreach ($search as $k => $value) {
|
||||
$out['pass'][] = $_this->stripEscape($value);
|
||||
}
|
||||
}
|
||||
|
@ -314,14 +314,14 @@ class Router extends Object {
|
|||
$_this =& Router::getInstance();
|
||||
|
||||
if ($_this->__parseExtensions) {
|
||||
if(preg_match('/\.[0-9a-zA-Z]*$/', $url, $match) == 1) {
|
||||
if (preg_match('/\.[0-9a-zA-Z]*$/', $url, $match) == 1) {
|
||||
$match = substr($match[0], 1);
|
||||
if(empty($_this->__validExtensions)) {
|
||||
if (empty($_this->__validExtensions)) {
|
||||
$url = substr($url, 0, strpos($url, '.' . $match));
|
||||
$ext = $match;
|
||||
} else {
|
||||
foreach($_this->__validExtensions as $name) {
|
||||
if(strcasecmp($name, $match) === 0) {
|
||||
foreach ($_this->__validExtensions as $name) {
|
||||
if (strcasecmp($name, $match) === 0) {
|
||||
$url = substr($url, 0, strpos($url, '.' . $name));
|
||||
$ext = $match;
|
||||
}
|
||||
|
@ -457,19 +457,19 @@ class Router extends Object {
|
|||
$_this =& Router::getInstance();
|
||||
$defaults = $params = array('plugin' => null, 'controller' => null, 'action' => 'index');
|
||||
|
||||
if(!empty($_this->__params)) {
|
||||
if(!isset($_this->params['requested'])) {
|
||||
if (!empty($_this->__params)) {
|
||||
if (!isset($_this->params['requested'])) {
|
||||
$params = $_this->__params[0];
|
||||
} else if(isset($_this->params['requested'])) {
|
||||
} elseif (isset($_this->params['requested'])) {
|
||||
$params = end($_this->__params);
|
||||
}
|
||||
}
|
||||
$path = array('base' => null);
|
||||
|
||||
if(!empty($_this->__paths)) {
|
||||
if(!isset($_this->params['requested'])) {
|
||||
if (!empty($_this->__paths)) {
|
||||
if (!isset($_this->params['requested'])) {
|
||||
$path = $_this->__paths[0];
|
||||
} else if(isset($_this->params['requested'])) {
|
||||
} elseif (isset($_this->params['requested'])) {
|
||||
$path = end($_this->__paths);
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ class Router extends Object {
|
|||
$named = $args = array();
|
||||
$skip = am(array_keys($_this->__mapped), array('bare', 'action', 'controller', 'plugin', 'ext', '?', '#'));
|
||||
|
||||
if(defined('CAKE_ADMIN')) {
|
||||
if (defined('CAKE_ADMIN')) {
|
||||
$skip[] = CAKE_ADMIN;
|
||||
}
|
||||
$_this->__mapped = array();
|
||||
|
@ -531,11 +531,11 @@ class Router extends Object {
|
|||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($i == 0 && is_numeric($keys[$i]) && in_array('id', $keys)) {
|
||||
$args[0] = $url[$keys[$i]];
|
||||
} else if (is_numeric($keys[$i]) || $keys[$i] == 'id') {
|
||||
} elseif (is_numeric($keys[$i]) || $keys[$i] == 'id') {
|
||||
$args[] = $url[$keys[$i]];
|
||||
} else if(!empty($path['namedArgs']) && in_array($keys[$i], array_keys($path['namedArgs'])) && !empty($url[$keys[$i]])) {
|
||||
} elseif (!empty($path['namedArgs']) && in_array($keys[$i], array_keys($path['namedArgs'])) && !empty($url[$keys[$i]])) {
|
||||
$named[] = $keys[$i] . $path['argSeparator'] . $url[$keys[$i]];
|
||||
} elseif(!empty($url[$keys[$i]]) || is_numeric($url[$keys[$i]])) {
|
||||
} elseif (!empty($url[$keys[$i]]) || is_numeric($url[$keys[$i]])) {
|
||||
$named[] = $keys[$i] . $path['argSeparator'] . $url[$keys[$i]];
|
||||
}
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ class Router extends Object {
|
|||
|
||||
$urlOut = Set::filter(array($url['plugin'], $url['controller'], $url['action']));
|
||||
|
||||
if($url['plugin'] == $url['controller']) {
|
||||
if ($url['plugin'] == $url['controller']) {
|
||||
array_shift($urlOut);
|
||||
}
|
||||
if (defined('CAKE_ADMIN') && isset($url[CAKE_ADMIN]) && $url[CAKE_ADMIN]) {
|
||||
|
@ -557,7 +557,7 @@ class Router extends Object {
|
|||
}
|
||||
|
||||
if (!empty($args)) {
|
||||
if($output{strlen($output)-1} == '/') {
|
||||
if ($output{strlen($output)-1} == '/') {
|
||||
$output .= join('/', Set::filter($args, true));
|
||||
} else {
|
||||
$output .= '/'. join('/', Set::filter($args, true));
|
||||
|
@ -565,7 +565,7 @@ class Router extends Object {
|
|||
}
|
||||
|
||||
if (!empty($named)) {
|
||||
if($output{strlen($output)-1} == '/') {
|
||||
if ($output{strlen($output)-1} == '/') {
|
||||
$output .= join('/', Set::filter($named, true));
|
||||
} else {
|
||||
$output .= '/'. join('/', Set::filter($named, true));
|
||||
|
@ -580,7 +580,7 @@ class Router extends Object {
|
|||
|
||||
if (empty($url)) {
|
||||
return $path['here'];
|
||||
} elseif($url{0} == '/') {
|
||||
} elseif ($url{0} == '/') {
|
||||
$output = $base . $url;
|
||||
} else {
|
||||
$output = $base . '/';
|
||||
|
@ -624,8 +624,8 @@ class Router extends Object {
|
|||
return false;
|
||||
}
|
||||
|
||||
foreach($pass as $key => $value) {
|
||||
if(!is_numeric($key)) {
|
||||
foreach ($pass as $key => $value) {
|
||||
if (!is_numeric($key)) {
|
||||
unset($pass[$key]);
|
||||
}
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ class Router extends Object {
|
|||
return array(Router::__mapRoute($route, am($url, array('pass' => $pass))), array());
|
||||
} elseif (!empty($params) && !empty($route[3])) {
|
||||
$required = array_diff(array_keys($defaults), array_keys($url));
|
||||
if(!empty($required)) {
|
||||
if (!empty($required)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -655,17 +655,17 @@ class Router extends Object {
|
|||
}
|
||||
} else {
|
||||
$required = array_diff(array_keys($defaults), array_keys($url));
|
||||
if(empty($required) && $defaults['plugin'] == $url['plugin'] && $defaults['controller'] == $url['controller'] && $defaults['action'] == $url['action']) {
|
||||
if (empty($required) && $defaults['plugin'] == $url['plugin'] && $defaults['controller'] == $url['controller'] && $defaults['action'] == $url['action']) {
|
||||
return array(Router::__mapRoute($route, am($url, array('pass' => $pass))), $url);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($route[3]['controller']) && !empty($route[3]['controller']) && $url['controller'] != $route[3]['controller']) {
|
||||
if (isset($route[3]['controller']) && !empty($route[3]['controller']) && $url['controller'] != $route[3]['controller']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!empty($route[4])) {
|
||||
if (!empty($route[4])) {
|
||||
foreach ($route[4] as $key => $reg) {
|
||||
if (isset($url[$key]) && !preg_match('/' . $reg . '/', $url[$key])) {
|
||||
return false;
|
||||
|
@ -786,16 +786,16 @@ class Router extends Object {
|
|||
*/
|
||||
function stripEscape($param) {
|
||||
$_this =& Router::getInstance();
|
||||
if(!is_array($param) || empty($param)) {
|
||||
if(is_bool($param)) {
|
||||
if (!is_array($param) || empty($param)) {
|
||||
if (is_bool($param)) {
|
||||
return $param;
|
||||
}
|
||||
|
||||
$return = preg_replace('/^[\\t ]*(?:-!)+/', '', $param);
|
||||
return $return;
|
||||
}
|
||||
foreach($param as $key => $value) {
|
||||
if(is_string($value)) {
|
||||
foreach ($param as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$return[$key] = preg_replace('/^[\\t ]*(?:-!)+/', '', $value);
|
||||
} else {
|
||||
foreach ($value as $array => $string) {
|
||||
|
@ -829,7 +829,7 @@ class Router extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if(!function_exists('http_build_query')) {
|
||||
if (!function_exists('http_build_query')) {
|
||||
/**
|
||||
* Implements http_build_query for PHP4.
|
||||
*
|
||||
|
@ -841,7 +841,7 @@ if(!function_exists('http_build_query')) {
|
|||
* @see http://php.net/http_build_query
|
||||
*/
|
||||
function http_build_query($data, $prefix = null, $argSep = null, $baseKey = null) {
|
||||
if(empty($argSep)) {
|
||||
if (empty($argSep)) {
|
||||
$argSep = ini_get('arg_separator.output');
|
||||
}
|
||||
if (is_object($data)) {
|
||||
|
@ -849,17 +849,17 @@ if(!function_exists('http_build_query')) {
|
|||
}
|
||||
$out = array();
|
||||
|
||||
foreach((array)$data as $key => $v) {
|
||||
if(is_numeric($key) && !empty($prefix)) {
|
||||
foreach ((array)$data as $key => $v) {
|
||||
if (is_numeric($key) && !empty($prefix)) {
|
||||
$key = $prefix . $key;
|
||||
}
|
||||
$key = urlencode($key);
|
||||
|
||||
if(!empty($baseKey)) {
|
||||
if (!empty($baseKey)) {
|
||||
$key = $baseKey . '[' . $key . ']';
|
||||
}
|
||||
|
||||
if(is_array($v) || is_object($v)) {
|
||||
if (is_array($v) || is_object($v)) {
|
||||
$out[] = http_build_query($v, $prefix, $argSep, $key);
|
||||
} else {
|
||||
$out[] = $key . '=' . urlencode($v);
|
||||
|
|
|
@ -47,13 +47,13 @@ class Sanitize{
|
|||
function paranoid($string, $allowed = array()) {
|
||||
$allow = null;
|
||||
if (!empty($allowed)) {
|
||||
foreach($allowed as $value) {
|
||||
foreach ($allowed as $value) {
|
||||
$allow .= "\\$value";
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($string)) {
|
||||
foreach($string as $key => $clean) {
|
||||
foreach ($string as $key => $clean) {
|
||||
$cleaned[$key] = preg_replace("/[^{$allow}a-zA-Z0-9]/", '', $clean);
|
||||
}
|
||||
} else {
|
||||
|
@ -153,7 +153,7 @@ class Sanitize{
|
|||
$params = params(func_get_args());
|
||||
$str = $params[0];
|
||||
|
||||
for($i = 1; $i < count($params); $i++) {
|
||||
for ($i = 1; $i < count($params); $i++) {
|
||||
$str = preg_replace('/<' . $params[$i] . '[^>]*>/i', '', $str);
|
||||
$str = preg_replace('/<\/' . $params[$i] . '[^>]*>/i', '', $str);
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ class Sanitize{
|
|||
* @static
|
||||
*/
|
||||
function formatColumns(&$model) {
|
||||
foreach($model->data as $name => $values) {
|
||||
foreach ($model->data as $name => $values) {
|
||||
if ($name == $model->name) {
|
||||
$curModel =& $model;
|
||||
} elseif (isset($model->{$name}) && is_object($model->{$name}) && is_subclass_of($model->{$name}, 'Model')) {
|
||||
|
@ -219,7 +219,7 @@ class Sanitize{
|
|||
}
|
||||
|
||||
if ($curModel != null) {
|
||||
foreach($values as $column => $data) {
|
||||
foreach ($values as $column => $data) {
|
||||
$colType = $curModel->getColumnType($column);
|
||||
|
||||
if ($colType != null) {
|
||||
|
|
|
@ -147,8 +147,8 @@ class Security extends Object{
|
|||
srand (CIPHER_SEED);
|
||||
$out = '';
|
||||
|
||||
for($i = 0; $i < strlen($text); $i++) {
|
||||
for($j = 0; $j < ord(substr($key, $i % strlen($key), 1)); $j++) {
|
||||
for ($i = 0; $i < strlen($text); $i++) {
|
||||
for ($j = 0; $j < ord(substr($key, $i % strlen($key), 1)); $j++) {
|
||||
$toss = rand(0, 255);
|
||||
}
|
||||
$mask = rand(0, 255);
|
||||
|
|
|
@ -129,7 +129,7 @@ class CakeSession extends Object {
|
|||
}
|
||||
$this->time = time();
|
||||
|
||||
if($start === true) {
|
||||
if ($start === true) {
|
||||
$this->host = env('HTTP_HOST');
|
||||
|
||||
if (empty($base) || strpos($base, '?')) {
|
||||
|
@ -188,7 +188,7 @@ class CakeSession extends Object {
|
|||
$names = array($name);
|
||||
}
|
||||
$expression = "\$_SESSION";
|
||||
foreach($names as $item) {
|
||||
foreach ($names as $item) {
|
||||
$expression .= is_numeric($item) ? "[$item]" : "['$item']";
|
||||
}
|
||||
return $expression;
|
||||
|
@ -575,7 +575,7 @@ class CakeSession extends Object {
|
|||
*/
|
||||
function __close() {
|
||||
$probability = mt_rand(1, 150);
|
||||
if($probability <= 3) {
|
||||
if ($probability <= 3) {
|
||||
CakeSession::__gc();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -76,7 +76,7 @@ class Set extends Object {
|
|||
function merge($arr1, $arr2 = null) {
|
||||
$args = func_get_args();
|
||||
|
||||
if(is_a($this, 'set')) {
|
||||
if (is_a($this, 'set')) {
|
||||
$backtrace = debug_backtrace();
|
||||
$previousCall = low($backtrace[1]['class'].'::'.$backtrace[1]['function']);
|
||||
if ($previousCall != 'set::merge') {
|
||||
|
@ -84,19 +84,19 @@ class Set extends Object {
|
|||
array_unshift($args, null);
|
||||
}
|
||||
}
|
||||
if(!isset($r)) {
|
||||
if (!isset($r)) {
|
||||
$r = (array)current($args);
|
||||
}
|
||||
|
||||
while(($arg = next($args)) !== false) {
|
||||
while (($arg = next($args)) !== false) {
|
||||
if (is_a($arg, 'set')) {
|
||||
$arg = $arg->get();
|
||||
}
|
||||
|
||||
foreach((array)$arg as $key => $val) {
|
||||
if(is_array($val) && isset($r[$key]) && is_array($r[$key])) {
|
||||
foreach ((array)$arg as $key => $val) {
|
||||
if (is_array($val) && isset($r[$key]) && is_array($r[$key])) {
|
||||
$r[$key] = Set::merge($r[$key], $val);
|
||||
} elseif(is_int($key)) {
|
||||
} elseif (is_int($key)) {
|
||||
$r[] = $val;
|
||||
} else {
|
||||
$r[$key] = $val;
|
||||
|
@ -135,7 +135,7 @@ class Set extends Object {
|
|||
*/
|
||||
function pushDiff($array = null, $array2 = null) {
|
||||
if ($array2 !== null && is_array($array2)) {
|
||||
foreach($array2 as $key => $value) {
|
||||
foreach ($array2 as $key => $value) {
|
||||
if (!array_key_exists($key, $array)) {
|
||||
$array[$key] = $value;
|
||||
} else {
|
||||
|
@ -147,7 +147,7 @@ class Set extends Object {
|
|||
return $array;
|
||||
}
|
||||
|
||||
if(!isset($this->value)) {
|
||||
if (!isset($this->value)) {
|
||||
$this->value = array();
|
||||
}
|
||||
$this->value = Set::pushDiff($this->value, Set::__array($array));
|
||||
|
@ -332,7 +332,7 @@ class Set extends Object {
|
|||
return null;
|
||||
}
|
||||
|
||||
foreach($path as $i => $key) {
|
||||
foreach ($path as $i => $key) {
|
||||
if (is_numeric($key) && intval($key) > 0 || $key == '0') {
|
||||
if (isset($data[intval($key)])) {
|
||||
$data = $data[intval($key)];
|
||||
|
@ -340,7 +340,7 @@ class Set extends Object {
|
|||
return null;
|
||||
}
|
||||
} elseif ($key == '{n}') {
|
||||
foreach($data as $j => $val) {
|
||||
foreach ($data as $j => $val) {
|
||||
$tmp[] = Set::extract($val, array_slice($path, $i + 1));
|
||||
}
|
||||
return $tmp;
|
||||
|
@ -374,7 +374,7 @@ class Set extends Object {
|
|||
}
|
||||
$_list =& $list;
|
||||
|
||||
foreach($path as $i => $key) {
|
||||
foreach ($path as $i => $key) {
|
||||
if (is_numeric($key) && intval($key) > 0 || $key == '0') {
|
||||
$key = intval($key);
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ class Set extends Object {
|
|||
}
|
||||
$_list =& $list;
|
||||
|
||||
foreach($path as $i => $key) {
|
||||
foreach ($path as $i => $key) {
|
||||
if (is_numeric($key) && intval($key) > 0 || $key == '0') {
|
||||
$key = intval($key);
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ class Set extends Object {
|
|||
$path = explode('.', $path);
|
||||
}
|
||||
|
||||
foreach($path as $i => $key) {
|
||||
foreach ($path as $i => $key) {
|
||||
if (is_numeric($key) && intval($key) > 0 || $key == '0') {
|
||||
$key = intval($key);
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ class Set extends Object {
|
|||
foreach ($val1 as $key => $val) {
|
||||
if (isset($val2[$key]) && $val2[$key] != $val) {
|
||||
$out[$key] = $val;
|
||||
} else if(!array_key_exists($key, $val2)){
|
||||
} elseif (!array_key_exists($key, $val2)){
|
||||
$out[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,12 +126,12 @@ class Validation extends Object {
|
|||
$this->_extract($check);
|
||||
}
|
||||
|
||||
if(empty($this->check)) {
|
||||
if (empty($this->check)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->regex = '/[^\\dA-Z]/i';
|
||||
if($this->_check() === true){
|
||||
if ($this->_check() === true){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
@ -177,7 +177,7 @@ class Validation extends Object {
|
|||
}
|
||||
|
||||
$this->regex = '/[^\\s]/';
|
||||
if($this->_check() === true){
|
||||
if ($this->_check() === true){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
@ -210,12 +210,12 @@ class Validation extends Object {
|
|||
|
||||
$this->check = str_replace(array('-', ' '), '', $this->check);
|
||||
|
||||
if(strlen($this->check) < 13){
|
||||
if (strlen($this->check) < 13){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!is_null($this->regex)) {
|
||||
if($this->_check()) {
|
||||
if (!is_null($this->regex)) {
|
||||
if ($this->_check()) {
|
||||
return $this->_luhn();
|
||||
}
|
||||
}
|
||||
|
@ -240,23 +240,23 @@ class Validation extends Object {
|
|||
$card = low($value);
|
||||
$this->regex = $cards['all'][$card];
|
||||
|
||||
if($this->_check()) {
|
||||
if ($this->_check()) {
|
||||
return $this->_luhn();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if($this->type == 'all') {
|
||||
if ($this->type == 'all') {
|
||||
foreach ($cards['all'] as $key => $value) {
|
||||
$this->regex = $value;
|
||||
|
||||
if($this->_check()) {
|
||||
if ($this->_check()) {
|
||||
return $this->_luhn();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->regex = $cards['fast'];
|
||||
|
||||
if($this->_check()) {
|
||||
if ($this->_check()) {
|
||||
return $this->_luhn();
|
||||
}
|
||||
}
|
||||
|
@ -284,37 +284,37 @@ class Validation extends Object {
|
|||
switch($operator) {
|
||||
case 'isgreater':
|
||||
case '>':
|
||||
if($check1 > $check2) {
|
||||
if ($check1 > $check2) {
|
||||
$return = true;
|
||||
}
|
||||
break;
|
||||
case 'isless':
|
||||
case '<':
|
||||
if($check1 < $check2) {
|
||||
if ($check1 < $check2) {
|
||||
$return = true;
|
||||
}
|
||||
break;
|
||||
case 'greaterorequal':
|
||||
case '>=':
|
||||
if($check1 >= $check2) {
|
||||
if ($check1 >= $check2) {
|
||||
$return = true;
|
||||
}
|
||||
break;
|
||||
case 'lessorequal':
|
||||
case '<=':
|
||||
if($check1 <= $check2) {
|
||||
if ($check1 <= $check2) {
|
||||
$return = true;
|
||||
}
|
||||
break;
|
||||
case 'equalto':
|
||||
case '==':
|
||||
if($check1 == $check2) {
|
||||
if ($check1 == $check2) {
|
||||
$return = true;
|
||||
}
|
||||
break;
|
||||
case 'notequal':
|
||||
case '!=':
|
||||
if($check1 != $check2) {
|
||||
if ($check1 != $check2) {
|
||||
$return = true;
|
||||
}
|
||||
break;
|
||||
|
@ -341,7 +341,7 @@ class Validation extends Object {
|
|||
if (is_array($check)) {
|
||||
$this->_extract($check);
|
||||
}
|
||||
if($this->regex === null){
|
||||
if ($this->regex === null){
|
||||
$this->errors[] = __('You must define a regular expression for Validation::custom()', true);
|
||||
return false;
|
||||
}
|
||||
|
@ -369,14 +369,14 @@ class Validation extends Object {
|
|||
$this->check = $check;
|
||||
$this->regex = $regex;
|
||||
|
||||
if(!is_null($this->regex)) {
|
||||
if (!is_null($this->regex)) {
|
||||
return $this->_check();
|
||||
}
|
||||
|
||||
$search = array();
|
||||
|
||||
if(is_array($format)){
|
||||
foreach($format as $key => $value){
|
||||
if (is_array($format)){
|
||||
foreach ($format as $key => $value){
|
||||
$search[$value] = $value;
|
||||
}
|
||||
} else {
|
||||
|
@ -393,7 +393,7 @@ class Validation extends Object {
|
|||
foreach ($search as $key){
|
||||
$this->regex = $regex[$key];
|
||||
|
||||
if($this->_check() === true){
|
||||
if ($this->_check() === true){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -414,11 +414,11 @@ class Validation extends Object {
|
|||
$this->regex = $regex;
|
||||
$this->check = $check;
|
||||
|
||||
if(!is_null($this->regex)) {
|
||||
if (!is_null($this->regex)) {
|
||||
return $this->_check();
|
||||
}
|
||||
|
||||
if(is_null($places)) {
|
||||
if (is_null($places)) {
|
||||
$this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/';
|
||||
return $this->_check();
|
||||
}
|
||||
|
@ -445,12 +445,12 @@ class Validation extends Object {
|
|||
$this->_extract($check);
|
||||
}
|
||||
|
||||
if(is_null($this->regex)) {
|
||||
if (is_null($this->regex)) {
|
||||
$this->regex = '/\\A(?:^([a-z0-9][a-z0-9_\\-\\.\\+]*)@([a-z0-9][a-z0-9\\.\\-]{0,63}\\.(com|org|net|biz|info|name|net|pro|aero|coop|museum|[a-z]{2,4}))$)\\z/i';
|
||||
}
|
||||
$return = $this->_check();
|
||||
|
||||
if($this->deep === false || $this->deep === null) {
|
||||
if ($this->deep === false || $this->deep === null) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -580,7 +580,7 @@ class Validation extends Object {
|
|||
if (isset($lower) && isset($upper) && $lower > $upper) {
|
||||
//error
|
||||
}
|
||||
if(is_float($check)) {
|
||||
if (is_float($check)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ class Validation extends Object {
|
|||
$this->country = $country;
|
||||
}
|
||||
|
||||
if(is_null($this->regex)) {
|
||||
if (is_null($this->regex)) {
|
||||
switch ($this->country) {
|
||||
case 'us':
|
||||
$this->regex = '/1?[-. ]?\\(?([0-9]{3})\\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})/';
|
||||
|
@ -642,7 +642,7 @@ class Validation extends Object {
|
|||
$this->country = $country;
|
||||
}
|
||||
|
||||
if(is_null($this->regex)) {
|
||||
if (is_null($this->regex)) {
|
||||
switch ($this->country) {
|
||||
case 'us':
|
||||
$this->regex = '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i';
|
||||
|
@ -676,7 +676,7 @@ class Validation extends Object {
|
|||
$this->country = $country;
|
||||
}
|
||||
|
||||
if(is_null($this->regex)) {
|
||||
if (is_null($this->regex)) {
|
||||
switch ($this->country) {
|
||||
case 'us':
|
||||
$this->regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
|
||||
|
@ -768,8 +768,8 @@ class Validation extends Object {
|
|||
* @access protected
|
||||
*/
|
||||
function _luhn() {
|
||||
if($this->deep === true){
|
||||
if($this->check == 0) {
|
||||
if ($this->deep === true){
|
||||
if ($this->check == 0) {
|
||||
return false;
|
||||
}
|
||||
$sum = 0;
|
||||
|
|
|
@ -157,7 +157,7 @@ class Helper extends Overloadable {
|
|||
function loadConfig($name = 'tags') {
|
||||
if (file_exists(APP . 'config' . DS . $name .'.php')) {
|
||||
require(APP . 'config' . DS . $name .'.php');
|
||||
if(isset($tags)) {
|
||||
if (isset($tags)) {
|
||||
$this->tags = am($this->tags, $tags);
|
||||
}
|
||||
}
|
||||
|
@ -190,14 +190,14 @@ class Helper extends Overloadable {
|
|||
*/
|
||||
function webroot($file) {
|
||||
$webPath = "{$this->webroot}" . $file;
|
||||
if(!empty($this->themeWeb)) {
|
||||
if (!empty($this->themeWeb)) {
|
||||
$os = env('OS');
|
||||
if (!empty($os) && strpos($os, 'Windows') !== false) {
|
||||
$path = str_replace('/', '\\', WWW_ROOT . $this->themeWeb . $file);
|
||||
} else {
|
||||
$path = WWW_ROOT . $this->themeWeb . $file;
|
||||
}
|
||||
if(file_exists($path)){
|
||||
if (file_exists($path)){
|
||||
$webPath = "{$this->webroot}" . $this->themeWeb . $file;
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ class Helper extends Overloadable {
|
|||
$values = array_intersect_key(array_values($options), $keys);
|
||||
$escape = $options['escape'];
|
||||
$attributes = array();
|
||||
foreach($keys as $index => $key) {
|
||||
foreach ($keys as $index => $key) {
|
||||
$attributes[] = $this->__formatAttribute($key, $values[$index], $escape);
|
||||
}
|
||||
$out = implode(' ', $attributes);
|
||||
|
@ -305,7 +305,7 @@ class Helper extends Overloadable {
|
|||
function setFormTag($tagValue) {
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
|
||||
if($tagValue === null) {
|
||||
if ($tagValue === null) {
|
||||
$view->model = null;
|
||||
$view->association = null;
|
||||
$view->modelId = null;
|
||||
|
@ -330,7 +330,7 @@ class Helper extends Overloadable {
|
|||
$view->modelId = $parts[1];
|
||||
$view->field = $parts[2];
|
||||
}
|
||||
if(!isset($view->model)) {
|
||||
if (!isset($view->model)) {
|
||||
$view->model = $view->association;
|
||||
$view->association = null;
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ class Helper extends Overloadable {
|
|||
*/
|
||||
function model() {
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
if($view->association == null) {
|
||||
if ($view->association == null) {
|
||||
return $view->model;
|
||||
} else {
|
||||
return $view->association;
|
||||
|
@ -591,18 +591,18 @@ class Helper extends Overloadable {
|
|||
* @access private
|
||||
*/
|
||||
function __selectedArray($data, $key = 'id') {
|
||||
if(!is_array($data)) {
|
||||
if (!is_array($data)) {
|
||||
$model = $data;
|
||||
if(!empty($this->data[$model][$model])) {
|
||||
if (!empty($this->data[$model][$model])) {
|
||||
return $this->data[$model][$model];
|
||||
}
|
||||
if(!empty($this->data[$model])) {
|
||||
if (!empty($this->data[$model])) {
|
||||
$data = $this->data[$model];
|
||||
}
|
||||
}
|
||||
$array = array();
|
||||
if(!empty($data)) {
|
||||
foreach($data as $var) {
|
||||
if (!empty($data)) {
|
||||
foreach ($data as $var) {
|
||||
$array[$var[$key]] = $var[$key];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -605,7 +605,7 @@ class AjaxHelper extends AppHelper {
|
|||
$url = $this->url($url);
|
||||
$options['ajaxOptions'] = $this->__optionsForAjax($options);
|
||||
|
||||
foreach($this->ajaxOptions as $opt) {
|
||||
foreach ($this->ajaxOptions as $opt) {
|
||||
if (isset($options[$opt])) {
|
||||
unset($options[$opt]);
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ class AjaxHelper extends AppHelper {
|
|||
);
|
||||
$options = $this->_optionsToString($options, array('method'));
|
||||
|
||||
foreach($options as $key => $value) {
|
||||
foreach ($options as $key => $value) {
|
||||
switch($key) {
|
||||
case 'type':
|
||||
$jsOptions['asynchronous'] = ife(($value == 'synchronous'), 'false', 'true');
|
||||
|
@ -721,13 +721,13 @@ class AjaxHelper extends AppHelper {
|
|||
* @access private
|
||||
*/
|
||||
function __getHtmlOptions($options, $extra = array()) {
|
||||
foreach($this->ajaxOptions as $key) {
|
||||
foreach ($this->ajaxOptions as $key) {
|
||||
if (isset($options[$key])) {
|
||||
unset($options[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($extra as $key) {
|
||||
foreach ($extra as $key) {
|
||||
if (isset($options[$key])) {
|
||||
unset($options[$key]);
|
||||
}
|
||||
|
@ -747,7 +747,7 @@ class AjaxHelper extends AppHelper {
|
|||
if (is_array($options)) {
|
||||
$out = array();
|
||||
|
||||
foreach($options as $k => $v) {
|
||||
foreach ($options as $k => $v) {
|
||||
if (in_array($k, $acceptable)) {
|
||||
$out[] = "$k:$v";
|
||||
}
|
||||
|
@ -789,7 +789,7 @@ class AjaxHelper extends AppHelper {
|
|||
function _buildCallbacks($options) {
|
||||
$callbacks = array();
|
||||
|
||||
foreach($this->callbacks as $callback) {
|
||||
foreach ($this->callbacks as $callback) {
|
||||
if (isset($options[$callback])) {
|
||||
$name = 'on' . ucfirst($callback);
|
||||
$code = $options[$callback];
|
||||
|
@ -816,7 +816,7 @@ class AjaxHelper extends AppHelper {
|
|||
* @return array
|
||||
*/
|
||||
function _optionsToString($options, $stringOpts = array()) {
|
||||
foreach($stringOpts as $option) {
|
||||
foreach ($stringOpts as $option) {
|
||||
if (isset($options[$option]) && !$options[$option][0] != "'") {
|
||||
if ($options[$option] === true || $options[$option] === 'true') {
|
||||
$options[$option] = 'true';
|
||||
|
|
|
@ -82,7 +82,7 @@ class CacheHelper extends AppHelper {
|
|||
$index = null;
|
||||
$count = 0;
|
||||
|
||||
foreach($keys as $key => $value) {
|
||||
foreach ($keys as $key => $value) {
|
||||
if (strpos($check, $value) === 0) {
|
||||
$index = $found[$count];
|
||||
break;
|
||||
|
@ -143,7 +143,7 @@ class CacheHelper extends AppHelper {
|
|||
if (!empty($result['0'])) {
|
||||
$count = 0;
|
||||
|
||||
foreach($result['0'] as $result) {
|
||||
foreach ($result['0'] as $result) {
|
||||
if (isset($oresult['0'][$count])) {
|
||||
$this->__replace[] = $result;
|
||||
$this->__match[] = $oresult['0'][$count];
|
||||
|
@ -163,7 +163,7 @@ class CacheHelper extends AppHelper {
|
|||
$count = 0;
|
||||
if (!empty($this->__match)) {
|
||||
|
||||
foreach($this->__match as $found) {
|
||||
foreach ($this->__match as $found) {
|
||||
$original = $cache;
|
||||
$length = strlen($found);
|
||||
$position = 0;
|
||||
|
@ -171,7 +171,7 @@ class CacheHelper extends AppHelper {
|
|||
for ($i = 1; $i <= 1; $i++) {
|
||||
$position = strpos($cache, $found, $position);
|
||||
|
||||
if($position !== false) {
|
||||
if ($position !== false) {
|
||||
$cache = substr($original, 0, $position);
|
||||
$cache .= $this->__replace[$count];
|
||||
$cache .= substr($original, $position + $length);
|
||||
|
@ -203,13 +203,13 @@ class CacheHelper extends AppHelper {
|
|||
}
|
||||
|
||||
$cache = convertSlash($this->here);
|
||||
if(empty($cache)){
|
||||
if (empty($cache)){
|
||||
return;
|
||||
}
|
||||
|
||||
$cache = $cache . '.php';
|
||||
$file = '<!--cachetime:' . $cacheTime . '--><?php';
|
||||
if(empty($this->plugin)) {
|
||||
if (empty($this->plugin)) {
|
||||
$file .= '
|
||||
loadController(\'' . $this->controllerName. '\');
|
||||
loadModels();
|
||||
|
@ -244,15 +244,15 @@ class CacheHelper extends AppHelper {
|
|||
$this->plugin = \'' . $this->plugin . '\';
|
||||
$loadedHelpers = array();
|
||||
$loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
|
||||
foreach(array_keys($loadedHelpers) as $helper)
|
||||
foreach (array_keys($loadedHelpers) as $helper)
|
||||
{
|
||||
$replace = strtolower(substr($helper, 0, 1));
|
||||
$camelBackedHelper = preg_replace(\'/\\w/\', $replace, $helper, 1);
|
||||
${$camelBackedHelper} =& $loadedHelpers[$helper];
|
||||
|
||||
if(isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers))
|
||||
if (isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers))
|
||||
{
|
||||
foreach(${$camelBackedHelper}->helpers as $subHelper)
|
||||
foreach (${$camelBackedHelper}->helpers as $subHelper)
|
||||
{
|
||||
${$camelBackedHelper}->{$subHelper} =& $loadedHelpers[$subHelper];
|
||||
}
|
||||
|
|
|
@ -1231,17 +1231,17 @@ class FormHelper extends AppHelper {
|
|||
|
||||
switch ($name) {
|
||||
case 'minute':
|
||||
for($i = 0; $i < 60; $i++) {
|
||||
for ($i = 0; $i < 60; $i++) {
|
||||
$data[$i] = sprintf('%02d', $i);
|
||||
}
|
||||
break;
|
||||
case 'hour':
|
||||
for($i = 1; $i <= 12; $i++) {
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$data[sprintf('%02d', $i)] = $i;
|
||||
}
|
||||
break;
|
||||
case 'hour24':
|
||||
for($i = 0; $i <= 23; $i++) {
|
||||
for ($i = 0; $i <= 23; $i++) {
|
||||
$data[sprintf('%02d', $i)] = $i;
|
||||
}
|
||||
break;
|
||||
|
@ -1255,12 +1255,12 @@ class FormHelper extends AppHelper {
|
|||
if (empty($max)) {
|
||||
$max = 31;
|
||||
}
|
||||
for($i = $min; $i <= $max; $i++) {
|
||||
for ($i = $min; $i <= $max; $i++) {
|
||||
$data[sprintf('%02d', $i)] = $i;
|
||||
}
|
||||
break;
|
||||
case 'month':
|
||||
for($i = 1; $i <= 12; $i++) {
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$data[sprintf("%02s", $i)] = strftime("%B", mktime(1,1,1,$i,1,1999));
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -226,9 +226,9 @@ class HtmlHelper extends AppHelper {
|
|||
* @return string A meta tag containing the specified character set.
|
||||
*/
|
||||
function charset($charset = null) {
|
||||
if(is_null($charset)){
|
||||
if (is_null($charset)){
|
||||
$charset = Configure::read('charset');
|
||||
if(is_null($charset)){
|
||||
if (is_null($charset)){
|
||||
$charset = 'utf-8';
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ class HtmlHelper extends AppHelper {
|
|||
* @return string An <a /> element.
|
||||
*/
|
||||
function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true) {
|
||||
if($url !== null) {
|
||||
if ($url !== null) {
|
||||
$url = $this->url($url);
|
||||
} else {
|
||||
$url = $this->url($title);
|
||||
|
@ -260,17 +260,17 @@ class HtmlHelper extends AppHelper {
|
|||
$escapeTitle = false;
|
||||
}
|
||||
|
||||
if(isset($htmlAttributes['escape'])) {
|
||||
if (isset($htmlAttributes['escape'])) {
|
||||
$escapeTitle = $htmlAttributes['escape'];
|
||||
unset($htmlAttributes['escape']);
|
||||
}
|
||||
if($escapeTitle === true) {
|
||||
if ($escapeTitle === true) {
|
||||
$title = htmlspecialchars($title, ENT_QUOTES);
|
||||
} elseif(is_string($escapeTitle)) {
|
||||
} elseif (is_string($escapeTitle)) {
|
||||
$title = htmlentities($title, ENT_QUOTES, $escapeTitle);
|
||||
}
|
||||
|
||||
if(!empty($htmlAttributes['confirm'])) {
|
||||
if (!empty($htmlAttributes['confirm'])) {
|
||||
$confirmMessage = $htmlAttributes['confirm'];
|
||||
unset($htmlAttributes['confirm']);
|
||||
}
|
||||
|
@ -339,10 +339,10 @@ class HtmlHelper extends AppHelper {
|
|||
return $data;
|
||||
}
|
||||
$out = array();
|
||||
foreach($data as $key=> $value) {
|
||||
foreach ($data as $key=> $value) {
|
||||
$out[] = $key.':'.$value.';';
|
||||
}
|
||||
if($inline) {
|
||||
if ($inline) {
|
||||
return 'style="'.join(' ', $out).'"';
|
||||
}
|
||||
return join("\n", $out);
|
||||
|
@ -361,8 +361,8 @@ class HtmlHelper extends AppHelper {
|
|||
$out[] = $this->link($startText, '/');
|
||||
}
|
||||
|
||||
foreach($this->_crumbs as $crumb) {
|
||||
if(!empty($crumb[1])){
|
||||
foreach ($this->_crumbs as $crumb) {
|
||||
if (!empty($crumb[1])){
|
||||
$out[] = $this->link($crumb[0], $crumb[1]);
|
||||
} else {
|
||||
$out[] = $crumb[0];
|
||||
|
@ -407,7 +407,7 @@ class HtmlHelper extends AppHelper {
|
|||
$value = isset($htmlAttributes['value']) ? $htmlAttributes['value'] : $this->value($fieldName);
|
||||
$out = array();
|
||||
|
||||
foreach($options as $optValue => $optTitle) {
|
||||
foreach ($options as $optValue => $optTitle) {
|
||||
$optionsHere = array('value' => $optValue);
|
||||
if (!empty($value) && $optValue == $value) {
|
||||
$optionsHere['checked'] = 'checked';
|
||||
|
@ -430,7 +430,7 @@ class HtmlHelper extends AppHelper {
|
|||
*/
|
||||
function tableHeaders($names, $trOptions = null, $thOptions = null) {
|
||||
$out = array();
|
||||
foreach($names as $arg) {
|
||||
foreach ($names as $arg) {
|
||||
$out[] = sprintf($this->tags['tableheader'], $this->_parseAttributes($thOptions), $arg);
|
||||
}
|
||||
$data = sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out));
|
||||
|
@ -450,11 +450,11 @@ class HtmlHelper extends AppHelper {
|
|||
}
|
||||
static $count = 0;
|
||||
|
||||
foreach($data as $line) {
|
||||
foreach ($data as $line) {
|
||||
$count++;
|
||||
$cellsOut = array();
|
||||
|
||||
foreach($line as $cell) {
|
||||
foreach ($line as $cell) {
|
||||
$cellsOut[] = sprintf($this->tags['tablecell'], null, $cell);
|
||||
}
|
||||
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);
|
||||
|
@ -568,7 +568,7 @@ class HtmlHelper extends AppHelper {
|
|||
} else {
|
||||
$model = $this->model();
|
||||
if (isset($htmlAttributes['value']) || (!class_exists($model) && !loadModel($model))) {
|
||||
if(isset($htmlAttributes['value']) && $htmlAttributes['value'] == $value){
|
||||
if (isset($htmlAttributes['value']) && $htmlAttributes['value'] == $value){
|
||||
$htmlAttributes['checked'] = 'checked';
|
||||
} else {
|
||||
$htmlAttributes['checked'] = null;
|
||||
|
@ -662,7 +662,7 @@ class HtmlHelper extends AppHelper {
|
|||
}
|
||||
|
||||
$errors = array();
|
||||
foreach($objects as $object) {
|
||||
foreach ($objects as $object) {
|
||||
$errors = array_merge($errors, $object->invalidFields($object->data));
|
||||
}
|
||||
return $this->validationErrors = (count($errors) ? $errors : false);
|
||||
|
|
|
@ -305,7 +305,7 @@ class JavascriptHelper extends AppHelper {
|
|||
$files = scandir(JS);
|
||||
$javascript = '';
|
||||
|
||||
foreach($files as $file) {
|
||||
foreach ($files as $file) {
|
||||
if (substr($file, -3) == '.js') {
|
||||
$javascript .= file_get_contents(JS . "{$file}") . "\n\n";
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ class JavascriptHelper extends AppHelper {
|
|||
$numeric = (array_values($keys) === array_keys(array_values($keys)));
|
||||
}
|
||||
|
||||
foreach($data as $key => $val) {
|
||||
foreach ($data as $key => $val) {
|
||||
if (is_array($val) || is_object($val)) {
|
||||
$val = $this->object($val, false, '', '', $stringKeys, $quoteKeys, $q);
|
||||
} else {
|
||||
|
|
|
@ -89,7 +89,7 @@ class JsHelper extends Overloadable2 {
|
|||
$if{$len} = null;
|
||||
}
|
||||
|
||||
$out = 'if(' . $if . ') { ' . $then . ' }';
|
||||
$out = 'if (' . $if . ') { ' . $then . ' }';
|
||||
|
||||
foreach ($elseif as $cond => $exec) {
|
||||
//$out .=
|
||||
|
@ -237,7 +237,7 @@ class JsHelper extends Overloadable2 {
|
|||
$numeric = true;
|
||||
|
||||
if (!empty($keys)) {
|
||||
foreach($keys as $key) {
|
||||
foreach ($keys as $key) {
|
||||
if (!is_numeric($key)) {
|
||||
$numeric = false;
|
||||
break;
|
||||
|
@ -245,7 +245,7 @@ class JsHelper extends Overloadable2 {
|
|||
}
|
||||
}
|
||||
|
||||
foreach($data as $key => $val) {
|
||||
foreach ($data as $key => $val) {
|
||||
if (is_array($val) || is_object($val)) {
|
||||
$val = $this->object($val, false, '', '', $stringKeys, $quoteKeys, $q);
|
||||
} else {
|
||||
|
|
|
@ -96,33 +96,33 @@ class NumberHelper extends AppHelper {
|
|||
*/
|
||||
function format($number, $options = false) {
|
||||
$places = 0;
|
||||
if(is_int($options)) {
|
||||
if (is_int($options)) {
|
||||
$places = $options;
|
||||
}
|
||||
|
||||
$seperators = array(',', '.', '-', ':');
|
||||
|
||||
$before = null;
|
||||
if(is_string($options) && !in_array( $options, $seperators)) {
|
||||
if (is_string($options) && !in_array( $options, $seperators)) {
|
||||
$before = $options;
|
||||
}
|
||||
$seperator = ',';
|
||||
if(!is_array($options) && in_array( $options, $seperators)) {
|
||||
if (!is_array($options) && in_array( $options, $seperators)) {
|
||||
$seperator = $options;
|
||||
}
|
||||
|
||||
if(is_array($options)) {
|
||||
if(isset($options['places'])) {
|
||||
if (is_array($options)) {
|
||||
if (isset($options['places'])) {
|
||||
$places = $options['places'];
|
||||
unset($options['places']);
|
||||
}
|
||||
|
||||
if(isset($options['before'])) {
|
||||
if (isset($options['before'])) {
|
||||
$before = $options['before'];
|
||||
unset($options['before']);
|
||||
}
|
||||
|
||||
if(isset($options['seperator'])) {
|
||||
if (isset($options['seperator'])) {
|
||||
$seperator = $options['seperator'];
|
||||
unset($options['seperator']);
|
||||
}
|
||||
|
|
|
@ -94,8 +94,8 @@ class PaginatorHelper extends AppHelper {
|
|||
$options = array('update' => $options);
|
||||
}
|
||||
|
||||
if(!empty($options['paging'])) {
|
||||
if(!isset($this->params['paging'])) {
|
||||
if (!empty($options['paging'])) {
|
||||
if (!isset($this->params['paging'])) {
|
||||
$this->params['paging'] = array();
|
||||
}
|
||||
$this->params['paging'] = am($this->params['paging'], $options['paging']);
|
||||
|
@ -103,8 +103,8 @@ class PaginatorHelper extends AppHelper {
|
|||
}
|
||||
|
||||
$model = $this->defaultModel();
|
||||
if(!empty($options[$model])) {
|
||||
if(!isset($this->params['paging'][$model])) {
|
||||
if (!empty($options[$model])) {
|
||||
if (!isset($this->params['paging'][$model])) {
|
||||
$this->params['paging'][$model] = array();
|
||||
}
|
||||
$this->params['paging'][$model] = am($this->params['paging'][$model], $options[$model]);
|
||||
|
@ -244,13 +244,13 @@ class PaginatorHelper extends AppHelper {
|
|||
$model = $options['model'];
|
||||
unset($options['model']);
|
||||
|
||||
if(!empty($this->options)) {
|
||||
if (!empty($this->options)) {
|
||||
$options = am($this->options, $options);
|
||||
}
|
||||
|
||||
$paging = $this->params($model);
|
||||
$urlOption = null;
|
||||
if(isset($options['url'])) {
|
||||
if (isset($options['url'])) {
|
||||
$urlOption = $options['url'];
|
||||
unset($options['url']);
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ class PaginatorHelper extends AppHelper {
|
|||
$params = $this->params($options['model']);
|
||||
unset($options['model']);
|
||||
|
||||
if($params['pageCount'] <= 1) {
|
||||
if ($params['pageCount'] <= 1) {
|
||||
return false;
|
||||
}
|
||||
$before = $options['before'];
|
||||
|
@ -450,15 +450,15 @@ class PaginatorHelper extends AppHelper {
|
|||
|
||||
$out = $before;
|
||||
|
||||
if($modulus && $params['pageCount'] > $modulus) {
|
||||
if ($modulus && $params['pageCount'] > $modulus) {
|
||||
$half = intval($modulus / 2);
|
||||
$end = $params['page'] + $half;
|
||||
if($end > $params['pageCount']) {
|
||||
if ($end > $params['pageCount']) {
|
||||
$end = $params['pageCount'];
|
||||
}
|
||||
$start = $params['page'] - ($modulus - ($end - $params['page']));
|
||||
|
||||
if($start <= 1) {
|
||||
if ($start <= 1) {
|
||||
$start = 1;
|
||||
$end = $params['page'] + ($modulus - $params['page']) + 1;
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ class PaginatorHelper extends AppHelper {
|
|||
}
|
||||
} else {
|
||||
for ($i = 1; $i <= $params['pageCount']; $i++) {
|
||||
if($i == $params['page']) {
|
||||
if ($i == $params['page']) {
|
||||
$out .= $i;
|
||||
} else {
|
||||
$out .= $this->link($i, am($options, array('page' => $i)));
|
||||
|
|
|
@ -64,7 +64,7 @@ class TextHelper extends AppHelper {
|
|||
$replace = array();
|
||||
$with = array();
|
||||
|
||||
foreach($phrase as $key => $value) {
|
||||
foreach ($phrase as $key => $value) {
|
||||
$key = $value;
|
||||
$value = $highlighter;
|
||||
|
||||
|
@ -97,7 +97,7 @@ class TextHelper extends AppHelper {
|
|||
function autoLinkUrls($text, $htmlOptions = array()) {
|
||||
$options = 'array(';
|
||||
|
||||
foreach($htmlOptions as $option => $value) {
|
||||
foreach ($htmlOptions as $option => $value) {
|
||||
$options .= "'$option' => '$value', ";
|
||||
}
|
||||
$options .= ')';
|
||||
|
@ -118,7 +118,7 @@ class TextHelper extends AppHelper {
|
|||
function autoLinkEmails($text, $htmlOptions = array()) {
|
||||
$options = 'array(';
|
||||
|
||||
foreach($htmlOptions as $option => $value) {
|
||||
foreach ($htmlOptions as $option => $value) {
|
||||
$options .= "'$option' => '$value', ";
|
||||
}
|
||||
$options .= ')';
|
||||
|
|
|
@ -94,7 +94,7 @@ class TimeHelper extends AppHelper {
|
|||
|
||||
if ($this->isToday($date)) {
|
||||
$ret = "Today, " . date("H:i", $date);
|
||||
} elseif($this->wasYesterday($date)) {
|
||||
} elseif ($this->wasYesterday($date)) {
|
||||
$ret = "Yesterday, " . date("H:i", $date);
|
||||
} else {
|
||||
$ret = date("M jS{$y}, H:i", $date);
|
||||
|
@ -280,15 +280,15 @@ class TimeHelper extends AppHelper {
|
|||
// weeks and days
|
||||
$relative_date .= ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : '');
|
||||
$relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : '';
|
||||
} elseif($days > 0) {
|
||||
} elseif ($days > 0) {
|
||||
// days and hours
|
||||
$relative_date .= ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '');
|
||||
$relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : '';
|
||||
} elseif($hours > 0) {
|
||||
} elseif ($hours > 0) {
|
||||
// hours and minutes
|
||||
$relative_date .= ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '');
|
||||
$relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : '';
|
||||
} elseif($minutes > 0) {
|
||||
} elseif ($minutes > 0) {
|
||||
// minutes only
|
||||
$relative_date .= ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '');
|
||||
} else {
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
</div>
|
||||
<div id="content">
|
||||
<?php
|
||||
if($session->check('Message.flash')):
|
||||
if ($session->check('Message.flash')):
|
||||
$session->flash();
|
||||
endif;
|
||||
?>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<title><?php echo $page_title?></title>
|
||||
<?php echo $html->charset(); ?>
|
||||
|
||||
<?php if(Configure::read() == 0) { ?>
|
||||
<?php if (Configure::read() == 0) { ?>
|
||||
<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>"/>
|
||||
<?php } ?>
|
||||
<style><!--
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<span class="notice">
|
||||
<?php
|
||||
__('Your tmp directory is ');
|
||||
if(is_writable(TMP)):
|
||||
if (is_writable(TMP)):
|
||||
__('writable.');
|
||||
else:
|
||||
__('NOT writable.');
|
||||
|
@ -57,7 +57,7 @@
|
|||
else:
|
||||
__('NOT working.');
|
||||
echo '<br />';
|
||||
if(is_writable(TMP)):
|
||||
if (is_writable(TMP)):
|
||||
__('Edit: config/core.php to insure you have the newset version of this file and the variable $cakeCache set properly');
|
||||
endif;
|
||||
endif;
|
||||
|
@ -69,7 +69,7 @@
|
|||
<?php
|
||||
__('Your database configuration file is ');
|
||||
$filePresent = null;
|
||||
if(file_exists(CONFIGS.'database.php')):
|
||||
if (file_exists(CONFIGS.'database.php')):
|
||||
__('present.');
|
||||
$filePresent = true;
|
||||
else:
|
||||
|
@ -90,7 +90,7 @@ if (!empty($filePresent)):
|
|||
<span class="notice">
|
||||
<?php
|
||||
__('Cake');
|
||||
if($connected->isConnected()):
|
||||
if ($connected->isConnected()):
|
||||
__(' is able to ');
|
||||
else:
|
||||
__(' is NOT able to ');
|
||||
|
|
|
@ -29,14 +29,14 @@
|
|||
<fieldset>
|
||||
<legend><?php echo Inflector::humanize($this->action).' '. $singularHumanName;?></legend>
|
||||
<?php
|
||||
foreach($fields as $field) {
|
||||
if($this->action == 'add' && $field['name'] == $primaryKey) {
|
||||
foreach ($fields as $field) {
|
||||
if ($this->action == 'add' && $field['name'] == $primaryKey) {
|
||||
continue;
|
||||
} else if(!in_array($field['name'], array('created', 'modified', 'updated'))){
|
||||
} elseif (!in_array($field['name'], array('created', 'modified', 'updated'))){
|
||||
echo "\t\t".$form->input($field['name'])."\n";
|
||||
}
|
||||
}
|
||||
foreach($hasAndBelongsToMany as $assocName => $assocData) {
|
||||
foreach ($hasAndBelongsToMany as $assocName => $assocData) {
|
||||
echo "\t\t".$form->input($assocName)."\n";
|
||||
}
|
||||
?>
|
||||
|
@ -47,14 +47,14 @@
|
|||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<?php if($this->action != 'add'):?>
|
||||
<?php if ($this->action != 'add'):?>
|
||||
<li><?php echo $html->link(__('Delete', true), array('action'=>'delete', $form->value($modelClass.'.'.$primaryKey)), null, __('Are you sure you want to delete', true).' #' . $form->value($modelClass.'.'.$primaryKey)); ?></li>
|
||||
<?php endif;?>
|
||||
<li><?php echo $html->link(__('List', true).' '.$pluralHumanName, array('action'=>'index'));?></li>
|
||||
<?php
|
||||
foreach($foreignKeys as $field => $value) {
|
||||
foreach ($foreignKeys as $field => $value) {
|
||||
$otherModelClass = $value['1'];
|
||||
if($otherModelClass != $modelClass) {
|
||||
if ($otherModelClass != $modelClass) {
|
||||
$otherModelKey = Inflector::underscore($otherModelClass);
|
||||
$otherControllerName = Inflector::pluralize($otherModelClass);
|
||||
$otherControllerPath = Inflector::underscore($otherControllerName);
|
||||
|
|
|
@ -33,28 +33,28 @@ echo $paginator->counter(array(
|
|||
?></p>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<?php foreach($fields as $field):?>
|
||||
<?php foreach ($fields as $field):?>
|
||||
<th><?php echo $paginator->sort("{$field['name']}");?></th>
|
||||
<?php endforeach;?>
|
||||
<th><?php __('Actions');?></th>
|
||||
</tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach(${$pluralVar} as ${$singularVar}):
|
||||
foreach (${$pluralVar} as ${$singularVar}):
|
||||
$class = null;
|
||||
if($i++ % 2 == 0) {
|
||||
if ($i++ % 2 == 0) {
|
||||
$class = ' class=\"altrow\"';
|
||||
}
|
||||
echo "\n";
|
||||
echo "\t<tr" . $class . ">\n";
|
||||
|
||||
foreach($fields as $field) {
|
||||
if(in_array($field['name'], array_keys($foreignKeys))) {
|
||||
foreach ($fields as $field) {
|
||||
if (in_array($field['name'], array_keys($foreignKeys))) {
|
||||
$otherModelClass = $foreignKeys[$field['name']][1];
|
||||
$otherModelKey = Inflector::underscore($otherModelClass);
|
||||
$otherControllerName = Inflector::pluralize($otherModelClass);
|
||||
$otherControllerPath = Inflector::underscore($otherControllerName);
|
||||
if(isset($foreignKeys[$field['name']][2])) {
|
||||
if (isset($foreignKeys[$field['name']][2])) {
|
||||
$otherModelClass = $foreignKeys[$field['name']][2];
|
||||
}
|
||||
$otherVariableName = Inflector::variable($otherModelClass);
|
||||
|
@ -88,9 +88,9 @@ echo "\n";
|
|||
<ul>
|
||||
<li><?php echo $html->link('New '.$singularHumanName, array('action'=>'add')); ?></li>
|
||||
<?php
|
||||
foreach($foreignKeys as $field => $value) {
|
||||
foreach ($foreignKeys as $field => $value) {
|
||||
$otherModelClass = $value['1'];
|
||||
if($otherModelClass != $modelClass) {
|
||||
if ($otherModelClass != $modelClass) {
|
||||
$otherModelKey = Inflector::underscore($otherModelClass);
|
||||
$otherControllerName = Inflector::pluralize($otherModelClass);
|
||||
$otherControllerPath = Inflector::underscore($otherControllerName);
|
||||
|
|
|
@ -29,18 +29,18 @@
|
|||
<dl>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach($fields as $field) {
|
||||
foreach ($fields as $field) {
|
||||
$class = null;
|
||||
if($i++ % 2 == 0) {
|
||||
if ($i++ % 2 == 0) {
|
||||
$class = ' class="altrow"';
|
||||
}
|
||||
|
||||
if(in_array($field['name'], array_keys($foreignKeys))) {
|
||||
if (in_array($field['name'], array_keys($foreignKeys))) {
|
||||
$otherModelClass = $foreignKeys[$field['name']][1];
|
||||
$otherModelKey = Inflector::underscore($otherModelClass);
|
||||
$otherControllerName = Inflector::pluralize($otherModelClass);
|
||||
$otherControllerPath = Inflector::underscore($otherControllerName);
|
||||
if(isset($foreignKeys[$field['name']][2])) {
|
||||
if (isset($foreignKeys[$field['name']][2])) {
|
||||
$otherModelClass = $foreignKeys[$field['name']][2];
|
||||
}
|
||||
$otherSingularVar = Inflector::variable($otherModelClass);
|
||||
|
@ -65,9 +65,9 @@ foreach($fields as $field) {
|
|||
echo "\t\t<li>" .$html->link(__('List', true)." ".$pluralHumanName, array('action'=>'index')). " </li>\n";
|
||||
echo "\t\t<li>" .$html->link(__('New', true)." ".$singularHumanName, array('action'=>'add')). " </li>\n";
|
||||
|
||||
foreach($foreignKeys as $field => $value) {
|
||||
foreach ($foreignKeys as $field => $value) {
|
||||
$otherModelClass = $value['1'];
|
||||
if($otherModelClass != $modelClass) {
|
||||
if ($otherModelClass != $modelClass) {
|
||||
$otherModelKey = Inflector::underscore($otherModelClass);
|
||||
$otherControllerName = Inflector::pluralize($otherModelClass);
|
||||
$otherControllerPath = Inflector::underscore($otherControllerName);
|
||||
|
@ -95,13 +95,13 @@ foreach ($hasOne as $assocName => $assocData):
|
|||
?>
|
||||
<div class="related">
|
||||
<h3><?php echo sprintf(__("Related %s", true), $otherPluralHumanName);?></h3>
|
||||
<?php if(!empty(${$singularVar}[$assocName])):?>
|
||||
<?php if (!empty(${$singularVar}[$assocName])):?>
|
||||
<dl>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach($otherFields as $field) {
|
||||
foreach ($otherFields as $field) {
|
||||
$class = null;
|
||||
if($i++ % 2 == 0) {
|
||||
if ($i++ % 2 == 0) {
|
||||
$class = ' class="altrow"';
|
||||
}
|
||||
echo "\t\t<dt{$class}>".Inflector::humanize($field['name'])."</dt>\n";
|
||||
|
@ -121,7 +121,7 @@ endforeach;
|
|||
|
||||
$relations = array_merge($hasMany, $hasAndBelongsToMany);
|
||||
$i = 0;
|
||||
foreach($relations as $assocName => $assocData):
|
||||
foreach ($relations as $assocName => $assocData):
|
||||
$otherModelKey = Inflector::underscore($assocData['className']);
|
||||
$otherModelObj =& ClassRegistry::getObject($otherModelKey);
|
||||
$otherControllerPath = Inflector::pluralize($otherModelKey);
|
||||
|
@ -138,11 +138,11 @@ foreach($relations as $assocName => $assocData):
|
|||
|
||||
|
||||
|
||||
<?php if(!empty(${$singularVar}[$assocName])):?>
|
||||
<?php if (!empty(${$singularVar}[$assocName])):?>
|
||||
<table cellpadding = "0" cellspacing = "0">
|
||||
<tr>
|
||||
<?php
|
||||
foreach($otherFields as $field) {
|
||||
foreach ($otherFields as $field) {
|
||||
echo "\t\t<th>".Inflector::humanize($field['name'])."</th>\n";
|
||||
}
|
||||
?>
|
||||
|
@ -150,14 +150,14 @@ foreach($relations as $assocName => $assocData):
|
|||
</tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach(${$singularVar}[$assocName] as ${$otherSingularVar}):
|
||||
foreach (${$singularVar}[$assocName] as ${$otherSingularVar}):
|
||||
$class = null;
|
||||
if($i++ % 2 == 0) {
|
||||
if ($i++ % 2 == 0) {
|
||||
$class = ' class=\"altrow\"';
|
||||
}
|
||||
echo "\t\t<tr{$class}>\n";
|
||||
|
||||
foreach($otherFields as $field) {
|
||||
foreach ($otherFields as $field) {
|
||||
echo "\t\t\t<td>".${$otherSingularVar}[$field['name']]."</td>\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ class ThemeView extends View {
|
|||
parent::__construct($controller);
|
||||
|
||||
$this->theme =& $controller->theme;
|
||||
if(!empty($this->theme)) {
|
||||
if(is_dir(WWW_ROOT . 'themed' . DS . $this->theme)){
|
||||
if (!empty($this->theme)) {
|
||||
if (is_dir(WWW_ROOT . 'themed' . DS . $this->theme)){
|
||||
$this->themeWeb = 'themed/'. $this->theme .'/';
|
||||
}
|
||||
$this->themeElement = 'themed'. DS . $this->theme . DS .'elements'. DS;
|
||||
|
@ -79,7 +79,7 @@ class ThemeView extends View {
|
|||
*/
|
||||
function error($code, $name, $message) {
|
||||
$file = VIEWS . $this->themeLayout.'error'.$this->ext;
|
||||
if(!file_exists($file)) {
|
||||
if (!file_exists($file)) {
|
||||
$file = LAYOUTS.'error'.$this->ext;
|
||||
}
|
||||
header ("HTTP/1.0 {$code} {$name}");
|
||||
|
@ -96,7 +96,7 @@ class ThemeView extends View {
|
|||
* @return unknown
|
||||
*/
|
||||
function renderElement($name, $params = array()) {
|
||||
if(isset($params['plugin'])) {
|
||||
if (isset($params['plugin'])) {
|
||||
$this->plugin = $params['plugin'];
|
||||
$this->pluginPath = 'plugins' . DS . $this->plugin . DS;
|
||||
$this->pluginPaths = array(
|
||||
|
@ -109,34 +109,34 @@ class ThemeView extends View {
|
|||
$viewPaths = am($this->pluginPaths, $paths->viewPaths);
|
||||
|
||||
$file = null;
|
||||
foreach($viewPaths as $path) {
|
||||
if(file_exists($path . $this->themeElement . $name . $this->ext)) {
|
||||
foreach ($viewPaths as $path) {
|
||||
if (file_exists($path . $this->themeElement . $name . $this->ext)) {
|
||||
$file = $path . $this->themeElement . $name . $this->ext;
|
||||
break;
|
||||
} else if(file_exists($path . $this->themeElement . $name . '.thtml')) {
|
||||
} elseif (file_exists($path . $this->themeElement . $name . '.thtml')) {
|
||||
$file = $path . $this->themeElement . $name . '.thtml';
|
||||
break;
|
||||
} else if(file_exists($path . 'elements' . DS . $name . $this->ext)) {
|
||||
} elseif (file_exists($path . 'elements' . DS . $name . $this->ext)) {
|
||||
$file = $path . 'elements' . DS . $name . $this->ext;
|
||||
break;
|
||||
} else if(file_exists($path . 'elements' . DS . $name . '.thtml')) {
|
||||
} elseif (file_exists($path . 'elements' . DS . $name . '.thtml')) {
|
||||
$file = $path . 'elements' . DS . $name . '.thtml';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_null($file)) {
|
||||
if (!is_null($file)) {
|
||||
$params = array_merge_recursive($params, $this->loaded);
|
||||
return $this->_render($file, array_merge($this->viewVars, $params), false);
|
||||
}
|
||||
|
||||
if(!is_null($this->pluginPath)) {
|
||||
if (!is_null($this->pluginPath)) {
|
||||
$file = APP . $this->pluginPath . $this->themeElement . $name . $this->ext;
|
||||
} else {
|
||||
$file = VIEWS . $this->themeElement . $name . $this->ext;
|
||||
}
|
||||
|
||||
if(Configure::read() > 0) {
|
||||
if (Configure::read() > 0) {
|
||||
return "Not Found: " . $file;
|
||||
}
|
||||
}
|
||||
|
@ -169,24 +169,24 @@ class ThemeView extends View {
|
|||
$viewPaths = am($this->pluginPaths, $paths->viewPaths);
|
||||
|
||||
$name = $this->viewPath . DS . $this->subDir . $type . $action;
|
||||
foreach($viewPaths as $path) {
|
||||
if(file_exists($path . $this->themePath . $name . $this->ext)) {
|
||||
foreach ($viewPaths as $path) {
|
||||
if (file_exists($path . $this->themePath . $name . $this->ext)) {
|
||||
return $path . $this->themePath . $name . $this->ext;
|
||||
} else if(file_exists($path . $this->themePath . $name . '.thtml')) {
|
||||
} elseif (file_exists($path . $this->themePath . $name . '.thtml')) {
|
||||
return $path . $this->themePath . $name . '.thtml';
|
||||
} else if(file_exists($path . $name . $this->ext)) {
|
||||
} elseif (file_exists($path . $name . $this->ext)) {
|
||||
return $path . $name . $this->ext;
|
||||
} else if(file_exists($path . $name . '.thtml')) {
|
||||
} elseif (file_exists($path . $name . '.thtml')) {
|
||||
return $path . $name . '.thtml';
|
||||
}
|
||||
}
|
||||
|
||||
if ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . $type . $action . '.ctp')) {
|
||||
return $viewFileName;
|
||||
} elseif($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.ctp')) {
|
||||
} elseif ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.ctp')) {
|
||||
return $viewFileName;
|
||||
} else {
|
||||
if(!is_null($this->pluginPath)) {
|
||||
if (!is_null($this->pluginPath)) {
|
||||
$viewFileName = APP . $this->pluginPath . $this->themePath . $name . $this->ext;
|
||||
} else {
|
||||
$viewFileName = VIEWS . $this->themePath . $name . $this->ext;
|
||||
|
@ -208,7 +208,7 @@ class ThemeView extends View {
|
|||
$type = null;
|
||||
}
|
||||
|
||||
if(!is_null($this->layoutPath)) {
|
||||
if (!is_null($this->layoutPath)) {
|
||||
$type = $this->layoutPath . DS;
|
||||
}
|
||||
|
||||
|
@ -216,19 +216,19 @@ class ThemeView extends View {
|
|||
$viewPaths = am($this->pluginPaths, $paths->viewPaths);
|
||||
|
||||
$name = $this->subDir . $type . $this->layout;
|
||||
foreach($viewPaths as $path) {
|
||||
if(file_exists($path . $this->themeLayout . $name . $this->ext)) {
|
||||
foreach ($viewPaths as $path) {
|
||||
if (file_exists($path . $this->themeLayout . $name . $this->ext)) {
|
||||
return $path . $this->themeLayout . $name . $this->ext;
|
||||
} else if(file_exists($path . $this->themeLayout . $name . '.thtml')) {
|
||||
} elseif (file_exists($path . $this->themeLayout . $name . '.thtml')) {
|
||||
return $path . $this->themeLayout . $name . '.thtml';
|
||||
} else if(file_exists($path . 'layouts' . DS . $name . $this->ext)) {
|
||||
} elseif (file_exists($path . 'layouts' . DS . $name . $this->ext)) {
|
||||
return $path . 'layouts' . DS . $name . $this->ext;
|
||||
} else if(file_exists($path . 'layouts' . DS . $name . '.thtml')) {
|
||||
} elseif (file_exists($path . 'layouts' . DS . $name . '.thtml')) {
|
||||
return $path . 'layouts' . DS . $name . '.thtml';
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_null($this->pluginPath)) {
|
||||
if (!is_null($this->pluginPath)) {
|
||||
$layoutFileName = APP . $this->pluginPath . 'views' . DS . $this->themeLayout . $name . $this->ext;
|
||||
} else {
|
||||
$layoutFileName = VIEWS . $this->themeLayout . $name . $this->ext;
|
||||
|
@ -238,11 +238,11 @@ class ThemeView extends View {
|
|||
if (empty($default) && !empty($type)) {
|
||||
$default = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . 'default.ctp');
|
||||
}
|
||||
if(empty($default)) {
|
||||
if (empty($default)) {
|
||||
$default = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $this->layout . '.ctp');
|
||||
}
|
||||
|
||||
if(!empty($default)) {
|
||||
if (!empty($default)) {
|
||||
return $default;
|
||||
}
|
||||
return $layoutFileName;
|
||||
|
|
|
@ -282,7 +282,7 @@ class View extends Object {
|
|||
* @return View
|
||||
*/
|
||||
function __construct(&$controller) {
|
||||
if(is_object($controller)) {
|
||||
if (is_object($controller)) {
|
||||
$count = count($this->__passedVars);
|
||||
for ($j = 0; $j < $count; $j++) {
|
||||
$var = $this->__passedVars[$j];
|
||||
|
@ -370,7 +370,7 @@ class View extends Object {
|
|||
*/
|
||||
function renderElement($name, $params = array(), $loadHelpers = false) {
|
||||
|
||||
if(isset($params['plugin'])) {
|
||||
if (isset($params['plugin'])) {
|
||||
$this->plugin = $params['plugin'];
|
||||
$this->pluginPath = 'plugins' . DS . $this->plugin . DS;
|
||||
$this->pluginPaths = array(
|
||||
|
@ -383,28 +383,28 @@ class View extends Object {
|
|||
$viewPaths = am($this->pluginPaths, $paths->viewPaths);
|
||||
|
||||
$file = null;
|
||||
foreach($viewPaths as $path) {
|
||||
if(file_exists($path . 'elements' . DS . $name . $this->ext)) {
|
||||
foreach ($viewPaths as $path) {
|
||||
if (file_exists($path . 'elements' . DS . $name . $this->ext)) {
|
||||
$file = $path . 'elements' . DS . $name . $this->ext;
|
||||
break;
|
||||
} else if(file_exists($path . 'elements' . DS . $name . '.thtml')) {
|
||||
} elseif (file_exists($path . 'elements' . DS . $name . '.thtml')) {
|
||||
$file = $path . 'elements' . DS . $name . '.thtml';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_null($file)) {
|
||||
if (!is_null($file)) {
|
||||
$params = array_merge_recursive($params, $this->loaded);
|
||||
return $this->_render($file, array_merge($this->viewVars, $params), $loadHelpers);
|
||||
}
|
||||
|
||||
if(!is_null($this->pluginPath)) {
|
||||
if (!is_null($this->pluginPath)) {
|
||||
$file = APP . $this->pluginPath . 'views' . DS . 'elements' . DS . $name . $this->ext;
|
||||
} else {
|
||||
$file = VIEWS . 'elements' . DS . $name . $this->ext;
|
||||
}
|
||||
|
||||
if(Configure::read() > 0) {
|
||||
if (Configure::read() > 0) {
|
||||
return "Not Found: " . $file;
|
||||
}
|
||||
}
|
||||
|
@ -418,19 +418,19 @@ class View extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function element($name, $params = array()) {
|
||||
if(in_array('cache', array_keys($params))) {
|
||||
if (in_array('cache', array_keys($params))) {
|
||||
$expires = '+1 day';
|
||||
if($params['cache'] !== true) {
|
||||
if ($params['cache'] !== true) {
|
||||
$expires = $params['cache'];
|
||||
}
|
||||
if($expires) {
|
||||
if ($expires) {
|
||||
$plugin = null;
|
||||
if(isset($params['plugin'])) {
|
||||
if (isset($params['plugin'])) {
|
||||
$plugin = $params['plugin'];
|
||||
}
|
||||
$cacheFile = 'element_' . $plugin .'_' . convertSlash($name);
|
||||
$cache = cache('views' . DS . $cacheFile, null, $expires);
|
||||
if($cache) {
|
||||
if ($cache) {
|
||||
return $cache;
|
||||
} else {
|
||||
$element = $this->renderElement($name, $params);
|
||||
|
@ -585,7 +585,7 @@ class View extends Object {
|
|||
return false;
|
||||
}
|
||||
|
||||
foreach($data as $name => $value) {
|
||||
foreach ($data as $name => $value) {
|
||||
if ($name == 'title') {
|
||||
$this->pageTitle = $value;
|
||||
} else {
|
||||
|
@ -646,20 +646,20 @@ class View extends Object {
|
|||
$viewPaths = am($this->pluginPaths, $paths->viewPaths);
|
||||
|
||||
$name = $this->viewPath . DS . $this->subDir . $type . $action;
|
||||
foreach($viewPaths as $path) {
|
||||
if(file_exists($path . $name . $this->ext)) {
|
||||
foreach ($viewPaths as $path) {
|
||||
if (file_exists($path . $name . $this->ext)) {
|
||||
return $path . $name . $this->ext;
|
||||
} else if(file_exists($path . $name . '.thtml')) {
|
||||
} elseif (file_exists($path . $name . '.thtml')) {
|
||||
return $path . $name . '.thtml';
|
||||
}
|
||||
}
|
||||
|
||||
if ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . $type . $action . '.ctp')) {
|
||||
return $viewFileName;
|
||||
} elseif($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.ctp')) {
|
||||
} elseif ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.ctp')) {
|
||||
return $viewFileName;
|
||||
} else {
|
||||
if(!is_null($this->pluginPath)) {
|
||||
if (!is_null($this->pluginPath)) {
|
||||
$viewFileName = APP . $this->pluginPath . 'views' . DS . $name . $this->ext;
|
||||
} else {
|
||||
$viewFileName = VIEWS . $name . $this->ext;
|
||||
|
@ -682,7 +682,7 @@ class View extends Object {
|
|||
$type = null;
|
||||
}
|
||||
|
||||
if(!is_null($this->layoutPath)) {
|
||||
if (!is_null($this->layoutPath)) {
|
||||
$type = $this->layoutPath . DS;
|
||||
}
|
||||
|
||||
|
@ -690,15 +690,15 @@ class View extends Object {
|
|||
$viewPaths = am($this->pluginPaths, $paths->viewPaths);
|
||||
|
||||
$name = $this->subDir . $type . $this->layout;
|
||||
foreach($viewPaths as $path) {
|
||||
if(file_exists($path . 'layouts' . DS . $name . $this->ext)) {
|
||||
foreach ($viewPaths as $path) {
|
||||
if (file_exists($path . 'layouts' . DS . $name . $this->ext)) {
|
||||
return $path . 'layouts' . DS . $name . $this->ext;
|
||||
} else if(file_exists($path . 'layouts' . DS . $name . '.thtml')) {
|
||||
} elseif (file_exists($path . 'layouts' . DS . $name . '.thtml')) {
|
||||
return $path . 'layouts' . DS . $name . '.thtml';
|
||||
}
|
||||
}
|
||||
|
||||
if(!is_null($this->pluginPath)) {
|
||||
if (!is_null($this->pluginPath)) {
|
||||
$layoutFileName = APP . $this->pluginPath . 'views' . DS . 'layouts' . DS . $name . $this->ext;
|
||||
} else {
|
||||
$layoutFileName = VIEWS . 'layouts' . DS . $name . $this->ext;
|
||||
|
@ -708,11 +708,11 @@ class View extends Object {
|
|||
if (empty($default) && !empty($type)) {
|
||||
$default = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . 'default.ctp');
|
||||
}
|
||||
if(empty($default)) {
|
||||
if (empty($default)) {
|
||||
$default = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $this->layout . '.ctp');
|
||||
}
|
||||
|
||||
if(!empty($default)) {
|
||||
if (!empty($default)) {
|
||||
return $default;
|
||||
}
|
||||
return $layoutFileName;
|
||||
|
@ -732,7 +732,7 @@ class View extends Object {
|
|||
$loadedHelpers = array();
|
||||
$loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
|
||||
|
||||
foreach(array_keys($loadedHelpers) as $helper) {
|
||||
foreach (array_keys($loadedHelpers) as $helper) {
|
||||
$replace = strtolower(substr($helper, 0, 1));
|
||||
$camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);
|
||||
|
||||
|
@ -740,7 +740,7 @@ class View extends Object {
|
|||
|
||||
if (is_array(${$camelBackedHelper}->helpers) && !empty(${$camelBackedHelper}->helpers)) {
|
||||
$subHelpers = ${$camelBackedHelper}->helpers;
|
||||
foreach($subHelpers as $subHelper) {
|
||||
foreach ($subHelpers as $subHelper) {
|
||||
${$camelBackedHelper}->{$subHelper} =& $loadedHelpers[$subHelper];
|
||||
}
|
||||
}
|
||||
|
@ -814,10 +814,10 @@ class View extends Object {
|
|||
function &_loadHelpers(&$loaded, $helpers) {
|
||||
$helpers[] = 'Session';
|
||||
|
||||
foreach($helpers as $helper) {
|
||||
foreach ($helpers as $helper) {
|
||||
$parts = preg_split('/\/|\./', $helper);
|
||||
|
||||
if(count($parts) === 1) {
|
||||
if (count($parts) === 1) {
|
||||
$plugin = $this->plugin;
|
||||
} else {
|
||||
$plugin = Inflector::underscore($parts['0']);
|
||||
|
@ -892,7 +892,7 @@ class View extends Object {
|
|||
unset ($out);
|
||||
return;
|
||||
} else {
|
||||
if($this->layout === 'xml'){
|
||||
if ($this->layout === 'xml'){
|
||||
header('Content-type: text/xml');
|
||||
}
|
||||
$out = str_replace('<!--cachetime:'.$match['1'].'-->', '', $out);
|
||||
|
@ -915,7 +915,7 @@ class View extends Object {
|
|||
$errorAction = 'missingView';
|
||||
}
|
||||
|
||||
foreach(array($this->name, 'errors') as $viewDir) {
|
||||
foreach (array($this->name, 'errors') as $viewDir) {
|
||||
$errorAction = Inflector::underscore($errorAction);
|
||||
if (file_exists(VIEWS . $viewDir . DS . $errorAction . $this->ext)) {
|
||||
$missingViewFileName = VIEWS . $viewDir . DS . $errorAction . $this->ext;
|
||||
|
|
|
@ -205,7 +205,7 @@ class XMLNode extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function &first() {
|
||||
if(isset($this->children[0])) {
|
||||
if (isset($this->children[0])) {
|
||||
return $this->children[0];
|
||||
} else {
|
||||
return null;
|
||||
|
@ -218,7 +218,7 @@ class XMLNode extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function &last() {
|
||||
if(count($this->children) > 0) {
|
||||
if (count($this->children) > 0) {
|
||||
return $this->children[count($this->children) - 1];
|
||||
} else {
|
||||
return null;
|
||||
|
@ -234,15 +234,15 @@ class XMLNode extends Object {
|
|||
function &child($id) {
|
||||
$null = null;
|
||||
|
||||
if(is_int($id)) {
|
||||
if(isset($this->children[$id])) {
|
||||
if (is_int($id)) {
|
||||
if (isset($this->children[$id])) {
|
||||
return $this->children[$id];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} elseif(is_string($id)) {
|
||||
for($i = 0; $i < count($this->children); $i++) {
|
||||
if($this->children[$i]->name == $id) {
|
||||
} elseif (is_string($id)) {
|
||||
for ($i = 0; $i < count($this->children); $i++) {
|
||||
if ($this->children[$i]->name == $id) {
|
||||
return $this->children[$i];
|
||||
}
|
||||
}
|
||||
|
@ -261,8 +261,8 @@ class XMLNode extends Object {
|
|||
function children($name) {
|
||||
$nodes = array();
|
||||
$count = count($this->children);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
if($this->children[$i]->name == $name) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($this->children[$i]->name == $name) {
|
||||
$nodes[] =& $this->children[$i];
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ class XMLNode extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function hasChildren() {
|
||||
if(is_array($this->children) && count($this->children) > 0) {
|
||||
if (is_array($this->children) && count($this->children) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -331,36 +331,36 @@ class XMLNode extends Object {
|
|||
*/
|
||||
function toString() {
|
||||
$d = '';
|
||||
if($this->name != '') {
|
||||
if ($this->name != '') {
|
||||
$d .= '<' . $this->name;
|
||||
if(is_array($this->attributes) && count($this->attributes) > 0) {
|
||||
foreach($this->attributes as $key => $val) {
|
||||
if (is_array($this->attributes) && count($this->attributes) > 0) {
|
||||
foreach ($this->attributes as $key => $val) {
|
||||
$d .= " $key=\"$val\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$this->hasChildren() && empty($this->value)) {
|
||||
if($this->name != '') {
|
||||
if (!$this->hasChildren() && empty($this->value)) {
|
||||
if ($this->name != '') {
|
||||
$d .= " />\n";
|
||||
}
|
||||
} else {
|
||||
if($this->name != '') {
|
||||
if ($this->name != '') {
|
||||
$d .= ">";
|
||||
}
|
||||
if($this->hasChildren()) {
|
||||
if ($this->hasChildren()) {
|
||||
if (is_string($this->value) || empty($this->value)) {
|
||||
if (!empty($this->value)) {
|
||||
$d .= $this->value;
|
||||
}
|
||||
$count = count($this->children);
|
||||
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$d .= $this->children[$i]->toString();
|
||||
}
|
||||
} elseif (is_array($this->value)) {
|
||||
$count = count($this->value);
|
||||
for($i = 0; $i < $count; $i++) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$d .= $this->value[$i];
|
||||
if (isset($this->children[$i])) {
|
||||
$d .= $this->children[$i]->toString();
|
||||
|
@ -379,7 +379,7 @@ class XMLNode extends Object {
|
|||
$d .= $this->value;
|
||||
}
|
||||
|
||||
if($this->name != '' && ($this->hasChildren() || !empty($this->value))) {
|
||||
if ($this->name != '' && ($this->hasChildren() || !empty($this->value))) {
|
||||
$d .= "</" . $this->name . ">\n";
|
||||
}
|
||||
}
|
||||
|
@ -403,8 +403,8 @@ class XMLNode extends Object {
|
|||
*/
|
||||
function __killParent($recursive = true) {
|
||||
unset($this->__parent);
|
||||
if($recursive && $this->hasChildren()) {
|
||||
for($i = 0; $i < count($this->children); $i++) {
|
||||
if ($recursive && $this->hasChildren()) {
|
||||
for ($i = 0; $i < count($this->children); $i++) {
|
||||
$this->children[$i]->__killParent(true);
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ class XML extends XMLNode {
|
|||
|
||||
$this->children = array();
|
||||
|
||||
if($input != null) {
|
||||
if ($input != null) {
|
||||
$vars = null;
|
||||
if (is_string($input)) {
|
||||
$this->load($input);
|
||||
|
@ -529,12 +529,12 @@ class XML extends XMLNode {
|
|||
|
||||
if (is_string($in)) {
|
||||
|
||||
if(strstr($in, "<")) {
|
||||
if (strstr($in, "<")) {
|
||||
// Input is raw xml data
|
||||
$this->__rawData = $in;
|
||||
} else {
|
||||
// Input is an xml file
|
||||
if(strpos($in, '://') || file_exists($in)) {
|
||||
if (strpos($in, '://') || file_exists($in)) {
|
||||
$this->__rawData = @file_get_contents($in);
|
||||
if ($this->__rawData == null) {
|
||||
$this->error("XML file $in is empty or could not be read (possible permissions error).");
|
||||
|
@ -572,10 +572,10 @@ class XML extends XMLNode {
|
|||
$tmpXML = new XMLNode();
|
||||
$tmpXML->name = $data['tag'];
|
||||
|
||||
if(isset($data['value'])) {
|
||||
if (isset($data['value'])) {
|
||||
$tmpXML->value = $data['value'];
|
||||
}
|
||||
if(isset($data['attributes'])) {
|
||||
if (isset($data['attributes'])) {
|
||||
$tmpXML->attributes = $data['attributes'];
|
||||
}
|
||||
|
||||
|
@ -593,10 +593,10 @@ class XML extends XMLNode {
|
|||
$tmpXML = new XMLNode();
|
||||
$tmpXML->name = $data['tag'];
|
||||
|
||||
if(isset($data['value'])) {
|
||||
if (isset($data['value'])) {
|
||||
$tmpXML->value = $data['value'];
|
||||
}
|
||||
if(isset($data['attributes'])) {
|
||||
if (isset($data['attributes'])) {
|
||||
$tmpXML->attributes = $data['attributes'];
|
||||
}
|
||||
|
||||
|
@ -653,7 +653,7 @@ class XML extends XMLNode {
|
|||
* @access public
|
||||
*/
|
||||
function error($msg, $code = 0, $line = 0) {
|
||||
if(DEBUG) {
|
||||
if (DEBUG) {
|
||||
echo $msg . " " . $code . " " . $line;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -627,8 +627,8 @@ class DboSourceTest extends UnitTestCase {
|
|||
|
||||
$queryData = array();
|
||||
|
||||
foreach($this->model->Category2->__associations as $type) {
|
||||
foreach($this->model->Category2->{$type} as $assoc => $assocData) {
|
||||
foreach ($this->model->Category2->__associations as $type) {
|
||||
foreach ($this->model->Category2->{$type} as $assoc => $assocData) {
|
||||
$linkModel =& $this->model->Category2->{$assoc};
|
||||
$external = isset($assocData['external']);
|
||||
|
||||
|
@ -1279,11 +1279,11 @@ class DboSourceTest extends UnitTestCase {
|
|||
}
|
||||
|
||||
function _buildRelatedModels(&$model) {
|
||||
foreach($model->__associations as $type) {
|
||||
foreach($model->{$type} as $assoc => $assocData) {
|
||||
foreach ($model->__associations as $type) {
|
||||
foreach ($model->{$type} as $assoc => $assocData) {
|
||||
if (is_string($assocData)) {
|
||||
$className = $assocData;
|
||||
} else if (isset($assocData['className'])) {
|
||||
} elseif (isset($assocData['className'])) {
|
||||
$className = $assocData['className'];
|
||||
}
|
||||
$model->$className = new $className();
|
||||
|
|
|
@ -125,7 +125,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
$classRegistry =& ClassRegistry::getInstance();
|
||||
$models = array();
|
||||
|
||||
foreach($classRegistry->__map as $key => $name) {
|
||||
foreach ($classRegistry->__map as $key => $name) {
|
||||
$object =& $classRegistry->getObject(Inflector::camelize($key));
|
||||
if (is_subclass_of($object, 'Model') && ((is_array($params['fixturize']) && in_array($object->name, $params['fixturize'])) || $params['fixturize'] === true)) {
|
||||
$models[$object->name] = array (
|
||||
|
@ -143,7 +143,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
'drop' => array()
|
||||
);
|
||||
|
||||
foreach($models as $model) {
|
||||
foreach ($models as $model) {
|
||||
$fixture =& new CakeTestFixture($this->db);
|
||||
|
||||
$fixture->name = $model['model'] . 'Test';
|
||||
|
@ -167,19 +167,19 @@ class CakeTestCase extends UnitTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
foreach($this->_queries['create'] as $query) {
|
||||
foreach ($this->_queries['create'] as $query) {
|
||||
if (isset($query) && $query !== false) {
|
||||
$this->db->_execute($query);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->_queries['insert'] as $query) {
|
||||
foreach ($this->_queries['insert'] as $query) {
|
||||
if (isset($query) && $query !== false) {
|
||||
$this->db->_execute($query);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($models as $model) {
|
||||
foreach ($models as $model) {
|
||||
$object =& $classRegistry->getObject($model['key']);
|
||||
|
||||
if ($object !== false) {
|
||||
|
@ -198,7 +198,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
*/
|
||||
function endController(&$controller, $params = array()) {
|
||||
if (isset($this->db) && isset($this->_queries) && !empty($this->_queries) && !empty($this->_queries['drop'])) {
|
||||
foreach($this->_queries['drop'] as $query) {
|
||||
foreach ($this->_queries['drop'] as $query) {
|
||||
if (isset($query) && $query !== false) {
|
||||
$this->db->_execute($query);
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
|
||||
$result = array();
|
||||
|
||||
foreach($viewVars as $var) {
|
||||
foreach ($viewVars as $var) {
|
||||
$result[$var] = $view->getVar($var);
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
|
||||
$classRegistry =& ClassRegistry::getInstance();
|
||||
$keys = array_keys($classRegistry->__objects);
|
||||
foreach($keys as $key) {
|
||||
foreach ($keys as $key) {
|
||||
$key = Inflector::camelize($key);
|
||||
$classRegistry->removeObject($key);
|
||||
}
|
||||
|
@ -310,11 +310,11 @@ class CakeTestCase extends UnitTestCase {
|
|||
|
||||
// Create records
|
||||
if (isset($this->_fixtures) && isset($this->db) && !in_array(low($method), array('start', 'end'))) {
|
||||
foreach($this->_fixtures as $fixture) {
|
||||
foreach ($this->_fixtures as $fixture) {
|
||||
$inserts = $fixture->insert();
|
||||
|
||||
if (isset($inserts) && !empty($inserts)) {
|
||||
foreach($inserts as $query) {
|
||||
foreach ($inserts as $query) {
|
||||
if (isset($query) && $query !== false) {
|
||||
$this->db->_execute($query);
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
*/
|
||||
function start() {
|
||||
if (isset($this->_fixtures) && isset($this->db)) {
|
||||
foreach($this->_fixtures as $fixture) {
|
||||
foreach ($this->_fixtures as $fixture) {
|
||||
$query = $fixture->create();
|
||||
|
||||
if (isset($query) && $query !== false) {
|
||||
|
@ -350,7 +350,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
*/
|
||||
function end() {
|
||||
if (isset($this->_fixtures) && isset($this->db)) {
|
||||
foreach(array_reverse($this->_fixtures) as $fixture) {
|
||||
foreach (array_reverse($this->_fixtures) as $fixture) {
|
||||
$query = $fixture->drop();
|
||||
|
||||
if (isset($query) && $query !== false) {
|
||||
|
@ -368,7 +368,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
*/
|
||||
function after($method) {
|
||||
if (isset($this->_fixtures) && isset($this->db) && !in_array(low($method), array('start', 'end'))) {
|
||||
foreach($this->_fixtures as $fixture) {
|
||||
foreach ($this->_fixtures as $fixture) {
|
||||
$query = $fixture->truncate();
|
||||
|
||||
if (isset($query) && $query !== false) {
|
||||
|
@ -451,7 +451,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
|
||||
$this->_fixtures = array();
|
||||
|
||||
foreach($this->fixtures as $index => $fixture) {
|
||||
foreach ($this->fixtures as $index => $fixture) {
|
||||
$fixtureFile = null;
|
||||
|
||||
if (strpos($fixture, 'core.') === 0) {
|
||||
|
@ -459,7 +459,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
$fixturePaths = array(
|
||||
CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'tests' . DS . 'fixtures'
|
||||
);
|
||||
} else if (strpos($fixture, 'app.') === 0) {
|
||||
} elseif (strpos($fixture, 'app.') === 0) {
|
||||
$fixture = substr($fixture, strlen('app.'));
|
||||
$fixturePaths = array(
|
||||
APP . 'tests' . DS . 'fixtures'
|
||||
|
@ -471,7 +471,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
foreach($fixturePaths as $path) {
|
||||
foreach ($fixturePaths as $path) {
|
||||
if (is_readable($path . DS . $fixture . '_fixture.php')) {
|
||||
$fixtureFile = $path . DS . $fixture . '_fixture.php';
|
||||
break;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue