[pLog-svn] r4075 - in plog/trunk: class/action class/view class/view/admin locale templates/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Oct 1 21:58:21 GMT 2006


Author: oscar
Date: 2006-10-01 21:58:21 +0000 (Sun, 01 Oct 2006)
New Revision: 4075

Modified:
   plog/trunk/class/action/blogaction.class.php
   plog/trunk/class/action/defaultaction.class.php
   plog/trunk/class/action/rssaction.class.php
   plog/trunk/class/action/searchaction.class.php
   plog/trunk/class/view/admin/adminpostslistview.class.php
   plog/trunk/class/view/blogview.class.php
   plog/trunk/locale/locale_en_UK.php
   plog/trunk/templates/admin/globalsettings_general.template
Log:
implemented feature request http://bugs.lifetype.net/view.php?id=1055, adding two parameters to act as 'hard' limits for 'show_posts_max' and 'recent_posts_max' so that administrators can set an upper limit for these values (some users like to set these to something like 300, killing server performance every time their pages are reloaded)


Modified: plog/trunk/class/action/blogaction.class.php
===================================================================
--- plog/trunk/class/action/blogaction.class.php	2006-10-01 21:55:56 UTC (rev 4074)
+++ plog/trunk/class/action/blogaction.class.php	2006-10-01 21:58:21 UTC (rev 4075)
@@ -368,6 +368,6 @@
 					$page = 1;	
 
 				return $page;	    
-	    }		
+	    }	
     }
 ?>
\ No newline at end of file

Modified: plog/trunk/class/action/defaultaction.class.php
===================================================================
--- plog/trunk/class/action/defaultaction.class.php	2006-10-01 21:55:56 UTC (rev 4074)
+++ plog/trunk/class/action/defaultaction.class.php	2006-10-01 21:58:21 UTC (rev 4075)
@@ -95,6 +95,7 @@
             require_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
             require_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
 			require_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+			include_once( PLOG_CLASS_PATH."class/config/siteconfig.class.php" );			
 
             // if we got a category name instead of a category id, then we
             // should first look up this category in the database and see if
@@ -177,7 +178,10 @@
        		}
 			       		
        		// get the articles...
-            $this->_postAmount = $blogSettings->getValue( 'show_posts_max' );			
+			$hardLimit = SiteConfig::getHardShowPostsMax();
+			$this->_postAmount = $blogSettings->getValue( "show_posts_max" );			
+			if( $this->_postAmount > $hardLimit ) $this->_postAmount = $hardLimit;
+
 			$articles = new Articles();
 			$blogArticles = $articles->getBlogArticles( 
 			                        $blogId, 

Modified: plog/trunk/class/action/rssaction.class.php
===================================================================
--- plog/trunk/class/action/rssaction.class.php	2006-10-01 21:55:56 UTC (rev 4074)
+++ plog/trunk/class/action/rssaction.class.php	2006-10-01 21:58:21 UTC (rev 4075)
@@ -5,6 +5,7 @@
     include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
 
+
     /**
      * \ingroup Action
      * @private
@@ -82,6 +83,7 @@
     		include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
     		include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );			
     		include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+			include_once( PLOG_CLASS_PATH."class/config/siteconfig.class.php" );
     		
         	$articles = new Articles();    		
 
@@ -89,7 +91,11 @@
             $locale = Locales::getLocale( $localeCode );
 
             // fetch the posts, though we are going to fetch the same amount in both branches
-			$amount = $blogSettings->getValue( "recent_posts_max", 15 );            
+
+			$hardLimit = SiteConfig::getHardRecentPostsMax();
+			$amount = $blogSettings->getValue( "recent_posts_max", 15 );			
+			if( $amount > $hardLimit ) $amount = $hardLimit;
+
 			$t = new Timestamp();
 			if( $blogSettings->getValue( 'show_future_posts_in_calendar' )) {
 				$blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(), -1, $amount, 

Modified: plog/trunk/class/action/searchaction.class.php
===================================================================
--- plog/trunk/class/action/searchaction.class.php	2006-10-01 21:55:56 UTC (rev 4074)
+++ plog/trunk/class/action/searchaction.class.php	2006-10-01 21:58:21 UTC (rev 4075)
@@ -50,7 +50,7 @@
 			
 			// calculate how many results per page
 			$blogSettings = $this->_blogInfo->getSettings();
-            $itemsPerPage = $blogSettings->getValue( 'show_posts_max' );
+            $itemsPerPage = $this->_getNumPostsPerPage();
 			
 			// get the array with the results
             $searchEngine = new SearchEngine();

Modified: plog/trunk/class/view/admin/adminpostslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminpostslistview.class.php	2006-10-01 21:55:56 UTC (rev 4074)
+++ plog/trunk/class/view/admin/adminpostslistview.class.php	2006-10-01 21:58:21 UTC (rev 4075)
@@ -8,6 +8,7 @@
     include_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
     include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
     include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );    
+    include_once( PLOG_CLASS_PATH."class/config/siteconfig.class.php" );
 	
     /**
      * \ingroup View
@@ -36,8 +37,12 @@
 			$this->_setViewParameters( $params );
 			
 			$this->_page = $this->getCurrentPageFromRequest();		
+
 			$blogSettings = $blogInfo->getSettings();
+
 			$this->_itemsPerPage = $blogSettings->getValue( "show_posts_max" );
+			if( $this->_itemsPerPage > SiteConfig::getHardShowPostsMax()) 
+				$this->_itemsPerPage = SiteConfig::getHardShowPostsMax();
 		}
 		
 		

Modified: plog/trunk/class/view/blogview.class.php
===================================================================
--- plog/trunk/class/view/blogview.class.php	2006-10-01 21:55:56 UTC (rev 4074)
+++ plog/trunk/class/view/blogview.class.php	2006-10-01 21:58:21 UTC (rev 4075)
@@ -119,11 +119,16 @@
         function _getRecentPosts()
         {
             include_once( PLOG_CLASS_PATH.'class/dao/recentarticles.class.php' );
+			include_once( PLOG_CLASS_PATH."class/config/siteconfig.class.php" );
 
             $blogSettings = $this->_blogInfo->getSettings();
+
+			$hardLimit = SiteConfig::getHardRecentPostsMax();
+			$amount = $blogSettings->getValue( "recent_posts_max", 15 );	
+			if( $amount > $hardLimit ) $amount = $hardLimit;
+
 			$recent = new RecentArticles();
-			$recentPosts = $recent->getRecentArticles( $this->_blogInfo->getId(),
-			                                           $blogSettings->getValue( 'recent_posts_max' ));
+			$recentPosts = $recent->getRecentArticles( $this->_blogInfo->getId(), $amount );
         	$this->_pm->notifyEvent( EVENT_POSTS_LOADED, Array( 'articles' => &$recentPosts ));        	
         	
         	return $recentPosts;

Modified: plog/trunk/locale/locale_en_UK.php
===================================================================
--- plog/trunk/locale/locale_en_UK.php	2006-10-01 21:55:56 UTC (rev 4074)
+++ plog/trunk/locale/locale_en_UK.php	2006-10-01 21:58:21 UTC (rev 4075)
@@ -1103,4 +1103,7 @@
 $messages['permission_deleted_ok'] = 'Permission "%s" was deleted successfully';
 $messages['permissions_deleted_ok'] = '%s permissions successfully deleted';
 $messages['error_deleting_permission2'] = 'There was an error deleting permission with identifier "%s"';
+
+$messages['help_hard_show_posts_max'] = 'Maximum upper limit for articles shown in blog pages. If users set a custom value over this limit, it will be ignored and the value speciefied here will be used. [ Default = 50 ]';
+$messages['help_hard_recent_posts_max'] = 'Maximum upper limit for recent articles shown in blog pages. If users set a custom value over this limit, it will be ignored and the value specified here will be used [ Default = 25 ]';
 ?>
\ No newline at end of file

Modified: plog/trunk/templates/admin/globalsettings_general.template
===================================================================
--- plog/trunk/templates/admin/globalsettings_general.template	2006-10-01 21:55:56 UTC (rev 4074)
+++ plog/trunk/templates/admin/globalsettings_general.template	2006-10-01 21:58:21 UTC (rev 4075)
@@ -18,7 +18,7 @@
     <label for="config[temp_folder]">temp_folder</label>
     <div class="formHelp">{$locale->tr("help_temp_folder")}</div>	 
     <input style="width:100%" type="text" name="config[temp_folder]" value="{$temp_folder}"/>
-   </div>
+   </div>s
    <!-- base_url -->
    <div class="field">
     <label for="config[base_url"]>base_url</label>
@@ -63,12 +63,24 @@
     <div class="formHelp">{$locale->tr("help_show_posts_max")}</div>
     <input style="width:100%" type="text" name="config[show_posts_max]" value="{$show_posts_max}"/>
    </div>
+   <!-- hard_show_posts_max -->
+   <div class="field">
+    <label for="config[hard_show_posts_max]">hard_show_posts_max</label>
+    <div class="formHelp">{$locale->tr("help_hard_show_posts_max")}</div>
+    <input style="width:100%" type="text" name="config[hard_show_posts_max]" value="{$hard_show_posts_max}"/>
+   </div>
    <!-- recent_posts_max -->
    <div class="field">
     <label for="config[recent_posts_max]">recent_posts_max</label>
     <div class="formHelp">{$locale->tr("help_recent_posts_max")}</div>
     <input style="width:100%" type="text" name="config[recent_posts_max]" value="{$recent_posts_max}"/>
    </div>
+   <!-- hard_recent_posts_max -->
+   <div class="field">
+    <label for="config[hard_recent_posts_max]">hard_recent_posts_max</label>
+    <div class="formHelp">{$locale->tr("help_hard_recent_posts_max")}</div>
+    <input style="width:100%" type="text" name="config[hard_recent_posts_max]" value="{$hard_recent_posts_max}"/>
+   </div>
    <!-- save_drafts_via_xmlhttprequest_enabled -->
    <div class="field">
     <label for="config[save_drafts_via_xmlhttprequest_enabled]">save_drafts_via_xmlhttprequest_enabled</label>



More information about the pLog-svn mailing list