add_panel.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Widget add panel
  4. *
  5. * @uses $vars['widgets'] Array of current widgets
  6. * @uses $vars['context'] The context for this widget layout
  7. * @uses $vars['exact_match'] Only use widgets that match the context
  8. */
  9. $widgets = $vars['widgets'];
  10. $context = $vars['context'];
  11. $exact = elgg_extract('exact_match', $vars, false);
  12. $widget_types = elgg_get_widget_types($context, $exact);
  13. uasort($widget_types, create_function('$a,$b', 'return strcmp($a->name,$b->name);'));
  14. $current_handlers = array();
  15. foreach ($widgets as $column_widgets) {
  16. foreach ($column_widgets as $widget) {
  17. $current_handlers[] = $widget->handler;
  18. }
  19. }
  20. ?>
  21. <div class="elgg-widgets-add-panel hidden clearfix" id="widgets-add-panel">
  22. <p>
  23. <?php echo elgg_echo('widgets:add:description'); ?>
  24. </p>
  25. <ul>
  26. <?php
  27. foreach ($widget_types as $handler => $widget_type) {
  28. // check if widget added and only one instance allowed
  29. if ($widget_type->multiple == false && in_array($handler, $current_handlers)) {
  30. $class = 'elgg-state-unavailable';
  31. $tooltip = elgg_echo('widget:unavailable');
  32. } else {
  33. $class = 'elgg-state-available';
  34. $tooltip = $widget_type->description;
  35. }
  36. if ($widget_type->multiple) {
  37. $class .= ' elgg-widget-multiple';
  38. } else {
  39. $class .= ' elgg-widget-single';
  40. }
  41. echo "<li title=\"$tooltip\" class=\"$class\" data-elgg-widget-type=\"$handler\">$widget_type->name</li>";
  42. }
  43. ?>
  44. </ul>
  45. <?php
  46. echo elgg_view('input/hidden', array(
  47. 'name' => 'widget_context',
  48. 'value' => $context
  49. ));
  50. echo elgg_view('input/hidden', array(
  51. 'name' => 'show_access',
  52. 'value' => (int)$vars['show_access']
  53. ));
  54. ?>
  55. </div>