當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XenForo_Template_Compiler::parseConditionExpression方法代碼示例

本文整理匯總了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 . '\' : \'\')';
 }
開發者ID:namgiangle90,項目名稱:tokyobaito,代碼行數:20,代碼來源:CheckedSelected.php

示例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 . ')';
 }
開發者ID:Sywooch,項目名稱:forums,代碼行數:23,代碼來源:Escape.php

示例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 . ')';
 }
開發者ID:hahuunguyen,項目名稱:DTUI_201105,代碼行數:24,代碼來源:Escape.php

示例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 . '))';
 }
開發者ID:Sywooch,項目名稱:forums,代碼行數:24,代碼來源: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)
 {
     // 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) . '))';
 }
開發者ID:Sywooch,項目名稱:forums,代碼行數:27,代碼來源:Avatar.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)
 {
     // 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')) . ')';
 }
開發者ID:hahuunguyen,項目名稱:DTUI_201105,代碼行數:28,代碼來源:Username.php


注:本文中的XenForo_Template_Compiler::parseConditionExpression方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。