Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1688 Rev 1968
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: lien.php,v 1.1 2006-12-08 20:08:59 jp_milcent Exp $
24
// CVS : $Id: lien.php,v 1.1.4.1 2008-11-14 11:22:22 jp_milcent Exp $
25
/**
25
/**
26
* papyrus_bp - lien.php
26
* papyrus_bp - lien.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.1 $ $Date: 2006-12-08 20:08:59 $
36
*@version       $Revision: 1.1.4.1 $ $Date: 2008-11-14 11:22:22 $
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'] = 'afficherLien';
43
$GLOBALS['_GEN_commun']['info_applette_nom_fonction'] = 'afficherLien';
44
$GLOBALS['_GEN_commun']['info_applette_balise'] = '\{\{[Ll]ien(?:\s*(?:((?:menu|site)="[^"]+")|(titre="[^"]+")|))+\s*\}\}';
44
$GLOBALS['_GEN_commun']['info_applette_balise'] = '\{\{[Ll]ien(?:\s*(?:((?:menu|site)="[^"]+")|(titre="[^"]+")|))+\s*\}\}';
45
 
45
 
46
// --------------------------------------------------------------------------------------------------------
46
// --------------------------------------------------------------------------------------------------------
47
/** Inclusion du fichier de configuration de cette application.*/
47
/** Inclusion du fichier de configuration de cette application.*/
48
require_once GEN_CHEMIN_APPLETTE.'lien'.GEN_SEP.'configuration'.GEN_SEP.'lien_configuration.inc.php';
48
require_once GEN_CHEMIN_APPLETTE.'lien'.GEN_SEP.'configuration'.GEN_SEP.'lien_configuration.inc.php';
49
 
49
 
50
// Inclusion des fichiers de traduction de l'applette LIEN de Papyrus
50
// Inclusion des fichiers de traduction de l'applette LIEN de Papyrus
51
if (file_exists(LIEN_CHEMIN_LANGUE.'lien_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
51
if (file_exists(LIEN_CHEMIN_LANGUE.'lien_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
52
    /** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
52
    /** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
53
    require_once LIEN_CHEMIN_LANGUE.'lien_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
53
    require_once LIEN_CHEMIN_LANGUE.'lien_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
54
} else {
54
} else {
55
    /** Inclusion du fichier de traduction par défaut.*/
55
    /** Inclusion du fichier de traduction par défaut.*/
56
    require_once LIEN_CHEMIN_LANGUE.'lien_langue_'.LIEN_I18N_DEFAUT.'.inc.php';
56
    require_once LIEN_CHEMIN_LANGUE.'lien_langue_'.LIEN_I18N_DEFAUT.'.inc.php';
57
}
57
}
58
 
58
 
59
 
59
 
60
// +------------------------------------------------------------------------------------------------------+
60
// +------------------------------------------------------------------------------------------------------+
61
// |                                            CORPS du PROGRAMME                                        |
61
// |                                            CORPS du PROGRAMME                                        |
62
// +------------------------------------------------------------------------------------------------------+
62
// +------------------------------------------------------------------------------------------------------+
63
/** Fonction afficherLien() - Retourne le lien d'un menu ou d'un site.
63
/** Fonction afficherLien() - Retourne le lien d'un menu ou d'un site.
64
*
64
*
65
* Cette fonction retourne un lien vers un menu ou un site. Le lien est créé dynamiquement et donc toujours à jour.
65
* Cette fonction retourne un lien vers un menu ou un site. Le lien est créé dynamiquement et donc toujours à jour.
66
* Il est possible d'utiliser les code numérique ou alphanumérique.
66
* Il est possible d'utiliser les code numérique ou alphanumérique.
67
*
67
*
68
* @param  array contient les arguments de la fonction.
68
* @param  array contient les arguments de la fonction.
69
* @param  array  tableau global de Papyrus.
69
* @param  array  tableau global de Papyrus.
70
* @return string XHTML le lien.
70
* @return string XHTML le lien.
71
*/
71
*/
72
function afficherLien($tab_applette_arguments, $_GEN_commun)
72
function afficherLien($tab_applette_arguments, $_GEN_commun)
73
{
73
{
74
	// Initialisation des variables
74
	// Initialisation des variables
75
    $sortie = '';
75
    $sortie = '';
-
 
76
    $niveau = null;
76
	$GLOBALS['_LIEN_']['url'] = '';
77
	$GLOBALS['_LIEN_']['url'] = '';
77
	$GLOBALS['_LIEN_']['titre'] = LIEN_LG_ERREUR_TITRE;
78
	$GLOBALS['_LIEN_']['titre'] = LIEN_LG_ERREUR_TITRE;
78
    $GLOBALS['_LIEN_']['erreurs'] = array();
79
    $GLOBALS['_LIEN_']['erreurs'] = array();
79
 
80
 
80
	//+----------------------------------------------------------------------------------------------------------------+
81
	//+----------------------------------------------------------------------------------------------------------------+
81
	// Gestion des arguments
82
	// Gestion des arguments
82
    $tab_arguments = $tab_applette_arguments;
83
    $tab_arguments = $tab_applette_arguments;
83
	unset($tab_arguments[0]);
84
	unset($tab_arguments[0]);
84
    foreach($tab_arguments as $argument) {
85
    foreach($tab_arguments as $argument) {
85
	    $tab_parametres = explode('=', $argument);
86
	    $tab_parametres = explode('=', $argument);
86
	    $options[$tab_parametres[0]] = trim($tab_parametres[1], '"'); 
87
	    $options[$tab_parametres[0]] = trim($tab_parametres[1], '"'); 
87
    }
88
    }
88
	
89
	
89
	//+----------------------------------------------------------------------------------------------------------------+
90
	//+----------------------------------------------------------------------------------------------------------------+
90
    // Gestion des erreurs de paramètrage
91
    // Gestion des erreurs de paramètrage
91
    if (!isset($options['menu']) && !isset($options['site']) ) {
92
    if (!isset($options['menu']) && !isset($options['site']) ) {
92
        $GLOBALS['_LIEN_']['erreur'] = LIEN_LG_ERREUR_SITE_MENU;
93
        $GLOBALS['_LIEN_']['erreur'] = LIEN_LG_ERREUR_SITE_MENU;
93
    } else {
94
    } else {
94
    	if (isset($options['menu'])) {
95
    	if (isset($options['menu'])) {
95
    		$niveau = 'menu';
96
    		$niveau = 'menu';
96
    		$identifiant = $options['menu']; 
97
    		$identifiant = $options['menu']; 
97
    	} else if (isset($options['site'])) {
98
    	} else if (isset($options['site'])) {
98
    		$niveau = 'site';
99
    		$niveau = 'site';
99
    		$identifiant = $options['site'];
100
    		$identifiant = $options['site'];
100
    	} 
101
    	} 
101
    }
102
    }
102
 
103
 
103
    //+----------------------------------------------------------------------------------------------------------------+
104
    //+----------------------------------------------------------------------------------------------------------------+
104
    // Récupération des données
105
    // Récupération des données
105
	$bdd =& $GLOBALS['_GEN_commun']['pear_db'];
106
	$bdd =& $GLOBALS['_GEN_commun']['pear_db'];
106
	$id_langue = $GLOBALS['_GEN_commun']['i18n']; //identifiant de la langue choisie
107
	$id_langue = $GLOBALS['_GEN_commun']['i18n']; //identifiant de la langue choisie
107
	if (isset($id_langue) && ($id_langue != '')) {
108
	if (isset($id_langue) && ($id_langue != '')) {
108
		$langue_url = $id_langue;
109
		$langue_url = $id_langue;
109
	} else {
110
	} else {
110
		$langue_url = GEN_I18N_ID_DEFAUT;
111
		$langue_url = GEN_I18N_ID_DEFAUT;
111
	}
112
	}
112
	$une_url =& new Pap_URL();
113
	$une_url =& new Pap_URL();
113
	// Les sites
114
	// Les sites
114
	if ($niveau == "site") {
115
	if ($niveau == "site") {
115
		if (preg_match('/^[0-9]+$/', $identifiant)) {
116
		if (preg_match('/^[0-9]+$/', $identifiant)) {
116
			$aso_site = GEN_lireInfoSiteI18nCodeAlpha($bdd, GEN_retournerSiteCodeAlpha($bdd, $identifiant), $langue_url, DB_FETCHMODE_ASSOC);
117
			$aso_site = GEN_lireInfoSiteI18nCodeAlpha($bdd, GEN_retournerSiteCodeAlpha($bdd, $identifiant), $langue_url, DB_FETCHMODE_ASSOC);
117
		} else {
118
		} else {
118
			$aso_site = GEN_lireInfoSiteI18nCodeAlpha($bdd, $identifiant, $langue_url, DB_FETCHMODE_ASSOC);
119
			$aso_site = GEN_lireInfoSiteI18nCodeAlpha($bdd, $identifiant, $langue_url, DB_FETCHMODE_ASSOC);
119
		}
120
		}
120
		
121
		
121
        if (isset($options['titre'])) {
122
        if (isset($options['titre'])) {
122
        	$GLOBALS['_LIEN_']['titre'] = $options['titre'];
123
        	$GLOBALS['_LIEN_']['titre'] = $options['titre'];
123
        } else {
124
        } else {
124
        	if (!empty($aso_site['gs_titre'])) {
125
        	if (!empty($aso_site['gs_titre'])) {
125
				$GLOBALS['_LIEN_']['titre'] = $aso_site['gs_titre'];
126
				$GLOBALS['_LIEN_']['titre'] = $aso_site['gs_titre'];
126
        	} else {
127
        	} else {
127
				$GLOBALS['_LIEN_']['titre'] = $aso_site['gs_nom'];
128
				$GLOBALS['_LIEN_']['titre'] = $aso_site['gs_nom'];
128
        	}
129
        	}
129
        }
130
        }
130
    	$une_url->setUrlType('SITE');
131
    	$une_url->setUrlType('SITE');
131
    	$une_url->setId($aso_site['gs_id_site']);
132
    	$une_url->setId($aso_site['gs_id_site']);
132
	}
133
	}
133
	// Les menus
134
	// Les menus
134
	if ($niveau == "menu") {
135
	if ($niveau == "menu") {
135
		if (preg_match('/^[0-9]+$/', $identifiant)) {
136
		if (preg_match('/^[0-9]+$/', $identifiant)) {
136
			$aso_menu = GEN_lireInfoMenu($bdd, GEN_retournerIdMenuParCodeNum($bdd, $identifiant), DB_FETCHMODE_ASSOC);
137
			$aso_menu = GEN_lireInfoMenu($bdd, GEN_retournerIdMenuParCodeNum($bdd, $identifiant), DB_FETCHMODE_ASSOC);
137
		} else {
138
		} else {
138
			$aso_menu = GEN_lireInfoMenu($bdd, GEN_retournerIdMenuParCodeNum($bdd, GEN_retournerMenuCodeNum($bdd, $identifiant)), DB_FETCHMODE_ASSOC);
139
			$aso_menu = GEN_lireInfoMenu($bdd, GEN_retournerIdMenuParCodeNum($bdd, GEN_retournerMenuCodeNum($bdd, $identifiant)), DB_FETCHMODE_ASSOC);
139
		}
140
		}
140
        if (isset($options['titre'])) {
141
        if (isset($options['titre'])) {
141
        	$GLOBALS['_LIEN_']['titre'] = $options['titre'];
142
        	$GLOBALS['_LIEN_']['titre'] = $options['titre'];
142
        } else {
143
        } else {
143
        	if (!empty($aso_menu['gm_titre'])) {
144
        	if (!empty($aso_menu['gm_titre'])) {
144
				$GLOBALS['_LIEN_']['titre'] = $aso_menu['gm_titre'];
145
				$GLOBALS['_LIEN_']['titre'] = $aso_menu['gm_titre'];
145
            } elseif (!empty($aso_menu['gm_titre_alternatif'])) {
146
            } elseif (!empty($aso_menu['gm_titre_alternatif'])) {
146
				$GLOBALS['_LIEN_']['titre'] = $aso_menu['gm_titre_alternatif'];
147
				$GLOBALS['_LIEN_']['titre'] = $aso_menu['gm_titre_alternatif'];
147
            } elseif (!empty($aso_menu['gm_nom'])) {
148
            } elseif (!empty($aso_menu['gm_nom'])) {
148
				$GLOBALS['_LIEN_']['titre'] = $aso_menu['gm_nom'];
149
				$GLOBALS['_LIEN_']['titre'] = $aso_menu['gm_nom'];
149
            }
150
            }
150
        }
151
        }
151
    	$une_url->setId($aso_menu['gm_id_menu']);
152
    	$une_url->setId($aso_menu['gm_id_menu']);
152
    }
153
    }
153
	    
154
	    
154
	if ($langue_url != GEN_I18N_ID_DEFAUT) {
155
	if ($langue_url != GEN_I18N_ID_DEFAUT) {
155
		$une_url->addQueryString(GEN_URL_CLE_I18N, $langue_url);
156
		$une_url->addQueryString(GEN_URL_CLE_I18N, $langue_url);
156
	} 
157
	} 
157
	$GLOBALS['_LIEN_']['url'] = $une_url->getURL();
158
	$GLOBALS['_LIEN_']['url'] = $une_url->getURL();
158
	$GLOBALS['_LIEN_']['titre'] = htmlentities($GLOBALS['_LIEN_']['titre']);
159
	$GLOBALS['_LIEN_']['titre'] = htmlentities($GLOBALS['_LIEN_']['titre']);
159
	
160
	
160
	//+----------------------------------------------------------------------------------------------------------------+
161
	//+----------------------------------------------------------------------------------------------------------------+
161
    // Extrait les variables et les ajoutes à l'espace de noms local
162
    // Extrait les variables et les ajoutes à l'espace de noms local
162
	// Gestion des squelettes
163
	// Gestion des squelettes
163
	extract($GLOBALS['_LIEN_']);
164
	extract($GLOBALS['_LIEN_']);
164
	// Démarre le buffer
165
	// Démarre le buffer
165
	ob_start();
166
	ob_start();
166
	// Inclusion du fichier
167
	// Inclusion du fichier
167
	include(LIEN_CHEMIN_SQUELETTE.LIEN_SQUELETTE_LISTE);
168
	include(LIEN_CHEMIN_SQUELETTE.LIEN_SQUELETTE_LISTE);
168
	// Récupérer le  contenu du buffer
169
	// Récupérer le  contenu du buffer
169
	$sortie = ob_get_contents();
170
	$sortie = ob_get_contents();
170
	// Arrête et détruit le buffer
171
	// Arrête et détruit le buffer
171
	ob_end_clean();
172
	ob_end_clean();
172
	
173
	
173
	//+----------------------------------------------------------------------------------------------------------------+
174
	//+----------------------------------------------------------------------------------------------------------------+
174
	// Sortie
175
	// Sortie
175
    return $sortie;
176
    return $sortie;
176
}
177
}
177
 
178
 
178
/* +--Fin du code ----------------------------------------------------------------------------------------+
179
/* +--Fin du code ----------------------------------------------------------------------------------------+
179
*
180
*
180
* $Log: not supported by cvs2svn $
181
* $Log: not supported by cvs2svn $
-
 
182
* Revision 1.1  2006-12-08 20:08:59  jp_milcent
-
 
183
* Ajout de l'apllette Lien.
-
 
184
*
181
*
185
*
182
* +-- Fin du code ----------------------------------------------------------------------------------------+
186
* +-- Fin du code ----------------------------------------------------------------------------------------+
183
*/
187
*/
184
?>
188
?>
185
189