[pLog-CVS] plog/class/action admineditpostsaction.class.php,1.3.6.2,1.3.6.3
Brought to you by:
jondaley
From: Oscar R. <phu...@us...> - 2004-06-08 18:32:53
|
Update of /cvsroot/plog/plog/class/action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21707/action Modified Files: Tag: PLOG_0_3_2_DEVEL admineditpostsaction.class.php Log Message: fixed a couple more things Index: admineditpostsaction.class.php =================================================================== RCS file: /cvsroot/plog/plog/class/action/admineditpostsaction.class.php,v retrieving revision 1.3.6.2 retrieving revision 1.3.6.3 diff -C2 -d -r1.3.6.2 -r1.3.6.3 *** admineditpostsaction.class.php 27 May 2004 19:19:33 -0000 1.3.6.2 --- admineditpostsaction.class.php 8 Jun 2004 18:32:43 -0000 1.3.6.3 *************** *** 29,41 **** { $articles = new Articles(); ! $archiveStats = $articles->getNumberPostsPerMonth( $this->_blogInfo->getId()); ! if( !$archiveStats ) ! return Array(); $result = Array(); foreach( $archiveStats as $yearName => $year) { foreach( $year as $monthName => $month ) { // we can use the Timestamp class to help us with this... $t = new Timestamp( "" ); --- 29,67 ---- { $articles = new Articles(); ! $archiveStats = $articles->getNumberPostsPerMonthAdmin( $this->_blogInfo->getId()); ! if( !$archiveStats ) ! return Array(); $result = Array(); + + $t = new Timestamp(); + $curyear = (int)$t->getYear(); + $curmonth = (int)$t->getMonth(); foreach( $archiveStats as $yearName => $year) { foreach( $year as $monthName => $month ) { + // the next bit is so disgustingly ugly that I am ashamed of it... + // what I'm trying to do here is that the getNumberPostsPerMonthAdmin() method + // won't return the current month if there wasn't anything posted during it but + // we still should show the current month even if there's nothing in it, because otherwise + // when generating page where the posts are listed, it will end up saying "Date: All" + // but no posts at all shown (it didn't have anything to show) This is a way of + // "introducing" a month in the array without fucking it up. In fact, PHP *was* + // indeed fucking it up... it didn't just want to keep the order! Oh well, it's a very + // long and stupid story but we need this hack, ok? :) + if( $archiveStats[$curyear][$curmonth] == "" && !$alreadyAdded ) { + // there goes the dirty hack :P + if( $yearName == $curyear && $monthName < $curmonth ) { + $t = new Timestamp(); + $name = $this->_locale->formatDate( $t, "%B %Y" ); + $monthStr = Array( "name" => $name, + "date" => $this->_locale->formatDate($t, "%Y%m")); + array_push( $result, $monthStr ); + $alreadyAdded = true; + } + } + + // we can use the Timestamp class to help us with this... $t = new Timestamp( "" ); *************** *** 43,48 **** $t->setMonth( $monthName ); $name = $this->_locale->formatDate( $t, "%B %Y" ); ! $month = Array( "name" => $name, "date" => $this->_locale->formatDate($t, "%Y%m")); ! array_push( $result, $month ); } } --- 69,75 ---- $t->setMonth( $monthName ); $name = $this->_locale->formatDate( $t, "%B %Y" ); ! $monthStr = Array( "name" => $name, ! "date" => $this->_locale->formatDate($t, "%Y%m")); ! array_push( $result, $monthStr ); } } |