diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-07-08 16:04:07 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-07-08 16:04:07 +0000 |
commit | 5b73def39b0300cc08bcd21fb46717c7b057c42e (patch) | |
tree | b5f253058c521a10d84124e18db33b0c1884cd6c /includes | |
parent | 898bdeffafe913417951ec214d57ec930ea90812 (diff) | |
download | brdo-5b73def39b0300cc08bcd21fb46717c7b057c42e.tar.gz brdo-5b73def39b0300cc08bcd21fb46717c7b057c42e.tar.bz2 |
- Changed the way status messages are printed as per Kristjan's suggestion:
http://drupal.org/files/issues/error_messages_list.png (issue #9138).
drupal_set_message() has been changed to group message by type and a
helper function, theme_status_message(), is added to display the messages.
Chameleon and Xtemplate have been updated to use this new function.
- Updated CHANGELOG.txt.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/bootstrap.inc | 14 | ||||
-rw-r--r-- | includes/theme.inc | 31 |
2 files changed, 39 insertions, 6 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 968f0d29f..7a4518a51 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -261,12 +261,16 @@ function watchdog($type, $message, $link = NULL) { * @{ */ function drupal_set_message($message = NULL, $type = "status") { - if (!isset($_SESSION['messages'])) { - $_SESSION['messages'] = array(); - } - if (isset($message)) { - $_SESSION['messages'][] = array($message, $type); + if (!isset($_SESSION['messages'])) { + $_SESSION['messages'] = array(); + } + + if (!isset($_SESSION['messages'][$type])) { + $_SESSION['messages'][$type] = array(); + } + + $_SESSION['messages'][$type][] = $message; } return $_SESSION['messages']; diff --git a/includes/theme.inc b/includes/theme.inc index 494ee78b2..c7c7c4887 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -184,6 +184,35 @@ function theme_page($content, $title = NULL, $breadcrumb = NULL) { } /** + * Returns themed set of status and/or error messages. The messages are grouped + * by type. + * + * @return a string containing the messages. + */ +function theme_status_messages() { + if ($data = drupal_get_messages()) { + $output = ''; + foreach ($data as $type => $messages) { + $output .= "<div class=\"messages $type\">\n"; + if (count($messages) > 1) { + $output .= " <ul>\n"; + foreach($messages as $message) { + $output .= " <li>". ucfirst($message) ."</li>\n"; + } + $output .= " </ul>\n"; + } + else { + $output .= ucfirst($messages[0]); + } + $output .= "</div>\n"; + } + + return $output; + } +} + + +/** * Returns themed set of links. * * @param $links an array of @a links to be themed. @@ -283,7 +312,6 @@ function theme_node($node, $main = 0, $page = 0) { function theme_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) { $output = "<div class=\"form-item\">\n"; - $required = $required ? theme('mark') : ''; if ($title) { @@ -446,6 +474,7 @@ function theme_item_list($items = array(), $title = NULL) { /** * Returns themed error message. + * REMOVE: this function is deprecated an no longer used in core. * * @param $message the error message to be themed. * |