Subversion Repositories Applications.papyrus

Rev

Rev 1151 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1142 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: mot_cles.php,v 1.1 2006-12-12 13:32:27 jp_milcent Exp $
25
/**
26
* papyrus_bp - mot_cles.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-12 13:32:27 $
37
// +------------------------------------------------------------------------------------------------------+
38
*/
39
 
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTÊTE du PROGRAMME                                       |
42
// +------------------------------------------------------------------------------------------------------+
43
$GLOBALS['_GEN_commun']['info_applette_nom_fonction'] = 'afficherMotCles';
44
$GLOBALS['_GEN_commun']['info_applette_balise'] = '\{\{[Mm]otCles(?:\s*(?:((?:mots|categorie)="[^"]+")|((?:condition|mots_condition|categorie_condition)="(?i:et|ou)")|(ordre="(?i:asc|desc)")|))+\s*\}\}';
45
 
46
// --------------------------------------------------------------------------------------------------------
47
/** Inclusion du fichier de configuration de cette application.*/
48
require_once GEN_CHEMIN_APPLETTE.'mot_cles'.GEN_SEP.'configuration'.GEN_SEP.'mocl_configuration.inc.php';
49
 
50
// Inclusion des fichiers de traduction de l'applette MOCL de Papyrus
51
if (file_exists(MOCL_CHEMIN_LANGUE.'mocl_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
52
    /** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
53
    require_once MOCL_CHEMIN_LANGUE.'mocl_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
54
} else {
55
    /** Inclusion du fichier de traduction par défaut.*/
56
    require_once MOCL_CHEMIN_LANGUE.'mocl_langue_'.MOCL_I18N_DEFAUT.'.inc.php';
57
}
58
 
59
// +------------------------------------------------------------------------------------------------------+
60
// |                                            CORPS du PROGRAMME                                        |
61
// +------------------------------------------------------------------------------------------------------+
62
/** Fonction afficherMotCles() - Retourne la liste des pages pour un mot clés donné.
63
*
64
* Cette fonction retourne la liste des pages pour un mot clés donné.
65
*
66
* @param  array contient les arguments de la fonction.
67
* @param  array  tableau global de Papyrus.
68
* @return string HTML la liste des listes de menus.
69
*/
70
function afficherMotCles($tab_applette_arguments, $_GEN_commun)
71
{
72
	// Initialisation des variables
73
    $sortie = '';
74
	$GLOBALS['_MOT_CLES_']['erreurs'] = array();
75
	$GLOBALS['_MOT_CLES_']['informations'] = array();
76
 
77
	//+----------------------------------------------------------------------------------------------------------------+
78
	// Gestion des arguments
79
	$balise = $tab_applette_arguments[0];
80
    $tab_arguments = $tab_applette_arguments;
81
	unset($tab_arguments[0]);
82
    foreach($tab_arguments as $argument) {
83
	    $tab_parametres = explode('=', $argument);
84
	    $options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
85
    }
86
 
87
	//+----------------------------------------------------------------------------------------------------------------+
88
    // Gestion des erreurs de paramètrage
89
	if (!isset($options['mots'])) {
90
		$GLOBALS['_MOT_CLES_']['erreurs'][] = MOCL_LG_ERREUR_MOTS;
91
	}
92
	if (!isset($options['categorie']) && isset($options['categorie_condition'])) {
93
		$GLOBALS['_MOT_CLES_']['erreurs'][] = sprintf(MOCL_LG_ERREUR_MOTS_CATEG, $balise);
94
	}
95
	if (!isset($options['categorie'])) {
96
		$options['categorie'] = '';
97
	}
98
    // Les conditions étant écrites en français, ce qui suit les traduit, "et" devient "AND" etc.
99
	$tab_condition_type = array('condition', 'mots_condition', 'categorie_condition');
100
	foreach ($tab_condition_type as $type) {
101
		if (isset($options[$type])) {
102
			if (strtolower($options[$type]) == 'et') {
103
				$options[$type] = 'AND';
104
			} elseif (strtolower($options[$type]) == 'ou') {
105
				$options[$type] = 'OR';
106
			}
107
		}
108
	}
109
	if (!isset($options['mots_condition']) && isset($options['condition'])) {
110
		$options['mots_condition'] = $options['condition'];
111
	}
112
	if (!isset($options['categorie_condition']) && isset($options['condition'])) {
113
		$options['categorie_condition'] = $options['condition'];
114
	}
115
	if (!isset($options['categorie_condition']) && !isset($options['condition']) && isset($options['mots_condition'])) {
116
		$options['categorie_condition'] = $options['mots_condition'];
117
	}
118
	if (!isset($options['ordre'])) {
119
		$options['ordre'] = 'ASC';
120
	}
121
 
122
    //+----------------------------------------------------------------------------------------------------------------+
123
    // Récupération des données
124
    // Récupération des infos sur les mots
125
	$tab_mots = explode(',', $options['mots']);
126
	for ($i = 0; $i < count($tab_mots); $i++) {
127
		// Suppression des espaces, tabulations... en début et fin de chaine
128
		$tab_mots[$i] = trim($tab_mots[$i]);
129
	}
130
 
131
	// Récupération des infos sur les catégories
132
	$tab_cat = explode(',', $options['categorie']) ;
133
	for ($i = 0; $i < count($tab_cat); $i++) {
134
		// Suppression des espaces, tabulations... en début et fin de chaine
135
		$tab_cat[$i] = trim($tab_cat[$i]);
136
	}
137
 
138
	$aso_info_menu = GEN_lireInfoMenuMeta($GLOBALS['_GEN_commun']['pear_db'], $tab_mots, $tab_cat, $options['mots_condition'], $options['categorie_condition'], $options['ordre']);
139
	if (count($aso_info_menu) == 0) {
140
		$GLOBALS['_MOT_CLES_']['informations'][] = sprintf(CATEG_LG_INFO_ZERO_PAGE, $options['mots']);
141
	} else {
142
		foreach ($aso_info_menu as $id_menu => $un_menu) {
143
	        // Initialisation
144
	        $aso_page = array();
145
			$aso_page['url'] = '#';
146
			$aso_page['auteur'] = MOCL_LG_INCONNU_AUTEUR;
147
			$aso_page['titre'] = MOCL_LG_INCONNU_TITRE;
148
			$aso_page['heure'] = '';
149
			$aso_page['minute'] = '';
150
			$aso_page['seconde'] = '';
151
			$aso_page['jours'] = '';
152
			$aso_page['mois'] = '';
153
			$aso_page['annee'] = '';
154
 
155
			// Création de l'url
156
			$une_url =& new Pap_URL();
157
			$une_url->setId($id_menu);
158
	        $aso_page['url'] = $une_url->getURL();
159
 
160
	        // Affichage de l'auteur(s)
161
	        if ($un_menu->gm_auteur != '') {
162
	        	$aso_page['auteur'] = $un_menu->gm_auteur;
163
	    	}
164
 
165
	        // Affichage du titre
166
	        if ($un_menu->gm_titre != '') {
167
				$aso_page['titre'] = $un_menu->gm_titre;
168
	        }
169
 
170
	        // Affichage de l'horaire de la création de la page
171
			if (($heure = date('G', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
172
				$aso_page['heure'] = $heure;
173
				$minute = date('i', strtotime($un_menu->gm_date_creation));
174
				$aso_page['minute'] = $minute;
175
				if (($seconde = date('s', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
176
					$aso_page['seconde'] = $seconde;
177
				}
178
			}
179
 
180
			// Affichage de la date de la création de la page
181
			if (($jour = date('d', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
182
				$aso_page['jour'] = $jour;
183
			}
184
			if (($mois = _traduireMois(date('m', strtotime($un_menu->gm_date_creation))) ) != '' ) {
185
				$aso_page['mois'] = $mois;
186
	        }
187
	        if (($annee = date('Y', strtotime($un_menu->gm_date_creation)) ) != 0 ) {
188
	            $aso_page['annee'] = $annee;
189
	        }
190
	        $GLOBALS['_MOT_CLES_']['pages'][] = $aso_page;
191
	    }
192
	}
193
 
194
	//+----------------------------------------------------------------------------------------------------------------+
195
    // Extrait les variables et les ajoutes à l'espace de noms local
196
	// Gestion des squelettes
197
	extract($GLOBALS['_MOT_CLES_']);
198
	// Démarre le buffer
199
	ob_start();
200
	// Inclusion du fichier
201
	include(MOCL_CHEMIN_SQUELETTE.MOCL_SQUELETTE_LISTE);
202
	// Récupérer le  contenu du buffer
203
	$sortie = ob_get_contents();
204
	// Arrête et détruit le buffer
205
	ob_end_clean();
206
 
207
	//+----------------------------------------------------------------------------------------------------------------+
208
	// Sortie
209
    return $sortie;
210
}
211
 
212
if (!function_exists('_traduireMois')) {
213
	function _traduireMois($mois_numerique)
214
	{
215
	    switch ($mois_numerique) {
216
	        case '01' :
217
	            return MOCL_LG_MOIS_01;
218
	        case '02' :
219
	            return MOCL_LG_MOIS_02;
220
	        case '03' :
221
	            return MOCL_LG_MOIS_03;
222
	        case '04' :
223
	            return MOCL_LG_MOIS_04;
224
	        case '05' :
225
	            return MOCL_LG_MOIS_05;
226
	        case '06' :
227
	            return MOCL_LG_MOIS_06;
228
	        case '07' :
229
	            return MOCL_LG_MOIS_07;
230
	        case '08' :
231
	            return MOCL_LG_MOIS_08;
232
	        case '09' :
233
	            return MOCL_LG_MOIS_09;
234
	        case '10' :
235
	            return MOCL_LG_MOIS_10;
236
	        case '11' :
237
	            return MOCL_LG_MOIS_11;
238
	        case '12' :
239
	            return MOCL_LG_MOIS_12;
240
	        default:
241
	            return '';
242
	    }
243
	}
244
}
245
 
246
/* +--Fin du code ----------------------------------------------------------------------------------------+
247
*
248
* $Log: not supported by cvs2svn $
249
*
250
* +-- Fin du code ----------------------------------------------------------------------------------------+
251
*/
252
?>