Subversion Repositories Applications.papyrus

Rev

Rev 425 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
425 florian 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 Lesser 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
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser 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
// +------------------------------------------------------------------------------------------------------+
446 florian 22
// CVS : $Id: cartographie.admin.php,v 1.2 2005-09-22 13:30:49 florian Exp $
425 florian 23
/**
24
*
25
*@package bazar
26
//Auteur original :
27
*@author        Florian Schmitt <florian@ecole-et-nature.org>
28
//Autres auteurs :
29
*@copyright     Tela-Botanica 2000-2004
446 florian 30
*@version       $Revision: 1.2 $ $Date: 2005-09-22 13:30:49 $
425 florian 31
// +------------------------------------------------------------------------------------------------------+
32
*/
33
// +------------------------------------------------------------------------------------------------------+
34
// |                                            ENT?E du PROGRAMME                                       |
35
// +------------------------------------------------------------------------------------------------------+
36
 
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                                 CLASSE                                               |
40
// +------------------------------------------------------------------------------------------------------+
41
class Cartographie_Admin {
42
    var $objet_pear_auth;
43
    var $objet_pear_db;
44
    var $objet_pear_url;
45
    var $sortie_xhtml;
46
 
47
    /** Fonction redigerContenu() - Affiche le formulaire de r?action
48
    *
49
    *
50
    *   @return  string  Le HTML
51
    */
52
    function afficherContenuCorps()
53
    {
54
        /** Inclusion du fichier de configuration de cette application.*/
55
        require_once 'configuration/ins_annuaire.config.inc.php';
56
	require_once INS_CHEMIN_APPLI.'configuration/cartographie.config.inc.php';
57
	require_once 'HTML/QuickForm.php' ;
58
 
59
        //-------------------------------------------------------------------------------------------------------------------
60
        // Initialisation des attributs
61
        $this->objet_pear_auth = $GLOBALS['_GEN_commun']['pear_auth'];
62
        $this->objet_pear_db = $GLOBALS['_GEN_commun']['pear_db'];
63
        $this->objet_pear_url = $GLOBALS['_GEN_commun']['url'];
64
        $this->sortie_xhtml = '';
65
 
66
        //-------------------------------------------------------------------------------------------------------------------
67
	// Création du formulaire
68
        $this->objet_pear_url->addQueryString('adme_site_id', 2);
69
	$this->objet_pear_url->addQueryString('adme_menu_id', 14);
70
	$this->objet_pear_url->addQueryString('adme_action', 'administrer');
71
	$form =& new HTML_QuickForm('form_param_carto', 'post', str_replace('&amp;', '&', $this->objet_pear_url->getUrl()));
72
        $squelette =& $form->defaultRenderer();
73
        $squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'<ul>'."\n".'{content}'."\n".'</ul>'."\n".'</form>'."\n");
74
        $squelette->setElementTemplate(  '<li>'."\n".
75
                                        '{label}'."\n".
76
                                        '{element}'."\n".
77
                                        '<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
78
                                        '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
79
                                        '</li>'."\n");
80
	$requete = $requete = 'SHOW TABLES FROM '.INS_BASE;
81
	$resultat = $this->objet_pear_db->query($requete) ;
82
	if (DB::isError($resultat)) {
83
		die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
84
	}
85
	$option_tables = array();
86
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
87
		$option_tables[$ligne['Tables_in_'.INS_BASE]] =  $ligne['Tables_in_'.INS_BASE];
88
	}
89
	$javascript= array('onchange' => 'javascript:this.form.submit();');
90
	$form->addElement('select', 'nom_table1', INS_TABLE, $option_tables, $javascript);
91
 
92
	$requete = $requete = 'SELECT * FROM carto_config WHERE cc_menu_id='.$_GET['adme_menu_id'];
93
	$resultat = $this->objet_pear_db->query($requete) ;
94
	if (DB::isError($resultat)) {
95
		die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
96
	}
97
	echo '<pre>'.print_r($_POST, true).'</pre>';
98
	if (($resultat->numRows()>0)or(isset($_POST['nom_table1']))) {
99
		if (isset($_POST['nom_table1'])) {
100
				$ligne['cc_table1']=$_POST['nom_table1'];
101
		}
102
 
103
		$requete = $requete = 'SHOW COLUMNS FROM '.$ligne['cc_table1'];
104
		$resultat = $this->objet_pear_db->query($requete) ;
105
		if (DB::isError($resultat)) {
106
			die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
107
		}
108
		$option_champs = array();
109
		$i=0;
110
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
111
			$option_champs[$i] =  $ligne['Field'];
112
			$i++;
113
		}
114
		$form->addElement('select', 'nom_champs_pays', INS_NOM_CHAMPS_PAYS, $option_champs);
115
		$form->addElement('select', 'nom_champs_cp', INS_NOM_CHAMPS_CP, $option_champs);
116
		$option_tables[0] = INS_PAS_NECESSAIRE;
117
		$form->addElement('select', 'nom_table2', INS_TABLE_SUPPLEMENTAIRE, $option_tables);
118
		$form->addElement('text', 'requete_sql', INS_REQUETE_SQL_SUPPLEMENTAIRE);
119
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
120
			//valeurs par defaut
121
		}
122
 
123
	}
124
 
125
        $liste_bouton_debut = '<ul class="liste_bouton">'."\n";
126
        $form->addElement('html', $liste_bouton_debut);
446 florian 127
        $form->addElement('submit', 'afficheur_enregistrer_quitter', INS_ENREGISTRER_ET_QUITTER);
425 florian 128
        $form->addElement('submit', 'afficheur_annuler', INS_ANNULER);
129
        $liste_bouton_fin = '</ul>'."\n";
130
        $form->addElement('html', $liste_bouton_fin);
131
        $this->sortie_xhtml .= $form->toHTML()."\n";
132
 
133
        return $this->sortie_xhtml;
134
    }
135
 
136
}// Fin de la classe
137
 
138
// +------------------------------------------------------------------------------------------------------+
139
// |                                            PIED du PROGRAMME                                         |
140
// +------------------------------------------------------------------------------------------------------+
141
 
142
?>