/** * 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 . ')'; }
/** * 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 . ')'; }
/** * Compiles the phrase 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(); } $phraseName = $compiler->getArgumentLiteralValue(array_shift($arguments)); if ($phraseName === false) { throw $compiler->getNewCompilerException(new XenForo_Phrase('phrase_name_must_be_literal')); } $phraseValue = $compiler->getPhraseValue($phraseName); if ($phraseValue === false) { return "'" . $compiler->escapeSingleQuotedString($phraseName) . "'"; } $this->_params = $compiler->compileNamedParams($compiler->parseNamedArguments($arguments), $options); $phraseValueEscaped = $compiler->escapeSingleQuotedString($phraseValue); $phraseValueEscaped = preg_replace_callback('/\\{([a-z0-9_-]+)\\}/i', array($this, '_replaceParam'), $phraseValueEscaped); if ($phraseValueEscaped === '') { return ''; } $this->_params = array(); return "'" . $phraseValueEscaped . "'"; }
/** * 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; }