Subversion Repositories Applications.papyrus

Rev

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

Rev Author Line No. Line
448 ddelon 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 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
// | General Public License for more details.                                                             |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU 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
// +------------------------------------------------------------------------------------------------------+
1306 alexandre_ 22
// CVS : $Id: HTML_listeDocuments.class.php,v 1.7.2.1 2007-04-11 12:31:53 alexandre_tb Exp $
448 ddelon 23
/**
24
* Application projet
25
*
26
* La classe HTML_listeDocuments
27
*
28
*@package projet
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2004
1306 alexandre_ 34
*@version       $Revision: 1.7.2.1 $
448 ddelon 35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
 
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
42
 
43
 
44
// +------------------------------------------------------------------------------------------------------+
45
// |                                           LISTE des constantes                                       |
46
// +------------------------------------------------------------------------------------------------------+
47
 
48
define ("FICHIER_ICONE_COUPER", "cut.gif") ;
49
define ("FICHIER_ICONE_COLLER", "paste.gif") ;
50
define ("FICHIER_ICONE_SUPPRIMER", "trash.gif") ;
51
define ("FICHIER_ICONE_MODIFIER", "modif.png") ;
52
 
1306 alexandre_ 53
 
54
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php';
448 ddelon 55
/**
56
 * class HTML_listeDocuments
57
 *
58
 */
1306 alexandre_ 59
 
60
 
61
 
448 ddelon 62
class HTML_listeDocuments extends HTML_Liste
63
{
64
    /*** Attributes: ***/
65
 
66
    /**
67
     * Une url.
68
     * @access private
69
     */
70
    var $_url;
71
 
72
    /**
73
     * Tableau contenant les actions possibles. "couper" => 1, "modifier" => 2,
74
     * "supprimer" => 3 Elles seront passées en paramètre aux url des icones des
75
     * documents.
76
     * @access private
77
     */
78
    var $_actions = array ("couper" => 1, "modifier" => 2, "supprimer" => 3) ;
79
 
80
    /**
81
     * Indique le chemin des icones couper, coller, modifier, supprimer.
82
     * @access private
83
     */
84
    var $_chemin_icone = "icones/";
85
 
86
    /**
87
     * L'identifiant du répertoire que l'on est en train d'observer.
88
     * @access private
89
     */
90
    var $_id_repertoire;
91
 
92
    /**
93
     * Un tableau contenant les id et les noms du chemin des répertoires. 0 => ["id"],
94
     * ["nom"] etc.
95
     * @access private
96
     */
97
    var $_chemin_navigation = array ();
98
 
99
    /**
100
     * un pointeur vers une authentificatin PEAR
101
     * @access private
102
     */
103
    var $_auth ;
104
    /**
105
     *
106
     *
107
     * @param bool utilise_pager Indique l'utilisation ou non du Pager.
108
     * @return void
109
     * @access public
110
     */
111
    function HTML_listeDocuments(&$url,  $utilise_pager = false, $id_repertoire = 0, $auth = '' )
112
    {
113
        HTML_Liste::HTML_Liste($utilise_pager, array('class' => 'table_cadre')) ;
114
        $this->_url = $url ;
115
 
116
        $this->_id_repertoire = $id_repertoire ;
117
        if (is_object($auth)) {
118
            $this->_auth = $auth ;
119
        }
120
    } // end of member function HTML_listeDocuments
121
 
122
    /**
123
     *
124
     *
125
     * @param bool utilise_pager Voir HTML_listeDocuments
126
     * @return void
127
     * @access public
128
     */
481 ddelon 129
    function __construct( &$url,  $utilise_pager = false, $id_repertoire = 0, $auth = '' )
448 ddelon 130
    {
481 ddelon 131
        $this->HTML_listeDocuments($url,  $utilise_pager, $id_repertoire, $auth);
448 ddelon 132
 
133
    } // end of member function __construct
134
 
135
    /**
136
     *
137
     *
138
     * @param Array tableau_label Un tableau contenant les labels à afficher dans l'entête.
139
     * @return void
140
     * @access public
141
     */
142
    function construitEntete( $tableau_label )
143
    {
144
        $this->addRow ($tableau_label, NULL, 'TH') ;
145
    } // end of member function construitEntete
146
 
147
    /**
148
     *
149
     *
150
     * @param Array tableau_label Un tableau à deux dimensions avec les labels à afficher dans le corps du
151
     * tableau.
152
     * @return void
153
     * @access public
154
     */
155
    function construitListe( &$tableau_document, $droits, $mode = '', $objetDB = '')
156
    {
157
        $compteur = 0 ;$class[0] = 'ligne_impaire'; $class[1] = 'ligne_paire' ;
158
 
159
        for ($i = 0; $i < count ($tableau_document) ; $i++) {
160
            // Première condition : est-ce que le fichier a pour père le répertoire courant, si oui on l'affiche
161
            if ($tableau_document[$i]->_id_pere == $this->_id_repertoire || $mode == 'ignore_repertoire') {
162
                // d'abord l'image
163
                $icone = '<img src="'.$tableau_document[$i]->getCheminIcone().'" />' ;
164
                // Si le document est un répertoire, on ajoute id_repertoire au lien.
165
                if ($tableau_document[$i]->isRepertoire()) {
166
                    $this->_url->addQueryString ('id_repertoire', $tableau_document[$i]->getChemin()) ;
167
                    $lien = $this->_url->getURL() ;
168
                } else {    //  Si c'est un fichier, on fait un lien direct
169
                    $lien = $tableau_document[$i]->getChemin() ;
170
                }
171
                // pour éviter des effets de bords, on enlève id_repertoire de l'url
172
                // dans le cas d'un répertoire, pour les fichiers on le laisse pour
173
                // qu'après une opération, on reste dans le répertoire où a eu lieu l'opération
174
                if ($tableau_document[$i]->isRepertoire()) $this->_url->removeQueryString('id_repertoire') ;
175
 
176
                // on insère le lien
177
                $lien_nom = '<a href="'.$lien.'">'.$icone.' '.$tableau_document[$i]->getNomLong()."</a>\n" ;
178
 
179
                // Pour la taille on divise par 1000 et on écrit Ko
180
                $taille = round($tableau_document[$i]->getTaille() / 1000).'&nbsp;Ko' ;
181
 
182
                // Récupération de l'auteur
183
                include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
184
                $annuaire = new annuaire($objetDB, array('table' => PROJET_ANNUAIRE, 'identifiant' => PROJET_CHAMPS_ID,
185
                                            'nom' => PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
186
                $annuaire->setId($tableau_document[$i]->_id_proprietaire) ;
187
                $nom_prenom = $annuaire->getInfo('nom').' '.$annuaire->getInfo('prenom') ;
188
                // On rempli le tableau à donner en paramètre à HTML_Table avec toutes ces infos, une par colonne
189
                $ligne_tableau = array($lien_nom, $taille, $nom_prenom, $tableau_document[$i]->getDateMiseAJour()) ;
190
                if ($droits <= PROJET_DROIT_CONTRIBUTEUR) array_push ($ligne_tableau, $tableau_document[$i]->getVisibilite()) ;
191
 
192
                // On ajoute au tableau, les action couper / modifier / supprimer
193
                if ($droits <= PROJET_DROIT_COORDINATEUR || $this->_auth->getAuthData(PROJET_CHAMPS_ID) == $tableau_document[$i]->_id_proprietaire)
194
                                                array_push ($ligne_tableau, $this->_actions ($tableau_document[$i])) ;
764 alexandre_ 195
                if ($tableau_document[$i]->getVisibilite() != 'prive' || $droits < PROJET_DROIT_AUCUN) {
196
	                $this->addRow ($ligne_tableau, array('class' => $class[$compteur]), 'TD', true) ;
197
	                // enfin , s'il y a une description, on l'ajoute, mais sur une ligne entière (colspan)
198
	                if ($tableau_document[$i]->getDescription() != "") {
199
	                    $this->addRow (array ($tableau_document[$i]->getDescription()),
200
	                    		array ('colspan' => $this->getColCount(), 'class' => $class[$compteur])) ;
905 alexandre_ 201
	                    $this->updateRowAttributes ($this->getRowCount()-1, array ('class' => $class[$compteur]), true) ;
764 alexandre_ 202
	                }
448 ddelon 203
                }
204
                $compteur++;
205
            }
206
 
207
            if ($compteur == 2) $compteur = 0 ;
208
        }
209
        $this->updateColAttributes(0, array ('class' => 'col1')) ;
210
    } // end of member function construitListe
211
 
212
    /**
213
     *
214
     *
215
     * @param Array actions Un tableau avec les valeurs d'actions comme clé. "couper", modifier",
216
     * "supprimer".
217
     * @return void
218
     * @access public
219
     */
220
    function setAction( $actions )
221
    {
222
        $this->_actions = $actions ;
223
    } // end of member function setAction
224
 
225
    /**
226
     *
227
     *
228
     * @param string chemin Le chemin vers les icones couper, coller ...
229
     * @return void
230
     * @access public
231
     */
232
    function setCheminIcones( $chemin )
233
    {
234
        $this->_chemin_icone = $chemin ;
235
    } // end of member function setCheminIcones
236
 
237
    /**
238
     * Surcharge de l'opération de la classe mère. Ajoute la navigation dans les
239
     * répertoires.
240
     *
241
     * @return string
242
     * @access public
243
     */
244
    function toHTML( )
245
    {
246
        $chemin_navig = "" ;
247
        if ($this->_id_repertoire != "") {
474 alexandre_ 248
            $this->_url->removeQueryString(PROJET_VARIABLE_ID_REPERTOIRE) ;
448 ddelon 249
            $chemin_navig = "<p>" ;
250
            $chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".PROJET_RACINE."</a>\n" ;
474 alexandre_ 251
            $this->_url->addQueryString(PROJET_VARIABLE_ID_REPERTOIRE, $this->_id_repertoire) ;
448 ddelon 252
            for ($i = 0; $i < count ($this->_chemin_navigation); $i+=2) {
253
                $chemin_navig .= "&gt;&nbsp;" ;
254
                $nom = $this->_chemin_navigation[$i+1] ;
255
                $this->_url->addQueryString ('id_repertoire', $this->_chemin_navigation[$i]) ;
256
                $chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".$nom."</a>\n" ;
257
            }
258
            $chemin_navig .= "</p>\n" ;
259
        }
260
        $res = $chemin_navig.HTML_Liste::toHTML() ;
261
        if ($this->getRowCount() == 1 && $this->_id_repertoire == '') {
262
            return '<div>'.PROJET_PAS_DE_DOCUMENTS.'</div>'."\n";
263
        }
264
        return $res ;
265
    } // end of member function toHTML
266
 
267
    /**
268
     *
269
     *
270
     * @param Array tableau_navigation Un tableau contenant les identifiants et les noms des répertoires.  0 => ["id"],
271
     * ["nom"] etc.
272
     * @return void
273
     * @access public
274
     */
275
    function setCheminNavigation( $tableau_navigation )
276
    {
277
        $this->_chemin_navigation = $tableau_navigation ;
278
    } // end of member function setCheminNavigation
279
 
280
    /**
281
     * Affiche la légende des actions du module "documents"
282
     *
283
     * @return string
284
     * @access public
285
     */
286
    function affLegende( )
287
    {
288
        $res = "<h2 class=\"titre2_projet\">".PROJET_LEGENDE."</h2>\n" ;
289
        $res .= "<p><img src=\"".$this->_chemin_icone."/cut.gif\" title=\"couper\" alt=\"couper\">".PROJET_LEGENDE_DEPLACE."</p>\n" ;
290
        $res .= "<p><img src=\"".$this->_chemin_icone."/modif.png\" title=\"modifier\" alt=\"modifier\"> ".PROJET_LEGENDE_MODIFIE."</p>\n" ;
291
        $res .= "<p><img src=\"".$this->_chemin_icone."/trash.gif\" title=\"supprimer\" alt=\"supprimer\"> ".PROJET_LEGENDE_SUPPR."</p>\n" ;
292
        return $res ;
293
    } // end of member function affLegende
294
 
295
 
296
    /**
297
     * Renvoie le chemin HTML, depuis le répertoire courant jusqu'à la racine.
298
     *
299
     * @return string
300
     * @access private
301
     */
302
    function _getCheminHTML( )
303
    {
304
        $path = "" ;
305
 
306
        return $path ;
307
    } // end of member function _getCheminHTML
308
 
309
 
310
 
311
    /**
312
     * Renvoie une chaine contenant le code html des icones des actions possibles sur un
313
     * fichier, c'est à dire couper, modifier, supprimer.
314
     *
315
     * @return string
316
     * @access private
317
     */
318
    function _actions($document)
319
    {
320
        $this->_url->addQueryString ('id_document', $document->getIdDocument()) ;
321
 
322
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["couper"]) ;
692 alexandre_ 323
        $couper = ' '.PROJET_FICHIER_COUPER ;
448 ddelon 324
        if (!$document->isRepertoire()) $couper = '<a href="'.$this->_url->getURL().'">'.$couper.'</a>' ;
325
 
326
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["modifier"]) ;
692 alexandre_ 327
        $modifier = '<a href="'.$this->_url->getURL().'">'.PROJET_FICHIER_MODIFIER.'</a> ' ;
448 ddelon 328
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["supprimer"]) ;
329
        $supprimer= '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm (\''.PROJET_FICHIER_SUPPRIMER.' ?\');">'.PROJET_FICHIER_SUPPRIMER.'</a>' ;
330
        $this->_url->removeQueryString ('id_document') ;
331
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_DOCUMENT) ;
332
        return $modifier.$supprimer.$couper ;
333
    } // end of member function _action
334
 
335
 
336
} // end of HTML_listeDocuments
337
?>