Subversion Repositories Applications.papyrus

Rev

Rev 448 | 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
// +------------------------------------------------------------------------------------------------------+
474 alexandre_ 22
// CVS : $Id: HTML_listeParticipants.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $
448 ddelon 23
/**
24
* Application projet
25
*
26
* La classe HTML_listeParticipants
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
474 alexandre_ 34
*@version       $Revision: 1.2 $
448 ddelon 35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
 
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
42
 
43
include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php' ;
44
 
45
 
46
/**
47
 * class HTML_listeParticipants
48
 *
49
 */
50
class HTML_listeParticipants extends HTML_Liste
51
{
52
     /*** Attributes: ***/
53
 
54
    /**
55
     * Le mode, par défaut 0 => normal 1 => modification En mode modification, une
56
     * colonne de plus pour désinscrire un utilisateur
57
     * @access private
58
     */
59
    var $_mode;
60
    /**
61
     * L'url vers la page affichant la liste
62
     * @access private
63
     */
64
    var $_url;
65
 
66
    /**
67
     *
68
     *
69
     * @return void
70
     * @access public
71
     */
72
    function HTML_listeParticipants( $utilise_pager)
73
    {
74
        HTML_Liste::HTML_Liste($utilise_pager, array('class' => 'table_cadre')) ;
75
    } // end of member function HTML_listeParticipants
76
 
77
    /**
78
     *
79
     *
80
     * @param Array elements Tableau des éléments de l'entête. Des labels.
81
     * @return void
82
     * @access public
83
     */
84
    function construitEntete( $elements )
85
    {
86
        if ($this->_mode == 1) {
87
            array_push ($elements, PROJET_SUPPRIMER) ;
88
        }
89
        $this->addRow ($elements, '', 'TH') ;
90
    } // end of member function construitEntete
91
 
92
    /**
93
     *
94
     *
95
     * @param Array elements Tableau à deux dimension contenant les éléments à afficher.
96
     * @return void
97
     * @access public
98
     */
99
    function construitListe( $elements, $tableau_statut = '' )
100
    {
101
        for ($i = 0; $i < count ($elements) ; $i++) {
102
            // L'identifiant de l'utilisateur est le premier élément du tableau
103
            $id_utilisateur = array_shift ($elements[$i]) ;
104
 
105
            // L'identifiant du statut est le dernier
106
            $id_statut = (int) array_pop ($elements[$i]) ;
107
            // En mode modif on ajoute la colonne supprimer
108
            if ($this->_mode == 1) {
109
                $this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ;
110
                $this->_url->addQueryString('statut', 4) ;
111
                array_push ($elements[$i], '', '<a href="'.$this->_url->getURL().'" onclick="javascript:return confirm(\''.PROJET_SUPPRIMER.' ?\')">'
112
                                                .PROJET_SUPPRIMER.'</a>');
113
                $this->_url->removeQueryString('statut') ;
114
            }
115
 
116
            $this->addRow ($elements[$i]) ;
117
            // mise à jour du champs mail en l'entourant par la balise mailto
118
 
119
            ///                     $i+1 pour sauter la ligne de titre,
120
            $this->setCellContents ($i+1, 2, '<a href="mailto:'.$elements[$i][2].'">'.$elements[$i][2].'</a>') ;
121
 
122
            // Mise à jour de la cellule contenant le statut
123
            if ($this->_mode == 1) {
124
                $this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ;
125
                $select = '<form action="'.$this->_url->getURL().'" method="post">'."\n" ;
126
                $select .= '<select name="statut" onchange="javascript:this.form.submit();">' ;
127
                foreach ($tableau_statut as $cle =>$element_statut) {
128
                    $select .= '<option value="'.$cle.'"' ;
129
                    if ($cle == $id_statut) {
130
                        $select .= ' selected="selected"' ;
131
                    }
132
                    $select .= '>'.$element_statut.'</option>'."\n" ;
133
                }
134
                $select .= '</select>'."\n".'</form>'."\n" ;
135
                $this->setCellContents($i+1, 4, $select) ;
136
            }
137
            if ($id_statut == 1 && $this->_mode != 1) {
138
                $this->setCellContents($i + 1, 4, PROJET_CHEF) ;
139
                $this->updateRowAttributes ($i + 1, array('style' => 'font-weight:bold'), true) ;
140
            }
141
            if ($this->_mode != 1 && $id_statut != 1) {
142
                $this->setCellContents($i + 1, 4, $tableau_statut[$id_statut]) ;
143
            }
474 alexandre_ 144
            $this->updateCellAttributes ($i + 1, 0, array ('class' => 'nom')) ;
145
            $this->updateCellAttributes ($i + 1, 1, array ('class' => 'prenom')) ;
448 ddelon 146
        }
147
 
148
    } // end of member function construitListe
149
 
150
    /**
151
     *
152
     *
153
     * @return void
154
     * @access public
155
     */
156
    function setModeModification( )
157
    {
158
        $this->_mode = 1 ;
159
    } // end of member function setModeModification
160
 
161
    /**
162
     * Renvoie le code HTML de la table.
163
     *
164
     * @return string
165
     * @access public
166
     */
167
    function toHTML( )
168
    {
169
        // Application de style
474 alexandre_ 170
        $this->altRowAttributes(1, array('class' =>'ligne_paire'), array('class' =>'ligne_impaire'), true) ;
448 ddelon 171
 
172
        // s'il n'y a qu'une seule ligne, on renvoie un message indiquant qu'il n'y a pas de participants
173
        if ($this->getRowCount() == 1) {
174
            return '<div>'.PROJET_PAS_D_INSCRIT.'</div>'."\n";
175
        }
176
 
177
        $res = HTML_Table::toHTML() ;
178
 
179
        return $res ;
180
    } // end of member function toHTML
181
 
182
    /**
183
     * Fixe la valeur de l'URL
184
     *
185
     * @param Net_URL url Un pointeur vers un objet Net_URL
186
     * @return void
187
     * @access public
188
     */
189
    function setURL( &$url )
190
    {
191
        $this->_url = $url ;
192
    } // end of member function setURL
193
 
194
} // end of HTML_listeParticipants
195
?>