Esempio n. 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);
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
 function Show($TYPE_SID, $HTML_BEFORE = "", $HTML_AFTER = "")
 {
     global $APPLICATION, $USER;
     $debug = null;
     if ($_SESSION["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && $USER->IsAdmin()) {
         $debug = new CDebugInfo();
         $debug->Start();
     }
     $arBanner = CAdvBanner::GetRandom($TYPE_SID);
     $strReturn = CAdvBanner::GetHTML($arBanner);
     if (strlen($strReturn) > 0) {
         CAdvBanner::FixShow($arBanner);
         if (($arIcons = CAdvBanner::GetEditIcons($arBanner, $TYPE_SID)) !== false) {
             $strReturn = $APPLICATION->IncludeString($strReturn, $arIcons);
         }
         $strReturn = $HTML_BEFORE . $strReturn . $HTML_AFTER;
         if ($debug) {
             $strReturn .= $debug->Output();
         }
         return $strReturn;
     }
     if ($debug) {
         echo $debug->Output();
     }
     return false;
 }
Esempio n. 3
0
    $arParams["CACHE_TIME"] = 0;
}
//Result
$arResult = array("BANNER" => "", "BANNER_PROPERTIES" => array());
$obCache = new CPHPCache();
$cache_id = SITE_ID . "|advertising.banner|" . serialize($arParams) . "|" . $USER->GetGroups();
$cache_path = "/" . SITE_ID . $this->GetRelativePath();
if ($obCache->StartDataCache($arParams["CACHE_TIME"], $cache_id, $cache_path)) {
    if (!CModule::IncludeModule("advertising")) {
        return;
    }
    $arBanner = CAdvBanner::GetRandom($arParams["TYPE"]);
    $strReturn = CAdvBanner::GetHTML($arBanner, $arParams["NOINDEX"] == "Y");
    $arResult["BANNER"] = $strReturn;
    $arResult["BANNER_PROPERTIES"] = $arBanner;
    if (strlen($arResult["BANNER"]) > 0) {
        CAdvBanner::FixShow($arBanner);
    }
    $this->IncludeComponentTemplate();
    $templateCachedData = $this->GetTemplateCachedData();
    $obCache->EndDataCache(array("arResult" => $arResult, "templateCachedData" => $templateCachedData));
} else {
    $arVars = $obCache->GetVars();
    $arResult = $arVars["arResult"];
    $this->SetTemplateCachedData($arVars["templateCachedData"]);
}
if ($USER->IsAuthorized() && $APPLICATION->GetShowIncludeAreas()) {
    if (($arIcons = CAdvBanner::GetEditIcons($arResult["BANNER_PROPERTIES"], $arParams["TYPE"])) !== false) {
        $this->AddIncludeAreaIcons($arIcons);
    }
}