mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Use "date" for archives, using numbers directly causes too many problems
This commit is contained in:
parent
e52171bf75
commit
a7f024bc45
@ -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
|
||||
*/
|
||||
|
@ -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 '';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user