[pLog-svn] r3231 - in plog/trunk: class/summary/action class/summary/view templates/summary

mark at devel.lifetype.net mark at devel.lifetype.net
Tue Apr 11 13:00:08 GMT 2006


Author: mark
Date: 2006-04-11 13:00:08 +0000 (Tue, 11 Apr 2006)
New Revision: 3231

Modified:
   plog/trunk/class/summary/action/summaryrssaction.class.php
   plog/trunk/class/summary/view/summarybloglistview.class.php
   plog/trunk/class/summary/view/summarypostlistview.class.php
   plog/trunk/templates/summary/blogslist.template
   plog/trunk/templates/summary/postslist.template
Log:
Now the bloglist and postlist has rssfeed.

But, I just found another bug, it seems the getRecentPostsByGlobalCategory() return wrong results.

Modified: plog/trunk/class/summary/action/summaryrssaction.class.php
===================================================================
--- plog/trunk/class/summary/action/summaryrssaction.class.php	2006-04-11 12:49:34 UTC (rev 3230)
+++ plog/trunk/class/summary/action/summaryrssaction.class.php	2006-04-11 13:00:08 UTC (rev 3231)
@@ -6,14 +6,15 @@
     include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
 	include_once( PLOG_CLASS_PATH."class/summary/view/summaryrssview.class.php" );
 	include_once( PLOG_CLASS_PATH."class/net/rawrequestgenerator.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 
+    include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
 	
 	define( "SUMMARY_RSS_TYPE_DEFAULT", "default" );
 	define( "SUMMARY_RSS_TYPE_MOST_COMMENTED", "mostcommented" );
 	define( "SUMMARY_RSS_TYPE_MOST_READ", "mostread" );
 	define( "SUMMARY_RSS_TYPE_MOST_ACTIVE_BLOGS", "mostactiveblogs" );
 	define( "SUMMARY_RSS_TYPE_NEWEST_BLOGS", "newestblogs" );
+	define( "SUMMARY_RSS_TYPE_POSTS_LIST", "postslist" );
+	define( "SUMMARY_RSS_TYPE_BLOGS_LIST", "blogslist" );	
 
      /**
       * This is the one and only default action. It simply fetches all the most recent
@@ -37,7 +38,9 @@
 			    $this->_mode != SUMMARY_RSS_TYPE_MOST_COMMENTED &&
 				$this->_mode != SUMMARY_RSS_TYPE_MOST_READ &&
 				$this->_mode != SUMMARY_RSS_TYPE_MOST_ACTIVE_BLOGS &&
-				$this->_mode != SUMMARY_RSS_TYPE_NEWEST_BLOGS ) {
+				$this->_mode != SUMMARY_RSS_TYPE_NEWEST_BLOGS &&
+				$this->_mode != SUMMARY_RSS_TYPE_POSTS_LIST &&
+				$this->_mode != SUMMARY_RSS_TYPE_BLOGS_LIST ) {
 				
 				// in case the parameter looks weird, let's use a default one...
 				$this->_mode = SUMMARY_RSS_TYPE_DEFAULT;
@@ -55,9 +58,10 @@
         {
             if( $this->_mode == SUMMARY_RSS_TYPE_MOST_COMMENTED ||
                 $this->_mode == SUMMARY_RSS_TYPE_MOST_READ ||
-                $this->_mode == SUMMARY_RSS_TYPE_DEFAULT ) {	                
+                $this->_mode == SUMMARY_RSS_TYPE_DEFAULT ||
+                $this->_mode == SUMMARY_RSS_TYPE_POSTS_LIST ) {	                
 	                
-            	// get the blogCategoryId from request
+            	// get the globalArticleCategoryId from request
 				$globalArticleCategoryId = $this->_request->getValue( "globalArticleCategoryId" );
 				$val = new IntegerValidator();
 				if( !$val->validate( $globalArticleCategoryId ))
@@ -76,32 +80,59 @@
             	$stats       = new SummaryStats();
 	                
 				if( $this->_mode == SUMMARY_RSS_TYPE_MOST_COMMENTED ) {
-					$posts = $stats->getMostCommentedArticles();
+					$postslist = $stats->getMostCommentedArticles();
 				}
 				elseif( $this->_mode == SUMMARY_RSS_TYPE_MOST_READ ) {
-					$posts = $stats->getMostReadArticles();			
+					$postslist = $stats->getMostReadArticles();			
 				}
+				elseif( $this->_mode == SUMMARY_RSS_TYPE_POSTS_LIST ) {
+     				include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+            		include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+            		
+            		// get the summary_blogs_per_page from config
+            		$config =& Config::getConfig();
+            		$summaryItemsPerPage = $config->getValue( "summary_blogs_per_page", SUMMARY_DEFAULT_ITEMS_PER_PAGE );
+					
+					$categories = new GlobalArticleCategories();
+					$currentGlobalArticleCategory = $categories->getGlobalArticleCategory( $globalArticleCategoryId );
+					
+					if( empty($currentGlobalArticleCategory) )
+						$globalArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES;
+						
+					$postslist = $stats->getRecentPostsByGlobalCategory( $globalArticleCategoryId,
+        										 					 $page = 1, 
+        										 					 $summaryItemsPerPage );
+				}				
 				else {
+					include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
 					$categories = new GlobalArticleCategories();
 					$currentGlobalArticleCategory = $categories->getGlobalArticleCategory( $globalArticleCategoryId );
 					
 					if( empty($currentGlobalArticleCategory) )
 						$globalArticleCategoryId = ALL_GLOBAL_ARTICLE_CATEGORIES;
 					
-					$posts = $stats->getRecentArticles( $globalArticleCategoryId );
+					$postslist = $stats->getRecentArticles( $globalArticleCategoryId );
 				}
 	
-	            if( !$posts ) {
-					$posts = Array();
+	            if( !$postslist ) {
+					$postslist = Array();
 	            }
 	
-				$this->_view->setValue( "posts", $posts );
+				$this->_view->setValue( "posts", $postslist );
 			}
 			elseif( $this->_mode == SUMMARY_RSS_TYPE_MOST_ACTIVE_BLOGS ||
-			        $this->_mode == SUMMARY_RSS_TYPE_NEWEST_BLOGS ) {
+			        $this->_mode == SUMMARY_RSS_TYPE_NEWEST_BLOGS ||
+			        $this->_mode == SUMMARY_RSS_TYPE_BLOGS_LIST ) {
+				
+            	// get the globalArticleCategoryId from request
+				$blogCategoryId = $this->_request->getValue( "blogCategoryId" );
+				$val = new IntegerValidator();
+				if( !$val->validate( $blogCategoryId ))
+					$blogCategoryId = ALL_BLOG_CATEGORIES;
+
 				// RSS feeds for blogs, need different template sets...
-				
-	            $this->_view = new SummaryRssView( "blogs_".$this->_profile, Array( "summary" => "rss", 
+	            $this->_view = new SummaryRssView( "blogs_".$this->_profile, Array( "summary" => "rss",
+	            								   "blogCategoryId" => $blogCategoryId, 
 			                                       "mode" => $this->_mode,
 												   "profile" => $this->_profile ));
 				if( $this->_view->isCached()) {
@@ -109,25 +140,46 @@
 				}
 				
 				// load the stuff
+				$blogs = new Blogs();
 				$stats = new SummaryStats();
 				
 				if( $this->_mode == SUMMARY_RSS_TYPE_MOST_ACTIVE_BLOGS ) {
-					$blogs = $stats->getMostActiveBlogs();	
+					$blogslist = $stats->getMostActiveBlogs();	
 				}
+				elseif( $this->_mode == SUMMARY_RSS_TYPE_BLOGS_LIST ) {
+     				include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
+            		include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+            		
+            		// get the summary_blogs_per_page from config
+            		$config =& Config::getConfig();
+            		$summaryItemsPerPage = $config->getValue( "summary_blogs_per_page", SUMMARY_DEFAULT_ITEMS_PER_PAGE );
+					
+					$categories = new BlogCategories();
+					$currentBlogCategory = $categories->getBlogCategory( $blogCategoryId );
+					
+					if( empty($currentBlogCategory) )
+						$blogCategoryId = ALL_BLOG_CATEGORIES;
+						
+					$blogslist = $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, 
+													  $blogCategoryId, 
+													  "", 
+													  1, 
+													  $summaryItemsPerPage );
+				}
 				else {
-					$blogs = $stats->getRecentBlogs();
+					$blogslist = $stats->getRecentBlogs();
 				}
 				
 				// in case there is really no data to fetch...
-				if( !$blogs )
-					$blogs = Array();
+				if( !$blogslist )
+					$blogslist = Array();
 					
 				// this 'url' object is just a dummy one... But we cannot get it from the list
 				// of blogs that we fetched because it could potentially be null! Besides, we only
 				// need it to generate the base url to rss.css and to summary.php, so no need to
 				// have a fully-featured object
 				$this->_view->setValue( "url", new RawRequestGenerator( null ));
-				$this->_view->setValue( "blogs", $blogs );								
+				$this->_view->setValue( "blogs", $blogslist );								
 			}
 			
 			$this->_view->setValue( "type", $this->_mode );

Modified: plog/trunk/class/summary/view/summarybloglistview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarybloglistview.class.php	2006-04-11 12:49:34 UTC (rev 3230)
+++ plog/trunk/class/summary/view/summarybloglistview.class.php	2006-04-11 13:00:08 UTC (rev 3231)
@@ -84,6 +84,11 @@
 			$this->setValue( "currentBlogCategory", $currentBlogCategory);
 			$this->setValue( "min", $min );
 			$this->setValue( "step", $step );
+
+			// we just need a random blog so... we'll get one :)
+			$randomBlog = array_pop( $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, ALL_BLOG_CATEGORIES, "", 1, 1) );
+			$url = $randomBlog->getBlogRequestGenerator();
+			$this->setValue( "url", $url );			
 		
 			// let the parent view do its job
 			parent::render();

Modified: plog/trunk/class/summary/view/summarypostlistview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarypostlistview.class.php	2006-04-11 12:49:34 UTC (rev 3230)
+++ plog/trunk/class/summary/view/summarypostlistview.class.php	2006-04-11 13:00:08 UTC (rev 3231)
@@ -87,6 +87,13 @@
 			$this->setValue( "min", $min );
 			$this->setValue( "step", $step );
 					
+			// we just need a random blog so... we'll get one :)
+			include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+			$blogs = new Blogs();
+			$randomBlog = array_pop( $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, ALL_BLOG_CATEGORIES, "", 1, 1) );
+			$url = $randomBlog->getBlogRequestGenerator();
+			$this->setValue( "url", $url );
+			
 			// let the parent view do its job
 			parent::render();
 		}

Modified: plog/trunk/templates/summary/blogslist.template
===================================================================
--- plog/trunk/templates/summary/blogslist.template	2006-04-11 12:49:34 UTC (rev 3230)
+++ plog/trunk/templates/summary/blogslist.template	2006-04-11 13:00:08 UTC (rev 3231)
@@ -8,9 +8,21 @@
 	{/foreach}
     </div>
     {if empty($currentBlogCategory)}
-    	<h4>{$locale->tr("all")}</h4>
+      <h4>{$locale->tr("all")}
+		{if $blogs}
+		  <a href="{$url->getRssUrl()}?summary=1&amp;type=blogslist">
+			<img src="{$url->getUrl("/imgs/rss_logo_small.gif")}" alt="RSS" />
+		  </a>
+		{/if}
+      </h4>
     {else}
-    	<h4>{$currentBlogCategory->getName()} ({$currentBlogCategory->getNumBlogs()})</h4>
+      <h4>{$currentBlogCategory->getName()} ({$currentBlogCategory->getNumBlogs()})
+		{if $blogs}
+	      <a href="{$url->getRssUrl()}?summary=1&amp;type=blogslist&amp;blogCategoryId={$currentBlogCategory->getId()}">
+		    <img src="{$url->getUrl("/imgs/rss_logo_small.gif")}" alt="RSS" />
+		  </a>
+		{/if}
+      </h4>
     {/if}
     {foreach from=$blogs item=blog}
         {assign var="updateDate" value=$blog->getUpdateDateObject()}

Modified: plog/trunk/templates/summary/postslist.template
===================================================================
--- plog/trunk/templates/summary/postslist.template	2006-04-11 12:49:34 UTC (rev 3230)
+++ plog/trunk/templates/summary/postslist.template	2006-04-11 13:00:08 UTC (rev 3231)
@@ -8,9 +8,21 @@
 	{/foreach}
     </div>
     {if empty($currentGlobalArticleCategory)}
-    	<h4>{$locale->tr("all")}</h4>
+   	  <h4>{$locale->tr("all")}
+		{if $recentPosts}
+		  <a href="{$url->getRssUrl()}?summary=1&amp;type=postslist">
+			<img src="{$url->getUrl("/imgs/rss_logo_small.gif")}" alt="RSS" />
+		  </a>
+		{/if}
+      </h4>
     {else}
-    	<h4>{$currentGlobalArticleCategory->getName()} ({$numRecentPosts})</h4>
+      <h4>{$currentGlobalArticleCategory->getName()} ({$numRecentPosts})
+		{if $recentPosts}
+	      <a href="{$url->getRssUrl()}?summary=1&amp;type=postslist&amp;globalArticleCategoryId={$currentGlobalArticleCategory->getId()}">
+		    <img src="{$url->getUrl("/imgs/rss_logo_small.gif")}" alt="RSS" />
+		  </a>
+		{/if}
+      </h4>
     {/if}
 	{foreach from=$recentPosts item=post}
 	 {include file="summary/post.template"}



More information about the pLog-svn mailing list