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


PHP XenForo_Template_Compiler::prepareSegmentsForIteration方法代码示例

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


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

示例1: _getStandardAdminTagData

 /**
  * Gets the standard data out of a list of segments. Data will be pulled from tags
  * in that list and their attributes only.
  *
  * @param XenForo_Template_Compiler
  * @param array List of segments
  * @param array An optional list of additional tags that are allowed
  *
  * @return array Keys are standard data types that were found
  */
 protected function _getStandardAdminTagData(XenForo_Template_Compiler $compiler, array $segments, array $extraAllowedTags = array())
 {
     $segments = $compiler->prepareSegmentsForIteration($segments);
     $output = array();
     $foundContent = false;
     foreach ($segments as $segment) {
         if (is_string($segment)) {
             if (trim($segment) !== '') {
                 $foundContent = true;
             }
             continue;
         } else {
             if (!isset($segment['type']) || $segment['type'] != 'TAG') {
                 $foundContent = true;
                 continue;
             }
         }
         switch ($segment['name']) {
             case 'label':
                 $attributes = $segment['attributes'];
                 if (isset($attributes['hidden'])) {
                     $output['labelHidden'] = $attributes['hidden'];
                 }
                 if (isset($attributes['hint'])) {
                     $output['hint'] = $attributes['hint'];
                 }
                 $output['label'] = $segment['children'];
                 break;
             case 'hint':
             case 'explain':
             case 'html':
                 $output[$segment['name']] = $segment['children'];
                 break;
             default:
                 if (!$extraAllowedTags || !in_array($segment['name'], $extraAllowedTags)) {
                     // all other tags are "content" tags
                     $foundContent = true;
                 }
         }
     }
     if ($output && $foundContent) {
         // found some known tags, some content -- error
         throw $compiler->getNewCompilerException(new XenForo_Phrase('found_unexpected_content_within_an_admin_control_tag'));
     } else {
         if ($foundContent) {
             // content only -- treat it as HTML tag
             $output = array('html' => $segments);
         }
     }
     return $output;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:61,代码来源:Abstract.php

示例2: compile

 /**
  * Compile the function and return PHP handle it.
  *
  * @param XenForo_Template_Compiler The invoking compiler
  * @param string                 Name of the function called
  * @param array                  Arguments to the function (should have at least 1)
  * @param array                  Compilation options
  *
  * @return string
  */
 public function compile(XenForo_Template_Compiler $compiler, $function, array $arguments, array $options)
 {
     if (count($arguments) != 1) {
         throw $compiler->getNewCompilerArgumentException();
     }
     $placeholders = array();
     if (is_string($arguments[0])) {
         $expression = $arguments[0];
     } else {
         $expression = '';
         foreach ($compiler->prepareSegmentsForIteration($arguments[0]) as $segment) {
             if (is_string($segment)) {
                 if (strpos($segment, '?') !== false) {
                     throw $compiler->getNewCompilerException(new XenForo_Phrase('invalid_math_expression'));
                 }
                 $expression .= $segment;
             } else {
                 $expression .= '?';
                 $placeholders[] = $compiler->compileSegment($segment, array_merge($options, array('varEscape' => false)));
             }
         }
     }
     return $this->_parseMathExpression($compiler, $expression, $placeholders);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:34,代码来源:Calc.php


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