Rev 735 | Rev 773 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phprequire_once PAP_CHEMIN_API_PEAR.'XML/RSS.php';class Text_Wiki_Render_Xhtml_Syndication extends Text_Wiki_Render {/**** Renders a token into text matching the requested format.** @access public** @param array $options The "options" portion of the token (second* element).** @return string The text rendered from the token options.**/function token($options){// Initialisation des variables$sortie = '';$titre = $options['titre'];$urls = $options['url'];$nblimite = $options['nb'];$tab_url = array_map('trim', explode(',', $urls));if (ini_get('allow_url_fopen') != 0) {ini_set('allow_url_fopen', 1);}if (ini_get('allow_url_fopen') != 0) {foreach ($tab_url as $cle => $url) {$url = str_replace('&', '&', $url) ;$rss =& new XML_RSS($url);if (!$rss->parse()) echo 'une erreur d\'analyse du fichier RSS s\'est produite';$aso_info_rss = $rss->getChannelInfo();if ($titre!='') {$sortie .= '<h2>'.$titre.'</h2>';} elseif (isset($aso_info_rss['title'])) {$sortie .= '<h2>'.$aso_info_rss['title'].'</h2>';}$sortie .= '<ul class="syndication" >'."\n";$nbannonces=0;$tabsortie=array();foreach ($rss->getItems() as $item) {$tabsortie[$nbannonces]='<li><a href="'.preg_replace ('/&/', '&', $item['link']).'">'.$item['title'].'</a></li>'."\n";$nbannonces++;}//affichage du nombre limité d'annonces classées de la plus récente à la plus vieilleif ($nblimite>0) {for ($i = $nbannonces-1; (($i >= $nbannonces-$nblimite)and($i>=0)); $i--) {$sortie .= $tabsortie[$i];}}else {for ($i = $nbannonces-1; ($i>=0); $i--) {$sortie .= $tabsortie[$i];}}//si toutes les annonces n'ont pas été affichées, on propose de consulter les reste des annoncesif ($i>0) $sortie .= '<li>'.'<a href="'.$aso_info_rss['link'].'">'.'toutes les annonces</a></li>';$sortie .= '</ul>'."\n";}}return $sortie;}}?>