<?php
  include __DIR__ . "/../layout/header_drop.php";
//  include __DIR__ . "/../inc/foto_nav.php";
  include __DIR__ . "/../css/navi.css";

  $themen = $anz_themen = array();  // Themenunterschrift - Anzahl Bilder vom gleichen Thema
  $path_images = __DIR__ . "/../images/".$thema."/";
  $base_ordner = "/home/foto/views/images/";
  $unterordner = scandir($path_images);

  $i = 1;                     // 1. Bild
  $alles = array();
  $anz_themen[] = 0;
//  foreach($unter_thema AS $bild_thema){
  foreach($unterordner AS $bild_thema){
    if ($bild_thema != "." && $bild_thema != ".." && $bild_thema != "klein" && $bild_thema != "_notes" &&
      $bild_thema != ".DS_Store" && $bild_thema != "Thumbs.db") {
      $unter_thema[] = $bild_thema; // gültiges Unterthema
    //echo "</br>Thema: ".$bild_thema; echo "</br>";
    $ordner = $base_ordner.$thema."/".$bild_thema;


    //$ordner = $base_ordner.$thema."/".$bild_thema; //echo "<br".$ordner;
    $file_img = $path_images.$bild_thema."/"; //$file_img = $base_ordner.$bild_thema."/";
    $themen[] = $bild_thema;   //element an letzter stelle hizufügen
    $allebilder = scandir($file_img);


    foreach ($allebilder as $bild) {      //Ordner "images" auslesen
      $bildinfo = pathinfo($ordner."/".$bild);
      if ($bild != "." && $bild != ".." && $bild != "klein" && $bild != "_notes"
        && $bildinfo['basename'] != "Thumbs.db" && $bildinfo['basename'] != ".DS_Store") { ?>
        <style><?php
          echo ("#p".$i.",#p".$i." + span{background-image:url(".$ordner."/".$bild.")}");?>
        </style><?php
        $i++;
        $alles[] = $bild;
      }
    }
    $anz_themen[] = $i-1;   //anzahl bilder an letzter stelle hizufügen
  }
}
  $anz_images = $i; ?>
    <div id="myBtnContainer" style="padding-left:20px; top:0px; text-transform:capitalize;"><?php
      echo "&nbsp;<b>Thema &nbsp;".$thema.":</b>&nbsp;&nbsp;";?>
    <a href='<?php echo $thema."?carussel=00";?>'>zurück -> Einzelbilder</a>
  </div> <?php
//  $anz = count($unter_thema); //die();
  $anz = count($unterordner);
  $active = "class=\”active\"";
  $i = 0;   // 1. Bild
  $m = $b = 0;   // $m = 1. Matrix-Eintrag
  $nr = $i; // 1. Bild ?>

  <div>
    <div class="container"> <!--  <h2>Carousel Example</h2> -->
      <div id="myCarousel" class="carousel slide" data-ride="carousel">
        <!-- Indicators -->
        <div class="carousel-inner"><?php
          for ($i = $nr; $i < $anz_images-1; $i++) {
            echo "<div class=\"";
            if ($i == $nr) {echo "item active\">";} else { echo "item\">";}?>
              <img src="<?php echo $base_ordner.$thema."/".$themen[$m]."/".$alles[$i];?>"
                 alt="hbc fotos" style="width:100%;">
              <!-- Beschriftung -->
              <div class='top-left'>
                <h3>hb fotos</h3>
             </div>
              <div class='bottom-left'>
                <p><?php echo "Bild ".($i+1)." (".($anz_images-1).") - ".$themen[$m]." - ".$titel[$i+1]."</p>";?>
             </div>
            </div><?php
            if ($i+1 >= ($anz_themen[$m+1])) {    // Themenzähler bginnt bei 0
              $m = $m+1;
            }
            //$b++;
          } ?>
        </div>
        <!-- Left and right controls -->
        <a class="left carousel-control" href="#myCarousel" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#myCarousel" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>
    </div><?php
  //}?>
  </div>
  <div>
  <button input class="btn-default" type="button"><a href='<?php echo $thema."?carussel=00";?>'>zurück -> Einzelbilder</a></button>
</div>
  <br>    <!-- leere Zeile unter dem Bild -->

<?php
    include __DIR__ . "/../js/filter_1.inc.js";
    //include __DIR__ . "/../layout/footer.php";
?>