| 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_atom_dist($rss, $intro = '') { |
| 21 | // entetes |
| 22 | $u = '<'.'?xml version="1.0" encoding="'.$GLOBALS['meta']['charset'] |
| 23 | .'"?'.">\n"; |
| 24 | $u .= '<feed xmlns="http://www.w3.org/2005/Atom"'; |
| 25 | if ($intro['language']) |
| 26 | $u .= ' xml:lang="'.$intro['language'].'"'; |
| 27 | $u .= '> |
| 28 | <title>'.texte_backend($intro['title']).'</title> |
| 29 | <id>'.texte_backend(url_absolue($intro['url'])).'</id> |
| 30 | <link href="'.texte_backend(url_absolue($intro['url'])).'"/>'; |
| 31 | if ($intro['description']) $u .= '<subtitle>'.texte_backend($intro['description']).'</subtitle>'; |
| 32 | $u .= '<link rel="self" type="application/atom+xml" href="'.texte_backend(url_absolue($_SERVER['REQUEST_URI'])).'"/> |
| 33 | <updated>'.gmdate("Y-m-d\TH:i:s\Z").'</updated>'; // probleme, <updated> pourrait etre plus precis |
| 34 | |
| 35 | // elements |
| 36 | if (is_array($rss)) { |
| 37 | usort($rss, 'trier_par_date'); |
| 38 | foreach ($rss as $article) { |
| 39 | $u .= "\n\t<entry"; |
| 40 | if ($article['lang']) |
| 41 | $u .= ' xml:lang="'.texte_backend($article['lang']).'"'; |
| 42 | $u .= '> |
| 43 | <title>'.texte_backend($article['title']).'</title> |
| 44 | <id>'.texte_backend(url_absolue($article['url'])).'</id> |
| 45 | <link rel="alternate" type="text/html" href="'.texte_backend(url_absolue($article['url'])).'"/> |
| 46 | <published>'.date_iso($article['date']).'</published> |
| 47 | <updated>'.date_iso($article['date']).'</updated>'; |
| 48 | if ($article['author']) { |
| 49 | $u .= ' |
| 50 | <author><name>'.texte_backend($article['author']).'</name>'; |
| 51 | if ($article['email']) |
| 52 | $u .= '<email>'.texte_backend($article['email']).'</email>'; |
| 53 | $u .= '</author>'; |
| 54 | } |
| 55 | $u .=' |
| 56 | <summary type="html">'.texte_backend(liens_absolus($article['description'])).'</summary> |
| 57 | </entry> |
| 58 | '; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // pied |
| 63 | $u .= ' |
| 64 | </feed> |
| 65 | '; |
| 66 | |
| 67 | header('Content-Type: text/xml; charset='.$GLOBALS['meta']['charset']); |
| 68 | echo $u; |
| 69 | } |
| 70 | ?> |