Subversion Repositories Applications.papyrus

Rev

Rev 763 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 763 Rev 773
Line 1... Line 1...
1
<?php
1
<?php
2
require_once PAP_CHEMIN_API_PEAR.'XML/RSS.php';
2
require_once GEN_CHEMIN_API.'syndication_rss/syndication_rss.php';
Line 3... Line 3...
3
 
3
 
Line 4... Line 4...
4
class Text_Wiki_Render_Xhtml_Syndication extends Text_Wiki_Render {
4
class Text_Wiki_Render_Xhtml_Syndication extends Text_Wiki_Render {
5
    
5
    
Line 16... Line 16...
16
    * 
16
    * 
17
    */
17
    */
Line 18... Line 18...
18
    
18
    
19
    function token($options)
19
    function token($options)
20
    {
20
    {
21
        // Initialisation des variables
21
	// Initialisation des variables
22
        $sortie = '';
22
        $sortie = '';
23
        $titre = $options['titre'];
23
        $titre = $options['titre'];
24
        $urls = $options['url'];
24
        $urls = $options['url'];
-
 
25
        $nblimite = $options['nb'];
-
 
26
        $nouvellefenetre = $options['nouvellefenetre'];
25
        $nblimite = $options['nb'];
27
        $formatdate = $options['formatdate'];
26
        $tab_url = array_map('trim', explode(',', $urls));
-
 
27
        if (ini_get('allow_url_fopen') != 0) {
-
 
28
            ini_set('allow_url_fopen', 1);
-
 
29
        }
-
 
30
        if (ini_get('allow_url_fopen') != 0) {
28
        $tab_url = array_map('trim', explode(',', $urls));
31
            foreach ($tab_url as $cle => $url) {
29
        foreach ($tab_url as $cle => $url) {
32
                $url = str_replace('&amp;', '&', $url) ;
-
 
33
                $rss =& new XML_RSS($url);
30
             $url = str_replace('&amp;', '&', $url) ;
34
                if (!$rss->parse()) echo 'une erreur d\'analyse du fichier RSS s\'est produite';
-
 
35
                $aso_info_rss = $rss->getChannelInfo();
-
 
36
                if ($titre!='') {
-
 
37
					$sortie .= '<h2>'.$titre.'</h2>';
-
 
38
				} elseif (isset($aso_info_rss['title'])) {
-
 
39
                    $sortie .= '<h2>'.$aso_info_rss['title'].'</h2>';
-
 
40
                }
-
 
41
                $sortie .= '<ul class="syndication" >'."\n";
-
 
42
				$nbannonces=0;
-
 
43
				$tabsortie=array();
-
 
44
                foreach ($rss->getItems() as $item) {
-
 
45
					$tabsortie[$nbannonces]='<li><a href="'.preg_replace ('/&/', '&amp;', $item['link']).'">'.$item['title'].'</a></li>'."\n";
-
 
46
					$nbannonces++;
-
 
47
                }
-
 
48
		//affichage du nombre limité d'annonces classées de la plus récente à  la plus vieille
-
 
49
		if ($nblimite>0) {
-
 
50
			for ($i = $nbannonces-1; (($i >= $nbannonces-$nblimite)and($i>=0)); $i--) {
-
 
51
				$sortie .= $tabsortie[$i];
-
 
52
			}
-
 
53
		}
-
 
54
		else {
-
 
55
			for ($i = $nbannonces-1; ($i>=0); $i--) {
-
 
56
				$sortie .= $tabsortie[$i];
-
 
57
			}
-
 
58
		}
-
 
59
		//si toutes les annonces n'ont pas été affichées, on propose de consulter les reste des annonces
-
 
60
		if ($i>0) $sortie .= '<li>'.
-
 
61
							'<a href="'.$aso_info_rss['link'].'">'.
-
 
62
							'toutes les annonces</a></li>';
-
 
63
                $sortie .= '</ul>'."\n";
-
 
64
            }
31
	     $sortie .= voir_rss($titre, $url, $nblimite, $nouvellefenetre, $formatdate);
65
        }
32
        }
66
        return $sortie;
33
        return $sortie;
67
    }
34
    }
68
}
35
}
69
?>
36
?>