[php-blog-cvs] serendipity serendipity_functions.inc.php,1.219,1.220
A reliable, secure & extensible PHP blog | Not mainstream since 2002
Brought to you by:
garvinhicking,
jhermanns
From: <tom...@us...> - 2004-02-27 20:13:55
|
Update of /cvsroot/php-blog/serendipity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31225 Modified Files: serendipity_functions.inc.php Log Message: Forgot empty() returned true if the input was "0" Took a pen and paper and did some math on this, the new method should seem more logic Index: serendipity_functions.inc.php =================================================================== RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v retrieving revision 1.219 retrieving revision 1.220 diff -u -d -r1.219 -r1.220 --- serendipity_functions.inc.php 27 Feb 2004 19:25:55 -0000 1.219 +++ serendipity_functions.inc.php 27 Feb 2004 20:04:59 -0000 1.220 @@ -301,11 +301,13 @@ function serendipity_drawCalendar($month, $year, $bow=1) { global $serendipity; - if (empty($bow)) { + // Check for faulty input, is so - run the default + if (!is_numeric($bow) || (int)$bow>6) { $bow = 1; } - + $bow = (int)$bow; + // Catch faulty month if ($month<1) { $month = 1; @@ -317,15 +319,16 @@ $nrOfDays = date('t', $ts); $firstDayWeekDay = date('w', $ts); - // Hack out if firstday is sunday, then we move it to the last day of the week + // Hack if the selected first day is sunday, then we move it to the last day of the week if ( $firstDayWeekDay == 0 ) { $firstDayWeekDay = 6; } - - if ( $bow >= $firstDayWeekDay+1 ) { - $firstDayWeekDay += ($bow*2)+1; + + // Calculate the first day of the week, based on the beginning of the week ($bow) + if ( $bow > $firstDayWeekDay ) { + $firstDayWeekDay = $firstDayWeekDay+7-$bow; } else { - $firstDayWeekDay -= ($bow); + $firstDayWeekDay = $firstDayWeekDay-$bow; } // Calculate the number of next/previous month @@ -417,7 +420,7 @@ <tr> <?php for ( $i = 1; $i <= 7; $i++ ) { - $date = mktime(0,0,0,3,$i+$bow-1,2004); + $date = mktime(0,0,0,3,$bow+$i-1,2004); ?> <td class="serendipity_weekDayName" align="center"><?php echo substr(strftime("%a", $date),0,2); ?></td> <?php |