Subversion Repositories Applications.papyrus

Rev

Rev 448 | Blame | 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 Lesser 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                                    |
// | Lesser General Public License for more details.                                                      |
// |                                                                                                      |
// | You should have received a copy of the GNU Lesser 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: cartographie.admin.php,v 1.2 2005-11-24 16:17:52 florian Exp $
/**
* 
*@package bazar
//Auteur original :
*@author        Florian Schmitt <florian@ecole-et-nature.org>
//Autres auteurs :
*@copyright     Tela-Botanica 2000-2004
*@version       $Revision: 1.2 $ $Date: 2005-11-24 16:17:52 $
// +------------------------------------------------------------------------------------------------------+
*/
// +------------------------------------------------------------------------------------------------------+
// |                                            ENT?E du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+


// +------------------------------------------------------------------------------------------------------+
// |                                                 CLASSE                                               |
// +------------------------------------------------------------------------------------------------------+
class Cartographie_Admin {
    var $objet_pear_auth;
    var $objet_pear_db;
    var $objet_pear_url;
    var $sortie_xhtml;
    
    /** Fonction redigerContenu() - Affiche le formulaire de r?action
    *
    *
    *   @return  string  Le HTML
    */
    function afficherContenuCorps()
    {
        /** Inclusion du fichier de configuration de cette application.*/
    require_once PAP_CHEMIN_RACINE.'client/bottin/configuration/bottin.config.inc.php';
        require_once INS_CHEMIN_APPLI.'configuration/cartographie.config.inc.php';
        require_once PAP_CHEMIN_RACINE.'api/pear/HTML/QuickForm.php' ;
        
        //-------------------------------------------------------------------------------------------------------------------
        // Initialisation des attributs
        $this->objet_pear_auth = $GLOBALS['_GEN_commun']['pear_auth'];
        $this->objet_pear_db = $GLOBALS['_GEN_commun']['pear_db'];
        $this->objet_pear_url = $GLOBALS['_GEN_commun']['url'];
        $this->sortie_xhtml = '';
        
        //-------------------------------------------------------------------------------------------------------------------
        // Création du formulaire
        $this->objet_pear_url->addQueryString('adme_site_id', 2);
        $this->objet_pear_url->addQueryString('adme_menu_id', 14);
        $this->objet_pear_url->addQueryString('adme_action', 'administrer');
        $form =& new HTML_QuickForm('form_param_carto', 'post', str_replace('&amp;', '&', $this->objet_pear_url->getUrl()));
        $squelette =& $form->defaultRenderer();
        $squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'<ul>'."\n".'{content}'."\n".'</ul>'."\n".'</form>'."\n");
        $squelette->setElementTemplate(  '<li>'."\n".
                                        '{label}'."\n".
                                        '{element}'."\n".
                                        '<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
                                        '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
                                        '</li>'."\n");
        $requete = 'SHOW TABLES FROM '.$this->objet_pear_db->dsn['database'];
        $resultat = $this->objet_pear_db->query($requete) ;
        if (DB::isError($resultat)) {
                die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
        }
        $option_tables = array();
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
                $option_tables[$ligne['Tables_in_'.$this->objet_pear_db->dsn['database']]] =  $ligne['Tables_in_'.$this->objet_pear_db->dsn['database']];
        }
        $javascript= array('onchange' => 'javascript:this.form.submit();');
        $form->addElement('select', 'nom_table1', INS_TABLE, $option_tables, $javascript);
        
        $requete = $requete = 'SELECT * FROM carto_config WHERE cc_menu_id='.$_GET['adme_menu_id'];
        $resultat = $this->objet_pear_db->query($requete) ;
        if (DB::isError($resultat)) {
                die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
        }
        echo '<pre>'.print_r($_POST, true).'</pre>';
        if (($resultat->numRows()>0)or(isset($_POST['nom_table1']))) {
                if (isset($_POST['nom_table1'])) {
                                $ligne['cc_table1']=$_POST['nom_table1'];
                }
                
                $requete = $requete = 'SHOW COLUMNS FROM '.$ligne['cc_table1'];
                $resultat = $this->objet_pear_db->query($requete) ;
                if (DB::isError($resultat)) {
                        die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
                }
                $option_champs = array();
                $i=0;
                while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
                        $option_champs[$i] =  $ligne['Field'];
                        $i++;
                }
                $form->addElement('select', 'nom_champs_pays', INS_NOM_CHAMPS_PAYS, $option_champs);
                $form->addElement('select', 'nom_champs_cp', INS_NOM_CHAMPS_CP, $option_champs);
                $option_tables[0] = INS_PAS_NECESSAIRE;
                $form->addElement('select', 'nom_table2', INS_TABLE_SUPPLEMENTAIRE, $option_tables);
                $form->addElement('text', 'requete_sql', INS_REQUETE_SQL_SUPPLEMENTAIRE);
                while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
                        //valeurs par defaut
                }
                 
        }
        
        $liste_bouton_debut = '<ul class="liste_bouton">'."\n";
        $form->addElement('html', $liste_bouton_debut);
        $form->addElement('submit', 'afficheur_enregistrer_quitter', INS_ENREGISTRER_ET_QUITTER);
        $form->addElement('submit', 'afficheur_annuler', INS_ANNULER);
        $liste_bouton_fin = '</ul>'."\n";
        $form->addElement('html', $liste_bouton_fin);
        $this->sortie_xhtml .= $form->toHTML()."\n";
        
        return $this->sortie_xhtml;
    }

}// Fin de la classe

// +------------------------------------------------------------------------------------------------------+
// |                                            PIED du PROGRAMME                                         |
// +------------------------------------------------------------------------------------------------------+

?>