本文整理汇总了PHP中TemplateEngine::setCacheable方法的典型用法代码示例。如果您正苦于以下问题:PHP TemplateEngine::setCacheable方法的具体用法?PHP TemplateEngine::setCacheable怎么用?PHP TemplateEngine::setCacheable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateEngine
的用法示例。
在下文中一共展示了TemplateEngine::setCacheable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderTree
/**
* renders tree into menu template
* @return object
*/
public function renderTree()
{
if (!$this->getConfig()->template_menu) {
return;
}
if (!$this->tree) {
return;
}
$template = new TemplateEngine($this->templatePath . $this->getConfig()->template_menu);
$template->setCacheable(true);
$cache = Cache::getInstance();
if (!$cache->isCached('submenu')) {
$childs = array();
$childlist = $this->tree->getChildList($this->tree->getCurrentId());
foreach ($childlist as $item) {
if (isset($item['visible']) && !$item['visible']) {
continue;
}
$item['path'] = $this->tree->getPath($item['id']);
$childs[] = $item;
}
$template->setVariable('submenu', $childs, false);
$cache->save(serialize($childs), 'submenu');
} else {
$template->setVariable('submenu', unserialize($cache->getCache('submenu')), false);
}
// check if template is in cache
if ($template->isCached()) {
return $template;
}
$menu = $this->tree->getRootList();
// get selected main menu item
$firstNode = $this->tree->getFirstAncestorNode($this->tree->getCurrentId());
$firstId = $firstNode ? $firstNode['id'] : 0;
foreach ($menu as &$item) {
$item['path'] = isset($item['external']) && $item['external'] ? $item['url'] : $this->tree->getPath($item['id']);
$item['selected'] = $item['id'] == $firstId;
}
$template->setVariable('menu', $menu, false);
$auth = Authentication::getInstance();
$template->setVariable('loginName', $auth->getUserName(), false);
return $template;
}
示例2: getImageTemplate
public function getImageTemplate($cal_id, $tag)
{
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setPostfix($tag . $cal_id);
$template->setCacheable(true);
// check if template is in cache
if (!$template->isCached()) {
$searchcriteria = array('cal_id' => $cal_id, 'activated' => true);
$imageSelect = array();
$htdocsPathAbs = $this->plugin->getContentPath(true);
$htdocsPath = $this->plugin->getContentPath(false);
$list = $this->getList($searchcriteria);
foreach ($list['data'] as &$item) {
$imageSelect[] = $item['id'];
if ($item['image']) {
$img = new Image($item['image'], $htdocsPathAbs);
$item['image'] = array('src' => $htdocsPath . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
}
if ($item['thumbnail']) {
$img = new Image($item['thumbnail'], $htdocsPathAbs);
$item['thumbnail'] = array('src' => $htdocsPath . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
}
}
$template->setVariable('calendarimage', $list);
}
$theme = $this->director->theme;
$theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/prototype.js"></script>');
$theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/scriptaculous.js"></script>');
$theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/lightbox.js"></script>');
$theme->addHeader('<link rel="stylesheet" href="' . DIF_VIRTUAL_WEB_ROOT . 'css/lightbox.css" type="text/css" media="screen" />');
return $template;
}
示例3: handleDetail
/**
* handle detail request
*/
private function handleDetail()
{
$request = Request::getInstance();
$view = ViewManager::getInstance();
// process attachments
$attachment = $this->getAttachment();
$attachment->handleHttpGetRequest();
// clear subtitle
$view->setName('');
// check security
if (!$request->exists('id')) {
throw new Exception('Poll item is missing.');
}
$id = intval($request->getValue('id'));
$key = array('id' => $id, 'activated' => true);
if (!$this->exists($key)) {
throw new HttpException('404');
}
$detail = $this->getDetail($key);
// check if tree node of poll item is accessable
$tree = $this->director->tree;
if (!$tree->exists($detail['tree_id'])) {
throw new HttpException('404');
}
// process request
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setPostfix($detail['tag']);
// disable cache because we want to count visits
$template->setCacheable(false);
Cache::disableCache();
// update view counter
$this->updateCount($key);
// overwrite default naming
$template->setVariable('pageTitle', $detail['name'], false);
// add breadcrumb item
$url = new Url(true);
$url->clearParameter('id');
$breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
$this->director->theme->addBreadcrumb($breadcrumb);
// check if template is in cache
/*
if(!$template->isCached())
{
$template->setVariable('poll', $detail, false);
}
*/
$template->setVariable('poll', $detail, false);
$settings = $this->getPollSettings();
$treeSettings = $settings->getSettings($detail['tag'], $detail['tree_id']);
$template->setVariable('newssettings', $treeSettings, false);
// get settings
if ($treeSettings['item']) {
// process items
$item = $this->getItem();
$item->handleHttpGetRequest();
}
$url = new Url(true);
$url->clearParameter('id');
$url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
$template->setVariable('href_back', $url->getUrl(true), false);
$this->template[$detail['tag']] = $template;
}
示例4: handleOverview
/**
* handle overview request
*/
private function handleOverview()
{
$taglist = $this->getTagList();
if (!$taglist) {
return;
}
foreach ($taglist as $item) {
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setCacheable(true);
$template->setPostfix($item['tag']);
$skip = false;
$key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
$detail = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT);
switch ($detail['type']) {
case self::TYPE_HORIZONTAL_LEVEL1:
case self::TYPE_VERTICAL_LEVEL1:
case self::TYPE_VERTICAL_LEVEL2:
$this->handleSingleMenu($detail, $template);
break;
case self::TYPE_HORIZONTAL_PULLDOWN:
case self::TYPE_VERTICAL_PULLDOWN:
$this->handlePulldownMenu($detail, $template);
break;
default:
$skip = true;
}
// skip if no type defined
if ($skip) {
continue;
}
$this->template[$item['tag']] = $template;
}
}
示例5: getAttachmentTemplate
public function getAttachmentTemplate($nl_id, $tag)
{
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setPostfix($tag . $nl_id);
$template->setCacheable(true);
// check if template is in cache
if (!$template->isCached()) {
$searchcriteria = array('nl_id' => $nl_id, 'activated' => true);
$list = $this->getList($searchcriteria);
foreach ($list['data'] as &$item) {
$item['href_detail'] = $item['file'] ? $this->plugin->getFileUrl($item['id']) : '';
}
$template->setVariable('attachment', $list);
}
return $template;
}
示例6: handleOverview
/**
* handle overview request
*/
private function handleOverview()
{
$request = Request::getInstance();
$view = ViewManager::getInstance();
$page = $this->getPage();
$this->pagerUrl->setParameter($view->getUrlId(), $view->getType());
// retrieve tags that are linked to this plugin
$taglist = $this->plugin->getTagList();
if (!$taglist) {
return;
}
// get settings
$settings = $this->getSettings();
foreach ($taglist as $tag) {
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setPostfix($tag['tag']);
$template->setCacheable(true);
$template->setVariable($settings, NULL, false);
// check if template is in cache
if (!$template->isCached()) {
$pagesize = $settings['rows'];
$searchcriteria = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag'], 'activated' => true);
$list = $this->getList($searchcriteria, $pagesize, $page, $settings['display_order']);
foreach ($list['data'] as &$item) {
$item['href_detail'] = $item['file'] ? $this->plugin->getFileUrl($item['id']) : '';
}
$template->setVariable('attachment', $list);
}
$this->template[$tag['tag']] = $template;
}
}
示例7: handleOverview
/**
* handle overview request
*/
private function handleOverview()
{
$taglist = $this->getTagList();
if (!$taglist) {
return;
}
$tree = $this->director->tree;
foreach ($taglist as $item) {
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setCacheable(true);
$template->setPostfix($item['tag']);
// check if template is in cache
if (!$template->isCached()) {
$key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
$detail = $this->getDetail($key);
$currentId = $tree->getCurrentId();
if (!$detail['type'] || $detail['type'] == self::TYPE_SKIP_TOP && $tree->getParentId($currentId) == $tree->getRootId() || $detail['type'] == self::TYPE_LAST && !$tree->isLeafNode($currentId)) {
continue;
}
$parentId = $tree->getParentId($currentId);
$sibling = array();
$siblinglist = $tree->getChildList($parentId);
foreach ($siblinglist as $sibitem) {
if (isset($sibitem['visible']) && !$sibitem['visible']) {
continue;
}
$sibitem['path'] = isset($sibitem['external']) && $sibitem['external'] ? $sibitem['url'] : $tree->getPath($sibitem['id']);
$sibling[] = $sibitem;
}
// skip if no sibling present
if (sizeof($sibling) <= 1) {
return;
}
if ($detail['show_name']) {
$template->setVariable('currentmenuname', $tree->getName($parentId));
}
$template->setVariable('currentmenu', $sibling);
$template->setVariable('currentId', $currentId);
}
$this->template[$item['tag']] = $template;
}
}
示例8: handleOverview
/**
* handle overview request
*/
private function handleOverview()
{
$taglist = $this->getTagList();
if (!$taglist) {
return;
}
$tree = $this->director->tree;
foreach ($taglist as $item) {
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setCacheable(true);
$template->setPostfix($item['tag']);
// check if template is in cache
if (!$template->isCached()) {
$key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
$detail = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT);
$currentId = $tree->getCurrentId();
if (!$detail['type'] || $detail['type'] == self::TYPE_SKIP_TOP && $tree->getParentId($currentId) == $tree->getRootId()) {
continue;
}
$childs = array();
$childlist = $tree->getChildList($currentId);
foreach ($childlist as $subitem) {
if (isset($subitem['visible']) && !$subitem['visible']) {
continue;
}
$subitem['path'] = isset($subitem['external']) && $subitem['external'] ? $subitem['url'] : $tree->getPath($subitem['id']);
$childs[] = $subitem;
}
// skip if no submenu
if (!$childs) {
return;
}
if ($detail['show_name']) {
$template->setVariable('submenuname', $tree->getName($currentId));
}
$template->setVariable('submenu', $childs);
}
$this->template[$item['tag']] = $template;
}
}
示例9: handleOverview
/**
* handle overview request
*/
private function handleOverview()
{
$request = Request::getInstance();
$view = ViewManager::getInstance();
$tag = 'poll_item';
if (!$request->exists('id')) {
throw new Exception('Poll is missing.');
}
$poll_id = intval($request->getValue('id'));
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setPostfix($tag);
$template->setCacheable(true);
// add item if requested
if ($request->exists(self::VIEW_KEY)) {
$this->handleItemAdd($template);
}
// check if template is in cache
if (!$template->isCached()) {
// retrieve items
$searchcriteria = array('poll_id' => $poll_id, 'activated' => true);
$list = $this->getList($searchcriteria);
$template->setVariable('item', $list);
}
$this->template[$tag] = $template;
}
示例10: handleDetail
/**
* handle detail request
*/
private function handleDetail()
{
$request = Request::getInstance();
$view = ViewManager::getInstance();
// clear subtitle
$view->setName('');
// check security
if (!$request->exists('id')) {
throw new Exception('Reservation item is missing.');
}
$id = intval($request->getValue('id'));
$key = array('id' => $id, 'activated' => true);
if (!$this->exists($key)) {
throw new HttpException('404');
}
$detail = $this->getDetail($key);
// check if tree node of reservation item is accessable
$tree = $this->director->tree;
if (!$tree->exists($detail['tree_id'])) {
throw new HttpException('404');
}
// process request
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setPostfix($detail['tag']);
$template->setCacheable(true);
// overwrite default naming
$template->setVariable('pageTitle', $detail['name'], false);
// add breadcrumb item
$url = new Url(true);
$url->clearParameter('id');
$breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
$this->director->theme->addBreadcrumb($breadcrumb);
// check if template is in cache
if (!$template->isCached()) {
$template->setVariable('reservation', $detail);
}
$objSettings = $this->plugin->getObject(Reservation::TYPE_SETTINGS);
$settings = $objSettings->getSettings($detail['tree_id'], $detail['tag']);
$template->setVariable('reservationsettings', $settings, false);
$url = new Url(true);
$url->clearParameter('id');
$url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
$template->setVariable('href_back', $url->getUrl(true), false);
$this->template[$detail['tag']] = $template;
}
示例11: handleTreeEditGet
/**
* handle edit request
*/
private function handleTreeEditGet($retrieveFields = true)
{
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$request = Request::getInstance();
$view = ViewManager::getInstance();
$view->setType(ViewManager::TREE_EDIT);
$element = $this->plugin->getObject(Form::TYPE_ELEMENT);
$record = $this->plugin->getObject(Form::TYPE_RECORD);
$recordItem = $this->plugin->getObject(Form::TYPE_RECORD_ITEM);
if (!$request->exists('rcd_id')) {
throw new Exception('Record id is missing.');
}
$rcd_id = intval($request->getValue('rcd_id'));
$key = array('id' => $rcd_id);
if (!$record->exists($key)) {
throw new Exception('Record does not exist.');
}
$recordDetail = $record->getDetail($key);
$tree_id = $recordDetail['tree_id'];
$tag = $recordDetail['tag'];
// get record items
if ($request->getRequestType() == Request::GET) {
$recordItemList = $recordItem->getRecordElementList($rcd_id);
} else {
$recordItemList = array();
}
// get settings
$settings = $this->plugin->getSettings($tree_id, $tag);
$templateItem = new TemplateEngine($this->getPath() . "templates/formoverviewitem.tpl");
$template->setPostfix($tag);
$template->setCacheable(true);
$templateItem->setVariable('settings', $settings);
$searchcriteria = array('tree_id' => $tree_id, 'tag' => $tag, 'active' => true);
$list = $element->getList($searchcriteria, 0, 1, SqlParser::ORDER_ASC);
foreach ($list['data'] as &$item) {
$obj = $element->getObject($item['type'], $item);
$obj->setId($element->getTypeId($item['id']));
if ($request->getRequestType() == Request::POST) {
$obj->handlePostRequest();
} elseif (array_key_exists($obj->getId(), $recordItemList)) {
$obj->handleSetValue($recordItemList[$obj->getId()]['value']);
}
$item['html'] = $obj->getHtml();
$item['class'] = get_class($obj);
}
$templateItem->setVariable('fields', $list);
$template->setVariable('rcd_id', $rcd_id);
$template->setVariable('tag', $tag);
$template->setVariable('settings', $settings);
$template->setVariable('tpl_element_item', $templateItem);
$this->handleTreeSettings($template);
$this->template[$this->director->theme->getConfig()->main_tag] = $template;
}
示例12: handleOverview
/**
* handle overview request
*/
private function handleOverview()
{
$taglist = $this->getTagList();
if (!$taglist) {
return;
}
$tree = $this->director->tree;
foreach ($taglist as $item) {
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setCacheable(true);
$template->setPostfix($item['tag']);
$key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
// check if template is in cache
if (!$template->isCached()) {
$siteGroup = $this->getSiteGroup();
$id = $siteGroup->getCurrentId();
$detail = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT);
$template->setVariable('detail', $detail);
$url = new Url();
$url->setPath('/');
$grouplist = $siteGroup->getList(array('active' => true));
if ($grouplist['totalItems'] < 2) {
continue;
}
foreach ($grouplist['data'] as &$list) {
$url->setParameter(SystemSiteGroup::CURRENT_ID_KEY, $list['id']);
$list['path'] = $url->getUrl(true);
$list['selected'] = $list['id'] == $id;
$list['img'] = $this->getImage($list['language']);
}
$template->setVariable('sitegroup', $grouplist, false);
$template->setVariable('sitegroupId', $id);
}
$this->template[$item['tag']] = $template;
}
}
示例13: handleDetail
/**
* handle detail request
*/
private function handleDetail()
{
$request = Request::getInstance();
$view = ViewManager::getInstance();
// clear subtitle
$view->setName('');
if (!$request->exists('id')) {
throw new Exception('Galerij ontbreekt.');
}
$id = intval($request->getValue('id'));
$key = array('id' => $id, 'activated' => true);
if (!$this->exists($key)) {
throw new HttpException('404');
}
$detail = $this->getDetail($key);
// check if tree node of gallery item is accessable
$tree = $this->director->tree;
if (!$tree->exists($detail['tree_id'])) {
throw new HttpException('404');
}
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setCacheable(true);
// overwrite default naming
$template->setVariable('pageTitle', $detail['name'], false);
// add breadcrumb item
$url = new Url(true);
$url->clearParameter('id');
$breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
$this->director->theme->addBreadcrumb($breadcrumb);
// check if template is in cache
if (!$template->isCached()) {
// add image
if ($detail['image']) {
$img = new Image($detail['image'], $this->plugin->getContentPath(true));
$detail['image'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
}
$template->setVariable('gallery', $detail, false);
// previous and next
$url = new Url(true);
$search = array('activated' => true, 'previous' => $detail['id']);
$prev_id = $this->getId($search);
if ($prev_id) {
$url->setParameter('id', $prev_id);
$template->setVariable('href_previous', $url->getUrl(true), false);
}
$search = array('activated' => true, 'next' => $detail['id']);
$next_id = $this->getId($search);
if ($next_id) {
$url->setParameter('id', $next_id);
$template->setVariable('href_next', $url->getUrl(true), false);
}
// comment
$settings = $this->getSettings($detail['tree_id'], $detail['tag']);
$template->setVariable('gallerysettings', $settings);
// get settings
if ($settings['comment']) {
// process comments
$comment = $this->plugin->getObject(Gallery::TYPE_COMMENT);
$comment->setSettings($settings);
$comment->handleHttpGetRequest();
}
}
$url = new Url(true);
$url->clearParameter('id');
$url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
$template->setVariable('href_back', $url->getUrl(true), false);
$this->template[$detail['tag']] = $template;
}
示例14: handleDetail
/**
* handle detail request
*/
private function handleDetail()
{
$request = Request::getInstance();
$view = ViewManager::getInstance();
// it makes no sense to have multiple tags for this plugin.
// if someone did it, you get strange results and he probably can figure out why.. no multiple detail stuff in 1 page supported!
// so take a shot and get the first tag to set the content
$taglist = $this->plugin->getTagList(array('plugin_type' => Calendar::TYPE_ARCHIVE));
if (!$taglist) {
return;
}
$taginfo = current($taglist);
// process attachments
$attachment = $this->plugin->getObject(Calendar::TYPE_ATTACHMENT);
$attachment->handleHttpGetRequest();
// process images
$image = $this->plugin->getObject(Calendar::TYPE_IMAGE);
$image->handleHttpGetRequest();
// clear subtitle
$view->setName('');
if (!$request->exists('id')) {
throw new Exception('Calendar id is missing.');
}
$id = intval($request->getValue('id'));
$key = array('id' => $id, 'active' => true, 'finished' => true);
$overview = $this->plugin->getObject(Calendar::TYPE_DEFAULT);
if (!$overview->exists($key)) {
return;
}
$detail = $overview->getDetail($key);
// check if tree node of cal item is accessable
$tree = $this->director->tree;
if (!$tree->exists($detail['tree_id'])) {
throw new HttpException('404');
}
$objSettings = $this->plugin->getObject(Calendar::TYPE_SETTINGS);
$settings = $objSettings->getSettings($detail['tree_id'], $detail['tag']);
if ($detail['thumbnail']) {
$img = new Image($detail['thumbnail'], $this->plugin->getContentPath(true));
$detail['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
}
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setPostfix($detail['tag']);
// disable cache because we want to count visits
$template->setCacheable(false);
Cache::disableCache();
// update view counter
$overview->updateCount($key);
// overwrite default naming
$template->setVariable('pageTitle', $detail['name'], false);
$url = new Url(true);
$url->clearParameter('id');
$url->setParameter($view->getUrlId(), ViewManager::OVERVIEW);
$template->setVariable('href_back', $url->getUrl(true), false);
$breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true));
$this->director->theme->addBreadcrumb($breadcrumb);
$template->setVariable('cal', $detail, false);
$template->setVariable('settings', $settings);
$template->setVariable('calsettings', $settings, false);
// get settings
if ($settings['comment']) {
// process comments
$comment = $this->plugin->getObject(Calendar::TYPE_COMMENT);
$comment->setSettings($settings);
$comment->handleHttpGetRequest();
}
$this->template[$taginfo['tag']] = $template;
}
示例15: handleOverview
/**
* handle overview request
*/
private function handleOverview()
{
$request = Request::getInstance();
$view = ViewManager::getInstance();
// retrieve tags that are linked to this plugin
$taglist = $this->plugin->getTagList(array('plugin_type' => Reservation::TYPE_LIST));
if (!$taglist) {
return;
}
foreach ($taglist as $tag) {
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setPostfix($tag['tag']);
$template->setCacheable(false);
$template->setVariable($tag, null, false);
$this->template[$tag['tag']] = $template;
}
$this->director->theme->addJavascript('Event.observe( window, "load", function() { getReservationList();} );');
}