<?php
/**
 * Smarty plugin
 *
 * @category Smarty
 * @license /_licenses/untermStrich/agb_normal.pdf
 * @author Christian Koller
 * @copyright 2009 untermStrich
 * @package Smarty
 * @subpackage plugins
 * @version $Id$
*/

/**
 * Smarty {site_url} function plugin
 *
 * @param   string  $params     Parameters:
 *                              <ul>
 *                                  <li>url     string  Value to show</li>
 *                                  <li>webcal  boolean Use webcal:</li>
 *                                  <li>https   boolean Use https:</li>
 *                              </ul>
 * @param   object  &$smarty    The smarty object
 * @return   string
 */
function smarty_function_site_url($params, US_Smarty &$smarty)
{
    if (!isset($params['url'])) {
        return site_url();
    } else {
        if (isset($params['webcal'])) {
            return str_ireplace(array('http:', 'https:'), 'webcal:', site_url($params['url']));
        } elseif (isset($params['https'])) {
            return str_ireplace('http:', 'https:', site_url($params['url']));
        } else {
            return site_url($params['url']);
        }
    }
}

/* End of function.site_url.php */