Commit | Line | Data |
---|---|---|
c495c100 P |
1 | <?php |
2 | ||
3 | /***************************************************************************\ | |
4 | * SPIP, Systeme de publication pour l'internet * | |
5 | * * | |
6 | * Copyright (c) 2001-2007 * | |
7 | * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * | |
8 | * * | |
9 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * | |
10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * | |
11 | \***************************************************************************/ | |
12 | ||
13 | ||
14 | if (!defined("_ECRIRE_INC_VERSION")) return; | |
15 | ||
16 | include_spip('inc/minipres'); | |
17 | include_spip('inc/acces'); | |
18 | include_spip('inc/texte'); // utile pour l'espace public, deja fait sinon | |
19 | ||
20 | function xml_rss_dist($rss, $intro = '') { | |
21 | // entetes | |
22 | $u = '<'.'?xml version="1.0" encoding="'.$GLOBALS['meta']['charset'].'"?'.">\n"; | |
23 | ||
24 | $u .= ' | |
25 | <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"> | |
26 | <channel> | |
27 | <title>'.texte_backend($intro['title']).'</title> | |
28 | <link>'.texte_backend(url_absolue($intro['url'])).'</link> | |
29 | <description>'.texte_backend($intro['description']).'</description> | |
30 | <language>'.texte_backend($intro['language']).'</language> | |
31 | '; | |
32 | ||
33 | // elements | |
34 | if (is_array($rss)) { | |
35 | usort($rss, 'trier_par_date'); | |
36 | foreach ($rss as $article) { | |
37 | $u .= ' | |
38 | <item> | |
39 | <title>'.texte_backend($article['title']).'</title> | |
40 | <link>'.texte_backend(url_absolue($article['url'])).'</link> | |
41 | <guid isPermaLink="true">'.texte_backend(url_absolue($article['url'])).'</guid> | |
42 | <dc:date>'.date_iso($article['date']).'</dc:date> | |
43 | <dc:format>text/html</dc:format>'; | |
44 | if ($article['lang']) $u .= ' | |
45 | <dc:language>'.texte_backend($article['lang']).'</dc:language>'; | |
46 | if ($article['author']) { | |
47 | if ($article['email']) | |
48 | $article['author'].=' <'.$article['email'].'>'; | |
49 | ||
50 | $u .= ' | |
51 | <dc:creator>'.texte_backend($article['author']).'</dc:creator>'; | |
52 | } | |
53 | $u .= ' | |
54 | <description>'.texte_backend(liens_absolus($article['description'])).'</description> | |
55 | </item> | |
56 | '; | |
57 | } | |
58 | } | |
59 | ||
60 | // pied | |
61 | $u .= ' | |
62 | </channel> | |
63 | </rss> | |
64 | '; | |
65 | header('Content-Type: text/xml; charset='.$GLOBALS['meta']['charset']); | |
66 | echo $u; | |
67 | } | |
68 | ?> |