BUGFIX Fixed checking for correct day, month and year values before setting the Date value in ArchiveWidget
This commit is contained in:
parent
67d8a8b423
commit
c438757b28
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
?>
|
}
|
Loading…
Reference in New Issue