[pLog-svn] r2639 - in plog/trunk/class: dao summary/action summary/dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sat Nov 26 16:43:01 GMT 2005


Author: oscar
Date: 2005-11-26 16:43:01 +0000 (Sat, 26 Nov 2005)
New Revision: 2639

Modified:
   plog/trunk/class/dao/article.class.php
   plog/trunk/class/dao/articles.class.php
   plog/trunk/class/summary/action/dofinishregister.class.php
   plog/trunk/class/summary/dao/summarystats.class.php
Log:
Added a new field to the plog_articles table: 'in_summary_page', which will be used to determine which posts should appear in the front page (summary.php) and which shouldn't. Only the "welcome" sort of posts created by summary.php will be marked to have this attribute as 'false', but it could potentially be offered as an extra checkbox in the "new post" page for all those who don't want their posts to appear in the summary page too.

This helps of course to speed up certain queries in the summary page (more to come about that soon)

Modified: plog/trunk/class/dao/article.class.php
===================================================================
--- plog/trunk/class/dao/article.class.php	2005-11-26 16:40:58 UTC (rev 2638)
+++ plog/trunk/class/dao/article.class.php	2005-11-26 16:43:01 UTC (rev 2639)
@@ -47,6 +47,7 @@
 		var $_nextArticle;
 		var $_prevArticle;
 		var $_globalCategory;
+		var $_inSummary;
 
         /**
          * Constructor.
@@ -101,6 +102,7 @@
 			$this->_userInfo = null;
 			$this->_blogInfo = null;
 			$this->_globalCategoryId = 0;
+			$this->_inSummary = true;
 
 			$this->_pk = "id";
 			$this->_fields = Array(
@@ -116,7 +118,8 @@
 			    "num_trackbacks" => "getTotalTrackbacks",
 			    "num_nonspam_trackbacks" => "getNumTrackbacks",
 			    "num_nonspam_comments" => "getNumComments",
-			    "global_category_id" => "getGlobalCategoryId"
+			    "global_category_id" => "getGlobalCategoryId",
+				"in_summary_page" => "getInSummary"
 			);		
 		}
 
@@ -1055,5 +1058,25 @@
 			$this->_customFields = null;
 			return( parent::__sleep());
 		}
+		
+		/**
+		 * Returns whether this article should appear in the front summary.php page or not
+		 *
+		 * @return boolean value
+		 */
+		function getInSummary()
+		{
+			return( $this->_inSummary );
+		}
+		
+		/**
+		 * Whether to make this post appear in the front summary.php page
+		 *
+		 * @param inSummary
+		 */
+		function setInSummary( $inSummary )
+		{
+			$this->_inSummary = $inSummary;
+		}
 	}
 ?>
\ No newline at end of file

Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php	2005-11-26 16:40:58 UTC (rev 2638)
+++ plog/trunk/class/dao/articles.class.php	2005-11-26 16:43:01 UTC (rev 2639)
@@ -1028,6 +1028,9 @@
 			
 			// global article category
 			$article->setGlobalCategoryId( $query_result['global_category_id'] );
+			
+			// shown in summary or not
+			$article->setInSummary( $query_result['in_summary_page'] );
 
             return $article;
 

Modified: plog/trunk/class/summary/action/dofinishregister.class.php
===================================================================
--- plog/trunk/class/summary/action/dofinishregister.class.php	2005-11-26 16:40:58 UTC (rev 2638)
+++ plog/trunk/class/summary/action/dofinishregister.class.php	2005-11-26 16:43:01 UTC (rev 2639)
@@ -140,6 +140,7 @@
             $article = new Article( $articleTopic, $articleText, Array( $catId ), $userId, $newblogId, POST_STATUS_PUBLISHED, 0, Array(), "welcome" );
             $article->setDateObject( new Timestamp());  // set it to the current date
             $article->setCommentsEnabled( true ); // enable comments
+			$article->setInSummary( false );	// no need to see these in the summary!
             $articles = new Articles();
             $articles->addArticle( $article );
 

Modified: plog/trunk/class/summary/dao/summarystats.class.php
===================================================================
--- plog/trunk/class/summary/dao/summarystats.class.php	2005-11-26 16:40:58 UTC (rev 2638)
+++ plog/trunk/class/summary/dao/summarystats.class.php	2005-11-26 16:43:01 UTC (rev 2639)
@@ -63,7 +63,8 @@
        				         AND c.status = ".COMMENT_STATUS_NONSPAM."
        				         AND b.id = a.blog_id
        				         AND b.status = ".BLOG_STATUS_ACTIVE."
-       				         AND a.date <= ".$this->_now;
+       				         AND a.date <= ".$this->_now."
+							 AND in_summmary_page = '1'";
 
 			$query .= " GROUP BY c.article_id ORDER BY total_comments DESC ";
 
@@ -113,7 +114,8 @@
                  FROM {$prefix}articles a, {$prefix}blogs b
                  WHERE a.status = ".POST_STATUS_PUBLISHED."
                  AND a.blog_id = b.id AND b.status = ".BLOG_STATUS_ACTIVE."
-                 AND a.date <= ".$this->_now." AND a.date > ".$this->_sevenDaysAgo;
+                 AND a.date <= ".$this->_now." AND a.date > ".$this->_sevenDaysAgo."
+				 AND in_summary_page = '1'";
 
 			$query .= " ORDER BY a.num_reads DESC ";
 
@@ -187,6 +189,7 @@
                        INNER JOIN {$prefix}blogs AS b 
                            ON b.id=a.blog_id AND b.status=".BLOG_STATUS_ACTIVE.
                        " WHERE a.date >= ".$this->_sevenDaysAgo." AND a.date <= ".$this->_now." 
+					   AND in_summary_page = '1' 
                        GROUP BY a.blog_id ORDER BY rank DESC ";
 
             if( $maxBlogs > 0 )
@@ -237,7 +240,8 @@
 					  WHERE a.date >= ".$this->_sevenDaysAgo." AND a.date <= ".$this->_now."
 					        AND a.blog_id = b.id
 					        AND b.status = ".BLOG_STATUS_ACTIVE."
-					        AND a.status = ".POST_STATUS_PUBLISHED;
+					        AND a.status = ".POST_STATUS_PUBLISHED."
+							AND in_summary_page = '1'";
 
 			$query .= " GROUP BY a.id ORDER BY a.date DESC LIMIT 0, $maxPosts";
             $result = $this->Execute( $query );




More information about the pLog-svn mailing list