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:
Will Rossiter 2010-05-16 02:38:19 +00:00
parent 3864a78ab5
commit b066dce821
2 changed files with 48 additions and 32 deletions

View File

@ -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 {
static $allowed_actions = array(
'index',
'rss',
@ -250,11 +229,16 @@ class BlogTree_Controller extends Page_Controller {
}
$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() {
// This will create a <link> tag point to the RSS feed
RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
}
@ -274,13 +258,43 @@ class BlogTree_Controller extends Page_Controller {
$rss->outputToBrowser();
}
}
/**
* Protection against infinite loops when an RSS widget pointing to this page is added to this page
*/
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();
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;
}
}

View File

@ -4,8 +4,10 @@
<% include BreadCrumbs %>
<% if Tag %>
<h3><% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$Tag'</h3>
<% if SelectedTag %>
<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 %>
<% if BlogEntries %>