Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 2058 → Rev 2059

/trunk/papyrus/applettes/syndication/syndication.php
47,6 → 47,7
'(url="[^"]*")|'.
'(titre="[^"]*")|'.
'(nb="?\d+"?)|'.
'(nbmax="?\d+"?)|'.
'(nouvellefenetre="?(?:0|1)"?)|'.
'(formatdate="[^"]*")|'.
'(formatdatepro="[^"]*")|'.
58,6 → 59,9
/** Inclusion du fichier de configuration de cette application.*/
require_once GEN_CHEMIN_APPLETTE.'syndication'.GEN_SEP.'configuration'.GEN_SEP.'synd_configuration.inc.php';
 
/** Inclusion du fichier de fonctions de cette application.*/
require_once GEN_CHEMIN_APPLETTE.'syndication'.GEN_SEP.'bibliotheque'.GEN_SEP.'syndication.fonct.php';
 
// Inclusion des fichiers de traduction de l'applette SYND de Papyrus
if (file_exists(SYND_CHEMIN_LANGUE.'synd_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
/** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
66,6 → 70,7
/** Inclusion du fichier de traduction par défaut.*/
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 PAP_CHEMIN_API_PEAR.'XML/Feed/Parser.php';
87,7 → 92,9
$GLOBALS['_SYNDICATION_']['erreurs'] = array();
$GLOBALS['_SYNDICATION_']['informations'] = array();
$GLOBALS['_SYNDICATION_']['sites'] = array();
 
 
$string_arguments = "";
//+----------------------------------------------------------------------------------------------------------------+
// Gestion des arguments
$balise = $tab_applette_arguments[0];
95,10 → 102,17
unset($tab_arguments[0]);
foreach($tab_arguments as $argument) {
if ($argument != '') {
$string_arguments .= $argument;
$tab_parametres = explode('=', $argument, 2);
$options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
}
}
 
$id_cache = md5($string_arguments);
 
if($contenu_cache = verifierCache($id_cache)) {
return $contenu_cache;
}
//
//+----------------------------------------------------------------------------------------------------------------+
// Gestion des erreurs de paramétrage
111,6 → 125,9
if (!isset($options['nb'])) {
$options['nb'] = SYND_NOMBRE;
}
if (!isset($options['nbmax'])) {
$options['nbmax'] = SYND_NOMBRE_MAX;
}
if (!isset($options['nouvellefenetre'])) {
$options['nouvellefenetre'] = SYND_OUVRIR_LIEN_RSS_NOUVELLE_FENETRE;
}
127,7 → 144,7
$options['template'] = SYND_CHEMIN_SQUELETTE.$options['template'];
}
}
 
//+----------------------------------------------------------------------------------------------------------------+
// Recuperation des donnees
if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
142,7 → 159,7
} catch (XML_Feed_Parser_Exception $e) {
return('Le flux RSS est invalide : ' . $e->getMessage());
}
 
if ($options['template'] != '' && !file_exists($options['template'])) {
$i = 0 ;
$res= '';
156,7 → 173,7
$all = false;
}
if (isset($item->summary)) {
$item->description = mb_convert_encoding($item->summary, 'HTML-ENTITIES', $encodages);
$item->description = mb_convert_encoding($item->summary, 'HTML-ENTITIES', $encodages);
} else {
if (strlen($item->description) > 200 && !$all) {
$item->description = substr(mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages), 0, 300).
172,8 → 189,8
$item->pubdate = $match[3].'-'.$match[2].'-'.$match[1];
//echo $item['pubdate'];
}
$res .= str_replace ('{num}', ++$i,
str_replace ('{item}', '<a href="'.htmlentities($item->link).'" target="_top">'.mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages).'</a>',
$res .= str_replace ('{num}', ++$i,
str_replace ('{item}', '<a href="'.htmlentities($item->link).'" target="_top">'.mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages).'</a>',
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item->pubdate)),
str_replace ('{description}', mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages), $options['template'])))) ;
$res .= "\n";
202,12 → 219,12
$nb_item = $feed->numberEntries;
 
foreach ($feed as $item) {
 
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
break;
}
$i++;
 
$aso_page = array();
$aso_page['site'] = $aso_site;
$aso_page['url'] = htmlentities($item->link);
215,7 → 232,7
$aso_page['description'] = mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages);
$aso_page['category'] = mb_convert_encoding($item->model->getElementsByTagName('category')->item(0)->nodeValue, 'HTML-ENTITIES', $encodages);
$aso_page['author'] = mb_convert_encoding($item->author, 'HTML-ENTITIES', $encodages);
$aso_page['date'] = $item->pubDate;
$aso_page['date'] = $item->pubDate;
if ($options['formatdatepro']) {
switch ($options['formatdatepro']) {
case 'jm' :
259,9 → 276,11
}
}
// Trie des pages par date
//var_dump($GLOBALS['_SYNDICATION_']['pages']);
krsort($GLOBALS['_SYNDICATION_']['pages']);
 
$GLOBALS['_SYNDICATION_']['sites'] = array_slice($GLOBALS['_SYNDICATION_']['sites'],0,$options['nbmax'],true) ;
$GLOBALS['_SYNDICATION_']['pages'] = array_slice($GLOBALS['_SYNDICATION_']['pages'],0,$options['nbmax'],true) ;
 
//+----------------------------------------------------------------------------------------------------------------+
// Extrait les variables et les ajoutes a l'espace de noms local
// Gestion des squelettes
272,9 → 291,10
include($options['template']);
// Recuperer le contenu du buffer
$sortie = ob_get_contents();
creer_cache($id_cache,$sortie);
// Arrete et detruit le buffer
ob_end_clean();
 
//+----------------------------------------------------------------------------------------------------------------+
// Sortie
return $sortie;