diff --git a/core/modules/views/theme/views-view-row-comment.tpl.php b/core/modules/comment/templates/views-view-row-comment.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-row-comment.tpl.php rename to core/modules/comment/templates/views-view-row-comment.tpl.php diff --git a/core/modules/views/lib/Drupal/views/Plugin/Type/PluginManager.php b/core/modules/views/lib/Drupal/views/Plugin/Type/PluginManager.php index 354c1069d36c0903aef9e62ee9919a31b0e88f46..f492034ea9bbff297b863ade855e63aaa36daf7d 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Type/PluginManager.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Type/PluginManager.php @@ -30,22 +30,8 @@ public function __construct($type) { 'parent' => 'parent', 'plugin_type' => $type, 'module' => 'views', + 'register_theme' => TRUE, ); } - /** - * Overrides Drupal\Component\Plugin\PluginManagerBase::processDefinition(). - */ - public function processDefinition(&$definition, $plugin_id) { - parent::processDefinition($definition, $plugin_id); - - // Setup automatic path/file finding for theme registration. - if ($definition['module'] == 'views' || isset($definition['theme'])) { - $definition += array( - 'theme path' => drupal_get_path('module', 'views') . '/theme', - 'theme file' => 'theme.inc', - ); - } - } - } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.php index c045b7d470f94a30e7b63b6d1de665418fe17b03..36b1a018e86e255cd52bf9145f64b0559b422cfb 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.php @@ -179,19 +179,6 @@ public function themeFunctions() { return views_theme_functions($this->definition['theme'], $this->view, $this->view->display_handler->display); } - /** - * Provide a list of additional theme functions for the theme information page - */ - public function additionalThemeFunctions() { - $funcs = array(); - if (!empty($this->definition['additional themes'])) { - foreach ($this->definition['additional themes'] as $theme => $type) { - $funcs[] = views_theme_functions($theme, $this->view, $this->view->display_handler->display); - } - } - return $funcs; - } - /** * Validate that the plugin is correct and can be saved. * diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 5f5cfe1a9c65ac72198b82df51527611eb223e23..91da34500046dd99d0505e74f6f333da98cdd7d6 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -1762,34 +1762,16 @@ public function buildOptionsForm(&$form, &$form_state) { // delegates to the style. if (!empty($this->definition['theme'])) { $funcs[] = $this->optionLink(t('Display output'), 'analyze-theme-display') . ': ' . $this->formatThemes($this->themeFunctions()); - $themes = $this->additionalThemeFunctions(); - if ($themes) { - foreach ($themes as $theme) { - $funcs[] = $this->optionLink(t('Alternative display output'), 'analyze-theme-display') . ': ' . $this->formatThemes($theme); - } - } } $plugin = $this->getPlugin('style'); if ($plugin) { - $funcs[] = $this->optionLink(t('Style output'), 'analyze-theme-style') . ': ' . $this->formatThemes($plugin->themeFunctions(), $plugin->additionalThemeFunctions()); - $themes = $plugin->additionalThemeFunctions(); - if ($themes) { - foreach ($themes as $theme) { - $funcs[] = $this->optionLink(t('Alternative style'), 'analyze-theme-style') . ': ' . $this->formatThemes($theme); - } - } + $funcs[] = $this->optionLink(t('Style output'), 'analyze-theme-style') . ': ' . $this->formatThemes($plugin->themeFunctions()); if ($plugin->usesRowPlugin()) { $row_plugin = $this->getPlugin('row'); if ($row_plugin) { $funcs[] = $this->optionLink(t('Row style output'), 'analyze-theme-row') . ': ' . $this->formatThemes($row_plugin->themeFunctions()); - $themes = $row_plugin->additionalThemeFunctions(); - if ($themes) { - foreach ($themes as $theme) { - $funcs[] = $this->optionLink(t('Alternative row style'), 'analyze-theme-row') . ': ' . $this->formatThemes($theme); - } - } } } @@ -1863,14 +1845,7 @@ public function buildOptionsForm(&$form, &$form_state) { } else { $output .= '<p>' . t('This is the default theme template used for this display.') . '</p>'; - $output .= '<pre>' . check_plain(file_get_contents('./' . $this->definition['theme path'] . '/' . strtr($this->definition['theme'], '_', '-') . '.tpl.php')) . '</pre>'; - } - - if (!empty($this->definition['additional themes'])) { - foreach ($this->definition['additional themes'] as $theme => $type) { - $output .= '<p>' . t('This is an alternative template for this display.') . '</p>'; - $output .= '<pre>' . check_plain(file_get_contents('./' . $this->definition['theme path'] . '/' . strtr($theme, '_', '-') . '.tpl.php')) . '</pre>'; - } + $output .= '<pre>' . check_plain(file_get_contents('./' . $this->definition['theme_path'] . '/' . strtr($this->definition['theme'], '_', '-') . '.tpl.php')) . '</pre>'; } $form['analysis'] = array( @@ -1890,14 +1865,7 @@ public function buildOptionsForm(&$form, &$form_state) { } else { $output .= '<p>' . t('This is the default theme template used for this style.') . '</p>'; - $output .= '<pre>' . check_plain(file_get_contents('./' . $plugin->definition['theme path'] . '/' . strtr($plugin->definition['theme'], '_', '-') . '.tpl.php')) . '</pre>'; - } - - if (!empty($plugin->definition['additional themes'])) { - foreach ($plugin->definition['additional themes'] as $theme => $type) { - $output .= '<p>' . t('This is an alternative template for this style.') . '</p>'; - $output .= '<pre>' . check_plain(file_get_contents('./' . $plugin->definition['theme path'] . '/' . strtr($theme, '_', '-') . '.tpl.php')) . '</pre>'; - } + $output .= '<pre>' . check_plain(file_get_contents('./' . $plugin->definition['theme_path'] . '/' . strtr($plugin->definition['theme'], '_', '-') . '.tpl.php')) . '</pre>'; } $form['analysis'] = array( @@ -1917,14 +1885,7 @@ public function buildOptionsForm(&$form, &$form_state) { } else { $output .= '<p>' . t('This is the default theme template used for this row style.') . '</p>'; - $output .= '<pre>' . check_plain(file_get_contents('./' . $plugin->definition['theme path'] . '/' . strtr($plugin->definition['theme'], '_', '-') . '.tpl.php')) . '</pre>'; - } - - if (!empty($plugin->definition['additional themes'])) { - foreach ($plugin->definition['additional themes'] as $theme => $type) { - $output .= '<p>' . t('This is an alternative template for this row style.') . '</p>'; - $output .= '<pre>' . check_plain(file_get_contents('./' . $plugin->definition['theme path'] . '/' . strtr($theme, '_', '-') . '.tpl.php')) . '</pre>'; - } + $output .= '<pre>' . check_plain(file_get_contents('./' . $plugin->definition['theme_path'] . '/' . strtr($plugin->definition['theme'], '_', '-') . '.tpl.php')) . '</pre>'; } $form['analysis'] = array( @@ -1941,7 +1902,7 @@ public function buildOptionsForm(&$form, &$form_state) { // Field templates aren't registered the normal way...and they're always // this one, anyhow. - $output .= '<pre>' . check_plain(file_get_contents(drupal_get_path('module', 'views') . '/theme/views-view-field.tpl.php')) . '</pre>'; + $output .= '<pre>' . check_plain(file_get_contents(drupal_get_path('module', 'views') . '/templates/views-view-field.tpl.php')) . '</pre>'; $form['analysis'] = array( '#markup' => '<div class="form-item">' . $output . '</div>', diff --git a/core/modules/views/theme/views-exposed-form.tpl.php b/core/modules/views/templates/views-exposed-form.tpl.php similarity index 100% rename from core/modules/views/theme/views-exposed-form.tpl.php rename to core/modules/views/templates/views-exposed-form.tpl.php diff --git a/core/modules/views/theme/views-more.tpl.php b/core/modules/views/templates/views-more.tpl.php similarity index 100% rename from core/modules/views/theme/views-more.tpl.php rename to core/modules/views/templates/views-more.tpl.php diff --git a/core/modules/views/theme/views-view-field.tpl.php b/core/modules/views/templates/views-view-field.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-field.tpl.php rename to core/modules/views/templates/views-view-field.tpl.php diff --git a/core/modules/views/theme/views-view-fields.tpl.php b/core/modules/views/templates/views-view-fields.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-fields.tpl.php rename to core/modules/views/templates/views-view-fields.tpl.php diff --git a/core/modules/views/theme/views-view-grid.tpl.php b/core/modules/views/templates/views-view-grid.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-grid.tpl.php rename to core/modules/views/templates/views-view-grid.tpl.php diff --git a/core/modules/views/theme/views-view-grouping.tpl.php b/core/modules/views/templates/views-view-grouping.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-grouping.tpl.php rename to core/modules/views/templates/views-view-grouping.tpl.php diff --git a/core/modules/views/theme/views-view-list.tpl.php b/core/modules/views/templates/views-view-list.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-list.tpl.php rename to core/modules/views/templates/views-view-list.tpl.php diff --git a/core/modules/views/theme/views-view-row-rss.tpl.php b/core/modules/views/templates/views-view-row-rss.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-row-rss.tpl.php rename to core/modules/views/templates/views-view-row-rss.tpl.php diff --git a/core/modules/views/theme/views-view-rss.tpl.php b/core/modules/views/templates/views-view-rss.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-rss.tpl.php rename to core/modules/views/templates/views-view-rss.tpl.php diff --git a/core/modules/views/theme/views-view-summary-unformatted.tpl.php b/core/modules/views/templates/views-view-summary-unformatted.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-summary-unformatted.tpl.php rename to core/modules/views/templates/views-view-summary-unformatted.tpl.php diff --git a/core/modules/views/theme/views-view-summary.tpl.php b/core/modules/views/templates/views-view-summary.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-summary.tpl.php rename to core/modules/views/templates/views-view-summary.tpl.php diff --git a/core/modules/views/theme/views-view-table.tpl.php b/core/modules/views/templates/views-view-table.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-table.tpl.php rename to core/modules/views/templates/views-view-table.tpl.php diff --git a/core/modules/views/theme/views-view-unformatted.tpl.php b/core/modules/views/templates/views-view-unformatted.tpl.php similarity index 100% rename from core/modules/views/theme/views-view-unformatted.tpl.php rename to core/modules/views/templates/views-view-unformatted.tpl.php diff --git a/core/modules/views/theme/views-view.tpl.php b/core/modules/views/templates/views-view.tpl.php similarity index 100% rename from core/modules/views/theme/views-view.tpl.php rename to core/modules/views/templates/views-view.tpl.php diff --git a/core/modules/views/views.module b/core/modules/views/views.module index f1286d1039350d25757d7f9919be80cff85af7a5..e2d59310980b38c344f71884d48355e3da3cb97c 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -95,13 +95,11 @@ function views_config_import_create($name, $new_config, $old_config) { * Implement hook_theme(). Register views theming functions. */ function views_theme($existing, $type, $theme, $path) { - $path = drupal_get_path('module', 'views'); - module_load_include('inc', 'views', 'theme/theme'); + module_load_include('inc', 'views', 'views.theme'); // Some quasi clever array merging here. $base = array( - 'file' => 'theme.inc', - 'path' => $path . '/theme', + 'file' => 'views.theme.inc', ); // Our extra version of pager from pager.inc @@ -139,42 +137,39 @@ function views_theme($existing, $type, $theme, $path) { // Register theme functions for all style plugins foreach ($plugins as $type => $info) { foreach ($info as $plugin => $def) { - if (isset($def['theme']) && (!isset($def['register theme']) || !empty($def['register theme']))) { - $hooks[$def['theme']] = array( - 'pattern' => $def['theme'] . '__', - 'file' => $def['theme file'], - 'path' => $def['theme path'], - 'variables' => $variables[$type], - ); + // Not all plugins have theme functions, and they can also explicitly + // prevent a theme function from being registered automatically. + if (!isset($def['theme']) || empty($def['register_theme'])) { + continue; + } - $include = DRUPAL_ROOT . '/' . $def['theme path'] . '/' . $def['theme file']; - if (file_exists($include)) { - require_once $include; - } + $hooks[$def['theme']] = array( + 'pattern' => $def['theme'] . '__', + 'variables' => $variables[$type], + ); - if (!function_exists('theme_' . $def['theme'])) { - $hooks[$def['theme']]['template'] = drupal_clean_css_identifier($def['theme']); - } + if ($def['module'] == 'views') { + $def['theme_file'] = 'views.theme.inc'; + } + elseif (isset($def['theme_file'])) { + $def['theme_path'] = drupal_get_path('module', $def['module']); } - if (isset($def['additional themes'])) { - foreach ($def['additional themes'] as $theme => $theme_type) { - if (empty($theme_type)) { - $theme = $theme_type; - $theme_type = $type; - } - - $hooks[$theme] = array( - 'pattern' => $theme . '__', - 'file' => $def['theme file'], - 'path' => $def['theme path'], - 'variables' => $variables[$theme_type], - ); - if (!function_exists('theme_' . $theme)) { - $hooks[$theme]['template'] = drupal_clean_css_identifier($theme); - } + if (isset($def['theme_path'])) { + $hooks[$def['theme']]['path'] = $def['theme_path']; + } + if (isset($def['theme_file'])) { + $hooks[$def['theme']]['file'] = $def['theme_file']; + } + if (isset($def['theme_path']) && isset($def['theme_file'])) { + $include = DRUPAL_ROOT . '/' . $def['theme_path'] . '/' . $def['theme_file']; + if (is_file($include)) { + require_once $include; } } + if (!function_exists('theme_' . $def['theme'])) { + $hooks[$def['theme']]['template'] = drupal_clean_css_identifier($def['theme']); + } } } @@ -1931,7 +1926,7 @@ function views_exposed_form_cache($views_name, $display_name, $form_output = NUL * Build a list of theme function names for use most everywhere. */ function views_theme_functions($hook, ViewExecutable $view, $display = NULL) { - module_load_include('inc', 'views', 'theme/theme'); + module_load_include('inc', 'views', 'views.theme'); return _views_theme_functions($hook, $view, $display); } diff --git a/core/modules/views/theme/theme.inc b/core/modules/views/views.theme.inc similarity index 100% rename from core/modules/views/theme/theme.inc rename to core/modules/views/views.theme.inc diff --git a/core/modules/views/views_ui/theme/views-ui-display-tab-bucket.tpl.php b/core/modules/views/views_ui/templates/views-ui-display-tab-bucket.tpl.php similarity index 100% rename from core/modules/views/views_ui/theme/views-ui-display-tab-bucket.tpl.php rename to core/modules/views/views_ui/templates/views-ui-display-tab-bucket.tpl.php diff --git a/core/modules/views/views_ui/theme/views-ui-display-tab-setting.tpl.php b/core/modules/views/views_ui/templates/views-ui-display-tab-setting.tpl.php similarity index 100% rename from core/modules/views/views_ui/theme/views-ui-display-tab-setting.tpl.php rename to core/modules/views/views_ui/templates/views-ui-display-tab-setting.tpl.php diff --git a/core/modules/views/views_ui/theme/views-ui-edit-item.tpl.php b/core/modules/views/views_ui/templates/views-ui-edit-item.tpl.php similarity index 100% rename from core/modules/views/views_ui/theme/views-ui-edit-item.tpl.php rename to core/modules/views/views_ui/templates/views-ui-edit-item.tpl.php diff --git a/core/modules/views/views_ui/theme/views-ui-edit-view.tpl.php b/core/modules/views/views_ui/templates/views-ui-edit-view.tpl.php similarity index 100% rename from core/modules/views/views_ui/theme/views-ui-edit-view.tpl.php rename to core/modules/views/views_ui/templates/views-ui-edit-view.tpl.php diff --git a/core/modules/views/views_ui/views_ui.module b/core/modules/views/views_ui/views_ui.module index 74c9e0720c90796759d755cac5cc4b9ec736b002..a7b20c8a7e8a0c8f8ba7262f2bc35074736f141f 100644 --- a/core/modules/views/views_ui/views_ui.module +++ b/core/modules/views/views_ui/views_ui.module @@ -197,55 +197,45 @@ function views_ui_menu() { * Implements hook_theme(). */ function views_ui_theme() { - $path = drupal_get_path('module', 'views_ui'); - return array( // edit a view 'views_ui_display_tab_setting' => array( 'variables' => array('description' => '', 'link' => '', 'settings_links' => array(), 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => array()), 'template' => 'views-ui-display-tab-setting', - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), 'views_ui_display_tab_bucket' => array( 'render element' => 'element', 'template' => 'views-ui-display-tab-bucket', - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), 'views_ui_edit_item' => array( 'variables' => array('type' => NULL, 'view' => NULL, 'display' => NULL, 'no_fields' => FALSE), 'template' => 'views-ui-edit-item', - 'path' => "$path/theme", ), 'views_ui_rearrange_form' => array( 'render element' => 'form', - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), 'views_ui_rearrange_filter_form' => array( 'render element' => 'form', - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), 'views_ui_expose_filter_form' => array( 'render element' => 'form', - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), // list views 'views_ui_view_info' => array( 'variables' => array('view' => NULL, 'base' => NULL), - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), // Group of filters. 'views_ui_build_group_filter_form' => array( 'render element' => 'form', - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), // tab themes @@ -257,30 +247,26 @@ function views_ui_theme() { ), 'views_ui_reorder_displays_form' => array( 'render element' => 'form', - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), // On behalf of a plugin 'views_ui_style_plugin_table' => array( 'render element' => 'form', - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), // When previewing a view. 'views_ui_view_preview_section' => array( 'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''), - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), // Generic container wrapper, to use instead of theme_container when an id // is not desired. 'views_ui_container' => array( 'render element' => 'element', - 'path' => "$path/theme", - 'file' => 'theme.inc', + 'file' => 'views_ui.theme.inc', ), ); } diff --git a/core/modules/views/views_ui/theme/theme.inc b/core/modules/views/views_ui/views_ui.theme.inc similarity index 100% rename from core/modules/views/views_ui/theme/theme.inc rename to core/modules/views/views_ui/views_ui.theme.inc