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