public function action_index() { $code = $this->request->param('code'); if ($code === NULL) { Model_Page_Front::not_found(); } $reflink_model = ORM::factory('user_reflink', $code); if (!$reflink_model->loaded()) { Messages::errors(__('Reflink not found')); $this->go_home(); } $next_url = Arr::get($reflink_model->data, 'next_url'); try { Database::instance()->begin(); Reflink::factory($reflink_model)->confirm(); $reflink_model->delete(); Database::instance()->commit(); } catch (Kohana_Exception $e) { Database::instance()->rollback(); Messages::errors($e->getMessage()); } if (Valid::url($next_url)) { $this->go($next_url); } $this->go_home(); }
public function action_index() { $path = Download::decode_path($this->request->param('path')); if (!file_exists($path)) { if (IS_BACKEND) { throw new HTTP_Exception_404('File :file not found', array(':file' => $path)); } else { Model_Page_Front::not_found('File :file not found', array(':file' => $path)); } } $this->responses->send_file($path); }
/** * * @param type Model_Page_Front */ private function _render(Model_Page_Front $page) { View::set_global('page_object', $page); View::set_global('page', $page); $this->_ctx->set_page($page); // If page needs login, redirect to login if ($page->needs_login() == Model_Page::LOGIN_REQUIRED) { Observer::notify('frontpage_login_required', $page); if (!Auth::is_logged_in()) { Flash::set('redirect', $page->url()); $this->redirect(Route::get('user')->uri(array('action' => 'login'))); } } Observer::notify('frontpage_found', $page); $this->_ctx->set_crumbs($page); $this->_ctx->build_crumbs(); // Если установлен статус 404, то выводим страницу 404 // Страницу 404 могут выкидывать также Виджеты if (Request::current()->is_initial() and $this->response->status() == 404) { $message = $this->_ctx->get('throw_message'); $this->_ctx = NULL; if (!$message) { $message = 'Page not found'; } Model_Page_Front::not_found($message); } $html = (string) $page->render_layout(); // Если пользователь Администраторо или девелопер, в конец шаблона // добавляем View 'system/blocks/toolbar', в котором можно добавлять // собственный HTML, например панель администратора if (Auth::is_logged_in() and Auth::has_permissions(array('administrator', 'developer'))) { $inject_html = (string) View::factory('system/blocks/toolbar'); // Insert system HTML before closed tag body $matches = preg_split('/(<\\/body>)/i', $html, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); if (count($matches) > 1) { /* assemble the HTML output back with the iframe code in it */ $html = $matches[0] . $inject_html . $matches[1] . $matches[2]; } } // Если в наcтройках выключен режим отладки, то выключить etag кеширование if (Config::get('site', 'debug') == Config::NO) { $this->check_cache(sha1($html)); $this->response->headers('last-modified', date('r', strtotime($page->updated_on))); } $this->response->headers('Content-Type', $page->mime()); if (Config::get('global', 'x_powered_header') == Config::YES) { $this->response->headers('X-Powered-CMS', CMS_NAME . '/' . CMS_VERSION); } $this->response->body($html); }
public function execute() { $slug = $this->router()->param('item'); if (empty($slug)) { return; } $item_page_id = $this->settings()->item_page_id; // Если не найдена внутрення страница по SLUG if (($this->_page = Model_Page_Front::find($slug, FALSE, $this->page())) === FALSE) { // Производим поиск страницы которая укзана в настройках типа страницы if (!empty($item_page_id)) { $this->_page = Model_Page_Front::findById($item_page_id); return; } Model_Page_Front::not_found(); } }
/** * * @return array [$pages] */ public function fetch_data() { $page = $this->get_page(); if (!$page instanceof Model_Page_Behavior_Archive) { Model_Page_Front::not_found(); } $params = $page->behavior()->router()->params(); $date = implode('-', $params); $clause = array('where' => array(array('page.published_on', 'like', $date . '%')), 'order_by' => array(array('page.published_on', 'desc'))); if ($this->list_offset > 0) { $clause['offset'] = (int) $this->list_offset; } if ($this->list_size > 0) { $clause['limit'] = (int) $this->list_size; } $pages = $page->parent()->children($clause); return array('pages' => $pages); }