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,26 +111,32 @@ class BlogHolder extends BlogTree implements PermissionProvider {
$blogholder->URLSegment = "blog"; $blogholder->URLSegment = "blog";
$blogholder->Status = "Published"; $blogholder->Status = "Published";
$widgetarea = new WidgetArea(); if(class_exists('WidgetArea')) {
$widgetarea->write(); $widgetarea = new WidgetArea();
$widgetarea->write();
$blogholder->SideBarID = $widgetarea->ID; $blogholder->SideBarID = $widgetarea->ID;
$blogholder->write(); $blogholder->write();
$blogholder->publish("Stage", "Live"); $blogholder->publish("Stage", "Live");
$managementwidget = new BlogManagementWidget(); $managementwidget = new BlogManagementWidget();
$managementwidget->ParentID = $widgetarea->ID; $managementwidget->ParentID = $widgetarea->ID;
$managementwidget->write(); $managementwidget->write();
$tagcloudwidget = new TagCloudWidget(); $tagcloudwidget = new TagCloudWidget();
$tagcloudwidget->ParentID = $widgetarea->ID; $tagcloudwidget->ParentID = $widgetarea->ID;
$tagcloudwidget->write(); $tagcloudwidget->write();
$archivewidget = new ArchiveWidget(); $archivewidget = new ArchiveWidget();
$archivewidget->ParentID = $widgetarea->ID; $archivewidget->ParentID = $widgetarea->ID;
$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");
}