Exemple #1
0
 /**
  * 执行指定模块
  */
 public function start()
 {
     $route = new Route();
     $route->index();
     unset($route);
     include PES_PATH . '/Slice/registerSlice.php';
     array_walk(\Core\Slice\InitSlice::$slice, function ($obj) {
         $obj->before();
     });
     $runningNormally = false;
     foreach (['getContorller', 'getContent'] as $value) {
         if ($this->{$value}() !== false) {
             $runningNormally = true;
             break;
         }
     }
     if (\Core\Slice\InitSlice::$beforeViewToExecAfter === false) {
         array_walk(\Core\Slice\InitSlice::$slice, function ($obj) {
             $obj->after();
         });
     }
     if ($runningNormally === false) {
         $title = "404 Page Not Found";
         $errorMes = "<b>Debug route info:</b><br />Group:" . GROUP . ", Model:" . MODULE . ", Method:" . METHOD . ", Action:" . ACTION;
         $errorFile = "<b>File loaded:</b><br />" . PES_PATH . "{$this->unixPath}.class.php";
         $this->promptPage($title, $errorMes, $errorFile);
     }
 }
Exemple #2
0
 /**
  * 执行指定模块
  */
 public function start()
 {
     $route = new Route();
     $route->index();
     unset($route);
     $this->setLanguage();
     try {
         $class = "\\" . ITEM . "\\" . GROUP . "\\" . METHOD . "\\" . MODULE;
         $unixPath = str_replace("\\", "/", $class);
         /**
          * 当前执行的类文件不存在
          * 则调用Content类。
          */
         if (!file_exists(PES_PATH . $unixPath . '.class.php')) {
             $class = ITEM . "\\" . GROUP . "\\" . METHOD . "\\Content";
             $obj = new $class();
             throw new Abnormal($GLOBALS['_CORELANG']['404']);
         }
         $obj = new $class();
         if (!method_exists($obj, ACTION)) {
             throw new Abnormal($GLOBALS['_CORELANG']['404']);
         }
         $a = ACTION;
         $obj->{$a}();
         unset($a);
     } catch (Abnormal $e) {
         try {
             //让魔术方法可以调用
             if (!is_callable(array($obj, ACTION))) {
                 throw new Abnormal($GLOBALS['_CORELANG']['404']);
             }
             $a = ACTION;
             $obj->{$a}();
             unset($a);
         } catch (Abnormal $e) {
             /* 无法侦测到 */
             try {
                 if (file_exists(THEME . '/' . GROUP . '/' . METHOD . '/' . MODULE . '_' . ACTION . '.php')) {
                     include THEME . '/' . GROUP . '/' . METHOD . '/' . MODULE . '_' . ACTION . '.php';
                 } else {
                     throw new Abnormal('404 Not found!');
                 }
             } catch (Abnormal $e) {
                 header('HTTP/1.1 404');
                 if (DEBUG == true) {
                     $title = "404 Page Not Found";
                     $errorMes = "<b>Debug route info:</b><br /> Group:" . GROUP . ", Model:" . MODULE . ", Method:" . METHOD . ", Action:" . ACTION;
                     $errorFile = "<b>File loaded:</b><br />" . PES_PATH . "{$unixPath}.class.php";
                 } else {
                     $title = $GLOBALS['_CORELANG']['404'];
                     $errorMes = $GLOBALS['_CORELANG']['ERROR_MES'];
                     $errorFile = $GLOBALS['_CORELANG']['ERROR_FILE'];
                 }
                 require $this->promptPage();
                 exit;
             }
         }
     }
 }
Exemple #3
0
 /**
  * 执行指定模块
  */
 public function start()
 {
     $route = new Route();
     $route->index();
     unset($route);
     $runningNormally = false;
     foreach (['getContorller', 'getContent', 'getTemplate'] as $value) {
         if ($this->{$value}() !== false) {
             $runningNormally = true;
             break;
         }
     }
     if ($runningNormally === false) {
         $title = "404 Page Not Found";
         $errorMes = "<b>Debug route info:</b><br />Group:" . GROUP . ", Model:" . MODULE . ", Method:" . METHOD . ", Action:" . ACTION;
         $errorFile = "<b>File loaded:</b><br />" . PES_PATH . "{$this->unixPath}.class.php";
         $this->promptPage($title, $errorMes, $errorFile);
     }
 }
 * Configure autoload
 */
require_once 'SplClassLoader.php';
$loader = new SplClassLoader();
$loader->register();
/**
 * Init config
 */
\Core\Config\Config::init();
/**
 * Include helpers
 */
require_once "Core/Helpers.php";
ob_start();
try {
    /**
     * Route
     */
    \Core\Route\Route::start();
    /**
     * Fire!
     */
    $app = new \Core\App();
    $app->fire();
} catch (\Core\Exceptions\ControllerException $e) {
    echo view('500.error');
    exit;
} catch (\Core\Exceptions\Error404 $e) {
    echo view('404.error');
    exit;
}
Exemple #5
0
<?php

\Core\Route\Route::get('/news/', 'NewsController@index');
\Core\Route\Route::get('/news/list/{page}', 'NewsController@index');
\Core\Route\Route::get('/news/{id}', 'NewsController@show');
\Core\Route\Route::get('/', 'IndexController@index');
\Core\Route\Route::get('/api/v1/news/{page}', 'ApiController@index');