mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Fix some incorrect table/model namespace issues
This commit is contained in:
parent
13a5badff5
commit
72a9f041c2
@ -121,7 +121,7 @@ class BlogController extends Page_Controller
|
|||||||
/**
|
/**
|
||||||
* Renders an archive for a specified date. This can be by year or year/month.
|
* Renders an archive for a specified date. This can be by year or year/month.
|
||||||
*
|
*
|
||||||
* @return null|SS_HTTPResponse
|
* @return null|HTTPResponse
|
||||||
*/
|
*/
|
||||||
public function archive()
|
public function archive()
|
||||||
{
|
{
|
||||||
@ -256,7 +256,7 @@ class BlogController extends Page_Controller
|
|||||||
/**
|
/**
|
||||||
* Renders the blog posts for a given category.
|
* Renders the blog posts for a given category.
|
||||||
*
|
*
|
||||||
* @return null|SS_HTTPResponse
|
* @return null|HTTPResponse
|
||||||
*/
|
*/
|
||||||
public function category()
|
public function category()
|
||||||
{
|
{
|
||||||
|
@ -152,23 +152,38 @@ class Blog extends Page implements PermissionProvider
|
|||||||
'Categories',
|
'Categories',
|
||||||
_t('Blog.Categories', 'Categories'),
|
_t('Blog.Categories', 'Categories'),
|
||||||
$self->Categories(),
|
$self->Categories(),
|
||||||
GridFieldCategorisationConfig::create(15, $self->Categories()->sort('Title'), 'SilverStripe\\Blog\\Model\\BlogCategory', 'Categories', 'BlogPosts')
|
GridFieldCategorisationConfig::create(
|
||||||
|
15,
|
||||||
|
$self->Categories()->sort('Title'),
|
||||||
|
BlogCategory::class,
|
||||||
|
'Categories',
|
||||||
|
'BlogPosts'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$tags = GridField::create(
|
$tags = GridField::create(
|
||||||
'Tags',
|
'Tags',
|
||||||
_t('Blog.Tags', 'Tags'),
|
_t('Blog.Tags', 'Tags'),
|
||||||
$self->Tags(),
|
$self->Tags(),
|
||||||
GridFieldCategorisationConfig::create(15, $self->Tags()->sort('Title'), 'SilverStripe\\Blog\\Model\\BlogTag', 'Tags', 'BlogPosts')
|
GridFieldCategorisationConfig::create(
|
||||||
|
15,
|
||||||
|
$self->Tags()->sort('Title'),
|
||||||
|
BlogTag::class,
|
||||||
|
'Tags',
|
||||||
|
'BlogPosts'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FieldList $fields
|
* @var FieldList $fields
|
||||||
*/
|
*/
|
||||||
$fields->addFieldsToTab('Root.Categorisation', array(
|
$fields->addFieldsToTab(
|
||||||
|
'Root.Categorisation',
|
||||||
|
array(
|
||||||
$categories,
|
$categories,
|
||||||
$tags
|
$tags
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$fields->findOrMakeTab('Root.Categorisation')->addExtraClass('blog-cms-categorisation');
|
$fields->findOrMakeTab('Root.Categorisation')->addExtraClass('blog-cms-categorisation');
|
||||||
});
|
});
|
||||||
@ -258,7 +273,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
public function RoleOf($member)
|
public function RoleOf($member)
|
||||||
{
|
{
|
||||||
if (is_numeric($member)) {
|
if (is_numeric($member)) {
|
||||||
$member = DataObject::get_by_id('Member', $member);
|
$member = DataObject::get_by_id(Member::class, $member);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$member) {
|
if (!$member) {
|
||||||
@ -331,7 +346,8 @@ class Blog extends Page implements PermissionProvider
|
|||||||
{
|
{
|
||||||
$fields = parent::getSettingsFields();
|
$fields = parent::getSettingsFields();
|
||||||
|
|
||||||
$fields->addFieldToTab('Root.Settings',
|
$fields->addFieldToTab(
|
||||||
|
'Root.Settings',
|
||||||
NumericField::create('PostsPerPage', _t('Blog.PostsPerPage', 'Posts Per Page'))
|
NumericField::create('PostsPerPage', _t('Blog.PostsPerPage', 'Posts Per Page'))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -387,11 +403,14 @@ class Blog extends Page implements PermissionProvider
|
|||||||
$contributorField = $contributorField->performDisabledTransformation();
|
$contributorField = $contributorField->performDisabledTransformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Users', array(
|
$fields->addFieldsToTab(
|
||||||
|
'Root.Users',
|
||||||
|
array(
|
||||||
$editorField,
|
$editorField,
|
||||||
$writerField,
|
$writerField,
|
||||||
$contributorField
|
$contributorField
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
@ -501,7 +520,10 @@ class Blog extends Page implements PermissionProvider
|
|||||||
$stage = '_' . $stage;
|
$stage = '_' . $stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query->innerJoin('SilverStripe\\Blog\\Model\\BlogPost', sprintf('"SiteTree%s"."ID" = "BlogPost%s"."ID"', $stage, $stage));
|
$query->innerJoin(
|
||||||
|
DataObject::getSchema()->tableName(BlogPost::class),
|
||||||
|
sprintf('"SiteTree%s"."ID" = "BlogPost%s"."ID"', $stage, $stage)
|
||||||
|
);
|
||||||
|
|
||||||
$conn = DB::getConn();
|
$conn = DB::getConn();
|
||||||
|
|
||||||
@ -638,13 +660,13 @@ class Blog extends Page implements PermissionProvider
|
|||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
|
|
||||||
$group = new Group();
|
$group = Group::create();
|
||||||
$group->Title = 'Blog users';
|
$group->Title = 'Blog users';
|
||||||
$group->Code = $code;
|
$group->Code = $code;
|
||||||
|
|
||||||
$group->write();
|
$group->write();
|
||||||
|
|
||||||
$permission = new Permission();
|
$permission = Permission::create();
|
||||||
$permission->Code = $this->config()->grant_user_permission;
|
$permission->Code = $this->config()->grant_user_permission;
|
||||||
|
|
||||||
$group->Permissions()->add($permission);
|
$group->Permissions()->add($permission);
|
||||||
|
@ -11,6 +11,7 @@ use SilverStripe\Forms\FormTransformation;
|
|||||||
use SilverStripe\Forms\GridField\GridField;
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
use SilverStripe\Forms\Tab;
|
use SilverStripe\Forms\Tab;
|
||||||
use SilverStripe\Lumberjack\Model\Lumberjack;
|
use SilverStripe\Lumberjack\Model\Lumberjack;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\Versioning\Versioned;
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
use SilverStripe\Security\Permission;
|
use SilverStripe\Security\Permission;
|
||||||
@ -41,7 +42,10 @@ class BlogFilter extends Lumberjack
|
|||||||
}
|
}
|
||||||
|
|
||||||
$dataQuery = $staged->dataQuery()
|
$dataQuery = $staged->dataQuery()
|
||||||
->innerJoin('BlogPost', sprintf('"BlogPost%s"."ID" = "SiteTree%s"."ID"', $stage, $stage))
|
->innerJoin(
|
||||||
|
DataObject::getSchema()->tableName(BlogPost::class),
|
||||||
|
sprintf('"BlogPost%s"."ID" = "SiteTree%s"."ID"', $stage, $stage)
|
||||||
|
)
|
||||||
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
||||||
|
|
||||||
$staged = $staged->setDataQuery($dataQuery);
|
$staged = $staged->setDataQuery($dataQuery);
|
||||||
@ -55,7 +59,7 @@ class BlogFilter extends Lumberjack
|
|||||||
*/
|
*/
|
||||||
protected function subclassForBlog()
|
protected function subclassForBlog()
|
||||||
{
|
{
|
||||||
return in_array(get_class($this->owner), ClassInfo::subclassesFor('Blog'));
|
return in_array(get_class($this->owner), ClassInfo::subclassesFor(Blog::class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,7 +71,10 @@ class BlogFilter extends Lumberjack
|
|||||||
|
|
||||||
if (!$this->shouldFilter() && $this->isBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) {
|
if (!$this->shouldFilter() && $this->isBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||||
$dataQuery = $staged->dataQuery()
|
$dataQuery = $staged->dataQuery()
|
||||||
->innerJoin('BlogPost', '"BlogPost_Live"."ID" = "SiteTree_Live"."ID"')
|
->innerJoin(
|
||||||
|
DataObject::getSchema()->tableName(BlogPost::class),
|
||||||
|
'"BlogPost_Live"."ID" = "SiteTree_Live"."ID"'
|
||||||
|
)
|
||||||
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
||||||
|
|
||||||
$staged = $staged->setDataQuery($dataQuery);
|
$staged = $staged->setDataQuery($dataQuery);
|
||||||
|
@ -24,21 +24,21 @@ class BlogMemberExtension extends DataExtension
|
|||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'URLSegment' => 'Varchar',
|
'URLSegment' => 'Varchar',
|
||||||
'BlogProfileSummary' => 'Text',
|
'BlogProfileSummary' => 'Text'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'BlogProfileImage' => 'Image',
|
'BlogProfileImage' => 'SilverStripe\\Assets\\Image'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
'BlogPosts' => 'SilverStripe\\Blog\\Model\\BlogPost',
|
'BlogPosts' => 'SilverStripe\\Blog\\Model\\BlogPost'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,9 +264,11 @@ class BlogPost extends Page
|
|||||||
$publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date'));
|
$publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date'));
|
||||||
$publishDate->getDateField()->setConfig('showcalendar', true);
|
$publishDate->getDateField()->setConfig('showcalendar', true);
|
||||||
if (!$this->PublishDate) {
|
if (!$this->PublishDate) {
|
||||||
$publishDate->setDescription(_t(
|
$publishDate->setDescription(
|
||||||
|
_t(
|
||||||
'BlogPost.PublishDate_Description',
|
'BlogPost.PublishDate_Description',
|
||||||
'Will be set to "now" if published without a value.')
|
'Will be set to "now" if published without a value.'
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,12 +325,12 @@ class BlogPost extends Page
|
|||||||
{
|
{
|
||||||
if ($this->config()->restrict_authors_to_group) {
|
if ($this->config()->restrict_authors_to_group) {
|
||||||
return Group::get()->filter('Code', $this->config()->restrict_authors_to_group)->first()->Members();
|
return Group::get()->filter('Code', $this->config()->restrict_authors_to_group)->first()->Members();
|
||||||
} else {
|
}
|
||||||
|
|
||||||
$list = Member::get();
|
$list = Member::get();
|
||||||
$this->extend('updateCandidateAuthors', $list);
|
$this->extend('updateCandidateAuthors', $list);
|
||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if this user can edit the authors list.
|
* Determine if this user can edit the authors list.
|
||||||
|
@ -6,6 +6,7 @@ use SilverStripe\Admin\LeftAndMain;
|
|||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
use SilverStripe\ORM\DataExtension;
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\ORM\DataQuery;
|
use SilverStripe\ORM\DataQuery;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\Queries\SQLSelect;
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
@ -57,6 +58,9 @@ class BlogPostFilter extends DataExtension
|
|||||||
*/
|
*/
|
||||||
public function augmentLoadLazyFields(SQLSelect &$query, DataQuery &$dataQuery = null, $dataObject)
|
public function augmentLoadLazyFields(SQLSelect &$query, DataQuery &$dataQuery = null, $dataObject)
|
||||||
{
|
{
|
||||||
$dataQuery->innerJoin('BlogPost', '"SiteTree"."ID" = "BlogPost"."ID"');
|
$dataQuery->innerJoin(
|
||||||
|
DataObject::getSchema()->tableName(BlogPost::class),
|
||||||
|
'"SiteTree"."ID" = "BlogPost"."ID"'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,14 +49,14 @@ class BlogTag extends DataObject implements CategorisationObject
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Blog' => 'SilverStripe\\Blog\\Model\\Blog',
|
'Blog' => 'SilverStripe\\Blog\\Model\\Blog'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
'BlogPosts' => 'SilverStripe\\Blog\\Model\\BlogPost',
|
'BlogPosts' => 'SilverStripe\\Blog\\Model\\BlogPost'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,7 @@ use SilverStripe\Security\Member;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
* @mixin PHPUnit_Framework_TestCase
|
||||||
|
* @coversDefaultClass \SilverStripe\Blog\Model\BlogPostFilter
|
||||||
*/
|
*/
|
||||||
class BlogPostFilterTest extends SapphireTest
|
class BlogPostFilterTest extends SapphireTest
|
||||||
{
|
{
|
||||||
@ -28,6 +29,10 @@ class BlogPostFilterTest extends SapphireTest
|
|||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that unpublished articles are not returned
|
||||||
|
* @covers ::augmentSQL
|
||||||
|
*/
|
||||||
public function testFilter()
|
public function testFilter()
|
||||||
{
|
{
|
||||||
$member = Member::currentUser();
|
$member = Member::currentUser();
|
||||||
|
Loading…
Reference in New Issue
Block a user