[*] Front: move front controllers in controllers/front/ directory

// Refactoring of front controllers part 1

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8721 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rMalie
2011-09-22 15:19:42 +00:00
parent 2dbea99b61
commit 69db63f26c
94 changed files with 771 additions and 939 deletions
+17 -7
View File
@@ -188,7 +188,7 @@ class DispatcherCore
}
// Get and instantiate controller
$this->getController();
$controllers = Dispatcher::getControllers();
$controllers = Dispatcher::getControllers(_PS_CONTROLLER_DIR_);
if (!$this->controller)
$this->controller = 'index';
if (!isset($controllers[$this->controller]))
@@ -423,18 +423,28 @@ class DispatcherCore
*
* @return array
*/
public static function getControllers()
public static function getControllers($dir)
{
$controller_files = scandir(_PS_ROOT_DIR_.DIRECTORY_SEPARATOR.'controllers');
$controllers = array();
static $controllers;
$controller_files = scandir($dir);
foreach ($controller_files as $controller_filename)
if (substr($controller_filename, -14, 14) == 'Controller.php')
{
if (!in_array($controller_filename, array('.','..','.svn')) AND is_dir($dir.$controller_filename))
$controllers = self::getControllers($dir.$controller_filename.DIRECTORY_SEPARATOR);
else if (substr($controller_filename, -14, 14) == 'Controller.php')
{
$subdir = str_replace(_PS_CONTROLLER_DIR_,'',$dir);
$controllers[strtolower(substr($controller_filename, 0, -14))] = basename($controller_filename, '.php');
}
}
// add default controller
$controllers['index'] = 'IndexController';
$controllers['authentication'] = $controllers['auth'];
$controllers['productscomparison'] = $controllers['compare'];
if (isset($controllers['auth']))
$controllers['authentication'] = $controllers['auth'];
if (isset($controllers['compare']))
$controllers['productscomparison'] = $controllers['compare'];
return $controllers;
}