Subversion Repositories Applications.projet

Rev

Rev 163 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 163 Rev 431
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU General Public                                                  |
9
// | modify it under the terms of the GNU General Public                                                  |
10
// | License as published by the Free Software Foundation; either                                         |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | General Public License for more details.                                                             |
16
// | General Public License for more details.                                                             |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU General Public                                            |
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                                  |
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                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: HTML_formulaireDocument.class.php,v 1.4 2007-02-13 15:11:39 jp_milcent Exp $
22
// CVS : $Id: HTML_formulaireDocument.class.php,v 1.4 2007/02/13 15:11:39 jp_milcent Exp $
23
/**
23
/**
24
* Application projet
24
* Application projet
25
*
25
*
26
* La classe HTML_formulaireDocument
26
* La classe HTML_formulaireDocument
27
*
27
*
28
*@package projet
28
*@package projet
29
//Auteur original :
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
31
//Autres auteurs :
32
*@author        Aucun
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2004
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.4 $
34
*@version       $Revision: 1.4 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
37
 
37
 
38
 
38
 
39
// +------------------------------------------------------------------------------------------------------+
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
41
// +------------------------------------------------------------------------------------------------------+
42
 
42
 
43
/** Inclure le fichier de langue pour utiliser cette classe de façon autonome. */
43
/** Inclure le fichier de langue pour utiliser cette classe de façon autonome. */
44
 
44
 
45
require_once 'HTML/QuickForm.php' ;
45
require_once 'HTML/QuickForm.php' ;
46
require_once 'HTML/QuickForm/checkbox.php' ;
46
require_once 'HTML/QuickForm/checkbox.php' ;
47
require_once 'HTML/QuickForm/select.php' ;
47
require_once 'HTML/QuickForm/select.php' ;
48
 
48
 
49
/**
49
/**
50
 * class HTML_formulaireDocument
50
 * class HTML_formulaireDocument
51
 * 
51
 * 
52
 */
52
 */
53
class HTML_formulaireDocument extends HTML_QuickForm
53
class HTML_formulaireDocument extends HTML_QuickForm
54
{
54
{
55
    /** Le type d'un document, par défaut 'fichier'
55
    /** Le type d'un document, par défaut 'fichier'
56
     * 
56
     * 
57
     * @access private
57
     * @access private
58
     */
58
     */
59
    var $_type = 'fichier';
59
    var $_type = 'fichier';
60
 
60
 
61
    /**
61
    /**
62
     * Constructeur
62
     * Constructeur
63
     *
63
     *
64
     * @param string formName Le nom du formulaire
64
     * @param string formName Le nom du formulaire
65
     * @param string method Méthode post ou get
65
     * @param string method Méthode post ou get
66
     * @param string action L'action du formulaire.
66
     * @param string action L'action du formulaire.
67
     * @param int target La cible.
67
     * @param int target La cible.
68
     * @param Array attributes Les attributs HTML en plus.
68
     * @param Array attributes Les attributs HTML en plus.
69
     * @param bool trackSubmit ??
69
     * @param bool trackSubmit ??
70
     * @return void
70
     * @return void
71
     * @access public
71
     * @access public
72
     */
72
     */
73
    function HTML_formulaireDocument( $formName,  $method = "post",  $action,  $target = "_self",  $attributes = '',  $trackSubmit = false )
73
    function HTML_formulaireDocument( $formName,  $method = "post",  $action,  $target = "_self",  $attributes = '',  $trackSubmit = false )
74
    {
74
    {
75
        HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit) ;
75
        HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit) ;
76
    } // end of member function HTML_formulaireDocument
76
    } // end of member function HTML_formulaireDocument
77
 
77
 
78
    /**
78
    /**
79
     * 
79
     * 
80
     *
80
     *
81
     * @return void
81
     * @return void
82
     * @access public
82
     * @access public
83
     */
83
     */
84
    function construitFormulaire($action = PROJET_NOUVEAU_FICHIER)
84
    function construitFormulaire($action = PROJET_NOUVEAU_FICHIER)
85
    {
85
    {
86
        $this->addElement ('text', 'document_nom', PROJET_FICHIER_NOM_DOCUMENT, array ('size' => 40)) ;
86
        $this->addElement ('text', 'document_nom', PROJET_FICHIER_NOM_DOCUMENT, array ('size' => 40)) ;
87
        $this->addRule ('document_nom', PROJET_FICHIER_ALERTE, 'required', '', 'client') ;
87
        $this->addRule ('document_nom', PROJET_FICHIER_ALERTE, 'required', '', 'client') ;
88
        $this->addElement ('html', '<tr><td colspan="2">'.PROJET_FICHIER_NOM_DOCUMENT_EXPLICATION.'</td></tr>') ;
88
        $this->addElement ('html', '<tr><td colspan="2">'.PROJET_FICHIER_NOM_DOCUMENT_EXPLICATION.'</td></tr>') ;
89
        $this->addElement ('textarea', 'document_description', PROJET_FICHIER_DESCRIPTION, array('cols'=>40, 'rows'=>10)) ;
89
        $this->addElement ('textarea', 'document_description', PROJET_FICHIER_DESCRIPTION, array('cols'=>40, 'rows'=>10)) ;
90
        
90
        
91
        // on fait un groupe avec les boutons radio pour les mettres sur la même ligne
91
        // on fait un groupe avec les boutons radio pour les mettres sur la même ligne
92
 
92
 
93
        $radio[] = &HTML_QuickForm::createElement('radio', 'document_visibilite', 'public', PROJET_FICHIER_PUBLIC, 'public') ;
93
        $radio[] = &HTML_QuickForm::createElement('radio', 'document_visibilite', 'public', PROJET_FICHIER_PUBLIC, 'public') ;
94
        $radio[] = &HTML_QuickForm::createElement('radio', 'document_visibilite', 'prive', PROJET_FICHIER_PRIVEE, 'prive');
94
        $radio[] = &HTML_QuickForm::createElement('radio', 'document_visibilite', 'prive', PROJET_FICHIER_PRIVEE, 'prive');
95
        $this->addGroup($radio, null, PROJET_FICHIERS_VISIBILITE, '&nbsp;');
95
        $this->addGroup($radio, null, PROJET_FICHIERS_VISIBILITE, '&nbsp;');
96
        
96
        
97
        // Le champs fichier si le type du document est un fichier
97
        // Le champs fichier si le type du document est un fichier
98
        if ($this->_type == 'fichier' && $action == PROJET_NOUVEAU_FICHIER) {
98
        if ($this->_type == 'fichier' && $action == PROJET_NOUVEAU_FICHIER) {
99
            $GLOBALS['fichier'] = $this->addElement ('file', 'fichier', PROJET_FICHIER_LE_FICHIER) ;
99
            $GLOBALS['fichier'] = $this->addElement ('file', 'fichier', PROJET_FICHIER_LE_FICHIER) ;
100
            $this->setMaxFileSize(PROJET_UPLOAD_MAX_FILE_SIZE) ;
100
            $this->setMaxFileSize(PROJET_UPLOAD_MAX_FILE_SIZE) ;
101
            $this->addRule ('fichier', PROJET_FICHIER_ALERTE_PAS_DE_FICHIER, 'required', '', 'client') ;
101
            $this->addRule ('fichier', PROJET_FICHIER_ALERTE_PAS_DE_FICHIER, 'required', '', 'client') ;
102
        }
102
        }
103
        
103
        
104
        $url_annuler = new Net_URL($this->getAttribute('action')) ;
104
        $url_annuler = new Net_URL($this->getAttribute('action')) ;
105
        $url_annuler->removeQueryString(PROJET_VARIABLE_ACTION) ;
105
        $url_annuler->removeQueryString(PROJET_VARIABLE_ACTION) ;
106
        // on fait un groupe avec les boutons pour les mettres sur la même ligne
106
        // on fait un groupe avec les boutons pour les mettres sur la même ligne
107
        $buttons[] = &HTML_QuickForm::createElement('link', 'annuler', PROJET_FICHIER_ANNULER, 
107
        $buttons[] = &HTML_QuickForm::createElement('link', 'annuler', PROJET_FICHIER_ANNULER, 
108
                            preg_replace ("/&amp;/", "&", $url_annuler->getURL()), PROJET_FICHIER_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
108
                            preg_replace ("/&amp;/", "&", $url_annuler->getURL()), PROJET_FICHIER_ANNULER); // Le preg_replace contourne un pb de QuickForm et Net_URL
109
                                                                                                            // qui remplacent deux fois les & par des &amp;
109
                                                                                                            // qui remplacent deux fois les & par des &amp;
110
                                                                                                            // ce qui fait échouer le lien
110
                                                                                                            // ce qui fait échouer le lien
111
        $buttons[] = &HTML_QuickForm::createElement('submit', 'valider', PROJET_FICHIER_VALIDER);
111
        $buttons[] = &HTML_QuickForm::createElement('submit', 'valider', PROJET_FICHIER_VALIDER);
112
        $this->addGroup($buttons, null, null, '&nbsp;');
112
        $this->addGroup($buttons, null, null, '&nbsp;');
113
        $this->applyFilter('document_nom', 'addslashes') ;
113
        $this->applyFilter('document_nom', 'addslashes') ;
114
        $this->applyFilter('document_description', 'addslashes') ;
114
        $this->applyFilter('document_description', 'addslashes') ;
115
        
115
        
116
        $this->setRequiredNote('<span style="color: #ff0000">*</span>'.PROJET_CHAMPS_REQUIS) ;
116
        $this->setRequiredNote('<span style="color: #ff0000">*</span>'.PROJET_CHAMPS_REQUIS) ;
117
    } // end of member function construitFormulaire
117
    } // end of member function construitFormulaire
118
 
118
 
119
    /**
119
    /**
120
     *  Permet de spécifier le type de formulaire à montrer
120
     *  Permet de spécifier le type de formulaire à montrer
121
     *
121
     *
122
     * @param string type Le type d'un document, 'fichier' ou 'repertoire'
122
     * @param string type Le type d'un document, 'fichier' ou 'repertoire'
123
     * @return void
123
     * @return void
124
     * @access public
124
     * @access public
125
     */
125
     */
126
    function setType( $type )
126
    function setType( $type )
127
    {
127
    {
128
        if ($type != 'fichier' && $type != 'repertoire') trigger_error ('type invalide', E_USER_ERROR) ;
128
        if ($type != 'fichier' && $type != 'repertoire') trigger_error ('type invalide', E_USER_ERROR) ;
129
        $this->_type = $type ;
129
        $this->_type = $type ;
130
    } // end of member function setType
130
    } // end of member function setType
131
 
131
 
132
    /**
132
    /**
133
     * 
133
     * 
134
     *
134
     *
135
     * @return string
135
     * @return string
136
     * @access public
136
     * @access public
137
     */
137
     */
138
    function toHTML( )
138
    function toHTML( )
139
    {
139
    {
140
        $res = HTML_QuickForm::toHTML() ;
140
        $res = HTML_QuickForm::toHTML() ;
141
        return $res ;
141
        return $res ;
142
    } // end of member function toHTML
142
    } // end of member function toHTML
143
 
143
 
144
 
144
 
145
} // end of HTML_formulaireDocument
145
} // end of HTML_formulaireDocument
146
?>
146
?>