Ejemplo n.º 1
0
    /**
     * Draw top banners code
     * 		@param $banner_image
     * 		@param $show_always
     * 		@param $draw
     */
    public static function DrawBannersTop(&$banner_image, $show_always = true, $draw = true)
    {
        global $objLogin;
        $default_banner_image = '';
        $nl = "\n";
        if (Modules::IsModuleInstalled('banners')) {
            $is_banners_active = ModulesSettings::Get('banners', 'is_active');
            $rotate_delay = ModulesSettings::Get('banners', 'rotate_delay');
            $rotation_type = ModulesSettings::Get('banners', 'rotation_type');
            $caption_html = ModulesSettings::Get('banners', 'slideshow_caption_html');
            if ($is_banners_active == 'yes') {
                $objBanners = new Banners();
                if ($rotation_type == 'slide show') {
                    $arrBanners = $objBanners->GetBannersArray();
                    if ($show_always || !$show_always && Application::Get('page') == 'home' && !$objLogin->IsLoggedIn()) {
                        $output = '<script src="' . APPHP_BASE . 'modules/cslide/jquery.cross-slide.min.js" type="text/javascript"></script>' . $nl;
                        $output .= '<script type="text/javascript">' . $nl;
                        $output .= 'jQuery(function() {
							jQuery(\'#slideshow\').crossSlide({
							  sleep: ' . $rotate_delay . ', fade: 2,variant: true
							}, [						
						';
                        $ind = '0';
                        foreach ($arrBanners as $key => $val) {
                            if ($ind == '0') {
                                $default_banner_image = 'images/banners/' . $val['image_file'];
                            } else {
                                $output .= ',';
                            }
                            $output .= '{ src: \'images/banners/' . $val['image_file'] . '\', alt: \'' . encode_text($val['image_text']) . ($val['link_url'] != '' ? '##' . $val['link_url'] : '') . '\', to:\'up\' }';
                            $ind++;
                        }
                        $output .= '], function(idx, img, idxOut, imgOut) {
							var img_alt_split = img.alt.split(\'##\');
							var caption_width = jQuery(\'div#slideshow\').width() - 20;						
							if(idxOut == undefined){							
							  /* starting single image phase, put up caption */
							  if(img.alt != \'\'){
								jQuery(\'div.slideshow-caption\').click(function(){ if(img_alt_split[1] != undefined && img_alt_split[1] != \'\') appGoToPage(img_alt_split[1]); });
								jQuery(\'div.slideshow-caption\').' . ($caption_html == 'yes' ? 'html' : 'text') . '(img_alt_split[0]).animate({ opacity: .7 })
								jQuery(\'div.slideshow-caption\').fadeIn();
								if(caption_width != null) jQuery(\'div.slideshow-caption\').width(caption_width);
							  }
							}else{
							  // starting cross-fade phase, take out caption
							  jQuery(\'div.slideshow-caption\').click(function() { });
							  jQuery(\'div.slideshow-caption\').fadeOut();
							}}) });';
                        $output .= '</script>' . $nl;
                        if ($ind == 1) {
                            $banner_image = '<div class="banners-box-random" id="slideshow">' . $objBanners->GetRandomBanner() . '</div>';
                        } else {
                            if ($draw) {
                                echo $output;
                            } else {
                                return $output;
                            }
                            $banner_image = '<div class="banners-box-slideshow" id="slideshow"></div><div class="slideshow-caption"></div>';
                        }
                    }
                } else {
                    if ($show_always || !$show_always && Application::Get('page') == 'home' && !$objLogin->IsLoggedIn()) {
                        $banner_image = '<div class="banners-box-random" id="slideshow">' . $objBanners->GetRandomBanner() . '</div>';
                    }
                }
            }
        }
    }