| 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.6 2007-06-25 12:15:07 alexandre_tb Exp $
|
24 |
// CVS : $Id: syndication.php,v 1.7 2007-07-25 15:09:44 jp_milcent 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.6 $ $Date: 2007-06-25 12:15:07 $
|
36 |
*@version $Revision: 1.7 $ $Date: 2007-07-25 15:09:44 $
|
| 37 |
// +------------------------------------------------------------------------------------------------------+
|
37 |
// +------------------------------------------------------------------------------------------------------+
|
| 38 |
*/
|
38 |
*/
|
| Line 39... |
Line 39... |
| 39 |
|
39 |
|
| 40 |
// +------------------------------------------------------------------------------------------------------+
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
| Line 66... |
Line 66... |
| 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 |
require_once PAP_CHEMIN_API_PEAR.'XML/RSS.php';
|
71 |
require_once PAP_CHEMIN_API_PEAR.'XML/Feed/Parser.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 133... |
Line 133... |
| 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 |
try {
|
| 138 |
$rss =& new XML_RSS(str_replace('&', '&', $url));
|
139 |
$feed = new XML_Feed_Parser(file_get_contents($url));
|
| - |
|
140 |
} catch (XML_Feed_Parser_Exception $e) {
|
| - |
|
141 |
die('Le flux RSS est invalide : ' . $e->getMessage());
|
| 139 |
$rss->parse();
|
142 |
}
|
| - |
|
143 |
|
| 140 |
if ($options['template'] != '' && !file_exists($options['template'])) {
|
144 |
if ($options['template'] != '' && !file_exists($options['template'])) {
|
| 141 |
$i = 0 ;
|
145 |
$i = 0 ;
|
| 142 |
$res= '';
|
146 |
$res= '';
|
| 143 |
foreach ($rss->getItems() as $item) {
|
147 |
foreach ($feed as $item) {
|
| 144 |
// Le test suivant pour savoir s il faut reduire l excendent de description
|
148 |
// Le test suivant pour savoir s il faut reduire l excendent de description
|
| 145 |
// Si {all} est present dans le template on ne reduit pas
|
149 |
// Si {all} est present dans le template on ne reduit pas
|
| 146 |
if (preg_match ('/{all}/', $options['template'])) {
|
150 |
if (preg_match ('/{all}/', $options['template'])) {
|
| 147 |
$template = str_replace('{all}', '', $options['template']);
|
151 |
$template = str_replace('{all}', '', $options['template']);
|
| 148 |
$all = true ;
|
152 |
$all = true ;
|
| 149 |
} else {
|
153 |
} else {
|
| 150 |
$all = false;
|
154 |
$all = false;
|
| 151 |
}
|
155 |
}
|
| 152 |
if (isset($item['summary'])) {
|
156 |
if (isset($item->summary)) {
|
| 153 |
$item['description'] = $item['summary'];
|
157 |
$item->description = $item->summary;
|
| 154 |
} else {
|
158 |
} else {
|
| 155 |
if (strlen($item['description']) > 200 && !$all) {
|
159 |
if (strlen($item->description) > 200 && !$all) {
|
| 156 |
$item['description'] = substr ($item['description'] , 0, 300).
|
160 |
$item->description = substr ($item->description , 0, 300).
|
| 157 |
'... <a href="'.$item['link'].'">Lire la suite</a>';
|
161 |
'... <a href="'.$item->link.'">Lire la suite</a>';
|
| 158 |
}
|
162 |
}
|
| 159 |
}
|
163 |
}
|
| 160 |
if (!isset($item['pubdate'])) {
|
164 |
if (!isset($item->pubdate)) {
|
| 161 |
$item['pubdate'] = date('dmY');
|
165 |
$item->pubdate = date('dmY');
|
| 162 |
}
|
166 |
}
|
| 163 |
// Le code ci-apres est pour rattraper les dates du type 01012005 parsees par magpie
|
167 |
// Le code ci-apres est pour rattraper les dates du type 01012005 parsees par magpie
|
| 164 |
// lorsque les flux donne des dates au format iso
|
168 |
// lorsque les flux donne des dates au format iso
|
| 165 |
if (preg_match('/^([0-3][0-9])([0-1][0-9])([0-9][0-9][0-9][0-9])$/', $item['pubdate'], $match)) {
|
169 |
if (preg_match('/^([0-3][0-9])([0-1][0-9])([0-9][0-9][0-9][0-9])$/', $item->pubdate, $match)) {
|
| 166 |
$item['pubdate'] = $match[3].'-'.$match[2].'-'.$match[1];
|
170 |
$item->pubdate = $match[3].'-'.$match[2].'-'.$match[1];
|
| 167 |
//echo $item['pubdate'];
|
171 |
//echo $item['pubdate'];
|
| 168 |
}
|
172 |
}
|
| 169 |
$res .= str_replace ('{num}', ++$i,
|
173 |
$res .= str_replace ('{num}', ++$i,
|
| 170 |
str_replace ('{item}', '<a href="'.$item['link'].'" target="_top">'.htmlentities($item['title']).'</a>',
|
174 |
str_replace ('{item}', '<a href="'.$item->link.'" target="_top">'.htmlentities($item->title).'</a>',
|
| 171 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item['pubdate'])),
|
175 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item->pubdate)),
|
| 172 |
str_replace ('{description}', $item['description'], $options['template'])))) ;
|
176 |
str_replace ('{description}', $item->description, $options['template'])))) ;
|
| 173 |
$res .= "\n";
|
177 |
$res .= "\n";
|
| 174 |
if ($i > $options['nb']) {
|
178 |
if ($i > $options['nb']) {
|
| 175 |
break;
|
179 |
break;
|
| 176 |
}
|
180 |
}
|
| 177 |
}
|
181 |
}
|
| 178 |
return $res;
|
182 |
return $res;
|
| 179 |
}
|
183 |
}
|
| 180 |
$channel=$rss->getChannelInfo();
|
- |
|
| 181 |
//var_dump($channel);
|
- |
|
| 182 |
// Gestion du titre
|
184 |
// Gestion du titre
|
| 183 |
if ( $options['titre'] == '' ) {
|
185 |
if ( $options['titre'] == '' ) {
|
| 184 |
$aso_site['titre'] = utf8_decode($channel['title']);
|
186 |
$aso_site['titre'] = utf8_decode($feed->title);
|
| 185 |
} else if ( $options['titre'] != '0' ) {
|
187 |
} else if ( $options['titre'] != '0' ) {
|
| 186 |
$aso_site['titre'] = utf8_decode($options['titre']);
|
188 |
$aso_site['titre'] = $options['titre'];
|
| 187 |
}
|
189 |
}
|
| 188 |
// Gestion de l'url du site
|
190 |
// Gestion de l'url du site
|
| 189 |
if (isset($channel['link'])) {
|
- |
|
| 190 |
$aso_site['url'] = htmlentities($channel['link']);
|
191 |
$aso_site['url'] = htmlentities($feed->link);
|
| 191 |
}
|
192 |
|
| 192 |
// Ouverture du lien dans une nouvelle fenetre
|
193 |
// Ouverture du lien dans une nouvelle fenetre
|
| 193 |
$aso_site['ext'] = false;
|
194 |
$aso_site['ext'] = false;
|
| 194 |
if ($options['nouvellefenetre'] == 1) {
|
195 |
if ($options['nouvellefenetre'] == 1) {
|
| 195 |
$aso_site['ext'] = true;
|
196 |
$aso_site['ext'] = true;
|
| 196 |
}
|
197 |
}
|
| 197 |
// Gestion des pages syndiquees
|
198 |
// Gestion des pages syndiquees
|
| 198 |
$i = 0;
|
199 |
$i = 0;
|
| 199 |
$nb_item = count($rss->getItems());
|
200 |
$nb_item = $feed->numberEntries;
|
| 200 |
foreach ($rss->getItems() as $item) {
|
201 |
foreach ($feed as $item) {
|
| - |
|
202 |
//echo '<pre>'.print_r($item, true).'</pre>';
|
| 201 |
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
|
203 |
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
|
| 202 |
break;
|
204 |
break;
|
| 203 |
}
|
205 |
}
|
| 204 |
$i++;
|
206 |
$i++;
|
| 205 |
$aso_page = array();
|
207 |
$aso_page = array();
|
| 206 |
$aso_page['site'] = $aso_site;
|
208 |
$aso_page['site'] = $aso_site;
|
| 207 |
$aso_page['url'] = $item['link'];
|
209 |
$aso_page['url'] = $item->link;
|
| 208 |
$aso_page['titre'] = utf8_decode($item['title']);
|
210 |
$aso_page['titre'] = utf8_decode($item->title);
|
| 209 |
if (isset($item['pubdate'])) {
|
- |
|
| 210 |
$aso_page['date'] = $item['pubdate'];
|
211 |
$aso_page['date'] = $item->pubDate;
|
| 211 |
} elseif (isset($item['date'])) {
|
- |
|
| 212 |
$aso_page['date'] = $item['date'];
|
- |
|
| 213 |
} elseif (isset($item['date_timestamp'])) {
|
- |
|
| 214 |
$aso_page['date'] = $item['date_timestamp'];
|
- |
|
| 215 |
} else {
|
- |
|
| 216 |
$aso_page['date'] = '';
|
- |
|
| 217 |
}
|
- |
|
| 218 |
if ($options['formatdatepro']) {
|
212 |
if ($options['formatdatepro']) {
|
| 219 |
switch ($options['formatdatepro']) {
|
213 |
switch ($options['formatdatepro']) {
|
| 220 |
case 'jm' :
|
214 |
case 'jm' :
|
| 221 |
$aso_page['date'] = strftime('%d.%m', strtotime($aso_page['date']));
|
215 |
$aso_page['date'] = strftime('%d.%m', $aso_page['date']);
|
| 222 |
break;
|
216 |
break;
|
| 223 |
case 'jma' :
|
217 |
case 'jma' :
|
| 224 |
$aso_page['date'] = strftime('%d.%m.%Y', strtotime($aso_page['date']));
|
218 |
$aso_page['date'] = strftime('%d.%m.%Y', $aso_page['date']);
|
| 225 |
break;
|
219 |
break;
|
| 226 |
case 'jmh' :
|
220 |
case 'jmh' :
|
| 227 |
$aso_page['date'] = strftime('%d.%m %H:%M', strtotime($aso_page['date']));
|
221 |
$aso_page['date'] = strftime('%d.%m %H:%M', $aso_page['date']);
|
| 228 |
break;
|
222 |
break;
|
| 229 |
case 'jmah' :
|
223 |
case 'jmah' :
|
| 230 |
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', strtotime($aso_page['date']));
|
224 |
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', $aso_page['date']);
|
| 231 |
break;
|
225 |
break;
|
| 232 |
default :
|
226 |
default :
|
| 233 |
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', strtotime($aso_page['date']));
|
227 |
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', $aso_page['date']);
|
| 234 |
}
|
228 |
}
|
| 235 |
} else {
|
229 |
} else {
|
| 236 |
switch ($options['formatdate']) {
|
230 |
switch ($options['formatdate']) {
|
| 237 |
case 'jm' :
|
231 |
case 'jm' :
|
| 238 |
$aso_page['date'] = strftime('%d.%m', strtotime($aso_page['date']));
|
232 |
$aso_page['date'] = strftime('%d.%m', $aso_page['date']);
|
| 239 |
break;
|
233 |
break;
|
| 240 |
case 'jma' :
|
234 |
case 'jma' :
|
| 241 |
$aso_page['date'] = strftime('%d.%m.%Y', strtotime($aso_page['date']));
|
235 |
$aso_page['date'] = strftime('%d.%m.%Y', $aso_page['date']);
|
| 242 |
break;
|
236 |
break;
|
| 243 |
case 'jmh' :
|
237 |
case 'jmh' :
|
| 244 |
$aso_page['date'] = strftime('%d.%m %H:%M', strtotime($aso_page['date']));
|
238 |
$aso_page['date'] = strftime('%d.%m %H:%M', $aso_page['date']);
|
| 245 |
break;
|
239 |
break;
|
| 246 |
case 'jmah' :
|
240 |
case 'jmah' :
|
| 247 |
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', strtotime($aso_page['date']));
|
241 |
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', $aso_page['date']);
|
| 248 |
break;
|
242 |
break;
|
| 249 |
default :
|
243 |
default :
|
| 250 |
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', strtotime($aso_page['date']));
|
244 |
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', $aso_page['date']);
|
| 251 |
}
|
245 |
}
|
| 252 |
}
|
246 |
}
|
| 253 |
$aso_site['pages'][] = $aso_page;
|
247 |
$aso_site['pages'][] = $aso_page;
|
| 254 |
$GLOBALS['_SYNDICATION_']['pages'][strtotime($aso_page['date'])] = $aso_page;
|
248 |
$GLOBALS['_SYNDICATION_']['pages'][strtotime($aso_page['date'])] = $aso_page;
|
| 255 |
}
|
249 |
}
|
| Line 280... |
Line 274... |
| 280 |
}
|
274 |
}
|
| Line 281... |
Line 275... |
| 281 |
|
275 |
|
| 282 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
276 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
| 283 |
*
|
277 |
*
|
| - |
|
278 |
* $Log: not supported by cvs2svn $
|
| - |
|
279 |
* Revision 1.5.2.4 2007-07-25 15:07:52 jp_milcent
|
| - |
|
280 |
* Correction problème url.
|
| - |
|
281 |
*
|
| - |
|
282 |
* Revision 1.5.2.3 2007-07-25 14:50:21 jp_milcent
|
| - |
|
283 |
* Corrections, meilleure utilisation de XML_Feed_Parser.
|
| - |
|
284 |
*
|
| - |
|
285 |
* Revision 1.5.2.2 2007-07-25 09:45:07 jp_milcent
|
| - |
|
286 |
* Utilisation de XML_Feed_Parser de Pear pour l'applette Syndication.
|
| - |
|
287 |
*
|
| - |
|
288 |
* Revision 1.6 2007-06-25 12:15:07 alexandre_tb
|
| - |
|
289 |
* merge from narmer
|
| 284 |
* $Log: not supported by cvs2svn $
|
290 |
*
|
| 285 |
* Revision 1.5.2.1 2007-06-06 15:24:37 jp_milcent
|
291 |
* Revision 1.5.2.1 2007-06-06 15:24:37 jp_milcent
|
| 286 |
* Amélioration de la compatibilité avec les anciennes version des balises de l'applette syndication.
|
292 |
* Amélioration de la compatibilité avec les anciennes version des balises de l'applette syndication.
|
| 287 |
*
|
293 |
*
|
| 288 |
* Revision 1.5 2007-04-20 12:50:18 florian
|
294 |
* Revision 1.5 2007-04-20 12:50:18 florian
|