Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 169 → Rev 170

/trunk/api/text/wiki_wikini/Render/Xhtml/Include.php
New file
0,0 → 1,62
<?php
 
class Text_Wiki_Render_Xhtml_Include extends Text_Wiki_Render {
var $conf = array(
'sites' => array(
'Wikipedia' => 'http://fr.wikipedia.org/wiki/%s',
'Wikipedia_fr' => 'http://fr.wikipedia.org/wiki/%s',
'Wikipedia_en' => 'http://en.wikipedia.org/wiki/%s'
),
'css' => null
);
/**
*
* 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)
{
$site = $options['site'];
$page = $options['page'];
$text = $options['text'];
$css = $this->formatConf(' class="%s"', 'css');
echo $site;
if (isset($this->conf['sites'][$site])) {
$href = $this->conf['sites'][$site];
} else {
return $text;
}
// old form where page is at end,
// or new form with %s placeholder for sprintf()?
if (strpos($href, '%s') === false) {
// use the old form
$href = $href . $page;
} else {
// use the new form
$href = sprintf($href, $page);
}
$output = '';
if (preg_match('/^Wikipedia/', $site)) {
$contenu = file_get_contents($href);
preg_match('/<!-- start content -->(.*)<!-- end content -->/Umsi', $contenu, $tab_matches);
$output = $tab_matches[1];
}
return $output;
}
}
?>