<?php
/**
 * @package sicht_details
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf 
 */



class KursFotosMobilePage extends DefaultMobilePage{

  function __construct() {
    if(isset($_REQUEST['nr'])){
      parent::__construct(366, TOOL_MOB_KURSDETAILS, RequestOperations::getVarValue('nr'));
    } else {
      parent::__construct(366, TOOL_MOB_KURSDETAILS, 'Fotos');
    }
    
    $this->addAttr('class', 'page-gallery');
    
    
    $this->dbwork = new DBWorkFoto();
    $this->fetchData();
  }

  public function fetchData(){
    if(isset($this->urlParameter['nr'])){
      $this->data = $this->dbwork->getFotoNummern('K', $this->urlParameter['nr']);
    } else {
      $this->data = NULL;
    }
    $this->dataCount = count($this->data);
  }

  public function getMobileHtml(){
  	if ($this->data && $this->dataCount > 0){
  		
  		$retour  = '<div id="foto_gallery">';
  		foreach ($this->data as $fotoNr) {
  			$foto = $this->dbwork->getFoto('K', $this->urlParameter['nr'], $fotoNr);
  			$fotoLink = FotoAPI::getFotoLink(0, 0, 0, $foto);
  			if($fotoLink != "") {
  				$retour .= '<img src="../webbasys/' . $fotoLink. '" alt="' . $foto->beschreibung_bf . '" title="'.$foto->untertitel.'">'."\n";
  			}
  		}
  		$retour .= '</div>';
  	} else {
  		$retour =  '<ul data-role="listview" data-filter="true">'."\n";
  		$retour .= '  <li>'."\n";
  		$sprachsettings = new SprachSettingsObject();
  		$retour .= '  <p class="listKeineDaten">Für '.$sprachsettings->Kurs['Singular_mit_Artikel']['Akkusativ'].' existieren keine Fotos.</p>'."\n";
  		$retour .= '  </li>'."\n";
  		$retour .= '</ul>'."\n";
  	}
  	return $retour;
  }
  

}
?>