Пример #1
0
 protected function loadBanners()
 {
     global $APPLICATION, $USER;
     $this->arBanners = CAdvBanner::GetRandomArray($this->arParams["TYPE"], $this->arParams['QUANTITY']);
     $this->arResult["BANNERS"] = array();
     if (is_array($this->arBanners) && count($this->arBanners) > 0) {
         foreach ($this->arBanners as $key => $banner) {
             $templateName = $this->GetTemplateName();
             if ($banner["AD_TYPE"] == 'template') {
                 $templateProps = unserialize($banner["TEMPLATE"]);
                 $templateFiles = unserialize($banner["TEMPLATE_FILES"]);
                 if ($templateName == '.default' || $templateName == '') {
                     $templateName = $templateProps['NAME'];
                 }
                 if (empty($this->arResult['SIZE'])) {
                     $this->templateFiles = $templateFiles;
                     $this->arResult['SIZE'] = $this->getBannerSize();
                 }
                 if (count($templateProps['PROPS']) > 1) {
                     if (count($this->arResult["BANNERS"]) == 0) {
                         foreach ($templateProps['PROPS'] as $k => $v) {
                             ob_start();
                             $APPLICATION->IncludeComponent('bitrix:advertising.banner.view', $templateName, array('PROPS' => $v, 'FILES' => $templateFiles[$k], 'EXT_MODE' => $templateProps['MODE'], 'INDEX' => $this->bannerIndex, 'HEIGHT' => $this->arParams['HEIGHT'], 'CASUAL_PROPERTIES' => array('TYPE' => $banner['AD_TYPE'])), null, array('HIDE_ICONS' => 'Y'));
                             $strReturn = CAdvBanner::PrepareHTML(ob_get_contents(), $banner);
                             $strReturn = CAdvBanner::ReplaceURL($strReturn, $banner);
                             ob_end_clean();
                             $this->arResult["BANNERS"][] = $strReturn;
                             $this->bannerIndex++;
                         }
                         $this->arResult["BANNERS_PROPERTIES"][$key] = $banner;
                         CAdvBanner::FixShow($banner);
                         if ($USER->IsAuthorized() && $APPLICATION->GetShowIncludeAreas()) {
                             if (($arIcons = CAdvBanner::GetEditIcons($banner, $this->arParams["TYPE"], $this->getIncludeAreaIcons())) !== false) {
                                 $this->AddIncludeAreaIcons($arIcons);
                             }
                         }
                         break;
                     } else {
                         continue;
                     }
                 } else {
                     ob_start();
                     $APPLICATION->IncludeComponent('bitrix:advertising.banner.view', $templateName, array('PROPS' => $templateProps['PROPS'][0], 'FILES' => $templateFiles[0], 'EXT_MODE' => $templateProps['MODE'], 'INDEX' => $this->bannerIndex, 'HEIGHT' => $this->arParams['HEIGHT'], 'CASUAL_PROPERTIES' => array('TYPE' => $banner['AD_TYPE'])), null, array('HIDE_ICONS' => 'Y'));
                     $strReturn = CAdvBanner::PrepareHTML(ob_get_contents(), $banner);
                     $strReturn = CAdvBanner::ReplaceURL($strReturn, $banner);
                     ob_end_clean();
                     $this->arResult["BANNERS"][$key] = $strReturn;
                     $this->arResult["BANNERS_PROPERTIES"][$key] = $banner;
                     $this->bannerIndex++;
                     CAdvBanner::FixShow($banner);
                     if ($USER->IsAuthorized() && $APPLICATION->GetShowIncludeAreas()) {
                         if (($arIcons = CAdvBanner::GetEditIcons($banner, $this->arParams["TYPE"], $this->getIncludeAreaIcons())) !== false) {
                             $this->AddIncludeAreaIcons($arIcons);
                         }
                     }
                 }
             } else {
                 if ($banner["AD_TYPE"] == 'image' && ($templateName == 'bootstrap' || $templateName == 'jssor' || $templateName == 'nivo' || $templateName == 'parallax')) {
                     $strReturn = CAdvBanner::GetHTML($banner, $this->arParams["NOINDEX"] == "Y");
                     ob_start();
                     $APPLICATION->IncludeComponent('bitrix:advertising.banner.view', $templateName, array('PROPS' => array(), 'FILES' => array(), 'EXT_MODE' => 'N', 'HEIGHT' => $this->arParams['HEIGHT'], 'CASUAL_PROPERTIES' => array('TYPE' => $banner['AD_TYPE'], 'IMG' => $banner['IMAGE_ID'], 'ALT' => $banner['IMAGE_ALT'], 'URL' => $banner['URL'], 'URL_TARGET' => $banner['URL_TARGET'])), null, array('HIDE_ICONS' => 'Y'));
                     $strReturn = ob_get_contents();
                     ob_end_clean();
                 } else {
                     $strReturn = CAdvBanner::GetHTML($banner, $this->arParams["NOINDEX"] == "Y");
                 }
                 $this->arResult["BANNERS"][$key] = $strReturn;
                 $this->arResult["BANNERS_PROPERTIES"][$key] = $banner;
                 $this->bannerIndex++;
                 CAdvBanner::FixShow($banner);
                 if ($USER->IsAuthorized() && $APPLICATION->GetShowIncludeAreas()) {
                     if (($arIcons = CAdvBanner::GetEditIcons($banner, $this->arParams["TYPE"], $this->getIncludeAreaIcons())) !== false) {
                         $this->AddIncludeAreaIcons($arIcons);
                     }
                 }
             }
         }
     }
 }