Subversion Repositories Applications.papyrus

Rev

Rev 25 | Rev 116 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25 Rev 40
Line 17... Line 17...
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
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                                  |
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                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: selecteur_sites.php,v 1.3 2004-07-06 17:07:16 jpm Exp $
22
// CVS : $Id: selecteur_sites.php,v 1.4 2004-09-15 09:32:01 jpm Exp $
23
/**
23
/**
24
* Applette : selecteur sites
24
* Applette : selecteur sites
25
*
25
*
26
* Génère un formulaire contenant un menu déroulant permettant de choisir un site parmis les disponibles.
26
* Génère un formulaire contenant un menu déroulant permettant de choisir un site parmis les disponibles.
27
* Nécessite :
27
* Nécessite :
28
* - Constantes et globales de Papyrus.
28
* - Constantes et globales de Papyrus.
29
* - Base de données de Papyrus
29
* - Base de données de Papyrus
30
* - Pear Net_URL
30
* - Pear Net_URL
31
* - Pear DB
31
* - Pear DB
32
* - API Débogage 1.0
32
* - API Débogage 1.0
-
 
33
* Le nom de l'applette est "SELECTEUR_SITES" pour afficher un formulaire HTML et "SELECTEUR_SITES_XHTML" 
-
 
34
* pour afficher un formulaire XHTML strict.
33
*
35
*
34
*@package Applette
36
*@package Applette
35
*@subpackage Selecteur_sites
37
*@subpackage Selecteur_sites
36
//Auteur original :
38
//Auteur original :
37
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
39
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
38
//Autres auteurs :
40
//Autres auteurs :
39
*@author        Aucun
41
*@author        Aucun
40
*@copyright     Tela-Botanica 2000-2004
42
*@copyright     Tela-Botanica 2000-2004
41
*@version       $Revision: 1.3 $ $Date: 2004-07-06 17:07:16 $
43
*@version       $Revision: 1.4 $ $Date: 2004-09-15 09:32:01 $
42
// +------------------------------------------------------------------------------------------------------+
44
// +------------------------------------------------------------------------------------------------------+
43
*/
45
*/
Line 44... Line 46...
44
 
46
 
45
// +------------------------------------------------------------------------------------------------------+
47
// +------------------------------------------------------------------------------------------------------+
46
// |                                            ENTÊTE du PROGRAMME                                       |
48
// |                                            ENTÊTE du PROGRAMME                                       |
47
// +------------------------------------------------------------------------------------------------------+
49
// +------------------------------------------------------------------------------------------------------+
48
$_GEN_commun['info_applette_nom_fonction'] = 'afficherSelecteurSite';
50
$_GEN_commun['info_applette_nom_fonction'] = 'afficherSelecteurSite';
Line 49... Line 51...
49
$_GEN_commun['info_applette_balise'] = 'SELECTEUR_SITES';
51
$_GEN_commun['info_applette_balise'] = 'SELECTEUR_SITES_?(XHTML)?';
50
 
52
 
51
// +------------------------------------------------------------------------------------------------------+
53
// +------------------------------------------------------------------------------------------------------+
Line 65... Line 67...
65
*
67
*
66
* @param  array  tableau d'éventuel arguments présent dans la balise transmis à la fonction. 
68
* @param  array  tableau d'éventuel arguments présent dans la balise transmis à la fonction. 
67
* @param  array  tableau global de Papyrus.
69
* @param  array  tableau global de Papyrus.
68
* @return   string  formulaire XHTML contenant les sites disponibles.
70
* @return   string  formulaire XHTML contenant les sites disponibles.
69
*/
71
*/
70
function afficherSelecteurSite($tab_arguments, $_GEN_commun)
72
function afficherSelecteurSite($tab_applette_arguments, $_GEN_commun)
71
{
73
{
72
    // Initialisation de variable de configuration.
74
    // Initialisation de variable de configuration.
73
    $objet_pear_db = $_GEN_commun['pear_db'];//objet Pear créé par DB contenant la connexion à la base de données.
75
    $objet_pear_db = $_GEN_commun['pear_db'];//objet Pear créé par DB contenant la connexion à la base de données.
74
    $code_site = $_GEN_commun['url_site'];//identifiant du site courant.
76
    $code_site = $_GEN_commun['url_site'];//identifiant du site courant.
75
    $id_langue = $_GEN_commun['url_i18n'];//identifiant de la langue principale du site courant.
77
    $id_langue = $_GEN_commun['url_i18n'];//identifiant de la langue principale du site courant.
76
    $url_cle_site = GEN_URL_CLE_SITE;
78
    $url_cle_site = GEN_URL_CLE_SITE;
77
    $url_cle_i18n = GEN_URL_CLE_I18N;
79
    $url_cle_i18n = GEN_URL_CLE_I18N;
78
    $url_id_type_site = GEN_URL_ID_TYPE_SITE;
80
    $url_id_type_site = GEN_URL_ID_TYPE_SITE;
79
    $indent_origine = 12;// Indentation de départ en nombre d'espace
81
    $indent_origine = 12;// Indentation de départ en nombre d'espace
80
    $indent_pas     = 4;// Pas d'indentation en nombre d'espace
82
    $indent_pas     = 4;// Pas d'indentation en nombre d'espace
-
 
83
    
-
 
84
    // Récupérations des arguments passés dans la balise.
-
 
85
    // Nous vérifions si on veut du XHTML strict ou pas
-
 
86
    $bln_xhtml_strict = 0;
-
 
87
    if (isset($tab_applette_arguments[2]) && $tab_applette_arguments[2] == 'XHTML') {
-
 
88
        $bln_xhtml_strict = 1;
-
 
89
    }
Line 81... Line 90...
81
    
90
    
82
    // Texte à traduire
91
    // Texte à traduire
83
    $etiquette_legende = 'Sélecteur de monde';
92
    $etiquette_legende = 'Sélecteur de monde';
84
    $etiquette_option_defaut = 'changer de monde';
93
    $etiquette_option_defaut = 'changer de monde';
Line 91... Line 100...
91
                'WHERE './/gs_id_site <> 1 '.// 1 correspond à l'identifiant du site Admin par défaut.
100
                'WHERE './/gs_id_site <> 1 '.// 1 correspond à l'identifiant du site Admin par défaut.
92
                'gsr_id_site_01 = gsr_id_site_02 './/'AND 
101
                'gsr_id_site_01 = gsr_id_site_02 './/'AND 
93
                'AND gsr_id_valeur = 102 '.// 102 = site "principal"
102
                'AND gsr_id_valeur = 102 '.// 102 = site "principal"
94
                'AND gs_id_site = gsr_id_site_01';
103
                'AND gs_id_site = gsr_id_site_01';
Line 95... Line 104...
95
    
104
    
96
    $resultat = $objet_pear_db->query($requete);
105
    $retourultat = $objet_pear_db->query($requete);
97
    (DB::isError($resultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '';
106
    (DB::isError($retourultat)) ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $retourultat->getMessage(), $requete)) : '';
98
    if ( $resultat->numRows() == 0 ) {
107
    if ( $retourultat->numRows() == 0 ) {
99
        $res =  str_repeat(' ', $indent_origine + ($indent_pas * 0)).
108
        $retour =  str_repeat(' ', $indent_origine + ($indent_pas * 0)).
100
                '<!-- '.$etiquette_erreur.' -->';
109
                '<!-- '.$etiquette_erreur.' -->';
101
    } else {
110
    } else {
102
        // Préparation de l'url de retour du formulaire
111
        // Préparation de l'url de retour du formulaire
103
        $objet_pear_url = & new Net_URL('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
112
        $objet_pear_url = & new Net_URL('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
104
        $objet_pear_url->addQueryString($url_cle_i18n, $id_langue);
113
        $objet_pear_url->addQueryString($url_cle_i18n, $id_langue);
105
        // Préparation du code du sites
114
        // Préparation du code du sites
Line 106... Line 115...
106
        $champs_code_site = ($url_id_type_site == 'int') ? 'gs_code_num' : 'gs_code_alpha';
115
        $champs_code_site = ($url_id_type_site == 'int') ? 'gs_code_num' : 'gs_code_alpha';
107
        
116
        
-
 
117
        // Préparation du formulaire
-
 
118
        $retour = str_repeat(' ', $indent_origine + ($indent_pas * 0)).
-
 
119
                '<form id="selecteur_sites" ';
-
 
120
        // Test sur XHTML strict
-
 
121
        if ($bln_xhtml_strict == 0) {
108
        // Préparation du formulaire
122
            $retour .= 'name="selecteur_sites" ';
-
 
123
        }
109
        $res = str_repeat(' ', $indent_origine + ($indent_pas * 0)).
124
        $retour .= 'action="'.$objet_pear_url->getURL().'" method="get">'."\n";
110
                '<form id="selecteur_sites" name="selecteur_sites" action="'.$objet_pear_url->getURL().'" method="get">'."\n";
125
        
111
        $res .= str_repeat(' ', $indent_origine + ($indent_pas * 1)).
126
        $retour .= str_repeat(' ', $indent_origine + ($indent_pas * 1)).
112
                '<fieldset>'."\n";
127
                '<fieldset>'."\n";
113
        $res .= str_repeat(' ', $indent_origine + ($indent_pas * 2)).
128
        $retour .= str_repeat(' ', $indent_origine + ($indent_pas * 2)).
114
                '<legend>'.$etiquette_legende.'</legend>'."\n";
129
                '<legend>'.$etiquette_legende.'</legend>'."\n";
115
        $res .= str_repeat(' ', $indent_origine + ($indent_pas * 2)).
130
        $retour .= str_repeat(' ', $indent_origine + ($indent_pas * 2)).
116
                '<select id="'.$url_cle_site.'" name="'.$url_cle_site.'" onchange="javascript:this.form.submit();">'."\n";
131
                '<select id="'.$url_cle_site.'" name="'.$url_cle_site.'" onchange="javascript:this.form.submit();">'."\n";
117
        $res .= str_repeat(' ', $indent_origine + ($indent_pas * 3)).
132
        $retour .= str_repeat(' ', $indent_origine + ($indent_pas * 3)).
118
                '<option value="'.$code_site.'" selected="selected">'.$etiquette_option_defaut.'</option>'."\n";
133
                '<option value="'.$code_site.'" selected="selected">'.$etiquette_option_defaut.'</option>'."\n";
119
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
134
        while ($ligne = $retourultat->fetchRow(DB_FETCHMODE_ASSOC)) {
Line 120... Line 135...
120
            // Initialisation des variables
135
            // Initialisation des variables
121
            $nom = '';
136
            $nom = '';
Line 126... Line 141...
126
                                    'WHERE '.$ligne['gs_id_site'].' = gsr_id_site_01 '.
141
                                    'WHERE '.$ligne['gs_id_site'].' = gsr_id_site_01 '.
127
                                    'AND gsr_id_valeur = 1 '. // 1 = "avoir traduction"
142
                                    'AND gsr_id_valeur = 1 '. // 1 = "avoir traduction"
128
                                    'AND gsr_id_site_02 = gs_id_site '.
143
                                    'AND gsr_id_site_02 = gs_id_site '.
129
                                    'AND gs_ce_i18n = "'.$id_langue.'"';
144
                                    'AND gs_ce_i18n = "'.$id_langue.'"';
Line 130... Line 145...
130
            
145
            
131
            $resultat_traduction = $objet_pear_db->query($requete_traduction);
146
            $retourultat_traduction = $objet_pear_db->query($requete_traduction);
132
            (DB::isError($resultat_traduction))
147
            (DB::isError($retourultat_traduction))
133
                ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_traduction->getMessage(), $requete_traduction))
148
                ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $retourultat_traduction->getMessage(), $requete_traduction))
134
                : '';
149
                : '';
135
            if ( $resultat_traduction->numRows() != 0 ) {
150
            if ( $retourultat_traduction->numRows() != 0 ) {
136
                $ligne_traduction = $resultat_traduction->fetchRow(DB_FETCHMODE_OBJECT);
151
                $ligne_traduction = $retourultat_traduction->fetchRow(DB_FETCHMODE_OBJECT);
137
                $nom = $ligne_traduction->gs_nom;
152
                $nom = $ligne_traduction->gs_nom;
138
            } else {
153
            } else {
139
                $nom = $ligne['gs_nom'];
154
                $nom = $ligne['gs_nom'];
140
            }
155
            }
141
            $resultat_traduction->free();
156
            $retourultat_traduction->free();
142
            $res .= str_repeat(' ', $indent_origine + ($indent_pas * 3)).
157
            $retour .= str_repeat(' ', $indent_origine + ($indent_pas * 3)).
143
                    '<option value="'.$ligne[$champs_code_site].'">'.$nom.'</option>'."\n";
158
                    '<option value="'.$ligne[$champs_code_site].'">'.$nom.'</option>'."\n";
144
        }
159
        }
145
        $res .= str_repeat(' ', $indent_origine + ($indent_pas * 2)).
160
        $retour .= str_repeat(' ', $indent_origine + ($indent_pas * 2)).
146
                '</select>'."\n";
161
                '</select>'."\n";
147
        $res .= str_repeat(' ', $indent_origine + ($indent_pas * 2)).
162
        $retour .= str_repeat(' ', $indent_origine + ($indent_pas * 2)).
148
                '<input type="submit" value="'.$etiquette_bouton_valider.'"/>'."\n";
163
                '<input type="submit" value="'.$etiquette_bouton_valider.'"/>'."\n";
149
        $res .= str_repeat(' ', $indent_origine + ($indent_pas * 1)).
164
        $retour .= str_repeat(' ', $indent_origine + ($indent_pas * 1)).
150
                '</fieldset>'."\n";
165
                '</fieldset>'."\n";
151
        $res .= str_repeat(' ', $indent_origine + ($indent_pas * 0)).
166
        $retour .= str_repeat(' ', $indent_origine + ($indent_pas * 0)).
152
                '</form>'."\n";
167
                '</form>'."\n";
153
    }
168
    }
Line 154... Line 169...
154
    $resultat->free();
169
    $retourultat->free();
155
    
170
    
Line 156... Line 171...
156
    return $res;
171
    return $retour;
157
}
172
}
158
 
173
 
Line 163... Line 178...
163
 
178
 
164
 
179
 
165
/* +--Fin du code ----------------------------------------------------------------------------------------+
180
/* +--Fin du code ----------------------------------------------------------------------------------------+
-
 
181
*
-
 
182
* $Log: not supported by cvs2svn $
-
 
183
* Revision 1.3  2004/07/06 17:07:16  jpm
166
*
184
* Modification de la documentation pour une mailleur analyse par PhpDocumentor.
167
* $Log: not supported by cvs2svn $
185
*
168
* Revision 1.2  2004/06/21 07:37:50  alex
186
* Revision 1.2  2004/06/21 07:37:50  alex
169
* Modification d'un label
187
* Modification d'un label
170
*
188
*