Subversion Repositories Applications.papyrus

Rev

Rev 474 | 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
// +------------------------------------------------------------------------------------------------------+
692 alexandre_ 22
// CVS : $Id: HTML_listeParticipants.class.php,v 1.3 2006-01-11 10:32:09 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
692 alexandre_ 34
*@version       $Revision: 1.3 $
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,
692 alexandre_ 120
 
121
            if (strlen ($elements[$i][2]) > 10) {
122
            	$mail_racourci = substr($elements[$i][2], 0, 10).'...' ;
123
            }
124
 
125
            $this->setCellContents ($i+1, 2, '<a href="mailto:'.$elements[$i][2].'">'.$mail_racourci.'</a>') ;
448 ddelon 126
 
127
            // Mise à jour de la cellule contenant le statut
128
            if ($this->_mode == 1) {
129
                $this->_url->addQueryString ('id_utilisateur', $id_utilisateur) ;
130
                $select = '<form action="'.$this->_url->getURL().'" method="post">'."\n" ;
131
                $select .= '<select name="statut" onchange="javascript:this.form.submit();">' ;
132
                foreach ($tableau_statut as $cle =>$element_statut) {
133
                    $select .= '<option value="'.$cle.'"' ;
134
                    if ($cle == $id_statut) {
135
                        $select .= ' selected="selected"' ;
136
                    }
137
                    $select .= '>'.$element_statut.'</option>'."\n" ;
138
                }
139
                $select .= '</select>'."\n".'</form>'."\n" ;
140
                $this->setCellContents($i+1, 4, $select) ;
141
            }
142
            if ($id_statut == 1 && $this->_mode != 1) {
143
                $this->setCellContents($i + 1, 4, PROJET_CHEF) ;
144
                $this->updateRowAttributes ($i + 1, array('style' => 'font-weight:bold'), true) ;
145
            }
146
            if ($this->_mode != 1 && $id_statut != 1) {
147
                $this->setCellContents($i + 1, 4, $tableau_statut[$id_statut]) ;
148
            }
474 alexandre_ 149
            $this->updateCellAttributes ($i + 1, 0, array ('class' => 'nom')) ;
150
            $this->updateCellAttributes ($i + 1, 1, array ('class' => 'prenom')) ;
448 ddelon 151
        }
152
 
153
    } // end of member function construitListe
154
 
155
    /**
156
     *
157
     *
158
     * @return void
159
     * @access public
160
     */
161
    function setModeModification( )
162
    {
163
        $this->_mode = 1 ;
164
    } // end of member function setModeModification
165
 
166
    /**
167
     * Renvoie le code HTML de la table.
168
     *
169
     * @return string
170
     * @access public
171
     */
172
    function toHTML( )
173
    {
174
        // Application de style
474 alexandre_ 175
        $this->altRowAttributes(1, array('class' =>'ligne_paire'), array('class' =>'ligne_impaire'), true) ;
448 ddelon 176
 
177
        // s'il n'y a qu'une seule ligne, on renvoie un message indiquant qu'il n'y a pas de participants
178
        if ($this->getRowCount() == 1) {
179
            return '<div>'.PROJET_PAS_D_INSCRIT.'</div>'."\n";
180
        }
181
 
182
        $res = HTML_Table::toHTML() ;
183
 
184
        return $res ;
185
    } // end of member function toHTML
186
 
187
    /**
188
     * Fixe la valeur de l'URL
189
     *
190
     * @param Net_URL url Un pointeur vers un objet Net_URL
191
     * @return void
192
     * @access public
193
     */
194
    function setURL( &$url )
195
    {
196
        $this->_url = $url ;
197
    } // end of member function setURL
198
 
199
} // end of HTML_listeParticipants
200
?>