Elgg  Version 3.0
widget.php
Go to the documentation of this file.
1 <?php
10 $widget = elgg_extract('entity', $vars);
11 if (!($widget instanceof \ElggWidget)) {
12  return;
13 }
14 
15 $handler = $widget->handler;
16 
17 $widget_instance = preg_replace('/[^a-z0-9-]/i', '-', "elgg-widget-instance-$handler");
18 
20 $widget_class[] = $widget->canEdit() ? 'elgg-state-draggable' : 'elgg-state-fixed';
21 
22 $body = '';
23 if ($widget->canEdit()) {
24  $settings = elgg_view('object/widget/elements/settings', [
25  'widget' => $widget,
26  'show_access' => elgg_extract('show_access', $vars, true),
27  ]);
28  $body .= $settings;
29 
30  if (empty($settings)) {
31  // store for determining the edit menu item
32  $vars['show_edit'] = false;
33  }
34 }
35 
36 $body .= elgg_view('object/widget/body', $vars);
37 
38 echo elgg_view_module('widget', '', $body, [
39  'class' => $widget_class,
40  'id' => "elgg-widget-$widget->guid",
41  'header' => elgg_view('object/widget/header', $vars),
42 ]);
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:1153
$widget
Widget object.
Definition: widget.php:10
elgg_view_module($type, $title, $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:1198
elgg echo
Translates a string.
Definition: languages.js:43
if(!($widget instanceof\ElggWidget)) $handler
Definition: widget.php:15
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:1131
$vars['type']
Definition: save.php:11
$widget_instance
Definition: widget.php:17
$settings
Definition: settings.php:3
$body
Definition: widget.php:22
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
$widget_class
Definition: widget.php:19