diff --git a/app/webroot/index.php b/app/webroot/index.php index f4ba293f4..67c5782b4 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -78,8 +78,9 @@ trigger_error("Can't find CakePHP core. Check the value of CAKE_CORE_INCLUDE_PATH in app/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { + return; } else { - $Dispatcher=new Dispatcher(); + $Dispatcher = new Dispatcher(); $Dispatcher->dispatch($url); } if (Configure::read() > 0) { diff --git a/app/webroot/test.php b/app/webroot/test.php index 4ce4e70ad..cc6dc6700 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -74,10 +74,11 @@ if (empty( $_GET['output'])) { $_GET['output'] = 'html'; } -if (!defined('BASE_URL')) { - $dispatch =& new Dispatcher(); - define('BASE_URL', $dispatch->baseUrl()); -} +$dispatch =& new Dispatcher(); +$dispatch->base = env('SCRIPT_NAME'); +$dispatch->baseUrl(); +define('BASE', $dispatch->webroot); + /** * * Used to determine output to display @@ -179,7 +180,7 @@ if (!vendor('simpletest' . DS . 'reporter')) { function CakePHPTestHeader() { switch (CAKE_TEST_OUTPUT) { case CAKE_TEST_OUTPUT_HTML: - $baseUrl = BASE_URL; + $baseUrl = BASE; $characterSet = 'ISO-8859-1'; include CAKE . 'tests' . DS . 'lib' . DS . 'header.php'; break; @@ -203,7 +204,7 @@ if (!vendor('simpletest' . DS . 'reporter')) { function CakePHPTestSuiteFooter() { switch ( CAKE_TEST_OUTPUT) { case CAKE_TEST_OUTPUT_HTML: - $baseUrl = BASE_URL; + $baseUrl = BASE; include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php'; break; } @@ -240,4 +241,4 @@ if (!vendor('simpletest' . DS . 'reporter')) { CakePHPTestGroupTestList(); } CakePHPTestSuiteFooter(); -?> \ No newline at end of file +?> diff --git a/cake/basics.php b/cake/basics.php index 7ed2b8442..531846ba4 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -320,6 +320,7 @@ if ($name === null) { return true; } + if (strpos($name, '.') !== false) { list($plugin, $name) = explode('.', $name); @@ -364,7 +365,9 @@ } $className = $name . 'Controller'; - if (!class_exists($className)) { + if (class_exists($className)) { + return true; + } else { $name = Inflector::underscore($className); $controllers = Configure::read('Controllers'); if (is_array($controllers)) { @@ -1003,7 +1006,50 @@ $uri = env('PHP_SELF') . '/' . env('QUERY_STRING'); } } - return preg_replace('/\?url=\//', '', $uri); + return str_replace('//', '/', preg_replace('/\?url=/', '/', $uri)); + } +/** + * Returns and sets the $_GET[url] derived from the REQUEST_INFO + * + * @param string $uri + * @return string URL + */ + function setUrl($uri = null, $script = null) { + if ($uri == null) { + $uri = setUri(); + } + if ($script == null) { + if (defined('BASE_URL')) { + $script = BASE_URL; + } else { + $script = env('SCRIPT_NAME'); + } + } + $url = null; + if ($uri === '/' || $uri === $script || $uri === '/'.APP_DIR.'/') { + $url = $_GET['url'] = '/'; + } else { + if (strpos($uri, $script) !== false) { + $elements = explode($script, $uri); + } elseif (strpos($uri, APP_DIR) !== false) { + $elements = explode(APP_DIR, $uri); + } elseif (preg_match('/^[\/\?\/|\/\?|\?\/]/', $uri)) { + $elements = array(1 => preg_replace('/^[\/\?\/|\/\?|\?\/]/', '', $uri)); + } else { + $elements = array(); + } + + if (!empty($elements[1])) { + $_GET['url'] = $elements[1]; + $url = $elements[1]; + } else { + $url = $_GET['url'] = '/'; + } + if (strpos($url, '/') === 0 && $url != '/') { + $url = $_GET['url'] = substr($url, 1); + } + } + return $url; } /** * Gets an environment variable from available sources, and provides emulation diff --git a/cake/bootstrap.php b/cake/bootstrap.php index d0f898109..2c365143a 100644 --- a/cake/bootstrap.php +++ b/cake/bootstrap.php @@ -36,14 +36,14 @@ if (!defined('PHP5')) { require CORE_PATH . 'cake' . DS . 'basics.php'; require APP_PATH . 'config' . DS . 'core.php'; require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php'; + require LIBS . 'object.php'; + require LIBS . 'configure.php'; } $TIME_START = getMicrotime(); - require LIBS . 'object.php'; require LIBS . 'cache.php'; require LIBS . 'session.php'; require LIBS . 'security.php'; require LIBS . 'inflector.php'; - require LIBS . 'configure.php'; $paths = Configure::getInstance(); if (isset($cakeCache)) { @@ -73,31 +73,7 @@ if (!defined('PHP5')) { * Get the application path and request URL */ if (empty($uri) && defined('BASE_URL')) { - $uri = setUri(); - - if ($uri === '/' || $uri === '/index.php' || $uri === '/'.APP_DIR.'/') { - $_GET['url'] = '/'; - $url = '/'; - } else { - if (strpos($uri, 'index.php') !== false) { - $uri = r('?', '', $uri); - $elements = explode('/index.php', $uri); - } elseif (preg_match('/^[\/\?\/|\/\?|\?\/]/', $uri)) { - $elements = array(1 => preg_replace('/^[\/\?\/|\/\?|\?\/]/', '', $uri)); - } else { - $elements = array(); - } - - if (!empty($elements[1])) { - $_GET['url'] = $elements[1]; - $url = $elements[1]; - } else { - $url = $_GET['url'] = '/'; - } - if (strpos($url, '/') === 0 && $url != '/') { - $url = $_GET['url'] = substr($url, 1); - } - } + $url = setUrl(); } else { if (empty($_GET['url'])) { $url = null; diff --git a/cake/console/cake.php b/cake/console/cake.php index e49611aec..3e874999c 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -434,7 +434,7 @@ class ShellDispatcher { if ($this->params['app']{0} == '/') { $root = dirname($this->params['app']); $app = basename($this->params['app']); - } else if (!empty($this->params['working'])) { + } elseif (!empty($this->params['working'])) { $root = realpath($this->params['working']); } $app = $this->params['app']; diff --git a/cake/console/libs/bake.php b/cake/console/libs/bake.php index ae60adbcc..c4789ad35 100644 --- a/cake/console/libs/bake.php +++ b/cake/console/libs/bake.php @@ -104,4 +104,4 @@ class BakeShell extends Shell { } } -?> +?> \ No newline at end of file diff --git a/cake/console/libs/tasks/model.php b/cake/console/libs/tasks/model.php index 6af58fbcc..0c8ac3882 100644 --- a/cake/console/libs/tasks/model.php +++ b/cake/console/libs/tasks/model.php @@ -44,7 +44,7 @@ class ModelTask extends Shell { $this->__interactive(); } - if(!empty($this->args[0])) { + if (!empty($this->args[0])) { $model = $this->args[0]; if ($this->__bake($model)) { if ($this->_checkUnitTest()) { diff --git a/cake/console/libs/tasks/project.php b/cake/console/libs/tasks/project.php index ff866cc24..e209a1b11 100644 --- a/cake/console/libs/tasks/project.php +++ b/cake/console/libs/tasks/project.php @@ -66,7 +66,7 @@ class ProjectTask extends Shell { } } - if(empty($this->params['skel'])) { + if (empty($this->params['skel'])) { $this->params['skel'] = ''; if (is_dir(CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'console'.DS.'libs'.DS.'templates'.DS.'skel') === true) { $this->params['skel'] = CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'console'.DS.'libs'.DS.'templates'.DS.'skel'; @@ -81,7 +81,7 @@ class ProjectTask extends Shell { $this->params['app'] = basename($project); } - if($this->params['root'] === dirname(dirname(dirname(dirname(dirname(__FILE__)))))) { + if ($this->params['root'] === dirname(dirname(dirname(dirname(dirname(__FILE__)))))) { $this->params['working'] = $this->params['root'] . DS; } diff --git a/cake/console/libs/templates/skel/webroot/index.php b/cake/console/libs/templates/skel/webroot/index.php index 8d4ecdb23..67c5782b4 100644 --- a/cake/console/libs/templates/skel/webroot/index.php +++ b/cake/console/libs/templates/skel/webroot/index.php @@ -74,10 +74,13 @@ define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } } - require CORE_PATH . 'cake' . DS . 'bootstrap.php'; + if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) { + trigger_error("Can't find CakePHP core. Check the value of CAKE_CORE_INCLUDE_PATH in app/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); + } if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { + return; } else { - $Dispatcher=new Dispatcher(); + $Dispatcher = new Dispatcher(); $Dispatcher->dispatch($url); } if (Configure::read() > 0) { diff --git a/cake/console/libs/templates/skel/webroot/test.php b/cake/console/libs/templates/skel/webroot/test.php index 4ce4e70ad..6344146ad 100644 --- a/cake/console/libs/templates/skel/webroot/test.php +++ b/cake/console/libs/templates/skel/webroot/test.php @@ -74,10 +74,11 @@ if (empty( $_GET['output'])) { $_GET['output'] = 'html'; } -if (!defined('BASE_URL')) { - $dispatch =& new Dispatcher(); - define('BASE_URL', $dispatch->baseUrl()); -} +$dispatch =& new Dispatcher(); +$dispatch->base = env('SCRIPT_NAME'); +$dispatch->baseUrl(); +define('BASE', $dispatch->webroot); + /** * * Used to determine output to display @@ -179,7 +180,7 @@ if (!vendor('simpletest' . DS . 'reporter')) { function CakePHPTestHeader() { switch (CAKE_TEST_OUTPUT) { case CAKE_TEST_OUTPUT_HTML: - $baseUrl = BASE_URL; + $baseUrl = BASE; $characterSet = 'ISO-8859-1'; include CAKE . 'tests' . DS . 'lib' . DS . 'header.php'; break; @@ -203,7 +204,7 @@ if (!vendor('simpletest' . DS . 'reporter')) { function CakePHPTestSuiteFooter() { switch ( CAKE_TEST_OUTPUT) { case CAKE_TEST_OUTPUT_HTML: - $baseUrl = BASE_URL; + $baseUrl = BASE; include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php'; break; } diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 9748a229b..d4eb39175 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -78,8 +78,11 @@ class Dispatcher extends Object { /** * Constructor. */ - function __construct() { + function __construct($url = null) { parent::__construct(); + if ($url !== null) { + return $this->dispatch($url); + } } /** * Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set). @@ -96,62 +99,41 @@ class Dispatcher extends Object { */ function dispatch($url, $additionalParams = array()) { $params = array_merge($this->parseParams($url), $additionalParams); - $missingController = false; - $missingAction = false; - $missingView = false; - $privateAction = false; + $missingAction = $missingView = $privateAction = false; + $this->base = $this->baseUrl(); - if (empty($params['controller'])) { - $missingController = true; - } else { - $ctrlName = Inflector::camelize($params['controller']); - $ctrlClass = $ctrlName.'Controller'; - - if (!loadController($ctrlName)) { - $pluginName = Inflector::camelize($params['action']); - if (!loadController($ctrlName . '.' . $pluginName)) { - 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)) { - $missingController = true; - } else { - $params['plugin'] = null; - $this->plugin = null; - } - } else { - $params['plugin'] = Inflector::underscore($ctrlName); - } - } else { - $params['plugin'] = null; - $this->plugin = null; - } + $pluginPath = null; + if (!empty($params['plugin'])) { + $this->plugin = $params['plugin']; + $pluginPath = Inflector::camelize($this->plugin).'.'; } - if (isset($params['plugin'])) { - $plugin = $params['plugin']; - $pluginName = Inflector::camelize($params['action']); - $pluginClass = $pluginName.'Controller'; - $ctrlClass = $pluginClass; - $oldAction = $params['action']; - $params = $this->_restructureParams($params); - $this->plugin = $plugin; - loadPluginModels($plugin); - $this->base = $this->base.'/'.Inflector::underscore($ctrlName); + if (!empty($params['controller'])) { + $ctrlName = Inflector::camelize($params['controller']); + $ctrlClass = $ctrlName.'Controller'; + } - if (empty($params['controller']) || !class_exists($pluginClass)) { - $params['controller'] = Inflector::underscore($ctrlName); - $ctrlClass = $ctrlName.'Controller'; - if (!is_null($params['action'])) { - array_unshift($params['pass'], $params['action']); - } - $params['action'] = $oldAction; + if (!loadController($pluginPath . $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))); + } else { + Router::setRequestInfo(array($params, array('base' => $this->base, 'webroot' => $this->webroot))); + return $this->cakeError('missingController', array( + array( + 'className' => Inflector::camelize($params['controller']."Controller"), + 'webroot' => $this->webroot, + 'url' => $url, + 'base' => $this->base + ) + )); } + } else { + $controller =& new $ctrlClass(); } if (empty($params['action'])) { @@ -167,42 +149,22 @@ class Dispatcher extends Object { $privateAction = true; } } - $base = Router::stripPlugin($this->base, $this->plugin); - if (defined('BASE_URL')) { - $this->here = $base . $this->admin . $url; - } else { - $this->here = $base . $this->admin . '/' . $url; - } - if ($missingController) { - Router::setRequestInfo(array($params, array('base' => $this->base, 'webroot' => $this->webroot))); - return $this->cakeError('missingController', array( - array( - 'className' => Inflector::camelize($params['controller']."Controller"), - 'webroot' => $this->webroot, - 'url' => $url, - 'base' => $this->base - ) - )); - } else { - $controller =& new $ctrlClass(); - } + $this->here = $this->base . $this->admin . '/' . $url; - $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) { + $protected = array('constructclasses', 'redirect', 'set', 'setAction', 'isauthorized', 'validate', 'validateerrors', + 'render', 'referer', 'disablecache', 'flash', 'generatefieldnames', 'postconditions', 'cleanupfields', + 'paginate', 'beforefilter', 'beforerender', 'afterfilter', 'object', 'tostring', 'requestaction', 'log', + 'cakeerror'); + + $classMethods = array_map("low", get_class_methods($controller)); + + if (in_array(low($params['action']), $protected) || strpos($params['action'], '_', 0) === 0) { $privateAction = true; } - if (!in_array($params['action'], $classMethods) && !in_array(strtolower($params['action']), $classMethods)) { - $missingAction = true; - } - - if (in_array(strtolower($params['action']), array( - 'object', 'tostring', 'requestaction', 'log', 'cakeerror', 'constructclasses', 'redirect', 'set', 'setaction', - 'validate', 'validateerrors', 'render', 'referer', 'flash', 'flashout', 'generatefieldnames', - 'postconditions', 'cleanupfields', 'beforefilter', 'beforerender', 'afterfilter', 'disablecache', 'paginate'))) { + if (!in_array(low($params['action']), $classMethods)) { $missingAction = true; } @@ -214,7 +176,13 @@ class Dispatcher extends Object { $controller->here = $this->here; $controller->webroot = $this->webroot; $controller->params = $params; + $controller->plugin = $this->plugin; $controller->action = $params['action']; + $controller->webservices = $params['webservices']; + + list($passedArgs, $namedArgs) = Router::getArgs($params, $controller->namedArgs, $controller->argSeparator); + $controller->passedArgs = $passedArgs; + $controller->namedArgs = $namedArgs; if (!empty($controller->params['data'])) { $controller->data =& $controller->params['data']; @@ -222,65 +190,10 @@ class Dispatcher extends Object { $controller->data = null; } - $namedArgs = array(); - if (is_array($controller->namedArgs)) { - if (array_key_exists($params['action'], $controller->namedArgs)) { - $namedArgs = $controller->namedArgs[$params['action']]; - } else { - $namedArgs = $controller->namedArgs; - } - $controller->namedArgs = true; - } - if (!empty($controller->params['pass'])) { - $controller->passedArgs =& $controller->params['pass']; - if ($controller->namedArgs === true) { - $controller->namedArgs = array(); - $c = count($controller->passedArgs); - 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)))) { - $controller->passedArgs[$argKey] = $argVal; - $controller->namedArgs[$argKey] = $argVal; - unset($controller->passedArgs[$i]); - unset($params['pass'][$i]); - } - } elseif ($controller->argSeparator === '/') { - $ii = $i + 1; - 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)))) { - $controller->passedArgs[$argKey] = $argVal; - $controller->namedArgs[$argKey] = $argVal; - unset($controller->passedArgs[$i], $controller->passedArgs[$ii]); - unset($params['pass'][$i], $params['pass'][$ii]); - } - } - } - } - $controller->passedArgs = am($namedArgs, $controller->passedArgs); - $controller->namedArgs = am($namedArgs, $controller->namedArgs); - } - } else { - $controller->passedArgs = null; - if ($controller->namedArgs === true) { - $controller->passedArgs = array(); - $controller->namedArgs = array(); - $controller->passedArgs = am($namedArgs, $controller->passedArgs); - $controller->namedArgs = am($namedArgs, $controller->namedArgs); - } - } - if (!empty($params['bare'])) { - $controller->autoLayout = !$params['bare']; + $controller->autoLayout = false; } - $controller->webservices = $params['webservices']; - $controller->plugin = $this->plugin; - if (isset($params['viewPath'])) { - $controller->viewPath = $params['viewPath']; - } if (isset($params['layout'])) { if ($params['layout'] === '') { $controller->autoLayout = false; @@ -289,6 +202,10 @@ class Dispatcher extends Object { } } + if (isset($params['viewPath'])) { + $controller->viewPath = $params['viewPath']; + } + foreach (array('components', 'helpers') as $var) { if (isset($params[$var]) && !empty($params[$var]) && is_array($controller->{$var})) { $diff = array_diff($params[$var], $controller->{$var}); @@ -304,19 +221,6 @@ class Dispatcher extends Object { $controller->_initComponents(); $controller->constructClasses(); - if ($missingAction && !in_array('scaffold', array_keys($classVars))) { - $this->start($controller); - return $this->cakeError('missingAction', array( - array( - 'className' => Inflector::camelize($params['controller']."Controller"), - 'action' => $params['action'], - 'webroot' => $this->webroot, - 'url' => $url, - 'base' => $this->base - ) - )); - } - if ($privateAction) { $this->start($controller); return $this->cakeError('privateAction', array( @@ -349,12 +253,24 @@ class Dispatcher extends Object { if ($missingAction && in_array('scaffold', array_keys($classVars))) { uses('controller'. DS . 'scaffold'); return new Scaffold($controller, $params); + } elseif ($missingAction && !in_array('scaffold', array_keys($classVars))) { + return $this->cakeError('missingAction', array( + array( + 'className' => Inflector::camelize($params['controller']."Controller"), + 'action' => $params['action'], + 'webroot' => $this->webroot, + 'url' => $this->here, + 'base' => $this->base + ) + )); } else { $output = call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']); } + if ($controller->autoRender) { $output = $controller->render(); } + $controller->output =& $output; foreach ($controller->components as $c) { @@ -417,12 +333,12 @@ class Dispatcher extends Object { include CONFIGS.'routes.php'; $params = Router::parse($fromUrl); - if (ini_get('magic_quotes_gpc') == 1) { - if (!empty($_POST)) { + if (isset($_POST)) { + if (ini_get('magic_quotes_gpc') == 1) { $params['form'] = stripslashes_deep($_POST); + } else { + $params['form'] = $_POST; } - } else { - $params['form'] = $_POST; } if (isset($params['form']['data'])) { @@ -458,66 +374,71 @@ class Dispatcher extends Object { } } } - $params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1; + $params['bare'] = empty($params['ajax']) ? (empty($params['bare']) ? 0: 1) : 1; $params['webservices'] = empty($params['webservices']) ? null : $params['webservices']; return $params; } /** - * Returns a base URL. + * Returns a base URL and sets the proper webroot * * @return string Base URL * @access public */ function baseUrl() { - $htaccess = null; - $base = $this->admin; - $this->webroot = ''; + $base = $this->base; + $this->webroot = '/'; - if (defined('BASE_URL')) { - $base = BASE_URL.$this->admin; + $baseUrl = Configure::read('baseUrl'); + $app = Configure::read('app'); + $webroot = Configure::read('webroot'); + + $file = $script = null; + if (!$baseUrl && $this->base == false) { + $docRoot = env('DOCUMENT_ROOT'); + $script = env('SCRIPT_FILENAME'); + $base = r($docRoot, '', $script); + } elseif ($baseUrl && $this->base == false) { + $base = $baseUrl; } - $docRoot = env('DOCUMENT_ROOT'); - $scriptName = env('PHP_SELF'); - $r = null; - $appDirName = str_replace('/','\/',preg_quote(APP_DIR)); - $webrootDirName = str_replace('/', '\/', preg_quote(WEBROOT_DIR)); - - if (preg_match('/'.$appDirName.'\\'.DS.$webrootDirName.'/', $docRoot)) { - $this->webroot = '/'; - - if (preg_match('/^(.*)\/index\.php$/', $scriptName, $r)) { - - if (!empty($r[1])) { - return $base.$r[1]; - } - } - } else { - if (defined('BASE_URL')) { - $webroot = setUri(); - $htaccess = preg_replace('/(?:'.APP_DIR.'\\/(.*)|index\\.php(.*))/i', '', $webroot).APP_DIR.'/'.$webrootDirName.'/'; - } - - if (preg_match('/^(.*)\\/'.$appDirName.'\\/'.$webrootDirName.'\\/index\\.php$/', $scriptName, $regs)) { - - if (APP_DIR === 'app') { - $appDir = null; - } else { - $appDir = '/'.APP_DIR; - } - !empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[1].$appDir.'/'; - return $base.$regs[1].$appDir; - - } elseif (preg_match('/^(.*)\\/'.$webrootDirName.'([^\/i]*)|index\\\.php$/', $scriptName, $regs)) { - !empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[0].'/'; - return $base.$regs[0]; - - } else { - !empty($htaccess)? $this->webroot = $htaccess : $this->webroot = '/'; - return $base; - } + $file = basename($base); + if (($baseUrl || $this->base) && strpos($file, '.php') !== false) { + $baseUrl = true; + $file = '/'. $file; } - return $base; + + $base = dirname($base); + + if ($base == '/' || $base == '.') { + $base = ''; + } + + if (!$baseUrl && strpos($script, $app) !== false && $app === 'app') { + $base = str_replace($app.'/', '', $base); + } + + $base = str_replace('//', '/', str_replace('/'.$webroot, '', $base)); + + $this->webroot = $base .'/'; + + if (!$baseUrl) { + return $base; + } + + if ($baseUrl && $base == '') { + return $file; + } + + if (strpos($base, $app) === false) { + $this->webroot .= '/' . $app . '/' ; + } + + if ($baseUrl && strpos($this->webroot, $webroot) === false) { + $this->webroot .= $webroot . '/'; + } + $this->webroot = str_replace('//', '/', $this->webroot); + + return $base . $file; } /** * Restructure params in case we're serving a plugin. diff --git a/cake/libs/configure.php b/cake/libs/configure.php index e4425ab35..f076f44ac 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -452,6 +452,14 @@ class Configure extends Object { $_this->__buildHelperPaths($helperPaths); $_this->__buildComponentPaths($componentPaths); $_this->__buildBehaviorPaths($behaviorPaths); + + $_this->write('app', APP_DIR); + $_this->write('webroot', WEBROOT_DIR); + $baseUrl = false; + if (defined('BASE_URL')) { + $baseUrl = BASE_URL; + } + $_this->write('baseUrl', $baseUrl); } } ?> \ No newline at end of file diff --git a/cake/libs/controller/components/acl.php b/cake/libs/controller/components/acl.php index bd88f097d..a109ec538 100644 --- a/cake/libs/controller/components/acl.php +++ b/cake/libs/controller/components/acl.php @@ -54,8 +54,8 @@ class AclComponent extends Object { function &getACL() { if ($this->_instance == null) { $name = $this->name; - if(!class_exists($name)) { - if(loadComponent($name)) { + if (!class_exists($name)) { + if (loadComponent($name)) { if (strpos($name, '.') !== false) { list($plugin, $name) = explode('.', $name); } diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 685e42d46..52b831044 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -300,10 +300,10 @@ class AuthComponent extends Object { } } - if($this->authorize) { + if ($this->authorize) { extract($this->__authType()); - if(in_array($type, array('crud', 'actions'))) { - if(isset($controller->Acl)) { + if (in_array($type, array('crud', 'actions'))) { + if (isset($controller->Acl)) { $this->Acl =& $controller->Acl; if ($this->isAuthorized($type)) { return true; @@ -311,8 +311,8 @@ class AuthComponent extends Object { } else { trigger_error(__('Could not find AclComponent. Please include Acl in Controller::$components.', true), E_USER_WARNING); } - } else if($type == 'model') { - if(!isset($object)) { + } elseif ($type == 'model') { + if (!isset($object)) { if (isset($controller->{$controller->modelClass}) && is_object($controller->{$controller->modelClass})) { $object = $controller->modelClass; } elseif (!empty($controller->uses) && isset($controller->{$controller->uses[0]}) && is_object($controller->{$controller->uses[0]})) { @@ -322,8 +322,8 @@ class AuthComponent extends Object { if ($this->isAuthorized($type, null, $object)) { return true; } - } else if($type == 'controller'){ - if($controller->isAuthorized()) { + } elseif ($type == 'controller'){ + if ($controller->isAuthorized()) { return true; } } @@ -377,7 +377,7 @@ class AuthComponent extends Object { extract($this->__authType(array($type => $object))); - if(!$object) { + if (!$object) { $object = $this->objectModel; } @@ -395,14 +395,14 @@ class AuthComponent extends Object { } break; case 'model': - if(empty($object)) { + if (empty($object)) { trigger_error(__(sprintf('Could not find %s. Set AuthComponent::$objectModel in beforeFilter() or pass object name.', $this->objectModel), true), E_USER_WARNING); return; } $model = $this->getModel($object); if (method_exists($model, 'isAuthorized')) { $valid = $model->isAuthorized($user, $this->action(':controller'), $this->action(':action')); - } else if($model){ + } elseif ($model){ trigger_error(__(sprintf('%s::isAuthorized() is not defined.', $model), true), E_USER_WARNING); } break; @@ -626,7 +626,7 @@ class AuthComponent extends Object { */ function &getModel($name = null) { $model = null; - if(!$name) { + if (!$name) { $name = $this->userModel; } if (!ClassRegistry::isKeySet($name)) { @@ -768,7 +768,7 @@ class AuthComponent extends Object { } $paths = Router::getPaths(); - if(stristr($url, $paths['base'])) { + if (stristr($url, $paths['base'])) { $url = r($paths['base'], '', $url); } @@ -781,4 +781,4 @@ class AuthComponent extends Object { } } -?> +?> \ No newline at end of file diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index ea133e561..5cd1596e1 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -257,7 +257,7 @@ class RequestHandlerComponent extends Object { */ function isMobile() { preg_match('/' . REQUEST_MOBILE_UA . '/i', env('HTTP_USER_AGENT'), $match); - if(!empty($match) || $this->accepts('wap')) { + if (!empty($match) || $this->accepts('wap')) { return true; } return false; diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index 1417335b9..5ec6e271c 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -495,7 +495,7 @@ class SecurityComponent extends Object { if ($string === '_') { $newKey = substr($key, 1); - if(!isset($controller->data[$newKey])) { + if (!isset($controller->data[$newKey])) { $controller->data[$newKey] = array(); } diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 64e31701d..f63278e8e 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -275,7 +275,7 @@ class Scaffold extends Object { } else { return $this->controller->flash(sprintf(__("No id set for %s::edit()", true), Inflector::humanize($this->modelKey)), $this->redirect); } - } elseif($action == 'edit') { + } elseif ($action == 'edit') { $this->ScaffoldModel->id = $params['pass'][0]; } @@ -506,7 +506,7 @@ class Scaffold extends Object { return $path . $this->viewPath . DS . 'scaffolds' . DS . $this->subDir . $type . $scaffoldAction . '.thtml'; } } - if($action === 'add') { + if ($action === 'add') { $action = 'edit'; } return LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . $action . '.ctp'; diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 729f2bb21..e9209b036 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -474,4 +474,4 @@ class I18nModel extends AppModel { var $useTable = 'i18n'; var $belongsTo = array('Content' => array('className' => 'I18nContent', 'foreignKey' => 'i18n_content_id')); } -?> +?> \ No newline at end of file diff --git a/cake/libs/model/behaviors/tree.php b/cake/libs/model/behaviors/tree.php index 5a8a179da..e13dc7d4f 100644 --- a/cake/libs/model/behaviors/tree.php +++ b/cake/libs/model/behaviors/tree.php @@ -719,4 +719,4 @@ class TreeBehavior extends ModelBehavior { $model->updateAll(array($field => "{$field} $dir {$shift}"), $conditions); } } -?> +?> \ No newline at end of file diff --git a/cake/libs/model/datasources/dbo/dbo_adodb.php b/cake/libs/model/datasources/dbo/dbo_adodb.php index a23857cdc..13b1a248f 100644 --- a/cake/libs/model/datasources/dbo/dbo_adodb.php +++ b/cake/libs/model/datasources/dbo/dbo_adodb.php @@ -421,6 +421,18 @@ class DboAdodb extends DboSource { return false; } } +/** + * Inserts multiple values into a join table + * + * @param string $table + * @param string $fields + * @param array $values + */ + function insertMulti($table, $fields, $values) { + $count = count($values); + for ($x = 0; $x < $count; $x++) { + $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}"); + } + } } - ?> \ No newline at end of file diff --git a/cake/libs/model/datasources/dbo/dbo_firebird.php b/cake/libs/model/datasources/dbo/dbo_firebird.php index ba5e32568..56fcfbadc 100644 --- a/cake/libs/model/datasources/dbo/dbo_firebird.php +++ b/cake/libs/model/datasources/dbo/dbo_firebird.php @@ -496,5 +496,18 @@ class DboFirebird extends DboSource { return false; } } +/** + * Inserts multiple values into a join table + * + * @param string $table + * @param string $fields + * @param array $values + */ + function insertMulti($table, $fields, $values) { + $count = count($values); + for ($x = 0; $x < $count; $x++) { + $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}"); + } + } } ?> \ No newline at end of file diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/cake/libs/model/datasources/dbo/dbo_mssql.php index d12460fac..df6cb185e 100644 --- a/cake/libs/model/datasources/dbo/dbo_mssql.php +++ b/cake/libs/model/datasources/dbo/dbo_mssql.php @@ -585,6 +585,18 @@ class DboMssql extends DboSource { $query = trim(r($search, $replace, $schema)); return $query; } +/** + * Inserts multiple values into a join table + * + * @param string $table + * @param string $fields + * @param array $values + */ + function insertMulti($table, $fields, $values) { + $count = count($values); + for ($x = 0; $x < $count; $x++) { + $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}"); + } + } } - ?> \ No newline at end of file diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php index 7e47c519a..119eab106 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/cake/libs/model/datasources/dbo/dbo_oracle.php @@ -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; } @@ -217,17 +217,17 @@ class DboOracle extends DboSource { $lastTableName = ''; foreach($fields as $key => $value) { - if($value != 'COUNT(*) AS count') { - if(preg_match('/\s+(\w+(\.\w+)*)$/', $value, $matches)) { + 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]; } */ @@ -237,7 +237,7 @@ class DboOracle extends DboSource { 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; @@ -332,7 +332,7 @@ class DboOracle extends DboSource { 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,12 +386,12 @@ 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(); @@ -412,13 +412,13 @@ 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, DATA_LENGTH FROM user_tab_columns WHERE table_name = \''; $sql .= strtoupper($this->fullTableName($model)) . '\''; - if(!$this->execute($sql)) { + if (!$this->execute($sql)) { return false; } $fields = array(); @@ -494,10 +494,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; @@ -508,28 +508,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'; @@ -543,7 +543,7 @@ class DboOracle extends DboSource { */ function value($data, $column = null, $safe = false) { $parent = parent::value($data, $column, $safe); - + if ($parent != null) { return $parent; } @@ -552,10 +552,10 @@ class DboOracle extends DboSource { return 'NULL'; } - if($data === '') { + if ($data === '') { return "''"; } - + switch($column) { case 'date': $data = date('Y-m-d H:i:s', strtotime($data)); @@ -564,7 +564,7 @@ class DboOracle extends DboSource { case 'integer' : case 'float' : case null : - if(is_numeric($data)) { + if (is_numeric($data)) { break; } default: @@ -585,7 +585,7 @@ 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; } @@ -603,7 +603,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; @@ -617,7 +617,7 @@ class DboOracle extends DboSource { function lastAffected() { return $this->_statementId ? ocirowcount($this->_statementId): false; } - + /** * Generate a Oracle-native column schema string * @@ -667,6 +667,18 @@ class DboOracle extends DboSource { } return $out; } - +/** + * Inserts multiple values into a join table + * + * @param string $table + * @param string $fields + * @param array $values + */ + function insertMulti($table, $fields, $values) { + $count = count($values); + for ($x = 0; $x < $count; $x++) { + $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}"); + } + } } -?> +?> \ No newline at end of file diff --git a/cake/libs/model/datasources/dbo/dbo_pear.php b/cake/libs/model/datasources/dbo/dbo_pear.php index efec3f82b..a7b374471 100644 --- a/cake/libs/model/datasources/dbo/dbo_pear.php +++ b/cake/libs/model/datasources/dbo/dbo_pear.php @@ -224,5 +224,18 @@ class DboPear extends DboSource{ function selectLimit($limit, $offset = '0') { return ' ' . $this->_pear->modifyLimitQuery('', $offset, $limit); } +/** + * Inserts multiple values into a join table + * + * @param string $table + * @param string $fields + * @param array $values + */ + function insertMulti($table, $fields, $values) { + $count = count($values); + for ($x = 0; $x < $count; $x++) { + $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}"); + } + } } ?> \ No newline at end of file diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/cake/libs/model/datasources/dbo/dbo_sqlite.php index a5d6b58a2..ea74a6f81 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/cake/libs/model/datasources/dbo/dbo_sqlite.php @@ -393,6 +393,18 @@ class DboSqlite extends DboSource { } return null; } +/** + * Inserts multiple values into a join table + * + * @param string $table + * @param string $fields + * @param array $values + */ + function insertMulti($table, $fields, $values) { + $count = count($values); + for ($x = 0; $x < $count; $x++) { + $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}"); + } + } } - ?> \ No newline at end of file diff --git a/cake/libs/model/datasources/dbo/dbo_sybase.php b/cake/libs/model/datasources/dbo/dbo_sybase.php index 94651b87e..82d47444e 100644 --- a/cake/libs/model/datasources/dbo/dbo_sybase.php +++ b/cake/libs/model/datasources/dbo/dbo_sybase.php @@ -392,5 +392,18 @@ class DboSybase extends DboSource { $query = trim(r($search, $replace, $schema)); return $query; } +/** + * Inserts multiple values into a join table + * + * @param string $table + * @param string $fields + * @param array $values + */ + function insertMulti($table, $fields, $values) { + $count = count($values); + for ($x = 0; $x < $count; $x++) { + $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}"); + } + } } ?> \ No newline at end of file diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index a4c883a71..1c57e475a 100644 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1569,11 +1569,11 @@ class DboSource extends DataSource { } elseif (!isset($match['2'])) { $match['1'] = ' = '; $match['2'] = $match['0']; - } else if(low($mValue) == 'not') { + } elseif (low($mValue) == 'not') { $not = $this->conditionKeysToString(array($mValue => array($key => $match[2])), $quoteValues); } - if($not) { + if ($not) { $data = $not[0]; } elseif (strpos($match['2'], '-!') === 0) { $match['2'] = str_replace('-!', '', $match['2']); @@ -1814,6 +1814,16 @@ class DboSource extends DataSource { $this->close(); parent::__destruct(); } +/** + * Inserts multiple values into a join table + * + * @param string $table + * @param string $fields + * @param array $values + */ + function insertMulti($table, $fields, $values) { + $values = implode(', ', $values); + $this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}"); + } } - -?> +?> \ No newline at end of file diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 38ecc3a66..0e8a16bc5 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1111,8 +1111,7 @@ class Model extends Overloadable { $db->query("DELETE FROM {$table} WHERE {$mainKey[$loopAssoc]} = '{$id}'"); if (!empty($newValue[$loopAssoc])) { - $insertValues = implode(', ', $newValue[$loopAssoc]); - $db->query("INSERT INTO {$table} ({$fields[$loopAssoc]}) VALUES {$insertValues};"); + $db->insertMulti($table, $fields[$loopAssoc], $newValue[$loopAssoc]); } } } diff --git a/cake/libs/router.php b/cake/libs/router.php index eb419e078..ce36f97fe 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -670,7 +670,7 @@ class Router extends Object { if ($full) { $output = FULL_BASE_URL . $output; } - if(!empty($extension) && substr($output, -1) == '/') { + if (!empty($extension) && substr($output, -1) == '/') { $output = substr($output, 0, -1); } return $output . $extension . $_this->queryString($q) . $frag; diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index e57d6958a..df734fbe3 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -72,7 +72,7 @@ class Sanitize{ */ function escape($string, $connection = 'default') { $db = ConnectionManager::getDataSource($connection); - if(is_numeric($string)) { + if (is_numeric($string)) { return $string; } $string = substr($db->value($string), 1); diff --git a/cake/libs/set.php b/cake/libs/set.php index a6d4978de..928e32a03 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -622,7 +622,7 @@ class Set extends Object { $path2 = $path1; $path1 = $data; $data = $this->get(); - } else if (is_a($this, 'set') && is_string($data) && empty($path2)) { + } elseif (is_a($this, 'set') && is_string($data) && empty($path2)) { $path2 = $path1; $path1 = $data; $data = $this->get(); @@ -638,7 +638,7 @@ class Set extends Object { $vals = Set::extract($data, $path2); } else { $count = count($keys); - for($i=0; $i < $count; $i++) { + for ($i=0; $i < $count; $i++) { $vals[$i] = null; } } @@ -709,7 +709,7 @@ class Set extends Object { } $return = $object; - if(!empty($merge)) { + if (!empty($merge)) { $mergeKeys = array_keys($merge); $objectKeys = array_keys($object); $count = count($mergeKeys); @@ -720,8 +720,8 @@ class Set extends Object { $loop = $count1; for ($ii = 0; $ii < $loop; $ii++) { - if(is_array($object[$objectKeys[$ii]])) { - if(array_key_exists($objectKeys[$ii], $object[$objectKeys[$ii]])) { + if (is_array($object[$objectKeys[$ii]])) { + if (array_key_exists($objectKeys[$ii], $object[$objectKeys[$ii]])) { unset($change[$objectKeys[$ii]][$objectKeys[$ii]]); } } else { @@ -730,8 +730,8 @@ class Set extends Object { } foreach ($objectKeys as $key => $value) { - if(is_array($object[$value])) { - if(array_key_exists($mergeKeys[$i], $object[$value])) { + if (is_array($object[$value])) { + if (array_key_exists($mergeKeys[$i], $object[$value])) { unset($change[$value][$mergeKeys[$i]]); } } else { diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 6a0ef7ad8..9b54f7439 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -466,12 +466,12 @@ class FormHelper extends AppHelper { } } - if(isset($options['type']) && $options['type'] == 'radio') { - if(!isset($options['options']) && isset($options['value'])) { + if (isset($options['type']) && $options['type'] == 'radio') { + if (!isset($options['options']) && isset($options['value'])) { $radioOptions = array($options['value']); unset($options['value']); - } else if(isset($options['options'])) { - if(is_array($options['options'])) { + } elseif (isset($options['options'])) { + if (is_array($options['options'])) { $radioOptions = $options['options']; } else { $radioOptions = array($options['options']); @@ -480,8 +480,8 @@ class FormHelper extends AppHelper { } $inBetween = null; - if(isset($options['inbetween'])) { - if(!empty($options['inbetween'])) { + if (isset($options['inbetween'])) { + if (!empty($options['inbetween'])) { $inBetween = $options['inbetween']; } unset($options['inbetween']); @@ -731,9 +731,9 @@ class FormHelper extends AppHelper { foreach ($options as $optValue => $optTitle) { $optionsHere = array('value' => $optValue); - if(empty($value) && $count == 0) { + if (empty($value) && $count == 0) { $optionsHere['checked'] = 'checked'; - } else if (!empty($value) && $optValue == $value) { + } elseif (!empty($value) && $optValue == $value) { $optionsHere['checked'] = 'checked'; } diff --git a/cake/libs/view/helpers/number.php b/cake/libs/view/helpers/number.php index e3ac1ccbc..02f62c13b 100644 --- a/cake/libs/view/helpers/number.php +++ b/cake/libs/view/helpers/number.php @@ -111,7 +111,7 @@ class NumberHelper extends AppHelper { $seperator = $options; } $decimals = '.'; - if(!is_array($options) && in_array( $options, $seperators)) { + if (!is_array($options) && in_array( $options, $seperators)) { $decimals = $options; } $escape = true; @@ -130,7 +130,7 @@ class NumberHelper extends AppHelper { unset($options['before']); } - if(isset($options['decimals'])) { + if (isset($options['decimals'])) { $decimals = $options['decimals']; unset($options['decimals']); } diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index a25b924d8..1674bbcb3 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -471,7 +471,7 @@ class PaginatorHelper extends AppHelper { for ($i = $start; $i < $end; $i++) { $out .= $this->link($i, array('page' => $i), $options) . $separator; } - + if ($end != $params['page']) { $out .= $this->link($i, array('page' => $end), $options); } @@ -488,4 +488,4 @@ class PaginatorHelper extends AppHelper { return $this->output($out); } } -?> +?> \ No newline at end of file diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index f2e04b6f5..bbd049df3 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -26,7 +26,62 @@ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ - require_once CAKE.'dispatcher.php'; +require_once CAKE.'dispatcher.php'; + +class TestDispatcher extends Dispatcher { + + function _invoke(&$controller, $params, $missingAction) { + $this->start($controller); + $classVars = get_object_vars($controller); + if ($missingAction && in_array('scaffold', array_keys($classVars))) { + uses('controller'. DS . 'scaffold'); + return new Scaffold($controller, $params); + } elseif ($missingAction && !in_array('scaffold', array_keys($classVars))) { + return $this->cakeError('missingAction', array( + array( + 'className' => Inflector::camelize($params['controller']."Controller"), + 'action' => $params['action'], + 'webroot' => $this->webroot, + 'url' => $this->here, + 'base' => $this->base + ) + )); + } + return $controller; + } + + function start(&$controller) { + return; + } + + function cakeError($filename) { + return $filename; + } + +} + +class MyPluginAppController extends Controller { + +} +class SomePagesController extends MyPluginAppController { + + var $name = 'SomePages'; + var $uses = array(); + + function display($page = null) { + return $page; + } +} + +class TestDispatchPagesController extends Controller { + + var $name = 'TestDispatchPages'; + var $uses = array(); + + function admin_index() { + return true; + } +} /** * Short description for class. * @@ -35,6 +90,15 @@ */ class DispatcherTest extends UnitTestCase { + function setUp() { + $this->_get = $_GET; + $_GET = array(); + Configure::write('baseUrl', false); + Configure::write('app', 'app'); + Configure::write('webroot', 'webroot'); + + } + function testParseParamsWithoutZerosAndEmptyPost() { $dispatcher =& new Dispatcher(); $test = $dispatcher->parseParams("/testcontroller/testaction/params1/params2/params3"); @@ -96,5 +160,304 @@ class DispatcherTest extends UnitTestCase { $this->assertPattern('/\\A(?:000030)\\z/', $test['pass'][4]); $this->assertPattern('/\\A(?:0000400)\\z/', $test['pass'][5]); } + + function testSetUrl() { + $uri = '/app/webroot/index.php/posts/add'; + $_SERVER['SCRIPT_NAME'] = '/app/webroot/index.php'; + $result = setUrl($uri); + $expected = 'posts/add'; + $this->assertEqual($expected, $result); + + $uri = APP_DIR . '/posts/add'; + $_SERVER['SCRIPT_NAME'] = APP_DIR . '/webroot/index.php'; + $result = setUrl($uri); + $expected = 'posts/add'; + $this->assertEqual($expected, $result); + + $uri = '/posts/add'; + $_SERVER['SCRIPT_NAME'] = '/app/webroot/index.php'; + $result = setUrl($uri); + $expected = 'posts/add'; + $this->assertEqual($expected, $result); + } + + function testBaseUrlAndWebrootWithModRewrite() { + $dispatcher =& new Dispatcher(); + + Configure::write('app', 'app'); + Configure::write('webroot', 'webroot'); + Configure::write('baseUrl', false); + + $dispatcher->base = false; + $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches'; + $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php'; + $result = $dispatcher->baseUrl(); + $expected = '/1.2.x.x'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/1.2.x.x/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + $dispatcher->base = false; + $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/app/webroot'; + $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php'; + $result = $dispatcher->baseUrl(); + $expected = ''; + $this->assertEqual($expected, $result); + $expectedWebroot = '/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + + Configure::write('app', 'auth'); + + $dispatcher->base = false;; + $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches'; + $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/demos/auth/webroot/index.php'; + $result = $dispatcher->baseUrl(); + $expected = '/demos/auth'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/demos/auth/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + Configure::write('app', 'code'); + + $dispatcher->base = false;; + $_SERVER['DOCUMENT_ROOT'] = '/Library/WebServer/Documents'; + $_SERVER['SCRIPT_FILENAME'] = '/Library/WebServer/Documents/clients/PewterReport/code/webroot/index.php'; + $result = $dispatcher->baseUrl(); + $expected = '/clients/PewterReport/code'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/clients/PewterReport/code/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + } + + function testBaseUrlAndWebrootWithBaseUrl() { + $dispatcher =& new Dispatcher(); + + Configure::write('app', 'app'); + + Configure::write('baseUrl', '/app/webroot/index.php'); + $result = $dispatcher->baseUrl(); + $expected = '/app/index.php'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/app/webroot/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + Configure::write('baseUrl', '/app/webroot/test.php'); + $result = $dispatcher->baseUrl(); + $expected = '/app/test.php'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/app/webroot/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + Configure::write('baseUrl', '/app/index.php'); + $result = $dispatcher->baseUrl(); + $expected = '/app/index.php'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/app/webroot/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + Configure::write('baseUrl', '/index.php'); + $result = $dispatcher->baseUrl(); + $expected = '/index.php'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + Configure::write('baseUrl', '/CakeBB/app/webroot/index.php'); + $result = $dispatcher->baseUrl(); + $expected = '/CakeBB/app/index.php'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/CakeBB/app/webroot/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + Configure::write('baseUrl', '/CakeBB/app/index.php'); + $result = $dispatcher->baseUrl(); + $expected = '/CakeBB/app/index.php'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/CakeBB/app/webroot/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + + Configure::write('baseUrl', '/CakeBB/index.php'); + $result = $dispatcher->baseUrl(); + $expected = '/CakeBB/index.php'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/CakeBB/app/webroot/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + } + + function testBaseUrlAndWebrootWithBase() { + $dispatcher =& new Dispatcher(); + Configure::write('baseUrl',false); + $dispatcher->base = '/app/webroot'; + $result = $dispatcher->baseUrl(); + $expected = '/app'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/app/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + $dispatcher->base = '/app'; + $result = $dispatcher->baseUrl(); + $expected = ''; + $this->assertEqual($expected, $result); + $expectedWebroot = '/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + + Configure::write('app', 'testbed'); + $dispatcher->base = '/cake/testbed/webroot/test.php'; + $result = $dispatcher->baseUrl(); + $expected = '/cake/testbed/test.php'; + $this->assertEqual($expected, $result); + $expectedWebroot = '/cake/testbed/webroot/'; + $this->assertEqual($expectedWebroot, $dispatcher->webroot); + } + + function testMissingController() { + $dispatcher =& new TestDispatcher(); + $dispatcher->base = '/index.php'; + $url = setUrl('/some_controller/home/param:value/param2:value2'); + + restore_error_handler(); + @$controller = $dispatcher->dispatch($url, array('return'=> 1)); + set_error_handler('simpleTestErrorHandler'); + + $expected = 'missingController'; + $this->assertEqual($expected, $controller); + } + + function testPrivate() { + $dispatcher =& new TestDispatcher(); + $dispatcher->base = '/index.php'; + $url = setUrl('/some_pages/redirect/param:value/param2:value2'); + + restore_error_handler(); + @$controller = $dispatcher->dispatch($url, array('return'=> 1)); + set_error_handler('simpleTestErrorHandler'); + + $expected = 'privateAction'; + $this->assertEqual($expected, $controller); + } + + function testMissingAction() { + $dispatcher =& new TestDispatcher(); + $dispatcher->base = '/index.php'; + $url = setUrl('/some_pages/home/param:value/param2:value2'); + + restore_error_handler(); + @$controller = $dispatcher->dispatch($url, array('return'=> 1)); + set_error_handler('simpleTestErrorHandler'); + $expected = 'missingAction'; + $this->assertEqual($expected, $controller); + } + + function testDispatch() { + $dispatcher =& new TestDispatcher(); + $dispatcher->base = '/index.php'; + $url = setUrl('/pages/home/param:value/param2:value2'); + + restore_error_handler(); + @$controller = $dispatcher->dispatch($url, array('return'=> 1)); + set_error_handler('simpleTestErrorHandler'); + + $expected = 'Pages'; + $this->assertEqual($expected, $controller->name); + + $expected = array('param'=>'value', 'param2'=>'value2'); + $this->assertIdentical($expected, $controller->namedArgs); + } + + function testAdminDispatch() { + $_POST = array(); + + if (!defined('CAKE_ADMIN')) { + define('CAKE_ADMIN', 'admin'); + } + $_SERVER['DOCUMENT_ROOT'] = ''; + $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php'; + + $dispatcher =& new TestDispatcher(); + $dispatcher->base = false; + $url = setUrl('/admin/test_dispatch_pages/index/param:value/param2:value2'); + + Router::reload(); + $Router =& Router::getInstance(); + if (defined('CAKE_ADMIN')) { + $admin = CAKE_ADMIN; + if (!empty($admin)) { + $Router->__admin = array( + '/:' . $admin . '/:controller/:action/*', + '/^(?:\/(?:(' . $admin . ')(?:\\/([a-zA-Z0-9_\\-\\.\\;\\:]+)(?:\\/([a-zA-Z0-9_\\-\\.\\;\\:]+)(?:[\\/\\?](.*))?)?)?))[\/]*$/', + array($admin, 'controller', 'action'), array() + ); + } + } + + restore_error_handler(); + @$controller = $dispatcher->dispatch($url, array('return'=> 1)); + set_error_handler('simpleTestErrorHandler'); + + $expected = 'TestDispatchPages'; + $this->assertEqual($expected, $controller->name); + + $expected = array('param'=>'value', 'param2'=>'value2'); + $this->assertIdentical($expected, $controller->namedArgs); + + $expected = 'admin'; + $this->assertIdentical($expected, $controller->params['admin']); + + $expected = '/cake/repo/branches/1.2.x.x/admin/test_dispatch_pages/index/param:value/param2:value2'; + $this->assertIdentical($expected, $controller->here); + + $expected = '/cake/repo/branches/1.2.x.x'; + $this->assertIdentical($expected, $controller->base); + + } + + function testPluginDispatch() { + $_POST = array(); + $_SERVER['DOCUMENT_ROOT'] = ''; + $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php'; + + Router::reload(); + $dispatcher =& new TestDispatcher(); + Router::connect('/my_plugin/:controller/*', array('plugin'=>'my_plugin', 'controller'=>'pages', 'action'=>'display')); + + $dispatcher->base = false; + $url = setUrl('/my_plugin/some_pages/home/param:value/param2:value2'); + + restore_error_handler(); + @$controller = $dispatcher->dispatch($url, array('return'=> 1)); + set_error_handler('simpleTestErrorHandler'); + + + $result = $dispatcher->parseParams($url); + $expected = array('pass' => array('home', 'param:value', 'param2:value2'), + 'plugin'=> 'my_plugin', 'controller'=> 'some_pages', 'action'=> 'display', + 'form'=> null, //array('testdata'=> 'My Posted Data'), + 'url'=> array('url'=> 'my_plugin/some_pages/home/param:value/param2:value2'), + 'bare'=> 0, 'webservices'=> ''); + $this->assertEqual($expected, $result); + + $expected = 'my_plugin'; + $this->assertIdentical($expected, $controller->plugin); + + $expected = 'SomePages'; + $this->assertIdentical($expected, $controller->name); + + $expected = array('param'=>'value', 'param2'=>'value2'); + $this->assertIdentical($expected, $controller->namedArgs); + + $expected = '/cake/repo/branches/1.2.x.x/my_plugin/some_pages/home/param:value/param2:value2'; + $this->assertIdentical($expected, $controller->here); + + $expected = '/cake/repo/branches/1.2.x.x'; + $this->assertIdentical($expected, $controller->base); + } + + function tearDown() { + $_GET = $this->_get; + } } -?> \ No newline at end of file +?> diff --git a/cake/tests/cases/libs/cache.test.php b/cake/tests/cases/libs/cache.test.php index 4aaa6d79a..5bcd58cb3 100644 --- a/cake/tests/cases/libs/cache.test.php +++ b/cake/tests/cases/libs/cache.test.php @@ -36,7 +36,7 @@ uses('cache'); class CacheTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'CacheTest not implemented'); + $this->skipif (true, 'CacheTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/cache/apc.test.php b/cake/tests/cases/libs/cache/apc.test.php index 575b68337..85bd65232 100644 --- a/cake/tests/cases/libs/cache/apc.test.php +++ b/cake/tests/cases/libs/cache/apc.test.php @@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'apc'); class APCEngineTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'APCEngineTest not implemented'); + $this->skipif (true, 'APCEngineTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/cache/file.test.php b/cake/tests/cases/libs/cache/file.test.php index 719787996..a8bc02dd1 100644 --- a/cake/tests/cases/libs/cache/file.test.php +++ b/cake/tests/cases/libs/cache/file.test.php @@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'file'); class FileEngineTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'FileEngineTest not implemented'); + $this->skipif (true, 'FileEngineTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/cache/memcache.test.php b/cake/tests/cases/libs/cache/memcache.test.php index 15ac2825b..30528b455 100644 --- a/cake/tests/cases/libs/cache/memcache.test.php +++ b/cake/tests/cases/libs/cache/memcache.test.php @@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'memcache'); class MemcacheEngineTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'MemcacheEngineTest not implemented'); + $this->skipif (true, 'MemcacheEngineTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/cache/model.test.php b/cake/tests/cases/libs/cache/model.test.php index 826a69456..df72a2fb6 100644 --- a/cake/tests/cases/libs/cache/model.test.php +++ b/cake/tests/cases/libs/cache/model.test.php @@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'model'); class ModelEngineTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'ModelEngineTest not implemented'); + $this->skipif (true, 'ModelEngineTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/cache/xcache.test.php b/cake/tests/cases/libs/cache/xcache.test.php index 591c06c8c..3e0e229f9 100644 --- a/cake/tests/cases/libs/cache/xcache.test.php +++ b/cake/tests/cases/libs/cache/xcache.test.php @@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'xcache'); class XcacheEngineTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'XcacheEngineTest not implemented'); + $this->skipif (true, 'XcacheEngineTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/cake_log.test.php b/cake/tests/cases/libs/cake_log.test.php index 626631895..0fcf48f36 100644 --- a/cake/tests/cases/libs/cake_log.test.php +++ b/cake/tests/cases/libs/cake_log.test.php @@ -36,7 +36,7 @@ uses('cake_log'); class CakeLogTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'CakeLogTest not implemented'); + $this->skipif (true, 'CakeLogTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/class_registry.test.php b/cake/tests/cases/libs/class_registry.test.php index bb7bf8781..c70cbcc4d 100644 --- a/cake/tests/cases/libs/class_registry.test.php +++ b/cake/tests/cases/libs/class_registry.test.php @@ -36,7 +36,7 @@ uses('class_registry'); class ClassRegistryTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'ClassRegistry not implemented'); + $this->skipif (true, 'ClassRegistry not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index 688f0d88a..999007c80 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -36,7 +36,7 @@ uses('configure'); class ConfigureTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'ConfigureTest not implemented'); + $this->skipif (true, 'ConfigureTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/component.test.php b/cake/tests/cases/libs/controller/component.test.php index da30c6476..123498321 100644 --- a/cake/tests/cases/libs/controller/component.test.php +++ b/cake/tests/cases/libs/controller/component.test.php @@ -36,7 +36,7 @@ uses('controller' . DS . 'component'); class ComponentTest extends CakeTestCase { function skip() { - $this->skipIf(true, 'ComponentTest not implemented'); + $this->skipif (true, 'ComponentTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/acl.test.php b/cake/tests/cases/libs/controller/components/acl.test.php index 8b5109d47..955e7b4f1 100644 --- a/cake/tests/cases/libs/controller/components/acl.test.php +++ b/cake/tests/cases/libs/controller/components/acl.test.php @@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'acl'); class AclComponentTest extends CakeTestCase { function skip() { - $this->skipIf(true, 'AclComponentTest not implemented'); + $this->skipif (true, 'AclComponentTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 45d5cecfe..b82d9c038 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -40,7 +40,7 @@ class AuthUser extends CakeTestModel { } function isAuthorized($user) { - if(!empty($user)) { + if (!empty($user)) { return true; } return false; @@ -87,7 +87,7 @@ class AuthTest extends CakeTestCase { var $fixtures = array('core.auth_user', 'core.aco', 'core.aro', 'core.aros_aco'); function skip() { - $this->skipIf(true, 'Auth tests currently disabled, to test use a clean database with tables needed for acl and comment out this line'); + $this->skipif (true, 'Auth tests currently disabled, to test use a clean database with tables needed for acl and comment out this line'); } function setUp() { diff --git a/cake/tests/cases/libs/controller/components/cookie.test.php b/cake/tests/cases/libs/controller/components/cookie.test.php index ac69bcfab..422ee3181 100644 --- a/cake/tests/cases/libs/controller/components/cookie.test.php +++ b/cake/tests/cases/libs/controller/components/cookie.test.php @@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'cookie'); class CookieComponentTest extends CakeTestCase { function skip() { - $this->skipIf(true, 'CookieComponentTest not implemented'); + $this->skipif (true, 'CookieComponentTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 31628130a..9b51843a3 100644 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -49,7 +49,7 @@ class EmailTest extends CakeTestCase { } function testBadSmtpSend() { - if(@fsockopen('localhost', 25)) { + if (@fsockopen('localhost', 25)) { $this->Controller->Email->smtpOptions['host'] = 'blah'; $this->assertFalse($this->Controller->Email->send('Should not work')); } else { @@ -58,7 +58,7 @@ class EmailTest extends CakeTestCase { } function testSmtpSend() { - if(@fsockopen('localhost', 25)) { + if (@fsockopen('localhost', 25)) { $this->assertTrue(@fsockopen('localhost', 25), "Local mail server is running"); $this->Controller->Email->reset(); $this->Controller->Email->to = 'chartjes@localhost'; diff --git a/cake/tests/cases/libs/controller/components/request_handler.test.php b/cake/tests/cases/libs/controller/components/request_handler.test.php index 15ab0d7a5..6c6b9dba7 100644 --- a/cake/tests/cases/libs/controller/components/request_handler.test.php +++ b/cake/tests/cases/libs/controller/components/request_handler.test.php @@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'request_handler'); class RequestHandlerComponentTest extends CakeTestCase { function skip() { - $this->skipIf(true, 'RequestHandlerComponentTest not implemented'); + $this->skipif (true, 'RequestHandlerComponentTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index 07d8ee277..6c4aaca36 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'security'); class SecurityComponentTest extends CakeTestCase { function skip() { - $this->skipIf(true, 'SecurityComponentTest not implemented'); + $this->skipif (true, 'SecurityComponentTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/session.test.php b/cake/tests/cases/libs/controller/components/session.test.php index 302e03aea..fd39693eb 100644 --- a/cake/tests/cases/libs/controller/components/session.test.php +++ b/cake/tests/cases/libs/controller/components/session.test.php @@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'session'); class SessionComponentTest extends CakeTestCase { function skip() { - $this->skipIf(true, 'SessionComponentTest not implemented'); + $this->skipif (true, 'SessionComponentTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 154d18d5c..018cd3467 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -36,7 +36,7 @@ uses('controller' . DS . 'controller'); class ControllerTest extends CakeTestCase { function skip() { - $this->skipIf(true, 'ControllerTest not implemented'); + $this->skipif (true, 'ControllerTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/pages_controller.php b/cake/tests/cases/libs/controller/pages_controller.php index c7b68a6ce..2a1b4f976 100644 --- a/cake/tests/cases/libs/controller/pages_controller.php +++ b/cake/tests/cases/libs/controller/pages_controller.php @@ -36,7 +36,7 @@ uses('controller' . DS . 'controller', 'controller' . DS . 'pages_controller'); class PagesControllerTest extends CakeTestCase { function skip() { - $this->skipIf(true, 'PagesControllerTest not implemented'); + $this->skipif (true, 'PagesControllerTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index 4b515f543..21c418e5b 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -36,7 +36,7 @@ uses('controller' . DS . 'scaffold'); class ScaffoldTest extends CakeTestCase { function skip() { - $this->skipIf(true, 'ScaffoldTest not implemented'); + $this->skipif (true, 'ScaffoldTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/debugger.test.php b/cake/tests/cases/libs/debugger.test.php index 106ba895e..6e80dd24d 100644 --- a/cake/tests/cases/libs/debugger.test.php +++ b/cake/tests/cases/libs/debugger.test.php @@ -36,7 +36,7 @@ uses('debugger'); class DebuggerTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'ConfigureTest not implemented'); + $this->skipif (true, 'ConfigureTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/error.test.php b/cake/tests/cases/libs/error.test.php index d0de6dc93..3c97886e0 100644 --- a/cake/tests/cases/libs/error.test.php +++ b/cake/tests/cases/libs/error.test.php @@ -36,7 +36,7 @@ uses('error'); class ErrorHandlerTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'ConfigureTest not implemented'); + $this->skipif (true, 'ConfigureTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/flay.test.php b/cake/tests/cases/libs/flay.test.php index 3abb86942..1bd7f04ac 100644 --- a/cake/tests/cases/libs/flay.test.php +++ b/cake/tests/cases/libs/flay.test.php @@ -36,7 +36,7 @@ uses('flay'); class FlayTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'FlayTest not implemented'); + $this->skipif (true, 'FlayTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/i18n.test.php b/cake/tests/cases/libs/i18n.test.php index b092df15b..3d5165334 100644 --- a/cake/tests/cases/libs/i18n.test.php +++ b/cake/tests/cases/libs/i18n.test.php @@ -36,7 +36,7 @@ uses('i18n'); class I18nTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'I18nTest not implemented'); + $this->skipif (true, 'I18nTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/l10n.test.php b/cake/tests/cases/libs/l10n.test.php index 43ee17d03..7bcf1241a 100644 --- a/cake/tests/cases/libs/l10n.test.php +++ b/cake/tests/cases/libs/l10n.test.php @@ -36,7 +36,7 @@ uses('l10n'); class L10nTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'L10nTest not implemented'); + $this->skipif (true, 'L10nTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/neat_string.test.php b/cake/tests/cases/libs/neat_string.test.php index 289e24749..0897d9df4 100644 --- a/cake/tests/cases/libs/neat_string.test.php +++ b/cake/tests/cases/libs/neat_string.test.php @@ -36,7 +36,7 @@ uses('neat_string'); class NeatStringTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'NeatString not implemented'); + $this->skipif (true, 'NeatString not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/object.test.php b/cake/tests/cases/libs/object.test.php index 778c14175..6714a6ce4 100644 --- a/cake/tests/cases/libs/object.test.php +++ b/cake/tests/cases/libs/object.test.php @@ -36,7 +36,7 @@ uses('object'); class ObjectTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'ObjectTest not implemented'); + $this->skipif (true, 'ObjectTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/overloadable.test.php b/cake/tests/cases/libs/overloadable.test.php index 04a8ff785..d548a8378 100644 --- a/cake/tests/cases/libs/overloadable.test.php +++ b/cake/tests/cases/libs/overloadable.test.php @@ -36,7 +36,7 @@ uses('overloadable'); class OverloadableTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'OverloadableTest not implemented'); + $this->skipif (true, 'OverloadableTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/security.test.php b/cake/tests/cases/libs/security.test.php index db4d6ad68..a90146c13 100644 --- a/cake/tests/cases/libs/security.test.php +++ b/cake/tests/cases/libs/security.test.php @@ -36,7 +36,7 @@ uses('security'); class SecurityTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'SecurityTest not implemented'); + $this->skipif (true, 'SecurityTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index 30a9dd5f7..77eb939d8 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view class CacheHelperTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'CacheHelper test not implemented'); + $this->skipif (true, 'CacheHelper test not implemented'); } function setUp() { diff --git a/cake/tests/cases/libs/view/helpers/js.test.php b/cake/tests/cases/libs/view/helpers/js.test.php index 557f24d03..1350c88c4 100644 --- a/cake/tests/cases/libs/view/helpers/js.test.php +++ b/cake/tests/cases/libs/view/helpers/js.test.php @@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view class JsTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'JsHelper test not implemented'); + $this->skipif (true, 'JsHelper test not implemented'); } function setUp() { diff --git a/cake/tests/cases/libs/view/helpers/rss.test.php b/cake/tests/cases/libs/view/helpers/rss.test.php index 7e4045488..a578898ec 100644 --- a/cake/tests/cases/libs/view/helpers/rss.test.php +++ b/cake/tests/cases/libs/view/helpers/rss.test.php @@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view class RssTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'RssHelper test not implemented'); + $this->skipif (true, 'RssHelper test not implemented'); } function setUp() { diff --git a/cake/tests/cases/libs/view/helpers/session.test.php b/cake/tests/cases/libs/view/helpers/session.test.php index b70bb55f6..c89a03608 100644 --- a/cake/tests/cases/libs/view/helpers/session.test.php +++ b/cake/tests/cases/libs/view/helpers/session.test.php @@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view class SessionHelperTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'SessionHelper test not implemented'); + $this->skipif (true, 'SessionHelper test not implemented'); } function setUp() { diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index 174827aeb..7e2ec19af 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view class TimeTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'TimeHelper test not implemented'); + $this->skipif (true, 'TimeHelper test not implemented'); } function setUp() { diff --git a/cake/tests/cases/libs/view/helpers/xml.test.php b/cake/tests/cases/libs/view/helpers/xml.test.php index c01a2709d..1d7a1ca2a 100644 --- a/cake/tests/cases/libs/view/helpers/xml.test.php +++ b/cake/tests/cases/libs/view/helpers/xml.test.php @@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view class XmlHelperTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'XmlHelper test not implemented'); + $this->skipif (true, 'XmlHelper test not implemented'); } function setUp() { diff --git a/cake/tests/cases/libs/xml.test.php b/cake/tests/cases/libs/xml.test.php index 429196a49..7d83aa68d 100644 --- a/cake/tests/cases/libs/xml.test.php +++ b/cake/tests/cases/libs/xml.test.php @@ -36,7 +36,7 @@ uses('xml'); class XMLNodeTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'XMLNodeTest not implemented'); + $this->skipif (true, 'XMLNodeTest not implemented'); } } /** @@ -48,7 +48,7 @@ class XMLNodeTest extends UnitTestCase { class XMLTest extends UnitTestCase { function skip() { - $this->skipIf(true, 'XMLTest not implemented'); + $this->skipif (true, 'XMLTest not implemented'); } } ?> \ No newline at end of file diff --git a/cake/tests/lib/cake_reporter.php b/cake/tests/lib/cake_reporter.php index 7a0b59d5e..df94a1d34 100644 --- a/cake/tests/lib/cake_reporter.php +++ b/cake/tests/lib/cake_reporter.php @@ -50,7 +50,7 @@ class CakeHtmlReporter extends HtmlReporter { */ function paintHeader($testName) { $this->sendNoCacheHeaders(); - $baseUrl = BASE_URL; + $baseUrl = BASE; print "