mirror of
https://github.com/silverstripe/silverstripe-widgets
synced 2024-10-22 17:05:54 +02:00
Merge pull request #51 from NoBone/0.1
Updated Widget module to show hide Widgets in specified WidgetArea
This commit is contained in:
commit
1b54cfc321
code
@ -35,14 +35,20 @@ class WidgetAreaEditor extends FormField {
|
|||||||
* @return ArrayList
|
* @return ArrayList
|
||||||
*/
|
*/
|
||||||
public function AvailableWidgets() {
|
public function AvailableWidgets() {
|
||||||
|
|
||||||
$widgets= new ArrayList();
|
$widgets= new ArrayList();
|
||||||
|
|
||||||
foreach($this->widgetClasses as $widgetClass) {
|
foreach($this->widgetClasses as $widgetClass) {
|
||||||
$classes = ClassInfo::subclassesFor($widgetClass);
|
$classes = ClassInfo::subclassesFor($widgetClass);
|
||||||
array_shift($classes);
|
array_shift($classes);
|
||||||
foreach($classes as $class) {
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ class Widget extends DataObject {
|
|||||||
'Enabled' => true
|
'Enabled' => true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public static $only_available_in = array();
|
||||||
|
|
||||||
public static $has_one = array(
|
public static $has_one = array(
|
||||||
"Parent" => "WidgetArea",
|
"Parent" => "WidgetArea",
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user