/template_engines_bench/libs/smarty-light/src/plugins/function.urlencode.php
PHP | 27 lines | 18 code | 1 blank | 8 comment | 5 complexity | e5c4c34f371243ba2e5c4f06215495bb MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1
- <?php
- /**
- * Smarty-Light urlencode modifier plugin
- *
- * Type: modifier
- * Name: urlencode
- * Purpose: urlencode vars (only if they were assigned/defined) function
- * Author: axel
- */
- function tpl_modifier_urlencode($data) {
- if (is_array($data) && function_exists("http_build_query")) {
- return http_build_query($data);
- } else {
- return urlencode($data)
- }
- $_args = explode( ",", $params["vars"] );
- $url = array();
- foreach($_args as $val) {
- $var = $tpl->get_vars( trim( $val ) );
- if( $var != null ) {
- $url[ $val ] = $var;
- }
- }
- return http_build_query($url);
- }
- ?>