Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.1038 diff -u -p -r1.1038 common.inc --- includes/common.inc 2 Nov 2009 03:46:43 -0000 1.1038 +++ includes/common.inc 2 Nov 2009 16:15:14 -0000 @@ -4605,6 +4605,47 @@ function drupal_set_page_content($conten } /** + * #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', ), Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.390 diff -u -p -r1.390 form.inc --- includes/form.inc 2 Nov 2009 03:00:28 -0000 1.390 +++ includes/form.inc 2 Nov 2009 16:15:15 -0000 @@ -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 Index: includes/locale.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/locale.inc,v retrieving revision 1.233 diff -u -p -r1.233 locale.inc --- includes/locale.inc 16 Oct 2009 02:04:42 -0000 1.233 +++ includes/locale.inc 2 Nov 2009 16:15:15 -0000 @@ -579,13 +579,13 @@ function _locale_languages_configure_for $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; } } Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.545 diff -u -p -r1.545 theme.inc --- includes/theme.inc 2 Nov 2009 00:25:32 -0000 1.545 +++ includes/theme.inc 2 Nov 2009 16:15:15 -0000 @@ -2043,6 +2043,10 @@ function _theme_table_cell($cell, $heade 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']); Index: modules/block/block.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v retrieving revision 1.60 diff -u -p -r1.60 block.admin.inc --- modules/block/block.admin.inc 16 Oct 2009 23:48:37 -0000 1.60 +++ modules/block/block.admin.inc 2 Nov 2009 16:15:15 -0000 @@ -87,14 +87,16 @@ function block_admin_display_form($form, '#options' => $block_regions, ); $form[$key]['configure'] = array( - '#markup' => l(t('configure'), - 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure'), + '#type' => 'link', + '#title' => t('configure'), + '#href' => 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', ); if ($block['module'] == 'block') { $form[$key]['delete'] = array( - '#markup' => l(t('delete'), - 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/delete'), - ); + '#type' => 'link', + '#title' => t('delete'), + '#href' => 'admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/delete', + ); } } // Do not allow disabling the main system content block. Index: modules/comment/comment.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.admin.inc,v retrieving revision 1.35 diff -u -p -r1.35 comment.admin.inc --- modules/comment/comment.admin.inc 16 Oct 2009 20:40:05 -0000 1.35 +++ modules/comment/comment.admin.inc 2 Nov 2009 16:16:23 -0000 @@ -86,11 +86,31 @@ function comment_admin_overview($form, & foreach ($result as $comment) { $options[$comment->cid] = array( - 'subject' => l($comment->subject, 'comment/' . $comment->cid, array('attributes' => array('title' => truncate_utf8($comment->comment, 128)), 'fragment' => 'comment-' . $comment->cid)), + 'subject' => array( + 'data' => array( + '#type' => 'link', + '#title' => $comment->subject, + '#href' => 'comment/' . $comment->cid, + '#options' => array('attributes' => array('title' => truncate_utf8($comment->comment, 128)), 'fragment' => 'comment-' . $comment->cid), + ), + ), 'author' => theme('username', array('account' => $comment)), - 'posted_in' => l($comment->node_title, 'node/' . $comment->nid), + 'posted_in' => array( + 'data' => array( + '#type' => 'link', + '#title' => $comment->node_title, + '#href' => 'node/' . $comment->nid, + ), + ), 'changed' => format_date($comment->changed, 'short'), - 'operations' => l(t('edit'), 'comment/' . $comment->cid .'/edit', array('query' => $destination)), + 'operations' => array( + 'data' => array( + '#type' => 'link', + '#title' => t('edit'), + '#href' => 'comment/' . $comment->cid . '/edit', + '#options' => array('query' => $destination), + ), + ), ); } Index: modules/field_ui/field_ui.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.admin.inc,v retrieving revision 1.26 diff -u -p -r1.26 field_ui.admin.inc --- modules/field_ui/field_ui.admin.inc 29 Oct 2009 07:21:04 -0000 1.26 +++ modules/field_ui/field_ui.admin.inc 2 Nov 2009 16:15:15 -0000 @@ -110,17 +110,29 @@ function field_ui_field_overview_form($f '#markup' => $instance['field_name'], ), 'type' => array( - '#markup' => l(t($field_types[$field['type']]['label']), $admin_field_path . '/field-settings', array('attributes' => array('title' => t('Edit field settings.')))), + '#type' => 'link', + '#title' => t($field_types[$field['type']]['label']), + '#href' => $admin_field_path . '/field-settings', + '#options' => array('attributes' => array('title' => t('Edit field settings.'))), ), 'widget_type' => array( - '#markup' => l(t($widget_types[$instance['widget']['type']]['label']), $admin_field_path . '/widget-type', array('attributes' => array('title' => t('Change widget type.')))), + '#type' => 'link', + '#title' => t($widget_types[$instance['widget']['type']]['label']), + '#href' => $admin_field_path . '/widget-type', + '#options' => array('attributes' => array('title' => t('Change widget type.'))), ), 'edit' => array( - '#markup' => l(t('edit'), $admin_field_path, array('attributes' => array('title' => t('Edit instance settings.')))), + '#type' => 'link', + '#title' => t('edit'), + '#href' => $admin_field_path, + '#options' => array('attributes' => array('title' => t('Edit instance settings.'))), ), 'delete' => array( - '#markup' => l(t('delete'), $admin_field_path . '/delete', array('attributes' => array('title' => t('Delete instance.')))), - ), + '#type' => 'link', + '#title' => t('delete'), + '#href' => $admin_field_path . '/delete', + '#options' => array('attributes' => array('title' => t('Delete instance.'))), + ), 'weight' => array( '#type' => 'textfield', '#default_value' => $weight, Index: modules/filter/filter.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v retrieving revision 1.49 diff -u -p -r1.49 filter.admin.inc --- modules/filter/filter.admin.inc 13 Oct 2009 15:39:41 -0000 1.49 +++ modules/filter/filter.admin.inc 2 Nov 2009 16:15:15 -0000 @@ -32,8 +32,8 @@ 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]['delete'] = array('#markup' => $form['formats'][$id]['#is_fallback'] ? '' : l(t('delete'), 'admin/config/content/formats/' . $id . '/delete')); + $form['formats'][$id]['configure'] = array('#type' => 'link', '#title' => t('configure'), '#href' => 'admin/config/content/formats/' . $id); + $form['formats'][$id]['delete'] = array('#type' => 'link', '#title' => t('delete'), '#href' => 'admin/config/content/formats/' . $id . '/delete', '#access' => !$form['formats'][$id]['#is_fallback']); $form['formats'][$id]['weight'] = array('#type' => 'weight', '#default_value' => $format->weight); } $form['submit'] = array('#type' => 'submit', '#value' => t('Save changes')); Index: modules/image/image.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/image/image.admin.inc,v retrieving revision 1.14 diff -u -p -r1.14 image.admin.inc --- modules/image/image.admin.inc 16 Oct 2009 00:52:46 -0000 1.14 +++ modules/image/image.admin.inc 2 Nov 2009 16:15:15 -0000 @@ -97,11 +97,15 @@ function image_style_form($form, &$form_ '#access' => $editable, ); $form['effects'][$ieid]['configure'] = array( - '#markup' => isset($effect['form callback']) ? l(t('edit'), 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'] ) : '', - '#access' => $editable, + '#type' => 'link', + '#title' => t('edit'), + '#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'], + '#access' => $editable && isset($effect['form callback']), ); $form['effects'][$ieid]['remove'] = array( - '#markup' => l(t('delete'), 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'] . '/delete'), + '#type' => 'link', + '#title' => t('delete'), + '#href' => 'admin/config/media/image-styles/edit/' . $style['name'] . '/effects/' . $effect['ieid'] . '/delete', '#access' => $editable, ); } Index: modules/menu/menu.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.admin.inc,v retrieving revision 1.66 diff -u -p -r1.66 menu.admin.inc --- modules/menu/menu.admin.inc 1 Nov 2009 23:02:13 -0000 1.66 +++ modules/menu/menu.admin.inc 2 Nov 2009 16:15:15 -0000 @@ -109,20 +109,16 @@ function _menu_overview_tree_form($tree) ); // Build a list of operations. $operations = array(); - $operations['edit'] = l(t('edit'), 'admin/structure/menu/item/' . $item['mlid'] . '/edit'); + $operations['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/edit'); // Only items created by the menu module can be deleted. if ($item['module'] == 'menu' || $item['updated'] == 1) { - $operations['delete'] = l(t('delete'), 'admin/structure/menu/item/' . $item['mlid'] . '/delete'); + $operations['delete'] = array('#type' => 'link', '#title' => t('delete'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/delete'); } // Set the reset column. elseif ($item['module'] == 'system' && $item['customized']) { - $operations['reset'] = l(t('reset'), 'admin/structure/menu/item/' . $item['mlid'] . '/reset'); - } - - $form[$mlid]['operations'] = array(); - foreach ($operations as $op => $value) { - $form[$mlid]['operations'][$op] = array('#markup' => $value); + $operations['reset'] = array('#type' => 'link', '#title' => t('reset'), '#href' => 'admin/structure/menu/item/' . $item['mlid'] . '/reset'); } + $form[$mlid]['operations'] = $operations; } if ($data['below']) { Index: modules/node/node.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v retrieving revision 1.74 diff -u -p -r1.74 node.admin.inc --- modules/node/node.admin.inc 27 Oct 2009 04:06:44 -0000 1.74 +++ modules/node/node.admin.inc 2 Nov 2009 16:15:15 -0000 @@ -449,7 +449,15 @@ function node_admin_nodes() { foreach ($result as $node) { $l_options = empty($node->language) ? array() : array('language' => $languages[$node->language]); $options[$node->nid] = array( - 'title' => l($node->title, 'node/' . $node->nid, $l_options) . ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))), + 'title' => array( + 'data' => array( + '#type' => 'link', + '#title' => $node->title, + '#href' => 'node/' . $node->nid, + '#options' => $l_options, + '#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))), + ), + ), 'type' => check_plain(node_type_get_name($node)), 'author' => theme('username', array('account' => $node)), 'status' => $node->status ? t('published') : t('not published'), @@ -458,7 +466,14 @@ function node_admin_nodes() { if ($multilanguage) { $options[$node->nid]['language'] = empty($node->language) ? t('Language neutral') : t($languages[$node->language]->name); } - $options[$node->nid]['operations'] = l(t('edit'), 'node/' . $node->nid . '/edit', array('query' => $destination)); + $options[$node->nid]['operations'] = array( + 'data' => array( + '#type' => 'link', + '#title' => t('edit'), + '#href' => 'node/' . $node->nid . '/edit', + '#options' => array('query' => $destination), + ), + ); } $form['nodes'] = array( '#type' => 'tableselect', Index: modules/profile/profile.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.admin.inc,v retrieving revision 1.33 diff -u -p -r1.33 profile.admin.inc --- modules/profile/profile.admin.inc 9 Oct 2009 01:00:02 -0000 1.33 +++ modules/profile/profile.admin.inc 2 Nov 2009 16:15:15 -0000 @@ -26,8 +26,8 @@ function profile_admin_overview($form) { $form[$field->fid]['type'] = array('#markup' => $field->type); $form[$field->fid]['category'] = array('#type' => 'select', '#default_value' => $field->category, '#options' => array()); $form[$field->fid]['weight'] = array('#type' => 'weight', '#default_value' => $field->weight); - $form[$field->fid]['edit'] = array('#markup' => l(t('edit'), "admin/config/people/profile/edit/$field->fid")); - $form[$field->fid]['delete'] = array('#markup' => l(t('delete'), "admin/config/people/profile/delete/$field->fid")); + $form[$field->fid]['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => "admin/config/people/profile/edit/$field->fid"); + $form[$field->fid]['delete'] = array('#type' => 'link', '#title' => t('delete'), '#href' => "admin/config/people/profile/delete/$field->fid"); } // Add the category combo boxes @@ -51,6 +51,7 @@ function profile_admin_overview($form) { } $form['#tree'] = TRUE; + // @todo: Any reason this isn't done using an element with #theme = 'links'? $addnewfields = '

' . t('Add new field') . '

'; $addnewfields .= '