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
This commit is contained in:
Sean Harvey 2009-12-16 05:44:20 +00:00
parent b1bf03ffd1
commit 3a982497aa
2 changed files with 15 additions and 5 deletions

View File

@ -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 File

@ -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 @@ class WidgetArea extends DataObject {
}
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() {