Subversion Repositories Applications.papyrus

Rev

Rev 354 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
345 jpm 1
<?php
2
require_once PAP_CHEMIN_API_PEAR.'XML/RSS.php';
3
 
4
class Text_Wiki_Render_Xhtml_Syndication extends Text_Wiki_Render {
5
 
6
    /**
7
    *
8
    * Renders a token into text matching the requested format.
9
    *
10
    * @access public
11
    *
12
    * @param array $options The "options" portion of the token (second
13
    * element).
14
    *
15
    * @return string The text rendered from the token options.
16
    *
17
    */
18
 
19
    function token($options)
20
    {
21
        // Initialisation des variables
22
        $sortie = '';
23
        $urls = $options['url'];
24
        $tab_url = array_map('trim', explode(',', $urls));
25
        if (ini_get('allow_url_fopen') != 0) {
26
            ini_set('allow_url_fopen', 1);
27
        }
28
        if (ini_get('allow_url_fopen') != 0) {
29
            foreach ($tab_url as $cle => $url) {
30
                $rss =& new XML_RSS($url);
31
                $rss->parse();
32
                $aso_info_rss = $rss->getChannelInfo();
355 florian 33
                if (isset($aso_info_rss['title'])) {
354 jpm 34
                    $sortie .= '<h2>'.$aso_info_rss['title'].'</h2>';
35
                }
36
                $sortie .= '<ul class="syndication" >'."\n";
345 jpm 37
                foreach ($rss->getItems() as $item) {
38
                    $sortie .= '<li><a href="'.$item['link'].'">'.$item['title'].'</a></li>'."\n";
39
                }
40
                $sortie .= '</ul>'."\n";
41
            }
42
        }
43
        return $sortie;
44
    }
45
}
46
?>