示例#1
0
    function GetHTML($arBanner, $bNoIndex = false)
    {
        $strReturn = "";
        // обрабатываем изображение
        if (intval($arBanner["IMAGE_ID"]) > 0 && $arBanner["AD_TYPE"] != "html") {
            $arImage = CFile::GetFileArray($arBanner["IMAGE_ID"]);
            if ($arImage) {
                $file_type = GetFileType($arImage["FILE_NAME"]);
                $path = $arImage["SRC"];
                switch ($file_type) {
                    case "FLASH":
                        $arParams = array();
                        $url = $param = "";
                        $alt = $a_title = $a_target = "";
                        if (strlen(trim($arBanner["URL"])) > 0) {
                            $param = CAdvBanner::PrepareHTML($arBanner["URL"], $arBanner);
                            $param = CAdvBanner::GetRedirectURL($param, $arBanner);
                            $url = $param;
                            $arParams[] = "flash_link=" . urlencode($param);
                            if (strlen(trim($arBanner["URL_TARGET"])) > 0) {
                                $arParams[] = "flash_target=" . urlencode($arBanner["URL_TARGET"]);
                                $a_target = ' target="' . htmlspecialcharsbx($arBanner["URL_TARGET"]) . '" ';
                            }
                        }
                        if (strlen(trim($arBanner["IMAGE_ALT"])) > 0) {
                            $alt = CAdvBanner::PrepareHTML($arBanner["IMAGE_ALT"], $arBanner);
                            $arParams[] = "flash_alt=" . urlencode($alt);
                            $a_title = " title=\"" . htmlspecialcharsbx($alt) . "\" ";
                        }
                        if (count($arParams) > 0) {
                            $param = "?" . implode("&", $arParams);
                        }
                        if ($arBanner["FLASH_TRANSPARENT"] == '') {
                            $arBanner["FLASH_TRANSPARENT"] = 'transparent';
                        }
                        if ($arBanner["FLASH_JS"] != 'Y') {
                            $strReturn = '<div style="width: ' . $arImage["WIDTH"] . 'px; height: ' . $arImage["HEIGHT"] . 'px; padding:0; margin:0">';
                            if (strlen(trim($arBanner["URL"])) > 0 && $arBanner["NO_URL_IN_FLASH"] == "Y") {
                                $strReturn .= ($bNoIndex ? '<noindex>' : '') . '<div style="position:absolute; z-index:100;"><a href="' . $url . '"' . $a_target . $a_title . ($bNoIndex ? ' rel="nofollow"' : '') . '><img src="/bitrix/images/1.gif" width="' . $arImage["WIDTH"] . '" height="' . $arImage["HEIGHT"] . '" style="border:0;" alt="' . htmlspecialcharsEx($alt) . '" /></a></div>' . ($bNoIndex ? '</noindex>' : '');
                            }
                            $strReturn .= '<OBJECT
	classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000"
	codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
	id="banner_' . $arBanner["ID"] . '"
	WIDTH="' . $arImage["WIDTH"] . '"
	HEIGHT="' . $arImage["HEIGHT"] . '">
		<PARAM NAME="movie" VALUE="' . $path . $param . '" />
		<PARAM NAME="quality" VALUE="high" />
		<PARAM NAME="bgcolor" VALUE="#FFFFFF" />
		<PARAM NAME="wmode" VALUE="' . $arBanner["FLASH_TRANSPARENT"] . '" />
		<EMBED
			src="' . $path . $param . '"
			quality="high"
			bgcolor="#FFFFFF"
			wmode="' . $arBanner["FLASH_TRANSPARENT"] . '"
			WIDTH="' . $arImage["WIDTH"] . '"
			HEIGHT="' . $arImage["HEIGHT"] . '"
			NAME="banner"
			TYPE="application/x-shockwave-flash"
			PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
		</EMBED>
</OBJECT></div>';
                        } else {
                            $strReturn = "";
                            static $bScript = null;
                            if ($bScript === null) {
                                $bScript = true;
                                $strReturn .= '<script type="text/javascript" src="' . CUtil::GetAdditionalFileURL('/bitrix/js/advertising/flash.js') . '"></script>';
                            }
                            $altImgPath = '';
                            $arAltImage = CFile::GetFileArray($arBanner["FLASH_IMAGE"]);
                            if ($arAltImage) {
                                $altImgPath = $arAltImage["SRC"];
                            }
                            $test_id = 'id' . RandString(10);
                            $strReturn .= '<div id="' . $test_id . '" style="width: ' . $arImage["WIDTH"] . 'px; height: ' . $arImage["HEIGHT"] . 'px; padding:0; margin:0;">';
                            $altHref = '';
                            if (trim($arBanner["URL"]) != '') {
                                if ($arBanner["NO_URL_IN_FLASH"] == "Y") {
                                    $strReturn .= ($bNoIndex ? '<noindex>' : '') . '<div style="position:absolute; z-index:100;"><a href="' . $url . '"' . $a_target . $a_title . ($bNoIndex ? ' rel="nofollow"' : '') . '><img src="/bitrix/images/1.gif" width="' . $arImage["WIDTH"] . '" height="' . $arImage["HEIGHT"] . '" style="border:0;" alt="' . htmlspecialcharsEx($alt) . '" /></a></div>' . ($bNoIndex ? '</noindex>' : '');
                                } else {
                                    $altHref = $url;
                                }
                            }
                            $strReturn .= '</div>';
                            $strReturn .= '<script type="text/javascript">bx_adv_includeFlash("' . $test_id . '", "' . CUtil::JSEscape($path . $param) . '", "' . $arImage["WIDTH"] . '", "' . $arImage["HEIGHT"] . '", "' . $arBanner["FLASH_TRANSPARENT"] . '", "' . CUtil::JSEscape($altImgPath) . '", ' . (intval($arBanner["FLASH_VER"]) <= 0 ? 'null' : intval($arBanner["FLASH_VER"])) . ', "' . CUtil::JSEscape($altHref) . '", "' . CUtil::JSEscape(htmlspecialcharsbx($arBanner["URL_TARGET"])) . '", "' . CUtil::JSEscape(htmlspecialcharsbx($alt)) . '");</script>';
                        }
                        break;
                    default:
                        $alt = CAdvBanner::PrepareHTML(trim($arBanner["IMAGE_ALT"]), $arBanner);
                        $strImage = "<img alt=\"" . htmlspecialcharsEx($alt) . "\" title=\"" . htmlspecialcharsEx($alt) . "\" src=\"" . $path . "\" width=\"" . $arImage["WIDTH"] . "\" height=\"" . $arImage["HEIGHT"] . "\" style=\"border:0;\" />";
                        if (strlen(trim($arBanner["URL"])) > 0) {
                            $url = $arBanner["URL"];
                            $url = CAdvBanner::PrepareHTML($url, $arBanner);
                            $url = CAdvBanner::GetRedirectURL($url, $arBanner);
                            $target = strlen(trim($arBanner["URL_TARGET"])) > 0 ? " target=\"" . $arBanner["URL_TARGET"] . "\" " : "";
                            $strReturn = ($bNoIndex ? '<noindex>' : '') . "<a href=\"" . $url . "\"" . $target . ($bNoIndex ? ' rel="nofollow"' : '') . ">" . $strImage . "</a>" . ($bNoIndex ? '</noindex>' : '');
                        } else {
                            $strReturn .= $strImage;
                        }
                        break;
                }
            }
        }
        if ($arBanner["CODE"] != '') {
            $code = $arBanner["CODE"];
            if ($arBanner["CODE_TYPE"] == "text") {
                $code = TxtToHTML($code);
            }
            $code = CAdvBanner::PrepareHTML($code, $arBanner);
            $strReturn .= CAdvBanner::ReplaceURL($code, $arBanner);
        }
        return $strReturn;
    }
示例#2
0
 protected function loadPreview()
 {
     global $APPLICATION;
     if ($banner = CAdvBanner::GetByID($this->arParams["BANNER_ID"])->Fetch()) {
         if ($banner["AD_TYPE"] == 'template') {
             $this->templateProps = unserialize($banner["TEMPLATE"]);
             $this->templateFiles = unserialize($banner["TEMPLATE_FILES"]);
             foreach ($this->templateProps['PROPS'] as $k => $v) {
                 ob_start();
                 $APPLICATION->IncludeComponent('bitrix:advertising.banner.view', $this->templateProps['NAME'], array('PROPS' => $v, 'FILES' => $this->templateFiles[$k], 'EXT_MODE' => $this->templateProps['MODE'], 'INDEX' => $this->bannerIndex, 'PREVIEW' => $this->arParams['PREVIEW'], 'CASUAL_PROPERTIES' => array('TYPE' => $banner['AD_TYPE'])), null, array('HIDE_ICONS' => 'Y'));
                 $strReturn = CAdvBanner::PrepareHTML(ob_get_contents(), $banner);
                 ob_end_clean();
                 $this->arResult["BANNERS"][] = $strReturn;
                 $this->bannerIndex++;
             }
             $this->arResult["BANNERS_PROPERTIES"][] = $banner;
         }
         $this->arResult['SIZE'] = $this->getBannerSize();
     } else {
         $this->arResult = array();
     }
 }