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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,15 +1,16 @@
|
||||
<?php
|
||||
class RSSCommentsTest extends ShimmiePHPUnitTestCase {
|
||||
function testImageFeed() {
|
||||
global $user;
|
||||
$this->log_in_as_user();
|
||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
||||
send_event(new CommentPostingEvent($image_id, $user, "ASDFASDF"));
|
||||
class RSSCommentsTest extends ShimmiePHPUnitTestCase
|
||||
{
|
||||
public function testImageFeed()
|
||||
{
|
||||
global $user;
|
||||
$this->log_in_as_user();
|
||||
$image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx");
|
||||
send_event(new CommentPostingEvent($image_id, $user, "ASDFASDF"));
|
||||
|
||||
$this->get_page('rss/comments');
|
||||
//$this->assert_mime("application/rss+xml");
|
||||
$this->assert_no_content("Exception");
|
||||
$this->assert_content("ASDFASDF");
|
||||
$this->get_page('rss/comments');
|
||||
//$this->assert_mime("application/rss+xml");
|
||||
$this->assert_no_content("Exception");
|
||||
$this->assert_content("ASDFASDF");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user