Skip to content
Snippets Groups Projects
Commit 5b73def3 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- 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.
parent 898bdeff
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -22,11 +22,14 @@ Drupal x.x.x, xxxx-xx-xx ...@@ -22,11 +22,14 @@ Drupal x.x.x, xxxx-xx-xx
* added support for multiple database connections. * added support for multiple database connections.
- theme system: - theme system:
* changed all GIFs to PNGs. * changed all GIFs to PNGs.
- blocks:
* added 'recent comments' block.
* added 'categories' block.
- blogger API: - blogger API:
* added support for auto-discovery of blogger API via RSD. * added support for auto-discovery of blogger API via RSD.
- accessibility: - accessibility:
* improved the accessibility of the archive module's calendar. * improved the accessibility of the archive module's calendar.
* improved form handling. * improved form handling and error reporting.
Drupal 4.4.2, 2004-07-04 Drupal 4.4.2, 2004-07-04
......
...@@ -261,12 +261,16 @@ function watchdog($type, $message, $link = NULL) { ...@@ -261,12 +261,16 @@ function watchdog($type, $message, $link = NULL) {
* @{ * @{
*/ */
function drupal_set_message($message = NULL, $type = "status") { function drupal_set_message($message = NULL, $type = "status") {
if (isset($message)) {
if (!isset($_SESSION['messages'])) { if (!isset($_SESSION['messages'])) {
$_SESSION['messages'] = array(); $_SESSION['messages'] = array();
} }
if (isset($message)) { if (!isset($_SESSION['messages'][$type])) {
$_SESSION['messages'][] = array($message, $type); $_SESSION['messages'][$type] = array();
}
$_SESSION['messages'][$type][] = $message;
} }
return $_SESSION['messages']; return $_SESSION['messages'];
......
...@@ -183,6 +183,35 @@ function theme_page($content, $title = NULL, $breadcrumb = NULL) { ...@@ -183,6 +183,35 @@ function theme_page($content, $title = NULL, $breadcrumb = NULL) {
return $output; return $output;
} }
/**
* 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. * Returns themed set of links.
* *
...@@ -283,7 +312,6 @@ function theme_node($node, $main = 0, $page = 0) { ...@@ -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) { function theme_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) {
$output = "<div class=\"form-item\">\n"; $output = "<div class=\"form-item\">\n";
$required = $required ? theme('mark') : ''; $required = $required ? theme('mark') : '';
if ($title) { if ($title) {
...@@ -446,6 +474,7 @@ function theme_item_list($items = array(), $title = NULL) { ...@@ -446,6 +474,7 @@ function theme_item_list($items = array(), $title = NULL) {
/** /**
* Returns themed error message. * Returns themed error message.
* REMOVE: this function is deprecated an no longer used in core.
* *
* @param $message the error message to be themed. * @param $message the error message to be themed.
* *
......
...@@ -77,10 +77,7 @@ function chameleon_page($content, $title = NULL, $breadcrumb = NULL) { ...@@ -77,10 +77,7 @@ function chameleon_page($content, $title = NULL, $breadcrumb = NULL) {
$output .= "<div id=\"help\">$help</div><hr />"; $output .= "<div id=\"help\">$help</div><hr />";
} }
foreach (drupal_get_messages() as $message) { $output .= theme_status_messages();
list($message, $type) = $message;
$output .= "<div class=\"message $type\">". ucfirst($message) ."</div>";
}
$output .= "\n<!-- begin content -->\n"; $output .= "\n<!-- begin content -->\n";
$output .= $content; $output .= $content;
......
...@@ -99,17 +99,17 @@ br { ...@@ -99,17 +99,17 @@ br {
.block { .block {
width: 180px; width: 180px;
} }
.message { .messages {
padding: 0.3em; padding: 0.3em;
margin: 1em 0em 1em 0em; margin: 0.5em 0em 0.5em 0em;
} }
.status { .status {
border: 1px solid #696; border: 1px solid #3a3;
color: #696; color: #3a3;
} }
.error, form-item input.error { .error, form-item input.error {
border: 1px solid #930; border: 1px solid red;
color: #930; color: red;
} }
/* /*
......
...@@ -142,7 +142,7 @@ table { ...@@ -142,7 +142,7 @@ table {
.breadcrumb { .breadcrumb {
margin-bottom: .5em; margin-bottom: .5em;
} }
.message { .messages {
background-color: #eee; background-color: #eee;
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 0.3em; padding: 0.3em;
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<div id="help">{help}</div> <div id="help">{help}</div>
<!-- END: help --> <!-- END: help -->
<!-- BEGIN: message --> <!-- BEGIN: message -->
<div class="message {type}">{message}</div> {message}
<!-- END: message --> <!-- END: message -->
<!-- END: header --> <!-- END: header -->
......
...@@ -177,7 +177,7 @@ td#home a:hover img { ...@@ -177,7 +177,7 @@ td#home a:hover img {
.breadcrumb { .breadcrumb {
margin-bottom: .5em; margin-bottom: .5em;
} }
.message { .messages {
background-color: #eee; background-color: #eee;
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 0.3em; padding: 0.3em;
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<div id="help">{help}</div> <div id="help">{help}</div>
<!-- END: help --> <!-- END: help -->
<!-- BEGIN: message --> <!-- BEGIN: message -->
<div class="message {type}">{message}</div> {message}
<!-- END: message --> <!-- END: message -->
<!-- END: header --> <!-- END: header -->
......
...@@ -164,10 +164,8 @@ function xtemplate_page($content, $title = NULL, $breadcrumb = NULL) { ...@@ -164,10 +164,8 @@ function xtemplate_page($content, $title = NULL, $breadcrumb = NULL) {
$xtemplate->template->parse("header.help"); $xtemplate->template->parse("header.help");
} }
foreach (drupal_get_messages() as $message) { if ($message = theme_status_messages()) {
list($message, $type) = $message; $xtemplate->template->assign("message", $message);
$xtemplate->template->assign("message", ucfirst($message));
$xtemplate->template->assign("type", $type);
$xtemplate->template->parse("header.message"); $xtemplate->template->parse("header.message");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment