Elgg  Version 3.0
message.php
Go to the documentation of this file.
1 <?php
12 $type = elgg_extract('type', $vars, false);
14 $body = elgg_extract('body', $vars, '');
15 
16 if (empty($title) && empty($body)) {
17  return;
18 }
19 
20 $attrs = [
21  'class' => elgg_extract_class($vars, 'elgg-message'),
22 ];
23 
24 if ($type) {
25  $attrs['class'][] = "elgg-message-$type";
26 }
27 
29  'error' => 'exclamation-circle',
30  'help' => 'question-circle',
31  'notice' => 'info-circle',
32  'warning' => 'exclamation-triangle',
33  'success' => 'check-circle',
34 ];
35 
38 
39 if (is_null($title) && !empty($type) && elgg_language_key_exists("messages:title:{$type}")) {
40  $title = elgg_echo("messages:title:{$type}");
41 }
42 
43 $header = '';
44 if (!empty($title) && !empty($icon_name)) {
45  $header .= elgg_view_icon($icon_name, ['class' => 'elgg-message-icon']);
46 }
47 
48 if (!empty($title)) {
49  $header .= elgg_format_element('span', ['class' => 'elgg-message-title'], $title);
50 }
51 
52 if (!empty($header)) {
53  $header = elgg_format_element('div', ['class' => 'elgg-head'], $header);
54 }
55 
56 if (!empty($body)) {
57  $body = elgg_format_element('div', ['class' => 'elgg-body'], $body);
58 }
59 
60 $contents = elgg_format_element('div', ['class' => 'elgg-inner'], $header . $body);
61 
elgg_language_key_exists($key, $language= 'en')
Check if a given language key exists.
Definition: languages.php:96
$type
Elgg message element.
Definition: message.php:12
if(!empty($title)&&!empty($icon_name)) if(!empty($title)) if(!empty($header)) if(!empty($body)) $contents
Definition: message.php:60
$icon_name
Definition: message.php:37
if(is_null($title)&&!empty($type)&&elgg_language_key_exists("messages:title:{$type}")) $header
Definition: message.php:43
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
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
$body
Definition: message.php:14
$title
Definition: message.php:13
if(empty($title)&&empty($body)) $attrs
Definition: message.php:20
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg echo
Translates a string.
Definition: languages.js:43
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
if(empty($title)&&empty($body)) if($type) $default_icons
Definition: message.php:28
elgg_view_icon($name, $vars=[])
View an icon glyph.
Definition: views.php:1552
$vars['type']
Definition: save.php:11
if(empty($title)&&empty($body)) if($type) $default_icon_name
Definition: message.php:36