Example #1
0
 /**
  * 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')) . ')';
 }
Example #2
0
 /**
  * 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)
 {
     $controlOptions = $compiler->getNamedAttributes($attributes, array('save', 'name', 'reset', 'savekey', 'saveclass', 'resetkey', 'resetclass', 'explain'));
     $controlOptions = $compiler->getNamedParamsAsPhpCode($controlOptions, $options);
     $childOutput = $compiler->compileIntoVariable($children, $submitVar, $options);
     $statement = $compiler->getNewRawStatement();
     $statement->addStatement($childOutput);
     $statement->addStatement('$' . $compiler->getOutputVar() . ' .= XenForo_Template_Helper_Admin::submitUnit($' . $submitVar . ', ' . $controlOptions . ");\n" . 'unset($' . $submitVar . ");\n");
     return $statement;
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * 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 (!isset($attributes['action'])) {
         throw $compiler->getNewCompilerException(new XenForo_Phrase('form_tags_must_specify_an_action'));
     }
     $rowOptions = $compiler->getNamedParamsAsPhpCode($attributes, $options, array('upload'));
     $childOutput = $compiler->compileIntoVariable($children, $formVar, $options);
     $statement = $compiler->getNewRawStatement();
     $statement->addStatement($childOutput);
     $statement->addStatement('$' . $compiler->getOutputVar() . ' .= XenForo_Template_Helper_Admin::form($' . $formVar . ', ' . $rowOptions . ");\n" . 'unset($' . $formVar . ");\n");
     return $statement;
 }
Example #5
0
 /**
  * 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')) . '))';
 }
Example #6
0
 /**
  * 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) . '))';
 }
Example #7
0
 /**
  * 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')) . ')';
 }
Example #8
0
 /**
  * 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 < 4) {
         throw $compiler->getNewCompilerArgumentException();
     }
     $perPage = array_shift($arguments);
     $totalItems = array_shift($arguments);
     $page = array_shift($arguments);
     $linkType = array_shift($arguments);
     $data = 'false';
     if (isset($arguments[0])) {
         $dataRef = array_shift($arguments);
         $data = $compiler->compileAndCombineSegments($dataRef, array_merge($options, array('varEscape' => false)));
     }
     $params = $compiler->getNamedParamsAsPhpCode($compiler->parseNamedArguments($arguments), array_merge($options, array('varEscape' => false)));
     $phpFunction = $function == 'adminpagenav' ? 'adminPageNav' : 'pageNav';
     return 'XenForo_Template_Helper_Core::' . $phpFunction . '(' . $compiler->compileAndCombineSegments($perPage, $options) . ', ' . $compiler->compileAndCombineSegments($totalItems, $options) . ', ' . $compiler->compileAndCombineSegments($page, $options) . ', ' . $compiler->compileAndCombineSegments($linkType, $options) . ', ' . $data . ', ' . $params . ')';
 }
Example #9
0
 /**
  * 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();
     }
     $type = array_shift($arguments);
     $data = 'false';
     if (isset($arguments[0])) {
         $dataRef = array_shift($arguments);
         $data = $compiler->compileAndCombineSegments($dataRef, array_merge($options, array('varEscape' => false)));
     }
     $params = $compiler->getNamedParamsAsPhpCode($compiler->parseNamedArguments($arguments), array_merge($options, array('varEscape' => false)));
     $phpFunction = $function == 'adminlink' ? 'adminLink' : 'link';
     if ($options['varEscape'] != 'htmlspecialchars') {
         $varEscapeParam = ', ' . ($options['varEscape'] ? "'{$options['varEscape']}'" : 'false');
     } else {
         $varEscapeParam = '';
     }
     return 'XenForo_Template_Helper_Core::' . $phpFunction . "(" . $compiler->compileAndCombineSegments($type, $options) . ', ' . $data . ', ' . $params . $varEscapeParam . ')';
 }
Example #10
0
 /**
  * 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)
 {
     $params = $compiler->getNamedParamsAsPhpCode($compiler->parseNamedArguments($arguments), array_merge($options, array('varEscape' => false)));
     return $params;
 }