Subversion Repositories Applications.papyrus

Rev

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

Rev Author Line No. Line
1331 florian 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2006 Outils Reseaux (info@outils-reseaux.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
// +------------------------------------------------------------------------------------------------------+
1333 florian 22
// CVS : $Id: questionnaire.admin.php,v 1.1.2.1 2007-04-19 14:51:30 florian Exp $
1331 florian 23
/**
24
*
25
*@package Questionnaire
26
//Auteur original :
27
*@author        Florian Schmitt <florian@ecole-et-nature.org>
28
//Autres auteurs :
29
*@copyright     Outils Reseaux 2006
1333 florian 30
*@version       $Revision: 1.1.2.1 $ $Date: 2007-04-19 14:51:30 $
1331 florian 31
// +------------------------------------------------------------------------------------------------------+
32
*/
33
// +------------------------------------------------------------------------------------------------------+
34
// |                                            ENTETE du PROGRAMME                                       |
35
// +------------------------------------------------------------------------------------------------------+
36
 
37
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm.php' ;
38
require_once PAP_CHEMIN_API_PEAR.'HTML/QuickForm/textarea.php' ;
39
//appel du fichier de constantes des langues
40
include_once 'langues/questionnaire.langue.'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
41
 
42
 
43
// +------------------------------------------------------------------------------------------------------+
44
// |                                                 CLASSE                                               |
45
// +------------------------------------------------------------------------------------------------------+
46
 
47
class Questionnaire_Admin {
48
    var $objet_pear_auth;
49
    var $objet_pear_db;
50
    var $objet_pear_url;
51
    var $sortie_xhtml;
52
 
53
    /** Fonction redigerContenu() - Affiche le formulaire de r?action
54
    *
55
    *
56
    *   @return  string  Le HTML
57
    */
58
    function afficherContenuCorps()
59
    {
60
        //-------------------------------------------------------------------------------------------------------------------
61
        // Initialisation des attributs
62
        $this->objet_pear_auth = $GLOBALS['_GEN_commun']['pear_auth'];
63
        $this->objet_pear_db = $GLOBALS['_GEN_commun']['pear_db'];
64
        $this->objet_pear_url = $GLOBALS['_GEN_commun']['url'];
65
        $this->sortie_xhtml = '<h1>'.QUESTIONNAIRE_CONFIG.'</h1>'."\n";
66
 
67
        //-------------------------------------------------------------------------------------------------------------------
68
        // Gestion des boutons de l'interface
69
        if (isset($_POST['afficheur_annuler'])) {
70
            return false;
71
        } else if (isset($_POST['afficheur_enregistrer_quitter'])) {
72
            $requete = 'UPDATE gen_menu SET gm_application_arguments="num_questionnaire='.$_POST['num_questionnaire'].
73
					   '||mail_questionnaire='.$_POST['mail_questionnaire'].'||texte_questionnaire_envoye='.$_POST['texte_questionnaire_envoye'].'" WHERE gm_id_menu='.$_GET['adme_menu_id'];
74
            $resultat = $this->objet_pear_db->query($requete) ;
75
            if (DB::isError($resultat)) {
76
            	die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
77
            }
78
            return false;
79
        }
80
 
81
        //--------------------------------------------------------------------------------------------------------------
82
        // Gestion des valeurs par defauts, en fonctions des donnees sauvees dans le menu
83
        $requete = 'SELECT gm_application_arguments FROM gen_menu WHERE gm_id_menu='.$_GET['adme_menu_id'];
84
        $resultat = $this->objet_pear_db->query($requete) ;
85
        //echo $requete;
86
        if (DB::isError($resultat)) {
87
        	die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
88
        }
89
        $valeurs_par_defaut = array();
90
        if ($resultat->numRows()>0) {
91
        	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
92
        		$arguments = explode('||', $ligne->gm_application_arguments);
93
 				for ($i = 0; $i < count($arguments); $i++) {
94
 					$attr = explode('=', $arguments[$i], 2);
95
 					if ($attr[0] != '') {
96
 						$info_application->$attr[0] = (isset($attr[1]) ? $attr[1] : '');
97
 					}
98
 			   	}
99
 			}
100
        	//valeurs par defaut enregistrees dans la table
101
        	if (isset($info_application)) {
102
        		$valeurs_par_defaut['num_questionnaire']=$info_application->num_questionnaire;
103
        		$valeurs_par_defaut['mail_questionnaire']=$info_application->mail_questionnaire;
104
        		$valeurs_par_defaut['texte_questionnaire_envoye']=$info_application->texte_questionnaire_envoye;
105
        	}
106
        } else {
107
        	//valeurs par defaut pour afficher une carto des structures
108
        	$valeurs_par_defaut['num_questionnaire']='';
109
        	$valeurs_par_defaut['mail_questionnaire']='';
110
        	$valeurs_par_defaut['texte_questionnaire_envoye']='';
111
        }
112
 
113
        //--------------------------------------------------------------------------------------------------------------
114
        // Gestion du questionnaire
115
        $this->objet_pear_url->addQueryString('adme_site_id', $_GET['adme_site_id']);
116
        $this->objet_pear_url->addQueryString('adme_menu_id', $_GET['adme_menu_id']);
117
        $this->objet_pear_url->addQueryString('adme_action', 'administrer');
118
        $form =& new HTML_QuickForm('form_param_questionnaire', 'post', str_replace('&amp;', '&', $this->objet_pear_url->getUrl()));
119
        $squelette =& $form->defaultRenderer();
120
        $squelette->setFormTemplate("\n".'<form {attributes}>'."\n".'{content}'."\n".'</form>'."\n");
121
        $squelette->setElementTemplate( '<p>'."\n".
122
                                        '<label style="width:100px;padding:5px;text-align:right;">{label}'.
123
                                        '<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
124
                                        '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n".
125
										' : </label>'."\n".'{element}'."\n".
126
										'</p>'."\n" );
127
 
128
        // on récupère tous les questionnaires
129
        $requete = 'SELECT bti_id, bti_nom FROM pap_formulaires WHERE bti_groupe="questionnaire" AND bti_i18n LIKE "'.$GLOBALS['_GEN_commun']['i18n'].'%"' ;
130
        $resultat = $this->objet_pear_db->query($requete) ;
131
        if (DB::isError($resultat)) {
132
        	die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
133
        }
134
        if ($resultat->numRows()>0) {
135
        	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
136
        		$select[$ligne->bti_id]=$ligne->bti_nom;
137
    		}
138
        }
139
        $option=array('style'=>'width: 200px;');
140
		$select= new HTML_QuickForm_select('num_questionnaire', QUESTIONNAIRE_CHOIX, $select, $option);
141
		$select->setSize(1);
142
		$select->setMultiple(0);
143
		$form->addElement($select) ;
144
		$formtexte= new HTML_QuickForm_textarea('texte_questionnaire_envoye', QUESTIONNAIRE_TEXTE_MESSAGE_ENVOYE, array('style'=>'white-space: normal;'));
145
		$formtexte->setCols(40);
146
		$formtexte->setRows(10);
147
		$form->addElement($formtexte) ;
148
		$form->applyFilter('texte_questionnaire_envoye', 'addslashes') ;
149
        $form->addElement('text', 'mail_questionnaire', QUESTIONNAIRE_MAIL);
150
        $liste_bouton_debut = '<ul class="liste_bouton">'."\n";
151
        $form->addElement('html', $liste_bouton_debut);
152
        $form->addElement('submit', 'afficheur_enregistrer_quitter', QUESTIONNAIRE_ENREGISTRER_ET_QUITTER);
153
        $form->addElement('submit', 'afficheur_annuler', QUESTIONNAIRE_ANNULER);
154
        $liste_bouton_fin = '</ul>'."\n";
155
        $form->addElement('html', $liste_bouton_fin);
156
        $form->setDefaults($valeurs_par_defaut);
157
        $this->sortie_xhtml .= $form->toHTML()."\n";
158
        return $this->sortie_xhtml;
159
    }
160
 
161
}// Fin de la classe
162
 
163
// +------------------------------------------------------------------------------------------------------+
164
// |                                            PIED du PROGRAMME                                         |
165
// +------------------------------------------------------------------------------------------------------+
166
?>