/**
  * Checks to see if the current items is cached.
  * @param string $template The tempalte to check
  * @return boolean True if the template was cached
  */
 public function is_cached($template, $cache_id = null)
 {
     if (is_null($cache_id)) {
         return $this->_smarty->is_cached($template);
     } else {
         return $this->_smarty->is_cached($template, $cache_id);
     }
 }
 /**
  * キャッシュテンプレート表示処理
  *
  * @param <type> $name
  */
 public function display($name)
 {
     // キャッシュされていれば、それを表示する
     if ($this->_smarty->is_cached($name, $this->_cache_id)) {
         $this->_smarty->display($name, $this->_cache_id);
         exit;
     }
 }
Example #3
0
 /**
  * test to see if valid cache exists for this template
  *
  * @param string $tpl_file name of template file
  * @param string $cache_id
  * @param string $compile_id
  * @return string|false results of {@link _read_cache_file()}
  */
 function is_cached($tpl_file, $cache_id = null, $compile_id = null)
 {
     if (!$this->caching) {
         return false;
     }
     if (!isset($compile_id)) {
         $compile_id = $this->language->getCurrentLanguage() . '-' . $this->compile_id;
         $cache_id = $compile_id;
     }
     return parent::is_cached($tpl_file, $cache_id, $compile_id);
 }
Example #4
0
 /**
  * 重载Smarty中的is_cached方法
  * @param	string	$tpl_file	模板的位置
  * @param	mixed	$cache_id	缓存的ID
  */
 public function is_cached($tpl_file = null, $cache_id = null, $compile_id = null)
 {
     if (is_null($tpl_file)) {
         $tpl_file = $_GET['m'] . '/' . $_GET['a'] . '.' . TPLPREFIX;
     } else {
         if (strstr($tpl_file, '/')) {
             $tpl_file = $tpl_file . TPLPREFIX;
         } else {
             $tpl_file = $_GET['m'] . '/' . $tpl_file . '.' . TPLPREFIX;
         }
     }
     return parent::is_cached($tpl_file, $cache_id, $compile_id);
 }
Example #5
0
 function is_cached($tpl_file = null, $cache_id = null, $compile_id = null)
 {
     if (is_null($tpl_file)) {
         $tpl_file = "{$_GET["m"]}/{$_GET["a"]}." . TPLPREFIX;
     } else {
         if (strstr($tpl_file, "/")) {
             $tpl_file = $tpl_file . "." . TPLPREFIX;
         } else {
             $tpl_file = $_GET["m"] . "/" . $tpl_file . "." . TPLPREFIX;
         }
     }
     return parent::is_cached($tpl_file, $cache_id, $compile_id);
 }
Example #6
0
 /**
  * Finds out if a template is already cached.
  *
  * This returns true if there is a valid cache for this template.
  *
  * @param string $template   The name of the template.
  * @param string $cache_id   The cache ID (optional).
  * @param string $compile_id The compile ID (optional).
  *
  * @return boolean
  */
 public function is_cached($template, $cache_id = null, $compile_id = null)
 {
     if (is_null($cache_id)) {
         $cache_id = $this->cache_id;
     }
     if (is_null($compile_id)) {
         $compile_id = $this->compile_id;
     }
     return parent::is_cached($template, $cache_id, $compile_id);
 }
 /**
  * finds out if a template is already cached
  *
  * This returns true if there is a valid cache for this template.
  * Right now, we are just passing it to the original Smarty function.
  * We might introduce a function to decide if the cache is in need
  * to be refreshed...
  *
  * @param   string   $template    the name of the template
  * @param   string   $cache_id    (optional) the cache ID
  * @return  boolean
  */
 function is_cached($template, $cache_id = null, $compile_id = null)
 {
     // insert the condition to check the cache here!
     // if (functioncheckdb($this -> module)) {
     //        return parent :: clear_cache($template, $this -> cache_id);
     //}
     $this->_setup_template($template);
     if ($cache_id) {
         $cache_id = $this->module . '|' . $cache_id;
     } else {
         $cache_id = $this->module . '|' . $this->cache_id;
     }
     if (!isset($compile_id)) {
         $compile_id = $this->compile_id;
     }
     return parent::is_cached($template, $cache_id, $compile_id);
 }
Example #8
0
 /**
  * Use Smarty caching
  *
  * The last two methods were created to simply integrate the Smarty caching mechanism in the View class. With the first one you can check for cached template and with the second one you can set the caching on or of.
  *
  * @param string $template
  * @return bool
  */
 public function isCached($template)
 {
     return $this->_smarty->is_cached($template);
 }
Example #9
0
 function print_summary($type = 'full')
 {
     global $current_user, $globals, $the_template, $smarty;
     include_once './Smarty.class.php';
     $smarty = new Smarty();
     $smarty->compile_check = false;
     // enable caching at your own risk. this code is still experimental
     //$smarty->cache = true;
     $smarty->cache_lifetime = 120;
     $smarty->cache_dir = "templates_c/";
     $smarty->compile_dir = "templates_c/";
     $smarty->template_dir = "templates/";
     $smarty->config_dir = "";
     if (!$smarty->is_cached($the_template . '/link_summary.tpl', 'story' . $this->id . "|" . $current_user->user_id . "|" . $type)) {
         if (phpnum() == 4) {
             $smarty->force_compile = true;
         }
         $smarty = $this->fill_smarty($smarty, $type);
         $smarty->assign('use_title_as_link', use_title_as_link);
         $smarty->assign('open_in_new_window', open_in_new_window);
         $smarty->assign('use_thumbnails', use_thumbnails);
         $smarty->assign('the_template', The_Template);
         // this is soooo ugly. we'll fix this for beta 9
         $main_smarty = $smarty;
         include mnminclude . 'extra_fields_smarty.php';
         $smarty = $main_smarty;
     }
     $smarty->display($the_template . '/link_summary.tpl', 'story' . $this->id . "|" . $current_user->user_id . "|" . $type);
 }
Example #10
0
 function is_cached($tpl_file = null, $cache_id = null, $compile_id = null)
 {
     return parent::is_cached($this->templateName, $this->cacheId);
 }
 function is_cached($_smarty_tpl_file, $_smarty_cache_id = null, $_smarty_compile_id = null)
 {
     global $prefs, $style_base, $tikidomain;
     if (isset($prefs['style']) && isset($style_base)) {
         if ($tikidomain and file_exists("templates/{$tikidomain}/styles/{$style_base}/{$_smarty_tpl_file}")) {
             $_smarty_tpl_file = "{$tikidomain}/styles/{$style_base}/{$_smarty_tpl_file}";
         } elseif ($tikidomain and file_exists("templates/{$tikidomain}/{$_smarty_tpl_file}")) {
             $_smarty_tpl_file = "{$tikidomain}/{$_smarty_tpl_file}";
         } elseif (file_exists("templates/styles/{$style_base}/{$_smarty_tpl_file}")) {
             $_smarty_tpl_file = "styles/{$style_base}/{$_smarty_tpl_file}";
         }
     }
     $_smarty_cache_id = $prefs['language'] . $_smarty_cache_id;
     $_smarty_compile_id = $prefs['language'] . $_smarty_compile_id;
     return parent::is_cached($_smarty_tpl_file, $_smarty_cache_id, $_smarty_compile_id);
 }
Example #12
0
 /**
  * Returns whever current loaded template is cached or not
  * @return	bool	true if cached
  */
 public function cached()
 {
     return parent::is_cached($this->data['template'] . ".tpl", $this->data['cache_version'], BF::gc('locale_enabled') ? BF::gl()->locale : null);
 }
// MODEL
//----------------------------------------------------------------------------------------------------------------------------------//
include_once "./common/include.display.members.php";
include_once "./common/include.display.committees.php";
include_once "./common/include.display.achievements.php";
include_once "./common/include.display.todaysattendance.php";
include_once "./common/include.display.recentachievements.php";
include_once "./common/include.display.perfectattendance.php";
include_once "./common/include.display.attendance.php";
include_once "./common/include.display.charts.php";
//----------------------------------------------------------------------------------------------------------------------------------//
// CONTROLLER
//----------------------------------------------------------------------------------------------------------------------------------//
if (isset($_GET['charts'])) {
    $smarty->caching = 1;
    if (!$smarty->is_cached('reportCharts.tpl')) {
        $smarty->assign("all_members", report_chart_major_pie_chart());
        $smarty->assign("committee_involvement", report_chart_committee_pie_chart());
        $smarty->assign("members_first_count", report_chart_major_member_count(10));
        $smarty->assign("members_first", report_chart_member_breakdown(10));
        $smarty->assign("members_second_count", report_chart_major_member_count(11));
        $smarty->assign("members_second", report_chart_member_breakdown(11));
        $smarty->assign("members_third_count", report_chart_major_member_count(12));
        $smarty->assign("members_third", report_chart_member_breakdown(12));
        $smarty->assign("members_forth_count", report_chart_major_member_count(13));
        $smarty->assign("members_forth", report_chart_member_breakdown(13));
        $smarty->assign("members_fifth_count", report_chart_major_member_count(14));
        $smarty->assign("members_fifth", report_chart_member_breakdown(14));
        $smarty->assign("members_phd_count", report_chart_major_member_count(15));
        $smarty->assign("members_phd", report_chart_member_breakdown(15));
        $smarty->assign("members_mal_count", report_chart_major_member_count(19));
Example #14
0
 /**
  * Переопределение одноименного метода Smarty
  * для пользовательских шаблонов созданных в теме дизайна.
  *
  * @param string $tpl_file name of template file
  * @param string $cache_id
  * @param string $compile_id
  * @return string|false results of {@link _read_cache_file()}
  */
 function is_cached($tpl_file, $cache_id = null, $compile_id = null)
 {
     return Smarty::is_cached($this->_redefine_template($tpl_file), $cache_id, $compile_id);
 }
Example #15
0
 function is_cached()
 {
     return parent::is_cached($this->templateName, $this->cacheId);
 }
Example #16
0
 function is_cached($dummy1 = null, $dummy2 = null, $dummy3 = null)
 {
     global $login;
     // if the user is an admin, dont cache the content
     if (isset($login)) {
         if ($login->admin) {
             return false;
         }
     }
     return parent::is_cached($this->main_template . '.tpl', $this->get_cache_id(), $this->get_compile_id());
 }
 /**
  * is_cached * 手册中只有两个参数,但是Smarty代码中这个方法有三个参数,所以用Smarty源代码中的方法重写 * 是否有缓存,可以加在想要缓存的地方比如: * if($this->is_cached('index/update' , $_SERVER['REQUEST_URI'], )){ * }
  * 
  * @Param $tpl_file 
  * @Param $cache_id 
  * @Param $compile_id 
  * @Access public
  * @Return void
  */
 function is_cached($tpl_file = '', $cache_id = NULL, $compile_id = NULL)
 {
     if (empty($tpl_file)) {
         $tpl_file = $_GET['m'] . '/' . $_GET['a'] . '.' . TPL_PREFIX;
     } else {
         if (strstr($tpl_file, '/')) {
             $tpl_file = $tpl_file . '.' . TPL_PREFIX;
         } else {
             $tpl_file = $_GET['m'] . '/' . $tpl_file . '.' . TPL_PREFIX;
         }
     }
     parent::is_cached($tpl_file, $cache_id, $compile_id);
 }
Example #18
0
 public function IsCached($cache_id = null, $compile_id = null)
 {
     return parent::is_cached($this->_template, $cache_id, $compile_id);
 }
Example #19
0
 function is_cached($template, $cache_id = null, $compile_id = null)
 {
     global $USER, $CONF;
     if (!empty($this->disable_caching)) {
         $this->caching = 0;
     }
     $filename = str_replace("|", "___", "{$this->cache_dir}/lock_{$template}-{$cache_id}.tmp");
     if (isset($_GET['refresh']) && $USER->hasPerm('admin')) {
         $this->clear_cache($template, $cache_id, $compile_id);
     } elseif (!empty($CONF['memcache']['smarty'])) {
         if ($GLOBALS['memcached_res']->get($filename)) {
             //its recent so lets extend caching to use the current file (IF there is one!)
             $this->cache_lifetime = $this->cache_lifetime + 3600 * 2;
             //+2hr
         }
     } else {
         //check if there is a generation already in progress
         if (file_exists($filename)) {
             //we have a lock file
             if (filemtime($filename) > time() - 60 * 5) {
                 //its recent so lets extend caching to use the current file (IF there is one!)
                 $this->cache_lifetime = $this->cache_lifetime + 3600 * 2;
                 //+2hr
             } else {
                 //the lock is now old, so lets remove it and try again
                 unlink($filename);
             }
         }
     }
     $isCached = parent::is_cached($template, $cache_id, $compile_id);
     if (!$isCached) {
         if (isset($CONF['curtail_level']) && $CONF['curtail_level'] > 6 && strpos($_SERVER['PHP_SELF'], 'statistics/') !== FALSE) {
             header("HTTP/1.1 503 Service Unavailable");
             die("server busy, please try later");
         }
         if (!empty($CONF['memcache']['smarty'])) {
             $GLOBALS['memcached_res']->set($filename, $template, false, 60 * 5);
         } else {
             //we don't have a cache so lets write the lock file
             $h = fopen($filename, "w");
             fwrite($h, ".");
             fclose($h);
         }
         $this->wroteLock = $filename;
     }
     return $isCached;
 }