protected function init() { $request = $this->request->current(); $this->config = Kohana::$config->load($this->config)->as_array(); $this->acl_init(); $this->site_init(); $helper_acl = new Helper_ACL($this->acl); $a2_config = Kohana::$config->load('admin/a2/base')->as_array(); $helper_acl->inject($a2_config); if (Route::name($request->route()) == 'modules') { $this->module_page_id = (int) $request->query('page'); $this->module_config = empty($this->module_config) ? Helper_Module::code_by_controller($request->controller()) : $this->module_config; $_pages = $this->get_module_pages($this->module_config); if ($_pages->count() > 0) { if ($this->module_page_id == 0) { $this->module_page_id = $_pages->rewind()->current()->id; } foreach ($_pages as $_item) { $_link = URL::base() . Page_Route::dynamic_base_uri($_item->id); $this->module_pages[$_item->id] = $_item->title . " [ {$_link} ]"; } } $this->module_config = Helper_Module::load_config($this->module_config); if (!Kohana::$is_cli) { $config = Arr::get($this->module_config, 'a2'); $helper_acl->inject($config); } if (!$this->acl->is_allowed($this->user, $request->controller() . '_controller', 'access')) { throw new HTTP_Exception_404(); } } $injectors = array(); foreach ($this->injectors as $_key => $_array) { $params = Arr::get($_array, 1); if (class_exists($_array[0])) { $object = new $_array[0]($request, $this->user, $this->acl, $params); $injectors[$_key] = $object; } } $this->injectors = $injectors; unset($injectors); $this->is_cancel = $request->post('cancel') == 'cancel'; $this->back_url = $request->query('back_url'); $this->post_check_empty_files(); $this->post_check_deleted_fields(); }
public static function uri($page_id, $name, array $params = NULL, $region = TRUE) { if (empty(self::$dynamic_routes)) { foreach (Kohana::list_files('config' . DIRECTORY_SEPARATOR . 'routes') as $file_key => $file) { $_tmp = explode(DIRECTORY_SEPARATOR, $file_key); $config_file_name = array_pop($_tmp); $routes_config = Kohana::$config->load('routes/' . str_replace('.php', '', $config_file_name))->as_array(); foreach ($routes_config as $key => $value) { $route = new Route(Arr::get($value, 'uri_callback'), Arr::get($value, 'regex')); $route->defaults(Arr::get($value, 'defaults')); self::$dynamic_routes[$key] = $route; } } } if (isset(self::$dynamic_routes[$name])) { $base_uri = $page_id !== FALSE ? Page_Route::dynamic_base_uri($page_id) : '_module/' . $name; $route_uri = self::$dynamic_routes[$name]->uri($params, $region); return $base_uri . $route_uri; } return NULL; }
public function action_page() { $link = URL::base() . Page_Route::dynamic_base_uri($this->request->page['data']); $this->request->current()->redirect($link); }