mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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:
parent
31c3447682
commit
549d86ac23
76 changed files with 812 additions and 409 deletions
|
@ -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);
|
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') {
|
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
$Dispatcher=new Dispatcher();
|
$Dispatcher = new Dispatcher();
|
||||||
$Dispatcher->dispatch($url);
|
$Dispatcher->dispatch($url);
|
||||||
}
|
}
|
||||||
if (Configure::read() > 0) {
|
if (Configure::read() > 0) {
|
||||||
|
|
|
@ -74,10 +74,11 @@ if (empty( $_GET['output'])) {
|
||||||
$_GET['output'] = 'html';
|
$_GET['output'] = 'html';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('BASE_URL')) {
|
$dispatch =& new Dispatcher();
|
||||||
$dispatch =& new Dispatcher();
|
$dispatch->base = env('SCRIPT_NAME');
|
||||||
define('BASE_URL', $dispatch->baseUrl());
|
$dispatch->baseUrl();
|
||||||
}
|
define('BASE', $dispatch->webroot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Used to determine output to display
|
* Used to determine output to display
|
||||||
|
@ -179,7 +180,7 @@ if (!vendor('simpletest' . DS . 'reporter')) {
|
||||||
function CakePHPTestHeader() {
|
function CakePHPTestHeader() {
|
||||||
switch (CAKE_TEST_OUTPUT) {
|
switch (CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
$baseUrl = BASE_URL;
|
$baseUrl = BASE;
|
||||||
$characterSet = 'ISO-8859-1';
|
$characterSet = 'ISO-8859-1';
|
||||||
include CAKE . 'tests' . DS . 'lib' . DS . 'header.php';
|
include CAKE . 'tests' . DS . 'lib' . DS . 'header.php';
|
||||||
break;
|
break;
|
||||||
|
@ -203,7 +204,7 @@ if (!vendor('simpletest' . DS . 'reporter')) {
|
||||||
function CakePHPTestSuiteFooter() {
|
function CakePHPTestSuiteFooter() {
|
||||||
switch ( CAKE_TEST_OUTPUT) {
|
switch ( CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
$baseUrl = BASE_URL;
|
$baseUrl = BASE;
|
||||||
include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php';
|
include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,6 +320,7 @@
|
||||||
if ($name === null) {
|
if ($name === null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($name, '.') !== false) {
|
if (strpos($name, '.') !== false) {
|
||||||
list($plugin, $name) = explode('.', $name);
|
list($plugin, $name) = explode('.', $name);
|
||||||
|
|
||||||
|
@ -364,7 +365,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$className = $name . 'Controller';
|
$className = $name . 'Controller';
|
||||||
if (!class_exists($className)) {
|
if (class_exists($className)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
$name = Inflector::underscore($className);
|
$name = Inflector::underscore($className);
|
||||||
$controllers = Configure::read('Controllers');
|
$controllers = Configure::read('Controllers');
|
||||||
if (is_array($controllers)) {
|
if (is_array($controllers)) {
|
||||||
|
@ -1003,7 +1006,50 @@
|
||||||
$uri = env('PHP_SELF') . '/' . env('QUERY_STRING');
|
$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
|
* Gets an environment variable from available sources, and provides emulation
|
||||||
|
|
|
@ -36,14 +36,14 @@ if (!defined('PHP5')) {
|
||||||
require CORE_PATH . 'cake' . DS . 'basics.php';
|
require CORE_PATH . 'cake' . DS . 'basics.php';
|
||||||
require APP_PATH . 'config' . DS . 'core.php';
|
require APP_PATH . 'config' . DS . 'core.php';
|
||||||
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
||||||
|
require LIBS . 'object.php';
|
||||||
|
require LIBS . 'configure.php';
|
||||||
}
|
}
|
||||||
$TIME_START = getMicrotime();
|
$TIME_START = getMicrotime();
|
||||||
require LIBS . 'object.php';
|
|
||||||
require LIBS . 'cache.php';
|
require LIBS . 'cache.php';
|
||||||
require LIBS . 'session.php';
|
require LIBS . 'session.php';
|
||||||
require LIBS . 'security.php';
|
require LIBS . 'security.php';
|
||||||
require LIBS . 'inflector.php';
|
require LIBS . 'inflector.php';
|
||||||
require LIBS . 'configure.php';
|
|
||||||
$paths = Configure::getInstance();
|
$paths = Configure::getInstance();
|
||||||
|
|
||||||
if (isset($cakeCache)) {
|
if (isset($cakeCache)) {
|
||||||
|
@ -73,31 +73,7 @@ if (!defined('PHP5')) {
|
||||||
* Get the application path and request URL
|
* Get the application path and request URL
|
||||||
*/
|
*/
|
||||||
if (empty($uri) && defined('BASE_URL')) {
|
if (empty($uri) && defined('BASE_URL')) {
|
||||||
$uri = setUri();
|
$url = setUrl();
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (empty($_GET['url'])) {
|
if (empty($_GET['url'])) {
|
||||||
$url = null;
|
$url = null;
|
||||||
|
|
|
@ -434,7 +434,7 @@ class ShellDispatcher {
|
||||||
if ($this->params['app']{0} == '/') {
|
if ($this->params['app']{0} == '/') {
|
||||||
$root = dirname($this->params['app']);
|
$root = dirname($this->params['app']);
|
||||||
$app = basename($this->params['app']);
|
$app = basename($this->params['app']);
|
||||||
} else if (!empty($this->params['working'])) {
|
} elseif (!empty($this->params['working'])) {
|
||||||
$root = realpath($this->params['working']);
|
$root = realpath($this->params['working']);
|
||||||
}
|
}
|
||||||
$app = $this->params['app'];
|
$app = $this->params['app'];
|
||||||
|
|
|
@ -44,7 +44,7 @@ class ModelTask extends Shell {
|
||||||
$this->__interactive();
|
$this->__interactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($this->args[0])) {
|
if (!empty($this->args[0])) {
|
||||||
$model = $this->args[0];
|
$model = $this->args[0];
|
||||||
if ($this->__bake($model)) {
|
if ($this->__bake($model)) {
|
||||||
if ($this->_checkUnitTest()) {
|
if ($this->_checkUnitTest()) {
|
||||||
|
|
|
@ -66,7 +66,7 @@ class ProjectTask extends Shell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($this->params['skel'])) {
|
if (empty($this->params['skel'])) {
|
||||||
$this->params['skel'] = '';
|
$this->params['skel'] = '';
|
||||||
if (is_dir(CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'console'.DS.'libs'.DS.'templates'.DS.'skel') === true) {
|
if (is_dir(CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'console'.DS.'libs'.DS.'templates'.DS.'skel') === true) {
|
||||||
$this->params['skel'] = CAKE_CORE_INCLUDE_PATH.DS.'cake'.DS.'console'.DS.'libs'.DS.'templates'.DS.'skel';
|
$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);
|
$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;
|
$this->params['working'] = $this->params['root'] . DS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,10 +74,13 @@
|
||||||
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
|
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') {
|
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
$Dispatcher=new Dispatcher();
|
$Dispatcher = new Dispatcher();
|
||||||
$Dispatcher->dispatch($url);
|
$Dispatcher->dispatch($url);
|
||||||
}
|
}
|
||||||
if (Configure::read() > 0) {
|
if (Configure::read() > 0) {
|
||||||
|
|
|
@ -74,10 +74,11 @@ if (empty( $_GET['output'])) {
|
||||||
$_GET['output'] = 'html';
|
$_GET['output'] = 'html';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('BASE_URL')) {
|
$dispatch =& new Dispatcher();
|
||||||
$dispatch =& new Dispatcher();
|
$dispatch->base = env('SCRIPT_NAME');
|
||||||
define('BASE_URL', $dispatch->baseUrl());
|
$dispatch->baseUrl();
|
||||||
}
|
define('BASE', $dispatch->webroot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Used to determine output to display
|
* Used to determine output to display
|
||||||
|
@ -179,7 +180,7 @@ if (!vendor('simpletest' . DS . 'reporter')) {
|
||||||
function CakePHPTestHeader() {
|
function CakePHPTestHeader() {
|
||||||
switch (CAKE_TEST_OUTPUT) {
|
switch (CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
$baseUrl = BASE_URL;
|
$baseUrl = BASE;
|
||||||
$characterSet = 'ISO-8859-1';
|
$characterSet = 'ISO-8859-1';
|
||||||
include CAKE . 'tests' . DS . 'lib' . DS . 'header.php';
|
include CAKE . 'tests' . DS . 'lib' . DS . 'header.php';
|
||||||
break;
|
break;
|
||||||
|
@ -203,7 +204,7 @@ if (!vendor('simpletest' . DS . 'reporter')) {
|
||||||
function CakePHPTestSuiteFooter() {
|
function CakePHPTestSuiteFooter() {
|
||||||
switch ( CAKE_TEST_OUTPUT) {
|
switch ( CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
$baseUrl = BASE_URL;
|
$baseUrl = BASE;
|
||||||
include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php';
|
include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,11 @@ class Dispatcher extends Object {
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
function __construct() {
|
function __construct($url = null) {
|
||||||
parent::__construct();
|
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).
|
* 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()) {
|
function dispatch($url, $additionalParams = array()) {
|
||||||
$params = array_merge($this->parseParams($url), $additionalParams);
|
$params = array_merge($this->parseParams($url), $additionalParams);
|
||||||
$missingController = false;
|
$missingAction = $missingView = $privateAction = false;
|
||||||
$missingAction = false;
|
|
||||||
$missingView = false;
|
|
||||||
$privateAction = false;
|
|
||||||
$this->base = $this->baseUrl();
|
$this->base = $this->baseUrl();
|
||||||
|
|
||||||
if (empty($params['controller'])) {
|
$pluginPath = null;
|
||||||
$missingController = true;
|
if (!empty($params['plugin'])) {
|
||||||
} else {
|
$this->plugin = $params['plugin'];
|
||||||
|
$pluginPath = Inflector::camelize($this->plugin).'.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($params['controller'])) {
|
||||||
$ctrlName = Inflector::camelize($params['controller']);
|
$ctrlName = Inflector::camelize($params['controller']);
|
||||||
$ctrlClass = $ctrlName.'Controller';
|
$ctrlClass = $ctrlName.'Controller';
|
||||||
|
}
|
||||||
|
|
||||||
if (!loadController($ctrlName)) {
|
if (!loadController($pluginPath . $ctrlName)) {
|
||||||
$pluginName = Inflector::camelize($params['action']);
|
|
||||||
if (!loadController($ctrlName . '.' . $pluginName)) {
|
|
||||||
if (preg_match('/([\\.]+)/', $ctrlName)) {
|
if (preg_match('/([\\.]+)/', $ctrlName)) {
|
||||||
Router::setRequestInfo(array($params, array('base' => $this->base, 'webroot' => $this->webroot)));
|
Router::setRequestInfo(array($params, array('base' => $this->base, 'webroot' => $this->webroot)));
|
||||||
|
|
||||||
return $this->cakeError('error404',
|
return $this->cakeError('error404', array(array('url' => strtolower($ctrlName),
|
||||||
array(array('url' => strtolower($ctrlName),
|
|
||||||
'message' => 'Was not found on this server',
|
'message' => 'Was not found on this server',
|
||||||
'base' => $this->base)));
|
'base' => $this->base)));
|
||||||
} elseif (!class_exists($ctrlClass)) {
|
|
||||||
$missingController = true;
|
|
||||||
} else {
|
} else {
|
||||||
$params['plugin'] = null;
|
Router::setRequestInfo(array($params, array('base' => $this->base, 'webroot' => $this->webroot)));
|
||||||
$this->plugin = null;
|
return $this->cakeError('missingController', array(
|
||||||
|
array(
|
||||||
|
'className' => Inflector::camelize($params['controller']."Controller"),
|
||||||
|
'webroot' => $this->webroot,
|
||||||
|
'url' => $url,
|
||||||
|
'base' => $this->base
|
||||||
|
)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$params['plugin'] = Inflector::underscore($ctrlName);
|
$controller =& new $ctrlClass();
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$params['plugin'] = null;
|
|
||||||
$this->plugin = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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']) || !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 (empty($params['action'])) {
|
if (empty($params['action'])) {
|
||||||
|
@ -167,42 +149,22 @@ class Dispatcher extends Object {
|
||||||
$privateAction = true;
|
$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) {
|
$this->here = $this->base . $this->admin . '/' . $url;
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
$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;
|
$privateAction = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($params['action'], $classMethods) && !in_array(strtolower($params['action']), $classMethods)) {
|
if (!in_array(low($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'))) {
|
|
||||||
$missingAction = true;
|
$missingAction = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +176,13 @@ class Dispatcher extends Object {
|
||||||
$controller->here = $this->here;
|
$controller->here = $this->here;
|
||||||
$controller->webroot = $this->webroot;
|
$controller->webroot = $this->webroot;
|
||||||
$controller->params = $params;
|
$controller->params = $params;
|
||||||
|
$controller->plugin = $this->plugin;
|
||||||
$controller->action = $params['action'];
|
$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'])) {
|
if (!empty($controller->params['data'])) {
|
||||||
$controller->data =& $controller->params['data'];
|
$controller->data =& $controller->params['data'];
|
||||||
|
@ -222,65 +190,10 @@ class Dispatcher extends Object {
|
||||||
$controller->data = null;
|
$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'])) {
|
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 (isset($params['layout'])) {
|
||||||
if ($params['layout'] === '') {
|
if ($params['layout'] === '') {
|
||||||
$controller->autoLayout = false;
|
$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) {
|
foreach (array('components', 'helpers') as $var) {
|
||||||
if (isset($params[$var]) && !empty($params[$var]) && is_array($controller->{$var})) {
|
if (isset($params[$var]) && !empty($params[$var]) && is_array($controller->{$var})) {
|
||||||
$diff = array_diff($params[$var], $controller->{$var});
|
$diff = array_diff($params[$var], $controller->{$var});
|
||||||
|
@ -304,19 +221,6 @@ class Dispatcher extends Object {
|
||||||
$controller->_initComponents();
|
$controller->_initComponents();
|
||||||
$controller->constructClasses();
|
$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) {
|
if ($privateAction) {
|
||||||
$this->start($controller);
|
$this->start($controller);
|
||||||
return $this->cakeError('privateAction', array(
|
return $this->cakeError('privateAction', array(
|
||||||
|
@ -349,12 +253,24 @@ class Dispatcher extends Object {
|
||||||
if ($missingAction && in_array('scaffold', array_keys($classVars))) {
|
if ($missingAction && in_array('scaffold', array_keys($classVars))) {
|
||||||
uses('controller'. DS . 'scaffold');
|
uses('controller'. DS . 'scaffold');
|
||||||
return new Scaffold($controller, $params);
|
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 {
|
} else {
|
||||||
$output = call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
|
$output = call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($controller->autoRender) {
|
if ($controller->autoRender) {
|
||||||
$output = $controller->render();
|
$output = $controller->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
$controller->output =& $output;
|
$controller->output =& $output;
|
||||||
|
|
||||||
foreach ($controller->components as $c) {
|
foreach ($controller->components as $c) {
|
||||||
|
@ -417,13 +333,13 @@ class Dispatcher extends Object {
|
||||||
include CONFIGS.'routes.php';
|
include CONFIGS.'routes.php';
|
||||||
$params = Router::parse($fromUrl);
|
$params = Router::parse($fromUrl);
|
||||||
|
|
||||||
|
if (isset($_POST)) {
|
||||||
if (ini_get('magic_quotes_gpc') == 1) {
|
if (ini_get('magic_quotes_gpc') == 1) {
|
||||||
if (!empty($_POST)) {
|
|
||||||
$params['form'] = stripslashes_deep($_POST);
|
$params['form'] = stripslashes_deep($_POST);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$params['form'] = $_POST;
|
$params['form'] = $_POST;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($params['form']['data'])) {
|
if (isset($params['form']['data'])) {
|
||||||
$params['data'] = Router::stripEscape($params['form']['data']);
|
$params['data'] = Router::stripEscape($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'];
|
$params['webservices'] = empty($params['webservices']) ? null : $params['webservices'];
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns a base URL.
|
* Returns a base URL and sets the proper webroot
|
||||||
*
|
*
|
||||||
* @return string Base URL
|
* @return string Base URL
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function baseUrl() {
|
function baseUrl() {
|
||||||
$htaccess = null;
|
$base = $this->base;
|
||||||
$base = $this->admin;
|
|
||||||
$this->webroot = '';
|
|
||||||
|
|
||||||
if (defined('BASE_URL')) {
|
|
||||||
$base = BASE_URL.$this->admin;
|
|
||||||
}
|
|
||||||
|
|
||||||
$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 = '/';
|
$this->webroot = '/';
|
||||||
|
|
||||||
if (preg_match('/^(.*)\/index\.php$/', $scriptName, $r)) {
|
$baseUrl = Configure::read('baseUrl');
|
||||||
|
$app = Configure::read('app');
|
||||||
|
$webroot = Configure::read('webroot');
|
||||||
|
|
||||||
if (!empty($r[1])) {
|
$file = $script = null;
|
||||||
return $base.$r[1];
|
if (!$baseUrl && $this->base == false) {
|
||||||
}
|
$docRoot = env('DOCUMENT_ROOT');
|
||||||
}
|
$script = env('SCRIPT_FILENAME');
|
||||||
} else {
|
$base = r($docRoot, '', $script);
|
||||||
if (defined('BASE_URL')) {
|
} elseif ($baseUrl && $this->base == false) {
|
||||||
$webroot = setUri();
|
$base = $baseUrl;
|
||||||
$htaccess = preg_replace('/(?:'.APP_DIR.'\\/(.*)|index\\.php(.*))/i', '', $webroot).APP_DIR.'/'.$webrootDirName.'/';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/^(.*)\\/'.$appDirName.'\\/'.$webrootDirName.'\\/index\\.php$/', $scriptName, $regs)) {
|
$file = basename($base);
|
||||||
|
if (($baseUrl || $this->base) && strpos($file, '.php') !== false) {
|
||||||
if (APP_DIR === 'app') {
|
$baseUrl = true;
|
||||||
$appDir = null;
|
$file = '/'. $file;
|
||||||
} 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)) {
|
$base = dirname($base);
|
||||||
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[0].'/';
|
|
||||||
return $base.$regs[0];
|
|
||||||
|
|
||||||
} else {
|
if ($base == '/' || $base == '.') {
|
||||||
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = '/';
|
$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;
|
return $base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($baseUrl && $base == '') {
|
||||||
|
return $file;
|
||||||
}
|
}
|
||||||
return $base;
|
|
||||||
|
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.
|
* Restructure params in case we're serving a plugin.
|
||||||
|
|
|
@ -452,6 +452,14 @@ class Configure extends Object {
|
||||||
$_this->__buildHelperPaths($helperPaths);
|
$_this->__buildHelperPaths($helperPaths);
|
||||||
$_this->__buildComponentPaths($componentPaths);
|
$_this->__buildComponentPaths($componentPaths);
|
||||||
$_this->__buildBehaviorPaths($behaviorPaths);
|
$_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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -54,8 +54,8 @@ class AclComponent extends Object {
|
||||||
function &getACL() {
|
function &getACL() {
|
||||||
if ($this->_instance == null) {
|
if ($this->_instance == null) {
|
||||||
$name = $this->name;
|
$name = $this->name;
|
||||||
if(!class_exists($name)) {
|
if (!class_exists($name)) {
|
||||||
if(loadComponent($name)) {
|
if (loadComponent($name)) {
|
||||||
if (strpos($name, '.') !== false) {
|
if (strpos($name, '.') !== false) {
|
||||||
list($plugin, $name) = explode('.', $name);
|
list($plugin, $name) = explode('.', $name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,10 +300,10 @@ class AuthComponent extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->authorize) {
|
if ($this->authorize) {
|
||||||
extract($this->__authType());
|
extract($this->__authType());
|
||||||
if(in_array($type, array('crud', 'actions'))) {
|
if (in_array($type, array('crud', 'actions'))) {
|
||||||
if(isset($controller->Acl)) {
|
if (isset($controller->Acl)) {
|
||||||
$this->Acl =& $controller->Acl;
|
$this->Acl =& $controller->Acl;
|
||||||
if ($this->isAuthorized($type)) {
|
if ($this->isAuthorized($type)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -311,8 +311,8 @@ class AuthComponent extends Object {
|
||||||
} else {
|
} else {
|
||||||
trigger_error(__('Could not find AclComponent. Please include Acl in Controller::$components.', true), E_USER_WARNING);
|
trigger_error(__('Could not find AclComponent. Please include Acl in Controller::$components.', true), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
} else if($type == 'model') {
|
} elseif ($type == 'model') {
|
||||||
if(!isset($object)) {
|
if (!isset($object)) {
|
||||||
if (isset($controller->{$controller->modelClass}) && is_object($controller->{$controller->modelClass})) {
|
if (isset($controller->{$controller->modelClass}) && is_object($controller->{$controller->modelClass})) {
|
||||||
$object = $controller->modelClass;
|
$object = $controller->modelClass;
|
||||||
} elseif (!empty($controller->uses) && isset($controller->{$controller->uses[0]}) && is_object($controller->{$controller->uses[0]})) {
|
} 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)) {
|
if ($this->isAuthorized($type, null, $object)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if($type == 'controller'){
|
} elseif ($type == 'controller'){
|
||||||
if($controller->isAuthorized()) {
|
if ($controller->isAuthorized()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,7 +377,7 @@ class AuthComponent extends Object {
|
||||||
|
|
||||||
extract($this->__authType(array($type => $object)));
|
extract($this->__authType(array($type => $object)));
|
||||||
|
|
||||||
if(!$object) {
|
if (!$object) {
|
||||||
$object = $this->objectModel;
|
$object = $this->objectModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,14 +395,14 @@ class AuthComponent extends Object {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'model':
|
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);
|
trigger_error(__(sprintf('Could not find %s. Set AuthComponent::$objectModel in beforeFilter() or pass object name.', $this->objectModel), true), E_USER_WARNING);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$model = $this->getModel($object);
|
$model = $this->getModel($object);
|
||||||
if (method_exists($model, 'isAuthorized')) {
|
if (method_exists($model, 'isAuthorized')) {
|
||||||
$valid = $model->isAuthorized($user, $this->action(':controller'), $this->action(':action'));
|
$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);
|
trigger_error(__(sprintf('%s::isAuthorized() is not defined.', $model), true), E_USER_WARNING);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -626,7 +626,7 @@ class AuthComponent extends Object {
|
||||||
*/
|
*/
|
||||||
function &getModel($name = null) {
|
function &getModel($name = null) {
|
||||||
$model = null;
|
$model = null;
|
||||||
if(!$name) {
|
if (!$name) {
|
||||||
$name = $this->userModel;
|
$name = $this->userModel;
|
||||||
}
|
}
|
||||||
if (!ClassRegistry::isKeySet($name)) {
|
if (!ClassRegistry::isKeySet($name)) {
|
||||||
|
@ -768,7 +768,7 @@ class AuthComponent extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
$paths = Router::getPaths();
|
$paths = Router::getPaths();
|
||||||
if(stristr($url, $paths['base'])) {
|
if (stristr($url, $paths['base'])) {
|
||||||
$url = r($paths['base'], '', $url);
|
$url = r($paths['base'], '', $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ class RequestHandlerComponent extends Object {
|
||||||
*/
|
*/
|
||||||
function isMobile() {
|
function isMobile() {
|
||||||
preg_match('/' . REQUEST_MOBILE_UA . '/i', env('HTTP_USER_AGENT'), $match);
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -495,7 +495,7 @@ class SecurityComponent extends Object {
|
||||||
if ($string === '_') {
|
if ($string === '_') {
|
||||||
$newKey = substr($key, 1);
|
$newKey = substr($key, 1);
|
||||||
|
|
||||||
if(!isset($controller->data[$newKey])) {
|
if (!isset($controller->data[$newKey])) {
|
||||||
$controller->data[$newKey] = array();
|
$controller->data[$newKey] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ class Scaffold extends Object {
|
||||||
} else {
|
} else {
|
||||||
return $this->controller->flash(sprintf(__("No id set for %s::edit()", true), Inflector::humanize($this->modelKey)), $this->redirect);
|
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];
|
$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';
|
return $path . $this->viewPath . DS . 'scaffolds' . DS . $this->subDir . $type . $scaffoldAction . '.thtml';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($action === 'add') {
|
if ($action === 'add') {
|
||||||
$action = 'edit';
|
$action = 'edit';
|
||||||
}
|
}
|
||||||
return LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . $action . '.ctp';
|
return LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . $action . '.ctp';
|
||||||
|
|
|
@ -421,6 +421,18 @@ class DboAdodb extends DboSource {
|
||||||
return false;
|
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]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -496,5 +496,18 @@ class DboFirebird extends DboSource {
|
||||||
return false;
|
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]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -585,6 +585,18 @@ class DboMssql extends DboSource {
|
||||||
$query = trim(r($search, $replace, $schema));
|
$query = trim(r($search, $replace, $schema));
|
||||||
return $query;
|
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]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -145,11 +145,11 @@ class DboOracle extends DboSource {
|
||||||
|
|
||||||
if ($this->connection) {
|
if ($this->connection) {
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
if(!empty($config['nls_sort'])) {
|
if (!empty($config['nls_sort'])) {
|
||||||
$this->execute('ALTER SESSION SET NLS_SORT='.$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_COMP='.$config['nls_comp']);
|
||||||
}
|
}
|
||||||
$this->execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
|
$this->execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
|
||||||
|
@ -165,7 +165,7 @@ class DboOracle extends DboSource {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function setEncoding($lang) {
|
function setEncoding($lang) {
|
||||||
if(!$this->execute('ALTER SESSION SET NLS_LANGUAGE='.$lang)) {
|
if (!$this->execute('ALTER SESSION SET NLS_LANGUAGE='.$lang)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -177,11 +177,11 @@ class DboOracle extends DboSource {
|
||||||
*/
|
*/
|
||||||
function getEncoding() {
|
function getEncoding() {
|
||||||
$sql = 'SELECT VALUE FROM NLS_SESSION_PARAMETERS WHERE PARAMETER=\'NLS_LANGUAGE\'';
|
$sql = 'SELECT VALUE FROM NLS_SESSION_PARAMETERS WHERE PARAMETER=\'NLS_LANGUAGE\'';
|
||||||
if(!$this->execute($sql)) {
|
if (!$this->execute($sql)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$row = $this->fetchRow()) {
|
if (!$row = $this->fetchRow()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $row[0]['VALUE'];
|
return $row[0]['VALUE'];
|
||||||
|
@ -193,7 +193,7 @@ class DboOracle extends DboSource {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function disconnect() {
|
function disconnect() {
|
||||||
if($this->connection) {
|
if ($this->connection) {
|
||||||
$this->connected = !ocilogoff($this->connection);
|
$this->connected = !ocilogoff($this->connection);
|
||||||
return !$this->connected;
|
return !$this->connected;
|
||||||
}
|
}
|
||||||
|
@ -217,17 +217,17 @@ class DboOracle extends DboSource {
|
||||||
$lastTableName = '';
|
$lastTableName = '';
|
||||||
|
|
||||||
foreach($fields as $key => $value) {
|
foreach($fields as $key => $value) {
|
||||||
if($value != 'COUNT(*) AS count') {
|
if ($value != 'COUNT(*) AS count') {
|
||||||
if(preg_match('/\s+(\w+(\.\w+)*)$/', $value, $matches)) {
|
if (preg_match('/\s+(\w+(\.\w+)*)$/', $value, $matches)) {
|
||||||
$fields[$key] = $matches[1];
|
$fields[$key] = $matches[1];
|
||||||
|
|
||||||
if(preg_match('/^(\w+\.)/', $value, $matches)) {
|
if (preg_match('/^(\w+\.)/', $value, $matches)) {
|
||||||
$fields[$key] = $matches[1] . $fields[$key];
|
$fields[$key] = $matches[1] . $fields[$key];
|
||||||
$lastTableName = $matches[1];
|
$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];
|
$fields[$key] = isset($matches[4]) ? $matches[2] . '.' . $matches[4] : $matches[1];
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -237,7 +237,7 @@ class DboOracle extends DboSource {
|
||||||
|
|
||||||
foreach($fields as $f) {
|
foreach($fields as $f) {
|
||||||
$e = explode('.', $f);
|
$e = explode('.', $f);
|
||||||
if(count($e) > 1) {
|
if (count($e) > 1) {
|
||||||
$table = $e[0];
|
$table = $e[0];
|
||||||
$field = strtolower($e[1]);
|
$field = strtolower($e[1]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -278,17 +278,17 @@ class DboOracle extends DboSource {
|
||||||
*/
|
*/
|
||||||
function _execute($sql) {
|
function _execute($sql) {
|
||||||
$this->_statementId = ociparse($this->connection, $sql);
|
$this->_statementId = ociparse($this->connection, $sql);
|
||||||
if(!$this->_statementId) {
|
if (!$this->_statementId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->__transactionStarted) {
|
if ($this->__transactionStarted) {
|
||||||
$mode = OCI_DEFAULT;
|
$mode = OCI_DEFAULT;
|
||||||
} else {
|
} else {
|
||||||
$mode = OCI_COMMIT_ON_SUCCESS;
|
$mode = OCI_COMMIT_ON_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ociexecute($this->_statementId, $mode)) {
|
if (!ociexecute($this->_statementId, $mode)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ class DboOracle extends DboSource {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->_limit >= 1) {
|
if ($this->_limit >= 1) {
|
||||||
ocisetprefetch($this->_statementId, $this->_limit);
|
ocisetprefetch($this->_statementId, $this->_limit);
|
||||||
} else {
|
} else {
|
||||||
ocisetprefetch($this->_statementId, 3000);
|
ocisetprefetch($this->_statementId, 3000);
|
||||||
|
@ -319,7 +319,7 @@ class DboOracle extends DboSource {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function fetchRow() {
|
function fetchRow() {
|
||||||
if($this->_currentRow >= $this->_numRows) {
|
if ($this->_currentRow >= $this->_numRows) {
|
||||||
ocifreestatement($this->_statementId);
|
ocifreestatement($this->_statementId);
|
||||||
$this->_map = null;
|
$this->_map = null;
|
||||||
$this->_results = null;
|
$this->_results = null;
|
||||||
|
@ -332,7 +332,7 @@ class DboOracle extends DboSource {
|
||||||
foreach($this->_results[$this->_currentRow] as $index => $field) {
|
foreach($this->_results[$this->_currentRow] as $index => $field) {
|
||||||
list($table, $column) = $this->_map[$index];
|
list($table, $column) = $this->_map[$index];
|
||||||
|
|
||||||
if(strpos($column, ' count')) {
|
if (strpos($column, ' count')) {
|
||||||
$resultRow[0]['count'] = $field;
|
$resultRow[0]['count'] = $field;
|
||||||
} else {
|
} else {
|
||||||
$resultRow[$table][$column] = $this->_results[$this->_currentRow][$index];
|
$resultRow[$table][$column] = $this->_results[$this->_currentRow][$index];
|
||||||
|
@ -350,7 +350,7 @@ class DboOracle extends DboSource {
|
||||||
*/
|
*/
|
||||||
function sequenceExists($sequence) {
|
function sequenceExists($sequence) {
|
||||||
$sql = "SELECT SEQUENCE_NAME FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '$sequence'";
|
$sql = "SELECT SEQUENCE_NAME FROM USER_SEQUENCES WHERE SEQUENCE_NAME = '$sequence'";
|
||||||
if(!$this->execute($sql)) {
|
if (!$this->execute($sql)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $this->fetchRow();
|
return $this->fetchRow();
|
||||||
|
@ -386,12 +386,12 @@ class DboOracle extends DboSource {
|
||||||
*/
|
*/
|
||||||
function listSources() {
|
function listSources() {
|
||||||
$cache = parent::listSources();
|
$cache = parent::listSources();
|
||||||
if($cache != null) {
|
if ($cache != null) {
|
||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
$sql = 'SELECT view_name AS name FROM user_views UNION SELECT table_name AS name FROM user_tables';
|
$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;
|
return false;
|
||||||
}
|
}
|
||||||
$sources = array();
|
$sources = array();
|
||||||
|
@ -412,13 +412,13 @@ class DboOracle extends DboSource {
|
||||||
function describe(&$model) {
|
function describe(&$model) {
|
||||||
$cache = parent::describe($model);
|
$cache = parent::describe($model);
|
||||||
|
|
||||||
if($cache != null) {
|
if ($cache != null) {
|
||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
$sql = 'SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH FROM user_tab_columns WHERE table_name = \'';
|
$sql = 'SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH FROM user_tab_columns WHERE table_name = \'';
|
||||||
$sql .= strtoupper($this->fullTableName($model)) . '\'';
|
$sql .= strtoupper($this->fullTableName($model)) . '\'';
|
||||||
|
|
||||||
if(!$this->execute($sql)) {
|
if (!$this->execute($sql)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$fields = array();
|
$fields = array();
|
||||||
|
@ -494,10 +494,10 @@ class DboOracle extends DboSource {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function column($real) {
|
function column($real) {
|
||||||
if(is_array($real)) {
|
if (is_array($real)) {
|
||||||
$col = $real['name'];
|
$col = $real['name'];
|
||||||
|
|
||||||
if(isset($real['limit'])) {
|
if (isset($real['limit'])) {
|
||||||
$col .= '('.$real['limit'].')';
|
$col .= '('.$real['limit'].')';
|
||||||
}
|
}
|
||||||
return $col;
|
return $col;
|
||||||
|
@ -508,28 +508,28 @@ class DboOracle extends DboSource {
|
||||||
$limit = null;
|
$limit = null;
|
||||||
|
|
||||||
@list($col, $limit) = explode('(', $col);
|
@list($col, $limit) = explode('(', $col);
|
||||||
if(in_array($col, array('date', 'timestamp'))) {
|
if (in_array($col, array('date', 'timestamp'))) {
|
||||||
return $col;
|
return $col;
|
||||||
}
|
}
|
||||||
if(strpos($col, 'number') !== false) {
|
if (strpos($col, 'number') !== false) {
|
||||||
return 'integer';
|
return 'integer';
|
||||||
}
|
}
|
||||||
if(strpos($col, 'integer') !== false) {
|
if (strpos($col, 'integer') !== false) {
|
||||||
return 'integer';
|
return 'integer';
|
||||||
}
|
}
|
||||||
if(strpos($col, 'char') !== false) {
|
if (strpos($col, 'char') !== false) {
|
||||||
return 'string';
|
return 'string';
|
||||||
}
|
}
|
||||||
if(strpos($col, 'text') !== false) {
|
if (strpos($col, 'text') !== false) {
|
||||||
return 'text';
|
return 'text';
|
||||||
}
|
}
|
||||||
if(strpos($col, 'blob') !== false) {
|
if (strpos($col, 'blob') !== false) {
|
||||||
return 'binary';
|
return 'binary';
|
||||||
}
|
}
|
||||||
if(in_array($col, array('float', 'double', 'decimal'))) {
|
if (in_array($col, array('float', 'double', 'decimal'))) {
|
||||||
return 'float';
|
return 'float';
|
||||||
}
|
}
|
||||||
if($col == 'boolean') {
|
if ($col == 'boolean') {
|
||||||
return $col;
|
return $col;
|
||||||
}
|
}
|
||||||
return 'text';
|
return 'text';
|
||||||
|
@ -552,7 +552,7 @@ class DboOracle extends DboSource {
|
||||||
return 'NULL';
|
return 'NULL';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data === '') {
|
if ($data === '') {
|
||||||
return "''";
|
return "''";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ class DboOracle extends DboSource {
|
||||||
case 'integer' :
|
case 'integer' :
|
||||||
case 'float' :
|
case 'float' :
|
||||||
case null :
|
case null :
|
||||||
if(is_numeric($data)) {
|
if (is_numeric($data)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -585,7 +585,7 @@ class DboOracle extends DboSource {
|
||||||
$sequence = (!empty($this->sequence)) ? $this->sequence : $source . '_seq';
|
$sequence = (!empty($this->sequence)) ? $this->sequence : $source . '_seq';
|
||||||
$sql = "SELECT $sequence.currval FROM dual";
|
$sql = "SELECT $sequence.currval FROM dual";
|
||||||
|
|
||||||
if(!$this->execute($sql)) {
|
if (!$this->execute($sql)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ class DboOracle extends DboSource {
|
||||||
function lastError() {
|
function lastError() {
|
||||||
$errors = ocierror();
|
$errors = ocierror();
|
||||||
|
|
||||||
if(($errors != null) && (isset($errors["message"]))) {
|
if (($errors != null) && (isset($errors["message"]))) {
|
||||||
return($errors["message"]);
|
return($errors["message"]);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -667,6 +667,18 @@ class DboOracle extends DboSource {
|
||||||
}
|
}
|
||||||
return $out;
|
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]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -224,5 +224,18 @@ class DboPear extends DboSource{
|
||||||
function selectLimit($limit, $offset = '0') {
|
function selectLimit($limit, $offset = '0') {
|
||||||
return ' ' . $this->_pear->modifyLimitQuery('', $offset, $limit);
|
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]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -393,6 +393,18 @@ class DboSqlite extends DboSource {
|
||||||
}
|
}
|
||||||
return null;
|
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]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -392,5 +392,18 @@ class DboSybase extends DboSource {
|
||||||
$query = trim(r($search, $replace, $schema));
|
$query = trim(r($search, $replace, $schema));
|
||||||
return $query;
|
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]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -1569,11 +1569,11 @@ class DboSource extends DataSource {
|
||||||
} elseif (!isset($match['2'])) {
|
} elseif (!isset($match['2'])) {
|
||||||
$match['1'] = ' = ';
|
$match['1'] = ' = ';
|
||||||
$match['2'] = $match['0'];
|
$match['2'] = $match['0'];
|
||||||
} else if(low($mValue) == 'not') {
|
} elseif (low($mValue) == 'not') {
|
||||||
$not = $this->conditionKeysToString(array($mValue => array($key => $match[2])), $quoteValues);
|
$not = $this->conditionKeysToString(array($mValue => array($key => $match[2])), $quoteValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($not) {
|
if ($not) {
|
||||||
$data = $not[0];
|
$data = $not[0];
|
||||||
} elseif (strpos($match['2'], '-!') === 0) {
|
} elseif (strpos($match['2'], '-!') === 0) {
|
||||||
$match['2'] = str_replace('-!', '', $match['2']);
|
$match['2'] = str_replace('-!', '', $match['2']);
|
||||||
|
@ -1814,6 +1814,16 @@ class DboSource extends DataSource {
|
||||||
$this->close();
|
$this->close();
|
||||||
parent::__destruct();
|
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}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1111,8 +1111,7 @@ class Model extends Overloadable {
|
||||||
$db->query("DELETE FROM {$table} WHERE {$mainKey[$loopAssoc]} = '{$id}'");
|
$db->query("DELETE FROM {$table} WHERE {$mainKey[$loopAssoc]} = '{$id}'");
|
||||||
|
|
||||||
if (!empty($newValue[$loopAssoc])) {
|
if (!empty($newValue[$loopAssoc])) {
|
||||||
$insertValues = implode(', ', $newValue[$loopAssoc]);
|
$db->insertMulti($table, $fields[$loopAssoc], $newValue[$loopAssoc]);
|
||||||
$db->query("INSERT INTO {$table} ({$fields[$loopAssoc]}) VALUES {$insertValues};");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -670,7 +670,7 @@ class Router extends Object {
|
||||||
if ($full) {
|
if ($full) {
|
||||||
$output = FULL_BASE_URL . $output;
|
$output = FULL_BASE_URL . $output;
|
||||||
}
|
}
|
||||||
if(!empty($extension) && substr($output, -1) == '/') {
|
if (!empty($extension) && substr($output, -1) == '/') {
|
||||||
$output = substr($output, 0, -1);
|
$output = substr($output, 0, -1);
|
||||||
}
|
}
|
||||||
return $output . $extension . $_this->queryString($q) . $frag;
|
return $output . $extension . $_this->queryString($q) . $frag;
|
||||||
|
|
|
@ -72,7 +72,7 @@ class Sanitize{
|
||||||
*/
|
*/
|
||||||
function escape($string, $connection = 'default') {
|
function escape($string, $connection = 'default') {
|
||||||
$db = ConnectionManager::getDataSource($connection);
|
$db = ConnectionManager::getDataSource($connection);
|
||||||
if(is_numeric($string)) {
|
if (is_numeric($string)) {
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
$string = substr($db->value($string), 1);
|
$string = substr($db->value($string), 1);
|
||||||
|
|
|
@ -622,7 +622,7 @@ class Set extends Object {
|
||||||
$path2 = $path1;
|
$path2 = $path1;
|
||||||
$path1 = $data;
|
$path1 = $data;
|
||||||
$data = $this->get();
|
$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;
|
$path2 = $path1;
|
||||||
$path1 = $data;
|
$path1 = $data;
|
||||||
$data = $this->get();
|
$data = $this->get();
|
||||||
|
@ -638,7 +638,7 @@ class Set extends Object {
|
||||||
$vals = Set::extract($data, $path2);
|
$vals = Set::extract($data, $path2);
|
||||||
} else {
|
} else {
|
||||||
$count = count($keys);
|
$count = count($keys);
|
||||||
for($i=0; $i < $count; $i++) {
|
for ($i=0; $i < $count; $i++) {
|
||||||
$vals[$i] = null;
|
$vals[$i] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -709,7 +709,7 @@ class Set extends Object {
|
||||||
}
|
}
|
||||||
$return = $object;
|
$return = $object;
|
||||||
|
|
||||||
if(!empty($merge)) {
|
if (!empty($merge)) {
|
||||||
$mergeKeys = array_keys($merge);
|
$mergeKeys = array_keys($merge);
|
||||||
$objectKeys = array_keys($object);
|
$objectKeys = array_keys($object);
|
||||||
$count = count($mergeKeys);
|
$count = count($mergeKeys);
|
||||||
|
@ -720,8 +720,8 @@ class Set extends Object {
|
||||||
$loop = $count1;
|
$loop = $count1;
|
||||||
|
|
||||||
for ($ii = 0; $ii < $loop; $ii++) {
|
for ($ii = 0; $ii < $loop; $ii++) {
|
||||||
if(is_array($object[$objectKeys[$ii]])) {
|
if (is_array($object[$objectKeys[$ii]])) {
|
||||||
if(array_key_exists($objectKeys[$ii], $object[$objectKeys[$ii]])) {
|
if (array_key_exists($objectKeys[$ii], $object[$objectKeys[$ii]])) {
|
||||||
unset($change[$objectKeys[$ii]][$objectKeys[$ii]]);
|
unset($change[$objectKeys[$ii]][$objectKeys[$ii]]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -730,8 +730,8 @@ class Set extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($objectKeys as $key => $value) {
|
foreach ($objectKeys as $key => $value) {
|
||||||
if(is_array($object[$value])) {
|
if (is_array($object[$value])) {
|
||||||
if(array_key_exists($mergeKeys[$i], $object[$value])) {
|
if (array_key_exists($mergeKeys[$i], $object[$value])) {
|
||||||
unset($change[$value][$mergeKeys[$i]]);
|
unset($change[$value][$mergeKeys[$i]]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -466,12 +466,12 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($options['type']) && $options['type'] == 'radio') {
|
if (isset($options['type']) && $options['type'] == 'radio') {
|
||||||
if(!isset($options['options']) && isset($options['value'])) {
|
if (!isset($options['options']) && isset($options['value'])) {
|
||||||
$radioOptions = array($options['value']);
|
$radioOptions = array($options['value']);
|
||||||
unset($options['value']);
|
unset($options['value']);
|
||||||
} else if(isset($options['options'])) {
|
} elseif (isset($options['options'])) {
|
||||||
if(is_array($options['options'])) {
|
if (is_array($options['options'])) {
|
||||||
$radioOptions = $options['options'];
|
$radioOptions = $options['options'];
|
||||||
} else {
|
} else {
|
||||||
$radioOptions = array($options['options']);
|
$radioOptions = array($options['options']);
|
||||||
|
@ -480,8 +480,8 @@ class FormHelper extends AppHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
$inBetween = null;
|
$inBetween = null;
|
||||||
if(isset($options['inbetween'])) {
|
if (isset($options['inbetween'])) {
|
||||||
if(!empty($options['inbetween'])) {
|
if (!empty($options['inbetween'])) {
|
||||||
$inBetween = $options['inbetween'];
|
$inBetween = $options['inbetween'];
|
||||||
}
|
}
|
||||||
unset($options['inbetween']);
|
unset($options['inbetween']);
|
||||||
|
@ -731,9 +731,9 @@ class FormHelper extends AppHelper {
|
||||||
foreach ($options as $optValue => $optTitle) {
|
foreach ($options as $optValue => $optTitle) {
|
||||||
$optionsHere = array('value' => $optValue);
|
$optionsHere = array('value' => $optValue);
|
||||||
|
|
||||||
if(empty($value) && $count == 0) {
|
if (empty($value) && $count == 0) {
|
||||||
$optionsHere['checked'] = 'checked';
|
$optionsHere['checked'] = 'checked';
|
||||||
} else if (!empty($value) && $optValue == $value) {
|
} elseif (!empty($value) && $optValue == $value) {
|
||||||
$optionsHere['checked'] = 'checked';
|
$optionsHere['checked'] = 'checked';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ class NumberHelper extends AppHelper {
|
||||||
$seperator = $options;
|
$seperator = $options;
|
||||||
}
|
}
|
||||||
$decimals = '.';
|
$decimals = '.';
|
||||||
if(!is_array($options) && in_array( $options, $seperators)) {
|
if (!is_array($options) && in_array( $options, $seperators)) {
|
||||||
$decimals = $options;
|
$decimals = $options;
|
||||||
}
|
}
|
||||||
$escape = true;
|
$escape = true;
|
||||||
|
@ -130,7 +130,7 @@ class NumberHelper extends AppHelper {
|
||||||
unset($options['before']);
|
unset($options['before']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($options['decimals'])) {
|
if (isset($options['decimals'])) {
|
||||||
$decimals = $options['decimals'];
|
$decimals = $options['decimals'];
|
||||||
unset($options['decimals']);
|
unset($options['decimals']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,62 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @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.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -35,6 +90,15 @@
|
||||||
*/
|
*/
|
||||||
class DispatcherTest extends UnitTestCase {
|
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() {
|
function testParseParamsWithoutZerosAndEmptyPost() {
|
||||||
$dispatcher =& new Dispatcher();
|
$dispatcher =& new Dispatcher();
|
||||||
$test = $dispatcher->parseParams("/testcontroller/testaction/params1/params2/params3");
|
$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(?:000030)\\z/', $test['pass'][4]);
|
||||||
$this->assertPattern('/\\A(?:0000400)\\z/', $test['pass'][5]);
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('cache');
|
||||||
class CacheTest extends UnitTestCase {
|
class CacheTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'CacheTest not implemented');
|
$this->skipif (true, 'CacheTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
2
cake/tests/cases/libs/cache/apc.test.php
vendored
2
cake/tests/cases/libs/cache/apc.test.php
vendored
|
@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'apc');
|
||||||
class APCEngineTest extends UnitTestCase {
|
class APCEngineTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'APCEngineTest not implemented');
|
$this->skipif (true, 'APCEngineTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
2
cake/tests/cases/libs/cache/file.test.php
vendored
2
cake/tests/cases/libs/cache/file.test.php
vendored
|
@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'file');
|
||||||
class FileEngineTest extends UnitTestCase {
|
class FileEngineTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'FileEngineTest not implemented');
|
$this->skipif (true, 'FileEngineTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'memcache');
|
||||||
class MemcacheEngineTest extends UnitTestCase {
|
class MemcacheEngineTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'MemcacheEngineTest not implemented');
|
$this->skipif (true, 'MemcacheEngineTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
2
cake/tests/cases/libs/cache/model.test.php
vendored
2
cake/tests/cases/libs/cache/model.test.php
vendored
|
@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'model');
|
||||||
class ModelEngineTest extends UnitTestCase {
|
class ModelEngineTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ModelEngineTest not implemented');
|
$this->skipif (true, 'ModelEngineTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
2
cake/tests/cases/libs/cache/xcache.test.php
vendored
2
cake/tests/cases/libs/cache/xcache.test.php
vendored
|
@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'xcache');
|
||||||
class XcacheEngineTest extends UnitTestCase {
|
class XcacheEngineTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'XcacheEngineTest not implemented');
|
$this->skipif (true, 'XcacheEngineTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('cake_log');
|
||||||
class CakeLogTest extends UnitTestCase {
|
class CakeLogTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'CakeLogTest not implemented');
|
$this->skipif (true, 'CakeLogTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('class_registry');
|
||||||
class ClassRegistryTest extends UnitTestCase {
|
class ClassRegistryTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ClassRegistry not implemented');
|
$this->skipif (true, 'ClassRegistry not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('configure');
|
||||||
class ConfigureTest extends UnitTestCase {
|
class ConfigureTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ConfigureTest not implemented');
|
$this->skipif (true, 'ConfigureTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'component');
|
||||||
class ComponentTest extends CakeTestCase {
|
class ComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ComponentTest not implemented');
|
$this->skipif (true, 'ComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'acl');
|
||||||
class AclComponentTest extends CakeTestCase {
|
class AclComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'AclComponentTest not implemented');
|
$this->skipif (true, 'AclComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -40,7 +40,7 @@ class AuthUser extends CakeTestModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAuthorized($user) {
|
function isAuthorized($user) {
|
||||||
if(!empty($user)) {
|
if (!empty($user)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -87,7 +87,7 @@ class AuthTest extends CakeTestCase {
|
||||||
var $fixtures = array('core.auth_user', 'core.aco', 'core.aro', 'core.aros_aco');
|
var $fixtures = array('core.auth_user', 'core.aco', 'core.aro', 'core.aros_aco');
|
||||||
|
|
||||||
function skip() {
|
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() {
|
function setUp() {
|
||||||
|
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'cookie');
|
||||||
class CookieComponentTest extends CakeTestCase {
|
class CookieComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'CookieComponentTest not implemented');
|
$this->skipif (true, 'CookieComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -49,7 +49,7 @@ class EmailTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testBadSmtpSend() {
|
function testBadSmtpSend() {
|
||||||
if(@fsockopen('localhost', 25)) {
|
if (@fsockopen('localhost', 25)) {
|
||||||
$this->Controller->Email->smtpOptions['host'] = 'blah';
|
$this->Controller->Email->smtpOptions['host'] = 'blah';
|
||||||
$this->assertFalse($this->Controller->Email->send('Should not work'));
|
$this->assertFalse($this->Controller->Email->send('Should not work'));
|
||||||
} else {
|
} else {
|
||||||
|
@ -58,7 +58,7 @@ class EmailTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSmtpSend() {
|
function testSmtpSend() {
|
||||||
if(@fsockopen('localhost', 25)) {
|
if (@fsockopen('localhost', 25)) {
|
||||||
$this->assertTrue(@fsockopen('localhost', 25), "Local mail server is running");
|
$this->assertTrue(@fsockopen('localhost', 25), "Local mail server is running");
|
||||||
$this->Controller->Email->reset();
|
$this->Controller->Email->reset();
|
||||||
$this->Controller->Email->to = 'chartjes@localhost';
|
$this->Controller->Email->to = 'chartjes@localhost';
|
||||||
|
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'request_handler');
|
||||||
class RequestHandlerComponentTest extends CakeTestCase {
|
class RequestHandlerComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'RequestHandlerComponentTest not implemented');
|
$this->skipif (true, 'RequestHandlerComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'security');
|
||||||
class SecurityComponentTest extends CakeTestCase {
|
class SecurityComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'SecurityComponentTest not implemented');
|
$this->skipif (true, 'SecurityComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'session');
|
||||||
class SessionComponentTest extends CakeTestCase {
|
class SessionComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'SessionComponentTest not implemented');
|
$this->skipif (true, 'SessionComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'controller');
|
||||||
class ControllerTest extends CakeTestCase {
|
class ControllerTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ControllerTest not implemented');
|
$this->skipif (true, 'ControllerTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'controller', 'controller' . DS . 'pages_controller');
|
||||||
class PagesControllerTest extends CakeTestCase {
|
class PagesControllerTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'PagesControllerTest not implemented');
|
$this->skipif (true, 'PagesControllerTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'scaffold');
|
||||||
class ScaffoldTest extends CakeTestCase {
|
class ScaffoldTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ScaffoldTest not implemented');
|
$this->skipif (true, 'ScaffoldTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('debugger');
|
||||||
class DebuggerTest extends UnitTestCase {
|
class DebuggerTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ConfigureTest not implemented');
|
$this->skipif (true, 'ConfigureTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('error');
|
||||||
class ErrorHandlerTest extends UnitTestCase {
|
class ErrorHandlerTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ConfigureTest not implemented');
|
$this->skipif (true, 'ConfigureTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('flay');
|
||||||
class FlayTest extends UnitTestCase {
|
class FlayTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'FlayTest not implemented');
|
$this->skipif (true, 'FlayTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('i18n');
|
||||||
class I18nTest extends UnitTestCase {
|
class I18nTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'I18nTest not implemented');
|
$this->skipif (true, 'I18nTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('l10n');
|
||||||
class L10nTest extends UnitTestCase {
|
class L10nTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'L10nTest not implemented');
|
$this->skipif (true, 'L10nTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('neat_string');
|
||||||
class NeatStringTest extends UnitTestCase {
|
class NeatStringTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'NeatString not implemented');
|
$this->skipif (true, 'NeatString not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('object');
|
||||||
class ObjectTest extends UnitTestCase {
|
class ObjectTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ObjectTest not implemented');
|
$this->skipif (true, 'ObjectTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('overloadable');
|
||||||
class OverloadableTest extends UnitTestCase {
|
class OverloadableTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'OverloadableTest not implemented');
|
$this->skipif (true, 'OverloadableTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('security');
|
||||||
class SecurityTest extends UnitTestCase {
|
class SecurityTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'SecurityTest not implemented');
|
$this->skipif (true, 'SecurityTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class CacheHelperTest extends UnitTestCase {
|
class CacheHelperTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'CacheHelper test not implemented');
|
$this->skipif (true, 'CacheHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class JsTest extends UnitTestCase {
|
class JsTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'JsHelper test not implemented');
|
$this->skipif (true, 'JsHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class RssTest extends UnitTestCase {
|
class RssTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'RssHelper test not implemented');
|
$this->skipif (true, 'RssHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class SessionHelperTest extends UnitTestCase {
|
class SessionHelperTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'SessionHelper test not implemented');
|
$this->skipif (true, 'SessionHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class TimeTest extends UnitTestCase {
|
class TimeTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'TimeHelper test not implemented');
|
$this->skipif (true, 'TimeHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class XmlHelperTest extends UnitTestCase {
|
class XmlHelperTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'XmlHelper test not implemented');
|
$this->skipif (true, 'XmlHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -36,7 +36,7 @@ uses('xml');
|
||||||
class XMLNodeTest extends UnitTestCase {
|
class XMLNodeTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
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 {
|
class XMLTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'XMLTest not implemented');
|
$this->skipif (true, 'XMLTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -50,7 +50,7 @@ class CakeHtmlReporter extends HtmlReporter {
|
||||||
*/
|
*/
|
||||||
function paintHeader($testName) {
|
function paintHeader($testName) {
|
||||||
$this->sendNoCacheHeaders();
|
$this->sendNoCacheHeaders();
|
||||||
$baseUrl = BASE_URL;
|
$baseUrl = BASE;
|
||||||
print "<h2>$testName</h2>\n";
|
print "<h2>$testName</h2>\n";
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
<!--PLEASE USE ONE OF THE POWERED BY CAKEPHP LOGO-->
|
<!--PLEASE USE ONE OF THE POWERED BY CAKEPHP LOGO-->
|
||||||
<a href="http://www.cakephp.org/" target="_new">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv='content-Type' content='text/html; <?php echo $characterSet; ?>' />
|
<meta http-equiv='content-Type' content='text/html; <?php echo $characterSet; ?>' />
|
||||||
<title>CakePHP Test Suite v 1.2.0.0</title>
|
<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>
|
<style>
|
||||||
h3 {font-size: 150%}
|
h3 {font-size: 150%}
|
||||||
a {font-size: 120%}
|
a {font-size: 120%}
|
||||||
|
|
23
index.php
23
index.php
|
@ -54,24 +54,11 @@
|
||||||
require CORE_PATH . 'cake' . DS . 'basics.php';
|
require CORE_PATH . 'cake' . DS . 'basics.php';
|
||||||
require APP_PATH . 'config' . DS . 'core.php';
|
require APP_PATH . 'config' . DS . 'core.php';
|
||||||
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
||||||
$bootstrap=true;
|
require LIBS . 'object.php';
|
||||||
$uri =setUri();
|
require LIBS . 'configure.php';
|
||||||
/**
|
|
||||||
* As mod_rewrite (or .htaccess files) is not working, we need to take care
|
$bootstrap = true;
|
||||||
* of what would normally be rewritten, i.e. the static files in app/webroot/
|
$url = setUrl();
|
||||||
*/
|
|
||||||
if ($uri === '/' || $uri === '/index.php') {
|
|
||||||
$_GET['url'] = '/';
|
|
||||||
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
|
|
||||||
} else {
|
|
||||||
$elements=explode('/index.php', $uri);
|
|
||||||
|
|
||||||
if (!empty($elements[1])) {
|
|
||||||
$path = $elements[1];
|
|
||||||
} else {
|
|
||||||
$path = '/';
|
|
||||||
}
|
|
||||||
$_GET['url']=$path;
|
|
||||||
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
|
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
|
||||||
}
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue