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


PHP XenForo_Template_Compiler::setOutputVar方法代码示例

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


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

示例1: compilePopupChildren

 /**
  * Compiles the children of a popup.
  *
  * @param string $newOutputVar Name of the compiler output var
  * @param array $children Children of popup
  * @param XenForo_Template_Compiler $compiler
  * @param array $options Compiler options
  *
  * @return string|XenForo_Template_Statement_Raw
  */
 public static function compilePopupChildren($newOutputVar, array $children, XenForo_Template_Compiler $compiler, array $options)
 {
     $oldOutputVar = $compiler->getOutputVar();
     $compiler->setOutputVar($newOutputVar);
     $code = array();
     foreach ($children as $child) {
         if ($compiler->isSegmentNamedTag($child, 'foreach')) {
             $inner = self::compilePopupChildren($newOutputVar, $child['children'], $compiler, $options);
             $code[] = XenForo_Template_Compiler_Tag_Foreach::compileForeach($inner, $compiler, $child['attributes'], $options);
             continue;
         }
         $choice = false;
         $tempVar = false;
         if ($compiler->isSegmentNamedTag($child, 'link')) {
             if (!isset($child['attributes']['href'])) {
                 throw $compiler->getNewCompilerException(new XenForo_Phrase('popup_links_must_specify_an_href'), $child);
             }
             $choice = array('href' => $compiler->compileAndCombineSegments($child['attributes']['href'], $options), 'text' => $compiler->compileAndCombineSegments($child['children'], $options));
         } else {
             if ($compiler->isSegmentNamedTag($child, 'html')) {
                 $code[] = $compiler->compileIntoVariable($child['children'], $htmlOutputVar, $options);
                 $choice = array('html' => '$' . $htmlOutputVar);
                 $tempVar = '$' . $htmlOutputVar;
             }
         }
         if ($choice) {
             $choiceCode = '$' . $newOutputVar . '[] = ' . $compiler->buildNamedParamCode($choice) . ";\n";
             if ($tempVar) {
                 $choiceCode .= 'unset(' . $tempVar . ");\n";
             }
             if (isset($child['attributes']['displayif'])) {
                 $condition = $compiler->parseConditionExpression($child['attributes']['displayif'], $options);
                 $code[] = 'if ' . $condition . "\n{\n" . $choiceCode . "}\n";
             } else {
                 $code[] = $choiceCode;
             }
         }
     }
     $compiler->setOutputVar($oldOutputVar);
     if ($code) {
         $statement = $compiler->getNewRawStatement();
         foreach ($code as $codeStatement) {
             $statement->addStatement($codeStatement);
         }
         return $statement;
     } else {
         return '';
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:59,代码来源:Popup.php

示例2: _getChoicesCode

 /**
  * Gets the choices that apply to this tag, via option/optgroup/options tags.
  *
  * @param array $children Child tags to search
  * @param XenForo_Template_Compiler $compiler Compiler
  * @param array $options Compiler options
  * @param string $newOutputVar
  *
  * @return string
  */
 protected function _getChoicesCode(array $children, XenForo_Template_Compiler $compiler, array $options, &$newOutputVar = '')
 {
     $oldOutputVar = $compiler->getOutputVar();
     $newOutputVar = $compiler->getUniqueVar();
     $compiler->setOutputVar($newOutputVar);
     $code = '$' . $newOutputVar . " = array();\n";
     foreach ($children as $child) {
         $compiler->setLastVistedSegment($child);
         $code .= $this->_compileChoiceChild($newOutputVar, $child, $compiler, $options);
     }
     $compiler->setOutputVar($oldOutputVar);
     return $code;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:23,代码来源:Abstract.php

示例3: compile

 /**
  * Compile the specified tag and return PHP code to handle it.
  *
  * @param XenForo_Template_Compiler The invoking compiler
  * @param string                 Name of the tag called
  * @param array                  Attributes for the tag (may be empty)
  * @param array                  Nodes (tags/curlies/text) within this tag (may be empty)
  * @param array                  Compilation options
  *
  * @return string
  */
 public function compile(XenForo_Template_Compiler $compiler, $tag, array $attributes, array $children, array $options)
 {
     $data = $attributes;
     $html = null;
     $popups = array();
     $links = array();
     $tempVars = array();
     $statement = $compiler->getNewRawStatement();
     foreach ($children as $child) {
         if ($compiler->isSegmentNamedTag($child, 'label')) {
             $data['label'] = $child['children'];
         } else {
             if ($compiler->isSegmentNamedTag($child, 'snippet')) {
                 $data['snippet'] = $child['children'];
             } else {
                 if ($compiler->isSegmentNamedTag($child, 'html')) {
                     $html = $child['children'];
                 } else {
                     if ($compiler->isSegmentNamedTag($child, 'popup')) {
                         $tempVar = $compiler->getUniqueVar();
                         $oldOutputVar = $compiler->getOutputVar();
                         $compiler->setOutputVar($tempVar);
                         $popupStatement = XenForo_Template_Compiler_Tag_Admin_Popup::compilePopup($compiler, $child['attributes'], $child['children'], $options, 'div', 'Left');
                         $statement->addStatement($compiler->getOutputVarInitializer() . $popupStatement->getFullStatements($tempVar));
                         $popups[] = '$' . $tempVar;
                         $tempVars[] = '$' . $tempVar;
                         $compiler->setOutputVar($oldOutputVar);
                     } else {
                         if ($compiler->isSegmentNamedTag($child, 'beforelabel')) {
                             $data['beforelabel'] = $child['children'];
                         } else {
                             if ($compiler->isSegmentNamedTag($child, 'toggle')) {
                                 $data['toggle'] = $child['children'];
                             } else {
                                 if ($compiler->isSegmentNamedTag($child, 'toggletitle')) {
                                     $data['toggletitle'] = $child['children'];
                                 }
                             }
                         }
                     }
                 }
             }
         }
         /*else if ($compiler->isSegmentNamedTag($child, 'link'))
         			{
         				$tempVar = $compiler->getUniqueVar();
         
         				$oldOutputVar = $compiler->getOutputVar();
         				$compiler->setOutputVar($tempVar);
         
         				$linkStatement = XenForo_Template_Compiler_Tag_Admin_ListItemLink::compileLink(
         					$compiler, $child['attributes'], $child['children'], $options
         				);
         
         				$statement->addStatement(
         					$compiler->getOutputVarInitializer()
         					. $linkStatement->getFullStatements($tempVar)
         				);
         
         				$links[] = '$' . $tempVar;
         				$tempVars[] = '$' . $tempVar;
         
         				$compiler->setOutputVar($oldOutputVar);
         			}*/
     }
     if (!isset($data['label'])) {
         throw $compiler->getNewCompilerException(new XenForo_Phrase('list_items_must_specify_label'));
     }
     if (!isset($data['id'])) {
         throw $compiler->getNewCompilerException(new XenForo_Phrase('list_items_must_specify_an_id'));
     }
     $compiledData = $compiler->compileNamedParams($data, $options);
     if ($html) {
         $htmlCode = $compiler->compileIntoVariable($html, $htmlOutputVar, $options);
         $statement->addStatement($htmlCode);
         $compiledData['html'] = '$' . $htmlOutputVar;
         $tempVars[] = '$' . $htmlOutputVar;
     }
     $controlData = $compiler->buildNamedParamCode($compiledData);
     if ($popups) {
         $popupData = $compiler->buildNamedParamCode($popups);
     } else {
         $popupData = 'array()';
     }
     if ($links) {
         $linkData = $compiler->buildNamedParamCode($links);
     } else {
         $linkData = 'array()';
     }
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:forums,代码行数:101,代码来源:ListItem.php


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