Subversion Repositories Applications.papyrus

Rev

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

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