summaryrefslogtreecommitdiff
path: root/tpl/blog/atom_feed.php
blob: 20dc0ea48547a32349cbe525678998db162e1835 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
header("Content-Type: application/xml");

echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n";
echo '<title>' . $blog_title . '</title>'."\n";
echo '<id>' . $blog_base_url . "blog". "</id>\n";
echo '<link href="' . $blog_base_url . "blog". '" rel="self" />' . "\n";


function beginning($text, $len = 500) {
	$text = preg_replace('#<.+>#isU', ' ', $text);
	if (strlen($text) > $len) {
		$text = substr($text, 0, $len)."...";
	}
	return $text;
}

foreach ($posts as $post) {
	echo "\n<entry>\n";
	echo '<title>' . $post['title'] . "</title>\n";
	echo '<published>' . @date("c", $post['date_ts']) . "</published>\n";
	echo '<id>' . $blog_base_url . "view-blog-" . $post['id'] . "</id>\n";
	foreach (explode(',  ', $post['tags']) as $tag) {
		echo '<category term="' . $tag . '" />' . "\n";
	}
	echo '<link href="' . $blog_base_url . "view-blog-" . $post['id'] . '" />' . "\n";
	echo '<summary type="html"><![CDATA['. beginning($post['text_html']) .']]></summary>' . "\n";
	echo '<content type="html"><![CDATA['. $post['text_html'] ."]]></content>\n";
	echo "<author><name>".$post['owner']."</name></author>\n";
	echo "</entry>\n";
}

echo '</feed>';

die();