Example #1
0
 public function __construct()
 {
     $pathStr = self::GetPathStr();
     $pathInfo = self::ParsePath($pathStr);
     self::$path = $pathInfo['path'];
     if ($pathInfo['param']) {
         self::SetParam($pathInfo['param']);
     }
 }
 public function _validate_request($segments)
 {
     isset($segments[1]) or $segments[1] = NULL;
     /* locate the module controller */
     list($module, $controller) = Router::locate($segments);
     /* Modification starts */
     // Does the requested controller exist in the root folder?
     if (file_exists(APPPATH . 'controllers/' . $segments[0] . EXT)) {
         return $segments;
     }
     // Is the controller in a sub-folder?
     if (is_dir(APPPATH . 'controllers/' . $segments[0])) {
         // Set the directory and remove it from the segment array
         $this->set_directory($segments[0]);
         $segments = array_slice($segments, 1);
         if (count($segments) > 0) {
             // Does the requested controller exist in the application sub-folder?
             if (!file_exists(APPPATH . 'controllers/' . $this->fetch_directory() . $segments[0] . EXT)) {
                 show_404(APPPATH . 'controllers/' . $this->fetch_directory() . $segments[0]);
             }
         } else {
             $this->set_class($this->default_controller);
             $this->set_method('index');
             // Does the default controller exist in the sub-folder?
             if (!file_exists(APPPATH . 'controllers/' . $this->fetch_directory() . $this->default_controller . EXT)) {
                 $this->directory = '';
                 return array();
             }
         }
         return $segments;
     }
     /* Modificatiion Ends */
     // (isset($segments[1])) OR $segments[1] = NULL;
     /* locate the module controller */
     // list($module, $controller) = Router::locate($segments);
     /* no controller found */
     $module === FALSE and show_404($controller);
     /* set the module directory */
     Router::$path = $controller ? $module : NULL;
     /* set the module path */
     $path = $controller ? MODOFFSET . $module . '/controllers/' : NULL;
     $this->set_directory($path);
     /* remove the directory segment */
     if ($controller != $module and $controller != NULL) {
         $segments = array_slice($segments, 1);
     }
     return $segments;
 }
Example #3
0
 /** Locate the controller **/
 public static function locate($segments)
 {
     list($module, $controller) = $segments;
     $controller == NULL and $controller = $module;
     /* module? */
     if ($module and is_dir(MODBASE . $module)) {
         self::$path = $module;
         /* module sub-controller? */
         if (is_file(MODBASE . $module . '/controllers/' . $controller . EXT)) {
             return array($module, $controller);
         }
         /* module controller? */
         return array($module, $module);
     }
     /* not a module controller */
     return array(FALSE, FALSE);
 }