| Line 3... |
Line 3... |
| 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. |
|
| Line 19... |
Line 19... |
| 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: syndication.php,v 1.3 2007-01-23 14:17:19 alexandre_tb Exp $
|
24 |
// CVS : $Id: syndication.php,v 1.4 2007-03-28 15:53:27 florian Exp $
|
| 25 |
/**
|
25 |
/**
|
| 26 |
* papyrus_bp - syndication.php
|
26 |
* papyrus_bp - syndication.php
|
| 27 |
*
|
27 |
*
|
| 28 |
* Description :
|
28 |
* Description :
|
| 29 |
*
|
29 |
*
|
| Line 31... |
Line 31... |
| 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.3 $ $Date: 2007-01-23 14:17:19 $
|
36 |
*@version $Revision: 1.4 $ $Date: 2007-03-28 15:53:27 $
|
| 37 |
// +------------------------------------------------------------------------------------------------------+
|
37 |
// +------------------------------------------------------------------------------------------------------+
|
| 38 |
*/
|
38 |
*/
|
| Line 39... |
Line 39... |
| 39 |
|
39 |
|
| 40 |
// +------------------------------------------------------------------------------------------------------+
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
| Line 65... |
Line 65... |
| 65 |
} else {
|
65 |
} else {
|
| 66 |
/** Inclusion du fichier de traduction par défaut.*/
|
66 |
/** Inclusion du fichier de traduction par défaut.*/
|
| 67 |
require_once SYND_CHEMIN_LANGUE.'synd_langue_'.SYND_I18N_DEFAUT.'.inc.php';
|
67 |
require_once SYND_CHEMIN_LANGUE.'synd_langue_'.SYND_I18N_DEFAUT.'.inc.php';
|
| 68 |
}
|
68 |
}
|
| 69 |
/** Inclusion du fichier de la bibliotheque permettant de manipuler les flux RSS.*/
|
69 |
/** Inclusion du fichier de la bibliotheque permettant de manipuler les flux RSS.*/
|
| 70 |
require_once(MAGPIE_DIR.'rss_fetch.inc');
|
70 |
//require_once(MAGPIE_DIR.'rss_fetch.inc');
|
| 71 |
|
- |
|
| - |
|
71 |
require_once PAP_CHEMIN_API_PEAR.'XML/RSS.php';
|
| 72 |
// +------------------------------------------------------------------------------------------------------+
|
72 |
// +------------------------------------------------------------------------------------------------------+
|
| 73 |
// | CORPS du PROGRAMME |
|
73 |
// | CORPS du PROGRAMME |
|
| 74 |
// +------------------------------------------------------------------------------------------------------+
|
74 |
// +------------------------------------------------------------------------------------------------------+
|
| 75 |
/** Fonction afficherSyndication() - Retourne la liste des pages des sites syndiqués.
|
75 |
/** Fonction afficherSyndication() - Retourne la liste des pages des sites syndiqués.
|
| 76 |
*
|
76 |
*
|
| Line 93... |
Line 93... |
| 93 |
$balise = $tab_applette_arguments[0];
|
93 |
$balise = $tab_applette_arguments[0];
|
| 94 |
$tab_arguments = $tab_applette_arguments;
|
94 |
$tab_arguments = $tab_applette_arguments;
|
| 95 |
unset($tab_arguments[0]);
|
95 |
unset($tab_arguments[0]);
|
| 96 |
foreach($tab_arguments as $argument) {
|
96 |
foreach($tab_arguments as $argument) {
|
| 97 |
if ($argument != '') {
|
97 |
if ($argument != '') {
|
| 98 |
$tab_parametres = explode('=', $argument);
|
98 |
$tab_parametres = explode('=', $argument, 2);
|
| 99 |
$options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
|
99 |
$options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
|
| 100 |
}
|
100 |
}
|
| 101 |
}
|
101 |
}
|
| Line 102... |
Line 102... |
| 102 |
|
102 |
|
| 103 |
//+----------------------------------------------------------------------------------------------------------------+
|
103 |
//+----------------------------------------------------------------------------------------------------------------+
|
| 104 |
// Gestion des erreurs de paramètrage
|
104 |
// Gestion des erreurs de paramétrage
|
| 105 |
if (!isset($options['url'])) {
|
105 |
if (!isset($options['url'])) {
|
| 106 |
$GLOBALS['_SYNDICATION_']['erreurs'][] = sprintf(SYND_LG_ERREUR_URL, $balise);
|
106 |
$GLOBALS['_SYNDICATION_']['erreurs'][] = sprintf(SYND_LG_ERREUR_URL, $balise);
|
| 107 |
}
|
107 |
}
|
| 108 |
if (!isset($options['titre'])) {
|
108 |
if (!isset($options['titre'])) {
|
| Line 127... |
Line 127... |
| 127 |
$options['template'] = SYND_CHEMIN_SQUELETTE.$options['template'];
|
127 |
$options['template'] = SYND_CHEMIN_SQUELETTE.$options['template'];
|
| 128 |
}
|
128 |
}
|
| 129 |
}
|
129 |
}
|
| Line 130... |
Line 130... |
| 130 |
|
130 |
|
| 131 |
//+----------------------------------------------------------------------------------------------------------------+
|
131 |
//+----------------------------------------------------------------------------------------------------------------+
|
| 132 |
// Récupération des données
|
132 |
// Recuperation des donnees
|
| 133 |
if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
|
133 |
if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
|
| 134 |
$tab_url = array_map('trim', explode(',', $options['url']));
|
134 |
$tab_url = array_map('trim', explode(',', $options['url']));
|
| 135 |
foreach ($tab_url as $cle => $url) {
|
135 |
foreach ($tab_url as $cle => $url) {
|
| 136 |
if ($url != '') {
|
136 |
if ($url != '') {
|
| 137 |
$aso_site = array();
|
137 |
$aso_site = array();
|
| 138 |
$url = str_replace('&', '&', $url) ;
|
138 |
$url = str_replace('&', '&', $url) ;
|
| 139 |
$rss = fetch_rss($url);
|
139 |
$rss =& new XML_RSS($url);
|
| 140 |
//echo '<pre>'.print_r($rss, true).'</pre>';
|
140 |
$rss->parse();
|
| 141 |
if ($options['template'] != '' && !file_exists($options['template'])) {
|
141 |
if ($options['template'] != '' && !file_exists($options['template'])) {
|
| 142 |
$i = 0 ;
|
142 |
$i = 0 ;
|
| 143 |
$res= '';
|
143 |
$res= '';
|
| 144 |
foreach ($rss->items as $item) {
|
144 |
foreach ($rss->getItems() as $item) {
|
| 145 |
// Le test suivant pour savoir s il faut reduire l excendent de description
|
145 |
// Le test suivant pour savoir s il faut reduire l excendent de description
|
| 146 |
// Si {all} est present dans le template on ne reduit pas
|
146 |
// Si {all} est present dans le template on ne reduit pas
|
| 147 |
if (preg_match ('/{all}/', $options['template'])) {
|
147 |
if (preg_match ('/{all}/', $options['template'])) {
|
| 148 |
$template = str_replace('{all}', '', $options['template']);
|
148 |
$template = str_replace('{all}', '', $options['template']);
|
| Line 166... |
Line 166... |
| 166 |
if (preg_match('/^([0-3][0-9])([0-1][0-9])([0-9][0-9][0-9][0-9])$/', $item['pubdate'], $match)) {
|
166 |
if (preg_match('/^([0-3][0-9])([0-1][0-9])([0-9][0-9][0-9][0-9])$/', $item['pubdate'], $match)) {
|
| 167 |
$item['pubdate'] = $match[3].'-'.$match[2].'-'.$match[1];
|
167 |
$item['pubdate'] = $match[3].'-'.$match[2].'-'.$match[1];
|
| 168 |
//echo $item['pubdate'];
|
168 |
//echo $item['pubdate'];
|
| 169 |
}
|
169 |
}
|
| 170 |
$res .= str_replace ('{num}', ++$i,
|
170 |
$res .= str_replace ('{num}', ++$i,
|
| 171 |
str_replace ('{item}', '<a href="'.$item['link'].'" target="_top">'.$item['title'].'</a>',
|
171 |
str_replace ('{item}', '<a href="'.$item['link'].'" target="_top">'.htmlentities($item['title']).'</a>',
|
| 172 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item['pubdate'])),
|
172 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item['pubdate'])),
|
| 173 |
str_replace ('{description}', $item['description'], $options['template'])))) ;
|
173 |
str_replace ('{description}', $item['description'], $options['template'])))) ;
|
| 174 |
$res .= "\n";
|
174 |
$res .= "\n";
|
| 175 |
if ($i > $options['nb']) {
|
175 |
if ($i > $options['nb']) {
|
| 176 |
break;
|
176 |
break;
|
| 177 |
}
|
177 |
}
|
| 178 |
}
|
178 |
}
|
| 179 |
return $res;
|
179 |
return $res;
|
| 180 |
}
|
180 |
}
|
| - |
|
181 |
$channel=$rss->getChannelInfo();
|
| 181 |
// Gestion du titre
|
182 |
// Gestion du titre
|
| 182 |
if ( $options['titre'] == '' ) {
|
183 |
if ( $options['titre'] == '' ) {
|
| 183 |
$aso_site['titre'] = $rss->channel['title'];
|
184 |
$aso_site['titre'] = utf8_decode($channel['title']);
|
| 184 |
} else if ( $options['titre'] != '0' ) {
|
185 |
} else if ( $options['titre'] != '0' ) {
|
| 185 |
$aso_site['titre'] = $options['titre'];
|
186 |
$aso_site['titre'] = utf8_decode($options['titre']);
|
| 186 |
}
|
187 |
}
|
| 187 |
// Gestion de l'url du site
|
188 |
// Gestion de l'url du site
|
| 188 |
if (isset($rss->channel['link'])) {
|
189 |
if (isset($channel['link'])) {
|
| 189 |
$aso_site['url'] = $rss->channel['link'];
|
190 |
$aso_site['url'] = htmlentities($channel['link']);
|
| 190 |
}
|
191 |
}
|
| 191 |
// Ouverture du lien dans une nouvelle fenêtre
|
192 |
// Ouverture du lien dans une nouvelle fenetre
|
| 192 |
$aso_site['ext'] = false;
|
193 |
$aso_site['ext'] = false;
|
| 193 |
if ($options['nouvellefenetre'] == 1) {
|
194 |
if ($options['nouvellefenetre'] == 1) {
|
| 194 |
$aso_site['ext'] = true;
|
195 |
$aso_site['ext'] = true;
|
| 195 |
}
|
196 |
}
|
| 196 |
// Gestion des pages syndiquées
|
197 |
// Gestion des pages syndiquees
|
| 197 |
$i = 0;
|
198 |
$i = 0;
|
| 198 |
$nb_item = count($rss->items);
|
199 |
$nb_item = count($rss->getItems());
|
| 199 |
foreach ($rss->items as $item) {
|
200 |
foreach ($rss->getItems() as $item) {
|
| 200 |
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
|
201 |
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
|
| 201 |
break;
|
202 |
break;
|
| 202 |
}
|
203 |
}
|
| 203 |
$i++;
|
204 |
$i++;
|
| 204 |
$aso_page = array();
|
205 |
$aso_page = array();
|
| 205 |
$aso_page['site'] = $aso_site;
|
206 |
$aso_page['site'] = $aso_site;
|
| 206 |
$aso_page['url'] = $item['link'];
|
207 |
$aso_page['url'] = $item['link'];
|
| 207 |
$aso_page['titre'] = $item['title'];
|
208 |
$aso_page['titre'] = utf8_decode($item['title']);
|
| 208 |
if (isset($item['pubdate'])) {
|
209 |
if (isset($item['pubdate'])) {
|
| 209 |
$aso_page['date'] = $item['pubdate'];
|
210 |
$aso_page['date'] = $item['pubdate'];
|
| 210 |
} elseif (isset($item['date'])) {
|
211 |
} elseif (isset($item['date'])) {
|
| 211 |
$aso_page['date'] = $item['date'];
|
212 |
$aso_page['date'] = $item['date'];
|
| 212 |
} elseif (isset($item['date_timestamp'])) {
|
213 |
} elseif (isset($item['date_timestamp'])) {
|
| 213 |
$aso_page['date'] = $item['date_timestamp'];
|
214 |
$aso_page['date'] = $item['date_timestamp'];
|
| 214 |
} else {
|
215 |
} else {
|
| 215 |
$aso_page['date'] = '';
|
216 |
$aso_page['date'] = '';
|
| 216 |
}
|
217 |
}
|
| 217 |
if ($options['formatdatepro']) {
|
218 |
if ($options['formatdatepro']) {
|
| - |
|
219 |
switch ($options['formatdatepro']) {
|
| - |
|
220 |
case 'jm' :
|
| - |
|
221 |
$aso_page['date'] = strftime('%d.%m', strtotime($aso_page['date']));
|
| - |
|
222 |
break;
|
| - |
|
223 |
case 'jma' :
|
| 218 |
$aso_page['date'] = strftime($options['formatdatepro'], strtotime($aso_page['date']));
|
224 |
$aso_page['date'] = strftime('%d.%m.%Y', strtotime($aso_page['date']));
|
| - |
|
225 |
break;
|
| - |
|
226 |
case 'jmh' :
|
| - |
|
227 |
$aso_page['date'] = strftime('%d.%m %H:%M', strtotime($aso_page['date']));
|
| - |
|
228 |
break;
|
| - |
|
229 |
case 'jmah' :
|
| - |
|
230 |
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', strtotime($aso_page['date']));
|
| - |
|
231 |
break;
|
| - |
|
232 |
default :
|
| - |
|
233 |
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', strtotime($aso_page['date']));
|
| - |
|
234 |
}
|
| 219 |
} else {
|
235 |
} else {
|
| 220 |
switch ($options['formatdate']) {
|
236 |
switch ($options['formatdate']) {
|
| 221 |
case 'jm' :
|
237 |
case 'jm' :
|
| 222 |
$aso_page['date'] = strftime('%d.%m', strtotime($aso_page['date']));
|
238 |
$aso_page['date'] = strftime('%d.%m', strtotime($aso_page['date']));
|
| 223 |
break;
|
239 |
break;
|
| Line 240... |
Line 256... |
| 240 |
$GLOBALS['_SYNDICATION_']['sites'][] = $aso_site;
|
256 |
$GLOBALS['_SYNDICATION_']['sites'][] = $aso_site;
|
| 241 |
}
|
257 |
}
|
| 242 |
}
|
258 |
}
|
| 243 |
}
|
259 |
}
|
| 244 |
// Trie des pages par date
|
260 |
// Trie des pages par date
|
| - |
|
261 |
//var_dump($GLOBALS['_SYNDICATION_']);
|
| 245 |
krsort($GLOBALS['_SYNDICATION_']['pages']);
|
262 |
krsort($GLOBALS['_SYNDICATION_']['pages']);
|
| Line 246... |
Line 263... |
| 246 |
|
263 |
|
| 247 |
//+----------------------------------------------------------------------------------------------------------------+
|
264 |
//+----------------------------------------------------------------------------------------------------------------+
|
| 248 |
// Extrait les variables et les ajoutes à l'espace de noms local
|
265 |
// Extrait les variables et les ajoutes a l'espace de noms local
|
| 249 |
// Gestion des squelettes
|
266 |
// Gestion des squelettes
|
| 250 |
extract($GLOBALS['_SYNDICATION_']);
|
267 |
extract($GLOBALS['_SYNDICATION_']);
|
| 251 |
// Démarre le buffer
|
268 |
// Demarre le buffer
|
| 252 |
ob_start();
|
269 |
ob_start();
|
| 253 |
// Inclusion du fichier
|
270 |
// Inclusion du fichier
|
| 254 |
include($options['template']);
|
271 |
include($options['template']);
|
| 255 |
// Récupérer le contenu du buffer
|
272 |
// Recuperer le contenu du buffer
|
| 256 |
$sortie = ob_get_contents();
|
273 |
$sortie = ob_get_contents();
|
| 257 |
// Arrête et détruit le buffer
|
274 |
// Arrete et detruit le buffer
|
| Line 258... |
Line 275... |
| 258 |
ob_end_clean();
|
275 |
ob_end_clean();
|
| 259 |
|
276 |
|
| 260 |
//+----------------------------------------------------------------------------------------------------------------+
|
277 |
//+----------------------------------------------------------------------------------------------------------------+
|
| 261 |
// Sortie
|
278 |
// Sortie
|
| Line 262... |
Line 279... |
| 262 |
return $sortie;
|
279 |
return $sortie;
|
| 263 |
}
|
280 |
}
|
| 264 |
|
281 |
|
| - |
|
282 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
| - |
|
283 |
*
|
| - |
|
284 |
* $Log: not supported by cvs2svn $
|
| - |
|
285 |
* Revision 1.3 2007/01/23 14:17:19 alexandre_tb
|
| 265 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
286 |
* backport : hack pour rattraper les dates du type 01012005 parsees par magpie
|
| 266 |
*
|
287 |
* lorsque les flux donne des dates au format iso
|
| 267 |
* $Log: not supported by cvs2svn $
|
288 |
*
|
| 268 |
* Revision 1.2 2006/12/13 17:20:51 jp_milcent
|
289 |
* Revision 1.2 2006/12/13 17:20:51 jp_milcent
|
| 269 |
* Correction bogue : paramètre nb non pris en compte
|
290 |
* Correction bogue : paramètre nb non pris en compte
|