diff options
author | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-18 18:37:32 +0000 |
---|---|---|
committer | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-18 18:37:32 +0000 |
commit | dd09373e0cefa8d33d0e9faa741593802d53c2a7 (patch) | |
tree | ebf986bfabd17bfd5adb3b560e762b83f0a8b825 /views/default/page/components/widget.php | |
parent | 067c53f2575b96573b3c6966747bb0426669ae02 (diff) | |
download | elgg-dd09373e0cefa8d33d0e9faa741593802d53c2a7.tar.gz elgg-dd09373e0cefa8d33d0e9faa741593802d53c2a7.tar.bz2 |
Refs #2950: layout/objects => page/components
git-svn-id: http://code.elgg.org/elgg/trunk@8288 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/page/components/widget.php')
-rw-r--r-- | views/default/page/components/widget.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/views/default/page/components/widget.php b/views/default/page/components/widget.php new file mode 100644 index 000000000..d5e2c4ca2 --- /dev/null +++ b/views/default/page/components/widget.php @@ -0,0 +1,67 @@ +<?php +/** + * Widget object + * + * @uses $vars['entity'] ElggWidget + * @uses $vars['show_access'] Show the access control in edit area? (true) + */ + +$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('layout/objects/widget/settings', array( + 'widget' => $widget, + 'show_access' => $show_access, + )); +} +$controls = elgg_view('layout/objects/widget/controls', array( + 'widget' => $widget, + 'show_edit' => $edit_area != '', +)); + + +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"; +} + +echo <<<HTML +<div class="$widget_class" id="$widget_id"> + <div class="elgg-head"> + <h3>$title</h3> + $controls + </div> + <div class="elgg-body"> + $edit_area + <div class="elgg-widget-content"> + $content + </div> + </div> +</div> +HTML; |