Subversion Repositories Applications.papyrus

Rev

Rev 1161 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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