From: Andrey Kutejko Date: Tue, 30 Jul 2013 17:26:39 +0000 (+0300) Subject: better url template tag. no need to wrap parameters into array X-Git-Tag: 0.5~103 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=87043cab7b72503d0b96a8fd82e8f362e0f2bb74;p=ipf.git better url template tag. no need to wrap parameters into array --- diff --git a/ipf/template/tag/url.php b/ipf/template/tag/url.php index ec3509e..7619f9d 100644 --- a/ipf/template/tag/url.php +++ b/ipf/template/tag/url.php @@ -2,9 +2,22 @@ class IPF_Template_Tag_Url extends IPF_Template_Tag { - function start($view, $params=array(), $get_params=array()) + function start() { - echo IPF_HTTP_URL::urlForView($view, $params, $get_params); + $args = func_get_args(); + $count = count($args); + if ($count === 0) + throw new IPF_Exception('No view specified'); + + $view = array_shift($args); + + if ($count === 2 && is_array($args[0])) { + echo IPF_HTTP_URL::urlForView($view, $args[0]); + } elseif ($count === 3 && is_array($args[0]) && is_array($args[1])) { + echo IPF_HTTP_URL::urlForView($view, $args[0], $args[1]); + } else { + echo IPF_HTTP_URL::urlForView($view, $args); + } } }