aboutsummaryrefslogtreecommitdiff
path: root/views/default/object
diff options
context:
space:
mode:
Diffstat (limited to 'views/default/object')
-rw-r--r--views/default/object/widget.php73
-rw-r--r--views/default/object/widget/elements/controls.php47
-rw-r--r--views/default/object/widget/elements/settings.php13
3 files changed, 129 insertions, 4 deletions
diff --git a/views/default/object/widget.php b/views/default/object/widget.php
index efc8ef9ae..ce2dc33da 100644
--- a/views/default/object/widget.php
+++ b/views/default/object/widget.php
@@ -1,9 +1,74 @@
<?php
/**
- * Elgg default widget view
+ * Widget object
*
- * @package Elgg
- * @subpackage Core
+ * @uses $vars['entity'] ElggWidget
+ * @uses $vars['show_access'] Show the access control in edit area? (true)
*/
-echo elgg_view('page/components/widget', $vars);
+$widget = $vars['entity'];
+if (!elgg_instanceof($widget, 'object', 'widget')) {
+ return true;
+}
+
+$show_access = elgg_extract('show_access', $vars, true);
+
+// @todo catch for disabled plugins
+$widget_types = elgg_get_widget_types('all');
+
+$handler = $widget->handler;
+
+$title = $widget->getTitle();
+
+$edit_area = '';
+$can_edit = $widget->canEdit();
+if ($can_edit) {
+ $edit_area = elgg_view('object/widget/elements/settings', array(
+ 'widget' => $widget,
+ 'show_access' => $show_access,
+ ));
+}
+$controls = elgg_view('object/widget/elements/controls', array(
+ 'widget' => $widget,
+ 'show_edit' => $edit_area != '',
+));
+
+// don't show content for default widgets
+if (elgg_in_context('default_widgets')) {
+ $content = '';
+} else {
+ if (elgg_view_exists("widgets/$handler/content")) {
+ $content = elgg_view("widgets/$handler/content", $vars);
+ } else {
+ elgg_deprecated_notice("widgets use content as the display view", 1.8);
+ $content = elgg_view("widgets/$handler/view", $vars);
+ }
+}
+
+$widget_id = "elgg-widget-$widget->guid";
+$widget_instance = "elgg-widget-instance-$handler";
+$widget_class = "elgg-module elgg-module-widget";
+if ($can_edit) {
+ $widget_class .= " elgg-state-draggable $widget_instance";
+} else {
+ $widget_class .= " elgg-state-fixed $widget_instance";
+}
+
+$widget_header = <<<HEADER
+ <h3>$title</h3>
+ $controls
+HEADER;
+
+$widget_body = <<<BODY
+ $edit_area
+ <div class="elgg-widget-content">
+ $content
+ </div>
+BODY;
+
+echo elgg_view('page/components/module', array(
+ 'class' => $widget_class,
+ 'id' => $widget_id,
+ 'body' => $widget_body,
+ 'header' => $widget_header,
+));
diff --git a/views/default/object/widget/elements/controls.php b/views/default/object/widget/elements/controls.php
new file mode 100644
index 000000000..09f5fc947
--- /dev/null
+++ b/views/default/object/widget/elements/controls.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Elgg widget controls
+ *
+ * @uses $vars['widget']
+ * @uses $vars['show_edit'] Whether to show the edit button (true)
+ */
+
+$widget = $vars['widget'];
+$show_edit = elgg_extract('show_edit', $vars, true);
+
+$params = array(
+ 'text' => ' ',
+ 'href' => "#",
+ 'class' => 'elgg-widget-collapse-button',
+);
+$collapse_link = elgg_view('output/url', $params);
+
+$delete_link = $edit_link = '';
+if ($widget->canEdit()) {
+ $params = array(
+ 'text' => ' ',
+ 'title' => elgg_echo('widget:delete', array($widget->getTitle())),
+ 'href' => elgg_get_site_url() . "action/widgets/delete?guid=$widget->guid",
+ 'is_action' => true,
+ 'class' => 'elgg-widget-delete-button',
+ 'id' => "elgg-widget-delete-button-$widget->guid"
+ );
+ $delete_link = elgg_view('output/url', $params);
+
+ if ($show_edit) {
+ $params = array(
+ 'text' => ' ',
+ 'title' => elgg_echo('widget:edit'),
+ 'href' => "#",
+ 'class' => 'elgg-widget-edit-button elgg-toggle',
+ 'id' => "elgg-toggler-widget-$widget->guid"
+ );
+ $edit_link = elgg_view('output/url', $params);
+ }
+}
+
+echo <<<___END
+ $collapse_link
+ $delete_link
+ $edit_link
+___END;
diff --git a/views/default/object/widget/elements/settings.php b/views/default/object/widget/elements/settings.php
new file mode 100644
index 000000000..05cc7b5ce
--- /dev/null
+++ b/views/default/object/widget/elements/settings.php
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Elgg widget edit settings
+ *
+ * @uses $vars['widget']
+ */
+
+$widget = elgg_extract('widget', $vars);
+?>
+
+<div class="elgg-widget-edit" id="elgg-togglee-widget-<?php echo $widget->guid; ?>">
+ <?php echo elgg_view_form('widgets/save', array(), $vars); ?>
+</div>