/**
 * Smarty {product_info_link} function plugin
 *
 * Type:     function<br>
 * Name:     product_info_link<br>
 * Date:     Aug 24, 2004<br>
 * Purpose:  URL for the products info<br>
 * Input:<br>
 *         - products_id
 *
 * Examples: <{product_info_link products_id=17}>
 * Output:   http:// ... index.php?page=product_info&amp;products_id=17
 * @author   r23 <*****@*****.**>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_html_href_link()
 */
function smarty_function_product_info_link($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('function', 'html_href_link');
    $aPages = oos_get_pages();
    $result = array();
    $link_params = array();
    $link_params = array('page' => $aPages['product_info']);
    if (is_array($params)) {
        $result = array_merge($link_params, $params);
    } else {
        $smarty->trigger_error("products_info_link: extra attribute '{$params}' must an array", E_USER_NOTICE);
    }
    return smarty_function_html_href_link($result, $smarty);
}
/**
 * Smarty {categories_link} function plugin
 *
 * Type:     function<br>
 * Name:     categories_link<br>
 * Date:     Oct 27, 2008<br>
 * Purpose:  URL for the categorie info<br>
 * Input:<br>
 *         - categories
 *
 * Examples: {categories_link categories=17}
 * Output:   http:// ... index.php?mp=mp&amp;file=shop&amp;categories=17
 * @author   r23 <*****@*****.**>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_html_href_link()
 */
function smarty_function_categories_link($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('function', 'html_href_link');
    $aModules = oos_get_modules();
    $aFilename = oos_get_filename();
    $result = array();
    $link_params = array();
    $link_params = array('modul' => $aModules['main'], 'file' => $aFilename['shop']);
    if (is_array($params)) {
        $result = array_merge($link_params, $params);
    } else {
        $smarty->trigger_error("categories_link: extra attribute '{$params}' must an array", E_USER_NOTICE);
    }
    return smarty_function_html_href_link($result, $smarty);
}
/**
 * Smarty {categories_link} function plugin
 *
 * Type:     function<br>
 * Name:     categories_link<br>
 * Date:     Oct 27, 2008<br>
 * Purpose:  URL for the categorie info<br>
 * Input:<br>
 *         - categories
 *
 * Examples: {categories_link categories=17}
 * Output:   http:// ... index.php?page=shop&amp;categories=17
 * @author   r23 <*****@*****.**>
 * @version  1.0
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_html_href_link()
 */
function smarty_function_categories_link($params, &$smarty)
{

  MyOOS_CoreApi::requireOnce('lib/smarty-plugins/myoos/function.html_href_link.php');

  $aPages = oos_get_pages();

  $result = array();
  $link_params = array();
  $link_params = array('page' => $aPages['shop']);

  if (is_array($params)) {
    $result = array_merge($link_params, $params);
  } else {
    $smarty->trigger_error("categories_link: extra attribute '$params' must an array", E_USER_NOTICE);
  }

  return smarty_function_html_href_link($result, $smarty);

}
/**
 * Smarty {tooltip} function plugin
 *
 * Type:     function<br>
 * Name:     tooltip<br>
 * Purpose:  make text pop up in windows via wz_tooltip
 * Author:   r23 <info at r23 dot de>
 * @param array
 * @param Smarty
 * @return string
 */
function smarty_function_tooltip($params, &$smarty)
{
    require_once $smarty->_get_plugin_filepath('function', 'html_href_link');
    $aPages = oos_get_pages();
    $basedir = OOS_IMAGES;
    $height = SMALL_IMAGE_HEIGHT;
    $width = SMALL_IMAGE_WIDTH;
    $align = 'right';
    $image = '';
    $sLanguage = oos_var_prep_for_os($_SESSION['language']);
    foreach ($params as $_key => $_val) {
        switch ($_key) {
            case 'image':
            case 'height':
            case 'width':
            case 'basedir':
            case 'align':
            case 'products_description':
            case 'products_id':
                ${$_key} = (string) $_val;
                break;
            default:
                $smarty->trigger_error("[tooltip] unknown parameter {$_key}", E_USER_WARNING);
                break;
        }
    }
    $image = $basedir . $image;
    if ((empty($image) || $image == OOS_IMAGES) && IMAGE_REQUIRED == '0') {
        return false;
    }
    if ((empty($image) || $image == OOS_IMAGES) && IMAGE_REQUIRED == '1') {
        if (is_readable(OOS_ABSOLUTE_PATH . OOS_IMAGES . 'no_picture_' . $sLanguage . '.gif')) {
            $image = OOS_IMAGES . 'no_picture_' . $sLanguage . '.gif';
        } elseif (is_readable(OOS_ABSOLUTE_PATH . OOS_IMAGES . 'no_picture.gif')) {
            $image = OOS_IMAGES . 'no_picture.gif';
        } else {
            return false;
        }
        $image_size = @getimagesize($image);
        $width = $image_size[0];
        $height = $image_size[1];
    } elseif (CONFIG_CALCULATE_IMAGE_SIZE == '1' && (empty($width) || empty($height))) {
        if (is_readable(OOS_ABSOLUTE_PATH . $image)) {
            $image_size = @getimagesize($image);
            if (empty($width) && !empty($height)) {
                $ratio = $height / $image_size[1];
                $width = $image_size[0] * $ratio;
            } elseif (!empty($width) && empty($height)) {
                $ratio = $width / $image_size[0];
                $height = $image_size[1] * $ratio;
            } elseif (empty($width) && empty($height)) {
                $width = $image_size[0];
                $height = $image_size[1];
            }
        } elseif (IMAGE_REQUIRED == '1') {
            if (is_readable(OOS_ABSOLUTE_PATH . OOS_IMAGES . 'no_picture_' . $sLanguage . '.gif')) {
                $image = OOS_IMAGES . 'no_picture_' . $sLanguage . '.gif';
            } elseif (is_readable(OOS_ABSOLUTE_PATH . OOS_IMAGES . 'no_picture.gif')) {
                $image = OOS_IMAGES . 'no_picture.gif';
            } else {
                return false;
            }
            $image_size = @getimagesize($image);
            $width = $image_size[0];
            $height = $image_size[1];
        } else {
            return false;
        }
    }
    $image = '<img src=' . $image . ' align=' . $align . ' width=' . $width . ' height=' . $height . '>';
    $link_params = array();
    $link_params = array('page' => $aPages['product_info'], 'products_id' => $params['products_id']);
    $link = smarty_function_html_href_link($link_params, $smarty);
    $products_description = strip_tags($products_description);
    $products_description = preg_replace(array("!'!", "![\r\n]!"), array("\\'", '\\r'), $products_description);
    $products_description = str_replace('"', ' ', $products_description);
    return '<a onmouseover="Tip(\'' . $image . ' ' . $products_description . '\', WIDTH, 200)" onmouseout="UnTip()" href="' . $link . '" target="_top">';
}