00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class t3lib_FlashMessage {
00037
00038 const NOTICE = -2;
00039 const INFO = -1;
00040 const OK = 0;
00041 const WARNING = 1;
00042 const ERROR = 2;
00043
00044
00045
00046
00047
00048
00049 protected $title = '';
00050
00051
00052
00053
00054
00055
00056 protected $message = '';
00057
00058
00059
00060
00061
00062
00063 protected $severity = self::OK;
00064
00065
00066
00067
00068
00069
00070 protected $storeInSession = FALSE;
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 public function __construct($message, $title = '', $severity = self::OK, $storeInSession = FALSE) {
00083 $this->setMessage($message);
00084 $this->setTitle($title);
00085 $this->setSeverity($severity);
00086 $this->setStoreInSession($storeInSession);
00087 }
00088
00089
00090
00091
00092
00093
00094 public function getTitle() {
00095 return $this->title;
00096 }
00097
00098
00099
00100
00101
00102
00103
00104 public function setTitle($title) {
00105 $this->title = (string) $title;
00106 }
00107
00108
00109
00110
00111
00112
00113
00114 public function isSessionMessage() {
00115 return $this->storeInSession;
00116 }
00117
00118
00119
00120
00121
00122
00123
00124 public function setStoreInSession($storeInSession) {
00125 $this->storeInSession = (bool) $storeInSession;
00126 }
00127
00128
00129
00130
00131
00132
00133
00134 public function getMessage() {
00135 return $this->message;
00136 }
00137
00138
00139
00140
00141
00142
00143
00144 public function setMessage($message) {
00145 $this->message = (string) $message;
00146 }
00147
00148
00149
00150
00151
00152
00153 public function getSeverity() {
00154 return $this->severity;
00155 }
00156
00157
00158
00159
00160
00161
00162
00163 public function setSeverity($severity = self::OK) {
00164 $this->severity = t3lib_div::intInRange(
00165 $severity,
00166 self::NOTICE,
00167 self::ERROR,
00168 self::OK
00169 );
00170 }
00171
00172
00173
00174
00175
00176
00177 public function render() {
00178 $classes = array(
00179 t3lib_FlashMessage::NOTICE => 'notice',
00180 t3lib_FlashMessage::INFO => 'information',
00181 t3lib_FlashMessage::OK => 'ok',
00182 t3lib_FlashMessage::WARNING => 'warning',
00183 t3lib_FlashMessage::ERROR => 'error',
00184 );
00185
00186 $title = '';
00187 if (!empty($this->title)) {
00188 $title = '<div class="message-header">' . $this->title . '</div>';
00189 }
00190
00191 $message = '<div class="typo3-message message-' . $classes[$this->severity] . '">'
00192 . $title
00193 . '<div class="message-body">' . $this->message . '</div>'
00194 . '</div>';
00195
00196 return $message;
00197 }
00198
00199
00200
00201
00202
00203
00204
00205
00206 public function __toString() {
00207 $severities = array(
00208 t3lib_FlashMessage::INFO => 'INFO',
00209 t3lib_FlashMessage::OK => 'OK',
00210 t3lib_FlashMessage::WARNING => 'WARNING',
00211 t3lib_FlashMessage::ERROR => 'ERROR',
00212 );
00213
00214 $title = '';
00215 if (!empty($this->title)) {
00216 $title = ' - ' . $this->title;
00217 }
00218
00219 return $severities[$this->severity] . $title . ': ' . $this->message;
00220 }
00221
00222 }
00223
00224
00225 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_flashmessage.php']) {
00226 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_flashmessage.php']);
00227 }
00228
00229 ?>