Your IP : 3.14.249.184


Current Path : /data/web/virtuals/51568/virtual/www/class/
Upload File :
Current File : /data/web/virtuals/51568/virtual/www/class/slideshow.class.php

<?php
  require_once "pdoDB.class.php";
  $pdo = new pdoDB();
  
class Slideshow
{  
  private $slozka;
  private $galerie_id;
  private $galerieNadpis;
  private $komentar;

 	public function __construct($galerie_id)
	{		
//    $this->aktfotka_id = $aktfotka_id;
    $this->galerie_id = $galerie_id;
    global $pdo;
    $query = "SELECT `folder`, `nazev`, `komentar` FROM `soubory_galerie` WHERE id = :galerie_id";
    $row = $pdo->queryOne($query, Array(':galerie_id' => $galerie_id));    
    $this->galerieNadpis = $row->nazev;  
    $this->komentar = $row->komentar;  
    if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {$url = 'https://';   }   
    else {$url = 'http://';}  
    $url.= $_SERVER['HTTP_HOST'];   
    $this->slozka = $url.'/ftp/galerie/'.$row->folder.'/';
	}

  public function showSlideshow ($ukazNadpis = false, $spustitText = true, $width = 200) {
    global $pdo; 
     $rand = mt_rand();
    $maxHeight = 0.7 * $width;
    $query = "SELECT `id`, `popis`, `ext` FROM `soubory` WHERE galerie_id=:galerie_id order by `poradi`"; 
    $fotky = $pdo->queryAll($query, Array(':galerie_id' => $this->galerie_id));   
    $fancybox = "gallery".$this->galerie_id;
    $html = "";  
    if ($ukazNadpis) {
       $html .= '<div class="text-right"><button class="btn btn-outline-primary btn-sm my-2 py-1 rounded-0" onclick="galerieSeznam()">Zpět na galerie</button></div>
       <div class="alert alert-info my-2 py-1 rounded-0">'.$this->galerieNadpis.'</div>
       <p>'.nl2br($this->komentar).'</p>';
    }
    if ($spustitText){    
      $html .= '<div class="text-muted form-text my-2" style="font-size: 0.8rem">Kliknutím na libovolné fotce spustíš galerii.</div>
     <div class="galerie" style=" grid-template-columns: repeat(auto-fill, '.$width.'px);">' ;
    } else {
      $html .= '<div class="galerie mb-3" style=" grid-template-columns: repeat(auto-fill, '.$width.'px);">' ;
    }    
	  forEach ($fotky as $fotka){
       $odkaz = $this->slozka.$fotka->id.'.'.$fotka->ext;
       $odkazMala = $this->slozka.$fotka->id.'_m.'.$fotka->ext;
    //   if (@getimagesize($odkaz)) {
          $caption = $this->galerieNadpis;
          if ($fotka->popis > ' ') {$caption .= "<br>".$fotka->popis;}
          $title = ($fotka->popis > ' ') ? $this->galerieNadpis.": ".$fotka->popis :  $this->galerieNadpis; 
          $html .= '<a data-fancybox="'.$fancybox.'" href="'.$odkaz.'?v='.$rand.'" data-caption="'.$caption.'" class="gallery-item p-1 ">
          <div class="image">
						<img  src="'.$odkazMala.'?v='.$rand.'"  
            alt="'.$caption.'" title="'.$title.'">
            </div>
            </a>';
     //  }         
     }
     return "</div>".$html; 
  } 
  
  public function showSlideshowCounter ($ukazNadpis = false, $spustitText = true, $width = 200, $rok = '', $zapocitat) {
    global $pdo; 
    $fileStahnout = "../../ftp/galeriezip/".$this->galerie_id.'.zip';
    $fileStahnout2 = "ftp/galeriezip/".$this->galerie_id.'.zip';
    $btnStahnout = (file_exists($fileStahnout)) ? 
      '<a class="ml-auto" href="'.$fileStahnout.'"><button class="btn btn-outline-info rounded-0" >Stáhnout galerii v ZIPu</button></a>' : 
      '';       
    if (!$btnStahnout) {
        $btnStahnout =  (file_exists($fileStahnout2))  ? 
      '<a class="ml-auto" href="'.$fileStahnout.'"><button class="btn btn-outline-info rounded-0" >Stáhnout všechny fotky v jednom ZIPu</button></a>' : 
      '';
      }    
    if ($zapocitat == '1'){
      $query = "SELECT `zobrazeno` FROM `soubory_galerie` WHERE `id` = :galerie_id";
      $result = $pdo->queryOne($query, Array(':galerie_id' => $this->galerie_id));
      $zobrazeno = $result->zobrazeno + 1;
      $query = "UPDATE `soubory_galerie` SET `zobrazeno`= :zobrazeno WHERE `id` = :galerie_id";
      $pdo->execute($query, Array(':galerie_id' => $this->galerie_id, ':zobrazeno'=>$zobrazeno));
    }
    $rand = mt_rand();
    $maxHeight = 0.7 * $width;
    $query = "SELECT `id`, `popis`, `ext` FROM `soubory` WHERE galerie_id=:galerie_id order by `poradi`"; 
    $fotky = $pdo->queryAll($query, Array(':galerie_id' => $this->galerie_id));   
    $fancybox = "gallery".$this->galerie_id;
    $html =  "<script> $('[data-fancybox^=\"gallery\"]').fancybox({ protect: true, }); </script>";  


    if ($ukazNadpis) {
       $html .= '<div class="text-right"><button class="btn btn-outline-primary btn-sm my-2 py-1 rounded-0" onclick="galerieSeznam()">Zpět na galerie '.$rok.'</button></div>
       <div class="alert alert-info my-2 py-1 rounded-0 d-flex"><div class="h5 pt-2">'.$this->galerieNadpis.'</div>'.$btnStahnout.'   
        </div>
       <p>'.nl2br($this->komentar).'</p>';
    }
    if ($spustitText){    
      $html .= '<div class="text-muted form-text my-2" style="font-size: 0.8rem">Kliknutím na libovolné fotce spustíš galerii.</div>
     <div class="galerie" style=" grid-template-columns: repeat(auto-fill, '.$width.'px);">' ;
    } else {
      $html .= '<div class="galerie mb-3" style=" grid-template-columns: repeat(auto-fill, '.$width.'px);">' ;
    }    
	  forEach ($fotky as $fotka){
       $odkaz = $this->slozka.$fotka->id.'.'.$fotka->ext;
       $odkazMala = $this->slozka.$fotka->id.'_m.'.$fotka->ext;
     //  if (@getimagesize($odkaz)) {
     //  if (is_file($odkaz)) {
          $caption = $this->galerieNadpis;
          if ($fotka->popis > ' ') {$caption .= "<br>".$fotka->popis;}
          $title = ($fotka->popis > ' ') ? $this->galerieNadpis.": ".$fotka->popis :  $this->galerieNadpis; 
          $html .= '<a data-fancybox="'.$fancybox.'" href="'.$odkaz.'?v='.$rand.'" data-caption="'.$caption.'" class="gallery-item"  >
          <div class="image">
						<img src="'.$odkazMala.'?v='.$rand.'" alt="'.$caption.'" title="'.$title.'">
            </div>
            </a>';
     //  }         
     }
     $html = "</div>".$html."</div>" ;
     if (!$ukazNadpis && $btnStahnout) {
       $html .= '<div class="text-right">'.$btnStahnout.'</div>';
     }
     return $html; 
  }   
 
 
}