1 |
<?php |
2 |
///////////////////////////////////////////////// |
3 |
// PukiWiki - Yet another WikiWikiWeb clone. |
4 |
// |
5 |
// $Id: rss10.inc.php,v 1.2 2003/02/20 12:21:13 panda Exp $ |
6 |
// |
7 |
// RecentChanges の RSS を出力 |
8 |
function plugin_rss10_action() |
9 |
{ |
10 |
global $script,$rss_max,$page_title,$whatsnew; |
11 |
|
12 |
$self = $script.'?'; |
13 |
|
14 |
$page_title_utf8 = $page_title; |
15 |
if (function_exists('mb_convert_encoding')) { |
16 |
$page_title_utf8 = mb_convert_encoding($page_title_utf8,'UTF-8',SOURCE_ENCODING); |
17 |
} |
18 |
|
19 |
$items = $rdf_li = ''; |
20 |
|
21 |
if (!file_exists(CACHE_DIR.'recent.dat')) { |
22 |
return ''; |
23 |
} |
24 |
$recent = file(CACHE_DIR.'recent.dat'); |
25 |
$lines = array_splice($recent,0,$rss_max); |
26 |
foreach ($lines as $line) { |
27 |
list($time,$page) = explode("\t",rtrim($line)); |
28 |
$r_page = rawurlencode($page); |
29 |
$title = $page; |
30 |
if (function_exists('mb_convert_encoding')) { |
31 |
$title = mb_convert_encoding($title,'UTF-8',SOURCE_ENCODING); |
32 |
} |
33 |
// 'O'が出力する時刻を'+09:00'の形に整形 |
34 |
$dcdate = substr_replace(get_date('Y-m-d\TH:i:sO',$time),':',-2,0); |
35 |
|
36 |
// $desc = get_date('D, d M Y H:i:s T',$time); |
37 |
// <description>$desc</description> |
38 |
|
39 |
$items .= <<<EOD |
40 |
<item rdf:about="$script?$r_page"> |
41 |
<title>$title</title> |
42 |
<link>$script?$r_page</link> |
43 |
<dc:date>$dcdate</dc:date> |
44 |
</item> |
45 |
|
46 |
EOD; |
47 |
$rdf_li .= " <rdf:li rdf:resource=\"$script?$r_page\" />\n"; |
48 |
} |
49 |
|
50 |
header('Content-type: application/xml'); |
51 |
|
52 |
print <<<EOD |
53 |
<?xml version="1.0" encoding="utf-8"?> |
54 |
|
55 |
<rdf:RDF |
56 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
57 |
xmlns="http://purl.org/rss/1.0/" |
58 |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
59 |
xml:lang="ja"> |
60 |
|
61 |
<channel rdf:about="$script?rss"> |
62 |
<title>$page_title_utf8</title> |
63 |
<link>$script?$whatsnew</link> |
64 |
<description>PukiWiki RecentChanges</description> |
65 |
<items> |
66 |
<rdf:Seq> |
67 |
$rdf_li |
68 |
</rdf:Seq> |
69 |
</items> |
70 |
</channel> |
71 |
|
72 |
$items |
73 |
</rdf:RDF> |
74 |
EOD; |
75 |
exit; |
76 |
} |
77 |
?> |