Elgg  Version master
message.php
Go to the documentation of this file.
1 <?php
14 $type = (string) elgg_extract('type', $vars, false);
17 $body = elgg_extract('body', $vars, '');
19 
20 if (empty($title) && empty($body)) {
21  return;
22 }
23 
24 if (!empty($link)) {
25  $body = elgg_view_image_block('', $body, ['image_alt' => $link]);
26 }
27 
28 $attrs = [
29  'class' => elgg_extract_class($vars, 'elgg-message'),
30 ];
31 
32 if (!empty($type)) {
33  $attrs['class'][] = "elgg-message-{$type}";
34 }
35 
37  'error' => 'exclamation-circle',
38  'help' => 'question-circle',
39  'notice' => 'info-circle',
40  'info' => 'info-circle',
41  'warning' => 'exclamation-triangle',
42  'success' => 'check-circle',
43 ];
44 
47 
48 if (is_null($title) && !empty($type) && elgg_language_key_exists("messages:title:{$type}")) {
49  $title = elgg_echo("messages:title:{$type}");
50 }
51 
52 $header = '';
53 if (!empty($title) && !empty($icon_name)) {
54  $header .= elgg_view_icon($icon_name, ['class' => 'elgg-message-icon']);
55 }
56 
57 if (!empty($title)) {
58  $header .= elgg_format_element('span', ['class' => 'elgg-message-title'], $title);
59 }
60 
61 if (!empty($menu)) {
62  $header .= elgg_format_element('span', ['class' => 'elgg-message-menu'], $menu);
63 }
64 
65 if (!empty($header)) {
66  $header = elgg_format_element('div', ['class' => 'elgg-head'], $header);
67 }
68 
69 if (!empty($body)) {
70  $body = elgg_format_element('div', ['class' => 'elgg-body'], $body);
71 }
72 
73 $contents = elgg_format_element('div', ['class' => 'elgg-inner'], $header . $body);
74 
75 unset($vars['type']);
76 unset($vars['title']);
77 unset($vars['icon_name']);
78 unset($vars['menu']);
79 unset($vars['body']);
80 unset($vars['link']);
81 unset($vars['class']);
82 
83 $attrs = array_merge($vars, $attrs);
84 
$type
Elgg message element (all unsupported vars will be passed as attributes to the container) ...
Definition: message.php:14
if(empty($title)&&empty($body)) if(!empty($link)) if(!empty($type)) $default_icons
Definition: message.php:36
elgg_view_image_block(string $image, string $body, array $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:898
if(empty($title)&&empty($body)) if(!empty($link)) if(!empty($type)) $default_icon_name
Definition: message.php:45
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$icon_name
Definition: message.php:46
$link
Definition: message.php:18
if(is_null($title)&&!empty($type)&&elgg_language_key_exists("messages:title:{$type}")) $header
Definition: message.php:52
$body
Definition: message.php:17
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_language_key_exists(string $key, string $language= 'en')
Check if a given language key exists.
Definition: languages.php:44
$title
Definition: message.php:15
elgg_view_icon(string $name, array $vars=[])
View an icon glyph.
Definition: views.php:1261
$menu
Definition: message.php:16
$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
if(empty($title)&&empty($body)) if(!empty($link)) $attrs
Definition: message.php:28
if(!empty($title)&&!empty($icon_name)) if(!empty($title)) if(!empty($menu)) if(!empty($header)) if(!empty($body)) $contents
Definition: message.php:73