Elgg  Version 4.3
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_require_js('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
$messages
Elgg global system message list Lists all system messages.
Definition: messages.php:9
elgg_view_message($type, $body, array $vars=[])
Wrapper function for the message display pattern.
Definition: views.php:965
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:135
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
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
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof ElggRelationship) elseif(is_callable([$item, 'getType']))
Definition: item.php:48
elgg echo
Translates a string.
Definition: deprecated.js:530
$vars['head']
Definition: html.php:24