<?php

/**
 * Smarty plugin.
 */

/**
 * Smarty {url} plugin.
 *
 * Type:     function<br>
 * Name:     url<br>
 * Purpose:  insert seo-friendly url
 *
 * @param array $params parameters
 *
 * @return string
 */
function smarty_function_url($params, &$smarty)
{
    $assign = getVal('assign', $params);

    if ($assign) {
        unset($params['assign']);
    }

    $url = createScriptURL($params);

    if ($assign) {
        $smarty->assign($assign, $url);

        return '';
    }

    if (isset($params['ESCAPE'])) {
        return $url;
    }

    return htmlspecialchars($url, ENT_QUOTES);
}
