mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Moved LegacyIDs from BlogEntry and File to Decorators
This commit is contained in:
parent
efbe5242ce
commit
0ba0c52553
@ -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"
|
||||||
|
@ -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;
|
||||||
|
$authorCheck = '';
|
||||||
|
|
||||||
|
$author = isset($_GET['author']) ? $_GET['author'] : '';
|
||||||
$blogName = $this->Name;
|
$blogName = $this->Name;
|
||||||
$altBlogName = $project . ' blog';
|
$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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user