From c5680fd1e062510a1619ed6d408113ba89351251 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Tue, 9 Jul 2013 17:43:45 +0000 Subject: [PATCH] Change function name and slightly safer logic. --- includes/utilities.inc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/includes/utilities.inc b/includes/utilities.inc index 29f450b1..5ce2ca14 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -869,6 +869,8 @@ function islandora_deprecated($release, $solution = NULL) { /** * Transform recursively-merged array of strings to renderable arrays. * + * Renderable arrays are passed-through as-is. + * * Previously, functions/hooks like islandora_view_object would return an * associative array with string values containing markup. These values were * then imploded into one large piece of markup. Here, we transform this older @@ -880,16 +882,24 @@ function islandora_deprecated($release, $solution = NULL) { * of strings, which we transform to renderable markup elements (by * reference). */ -function islandora_array_of_markup_to_renderable_array(&$markup_array) { +function islandora_as_renderable_array(&$markup_array) { foreach ($markup_array as &$value) { if (!is_array($value)) { + // Not a renderable array, just a string. Let's convert it to a + // renderable '#markup' element. $value = array( '#markup' => $value, ); } - else { + elseif (!isset($value['#type']) && !isset($value['#markup'])) { + // A simple array--possibly the result of a recursive merge? Let's + // look at each, to possibly convert them to a renderable '#markup' + // elements. foreach ($value as &$inner) { if (!is_array($inner)) { + // If it is an array at this level, we can assume that it is a + // renderable array. If it is not an array, convert to a renderable + // '#markup' element. $inner = array( '#markup' => $inner, );