Elgg  Version 6.1
messages.php
Go to the documentation of this file.
1 <?php
9 $messages = (array) elgg_extract('object', $vars, []);
10 
11 if (!empty($messages)) {
12  elgg_import_esm('elgg/system_messages');
13 }
14 
15 // hidden li so we validate, we need this for javascript added system messages
16 $list_items = elgg_format_element('li', ['class' => 'hidden']);
17 
18 foreach ($messages as $type => $list) {
20  foreach ($list as $message) {
21  $message_vars = $message->getVars(['title' => false]);
22  if ($message->getTtl() > -1) {
23  // 0 means persistent
24  $message_vars['data-ttl'] = $message->getTtl() * 1000;
25  } elseif (isset($message_vars['link'])) {
26  // keep the message persistent if there is a link
27  $message_vars['data-ttl'] = 0;
28  }
29 
30  $list_items .= elgg_format_element('li', [], elgg_view_message($message->getType(), $message->getMessage(), $message_vars));
31  }
32 }
33 
34 echo elgg_format_element('ul', ['class' => 'elgg-system-messages'], $list_items);
if(!empty($messages)) $list_items
Definition: messages.php:16
$type
Definition: delete.php:21
$message_vars
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
Definition: item.php:48
$messages
Elgg global system message list Lists all system messages.
Definition: messages.php:9
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:256
elgg_import_esm(string $name)
Helper functions for external files like css/js.
$vars
Definition: theme.php:5
elgg_view_message(string $type, string $body, array $vars=[])
Wrapper function for the message display pattern.
Definition: views.php:940
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145