Subversion Repositories Applications.projet

Rev

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

Rev Author Line No. Line
2 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
// +------------------------------------------------------------------------------------------------------+
249 alexandre_ 22
// CVS : $Id: HTML_listeDocuments.class.php,v 1.9 2007-06-25 12:15:06 alexandre_tb Exp $
2 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
249 alexandre_ 34
*@version       $Revision: 1.9 $
2 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
 
208 neiluj 53
 
54
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php';
2 ddelon 55
/**
56
 * class HTML_listeDocuments
57
 *
58
 */
59
class HTML_listeDocuments extends HTML_Liste
60
{
61
    /*** Attributes: ***/
62
 
63
    /**
64
     * Une url.
65
     * @access private
66
     */
67
    var $_url;
68
 
69
    /**
70
     * Tableau contenant les actions possibles. "couper" => 1, "modifier" => 2,
71
     * "supprimer" => 3 Elles seront passées en paramètre aux url des icones des
72
     * documents.
73
     * @access private
74
     */
75
    var $_actions = array ("couper" => 1, "modifier" => 2, "supprimer" => 3) ;
76
 
77
    /**
78
     * Indique le chemin des icones couper, coller, modifier, supprimer.
79
     * @access private
80
     */
81
    var $_chemin_icone = "icones/";
82
 
83
    /**
249 alexandre_ 84
     * L'identifiant du repertoire que l'on est en train d'observer.
2 ddelon 85
     * @access private
86
     */
87
    var $_id_repertoire;
88
 
89
    /**
90
     * Un tableau contenant les id et les noms du chemin des répertoires. 0 => ["id"],
91
     * ["nom"] etc.
92
     * @access private
93
     */
94
    var $_chemin_navigation = array ();
95
 
96
    /**
97
     * un pointeur vers une authentificatin PEAR
98
     * @access private
99
     */
100
    var $_auth ;
249 alexandre_ 101
 
2 ddelon 102
    /**
249 alexandre_ 103
     * le style d affichage
104
     * @access private
105
     */
106
    var $_mode_affichage ;
107
    /**
2 ddelon 108
     *
109
     *
110
     * @param bool utilise_pager Indique l'utilisation ou non du Pager.
111
     * @return void
112
     * @access public
113
     */
114
    function HTML_listeDocuments(&$url,  $utilise_pager = false, $id_repertoire = 0, $auth = '' )
115
    {
116
        HTML_Liste::HTML_Liste($utilise_pager, array('class' => 'table_cadre')) ;
117
        $this->_url = $url ;
118
 
119
        $this->_id_repertoire = $id_repertoire ;
120
        if (is_object($auth)) {
121
            $this->_auth = $auth ;
122
        }
249 alexandre_ 123
        $this->_mode_affichage = 'standart';
2 ddelon 124
    } // end of member function HTML_listeDocuments
125
 
126
    /**
127
     *
128
     *
129
     * @param bool utilise_pager Voir HTML_listeDocuments
130
     * @return void
131
     * @access public
132
     */
249 alexandre_ 133
    function __construct( &$url,  $utilise_pager = false, $id_repertoire = 0, $auth = '', $id_projet = '' )
2 ddelon 134
    {
15 ddelon 135
        $this->HTML_listeDocuments($url,  $utilise_pager, $id_repertoire, $auth);
2 ddelon 136
 
137
    } // end of member function __construct
138
 
139
    /**
140
     *
141
     *
142
     * @param Array tableau_label Un tableau contenant les labels à afficher dans l'entête.
143
     * @return void
144
     * @access public
145
     */
146
    function construitEntete( $tableau_label )
147
    {
148
        $this->addRow ($tableau_label, NULL, 'TH') ;
249 alexandre_ 149
    }
2 ddelon 150
 
151
    /**
152
     *
153
     *
249 alexandre_ 154
     * @param Array tableau_label Un tableau a deux dimensions avec les labels a afficher dans le corps du
2 ddelon 155
     * tableau.
156
     * @return void
157
     * @access public
158
     */
249 alexandre_ 159
    function construitListe( &$tableau_document, $droits, $mode = '', $objetDB = '', $id_projet = '')
2 ddelon 160
    {
249 alexandre_ 161
        if ($this->_mode_affichage == 'standart') {
162
	        $compteur = 0 ;$class[0] = 'ligne_impaire'; $class[1] = 'ligne_paire' ;
163
 
164
	        for ($i = 0; $i < count ($tableau_document) ; $i++) {
165
	            // Premiere condition : est-ce que le fichier a pour pere le repertoire courant, si oui on l'affiche
166
	            if ($tableau_document[$i]->_id_pere == $this->_id_repertoire || $mode == 'ignore_repertoire') {
167
	                // d'abord l'image
168
	                $icone = '<img src="'.$tableau_document[$i]->getCheminIcone().'" />' ;
169
	                // Si le document est un repertoire, on ajoute id_repertoire au lien.
170
	                if ($tableau_document[$i]->isRepertoire()) {
171
	                    $this->_url->addQueryString ('id_repertoire', $tableau_document[$i]->getIdDocument()) ;
172
	                    $lien = $this->_url->getURL() ;
173
	                } else {    //  Si c'est un fichier, on fait un lien direct
174
	                	$this->_url->addQueryString('id_document', $tableau_document[$i]->getIdDocument());
175
	                	$this->_url->addQueryString('service', 'telechargement');
176
	                    $lien = $this->_url->getURL() ;
177
	                    $this->_url->removeQueryString('service');
104 alexandre_ 178
	                }
249 alexandre_ 179
	                // pour eviter des effets de bords, on enleve id_repertoire de l'url
180
	                // dans le cas d'un repertoire, pour les fichiers on le laisse pour
181
	                // qu'apres une operation, on reste dans le repertoire ou a eu lieu l'operation
182
	                if ($tableau_document[$i]->isRepertoire()) $this->_url->removeQueryString('id_repertoire') ;
183
 
184
	                // on insere le lien
185
	                $lien_nom = '<a href="'.$lien.'">'.$icone.' '.$tableau_document[$i]->getNomLong()."</a>\n" ;
186
 
187
	                $taille = $tableau_document[$i]->getTailleFormatee();
188
 
189
	                // Recuperation de l'auteur
190
	                include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
191
	                $annuaire = new annuaire($objetDB, array('table' => PROJET_ANNUAIRE, 'identifiant' => PROJET_CHAMPS_ID,
192
	                                            'nom' => PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
193
	                $annuaire->setId($tableau_document[$i]->_id_proprietaire) ;
194
	                $nom_prenom = $annuaire->getInfo('nom').' '.$annuaire->getInfo('prenom') ;
195
	                // On rempli le tableau a donner en parametre a HTML_Table avec toutes ces infos, une par colonne
196
	                $ligne_tableau = array($lien_nom, $taille, $nom_prenom, $tableau_document[$i]->getDateMiseAJour()) ;
197
	                if ($droits <= PROJET_DROIT_CONTRIBUTEUR) array_push ($ligne_tableau, $tableau_document[$i]->getVisibilite()) ;
198
 
199
	                // On ajoute au tableau, les action couper / modifier / supprimer
200
	                if ($droits <= PROJET_DROIT_COORDINATEUR || $this->_auth->getAuthData(PROJET_CHAMPS_ID) == $tableau_document[$i]->_id_proprietaire)
201
	                                                array_push ($ligne_tableau, $this->_actions ($tableau_document[$i])) ;
202
	                if ($tableau_document[$i]->getVisibilite() != 'prive' || $droits < PROJET_DROIT_AUCUN) {
203
		                $this->addRow ($ligne_tableau, array('class' => $class[$compteur]), 'TD', true) ;
204
		                // enfin , s'il y a une description, on l'ajoute, mais sur une ligne entière (colspan)
205
		                if ($tableau_document[$i]->getDescription() != "") {
206
		                    $this->addRow (array ($tableau_document[$i]->getDescription()),
207
		                    		array ('colspan' => $this->getColCount(), 'class' => $class[$compteur])) ;
208
		                    $this->updateRowAttributes ($this->getRowCount()-1, array ('class' => $class[$compteur]), true) ;
209
		                }
210
	                }
211
	                $compteur++;
212
	            }
213
 
214
	            if ($compteur == 2) $compteur = 0 ;
215
	        }
216
	        $this->_url->removeQueryString('id_document');
217
	        $this->updateColAttributes(0, array ('class' => 'col1')) ;
218
        } else {
219
 
2 ddelon 220
        }
221
    } // end of member function construitListe
222
 
223
    /**
224
     *
225
     *
249 alexandre_ 226
     * @param Array actions Un tableau avec les valeurs d'actions comme cle. "couper", modifier",
2 ddelon 227
     * "supprimer".
228
     * @return void
229
     * @access public
230
     */
231
    function setAction( $actions )
232
    {
233
        $this->_actions = $actions ;
249 alexandre_ 234
    }
235
 
236
    /**
237
     *
238
     *
239
     * @param string le mode, valeur possible standart ou ajax
240
     * @return void
241
     * @access public
242
     */
243
    function setModeAffichage( $mode )
244
    {
245
        $this->_mode_affichage = $mode ;
246
    }
2 ddelon 247
 
249 alexandre_ 248
 
2 ddelon 249
    /**
250
     *
251
     *
252
     * @param string chemin Le chemin vers les icones couper, coller ...
253
     * @return void
254
     * @access public
255
     */
256
    function setCheminIcones( $chemin )
257
    {
258
        $this->_chemin_icone = $chemin ;
249 alexandre_ 259
    }
2 ddelon 260
 
261
    /**
249 alexandre_ 262
     * Surcharge de l'operation de la classe mere. Ajoute la navigation dans les
263
     * repertoires.
2 ddelon 264
     *
265
     * @return string
266
     * @access public
267
     */
249 alexandre_ 268
    function toHTML($id_projet = '', $droits)
2 ddelon 269
    {
249 alexandre_ 270
        if ($this->_mode_affichage == 'standart') {
271
	        $chemin_navig = "" ;
272
	        if ($this->_id_repertoire != "") {
273
	            $this->_url->removeQueryString(PROJET_VARIABLE_ID_REPERTOIRE) ;
274
	            $chemin_navig = "<p>" ;
275
	            $chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".PROJET_RACINE."</a>\n" ;
276
	            $this->_url->addQueryString(PROJET_VARIABLE_ID_REPERTOIRE, $this->_id_repertoire) ;
277
	            for ($i = 0; $i < count ($this->_chemin_navigation); $i++) {
278
	                $chemin_navig .= "&gt;&nbsp;" ;
279
	                $doc = new document ($this->_chemin_navigation[$i], $GLOBALS['projet_db']);
280
	                $nom = $doc->getNomLong() ;
281
	                $this->_url->addQueryString ('id_repertoire', $this->_chemin_navigation[$i]) ;
282
	                $chemin_navig .= "<a href=\"".$this->_url->getURL()."\">".$nom."</a>\n" ;
283
	            }
284
	            $chemin_navig .= "</p>\n" ;
285
	        }
286
	        $res = $chemin_navig.HTML_Liste::toHTML() ;
287
	        if ($this->getRowCount() == 1 && $this->_id_repertoire == '') {
288
	            return '<div>'.PROJET_PAS_DE_DOCUMENTS.'</div>'."\n";
289
	        }
290
        } else {
291
        	GEN_stockerFichierScript('dojo', 'api/js/dojo/dojo.js', 'text/javascript');
292
        	GEN_stockerFichierScript('dojoScriptProjet', 'client/projet/js/arbreDocument.js');
293
 
294
			$res = '' ;
295
 
296
			$RCPUrl = PROJET_CHEMIN_APPLI.'services/ecouteArbreFichier.php?id_projet='.$id_projet;
297
			$this->_url->addQueryString(PROJET_VARIABLE_SERVICE, 'ecouteArbreFichier');
298
 
299
			$RCPUrl = $this->_url->getURL();
300
			// Le noeud racine
301
 
302
			if ($droits <= PROJET_DROIT_CONTRIBUTEUR) {
303
				$tree = '<div dojoType="Tree" DNDMode="between" selector="treeSelector" DNDAcceptTypes="bandTree" widgetId="bandTree" controller="treeController" eventNames="moveTo:nodeRemoved">';
304
			} else {
305
				$tree = '<div dojoType="Tree" selector="treeSelector" DNDAcceptTypes="bandTree" widgetId="bandTree" controller="treeController">';
306
			}
307
	        $res .= '<div dojoType="TreeLoadingController" RPCUrl="'.$RCPUrl.'" widgetId="treeController" DNDController="create"></div>
308
				<div dojoType="TreeSelector" widgetId="treeSelector"></div>'.$tree.
309
				'<div dojoType="TreeNode" title="Racine" widgetId="rootNode" objectId="root" isFolder="true"></div></div>';
310
 
2 ddelon 311
        }
312
        return $res ;
313
    } // end of member function toHTML
314
 
315
    /**
316
     *
317
     *
249 alexandre_ 318
     * @param Array tableau_navigation Un tableau contenant les identifiants et les noms des repertoires.  0 => ["id"],
2 ddelon 319
     * ["nom"] etc.
320
     * @return void
321
     * @access public
322
     */
323
    function setCheminNavigation( $tableau_navigation )
324
    {
325
        $this->_chemin_navigation = $tableau_navigation ;
326
    } // end of member function setCheminNavigation
327
 
328
    /**
249 alexandre_ 329
     * Affiche la legende des actions du module "documents"
2 ddelon 330
     *
331
     * @return string
332
     * @access public
333
     */
334
    function affLegende( )
335
    {
336
        $res = "<h2 class=\"titre2_projet\">".PROJET_LEGENDE."</h2>\n" ;
337
        $res .= "<p><img src=\"".$this->_chemin_icone."/cut.gif\" title=\"couper\" alt=\"couper\">".PROJET_LEGENDE_DEPLACE."</p>\n" ;
338
        $res .= "<p><img src=\"".$this->_chemin_icone."/modif.png\" title=\"modifier\" alt=\"modifier\"> ".PROJET_LEGENDE_MODIFIE."</p>\n" ;
339
        $res .= "<p><img src=\"".$this->_chemin_icone."/trash.gif\" title=\"supprimer\" alt=\"supprimer\"> ".PROJET_LEGENDE_SUPPR."</p>\n" ;
340
        return $res ;
249 alexandre_ 341
    }
2 ddelon 342
 
343
 
344
    /**
249 alexandre_ 345
     * Renvoie le chemin HTML, depuis le repertoire courant jusqu'a la racine.
2 ddelon 346
     *
347
     * @return string
348
     * @access private
349
     */
350
    function _getCheminHTML( )
351
    {
352
        $path = "" ;
353
 
354
        return $path ;
249 alexandre_ 355
    }
2 ddelon 356
 
357
    /**
358
     * Renvoie une chaine contenant le code html des icones des actions possibles sur un
249 alexandre_ 359
     * fichier, c'est a dire couper, modifier, supprimer.
2 ddelon 360
     *
361
     * @return string
362
     * @access private
363
     */
364
    function _actions($document)
365
    {
366
        $this->_url->addQueryString ('id_document', $document->getIdDocument()) ;
367
 
368
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["couper"]) ;
95 alexandre_ 369
        $couper = ' '.PROJET_FICHIER_COUPER ;
249 alexandre_ 370
        $couper = '<a href="'.$this->_url->getURL().'">'.$couper.'</a>' ;
2 ddelon 371
 
372
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["modifier"]) ;
95 alexandre_ 373
        $modifier = '<a href="'.$this->_url->getURL().'">'.PROJET_FICHIER_MODIFIER.'</a> ' ;
2 ddelon 374
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, $this->_actions["supprimer"]) ;
375
        $supprimer= '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm (\''.PROJET_FICHIER_SUPPRIMER.' ?\');">'.PROJET_FICHIER_SUPPRIMER.'</a>' ;
376
        $this->_url->removeQueryString ('id_document') ;
377
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_DOCUMENT) ;
378
        return $modifier.$supprimer.$couper ;
379
    } // end of member function _action
380
 
381
 
382
} // end of HTML_listeDocuments
383
?>