From 863b346364a725218d6d2310d438d720c219eae7 Mon Sep 17 00:00:00 2001 From: Tim Plunkett <git@plnktt.com> Date: Mon, 20 Aug 2012 17:43:44 +0200 Subject: [PATCH] Issue #1741172 by tim.plunkett: Remove as much CTools code as possible, and document the parts left to remove. --- drush/views.drush.inc | 1 + includes/admin.inc | 10 +--------- .../Plugin/views/filter/FilterPluginBase.php | 2 ++ .../Plugin/views/wizard/WizardPluginBase.php | 3 --- lib/Drupal/views/ViewsDbObject.php | 1 + lib/Views/field/Plugin/views/field/Field.php | 1 + .../Plugin/views/argument_default/Tid.php | 1 - views.module | 18 ++++++++++++------ views_ui.module | 7 ++----- 9 files changed, 20 insertions(+), 24 deletions(-) diff --git a/drush/views.drush.inc b/drush/views.drush.inc index 7d9206fef960..93a0b4265c42 100644 --- a/drush/views.drush.inc +++ b/drush/views.drush.inc @@ -220,6 +220,7 @@ function views_revert_view($view) { // Revert the view. $view->delete(); // Clear its cache. + // @todo Convert this: http://drupal.org/node/1658068. ctools_include('object-cache'); ctools_object_cache_clear('view', $view->name); // Give feedback. diff --git a/includes/admin.inc b/includes/admin.inc index 6dff0ba88b41..d0bb7dc42f11 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -303,7 +303,6 @@ function views_ui_add_page() { * Form builder for the "add new view" page. */ function views_ui_add_form($form, &$form_state) { - ctools_include('dependent'); $form['#attached']['js'][] = drupal_get_path('module', 'views_ui') . '/js/views-admin.js'; $form['#attributes']['class'] = array('views-admin'); @@ -971,8 +970,7 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { // - Change $form_state['view'] to $form_state['temporary']['view']. // - Add a #process function to initialize $form_state['temporary']['view'] // on cached form submissions. - // - Update ctools_include() to support cached forms, or else use - // form_load_include(). + // - Use form_load_include(). $form_state['no_cache'] = TRUE; if ($display_id) { @@ -984,8 +982,6 @@ function views_ui_edit_form($form, &$form_state, $view, $display_id = NULL) { $view->fix_missing_relationships(); } - ctools_include('dependent'); - $form['#attached']['js'][] = ctools_attach_js('dependent'); $form['#attached']['js'][] = ctools_attach_js('collapsible-div'); $form['#tree'] = TRUE; @@ -1196,7 +1192,6 @@ function views_ui_preview_form($form, &$form_state, $view, $display_id = 'defaul '#type' => 'submit', '#value' => t('Update preview'), '#attributes' => array('class' => array('arguments-preview', 'ctools-auto-submit-click')), - '#pre_render' => array('ctools_dependent_pre_render'), '#prefix' => '<div id="preview-submit-wrapper">', '#suffix' => '</div>', '#id' => 'preview-submit', @@ -4028,8 +4023,6 @@ function views_ui_add_item_form($form, &$form_state) { ), ); - ctools_add_js('dependent'); - if (!$view->set_display($display_id)) { views_ajax_error(t('Invalid display id @display', array('@display' => $display_id))); } @@ -4137,7 +4130,6 @@ function views_ui_add_item_form($form, &$form_state) { '#theme_wrappers' => array('form_element', 'views_container'), '#attributes' => array('class' => array('container-inline', 'views-add-form-selected')), ); - ctools_include('dependent'); views_ui_standard_form_buttons($form, $form_state, 'views_ui_add_item_form', t('Add and configure @types', array('@types' => $ltitle))); // Remove the default submit function. diff --git a/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php b/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php index b22a3888ad6e..c1991f09c8dd 100644 --- a/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php +++ b/lib/Drupal/views/Plugin/views/filter/FilterPluginBase.php @@ -944,6 +944,8 @@ function build_group_form(&$form, &$form_state) { $row['operator']['#title'] = ''; $this->value_form($row, $form_state); + // @todo: Convert this to #states. + ctools_include('dependent'); // Fix the dependencies to update value forms when operators // changes. This is needed because forms are inside a new form and // their ids changes. Dependencies are used when operator changes diff --git a/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php index 5884c1eccd37..994f48cd0743 100644 --- a/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -87,7 +87,6 @@ function build_form($form, &$form_state) { ':input[name="page[create]"]' => array('checked' => TRUE), ), ), - '#pre_render' => array('ctools_dependent_pre_render'), '#prefix' => '<div><div id="edit-page-wrapper">', '#suffix' => '</div></div>', '#parents' => array('page'), @@ -200,7 +199,6 @@ function build_form($form, &$form_state) { ':input[name="page[feed]"]' => array('checked' => TRUE), ), ), - '#pre_render' => array('ctools_dependent_pre_render'), '#prefix' => '<div id="edit-page-feed-properties-row-plugin-wrapper">', '#suffix' => '</div>', ); @@ -228,7 +226,6 @@ function build_form($form, &$form_state) { ':input[name="block[create]"]' => array('checked' => TRUE), ), ), - '#pre_render' => array('ctools_dependent_pre_render'), '#prefix' => '<div id="edit-block-wrapper">', '#suffix' => '</div>', '#parents' => array('block'), diff --git a/lib/Drupal/views/ViewsDbObject.php b/lib/Drupal/views/ViewsDbObject.php index a04601c35475..ba3a9a0ba002 100644 --- a/lib/Drupal/views/ViewsDbObject.php +++ b/lib/Drupal/views/ViewsDbObject.php @@ -127,6 +127,7 @@ function load_row($data) { * An optional indentation for prettifying nested code. */ function export_row($identifier = NULL, $indent = '') { + // @todo replace with http://drupal.org/node/1741154. ctools_include('export'); if (!$identifier) { diff --git a/lib/Views/field/Plugin/views/field/Field.php b/lib/Views/field/Plugin/views/field/Field.php index 582cb155b2c1..dca12def14f3 100644 --- a/lib/Views/field/Plugin/views/field/Field.php +++ b/lib/Views/field/Plugin/views/field/Field.php @@ -432,6 +432,7 @@ function options_form(&$form, &$form_state) { $settings = $this->options['settings'] + field_info_formatter_settings($format); // Provide an instance array for hook_field_formatter_settings_form(). + // @todo Remove this: http://drupal.org/node/1741128. ctools_include('fields'); $instance = ctools_fields_fake_field_instance($this->definition['field_name'], '_dummy', $formatter, $settings); diff --git a/lib/Views/taxonomy/Plugin/views/argument_default/Tid.php b/lib/Views/taxonomy/Plugin/views/argument_default/Tid.php index 2a8a5b6051ff..d0ebec3f08ad 100644 --- a/lib/Views/taxonomy/Plugin/views/argument_default/Tid.php +++ b/lib/Views/taxonomy/Plugin/views/argument_default/Tid.php @@ -94,7 +94,6 @@ function options_form(&$form, &$form_state) { '#type' => 'radios', '#title' => t('Multiple-value handling'), '#default_value' => $this->options['anyall'], - '#process' => array('form_process_radios', 'ctools_dependent_process'), '#options' => array( ',' => t('Filter to items that share all terms'), '+' => t('Filter to items that share any term'), diff --git a/views.module b/views.module index 6dcc9856f081..61bdf8944739 100644 --- a/views.module +++ b/views.module @@ -103,7 +103,7 @@ function views_api_minimum_version() { */ function views_theme($existing, $type, $theme, $path) { $path = drupal_get_path('module', 'views'); - ctools_include('theme', 'views', 'theme'); + module_load_include('inc', 'views', 'theme/theme'); // Some quasi clever array merging here. $base = array( @@ -1125,7 +1125,7 @@ function &views_get_current_view() { * Include views .inc files as necessary. */ function views_include($file) { - ctools_include($file, 'views'); + module_load_include('inc', 'views', 'includes/' . $file); } /** @@ -1138,6 +1138,8 @@ function views_module_include($api, $reset = FALSE) { unset($cache['views']['views']); } } + + // @todo replace with http://drupal.org/node/1741154. ctools_include('plugins'); return ctools_plugin_api_include('views', $api, views_api_minimum_version(), views_api_version()); } @@ -1152,6 +1154,8 @@ function views_get_module_apis($api = 'views', $reset = FALSE) { unset($cache['views']['views']); } } + + // @todo replace with http://drupal.org/node/1741154. ctools_include('plugins'); return ctools_plugin_api_info('views', $api, views_api_minimum_version(), views_api_version()); } @@ -1175,9 +1179,10 @@ function views_add_js($file) { if (config('views.settings')->get('no_javascript')) { return; } + $path = drupal_get_path('module', 'views'); static $base = TRUE, $ajax = TRUE; if ($base) { - drupal_add_js(drupal_get_path('module', 'views') . "/js/base.js"); + drupal_add_js($path . "/js/base.js"); $base = FALSE; } if ($ajax && in_array($file, array('ajax', 'ajax_view'))) { @@ -1185,7 +1190,7 @@ function views_add_js($file) { drupal_add_library('system', 'jquery.form'); $ajax = FALSE; } - ctools_add_js($file, 'views'); + drupal_add_js($path . "/js/$file.js"); } /** @@ -1528,6 +1533,7 @@ function views_get_applicable_views($type) { * If TRUE, reset the static cache forcing views to be reloaded. */ function views_get_all_views($reset = FALSE) { + // @todo replace with http://drupal.org/node/1741154. ctools_include('export'); return ctools_export_crud_load_all('views_view', $reset); } @@ -1663,6 +1669,7 @@ function views_get_view($name, $reset = FALSE) { } } + // @todo replace with http://drupal.org/node/1741154. ctools_include('export'); $view = ctools_export_crud_load('views_view', $name); if ($view) { @@ -2097,7 +2104,6 @@ function views_exposed_form($form, &$form_state) { if ($view->use_ajax) { drupal_add_library('system', 'jquery.form'); } - ctools_include('dependent'); $exposed_form_plugin = $form_state['exposed_form_plugin']; $exposed_form_plugin->exposed_form_alter($form, $form_state); @@ -2193,7 +2199,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, $view, $display = NULL) { - require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'views') . "/theme/theme.inc"; + module_load_include('inc', 'views', 'theme/theme'); return _views_theme_functions($hook, $view, $display); } diff --git a/views_ui.module b/views_ui.module index ac8ef523e3a0..2a7cdb765036 100644 --- a/views_ui.module +++ b/views_ui.module @@ -290,6 +290,7 @@ function views_ui_edit_page_title($view) { * someone else is already editing the view. */ function views_ui_cache_load($name) { + // @todo Convert this: http://drupal.org/node/1658068. ctools_include('object-cache'); $view = ctools_object_cache_get('view', $name); $original_view = views_get_view($name); @@ -330,6 +331,7 @@ function views_ui_cache_set(&$view) { drupal_set_message(t('Changes cannot be made to a locked view.'), 'error'); return; } + // @todo Convert this: http://drupal.org/node/1658068. ctools_include('object-cache'); $view->changed = TRUE; // let any future object know that this view has changed. @@ -556,7 +558,6 @@ function views_ui_ctools_plugin_directory($module, $plugin) { * An array with information about the requested wizard type. */ function views_ui_get_wizard($wizard_type) { - ctools_include('plugins'); $manager = new ViewsPluginManager('wizard'); $wizard = $manager->getDefinition($wizard_type); // @todo - handle this via an alter hook instead. @@ -568,10 +569,6 @@ function views_ui_get_wizard($wizard_type) { $wizard['base_table'] = $wizard_type; $wizard['title'] = $base_tables[$wizard_type]['title']; } - // The plugin is neither a base table nor an existing wizard. - else { - vpr('Views Wizard: @wizard does not exist. Be sure to implement hook_ctools_plugin_directory.', array('@wizard' => $wizard_type)); - } } return $wizard; } -- GitLab