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'
));
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->Status = "Published";
$widgetarea = new WidgetArea();
$widgetarea->write();
if(class_exists('WidgetArea')) {
$widgetarea = new WidgetArea();
$widgetarea->write();
$blogholder->SideBarID = $widgetarea->ID;
$blogholder->write();
$blogholder->publish("Stage", "Live");
$blogholder->SideBarID = $widgetarea->ID;
$blogholder->write();
$blogholder->publish("Stage", "Live");
$managementwidget = new BlogManagementWidget();
$managementwidget->ParentID = $widgetarea->ID;
$managementwidget->write();
$managementwidget = new BlogManagementWidget();
$managementwidget->ParentID = $widgetarea->ID;
$managementwidget->write();
$tagcloudwidget = new TagCloudWidget();
$tagcloudwidget->ParentID = $widgetarea->ID;
$tagcloudwidget->write();
$tagcloudwidget = new TagCloudWidget();
$tagcloudwidget->ParentID = $widgetarea->ID;
$tagcloudwidget->write();
$archivewidget = new ArchiveWidget();
$archivewidget->ParentID = $widgetarea->ID;
$archivewidget->write();
$archivewidget = new ArchiveWidget();
$archivewidget->ParentID = $widgetarea->ID;
$archivewidget->write();
$widgetarea->write();
} else {
$blogholder->write();
$blogholder->publish("Stage", "Live");
}
$widgetarea->write();
$blog = new BlogEntry();
$blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed");

View File

@ -23,9 +23,9 @@ class BlogTree extends Page {
'InheritSideBar' => True
);
static $has_one = array(
"SideBar" => "WidgetArea",
);
static $has_one = array();
static $has_many = array();
static $allowed_children = array(
'BlogTree', 'BlogHolder'
@ -113,9 +113,11 @@ class BlogTree extends Page {
"12 MONTH" => "Last year's entries",
"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 WidgetAreaEditor("SideBar"));
}
$fields->addFieldToTab("Root.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent'));
$fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("SideBar"));
return $fields;
}

View File

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