MINOR make widgetarea/editor more suitable for generic use

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@95086 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Tom Rix 2009-12-14 01:26:49 +00:00 committed by Sam Minnee
parent 9302027d9c
commit b7cc159214
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() {