- * $message = PMA_Message::success('strSomeLocaleMessage');
- *
- * $hint = PMA_Message::notice('strSomeFootnote');
- * $hint->addParam('[a@./Documentation.html#cfg_Example@_blank]');
- * $hint->addParam('[/a]');
- * $hint = PMA_showHint($hint);
- *
- * $message->addMessage($hint);
- *
- * $more = PMA_Message::notice('strSomeMoreLocale');
- * $more->addString('strSomeEvenMoreLocale', '
');
- * $more->addParam('parameter for strSomeMoreLocale');
- * $more->addParam('more parameter for strSomeMoreLocale');
- *
- * $message->addMessage($more);
- * $message->addMessage('some final words', ' - ');
- *
- * $message->display();
- * // strSomeLocaleMessage 1 strSomeMoreLocale
- * // strSomeEvenMoreLocale - some final words
- *
- */
-class PMA_Message
-{
- const SUCCESS = 1; // 0001
- const NOTICE = 2; // 0010
- const WARNING = 4; // 0100
- const ERROR = 8; // 1000
-
- const SANITIZE_NONE = 0; // 0000 0000
- const SANITIZE_STRING = 16; // 0001 0000
- const SANITIZE_PARAMS = 32; // 0010 0000
- const SANITIZE_BOOTH = 48; // 0011 0000
-
- /**
- * message levels
- *
- * @var array
- */
- static public $level = array (
- PMA_Message::SUCCESS => 'success',
- PMA_Message::NOTICE => 'notice',
- PMA_Message::WARNING => 'warning',
- PMA_Message::ERROR => 'error',
- );
-
- /**
- * The message number
- *
- * @access protected
- * @var integer
- */
- protected $_number = PMA_Message::NOTICE;
-
- /**
- * The locale string identifier
- *
- * @access protected
- * @var string
- */
- protected $_string = '';
-
- /**
- * The formated message
- *
- * @access protected
- * @var string
- */
- protected $_message = '';
-
- /**
- * Whether the message was already displayed
- *
- * @access protected
- * @var boolean
- */
- protected $_is_displayed = false;
-
- /**
- * Unique id
- *
- * @access protected
- * @var string
- */
- protected $_hash = null;
-
- /**
- * holds parameters
- *
- * @access protected
- * @var array
- */
- protected $_params = array();
-
- /**
- * holds additional messages
- *
- * @access protected
- * @var array
- */
- protected $_added_messages = array();
-
- /**
- * Constructor
- *
- * @uses PMA_Message::setNumber()
- * @uses PMA_Message::setString()
- * @uses PMA_Message::setParams()
- * @uses PMA_Message::NOTICE
- * @uses PMA_Message::SANITIZE_NONE
- * @uses PMA_Message::SANITIZE_STRING
- * @uses PMA_Message::SANITIZE_PARAMS
- * @param string $string
- * @param integer $number
- * @param array $$params
- * @param boolean $sanitize
- */
- public function __construct($string = '', $number = PMA_Message::NOTICE,
- $params = array(), $sanitize = PMA_Message::SANITIZE_NONE)
- {
- $this->setString($string, $sanitize & PMA_Message::SANITIZE_STRING);
- $this->setNumber($number);
- $this->setParams($params, $sanitize & PMA_Message::SANITIZE_PARAMS);
- }
-
- /**
- * magic method: return string representation for this object
- *
- * @uses PMA_Message::getMessage()
- * @return string
- */
- public function __toString()
- {
- return $this->getMessage();
- }
-
- /**
- * get PMA_Message of type success
- *
- * shorthand for getting a simple success message
- *
- * @static
- * @uses PMA_Message as returned object
- * @uses PMA_Message::SUCCESS
- * @param string $string
- * @return PMA_Message
- */
- static public function success($string = '')
- {
- if (empty($string)) {
- $string = 'strSuccess';
- }
-
- return new PMA_Message($string, PMA_Message::SUCCESS);
- }
-
- /**
- * get PMA_Message of type error
- *
- * shorthand for getting a simple error message
- *
- * @static
- * @uses PMA_Message as returned object
- * @uses PMA_Message::ERROR
- * @param string $string
- * @return PMA_Message
- */
- static public function error($string = '')
- {
- if (empty($string)) {
- $string = 'strError';
- }
-
- return new PMA_Message($string, PMA_Message::ERROR);
- }
-
- /**
- * get PMA_Message of type warning
- *
- * shorthand for getting a simple warning message
- *
- * @static
- * @uses PMA_Message as returned object
- * @uses PMA_Message::WARNING
- * @param string $string
- * @return PMA_Message
- */
- static public function warning($string)
- {
- return new PMA_Message($string, PMA_Message::WARNING);
- }
-
- /**
- * get PMA_Message of type notice
- *
- * shorthand for getting a simple notice message
- *
- * @static
- * @uses PMA_Message as returned object
- * @uses PMA_Message::NOTICE
- * @param string $string
- * @return PMA_Message
- */
- static public function notice($string)
- {
- return new PMA_Message($string, PMA_Message::NOTICE);
- }
-
- /**
- * get PMA_Message with customized content
- *
- * shorthand for getting a customized message
- *
- * @static
- * @uses PMA_Message as returned object
- * @uses PMA_Message::setMessage()
- * @param string $message
- * @param integer $type
- * @return PMA_Message
- */
- static public function raw($message, $type = PMA_Message::NOTICE)
- {
- $r = new PMA_Message('', $type);
- $r->setMessage($message);
- return $r;
- }
-
- /**
- * get PMA_Message of type error with custom content
- *
- * shorthand for getting a customized error message
- *
- * @static
- * @uses PMA_Message::raw()
- * @uses PMA_Message::ERROR
- * @param string $message
- * @return PMA_Message
- */
- static public function rawError($message)
- {
- return PMA_Message::raw($message, PMA_Message::ERROR);
- }
-
- /**
- * get PMA_Message of type warning with custom content
- *
- * shorthand for getting a customized warning message
- *
- * @static
- * @uses PMA_Message::raw()
- * @uses PMA_Message::WARNING
- * @param string $message
- * @return PMA_Message
- */
- static public function rawWarning($message)
- {
- return PMA_Message::raw($message, PMA_Message::WARNING);
- }
-
- /**
- * get PMA_Message of type notice with custom content
- *
- * shorthand for getting a customized notice message
- *
- * @static
- * @uses PMA_Message::raw()
- * @uses PMA_Message::NOTICE
- * @param string $message
- * @return PMA_Message
- */
- static public function rawNotice($message)
- {
- return PMA_Message::raw($message, PMA_Message::NOTICE);
- }
-
- /**
- * get PMA_Message of type success with custom content
- *
- * shorthand for getting a customized success message
- *
- * @static
- * @uses PMA_Message::raw()
- * @uses PMA_Message::SUCCESS
- * @param string $message
- * @return PMA_Message
- */
- static public function rawSuccess($message)
- {
- return PMA_Message::raw($message, PMA_Message::SUCCESS);
- }
-
- /**
- * returns whether this message is a success message or not
- * and optionaly makes this message a success message
- *
- * @uses PMA_Message::SUCCESS
- * @uses PMA_Message::setNumber()
- * @uses PMA_Message::getNumber()
- * @param boolean $set
- * @return boolean whether this is a success message or not
- */
- public function isSuccess($set = false)
- {
- if ($set) {
- $this->setNumber(PMA_Message::SUCCESS);
- }
-
- return $this->getNumber() & PMA_Message::SUCCESS;
- }
-
- /**
- * returns whether this message is a notice message or not
- * and optionaly makes this message a notice message
- *
- * @uses PMA_Message::NOTICE
- * @uses PMA_Message::setNumber()
- * @uses PMA_Message::getNumber()
- * @param boolean $set
- * @return boolean whether this is a notice message or not
- */
- public function isNotice($set = false)
- {
- if ($set) {
- $this->setNumber(PMA_Message::NOTICE);
- }
-
- return $this->getNumber() & PMA_Message::NOTICE;
- }
-
- /**
- * returns whether this message is a warning message or not
- * and optionaly makes this message a warning message
- *
- * @uses PMA_Message::WARNING
- * @uses PMA_Message::setNumber()
- * @uses PMA_Message::getNumber()
- * @param boolean $set
- * @return boolean whether this is a warning message or not
- */
- public function isWarning($set = false)
- {
- if ($set) {
- $this->setNumber(PMA_Message::WARNING);
- }
-
- return $this->getNumber() & PMA_Message::WARNING;
- }
-
- /**
- * returns whether this message is an error message or not
- * and optionaly makes this message an error message
- *
- * @uses PMA_Message::ERROR
- * @uses PMA_Message::setNumber()
- * @uses PMA_Message::getNumber()
- * @param boolean $set
- * @return boolean whether this is an error message or not
- */
- public function isError($set = false)
- {
- if ($set) {
- $this->setNumber(PMA_Message::ERROR);
- }
-
- return $this->getNumber() & PMA_Message::ERROR;
- }
-
- /**
- * set raw message (overrides string)
- *
- * @uses PMA_Message::$_message to set it
- * @uses PMA_Message::sanitize()
- * @param string $message
- * @param boolean $sanitize whether to sanitize $message or not
- */
- public function setMessage($message, $sanitize = false)
- {
- if ($sanitize) {
- $message = PMA_Message::sanitize($message);
- }
- $this->_message = $message;
- }
-
- /**
- * set string (does not take effect if raw message is set)
- *
- * @uses PMA_Message::$_string to set it
- * @uses PMA_Message::sanitize()
- * @param string $_string
- * @param boolean $sanitize whether to sanitize $string or not
- */
- public function setString($_string, $sanitize = true)
- {
- if ($sanitize) {
- $_string = PMA_Message::sanitize($_string);
- }
- $this->_string = $_string;
- }
-
- /**
- * set message type number
- *
- * @uses PMA_Message::$_number to set it
- * @param integer $number
- */
- public function setNumber($number)
- {
- $this->_number = $number;
- }
-
- /**
- * add parameter, usually in conjunction with strings
- *
- * usage
- *
- * $message->addParam('strLocale', false);
- * $message->addParam('[em]somes tring[/em]');
- * $message->addParam('
', false);
- *
- *
- * @uses htmlspecialchars()
- * @uses PMA_Message::$_params to fill
- * @uses PMA_Message::notice()
- * @param mixed $param
- * @param boolean $raw
- */
- public function addParam($param, $raw = true)
- {
- if ($param instanceof PMA_Message) {
- $this->_params[] = $param;
- } elseif ($raw) {
- $this->_params[] = htmlspecialchars($param);
- } else {
- $this->_params[] = PMA_Message::notice($param);
- }
- }
-
- /**
- * add another string to be concatenated on displaying
- *
- * @uses PMA_Message::$_added_messages to fill
- * @uses PMA_Message::notice()
- * @param string $string to be added
- * @param string $separator to use between this and previous string/message
- */
- public function addString($string, $separator = ' ')
- {
- $this->_added_messages[] = $separator;
- $this->_added_messages[] = PMA_Message::notice($string);
- }
-
- /**
- * add a bunch of messages at once
- *
- * @uses PMA_Message::addMessage()
- * @param array $messages to be added
- * @param string $separator to use between this and previous string/message
- */
- public function addMessages($messages, $separator = ' ')
- {
- foreach ($messages as $message) {
- $this->addMessage($message, $separator);
- }
- }
-
- /**
- * add another raw message to be concatenated on displaying
- *
- * @uses PMA_Message::$_added_messages to fill
- * @uses PMA_Message::rawNotice()
- * @param mixed $message to be added
- * @param string $separator to use between this and previous string/message
- */
- public function addMessage($message, $separator = ' ')
- {
- if (strlen($separator)) {
- $this->_added_messages[] = $separator;
- }
-
- if ($message instanceof PMA_Message) {
- $this->_added_messages[] = $message;
- } else {
- $this->_added_messages[] = PMA_Message::rawNotice($message);
- }
- }
-
- /**
- * set all params at once, usually used in conjunction with string
- *
- * @uses PMA_Message::sanitize()
- * @uses PMA_Message::$_params to set
- * @param array $params
- * @param boolean $sanitize
- */
- public function setParams($params, $sanitize = false)
- {
- if ($sanitize) {
- $params = PMA_Message::sanitize($params);
- }
- $this->_params = $params;
- }
-
- /**
- * return all parameters
- *
- * @uses PMA_Message::$_params as return value
- * @return array
- */
- public function getParams()
- {
- return $this->_params;
- }
-
- /**
- * return all added messages
- *
- * @uses PMA_Message::$_added_messages as return value
- * @return array
- */
- public function getAddedMessages()
- {
- return $this->_added_messages;
- }
-
- /**
- * Sanitizes $message
- *
- * @static
- * @uses is_array()
- * @uses htmlspecialchars()
- * @uses PMA_Message::sanitize() recursiv
- * @param mixed the message(s)
- * @return mixed the sanitized message(s)
- * @access public
- */
- static public function sanitize($message)
- {
- if (is_array($message)) {
- foreach ($message as $key => $val) {
- $message[$key] = PMA_Message::sanitize($val);
- }
-
- return $message;
- }
-
- return htmlspecialchars($message);
- }
-
- /**
- * decode $message, taking into account our special codes
- * for formatting
- *
- * @static
- * @uses PREG_SET_ORDER
- * @uses in_array()
- * @uses preg_match_all()
- * @uses preg_match()
- * @uses preg_replace()
- * @uses substr()
- * @uses strtr()
- * @param string $message the message
- * @return string the decoded message
- * @access public
- */
- static public function decodeBB($message)
- {
- $replace_pairs = array(
- '[i]' => '', // deprecated by em
- '[/i]' => '', // deprecated by em
- '[em]' => '',
- '[/em]' => '',
- '[b]' => '', // deprecated by strong
- '[/b]' => '', // deprecated by strong
- '[strong]' => '',
- '[/strong]' => '',
- '[tt]' => '', // deprecated by CODE or KBD
- '[/tt]' => '
', // deprecated by CODE or KBD
- '[code]' => '',
- '[/code]' => '
',
- '[kbd]' => '',
- '[/kbd]' => '',
- '[br]' => '
+ * $message = PMA_Message::success('strSomeLocaleMessage');
+ *
+ * $hint = PMA_Message::notice('strSomeFootnote');
+ * $hint->addParam('[a@./Documentation.html#cfg_Example@_blank]');
+ * $hint->addParam('[/a]');
+ * $hint = PMA_showHint($hint);
+ *
+ * $message->addMessage($hint);
+ *
+ * $more = PMA_Message::notice('strSomeMoreLocale');
+ * $more->addString('strSomeEvenMoreLocale', '
');
+ * $more->addParam('parameter for strSomeMoreLocale');
+ * $more->addParam('more parameter for strSomeMoreLocale');
+ *
+ * $message->addMessage($more);
+ * $message->addMessage('some final words', ' - ');
+ *
+ * $message->display();
+ * // strSomeLocaleMessage 1 strSomeMoreLocale
+ * // strSomeEvenMoreLocale - some final words
+ *
+ */
+class PMA_Message
+{
+ const SUCCESS = 1; // 0001
+ const NOTICE = 2; // 0010
+ const WARNING = 4; // 0100
+ const ERROR = 8; // 1000
+
+ const SANITIZE_NONE = 0; // 0000 0000
+ const SANITIZE_STRING = 16; // 0001 0000
+ const SANITIZE_PARAMS = 32; // 0010 0000
+ const SANITIZE_BOOTH = 48; // 0011 0000
+
+ /**
+ * message levels
+ *
+ * @var array
+ */
+ static public $level = array (
+ PMA_Message::SUCCESS => 'success',
+ PMA_Message::NOTICE => 'notice',
+ PMA_Message::WARNING => 'warning',
+ PMA_Message::ERROR => 'error',
+ );
+
+ /**
+ * The message number
+ *
+ * @access protected
+ * @var integer
+ */
+ protected $_number = PMA_Message::NOTICE;
+
+ /**
+ * The locale string identifier
+ *
+ * @access protected
+ * @var string
+ */
+ protected $_string = '';
+
+ /**
+ * The formated message
+ *
+ * @access protected
+ * @var string
+ */
+ protected $_message = '';
+
+ /**
+ * Whether the message was already displayed
+ *
+ * @access protected
+ * @var boolean
+ */
+ protected $_is_displayed = false;
+
+ /**
+ * Unique id
+ *
+ * @access protected
+ * @var string
+ */
+ protected $_hash = null;
+
+ /**
+ * holds parameters
+ *
+ * @access protected
+ * @var array
+ */
+ protected $_params = array();
+
+ /**
+ * holds additional messages
+ *
+ * @access protected
+ * @var array
+ */
+ protected $_added_messages = array();
+
+ /**
+ * Constructor
+ *
+ * @uses PMA_Message::setNumber()
+ * @uses PMA_Message::setString()
+ * @uses PMA_Message::setParams()
+ * @uses PMA_Message::NOTICE
+ * @uses PMA_Message::SANITIZE_NONE
+ * @uses PMA_Message::SANITIZE_STRING
+ * @uses PMA_Message::SANITIZE_PARAMS
+ * @param string $string
+ * @param integer $number
+ * @param array $$params
+ * @param boolean $sanitize
+ */
+ public function __construct($string = '', $number = PMA_Message::NOTICE,
+ $params = array(), $sanitize = PMA_Message::SANITIZE_NONE)
+ {
+ $this->setString($string, $sanitize & PMA_Message::SANITIZE_STRING);
+ $this->setNumber($number);
+ $this->setParams($params, $sanitize & PMA_Message::SANITIZE_PARAMS);
+ }
+
+ /**
+ * magic method: return string representation for this object
+ *
+ * @uses PMA_Message::getMessage()
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->getMessage();
+ }
+
+ /**
+ * get PMA_Message of type success
+ *
+ * shorthand for getting a simple success message
+ *
+ * @static
+ * @uses PMA_Message as returned object
+ * @uses PMA_Message::SUCCESS
+ * @param string $string
+ * @return PMA_Message
+ */
+ static public function success($string = '')
+ {
+ if (empty($string)) {
+ $string = 'strSuccess';
+ }
+
+ return new PMA_Message($string, PMA_Message::SUCCESS);
+ }
+
+ /**
+ * get PMA_Message of type error
+ *
+ * shorthand for getting a simple error message
+ *
+ * @static
+ * @uses PMA_Message as returned object
+ * @uses PMA_Message::ERROR
+ * @param string $string
+ * @return PMA_Message
+ */
+ static public function error($string = '')
+ {
+ if (empty($string)) {
+ $string = 'strError';
+ }
+
+ return new PMA_Message($string, PMA_Message::ERROR);
+ }
+
+ /**
+ * get PMA_Message of type warning
+ *
+ * shorthand for getting a simple warning message
+ *
+ * @static
+ * @uses PMA_Message as returned object
+ * @uses PMA_Message::WARNING
+ * @param string $string
+ * @return PMA_Message
+ */
+ static public function warning($string)
+ {
+ return new PMA_Message($string, PMA_Message::WARNING);
+ }
+
+ /**
+ * get PMA_Message of type notice
+ *
+ * shorthand for getting a simple notice message
+ *
+ * @static
+ * @uses PMA_Message as returned object
+ * @uses PMA_Message::NOTICE
+ * @param string $string
+ * @return PMA_Message
+ */
+ static public function notice($string)
+ {
+ return new PMA_Message($string, PMA_Message::NOTICE);
+ }
+
+ /**
+ * get PMA_Message with customized content
+ *
+ * shorthand for getting a customized message
+ *
+ * @static
+ * @uses PMA_Message as returned object
+ * @uses PMA_Message::setMessage()
+ * @param string $message
+ * @param integer $type
+ * @return PMA_Message
+ */
+ static public function raw($message, $type = PMA_Message::NOTICE)
+ {
+ $r = new PMA_Message('', $type);
+ $r->setMessage($message);
+ return $r;
+ }
+
+ /**
+ * get PMA_Message of type error with custom content
+ *
+ * shorthand for getting a customized error message
+ *
+ * @static
+ * @uses PMA_Message::raw()
+ * @uses PMA_Message::ERROR
+ * @param string $message
+ * @return PMA_Message
+ */
+ static public function rawError($message)
+ {
+ return PMA_Message::raw($message, PMA_Message::ERROR);
+ }
+
+ /**
+ * get PMA_Message of type warning with custom content
+ *
+ * shorthand for getting a customized warning message
+ *
+ * @static
+ * @uses PMA_Message::raw()
+ * @uses PMA_Message::WARNING
+ * @param string $message
+ * @return PMA_Message
+ */
+ static public function rawWarning($message)
+ {
+ return PMA_Message::raw($message, PMA_Message::WARNING);
+ }
+
+ /**
+ * get PMA_Message of type notice with custom content
+ *
+ * shorthand for getting a customized notice message
+ *
+ * @static
+ * @uses PMA_Message::raw()
+ * @uses PMA_Message::NOTICE
+ * @param string $message
+ * @return PMA_Message
+ */
+ static public function rawNotice($message)
+ {
+ return PMA_Message::raw($message, PMA_Message::NOTICE);
+ }
+
+ /**
+ * get PMA_Message of type success with custom content
+ *
+ * shorthand for getting a customized success message
+ *
+ * @static
+ * @uses PMA_Message::raw()
+ * @uses PMA_Message::SUCCESS
+ * @param string $message
+ * @return PMA_Message
+ */
+ static public function rawSuccess($message)
+ {
+ return PMA_Message::raw($message, PMA_Message::SUCCESS);
+ }
+
+ /**
+ * returns whether this message is a success message or not
+ * and optionaly makes this message a success message
+ *
+ * @uses PMA_Message::SUCCESS
+ * @uses PMA_Message::setNumber()
+ * @uses PMA_Message::getNumber()
+ * @param boolean $set
+ * @return boolean whether this is a success message or not
+ */
+ public function isSuccess($set = false)
+ {
+ if ($set) {
+ $this->setNumber(PMA_Message::SUCCESS);
+ }
+
+ return $this->getNumber() & PMA_Message::SUCCESS;
+ }
+
+ /**
+ * returns whether this message is a notice message or not
+ * and optionaly makes this message a notice message
+ *
+ * @uses PMA_Message::NOTICE
+ * @uses PMA_Message::setNumber()
+ * @uses PMA_Message::getNumber()
+ * @param boolean $set
+ * @return boolean whether this is a notice message or not
+ */
+ public function isNotice($set = false)
+ {
+ if ($set) {
+ $this->setNumber(PMA_Message::NOTICE);
+ }
+
+ return $this->getNumber() & PMA_Message::NOTICE;
+ }
+
+ /**
+ * returns whether this message is a warning message or not
+ * and optionaly makes this message a warning message
+ *
+ * @uses PMA_Message::WARNING
+ * @uses PMA_Message::setNumber()
+ * @uses PMA_Message::getNumber()
+ * @param boolean $set
+ * @return boolean whether this is a warning message or not
+ */
+ public function isWarning($set = false)
+ {
+ if ($set) {
+ $this->setNumber(PMA_Message::WARNING);
+ }
+
+ return $this->getNumber() & PMA_Message::WARNING;
+ }
+
+ /**
+ * returns whether this message is an error message or not
+ * and optionaly makes this message an error message
+ *
+ * @uses PMA_Message::ERROR
+ * @uses PMA_Message::setNumber()
+ * @uses PMA_Message::getNumber()
+ * @param boolean $set
+ * @return boolean whether this is an error message or not
+ */
+ public function isError($set = false)
+ {
+ if ($set) {
+ $this->setNumber(PMA_Message::ERROR);
+ }
+
+ return $this->getNumber() & PMA_Message::ERROR;
+ }
+
+ /**
+ * set raw message (overrides string)
+ *
+ * @uses PMA_Message::$_message to set it
+ * @uses PMA_Message::sanitize()
+ * @param string $message
+ * @param boolean $sanitize whether to sanitize $message or not
+ */
+ public function setMessage($message, $sanitize = false)
+ {
+ if ($sanitize) {
+ $message = PMA_Message::sanitize($message);
+ }
+ $this->_message = $message;
+ }
+
+ /**
+ * set string (does not take effect if raw message is set)
+ *
+ * @uses PMA_Message::$_string to set it
+ * @uses PMA_Message::sanitize()
+ * @param string $_string
+ * @param boolean $sanitize whether to sanitize $string or not
+ */
+ public function setString($_string, $sanitize = true)
+ {
+ if ($sanitize) {
+ $_string = PMA_Message::sanitize($_string);
+ }
+ $this->_string = $_string;
+ }
+
+ /**
+ * set message type number
+ *
+ * @uses PMA_Message::$_number to set it
+ * @param integer $number
+ */
+ public function setNumber($number)
+ {
+ $this->_number = $number;
+ }
+
+ /**
+ * add parameter, usually in conjunction with strings
+ *
+ * usage
+ *
+ * $message->addParam('strLocale', false);
+ * $message->addParam('[em]somes tring[/em]');
+ * $message->addParam('
', false);
+ *
+ *
+ * @uses htmlspecialchars()
+ * @uses PMA_Message::$_params to fill
+ * @uses PMA_Message::notice()
+ * @param mixed $param
+ * @param boolean $raw
+ */
+ public function addParam($param, $raw = true)
+ {
+ if ($param instanceof PMA_Message) {
+ $this->_params[] = $param;
+ } elseif ($raw) {
+ $this->_params[] = htmlspecialchars($param);
+ } else {
+ $this->_params[] = PMA_Message::notice($param);
+ }
+ }
+
+ /**
+ * add another string to be concatenated on displaying
+ *
+ * @uses PMA_Message::$_added_messages to fill
+ * @uses PMA_Message::notice()
+ * @param string $string to be added
+ * @param string $separator to use between this and previous string/message
+ */
+ public function addString($string, $separator = ' ')
+ {
+ $this->_added_messages[] = $separator;
+ $this->_added_messages[] = PMA_Message::notice($string);
+ }
+
+ /**
+ * add a bunch of messages at once
+ *
+ * @uses PMA_Message::addMessage()
+ * @param array $messages to be added
+ * @param string $separator to use between this and previous string/message
+ */
+ public function addMessages($messages, $separator = ' ')
+ {
+ foreach ($messages as $message) {
+ $this->addMessage($message, $separator);
+ }
+ }
+
+ /**
+ * add another raw message to be concatenated on displaying
+ *
+ * @uses PMA_Message::$_added_messages to fill
+ * @uses PMA_Message::rawNotice()
+ * @param mixed $message to be added
+ * @param string $separator to use between this and previous string/message
+ */
+ public function addMessage($message, $separator = ' ')
+ {
+ if (strlen($separator)) {
+ $this->_added_messages[] = $separator;
+ }
+
+ if ($message instanceof PMA_Message) {
+ $this->_added_messages[] = $message;
+ } else {
+ $this->_added_messages[] = PMA_Message::rawNotice($message);
+ }
+ }
+
+ /**
+ * set all params at once, usually used in conjunction with string
+ *
+ * @uses PMA_Message::sanitize()
+ * @uses PMA_Message::$_params to set
+ * @param array $params
+ * @param boolean $sanitize
+ */
+ public function setParams($params, $sanitize = false)
+ {
+ if ($sanitize) {
+ $params = PMA_Message::sanitize($params);
+ }
+ $this->_params = $params;
+ }
+
+ /**
+ * return all parameters
+ *
+ * @uses PMA_Message::$_params as return value
+ * @return array
+ */
+ public function getParams()
+ {
+ return $this->_params;
+ }
+
+ /**
+ * return all added messages
+ *
+ * @uses PMA_Message::$_added_messages as return value
+ * @return array
+ */
+ public function getAddedMessages()
+ {
+ return $this->_added_messages;
+ }
+
+ /**
+ * Sanitizes $message
+ *
+ * @static
+ * @uses is_array()
+ * @uses htmlspecialchars()
+ * @uses PMA_Message::sanitize() recursiv
+ * @param mixed the message(s)
+ * @return mixed the sanitized message(s)
+ * @access public
+ */
+ static public function sanitize($message)
+ {
+ if (is_array($message)) {
+ foreach ($message as $key => $val) {
+ $message[$key] = PMA_Message::sanitize($val);
+ }
+
+ return $message;
+ }
+
+ return htmlspecialchars($message);
+ }
+
+ /**
+ * decode $message, taking into account our special codes
+ * for formatting
+ *
+ * @static
+ * @uses PREG_SET_ORDER
+ * @uses in_array()
+ * @uses preg_match_all()
+ * @uses preg_match()
+ * @uses preg_replace()
+ * @uses substr()
+ * @uses strtr()
+ * @param string $message the message
+ * @return string the decoded message
+ * @access public
+ */
+ static public function decodeBB($message)
+ {
+ $replace_pairs = array(
+ '[i]' => '', // deprecated by em
+ '[/i]' => '', // deprecated by em
+ '[em]' => '',
+ '[/em]' => '',
+ '[b]' => '', // deprecated by strong
+ '[/b]' => '', // deprecated by strong
+ '[strong]' => '',
+ '[/strong]' => '',
+ '[tt]' => '', // deprecated by CODE or KBD
+ '[/tt]' => '
', // deprecated by CODE or KBD
+ '[code]' => '',
+ '[/code]' => '
',
+ '[kbd]' => '',
+ '[/kbd]' => '',
+ '[br]' => '