From b27351533f22076a6741ca3ba9516bc4cef822e8 Mon Sep 17 00:00:00 2001 From: NoBone Date: Mon, 22 Apr 2013 16:17:29 +0300 Subject: [PATCH 1/2] Update Widget.php --- code/model/Widget.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/model/Widget.php b/code/model/Widget.php index ef41766..b51b835 100644 --- a/code/model/Widget.php +++ b/code/model/Widget.php @@ -20,6 +20,8 @@ class Widget extends DataObject { public static $defaults = array( 'Enabled' => true ); + + public static $only_available_in = array(); public static $has_one = array( "Parent" => "WidgetArea", From 9ee3b893fbdaa366efd98a6b32a3be4616dc1084 Mon Sep 17 00:00:00 2001 From: NoBone Date: Mon, 22 Apr 2013 16:18:07 +0300 Subject: [PATCH 2/2] Update WidgetAreaEditor.php --- code/form/WidgetAreaEditor.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/code/form/WidgetAreaEditor.php b/code/form/WidgetAreaEditor.php index 4edc40f..a2bac4a 100644 --- a/code/form/WidgetAreaEditor.php +++ b/code/form/WidgetAreaEditor.php @@ -35,14 +35,20 @@ class WidgetAreaEditor extends FormField { * @return ArrayList */ public function AvailableWidgets() { - $widgets= new ArrayList(); - + foreach($this->widgetClasses as $widgetClass) { $classes = ClassInfo::subclassesFor($widgetClass); array_shift($classes); foreach($classes as $class) { - $widgets->push(singleton($class)); + + if (!empty($class::$only_available_in) && is_array($class::$only_available_in)){ + if(in_array($this->Name, $class::$only_available_in)) { + $widgets->push(singleton($class)); + } + }else { + $widgets->push(singleton($class)); + } } }