diff --git a/app/webroot/js/vendors.php b/app/webroot/js/vendors.php index ab21ea9df..a927b68ce 100644 --- a/app/webroot/js/vendors.php +++ b/app/webroot/js/vendors.php @@ -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); } diff --git a/app/webroot/test.php b/app/webroot/test.php index 8889c08bd..e3861086f 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -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'; diff --git a/cake/basics.php b/cake/basics.php index 12838ae90..9aaf4b699 100644 --- a/cake/basics.php +++ b/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; diff --git a/cake/bootstrap.php b/cake/bootstrap.php index b12b09aef..d0f898109 100644 --- a/cake/bootstrap.php +++ b/cake/bootstrap.php @@ -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); diff --git a/cake/config/paths.php b/cake/config/paths.php index fd97412a5..91cb2d5fa 100644 --- a/cake/config/paths.php +++ b/cake/config/paths.php @@ -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'); } /** diff --git a/cake/console/cake.php b/cake/console/cake.php index 6fd24d12b..9d5b1bdb8 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -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) { diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php index 8cf0b1ef8..6e54b4ee2 100644 --- a/cake/console/libs/acl.php +++ b/cake/console/libs/acl.php @@ -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') { diff --git a/cake/console/libs/api.php b/cake/console/libs/api.php index ae1bbc2b4..62862dc91 100644 --- a/cake/console/libs/api.php +++ b/cake/console/libs/api.php @@ -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'; diff --git a/cake/console/libs/bake.php b/cake/console/libs/bake.php index 085068683..1642f4ba4 100644 --- a/cake/console/libs/bake.php +++ b/cake/console/libs/bake.php @@ -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(); diff --git a/cake/console/libs/console.php b/cake/console/libs/console.php index 4dcc302da..0ca0fef25 100644 --- a/cake/console/libs/console.php +++ b/cake/console/libs/console.php @@ -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"); diff --git a/cake/console/libs/extract.php b/cake/console/libs/extract.php index 66483c9f2..22deb6665 100644 --- a/cake/console/libs/extract.php +++ b/cake/console/libs/extract.php @@ -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]); } } diff --git a/cake/console/libs/shell.php b/cake/console/libs/shell.php index 9888fa207..e77e32a27 100644 --- a/cake/console/libs/shell.php +++ b/cake/console/libs/shell.php @@ -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(); diff --git a/cake/console/libs/tasks/controller.php b/cake/console/libs/tasks/controller.php index 0b8b6afeb..414418475 100644 --- a/cake/console/libs/tasks/controller.php +++ b/cake/console/libs/tasks/controller.php @@ -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(); diff --git a/cake/console/libs/tasks/db_config.php b/cake/console/libs/tasks/db_config.php index df44f7f08..6296bbfa8 100644 --- a/cake/console/libs/tasks/db_config.php +++ b/cake/console/libs/tasks/db_config.php @@ -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 = " '{$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"; diff --git a/cake/console/libs/tasks/model.php b/cake/console/libs/tasks/model.php index 30f5d9bf1..8ee861277 100644 --- a/cake/console/libs/tasks/model.php +++ b/cake/console/libs/tasks/model.php @@ -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); } diff --git a/cake/console/libs/tasks/project.php b/cake/console/libs/tasks/project.php index 11bf350d6..e9bb9c796 100644 --- a/cake/console/libs/tasks/project.php +++ b/cake/console/libs/tasks/project.php @@ -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; diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php index b42043a28..371ba65b4 100644 --- a/cake/console/libs/tasks/view.php +++ b/cake/console/libs/tasks/view.php @@ -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); diff --git a/cake/console/libs/templates/skel/views/layouts/default.ctp b/cake/console/libs/templates/skel/views/layouts/default.ctp index 8ecc8bdec..f9294391f 100644 --- a/cake/console/libs/templates/skel/views/layouts/default.ctp +++ b/cake/console/libs/templates/skel/views/layouts/default.ctp @@ -45,7 +45,7 @@
check('Message.flash')): + if ($session->check('Message.flash')): $session->flash(); endif; ?> diff --git a/cake/console/libs/templates/skel/views/layouts/flash.ctp b/cake/console/libs/templates/skel/views/layouts/flash.ctp index fc8293d10..b39b71171 100644 --- a/cake/console/libs/templates/skel/views/layouts/flash.ctp +++ b/cake/console/libs/templates/skel/views/layouts/flash.ctp @@ -30,7 +30,7 @@ <?php echo $page_title?> charset(); ?> - +