repertoire_galerie.'/'.$this->section_courante.'/'; } #constructeur function Galerie($rep='.') { $this->repertoire_galerie = $rep; #ouvre le repertoire de la galerie $rep_galerie = dir($this->repertoire_galerie); #pour chaque repertoire (section) while ($section = $rep_galerie->read()) { if ($section != '..' and $section != '.') { if (is_null($this->section_courante)) $this->section_courante = $section; #ouvre le repertoire des images de la section en cours $rep_section = dir($this->repertoire_galerie.'/'.$section); #essais d'inclure le fichier d'info if (!@include($this->repertoire_galerie.'/'.$section.'/'.NOM_FICHIER_INFO)) {$auteur = 'auteur inconnu'; $date = 'date inconnue';} #enregistre les infos $this->sections[$section]['infos']['auteur'] = $auteur; $this->sections[$section]['infos']['date'] = $date; #pour chaque images while ($photo = $rep_section->read()) { if (ereg('('.SUFFIXE_VIGNETTE.'|'.SUFFIXE_PHOTO_REDUITE.').*', $photo)) continue; if (ereg('.*\.[jJ][pP][gG]', $photo)) #si l'extension est .jpg alors mémorise l'image $this->sections[$section]['images'][] = $photo; } $rep_section->close(); } } $rep_galerie->close(); foreach($this->sections as $nom_section => $null) sort($this->sections[$nom_section]['images']); } #affiche la liste des pages function liste_pages() { for($i=1; $i<=ceil(count($this->sections[$this->section_courante]['images'])/NOMBRE_VIGNETTE_PAR_PAGE); $i++) echo ($i==1?'':' | ') ,($i==$_GET['__page_section']?'':''),'',$i,'',($i==$_GET['__page_section']?'':''); } #affiche les vignettes de la section courante function afficher_vignettes($page) { $num_image = 0; echo ''; echo ''; echo ''; echo '
',$this->section_courante,'
Pages : ',$this->liste_pages(),'
Auteur : ', $this->get_auteur(), ' - Date : ', $this->get_date(), '
'; #pour chaque image de la section courante echo '
'; foreach ($this->sections[$this->section_courante]['images'] as $image) { $num_image++; if ($num_image <= $page*NOMBRE_VIGNETTE_PAR_PAGE-NOMBRE_VIGNETTE_PAR_PAGE or $num_image > $page*NOMBRE_VIGNETTE_PAR_PAGE) continue; $vignette = $this->repertoire_courant().SUFFIXE_VIGNETTE.$image; image_redim ($this->repertoire_courant().$image, TAILLE_VIGNETTE, $vignette, 60, 1); if (($num_image - $page*NOMBRE_VIGNETTE_PAR_PAGE-1) % NOMBRE_COLONNE == 0) echo ''; echo ''; } echo '
', $vignette ,'
'; } #pour afficher une seule photo function afficher_photo($photo) { $photo_reduite = $this->repertoire_courant().SUFFIXE_PHOTO_REDUITE.$photo; $pas_redim = false; if (!image_redim ($this->repertoire_courant().$photo, TAILLE_PHOTO_REDUITE, $photo_reduite, 70, 1)) $pas_redim = true; $lien_retour = NOM_FICHIER.'?'.arguments_page().'__section='.$this->section_courante.'&__page_section='.$this->num_page_photo($photo).'&__page_galerie=section'; if ($photo_suivant = $this->photo_suivante($photo)) $lien_suivant = NOM_FICHIER.'?'.arguments_page().'__section='.$this->section_courante.'&__photo='.$photo_suivant.'&__page_galerie=photo'; if ($photo_precedante = $this->photo_precedante($photo)) $lien_precedant = NOM_FICHIER.'?'.arguments_page().'__section='.$this->section_courante.'&__photo='.$photo_precedante.'&__page_galerie=photo'; echo ''; #la barre de navigation : suivant / précédant $nav = ''. ''. ''; echo $nav; echo ''; echo ''; echo $nav; echo '
'.(isset($lien_precedant)?'Photo précédente':'').'Retour'.(isset($lien_suivant)?'Photo suivante':'').'
'.($pas_redim ? '' : '0').''. ($pas_redim ? $photo : $photo_reduite) .''.($pas_redim ?'':'').'
',$photo,'
'; } #renvois le numéros de la page ou se trouve une photo function num_page_photo($photo) { $num_image = 0; foreach($this->sections[$this->section_courante]['images'] as $nom_image) { $num_image++; if ($photo == $nom_image) return ceil($num_image/NOMBRE_VIGNETTE_PAR_PAGE); } return 1; } #renvois la photo suivant, si elle n'existe pas alors renvois 0 function photo_suivante($photo) { $num_photo = array_search($photo, $this->sections[$this->section_courante]['images']); if (isset($this->sections[$this->section_courante]['images'][$num_photo+1])) return $this->sections[$this->section_courante]['images'][$num_photo+1]; else return 0; } #renvois la photo precedante, si elle n'existe pas alors renvois 0 function photo_precedante($photo) { $num_photo = array_search($photo, $this->sections[$this->section_courante]['images']); if (isset($this->sections[$this->section_courante]['images'][$num_photo-1])) return $this->sections[$this->section_courante]['images'][$num_photo-1]; else return 0; } #renvois un tableau des sections function sections() { $sections = array(); foreach ($this->sections as $nom_section => $section) array_push($sections, $nom_section); return $sections; } function set_section_courante($section) { $this->section_courante = $section; } #renvois l'auteur d'une section function get_auteur($section=null) { if (is_null($section)) $section = $this->section_courante; return $this->sections[$section]['infos']['auteur']; } #renvois la date de la section function get_date($section=null) { if (is_null($section)) $section = $this->section_courante; return $this->sections[$section]['infos']['date']; } } ?>