mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 09:05:58 +00:00
ENHANCEMENT Use of themedCSS() in BlogEntry instead of relative paths to css files
MINOR Code cleanup on BlogEntry class
This commit is contained in:
parent
bf70b7e7bc
commit
475b41bbda
@ -41,8 +41,6 @@ class BlogEntry extends Page {
|
|||||||
"Versioned('Stage', 'Live')"
|
"Versioned('Stage', 'Live')"
|
||||||
);
|
);
|
||||||
|
|
||||||
static $allowed_children = "none";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is WYSIWYG editing allowed?
|
* Is WYSIWYG editing allowed?
|
||||||
* @var boolean
|
* @var boolean
|
||||||
@ -60,26 +58,28 @@ class BlogEntry extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* overload so that the default date is today.
|
* Overload so that the default date is today.
|
||||||
*/
|
*/
|
||||||
public function populateDefaults(){
|
public function populateDefaults(){
|
||||||
parent::populateDefaults();
|
parent::populateDefaults();
|
||||||
$this->Date = date("Y-m-d H:i:s",time());
|
|
||||||
|
$this->Date = date('Y-m-d H:i:s', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures the most recent article edited on the same day is shown first.
|
* Ensures the most recent article edited on the same day is shown first.
|
||||||
*/
|
*/
|
||||||
public function setDate($val){
|
public function setDate($val) {
|
||||||
$datepart = date("Y-m-d",strtotime($val));
|
$datepart = date('Y-m-d', strtotime($val));
|
||||||
$minutepart = date("H:i:s",time());
|
$minutepart = date('H:i:s', time());
|
||||||
$date = $datepart . " " . $minutepart;
|
$date = $datepart . " " . $minutepart;
|
||||||
return $this->setField("Date",$date);
|
|
||||||
|
return $this->setField('Date', $date);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
Requirements::javascript('blog/javascript/bbcodehelp.js');
|
Requirements::javascript('blog/javascript/bbcodehelp.js');
|
||||||
Requirements::css('blog/css/bbcodehelp.css');
|
Requirements::themedCSS('bbcodehelp');
|
||||||
|
|
||||||
$firstName = Member::currentUser() ? Member::currentUser()->FirstName : '';
|
$firstName = Member::currentUser() ? Member::currentUser()->FirstName : '';
|
||||||
$codeparser = new BBCodeParser();
|
$codeparser = new BBCodeParser();
|
||||||
@ -108,22 +108,23 @@ class BlogEntry extends Page {
|
|||||||
* Returns the tags added to this blog entry
|
* Returns the tags added to this blog entry
|
||||||
*/
|
*/
|
||||||
function TagsCollection() {
|
function TagsCollection() {
|
||||||
$theseTags = split(" *, *", trim($this->Tags));
|
$tags = split(" *, *", trim($this->Tags));
|
||||||
|
|
||||||
$output = new DataObjectSet();
|
$output = new DataObjectSet();
|
||||||
foreach($theseTags as $tag) {
|
|
||||||
|
foreach($tags as $tag) {
|
||||||
$output->push(new ArrayData(array(
|
$output->push(new ArrayData(array(
|
||||||
"Tag" => $tag,
|
'Tag' => $tag,
|
||||||
"Link" => $this->getParent()->Link() . 'tag/' . urlencode($tag)
|
'Link' => $this->getParent()->Link() . 'tag/' . urlencode($tag)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
if($this->Tags){
|
|
||||||
|
if($this->Tags) {
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the sidebar
|
* Get the sidebar from the BlogHolder.
|
||||||
*/
|
*/
|
||||||
function SideBar() {
|
function SideBar() {
|
||||||
return $this->getParent()->SideBar();
|
return $this->getParent()->SideBar();
|
||||||
@ -153,6 +154,7 @@ class BlogEntry extends Page {
|
|||||||
$parser = new BBCodeParser($this->Content);
|
$parser = new BBCodeParser($this->Content);
|
||||||
$content = new Text('Content');
|
$content = new Text('Content');
|
||||||
$content->value = $parser->parse();
|
$content->value = $parser->parse();
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +163,7 @@ class BlogEntry extends Page {
|
|||||||
* Link for editing this blog entry
|
* Link for editing this blog entry
|
||||||
*/
|
*/
|
||||||
function EditURL() {
|
function EditURL() {
|
||||||
return $this->getParent()->Link('post')."/".$this->ID."/";
|
return $this->getParent()->Link('post') . '/' . $this->ID . '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,9 +176,11 @@ class BlogEntry extends Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BlogEntry_Controller extends Page_Controller {
|
class BlogEntry_Controller extends Page_Controller {
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
parent::init();
|
parent::init();
|
||||||
Requirements::themedCSS("blog");
|
|
||||||
|
Requirements::themedCSS('blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user