Merge remote-tracking branch 'origin/0.6'
Conflicts: .travis.yml README.md _config.php code/BlogHolder.php code/BlogTree.php code/widgets/ArchiveWidget.php code/widgets/BlogManagementWidget.php code/widgets/BlogTreeExtension.php code/widgets/RSSWidget.php code/widgets/SubscribeRSSWidget.php composer.json
This commit is contained in:
commit
e33881615d
14
README.md
14
README.md
|
@ -78,8 +78,20 @@ See [:pagecomment](/pagecomment) for creating Askimet-protected comments for eve
|
|||
|
||||
## Widgets
|
||||
|
||||
See [widgets](/widgets)
|
||||
The module comes with a couple of default widgets, which rely on the "silverstripe/widgets"
|
||||
module being installed. Since widgets are based on database records and relations
|
||||
to pages, they need to be enabled through an `Extension` class in your `config.yml`:
|
||||
|
||||
:::yml
|
||||
BlogTree:
|
||||
extensions:
|
||||
- WidgetPageExtension
|
||||
BlogEntry:
|
||||
extensions:
|
||||
- WidgetPageExtension
|
||||
|
||||
Alternatively, you can simply enable the extension on your `Page` records
|
||||
to have it available globally.
|
||||
|
||||
## Working with the theme
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
<?php
|
||||
|
||||
if(class_exists('WidgetArea')) BlogTree::add_extension('BlogTreeExtension');
|
|
@ -108,16 +108,6 @@ class BlogEntry extends Page {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sidebar from the BlogHolder.
|
||||
*/
|
||||
function SideBar() {
|
||||
if(method_exists($this->Parent(), 'SideBar')) {
|
||||
return $this->getParent()->SideBar();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function Content() {
|
||||
if(self::$allow_wysiwyg_editing) {
|
||||
return $this->getField('Content');
|
||||
|
|
|
@ -49,7 +49,12 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||
"Content"
|
||||
);
|
||||
$fields->addFieldToTab('Root.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'), "Content");
|
||||
$fields->addFieldToTab("Root.Main", new CheckboxField("ShowFullEntry", "Show Full Entry"), "Content");
|
||||
$fields->addFieldToTab(
|
||||
"Root.Main",
|
||||
CheckboxField::create("ShowFullEntry", "Show Full Entry")
|
||||
->setDescription('Show full content in overviews rather than summary'),
|
||||
"Content"
|
||||
);
|
||||
|
||||
$this->extend('updateCMSFields', $fields);
|
||||
|
||||
|
@ -123,12 +128,18 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||
$blogholder->Title = "Blog";
|
||||
$blogholder->URLSegment = "blog";
|
||||
$blogholder->Status = "Published";
|
||||
$blogholder->write();
|
||||
$blogholder->publish("Stage", "Live");
|
||||
|
||||
// Add default widgets to first found WidgetArea relationship
|
||||
if(class_exists('WidgetArea')) {
|
||||
foreach($this->has_one() as $name => $class) {
|
||||
if(is_a($class, 'WidgetArea', true)) {
|
||||
$relationName = "{$name}ID";
|
||||
$widgetarea = new WidgetArea();
|
||||
$widgetarea->write();
|
||||
|
||||
$blogholder->SideBarID = $widgetarea->ID;
|
||||
$blogholder->$relationName = $widgetarea->ID;
|
||||
$blogholder->write();
|
||||
$blogholder->publish("Stage", "Live");
|
||||
|
||||
|
@ -145,17 +156,17 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||
$archivewidget->write();
|
||||
|
||||
$widgetarea->write();
|
||||
} else {
|
||||
$blogholder->write();
|
||||
$blogholder->publish("Stage", "Live");
|
||||
}
|
||||
|
||||
break; // only apply to one
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$blog = new BlogEntry();
|
||||
$blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed");
|
||||
$blog->URLSegment = 'sample-blog-entry';
|
||||
$blog->Tags = _t('BlogHolder.SUCTAGS',"silverstripe, blog");
|
||||
$blog->Content = _t('BlogHolder.SUCCONTENT',"<p>Congratulations, the SilverStripe blog module has been successfully installed. This blog entry can be safely deleted. You can configure aspects of your blog (such as the widgets displayed in the sidebar) in <a href=\"admin\">the CMS</a>.</p>");
|
||||
$blog->Content = _t('BlogHolder.SUCCONTENT',"<p>Congratulations, the SilverStripe blog module has been successfully installed. This blog entry can be safely deleted. You can configure aspects of your blog in <a href=\"admin\">the CMS</a>.</p>");
|
||||
$blog->Status = "Published";
|
||||
$blog->ParentID = $blogholder->ID;
|
||||
$blog->write();
|
||||
|
@ -164,6 +175,10 @@ class BlogHolder extends BlogTree implements PermissionProvider {
|
|||
DB::alteration_message("Blog page created","created");
|
||||
}
|
||||
}
|
||||
|
||||
function providePermissions() {
|
||||
return array("BLOGMANAGEMENT" => "Blog management");
|
||||
}
|
||||
}
|
||||
|
||||
class BlogHolder_Controller extends BlogTree_Controller {
|
||||
|
@ -190,10 +205,6 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||
return BBCodeParser::usable_tags();
|
||||
}
|
||||
|
||||
function providePermissions() {
|
||||
return array("BLOGMANAGEMENT" => "Blog management");
|
||||
}
|
||||
|
||||
/**
|
||||
* Post a new blog entry
|
||||
*/
|
||||
|
@ -306,6 +317,3 @@ class BlogHolder_Controller extends BlogTree_Controller {
|
|||
$this->redirect($this->Link());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
@ -40,8 +40,6 @@ class BlogTree extends Page {
|
|||
'BlogTree', 'BlogHolder'
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Finds the BlogTree object most related to the current page.
|
||||
* - If this page is a BlogTree, use that
|
||||
|
@ -91,24 +89,17 @@ class BlogTree extends Page {
|
|||
return $freshness;
|
||||
}
|
||||
|
||||
function SideBar() {
|
||||
if($this->InheritSideBar && $this->getParent()) {
|
||||
if (method_exists($this->getParent(), 'SideBar')) return $this->getParent()->SideBar();
|
||||
}
|
||||
|
||||
if($this->SideBarID){
|
||||
return DataObject::get_by_id('WidgetArea', $this->SideBarID);
|
||||
// @todo: This segfaults - investigate why then fix: return $this->getComponent('SideBar');
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------- CMS CONTROL -------------- */
|
||||
|
||||
function getCMSFields() {
|
||||
$fields = parent::getCMSFields();
|
||||
function getSettingsFields() {
|
||||
$fields = parent::getSettingsFields();
|
||||
|
||||
$fields->addFieldToTab("Root.Main", new TextField("Name", "Name of blog"), "Content");
|
||||
$fields->addFieldToTab('Root.Main', new DropdownField('LandingPageFreshness', 'When you first open the blog, how many entries should I show', array(
|
||||
$fields->addFieldToTab(
|
||||
'Root.Settings',
|
||||
new DropdownField(
|
||||
'LandingPageFreshness',
|
||||
'When you first open the blog, how many entries should I show',
|
||||
array(
|
||||
"" => "All entries",
|
||||
"1" => "Last month's entries",
|
||||
"2" => "Last 2 months' entries",
|
||||
|
@ -123,12 +114,9 @@ class BlogTree extends Page {
|
|||
"11" => "Last 11 months' entries",
|
||||
"12" => "Last year's entries",
|
||||
"INHERIT" => "Take value from parent Blog Tree"
|
||||
)), "Content");
|
||||
if(class_exists('WidgetArea')) {
|
||||
$fields->addFieldToTab("Root.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent'));
|
||||
$fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("SideBar"));
|
||||
}
|
||||
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
@ -296,7 +284,7 @@ class BlogTree_Controller extends Page_Controller {
|
|||
function rss() {
|
||||
global $project_name;
|
||||
|
||||
$blogName = $this->Name;
|
||||
$blogName = $this->Title;
|
||||
$altBlogName = $project_name . ' blog';
|
||||
|
||||
$entries = $this->Entries(20);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
if(class_exists('Widget')) {
|
||||
/**
|
||||
* Shows a widget with viewing blog entries
|
||||
* by months or years.
|
||||
*
|
||||
* @package blog
|
||||
*/
|
||||
class ArchiveWidget extends Widget {
|
||||
class ArchiveWidget extends Widget {
|
||||
private static $db = array(
|
||||
'DisplayMode' => 'Varchar'
|
||||
);
|
||||
|
@ -106,6 +107,6 @@ class ArchiveWidget extends Widget {
|
|||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
if(class_exists('Widget')) {
|
||||
|
||||
/**
|
||||
* Blog Management Widget
|
||||
* @package blog
|
||||
*/
|
||||
class BlogManagementWidget extends Widget implements PermissionProvider {
|
||||
class BlogManagementWidget extends Widget {
|
||||
private static $db = array();
|
||||
|
||||
private static $has_one = array();
|
||||
|
@ -45,13 +47,9 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
|
|||
}
|
||||
}
|
||||
|
||||
function providePermissions() {
|
||||
return array("BLOGMANAGEMENT" => "Blog management");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class BlogManagementWidget_Controller extends Widget_Controller {
|
||||
class BlogManagementWidget_Controller extends Widget_Controller {
|
||||
|
||||
function WidgetHolder() {
|
||||
if(Permission::check("BLOGMANAGEMENT")) {
|
||||
|
@ -63,5 +61,6 @@ class BlogManagementWidget_Controller extends Widget_Controller {
|
|||
$container = BlogTree::current();
|
||||
return ($container && $container->ClassName != "BlogTree") ? $container->Link('post') : false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
class BlogTreeExtension extends DataExtension {
|
||||
|
||||
private static $has_one = array("SideBar" => "WidgetArea");
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class RSSWidget extends Widget {
|
||||
if(class_exists('Widget')) {
|
||||
class RSSWidget extends Widget {
|
||||
private static $db = array(
|
||||
"RSSTitle" => "Text",
|
||||
"RssUrl" => "Text",
|
||||
|
@ -91,6 +91,6 @@ class RSSWidget extends Widget {
|
|||
return $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
if(class_exists('Widget')) {
|
||||
/**
|
||||
* A simple widget that just shows a link
|
||||
* to this website's blog RSS, with an RSS
|
||||
* icon.
|
||||
*
|
||||
* @package blog
|
||||
*/
|
||||
class SubscribeRSSWidget extends Widget {
|
||||
class SubscribeRSSWidget extends Widget {
|
||||
|
||||
private static $title = 'Subscribe via RSS';
|
||||
|
||||
|
@ -26,6 +26,6 @@ class SubscribeRSSWidget extends Widget {
|
|||
$container = BlogTree::current();
|
||||
if ($container) return $container->Link('rss');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
div.flickrwidget {
|
||||
text-align: center;
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
<div id="Sidebar" class="typography">
|
||||
$SideBar
|
||||
</div>
|
||||
<% if SideBarView %>
|
||||
<div id="Sidebar" class="typography">
|
||||
$SideBarView
|
||||
</div>
|
||||
<% end_if %>
|
Loading…
Reference in New Issue