public function isCached($template = null, $cache_id = null, $compile_id = null, $parent = null) { if (is_null($template)) { $template = CONTROLLER_NAME . '/' . ACTION_NAME . C('view_suffix'); } elseif (strstr($template, '.')) { //直接使用模板路径 } elseif (strstr($template, ':')) { $template = str_replace(':', '/', $template); $template = $template . C('view_suffix'); } else { $template = CONTROLLER_NAME . '/' . $template . C('view_suffix'); } return parent::isCached($template, $cache_id, $compile_id, $parent); }
/** * Renders the output */ public function Render() { if ($this->config->GetValue('cache') == true && $this->config->GetValue('cacheexpire') === true) { $this->CacheExpire(); } $log = GitPHP_DebugLog::GetInstance(); if (!$this->tpl->isCached($this->GetTemplate(), $this->GetFullCacheKey())) { $this->tpl->clearAllAssign(); $log->TimerStart(); $this->LoadCommonData(); $log->TimerStop('Common data'); $log->TimerStart(); $this->LoadData(); $log->TimerStop('Data'); } if (!$this->preserveWhitespace) { //$this->tpl->loadFilter('output', 'trimwhitespace'); } $log->TimerStart(); $this->tpl->display($this->GetTemplate(), $this->GetFullCacheKey()); $log->TimerStop('Render'); $this->tpl->clearAllAssign(); if ($this->projectList) { $log->Log('MemoryCache', 'Count: ' . $this->projectList->GetMemoryCache()->GetCount()); } if ($log->GetEnabled()) { $this->tpl->assign('debuglog', $log); $this->tpl->display('debug.tpl'); } }
/** * @param null $template * @param null $cache_id * @param null $compile_id * @param null $parent * @return bool */ public function isCached($template = null, $cache_id = null, $compile_id = null, $parent = null) { try { return $this->smarty->isCached($template, $cache_id, $compile_id, $parent); } catch (\Exception $e) { return false; } }
/** * Проверка существования кэштрованного файла для данной страницы * @param null $template * @param null $cache_id * @param null $compile_id * @param null $parent * @return bool */ public function isCached($template = null, $cache_id = null, $compile_id = null, $parent = null) { if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] != '') { // Проверка существования идентификатора кэша $query = 'CALL check_cach_id(:link)'; $params = array(':link' => $_SERVER['REQUEST_URI']); $check = PdoWrap::selectRow($query, $params); if (isset($check['id']) && (int) $check['id'] > 0) { $this->setCurrentTemplate($check['template']); $this->setCurrentCachId($check['id']); return parent::isCached($check['template'], $check['id']); } else { return false; } } else { return false; } }
public function show_News() { header("Content-Type: application/rss+xml; charset=UTF-8"); $tpl = new Smarty(); $tpl->cache_lifetime = 3600 * 24; $tpl->setCaching(Smarty::CACHING_LIFETIME_CURRENT); $cacheID = 'rssFeed'; if (!$tpl->isCached('rss.xml', $cacheID)) { $items = array(); $dbItems = R::find('homepage_posts', ' 1=1 ORDER BY id DESC LIMIT 15'); foreach ($dbItems as $item) { $author = R::relatedOne($item, 'user'); $items[] = array('title' => $item->title, 'link' => $item->link == '' ? APP_WEBSITE . APP_DIR : $item->link, 'description' => $item->content, 'author' => $author->username, 'date' => date("D, d M Y H:i:s O", $item->time)); } $tpl->assign('items', $items); $tpl->assign('gentime', date("D, d M Y H:i:s O")); $tpl->assign('link', APP_WEBSITE . APP_DIR); } $tpl->display('rss.xml', $cacheID); }
public function isPageCached() { if ($this->cacheId !== null and parent::isCached($this->mainTemplate, $this->cacheId)) { return true; } return false; }
public function isCached($template = NULL, $cache_id = NULL, $compile_id = NULL, $parent = NULL) { if ($template) { $tpl = $template; } else { $tpl = system::param("page"); } if ($cache_id) { $cacheID = $cache_id; } else { $cacheID = $this->cacheIdShow; } $checkStr = "{$tpl}.tpl"; if (system::param("templateBase")) { $checkStr = "extends:" . system::param("templateBase") . "|{$checkStr}"; } return parent::isCached($checkStr, $cacheID); }
public function isCached($template, $cache_id = null) { $this->setCompileId(); return $this->smarty->isCached($template, $cache_id); }
public function isCached($template, $cache_id = null) { return $this->smarty->isCached($template, $cache_id); }
public function isCached($template, $cache_id = null, $compile_id = null, $parent = null) { $template = $this->get_template_real_path($template); return parent::isCached($template, $cache_id, $compile_id, $parent); }
<?php require_once 'app/core/init.php'; require_once 'main.php'; $smarty = new Smarty(); $smarty->debugging = Config::get('debug/smartyDebug'); $smarty->caching = Config::get('smarty/caching'); $smarty->cache_lifetime = Config::get('smarty/cache_lifetime'); $cache_id = md5(json_encode($_GET) . json_encode($_POST) . Notifications::getAsJson()); if (!$smarty->isCached('templates/errors/404.tpl', $cache_id)) { $smarty = pageAddMain($smarty); } $smarty = pageAddMessages($smarty); $smarty->loadFilter("output", "trimwhitespace"); $smarty->display('templates/errors/404.tpl', $cache_id);
<?php require_once 'app/core/init.php'; require_once 'main.php'; if (isset($_GET['page']) && !empty($_GET['page'])) { $smarty = new Smarty(); $smarty->debugging = Config::get('debug/smartyDebug'); $smarty->caching = Config::get('smarty/caching'); $smarty->cache_lifetime = Config::get('smarty/cache_lifetime'); $cache_id = md5(json_encode($_GET) . json_encode($_POST) . Notifications::getAsJson()); $pageFile = 'app/pages/' . $_GET['page'] . '.php'; $templateFile = 'templates/pages/' . $_GET['page'] . '.tpl'; if (file_exists($pageFile) && file_exists($templateFile)) { require $pageFile; if (!$allowCaching) { $cache_id = md5($cache_id . Hash::hashUnique()); } if (!$smarty->isCached($templateFile, $cache_id)) { $smarty = createPage($smarty); $smarty = pageAddMain($smarty); } $smarty = pageAddMessages($smarty); $smarty->loadFilter("output", "trimwhitespace"); $smarty->display($templateFile, $cache_id); } else { Redirect::error(404); } } else { Redirect::to('?page=home'); }