From 8e57fb5263a832f7a31183a19751d3b4960d07f6 Mon Sep 17 00:00:00 2001 From: Dries Date: Wed, 15 May 2013 14:59:43 -0400 Subject: [PATCH] Issue #1938430 by shanethehat, steveoliver, Fabianx: Don't add a default theme hook class in template_preprocess(). --- core/includes/theme.inc | 10 +++++++--- core/modules/block/block.module | 1 + core/modules/comment/comment.module | 4 ++++ .../lib/Drupal/layout/Plugin/Layout/StaticLayout.php | 3 +++ core/modules/node/node.module | 1 + core/modules/overlay/overlay.module | 4 ++++ core/modules/taxonomy/taxonomy.module | 1 + core/modules/views/views.theme.inc | 1 + core/modules/views_ui/views_ui.theme.inc | 4 ++++ 9 files changed, 26 insertions(+), 3 deletions(-) diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 0d0e7397649..150c9a35269 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1646,6 +1646,10 @@ function template_preprocess_datetime(&$variables) { $variables['html'] = FALSE; } } + + // Add a 'datetime' class. + $variables['attributes']['class'][] = 'datetime'; + $variables['attributes'] = new Attribute($variables['attributes']); } @@ -2686,9 +2690,6 @@ function template_preprocess(&$variables, $hook) { 'title_attributes' => array(), 'content_attributes' => array(), ); - - // Initialize html class attribute for the current hook. - $variables['attributes']['class'][] = drupal_html_class($hook); } /** @@ -2732,6 +2733,7 @@ function template_preprocess_html(&$variables) { // Compile a list of classes that are going to be applied to the body element. // This allows advanced theming based on context (home page, node of certain type, etc.). + $variables['attributes']['class'][] = 'html'; // Add a class that tells us whether we're on the front page or not. $variables['attributes']['class'][] = $variables['is_front'] ? 'front' : 'not-front'; // Add a class that tells us whether the page is viewed by an authenticated user or not. @@ -3109,6 +3111,7 @@ function template_preprocess_maintenance_page(&$variables) { $variables['title'] = drupal_get_title(); // Compile a list of classes that are going to be applied to the body element. + $variables['attributes']['class'][] = 'maintenance-page'; $variables['attributes']['class'][] = 'in-maintenance'; if (isset($variables['db_is_active']) && !$variables['db_is_active']) { $variables['attributes']['class'][] = 'db-offline'; @@ -3169,6 +3172,7 @@ function template_preprocess_region(&$variables) { $variables['content'] = $variables['elements']['#children']; $variables['region'] = $variables['elements']['#region']; + $variables['attributes']['class'][] = 'region'; $variables['attributes']['class'][] = drupal_region_class($variables['region']); $variables['theme_hook_suggestions'][] = 'region__' . $variables['region']; } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index db497e32272..d94ec3b3723 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -539,6 +539,7 @@ function template_preprocess_block(&$variables) { $variables['label'] = !empty($variables['configuration']['label_display']) ? $variables['configuration']['label'] : ''; $variables['content'] = $variables['elements']['content']; + $variables['attributes']['class'][] = 'block'; $variables['attributes']['class'][] = drupal_html_class('block-' . $variables['configuration']['module']); // Add default class for block content. diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 3f6fdf53277..ba2acb72033 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1646,6 +1646,7 @@ function template_preprocess_comment(&$variables) { } // Gather comment classes. + $variables['attributes']['class'][] = 'comment'; // 'published' class is not needed, it is either 'preview' or 'unpublished'. if ($variables['status'] != 'published') { $variables['attributes']['class'][] = $variables['status']; @@ -1724,6 +1725,9 @@ function template_preprocess_comment_wrapper(&$variables) { $variables['display_mode'] = variable_get('comment_default_mode_' . $variables['node']->type, COMMENT_MODE_THREADED); // The comment form is optional and may not exist. $variables['content'] += array('comment_form' => array()); + + // Add a comment wrapper class. + $variables['attributes']['class'][] = 'comment-wrapper'; } /** diff --git a/core/modules/layout/lib/Drupal/layout/Plugin/Layout/StaticLayout.php b/core/modules/layout/lib/Drupal/layout/Plugin/Layout/StaticLayout.php index ead803b1e4c..f88da2f9a71 100644 --- a/core/modules/layout/lib/Drupal/layout/Plugin/Layout/StaticLayout.php +++ b/core/modules/layout/lib/Drupal/layout/Plugin/Layout/StaticLayout.php @@ -82,6 +82,9 @@ class StaticLayout extends PluginBase implements LayoutInterface { $build = array( '#theme' => $definition['theme'], '#content' => array(), + '#attributes' => array( + 'class' => drupal_html_class($definition['theme']), + ), ); // Render all regions needed for this layout. diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 32e5b8197b0..183bdd832ab 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1186,6 +1186,7 @@ function template_preprocess_node(&$variables) { $variables['attributes']['role'] = 'article'; // Gather node classes. + $variables['attributes']['class'][] = 'node'; $variables['attributes']['class'][] = drupal_html_class('node-' . $node->type); if ($node->promote) { $variables['attributes']['class'][] = 'promoted'; diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index 31289d5fda5..1566740a06e 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -519,6 +519,10 @@ function template_preprocess_overlay(&$variables) { $variables['tabs'] = menu_primary_local_tasks(); $variables['title'] = drupal_get_title(); $variables['disable_overlay'] = overlay_disable_message(); + + // Add atrributes for the overlay container. + $variables['attributes']['class'][] = 'overlay'; + // Add attributes for the overlay content. $variables['content_attributes']['class'][] = 'clearfix'; } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index d576b540495..419e0baf11b 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -490,6 +490,7 @@ function template_preprocess_taxonomy_term(&$variables) { field_attach_preprocess($term, $variables['content'], $variables); // Gather classes, and clean up name so there are no underscores. + $variables['attributes']['class'][] = 'taxonomy-term'; $vocabulary_name_css = str_replace('_', '-', $term->bundle()); $variables['attributes']['class'][] = 'vocabulary-' . $vocabulary_name_css; diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index e0bbbebcb0e..e987ffdb2bb 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -620,6 +620,7 @@ function template_preprocess_views_view_table(&$vars) { } $vars['attributes']['class'][] = 'views-table'; + $vars['attributes']['class'][] = 'views-view-table'; if (empty($vars['rows']) && !empty($options['empty_table'])) { $build = $view->display_handler->renderArea('empty'); $vars['rows'][0][0] = drupal_render($build); diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc index 1a3e596a220..e19cefaf564 100644 --- a/core/modules/views_ui/views_ui.theme.inc +++ b/core/modules/views_ui/views_ui.theme.inc @@ -24,6 +24,8 @@ function template_preprocess_views_ui_display_tab_setting(&$variables) { array_unshift($variables['settings_links'], $variables['link']); $variables['settings_links'] = implode(' | ', $variables['settings_links']); + $variables['attributes']['class'][] = 'views-ui-display-tab-setting'; + if (!empty($variables['defaulted'])) { $variables['attributes']['class'][] = 'defaulted'; } @@ -41,6 +43,8 @@ function template_preprocess_views_ui_display_tab_setting(&$variables) { function template_preprocess_views_ui_display_tab_bucket(&$variables) { $element = $variables['element']; + $variables['attributes']['class'][] = 'views-ui-display-tab-bucket'; + if (!empty($element['#name'])) { $variables['attributes']['class'][] = drupal_html_class($element['#name']); }