/** Load a module controller **/ public static function load($module) { is_array($module) and list($module, $params) = each($module) or $params = NULL; /* get the controller class name */ $class = strtolower(end(explode('/', $module))); /* is controller in registry? */ if (isset(self::$registry[$class])) { return self::$registry[$class]; } /* get the module name */ list($module) = explode('/', $module); /* find the module controller */ list($module, $controller) = Router::locate(array($module, $class)); if ($module === FALSE) { return; } /* set the module directory */ self::$home = $module; $path = $module ? MODOFFSET . $module . '/controllers/' : NULL; /* load the module controller class */ self::load_file($controller, APPPATH . 'controllers/' . $path); $class = ucfirst($controller); /* create the new controller */ $controller = new $class($params); return $controller; }
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; }
public function _validate_request($segments) { isset($segments[1]) or $segments[1] = NULL; /* locate the module controller */ list($module, $controller) = Router::locate($segments); /* not a module controller */ if ($controller === FALSE) { return parent::_validate_request($segments); } /* set the module path */ $path = $module ? MODOFFSET . $module . '/controllers/' : NULL; $this->set_directory($path); /* remove the directory segment */ if ($module != $controller and $module != FALSE) { $segments = array_slice($segments, 1); } return $segments; }
/** Load a module controller **/ public static function load($module) { is_array($module) and list($module, $params) = each($module) or $params = NULL; /* get the controller class name */ $class = strtolower(end(explode('/', $module))); /* return an existing controller from the registry */ if (isset(self::$registry[$class])) { return self::$registry[$class]; } /* get the module name */ list($module) = explode('/', $module); /* find the module controller */ list($module, $controller) = Router::locate(array($module, $class)); if ($controller === FALSE) { return; } /* set the module directory */ $path = Router::$path ? MODBASE . $module . '/controllers/' : APPPATH . 'controllers/'; /* load the controller class */ self::load_file($controller, $path); /* create the new controller */ $controller = ucfirst($controller); return new $controller($params); }