mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Converted to PSR-2
This commit is contained in:
parent
4785ad0123
commit
f82825d9a6
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor {
|
||||
class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
||||
{
|
||||
/**
|
||||
* @param int $itemsPerPage
|
||||
* @param array|SS_List $mergeRecords
|
||||
@ -8,7 +9,8 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor {
|
||||
* @param string $parentMethod
|
||||
* @param string $childMethod
|
||||
*/
|
||||
public function __construct($itemsPerPage = 15, $mergeRecords, $parentType, $parentMethod, $childMethod) {
|
||||
public function __construct($itemsPerPage = 15, $mergeRecords, $parentType, $parentMethod, $childMethod)
|
||||
{
|
||||
parent::__construct($itemsPerPage);
|
||||
|
||||
$this->removeComponentsByType('GridFieldAddNewButton');
|
||||
@ -38,7 +40,8 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor {
|
||||
/**
|
||||
* Reorders GridField columns so that Actions is last.
|
||||
*/
|
||||
protected function changeColumnOrder() {
|
||||
protected function changeColumnOrder()
|
||||
{
|
||||
/**
|
||||
* @var GridFieldDataColumns $columns
|
||||
*/
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
class GridFieldFormAction extends GridField_FormAction {
|
||||
class GridFieldFormAction extends GridField_FormAction
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -9,14 +10,16 @@ class GridFieldFormAction extends GridField_FormAction {
|
||||
/**
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function setExtraAttributes(array $attributes) {
|
||||
public function setExtraAttributes(array $attributes)
|
||||
{
|
||||
$this->extraAttributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes() {
|
||||
public function getAttributes()
|
||||
{
|
||||
$attributes = parent::getAttributes();
|
||||
|
||||
return array_merge(
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
class GridFieldMergeAction implements GridField_ColumnProvider, GridField_ActionProvider {
|
||||
class GridFieldMergeAction implements GridField_ColumnProvider, GridField_ActionProvider
|
||||
{
|
||||
/**
|
||||
* List of records to show in the MergeAction column.
|
||||
*
|
||||
@ -35,7 +36,8 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
||||
* @param string $parentMethod
|
||||
* @param string $childMethod
|
||||
*/
|
||||
public function __construct($records = array(), $parentType, $parentMethod, $childMethod) {
|
||||
public function __construct($records = array(), $parentType, $parentMethod, $childMethod)
|
||||
{
|
||||
$this->records = $records;
|
||||
$this->parentType = $parentType;
|
||||
$this->parentMethod = $parentMethod;
|
||||
@ -45,7 +47,8 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function augmentColumns($gridField, &$columns) {
|
||||
public function augmentColumns($gridField, &$columns)
|
||||
{
|
||||
if (!in_array('MergeAction', $columns)) {
|
||||
$columns[] = 'MergeAction';
|
||||
}
|
||||
@ -56,14 +59,16 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getColumnsHandled($gridField) {
|
||||
public function getColumnsHandled($gridField)
|
||||
{
|
||||
return array('MergeAction');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getColumnContent($gridField, $record, $columnName) {
|
||||
public function getColumnContent($gridField, $record, $columnName)
|
||||
{
|
||||
if ($columnName === 'MergeAction' && $record->{$this->childMethod}()->Count() > 0) {
|
||||
$dropdown = new DropdownField('Target', 'Target', $this->records->exclude('ID', $record->ID)->map());
|
||||
$dropdown->setAttribute('id', 'Target_'.$record->ID);
|
||||
@ -93,28 +98,32 @@ class GridFieldMergeAction implements GridField_ColumnProvider, GridField_Action
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getColumnAttributes($gridField, $record, $columnName) {
|
||||
public function getColumnAttributes($gridField, $record, $columnName)
|
||||
{
|
||||
return array('class' => 'MergeAction');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getColumnMetadata($gridField, $columnName) {
|
||||
public function getColumnMetadata($gridField, $columnName)
|
||||
{
|
||||
return array('title' => 'Move posts to');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getActions($gridField) {
|
||||
public function getActions($gridField)
|
||||
{
|
||||
return array('merge');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handleAction(GridField $gridField, $actionName, $arguments, $data) {
|
||||
public function handleAction(GridField $gridField, $actionName, $arguments, $data)
|
||||
{
|
||||
if ($actionName === 'merge') {
|
||||
$controller = Controller::curr();
|
||||
|
||||
|
@ -8,7 +8,8 @@
|
||||
* @property string $PublishDate
|
||||
* @property string $Tags
|
||||
*/
|
||||
class BlogEntry extends BlogPost implements MigratableObject {
|
||||
class BlogEntry extends BlogPost implements MigratableObject
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -26,23 +27,23 @@ class BlogEntry extends BlogPost implements MigratableObject {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canCreate($member = null) {
|
||||
public function canCreate($member = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function up() {
|
||||
public function up()
|
||||
{
|
||||
|
||||
//Migrate comma separated tags into BlogTag objects.
|
||||
foreach ($this->TagNames() as $tag) {
|
||||
|
||||
$existingTag = BlogTag::get()->filter(array('Title' => $tag, 'BlogID' => $this->ParentID));
|
||||
if ($existingTag->count()) {
|
||||
//if tag already exists we will simply add it to this post.
|
||||
$tagObject = $existingTag->First();
|
||||
|
||||
} else {
|
||||
|
||||
//if the tag is now we create it and add it to this post.
|
||||
@ -50,8 +51,6 @@ class BlogEntry extends BlogPost implements MigratableObject {
|
||||
$tagObject->Title = $tag;
|
||||
$tagObject->BlogID = $this->ParentID;
|
||||
$tagObject->write();
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($tagObject) {
|
||||
@ -90,23 +89,25 @@ class BlogEntry extends BlogPost implements MigratableObject {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function TagNames() {
|
||||
public function TagNames()
|
||||
{
|
||||
$tags = preg_split('/\s*,\s*/', trim($this->Tags));
|
||||
|
||||
$results = array();
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
if($tag) $results[mb_strtolower($tag)] = $tag;
|
||||
if ($tag) {
|
||||
$results[mb_strtolower($tag)] = $tag;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class BlogEntry_Controller extends BlogPost_Controller {
|
||||
|
||||
class BlogEntry_Controller extends BlogPost_Controller
|
||||
{
|
||||
}
|
||||
|
@ -3,7 +3,8 @@
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class BlogHolder extends BlogTree implements MigratableObject {
|
||||
class BlogHolder extends BlogTree implements MigratableObject
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -27,24 +28,27 @@ class BlogHolder extends BlogTree implements MigratableObject {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canCreate($member = null) {
|
||||
public function canCreate($member = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//Overload these to stop the Uncaught Exception: Object->__call(): the method 'parent' does not exist on 'BlogHolder' error.
|
||||
public function validURLSegment() {
|
||||
public function validURLSegment()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public function syncLinkTracking() {
|
||||
public function syncLinkTracking()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function up() {
|
||||
|
||||
public function up()
|
||||
{
|
||||
$published = $this->IsPublished();
|
||||
|
||||
if ($this->ClassName === 'BlogHolder') {
|
||||
@ -68,6 +72,6 @@ class BlogHolder extends BlogTree implements MigratableObject {
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class BlogHolder_Controller extends BlogTree_Controller {
|
||||
|
||||
class BlogHolder_Controller extends BlogTree_Controller
|
||||
{
|
||||
}
|
||||
|
@ -3,7 +3,8 @@
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class BlogTree extends Page implements MigratableObject {
|
||||
class BlogTree extends Page implements MigratableObject
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -20,14 +21,16 @@ class BlogTree extends Page implements MigratableObject {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canCreate($member = null) {
|
||||
public function canCreate($member = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function up() {
|
||||
public function up()
|
||||
{
|
||||
$published = $this->IsPublished();
|
||||
if ($this->ClassName === 'BlogTree') {
|
||||
$this->ClassName = 'Page';
|
||||
@ -48,6 +51,6 @@ class BlogTree extends Page implements MigratableObject {
|
||||
/**
|
||||
* @deprecated since version 2.0
|
||||
*/
|
||||
class BlogTree_Controller extends Page_Controller {
|
||||
|
||||
class BlogTree_Controller extends Page_Controller
|
||||
{
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
class BlogMigrationTask extends MigrationTask {
|
||||
class BlogMigrationTask extends MigrationTask
|
||||
{
|
||||
/**
|
||||
* Should this task be invoked automatically via dev/build?
|
||||
*
|
||||
@ -13,22 +14,22 @@ class BlogMigrationTask extends MigrationTask {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function up() {
|
||||
public function up()
|
||||
{
|
||||
$classes = ClassInfo::implementorsOf('MigratableObject');
|
||||
|
||||
$this->message('Migrating legacy blog records');
|
||||
|
||||
foreach ($classes as $class) {
|
||||
|
||||
$this->upClass($class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text
|
||||
*/
|
||||
protected function message($text) {
|
||||
protected function message($text)
|
||||
{
|
||||
if (Controller::curr() instanceof DatabaseAdmin) {
|
||||
DB::alteration_message($text, 'obsolete');
|
||||
} else {
|
||||
@ -42,7 +43,8 @@ class BlogMigrationTask extends MigrationTask {
|
||||
* @param string $class
|
||||
* @param null|string $stage
|
||||
*/
|
||||
protected function upClass($class) {
|
||||
protected function upClass($class)
|
||||
{
|
||||
if (!class_exists($class)) {
|
||||
return;
|
||||
}
|
||||
@ -83,7 +85,8 @@ class BlogMigrationTask extends MigrationTask {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function down() {
|
||||
public function down()
|
||||
{
|
||||
$this->message('BlogMigrationTask::down() not implemented');
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
interface MigratableObject {
|
||||
interface MigratableObject
|
||||
{
|
||||
/**
|
||||
* Migrate the object up to the current version.
|
||||
*/
|
||||
|
@ -10,7 +10,8 @@ if(!class_exists('Widget')) {
|
||||
* @property string $DisplayMode
|
||||
* @property string $ArchiveType
|
||||
*/
|
||||
class ArchiveWidget extends BlogArchiveWidget implements MigratableObject {
|
||||
class ArchiveWidget extends BlogArchiveWidget implements MigratableObject
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -28,14 +29,16 @@ class ArchiveWidget extends BlogArchiveWidget implements MigratableObject {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canCreate($member = null) {
|
||||
public function canCreate($member = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function up() {
|
||||
public function up()
|
||||
{
|
||||
if ($this->DisplayMode) {
|
||||
$this->ArchiveType = 'Monthly';
|
||||
|
||||
@ -47,6 +50,5 @@ class ArchiveWidget extends BlogArchiveWidget implements MigratableObject {
|
||||
$this->ClassName = 'BlogArchiveWidget';
|
||||
$this->write();
|
||||
return "Migrated " . $this->ArchiveType . " archive widget";
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ if(!class_exists('Widget')) {
|
||||
*
|
||||
* @package blog
|
||||
*/
|
||||
class TagCloudWidget extends BlogTagsWidget implements MigratableObject {
|
||||
class TagCloudWidget extends BlogTagsWidget implements MigratableObject
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -29,14 +30,16 @@ class TagCloudWidget extends BlogTagsWidget implements MigratableObject {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canCreate($member = null) {
|
||||
public function canCreate($member = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function up() {
|
||||
public function up()
|
||||
{
|
||||
$this->ClassName = 'BlogTagsWidget';
|
||||
$this->write();
|
||||
return "Migrated " . $this->Title . " widget";
|
||||
|
@ -3,13 +3,15 @@
|
||||
/**
|
||||
* Adds Blog specific behaviour to Comment.
|
||||
*/
|
||||
class BlogCommentExtension extends DataExtension {
|
||||
class BlogCommentExtension extends DataExtension
|
||||
{
|
||||
/**
|
||||
* Extra CSS classes for styling different comment types.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtraClass() {
|
||||
public function getExtraClass()
|
||||
{
|
||||
$blogPost = $this->owner->getParent();
|
||||
|
||||
if ($blogPost instanceof BlogPost) {
|
||||
|
@ -7,11 +7,13 @@
|
||||
* @package silverstripe
|
||||
* @subpackage blog
|
||||
*/
|
||||
class BlogFilter extends Lumberjack {
|
||||
class BlogFilter extends Lumberjack
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function stageChildren($showAll = false) {
|
||||
public function stageChildren($showAll = false)
|
||||
{
|
||||
$staged = parent::stageChildren($showAll);
|
||||
|
||||
if (!$this->shouldFilter() && $this->subclassForBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||
@ -36,14 +38,16 @@ class BlogFilter extends Lumberjack {
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function subclassForBlog() {
|
||||
protected function subclassForBlog()
|
||||
{
|
||||
return in_array(get_class($this->owner), ClassInfo::subClassesFor('Blog'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function liveChildren($showAll = false, $onlyDeletedFromStage = false) {
|
||||
public function liveChildren($showAll = false, $onlyDeletedFromStage = false)
|
||||
{
|
||||
$staged = parent::liveChildren($showAll, $onlyDeletedFromStage);
|
||||
|
||||
if (!$this->shouldFilter() && $this->isBlog() && !Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||
@ -60,14 +64,16 @@ class BlogFilter extends Lumberjack {
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isBlog() {
|
||||
protected function isBlog()
|
||||
{
|
||||
return $this->owner instanceof Blog;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function updateCMSFields(FieldList $fields) {
|
||||
public function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$excluded = $this->owner->getExcludedSiteTreeClassNames();
|
||||
|
||||
if (!empty($excluded)) {
|
||||
@ -94,13 +100,15 @@ class BlogFilter extends Lumberjack {
|
||||
/**
|
||||
* Enables children of non-editable pages to be edited.
|
||||
*/
|
||||
class BlogFilter_GridField extends GridField {
|
||||
class BlogFilter_GridField extends GridField
|
||||
{
|
||||
/**
|
||||
* @param FormTransformation $transformation
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function transform(FormTransformation $transformation) {
|
||||
public function transform(FormTransformation $transformation)
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@
|
||||
* @package silverstripe
|
||||
* @subpackage blog
|
||||
*/
|
||||
class BlogMemberExtension extends DataExtension {
|
||||
class BlogMemberExtension extends DataExtension
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -32,7 +33,8 @@ class BlogMemberExtension extends DataExtension {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function onBeforeWrite() {
|
||||
public function onBeforeWrite()
|
||||
{
|
||||
$count = 1;
|
||||
|
||||
$this->owner->URLSegment = $this->generateURLSegment();
|
||||
@ -48,7 +50,8 @@ class BlogMemberExtension extends DataExtension {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateURLSegment() {
|
||||
public function generateURLSegment()
|
||||
{
|
||||
$filter = URLSegmentFilter::create();
|
||||
$name = $this->owner->FirstName . ' ' . $this->owner->Surname;
|
||||
$urlSegment = $filter->filter($name);
|
||||
@ -66,7 +69,8 @@ class BlogMemberExtension extends DataExtension {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validURLSegment() {
|
||||
public function validURLSegment()
|
||||
{
|
||||
$conflict = Member::get()->filter('URLSegment', $this->owner->URLSegment);
|
||||
|
||||
if ($this->owner->ID) {
|
||||
@ -80,7 +84,8 @@ class BlogMemberExtension extends DataExtension {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function updateCMSFields(FieldList $fields) {
|
||||
public function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$fields->removeByName('URLSegment');
|
||||
|
||||
// Remove the automatically-generated posts tab.
|
||||
|
@ -7,13 +7,15 @@
|
||||
* @package silverstripe
|
||||
* @subpackage blog
|
||||
*/
|
||||
class BlogPostFilter extends DataExtension {
|
||||
class BlogPostFilter extends DataExtension
|
||||
{
|
||||
/**
|
||||
* Augment queries so that we don't fetch unpublished articles.
|
||||
*
|
||||
* @param SQLQuery $query
|
||||
*/
|
||||
public function augmentSQL(SQLQuery &$query) {
|
||||
public function augmentSQL(SQLQuery &$query)
|
||||
{
|
||||
$stage = Versioned::current_stage();
|
||||
|
||||
if (Controller::curr() instanceof LeftAndMain) {
|
||||
@ -36,7 +38,8 @@ class BlogPostFilter extends DataExtension {
|
||||
* @param mixed $dataQuery
|
||||
* @param mixed $parent
|
||||
*/
|
||||
public function augmentLoadLazyFields(SQLQuery &$query, &$dataQuery, $parent) {
|
||||
public function augmentLoadLazyFields(SQLQuery &$query, &$dataQuery, $parent)
|
||||
{
|
||||
$dataQuery->innerJoin('BlogPost', '"SiteTree"."ID" = "BlogPost"."ID"');
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,16 @@
|
||||
*
|
||||
* Extends {@see BlogPost} with extensions to {@see CommentNotifiable}.
|
||||
*/
|
||||
class BlogPostNotifications extends DataExtension {
|
||||
class BlogPostNotifications extends DataExtension
|
||||
{
|
||||
/**
|
||||
* Notify all authors of notifications.
|
||||
*
|
||||
* @param SS_List $list
|
||||
* @param mixed $comment
|
||||
*/
|
||||
public function updateNotificationRecipients(&$list, &$comment) {
|
||||
public function updateNotificationRecipients(&$list, &$comment)
|
||||
{
|
||||
$list = $this->owner->Authors();
|
||||
}
|
||||
|
||||
@ -23,7 +25,8 @@ class BlogPostNotifications extends DataExtension {
|
||||
* @param Comment $comment
|
||||
* @param Member|string $recipient
|
||||
*/
|
||||
public function updateNotificationSubject(&$subject, &$comment, &$recipient) {
|
||||
public function updateNotificationSubject(&$subject, &$comment, &$recipient)
|
||||
{
|
||||
$subject = sprintf('A new comment has been posted on ', $this->owner->Title);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@
|
||||
* @package silverstripe
|
||||
* @subpackage blog
|
||||
*/
|
||||
class URLSegmentExtension extends DataExtension {
|
||||
class URLSegmentExtension extends DataExtension
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -17,7 +18,8 @@ class URLSegmentExtension extends DataExtension {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function onBeforeWrite() {
|
||||
public function onBeforeWrite()
|
||||
{
|
||||
$this->owner->generateURLSegment();
|
||||
}
|
||||
|
||||
@ -28,7 +30,8 @@ class URLSegmentExtension extends DataExtension {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateURLSegment($increment = null) {
|
||||
public function generateURLSegment($increment = null)
|
||||
{
|
||||
$filter = new URLSegmentFilter();
|
||||
|
||||
$this->owner->URLSegment = $filter->filter($this->owner->Title);
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
class BlogAdminSidebar extends FieldGroup {
|
||||
class BlogAdminSidebar extends FieldGroup
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isOpen() {
|
||||
public function isOpen()
|
||||
{
|
||||
$sidebar = Cookie::get('blog-admin-sidebar');
|
||||
|
||||
if ($sidebar == 1 || is_null($sidebar)) {
|
||||
|
@ -6,7 +6,8 @@
|
||||
* @package silverstripe
|
||||
* @subpackage blog
|
||||
*/
|
||||
class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLProvider {
|
||||
class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLProvider
|
||||
{
|
||||
/**
|
||||
* HTML Fragment to render the field.
|
||||
*
|
||||
@ -28,7 +29,8 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
* @param string $targetFragment
|
||||
* @param string $dataObjectField
|
||||
*/
|
||||
public function __construct($targetFragment = 'before', $dataObjectField = 'Title') {
|
||||
public function __construct($targetFragment = 'before', $dataObjectField = 'Title')
|
||||
{
|
||||
$this->targetFragment = $targetFragment;
|
||||
$this->dataObjectField = (string) $dataObjectField;
|
||||
}
|
||||
@ -40,7 +42,8 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getActions($gridField) {
|
||||
public function getActions($gridField)
|
||||
{
|
||||
return array(
|
||||
'add',
|
||||
);
|
||||
@ -58,7 +61,8 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
*
|
||||
* @throws UnexpectedValueException
|
||||
*/
|
||||
public function handleAction(GridField $gridField, $actionName, $arguments, $data) {
|
||||
public function handleAction(GridField $gridField, $actionName, $arguments, $data)
|
||||
{
|
||||
if ($actionName == 'add') {
|
||||
$dbField = $this->getDataObjectField();
|
||||
|
||||
@ -119,7 +123,8 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDataObjectField() {
|
||||
public function getDataObjectField()
|
||||
{
|
||||
return $this->dataObjectField;
|
||||
}
|
||||
|
||||
@ -128,7 +133,8 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
*
|
||||
* @param $field string
|
||||
*/
|
||||
public function setDataObjectField($field) {
|
||||
public function setDataObjectField($field)
|
||||
{
|
||||
$this->dataObjectField = (string) $field;
|
||||
}
|
||||
|
||||
@ -139,7 +145,8 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHTMLFragments($gridField) {
|
||||
public function getHTMLFragments($gridField)
|
||||
{
|
||||
/**
|
||||
* @var DataList $dataList
|
||||
*/
|
||||
|
@ -7,11 +7,13 @@
|
||||
* @package silverstripe
|
||||
* @subpackage blog
|
||||
*/
|
||||
class GridFieldBlogPostState extends GridFieldSiteTreeState {
|
||||
class GridFieldBlogPostState extends GridFieldSiteTreeState
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getColumnContent($gridField, $record, $columnName) {
|
||||
public function getColumnContent($gridField, $record, $columnName)
|
||||
{
|
||||
if ($columnName == 'State') {
|
||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
||||
if ($record instanceof BlogPost) {
|
||||
@ -70,7 +72,8 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getColumnAttributes($gridField, $record, $columnName) {
|
||||
public function getColumnAttributes($gridField, $record, $columnName)
|
||||
{
|
||||
if ($columnName == 'State') {
|
||||
if ($record instanceof BlogPost) {
|
||||
$published = $record->isPublished();
|
||||
|
@ -6,11 +6,13 @@
|
||||
* @package silverstripe
|
||||
* @subpackage blog
|
||||
*/
|
||||
class GridFieldConfig_BlogPost extends GridFieldConfig_Lumberjack {
|
||||
class GridFieldConfig_BlogPost extends GridFieldConfig_Lumberjack
|
||||
{
|
||||
/**
|
||||
* @param null|int $itemsPerPage
|
||||
*/
|
||||
public function __construct($itemsPerPage = null) {
|
||||
public function __construct($itemsPerPage = null)
|
||||
{
|
||||
parent::__construct($itemsPerPage);
|
||||
|
||||
$this->removeComponentsByType('GridFieldSiteTreeState');
|
||||
|
@ -12,7 +12,8 @@
|
||||
* @method ManyManyList Writers() List of writers
|
||||
* @method ManyManyList Contributors() List of contributors
|
||||
*/
|
||||
class Blog extends Page implements PermissionProvider {
|
||||
class Blog extends Page implements PermissionProvider
|
||||
{
|
||||
/**
|
||||
* Permission for user management.
|
||||
*
|
||||
@ -103,7 +104,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
public function getCMSFields()
|
||||
{
|
||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
||||
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
|
||||
|
||||
@ -145,7 +147,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canEdit($member = null) {
|
||||
public function canEdit($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
if ($this->isEditor($member)) {
|
||||
@ -160,7 +163,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return null|Member
|
||||
*/
|
||||
protected function getMember($member = null) {
|
||||
protected function getMember($member = null)
|
||||
{
|
||||
if (!$member) {
|
||||
$member = Member::currentUser();
|
||||
}
|
||||
@ -179,7 +183,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEditor($member) {
|
||||
public function isEditor($member)
|
||||
{
|
||||
$isEditor = $this->isMemberOf($member, $this->Editors());
|
||||
$this->extend('updateIsEditor', $isEditor, $member);
|
||||
|
||||
@ -194,7 +199,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isMemberOf($member, $relation) {
|
||||
protected function isMemberOf($member, $relation)
|
||||
{
|
||||
if (!$member || !$member->exists()) {
|
||||
return false;
|
||||
}
|
||||
@ -217,7 +223,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function RoleOf($member) {
|
||||
public function RoleOf($member)
|
||||
{
|
||||
if (is_numeric($member)) {
|
||||
$member = DataObject::get_by_id('Member', $member);
|
||||
}
|
||||
@ -248,7 +255,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isWriter($member) {
|
||||
public function isWriter($member)
|
||||
{
|
||||
$isWriter = $this->isMemberOf($member, $this->Writers());
|
||||
$this->extend('updateIsWriter', $isWriter, $member);
|
||||
|
||||
@ -262,7 +270,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isContributor($member) {
|
||||
public function isContributor($member)
|
||||
{
|
||||
$isContributor = $this->isMemberOf($member, $this->Contributors());
|
||||
$this->extend('updateIsContributor', $isContributor, $member);
|
||||
|
||||
@ -272,7 +281,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canAddChildren($member = null) {
|
||||
public function canAddChildren($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
if ($this->isEditor($member) || $this->isWriter($member) || $this->isContributor($member)) {
|
||||
@ -285,7 +295,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSettingsFields() {
|
||||
public function getSettingsFields()
|
||||
{
|
||||
$fields = parent::getSettingsFields();
|
||||
|
||||
$fields->addFieldToTab('Root.Settings',
|
||||
@ -358,7 +369,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return SS_List
|
||||
*/
|
||||
protected function getCandidateUsers() {
|
||||
protected function getCandidateUsers()
|
||||
{
|
||||
if ($this->config()->grant_user_access) {
|
||||
$list = Member::get();
|
||||
$this->extend('updateCandidateUsers', $list);
|
||||
@ -377,7 +389,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canEditEditors($member = null) {
|
||||
public function canEditEditors($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
$extended = $this->extendedCan('canEditEditors', $member);
|
||||
@ -396,7 +409,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canEditWriters($member = null) {
|
||||
public function canEditWriters($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
$extended = $this->extendedCan('canEditWriters', $member);
|
||||
@ -419,7 +433,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canEditContributors($member = null) {
|
||||
public function canEditContributors($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
$extended = $this->extendedCan('canEditContributors', $member);
|
||||
@ -444,7 +459,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return DataList
|
||||
*/
|
||||
public function getArchivedBlogPosts($year, $month = null, $day = null) {
|
||||
public function getArchivedBlogPosts($year, $month = null, $day = null)
|
||||
{
|
||||
$query = $this->getBlogPosts()->dataQuery();
|
||||
|
||||
$stage = $query->getQueryParam('Versioned.stage');
|
||||
@ -473,7 +489,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return DataList of BlogPost objects
|
||||
*/
|
||||
public function getBlogPosts() {
|
||||
public function getBlogPosts()
|
||||
{
|
||||
$blogPosts = BlogPost::get()->filter('ParentID', $this->ID);
|
||||
|
||||
$this->extend('updateGetBlogPosts', $blogPosts);
|
||||
@ -488,7 +505,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ProfileLink($urlSegment) {
|
||||
public function ProfileLink($urlSegment)
|
||||
{
|
||||
return Controller::join_links($this->Link(), 'profile', $urlSegment);
|
||||
}
|
||||
|
||||
@ -497,7 +515,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLumberjackTitle() {
|
||||
public function getLumberjackTitle()
|
||||
{
|
||||
return _t('Blog.LumberjackTitle', 'Blog Posts');
|
||||
}
|
||||
|
||||
@ -506,14 +525,16 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return GridFieldConfig
|
||||
*/
|
||||
public function getLumberjackGridFieldConfig() {
|
||||
public function getLumberjackGridFieldConfig()
|
||||
{
|
||||
return GridFieldConfig_BlogPost::create();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providePermissions() {
|
||||
public function providePermissions()
|
||||
{
|
||||
return array(
|
||||
Blog::MANAGE_USERS => array(
|
||||
'name' => _t(
|
||||
@ -533,7 +554,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function onBeforeWrite() {
|
||||
protected function onBeforeWrite()
|
||||
{
|
||||
parent::onBeforeWrite();
|
||||
$this->assignGroup();
|
||||
}
|
||||
@ -541,7 +563,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
/**
|
||||
* Assign users as necessary to the blog group.
|
||||
*/
|
||||
protected function assignGroup() {
|
||||
protected function assignGroup()
|
||||
{
|
||||
if (!$this->config()->grant_user_access) {
|
||||
return;
|
||||
}
|
||||
@ -565,7 +588,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
*
|
||||
* @return Group
|
||||
*/
|
||||
protected function getUserGroup() {
|
||||
protected function getUserGroup()
|
||||
{
|
||||
$code = $this->config()->grant_user_group;
|
||||
|
||||
$group = Group::get()->filter('Code', $code)->first();
|
||||
@ -593,7 +617,8 @@ class Blog extends Page implements PermissionProvider {
|
||||
* @package silverstripe
|
||||
* @subpackage blog
|
||||
*/
|
||||
class Blog_Controller extends Page_Controller {
|
||||
class Blog_Controller extends Page_Controller
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -633,7 +658,8 @@ class Blog_Controller extends Page_Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
/**
|
||||
* @var Blog $dataRecord
|
||||
*/
|
||||
@ -649,7 +675,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return SS_HTTPResponse
|
||||
*/
|
||||
public function profile() {
|
||||
public function profile()
|
||||
{
|
||||
$profile = $this->getCurrentProfile();
|
||||
|
||||
if (!$profile) {
|
||||
@ -666,7 +693,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return null|Member
|
||||
*/
|
||||
public function getCurrentProfile() {
|
||||
public function getCurrentProfile()
|
||||
{
|
||||
$urlSegment = $this->request->param('URLSegment');
|
||||
|
||||
if ($urlSegment) {
|
||||
@ -683,7 +711,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return null|DataList
|
||||
*/
|
||||
public function getCurrentProfilePosts() {
|
||||
public function getCurrentProfilePosts()
|
||||
{
|
||||
$profile = $this->getCurrentProfile();
|
||||
|
||||
if ($profile) {
|
||||
@ -698,7 +727,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return null|SS_HTTPResponse
|
||||
*/
|
||||
public function archive() {
|
||||
public function archive()
|
||||
{
|
||||
/**
|
||||
* @var Blog $dataRecord
|
||||
*/
|
||||
@ -732,10 +762,9 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getArchiveYear() {
|
||||
|
||||
public function getArchiveYear()
|
||||
{
|
||||
if ($this->request->param('Year')) {
|
||||
|
||||
if (preg_match('/^[0-9]{4}$/', $year = $this->request->param('Year'))) {
|
||||
return (int) $year;
|
||||
}
|
||||
@ -751,7 +780,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return null|int
|
||||
*/
|
||||
public function getArchiveMonth() {
|
||||
public function getArchiveMonth()
|
||||
{
|
||||
$month = $this->request->param('Month');
|
||||
|
||||
if (preg_match('/^[0-9]{1,2}$/', $month)) {
|
||||
@ -770,7 +800,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return null|int
|
||||
*/
|
||||
public function getArchiveDay() {
|
||||
public function getArchiveDay()
|
||||
{
|
||||
$day = $this->request->param('Day');
|
||||
|
||||
if (preg_match('/^[0-9]{1,2}$/', $day)) {
|
||||
@ -787,7 +818,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return null|SS_HTTPResponse
|
||||
*/
|
||||
public function tag() {
|
||||
public function tag()
|
||||
{
|
||||
$tag = $this->getCurrentTag();
|
||||
|
||||
if ($tag) {
|
||||
@ -805,7 +837,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return null|BlogTag
|
||||
*/
|
||||
public function getCurrentTag() {
|
||||
public function getCurrentTag()
|
||||
{
|
||||
/**
|
||||
* @var Blog $dataRecord
|
||||
*/
|
||||
@ -824,7 +857,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return null|SS_HTTPResponse
|
||||
*/
|
||||
public function category() {
|
||||
public function category()
|
||||
{
|
||||
$category = $this->getCurrentCategory();
|
||||
|
||||
if ($category) {
|
||||
@ -843,7 +877,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return null|BlogCategory
|
||||
*/
|
||||
public function getCurrentCategory() {
|
||||
public function getCurrentCategory()
|
||||
{
|
||||
/**
|
||||
* @var Blog $dataRecord
|
||||
*/
|
||||
@ -862,7 +897,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMetaTitle() {
|
||||
public function getMetaTitle()
|
||||
{
|
||||
$title = $this->data()->getTitle();
|
||||
$filter = $this->getFilterDescription();
|
||||
|
||||
@ -880,7 +916,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFilterDescription() {
|
||||
public function getFilterDescription()
|
||||
{
|
||||
$items = array();
|
||||
|
||||
$list = $this->PaginatedList();
|
||||
@ -965,7 +1002,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return PaginatedList
|
||||
*/
|
||||
public function PaginatedList() {
|
||||
public function PaginatedList()
|
||||
{
|
||||
$allPosts = $this->blogPosts ?: new ArrayList();
|
||||
|
||||
$posts = new PaginatedList($allPosts);
|
||||
@ -992,7 +1030,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function rss() {
|
||||
public function rss()
|
||||
{
|
||||
/**
|
||||
* @var Blog $dataRecord
|
||||
*/
|
||||
@ -1012,7 +1051,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return null|Date
|
||||
*/
|
||||
public function getArchiveDate() {
|
||||
public function getArchiveDate()
|
||||
{
|
||||
$year = $this->getArchiveYear();
|
||||
$month = $this->getArchiveMonth();
|
||||
$day = $this->getArchiveDay();
|
||||
@ -1039,7 +1079,8 @@ class Blog_Controller extends Page_Controller {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRSSLink() {
|
||||
public function getRSSLink()
|
||||
{
|
||||
return $this->Link('rss');
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,8 @@
|
||||
* @property string $URLSegment
|
||||
* @property int $BlogID
|
||||
*/
|
||||
class BlogCategory extends DataObject implements CategorisationObject {
|
||||
class BlogCategory extends DataObject implements CategorisationObject
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -43,7 +44,8 @@ class BlogCategory extends DataObject implements CategorisationObject {
|
||||
/**
|
||||
* @return DataList
|
||||
*/
|
||||
public function BlogPosts() {
|
||||
public function BlogPosts()
|
||||
{
|
||||
$blogPosts = parent::BlogPosts();
|
||||
|
||||
$this->extend("updateGetBlogPosts", $blogPosts);
|
||||
@ -54,7 +56,8 @@ class BlogCategory extends DataObject implements CategorisationObject {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
public function getCMSFields()
|
||||
{
|
||||
$fields = new FieldList(
|
||||
TextField::create('Title', _t('BlogCategory.Title', 'Title'))
|
||||
);
|
||||
@ -69,7 +72,8 @@ class BlogCategory extends DataObject implements CategorisationObject {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLink() {
|
||||
public function getLink()
|
||||
{
|
||||
return Controller::join_links($this->Blog()->Link(), 'category', $this->URLSegment);
|
||||
}
|
||||
|
||||
@ -80,7 +84,8 @@ class BlogCategory extends DataObject implements CategorisationObject {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView($member = null) {
|
||||
public function canView($member = null)
|
||||
{
|
||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||
|
||||
if ($extended !== null) {
|
||||
@ -97,7 +102,8 @@ class BlogCategory extends DataObject implements CategorisationObject {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canCreate($member = null) {
|
||||
public function canCreate($member = null)
|
||||
{
|
||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||
|
||||
if ($extended !== null) {
|
||||
@ -116,7 +122,8 @@ class BlogCategory extends DataObject implements CategorisationObject {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canDelete($member = null) {
|
||||
public function canDelete($member = null)
|
||||
{
|
||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||
|
||||
if ($extended !== null) {
|
||||
@ -133,7 +140,8 @@ class BlogCategory extends DataObject implements CategorisationObject {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canEdit($member = null) {
|
||||
public function canEdit($member = null)
|
||||
{
|
||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||
|
||||
if ($extended !== null) {
|
||||
|
@ -15,8 +15,8 @@
|
||||
* @property string $AuthorNames
|
||||
* @property int $ParentID
|
||||
*/
|
||||
class BlogPost extends Page {
|
||||
|
||||
class BlogPost extends Page
|
||||
{
|
||||
/**
|
||||
* Same as above, but for list of users that can be
|
||||
* given credit in the author field for blog posts
|
||||
@ -122,7 +122,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function RoleOf($member = null) {
|
||||
public function RoleOf($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
if (!$member) {
|
||||
@ -149,7 +150,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAuthor($member = null) {
|
||||
public function isAuthor($member = null)
|
||||
{
|
||||
if (!$member || !$member->exists()) {
|
||||
return false;
|
||||
}
|
||||
@ -166,7 +168,8 @@ class BlogPost extends Page {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
public function getCMSFields()
|
||||
{
|
||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
||||
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
|
||||
|
||||
@ -289,7 +292,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return SS_List
|
||||
*/
|
||||
public function getCandidateAuthors() {
|
||||
public function getCandidateAuthors()
|
||||
{
|
||||
if ($this->config()->restrict_authors_to_group) {
|
||||
return Group::get()->filter('Code', $this->config()->restrict_authors_to_group)->first()->Members();
|
||||
} else {
|
||||
@ -306,7 +310,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canEditAuthors($member = null) {
|
||||
public function canEditAuthors($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
$extended = $this->extendedCan('canEditAuthors', $member);
|
||||
@ -335,7 +340,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return null|Member
|
||||
*/
|
||||
protected function getMember($member = null) {
|
||||
protected function getMember($member = null)
|
||||
{
|
||||
if (!$member) {
|
||||
$member = Member::currentUser();
|
||||
}
|
||||
@ -354,7 +360,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canCreateCategories($member = null) {
|
||||
public function canCreateCategories($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
$parent = $this->Parent();
|
||||
@ -377,7 +384,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canCreateTags($member = null) {
|
||||
public function canCreateTags($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
$parent = $this->Parent();
|
||||
@ -402,7 +410,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* Update the PublishDate to now if the BlogPost would otherwise be published without a date.
|
||||
*/
|
||||
public function onBeforePublish() {
|
||||
public function onBeforePublish()
|
||||
{
|
||||
/**
|
||||
* @var SS_Datetime $publishDate
|
||||
*/
|
||||
@ -419,7 +428,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* Sets blog relationship on all categories and tags assigned to this post.
|
||||
*/
|
||||
public function onAfterWrite() {
|
||||
public function onAfterWrite()
|
||||
{
|
||||
parent::onAfterWrite();
|
||||
|
||||
foreach ($this->Categories() as $category) {
|
||||
@ -442,7 +452,8 @@ class BlogPost extends Page {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canView($member = null) {
|
||||
public function canView($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
if (!parent::canView($member)) {
|
||||
@ -466,7 +477,8 @@ class BlogPost extends Page {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canPublish($member = null) {
|
||||
public function canPublish($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
if (Permission::checkMember($member, 'ADMIN')) {
|
||||
@ -501,7 +513,8 @@ class BlogPost extends Page {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function canEdit($member = null) {
|
||||
public function canEdit($member = null)
|
||||
{
|
||||
$member = $this->getMember($member);
|
||||
|
||||
if (parent::canEdit($member)) {
|
||||
@ -532,7 +545,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function Excerpt($wordsToDisplay = 30) {
|
||||
public function Excerpt($wordsToDisplay = 30)
|
||||
{
|
||||
/**
|
||||
* @var Text $content
|
||||
*/
|
||||
@ -548,7 +562,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMonthlyArchiveLink($type = 'day') {
|
||||
public function getMonthlyArchiveLink($type = 'day')
|
||||
{
|
||||
/**
|
||||
* @var SS_Datetime $date
|
||||
*/
|
||||
@ -575,7 +590,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getYearlyArchiveLink() {
|
||||
public function getYearlyArchiveLink()
|
||||
{
|
||||
/**
|
||||
* @var SS_Datetime $date
|
||||
*/
|
||||
@ -589,7 +605,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
public function getCredits() {
|
||||
public function getCredits()
|
||||
{
|
||||
$list = new ArrayList();
|
||||
|
||||
$list->merge($this->getDynamicCredits());
|
||||
@ -603,7 +620,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
protected function getDynamicCredits() {
|
||||
protected function getDynamicCredits()
|
||||
{
|
||||
// Find best page to host user profiles
|
||||
$parent = $this->Parent();
|
||||
if (! ($parent instanceof Blog)) {
|
||||
@ -634,7 +652,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
protected function getStaticCredits() {
|
||||
protected function getStaticCredits()
|
||||
{
|
||||
$items = new ArrayList();
|
||||
|
||||
$authors = array_filter(preg_split('/\s*,\s*/', $this->AuthorNames));
|
||||
@ -657,7 +676,8 @@ class BlogPost extends Page {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fieldLabels($includeRelations = true) {
|
||||
public function fieldLabels($includeRelations = true)
|
||||
{
|
||||
$labels = parent::fieldLabels($includeRelations);
|
||||
|
||||
$labels['Title'] = _t('BlogPost.PageTitleLabel', 'Post Title');
|
||||
@ -668,7 +688,8 @@ class BlogPost extends Page {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function onBeforeWrite() {
|
||||
protected function onBeforeWrite()
|
||||
{
|
||||
parent::onBeforeWrite();
|
||||
|
||||
if (!$this->exists() && ($member = Member::currentUser())) {
|
||||
@ -681,6 +702,6 @@ class BlogPost extends Page {
|
||||
* @package silverstripe
|
||||
* @subpackage blog
|
||||
*/
|
||||
class BlogPost_Controller extends Page_Controller {
|
||||
|
||||
class BlogPost_Controller extends Page_Controller
|
||||
{
|
||||
}
|
||||
|
@ -12,7 +12,8 @@
|
||||
* @property string $URLSegment
|
||||
* @property int $BlogID
|
||||
*/
|
||||
class BlogTag extends DataObject implements CategorisationObject {
|
||||
class BlogTag extends DataObject implements CategorisationObject
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@ -44,7 +45,8 @@ class BlogTag extends DataObject implements CategorisationObject {
|
||||
/**
|
||||
* @return DataList
|
||||
*/
|
||||
public function BlogPosts() {
|
||||
public function BlogPosts()
|
||||
{
|
||||
$blogPosts = parent::BlogPosts();
|
||||
|
||||
$this->extend("updateGetBlogPosts", $blogPosts);
|
||||
@ -55,7 +57,8 @@ class BlogTag extends DataObject implements CategorisationObject {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
public function getCMSFields()
|
||||
{
|
||||
$fields = new FieldList(
|
||||
TextField::create('Title', _t('BlogTag.Title', 'Title'))
|
||||
);
|
||||
@ -70,7 +73,8 @@ class BlogTag extends DataObject implements CategorisationObject {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLink() {
|
||||
public function getLink()
|
||||
{
|
||||
return Controller::join_links($this->Blog()->Link(), 'tag', $this->URLSegment);
|
||||
}
|
||||
|
||||
@ -81,7 +85,8 @@ class BlogTag extends DataObject implements CategorisationObject {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView($member = null) {
|
||||
public function canView($member = null)
|
||||
{
|
||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||
|
||||
if ($extended !== null) {
|
||||
@ -98,7 +103,8 @@ class BlogTag extends DataObject implements CategorisationObject {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canCreate($member = null) {
|
||||
public function canCreate($member = null)
|
||||
{
|
||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||
|
||||
if ($extended !== null) {
|
||||
@ -117,7 +123,8 @@ class BlogTag extends DataObject implements CategorisationObject {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canDelete($member = null) {
|
||||
public function canDelete($member = null)
|
||||
{
|
||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||
|
||||
if ($extended !== null) {
|
||||
@ -134,7 +141,8 @@ class BlogTag extends DataObject implements CategorisationObject {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canEdit($member = null) {
|
||||
public function canEdit($member = null)
|
||||
{
|
||||
$extended = $this->extendedCan(__FUNCTION__, $member);
|
||||
|
||||
if ($extended !== null) {
|
||||
|
@ -3,6 +3,6 @@
|
||||
/**
|
||||
* @method ManyManyList BlogPosts
|
||||
*/
|
||||
interface CategorisationObject {
|
||||
|
||||
interface CategorisationObject
|
||||
{
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ if(!class_exists('Widget')) {
|
||||
* @property string $ArchiveType
|
||||
* @property int $NumberToDisplay
|
||||
*/
|
||||
class BlogArchiveWidget extends Widget {
|
||||
class BlogArchiveWidget extends Widget
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -51,7 +52,8 @@ class BlogArchiveWidget extends Widget {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
public function getCMSFields()
|
||||
{
|
||||
$self =& $this;
|
||||
|
||||
$this->beforeUpdateCMSFields(function ($fields) use ($self) {
|
||||
@ -84,7 +86,8 @@ class BlogArchiveWidget extends Widget {
|
||||
*
|
||||
* @return DataList
|
||||
*/
|
||||
public function getArchive() {
|
||||
public function getArchive()
|
||||
{
|
||||
$query = $this->Blog()->getBlogPosts()->dataQuery();
|
||||
|
||||
if ($this->ArchiveType == 'Yearly') {
|
||||
@ -130,6 +133,6 @@ class BlogArchiveWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
class BlogArchiveWidget_Controller extends Widget_Controller {
|
||||
|
||||
class BlogArchiveWidget_Controller extends Widget_Controller
|
||||
{
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ if(!class_exists("Widget")) {
|
||||
/**
|
||||
* @method Blog Blog()
|
||||
*/
|
||||
class BlogCategoriesWidget extends Widget {
|
||||
class BlogCategoriesWidget extends Widget
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -42,7 +43,8 @@ class BlogCategoriesWidget extends Widget {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
public function getCMSFields()
|
||||
{
|
||||
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||
$fields[] = DropdownField::create(
|
||||
'BlogID', _t('BlogCategoriesWidget.Blog', 'Blog'), Blog::get()->map()
|
||||
@ -71,7 +73,8 @@ class BlogCategoriesWidget extends Widget {
|
||||
/**
|
||||
* @return DataList
|
||||
*/
|
||||
public function getCategories() {
|
||||
public function getCategories()
|
||||
{
|
||||
$blog = $this->Blog();
|
||||
|
||||
if (!$blog) {
|
||||
@ -92,6 +95,6 @@ class BlogCategoriesWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
class BlogCategoriesWidget_Controller extends Widget_Controller {
|
||||
|
||||
class BlogCategoriesWidget_Controller extends Widget_Controller
|
||||
{
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ if(!class_exists("Widget")) {
|
||||
*
|
||||
* @property int $NumberOfPosts
|
||||
*/
|
||||
class BlogRecentPostsWidget extends Widget {
|
||||
class BlogRecentPostsWidget extends Widget
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -42,7 +43,8 @@ class BlogRecentPostsWidget extends Widget {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
public function getCMSFields()
|
||||
{
|
||||
$this->beforeUpdateCMSFields(function ($fields) {
|
||||
/**
|
||||
* @var FieldList $fields
|
||||
@ -59,7 +61,8 @@ class BlogRecentPostsWidget extends Widget {
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPosts() {
|
||||
public function getPosts()
|
||||
{
|
||||
$blog = $this->Blog();
|
||||
|
||||
if ($blog) {
|
||||
@ -72,6 +75,6 @@ class BlogRecentPostsWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
class BlogRecentPostsWidget_Controller extends Widget_Controller {
|
||||
|
||||
class BlogRecentPostsWidget_Controller extends Widget_Controller
|
||||
{
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ if(!class_exists("Widget")) {
|
||||
/**
|
||||
* @method Blog Blog()
|
||||
*/
|
||||
class BlogTagsWidget extends Widget {
|
||||
class BlogTagsWidget extends Widget
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -42,7 +43,8 @@ class BlogTagsWidget extends Widget {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
public function getCMSFields()
|
||||
{
|
||||
$this->beforeUpdateCMSFields(function (Fieldlist $fields) {
|
||||
$fields[] = DropdownField::create(
|
||||
'BlogID', _t('BlogTagsWidget.Blog', 'Blog'), Blog::get()->map()
|
||||
@ -71,7 +73,8 @@ class BlogTagsWidget extends Widget {
|
||||
/**
|
||||
* @return DataList
|
||||
*/
|
||||
public function getTags() {
|
||||
public function getTags()
|
||||
{
|
||||
$blog = $this->Blog();
|
||||
|
||||
if (!$blog) {
|
||||
@ -92,6 +95,6 @@ class BlogTagsWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
class BlogTagsWidget_Controller extends Widget_Controller {
|
||||
|
||||
class BlogTagsWidget_Controller extends Widget_Controller
|
||||
{
|
||||
}
|
||||
|
@ -3,16 +3,18 @@
|
||||
/**
|
||||
* @mixin PHPUnit_Framework_TestCase
|
||||
*/
|
||||
class BlogCategoryTest extends FunctionalTest {
|
||||
class BlogCategoryTest extends FunctionalTest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
static $fixture_file = 'blog.yml';
|
||||
public static $fixture_file = 'blog.yml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
|
||||
@ -21,7 +23,8 @@ class BlogCategoryTest extends FunctionalTest {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function tearDown() {
|
||||
public function tearDown()
|
||||
{
|
||||
SS_Datetime::clear_mock_now();
|
||||
|
||||
parent::tearDown();
|
||||
@ -31,7 +34,8 @@ class BlogCategoryTest extends FunctionalTest {
|
||||
* Tests that any blog posts returned from $category->BlogPosts() many_many are published,
|
||||
* both by normal 'save & publish' functionality and by publish date.
|
||||
*/
|
||||
public function testBlogPosts() {
|
||||
public function testBlogPosts()
|
||||
{
|
||||
$member = Member::currentUser();
|
||||
|
||||
if ($member) {
|
||||
@ -48,7 +52,8 @@ class BlogCategoryTest extends FunctionalTest {
|
||||
$this->assertEquals(1, $category->BlogPosts()->count(), 'Category blog post count');
|
||||
}
|
||||
|
||||
public function testCanView() {
|
||||
public function testCanView()
|
||||
{
|
||||
$this->useDraftSite();
|
||||
|
||||
$this->objFromFixture('Member', 'Admin');
|
||||
@ -62,7 +67,8 @@ class BlogCategoryTest extends FunctionalTest {
|
||||
/**
|
||||
* The first blog can be viewed by anybody.
|
||||
*/
|
||||
public function testCanEdit() {
|
||||
public function testCanEdit()
|
||||
{
|
||||
$this->useDraftSite();
|
||||
|
||||
$admin = $this->objFromFixture('Member', 'Admin');
|
||||
@ -84,7 +90,8 @@ class BlogCategoryTest extends FunctionalTest {
|
||||
$this->assertTrue($category->canEdit($editor), 'Editor should be able to edit category.');
|
||||
}
|
||||
|
||||
public function testCanCreate() {
|
||||
public function testCanCreate()
|
||||
{
|
||||
$this->useDraftSite();
|
||||
|
||||
$admin = $this->objFromFixture('Member', 'Admin');
|
||||
@ -96,7 +103,8 @@ class BlogCategoryTest extends FunctionalTest {
|
||||
$this->assertTrue($category->canCreate($editor), 'Editor should be able to create category.');
|
||||
}
|
||||
|
||||
public function testCanDelete() {
|
||||
public function testCanDelete()
|
||||
{
|
||||
$this->useDraftSite();
|
||||
|
||||
$admin = $this->objFromFixture('Member', 'Admin');
|
||||
|
@ -3,25 +3,29 @@
|
||||
/**
|
||||
* @mixin PHPUnit_Framework_TestCase
|
||||
*/
|
||||
class BlogPostFilterTest extends SapphireTest {
|
||||
class BlogPostFilterTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
static $fixture_file = 'blog.yml';
|
||||
public static $fixture_file = 'blog.yml';
|
||||
|
||||
public function setUp() {
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown()
|
||||
{
|
||||
SS_Datetime::clear_mock_now();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testFilter() {
|
||||
public function testFilter()
|
||||
{
|
||||
$member = Member::currentUser();
|
||||
|
||||
if ($member) {
|
||||
|
@ -1,23 +1,25 @@
|
||||
<?php
|
||||
|
||||
class BlogPostTest extends SapphireTest {
|
||||
|
||||
class BlogPostTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
static $fixture_file = 'blog.yml';
|
||||
public static $fixture_file = 'blog.yml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function tearDown() {
|
||||
public function tearDown()
|
||||
{
|
||||
SS_Datetime::clear_mock_now();
|
||||
parent::tearDown();
|
||||
}
|
||||
@ -25,14 +27,16 @@ class BlogPostTest extends SapphireTest {
|
||||
/**
|
||||
* @dataProvider canViewProvider
|
||||
*/
|
||||
public function testCanView($date, $user, $page, $canView) {
|
||||
public function testCanView($date, $user, $page, $canView)
|
||||
{
|
||||
$userRecord = $this->objFromFixture('Member', $user);
|
||||
$pageRecord = $this->objFromFixture('BlogPost', $page);
|
||||
SS_Datetime::set_mock_now($date);
|
||||
$this->assertEquals($canView, $pageRecord->canView($userRecord));
|
||||
}
|
||||
|
||||
public function canViewProvider() {
|
||||
public function canViewProvider()
|
||||
{
|
||||
$someFutureDate = '2013-10-10 20:00:00';
|
||||
$somePastDate = '2009-10-10 20:00:00';
|
||||
return array(
|
||||
@ -64,7 +68,8 @@ class BlogPostTest extends SapphireTest {
|
||||
);
|
||||
}
|
||||
|
||||
public function testCandidateAuthors() {
|
||||
public function testCandidateAuthors()
|
||||
{
|
||||
$blogpost = $this->objFromFixture('BlogPost', 'PostC');
|
||||
|
||||
$this->assertEquals(7, $blogpost->getCandidateAuthors()->count());
|
||||
@ -73,7 +78,5 @@ class BlogPostTest extends SapphireTest {
|
||||
Config::inst()->update('BlogPost', 'restrict_authors_to_group', 'BlogUsers');
|
||||
|
||||
$this->assertEquals(3, $blogpost->getCandidateAuthors()->count());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,16 +3,18 @@
|
||||
/**
|
||||
* @mixin PHPUnit_Framework_TestCase
|
||||
*/
|
||||
class BlogTagTest extends FunctionalTest {
|
||||
class BlogTagTest extends FunctionalTest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
static $fixture_file = 'blog.yml';
|
||||
public static $fixture_file = 'blog.yml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
|
||||
@ -21,7 +23,8 @@ class BlogTagTest extends FunctionalTest {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function tearDown() {
|
||||
public function tearDown()
|
||||
{
|
||||
SS_Datetime::clear_mock_now();
|
||||
|
||||
parent::tearDown();
|
||||
@ -31,7 +34,8 @@ class BlogTagTest extends FunctionalTest {
|
||||
* Tests that any blog posts returned from $tag->BlogPosts() many_many are published, both by
|
||||
* normal 'save & publish' functionality and by publish date.
|
||||
*/
|
||||
public function testBlogPosts() {
|
||||
public function testBlogPosts()
|
||||
{
|
||||
$member = Member::currentUser();
|
||||
|
||||
if ($member) {
|
||||
@ -51,7 +55,8 @@ class BlogTagTest extends FunctionalTest {
|
||||
/**
|
||||
* The first blog can be viewed by anybody.
|
||||
*/
|
||||
public function testCanView() {
|
||||
public function testCanView()
|
||||
{
|
||||
$this->useDraftSite();
|
||||
|
||||
$admin = $this->objFromFixture('Member', 'Admin');
|
||||
@ -68,7 +73,8 @@ class BlogTagTest extends FunctionalTest {
|
||||
$this->assertFalse($tag->canView($editor), 'Editor should not be able to view tag.');
|
||||
}
|
||||
|
||||
public function testCanEdit() {
|
||||
public function testCanEdit()
|
||||
{
|
||||
$this->useDraftSite();
|
||||
|
||||
$admin = $this->objFromFixture('Member', 'Admin');
|
||||
@ -90,7 +96,8 @@ class BlogTagTest extends FunctionalTest {
|
||||
$this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.');
|
||||
}
|
||||
|
||||
public function testCanCreate() {
|
||||
public function testCanCreate()
|
||||
{
|
||||
$this->useDraftSite();
|
||||
|
||||
$admin = $this->objFromFixture('Member', 'Admin');
|
||||
@ -102,7 +109,8 @@ class BlogTagTest extends FunctionalTest {
|
||||
$this->assertTrue($tag->canCreate($editor), 'Editor should be able to create tag.');
|
||||
}
|
||||
|
||||
public function testCanDelete() {
|
||||
public function testCanDelete()
|
||||
{
|
||||
$this->useDraftSite();
|
||||
|
||||
$admin = $this->objFromFixture('Member', 'Admin');
|
||||
|
@ -3,16 +3,18 @@
|
||||
/**
|
||||
* @mixin PHPUnit_Framework_TestCase
|
||||
*/
|
||||
class BlogTest extends SapphireTest {
|
||||
class BlogTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
static $fixture_file = 'blog.yml';
|
||||
public static $fixture_file = 'blog.yml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Config::nest();
|
||||
@ -29,14 +31,16 @@ class BlogTest extends SapphireTest {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function tearDown() {
|
||||
public function tearDown()
|
||||
{
|
||||
SS_Datetime::clear_mock_now();
|
||||
Config::unnest();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetExcludedSiteTreeClassNames() {
|
||||
public function testGetExcludedSiteTreeClassNames()
|
||||
{
|
||||
$member = Member::currentUser();
|
||||
|
||||
if ($member) {
|
||||
@ -59,7 +63,8 @@ class BlogTest extends SapphireTest {
|
||||
$this->assertContains('BlogPost', $classes, 'BlogPost class should be hidden.');
|
||||
}
|
||||
|
||||
public function testGetArchivedBlogPosts() {
|
||||
public function testGetArchivedBlogPosts()
|
||||
{
|
||||
$member = Member::currentUser();
|
||||
|
||||
if ($member) {
|
||||
@ -86,7 +91,8 @@ class BlogTest extends SapphireTest {
|
||||
$this->assertEquals(1, $archive->count(), 'Incorrect daily archive count.');
|
||||
}
|
||||
|
||||
public function testArchiveLinks() {
|
||||
public function testArchiveLinks()
|
||||
{
|
||||
/**
|
||||
* @var Blog $blog
|
||||
*/
|
||||
@ -122,13 +128,13 @@ class BlogTest extends SapphireTest {
|
||||
$link = Controller::join_links($blog->Link('archive'), '2013', '10', '99');
|
||||
|
||||
$this->assertEquals(404, $this->getStatusOf($link), 'HTTP Status should be 404');
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Test archive year
|
||||
*/
|
||||
public function testArchiveYear(){
|
||||
public function testArchiveYear()
|
||||
{
|
||||
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
||||
$controller = new Blog_Controller($blog);
|
||||
$this->requestURL($controller, 'first-post/archive/');
|
||||
@ -140,11 +146,13 @@ class BlogTest extends SapphireTest {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getStatusOf($link) {
|
||||
protected function getStatusOf($link)
|
||||
{
|
||||
return Director::test($link)->getStatusCode();
|
||||
}
|
||||
|
||||
public function testRoles() {
|
||||
public function testRoles()
|
||||
{
|
||||
/**
|
||||
* @var Blog $firstBlog
|
||||
*/
|
||||
@ -264,7 +272,8 @@ class BlogTest extends SapphireTest {
|
||||
$this->assertFalse($postC->canPublish($visitor));
|
||||
}
|
||||
|
||||
public function testFilteredCategories() {
|
||||
public function testFilteredCategories()
|
||||
{
|
||||
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
||||
$controller = new Blog_Controller($blog);
|
||||
|
||||
@ -310,7 +319,8 @@ class BlogTest extends SapphireTest {
|
||||
* @param ContentController $controller
|
||||
* @param string $url
|
||||
*/
|
||||
protected function requestURL(ContentController $controller, $url) {
|
||||
protected function requestURL(ContentController $controller, $url)
|
||||
{
|
||||
$request = new SS_HTTPRequest('get', $url);
|
||||
$request->match('$URLSegment//$Action/$ID/$OtherID');
|
||||
$request->shift();
|
||||
@ -324,9 +334,14 @@ class BlogTest extends SapphireTest {
|
||||
* @param array|SS_List $left
|
||||
* @param array|SS_List $right
|
||||
*/
|
||||
protected function assertIDsEquals($left, $right) {
|
||||
if($left instanceof SS_List) $left = $left->column('ID');
|
||||
if($right instanceof SS_List) $right = $right->column('ID');
|
||||
protected function assertIDsEquals($left, $right)
|
||||
{
|
||||
if ($left instanceof SS_List) {
|
||||
$left = $left->column('ID');
|
||||
}
|
||||
if ($right instanceof SS_List) {
|
||||
$right = $right->column('ID');
|
||||
}
|
||||
asort($left);
|
||||
asort($right);
|
||||
$this->assertEquals(array_values($left), array_values($right));
|
||||
|
Loading…
Reference in New Issue
Block a user