当前位置: 首页>>代码示例>>PHP>>正文


PHP Tpl::set_global方法代码示例

本文整理汇总了PHP中Tpl::set_global方法的典型用法代码示例。如果您正苦于以下问题:PHP Tpl::set_global方法的具体用法?PHP Tpl::set_global怎么用?PHP Tpl::set_global使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tpl的用法示例。


在下文中一共展示了Tpl::set_global方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_index


//.........这里部分代码省略.........
         $get_user = Auth::instance()->get_user();
         // Build logged_in_user
         $this->logged_in_user = (object) array('id' => $get_user->id, 'email' => $get_user->email, 'username' => $get_user->username, 'logins' => $get_user->logins, 'last_login' => $get_user->last_login, 'ext' => $get_user->ext, 'avatar' => FALSE, 'detail' => FALSE, 'role' => FALSE);
         // Set logged in user avatar
         if (is_file('application/' . Cms_Helper::settings('image_dir') . '/user/' . $get_user->username . '/avatar' . $get_user->ext)) {
             $this->logged_in_user->avatar = (object) array('path' => URL::site("imagefly", 'http') . '/user/' . $get_user->username . '/', 'file' => '/' . 'avatar' . $get_user->ext);
         }
         // Set logged in user detail
         $this->logged_in_user->detail = Tbl::factory('users_details')->join('details')->on('users_details.detail_id', '=', 'details.id')->select('users_details.*')->select('details.name')->select('details.segment')->where('users_details.user_id', '=', $get_user->id)->read()->as_array('segment');
         // Set logged in user role
         $this->logged_in_user->role = Tbl::factory('roles_users')->select('roles.*')->join('roles')->on('roles_users.role_id', '=', 'roles.id')->where('roles_users.user_id', '=', $get_user->id)->where('roles.name', '!=', 'login')->read('name');
     }
     // </editor-fold>
     /**
      * Set global value
      */
     // <editor-fold defaultstate="collapsed" desc="Set global value">
     // Get site details
     $site = array();
     $site_detail_string = explode("\n", $settings->site_details);
     if ($site_detail_string) {
         foreach ($site_detail_string as $value) {
             $array = explode(':', $value);
             $site[trim($array[0])] = trim($array[1]);
         }
     }
     // Build logged_in_user
     if ($this->logged_in_user) {
         $logged_in_user = clone $this->logged_in_user;
         unset($logged_in_user->password, $logged_in_user->reset_key);
     } else {
         $logged_in_user = $this->logged_in_user;
     }
     Tpl::set_global(array('host' => URL::base(true), 'media_dir' => URL::site('media', 'http') . '/', 'images_dir' => URL::site('media/images', 'http') . '/', 'imagefly' => URL::site('imagefly/item', 'http') . '/', 'css_dir' => URL::site('media/css', 'http') . '/', 'js_dir' => URL::site('media/js', 'http') . '/', 'icon_dir' => URL::site('media/icon', 'http') . '/', 'lang' => $settings->lang, 'logged_in_user' => $logged_in_user, 'time' => time(), 'return' => PHP_EOL, 'site_title' => $settings->site_title, 'site_email_address' => $settings->site_email_address, 'site' => $site));
     // </editor-fold>
     /**
      * If logout
      */
     // <editor-fold defaultstate="collapsed" desc="If logout">
     // If query ここはログイン機能OFFでもログアウト
     if ($this->request->query('logout')) {
         Cms_Item::logout();
         $this->redirect();
     }
     // </editor-fold>
     /**
      * If post register
      */
     // <editor-fold defaultstate="collapsed" desc="register">
     // If switch and post レジスター機能ONのときポストがあったら
     if ($settings->author_register_is_on and $this->request->post('register')) {
         Cms_Item::register($this->request->post());
     }
     // </editor-fold>
     /**
      * If get activate
      */
     // <editor-fold defaultstate="collapsed" desc="activate">
     // If switch and post レジスター機能ONでアクティベートONのときポストがあったら
     if ($settings->author_register_is_on and $settings->author_register_activate_is_on and $this->request->query('activate_key')) {
         Cms_Item::activate($this->request->query());
     }
     // </editor-fold>
     /**
      * If post forgot
      */
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:67,代码来源:Item.php

示例2: after

 /**
  * After
  */
 public function after()
 {
     // Auto render
     if ($this->auto_render) {
         /**
          * build snippets -> snippetsようにつくるようにつくる!
          */
         // <editor-fold defaultstate="collapsed" desc="build snippets">
         // Get site details
         $sites = array();
         $site_details = Tbl::factory('settings')->where('key', '=', 'site_details')->read('value');
         $site_detail_strings = explode("\n", $site_details);
         if ($site_detail_strings) {
             foreach ($site_detail_strings as $site_detail_string) {
                 $array = explode(':', $site_detail_string);
                 $sites[trim($array[0])] = array('key' => trim($array[0]), 'value' => trim($array[1]));
             }
         }
         // Get items for snippets item. 下の$this->snippetsのitemに入れるように取得する
         $snippet_item = NULL;
         if ($this->request->param('key')) {
             $snippet_item_segment = Tbl::factory('items')->where('id', '=', $this->request->param('key'))->read('segment');
             if ($snippet_item_segment) {
                 $snippet_item = Cms_Functions::get_item($snippet_item_segment, TRUE, TRUE, TRUE);
             }
         }
         // Get parts for snippets part. 下の$this->snippetsのpartsに入れるように取得する
         $snippet_parts = Cms_Helper::get_dirfiles('part', $this->settings->front_tpl_dir);
         foreach ($snippet_parts as $snippet_part) {
             $snippet_part->content = Tpl::get_file($snippet_part->segment, $this->settings->front_tpl_dir . '/part');
         }
         // Set snippets
         $this->snippets = array('host' => URL::base(true), 'media_dir' => URL::site('media', 'http') . '/', 'images_dir' => URL::site('media/images_dir', 'http') . '/', 'css_dir' => URL::site('media/css_dir', 'http') . '/', 'js_dir' => URL::site('media/js_dir', 'http') . '/', 'icon_dir' => URL::site('media/icon_dir', 'http') . '/', 'lang' => $this->settings->lang, 'logged_in_user' => array('id' => isset($this->logged_in_user->id) ? $this->logged_in_user->id : NULL, 'email' => isset($this->logged_in_user->email) ? $this->logged_in_user->email : NULL, 'username' => isset($this->logged_in_user->username) ? $this->logged_in_user->username : NULL, 'logins' => isset($this->logged_in_user->logins) ? $this->logged_in_user->logins : NULL, 'details' => isset($this->logged_in_user->details) ? $this->logged_in_user->details : NULL), 'sites' => $sites, 'timestamp' => time(), 'return' => 'PHP_EOL', 'item' => isset($snippet_item) ? (object) $snippet_item : NULL, 'parts' => isset($snippet_parts) ? (object) $snippet_parts : NULL);
         // </editor-fold>
         /**
          * View
          */
         // <editor-fold defaultstate="collapsed" desc="View">
         // Set global value -> Set to contentといっしょ
         Tpl::set_global(array('host' => URL::base(true), 'site_title' => $this->settings->site_title, 'site_email_address' => $this->settings->site_email_address, 'backend_host' => URL::base(true) . $this->settings->backend_name . '/', 'logged_in_user' => $this->logged_in_user, 'logout_url' => URL::site("{$this->settings->backend_name}/logout", 'http'), 'time' => time()));
         // Set to content
         $this->content->set('menus', $this->menus)->set('notice', Notice::render())->set('local_menus', $this->local_menus)->set('frontend_link', $this->frontend_link)->set('snippets', $this->snippets);
         // Get tamplate file
         $template = Tpl::get_file('template', $this->settings->back_tpl_dir);
         $backend_ucfirst = str_replace('_', ' ', Text::ucfirst($this->settings->backend_name, '_'));
         // Factory and set
         $this->template = Tpl::factory($template)->set('title', $backend_ucfirst)->set('keywords', $backend_ucfirst)->set('description', $backend_ucfirst)->set('content', $this->content->render());
         // Render body
         $this->response->body($this->template->render());
         // </editor-fold>
     }
     /**
      * after
      */
     parent::after();
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:59,代码来源:Template.php


注:本文中的Tpl::set_global方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。