TYPO3  7.6
FlashMessage.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Messaging;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
23 {
29  protected $storeInSession = false;
30 
34  protected $classes = array(
35  self::NOTICE => 'notice',
36  self::INFO => 'info',
37  self::OK => 'success',
38  self::WARNING => 'warning',
39  self::ERROR => 'danger'
40  );
41 
45  protected $icons = array(
46  self::NOTICE => 'lightbulb-o',
47  self::INFO => 'info',
48  self::OK => 'check',
49  self::WARNING => 'exclamation',
50  self::ERROR => 'times'
51  );
52 
61  public function __construct($message, $title = '', $severity = self::OK, $storeInSession = false)
62  {
63  $this->setMessage($message);
64  $this->setTitle($title);
65  $this->setSeverity($severity);
67  }
68 
74  public function isSessionMessage()
75  {
76  return $this->storeInSession;
77  }
78 
86  {
87  $this->storeInSession = (bool)$storeInSession;
88  }
89 
95  public function getClass()
96  {
97  return 'alert-' . $this->classes[$this->severity];
98  }
99 
105  public function getIconName()
106  {
107  return $this->icons[$this->severity];
108  }
109 
116  public function render()
117  {
119  $title = '';
120  if (!empty($this->title)) {
121  $title = '<h4 class="alert-title">' . $this->title . '</h4>';
122  }
123  $message = '
124  <div class="alert ' . $this->getClass() . '">
125  <div class="media">
126  <div class="media-left">
127  <span class="fa-stack fa-lg">
128  <i class="fa fa-circle fa-stack-2x"></i>
129  <i class="fa fa-' . $this->getIconName() . ' fa-stack-1x"></i>
130  </span>
131  </div>
132  <div class="media-body">
133  ' . $title . '
134  <div class="alert-message">' . $this->message . '</div>
135  </div>
136  </div>
137  </div>';
138  return $message;
139  }
140 }