Moved LegacyIDs from BlogEntry and File to Decorators

This commit is contained in:
Saophalkun Ponlu 2008-12-02 02:46:42 +00:00
parent efbe5242ce
commit 0ba0c52553
2 changed files with 26 additions and 9 deletions

View File

@ -16,7 +16,6 @@ class BlogEntry extends Page {
static $icon = "blog/images/blogpage"; static $icon = "blog/images/blogpage";
static $db = array( static $db = array(
"LegacyID" => "Varchar(5)", // used for blog migration only
"Date" => "SSDatetime", "Date" => "SSDatetime",
"Author" => "Text", "Author" => "Text",
"Tags" => "Text" "Tags" => "Text"

View File

@ -67,9 +67,10 @@ class BlogHolder extends Page {
* @param string date Only get blog entries on this date - either a year, or a year-month eg '2008' or '2008-02' * @param string date Only get blog entries on this date - either a year, or a year-month eg '2008' or '2008-02'
* @return DataObjectSet * @return DataObjectSet
*/ */
public function Entries($limit = '', $tag = '', $date = '') { public function Entries($limit = '', $tag = '', $date = '', $author = '') {
$tagCheck = ''; $tagCheck = '';
$dateCheck = ''; $dateCheck = '';
$authorCheck = '';
if($tag) { if($tag) {
$SQL_tag = Convert::raw2sql($tag); $SQL_tag = Convert::raw2sql($tag);
@ -92,7 +93,11 @@ class BlogHolder extends Page {
} }
} }
return DataObject::get("Page","`ParentID` = $this->ID AND ShowInMenus = 1 $tagCheck $dateCheck","`BlogEntry`.Date DESC",'',"$limit"); if($author) {
$authorCheck = "AND Author = '{$author}'";
}
return DataObject::get("Page","`ParentID` = $this->ID AND ShowInMenus = 1 $authorCheck $tagCheck $dateCheck","`BlogEntry`.Date DESC",'',"$limit");
} }
/** /**
@ -228,6 +233,7 @@ class BlogHolder_Controller extends Page_Controller {
} }
function BlogEntries($limit = 10) { function BlogEntries($limit = 10) {
$author = isset($_GET['author']) ? $_GET['author'] : '';
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0; $start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
$tag = ''; $tag = '';
$date = ''; $date = '';
@ -247,7 +253,7 @@ class BlogHolder_Controller extends Page_Controller {
} }
} }
return $this->Entries("$start,$limit", $tag, $date); return $this->Entries("$start,$limit", $tag, $date, $author);
} }
/** /**
@ -286,13 +292,25 @@ class BlogHolder_Controller extends Page_Controller {
*/ */
function rss() { function rss() {
global $project; global $project;
$limit=10;
$blogName = $this->Name; $authorCheck = '';
$altBlogName = $project . ' blog';
$author = isset($_GET['author']) ? $_GET['author'] : '';
$blogName = $this->Name;
$altBlogName = "$this->Title » SilverStripe.com";
if($author) {
$authorCheck = "AND Author = '{$author}'";
}
$children = DataObject::get("Page","`ParentID` = $this->ID AND ShowInMenus = 1 $authorCheck","`BlogEntry`.Date DESC",'', "$limit");
if($author AND $children) {
$altBlogName = ucwords($author) . "'s blog » SilverStripe.com";
}
$children = $this->Children();
$children->sort('Date', 'DESC');
$rss = new RSSFeed($children, $this->Link(), ($blogName ? $blogName : $altBlogName), "", "Title", "ParsedContent"); $rss = new RSSFeed($children, $this->Link(), ($blogName ? $blogName : $altBlogName), "", "Title", "ParsedContent");
$rss->outputToBrowser(); $rss->outputToBrowser();
} }