Subversion Repositories Applications.papyrus

Rev

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

Rev Author Line No. Line
126 jpm 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
// +------------------------------------------------------------------------------------------------------+
134 jpm 8
// | This file is part of Papyrus.                                                                        |
126 jpm 9
// |                                                                                                      |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
11
// | it under the terms of the GNU General Public License as published by                                 |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
251 jpm 24
// CVS : $Id: adme_general.fonct.php,v 1.8 2005-01-26 16:18:05 jpm Exp $
126 jpm 25
/**
134 jpm 26
* Contient l'affichage par défaut de l'appli quand aucune actin
126 jpm 27
*
134 jpm 28
* Ce fichier contient les fonctions d'affichage commune à toute l'application Admin Menu.
29
* Nous y trouvons, entre autre, la fonction d'affichage par défaut de l'appli.
126 jpm 30
*
134 jpm 31
*@package Admin_menu
32
*@subpackage Fonctions
126 jpm 33
//Auteur original :
134 jpm 34
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
126 jpm 35
//Autres auteurs :
36
*@author        Aucun
37
*@copyright     Tela-Botanica 2000-2004
251 jpm 38
*@version       $Revision: 1.8 $ $Date: 2005-01-26 16:18:05 $
126 jpm 39
// +------------------------------------------------------------------------------------------------------+
40
*/
41
 
42
// +------------------------------------------------------------------------------------------------------+
43
// |                                            ENTETE du PROGRAMME                                       |
44
// +------------------------------------------------------------------------------------------------------+
45
 
46
 
47
// +------------------------------------------------------------------------------------------------------+
48
// |                                           LISTE de FONCTIONS                                         |
49
// +------------------------------------------------------------------------------------------------------+
141 jpm 50
/** Fonction ADME_afficherFormPrincipal() - Affichage par défaut.
51
*
52
* Fournit l'affichage par défaut de l'application Admin Menus.
53
*
54
* @param  object objet Pear de connection à la base de données.
55
* @param  object objet Pear représentant l'url de base.
56
* @return string le XHTML par défaut de la page.
57
*/
58
function ADME_afficherFormPrincipal($objet_pear_db, $objet_pear_url, $adme_site_id, $adme_menu_id, $adme_action)
126 jpm 59
{
60
    //---------------------------------------------------------------------------------------------------------------
61
    // Nous affichons la liste des menus classiques et communs
62
    $retour = '';
63
    // Liste des sites principaux
64
    $requete =  'SELECT gs_id_site, gs_code_alpha, gs_nom '.
65
                'FROM gen_site, gen_site_relation '.
66
                'WHERE gsr_id_site_01 = gsr_id_site_02 '.
67
                'AND gsr_id_valeur = 102 '.// 102 = site "principal"
68
                'AND gsr_id_site_01 = gs_id_site '.
132 jpm 69
                'ORDER BY gsr_ordre ASC';
126 jpm 70
 
71
    $resultat = $objet_pear_db->query($requete);
72
    (DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ;
73
 
74
    //---------------------------------------------------------------------------------------------------------------
75
    // Création du formulaire
76
    // Notes : Quickform semble remplacer les & des &amp; à nouveau par des &amp; solution utiliser str_replace()...
77
    $form =& new HTML_QuickForm('adme_form_sites', 'post', str_replace('&amp;', '&', $objet_pear_url->getUrl()));
78
    $tab_index = 1000;
79
    $squelette =& $form->defaultRenderer();
80
    $squelette->setFormTemplate("\n".'<form{attributes}>'."\n".'{content}'."\n"."\n".'</form>'."\n");
81
    $squelette->setElementTemplate( '{label}'."\n".'{element}'."\n".
82
                                    '<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n".
83
                                    '<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n");
84
    $partie_site_debut =    '<fieldset>'."\n".
150 jpm 85
                            '<legend>'.ADME_LG_FORM_SITE_TITRE.'</legend>'."\n";
126 jpm 86
    $form->addElement('html', $partie_site_debut);
87
    $id = 'adme_site_id';
88
    $aso_attributs = array('id'=> $id, 'tabindex' => $tab_index++, 'onchange' => 'javascript:this.form.submit();');
148 jpm 89
    $label = '<label for="'.$id.'">'.ADME_LG_FORM_SITE_CHOIX.'</label>';
126 jpm 90
    $objet_select = new HTML_QuickForm_select($id, $label, '', $aso_attributs);
91
    $aso_options = array();
92
    while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
141 jpm 93
        if (!isset($adme_site_id) || $adme_site_id == 0) {
94
            $adme_site_id = $ligne->gs_id_site;
126 jpm 95
        }
141 jpm 96
        if ($ligne->gs_id_site == $adme_site_id) {
132 jpm 97
            $objet_select->addOption(htmlentities($ligne->gs_nom.' ('.$ligne->gs_code_alpha.')'), $ligne->gs_id_site, 'selected="selected"');
251 jpm 98
            // Attribution du nom du site sur lequel on travaille pour le titre
99
            $site_nom = $ligne->gs_nom;
126 jpm 100
        } else {
132 jpm 101
            $objet_select->addOption(htmlentities($ligne->gs_nom.' ('.$ligne->gs_code_alpha.')'), $ligne->gs_id_site);
126 jpm 102
        }
103
    }
104
    $resultat->free();
105
    $form->addElement($objet_select);
148 jpm 106
    $form->addElement('submit', 'choisir_site', ADME_LG_FORM_SITE_VALIDER);
126 jpm 107
    $partie_site_fin = "\n".'</fieldset>';
108
    $form->addElement('html', $partie_site_fin);
109
 
110
    // Instanciation des valeurs par défaut du formulaire
141 jpm 111
    $form->setDefaults($adme_site_id);
126 jpm 112
 
148 jpm 113
    $retour .= '<h1>'.ADME_LG_MENU_TITRE.$site_nom.'</h1>'."\n";
126 jpm 114
    $retour .= '<p>'."\n";
115
    $retour .= $form->toHTML()."\n";
116
    $retour .= '</p>'."\n";
117
 
118
    //---------------------------------------------------------------------------------------------------------------
119
    // Gestion des menus classiques
120
    $retour .= '<p>'."\n";
121
    $objet_pear_url_copie = $objet_pear_url;
166 jpm 122
    $objet_pear_url_copie->addQueryString('adme_action', ADME_LG_ACTION_CLASSIQUE_AJOUTER);
141 jpm 123
    $objet_pear_url_copie->addQueryString('adme_site_id', $adme_site_id);
126 jpm 124
    $objet_pear_url_copie->addQueryString('adme_menu_id', 0);
125
    $url_ajout_menu_classique_n1 = $objet_pear_url_copie->getURL();
126
    unset($url_ajout_menu_n1);
127
    $retour .=    '<a href="'.$url_ajout_menu_classique_n1.'" >'.
148 jpm 128
                            ADME_LG_MENU_CLASSIQUE_RACINE.'&nbsp;'.
126 jpm 129
                            '<img class="'.ADME_CLASS_IMG_ICONE.'" src="'.ADME_IMAGE_NOUVEAU.'" alt="+" />'.
130
                        '</a>'."\n";
131
    $retour .= '</p>'."\n";
132
 
141 jpm 133
    $retour .= ADME_afficherListeMenuClassique($objet_pear_db, $objet_pear_url, $adme_site_id, $adme_menu_id, $adme_action, 0);
126 jpm 134
    //---------------------------------------------------------------------------------------------------------------
135
    // Gestion des menus communs
136
    $retour .=     '<p>'."\n";
137
    $objet_pear_url_copie = $objet_pear_url;
166 jpm 138
    $objet_pear_url_copie->addQueryString('adme_action', ADME_LG_ACTION_COMMUN_AJOUTER);
141 jpm 139
    $objet_pear_url_copie->addQueryString('adme_site_id', $adme_site_id);
126 jpm 140
    $objet_pear_url_copie->addQueryString('adme_menu_id', 0);
141
    $url_ajout_menu_commun_n1 = $objet_pear_url_copie->getURL();
142
    unset($url_ajout_menu_n1);
143
    $retour .=     '<a href="'.$url_ajout_menu_commun_n1.'">'.
148 jpm 144
                            ADME_LG_MENU_COMMUN_RACINE.'&nbsp;'.
126 jpm 145
                            '<img class="'.ADME_CLASS_IMG_ICONE.'" src="'.ADME_IMAGE_NOUVEAU.'" alt="+" />'.
146
                        '</a>'."\n";
147
    $retour .=     '</p>'."\n";
141 jpm 148
    $retour .= ADME_afficherListeMenuCommun($objet_pear_db, $objet_pear_url, $adme_site_id, $adme_menu_id, $adme_action, 0);
126 jpm 149
    return $retour;
150
}
141 jpm 151
 
126 jpm 152
// +------------------------------------------------------------------------------------------------------+
153
// |                                            PIED du PROGRAMME                                         |
154
// +------------------------------------------------------------------------------------------------------+
155
 
156
 
157
/* +--Fin du code ----------------------------------------------------------------------------------------+
158
*
159
* $Log: not supported by cvs2svn $
251 jpm 160
* Revision 1.7  2004/11/24 11:31:51  jpm
161
* Ajout d'une contante de langue à la place d'un texte.
162
*
166 jpm 163
* Revision 1.6  2004/11/10 17:26:07  jpm
164
* Fin gestion de la traduction.
165
*
150 jpm 166
* Revision 1.5  2004/11/10 11:58:54  jpm
167
* Mise en place des constantes de traduction de l'appli.
168
*
148 jpm 169
* Revision 1.4  2004/11/09 17:48:35  jpm
170
* Gestion de différentes interfaces d'administration.
171
*
141 jpm 172
* Revision 1.3  2004/11/09 12:37:34  jpm
173
* Fin de gestion des menus et mise en conformité avec la convention de codage.
174
*
134 jpm 175
* Revision 1.2  2004/11/08 17:41:07  jpm
176
* Légères corrections : multisite, corrections SQL.
177
*
132 jpm 178
* Revision 1.1  2004/11/04 12:26:42  jpm
179
* Contient les fonctions d'affichage général de l'appli ADME.
126 jpm 180
*
132 jpm 181
*
126 jpm 182
* +-- Fin du code ----------------------------------------------------------------------------------------+
183
*/
184
?>