diff --git includes/common.inc includes/common.inc index d7a989b..27d503f 100644 --- includes/common.inc +++ includes/common.inc @@ -4321,6 +4321,36 @@ function drupal_set_page_content($content = NULL) { } } +/* + * A #pre_render callback. Construct a link. Doing so during pre_render gives + * modules a chance to alter the link parts. + * + * @param $elements + * A render array + * @return + * The same render array, but with type=#markup and a built link. + */ +function drupal_pre_render_link($elements) { + $options = isset($elements['#options']) ? $elements['#options'] : array(); + $elements['#markup'] = l($elements['#title'], $elements['#href'], $options); + $elements['#post_render'][] = 'drupal_post_render_markup'; + return $elements; +} + +/* + * A #pre_render callback. Append #markup contents to #prefix. + * + * @param $elements + * A render array + * @return + * The same render array, but with more output in #prefix. + */ +function drupal_pre_render_markup($elements) { + // Prepend markup and let drupal_render() handle the children. + $elements['#prefix'] .= $elements['#markup']; + return $elements; +} + /** * Renders the page, including all theming. * @@ -4429,6 +4459,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 the #type. + if (!empty($elements['#markup'])) { + $elements['#type'] = 'markup'; + } // If the default values for this element have not been loaded yet, populate // them. @@ -4442,12 +4478,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. @@ -4990,9 +5020,6 @@ function drupal_common_theme() { 'textarea' => array( 'arguments' => array('element' => NULL), ), - 'markup' => array( - 'arguments' => array('element' => NULL), - ), 'password' => array( 'arguments' => array('element' => NULL), ), diff --git includes/form.inc includes/form.inc index 1d9acbd..026b3ad 100644 --- includes/form.inc +++ includes/form.inc @@ -2595,24 +2595,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 modules/filter/filter.admin.inc modules/filter/filter.admin.inc index 31438df..3aa19ed 100644 --- modules/filter/filter.admin.inc +++ modules/filter/filter.admin.inc @@ -32,7 +32,7 @@ function filter_admin_overview($form) { $roles_markup = $roles ? implode(', ', $roles) : t('No roles may use this format'); } $form['formats'][$id]['roles'] = array('#markup' => $roles_markup); - $form['formats'][$id]['configure'] = array('#markup' => l(t('configure'), 'admin/config/content/formats/' . $id)); + $form['formats'][$id]['configure'] = array('#type' => 'link', '#title' => t('configure'), '#href' => 'admin/config/content/formats/' . $id); $form['formats'][$id]['delete'] = array('#markup' => $form['formats'][$id]['#is_fallback'] ? '' : l(t('delete'), 'admin/config/content/formats/' . $id . '/delete')); $form['formats'][$id]['weight'] = array('#type' => 'weight', '#default_value' => $format->weight); } diff --git modules/system/system.module modules/system/system.module index 8841b87..948eef3 100644 --- modules/system/system.module +++ modules/system/system.module @@ -444,7 +444,11 @@ function system_element_info() { ); $types['markup'] = array( '#markup' => '', - '#theme' => 'markup', + '#prefix' => '', + '#pre_render' => array('drupal_pre_render_markup'), + ); + $types['link'] = array( + '#pre_render' => array('drupal_pre_render_link'), ); $types['fieldset'] = array( '#collapsible' => FALSE,