Refactoring dispatcher.

Added test for changes to Dispatcher.
Updating Model::_ _saveMulti(), moved the insert statement to DboSource::insertMulti() this will allow database that do not support multiple inserts in one statement to save data.


git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5460 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-07-25 04:38:28 +00:00
parent 31c3447682
commit 549d86ac23
76 changed files with 812 additions and 409 deletions

View file

@ -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) {

View file

@ -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();
?>
?>

View file

@ -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

View file

@ -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;

View file

@ -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'];

View file

@ -104,4 +104,4 @@ class BakeShell extends Shell {
}
}
?>
?>

View file

@ -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()) {

View file

@ -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;
}

View file

@ -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) {

View file

@ -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;
}

View file

@ -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.

View file

@ -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);
}
}
?>

View file

@ -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);
}

View file

@ -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 {
}
}
?>
?>

View file

@ -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;

View file

@ -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();
}

View file

@ -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';

View file

@ -474,4 +474,4 @@ class I18nModel extends AppModel {
var $useTable = 'i18n';
var $belongsTo = array('Content' => array('className' => 'I18nContent', 'foreignKey' => 'i18n_content_id'));
}
?>
?>

View file

@ -719,4 +719,4 @@ class TreeBehavior extends ModelBehavior {
$model->updateAll(array($field => "{$field} $dir {$shift}"), $conditions);
}
}
?>
?>

View file

@ -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]}");
}
}
}
?>

View file

@ -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]}");
}
}
}
?>

View file

@ -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]}");
}
}
}
?>

View file

@ -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]}");
}
}
}
?>
?>

View file

@ -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]}");
}
}
}
?>

View file

@ -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]}");
}
}
}
?>

View file

@ -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]}");
}
}
}
?>

View file

@ -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}");
}
}
?>
?>

View file

@ -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]);
}
}
}

View file

@ -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;

View file

@ -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);

View file

@ -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 {

View file

@ -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';
}

View file

@ -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']);
}

View file

@ -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);
}
}
?>
?>

View file

@ -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;
}
}
?>
?>

View file

@ -36,7 +36,7 @@ uses('cache');
class CacheTest extends UnitTestCase {
function skip() {
$this->skipIf(true, 'CacheTest not implemented');
$this->skipif (true, 'CacheTest not implemented');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -36,7 +36,7 @@ uses('configure');
class ConfigureTest extends UnitTestCase {
function skip() {
$this->skipIf(true, 'ConfigureTest not implemented');
$this->skipif (true, 'ConfigureTest not implemented');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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() {

View file

@ -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');
}
}
?>

View file

@ -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';

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -36,7 +36,7 @@ uses('debugger');
class DebuggerTest extends UnitTestCase {
function skip() {
$this->skipIf(true, 'ConfigureTest not implemented');
$this->skipif (true, 'ConfigureTest not implemented');
}
}
?>

View file

@ -36,7 +36,7 @@ uses('error');
class ErrorHandlerTest extends UnitTestCase {
function skip() {
$this->skipIf(true, 'ConfigureTest not implemented');
$this->skipif (true, 'ConfigureTest not implemented');
}
}
?>

View file

@ -36,7 +36,7 @@ uses('flay');
class FlayTest extends UnitTestCase {
function skip() {
$this->skipIf(true, 'FlayTest not implemented');
$this->skipif (true, 'FlayTest not implemented');
}
}
?>

View file

@ -36,7 +36,7 @@ uses('i18n');
class I18nTest extends UnitTestCase {
function skip() {
$this->skipIf(true, 'I18nTest not implemented');
$this->skipif (true, 'I18nTest not implemented');
}
}
?>

View file

@ -36,7 +36,7 @@ uses('l10n');
class L10nTest extends UnitTestCase {
function skip() {
$this->skipIf(true, 'L10nTest not implemented');
$this->skipif (true, 'L10nTest not implemented');
}
}
?>

View file

@ -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');
}
}
?>

View file

@ -36,7 +36,7 @@ uses('object');
class ObjectTest extends UnitTestCase {
function skip() {
$this->skipIf(true, 'ObjectTest not implemented');
$this->skipif (true, 'ObjectTest not implemented');
}
}
?>

View file

@ -36,7 +36,7 @@ uses('overloadable');
class OverloadableTest extends UnitTestCase {
function skip() {
$this->skipIf(true, 'OverloadableTest not implemented');
$this->skipif (true, 'OverloadableTest not implemented');
}
}
?>

View file

@ -36,7 +36,7 @@ uses('security');
class SecurityTest extends UnitTestCase {
function skip() {
$this->skipIf(true, 'SecurityTest not implemented');
$this->skipif (true, 'SecurityTest not implemented');
}
}
?>

View file

@ -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() {

View file

@ -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() {

View file

@ -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() {

View file

@ -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() {

View file

@ -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() {

View file

@ -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() {

View file

@ -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');
}
}
?>

View file

@ -50,7 +50,7 @@ class CakeHtmlReporter extends HtmlReporter {
*/
function paintHeader($testName) {
$this->sendNoCacheHeaders();
$baseUrl = BASE_URL;
$baseUrl = BASE;
print "<h2>$testName</h2>\n";
flush();
}
@ -74,4 +74,4 @@ class CakeHtmlReporter extends HtmlReporter {
print "</div>\n";
}
}
?>
?>

View file

@ -31,8 +31,8 @@
<div id="footer">
<!--PLEASE USE ONE OF THE POWERED BY CAKEPHP LOGO-->
<a href="http://www.cakephp.org/" target="_new">
<img src="<?php echo $baseUrl; ?>/img/cake.power.png" alt="CakePHP(tm) :: Rapid Development Framework" height = "15" width = "80" /></a></p>
<img src="<?php echo $baseUrl; ?>img/cake.power.png" alt="CakePHP(tm) :: Rapid Development Framework" height = "15" width = "80" /></a></p>
</div>
</div>
</body>
</html>
</html>

View file

@ -32,7 +32,7 @@
<head>
<meta http-equiv='content-Type' content='text/html; <?php echo $characterSet; ?>' />
<title>CakePHP Test Suite v 1.2.0.0</title>
<link rel="stylesheet" type="text/css" href="<?php echo $baseUrl; ?>/css/cake.generic.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $baseUrl; ?>css/cake.generic.css" />
<style>
h3 {font-size: 150%}
a {font-size: 120%}

View file

@ -365,4 +365,4 @@ class HtmlTestManager extends TestManager {
return $buffer;
}
}
?>
?>

View file

@ -54,24 +54,11 @@
require CORE_PATH . 'cake' . DS . 'basics.php';
require APP_PATH . 'config' . DS . 'core.php';
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
$bootstrap=true;
$uri =setUri();
/**
* As mod_rewrite (or .htaccess files) is not working, we need to take care
* of what would normally be rewritten, i.e. the static files in app/webroot/
*/
if ($uri === '/' || $uri === '/index.php') {
$_GET['url'] = '/';
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
} else {
$elements=explode('/index.php', $uri);
require LIBS . 'object.php';
require LIBS . 'configure.php';
if (!empty($elements[1])) {
$path = $elements[1];
} else {
$path = '/';
}
$_GET['url']=$path;
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
}
$bootstrap = true;
$url = setUrl();
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
?>