aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggWidget.php
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2012-01-12 16:15:16 +0100
committerSem <sembrestels@riseup.net>2012-01-12 16:15:16 +0100
commitcc544cfa2086e418318a899ffd550adfb744c7ba (patch)
tree6c04fbe2e3df67513aa76803cb8d05c105ba219b /engine/classes/ElggWidget.php
parente7d64510ebd823f186282e2b80780295bcca1b79 (diff)
parent68e4829ac0959d86c651e7ed6dc255c39694c8af (diff)
downloadelgg-cc544cfa2086e418318a899ffd550adfb744c7ba.tar.gz
elgg-cc544cfa2086e418318a899ffd550adfb744c7ba.tar.bz2
Merge Elgg 1.8.3.
Diffstat (limited to 'engine/classes/ElggWidget.php')
-rw-r--r--engine/classes/ElggWidget.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/engine/classes/ElggWidget.php b/engine/classes/ElggWidget.php
index 0eb83913b..7914fa140 100644
--- a/engine/classes/ElggWidget.php
+++ b/engine/classes/ElggWidget.php
@@ -115,6 +115,8 @@ class ElggWidget extends ElggObject {
$options = array(
'type' => 'object',
'subtype' => 'widget',
+ 'container_guid' => $this->container_guid,
+ 'limit' => false,
'private_setting_name_value_pairs' => array(
array('name' => 'context', 'value' => $this->getContext()),
array('name' => 'column', 'value' => $column)
@@ -132,17 +134,30 @@ class ElggWidget extends ElggObject {
if ($rank == 0) {
// top of the column
$this->order = $widgets[0]->order - 10;
- } elseif ($rank == count($widgets)) {
+ } elseif ($rank == (count($widgets) - 1)) {
// bottom of the column
$this->order = end($widgets)->order + 10;
} else {
- // reorder widgets that are below
- $this->order = $widgets[$rank]->order;
- for ($index = $rank; $index < count($widgets); $index++) {
- if ($widgets[$index]->guid != $this->guid) {
- $widgets[$index]-> order += 10;
+ // reorder widgets
+
+ // remove the widget that's being moved from the array
+ foreach ($widgets as $index => $widget) {
+ if ($widget->guid == $this->guid) {
+ unset($widgets[$index]);
}
}
+
+ // split the array in two and recombine with the moved array in middle
+ $before = array_slice($widgets, 0, $rank);
+ array_push($before, $this);
+ $after = array_slice($widgets, $rank);
+ $widgets = array_merge($before, $after);
+ ksort($widgets);
+ $order = 0;
+ foreach ($widgets as $widget) {
+ $widget->order = $order;
+ $order += 10;
+ }
}
$this->column = $column;
}