1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- ApplicationSettings::RegisterDefaultSetting("navigation", "mode", "exclude");
- ApplicationSettings::RegisterDefaultSetting("navigation", "pages", "");
- require_once 'Controller/Navigation/base/INavigationController.php';
- Navigation::Load();
- class Navigation {
- private static $_controllers=array();
-
- public static function LoadNavigationController($name){
- include_once "Controller/Navigation/$name.php";
- $controller=new $name;
- self::RegisterPage($name,$controller);
- }
- public static function Load(){
- $mode=ApplicationSettings::GetSetting("navigation", "mode");
- $pages=ApplicationSettings::GetSetting("navigation", "pages");
- $pageList=explode(",", $pages);
- switch (strtolower($mode)){
- case "include":
- foreach ($pageList as $page)
- self::LoadNavigationController($page);
- break;
- case "exclude":
- $files=glob("Controller/Navigation/*.php");
- foreach ($files as $file){
- $page=basename($file,".php");
- if (!in_array($page, $pageList))
- self::LoadNavigationController($page);
- }
- break;
- default:
- throw new Exception("Invalid navigiation mode: $mode. Please set to include or exclude.");
- }
- }
-
- public static function RegisterPage($name, INavigationController $contoller){
- self::$_controllers[$name]=$contoller;
- }
-
- public static function Get(){
- return self::$_controllers;
- }
- }
|