Subversion Repositories Applications.projet

Rev

Rev 134 | 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_listeProjet.class.php,v 1.7 2006/09/15 12:35:54 alexandre_tb Exp $
/**
* Application projet
*
* La classe controleur projet
*
*@package projet
//Auteur original :
*@author        Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author        Aucun
*@copyright     Tela-Botanica 2000-2004
*@version       $Revision: 1.7 $
// +------------------------------------------------------------------------------------------------------+
*/


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

include_once PROJET_CHEMIN_CLASSES.'HTML_Liste.class.php' ;

/**
 * class HTML_listeProjet
 * 
 */
class HTML_listeProjet extends HTML_Liste
{
    /*** Attributes: ***/
    /**
     * 0 mode normal 1 mode modification, rajoute un formulaire pour modifier le statut
     * d'un utilisateur.
     * @access private
     */
    var $_mode;
    /**
     * Un objet PEAR::Net_URL
     * @access private
     */
    var $_url;

    /**
     * 
     *
     * @param bool utilise_pager Indique si les résultats sont divisés en page.
     * @return void
     * @access public
     */
    function HTML_listeProjet( $utilise_pager = false )
    {
        HTML_Liste::HTML_Liste($utilise_pager, array ('class' => 'table_cadre', 'summary' => PROJET_LISTE)) ;
    } // end of member function HTML_listeProjet

    /**
     * 
     *
     * @return void
     * @access public
     */
    function __construct($utilise_pager = false)
    {
        $this->HTML_listeProjet($utilise_pager);
        
    } // end of member function __cosntruct

    /**
     * 
     *
     * @param Array label_entete Un tableau contenant les labels pour l'entête de la liste.
     * @return void
     * @access public
     */
    function construitEntete( $label_entete )
    {
        $this->addRow ($label_entete, '', 'TH') ;
    } // end of member function construitEntete

    /**
     * 
     *
     * @param Array label_liste Un tableau à double dimension contenant les valeurs de la liste. du type 
     *      0 =>'label', 'label2', 
     *      1 => ...
     * @return void
     * @access public
     */
    function construitListe( $label_liste, $tableau_statut = '' )
    {
        for ($i = 0; $i < count ($label_liste) ; $i++) {
            if ($this->_mode == 1) {
                $id_projet = array_shift ($label_liste[$i]) ;
                $id_statut = array_pop ($label_liste[$i]) ;
                
            }
            $resume = array_shift ($label_liste[$i]) ;
            $this->addRow ($label_liste[$i]) ;
            
            
            if ($this->_mode == 1 && $id_statut < 3) {
                $this->_url->addQueryString ('identifiant_projet', $id_projet) ;
                $this->_url->removeQueryString (PROJET_VARIABLE_ID_PROJET) ;
                $select = '<form action="'.$this->_url->getURL().'" method="post" class="magali">'."\n" ;
                $select .= '<select name="statut" onchange="javascript:this.form.submit();">' ;
                foreach ($tableau_statut as $cle =>$element_statut) {
                    $select .= '<option value="'.$cle.'"' ;
                    if ($cle == $id_statut) {
                        $select .= ' selected="selected"' ;
                    }
                    $select .= '>'.$element_statut.'</option>'."\n" ;
                }
                $select .= '</select>'."\n".'</form>'."\n" ;
                if (is_int($id_statut)) {
                    //$this->setCellContents($i+1, 2, $select) ;
                    $this->setCellContents($this->getRowCount() - 1, 2, $select) ;
                } else {
                    $this->setCellContents($i+1, 2, PROJET_PAS_DE_LISTE) ;
                }
            }
            // On affiche le résumé dans la deuxième ligne
            if (PROJET_LISTE_RESUME) {
                $this->addRow (array ($resume), array('colspan' => $this->getColCount()));      
            }
        }
        $this->altRowAttributes(1, array('class' => 'ligne_impaire'), array('class' => 'ligne_paire')) ;
        
    } // end of member function construitListe

    /**
     * 
     *
     * @return void
     * @access public
     */
    function setModeModification( )
    {
        $this->_mode = 1 ;
    } // end of member function setModeModification

    /**
     * 
     *
     * @param Net_URL url Un objet PEAR::Net_URL
     * @return void
     * @access public
     */
    function setURL(& $url )
    {
        $this->_url = $url ;
    } // end of member function setURL
    
        /**
     * Alternates the row attributes starting at $start
     * @param    int      $start          Row index of row in which alternating begins
     * @param    mixed    $attributes1    Associative array or string of table row attributes
     * @param    mixed    $attributes2    Associative array or string of table row attributes
     * @param    bool     $inTR           false if attributes are to be applied in TD tags
     *                                    true if attributes are to be applied in TR tag
     * @access   public
     */
     
     function altRowAttributes($start, $attributes1, $attributes2, $inTR = false)
     {
         for ($row = $start ; $row < $this->_rows ; $row++) {
             $attributes = ( ($row+$start)%2 == 0 ) ? $attributes1 : $attributes2;
             $this->updateRowAttributes($row, $attributes, $inTR);
             if (PROJET_LISTE_RESUME) {
                     $row++;
                     $this->updateRowAttributes($row, $attributes, $inTR);
                     $start++;
             }
        }
        } // end func altRowAttributes

} // end of HTML_listeProjet
?>