ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSystemStyleMessageStack.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
15  protected $messages = array();
16 
23  {
24  array_unshift($this->messages, $message);
25  }
26 
33  {
34  $this->messages[] = $message;
35  }
36 
42  public function sendMessages($keep = false)
43  {
44  foreach ($this->getJoinedMessages() as $type => $joined_message) {
45  switch ($type) {
47  ilUtil::sendSuccess($joined_message, $keep);
48  break;
50  ilUtil::sendInfo($joined_message, $keep);
51  break;
53  ilUtil::sendFailure($joined_message, $keep);
54  break;
55  }
56  }
57  }
58 
64  public function getJoinedMessages()
65  {
66  $joined_messages = [];
67  foreach ($this->getMessages() as $message) {
68  if (!array_key_exists($message->getTypeId(), $joined_messages)) {
69  $joined_messages[$message->getTypeId()] = "";
70  }
71  $joined_messages[$message->getTypeId()] .= $message->getMessageOutput();
72  }
73  return $joined_messages;
74  }
75 
79  public function getMessages()
80  {
81  return $this->messages;
82  }
83 
87  public function setMessages($messages)
88  {
89  $this->messages = $messages;
90  }
91 
97  public function hasMessages()
98  {
99  return count($this->getMessages()) > 0;
100  }
101 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$type
hasMessages()
Return wheter there are any message at all stored in the stack.
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
prependMessage(ilSystemStyleMessage $message)
Add a message to be displayed before all others.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
catch(Exception $e) $message
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Used to stack messages to be shown to the user.
getJoinedMessages()
Return an array containing a string with all messages for each type.
sendMessages($keep=false)
Send messages via ilUtil to be displayed.