本文整理汇总了PHP中TemplateEngine::setFile方法的典型用法代码示例。如果您正苦于以下问题:PHP TemplateEngine::setFile方法的具体用法?PHP TemplateEngine::setFile怎么用?PHP TemplateEngine::setFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemplateEngine
的用法示例。
在下文中一共展示了TemplateEngine::setFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleOverview
/**
* handle overview request
*/
private function handleOverview()
{
$taglist = $this->getTagList();
if (!$taglist) {
return;
}
foreach ($taglist as $item) {
$template = new TemplateEngine();
$template->setPostfix($item['tag']);
$template->setCacheable(true);
// check if template is in cache
if (!$template->isCached()) {
$key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']);
$detail = $this->getDetail($key);
$template->setFile($detail['text']);
$template->setIncludeFile(false);
}
$this->template[$item['tag']] = $template;
}
}
示例2: getOverviewList
public function getOverviewList($searchcriteria, $settings, $url)
{
$view = ViewManager::getInstance();
$template = new TemplateEngine($this->getPath() . "templates/calendaroverviewlist.tpl");
$template->setPostfix($searchcriteria['tag']);
$template->setCacheable(true);
// check if template is in cache
if ($template->isCached()) {
return $template;
}
// get settings
$template->setVariable('settings', $settings);
// parse template
if ($settings['template']) {
$template->setFile($settings['template']);
$template->setIncludeFile(false);
}
$list = $this->getList($searchcriteria, $settings['rows'], $this->getPage(), SqlParser::ORDER_ASC);
if (!$list['data']) {
return;
}
foreach ($list['data'] as &$item) {
$url->setParameter('id', $item['id']);
$item['href_detail'] = $url->getUrl(true);
if ($item['thumbnail']) {
$img = new Image($item['thumbnail'], $this->plugin->getContentPath(true));
$item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
}
// retrieve attachments
if ($settings['display'] == Calendar::DISP_FULL) {
$attachmentTag = 'calattachment';
$attachment = $this->plugin->getObject(Calendar::TYPE_ATTACHMENT);
$item[$attachmentTag] = $attachment->getAttachmentTemplate($item['id'], $attachmentTag);
$imageTag = 'template_calimage';
$image = $this->plugin->getObject(Calendar::TYPE_IMAGE);
$item[$imageTag] = $image->getImageTemplate($item['id'], $imageTag);
}
}
$template->setVariable('cal', $list);
return $template;
}
示例3: 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(array('plugin_type' => News::TYPE_DEFAULT));
if (!$taglist) {
return;
}
$url = new Url(true);
$url->setParameter($view->getUrlId(), News::VIEW_DETAIL);
$newsSettings = $this->plugin->getObject(News::TYPE_SETTINGS);
foreach ($taglist as $tag) {
$template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile);
$template->setPostfix($tag['tag']);
$template->setCacheable(true);
// check if template is in cache
if (!$template->isCached()) {
// get settings
$globalSettings = $this->plugin->getSettings();
$settings = array_merge($globalSettings, $newsSettings->getSettings($tag['tree_id'], $tag['tag']));
$template->setVariable('settings', $settings);
// parse stylesheet
if ($settings['template']) {
$template->setFile($settings['template']);
$template->setIncludeFile(false);
}
$pagesize = $settings['rows'] ? $settings['rows'] : $globalSettings['rows'];
$searchcriteria = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag'], 'activated' => true);
$list = $this->getList($searchcriteria, $pagesize, $page);
if (!$list['data']) {
continue;
}
foreach ($list['data'] as &$item) {
$url->setParameter('id', $item['id']);
$item['href_detail'] = $url->getUrl(true);
if ($item['thumbnail']) {
$img = new Image($item['thumbnail'], $this->plugin->getContentPath(true));
$item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight());
}
// retrieve attachments
if ($settings['display'] == News::DISP_FULL) {
$attachmentTag = 'newsattachment';
$attachment = $this->plugin->getObject(News::TYPE_ATTACHMENT);
$item[$attachmentTag] = $attachment->getAttachmentTemplate($item['id'], $attachmentTag);
$imageTag = 'template_newsimage';
$image = $this->plugin->getObject(News::TYPE_IMAGE);
$item[$imageTag] = $image->getImageTemplate($item['id'], $imageTag);
}
}
$template->setVariable('news', $list);
}
$this->template[$tag['tag']] = $template;
}
}