[pLog-svn] r4074 - plog/trunk/class/config

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


Author: oscar
Date: 2006-10-01 21:55:56 +0000 (Sun, 01 Oct 2006)
New Revision: 4074

Added:
   plog/trunk/class/config/siteconfig.class.php
Log:
added the SiteConfig class, that extends Config and provides some static shorthand methods for accessing certain values from the site-wide configuration.


Added: plog/trunk/class/config/siteconfig.class.php
===================================================================
--- plog/trunk/class/config/siteconfig.class.php	2006-10-01 20:54:21 UTC (rev 4073)
+++ plog/trunk/class/config/siteconfig.class.php	2006-10-01 21:55:56 UTC (rev 4074)
@@ -0,0 +1,57 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+	
+	/**
+	 * some default values for the method below
+	 */
+	define( "DEFAULT_TMP_FOLDER", "./tmp" );	
+	define( "DEFAULT_HARD_SHOW_POSTS_MAX", 50 );	
+	define( "DEFAULT_HARD_RECENT_POSTS_MAX", 25 );	
+
+	class SiteConfig extends Config
+	{
+		function _getConfigValueWithDefault( $key, $default )
+		{
+			$config =& Config::getConfig();
+			return( $config->getValue( $key, $default ));			
+		}
+		
+		/** 
+		 * @static
+		 * Returns the temporaray folder
+		 */
+		function getTempFolder()
+		{
+			return( SiteConfig::_getConfigValueWithDefault( "temp_folder", DEFAULT_TMP_FOLDER ));
+		}
+
+		/** 
+		 * @static
+		 * Returns the maximum value for the hard_show_posts_max key
+		 */		
+		function getHardShowPostsMax()
+		{
+			return( SiteConfig::_getConfigValueWithDefault( "hard_show_posts_max", DEFAULT_HARD_SHOW_POSTS_MAX ));
+		}
+		
+		/** 
+		 * @static
+		 * Returns the maximum value for the hard_recent_posts_max key
+		 */		
+		function getHardRecentPostsMax()
+		{
+			return( SiteConfig::_getConfigValueWithDefault( "hard_recent_posts_max", DEFAULT_HARD_RECENT_POSTS_MAX ));
+		}
+		
+		/**
+		 * @static
+		 * @see Config
+		 */
+		function getValue( $key, $default )
+		{
+			$config =& parent::getConfig();
+			return( $config->getValue( $key, $default ));
+		}
+	}
+?>
\ No newline at end of file



More information about the pLog-svn mailing list