Example #1
0
 protected static function _parseRequest($routes, $level)
 {
     $p = InRequest::getUrlPart($level);
     if ($p && isset($routes[$p])) {
         if (!is_array($routes[$p])) {
             self::$_controller = $routes[$p];
             self::$_context = IN_CONTEXT_DEFAULT;
         } else {
             self::_parseRequest($routes[$p], $level + 1);
         }
     } else {
         if (isset($routes['default'])) {
             if (!is_array($routes['default'])) {
                 self::$_controller = $routes['default'];
                 self::$_context = IN_CONTEXT_DEFAULT;
             } else {
                 self::$_controller = $routes['default'][0];
                 self::$_context = isset($routes['default'][1]) ? $routes['default'][1] : IN_CONTEXT_DEFAULT;
                 self::$_params = isset($routes['default'][2]) ? $routes['default'][2] : null;
             }
         } else {
             self::$_controller = $routes[0];
             self::$_context = isset($routes[1]) ? $routes[1] : IN_CONTEXT_DEFAULT;
             self::$_params = isset($routes[2]) ? $routes[2] : null;
         }
     }
 }
Example #2
0
 public function __construct()
 {
     $this->_page = InRouter::getController();
     $this->_theme = new InTheme();
     $this->_theme->page = $this->_page;
     $this->_theme->path = InRouter::getContext();
     $this->_theme->view = $this->_page;
     if ($this->_page) {
         $theme = $this->_theme;
         $project = $this;
         require_once IN_CONTROLLERS_PATH . '/' . InRouter::getContext() . '/' . InRouter::getController() . '.php';
     }
 }
Example #3
0
 public function __construct()
 {
     $this->_page = InRouter::getController();
     $this->_theme = new InTheme();
     $this->_theme->page = $this->_page;
     $this->_theme->path = InRouter::getContext();
     $this->_theme->view = $this->_page;
     // Project dependencies
     $dep_path = dirname(dirname(dirname(dirname(__FILE__)))) . '/project/index.php';
     if (file_exists($dep_path)) {
         require_once $dep_path;
     }
     // Load Controller
     if ($this->_page) {
         $theme = $this->_theme;
         $project = $this;
         require_once IN_CONTROLLERS_PATH . '/' . InRouter::getContext() . '/' . InRouter::getController() . '.php';
     }
 }
Example #4
0
 protected function _validateParams()
 {
     $type = InRouter::getParams();
     switch ($type) {
         case 'POST':
             $source = $_POST;
             break;
         default:
             $source = $_GET;
             break;
     }
     $params = InRouter::getContext();
     if ($params && is_array($params) && count($params) > 0) {
         foreach ($params as $p) {
             if (isset($source[$p])) {
                 $this->_params[$p] = $source[$p];
             } else {
                 $this->setError(422);
                 return false;
             }
         }
     }
     return true;
 }