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


PHP SSViewer::getTemplateFileByType方法代码示例

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


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

示例1: getContent

 public function getContent()
 {
     if ($this->getField('Content') == '') {
         $templatePath = SSViewer::getTemplateFileByType($this->Identifier, 'main');
         if (file_exists($templatePath)) {
             $contents = file_get_contents($templatePath);
             return $contents;
         }
     }
     return $this->getField('Content');
 }
开发者ID:xmarkclx,项目名称:silverstripe-permamail,代码行数:11,代码来源:PermamailTemplate.php

示例2: collectFromTemplate

 /**
  * Extracts translatables from .ss templates (Self referencing)
  * 
  * @param string $content The text content of a parsed template-file
  * @param string $module Module's name or 'themes'
  * @param string $fileName The name of a template file when method is used in self-referencing mode
  * @return array $entities An array of entities representing the extracted template function calls
  * 
  * @todo Why the type juggling for $this->collectFromTemplate()? It always returns an array.
  */
 public function collectFromTemplate($content, $fileName, $module, &$parsedFiles = array())
 {
     $entities = array();
     // Search for included templates
     preg_match_all('/<' . '% include +([A-Za-z0-9_]+) +%' . '>/', $content, $regs, PREG_SET_ORDER);
     foreach ($regs as $reg) {
         $includeName = $reg[1];
         $includeFileName = "{$includeName}.ss";
         $filePath = SSViewer::getTemplateFileByType($includeName, 'Includes');
         if (!$filePath) {
             $filePath = SSViewer::getTemplateFileByType($includeName, 'main');
         }
         if ($filePath && !in_array($filePath, $parsedFiles)) {
             $parsedFiles[] = $filePath;
             $includeContent = file_get_contents($filePath);
             $entities = array_merge($entities, (array) $this->collectFromTemplate($includeContent, $module, $includeFileName, $parsedFiles));
         }
         // @todo Will get massively confused if you include the includer -> infinite loop
     }
     // use parser to extract <%t style translatable entities
     $translatables = i18nTextCollector_Parser::GetTranslatables($content);
     $entities = array_merge($entities, (array) $translatables);
     // use the old method of getting _t() style translatable entities
     // Collect in actual template
     if (preg_match_all('/(_t\\([^\\)]*?\\))/ms', $content, $matches)) {
         foreach ($matches[1] as $match) {
             $entities = array_merge($entities, $this->collectFromCode($match, $module));
         }
     }
     foreach ($entities as $entity => $spec) {
         unset($entities[$entity]);
         $entities[$this->normalizeEntity($entity, $module)] = $spec;
     }
     ksort($entities);
     return $entities;
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:46,代码来源:i18nTextCollector.php

示例3: collectFromTemplate

 public function collectFromTemplate($content, $module, $fileName)
 {
     $entitiesArr = array();
     // Search for included templates
     preg_match_all('/<' . '% include +([A-Za-z0-9_]+) +%' . '>/', $content, $regs, PREG_SET_ORDER);
     foreach ($regs as $reg) {
         $includeName = $reg[1];
         $includeFileName = "{$includeName}.ss";
         $filePath = SSViewer::getTemplateFileByType($includeName, 'Includes');
         if (!$filePath) {
             $filePath = SSViewer::getTemplateFileByType($includeName, 'main');
         }
         if ($filePath) {
             $includeContent = file_get_contents($filePath);
             $entitiesArr = array_merge($entitiesArr, (array) $this->collectFromTemplate($includeContent, $module, $includeFileName));
         }
         // @todo Will get massively confused if you include the includer -> infinite loop
     }
     // @todo respect template tags (< % _t() % > instead of _t())
     $regexRule = '_t[[:space:]]*\\(' . '[[:space:]]*("[^"]*"|\\\'[^\']*\\\')[[:space:]]*,' . '[[:space:]]*(("([^"]|\\\\")*"|\'([^\']|\\\\\')*\')' . '([[:space:]]*\\.[[:space:]]*("([^"]|\\\\")*"|\'([^\']|\\\\\')*\'))*)' . '([[:space:]]*,[[:space:]]*[^,)]*)?([[:space:]]*,' . '[[:space:]]*("([^"]|\\\\")*"|\'([^\']|\\\\\')*\'))?[[:space:]]*' . '\\)';
     while (ereg($regexRule, $content, $regs)) {
         $entitiesArr = array_merge($entitiesArr, (array) $this->entitySpecFromRegexMatches($regs, $fileName));
         // remove parsed content to continue while() loop
         $content = str_replace($regs[0], "", $content);
     }
     ksort($entitiesArr);
     return $entitiesArr;
 }
开发者ID:comperio,项目名称:silverstripe-framework,代码行数:28,代码来源:i18nTextCollector.php


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