[pLog-svn] r3105 - plugins/trunk/recentcomments

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Fri Mar 24 02:43:06 GMT 2006


Author: jondaley
Date: 2006-03-24 02:43:05 +0000 (Fri, 24 Mar 2006)
New Revision: 3105

Modified:
   plugins/trunk/recentcomments/pluginrecentcomments.class.php
Log:
plugin is now updated for 1.1

Modified: plugins/trunk/recentcomments/pluginrecentcomments.class.php
===================================================================
--- plugins/trunk/recentcomments/pluginrecentcomments.class.php	2006-03-24 01:00:13 UTC (rev 3104)
+++ plugins/trunk/recentcomments/pluginrecentcomments.class.php	2006-03-24 02:43:05 UTC (rev 3105)
@@ -8,10 +8,9 @@
      */
     class PluginRecentComments extends PluginBase
     {
-        var $prefix;
         var $pluginEnabled;
         var $maxComments;
-            
+        
         function PluginRecentComments()
         {
             $this->PluginBase();
@@ -19,12 +18,7 @@
             $this->id = "recentcomments";
             $this->author = "Mark Wu";
             $this->desc = "This plugin offers the most recently article comments.";
-  
-			include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
-            $this->prefix = Db::getPrefix();
-            
             $this->locales = Array( "en_UK" , "zh_TW" , "zh_CN", "es_ES" );
-            
             $this->init();
         }
 
@@ -43,7 +37,7 @@
 		{
 		    $blogSettings = $this->blogInfo->getSettings();
 		    $this->pluginEnabled = $blogSettings->getValue( "plugin_recentcomments_enabled" );
-	        $this->maxComments = $blogSettings->getValue( "plugin_recentcomments_maxcomments" );
+	        $this->maxComments = $blogSettings->getValue( "plugin_recentcomments_maxcomments", 10);
 	    }
 	    
 	    function isEnabled()
@@ -54,74 +48,28 @@
         /**
          * Returns the recent comments object of current blog
          */
-        function getRecentComments($maxComments = 0, $based = 'BLOG')
+        function getRecentComments()
         {
 			include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
-		
             $comments = new ArticleComments();
+
             $blogId = $this->blogInfo->getId();
             
-            if ($based == 'BLOG') {   
-                $query = "SELECT ".$this->prefix."articles_comments.* FROM ".$this->prefix."articles_comments, ".$this->prefix."articles";
-                $query .= " WHERE ".$this->prefix."articles_comments.article_id = ".$this->prefix."articles.id AND ".$this->prefix."articles.blog_id = ".$blogId." AND ".$this->prefix."articles.status=1";
-                $query .= " AND ".$this->prefix."articles_comments.status = 0";
-                $query .= " ORDER BY ".$this->prefix."articles_comments.date DESC";
-            } elseif ($based == 'SITE') {
-                $query = "SELECT ".$this->prefix."articles_comments.* FROM ".$this->prefix."articles_comments, ".$this->prefix."articles";
-                $query .= " WHERE ".$this->prefix."articles_comments.article_id = ".$this->prefix."articles.id AND ".$this->prefix."articles.status=1";
-                $query .= " AND ".$this->prefix."articles_comments.status = 0";
-                $query .= " ORDER BY ".$this->prefix."articles_comments.date DESC";
-            } else {
-                return false;
-            }
-
-            if( $maxComments > 0 ) 
-            {
-                $query .= " LIMIT " . $maxComments; 
-            } else {
-                $query .= " LIMIT " . $this->maxComments;
-            }
-
-            $result = $comments->_db->Execute( $query ); 
-
-            if( !$result ) 
-                return false; 
-            
-            $recentcomments = Array();
-            while( $row = $result->FetchRow()) { 
-               array_push( $recentcomments, $comments->mapRow($row)); 
-            } 
-
-            return $recentcomments; 
+            return $comments->getBlogComments($blogId, COMMENT_ORDER_NEWEST_FIRST, COMMENT_STATUS_NONSPAM,
+                                              "", 1, $this->maxComments);
         }
-        
+
+            /**
+             * 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 )
         {
 			include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );				
-		
             $articles = new Articles();
-            $blogId = $this->blogInfo->getId();
-            
-            $query = "SELECT * FROM ".$this->prefix."articles WHERE id = ".$artId;
-
-               $query .= " AND blog_id = ".$blogId;
-
-            $query .= ";";
-
-            // we send the query and then fetch the first array with the result
-            $result = $articles->_db->Execute( $query );
-
-            if( $result == false )
-                return false;
-
-            if ( $result->RecordCount() == 0)
-                return false;
-
-            $row = $result->FetchRow( $result );
-
-            $article = $articles->_fillArticleInformation( $row );
-
-            return $article;
+            return $articles->getArticle($artId);
         }
     }
 ?>
\ No newline at end of file



More information about the pLog-svn mailing list