Subversion Repositories Applications.papyrus

Rev

Rev 1159 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1159 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
// +------------------------------------------------------------------------------------------------------+
1763 alexandre_ 24
// CVS : $Id: redirection.php,v 1.2 2007-12-07 10:08:43 alexandre_tb Exp $
1159 jp_milcent 25
/**
26
* papyrus_bp - redirection.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
1763 alexandre_ 36
*@version       $Revision: 1.2 $ $Date: 2007-12-07 10:08:43 $
1159 jp_milcent 37
// +------------------------------------------------------------------------------------------------------+
38
*/
39
 
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTÊTE du PROGRAMME                                       |
42
// +------------------------------------------------------------------------------------------------------+
43
$GLOBALS['_GEN_commun']['info_applette_nom_fonction'] = 'lancerRedirection';
44
$GLOBALS['_GEN_commun']['info_applette_balise'] = 	'\{\{[Rr]edirection'.
45
													'(?:\s*'.
46
														'(?:'.
47
															'(url="[^"]*")|'.
48
														')'.
49
													')+'.
50
													'\s*\}\}';
51
 
52
// --------------------------------------------------------------------------------------------------------
53
/** Inclusion du fichier de configuration de cette application.*/
54
require_once GEN_CHEMIN_APPLETTE.'redirection'.GEN_SEP.'configuration'.GEN_SEP.'redi_configuration.inc.php';
55
 
56
// Inclusion des fichiers de traduction de l'applette REDI de Papyrus
57
if (file_exists(REDI_CHEMIN_LANGUE.'redi_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
58
    /** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
59
    require_once REDI_CHEMIN_LANGUE.'redi_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
60
} else {
61
    /** Inclusion du fichier de traduction par défaut.*/
62
    require_once REDI_CHEMIN_LANGUE.'redi_langue_'.REDI_I18N_DEFAUT.'.inc.php';
63
}
64
 
65
// +------------------------------------------------------------------------------------------------------+
66
// |                                            CORPS du PROGRAMME                                        |
67
// +------------------------------------------------------------------------------------------------------+
68
/** Fonction lancerRedirection() - Redirige vers une nouvelle URL.
69
*
70
* Cette fonction redirige l'utilisateur vers une nouvelle url.
71
*
72
* @param  array contient les arguments de la fonction.
73
* @param  array  tableau global de Papyrus.
74
* @return null on est redirigé.
75
*/
76
function lancerRedirection($tab_applette_arguments, $_GEN_commun)
77
{
78
	// Initialisation des variables
79
	$sortie = '';
80
	$GLOBALS['_REDIRECTION_']['erreurs'] = array();
81
 
82
	//+----------------------------------------------------------------------------------------------------------------+
83
	// Gestion des arguments
84
	$balise = $tab_applette_arguments[0];
85
    $tab_arguments = $tab_applette_arguments;
86
	unset($tab_arguments[0]);
87
    foreach($tab_arguments as $argument) {
88
    	if ($argument != '') {
1763 alexandre_ 89
	    	$tab_parametres = explode('=', $argument,2);
1159 jp_milcent 90
	    	$options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
91
    	}
92
    }
93
 
94
	//+----------------------------------------------------------------------------------------------------------------+
95
    // Gestion des erreurs de paramètrage
96
	if (!isset($options['url'])) {
97
		$GLOBALS['_REDIRECTION_']['erreurs'][] = sprintf(REDI_LG_ERREUR_URL, $balise);
98
	}
99
	if (isset($options['url']) && $options['url'] == '') {
100
		$GLOBALS['_REDIRECTION_']['erreurs'][] = sprintf(REDI_LG_ERREUR_URL_VIDE, $balise);
101
	}
102
 
103
	//+----------------------------------------------------------------------------------------------------------------+
104
    // Redirection
105
    if (count($GLOBALS['_REDIRECTION_']['erreurs']) == 0) {
106
		$options['url'] = preg_replace('/&amp;/', '&', $options['url']);
107
		header('Location: '.$options['url']);
108
		exit();
109
    } else {
110
    	//+----------------------------------------------------------------------------------------------------------------+
111
	    // Extrait les variables et les ajoutes à l'espace de noms local
112
		// Gestion des squelettes
113
		extract($GLOBALS['_REDIRECTION_']);
114
		// Démarre le buffer
115
		ob_start();
116
		// Inclusion du fichier
117
		include(REDI_CHEMIN_SQUELETTE.REDI_SQUELETTE_PRINCIPAL);
118
		// Récupérer le  contenu du buffer
119
		$sortie = ob_get_contents();
120
		// Arrête et détruit le buffer
121
		ob_end_clean();
122
 
123
		//+----------------------------------------------------------------------------------------------------------------+
124
		// Sortie
125
	    return $sortie;
126
    }
127
}
128
 
129
/* +--Fin du code ----------------------------------------------------------------------------------------+
130
*
131
* $Log: not supported by cvs2svn $
1763 alexandre_ 132
* Revision 1.1  2006-12-13 10:52:30  jp_milcent
133
* Ajout de l'applette Rediection.
1159 jp_milcent 134
*
1763 alexandre_ 135
*
1159 jp_milcent 136
* +-- Fin du code ----------------------------------------------------------------------------------------+
137
*/
138
?>