1157 |
jp_milcent |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 5.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 1999-2006 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This file is part of papyrus_bp. |
|
|
|
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 |
// +------------------------------------------------------------------------------------------------------+
|
1161 |
jp_milcent |
24 |
// CVS : $Id: plan.php,v 1.2 2006-12-13 10:53:36 jp_milcent Exp $
|
1157 |
jp_milcent |
25 |
/**
|
|
|
26 |
* papyrus_bp - plan.php
|
|
|
27 |
*
|
|
|
28 |
* Description :
|
|
|
29 |
*
|
|
|
30 |
*@package papyrus_bp
|
|
|
31 |
//Auteur original :
|
|
|
32 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
33 |
//Autres auteurs :
|
|
|
34 |
*@author Aucun
|
|
|
35 |
*@copyright Tela-Botanica 1999-2006
|
1161 |
jp_milcent |
36 |
*@version $Revision: 1.2 $ $Date: 2006-12-13 10:53:36 $
|
1157 |
jp_milcent |
37 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
38 |
*/
|
|
|
39 |
|
|
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
41 |
// | ENTÊTE du PROGRAMME |
|
|
|
42 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
43 |
$GLOBALS['_GEN_commun']['info_applette_nom_fonction'] = 'afficherPlan';
|
|
|
44 |
$GLOBALS['_GEN_commun']['info_applette_balise'] = '\{\{[Pp]lan'.
|
|
|
45 |
'(?:\s*'.
|
|
|
46 |
'(?:'.
|
1161 |
jp_milcent |
47 |
'(site="[^"]*")|'.
|
|
|
48 |
'(permalien="[^"]*")|'.
|
1157 |
jp_milcent |
49 |
')'.
|
|
|
50 |
')+'.
|
|
|
51 |
'\s*\}\}';
|
|
|
52 |
|
|
|
53 |
// --------------------------------------------------------------------------------------------------------
|
|
|
54 |
/** Inclusion du fichier de configuration de cette application.*/
|
|
|
55 |
require_once GEN_CHEMIN_APPLETTE.'plan'.GEN_SEP.'configuration'.GEN_SEP.'plan_configuration.inc.php';
|
|
|
56 |
|
|
|
57 |
// Inclusion des fichiers de traduction de l'applette PLAN de Papyrus
|
|
|
58 |
if (file_exists(PLAN_CHEMIN_LANGUE.'plan_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
|
|
|
59 |
/** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
|
|
|
60 |
require_once PLAN_CHEMIN_LANGUE.'plan_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
|
|
|
61 |
} else {
|
|
|
62 |
/** Inclusion du fichier de traduction par défaut.*/
|
|
|
63 |
require_once PLAN_CHEMIN_LANGUE.'plan_langue_'.PLAN_I18N_DEFAUT.'.inc.php';
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
67 |
// | CORPS du PROGRAMME |
|
|
|
68 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
69 |
/** Fonction afficherPlan() - Retourne la liste des pages du plan d'un site.
|
|
|
70 |
*
|
|
|
71 |
* Cette fonction retourne la liste des pages du plan d'un site.
|
|
|
72 |
*
|
|
|
73 |
* @param array contient les arguments de la fonction.
|
|
|
74 |
* @param array tableau global de Papyrus.
|
|
|
75 |
* @return string HTML la liste de menus.
|
|
|
76 |
*/
|
|
|
77 |
function afficherPlan($tab_applette_arguments, $_GEN_commun)
|
|
|
78 |
{
|
|
|
79 |
// Initialisation des variables
|
|
|
80 |
$sortie = '';
|
|
|
81 |
$GLOBALS['_PLAN_']['erreurs'] = array();
|
|
|
82 |
$GLOBALS['_PLAN_']['informations'] = array();
|
|
|
83 |
$GLOBALS['_PLAN_']['sites'] = array();
|
|
|
84 |
|
|
|
85 |
//+----------------------------------------------------------------------------------------------------------------+
|
|
|
86 |
// Gestion des arguments
|
|
|
87 |
$balise = $tab_applette_arguments[0];
|
|
|
88 |
$tab_arguments = $tab_applette_arguments;
|
|
|
89 |
unset($tab_arguments[0]);
|
|
|
90 |
foreach($tab_arguments as $argument) {
|
|
|
91 |
if ($argument != '') {
|
|
|
92 |
$tab_parametres = explode('=', $argument);
|
|
|
93 |
$options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
|
|
|
94 |
}
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
//+----------------------------------------------------------------------------------------------------------------+
|
|
|
98 |
// Gestion des erreurs de paramètrage
|
|
|
99 |
if (!isset($options['site'])) {
|
|
|
100 |
$GLOBALS['_PLAN_']['erreurs'][] = sprintf(PLAN_LG_ERREUR_SITE, $balise);
|
|
|
101 |
}
|
|
|
102 |
if (!isset($options['permalien'])) {
|
|
|
103 |
$options['permalien'] = false;
|
|
|
104 |
}
|
|
|
105 |
if (isset($options['permalien']) && $options['permalien'] != '' && $options['permalien'] != 'oui' && $options['permalien'] != 'non') {
|
|
|
106 |
$GLOBALS['_PLAN_']['erreurs'][] = sprintf(PLAN_LG_ERREUR_PERMALIEN, $balise);
|
|
|
107 |
} else {
|
|
|
108 |
if ($options['permalien'] == 'oui') {
|
|
|
109 |
$options['permalien'] = true;
|
|
|
110 |
} else if ($options['permalien'] == 'non') {
|
|
|
111 |
$options['permalien'] = false;
|
|
|
112 |
}
|
|
|
113 |
}
|
1161 |
jp_milcent |
114 |
|
1157 |
jp_milcent |
115 |
//+----------------------------------------------------------------------------------------------------------------+
|
|
|
116 |
// Récupération des données
|
|
|
117 |
if (count($GLOBALS['_PLAN_']['erreurs']) == 0) {
|
1161 |
jp_milcent |
118 |
$tab_site = array_map('trim', explode(',', $options['site']));
|
|
|
119 |
if (count($tab_site) == 0) {
|
1157 |
jp_milcent |
120 |
$GLOBALS['_PLAN_']['informations'][] = sprintf(PLAN_LG_INFO_ZERO_PAGE, $options['site']);
|
1161 |
jp_milcent |
121 |
} else {
|
1157 |
jp_milcent |
122 |
foreach ($tab_site as $cle => $site) {
|
|
|
123 |
$aso_site_info = GEN_lireInfoSitePrincipalCodeAlpha($GLOBALS['_GEN_commun']['pear_db'], $site, DB_FETCHMODE_ASSOC);
|
|
|
124 |
$aso_site['abreviation'] = $site;
|
|
|
125 |
if (!empty($aso_site_info['gs_titre'])) {
|
|
|
126 |
$titre = $aso_site_info['gs_titre'];
|
|
|
127 |
} else {
|
|
|
128 |
$titre = $aso_site_info['gs_nom'];
|
|
|
129 |
}
|
|
|
130 |
$aso_site['titre'] = htmlentities($titre);
|
|
|
131 |
|
|
|
132 |
$url_site =& new Pap_URL();
|
|
|
133 |
$url_site->setUrlType('SITE');
|
|
|
134 |
$url_site->setId($aso_site_info['gs_id_site']);
|
|
|
135 |
$aso_site['url'] = $url_site->getUrl();
|
|
|
136 |
|
|
|
137 |
$aso_menus = GEN_retournerTableauMenusSiteCodeAlpha($GLOBALS['_GEN_commun']['pear_db'], $site);
|
|
|
138 |
$aso_site['pages'] = parserTableauMenus($aso_menus, $options['permalien']);
|
|
|
139 |
$GLOBALS['_PLAN_']['sites'][] = $aso_site;
|
|
|
140 |
}
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
//+----------------------------------------------------------------------------------------------------------------+
|
|
|
145 |
// Extrait les variables et les ajoutes à l'espace de noms local
|
|
|
146 |
// Gestion des squelettes
|
|
|
147 |
extract($GLOBALS['_PLAN_']);
|
|
|
148 |
// Démarre le buffer
|
|
|
149 |
ob_start();
|
|
|
150 |
// Inclusion du fichier
|
|
|
151 |
include(PLAN_CHEMIN_SQUELETTE.PLAN_SQUELETTE_LISTE);
|
|
|
152 |
// Récupérer le contenu du buffer
|
|
|
153 |
$sortie = ob_get_contents();
|
|
|
154 |
// Arrête et détruit le buffer
|
|
|
155 |
ob_end_clean();
|
|
|
156 |
|
|
|
157 |
//+----------------------------------------------------------------------------------------------------------------+
|
|
|
158 |
// Sortie
|
|
|
159 |
return $sortie;
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
function parserTableauMenus($aso_menus, $permalien)
|
|
|
163 |
{
|
|
|
164 |
$aso_arbo_site = array();
|
|
|
165 |
foreach ($aso_menus as $menu_id => $menu_valeur) {
|
|
|
166 |
if ( $menu_valeur['gm_date_fin_validite'] == ''
|
|
|
167 |
|| $menu_valeur['gm_date_fin_validite'] == '0000-00-00 00:00:00'
|
|
|
168 |
|| strtotime($menu_valeur['gm_date_fin_validite']) > time()) {
|
|
|
169 |
// Initialisation
|
|
|
170 |
$aso_page = array();
|
|
|
171 |
$aso_page['url'] = PLAN_LG_INCONNU_URL;
|
|
|
172 |
$aso_page['nom'] = PLAN_LG_INCONNU_NOM;
|
|
|
173 |
$aso_page['titre'] = PLAN_LG_INCONNU_TITRE;
|
|
|
174 |
$aso_page['sous_menus'] = 'fermer';
|
|
|
175 |
|
|
|
176 |
// Création de l'url
|
|
|
177 |
$une_url =& new Pap_URL();
|
|
|
178 |
$une_url->setId($menu_id);
|
|
|
179 |
$aso_page['url'] = $une_url->getURL();
|
|
|
180 |
|
|
|
181 |
// Construction de l'attribut title
|
|
|
182 |
$title = '';
|
|
|
183 |
if (!empty($menu_valeur['gm_titre'])) {
|
|
|
184 |
$title = $menu_valeur['gm_titre'];
|
|
|
185 |
} elseif (!empty($menu_valeur['gm_titre_alternatif'])) {
|
|
|
186 |
$title = $menu_valeur['gm_titre_alternatif'];
|
|
|
187 |
}
|
|
|
188 |
$aso_page['titre'] = htmlentities($title);
|
|
|
189 |
|
|
|
190 |
// Le nom
|
|
|
191 |
$aso_page['nom'] = htmlentities($menu_valeur['gm_nom']);
|
|
|
192 |
|
|
|
193 |
// Nous affichons ou pas le permalien
|
|
|
194 |
if ($permalien) {
|
|
|
195 |
$une_url->setPermalienBool(true);
|
|
|
196 |
$aso_page['permalien_url'] = $une_url->getURL();
|
|
|
197 |
$aso_page['permalien_nom'] = $une_url->getPermalien();
|
|
|
198 |
$une_url->setPermalienBool(false);
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
// Nous ajoutons les sous-menus s'il y en a.
|
|
|
202 |
$retour = parserTableauMenus($menu_valeur['sous_menus'], $permalien);
|
|
|
203 |
if (count($retour) != 0) {
|
|
|
204 |
$aso_page['sous_menus'] = 'ouvrir_liste';
|
|
|
205 |
$aso_arbo_site[] = $aso_page;
|
|
|
206 |
$aso_arbo_site = array_merge($aso_arbo_site, $retour);
|
|
|
207 |
$aso_arbo_site[]['sous_menus'] = 'fermer_liste';
|
|
|
208 |
} else {
|
|
|
209 |
$aso_arbo_site[] = $aso_page;
|
|
|
210 |
}
|
|
|
211 |
}
|
|
|
212 |
}
|
|
|
213 |
return $aso_arbo_site;
|
|
|
214 |
}
|
|
|
215 |
|
|
|
216 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
217 |
*
|
2092 |
drzraf |
218 |
* $Log: plan.php,v $
|
|
|
219 |
* Revision 1.2 2006-12-13 10:53:36 jp_milcent
|
|
|
220 |
* Correction dans la gestion des erreurs.
|
|
|
221 |
*
|
1161 |
jp_milcent |
222 |
* Revision 1.1 2006/12/13 09:42:39 jp_milcent
|
|
|
223 |
* Ajout de l'applette Plan.
|
1157 |
jp_milcent |
224 |
*
|
1161 |
jp_milcent |
225 |
*
|
1157 |
jp_milcent |
226 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
227 |
*/
|
|
|
228 |
?>
|