[pLog-svn] r4351 - in plog/trunk: class/action class/action/admin class/config class/dao class/view/admin templates/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Mon Nov 27 20:41:39 GMT 2006


Author: oscar
Date: 2006-11-27 20:41:37 +0000 (Mon, 27 Nov 2006)
New Revision: 4351

Modified:
   plog/trunk/class/action/admin/adminupdateblogsettingsaction.class.php
   plog/trunk/class/action/viewarticleaction.class.php
   plog/trunk/class/config/siteconfig.class.php
   plog/trunk/class/dao/blogsettings.class.php
   plog/trunk/class/view/admin/adminblogsettingsview.class.php
   plog/trunk/templates/admin/blogsettings.template
   plog/trunk/templates/admin/globalsettings_general.template
Log:
added support for configuring how many posts per page should be shown and the hard limits for these settings


Modified: plog/trunk/class/action/admin/adminupdateblogsettingsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateblogsettingsaction.class.php	2006-11-27 19:20:13 UTC (rev 4350)
+++ plog/trunk/class/action/admin/adminupdateblogsettingsaction.class.php	2006-11-27 20:41:37 UTC (rev 4351)
@@ -37,6 +37,7 @@
 			$this->registerFieldValidator( "blogLocale", new StringValidator());
 			$this->registerFieldValidator( "blogTemplate", new StringValidator());
 			$this->registerFieldValidator( "blogCategory", new IntegerValidator());
+			$this->registerFieldValidator( "blogNumCommentsPerPage", $val );
 			$this->registerField( "blogAbout" );
 			$this->registerField( "blogShowMoreEnabled" );
 			$this->registerField( "blogEnableHtmlarea" );
@@ -51,7 +52,8 @@
 			$this->registerField( "blogLinkCategoriesOrder" );
 			$this->registerField( "blogEnableAutosaveDrafts" );
 			$this->registerField( "blogShowInSummary" );
-			$this->registerField( "blogSendNotification" );			
+			$this->registerField( "blogSendNotification" );
+			$this->registerField( "blogCommentOnlyRegisteredUsers" );
 			if( Subdomains::getSubdomainsEnabled()) {
 				$this->registerFieldValidator( "blogSubDomain", new DomainValidator());
 				$this->registerFieldValidator( "blogMainDomain", new DomainValidator());			
@@ -87,6 +89,8 @@
            	$blogSettings->setValue( "show_future_posts_in_calendar",  Textfilter::checkboxToBoolean($this->_request->getValue( "blogShowFuturePosts" )));
            	$blogSettings->setValue( "first_day_of_week",  $this->_request->getValue( "blogFirstDayOfWeek" ));
            	$blogSettings->setValue( "new_drafts_autosave_enabled", Textfilter::checkboxToBoolean($this->_request->getValue( "blogEnableAutosaveDrafts" )));
+           	$blogSettings->setValue( "show_comments_max", $this->_request->getValue( "blogNumCommentsPerPage" ));
+			$blogSettings->setValue( "comment_only_auth_users", Textfilter::checkboxToBoolean($this->_request->getValue( "blogCommentOnlyRegisteredUsers" )));
             $blogSettings->setValue( "comments_order", $this->_request->getValue( "blogCommentsOrder" ));
             $blogSettings->setValue( "default_send_notification", $this->_request->getValue( "blogSendNotification" ));
             $this->_blogInfo->setAbout( Textfilter::filterAllHTML($this->_request->getValue( "blogAbout" )));

Modified: plog/trunk/class/action/viewarticleaction.class.php
===================================================================
--- plog/trunk/class/action/viewarticleaction.class.php	2006-11-27 19:20:13 UTC (rev 4350)
+++ plog/trunk/class/action/viewarticleaction.class.php	2006-11-27 20:41:37 UTC (rev 4351)
@@ -4,8 +4,9 @@
 	lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
 	lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );	
     lt_include( PLOG_CLASS_PATH."class/view/errorview.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/config/siteconfig.class.php" );
 
-	define( "DEFAULT_SHOW_COMMENTS_MAX", 10 );
+	define( "DEFAULT_SHOW_COMMENTS_MAX", 20 );
 
     /**
      * \ingroup Action
@@ -237,8 +238,12 @@
             // if everything's fine, we set up the article object for the view
             $this->_view->setArticle( $article );
 			// and the comments
-			$blogSettings = $this->_blogInfo->getSettings();
-			$commentsPerPage = $blogSettings->getValue( "show_comments_max", DEFAULT_SHOW_COMMENTS_MAX );
+			$blogSettings = $this->_blogInfo->getSettings();			
+			$hardLimit = SiteConfig::getHardShowCommentsMax();
+			print("hard limit = $hardLimit<br/>");
+			$commentsPerPage = $blogSettings->getValue( "show_comments_max", DEFAULT_SHOW_COMMENTS_MAX );	
+			if( $commentsPerPage > $hardLimit ) $commentsPerPage = $hardLimit;						
+
 			$comments = new ArticleComments();
 			$postComments = $comments->getPostComments( $article->getId(), 
 			                                            $order = COMMENT_ORDER_NEWEST_FIRST, 

Modified: plog/trunk/class/config/siteconfig.class.php
===================================================================
--- plog/trunk/class/config/siteconfig.class.php	2006-11-27 19:20:13 UTC (rev 4350)
+++ plog/trunk/class/config/siteconfig.class.php	2006-11-27 20:41:37 UTC (rev 4351)
@@ -8,6 +8,7 @@
 	define( "DEFAULT_TMP_FOLDER", "./tmp" );	
 	define( "DEFAULT_HARD_SHOW_POSTS_MAX", 50 );	
 	define( "DEFAULT_HARD_RECENT_POSTS_MAX", 25 );	
+	define( "DEFAULT_HARD_SHOW_COMMENTS_MAX", 20 );		
 
 	class SiteConfig extends Config
 	{
@@ -44,6 +45,16 @@
 			return( SiteConfig::_getConfigValueWithDefault( "hard_recent_posts_max", DEFAULT_HARD_RECENT_POSTS_MAX ));
 		}
 		
+		/** 
+		 * @static
+		 * Returns the maximum value for the hard_recent_posts_max key
+		 */		
+		function getHardShowCommentsMax()
+		{
+			print("here?");
+			return( SiteConfig::_getConfigValueWithDefault( "hard_show_comments_max", DEFAULT_HARD_SHOW_COMMENTS_MAX ));
+		}		
+		
 		/**
 		 * @static
 		 * @see Config

Modified: plog/trunk/class/dao/blogsettings.class.php
===================================================================
--- plog/trunk/class/dao/blogsettings.class.php	2006-11-27 19:20:13 UTC (rev 4350)
+++ plog/trunk/class/dao/blogsettings.class.php	2006-11-27 20:41:37 UTC (rev 4351)
@@ -37,6 +37,7 @@
 			$this->setValue( "template", $config->getValue("default_template"));
 			$this->setValue( "show_more_enabled", $config->getValue( "show_more_enabled"));
             $this->setValue( "recent_posts_max", $config->getValue( "recent_posts_max" ));
+            $this->setValue( "show_comments_max", $config->getValue( "show_comments_max" ));
             $this->setValue( "xmlrpc_ping_hosts", $config->getValue( "xmlrpc_ping_hosts" ));
             $this->setValue( "htmlarea_enabled", $config->getValue( "htmlarea_enabled" ));
 			$this->setValue( "pull_down_menu_enabled", $config->getValue("pull_down_menu_enabled"));

Modified: plog/trunk/class/view/admin/adminblogsettingsview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminblogsettingsview.class.php	2006-11-27 19:20:13 UTC (rev 4350)
+++ plog/trunk/class/view/admin/adminblogsettingsview.class.php	2006-11-27 20:41:37 UTC (rev 4351)
@@ -43,6 +43,8 @@
 			$this->setValue( "blogCategory", $this->_blogInfo->getBlogCategoryId());
 			$this->setValue( "blogShowInSummary", $this->_blogInfo->getShowInSummary());
 			$this->setValue( "blogSendNotification", $blogSettings->getValue( "default_send_notification" ));
+			$this->setValue( "blogCommentOnlyRegisteredUsers", $blogSettings->getValue( "comment_only_auth_users" ));
+			$this->setValue( "blogNumCommentsPerPage", $blogSettings->getValue( "show_comments_max" ));
 			
             // only do blog_domain stuff if subdomains are enabled
             // Don't waste time here, as well as be less confusing by

Modified: plog/trunk/templates/admin/blogsettings.template
===================================================================
--- plog/trunk/templates/admin/blogsettings.template	2006-11-27 19:20:13 UTC (rev 4350)
+++ plog/trunk/templates/admin/blogsettings.template	2006-11-27 20:41:37 UTC (rev 4351)
@@ -139,7 +139,25 @@
       </div>  
      </div>
 
+	 <!-- only authenaticated users can comment -->
      <div class="field">
+      <label for="blogCommentOnlyRegisteredUsers">{$locale->tr("comment_only_auth_users")}</label>
+      <div class="formHelp">
+	    <input class="checkbox" type="checkbox" name="blogCommentOnlyRegisteredUsers" id="blogCommentOnlyRegisteredUsers" value="1" {if $blogCommentOnlyRegisteredUsers == true} checked="checked" {/if} />
+	    {$locale->tr("comment_only_auth_users_help")}
+      </div>  
+     </div>
+
+     <!-- paged comments -->
+    <div class="field">
+     <label for="blogNumCommentsPerPage">{$locale->tr("show_comments_max")}</label>
+     <span class="required"></span>
+     <div class="formHelp">{$locale->tr("show_comments_max_help")}</div>
+     <input type="text" name="blogNumCommentsPerPage" id="blogNumCommentsPerPage" value="{$blogNumCommentsPerPage}" />
+     {include file="$admintemplatepath/validate.template" field=blogNumCommentsPerPage message=$locale->tr("error_invalid_number")}
+    </div>     
+
+     <div class="field">
       <label for="blogShowFuturePosts">{$locale->tr("show_future_posts")}</label>
       <div class="formHelp">
         <input class="checkbox" type="checkbox" name="blogShowFuturePosts" id="blogShowFuturePosts" value="1" {if $blogShowFuturePosts == true} checked="checked" {/if} />	  

Modified: plog/trunk/templates/admin/globalsettings_general.template
===================================================================
--- plog/trunk/templates/admin/globalsettings_general.template	2006-11-27 19:20:13 UTC (rev 4350)
+++ plog/trunk/templates/admin/globalsettings_general.template	2006-11-27 20:41:37 UTC (rev 4351)
@@ -78,9 +78,21 @@
    <!-- 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>
+    <div class="formHelp">{$locale->tr("hard_recent_posts_max_help")}</div>
     <input style="width:100%" type="text" name="config[hard_recent_posts_max]" value="{$hard_recent_posts_max}"/>
    </div>
+   <!-- show_comments_max -->
+   <div class="field">
+    <label for="config[show_comments_max]">show_comments_max</label>
+    <div class="formHelp">{$locale->tr("show_comments_max_help")}</div>
+    <input style="width:100%" type="text" name="config[show_comments_max]" value="{$show_comments_max}"/>
+   </div>
+   <!-- hard_show_comments_max -->
+   <div class="field">
+    <label for="config[hard_show_comments_max]">hard_show_comments_max</label>
+    <div class="formHelp">{$locale->tr("hard_show_comments_max_help")}</div>
+    <input style="width:100%" type="text" name="config[hard_show_comments_max]" value="{$hard_show_comments_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