Skip to content
Browse files

ENHANCEMENT: make blog module independent of widget module

  • Loading branch information...
1 parent 5a21b4e commit efb12649268b8e28fbf9d8c69a29b940a28ee187 @cbarberis cbarberis committed May 28, 2012
Showing with 43 additions and 26 deletions.
  1. +2 −0 _config.php
  2. +26 −20 code/BlogHolder.php
  3. +8 −6 code/BlogTree.php
  4. +7 −0 code/widgets/BlogTreeExtension.php
View
2 _config.php
@@ -4,4 +4,6 @@
'metaweblog' => 'MetaWeblogController'
));
+if(class_exists('WidgetArea')) DataExtension::add_to_class('BlogTree','BlogTreeExtension');
+
?>
View
46 code/BlogHolder.php
@@ -111,26 +111,32 @@ function requireDefaultRecords() {
$blogholder->URLSegment = "blog";
$blogholder->Status = "Published";
- $widgetarea = new WidgetArea();
- $widgetarea->write();
-
- $blogholder->SideBarID = $widgetarea->ID;
- $blogholder->write();
- $blogholder->publish("Stage", "Live");
-
- $managementwidget = new BlogManagementWidget();
- $managementwidget->ParentID = $widgetarea->ID;
- $managementwidget->write();
-
- $tagcloudwidget = new TagCloudWidget();
- $tagcloudwidget->ParentID = $widgetarea->ID;
- $tagcloudwidget->write();
-
- $archivewidget = new ArchiveWidget();
- $archivewidget->ParentID = $widgetarea->ID;
- $archivewidget->write();
-
- $widgetarea->write();
+ if(class_exists('WidgetArea')) {
+ $widgetarea = new WidgetArea();
+ $widgetarea->write();
+
+ $blogholder->SideBarID = $widgetarea->ID;
+ $blogholder->write();
+ $blogholder->publish("Stage", "Live");
+
+ $managementwidget = new BlogManagementWidget();
+ $managementwidget->ParentID = $widgetarea->ID;
+ $managementwidget->write();
+
+ $tagcloudwidget = new TagCloudWidget();
+ $tagcloudwidget->ParentID = $widgetarea->ID;
+ $tagcloudwidget->write();
+
+ $archivewidget = new ArchiveWidget();
+ $archivewidget->ParentID = $widgetarea->ID;
+ $archivewidget->write();
+
+ $widgetarea->write();
+ } else {
+ $blogholder->write();
+ $blogholder->publish("Stage", "Live");
+ }
+
$blog = new BlogEntry();
$blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed");
View
14 code/BlogTree.php
@@ -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 @@ function getCMSFields() {
"12 MONTH" => "Last year's entries",
"INHERIT" => "Take value from parent Blog Tree"
)));
-
- $fields->addFieldToTab("Root.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent'));
- $fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("SideBar"));
+ if(class_exists('WidgetArea')) {
+ $fields->addFieldToTab("Root.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent'));
+ $fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("SideBar"));
+ }
+
return $fields;
}
View
7 code/widgets/BlogTreeExtension.php
@@ -0,0 +1,7 @@
+<?php
+
+class BlogTreeExtension extends DataExtension {
+
+ static $has_one = array("SideBar" => "WidgetArea");
+
+}

0 comments on commit efb1264

Please sign in to comment.
Something went wrong with that request. Please try again.