Subversion Repositories Applications.wikini

Rev

Rev 6 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 jpm 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 5.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 1999-2006 Tela Botanica (accueil@tela-botanica.org)                                    |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of wikini.                                                                         |
9
// |                                                                                                      |
10
// | wikini is free software; you can redistribute it and/or modify                                       |
11
// | it under the terms of the GNU General Public License as published by                                 |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
15
// | wikini is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id$
25
/**
26
* wikini - galerie.php
27
*
28
* Description :
29
*
30
*@package wikini
31
//Auteur original :
32
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
33
//Autres auteurs :
34
*@author        Aucun
35
*@copyright     Tela-Botanica 1999-2007
36
*@version       $Revision$ $Date$
37
// +------------------------------------------------------------------------------------------------------+
38
*/
39
 
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTÊTE du PROGRAMME                                       |
42
// +------------------------------------------------------------------------------------------------------+
43
// Définition de constantes
44
define('DS', DIRECTORY_SEPARATOR);
45
/** Constante "dynamique" stockant le chemin absolue de base de l'application.*/
46
define('GAL_CHEMIN_APPLI', dirname(__FILE__).DS);
47
 
48
// Initialisation des variables
49
$sortie = '';
50
$GLOBALS['_GALLERIE_']['erreur'] = '';
51
 
52
// Inclusion du fichier de config de l'action
53
require_once GAL_CHEMIN_APPLI.'galerie'.DS.'configuration'.DS.'gal_config.inc.php';
54
require_once GAL_CHEMIN_APPLI.'galerie'.DS.'bibliotheque'.DS.'metadonnees.fonct.php';
55
//+----------------------------------------------------------------------------------------------------------------+
56
// Récupération des paramêtres et gestion des erreurs de paramètrage
57
if (!$this->GetParameter('dossier')) {
58
	$options['dossier'] = null;
59
	$GLOBALS['_GALERIE_']['erreur'] = "Applette GALERIE : le paramètre 'dossier' est obligatoire !";
60
} else {
61
	$options['dossier'] = rtrim($this->GetParameter('dossier'), DS);
62
}
63
if (!$this->GetParameter('id')) {
64
	$options['id'] = microtime();
65
	//$GLOBALS['_GALERIE_']['erreur'] = "Applette GALERIE : le paramètre 'id' est obligatoire !";
66
} else {
67
	$options['id'] = $this->GetParameter('id');
68
}
69
if (!$this->GetParameter('largeur')) {
70
    $options['largeur'] = 160;
71
} else {
72
	$options['largeur'] = $this->GetParameter('largeur');
73
}
74
if (!$this->GetParameter('hauteur')) {
75
    $options['hauteur'] = 160;
76
} else {
77
	$options['hauteur'] = $this->GetParameter('hauteur');
78
}
79
if (!isset($options['qualite'])) {
80
    $options['qualite'] = 70;
81
}
82
if (!$this->GetParameter('imglargeur')) {
83
    $options['img_largeur'] = 800;
84
} else {
85
	$options['img_largeur'] = $this->GetParameter('imglargeur');
86
}
87
if (!$this->GetParameter('imghauteur')) {
88
    $options['img_hauteur'] = 600;
89
} else {
90
	$options['img_hauteur'] = $this->GetParameter('imghauteur');
91
}
92
if (!isset($options['img_qualite'])) {
93
    $options['img_qualite'] = 70;
94
}
95
if (!isset($options['squelette'])) {
96
    $options['squelette'] = GAL_SQUELETTE_LISTE;
97
}
98
// +------------------------------------------------------------------------------------------------------+
99
// |                                            CORPS du PROGRAMME                                        |
100
// +------------------------------------------------------------------------------------------------------+
101
//+----------------------------------------------------------------------------------------------------------------+
102
// Récupération des données
103
$noimage = 0;
104
$GLOBALS['_GALERIE_']['id'] = $options['id'];
105
$GLOBALS['_GALERIE_']['dossier'] = GAL_CHEMIN_RACINE.$options['dossier'];
106
if (is_dir($GLOBALS['_GALERIE_']['dossier'])) {
107
	if ($dh = opendir($GLOBALS['_GALERIE_']['dossier'])) {
108
		$images = array();
109
		while (($f = readdir($dh)) !== false) {
110
			if((substr(strtolower($f),-3) == 'jpg') || (substr(strtolower($f),-3) == 'gif') || (substr(strtolower($f),-3) == 'png')) {
111
				$noimage++;
112
 
113
				// Gestion des métadonnées
114
				$iptc = array();
115
				$exif = array();
116
				$fichier = $GLOBALS['_GALERIE_']['dossier'].DIRECTORY_SEPARATOR.$f;
117
				$iptc = get_iptc_data($fichier, array('keywords' => '2#025', 'date_creation' => '2#055', 'author' => '2#122', 'name' => '2#005', 'comment' => '2#120'));
118
 
119
				// Nous demandons des entités HTML pour la convertion des champs EXIF stockés en Unicode
120
				ini_set('exif.encode_unicode', 'HTML-ENTITIES');
121
				$exif = get_exif_data($fichier, array('date_creation' => 'DateTimeOriginal', 'comment' => 'UserComment'));
122
 
123
				// Initialisation et prétraitement des commentaires
124
				$commentaire = '';
125
				$exif['comment'] = trim($exif['comment']);
126
				$iptc['comment'] = trim($iptc['comment']);
127
				// Comparaison et ajout des commentaires IPTC et EXIF
128
				if (!empty($iptc['comment']) || !empty($exif['comment'])) {
129
					if (!empty($exif['comment'])) {
130
						// Dans le cas d'un champ de commentaire unicode nous supprimons les caractères NULL
131
						if ($exif['comment_encodage'] == 'UNICODE') {
132
							$exif['comment'] = str_replace(chr(0), '', $exif['comment']);
133
						}
134
						$commentaire .= "\n".trim($exif['comment']);
135
					}
136
 
137
					if (!empty($iptc['comment']) && $iptc['comment'] != $exif['comment']) {
138
						$commentaire .= $iptc['comment'];
139
					}
140
				}
141
 
142
				// Récupération des infos
143
				$images[] = array('filename' => $f, 'titre' => trim($commentaire));
144
				array_multisort($images, SORT_ASC, SORT_REGULAR);
145
			}
146
		}
147
		closedir($dh);
148
	} else {
149
		$GLOBALS['_GALERIE_']['erreur'] = "Applette GALERIE : le dossier d'images ne peut pas être ouvert : ".$GLOBALS['_GALERIE_']['dossier'];
150
	}
151
} else {
152
	$GLOBALS['_GALERIE_']['erreur'] = "Applette GALERIE : le dossier d'images est introuvable à : ".$GLOBALS['_GALERIE_']['dossier'];
153
}
154
//trigger_error('<pre>'.print_r($images, true).'</pre>', E_USER_WARNING);
155
if($noimage) {
156
	$GLOBALS['_GALERIE_']['css']['chemin'] = GAL_CHEMIN_STYLES_RELATIF;
157
	$GLOBALS['_GALERIE_']['css']['largeur'] = $options['largeur'];
158
	$GLOBALS['_GALERIE_']['script']['chemin'] = GAL_CHEMIN_SCRIPTS_RELATIF;
159
	$GLOBALS['_GALERIE_']['images'] = array();
160
	foreach($images as $image) {
161
		if ($image['filename'] != '') {
162
			$aso_img['fichier_nom'] = $image['filename'];
163
			$aso_img['title'] = $image['titre'];
164
			$aso_img['url_img'] = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).DS.GAL_CHEMIN_SCRIPTS_RELATIF.'showthumb.php?img='.urlencode(GAL_CHEMIN_RACINE.$options['dossier'].DS.$image['filename']).'&amp;width='.$options['img_largeur'].'&amp;height='.$options['img_hauteur'].'&amp;quality='.$options['img_qualite'].'&amp;centrage=0';
165
			$aso_img['url_img_mini'] = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).DS.GAL_CHEMIN_SCRIPTS_RELATIF.'showthumb.php?img='.urlencode(GAL_CHEMIN_RACINE.$options['dossier'].DS.$image['filename']).'&amp;width='.$options['largeur'].'&amp;height='.$options['hauteur'].'&amp;quality='.$options['qualite'].'&amp;centrage=1';
166
			$GLOBALS['_GALERIE_']['images'][] = $aso_img;
167
		}
168
 	}
169
} else {
170
	$GLOBALS['_GALERIE_']['erreur'] = "Applette GALERIE : le dossier d'images ne contient rien : ".$GLOBALS['_GALERIE_']['dossier'];
171
}
172
 
173
//+----------------------------------------------------------------------------------------------------------------+
174
// Gestion des squelettes
175
// Extrait les variables et les ajoutes à l'espace de noms local
176
extract($GLOBALS['_GALERIE_']);
177
// Démarre le buffer
178
ob_start();
179
// Inclusion du fichier
180
include GAL_CHEMIN_SQUELETTE.$options['squelette'];
181
// Récupérer le  contenu du buffer
182
$sortie = ob_get_contents();
183
// Arrête et détruit le buffer
184
ob_end_clean();
185
 
186
//+----------------------------------------------------------------------------------------------------------------+
187
// Sortie
188
echo $sortie;
189
 
190
/* +--Fin du code ----------------------------------------------------------------------------------------+
191
*
192
* $Log$
193
*
194
* +-- Fin du code ----------------------------------------------------------------------------------------+
195
*/
196
?>