Skip to content
Snippets Groups Projects
Commit 2809f13d authored by webchick's avatar webchick
Browse files

Issue #1805980 by tim.plunkett: Rename /theme to /templates and theme.inc to views.theme.inc

parent 6f48b043
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Showing
with 36 additions and 107 deletions
...@@ -30,22 +30,8 @@ public function __construct($type) { ...@@ -30,22 +30,8 @@ public function __construct($type) {
'parent' => 'parent', 'parent' => 'parent',
'plugin_type' => $type, 'plugin_type' => $type,
'module' => 'views', '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',
);
}
}
} }
...@@ -179,19 +179,6 @@ public function themeFunctions() { ...@@ -179,19 +179,6 @@ public function themeFunctions() {
return views_theme_functions($this->definition['theme'], $this->view, $this->view->display_handler->display); 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. * Validate that the plugin is correct and can be saved.
* *
......
...@@ -1762,34 +1762,16 @@ public function buildOptionsForm(&$form, &$form_state) { ...@@ -1762,34 +1762,16 @@ public function buildOptionsForm(&$form, &$form_state) {
// delegates to the style. // delegates to the style.
if (!empty($this->definition['theme'])) { if (!empty($this->definition['theme'])) {
$funcs[] = $this->optionLink(t('Display output'), 'analyze-theme-display') . ': ' . $this->formatThemes($this->themeFunctions()); $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'); $plugin = $this->getPlugin('style');
if ($plugin) { if ($plugin) {
$funcs[] = $this->optionLink(t('Style output'), 'analyze-theme-style') . ': ' . $this->formatThemes($plugin->themeFunctions(), $plugin->additionalThemeFunctions()); $funcs[] = $this->optionLink(t('Style output'), 'analyze-theme-style') . ': ' . $this->formatThemes($plugin->themeFunctions());
$themes = $plugin->additionalThemeFunctions();
if ($themes) {
foreach ($themes as $theme) {
$funcs[] = $this->optionLink(t('Alternative style'), 'analyze-theme-style') . ': ' . $this->formatThemes($theme);
}
}
if ($plugin->usesRowPlugin()) { if ($plugin->usesRowPlugin()) {
$row_plugin = $this->getPlugin('row'); $row_plugin = $this->getPlugin('row');
if ($row_plugin) { if ($row_plugin) {
$funcs[] = $this->optionLink(t('Row style output'), 'analyze-theme-row') . ': ' . $this->formatThemes($row_plugin->themeFunctions()); $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) { ...@@ -1863,14 +1845,7 @@ public function buildOptionsForm(&$form, &$form_state) {
} }
else { else {
$output .= '<p>' . t('This is the default theme template used for this display.') . '</p>'; $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>'; $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>';
}
} }
$form['analysis'] = array( $form['analysis'] = array(
...@@ -1890,14 +1865,7 @@ public function buildOptionsForm(&$form, &$form_state) { ...@@ -1890,14 +1865,7 @@ public function buildOptionsForm(&$form, &$form_state) {
} }
else { else {
$output .= '<p>' . t('This is the default theme template used for this style.') . '</p>'; $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>'; $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>';
}
} }
$form['analysis'] = array( $form['analysis'] = array(
...@@ -1917,14 +1885,7 @@ public function buildOptionsForm(&$form, &$form_state) { ...@@ -1917,14 +1885,7 @@ public function buildOptionsForm(&$form, &$form_state) {
} }
else { else {
$output .= '<p>' . t('This is the default theme template used for this row style.') . '</p>'; $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>'; $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>';
}
} }
$form['analysis'] = array( $form['analysis'] = array(
...@@ -1941,7 +1902,7 @@ public function buildOptionsForm(&$form, &$form_state) { ...@@ -1941,7 +1902,7 @@ public function buildOptionsForm(&$form, &$form_state) {
// Field templates aren't registered the normal way...and they're always // Field templates aren't registered the normal way...and they're always
// this one, anyhow. // 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( $form['analysis'] = array(
'#markup' => '<div class="form-item">' . $output . '</div>', '#markup' => '<div class="form-item">' . $output . '</div>',
......
...@@ -95,13 +95,11 @@ function views_config_import_create($name, $new_config, $old_config) { ...@@ -95,13 +95,11 @@ function views_config_import_create($name, $new_config, $old_config) {
* Implement hook_theme(). Register views theming functions. * Implement hook_theme(). Register views theming functions.
*/ */
function views_theme($existing, $type, $theme, $path) { function views_theme($existing, $type, $theme, $path) {
$path = drupal_get_path('module', 'views'); module_load_include('inc', 'views', 'views.theme');
module_load_include('inc', 'views', 'theme/theme');
// Some quasi clever array merging here. // Some quasi clever array merging here.
$base = array( $base = array(
'file' => 'theme.inc', 'file' => 'views.theme.inc',
'path' => $path . '/theme',
); );
// Our extra version of pager from pager.inc // Our extra version of pager from pager.inc
...@@ -139,41 +137,38 @@ function views_theme($existing, $type, $theme, $path) { ...@@ -139,41 +137,38 @@ function views_theme($existing, $type, $theme, $path) {
// Register theme functions for all style plugins // Register theme functions for all style plugins
foreach ($plugins as $type => $info) { foreach ($plugins as $type => $info) {
foreach ($info as $plugin => $def) { foreach ($info as $plugin => $def) {
if (isset($def['theme']) && (!isset($def['register theme']) || !empty($def['register theme']))) { // 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;
}
$hooks[$def['theme']] = array( $hooks[$def['theme']] = array(
'pattern' => $def['theme'] . '__', 'pattern' => $def['theme'] . '__',
'file' => $def['theme file'],
'path' => $def['theme path'],
'variables' => $variables[$type], 'variables' => $variables[$type],
); );
$include = DRUPAL_ROOT . '/' . $def['theme path'] . '/' . $def['theme file']; if ($def['module'] == 'views') {
if (file_exists($include)) { $def['theme_file'] = 'views.theme.inc';
require_once $include;
} }
elseif (isset($def['theme_file'])) {
if (!function_exists('theme_' . $def['theme'])) { $def['theme_path'] = drupal_get_path('module', $def['module']);
$hooks[$def['theme']]['template'] = drupal_clean_css_identifier($def['theme']);
} }
if (isset($def['theme_path'])) {
$hooks[$def['theme']]['path'] = $def['theme_path'];
} }
if (isset($def['additional themes'])) { if (isset($def['theme_file'])) {
foreach ($def['additional themes'] as $theme => $theme_type) { $hooks[$def['theme']]['file'] = $def['theme_file'];
if (empty($theme_type)) {
$theme = $theme_type;
$theme_type = $type;
} }
if (isset($def['theme_path']) && isset($def['theme_file'])) {
$hooks[$theme] = array( $include = DRUPAL_ROOT . '/' . $def['theme_path'] . '/' . $def['theme_file'];
'pattern' => $theme . '__', if (is_file($include)) {
'file' => $def['theme file'], require_once $include;
'path' => $def['theme path'],
'variables' => $variables[$theme_type],
);
if (!function_exists('theme_' . $theme)) {
$hooks[$theme]['template'] = drupal_clean_css_identifier($theme);
} }
} }
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 ...@@ -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. * Build a list of theme function names for use most everywhere.
*/ */
function views_theme_functions($hook, ViewExecutable $view, $display = NULL) { 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); return _views_theme_functions($hook, $view, $display);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment