Upgraded to work with silverstripe 4.x

This commit is contained in:
micmania1 2016-06-01 17:28:59 +12:00 committed by Robbie Averill
parent b967860007
commit 2ae1457068
10 changed files with 30 additions and 28 deletions

View File

@ -27,7 +27,7 @@ class BlogEntry extends BlogPost implements MigratableObject
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function canCreate($member = null) public function canCreate($member = null, $context = array())
{ {
return false; return false;
} }

View File

@ -28,7 +28,7 @@ class BlogHolder extends BlogTree implements MigratableObject
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function canCreate($member = null) public function canCreate($member = null, $context = array())
{ {
return false; return false;
} }
@ -64,7 +64,7 @@ class BlogHolder extends BlogTree implements MigratableObject
} else { } else {
$message = "DRAFT: "; $message = "DRAFT: ";
} }
return $message . $this->Title; return $message . $this->Title;
} }
} }

View File

@ -21,7 +21,7 @@ class BlogTree extends Page implements MigratableObject
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function canCreate($member = null) public function canCreate($member = null, $context = array())
{ {
return false; return false;
} }
@ -43,7 +43,7 @@ class BlogTree extends Page implements MigratableObject
} else { } else {
$message = "DRAFT: "; $message = "DRAFT: ";
} }
return $message . $this->Title; return $message . $this->Title;
} }
} }

View File

@ -17,7 +17,7 @@ class BlogFilter extends Lumberjack
$staged = parent::stageChildren($showAll); $staged = parent::stageChildren($showAll);
if (!$this->shouldFilter() && $this->subclassForBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) { if (!$this->shouldFilter() && $this->subclassForBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) {
$stage = Versioned::current_stage(); $stage = Versioned::get_stage();
if ($stage == 'Stage') { if ($stage == 'Stage') {
$stage = ''; $stage = '';

View File

@ -14,16 +14,19 @@ class BlogPostFilter extends DataExtension
* *
* @param SQLQuery $query * @param SQLQuery $query
*/ */
public function augmentSQL(SQLQuery &$query) public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
{ {
$stage = Versioned::current_stage(); $stage = Versioned::get_stage();
if (Controller::curr() instanceof LeftAndMain) { if (Controller::curr() instanceof LeftAndMain) {
return; return;
} }
if ($stage == 'Live' || !Permission::check('VIEW_DRAFT_CONTENT')) { if ($stage == 'Live' || !Permission::check('VIEW_DRAFT_CONTENT')) {
$query->addWhere(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(SS_Datetime::now()))); $query->addWhere(sprintf(
'"PublishDate" < \'%s\'',
Convert::raw2sql(SS_Datetime::now())
));
} }
} }
@ -38,8 +41,11 @@ class BlogPostFilter extends DataExtension
* @param mixed $dataQuery * @param mixed $dataQuery
* @param mixed $parent * @param mixed $parent
*/ */
public function augmentLoadLazyFields(SQLQuery &$query, &$dataQuery, $parent) public function augmentLoadLazyFields(
{ SQLSelect &$query,
DataQuery &$dataQuery = null,
$dataObject
) {
$dataQuery->innerJoin('BlogPost', '"SiteTree"."ID" = "BlogPost"."ID"'); $dataQuery->innerJoin('BlogPost', '"SiteTree"."ID" = "BlogPost"."ID"');
} }
} }

View File

@ -1,5 +1,7 @@
<?php <?php
use SilverStripe\Model\FieldType\DBDatetime;
/** /**
* Blog Holder * Blog Holder
* *
@ -1083,7 +1085,9 @@ class Blog_Controller extends Page_Controller
$date = sprintf('%s-01-01', $year); $date = sprintf('%s-01-01', $year);
} }
return DBField::create_field('Date', $date); $obj = new DBDatetime('date');
$obj->setValue($date);
return $obj;
} }
return null; return null;

View File

@ -80,7 +80,7 @@ class BlogCategory extends DataObject implements CategorisationObject
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function validate() public function validate()
{ {
$validation = parent::validate(); $validation = parent::validate();
if($validation->valid()) { if($validation->valid()) {
@ -131,13 +131,9 @@ class BlogCategory extends DataObject implements CategorisationObject
} }
/** /**
* Inherits from the parent blog or can be overwritten using a DataExtension. * {@inheritdoc}
*
* @param null|Member $member
*
* @return bool
*/ */
public function canCreate($member = null) public function canCreate($member = null, $context = array())
{ {
$extended = $this->extendedCan(__FUNCTION__, $member); $extended = $this->extendedCan(__FUNCTION__, $member);

View File

@ -218,7 +218,7 @@ class BlogPost extends Page
'Authors', 'Authors',
_t('BlogPost.Authors', 'Authors'), _t('BlogPost.Authors', 'Authors'),
$self->getCandidateAuthors()->map()->toArray() $self->getCandidateAuthors()->map()->toArray()
)->setMultiple(true); );
$authorNames = TextField::create( $authorNames = TextField::create(
'AuthorNames', 'AuthorNames',

View File

@ -81,7 +81,7 @@ class BlogTag extends DataObject implements CategorisationObject
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function validate() public function validate()
{ {
$validation = parent::validate(); $validation = parent::validate();
if($validation->valid()) { if($validation->valid()) {
@ -132,13 +132,9 @@ class BlogTag extends DataObject implements CategorisationObject
} }
/** /**
* Inherits from the parent blog or can be overwritten using a DataExtension. * {@inheritdoc}
*
* @param null|Member $member
*
* @return bool
*/ */
public function canCreate($member = null) public function canCreate($member = null, $context = array())
{ {
$extended = $this->extendedCan(__FUNCTION__, $member); $extended = $this->extendedCan(__FUNCTION__, $member);

View File

@ -166,7 +166,7 @@ BlogPost:
Authors: =>Member.BlogEditor,=>Member.Writer,=>Member.Contributor Authors: =>Member.BlogEditor,=>Member.Writer,=>Member.Contributor
NullPublishDate: NullPublishDate:
Title: 'No publish date' Title: 'No publish date'
PublishDate: 'NULL' PublishDate: ''
Parent: =>Blog.FourthBlog Parent: =>Blog.FourthBlog
Authors: =>Member.BlogEditor,=>Member.Writer,=>Member.Contributor Authors: =>Member.BlogEditor,=>Member.Writer,=>Member.Contributor