Elgg  Version 2.3
add_panel.php
Go to the documentation of this file.
1 <?php
11 $widgets = elgg_extract('widgets', $vars);
12 $context = elgg_extract('context', $vars);
13 $exact = elgg_extract('exact_match', $vars, false);
15 
17  'context' => $context,
18  'exact' => $exact,
19  'container' => $container,
20 ]);
21 uasort($widget_types, function($a, $b) {
22  return strcmp($a->name,$b->name);
23 });
24 
26 foreach ($widgets as $column_widgets) {
27  foreach ($column_widgets as $widget) {
28  $current_handlers[] = $widget->handler;
29  }
30 }
31 
32 ?>
33 <div class="elgg-widgets-add-panel hidden clearfix" id="widgets-add-panel">
34  <p>
35  <?php echo elgg_echo('widgets:add:description'); ?>
36  </p>
37  <ul>
38 <?php
39  foreach ($widget_types as $handler => $widget_type) {
40  // check if widget added and only one instance allowed
41  if ($widget_type->multiple == false && in_array($handler, $current_handlers)) {
42  $class = 'elgg-state-unavailable';
43  $tooltip = elgg_echo('widget:unavailable');
44  } else {
45  $class = 'elgg-state-available';
46  $tooltip = $widget_type->description;
47  }
48 
49  if ($widget_type->multiple) {
50  $class .= ' elgg-widget-multiple';
51  } else {
52  $class .= ' elgg-widget-single';
53  }
54 
55  echo "<li title=\"$tooltip\" class=\"$class\" data-elgg-widget-type=\"$handler\">$widget_type->name</li>";
56  }
57 ?>
58  </ul>
59 <?php
60  echo elgg_view('input/hidden', array(
61  'name' => 'widget_context',
62  'value' => $context
63  ));
64  echo elgg_view('input/hidden', array(
65  'name' => 'show_access',
66  'value' => (int)$vars['show_access']
67  ));
68 ?>
69 </div>
$context
Definition: add_panel.php:12
$widget_types
Definition: add_panel.php:16
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$class
Definition: field.php:20
$widget
Definition: delete.php:9
$exact
Definition: add_panel.php:13
$vars['entity']
ul
Definition: admin.css.php:44
$container
Definition: add_panel.php:14
fieldset div
Definition: admin.css.php:485
elgg echo
Translates a string.
Definition: languages.js:48
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:336
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:56
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1375
p
Definition: admin.css.php:118
$widgets
Widget add panel.
Definition: add_panel.php:11
elgg_get_widget_types($context="", $exact=false)
Get the widget types for a context.
Definition: widgets.php:140
$handler
Definition: add.php:10
$current_handlers
Definition: add_panel.php:25