/library/XenForo/Template/Compiler/Function/UrlEncode.php
https://github.com/hanguyenhuu/DTUI_201105 · PHP · 30 lines · 12 code · 2 blank · 16 comment · 2 complexity · c4f0818454c28c9466232dad5857eb32 MD5 · raw file
- <?php
- /**
- * Class to handle compiling template function calls for "urlencode". This function
- * uses URL encoding instead of HTML escaping on the named variable reference.
- *
- * @package XenForo_Template
- */
- class XenForo_Template_Compiler_Function_UrlEncode implements XenForo_Template_Compiler_Function_Interface
- {
- /**
- * 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))) . ')';
- }
- }