本文整理汇总了PHP中XenForo_Template_Compiler类的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Template_Compiler类的具体用法?PHP XenForo_Template_Compiler怎么用?PHP XenForo_Template_Compiler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XenForo_Template_Compiler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 (empty($options['allowRawStatements'])) {
throw $compiler->getNewCompilerException(new XenForo_Phrase('x_tags_only_used_where_full_statements_allowed', array('tag' => 'callback')));
}
if (empty($attributes['class'])) {
throw $compiler->getNewCompilerException(new XenForo_Phrase('missing_attribute_x_for_tag_y', array('attribute' => 'class', 'tag' => 'callback')));
}
if (empty($attributes['method'])) {
throw $compiler->getNewCompilerException(new XenForo_Phrase('missing_attribute_x_for_tag_y', array('attribute' => 'method', 'tag' => 'callback')));
}
$noEscapeOptions = array_merge($options, array('varEscape' => false));
$class = $compiler->compileAndCombineSegments($attributes['class'], $noEscapeOptions);
$method = $compiler->compileAndCombineSegments($attributes['method'], $noEscapeOptions);
$compiled = $compiler->compileIntoVariable($children, $var, $options);
if (!empty($attributes['params'])) {
$params = $compiler->compileAndCombineSegments($attributes['params'], $noEscapeOptions);
} else {
$params = 'array()';
}
$statement = $compiler->getNewRawStatement();
$statement->addStatement($compiled);
$statement->addStatement('$' . $compiler->getOutputVar() . ' .= $this->callTemplateCallback(' . $class . ', ' . $method . ', $' . $var . ', ' . $params . ");\n" . 'unset($' . $var . ");\n");
return $statement;
}
开发者ID:Sywooch,项目名称:forums,代码行数:36,代码来源:Callback.php
示例2: compile
/**
* Compile the var named in the first argument and return PHP code to access it raw.
*
* @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();
}
return $compiler->compileVarRef($arguments[0], $options);
}
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:17,代码来源:Raw.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)
{
if (empty($attributes['template'])) {
throw $compiler->getNewCompilerException(new XenForo_Phrase('missing_attribute_x_for_tag_y', array('attribute' => 'template', 'tag' => 'edithint')));
}
return '';
}
开发者ID:Sywooch,项目名称:forums,代码行数:18,代码来源:EditHint.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 (empty($attributes['url'])) {
throw $compiler->getNewCompilerException(new XenForo_Phrase('missing_attribute_x_for_tag_y', array('attribute' => 'url', 'tag' => 'formaction')));
}
return 'XenForo_Template_Helper_Core::getHiddenInputsFromUrl(' . $compiler->compileAndCombineSegments($attributes['url'], $options) . ')';
}
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:18,代码来源:FormAction.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)
{
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
示例6: compile
/**
* Compile the var named in the first argument and return PHP code to access and urlencode 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();
}
return 'urlencode(' . $compiler->compileAndCombineSegments($arguments[0], array_merge($options, array('varEscape' => false))) . ')';
}
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:17,代码来源:UrlEncode.php
示例7: 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();
}
return "XenForo_Template_Helper_Core::styleProperty(" . $compiler->compileAndCombineSegments($arguments[0], array_merge($options, array('varEscape' => false))) . ")";
}
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:17,代码来源:Property.php
示例8: parse
public static function parse($raw)
{
$compiler = new XenForo_Template_Compiler(sprintf('<xen:if is="%s">%s</xen:if>', $raw, md5($raw)));
$compiler->addFunctionHandler('helper', new WidgetFramework_Helper_Conditional_Function_Helper());
$parsed = $compiler->lexAndParse();
$compiler->setFollowExternal(false);
$parsed = $compiler->compileParsed($parsed, __CLASS__, 0, 0);
return $parsed;
}
开发者ID:maitandat1507,项目名称:bdWidgetFramework,代码行数:9,代码来源:Conditional.php
示例9: _renderTemplate
protected function _renderTemplate($template, array $params = array())
{
extract($params);
$compiler = new XenForo_Template_Compiler($template);
XenForo_Application::disablePhpErrorHandler();
@eval($compiler->compile());
XenForo_Application::enablePhpErrorHandler();
return htmlspecialchars_decode($__output, ENT_QUOTES);
}
开发者ID:Mirovinger,项目名称:xenforo-simple-forms,代码行数:9,代码来源:Form.php
示例10: 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($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' => 'follow')));
}
return 'XenForo_Template_Helper_Core::followHtml(' . $user . ',' . $compiler->getNamedParamsAsPhpCode($attributes, $options, array('code')) . ')';
}
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:20,代码来源:Follow.php
示例11: 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' => 'title')));
}
$var = '__extraData[\'title\']';
$childOutput = $compiler->compileIntoVariable($children, $var, $options, false);
return $compiler->getNewRawStatement($childOutput);
}
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:20,代码来源:Title.php
示例12: 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 . '\' : \'\')';
}
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:20,代码来源:CheckedSelected.php
示例13: 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' => 'require')));
}
$requirements = $compiler->getNamedAttributes($attributes, array('css', 'js'));
if (!$requirements) {
throw $compiler->getNewCompilerException(new XenForo_Phrase('require_tag_does_not_specify_any_known_types_css_or_js'));
}
if (isset($requirements['css'])) {
$css = $requirements['css'];
if (empty($css) || count($css) != 1 || !is_string($css[0])) {
throw $compiler->getNewCompilerException(new XenForo_Phrase('only_literal_css_templates_may_be_included_by_require_tag'));
}
if (substr($css[0], -4) != '.css') {
throw $compiler->getNewCompilerException(new XenForo_Phrase('all_required_css_templates_must_end_in_'));
}
$requirements['css'][0] = substr($css[0], 0, -4);
}
$statement = $compiler->getNewRawStatement();
foreach ($requirements as $attribute => $value) {
$statement->addStatement('$this->addRequiredExternal(\'' . $compiler->escapeSingleQuotedString($attribute) . '\', ' . $compiler->compileAndCombineSegments($value) . ");\n");
}
return $statement;
}
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:36,代码来源:Require.php
示例14: 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' => 'description')));
}
$rawStatement = $compiler->getNewRawStatement();
$rawStatement->addStatement("\$__extraData['pageDescription'] = " . $compiler->getNamedParamsAsPhpCode($attributes, $options, array('skipmeta')) . ";\n");
$var = '__extraData[\'pageDescription\'][\'content\']';
$rawStatement->addStatement($compiler->compileIntoVariable($children, $var, $options, false));
return $rawStatement;
}
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:22,代码来源:Description.php
示例15: 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 && $argc != 2) {
throw $compiler->getNewCompilerArgumentException();
}
if (empty($arguments[1])) {
$arguments[1] = '0';
}
return 'XenForo_Template_Helper_Core::numberFormat(' . $compiler->compileAndCombineSegments($arguments[0], array_merge($options, array('varEscape' => false))) . ', ' . $compiler->compileAndCombineSegments($arguments[1], array_merge($options, array('varEscape' => false))) . ')';
}
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:21,代码来源:Number.php
示例16: 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($attributes['time'])) {
$time = $compiler->compileVarRef($attributes['time'], $options);
} else {
if (!empty($children)) {
$time = $compiler->compileAndCombineSegments($children, $options);
} else {
throw $compiler->getNewCompilerException(new XenForo_Phrase('missing_attribute_x_for_tag_y', array('attribute' => 'time', 'tag' => 'datetime')));
}
}
return 'XenForo_Template_Helper_Core::callHelper(\'datetimehtml\', array(' . $time . ',' . $compiler->getNamedParamsAsPhpCode($attributes, $options, array('code')) . '))';
}
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:24,代码来源:DateTime.php
示例17: 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 . ')';
}
开发者ID:Sywooch,项目名称:forums,代码行数:23,代码来源:Escape.php
示例18: compile
/**
* Compile the var named in the first argument and return PHP code to access it raw.
*
* @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) > 2) {
throw $compiler->getNewCompilerArgumentException();
}
$compileOptions = array_merge($options, array('varEscape' => false));
$raw = $compiler->compileVarRef($arguments[0], $options);
if (empty($arguments[1])) {
return $raw;
} else {
return 'XenForo_Template_Helper_Core::rawCondition(' . $raw . ', ' . $compiler->compileAndCombineSegments($arguments[1], $compileOptions) . ')';
}
}
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:23,代码来源:Raw.php
示例19: 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' => 'set')));
}
if (empty($attributes['var'])) {
throw $compiler->getNewCompilerException(new XenForo_Phrase('missing_attribute_x_for_tag_y', array('attribute' => 'var', 'tag' => 'set')));
}
$var = $compiler->compileVarRef($attributes['var'], array_merge($options, array('disableVarMap' => true)));
$var = substr($var, 1);
// need to take off leading $
if (empty($children)) {
$children = null;
}
if (!empty($attributes['value'])) {
if ($children) {
throw $compiler->getNewCompilerException(new XenForo_Phrase('tag_contained_children_and_value_attribute'));
}
$value = $compiler->compileAndCombineSegments($attributes['value'], array_merge($options, array('varEscape' => false)));
$childOutput = '$' . $var . ' = ' . $value . ";\n";
} else {
$childOutput = $compiler->compileIntoVariable($children, $var, $options, false);
}
$statement = $compiler->getNewRawStatement();
$statement->addStatement($childOutput);
return $statement;
}
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:38,代码来源:Set.php
示例20: 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 . ')';
}
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:24,代码来源:Escape.php
注:本文中的XenForo_Template_Compiler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论