ok

Mini Shell

Direktori : /home/institutonamaste/www/class/
Upload File :
Current File : /home/institutonamaste/www/class/class-banner.php

<?php
class BannerHome{	

	private $li	 = 'banner/';
	private $tb  = "banner";
	
	public function __construct()
	{		
		$cont = 1;
		$sql = DBRead($this->tb, "WHERE status = '1' ORDER BY id DESC", "img1, titulo1, texto1, url1, link_externo1, img2, titulo2, texto2, url2, link_externo2");			
		while($row = mysqli_fetch_object($sql))
		{			
			if(mysqli_num_rows($sql) > 0)
			{
				$ext1 	= ($row->link_externo1 == 1) ? 'target="_blank"' : '';
				$ext2 	= ($row->link_externo2 == 1) ? 'target="_blank"' : '';
				$active = ($cont == 1) ? 'active' : '';
				$cont++;
				
				$banners .= '<div class="carousel-item '.$active.'">';
				
				if(!empty($row->img1) && !empty($row->img2))
					$banners .= $this->BannerDuplo($row->img1, $row->titulo1, $row->texto1, $row->url1, $ext1, $row->img2, $row->titulo2, $row->texto2, $row->url2, $ext2);				
				elseif(!empty($row->img1) && empty($row->img2))
					$banners .= $this->BannerSingle($row->img1, $row->titulo1, $row->texto1, $row->url1, $ext1);

				$banners .= '</div><!-- carousel-item -->';
			}
		}
	
		echo $banners;	
	}
				
	public function BannerSingle($img, $title, $text, $link, $externo)
	{
		if(!empty($title) or !empty($text))
		{
			$banner = '
			<div class="row clearfix">
				<div class="image bg-full">
					<img src="'.IMG.$this->li.$img.'" alt="'.$title.'">
				</div>
								
				<div class="text-full">
					<h2>'.$title.'</h2>
					<p>'.$text.'</p>
					<a href="'.$link.'" class="more" '.$externo.'>SAIBA MAIS</a>
				</div>						
			</div><!-- row -->';
		}else{
			$banner = '
			<div class="row clearfix">
				<div class="image bg-full">
					<a href="'.$link.'" '.$externo.'><img src="'.IMG.$this->li.$img.'" alt="'.$title.'"></a>
				</div>			
			</div><!-- row -->';				
		}	

		return $banner;
	}
	
	public function BannerDuplo($img1, $title1, $text1, $lk1, $ex1, $img2, $title2, $text2, $lk2, $ex2)
	{
		$banner = '
		<div class="row clearfix">
			<div class="image left">
				<img src="'.IMG.$this->li.$img1.'" alt="'.$title1.'">
			</div>
						
			<div class="text-duplo left">
				<h2>'.$title1.'</h2>
				<p>'.$text1.'</p>
				<a href="'.$lk1.'" class="more" '.$ex1.'>SAIBA MAIS</a>
			</div>
						
			<div class="image right">
				<img src="'.IMG.$this->li.$img2.'" alt="'.$title2.'">
			</div>
					
			<div class="text-duplo right">
				<h2>'.$title2.'</h2>
				<p>'.$text2.'</p>
				<a href="'.$lk2.'" class="more" '.$ex2.'>SAIBA MAIS</a>
			</div>						
		</div><!-- row -->';

		return $banner;
	}
}
?>

Zerion Mini Shell 1.0