BUGFIX Fixed checking for correct day, month and year values before setting the Date value in ArchiveWidget

This commit is contained in:
Sean Harvey 2009-07-27 02:52:42 +00:00
parent 67d8a8b423
commit c438757b28
1 changed files with 13 additions and 12 deletions

View File

@ -85,20 +85,21 @@ class ArchiveWidget extends Widget {
} }
} }
if(!$sqlResults) return new DataObjectSet(); if($sqlResults) foreach($sqlResults as $sqlResult) {
$isMonthDisplay = $this->DisplayMode == 'month';
foreach($sqlResults as $sqlResult) {
$date = new Date('Date');
$month = ($this->DisplayMode == 'month') ? (int)$sqlResult['Month'] : 1;
$date->setValue(array( $monthVal = ($sqlResult['Month']) ? (int) $sqlResult['Month'] : 1;
$month = ($isMonthDisplay) ? $monthVal : 1;
$year = ($sqlResult['Year']) ? (int) $sqlResult['Year'] : date('Y');
$date = DBField::create('Date', array(
'Day' => 1, 'Day' => 1,
'Month' => $month, 'Month' => $month,
'Year' => (int) $sqlResult['Year'] 'Year' => $year
)); ));
if($this->DisplayMode == 'month') { if($isMonthDisplay) {
$link = $container->Link() . $sqlResult['Year']. '/' . sprintf("%'02d", $sqlResult['Month']); $link = $container->Link() . $sqlResult['Year']. '/' . sprintf("%'02d", $monthVal);
} else { } else {
$link = $container->Link() . $sqlResult['Year']; $link = $container->Link() . $sqlResult['Year'];
} }
@ -111,5 +112,5 @@ class ArchiveWidget extends Widget {
return $results; return $results;
} }
}
?> }