ENHANCEMENT: make blog module independent of widget module

This commit is contained in:
carlos barberis 2012-05-28 18:12:53 +12:00
parent 5a21b4eeb9
commit efb1264926
4 changed files with 38 additions and 21 deletions

View File

@ -4,4 +4,6 @@ Director::addRules(10, array(
'metaweblog' => 'MetaWeblogController' 'metaweblog' => 'MetaWeblogController'
)); ));
if(class_exists('WidgetArea')) DataExtension::add_to_class('BlogTree','BlogTreeExtension');
?> ?>

View File

@ -111,6 +111,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
$blogholder->URLSegment = "blog"; $blogholder->URLSegment = "blog";
$blogholder->Status = "Published"; $blogholder->Status = "Published";
if(class_exists('WidgetArea')) {
$widgetarea = new WidgetArea(); $widgetarea = new WidgetArea();
$widgetarea->write(); $widgetarea->write();
@ -131,6 +132,11 @@ class BlogHolder extends BlogTree implements PermissionProvider {
$archivewidget->write(); $archivewidget->write();
$widgetarea->write(); $widgetarea->write();
} else {
$blogholder->write();
$blogholder->publish("Stage", "Live");
}
$blog = new BlogEntry(); $blog = new BlogEntry();
$blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed"); $blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed");

View File

@ -23,9 +23,9 @@ class BlogTree extends Page {
'InheritSideBar' => True 'InheritSideBar' => True
); );
static $has_one = array( static $has_one = array();
"SideBar" => "WidgetArea",
); static $has_many = array();
static $allowed_children = array( static $allowed_children = array(
'BlogTree', 'BlogHolder' 'BlogTree', 'BlogHolder'
@ -113,9 +113,11 @@ class BlogTree extends Page {
"12 MONTH" => "Last year's entries", "12 MONTH" => "Last year's entries",
"INHERIT" => "Take value from parent Blog Tree" "INHERIT" => "Take value from parent Blog Tree"
))); )));
if(class_exists('WidgetArea')) {
$fields->addFieldToTab("Root.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent')); $fields->addFieldToTab("Root.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent'));
$fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("SideBar")); $fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("SideBar"));
}
return $fields; return $fields;
} }

View File

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