PageRenderTime 40ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.1, GPL-2.0, BSD-3-Clause
  1. <?php
  2. /**
  3. * Class to handle compiling template function calls for "urlencode". This function
  4. * uses URL encoding instead of HTML escaping on the named variable reference.
  5. *
  6. * @package XenForo_Template
  7. */
  8. class XenForo_Template_Compiler_Function_UrlEncode implements XenForo_Template_Compiler_Function_Interface
  9. {
  10. /**
  11. * Compile the var named in the first argument and return PHP code to access and urlencode it.
  12. *
  13. * @param XenForo_Template_Compiler The invoking compiler
  14. * @param string Name of the function called
  15. * @param array Arguments to the function (should have at least 1)
  16. * @param array Compilation options
  17. *
  18. * @return string
  19. */
  20. public function compile(XenForo_Template_Compiler $compiler, $function, array $arguments, array $options)
  21. {
  22. if (count($arguments) != 1)
  23. {
  24. throw $compiler->getNewCompilerArgumentException();
  25. }
  26. return 'urlencode(' . $compiler->compileAndCombineSegments($arguments[0], array_merge($options, array('varEscape' => false))) . ')';
  27. }
  28. }