<?php
/******************************************************************************/
//                                                                            //
//                             Smarty plugin                                  //
//                            @package Smarty                                 //
//							 @subpackage plugins                              //
//                        http://life-style.uz/                               //
//                   produced by Life Style, life-style.uz                    //
//                                                                            //
/******************************************************************************/

use Mnv\Core\Config;

function smarty_function_logo($params, &$smarty)
{

    $link = (bool)fetch_getParam('link', $params, TRUE);
    $classLink = fetch_getParam('classLink', $params);
    $classImg = fetch_getParam('classImg', $params, '');
    $width = fetch_getParam('width', $params, '');
    $style = fetch_getParam('style', $params, '');
    $logoUrl = fetch_getParam('logoUrl', $params, '');

    $file = getLogoFile(SITE_ROOT.'/uploads/');
    if (empty($logoUrl)) {
        $logoUrl = !empty($file) ? SITE_URL . '/uploads/' . $file[0] : '';
    }

    if ($link) {
        $logo = '<a href="' . SITE_URL . '" class="' . $classLink . '"><img src="' . $logoUrl . '" alt="' . Config::getValue('website_name') .'"></a>';
    } else {
        $logo = '<img src="' . $logoUrl . '" class="' . $classImg . '" alt="' . Config::getValue('website_name') . '" width="'.$width.'" style="'. $style .'">';
    }

    return $logo;
}

?>