From 76d501c6f2494dfe9a29c5805ff8cbcc9bb54383 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Tue, 30 Jul 2013 20:26:39 +0300 Subject: [PATCH] better url template tag. no need to wrap parameters into array --- ipf/template/tag/url.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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); + } } } -- 2.49.0