Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 5 | Rev 12 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 linda 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
11 linda 22
// CVS : $Id: eflore_photo.inc.php,v 1.3 2004-06-22 12:28:01 linda Exp $
3 linda 23
/**
24
* Titre
25
*
26
* Description
27
*
28
*@package nom_du_paquetage
29
*@subpackage nom_du_sous-paquetage_si_necessaire
30
//Auteur original :
31
*@author        linda ANGAMA<linda_angama@yahoo.fr>
32
//Autres auteurs :
33
*@author        Aucun
34
*@copyright     Tela-Botanica 2000-2004
11 linda 35
*@version       $Revision: 1.3 $ $Date: 2004-06-22 12:28:01 $
3 linda 36
*/
37
 
5 linda 38
 
3 linda 39
$res="";
40
 
5 linda 41
GEN_stockerStyleExterne('photo', GEN_CHEMIN_CLIENT.'eflore/presentations/styles/photo.css');
11 linda 42
 
43
if (isset($_GET['agrandit']))
3 linda 44
{
11 linda 45
$res.="<div>";
46
$res.="<p><a href=\"papyrus.php?site=3&menu=39&onglet=photo&"./*.SID."&*/"deb=".$_SESSION['dep']."\">Retour &agrave; la miniature</a></p>";
47
$res.="<div class=\"debord\"><img src=\"".$_GET['agrandit']."\"></div></div>";
48
//unset($agrandit);
3 linda 49
}
5 linda 50
else
51
{
11 linda 52
    if (!isset($_GET['deb']))    {$deb=0;}
53
    else {$deb=$_GET['deb'];}
54
    $_SESSION['dep']=$deb;
55
    $sep="\"\n";
56
    $img_pg=6;
57
    $img_l=3;
58
    $prec=null;
59
    $suiv=null;
3 linda 60
 
11 linda 61
    //en-tete commune a tous les fichiers rdf
62
    $en_tete="<rdf=RDF";
63
    $en_tete .="\n";
64
    $en_tete .="xmls:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#";
65
    $en_tete .=$sep;
66
    $en_tete .="xmls:dc=\"http://purl.org/dc/elements/1.1/".$sep;
67
    $en_tete .="xmls:dcterms=\"http://purl.org/dc/terms".$sep;
68
    $en_tete .=">"."\n\n";
3 linda 69
 
11 linda 70
    //connexion a la base
71
 
72
    if (DB::isError($GLOBALS['db_eflore']))
73
    {
3 linda 74
        echo "<ERREUR>";
11 linda 75
        echo "Impossible d'&eacutetablir de connexion ",$GLOBALS['db_eflore']->getMessage();
3 linda 76
        echo "</ERREUR>";
77
        exit;
78
    }
79
 
80
 
11 linda 81
    //requete sql
82
    $req="select * from images";
83
    $cond="";
84
//    $cond="where identifier<=7";
85
    $requete="select count('identifier') from images ";
86
    if(!$cond=="")
87
    {
88
        $resultat=$GLOBALS['db_eflore']->query($req." ".$cond);
89
        $cpt=$GLOBALS['db_eflore']->query("select count('identifier') from images ".$cond);
90
        $nbre_ligne=$cpt->fetchRow(DB_FETCHMODE_ORDERED);
91
        //print("nombre de lignes r&eacute;sultat de la requ&ecirc;te : ".$nbre_ligne[0]."<br>");
92
    }
93
    else
94
    {
95
        $resultat=$GLOBALS['db_eflore']->query($req);
96
        $cpt=$GLOBALS['db_eflore']->query("select count('identifier') from images ");
97
        $nbre_ligne=$cpt->fetchRow(DB_FETCHMODE_ORDERED);
98
    }
3 linda 99
 
11 linda 100
    //selection des lignes de la requete &agrave; traiter
3 linda 101
 
11 linda 102
    if (($deb+$img_pg+1)<=($nbre_ligne[0]))
103
    {
104
        $fin=$deb+$img_pg-1;
105
    }
106
    else
107
    {
108
        $fin=$nbre_ligne[0]-1;
109
    }
3 linda 110
 
111
 
112
 
11 linda 113
    //affichage des miniatures et g&eacute;n&eacute;ration des fichiers rdf
114
    if ($fin!==0)
115
    {
116
        $res.="            <ul class=\"liste_photo\">\n";
117
        foreach (range($deb, $fin) as $num_ligne)
118
        {
119
            if (!$ligne = $resultat->fetchrow(DB_FETCHMODE_ORDERED, $num_ligne))
120
            {
121
                break;
122
            }
123
            if ($num_ligne%$img_l==0)
124
            {
125
                $res.="              ";
126
                $res.="<li class=\"colonne\">";
127
                $res.="\n              ";
128
                $res.="<ul>\n";
129
            }
130
            $url_img=$ligne[8];
131
            $url_img_mini=$url_img."mini_photos_plte/mini_";
132
            $url_img_mini .=$ligne[1];
133
            $url_img .=$ligne[1];
134
            $res.="                ";
135
            $res.="<li class=\"ligne\">\n";
136
            $res.="                  ";
137
            $res.="<a href=\"papyrus.php?site=3&menu=39&onglet=photo&agrandit=".$url_img."\">";
138
            $res.="\n                    ";
139
            $res.="<img src=\"".$url_img_mini."\" border=0 />";
140
            $res.="\n                  ";
141
            $res.="</a>";
142
            $res.="\n                  ";
143
            $res.="<p class=\"info\">";
144
            $res.="\n                    ";
145
            $res.="<span class=\"label\">";
146
            $res.="\n                      ";
147
            $res.="num_ligne : ".$num_ligne;
148
            $res.="\n                    ";
149
            $res.="</span>";
150
            $res.="\n                    ";
151
            $res.="<span class=\"label\">";
152
            $res.="\n                      ";
153
            $res.="id: ".$ligne[0]."->".$ligne[1];
154
            $res.="\n                    ";
155
            $res.="</span>";
156
            $res.="\n                  ";
157
            $res.="</p>";
158
            $res.="\n                   ";
159
            $res.="</li>\n";
160
            if ($num_ligne%$img_l==2)
161
            {
162
                $res.="            </ul><div style=\"clear:both;\">&nbsp;</div>\n  \n";
163
            }
164
 
165
 
166
            //g&eacute;n&eacute;ration d'un fichier rdf pour chaque resultat de la requete
167
            $fic=EFLORE_CHEMIN_RDF;
168
            $fic .=$ligne[0];
169
            $fic .=".rdf";
170
            if(!file_exists($fic))
171
            {
172
                $fp=fopen($fic,"w+");
173
                $text_rdf="";
174
                if(!$fp)
175
                {
176
                    $res.="erreur de cr&eacute;ation du fichier rdf";
177
                    exit;
178
                }
179
 
180
                $text_rdf .=$en_tete;
181
 
182
                $text_rdf .="<rdf:Description  rdf:about=\"";
183
                $url_img=$ligne[8];
184
                $url_img .=$ligne[1];
185
                $text_rdf .=$url_img .$sep;
186
 
187
                $text_rdf .="dc:identifier=\"";
188
                $text_rdf .=$ligne[0];
189
                $text_rdf .=$sep;
190
 
191
                $text_rdf .="dc:title=\"";
192
                $text_rdf .=$ligne[1];
193
                $text_rdf .=$sep;
194
 
195
                $text_rdf .="dc:creator=\"";
196
                $text_rdf .=$ligne[2];
197
                $text_rdf .=$sep;
198
 
199
                $text_rdf .="dc:type=\"";
200
                $text_rdf .=$ligne[3];
201
                $text_rdf .=$sep;
202
 
203
                if(!(is_null($ligne[4])))
204
                {
205
 
206
                    $text_rdf .="dcterms:created=\"";
207
                    $text_rdf .=$ligne[4];
208
                    $text_rdf .=$sep;
209
                }
210
 
211
                $text_rdf .=">\n</rdf:Description>\n</rdf:RDF>\n";
212
 
213
                $i=fwrite($fp,$text_rdf);
214
                fclose($fp);
215
            }
216
        }
217
        $res.="</ul>\n";
218
        //affichage des liens suivant/précédent
219
        if ($deb!=0)
220
        {
221
            if (($deb-$img_pg-1)>=0)
222
            {
223
                $prec="<a href=papyrus.php?site=3&menu=39&onglet=photo&deb=".($deb-$img_pg-1).">Pr&eacute;c&eacute;dent</a>";
224
                $res.="<div class=\"prec\">".$prec."</div>";
225
            }
226
            else
227
            {
228
                $prec="<a href=papyrus.php?site=3&menu=39&onglet=photo&deb=0>Pr&eacute;c&eacute;dent</a>";
229
            }
230
            $res.="<div class=\"prec\">".$prec."</div>";
231
        }
232
 
233
        if ($deb+$img_pg<$nbre_ligne[0])
234
        {
235
            $suiv="<a href=papyrus.php?site=3&menu=39&onglet=photo&deb=".($fin+1).">Suivant</a>";
236
            $res.="<div class=\"suiv\">".$suiv."</div>";
237
        }
238
    }
3 linda 239
 
240
}
241
 
242
?>