当前位置: 首页>>代码示例>>PHP>>正文


PHP Template::replaceIdentifier方法代码示例

本文整理汇总了PHP中Template::replaceIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP Template::replaceIdentifier方法的具体用法?PHP Template::replaceIdentifier怎么用?PHP Template::replaceIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Template的用法示例。


在下文中一共展示了Template::replaceIdentifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderFrontend

 public function renderFrontend()
 {
     $oCriteria = DocumentQuery::create()->filterByDocumentKind('image');
     if (!Session::getSession()->isAuthenticated()) {
         $oCriteria->filterByIsProtected(false);
     }
     if ($this->iCategoryId !== null) {
         $oCriteria->filterByDocumentCategoryId($this->iCategoryId);
     }
     $aDocuments = $oCriteria->find();
     $sTemplateName = 'helpers/gallery';
     try {
         $oListTemplate = new Template($sTemplateName);
         foreach ($aDocuments as $i => $oDocument) {
             $oItemTemplate = new Template($sTemplateName . DocumentListFrontendModule::LIST_ITEM_POSTFIX);
             $oItemTemplate->replaceIdentifier('model', 'Document');
             $oItemTemplate->replaceIdentifier('counter', $i + 1);
             $oDocument->renderListItem($oItemTemplate);
             $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate);
         }
     } catch (Exception $e) {
         $oListTemplate = new Template("", null, true);
     }
     return $oListTemplate;
 }
开发者ID:rapila,项目名称:cms-full,代码行数:25,代码来源:CategorySubpagesFrontendModule.php

示例2: listInSidebar

 private function listInSidebar(Template $oTemplate)
 {
     $aWidgets = Module::listModulesByType(WidgetModule::getType());
     $oLinks = new Template(TemplateIdentifier::constructIdentifier('links'), null, true);
     foreach ($aWidgets as $sWidgetName => $aWidgetInfo) {
         $oLink = new Template('<a href="{{href}}">{{name}}</a><br />', null, true);
         $oLink->replaceIdentifier('href', LinkUtil::link(array($sWidgetName), get_class()));
         $oLink->replaceIdentifier('name', WidgetModule::getDisplayNameByName($sWidgetName));
         $oLinks->replaceIdentifierMultiple('links', $oLink);
     }
     $oTemplate->replaceIdentifierMultiple('sidebar_content', $oLinks);
 }
开发者ID:rapila,项目名称:cms-base,代码行数:12,代码来源:WidgetTestManager.php

示例3: send

 /** send()
  * Description:
  * • This method is called when NewsletterMailer is instanciated
  * • All newsletter, sender and recipient info are ready
  *
  * @return boolean has_invalid email addresses
  */
 public function send()
 {
     // Get newsletter email main template and template body and css by template name
     $oEmailTemplate = new Template('main', array(DIRNAME_TEMPLATES, 'newsletter'));
     $oEmailTemplate->replaceIdentifier('newsletter_template_css', new Template("{$this->oNewsletter->getTemplateName()}.css", array(DIRNAME_TEMPLATES, 'newsletter')));
     // Parse links differently in text
     RichtextUtil::$USE_ABSOLUTE_LINKS = LinkUtil::isSSL();
     $oEMailContent = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($this->oNewsletter->getNewsletterBody()));
     RichtextUtil::$USE_ABSOLUTE_LINKS = null;
     // Replace add surrounding (body.tmpl) before content if exists. Template needs to contain a newsletter_content identifier
     if (ResourceFinder::findResource(array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME, "{$this->oNewsletter->getTemplateName()}.body.tmpl")) !== null) {
         $oEmailTemplate->replaceIdentifier('newsletter_content', new Template("{$this->oNewsletter->getTemplateName()}.body", array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME)), null, Template::LEAVE_IDENTIFIERS);
     }
     $oEmailTemplate->replaceIdentifier('newsletter_content', $oEMailContent, null, Template::LEAVE_IDENTIFIERS);
     $oEmailTemplate->replaceIdentifier('subject', $this->oNewsletter->getSubject());
     $oEmailTemplate->replaceIdentifier('language', $this->oNewsletter->getLanguageId());
     $oEmailTemplate->replaceIdentifier('newsletter_link', LinkUtil::absoluteLink($this->oNewsletter->getDisplayLink()));
     $oEmailTemplate->replaceIdentifier('newsletter_date', LocaleUtil::localizeDate(null, $this->oNewsletter->getLanguageId()));
     $oEmailTemplate->replaceIdentifier('newsletter_timestamp', time());
     // Process templates with each recipient, depending on whether recipient is object and object of Subscriber or string
     foreach ($this->aRecipients as $mRecipient) {
         $this->sendNewsletter($mRecipient, clone $oEmailTemplate);
     }
     return count($this->aInvalidEmails) === 0;
 }
开发者ID:rapila,项目名称:plugin-newsletter,代码行数:32,代码来源:NewsletterMailer.php

示例4: testCalculations

 /**
  * @dataProvider validCalculations
  */
 public function testCalculations($sCalculation, $sExpectedResult = '0')
 {
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('doCalculation', $sCalculation), null, true);
     $oExpected = new Template(TemplateIdentifier::constructIdentifier('result'), null, true);
     $oExpected->replaceIdentifier('result', $sExpectedResult);
     $this->assertSame($oExpected->render(), $oTemplate->render());
 }
开发者ID:rapila,项目名称:cms-base,代码行数:10,代码来源:TemplateSpecialIdentifierTests.php

示例5: testPStringWithHTMLAsTemplate

 public function testPStringWithHTMLAsTemplate()
 {
     $sString = TranslationPeer::getString('simple_quote', 'de', null, array('quoted' => 'String'));
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('string'), null, true);
     $oTemplate->replaceIdentifier('string', $sString);
     $this->assertSame("&gt;String&lt;", $oTemplate->render());
 }
开发者ID:rapila,项目名称:cms-base,代码行数:7,代码来源:TemplateStringTests.php

示例6: getStringAsHTML

 public function getStringAsHTML($sKey, $aParams = array(), $sLanguageId = null, $sDefaultValue = null)
 {
     $mResult = TranslationPeer::getString($sKey, $sLanguageId, $sDefaultValue, $aParams, true);
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('result'), null, true);
     $oTemplate->replaceIdentifier('result', $mResult);
     return $oTemplate->render();
 }
开发者ID:rapila,项目名称:cms-base,代码行数:7,代码来源:StringWidgetModule.php

示例7: testSimpleInlineFlagForceHtmlEscape

    public function testSimpleInlineFlagForceHtmlEscape()
    {
        $sTemplateText = <<<EOT
{{test;templateFlag=FORCE_HTML_ESCAPE}}
EOT;
        $oTemplate = new Template($sTemplateText, null, true);
        $oTemplate->replaceIdentifier('test', new Template('<a>&nbsp;</a>', null, true));
        $this->assertSame('&lt;a&gt;&amp;nbsp;&lt;/a&gt;', $oTemplate->render());
    }
开发者ID:rapila,项目名称:cms-base,代码行数:9,代码来源:TemplateReplacementInlineFlagTests.php

示例8: testDirectOutputWithIdentifierAndValue

    public function testDirectOutputWithIdentifierAndValue()
    {
        $sTemplateText = <<<EOT
test{{id}}test2
EOT;
        $this->expectOutputString('test value test2');
        $oTemplate = new Template($sTemplateText, null, true, true);
        $oTemplate->replaceIdentifier("id", " value ");
    }
开发者ID:rapila,项目名称:cms-base,代码行数:9,代码来源:TemplateDirectOutputTests.php

示例9: display

 public function display(Template $oTemplate, $bIsPreview = false)
 {
     $sTemplateName = $this->oPage->getTemplateNameUsed();
     $sLanguageId = Session::language();
     $oListTemplate = null;
     $oItemTemplatePrototype = null;
     try {
         $oListTemplate = new Template("search_results/{$sTemplateName}");
         $oItemTemplatePrototype = new Template("search_results/{$sTemplateName}_item");
     } catch (Exception $e) {
         $oListTemplate = new Template("search_results/default");
         $oItemTemplatePrototype = new Template("search_results/default_item");
     }
     $aResults = array();
     $sWords = isset($_REQUEST['q']) ? $_REQUEST['q'] : '';
     if ($sWords) {
         $aWords = StringUtil::getWords($sWords, false, '%');
         $oSearchWordQuery = SearchIndexWordQuery::create();
         foreach ($aWords as $sWord) {
             $sWord = Synonyms::rootFor($sWord);
             $sComparison = Criteria::EQUAL;
             if (strpos($sWord, '%') !== false) {
                 $sComparison = Criteria::LIKE;
             }
             $oSearchWordQuery->addOr(SearchIndexWordPeer::WORD, $sWord, $sComparison);
         }
         $oSearchWordQuery->joinSearchIndex()->useQuery('SearchIndex')->joinPage()->useQuery('Page')->active(true)->filterByIsProtected(false)->endUse()->endUse();
         foreach ($oSearchWordQuery->find() as $oSearchIndexWord) {
             $iId = $oSearchIndexWord->getSearchIndexId();
             if (isset($aResults[$iId])) {
                 $aResults[$iId] += $oSearchIndexWord->getCount();
             } else {
                 $aResults[$iId] = $oSearchIndexWord->getCount();
             }
         }
         arsort($aResults);
     }
     $oListTemplate->replaceIdentifier('count', count($aResults));
     $oListTemplate->replaceIdentifier('search_string', $sWords);
     if (count($aResults) === 0) {
         $oListTemplate->replaceIdentifier('no_results', TranslationPeer::getString('wns.search.no_results', null, null, array('search_string' => $sWords)));
     }
     foreach ($aResults as $iIndexId => $iCount) {
         $oIndex = SearchIndexQuery::create()->findPk(array($iIndexId, $sLanguageId));
         if (!$oIndex || !$oIndex->getPage()) {
             continue;
         }
         $oItemTemplate = clone $oItemTemplatePrototype;
         $oIndex->renderListItem($oItemTemplate);
         $oItemTemplate->replaceIdentifier('count', $iCount);
         $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate);
     }
     $oTemplate->replaceIdentifier('search_results', $oListTemplate);
 }
开发者ID:rapila,项目名称:plugin-full_text_search,代码行数:54,代码来源:SearchResultPageTypeModule.php

示例10: onFillPageAttributes

 public function onFillPageAttributes($oCurrentPage, $oTemplate)
 {
     $oSearchPage = $oCurrentPage->getPageOfType('search_result');
     if ($oSearchPage === null) {
         return;
     }
     $oTemplate->replaceIdentifier("search_action", LinkUtil::link($oSearchPage->getLinkArray()));
     foreach ($oTemplate->identifiersMatching('search_form', Template::$ANY_VALUE) as $oIdentifier) {
         $oSubTemplate = new Template($oIdentifier->getValue() ? $oIdentifier->getValue() : 'default', array(DIRNAME_TEMPLATES, 'search_form'));
         $oSubTemplate->replaceIdentifier("search_action", LinkUtil::link($oSearchPage->getLinkArray()));
         $oTemplate->replaceIdentifier($oIdentifier, $oSubTemplate);
     }
 }
开发者ID:rapila,项目名称:plugin-full_text_search,代码行数:13,代码来源:SearchFilterModule.php

示例11: renderFile

 /**
  * renderFile()
  * @return string xhtml output
  */
 public function renderFile()
 {
     $oOutput = new XHTMLOutput(XHTMLOutput::SETTING_HTML_4_TRANSITIONAL, true, null, $this->oNewsletter->getLanguageId());
     $oOutput->render();
     $oNewsletterTemplate = new Template('main_display', array(DIRNAME_TEMPLATES, 'newsletter'), false, true);
     $oNewsletterTemplate->replaceIdentifier('newsletter_template_css', new Template("{$this->oNewsletter->getTemplateName()}.css", array(DIRNAME_TEMPLATES, 'newsletter')));
     $oNewsletterContent = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($this->oNewsletter->getNewsletterBody()));
     if (ResourceFinder::findResource(array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME, "{$this->oNewsletter->getTemplateName()}.body.tmpl")) !== null) {
         $oNewsletterTemplate->replaceIdentifier('newsletter_content', new Template("{$this->oNewsletter->getTemplateName()}.body", array(DIRNAME_TEMPLATES, NewsletterDetailWidgetModule::NEWSLETTER_DIRNAME)), null, Template::LEAVE_IDENTIFIERS);
     }
     $oNewsletterTemplate->replaceIdentifier('newsletter_content', $oNewsletterContent, null, Template::LEAVE_IDENTIFIERS);
     $oNewsletterTemplate->replaceIdentifier('language', $this->oNewsletter->getLanguageId());
     if ($this->oMailing !== null) {
         $oNewsletterTemplate->replaceIdentifier('newsletter_date', LocaleUtil::localizeDate($this->oMailing->getDateSent(null)->getTimestamp(), $this->oNewsletter->getLanguageId()));
         $oNewsletterTemplate->replaceIdentifier('newsletter_timestamp', $this->oMailing->getDateSent(null)->getTimestamp());
     } else {
         $oNewsletterTemplate->replaceIdentifier('newsletter_date', LocaleUtil::localizeDate($this->oNewsletter->getCreatedAt(null)->getTimestamp(), $this->oNewsletter->getLanguageId()));
         $oNewsletterTemplate->replaceIdentifier('newsletter_timestamp', $this->oNewsletter->getCreatedAt(null)->getTimestamp());
     }
     $oNewsletterTemplate->replaceIdentifier('recipient', TranslationPeer::getString('wns.newsletter.recipient', $this->oNewsletter->getLanguageId()));
     $oNewsletterTemplate->replaceIdentifier('subject', $this->oNewsletter->getSubject());
     $oNewsletterTemplate->render();
 }
开发者ID:rapila,项目名称:plugin-newsletter,代码行数:27,代码来源:DisplayNewsletterFileModule.php

示例12: renderListItem

 public function renderListItem(Template $oTemplate)
 {
     $oTemplate->replaceIdentifier("id", $this->getId());
     $oTemplate->replaceIdentifier("name", $this->getPage()->getName());
     $oTemplate->replaceIdentifier("link_text", $this->getLinkText());
     $oTemplate->replaceIdentifier("title", $this->getPageTitle());
     $oTemplate->replaceIdentifier("description", $this->getPage()->getDescription());
     $oTemplate->replaceIdentifier("url", $this->getLink());
 }
开发者ID:rapila,项目名称:plugin-full_text_search,代码行数:9,代码来源:SearchIndex.php

示例13: testTypesInArrayReplace

 public function testTypesInArrayReplace()
 {
     $oTestTemplate = new Template('{{test}}', null, true);
     $oTestTemplate->replaceIdentifier('test', array('SAMPLE', 1, 9999999999.0, 3.1415972, new TagWriter('a')));
     $this->assertSame("SAMPLE199999999993.1415972&lt;a&gt;&lt;/a&gt;", $oTestTemplate->render());
 }
开发者ID:rapila,项目名称:cms-base,代码行数:6,代码来源:TemplateReplacementTypeTests.php

示例14: testIdentifierEscaping

    public function testIdentifierEscaping()
    {
        $sTemplateText = <<<EOT
{{test=\\\\}}{{test=\\{\\{t1=\\\\\\\\\\\\}\\}\\}}}{{test=val2}}
EOT;
        $oTemplate = new Template($sTemplateText, null, true);
        $this->assertSame("{{test=\\\\}}{{test=\\{\\{t1\\=\\\\\\}\\}\\}}}{{test=val2}}", $oTemplate->__toString());
        $oTemplate->replaceIdentifier('test', "val", '\\', Template::NO_IDENTIFIER_VALUE_REPLACEMENT);
        $this->assertSame("val{{test=\\{\\{t1\\=\\\\\\}\\}\\}}}{{test=val2}}", $oTemplate->__toString());
        $oTemplate->replaceIdentifier('t1', "val2");
        $this->assertSame("val{{test=\\{\\{t1\\=\\\\\\}\\}\\}}}{{test=val2}}", $oTemplate->__toString());
        /// @todo
        // $oTemplate->replaceIdentifier('t1', "val3", '\\}');
        // $this->assertSame("val{{test=val3}}{{test=val2}}", $oTemplate->__toString());
        $this->assertSame("val", $oTemplate->render());
    }
开发者ID:rapila,项目名称:cms-base,代码行数:16,代码来源:TemplateReplacementTests.php

示例15: getString

 public static function getString($sKey, $sLanguageId = null, $sDefaultValue = null, $aParameters = null, $bMayReturnTemplate = false, $iFlags = 0)
 {
     $bNoHTMLInReturnedString = $bMayReturnTemplate === null;
     if (Settings::getSetting('frontend', 'display_string_keys', false)) {
         return $sKey;
     }
     if (!is_string($sDefaultValue)) {
         $sDefaultValue = "Translation missing: {$sKey}";
     }
     if ($sLanguageId === null) {
         $sLanguageId = Session::language();
     }
     $oString = self::retrieveByPK($sLanguageId, $sKey);
     $sString = '';
     if ($oString === null) {
         $sString = self::getStaticString($sKey, $sLanguageId);
         if ($sString === null) {
             return $sDefaultValue;
         }
     } else {
         $sString = $oString->getText();
     }
     if (is_array($aParameters) && count($aParameters) > 0 || strpos($sString, TEMPLATE_IDENTIFIER_START) !== false) {
         if (!is_array($aParameters)) {
             $aParameters = array();
         }
         if (!$bMayReturnTemplate) {
             //NO_HTML_ESCAPE works in any case:
             //Case $bMayReturnTemplate === false: strings will always be included in templates and thus always be encoded correctly in a second step.
             //Case $bMayReturnTemplate === null: strings should not contain any HTML-characteristics, including entities. {{br}}-Tags will be stripped as well.
             $iFlags = $iFlags | Template::NO_HTML_ESCAPE;
         }
         if ($bMayReturnTemplate) {
             //If returned item is a template, it is assumed that nothing will run htmlentities on it later on so we have to run it now.
             $sString = Template::htmlEncode($sString);
         }
         if ($bNoHTMLInReturnedString) {
             $sString = str_replace('{{br}}', "\n", $sString);
         }
         $tmpl = new Template($sString, "db", true, false, Settings::getSetting("encoding", "db", "utf-8"), null, $iFlags);
         foreach ($aParameters as $sKey => $sValue) {
             $tmpl->replaceIdentifier($sKey, $sValue);
         }
         if ($bMayReturnTemplate) {
             return $tmpl;
         }
         $sString = $tmpl->render();
     }
     return $sString;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:50,代码来源:TranslationPeer.php


注:本文中的Template::replaceIdentifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。