From 561c160ed8db7f418cc5ae34e04b959be5066442 Mon Sep 17 00:00:00 2001 From: cash Date: Tue, 25 Jan 2011 12:12:54 +0000 Subject: converted widgets to modules git-svn-id: http://code.elgg.org/elgg/trunk@7928 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/layout/objects/widget.php | 63 ++++++++++++++-------- views/default/layout/objects/widget/controls.php | 27 +++++----- views/default/layout/objects/widget/settings.php | 24 +++++---- views/default/layout/shells/widgets.php | 6 ++- views/default/layout/shells/widgets/add_button.php | 6 ++- views/default/layout/shells/widgets/add_panel.php | 4 +- 6 files changed, 77 insertions(+), 53 deletions(-) (limited to 'views/default/layout') diff --git a/views/default/layout/objects/widget.php b/views/default/layout/objects/widget.php index d9a0681af..727b04533 100644 --- a/views/default/layout/objects/widget.php +++ b/views/default/layout/objects/widget.php @@ -2,7 +2,8 @@ /** * Widget object * - * @uses $vars['entity'] + * @uses $vars['entity'] ElggWidget + * @uses $vars['show_access'] Show the access control in edit area? (true) */ $widget = $vars['entity']; @@ -10,41 +11,57 @@ if (!elgg_instanceof($widget, 'object', 'widget')) { return true; } +$show_access = elgg_get_array_value('show_access', $vars, true); + // @todo catch for disabled plugins -$widgettypes = elgg_get_widget_types('all'); +$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 << +
+

$title

+ $controls
- $widget)); - ?> -
- $widget)); - } - ?> +
+ $edit_area
- + $content
+HTML; diff --git a/views/default/layout/objects/widget/controls.php b/views/default/layout/objects/widget/controls.php index 9693ba42f..bd1e96ea7 100644 --- a/views/default/layout/objects/widget/controls.php +++ b/views/default/layout/objects/widget/controls.php @@ -2,18 +2,17 @@ /** * Elgg widget controls * - * @package Elgg - * @subpackage Core + * @uses $vars['widget'] + * @uses $vars['show_edit'] Whether to show the edit button (true) */ $widget = $vars['widget']; +$show_edit = elgg_get_array_value('show_edit', $vars, true); $params = array( 'text' => ' ', 'href' => "#", 'class' => 'elgg-widget-collapse-button', -// 'internalid' => "elgg-toggler-widget-$widget->guid" -// 'internalid' => "elgg-widget-collapse-button-$widget->guid" ); $collapse_link = elgg_view('output/url', $params); @@ -29,20 +28,20 @@ if ($widget->canEdit()) { ); $delete_link = elgg_view('output/url', $params); - $params = array( - 'text' => ' ', - 'title' => elgg_echo('widget:edit'), - 'href' => "#", - 'class' => 'elgg-widget-edit-button elgg-toggle', - 'internalid' => "elgg-toggler-widget-$widget->guid" - ); - $edit_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', + 'internalid' => "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/layout/objects/widget/settings.php b/views/default/layout/objects/widget/settings.php index 8020983c6..c53ea8fc6 100644 --- a/views/default/layout/objects/widget/settings.php +++ b/views/default/layout/objects/widget/settings.php @@ -2,27 +2,31 @@ /** * Elgg widget edit settings * - * @package Elgg - * @subpackage Core + * @uses $vars['widget'] + * @uses $vars['show_access'] */ $widget = $vars['widget']; +$show_access = elgg_get_array_value('show_access', $vars, true); $edit_view = "widgets/$widget->handler/edit"; $custom_form_section = elgg_view($edit_view, array('entity' => $widget)); -$access_label = elgg_echo('access'); -$access = elgg_view('input/access', array('internalname' => 'params[access_id]','value' => $widget->access_id)); -$access_html = "

$access

"; +$access = ''; +if ($show_access) { + $access = elgg_view('input/access', array( + 'internalname' => 'params[access_id]', + 'value' => $widget->access_id, + )); +} + +if (!$custom_form_section && !$access) { + return true; +} $hidden = elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $widget->guid)); $submit = elgg_view('input/submit', array('value' => elgg_echo('save'))); -// dashboard widgets do not get access controls -if (elgg_in_context('dashboard')) { - $access = ''; -} - $body = <<<___END $custom_form_section $access diff --git a/views/default/layout/shells/widgets.php b/views/default/layout/shells/widgets.php index 656a0e4c3..f47c90f03 100644 --- a/views/default/layout/shells/widgets.php +++ b/views/default/layout/shells/widgets.php @@ -6,12 +6,14 @@ * @uses $vars['num_columns'] Number of widget columns for this layout (3) * @uses $vars['show_add_widgets'] Display the add widgets button and panel (true) * @uses $vars['exact_match'] Widgets must match the current context (false) + * @uses $vars['show_access'] Show the access control (true) */ $box = elgg_get_array_value('box', $vars, ''); $num_columns = elgg_get_array_value('num_columns', $vars, 3); $show_add_widgets = elgg_get_array_value('show_add_widgets', $vars, true); $exact_match = elgg_get_array_value('exact_match', $vars, false); +$show_access = elgg_get_array_value('show_access', $vars, true); $owner = elgg_get_page_owner(); $context = elgg_get_context(); @@ -40,7 +42,7 @@ for ($column_index = 1; $column_index <= $num_columns; $column_index++) { echo "
"; if (is_array($column_widgets) && sizeof($column_widgets) > 0) { foreach ($column_widgets as $widget) { - echo elgg_view_entity($widget); + echo elgg_view_entity($widget, array('show_access' => $show_access)); } } echo '
'; @@ -48,4 +50,4 @@ for ($column_index = 1; $column_index <= $num_columns; $column_index++) { elgg_pop_context(); -echo elgg_view('graphics/ajax_loader', array('internalid' => 'elgg-widget-loader')); \ No newline at end of file +echo elgg_view('graphics/ajax_loader', array('internalid' => 'elgg-widget-loader')); diff --git a/views/default/layout/shells/widgets/add_button.php b/views/default/layout/shells/widgets/add_button.php index 492f0f6fc..51b03edbb 100644 --- a/views/default/layout/shells/widgets/add_button.php +++ b/views/default/layout/shells/widgets/add_button.php @@ -3,6 +3,8 @@ * Button area for showing the add widgets panel */ ?> -
- + diff --git a/views/default/layout/shells/widgets/add_panel.php b/views/default/layout/shells/widgets/add_panel.php index 2d2a05a08..ff789cbd3 100644 --- a/views/default/layout/shells/widgets/add_panel.php +++ b/views/default/layout/shells/widgets/add_panel.php @@ -31,10 +31,10 @@ foreach ($widgets as $column_widgets) { $id = "elgg-widget-type-$handler"; // check if widget added and only one instance allowed if ($widget_type->multiple == false && in_array($handler, $current_handlers)) { - $class = 'elgg-widget-unavailable'; + $class = 'elgg-state-unavailable'; $tooltip = elgg_echo('widget:unavailable'); } else { - $class = 'elgg-widget-available'; + $class = 'elgg-state-available'; $tooltip = $widget_type->description; } -- cgit v1.2.3