From 883e4eb0c8537c939e4e613591c214258f48eb36 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 3 Mar 2013 20:53:08 -0800 Subject: [PATCH] Message Handler enhancement - render specific types. --- e107_handlers/message_handler.php | 15 +++++++++------ e107_languages/English/admin/help/cron.php | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/e107_handlers/message_handler.php b/e107_handlers/message_handler.php index 1c373551b..c276eca10 100644 --- a/e107_handlers/message_handler.php +++ b/e107_handlers/message_handler.php @@ -443,30 +443,33 @@ class eMessage } /** - * Output all accumulated messages + * Output all accumulated messages OR a specific type of messages. eg. 'info', 'warning', 'error', 'success' * * @param string $mstack message stack name - * @param bool $session merge with session messages + * @param bool|string $options - true : merge with session messages or enter a type 'info', 'warning', 'error', 'success' * @param bool $reset reset all messages * @param bool $raw force return type array * @return array|string messages */ - public function render($mstack = 'default', $session = false, $reset = true, $raw = false) + public function render($mstack = 'default', $options = false, $reset = true, $raw = false) { - if($session) + if($options === true ) { $this->mergeWithSession(true, $mstack); } $ret = array(); $unique = array(); - foreach ($this->_get_types() as $type) + + $typesArray = (is_string($options) && in_array($options, $this->_get_types())) ? array($options) : $this->_get_types(); + + foreach ($typesArray as $type) { if(E_MESSAGE_DEBUG === $type && !deftrue('E107_DEBUG_LEVEL')) { continue; } $message = $this->get($type, $mstack, $raw); - + if(!empty($message)) { $ret[$type] = $message; diff --git a/e107_languages/English/admin/help/cron.php b/e107_languages/English/admin/help/cron.php index 05819ebb1..166147a44 100644 --- a/e107_languages/English/admin/help/cron.php +++ b/e107_languages/English/admin/help/cron.php @@ -3,6 +3,6 @@ $mes = e107::getMessage(); -echo $mes->render(); +echo $mes->render('default','info',false); ?>