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}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function canCreate($member = null)
|
public function canCreate($member = null, $context = array())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 = '';
|
||||||
|
@ -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"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -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',
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user