本文整理汇总了PHP中Controller_Template::before方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller_Template::before方法的具体用法?PHP Controller_Template::before怎么用?PHP Controller_Template::before使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller_Template
的用法示例。
在下文中一共展示了Controller_Template::before方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
public function before()
{
parent::before();
if (empty(Session::get(self::LOGIN))) {
return Response::redirect('client/auth');
}
}
示例2: before
public function before()
{
parent::before();
$this->session = Session::instance();
# Check user authentication
$auth_result = true;
$action_name = Request::instance()->action;
if (array_key_exists($action_name, $this->auth)) {
$auth_result = $this->_check_auth($action_name);
} else {
if (array_key_exists('*', $this->auth)) {
$auth_result = $this->_check_auth('*');
}
}
if (!$auth_result) {
if (Auth::instance()->logged_in()) {
//! \todo Flash message.
Request::instance()->redirect('user');
} else {
Request::instance()->redirect('login');
}
}
// Try to pre-fetch the template. Doesn't have to succeed.
try {
$this->template->content = View::factory(Request::instance()->controller . '/' . Request::instance()->action);
} catch (Kohana_View_Exception $e) {
}
$this->template->title = ucwords(Request::instance()->action);
$this->template->left = null;
$this->template->right = null;
$this->template->footer = null;
$this->template->no_back_button = true;
$this->template->menu = array();
}
示例3: before
public function before()
{
parent::before();
$this->app = \Uri::segment(1);
// guess app_name, if it is not provided
if (is_null($this->app_name)) {
$this->app_name = \Inflector::classify($this->app);
}
// guess model name from URI segment, if it is not provided
if (is_null($this->model)) {
$this->model = 'Model_' . $this->app_name;
}
// set app title
$this->template->title = static::$title;
// render menus
$this->template->set('menu', Petro_Menu::render(static::$menu), false);
// use uri segment to find ref_type from defined menu for later use
$menu = Petro_Menu::find($this->app, static::$menu);
// if page_title is not set, default to menu label
if (!isset($this->template->page_title)) {
$this->template->page_title = empty($menu['label']) ? \Inflector::pluralize($this->app_name) : $menu['label'];
}
$this->sidebars = new Petro_Sidebar();
is_null($this->must_login) and $this->must_login = \Config::get('petro.auth.enable', true);
// if require login and not in the ignore login list, then check for login
if ($this->must_login and !in_array(\Uri::string(), static::$ignore_login)) {
if (!\Auth::instance()->check()) {
$this->login_then_redirect(\Uri::string());
}
}
}
示例4: before
public function before()
{
// Open remote URLs in a new window
html::$windowed_urls = TRUE;
/**
* Adding admin users
$user = ORM::factory('user');
$user->email = 'omryoz@gmail.com';
$user->username = 'omryo';
$user->password = 'test123';
$user->save();
// dont forget to add roles. 'login' role needs for successful login
//$user->add('roles', ORM::factory('role', array('name' => 'admin')));
$user->add('roles', ORM::factory('role', array('name' => 'login')));
*/
parent::before();
$this->template->scripts = array();
$this->template->styles = array();
$this->template->title = $this->template->content = '';
$auth = Auth::instance();
// set user
$this->_user = $auth->get_user();
$this->_admin = $this->_checkAdmin();
$this->_supadmin = $this->_checkSupadmin();
//echo $this->_user;
// handle ajax
if ($this->request->is_ajax()) {
// ajax like call detected, don't render whole template!
$this->_ajax = TRUE;
} else {
// initiates the template dynamic content (header, nav, panel, footer, ...)
$this->init();
}
}
示例5: before
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->api = Route::get('docs/api');
$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);
// Use customized Markdown parser
define('MARKDOWN_PARSER_CLASS', 'Kodoc_Markdown');
// 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();
}
示例6: before
public function before()
{
if ($this->tt == 0) {
return 0;
}
return parent::before();
}
示例7: before
public function before()
{
parent::before();
if (Request::current()->is_initial()) {
$this->request->action(404);
}
}
示例8: before
public function before()
{
// if(!CMS_User::instance()->is_authenticated()){
// $this->request->redirect(CMS_Infrastructure_Routes_Manager::login());
// }
parent::before();
$this->template->cms_url_prefix = URL_PREFIX;
$this->template->topmenu = View::factory('cms/navigation/top');
$this->template->leftmenu = View::factory('cms/navigation/left');
$this->set_caption('Модуль управления сайтом');
$this->set_content('', 'main_content');
$this->template->styles = array();
$this->add_style('cms/css/bootstrap.min.css');
$this->add_style('cms/font-awesome/css/font-awesome.css');
$this->add_style('cms/css/sb-admin-2.css');
$this->add_style('cms/css/style.css');
$this->template->scripts = array();
$this->add_script('cms/js/jquery-1.10.2.js');
$this->add_script('cms/js/bootstrap.min.js');
$this->add_script('cms/js/plugins/metisMenu/jquery.metisMenu.js');
$this->add_script('cms/js/plugins/cms/jquery.inputeditor.js');
$this->add_script('cms/js/plugins/cms/jquery.inputeditor2.js');
$this->add_script('cms/js/plugins/cms/jquery.controlselect.js');
$this->add_script('cms/js/plugins/cms/jquery.colorselect.js');
$this->add_script('cms/js/sb-admin.js');
$this->add_script('cms/js/script.js');
}
示例9: before
public function before()
{
// Run anything that need ot run before this.
parent::before();
if ($this->auto_render) {
// Initialize empty values
$this->template->title = 'SiRPEC';
$this->template->meta_keywords = '';
$this->template->meta_description = '';
$this->template->meta_copywrite = '';
$this->template->header = '';
$this->template->content = '';
$this->template->menu = '';
$this->template->footer = 'copyright AEVivienda';
$this->template->adminmenu = '';
$this->template->styles = array();
$this->template->scripts = array();
$this->template->menutop = '';
$this->template->titulo = '';
$this->template->descripcion = '';
$this->template->menutop = '';
$this->template->username = '';
$this->template->submenu = View::factory('user/menu');
$this->template->controller = 'index';
$this->template->theme = '#modx-topbar{border-bottom: 2px solid #249cf5;} #bos-main-blocks h2 a,h2.titulo v,.colorcito {color:#249cf5;}#menu-left ul li a:hover,#menu-left ul li:hover {color:#fff; background: #249cf5; font-weight: bold; } html #modx-topnav ul.modx-subnav li a:hover {background-color:#249cf5;} input#searchsubmit:hover {background-color:#249cf5;} #icon-logo{background:#249cf5 url(/media/images/icon_user.png) scroll left no-repeat; }.button2{border: 1px solid#249cf5;background-color:#249cf5;}.button2:hover, .button2:focus {background:#249cf5;}.jOrgChart .node { background-color:#249cf5;}.widget .title {background: none repeat scroll 0 0 #249cf5;} legend {border: 1px solid #249cf5;}fieldset { border: 2px solid#249cf5;}.proveido {color:#249cf5;}';
}
}
示例10: before
/**
* Construct controller
*/
public function before()
{
parent::before();
if (!Visitor::instance()->logged_in('admin')) {
throw new Permission_Exception(new Model_Role());
}
}
示例11: before
/**
* @return void
*/
public function before()
{
parent::before();
// Start a session
Session::instance();
// Load Auth instance
$this->auth = Auth::instance();
// Get the currently logged in user or set up a new one.
// Note that get_user will also do an auto_login check.
if (($this->user = $this->auth->get_user()) === FALSE)
{
$this->user = ORM::factory('user');
}
if ($this->auto_render)
{
// Initialize default values
$this->template->title = 'KohanaJobs v2';
$this->template->content = '';
$this->template->bind_global('user', $this->user);
}
}
示例12: before
/**
* Loads test suite
*/
public function before()
{
parent::before();
if( ! Kohana_Tests::enabled())
{
// Pretend this is a normal 404 error...
$this->status = 404;
throw new Kohana_Request_Exception('Unable to find a route to match the URI: :uri',
array(':uri' => $this->request->uri));
}
// Prevent the whitelist from being autoloaded, but allow the blacklist
// to be laoded
Kohana_Tests::configure_enviroment(FALSE);
$this->config = Kohana::$config->load('phpunit');
// This just stops some very very long lines
$route = Route::get('unittest');
$this->report_uri = $route->uri(array('controller' => 'phpunit', 'action' => 'report'));
$this->run_uri = $route->uri(array('controller' => 'phpunit', 'action' => 'run'));
// Switch used to disable cc settings
$this->xdebug_loaded = extension_loaded('xdebug');
$this->template->set_global('xdebug_enabled', $this->xdebug_loaded);
}
示例13: before
public function before()
{
parent::before();
View::set_global('base', URL::base(TRUE, FALSE));
$this->__JS__ = 'public/static/template/admin/';
$this->__CSS__ = 'public/static/template/admin/';
}
示例14: before
public function before()
{
parent::before();
if (!isset($this->_config)) {
$this->_config = Config::load('opauth', 'opauth');
}
}
示例15: before
public function before()
{
parent::before();
$auth = \Auth::instance('SimpleAuth');
if (\Input::get('logout')) {
$auth->logout();
\Response::redirect(\Uri::base(false) . 'admin/login');
}
$uri = explode('/', \Uri::string());
if ($auth->check()) {
if (count($uri) < 3 && (empty($uri[1]) || $uri[1] == 'login')) {
\Response::redirect(\Uri::base(false) . 'admin/list');
}
// Load admin Config for List View and default to first tab
$this->data['tabs'] = $this->template->tabs = \Config::get('admin.tabs');
$this->data['table'] = $this->param('item', '');
// get item from URI
if (!$this->data['table']) {
list($this->data['table']) = array_slice(array_keys($this->data['tabs']), 0, 1);
}
$this->template->table = $this->data['table'];
} elseif (count($uri) > 1 && $uri[1] != 'login') {
\Response::redirect(\Uri::base(false) . 'admin/login');
}
if ($this->auto_render === true) {
// set up defaults
$this->template->body = '';
}
return true;
}