mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Move "code" to PSR-4 friendly "src" folders. Add namespacing.
This commit is contained in:
parent
4313643a0b
commit
13a5badff5
@ -5,4 +5,4 @@
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
**/
|
||||||
define('BLOGGER_DIR', ltrim(Director::makeRelative(realpath(__DIR__)), DIRECTORY_SEPARATOR));
|
define('BLOGGER_DIR', dirname(__FILE__));
|
||||||
|
@ -5,13 +5,13 @@ Only:
|
|||||||
---
|
---
|
||||||
Comment:
|
Comment:
|
||||||
extensions:
|
extensions:
|
||||||
- BlogCommentExtension
|
- SilverStripe\Blog\Model\BlogCommentExtension
|
||||||
|
|
||||||
---
|
---
|
||||||
Name: blogcommentnotifications
|
Name: blogcommentnotifications
|
||||||
Only:
|
Only:
|
||||||
moduleexists: 'comment-notifications'
|
moduleexists: 'comment-notifications'
|
||||||
---
|
---
|
||||||
BlogPost:
|
SilverStripe\Blog\Model\BlogPost:
|
||||||
extensions:
|
extensions:
|
||||||
- BlogPostNotifications
|
- SilverStripe\Blog\Model\BlogPostNotifications
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
Name: blogconfig
|
Name: blogconfig
|
||||||
---
|
---
|
||||||
Member:
|
SilverStripe\Security\Member:
|
||||||
extensions:
|
extensions:
|
||||||
- BlogMemberExtension
|
- SilverStripe\Blog\Model\BlogMemberExtension
|
||||||
|
@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated since version 2.0
|
|
||||||
*
|
|
||||||
* @property int $ParentID
|
|
||||||
* @property string $Date
|
|
||||||
* @property string $PublishDate
|
|
||||||
* @property string $Tags
|
|
||||||
*/
|
|
||||||
class BlogEntry extends BlogPost implements MigratableObject
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private static $hide_ancestor = 'BlogEntry';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $db = array(
|
|
||||||
'Date' => 'SS_Datetime',
|
|
||||||
'Author' => 'Text',
|
|
||||||
'Tags' => 'Text',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function canCreate($member = null, $context = array())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
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.
|
|
||||||
$tagObject = new BlogTag();
|
|
||||||
$tagObject->Title = $tag;
|
|
||||||
$tagObject->BlogID = $this->ParentID;
|
|
||||||
$tagObject->write();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($tagObject) {
|
|
||||||
$this->Tags()->add($tagObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Store if the original entity was published or not (draft)
|
|
||||||
$published = $this->IsPublished();
|
|
||||||
// If a user has subclassed BlogEntry, it should not be turned into a BlogPost.
|
|
||||||
if ($this->ClassName === 'BlogEntry') {
|
|
||||||
$this->ClassName = 'BlogPost';
|
|
||||||
$this->RecordClassName = 'BlogPost';
|
|
||||||
}
|
|
||||||
//Migrate these key data attributes
|
|
||||||
$this->PublishDate = $this->Date;
|
|
||||||
$this->AuthorNames = $this->Author;
|
|
||||||
$this->InheritSideBar = true;
|
|
||||||
|
|
||||||
//Write and additionally publish the item if it was published before.
|
|
||||||
$this->write();
|
|
||||||
if ($published) {
|
|
||||||
$this->publish('Stage', 'Live');
|
|
||||||
$message = "PUBLISHED: ";
|
|
||||||
} else {
|
|
||||||
$message = "DRAFT: ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $message . $this->Title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Safely split and parse all distinct tags assigned to this BlogEntry.
|
|
||||||
*
|
|
||||||
* @deprecated since version 2.0
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function TagNames()
|
|
||||||
{
|
|
||||||
$tags = preg_split('/\s*,\s*/', trim($this->Tags));
|
|
||||||
|
|
||||||
$results = array();
|
|
||||||
|
|
||||||
foreach ($tags as $tag) {
|
|
||||||
if ($tag) {
|
|
||||||
$results[mb_strtolower($tag)] = $tag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated since version 2.0
|
|
||||||
*/
|
|
||||||
class BlogEntry_Controller extends BlogPost_Controller
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated since version 2.0
|
|
||||||
*/
|
|
||||||
class BlogHolder extends BlogTree implements MigratableObject
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private static $hide_ancestor = 'BlogHolder';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $db = array(
|
|
||||||
'AllowCustomAuthors' => 'Boolean',
|
|
||||||
'ShowFullEntry' => 'Boolean',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $has_one = array(
|
|
||||||
'Owner' => 'Member',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function canCreate($member = null, $context = array())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Overload these to stop the Uncaught Exception: Object->__call(): the method 'parent' does not exist on 'BlogHolder' error.
|
|
||||||
public function validURLSegment()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public function syncLinkTracking()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$published = $this->IsPublished();
|
|
||||||
|
|
||||||
if ($this->ClassName === 'BlogHolder') {
|
|
||||||
$this->ClassName = 'Blog';
|
|
||||||
$this->RecordClassName = 'Blog';
|
|
||||||
$this->PostsPerPage = 10;
|
|
||||||
$this->write();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($published) {
|
|
||||||
$this->publish('Stage', 'Live');
|
|
||||||
$message = "PUBLISHED: ";
|
|
||||||
} else {
|
|
||||||
$message = "DRAFT: ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $message . $this->Title;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated since version 2.0
|
|
||||||
*/
|
|
||||||
class BlogHolder_Controller extends BlogTree_Controller
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated since version 2.0
|
|
||||||
*/
|
|
||||||
class BlogTree extends Page implements MigratableObject
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private static $hide_ancestor = 'BlogTree';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $db = array(
|
|
||||||
'Name' => 'Varchar(255)',
|
|
||||||
'LandingPageFreshness' => 'Varchar',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function canCreate($member = null, $context = array())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$published = $this->IsPublished();
|
|
||||||
if ($this->ClassName === 'BlogTree') {
|
|
||||||
$this->ClassName = 'Page';
|
|
||||||
$this->RecordClassName = 'Page';
|
|
||||||
$this->write();
|
|
||||||
}
|
|
||||||
if ($published) {
|
|
||||||
$this->publish('Stage', 'Live');
|
|
||||||
$message = "PUBLISHED: ";
|
|
||||||
} else {
|
|
||||||
$message = "DRAFT: ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $message . $this->Title;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated since version 2.0
|
|
||||||
*/
|
|
||||||
class BlogTree_Controller extends Page_Controller
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
class BlogMigrationTask extends MigrationTask
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Should this task be invoked automatically via dev/build?
|
|
||||||
*
|
|
||||||
* @config
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private static $run_during_dev_build = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
if (Controller::curr() instanceof DatabaseAdmin) {
|
|
||||||
DB::alteration_message($text, 'obsolete');
|
|
||||||
} else {
|
|
||||||
echo $text . "<br/>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Migrate records of a single class
|
|
||||||
*
|
|
||||||
* @param string $class
|
|
||||||
* @param null|string $stage
|
|
||||||
*/
|
|
||||||
protected function upClass($class)
|
|
||||||
{
|
|
||||||
if (!class_exists($class)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_subclass_of($class, 'SiteTree')) {
|
|
||||||
$items = SiteTree::get()->filter('ClassName', $class);
|
|
||||||
} else {
|
|
||||||
$items = $class::get();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($count = $items->count()) {
|
|
||||||
$this->message(
|
|
||||||
sprintf(
|
|
||||||
'Migrating %s legacy %s records.',
|
|
||||||
$count,
|
|
||||||
$class
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($items as $item) {
|
|
||||||
$cancel = $item->extend('onBeforeUp');
|
|
||||||
|
|
||||||
if ($cancel && min($cancel) === false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var MigratableObject $item
|
|
||||||
*/
|
|
||||||
$result = $item->up();
|
|
||||||
$this->message($result);
|
|
||||||
|
|
||||||
$item->extend('onAfterUp');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
$this->message('BlogMigrationTask::down() not implemented');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
interface MigratableObject
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Migrate the object up to the current version.
|
|
||||||
*/
|
|
||||||
public function up();
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
if (!class_exists('Widget')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated since version 2.0
|
|
||||||
*
|
|
||||||
* @property string $DisplayMode
|
|
||||||
* @property string $ArchiveType
|
|
||||||
*/
|
|
||||||
class ArchiveWidget extends BlogArchiveWidget implements MigratableObject
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $db = array(
|
|
||||||
'DisplayMode' => 'Varchar',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $only_available_in = array(
|
|
||||||
'none',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function canCreate($member = null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
if ($this->DisplayMode) {
|
|
||||||
$this->ArchiveType = 'Monthly';
|
|
||||||
|
|
||||||
if ($this->DisplayMode === 'year') {
|
|
||||||
$this->ArchiveType = 'Yearly';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->ClassName = 'BlogArchiveWidget';
|
|
||||||
$this->write();
|
|
||||||
return "Migrated " . $this->ArchiveType . " archive widget";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
if (!class_exists('Widget')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A list of tags associated with blog posts.
|
|
||||||
*
|
|
||||||
* @package blog
|
|
||||||
*/
|
|
||||||
class TagCloudWidget extends BlogTagsWidget implements MigratableObject
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $db = array(
|
|
||||||
'Title' => 'Varchar',
|
|
||||||
'Limit' => 'Int',
|
|
||||||
'Sortby' => 'Varchar',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $only_available_in = array(
|
|
||||||
'none',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function canCreate($member = null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
$this->ClassName = 'BlogTagsWidget';
|
|
||||||
$this->write();
|
|
||||||
return "Migrated " . $this->Title . " widget";
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,7 +17,12 @@
|
|||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.x-dev"
|
"dev-master": "3.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"SilverStripe\\Blog\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
|
28
src/.upgrade.yml
Normal file
28
src/.upgrade.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
mappings:
|
||||||
|
GridFieldCategorisationConfig: SilverStripe\Blog\Admin\GridFieldCategorisationConfig
|
||||||
|
GridFieldFormAction: SilverStripe\Blog\Admin\GridFieldFormAction
|
||||||
|
GridFieldMergeAction: SilverStripe\Blog\Admin\GridFieldMergeAction
|
||||||
|
BlogCommentExtension: SilverStripe\Blog\Model\BlogCommentExtension
|
||||||
|
BlogFilter: SilverStripe\Blog\Model\BlogFilter
|
||||||
|
BlogFilter_GridField: SilverStripe\Blog\Model\BlogFilter_GridField
|
||||||
|
BlogMemberExtension: SilverStripe\Blog\Model\BlogMemberExtension
|
||||||
|
BlogPostFilter: SilverStripe\Blog\Model\BlogPostFilter
|
||||||
|
BlogPostNotifications: SilverStripe\Blog\Model\BlogPostNotifications
|
||||||
|
Blog: SilverStripe\Blog\Model\Blog
|
||||||
|
Blog_Controller: SilverStripe\Blog\Controllers\BlogController
|
||||||
|
BlogController: SilverStripe\Blog\Controllers\BlogController
|
||||||
|
BlogCategory: SilverStripe\Blog\Model\BlogCategory
|
||||||
|
BlogPost: SilverStripe\Blog\Model\BlogPost
|
||||||
|
BlogPost_Controller: SilverStripe\Blog\Controllers\BlogPostController
|
||||||
|
BlogPostController: SilverStripe\Blog\Controllers\BlogPostController
|
||||||
|
BlogTag: SilverStripe\Blog\Model\BlogTag
|
||||||
|
CategorisationObject: SilverStripe\Blog\Model\CategorisationObject
|
||||||
|
BlogAdminSidebar: SilverStripe\Blog\Forms\BlogAdminSidebar
|
||||||
|
GridFieldAddByDBField: SilverStripe\Blog\Forms\GridField\GridFieldAddByDBField
|
||||||
|
GridFieldBlogPostState: SilverStripe\Blog\Forms\GridField\GridFieldBlogPostState
|
||||||
|
GridFieldConfig_BlogPost: SilverStripe\Blog\Forms\GridField\GridFieldConfig_BlogPost
|
||||||
|
BlogArchiveWidget: SilverStripe\Blog\Widgets\BlogArchiveWidget
|
||||||
|
BlogCategoriesWidget: SilverStripe\Blog\Widgets\BlogCategoriesWidget
|
||||||
|
BlogRecentPostsWidget: SilverStripe\Blog\Widgets\BlogRecentPostsWidget
|
||||||
|
BlogTagsCloudWidget: SilverStripe\Blog\Widgets\BlogTagsCloudWidget
|
||||||
|
BlogTagsWidget: SilverStripe\Blog\Widgets\BlogTagsWidget
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Admin;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Form\GridField\GridFieldAddByDBField;
|
||||||
|
use SilverStripe\Blog\Admin\GridFieldMergeAction;
|
||||||
|
use SilverStripe\Blog\Model\CategorisationObject;
|
||||||
|
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
|
||||||
|
|
||||||
class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -47,11 +54,13 @@ class GridFieldCategorisationConfig extends GridFieldConfig_RecordEditor
|
|||||||
*/
|
*/
|
||||||
$columns = $this->getComponentByType('GridFieldDataColumns');
|
$columns = $this->getComponentByType('GridFieldDataColumns');
|
||||||
|
|
||||||
$columns->setDisplayFields(array(
|
$columns->setDisplayFields(
|
||||||
|
array(
|
||||||
'Title' => 'Title',
|
'Title' => 'Title',
|
||||||
'BlogPostsCount' => 'Posts',
|
'BlogPostsCount' => 'Posts',
|
||||||
'MergeAction' => 'MergeAction',
|
'MergeAction' => 'MergeAction',
|
||||||
'Actions' => 'Actions',
|
'Actions' => 'Actions'
|
||||||
));
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Admin;
|
||||||
|
|
||||||
|
use GridField_FormAction;
|
||||||
|
|
||||||
class GridFieldFormAction extends GridField_FormAction
|
class GridFieldFormAction extends GridField_FormAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
@ -1,5 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Admin;
|
||||||
|
|
||||||
|
use GridField_ColumnProvider;
|
||||||
|
use GridField_ActionProvider;
|
||||||
|
use DropdownField;
|
||||||
|
|
||||||
|
use GridField;
|
||||||
|
use Controller;
|
||||||
|
use SilverStripe\Blog\Admin\GridFieldFormAction;
|
||||||
|
|
||||||
|
|
||||||
class GridFieldMergeAction implements GridField_ColumnProvider, GridField_ActionProvider
|
class GridFieldMergeAction implements GridField_ColumnProvider, GridField_ActionProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
517
src/Controllers/BlogController.php
Normal file
517
src/Controllers/BlogController.php
Normal file
@ -0,0 +1,517 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Controllers;
|
||||||
|
|
||||||
|
use Page_Controller;
|
||||||
|
use SilverStripe\Control\RSS\RSSFeed;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\PaginatedList;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package silverstripe
|
||||||
|
* @subpackage blog
|
||||||
|
*/
|
||||||
|
class BlogController extends Page_Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $allowed_actions = array(
|
||||||
|
'archive',
|
||||||
|
'tag',
|
||||||
|
'category',
|
||||||
|
'rss',
|
||||||
|
'profile'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $url_handlers = array(
|
||||||
|
'tag/$Tag!/$Rss' => 'tag',
|
||||||
|
'category/$Category!/$Rss' => 'category',
|
||||||
|
'archive/$Year!/$Month/$Day' => 'archive',
|
||||||
|
'profile/$URLSegment!' => 'profile'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $casting = array(
|
||||||
|
'MetaTitle' => 'Text',
|
||||||
|
'FilterDescription' => 'Text'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current Blog Post DataList query.
|
||||||
|
*
|
||||||
|
* @var DataList
|
||||||
|
*/
|
||||||
|
protected $blogPosts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Blog $dataRecord
|
||||||
|
*/
|
||||||
|
$dataRecord = $this->dataRecord;
|
||||||
|
|
||||||
|
$this->blogPosts = $dataRecord->getBlogPosts();
|
||||||
|
|
||||||
|
return $this->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders a Blog Member's profile.
|
||||||
|
*
|
||||||
|
* @return SS_HTTPResponse
|
||||||
|
*/
|
||||||
|
public function profile()
|
||||||
|
{
|
||||||
|
$profile = $this->getCurrentProfile();
|
||||||
|
|
||||||
|
if (!$profile) {
|
||||||
|
return $this->httpError(404, 'Not Found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->blogPosts = $this->getCurrentProfilePosts();
|
||||||
|
|
||||||
|
return $this->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Member associated with the current URL segment.
|
||||||
|
*
|
||||||
|
* @return null|Member
|
||||||
|
*/
|
||||||
|
public function getCurrentProfile()
|
||||||
|
{
|
||||||
|
$urlSegment = $this->request->param('URLSegment');
|
||||||
|
|
||||||
|
if ($urlSegment) {
|
||||||
|
return Member::get()
|
||||||
|
->filter('URLSegment', $urlSegment)
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get posts related to the current Member profile.
|
||||||
|
*
|
||||||
|
* @return null|DataList
|
||||||
|
*/
|
||||||
|
public function getCurrentProfilePosts()
|
||||||
|
{
|
||||||
|
$profile = $this->getCurrentProfile();
|
||||||
|
|
||||||
|
if ($profile) {
|
||||||
|
return $profile->BlogPosts()->filter('ParentID', $this->ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders an archive for a specified date. This can be by year or year/month.
|
||||||
|
*
|
||||||
|
* @return null|SS_HTTPResponse
|
||||||
|
*/
|
||||||
|
public function archive()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Blog $dataRecord
|
||||||
|
*/
|
||||||
|
$dataRecord = $this->dataRecord;
|
||||||
|
|
||||||
|
$year = $this->getArchiveYear();
|
||||||
|
$month = $this->getArchiveMonth();
|
||||||
|
$day = $this->getArchiveDay();
|
||||||
|
|
||||||
|
if ($this->request->param('Month') && !$month) {
|
||||||
|
$this->httpError(404, 'Not Found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($month && $this->request->param('Day') && !$day) {
|
||||||
|
$this->httpError(404, 'Not Found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($year) {
|
||||||
|
$this->blogPosts = $dataRecord->getArchivedBlogPosts($year, $month, $day);
|
||||||
|
|
||||||
|
return $this->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->httpError(404, 'Not Found');
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches the archive year from the url.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getArchiveYear()
|
||||||
|
{
|
||||||
|
if ($this->request->param('Year')) {
|
||||||
|
if (preg_match('/^[0-9]{4}$/', $year = $this->request->param('Year'))) {
|
||||||
|
return (int) $year;
|
||||||
|
}
|
||||||
|
} elseif ($this->request->param('Action') == 'archive') {
|
||||||
|
return DBDatetime::now()->Year();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches the archive money from the url.
|
||||||
|
*
|
||||||
|
* @return null|int
|
||||||
|
*/
|
||||||
|
public function getArchiveMonth()
|
||||||
|
{
|
||||||
|
$month = $this->request->param('Month');
|
||||||
|
|
||||||
|
if (preg_match('/^[0-9]{1,2}$/', $month)) {
|
||||||
|
if ($month > 0 && $month < 13) {
|
||||||
|
if (checkdate($month, 01, $this->getArchiveYear())) {
|
||||||
|
return (int) $month;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches the archive day from the url.
|
||||||
|
*
|
||||||
|
* @return null|int
|
||||||
|
*/
|
||||||
|
public function getArchiveDay()
|
||||||
|
{
|
||||||
|
$day = $this->request->param('Day');
|
||||||
|
|
||||||
|
if (preg_match('/^[0-9]{1,2}$/', $day)) {
|
||||||
|
if (checkdate($this->getArchiveMonth(), $day, $this->getArchiveYear())) {
|
||||||
|
return (int) $day;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the blog posts for a given tag.
|
||||||
|
*
|
||||||
|
* @return null|HTTPResponse
|
||||||
|
*/
|
||||||
|
public function tag()
|
||||||
|
{
|
||||||
|
$tag = $this->getCurrentTag();
|
||||||
|
|
||||||
|
if ($tag) {
|
||||||
|
$this->blogPosts = $tag->BlogPosts();
|
||||||
|
|
||||||
|
if($this->isRSS()) {
|
||||||
|
return $this->rssFeed($this->blogPosts, $tag->getLink());
|
||||||
|
} else {
|
||||||
|
return $this->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->httpError(404, 'Not Found');
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tag Getter for use in templates.
|
||||||
|
*
|
||||||
|
* @return null|BlogTag
|
||||||
|
*/
|
||||||
|
public function getCurrentTag()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Blog $dataRecord
|
||||||
|
*/
|
||||||
|
$dataRecord = $this->dataRecord;
|
||||||
|
$tag = $this->request->param('Tag');
|
||||||
|
if ($tag) {
|
||||||
|
return $dataRecord->Tags()
|
||||||
|
->filter('URLSegment', array($tag, rawurlencode($tag)))
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the blog posts for a given category.
|
||||||
|
*
|
||||||
|
* @return null|SS_HTTPResponse
|
||||||
|
*/
|
||||||
|
public function category()
|
||||||
|
{
|
||||||
|
$category = $this->getCurrentCategory();
|
||||||
|
|
||||||
|
if ($category) {
|
||||||
|
$this->blogPosts = $category->BlogPosts();
|
||||||
|
|
||||||
|
if($this->isRSS()) {
|
||||||
|
return $this->rssFeed($this->blogPosts, $category->getLink());
|
||||||
|
} else {
|
||||||
|
return $this->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->httpError(404, 'Not Found');
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Category Getter for use in templates.
|
||||||
|
*
|
||||||
|
* @return null|BlogCategory
|
||||||
|
*/
|
||||||
|
public function getCurrentCategory()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Blog $dataRecord
|
||||||
|
*/
|
||||||
|
$dataRecord = $this->dataRecord;
|
||||||
|
$category = $this->request->param('Category');
|
||||||
|
if ($category) {
|
||||||
|
return $dataRecord->Categories()
|
||||||
|
->filter('URLSegment', array($category, rawurlencode($category)))
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the meta title for the current action.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getMetaTitle()
|
||||||
|
{
|
||||||
|
$title = $this->data()->getTitle();
|
||||||
|
$filter = $this->getFilterDescription();
|
||||||
|
|
||||||
|
if ($filter) {
|
||||||
|
$title = sprintf('%s - %s', $title, $filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->extend('updateMetaTitle', $title);
|
||||||
|
|
||||||
|
return $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a description of the current filter.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFilterDescription()
|
||||||
|
{
|
||||||
|
$items = array();
|
||||||
|
|
||||||
|
$list = $this->PaginatedList();
|
||||||
|
$currentPage = $list->CurrentPage();
|
||||||
|
|
||||||
|
if ($currentPage > 1) {
|
||||||
|
$items[] = _t(
|
||||||
|
'Blog.FILTERDESCRIPTION_PAGE',
|
||||||
|
'Page {page}',
|
||||||
|
null,
|
||||||
|
array(
|
||||||
|
'page' => $currentPage
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($author = $this->getCurrentProfile()) {
|
||||||
|
$items[] = _t(
|
||||||
|
'Blog.FILTERDESCRIPTION_AUTHOR',
|
||||||
|
'By {author}',
|
||||||
|
null,
|
||||||
|
array(
|
||||||
|
'author' => $author->Title
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($tag = $this->getCurrentTag()) {
|
||||||
|
$items[] = _t(
|
||||||
|
'Blog.FILTERDESCRIPTION_TAG',
|
||||||
|
'Tagged with {tag}',
|
||||||
|
null,
|
||||||
|
array(
|
||||||
|
'tag' => $tag->Title
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($category = $this->getCurrentCategory()) {
|
||||||
|
$items[] = _t(
|
||||||
|
'Blog.FILTERDESCRIPTION_CATEGORY',
|
||||||
|
'In category {category}',
|
||||||
|
null,
|
||||||
|
array(
|
||||||
|
'category' => $category->Title
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->owner->getArchiveYear()) {
|
||||||
|
if ($this->owner->getArchiveDay()) {
|
||||||
|
$date = $this->owner->getArchiveDate()->Nice();
|
||||||
|
} elseif ($this->owner->getArchiveMonth()) {
|
||||||
|
$date = $this->owner->getArchiveDate()->format('F, Y');
|
||||||
|
} else {
|
||||||
|
$date = $this->owner->getArchiveDate()->format('Y');
|
||||||
|
}
|
||||||
|
|
||||||
|
$items[] = _t(
|
||||||
|
'Blog.FILTERDESCRIPTION_DATE',
|
||||||
|
'In {date}',
|
||||||
|
null,
|
||||||
|
array(
|
||||||
|
'date' => $date,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = '';
|
||||||
|
|
||||||
|
if ($items) {
|
||||||
|
$result = implode(', ', $items);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->extend('updateFilterDescription', $result);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of paginated blog posts based on the BlogPost dataList.
|
||||||
|
*
|
||||||
|
* @return PaginatedList
|
||||||
|
*/
|
||||||
|
public function PaginatedList()
|
||||||
|
{
|
||||||
|
$allPosts = $this->blogPosts ?: ArrayList::create();
|
||||||
|
|
||||||
|
$posts = PaginatedList::create($allPosts);
|
||||||
|
|
||||||
|
// Set appropriate page size
|
||||||
|
if ($this->PostsPerPage > 0) {
|
||||||
|
$pageSize = $this->PostsPerPage;
|
||||||
|
} elseif ($count = $allPosts->count()) {
|
||||||
|
$pageSize = $count;
|
||||||
|
} else {
|
||||||
|
$pageSize = 99999;
|
||||||
|
}
|
||||||
|
$posts->setPageLength($pageSize);
|
||||||
|
|
||||||
|
// Set current page
|
||||||
|
$start = $this->request->getVar($posts->getPaginationGetVar());
|
||||||
|
$posts->setPageStart($start);
|
||||||
|
|
||||||
|
return $posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays an RSS feed of blog posts.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function rss()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Blog $dataRecord
|
||||||
|
*/
|
||||||
|
$dataRecord = $this->dataRecord;
|
||||||
|
|
||||||
|
$this->blogPosts = $dataRecord->getBlogPosts();
|
||||||
|
|
||||||
|
return $this->rssFeed($this->blogPosts, $this->Link());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current archive date.
|
||||||
|
*
|
||||||
|
* @return null|Date
|
||||||
|
*/
|
||||||
|
public function getArchiveDate()
|
||||||
|
{
|
||||||
|
$year = $this->getArchiveYear();
|
||||||
|
$month = $this->getArchiveMonth();
|
||||||
|
$day = $this->getArchiveDay();
|
||||||
|
|
||||||
|
if ($year) {
|
||||||
|
if ($month) {
|
||||||
|
$date = sprintf('%s-%s-01', $year, $month);
|
||||||
|
|
||||||
|
if ($day) {
|
||||||
|
$date = sprintf('%s-%s-%s', $year, $month, $day);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$date = sprintf('%s-01-01', $year);
|
||||||
|
}
|
||||||
|
|
||||||
|
$obj = DBDatetime::create('date');
|
||||||
|
$obj->setValue($date);
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a link to the RSS feed.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRSSLink()
|
||||||
|
{
|
||||||
|
return $this->Link('rss');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays an RSS feed of the given blog posts.
|
||||||
|
*
|
||||||
|
* @param DataList $blogPosts
|
||||||
|
* @param string $link
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function rssFeed($blogPosts, $link)
|
||||||
|
{
|
||||||
|
$rss = new RSSFeed($blogPosts, $link, $this->MetaTitle, $this->MetaDescription);
|
||||||
|
|
||||||
|
$this->extend('updateRss', $rss);
|
||||||
|
|
||||||
|
return $rss->outputToBrowser();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the $Rss sub-action for categories/tags has been set to "rss"
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isRSS()
|
||||||
|
{
|
||||||
|
$rss = $this->request->param('Rss');
|
||||||
|
return (is_string($rss) && strcasecmp($rss, 'rss') == 0);
|
||||||
|
}
|
||||||
|
}
|
14
src/Controllers/BlogPostController.php
Normal file
14
src/Controllers/BlogPostController.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Controllers;
|
||||||
|
|
||||||
|
use Page_Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package silverstripe
|
||||||
|
* @subpackage blog
|
||||||
|
*/
|
||||||
|
class BlogPostController extends Page_Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Forms;
|
||||||
|
|
||||||
|
use SilverStripe\Forms\FieldGroup;
|
||||||
|
use SilverStripe\Control\Cookie;
|
||||||
|
|
||||||
class BlogAdminSidebar extends FieldGroup
|
class BlogAdminSidebar extends FieldGroup
|
||||||
{
|
{
|
||||||
/**
|
/**
|
@ -1,5 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Forms\GridField;
|
||||||
|
|
||||||
|
use UnexpectedValueException;
|
||||||
|
use SilverStripe\Control\Controller;
|
||||||
|
use SilverStripe\Core\Convert;
|
||||||
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
|
use SilverStripe\Forms\GridField\GridField_ActionProvider;
|
||||||
|
use SilverStripe\Forms\GridField\GridField_FormAction;
|
||||||
|
use SilverStripe\Forms\GridField\GridField_HTMLProvider;
|
||||||
|
use SilverStripe\Forms\TextField;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\Security\Security;
|
||||||
|
use SilverStripe\View\ArrayData;
|
||||||
|
use SilverStripe\View\Requirements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a component which allows a user to add a new DataObject by database field.
|
* Adds a component which allows a user to add a new DataObject by database field.
|
||||||
*
|
*
|
||||||
@ -195,7 +210,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
|
|||||||
$forTemplate->Fields->push($addAction);
|
$forTemplate->Fields->push($addAction);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
$this->targetFragment => $forTemplate->renderWith('GridFieldAddByDBField')
|
$this->targetFragment => $forTemplate->renderWith('SilverStripe\\Blog\\Form\\GridField\\GridFieldAddByDBField')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Forms\GridField;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\BlogPost;
|
||||||
|
use SilverStripe\Lumberjack\Forms\GridFieldSiteTreeState;
|
||||||
|
use SilverStripe\View\Requirements;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a component to the {@link GridField} which tells the user whether or not a blog post
|
* Provides a component to the {@link GridField} which tells the user whether or not a blog post
|
||||||
* has been published and when.
|
* has been published and when.
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Forms\GridField;
|
||||||
|
|
||||||
|
use SilverStripe\Lumberjack\Forms\GridFieldConfig_Lumberjack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GridField config necessary for managing a SiteTree object.
|
* GridField config necessary for managing a SiteTree object.
|
||||||
*
|
*
|
@ -1,6 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBDatetime;
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
|
use Page;
|
||||||
|
use Page_Controller;
|
||||||
|
use SilverStripe\Blog\Admin\GridFieldCategorisationConfig;
|
||||||
|
use SilverStripe\Blog\Forms\GridField\GridFieldConfig_BlogPost;
|
||||||
|
use SilverStripe\Control\Controller;
|
||||||
|
use SilverStripe\Control\RSS\RSSFeed;
|
||||||
|
use SilverStripe\Core\Convert;
|
||||||
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
|
use SilverStripe\Forms\ListboxField;
|
||||||
|
use SilverStripe\Forms\NumericField;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\PaginatedList;
|
||||||
|
use SilverStripe\ORM\UnsavedRelationList;
|
||||||
|
use SilverStripe\Security\Group;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\Security\PermissionProvider;
|
||||||
|
use SilverStripe\View\Requirements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blog Holder
|
* Blog Holder
|
||||||
@ -52,6 +74,12 @@ class Blog extends Page implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
private static $grant_user_group = 'blog-users';
|
private static $grant_user_group = 'blog-users';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private static $table_name = 'Blog';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@ -63,31 +91,31 @@ class Blog extends Page implements PermissionProvider
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_many = array(
|
private static $has_many = array(
|
||||||
'Tags' => 'BlogTag',
|
'Tags' => 'SilverStripe\\Blog\\Model\\BlogTag',
|
||||||
'Categories' => 'BlogCategory',
|
'Categories' => 'SilverStripe\\Blog\\Model\\BlogCategory',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
'Editors' => 'Member',
|
'Editors' => 'SilverStripe\\Security\\Member',
|
||||||
'Writers' => 'Member',
|
'Writers' => 'SilverStripe\\Security\\Member',
|
||||||
'Contributors' => 'Member',
|
'Contributors' => 'SilverStripe\\Security\\Member',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $allowed_children = array(
|
private static $allowed_children = array(
|
||||||
'BlogPost',
|
'SilverStripe\\Blog\\Model\\BlogPost',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'BlogFilter',
|
'SilverStripe\\Blog\\Model\\BlogFilter',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +123,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
private static $defaults = array(
|
private static $defaults = array(
|
||||||
'ProvideComments' => false,
|
'ProvideComments' => false,
|
||||||
'PostsPerPage' => 10,
|
'PostsPerPage' => 10
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,14 +152,14 @@ 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'), 'BlogCategory', 'Categories', 'BlogPosts')
|
GridFieldCategorisationConfig::create(15, $self->Categories()->sort('Title'), 'SilverStripe\\Blog\\Model\\BlogCategory', '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'), 'BlogTag', 'Tags', 'BlogPosts')
|
GridFieldCategorisationConfig::create(15, $self->Tags()->sort('Title'), 'SilverStripe\\Blog\\Model\\BlogTag', 'Tags', 'BlogPosts')
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -473,7 +501,7 @@ class Blog extends Page implements PermissionProvider
|
|||||||
$stage = '_' . $stage;
|
$stage = '_' . $stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query->innerJoin('BlogPost', sprintf('"SiteTree%s"."ID" = "BlogPost%s"."ID"', $stage, $stage));
|
$query->innerJoin('SilverStripe\\Blog\\Model\\BlogPost', sprintf('"SiteTree%s"."ID" = "BlogPost%s"."ID"', $stage, $stage));
|
||||||
|
|
||||||
$conn = DB::getConn();
|
$conn = DB::getConn();
|
||||||
|
|
||||||
@ -624,512 +652,3 @@ class Blog extends Page implements PermissionProvider
|
|||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
|
||||||
class Blog_Controller extends Page_Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $allowed_actions = array(
|
|
||||||
'archive',
|
|
||||||
'tag',
|
|
||||||
'category',
|
|
||||||
'rss',
|
|
||||||
'profile',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $url_handlers = array(
|
|
||||||
'tag/$Tag!/$Rss' => 'tag',
|
|
||||||
'category/$Category!/$Rss' => 'category',
|
|
||||||
'archive/$Year!/$Month/$Day' => 'archive',
|
|
||||||
'profile/$URLSegment!' => 'profile',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $casting = array(
|
|
||||||
'MetaTitle' => 'Text',
|
|
||||||
'FilterDescription' => 'Text',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current Blog Post DataList query.
|
|
||||||
*
|
|
||||||
* @var DataList
|
|
||||||
*/
|
|
||||||
protected $blogPosts;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Blog $dataRecord
|
|
||||||
*/
|
|
||||||
$dataRecord = $this->dataRecord;
|
|
||||||
|
|
||||||
$this->blogPosts = $dataRecord->getBlogPosts();
|
|
||||||
|
|
||||||
return $this->render();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders a Blog Member's profile.
|
|
||||||
*
|
|
||||||
* @return SS_HTTPResponse
|
|
||||||
*/
|
|
||||||
public function profile()
|
|
||||||
{
|
|
||||||
$profile = $this->getCurrentProfile();
|
|
||||||
|
|
||||||
if (!$profile) {
|
|
||||||
return $this->httpError(404, 'Not Found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->blogPosts = $this->getCurrentProfilePosts();
|
|
||||||
|
|
||||||
return $this->render();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the Member associated with the current URL segment.
|
|
||||||
*
|
|
||||||
* @return null|Member
|
|
||||||
*/
|
|
||||||
public function getCurrentProfile()
|
|
||||||
{
|
|
||||||
$urlSegment = $this->request->param('URLSegment');
|
|
||||||
|
|
||||||
if ($urlSegment) {
|
|
||||||
return Member::get()
|
|
||||||
->filter('URLSegment', $urlSegment)
|
|
||||||
->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get posts related to the current Member profile.
|
|
||||||
*
|
|
||||||
* @return null|DataList
|
|
||||||
*/
|
|
||||||
public function getCurrentProfilePosts()
|
|
||||||
{
|
|
||||||
$profile = $this->getCurrentProfile();
|
|
||||||
|
|
||||||
if ($profile) {
|
|
||||||
return $profile->BlogPosts()->filter('ParentID', $this->ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders an archive for a specified date. This can be by year or year/month.
|
|
||||||
*
|
|
||||||
* @return null|SS_HTTPResponse
|
|
||||||
*/
|
|
||||||
public function archive()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Blog $dataRecord
|
|
||||||
*/
|
|
||||||
$dataRecord = $this->dataRecord;
|
|
||||||
|
|
||||||
$year = $this->getArchiveYear();
|
|
||||||
$month = $this->getArchiveMonth();
|
|
||||||
$day = $this->getArchiveDay();
|
|
||||||
|
|
||||||
if ($this->request->param('Month') && !$month) {
|
|
||||||
$this->httpError(404, 'Not Found');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($month && $this->request->param('Day') && !$day) {
|
|
||||||
$this->httpError(404, 'Not Found');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($year) {
|
|
||||||
$this->blogPosts = $dataRecord->getArchivedBlogPosts($year, $month, $day);
|
|
||||||
|
|
||||||
return $this->render();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->httpError(404, 'Not Found');
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the archive year from the url.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public function getArchiveYear()
|
|
||||||
{
|
|
||||||
if ($this->request->param('Year')) {
|
|
||||||
if (preg_match('/^[0-9]{4}$/', $year = $this->request->param('Year'))) {
|
|
||||||
return (int) $year;
|
|
||||||
}
|
|
||||||
} elseif ($this->request->param('Action') == 'archive') {
|
|
||||||
return SS_Datetime::now()->Year();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the archive money from the url.
|
|
||||||
*
|
|
||||||
* @return null|int
|
|
||||||
*/
|
|
||||||
public function getArchiveMonth()
|
|
||||||
{
|
|
||||||
$month = $this->request->param('Month');
|
|
||||||
|
|
||||||
if (preg_match('/^[0-9]{1,2}$/', $month)) {
|
|
||||||
if ($month > 0 && $month < 13) {
|
|
||||||
if (checkdate($month, 01, $this->getArchiveYear())) {
|
|
||||||
return (int) $month;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the archive day from the url.
|
|
||||||
*
|
|
||||||
* @return null|int
|
|
||||||
*/
|
|
||||||
public function getArchiveDay()
|
|
||||||
{
|
|
||||||
$day = $this->request->param('Day');
|
|
||||||
|
|
||||||
if (preg_match('/^[0-9]{1,2}$/', $day)) {
|
|
||||||
if (checkdate($this->getArchiveMonth(), $day, $this->getArchiveYear())) {
|
|
||||||
return (int) $day;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the blog posts for a given tag.
|
|
||||||
*
|
|
||||||
* @return null|SS_HTTPResponse
|
|
||||||
*/
|
|
||||||
public function tag()
|
|
||||||
{
|
|
||||||
$tag = $this->getCurrentTag();
|
|
||||||
|
|
||||||
if ($tag) {
|
|
||||||
$this->blogPosts = $tag->BlogPosts();
|
|
||||||
|
|
||||||
if($this->isRSS()) {
|
|
||||||
return $this->rssFeed($this->blogPosts, $tag->getLink());
|
|
||||||
} else {
|
|
||||||
return $this->render();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->httpError(404, 'Not Found');
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tag Getter for use in templates.
|
|
||||||
*
|
|
||||||
* @return null|BlogTag
|
|
||||||
*/
|
|
||||||
public function getCurrentTag()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Blog $dataRecord
|
|
||||||
*/
|
|
||||||
$dataRecord = $this->dataRecord;
|
|
||||||
$tag = $this->request->param('Tag');
|
|
||||||
if ($tag) {
|
|
||||||
return $dataRecord->Tags()
|
|
||||||
->filter('URLSegment', array($tag, rawurlencode($tag)))
|
|
||||||
->first();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the blog posts for a given category.
|
|
||||||
*
|
|
||||||
* @return null|SS_HTTPResponse
|
|
||||||
*/
|
|
||||||
public function category()
|
|
||||||
{
|
|
||||||
$category = $this->getCurrentCategory();
|
|
||||||
|
|
||||||
if ($category) {
|
|
||||||
$this->blogPosts = $category->BlogPosts();
|
|
||||||
|
|
||||||
if($this->isRSS()) {
|
|
||||||
return $this->rssFeed($this->blogPosts, $category->getLink());
|
|
||||||
} else {
|
|
||||||
return $this->render();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->httpError(404, 'Not Found');
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Category Getter for use in templates.
|
|
||||||
*
|
|
||||||
* @return null|BlogCategory
|
|
||||||
*/
|
|
||||||
public function getCurrentCategory()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Blog $dataRecord
|
|
||||||
*/
|
|
||||||
$dataRecord = $this->dataRecord;
|
|
||||||
$category = $this->request->param('Category');
|
|
||||||
if ($category) {
|
|
||||||
return $dataRecord->Categories()
|
|
||||||
->filter('URLSegment', array($category, rawurlencode($category)))
|
|
||||||
->first();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the meta title for the current action.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getMetaTitle()
|
|
||||||
{
|
|
||||||
$title = $this->data()->getTitle();
|
|
||||||
$filter = $this->getFilterDescription();
|
|
||||||
|
|
||||||
if ($filter) {
|
|
||||||
$title = sprintf('%s - %s', $title, $filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->extend('updateMetaTitle', $title);
|
|
||||||
|
|
||||||
return $title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a description of the current filter.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getFilterDescription()
|
|
||||||
{
|
|
||||||
$items = array();
|
|
||||||
|
|
||||||
$list = $this->PaginatedList();
|
|
||||||
$currentPage = $list->CurrentPage();
|
|
||||||
|
|
||||||
if ($currentPage > 1) {
|
|
||||||
$items[] = _t(
|
|
||||||
'Blog.FILTERDESCRIPTION_PAGE',
|
|
||||||
'Page {page}',
|
|
||||||
null,
|
|
||||||
array(
|
|
||||||
'page' => $currentPage,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($author = $this->getCurrentProfile()) {
|
|
||||||
$items[] = _t(
|
|
||||||
'Blog.FILTERDESCRIPTION_AUTHOR',
|
|
||||||
'By {author}',
|
|
||||||
null,
|
|
||||||
array(
|
|
||||||
'author' => $author->Title,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($tag = $this->getCurrentTag()) {
|
|
||||||
$items[] = _t(
|
|
||||||
'Blog.FILTERDESCRIPTION_TAG',
|
|
||||||
'Tagged with {tag}',
|
|
||||||
null,
|
|
||||||
array(
|
|
||||||
'tag' => $tag->Title,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($category = $this->getCurrentCategory()) {
|
|
||||||
$items[] = _t(
|
|
||||||
'Blog.FILTERDESCRIPTION_CATEGORY',
|
|
||||||
'In category {category}',
|
|
||||||
null,
|
|
||||||
array(
|
|
||||||
'category' => $category->Title,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->owner->getArchiveYear()) {
|
|
||||||
if ($this->owner->getArchiveDay()) {
|
|
||||||
$date = $this->owner->getArchiveDate()->Nice();
|
|
||||||
} elseif ($this->owner->getArchiveMonth()) {
|
|
||||||
$date = $this->owner->getArchiveDate()->format('F, Y');
|
|
||||||
} else {
|
|
||||||
$date = $this->owner->getArchiveDate()->format('Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
$items[] = _t(
|
|
||||||
'Blog.FILTERDESCRIPTION_DATE',
|
|
||||||
'In {date}',
|
|
||||||
null,
|
|
||||||
array(
|
|
||||||
'date' => $date,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = '';
|
|
||||||
|
|
||||||
if ($items) {
|
|
||||||
$result = implode(', ', $items);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->extend('updateFilterDescription', $result);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of paginated blog posts based on the BlogPost dataList.
|
|
||||||
*
|
|
||||||
* @return PaginatedList
|
|
||||||
*/
|
|
||||||
public function PaginatedList()
|
|
||||||
{
|
|
||||||
$allPosts = $this->blogPosts ?: new ArrayList();
|
|
||||||
|
|
||||||
$posts = new PaginatedList($allPosts);
|
|
||||||
|
|
||||||
// Set appropriate page size
|
|
||||||
if ($this->PostsPerPage > 0) {
|
|
||||||
$pageSize = $this->PostsPerPage;
|
|
||||||
} elseif ($count = $allPosts->count()) {
|
|
||||||
$pageSize = $count;
|
|
||||||
} else {
|
|
||||||
$pageSize = 99999;
|
|
||||||
}
|
|
||||||
$posts->setPageLength($pageSize);
|
|
||||||
|
|
||||||
// Set current page
|
|
||||||
$start = $this->request->getVar($posts->getPaginationGetVar());
|
|
||||||
$posts->setPageStart($start);
|
|
||||||
|
|
||||||
return $posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays an RSS feed of blog posts.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function rss()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Blog $dataRecord
|
|
||||||
*/
|
|
||||||
$dataRecord = $this->dataRecord;
|
|
||||||
|
|
||||||
$this->blogPosts = $dataRecord->getBlogPosts();
|
|
||||||
|
|
||||||
return $this->rssFeed($this->blogPosts, $this->Link());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current archive date.
|
|
||||||
*
|
|
||||||
* @return null|Date
|
|
||||||
*/
|
|
||||||
public function getArchiveDate()
|
|
||||||
{
|
|
||||||
$year = $this->getArchiveYear();
|
|
||||||
$month = $this->getArchiveMonth();
|
|
||||||
$day = $this->getArchiveDay();
|
|
||||||
|
|
||||||
if ($year) {
|
|
||||||
if ($month) {
|
|
||||||
$date = sprintf('%s-%s-01', $year, $month);
|
|
||||||
|
|
||||||
if ($day) {
|
|
||||||
$date = sprintf('%s-%s-%s', $year, $month, $day);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$date = sprintf('%s-01-01', $year);
|
|
||||||
}
|
|
||||||
|
|
||||||
$obj = new DBDatetime('date');
|
|
||||||
$obj->setValue($date);
|
|
||||||
return $obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a link to the RSS feed.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getRSSLink()
|
|
||||||
{
|
|
||||||
return $this->Link('rss');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays an RSS feed of the given blog posts.
|
|
||||||
*
|
|
||||||
* @param DataList $blogPosts
|
|
||||||
* @param string $link
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function rssFeed($blogPosts, $link)
|
|
||||||
{
|
|
||||||
$rss = new RSSFeed($blogPosts, $link, $this->MetaTitle, $this->MetaDescription);
|
|
||||||
|
|
||||||
$this->extend('updateRss', $rss);
|
|
||||||
|
|
||||||
return $rss->outputToBrowser();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the $Rss sub-action for categories/tags has been set to "rss"
|
|
||||||
*/
|
|
||||||
private function isRSS()
|
|
||||||
{
|
|
||||||
$rss = $this->request->param('Rss');
|
|
||||||
if(is_string($rss) && strcasecmp($rss, "rss") == 0) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\BlogObject;
|
||||||
|
use SilverStripe\Blog\Model\CategorisationObject;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A blog category for generalising blog posts.
|
* A blog category for generalising blog posts.
|
||||||
*
|
*
|
||||||
@ -25,26 +31,32 @@ class BlogCategory extends DataObject implements CategorisationObject
|
|||||||
*/
|
*/
|
||||||
const DUPLICATE_EXCEPTION = 'DUPLICATE';
|
const DUPLICATE_EXCEPTION = 'DUPLICATE';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private static $table_name = 'BlogCategory';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'Title' => 'Varchar(255)',
|
'Title' => 'Varchar(255)',
|
||||||
'URLSegment' => 'Varchar(255)',
|
'URLSegment' => 'Varchar(255)'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Blog' => 'Blog',
|
'Blog' => 'SilverStripe\\Blog\\Model\\Blog',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
'BlogPosts' => 'BlogPost',
|
'BlogPosts' => 'SilverStripe\\Blog\\Model\\BlogPost',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\BlogPost;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds Blog specific behaviour to Comment.
|
* Adds Blog specific behaviour to Comment.
|
||||||
*/
|
*/
|
@ -1,5 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\Blog;
|
||||||
|
use SilverStripe\Blog\Model\BlogPost;
|
||||||
|
use SilverStripe\Core\ClassInfo;
|
||||||
|
use SilverStripe\Core\Convert;
|
||||||
|
use SilverStripe\Forms\FieldList;
|
||||||
|
use SilverStripe\Forms\FormTransformation;
|
||||||
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
|
use SilverStripe\Forms\Tab;
|
||||||
|
use SilverStripe\Lumberjack\Model\Lumberjack;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is responsible for filtering the SiteTree when necessary and also overlaps into
|
* This class is responsible for filtering the SiteTree when necessary and also overlaps into
|
||||||
* filtering only published posts.
|
* filtering only published posts.
|
||||||
@ -27,7 +42,7 @@ class BlogFilter extends Lumberjack
|
|||||||
|
|
||||||
$dataQuery = $staged->dataQuery()
|
$dataQuery = $staged->dataQuery()
|
||||||
->innerJoin('BlogPost', sprintf('"BlogPost%s"."ID" = "SiteTree%s"."ID"', $stage, $stage))
|
->innerJoin('BlogPost', sprintf('"BlogPost%s"."ID" = "SiteTree%s"."ID"', $stage, $stage))
|
||||||
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(SS_Datetime::now())));
|
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
||||||
|
|
||||||
$staged = $staged->setDataQuery($dataQuery);
|
$staged = $staged->setDataQuery($dataQuery);
|
||||||
}
|
}
|
||||||
@ -40,7 +55,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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,7 +68,7 @@ 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('BlogPost', '"BlogPost_Live"."ID" = "SiteTree_Live"."ID"')
|
||||||
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(SS_Datetime::now())));
|
->where(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now())));
|
||||||
|
|
||||||
$staged = $staged->setDataQuery($dataQuery);
|
$staged = $staged->setDataQuery($dataQuery);
|
||||||
}
|
}
|
||||||
@ -82,14 +97,14 @@ class BlogFilter extends Lumberjack
|
|||||||
'ClassName' => $excluded
|
'ClassName' => $excluded
|
||||||
));
|
));
|
||||||
|
|
||||||
$gridField = new BlogFilter_GridField(
|
$gridField = BlogFilter_GridField::create(
|
||||||
'ChildPages',
|
'ChildPages',
|
||||||
$this->getLumberjackTitle(),
|
$this->getLumberjackTitle(),
|
||||||
$pages,
|
$pages,
|
||||||
$this->getLumberjackGridFieldConfig()
|
$this->getLumberjackGridFieldConfig()
|
||||||
);
|
);
|
||||||
|
|
||||||
$tab = new Tab('ChildPages', $this->getLumberjackTitle(), $gridField);
|
$tab = Tab::create('ChildPages', $this->getLumberjackTitle(), $gridField);
|
||||||
|
|
||||||
$fields->insertBefore($tab, 'Main');
|
$fields->insertBefore($tab, 'Main');
|
||||||
}
|
}
|
@ -1,5 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Forms\GridField\GridFieldConfig_BlogPost;
|
||||||
|
use SilverStripe\Forms\FieldList;
|
||||||
|
use SilverStripe\Forms\GridField\GridField;
|
||||||
|
use SilverStripe\Forms\Tab;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\View\Parsers\URLSegmentFilter;
|
||||||
|
use SilverStripe\View\Requirements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is responsible for add Blog specific behaviour to Members.
|
* This class is responsible for add Blog specific behaviour to Members.
|
||||||
*
|
*
|
||||||
@ -27,7 +38,7 @@ class BlogMemberExtension extends DataExtension
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
'BlogPosts' => 'BlogPost',
|
'BlogPosts' => 'SilverStripe\\Blog\\Model\\BlogPost',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +91,6 @@ class BlogMemberExtension extends DataExtension
|
|||||||
return $conflict->count() == 0;
|
return $conflict->count() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -97,13 +107,13 @@ class BlogMemberExtension extends DataExtension
|
|||||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
||||||
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
|
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
|
||||||
|
|
||||||
$tab = new Tab('BlogPosts', 'Blog Posts');
|
$tab = Tab::create('BlogPosts', 'Blog Posts');
|
||||||
|
|
||||||
$gridField = new GridField(
|
$gridField = GridField::create(
|
||||||
'BlogPosts',
|
'BlogPosts',
|
||||||
'Blog Posts',
|
'Blog Posts',
|
||||||
$this->owner->BlogPosts(),
|
$this->owner->BlogPosts(),
|
||||||
new GridFieldConfig_BlogPost()
|
GridFieldConfig_BlogPost::create()
|
||||||
);
|
);
|
||||||
|
|
||||||
$tab->Fields()->add($gridField);
|
$tab->Fields()->add($gridField);
|
@ -1,13 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
|
use SilverStripe\Control\Controller;
|
||||||
|
use SilverStripe\Forms\FieldList;
|
||||||
|
use SilverStripe\Forms\Tab;
|
||||||
|
use SilverStripe\Forms\TabSet;
|
||||||
|
use SilverStripe\Forms\TextField;
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\View\Parsers\URLSegmentFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object shared by BlogTag and BlogCategory.
|
* An object shared by BlogTag and BlogCategory.
|
||||||
*
|
*
|
||||||
* @package silverstripe
|
* @package silverstripe
|
||||||
* @subpackage blog
|
* @subpackage blog
|
||||||
*/
|
*/
|
||||||
trait BlogObject {
|
trait BlogObject
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @return DataList
|
* @return DataList
|
||||||
*/
|
*/
|
||||||
@ -25,8 +36,8 @@ trait BlogObject {
|
|||||||
*/
|
*/
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = new TabSet('Root',
|
$fields = TabSet::create('Root',
|
||||||
new Tab('Main',
|
Tab::create('Main',
|
||||||
TextField::create('Title', _t(self::class . '.Title', 'Title'))
|
TextField::create('Title', _t(self::class . '.Title', 'Title'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -39,21 +50,23 @@ trait BlogObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
* @return ValidationResult
|
||||||
*/
|
*/
|
||||||
public function validate()
|
public function validate()
|
||||||
{
|
{
|
||||||
|
/** @var ValidationResult $validation */
|
||||||
$validation = parent::validate();
|
$validation = parent::validate();
|
||||||
if(!$validation->valid()) {
|
if (!$validation->isValid()) {
|
||||||
return $validation;
|
return $validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
$blog = $this->Blog();
|
$blog = $this->Blog();
|
||||||
if(!$blog || !$blog->exists()) {
|
if (!$blog || !$blog->exists()) {
|
||||||
return $validation;
|
return $validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->getDuplicatesByUrlSegment()->count() > 0) {
|
if ($this->getDuplicatesByUrlSegment()->count() > 0) {
|
||||||
$validation->error($this->getDuplicateError(), self::DUPLICATE_EXCEPTION);
|
$validation->addError($this->getDuplicateError(), self::DUPLICATE_EXCEPTION);
|
||||||
}
|
}
|
||||||
return $validation;
|
return $validation;
|
||||||
}
|
}
|
||||||
@ -163,7 +176,7 @@ trait BlogObject {
|
|||||||
public function generateURLSegment($increment = 0)
|
public function generateURLSegment($increment = 0)
|
||||||
{
|
{
|
||||||
$increment = (int) $increment;
|
$increment = (int) $increment;
|
||||||
$filter = new URLSegmentFilter();
|
$filter = URLSegmentFilter::create();
|
||||||
|
|
||||||
$this->URLSegment = $filter->filter($this->owner->Title);
|
$this->URLSegment = $filter->filter($this->owner->Title);
|
||||||
|
|
||||||
@ -185,10 +198,13 @@ trait BlogObject {
|
|||||||
*/
|
*/
|
||||||
protected function getDuplicatesByUrlSegment()
|
protected function getDuplicatesByUrlSegment()
|
||||||
{
|
{
|
||||||
$duplicates = DataList::create(self::class)->filter(array(
|
$duplicates = DataList::create(self::class)
|
||||||
|
->filter(
|
||||||
|
array(
|
||||||
'URLSegment' => $this->URLSegment,
|
'URLSegment' => $this->URLSegment,
|
||||||
'BlogID' => (int) $this->BlogID,
|
'BlogID' => (int) $this->BlogID,
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if ($this->ID) {
|
if ($this->ID) {
|
||||||
$duplicates = $duplicates->exclude('ID', $this->ID);
|
$duplicates = $duplicates->exclude('ID', $this->ID);
|
||||||
@ -217,5 +233,4 @@ trait BlogObject {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
abstract protected function getDuplicateError();
|
abstract protected function getDuplicateError();
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
|
use Page;
|
||||||
|
use SilverStripe\Blog\Forms\BlogAdminSidebar;
|
||||||
|
use SilverStripe\Control\Controller;
|
||||||
|
use SilverStripe\Forms\DatetimeField;
|
||||||
|
use SilverStripe\Forms\HiddenField;
|
||||||
|
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
|
||||||
|
use SilverStripe\Forms\ListboxField;
|
||||||
|
use SilverStripe\Forms\TextField;
|
||||||
|
use SilverStripe\Forms\ToggleCompositeField;
|
||||||
|
use SilverStripe\Forms\UploadField;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\UnsavedRelationList;
|
||||||
|
use SilverStripe\Security\Group;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
use SilverStripe\TagField\TagField;
|
||||||
|
use SilverStripe\View\ArrayData;
|
||||||
|
use SilverStripe\View\Requirements;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An individual blog post.
|
* An individual blog post.
|
||||||
*
|
*
|
||||||
@ -24,11 +46,17 @@ class BlogPost extends Page
|
|||||||
*/
|
*/
|
||||||
private static $restrict_authors_to_group = false;
|
private static $restrict_authors_to_group = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private static $table_name = 'BlogPost';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'PublishDate' => 'SS_Datetime',
|
'PublishDate' => 'Datetime',
|
||||||
'AuthorNames' => 'Varchar(1024)',
|
'AuthorNames' => 'Varchar(1024)',
|
||||||
'Summary' => 'HTMLText',
|
'Summary' => 'HTMLText',
|
||||||
);
|
);
|
||||||
@ -37,16 +65,16 @@ class BlogPost extends Page
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'FeaturedImage' => 'Image',
|
'FeaturedImage' => 'SilverStripe\\Assets\\Image',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
'Categories' => 'BlogCategory',
|
'Categories' => 'SilverStripe\\Blog\\Model\\BlogCategory',
|
||||||
'Tags' => 'BlogTag',
|
'Tags' => 'SilverStripe\\Blog\\Model\\BlogTag',
|
||||||
'Authors' => 'Member',
|
'Authors' => 'SilverStripe\\Security\\Member',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,21 +90,21 @@ class BlogPost extends Page
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'BlogPostFilter',
|
'SilverStripe\\Blog\\Model\\BlogPostFilter'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $searchable_fields = array(
|
private static $searchable_fields = array(
|
||||||
'Title',
|
'Title'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $summary_fields = array(
|
private static $summary_fields = array(
|
||||||
'Title',
|
'Title'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,7 +112,7 @@ class BlogPost extends Page
|
|||||||
*/
|
*/
|
||||||
private static $casting = array(
|
private static $casting = array(
|
||||||
'Excerpt' => 'HTMLText',
|
'Excerpt' => 'HTMLText',
|
||||||
'Date' => 'SS_Datetime',
|
'Date' => 'SS_Datetime'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -412,12 +440,12 @@ class BlogPost extends Page
|
|||||||
public function onBeforePublish()
|
public function onBeforePublish()
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var SS_Datetime $publishDate
|
* @var DBDatetime $publishDate
|
||||||
*/
|
*/
|
||||||
$publishDate = $this->dbObject('PublishDate');
|
$publishDate = $this->dbObject('PublishDate');
|
||||||
|
|
||||||
if (!$publishDate->getValue()) {
|
if (!$publishDate->getValue()) {
|
||||||
$this->PublishDate = SS_Datetime::now()->getValue();
|
$this->PublishDate = DBDatetime::now()->getValue();
|
||||||
$this->write();
|
$this->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,7 +492,7 @@ class BlogPost extends Page
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SS_Datetime $publishDate
|
* @var DBDatetime $publishDate
|
||||||
*/
|
*/
|
||||||
$publishDate = $this->dbObject('PublishDate');
|
$publishDate = $this->dbObject('PublishDate');
|
||||||
if(!$publishDate->exists()) {
|
if(!$publishDate->exists()) {
|
||||||
@ -563,7 +591,7 @@ class BlogPost extends Page
|
|||||||
public function getMonthlyArchiveLink($type = 'day')
|
public function getMonthlyArchiveLink($type = 'day')
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var SS_Datetime $date
|
* @var DBDatetime $date
|
||||||
*/
|
*/
|
||||||
$date = $this->dbObject('PublishDate');
|
$date = $this->dbObject('PublishDate');
|
||||||
|
|
||||||
@ -591,7 +619,7 @@ class BlogPost extends Page
|
|||||||
public function getYearlyArchiveLink()
|
public function getYearlyArchiveLink()
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var SS_Datetime $date
|
* @var DBDatetime $date
|
||||||
*/
|
*/
|
||||||
$date = $this->dbObject('PublishDate');
|
$date = $this->dbObject('PublishDate');
|
||||||
|
|
||||||
@ -706,11 +734,3 @@ class BlogPost extends Page
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @package silverstripe
|
|
||||||
* @subpackage blog
|
|
||||||
*/
|
|
||||||
class BlogPost_Controller extends Page_Controller
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,5 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
|
use SilverStripe\Admin\LeftAndMain;
|
||||||
|
use SilverStripe\Control\Controller;
|
||||||
|
use SilverStripe\Core\Convert;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\ORM\DataQuery;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\Security\Permission;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is responsible for filtering only published posts to users who do not have permission to
|
* This is responsible for filtering only published posts to users who do not have permission to
|
||||||
* view non-published posts.
|
* view non-published posts.
|
||||||
@ -25,27 +37,26 @@ class BlogPostFilter extends DataExtension
|
|||||||
if ($stage == 'Live' || !Permission::check('VIEW_DRAFT_CONTENT')) {
|
if ($stage == 'Live' || !Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||||
$query->addWhere(sprintf(
|
$query->addWhere(sprintf(
|
||||||
'"PublishDate" < \'%s\'',
|
'"PublishDate" < \'%s\'',
|
||||||
Convert::raw2sql(SS_Datetime::now())
|
Convert::raw2sql(DBDatetime::now())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
* This is a fix so that when we try to fetch subclasses of BlogPost, lazy loading includes the
|
* This is a fix so that when we try to fetch subclasses of BlogPost, lazy loading includes the
|
||||||
* BlogPost table in its query. Leaving this table out means the default sort order column
|
* BlogPost table in its query. Leaving this table out means the default sort order column
|
||||||
* PublishDate causes an error.
|
* PublishDate causes an error.
|
||||||
*
|
*
|
||||||
* @see https://github.com/silverstripe/silverstripe-framework/issues/1682
|
* @see https://github.com/silverstripe/silverstripe-framework/issues/1682
|
||||||
*
|
*
|
||||||
* @param SQLQuery $query
|
* @param SQLSelect $query
|
||||||
* @param mixed $dataQuery
|
* @param DataQuery $dataQuery
|
||||||
* @param mixed $parent
|
* @param DataObject $dataObject
|
||||||
*/
|
*/
|
||||||
public function augmentLoadLazyFields(
|
public function augmentLoadLazyFields(SQLSelect &$query, DataQuery &$dataQuery = null, $dataObject)
|
||||||
SQLSelect &$query,
|
{
|
||||||
DataQuery &$dataQuery = null,
|
|
||||||
$dataObject
|
|
||||||
) {
|
|
||||||
$dataQuery->innerJoin('BlogPost', '"SiteTree"."ID" = "BlogPost"."ID"');
|
$dataQuery->innerJoin('BlogPost', '"SiteTree"."ID" = "BlogPost"."ID"');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customise blog post to support comment notifications.
|
* Customise blog post to support comment notifications.
|
||||||
*
|
*
|
@ -1,5 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\Blog\Model\BlogObject;
|
||||||
|
use SilverStripe\Blog\Model\CategorisationObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A blog tag for keyword descriptions of a blog post.
|
* A blog tag for keyword descriptions of a blog post.
|
||||||
*
|
*
|
||||||
@ -23,28 +29,34 @@ class BlogTag extends DataObject implements CategorisationObject
|
|||||||
* @const string
|
* @const string
|
||||||
* This must be a string because ValidationException has decided we can't use int
|
* This must be a string because ValidationException has decided we can't use int
|
||||||
*/
|
*/
|
||||||
const DUPLICATE_EXCEPTION = "DUPLICATE";
|
const DUPLICATE_EXCEPTION = 'DUPLICATE';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private static $table_name = 'BlogTag';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'Title' => 'Varchar(255)',
|
'Title' => 'Varchar(255)',
|
||||||
'URLSegment' => 'Varchar(255)',
|
'URLSegment' => 'Varchar(255)'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Blog' => 'Blog',
|
'Blog' => 'SilverStripe\\Blog\\Model\\Blog',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
||||||
'BlogPosts' => 'BlogPost',
|
'BlogPosts' => 'SilverStripe\\Blog\\Model\\BlogPost',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method ManyManyList BlogPosts
|
* @method ManyManyList BlogPosts
|
||||||
*/
|
*/
|
||||||
interface CategorisationObject
|
interface CategorisationObject
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Widgets;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\Blog;
|
||||||
|
|
||||||
if (!class_exists('Widget')) {
|
if (!class_exists('Widget')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -46,7 +50,7 @@ class BlogArchiveWidget extends Widget
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Blog' => 'Blog',
|
'Blog' => 'SilverStripe\\Blog\\Model\\Blog',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +76,7 @@ class BlogArchiveWidget extends Widget
|
|||||||
* @var FieldList $fields
|
* @var FieldList $fields
|
||||||
*/
|
*/
|
||||||
$fields->merge(array(
|
$fields->merge(array(
|
||||||
DropdownField::create('BlogID', _t('BlogArchiveWidget.Blog', 'Blog'), Blog::get()->map()),
|
DropdownField::create('BlogID', _t('BlogArchiveWidget.Blog', 'SilverStripe\\Blog\\Model\\Blog'), Blog::get()->map()),
|
||||||
DropdownField::create('ArchiveType', _t('BlogArchiveWidget.ArchiveType', 'ArchiveType'), $type),
|
DropdownField::create('ArchiveType', _t('BlogArchiveWidget.ArchiveType', 'ArchiveType'), $type),
|
||||||
NumericField::create('NumberToDisplay', _t('BlogArchiveWidget.NumberToDisplay', 'No. to Display'))
|
NumericField::create('NumberToDisplay', _t('BlogArchiveWidget.NumberToDisplay', 'No. to Display'))
|
||||||
));
|
));
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!class_exists("Widget")) {
|
namespace SilverStripe\Blog\Widgets;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\Blog;
|
||||||
|
|
||||||
|
if (!class_exists('Widget')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +41,7 @@ class BlogCategoriesWidget extends Widget
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Blog' => 'Blog',
|
'Blog' => 'SilverStripe\\Blog\\Model\\Blog',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +51,7 @@ class BlogCategoriesWidget extends Widget
|
|||||||
{
|
{
|
||||||
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
$this->beforeUpdateCMSFields(function (FieldList $fields) {
|
||||||
$fields[] = DropdownField::create(
|
$fields[] = DropdownField::create(
|
||||||
'BlogID', _t('BlogCategoriesWidget.Blog', 'Blog'), Blog::get()->map()
|
'BlogID', _t('BlogCategoriesWidget.Blog', 'SilverStripe\\Blog\\Model\\Blog'), Blog::get()->map()
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields[] = NumericField::create(
|
$fields[] = NumericField::create(
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!class_exists("Widget")) {
|
namespace SilverStripe\Blog\Widgets;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\Blog;
|
||||||
|
|
||||||
|
if (!class_exists('Widget')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +41,7 @@ class BlogRecentPostsWidget extends Widget
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Blog' => 'Blog',
|
'Blog' => 'SilverStripe\\Blog\\Model\\Blog',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +54,7 @@ class BlogRecentPostsWidget extends Widget
|
|||||||
* @var FieldList $fields
|
* @var FieldList $fields
|
||||||
*/
|
*/
|
||||||
$fields->merge(array(
|
$fields->merge(array(
|
||||||
DropdownField::create('BlogID', _t('BlogRecentPostsWidget.Blog', 'Blog'), Blog::get()->map()),
|
DropdownField::create('BlogID', _t('BlogRecentPostsWidget.Blog', 'SilverStripe\\Blog\\Model\\Blog'), Blog::get()->map()),
|
||||||
NumericField::create('NumberOfPosts', _t('BlogRecentPostsWidget.NumberOfPosts', 'Number of Posts'))
|
NumericField::create('NumberOfPosts', _t('BlogRecentPostsWidget.NumberOfPosts', 'Number of Posts'))
|
||||||
));
|
));
|
||||||
});
|
});
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\Blog\Widgets;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\Blog;
|
||||||
|
|
||||||
if (!class_exists('Widget')) {
|
if (!class_exists('Widget')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -33,7 +37,7 @@ class BlogTagsCloudWidget extends Widget
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Blog' => 'Blog',
|
'Blog' => 'SilverStripe\\Blog\\Model\\Blog',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +51,7 @@ class BlogTagsCloudWidget extends Widget
|
|||||||
*/
|
*/
|
||||||
$fields->push(
|
$fields->push(
|
||||||
DropdownField::create('BlogID', _t('BlogTagsCloudWidget.Blog',
|
DropdownField::create('BlogID', _t('BlogTagsCloudWidget.Blog',
|
||||||
'Blog'), Blog::get()->map())
|
'SilverStripe\\Blog\\Model\\Blog'), Blog::get()->map())
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!class_exists("Widget")) {
|
namespace SilverStripe\Blog\Widgets;
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\Blog;
|
||||||
|
|
||||||
|
if (!class_exists('Widget')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +41,7 @@ class BlogTagsWidget extends Widget
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Blog' => 'Blog',
|
'Blog' => 'SilverStripe\\Blog\\Model\\Blog',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +51,7 @@ class BlogTagsWidget extends Widget
|
|||||||
{
|
{
|
||||||
$this->beforeUpdateCMSFields(function (Fieldlist $fields) {
|
$this->beforeUpdateCMSFields(function (Fieldlist $fields) {
|
||||||
$fields[] = DropdownField::create(
|
$fields[] = DropdownField::create(
|
||||||
'BlogID', _t('BlogTagsWidget.Blog', 'Blog'), Blog::get()->map()
|
'BlogID', _t('BlogTagsWidget.Blog', 'SilverStripe\\Blog\\Model\\Blog'), Blog::get()->map()
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields[] = NumericField::create(
|
$fields[] = NumericField::create(
|
@ -1,5 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\Blog;
|
||||||
|
use SilverStripe\Blog\Model\BlogCategory;
|
||||||
|
use SilverStripe\Blog\Model\BlogTag;
|
||||||
|
use SilverStripe\Dev\FunctionalTest;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
* @mixin PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
@ -17,7 +25,7 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
|
DBDatetime::set_mock_now('2013-10-10 20:00:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,7 +33,7 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
*/
|
*/
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
SS_Datetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
@ -42,12 +50,12 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
$member->logout();
|
$member->logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->objFromFixture('BlogPost', 'FirstBlogPost');
|
$this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'FirstBlogPost');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var BlogCategory $category
|
* @var BlogCategory $category
|
||||||
*/
|
*/
|
||||||
$category = $this->objFromFixture('BlogCategory', 'FirstCategory');
|
$category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'FirstCategory');
|
||||||
|
|
||||||
$this->assertEquals(5, $category->BlogPosts()->count(), 'Category blog post count');
|
$this->assertEquals(5, $category->BlogPosts()->count(), 'Category blog post count');
|
||||||
}
|
}
|
||||||
@ -72,10 +80,10 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
|
|
||||||
$this->objFromFixture('Member', 'Admin');
|
$this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
|
||||||
|
|
||||||
$editor = $this->objFromFixture('Member', 'Editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
|
||||||
$category = $this->objFromFixture('BlogCategory', 'SecondCategory');
|
$category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'SecondCategory');
|
||||||
|
|
||||||
$this->assertFalse($category->canView($editor), 'Editor should not be able to view category.');
|
$this->assertFalse($category->canView($editor), 'Editor should not be able to view category.');
|
||||||
}
|
}
|
||||||
@ -87,20 +95,20 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
|
|
||||||
$admin = $this->objFromFixture('Member', 'Admin');
|
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
|
||||||
$editor = $this->objFromFixture('Member', 'Editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
|
||||||
|
|
||||||
$category = $this->objFromFixture('BlogCategory', 'FirstCategory');
|
$category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'FirstCategory');
|
||||||
|
|
||||||
$this->assertTrue($category->canEdit($admin), 'Admin should be able to edit category.');
|
$this->assertTrue($category->canEdit($admin), 'Admin should be able to edit category.');
|
||||||
$this->assertTrue($category->canEdit($editor), 'Editor should be able to edit category.');
|
$this->assertTrue($category->canEdit($editor), 'Editor should be able to edit category.');
|
||||||
|
|
||||||
$category = $this->objFromFixture('BlogCategory', 'SecondCategory');
|
$category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'SecondCategory');
|
||||||
|
|
||||||
$this->assertTrue($category->canEdit($admin), 'Admin should be able to edit category.');
|
$this->assertTrue($category->canEdit($admin), 'Admin should be able to edit category.');
|
||||||
$this->assertFalse($category->canEdit($editor), 'Editor should not be able to edit category.');
|
$this->assertFalse($category->canEdit($editor), 'Editor should not be able to edit category.');
|
||||||
|
|
||||||
$category = $this->objFromFixture('BlogCategory', 'ThirdCategory');
|
$category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'ThirdCategory');
|
||||||
|
|
||||||
$this->assertTrue($category->canEdit($admin), 'Admin should always be able to edit category.');
|
$this->assertTrue($category->canEdit($admin), 'Admin should always be able to edit category.');
|
||||||
$this->assertTrue($category->canEdit($editor), 'Editor should be able to edit category.');
|
$this->assertTrue($category->canEdit($editor), 'Editor should be able to edit category.');
|
||||||
@ -110,10 +118,10 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
|
|
||||||
$admin = $this->objFromFixture('Member', 'Admin');
|
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
|
||||||
$editor = $this->objFromFixture('Member', 'Editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
|
||||||
|
|
||||||
$category = singleton('BlogCategory');
|
$category = singleton('SilverStripe\\Blog\\Model\\BlogCategory');
|
||||||
|
|
||||||
$this->assertTrue($category->canCreate($admin), 'Admin should be able to create category.');
|
$this->assertTrue($category->canCreate($admin), 'Admin should be able to create category.');
|
||||||
$this->assertTrue($category->canCreate($editor), 'Editor should be able to create category.');
|
$this->assertTrue($category->canCreate($editor), 'Editor should be able to create category.');
|
||||||
@ -123,24 +131,25 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
|
|
||||||
$admin = $this->objFromFixture('Member', 'Admin');
|
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
|
||||||
$editor = $this->objFromFixture('Member', 'Editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
|
||||||
|
|
||||||
$category = $this->objFromFixture('BlogCategory', 'FirstCategory');
|
$category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'FirstCategory');
|
||||||
|
|
||||||
$this->assertTrue($category->canDelete($admin), 'Admin should be able to delete category.');
|
$this->assertTrue($category->canDelete($admin), 'Admin should be able to delete category.');
|
||||||
$this->assertTrue($category->canDelete($editor), 'Editor should be able to category category.');
|
$this->assertTrue($category->canDelete($editor), 'Editor should be able to category category.');
|
||||||
|
|
||||||
$category = $this->objFromFixture('BlogCategory', 'SecondCategory');
|
$category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'SecondCategory');
|
||||||
$this->assertTrue($category->canDelete($admin), 'Admin should be able to delete category.');
|
$this->assertTrue($category->canDelete($admin), 'Admin should be able to delete category.');
|
||||||
$this->assertFalse($category->canDelete($editor), 'Editor should not be able to delete category.');
|
$this->assertFalse($category->canDelete($editor), 'Editor should not be able to delete category.');
|
||||||
|
|
||||||
$category = $this->objFromFixture('BlogCategory', 'ThirdCategory');
|
$category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'ThirdCategory');
|
||||||
$this->assertTrue($category->canDelete($admin), 'Admin should always be able to delete category.');
|
$this->assertTrue($category->canDelete($admin), 'Admin should always be able to delete category.');
|
||||||
$this->assertTrue($category->canDelete($editor), 'Editor should be able to delete category.');
|
$this->assertTrue($category->canDelete($editor), 'Editor should be able to delete category.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDuplicateCategories() {
|
public function testDuplicateCategories()
|
||||||
|
{
|
||||||
$blog = new Blog();
|
$blog = new Blog();
|
||||||
$blog->Title = 'Testing for duplicate categories';
|
$blog->Title = 'Testing for duplicate categories';
|
||||||
$blog->write();
|
$blog->write();
|
||||||
@ -159,9 +168,9 @@ class BlogCategoryTest extends FunctionalTest
|
|||||||
$category->write();
|
$category->write();
|
||||||
$this->fail('Duplicate BlogCategory written');
|
$this->fail('Duplicate BlogCategory written');
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$codeList = $e->getResult()->codeList();
|
$messages = $e->getResult()->getMessages();
|
||||||
$this->assertCount(1, $codeList);
|
$this->assertCount(1, $messages);
|
||||||
$this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $codeList[0]);
|
$this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $messages[0]['messageType']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
* @mixin PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
@ -14,12 +18,12 @@ class BlogPostFilterTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
|
DBDatetime::set_mock_now('2013-10-10 20:00:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
SS_Datetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
@ -35,11 +39,11 @@ class BlogPostFilterTest extends SapphireTest
|
|||||||
/**
|
/**
|
||||||
* @var Blog $blog
|
* @var Blog $blog
|
||||||
*/
|
*/
|
||||||
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
$blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
|
||||||
|
|
||||||
$this->assertEquals(3, $blog->AllChildren()->Count(), 'Filtered blog posts');
|
$this->assertEquals(3, $blog->AllChildren()->Count(), 'Filtered blog posts');
|
||||||
|
|
||||||
SS_Datetime::set_mock_now('2020-01-01 00:00:00');
|
DBDatetime::set_mock_now('2020-01-01 00:00:00');
|
||||||
|
|
||||||
$this->assertEquals(5, $blog->AllChildren()->Count(), 'Unfiltered blog posts');
|
$this->assertEquals(5, $blog->AllChildren()->Count(), 'Unfiltered blog posts');
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
|
||||||
class BlogPostNotificationsTest extends SapphireTest
|
class BlogPostNotificationsTest extends SapphireTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public static $fixture_file = 'blog.yml';
|
public static $fixture_file = 'blog.yml';
|
||||||
@ -13,7 +16,7 @@ class BlogPostNotificationsTest extends SapphireTest
|
|||||||
$this->markTestSkipped('Comments Notification module is not installed');
|
$this->markTestSkipped('Comments Notification module is not installed');
|
||||||
}
|
}
|
||||||
|
|
||||||
$blogPost = $this->objFromFixture('BlogPost', 'PostC');
|
$blogPost = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'PostC');
|
||||||
$comment = new Comment();
|
$comment = new Comment();
|
||||||
$comment->Comment = 'This is a comment';
|
$comment->Comment = 'This is a comment';
|
||||||
$comment->write();
|
$comment->write();
|
||||||
@ -27,8 +30,10 @@ class BlogPostNotificationsTest extends SapphireTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
sort($segments);
|
sort($segments);
|
||||||
$this->assertEquals(array('blog-contributor', 'blog-editor',
|
$this->assertEquals(
|
||||||
'blog-writer', ), $segments);
|
array('blog-contributor', 'blog-editor', 'blog-writer'),
|
||||||
|
$segments
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpdateNotificationSubject()
|
public function testUpdateNotificationSubject()
|
||||||
@ -36,7 +41,7 @@ class BlogPostNotificationsTest extends SapphireTest
|
|||||||
if (!class_exists('CommentNotifier')) {
|
if (!class_exists('CommentNotifier')) {
|
||||||
$this->markTestSkipped('Comments Notification module is not installed');
|
$this->markTestSkipped('Comments Notification module is not installed');
|
||||||
}
|
}
|
||||||
$blogPost = $this->objFromFixture('BlogPost', 'PostC');
|
$blogPost = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'PostC');
|
||||||
$comment = new Comment();
|
$comment = new Comment();
|
||||||
$comment->Comment = 'This is a comment';
|
$comment->Comment = 'This is a comment';
|
||||||
$comment->write();
|
$comment->write();
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Core\Config\Config;
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
|
||||||
class BlogPostTest extends SapphireTest
|
class BlogPostTest extends SapphireTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public static $fixture_file = 'blog.yml';
|
public static $fixture_file = 'blog.yml';
|
||||||
@ -20,7 +25,7 @@ class BlogPostTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
SS_Datetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,12 +34,15 @@ class BlogPostTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testCanView($date, $user, $page, $canView)
|
public function testCanView($date, $user, $page, $canView)
|
||||||
{
|
{
|
||||||
$userRecord = $this->objFromFixture('Member', $user);
|
$userRecord = $this->objFromFixture('SilverStripe\\Security\\Member', $user);
|
||||||
$pageRecord = $this->objFromFixture('BlogPost', $page);
|
$pageRecord = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', $page);
|
||||||
SS_Datetime::set_mock_now($date);
|
DBDatetime::set_mock_now($date);
|
||||||
$this->assertEquals($canView, $pageRecord->canView($userRecord));
|
$this->assertEquals($canView, $pageRecord->canView($userRecord));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function canViewProvider()
|
public function canViewProvider()
|
||||||
{
|
{
|
||||||
$someFutureDate = '2013-10-10 20:00:00';
|
$someFutureDate = '2013-10-10 20:00:00';
|
||||||
@ -70,12 +78,12 @@ class BlogPostTest extends SapphireTest
|
|||||||
|
|
||||||
public function testCandidateAuthors()
|
public function testCandidateAuthors()
|
||||||
{
|
{
|
||||||
$blogpost = $this->objFromFixture('BlogPost', 'PostC');
|
$blogpost = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'PostC');
|
||||||
|
|
||||||
$this->assertEquals(7, $blogpost->getCandidateAuthors()->count());
|
$this->assertEquals(7, $blogpost->getCandidateAuthors()->count());
|
||||||
|
|
||||||
//Set the group to draw Members from
|
//Set the group to draw Members from
|
||||||
Config::inst()->update('BlogPost', 'restrict_authors_to_group', 'blogusers');
|
Config::inst()->update('SilverStripe\\Blog\\Model\\BlogPost', 'restrict_authors_to_group', 'blogusers');
|
||||||
|
|
||||||
$this->assertEquals(3, $blogpost->getCandidateAuthors()->count());
|
$this->assertEquals(3, $blogpost->getCandidateAuthors()->count());
|
||||||
|
|
||||||
@ -86,12 +94,12 @@ class BlogPostTest extends SapphireTest
|
|||||||
|
|
||||||
public function testCanViewFuturePost()
|
public function testCanViewFuturePost()
|
||||||
{
|
{
|
||||||
$blogPost = $this->objFromFixture('BlogPost', 'NullPublishDate');
|
$blogPost = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'NullPublishDate');
|
||||||
|
|
||||||
$editor = $this->objFromFixture('Member', 'BlogEditor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'BlogEditor');
|
||||||
$this->assertTrue($blogPost->canView($editor));
|
$this->assertTrue($blogPost->canView($editor));
|
||||||
|
|
||||||
$visitor = $this->objFromFixture('Member', 'Visitor');
|
$visitor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Visitor');
|
||||||
$this->assertFalse($blogPost->canView($visitor));
|
$this->assertFalse($blogPost->canView($visitor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Model\Blog;
|
||||||
|
use SilverStripe\Blog\Model\BlogTag;
|
||||||
|
use SilverStripe\Dev\FunctionalTest;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
* @mixin PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
class BlogTagTest extends FunctionalTest
|
class BlogTagTest extends FunctionalTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public static $fixture_file = 'blog.yml';
|
public static $fixture_file = 'blog.yml';
|
||||||
@ -17,7 +25,7 @@ class BlogTagTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
|
DBDatetime::set_mock_now('2013-10-10 20:00:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,7 +33,7 @@ class BlogTagTest extends FunctionalTest
|
|||||||
*/
|
*/
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
SS_Datetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
@ -42,12 +50,12 @@ class BlogTagTest extends FunctionalTest
|
|||||||
$member->logout();
|
$member->logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->objFromFixture('BlogPost', 'FirstBlogPost');
|
$this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'FirstBlogPost');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var BlogTag $tag
|
* @var BlogTag $tag
|
||||||
*/
|
*/
|
||||||
$tag = $this->objFromFixture('BlogTag', 'FirstTag');
|
$tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'FirstTag');
|
||||||
|
|
||||||
$this->assertEquals(1, $tag->BlogPosts()->count(), 'Tag blog post count');
|
$this->assertEquals(1, $tag->BlogPosts()->count(), 'Tag blog post count');
|
||||||
}
|
}
|
||||||
@ -75,15 +83,15 @@ class BlogTagTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
|
|
||||||
$admin = $this->objFromFixture('Member', 'Admin');
|
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
|
||||||
$editor = $this->objFromFixture('Member', 'Editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
|
||||||
|
|
||||||
$tag = $this->objFromFixture('BlogTag', 'FirstTag');
|
$tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'FirstTag');
|
||||||
|
|
||||||
$this->assertTrue($tag->canView($admin), 'Admin should be able to view tag.');
|
$this->assertTrue($tag->canView($admin), 'Admin should be able to view tag.');
|
||||||
$this->assertTrue($tag->canView($editor), 'Editor should be able to view tag.');
|
$this->assertTrue($tag->canView($editor), 'Editor should be able to view tag.');
|
||||||
|
|
||||||
$tag = $this->objFromFixture('BlogTag', 'SecondTag');
|
$tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'SecondTag');
|
||||||
|
|
||||||
$this->assertTrue($tag->canView($admin), 'Admin should be able to view tag.');
|
$this->assertTrue($tag->canView($admin), 'Admin should be able to view tag.');
|
||||||
$this->assertFalse($tag->canView($editor), 'Editor should not be able to view tag.');
|
$this->assertFalse($tag->canView($editor), 'Editor should not be able to view tag.');
|
||||||
@ -93,20 +101,20 @@ class BlogTagTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
|
|
||||||
$admin = $this->objFromFixture('Member', 'Admin');
|
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
|
||||||
$editor = $this->objFromFixture('Member', 'Editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
|
||||||
|
|
||||||
$tag = $this->objFromFixture('BlogTag', 'FirstTag');
|
$tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'FirstTag');
|
||||||
|
|
||||||
$this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit tag.');
|
$this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit tag.');
|
||||||
$this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.');
|
$this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.');
|
||||||
|
|
||||||
$tag = $this->objFromFixture('BlogTag', 'SecondTag');
|
$tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'SecondTag');
|
||||||
|
|
||||||
$this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit tag.');
|
$this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit tag.');
|
||||||
$this->assertFalse($tag->canEdit($editor), 'Editor should not be able to edit tag.');
|
$this->assertFalse($tag->canEdit($editor), 'Editor should not be able to edit tag.');
|
||||||
|
|
||||||
$tag = $this->objFromFixture('BlogTag', 'ThirdTag');
|
$tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'ThirdTag');
|
||||||
|
|
||||||
$this->assertTrue($tag->canEdit($admin), 'Admin should always be able to edit tags.');
|
$this->assertTrue($tag->canEdit($admin), 'Admin should always be able to edit tags.');
|
||||||
$this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.');
|
$this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.');
|
||||||
@ -116,10 +124,10 @@ class BlogTagTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
|
|
||||||
$admin = $this->objFromFixture('Member', 'Admin');
|
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
|
||||||
$editor = $this->objFromFixture('Member', 'Editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
|
||||||
|
|
||||||
$tag = singleton('BlogTag');
|
$tag = singleton('SilverStripe\\Blog\\Model\\BlogTag');
|
||||||
|
|
||||||
$this->assertTrue($tag->canCreate($admin), 'Admin should be able to create tag.');
|
$this->assertTrue($tag->canCreate($admin), 'Admin should be able to create tag.');
|
||||||
$this->assertTrue($tag->canCreate($editor), 'Editor should be able to create tag.');
|
$this->assertTrue($tag->canCreate($editor), 'Editor should be able to create tag.');
|
||||||
@ -129,26 +137,27 @@ class BlogTagTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
|
|
||||||
$admin = $this->objFromFixture('Member', 'Admin');
|
$admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin');
|
||||||
$editor = $this->objFromFixture('Member', 'Editor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor');
|
||||||
|
|
||||||
$tag = $this->objFromFixture('BlogTag', 'FirstTag');
|
$tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'FirstTag');
|
||||||
|
|
||||||
$this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete tag.');
|
$this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete tag.');
|
||||||
$this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete tag.');
|
$this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete tag.');
|
||||||
|
|
||||||
$tag = $this->objFromFixture('BlogTag', 'SecondTag');
|
$tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'SecondTag');
|
||||||
|
|
||||||
$this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete tag.');
|
$this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete tag.');
|
||||||
$this->assertFalse($tag->canDelete($editor), 'Editor should not be able to delete tag.');
|
$this->assertFalse($tag->canDelete($editor), 'Editor should not be able to delete tag.');
|
||||||
|
|
||||||
$tag = $this->objFromFixture('BlogTag', 'ThirdTag');
|
$tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'ThirdTag');
|
||||||
|
|
||||||
$this->assertTrue($tag->canDelete($admin), 'Admin should always be able to delete tags.');
|
$this->assertTrue($tag->canDelete($admin), 'Admin should always be able to delete tags.');
|
||||||
$this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete tag.');
|
$this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete tag.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDuplicateTagsForURLSegment() {
|
public function testDuplicateTagsForURLSegment()
|
||||||
|
{
|
||||||
$blog = new Blog();
|
$blog = new Blog();
|
||||||
$blog->Title = 'Testing for duplicates blog';
|
$blog->Title = 'Testing for duplicates blog';
|
||||||
$blog->write();
|
$blog->write();
|
||||||
@ -163,10 +172,10 @@ class BlogTagTest extends FunctionalTest
|
|||||||
$tag2->BlogID = $blog->ID;
|
$tag2->BlogID = $blog->ID;
|
||||||
$tag2->write();
|
$tag2->write();
|
||||||
$this->assertEquals('cat-test-1', $tag2->URLSegment);
|
$this->assertEquals('cat-test-1', $tag2->URLSegment);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDuplicateTags() {
|
public function testDuplicateTags()
|
||||||
|
{
|
||||||
$blog = new Blog();
|
$blog = new Blog();
|
||||||
$blog->Title = 'Testing for duplicate tags';
|
$blog->Title = 'Testing for duplicate tags';
|
||||||
$blog->write();
|
$blog->write();
|
||||||
@ -185,10 +194,9 @@ class BlogTagTest extends FunctionalTest
|
|||||||
$tag->write();
|
$tag->write();
|
||||||
$this->fail('Duplicate BlogTag written');
|
$this->fail('Duplicate BlogTag written');
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
$codeList = $e->getResult()->codeList();
|
$messages = $e->getResult()->getMessages();
|
||||||
$this->assertCount(1, $codeList);
|
$this->assertCount(1, $messages);
|
||||||
$this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $codeList[0]);
|
$this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $messages[0]['messageType']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class BlogTagsCloudWidgetTest extends SapphireTest {
|
use SilverStripe\Blog\Model\Blog\BlogTagsCloudWidget;
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\Control\Controller;
|
||||||
|
use SilverStripe\Control\Director;
|
||||||
|
|
||||||
|
class BlogTagsCloudWidgetTest extends SapphireTest
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public static $fixture_file = 'blog.yml';
|
public static $fixture_file = 'blog.yml';
|
||||||
|
|
||||||
public function testGetCMSFields() {
|
public function testGetCMSFields()
|
||||||
|
{
|
||||||
if (!class_exists('Widget')) {
|
if (!class_exists('Widget')) {
|
||||||
$this->markTestSkipped('Widgets module not installed');
|
$this->markTestSkipped('Widgets module not installed');
|
||||||
}
|
}
|
||||||
@ -23,12 +29,13 @@ class BlogTagsCloudWidgetTest extends SapphireTest {
|
|||||||
$this->assertEquals($expected, $names);
|
$this->assertEquals($expected, $names);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTags() {
|
public function testGetTags()
|
||||||
|
{
|
||||||
if (!class_exists('Widget')) {
|
if (!class_exists('Widget')) {
|
||||||
$this->markTestSkipped('Widgets module not installed');
|
$this->markTestSkipped('Widgets module not installed');
|
||||||
}
|
}
|
||||||
$widget = new BlogTagsCloudWidget();
|
$widget = new BlogTagsCloudWidget();
|
||||||
$blog = $this->objFromFixture('Blog', 'FourthBlog');
|
$blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FourthBlog');
|
||||||
$widget->BlogID = $blog->ID;
|
$widget->BlogID = $blog->ID;
|
||||||
$widget->write();
|
$widget->write();
|
||||||
$tags = $widget->getTags()->toArray();
|
$tags = $widget->getTags()->toArray();
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\Blog\Controllers\BlogController;
|
||||||
|
use SilverStripe\CMS\Controllers\ContentController;
|
||||||
|
use SilverStripe\Control\Controller;
|
||||||
|
use SilverStripe\Control\Director;
|
||||||
|
use SilverStripe\Control\HTTPRequest;
|
||||||
|
use SilverStripe\Core\Config\Config;
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\Security\Member;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin PHPUnit_Framework_TestCase
|
* @mixin PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
@ -18,12 +30,12 @@ class BlogTest extends SapphireTest
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
Config::nest();
|
Config::nest();
|
||||||
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
|
DBDatetime::set_mock_now('2013-10-10 20:00:00');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Blog $blog
|
* @var Blog $blog
|
||||||
*/
|
*/
|
||||||
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
$blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
|
||||||
|
|
||||||
$blog->publish('Stage', 'Live');
|
$blog->publish('Stage', 'Live');
|
||||||
}
|
}
|
||||||
@ -33,7 +45,7 @@ class BlogTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
SS_Datetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
Config::unnest();
|
Config::unnest();
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
@ -50,17 +62,17 @@ class BlogTest extends SapphireTest
|
|||||||
/**
|
/**
|
||||||
* @var Blog $blog
|
* @var Blog $blog
|
||||||
*/
|
*/
|
||||||
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
$blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
|
||||||
|
|
||||||
Config::inst()->update('BlogPost', 'show_in_sitetree', true);
|
Config::inst()->update('SilverStripe\\Blog\\Model\\BlogPost', 'show_in_sitetree', true);
|
||||||
$classes = $blog->getExcludedSiteTreeClassNames();
|
$classes = $blog->getExcludedSiteTreeClassNames();
|
||||||
|
|
||||||
$this->assertNotContains('BlogPost', $classes, 'BlogPost class should be hidden.');
|
$this->assertNotContains('SilverStripe\\Blog\\Model\\BlogPost', $classes, 'BlogPost class should be hidden.');
|
||||||
|
|
||||||
Config::inst()->update('BlogPost', 'show_in_sitetree', false);
|
Config::inst()->update('SilverStripe\\Blog\\Model\\BlogPost', 'show_in_sitetree', false);
|
||||||
$classes = $blog->getExcludedSiteTreeClassNames();
|
$classes = $blog->getExcludedSiteTreeClassNames();
|
||||||
|
|
||||||
$this->assertContains('BlogPost', $classes, 'BlogPost class should be hidden.');
|
$this->assertContains('SilverStripe\\Blog\\Model\\BlogPost', $classes, 'BlogPost class should be hidden.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetArchivedBlogPosts()
|
public function testGetArchivedBlogPosts()
|
||||||
@ -74,7 +86,7 @@ class BlogTest extends SapphireTest
|
|||||||
/**
|
/**
|
||||||
* @var Blog $blog
|
* @var Blog $blog
|
||||||
*/
|
*/
|
||||||
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
$blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
|
||||||
|
|
||||||
$archive = $blog->getArchivedBlogPosts(2013);
|
$archive = $blog->getArchivedBlogPosts(2013);
|
||||||
|
|
||||||
@ -96,7 +108,7 @@ class BlogTest extends SapphireTest
|
|||||||
/**
|
/**
|
||||||
* @var Blog $blog
|
* @var Blog $blog
|
||||||
*/
|
*/
|
||||||
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
$blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
|
||||||
|
|
||||||
$link = Controller::join_links($blog->Link('archive'), '2013', '10', '01');
|
$link = Controller::join_links($blog->Link('archive'), '2013', '10', '01');
|
||||||
|
|
||||||
@ -135,8 +147,8 @@ class BlogTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testArchiveYear()
|
public function testArchiveYear()
|
||||||
{
|
{
|
||||||
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
$blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
|
||||||
$controller = new Blog_Controller($blog);
|
$controller = new BlogController($blog);
|
||||||
$this->requestURL($controller, 'first-post/archive/');
|
$this->requestURL($controller, 'first-post/archive/');
|
||||||
$this->assertEquals(2013, $controller->getArchiveYear(), 'getArchiveYear should return 2013');
|
$this->assertEquals(2013, $controller->getArchiveYear(), 'getArchiveYear should return 2013');
|
||||||
}
|
}
|
||||||
@ -156,47 +168,47 @@ class BlogTest extends SapphireTest
|
|||||||
/**
|
/**
|
||||||
* @var Blog $firstBlog
|
* @var Blog $firstBlog
|
||||||
*/
|
*/
|
||||||
$firstBlog = $this->objFromFixture('Blog', 'FirstBlog');
|
$firstBlog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Blog $fourthBlog
|
* @var Blog $fourthBlog
|
||||||
*/
|
*/
|
||||||
$fourthBlog = $this->objFromFixture('Blog', 'FourthBlog');
|
$fourthBlog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FourthBlog');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var BlogPost $postA
|
* @var BlogPost $postA
|
||||||
*/
|
*/
|
||||||
$postA = $this->objFromFixture('BlogPost', 'PostA');
|
$postA = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'PostA');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var BlogPost $postB
|
* @var BlogPost $postB
|
||||||
*/
|
*/
|
||||||
$postB = $this->objFromFixture('BlogPost', 'PostB');
|
$postB = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'PostB');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var BlogPost $postC
|
* @var BlogPost $postC
|
||||||
*/
|
*/
|
||||||
$postC = $this->objFromFixture('BlogPost', 'PostC');
|
$postC = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'PostC');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Member $editor
|
* @var Member $editor
|
||||||
*/
|
*/
|
||||||
$editor = $this->objFromFixture('Member', 'BlogEditor');
|
$editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'BlogEditor');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Member $writer
|
* @var Member $writer
|
||||||
*/
|
*/
|
||||||
$writer = $this->objFromFixture('Member', 'Writer');
|
$writer = $this->objFromFixture('SilverStripe\\Security\\Member', 'Writer');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Member $contributor
|
* @var Member $contributor
|
||||||
*/
|
*/
|
||||||
$contributor = $this->objFromFixture('Member', 'Contributor');
|
$contributor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Contributor');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Member $visitor
|
* @var Member $visitor
|
||||||
*/
|
*/
|
||||||
$visitor = $this->objFromFixture('Member', 'Visitor');
|
$visitor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Visitor');
|
||||||
|
|
||||||
$this->assertEquals('Editor', $fourthBlog->RoleOf($editor));
|
$this->assertEquals('Editor', $fourthBlog->RoleOf($editor));
|
||||||
$this->assertEquals('Contributor', $fourthBlog->RoleOf($contributor));
|
$this->assertEquals('Contributor', $fourthBlog->RoleOf($contributor));
|
||||||
@ -274,8 +286,8 @@ class BlogTest extends SapphireTest
|
|||||||
|
|
||||||
public function testFilteredCategories()
|
public function testFilteredCategories()
|
||||||
{
|
{
|
||||||
$blog = $this->objFromFixture('Blog', 'FirstBlog');
|
$blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
|
||||||
$controller = new Blog_Controller($blog);
|
$controller = new BlogController($blog);
|
||||||
|
|
||||||
// Root url
|
// Root url
|
||||||
$this->requestURL($controller, 'first-post');
|
$this->requestURL($controller, 'first-post');
|
||||||
@ -293,10 +305,10 @@ class BlogTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Posts
|
// Posts
|
||||||
$firstPostID = $this->idFromFixture('BlogPost', 'FirstBlogPost');
|
$firstPostID = $this->idFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'FirstBlogPost');
|
||||||
$secondPostID = $this->idFromFixture('BlogPost', 'SecondBlogPost');
|
$secondPostID = $this->idFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'SecondBlogPost');
|
||||||
$firstFuturePostID = $this->idFromFixture('BlogPost', 'FirstFutureBlogPost');
|
$firstFuturePostID = $this->idFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'FirstFutureBlogPost');
|
||||||
$secondFuturePostID = $this->idFromFixture('BlogPost', 'SecondFutureBlogPost');
|
$secondFuturePostID = $this->idFromFixture('SilverStripe\\Blog\\Model\\BlogPost', 'SecondFutureBlogPost');
|
||||||
|
|
||||||
// Request first tag
|
// Request first tag
|
||||||
$this->requestURL($controller, 'first-post/tag/first-tag');
|
$this->requestURL($controller, 'first-post/tag/first-tag');
|
||||||
@ -321,7 +333,7 @@ class BlogTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
protected function requestURL(ContentController $controller, $url)
|
protected function requestURL(ContentController $controller, $url)
|
||||||
{
|
{
|
||||||
$request = new SS_HTTPRequest('get', $url);
|
$request = new HTTPRequest('get', $url);
|
||||||
$request->match('$URLSegment//$Action/$ID/$OtherID');
|
$request->match('$URLSegment//$Action/$ID/$OtherID');
|
||||||
$request->shift();
|
$request->shift();
|
||||||
$controller->init();
|
$controller->init();
|
||||||
|
130
tests/blog.yml
130
tests/blog.yml
@ -1,6 +1,6 @@
|
|||||||
# Mock date is set to 2013-10-01 20:00:00
|
# Mock date is set to 2013-10-01 20:00:00
|
||||||
|
|
||||||
Group:
|
SilverStripe\Security\Group:
|
||||||
Administrators:
|
Administrators:
|
||||||
Title: Administrators
|
Title: Administrators
|
||||||
Editors:
|
Editors:
|
||||||
@ -9,193 +9,193 @@ Group:
|
|||||||
Title: Blog Users
|
Title: Blog Users
|
||||||
Code: blogusers
|
Code: blogusers
|
||||||
|
|
||||||
Permission:
|
SilverStripe\Security\Permission:
|
||||||
Administrators:
|
Administrators:
|
||||||
Code: ADMIN
|
Code: ADMIN
|
||||||
Group: =>Group.Administrators
|
Group: =>SilverStripe\Security\Group.Administrators
|
||||||
Editors:
|
Editors:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
Group: =>Group.Editors
|
Group: =>SilverStripe\Security\Group.Editors
|
||||||
BlogUsers:
|
BlogUsers:
|
||||||
Code: CMS_ACCESS_CMSMain
|
Code: CMS_ACCESS_CMSMain
|
||||||
Group: =>Group.BlogUsers
|
Group: =>SilverStripe\Security\Group.BlogUsers
|
||||||
|
|
||||||
SiteConfig:
|
SilverStripe\SiteConfig\SiteConfig:
|
||||||
Default:
|
Default:
|
||||||
CanEditType: 'OnlyTheseUsers'
|
CanEditType: 'OnlyTheseUsers'
|
||||||
CanCreateTopLevelType: 'OnlyTheseUsers'
|
CanCreateTopLevelType: 'OnlyTheseUsers'
|
||||||
EditorGroups: =>Group.Administrators,=>Group.Editors
|
EditorGroups: =>SilverStripe\Security\Group.Administrators,=>SilverStripe\Security\Group.Editors
|
||||||
CreateTopLevelGroups: =>Group.Administrators,=>Group.Editors
|
CreateTopLevelGroups: =>SilverStripe\Security\Group.Administrators,=>SilverStripe\Security\Group.Editors
|
||||||
|
|
||||||
Member:
|
SilverStripe\Security\Member:
|
||||||
Admin:
|
Admin:
|
||||||
FirstName: Test
|
FirstName: Test
|
||||||
Surname: Administrator
|
Surname: Administrator
|
||||||
Groups: =>Group.Administrators
|
Groups: =>SilverStripe\Security\Group.Administrators
|
||||||
Editor:
|
Editor:
|
||||||
FirstName: Test
|
FirstName: Test
|
||||||
Surname: Editor
|
Surname: Editor
|
||||||
Groups: =>Group.Editors
|
Groups: =>SilverStripe\Security\Group.Editors
|
||||||
BlogEditor:
|
BlogEditor:
|
||||||
FirstName: Blog
|
FirstName: Blog
|
||||||
Surname: Editor
|
Surname: Editor
|
||||||
Groups: =>Group.BlogUsers
|
Groups: =>SilverStripe\Security\Group.BlogUsers
|
||||||
Writer:
|
Writer:
|
||||||
FirstName: Blog
|
FirstName: Blog
|
||||||
Surname: Writer
|
Surname: Writer
|
||||||
Groups: =>Group.BlogUsers
|
Groups: =>SilverStripe\Security\Group.BlogUsers
|
||||||
Contributor:
|
Contributor:
|
||||||
FirstName: Blog
|
FirstName: Blog
|
||||||
Surname: Contributor
|
Surname: Contributor
|
||||||
Groups: =>Group.BlogUsers
|
Groups: =>SilverStripe\Security\Group.BlogUsers
|
||||||
Visitor:
|
Visitor:
|
||||||
FirstName: Blog
|
FirstName: Blog
|
||||||
Surname: Visitor
|
Surname: Visitor
|
||||||
|
|
||||||
Blog:
|
SilverStripe\Blog\Model\Blog:
|
||||||
FirstBlog:
|
FirstBlog:
|
||||||
Title: 'First Blog'
|
Title: 'First Blog'
|
||||||
SecondBlog:
|
SecondBlog:
|
||||||
Title: 'Second Blog'
|
Title: 'Second Blog'
|
||||||
CanViewType: 'OnlyTheseUsers'
|
CanViewType: 'OnlyTheseUsers'
|
||||||
CanEditType: 'OnlyTheseUsers'
|
CanEditType: 'OnlyTheseUsers'
|
||||||
ViewerGroups: =>Group.Administrators
|
ViewerGroups: =>SilverStripe\Security\Group.Administrators
|
||||||
EditorGroups: =>Group.Administrators
|
EditorGroups: =>SilverStripe\Security\Group.Administrators
|
||||||
ThirdBlog:
|
ThirdBlog:
|
||||||
Title: 'Third Blog'
|
Title: 'Third Blog'
|
||||||
CanEditType: 'OnlyTheseUsers'
|
CanEditType: 'OnlyTheseUsers'
|
||||||
EditorGroups: =>Group.Editors
|
EditorGroups: =>SilverStripe\Security\Group.Editors
|
||||||
FourthBlog:
|
FourthBlog:
|
||||||
Title: 'Fourth Blog'
|
Title: 'Fourth Blog'
|
||||||
Editors: =>Member.BlogEditor
|
Editors: =>SilverStripe\Security\Member.BlogEditor
|
||||||
Writers: =>Member.Writer
|
Writers: =>SilverStripe\Security\Member.Writer
|
||||||
Contributors: =>Member.Contributor
|
Contributors: =>SilverStripe\Security\Member.Contributor
|
||||||
|
|
||||||
BlogTag:
|
SilverStripe\Blog\Model\BlogTag:
|
||||||
FirstTag:
|
FirstTag:
|
||||||
Title: 'First Tag'
|
Title: 'First Tag'
|
||||||
URLSegment: 'first-tag'
|
URLSegment: 'first-tag'
|
||||||
Blog: =>Blog.FirstBlog
|
Blog: =>SilverStripe\Blog\Model\Blog.FirstBlog
|
||||||
SecondTag:
|
SecondTag:
|
||||||
Title: 'Second Tag'
|
Title: 'Second Tag'
|
||||||
URLSegment: 'second-tag'
|
URLSegment: 'second-tag'
|
||||||
Blog: =>Blog.SecondBlog
|
Blog: =>SilverStripe\Blog\Model\Blog.SecondBlog
|
||||||
ThirdTag:
|
ThirdTag:
|
||||||
Title: 'Third Tag'
|
Title: 'Third Tag'
|
||||||
URLSegment: 'third-tag'
|
URLSegment: 'third-tag'
|
||||||
Blog: =>Blog.ThirdBlog
|
Blog: =>SilverStripe\Blog\Model\Blog.ThirdBlog
|
||||||
|
|
||||||
#Tags for Tag Cloud widget
|
#Tags for Tag Cloud widget
|
||||||
PopularTag:
|
PopularTag:
|
||||||
Title: 'Popular'
|
Title: 'Popular'
|
||||||
URLSegment: 'popular-tag'
|
URLSegment: 'popular-tag'
|
||||||
Blog: =>Blog.FourthBlog
|
Blog: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
CoolTag:
|
CoolTag:
|
||||||
Title: 'Cool'
|
Title: 'Cool'
|
||||||
URLSegment: 'cool-tag'
|
URLSegment: 'cool-tag'
|
||||||
Blog: =>Blog.FourthBlog
|
Blog: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
CatTag:
|
CatTag:
|
||||||
Title: 'Cat'
|
Title: 'Cat'
|
||||||
URLSegment: 'cat-tag'
|
URLSegment: 'cat-tag'
|
||||||
Blog: =>Blog.FourthBlog
|
Blog: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
KiwiTag:
|
KiwiTag:
|
||||||
Title: 'Kiwi'
|
Title: 'Kiwi'
|
||||||
URLSegment: 'kiwi-tag'
|
URLSegment: 'kiwi-tag'
|
||||||
Blog: =>Blog.FourthBlog
|
Blog: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
|
|
||||||
BlogCategory:
|
SilverStripe\Blog\Model\BlogCategory:
|
||||||
FirstCategory:
|
FirstCategory:
|
||||||
Title: 'First Category'
|
Title: 'First Category'
|
||||||
URLSegment: 'first-category'
|
URLSegment: 'first-category'
|
||||||
Blog: =>Blog.FirstBlog
|
Blog: =>SilverStripe\Blog\Model\Blog.FirstBlog
|
||||||
SecondCategory:
|
SecondCategory:
|
||||||
Title: 'Second Category'
|
Title: 'Second Category'
|
||||||
URLSegment: 'second-category'
|
URLSegment: 'second-category'
|
||||||
Blog: =>Blog.SecondBlog
|
Blog: =>SilverStripe\Blog\Model\Blog.SecondBlog
|
||||||
ThirdCategory:
|
ThirdCategory:
|
||||||
Title: 'Third Category'
|
Title: 'Third Category'
|
||||||
URLSegment: 'third-category'
|
URLSegment: 'third-category'
|
||||||
Blog: =>Blog.ThirdBlog
|
Blog: =>SilverStripe\Blog\Model\Blog.ThirdBlog
|
||||||
|
|
||||||
BlogPost:
|
SilverStripe\Blog\Model\BlogPost:
|
||||||
FirstBlogPost:
|
FirstBlogPost:
|
||||||
Title: 'First Post'
|
Title: 'First Post'
|
||||||
URLSegment: first-post
|
URLSegment: first-post
|
||||||
PublishDate: '2013-10-01 15:00:00'
|
PublishDate: '2013-10-01 15:00:00'
|
||||||
Parent: =>Blog.FirstBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FirstBlog
|
||||||
Tags: =>BlogTag.FirstTag
|
Tags: =>SilverStripe\Blog\Model\BlogTag.FirstTag
|
||||||
Categories: =>BlogCategory.FirstCategory
|
Categories: =>SilverStripe\Blog\Model\BlogCategory.FirstCategory
|
||||||
SecondBlogPost:
|
SecondBlogPost:
|
||||||
Title: 'Second Post'
|
Title: 'Second Post'
|
||||||
URLSegment: second-post
|
URLSegment: second-post
|
||||||
PublishDate: '2013-09-01 15:00:00'
|
PublishDate: '2013-09-01 15:00:00'
|
||||||
Parent: =>Blog.FirstBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FirstBlog
|
||||||
ThirdBlogPost:
|
ThirdBlogPost:
|
||||||
Title: 'Old Post'
|
Title: 'Old Post'
|
||||||
URLSegment: old-post
|
URLSegment: old-post
|
||||||
PublishDate: '2012-01-09 15:00:00'
|
PublishDate: '2012-01-09 15:00:00'
|
||||||
Parent: =>Blog.FirstBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FirstBlog
|
||||||
FirstFutureBlogPost:
|
FirstFutureBlogPost:
|
||||||
Title: 'Future Post'
|
Title: 'Future Post'
|
||||||
URLSegment: future-post
|
URLSegment: future-post
|
||||||
PublishDate: '2015-01-01 00:00:00'
|
PublishDate: '2015-01-01 00:00:00'
|
||||||
Tags: =>BlogTag.FirstTag
|
Tags: =>SilverStripe\Blog\Model\BlogTag.FirstTag
|
||||||
Categories: =>BlogCategory.FirstCategory
|
Categories: =>SilverStripe\Blog\Model\BlogCategory.FirstCategory
|
||||||
Parent: =>Blog.FirstBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FirstBlog
|
||||||
SecondFutureBlogPost:
|
SecondFutureBlogPost:
|
||||||
Title: 'Future Post 2'
|
Title: 'Future Post 2'
|
||||||
URLSegment: future-post-2
|
URLSegment: future-post-2
|
||||||
PublishDate: '2013-11-01 00:00:00'
|
PublishDate: '2013-11-01 00:00:00'
|
||||||
Tags: =>BlogTag.FirstTag
|
Tags: =>SilverStripe\Blog\Model\BlogTag.FirstTag
|
||||||
Categories: =>BlogCategory.FirstCategory
|
Categories: =>SilverStripe\Blog\Model\BlogCategory.FirstCategory
|
||||||
Parent: =>Blog.FirstBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FirstBlog
|
||||||
PostA:
|
PostA:
|
||||||
Title: 'One Post'
|
Title: 'One Post'
|
||||||
PublishDate: '2012-01-09 15:00:00'
|
PublishDate: '2012-01-09 15:00:00'
|
||||||
Parent: =>Blog.FourthBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
Authors: =>Member.Writer,=>Member.Contributor
|
Authors: =>SilverStripe\Security\Member.Writer,=>SilverStripe\Security\Member.Contributor
|
||||||
PostB:
|
PostB:
|
||||||
Title: 'Second Post'
|
Title: 'Second Post'
|
||||||
PublishDate: '2012-01-09 15:00:00'
|
PublishDate: '2012-01-09 15:00:00'
|
||||||
Parent: =>Blog.FourthBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
Authors: =>Member.BlogEditor
|
Authors: =>SilverStripe\Security\Member.BlogEditor
|
||||||
PostC:
|
PostC:
|
||||||
Title: 'Third Post'
|
Title: 'Third Post'
|
||||||
PublishDate: '2012-01-09 15:00:00'
|
PublishDate: '2012-01-09 15:00:00'
|
||||||
Parent: =>Blog.FourthBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
Authors: =>Member.BlogEditor,=>Member.Writer,=>Member.Contributor
|
Authors: =>SilverStripe\Security\Member.BlogEditor,=>SilverStripe\Security\Member.Writer,=>SilverStripe\Security\Member.Contributor
|
||||||
NullPublishDate:
|
NullPublishDate:
|
||||||
Title: 'No publish date'
|
Title: 'No publish date'
|
||||||
PublishDate: ''
|
PublishDate: ''
|
||||||
Parent: =>Blog.FourthBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
Authors: =>Member.BlogEditor,=>Member.Writer,=>Member.Contributor
|
Authors: =>SilverStripe\Security\Member.BlogEditor,=>SilverStripe\Security\Member.Writer,=>SilverStripe\Security\Member.Contributor
|
||||||
|
|
||||||
#Posts for the tag cloud widget test
|
#Posts for the tag cloud widget test
|
||||||
TaggedPost1:
|
TaggedPost1:
|
||||||
Title: 'Tagged Post 1'
|
Title: 'Tagged Post 1'
|
||||||
URLSegment: tagged-post-1
|
URLSegment: tagged-post-1
|
||||||
PublishDate: '2012-01-09 15:00:00'
|
PublishDate: '2012-01-09 15:00:00'
|
||||||
Tags: =>BlogTag.PopularTag,=>BlogTag.CoolTag
|
Tags: =>SilverStripe\Blog\Model\BlogTag.PopularTag,=>SilverStripe\Blog\Model\BlogTag.CoolTag
|
||||||
Categories: =>BlogCategory.FirstCategory
|
Categories: =>SilverStripe\Blog\Model\BlogCategory.FirstCategory
|
||||||
Parent: =>Blog.FourthBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
TaggedPost2:
|
TaggedPost2:
|
||||||
Title: 'Tagged Post 2'
|
Title: 'Tagged Post 2'
|
||||||
URLSegment: tagged-post-2
|
URLSegment: tagged-post-2
|
||||||
PublishDate: '2012-01-09 15:00:00'
|
PublishDate: '2012-01-09 15:00:00'
|
||||||
Tags: =>BlogTag.PopularTag,=>BlogTag.CoolTag,=>BlogTag.CatTag
|
Tags: =>SilverStripe\Blog\Model\BlogTag.PopularTag,=>SilverStripe\Blog\Model\BlogTag.CoolTag,=>SilverStripe\Blog\Model\BlogTag.CatTag
|
||||||
Categories: =>BlogCategory.FirstCategory
|
Categories: =>SilverStripe\Blog\Model\BlogCategory.FirstCategory
|
||||||
Parent: =>Blog.FourthBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
TaggedPost3:
|
TaggedPost3:
|
||||||
Title: 'Tagged Post 3'
|
Title: 'Tagged Post 3'
|
||||||
URLSegment: tagged-post-3
|
URLSegment: tagged-post-3
|
||||||
PublishDate: '2012-01-09 17:20:00'
|
PublishDate: '2012-01-09 17:20:00'
|
||||||
Tags: =>BlogTag.PopularTag,=>BlogTag.CoolTag,=>BlogTag.CatTag,=>BlogTag.KiwiTag
|
Tags: =>SilverStripe\Blog\Model\BlogTag.PopularTag,=>SilverStripe\Blog\Model\BlogTag.CoolTag,=>SilverStripe\Blog\Model\BlogTag.CatTag,=>SilverStripe\Blog\Model\BlogTag.KiwiTag
|
||||||
Categories: =>BlogCategory.FirstCategory
|
Categories: =>SilverStripe\Blog\Model\BlogCategory.FirstCategory
|
||||||
Parent: =>Blog.FourthBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
TaggedPost4:
|
TaggedPost4:
|
||||||
Title: 'Tagged Post 4'
|
Title: 'Tagged Post 4'
|
||||||
URLSegment: tagged-post-4
|
URLSegment: tagged-post-4
|
||||||
PublishDate: '2012-04-09 15:00:00'
|
PublishDate: '2012-04-09 15:00:00'
|
||||||
Tags: =>BlogTag.PopularTag
|
Tags: =>SilverStripe\Blog\Model\BlogTag.PopularTag
|
||||||
Categories: =>BlogCategory.FirstCategory
|
Categories: =>SilverStripe\Blog\Model\BlogCategory.FirstCategory
|
||||||
Parent: =>Blog.FourthBlog
|
Parent: =>SilverStripe\Blog\Model\Blog.FourthBlog
|
||||||
|
Loading…
Reference in New Issue
Block a user