示例#1
0
 public function Detail($key)
 {
     $this->data['user'] = $this->checkLogin(OpenSms::OPEN_ROLE_ADMIN);
     $this->data['module'] = OpenSms_Model_System_Module::getModule($key);
     $this->data['pageTitle'] = 'Module Detail | ' . OpenSms::getSystemSetting(OpenSms::SITE_NAME);
     //var_dump($this->data['module']); die();
     $this->renderTemplate();
 }
示例#2
0
 public function DisplayPage($key)
 {
     $this->page = $this->loadModel('OpenSms_Model_Page', [0 => $key]);
     if (!isset($this->page->Id)) {
         return false;
     }
     $this->module = OpenSms_Model_System_Module::getModule('cms');
     OpenSms::setCurrentModule($this->module);
     OpenSms::setCurrentRoute(new OpenSms_Model_System_Route($key, 'Actions', 'main/cms/actions.php', 'DisplayPage'));
     $this->data['contentKey'] = 'opensms_page_' . $this->page->Permalink;
     $this->data['pageTitle'] = $this->page->Title;
     $this->renderTemplate();
     exit;
 }
示例#3
0
 /**
  * Get and split the URL
  */
 private function splitUrl()
 {
     $_GET['q'] = isset($_GET['q']) ? $_GET['q'] : 'home';
     if (isset($_GET['q'])) {
         // split URL
         $url = rtrim($_GET['q'], '/');
         $url = filter_var($url, FILTER_SANITIZE_URL);
         $this->url = $url;
         $url = explode('/', $url);
         //flag for admin page
         $is_admin_page = strtolower($url[0]) == 'admin';
         self::$isAdminPage = $is_admin_page;
         // first key in the url is our module name
         $this->module_name = isset($url[0]) && $url[0] != null ? $url[0] : 'home';
         //get the module
         self::$module = OpenSms_Model_System_Module::getModule($this->module_name);
         //print_r(self::$module);die();
         if (!self::$module->exists) {
             self::pageNotFound($this->url);
         }
         $current_route = null;
         //print_r(self::$module->routes);die();
         //get the selected route(first search for default then a single path 'home' then 'home/index'
         //module :: uri = *
         if (empty($url[1]) && strtolower(self::$module->name) == strtolower($url[0])) {
             foreach (self::$module->routes as $route) {
                 if (strtolower((string) $route->uri) == '*') {
                     $current_route = $route;
                     $param_start_index = 1;
                     goto use_route;
                 }
             }
         }
         //module/action :: uri = */action
         if (!empty($url[1])) {
             foreach (self::$module->routes as $route) {
                 $route_parts = explode("/", $route->uri);
                 if (empty($route_parts[1])) {
                     continue;
                 }
                 if ($route_parts[0] == '*' && strtolower($route_parts[1]) == strtolower($url[1])) {
                     $current_route = $route;
                     $param_start_index = 2;
                     goto use_route;
                 }
             }
         }
         //module/controller or module/action where module == controller
         foreach (self::$module->routes as $route) {
             if (strtolower($url[0]) . (!empty($url[1]) ? '/' . strtolower($url[1]) : '') == strtolower((string) $route->uri)) {
                 $current_route = $route;
                 $param_start_index = 2;
             }
         }
         //module/controller/action
         foreach (self::$module->routes as $route) {
             if (strtolower($url[0]) . (!empty($url[1]) ? '/' . strtolower($url[1]) : '') . (!empty($url[2]) ? '/' . strtolower($url[2]) : '') == strtolower((string) $route->uri)) {
                 $current_route = $route;
                 $param_start_index = 3;
             }
         }
         /*
         foreach(self::$module->routes as $route){
                         $module_name_is_controller_name = strtolower(self::$module->name) == strtolower($route->controller);
                         if(strtolower((string)$route->uri) == $module_name_is_controller_name ? strtolower($url[1]) : strtolower($url[0])) {
                             $current_route = $route;
                             $param_start_index = $module_name_is_controller_name ? 2 : 1;
                         }
                     }
         
         //if(($is_admin_page && isset($url[2]) || (!$is_admin_page && isset($url[1]))))
                         foreach(self::$module->routes as $route){
                             $module_name_is_controller_name = strtolower(self::$module->name) == strtolower($route->controller);
                             $route_compare = ($module_name_is_controller_name ? strtolower($url[1]).(!empty($url[2])?'/'.strtolower($url[2]):'') :
                                 strtolower($url[0]).(!empty($url[1])?'/'.strtolower($url[1]):''));
                             if(strtolower((string)$route->uri) == $route_compare)
                             {
                                 $current_route = $route;
                                 $param_start_index = $module_name_is_controller_name ? 3 : 2;
                             }
                         }
         */
         use_route:
         // var_dump($current_route);die();
         if (!isset($current_route)) {
             self::pageNotFound($this->url);
         }
         self::$currentRoute = $current_route;
         $this->url_controllerFilePath = $current_route->filePath;
         $this->url_controller = $current_route->controller;
         $this->url_action = $current_route->action;
         $this->url_parameter_1 = isset($url[$param_start_index]) ? $url[$param_start_index] : null;
         $this->url_parameter_2 = isset($url[$param_start_index + 1]) ? $url[$param_start_index + 1] : null;
         $this->url_parameter_3 = isset($url[$param_start_index + 2]) ? $url[$param_start_index + 2] : null;
     }
 }
示例#4
0
 public static function getAll()
 {
     if (count(self::$actions) > 0) {
         return selft::$actions;
     }
     $modules = OpenSms_Model_System_Module::getModules();
     foreach ($modules as $module) {
         foreach ($module->actions as $action) {
             $actions[] = $action;
         }
     }
     return $actions;
 }