summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc62
-rw-r--r--includes/form.inc18
-rw-r--r--includes/locale.inc6
-rw-r--r--includes/theme.inc4
4 files changed, 59 insertions, 31 deletions
diff --git a/includes/common.inc b/includes/common.inc
index de7674380..94c86f515 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -4605,6 +4605,47 @@ function drupal_set_page_content($content = NULL) {
}
/**
+ * #pre_render callback to render a link into #markup.
+ *
+ * Doing so during pre_render gives modules a chance to alter the link parts.
+ *
+ * @param $elements
+ * A structured array whose keys form the arguments to l():
+ * - #title: The link text to pass as argument to l().
+ * - #href: The URL path component to pass as argument to l().
+ * - #options: (optional) An array of options to pass to l().
+ *
+ * @return
+ * The passed in elements containing a rendered link in '#markup'.
+ */
+function drupal_pre_render_link($elements) {
+ $options = isset($elements['#options']) ? $elements['#options'] : array();
+ $elements['#markup'] = l($elements['#title'], $elements['#href'], $options);
+ return $elements;
+}
+
+/**
+ * #pre_render callback to append contents in #markup to #children.
+ *
+ * This needs to be a #pre_render callback, because eventually assigned
+ * #theme_wrappers will expect the element's rendered content in #children.
+ * Note that if also a #theme is defined for the element, then the result of
+ * the theme callback will override #children.
+ *
+ * @see drupal_render()
+ *
+ * @param $elements
+ * A structured array using the #markup key.
+ *
+ * @return
+ * The passed in elements, but #markup appended to #children.
+ */
+function drupal_pre_render_markup($elements) {
+ $elements['#children'] = $elements['#markup'];
+ return $elements;
+}
+
+/**
* Renders the page, including all theming.
*
* @param $page
@@ -4721,6 +4762,12 @@ function drupal_render(&$elements) {
if (isset($elements['#cache']) && $cached_output = drupal_render_cache_get($elements)) {
return $cached_output;
}
+
+ // If #markup is not empty, set #type. This allows to specify just #markup on
+ // an element without setting #type.
+ if (!empty($elements['#markup']) && !isset($elements['#type'])) {
+ $elements['#type'] = 'markup';
+ }
// If the default values for this element have not been loaded yet, populate
// them.
@@ -4734,12 +4781,6 @@ function drupal_render(&$elements) {
$elements += $defaults;
}
- // If #markup is not empty and no theme function is set, use theme_markup.
- // This allows to specify just #markup on an element without setting the #type.
- if (!empty($elements['#markup']) && empty($elements['#theme'])) {
- $elements['#theme'] = 'markup';
- }
-
// Make any final changes to the element before it is rendered. This means
// that the $element or the children can be altered or corrected before the
// element is rendered into the final text.
@@ -4754,7 +4795,11 @@ function drupal_render(&$elements) {
// Get the children of the element, sorted by weight.
$children = element_children($elements, TRUE);
- $elements['#children'] = '';
+ // Initialize this element's #children, unless a #pre_render callback already
+ // preset #children.
+ if (!isset($elements['#children'])) {
+ $elements['#children'] = '';
+ }
// Call the element's #theme function if it is set. Then any children of the
// element have to be rendered there.
if (isset($elements['#theme'])) {
@@ -5292,9 +5337,6 @@ function drupal_common_theme() {
'textarea' => array(
'render element' => 'element',
),
- 'markup' => array(
- 'render element' => 'element',
- ),
'password' => array(
'render element' => 'element',
),
diff --git a/includes/form.inc b/includes/form.inc
index 5e3895aaa..c3fa149a6 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -2668,24 +2668,6 @@ function theme_textarea($variables) {
}
/**
- * Theme HTML markup for use in forms.
- *
- * @param $variables
- * An associative array containing:
- * - element: An associative array containing the properties of the element.
- * Properties used: #markup, #children.
- *
- * @return
- * A themed HTML string representing the HTML markup.
- *
- * @ingroup themeable
- */
-function theme_markup($variables) {
- $element = $variables['element'];
- return (!empty($element['#markup']) ? $element['#markup'] : '') . drupal_render_children($element);
-}
-
-/**
* Theme a password form element.
*
* @param $variables
diff --git a/includes/locale.inc b/includes/locale.inc
index b905477f0..67c0429ea 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -579,13 +579,13 @@ function _locale_languages_configure_form_language_table(&$form, $type) {
$table_form['description'][$id] = array('#markup' => filter_xss_admin($provider['description']));
- $config_op = '';
+ $config_op = array();
if (isset($provider['config'])) {
- $config_op = l(t('Configure'), $provider['config']);
+ $config_op = array('#type' => 'link', '#title' => t('Configure'), '#href' => $provider['config']);
// If there is at least one operation enabled show the operation column.
$table_form['#show_operations'] = TRUE;
}
- $table_form['operation'][$id] = array('#markup' => $config_op);
+ $table_form['operation'][$id] = $config_op;
}
}
diff --git a/includes/theme.inc b/includes/theme.inc
index c70eb0092..6ca3b477f 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -2043,6 +2043,10 @@ function _theme_table_cell($cell, $header = FALSE) {
if (is_array($cell)) {
$data = isset($cell['data']) ? $cell['data'] : '';
+ // Cell's data property can be a string or a renderable array.
+ if (is_array($data)) {
+ $data = drupal_render($data);
+ }
$header |= isset($cell['header']);
unset($cell['data']);
unset($cell['header']);