mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 09:05:58 +00:00
APICHANGE: removed BlogTree_URL class and its little static children. Changed to SelectedTag and SelectedDate to allow to be called in the template. SelectedDate now also returns a Date object rather than a string. BUGFIX: fixed missing Viewing posts by date text and added a viewing by post date text.
This commit is contained in:
parent
3864a78ab5
commit
b066dce821
@ -203,29 +203,8 @@ class BlogTree extends Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BlogTree_URL {
|
|
||||||
static function tag() {
|
|
||||||
if (Director::urlParam('Action') == 'tag') return Director::urlParam('ID');
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
static function date() {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class BlogTree_Controller extends Page_Controller {
|
class BlogTree_Controller extends Page_Controller {
|
||||||
|
|
||||||
static $allowed_actions = array(
|
static $allowed_actions = array(
|
||||||
'index',
|
'index',
|
||||||
'rss',
|
'rss',
|
||||||
@ -250,11 +229,16 @@ class BlogTree_Controller extends Page_Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
|
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
|
||||||
return $this->Entries("$start,$limit", BlogTree_URL::tag(), BlogTree_URL::date(), null, $filter);
|
|
||||||
|
$date = $this->SelectedDate();
|
||||||
|
|
||||||
|
return $this->Entries("$start,$limit", $this->SelectedTag(), ($date) ? $date->Format('Y-m') : '', null, $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will create a <link> tag point to the RSS feed
|
||||||
|
*/
|
||||||
function IncludeBlogRSS() {
|
function IncludeBlogRSS() {
|
||||||
// This will create a <link> tag point to the RSS feed
|
|
||||||
RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
|
RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,12 +259,42 @@ class BlogTree_Controller extends Page_Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Protection against infinite loops when an RSS widget pointing to this page is added to this page
|
||||||
|
*/
|
||||||
function defaultAction($action) {
|
function defaultAction($action) {
|
||||||
// Protection against infinite loops when an RSS widget pointing to this page is added to this page
|
|
||||||
if(stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) return $this->rss();
|
if(stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) return $this->rss();
|
||||||
|
|
||||||
return parent::defaultAction($action);
|
return parent::defaultAction($action);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
/**
|
||||||
|
* Return the currently viewing tag used in the template as $Tag
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
function SelectedTag() {
|
||||||
|
return (Director::urlParam('Action') == 'tag') ? Director::urlParam('ID') : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the selected date from the blog tree
|
||||||
|
*
|
||||||
|
* @return Date
|
||||||
|
*/
|
||||||
|
function SelectedDate() {
|
||||||
|
if(Director::urlParam('Action') == 'date') {
|
||||||
|
$year = Director::urlParam('ID');
|
||||||
|
$month = Director::urlParam('OtherID');
|
||||||
|
|
||||||
|
if(is_numeric($year) && is_numeric($month) && $month < 13) {
|
||||||
|
$date = new Date();
|
||||||
|
$date->setValue($year .'-'. $month);
|
||||||
|
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -4,8 +4,10 @@
|
|||||||
|
|
||||||
<% include BreadCrumbs %>
|
<% include BreadCrumbs %>
|
||||||
|
|
||||||
<% if Tag %>
|
<% if SelectedTag %>
|
||||||
<h3><% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$Tag'</h3>
|
<h3><% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'</h3>
|
||||||
|
<% else_if SelectedDate %>
|
||||||
|
<h3><% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedDate.Month $SelectedDate.Year</h3>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<% if BlogEntries %>
|
<% if BlogEntries %>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user