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

/**
 * Smarty filelink field view function plugin
 *
 * Purpose:  Shows a file linke
 *
 * @param   array   $params     Parameters:
 *                              <ul>
 *                                  <li>value   string  Value to show</li>
 *                              </ul>
 * @param   object  &$smarty    The smarty object
 * @return  string  The field source
 */
function smarty_function_filelink(array $params, US_Smarty &$smarty)
{
    if (isset($params['row_id'])) {
        $row_id = $params['row_id'];
    } else {
        $row_id = false;
    }
    
    if (isset($params['item'])) {
        $item = $params['item'];
    } else {
        $item = null;
    }    
    
    if (isset($params['show_link_depending_on_item'])) {
        $show_link_depending_on_item = $params['show_link_depending_on_item'];
    } else {
        $show_link_depending_on_item = false;
    }    
    
    if (isset($params['value'])) {
        if (isset($params['type'])) {
            return filelink_html($params['value'], $params['type'], $row_id, $show_link_depending_on_item, $item);
        } else {
            return filelink_html($params['value'], 'file', $row_id, $show_link_depending_on_item, $item);
        }
    } else {
        return '';
    }
}
