本文整理汇总了PHP中RainTPL::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP RainTPL::cache方法的具体用法?PHP RainTPL::cache怎么用?PHP RainTPL::cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RainTPL
的用法示例。
在下文中一共展示了RainTPL::cache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
/* Setup Routine */
$page = new RainTPL();
$page::configure(array('cache_dir' => 'tmp/'));
$page::$path_replace = false;
// We escape it here because ENT_NOQUOTES can't be used in RainTPL templates.
$page->assign('CIPHERDATA', htmlspecialchars(helper::getPaste()['data'], ENT_NOQUOTES));
$page->assign('ERROR', self::$error);
$page->assign('STATUS', self::$status);
$page->assign('VERSION', self::$version);
$page->assign('DISCUSSION', true);
$page->assign('OPENDISCUSSION', true);
$page->assign('MARKDOWN', true);
$page->assign('SYNTAXHIGHLIGHTING', true);
$page->assign('SYNTAXHIGHLIGHTINGTHEME', 'sons-of-obsidian');
$page->assign('BURNAFTERREADINGSELECTED', false);
$page->assign('PASSWORD', true);
$page->assign('FILEUPLOAD', false);
$page->assign('BASE64JSVERSION', '2.1.9');
$page->assign('NOTICE', 'example');
$page->assign('LANGUAGESELECTION', '');
$page->assign('LANGUAGES', i18n::getLanguageLabels(i18n::getAvailableLanguages()));
$page->assign('EXPIRE', self::$expire);
$page->assign('EXPIREDEFAULT', self::$expire_default);
$page->assign('EXPIRECLONE', true);
ob_start();
$page->draw('page');
$this->_content = ob_get_contents();
// run a second time from cache
$page->cache('page');
$page->draw('page');
ob_end_clean();
}
示例2: getData
public function getData($url_path = '/teams', $extra = NULL, $template_file = NULL, $useCache = true)
{
$wn_current = ltrim(date('W'), '0');
$wn_previous = ltrim(date('W', strtotime('-7 days')), '0');
$wn_next = ltrim(date('W', strtotime('+7 days')), '0');
$extra = str_replace(array('weeknummer=C', 'weeknummer=P', 'weeknummer=N'), array('weeknummer=' . $wn_current, 'weeknummer=' . $wn_previous, 'weeknummer=' . $wn_next), $extra);
$pluginFolder = dirname(__FILE__);
if (!isset($template_file) || $template_file == 'template') {
$template_file = basename($url_path);
if (strpos($extra, 'slider=1') > -1) {
// logica voor de slider: 'slider=1'
$template_file = $template_file . '_slider';
}
}
RainTPL::configure('base_url', NULL);
RainTPL::configure('tpl_dir', $pluginFolder . '/templates/');
RainTPL::configure('cache_dir', $pluginFolder . '/cache/');
RainTPL::configure('path_replace', false);
$tpl = new RainTPL();
// standaard 15 minuten cache
$cache_key = sanitize_file_name($url_path . '_' . $extra);
if ($useCache && ($cache = $tpl->cache($template_file, $expire_time = 900, $cache_id = $cache_key))) {
return $cache;
} else {
$list = $this->doRequest($url_path, $extra);
$tpl->assign('logo', strpos($extra, 'logo=1') > -1);
$tpl->assign('thuisonly', strpos($extra, 'thuisonly=1') > -1);
$tpl->assign('uitonly', strpos($extra, 'uitonly=1') > -1);
if (isset($list) && strpos($extra, 'thuis=1') > -1) {
// logica voor thuisclub eerst in overzichten als 'thuis=1' in $extra zit
if (strpos($extra, 'uitonly=1') === false) {
$thuis = array_filter($list, function ($row) {
$length = strlen($this->clubName);
return isset($row->ThuisClub) && substr($row->ThuisClub, 0, $length) === $this->clubName;
});
if (count($thuis) > 0) {
$tpl->assign('thuis', $thuis);
}
}
if (strpos($extra, 'thuisonly=1') === false) {
$uit = array_filter($list, function ($row) {
$length = strlen($this->clubName);
return isset($row->ThuisClub) && substr($row->UitClub, 0, $length) === $this->clubName;
});
if (count($uit) > 0) {
$tpl->assign('uit', $uit);
}
}
} else {
$tpl->assign('data', $list);
}
return $tpl->draw($template_file, $return_string = true);
}
}
示例3: RainTPL
<?php
//include the RainTPL class
include "inc/rain.tpl.class.php";
raintpl::configure("base_url", null);
raintpl::configure("tpl_dir", "tpl/");
raintpl::configure("cache_dir", "tmp/");
//initialize a Rain TPL object
$tpl = new RainTPL();
if ($cache = $tpl->cache('page', 60, 1)) {
echo $cache;
} else {
//variable assign example
$variable = "Hello World!";
$tpl->assign("variable", $variable);
//loop example
$week = array('Monday', 'Tuersday', 'Wednesday', 'Friday', 'Saturday', 'Sunday');
$tpl->assign("week", $week);
//loop example 2
$user = array(array('name' => 'Jupiter', 'color' => 'yellow'), array('name' => 'Mars', 'color' => 'red'), array('name' => 'Earth', 'color' => 'blue'));
$tpl->assign("user", $user);
//loop example with empty array
$tpl->assign("empty_array", array());
$info = array('title' => 'Rain TPL Example', 'copyright' => 'Copyright 2006 - 2011 Rain TPL<br>Project By Rain Team');
$tpl->assign($info);
global $global_variable;
$global_variable = 'This is a global variable';
//draw the template
echo $tpl->draw('page', $return_string = true);
}