public function before() { parent::before(); // detecting language, setting it $this->detect_language(); $this->set('_language', $this->language); // creating and attaching page metadata $this->metadata = new Model_Metadata(); $this->metadata->title(__(Application::instance()->get('title')), false); $this->set('_metadata', $this->metadata); //TODO: token auth /* if ($this->request->method() == Request::POST && Arr::get($_POST, 'token', '') !== Security::token()) { throw new HTTP_Exception_403('Wrong token data'); } */ $this->set('_token', Security::token()); // Handles return urls, cropping language out of it (will be appended by url.site at redirect time) $rr = Request::initial()->uri(); $rr = trim($rr, '/'); $rr = explode('/', $rr); if (in_array($rr[0], Application::instance()->get('language.list'))) { array_shift($rr); } $rr = implode('/', $rr); $this->set('_return', $rr); // detecting if user is logged in if (method_exists(Auth::instance(), 'auto_login')) { Auth::instance()->auto_login(); } $this->user = Auth::instance()->get_user(); $this->set('_user', $this->user); }
public function before() { parent::before(); $this->metadata = Model::factory('Metadata'); $this->set('_metadata', $this->metadata); Auth::instance()->auto_login(); $this->set('_language', i18n::lang()); $this->metadata->title('Вход в панель управления', false); }
public function before() { //$this->redirect('http://ehistory.kz/manage'); parent::before(); $this->response->headers('cache-control', 'private'); // creating and attaching page metadata $this->metadata = new Model_Metadata(); $this->metadata->title(__(Application::instance()->get('title')), false); $this->set('_metadata', $this->metadata); Auth::instance()->auto_login(); if (!Auth::instance()->logged_in()) { $this->redirect('manage/auth/login'); } else { $id = Auth::instance()->get_user()->id; $user = ORM::factory('user', $id); $input = $user->has('roles', ORM::factory('role', array('name' => 'admin'))) || $user->has('roles', ORM::factory('Role', array('name' => 'moderator'))); $input_redactor = $user->has('roles', ORM::factory('Role', array('name' => 'redactor'))); if (!$input && !$input_redactor) { $this->redirect('/manage/auth/logout'); } if (!$input && (strtolower($this->request->controller()) != 'ehistory' && strtolower($this->request->controller()) != 'language')) { $this->redirect('manage/ehistory'); } } $this->user = Auth::instance()->get_user(); if (Request::$initial === Request::$current) { $messages = Notify::instance()->get_all_once(); $this->set('_notifications', $messages); } $language = Session::instance()->get('_language', 'ru'); $this->language = in_array($language, array('ru', 'en', 'kz')) ? $language : 'ru'; I18n::lang($this->language); $rr = Request::initial()->uri() . urlencode(URL::query(null, true)); $rr = trim($rr, '/'); //$this->metadata->title('Sharua.kz', false); $countcomm = ORM::factory('Comment')->where('status', '=', '0')->count_all(); //смотрим сколько новых коментов $this->set('_user', $this->user)->set('_language', $this->language)->set('_return_url', $rr)->set('_countcomm', $countcomm); //вносим в переменную количество новых коментов $knigi = ORM::factory('Book')->where('category_id', '=', '0')->find_all(); //смотрим сколько книг без категории if ($knigi) { if (count($knigi) > 0) { $this->set('_uncatcount', count($knigi)); //вносим в переменную количество книг без категории } } $this->referrer = Request::initial()->referrer(); if (Message::get()) { $this->set('basic_message', Message::display('/message/basic')); } }
public function before() { parent::before(); // detecting language, setting it // $this->detect_language(); // $this->set('_language', $this->language); $this->set('device', $this->detect_device()); //var_dump($_COOKIE); // creating and attaching page metadata $this->metadata = new Model_Metadata(); $this->metadata->title(__(Application::instance()->get('title')), false); $this->set('_metadata', $this->metadata); $this->set('_token', Security::token()); // Handles return urls, cropping language out of it (will be appended by url.site at redirect time) // $rr = Request::initial()->uri(); // $rr = trim($rr, '/'); // $rr = explode('/', $rr); // if (in_array($rr[0], Application::instance()->get('language.list'))) { // array_shift($rr); // } // $rr = implode('/', $rr); // $this->set('_return', $rr . Url::query()); View::bind_global('_breadcumbs', $this->breadcumbs); // detecting if user is logged in if (method_exists(Auth::instance(), 'auto_login')) { Auth::instance()->auto_login(); } // if (Auth::instance()->logged_in()) { $id = Auth::instance()->get_user()->id; $user = ORM::factory('user', $id); $input = $user->has('roles', ORM::factory('role', array('name' => 'admin'))); $this->set("admin_mode", $input); } else { $this->set("admin_mode", false); } // $this->user = Auth::instance()->get_user(); $this->set('_user', $this->user); if (Auth::instance()->logged_in() && $this->user->profile->is_visited != 1 && strtolower($this->request->controller()) == 'profile') { $this->redirect('profile/information', 301); } $sliders = ORM::factory('Slider')->where('is_active', '=', 1)->and_where('type', '=', 'slider')->order_by('order', 'asc')->find_all(); $this->set('sliders', $sliders); $banner = ORM::factory('Slider')->where('is_active', '=', 1)->and_where('type', '=', 'banner')->find_all(); $this->set('menu_banner', $banner); $menu = ORM::factory('Page')->where('key', '=', 'menu')->find(); //Для SEO (сортировка) if ($this->request->controller() == 'Auth' or $this->request->controller() == 'Search' or $this->request->controller() == 'Profile') { $this->set('sort', 1); } //end SEO $page_roots = ORM::factory('Page', $menu->id)->children(); $page_main = array(); $children_pages = array(); $children_pages_last = array(); $children_pages_last_last = array(); foreach ($page_roots as $p) { $page_main[$p->key] = array('id' => $p->id, 'name' => $p->name, 'description' => $p->description); $children_pages[$p->key] = $p->children(); //ORM::factory('Page')->where('parent_id','=',$p->id)->find_all();//только первый уровень детей //второй уровень детей. foreach ($children_pages[$p->key] as $ch_p) { if ($ch_p->id == 232 or $ch_p->id == 159) { continue; } $children_pages_last[$ch_p->id] = $ch_p->children(); //третий уровень детей foreach ($children_pages_last[$ch_p->id] as $ch_p_l) { $children_pages_last_last[$ch_p_l->id] = $ch_p_l->children(); } } } $page_halyk_kaharmany = ORM::factory('Page', 319); $this->set('page_halyk_kaharmany', $page_halyk_kaharmany); $this->set('_pages', $page_main)->set('_children_pages', $children_pages)->set('_children_pages_last', $children_pages_last)->set('_children_pages_last_last', $children_pages_last_last)->set('_return_url', URL::media(Request::initial()->uri())); //для вывода сообщения о регистрации восстановления пароля и прочих действий //само сообщение выводится в модальном окне, находится в шаблоне footer if (Message::get()) { $this->set('basic_message', Message::display('/message/basic')); } $nofollowlink = url::media(Request::initial()->uri()); $controller = strtolower(Request::initial()->controller()); $action = strtolower(Request::initial()->action()); if ($controller == 'books' and $action == 'index') { $params = explode('books/', $_SERVER['REQUEST_URI']); if (isset($params[1]) and isset($params[0])) { $params = explode('?', $params[1]); $razdel = $params[0]; } else { $razdel = ''; } if (isset($params[1])) { $params = explode('=', $params[1]); $idbook = $params[1]; } else { $idbook = ''; } $wherestring = 'books_' . $razdel . '_' . $idbook; $page = ORM::factory('Page')->where('key', '=', $wherestring)->find(); $linkid = $page->id; $nofollowlink = URL::site('contents/list/' . $linkid); } if ($controller == 'biography' and $action == 'index') { $params = explode('biography/', $_SERVER['REQUEST_URI']); if (isset($params[1])) { $idbiography = $params[1]; } else { $idbiography = ''; } $wherestring = 'biography' . '_' . $idbiography; $page = ORM::factory('Page')->where('key', 'LIKE', $wherestring . '%')->find(); $linkid = $page->id; $nofollowlink = URL::site('contents/list/' . $linkid); } if ($controller == 'organization' and $action == 'show') { $params = explode('organization/show/', $_SERVER['REQUEST_URI']); if (isset($params[1])) { $idorganization = $params[1]; } else { $idorganization = ''; } $wherestring = 'organization' . '_' . $idorganization; $page = ORM::factory('Page')->where('key', 'LIKE', $wherestring . '%')->find(); $linkid = $page->id; $nofollowlink = URL::site('contents/list/' . $linkid); } if ($controller == 'expert' and $action == 'index') { $nofollowlink = URL::site('contents/list/301'); } //в базе дублируется запись 4 и 301 if ($controller == 'publications' and $action == 'index') { $nofollowlink = URL::site('contents/list/231'); } if ($controller == 'debate' and $action == 'index') { $nofollowlink = URL::site('contents/list/335'); } if ($controller == 'debate' and $action == 'index') { $nofollowlink = URL::site('contents/list/335'); } $this->set('nofollowlink', $nofollowlink); //потому-что SEO. }