public function before() { $config = Kohana::$config->load('common'); $this->template = $config->template_name; parent::before(); if (Auth::instance()->logged_in()) { $user = new Model_User(); $this->template->topbar = View::factory('profile/topbar')->set('users', $user->where('id', '=', Auth::instance()->get_user()->pk())->find())->set('users_levels', $user->get_level(Auth::instance()->get_user()->pk())); } else { $this->template->topbar = View::factory('login'); } $this->template->stylesheets = $config->stylesheets; $this->template->site_name = $config->site_name; if (Auth::instance()->logged_in()) { $user_id = Auth::instance()->get_user()->pk(); $roles = ORM::factory('Roles_User')->get_last_role_id($user_id); foreach ($roles as $role) { if ($role->role_id == 1) { if ($this->request->directory() == 'dashboard') { $this->request->redirect(''); } if ($this->request->uri() == 'dashboard') { $this->request->redirect(''); } } } } else { if ($this->request->directory() == 'dashboard') { $this->request->redirect(''); } if ($this->request->uri() == 'dashboard') { $this->request->redirect(''); } } }
public function before() { if (!(Auth::instance()->logged_in("admin") or Auth::instance()->logged_in("internal")) and $this->request->controller() !== 'user' and $this->request->action() !== 'log' and $this->request->param('id') !== 'in') { $back_url = "?back_url=" . URL::site($this->request->uri()) . (!empty($_GET) ? "?" . http_build_query($_GET, '&') : ""); $this->redirect('admin/user/log/in' . $back_url); } parent::before(); }
public function before() { parent::before(); $config = Kohana::$config->load('common'); $this->template->site_name = $config->site_name; $this->template->stylesheets = $config->stylesheets; $this->template->scripts = $config->scripts; }
public function before() { if ($this->request->is_ajax()) { $this->profiler = NULL; $this->auto_render = FALSE; header('content-type: application/json'); } parent::before(); }
public function before() { parent::before(); $this->checkAuth(); $this->modelStructure = new Structure(); $this->modelStructureArticle = new Structure_Article(); $this->modelStructureRole = new Structure_Role(); $this->config = Kohana::$config->load("structure"); $this->uploadPath = MODPATH . "/dynamic-structure/upload/"; }
/** * Checks for a media file */ public function before() { if ($this->request->action == 'media') { $this->auto_render = FALSE; } else { parent::before(); $this->dir = $this->request->param('dir'); $view_data = array('css' => array('console/media/css/reset.css' => 'screen', 'console/media/css/console.css' => 'screen'), 'js' => array('console/media/js/jquery-1.3.2.min.js', 'console/media/js/console.js')); $this->template->set($view_data); } }
public function before() { // Before anything, checks module installation $this->migrations = new Flexiblemigrations(true); try { $this->model = ORM::factory('Migration'); } catch (Database_Exception $a) { echo 'Flexible Migrations is not installed. Please Run the migrations.sql script in your mysql server'; exit; } parent::before(); }
public function before() { parent::before(); $this->template->set(array('head' => new View('components/head.phtml'), 'footer' => new View('components/footer.phtml'), 'pages' => new View('components/pages.phtml'))); // Get pages $pages = Request::factory('articles/all.json'); $pages->get = array('articles' => 0); $pages = $pages->execute(); // Parse the articles if ($pages->status === 200) { $pages = json_decode($pages->body); $this->template->set_global('pages', $pages); } }
public function before() { parent::before(); I18n::lang('fi'); // Translates are fetched from i18n/fi.php // Some initializing of template variables $this->template->title = ''; $this->template->main_nav = ''; $this->template->sidebar = array(); $this->template->scripts = array(); $this->template->inline_scripts = array(); $this->template->custom_data = array(); $this->template->layout_columns = array(false, 12); }
public function before() { parent::before(); /* twitter sandbox for the kohanatwitlib, if you are going to do * extensive testing please create your own account * same password for both accounts */ $username = '******'; //$username = '******'; $password = '******'; $this->t = Twitter::instance($username, $password); $this->u = $username; print '<h1>' . $this->request->param('action') . '</h1>'; print "<h2>user: {$username}</h2>"; }
public function before() { parent::before(); $config = Kohana::$config->load('common'); $this->template->name = $config->name; $this->template->stylesheets = $config->stylesheets; $categories = new Model_Category(); $client = new Model_Client(); $product = new Model_Product(); $this->template->products = $product->get_random_product_with_discount(); $this->template->valute = $client->get_user_valute(Session::instance()->get('email')); $this->template->categories = $categories->get_list_of_categories(); $this->template->users = $client->get_user_data(Session::instance()->get('email')); $this->template->scripts = $config->scripts; }
public function before() { parent::before(); if ($this->auto_render === TRUE) { // Render flash msg $session = Session::instance(); if ($msg = $session->get_once('err_msg')) { $this->template->err_msg = $msg; } elseif ($msg = $session->get_once('info_msg')) { $this->template->info_msg = $msg; } // XXX Not efficient, need improvement $this->view = View::factory(); } }
public function before() { // Before anything, checks module installation $this->migrations = new Flexiblemigrations(TRUE); if (!Auth::instance()->logged_in()) { $this->redirect('/'); } $user = Auth::instance()->get_user(); if (!$user->has_access('a')) { $this->redirect('/'); } try { $this->model = ORM::factory('Migration'); } catch (Database_Exception $a) { echo 'Flexible Migrations is not installed. Please Run the migrations.sql script in your mysql server'; exit; } parent::before(); }
public function before() { //J'ai préféré utiliser la fonction Kohana::cache plutôt que le module Cache if (Kohana::cache('sidebar_categories') == NULL) { $sidebar_categories = ORM::factory('Category')->order_by('post_count', 'DESC')->find_all(); Kohana::cache('sidebar_categories', $sidebar_categories->cached(), 60 * 60); // 60s * 60s = 1 heure } View::set_global('sidebar_categories', Kohana::cache('sidebar_categories')); if (Kohana::cache('sidebar_posts') == NULL) { $sidebar_posts = ORM::factory('Post')->order_by('created', 'DESC')->order_by('id', 'DESC')->limit(2)->find_all(); Kohana::cache('sidebar_posts', $sidebar_posts->cached(), 60 * 60); // 60s * 60s = 1 heure } View::set_global('sidebar_posts', Kohana::cache('sidebar_posts')); if (strrpos($this->request->action(), 'post_') === FALSE) { parent::before(); } //pas besoin de créer une vue pour ce cas }
public function before() { if ($this->request->action === 'media') { // Do not template media files $this->auto_render = FALSE; } else { // Grab the necessary routes $this->media = Route::get('docs/media'); $this->guide = Route::get('docs/guide'); if (isset($_GET['lang'])) { $lang = $_GET['lang']; // Load the accepted language list $translations = array_keys(Kohana::message('userguide', 'translations')); if (in_array($lang, $translations)) { // Set the language cookie Cookie::set('userguide_language', $lang, Date::YEAR); } // Reload the page $this->request->redirect($this->request->uri); } // Set the translation language I18n::$lang = Cookie::get('userguide_language', Kohana::config('userguide')->lang); if (defined('MARKDOWN_PARSER_CLASS')) { throw new Kohana_Exception('Markdown parser already registered. Live documentation will not work in your environment.'); } // Use customized Markdown parser define('MARKDOWN_PARSER_CLASS', 'Kodoc_Markdown'); if (!class_exists('Markdown', FALSE)) { // Load Markdown support require Kohana::find_file('vendor', 'markdown/markdown'); } // Set the base URL for links and images Kodoc_Markdown::$base_url = URL::site($this->guide->uri()) . '/'; Kodoc_Markdown::$image_url = URL::site($this->media->uri()) . '/'; } parent::before(); }
public function before() { parent::before(); }
public function before() { parent::before(); $config = Kohana::$config->load('common'); $this->template->set('site_title', $config->site_title); }
public function before() { parent::before(); $setting = Kohana::$config->load('common'); $this->template->set('site_title', $setting['site_title'])->set('img_descr', $setting['img_descr'])->set('site_description', $setting['site_description'])->set('footer', View::factory('template/footer')); }
/** * Binds some common variables to the template view, such as * `title`, `messages` etcetera. */ public function before() { parent::before(); View::bind_global('messages', $this->messages); }