Permalink
Browse files

MINOR make widgetarea/editor more suitable for generic use (from r95086)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95632 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent b1bf03f commit 3a982497aad908dc87a018a7aa6f4f8d80849616 @halkyon halkyon committed Dec 16, 2009
Showing with 15 additions and 5 deletions.
  1. +6 −2 widgets/Widget.php
  2. +9 −3 widgets/WidgetArea.php
View
@@ -12,7 +12,12 @@
*/
class Widget extends DataObject {
static $db = array(
- "Sort" => "Int"
+ "Sort" => "Int",
+ "Enabled" => "Boolean"
+ );
+
+ static $defaults = array(
+ 'Enabled' => true
);
static $has_one = array(
@@ -22,7 +27,6 @@ class Widget extends DataObject {
static $has_many = array();
static $many_many = array();
static $belongs_many_many = array();
- static $defaults = array();
static $default_sort = "Sort";
View
@@ -18,6 +18,8 @@ class WidgetArea extends DataObject {
static $belongs_many_many = array();
+ public $template = __CLASS__;
+
/**
* Used in template instead of {@link Widgets()}
* to wrap each widget in its controller, making
@@ -45,15 +47,19 @@ function WidgetControllers() {
}
function Items() {
- return $this->Widgets();
+ return $this->getComponents('Widgets');
}
function ItemsToRender() {
- return $this->Items();
+ return $this->getComponents('Widgets', "Widget.Enabled = 1");
}
function forTemplate() {
- return $this->renderWith($this->class);
+ return $this->renderWith($this->template);
+ }
+
+ function setTemplate($template) {
+ $this->template = $template;
}
function onBeforeDelete() {

0 comments on commit 3a98249

Please sign in to comment.