Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 772 → Rev 773

/trunk/api/text/wiki_papyrus/Parse/Syndication.php
1,5 → 1,5
<?php
// $Id: Syndication.php,v 1.3 2005-10-13 16:37:54 florian Exp $
// $Id: Syndication.php,v 1.4 2006-03-14 16:00:05 florian Exp $
 
 
/**
15,7 → 15,7
*/
class Text_Wiki_Parse_Syndication extends Text_Wiki_Parse {
var $regex = '/\{\{Syndication titre="(.+?)" url="(.+?)" nb=(.+?)\}\}/';
var $regex = '/\{\{Syndication titre="(.+?)" url="(.+?)" nb=(.+?) nouvellefenetre=(.+?) formatdate="(.+?)"\}\}/';
/**
*
35,7 → 35,7
function process(&$matches)
{
$options = array(
'titre' => $matches[1], 'url' => $matches[2], 'nb' => $matches[3],
'titre' => $matches[1], 'url' => $matches[2], 'nb' => $matches[3], 'nouvellefenetre' => $matches[4], 'formatdate' => $matches[5],
);
return $this->wiki->addToken($this->rule, $options);
}
/trunk/api/text/wiki_papyrus/Render/Xhtml/Syndication.php
1,5 → 1,5
<?php
require_once PAP_CHEMIN_API_PEAR.'XML/RSS.php';
require_once GEN_CHEMIN_API.'syndication_rss/syndication_rss.php';
 
class Text_Wiki_Render_Xhtml_Syndication extends Text_Wiki_Render {
18,51 → 18,18
function token($options)
{
// Initialisation des variables
// Initialisation des variables
$sortie = '';
$titre = $options['titre'];
$urls = $options['url'];
$nblimite = $options['nb'];
$nouvellefenetre = $options['nouvellefenetre'];
$formatdate = $options['formatdate'];
$tab_url = array_map('trim', explode(',', $urls));
if (ini_get('allow_url_fopen') != 0) {
ini_set('allow_url_fopen', 1);
foreach ($tab_url as $cle => $url) {
$url = str_replace('&amp;', '&', $url) ;
$sortie .= voir_rss($titre, $url, $nblimite, $nouvellefenetre, $formatdate);
}
if (ini_get('allow_url_fopen') != 0) {
foreach ($tab_url as $cle => $url) {
$url = str_replace('&amp;', '&', $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 ('/&/', '&amp;', $item['link']).'">'.$item['title'].'</a></li>'."\n";
$nbannonces++;
}
//affichage du nombre limité d'annonces classées de la plus récente à  la plus vieille
if ($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 annonces
if ($i>0) $sortie .= '<li>'.
'<a href="'.$aso_info_rss['link'].'">'.
'toutes les annonces</a></li>';
$sortie .= '</ul>'."\n";
}
}
return $sortie;
}
}