/trunk/api/syndication_rss/syndication_rss.php |
---|
New file |
0,0 → 1,86 |
<?php |
define('MAGPIE_DIR', GEN_CHEMIN_API.'syndication_rss/magpierss/'); |
define('MAGPIE_CACHE_DIR', MAGPIE_DIR.'tmp/magpie_cache'); |
define('OUVRIR_LIEN_RSS_NOUVELLE_FENETRE', 1); |
define('FORMAT_DATE', 'jma'); |
require_once(MAGPIE_DIR.'rss_fetch.inc'); |
function voir_rss($titre='', $url='', $nb=0, $nouvelle_fenetre=OUVRIR_LIEN_RSS_NOUVELLE_FENETRE, $formatdate=FORMAT_DATE, $template = "") { |
$res= ''; |
if ( $url!='' ) { |
$rss = fetch_rss( $url ); |
if ($template != "") { |
$i = 0 ; |
foreach ($rss->items as $item) { |
// Le test suivant pour savoir s il faut reduire l excendent de description |
// Si {all} est present dans le template on ne reduit pas |
if (preg_match ('/{all}/', $template)) { |
$template = str_replace('{all}', '', $template); |
$all = true ; |
} else { |
$all = false; |
} |
if (strlen($item['description']) > 200 && !$all) { |
$item['description'] = substr ($item['description'] , 0, 300).'... <a href="'.$item['link'].'">Lire la suite</a>'; |
} |
if (!isset($item['pubdate'])) $item['pubdate'] = date('dmY'); |
$res .= str_replace ('{num}', ++$i, |
str_replace ('{item}', '<a href="'.$item['link'].'" target="_top">'.$item['title'].'</a>', |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item['pubdate'])), |
str_replace ('{description}', $item['description'], $template)))) ; |
$res .= "\n"; |
if ($i > $nb) break; |
} |
return $res ; |
} |
if ( $titre=='' ) {$res .= '<h2>'.$rss->channel['title'].'</h2>'."\n";} |
elseif ( $titre!='0' ) {$res .= '<h2>'.$titre.'</h2>'."\n";} |
$res .= '<ul class="liste_rss">'."\n"; |
$i=0; |
$nb_item=count($rss->items); |
if (($nb==0)or($nb_item<=$nb)) { |
foreach ($rss->items as $item) { |
$href = $item['link']; |
$title = $item['title']; |
$res .= '<li class="titre_rss">'."\n"; |
if (isset($item['pubdate'])) $date=$item['pubdate']; |
elseif ((!isset($item['pubdate']))and(isset($item['date_timestamp']))) $date=$item['date_timestamp']; |
else $formatdate=''; |
if ($formatdate=='jm') {$res .= strftime('%d.%m',strtotime($date)).': ';} |
if ($formatdate=='jma') {$res .= strftime('%d.%m.%Y',strtotime($date)).': ';} |
if ($formatdate=='jmh') {$res .= strftime('%d.%m %H:%M',strtotime($date)).': ';} |
if ($formatdate=='jmah') {$res .= strftime('%d.%m.%Y %H:%M',strtotime($date)).': ';} |
$res .= '<a class="lien_rss" href="'.$href; |
if ($nouvelle_fenetre==1) $res .= '" onclick="window.open(this.href); return false;'; |
$res .= '">'.$title.'</a></li>'."\n"; |
} |
} |
else { |
$i=0; |
foreach ($rss->items as $item) { |
$href = $item['link']; |
$title = $item['title']; |
$res .= '<li class="titre_rss">'."\n"; |
if (isset($item['pubdate'])) $date=$item['pubdate']; |
elseif ((!isset($item['pubdate']))and(isset($item['date_timestamp']))) $date=$item['date_timestamp']; |
else $formatdate=''; |
if ($formatdate=='jm') {$res .= strftime('%d.%m',strtotime($date)).': ';} |
if ($formatdate=='jma') {$res .= strftime('%d.%m.%Y',strtotime($date)).': ';} |
if ($formatdate=='jmh') {$res .= strftime('%d.%m %H:%M',strtotime($date)).': ';} |
if ($formatdate=='jmah') {$res .= strftime('%d.%m.%Y %H:%M',strtotime($date)).': ';} |
$res .= '<a class="lien_rss" href="'.$href; |
if ($nouvelle_fenetre==1) $res .= '" onclick="window.open(this.href); return false;'; |
$res .= '">'.$title.'</a></li>'."\n"; |
$i++; |
if ($i>=$nb) break; |
} |
} |
$res .= '</ul>'."\n"; |
} |
//echo '<pre>'.var_dump($rss->items).'</pre><br /><br />'; |
return $res; |
} |
?> |
/trunk/api/text/wiki_papyrus/Parse/Syndication.php |
---|
New file |
0,0 → 1,51 |
<?php |
// $Id: Syndication.php,v 1.7 2006-11-21 13:35:19 jp_milcent Exp $ |
/** |
* |
* This class implements a Text_Wiki_Parse to find source text marked as |
* an Interwiki link. See the regex for a detailed explanation of the |
* text matching procedure; e.g., "InterWikiName:PageName". |
* |
* @author Paul M. Jones <pmjones@ciaweb.net> |
* |
* @package Text_Wiki |
* |
*/ |
class Text_Wiki_Parse_Syndication extends Text_Wiki_Parse { |
var $regex = '/\{\{Syndication titre="([^"]+)" url="([^"]+)"( nb=(?:"|)\d+(?:"|))?( nouvellefenetre=(?:"|)(?:0|1)(?:"|))?( formatdate="[^"]+")?( template="[^"]+")?\}\}/'; |
/** |
* |
* 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 |
* |
* @access public |
* |
* @param array &$matches The array of matches from parse(). |
* |
* @return A delimited token to be used as a placeholder in |
* the source text, plus any text priot to the match. |
* |
*/ |
function process(&$matches) |
{ |
// 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/Papyrus.class.php |
---|
21,7 → 21,7 |
// | along with Foobar; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: Papyrus.class.php,v 1.15 2006-12-13 17:14:00 jp_milcent Exp $ |
// CVS : $Id: Papyrus.class.php,v 1.14 2006-12-13 10:53:09 jp_milcent Exp $ |
/** |
* Classe configurant le formatage pour Papyrus. |
* |
36,7 → 36,7 |
//Autres auteurs : |
*@author Aucun |
*@copyright Tela-Botanica 2000-2004 |
*@version $Revision: 1.15 $ $Date: 2006-12-13 17:14:00 $ |
*@version $Revision: 1.14 $ $Date: 2006-12-13 10:53:09 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
71,7 → 71,9 |
* @var array |
* |
*/ |
var $rules = array(); |
var $rules = array( |
'Syndication' // Action Syndication |
); |
/** |
* |
276,9 → 278,6 |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.14 2006/12/13 10:53:09 jp_milcent |
* Suppression de l'action Redirection transformée en Applette. |
* |
* Revision 1.13 2006/12/13 09:43:13 jp_milcent |
* Suppression de l'action Plan transformée en Applette. |
* |
/trunk/api/text/wiki_papyrus/Render/Xhtml/Syndication.php |
---|
New file |
0,0 → 1,41 |
<?php |
require_once GEN_CHEMIN_API.'syndication_rss/syndication_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']; |
$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('&', '&', $url) ; |
$sortie .= voir_rss($titre, $url, $options['nb'], $options['nouvellefenetre'], $options['formatdate'], $options['template']); |
} |
return $sortie; |
} |
} |
?> |