[pLog-svn] r3582 - in plog/trunk/class: action dao

oscar at devel.lifetype.net oscar at devel.lifetype.net
Thu Jun 15 21:47:35 GMT 2006


Author: oscar
Date: 2006-06-15 21:47:33 +0000 (Thu, 15 Jun 2006)
New Revision: 3582

Modified:
   plog/trunk/class/action/blogaction.class.php
   plog/trunk/class/dao/articlecategories.class.php
   plog/trunk/class/dao/articles.class.php
Log:
fixed an issue with dates being ignored

Modified: plog/trunk/class/action/blogaction.class.php
===================================================================
--- plog/trunk/class/action/blogaction.class.php	2006-06-14 18:20:41 UTC (rev 3581)
+++ plog/trunk/class/action/blogaction.class.php	2006-06-15 21:47:33 UTC (rev 3582)
@@ -309,41 +309,33 @@
             $blogSettings = $this->_blogInfo->getSettings();
             $serverTimeOffset = $blogSettings->getValue( "time_offset" );
             
-            if( $serverTimeOffset == 0)
-            {
-            	$maxDate = -1;
-            	$outDate = $inDate;
-            }
-            else
-            {
-	            if( strlen($inDate) == 4 ) 
-	        	{
-	        		$year = $inDate;
-	        		$outDate = Timestamp::getDateWithOffset( $year."0101000000", -$serverTimeOffset );
-	        		$maxDate = Timestamp::getDateWithOffset( $year."1231235959", -$serverTimeOffset );
-	        	} 
-	        	elseif ( strlen($inDate) == 6 )
-	        	{
-	                $year = substr( $inDate, 0, 4 );
-	                $month = substr( $inDate, 4, 2 );
-	                $dayOfMonth = Date_Calc::daysInMonth( $month, $year );
-	        		$outDate = Timestamp::getDateWithOffset( $year.$month."01000000", -$serverTimeOffset );
-	        		$maxDate = Timestamp::getDateWithOffset( $year.$month.$dayOfMonth."235959", -$serverTimeOffset );
-	        	}
-	        	elseif ( strlen($inDate) == 8 )
-	        	{
-	        		$year = substr( $inDate, 0, 4 );
-	                $month = substr( $inDate, 4, 2 );
-	                $day = substr( $inDate, 6, 2 );
-	        		$outDate  = Timestamp::getDateWithOffset( $year.$month.$day."000000", -$serverTimeOffset );
-	        		$maxDate = Timestamp::getDateWithOffset( $year.$month.$day."235959", -$serverTimeOffset );
-	        	}
-	        	else
-	        	{
-	        		$maxDate = -1;
-	        		$outDate = $inDate;
-	        	}
-            }
+            if( strlen($inDate) == 4 ) 
+        	{
+        		$year = $inDate;
+        		$outDate = Timestamp::getDateWithOffset( $year."0101000000", -$serverTimeOffset );
+        		$maxDate = Timestamp::getDateWithOffset( $year."1231235959", -$serverTimeOffset );
+        	} 
+        	elseif ( strlen($inDate) == 6 )
+        	{
+                $year = substr( $inDate, 0, 4 );
+                $month = substr( $inDate, 4, 2 );
+                $dayOfMonth = Date_Calc::daysInMonth( $month, $year );
+        		$outDate = Timestamp::getDateWithOffset( $year.$month."01000000", -$serverTimeOffset );
+        		$maxDate = Timestamp::getDateWithOffset( $year.$month.$dayOfMonth."235959", -$serverTimeOffset );
+        	}
+        	elseif ( strlen($inDate) == 8 )
+        	{
+        		$year = substr( $inDate, 0, 4 );
+                $month = substr( $inDate, 4, 2 );
+                $day = substr( $inDate, 6, 2 );
+        		$outDate  = Timestamp::getDateWithOffset( $year.$month.$day."000000", -$serverTimeOffset );
+        		$maxDate = Timestamp::getDateWithOffset( $year.$month.$day."235959", -$serverTimeOffset );
+        	}
+        	else
+        	{
+        		$maxDate = -1;
+        		$outDate = $inDate;
+        	}
             
             $result["inDate"] = $inDate;
             $result["maxDate"] = $maxDate;

Modified: plog/trunk/class/dao/articlecategories.class.php
===================================================================
--- plog/trunk/class/dao/articlecategories.class.php	2006-06-14 18:20:41 UTC (rev 3581)
+++ plog/trunk/class/dao/articlecategories.class.php	2006-06-15 21:47:33 UTC (rev 3582)
@@ -79,10 +79,12 @@
 				
 			// there might be more than one in several different blogs...
 			$found = false;
-			while( !$found ) {
-				$category = array_pop( $categories );
+			//while( !$found ) {
+			foreach( $categories as $category ) {
+				//$category = array_pop( $categories );
 				if( $blogId > -1 && $category->getBlogId() == $blogId ) {
 					$found = true;
+					break;
 				}
 			}
 			

Modified: plog/trunk/class/dao/articles.class.php
===================================================================
--- plog/trunk/class/dao/articles.class.php	2006-06-14 18:20:41 UTC (rev 3581)
+++ plog/trunk/class/dao/articles.class.php	2006-06-15 21:47:33 UTC (rev 3582)
@@ -93,7 +93,8 @@
                                                     Array( CACHE_ARTICLES => "getId" ));
 			$found = false;
 			if($articles){
-                foreach( $articles as $article ) {					
+                foreach( $articles as $article ) {
+					print("title = $articleTitle - date = $date - maxDate = $maxDate<br/>");
                     if( $article->getBlogId() == $blogId && $this->check( $article, $date, $categoryId,
                                       $status, $userId, $maxDate )) {
                         $found = true;
@@ -256,13 +257,15 @@
 					return false;
 			}
 			if( $date != -1 && $maxDate == 0 ) {
-				$postDate = substr($article->getTimestamp(),0,strlen($date));
+				$t = $article->getDateObject();
+				$postDate = substr($t->getTimestamp(),0,strlen($maxDate));
 				if( $postDate != $date ) {
 					return false;
 				}				
 			}
-			elseif( $maxDate > 0 && $date != -1 ) {
-				$postDate = substr($article->getTimestamp(),0,strlen($maxDate));
+			elseif( $maxDate > 0 && $date != -1 ) {	
+				$t = $article->getDateObject();
+				$postDate = substr($t->getTimestamp(),0,strlen($maxDate));
                 // we need to check both ends of the range
 				if( $postDate >= $maxDate || $postDate <= $date) {
 					return false;					



More information about the pLog-svn mailing list