<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     function.url.php
 * Type:     function
 * Name:     assign
 * Purpose:  assign a value to a template variable
 * -------------------------------------------------------------
 */
use core\url;

function smarty_function_url($params, Smarty_Internal_Template $template) {
	$mode = isset($params["mode"]) ? trim(stripslashes($params["mode"])) : "";
	$area = isset($params["area"]) ? trim(stripslashes($params["area"])) : false;
	$controller = isset($params["controller"]) ? trim(stripslashes($params["controller"])) : "";
	$action = isset($params["action"]) ? trim(stripslashes($params["action"])) : "index";
	$id = isset($params["id"]) ? trim(stripslashes($params["id"])) : "";

	switch($mode) {
		case "root":
			return url::root();
		case "host":
			return url::host();
	}

	return url::action($controller, $action, $id, $area);
}
?>