Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1282 → Rev 1283

/trunk/papyrus/applettes/syndication/syndication.php
5,7 → 5,7
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 1999-2006 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of papyrus_bp. |
// | This file is part of papyrus_bp. |
// | |
// | Foobar is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
21,7 → 21,7
// | along with Foobar; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: syndication.php,v 1.3 2007-01-23 14:17:19 alexandre_tb Exp $
// CVS : $Id: syndication.php,v 1.4 2007-03-28 15:53:27 florian Exp $
/**
* papyrus_bp - syndication.php
*
33,7 → 33,7
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 1999-2006
*@version $Revision: 1.3 $ $Date: 2007-01-23 14:17:19 $
*@version $Revision: 1.4 $ $Date: 2007-03-28 15:53:27 $
// +------------------------------------------------------------------------------------------------------+
*/
 
67,8 → 67,8
require_once SYND_CHEMIN_LANGUE.'synd_langue_'.SYND_I18N_DEFAUT.'.inc.php';
}
/** Inclusion du fichier de la bibliotheque permettant de manipuler les flux RSS.*/
require_once(MAGPIE_DIR.'rss_fetch.inc');
 
//require_once(MAGPIE_DIR.'rss_fetch.inc');
require_once PAP_CHEMIN_API_PEAR.'XML/RSS.php';
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
95,13 → 95,13
unset($tab_arguments[0]);
foreach($tab_arguments as $argument) {
if ($argument != '') {
$tab_parametres = explode('=', $argument);
$tab_parametres = explode('=', $argument, 2);
$options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
}
}
//+----------------------------------------------------------------------------------------------------------------+
// Gestion des erreurs de paramètrage
// Gestion des erreurs de paramétrage
if (!isset($options['url'])) {
$GLOBALS['_SYNDICATION_']['erreurs'][] = sprintf(SYND_LG_ERREUR_URL, $balise);
}
129,7 → 129,7
}
//+----------------------------------------------------------------------------------------------------------------+
// Récupération des données
// Recuperation des donnees
if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
$tab_url = array_map('trim', explode(',', $options['url']));
foreach ($tab_url as $cle => $url) {
136,12 → 136,12
if ($url != '') {
$aso_site = array();
$url = str_replace('&', '&', $url) ;
$rss = fetch_rss($url);
//echo '<pre>'.print_r($rss, true).'</pre>';
$rss =& new XML_RSS($url);
$rss->parse();
if ($options['template'] != '' && !file_exists($options['template'])) {
$i = 0 ;
$res= '';
foreach ($rss->items as $item) {
foreach ($rss->getItems() as $item) {
// Le test suivant pour savoir s il faut reduire l excendent de description
// Si {all} est present dans le template on ne reduit pas
if (preg_match ('/{all}/', $options['template'])) {
168,7 → 168,7
//echo $item['pubdate'];
}
$res .= str_replace ('{num}', ++$i,
str_replace ('{item}', '<a href="'.$item['link'].'" target="_top">'.$item['title'].'</a>',
str_replace ('{item}', '<a href="'.$item['link'].'" target="_top">'.htmlentities($item['title']).'</a>',
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item['pubdate'])),
str_replace ('{description}', $item['description'], $options['template'])))) ;
$res .= "\n";
178,25 → 178,26
}
return $res;
}
$channel=$rss->getChannelInfo();
// Gestion du titre
if ( $options['titre'] == '' ) {
$aso_site['titre'] = $rss->channel['title'];
$aso_site['titre'] = utf8_decode($channel['title']);
} else if ( $options['titre'] != '0' ) {
$aso_site['titre'] = $options['titre'];
$aso_site['titre'] = utf8_decode($options['titre']);
}
// Gestion de l'url du site
if (isset($rss->channel['link'])) {
$aso_site['url'] = $rss->channel['link'];
if (isset($channel['link'])) {
$aso_site['url'] = htmlentities($channel['link']);
}
// Ouverture du lien dans une nouvelle fenêtre
// Ouverture du lien dans une nouvelle fenetre
$aso_site['ext'] = false;
if ($options['nouvellefenetre'] == 1) {
$aso_site['ext'] = true;
}
// Gestion des pages syndiquées
// Gestion des pages syndiquees
$i = 0;
$nb_item = count($rss->items);
foreach ($rss->items as $item) {
$nb_item = count($rss->getItems());
foreach ($rss->getItems() as $item) {
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
break;
}
204,7 → 205,7
$aso_page = array();
$aso_page['site'] = $aso_site;
$aso_page['url'] = $item['link'];
$aso_page['titre'] = $item['title'];
$aso_page['titre'] = utf8_decode($item['title']);
if (isset($item['pubdate'])) {
$aso_page['date'] = $item['pubdate'];
} elseif (isset($item['date'])) {
215,7 → 216,22
$aso_page['date'] = '';
}
if ($options['formatdatepro']) {
$aso_page['date'] = strftime($options['formatdatepro'], strtotime($aso_page['date']));
switch ($options['formatdatepro']) {
case 'jm' :
$aso_page['date'] = strftime('%d.%m', strtotime($aso_page['date']));
break;
case 'jma' :
$aso_page['date'] = strftime('%d.%m.%Y', strtotime($aso_page['date']));
break;
case 'jmh' :
$aso_page['date'] = strftime('%d.%m %H:%M', strtotime($aso_page['date']));
break;
case 'jmah' :
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', strtotime($aso_page['date']));
break;
default :
$aso_page['date'] = strftime('%d.%m.%Y %H:%M', strtotime($aso_page['date']));
}
} else {
switch ($options['formatdate']) {
case 'jm' :
242,19 → 258,20
}
}
// Trie des pages par date
//var_dump($GLOBALS['_SYNDICATION_']);
krsort($GLOBALS['_SYNDICATION_']['pages']);
//+----------------------------------------------------------------------------------------------------------------+
// Extrait les variables et les ajoutes à l'espace de noms local
// Extrait les variables et les ajoutes a l'espace de noms local
// Gestion des squelettes
extract($GLOBALS['_SYNDICATION_']);
// Démarre le buffer
// Demarre le buffer
ob_start();
// Inclusion du fichier
include($options['template']);
// Récupérer le contenu du buffer
// Recuperer le contenu du buffer
$sortie = ob_get_contents();
// Arrête et détruit le buffer
// Arrete et detruit le buffer
ob_end_clean();
//+----------------------------------------------------------------------------------------------------------------+
265,6 → 282,10
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.3 2007/01/23 14:17:19 alexandre_tb
* backport : hack pour rattraper les dates du type 01012005 parsees par magpie
* lorsque les flux donne des dates au format iso
*
* Revision 1.2 2006/12/13 17:20:51 jp_milcent
* Correction bogue : paramètre nb non pris en compte
*