<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
function smarty_function_url($params, $template)
{
	$action=empty($params['action'])?'':$params['action'];
	$type=empty($params['type'])?'':$params['type'];
	$href=empty($params['href'])?'':$params['href'];
	$redirect=empty($params['redirect'])?'':$params['redirect'];
	$token=isset($params['token'])?User::i()->token:false;
	unset($params['action'], $params['type'], $params['href'], $params['redirect'], $params['token']);
	
	foreach ($params as $key => $val) {
		if ($var_key=intval(str_replace('var', '', $key))) {
			unset($params[$key]);
			$params[($var_key-1)]=$val;
		}
	}
	
	echo call_user_func_array(
		array('Url', 'create'),
		array($params, $action, $type, $href, $redirect, $token)
	);
}
