Subversion Repositories Applications.papyrus

Rev

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

Rev 355 Rev 533
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'];
-
 
24
        $urls = $options['url'];
23
        $urls = $options['url'];
25
	$nblimite = $options['nb'];
24
        $tab_url = array_map('trim', explode(',', $urls));
26
        $tab_url = array_map('trim', explode(',', $urls));
25
        if (ini_get('allow_url_fopen') != 0) {
27
        if (ini_get('allow_url_fopen') != 0) {
26
            ini_set('allow_url_fopen', 1);
28
            ini_set('allow_url_fopen', 1);
27
        }
29
        }
28
        if (ini_get('allow_url_fopen') != 0) {
30
        if (ini_get('allow_url_fopen') != 0) {
29
            foreach ($tab_url as $cle => $url) {
31
            foreach ($tab_url as $cle => $url) {
30
                $rss =& new XML_RSS($url);
32
                $rss =& new XML_RSS($url);
31
                $rss->parse();
33
                $rss->parse();
-
 
34
                $aso_info_rss = $rss->getChannelInfo();
-
 
35
                if ($titre!='') {
-
 
36
			$sortie .= '<h2>'.$titre.'</h2>';
32
                $aso_info_rss = $rss->getChannelInfo();
37
		}
33
                if (isset($aso_info_rss['title'])) {
38
		elseif (isset($aso_info_rss['title'])) {
34
                    $sortie .= '<h2>'.$aso_info_rss['title'].'</h2>';
39
                    $sortie .= '<h2>'.$aso_info_rss['title'].'</h2>';
35
                }
40
                }
-
 
41
                $sortie .= '<ul class="syndication" >'."\n";
-
 
42
		$nbannonces=0;
36
                $sortie .= '<ul class="syndication" >'."\n";
43
		$tabsortie=array();
37
                foreach ($rss->getItems() as $item) {
44
                foreach ($rss->getItems() as $item) {
-
 
45
				$tabsortie[$nbannonces]='<li><a href="'.preg_replace ('/&/', '&amp;', $item['link']).'">'.$item['title'].'</a></li>'."\n";
38
                    $sortie .= '<li><a href="'.$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
39
                }
60
		if ($i>0) $sortie .= '<li style="margin-left:-18px;background:transparent;"><a href="http://educ-envir.org/papyrus.php?site=1&amp;menu=21&amp;action=1&amp;nature='.$aso_info_rss['title'].'"><strong>'.$aso_info_rss['title'].'</strong>: toutes les annonces</a></li>';
40
                $sortie .= '</ul>'."\n";
61
                $sortie .= '</ul>'."\n";
41
            }
62
            }
42
        }
63
        }
43
        return $sortie;
64
        return $sortie;