| 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 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
           | 431 | 
           mathias | 
           22 | 
           // CVS : $Id: HTML_formulaireDocument.class.php,v 1.4 2007/02/13 15:11:39 jp_milcent Exp $
  | 
        
        
           | 2 | 
           ddelon | 
           23 | 
           /**
  | 
        
        
            | 
            | 
           24 | 
           * Application projet
  | 
        
        
            | 
            | 
           25 | 
           *
  | 
        
        
            | 
            | 
           26 | 
           * La classe HTML_formulaireDocument
  | 
        
        
            | 
            | 
           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
  | 
        
        
           | 163 | 
           jp_milcent | 
           34 | 
           *@version       $Revision: 1.4 $
  | 
        
        
           | 2 | 
           ddelon | 
           35 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           36 | 
           */
  | 
        
        
            | 
            | 
           37 | 
              | 
        
        
            | 
            | 
           38 | 
              | 
        
        
            | 
            | 
           39 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           40 | 
           // |                                            ENTETE du PROGRAMME                                       |
  | 
        
        
            | 
            | 
           41 | 
           // +------------------------------------------------------------------------------------------------------+
  | 
        
        
            | 
            | 
           42 | 
              | 
        
        
            | 
            | 
           43 | 
           /** Inclure le fichier de langue pour utiliser cette classe de façon autonome. */
  | 
        
        
            | 
            | 
           44 | 
              | 
        
        
            | 
            | 
           45 | 
           require_once 'HTML/QuickForm.php' ;
  | 
        
        
            | 
            | 
           46 | 
           require_once 'HTML/QuickForm/checkbox.php' ;
  | 
        
        
            | 
            | 
           47 | 
           require_once 'HTML/QuickForm/select.php' ;
  | 
        
        
            | 
            | 
           48 | 
              | 
        
        
            | 
            | 
           49 | 
           /**
  | 
        
        
            | 
            | 
           50 | 
            * class HTML_formulaireDocument
  | 
        
        
            | 
            | 
           51 | 
            *
  | 
        
        
            | 
            | 
           52 | 
            */
  | 
        
        
            | 
            | 
           53 | 
           class HTML_formulaireDocument extends HTML_QuickForm
  | 
        
        
            | 
            | 
           54 | 
           {
  | 
        
        
            | 
            | 
           55 | 
               /** Le type d'un document, par défaut 'fichier'
  | 
        
        
            | 
            | 
           56 | 
                *
  | 
        
        
            | 
            | 
           57 | 
                * @access private
  | 
        
        
            | 
            | 
           58 | 
                */
  | 
        
        
            | 
            | 
           59 | 
               var $_type = 'fichier';
  | 
        
        
            | 
            | 
           60 | 
              | 
        
        
            | 
            | 
           61 | 
               /**
  | 
        
        
            | 
            | 
           62 | 
                * Constructeur
  | 
        
        
            | 
            | 
           63 | 
                *
  | 
        
        
            | 
            | 
           64 | 
                * @param string formName Le nom du formulaire
  | 
        
        
            | 
            | 
           65 | 
                * @param string method Méthode post ou get
  | 
        
        
            | 
            | 
           66 | 
                * @param string action L'action du formulaire.
  | 
        
        
            | 
            | 
           67 | 
                * @param int target La cible.
  | 
        
        
            | 
            | 
           68 | 
                * @param Array attributes Les attributs HTML en plus.
  | 
        
        
            | 
            | 
           69 | 
                * @param bool trackSubmit ??
  | 
        
        
            | 
            | 
           70 | 
                * @return void
  | 
        
        
            | 
            | 
           71 | 
                * @access public
  | 
        
        
            | 
            | 
           72 | 
                */
  | 
        
        
            | 
            | 
           73 | 
               function HTML_formulaireDocument( $formName,  $method = "post",  $action,  $target = "_self",  $attributes = '',  $trackSubmit = false )
  | 
        
        
            | 
            | 
           74 | 
               {
  | 
        
        
            | 
            | 
           75 | 
                   HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit) ;
  | 
        
        
            | 
            | 
           76 | 
               } // end of member function HTML_formulaireDocument
  | 
        
        
            | 
            | 
           77 | 
              | 
        
        
            | 
            | 
           78 | 
               /**
  | 
        
        
            | 
            | 
           79 | 
                *
  | 
        
        
            | 
            | 
           80 | 
                *
  | 
        
        
            | 
            | 
           81 | 
                * @return void
  | 
        
        
            | 
            | 
           82 | 
                * @access public
  | 
        
        
            | 
            | 
           83 | 
                */
  | 
        
        
            | 
            | 
           84 | 
               function construitFormulaire($action = PROJET_NOUVEAU_FICHIER)
  | 
        
        
            | 
            | 
           85 | 
               {
  | 
        
        
            | 
            | 
           86 | 
                   $this->addElement ('text', 'document_nom', PROJET_FICHIER_NOM_DOCUMENT, array ('size' => 40)) ;
  | 
        
        
            | 
            | 
           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>') ;
  | 
        
        
            | 
            | 
           89 | 
                   $this->addElement ('textarea', 'document_description', PROJET_FICHIER_DESCRIPTION, array('cols'=>40, 'rows'=>10)) ;
  | 
        
        
            | 
            | 
           90 | 
              | 
        
        
            | 
            | 
           91 | 
                   // on fait un groupe avec les boutons radio pour les mettres sur la même ligne
  | 
        
        
            | 
            | 
           92 | 
              | 
        
        
            | 
            | 
           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');
  | 
        
        
            | 
            | 
           95 | 
                   $this->addGroup($radio, null, PROJET_FICHIERS_VISIBILITE, ' ');
  | 
        
        
            | 
            | 
           96 | 
              | 
        
        
            | 
            | 
           97 | 
                   // Le champs fichier si le type du document est un fichier
  | 
        
        
            | 
            | 
           98 | 
                   if ($this->_type == 'fichier' && $action == PROJET_NOUVEAU_FICHIER) {
  | 
        
        
            | 
            | 
           99 | 
                       $GLOBALS['fichier'] = $this->addElement ('file', 'fichier', PROJET_FICHIER_LE_FICHIER) ;
  | 
        
        
           | 163 | 
           jp_milcent | 
           100 | 
                       $this->setMaxFileSize(PROJET_UPLOAD_MAX_FILE_SIZE) ;
  | 
        
        
           | 2 | 
           ddelon | 
           101 | 
                       $this->addRule ('fichier', PROJET_FICHIER_ALERTE_PAS_DE_FICHIER, 'required', '', 'client') ;
  | 
        
        
            | 
            | 
           102 | 
                   }
  | 
        
        
            | 
            | 
           103 | 
              | 
        
        
            | 
            | 
           104 | 
                   $url_annuler = new Net_URL($this->getAttribute('action')) ;
  | 
        
        
            | 
            | 
           105 | 
                   $url_annuler->removeQueryString(PROJET_VARIABLE_ACTION) ;
  | 
        
        
            | 
            | 
           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,
  | 
        
        
            | 
            | 
           108 | 
                                       preg_replace ("/&/", "&", $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 &
  | 
        
        
            | 
            | 
           110 | 
                                                                                                                       // ce qui fait échouer le lien
  | 
        
        
            | 
            | 
           111 | 
                   $buttons[] = &HTML_QuickForm::createElement('submit', 'valider', PROJET_FICHIER_VALIDER);
  | 
        
        
            | 
            | 
           112 | 
                   $this->addGroup($buttons, null, null, ' ');
  | 
        
        
           | 92 | 
           alexandre_ | 
           113 | 
                   $this->applyFilter('document_nom', 'addslashes') ;
  | 
        
        
            | 
            | 
           114 | 
                   $this->applyFilter('document_description', 'addslashes') ;
  | 
        
        
           | 2 | 
           ddelon | 
           115 | 
              | 
        
        
            | 
            | 
           116 | 
                   $this->setRequiredNote('<span style="color: #ff0000">*</span>'.PROJET_CHAMPS_REQUIS) ;
  | 
        
        
            | 
            | 
           117 | 
               } // end of member function construitFormulaire
  | 
        
        
            | 
            | 
           118 | 
              | 
        
        
            | 
            | 
           119 | 
               /**
  | 
        
        
            | 
            | 
           120 | 
                *  Permet de spécifier le type de formulaire à montrer
  | 
        
        
            | 
            | 
           121 | 
                *
  | 
        
        
            | 
            | 
           122 | 
                * @param string type Le type d'un document, 'fichier' ou 'repertoire'
  | 
        
        
            | 
            | 
           123 | 
                * @return void
  | 
        
        
            | 
            | 
           124 | 
                * @access public
  | 
        
        
            | 
            | 
           125 | 
                */
  | 
        
        
            | 
            | 
           126 | 
               function setType( $type )
  | 
        
        
            | 
            | 
           127 | 
               {
  | 
        
        
            | 
            | 
           128 | 
                   if ($type != 'fichier' && $type != 'repertoire') trigger_error ('type invalide', E_USER_ERROR) ;
  | 
        
        
            | 
            | 
           129 | 
                   $this->_type = $type ;
  | 
        
        
            | 
            | 
           130 | 
               } // end of member function setType
  | 
        
        
            | 
            | 
           131 | 
              | 
        
        
            | 
            | 
           132 | 
               /**
  | 
        
        
            | 
            | 
           133 | 
                *
  | 
        
        
            | 
            | 
           134 | 
                *
  | 
        
        
            | 
            | 
           135 | 
                * @return string
  | 
        
        
            | 
            | 
           136 | 
                * @access public
  | 
        
        
            | 
            | 
           137 | 
                */
  | 
        
        
            | 
            | 
           138 | 
               function toHTML( )
  | 
        
        
            | 
            | 
           139 | 
               {
  | 
        
        
            | 
            | 
           140 | 
                   $res = HTML_QuickForm::toHTML() ;
  | 
        
        
            | 
            | 
           141 | 
                   return $res ;
  | 
        
        
            | 
            | 
           142 | 
               } // end of member function toHTML
  | 
        
        
            | 
            | 
           143 | 
              | 
        
        
            | 
            | 
           144 | 
              | 
        
        
            | 
            | 
           145 | 
           } // end of HTML_formulaireDocument
  | 
        
        
            | 
            | 
           146 | 
           ?>
  |