aboutsummaryrefslogtreecommitdiff
path: root/engine/classes
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2012-02-09 21:13:50 -0500
committerCash Costello <cash.costello@gmail.com>2012-02-09 21:16:27 -0500
commitd26a5cb9cd5c49ec2c3fe94a1bbbc7f8b81cd010 (patch)
tree6d29b14f54e946820e3d75cc429cd8c4e2afb204 /engine/classes
parent1f4a462d84a2bda542580828d1c39bec0a5a6495 (diff)
downloadelgg-d26a5cb9cd5c49ec2c3fe94a1bbbc7f8b81cd010.tar.gz
elgg-d26a5cb9cd5c49ec2c3fe94a1bbbc7f8b81cd010.tar.bz2
Fixes #4283 moving widgets from inactive plugins to the bottom of columns
Diffstat (limited to 'engine/classes')
-rw-r--r--engine/classes/ElggWidget.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/engine/classes/ElggWidget.php b/engine/classes/ElggWidget.php
index 7914fa140..99708f66a 100644
--- a/engine/classes/ElggWidget.php
+++ b/engine/classes/ElggWidget.php
@@ -131,11 +131,21 @@ class ElggWidget extends ElggObject {
usort($widgets, create_function('$a,$b','return (int)$a->order > (int)$b->order;'));
+ // remove widgets from inactive plugins
+ $widget_types = elgg_get_widget_types($this->context);
+ $inactive_widgets = array();
+ foreach ($widgets as $index => $widget) {
+ if (!array_key_exists($widget->handler, $widget_types)) {
+ $inactive_widgets[] = $widget;
+ unset($widgets[$index]);
+ }
+ }
+
if ($rank == 0) {
// top of the column
- $this->order = $widgets[0]->order - 10;
+ $this->order = reset($widgets)->order - 10;
} elseif ($rank == (count($widgets) - 1)) {
- // bottom of the column
+ // bottom of the column of active widgets
$this->order = end($widgets)->order + 10;
} else {
// reorder widgets
@@ -147,7 +157,7 @@ class ElggWidget extends ElggObject {
}
}
- // split the array in two and recombine with the moved array in middle
+ // split the array in two and recombine with the moved widget in middle
$before = array_slice($widgets, 0, $rank);
array_push($before, $this);
$after = array_slice($widgets, $rank);
@@ -159,6 +169,22 @@ class ElggWidget extends ElggObject {
$order += 10;
}
}
+
+ // put inactive widgets at the bottom
+ if ($inactive_widgets) {
+ $bottom = 0;
+ foreach ($widgets as $widget) {
+ if ($widget->order > $bottom) {
+ $bottom = $widget->order;
+ }
+ }
+ $bottom += 10;
+ foreach ($inactive_widgets as $widget) {
+ $widget->order = $bottom;
+ $bottom += 10;
+ }
+ }
+
$this->column = $column;
}