Example #1
0
 public function before()
 {
     Request::$theme = 'mobile';
     parent::before();
     $is_weixin = false;
     $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
     if (strpos($ua, 'micromessenger') !== false) {
         $is_weixin = true;
     }
     $auth = Auth::instance('member');
     $this->user = $auth->get_user();
     $curr_theme = 'cyan-red';
     if (isset($_COOKIE['apptheme']) && in_array($_COOKIE['apptheme'], array_keys($this->theme_list))) {
         $curr_theme = $_COOKIE['apptheme'];
     }
     $theme_color = $this->theme_list[$curr_theme];
     if ($this->auto_render === TRUE) {
         View::bind_global('is_weixin', $is_weixin);
         View::bind_global('user', $this->user);
         View::bind_global('theme_list', $this->theme_list);
         View::bind_global('theme_color', $theme_color);
         View::bind_global('curr_theme', $curr_theme);
         if ($is_weixin) {
             $wx_js_api = new WeixinJSAPI('test');
             $wx_jsapi_config = $wx_js_api->get_jsapi_config();
             View::bind_global('wx_jsapi_config', $wx_jsapi_config);
         }
     }
 }
Example #2
0
 public function before()
 {
     parent::before();
     $this->_ctx =& Context::instance();
     $this->_ctx->request($this->request)->response($this->response);
     View::bind_global('ctx', $this->_ctx);
 }
Example #3
0
File: Core.php Project: korejwo/coc
 public function before()
 {
     parent::before();
     $this->session = Session::instance();
     $this->config = Kohana::$config->load('app');
     View::bind_global('app_config', $this->config);
 }
Example #4
0
 public function before()
 {
     if ($this->auto_render) {
         $hostArr = explode('.', $_SERVER['HTTP_HOST']);
         $preDomain = $hostArr[0];
         $site = ORM::factory('Site')->where('domain', '=', $preDomain)->find();
         if ($site->loaded()) {
             $this->siteId = $site->id;
             $this->category = ORM::factory('Category')->getAll($site->id, Model_Category::STATUS_SHOW);
             $site = $site->as_array();
             $site['logo'] = '/media/image/data/' . $site['logo'];
             $site['category'] = $this->category;
             $site['author'] = '简站(Simple-Site.cn) - 免费建站、微信网站、免费微信网站!';
             $site['copyright'] = 'Copyright © 2015 SimpleSite. All Rights Reserved';
             $site['friendLinks'] = ORM::factory('FriendLink')->getAll($site['id']);
             $this->theme = "themes/{$site['theme']}/";
             $this->template = View::factory($this->theme . 'base');
             foreach ($site as $key => $value) {
                 View::bind_global($key, $site[$key]);
             }
         } else {
             echo '404';
             exit;
         }
     }
 }
Example #5
0
File: base.php Project: sajans/cms
 protected function set_theme()
 {
     View::bind_global('before', $false);
     View::bind_global('navigation', $false);
     View::bind_global('after_navigation', $false);
     View::bind_global('sidebar', $false);
     View::bind_global('pageheader', $false);
     //echo "<pre>";var_dump(Uri::current()); exit;
     //$theme = Utils_Themer::get_theme(Uri::current());
     $theme = Utils_Themer::get_theme($this->request->uri->uri);
     //var_dump($theme); exit;
     $this->template = view::forge($theme['template']);
     View::bind_global('body_attr', $theme['body_attr']);
     Asset::css($theme['css'], array(), 'head_css');
     foreach ($theme['js'] as $js) {
         Casset\Casset::js($js);
     }
     if ($theme['navigation']) {
         $navigation = call_user_func('Utils_Navigation::get_links', $theme['navigation']);
         View::bind_global('navigation', $navigation, false);
     }
     if ($theme['pageheader']) {
         View::bind_global('pageheader', $theme['pageheader']);
     }
 }
Example #6
0
 /** 
  * 页面及错误(Exception)
  * 
  * @param Exception $ex 
  * @param mixed $message
  *
  */
 public static function request_error(Exception $ex = null, $message = null)
 {
     $code = 'error';
     if (!is_null($ex)) {
         $message = $ex->getMessage();
         if (false !== stripos($message, 'Unable to find a route to match the URI') || false !== stripos($message, 'not found on this server')) {
             $code = 404;
         }
         // Log the error
         //    if( $GLOBALS['__mogujie']['log_errors'] ){
         //      Kohana::$log->add(Kohana_Log::ERROR, var_export($ex,true) );
         //  }
     }
     if (empty($message)) {
         $message = 'unkown error';
     }
     View::bind_global('message', $message);
     View::bind_global('exception', $ex);
     $msg = $message . '-' . $ex;
     View::bind_global('msg', $msg);
     $uri = request_uri();
     crond_log("uri:{$uri}; code:{$code}; msg:{$msg}; referer:{$_SERVER['HTTP_REFERER']}", 'request_error.log');
     switch ($code) {
         case 404:
             //header("Status: 404 Not Found"); //header("HTTP/1.0 404 Not Found");
             echo Request::factory("error/404")->execute();
             break;
         default:
             echo Request::factory("error/index")->execute();
             break;
     }
     exit;
 }
Example #7
0
 protected function _set_view_globals()
 {
     View::bind_global('site_title', $this->_config->site_title);
     View::bind_global('oUser', $this->_oUser);
     View::set_global('action', $this->request->action());
     View::set_global('welcome', Session::instance()->get('title'));
 }
Example #8
0
 public function __construct(Request $req)
 {
     parent::__construct($req);
     $m_role = Model::factory('role');
     $this->role_list = $m_role->getAll(array('status' => 'normal'))->as_array('id');
     View::bind_global('role_list', $this->role_list);
 }
Example #9
0
 public function view_prepare()
 {
     $controller = $this->request->controller();
     $action = $this->request->action();
     View::bind_global('controller', $controller);
     View::bind_global('action', $action);
     // Load the template
     if (!$this->template instanceof View) {
         $this->template = View::factory($this->template);
     }
     $this->template->title = $GLOBALS['WEB_TITLE'];
     $this->template->scripts = array();
     //放在头部的Javascript
     $this->template->scriptscoda = array();
     //放在尾部的Javascript
     $this->template->scriptsglobe = array();
     //放在尾部的全局Javascript
     $this->template->styles = array();
     $this->add_style('reset.css');
     $this->add_style('base.css');
     $this->add_style('globe.css');
     //$this->add_script('jquery-1.7.2.min.js','head');
     $this->add_script('jquery-1.11.2.min.js', 'head');
     $this->add_script('jquery-migrate-1.2.1.min.js', 'head');
     $this->add_script('base.js', 'head');
     $this->add_script('globe.js', 'foot');
     $this->set_keywords($GLOBALS['WEB_KEYWORDS']);
     $this->set_description($GLOBALS['WEB_DESC']);
 }
Example #10
0
 public function before()
 {
     parent::before();
     $this->params = Arr::extract($this->request->param(), array('year', 'month', 'day'));
     View::bind_global('params', $this->params);
     View::bind_global('content', $this->content);
 }
Example #11
0
 public function before()
 {
     parent::before();
     View::bind_global('preview', $this->preview);
     if ($this->request->action() === 'index') {
         $this->page = Model_Page::find_by_slug($this->request->param('catcher'));
     } else {
         if (!Can::show()) {
             throw new Kohana_Exception("Permission Denied.");
         }
         $this->preview = TRUE;
         if ($this->request->query('preview') !== NULL) {
             $this->preview = (bool) $this->request->query('preview');
         }
         if ($this->request->query('id_page') !== NULL) {
             $id_page = (bool) $this->request->query('id_page');
             $this->page = Model_Page::factory('Page')->where('id_page', '=', $id_page)->order_by('id', 'DESC')->find();
             dd($this->page);
         } else {
             $page_id = (int) $this->request->param('id');
             $this->page = Model_Page::factory('Page', $page_id);
         }
     }
     View::bind_global('page', $this->page);
     $this->content = $this->page->render_blocks();
 }
Example #12
0
File: Ad.php Project: andygoo/admin
 public function before()
 {
     parent::before();
     View::bind_global('types', $this->types);
     View::bind_global('plats', $this->plats);
     View::bind_global('cities', $this->cities);
 }
Example #13
0
 public function before()
 {
     parent::before();
     // Make $page_title available to all views
     View::bind_global('page_title', $this->page_title);
     // Load $sidebar into the template as a view
     //$this->template->sidebar = View::factory('template/sidebar');
 }
Example #14
0
File: User.php Project: korejwo/coc
 public function before()
 {
     parent::before();
     $this->user = new Model_User();
     $this->config = Kohana::$config->load('app');
     $this->logged_in = Auth::instance()->logged_in();
     View::bind_global('app_config', $this->config);
 }
Example #15
0
 public function action_index()
 {
     $posts = ORM::factory('Post')->order_by('created', 'DESC')->find_all();
     $paginator = Paginator::factory($posts);
     $paginator->set_item_count_per_page(5);
     $paginator->set_current_page_number(Arr::get($_GET, 'page', 1));
     View::bind_global('posts', $paginator);
     $this->template->content = View::factory('blog/index');
 }
Example #16
0
File: Shop.php Project: andygoo/cms
 public function __construct(Request $request)
 {
     parent::__construct($request);
     $this->obj_cart = new Cart();
     if ($this->auto_render === TRUE) {
         $this->cart = $this->obj_cart->contents();
         View::bind_global('cart', $this->cart);
     }
 }
Example #17
0
 public function before()
 {
     parent::before();
     if (Auth::instance()->logged_in()) {
         $this->user = Auth::instance()->get_user();
         //now you have access to user information stored in the database
         View::bind_global('user', $this->user);
     }
 }
Example #18
0
 public function action_index()
 {
     $user = Auth::instance()->get_user();
     View::bind_global('user', $user);
     $sitename = Kohana::$config->load('site.sitename');
     View::bind_global('sitename', $sitename);
     $pages = ORM::factory('page')->order_by('date', 'DESC')->limit(10)->find_all();
     $catalogs = ORM::factory('catalog')->order_by('date', 'DESC')->limit(10)->find_all();
     $this->template->main = View::factory('admin/blocks/V_main')->bind('pages', $pages)->bind('catalogs', $catalogs);
 }
Example #19
0
 public function before()
 {
     parent::before();
     $this->session = Session::instance();
     $this->config = Kohana::$config->load('app');
     $this->brand = new Model_Brand();
     $this->product = new Model_Product();
     $this->size = new Model_Size();
     View::bind_global('app_config', $this->config);
 }
Example #20
0
 public function before()
 {
     parent::before();
     $authentic = Auth::instance();
     if ($authentic->logged_in()) {
         $this->user = $authentic->get_user();
         //now you have access to user information stored in the database
         View::bind_global('user', $this->user);
     } else {
         $this->request->redirect('login');
     }
 }
Example #21
0
 public function action_save()
 {
     $block = new stdClass();
     $block->data = $this->request->post();
     $block->page_id = $this->request->query('page_id');
     $block->page_block_template_id = $this->request->query('page_block_template_id');
     View::set_global('preview', TRUE);
     $page = Model_Page::factory('Page', $block->page_id);
     View::bind_global('page', $page);
     $result = Model_Page::instance()->render_block($block);
     $this->response->body($result);
 }
Example #22
0
 public function __construct(Request $req)
 {
     parent::__construct($req);
     $m_permit = Model::factory('permit');
     $this->permits = $m_permit->getAll()->as_array('id');
     $permits = array();
     foreach ($this->permits as $permit) {
         $cat = $permit['cat'];
         $permits[$cat][] = $permit;
     }
     View::bind_global('permits', $permits);
 }
Example #23
0
 public function before()
 {
     parent::before();
     View::set_global('title', 'Olgabro портфолио');
     View::set_global('description', 'Olgabro портфолио');
     View::set_global('keywords', 'Olgabro, портфолио');
     View::set_global('email', '*****@*****.**');
     View::set_global('phone', '+38 (099) 45 987 43');
     View::bind_global('data', $data);
     $this->template->content = '';
     $this->template->styles = array('main');
     $this->template->scripts = '';
 }
Example #24
0
 /**
  * Automatically executed before the controller action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     if (JFactory::getApplication()->isSite()) {
         $this->params = JComponentHelper::getParams(JRequest::getVar('option'));
         $this->params->merge(JFactory::getApplication()->getParams());
     } else {
         // Create an empty JRegistry object
         $this->params = new JRegistry();
     }
     if (!defined('KOJO_VIEW_GLOBALS')) {
         View::bind_global('params', $this->params);
         define('KOJO_VIEW_GLOBALS', TRUE);
     }
 }
Example #25
0
 public function before()
 {
     $this->nombre_consejo = Model_Globales::$nombre_consejo;
     // Hacemos disponible las variables generales
     View::bind_global('nombre_consejo', $this->nombre_consejo);
     View::bind_global('titulo', $this->titulo);
     View::bind_global('contenido', $this->contenido);
     if (Model_Usuario::esta_iniciado()) {
         View::set_global("admin_lateral", View::factory("admin/menu_lateral"));
     } else {
         View::set_global("admin_lateral", NULL);
     }
     parent::before();
 }
Example #26
0
 public function before()
 {
     if ($this->request->user_agent('mobile')) {
         Request::$theme = 'mobile';
     }
     parent::before();
     if ($this->auto_render === TRUE) {
         View::bind_global('uri', $this->request->uri);
         View::bind_global('controller', $this->request->controller);
         View::bind_global('action', $this->request->action);
         View::bind_global('title', $this->title);
         View::bind_global('content', $this->content);
     }
 }
Example #27
0
 public function before()
 {
     parent::before();
     $this->curr_db = $this->request->param('database', 'default');
     $model = new Model($this->curr_db);
     $tables = $model->list_tables()->as_array();
     $tables = array_map('array_pop', $tables);
     $this->curr_table = $this->request->param('table');
     View::bind_global('tables', $tables);
     View::bind_global('curr_db', $this->curr_db);
     View::bind_global('curr_table', $this->curr_table);
     View::bind_global('action', $this->request->action);
     View::bind_global('content', $this->content);
 }
Example #28
0
 public function __construct(Request $request)
 {
     parent::__construct($request);
     $city_pinyin = $this->request->param('city_pinyin', 'bj');
     $all_city = Common::$city_list;
     foreach ($all_city as $item) {
         if ($city_pinyin == $item[1]) {
             $this->city_info = array('city_id' => $item[0], 'city_pinyin' => $item[1], 'city_name' => $item[2]);
         }
     }
     if ($this->auto_render === TRUE) {
         View::bind_global('city_info', $this->city_info);
     }
 }
Example #29
0
 public function before()
 {
     parent::before();
     $this->session = Session::instance();
     $this->config = Kohana::$config->load('app');
     $this->photo = new Model_Photo();
     $this->stats = new Model_Stats();
     if ($session_hash = $this->session->get("session_hash")) {
         $this->session_hash = $session_hash;
     } else {
         $this->session_hash = md5(uniqid());
         $this->session->set("session_hash", $this->session_hash);
     }
     View::bind_global('app_config', $this->config);
 }
Example #30
0
 public function sendConfirmEmail()
 {
     if ($this->email_verified == 'True') {
         return false;
     }
     $this->generate_key();
     $html_email = View::factory('register/verify_email_html');
     $text_email = View::factory('register/verify_email_text');
     $link = url::site('register/verify/?' . 'key=' . $this->activation_key . '&id=' . $this->id);
     View::bind_global('link', $link);
     $email = new Model_Email();
     $email->message(array($this->email => $this->fullname()), '[Code-Wars] Welcome to Code-Wars', $html_email, $text_email);
     $this->new_email = false;
     $this->save();
     return true;
 }