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:
Ingo Schommer 2013-04-29 09:14:30 +02:00
commit e33881615d
13 changed files with 326 additions and 339 deletions

View File

@ -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

View File

@ -1,3 +0,0 @@
<?php
if(class_exists('WidgetArea')) BlogTree::add_extension('BlogTreeExtension');

View File

@ -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');

View File

@ -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());
}
}
?>

View File

@ -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);

View File

@ -1,4 +1,5 @@
<?php
if(class_exists('Widget')) {
/**
* Shows a widget with viewing blog entries
* by months or years.
@ -108,4 +109,4 @@ class ArchiveWidget extends Widget {
}
}
?>
}

View File

@ -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,10 +47,6 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
}
}
function providePermissions() {
return array("BLOGMANAGEMENT" => "Blog management");
}
}
class BlogManagementWidget_Controller extends Widget_Controller {
@ -64,4 +62,5 @@ class BlogManagementWidget_Controller extends Widget_Controller {
return ($container && $container->ClassName != "BlogTree") ? $container->Link('post') : false;
}
}
?>
}

View File

@ -1,7 +0,0 @@
<?php
class BlogTreeExtension extends DataExtension {
private static $has_one = array("SideBar" => "WidgetArea");
}

View File

@ -1,5 +1,5 @@
<?php
if(class_exists('Widget')) {
class RSSWidget extends Widget {
private static $db = array(
"RSSTitle" => "Text",
@ -93,4 +93,4 @@ class RSSWidget extends Widget {
}
}
?>
}

View File

@ -1,5 +1,5 @@
<?php
if(class_exists('Widget')) {
/**
* A simple widget that just shows a link
* to this website's blog RSS, with an RSS
@ -28,4 +28,4 @@ class SubscribeRSSWidget extends Widget {
}
}
?>
}

View File

@ -1,3 +0,0 @@
div.flickrwidget {
text-align: center;
}

View File

@ -1,3 +1,5 @@
<% if SideBarView %>
<div id="Sidebar" class="typography">
$SideBar
$SideBarView
</div>
<% end_if %>