/** * Adds a template. * * @param \Template $template The message. * * @return void */ public function parseTemplate(\Template $template) { if (self::$timeCollector) { self::$timeCollector->startMeasure($template->getName(), 'Parse: ' . $template->getName()); self::$timeCollector->stopMeasure($template->getName()); } self::$collector->addTemplate($template); }
public function cb_parseTemplate(\Template &$objTemplate) { global $objPage; if (strpos($objTemplate->getName(), 'news_') === 0) { if ($objTemplate->source == 'singlefile') { $modelFile = \FilesModel::findByUuid($objTemplate->singlefileSRC); try { if ($modelFile === null) { throw new \Exception("no file"); } $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload'])); if (!in_array($modelFile->extension, $allowedDownload)) { throw new Exception("download not allowed by extension"); } $objFile = new \File($modelFile->path, true); $strHref = \System::urlEncode($objFile->value); } catch (\Exception $e) { $strHref = ""; } $target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"'; $objTemplate->more = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $GLOBALS['TL_LANG']['MSC']['more']); $objTemplate->linkHeadline = sprintf('<a %s href="%s" title="%s">%s</a>', $target, $strHref, specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['open'], $objFile->basename)), $objTemplate->headline); } } }
public static function register(Template $uri_template) { if (!($name = $uri_template->getName())) { throw new \RuntimeException("Registered URI templates must have a name."); } static::$templates[$name] = $uri_template; }
public function formTemplatedFrames() { $this->data->idTemplate = $this->data->id; $model = new Template($this->data->idTemplate); $this->data->title = 'Template: ' . $model->getEntry() . ' [' . $model->getName() . ']'; $this->data->query = Manager::getAppURL('fnbr20', 'structure/template/gridDataTemplatedFrames/' . $this->data->id); $this->render(); }
/** * Inject the helper for the frontend templates. * * @param \Template $template The template being parsed. * * @return void */ public function hookParseTemplate(\Template $template) { if (substr($template->getName(), 0, 3) === 'fe_') { $helper = new Helper($template); $template->flexibleSections = function ($position, $template = 'block_sections') use($helper) { echo $helper->getCustomSections($position, $template); }; $template->getFlexibleSectionsHelper = function () use($helper) { return $helper; }; } }
/** * execute all registered template modifiers * * @param \Template $template */ public function execute(\Template $template) { if (!Bootstrap::isEnabled()) { return; } foreach ($GLOBALS['BOOTSTRAP']['templates']['modifiers'] as $config) { if ($config['disabled'] || !$this->isTemplateAffected($template->getName(), $config['templates'])) { continue; } if ($config['type'] == 'replace') { if (is_callable($config['replace'])) { $value = call_user_func($config['replace'], $template); } else { $value = $config['replace']; } $template->{$config}['key'] = str_replace($config['search'], $value, $template->{$config}['key']); } elseif ($config['type'] == 'callback') { call_user_func($config['callback'], $template); } } }
/** * Execute all registered template modifiers. * * @param \Template $template Current template. * * @return void */ public function modify(\Template $template) { if (!Bootstrap::isEnabled()) { return; } foreach ((array) Bootstrap::getConfigVar('templates.modifiers') as $config) { if ($config['disabled'] || !$this->isTemplateAffected($template->getName(), (array) $config['templates'])) { continue; } if ($config['type'] == 'replace') { if (is_callable($config['replace'])) { $value = call_user_func($config['replace'], $template); } else { $value = $config['replace']; } $template->{$config}['key'] = str_replace($config['search'], $value, $template->{$config}['key']); } elseif ($config['type'] == 'callback') { call_user_func($config['callback'], $template); } } }
public function createTemplate() { try { $this->data->idFrame = $this->data->id; $model = new Template(); $model->createFromFrame($this->data->idFrame); $this->renderPrompt('information', 'Template [' . $model->getName() . '] was created.'); } catch (\Exception $e) { $this->renderPrompt('error', $e->getMessage()); } }
$templateObj = new Template($templateId); if (!isset($_SERVER['SERVER_PORT'])) { $_SERVER['SERVER_PORT'] = 80; } $scheme = $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://'; $siteAlias = new Alias($publicationObj->getDefaultAliasId()); $websiteURL = $scheme.$siteAlias->getName() . $GLOBALS['Campsite']['SUBDIR']; $accessParams = "LoginUserId=" . $g_user->getUserId() . "&LoginUserKey=" . $g_user->getKeyId() . "&AdminAccess=all"; if ($publicationObj->getUrlTypeId() == 1) { $templateObj = new Template($templateId); $url = "$websiteURL/tpl/" . $templateObj->getName() . "?IdLanguage=$f_language_id" . "&IdPublication=$f_publication_id&NrIssue=$f_issue_number&NrSection=$f_section_number" . "&NrArticle=$f_article_number&$accessParams"; } else { $url = ShortURL::GetURL($f_publication_id, $f_language_selected, null, null, $f_article_number); if (PEAR::isError($url)) { $errorStr = $url->getMessage(); } $url .= '?' . $accessParams; } $selectedLanguage = (int)CampRequest::GetVar('f_language_selected'); $url .= "&previewLang=$selectedLanguage"; $siteTitle = (!empty($Campsite['site']['title'])) ? htmlspecialchars($Campsite['site']['title']) : putGS("Newscoop") . $Campsite['VERSION']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
public function parseTemplate(\Template $template) { if (substr($template->getName(), 0, 3) == 'ce_' && $template->imgSize) { $template->imgSize = ''; } }
/** * */ public function getTemplate($p_templateIdOrName = null) { if (!is_null($this->m_template)) { return $this->m_template->name; } if (!empty($p_templateIdOrName)) { $tplObj = new Template($p_templateIdOrName); if (!$tplObj->exists()) { return null; } $template = $tplObj->getName(); } elseif (is_null($this->m_errorCode)) { $template = CampSystem::GetTemplate($this->language->number, $this->publication->identifier, $this->issue->number, $this->section->number, $this->article->number); } else { return null; } return $template; } // fn getTemplate
protected function processTemplateBlocks(Template $template, &$globals, RendererInterface $renderer) { if ($this->benchmarkRendering) { $this->Benchmark->start('process-template-blocks-' . $template->getName()); } $templateBlocks = $template->getTemplateBlocks(); $data = $template->getData(); $locals = $template->getLocals(); $handler = $template->getContentType() != 'html' && $template->getContentType() != '' ? $template->getContentType() . '-' : ''; $renderout = ''; $contents = ''; $parsedContents = ''; $locals['DisplayRecords'] = sizeof($data); $locals['Count'] = 1; if (!empty($data)) { //if(LOG_ENABLE) System::log(self::$logType, 'Parsing contents block'); if (!isset($templateBlocks[$handler . 'contents']) && !isset($templateBlocks[$handler . 'header']) && !isset($templateBlocks[$handler . 'exec'])) { throw new Exception('Template [' . $template->getName() . '] is missing a template block for [' . $handler . 'contents] or [' . $handler . 'header] or [' . $handler . 'exec]'); } $eBlock = isset($templateBlocks[$handler . 'exec']) ? $templateBlocks[$handler . 'exec'] : ''; $cBlock = isset($templateBlocks[$handler . 'contents']) ? $templateBlocks[$handler . 'contents'] : ''; $ciBlock = isset($templateBlocks[$handler . 'contents-inbetween']) ? $templateBlocks[$handler . 'contents-inbetween'] : ''; if (!empty($eBlock)) { $contents = $eBlock; $contents = $this->parseSetters($contents, $locals); $contents = $this->parseConditions($contents, $locals); $contents = $this->parseFilters($contents, $locals); $contents = $this->parseAssets($contents, $locals); // parse dependent sub modules $template->setLocals($locals); // $this->Logger->debug("Parsing dependent includes for [{$template->getName()}]..."); $contents = $this->parseTemplateIncludes($contents, $template->getContentType(), $template, $globals, $renderer, false, true); $contents = $this->parseFormatVariables($contents, $locals); $renderout .= $contents; } else { // List Processing of the Data foreach ((array) $data as $row) { $contents = $cBlock; // if(strpos($contents, '{% set ') !== FALSE) { // while(preg_match("/(.*?)\{\%\s+set\s+([^\%]+?)\s+\%\}\s*(.*?)\s?\{\%\s+endset\s+\%\}\s*(.*)/s",$contents,$m)) { // if(!array_key_exists($m[2], $row)) { // $val = $this->parseFormatVariablesAndFilters($m[3], $row); // $row[$m[2]] = $val; // } // $contents = $m[1]. $m[4]; // } // } if ($locals['DisplayRecords'] != $locals['Count']) { $contents .= $ciBlock; } if (!is_array($row)) { if ($row instanceof Node) { /* * Populating Node itself into the row so it can be used in templates, * passed to events, filters, etc. see ticket #30 * todo: investigate populating 'Node' in populateNodeCheaters directly */ $node = $row; $row = $this->NodeMapper->populateNodeCheaters($row)->toArray(); $row['Node'] = $node; } else { if ($row instanceof Object) { $row = $row->toArray(); } else { throw new Exception("data is not an array\n" . print_r($row, true)); } } } $row_locals = array_merge($locals, $row); $row_locals['SerializedData'] = $row; //if(LOG_ENABLE) System::log(self::$logType, 'Locals ['.print_r($locals, true).']'); $contents = $this->parseSetters($contents, $row_locals); $contents = $this->parseConditions($contents, $row_locals); $contents = $this->parseFilters($contents, $row_locals); $contents = $this->parseAssets($contents, $row_locals); // parse dependent sub modules $template->setLocals($row_locals); // $this->Logger->debug("Parsing dependent includes for [{$template->getName()}]..."); $contents = $this->parseTemplateIncludes($contents, $template->getContentType(), $template, $globals, $renderer, false, true); $contents = $this->parseFormatVariables($contents, $row_locals); $locals['Count']++; $parsedContents .= $contents; } $locals = $row_locals; $template->setLocals($locals); // headers and footers can use format variables from the final row $renderout = ''; if (!empty($templateBlocks[$handler . 'header'])) { $header = $templateBlocks[$handler . 'header']; $header = $this->parseSetters($header, $locals); $header = $this->parseConditions($header, $locals); $header = $this->parseFilters($header, $locals); $header = $this->parseAssets($header, $locals); $template->setLocals($locals); // parse dependent sub modules $header = $this->parseTemplateIncludes($header, $template->getContentType(), $template, $globals, $renderer, false, true); $header = $this->parseFormatVariables($header, $locals); $renderout .= $header; } $renderout .= $parsedContents; if (!empty($templateBlocks[$handler . 'footer'])) { $footer = $templateBlocks[$handler . 'footer']; $footer = $this->parseSetters($footer, $locals); $footer = $this->parseConditions($footer, $locals); $footer = $this->parseFilters($footer, $locals); $footer = $this->parseAssets($footer, $locals); $template->setLocals($locals); // parse dependent sub modules $footer = $this->parseTemplateIncludes($footer, $template->getContentType(), $template, $globals, $renderer, false, true); $footer = $this->parseFormatVariables($footer, $locals); $renderout .= $footer; } } } else { if (!$template->isTopTemplate() && !array_key_exists($handler . 'contents', $templateBlocks) && !array_key_exists($handler . 'noresults', $templateBlocks)) { throw new Exception('Template [' . $template->getName() . '] is missing a template block for [' . $handler . 'noresults] or [' . $handler . 'contents] or [' . $handler . 'exec]'); } if (array_key_exists($handler . 'noresults', $templateBlocks)) { $renderout = $templateBlocks[$handler . 'noresults']; } elseif ($template->getData() === null && empty($locals['DataSource']) && array_key_exists($handler . 'exec', $templateBlocks)) { $renderout = $templateBlocks[$handler . 'exec']; } elseif ($template->getData() === null && empty($locals['DataSource']) && array_key_exists($handler . 'contents', $templateBlocks)) { $renderout = $templateBlocks[$handler . 'contents']; } elseif ($template->isTopTemplate()) { throw new NotFoundException($template->getName()); } $renderout = $this->parseSetters($renderout, $locals); $renderout = $this->parseConditions($renderout, $locals); $renderout = $this->parseFilters($renderout, $locals); $renderout = $this->parseConditions($renderout, $locals); $template->setLocals($locals); // parse dependent sub modules //$template->setLocals($locals); $renderout = $this->parseTemplateIncludes($renderout, $template->getContentType(), $template, $globals, $renderer, false, true); $renderout = $this->parseFormatVariables($renderout, $locals); } //if(LOG_ENABLE) System::log(self::$logType, 'Render out ['.print_r($renderout, true).']'); if ($this->benchmarkRendering) { $this->Benchmark->end('process-template-blocks-' . $template->getName()); } return $renderout; }
/** * A utility function to load a template from an .ini file which does * _not_ perform static initialization and therefore can be used during * static initialization. * @param string $filename The filename of the .ini file to load. * @param \EVought\vCardTools\Template $fallback A Template to use as a fallback * for undefined fragments. If null, this method will look for '_fallback' * in the .ini file and will use it, *if* a Template by that name is * registered. * @return \EVought\vCardTools\Template * @throws \DomainException If the file does not exist or is not readable. * @throws \DomainException If the key '_template' in the .ini file does * not contain the expected components. * @throws \RuntimeException If an error occurs while reading the .ini file. */ private static function i_fromINI($filename, Template $fallback = null) { assert(!empty($filename), '$filename may not be empty'); if (!is_readable($filename)) { throw new \DomainException('Filename, ' . $filename . 'must exist and be readable'); } $fragments = parse_ini_file($filename); if (false === $fragments) { throw new \RuntimeException('Failed to load INI file ' . $filename); } if (null === $fallback && array_key_exists('_fallback', $fragments) && array_key_exists($fragments['_fallback'], self::$templateRegistry)) { $fallback = self::$templateRegistry[$fragments['_fallback']]; } if (null === $fallback && array_key_exists('_fallback_file', $fragments)) { $fallback = self::i_fromINI($fragments['_fallback_file']); } unset($fragments['_fallback']); unset($fragments['_fallback_file']); if (array_key_exists('_template', $fragments)) { if (!is_array($fragments['_template'])) { throw new \DomainException('_template must be an array and ' . 'should contain informational ' . 'keys and values about the ' . 'Template'); } $info = TemplateInfo::fromArray($fragments['_template']); unset($fragments['_template']); } else { $info = new TemplateInfo(); } $template = new Template($fragments, $fallback, $info); if (null !== $template->getName()) { self::$templateRegistry[$template->getName()] = $template; } return $template; }
/** * parseTemplate hook for articles and events * * @param \Template $objTempalte */ public function parseTemplate(\Template $objTemplate) { // check for mod_article template if (stripos($objTemplate->getName(), 'mod_article') !== false) { // prepare sharebuttons string $strSharebuttons = ''; // get the networks $arrNetworks = deserialize($objTemplate->sharebuttons_networks); // check if there are any networks if ($arrNetworks) { // set data $networks = $arrNetworks; $theme = $objTemplate->sharebuttons_theme; $template = $objTemplate->sharebuttons_template; $url = $objTemplate->href; $title = $objTemplate->title; $description = $objTemplate->teaser; // create the share buttons $strSharebuttons = self::createShareButtons($networks, $theme, $template, $url, $title, $description); } // set sharebuttons variable $objTemplate->sharebuttons = $strSharebuttons; } elseif (stripos($objTemplate->getName(), 'event_') === 0) { // prepare sharebuttons string $strSharebuttons = ''; // get the calendar if (($objCalendar = \CalendarModel::findById($objTemplate->pid)) !== null) { // get the networks $arrNetworks = deserialize($objCalendar->sharebuttons_networks); // check if there are any networks if ($arrNetworks) { // set data $networks = $arrNetworks; $theme = $objCalendar->sharebuttons_theme; $template = $objCalendar->sharebuttons_template; $url = $objTemplate->href; $title = $objTemplate->title; $description = $objTemplate->teaser; $image = $objTemplate->singleSRC; // create the share buttons $strSharebuttons = self::createShareButtons($networks, $theme, $template, $url, $title, $description, $image); } } // set sharebuttons variable $objTemplate->sharebuttons = $strSharebuttons; } }
/** * ParseTemplate hook being used to beatify the backend view. * * @param \Template $template The template. * * @return void */ public function hookParseTemplate(\Template $template) { if (TL_MODE == 'BE' && $template->getName() == 'be_subcolumns' && Bootstrap::getConfigVar('grid-editor.backend.replace-subcolumns-template')) { $template->setName('be_subcolumns_bootstrap'); } }
/** * Adds a template. * * @param \Template $template The message. * * @return void */ public function addTemplate($template) { $this->messages[] = array('message' => $template->getData(), 'label' => $template->getName(), 'time' => microtime(true)); }
public function processTemplate(Template $template, $contentType, &$globals, $isFinalPass = false, $isDependentPass = false) { if (!$isFinalPass && $template->isDeferred() || $isDependentPass && !$template->isDependent()) { $this->Logger->debug("Deferring template [{$template->getName()}]"); // defer my execution return $template->getMatchString(); } $this->Logger->debug("Processing template [{$template->getName()}]"); if ($this->benchmarkRendering) { $this->Benchmark->start('process-template-' . $template->getName()); } if ($this->noTemplatesCalled == true) { $this->topTemplate = $template; $this->noTemplatesCalled = false; $template->setTopTemplate(true); } $templateEngine = $this->getTemplateEngine($template->getName()); try { $template = $templateEngine->loadTemplateExtended($template, $globals); } catch (Exception $e) { if ($this->throwRenderExceptions) { throw $e; } else { $this->Logger->error($e->getMessage() . "\nURL: " . URLUtils::fullUrl()); return ''; } } $cacheThisModule = false; $usedCache = false; if ($this->cacheEnabled && $template->isCacheable()) { $cacheThisModule = true; } if ($cacheThisModule) { $cacheKey = $this->TemplateCache->getTemplateCacheKey($template, $globals); if (!in_array($template->getName(), (array) $this->pushCache) && ($cachedTemplate = $this->TemplateCache->get($cacheKey))) { // check the timestamp //if ($cachedTemplate->getTimestamp() == $template->getTimestamp()) { $this->Logger->debug("Loaded from cache [" . $template->getName() . "]"); $locals = $template->Locals; // load from cache $template = $templateEngine->loadFromCache($cachedTemplate); $template->Locals = $locals; $content = $template->getProcessedContent(); $usedCache = true; //} } } if (!$usedCache) { $this->Logger->debug("Processing [{$template->getName()}]"); // process the template and all dependent includes $content = $templateEngine->processTemplateContents($template, $globals, $this, $isFinalPass, $isDependentPass); $template->setProcessedContent($content); if ($cacheThisModule) { // snapshot of the cache contents at this moment $toBeCachedTemplate = clone $templateEngine->prepareForCache($template); } } // parse all independent includes, outside of caching (recurse!) $content = $templateEngine->parseTemplateIncludes($content, $contentType, $template, $globals, $this, $isFinalPass, false); if (!$usedCache) { $this->Logger->debug("Processing template set globals [{$template->getName()}]..."); // parse template set globals $templateSetGlobals = $templateEngine->processTemplateSetGlobals($template, $globals, $isFinalPass); } else { $templateSetGlobals = $cachedTemplate->getTemplateSetGlobals(); } $globals = array_merge($globals, $templateSetGlobals); // store in cache if (!$usedCache && $cacheThisModule) { $toBeCachedTemplate->setIndependentTemplates($template->isIndependentTemplates()); $toBeCachedTemplate->setParsedIndependent(true); if ($template->isTopTemplate()) { $toBeCachedTemplate->setTemplateSetGlobals($globals); } else { $toBeCachedTemplate->setTemplateSetGlobals($templateSetGlobals); } $this->Logger->debug("Storing in cache [" . $toBeCachedTemplate->getName() . "]"); unset($toBeCachedTemplate->Locals); unset($toBeCachedTemplate->Data); unset($toBeCachedTemplate->Contents); unset($toBeCachedTemplate->SetMatches); unset($toBeCachedTemplate->File); unset($toBeCachedTemplate->TemplateBlocks); $this->TemplateCache->putTemplate($cacheKey, $toBeCachedTemplate); } if ($this->benchmarkRendering) { $this->Benchmark->end('process-template-' . $template->getName()); } return $content; }
/** * parseTemplate hook * * @param \Template $template * @return void */ public function parseTemplateHook($template) { if (!($permissions = static::checkLogin())) { return; } if (in_array('beModules', $permissions)) { if (substr($template->getName(), 0, 4) === 'com_' && substr($template->id, 0, 1) === 'c') { $template->class .= ' rsfh-comment-' . substr($template->id, 1); } if (substr($template->getName(), 0, 5) === 'rsmm_' && !empty($template->id)) { $template->cssClass .= ' rsfh-mega-menu-' . $template->id; } } }
/** * add stylesheet to the template depending on settings * * @param \Template $objTemplate */ public function onParseTemplate(\Template $objTemplate) { if (TL_MODE == 'BE' && $this->useImprovedTheme() && in_array($objTemplate->getName(), $GLOBALS['TL_CONFIG']['useBackendImprovedOnTemplates'])) { if ($this->objCombiner->hasEntries()) { $objTemplate->javascripts .= '<script src="' . $this->objCombiner->getCombinedFile() . '"></script>'; } $objTemplate->stylesheets .= '<link rel="stylesheet" href="system/modules/be_improved_theme/assets/style.css">' . "\r\n"; } }
/** * Returns a cacheKey for the specified Template * * @param Template $template The template to generate the cacheKey for * @param array $globals An array of globals set on this template * * @return string The cache key */ public function getTemplateCacheKey(Template $template, $globals) { $locals = $template->getLocals(); $cachekey = ''; if ($template->isTopTemplate()) { $cachekey .= $this->Request->getAdjustedRequestURI(); } else { $cachekey .= $template->getContentType() . $template->getName(); } $cacheParams = array(); // any locals that aren't globals foreach ($locals as $name => $value) { if (!is_array($value) && !array_key_exists($name, $globals) && !preg_match("/^[A-Z\\-\\_0-9]+\$/", $name) && !preg_match("/\\-\\d+\$/", $name)) { $cacheParams[$name] = $value; } } if (isset($cacheParams['UseQueryStringInCacheKey']) && StringUtils::strToBool($cacheParams['UseQueryStringInCacheKey']) == true) { foreach ($_GET as $name => $value) { if (!is_array($value)) { $cacheParams['q_' . $name] = $value; } } } $cachekey .= '?'; if (!empty($cacheParams)) { ksort($cacheParams); foreach ($cacheParams as $n => $v) { $cachekey .= $n . '=' . substr($v, 0, 255) . '&'; } } $cachekey = rtrim($cachekey, '&'); $this->Logger->debug('Cache Key [' . $cachekey . ']'); return $cachekey; }
/** * Use the parse template hook to inject column and row classes. * * @param \Template $template The template. * * @return void */ public function hookParseTemplate(\Template $template) { if (substr($template->getName(), 0, 3) != 'ce_' || $template->type != 'semantic_html5' || $template->sh5_tag != 'start') { return; } $this->createRow($template); $this->createColumn($template); }
/** * @group default */ public function testConstructWInfo() { $fragments = []; $template = new Template($fragments, null, new TemplateInfo('George')); $this->assertSame($fragments, $template->getFragments()); $this->assertEquals('George', $template->getName()); $this->assertNull($template->getFallback()); }
} if (!isset($_SERVER['SERVER_PORT'])) { $_SERVER['SERVER_PORT'] = 80; } $scheme = $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://'; $siteAlias = new Alias($publicationObj->getDefaultAliasId()); $websiteURL = $scheme.$siteAlias->getName(); $accessParams = "LoginUserId=" . $g_user->getUserId() . "&LoginUserKey=" . $g_user->getKeyId() . "&AdminAccess=all"; $urlType = $publicationObj->getProperty('IdURLType'); if ($urlType == 1) { $templateObj = new Template($templateId); $url = "$websiteURL" . $Campsite['SUBDIR'] . "/tpl/" . $templateObj->getName() . "?IdLanguage=$Language&IdPublication=$Pub&NrIssue=$Issue&$accessParams"; } else { $url = "$websiteURL" . $Campsite['SUBDIR'] . '/' . $languageObj->getCode() . "/" . $issueObj->getUrlName() . "?$accessParams"; } $selectedLanguage = (int)CampRequest::GetVar('Language'); $url .= "&previewLang=$selectedLanguage"; if ($g_user->hasPermission("ManageTempl") || $g_user->hasPermission("DeleteTempl")) { // Show dual-pane view for those with template management priviledges ?> <FRAMESET ROWS="60%,*" BORDER="1"> <FRAME SRC="<?php echo "$url&preview=on"; ?>" NAME="body" FRAMEBORDER="1"> <FRAME NAME="e" SRC="empty.php" FRAMEBORDER="1">
protected function loadTemplateContents(Template $template, $globals) { $file = $template->getFile(); $xml = file_get_contents($file); if (preg_match("/xbuilder\\=\"(c:)?([^\"]+)\"/si", $xml, $m)) { $parserClass = $m[2]; } else { throw new Exception('XModule [' . $template->getName() . '] failed to specify XBuilder class'); } $builder = $this->ApplicationContext->object($parserClass); if (!$builder instanceof XBuilderInterface) { throw new TemplateEngineException('XBuilder class does not implement XBuilderInterface: ' . get_class($builder)); } // TODO: cache module contents into a file and parse as usual $contents = $builder->handleBuild($xml, $file, $template, array_merge($globals, $this->getConstants())); // remove comments $contents = preg_replace("/{%\\s+\\/\\*.*\\*\\/\\s+%}/sU", '', $contents); if (empty($contents)) { throw new TemplateEngineException("Template empty: " . $template->getName()); } $template->setContents($contents); return $template; }