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();
foreach($sqlResults as $sqlResult) {
$date = new Date('Date');
$month = ($this->DisplayMode == 'month') ? (int)$sqlResult['Month'] : 1;
if($sqlResults) foreach($sqlResults as $sqlResult) {
$isMonthDisplay = $this->DisplayMode == 'month';
$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,
'Month' => $month,
'Year' => (int) $sqlResult['Year']
'Month' => $month,
'Year' => $year
));
if($this->DisplayMode == 'month') {
$link = $container->Link() . $sqlResult['Year']. '/' . sprintf("%'02d", $sqlResult['Month']);
if($isMonthDisplay) {
$link = $container->Link() . $sqlResult['Year']. '/' . sprintf("%'02d", $monthVal);
} else {
$link = $container->Link() . $sqlResult['Year'];
}
@ -111,5 +112,5 @@ class ArchiveWidget extends Widget {
return $results;
}
}
?>
}