diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-20 15:35:14 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-20 15:35:14 +0000 |
commit | 078d930d12f450f32f1b7d1976e5d3fe0aa01808 (patch) | |
tree | 5fc29b3cde5c9f84902851739b907697dbd8b81d /views/default/widgets/add_panel.php | |
parent | 95c79a67493521d2d9761fde60ccfbf2af48ce87 (diff) | |
download | elgg-078d930d12f450f32f1b7d1976e5d3fe0aa01808.tar.gz elgg-078d930d12f450f32f1b7d1976e5d3fe0aa01808.tar.bz2 |
Refs #472 not allowing widgets to be added if only single instance allowed
git-svn-id: http://code.elgg.org/elgg/trunk@7384 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/widgets/add_panel.php')
-rw-r--r-- | views/default/widgets/add_panel.php | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/views/default/widgets/add_panel.php b/views/default/widgets/add_panel.php index 70d80f41c..09511487c 100644 --- a/views/default/widgets/add_panel.php +++ b/views/default/widgets/add_panel.php @@ -1,10 +1,17 @@ <?php $widgets = $vars['widgets']; -$widget_types = elgg_get_widget_types(); - $context = $vars['context']; +$widget_types = elgg_get_widget_types($context); + +$current_handlers = array(); +foreach ($widgets as $column_widgets) { + foreach ($column_widgets as $widget) { + $current_handlers[] = $widget->handler; + } +} + ?> <div class="widgets_add_panel hidden"> <p> @@ -12,14 +19,17 @@ $context = $vars['context']; </p> <ul> <?php - foreach ($widget_types as $handler => $widget_type) { - $options = array( - 'text' => $widget_type->name, - 'href' => '#', - 'internalid' => $handler, - ); - $link = elgg_view('output/url', $options); - echo "<li>$link</li>"; + foreach ($widget_types as $handler => $widget_type) { + // check if widget added and only one instance allowed + if ($widget_type->multiple == false && in_array($handler, $current_handlers)) { + $class = 'widget_unavailable'; + $tooltip = elgg_echo('widget:unavailable'); + } else { + $class = 'widget_available'; + $tooltip = $widget_type->description; + } + + echo "<li title=\"$tooltip\" id=\"$handler\" class=\"$class\">$widget_type->name</li>"; } ?> </ul> |