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


PHP Template::replaceIdentifierMultiple方法代码示例

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


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

示例1: testStringWithoutHTMLAsTemplate

 public function testStringWithoutHTMLAsTemplate()
 {
     $sString1 = TranslationPeer::getString('name', 'de');
     $sString2 = TranslationPeer::getString('key', 'de');
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('string'), null, true);
     $oTemplate->replaceIdentifierMultiple('string', $sString1);
     $oTemplate->replaceIdentifierMultiple('string', $sString2);
     $this->assertSame("Name\nSchlüssel\n", $oTemplate->render());
 }
开发者ID:rapila,项目名称:cms-base,代码行数:9,代码来源:TemplateStringTests.php

示例2: renderFrontend

 public function renderFrontend()
 {
     $aData = unserialize($this->getData());
     $oTemplate = new Template($aData['template']);
     $oItemTemplatePrototype = new Template($aData['template'] . '_item');
     $bItemFound = false;
     // FIXME: Keep track of output $oCorrespondingItems and refuse output if already done
     foreach ($aData['tags'] as $iTagID) {
         $oTag = TagQuery::create()->findPk($iTagID);
         if ($oTag === null) {
             continue;
         }
         $aCorrespondingItems = $oTag->getAllCorrespondingDataEntries($aData['types']);
         foreach ($aCorrespondingItems as $i => $oCorrespondingItem) {
             if (!method_exists($oCorrespondingItem, 'renderListItem')) {
                 return;
             }
             if (!$oCorrespondingItem->shouldBeIncludedInList(Session::language(), FrontendManager::$CURRENT_PAGE)) {
                 continue;
             }
             $bItemFound = true;
             $oItemTemplate = clone $oItemTemplatePrototype;
             $oItemTemplate->replaceIdentifier('model', get_class($oCorrespondingItem));
             $oItemTemplate->replaceIdentifier('counter', $i + 1);
             $oCorrespondingItem->renderListItem($oItemTemplate);
             $oTemplate->replaceIdentifierMultiple("items", $oItemTemplate);
         }
     }
     if (!$bItemFound) {
         return null;
     }
     return $oTemplate;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:33,代码来源:TagFrontendModule.php

示例3: 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

示例4: testDirectOutputMultiple

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

示例5: content

 private function content(Template $oTemplate, $sWidgetName)
 {
     $sWidgetClass = WidgetModule::getClassNameByName($sWidgetName);
     if (is_callable(array($sWidgetClass, 'testWidget'))) {
         $oWidget = $sWidgetClass::testWidget();
     } else {
         $oWidget = WidgetModule::getWidget($sWidgetName, null);
     }
     $oTemplate->replaceIdentifierMultiple('main_content', $oWidget->doWidget());
 }
开发者ID:rapila,项目名称:cms-base,代码行数:10,代码来源:WidgetTestManager.php

示例6: 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

示例7: renderFrontend

 public function renderFrontend()
 {
     $aOptions = @unserialize($this->getData());
     try {
         $oListTemplate = new Template($aOptions['list_template']);
         $oItemPrototype = new Template($aOptions['list_template'] . self::LIST_ITEM_POSTFIX);
         foreach (self::listQuery($aOptions)->find() as $i => $oDocument) {
             $oItemTemplate = clone $oItemPrototype;
             $oDocument->renderListItem($oItemTemplate);
             $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate);
         }
     } catch (Exception $e) {
         $oListTemplate = new Template("", null, true);
     }
     return $oListTemplate;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:16,代码来源:DocumentListFrontendModule.php

示例8: renderFile

 public function renderFile()
 {
     $iTemplateFlags = 0;
     $oResourceFinder = ResourceFinder::create(array(DIRNAME_MODULES, $this->sModuleType, $this->sModuleName, DIRNAME_TEMPLATES))->returnObjects();
     $sFileName = "{$this->sModuleName}.{$this->sModuleType}.{$this->sResourceType}";
     $oResourceFinder->addPath($sFileName . Template::$SUFFIX);
     if ($this->sResourceType === ResourceIncluder::RESOURCE_TYPE_CSS) {
         header("Content-Type: text/css;charset=utf-8");
         $oResourceFinder->all();
     } else {
         if ($this->sResourceType === ResourceIncluder::RESOURCE_TYPE_JS) {
             header("Content-Type: text/javascript;charset=utf-8");
             $iTemplateFlags = Template::ESCAPE | Template::NO_HTML_ESCAPE;
         } else {
             header("Content-Type: text/html;charset=utf-8");
         }
     }
     $oCache = new Cache('template_resource-' . $sFileName . '-' . Session::language(), 'resource');
     $oTemplate = null;
     if ($oCache->entryExists() && !$oCache->isOutdated($oResourceFinder)) {
         $oCache->sendCacheControlHeaders();
         $oTemplate = $oCache->getContentsAsVariable();
     } else {
         $oTemplate = new Template(TemplateIdentifier::constructIdentifier('contents'), null, true, false, null, $sFileName);
         $aResources = $oResourceFinder->find();
         if (!$aResources) {
             $aResources = array();
         }
         if ($aResources instanceof FileResource) {
             $aResources = array($aResources);
         }
         foreach ($aResources as $oResource) {
             $oSubTemplate = new Template($oResource, null, false, false, null, null, $iTemplateFlags);
             $oTemplate->replaceIdentifierMultiple('contents', $oSubTemplate, null, Template::LEAVE_IDENTIFIERS);
         }
         $oCache->setContents($oTemplate);
         $oCache->sendCacheControlHeaders();
     }
     print $oTemplate->render();
 }
开发者ID:rapila,项目名称:cms-base,代码行数:40,代码来源:TemplateResourceFileModule.php

示例9: getIncludes

 /**
  * Returns a Template containing all of the necessary HTML code for the browser to load the included resources.
  * @param $bPrintNewlines Whether to put each include on a new line. Turn this off for “location_only”-type includes.
  * @param $bConsolidate Whether to consolidate CSS and JS includes into a single tag which will point to a new location which will serve all the scripts of one type concatenated.
  * Valid values — true: Consolidate all css/js resources, false: Don’t consolidate, 'internal': Only consolidate internal scripts, but not the ones loaded from external servers, null: Use the default value from the general/consolidate_resources configuration seting from resource_includer.yml.
  * Note that all concatenated scripts will have to be in the same charset, namely the one defined in the encoding/browser configuration setting.
  * Also note that a value of "internal" for $bConsolidate will only have an effect on js libraries if they’re not being locally cached (use_local_library_cache is false)
  */
 public function getIncludes($bPrintNewlines = true, $bConsolidate = null)
 {
     $bConsolidateSetting = Settings::getSetting('general', 'consolidate_resources', false, 'resource_includer');
     if ($bConsolidate === null) {
         $bConsolidate = $bConsolidateSetting;
     }
     if ($bConsolidate === 'never' || $bConsolidateSetting === 'never') {
         //In the “never” case, $bConsolidateSetting overrides a local $bConsolidate
         $bConsolidate = false;
     }
     if ($bConsolidate && !ini_get('allow_url_fopen')) {
         // Never consolidate external files if fopen_wrappers are disabled
         $bConsolidate = 'internal';
     }
     if ($bConsolidate) {
         $this->replaceContentsWithConsolidated($bConsolidate === 'internal');
     }
     $this->cleanupReverseDependencies();
     $iTemplateFlags = 0;
     if (!$bPrintNewlines) {
         $iTemplateFlags = Template::NO_NEWLINE;
     }
     $oTemplate = new Template(TemplateIdentifier::constructIdentifier('includes'), null, true, false, null, null, $iTemplateFlags);
     $aTemplateMasters = array();
     foreach ($this->aIncludedResources as $iPriority => $aIncludedResourcesOfType) {
         if (count($aIncludedResourcesOfType) === 0) {
             continue;
         }
         foreach ($aIncludedResourcesOfType as $aResourceInfo) {
             if (!isset($aTemplateMasters[$aResourceInfo['template']])) {
                 $aTemplateMasters[$aResourceInfo['template']] = new Template($aResourceInfo['template'], array(DIRNAME_TEMPLATES, 'resource_includers'));
             }
             $oIncludeTemplate = clone $aTemplateMasters[$aResourceInfo['template']];
             foreach ($aResourceInfo as $sResourceInfoKey => $sResourceInfoValue) {
                 $oIncludeTemplate->replaceIdentifier($sResourceInfoKey, $sResourceInfoValue);
             }
             if (isset($aResourceInfo['ie_condition'])) {
                 $oIeConditionalTemplate = $this->ieConditionalTemplate();
                 $oIeConditionalTemplate->replaceIdentifier('condition', $aResourceInfo['ie_condition']);
                 $oIeConditionalTemplate->replaceIdentifier('content', $oIncludeTemplate);
                 $oIncludeTemplate = $oIeConditionalTemplate;
             }
             $oTemplate->replaceIdentifierMultiple('includes', $oIncludeTemplate);
         }
     }
     return $oTemplate;
 }
开发者ID:rapila,项目名称:cms-base,代码行数:55,代码来源:ResourceIncluder.php

示例10: testCombinedInlineFlags

    public function testCombinedInlineFlags()
    {
        $sTemplateText = <<<EOT
{{test;templateFlag=LEAVE_IDENTIFIERS|ESCAPE}}
EOT;
        $oTemplate = new Template($sTemplateText, null, true, false, null, null, Template::NO_NEWLINE);
        $oTemplate->replaceIdentifierMultiple('test', new Template('"{{test2}}"', null, true));
        $oTemplate->replaceIdentifierMultiple('test2', 1);
        $this->assertSame('\\"1\\"', $oTemplate->render());
    }
开发者ID:rapila,项目名称:cms-base,代码行数:10,代码来源:TemplateReplacementInlineFlagTests.php

示例11: compileSchemaXml

    private static function compileSchemaXml()
    {
        $sSchemaTemplate = <<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<!-- {{comment}} -->
<database name="{{name}}" defaultIdMethod="native">
\t{{schema_content}}
</database>
EOT;
        foreach (self::groupedSchemaXml() as $sSchemaName => $aSchemas) {
            $oSchemaTemplate = new Template($sSchemaTemplate, null, true);
            $oSchemaTemplate->replaceIdentifier('comment', "This file is generated by the generate-model.sh script, edit schema.xml in the config dir or the plugins or site's schema.xml file instead", null, Template::NO_HTML_ESCAPE);
            $oSchemaTemplate->replaceIdentifier('name', $sSchemaName);
            foreach ($aSchemas as $oSchemaFile) {
                $oSchemaTemplate->replaceIdentifierMultiple('schema_content', file_get_contents($oSchemaFile->getFullPath()), null, Template::NO_HTML_ESCAPE);
            }
            $sSchemaOutputPath = MAIN_DIR . '/' . DIRNAME_GENERATED . "/{$sSchemaName}.schema.xml";
            file_put_contents($sSchemaOutputPath, $oSchemaTemplate->render());
        }
    }
开发者ID:rapila,项目名称:cms-base,代码行数:20,代码来源:BuildHelper.php

示例12: renderGallery

 /**
  * renderGallery()
  *
  * description: display image gallery
  * @return Template object
  */
 private function renderGallery(JournalEntry $oEntry)
 {
     $oEntryTemplate = $this->constructTemplate('journal_gallery');
     $oListTemplate = new Template('helpers/gallery');
     $oListTemplate->replaceIdentifier('title', $this->oEntry->getTitle());
     foreach ($this->oEntry->getImages() as $oJournalEntryImage) {
         $oDocument = $oJournalEntryImage->getDocument();
         $oItemTemplate = new Template('helpers/gallery_item');
         $oItemTemplate->replaceIdentifier('jounal_entry_id', $this->oEntry->getId());
         $oDocument->renderListItem($oItemTemplate);
         $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate);
     }
     $oEntryTemplate->replaceIdentifier('gallery', $oListTemplate);
     return $oEntryTemplate;
 }
开发者ID:rapila,项目名称:plugin-journal,代码行数:21,代码来源:JournalPageTypeModule.php

示例13: testContextsWithNamespaces

    public function testContextsWithNamespaces()
    {
        $sTemplateText = <<<EOT
{{identifierContext=start;name=id}}{{id.help}}: {{id.kill}}{{identifierContext=end;name=id}}

EOT;
        $oTemplate = new Template($sTemplateText, null, true);
        $oTemplate->replaceIdentifierMultiple('id', array('help' => 'me', 'kill' => 'no-one'));
        $oTemplate->replaceIdentifierMultiple('id', array('help' => 'yourself', 'kill' => 'everyone'));
        $this->assertSame(<<<EOT
me: no-one
yourself: everyone


EOT
, $oTemplate->render());
    }
开发者ID:rapila,项目名称:cms-base,代码行数:17,代码来源:TemplateIdentifierContextTests.php

示例14: adminGetContainers

 public function adminGetContainers()
 {
     $oTemplate = $this->oPage->getTemplate();
     foreach ($oTemplate->identifiersMatching('container', Template::$ANY_VALUE) as $oIdentifier) {
         $oInheritedFrom = null;
         $sContainerName = $oIdentifier->getValue();
         if (BooleanParser::booleanForString($oIdentifier->getParameter('inherit'))) {
             $oInheritedFrom = $this->oPage;
             $iInheritedObjectCount = 0;
             while ($iInheritedObjectCount === 0 && ($oInheritedFrom = $oInheritedFrom->getParent()) !== null) {
                 $iInheritedObjectCount = $oInheritedFrom->countObjectsForContainer($sContainerName);
             }
         }
         $sInheritedFrom = $oInheritedFrom ? $oInheritedFrom->getName() : '';
         $aTagParams = array('class' => 'template-container template-container-' . $sContainerName, 'data-container-name' => $sContainerName, 'data-container-string' => TranslationPeer::getString('container_name.' . $sContainerName, null, $sContainerName), 'data-inherited-from' => $sInheritedFrom);
         $oContainerTag = TagWriter::quickTag('ol', $aTagParams);
         $mInnerTemplate = new Template(TemplateIdentifier::constructIdentifier('content'), null, true);
         //Replace container info
         //…name
         $mInnerTemplate->replaceIdentifierMultiple('content', TagWriter::quickTag('div', array('class' => 'template-container-description'), TranslationPeer::getString('wns.page.template_container', null, null, array('container' => TranslationPeer::getString('template_container.' . $sContainerName, null, $sContainerName)), true)));
         //…additional info
         $mInnerTemplate->replaceIdentifierMultiple('content', TagWriter::quickTag('div', array('class' => 'template-container-info')));
         //…tag
         $mInnerTemplate->replaceIdentifierMultiple('content', $oContainerTag);
         //Replace actual container
         $oTemplate->replaceIdentifier($oIdentifier, $mInnerTemplate);
     }
     $bUseParsedCss = Settings::getSetting('admin', 'use_parsed_css_in_config', true);
     $oStyle = null;
     if ($bUseParsedCss) {
         $sTemplateName = $this->oPage->getTemplateNameUsed() . Template::$SUFFIX;
         $sCacheKey = 'parsed-css-' . $sTemplateName;
         $oCssCache = new Cache($sCacheKey, DIRNAME_PRELOAD);
         $sCssContents = "";
         if (!$oCssCache->entryExists() || $oCssCache->isOutdated(ResourceFinder::create(array(DIRNAME_TEMPLATES, $sTemplateName)))) {
             $oIncluder = new ResourceIncluder();
             foreach ($oTemplate->identifiersMatching('addResourceInclude', Template::$ANY_VALUE) as $oIdentifier) {
                 $oIncluder->addResourceFromTemplateIdentifier($oIdentifier);
             }
             foreach ($oIncluder->getAllIncludedResources() as $sIdentifier => $aResource) {
                 if ($aResource['resource_type'] === ResourceIncluder::RESOURCE_TYPE_CSS && !isset($aResource['ie_condition']) && !isset($aResource['frontend_specific'])) {
                     if (isset($aResource['media'])) {
                         $sCssContents .= "@media {$aResource['media']} {";
                     }
                     if (isset($aResource['file_resource'])) {
                         $sCssContents .= file_get_contents($aResource['file_resource']->getFullPath());
                     } else {
                         // Absolute link, requires fopen wrappers
                         $sCssContents .= file_get_contents($aResource['location']);
                     }
                     if (isset($aResource['media'])) {
                         $sCssContents .= "}";
                     }
                 }
             }
             $oParser = new Sabberworm\CSS\Parser($sCssContents, Sabberworm\CSS\Settings::create()->withDefaultCharset(Settings::getSetting("encoding", "browser", "utf-8")));
             $oCss = $oParser->parse();
             $this->cleanupCSS($oCss);
             $sCssContents = Template::htmlEncode($oCss->render(Sabberworm\CSS\OutputFormat::createCompact()));
             $oCssCache->setContents($sCssContents);
         } else {
             $sCssContents = $oCssCache->getContentsAsString();
         }
         $oStyle = new HtmlTag('style');
         $oStyle->addParameters(array('scoped' => 'scoped'));
         $oStyle->appendChild($sCssContents);
     }
     $sTemplate = $oTemplate->render();
     $sTemplate = substr($sTemplate, strpos($sTemplate, '<body') + 5);
     $sTemplate = substr($sTemplate, strpos($sTemplate, '>') + 1);
     $sTemplate = substr($sTemplate, 0, strpos($sTemplate, '</body'));
     $oParser = new TagParser("<body>{$sTemplate}</body>");
     $oTag = $oParser->getTag();
     $this->cleanupContainerStructure($oTag);
     if ($bUseParsedCss) {
         $oTag->appendChild($oStyle);
     }
     $sResult = $oTag->__toString();
     $sResult = substr($sResult, strpos($sResult, '<body>') + 6);
     $sResult = substr($sResult, 0, strrpos($sResult, '</body>'));
     return array('html' => $sResult, 'css_parsed' => $bUseParsedCss);
 }
开发者ID:rapila,项目名称:cms-base,代码行数:82,代码来源:DefaultPageTypeModule.php

示例15: testReplaceIdentifierMultipleNoNewContext1

    public function testReplaceIdentifierMultipleNoNewContext1()
    {
        $sTemplateText = <<<EOT
{{identifierContext=start;name=test}}{{test}} GAGA{{identifierContext=end;name=test}}
EOT;
        $oTemplate = new Template($sTemplateText, null, true);
        $oTemplate->setDefaultFlags(Template::NO_NEWLINE | Template::NO_NEW_CONTEXT);
        $oTemplate->replaceIdentifierMultiple('test', 'string');
        $oTemplate->replaceIdentifierMultiple('test', 1);
        $oTemplate->replaceIdentifierMultiple('test', true);
        $oTemplate->replaceIdentifierMultiple('test', 0xff);
        $oTemplate->replaceIdentifierMultiple('test', array("list", "item"));
        $this->assertSame("string1true255listitem GAGA", $oTemplate->render());
    }
开发者ID:rapila,项目名称:cms-base,代码行数:14,代码来源:TemplateReplacementTests.php


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