PageRenderTime 66ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/template_engines_bench/libs/smarty-light/src/plugins/function.urlencode.php

https://github.com/limb-php-framework/limb-tools
PHP | 27 lines | 18 code | 1 blank | 8 comment | 5 complexity | e5c4c34f371243ba2e5c4f06215495bb MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Smarty-Light urlencode modifier plugin
  4. *
  5. * Type: modifier
  6. * Name: urlencode
  7. * Purpose: urlencode vars (only if they were assigned/defined) function
  8. * Author: axel
  9. */
  10. function tpl_modifier_urlencode($data) {
  11. if (is_array($data) && function_exists("http_build_query")) {
  12. return http_build_query($data);
  13. } else {
  14. return urlencode($data)
  15. }
  16. $_args = explode( ",", $params["vars"] );
  17. $url = array();
  18. foreach($_args as $val) {
  19. $var = $tpl->get_vars( trim( $val ) );
  20. if( $var != null ) {
  21. $url[ $val ] = $var;
  22. }
  23. }
  24. return http_build_query($url);
  25. }
  26. ?>