<?php
//faiseur de gallerie

if ($this->dossier !='')
{
		$this->debug .= "isset($this->dossier), ";

		$total_thumbs=0; 
		$t_precedent = $t_suivant = $images_thumb="";
		$compteur_thumbs=0;
		$total_thumbs=0;
		$dossiers_a_scanner = $tableau_dossiers_a_scanner[$this->dossier];
		$analyse = "images/".$dossiers_a_scanner;
		$this->debug .= "******* scan de $analyse";
		$table_scandir = scandir($analyse);//scan du répertoire
		$this->debug .= " ...table_scandir: $table_scandir ...";
		//print_r($table_scandir);
		if ($table_scandir == FALSE){$this->debug .= " ...FALSE";}
		$table_thumbs_scandir = scandir($analyse."/thumb");
		$tableau_images[0]=NULL;
		
	$this->debug .= 'isset($this->dossier) image='.$this->image;
	if ($this->image=='') //juste dossier d'images pour thumbs
	{ 

				
//s'occuper des liens précédents et suivants des images
		
			foreach ($table_thumbs_scandir AS $k => $v)
		{
			if ($v != "." AND $v != '..' AND $v != 'Thumbs.db')//si c'est pas . ou ..
				{$total_thumbs++;
				$tableau_images[$total_thumbs] = $v;
				}
		}
		foreach ($table_thumbs_scandir AS $k2 => $v2)
		{
				if ($v2 != "." AND $v2 != '..' AND $v2 != 'Thumbs.db')
				//si c'est pas . ou ..
				{
				$compteur_thumbs++;;
				$images_thumb .= ' <a href="?p='.$this->page.'&d='.$this->dossier.'&i='.$v2.'&l='.$this->langue.'" >'.'<img class="gal-img" src="images/'.$dossiers_a_scanner.'/thumb/'.$v2.'" alt="'.$v2.'" title="'.$v2.'"/></a>';
				}
		}
		//$this->debug .= "$br insertion images des $compteur_thumbs thumbs";	
		$this->contenu .= "$images_thumb";
		//$this->debug .= "$compteur_thumbs images OK";	
	}



//si y'a une image
elseif ($this->image) 
{		

	foreach ($table_thumbs_scandir AS $k => $v)
		{
			if ($v != "." AND $v != '..' AND $v != 'Thumbs.db')
			//si c'est pas . ou ..
				{$total_thumbs++;
				$tableau_images[$total_thumbs] = $v;
				}
		}
				
$barre_a_afficher = 1;
$actuel = array_search($this->image, $tableau_images );
// $this->debug(' AAAAAAAAAA $actuel = '.$actuel.' ----');
// $actuel=2;
//espace central affichant l'image sélectionnée
$ajout = '

	<a href="images/'.$dossiers_a_scanner.'/grand/'.$this->image.'">
	<span class="zoomer" title="zoomer en taille maximale sur l\'image '.$this->image.'">
	<img src="decoration/zoom.png" alt="Zoom" title="zoomer en taille maximale sur l\'image '.$this->image.'">
	</span>
	</a>

';

	//Si l'image est la dernière du lot
	if ($total_thumbs <= $actuel){
	$ajout .='<a href="?p=BOOK&d='.$this->dossier.'&l='.$this->langue.'">';
	//l'image centrale pointe vers le dossier
	$this->debug .="$br -------- l'image est la dernière du lot";
}
else {
$ajout .='<a href="?p=BOOK&d='.$this->dossier.'&i='.$tableau_images[$actuel+1].'&l='.$this->langue.'">';}
	$ajout .='
	
	<img src="images/'.$dossiers_a_scanner.'/'.$this->image.'" alt="'.$this->image.'" title="'.$this->image.' - cliquez pour voir la suite du dossier '.$dossiers_a_scanner.'"/>
	</a>
<br/>

';
		$zoom = '<a href="images/'.$dossiers_a_scanner.'/grand/'.$this->image.'">Zoom <img src="decoration/zoom.png" alt="zoomer"></a>';

		$this->contenu .= $ajout;

			if ($actuel <$total_thumbs) {$suivant = '<a href="?p=BOOK&d='.$this->dossier.'&i='.$tableau_images[$actuel+1].'&l='.$this->langue.'"> '.($actuel +1).' <img src="decoration/mail.png"/></a>' ;
			$t_suivant = '<a href="?p=BOOK&d='.$this->dossier.'&i='.$tableau_images[$actuel+1].'&l='.$this->langue.'"> <img src="decoration/fleche_droite.png" alt="'.$mot_suivant.'" title="'.$mot_suivant.'"/> '.($actuel +1).'</a>' ;}

			if ($actuel >=2) 
			{
			$avant = $actuel-1;
			$precedent= 
			'<a href="?p=BOOK&d='.$this->dossier.'&i=			'.$tableau_images[$avant].'			&l='.$this->langue.'">
			<img src="decoration/fleche_gauche.png" /> '.($avant).'</a>' ;
			$t_precedent = '<a href="?p=BOOK&d='.$this->dossier.'&i='.$tableau_images[$avant].'&l='.$this->langue.'">   '.($avant).' <img src="decoration/fleche_gauche.png" title="'.$mot_precedent.'" title="'.$mot_precedent.'"/></a>' ;

			}
		// $this->contenu .= $total = '<a href="?p=BOOK&d='.$this->dossier.'&l='.$this->langue.'">'.$total_thumbs.'</a>';
$this->details .= '<a href="images/'.$dossiers_a_scanner.'/grand/'.$this->image.'"><img src="decoration/loupe.png" alt="Zoom" title="zoomer en taille maximale sur l\'image '.$this->image.'">'.
	$t_precedent.$t_suivant.'
	<br/>
	'.$infos.'
	</a>
';
		
}

//$this->debug .= $br.'src="images/'.$dossiers_a_scanner.'/'.$_GET["img"].'"';
}

?>