Merge pull request #51 from NoBone/0.1

Updated Widget module to show hide Widgets in specified WidgetArea
This commit is contained in:
Will Rossiter 2013-05-08 03:04:35 -07:00
commit 1b54cfc321
2 changed files with 11 additions and 3 deletions

View File

@ -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));
}
}
}

View File

@ -21,6 +21,8 @@ class Widget extends DataObject {
'Enabled' => true
);
public static $only_available_in = array();
public static $has_one = array(
"Parent" => "WidgetArea",
);