views_ui.module
Same filename and directory in other branches
File
-
core/
modules/ views_ui/ views_ui.module
View source
<?php
/**
* @file
*/
use Drupal\Core\Url;
use Drupal\views\ViewExecutable;
use Drupal\views_ui\Hook\ViewsUiThemeHooks;
/**
* Returns contextual links for each handler of a certain section.
*
* @todo Bring in relationships.
* @todo Refactor this function to use much stuff of
* views_ui_edit_form_get_bucket.
*
* @param bool $title
* Add a bolded title of this section.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. There is no
* replacement.
*
* @see https://www.drupal.org/node/3535324
*/
function views_ui_view_preview_section_handler_links(ViewExecutable $view, $type, $title = FALSE) : array {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. There is no replacement. See https://www.drupal.org/node/3535324', E_USER_DEPRECATED);
$display = $view->display_handler->display;
$handlers = $view->display_handler
->getHandlers($type);
$links = [];
$types = ViewExecutable::getHandlerTypes();
if ($title) {
$links[$type . '-title'] = [
'title' => $types[$type]['title'],
];
}
foreach ($handlers as $id => $handler) {
$field_name = $handler->adminLabel(TRUE);
$links[$type . '-edit-' . $id] = [
'title' => t('Edit @section', [
'@section' => $field_name,
]),
'url' => Url::fromRoute('views_ui.form_handler', [
'js' => 'nojs',
'view' => $view->storage
->id(),
'display_id' => $display['id'],
'type' => $type,
'id' => $id,
]),
'attributes' => [
'class' => [
'views-ajax-link',
],
],
];
}
$links[$type . '-add'] = [
'title' => t('Add new'),
'url' => Url::fromRoute('views_ui.form_add_handler', [
'js' => 'nojs',
'view' => $view->storage
->id(),
'display_id' => $display['id'],
'type' => $type,
]),
'attributes' => [
'class' => [
'views-ajax-link',
],
],
];
return $links;
}
/**
* Returns a link to editing a certain display setting.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. There is no
* replacement.
*
* @see https://www.drupal.org/node/3535324
*/
function views_ui_view_preview_section_display_category_links(ViewExecutable $view, $type, $title) : array {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. There is no replacement. See https://www.drupal.org/node/3535324', E_USER_DEPRECATED);
$display = $view->display_handler->display;
$links = [
$type . '-edit' => [
'title' => t('Edit @section', [
'@section' => $title,
]),
'url' => Url::fromRoute('views_ui.form_display', [
'js' => 'nojs',
'view' => $view->storage
->id(),
'display_id' => $display['id'],
'type' => $type,
]),
'attributes' => [
'class' => [
'views-ajax-link',
],
],
],
];
return $links;
}
/**
* Returns all contextual links for the main content part of the view.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. There is no
* replacement.
*
* @see https://www.drupal.org/node/3535324
*/
function views_ui_view_preview_section_rows_links(ViewExecutable $view) : array {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. There is no replacement. See https://www.drupal.org/node/3535324', E_USER_DEPRECATED);
$links = [];
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'filter', TRUE));
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'field', TRUE));
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'sort', TRUE));
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'argument', TRUE));
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'relationship', TRUE));
return $links;
}
/**
* Sets a static variable for controlling whether contextual links are rendered.
*
* @see views_ui_contextual_links_view_alter()
*/
function views_ui_contextual_links_suppress($set = NULL) {
$suppress =& drupal_static(__FUNCTION__);
if (isset($set)) {
$suppress = $set;
}
return $suppress;
}
/**
* Increments the views_ui_contextual_links_suppress() static variable.
*
* When this function is added to the #pre_render of an element, and
* 'views_ui_contextual_links_suppress_pop' is added to the #post_render of the
* same element, then all contextual links within the element and its
* descendants are suppressed from being rendered. This is used, for example,
* during a View preview, when it is not desired for nodes in the Views result
* to have contextual links.
*
* @see views_ui_contextual_links_suppress_pop()
*/
function views_ui_contextual_links_suppress_push() : void {
views_ui_contextual_links_suppress((int) views_ui_contextual_links_suppress() + 1);
}
/**
* Decrements the views_ui_contextual_links_suppress() static variable.
*
* @see views_ui_contextual_links_suppress_push()
*/
function views_ui_contextual_links_suppress_pop() : void {
views_ui_contextual_links_suppress((int) views_ui_contextual_links_suppress() - 1);
}
/**
* Prepares variables for Views UI display tab setting templates.
*
* Default template: views-ui-display-tab-setting.html.twig.
*
* @param array $variables
* An associative array containing:
* - link: The setting's primary link.
* - settings_links: An array of links for this setting.
* - defaulted: A boolean indicating the setting is in its default state.
* - overridden: A boolean indicating the setting has been overridden from
* the default.
* - description: The setting's description.
* - description_separator: A boolean indicating a separator colon should be
* appended to the setting's description.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial
* template_preprocess functions are registered directly in hook_theme().
*
* @see https://www.drupal.org/node/3504125
*/
function template_preprocess_views_ui_display_tab_setting(&$variables) : void {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED);
\Drupal::service(ViewsUiThemeHooks::class)->preprocessDisplayTabSetting($variables);
}
/**
* Prepares variables for Views UI view listing templates.
*
* Default template: views-ui-view-listing-table.html.twig.
*
* @param array $variables
* An associative array containing:
* - headers: An associative array containing the headers for the view
* listing table.
* - rows: An associative array containing the rows data for the view
* listing table.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial
* template_preprocess functions are registered directly in hook_theme().
*
* @see https://www.drupal.org/node/3504125
*/
function template_preprocess_views_ui_views_listing_table(&$variables) : void {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED);
\Drupal::service(ViewsUiThemeHooks::class)->preprocessViewsListingTable($variables);
}
/**
* Prepares variables for Views UI display tab bucket templates.
*
* Default template: views-ui-display-tab-bucket.html.twig.
*
* @param array $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #name, #overridden, #children, #title, #actions.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial
* template_preprocess functions are registered directly in hook_theme().
*
* @see https://www.drupal.org/node/3504125
*/
function template_preprocess_views_ui_display_tab_bucket(&$variables) : void {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED);
\Drupal::service(ViewsUiThemeHooks::class)->preprocessDisplayTabBucket($variables);
}
/**
* Prepares variables for Views UI build group filter form templates.
*
* Default template: views-ui-build-group-filter-form.html.twig.
*
* @param array $variables
* An associative array containing:
* - form: A render element representing the form.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial
* template_preprocess functions are registered directly in hook_theme().
*
* @see https://www.drupal.org/node/3504125
*/
function template_preprocess_views_ui_build_group_filter_form(&$variables) : void {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED);
\Drupal::service(ViewsUiThemeHooks::class)->preprocessBuildGroupFilterForm($variables);
}
/**
* Prepares variables for Views UI rearrange filter form templates.
*
* Default template: views-ui-rearrange-filter-form.html.twig.
*
* @param array $variables
* An associative array containing:
* - form: A render element representing the form.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial
* template_preprocess functions are registered directly in hook_theme().
*
* @see https://www.drupal.org/node/3504125
*/
function template_preprocess_views_ui_rearrange_filter_form(&$variables) : void {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED);
\Drupal::service(ViewsUiThemeHooks::class)->preprocessRearrangeFilterForm($variables);
}
/**
* Prepares variables for style plugin table templates.
*
* Default template: views-ui-style-plugin-table.html.twig.
*
* @param array $variables
* An associative array containing:
* - form: A render element representing the form.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial
* template_preprocess functions are registered directly in hook_theme().
*
* @see https://www.drupal.org/node/3504125
*/
function template_preprocess_views_ui_style_plugin_table(&$variables) : void {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED);
\Drupal::service(ViewsUiThemeHooks::class)->preprocessStylePluginTable($variables);
}
/**
* Prepares variables for views UI view preview section templates.
*
* Default template: views-ui-view-preview-section.html.twig.
*
* @param array $variables
* An associative array containing:
* - view: The view object.
* - section: The section name of a View (e.g. title, rows or pager).
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial
* template_preprocess functions are registered directly in hook_theme().
*
* @see https://www.drupal.org/node/3504125
*/
function template_preprocess_views_ui_view_preview_section(&$variables) : void {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED);
\Drupal::service(ViewsUiThemeHooks::class)->preprocessViewPreviewSection($variables);
}
Functions
| Title | Deprecated | Summary |
|---|---|---|
| template_preprocess_views_ui_build_group_filter_form | in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). |
Prepares variables for Views UI build group filter form templates. |
| template_preprocess_views_ui_display_tab_bucket | in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). |
Prepares variables for Views UI display tab bucket templates. |
| template_preprocess_views_ui_display_tab_setting | in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). |
Prepares variables for Views UI display tab setting templates. |
| template_preprocess_views_ui_rearrange_filter_form | in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). |
Prepares variables for Views UI rearrange filter form templates. |
| template_preprocess_views_ui_style_plugin_table | in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). |
Prepares variables for style plugin table templates. |
| template_preprocess_views_ui_views_listing_table | in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). |
Prepares variables for Views UI view listing templates. |
| template_preprocess_views_ui_view_preview_section | in drupal:11.3.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). |
Prepares variables for views UI view preview section templates. |
| views_ui_contextual_links_suppress | Sets a static variable for controlling whether contextual links are rendered. | |
| views_ui_contextual_links_suppress_pop | Decrements the views_ui_contextual_links_suppress() static variable. | |
| views_ui_contextual_links_suppress_push | Increments the views_ui_contextual_links_suppress() static variable. | |
| views_ui_view_preview_section_display_category_links | in drupal:11.3.0 and is removed from drupal:12.0.0. There is no replacement. |
Returns a link to editing a certain display setting. |
| views_ui_view_preview_section_handler_links | in drupal:11.3.0 and is removed from drupal:12.0.0. There is no replacement. |
Returns contextual links for each handler of a certain section. |
| views_ui_view_preview_section_rows_links | in drupal:11.3.0 and is removed from drupal:12.0.0. There is no replacement. |
Returns all contextual links for the main content part of the view. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.