forked from Cavemanon/cavepaintings
PSR-2. I'm not a huge fan, but ugly consistency beats no consistency...
This commit is contained in:
@ -7,24 +7,27 @@
|
||||
* Description: Self explanatory
|
||||
*/
|
||||
|
||||
class RSS_Comments extends Extension {
|
||||
protected $db_support = ['mysql', 'sqlite']; // pgsql has no UNIX_TIMESTAMP
|
||||
class RSS_Comments extends Extension
|
||||
{
|
||||
protected $db_support = ['mysql', 'sqlite']; // pgsql has no UNIX_TIMESTAMP
|
||||
|
||||
public function onPostListBuilding(PostListBuildingEvent $event) {
|
||||
global $config, $page;
|
||||
$title = $config->get_string('title');
|
||||
public function onPostListBuilding(PostListBuildingEvent $event)
|
||||
{
|
||||
global $config, $page;
|
||||
$title = $config->get_string('title');
|
||||
|
||||
$page->add_html_header("<link rel=\"alternate\" type=\"application/rss+xml\" ".
|
||||
"title=\"$title - Comments\" href=\"".make_link("rss/comments")."\" />");
|
||||
}
|
||||
$page->add_html_header("<link rel=\"alternate\" type=\"application/rss+xml\" ".
|
||||
"title=\"$title - Comments\" href=\"".make_link("rss/comments")."\" />");
|
||||
}
|
||||
|
||||
public function onPageRequest(PageRequestEvent $event) {
|
||||
global $config, $database, $page;
|
||||
if($event->page_matches("rss/comments")) {
|
||||
$page->set_mode("data");
|
||||
$page->set_type("application/rss+xml");
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
{
|
||||
global $config, $database, $page;
|
||||
if ($event->page_matches("rss/comments")) {
|
||||
$page->set_mode("data");
|
||||
$page->set_type("application/rss+xml");
|
||||
|
||||
$comments = $database->get_all("
|
||||
$comments = $database->get_all("
|
||||
SELECT
|
||||
users.id as user_id, users.name as user_name,
|
||||
comments.comment as comment, comments.id as comment_id,
|
||||
@ -36,17 +39,17 @@ class RSS_Comments extends Extension {
|
||||
LIMIT 10
|
||||
");
|
||||
|
||||
$data = "";
|
||||
foreach($comments as $comment) {
|
||||
$image_id = $comment['image_id'];
|
||||
$comment_id = $comment['comment_id'];
|
||||
$link = make_http(make_link("post/view/$image_id"));
|
||||
$owner = html_escape($comment['user_name']);
|
||||
$posted = date(DATE_RSS, strtotime($comment['posted']));
|
||||
$comment = html_escape($comment['comment']);
|
||||
$content = html_escape("$owner: $comment");
|
||||
$data = "";
|
||||
foreach ($comments as $comment) {
|
||||
$image_id = $comment['image_id'];
|
||||
$comment_id = $comment['comment_id'];
|
||||
$link = make_http(make_link("post/view/$image_id"));
|
||||
$owner = html_escape($comment['user_name']);
|
||||
$posted = date(DATE_RSS, strtotime($comment['posted']));
|
||||
$comment = html_escape($comment['comment']);
|
||||
$content = html_escape("$owner: $comment");
|
||||
|
||||
$data .= "
|
||||
$data .= "
|
||||
<item>
|
||||
<title>$owner comments on $image_id</title>
|
||||
<link>$link</link>
|
||||
@ -55,12 +58,12 @@ class RSS_Comments extends Extension {
|
||||
<description>$content</description>
|
||||
</item>
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
$title = $config->get_string('title');
|
||||
$base_href = make_http(get_base_href());
|
||||
$version = $config->get_string('version');
|
||||
$xml = <<<EOD
|
||||
$title = $config->get_string('title');
|
||||
$base_href = make_http(get_base_href());
|
||||
$version = $config->get_string('version');
|
||||
$xml = <<<EOD
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
@ -73,8 +76,7 @@ class RSS_Comments extends Extension {
|
||||
</channel>
|
||||
</rss>
|
||||
EOD;
|
||||
$page->set_data($xml);
|
||||
}
|
||||
}
|
||||
$page->set_data($xml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user