mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Upgraded to work with silverstripe 4.x
This commit is contained in:
parent
b967860007
commit
2ae1457068
@ -27,7 +27,7 @@ class BlogEntry extends BlogPost implements MigratableObject
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canCreate($member = null)
|
||||
public function canCreate($member = null, $context = array())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class BlogHolder extends BlogTree implements MigratableObject
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canCreate($member = null)
|
||||
public function canCreate($member = null, $context = array())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class BlogTree extends Page implements MigratableObject
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canCreate($member = null)
|
||||
public function canCreate($member = null, $context = array())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class BlogFilter extends Lumberjack
|
||||
$staged = parent::stageChildren($showAll);
|
||||
|
||||
if (!$this->shouldFilter() && $this->subclassForBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||
$stage = Versioned::current_stage();
|
||||
$stage = Versioned::get_stage();
|
||||
|
||||
if ($stage == 'Stage') {
|
||||
$stage = '';
|
||||
|
@ -14,16 +14,19 @@ class BlogPostFilter extends DataExtension
|
||||
*
|
||||
* @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) {
|
||||
return;
|
||||
}
|
||||
|
||||
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 $parent
|
||||
*/
|
||||
public function augmentLoadLazyFields(SQLQuery &$query, &$dataQuery, $parent)
|
||||
{
|
||||
public function augmentLoadLazyFields(
|
||||
SQLSelect &$query,
|
||||
DataQuery &$dataQuery = null,
|
||||
$dataObject
|
||||
) {
|
||||
$dataQuery->innerJoin('BlogPost', '"SiteTree"."ID" = "BlogPost"."ID"');
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Model\FieldType\DBDatetime;
|
||||
|
||||
/**
|
||||
* Blog Holder
|
||||
*
|
||||
@ -1083,7 +1085,9 @@ class Blog_Controller extends Page_Controller
|
||||
$date = sprintf('%s-01-01', $year);
|
||||
}
|
||||
|
||||
return DBField::create_field('Date', $date);
|
||||
$obj = new DBDatetime('date');
|
||||
$obj->setValue($date);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -80,7 +80,7 @@ class BlogCategory extends DataObject implements CategorisationObject
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function validate()
|
||||
public function validate()
|
||||
{
|
||||
$validation = parent::validate();
|
||||
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.
|
||||
*
|
||||
* @param null|Member $member
|
||||
*
|
||||
* @return bool
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canCreate($member = null)
|
||||
public function canCreate($member = null, $context = array())
|
||||
{
|
||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||
|
||||
|
@ -218,7 +218,7 @@ class BlogPost extends Page
|
||||
'Authors',
|
||||
_t('BlogPost.Authors', 'Authors'),
|
||||
$self->getCandidateAuthors()->map()->toArray()
|
||||
)->setMultiple(true);
|
||||
);
|
||||
|
||||
$authorNames = TextField::create(
|
||||
'AuthorNames',
|
||||
|
@ -81,7 +81,7 @@ class BlogTag extends DataObject implements CategorisationObject
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function validate()
|
||||
public function validate()
|
||||
{
|
||||
$validation = parent::validate();
|
||||
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.
|
||||
*
|
||||
* @param null|Member $member
|
||||
*
|
||||
* @return bool
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canCreate($member = null)
|
||||
public function canCreate($member = null, $context = array())
|
||||
{
|
||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||
|
||||
|
@ -166,7 +166,7 @@ BlogPost:
|
||||
Authors: =>Member.BlogEditor,=>Member.Writer,=>Member.Contributor
|
||||
NullPublishDate:
|
||||
Title: 'No publish date'
|
||||
PublishDate: 'NULL'
|
||||
PublishDate: ''
|
||||
Parent: =>Blog.FourthBlog
|
||||
Authors: =>Member.BlogEditor,=>Member.Writer,=>Member.Contributor
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user