Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1059 → Rev 1060

/trunk/api/text/wiki_papyrus/Parse/Syndication.php
1,5 → 1,5
<?php
// $Id: Syndication.php,v 1.6 2006-09-13 09:56:02 alexandre_tb Exp $
// $Id: Syndication.php,v 1.7 2006-11-21 13:35:19 jp_milcent Exp $
 
 
/**
15,11 → 15,11
*/
class Text_Wiki_Parse_Syndication extends Text_Wiki_Parse {
var $regex = '/\{\{Syndication titre="(.+?)" url="(.+?)" nb=(.+?) nouvellefenetre=(.+?) formatdate="(.+?)"( template="(.+?)")?\}\}/';
var $regex = '/\{\{Syndication titre="([^"]+)" url="([^"]+)"( nb=(?:"|)\d+(?:"|))?( nouvellefenetre=(?:"|)(?:0|1)(?:"|))?( formatdate="[^"]+")?( template="[^"]+")?\}\}/';
/**
*
* Remplace l'action par une liste des dernières pages modifiées
* Remplace l'action par une liste des dernières pages modifièes
* Les options sont:
*
* 'site' => le code alphanumérique du ou des sites que l'on veut afficher
34,10 → 34,16
*/
function process(&$matches)
{
$options = array(
'titre' => $matches[1], 'url' => $matches[2], 'nb' => $matches[3], 'nouvellefenetre' => $matches[4], 'formatdate' => $matches[5],
);
if (isset ($matches['7']) && $matches['7'] != "") $options['template'] = $matches[7];
// Gestion des paramêtres obligatoires
$options = array('titre' => $matches[1], 'url' => $matches[2]);
// Gestion des paramêtres optionnels
$tab_param_optionel = array('nb', 'nouvellefenetre', 'formatdate', 'template');
for ($i = 3; $i < count($matches); $i++) {
$tab_param = explode('=', $matches[$i]);
$options[trim($tab_param[0])] = str_replace('"', '', $tab_param[1]);
}
return $this->wiki->addToken($this->rule, $options);
}
/trunk/api/text/wiki_papyrus/Render/Xhtml/Syndication.php
22,14 → 22,18
$sortie = '';
$titre = $options['titre'];
$urls = $options['url'];
$nblimite = $options['nb'];
$nouvellefenetre = $options['nouvellefenetre'];
$formatdate = $options['formatdate'];
if (isset($options['template'])) $template = $options['template']; else $template = '';
$tab_param_optionel = array('nb', 'nouvellefenetre', 'formatdate', 'template');
foreach ($tab_param_optionel as $val) {
if (isset($options[$val])) {
$options[$val] = $options[$val];
} else {
$options[$val] = null;
}
}
$tab_url = array_map('trim', explode(',', $urls));
foreach ($tab_url as $cle => $url) {
$url = str_replace('&amp;', '&', $url) ;
$sortie .= voir_rss($titre, $url, $nblimite, $nouvellefenetre, $formatdate, $template);
$sortie .= voir_rss($titre, $url, $options['nb'], $options['nouvellefenetre'], $options['formatdate'], $options['template']);
}
return $sortie;
}