aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/widgets.php32
-rw-r--r--views/default/css.php22
-rw-r--r--views/default/layouts/widgets.php15
-rw-r--r--views/default/widgets/wrapper.php4
4 files changed, 47 insertions, 26 deletions
diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php
index 79a3b37bf..5d6a7fcc1 100644
--- a/engine/lib/widgets.php
+++ b/engine/lib/widgets.php
@@ -154,8 +154,31 @@ function get_widgets($user_guid, $context, $column) {
* @return array|false An array of widget ElggObjects, or false
*/
function elgg_get_widgets($user_guid, $context) {
- // @todo implement elgg_get_entities_from_private_settings() first
- return false;
+ $options = array(
+ 'type' => 'object',
+ 'subtype' => 'widget',
+ 'owner_guid' => $user_guid,
+ 'private_setting_name' => 'context',
+ 'private_setting_value' => $context
+ );
+ $widgets = elgg_get_entities_from_private_settings($options);
+ if (!$widgets) {
+ return false;
+ }
+
+ $sorted_widgets = array();
+ foreach ($widgets as $widget) {
+ if (!isset($sorted_widgets[$widget->column])) {
+ $sorted_widgets[$widget->column] = array();
+ }
+ $sorted_widgets[$widget->column][$widget->order] = $widget;
+ }
+
+ foreach ($sorted_widgets as $col => $widgets) {
+ ksort($sorted_widgets[$col]);
+ }
+
+ return $sorted_widgets;
}
/**
@@ -193,12 +216,15 @@ function add_widget($entity_guid, $handler, $context, $order = 0, $column = 1, $
$widget->access_id = get_default_access();
}
+ $guid = $widget->save();
+
+ // private settings cannot be set until ElggWidget saved
$widget->handler = $handler;
$widget->context = $context;
$widget->column = $column;
$widget->order = $order;
- return $widget->save();
+ return $guid;
}
return false;
diff --git a/views/default/css.php b/views/default/css.php
index d5b96bf59..36c5c60ec 100644
--- a/views/default/css.php
+++ b/views/default/css.php
@@ -867,19 +867,13 @@ li.navigation_more ul li {
width: 100%;
}
.widget_2_columns {
- width: 48%;
- margin-right: 4%;
+ width: 50%;
}
.widget_3_columns {
- width: 32%;
- margin-right: 2%;
+ width: 33.3%;
}
.widget_4_columns {
- width: 23.5%;
- margin-right: 2%;
-}
-.widget_col_1 {
- margin-right: 0;
+ width: 25%;
}
#widget_add_button {
padding: 0px;
@@ -887,11 +881,15 @@ li.navigation_more ul li {
margin-bottom: 15px;
}
.widgets_add {
- width: 100%;
- padding: 10px;
+ width: 96%;
+ padding: 2%;
margin-bottom: 15px;
background: #dedede;
}
+.widgets_add ul {
+ padding: 0;
+ margin: 0;
+}
.widgets_add li {
float: left;
margin: 2px 10px;
@@ -906,7 +904,7 @@ li.navigation_more ul li {
.widget {
background-color: #dedede;
padding: 2px;
- margin-bottom: 15px;
+ margin: 0 5px 15px;
}
.widget_title {
height: 30px;
diff --git a/views/default/layouts/widgets.php b/views/default/layouts/widgets.php
index 38451d1c1..74cb6da8d 100644
--- a/views/default/layouts/widgets.php
+++ b/views/default/layouts/widgets.php
@@ -15,7 +15,7 @@ $owner = elgg_get_page_owner();
$context = elgg_get_context();
elgg_push_context('widgets');
-elgg_get_widgets($owner->guid, $context);
+$widgets = elgg_get_widgets($owner->guid, $context);
if (elgg_can_edit_widgets()) {
if ($show_add_widgets) {
@@ -32,18 +32,11 @@ echo $vars['box'];
$widget_class = "widget_{$num_columns}_columns";
for ($column_index = 1; $column_index <= $num_columns; $column_index++) {
- $widgets = get_widgets($owner->guid, $context, $column_index);
-
- // test code during design and implementation
- $widget1 = new ElggWidget();
- $widget1->handler = 'test';
- $widget2 = new ElggWidget();
- $widget2->handler = 'test';
- $widgets = array($widget1, $widget2);
+ $column_widgets = $widgets[$column_index];
echo "<div class=\"widget_column $widget_class widget_col_$column_index\">";
- if (is_array($widgets) && sizeof($widgets) > 0) {
- foreach ($widgets as $widget) {
+ if (is_array($column_widgets) && sizeof($column_widgets) > 0) {
+ foreach ($column_widgets as $widget) {
echo elgg_view_entity($widget);
}
}
diff --git a/views/default/widgets/wrapper.php b/views/default/widgets/wrapper.php
index 13d8da50e..51f4725b9 100644
--- a/views/default/widgets/wrapper.php
+++ b/views/default/widgets/wrapper.php
@@ -19,12 +19,16 @@ if ($vars['entity'] instanceof ElggObject && $vars['entity']->getSubtype() == 'w
$title = elgg_echo("error");
}
+$display_view = "widgets/$handler/view";
+$edit_view = "widgets/$handler/edit";
+
?>
<div class="widget draggable">
<div class="widget_title drag_handle">
<h3>Widget Title</h3>
</div>
<div class="widget_content">
+ <?php echo elgg_view($display_view, $vars); ?>
<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
</div>
</div>