2 /***************************************************************
5 * (c) 2010 Benjamin Mack <benni@typo3.org>
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
29 * A class representing error messages shown on a page.
30 * Classic Example: "No pages are found on rootlevel"
32 * @author Benjamin Mack <benni@typo3.org>
34 * @subpackage t3lib/message
36 class t3lib_message_ErrorpageMessage
extends t3lib_message_AbstractMessage
{
39 * defines whether the message should be stored in the session
40 * (to survive redirects) or only for one request (default)
44 protected $htmlTemplate;
47 * Constructor for a error message
49 * @param string The message.
50 * @param string message title.
51 * @param integer Optional severity, must be either of t3lib_message_ErrorpageMessage::INFO, t3lib_message_ErrorpageMessage::OK,
52 * t3lib_message_ErrorpageMessage::WARNING or t3lib_message_ErrorpageMessage::ERROR. Default is t3lib_message_ErrorpageMessage::ERROR.
55 public function __construct($message, $title, $severity = self
::ERROR
) {
56 $this->htmlTemplate
= TYPO3_mainDir
. 'sysext/t3skin/templates/errorpage-message.html';
57 $this->setMessage($message);
58 $this->setTitle(strlen($title) > 0 ?
$title : 'Error!');
59 $this->setSeverity($severity);
64 * Gets the filename of the HTML template.
66 * @return string The filename of the HTML template.
68 public function getHtmlTemplate() {
69 return $this->htmlTemplate
;
73 * Sets the filename to the HTML template
75 * @param string The filename to the HTML template.
78 public function setHtmlTemplate($htmlTemplate) {
79 $this->htmlTemplate
= (string) $htmlTemplate;
83 * Renders the flash message.
85 * @return string The flash message as HTML.
87 public function render() {
89 self
::NOTICE
=> 'notice',
90 self
::INFO
=> 'information',
92 self
::WARNING
=> 'warning',
93 self
::ERROR
=> 'error',
97 '###CSS_CLASS###' => $classes[$this->severity
],
98 '###TITLE###' => $this->title
,
99 '###MESSAGE###' => $this->message
,
100 '###BASEURL###' => t3lib_div
::getIndpEnv('TYPO3_SITE_URL'),
101 '###TYPO3_mainDir###' => TYPO3_mainDir
,
104 $content = t3lib_div
::getUrl(PATH_site
. $this->htmlTemplate
);
105 $content = t3lib_parseHtml
::substituteMarkerArray($content, $markers, '', FALSE, TRUE);
110 * Renders the flash message and echoes it.
114 public function output() {
115 $content = $this->render();
122 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/message/class.t3lib_message_errorpagemessage.php']) {
123 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/message/class.t3lib_message_errorpagemessage.php']);