--- /dev/null
+<?php
+/**
+ * Elgg widget delete action
+ *
+ * @package Elgg.Core
+ * @subpackage Widgets.Management
+ */
+
+$guid = get_input('guid');
+
+$user = get_loggedin_user();
+
+$widget = get_entity($guid);
+if ($widget && $user->canEdit() && $widget->delete()) {
+ forward(REFERER);
+}
+
+register_error(elgg_echo('widgets:remove:failure'));
+forward(REFERER);
}
$this->column = $column;
}
+
+ public function canEdit($user_guid = 0) {
+ return true;
+ }
}
\ No newline at end of file
register_action('widgets/save');
register_action('widgets/add');
register_action('widgets/move');
+ register_action('widgets/delete');
// Now run this stuff, but only once
run_function_once("widget_run_once");
event.preventDefault();\r
});\r
\r
+ $('a.widget_delete').bind('click', elgg.ui.widgets.remove);\r
+\r
elgg.ui.widgets.equalHeight(".widget_column");\r
};\r
\r
// insert a widget into the layout\r
elgg.ui.widgets.insert = function(html) {\r
$('#widget_col_1').prepend(html);\r
+ $('#widget_col_1').children(":first").find('a.widget_delete').bind('click', elgg.ui.widgets.remove);\r
+}\r
+\r
+// remove a widget from the layout\r
+elgg.ui.widgets.remove = function(event) {\r
+ $(this).parent().parent().parent().parent().remove();\r
+ elgg.action('widgets/delete', {\r
+ data: {\r
+ // widget_delete_<guid>\r
+ guid: $(this).attr('id').substring(14)\r
+ }\r
+ });\r
+ event.preventDefault();\r
}\r
\r
+\r
elgg.ui.widgets.equalHeight = function(selector) {\r
var maxHeight = 0;\r
$(selector).each(function() {\r
'widgets:add:success' => "The widget was successfully added.",
'widgets:add:failure' => "We could not add your widget.",
'widgets:move:failure' => "We could not store the new widget position.",
+ 'widgets:remove:failure' => "Unable to remove this widget",
'widgets:handlernotfound' => 'This widget is either broken or has been disabled by the site administrator.',
/**
*************************************** */
.widget_column {
float: right;
- min-height: 15px;
+ min-height: 30px;
}
.widget_1_columns {
width: 100%;
padding: 0px;
text-align: right;
margin-bottom: 15px;
+ margin-right: 5px;
}
.widgets_add {
- width: 96%;
- padding: 2%;
- margin-bottom: 15px;
+ padding: 10px;
+ margin: 0 5px 15px;
background: #dedede;
}
.widgets_add ul {
line-height: 30px;
}
.widget_title h3 {
+ float: left;
padding: 0 5px;
}
+.widget_title ul, .widget_title li {
+ float: right;
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+.widget_title li {
+ margin: 0 4px;
+}
.widget_content {
background-color: #ffffff;
padding: 10px;
--- /dev/null
+<?php
+/**
+ * Elgg widget controls
+ *
+ * @package Elgg
+ * @subpackage Core
+ */
+
+$widget = $vars['widget'];
+
+$params = array(
+ 'text' => 'delete',
+ 'href' => '#', //elgg_get_site_url() . "action/widgets/delete?guid=$widget->guid",
+ 'is_action' => true,
+ 'class' => 'widget_delete',
+ 'internalid' => "widget_delete_$widget->guid"
+);
+$delete_link = elgg_view('output/url', $params);
+
+$params = array(
+ 'text' => 'edit',
+ 'href' => elgg_get_site_url() . "#",
+ 'is_action' => true,
+);
+$edit_link = elgg_view('output/url', $params);
+
+echo <<<___END
+<ul>
+ <li>$delete_link</li>
+ <li>$edit_link</li>
+</ul>
+___END;
$title = elgg_echo("error");
}
+$title = "Widget Title";
+
$display_view = "widgets/$handler/view";
$edit_view = "widgets/$handler/edit";
?>
<div class="widget draggable" id="widget_<?php echo $widget->guid; ?>">
<div class="widget_title drag_handle">
- <h3>Widget Title</h3>
- </div>
- <div class="widget_content">
+ <h3><?php echo $title; ?></h3>
+ <?php
+ if ($widget->canEdit()) {
+ echo elgg_view('widgets/controls', array('widget' => $widget));
+ }
+ ?>
+ </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>