本文整理汇总了PHP中XenForo_Template_Compiler::parseConditionExpression方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Template_Compiler::parseConditionExpression方法的具体用法?PHP XenForo_Template_Compiler::parseConditionExpression怎么用?PHP XenForo_Template_Compiler::parseConditionExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Template_Compiler
的用法示例。
在下文中一共展示了XenForo_Template_Compiler::parseConditionExpression方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Compiles the function call.
*
* @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)
{
$argc = count($arguments);
if ($argc != 1) {
throw $compiler->getNewCompilerArgumentException();
}
$condition = $compiler->parseConditionExpression($arguments[0], $options);
$true = $function == 'checked' ? 'checked="checked"' : 'selected="selected"';
return '(' . $condition . ' ? \' ' . $true . '\' : \'\')';
}
示例2: compile
/**
* Compile the var named in the first argument and return PHP code to access and escape 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();
}
$compileOptions = array_merge($options, array('varEscape' => false));
if (!empty($arguments[1])) {
$doubleEncode = $compiler->parseConditionExpression($arguments[1], $options);
} else {
$doubleEncode = 'true';
}
return 'htmlspecialchars(' . $compiler->compileAndCombineSegments($arguments[0], $compileOptions) . ', ENT_QUOTES, \'UTF-8\', ' . $doubleEncode . ')';
}
示例3: compile
/**
* Compile the var named in the first argument and return PHP code to access and escape 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();
}
$compileOptions = array_merge($options, array('varEscape' => false));
if (!empty($arguments[1])) {
$doubleEncode = $compiler->parseConditionExpression($arguments[1], $options);
} else {
$doubleEncode = 'true';
}
// note: ISO-8859-1 is fine since we use UTF-8 and are only replacing basic chars
return 'htmlspecialchars(' . $compiler->compileAndCombineSegments($arguments[0], $compileOptions) . ', ENT_COMPAT, \'ISO-8859-1\', ' . $doubleEncode . ')';
}
示例4: compile
/**
* Compiles the function call.
*
* @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)
{
$argc = count($arguments);
if ($argc != 2 && $argc != 3) {
throw $compiler->getNewCompilerArgumentException();
}
$condition = $compiler->parseConditionExpression($arguments[0], $options);
$true = $compiler->compileAndCombineSegments($arguments[1], $options);
if (!isset($arguments[2])) {
$arguments[2] = '';
}
$false = $compiler->compileAndCombineSegments($arguments[2], $options);
return '(' . $condition . ' ? (' . $true . ') : (' . $false . '))';
}
示例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)
{
// user array
if (!empty($attributes['user'])) {
$user = $compiler->compileVarRef($attributes['user'], $options);
} else {
throw $compiler->getNewCompilerException(new XenForo_Phrase('missing_attribute_x_for_tag_y', array('attribute' => 'user', 'tag' => 'avatar')));
}
// avatar image mode (span or img)
if (isset($attributes['img'])) {
$img = $compiler->parseConditionExpression($attributes['img'], $options);
} else {
$img = 'false';
}
return 'XenForo_Template_Helper_Core::callHelper(\'avatarhtml\', array(' . $user . ',' . $img . ',' . $compiler->getNamedParamsAsPhpCode($attributes, $options, array('code')) . ',' . $compiler->compileAndCombineSegments($children, $options) . '))';
}
示例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)
{
// user array
if (!empty($attributes['user'])) {
$user = $compiler->compileVarRef($attributes['user'], $options);
unset($attributes['user']);
} else {
throw $compiler->getNewCompilerException(new XenForo_Phrase('missing_x_attribute_for_y_tag', array('attribute' => 'user', 'tag' => 'username')));
}
if (!empty($attributes['rich'])) {
$rich = $compiler->parseConditionExpression($attributes['rich'], $options);
} else {
$rich = 'false';
}
unset($attributes['rich']);
return 'XenForo_Template_Helper_Core::userNameHtml(' . $user . ',' . $compiler->compileAndCombineSegments($children, $options) . ',' . $rich . ',' . $compiler->getNamedParamsAsPhpCode($attributes, $options, array('code')) . ')';
}