本文整理汇总了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 '';
}
}
示例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;
}
示例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()';
}
//.........这里部分代码省略.........