[pLog-svn] r5277 - in plugins/branches/lifetype-1.2/recentcomments: . class/action class/view locale

mark at devel.lifetype.net mark at devel.lifetype.net
Fri Apr 6 11:15:31 EDT 2007


Author: mark
Date: 2007-04-06 11:15:31 -0400 (Fri, 06 Apr 2007)
New Revision: 5277

Modified:
   plugins/branches/lifetype-1.2/recentcomments/class/action/pluginrecentcommentsupdateconfigaction.class.php
   plugins/branches/lifetype-1.2/recentcomments/class/view/pluginrecentcommentsconfigview.class.php
   plugins/branches/lifetype-1.2/recentcomments/class/view/pluginrecentcommentsrssview.class.php
   plugins/branches/lifetype-1.2/recentcomments/locale/locale_zh_CN.php
   plugins/branches/lifetype-1.2/recentcomments/locale/locale_zh_TW.php
   plugins/branches/lifetype-1.2/recentcomments/pluginrecentcomments.class.php
   plugins/branches/lifetype-1.2/recentcomments/readme.txt
Log:
Some modification to adapt lifetype 1.2 API. No more additional sql queries in recent comment, we get those data from our DAO.

Modified: plugins/branches/lifetype-1.2/recentcomments/class/action/pluginrecentcommentsupdateconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/recentcomments/class/action/pluginrecentcommentsupdateconfigaction.class.php	2007-04-06 13:55:57 UTC (rev 5276)
+++ plugins/branches/lifetype-1.2/recentcomments/class/action/pluginrecentcommentsupdateconfigaction.class.php	2007-04-06 15:15:31 UTC (rev 5277)
@@ -2,6 +2,7 @@
 
 	lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
 	lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
 	lt_include( PLOG_CLASS_PATH."plugins/recentcomments/class/view/pluginrecentcommentsconfigview.class.php" );	
 		
 	/**
@@ -22,7 +23,8 @@
             $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
             $this->_pluginEnabled = ($this->_pluginEnabled != "" );			
             $this->_maxComments = $this->_request->getValue( "maxComments" );
-            if( $this->_maxComments <= 0  || !ctype_digit($this->_maxComments) ) {
+        	$val = new IntegerValidator();
+        	if( !$val->validate( $this->_maxComments ) ) {
                 $this->_view = new PluginRecentCommentsConfigView( $this->_blogInfo );
                 $this->_view->setErrorMessage( $this->_locale->tr("recentcomments_error_maxcomments"));
                 $this->setCommonData();

Modified: plugins/branches/lifetype-1.2/recentcomments/class/view/pluginrecentcommentsconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/recentcomments/class/view/pluginrecentcommentsconfigview.class.php	2007-04-06 13:55:57 UTC (rev 5276)
+++ plugins/branches/lifetype-1.2/recentcomments/class/view/pluginrecentcommentsconfigview.class.php	2007-04-06 15:15:31 UTC (rev 5277)
@@ -19,7 +19,7 @@
 			$blogSettings = $this->_blogInfo->getSettings();
 			$pluginEnabled = $blogSettings->getValue( "plugin_recentcomments_enabled" );
 			$maxComments = $blogSettings->getValue( "plugin_recentcomments_maxcomments" );
-			if ($maxComments == "") $maxComments = 10;
+			if ($maxComments == "") $maxComments = DEFAULT_ITEMS_PER_PAGE;
 			
 			// create a view and export the settings to the template
 			$this->setValue( "pluginEnabled", $pluginEnabled );

Modified: plugins/branches/lifetype-1.2/recentcomments/class/view/pluginrecentcommentsrssview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/recentcomments/class/view/pluginrecentcommentsrssview.class.php	2007-04-06 13:55:57 UTC (rev 5276)
+++ plugins/branches/lifetype-1.2/recentcomments/class/view/pluginrecentcommentsrssview.class.php	2007-04-06 15:15:31 UTC (rev 5277)
@@ -14,7 +14,7 @@
 			$pluginEnabled = $blogSettings->getValue( "plugin_recentcomments_enabled" );
 			$maxComments = $blogSettings->getValue( "plugin_recentcomments_maxcomments" );
 			if($maxComments == "")
-                $maxComments = 10;
+                $maxComments = DEFAULT_ITEMS_PER_PAGE;
 
             $blogComments = array();
             $articleComments = new ArticleComments();

Modified: plugins/branches/lifetype-1.2/recentcomments/locale/locale_zh_CN.php
===================================================================
--- plugins/branches/lifetype-1.2/recentcomments/locale/locale_zh_CN.php	2007-04-06 13:55:57 UTC (rev 5276)
+++ plugins/branches/lifetype-1.2/recentcomments/locale/locale_zh_CN.php	2007-04-06 15:15:31 UTC (rev 5277)
@@ -1,17 +1,17 @@
 <?php
 $messages["manageRecentPlugins"] = "博客最近活动管理";
-$messages["RecentComments"] = "最近回复设置";
-$messages["recentcomments"] = "最近回复";
-$messages["view_comment_by"] = "查看 %s 的回复";
+$messages["RecentComments"] = "最近回响设置";
+$messages["recentcomments"] = "最近回响";
+$messages["view_comment_by"] = "查看 %s 的回响";
 
-$messages["recentcomments_maxcomments"] = "最新回复显示数量";
-$messages["recentcomments_plugin_enabled"] = "启用插件";
-$messages["recentcomments_plugin"] = "最近回复插件";
+$messages["recentcomments_maxcomments"] = "最新回响显示数量";
+$messages["recentcomments_plugin_enabled"] = "启动外挂程式";
+$messages["recentcomments_plugin"] = "最近回响外挂程式";
 
-$messages["recentcomments_settings_saved_ok"] = "最近回复设置储存成功。";
-$messages["recentcomments_error_maxcomments"] = "最近回复显示数量必须要大于0!";
+$messages["recentcomments_settings_saved_ok"] = "最近回响设置储存成功。";
+$messages["recentcomments_error_maxcomments"] = "最新回响显示数量必须要大于 0。";
 
 $messages["label_configuration"] = "设置";
-$messages["label_enable"] = "启用";
+$messages["label_enable"] = "启动";
 $messages["label_maxcomments"] = "显示数目";
-?>
+?>
\ No newline at end of file

Modified: plugins/branches/lifetype-1.2/recentcomments/locale/locale_zh_TW.php
===================================================================
--- plugins/branches/lifetype-1.2/recentcomments/locale/locale_zh_TW.php	2007-04-06 13:55:57 UTC (rev 5276)
+++ plugins/branches/lifetype-1.2/recentcomments/locale/locale_zh_TW.php	2007-04-06 15:15:31 UTC (rev 5277)
@@ -9,7 +9,7 @@
 $messages["recentcomments_plugin"] = "最近迴響外掛程式";
 
 $messages["recentcomments_settings_saved_ok"] = "最近迴響設定儲存成功。";
-$messages["recentcomments_error_maxcomments"] = "最新迴響顯示數量必須要 > 0!";
+$messages["recentcomments_error_maxcomments"] = "最新迴響顯示數量必須要大於 0。";
 
 $messages["label_configuration"] = "設定";
 $messages["label_enable"] = "啟動";

Modified: plugins/branches/lifetype-1.2/recentcomments/pluginrecentcomments.class.php
===================================================================
--- plugins/branches/lifetype-1.2/recentcomments/pluginrecentcomments.class.php	2007-04-06 13:55:57 UTC (rev 5276)
+++ plugins/branches/lifetype-1.2/recentcomments/pluginrecentcomments.class.php	2007-04-06 15:15:31 UTC (rev 5277)
@@ -14,7 +14,7 @@
         {
             $this->PluginBase($source);
             $this->id = "recentcomments";
-            $this->version = "20070302";
+            $this->version = "20070406";
 
             $this->author = "Mark Wu";
             $this->desc = "This plugin offers the most recently posted article comments.";
@@ -32,10 +32,8 @@
                                         "PluginRecentCommentsUpdateConfigAction" );
 			$menu =& Menu::getMenu();
 			if( !$menu->entryExists( "/menu/controlCenter/manageRecentPlugins" ))
-				$this->addMenuEntry( "/menu/controlCenter", "manageRecentPlugins",
-                                     "", "", true, false );			
-            $this->addMenuEntry( "/menu/controlCenter/manageRecentPlugins",
-                                 "RecentComments", "?op=recentcomments", "" );            
+				$this->addMenuEntry( "/menu/controlCenter", "manageRecentPlugins", "", "", true, false );			
+            $this->addMenuEntry( "/menu/controlCenter/manageRecentPlugins", "RecentComments", "?op=recentcomments", "" );            
 		}
 
         function init(){
@@ -46,7 +44,7 @@
 		{
 		    $blogSettings = $this->blogInfo->getSettings();
 		    $this->pluginEnabled = $blogSettings->getValue( "plugin_recentcomments_enabled" );
-	        $this->maxComments = $blogSettings->getValue( "plugin_recentcomments_maxcomments", 10);
+	        $this->maxComments = $blogSettings->getValue( "plugin_recentcomments_maxcomments", DEFAULT_ITEMS_PER_PAGE );
 	    }
 	    
 	    function isEnabled()
@@ -59,48 +57,21 @@
          */
         function getRecentComments()
         {
-            lt_include( PLOG_CLASS_PATH."class/dao/commentscommon.class.php" );
+            lt_include( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
 
             $blogId = $this->blogInfo->getId();
-            $commentsCommon = new CommentsCommon();
-            $prefix = Db::getPrefix();
+            $articleComments = new ArticleComments();
+            $comments = $articleComments->getBlogComments( $blogId );
 
-            $query = "SELECT c.*
-                      FROM {$prefix}articles_comments c, {$prefix}articles a
-                      WHERE c.blog_id = '".Db::qstr( $blogId )."'";
-            $query .= " AND c.article_id = a.id";
-            $query .= " AND a.status = ".POST_STATUS_PUBLISHED;
-            $query .= " AND c.status = ".COMMENT_STATUS_NONSPAM;
-            $query .= " ORDER BY c.date DESC";
-            $query .= " LIMIT ".$this->maxComments;
-
-            $db =& Db::getDb();
-            $result = $db->Execute( $query ); 
-            
-            if( !$result ){
-                return Array();
-            }
-                
-            if( $result->RowCount() == 0 ){
-                $result->Close();           
-                return Array();
-            }
-                
-            $comments = Array();
-            while( $row = $result->FetchRow()) {
-                $comments[] = $commentsCommon->mapRow( $row );
-            }
-            $result->Close();           
-
             return( $comments );
         }
 
-            /**
-             * Returns an article given an id
-             * This is needed here because we need to get various
-             * articles, not just the most recent, etc. that are generally
-             * available to the templates.
-             */
+        /**
+         * Returns an article given an id
+         * This is needed here because we need to get various
+         * articles, not just the most recent, etc. that are generally
+         * available to the templates.
+         */
         function getArticle( $artId )
         {
 			lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );				
@@ -127,7 +98,8 @@
                         Array("name" => "plugin_recentcomments_maxcomments",
                               "validator" => new IntegerValidator(),
                               "type" => "integer", "allowEmpty" => true ),
-                        ));
+                        )
+                   );
         }
         
     }

Modified: plugins/branches/lifetype-1.2/recentcomments/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/recentcomments/readme.txt	2007-04-06 13:55:57 UTC (rev 5276)
+++ plugins/branches/lifetype-1.2/recentcomments/readme.txt	2007-04-06 15:15:31 UTC (rev 5277)
@@ -1,22 +1,18 @@
 Plugin: Recent Comments
 Author: Mark Wu
-Release Date: 2005/01/23
-Version: 1.1
+Release Date: 2007/04/06
+Version: 20070406
 
 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.
+2. $recentcomments->getRecentComments() 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.
-2. $based is return the site-wide or blog-wide comments. "BLOG" means blog-wide, and "SITE" means site-wide. Default is "BLOG".
-
 Example:
-Add the following code to footer.template or header.template:
+Add the following code to your template file:
 {if $recentcomments->isEnabled()}
 <h2>Recent Comments [<a href="{$recentcomments->getRssFeedUrl()}">rss</a>]</h2>
 {assign var=comments value=$recentcomments->getRecentComments()}



More information about the pLog-svn mailing list