Exemplo n.º 1
0
 protected function parseRoute()
 {
     // parse the route from the URL
     if (!empty($this->Uri->uri_parts)) {
         $controller = $this->Uri->uri_parts[0];
         if (isset($this->Uri->uri_parts[1])) {
             $method = $this->Uri->uri_parts[1];
         }
     }
     // use default if no controller has been found
     if (empty($controller)) {
         $controller = $this->Config->get('default.controller');
     }
     // use default if no method has been found
     if (empty($method)) {
         $method = $this->Config->get('default.method');
     }
     // for controllers with multiple words in their name
     $controller = str_replace('-', ' ', $controller);
     // convert class name into expected casing
     $controller = ucwords($controller);
     // remove any spaces to give final controller name
     $controller = str_replace(' ', '', $controller);
     try {
         // init controller
         $this->Controller = Load::controller($controller);
     } catch (LoadException $e) {
         throw new Exception('ROUTER_INVALID_CONTROLLER');
     }
     // ensure method exists
     if (!method_exists($this->Controller, $method)) {
         throw new Exception('ROUTER_INVALID_METHOD');
     }
     // call the method
     $this->Method = call_user_func(array($this->Controller, $method));
     // call draw method
     $this->Draw = call_user_func(array($this->Controller, '_draw'));
 }
Exemplo n.º 2
0
 function bstatus()
 {
     Load::controller('bstatus');
 }
Exemplo n.º 3
0
            exit;
        }
    }
    //если запрошена главная страница админки - выводим ее шаблон
    if ($_SERVER['REQUEST_URI'] === '/admin/') {
        FileSys::includeFile(ADMIN_ROOT . '/templates/default/index.php');
    } else {
        $com = Request::get('com');
        if (!is_dir(ADMIN_ROOT . '/components/' . $com)) {
            Router::set404();
        }
        if (is_file(ADMIN_ROOT . '/components/' . $com . '/config.php')) {
            require_once ADMIN_ROOT . '/components/' . $com . '/config.php';
        }
        if (is_file(ADMIN_ROOT . '/components/' . $com . '/SectionController.php')) {
            Load::controller(ADMIN_ROOT . '/components/' . $com . '/SectionController.php', Request::get('section', false));
        } else {
            $com_dirs = FileSys::getDirs(ADMIN_ROOT . '/components/' . $com);
            $forbidden_dir = ['client'];
            $section = Request::get('section');
            if (in_array($section, $com_dirs) && !in_array($section, $forbidden_dir)) {
                Load::manager(ADMIN_ROOT . '/components/' . $com . '/' . $section . '/' . toCamelCase($section) . 'Manager.php');
            } else {
                Router::set404();
            }
        }
    }
} catch (SystemException $e) {
    header('HTTP/1.0 500 Internal Server Error');
    echo $e->getError();
} catch (ValidatorException $e) {
Exemplo n.º 4
0
 public function helpers()
 {
     Load::controller(__DIR__ . '/helpers/HelpersController.php', Request::get('action'));
 }
Exemplo n.º 5
0
 public static function manager($path)
 {
     Load::controller($path, Request::get('action', false));
 }