Exemplo n.º 1
0
 public function constructs($path)
 {
     $this->initialize();
     if ($path == null || $path == '' || empty($path)) {
         return;
     }
     $route = rtrim($path, '/');
     $routeParts = preg_split('/\\//', $route);
     $idx = 0;
     if ($this->_multilang == true && isset($routeParts[$idx])) {
         $this->_lang = $routeParts[$idx];
         $idx++;
     }
     $this->_component = null;
     if (isset($routeParts[$idx])) {
         $componentes = Model3_Site::getComponentList();
         if (in_array($routeParts[$idx], $componentes)) {
             $this->_component = $routeParts[$idx];
             $idx++;
         }
     }
     $this->_module = null;
     if (isset($routeParts[$idx])) {
         $modulos = Model3_Site::getModuleList();
         if (in_array($routeParts[$idx], $modulos)) {
             $this->_module = $routeParts[$idx];
             $idx++;
         }
     }
     $this->_controller = isset($routeParts[$idx]) && !empty($routeParts[$idx]) ? $routeParts[$idx] : "Index";
     $idx++;
     $this->_action = isset($routeParts[$idx]) && !empty($routeParts[$idx]) ? $routeParts[$idx] : "index";
     $idx++;
     for ($cont = 0; $cont < $idx; $cont++) {
         array_shift($routeParts);
     }
     $params = array();
     for ($cont = 0; $cont < count($routeParts); $cont += 2) {
         if (isset($routeParts[$cont + 1])) {
             $params[$routeParts[$cont]] = $routeParts[$cont + 1];
         }
     }
     $this->_params = $params;
 }
Exemplo n.º 2
0
 public function __construct()
 {
     $path = array_keys($_GET);
     $this->_controller = 'Index';
     $this->_action = 'index';
     $this->_params = array();
     $this->_method = strtolower($_SERVER['REQUEST_METHOD']);
     $this->_accepted = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : 'xml';
     //(strpos($_SERVER['HTTP_ACCEPT'], 'json')) ? 'json' : 'xml';
     if (isset($path[0])) {
         $route = $path[0];
         // Se debe limpiar de caracteres no validos...
         $route = rtrim($path[0], '/');
         $routeParts = preg_split('/\\//', $route);
         $idx = 0;
         $this->_component = null;
         $componentes = Model3_Site::getComponentList();
         if (in_array($routeParts[$idx], $componentes)) {
             $this->_component = $routeParts[$idx];
             $idx++;
         }
         $this->_module = null;
         if (isset($routeParts[$idx])) {
             $modulos = Model3_Site::getModuleList();
             if (in_array($routeParts[$idx], $modulos)) {
                 $this->_module = $routeParts[$idx];
                 $idx++;
             }
         }
         $this->_controller = isset($routeParts[$idx]) && !empty($routeParts[$idx]) ? $routeParts[$idx] : "Index";
         $idx++;
         $this->_action = isset($routeParts[$idx]) && !empty($routeParts[$idx]) ? $routeParts[$idx] : "index";
         $idx++;
         for ($cont = 0; $cont < $idx; $cont++) {
             array_shift($routeParts);
         }
         $this->_params = $routeParts;
     }
 }