Elgg  Version master
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 $widget_instance = preg_replace('/[^a-z0-9-]/i', '-', "elgg-widget-instance-{$widget->handler}");
17 
18 if ($widget->canEdit()) {
19  $widget_class[] = 'elgg-state-draggable';
20 
21  if (!elgg_view_exists("widgets/{$widget->handler}/edit") && elgg_extract('show_access', $vars) === false) {
22  // store for determining the edit menu item
23  $vars['show_edit'] = false;
24  }
25 }
26 
27 $body = elgg_view('object/widget/body', $vars);
28 
29 echo elgg_view_module('widget', '', $body, [
30  'class' => $widget_class,
31  'id' => "elgg-widget-{$widget->guid}",
32  'header' => elgg_view('object/widget/header', $vars),
33 ]);
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:919
$widget
Widget object.
Definition: widget.php:10
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
if(!$widget instanceof\ElggWidget) $widget_instance
Definition: widget.php:15
$vars
Definition: theme.php:5
elgg_extract_class(array $array, array|string $existing=[], string $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:277
if($widget->canEdit()) $body
Definition: widget.php:27
elgg_view_exists(string $view, string $viewtype= '', bool $recurse=true)
Returns whether the specified view exists.
Definition: views.php:131
$widget_class
Definition: widget.php:16