|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009-2011 Ingo Renner <ingo@typo3.org> 00006 * (c) 2010-2011 Benjamin Mack <benni@typo3.org> 00007 * All rights reserved 00008 * 00009 * This script is part of the TYPO3 project. The TYPO3 project is 00010 * free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * The GNU General Public License can be found at 00016 * http://www.gnu.org/copyleft/gpl.html. 00017 * A copy is found in the textfile GPL.txt and important notices to the license 00018 * from the author is found in LICENSE.txt distributed with these scripts. 00019 * 00020 * 00021 * This script is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * This copyright notice MUST APPEAR in all copies of the script! 00027 ***************************************************************/ 00028 00029 00030 /** 00031 * A class used for any kind of messages. 00032 * 00033 * @author Ingo Renner <ingo@typo3.org> 00034 * @author Benjamin Mack <benni@typo3.org> 00035 * @package TYPO3 00036 * @subpackage t3lib/message 00037 */ 00038 abstract class t3lib_message_AbstractMessage { 00039 00040 const NOTICE = -2; 00041 const INFO = -1; 00042 const OK = 0; 00043 const WARNING = 1; 00044 const ERROR = 2; 00045 00046 /** 00047 * The message's title 00048 * 00049 * @var string 00050 */ 00051 protected $title = ''; 00052 00053 /** 00054 * The message 00055 * 00056 * @var string 00057 */ 00058 protected $message = ''; 00059 00060 /** 00061 * The message's severity 00062 * 00063 * @var integer 00064 */ 00065 protected $severity = self::OK; 00066 00067 /** 00068 * Gets the message's title. 00069 * 00070 * @return string The message's title. 00071 */ 00072 public function getTitle() { 00073 return $this->title; 00074 } 00075 00076 /** 00077 * Sets the message's title 00078 * 00079 * @param string The message's title 00080 * @return void 00081 */ 00082 public function setTitle($title) { 00083 $this->title = (string) $title; 00084 } 00085 00086 /** 00087 * Gets the message. 00088 * 00089 * @return string The message. 00090 */ 00091 public function getMessage() { 00092 return $this->message; 00093 } 00094 00095 /** 00096 * Sets the message 00097 * 00098 * @param string The message 00099 * @return void 00100 */ 00101 public function setMessage($message) { 00102 $this->message = (string) $message; 00103 } 00104 00105 /** 00106 * Gets the message' severity. 00107 * 00108 * @return integer The message' severity, either of t3lib_message_AbstractMessage::INFO, 00109 * t3lib_message_AbstractMessage::OK, t3lib_message_AbstractMessage::WARNING 00110 * or t3lib_message_AbstractMessage::ERROR 00111 */ 00112 public function getSeverity() { 00113 return $this->severity; 00114 } 00115 00116 /** 00117 * Sets the message' severity 00118 * 00119 * @param string The severity, must be either of t3lib_message_AbstractMessage::INFO, 00120 * t3lib_message_AbstractMessage::OK, t3lib_message_AbstractMessage::WARNING 00121 * or t3lib_message_AbstractMessage::ERROR. Default is t3lib_message_AbstractMessage::OK. 00122 * @return void 00123 */ 00124 public function setSeverity($severity = self::OK) { 00125 $this->severity = t3lib_div::intInRange( 00126 $severity, 00127 self::NOTICE, // minimum 00128 self::ERROR, // maximum 00129 self::OK // default if out of bounds 00130 ); 00131 } 00132 00133 00134 /** 00135 * Creates a string representation of the message. Useful for command 00136 * line use. 00137 * 00138 * @return string A string representation of the message. 00139 */ 00140 public function __toString() { 00141 $severities = array( 00142 self::INFO => 'INFO', 00143 self::OK => 'OK', 00144 self::WARNING => 'WARNING', 00145 self::ERROR => 'ERROR', 00146 ); 00147 00148 $title = ''; 00149 if (!empty($this->title)) { 00150 $title = ' - ' . $this->title; 00151 } 00152 00153 return $severities[$this->severity] . $title . ': ' . $this->message; 00154 } 00155 00156 } 00157 00158 00159 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/message/class.t3lib_message_abstractmessage.php'])) { 00160 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/message/class.t3lib_message_abstractmessage.php']); 00161 } 00162 00163 ?>
1.8.0