Subversion Repositories Applications.papyrus

Rev

Rev 1688 | 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
// +------------------------------------------------------------------------------------------------------+
1968 jp_milcent 24
// CVS : $Id: lien.php,v 1.1.4.1 2008-11-14 11:22:22 jp_milcent Exp $
1128 jp_milcent 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
1968 jp_milcent 36
*@version       $Revision: 1.1.4.1 $ $Date: 2008-11-14 11:22:22 $
1128 jp_milcent 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 = '';
1968 jp_milcent 76
    $niveau = null;
1128 jp_milcent 77
	$GLOBALS['_LIEN_']['url'] = '';
78
	$GLOBALS['_LIEN_']['titre'] = LIEN_LG_ERREUR_TITRE;
79
    $GLOBALS['_LIEN_']['erreurs'] = array();
80
 
81
	//+----------------------------------------------------------------------------------------------------------------+
82
	// Gestion des arguments
83
    $tab_arguments = $tab_applette_arguments;
84
	unset($tab_arguments[0]);
85
    foreach($tab_arguments as $argument) {
86
	    $tab_parametres = explode('=', $argument);
87
	    $options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
88
    }
89
 
90
	//+----------------------------------------------------------------------------------------------------------------+
91
    // Gestion des erreurs de paramètrage
92
    if (!isset($options['menu']) && !isset($options['site']) ) {
93
        $GLOBALS['_LIEN_']['erreur'] = LIEN_LG_ERREUR_SITE_MENU;
94
    } else {
95
    	if (isset($options['menu'])) {
96
    		$niveau = 'menu';
97
    		$identifiant = $options['menu'];
98
    	} else if (isset($options['site'])) {
99
    		$niveau = 'site';
100
    		$identifiant = $options['site'];
101
    	}
102
    }
103
 
104
    //+----------------------------------------------------------------------------------------------------------------+
105
    // Récupération des données
106
	$bdd =& $GLOBALS['_GEN_commun']['pear_db'];
107
	$id_langue = $GLOBALS['_GEN_commun']['i18n']; //identifiant de la langue choisie
108
	if (isset($id_langue) && ($id_langue != '')) {
109
		$langue_url = $id_langue;
110
	} else {
111
		$langue_url = GEN_I18N_ID_DEFAUT;
112
	}
113
	$une_url =& new Pap_URL();
114
	// Les sites
115
	if ($niveau == "site") {
116
		if (preg_match('/^[0-9]+$/', $identifiant)) {
117
			$aso_site = GEN_lireInfoSiteI18nCodeAlpha($bdd, GEN_retournerSiteCodeAlpha($bdd, $identifiant), $langue_url, DB_FETCHMODE_ASSOC);
118
		} else {
119
			$aso_site = GEN_lireInfoSiteI18nCodeAlpha($bdd, $identifiant, $langue_url, DB_FETCHMODE_ASSOC);
120
		}
121
 
122
        if (isset($options['titre'])) {
123
        	$GLOBALS['_LIEN_']['titre'] = $options['titre'];
124
        } else {
125
        	if (!empty($aso_site['gs_titre'])) {
126
				$GLOBALS['_LIEN_']['titre'] = $aso_site['gs_titre'];
127
        	} else {
128
				$GLOBALS['_LIEN_']['titre'] = $aso_site['gs_nom'];
129
        	}
130
        }
131
    	$une_url->setUrlType('SITE');
132
    	$une_url->setId($aso_site['gs_id_site']);
133
	}
134
	// Les menus
135
	if ($niveau == "menu") {
136
		if (preg_match('/^[0-9]+$/', $identifiant)) {
137
			$aso_menu = GEN_lireInfoMenu($bdd, GEN_retournerIdMenuParCodeNum($bdd, $identifiant), DB_FETCHMODE_ASSOC);
138
		} else {
139
			$aso_menu = GEN_lireInfoMenu($bdd, GEN_retournerIdMenuParCodeNum($bdd, GEN_retournerMenuCodeNum($bdd, $identifiant)), DB_FETCHMODE_ASSOC);
140
		}
141
        if (isset($options['titre'])) {
142
        	$GLOBALS['_LIEN_']['titre'] = $options['titre'];
143
        } else {
144
        	if (!empty($aso_menu['gm_titre'])) {
145
				$GLOBALS['_LIEN_']['titre'] = $aso_menu['gm_titre'];
146
            } elseif (!empty($aso_menu['gm_titre_alternatif'])) {
147
				$GLOBALS['_LIEN_']['titre'] = $aso_menu['gm_titre_alternatif'];
148
            } elseif (!empty($aso_menu['gm_nom'])) {
149
				$GLOBALS['_LIEN_']['titre'] = $aso_menu['gm_nom'];
150
            }
151
        }
152
    	$une_url->setId($aso_menu['gm_id_menu']);
153
    }
154
 
155
	if ($langue_url != GEN_I18N_ID_DEFAUT) {
156
		$une_url->addQueryString(GEN_URL_CLE_I18N, $langue_url);
157
	}
158
	$GLOBALS['_LIEN_']['url'] = $une_url->getURL();
159
	$GLOBALS['_LIEN_']['titre'] = htmlentities($GLOBALS['_LIEN_']['titre']);
160
 
161
	//+----------------------------------------------------------------------------------------------------------------+
162
    // Extrait les variables et les ajoutes à l'espace de noms local
163
	// Gestion des squelettes
164
	extract($GLOBALS['_LIEN_']);
165
	// Démarre le buffer
166
	ob_start();
167
	// Inclusion du fichier
168
	include(LIEN_CHEMIN_SQUELETTE.LIEN_SQUELETTE_LISTE);
169
	// Récupérer le  contenu du buffer
170
	$sortie = ob_get_contents();
171
	// Arrête et détruit le buffer
172
	ob_end_clean();
173
 
174
	//+----------------------------------------------------------------------------------------------------------------+
175
	// Sortie
176
    return $sortie;
177
}
178
 
179
/* +--Fin du code ----------------------------------------------------------------------------------------+
180
*
181
* $Log: not supported by cvs2svn $
1968 jp_milcent 182
* Revision 1.1  2006-12-08 20:08:59  jp_milcent
183
* Ajout de l'apllette Lien.
1128 jp_milcent 184
*
1968 jp_milcent 185
*
1128 jp_milcent 186
* +-- Fin du code ----------------------------------------------------------------------------------------+
187
*/
1968 jp_milcent 188
?>