Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 2082 → Rev 2083

/trunk/papyrus/applettes/syndication/syndication.php
103,7 → 103,7
// Gestion des arguments
$balise = $tab_applette_arguments[0];
$tab_arguments = $tab_applette_arguments;
 
unset($tab_arguments[0]);
foreach($tab_arguments as $argument) {
if ($argument != '') {
125,7 → 125,7
//
//+----------------------------------------------------------------------------------------------------------------+
// Gestion des erreurs de paramétrage
 
if (!isset($options['url'])) {
$GLOBALS['_SYNDICATION_']['erreurs'][] = sprintf(SYND_LG_ERREUR_URL, $balise);
}
154,10 → 154,10
$options['template'] = SYND_CHEMIN_SQUELETTE.$options['template'];
}
}
 
 
 
 
//+----------------------------------------------------------------------------------------------------------------+
// Recuperation des donnees
if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
168,8 → 168,10
// Liste des encodages acceptés pour les flux
$encodages = 'UTF-8, ISO-8859-1, ISO-8859-15';
try {
$feed = new XML_Feed_Parser(file_get_contents($url));
$xml = file_get_contents($url);
$feed = new XML_Feed_Parser($xml);
} catch (XML_Feed_Parser_Exception $e) {
creer_cache('erreur', $xml, 604800);
return('Le flux RSS est invalide : ' . $e->getMessage());
}
 
219,17 → 221,17
} else if ( $options['titre'] != '0' ) {
$aso_site['titre'] = $options['titre'];
}
 
//Gestion de l'ID
if ( $options['id'] != '' ) {
$aso_site['id'] = $options['id'];
}
 
//Gestion du lien vers la suite
if ( $options['voirsuite'] != '' ) {
$aso_site['voirsuite'] = $options['voirsuite'];
}
 
// Gestion de l'url du site
$aso_site['url'] = htmlentities($feed->link);
 
243,7 → 245,7
$nb_item = $feed->numberEntries;
 
foreach ($feed as $item) {
 
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
break;
}
254,13 → 256,13
$aso_page['url'] = htmlentities($item->link);
$aso_page['titre'] = mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages);
$aso_page['description'] = mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages);
 
/* Extraction de l'image si incluse dans description */
$image = "";
$description = $aso_page['description'];
 
$taille = $options['tailledesc'];
 
if (!(strpos($description, '<img') === false)) {
$pos_debut = strpos($description, '<img');
$pos_fin_image = strpos($description, '>', $posimage) + 1;
267,20 → 269,20
$image = substr($description, $pos_debut, ($pos_fin_image - $pos_debut));
$description = substr_replace($description,' ', $pos_debut, ($pos_fin_image - $pos_debut));
}
 
$aso_page['image'] = $image;
$aso_page['description_sans_image'] = $description;
$aso_page['description_sans_image'] = $description;
 
if ($taille != null) {
 
//Attention : si on coupe simplement, on peut couper une balise en plein milieu.
//On va donc vérifier
//On va donc vérifier
//1. recherche de tags simples <i> ou <b>
$description = html_entity_decode($description);
$description = strip_tags($description, "<i><b>");
 
//Va-ton couper un mot ?
 
if ($description[$taille] != ' ' && $description[$taille+1] != ' ' && $description[$taille-1] != ' ') {
$strpos = strpos($description, ' ', $taille);
if ($strpos === true) {
287,11 → 289,11
$taille = $strpos;
}
}
 
 
$description = substr($description, 0, $taille);
$description.='(...)';
 
$pattern = '#<([ib])[ ]*[a-z]*>(.*?)</\1>#i';
//1. remplacer toutes le s balises fermées
$chaine = preg_replace($pattern, '$2', $description);
299,22 → 301,22
for ($occurences = 0; $occurences < $nb_occurences_i; $occurences++) {
$description .= "</i>";
}
 
$nb_occurences_b = substr_count($chaine, '<b');
for ($occurences = 0; $occurences < $nb_occurences_b; $occurences++) {
$description .= "</b>";
}
}
 
$aso_page['description_light'] = $description;
 
//Greg : ajout GUID
$aso_page['guid'] = mb_convert_encoding($item->model->getElementsByTagName('guid')->item(0)->nodeValue, '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;
if ($options['formatdatepro']) {
switch ($options['formatdatepro']) {