[pLog-svn] r4421 - in plugins/branches/lifetype-1.1/recentcomments:
. class/action class/view templates
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Sat Dec 23 21:19:56 GMT 2006
Author: jondaley
Date: 2006-12-23 21:19:56 +0000 (Sat, 23 Dec 2006)
New Revision: 4421
Added:
plugins/branches/lifetype-1.1/recentcomments/class/action/pluginrecentcommentsrssaction.class.php
plugins/branches/lifetype-1.1/recentcomments/class/view/pluginrecentcommentsrssview.class.php
plugins/branches/lifetype-1.1/recentcomments/templates/rss20.template
Modified:
plugins/branches/lifetype-1.1/recentcomments/pluginrecentcomments.class.php
plugins/branches/lifetype-1.1/recentcomments/readme.txt
Log:
We now have an RSS feed for recent comments in a blog
Added: plugins/branches/lifetype-1.1/recentcomments/class/action/pluginrecentcommentsrssaction.class.php
===================================================================
--- plugins/branches/lifetype-1.1/recentcomments/class/action/pluginrecentcommentsrssaction.class.php 2006-12-23 19:54:48 UTC (rev 4420)
+++ plugins/branches/lifetype-1.1/recentcomments/class/action/pluginrecentcommentsrssaction.class.php 2006-12-23 21:19:56 UTC (rev 4421)
@@ -0,0 +1,23 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/recentcomments/class/view/pluginrecentcommentsrssview.class.php" );
+
+ class PluginRecentCommentsRssAction extends BlogAction
+ {
+
+ function PluginRecentCommentsRssAction( $actionInfo, $request )
+ {
+ $this->BlogAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ $this->_view = new PluginRecentCommentsRssView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.1/recentcomments/class/view/pluginrecentcommentsrssview.class.php
===================================================================
--- plugins/branches/lifetype-1.1/recentcomments/class/view/pluginrecentcommentsrssview.class.php 2006-12-23 19:54:48 UTC (rev 4420)
+++ plugins/branches/lifetype-1.1/recentcomments/class/view/pluginrecentcommentsrssview.class.php 2006-12-23 21:19:56 UTC (rev 4421)
@@ -0,0 +1,34 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/view/plugintemplatedview.class.php" );
+ include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
+
+ class PluginRecentCommentsRssView extends PluginTemplatedView
+ {
+ function PluginRecentCommentsRssView($blogInfo){
+ $this->PluginTemplatedView( $blogInfo, "recentcomments", "rss20" );
+ }
+
+ function render(){
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_recentcomments_enabled" );
+ $maxComments = $blogSettings->getValue( "plugin_recentcomments_maxcomments" );
+ if($maxComments == "")
+ $maxComments = 10;
+
+ $blogComments = array();
+ $articleComments = new ArticleComments();
+ $blogComments = $articleComments->getBlogComments($this->_blogInfo->getId(),
+ COMMENT_ORDER_NEWEST_FIRST,
+ COMMENT_STATUS_NONSPAM,
+ "",
+ 1,
+ $maxComments);
+
+ $this->setValue("comments", $blogComments);
+ $this->setContentType( 'text/xml' );
+ parent::render();
+ }
+
+ }
+?>
\ No newline at end of file
Modified: plugins/branches/lifetype-1.1/recentcomments/pluginrecentcomments.class.php
===================================================================
--- plugins/branches/lifetype-1.1/recentcomments/pluginrecentcomments.class.php 2006-12-23 19:54:48 UTC (rev 4420)
+++ plugins/branches/lifetype-1.1/recentcomments/pluginrecentcomments.class.php 2006-12-23 21:19:56 UTC (rev 4421)
@@ -24,6 +24,8 @@
function init()
{
+ $this->registerBlogAction( "recentcommentsrss", "PluginRecentCommentsRssAction" );
+
$this->registerAdminAction( "recentcomments", "PluginRecentCommentsConfigAction" );
$this->registerAdminAction( "updateRecentCommentsConfig", "PluginRecentCommentsUpdateConfigAction" );
include_once( PLOG_CLASS_PATH."class/template/menu/menu.class.php" );
@@ -99,5 +101,16 @@
$articles = new Articles();
return $articles->getArticle($artId);
}
+
+ function getRssFeedUrl(){
+ include_once( PLOG_CLASS_PATH."class/net/rawrequestgenerator.class.php" );
+
+ $rg = new RawRequestGenerator($this->blogInfo);
+ $rg->addParameter( "op", "recentcommentsrss" );
+ $rg->addParameter( "blogId", $this->blogInfo->getId());
+
+ $feedUrl = $rg->getIndexUrl().$rg->getRequest();
+ return $feedUrl;
+ }
}
?>
\ No newline at end of file
Modified: plugins/branches/lifetype-1.1/recentcomments/readme.txt
===================================================================
--- plugins/branches/lifetype-1.1/recentcomments/readme.txt 2006-12-23 19:54:48 UTC (rev 4420)
+++ plugins/branches/lifetype-1.1/recentcomments/readme.txt 2006-12-23 21:19:56 UTC (rev 4421)
@@ -1,13 +1,15 @@
Plugin: Recent Comments
Author: Mark Wu
Release Date: 2005/01/23
-Version: 1.0
+Version: 1.1
-This plugin offers the most recently article comments. Usage as follow:
+This plugin offers the most recently article comments (for regular
+templates and an RSS feed). Usage as follow:
You can use:
1. $recentcomments->isEnabled() to check the plugin is enabled or not.
2. $recentcomments->getRecentComments( $maxComments , $based ) to get the recent comments.
+3. $recentcomments->getRssFeedUrl() to get the URL to the recent comments feed for the current blog
Where:
1. $maxComments is the the max comments you want to show. Default is 10.
@@ -16,7 +18,7 @@
Example:
Add the following code to footer.template or header.template:
{if $recentcomments->isEnabled()}
-<h2>Recent Comments</h2>
+<h2>Recent Comments [<a href="{$recentcomments->getRssFeedUrl()}">rss</a>]</h2>
{assign var=comments value=$recentcomments->getRecentComments()}
<ul>
{foreach from=$comments item=comment}
@@ -25,4 +27,4 @@
<li><a title="View comments by {$comment->getUsername()}" href="{$url->postPermalink($commentpost)}#{$comment->getId()}"><b>{$comment->getUsername()}¡G</b>{$comment->getText()|truncate:100:"..."|strip_tags}</a></li>
{/foreach}
</ul>
-{/if}
\ No newline at end of file
+{/if}
Added: plugins/branches/lifetype-1.1/recentcomments/templates/rss20.template
===================================================================
--- plugins/branches/lifetype-1.1/recentcomments/templates/rss20.template 2006-12-23 19:54:48 UTC (rev 4420)
+++ plugins/branches/lifetype-1.1/recentcomments/templates/rss20.template 2006-12-23 21:19:56 UTC (rev 4421)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="{$locale->getCharset()}"?>
+<?xml-stylesheet href="{$url->getUrl("/styles/rss.css")}" type="text/css"?>
+<rss version="2.0"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+>
+ <channel>
+ <title>Comments on {$blog->getBlog()|escape}</title>
+ <link>{$url->blogLink()}</link>
+ <description>{$blog->getAbout()|escape}</description>
+ <pubDate>{$locale->formatDateAsRFC822($now)}</pubDate>
+ <generator>http://www.lifetype.net</generator>
+ {foreach from=$comments item=comment}
+ {assign var="CommentsRssPost" value=$comment->getArticle()}
+ <item>
+ <title>
+ {if $comment->getTopic() != ""}
+ {$comment->getTopic()|escape}
+ {else}
+ Comment on {$CommentsRssPost->getTopic()|escape}
+ {/if}
+ </title>
+ <description>
+ {if $comment->getText() != ""}
+ {$comment->getText()|escape}
+ {else}
+ No comment
+ {/if}
+ </description>
+ <link>{$url->postPermalink($CommentsRssPost)}</link>
+ <comments>{$url->postPermalink($CommentsRssPost)}</comments>
+ <guid>{$url->postPermalink($CommentsRssPost)}#{$comment->getId()}</guid>
+ <dc:creator>{$comment->getUsername()|escape}</dc:creator>
+ {foreach from=$CommentsRssPost->getCategories() item=category}
+ <category>{$category->getName()|escape}</category>
+ {/foreach}
+ {assign var="commentDate" value=$comment->getDateObject()}
+ <pubDate>{$locale->formatDateAsRFC822($commentDate, $blog)}</pubDate>
+ <source url="{$url->rssLink("rss20")}">{$blog->getBlog()|escape}</source>
+ </item>
+ {/foreach}
+ </channel>
+</rss>
More information about the pLog-svn
mailing list