Skip to content

Instantly share code, notes, and snippets.

@xrado
Created September 19, 2010 17:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xrado/586963 to your computer and use it in GitHub Desktop.
Save xrado/586963 to your computer and use it in GitHub Desktop.
<?php if (!defined('APPLICATION')) exit();
// Define the plugin:
$PluginInfo['RssFeed'] = array(
'Description' => 'This simple plugin for new discussions and discussions updates',
'Version' => '1.0',
'RequiredApplications' => FALSE,
'RequiredTheme' => FALSE,
'RequiredPlugins' => FALSE,
'HasLocale' => TRUE,
'RegisterPermissions' => FALSE,
'Author' => 'xrado',
'AuthorEmail' => 'radovan.lozej@gmail.com',
'AuthorUrl' => 'http://www.xrado.si'
);
class RssFeed implements Gdn_IPlugin {
/// Methods ///
public function DiscussionsController_Rss_Create($Sender) {
$db = Gdn::Database();
$data = $db->SQL()->Query('
(
SELECT
GDN_Discussion.DiscussionID,
0 as CommentID,
GDN_Discussion.Name,
GDN_Discussion.Body,
GDN_Discussion. DateInserted,
GDN_User.Name as User
FROM GDN_Discussion
LEFT JOIN GDN_User ON (GDN_Discussion.InsertUserID=GDN_User.UserID)
ORDER BY DateInserted DESC
LIMIT 20
)
UNION ALL
(
SELECT
GDN_Comment.DiscussionID,
GDN_Comment.CommentID,
GDN_Discussion.Name,
GDN_Comment.Body,
GDN_Comment.DateInserted,
GDN_User.Name as User
FROM `GDN_Comment`
LEFT JOIN GDN_Discussion ON (GDN_Comment.DiscussionID=GDN_Discussion.DiscussionID)
LEFT JOIN GDN_User ON (GDN_Comment.InsertUserID=GDN_User.UserID)
ORDER BY GDN_Comment.DateInserted DESC
LIMIT 30
)
ORDER BY DateInserted DESC
LIMIT 40
');
header("Content-Type: application/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<link>'.Url('discussions', TRUE).'</link>
<title>All Discussions - Kohana Forums</title>
<description>All Discussions - Kohana Forums</description>
<language>en-CA</language>
<generator>KohanaPHP</generator>
<atom:link href="'.Url('discussions/rss', TRUE).'" rel="self" type="application/rss+xml" />
';
foreach($data as $d)
{
echo '<item>
<dc:creator>'.$d->User.'</dc:creator>
<title>'.$d->Name.'</title>
<link>'.Url('discussion/'.$d->DiscussionID.($d->CommentID ? '/#Item_'.$d->CommentID : ''), TRUE).'</link>
<guid>'.Url('discussion/'.$d->DiscussionID.($d->CommentID ? '/#Item_'.$d->CommentID : ''), TRUE).'</guid>
<description><![CDATA['.$d->Body.']]></description>
<pubDate>'.date('D, d M Y H:i:s O',strtotime($d->DateInserted)).'</pubDate>
</item>';
}
echo '</channel></rss>';
exit;
}
public function Setup() {
// No setup required
}
}
@shadowhand
Copy link

@xrado Thanks, I've updated and am now tracking your Gist. Please add a comment if you update it again.

@xrado
Copy link
Author

xrado commented Nov 14, 2011

can you re-enable this rss plugin on forum

@kiall
Copy link

kiall commented Nov 16, 2011

@xrado - I'm enabling it now, It was lost after the recent forum incident :)

@kiall
Copy link

kiall commented Nov 16, 2011

@xrado - done.. Also, I would love if you could turn it into a repo we can submodule :)

kohana/Garden@f752215

@xrado
Copy link
Author

xrado commented Nov 16, 2011

@kiall - thx, maybe i well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment