From 924d9a951faddc507d921d3119d8da1d60eb02dd Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Fri, 12 Oct 2007 08:05:11 +0000 Subject: [PATCH] added some shorthand functions --- libraries/Message.class.php | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/libraries/Message.class.php b/libraries/Message.class.php index cd9ba0736..a5cf55766 100644 --- a/libraries/Message.class.php +++ b/libraries/Message.class.php @@ -105,6 +105,56 @@ class PMA_Message $this->setMessage($this->getMessage() . $message); } + /** + * return success PMA_Message + * + * shorthand for getting a simple success message + * + * @static + * @uses PMA_Message + * @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); + } + + /** + * return success PMA_Message + * + * shorthand for getting a simple success message + * + * @static + * @uses PMA_Message + * @uses PMA_Message::SUCCESS + * @param string $string + * @return PMA_Message + */ + static public function error($string = '') + { + if (empty($string)) { + $string = 'strError'; + } + + if (substr($string, 0, 3) === 'str') { + return new PMA_Message($string, PMA_Message::ERROR); + } + + return PMA_Message::raw($string, PMA_Message::ERROR); + } + + static public function raw($message, $type = PMA_Message::NOTICE) + { + $r = new PMA_Message('', $type); + $r->setMessage($message); + return $r; + } + public function isSuccess($set = false) { if ($set) {