[pLog-svn] r2141 - in plog/trunk: . class class/action class/action/admin class/cache class/cache/Cache_Lite class/config class/controller class/dao class/dao/customfields class/data class/data/Date class/database class/gallery/dao class/locale class/net/http/session class/plugin class/security class/summary/action class/summary/dao class/summary/view class/template class/template/templatesets class/view class/view/admin class/xml/rssparser config templates/wizard

ork at devel.plogworld.net ork at devel.plogworld.net
Tue May 31 19:17:50 GMT 2005


Author: ork
Date: 2005-05-31 19:17:49 +0000 (Tue, 31 May 2005)
New Revision: 2141

Added:
   plog/trunk/class/cache/
   plog/trunk/class/cache/Cache_Lite/
   plog/trunk/class/cache/Cache_Lite/Lite.php
   plog/trunk/class/cache/bloginfomanager.class.php
   plog/trunk/class/cache/cache.class.php
   plog/trunk/class/cache/cachemanager.class.php
   plog/trunk/class/dao/blogarticles.class.php
   plog/trunk/class/dao/bloglinks.class.php
   plog/trunk/generateData.php
Removed:
   plog/trunk/class/cache/Cache_Lite/
   plog/trunk/class/cache/Cache_Lite/Lite.php
   plog/trunk/class/cache/bloginfomanager.class.php
   plog/trunk/class/cache/cache.class.php
   plog/trunk/class/cache/cachemanager.class.php
Modified:
   plog/trunk/class/action/action.class.php
   plog/trunk/class/action/addcommentaction.class.php
   plog/trunk/class/action/admin/adminaction.class.php
   plog/trunk/class/action/admin/adminaddpostaction.class.php
   plog/trunk/class/action/admin/admindeleteresourcealbumaction.class.php
   plog/trunk/class/action/admin/admineditblogaction.class.php
   plog/trunk/class/action/admin/admineditlinkaction.class.php
   plog/trunk/class/action/admin/adminmainaction.class.php
   plog/trunk/class/action/admin/adminupdateblogsettingsaction.class.php
   plog/trunk/class/action/admin/adminupdateeditblogaction.class.php
   plog/trunk/class/action/blogaction.class.php
   plog/trunk/class/action/defaultaction.class.php
   plog/trunk/class/action/templateaction.class.php
   plog/trunk/class/action/viewarticleaction.class.php
   plog/trunk/class/config/config.class.php
   plog/trunk/class/config/configdbstorage.class.php
   plog/trunk/class/config/properties.class.php
   plog/trunk/class/controller/controller.class.php
   plog/trunk/class/dao/article.class.php
   plog/trunk/class/dao/articlecategory.class.php
   plog/trunk/class/dao/articlecomments.class.php
   plog/trunk/class/dao/articlenotifications.class.php
   plog/trunk/class/dao/articles.class.php
   plog/trunk/class/dao/bloginfo.class.php
   plog/trunk/class/dao/blogs.class.php
   plog/trunk/class/dao/customfields/customfield.class.php
   plog/trunk/class/dao/customfields/customfieldcheckboxvalue.class.php
   plog/trunk/class/dao/customfields/customfielddatevalue.class.php
   plog/trunk/class/dao/model.class.php
   plog/trunk/class/dao/mylink.class.php
   plog/trunk/class/dao/mylinks.class.php
   plog/trunk/class/dao/mylinkscategories.class.php
   plog/trunk/class/dao/mylinkscategory.class.php
   plog/trunk/class/dao/referer.class.php
   plog/trunk/class/dao/referers.class.php
   plog/trunk/class/dao/searchengine.class.php
   plog/trunk/class/dao/sitestatistics.class.php
   plog/trunk/class/dao/trackbacks.class.php
   plog/trunk/class/dao/usercomment.class.php
   plog/trunk/class/dao/userinfo.class.php
   plog/trunk/class/dao/userpermissions.class.php
   plog/trunk/class/dao/users.class.php
   plog/trunk/class/data/Date.class.php
   plog/trunk/class/data/Date/Calc.class.php
   plog/trunk/class/database/db.class.php
   plog/trunk/class/gallery/dao/galleryalbums.class.php
   plog/trunk/class/gallery/dao/galleryresource.class.php
   plog/trunk/class/gallery/dao/galleryresources.class.php
   plog/trunk/class/locale/locale.class.php
   plog/trunk/class/locale/locales.class.php
   plog/trunk/class/net/http/session/sessionmanager.class.php
   plog/trunk/class/plugin/pluginbase.class.php
   plog/trunk/class/plugin/pluginmanager.class.php
   plog/trunk/class/security/bayesianfilter.class.php
   plog/trunk/class/security/nullpipelinefilter.class.php
   plog/trunk/class/security/pipeline.class.php
   plog/trunk/class/security/pipelinefilter.class.php
   plog/trunk/class/summary/action/summarydefaultaction.class.php
   plog/trunk/class/summary/dao/summarystats.class.php
   plog/trunk/class/summary/view/summarycachedview.class.php
   plog/trunk/class/template/template.class.php
   plog/trunk/class/template/templateservice.class.php
   plog/trunk/class/template/templatesets/templatesetstorage.class.php
   plog/trunk/class/view/admin/adminarticletrackbackslistview.class.php
   plog/trunk/class/view/admin/admindashboardview.class.php
   plog/trunk/class/view/admin/admindefaultview.class.php
   plog/trunk/class/view/admin/adminnewpostview.class.php
   plog/trunk/class/view/admin/adminpostslistview.class.php
   plog/trunk/class/view/blogview.class.php
   plog/trunk/class/view/defaultview.class.php
   plog/trunk/class/view/errorview.class.php
   plog/trunk/class/view/view.class.php
   plog/trunk/class/view/viewarticleview.class.php
   plog/trunk/class/xml/rssparser/rssparser.class.php
   plog/trunk/config/config.properties.php
   plog/trunk/index.php
   plog/trunk/templates/wizard/step1.template
   plog/trunk/version.php
Log:
merged 1.1-ben with the trunk. i'm sorry, a few views are broken now, i'll do my best to get the trunk back in a stable state


Modified: plog/trunk/class/action/action.class.php
===================================================================
--- plog/trunk/class/action/action.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/action.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -22,11 +22,6 @@
 	 */
 
 	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
-    include_once( PLOG_CLASS_PATH."class/action/actioninfo.class.php" );
-    include_once( PLOG_CLASS_PATH."class/config/properties.class.php" );
-    include_once( PLOG_CLASS_PATH."class/net/request.class.php" );
-    include_once( PLOG_CLASS_PATH."class/object/observable.class.php" );
-	include_once( PLOG_CLASS_PATH."class/data/forms/formvalidator.class.php" );
 
 	/**
 	 * \ingroup Action
@@ -73,6 +68,9 @@
          */
     	function Action( $actionInfo, $httpRequest )
         {
+            include_once( PLOG_CLASS_PATH."class/net/request.class.php" );
+	        include_once( PLOG_CLASS_PATH."class/data/forms/formvalidator.class.php" );
+
 			$this->Object();
 
             $this->_request = new Request( $httpRequest );
@@ -322,4 +320,4 @@
 			 $this->_form->setFormIsValid( $success );	 
 		 }
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/action/addcommentaction.class.php
===================================================================
--- plog/trunk/class/action/addcommentaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/addcommentaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -4,13 +4,10 @@
     include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/validator/emailvalidator.class.php" );
-    include_once( PLOG_CLASS_PATH."class/net/client.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
     include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
     include_once( PLOG_CLASS_PATH."class/bayesian/bayesianfiltercore.class.php" );
 	include_once( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
@@ -64,6 +61,8 @@
 
         function _fetchFields()
         {
+            include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
             $this->_articleId = $this->_request->getValue( "articleId" );
             $this->_blogId    = $this->_request->getValue( "blogId" );
             $this->_opId      = $this->_request->getValue( "op" );
@@ -137,6 +136,10 @@
          */
         function perform()
         {
+            include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
+            include_once( PLOG_CLASS_PATH."class/dao/usercomment.class.php" );
+            include_once( PLOG_CLASS_PATH."class/net/client.class.php" );
+
         	// need to check the ip of the client
             $clientIp = Client::getIp();
 

Modified: plog/trunk/class/action/admin/adminaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/admin/adminaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -81,10 +81,15 @@
          */
         function _getBlogInfo()
         {
+            // :TODO: this is not good yet.. 
+            require_once( PLOG_CLASS_PATH . "class/cache/bloginfomanager.class.php" );
+
             $session = HttpVars::getSession();
             $sessionInfo = $session["SessionInfo"];
+            $blogInfoManager = BlogInfoManager::getBlogInfoManager();
 
-            $this->_blogInfo = $sessionInfo->getValue( "blogInfo" );
+            $blogId = $sessionInfo->getValue( "blogId" );
+            $this->_blogInfo = $blogInfoManager->getBlogInfo( $blogId );
         }
 
         /**
@@ -148,7 +153,7 @@
          */
         function saveSession()
         {
-        	$this->_session->setValue( "blogInfo", $this->_blogInfo );
+        	$this->_session->setValue( "blogId", $this->_blogInfo->getId() );
             $this->_session->setValue( "userInfo", $this->_userInfo );
         	//$_SESSION["SessionInfo"] = $this->_session;
             $session = HttpVars::getSession();

Modified: plog/trunk/class/action/admin/adminaddpostaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddpostaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/admin/adminaddpostaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -2,17 +2,11 @@
 
 	include_once( PLOG_CLASS_PATH."class/action/admin/adminpostmanagementcommonaction.class.php" );
 	include_once( PLOG_CLASS_PATH."class/view/admin/adminpostslistview.class.php" );	
-    include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
-    include_once( PLOG_CLASS_PATH."class/locale/locale.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/stringutils.class.php" );
     include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
     include_once( PLOG_CLASS_PATH."class/view/admin/adminnewpostview.class.php" );    
-	include_once( PLOG_CLASS_PATH."class/bayesian/bayesianfiltercore.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );	
     include_once( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );	    
     include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
-	include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
-	include_once( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
 	
     /**
      * \ingroup Action
@@ -58,6 +52,8 @@
 		 */
 		function _savePostData( $article )
 		{
+            include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+
 			$status = $this->_postStatus;
 			
 			$articles = new Articles();
@@ -89,6 +85,9 @@
          */
         function perform()
         {
+            include_once( PLOG_CLASS_PATH."class/dao/article.class.php" );
+	        include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
 			$this->_fetchCommonData();
 
 			$this->_postId = $this->_request->getValue( "postId" );
@@ -118,10 +117,13 @@
                 $message = $this->_locale->tr("post_added_ok");
                 
                 // train the filter
+	            include_once( PLOG_CLASS_PATH."class/bayesian/bayesianfiltercore.class.php" );
                 BayesianFilterCore::trainWithArticle( $article );
                                 
         		// add the article notification if requested to do so
             	if( $this->_sendNotification ) {
+                    require_once( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );
+
                 	$artNotifications = new ArticleNotifications();
 	            	$artNotifications->addNotification( $artId, $this->_blogInfo->getId(), $this->_userInfo->getId());
                     $message .= " ".$this->_locale->tr("send_notifications_ok");
@@ -139,6 +141,8 @@
 
                     // and now check what to do with the trackbacks
                     if( $this->_sendTrackbacks ) {
+                        include_once( PLOG_CLASS_PATH."class/data/stringutils.class.php" );
+
                     	// get the links from the text of the post
         				$links = StringUtils::getLinks( stripslashes($article->getText()));
 
@@ -157,6 +161,8 @@
 					$this->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article )); 
 					
 					// empty the cache used by this blog
+	                include_once( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
+
 					CacheControl::resetBlogCache( $this->_blogInfo->getId());						
                 }
                 else {

Modified: plog/trunk/class/action/admin/admindeleteresourcealbumaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeleteresourcealbumaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/admin/admindeleteresourcealbumaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -4,6 +4,7 @@
     include_once( PLOG_CLASS_PATH."class/view/admin/adminresourceslistview.class.php" );
     include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresource.class.php" );
     include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
 
     /**
      * \ingroup Action

Modified: plog/trunk/class/action/admin/admineditblogaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditblogaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/admin/admineditblogaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -3,6 +3,7 @@
 	include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
     include_once( PLOG_CLASS_PATH."class/view/admin/adminsiteblogslistview.class.php" );
     include_once( PLOG_CLASS_PATH."class/view/admin/admineditsiteblogview.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
 
     /**

Modified: plog/trunk/class/action/admin/admineditlinkaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditlinkaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/admin/admineditlinkaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -5,6 +5,7 @@
 	include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/mylinkscategories.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/mylinks.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
 
     /**
      * \ingroup Action

Modified: plog/trunk/class/action/admin/adminmainaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminmainaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/admin/adminmainaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,10 +1,7 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
-    include_once( PLOG_CLASS_PATH."class/view/admin/adminnewpostview.class.php" );
-	include_once( PLOG_CLASS_PATH."class/view/admin/adminsimpleerrorview.class.php" );	
-    include_once( PLOG_CLASS_PATH."class/view/admin/admindashboardview.class.php" );	
-	include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
+//    include_once( PLOG_CLASS_PATH."class/view/admin/adminnewpostview.class.php" );
 
     /**
      * \ingroup Action
@@ -34,11 +31,13 @@
 	        // first of all, check if we have a valid blog id
 	        $this->_blogId = $this->_request->getValue( "blogId" );
             if( $this->_blogId == "" || $this->_blogId < 0 ) {
+	            include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
 				
 				// check if the user really belongs to one or more blogs and if not, quit
 				$users = new Users();
 				$userBlogs = $users->getUsersBlogs( $this->_userInfo->getId(), BLOG_STATUS_ACTIVE );
 				if( count($userBlogs) == 0 ) {
+	                include_once( PLOG_CLASS_PATH."class/view/admin/adminsimpleerrorview.class.php" );	
 					$this->_view = new AdminSimpleErrorView();
 					$this->_view->setValue( "message", $this->_locale->tr("error_dont_belong_to_any_blog" ));
 					
@@ -46,16 +45,21 @@
 				}
 				
 				// if everything went fine, then we can continue...
+                include_once( PLOG_CLASS_PATH."class/view/admin/admindashboardview.class.php" );	
+
 				$this->_view = new AdminDashboardView( $this->_userInfo, $userBlogs );
 				return false;
             }
 
 			// load the blog
-            $blogs = new Blogs();
-            $this->_blogInfo = $blogs->getBlogInfo( $this->_blogId );
+            require_once( PLOG_CLASS_PATH . "class/cache/bloginfomanager.class.php" );
+            $blogInfoManager = BlogInfoManager::getBlogInfoManager();
+            $this->_blogInfo = $blogInfoManager->getBlogInfo( $this->_blogId );
 			 
 			// check if the blog really exists
 			if( !$this->_blogInfo ) {
+	            include_once( PLOG_CLASS_PATH."class/view/admin/adminsimpleerrorview.class.php" );	
+
 				$this->_view = new AdminSimpleErrorView();
 				$this->_view->setValue( "message", $this->_locale->tr("error_incorrect_blog_id" ));
 				
@@ -76,6 +80,8 @@
             $userPermissions = new UserPermissions();
 			$blogUserPermissions = $userPermissions->getUserPermissions( $this->_userInfo->getId(), $this->_blogInfo->getId());
 			if( !$blogUserPermissions ) {
+	            include_once( PLOG_CLASS_PATH."class/view/admin/adminsimpleerrorview.class.php" );	
+
 				$this->_view = new AdminSimpleErrorView();
 				$this->_view->setValue( "message", $this->_locale->tr("error_no_permissions" ));
 				
@@ -85,7 +91,7 @@
             // if all correct, we can now set the blogInfo object in the session for later
             // use
             $session = HttpVars::getSession();
-            $session["SessionInfo"]->setValue( "blogInfo", $this->_blogInfo );
+            $session["SessionInfo"]->setValue( "blogId", $this->_blogInfo->getId() );
             HttpVars::setSession( $session );
 
             return true;

Modified: plog/trunk/class/action/admin/adminupdateblogsettingsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateblogsettingsaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/admin/adminupdateblogsettingsaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -52,6 +52,8 @@
          */
         function perform()
         {
+            require_once( PLOG_CLASS_PATH . "class/cache/bloginfomanager.class.php" );
+
         	// fetch the settings from the db and update them accordingly
             $blogs = new Blogs();
             $blogSettings = $blogs->getBlogSettings( $this->_blogInfo->getId());
@@ -77,7 +79,8 @@
             // and now update the settings in the database
             $blogs = new Blogs();
 			$this->notifyEvent( EVENT_PRE_BLOG_UPDATE, Array( "blog" => &$this->_blogInfo ));
-            if( !$blogs->updateBlog( $this->_blogInfo->getId(), $this->_blogInfo )) {
+            $blogInfoManager = BlogInfoManager::getBlogInfoManager();
+            if( !$blogInfoManager->updateBlogInfo( $this->_blogInfo->getId(), $this->_blogInfo )) {
             	$this->_view = new AdminBlogSettingsView( $this->_blogInfo );
                 $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
                	$this->setCommonData();

Modified: plog/trunk/class/action/admin/adminupdateeditblogaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateeditblogaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/admin/adminupdateeditblogaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -66,37 +66,36 @@
          */
         function perform()
         {
-        	// fetch the values from the form which have already been validated
-		$this->_blogName = $this->_request->getValue( "blogName" );
-        	$this->_blogLocale = $this->_request->getValue( "blogLocale" );
+            // fetch the values from the form which have already been validated
+            $this->_blogName = $this->_request->getValue( "blogName" );
+            $this->_blogLocale = $this->_request->getValue( "blogLocale" );
             $this->_blogTemplate = $this->_request->getValue( "blogTemplate" );
             $this->_blogOwner = $this->_request->getValue( "blogOwner" );
             $this->_editBlogId = $this->_request->getValue( "blogId" );
-            $this->_blogTimeOffset = $this->_request->getValue( "blogTimeOffset" );			
-			$this->_blogProperties = $this->_request->getValue( "properties" );
-			$this->_blogQuota = $this->_request->getValue( "blogResourcesQuota" );
-			$this->_blogUsers = $this->_request->getValue( "blogUsers" );
-			$this->_blogStatus = $this->_request->getValue( "blogStatus" );
-			//print_r($_REQUEST);
-		
-        	// get the blog we're trying to update
+            $this->_blogTimeOffset = $this->_request->getValue( "blogTimeOffset" );
+            $this->_blogProperties = $this->_request->getValue( "properties" );
+            $this->_blogQuota = $this->_request->getValue( "blogResourcesQuota" );
+            $this->_blogUsers = $this->_request->getValue( "blogUsers" );
+            $this->_blogStatus = $this->_request->getValue( "blogStatus" );
+
+            // get the blog we're trying to update
             $blogs = new Blogs();
             $blogInfo = $blogs->getBlogInfo( $this->_editBlogId );
             if( !$blogInfo ) {
-            	$this->_view = new AdminSiteBlogsListView( $this->_blogInfo );
+                $this->_view = new AdminSiteBlogsListView( $this->_blogInfo );
                 $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_blog"));
                 $this->setCommonData();
 
                 return false;
             }
-			
-			$this->notifyEvent( EVENT_BLOG_LOADED, Array( "blog" => &$blogInfo ));
 
+            $this->notifyEvent( EVENT_BLOG_LOADED, Array( "blog" => &$blogInfo ));
+
             // make sure that the user we'd like to set as owner exists
             $users = new Users();
             $userInfo = $users->getUserInfoFromId( $this->_blogOwner );
             if( !$userInfo ) {
-            	$this->_view = new AdminSiteBlogsListView( $this->_blogInfo );
+                $this->_view = new AdminSiteBlogsListView( $this->_blogInfo );
                 $this->_view->setErrorMessage( $this->_locale->tr("error_incorrect_blog_owner"));
                 $this->setCommonData();
                 return false;
@@ -135,7 +134,7 @@
                 		return false;
 			}
 
-			$this->notifyEvent( EVENT_POST_BLOG_UPDATE, Array( "blog" => &$blogInfo ));			
+			$this->notifyEvent( EVENT_POST_BLOG_UPDATE, Array( "blog" => &$blogInfo ));
 
             // do it again, baby :)))
             if( $this->_blogInfo->getId() == $blogInfo->getId()) {
@@ -149,10 +148,10 @@
             $this->_view = new AdminSiteBlogsListView( $this->_blogInfo );
             $this->_view->setSuccessMessage( $this->_locale->pr( "edit_blog_settings_updated_ok", $blogInfo->getBlog()));
             $this->setCommonData();
-			
-			// clear the cache
-			CacheControl::resetBlogCache( $blogInfo->getId());			
 
+            // clear the cache
+            CacheControl::resetBlogCache( $blogInfo->getId());
+
             // better to return true if everything fine
             return true;
         }

Modified: plog/trunk/class/action/blogaction.class.php
===================================================================
--- plog/trunk/class/action/blogaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/blogaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,14 +1,7 @@
 <?php
 
-	include_once( PLOG_CLASS_PATH."class/action/action.class.php" );
+    include_once( PLOG_CLASS_PATH."class/action/action.class.php" );
     include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
-    include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
-    include_once( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
-    include_once( PLOG_CLASS_PATH."class/security/pipeline.class.php" );
-	include_once( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/referers.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );	
 
     /**
      * \ingroup Action
@@ -37,14 +30,19 @@
          *
          *
          */
-		function BlogAction( $actionInfo, $request )
+        function BlogAction( $actionInfo, $request )
         {
-        	$this->Action( $actionInfo, $request );
+            include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+            include_once( PLOG_CLASS_PATH."class/security/pipeline.class.php" );
+            include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );	
+            include_once( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
 
+            $this->Action( $actionInfo, $request );
+
             // we use the HttpVars package since then we can access the session object
             // independently wether we're using php ver. < 4.1.0 or not
             $session = HttpVars::getSession();
-        	$this->_session = $session['SessionInfo'];
+            $this->_session = $session['SessionInfo'];
 
             $this->_config =& Config::getConfig();
 
@@ -142,9 +140,13 @@
          */
         function _getBlogInfo()
         {	
+            include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
 			// see if we're using subdomains
 			$config =& Config::getConfig();
 			if( $config->getValue( "subdomains_enabled" )) {
+                include_once( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
+
 				$subdomainInfo = Subdomains::getSubdomainInfoFromRequest();
 
 				if( $subdomainInfo["username"] != "" && $this->_request->getValue( 'blogUserName' ) == "" )
@@ -189,11 +191,16 @@
             }
 			
             // fetch the BlogInfo object
-            $blogs = new Blogs();
-            if( $blogId )
+            if( $blogId ) {
+
+                $blogs = new Blogs();
                 $this->_blogInfo = $blogs->getBlogInfo( $blogId );
-            else
+                
+                // $this->_blogInfo = $blogs->getBlogInfo( $blogId );
+            } else {
+                $blogs = new Blogs();
                 $this->_blogInfo = $blogs->getBlogInfoByName( $blogName );
+            }
 
             // security checks...
             if( $this->_blogInfo == false ) {
@@ -220,10 +227,15 @@
                 $day = substr( $date, 6, 2);
             }
             else {
-            		$t = new Timestamp();
-                	$year = $t->getYear();
-                	$month = $t->getMonth();
-                	$day = $t->getDay();
+                    // to much overhead for just getting the current date
+                    // :TODO: but we might need to read the timezone to enter a valid date.. not sure ..
+            		// $t = new Timestamp();
+                	// $year = $t->getYear();
+                    $year = date('Y');
+                	// $month = $t->getMonth();
+                    $month = date('m');
+                	// $day = $t->getDay();
+                    $day = date('d');
             }
 
             $this->_session->setValue( 'Year', $year );
@@ -239,10 +251,13 @@
 		 */
 		function _updateReferrer()
 		{
-			if( $this->_request->getValue( "articleId" ) != "" || $this->_request->getValue( "articleName" ) != "" ) 
+			if( $this->_request->getValue( "articleId" ) != "" || 
+                $this->_request->getValue( "articleName" ) != "" ) 
 				return true;
 				
         	// update the referer statistics
+            include_once( PLOG_CLASS_PATH."class/dao/referers.class.php" );
+
             $referers = new Referers();
             if (array_key_exists( 'HTTP_REFERER', $_SERVER ))
                 $referers->addReferer( $_SERVER['HTTP_REFERER'], 0, $this->_blogInfo->getId());

Modified: plog/trunk/class/action/defaultaction.class.php
===================================================================
--- plog/trunk/class/action/defaultaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/defaultaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,11 +1,7 @@
 <?php
 
-	include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
-    include_once( PLOG_CLASS_PATH."class/view/defaultview.class.php" );
-    include_once( PLOG_CLASS_PATH."class/net/http/session/sessioninfo.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
-    include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
-	include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );	
+	require_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
+	require_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );	
 
     /**
      * \ingroup Action
@@ -53,6 +49,8 @@
          */
         function perform()
         {
+            require_once( PLOG_CLASS_PATH."class/view/defaultview.class.php" );
+
         	// first of all, we have to determine which blog we would like to see
 			$blogId = $this->_blogInfo->getId();
 
@@ -75,6 +73,9 @@
 				return true;
 			}
 
+            require_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+            require_once( PLOG_CLASS_PATH."class/dao/articlecategories.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
             // it exists
@@ -82,6 +83,7 @@
             if( $this->_categoryName ) {
                 $category = $categories->getCategoryByName( $this->_categoryName, $this->_blogInfo->getId());
                 if( !$category ) {
+                    require_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
                     $this->_view = new ErrorView( $this->_blogInfo );
                     $this->_view->setValue( 'message', "error_incorrect_category_id" );
                     $this->setCommonData();
@@ -96,6 +98,7 @@
 				if( $this->_categoryId > 0 ) {
 					$category = $categories->getCategory( $this->_categoryId, $this->_blogInfo->getId());
 					if( !$category ) {
+                        require_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
 						$this->_view = new ErrorView( $this->_blogInfo );
 						$this->_view->setValue( 'message', "error_incorrect_category_id" );
 						$this->setCommonData();
@@ -129,6 +132,7 @@
             if( $this->_userName ) {
                 $user = $users->getUserInfoFromUsername( $this->_userName );
                 if( !$user ) {
+                    require_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
                     $this->_view = new ErrorView( $this->_blogInfo );
                     $this->_view->setValue( 'message', 'error_incorrect_user_id' );
                     $this->setCommonData();
@@ -177,6 +181,7 @@
 
             // if we couldn't fetch the articles, send an error and quit
             if( count($blogArticles) == 0 ) {
+                require_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
             	$this->_view = new ErrorView( $this->_blogInfo );
                 $this->_view->setValue( 'message', 'error_fetching_articles' );
             }

Modified: plog/trunk/class/action/templateaction.class.php
===================================================================
--- plog/trunk/class/action/templateaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/templateaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -2,7 +2,6 @@
 
 	include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
     include_once( PLOG_CLASS_PATH."class/view/templateview.class.php" );
-    include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
 
     /**
@@ -41,8 +40,6 @@
         	$this->BlogAction( $actionInfo, $request );
         	
         	$this->registerFieldValidator( "show", new StringValidator());
-        	$view = new ErrorView( $this->_blogInfo, "error_parameter_missing" );
-        	$this->setValidationErrorView( $view );
         }
 
         /**
@@ -59,6 +56,11 @@
         	$templateFile = $this->_request->getValue( "show" );
             // then, check if it has any extraneous character
             if( strstr( $templateFile, ".." )) {
+                include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
+
+        	    $view = new ErrorView( $this->_blogInfo, "error_parameter_missing" );
+        	    $this->setValidationErrorView( $view );
+
             	$this->_view = new ErrorView( $this->_blogInfo );
                 $this->_view->setValue( "message", "error_incorrect_parameter" );
                 $this->setCommonData();

Modified: plog/trunk/class/action/viewarticleaction.class.php
===================================================================
--- plog/trunk/class/action/viewarticleaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/action/viewarticleaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,14 +1,11 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
 	include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/referers.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
-    include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
-	include_once( PLOG_CLASS_PATH."class/view/viewarticleview.class.php" );
 
     /**
      * \ingroup Action
@@ -53,6 +50,8 @@
 		
 		function _setErrorView()
 		{
+            include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );
+
 			$this->_view = new ErrorView( $this->_blogInfo );
 			$this->_view->setValue( "message", "error_fetching_article" );
 			$this->setCommonData();		
@@ -101,6 +100,7 @@
 
         function perform()
         {
+	        include_once( PLOG_CLASS_PATH."class/view/viewarticleview.class.php" );
 
         	$this->_view = new ViewArticleView( $this->_blogInfo, 
                                                    Array( "articleId" => $this->_articleId,
@@ -156,20 +156,29 @@
 		
             // fetch the article
             // the article identifier can be either its internal id number or its mangled topic
+            include_once( PLOG_CLASS_PATH."class/dao/article.class.php" );
             if( $this->_articleId ) { 
-                $article  = $this->articles->getBlogArticle( $this->_articleId, $this->_blogInfo->getId(), false, 
-				                                       $this->_date, $this->_categoryId, $this->_userId,
-													   POST_STATUS_PUBLISHED );
-			}
-            else {
-                $article  = $this->articles->getBlogArticleByTitle( $this->_articleName, $this->_blogInfo->getId(), false,
-				                                              $this->_date, $this->_categoryId, $this->_userId,
-															  POST_STATUS_PUBLISHED );
-			}
-				
+
+                $article  = $this->articles->getBlogArticle( $this->_articleId, 
+                                                             $this->_blogInfo->getId(), 
+                                                             false, 
+                                                             $this->_date, 
+                                                             $this->_categoryId, 
+                                                             $this->_userId,
+                                                             POST_STATUS_PUBLISHED );
+            } else {
+                $article  = $this->articles->getBlogArticleByTitle( $this->_articleName, 
+                                                                    $this->_blogInfo->getId(), 
+                                                                    false,
+                                                                    $this->_date, 
+                                                                    $this->_categoryId, 
+                                                                    $this->_userId,
+                                                                    POST_STATUS_PUBLISHED );
+            }
+
             // if the article id doesn't exist, cancel the whole thing...
             if( !$article ) {
-				$this->_setErrorView();
+                $this->_setErrorView();
                 return false;
             }
 			
@@ -192,4 +201,4 @@
             return true;
         }
     }
-?>
\ No newline at end of file
+?>

Copied: plog/trunk/class/cache (from rev 2140, plog/branches/plog-1.1-ben/class/cache)

Copied: plog/trunk/class/cache/Cache_Lite (from rev 2140, plog/branches/plog-1.1-ben/class/cache/Cache_Lite)

Deleted: plog/trunk/class/cache/Cache_Lite/Lite.php
===================================================================
--- plog/branches/plog-1.1-ben/class/cache/Cache_Lite/Lite.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/cache/Cache_Lite/Lite.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,739 +0,0 @@
-<?php
-
-/**
-* Fast, light and safe Cache Class
-*
-* Cache_Lite is a fast, light and safe cache system. It's optimized
-* for file containers. It is fast and safe (because it uses file
-* locking and/or anti-corruption tests).
-*
-* There are some examples in the 'docs/examples' file
-* Technical choices are described in the 'docs/technical' file
-*
-* A tutorial is available in english at this url :
-* http://www.pearfr.org/index.php/en/article/cache_lite
-* (big thanks to Pierre-Alain Joye for the translation)
-*
-* The same tutorial is also available in french at this url :
-* http://www.pearfr.org/index.php/fr/article/cache_lite
-*
-* Memory Caching is from an original idea of
-* Mike BENOIT <ipso at snappymail.ca>
-*
-* @package Cache_Lite
-* @category Caching
-* @version $Id: Lite.php,v 1.23 2005/02/27 18:24:28 fab Exp $
-* @author Fabien MARTY <fab at php.net>
-*/
-
-define('CACHE_LITE_ERROR_RETURN', 1);
-define('CACHE_LITE_ERROR_DIE', 8);
-
-class Cache_Lite
-{
-
-    // --- Private properties ---
-
-    /**
-    * Directory where to put the cache files
-    * (make sure to add a trailing slash)
-    *
-    * @var string $_cacheDir
-    */
-    var $_cacheDir = '/tmp/';
-
-    /**
-    * Enable / disable caching
-    *
-    * (can be very usefull for the debug of cached scripts)
-    *
-    * @var boolean $_caching
-    */
-    var $_caching = true;
-
-    /**
-    * Cache lifetime (in seconds)
-    *
-    * @var int $_lifeTime
-    */
-    var $_lifeTime = 3600;
-
-    /**
-    * Enable / disable fileLocking
-    *
-    * (can avoid cache corruption under bad circumstances)
-    *
-    * @var boolean $_fileLocking
-    */
-    var $_fileLocking = true;
-
-    /**
-    * Timestamp of the last valid cache
-    *
-    * @var int $_refreshTime
-    */
-    var $_refreshTime;
-
-    /**
-    * File name (with path)
-    *
-    * @var string $_file
-    */
-    var $_file;
-    
-    /**
-    * File name (without path)
-    *
-    * @var string $_fileName
-    */
-    var $_fileName;
-
-    /**
-    * Enable / disable write control (the cache is read just after writing to detect corrupt entries)
-    *
-    * Enable write control will lightly slow the cache writing but not the cache reading
-    * Write control can detect some corrupt cache files but maybe it's not a perfect control
-    *
-    * @var boolean $_writeControl
-    */
-    var $_writeControl = true;
-
-    /**
-    * Enable / disable read control
-    *
-    * If enabled, a control key is embeded in cache file and this key is compared with the one
-    * calculated after the reading.
-    *
-    * @var boolean $_writeControl
-    */
-    var $_readControl = false;
-
-    /**
-    * Type of read control (only if read control is enabled)
-    *
-    * Available values are :
-    * 'md5' for a md5 hash control (best but slowest)
-    * 'crc32' for a crc32 hash control (lightly less safe but faster, better choice)
-    * 'strlen' for a length only test (fastest)
-    *
-    * @var boolean $_readControlType
-    */
-    var $_readControlType = 'crc32';
-
-    /**
-    * Pear error mode (when raiseError is called)
-    *
-    * (see PEAR doc)
-    *
-    * @see setToDebug()
-    * @var int $_pearErrorMode
-    */
-    var $_pearErrorMode = CACHE_LITE_ERROR_RETURN;
-    
-    /**
-    * Current cache id
-    *
-    * @var string $_id
-    */
-    var $_id;
-
-    /**
-    * Current cache group
-    *
-    * @var string $_group
-    */
-    var $_group;
-
-    /**
-    * Enable / Disable "Memory Caching"
-    *
-    * NB : There is no lifetime for memory caching ! 
-    *
-    * @var boolean $_memoryCaching
-    */
-    var $_memoryCaching = false;
-
-    /**
-    * Enable / Disable "Only Memory Caching"
-    * (be carefull, memory caching is "beta quality")
-    *
-    * @var boolean $_onlyMemoryCaching
-    */
-    var $_onlyMemoryCaching = false;
-
-    /**
-    * Memory caching array
-    *
-    * @var array $_memoryCachingArray
-    */
-    var $_memoryCachingArray = array();
-
-    /**
-    * Memory caching counter
-    *
-    * @var int $memoryCachingCounter
-    */
-    var $_memoryCachingCounter = 0;
-
-    /**
-    * Memory caching limit
-    *
-    * @var int $memoryCachingLimit
-    */
-    var $_memoryCachingLimit = 1000;
-    
-    /**
-    * File Name protection
-    *
-    * if set to true, you can use any cache id or group name
-    * if set to false, it can be faster but cache ids and group names
-    * will be used directly in cache file names so be carefull with
-    * special characters...
-    *
-    * @var boolean $fileNameProtection
-    */
-    var $_fileNameProtection = true;
-    
-    /**
-    * Enable / disable automatic serialization
-    *
-    * it can be used to save directly datas which aren't strings
-    * (but it's slower)    
-    *
-    * @var boolean $_serialize
-    */
-    var $_automaticSerialization = true;
-    
-    /**
-    * Disable / Tune the automatic cleaning process
-    *
-    * The automatic cleaning process destroy too old (for the given life time)
-    * cache files when a new cache file is written.
-    * 0               => no automatic cache cleaning
-    * 1               => systematic cache cleaning
-    * x (integer) > 1 => automatic cleaning randomly 1 times on x cache write
-    *
-    * @var int $_automaticCleaning
-    */
-    var $_automaticCleaningFactor = 0;
-    
-    /**
-    * Nested directory level
-    *
-    *
-    * @var int $_hashedDirectoryLevel
-    */
-    var $_hashedDirectoryLevel = 2;
-    
-    // --- Public methods ---
-
-    /**
-    * Constructor
-    *
-    * $options is an assoc. Available options are :
-    * $options = array(
-    *     'cacheDir' => directory where to put the cache files (string),
-    *     'caching' => enable / disable caching (boolean),
-    *     'lifeTime' => cache lifetime in seconds (int),
-    *     'fileLocking' => enable / disable fileLocking (boolean),
-    *     'writeControl' => enable / disable write control (boolean),
-    *     'readControl' => enable / disable read control (boolean),
-    *     'readControlType' => type of read control 'crc32', 'md5', 'strlen' (string),
-    *     'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int),
-    *     'memoryCaching' => enable / disable memory caching (boolean),
-    *     'onlyMemoryCaching' => enable / disable only memory caching (boolean),
-    *     'memoryCachingLimit' => max nbr of records to store into memory caching (int),
-    *     'fileNameProtection' => enable / disable automatic file name protection (boolean),
-    *     'automaticSerialization' => enable / disable automatic serialization (boolean)
-    *     'automaticCleaningFactor' => distable / tune automatic cleaning process (int)
-    *     'hashedDirectoryLevel' => level of the hashed directory system (int)
-    * );
-    *
-    * @param array $options options
-    * @access public
-    */
-    function Cache_Lite($options = array(NULL))
-    {
-        // original options
-        // $availableOptions = array('hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode');
-        // options really needed by pLog
-        $availableOptions = array('cacheDir');
-        foreach($options as $key => $value) {
-            if(in_array($key, $availableOptions)) {
-                $property = '_'.$key;
-                $this->$property = $value;
-            }
-        }
-        $this->_refreshTime = time() - $this->_lifeTime;
-    }
-    
-    /**
-    * Test if a cache is available and (if yes) return it
-    *
-    * @param string $id cache id
-    * @param string $group name of the cache group
-    * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
-    * @return string data of the cache (or false if no cache available)
-    * @access public
-    */
-    function get($id, $group = 'default', $doNotTestCacheValidity = false)
-    {
-        $this->_id = $id;
-        $this->_group = $group;
-        $data = false;
-        if ($this->_caching) {
-            $this->_setFileName($id, $group);
-//            :TODO: we won't have memory caching at all .. 
-//            if ($this->_memoryCaching) {
-//                if (isset($this->_memoryCachingArray[$this->_file])) {
-//                    if ($this->_automaticSerialization) {
-//                        return unserialize($this->_memoryCachingArray[$this->_file]);
-//                    } else {
-//                        return $this->_memoryCachingArray[$this->_file];
-//                    }
-//                } else {
-//                    if ($this->_onlyMemoryCaching) {
-//                        return false;
-//                    }
-//                }
-//            }
-            if ($doNotTestCacheValidity) {
-                if (file_exists($this->_file)) {
-                    $data = $this->_read();
-                }
-            } else {
-                if ((file_exists($this->_file)) && (@filemtime($this->_file) > $this->_refreshTime)) {
-                    $data = $this->_read();
-                }
-            }
-//            if (($data) and ($this->_memoryCaching)) {
-//                $this->_memoryCacheAdd($this->_file, $data);
-//            }
-            if (($this->_automaticSerialization) and (is_string($data))) {
-                $data = unserialize($data);
-            }
-            return $data;
-        }
-        return false;
-    }
-    
-    /**
-    * Save some data in a cache file
-    *
-    * @param string $data data to put in cache (can be another type than strings if automaticSerialization is on)
-    * @param string $id cache id
-    * @param string $group name of the cache group
-    * @return boolean true if no problem
-    * @access public
-    */
-    function save($data, $id = NULL, $group = 'default')
-    {
-        if ($this->_caching) {
-            if ($this->_automaticSerialization) {
-                $data = serialize($data);
-            }
-            if (isset($id)) {
-                $this->_setFileName($id, $group);
-            }
-//            :TODO: we won't have memory caching at all..
-//            if ($this->_memoryCaching) {
-//                $this->_memoryCacheAdd($this->_file, $data);
-//                if ($this->_onlyMemoryCaching) {
-//                    return true;
-//                }
-//            }
-	    if ($this->_automaticCleaningFactor>0) {
-                $rand = rand(1, $this->_automaticCleaningFactor);
-	        if ($rand==1) {
-	            $this->clean(false, 'old');
-		}
-            }
-            if ($this->_writeControl) {
-                if (!$this->_writeAndControl($data)) {
-                    @touch($this->_file, time() - 2*abs($this->_lifeTime));
-                    return false;
-                } else {
-                    return true;
-                }
-            } else {
-	        return $this->_write($data);
-	    }
-        }
-        return false;
-    }
-
-    /**
-    * Remove a cache file
-    *
-    * @param string $id cache id
-    * @param string $group name of the cache group
-    * @return boolean true if no problem
-    * @access public
-    */
-    function remove($id, $group = 'default')
-    {
-        $this->_setFileName($id, $group);
-//        :TODO: we won't have memory caching at all..
-//        if ($this->_memoryCaching) {
-//            if (isset($this->_memoryCachingArray[$this->_file])) {
-//                unset($this->_memoryCachingArray[$this->_file]);
-//                $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
-//            }
-//            if ($this->_onlyMemoryCaching) {
-//                return true;
-//            }
-//        }
-        return $this->_unlink($this->_file);
-    }
-
-    /**
-    * Clean the cache
-    *
-    * if no group is specified all cache files will be destroyed
-    * else only cache files of the specified group will be destroyed
-    *
-    * @param string $group name of the cache group
-    * @param string $mode flush cache mode : 'old', 'ingroup', 'notingroup'
-    * @return boolean true if no problem
-    * @access public
-    */
-    function clean($group = false, $mode = 'ingroup')
-    {
-        return $this->_cleanDir($this->_cacheDir, $group, $mode);
-    }
-       
-    /**
-    * Set to debug mode
-    *
-    * When an error is found, the script will stop and the message will be displayed
-    * (in debug mode only).
-    *
-    * @access public
-    */
-    function setToDebug()
-    {
-        $this->_pearErrorMode = CACHE_LITE_ERROR_DIE;
-    }
-
-    /**
-    * Set a new life time
-    *
-    * @param int $newLifeTime new life time (in seconds)
-    * @access public
-    */
-    function setLifeTime($newLifeTime)
-    {
-        $this->_lifeTime = $newLifeTime;
-        $this->_refreshTime = time() - $newLifeTime;
-    }
-
-    /**
-    * Save the state of the caching memory array into a cache file cache
-    *
-    * @param string $id cache id
-    * @param string $group name of the cache group
-    * @access public
-    */
-    function saveMemoryCachingState($id, $group = 'default')
-    {
-        if ($this->_caching) {
-            $array = array(
-                'counter' => $this->_memoryCachingCounter,
-                'array' => $this->_memoryCachingState
-            );
-            $data = serialize($array);
-            $this->save($data, $id, $group);
-        }
-    }
-
-    /**
-    * Load the state of the caching memory array from a given cache file cache
-    *
-    * @param string $id cache id
-    * @param string $group name of the cache group
-    * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
-    * @access public
-    */
-    function getMemoryCachingState($id, $group = 'default', $doNotTestCacheValidity = false)
-    {
-        if ($this->_caching) {
-            if ($data = $this->get($id, $group, $doNotTestCacheValidity)) {
-                $array = unserialize($data);
-                $this->_memoryCachingCounter = $array['counter'];
-                $this->_memoryCachingArray = $array['array'];
-            }
-        }
-    }
-    
-    /**
-    * Return the cache last modification time
-    *
-    * BE CAREFUL : THIS METHOD IS FOR HACKING ONLY !
-    *
-    * @return int last modification time
-    */
-    function lastModified() {
-        return filemtime($this->_file);
-    }
-    
-    /**
-    * Trigger a PEAR error
-    *
-    * To improve performances, the PEAR.php file is included dynamically.
-    * The file is so included only when an error is triggered. So, in most
-    * cases, the file isn't included and perfs are much better.
-    *
-    * @param string $msg error message
-    * @param int $code error code
-    * @access public
-    */
-    function raiseError($msg, $code)
-    {
-        include_once('PEAR.php');
-        PEAR::raiseError($msg, $code, $this->_pearErrorMode);
-    }
-    
-    // --- Private methods ---
-
-    /**
-    * Remove a file
-    * 
-    * @param string $file complete file path and name
-    * @return boolean true if no problem
-    * @access private
-    */
-    function _unlink($file)
-    {
-        if (file_exists($file) && !@unlink($file)) {
-            $this->raiseError('Cache_Lite : Unable to remove cache !', -3);
-            return false;
-        } else {
-            return true;
-        }
-    }
-
-    /**
-    * Recursive function for cleaning cache file in the given directory
-    *
-    * @param string $dir directory complete path (with a trailing slash)
-    * @param string $group name of the cache group
-    * @param string $mode flush cache mode : 'old', 'ingroup', 'notingroup'
-    * @return boolean true if no problem
-    * @access private
-    */
-    function _cleanDir($dir, $group = false, $mode = 'ingroup')     
-    {
-        if ($this->_fileNameProtection) {
-            $motif = ($group) ? 'cache_'.md5($group).'_' : 'cache_';
-        } else {
-            $motif = ($group) ? 'cache_'.$group.'_' : 'cache_';
-        }
-        if ($this->_memoryCaching) {
-            while (list($key, $value) = each($this->_memoryCachingArray)) {
-                if (strpos($key, $motif, 0)) {
-                    unset($this->_memoryCachingArray[$key]);
-                    $this->_memoryCachingCounter = $this->_memoryCachingCounter - 1;
-                }
-            }
-            if ($this->_onlyMemoryCaching) {
-                return true;
-            }
-        }
-        if (!($dh = opendir($dir))) {
-            $this->raiseError('Cache_Lite : Unable to open cache directory !', -4);
-            return false;
-        }
-        $result = true;
-        while ($file = readdir($dh)) {
-            if (($file != '.') && ($file != '..')) {
-                if (substr($file, 0, 6)=='cache_') {
-                    $file2 = $dir . $file;
-                    if (is_file($file2)) {
-                        switch ($mode) {
-                            case 'old':
-                                // files older than lifeTime get deleted from cache
-                                if ((mktime() - filemtime($file2)) > $this->_lifeTime) {
-                                    $result = ($result and ($this->_unlink($file2)));
-                                }
-                                break;
-                            case 'notingroup':
-                                if (!strpos($file2, $motif, 0)) {
-                                    $result = ($result and ($this->_unlink($file2)));
-                                }
-                                break;
-                            case 'ingroup':
-                            default:
-                                if (strpos($file2, $motif, 0)) {
-                                    $result = ($result and ($this->_unlink($file2)));
-                                }
-                                break;
-                        }
-                    }
-                    if ((is_dir($file2)) and ($this->_hashedDirectoryLevel>0)) {
-                        $result = ($result and ($this->_cleanDir($file2 . '/', $group, $mode)));
-                    }
-                }
-            }
-        }
-        return $result;
-    }
-      
-    /**
-    * Add some date in the memory caching array
-    *
-    * @param string $id cache id
-    * @param string $data data to cache
-    * @access private
-    */
-    function _memoryCacheAdd($id, $data)
-    {
-        $this->_memoryCachingArray[$this->_file] = $data;
-        if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) {
-            list($key, $value) = each($this->_memoryCachingArray);
-            unset($this->_memoryCachingArray[$key]);
-        } else {
-            $this->_memoryCachingCounter = $this->_memoryCachingCounter + 1;
-        }
-    }
-
-    /**
-    * Make a file name (with path)
-    *
-    * @param string $id cache id
-    * @param string $group name of the group
-    * @access private
-    */
-    function _setFileName($id, $group)
-    {
-        
-        if ($this->_fileNameProtection) {
-            $suffix = 'cache_'.md5($group).'_'.md5($id);
-        } else {
-            $suffix = 'cache_'.$group.'_'.$id;
-        }
-        $root = $this->_cacheDir;
-        if ($this->_hashedDirectoryLevel>0) {
-            $hash = md5($suffix);
-            for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
-                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
-            }   
-        }
-        $this->_fileName = $suffix;
-        $this->_file = $root.$suffix;
-    }
-    
-    /**
-    * Read the cache file and return the content
-    *
-    * @return string content of the cache file
-    * @access private
-    */
-    function _read()
-    {
-        $fp = @fopen($this->_file, "rb");
-        if ($this->_fileLocking) @flock($fp, LOCK_SH);
-        if ($fp) {
-            clearstatcache(); // because the filesize can be cached by PHP itself...
-            $length = @filesize($this->_file);
-            $mqr = get_magic_quotes_runtime();
-            set_magic_quotes_runtime(0);
-            if ($this->_readControl) {
-                $hashControl = @fread($fp, 32);
-                $length = $length - 32;
-            } 
-            $data = @fread($fp, $length);
-            set_magic_quotes_runtime($mqr);
-            if ($this->_fileLocking) @flock($fp, LOCK_UN);
-            @fclose($fp);
-            if ($this->_readControl) {
-                $hashData = $this->_hash($data, $this->_readControlType);
-                if ($hashData != $hashControl) {
-                    @touch($this->_file, time() - 2*abs($this->_lifeTime)); 
-                    return false;
-                }
-            }
-            return $data;
-        }
-        $this->raiseError('Cache_Lite : Unable to read cache !', -2);   
-        return false;
-    }
-    
-    /**
-    * Write the given data in the cache file
-    *
-    * @param string $data data to put in cache
-    * @return boolean true if ok
-    * @access private
-    */
-    function _write($data)
-    {
-        $this->_createCacheDir();
-        $fp = @fopen($this->_file, 'w');
-        if ($fp) {
-            if ($this->_fileLocking) @flock($fp, LOCK_EX);
-            if ($this->_readControl) {
-                @fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
-            }
-            $len = strlen($data);
-            @fwrite($fp, $data, $len);
-            if ($this->_fileLocking) @flock($fp, LOCK_UN);
-            @fclose($fp);
-            return true;
-        }
-        $this->raiseError('Cache_Lite : Unable to write cache file : '.$this->_file, -1);
-        return false;
-    }
-
-    function _createCacheDir()
-    {
-        if (($this->_hashedDirectoryLevel>0)) {
-            $hash = md5($this->_fileName);
-            $root = $this->_cacheDir;
-            for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
-                $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/';
-                if (!is_dir($root)) {
-                    @mkdir($root, 0700);
-                }
-            }
-        }
-    }
-    
-    /**
-    * Write the given data in the cache file and control it just after to avoir corrupted cache entries
-    *
-    * @param string $data data to put in cache
-    * @return boolean true if the test is ok
-    * @access private
-    */
-    function _writeAndControl($data)
-    {
-        $this->_write($data);
-        $dataRead = $this->_read($data);
-        return ($dataRead==$data);
-    }
-    
-    /**
-    * Make a control key with the string containing datas
-    *
-    * @param string $data data
-    * @param string $controlType type of control 'md5', 'crc32' or 'strlen'
-    * @return string control key
-    * @access private
-    */
-    function _hash($data, $controlType)
-    {
-        switch ($controlType) {
-        case 'md5':
-            return md5($data);
-        case 'crc32':
-            return sprintf('% 32d', crc32($data));
-        case 'strlen':
-            return sprintf('% 32d', strlen($data));
-        default:
-            $this->raiseError('Unknown controlType ! (available values are only \'md5\', \'crc32\', \'strlen\')', -5);
-        }
-    }
-    
-} 
-
-?>

Copied: plog/trunk/class/cache/Cache_Lite/Lite.php (from rev 2140, plog/branches/plog-1.1-ben/class/cache/Cache_Lite/Lite.php)


Property changes on: plog/trunk/class/cache/Cache_Lite/Lite.php
___________________________________________________________________
Name: svn:executable
   + *

Deleted: plog/trunk/class/cache/bloginfomanager.class.php
===================================================================
--- plog/branches/plog-1.1-ben/class/cache/bloginfomanager.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/cache/bloginfomanager.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,60 +0,0 @@
-<?php
-
-    class BlogInfoManager extends Object
-    {
-
-        var $_knownBlogs = array();
-
-        function getBlogInfo( $blogId )
-        {
-            $blogs = new Blogs();
-            $blogInfo = $blogs->getBlogInfo( $blogId );
-            return $blogInfo;
-
-            // not executed
-            if( array_key_exists( $blogId, $this->_knownBlogs) )
-                return $this->_knownBlogs[$blogId];
-
-            require_once( PLOG_CLASS_PATH . "class/cache/cachemanager.class.php" );
-            require_once( PLOG_CLASS_PATH . "class/dao/blogsettings.class.php" );
-
-            $cache =& CacheManager::getCache();
-            $blogInfo = $cache->getData( $blogId, CACHE_BLOGINFOS );
-
-            if( !$blogInfo ) {
-                require_once( PLOG_CLASS_PATH . "class/dao/blogs.class.php" );
-                $blogs = new Blogs();
-                $blogInfo = $blogs->getBlogInfo( $blogId );
-                $cache->setData( $blogId, CACHE_BLOGINFOS, $blogInfo );
-            }
-
-            $this->_knownBlogs[ $blogId ] = $blogInfo;
-            return $blogInfo;
-        }
-
-        function updateBlogInfo( $blogId, $blogInfo )
-        {
-            require_once( PLOG_CLASS_PATH . "class/dao/blogs.class.php" );
-            $blogs = new Blogs(); 
-            return $blogs->updateBlog( $blogId, $blogInfo );
-
-            // remove all cached info
-            $cache =& CacheManager::getCache();
-            $cache->removeData( $blogId, CACHE_BLOGINFOS );
-
-            // save the new blogInfo
-            // this is slow right now, but we don't care at this point
-        }
-
-        function &getBlogInfoManager()
-        {
-            static $manager;
-
-            if( !is_object($manager) ) {
-                $manager = new BlogInfoManager();
-            }
-
-            return $manager;
-        }
-    }
-?>

Copied: plog/trunk/class/cache/bloginfomanager.class.php (from rev 2140, plog/branches/plog-1.1-ben/class/cache/bloginfomanager.class.php)


Property changes on: plog/trunk/class/cache/bloginfomanager.class.php
___________________________________________________________________
Name: svn:executable
   + *

Deleted: plog/trunk/class/cache/cache.class.php
===================================================================
--- plog/branches/plog-1.1-ben/class/cache/cache.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/cache/cache.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,58 +0,0 @@
-<?php
-
-    require_once( PLOG_CLASS_PATH . "class/object/object.class.php" );
-    require_once( PLOG_CLASS_PATH . "class/cache/Cache_Lite/Lite.php" );
-
-   /**
-    * Provides a singleton for storing and retrieving data from a global cache.
-    */
-
-    class Cache extends Object
-    {
-        var $cache;
-
-        function Cache( $cacheProperties )
-        {
-            $this->Object();
-            $this->cache = new Cache_Lite( $cacheProperties );
-        }
-
-        function setData( $id, $group, $data )
-        {
-            $this->log->info("Caching $id ($group):" . $data );
-            return $this->cache->save( $data, $id, $group );
-        }
-
-        function getData( $id, $group )
-        {
-            $inCache = $this->cache->get( $id, $group );
-            if ($inCache) {
-                $this->log->info("Cache hit for $id ($group):" . $data );
-            } else {
-                $this->log->info("Cache miss for $id ($group)" );
-            }
-            return $inCache;
-        }
-
-        function removeData( $id, $group )
-        {
-            $this->log->info("Removing from cache $id ($group)" );
-            return $this->cache->remove( $id, $group );
-        }
-
-        function clearCacheByGroup( $group )
-        {
-            return $this->cache->clean( $group );
-        }
-
-        function clearCache()
-        {
-            return $this->cache->clean();
-        }
-
-        function setCacheDir( $temp_folder )
-        {
-            $this->cache->cacheDir = $temp_folder;
-        }
-    }
-?>

Copied: plog/trunk/class/cache/cache.class.php (from rev 2140, plog/branches/plog-1.1-ben/class/cache/cache.class.php)


Property changes on: plog/trunk/class/cache/cache.class.php
___________________________________________________________________
Name: svn:executable
   + *

Deleted: plog/trunk/class/cache/cachemanager.class.php
===================================================================
--- plog/branches/plog-1.1-ben/class/cache/cachemanager.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/cache/cachemanager.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,72 +0,0 @@
-<?php
-
-    require_once( PLOG_CLASS_PATH . "class/object/object.class.php" );
-
-
-    define( "CACHE_GLOBAL",            "pLog" );
-    define( "CACHE_LOCALES",           "locales" );
-    define( "CACHE_RESOURCES",         "resources" );
-    define( "CACHE_GALLERYALBUM",      "album" );
-    define( "CACHE_USERALBUMS",        "useralbums" );
-    define( "CACHE_USERINFO",          "userinfo" );
-    define( "CACHE_USERIDBYNAME",      "userinfo_idbyname" );
-    define( "CACHE_BLOGINFOS",         "bloginfo" );
-    define( "CACHE_BLOGIDBYNAME",      "bloginfo_idbyname" );
-    define( "CACHE_ARTICLETEXT",       "article_text" );
-    define( "CACHE_TRACKBACKS",        "trackbacks" );
-    define( "CACHE_NUMTRACKBACKS",     "trackbacks_size" );
-    define( "CACHE_CONFIGDBSTORAGE",   "config_db_storage" );
-    define( "CACHE_SITEADMINS",        "permissions_siteadmin" );
-    define( "CACHE_BLOGLINKS",         "blogLinks" );
-    define( "CACHE_MYLINKS",           "myBlogLinks" );
-    define( "CACHE_ARTICLES",          "articles" );
-    define( "CACHE_ARTICLETITLES",     "articles_titles" );
-
-    // :TODO: implement a cache-lifetime per cache-category, so e.g. blogInfo or
-    //        locales have a lifetime of several days, whereas articles, comments,
-    //        etc will only be cached for an hour.
-
-   /**
-    * Provides a singleton for storing and retrieving data from a global cache.
-    */
-
-    class CacheManager extends Object
-    {
-        var $cache;
-
-        function CacheManager()
-        {
-            $this->Object();
-        }
-
-        function clearCache()
-        {
-            $cache =& CacheManager::getInstance();
-            $cache->_clearCache();
-        }
-
-        function &getCache()
-        {
-            static $cache;
-
-            if( $cache == null ) {
-                // source the neccessary files
-                require_once( PLOG_CLASS_PATH . "class/cache/cache.class.php" );
-                require_once( PLOG_CLASS_PATH . "class/config/config.class.php" );
-
-                // damn .. produces a recursion.. need to fix that later on :)
-                // $config     =& Config::getConfig();
-                // $temp_folder = $config->getUncachedValue( 'temp_folder' );
-
-                // define defaults
-                $cacheParameter = array(
-                    'cacheDir' => "./tmp/",
-                     );
-
-                // build a new cache object
-                $cache =& new Cache( $cacheParameter);
-            }
-            return $cache;
-        }
-    }
-?>

Copied: plog/trunk/class/cache/cachemanager.class.php (from rev 2140, plog/branches/plog-1.1-ben/class/cache/cachemanager.class.php)


Property changes on: plog/trunk/class/cache/cachemanager.class.php
___________________________________________________________________
Name: svn:executable
   + *

Modified: plog/trunk/class/config/config.class.php
===================================================================
--- plog/trunk/class/config/config.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/config/config.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -98,7 +98,7 @@
 
 	            // if all went fine, get the name for that class
         	    $className = $storageTypes[$storage];
-		    include_once( PLOG_CLASS_PATH.'class/config/'.strtolower($className).'.class.php' );
+                include_once( PLOG_CLASS_PATH.'class/config/'.strtolower($className).'.class.php' );
 	            // and create an object
         	    $configInstance[$storage] = new $className( $params );
             }

Modified: plog/trunk/class/config/configdbstorage.class.php
===================================================================
--- plog/trunk/class/config/configdbstorage.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/config/configdbstorage.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,9 +1,10 @@
 <?php
 
-	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
-	include_once( PLOG_CLASS_PATH."class/config/configfilestorage.class.php" );
-	include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
+    include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
+    include_once( PLOG_CLASS_PATH."class/config/configfilestorage.class.php" );
+	include_once( PLOG_CLASS_PATH."class/cache/cachemanager.class.php" );
 
+
     /**
 	 * \ingroup Config
 	 *
@@ -34,27 +35,51 @@
         var $_db;
 
         // array used to store the options
-        var $_data;
+        var $_data = array();
 		
     	// information needed to connect to the db server
         var $_dbPrefix;		
+
+		// cache object
+		var $_cache;
         
         /**
          * Connects to the database using the parameters in the config file.
          *
          */
-    	function ConfigDbStorage( $params = null )
+    	function ConfigDbStorage()
         {            
-            // initialize the connection
-            $this->_db =& Db::getDb();
-            // get the prefix
-            $this->_dbPrefix = Db::getPrefix();
+		    $this->_cache =& CacheManager::getCache();
+        }
 
-            // and finally, load the whole data
+        function _loadAllValuesFromDatabase() {
+            // initialize the database
+            $this->_initializeDatabase();
+
+            // load the whole data
             $this->_loadData();
+
+            // and build the cache
+            $this->_cache->setData( CACHE_CONFIGDBSTORAGE, CACHE_GLOBAL, $this->_data );
         }
 
         /**
+         * Initialize the Database to allow db access
+         *
+         */
+        function _initializeDatabase() {
+            if ($this->_db == null) {
+                // source the neccessary class files
+                include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
+
+                // initialize the connection
+                $this->_db =& Db::getDb();
+                // get the prefix
+                $this->_dbPrefix = Db::getPrefix();
+            }
+        }
+
+        /**
          * Internal function that loads all the data from the table and puts in into
          * our array. It should be apparently faster that making an SQL query every time
          * we need to get a value.
@@ -98,12 +123,39 @@
 
         function getValue( $key, $defaultValue = null )
         {
-            if(!array_key_exists($key, $this->_data) ||
-                $this->_data[$key] == "" || 
-                $this->_data[$key] == null) {
-                return $defaultValue;
+            if (!is_object( $this->_cache )) {
+                $this->_cache =& CacheManager::getCache();
+            }
+            if($this->_data == array()) {
+                $data = $this->_data = $this->_cache->getData( CACHE_CONFIGDBSTORAGE, CACHE_GLOBAL );
+                if ($data) {
+                    $this->_data = $data;
+                } else {
+                    $this->_loadAllValuesFromDatabase();
+                }
+            }
+
+            if( array_key_exists($key, $this->_data) ) {
+                if ($this->_data[$key] == "" || $this->_data[$key] == null) {
+                    return $defaultValue;
+                } else {
+                    return $this->_data[$key];
+                }
+            }
+        }
+
+        function getUncachedValue( $key, $defaultValue = null )
+        {
+            if($this->_data == array()) {
+                $this->_loadAllValuesFromDatabase();
             } else {
-                return $this->_data[$key];
+                if(array_key_exists($key, $this->_data)) {
+                    if ($this->_data[$key] == "" || $this->_data[$key] == null) {
+                        return $defaultValue;
+                    } else {
+                        return $this->_data[$key];
+                    }
+                }
             }
         }
 
@@ -148,8 +200,11 @@
          */
         function _keyExists( $key )
         {
-        	$query = "SELECT * FROM ".$this->_dbPrefix."config WHERE config_key = '$key'";
+            // initialize the database
+            $this->_initializeDatabase();
 
+            $query = "SELECT * FROM ".$this->_dbPrefix."config WHERE config_key = '$key'";
+
             //$this->_db->debug=true;
             $result = $this->_db->Execute( $query );
 
@@ -167,6 +222,9 @@
 		 */
         function _updateValue( $key, $value )
         {
+            // initialize the database
+            $this->_initializeDatabase();
+
         	// if the key exists, we have to update it
             $type = $this->_getType( $value );
             switch( $type ) {
@@ -204,6 +262,9 @@
 		 */
         function _insertValue( $key, $value )
         {
+            // initialize the database
+            $this->_initializeDatabase();
+
         	$type = $this->_getType( $value );
             switch( $type ) {
             	case TYPE_INTEGER:
@@ -252,6 +313,9 @@
             	$this->saveValue( $key, $value );
             }
 
+            // update the cache
+            $this->_cache->setData( CACHE_CONFIGDBSTORAGE, CACHE_GLOBAL, $this->_data );
+
             // saveValue is already reloading the data for us everytime!
             return true;
         }
@@ -277,8 +341,12 @@
                  $result = $this->_insertValue( $key, $value );
             }
 
+            // update the cache
+            $this->_data[$key] = $value;
+            $this->_cache->removeData( CACHE_CONFIGDBSTORAGE, CACHE_GLOBAL );
+
             // we better reload the data just in case
-            $this->reload();
+            // $this->reload();
 
             return $result;
         }

Modified: plog/trunk/class/config/properties.class.php
===================================================================
--- plog/trunk/class/config/properties.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/config/properties.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -53,10 +53,6 @@
                 return $defaultValue;
             } else {
 			    $value = $this->_props[$key];
-			    if( empty($value) )
-                    if( $defaultValue != null )
-                        $value = $defaultValue;
-					
                 return $value;
             }
 		}

Modified: plog/trunk/class/controller/controller.class.php
===================================================================
--- plog/trunk/class/controller/controller.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/controller/controller.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -17,7 +17,6 @@
 
     include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
     include_once( PLOG_CLASS_PATH."class/action/action.class.php" );
-    include_once( PLOG_CLASS_PATH."class/action/actioninfo.class.php" );
 	include_once( PLOG_CLASS_PATH."class/controller/resourceclassloader.class.php" );
 
     //
@@ -258,6 +257,8 @@
          */
         function process( $httpRequest )
         {
+            include_once( PLOG_CLASS_PATH."class/net/request.class.php" );
+
             // get the name of the action
             $request = new Request( $httpRequest );
             $actionName = $request->getValue($this->_actionParam );
@@ -292,6 +293,8 @@
                 }
 
                 if( !$performed ) {
+                    include_once( PLOG_CLASS_PATH."class/action/actioninfo.class.php" );
+
                     // load the class if it hasn't been loaded yet
                     $this->loadActionClass( $actionClass );
 

Modified: plog/trunk/class/dao/article.class.php
===================================================================
--- plog/trunk/class/dao/article.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/article.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -2,14 +2,9 @@
 
 	include_once( PLOG_CLASS_PATH.'class/dao/articles.class.php' );
 	include_once( PLOG_CLASS_PATH.'class/object/object.class.php' );
-	include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
 	include_once( PLOG_CLASS_PATH.'class/dao/userinfo.class.php' );
-	include_once( PLOG_CLASS_PATH.'class/dao/bloginfo.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/articlecategory.class.php' );
     include_once( PLOG_CLASS_PATH.'class/dao/articlestatus.class.php' );
-	include_once( PLOG_CLASS_PATH.'class/data/textfilter.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/trackbacks.class.php' );	
-    include_once( PLOG_CLASS_PATH.'class/dao/customfields/customfieldsvalues.class.php' );	
+	include_once( PLOG_CLASS_PATH.'class/dao/articlecommentstatus.class.php' );
 
     define( 'POST_EXTENDED_TEXT_MODIFIER', '[@more@]' );
 
@@ -66,6 +61,8 @@
          */
 		function Article( $topic, $text, $categories, $user, $blog, $status, $numReads, $properties = Array(), $slug = "", $id = -1 )
 		{
+            include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
+
 			$this->_topic    = $topic;
 			$this->_text     = $text;
 			$this->_categoryIds = $categories;
@@ -77,7 +74,10 @@
             $this->_totalComments = 0;
             $this->_numTrackbacks = 0;
             $this->_numReads = $numReads;
-			if( $slug == "" ) $this->_slug = Textfilter::urlize( $topic );
+			if( $slug == "" ) {
+	            include_once( PLOG_CLASS_PATH.'class/data/textfilter.class.php' );
+                $this->_slug = Textfilter::urlize( $topic );
+            }
 			else $this->setPostSlug( $slug );
 			
 			// by default it'll have current time
@@ -227,6 +227,11 @@
         /**
          * The identifier of the user who posted this comment
          *
+         * NOTE: This is rather disturbing, i would expect to get a User Object
+         * when calling getUser(), i've added getUserId() which is more 
+         * precise, but left this one in here to stay backward compatible.
+         *
+         * @deprecated Use getUserId() instead
          * @return An integer value representing the user idenfitier.
          * @see getUserInfo
          */
@@ -235,6 +240,11 @@
 			return $this->_user;
 		}
 
+        function getUserId()
+        {
+			return $this->_user;
+        }
+
         /**
          * Returns the date, 14-digit format straight from the database.
          *
@@ -293,7 +303,8 @@
 				include_once( PLOG_CLASS_PATH.'class/dao/trackbacks.class.php' );			
 				$trackbacks =  new Trackbacks();
 				$blogSettings = $this->_blogInfo->getSettings();
-				$this->setTrackbacks( $trackbacks->getArticleTrackBacks( $this->getId(), COMMENT_STATUS_ALL ));
+				$this->setTrackbacks( $trackbacks->getArticleTrackBacks( $this->getId(), 
+                                                                         COMMENT_STATUS_ALL ));
 			}
 
 			// if we only want to return the active ones, then we have to loop through
@@ -332,6 +343,11 @@
         /**
          * Returns the blog identifier to which this article belongs.
          *
+         * NOTE: This is rather disturbing, i would expect to get a Blog Object
+         * when calling getBlog(), i've added getBlogId() which is more 
+         * precise, but left this one in here to stay backward compatible.
+         *
+         * @deprecated Use getBlogId() instead
          * @return An integer value representing the blog identifier.
          * @see getBlogInfo
          */
@@ -341,6 +357,17 @@
 		}
 
         /**
+         * Returns the blog identifier to which this article belongs.
+         *
+         * @return An integer value representing the blog identifier.
+         * @see getBlogInfo
+         */
+        function getBlogId()
+        {
+			return $this->_blog;
+        }
+
+        /**
          * Returns the status of the article:
          * <ul><li>published</li><li>draft</li><li>deleted</li></ul>
          *
@@ -606,6 +633,8 @@
          */
 		function setDate( $newDate )
 		{
+            include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
+
 			$this->_date = $newDate;
 
 			$this->_timestamp = new Timestamp( $newDate );
@@ -711,6 +740,7 @@
 		function getFields()
 		{
 			if( $this->_fields == null ) {
+                include_once( PLOG_CLASS_PATH.'class/dao/customfields/customfieldsvalues.class.php' );	
 				// get the custom fields
 				$customFields = new CustomFieldsValues();
 				$fields = $customFields->getArticleCustomFieldsValues( $this->getId(), $this->getBlog());
@@ -802,10 +832,12 @@
 		 */
 		function getPostSlug()
 		{
-			if( $this->_slug == "" )
+			if( $this->_slug == "" ) {
+                include_once( PLOG_CLASS_PATH.'class/data/textfilter.class.php' );
 				$slug = Textfilter::urlize( $this->getTopic());
-			else
+			} else {
 				$slug = $this->_slug;
+            }
 				
 			return $slug;
 		}
@@ -817,6 +849,7 @@
 		 */
 		function setPostSlug( $slug )
 		{
+            include_once( PLOG_CLASS_PATH.'class/data/textfilter.class.php' );
 			$this->_slug = Textfilter::urlize( $slug );
 		}
 

Modified: plog/trunk/class/dao/articlecategory.class.php
===================================================================
--- plog/trunk/class/dao/articlecategory.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/articlecategory.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -25,6 +25,8 @@
 
 		function ArticleCategory( $name, $url, $blogId, $inMainPage, $description = "", $numArticles = 0, $properties = Array(), $id = -1, $lastModification=null, $parentId = null)
 		{
+	        include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
 			$this->DbObject();
 			$this->_name = $name;
             $this->_url = $url;
@@ -178,6 +180,8 @@
 		 */
 		function getArticles( $status = POST_STATUS_PUBLISHED )
 		{
+	        include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+
 			if( !is_array( $this->_articles[$status] ) || $this->_articles[$status] == null ) {
 				$articles = new Articles();
 				// you've got to love these huge method calls...

Modified: plog/trunk/class/dao/articlecomments.class.php
===================================================================
--- plog/trunk/class/dao/articlecomments.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/articlecomments.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,227 +1,230 @@
-<?php
-
-	include_once( PLOG_CLASS_PATH."class/dao/commentscommon.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/usercomment.class.php" );
-
-    /**
-	 * \ingroup DAO
-	 *
-     * Model for the comments each article can have
-     */
-	class ArticleComments extends CommentsCommon 
-	{
-
-    	function ArticleComments()
-        {
-        	$this->CommentsCommon();
-        }
-
-		/**
-		 * Retrieves all the comments for a post
-		 *
-		 * @param artid The article identifier
-		 * @param order The order in which comments should be retrieved
-		 * @param status The status that the comment should have, use COMMENT_STATUS_ALL for
-		 * all possible statuses
-		 * @param page
-		 * @param itemsPerPage
-		 * @return False if error or an array of ArticleComments objects
-		 */
-		function getPostComments( $artid, $order = COMMENT_ORDER_NEWEST_FIRST, $status = COMMENT_STATUS_ALL, $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
-		{
-			return( CommentsCommon::getPostComments( $artid, $order, $status, COMMENT_TYPE_COMMENT, $page, $itemsPerPage ));
-		}
-		
-		/**
-		 * Retrieves all the comments for subquery of posts
-		 *
-		 * @private
-		 */
-		function getPostCommentsByIds( $ids, $order = COMMENT_ORDER_NEWEST_FIRST, $status = COMMENT_STATUS_ALL )
-		{
-			return( CommentsCommon::getPostCommentsByIds( $ids, $order, $status, COMMENT_TYPE_COMMENT ));
-		}
-		
-        /**
-         * Returns the total number of comments for a post
-		 *
-		 * @param artId the post id
-		 * @param status
-		 * @return The number of comments
-         */
-        function getNumPostComments( $artId, $status = COMMENT_STATUS_ALL )
-        {
-			return( CommentsCommon::getNumPostComments( $artId, $status, COMMENT_TYPE_COMMENT ));
-        }
-
-        /**
-         * Retrieves only one post from a given article
-         */
-        function getPostComment( $artid, $commentid )
-		{
-			return( CommentsCommon::getPostComment( $artid, $commentid, COMMENT_TYPE_COMMENT ));			
-		}
-
-        /**
-         * Returns true if there already is a comment in the database with the same
-         * article_id field, topic, text, replying to the same comment, username and so on
-         * Useful in case we want to check if the user sent the same comment by mistake
-         * by pressing the 'reload' button twice or something...
-         *
-         * @return Returns true if there already is such comment or false otherwise.
-         */
-        function getIdenticalComment( $topic, $text, $articleId, $parentId = 0, $userName = "", $userEmail = "", $userUrl = "", $clientIp = "0.0.0.0" )
-        {
-			return( CommentsCommon::getIdenticalComment( $topic, $text, $articleId,
-			                                             $parentId, $userName, $userEmail,
-														 $userUrl, $clientIp, COMMENT_TYPE_COMMENT ));
-        }
-
-        /**
-         * code factored out and made to be reused through several functions here...
-         */
-        function _fillCommentInformation( $row )
-        {
-        	// ---
-            // this stuff is another disgusting hack to make comments
-            // be aware of time differences that may have been set by
-            // users in their blogs... actually, it will make the whole
-            // thing run a little bit slower because for every article
-            // that we fetch, we need to know the time difference
-            // and that means, additional accesses to the database :(
-            // But hey, users demand these things and we are not in the position
-            // to deny anything, are we? :P
-            // ---
-            // at the same time, we're going to brake some of our "nicely"
-            // implemented bussiness logic with the query below, bypassing all
-            // our objects and directly fetching info from the database, just for
-            // the sake of being able to do things with a single query rather
-            // than needing at least two to do the same. We would have to first
-            // find to which blog the given article belongs and then use another
-            // query to find its settings... If we do it this way, we can still
-            // do it in one query and get a nice BlogSettings object with the
-            // information that we need. Dirty but works :S
-            // ---
-            $prefix = $this->getPrefix();
-            $date = $row["date"];
-            $articleId = $row["article_id"];
-
-            // let's try and keep some kind of cache for this...
-            if( empty($this->_blogSettings[$articlId])) {
-            	$query = "SELECT DISTINCT b.settings AS settings
-                          FROM {$prefix}blogs b, {$prefix}articles a,
-                          {$prefix}articles_comments c
-                          WHERE c.article_id = a.id AND
-                          a.blog_id = b.id
-                          AND a.id = $articleId";
-                $result = $this->Execute( $query );
-				if( !$result ) 
-					return false;
-				
-                $tmpRow = $result->FetchRow();
-                $blogSettings = Blogs::getBlogSettingsFromField( $tmpRow["settings"] );
-                $this->_blogSettings[$articleId] = $blogSettings;
-            }
-            else {
-            	$blogSettings = $this->_blogSettings[$articleId];
-            }
-
-            $timeDiff = $blogSettings->getValue( "time_offset" );
-            // now that we've got the time difference, we can
-            // calculate what would the "real" date...
-            $date = Timestamp::getDateWithOffset( $date, $timeDiff );
-
-        	$comment = new UserComment( $row["article_id"],
-            							$row["parent_id"],
-                                        $row["topic"],
-                                        $row["text"],
-                                        $date,
-                                        $row["user_name"],
-                                        $row["user_email"],
-                                        $row["user_url"],
-                                        $row["client_ip"],
-                                        $row["spam_rate"],
-                                        $row["status"],
-                                        $row["id"] );
-
-            return $comment;
-        }
-
-		/**
-		 * Removes a comment from a post. It also updates all the other posts that
-         * have this one as the parent and makes them look as if they were 'top level'
-         * comments with no parent.
-         *
-         * @param artid The article identifier.
-         * @param commentid The comment identifier.
-		 */
-		function deletePostComment( $artid, $commentid )
-		{
-			return( CommentsCommon::deletePostComment( $artid, $commentid, COMMENT_TYPE_COMMENT ));
-		}
-		
-		/**
-		 * Removes a comment from a post. It also updates all the other posts that
-         * have this one as the parent and makes them look as if they were 'top level'
-         * comments with no parent.
-         *
-         * @param commentid The comment identifier.
-         * @param articleId The article identifier.		 
-		 */
-		function deleteComment( $commentid, $articleId = -1 )
-		{
-			return( $this->deletePostComment( $articleId, $commentid ));
-		}		
-
-        /**
-         * Removes all the comments from a post.
-         *
-         * @param artId The article identifier
-         */
-        function deletePostComments( $artId )
-        {
-			return( CommentsCommon::deletePostComments( $artId, COMMENT_TYPE_COMMENT ));
-        }
-
-        /**
-         * updates the status of a comment, regarding its spam status...
-         *
-         * @param commentId
-         * @param status
-         * @return true or false, depending...
-         */
-        function updateCommentStatus( $commentId, $status )
-        {
-			return( CommentsCommon::updateCommentStatus( $commentId, $status, COMMENT_TYPE_COMMENT ));
-        }
-
-        /**
-         * removes all comments marked as spam from the database
-         */
-        function purgeSpamComments()
-        {
-			return( CommentsCommon::purgeSpamComments( COMMENT_TYPE_COMMENT ));
-        }
-		
-		
-		/**
-		 * returns a single comment, identified by its... identifier :)
-		 */
-		function getComment( $id )
-		{
-			return( CommentsCommon::getComment( $id, COMMENT_TYPE_COMMENT ));
-		}
-		
-		/**
-		 * returns the lastest $maxItems comments received in the blog
-		 *
-		 * @param blogId
-		 * @param maxItems
-		 * @return An array of ArticleComment objects
-		 */
-		function getBlogComments( $blogId, $maxItems = 0, $articleStatus = POST_STATUS_PUBLISHED )
-		{
-			return( CommentsCommon::getBlogComments( $blogId, $maxItems, $articleStatus, COMMENT_TYPE_COMMENT ));
-		}
-	}
-?>
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/dao/commentscommon.class.php" );
+	include_once( PLOG_CLASS_PATH."class/dao/usercomment.class.php" );
+
+    /**
+	 * \ingroup DAO
+	 *
+     * Model for the comments each article can have
+     */
+	class ArticleComments extends CommentsCommon 
+	{
+
+    	function ArticleComments()
+        {
+        	$this->CommentsCommon();
+        }
+
+		/**
+		 * Retrieves all the comments for a post
+		 *
+		 * @param artid The article identifier
+		 * @param order The order in which comments should be retrieved
+		 * @param status The status that the comment should have, use COMMENT_STATUS_ALL for
+		 * all possible statuses
+		 * @param page
+		 * @param itemsPerPage
+		 * @return False if error or an array of ArticleComments objects
+		 */
+		function getPostComments( $artid, $order = COMMENT_ORDER_NEWEST_FIRST, $status = COMMENT_STATUS_ALL, $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+		{
+			return( CommentsCommon::getPostComments( $artid, $order, $status, COMMENT_TYPE_COMMENT, $page, $itemsPerPage ));
+		}
+		
+		/**
+		 * Retrieves all the comments for subquery of posts
+		 *
+		 * @private
+		 */
+		function getPostCommentsByIds( $ids, $order = COMMENT_ORDER_NEWEST_FIRST, $status = COMMENT_STATUS_ALL )
+		{
+			return( CommentsCommon::getPostCommentsByIds( $ids, $order, $status, COMMENT_TYPE_COMMENT ));
+		}
+		
+        /**
+         * Returns the total number of comments for a post
+		 *
+		 * @param artId the post id
+		 * @param status
+		 * @return The number of comments
+         */
+        function getNumPostComments( $artId, $status = COMMENT_STATUS_ALL )
+        {
+			return( CommentsCommon::getNumPostComments( $artId, $status, COMMENT_TYPE_COMMENT ));
+
+        }
+
+        /**
+         * Retrieves only one post from a given article
+         */
+        function getPostComment( $artid, $commentid )
+		{
+			return( CommentsCommon::getPostComment( $artid, $commentid, COMMENT_TYPE_COMMENT ));			
+		}
+
+        /**
+         * Returns true if there already is a comment in the database with the same
+         * article_id field, topic, text, replying to the same comment, username and so on
+         * Useful in case we want to check if the user sent the same comment by mistake
+         * by pressing the 'reload' button twice or something...
+         *
+         * @return Returns true if there already is such comment or false otherwise.
+         */
+        function getIdenticalComment( $topic, $text, $articleId, $parentId = 0, $userName = "", $userEmail = "", $userUrl = "", $clientIp = "0.0.0.0" )
+        {
+			return( CommentsCommon::getIdenticalComment( $topic, $text, $articleId,
+			                                             $parentId, $userName, $userEmail,
+														 $userUrl, $clientIp, COMMENT_TYPE_COMMENT ));
+        }
+
+        /**
+         * code factored out and made to be reused through several functions here...
+         */
+        function _fillCommentInformation( $row )
+        {
+            require_once( PLOG_CLASS_PATH."class/dao/usercomment.class.php" );
+            require_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+        	// ---
+            // this stuff is another disgusting hack to make comments
+            // be aware of time differences that may have been set by
+            // users in their blogs... actually, it will make the whole
+            // thing run a little bit slower because for every article
+            // that we fetch, we need to know the time difference
+            // and that means, additional accesses to the database :(
+            // But hey, users demand these things and we are not in the position
+            // to deny anything, are we? :P
+            // ---
+            // at the same time, we're going to brake some of our "nicely"
+            // implemented bussiness logic with the query below, bypassing all
+            // our objects and directly fetching info from the database, just for
+            // the sake of being able to do things with a single query rather
+            // than needing at least two to do the same. We would have to first
+            // find to which blog the given article belongs and then use another
+            // query to find its settings... If we do it this way, we can still
+            // do it in one query and get a nice BlogSettings object with the
+            // information that we need. Dirty but works :S
+            // ---
+            $prefix = $this->getPrefix();
+            $date = $row["date"];
+            $articleId = $row["article_id"];
+
+            // let's try and keep some kind of cache for this...
+            if( empty($this->_blogSettings[$articlId])) {
+            	$query = "SELECT DISTINCT b.settings AS settings
+                          FROM {$prefix}blogs b, {$prefix}articles a,
+                          {$prefix}articles_comments c
+                          WHERE c.article_id = a.id AND
+                          a.blog_id = b.id
+                          AND a.id = $articleId";
+                $result = $this->Execute( $query );
+				if( !$result ) 
+					return false;
+				
+                $tmpRow = $result->FetchRow();
+                $blogSettings = Blogs::getBlogSettingsFromField( $tmpRow["settings"] );
+                $this->_blogSettings[$articleId] = $blogSettings;
+            }
+            else {
+            	$blogSettings = $this->_blogSettings[$articleId];
+            }
+
+            $timeDiff = $blogSettings->getValue( "time_offset" );
+            // now that we've got the time difference, we can
+            // calculate what would the "real" date...
+            $date = Timestamp::getDateWithOffset( $date, $timeDiff );
+
+        	$comment = new UserComment( $row["article_id"],
+            							$row["parent_id"],
+                                        $row["topic"],
+                                        $row["text"],
+                                        $date,
+                                        $row["user_name"],
+                                        $row["user_email"],
+                                        $row["user_url"],
+                                        $row["client_ip"],
+                                        $row["spam_rate"],
+                                        $row["status"],
+                                        $row["id"] );
+
+            return $comment;
+        }
+
+		/**
+		 * Removes a comment from a post. It also updates all the other posts that
+         * have this one as the parent and makes them look as if they were 'top level'
+         * comments with no parent.
+         *
+         * @param artid The article identifier.
+         * @param commentid The comment identifier.
+		 */
+		function deletePostComment( $artid, $commentid )
+		{
+			return( CommentsCommon::deletePostComment( $artid, $commentid, COMMENT_TYPE_COMMENT ));
+		}
+		
+		/**
+		 * Removes a comment from a post. It also updates all the other posts that
+         * have this one as the parent and makes them look as if they were 'top level'
+         * comments with no parent.
+         *
+         * @param commentid The comment identifier.
+         * @param articleId The article identifier.		 
+		 */
+		function deleteComment( $commentid, $articleId = -1 )
+		{
+			return( $this->deletePostComment( $articleId, $commentid ));
+		}		
+
+        /**
+         * Removes all the comments from a post.
+         *
+         * @param artId The article identifier
+         */
+        function deletePostComments( $artId )
+        {
+			return( CommentsCommon::deletePostComments( $artId, COMMENT_TYPE_COMMENT ));
+        }
+
+        /**
+         * updates the status of a comment, regarding its spam status...
+         *
+         * @param commentId
+         * @param status
+         * @return true or false, depending...
+         */
+        function updateCommentStatus( $commentId, $status )
+        {
+			return( CommentsCommon::updateCommentStatus( $commentId, $status, COMMENT_TYPE_COMMENT ));
+        }
+
+        /**
+         * removes all comments marked as spam from the database
+         */
+        function purgeSpamComments()
+        {
+			return( CommentsCommon::purgeSpamComments( COMMENT_TYPE_COMMENT ));
+        }
+		
+		
+		/**
+		 * returns a single comment, identified by its... identifier :)
+		 */
+		function getComment( $id )
+		{
+			return( CommentsCommon::getComment( $id, COMMENT_TYPE_COMMENT ));
+		}
+		
+		/**
+		 * returns the lastest $maxItems comments received in the blog
+		 *
+		 * @param blogId
+		 * @param maxItems
+		 * @return An array of ArticleComment objects
+		 */
+		function getBlogComments( $blogId, $maxItems = 0, $articleStatus = POST_STATUS_PUBLISHED )
+		{
+			return( CommentsCommon::getBlogComments( $blogId, $maxItems, $articleStatus, COMMENT_TYPE_COMMENT ));
+		}
+	}
+?>

Modified: plog/trunk/class/dao/articlenotifications.class.php
===================================================================
--- plog/trunk/class/dao/articlenotifications.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/articlenotifications.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -2,9 +2,6 @@
 
 	include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/articlenotification.class.php" );
-    include_once( PLOG_CLASS_PATH."class/mail/emailmessage.class.php" );
-    include_once( PLOG_CLASS_PATH."class/mail/emailservice.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
 	include_once( PLOG_CLASS_PATH."class/template/templateservice.class.php" );
 
@@ -81,7 +78,10 @@
           */
          function notifyUser( $notification, $userInfo, $subject, $body, $charset = 'iso-8859-1' )
          {
-         	//print( "sending notification to ".$userInfo->getEmail()."<br/>");
+            include_once( PLOG_CLASS_PATH."class/mail/emailservice.class.php" );
+            include_once( PLOG_CLASS_PATH."class/mail/emailmessage.class.php" );
+
+            // $this->log->info( "sending notification to ".$userInfo->getEmail());
             $message = new EmailMessage();
             $message->setFrom( $this->_config->getValue( "post_notification_source_address" ));
             $message->addTo( $userInfo->getEmail());
@@ -101,6 +101,8 @@
           */
          function notifyUsers( $postId, $blogInfo, $message = null)
          {
+            include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
+
          	$blogId = $blogInfo->getId();
          	$artNotifs = $this->getArticleNotifications( $postId, $blogId );
 

Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/articles.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -2,19 +2,8 @@
 
     include_once( PLOG_CLASS_PATH.'class/dao/model.class.php' );
     include_once( PLOG_CLASS_PATH.'class/dao/article.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/articlecategories.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/articlenotifications.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/articlecommentstatus.class.php' );	
-    include_once( PLOG_CLASS_PATH.'class/dao/users.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/trackbacks.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
+    include_once( PLOG_CLASS_PATH.'class/dao/articlestatus.class.php' );
     include_once( PLOG_CLASS_PATH.'class/config/config.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/blogs.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/data/textfilter.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/customfields/customfieldsvalues.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/customfields/customfields.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/logger/LogUtil.php' );
-
     /**
 	 * \ingroup DAO
 	 *
@@ -22,36 +11,101 @@
      */
     class Articles extends Model
     {
-
         // DAO objects that we keep for later, so that we don't have
         // to create them eeeeevery time!
-        var $categories;
-        var $comments;
-        var $trackbacks;
-        var $users;
-        var $blogs;
-		var $customfields;		
-		var $_blogInfo;
-		var $_blogSettings;
-		var $_timeDiff;
+        var $categories    = null;
+        var $comments      = null;
+        var $trackbacks    = null;
+        var $users         = null;
+        var $blogs         = null;
+		var $customfields  = null;
+		var $_blogInfo     = null;
+		var $_blogSettings = null;
+		var $_timeDiff     = null;
 
         function Articles()
         {
             $this->Model();
-            $this->categories = new ArticleCategories();
-            $this->trackbacks = new Trackbacks();
-            $this->users      = new Users();
-            $this->blogs      = new Blogs();
-			$this->customfields = new CustomFieldsValues();			
-			// fine, this is not very nice but it helps a lot, specially if all the classes
-			// that need to load articles share the same instance		
-			$this->cache      = Array();	
-			$this->_blogInfo  = null;
-			$this->_timeDiff  = 0;
+			$this->_blogInfo     = null;
+			$this->_timeDiff     = 0;
 			$this->_blogsettings = null;
         }
 
         /**
+         * Gets an article from the database, given its id. Also manages the
+         * cache for articles.
+         *
+         * @param articleId Identifier of the article we want to fetch
+         * @return Returns an Article object or 'false' otherwise.
+         */
+        function getArticle( $articleId )
+        {
+            $article = $this->_cache->getData( $articleId, CACHE_ARTICLES );
+
+            if ( !$article ) {
+                include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
+
+                $query = Db::buildSelectQuery( ARTICLES_TABLENAME,
+                                               array(),
+                                               'id',
+                                               $articleId );
+
+                // we send the query and then fetch the first array with the result
+                $result = $this->Execute( $query );
+
+                if ( $result->RecordCount() == 0 )
+                    return false;
+
+                $article = $this->_fillArticleInformation( $result->FetchRow( $result ) );
+
+                $this->_cache->setData( $article->getId(), CACHE_ARTICLES, $article );
+            }
+            return $article;
+        }
+
+        /**
+         * Get all articles of a blog from the database and store it in the cache.
+         * 
+         * @param blogId Identifier of the blog which articles we want to fetch
+         * @return true
+         */
+        function getArticles( $blogId )
+        {
+            require_once( PLOG_CLASS_PATH . 'class/dao/blogarticles.class.php' );
+
+            $blogArticles = $this->_cache->getData( $blogId, CACHE_BLOGARTICLES );
+
+            if( !$blogArticles ) {
+                require_once( PLOG_CLASS_PATH . 'class/database/db.class.php' );
+
+                $prefix = $this->getPrefix();
+
+                // as much as i would like to, i don't know how to use a less complicated
+                // sql statement or how to use an abstract method to build an statement
+                // like this one.
+                $query = "SELECT a.id as id, c.category_id as category_id, a.date as date, 
+                                 a.status as status, a.user_id as user_id
+                          FROM {$prefix}article_categories_link c LEFT JOIN {$prefix}articles a 
+                               ON a.id = c.article_id
+                          WHERE a.blog_id = $blogId
+                          ORDER BY a.date DESC";
+
+                $result = $this->Execute( $query );
+
+                $rows = array();
+                while( $row = $result->FetchRow($result) ) {
+                    $rows[] = $row;
+                }
+
+                $blogArticles = new BlogArticles( $blogId, $rows );
+
+                $this->_cache->setData( $blogId, CACHE_BLOGARTICLES, $blogArticles );
+            }
+
+            return $blogArticles;
+        }
+
+        /**
          * Gets an article from the database, given its id
          *
          * @param artId Identifier of the article we want to fetch
@@ -61,21 +115,18 @@
          */
         function getUserArticle( $artId, $userId = -1 )
         {
-            $query = "SELECT * FROM ".$this->getPrefix()."articles WHERE id = '".Db::qstr($artId)."'";
-            if( $userId != -1 )
-                $query .= " AND user_id = '".Db::qstr($userId)."'";
-            $query .= ";";
-
-            // we send the query and then fetch the first array with the result
-            $result = $this->Execute( $query );
-
-            if ( $result->RecordCount() == 0)
+            $article =  $this->getArticle( $artId );
+            if( !$article )
                 return false;
 
-            $row = $result->FetchRow( $result );
+            if ( $userId != -1 ) {
+                $article      = $this->getArticle( $artId );
+                $articleOwner = $article->getUser();
 
-            $article = $this->_fillArticleInformation( $row );
-
+                if( $articleOwner->getId() != $userId ) {
+                    return false;
+                }
+            }
             return $article;
         }
 
@@ -86,66 +137,108 @@
          * @param blogId If set, the article must belong to the given blog
          * @return Returns an Article object or 'false' otherwise.
          */
-        function getBlogArticle( $artId, $blogId = -1, $includeHiddenFields = true, $date = -1, $categoryId = -1, $userId = -1, $status = POST_STATUS_ALL )
+        function getBlogArticle( $artId, $blogId = -1 )
         {
-			$prefix = $this->getPrefix();
-            $query = "SELECT a.id, a.date,
-			                 a.user_id,a.blog_id,a.status,a.properties,
-							 a.num_reads, a.slug FROM {$prefix}articles a ";
-			// thanks jon for the tip :) You're right that the amount of rows will be too big if we don't really need these
-			// fields!
-			if($categoryId != -1 && $blogId != -1) {
-				$query .= ", {$prefix}articles_categories c, {$prefix}article_categories_link l ";
-			}
-			
-			$query .= "WHERE a.id = ".Db::qstr($artId);
-					 
-            if( $blogId != -1 )
-                $query .= " AND a.blog_id = ".Db::qstr($blogId);
-			if( $date != -1 )
-                $query .= " AND a.date+0 LIKE '$date%'";
-			if( $userId != -1 ) 
-				$query .= " AND a.user_id = ".Db::qstr($userId);
-			if( $categoryId != -1 )
-				$query .= " AND c.id = ".Db::qstr($categoryId)." AND c.id = l.category_id AND a.id = l.article_id";
-			if( $status != POST_STATUS_ALL )
-				$query .= " AND a.status = $status;";			
+            $article = $this->getArticle( $artId );
 
-            return $this->_getBlogArticleFromQuery( $query, $includeHiddenFields );
+            if( !$article )
+                return false;
+
+            if( $blogId != -1 ) {
+                $article     = $this->getArticle( $artId );
+
+                if( $article->getBlogId() != $blogId ) {
+                    return false;
+                }
+            }
+            return $article;
         }
         
         /**
          * Gets an article from the database, given its slug, this is used
          * with the fancy permalinks
+         * This method will always return the first matching article, so
+         * if there're more than one article with the same title, you will
+         * always get only one of them.
          *
+         * :TODO: includeHiddenFields has no meaning, this should be removed
+         * :TODO: this method is rather long, maybe we can shorten it somehow.
+         *
          * @param artTitle Identifier of the article we want to fetch
          * @param blogId If set, the article must belong to the given blog
          * @return Returns an Article object or 'false' otherwise.
          */        
-        function getBlogArticleByTitle( $artTitle, $blogId = -1, $includeHiddenFields = true, $date = -1, $categoryId = -1, $userId = -1, $status = POST_STATUS_PUBLISHED )
+        function getBlogArticleByTitle( $articleTitle, 
+                                        $blogId = -1, 
+                                        $includeHiddenFields = true, 
+                                        $date = -1, 
+                                        $categoryId = -1, 
+                                        $userId = -1, 
+                                        $status = POST_STATUS_PUBLISHED )
         {
-			$prefix = $this->getPrefix();
-            $query = "SELECT a.id, a.date,
-			                 a.user_id,a.blog_id,a.status,a.properties,
-							 a.num_reads, a.slug FROM {$prefix}articles a ";
-			// thanks jon once again :)
-			if($categoryId != -1 && $blogId != -1) {
-				$query .= ",{$prefix}articles_categories c, {$prefix}article_categories_link l ";
-			}
-			$query .= "WHERE a.slug = '".Db::qstr($artTitle)."'";
-            if( $blogId != -1 )
-                $query .= " AND a.blog_id = ".Db::qstr($blogId);
-			if( $date != -1 )
-                $query .= " AND a.date+0 LIKE '$date%'";
-			if( $userId != -1 ) 
-				$query .= " AND a.user_id = ".Db::qstr($userId);
-			if( $categoryId != -1 ) {
-				$query .= " AND c.id = ".Db::qstr($categoryId)." AND c.id = l.category_id AND a.id = l.article_id";
-			}
-				
-            $query .= " AND a.status = $status;";
+            $articleIds = $this->_cache->getData( $articleTitle, CACHE_ARTICLETITLES );
 
-            return $this->_getBlogArticleFromQuery( $query, $includeHiddenFields );
+            if( !$articleIds || empty($articleIds) ) {
+                // ArticleIds are not in the cache, we'll fetch the possible ids
+                // from the database.
+                // We will fetch all articles with the given title, to store the
+                // result in the cache and parse each article later on to find
+                // the correct one.
+                $whereConditions = array();
+                $whereConditions['slug'] = $articleTitle;
+
+                $query = Db::buildSelectQuery( ARTICLES_TABLENAME,
+                                               array('id'),
+                                               $whereConditions );
+
+                $result = $this->Execute( $query );
+
+                if( $result->RecordCount() == 0 ) {
+                    return false;
+                } elseif( $result->RecordCount() == 1 ) {
+                    $row        = $result->FetchRow( $result );
+                    $articleId  = $row['id'];
+                    $articles   = array( $this->getArticle($articleId) );
+                    $articleIds = array( $articleId );
+                } else {
+                    // we have more than just one id found, we need to
+                    // check them all.
+                    $articles   = array();
+                    $articleIds = array();
+
+                    while( $row = $result->FetchRow($result) ) {
+                        $articleId     = $row['id'];
+                        $articles[]    = $this->getArticle( $articleId );
+                        $articlesIds[] = $articlesId;
+                    }
+                }
+                $this->_cache->setData( $articleTitle, CACHE_ARTICLETITLES, $articlesIds );
+            } else {
+                foreach( $articleIds as $articleId ) {
+                    $articles[] = $this->getArticle( $articleId );
+                }
+            }
+
+            foreach( $articles as $article ) {
+                if( $blogId != -1 && $blogId != $article->getBlogId() ) {
+                    // wrong blogId, skip to the next article
+                    continue;
+                }
+                if( $categoryId != -1 && !in_array($categoryId, $article->getCategoryIds()) ) {
+                    // wrong category, skip to the next article
+                    continue;
+                }
+                if( $userId != -1 && $userId != $article->getUserId() ) {
+                    // wrong user, skip to the next article
+                    continue;
+                }
+                if( $status != $article->getStatus() ) {
+                    // wrong status, skip to the next article
+                    continue;
+                }
+                return $article;
+            }
+            return false;
         }
         
         /**
@@ -177,16 +270,27 @@
          */
         function getBlogNextArticle( $article )
         {
+            include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
+
 			// we need to keep the timestamp in mind
 			$date = $article->getDateObject();
-			$articleCorrectedDate = Timestamp::getDateWithOffset( $article->getDate(), -($article->getTimeOffset()));
-			$blogId = $article->getBlog();
+			$articleCorrectedDate = Timestamp::getDateWithOffset( $article->getDate(), 
+                                                                 -($article->getTimeOffset()));
 
-            // gets the article that is just next in time
-            $query = "SELECT * FROM ".$this->getPrefix()."articles 
-			                  WHERE date > '".$articleCorrectedDate."' AND status = '".Db::qstr(POST_STATUS_PUBLISHED)."' 
-							        AND blog_id = '".Db::qstr($blogId)."' ORDER BY date ASC LIMIT 1;";
-			
+            $whereConditions = array();
+            // '=' is the default when calculating the where conditions, but to
+            // have this look uniform, lets add the '=' anyway. :)
+            $whereConditions['blog_id'] = '=' . $article->getBlogId();
+            $whereConditions['date']    = '>' . $articleCorrectedDate;
+            $whereConditions['status']  = '=' . POST_STATUS_PUBLISHED;
+
+            $query = Db::buildSelectQuery( ARTICLES_TABLENAME,
+                                           array(),
+                                           $whereConditions,
+                                           null,
+                                           'date',
+                                           1 );
+
 			return( $this->_getBlogArticleFromQuery( $query, false ));
         }
 
@@ -198,15 +302,28 @@
          */
         function getBlogPrevArticle( $article )
         {
+            include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
+
 			// we need to keep the timestamp in mind
 			$date = $article->getDateObject();
-			$articleCorrectedDate = Timestamp::getDateWithOffset( $article->getDate(), -($article->getTimeOffset()));
-			$blogId = $article->getBlog();			
+			$articleCorrectedDate = Timestamp::getDateWithOffset( $article->getDate(), 
+                                                                 -($article->getTimeOffset()));
+			$blogId = $article->getBlog();
+
+            $whereConditions = array();
+            // '=' is the default when calculating the where conditions, but to
+            // have this look uniform, lets add the '=' anyway. :)
+            $whereConditions['blog_id'] = '=' . $article->getBlogId();
+            $whereConditions['date']    = '<' . $articleCorrectedDate;
+            $whereConditions['status']  = '=' . POST_STATUS_PUBLISHED;
 		
             // gets the article that is just previous in time
-            $query = "SELECT * FROM ".$this->getPrefix()."articles 
-			                   WHERE date < '".$articleCorrectedDate."' AND status = ".POST_STATUS_PUBLISHED." 
-									 AND blog_id = '".Db::qstr($blogId)."' ORDER BY date DESC LIMIT 1;";
+            $query = Db::buildSelectQuery( ARTICLES_TABLENAME,
+                                           array(),
+                                           $whereConditions,
+                                           null,
+                                           'date',
+                                           1 );
 									 
 			return( $this->_getBlogArticleFromQuery( $query, false ));
 		}
@@ -221,303 +338,138 @@
 		 */
 		function searchBlogArticles( $blogId, $searchTerms )
 		{
-			$posts = $this->getBlogArticles( $blogId,
-			                                 -1, // no date
-											 -1, // no amount
-											 0, // no category id
-											 0, // not any status
-											 0, // not belonging to any user id in particular
-											 0, // no maximum date
-											 $searchTerms // the only thing we're taking into account: the search terms!!
-											 );
+            // :TODO: implement this :-)
 												 
 			return $posts;
 		}
 		
 		/**
-		 * builds a WHERE clause for a query
-		 *
-		 * @private
-		 */
-		function buildWhere( $blogid, $date = -1, $amount = -1, $categoryId = 0, $status = 0, $userId = 0, $maxDate = 0, $searchTerms = "", $page = -1, $itemsPerPage = 15 )
-		{
-            $postStatus = $status;
-		    $prefix = $this->getPrefix();
-		    $query = "a.blog_id = ".Db::qstr($blogid);
-            if( $date != -1 )
-                $query .= " AND a.date+0 LIKE '$date%'";
-
-            // the common part "c.id = a.category_id" is needed so that
-            // we don't get one article row as many times as the amount of categories
-            // we have... due to the sql 'join' operation we're carrying out
-            if( $categoryId == -1 )
-                $query .= " AND c.id = l.category_id AND a.id = l.article_id ";
-            else {
-                if( $categoryId > 0 )
-                    $query .= " AND a.id = l.article_id AND l.category_id = $categoryId AND c.id = l.category_id";
-                else {
-                    $query .= " AND c.id = l.category_id AND a.id = l.article_id AND c.in_main_page = 1";
-                }
-            }
-
-            if( $status > 0 )
-                $query .= " AND a.status = '$postStatus'";
-            if( $userId > 0 )
-                $query .= " AND a.user_id = ".Db::qstr($userId);
-            if( $maxDate > 0 )
-                $query .= " AND a.date <= '$maxDate'";
-				
-			// in case there were some search terms specified as parameters...
-			if( $searchTerms != "" ) {
-				// load the class dynamically so that we don't have to waste memory
-				// if we're not going to need it!
-				include_once( PLOG_CLASS_PATH."class/dao/searchengine.class.php" );			
-				$searchEngine = new SearchEngine();
-				
-				// prepare the query string
-				$searchTerms = $searchEngine->_adaptSearchString( $searchTerms );
-				$whereString = $searchEngine->_generateSearchArticlesWhereString( $searchTerms );
-				
-				// and add it to the current search
-				$query .=" AND {$whereString} ";	
-			}
-				
-            if( $categoryId <= 0 )
-                $query .= " GROUP BY a.id ";
-
-                
-            return $query;
-		}
-		
-		/**
 		 * @see getBlogArticles
 		 */
-		function getNumBlogArticles( $blogid, $date = -1, $amount = -1, $categoryId = 0, $status = 0, $userId = 0, $maxDate = 0, $searchTerms = "" )
+		function getNumBlogArticles( $blogId,
+                                     $date = -1,
+                                     $amount = -1,
+                                     $categoryId = 0,
+                                     $status = POST_STATUS_PUBLISHED,
+                                     $userId = 0,
+                                     $maxDate = 0,
+                                     $searchTerms = "" )
 		{		
-            $postStatus = $status;
-		    $prefix = $this->getPrefix();			
-			$where = $this->buildWhere( $blogid, $date, $amount, $categoryId, $status, $userId, $maxDate, $searchTerms, $page, $itemsPerPage );	
-			$query = "SELECT COUNT(*) AS total FROM {$prefix}articles a, {$prefix}articles_categories c, 
-                             {$prefix}article_categories_link l";
-			if( $searchTerms != "" )
-				$query .= ", {$prefix}articles_text t ";
-				
-			if( $searchTerms != "" )
-				$query .= "WHERE t.article_id = a.id AND $where";
-			else
-				$query .= " WHERE $where";			
-				
-			if( $categoryId != -1 )
-				$query .= " GROUP BY a.id";
-                                                                      
-            $result = $this->_db->Execute( $query );
-            
-            if( !$result )
-            	return 0;
-            	            	
-            return $result->RowCount();
+            $articles = $this->getBlogArticles( $blogId, $date, $amount, $categoryId, $status, 
+                                                $userId, $maxDate, $searchTerms );
+
+            return count($articles);
 		}
 
         /**
-         * Returns all the articles for a given blog, according to the conditions specified in the call. If
-         * this function is too cumbersome to use (I reckon it might be, too many parameters that have been
-         * added over time due to new requirements) you may want to have a look at getBlogArticlesByQuery below.
-         * It's some kind of straight-through method that allows free-form SQL queries to be passed.
+         * Returns all the articles for a given blog, according to the conditions specified in 
+         * the call. If this function is too cumbersome to use (I reckon it might be, 
+         * too many parameters that have been added over time due to new requirements).
          *
          * @param blogId Identifier of the blog from where we want to fetch the articles
          * @param date date in MySQL TIMESTAMP(14) format
          * @param amount The maximum amount of posts that we would like to be returned.
-         * @param categoryId A category identifier. If specified, only the posts of the given category will be returned
+         * @param categoryId A category identifier. If specified, only the posts of 
+                             the given category will be returned
          * @param status If specified, only the posts with given status will be returned.
-         * @param userId If specified, only the posts that belong to the specified user will be returned
+         * @param userId If specified, only the posts that belong to the specified user 
+                         will be returned
          * @param maxDate a date in MySQL TIMESTAMP(14)
-		 * @param searchTerms in case we would like to further refine the filtering, we can also use search features
+		 * @param searchTerms in case we would like to further refine the filtering, 
+                              we can also use search features
          * @return Returns an array with all the articles from the given blog
          */
-        function getBlogArticles( $blogid, $date = -1, $amount = -1, $categoryId = 0, $status = 0, $userId = 0, 
-                                  $maxDate = 0, $searchTerms = "", $page = -1 )
+
+        function getBlogArticles( $blogId, 
+                                  $date        = -1, 
+                                  $amount      = -1, 
+                                  $categoryId  = 0, 
+                                  $status      = POST_STATUS_PUBLISHED, 
+                                  $userId      = 0, 
+                                  $maxDate     = 0, 
+                                  $searchTerms = "", 
+                                  $page        = -1 )
         {
-            // build the query
-            // the query gets quite complicated to build because we have to take care of plenty
-            // of conditions, such as the maximum date, the amount, the category,
-            // wether the category has to be shown in the main page or not, etc...
-            $postStatus = $status;
-		    $prefix = $this->getPrefix();
-		    $where = $this->buildWhere( $blogid, $date, $amount, $categoryId, $status, $userId, $maxDate, $searchTerms, $page );
-            $query = "SELECT a.id as id, a.id, a.date,
-                             a.user_id,a.blog_id,a.status,a.properties,
-                             a.num_reads, a.slug, 1 AS relevance FROM {$prefix}articles a, {$prefix}articles_categories c, 
-                             {$prefix}article_categories_link l";
-			if( $searchTerms != "" )
-				$query .= ", {$prefix}articles_text t ";
-			$query .= " WHERE ";
-			if( $searchTerms != "" )
-				$query .= " t.article_id = a.id AND ";
-			$query .= " $where";
-                      
-	
-			// if we're doing a search, we should sort by relevance
-			if( $searchTerms != "" ) {
-				$query .= " ORDER BY relevance";			
-			}
-			else {
-				$query .= " ORDER BY a.date DESC";				
-			}
-			
-            // we don't need limits if we're getting the posts for a given day
-            if( ($amount > 0) && ($date == -1) && ($page == -1 ))
-                $query .= " LIMIT $amount;"; 
-            
-            // in case we're using a paged display
-            if( $page > 0 ) {
-				$start = (($page - 1) * $amount);		        
-				$query .= " LIMIT $start, $amount";   
-            }
-                                                     
-				
-			// execute the query
-            $result = $this->Execute( $query );
+            $blogArticles      = $this->getArticles( $blogId );
+            $requestedArticles = $blogArticles->getArticleIdsByStatus( $status );
 
-            if( !$result )
-                return Array();
-				
-			if( $result->RowCount() == 0 )
-				return Array();
-            
-			$ids='';
+            if( $categoryId > 0 ) 
+                $requestedArticles = $blogArticles->getArticleIdsByCategory( $categoryId, 
+                                                                             $requestedArticles );
+            if( $userId > 0 )
+                $requestedArticles = $blogArticles->getArticleIdsByUserId( $userId,
+                                                                           $requestedArticles );
+            if( $date != -1 )
+                $requestedArticles = $blogArticles->getArticleIdsByDate( $date, 
+                                                                         $requestedArticles );
 
-            while( $row = $result->FetchRow()) {
-            	$ids.='"'.$row["id"].'",';
-                $article = $this->_fillArticleHeaderInformation( $row );
-		        $articles[] =$article;
-            }
+            if( $maxDate != 0 )
+                $requestedArticles = $blogArticles->getArticleIdsBefore( $maxDate, 
+                                                                         $requestedArticles );
 
-            $ids = substr($ids, 0, -1);          
-			$articleCategories = $this->categories->getArticleCategoriesByIds( $ids, $blogid );
-			$articleTexts = $this->getArticlesText( $ids );
-            
-            foreach( $articles as $article ) {
-            	$lastArticleId=$article->getId();
-            	// These are functions normally called by _fillArticleInformation
-				// But now I moved to test getPostCommentsByIds
-				$categoryIds = Array();
-				
-				// fill in the article texts
-				$article->setText( $articleTexts[$lastArticleId]['text'] );
-				$article->setTopic( $articleTexts[$lastArticleId]['topic'] );
-				
-				foreach( $articleCategories[$lastArticleId] as $category )
-					$categoryIds[] = $category->getId();
-					
-				$article->setCategoryIds( $categoryIds );
-				$article->setCategories( $articleCategories[$lastArticleId] );
-				//$article->setNumTrackbacks(sizeof($articleTrackbacks[$lastArticleId]));
-				//$article->setTrackbacks($articleTrackbacks[$lastArticleId]);
-				//$article->setTotalComments(sizeof($articleComments[$lastArticleId]));
-				//$article->setComments($articleComments[$lastArticleId]);
-				//$article->setFields( $fields[$lastArticleId] );
+            if( $searchTerms != '' )
+                $requestedArticles = $this->searchArticles( $searchTerms, $requestedArticles );
 
-				$fullarticles[]=$article;
-				$this->cache[$lastArticleId] = $article;       
+            if( ($amount > 0) && ($date == -1) && ($page == -1 ) )
+                $requestedArticles = array_slice( $requestedArticles, 0, $amount );
+
+            if( $page > 0 ) {
+				$start = (($page - 1) * $amount);
+                $requestedArticles = array_slice( $requestedArticles, $start, $amount );
             }
-            
-            return $fullarticles;
-        }
 
-		/**
-		 * Takes an article name and returns the id
-		 * @param articleName an article "name" (the post 'slug')
-		 * @return articleId or 0 if unsuccessful
-		 */
-        function getArticleIdFromName($articleName){
-            $query = "SELECT id FROM ".$this->getPrefix()."articles ".
-                     " WHERE slug = '".Db::qstr($articleName)."'";
-
-            $result = $this->Execute($query);
-
-            if($row = $result->FetchRow()){
-			  if($row["id"])
-				return $row["id"];
-			}
-            return 0;
-        }		
-
-
-		
-		/**
-		 * returns the text of a bunch of articles, given their ids
-		 *
-		 * @param articleIds
-		 * @return an array, where the key is the article id and the value is an another associative array with the
-		 * text and topics of the articles
-		 */
-		function getArticlesText( $articleIds )
-		{
-			$prefix = $this->getPrefix();
-			$query = "SELECT article_id,text,topic FROM {$prefix}articles_text WHERE
-			          article_id IN (".$articleIds.")";
-					  
-            $result = $this->Execute( $query );
-
-            // it's impossible that an article has no categories, but
-            // we'll bear with it...
-            if( !$result )
-                return Array();
-
-            // otherwise, fetch them
-            while ($row = $result->FetchRow()) {
-            	$lastArticleId=$row["article_id"];
-                $postTexts[$lastArticleId]=$row;
-			}
-			
-			return( $postTexts );
-		}
-
-        /**
-         * Returns all the articles for a given blog (takes a query string as an argument).
-         *
-         * @param query A valid SQL query that will be used to generate a list of articles to fetch.
-         * @return Returns an Array filled with Article objects or an empty array if none could be found or
-         * the query was invalid.
-         */
-        function getBlogArticlesByQuery( $query )
-        {
-            $result = $this->Execute( $query );
-            if( !$result ) return Array();
-            $articles = Array();
-            while( $row = $result->FetchRow()) {
-                $article = $this->_fillArticleInformation( $row );
-				$articles[] = $article;
+            $articles = array();
+            foreach( $requestedArticles as $article ) {
+                $articles[] = $this->getArticle( $article );
             }
             return $articles;
         }
-
+		
         /**
          * Gets the number of posts per month per year from the database
          *
-         * @param blogId The numeric identifier of the blog from which we'd like to calculate this values
+         * @param blogId The numeric identifier of the blog from which we'd like to 
+                         calculate this values
          * @return A 2-dimensional associative array where the first index is the year and the second
          * index is the number of the month: result[2003][11] = _posts for november 2003_
          */
         function getNumberPostsPerMonth( $blogId )
         {
-            // query to get the earliest post
-            // this must be my longest and most complex SQL query ever :)
-            $blogs = new Blogs();
-            $blogSettings = $blogs->getBlogSettings( $blogId );
 
-            if( $blogSettings->getValue( "show_future_posts_in_calendar" ))
-                $numPostsPerMonthQuery = "SELECT COUNT(*) AS 'count',YEAR(date) AS 'year',MONTH(date) AS 'month',DAYOFMONTH(date) AS 'daymonth' FROM ".$this->getPrefix()."articles WHERE status = 1 AND blog_id = ".$blogId." GROUP BY YEAR(date),MONTH(date) ORDER BY YEAR(date) DESC,MONTH(date) DESC;";
-            else
-                $numPostsPerMonthQuery = "SELECT COUNT(*) AS 'count',YEAR(date) AS 'year',MONTH(date) AS 'month',DAYOFMONTH(date) AS 'daymonth' FROM ".$this->getPrefix()."articles WHERE status = 1 AND blog_id = ".$blogId." AND date <= NOW() GROUP BY YEAR(date),MONTH(date) ORDER BY YEAR(date) DESC,MONTH(date) DESC;";
+            $archives = $this->_cache->getData( $blogId, CACHE_ARTICLESPERMONTH );
 
-            $result = $this->Execute( $numPostsPerMonthQuery);
-            if( $result == false )
-                return false;
+            if( !$archives ) {
+                require_once( PLOG_CLASS_PATH . 'class/dao/blogs.class.php' );
+                $blogs = new Blogs();
+                $blogSettings = $blogs->getBlogSettings( $blogId );
 
-            $archives = Array();
-            while( $row = $result->FetchRow()) {
-                $archives[$row["year"]][$row["month"]] = $row["count"];
+                if( $blogSettings->getValue("show_future_posts_in_calendar") )
+                    $numPostsPerMonthQuery = "SELECT COUNT(*) AS 'count',
+                                                YEAR(date) AS 'year',
+                                                MONTH(date) AS 'month'
+                                              FROM ".$this->getPrefix().ARTICLES_TABLENAME." 
+                                              WHERE status = 1 AND blog_id = ".$blogId." 
+                                              GROUP BY YEAR(date),MONTH(date) 
+                                              ORDER BY YEAR(date) DESC,MONTH(date) DESC;";
+                else
+                    $numPostsPerMonthQuery = "SELECT COUNT(*) AS 'count',
+                                                YEAR(date) AS 'year',
+                                                MONTH(date) AS 'month'
+                                              FROM ".$this->getPrefix().ARTICLES_TABLENAME." 
+                                              WHERE status = 1 AND blog_id = ".$blogId." 
+                                                AND date <= NOW() 
+                                              GROUP BY YEAR(date),MONTH(date) 
+                                              ORDER BY YEAR(date) DESC,MONTH(date) DESC;";
+
+                $result = $this->Execute( $numPostsPerMonthQuery);
+                if( $result == false )
+                    return false;
+
+                $archives = Array();
+                while( $row = $result->FetchRow()) {
+                    $archives[$row["year"]][$row["month"]] = $row["count"];
+                }
+                $this->_cache->setData( $blogId, CACHE_ARTICLESPERMONTH, $archives );
             }
 
             return $archives;
@@ -561,6 +513,7 @@
          */
         function getNumberPostsPerDay( $blogId, $year = null , $month = null )
         {
+            include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
             // if month and/or year are empty, get the current ones
             if( $year == null ) {
                 $t = new Timestamp();
@@ -604,13 +557,19 @@
          */
         function addPostCategoriesLink( $articleId, $categories )
         {
+            require_once( PLOG_CLASS_PATH.'class/database/db.class.php' );
+
 			// nothing to do if the $categories array is not ehem, an array :)
 			if( !is_array( $categories ))
 				return true;
 				
             foreach( $categories as $categoryId ) {
-                $query = "INSERT INTO ".$this->getPrefix()."article_categories_link
-                          (article_id, category_id) VALUES ($articleId, $categoryId )";
+                $keyValuePairs = array();
+                $keyValuePairs['article_id']  = $articleId;
+                $keyValuePairs['category_id'] = $categoryId;
+
+                $query = Db::buildInsertQuery( ARTICLE_CATEGORIES_RELATIONSHIP_TABLENAME,
+                                               $keyValuePairs );
                 $this->Execute( $query );
             }
 
@@ -623,9 +582,12 @@
          */
         function deletePostCategoriesLink( $articleId )
         {
-            $query = "DELETE FROM ".$this->getPrefix()."article_categories_link
-                      WHERE article_id = $articleId";
+            require_once( PLOG_CLASS_PATH.'class/database/db.class.php' );
 
+            $query = Db::buildDeleteQuery( ARTICLE_CATEGORIES_RELATIONSHIP_TABLENAME,
+                                           'article_id',
+                                           $articleId );
+
             return $this->Execute( $query );
         }
 
@@ -651,17 +613,21 @@
          */
         function addArticle( &$newArticle )
         {
-            // first, we build up the query
-            $filter = new Textfilter();
-            $query = "INSERT INTO ".$this->getPrefix()."articles( user_id,blog_id,status,date,properties, slug )
-                      VALUES ( ".$newArticle->getUser().",".
-                      $newArticle->getBlog().",'".
-                      $newArticle->getStatus()."','".
-                      $newArticle->getDate()."','".
-                      serialize($newArticle->getProperties())."','".
-					  $newArticle->getPostSlug()."');";
-            // and then we send it to the db
-            //$this->_db->debug=true;
+            include_once( PLOG_CLASS_PATH.'class/dao/customfields/customfields.class.php' );
+            require_once( PLOG_CLASS_PATH.'class/database/db.class.php' );
+
+            $valuesToInsert = array();
+
+            $valuesToInsert['user_id']    = $newArticle->getUser();
+            $valuesToInsert['blog_id']    = $newArticle->getBlogId();
+            $valuesToInsert['status']     = $newArticle->getStatus();
+            $valuesToInsert['date']       = $newArticle->getDate();
+            $valuesToInsert['properties'] = serialize( $newArticle->getProperties() );
+            $valuesToInsert['slug']       = $newArticle->getPostSlug();
+
+            $query = Db::buildInsertQuery( ARTICLES_TABLENAME,
+                                           $valuesToInsert );
+
             $result = $this->Execute( $query );
 
             if( !$result ){
@@ -681,6 +647,10 @@
             // and save the custom fields
             $this->addArticleCustomFields( $postId, $newArticle->getBlog(), $newArticle->getFields());
 
+            // and finally clear the cache :)
+            $this->_cache->removeData( $newArticle->getBlogId(), CACHE_BLOGARTICLES );
+            $this->_cache->removeData( $newArticle->getBlogId(), CACHE_ARTICLESPERMONTH );
+
             return $postId;
         }
 		
@@ -693,16 +663,21 @@
 		 */
 		function addArticleText( $newArticle )
 		{
+            require_once( PLOG_CLASS_PATH . 'class/data/textfilter.class.php' );
+            require_once( PLOG_CLASS_PATH . 'class/database/db.class.php' );
+
 			$filter = new Textfilter();
-			$prefix = $this->getPrefix();
-			$query = "INSERT INTO {$prefix}articles_text
-			                      (article_id, topic, text, normalized_text, normalized_topic)
-					  VALUES( '".Db::qstr( $newArticle->getId())."', '".
-					            Db::qstr($newArticle->getTopic())."','".
-                                Db::qstr($newArticle->getText(false))."','".
-                                $filter->normalizeText(Db::qstr($newArticle->getText(false)))."', '".
-                                $filter->normalizeText(Db::qstr($newArticle->getTopic()))."')";
-								
+
+            $valuesToInsert = array();
+            $valuesToInsert['article_id']       = $newArticle->getId();
+            $valuesToInsert['topic']            = $newArticle->getTopic();
+            $valuesToInsert['text']             = $newArticle->getText(false);
+            $valuesToInsert['normalized_text']  = $filter->normalizeText( $newArticle->getText(false) );
+            $valuesToInsert['normalized_topic'] = $filter->normalizeText( $newArticle->getTopic() );
+
+            $query = Db::buildInsertQuery( ARTICLETEXTS_TABLENAME,
+                                           $valuesToInsert );
+
 			return( $this->Execute( $query ));
 		}
 		
@@ -714,16 +689,25 @@
 		 */
 		function getArticleText( $articleId )
 		{
-			$prefix = $this->getPrefix();
-			$query = "SELECT text,topic FROM {$prefix}articles_text
-			          WHERE article_id = '".Db::qstr($articleId)."'";
-					  
-			$result = $this->Execute( $query );
-			
-			if( !$result ) 
-				return false;
-				
-			return( $result->FetchRow());
+            $text = $this->_cache->getData( $articleId, CACHE_ARTICLETEXT );
+
+            if( !$text ) {
+                $query = Db::buildSelectQuery( ARTICLETEXTS_TABLENAME,
+                                               array(),
+                                               'article_id',
+                                               $articleId );
+
+                $result = $this->Execute( $query );
+                
+                if( !$result ) 
+                    return false;
+                    
+                $text = $result->FetchRow();
+
+                $this->_cache->setData( $articleId, CACHE_ARTICLETEXT, $text );
+            }
+
+            return $text;
 		}
 		
 		/**
@@ -735,13 +719,21 @@
 		function updateArticleText( $article )
 		{
 			$filter = new Textfilter();
-            $query = "UPDATE ".$this->getPrefix()."articles_text SET 
-                        topic = '".Db::qstr($article->getTopic())."'".
-                     ", text = '".Db::qstr($article->getText(false))."'".
-                     ", normalized_text = '".$filter->normalizeText(Db::qstr($article->getText(false)))."'".
-                     ", normalized_topic = '".$filter->normalizeText(Db::qstr($article->getTopic()))."'".
-                     " WHERE article_id = ".$article->getId().";";
-			
+
+            $keyValuePairs = array();
+
+            $keyValuePairs['topic']            = $article->getTopic();
+            $keyValuePairs['text']             = $article->getText(false);
+            $keyValuePairs['normalized_text']  = $filter->normalizeText( $article->getText(false) );
+            $keyValuePairs['normalized_topic'] = $filter->normalizeText( $article->getTopic() );
+
+            $query = Db::buildUpdateQuery( ARTICLETEXTS_TABLENAME,
+                                           $keyValuePairs,
+                                           'article_id',
+                                           $article->getId() );
+
+            $this->_cache->removeData( $article->getId(), CACHE_ARTICLETEXT );
+
 			return($this->Execute( $query ));
 		}
 
@@ -758,7 +750,8 @@
             $customFields = new CustomFieldsValues();
 
             foreach( $fields as $field ) {
-                $customFields->addCustomFieldValue( $field->getFieldId(), $field->getValue(), $artId, $blogId );
+                $customFields->addCustomFieldValue( $field->getFieldId(), $field->getValue(), 
+                                                    $artId, $blogId );
             }
 
             return true;
@@ -772,19 +765,25 @@
          */
         function updateArticle( $article )
         {
+            include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
+
             // we have to build up the query, which will be pretty long...
             $articleDate = Timestamp::getDateWithOffset( $article->getDate(), -($article->getTimeOffset()));
             $filter = new Textfilter();
 
-            $query = "UPDATE ".$this->getPrefix()."articles SET id = ".$article->getId().
-                     ", user_id = ".$article->getUser().
-                     ", date = ".$articleDate.
-                     ", blog_id = ".$article->getBlog().
-                     ", status = '".$article->getStatus()."'".
-                     ", num_reads = ".$article->getNumReads().
-                     ", properties = '".serialize($article->getProperties())."'".
-					 ", slug = '".$article->getPostSlug()."'".
-                     " WHERE id = ".$article->getId().";";
+            $keyValuePairs = array();
+            $keyValuePairs['user_id']    = $article->getUser();
+            $keyValuePairs['date']       = $articleDate;
+            $keyValuePairs['blog_id']    = $article->getBlogId();
+            $keyValuePairs['status']     = $article->getStatus();
+            $keyValuePairs['num_reads']  = $article->getNumReads();
+            $keyValuePairs['properties'] = serialize( $article->getProperties() );
+            $keyValuePairs['slug']       = $article->gePostSlug();
+            
+            $query = Db::buildUpdateQuery( ARTICLES_TABLENAME,
+                                           $keyValuePairs,
+                                           'id',
+                                           $article->getId() );
 
             $result = $this->Execute( $query );
 
@@ -795,11 +794,14 @@
 			// update the article text
 			$this->updateArticleText( $article );
 
-            if( !$this->updatePostCategoriesLink( $article->getId(), $article->getCategoryIds()))
+            if( !$this->updatePostCategoriesLink( $article->getId(), $article->getCategoryIds()) ||
+                !$this->updateArticleCustomFields( $article->getId(), $article->getBlog(), 
+                                                   $article->getFields()) )
                 return false;
 
-            if( !$this->updateArticleCustomFields( $article->getId(), $article->getBlog(), $article->getFields()))
-                return false;
+            // clean up the cache
+            $this->_cache->removeData( $article->getBlogId(), CACHE_ARTICLESPERMONTH );
+            $this->_cache->removeData( $article->getId(), CACHE_ARTICLES );
 
             return true;
         }
@@ -823,7 +825,9 @@
                 return false;
 
             foreach( $fields as $field ) {
-                $customFields->addCustomFieldValue( $field->getFieldId(), $field->getValue(), $artId, $blogId );
+                $customFields->addCustomFieldValue( $field->getFieldId(), 
+                                                    $field->getValue(), 
+                                                    $artId, $blogId );
             }
 
             return true;
@@ -840,14 +844,27 @@
          */
         function updateArticleNumReads( $articleId )
         {
-            // we have to build up the query, which will be pretty long...
-            $query = "UPDATE ".$this->getPrefix()."articles SET ".
-                     " num_reads = num_reads+1 ".
-                     ", date = date ".
-                     " WHERE id = '".Db::qstr($articleId)."'";
+            require_once( PLOG_CLASS_PATH . 'class/database/db.class.php' );
 
+            $article  = $this->getArticle( $articleId );
+            $numReads = $article->getNumReads() + 1;
+
+            $article->setNumReads( $numReads );
+
+            $keyValuePairs = array();
+            $keyValuePairs['num_reads'] = $numReads;
+            $keyValuePairs['date']      = '@date';
+
+            $query = Db::buildUpdateQuery( ARTICLES_TABLENAME,
+                                           $keyValuePairs,
+                                           'id',
+                                           $articleId );
+
             $result = $this->Execute( $query );
 
+            if( $result )
+                $this->_cache->setData( $articleId, CACHE_ARTICLES, $article );
+
             return $result;
         }
 		
@@ -892,6 +909,9 @@
          */
         function deleteArticle( $artId, $userId, $blogId, $forever = false )
         {
+            include_once( PLOG_CLASS_PATH.'class/dao/articlecomments.class.php' );
+            include_once( PLOG_CLASS_PATH.'class/database/db.class.php' );
+
             if( $forever ) {
                 $query = "DELETE FROM ".$this->getPrefix()."articles WHERE id = ".$artId." AND user_id = ".$userId." AND blog_id = ".$blogId.";";
 				// -- text --
@@ -910,7 +930,14 @@
                 $customFields->removeArticleCustomFields( $artId );
             }
             else {
-                $query = "UPDATE ".$this->getPrefix()."articles SET date = date, status = 3 WHERE id = ".$artId." AND user_id = ".$userId." AND blog_id = ".$blogId.";";
+                $keyValuePairs = array();
+                $keyValuePairs['date']   = '@date';
+                $keyValuePairs['status'] = POST_STATUS_DELETED;
+
+                $query = Db::buildUpdateQuery( ARTICLES_TABLENAME,
+                                               $keyValuePairs,
+                                               'id',
+                                               $artId );
             }
 
             $result = $this->Execute( $query );
@@ -921,6 +948,10 @@
             if( $this->_db->Affected_Rows() == 0 )
                 return false;
 
+            $this->_cache->removeData( $blogId, CACHE_BLOGARTICLES );
+            $this->_cache->removeData( $blogId, CACHE_ARTICLESPERMONTH );
+            $this->_cache->removeData( $artId, CACHE_ARTICLES );
+
             return true;
         }
 		
@@ -934,9 +965,11 @@
 		 */
 		function deleteArticleText( $articleId )
 		{
-			$query = "DELETE FROM ".$this->getPrefix()."articles_text WHERE article_id = '".Db::qstr($articleId)."'";
+            $query = Db::buildDeleteQuery( ARTICLETEXTS_TABLENAME,
+                                           'article_id',
+                                           $articleId );
 			
-			return( $this->Execute( $query ));
+			return( $this->Execute($query) );
 		}
 
         /**
@@ -1001,7 +1034,8 @@
             foreach( $blogArticles as $article ) {
                 // the deleteArticle method will also take care of removing comments and
                 // trackbacks
-                $this->deleteArticle( $article->getId(), $article->getUser(), $article->getBlog(), true );
+                $this->deleteArticle( $article->getId(), $article->getUser(), 
+                                      $article->getBlog(), true );
             }
 
             return true;
@@ -1014,9 +1048,13 @@
          */
         function purgePosts()
         {
-            $query = "SELECT * FROM ".$this->getPrefix()."articles WHERE status = 3";
+            $query = Db::buildSelectQuery( ARTICLES_TABLENAME,
+                                           array('id', 'user_id', 'blog_id'),
+                                           'status',
+                                           POST_STATUS_DELETED );
 
             $result = $this->Execute( $query );
+
             if( !$result )
                 return false;
 
@@ -1032,31 +1070,26 @@
          */
         function getArticleCategories( $articleId, $blogId = -1 )
         {
+            include_once( PLOG_CLASS_PATH.'class/dao/articlecategories.class.php' );
+
+            if( $this->categories == null )
+                $this->categories = new ArticleCategories();
+
 			return $this->categories->getArticleCategories( $articleId, $blogId );
         }
 
         /**
-         * returns all the categories that an article has been assigned to
+         * sets a time difference that will be added to each
+         * date and time
+         *
+         * @param timeDiff The time difference. IT should be between +12 and -12
+         * @return Always returns true.
          */
-        function getArticleCategoryIds( $articleId )
+        function setTimeDiff( $timeDiff )
         {
-            $query = "SELECT category_id FROM ".$this->getPrefix()."article_categories_link
-                      WHERE article_id = $articleId";
+            $this->_timeDiff = $timeDiff;
 
-            $result = $this->Execute( $query );
-
-            // it's impossible that an article has no categories, but
-            // we'll bear with it...
-            if( !$result )
-                return Array();
-
-            // otherwise, fetch them
-            $categories = Array();
-            while( $row = $result->FetchRow()) {
-				$categories[] = $row['category_id'];
-            }
-
-            return $categories;
+            return true;
         }
 
         /**
@@ -1068,10 +1101,11 @@
          */
         function _fillArticleInformation( $query_result, $includeHiddenFields = true )
         {
+            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/dao/blogs.class.php' );
+
 			$id = $query_result['id'];
-			if( isset($this->cache[$id])) {
-				return($this->cache[$id]);
-			}
 
             // this is a little dirty trick or otherwise the old
             // that don't have the 'properties' field will not work
@@ -1081,27 +1115,23 @@
                 $query_result['properties'] = serialize($tmpArray);
             }
 
-            // ---
-            // this, i do not like... but I couldn't find a more
-            // "elegant" way to arrange it! This makes this method
-            // totally dependant on the blog configuration so it basically
-            // means an additional query every time we fetch an article
-            // (just in case we didn't have enough!)
-            // ---
-
             //
             // if there's a time difference applied to all dates, then we'd better
             // calculate it here!!
             //
-            $blogId = $query_result['blog_id'];
-            $blogInfo = $this->blogs->getBlogInfo( $blogId );
-			$blogSettings = $blogInfo->getSettings();
-            $timeDiff = $blogSettings->getValue( 'time_offset' );
+            if( $this->blogs == null )
+                $this->blogs  = new Blogs();
 
+            $blogId        = $query_result['blog_id'];
+            $blogInfo      = $this->blogs->getBlogInfo( $blogId );
+			$blogSettings  = $blogInfo->getSettings();
+            $timeDiff      = $blogSettings->getValue( 'time_offset' );
+
             // we can use this auxiliary function to help us...
             $date = Timestamp::getDateWithOffset( $query_result['date'], $timeDiff );
 
-			$articleCategories = $this->getArticleCategories( $query_result['id'], $query_result['blog_id'] );
+			$articleCategories = $this->getArticleCategories( $query_result['id'], 
+                                                              $query_result['blog_id'] );
             $categoryIds = Array();
 			foreach( $articleCategories as $category )
 				array_push( $categoryIds, $category->getId());
@@ -1126,92 +1156,11 @@
             // get information about the categories of the article
             $article->setCategories( $articleCategories );
 			$article->setBlogInfo( $blogInfo );
+            if ( $this->users == null )
+                $this->users = new Users();
 			$article->setUserInfo( $this->users->getUserInfoFromId( $query_result['user_id'] ));			
 
-			// fill in the cache with the result we just loaded
-			$this->cache[$query_result['id']] = $article;
-
             return $article;
         }
-
-		/**
-		 * @private
-		 */
-		function _fillArticleHeaderInformation( $query_result, $includeHiddenFields = true )
-        {
-			$id = $query_result['id'];
-			if( isset($this->cache[$id])) {
-				return($this->cache[$id]);
-			}
-
-            // this is a little dirty trick or otherwise the old
-            // that don't have the 'properties' field will not work
-            // as they will appear to have comments disabled
-            if( $query_result['properties'] == "" ) {
-                $tmpArray = Array( 'comments_enabled' => true );
-                $query_result['properties'] = serialize($tmpArray);
-            }
-
-            // ---
-            // this, i do not like... but I couldn't find a more
-            // "elegant" way to arrange it! This makes this method
-            // totally dependant on the blog configuration so it basically
-            // means an additional query every time we fetch an article
-            // (just in case we didn't have enough!)
-            // ---
-
-            //
-            // if there's a time difference applied to all dates, then we'd better
-            // calculate it here!!
-            //
-			if( $this->_blogInfo == null ) {
-				$blogId = $query_result['blog_id'];
-				$this->_blogInfo = $this->blogs->getBlogInfo( $blogId );
-				$this->_blogSettings = $this->_blogInfo->getSettings();
-				$this->_timeDiff = $this->_blogSettings->getValue( 'time_offset' );
-			}
-			
-            // we can use this auxiliary function to help us...
-            $date = Timestamp::getDateWithOffset( $query_result['date'], $this->_timeDiff );
-
-            // postText does not exist here.. maybe a copy/paste problem? 
-            // anyway.. it works without postText, so i'll just set this to
-            // null. oscar, pls double check.. original code:
-            // $article = new Article( $postText['topic'],
-            //                         $postText['text'],
-            //                         NULL,
-            $article = new Article( NULL,
-                                    NULL,
-                                    NULL,
-                                    $query_result['user_id'],
-                                    $query_result['blog_id'],
-                                    $query_result['status'],
-                                    $query_result['num_reads'],
-                                    unserialize($query_result['properties']),
-									$query_result['slug'],
-                                    $query_result['id'] );
-									
-            // and fill in all the fields with the information we just got from the db
-            $article->setDate( $date );
-            $article->setTimeOffset( $this->_timeDiff );
-			$article->setBlogInfo( $this->_blogInfo );
-			$article->setUserInfo( $this->users->getUserInfoFromId( $query_result['user_id'] ));			
-            
-            return $article;
-        }		
-
-        /**
-         * sets a time difference that will be added to each
-         * date and time
-         *
-         * @param timeDiff The time difference. IT should be between +12 and -12
-         * @return Always returns true.
-         */
-        function setTimeDiff( $timeDiff )
-        {
-            $this->_timeDiff = $timeDiff;
-
-            return true;
-        }
     }
 ?>

Copied: plog/trunk/class/dao/blogarticles.class.php (from rev 2140, plog/branches/plog-1.1-ben/class/dao/blogarticles.class.php)

Modified: plog/trunk/class/dao/bloginfo.class.php
===================================================================
--- plog/trunk/class/dao/bloginfo.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/bloginfo.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,12 +1,7 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/blogsettings.class.php" );
-	include_once( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" );
-	include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/blogsettings.class.php" );
 	
 	/**
 	 * \ingroup DAO
@@ -94,6 +89,17 @@
          *
          * @return An integer value representing the identifier of the user who owns this blog.
          */
+        function getOwnerId()
+        {
+            return $this->_owner;
+        }
+
+        /**
+         * Returns the identifier of the user who owns this journal.
+         *
+         * @return An integer value representing the identifier of the user who owns this blog.
+         * @deprecated Use getOwnerId() instead.
+         */
         function getOwner()
         {
             return $this->_owner;
@@ -119,6 +125,12 @@
             return $this->_settings;
         }
 
+        function getSetting( $setting )
+        {
+
+            return $this->_settings->getValue( $setting );
+        }
+
         /**
          * returns a key from the blog settings
          */
@@ -127,7 +139,7 @@
             if( !$this->_settings )
                 return "";
 
-            return $this->_settings->getValue( $value );
+            return $this->getSetting( $value );
         }
 
         /**
@@ -169,10 +181,16 @@
             return true;
         }
 
-         /**
-         */
+       /**
+        * :TODO: I'm not sure anyone ever calls this method, maybe we can
+        *        get rid of it
+        *                            (2005-05-31 ork at devel.plogworld.net)
+        *
+        */
         function getCreateDateObject( )
         {
+	        include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
             // if it hasn't been loaded yet...
             if( $this->_createTimestamp == null ) {
                 $blogs = new Blogs();
@@ -186,6 +204,8 @@
          */
         function getUpdateDateObject( )
         {
+	        include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
             if( $this->_updateTimestamp == null ) {
                 $blogs = new Blogs();
                 $this->setUpdateDate( $blogs->getBlogUpdateDate( $this->getId()));
@@ -198,6 +218,8 @@
          */
         function getTotalPosts( )
         {
+	        include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
             if( $this->_totalPosts == null ) {
                 $blogs = new Blogs();
                 $this->_totalPosts = $blogs->getBlogTotalPosts( $this->getId());
@@ -210,6 +232,8 @@
          */
         function getTotalComments( )
         {
+	        include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
             if( $this->_totalComments == null ) {
                 $blogs = new Blogs();
                 $this->_totalComments = $blogs->getBlogTotalComments( $this->getId());
@@ -222,6 +246,8 @@
          */
         function getTotalTrackbacks( )
         {
+	        include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
             if( $this->_totalTrackbacks == null ) {
                 $blogs = new Blogs();
                 $this->_totalTrackbacks = $blogs->getBlogTotalTrackbacks( $this->getId());
@@ -234,6 +260,8 @@
          */
         function getViewedTotal( )
         {
+	        include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
             if( $this->_viewedTotal == null ) {
                 $blogs = new Blogs();
                 $this->_viewedTotal = $blogs->getBlogViewedTotal( $this->getId());
@@ -248,6 +276,8 @@
          */
         function getOwnerInfo()
         {
+	        include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
+
             if( $this->_ownerInfo == null ) {
                 $users = new Users();
                 $ownerInfo = $users->getUserInfoFromId( $this->_owner );
@@ -262,6 +292,8 @@
          */
         function getUsersInfo( )
         {
+	        include_once( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
+
             if( $this->_usersInfo == null ) {
                 $userpermissions = new UserPermissions();
                 $blogUsers = $userpermissions->getBlogUsers( $this->getId());
@@ -286,6 +318,8 @@
          */
         function setBlog( $blog )
         {
+	        include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
             $tf = new Textfilter();
             $this->_blog = $tf->filterAllHTML($blog);
         }
@@ -382,7 +416,7 @@
          */
         function getTemplate()
         {
-            return $this->_settings->getValue( "template");
+            return $this->getSetting( "template");
         }
 
         /**
@@ -412,6 +446,8 @@
          */
         function getBlogRequestGenerator()
         {
+	        include_once( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" );
+
             return RequestGenerator::getRequestGenerator( $this );
         }
 
@@ -460,7 +496,7 @@
         {
             if( $this->_locale == null ) {
                 include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
-                $this->_locale =& Locales::getLocale( $this->_settings->getValue( "locale" ), "en_UK" );
+                $this->_locale =& Locales::getLocale( $this->getSetting( "locale" ), "en_UK" );
             }
 
             return $this->_locale;
@@ -511,7 +547,7 @@
          */
         function getResourcesQuota()
         {
-            $quota = $this->_settings->getValue( "resources_quota" );
+            $quota = $this->getSetting( "resources_quota" );
 
             // if there is no quota for this blog, then fetch it from the global
             // settings

Copied: plog/trunk/class/dao/bloglinks.class.php (from rev 2140, plog/branches/plog-1.1-ben/class/dao/bloglinks.class.php)

Modified: plog/trunk/class/dao/blogs.class.php
===================================================================
--- plog/trunk/class/dao/blogs.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/blogs.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,21 +1,13 @@
 <?php
 
-    include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
-    include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
-    include_once( PLOG_CLASS_PATH."class/net/xmlrpcclient.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/mylinks.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/mylinkscategories.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/bayesianfilterinfos.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
-    include_once( PLOG_CLASS_PATH."class/file/file.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/blogstatus.class.php" );
+    require_once( PLOG_CLASS_PATH . 'class/dao/model.class.php' );
+    require_once( PLOG_CLASS_PATH . 'class/config/config.class.php' );
+    require_once( PLOG_CLASS_PATH . 'class/dao/users.class.php' );
+    require_once( PLOG_CLASS_PATH . 'class/file/file.class.php' );
+    require_once( PLOG_CLASS_PATH . 'class/dao/blogstatus.class.php' );
 
     /**
-	 * \ingroup DAO
+     * \ingroup DAO
      * Model for the Blogs
      */
     class Blogs extends Model
@@ -28,11 +20,26 @@
          * @param extendedInfo
          * @return Returns a BlogInfo object containing information about the blog
          */
-        function getBlogInfo( $blogId, $extendedInfo = false )
+        function getBlogInfo( $blogId )
         {
-            $query = "SELECT * FROM ".$this->getPrefix()."blogs WHERE id = '".Db::qstr($blogId)."'";
+            require_once( PLOG_CLASS_PATH . 'class/dao/bloginfo.class.php' );
 
-            return $this->_getBlogInfoFromQuery( $query, $extendedInfo );
+            $blogInfo = $this->_cache->getData( $blogId, CACHE_BLOGINFOS );
+
+            if( !$blogInfo ) {
+                require_once( PLOG_CLASS_PATH."class/database/db.class.php" );
+
+                $query = Db::buildSelectQuery( BLOGS_TABLENAME,
+                                               array(),
+                                               'id',
+                                               $blogId );
+                $blogInfo = $this->_getBlogInfoFromQuery( $query, $extendedInfo );
+
+                // save the blogInfo object in the cache.
+                $this->_cache->setData( $blogId, CACHE_BLOGINFOS, $blogInfo );
+            }
+
+            return $blogInfo;
         }
 
         /**
@@ -43,74 +50,55 @@
          */
         function getBlogInfoByName( $blogName, $extendedInfo = false )
         {
-            $query = "SELECT * FROM ".$this->getPrefix()."blogs WHERE mangled_blog = '".Db::qstr($blogName)."';";
+            $blogId = $this->_cache->getData( $blogName, CACHE_BLOGIDBYNAME );
 
-            //$this->_db->debug=true;
+            if ( !$blogId ) {
+                require_once( PLOG_CLASS_PATH."class/database/db.class.php" );
 
-            return $this->_getBlogInfoFromQuery( $query, $extendedInfo );
-        }
+                $query = Db::buildSelectQuery( BLOGS_TABLENAME,
+                                               array(),
+                                               'mangled_blog',
+                                               $blogName );
 
-        /**
-         * @private
-         */
-        function _getBlogInfoFromQuery( $query, $extendedInfo = false )
-        {
-            $result = $this->Execute( $query );
+                $blogInfo = $this->_getBlogInfoFromQuery( $query, $extendedInfo );
 
-            if( !$result )
-                return false;
+                // and store the blogName-to-blogId relationship in the cache
+                $this->_cache->setData( $blogName, CACHE_BLOGIDBYNAME, $blogInfo->getId() );
+            } else {
+                $blogInfo = $this->getBlogInfo( $blogId );
+            }
 
-            if( $result->RecordCount() == 0 )
-                return false;
-
-            $row = $result->FetchRow( $result );
-            $blogInfo = $this->_fillBlogInformation( $row, $extendedInfo );
-            $blogSettings = $this->getBlogSettingsFromField( $row["settings"] );
-            $blogInfo->setSettings( $blogSettings );
-
             return $blogInfo;
         }
 
-        /**
-         * Private function.
-         *
-         * @private.
-         */
-        function _fillBlogInformation( $query_result, $extended = false )
-        {
-            $blogInfo = new BlogInfo( stripslashes($query_result["blog"]),
-                                      $query_result["owner_id"],
-                                      stripslashes($query_result["about"]),
-                                      unserialize($query_result["settings"]),
-                                      $query_result["id"] );
 
-            // load information about the blog owner
-            $blogInfo->setStatus( $query_result["status"] );
-
-            return $blogInfo;
-        }
-
         /**
          * Retrieves the first article date timestamp
+         * :TODO: I'm not sure anyone ever calls this method, maybe we can
+         *        get rid of it
+         *                            (2005-05-31 ork at devel.plogworld.net)
          *
-         * @param blogId The identifier of the blog from which we'd like to fetch the settings
+         * @param blogId The identifier of the blog from which we'd like 
+                         to fetch the creation date
          * @return Returns an Timestamp with the first article date
          */
         function getBlogCreateDate( $blogId )
         {
-            $query  = "SELECT date FROM ".$this->getPrefix()."articles WHERE blog_id = ".$blogId. " ORDER BY date ASC LIMIT 0,1" ;
+            require_once( PLOG_CLASS_PATH . 'class/dao/articles.class.php' );
 
-            $result = $this->_db->Execute( $query );
+            $articles     = new Articles();
+            $blogArticles = $articles->getArticles( $blogId );
+            // these are always sorted by date.
+            $allArticles  = $blogArticles->getArticleIds();
 
-            if (!$result)
-                return false;
+            // there might be no article, we return 01.01.1970 then :-)
+            if( empty($allArticles) )
+                return '19700101000000';
 
-            $row = $result->FetchRow();
+            // fetch the first article
+            $article  = $articles->getArticle( $allArticles[0] );
 
-            if (!isset($row["date"]))
-                return false;
-
-            return $row["date"];
+            return $article->getDate();
         }
 
         /**
@@ -121,18 +109,21 @@
          */
         function getBlogUpdateDate( $blogId )
         {
-            $query  = "SELECT date FROM ".$this->getPrefix()."articles WHERE blog_id = ".$blogId. " ORDER BY date DESC LIMIT 0,1" ;
-            $result = $this->_db->Execute( $query );
+            require_once( PLOG_CLASS_PATH . 'class/dao/articles.class.php' );
 
-            if (!$result)
-                return false;
+            $articles     = new Articles();
+            $blogArticles = $articles->getArticles( $blogId );
+            // these are always sorted by date.
+            $allArticles  = $blogArticles->getArticleIds();
 
-            $row = $result->FetchRow();
+            // there might be no article, we return 01.01.1970 then :-)
+            if( empty($allArticles) )
+                return '19700101000000';
 
-            if (!isset($row["date"]))
-                return false;
+            // fetch the last article
+            $article  = $articles->getArticle( $allArticles[count($allArticles) - 1] );
 
-            return $row["date"];
+            return $article->getDate();
         }
 
         /**
@@ -143,9 +134,10 @@
          */
         function getBlogViewedTotal( $blogId )
         {
-            $query  = "SELECT SUM(num_reads) as total FROM ".$this->getPrefix()."articles WHERE blog_id = ".$blogId;
+            $query  = "SELECT SUM(num_reads) as total FROM " . $this->getPrefix() .
+                      "articles WHERE blog_id = " . $blogId;
 
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
 
             if (!$result)
                 return false;
@@ -166,18 +158,15 @@
          */
         function getBlogTotalPosts( $blogId )
         {
-            $query  = "SELECT COUNT(*) as total FROM ".$this->getPrefix()."articles WHERE blog_id = $blogId AND status = ".POST_STATUS_PUBLISHED;
-            $result = $this->_db->Execute( $query );
+            require_once( PLOG_CLASS_PATH . 'class/dao/articlestatus.class.php' );
+            require_once( PLOG_CLASS_PATH . 'class/dao/articles.class.php' );
 
-            if (!$result)
-                return false;
+            $articles     = new Articles();
+            $blogArticles = $articles->getArticles( $blogId );
 
-            $row = $result->FetchRow();
+            $allArticles  = $blogArticles->getArticleByStatus( POST_STATUS_PUBLISHED );
 
-            if (!isset($row["total"]))
-                return false;
-
-            return intval($row["total"]);
+            return count($allArticles);
         }
 
         /**
@@ -189,7 +178,7 @@
         function getBlogTotalComments( $blogId )
         {
             $query  = "SELECT COUNT(*) as total FROM ".$this->getPrefix()."articles_comments AS c, ".$this->getPrefix()."articles AS a WHERE ((a.blog_id = $blogId) AND (a.id = c.article_id)) AND c.status = ".COMMENT_STATUS_NONSPAM;
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
 
             if (!$result)
                 return false;
@@ -211,7 +200,7 @@
         function getBlogTotalTrackbacks( $blogId )
         {
             $query  = "SELECT COUNT(*) as total FROM ".$this->getPrefix()."trackbacks AS t, ".$this->getPrefix()."articles AS a WHERE ((a.blog_id = $blogId) AND (a.id = t.article_id))";
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
 
             if (!$result)
                 return false;
@@ -232,12 +221,14 @@
          */
         function getBlogSettingsFromField( $settingsField )
         {
+            require_once( PLOG_CLASS_PATH . "class/dao/blogsettings.class.php" );
+
             if( $settingsField == "" || $settingsField == null ) {
                 $settings = new BlogSettings();
             }
             else {
                 $settings = unserialize( $settingsField );
-                if( !is_object($settings)) {
+                if( !is_object($settings) ) {
                     // if the BlogSettings object is not valid, return a valid one
                     // with some of the default settings, so that at least
                     // the blog will keep working!
@@ -256,13 +247,9 @@
          */
         function getBlogSettings( $blogId )
         {
-            $query = "SELECT settings FROM ".$this->getPrefix()."blogs WHERE id = ".$blogId;
+            $blogInfo = $this->getBlogInfo( $blogId );
 
-            $result = $this->Execute( $query );
-
-            $row = $result->FetchRow();
-
-            return $this->getBlogSettingsFromField( $row["settings"] );
+            return $blogInfo->getSettings();
         }
 
         /**
@@ -270,39 +257,57 @@
          *
          * @param blogId Blog identifier
          * @param blogInfo A BlogInfo object containing all the information of the blog
-         * @param return Returns true if everything ok or false otherwise
+         * @param return Returns true if everything's ok or false otherwise
          */
         function updateBlog( $blogId, $blogInfo )
         {
-            $query = "UPDATE ".$this->getPrefix()."blogs SET
-                     blog = '".Db::qstr($blogInfo->getBlog()).
-                     "', about = '".Db::qstr($blogInfo->getAbout()).
-                     "', settings = '".serialize($blogInfo->getSettings()).
-                     "', owner_id = ".$blogInfo->getOwner().
-                     ", mangled_blog = '".TextFilter::urlize($blogInfo->getBlog()).
-                     "', status = '".Db::qstr($blogInfo->getStatus()).
-                     "' WHERE id = '".Db::qstr($blogId)."';";
+            require_once( PLOG_CLASS_PATH . 'class/data/textfilter.class.php' );
+            require_once( PLOG_CLASS_PATH . 'class/database/db.class.php' );
 
+            $blogName = TextFilter::urlize($blogInfo->getBlog());
+
+            // setup an array containing the values we would like to set in the db
+            $keyValuePairs = array();
+            $keyValuePairs['blog']         = $blogInfo->getBlog();
+            $keyValuePairs['about']        = $blogInfo->getAbout();
+            $keyValuePairs['settings']     = serialize( $blogInfo->getSettings() );
+            $keyValuePairs['owner_id']     = $blogInfo->getOwnerId();
+            $keyValuePairs['mangled_blog'] = $blogName;
+            $keyValuePairs['status']       = $blogInfo->getStatus();
+
+            $query = Db::buildUpdateQuery( BLOGS_TABLENAME,
+                                           $keyValuePairs,
+                                           'id',
+                                           $blogId );
             $result = $this->Execute( $query );
 
+            $this->_cache->removeData( $blogName, CACHE_BLOGIDBYNAME );
+            $this->_cache->removeData( $blogId, CACHE_BLOGINFOS );
+
             return $result;
         }
 
-        /**
-         * Updates the settings of a blog
-         *
-         * @param blogId The blog we want to update
-         * @param blogSettings the BlogSettings object that we would like to update
-         * @return 'true' if all correct. 'false' otherwise.
-         */
-         function updateBlogSettings( $blogId, $blogSettings )
-         {
-            $query = "UPDATE ".$this->getPrefix()."blogs SET settings = '".serialize($blogSettings)."' WHERE id = ".$blogId;
+       /**
+        * Updates the settings of a blog
+        *
+        * @param blogId The blog we want to update
+        * @param blogSettings the BlogSettings object that we would like to update
+        * @return 'true' if all correct. 'false' otherwise.
+        */
+        function updateBlogSettings( $blogId, $blogSettings )
+        {
+            require_once( PLOG_CLASS_PATH . 'class/database/db.class.php' );
 
+            $query = Db::buildUpdateQuery( BLOGS_TABLENAME,
+                                           array( 'settings' => serialize($blogSettings) ),
+                                           'id',
+                                           $blogId );
             $result = $this->Execute( $query );
 
+            $this->_cache->removeData( $blogId, CACHE_BLOGINFOS );
+
             return $result;
-         }
+        }
 
          /**
           * Sends a weblogsUpdate.ping xmlrpc call to notifiy of changes in this blog
@@ -312,6 +317,9 @@
           */
          function updateNotify( $blogInfo )
          {
+            // source classes
+            include_once( PLOG_CLASS_PATH."class/net/xmlrpcclient.class.php" );
+
             // if this feature is not enabled, we quit
             $config =& Config::getConfig();
             if( !$config->getValue( "xmlrpc_ping_enabled" ))
@@ -353,6 +361,10 @@
           */
          function addBlog( &$blog )
          {
+            // source classes
+            include_once( PLOG_CLASS_PATH."class/dao/bayesianfilterinfos.class.php" );
+            include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
             $blogSettings = $blog->getSettings();
             if( !$blogSettings )
                 $blogSettings = new BlogSettings();
@@ -481,9 +493,17 @@
          * its links, its links categories, its trackbacks and its comments
          *
          * @param blogId the id of the blog we'd like to delete
+         * @return boolean success of the operation
          */
         function deleteBlog( $blogId )
         {
+            // source classes
+            require_once( PLOG_CLASS_PATH . 'class/dao/articles.class.php' );
+            require_once( PLOG_CLASS_PATH . 'class/dao/mylinks.class.php' );
+            require_once( PLOG_CLASS_PATH . 'class/dao/mylinkscategories.class.php' );
+            require_once( PLOG_CLASS_PATH . 'class/dao/userpermissions.class.php' );
+            require_once( PLOG_CLASS_PATH . 'class/database/db.class.php' );
+ 
             // first of all, delete the posts
             $articles = new Articles();
             $articles->deleteBlogPosts( $blogId );
@@ -503,33 +523,86 @@
             $perms->revokeBlogPermissions( $blogId );
 
             // and finally, delete the blog
-            $query = "DELETE FROM ".$this->getPrefix()."blogs WHERE id = $blogId";
-
+            $query = Db::buildDeleteQuery( BLOGS_TABLENAME,
+                                           'id',
+                                           $blogId );
             $result = $this->Execute( $query );
 
             return $result;
         }
 
          /**
-          * disables a blog
+          * disables a blog, this is done by setting the status of the blog
+          * to BLOG_STATUS_DISABLED. The blog an all posts still remain in
+          * the database.
           *
           * @param blogId
+          * @see deleteBlog
           */
-         function disableBlog( $blogId )
-         {
-                $query = "UPDATE ".$this->getPrefix()."blogs
-                          SET status = '".BLOG_STATUS_DISABLED."'
-                          WHERE id = '".Db::qstr($blogId)."'";
+        function disableBlog( $blogId )
+        {
+            require_once( PLOG_CLASS_PATH."class/database/db.class.php" );
 
-                $result = $this->Execute( $query );
+            $keyValuePairs = array();
+            $keyValuePairs['status'] = BLOG_STATUS_DISABLED;
 
-                if( !$result )
-                    return false;
+            $query = Db::buildUpdateQuery( BLOGS_TABLENAME,
+                                           $keyValuePairs,
+                                           'id',
+                                           $blogId );
 
-                if( $this->_db->Affected_Rows() == 0 )
-                    return false;
+            $result = $this->Execute( $query );
 
-                return true;
-         }
-     }
+            if( !$result || $this->_db->Affected_Rows() == 0 )
+                return false;
+
+            $this->_cache->removeData( $blogId, CACHE_BLOGINFOS );
+
+            return true;
+        }
+
+        /**
+         * @private
+         */
+        function _getBlogInfoFromQuery( $query, $extendedInfo = false )
+        {
+            $result = $this->Execute( $query );
+
+            if( !$result )
+                return false;
+
+            if( $result->RecordCount() == 0 )
+                return false;
+
+            $row = $result->FetchRow( $result );
+            $blogInfo = $this->_fillBlogInformation( $row, $extendedInfo );
+            $blogSettings = $this->getBlogSettingsFromField( $row["settings"] );
+            $blogInfo->setSettings( $blogSettings );
+
+            return $blogInfo;
+        }
+
+        /**
+         * Private function.
+         *
+         * @private
+         */
+        function _fillBlogInformation( $query_result, $extended = false )
+        {
+            // source class
+            include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
+
+            // create new BlogInfo
+            $blogInfo = new BlogInfo( stripslashes($query_result["blog"]),
+                                      $query_result["owner_id"],
+                                      stripslashes($query_result["about"]),
+                                      unserialize($query_result["settings"]),
+                                      $query_result["id"] );
+
+            // load information about the blog owner
+            $blogInfo->setStatus( $query_result["status"] );
+
+            return $blogInfo;
+        }
+    }
 ?>

Modified: plog/trunk/class/dao/customfields/customfield.class.php
===================================================================
--- plog/trunk/class/dao/customfields/customfield.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/customfields/customfield.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,7 +1,6 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
-	include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );	
 
 	/**
      * Defines a custom field
@@ -54,6 +53,8 @@
 		
 		function setName( $name )
 		{
+	        include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );	
+
 			$this->_name = Textfilter::filterAllHTML( $name );
 		}
 		
@@ -113,4 +114,4 @@
 			return $this->_defaultValue;	
 		}		
 	}
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/dao/customfields/customfieldcheckboxvalue.class.php
===================================================================
--- plog/trunk/class/dao/customfields/customfieldcheckboxvalue.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/customfields/customfieldcheckboxvalue.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,7 +1,6 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/dao/customfields/customfieldvalue.class.php" );
-	include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
 	
 	/**
 	 * offers methods for dealing with checkboxes
@@ -32,4 +31,4 @@
 			return( $this->getValue() == "1" );
 		}
 	}
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/dao/customfields/customfielddatevalue.class.php
===================================================================
--- plog/trunk/class/dao/customfields/customfielddatevalue.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/customfields/customfielddatevalue.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,7 +1,6 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/dao/customfields/customfieldvalue.class.php" );
-	include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
 	
 	/**
 	 * offers methods for dealing with custom fields that represent dates
@@ -42,6 +41,8 @@
 		 */
 		function setValue( $value )
 		{
+	        include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
             $this->_timestamp = new Timestamp();
             $dateTimeParts = explode(" ", $value );
             $dateParts = explode( "/", $dateTimeParts[0] );
@@ -80,8 +81,10 @@
 		 */
 		function getDefaultValue()
 		{
+	        include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
 			return( new Timestamp());	
 		}
 	}
 	
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/dao/model.class.php
===================================================================
--- plog/trunk/class/dao/model.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/model.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,185 +1,222 @@
 <?php
 
     /**
-	 * \defgroup DAO
-	 *	
+     * \defgroup DAO
+     *    
      * DAO stands for "Data Access Object" and represents a data model according to the MVC architecture. 
-	 *
-	 * DAO classes isolate developers of all the intricacies of the database structure, so that for example
-	 * loading a post from the dabase is as easy as:
-	 *
-	 * <pre>
-	 *   $articles = new Articles();
-	 *   $userPost = $arcticles->getBlogArticle( 15 );
-	 * </pre>
-	 *
-	 * Otherwise, developers would need to write an SQL query every time we need to load an article from the database. In
-	 * general, DAO classes provide access to reading, updating and removing data from the database. In pLog, we usually
-	 * have two classes per entity: a smaller one that contains no database access logic and that only contains the
-	 * information necessary (usually, it represents a row from the database), and the second will be a bigger
-	 * class that includes SQL code and database logic and that provides all the methods outlined above (read, update
-	 * and remove from the database) Examples of this are Articles and Article, or Users and UserInfo. 
-	 *
-	 * Other relevant DAO classes are ArticleComments and UserComment, MyLink and MyLinks, etc.
-	 *
-	 * All classes that extend the base Model class, automatically inherit an open connection to the database 
-	 * (via the private attribute Model::_db) and several other database-related methods. 
-	 *
-	 * If you need to implement some kind of data access, please extend from Model.
      *
-	 */
+     * DAO classes isolate developers of all the intricacies of the database structure, so that for example
+     * loading a post from the dabase is as easy as:
+     *
+     * <pre>
+     *   $articles = new Articles();
+     *   $userPost = $arcticles->getBlogArticle( 15 );
+     * </pre>
+     *
+     * Otherwise, developers would need to write an SQL query every time we need to load an article from the database. In
+     * general, DAO classes provide access to reading, updating and removing data from the database. In pLog, we usually
+     * have two classes per entity: a smaller one that contains no database access logic and that only contains the
+     * information necessary (usually, it represents a row from the database), and the second will be a bigger
+     * class that includes SQL code and database logic and that provides all the methods outlined above (read, update
+     * and remove from the database) Examples of this are Articles and Article, or Users and UserInfo. 
+     *
+     * Other relevant DAO classes are ArticleComments and UserComment, MyLink and MyLinks, etc.
+     *
+     * All classes that extend the base Model class, automatically inherit an open connection to the database 
+     * (via the private attribute Model::_db) and several other database-related methods. 
+     *
+     * If you need to implement some kind of data access, please extend from Model.
+     *
+     */
 
-	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
-    include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
-    include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
+    include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
 
-	/**
-	 * default database prefix, if none other specified
-	 */
+    /**
+     * default database prefix, if none other specified
+     */
     define( "DEFAULT_DB_PREFIX", "plog_" );
 
-	/**
-	 * whether database-level debugging is enabled
-	 */
-	define( "DAO_DEBUG_ENABLED", false );
+    /**
+     * whether database-level debugging is enabled
+     */
+    define( "DAO_DEBUG_ENABLED", false );
 
-	/**
-	 * how many items per page by default, when paging is enabled
-	 */
-	define( "DEFAULT_ITEMS_PER_PAGE", 15 );
-	
-	/**
-	 * whether we're going to use paging or not.
-	 */
-	define( "DEFAULT_PAGING_ENABLED", -1 );
+    /**
+     * how many items per page by default, when paging is enabled
+     */
+    define( "DEFAULT_ITEMS_PER_PAGE", 15 );
+    
+    /**
+     * whether we're going to use paging or not.
+     */
+    define( "DEFAULT_PAGING_ENABLED", -1 );
 
-	/**
-	 * \ingroup DAO
-	 *
+    /**
+     * the names of the tables used in pLog
+     */
+    define( 'BLOGS_TABLENAME',                           'blogs' );
+    define( 'ARTICLES_TABLENAME',                        'articles' );
+    define( 'ARTICLETEXTS_TABLENAME',                    'articles_text' );
+    define( 'ARTICLE_CATEGORIES_RELATIONSHIP_TABLENAME', 'article_categories_link' );
+
+
+    /**
+     * \ingroup DAO
+     *
      * This class provides all the classes extending it with a database connection so that classes don't have to 
-	 * worry about that. Later on, the Model classes will be used by the corresponding action object.
+     * worry about that. Later on, the Model classes will be used by the corresponding action object.
      */
     class Model extends Object 
-	{
+    {
 
-		var $_db;		
-        var $_prefix;
+        var $_db;        
+        var $_prefix = null;
+        var $_cache;
+        var $_dbInitialized =  false;
 
         /**
          * So far, it only initializes the connection to the database, using the ADOdb API.
+         *
+         * @param useCache Some object might not need a cache and can disable it by passing false
          */
-		function Model()
+        function Model( $useCache = true )
         {
             $this->Object();
 
-            $this->_db =& Db::getDb();
-
-            // fetch the database prefix            
-            $this->_prefix = Db::getPrefix();
-
-			$this->_db->debug=DAO_DEBUG_ENABLED;
+            if ( $useCache ) {
+                // allow a cache for all dao objects
+                include_once( PLOG_CLASS_PATH . "class/cache/cachemanager.class.php" );
+                $this->_cache =& CacheManager::getCache();
+            }
         }
 
-		/**
-		 * executes a query with certain limits (for paging, for ex.
-		 *
-		 * @param query
-		 * @param page
-		 * @param itemsPerPage
-		 * @see Execute
-		 * @return A ResultSet or false if errors
-		 */        
+        /**
+         * executes a query with certain limits (for paging, for ex.
+         *
+         * @param query
+         * @param page
+         * @param itemsPerPage
+         * @see Execute
+         * @return A ResultSet or false if errors
+         */        
         function Execute( $query, $page = DEFAULT_PAGING_ENABLED, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
         {
-			// if paging is enabled...
-			if( $page > DEFAULT_PAGING_ENABLED ) {
-				$start = (($page - 1) * $itemsPerPage);
-				$limits = " LIMIT $start, $itemsPerPage";
-				$query .= " $limits";
-			}
-		
-			$result = $this->_db->Execute( $query );
+            $this->log->info("executing $query");
+            $this->_initializeDb();
 
-			// if the query generated an error, write a message to the sql error log file
-			if( !$result ) {
-				$log =& LoggerManager::getLogger( "sqlerr" );
-				$error = $this->DbError();
-				$log->error( "The following query = \n{$query}\ngenerated the following error message = \n{$error}" );
-			}
-			
-			//$this->log->debug( "query = $query" );
-				
-			return( $result );
+            // if paging is enabled...
+            if( $page > DEFAULT_PAGING_ENABLED ) {
+                $start = (($page - 1) * $itemsPerPage);
+                $limits = " LIMIT $start, $itemsPerPage";
+                $query .= " $limits";
+            }
+        
+            $result = $this->_db->Execute( $query );
+
+            // if the query generated an error, write a message to the sql error log file
+            if( !$result ) {
+                include_once( PLOG_CLASS_PATH."class/logger/loggermanager.class.php" );
+
+                $log =& LoggerManager::getLogger( "sqlerr" );
+                $error = $this->DbError();
+                $log->error( "The following query = \n{$query}\ngenerated the following error message = \n{$error}" );
+            }
+                
+            return( $result );
         }
 
-		/**
-		 * executes and caches a query, using ADOdb's built-in caching features
-		 *
-		 * @param query the query to execute
-		 */
-		function CacheExecute( $query ) 
-		{
-			$queryCache=& Db::getDbCache();
-			
-			// we should only cache 'SELECT' queries
-			if( substr($query, 0, 6) == "SELECT" ) {
-				if( empty($queryCache[$query])) {
-					$queryCache[$query] = $this->_db->Execute( $query );
-				}
-					
-				$result = $queryCache[$query];
-			}
-			else {
-				$result = $this->_db->Execute( $query );
-			}
-			
-			return $result;
-		}
+        /**
+         * executes and caches a query, using ADOdb's built-in caching features
+         *
+         * @param query the query to execute
+         */
+        function CacheExecute( $query ) 
+        {
+            $queryCache=& Db::getDbCache();
+            
+            // we should only cache 'SELECT' queries
+            if( substr($query, 0, 6) == "SELECT" ) {
+                if( empty($queryCache[$query])) {
+                    $queryCache[$query] = $this->_db->Execute( $query );
+                }
+                    
+                $result = $queryCache[$query];
+            }
+            else {
+                $result = $this->_db->Execute( $query );
+            }
+            
+            return $result;
+        }
 
         /**
          * Returns the last error message from the database.
          */
         function DbError()
         {
-        	return $this->_db->ErrorMsg();
+            return $this->_db->ErrorMsg();
         }
 
-		/**
-		 * returns the current database prefix
-		 *
-		 * @return the current database prefix
-		 */
+        /**
+         * returns the current database prefix
+         *
+         * @return the current database prefix
+         */
         function getPrefix()
         {
-        	return $this->_prefix;
+            if ( $this->_prefix == null ) {
+                include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
+
+                $this->_prefix = Db::getPrefix();
+            }
+
+            return $this->_prefix;
         }
 
-		/**
-		 * retrieves the number of records in a table given an optional condition
-		 *
-		 * @param table
-		 * @param cond
-		 * @return the number of items or 0 if none or error
-		 */
-		function getNumItems( $table, $cond = "" )
-		{
-			// build up the query
-			if( $cond != "" ) $cond = "WHERE $cond";
-			$query = "SELECT COUNT(*) AS total FROM $table $cond";
+        /**
+         * retrieves the number of records in a table given an optional condition
+         *
+         * @param table
+         * @param cond
+         * @return the number of items or 0 if none or error
+         */
+        function getNumItems( $table, $cond = "" )
+        {
+            // build up the query
+            if( $cond != "" ) $cond = "WHERE $cond";
+            $query = "SELECT COUNT(*) AS total FROM $table $cond";
 
-			// execute it
-			$result = $this->Execute( $query );
+            // execute it
+            $result = $this->Execute( $query );
 
-			if( !$result )
-				return 0;
-			
-			// if no error, get the result
-			$row = $result->FetchRow();
-			$total = $row["total"];
-			if( $total == "" ) $total = 0;
+            if( !$result )
+                return 0;
+            
+            // if no error, get the result
+            $row = $result->FetchRow();
+            $total = $row["total"];
+            if( $total == "" ) $total = 0;
 
-			return $total;
-		}
+            return $total;
+        }
+
+        /**
+         * Initialize the Db and set the table-prefix.
+         */
+        function _initializeDb()
+        {
+            if ( !$this->_dbInitialized ) {
+                include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
+
+                $this->_db =& Db::getDb();
+
+                // fetch the database prefix            
+                $this->getPrefix();
+                // $this->_db->debug=DAO_DEBUG_ENABLED;
+
+                $this->_dbInitialized = true;
+            }
+        }
 		
 		/**
 		 * method to generate search conditions, should be implemented by child classes

Modified: plog/trunk/class/dao/mylink.class.php
===================================================================
--- plog/trunk/class/dao/mylink.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/mylink.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -157,6 +157,8 @@
 		
         function setDate( $newDate )
         {
+            include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
             $this->_date = $newDate;
             $this->_timestamp = new Timestamp( $newDate );
         }
@@ -181,4 +183,4 @@
 			$this->_rssFeed = $rssFeed;
 		}
 }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/dao/mylinks.class.php
===================================================================
--- plog/trunk/class/dao/mylinks.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/mylinks.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -2,6 +2,7 @@
 
 	include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/mylink.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/bloglinks.class.php" );
 	include_once( PLOG_CLASS_PATH."class/dao/mylinkscategories.class.php" );
 
     /**
@@ -22,33 +23,42 @@
 		 */
 		function getLinks( $blogId, $categoryId = 0, $page = -1, $itemsPerPage = 15 )
 		{
-			// check if we're using any paging
-	        if( $page > -1 ) {
-				$start = (($page - 1) * $itemsPerPage);
-				$limits = " LIMIT $start, $itemsPerPage";
-			}
-	    	else
-	    		$limits = "";
-		
-			$query = "SELECT * FROM ".$this->getPrefix()."mylinks WHERE blog_id = '".Db::qstr($blogId)."'";
-            if( $categoryId != 0 )
-            	$query .= " AND category_id = '".Db::qstr($categoryId)."'";
-            $query .= " ORDER BY id ASC $limits;";
-			
-			$result = $this->Execute( $query );
+            $blogLinks = $this->getBlogLinks( $blogId );
 
-			if( !$result )
-				return false;
+            $myLinks = $blogLinks->getLinksForCategory( $categoryId );
 
-			$blogLinks = Array();
+            // check if we're using any paging
+            if( $page > -1 ) {
+                $start = (($page - 1) * $itemsPerPage);
+                $myLinks = array_slice( $myLinks, $start, $itemsPerPage );
+            }
 
-			while( $row = $result->FetchRow()) {
-				$blogLink = $this->_fillMyLinkInformation( $row );
-                array_push( $blogLinks, $blogLink );
-			}
+			return $myLinks;
+		}
 
-			return $blogLinks;
-		}
+        function getBlogLinks( $blogId )
+        {
+            $blogLinks = $this->_cache->getData( $blogId, CACHE_BLOGLINKS );
+
+            if( !$blogLinks ) {
+                $query = "SELECT * FROM ".$this->getPrefix()."mylinks WHERE blog_id = '".Db::qstr($blogId)."' ORDER BY id;";
+
+                $result = $this->Execute( $query );
+
+                if( !$result )
+                    return false;
+
+                $links = Array();
+
+                while( $row = $result->FetchRow()) {
+                    $link = $this->_fillMyLinkInformation( $row );
+                    array_push( $links, $link );
+                }
+                $blogLinks = new BlogLinks( $blogId, $links );
+                $this->_cache->setData( $blogId, CACHE_BLOGLINKS, $blogLinks );
+            }
+            return $blogLinks;
+        }
 		
 		/**
 		 * returns how many links a blog has
@@ -59,13 +69,9 @@
 		 */
 		function getNumLinks( $blogId, $categoryId = 0 )
 		{
-			$prefix = $this->getPrefix();
-			$table = "{$prefix}mylinks";
-			$cond = "blog_id = '".Db::qstr($blogId)."'";
-			if( $categoryId > 0 )
-				$cond .=  " AND category_id = '".Db::qstr($categoryId)."'";
-				
-			return( $this->getNumItems( $table, $cond ));
+            $blogLinks = $this->getBlogLinks( $blogId );
+            $categoryLinks = $blogLinks->getLinksForCategory( $categoryId );
+            return count( $categoryLinks );
 		}		
 
         /**
@@ -92,6 +98,8 @@
 				// mark the corresponding link categories as modified now
 				$linkCategories = new MyLinksCategories();
 				$linkCategories->updateCategoryModificationDate( $myLink->getCategoryId());
+
+                $this->_cache->removeData( $blogId, CACHE_BLOGLINKS );
 			}
 
             return $result;
@@ -116,6 +124,8 @@
 				$linkCategories->updateCategoryModificationDate( $myLink->getCategoryId());
 			}*/
 
+            $this->_cache->removeData( $blogId, CACHE_BLOGLINKS );
+
             return $result;
         }
 
@@ -130,6 +140,8 @@
 
 			$result = $this->Execute( $query );
 
+            $this->_cache->removeData( $blogId, CACHE_BLOGLINKS );
+
             return $result;
         }        
 
@@ -142,21 +154,28 @@
          */
         function getMyLink( $linkId, $blogId = -1 )
         {
-        	$query = "SELECT * FROM ".$this->getPrefix()."mylinks WHERE id = ".Db::qstr($linkId);
-			if( $blogId > 0 )
-				$query .= " AND blog_id = '".$blogId."';";
+            $blogLink = $this->_cache->getData( $linkId, CACHE_MYLINKS );
 
-            $result = $this->Execute( $query );
+            if ( !$blogLink  || ( $blogLink->getBlogId() != $blogId && $blogId != -1 ) ) {
+                $query = "SELECT * FROM ".$this->getPrefix()."mylinks WHERE id = ".Db::qstr($linkId);
+                if( $blogId > 0 )
+                    $query .= " AND blog_id = '".$blogId."';";
 
-            if( !$result )
-            	return false;
+                $result = $this->Execute( $query );
 
-            if( $result->RecordCount() == 0 )
-            	return false;
+                if( !$result )
+                    return false;
 
-            $row = $result->FetchRow();
-			$blogLink = $this->_fillMyLinkInformation( $row );
+                if( $result->RecordCount() == 0 )
+                    return false;
 
+                $row = $result->FetchRow();
+                $blogLink = $this->_fillMyLinkInformation( $row );
+
+                // update the cache
+                $this->_cache->setData( $linkId, CACHE_MYLINKS, $blogLink );
+            }
+
             return $blogLink;
         }
 
@@ -183,11 +202,11 @@
             if( !$result )
             	return false;
             else {
-				if( $result ) {
-					// mark the corresponding link categories as modified now
-					$linkCategories = new MyLinksCategories();
-					$linkCategories->updateCategoryModificationDate( $myLink->getCategoryId());
-				}
+                // mark the corresponding link categories as modified now
+                $linkCategories = new MyLinksCategories();
+                $linkCategories->updateCategoryModificationDate( $myLink->getCategoryId());
+
+                $this->_cache->removeData( $myLink->getBlogId(), CACHE_BLOGLINKS );
 			
             	return true;
 			}
@@ -207,4 +226,4 @@
 			return $blogLink;
 		}
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/dao/mylinkscategories.class.php
===================================================================
--- plog/trunk/class/dao/mylinkscategories.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/mylinkscategories.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -28,7 +28,10 @@
 		 * @param page
 		 * @param itemsPerPage
          */
-        function getMyLinksCategories( $blogId, $order = MYLINKS_CATEGORIES_NO_ORDER, $page = -1, $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
+        function getMyLinksCategories( $blogId, 
+                                       $order = MYLINKS_CATEGORIES_NO_ORDER, 
+                                       $page = -1, 
+                                       $itemsPerPage = DEFAULT_ITEMS_PER_PAGE )
         {
 			$prefix = $this->getPrefix();			
 			// basic query
@@ -237,8 +240,7 @@
 			$query = "UPDATE ".$this->getPrefix()."mylinks_categories
 					  SET last_modification = NOW()
 					  WHERE id = '".Db::qstr( $categoryId )."'";
-			$this->_db->debug=false;
-			$result = $this->_db->Execute( $query );
+			$result = $this->Execute( $query );
 			
 			return $result;
 		}
@@ -251,8 +253,7 @@
 			$query = "UPDATE ".$this->getPrefix()."mylinks_categories
 					  SET last_modification = '".Db::qstr( $lastModification )."' 
 					  WHERE id = '".Db::qstr( $categoryId )."'";
-			$this->_db->debug=false;
-			$result = $this->_db->Execute( $query );
+			$result = $this->Execute( $query );
 			
 			return $result;
 		}

Modified: plog/trunk/class/dao/mylinkscategory.class.php
===================================================================
--- plog/trunk/class/dao/mylinkscategory.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/mylinkscategory.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,7 +1,6 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
-	include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
 
     /**
 	 * \ingroup DAO
@@ -28,6 +27,8 @@
          */
         function MyLinksCategory( $name, $blogId, $numLinks = 0, $properties = Array(), $id = -1 )
         {
+	        include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
 			$this->DbObject();
 
 			$this->_name = $name;

Modified: plog/trunk/class/dao/referer.class.php
===================================================================
--- plog/trunk/class/dao/referer.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/referer.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,7 +1,6 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
 
     /**
 	 * \ingroup DAO
@@ -32,6 +31,8 @@
          */
     	function Referer( $url, $articleId, $blogId, $date, $count = 0, $id = 0 )
         {
+            include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
 			$this->DbObject();
         	$this->_url = $url;
             $this->_articleId = $articleId;

Modified: plog/trunk/class/dao/referers.class.php
===================================================================
--- plog/trunk/class/dao/referers.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/referers.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,9 +1,7 @@
 <?php
 
-	include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
-    include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/referer.class.php" );
-    include_once( PLOG_CLASS_PATH."class/net/url.class.php" );
+	require_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
+    require_once( PLOG_CLASS_PATH."class/config/config.class.php" );
 	
 	define( "REFERRERS_LIST_ITEMS_PER_PAGE", 15 );	
 
@@ -37,6 +35,8 @@
          */
         function addReferer( $refererHeader, $articleId, $blogId )
         {
+            require_once( PLOG_CLASS_PATH."class/net/url.class.php" );
+
         	// quit inmediately if this is not enabled...
         	if( !$this->_enabled )
             	return;
@@ -151,6 +151,8 @@
          */
         function _fillRefererInformation( $row )
         {
+            require_once( PLOG_CLASS_PATH."class/dao/referer.class.php" );
+
         	$referer = new Referer( $row["url"], $row["article_id"], $row["blog_id"], $row["last_date"], $row["hits"], $row["id"] );
 
             return $referer;
@@ -181,7 +183,7 @@
 				
 			$row = $result->FetchRow();
 			$referrer = $this->_fillRefererInformation( $row );
-			
+
 			return $referrer;
 		}
 		

Modified: plog/trunk/class/dao/searchengine.class.php
===================================================================
--- plog/trunk/class/dao/searchengine.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/searchengine.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -220,7 +220,7 @@
 		{
 			// build the search query
 			$searchQuery = $this->_generateSearchArticlesQuery( $blogId, $query, $minRelevance = 0, $maxResults = 0, $status = POST_STATUS_PUBLISHED, $userId = -1, $date = 0 );
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
             
             // return an empty array if nothing available
             if( !$result )
@@ -363,7 +363,7 @@
 		 */
 		function _getQueryResults ( $query, $queryType )
 		{
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
             
             // return an empty array if nothing available
             if( !$result )

Modified: plog/trunk/class/dao/sitestatistics.class.php
===================================================================
--- plog/trunk/class/dao/sitestatistics.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/sitestatistics.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -45,6 +45,8 @@
 
         function getNumberOfPostsToday()
         {
+            include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
         	$today = new Timestamp();
             $todayTimestamp = $today->getYear().$today->getMonth().$today->getDay();
         	$query = "SELECT COUNT(*) AS total FROM ".$this->getPrefix()."articles".
@@ -55,6 +57,8 @@
 
         function getNumberOfPostsThisMonth()
         {
+            include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
         	$today = new Timestamp();
             $monthTimestamp = $today->getYear().$today->getMonth();
         	$query = "SELECT COUNT(*) AS total FROM ".$this->getPrefix()."articles".

Modified: plog/trunk/class/dao/trackbacks.class.php
===================================================================
--- plog/trunk/class/dao/trackbacks.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/trackbacks.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -3,6 +3,8 @@
 	include_once( PLOG_CLASS_PATH."class/dao/commentscommon.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/trackback.class.php" );
 
+    define( 'NO_TRACKBACKS', 'no trackbacks available' );
+
 	/**
      * Implementation of a trackback feature.
      * The technical specifications of the trackback protocol can be found
@@ -157,6 +159,7 @@
 		
 		/**
 		 * gets a single trackback from the db
+         * only used by the admin panel, no caching enabled
 		 *
 		 * @param trackbackId
 		 * @param postId
@@ -177,6 +180,10 @@
 		function deletePostTrackback( $trackbackId, $articleId )
 		{
 			return( CommentsCommon::deletePostComment( $articleId, $trackbackId, COMMENT_TYPE_TRACKBACK ));
+
+            // clear the cache
+            $this->_cache->removeData( $artId, CACHE_TRACKBACKS );
+            $this->_cache->removeData( $artId, CACHE_NUMTRACKBACKS );
 		}
 		
 		/**

Modified: plog/trunk/class/dao/usercomment.class.php
===================================================================
--- plog/trunk/class/dao/usercomment.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/usercomment.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,10 +1,10 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
-	include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
 	include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
 	include_once( PLOG_CLASS_PATH."class/dao/article.class.php" );
-	
+	include_once( PLOG_CLASS_PATH."class/dao/articlecommentstatus.class.php" );
+
     /**
      * This class represents a comment made by a casual user to an article. Please use the getter methods
      * exposed here to get all the information regarding this comment, such as the name of the user who
@@ -113,6 +113,8 @@
             $this->_status = $status;
 
             if( $date == null ) {
+	            include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
             	$t = new Timestamp();
                 $date = $t->getTimestamp();
             }
@@ -272,6 +274,7 @@
          */
 		function getDate()
 		{
+
 			return $this->_date;
 		}
 
@@ -281,6 +284,9 @@
          */
 		function setDate( $newdate )
 		{
+            // source necessary source
+            include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
 			$this->_date = $newdate;
 
 			// update the Timestamp object so that we can have more information
@@ -294,7 +300,7 @@
          * @preturn A Timestamp object representing the date.
          */
 		function getDateObject()
-		{
+		{ 
 			return $this->_timeStamp;
 		}
 

Modified: plog/trunk/class/dao/userinfo.class.php
===================================================================
--- plog/trunk/class/dao/userinfo.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/userinfo.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,8 +1,6 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/database/dbobject.class.php" );
-    include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresource.class.php" );
-	include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
 
     /**
      * Represents a user in our application. Includes information such as the username,
@@ -84,6 +82,8 @@
 
 		function setUsername( $newUsername )
 		{
+            include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+
 			$this->_username = Textfilter::filterAllHTML( $newUsername );
 		}
 
@@ -178,6 +178,7 @@
 		function _loadPicture()
 		{
 			include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
+
 			$resources = new GalleryResources();
 			$picture = $resources->getResource( $this->_resourcePictureId );
 			

Modified: plog/trunk/class/dao/userpermissions.class.php
===================================================================
--- plog/trunk/class/dao/userpermissions.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/userpermissions.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,8 +1,7 @@
 <?php
 
-	include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/userpermission.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );	
 
     //
     // :KLUDGE: This should be done in a better way...
@@ -13,15 +12,15 @@
 
     /**
      * Handles user permissions.
-	 *
-	 * \ingroup DAO
+     *
+     * \ingroup DAO
      */
-	class UserPermissions extends Model 
-	{
+    class UserPermissions extends Model 
+    {
 
-    	function UserPermissions()
+        function UserPermissions()
         {
-        	$this->Model();
+            $this->Model();
 
             //print("user constructor<br/>");
         }
@@ -39,31 +38,33 @@
         {
             $perms = Array();
 
-        	// check if the user is the owner
+            // check if the user is the owner
             $query = "SELECT owner_id FROM ".$this->getPrefix()."blogs WHERE id = '".Db::qstr($blogId)."'";
             $result = $this->Execute( $query );
             if( $result ) {
-            	$row = $result->FetchRow();
+                $row = $result->FetchRow();
                 if( $row["owner_id"] == $userId ) {
-                	$perm = new UserPermission( $userId, $blogId, PERMISSION_BLOG_OWNER, 0 );
+                    $perm = new UserPermission( $userId, $blogId, PERMISSION_BLOG_OWNER, 0 );
                     array_push( $perms, $perm );
                 }
             }
 
             // we can continue now to check for other permissions, even though BLOG_OWNER level
             // is higher than any other
-        	$query = "SELECT * FROM ".$this->getPrefix()."users_permissions WHERE user_id = '".Db::qstr($userId)."' AND blog_id = '".Db::qstr($blogId)."'";
+            $query = "SELECT * FROM ".$this->getPrefix()."users_permissions WHERE user_id = '".Db::qstr($userId)."' AND blog_id = '".Db::qstr($blogId)."'";
 
             $result = $this->Execute( $query );
             //$result = $this->_db->CacheExecute( 60, $query );
 
             if( !$result )
-            	return false;
+                return false;
 
             while( $row = $result->FetchRow()) {
-            	array_push( $perms, $this->_fillUserPermissionInformation( $row ));
+                array_push( $perms, $this->_fillUserPermissionInformation( $row ));
             }
 
+            $this->_cache->setData( $userId . '_' . $blogId, CACHE_USERPERMISSIONS, $perms );
+
             return $perms;
         }
 
@@ -72,7 +73,7 @@
          */
         function _fillUserPermissionInformation( $row )
         {
-        	$perm = new UserPermission( $row["user_id"], $row["blog_id"], $row["permission_id"], $row["id"] );
+            $perm = new UserPermission( $row["user_id"], $row["blog_id"], $row["permission_id"], $row["id"] );
 
             return $perm;
         }
@@ -85,32 +86,40 @@
          */
         function isSiteAdmin( $userId )
         {
-        	if( isset($this->cache[$userId])) {
-            	//print("user cached<br/>");
-                $result = $this->cache[$userId];
-            }
-            else {
+            $isAdmin = $this->_cache->getData( $userId, CACHE_SITEADMINS );
 
-        		$query = "SELECT * FROM ".$this->getPrefix()."users_permissions WHERE permission_id = 1 AND user_id = '".Db::qstr($userId)."'";
+            if ( is_bool($isAdmin) ) {
+                // fetched from cache
+                return $isAdmin;
+            } else {
+                if( isset($this->cache[$userId])) {
+                    //print("user cached<br/>");
+                    $result = $this->cache[$userId];
+                }
+                else {
 
-            	$result = $this->Execute( $query );
+                    $query = "SELECT * FROM ".$this->getPrefix()."users_permissions WHERE permission_id = 1 AND user_id = '".Db::qstr($userId)."'";
 
-                $this->cache[$userId] = $result;
-                //print("user fetching!<br/>");
-            }
+                    $result = $this->Execute( $query );
 
-            if( !$result )
-            	return false;
+                    $this->cache[$userId] = $result;
+                    //print("user fetching!<br/>");
+                }
 
-            if( $result->RowCount() == 0 )
-            	return false;
+                if( !$result )
+                    return false;
 
-            // let's double check and make completely sure...
-            $row = $result->FetchRow();
-            if( $row["user_id"] == $userId )
-            	return true;
-            else
-            	return false;
+                if( $result->RowCount() == 0 )
+                    return false;
+
+                // let's double check and make completely sure...
+                $row = $result->FetchRow();
+                if( $row["user_id"] == $userId ) {
+                    $this->_cache->setData( $userId, CACHE_SITEADMINS, true );
+                    return true;
+                } else
+                    return false;
+            }
         }
 
         /**
@@ -120,19 +129,22 @@
          */
         function setSiteAdmin( $userId )
         {
-        	// first check if the user already has administrator permissions
-        	if( $this->isSiteAdmin( $userId ))
-            	return true;
+            // first check if the user already has administrator permissions
+            if( $this->isSiteAdmin( $userId ))
+                return true;
 
             // if not, we can proceed and give them
             $query = "INSERT INTO ".$this->getPrefix()."users_permissions (user_id,blog_id,permission_id) VALUES ( $userId, 0, 1 );";
 
             $result = $this->Execute( $query );
 
+            // clear the cache
+            $this->_cache->removeData( $userId, CACHE_SITEADMINS );
+
             if( !$result )
-            	return false;
+                return false;
             else
-            	return true;
+                return true;
         }
 
         /**
@@ -143,19 +155,22 @@
          */
         function revokeSiteAdmin( $userId )
         {
-        	// we don't have to do anything if the user is not an administrator
-        	if( !$this->isSiteAdmin( $userId ))
-            	return true;
+            // we don't have to do anything if the user is not an administrator
+            if( !$this->isSiteAdmin( $userId ))
+                return true;
 
             // if he or she is, we can proceed and remove the permission
             $query = "DELETE FROM ".$this->getPrefix()."users_permissions WHERE user_id = $userId AND blog_id = 0 AND permission_id = 1;";
 
             $result = $this->Execute( $query );
 
+            // clear the cache
+            $this->_cache->removeData( $userId, CACHE_SITEADMINS );
+
             if( !$result )
-            	return false;
+                return false;
             else
-            	return true;
+                return true;
         }
 
         /**
@@ -164,15 +179,15 @@
          * remove them otherwise.
          *
          * @param userId The user identifier.
-         * @param siteAdmin A boolean value
+         * @param isAdmin A boolean value
          * @return Returns always true.
          */
-        function updateSiteAdmin( $userId, $siteAdmin )
+        function updateSiteAdmin( $userId, $isAdmin )
         {
-        	if( $siteAdmin )
-            	$result = $this->setSiteAdmin( $userId );
+            if( $isAdmin )
+                $result = $this->setSiteAdmin( $userId );
             else
-            	$result = $this->revokeSiteAdmin( $userId );
+                $result = $this->revokeSiteAdmin( $userId );
 
             return $result;
         }
@@ -189,7 +204,7 @@
          */
         function grantPermission( $userId, $blogId, $permissionId )
         {
-        	// check if the permission has already been granted
+            // check if the permission has already been granted
             $query = "SELECT * FROM ".$this->getPrefix()."users_permissions
                       WHERE user_id = $userId AND blog_id = $blogId
                       AND permission_id = $permissionId";
@@ -198,7 +213,7 @@
 
             // the permission has already been granted so there's nothing else to do here
             if( $result && $result->RowCount() == 1 )
-            	return true;
+                return true;
 
             // if not, grant it now
             $query = "INSERT INTO ".$this->getPrefix()."users_permissions
@@ -207,9 +222,9 @@
             $result = $this->Execute( $query );
 
             if( !$result )
-            	return false;
+                return false;
             else
-            	return true;
+                return true;
         }
 
         /**
@@ -223,7 +238,7 @@
          */
         function revokePermission( $userId, $blogId, $permissionId )
         {
-        	// check if the permission has already been removed or doesn't exist
+            // check if the permission has already been removed or doesn't exist
             $query = "SELECT * FROM ".$this->getPrefix()."users_permissions
                       WHERE user_id = $userId AND blog_id = $blogId
                       AND permission_id = $permissionId";
@@ -231,10 +246,10 @@
             $result = $this->Execute( $query );
 
             if( !$result )
-            	return true;
+                return true;
 
             if( $result->RowCount() == 0 )
-            	return true;
+                return true;
 
             // if not, grant it now
             $query = "DELETE FROM ".$this->getPrefix()."users_permissions
@@ -243,9 +258,9 @@
             $result = $this->Execute( $query );
 
             if( !$result )
-            	return false;
+                return false;
             else
-            	return true;
+                return true;
         }
 
         /**
@@ -257,7 +272,7 @@
          */
         function revokeBlogPermissions( $blogId )
         {
-        	$query = "DELETE FROM ".$this->getPrefix()."users_permissions
+            $query = "DELETE FROM ".$this->getPrefix()."users_permissions
                       WHERE blog_id = $blogId";
 
             $result = $this->Execute( $query );
@@ -265,34 +280,34 @@
             return $result;
         }
 
-		/**
-		* updates the list of users that have access to the blog. But this method works so
-		 * that it first removes all current permissions and then recreates them again
-		 * based on the given list of users
-		 *
-		 * @param blogId
-		 * @param userIdList An associative array with user ids
-		 * @return true if successful or false otherwise
-		 */
-		function updateBlogUserPermissions( $blogId, $userList )
-		{
-			// first of all, remove all the permissions
-			$this->revokeBlogPermissions( $blogId );
-			
-			// make sure that we're dealing with an array
-			if( !is_array( $userList )) {
-				return false;
-			}
-			
-			// loop through the array and recreate the permissions
-			foreach( $userList as $userId ) {
-				if( $userId > 0 ) {
-					$this->grantPermission( $userId, $blogId, PERMISSION_BLOG_USER );
-				}
-			}
-			
-			return true;
-		}
+        /**
+        * updates the list of users that have access to the blog. But this method works so
+         * that it first removes all current permissions and then recreates them again
+         * based on the given list of users
+         *
+         * @param blogId
+         * @param userIdList An associative array with user ids
+         * @return true if successful or false otherwise
+         */
+        function updateBlogUserPermissions( $blogId, $userList )
+        {
+            // first of all, remove all the permissions
+            $this->revokeBlogPermissions( $blogId );
+            
+            // make sure that we're dealing with an array
+            if( !is_array( $userList )) {
+                return false;
+            }
+            
+            // loop through the array and recreate the permissions
+            foreach( $userList as $userId ) {
+                if( $userId > 0 ) {
+                    $this->grantPermission( $userId, $blogId, PERMISSION_BLOG_USER );
+                }
+            }
+            
+            return true;
+        }
 
         /**
          * revokes all the permissions that a user may have
@@ -302,7 +317,7 @@
          */
         function revokeUserPermissions( $userId )
         {
-        	$query = "DELETE FROM ".$this->getPrefix()."users_permissions
+            $query = "DELETE FROM ".$this->getPrefix()."users_permissions
                       WHERE user_id = $userId";
 
             $result = $this->Execute( $query );
@@ -320,7 +335,7 @@
          */
         function getBlogUsersPermissions( $blogId )
         {
-			$query = "SELECT * FROM ".$this->getPrefix()."users_permissions WHERE blog_id = ".$blogId.";";
+            $query = "SELECT * FROM ".$this->getPrefix()."users_permissions WHERE blog_id = ".$blogId.";";
             $result = $this->Execute( $query );
 
             if (!$result)
@@ -328,33 +343,35 @@
 
             $perms = array();
             while( $row = $result->FetchRow()) {
-            	array_push( $perms, $this->_fillUserPermissionInformation( $row ));
+                array_push( $perms, $this->_fillUserPermissionInformation( $row ));
             }
 
             return $perms;
         }
-		
-		/**
-		 * returns the usernames of the users who have permissions in a blog
-		 *
-		 * @param blogId
-		 * @retur An array of UserInfo objects
-		 */ 
-		function getBlogUsers( $blogId )
-		{
-			$query = "SELECT * FROM ".$this->getPrefix()."users_permissions WHERE blog_id = '".Db::qstr($blogId)."'";
+        
+        /**
+         * returns the usernames of the users who have permissions in a blog
+         *
+         * @param blogId
+         * @retur An array of UserInfo objects
+         */ 
+        function getBlogUsers( $blogId )
+        {
+            include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );    
+
+            $query = "SELECT * FROM ".$this->getPrefix()."users_permissions WHERE blog_id = '".Db::qstr($blogId)."'";
             $result = $this->Execute( $query );
 
             if (!$result)
                 return false;
 
             $blogUsers = array();
-			$users = new Users();
+            $users = new Users();
             while( $row = $result->FetchRow()) {
-            	$blogUsers[] = $users->getUserInfoFromId( $row["user_id"] );
+                $blogUsers[] = $users->getUserInfoFromId( $row["user_id"] );
             }
 
-            return $blogUsers;		
-		}
+            return $blogUsers;        
+        }
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/dao/users.class.php
===================================================================
--- plog/trunk/class/dao/users.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/dao/users.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -62,18 +62,12 @@
          */
         function getUserInfo( $user, $pass )
         {
-            $prefix = $this->getPrefix();
-            $query = "SELECT u.id AS id, u.user AS user, u.password AS password, u.email AS email,
-                      u.about AS about, u.full_name AS full_name, u.properties AS properties,
-                      u.resource_picture_id AS resource_picture_id,
-                      IF(p.permission_id = 1, 1, 0 ) AS site_admin,
-                      u.status AS status
-                      FROM {$prefix}users u LEFT JOIN {$prefix}users_permissions p ON u.id = p.user_id
-                      WHERE u.user = '".Db::qstr($user)."' AND u.password = '".md5($pass)."'";
-
-            $userInfo = $this->_getUserInfoFromQuery( $query );
-
-            return $userInfo;
+            $userInfo = $this->getUserInfoFromUsername( $user );
+            if ( $userInfo->getPassword() == md5($pass) ) {
+                return $userInfo;
+            } else {
+                return false;
+            }
         }
 
         /**
@@ -84,18 +78,28 @@
          */
         function getUserInfoFromUsername( $username )
         {
-            $prefix = $this->getPrefix();
-            $query = "SELECT u.id AS id, u.user AS user, u.password AS password, u.email AS email,
-                             u.about AS about, u.full_name AS full_name, u.properties AS properties,
-                             u.resource_picture_id AS resource_picture_id,
-                             IF(p.permission_id = 1, 1, 0 ) AS site_admin,
-                             u.status AS status
-                      FROM {$prefix}users u LEFT JOIN {$prefix}users_permissions p ON u.id = p.user_id
-                      WHERE u.user = '".Db::qstr($username)."'";
+            $userId = $this->_cache->getData( $username, CACHE_USERIDBYNAME );
 
-            $userInfo = $this->_getUserInfoFromQuery( $query );
+            if ( !$userId ) {
+                $prefix = $this->getPrefix();
+                $query = "SELECT u.id AS id, u.user AS user, u.password AS password, u.email AS email,
+                                 u.about AS about, u.full_name AS full_name, u.properties AS properties,
+                                 u.resource_picture_id AS resource_picture_id,
+                                 IF(p.permission_id = 1, 1, 0 ) AS site_admin,
+                                 u.status AS status
+                          FROM {$prefix}users u LEFT JOIN {$prefix}users_permissions p ON u.id = p.user_id
+                          WHERE u.user = '".Db::qstr($username)."'";
+                 $userInfo = $this->_getUserInfoFromQuery( $query );
 
-            return $userInfo;
+                 if ( $userInfo ) {
+                     $this->_cache->setData( $userInfo->getUsername(), CACHE_USERIDBYNAME, $userInfo->getId() );
+                     $this->_cache->setData( $userInfo->getId(), CACHE_USERINFO, $userInfo );
+                 }
+
+                 return $userInfo;
+            }
+
+            return $this->getUserInfoFromId( $userId );
         }
 
         /**
@@ -110,16 +114,20 @@
                 $userInfo = $this->usercache[$userid];
             }
             else {
-                $prefix = $this->getPrefix();
-                $query = "SELECT u.id AS id, u.user AS user, u.password AS password, u.email AS email,
-                                 u.about AS about, u.full_name AS full_name, u.properties AS properties,
-                                 u.resource_picture_id AS resource_picture_id,
-                                 IF(p.permission_id = 1, 1, 0 ) AS site_admin,
-                                 u.status AS status
-                          FROM {$prefix}users u LEFT JOIN {$prefix}users_permissions p ON u.id = p.user_id
-                          WHERE u.id = $userid";
+                $userInfo = $this->_cache->getData( $userid, CACHE_USERINFO );
+                if ( !$userInfo ) {
+                    $prefix = $this->getPrefix();
+                    $query = "SELECT u.id AS id, u.user AS user, u.password AS password, u.email AS email,
+                                     u.about AS about, u.full_name AS full_name, u.properties AS properties,
+                                     u.resource_picture_id AS resource_picture_id,
+                                     IF(p.permission_id = 1, 1, 0 ) AS site_admin,
+                                     u.status AS status
+                              FROM {$prefix}users u LEFT JOIN {$prefix}users_permissions p ON u.id = p.user_id
+                              WHERE u.id = $userid";
 
-                $userInfo = $this->_getUserInfoFromQuery( $query, $extendedInfo );
+                    $userInfo = $this->_getUserInfoFromQuery( $query, $extendedInfo );
+                    $this->_cache->setData( $userid, CACHE_USERINFO, $userInfo );
+                }
 
                 $this->usercache[$userid] = $userInfo;
             }
@@ -296,6 +304,9 @@
             $perms = new UserPermissions();
             $perms->updateSiteAdmin( $userInfo->getId(), $userInfo->isSiteAdmin());
 
+            $this->_cache->removeData( $userInfo->getId(), CACHE_USERINFO );
+            $this->_cache->removeData( $userInfo->getUsername(), CACHE_USERIDBYNAME );
+
             return $result;
         }
 
@@ -416,6 +427,8 @@
             if( $this->_db->Affected_Rows() == 0 )
                 return false;
 
+            $this->_cache->removeData( $userId, CACHE_USERINFO );
+
             return true;
         }  
         
@@ -562,7 +575,7 @@
 
         	// check if the user is the owner of any blog
             $owner = "SELECT id FROM ".$this->getPrefix()."blogs WHERE owner_id = ".$userid.";";
-            $result = $this->_db->Execute( $owner );
+            $result = $this->Execute( $owner );
 
             if(!$result)
                 return $blogId;
@@ -583,7 +596,7 @@
                       FROM ".$this->getPrefix()."users 
                       WHERE email = '".Db::qstr($email)."'";
 
-            $result = $this->_db->Execute($query);
+            $result = $this->Execute($query);
 
             if($result && $result->RecordCount() >= 1)
                 return true;

Modified: plog/trunk/class/data/Date/Calc.class.php
===================================================================
--- plog/trunk/class/data/Date/Calc.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/data/Date/Calc.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -51,7 +51,7 @@
 
     } // end func dateNow
 
-     /**
+    /**
      * Returns true for valid date, false for invalid date.
      *
      * @param string year in format CCYY
@@ -68,113 +68,113 @@
         if ($year < 0 || $year > 9999) {
             return false;
         }
-        if (!checkdate($month,$day,$year)) {
+      if (!checkdate($month,$day,$year)) {
             return false;
         }
 
         return true;
-    } // end func isValidDate
+    }
 
-     /**
-     * Returns true for a leap year, else false
-     *
-     * @param string year in format CCYY
-     *
-     * @access public
-     *
-     * @return boolean true/false
-     */
-
-    function isLeapYear($year='')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-
-        if (preg_match('/\D/',$year)) {
-            return false;
-        }
-
-        if ($year < 1000) {
-            return false;
-        }
-
-        if ($year < 1582) {
-            // pre Gregorio XIII - 1582
-            return ($year % 4 == 0);
-        } else {
-            // post Gregorio XIII - 1582
-            return ( (($year % 4 == 0) and ($year % 100 != 0)) or ($year % 400 == 0) );
-        }
-    } // end func isLeapYear
-
+//     /**
+//     * Returns true for a leap year, else false
+//     *
+//     * @param string year in format CCYY
+//     *
+//     * @access public
+//     *
+//     * @return boolean true/false
+//     */
+//
+//    function isLeapYear($year='')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//
+//        if (preg_match('/\D/',$year)) {
+//            return false;
+//        }
+//
+//        if ($year < 1000) {
+//            return false;
+//        }
+//
+//        if ($year < 1582) {
+//            // pre Gregorio XIII - 1582
+//            return ($year % 4 == 0);
+//        } else {
+//            // post Gregorio XIII - 1582
+//            return ( (($year % 4 == 0) and ($year % 100 != 0)) or ($year % 400 == 0) );
+//        }
+//    } // end func isLeapYear
+//
+//    /**
+//     * Determines if given date is a future date from now.
+//     *
+//     * @param string day in format DD
+//     * @param string month in format MM
+//     * @param string year in format CCYY
+//     *
+//     * @access public
+//     *
+//     * @return boolean true/false
+//     */
+//
+//    function isFutureDate($day,$month,$year)
+//    {
+//        $this_year = Date_Calc::dateNow('%Y');
+//        $this_month = Date_Calc::dateNow('%m');
+//        $this_day = Date_Calc::dateNow('%d');
+//
+//        if ($year > $this_year) {
+//            return true;
+//        } elseif ($year == $this_year) {
+//            if ($month > $this_month) {
+//                return true;
+//            } elseif ($month == $this_month) {
+//                if ($day > $this_day) {
+//                    return true;
+//                }
+//            }
+//        }
+//
+//        return false;
+//    } // end func isFutureDate
+//
+//    /**
+//     * Determines if given date is a past date from now.
+//     *
+//     * @param string day in format DD
+//     * @param string month in format MM
+//     * @param string year in format CCYY
+//     *
+//     * @access public
+//     *
+//     * @return boolean true/false
+//     */
+//
+//    function isPastDate($day,$month,$year)
+//    {
+//        $this_year = Date_Calc::dateNow('%Y');
+//        $this_month = Date_Calc::dateNow('%m');
+//        $this_day = Date_Calc::dateNow('%d');
+//
+//        if ($year < $this_year) {
+//            return true;
+//        } elseif ($year == $this_year) {
+//            if ($month < $this_month) {
+//                return true;
+//            } elseif ($month == $this_month) {
+//                if ($day < $this_day) {
+//                    return true;
+//                }
+//            }
+//        }
+//
+//        return false;
+//    } // end func isPastDate
+//
     /**
-     * Determines if given date is a future date from now.
-     *
-     * @param string day in format DD
-     * @param string month in format MM
-     * @param string year in format CCYY
-     *
-     * @access public
-     *
-     * @return boolean true/false
-     */
-
-    function isFutureDate($day,$month,$year)
-    {
-        $this_year = Date_Calc::dateNow('%Y');
-        $this_month = Date_Calc::dateNow('%m');
-        $this_day = Date_Calc::dateNow('%d');
-
-        if ($year > $this_year) {
-            return true;
-        } elseif ($year == $this_year) {
-            if ($month > $this_month) {
-                return true;
-            } elseif ($month == $this_month) {
-                if ($day > $this_day) {
-                    return true;
-                }
-            }
-        }
-
-        return false;
-    } // end func isFutureDate
-
-    /**
-     * Determines if given date is a past date from now.
-     *
-     * @param string day in format DD
-     * @param string month in format MM
-     * @param string year in format CCYY
-     *
-     * @access public
-     *
-     * @return boolean true/false
-     */
-
-    function isPastDate($day,$month,$year)
-    {
-        $this_year = Date_Calc::dateNow('%Y');
-        $this_month = Date_Calc::dateNow('%m');
-        $this_day = Date_Calc::dateNow('%d');
-
-        if ($year < $this_year) {
-            return true;
-        } elseif ($year == $this_year) {
-            if ($month < $this_month) {
-                return true;
-            } elseif ($month == $this_month) {
-                if ($day < $this_day) {
-                    return true;
-                }
-            }
-        }
-
-        return false;
-    } // end func isPastDate
-
-    /**
      * Returns day of week for given date, 0=Sunday
      *
      * @param string day in format DD, default is current local day
@@ -214,458 +214,458 @@
         $weekday_number = (($day - 7 * floor($day / 7)));
 
         return $weekday_number;
-    } // end func dayOfWeek
+    }
 
+//    /**
+//     * Returns week of the year, first Sunday is first day of first week
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     *
+//     * @access public
+//     *
+//     * @return integer $week_number
+//     */
+//
+//    function weekOfYear($day='',$month='',$year='')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//        $iso    = Date_Calc::gregorianToISO($day, $month, $year);
+//        $parts  = explode('-',$iso);
+//        $week_number = intval($parts[1]);
+//        return $week_number;
+//    } // end func weekOfYear
+//
+//    /**
+//     * Returns number of days since 31 December of year before given date.
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     *
+//     * @access public
+//     *
+//     * @return int $julian
+//     */
+//
+//    function julianDate($day='',$month='',$year='')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        $days = array(0,31,59,90,120,151,181,212,243,273,304,334);
+//
+//        $julian = ($days[$month - 1] + $day);
+//
+//        if ($month > 2 && Date_Calc::isLeapYear($year)) {
+//            $julian++;
+//        }
+//
+//        return($julian);
+//    } // end func julianDate
+//
+//    /**
+//     * Returns quarter of the year for given date
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     *
+//     * @access public
+//     *
+//     * @return int $year_quarter
+//     */
+//
+//    function quarterOfYear($day='',$month='',$year='')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        $year_quarter = (intval(($month - 1) / 3 + 1));
+//
+//        return $year_quarter;
+//    } // end func quarterOfYear
+//
+//    /**
+//     * Returns date of begin of next month of given date.
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function beginOfNextMonth($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        if ($month < 12) {
+//            $month++;
+//            $day=1;
+//        } else {
+//            $year++;
+//            $month=1;
+//            $day=1;
+//        }
+//
+//        return Date_Calc::dateFormat($day,$month,$year,$format);
+//    } // end func beginOfNextMonth
+//
+//    /**
+//     * Returns date of the last day of next month of given date.
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function endOfNextMonth($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        if ($month < 12) {
+//            $month++;
+//        } else {
+//            $year++;
+//            $month=1;
+//        }
+//
+//        $day = Date_Calc::daysInMonth($month,$year);
+//
+//        return Date_Calc::dateFormat($day,$month,$year,$format);
+//    } // end func endOfNextMonth
+//
+//    /**
+//     * Returns date of the first day of previous month of given date.
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function beginOfPrevMonth($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        if ($month > 1) {
+//            $month--;
+//            $day=1;
+//        } else {
+//            $year--;
+//            $month=12;
+//            $day=1;
+//        }
+//
+//        return Date_Calc::dateFormat($day,$month,$year,$format);
+//    } // end func beginOfPrevMonth
+//
+//    /**
+//     * Returns date of the last day of previous month for given date.
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function endOfPrevMonth($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        if ($month > 1) {
+//            $month--;
+//        } else {
+//            $year--;
+//            $month=12;
+//        }
+//
+//        $day = Date_Calc::daysInMonth($month,$year);
+//
+//        return Date_Calc::dateFormat($day,$month,$year,$format);
+//    } // end func endOfPrevMonth
+//
+//    /**
+//     * Returns date of the next weekday of given date,
+//     * skipping from Friday to Monday.
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function nextWeekday($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        $days = Date_Calc::dateToDays($day,$month,$year);
+//
+//        if (Date_Calc::dayOfWeek($day,$month,$year) == 5) {
+//            $days += 3;
+//        } elseif (Date_Calc::dayOfWeek($day,$month,$year) == 6) {
+//            $days += 2;
+//        } else {
+//            $days += 1;
+//        }
+//
+//        return(Date_Calc::daysToDate($days,$format));
+//    } // end func nextWeekday
+//
+//    /**
+//     * Returns date of the previous weekday,
+//     * skipping from Monday to Friday.
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function prevWeekday($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        $days = Date_Calc::dateToDays($day,$month,$year);
+//
+//        if (Date_Calc::dayOfWeek($day,$month,$year) == 1) {
+//            $days -= 3;
+//        } elseif (Date_Calc::dayOfWeek($day,$month,$year) == 0) {
+//            $days -= 2;
+//        } else {
+//            $days -= 1;
+//        }
+//
+//        return(Date_Calc::daysToDate($days,$format));
+//    } // end func prevWeekday
+//
+//    /**
+//     * Returns date of the next specific day of the week
+//     * from the given date.
+//     *
+//     * @param int day of week, 0=Sunday
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param boolean onOrAfter if true and days are same, returns current day
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function nextDayOfWeek($dow,$day='',$month='',$year='',$format='%Y%m%d',$onOrAfter=false)
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        $days = Date_Calc::dateToDays($day,$month,$year);
+//        $curr_weekday = Date_Calc::dayOfWeek($day,$month,$year);
+//
+//        if ($curr_weekday == $dow) {
+//            if (!$onOrAfter) {
+//                $days += 7;
+//            }
+//        }
+//        elseif ($curr_weekday > $dow) {
+//            $days += 7 - ( $curr_weekday - $dow );
+//        } else {
+//            $days += $dow - $curr_weekday;
+//        }
+//
+//        return(Date_Calc::daysToDate($days,$format));
+//    } // end func nextDayOfWeek
+//
+//    /**
+//     * Returns date of the previous specific day of the week
+//     * from the given date.
+//     *
+//     * @param int day of week, 0=Sunday
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param boolean onOrBefore if true and days are same, returns current day
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function prevDayOfWeek($dow,$day='',$month='',$year='',$format='%Y%m%d',$onOrBefore=false)
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        $days = Date_Calc::dateToDays($day,$month,$year);
+//        $curr_weekday = Date_Calc::dayOfWeek($day,$month,$year);
+//
+//        if ($curr_weekday == $dow) {
+//            if (!$onOrBefore) {
+//                $days -= 7;
+//            }
+//        }
+//        elseif ($curr_weekday < $dow) {
+//            $days -= 7 - ( $dow - $curr_weekday );
+//        } else {
+//            $days -= $curr_weekday - $dow;
+//        }
+//
+//        return(Date_Calc::daysToDate($days,$format));
+//    } // end func prevDayOfWeek
+//
+//    /**
+//     * Returns date of the next specific day of the week
+//     * on or after the given date.
+//     *
+//     * @param int day of week, 0=Sunday
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function nextDayOfWeekOnOrAfter($dow,$day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        return(Date_Calc::nextDayOfWeek($dow,$day,$month,$year,$format,true));
+//    } // end func nextDayOfWeekOnOrAfter
+//
+//    /**
+//     * Returns date of the previous specific day of the week
+//     * on or before the given date.
+//     *
+//     * @param int day of week, 0=Sunday
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function prevDayOfWeekOnOrBefore($dow,$day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        return(Date_Calc::prevDayOfWeek($dow,$day,$month,$year,$format,true));
+//    } // end func prevDayOfWeekOnOrAfter
+//
     /**
-     * Returns week of the year, first Sunday is first day of first week
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     *
-     * @access public
-     *
-     * @return integer $week_number
-     */
-
-    function weekOfYear($day='',$month='',$year='')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-        $iso    = Date_Calc::gregorianToISO($day, $month, $year);
-        $parts  = explode('-',$iso);
-        $week_number = intval($parts[1]);
-        return $week_number;
-    } // end func weekOfYear
-
-    /**
-     * Returns number of days since 31 December of year before given date.
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     *
-     * @access public
-     *
-     * @return int $julian
-     */
-
-    function julianDate($day='',$month='',$year='')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        $days = array(0,31,59,90,120,151,181,212,243,273,304,334);
-
-        $julian = ($days[$month - 1] + $day);
-
-        if ($month > 2 && Date_Calc::isLeapYear($year)) {
-            $julian++;
-        }
-
-        return($julian);
-    } // end func julianDate
-
-    /**
-     * Returns quarter of the year for given date
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     *
-     * @access public
-     *
-     * @return int $year_quarter
-     */
-
-    function quarterOfYear($day='',$month='',$year='')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        $year_quarter = (intval(($month - 1) / 3 + 1));
-
-        return $year_quarter;
-    } // end func quarterOfYear
-
-    /**
-     * Returns date of begin of next month of given date.
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function beginOfNextMonth($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        if ($month < 12) {
-            $month++;
-            $day=1;
-        } else {
-            $year++;
-            $month=1;
-            $day=1;
-        }
-
-        return Date_Calc::dateFormat($day,$month,$year,$format);
-    } // end func beginOfNextMonth
-
-    /**
-     * Returns date of the last day of next month of given date.
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function endOfNextMonth($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        if ($month < 12) {
-            $month++;
-        } else {
-            $year++;
-            $month=1;
-        }
-
-        $day = Date_Calc::daysInMonth($month,$year);
-
-        return Date_Calc::dateFormat($day,$month,$year,$format);
-    } // end func endOfNextMonth
-
-    /**
-     * Returns date of the first day of previous month of given date.
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function beginOfPrevMonth($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        if ($month > 1) {
-            $month--;
-            $day=1;
-        } else {
-            $year--;
-            $month=12;
-            $day=1;
-        }
-
-        return Date_Calc::dateFormat($day,$month,$year,$format);
-    } // end func beginOfPrevMonth
-
-    /**
-     * Returns date of the last day of previous month for given date.
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function endOfPrevMonth($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        if ($month > 1) {
-            $month--;
-        } else {
-            $year--;
-            $month=12;
-        }
-
-        $day = Date_Calc::daysInMonth($month,$year);
-
-        return Date_Calc::dateFormat($day,$month,$year,$format);
-    } // end func endOfPrevMonth
-
-    /**
-     * Returns date of the next weekday of given date,
-     * skipping from Friday to Monday.
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function nextWeekday($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        $days = Date_Calc::dateToDays($day,$month,$year);
-
-        if (Date_Calc::dayOfWeek($day,$month,$year) == 5) {
-            $days += 3;
-        } elseif (Date_Calc::dayOfWeek($day,$month,$year) == 6) {
-            $days += 2;
-        } else {
-            $days += 1;
-        }
-
-        return(Date_Calc::daysToDate($days,$format));
-    } // end func nextWeekday
-
-    /**
-     * Returns date of the previous weekday,
-     * skipping from Monday to Friday.
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function prevWeekday($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        $days = Date_Calc::dateToDays($day,$month,$year);
-
-        if (Date_Calc::dayOfWeek($day,$month,$year) == 1) {
-            $days -= 3;
-        } elseif (Date_Calc::dayOfWeek($day,$month,$year) == 0) {
-            $days -= 2;
-        } else {
-            $days -= 1;
-        }
-
-        return(Date_Calc::daysToDate($days,$format));
-    } // end func prevWeekday
-
-    /**
-     * Returns date of the next specific day of the week
-     * from the given date.
-     *
-     * @param int day of week, 0=Sunday
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param boolean onOrAfter if true and days are same, returns current day
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function nextDayOfWeek($dow,$day='',$month='',$year='',$format='%Y%m%d',$onOrAfter=false)
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        $days = Date_Calc::dateToDays($day,$month,$year);
-        $curr_weekday = Date_Calc::dayOfWeek($day,$month,$year);
-
-        if ($curr_weekday == $dow) {
-            if (!$onOrAfter) {
-                $days += 7;
-            }
-        }
-        elseif ($curr_weekday > $dow) {
-            $days += 7 - ( $curr_weekday - $dow );
-        } else {
-            $days += $dow - $curr_weekday;
-        }
-
-        return(Date_Calc::daysToDate($days,$format));
-    } // end func nextDayOfWeek
-
-    /**
-     * Returns date of the previous specific day of the week
-     * from the given date.
-     *
-     * @param int day of week, 0=Sunday
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param boolean onOrBefore if true and days are same, returns current day
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function prevDayOfWeek($dow,$day='',$month='',$year='',$format='%Y%m%d',$onOrBefore=false)
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        $days = Date_Calc::dateToDays($day,$month,$year);
-        $curr_weekday = Date_Calc::dayOfWeek($day,$month,$year);
-
-        if ($curr_weekday == $dow) {
-            if (!$onOrBefore) {
-                $days -= 7;
-            }
-        }
-        elseif ($curr_weekday < $dow) {
-            $days -= 7 - ( $dow - $curr_weekday );
-        } else {
-            $days -= $curr_weekday - $dow;
-        }
-
-        return(Date_Calc::daysToDate($days,$format));
-    } // end func prevDayOfWeek
-
-    /**
-     * Returns date of the next specific day of the week
-     * on or after the given date.
-     *
-     * @param int day of week, 0=Sunday
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function nextDayOfWeekOnOrAfter($dow,$day='',$month='',$year='',$format='%Y%m%d')
-    {
-        return(Date_Calc::nextDayOfWeek($dow,$day,$month,$year,$format,true));
-    } // end func nextDayOfWeekOnOrAfter
-
-    /**
-     * Returns date of the previous specific day of the week
-     * on or before the given date.
-     *
-     * @param int day of week, 0=Sunday
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function prevDayOfWeekOnOrBefore($dow,$day='',$month='',$year='',$format='%Y%m%d')
-    {
-        return(Date_Calc::prevDayOfWeek($dow,$day,$month,$year,$format,true));
-    } // end func prevDayOfWeekOnOrAfter
-
-    /**
      * Returns date of day after given date.
      *
      * @param string day in format DD, default is current local day
@@ -693,503 +693,503 @@
         $days = Date_Calc::dateToDays($day,$month,$year);
 
         return(Date_Calc::daysToDate($days + 1,$format));
-    } // end func nextDay
+    }
 
+//    /**
+//     * Returns date of day before given date.
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function prevDay($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        $days = Date_Calc::dateToDays($day,$month,$year);
+//
+//        return(Date_Calc::daysToDate($days - 1,$format));
+//    } // end func prevDay
+//
+//    /**
+//     * Sets century for 2 digit year.
+//     * 51-99 is 19, else 20
+//     *
+//     * @param string 2 digit year
+//     *
+//     * @access public
+//     *
+//     * @return string 4 digit year
+//     */
+//
+//    function defaultCentury($year)
+//    {
+//        if (strlen($year) == 1) {
+//            $year = "0$year";
+//        }
+//        if ($year > 50) {
+//            return( "19$year" );
+//        } else {
+//            return( "20$year" );
+//        }
+//    } // end func defaultCentury
+//
+//    /**
+//     * Returns number of days between two given dates.
+//     *
+//    * @param string $day1   day in format DD
+//    * @param string $month1 month in format MM
+//    * @param string $year1  year in format CCYY
+//    * @param string $day2   day in format DD
+//    * @param string $month2 month in format MM
+//    * @param string $year2  year in format CCYY
+//     *
+//     * @access public
+//     *
+//     * @return int absolute number of days between dates,
+//     *      -1 if there is an error.
+//     */
+//
+//    function dateDiff($day1,$month1,$year1,$day2,$month2,$year2)
+//    {
+//        if (!Date_Calc::isValidDate($day1,$month1,$year1)) {
+//            return -1;
+//        }
+//        if (!Date_Calc::isValidDate($day2,$month2,$year2)) {
+//            return -1;
+//        }
+//
+//        return(abs((Date_Calc::dateToDays($day1,$month1,$year1))
+//                    - (Date_Calc::dateToDays($day2,$month2,$year2))));
+//    } // end func dateDiff
+//
+//    /**
+//    * Compares two dates
+//    *
+//    * @param string $day1   day in format DD
+//    * @param string $month1 month in format MM
+//    * @param string $year1  year in format CCYY
+//    * @param string $day2   day in format DD
+//    * @param string $month2 month in format MM
+//    * @param string $year2  year in format CCYY
+//    *
+//    * @access public
+//    * @return int 0 on equality, 1 if date 1 is greater, -1 if smaller
+//    */
+//    function compareDates($day1,$month1,$year1,$day2,$month2,$year2)
+//    {
+//        $ndays1 = Date_Calc::dateToDays($day1, $month1, $year1);
+//        $ndays2 = Date_Calc::dateToDays($day2, $month2, $year2);
+//        if ($ndays1 == $ndays2) {
+//            return 0;
+//        }
+//        return ($ndays1 > $ndays2) ? 1 : -1;
+//    } // end func compareDates
+//
+//    /**
+//     * Find the number of days in the given month.
+//     *
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     *
+//     * @access public
+//     *
+//     * @return int number of days
+//     */
+//
+//    function daysInMonth($month='',$year='')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//
+//        if ($year == 1582 && $month == 10) {
+//            return 21;  // October 1582 only had 1st-4th and 15th-31st
+//        }
+//
+//        if ($month == 2) {
+//            if (Date_Calc::isLeapYear($year)) {
+//                return 29;
+//             } else {
+//                return 28;
+//            }
+//        } elseif ($month == 4 or $month == 6 or $month == 9 or $month == 11) {
+//            return 30;
+//        } else {
+//            return 31;
+//        }
+//    } // end func daysInMonth
+//
+//    /**
+//     * Returns the number of rows on a calendar month. Useful for
+//     * determining the number of rows when displaying a typical
+//     * month calendar.
+//     *
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     *
+//     * @access public
+//     *
+//     * @return int number of weeks
+//     */
+//
+//    function weeksInMonth($month='',$year='')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        $FDOM = Date_Calc::firstOfMonthWeekday($month, $year);
+//        if (DATE_CALC_BEGIN_WEEKDAY==1 && $FDOM==0) {
+//            $first_week_days = 7 - $FDOM + DATE_CALC_BEGIN_WEEKDAY;
+//            $weeks = 1;
+//        } elseif (DATE_CALC_BEGIN_WEEKDAY==0 && $FDOM == 6) {
+//            $first_week_days = 7 - $FDOM + DATE_CALC_BEGIN_WEEKDAY;
+//            $weeks = 1;
+//        } else {
+//            $first_week_days = DATE_CALC_BEGIN_WEEKDAY - $FDOM;
+//            $weeks = 0;
+//        }
+//        $first_week_days %= 7;
+//        return (ceil((Date_Calc::daysInMonth($month, $year) - $first_week_days) / 7) + $weeks);
+//    } // end func weeksInMonth
+//
+//    /**
+//     * Find the day of the week for the first of the month of given date.
+//     *
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     *
+//     * @access public
+//     *
+//     * @return int number of weekday for the first day, 0=Sunday
+//     */
+//
+//    function firstOfMonthWeekday($month='',$year='')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//
+//        return(Date_Calc::dayOfWeek('01',$month,$year));
+//    } // end func firstOfMonthWeekday
+//
+//    /**
+//     * Return date of first day of month of given date.
+//     *
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function beginOfMonth($month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//
+//        return(Date_Calc::dateFormat('01',$month,$year,$format));
+//    } // end of func beginOfMonth
+//
+//    /**
+//     * Find the month day of the beginning of week for given date,
+//     * using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function beginOfWeek($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        $this_weekday = Date_Calc::dayOfWeek($day,$month,$year);
+//
+//        $interval = (7 - DATE_CALC_BEGIN_WEEKDAY + $this_weekday) % 7;
+//
+//        return(Date_Calc::daysToDate(Date_Calc::dateToDays($day,$month,$year) - $interval,$format));
+//    } // end of func beginOfWeek
+//
+//    /**
+//     * Find the month day of the end of week for given date,
+//     * using DATE_CALC_BEGIN_WEEKDAY. (can return weekday
+//     * of following month.)
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function endOfWeek($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//
+//        $this_weekday = Date_Calc::dayOfWeek($day,$month,$year);
+//
+//        $interval = (6 + DATE_CALC_BEGIN_WEEKDAY - $this_weekday) % 7;
+//
+//        return(Date_Calc::daysToDate(Date_Calc::dateToDays($day,$month,$year) + $interval,$format));
+//    } // end func endOfWeek
+//
+//    /**
+//     * Find the month day of the beginning of week after given date,
+//     * using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function beginOfNextWeek($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow("%Y");
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow("%m");
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow("%d");
+//        }
+//
+//        $date = Date_Calc::daysToDate(
+//                    Date_Calc::dateToDays($day+7,$month,$year),"%Y%m%d"
+//                );
+//
+//        $next_week_year = substr($date,0,4);
+//        $next_week_month = substr($date,4,2);
+//        $next_week_day = substr($date,6,2);
+//
+//        return Date_Calc::beginOfWeek(
+//                            $next_week_day,$next_week_month,$next_week_year,
+//                            $format
+//                        );
+//
+//        $date = Date_Calc::daysToDate(Date_Calc::dateToDays($day+7,$month,$year),"%Y%m%d");
+//    } // end func beginOfNextWeek
+//
+//    /**
+//     * Find the month day of the beginning of week before given date,
+//     * using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function beginOfPrevWeek($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow("%Y");
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow("%m");
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow("%d");
+//        }
+//
+//        $date = Date_Calc::daysToDate(
+//                        Date_Calc::dateToDays($day-7,$month,$year),"%Y%m%d"
+//                    );
+//
+//        $prev_week_year = substr($date,0,4);
+//        $prev_week_month = substr($date,4,2);
+//        $prev_week_day = substr($date,6,2);
+//
+//        return Date_Calc::beginOfWeek($prev_week_day,$prev_week_month,$prev_week_year,$format);
+//
+//
+//        $date = Date_Calc::daysToDate(Date_Calc::dateToDays($day-7,$month,$year),"%Y%m%d");
+//    } // end func beginOfPrevWeek
+//
+//    /**
+//     * Return an array with days in week
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return array $week[$weekday]
+//     */
+//
+//    function getCalendarWeek($day='',$month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        $week_array = array();
+//
+//        // date for the column of week
+//
+//        $curr_day = Date_Calc::beginOfWeek($day,$month,$year,'%E');
+//
+//        for($counter=0; $counter <= 6; $counter++) {
+//            $week_array[$counter] = Date_Calc::daysToDate($curr_day,$format);
+//            $curr_day++;
+//        }
+//
+//        return $week_array;
+//    } // end func getCalendarWeek
+//
+//    /**
+//     * Return a set of arrays to construct a calendar month for
+//     * the given date.
+//     *
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return array $month[$row][$col]
+//     */
+//
+//    function getCalendarMonth($month='',$year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//
+//        $month_array = array();
+//
+//        // date for the first row, first column of calendar month
+//        if (DATE_CALC_BEGIN_WEEKDAY == 1) {
+//            if (Date_Calc::firstOfMonthWeekday($month,$year) == 0) {
+//                $curr_day = Date_Calc::dateToDays('01',$month,$year) - 6;
+//            } else {
+//                $curr_day = Date_Calc::dateToDays('01',$month,$year)
+//                    - Date_Calc::firstOfMonthWeekday($month,$year) + 1;
+//            }
+//        } else {
+//            $curr_day = (Date_Calc::dateToDays('01',$month,$year)
+//                - Date_Calc::firstOfMonthWeekday($month,$year));
+//        }
+//
+//        // number of days in this month
+//        $daysInMonth = Date_Calc::daysInMonth($month,$year);
+//
+//        $weeksInMonth = Date_Calc::weeksInMonth($month,$year);
+//        for($row_counter=0; $row_counter < $weeksInMonth; $row_counter++) {
+//            for($column_counter=0; $column_counter <= 6; $column_counter++) {
+//                $month_array[$row_counter][$column_counter] =
+//                    Date_Calc::daysToDate($curr_day,$format);
+//                $curr_day++;
+//            }
+//        }
+//
+//        return $month_array;
+//    } // end func getCalendarMonth
+//
+//    /**
+//     * Return a set of arrays to construct a calendar year for
+//     * the given date.
+//     *
+//     * @param string year in format CCYY, default current local year
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return array $year[$month][$row][$col]
+//     */
+//
+//    function getCalendarYear($year='',$format='%Y%m%d')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//
+//        $year_array = array();
+//
+//        for($curr_month=0; $curr_month <=11; $curr_month++) {
+//            $year_array[$curr_month] =
+//                Date_Calc::getCalendarMonth(sprintf('%02d',$curr_month+1),$year,$format);
+//        }
+//
+//        return $year_array;
+//    } // end func getCalendarYear
+//
     /**
-     * Returns date of day before given date.
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function prevDay($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        $days = Date_Calc::dateToDays($day,$month,$year);
-
-        return(Date_Calc::daysToDate($days - 1,$format));
-    } // end func prevDay
-
-    /**
-     * Sets century for 2 digit year.
-     * 51-99 is 19, else 20
-     *
-     * @param string 2 digit year
-     *
-     * @access public
-     *
-     * @return string 4 digit year
-     */
-
-    function defaultCentury($year)
-    {
-        if (strlen($year) == 1) {
-            $year = "0$year";
-        }
-        if ($year > 50) {
-            return( "19$year" );
-        } else {
-            return( "20$year" );
-        }
-    } // end func defaultCentury
-
-    /**
-     * Returns number of days between two given dates.
-     *
-    * @param string $day1   day in format DD
-    * @param string $month1 month in format MM
-    * @param string $year1  year in format CCYY
-    * @param string $day2   day in format DD
-    * @param string $month2 month in format MM
-    * @param string $year2  year in format CCYY
-     *
-     * @access public
-     *
-     * @return int absolute number of days between dates,
-     *      -1 if there is an error.
-     */
-
-    function dateDiff($day1,$month1,$year1,$day2,$month2,$year2)
-    {
-        if (!Date_Calc::isValidDate($day1,$month1,$year1)) {
-            return -1;
-        }
-        if (!Date_Calc::isValidDate($day2,$month2,$year2)) {
-            return -1;
-        }
-
-        return(abs((Date_Calc::dateToDays($day1,$month1,$year1))
-                    - (Date_Calc::dateToDays($day2,$month2,$year2))));
-    } // end func dateDiff
-
-    /**
-    * Compares two dates
-    *
-    * @param string $day1   day in format DD
-    * @param string $month1 month in format MM
-    * @param string $year1  year in format CCYY
-    * @param string $day2   day in format DD
-    * @param string $month2 month in format MM
-    * @param string $year2  year in format CCYY
-    *
-    * @access public
-    * @return int 0 on equality, 1 if date 1 is greater, -1 if smaller
-    */
-    function compareDates($day1,$month1,$year1,$day2,$month2,$year2)
-    {
-        $ndays1 = Date_Calc::dateToDays($day1, $month1, $year1);
-        $ndays2 = Date_Calc::dateToDays($day2, $month2, $year2);
-        if ($ndays1 == $ndays2) {
-            return 0;
-        }
-        return ($ndays1 > $ndays2) ? 1 : -1;
-    } // end func compareDates
-
-    /**
-     * Find the number of days in the given month.
-     *
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     *
-     * @access public
-     *
-     * @return int number of days
-     */
-
-    function daysInMonth($month='',$year='')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-
-        if ($year == 1582 && $month == 10) {
-            return 21;  // October 1582 only had 1st-4th and 15th-31st
-        }
-
-        if ($month == 2) {
-            if (Date_Calc::isLeapYear($year)) {
-                return 29;
-             } else {
-                return 28;
-            }
-        } elseif ($month == 4 or $month == 6 or $month == 9 or $month == 11) {
-            return 30;
-        } else {
-            return 31;
-        }
-    } // end func daysInMonth
-
-    /**
-     * Returns the number of rows on a calendar month. Useful for
-     * determining the number of rows when displaying a typical
-     * month calendar.
-     *
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     *
-     * @access public
-     *
-     * @return int number of weeks
-     */
-
-    function weeksInMonth($month='',$year='')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        $FDOM = Date_Calc::firstOfMonthWeekday($month, $year);
-        if (DATE_CALC_BEGIN_WEEKDAY==1 && $FDOM==0) {
-            $first_week_days = 7 - $FDOM + DATE_CALC_BEGIN_WEEKDAY;
-            $weeks = 1;
-        } elseif (DATE_CALC_BEGIN_WEEKDAY==0 && $FDOM == 6) {
-            $first_week_days = 7 - $FDOM + DATE_CALC_BEGIN_WEEKDAY;
-            $weeks = 1;
-        } else {
-            $first_week_days = DATE_CALC_BEGIN_WEEKDAY - $FDOM;
-            $weeks = 0;
-        }
-        $first_week_days %= 7;
-        return (ceil((Date_Calc::daysInMonth($month, $year) - $first_week_days) / 7) + $weeks);
-    } // end func weeksInMonth
-
-    /**
-     * Find the day of the week for the first of the month of given date.
-     *
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     *
-     * @access public
-     *
-     * @return int number of weekday for the first day, 0=Sunday
-     */
-
-    function firstOfMonthWeekday($month='',$year='')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-
-        return(Date_Calc::dayOfWeek('01',$month,$year));
-    } // end func firstOfMonthWeekday
-
-    /**
-     * Return date of first day of month of given date.
-     *
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function beginOfMonth($month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-
-        return(Date_Calc::dateFormat('01',$month,$year,$format));
-    } // end of func beginOfMonth
-
-    /**
-     * Find the month day of the beginning of week for given date,
-     * using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function beginOfWeek($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        $this_weekday = Date_Calc::dayOfWeek($day,$month,$year);
-
-        $interval = (7 - DATE_CALC_BEGIN_WEEKDAY + $this_weekday) % 7;
-
-        return(Date_Calc::daysToDate(Date_Calc::dateToDays($day,$month,$year) - $interval,$format));
-    } // end of func beginOfWeek
-
-    /**
-     * Find the month day of the end of week for given date,
-     * using DATE_CALC_BEGIN_WEEKDAY. (can return weekday
-     * of following month.)
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function endOfWeek($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-
-        $this_weekday = Date_Calc::dayOfWeek($day,$month,$year);
-
-        $interval = (6 + DATE_CALC_BEGIN_WEEKDAY - $this_weekday) % 7;
-
-        return(Date_Calc::daysToDate(Date_Calc::dateToDays($day,$month,$year) + $interval,$format));
-    } // end func endOfWeek
-
-    /**
-     * Find the month day of the beginning of week after given date,
-     * using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function beginOfNextWeek($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow("%Y");
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow("%m");
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow("%d");
-        }
-
-        $date = Date_Calc::daysToDate(
-                    Date_Calc::dateToDays($day+7,$month,$year),"%Y%m%d"
-                );
-
-        $next_week_year = substr($date,0,4);
-        $next_week_month = substr($date,4,2);
-        $next_week_day = substr($date,6,2);
-
-        return Date_Calc::beginOfWeek(
-                            $next_week_day,$next_week_month,$next_week_year,
-                            $format
-                        );
-
-        $date = Date_Calc::daysToDate(Date_Calc::dateToDays($day+7,$month,$year),"%Y%m%d");
-    } // end func beginOfNextWeek
-
-    /**
-     * Find the month day of the beginning of week before given date,
-     * using DATE_CALC_BEGIN_WEEKDAY. (can return weekday of prev month.)
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function beginOfPrevWeek($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow("%Y");
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow("%m");
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow("%d");
-        }
-
-        $date = Date_Calc::daysToDate(
-                        Date_Calc::dateToDays($day-7,$month,$year),"%Y%m%d"
-                    );
-
-        $prev_week_year = substr($date,0,4);
-        $prev_week_month = substr($date,4,2);
-        $prev_week_day = substr($date,6,2);
-
-        return Date_Calc::beginOfWeek($prev_week_day,$prev_week_month,$prev_week_year,$format);
-
-
-        $date = Date_Calc::daysToDate(Date_Calc::dateToDays($day-7,$month,$year),"%Y%m%d");
-    } // end func beginOfPrevWeek
-
-    /**
-     * Return an array with days in week
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return array $week[$weekday]
-     */
-
-    function getCalendarWeek($day='',$month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        $week_array = array();
-
-        // date for the column of week
-
-        $curr_day = Date_Calc::beginOfWeek($day,$month,$year,'%E');
-
-        for($counter=0; $counter <= 6; $counter++) {
-            $week_array[$counter] = Date_Calc::daysToDate($curr_day,$format);
-            $curr_day++;
-        }
-
-        return $week_array;
-    } // end func getCalendarWeek
-
-    /**
-     * Return a set of arrays to construct a calendar month for
-     * the given date.
-     *
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return array $month[$row][$col]
-     */
-
-    function getCalendarMonth($month='',$year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-
-        $month_array = array();
-
-        // date for the first row, first column of calendar month
-        if (DATE_CALC_BEGIN_WEEKDAY == 1) {
-            if (Date_Calc::firstOfMonthWeekday($month,$year) == 0) {
-                $curr_day = Date_Calc::dateToDays('01',$month,$year) - 6;
-            } else {
-                $curr_day = Date_Calc::dateToDays('01',$month,$year)
-                    - Date_Calc::firstOfMonthWeekday($month,$year) + 1;
-            }
-        } else {
-            $curr_day = (Date_Calc::dateToDays('01',$month,$year)
-                - Date_Calc::firstOfMonthWeekday($month,$year));
-        }
-
-        // number of days in this month
-        $daysInMonth = Date_Calc::daysInMonth($month,$year);
-
-        $weeksInMonth = Date_Calc::weeksInMonth($month,$year);
-        for($row_counter=0; $row_counter < $weeksInMonth; $row_counter++) {
-            for($column_counter=0; $column_counter <= 6; $column_counter++) {
-                $month_array[$row_counter][$column_counter] =
-                    Date_Calc::daysToDate($curr_day,$format);
-                $curr_day++;
-            }
-        }
-
-        return $month_array;
-    } // end func getCalendarMonth
-
-    /**
-     * Return a set of arrays to construct a calendar year for
-     * the given date.
-     *
-     * @param string year in format CCYY, default current local year
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return array $year[$month][$row][$col]
-     */
-
-    function getCalendarYear($year='',$format='%Y%m%d')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-
-        $year_array = array();
-
-        for($curr_month=0; $curr_month <=11; $curr_month++) {
-            $year_array[$curr_month] =
-                Date_Calc::getCalendarMonth(sprintf('%02d',$curr_month+1),$year,$format);
-        }
-
-        return $year_array;
-    } // end func getCalendarYear
-
-    /**
      * Converts a date to number of days since a
      * distant unspecified epoch.
      *
@@ -1224,7 +1224,7 @@
             floor(( 1461 * $year) / 4 ) +
             floor(( 153 * $month + 2) / 5 ) +
             $day + 1721119);
-    } // end func dateToDays
+    } 
 
     /**
      * Converts number of days to a distant unspecified epoch.
@@ -1266,42 +1266,42 @@
         $century = sprintf('%02d',$century);
         $year = sprintf('%02d',$year);
         return(Date_Calc::dateFormat($day,$month,$century.$year,$format));
-    } // end func daysToDate
+    }
 
+//    /**
+//     * Calculates the date of the Nth weekday of the month,
+//     * such as the second Saturday of January 2000.
+//     *
+//     * @param string occurance: 1=first, 2=second, 3=third, etc.
+//     * @param string dayOfWeek: 0=Sunday, 1=Monday, etc.
+//     * @param string month in format MM
+//     * @param string year in format CCYY
+//     * @param string format for returned date
+//     *
+//     * @access public
+//     *
+//     * @return string date in given format
+//     */
+//
+//    function NWeekdayOfMonth($occurance,$dayOfWeek,$month,$year,$format='%Y%m%d')
+//    {
+//        $year = sprintf('%04d',$year);
+//        $month = sprintf('%02d',$month);
+//
+//        $DOW1day = sprintf('%02d',(($occurance - 1) * 7 + 1));
+//        $DOW1 = Date_Calc::dayOfWeek($DOW1day,$month,$year);
+//
+//        $wdate = ($occurance - 1) * 7 + 1 +
+//                (7 + $dayOfWeek - $DOW1) % 7;
+//
+//        if ( $wdate > Date_Calc::daysInMonth($month,$year)) {
+//            return -1;
+//        } else {
+//            return(Date_Calc::dateFormat($wdate,$month,$year,$format));
+//        }
+//    } // end func NWeekdayOfMonth
+//
     /**
-     * Calculates the date of the Nth weekday of the month,
-     * such as the second Saturday of January 2000.
-     *
-     * @param string occurance: 1=first, 2=second, 3=third, etc.
-     * @param string dayOfWeek: 0=Sunday, 1=Monday, etc.
-     * @param string month in format MM
-     * @param string year in format CCYY
-     * @param string format for returned date
-     *
-     * @access public
-     *
-     * @return string date in given format
-     */
-
-    function NWeekdayOfMonth($occurance,$dayOfWeek,$month,$year,$format='%Y%m%d')
-    {
-        $year = sprintf('%04d',$year);
-        $month = sprintf('%02d',$month);
-
-        $DOW1day = sprintf('%02d',(($occurance - 1) * 7 + 1));
-        $DOW1 = Date_Calc::dayOfWeek($DOW1day,$month,$year);
-
-        $wdate = ($occurance - 1) * 7 + 1 +
-                (7 + $dayOfWeek - $DOW1) % 7;
-
-        if ( $wdate > Date_Calc::daysInMonth($month,$year)) {
-            return -1;
-        } else {
-            return(Date_Calc::dateFormat($wdate,$month,$year,$format));
-        }
-    } // end func NWeekdayOfMonth
-
-    /**
      *  Formats the date in the given format, much like
      *  strfmt(). This function is used to alleviate the
      *  problem with 32-bit numbers for dates pre 1970
@@ -1412,326 +1412,325 @@
             }
         }
         return $output;
-    } // end func dateFormat
-
-    /**
-     * Returns the current local year in format CCYY
-     *
-     * @access public
-     *
-     * @return string year in format CCYY
-     */
-
-    function getYear()
-    {
-        return Date_Calc::dateNow('%Y');
-    } // end func getYear
-
-    /**
-     * Returns the current local month in format MM
-     *
-     * @access public
-     *
-     * @return string month in format MM
-     */
-
-    function getMonth()
-    {
-        return Date_Calc::dateNow('%m');
-    } // end func getMonth
-
-    /**
-     * Returns the current local day in format DD
-     *
-     * @access public
-     *
-     * @return string day in format DD
-     */
-
-    function getDay()
-    {
-        return Date_Calc::dateNow('%d');
-    } // end func getDay
-
-    /**
-     * Returns the full month name for the given month
-     *
-     * @param string month in format MM
-     *
-     * @access public
-     *
-     * @return string full month name
-     */
-
-    function getMonthFullname($month)
-    {
-        $month = (int)$month;
-
-        if (empty($month)) {
-            $month = (int) Date_Calc::dateNow('%m');
-        }
-
-        $month_names = Date_Calc::getMonthNames();
-
-        return $month_names[$month];
-        // getMonthNames returns months with correct indexes
-        //return $month_names[($month - 1)];
-    } // end func getMonthFullname
-
-    /**
-     * Returns the abbreviated month name for the given month
-     *
-     * @param string month in format MM
-     * @param int optional length of abbreviation, default is 3
-     *
-     * @access public
-     *
-     * @return string abbreviated month name
-     * @see Date_Calc::getMonthFullname
-     */
-
-    function getMonthAbbrname($month,$length=3)
-    {
-        $month = (int)$month;
-
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-
-        return substr(Date_Calc::getMonthFullname($month), 0, $length);
-    } // end func getMonthAbbrname
-
-    /**
-     * Returns the full weekday name for the given date
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     *
-     * @access public
-     *
-     * @return string full month name
-     */
-
-    function getWeekdayFullname($day='',$month='',$year='')
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        $weekday_names = Date_Calc::getWeekDays();
-        $weekday = Date_Calc::dayOfWeek($day,$month,$year);
-
-        return $weekday_names[$weekday];
-    } // end func getWeekdayFullname
-
-    /**
-     * Returns the abbreviated weekday name for the given date
-     *
-     * @param string day in format DD, default is current local day
-     * @param string month in format MM, default is current local month
-     * @param string year in format CCYY, default is current local year
-     * @param int optional length of abbreviation, default is 3
-     *
-     * @access public
-     *
-     * @return string full month name
-     * @see Date_Calc::getWeekdayFullname
-     */
-
-    function getWeekdayAbbrname($day='',$month='',$year='',$length=3)
-    {
-        if (empty($year)) {
-            $year = Date_Calc::dateNow('%Y');
-        }
-        if (empty($month)) {
-            $month = Date_Calc::dateNow('%m');
-        }
-        if (empty($day)) {
-            $day = Date_Calc::dateNow('%d');
-        }
-
-        return substr(Date_Calc::getWeekdayFullname($day,$month,$year),0,$length);
-    } // end func getWeekdayFullname
-
-    /**
-    * Returns the numeric month from the month name or an abreviation
-    *
-    * Both August and Aug would return 8.
-    * Month name is case insensitive.
-    *
-    * @param    string  month name
-    * @return   integer month number
-    */
-    function getMonthFromFullName($month)
-    {
-        $month = strtolower($month);
-        $months = Date_Calc::getMonthNames();
-        while(list($id, $name) = each($months)) {
-            if (ereg($month, strtolower($name))) {
-                return($id);
-            }
-        }
-
-        return(0);
-    } // end func getMonthFromFullName
-
-    /**
-    * Returns an array of month names
-    *
-    * Used to take advantage of the setlocale function to return
-    * language specific month names.
-    * XXX cache values to some global array to avoid preformace
-    * hits when called more than once.
-    *
-    * @returns array An array of month names
-    */
-    function getMonthNames()
-    {
-        for($i=1;$i<13;$i++) {
-            $months[$i] = strftime('%B', mktime(0, 0, 0, $i, 1, 2001));
-        }
-        return($months);
-    } // end func getMonthNames
-
-    /**
-    * Returns an array of week days
-    *
-    * Used to take advantage of the setlocale function to
-    * return language specific week days
-    * XXX cache values to some global array to avoid preformace
-    * hits when called more than once.
-    *
-    * @returns array An array of week day names
-    */
-    function getWeekDays()
-    {
-        for($i=0;$i<7;$i++) {
-            $weekdays[$i] = strftime('%A', mktime(0, 0, 0, 1, $i, 2001));
-        }
-        return($weekdays);
-    } // end func getWeekDays
-
-    /**
-     * Converts from Gregorian Year-Month-Day to
-     * ISO YearNumber-WeekNumber-WeekDay
-     *
-     * Uses ISO 8601 definitions.
-     * Algorithm from Rick McCarty, 1999 at
-     * http://personal.ecu.edu/mccartyr/ISOwdALG.txt
-     *
-     * @param string day in format DD
-     * @param string month in format MM
-     * @param string year in format CCYY
-     * @return string
-     * @access public
-     */
-    // Transcribed to PHP by Jesus M. Castagnetto (blame him if it is fubared ;-)
-    function gregorianToISO($day,$month,$year) {
-        $mnth = array (0,31,59,90,120,151,181,212,243,273,304,334);
-        $y_isleap = Date_Calc::isLeapYear($year);
-        $y_1_isleap = Date_Calc::isLeapYear($year - 1);
-        $day_of_year_number = $day + $mnth[$month - 1];
-        if ($y_isleap && $month > 2) {
-            $day_of_year_number++;
-        }
-        // find Jan 1 weekday (monday = 1, sunday = 7)
-        $yy = ($year - 1) % 100;
-        $c = ($year - 1) - $yy;
-        $g = $yy + intval($yy/4);
-        $jan1_weekday = 1 + intval((((($c / 100) % 4) * 5) + $g) % 7);
-        // weekday for year-month-day
-        $h = $day_of_year_number + ($jan1_weekday - 1);
-        $weekday = 1 + intval(($h - 1) % 7);
-        // find if Y M D falls in YearNumber Y-1, WeekNumber 52 or
-        if ($day_of_year_number <= (8 - $jan1_weekday) && $jan1_weekday > 4){
-            $yearnumber = $year - 1;
-            if ($jan1_weekday == 5 || ($jan1_weekday == 6 && $y_1_isleap)) {
-                $weeknumber = 53;
-            } else {
-                $weeknumber = 52;
-            }
-        } else {
-            $yearnumber = $year;
-        }
-        // find if Y M D falls in YearNumber Y+1, WeekNumber 1
-        if ($yearnumber == $year) {
-            if ($y_isleap) {
-                $i = 366;
-            } else {
-                $i = 365;
-            }
-            if (($i - $day_of_year_number) < (4 - $weekday)) {
-                $yearnumber++;
-                $weeknumber = 1;
-            }
-        }
-        // find if Y M D falls in YearNumber Y, WeekNumber 1 through 53
-        if ($yearnumber == $year) {
-            $j = $day_of_year_number + (7 - $weekday) + ($jan1_weekday - 1);
-            $weeknumber = intval($j / 7);
-            if ($jan1_weekday > 4) {
-                $weeknumber--;
-            }
-        }
-        // put it all together
-        if ($weeknumber < 10)
-            $weeknumber = '0'.$weeknumber;
-        return "{$yearnumber}-{$weeknumber}-{$weekday}";
     }
 
-    /**
-    * Determines julian date of the given season
-    * Adapted from previous work in Java by James Mark Hamilton, mhamilton at qwest.net
-    *
-    * @author Robert Butler <rob at maxwellcreek.org>
-    *
-    * @param string is VERNALEQUINOX, SUMMERSOLSTICE, AUTUMNALEQUINOX, or WINTERSOLSTICE.
-    * @param string year in format CCYY, must be a calendar year between -1000BC and 3000AD.
-    *
-    * @access public
-    *
-    * @return float $juliandate
-    */
-
-    function dateSeason ($season, $year = '') {
-            if ($year == '') {
-                    $year = Date_Calc::dateNow('%Y');
-            }
-
-            if (($year >= -1000) && ($year <= 1000)) {
-                    $y = $year / 1000.0;
-                    if ($season == 'VERNALEQUINOX') {
-                            $juliandate = (((((((-0.00071 * $y) - 0.00111) * $y) + 0.06134) * $y) + 365242.1374) * $y) + 1721139.29189;
-                    } else if ($season == 'SUMMERSOLSTICE') {
-                            $juliandate = ((((((( 0.00025 * $y) + 0.00907) * $y) - 0.05323) * $y) + 365241.72562) * $y) + 1721233.25401;
-                    } else if ($season == 'AUTUMNALEQUINOX') {
-                            $juliandate = ((((((( 0.00074 * $y) - 0.00297) * $y) - 0.11677) * $y) + 365242.49558) * $y) + 1721325.70455;
-                    } else if ($season == 'WINTERSOLSTICE') {
-                            $juliandate = (((((((-0.00006 * $y) - 0.00933) * $y) - 0.00769) * $y) + 365242.88257) * $y) + 1721414.39987;
-                    }
-            } elseif (($year > 1000) && ($year <= 3000)) {
-                    $y = ($year - 2000) / 1000;
-                    if ($season == 'VERNALEQUINOX') {
-                            $juliandate = (((((((-0.00057 * $y) - 0.00411) * $y) + 0.05169) * $y) + 365242.37404) * $y) + 2451623.80984;
-                    } else if ($season == 'SUMMERSOLSTICE') {
-                            $juliandate = (((((((-0.0003 * $y) + 0.00888) * $y) + 0.00325) * $y) + 365241.62603) * $y) + 2451716.56767;
-                    } else if ($season == 'AUTUMNALEQUINOX') {
-                            $juliandate = ((((((( 0.00078 * $y) + 0.00337) * $y) - 0.11575) * $y) + 365242.01767) * $y) + 2451810.21715;
-                    } else if ($season == 'WINTERSOLSTICE') {
-                            $juliandate = ((((((( 0.00032 * $y) - 0.00823) * $y) - 0.06223) * $y) + 365242.74049) * $y) + 2451900.05952;
-                    }
-            }
-
-            return ($juliandate);
-    } // end func dateSeason
-
+//    /**
+//     * Returns the current local year in format CCYY
+//     *
+//     * @access public
+//     *
+//     * @return string year in format CCYY
+//     */
+//
+//    function getYear()
+//    {
+//        return Date_Calc::dateNow('%Y');
+//    } // end func getYear
+//
+//    /**
+//     * Returns the current local month in format MM
+//     *
+//     * @access public
+//     *
+//     * @return string month in format MM
+//     */
+//
+//    function getMonth()
+//    {
+//        return Date_Calc::dateNow('%m');
+//    } // end func getMonth
+//
+//    /**
+//     * Returns the current local day in format DD
+//     *
+//     * @access public
+//     *
+//     * @return string day in format DD
+//     */
+//
+//    function getDay()
+//    {
+//        return Date_Calc::dateNow('%d');
+//    } // end func getDay
+//
+//    /**
+//     * Returns the full month name for the given month
+//     *
+//     * @param string month in format MM
+//     *
+//     * @access public
+//     *
+//     * @return string full month name
+//     */
+//
+//    function getMonthFullname($month)
+//    {
+//        $month = (int)$month;
+//
+//        if (empty($month)) {
+//            $month = (int) Date_Calc::dateNow('%m');
+//        }
+//
+//        $month_names = Date_Calc::getMonthNames();
+//
+//        return $month_names[$month];
+//        // getMonthNames returns months with correct indexes
+//        //return $month_names[($month - 1)];
+//    } // end func getMonthFullname
+//
+//    /**
+//     * Returns the abbreviated month name for the given month
+//     *
+//     * @param string month in format MM
+//     * @param int optional length of abbreviation, default is 3
+//     *
+//     * @access public
+//     *
+//     * @return string abbreviated month name
+//     * @see Date_Calc::getMonthFullname
+//     */
+//
+//    function getMonthAbbrname($month,$length=3)
+//    {
+//        $month = (int)$month;
+//
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//
+//        return substr(Date_Calc::getMonthFullname($month), 0, $length);
+//    } // end func getMonthAbbrname
+//
+//    /**
+//     * Returns the full weekday name for the given date
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     *
+//     * @access public
+//     *
+//     * @return string full month name
+//     */
+//
+//    function getWeekdayFullname($day='',$month='',$year='')
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        $weekday_names = Date_Calc::getWeekDays();
+//        $weekday = Date_Calc::dayOfWeek($day,$month,$year);
+//
+//        return $weekday_names[$weekday];
+//    } // end func getWeekdayFullname
+//
+//    /**
+//     * Returns the abbreviated weekday name for the given date
+//     *
+//     * @param string day in format DD, default is current local day
+//     * @param string month in format MM, default is current local month
+//     * @param string year in format CCYY, default is current local year
+//     * @param int optional length of abbreviation, default is 3
+//     *
+//     * @access public
+//     *
+//     * @return string full month name
+//     * @see Date_Calc::getWeekdayFullname
+//     */
+//
+//    function getWeekdayAbbrname($day='',$month='',$year='',$length=3)
+//    {
+//        if (empty($year)) {
+//            $year = Date_Calc::dateNow('%Y');
+//        }
+//        if (empty($month)) {
+//            $month = Date_Calc::dateNow('%m');
+//        }
+//        if (empty($day)) {
+//            $day = Date_Calc::dateNow('%d');
+//        }
+//
+//        return substr(Date_Calc::getWeekdayFullname($day,$month,$year),0,$length);
+//    } // end func getWeekdayFullname
+//
+//    /**
+//    * Returns the numeric month from the month name or an abreviation
+//    *
+//    * Both August and Aug would return 8.
+//    * Month name is case insensitive.
+//    *
+//    * @param    string  month name
+//    * @return   integer month number
+//    */
+//    function getMonthFromFullName($month)
+//    {
+//        $month = strtolower($month);
+//        $months = Date_Calc::getMonthNames();
+//        while(list($id, $name) = each($months)) {
+//            if (ereg($month, strtolower($name))) {
+//                return($id);
+//            }
+//        }
+//
+//        return(0);
+//    } // end func getMonthFromFullName
+//
+//    /**
+//    * Returns an array of month names
+//    *
+//    * Used to take advantage of the setlocale function to return
+//    * language specific month names.
+//    * XXX cache values to some global array to avoid preformace
+//    * hits when called more than once.
+//    *
+//    * @returns array An array of month names
+//    */
+//    function getMonthNames()
+//    {
+//        for($i=1;$i<13;$i++) {
+//            $months[$i] = strftime('%B', mktime(0, 0, 0, $i, 1, 2001));
+//        }
+//        return($months);
+//    } // end func getMonthNames
+//
+//    /**
+//    * Returns an array of week days
+//    *
+//    * Used to take advantage of the setlocale function to
+//    * return language specific week days
+//    * XXX cache values to some global array to avoid preformace
+//    * hits when called more than once.
+//    *
+//    * @returns array An array of week day names
+//    */
+//    function getWeekDays()
+//    {
+//        for($i=0;$i<7;$i++) {
+//            $weekdays[$i] = strftime('%A', mktime(0, 0, 0, 1, $i, 2001));
+//        }
+//        return($weekdays);
+//    } // end func getWeekDays
+//
+//    /**
+//     * Converts from Gregorian Year-Month-Day to
+//     * ISO YearNumber-WeekNumber-WeekDay
+//     *
+//     * Uses ISO 8601 definitions.
+//     * Algorithm from Rick McCarty, 1999 at
+//     * http://personal.ecu.edu/mccartyr/ISOwdALG.txt
+//     *
+//     * @param string day in format DD
+//     * @param string month in format MM
+//     * @param string year in format CCYY
+//     * @return string
+//     * @access public
+//     */
+//    // Transcribed to PHP by Jesus M. Castagnetto (blame him if it is fubared ;-)
+//    function gregorianToISO($day,$month,$year) {
+//        $mnth = array (0,31,59,90,120,151,181,212,243,273,304,334);
+//        $y_isleap = Date_Calc::isLeapYear($year);
+//        $y_1_isleap = Date_Calc::isLeapYear($year - 1);
+//        $day_of_year_number = $day + $mnth[$month - 1];
+//        if ($y_isleap && $month > 2) {
+//            $day_of_year_number++;
+//        }
+//        // find Jan 1 weekday (monday = 1, sunday = 7)
+//        $yy = ($year - 1) % 100;
+//        $c = ($year - 1) - $yy;
+//        $g = $yy + intval($yy/4);
+//        $jan1_weekday = 1 + intval((((($c / 100) % 4) * 5) + $g) % 7);
+//        // weekday for year-month-day
+//        $h = $day_of_year_number + ($jan1_weekday - 1);
+//        $weekday = 1 + intval(($h - 1) % 7);
+//        // find if Y M D falls in YearNumber Y-1, WeekNumber 52 or
+//        if ($day_of_year_number <= (8 - $jan1_weekday) && $jan1_weekday > 4){
+//            $yearnumber = $year - 1;
+//            if ($jan1_weekday == 5 || ($jan1_weekday == 6 && $y_1_isleap)) {
+//                $weeknumber = 53;
+//            } else {
+//                $weeknumber = 52;
+//            }
+//        } else {
+//            $yearnumber = $year;
+//        }
+//        // find if Y M D falls in YearNumber Y+1, WeekNumber 1
+//        if ($yearnumber == $year) {
+//            if ($y_isleap) {
+//                $i = 366;
+//            } else {
+//                $i = 365;
+//            }
+//            if (($i - $day_of_year_number) < (4 - $weekday)) {
+//                $yearnumber++;
+//                $weeknumber = 1;
+//            }
+//        }
+//        // find if Y M D falls in YearNumber Y, WeekNumber 1 through 53
+//        if ($yearnumber == $year) {
+//            $j = $day_of_year_number + (7 - $weekday) + ($jan1_weekday - 1);
+//            $weeknumber = intval($j / 7);
+//            if ($jan1_weekday > 4) {
+//                $weeknumber--;
+//            }
+//        }
+//        // put it all together
+//        if ($weeknumber < 10)
+//            $weeknumber = '0'.$weeknumber;
+//        return "{$yearnumber}-{$weeknumber}-{$weekday}";
+//    }
+//
+//    /**
+//    * Determines julian date of the given season
+//    * Adapted from previous work in Java by James Mark Hamilton, mhamilton at qwest.net
+//    *
+//    * @author Robert Butler <rob at maxwellcreek.org>
+//    *
+//    * @param string is VERNALEQUINOX, SUMMERSOLSTICE, AUTUMNALEQUINOX, or WINTERSOLSTICE.
+//    * @param string year in format CCYY, must be a calendar year between -1000BC and 3000AD.
+//    *
+//    * @access public
+//    *
+//    * @return float $juliandate
+//    */
+//
+//    function dateSeason ($season, $year = '') {
+//            if ($year == '') {
+//                    $year = Date_Calc::dateNow('%Y');
+//            }
+//
+//            if (($year >= -1000) && ($year <= 1000)) {
+//                    $y = $year / 1000.0;
+//                    if ($season == 'VERNALEQUINOX') {
+//                            $juliandate = (((((((-0.00071 * $y) - 0.00111) * $y) + 0.06134) * $y) + 365242.1374) * $y) + 1721139.29189;
+//                    } else if ($season == 'SUMMERSOLSTICE') {
+//                            $juliandate = ((((((( 0.00025 * $y) + 0.00907) * $y) - 0.05323) * $y) + 365241.72562) * $y) + 1721233.25401;
+//                    } else if ($season == 'AUTUMNALEQUINOX') {
+//                            $juliandate = ((((((( 0.00074 * $y) - 0.00297) * $y) - 0.11677) * $y) + 365242.49558) * $y) + 1721325.70455;
+//                    } else if ($season == 'WINTERSOLSTICE') {
+//                            $juliandate = (((((((-0.00006 * $y) - 0.00933) * $y) - 0.00769) * $y) + 365242.88257) * $y) + 1721414.39987;
+//                    }
+//            } elseif (($year > 1000) && ($year <= 3000)) {
+//                    $y = ($year - 2000) / 1000;
+//                    if ($season == 'VERNALEQUINOX') {
+//                            $juliandate = (((((((-0.00057 * $y) - 0.00411) * $y) + 0.05169) * $y) + 365242.37404) * $y) + 2451623.80984;
+//                    } else if ($season == 'SUMMERSOLSTICE') {
+//                            $juliandate = (((((((-0.0003 * $y) + 0.00888) * $y) + 0.00325) * $y) + 365241.62603) * $y) + 2451716.56767;
+//                    } else if ($season == 'AUTUMNALEQUINOX') {
+//                            $juliandate = ((((((( 0.00078 * $y) + 0.00337) * $y) - 0.11575) * $y) + 365242.01767) * $y) + 2451810.21715;
+//                    } else if ($season == 'WINTERSOLSTICE') {
+//                            $juliandate = ((((((( 0.00032 * $y) - 0.00823) * $y) - 0.06223) * $y) + 365242.74049) * $y) + 2451900.05952;
+//                    }
+//            }
+//
+//            return ($juliandate);
+//    } // end func dateSeason
+//
 } // end class Date_Calc
-
 ?>

Modified: plog/trunk/class/data/Date.class.php
===================================================================
--- plog/trunk/class/data/Date.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/data/Date.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -23,7 +23,7 @@
 /**@#+
  * Include supporting classes
  */
-require_once PLOG_CLASS_PATH.'class/data/Date/TimeZone.class.php';
+// require_once PLOG_CLASS_PATH.'class/data/Date/TimeZone.class.php';
 require_once PLOG_CLASS_PATH.'class/data/Date/Calc.class.php';
 require_once PLOG_CLASS_PATH.'class/data/Date/Span.class.php';
 /**@#-*/
@@ -112,7 +112,9 @@
      */
     var $tz;
 
+    var $offset = '+ 00:00';
 
+
     /**
      * Constructor
      *
@@ -129,7 +131,7 @@
      */
     function Date($date = null)
     {
-        $this->tz = Date_TimeZone::getDefault();
+        $this->tz = 'UTC';
         if (is_null($date)) {
             $this->setDate(date("Y-m-d H:i:s"));
         } elseif (is_a($date, 'Date')) {
@@ -176,6 +178,7 @@
             // so it has to store it as UTC
             if (isset($regs[9])) {
                 $this->toUTCbyOffset($regs[9]);
+                $this->offset = $regs[9];
             }
         } elseif (is_numeric($date)) {
             // UNIXTIME
@@ -210,23 +213,23 @@
             break;
         case DATE_FORMAT_ISO_BASIC:
             $format = "%Y%m%dT%H%M%S";
-            if ($this->tz->getID() == 'UTC') {
+            //if ($this->tz->getID() == 'UTC') {
                 $format .= "Z";
-            }
+            //}
             return $this->format($format);
             break;
         case DATE_FORMAT_ISO_EXTENDED:
             $format = "%Y-%m-%dT%H:%M:%S";
-            if ($this->tz->getID() == 'UTC') {
+            //if ($this->tz->getID() == 'UTC') {
                 $format .= "Z";
-            }
+            //}
             return $this->format($format);
             break;
         case DATE_FORMAT_ISO_EXTENDED_MICROTIME:
             $format = "%Y-%m-%dT%H:%M:%s";
-            if ($this->tz->getID() == 'UTC') {
+            //if ($this->tz->getID() == 'UTC') {
                 $format .= "Z";
-            }
+            //}
             return $this->format($format);
             break;
         case DATE_FORMAT_TIMESTAMP:
@@ -357,6 +360,9 @@
                     $output .= "\n";
                     break;
                 case "O":
+                    // :TODO: fix me .. this is just a hack right now, we need to calculate the correct offset
+                    $output .= $this->offset;
+                    break;
                     $offms = $this->tz->getOffset($this);
                     $direction = $offms >= 0 ? "+" : "-";
                     $offmins = abs($offms) / 1000 / 60;
@@ -365,6 +371,8 @@
                     $output .= sprintf("%s%02d:%02d", $direction, $hours, $minutes);
                     break;
                 case "o":
+                    $output = $this->offset;
+                    break;
                     $offms = $this->tz->getRawOffset($this);
                     $direction = $offms >= 0 ? "+" : "-";
                     $offmins = abs($offms) / 1000 / 60;
@@ -513,7 +521,7 @@
         } else {
             $this->addSeconds(intval(abs($this->tz->getOffset($this)) / 1000));
         }
-        $this->tz = new Date_TimeZone('UTC');
+        // $this->tz = new Date_TimeZone('UTC');
     }
 
     /**
@@ -527,22 +535,25 @@
      * @access public
      * @param object Date_TimeZone $tz the Date::TimeZone object for the conversion time zone
      */
-    function convertTZ($tz)
-    {
-        // convert to UTC
-        if ($this->tz->getOffset($this) > 0) {
-            $this->subtractSeconds(intval(abs($this->tz->getOffset($this)) / 1000));
-        } else {
-            $this->addSeconds(intval(abs($this->tz->getOffset($this)) / 1000));
-        }
-        // convert UTC to new timezone
-        if ($tz->getOffset($this) > 0) {
-            $this->addSeconds(intval(abs($tz->getOffset($this)) / 1000));
-        } else {
-            $this->subtractSeconds(intval(abs($tz->getOffset($this)) / 1000));
-        }
-        $this->tz = $tz;
-    }
+//
+//    disabling TZ Features
+//     
+//    function convertTZ($tz)
+//    {
+//        // convert to UTC
+//        if ($this->tz->getOffset($this) > 0) {
+//            $this->subtractSeconds(intval(abs($this->tz->getOffset($this)) / 1000));
+//        } else {
+//            $this->addSeconds(intval(abs($this->tz->getOffset($this)) / 1000));
+//        }
+//        // convert UTC to new timezone
+//        if ($tz->getOffset($this) > 0) {
+//            $this->addSeconds(intval(abs($tz->getOffset($this)) / 1000));
+//        } else {
+//            $this->subtractSeconds(intval(abs($tz->getOffset($this)) / 1000));
+//        }
+//        $this->tz = $tz;
+//    }
 
     /**
      * Converts this date to a new time zone, given a valid time zone ID
@@ -555,15 +566,15 @@
      * @access public
      * @param string id a time zone id
      */
-    function convertTZbyID($id)
-    {
-       if (Date_TimeZone::isValidID($id)) {
-          $tz = new Date_TimeZone($id);
-       } else {
-          $tz = Date_TimeZone::getDefault();
-       }
-       $this->convertTZ($tz);
-    }
+//    function convertTZbyID($id)
+//    {
+//       if (Date_TimeZone::isValidID($id)) {
+//          $tz = new Date_TimeZone($id);
+//       } else {
+//          $tz = Date_TimeZone::getDefault();
+//       }
+//       $this->convertTZ($tz);
+//    }
 
     function toUTCbyOffset($offset)
     {
@@ -588,7 +599,7 @@
                 $this->addSeconds(intval(abs($offset)));
             }
 
-            $this->tz = new Date_TimeZone('UTC');
+            // $this->tz = new Date_TimeZone('UTC');
             return true;
         }
 
@@ -733,7 +744,7 @@
      */
     function compare($d1, $d2)
     {
-        $d1->convertTZ(new Date_TimeZone('UTC'));
+        // $d1->convertTZ(new Date_TimeZone('UTC'));
         $d2->convertTZ(new Date_TimeZone('UTC'));
         $days1 = Date_Calc::dateToDays($d1->day, $d1->month, $d1->year);
         $days2 = Date_Calc::dateToDays($d2->day, $d2->month, $d2->year);

Modified: plog/trunk/class/database/db.class.php
===================================================================
--- plog/trunk/class/database/db.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/database/db.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -17,6 +17,7 @@
      */
 	class Db extends Object 
 	{
+        var $_prefix;
 
 		function Db()
 		{
@@ -70,11 +71,211 @@
 		 */
 		function getPrefix()
 		{
-			$fileConfig = new ConfigFileStorage();
-			$prefix = $fileConfig->getValue( "db_prefix" );
-			return( $prefix );	
+            static $prefix;
+
+            if ( isset($prefix) ) {
+                return $prefix;
+            } else {
+			    $fileConfig = new ConfigFileStorage();
+			    $prefix = $fileConfig->getValue( "db_prefix" );
+			    return( $prefix );	
+            }
 		}
 
+
+        function buildSelectQuery( $tableName, 
+                                   $fieldsToFetch = array(),
+                                   $whereColumn   = null, 
+                                   $whereValue    = null,
+                                   $orderColumn   = null,
+                                   $limit         = null,
+                                   $whereGlue     = ' AND ')
+        {
+            $tableName = Db::addTablePrefixToTableName( $tableName );
+
+            $query = 'SELECT ';
+            if( $fieldsToFetch == array() ) {
+                $query .= '*';
+            } else {
+                $query .= implode(",", $fieldsToFetch);
+            }
+            $query .= ' FROM ' . $tableName;
+
+            if( $orderColumn != null ) {
+                $query .= Db::_buildOrderCondition( $orderColumn );
+            }
+
+            if( $whereColumn != null ) {
+                $query .= Db::buildWhereConditions( $whereColumn, $whereValue, $whereGlue );
+            }
+
+            if( $limit != null ) {
+                $query .= ' LIMIT ' . $limit;
+            }
+
+            $query .= ';';
+
+            return $query;
+        }
+
+        function buildInsertQuery( $tableName,
+                                   $keyValuePairs )
+        {
+            $tableName = Db::addTablePrefixToTableName( $tableName );
+
+            $query  = 'INSERT INTO ' . $tableName;
+
+            foreach( $keyValuePairs as $key => $value ) {
+                $keys[]   = $key;
+                $values[] = Db::quoteValue( $value );
+            }
+            $query .= ' (' . implode( ",", $keys ) . ')';
+            $query .= ' VALUES (';
+            $query .= implode( ",", $values );
+            $query .= ');';
+
+            return $query;
+        }
+
+        function buildUpdateQuery( $tableName,
+                                   $keyValuePairs,
+                                   $whereColumn   = null, 
+                                   $whereValue    = null,
+                                   $whereGlue     = ' AND ')
+        {
+            $tableName = Db::addTablePrefixToTableName( $tableName );
+
+            $query  = 'UPDATE ' . $tableName . ' SET ';
+
+            $valuesToSet = array();
+            foreach( $keyValuePairs as $key => $value ) {
+                $queryPart  = $key . ' = ';
+                $queryPart .= Db::quoteValue( $value );
+                $valuesToSet[] = $queryPart;
+            }
+            $query .= implode( ",", $valuesToSet );
+            
+            if( $whereColumn != null )
+                $query .= Db::buildWhereConditions( $whereColumn, $whereValue, $whereGlue );
+
+            return $query;
+        }
+
+        function buildDeleteQuery( $tableName,
+                                   $whereColumn = null,
+                                   $whereValue  = null,
+                                   $whereGlue   = ' AND ')
+        {
+            $tableName = Db::addTablePrefixToTableName( $tableName );
+
+            $query  = 'DELETE FROM ' . $tableName;
+
+            if( $whereColumn != null )
+                $query .= Db::buildWhereConditions( $whereColumn, $whereValue, $whereGlue );
+
+            return $query;
+        }
+
+        function addTablePrefixToTableName( $tableName ) {
+            if ( !preg_match( "/^" . Db::getPrefix() . "/", $tableName) ) {
+                $tableName = Db::getPrefix() . $tableName;
+            }
+            return $tableName;
+        }
+
+        function _buildOrderCondition( $orderColumn )
+        {
+            preg_match( '/^(.)(.*)$/', $orderColumn, $matches );
+
+            $queryPart = ' ORDER BY '; 
+            switch( $firstValueCharacter ) {
+                case '-':
+                    $orderColumn = $matches[2];
+                    $direction = ' DESC';
+                case '+':
+                    $orderColumn = $matches[2];
+                default:
+                    $direction  = '';
+                    $queryPart .= $orderColumn . $direction;
+            }
+            return $queryPart;
+        }
+
+
+        function buildWhereConditions( $whereColumn, $whereValue, $whereGlue )
+        {
+            $queryPart = ' WHERE ';
+            if( is_array($whereColumn) ) {
+                $conditions = array();
+                foreach( $whereColumn as $column => $value ) {
+                    $conditions[] = Db::buildWhereCondition( $column, $value );
+                }
+                $queryPart .= implode( $whereGlue , $conditions );
+            } elseif( !empty($whereColumn) ) {
+                $queryPart .= Db::buildWhereCondition( $whereColumn, $whereValue );
+            }
+
+            return $queryPart;
+        }
+
+        function buildWhereCondition( $columnName, $columnValue )
+        {
+            preg_match( '/^(.)(.*)$/', $columnValue, $matches );
+            $firstValueCharacter = $matches[1];
+            switch( $firstValueCharacter ) {
+                case '>':
+                    $operator = '>';
+                    $columnValue = $matches[2];
+                    break;
+                case '<':
+                    $operator = '<';
+                    $columnValue = $matches[2];
+                    break;
+                case '=':
+                    $columnValue = $matches[2];
+                    // no break, we want to continue to the default
+                default:
+                    $operator = '=';
+                }
+            $queryPart  = $columnName . ' ' . $operator . ' ';
+            $queryPart .= Db::quoteValue( $columnValue );
+            return $queryPart;
+        }
+
+        /**
+         * Quote a value for a SQL query. Depending on the type of the
+         * value, this method will return the correct string to store
+         * the value in the database.
+         *
+         * - if the value is numeric, it will return the numeric value
+         * - if the value is a Timestamp(), it will return an isoDate
+         * - if the value is a string, it will return a quoted string
+         * - if the value starts with an '@', it will return the
+         *   unquoted value. this is used e.g. for adding something
+         *   like "date = date" in Articles()->deleteArticle().
+         *
+         * @param value a value to be stored in the database
+         * @return string the correctly quoted value
+         * @access public
+         */
+
+        function quoteValue( $value )
+        {
+            if( is_numeric($value) )
+                return $value;
+            if( preg_match('/^@(.*)/', $value, $matches) )
+                return $matches[1];
+            elseif( is_object($value) ) {
+                switch (get_class($value)) {
+                    case 'timestamp':
+                        return Db::quoteValue($value->getIsoDate());
+                        break;
+                }
+            }
+            else
+                return '\'' . Db::qstr( $value ) . '\'';
+        }
+
 		/**
 		 * Prepares a string for an SQL query by escaping apostrophe
 		 * characters. If the PHP configuration setting 'magic_quotes_gpc'
@@ -98,5 +299,5 @@
 
 			return $string;
 		}
-	}
+    }
 ?>

Modified: plog/trunk/class/gallery/dao/galleryalbums.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryalbums.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/gallery/dao/galleryalbums.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -81,23 +81,25 @@
 		 */
         function getAlbum( $id, $ownerId = -1, $fetchResources = true, $onlyShownAlbums = false )
         {
-        	// make sure that we don't have this album yet...
+        	// we might have this album in the memory cache already..
             if( isset($this->cache[$id])) {
             	return $this->cache[$id];
             }
 
-            // otherwise, continue the normal process...
-        	$query = "SELECT id, owner_id, description,
-        	                 name, flags, parent_id,
-        	                 date, properties, show_album 
-        	          FROM ".$this->getPrefix()."gallery_albums 
-        	          WHERE id = $id";
-            if( $ownerId != -1 )
-            	$query .= " AND owner_id = $ownerId";
-            if( $onlyShownAlbums )
-            	$query .= " AND show_album = 1";
-			
-			return $this->_getAlbumFromQuery( $query );
+            // or in the global file cache..
+            $album = $this->_cache->getData( $id, CACHE_GALLERYALBUM );
+
+            if ( !$album || ($onlyShownAlbums && !$album->getShowAlbum()) ) {
+                // otherwise, continue the normal process...
+                $query = "SELECT * FROM ".$this->getPrefix()."gallery_albums WHERE id = $id";
+                if( $ownerId != -1 )
+                    $query .= " AND owner_id = $ownerId";
+                if( $onlyShownAlbums )
+                    $query .= " AND show_album = 1";
+                $album = $this->_getAlbumFromQuery( $query );
+                $this->_cache->setData( $id, CACHE_GALLERYALBUM, $album );
+            }
+            return $album;
         }
 		
 		/**
@@ -228,6 +230,9 @@
                 
             // return the id of the last row we inserted, which will be the id of the album
             $result = $this->_db->Insert_ID();
+
+            // remove the cached album hierarchy array
+            $this->_cache->removeData( $album->getOwnerId(), CACHE_USERALBUMS );
             
             return $result;
         }
@@ -259,8 +264,8 @@
             if ($album->getId() == $album->getParentId()){
 				return false;
 			}
-			$tf = new TextFilter();
-        	$query = "UPDATE ".$this->getPrefix()."gallery_albums SET
+            $tf = new TextFilter();
+            $query = "UPDATE ".$this->getPrefix()."gallery_albums SET
                       description = '".Db::qstr($album->getDescription())."',
                       name = '".Db::qstr($album->getName())."',
                       parent_id = ".$album->getParentId().",
@@ -271,7 +276,13 @@
 					  mangled_name = '".$tf->urlize($album->getName())."'
                       WHERE id = ".$album->getId().";";
 
-             return $this->Execute( $query );
+            // remove the album from the cache
+            $this->_cache->removeData( $album->getId(), CACHE_GALLERYALBUM );
+
+            // and remove the cached album hierarchy array
+            $this->_cache->removeData( $album->getOwnerId(), CACHE_USERALBUMS );
+
+            return $this->Execute( $query );
         }
 
         /**
@@ -283,11 +294,20 @@
          */
         function deleteAlbum( $albumId, $userId = -1 )
         {
+            // remove the cached album hierarchy array 1st .. 
+            // too bad we need to load the album before deleting it, but this method
+            // won't get called all to often anyway :)
+            $album = $this->getAlbum( $albumId );
+            $this->_cache->removeData( $album->getOwnerId(), CACHE_USERALBUMS );
+
         	$query = "DELETE FROM ".$this->getPrefix()."gallery_albums
                       WHERE id = $albumId";
             if( $userId != -1 )
             	$query .= " AND owner_id = $userId";
 
+            // remove the album from the cache
+            $this->_cache->removeData( $albumId, CACHE_GALLERYALBUM );
+
             return $this->Execute( $query );
         }
 
@@ -362,45 +382,47 @@
 		 * array with all the albums that share the same parent id or empty if none
 		 *
 		 * @param userId 
-		 * @param albumId
+		 * @param albumId - unused
 		 * @return An associative array
 		 */
 		function getUserAlbumsGroupedByParentId( $userId, $albumId = 0 )
 		{
-			$prefix = $this->getPrefix();
-			$query = "SELECT id, owner_id, description,
-        	                 name, flags, parent_id,
-        	                 date, properties, show_album 
-        	          FROM {$prefix}gallery_albums 
-			          WHERE owner_id = '".Db::qstr($userId)."'
-					  ORDER BY name ASC";
+            $albums = $this->_cache->getData( $userId, CACHE_USERALBUMS );
 
-			$result = $this->Execute( $query );
+            if ( !$albums ) {
+                $prefix = $this->getPrefix();
+                $query = "SELECT * FROM {$prefix}gallery_albums 
+                          WHERE owner_id = '".Db::qstr($userId)."'
+                          ORDER BY name ASC";
+
+                $result = $this->Execute( $query );
+                
+                if( !$result )
+                    return Array();
+                    
+                $albums = Array();
+                $ids = Array();
+                $ids[] = 0;
+                while( $row = $result->FetchRow()) {
+                    $album = new GalleryAlbum( $row["owner_id"],
+                                            $row["name"],
+                                            $row["description"],
+                                            $row["flags"],
+                                            $row["parent_id"],
+                                            $row["date"],
+                                            unserialize($row["properties"]),
+                                            $row["show_album"],
+                                            $row["id"] );
+                    $key = $album->getParentId();
+                    if( $albums["$key"] == "" )
+                        $albums["$key"] = Array();
+                    $albums["$key"][] = $album;
+                    
+                    $ids[] = $album->getId();
+                }
+                $this->_cache->setData( $userId, CACHE_USERALBUMS, $albums );
+            }
 			
-			if( !$result )
-				return Array();
-				
-			$albums = Array();
-			$ids = Array();
-			$ids[] = 0;
-			while( $row = $result->FetchRow()) {
-				$album = new GalleryAlbum( $row["owner_id"],
-										$row["name"],
-										$row["description"],
-										$row["flags"],
-										$row["parent_id"],
-										$row["date"],
-										unserialize($row["properties"]),
-										$row["show_album"],
-										$row["id"] );
-				$key = $album->getParentId();
-				if( $albums["$key"] == "" )
-					$albums["$key"] = Array();
-				$albums["$key"][] = $album;
-				
-				$ids[] = $album->getId();
-			}
-			
 			return $albums;
 		}
 		
@@ -473,4 +495,4 @@
             return $album;
         }
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/gallery/dao/galleryresource.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresource.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/gallery/dao/galleryresource.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -8,7 +8,6 @@
     include_once( PLOG_CLASS_PATH."class/gallery/data/galleryresourcezipmetadatareader.class.php" );
     include_once( PLOG_CLASS_PATH."class/gallery/galleryconstants.php" );
     include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresourcestorage.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
     
     // Add this to avoid long file name error in windows server
     define('GETID3_HELPERAPPSDIR', 'no_helper_apps_needed'); 
@@ -120,6 +119,9 @@
 		 */	
         function getTimestamp()
         {
+            // source necessary source
+            include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+
         	return new Timestamp($this->_date);
         }
 

Modified: plog/trunk/class/gallery/dao/galleryresources.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresources.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/gallery/dao/galleryresources.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -92,26 +92,28 @@
          */
         function getResource( $resourceId, $ownerId = -1, $albumId = -1 )
         {
-        	$query = "SELECT id, owner_id, album_id, description,
-        	          date, flags, resource_type, file_path, file_name,
-        	          metadata, thumbnail_format
-        	          FROM ".$this->getPrefix()."gallery_resources
-                      WHERE id = $resourceId";
-            if( $ownerId > 0 )
-            	$query .= " AND owner_id = $ownerId";
-			if( $albumId > 0 )
-				$query .=" AND album_id = $albumId";
+            $resource = $this->_cache->getData( $resourceId, CACHE_RESOURCES );
 
-            $result = $this->Execute( $query );
+            if( !$resource ) {
+                $query = "SELECT * FROM ".$this->getPrefix()."gallery_resources
+                          WHERE id = $resourceId";
+                if( $ownerId > 0 )
+                    $query .= " AND owner_id = $ownerId";
+                if( $albumId > 0 )
+                    $query .=" AND album_id = $albumId";
 
-            if( !$result )
-            	return false;
+                $result = $this->Execute( $query );
 
-            if( $result->RecordCount() == 0 )
-            	return false;
+                if( !$result )
+                    return false;
 
-            $row = $result->FetchRow();
-            $resource = $this->_fillResourceInformation( $row );
+                if( $result->RecordCount() == 0 )
+                    return false;
+
+                $row = $result->FetchRow();
+                $resource = $this->_fillResourceInformation( $row );
+                $this->_cache->setData( $resourceId, CACHE_RESOURCES, $resource );
+            }
 			
 			return $resource;
         }
@@ -636,6 +638,9 @@
 
             $result = $this->Execute( $query );
 
+            // clear the cache
+            $this->_cache->removeData( $resource->getId(), CACHE_RESOURCES );
+
             if( !$result )
             	return false;
             else
@@ -661,6 +666,9 @@
             	$query .= " AND owner_id = $ownerId";
 
             $result = $this->Execute( $query );
+            
+            // clear the cache
+            $this->_cache->removeData( $resourceId, CACHE_RESOURCES );
 
             // if there was an error, we quit here
             if( !$result )

Modified: plog/trunk/class/locale/locale.class.php
===================================================================
--- plog/trunk/class/locale/locale.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/locale/locale.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -72,6 +72,7 @@
 
 		var $_defaultFolder;
 		var $_code;	// our ISO locale code, eg. es_ES, en_UK, etc
+        var $_cache;
 		var $_messages;
         var $_charset;
 		var $_description;
@@ -89,16 +90,15 @@
          */
 		function Locale( $code )
 		{
-			$this->Object();
+            $this->Object();
 
-            $this->_defaultFolder = $this->getLocaleFolder();
+            $this->_code = $code;
 
-			$this->_code = $code;
+            $this->_loadLocaleInfo();
 
-			$this->_loadLocaleInfo();
+            if( $this->_charset == "" )
+                $this->_charset = DEFAULT_ENCODING;
 
-            if( $this->_charset == "" )
-            	$this->_charset = DEFAULT_ENCODING;
 		}
 
         /**
@@ -106,15 +106,17 @@
          */
 		function _loadLocaleFile()
 		{
-			$fileName = $this->_defaultFolder."/locale_".$this->_code.".php";
+            $this->_defaultFolder = $this->getLocaleFolder();
+  
+            $fileName = $this->_defaultFolder."/locale_".$this->_code.".php";
 
-			if( File::isReadable( $fileName ))
-				include( $fileName );
+            if( File::isReadable( $fileName ))
+                include( $fileName );
 
-			$this->_messages = $messages;
+            $this->_messages = $messages;
 
             unset($messages);
-	
+
 			/*if( function_exists('memory_get_usage'))
 				$this->log->debug('Memory used after loading locale ' . $this->_code . ': ' . memory_get_usage());*/
 		}
@@ -125,8 +127,11 @@
 		 */
 		function _loadLocaleInfo()
 		{
-			// load the locale into $this->_messages
-			$this->_loadLocaleFile();
+
+            if( !is_array($this->_messages) ) {
+                // load the locale into $this->_messages
+                $this->_loadLocaleFile();
+            }
 			
 			// get the info that we need
 			$this->_description = isset($this->_messages["locale_description"]) ? $this->_messages["locale_description"] : "no description for " . $this->_code;

Modified: plog/trunk/class/locale/locales.class.php
===================================================================
--- plog/trunk/class/locale/locales.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/locale/locales.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -3,7 +3,6 @@
 	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
 	include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
 	include_once( PLOG_CLASS_PATH."class/locale/locale.class.php" );
-	include_once( PLOG_CLASS_PATH."class/locale/pluginlocale.class.php" );
 	include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
 
     define("DEFAULT_LOCALE", "en_UK");
@@ -29,7 +28,7 @@
 
     	function Locales()
         {
-        	$this->Object();
+            $this->Object();
         }
 
         /**
@@ -64,11 +63,16 @@
 
             // check if we have already loaded that locale or else, load it from
             // disk and keep it for later, just in case anybody asks again
-            if( isset($loadedLocales[$localeCode] )) {
+            if( isset($loadedLocales[$localeCode]) ) {
             	$locale = $loadedLocales[$localeCode];
-            }
-            else { 
-            	$locale = new Locale( $localeCode );
+            } else {
+                require_once( PLOG_CLASS_PATH . "class/cache/cachemanager.class.php" );
+                $cache =& CacheManager::getCache();
+                $locale = $cache->getData( $localeCode, CACHE_LOCALES );
+                if ( !$locale ) {
+                    $locale = new Locale( $localeCode );
+                    $cache->setData( $localeCode, CACHE_LOCALES, $locale );
+                }
                 $pm =& PluginManager::getPluginManager();                
                 foreach( $pm->_pluginList as $pluginId ) {
                     if( $pm->pluginHasLocale( $pluginId, $localeCode )) {
@@ -86,9 +90,9 @@
                     // merge the plugin locale with the big locale
                     $locale->mergeLocale( $pluginLocale );                    
                 }
+            }
                 
-                $loadedLocales[$localeCode] = $locale;
-            }
+           $loadedLocales[$localeCode] = $locale;
 			
             return $locale;
         }
@@ -118,6 +122,8 @@
             	$locale = $_plugins_loadedLocales[$pluginLocaleKey][$localeCode];
             }
             else {
+	            include_once( PLOG_CLASS_PATH."class/locale/pluginlocale.class.php" );
+
             	$locale = new PluginLocale( $pluginId, $localeCode );
                 $_plugins_loadedLocales[$pluginLocaleKey][$localeCode] = $locale;
             }

Modified: plog/trunk/class/net/http/session/sessionmanager.class.php
===================================================================
--- plog/trunk/class/net/http/session/sessionmanager.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/net/http/session/sessionmanager.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,6 +1,7 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
+    include_once( PLOG_CLASS_PATH."class/net/url.class.php" );
     include_once( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
 	include_once( PLOG_CLASS_PATH."class/net/http/session/sessioninfo.class.php" );
 	include_once( PLOG_CLASS_PATH."class/config/config.class.php" );

Modified: plog/trunk/class/plugin/pluginbase.class.php
===================================================================
--- plog/trunk/class/plugin/pluginbase.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/plugin/pluginbase.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -12,18 +12,6 @@
      */
 
 	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
-    include_once( PLOG_CLASS_PATH."class/database/adodb/adodb.inc.php" );
-    include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
-    include_once( PLOG_CLASS_PATH."class/controller/admincontroller.class.php" );
-    include_once( PLOG_CLASS_PATH."class/controller/blogcontroller.class.php" );
-    include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
-    include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
-    include_once( PLOG_CLASS_PATH."class/security/pipeline.class.php" );
-    include_once( PLOG_CLASS_PATH."class/security/pipelinerequest.class.php" );
-    include_once( PLOG_CLASS_PATH."class/security/pipelineresult.class.php" );
-	include_once( PLOG_CLASS_PATH."class/template/menu/menu.class.php" );
-	include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
 
     /**
      * \ingroup Plugin
@@ -55,6 +43,11 @@
         var $id = "";
 
         /**
+         * This should be filled with the author of the plugins
+         */
+        var $version = "";
+
+        /**
          * Set this to the html code that you would like to display when
          * configuring this plugin.
          */
@@ -170,6 +163,8 @@
          */
         function updateBlogSettings()
         {
+            include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
         	$blogs = new Blogs();
 
             $result = $blogs->updateBlogSettings( $this->blogInfo->getId(), $this->blogSettings);
@@ -206,6 +201,8 @@
          */
         function registerAdminAction( $key, $actionClass )
         {
+            include_once( PLOG_CLASS_PATH."class/controller/admincontroller.class.php" );
+
             AdminController::registerAction( $key, $actionClass );
             
             return true;
@@ -220,6 +217,8 @@
          */
         function registerBlogAction( $key, $actionClass )
         {
+            include_once( PLOG_CLASS_PATH."class/controller/blogcontroller.class.php" );
+
             BlogController::registerAction( $key, $actionClass );
             
             return true;
@@ -234,6 +233,8 @@
          */
         function registerFilter( $filterName )
         {
+            include_once( PLOG_CLASS_PATH."class/security/pipeline.class.php" );
+
             Pipeline::registerFilter( $filterName );
             
             return true;
@@ -252,6 +253,8 @@
 		 */
 		function addMenuEntry( $path, $id, $url, $localeId = null, $blogOwner = false, $siteAdmin = false )
 		{
+	        include_once( PLOG_CLASS_PATH."class/template/menu/menu.class.php" );
+
 			// get hold of the menu structure
 			$menu =& Menu::getMenu();
 			// and create a valid menuEntry object

Modified: plog/trunk/class/plugin/pluginmanager.class.php
===================================================================
--- plog/trunk/class/plugin/pluginmanager.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/plugin/pluginmanager.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -4,10 +4,10 @@
     include_once( PLOG_CLASS_PATH."class/file/file.class.php" );
     include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
     include_once( PLOG_CLASS_PATH."class/misc/glob.class.php" );
-    include_once( PLOG_CLASS_PATH."class/controller/blogcontroller.class.php" );
-    include_once( PLOG_CLASS_PATH."class/controller/admincontroller.class.php" );
-	include_once( PLOG_CLASS_PATH."class/plugin/eventlist.properties.php" );
-	include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+//    include_once( PLOG_CLASS_PATH."class/controller/blogcontroller.class.php" );
+//    include_once( PLOG_CLASS_PATH."class/controller/admincontroller.class.php" );
+//	include_once( PLOG_CLASS_PATH."class/plugin/eventlist.properties.php" );
+//	include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
 	include_once( PLOG_CLASS_PATH."class/controller/resourceclassloader.class.php" );
 
     /**
@@ -240,6 +240,8 @@
          */
         function _loadPluginLocale( $pluginId, $locale )
         {
+            require_once( PLOG_CLASS_PATH . "class/locale/locales.class.php" );
+
             return( Locales::getPluginLocale( $pluginId, $locale ));
         }
 

Modified: plog/trunk/class/security/bayesianfilter.class.php
===================================================================
--- plog/trunk/class/security/bayesianfilter.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/security/bayesianfilter.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,14 +1,6 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/security/pipelinefilter.class.php" );
-	include_once( PLOG_CLASS_PATH."class/bayesian/bayesiantokenizer.class.php" );
-	include_once( PLOG_CLASS_PATH."class/bayesian/bayesianfiltercore.class.php" );	
-    include_once( PLOG_CLASS_PATH."class/dao/bayesiantokens.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/bayesiantoken.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/bayesianfilterinfos.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/bayesianfilterinfo.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
-    include_once( PLOG_CLASS_PATH."class/net/client.class.php" );
 
     define("HIGH_SPAM_PROBABILITY", 1000);
 
@@ -49,6 +41,8 @@
         */         
         function filter()
         {
+            include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
+
         	$config	=& Config::getConfig();
         	
         	if (!$config->getValue("bayesian_filter_enabled"))
@@ -144,6 +138,8 @@
         */        
         function getSpamProbability($blogId, $topic, $text, $userName, $userEmail, $userUrl)
         {
+	        include_once( PLOG_CLASS_PATH."class/bayesian/bayesiantokenizer.class.php" );
+
             $tokenizer = new BayesianTokenizer();
 
             $tokensTopic = $tokenizer->addContextMark($tokenizer->tokenize($topic), TOKEN_TOPIC_MARK);
@@ -164,6 +160,9 @@
         */
 		function _getMostSignificantTokens($blogId, $tokens)
         {       
+            include_once( PLOG_CLASS_PATH."class/dao/bayesiantokens.class.php" );
+            include_once( PLOG_CLASS_PATH."class/dao/bayesianfilterinfos.class.php" );
+
         	$config	=& Config::getConfig(); 
         	
         	$bayesianFilterInfos = new BayesianFilterInfos();

Modified: plog/trunk/class/security/nullpipelinefilter.class.php
===================================================================
--- plog/trunk/class/security/nullpipelinefilter.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/security/nullpipelinefilter.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,6 +1,6 @@
 <?php
 
-	include_once( PLOG_CLASS_PATH."class/security/pipelinefilter.class.php" );
+	require_once( PLOG_CLASS_PATH."class/security/pipelinefilter.class.php" );
 
     /**
      * \ingroup Security
@@ -23,9 +23,11 @@
          */
         function filter()
         {
+            require_once( PLOG_CLASS_PATH . 'class/security/pipelineresult.class.php' );
+
         	$result = new PipelineResult();
 
             return $result;
         }
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/security/pipeline.class.php
===================================================================
--- plog/trunk/class/security/pipeline.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/security/pipeline.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -10,11 +10,7 @@
 
 
 	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
     include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
-    include_once( PLOG_CLASS_PATH."class/security/nullpipelinefilter.class.php" );
-    include_once( PLOG_CLASS_PATH."class/security/commentfilter.class.php" );
-    include_once( PLOG_CLASS_PATH."class/security/bayesianfilter.class.php" );
     
     /**
      * global array used to hold the list of filters that we're going to use in the pipeline.
@@ -90,6 +86,10 @@
          */
         function _registerDefaultFilters()
         {
+            include_once( PLOG_CLASS_PATH."class/security/nullpipelinefilter.class.php" );
+            include_once( PLOG_CLASS_PATH."class/security/commentfilter.class.php" );
+            include_once( PLOG_CLASS_PATH."class/security/bayesianfilter.class.php" );
+
             $this->registerFilter( "NullPipelineFilter" );
             $this->registerFilter( "CommentFilter" );
             $this->registerFilter( "BayesianFilter" );
@@ -120,6 +120,7 @@
          */
         function process()
         {
+            require_once( PLOG_CLASS_PATH . 'class/security/pipelinerequest.class.php' );
             global $_pLogPipelineRegisteredFilters;        
         
         	// check if the pipeline is enabled

Modified: plog/trunk/class/security/pipelinefilter.class.php
===================================================================
--- plog/trunk/class/security/pipelinefilter.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/security/pipelinefilter.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,8 +1,6 @@
 <?php
 
     include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
-    include_once( PLOG_CLASS_PATH."class/security/pipelinerequest.class.php" );
-    include_once( PLOG_CLASS_PATH."class/security/pipelineresult.class.php" );
 
     /**
      * \ingroup Security
@@ -60,4 +58,4 @@
             throw( new Exception( "This method must be implemented by child classes!" ));
         }
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/summary/action/summarydefaultaction.class.php
===================================================================
--- plog/trunk/class/summary/action/summarydefaultaction.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/summary/action/summarydefaultaction.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -2,9 +2,6 @@
 
 	include_once( PLOG_CLASS_PATH."class/summary/action/summaryaction.class.php" );
     include_once( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
-    include_once( PLOG_CLASS_PATH."class/logger/LogUtil.php" );
 
      /**
       * This is the one and only default action. It simply fetches all the most recent
@@ -28,7 +25,9 @@
          */
         function perform()
         {
-			$this->_view = new SummaryCachedView( "index", Array( "summary" => "default", "locale" => $this->_locale->getLocaleCode()));
+            include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
+			$this->_view = new SummaryCachedView( "index", Array( "summary" => "default" ));
 			if( $this->_view->isCached()) {
 				// if the view is already cached... move along! nothing to see here
 				return true;

Modified: plog/trunk/class/summary/dao/summarystats.class.php
===================================================================
--- plog/trunk/class/summary/dao/summarystats.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/summary/dao/summarystats.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,10 +1,9 @@
 <?php
 
     include_once( PLOG_CLASS_PATH."class/dao/model.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/articlecommentstatus.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articlecommentstatus.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articlestatus.class.php" );
 	
 	/**
 	 * maximum number of items that will be shown per page in the summary
@@ -40,6 +39,8 @@
          */
         function getMostCommentedArticles( $maxPosts = 0, $ignoreTopic = "", $ignoreText = "" )
         {
+            include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+
 			$prefix = $this->getPrefix();
 			$query = " SELECT COUNT(*) as total_comments, a.* 
 					   FROM {$prefix}articles_comments AS c, 
@@ -67,7 +68,7 @@
             	$query .= " LIMIT 0,".$maxPosts;
 
 
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
 
             if( !$result ){
             	return Array();
@@ -93,24 +94,28 @@
          */
         function getMostReadArticles( $maxPosts = 0, $ignoreTopic = "", $ignoreText = "" )
         {
-            $prefix = $this->getPrefix();
-					$query = " SELECT 
-                                   a.id as id, 
-                                   a.properties as properties, 
-                                   a.date as date, 
-                                   a.user_id as user_id,
-                                   a.blog_id as blog_id,
-                                   a.status as status,
-                                   a.num_reads as num_reads,
-                                   a.slug as slug,
-                                   t.article_id as article_id,
-                                   t.text as text
-                               FROM {$prefix}articles a, {$prefix}articles_text t, {$prefix}blogs b
-                               WHERE a.id = t.article_id 
-                                   AND a.status = ".POST_STATUS_PUBLISHED."
-							       AND TO_DAYS(NOW()) - TO_DAYS(date) < 7
-							       AND a.blog_id = b.id AND b.status = ".BLOG_STATUS_ACTIVE;
+             include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
 
+             $query = " SELECT 
+                 a.id as id, 
+                 a.properties as properties, 
+                 a.date as date, 
+                 a.user_id as user_id,
+                 a.blog_id as blog_id,
+                 a.status as status,
+                 a.num_reads as num_reads,
+                 a.slug as slug,
+                 t.article_id as article_id,
+                 t.text as text,
+                 t.topic as topic,
+                 t.normalized_text as normalized_text,
+                 t.normalized_topic as normalized_topic,
+                 t.mangled_topic as mangled_topic
+                 FROM ".$this->getPrefix()."articles a, ".$this->getPrefix()."articles_text t 
+                 WHERE a.id = t.article_id 
+                 AND status = ".POST_STATUS_PUBLISHED."
+                 AND TO_DAYS(NOW()) - TO_DAYS(date) < 7  ";
+
 			// ignore certain topics and/or certain texts
 			if( $ignoreTopic != "" )
 				$query .= " AND t.topic NOT LIKE '".Db::qstr( $ignoreTopic )."' ";
@@ -123,7 +128,7 @@
             if( $maxPosts > 0 )
             	$query .= " LIMIT 0,".$maxPosts;
 
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
 
             if( !$result )
             	return Array();
@@ -153,7 +158,7 @@
             if( $maxBlogs > 0 )
             	$query .= " LIMIT 0,".$maxBlogs;
 
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
 
             if( !$result ){
             	return Array();
@@ -188,7 +193,7 @@
             if( $maxBlogs > 0 )
                 $query .= " LIMIT 0,".$maxBlogs;
 
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
 
             if( !$result ){
                 return Array();
@@ -212,6 +217,7 @@
           */
          function getAllUsersPaged( $page, $itemsPerPage )
          {
+            include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
 			// calculate the limits...
 			if( $page > 0 ) {
 				$start = (($page - 1) * $itemsPerPage);
@@ -253,6 +259,11 @@
          */
         function getRecentArticles( $maxPosts, $ignoreTopic = "", $ignoreText = "" )
         {
+            include_once( PLOG_CLASS_PATH . "class/data/timestamp.class.php" );
+            include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+
+            $t      = new Timestamp();
+            $date   = $t->getTimestamp();
 			$prefix = $this->getPrefix();
 
 			$query = "SELECT a.id as id, a.id,t.topic,t.text,a.date,
@@ -284,7 +295,7 @@
 			}*/
 			$query .= " GROUP BY a.id ORDER BY a.date DESC LIMIT 0, $maxPosts";
 
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
 
             if( !$result )
                 return Array();
@@ -322,7 +333,7 @@
             if( $maxPosts > 0 )
                 $query .= " LIMIT 0,". ($maxPosts * 3);
 
-            $result = $this->_db->Execute( $query );
+            $result = $this->Execute( $query );
 
             if( !$result )
                 return false;

Modified: plog/trunk/class/summary/view/summarycachedview.class.php
===================================================================
--- plog/trunk/class/summary/view/summarycachedview.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/summary/view/summarycachedview.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,10 +1,6 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/view/view.class.php" );
-    include_once( PLOG_CLASS_PATH."class/template/templateservice.class.php" );
-	include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
-	include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
-	include_once( PLOG_CLASS_PATH."class/net/http/httpcache.class.php" );	
 
 	/**
 	 * This class should extended SmartyView but SmartyView was designed to work with BlogInfo
@@ -31,6 +27,8 @@
         
         function generateTemplate()
         {
+            include_once( PLOG_CLASS_PATH."class/template/templateservice.class.php" );
+
             $templateService = new TemplateService();
             $this->_template = $templateService->customTemplate( $this->_templateName, "summary", true );
         }
@@ -78,6 +76,11 @@
 		
 		function sendUncachedOutput()
 		{
+	        include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+	        include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
+
+		    $config =& Config::getConfig();
+			$this->_locale =& Locales::getLocale( $config->getValue("default_locale" ));
 			$this->_params->setValue( "version", new Version());
 			$this->_params->setValue( "locale", $this->_locale);
 			$this->_template->assign( $this->_params->getAsArray());
@@ -87,6 +90,9 @@
 
         function render()
         {
+	       include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+	       include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
+
 			// set the view character set based on the default locale
 			$this->_getLocale();
 			$this->setCharset( $this->_locale->getCharset());
@@ -96,6 +102,7 @@
 			// check if support for conditional HTTP requests is enabled
 			$config =& Config::getConfig();
 			if( $config->getValue( "template_http_cache_enabled" )) {
+	            include_once( PLOG_CLASS_PATH."class/net/http/httpcache.class.php" );	
 				// some debug information
 				$timestamp = $this->_template->getCreationTimestamp();
 				// and now send the correct headers
@@ -114,4 +121,4 @@
 			}
         }
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/template/template.class.php
===================================================================
--- plog/trunk/class/template/template.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/template/template.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -18,7 +18,6 @@
 
     include_once( PLOG_CLASS_PATH.'class/template/smarty/Smarty.class.php' );
     include_once( PLOG_CLASS_PATH.'class/config/config.class.php' );
-	include_once( PLOG_CLASS_PATH.'class/logger/loggermanager.class.php' );
 
     /**
      * \ingroup Template
@@ -40,10 +39,10 @@
     class Template extends Smarty 
     {
 
-        var $_templateFile;
+        var $_templateFile = null;
         
         // logger object
-        var $log;
+        var $log = null;
 
         /**
          * Constructor. 
@@ -53,7 +52,9 @@
         function Template( $templateFile )
         {
             // initialize logging
-            $this->log =& LoggerManager::getLogger( "default" );
+            // :TODO: we need define a global logging switch like logging_enabled
+	        // include_once( PLOG_CLASS_PATH.'class/logger/loggermanager.class.php' );
+            // $this->log =& LoggerManager::getLogger( "default" );
 
             // create the Smarty object and set the security values
             $this->Smarty();
@@ -74,7 +75,7 @@
             	
             $this->security = (boolean)!$config->getValue( 'allow_php_code_in_templates', false );
             //$this->security = true;
-			$this->secure_dir = Array( "./templates/admin", "./templates/" );
+			$this->secure_dir = Array( './templates/admin', './templates/' );
 
             // default folders
             $this->compile_dir  = $config->getValue( 'temp_folder' );

Modified: plog/trunk/class/template/templateservice.class.php
===================================================================
--- plog/trunk/class/template/templateservice.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/template/templateservice.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,14 +1,9 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH.'class/object/object.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/template/template.class.php' );
     include_once( PLOG_CLASS_PATH.'class/config/config.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/blogsettings.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/blogs.class.php' );
     include_once( PLOG_CLASS_PATH.'class/misc/glob.class.php' );
     include_once( PLOG_CLASS_PATH.'class/file/file.class.php' );
-	include_once( PLOG_CLASS_PATH.'class/template/cachedtemplate.class.php' );
-	include_once( PLOG_CLASS_PATH.'class/template/templatesets/templatesetstorage.class.php' );
 	
 	/**
 	 * default permissions used to create temporary template folders. Seems like
@@ -72,6 +67,8 @@
          */
         function Template( $templateName, $layout, $blogInfo = null )
         {
+            include_once( PLOG_CLASS_PATH . 'class/template/template.class.php' );
+
 			// get some information about the folder where the template is and the template file
 			$templateInfo = $this->_getTemplateFileInfo( $templateName, $layout, $blogInfo );
 			$templateFileName = $templateInfo['templateFileName'];
@@ -106,6 +103,8 @@
 		 */
 		function customTemplate( $templateName, $layout, $cached = false )
 		{
+	        include_once( PLOG_CLASS_PATH.'class/template/cachedtemplate.class.php' );
+
 			// get a nice Template object
 			$config =& Config::getConfig();
 			if( $cached )
@@ -141,6 +140,8 @@
 		 */
 		function AdminTemplate( $templateName, $blogInfo = null ) 
 		{
+	        include_once( PLOG_CLASS_PATH.'class/template/templatesets/templatesetstorage.class.php' );
+
 			$t = $this->Template( $templateName, 'admin', $blogInfo );
 			$t->assign( 'admintemplatepath', TemplateSetStorage::getAdminTemplateFolder());
 			
@@ -163,6 +164,8 @@
 		 */
         function CachedTemplate( $templateName, $layout, $blogInfo = null )
         {
+	        include_once( PLOG_CLASS_PATH.'class/template/cachedtemplate.class.php' );
+
 			// get some information about the folder where the template is and the template file		
 			$templateInfo = $this->_getTemplateFileInfo( $templateName, $layout, $blogInfo );
 			$templateFileName = $templateInfo['templateFileName'];
@@ -189,6 +192,8 @@
 		 */
 		function _getTemplateFileInfo( $templateName, $layout, $blogInfo ) 
 		{
+	        include_once( PLOG_CLASS_PATH.'class/template/templatesets/templatesetstorage.class.php' );
+
             // build the file name
             if( $blogInfo == null ) {
             	$templateFileName = $layout.'/'.$templateName.'.template';
@@ -234,6 +239,8 @@
 		 */
 		function PluginTemplate( $pluginId, $templateName, $blogInfo = null )
 		{
+            require_once( PLOG_CLASS_PATH . 'class/template/templatesets/templatesetstorage.class.php' );
+
 			// define the template file name
 			$templateFolder = TemplateSetStorage::getPluginTemplateFolder( $pluginId );
 			$templateFileName = $templateFolder.$templateName.'.template';
@@ -263,6 +270,8 @@
 		 */
 		function PluginCachedTemplate( $pluginId, $templateName, $blogInfo = null )
 		{
+	        include_once( PLOG_CLASS_PATH.'class/template/cachedtemplate.class.php' );
+
 			// define the template file name
 			$templateFolder = TemplateSetStorage::getPluginTemplateFolder( $pluginId );
 			$templateFileName = $templateFolder.$templateName.'.template';
@@ -305,4 +314,4 @@
 			return $t;
 		}
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/template/templatesets/templatesetstorage.class.php
===================================================================
--- plog/trunk/class/template/templatesets/templatesetstorage.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/template/templatesets/templatesetstorage.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -424,4 +424,4 @@
 			return $url;
 		}
 	}
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/view/admin/adminarticletrackbackslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminarticletrackbackslistview.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/view/admin/adminarticletrackbackslistview.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -57,7 +57,7 @@
 			$this->notifyEvent( EVENT_TRACKBACKS_LOADED, Array( "trackbacks" => &$postTrackbacks ));
 			$this->setValue( "trackbacks", $postTrackbacks);
 			// and the total number of trackbacks
-			$numTrackbacks = $trackbacks->getNumTrackbacksArticle( $this->_article->getId(), $this->_tbStatus );
+			$numTrackbacks = count( $postTrackbacks );
 			
 			// create and export the pager to the view
 			if( $this->_tbStatus == COMMENT_STATUS_ALL )
@@ -80,4 +80,4 @@
 			parent::render();
 		}
 	}
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/view/admin/admindashboardview.class.php
===================================================================
--- plog/trunk/class/view/admin/admindashboardview.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/view/admin/admindashboardview.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -6,7 +6,7 @@
 	include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
 	include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
 	include_once( PLOG_CLASS_PATH."class/dao/trackbacks.class.php" );
-	include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
+//	include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
 	
 	/**
 	 * maximum number of recent items that we will show in the statistics
@@ -55,7 +55,7 @@
 			$articles = new Articles();
 			$comments = new ArticleComments();
 			$trackbacks = new Trackbacks();
-			$resources = new GalleryResources();
+//			$resources = new GalleryResources();
 			$recentPosts = Array();
 			$recentComments = Array();
 			$recentResources = Array();

Modified: plog/trunk/class/view/admin/admindefaultview.class.php
===================================================================
--- plog/trunk/class/view/admin/admindefaultview.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/view/admin/admindefaultview.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -9,6 +9,7 @@
     include_once( PLOG_CLASS_PATH."class/template/templateservice.class.php" );
     include_once( PLOG_CLASS_PATH."class/template/template.class.php" );
 	include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
+	include_once( PLOG_CLASS_PATH."class/misc/version.class.php" );
 
     // name of the template we are going to use for this view
     define( "DEFAULTADMIN_TEMPLATE", "default" );

Modified: plog/trunk/class/view/admin/adminnewpostview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminnewpostview.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/view/admin/adminnewpostview.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,69 +1,71 @@
-<?php
-
-	include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
-	include_once( PLOG_CLASS_PATH."class/config/config.class.php" );	
-	
+<?php
+
+    include_once( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
+    include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+    
     /**
      * \ingroup View
      * @private
-     */	
-	class AdminNewPostView extends AdminTemplatedView
-	{
-	
-		function AdminNewPostView( $blogInfo )
-		{
-			$this->AdminTemplatedView( $blogInfo, "newpost" );
-		}
-		
-		function render()
-		{
-           // fetch the categories
-            $categories = new ArticleCategories();
-			$blogSettings = $this->_blogInfo->getSettings();
-			$categoriesOrder = $blogSettings->getValue( "categories_order" );
-            $blogCategories = $categories->getBlogCategories( $this->_blogInfo->getId(), false, $categoriesOrder );
-
-            // get some stuff for the time stamp of the post, which is changeable now
-            //$t = new Timestamp();
-            $t = Timestamp::getBlogDate( $this->_blogInfo );
-            //$t->toUTC();
-            //
-            // changes to make plog store its dates with the time difference already
-            // applied, instead of applying it dynamically
-            //
-            $config =& Config::getConfig();
-            /*if( $config->getValue( "time_difference_calculation" == TIME_DIFFERENCE_CALCULATION_STATIC ) {
-				$blogSettings = $this->_blogInfo->getSettings();
-				$difference = $blogSettings->getValue( "time_offset" );
-            	$t->setDate( Timestamp::getDateWithOffset( $t->getDate(), $difference ), DATE_FORMAT_TIMESTAMP );
-        	}*/
-            				
-			// fetch the custom fields, if any, but not including the ones that have been set to "hidden"...
-			$customFields = new CustomFields();
-			$blogFields   = $customFields->getBlogCustomFields( $this->_blogInfo->getId(), false);
-
-            // and put everything in the template
-        	$locale = $this->_blogInfo->getLocale();            
-            $this->setValue( "commentsEnabled", $blogSettings->getValue( "comments_enabled" ));
-            $this->setValue( "categories", $blogCategories );
-            $this->setValue( "today", $t );
-            $this->setValue( "months", $locale->getMonthNames());
-            $this->setValue( "days", $locale->getDayNamesShort());
-            $this->setValue( "years", Timestamp::getYears());
-            $this->setValue( "hours", Timestamp::getAllHours());
-            $this->setValue( "minutes", Timestamp::getAllMinutes());
-			$this->setValue( "customfields", $blogFields );
-			$this->setValue( "poststatus", ArticleStatus::getStatusList());
-			$this->setValue( "sendPings", $config->getValue( "send_xmlrpc_pings_enabled_by_default", true ));
-			$this->setValue( "xmlRpcPingEnabled", $config->getValue( "xmlrpc_ping_enabled", false ));
-			$this->setValue( "autoSaveNewDraftsTimeMillis", $config->getValue( "autosave_new_drafts_time_millis" ));
-			$this->setValue( "xmlHttpRequestSupportEnabled", $config->getValue( "save_drafts_via_xmlhttprequest_enabled" ));
-			$this->setValue( "postDateTime", $t->getDay()."/".$t->getMonth()."/".$t->getYear()." ".$t->getHour().":".$t->getMinutes());						
-			
-			parent::render();
-		}
-	}
-?>
\ No newline at end of file
+     */    
+    class AdminNewPostView extends AdminTemplatedView
+    {
+    
+        function AdminNewPostView( $blogInfo )
+        {
+            $this->AdminTemplatedView( $blogInfo, "newpost" );
+        }
+
+        function render()
+        {
+            require_once( PLOG_CLASS_PATH."class/dao/articlestatus.class.php" );
+
+            // fetch the categories
+            $categories = new ArticleCategories();
+            $blogSettings = $this->_blogInfo->getSettings();
+            $categoriesOrder = $blogSettings->getValue( "categories_order" );
+            $blogCategories = $categories->getBlogCategories( $this->_blogInfo->getId(), false, $categoriesOrder );
+
+            // get some stuff for the time stamp of the post, which is changeable now
+            //$t = new Timestamp();
+            $t = Timestamp::getBlogDate( $this->_blogInfo );
+            //$t->toUTC();
+            //
+            // changes to make plog store its dates with the time difference already
+            // applied, instead of applying it dynamically
+            //
+            $config =& Config::getConfig();
+            /*if( $config->getValue( "time_difference_calculation" == TIME_DIFFERENCE_CALCULATION_STATIC ) {
+                $blogSettings = $this->_blogInfo->getSettings();
+                $difference = $blogSettings->getValue( "time_offset" );
+                $t->setDate( Timestamp::getDateWithOffset( $t->getDate(), $difference ), DATE_FORMAT_TIMESTAMP );
+            }*/
+
+            // fetch the custom fields, if any, but not including the ones that have been set to "hidden"...
+            $customFields = new CustomFields();
+            $blogFields   = $customFields->getBlogCustomFields( $this->_blogInfo->getId(), false);
+
+            // and put everything in the template
+            $locale = $this->_blogInfo->getLocale();
+            $this->setValue( "commentsEnabled", $blogSettings->getValue( "comments_enabled" ));
+            $this->setValue( "categories", $blogCategories );
+            $this->setValue( "today", $t );
+            $this->setValue( "months", $locale->getMonthNames());
+            $this->setValue( "days", $locale->getDayNamesShort());
+            $this->setValue( "years", Timestamp::getYears());
+            $this->setValue( "hours", Timestamp::getAllHours());
+            $this->setValue( "minutes", Timestamp::getAllMinutes());
+            $this->setValue( "customfields", $blogFields );
+            $this->setValue( "poststatus", ArticleStatus::getStatusList());
+            $this->setValue( "sendPings", $config->getValue( "send_xmlrpc_pings_enabled_by_default", true ));
+            $this->setValue( "xmlRpcPingEnabled", $config->getValue( "xmlrpc_ping_enabled", false ));
+            $this->setValue( "autoSaveNewDraftsTimeMillis", $config->getValue( "autosave_new_drafts_time_millis" ));
+            $this->setValue( "xmlHttpRequestSupportEnabled", $config->getValue( "save_drafts_via_xmlhttprequest_enabled" ));
+            $this->setValue( "postDateTime", $t->getDay()."/".$t->getMonth()."/".$t->getYear()." ".$t->getHour().":".$t->getMinutes());    
+
+            parent::render();
+        }
+    }
+?>

Modified: plog/trunk/class/view/admin/adminpostslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminpostslistview.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/view/admin/adminpostslistview.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -6,6 +6,7 @@
     include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/articlestatus.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/pager/pager.class.php" );
+    include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
 	
     /**
      * \ingroup View
@@ -202,4 +203,4 @@
 			parent::render();
 		}
 	}
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/view/blogview.class.php
===================================================================
--- plog/trunk/class/view/blogview.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/view/blogview.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,17 +1,7 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH.'class/view/smartyview.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/bloginfo.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/data/plogcalendar.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/articles.class.php' );
-	include_once( PLOG_CLASS_PATH.'class/dao/archivelink.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/articles.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/mylinks.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/misc/version.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/dao/mylinkscategories.class.php' ); 
     include_once( PLOG_CLASS_PATH.'class/plugin/pluginmanager.class.php' );
-    include_once( PLOG_CLASS_PATH.'class/xml/rssparser/rssparser.class.php' );    
     
     /**
      * default date format used for the archive links
@@ -35,6 +25,8 @@
 		 */
 		function BlogView( $blogInfo, $template, $cachingEnabled = SMARTY_VIEW_CACHE_CHECK, $data = Array())
         {
+            include_once( PLOG_CLASS_PATH.'class/dao/articles.class.php' );
+
 			// the SmartyView will generate the right Template object for us
         	$this->SmartyView( $blogInfo, $template, $cachingEnabled, $data );
 			
@@ -57,6 +49,8 @@
          */
         function generateCalendar( $year = null, $month = null )
         {
+            include_once( PLOG_CLASS_PATH.'class/data/plogcalendar.class.php' );
+
 			$monthPosts = $this->getValue( 'monthposts' );
             $locale     = $this->_blogInfo->getLocale();
 
@@ -84,7 +78,10 @@
          * @private
          */
         function _getArchives()
-        {
+        { 
+	        include_once( PLOG_CLASS_PATH.'class/dao/archivelink.class.php' );
+            include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
+
             $archiveStats = $this->articles->getNumberPostsPerMonth( $this->_blogInfo->getId());
 
             if( $archiveStats == '' )
@@ -123,6 +120,8 @@
          */
         function _getRecentPosts()
         {
+            include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
+
             $blogSettings = $this->_blogInfo->getSettings();
 
             $t = new Timestamp();
@@ -142,6 +141,8 @@
          */
         function _getMonthPosts()
         {
+            include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
+
         	$t = new Timestamp();
             $blogSettings = $this->_blogInfo->getSettings();
             // the values for the month and the year have been included in the session
@@ -158,6 +159,8 @@
          */
         function _getLinkCategories()
         {
+            include_once( PLOG_CLASS_PATH.'class/dao/mylinkscategories.class.php' ); 
+
 			$blogSettings = $this->_blogInfo->getSettings();
 			$linkCategoriesOrder = $blogSettings->getValue( 'link_categories_order', MYLINKS_CATEGORIES_NO_ORDER );		
             $myLinksCategories = new MyLinksCategories();
@@ -174,6 +177,8 @@
          */
         function _getArticleCategories()
         {
+            require_once( PLOG_CLASS_PATH.'class/dao/articlecategories.class.php' ); 
+
 			$blogSettings = $this->_blogInfo->getSettings();
 			$categoryOrder = $blogSettings->getValue( 'categories_order' );
         	$categories = new ArticleCategories();
@@ -191,7 +196,12 @@
 		 */
 		function render()
 		{		
-			if( !$this->isCached()) {
+            include_once( PLOG_CLASS_PATH.'class/misc/version.class.php' );
+            include_once( PLOG_CLASS_PATH.'class/xml/rssparser/rssparser.class.php' );    
+
+			if( !$this->isCached() ) {
+                include_once( PLOG_CLASS_PATH.'class/data/plogcalendar.class.php' );
+
 				// and then add our stuff to the view...
 				$this->setValue( 'archives', $this->_getArchives());
 				$this->setValue( 'recentposts', $this->_getRecentPosts());
@@ -199,6 +209,9 @@
 				$this->setValue( 'monthposts', $this->_getMonthPosts());
 				$this->setValue( 'articlecategories', $this->_getArticleCategories());
 				$this->generateCalendar( $this->getValue( 'Year' ), $this->getValue( 'Month' ));
+
+                $this->setValue( 'url', $this->_blogInfo->getBlogRequestGenerator());
+                $this->setValue( 'utils', $this->_blogInfo->getBlogRequestGenerator());
 				
 				// also, let's not forget about the plugins...
 				// put the plugins in the context
@@ -211,12 +224,10 @@
 			//
 			// these things can go in since they do not mean much overhead when generating the view...
 			//
+
 			$this->setValue( 'locale', $this->_blogInfo->getLocale());			
 			$this->setValue( 'version', Version::getVersion());
-			$this->setValue( 'now', new Timestamp());			
 			$this->setValue( 'blog', $this->_blogInfo );			
-			$this->setValue( 'url', $this->_blogInfo->getBlogRequestGenerator());
-			$this->setValue( 'utils', $this->_blogInfo->getBlogRequestGenerator());
 			$this->setValue( 'blogsettings', $this->_blogInfo->getSettings());
 			$this->setValue( 'rss', new RssParser());
 			
@@ -224,4 +235,4 @@
 			parent::render();
 		}
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/view/defaultview.class.php
===================================================================
--- plog/trunk/class/view/defaultview.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/view/defaultview.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,7 +1,6 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/view/blogview.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
 
 	define( "MAIN_TEMPLATE", "main" );
 
@@ -36,9 +35,10 @@
         	$posts = $this->_params->getValue( 'posts' );
             $locale = $this->_blogInfo->getLocale();
 
+            //include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
             //$textFilter = new TextFilter();
             $modifPosts = Array();
-            $rg = RequestGenerator::getRequestGenerator( $this->_blogInfo );
+            $rg = $this->_blogInfo->getBlogRequestGenerator();
             foreach( $posts as $post ) {
                 if( $post->hasExtendedText()) {				
                 	$result = $post->getIntroText();
@@ -82,4 +82,4 @@
             parent::render();
         }
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/view/errorview.class.php
===================================================================
--- plog/trunk/class/view/errorview.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/view/errorview.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,6 +1,7 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/view/blogview.class.php" );
+    include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
 
 	define( "ERROR_TEMPLATE", "error" );
 
@@ -42,8 +43,10 @@
         {
             if(!empty($this->_message))
 	            $this->setValue( "message", $this->_message );
+
+  			$this->setValue( 'now', new Timestamp());			
 	        
 			parent::render();
         }
     }
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/view/view.class.php
===================================================================
--- plog/trunk/class/view/view.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/view/view.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -17,8 +17,6 @@
 
 	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
     include_once( PLOG_CLASS_PATH."class/config/properties.class.php" );
-	include_once( PLOG_CLASS_PATH."class/net/http/phpsniff/phpSniff.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php");    	
 	
 	/**
 	 * constants that can be used for content types
@@ -281,6 +279,7 @@
 		 */
 		function getCurrentPageFromRequest()
 		{
+            include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php");    	
 			// get the value from the request
 			$page = HttpVars::getRequestValue( VIEW_DEFAULT_PAGE_PARAMETER );
 			// but first of all, validate it
@@ -302,6 +301,8 @@
          */
         function render()
         {
+	        include_once( PLOG_CLASS_PATH."class/net/http/phpsniff/phpSniff.class.php" );
+
             // send the headers we've been assigned if any, alognside the conten-type header
             foreach( $this->_headers as $header )
             header( $header );

Modified: plog/trunk/class/view/viewarticleview.class.php
===================================================================
--- plog/trunk/class/view/viewarticleview.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/view/viewarticleview.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -73,4 +73,4 @@
             parent::render();		
 		}
 	}
-?>
\ No newline at end of file
+?>

Modified: plog/trunk/class/xml/rssparser/rssparser.class.php
===================================================================
--- plog/trunk/class/xml/rssparser/rssparser.class.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/class/xml/rssparser/rssparser.class.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,12 +1,11 @@
 <?php
 
 	include_once( PLOG_CLASS_PATH."class/object/object.class.php" );
-	include_once( PLOG_CLASS_PATH."class/xml/rssparser/magpierss/rss_fetch.inc" );	
-	include_once( PLOG_CLASS_PATH."class/xml/rssparser/magpierss/rss_cache.inc" );
-	include_once( PLOG_CLASS_PATH."class/xml/rssparser/magpierss/rss_parse.inc" );
-	include_once( PLOG_CLASS_PATH."class/xml/rssparser/magpierss/rss_utils.inc" );
-	include_once( PLOG_CLASS_PATH."class/xml/rssparser/rsschannel.class.php" );
-	include_once( PLOG_CLASS_PATH."class/xml/rssparser/rssitem.class.php" );
+//  include_once( PLOG_CLASS_PATH."class/xml/rssparser/magpierss/rss_fetch.inc" );	
+//  include_once( PLOG_CLASS_PATH."class/xml/rssparser/magpierss/rss_cache.inc" );
+//  include_once( PLOG_CLASS_PATH."class/xml/rssparser/magpierss/rss_parse.inc" );
+//  include_once( PLOG_CLASS_PATH."class/xml/rssparser/magpierss/rss_utils.inc" );
+//  include_once( PLOG_CLASS_PATH."class/xml/rssparser/rssitem.class.php" );
 
     /**
      * \ingroup XML
@@ -64,6 +63,8 @@
          */
 		function parse( $rssFeed )
 		{
+	        include_once( PLOG_CLASS_PATH."class/xml/rssparser/rsschannel.class.php" );
+
 			$rss = fetch_rss( $rssFeed );
 
 			if( !$rss )

Modified: plog/trunk/config/config.properties.php
===================================================================
--- plog/trunk/config/config.properties.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/config/config.properties.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,10 +1,17 @@
-<?php
-#
-# database settings
-#
-
-$config["db_host"] = "";
-$config["db_username"] = "";
-$config["db_password"] = "";
-$config["db_database"] = "";
-$config["db_prefix"] = "";
\ No newline at end of file
+<?php
+#
+# database settings
+#
+$config["db_host"] = "localhost";
+$config["db_username"] = "root";
+$config["db_password"] = "oL24Bg93";
+$config["db_database"] = "pLog";
+#
+# the database prefix will be appended to the name of each database tables in case you want
+# to have more than one version of plog running at the same time, such as the stable and
+# unstable one for testing. Each one could use a different prefix and therefore they could
+# coexist in the same unique database. If you change this after the initial configuration done
+# with the installation wizard, please make sure that you also rename the tables.
+#
+$config["db_prefix"] = "plog_";
+?>
\ No newline at end of file

Copied: plog/trunk/generateData.php (from rev 2140, plog/branches/plog-1.1-ben/generateData.php)

Modified: plog/trunk/index.php
===================================================================
--- plog/trunk/index.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/index.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,6 +1,7 @@
 <?php
 
 //xdebug_start_profiling();
+//xdebug_start_trace('/tmp/trace');
 
     // please enable the line below if you are having memory problems
     //ini_set('memory_limit', "16M");
@@ -14,6 +15,7 @@
     include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
     include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
 
     // just to make php use &amp; as the separator when adding the PHPSESSID
     // variable to our requests
@@ -40,6 +42,9 @@
     $pluginManager =& PluginManager::getPluginManager();
     $pluginManager->loadPlugins();
 
+	// initialize the session
+	SessionManager::init();
+	
     // give control to the, ehem, controller :)
     $controller->process( HttpVars::getRequest(), "op");
 

Modified: plog/trunk/templates/wizard/step1.template
===================================================================
--- plog/trunk/templates/wizard/step1.template	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/templates/wizard/step1.template	2005-05-31 19:17:49 UTC (rev 2141)
@@ -37,7 +37,7 @@
     <div class="field">
      <label for="dbPrefix">Database prefix</label>
      <div class="fieldHelp"></div>     
-     <span id="dbPrerix">{$dbPrefix}</span><br/>
+     <span id="dbPrefix">{$dbPrefix}</span><br/>
     </div>
     <div class="field">
      <label for="createDatabase">Create database</label>

Modified: plog/trunk/version.php
===================================================================
--- plog/trunk/version.php	2005-05-31 18:16:51 UTC (rev 2140)
+++ plog/trunk/version.php	2005-05-31 19:17:49 UTC (rev 2141)
@@ -1,3 +1,3 @@
 <?php
-$version = 'PLOG_1_0';
+$version = 'PLOG_1_1DEV';
 ?>




More information about the pLog-svn mailing list