Commit 2809f13d authored by webchick's avatar webchick

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

parent 6f48b043
...@@ -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,42 +137,39 @@ function views_theme($existing, $type, $theme, $path) { ...@@ -139,42 +137,39 @@ 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
$hooks[$def['theme']] = array( // prevent a theme function from being registered automatically.
'pattern' => $def['theme'] . '__', if (!isset($def['theme']) || empty($def['register_theme'])) {
'file' => $def['theme file'], continue;
'path' => $def['theme path'], }
'variables' => $variables[$type],
);
$include = DRUPAL_ROOT . '/' . $def['theme path'] . '/' . $def['theme file']; $hooks[$def['theme']] = array(
if (file_exists($include)) { 'pattern' => $def['theme'] . '__',
require_once $include; 'variables' => $variables[$type],
} );
if (!function_exists('theme_' . $def['theme'])) { if ($def['module'] == 'views') {
$hooks[$def['theme']]['template'] = drupal_clean_css_identifier($def['theme']); $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)) { if (isset($def['theme_path'])) {
$hooks[$theme]['template'] = drupal_clean_css_identifier($theme); $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 ...@@ -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);
} }
......
...@@ -197,55 +197,45 @@ function views_ui_menu() { ...@@ -197,55 +197,45 @@ function views_ui_menu() {
* Implements hook_theme(). * Implements hook_theme().
*/ */
function views_ui_theme() { function views_ui_theme() {
$path = drupal_get_path('module', 'views_ui');
return array( return array(
// edit a view // edit a view
'views_ui_display_tab_setting' => array( 'views_ui_display_tab_setting' => array(
'variables' => array('description' => '', 'link' => '', 'settings_links' => array(), 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => array()), 'variables' => array('description' => '', 'link' => '', 'settings_links' => array(), 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => array()),
'template' => 'views-ui-display-tab-setting', 'template' => 'views-ui-display-tab-setting',
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
'views_ui_display_tab_bucket' => array( 'views_ui_display_tab_bucket' => array(
'render element' => 'element', 'render element' => 'element',
'template' => 'views-ui-display-tab-bucket', 'template' => 'views-ui-display-tab-bucket',
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
'views_ui_edit_item' => array( 'views_ui_edit_item' => array(
'variables' => array('type' => NULL, 'view' => NULL, 'display' => NULL, 'no_fields' => FALSE), 'variables' => array('type' => NULL, 'view' => NULL, 'display' => NULL, 'no_fields' => FALSE),
'template' => 'views-ui-edit-item', 'template' => 'views-ui-edit-item',
'path' => "$path/theme",
), ),
'views_ui_rearrange_form' => array( 'views_ui_rearrange_form' => array(
'render element' => 'form', 'render element' => 'form',
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
'views_ui_rearrange_filter_form' => array( 'views_ui_rearrange_filter_form' => array(
'render element' => 'form', 'render element' => 'form',
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
'views_ui_expose_filter_form' => array( 'views_ui_expose_filter_form' => array(
'render element' => 'form', 'render element' => 'form',
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
// list views // list views
'views_ui_view_info' => array( 'views_ui_view_info' => array(
'variables' => array('view' => NULL, 'base' => NULL), 'variables' => array('view' => NULL, 'base' => NULL),
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
// Group of filters. // Group of filters.
'views_ui_build_group_filter_form' => array( 'views_ui_build_group_filter_form' => array(
'render element' => 'form', 'render element' => 'form',
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
// tab themes // tab themes
...@@ -257,30 +247,26 @@ function views_ui_theme() { ...@@ -257,30 +247,26 @@ function views_ui_theme() {
), ),
'views_ui_reorder_displays_form' => array( 'views_ui_reorder_displays_form' => array(
'render element' => 'form', 'render element' => 'form',
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
// On behalf of a plugin // On behalf of a plugin
'views_ui_style_plugin_table' => array( 'views_ui_style_plugin_table' => array(
'render element' => 'form', 'render element' => 'form',
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
// When previewing a view. // When previewing a view.
'views_ui_view_preview_section' => array( 'views_ui_view_preview_section' => array(
'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''), 'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''),
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
// Generic container wrapper, to use instead of theme_container when an id // Generic container wrapper, to use instead of theme_container when an id
// is not desired. // is not desired.
'views_ui_container' => array( 'views_ui_container' => array(
'render element' => 'element', 'render element' => 'element',
'path' => "$path/theme", 'file' => 'views_ui.theme.inc',
'file' => 'theme.inc',
), ),
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment