Use "date" for archives, using numbers directly causes too many problems

This commit is contained in:
Andrew O'Neil 2009-12-20 00:31:24 +00:00
parent e52171bf75
commit a7f024bc45
3 changed files with 14 additions and 22 deletions

View File

@ -135,6 +135,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
static $allowed_actions = array(
'index',
'tag',
'date',
'metaweblog',
'postblog' => 'BLOGMANAGEMENT',
'post' => 'BLOGMANAGEMENT',
@ -146,17 +147,6 @@ class BlogHolder_Controller extends BlogTree_Controller {
Requirements::themedCSS("bbcodehelp");
}
/**
* TODO: this is an urgent fix to work with archive link (e.g. page_url/2009/04). Replace this with something better.
*/
function checkAccessAction($action) {
if(preg_match('/[0-9]{4}/', $action)) {
return true;
}
return parent::checkAccessAction($action);
}
/**
* Return list of usable tags for help
*/

View File

@ -196,16 +196,18 @@ class BlogTree_URL {
}
static function date() {
$year = Director::urlParam('Action');
$month = Director::urlParam('ID');
if(Director::urlParam('Action') == 'date') {
$year = Director::urlParam('ID');
$month = Director::urlParam('OtherID');
if($month && is_numeric($month) && $month >= 1 && $month <= 12 && is_numeric($year)) {
return "$year-$month";
} elseif (is_numeric($year)) {
return $year;
if($month && is_numeric($month) && $month >= 1 && $month <= 12 && is_numeric($year)) {
return "$year-$month";
} elseif (is_numeric($year)) {
return $year;
}
return '';
}
return '';
}
}

View File

@ -81,9 +81,9 @@ class ArchiveWidget extends Widget {
));
if($isMonthDisplay) {
$link = $container->Link($sqlResult['Year']) . '/' . sprintf("%'02d", $monthVal);
$link = $container->Link('date') . '/' . $sqlResult['Year'] . '/' . sprintf("%'02d", $monthVal);
} else {
$link = $container->Link($sqlResult['Year']);
$link = $container->Link('date') . '/' . $sqlResult['Year'];
}
$results->push(new ArrayData(array(