mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
merging changes made in sandboxes
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@893 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a86866a7a1
commit
1a93ab942f
6 changed files with 55 additions and 46 deletions
|
@ -177,4 +177,10 @@ define ('IMAGES_URL', '/img/');
|
|||
*/
|
||||
define ('CSS_URL', '/css/');
|
||||
|
||||
/**
|
||||
* Web path to the js files directory.
|
||||
*/
|
||||
define ('JS_URL', '/js/');
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
@ -54,7 +54,7 @@ function loadModels ()
|
|||
require (APP.'app_model.php');
|
||||
foreach (listClasses(MODELS) as $model_fn)
|
||||
{
|
||||
require (MODELS.$model_fn);
|
||||
require_once (MODELS.$model_fn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,12 +72,12 @@ function loadControllers ()
|
|||
|
||||
foreach (listClasses(HELPERS) as $helper)
|
||||
{
|
||||
require (HELPERS.$helper.'.php');
|
||||
require_once (HELPERS.$helper.'.php');
|
||||
}
|
||||
|
||||
foreach (listClasses(CONTROLLERS) as $controller)
|
||||
{
|
||||
require (CONTROLLERS.$controller.'.php');
|
||||
require_once (CONTROLLERS.$controller.'.php');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,10 +92,10 @@ function loadController ($name)
|
|||
$controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
|
||||
$helper_fn = HELPERS.Inflector::underscore($name).'_helper.php';
|
||||
|
||||
require(APP.'app_controller.php');
|
||||
require_once(APP.'app_controller.php');
|
||||
|
||||
if (file_exists($helper_fn))
|
||||
require($helper_fn);
|
||||
require_once($helper_fn);
|
||||
|
||||
return file_exists($controller_fn)? require($controller_fn): false;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ function config ()
|
|||
}
|
||||
elseif (file_exists(CONFIGS.$arg.'.php'))
|
||||
{
|
||||
include (CONFIGS.$arg.'.php');
|
||||
include_once (CONFIGS.$arg.'.php');
|
||||
if (count($args) == 1) return true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -772,9 +772,6 @@ class Controller extends Object
|
|||
}
|
||||
} // end loop through manytomany relations.
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $fieldNames;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,9 +85,9 @@ class Dispatcher extends Object
|
|||
* @param string $url URL information to work on.
|
||||
* @return boolean Success
|
||||
*/
|
||||
function dispatch($url)
|
||||
function dispatch($url, $additional_params=array())
|
||||
{
|
||||
$params = $this->parseParams($url);
|
||||
$params = array_merge($this->parseParams($url), $additional_params);
|
||||
$missingController = false;
|
||||
$missingAction = false;
|
||||
$missingView = false;
|
||||
|
@ -120,19 +120,15 @@ class Dispatcher extends Object
|
|||
$controller = new $ctrlClass($this);
|
||||
}
|
||||
|
||||
if (empty($params['action']))
|
||||
{
|
||||
if (method_exists($controller, 'index'))
|
||||
$classMethods = get_class_methods($controller);
|
||||
$classVars = get_object_vars($controller);
|
||||
|
||||
if ((empty($params['action'])) && in_array('index', $classMethods))
|
||||
{
|
||||
$params['action'] = 'index';
|
||||
}
|
||||
else
|
||||
{
|
||||
$missingAction = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!method_exists($controller, $params['action']))
|
||||
if(!in_array($params['action'], $classMethods))
|
||||
{
|
||||
$missingAction = true;
|
||||
}
|
||||
|
@ -143,13 +139,12 @@ class Dispatcher extends Object
|
|||
$controller->action = $params['action'];
|
||||
$controller->data = empty($params['data'])? null: $params['data'];
|
||||
$controller->passed_args = empty($params['pass'])? null: $params['pass'];
|
||||
$controller->viewpath = Inflector::underscore($ctrlName);
|
||||
$controller->autoLayout = !$params['bare'];
|
||||
|
||||
foreach (get_object_vars($controller) as $name => $value)
|
||||
if((in_array('scaffold', array_keys($classVars))) && ($missingAction === true || !empty($params['action'])))
|
||||
{
|
||||
if(($name === 'scaffold' && $missingAction === true)
|
||||
|| ($name === 'scaffold' && !empty($params['action'])))
|
||||
{
|
||||
if (!method_exists($controller, $params['action']))
|
||||
if(!in_array($params['action'], $classMethods))
|
||||
{
|
||||
if(empty($params['action']))
|
||||
{
|
||||
|
@ -159,7 +154,6 @@ class Dispatcher extends Object
|
|||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$controller->constructClasses();
|
||||
|
||||
|
@ -227,6 +221,7 @@ class Dispatcher extends Object
|
|||
$params['form'][$name] = $data;
|
||||
}
|
||||
|
||||
$params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1;
|
||||
return $params;
|
||||
}
|
||||
|
||||
|
@ -273,20 +268,25 @@ class Dispatcher extends Object
|
|||
return preg_match('/^(.*)\/public\/index\.php$/', $script_name, $r)? $r[1]: false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Displays an error page (e.g. 404 Not found).
|
||||
*
|
||||
* @param int $code Error code (e.g. 404)
|
||||
* @param string $name Name of the error message (e.g. Not found)
|
||||
* @param string $message
|
||||
* @return unknown
|
||||
*/
|
||||
function error ($code, $name, $message)
|
||||
{
|
||||
$controller = new Controller ($this);
|
||||
$controller->base = $this->base;
|
||||
$controller->error($code, $name, $message);
|
||||
$controller->autoLayout = false;
|
||||
$controller->set(array('code'=>$code, 'name'=>$name, 'message'=>$message));
|
||||
return $controller->render('layouts/error');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenience method to display a 404 page.
|
||||
*
|
||||
|
|
|
@ -140,7 +140,8 @@ class Router extends Object {
|
|||
array()
|
||||
);
|
||||
|
||||
|
||||
$this->connect('/bare/:controller/:action/*', array('bare'=>'1'));
|
||||
$this->connect('/ajax/:controller/:action/*', array('bare'=>'1'));
|
||||
$this->routes[] = $admin_route;
|
||||
$this->routes[] = $default_route;
|
||||
|
||||
|
|
|
@ -553,6 +553,11 @@ class View extends Object
|
|||
return $out;
|
||||
}
|
||||
|
||||
function fetch ($url)
|
||||
{
|
||||
$dispatcher = new Dispatcher();
|
||||
return $dispatcher->dispatch($url, array('bare'=>1));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Reference in a new issue