diff --git a/app/config/core.php b/app/config/core.php index 0280c5d08..186f581fb 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -83,6 +83,15 @@ define('CAKE_SECURITY', 'high'); */ define('CAKE_SESSION_SAVE', 'php'); +/** + * Uncomment the define below to use cake built in admin routes. + * You can set this value to anything you want. + * All methods related to the admin route should be prefixed with the + * name you set CAKE_ADMIN to. + * For example: admin_index, admin_edit + */ +//define('CAKE_ADMIN', 'admin'); + /** * Compress output CSS (removing comments, whitespace, repeating tags etc.) * This requires a /var/cache directory to be writable by the web server (caching). diff --git a/app/webroot/index.php b/app/webroot/index.php index 085cd6a34..2b2dcdafc 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -128,13 +128,6 @@ uses('folder'); require_once CAKE.'dispatcher.php'; require_once LIBS.'model'.DS.'dbo'.DS.'dbo_factory.php'; -if(!defined('AUTO_SESSION') || AUTO_SESSION == true) -{ - // Starts the session unless AUTO_SESSION is explicitly set to false in config/core - //session_start(); - $session =& CakeSession::getInstance(); -} - config('database'); if (class_exists('DATABASE_CONFIG')) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 36c7b30b1..3d6b40577 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -53,6 +53,12 @@ class Dispatcher extends Object * @var string */ var $base = false; + +/** + * Base URL + * @var string + */ + var $admin = false; /** * Constructor. @@ -74,13 +80,31 @@ class Dispatcher extends Object */ function dispatch($url, $additionalParams=array()) { - $this->base = $this->baseUrl(); $params = array_merge($this->parseParams($url), $additionalParams); $missingController = false; $missingAction = false; $missingView = false; $privateAction = false; + if(defined('CAKE_ADMIN')) + { + if(isset($params[CAKE_ADMIN])) + { + $this->admin = '/'.CAKE_ADMIN ; + $url = preg_replace('/'.CAKE_ADMIN.'\//', '', $url); + if (empty($params['action'])) + { + $params['action'] = CAKE_ADMIN.'_'.'index'; + } + else + { + $params['action'] = CAKE_ADMIN.'_'.$params['action']; + } + } + } + + $this->base = $this->baseUrl(); + if(!in_array('render', array_keys($params))) { $params['render'] = 0; @@ -111,6 +135,7 @@ class Dispatcher extends Object if ($missingController) { + require_once(CAKE.'app_controller.php'); $controller =& new AppController(); $params['action'] = 'missingController'; $params['controller'] = Inflector::camelize($params['controller']."Controller"); @@ -170,7 +195,11 @@ class Dispatcher extends Object $controller->privateAction = $params['action']; $params['action'] = 'privateAction'; } - + if(!defined('AUTO_SESSION') || AUTO_SESSION == true) + { + session_write_close(); + $session =& CakeSession::getInstance(); + } return $this->_invoke($controller, $params ); } @@ -256,11 +285,11 @@ class Dispatcher extends Object function baseUrl() { $htaccess = null; - $base = null; + $base = $this->admin; $this->webroot = ''; if (defined('BASE_URL')) { - $base = BASE_URL; + $base = BASE_URL.$this->admin; } $docRoot = $_SERVER['DOCUMENT_ROOT']; diff --git a/cake/libs/controller/components/session.php b/cake/libs/controller/components/session.php index b02e883f2..88648f438 100644 --- a/cake/libs/controller/components/session.php +++ b/cake/libs/controller/components/session.php @@ -54,6 +54,8 @@ class Session extends Object /** * Enter description here... * + * Use like this. $this->session->write('Controller.sessKey', 'session value'); + * * @param unknown_type $name * @param unknown_type $value * @return unknown @@ -66,6 +68,8 @@ class Session extends Object /** * Enter description here... * + * Use like this. $this->session->read('Controller.sessKey'); + * * @param unknown_type $name * @return unknown */ @@ -77,6 +81,8 @@ class Session extends Object /** * Enter description here... * + * Use like this. $this->session->del('Controller.sessKey'); + * * @param unknown_type $name * @return unknown */ @@ -88,6 +94,8 @@ class Session extends Object /** * Enter description here... * + * Use like this. $this->session->check('Controller.sessKey'); + * * @param unknown_type $name * @return unknown */ @@ -112,9 +120,9 @@ class Session extends Object * @param unknown_type $name * @return unknown */ - function valid($name) + function valid() { - return CakeSession::isValid($name); + return CakeSession::isValid(); } } diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index b0406c9a8..205bd7960 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -297,9 +297,14 @@ class Scaffold extends Object { if(!empty($isDataBaseSet)) { $this->controllerClass->constructClasses(); + if(!defined('AUTO_SESSION') || AUTO_SESSION == true) + { + session_write_close(); + $session =& CakeSession::getInstance(); + } if($params['action'] === 'index' || $params['action'] === 'list' || - $params['action'] === 'show' || $params['action'] === 'new' || + $params['action'] === 'show' || $params['action'] === 'add' || $params['action'] === 'create' || $params['action'] === 'edit' || $params['action'] === 'update' || $params['action'] === 'destroy') { @@ -317,7 +322,7 @@ class Scaffold extends Object { $this->_scaffoldList($params); break; - case 'new': + case 'add': $this->_scaffoldNew($params); break; diff --git a/cake/libs/controller/templates/scaffolds/list.thtml b/cake/libs/controller/templates/scaffolds/list.thtml index 49cdeb8d1..98d4f14f4 100644 --- a/cake/libs/controller/templates/scaffolds/list.thtml +++ b/cake/libs/controller/templates/scaffolds/list.thtml @@ -93,7 +93,7 @@
Fatal: Unable to load view file missingView;?> for -action params['controller'];?>::params['action'];?> +action missingView;?>::params['action'];?>
1):?>