Elgg  Version 6.0
module.php
Go to the documentation of this file.
1 <?php
16 $type = (string) elgg_extract('type', $vars);
17 $title = (string) elgg_extract('title', $vars);
18 $body = (string) elgg_extract('body', $vars);
19 $footer = (string) elgg_extract('footer', $vars);
20 $show_inner = (bool) elgg_extract('show_inner', $vars, false);
21 
22 $attrs = [
23  'id' => elgg_extract('id', $vars),
24  'class' => elgg_extract_class($vars, 'elgg-module'),
25 ];
26 
27 if (!elgg_is_empty($type)) {
28  $attrs['class'][] = "elgg-module-{$type}";
29 }
30 
31 $header = elgg_extract('header', $vars);
32 if (!elgg_is_empty($title)) {
33  $header = elgg_format_element('h2', [], $title);
34 }
35 
36 if ($header !== null) {
37  $menu = (string) elgg_extract('menu', $vars);
38  if ($menu) {
39  $header .= elgg_format_element('div', ['class' => 'elgg-module-menu'], $menu);
40  }
41 
42  $header = elgg_format_element('div', ['class' => 'elgg-head'], (string) $header);
43 }
44 
45 if (!elgg_is_empty($body)) {
46  $body = elgg_format_element('div', ['class' => 'elgg-body'], $body);
47 }
48 
49 if (!elgg_is_empty($footer)) {
50  $footer = elgg_format_element('div', ['class' => 'elgg-foot'], $footer);
51 }
52 
55  $contents = elgg_format_element('div', ['class' => 'elgg-inner'], $contents);
56 }
57 
58 echo elgg_format_element('section', $attrs, $contents);
$attrs
Definition: module.php:22
$title
Definition: module.php:17
elgg_is_empty($value)
Check if a value isn&#39;t empty, but allow 0 and &#39;0&#39;.
Definition: input.php:176
$type
Elgg module element.
Definition: module.php:16
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
if(!elgg_is_empty($type)) $header
Definition: module.php:31
$menu
Form body for setting up site menu.
Definition: save.php:7
$body
Definition: module.php:18
$show_inner
Definition: module.php:20
$vars
Definition: theme.php:5
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
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
$footer
Definition: module.php:19
if(!elgg_is_empty($title)) if($header!==null) if(!elgg_is_empty($body)) if(!elgg_is_empty($footer)) $contents
Definition: module.php:53