Elgg  Version 4.3
message.php
Go to the documentation of this file.
1 <?php
14 $type = 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 ($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 
elgg_language_key_exists($key, $language= 'en')
Check if a given language key exists.
Definition: languages.php:46
$type
Elgg message element (all unsupported vars will be passed as attributes to the container) ...
Definition: message.php:14
$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
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:569
$body
Definition: message.php:17
elgg_view_image_block($image, $body, $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:923
$title
Definition: message.php:15
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:135
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:547
$menu
Definition: message.php:16
if(empty($title)&&empty($body)) if(!empty($link)) if($type) $default_icons
Definition: message.php:36
elgg_view_icon($name, $vars=[])
View an icon glyph.
Definition: views.php:1297
elgg echo
Translates a string.
Definition: deprecated.js:530
$vars['head']
Definition: html.php:24
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
if(empty($title)&&empty($body)) if(!empty($link)) if($type) $default_icon_name
Definition: message.php:45