From 40c8bac42534ff67646c715afc0f5fbea7ed0980 Mon Sep 17 00:00:00 2001 From: mitchmac Date: Fri, 18 Oct 2013 11:59:57 -0300 Subject: [PATCH 1/2] Try to limit wall of text with derivative messages --- includes/derivatives.inc | 14 +++++++++++++- includes/utilities.inc | 19 +++++++++++++++++++ islandora.module | 7 +++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index 8a6627e5..cb8bacbf 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -96,7 +96,19 @@ function islandora_derivative_logging(array $logging_results) { foreach ($logging_results as $result) { foreach ($result['messages'] as $message) { if ($message['type'] === 'dsm') { - drupal_set_message(filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())), isset($message['severity']) ? $message['severity'] : 'status'); + if (isset($message['severity']) && $message['severity'] != 'status') { + drupal_set_message(filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())), $message['severity']); + } + else { + if (!isset($_SESSION['islandora_derivative_messages'])) { + $_SESSION['islandora_derivative_messages'] = array(); + } + $_SESSION['islandora_derivative_messages'][] = array( + 'message' => filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())), + 'severity' => 'status', + ); + drupal_set_message(l(t('Derivatives successfully created.'), 'islandora/event-status'), 'status', FALSE); + } } else { // We know what we are doing here. Passing through the translated diff --git a/includes/utilities.inc b/includes/utilities.inc index 2139ae09..5417100b 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -924,3 +924,22 @@ function islandora_sanitize_input_for_valid_xml($input, $replacement = '') { $input = preg_replace('/[^\x9\xA\xD\x20-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u', $replacement, $input); return $input; } + +/** + * Page callback for session status messages to be sent to drupal_set_message(). + * + * @return array + * Render array containing markup. + */ +function islandora_event_status() { + $results = FALSE; + if (isset($_SESSION['islandora_derivative_messages'])) { + foreach ($_SESSION['islandora_derivative_messages'] as $message) { + drupal_set_message($message['message'], $message['severity']); + $results = TRUE; + } + unset($_SESSION['islandora_derivative_messages']); + } + $text = ($results) ? t('The status messages above will be deleted after viewing this page.') : t('No messages to display.'); + return array('#markup' => $text); +} diff --git a/islandora.module b/islandora.module index 1d951b74..9c14c90f 100644 --- a/islandora.module +++ b/islandora.module @@ -322,6 +322,13 @@ function islandora_menu() { 'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2), 'load arguments' => array(2), ); + $items['islandora/event-status'] = array( + 'title' => 'Event Status', + 'page callback' => 'islandora_event_status', + 'type' => MENU_CALLBACK, + 'access callback' => TRUE, + 'file' => 'includes/utilities.inc', + ); $items[ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE] = array( 'title' => 'Autocomplete callback', 'description' => 'Autocomplete a Fedora content model PID.', From 1f6d4f56ffdd09c58d0c6548d4f89e4c6ba1749a Mon Sep 17 00:00:00 2001 From: mitchmac Date: Fri, 18 Oct 2013 12:05:40 -0300 Subject: [PATCH 2/2] Rename session array to be more generic --- includes/derivatives.inc | 6 +++--- includes/utilities.inc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/derivatives.inc b/includes/derivatives.inc index cb8bacbf..4daa2133 100644 --- a/includes/derivatives.inc +++ b/includes/derivatives.inc @@ -100,10 +100,10 @@ function islandora_derivative_logging(array $logging_results) { drupal_set_message(filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())), $message['severity']); } else { - if (!isset($_SESSION['islandora_derivative_messages'])) { - $_SESSION['islandora_derivative_messages'] = array(); + if (!isset($_SESSION['islandora_event_messages'])) { + $_SESSION['islandora_event_messages'] = array(); } - $_SESSION['islandora_derivative_messages'][] = array( + $_SESSION['islandora_event_messages'][] = array( 'message' => filter_xss(format_string($message['message'], isset($message['message_sub']) ? $message['message_sub'] : array())), 'severity' => 'status', ); diff --git a/includes/utilities.inc b/includes/utilities.inc index 5417100b..44a80402 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -933,12 +933,12 @@ function islandora_sanitize_input_for_valid_xml($input, $replacement = '') { */ function islandora_event_status() { $results = FALSE; - if (isset($_SESSION['islandora_derivative_messages'])) { - foreach ($_SESSION['islandora_derivative_messages'] as $message) { + if (isset($_SESSION['islandora_event_messages'])) { + foreach ($_SESSION['islandora_event_messages'] as $message) { drupal_set_message($message['message'], $message['severity']); $results = TRUE; } - unset($_SESSION['islandora_derivative_messages']); + unset($_SESSION['islandora_event_messages']); } $text = ($results) ? t('The status messages above will be deleted after viewing this page.') : t('No messages to display.'); return array('#markup' => $text);