ramy Posted August 4, 2005 Share Posted August 4, 2005 voici l'etat actuel du code : ----------------------------------------- <ul> <?php require_once "magpierss/rss_fetch.inc"; $source = array(); $source[matbe] = ("http://www.matbe.com/export/rss.xml","<a href=http://forum.matbe.com/ title='actualite au quotidien et communauté d\'entraide'><img width=100 border=0 src=img/matbe.gif></a>"); $source[hfr] = ("http://www.hardware.fr/backend/news.xml","<a href=http://forum.hardware.fr/ title='l'incontournable : n°1 du web français'><img width=100 border=0 src=img/hfr.gif></a>"); $source[x86] = ("http://www.x86-secret.com/news/x86xml.php","<a href=http://forum.x86-secret.com/ title='highly technical hardware review'><img width=100 border=0 src=img/x86.gif></a>"); $source[zataz] = ("http://www.zataz.com/rss/zataz-news.rss","<a href=http://www.zataz.com/ title='le voici de l'underground'><img src=img/zataz.gif width=100 border=0></a>"); $source[gueux] = ("http://gueux.be/modules/news/rss/gueux_news_xbox.rss","<a href=http://gueux.be/ title='prenez le controle de votre console'><img src=img/gueux.gif width=100 border=0></a>"); $source[lfr] = ("http://linuxfr.org/backend/news-homepage/rss091.rss","<a href=http://linuxfr.org/pub/ title='un pied dans le monde libre'><img width=100 border=0 src=img/linuxfr.gif></a>"); $fichier_xml = array_slice($source, 0, 5); foreach ($fichier_xml as $xml) { $rss = fetch_rss($fichier_xml); if (is_array($rss->items)) { $liste = array_slice($rss->items, 0, 15); foreach ($liste as $item ) { $title = htmlspecialchars($item[title]); $url = $item[link]; $description = htmlspecialchars($item[description]); echo "<li> <a href='$url' title='$description'>$title</a> </li>"; } } } ?> </ul> ----------------------------------------- premier probleme : la variable $xml (en gras) correspond aux flux (en gras egalement ) ; je ne vois pas comment definir cette variable ou alors acceder a ces flux de l'array de 2e dimension ensuite je cherche aussi a trier les news (car il s'agit de news hardware) par date : seul les news du jour seront conserver puis trié par ordre de parution ( de la plus ressente a la moin ressente )... enfin le second element des arrays de 2e dimension ( ceux a cote des flux mis en surgras ) sont destiné a etre placé en debut de chaque news pour preciser la source de cette derniere et la je dois avouer que je lutte Link to comment Share on other sites More sharing options...
ramy Posted August 4, 2005 Author Share Posted August 4, 2005 voila ou j'en suis : <?php $jour["Monday"] = "Lundi"; $jour["Tuesday"] = "Mardi"; $jour["Wednesday"] = "Mercredi"; $jour["Thursday"] = "Jeudi"; $jour["Friday"] = "Vendredi"; $jour["Saturday"] = "Samedi"; $jour["Sunday"] = "Dimanche"; function getJour($day) { return $jour[$day]; } $mois["January"] = "Janvier"; $mois["Febrary"] = "Février"; $mois["March"] = "Mars"; $mois["April"] = "Avril"; $mois["May"] = "Mai"; $mois["June"] = "Juin"; $mois["July"] = "Juillet"; $mois["August"] = "Août"; $mois["September"] = "Septembre"; $mois["October"] = "Octobre"; $mois["November"] = "Novembre"; $mois["December"] = "Décembre"; function getMois($month){ return $mois[$month]; } $month = Date(F); $day = Date(l); getJour($day); getMois($month); print "Actualite du ."; print "$jour[$day] "; print Date(d)." "; print "$mois[$month] "; print Date(Y); echo "<br/> <ul>"; require_once "magpierss/rss_fetch.inc"; $source = array(); $source[0] = "http://www.matbe.com/export/rss.xml"; $source[1] = "http://www.hardware.fr/backend/news.xml"; $source[2] = "http://www.x86-secret.com/news/x86xml.php"; $source[3] = "http://www.zataz.com/rss/zataz-news.rss"; $source[4] = "http://gueux.be/modules/news/rss/gueux_news_xbox.rss"; $source[5] = "http://linuxfr.org/backend/news-homepage/rss091.rss"; $source[6] = "http://www.generation-nt.com/export/rss.xml"; $source[7] = "http://www.lemonde.fr/rss/sequence/0,2-3208,1-0,0.xml"; $source[8] = "http://www.lemonde.fr/rss/sequence/0,2-3242,1-0,0.xml"; $img = array(); $img[0] = "<a href=http://forum.matbe.com/ title='actualite au quotidien et communauté d'entraide'><img height=25 width=50 border=0 src=img/matbe.gif></a>"; $img[1] = "<a href=http://forum.hardware.fr/ title='incontournable : n°1 du web français'><img height=25 width=50 border=0 src=img/hfr.gif></a>"; $img[2] = "<a href=http://forum.x86-secret.com/ title='highly technical hardware review'><img height=25 width=50 border=0 src=img/x86.gif></a>"; $img[3] = "<a href=http://www.zataz.com/ title='le voici de l/'underground'><img src=img/zataz.gif width=50 height=25 border=0></a>"; $img[4] = "<a href=http://gueux.be><img width=50 height=25 src=http://gueux.be/images/GueuxNet.gif border=0></a>"; $img[5] = "<a href=http://linuxfr.org/pub/ title='un pied dans le monde libre'><img height=25 width=50 border=0 src=img/linuxfr.gif></a>"; $img[6] = "<a href=http://www.generation-nt.com/ title='personnalisez votre windows'><img height=25 width=50 border=0 src=img/gnt.gif></a>"; $img[7] = "<a href=http://www.lemonde.fr title='le monde à la une'><img border=0 src=img/lemondefr_rss.gif></a>"; $img[8] = "<a href=http://www.lemonde.fr title='le monde à la une'>LeMonde.fr - Sport</a>"; for ($i=0; $i<=8; $i++) { $rss = fetch_rss($source[$i]); if (is_array($rss->items)) { $liste = array_slice($rss->items, 0, 20); foreach ($liste as $item ) { $title = $item[title]; $url = $item[link]; $description = $item[description]; $description = htmlspecialchars($description, ENT_QUOTES); echo "<li> $pubdate $img[$i] <a href=$url title='$description'>$title</a> </li>"; } } } print "</ul>"; ?> maintenant je bloque sur un fonction capable de trier ces news par date: pour resumer : matbe presente ça sous la forme Citation: <dc:date>2005-08-04T16:59:42+01:00</dc:date> x86 et hfr Citation: <pubDate>Wed, 03 Aug 2005 20:12:41 +0200</pubDate> generation nt Citation: <dc:date>2005-08-04T17:27:01+01:00</dc:date> gueux.be, linuxfr et zataz n'en utilise pas! la fonction de tri par date ressemble a ceci Code: $time = date("d/m"); $pubdate = $item[date]; $pubdate = date("d/m", strtotime($pubdate)); if ($time == $pubdate) { echo news; } seulement pour les 3 cas presents, seul les news de hfr et x86 repondent correctement a la demande avec cette fonction Razz dans les autres cas, la fonction strtotime perd pied... Link to comment Share on other sites More sharing options...
Baramine Posted August 6, 2005 Share Posted August 6, 2005 Tu cherches à mettre toutes les news sur la même page (comme ici) ou plutot à mélanger toutes les news et les classer par date? Link to comment Share on other sites More sharing options...
ramy Posted August 7, 2005 Author Share Posted August 7, 2005 Tu cherches à mettre toutes les news sur la même page (comme ici) ou plutot à mélanger toutes les news et les classer par date? les classer par date a savoir ne garder que les news du jour et les ranger par date de parution (croissant)... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.