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


PHP XenForo_Template_Compiler::isSegmentNamedTag方法代码示例

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


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

示例1: 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)
 {
     if ($tag == 'breadcrumb') {
         throw $compiler->getNewCompilerException(new XenForo_Phrase('breadcrumb_tag_must_be_within_navigation_tag'));
     }
     if (empty($options['allowRawStatements'])) {
         throw $compiler->getNewCompilerException(new XenForo_Phrase('x_tags_only_used_where_full_statements_allowed', array('tag' => 'navigation')));
     }
     $rawStatement = $compiler->getNewRawStatement();
     $rawStatement->addStatement("\$__extraData['navigation'] = array();\n");
     foreach ($children as $child) {
         if ($compiler->isSegmentNamedTag($child, 'breadcrumb')) {
             if (isset($child['attributes']['source'])) {
                 $sourceVar = $compiler->compileVarRef($child['attributes']['source'], $options);
                 $rawStatement->addStatement('$__extraData[\'navigation\'] = XenForo_Template_Helper_Core::appendBreadCrumbs($__extraData[\'navigation\'], ' . $sourceVar . ");\n");
             } else {
                 $parts = array();
                 foreach ($child['attributes'] as $name => $value) {
                     $parts[] = "'" . $compiler->escapeSingleQuotedString($name) . "' => " . $compiler->compileAndCombineSegments($value, $options);
                 }
                 $parts[] = "'value' => " . $compiler->compileAndCombineSegments($child['children'], $options);
                 $rawStatement->addStatement('$__extraData[\'navigation\'][] = array(' . implode(', ', $parts) . ");\n");
             }
         } else {
             if (is_string($child) && trim($child) === '') {
                 // whitespace -- ignore it
             } else {
                 throw $compiler->getNewCompilerException(new XenForo_Phrase('invalid_data_found_in_navigation_tag'), $child);
             }
         }
     }
     return $rawStatement;
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:44,代码来源:Navigation.php

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

示例3: _compileChoiceChild

 protected function _compileChoiceChild($newOutputVar, $child, XenForo_Template_Compiler $compiler, array $options)
 {
     if ($compiler->isSegmentNamedTag($child, 'foreach')) {
         $inner = '';
         foreach ($child['children'] as $grandChild) {
             $inner .= $this->_compileChoiceChild($newOutputVar, $grandChild, $compiler, $options);
         }
         $statement = XenForo_Template_Compiler_Tag_Foreach::compileForeach($inner, $compiler, $child['attributes'], $options);
         return $statement->getFullStatements($newOutputVar);
     } else {
         if ($compiler->isSegmentNamedTag($child, 'option')) {
             $choice = $compiler->getNamedAttributes($child['attributes'], array('label', 'name', 'value', 'selected', 'hint', 'id', 'class', 'inputclass', 'title', 'depth', 'disabled', 'optdisabled', 'unselectable'));
             $childrenAsLabel = isset($choice['label']) ? false : true;
             // if label attribute, then assume children as "special"
             $foundOther = false;
             $disabledControls = array();
             foreach ($child['children'] as $optionChild) {
                 if (!is_array($optionChild) || !isset($optionChild['type']) || $optionChild['type'] != 'TAG') {
                     continue;
                 }
                 $optionChildName = strtolower($optionChild['name']);
                 switch ($optionChildName) {
                     case 'label':
                     case 'hint':
                         $choice[$optionChildName] = $optionChild['children'];
                         $childrenAsLabel = false;
                         break;
                     case 'checkbox':
                     case 'combobox':
                     case 'password':
                     case 'radio':
                     case 'select':
                     case 'spinbox':
                     case 'textbox':
                     case 'upload':
                         $disabledControls[] = $optionChild;
                         $childrenAsLabel = false;
                         break;
                     case 'disabled':
                         $disabledControls[] = $optionChild['children'];
                         $childrenAsLabel = false;
                         break;
                     default:
                         $foundOther = $optionChild;
                 }
             }
             if (!isset($choice['label'])) {
                 if (!$childrenAsLabel) {
                     throw $compiler->getNewCompilerException(new XenForo_Phrase('missing_label_for_option_tag'), $child);
                 }
                 $choice['label'] = $child['children'];
             }
             $data = $this->_getDataAttributes($compiler, $child['attributes']);
             if ($data) {
                 $choice['_data'] = $data;
             }
             if (!$childrenAsLabel && $foundOther) {
                 // have special tags as child and found unexpected
                 throw $compiler->getNewCompilerException(new XenForo_Phrase('found_unexpected_tag_x_as_disabled_control', array('tag' => $foundOther['name'])), $foundOther);
             }
             $compiled = $compiler->compileNamedParams($choice, $options, array('selected'));
             $disabledCode = '';
             if ($disabledControls) {
                 $compiled['disabled'] = array();
                 foreach ($disabledControls as $disabled) {
                     $disabledCode .= $compiler->compileIntoVariable($disabled, $disabledOutputVar, $options, true);
                     $compiled['disabled'][] = '$' . $disabledOutputVar;
                 }
             }
             $additionalCode = $disabledCode . '$' . $newOutputVar . '[] = ' . $compiler->buildNamedParamCode($compiled) . ";\n";
             if (!empty($compiled['disabled'])) {
                 $additionalCode .= 'unset(' . implode(', ', $compiled['disabled']) . ");\n";
             }
             if (!empty($child['attributes']['displayif'])) {
                 $condition = $compiler->parseConditionExpression($child['attributes']['displayif'], $options);
                 return 'if ' . $condition . "\n{\n" . $additionalCode . "}\n";
             } else {
                 return $additionalCode;
             }
         } else {
             if ($compiler->isSegmentNamedTag($child, 'options')) {
                 if (!isset($child['attributes']['source'])) {
                     throw $compiler->getNewCompilerException(new XenForo_Phrase('options_tag_must_have_source_attribute'), $child);
                 }
                 $sourceVar = $compiler->compileVarRef($child['attributes']['source'], array_merge($options, array('varEscape' => false)));
                 if (!empty($child['attributes']['raw'])) {
                     $raw = $compiler->parseConditionExpression($child['attributes']['raw'], $options);
                 } else {
                     $raw = 'false';
                 }
                 return '$' . $newOutputVar . ' = XenForo_Template_Helper_Admin::mergeOptionArrays(' . '$' . $newOutputVar . ', ' . $sourceVar . ', ' . $raw . ");\n";
             } else {
                 if ($compiler->isSegmentNamedTag($child, 'optgroup')) {
                     if (!isset($child['attributes']['label'])) {
                         throw $compiler->getNewCompilerException(new XenForo_Phrase('optgroups_must_have_label'), $child);
                     }
                     $label = $compiler->compileAndCombineSegments($child['attributes']['label']);
                     $groupVar = null;
                     // changed by next line
                     $code = $this->_getChoicesCode($child['children'], $compiler, $options, $groupVar);
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:forums,代码行数:101,代码来源:Abstract.php

示例4: 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)
 {
     if ($tag == 'contentcheck') {
         throw $compiler->getNewCompilerException(new XenForo_Phrase('contentcheck_tag_found_that_was_not_direct_child_of_an_if_tag_with'));
     } else {
         if ($tag != 'if') {
             throw $compiler->getNewCompilerException(new XenForo_Phrase('else_or_else_if_tag_not_found_that_was_not_direct_child_of_an_if_tag'));
         }
     }
     if (empty($options['allowRawStatements'])) {
         throw $compiler->getNewCompilerException(new XenForo_Phrase('x_tags_only_used_where_full_statements_allowed', array('tag' => 'if')));
     }
     $parts = array(0 => array('is' => isset($attributes['is']) ? $attributes['is'] : '', 'hascontent' => isset($attributes['hascontent']) ? $attributes['hascontent'] : '', 'segments' => array(), 'line' => $compiler->getLineNumber()));
     $partKey = 0;
     $haveElse = false;
     foreach ($children as $child) {
         if ($compiler->isSegmentNamedTag($child, 'elseif')) {
             if ($haveElse) {
                 throw $compiler->getNewCompilerException(new XenForo_Phrase('else_if_tag_found_after_else_tag'), $child);
             }
             if (!empty($child['children'])) {
                 throw $compiler->getNewCompilerException(new XenForo_Phrase('else_if_tags_may_not_have_children'), $child);
             }
             $partKey++;
             $parts[$partKey] = array('is' => isset($child['attributes']['is']) ? $child['attributes']['is'] : '', 'hascontent' => isset($child['attributes']['hascontent']) ? $child['attributes']['hascontent'] : '', 'segments' => array(), 'line' => $child['line']);
         } else {
             if ($compiler->isSegmentNamedTag($child, 'else')) {
                 if (!empty($child['children'])) {
                     throw $compiler->getNewCompilerException(new XenForo_Phrase('else_tags_may_not_have_children'), $child);
                 }
                 if ($haveElse) {
                     throw $compiler->getNewCompilerException(new XenForo_Phrase('only_one_else_tag_allowed_per_if_tag'), $child);
                 }
                 $haveElse = true;
                 $partKey++;
                 $parts[$partKey] = array('else' => true, 'segments' => array(), 'line' => $child['line']);
             } else {
                 $parts[$partKey]['segments'][] = $child;
             }
         }
     }
     $ifStatement = $compiler->getNewRawStatement();
     $prependCheckStatements = $compiler->getNewRawStatement();
     $allCheckVars = array();
     foreach ($parts as $partKey => $part) {
         $conditionType = $partKey == 0 ? 'if' : 'else if';
         if (!empty($part['is'])) {
             $condition = $compiler->parseConditionExpression($part['is'], $options);
             $ifStatement->addStatement($conditionType . ' ' . $condition . "\n{\n")->addStatement($compiler->compileSegments($part['segments'], $options))->addStatement("}\n");
         } else {
             if (!empty($part['hascontent'])) {
                 $childStatement = $compiler->getNewStatementCollection();
                 $checkVars = array();
                 foreach ($part['segments'] as $segment) {
                     if ($compiler->isSegmentNamedTag($segment, 'contentcheck')) {
                         $prependCheckStatements->addStatement($compiler->compileIntoVariable($segment['children'], $checkVar, $options));
                         $childStatement->addStatement('$' . $checkVar);
                         $checkVars[] = $checkVar;
                         $allCheckVars[] = '$' . $checkVar;
                     } else {
                         $childStatement->addStatement($compiler->compileSegment($segment, $options));
                     }
                 }
                 if (!$checkVars) {
                     throw $compiler->getNewCompilerException(new XenForo_Phrase('cannot_have_content_checking_if_tag_without_contentcheck_part'), $part['line']);
                 }
                 $conditionParts = array();
                 foreach ($checkVars as $checkCondition) {
                     $conditionParts[] = 'trim($' . $checkCondition . ") !== ''";
                 }
                 $checkCond = implode(' || ', $conditionParts);
                 $ifStatement->addStatement("{$conditionType} ({$checkCond})\n{\n")->addStatement($childStatement)->addStatement("}\n");
             } else {
                 if (!empty($part['else'])) {
                     $ifStatement->addStatement("else\n{\n")->addStatement($compiler->compileSegments($part['segments'], $options))->addStatement("}\n");
                 } else {
                     throw $compiler->getNewCompilerException(new XenForo_Phrase('invalid_if_or_else_if_tag_missing_is_or_hascontent'), $part['line']);
                 }
             }
         }
     }
     $prependCheckStatements->addStatement($ifStatement);
     if ($allCheckVars) {
         $prependCheckStatements->addStatement("unset(" . implode(', ', $allCheckVars) . ");\n");
     }
     return $prependCheckStatements;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:98,代码来源:If.php

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

示例6: 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)
 {
     if (empty($options['allowRawStatements'])) {
         throw $compiler->getNewCompilerException(new XenForo_Phrase('x_tags_only_used_where_full_statements_allowed', array('tag' => 'include')));
     }
     if (empty($attributes['template']) || count($attributes['template']) != 1 || !is_string($attributes['template'][0])) {
         throw $compiler->getNewCompilerException(new XenForo_Phrase('invalid_template_include_specified'));
     }
     $include = $attributes['template'][0];
     $template = $compiler->includeParsedTemplate($include);
     $statement = $compiler->getNewRawStatement();
     $tempVars = array();
     $mapVars = array();
     foreach ($children as $child) {
         if ($compiler->isSegmentNamedTag($child, 'map')) {
             $childAttr = $child['attributes'];
             if (empty($childAttr['from']) || empty($childAttr['to'])) {
                 throw $compiler->getNewCompilerException(new XenForo_Phrase('included_template_variable_mappings_must_include_from_and_to_attributes'));
             }
             $from = $compiler->compileVarRef($childAttr['from'], $options);
             if (count($childAttr['to']) != 1 || !is_string($childAttr['to'][0])) {
                 throw $compiler->getNewCompilerException(new XenForo_Phrase('invalid_template_include_variable_mapping_specified'));
             }
             if (!preg_match('#^\\$([a-zA-Z_][a-zA-Z0-9_]*)$#', $childAttr['to'][0])) {
                 throw $compiler->getNewCompilerException(new XenForo_Phrase('invalid_template_include_variable_mapping_specified'));
             }
             // "from $outer" and "to $inner"; when processed (within inner template), need to map the other direction.
             $mapVars[substr($childAttr['to'][0], 1)] = substr($from, 1);
         } else {
             if ($compiler->isSegmentNamedTag($child, 'set')) {
                 // take var as "to" and compile into a temporary variable
                 $childAttr = $child['attributes'];
                 if (empty($childAttr['var'])) {
                     throw $compiler->getNewCompilerException(new XenForo_Phrase('included_template_variable_assignments_must_include_var_attribute'));
                 }
                 if (count($childAttr['var']) != 1 || !is_string($childAttr['var'][0])) {
                     throw $compiler->getNewCompilerException(new XenForo_Phrase('invalid_template_include_variable_assignment_specified'));
                 }
                 $mapRegex = '#^\\$([a-zA-Z_][a-zA-Z0-9_]*)$#';
                 if (!preg_match($mapRegex, $childAttr['var'][0])) {
                     throw $compiler->getNewCompilerException(new XenForo_Phrase('invalid_template_include_variable_assignment_specified'));
                 }
                 if (!empty($childAttr['value'])) {
                     if ($child['children']) {
                         throw $compiler->getNewCompilerException(new XenForo_Phrase('tag_contained_children_and_value_attribute'));
                     }
                     $value = $compiler->compileAndCombineSegments($childAttr['value'], array_merge($options, array('varEscape' => false)));
                     $setVar = $compiler->getUniqueVar();
                     $childOutput = '$' . $setVar . ' = ' . $value . ";\n";
                 } else {
                     $childOutput = $compiler->compileIntoVariable($child['children'], $setVar, $options);
                 }
                 $statement->addStatement($childOutput);
                 $mapVars[substr($childAttr['var'][0], 1)] = $setVar;
                 $tempVars[] = $setVar;
             }
         }
     }
     if ($template) {
         $oldMap = $compiler->getVariableMap();
         $compiler->setVariableMap($mapVars, true);
         $compiled = $compiler->compileIntoVariable($template, $var, $options);
         $tempVars[] = $var;
         $compiler->setVariableMap($oldMap);
         $statement->addStatement($compiled);
         $statement->addStatement('$' . $compiler->getOutputVar() . ' .= $' . $var . ";\n" . 'unset($' . implode(', $', $tempVars) . ");\n");
         return $statement;
     } else {
         return '';
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:82,代码来源:Include.php


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