* @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;
}
/**
$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;
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;
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;
.widget {
background-color: #dedede;
padding: 2px;
- margin-bottom: 15px;
+ margin: 0 5px 15px;
}
.widget_title {
height: 30px;
$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) {
$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);
}
}
$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>