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) {
'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',
);
}
}
}
......@@ -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.
*
......
......@@ -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>',
......
......@@ -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);
}
......
......@@ -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',
),
);
}
......
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