Subversion Repositories Applications.papyrus

Rev

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

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