Subversion Repositories Applications.papyrus

Rev

Rev 1087 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1                                                                                      |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or                                        |
// | modify it under the terms of the GNU General Public                                                  |
// | License as published by the Free Software Foundation; either                                         |
// | version 2.1 of the License, or (at your option) any later version.                                   |
// |                                                                                                      |
// | This library is distributed in the hope that it will be useful,                                      |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
// | General Public License for more details.                                                             |
// |                                                                                                      |
// | You should have received a copy of the GNU General Public                                            |
// | License along with this library; if not, write to the Free Software                                  |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: HTML_formulaireCouperColler.class.php,v 1.2 2005-09-27 16:39:25 alexandre_tb Exp $
/**
* Application projet
*
* La classe HTML_formulaireCouperColler
*
*@package projet
//Auteur original :
*@author        Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author        Aucun
*@copyright     Tela-Botanica 2000-2004
*@version       $Revision: 1.2 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            ENTETE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+

/**
 * class HTML_formulaireCouperColler
 * 
 */
class HTML_formulaireCouperColler extends HTML_QuickForm
{
    /**
     * 
     *
     * @return void
     * @access public
     */
    function construitFormulaire($tableau_repertoire)
    {
        $squelette =& $this->defaultRenderer();
        $squelette->setFormTemplate("\n".'<form{attributes}><ul>'."\n".'{content}'."\n".'</ul></form>'."\n");
        $squelette->setElementTemplate( '<li style="list-style-type: none;">'."\n".'{element}'."\n".'</li>'."\n");
        
        $this->addElement('radio', 'projet_repertoire', '', PROJET_RACINE, 0) ;
        if (count ($tableau_repertoire)) {
            $this->addElement('html', '<ul>') ;
            foreach ($tableau_repertoire as $cle => $valeur) {
                if ($valeur->_id_pere ==0) {
                    $this->addElement ('radio', 'projet_repertoire', '', $valeur->getNomLong(), $valeur->getIdDocument()) ;
                    $sous_tableau = array() ;
                    foreach ($tableau_repertoire as $valeur_fils) {
                        if ($valeur_fils->_id_pere == $valeur->getIdDocument()) {
                            array_push ($sous_tableau, $valeur_fils) ;
                        }
                    }
                    if (count ($sous_tableau)) $this->construitLigneRepertoire($sous_tableau) ;
                }
            }
            $this->addElement('html', '</ul>') ;
        }
        
        $url_annuler = new Net_URL($this->getAttribute('action')) ;
        $url_annuler->removeQueryString(PROJET_VARIABLE_ACTION) ;
        
        // on fait un groupe avec les boutons pour les mettres sur la même ligne
        $buttons[] = &HTML_QuickForm::createElement('link', 'annuler', '', 
                            preg_replace ("/&amp;/", "&", $url_annuler->getURL()), PROJET_FICHIER_ANNULER
                                            ); // Le preg_replace contourne un pb de QuickForm et Net_URL
                                                                                                            // qui remplacent deux fois les & par des &amp;
                                                                                                            // ce qui fait échouer le lien
        $buttons[] = &HTML_QuickForm::createElement('submit', 'valider_inscription_projet', PROJET_FICHIER_VALIDER);
        $this->addGroup($buttons, null, null, '&nbsp;');
    } // end of member function construitFormulaire


    /**
    *
    *
    *
    *
    */
    
    function construitLigneRepertoire($tableau) {
        $this->addElement('html', '<ul>') ;
        foreach ($tableau as $valeur) {
            $this->addElement('radio', 'projet_repertoire', '', $valeur->getNomLong(), $valeur->getIdDocument()) ;
        }
        $this->addElement('html', '</ul>') ;
    }
    /**
     * 
     *
     * @return void
     * @access public
     */
    function HTML_formulaireCouperColler($formName = '',  $method = 'post',  $action = '',  $target = '_self',  $attributes = '',  $trackSubmit = false  )
    {
        HTML_QuickForm::HTML_QuickForm($formName, $method, $action, $target, $attributes, $trackSubmit) ;
    } // end of member function HTML_formulaireCouperColler

    /**
     * 
     *
     * @return string
     * @access public
     */
    function toHTML($nom_de_fichier)
    {
        $res = '<h2>'.PROJET_CHANGER_REPERTOIRE.'</h2>'."\n" ;
        $res .= PROJET_FICHIER_A_DEPLACER . $nom_de_fichier;
        $res .= '<h2>'.PROJET_CHOISISSEZ_REPERTOIRE.'</h2>' ;
        $res .= HTML_QuickForm::toHTML() ;
        return $res ;
    } // end of member function toHTML
} // end of HTML_formulaireCouperColler
?>