annotate core/modules/views_ui/views_ui.theme.inc @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /**
Chris@0 4 * @file
Chris@0 5 * Preprocessors and theme functions for the Views UI.
Chris@0 6 */
Chris@0 7
Chris@17 8 use Drupal\Component\Render\FormattableMarkup;
Chris@0 9 use Drupal\Core\Form\FormState;
Chris@0 10 use Drupal\Core\Render\Element;
Chris@0 11 use Drupal\Core\Render\Element\Checkboxes;
Chris@0 12 use Drupal\Core\Render\Element\Radios;
Chris@0 13 use Drupal\Core\Url;
Chris@0 14 use Drupal\Core\Template\Attribute;
Chris@0 15
Chris@0 16 /**
Chris@0 17 * Prepares variables for Views UI display tab setting templates.
Chris@0 18 *
Chris@0 19 * Default template: views-ui-display-tab-setting.html.twig.
Chris@0 20 *
Chris@0 21 * @param array $variables
Chris@0 22 * An associative array containing:
Chris@0 23 * - link: The setting's primary link.
Chris@0 24 * - settings_links: An array of links for this setting.
Chris@0 25 * - defaulted: A boolean indicating the setting is in its default state.
Chris@0 26 * - overridden: A boolean indicating the setting has been overridden from
Chris@0 27 * the default.
Chris@0 28 * - description: The setting's description.
Chris@0 29 * - description_separator: A boolean indicating a separator colon should be
Chris@0 30 * appended to the setting's description.
Chris@0 31 */
Chris@0 32 function template_preprocess_views_ui_display_tab_setting(&$variables) {
Chris@0 33 // Put the primary link to the left side.
Chris@0 34 array_unshift($variables['settings_links'], $variables['link']);
Chris@0 35
Chris@0 36 if (!empty($variables['overridden'])) {
Chris@0 37 $variables['attributes']['title'][] = t('Overridden');
Chris@0 38 }
Chris@0 39
Chris@0 40 // Append a colon to the description, if requested.
Chris@0 41 if ($variables['description'] && $variables['description_separator']) {
Chris@0 42 $variables['description'] .= t(':');
Chris@0 43 }
Chris@0 44 }
Chris@0 45
Chris@0 46 /**
Chris@0 47 * Prepares variables for Views UI view listing templates.
Chris@0 48 *
Chris@0 49 * Default template: views-ui-view-listing-table.html.twig.
Chris@0 50 *
Chris@0 51 * @param array $variables
Chris@0 52 * An associative array containing:
Chris@0 53 * - headers: An associative array containing the headers for the view
Chris@0 54 * listing table.
Chris@0 55 * - rows: An associative array containing the rows data for the view
Chris@0 56 * listing table.
Chris@0 57 */
Chris@0 58 function template_preprocess_views_ui_views_listing_table(&$variables) {
Chris@0 59 // Convert the attributes to valid attribute objects.
Chris@0 60 foreach ($variables['headers'] as $key => $header) {
Chris@0 61 $variables['headers'][$key]['attributes'] = new Attribute($header['#attributes']);
Chris@0 62 }
Chris@0 63
Chris@0 64 if (!empty($variables['rows'])) {
Chris@0 65 foreach ($variables['rows'] as $key => $row) {
Chris@0 66 $variables['rows'][$key]['attributes'] = new Attribute($row['#attributes']);
Chris@0 67 }
Chris@0 68 }
Chris@0 69 }
Chris@0 70
Chris@0 71 /**
Chris@0 72 * Prepares variables for Views UI display tab bucket templates.
Chris@0 73 *
Chris@0 74 * Default template: views-ui-display-tab-bucket.html.twig.
Chris@0 75 *
Chris@0 76 * @param array $variables
Chris@0 77 * An associative array containing:
Chris@0 78 * - element: An associative array containing the properties of the element.
Chris@0 79 * Properties used: #name, #overridden, #children, #title, #actions.
Chris@0 80 */
Chris@0 81 function template_preprocess_views_ui_display_tab_bucket(&$variables) {
Chris@0 82 $element = $variables['element'];
Chris@0 83
Chris@0 84 if (!empty($element['#overridden'])) {
Chris@0 85 $variables['attributes']['title'][] = t('Overridden');
Chris@0 86 }
Chris@0 87
Chris@0 88 $variables['name'] = isset($element['#name']) ? $element['#name'] : NULL;
Chris@0 89 $variables['overridden'] = isset($element['#overridden']) ? $element['#overridden'] : NULL;
Chris@0 90 $variables['content'] = $element['#children'];
Chris@0 91 $variables['title'] = $element['#title'];
Chris@0 92 $variables['actions'] = !empty($element['#actions']) ? $element['#actions'] : [];
Chris@0 93 }
Chris@0 94
Chris@0 95 /**
Chris@0 96 * Prepares variables for Views UI build group filter form templates.
Chris@0 97 *
Chris@0 98 * Default template: views-ui-build-group-filter-form.html.twig.
Chris@0 99 *
Chris@0 100 * @param array $variables
Chris@0 101 * An associative array containing:
Chris@0 102 * - form: A render element representing the form.
Chris@0 103 */
Chris@0 104 function template_preprocess_views_ui_build_group_filter_form(&$variables) {
Chris@0 105 $form = $variables['form'];
Chris@0 106
Chris@0 107 // Prepare table of options.
Chris@0 108 $header = [
Chris@0 109 t('Default'),
Chris@0 110 t('Weight'),
Chris@0 111 t('Label'),
Chris@0 112 t('Operator'),
Chris@0 113 t('Value'),
Chris@0 114 t('Operations'),
Chris@0 115 ];
Chris@0 116
Chris@0 117 // Prepare default selectors.
Chris@0 118 $form_state = new FormState();
Chris@0 119 $form['default_group'] = Radios::processRadios($form['default_group'], $form_state, $form);
Chris@0 120 $form['default_group_multiple'] = Checkboxes::processCheckboxes($form['default_group_multiple'], $form_state, $form);
Chris@0 121 $form['default_group']['All']['#title'] = '';
Chris@0 122
Chris@0 123 $rows[] = [
Chris@0 124 ['data' => $form['default_group']['All']],
Chris@0 125 '',
Chris@0 126 [
Chris@0 127 'data' => \Drupal::config('views.settings')->get('ui.exposed_filter_any_label') == 'old_any' ? t('&lt;Any&gt;') : t('- Any -'),
Chris@0 128 'colspan' => 4,
Chris@0 129 'class' => ['class' => 'any-default-radios-row'],
Chris@0 130 ],
Chris@0 131 ];
Chris@0 132 // Remove the 'All' default_group form element because it's added to the
Chris@0 133 // table row.
Chris@0 134 unset($variables['form']['default_group']['All']);
Chris@0 135
Chris@0 136 foreach (Element::children($form['group_items']) as $group_id) {
Chris@0 137 $form['group_items'][$group_id]['value']['#title'] = '';
Chris@0 138 $default = [
Chris@0 139 $form['default_group'][$group_id],
Chris@0 140 $form['default_group_multiple'][$group_id],
Chris@0 141 ];
Chris@0 142 // Remove these fields from the form since they are moved into the table.
Chris@0 143 unset($variables['form']['default_group'][$group_id]);
Chris@0 144 unset($variables['form']['default_group_multiple'][$group_id]);
Chris@0 145
Chris@0 146 $link = [
Chris@0 147 '#type' => 'link',
Chris@0 148 '#url' => Url::fromRoute('<none>', [], [
Chris@0 149 'attributes' => [
Chris@0 150 'id' => 'views-remove-link-' . $group_id,
Chris@0 151 'class' => [
Chris@0 152 'views-hidden',
Chris@0 153 'views-button-remove',
Chris@0 154 'views-groups-remove-link',
Chris@0 155 'views-remove-link',
Chris@0 156 ],
Chris@0 157 'alt' => t('Remove this item'),
Chris@0 158 'title' => t('Remove this item'),
Chris@0 159 ],
Chris@0 160 ]),
Chris@17 161 '#title' => new FormattableMarkup('<span>@text</span>', ['@text' => t('Remove')]),
Chris@0 162 ];
Chris@0 163 $remove = [$form['group_items'][$group_id]['remove'], $link];
Chris@0 164 $data = [
Chris@0 165 'default' => ['data' => $default],
Chris@0 166 'weight' => ['data' => $form['group_items'][$group_id]['weight']],
Chris@0 167 'title' => ['data' => $form['group_items'][$group_id]['title']],
Chris@0 168 'operator' => ['data' => $form['group_items'][$group_id]['operator']],
Chris@0 169 'value' => ['data' => $form['group_items'][$group_id]['value']],
Chris@0 170 'remove' => ['data' => $remove],
Chris@0 171 ];
Chris@0 172 $rows[] = ['data' => $data, 'id' => 'views-row-' . $group_id, 'class' => ['draggable']];
Chris@0 173 }
Chris@0 174 $variables['table'] = [
Chris@0 175 '#type' => 'table',
Chris@0 176 '#header' => $header,
Chris@0 177 '#rows' => $rows,
Chris@0 178 '#attributes' => [
Chris@0 179 'class' => ['views-filter-groups'],
Chris@0 180 'id' => 'views-filter-groups',
Chris@0 181 ],
Chris@0 182 '#tabledrag' => [
Chris@0 183 [
Chris@0 184 'action' => 'order',
Chris@0 185 'relationship' => 'sibling',
Chris@0 186 'group' => 'weight',
Chris@17 187 ],
Chris@0 188 ],
Chris@0 189 ];
Chris@0 190
Chris@0 191 // Hide fields used in table.
Chris@0 192 unset($variables['form']['group_items']);
Chris@0 193 }
Chris@0 194
Chris@0 195 /**
Chris@0 196 * Prepares variables for Views UI rearrange filter form templates.
Chris@0 197 *
Chris@0 198 * Default template: views-ui-rearrange-filter-form.html.twig.
Chris@0 199 *
Chris@0 200 * @param array $variables
Chris@0 201 * An associative array containing:
Chris@0 202 * - form: A render element representing the form.
Chris@0 203 */
Chris@0 204 function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
Chris@0 205 $form = &$variables['form'];
Chris@0 206 $rows = $ungroupable_rows = [];
Chris@0 207 // Enable grouping only if > 1 group.
Chris@0 208 $variables['grouping'] = count(array_keys($form['#group_options'])) > 1;
Chris@0 209
Chris@0 210 foreach ($form['#group_renders'] as $group_id => $contents) {
Chris@0 211 // Header row for the group.
Chris@0 212 if ($group_id !== 'ungroupable') {
Chris@0 213 // Set up tabledrag so that it changes the group dropdown when rows are
Chris@0 214 // dragged between groups.
Chris@0 215 $options = [
Chris@0 216 'table_id' => 'views-rearrange-filters',
Chris@0 217 'action' => 'match',
Chris@0 218 'relationship' => 'sibling',
Chris@0 219 'group' => 'views-group-select',
Chris@0 220 'subgroup' => 'views-group-select-' . $group_id,
Chris@0 221 ];
Chris@0 222 drupal_attach_tabledrag($form['override'], $options);
Chris@0 223
Chris@0 224 // Title row, spanning all columns.
Chris@0 225 $row = [];
Chris@0 226 // Add a cell to the first row, containing the group operator.
Chris@0 227 $row[] = [
Chris@0 228 'class' => ['group', 'group-operator', 'container-inline'],
Chris@0 229 'data' => $form['filter_groups']['groups'][$group_id],
Chris@0 230 'rowspan' => max([2, count($contents) + 1]),
Chris@0 231 ];
Chris@0 232 // Title.
Chris@0 233 $row[] = [
Chris@0 234 'class' => ['group', 'group-title'],
Chris@0 235 'data' => [
Chris@0 236 '#prefix' => '<span>',
Chris@0 237 '#markup' => $form['#group_options'][$group_id],
Chris@0 238 '#suffix' => '</span>',
Chris@0 239 ],
Chris@0 240 'colspan' => 4,
Chris@0 241 ];
Chris@0 242 $rows[] = [
Chris@0 243 'class' => ['views-group-title'],
Chris@0 244 'data' => $row,
Chris@0 245 'id' => 'views-group-title-' . $group_id,
Chris@0 246 ];
Chris@0 247
Chris@0 248 // Row which will only appear if the group has nothing in it.
Chris@0 249 $row = [];
Chris@0 250 $class = 'group-' . (count($contents) ? 'populated' : 'empty');
Chris@0 251 $instructions = '<span>' . t('No filters have been added.') . '</span> <span class="js-only">' . t('Drag to add filters.') . '</span>';
Chris@0 252 // When JavaScript is enabled, the button for removing the group (if it's
Chris@0 253 // present) should be hidden, since it will be replaced by a link on the
Chris@0 254 // client side.
Chris@0 255 if (!empty($form['remove_groups'][$group_id]['#type']) && $form['remove_groups'][$group_id]['#type'] == 'submit') {
Chris@0 256 $form['remove_groups'][$group_id]['#attributes']['class'][] = 'js-hide';
Chris@0 257 }
Chris@0 258 $row[] = [
Chris@0 259 'colspan' => 5,
Chris@0 260 'data' => [
Chris@0 261 ['#markup' => $instructions],
Chris@0 262 $form['remove_groups'][$group_id],
Chris@0 263 ],
Chris@0 264 ];
Chris@0 265 $rows[] = [
Chris@0 266 'class' => [
Chris@0 267 'group-message',
Chris@0 268 'group-' . $group_id . '-message',
Chris@0 269 $class,
Chris@0 270 ],
Chris@0 271 'data' => $row,
Chris@0 272 'id' => 'views-group-' . $group_id,
Chris@0 273 ];
Chris@0 274 }
Chris@0 275
Chris@0 276 foreach ($contents as $id) {
Chris@0 277 if (isset($form['filters'][$id]['name'])) {
Chris@0 278 $row = [];
Chris@0 279 $row[]['data'] = $form['filters'][$id]['name'];
Chris@0 280 $form['filters'][$id]['weight']['#attributes']['class'] = ['weight'];
Chris@0 281 $row[]['data'] = $form['filters'][$id]['weight'];
Chris@0 282 $form['filters'][$id]['group']['#attributes']['class'] = ['views-group-select views-group-select-' . $group_id];
Chris@0 283 $row[]['data'] = $form['filters'][$id]['group'];
Chris@0 284 $form['filters'][$id]['removed']['#attributes']['class'][] = 'js-hide';
Chris@0 285
Chris@0 286 $remove_link = [
Chris@0 287 '#type' => 'link',
Chris@0 288 '#url' => Url::fromRoute('<none>'),
Chris@17 289 '#title' => new FormattableMarkup('<span>@text</span>', ['@text' => t('Remove')]),
Chris@0 290 '#weight' => '1',
Chris@0 291 '#options' => [
Chris@0 292 'attributes' => [
Chris@0 293 'id' => 'views-remove-link-' . $id,
Chris@0 294 'class' => [
Chris@0 295 'views-hidden',
Chris@0 296 'views-button-remove',
Chris@0 297 'views-groups-remove-link',
Chris@0 298 'views-remove-link',
Chris@0 299 ],
Chris@0 300 'alt' => t('Remove this item'),
Chris@0 301 'title' => t('Remove this item'),
Chris@0 302 ],
Chris@0 303 ],
Chris@0 304 ];
Chris@0 305 $row[]['data'] = [
Chris@0 306 $form['filters'][$id]['removed'],
Chris@0 307 $remove_link,
Chris@0 308 ];
Chris@0 309
Chris@0 310 $row = [
Chris@0 311 'data' => $row,
Chris@0 312 'class' => ['draggable'],
Chris@0 313 'id' => 'views-row-' . $id,
Chris@0 314 ];
Chris@0 315
Chris@0 316 if ($group_id !== 'ungroupable') {
Chris@0 317 $rows[] = $row;
Chris@0 318 }
Chris@0 319 else {
Chris@0 320 $ungroupable_rows[] = $row;
Chris@0 321 }
Chris@0 322 }
Chris@0 323 }
Chris@0 324 }
Chris@0 325
Chris@0 326 if (!$variables['grouping']) {
Chris@0 327 $form['filter_groups']['groups'][0]['#title'] = t('Operator');
Chris@0 328 }
Chris@0 329
Chris@0 330 if (!empty($ungroupable_rows)) {
Chris@0 331 $header = [
Chris@0 332 t('Ungroupable filters'),
Chris@0 333 t('Weight'),
Chris@0 334 [
Chris@0 335 'data' => t('Group'),
Chris@0 336 'class' => ['views-hide-label'],
Chris@0 337 ],
Chris@0 338 [
Chris@0 339 'data' => t('Remove'),
Chris@0 340 'class' => ['views-hide-label'],
Chris@0 341 ],
Chris@0 342 ];
Chris@0 343 $variables['ungroupable_table'] = [
Chris@0 344 '#type' => 'table',
Chris@0 345 '#header' => $header,
Chris@0 346 '#rows' => $ungroupable_rows,
Chris@0 347 '#attributes' => [
Chris@0 348 'id' => 'views-rearrange-filters-ungroupable',
Chris@0 349 'class' => ['arrange'],
Chris@0 350 ],
Chris@0 351 '#tabledrag' => [
Chris@0 352 [
Chris@0 353 'action' => 'order',
Chris@0 354 'relationship' => 'sibling',
Chris@0 355 'group' => 'weight',
Chris@17 356 ],
Chris@0 357 ],
Chris@0 358 ];
Chris@0 359 }
Chris@0 360
Chris@0 361 if (empty($rows)) {
Chris@0 362 $rows[] = [['data' => t('No fields available.'), 'colspan' => '2']];
Chris@0 363 }
Chris@0 364
Chris@0 365 // Set up tabledrag so that the weights are changed when rows are dragged.
Chris@0 366 $variables['table'] = [
Chris@0 367 '#type' => 'table',
Chris@0 368 '#rows' => $rows,
Chris@0 369 '#attributes' => [
Chris@0 370 'id' => 'views-rearrange-filters',
Chris@0 371 'class' => ['arrange'],
Chris@0 372 ],
Chris@0 373 '#tabledrag' => [
Chris@0 374 [
Chris@0 375 'action' => 'order',
Chris@0 376 'relationship' => 'sibling',
Chris@0 377 'group' => 'weight',
Chris@0 378 ],
Chris@0 379 ],
Chris@0 380 ];
Chris@0 381
Chris@0 382 // When JavaScript is enabled, the button for adding a new group should be
Chris@0 383 // hidden, since it will be replaced by a link on the client side.
Chris@0 384 $form['actions']['add_group']['#attributes']['class'][] = 'js-hide';
Chris@0 385
Chris@0 386 }
Chris@0 387
Chris@0 388 /**
Chris@0 389 * Prepares variables for style plugin table templates.
Chris@0 390 *
Chris@0 391 * Default template: views-ui-style-plugin-table.html.twig.
Chris@0 392 *
Chris@0 393 * @param array $variables
Chris@0 394 * An associative array containing:
Chris@0 395 * - form: A render element representing the form.
Chris@0 396 */
Chris@0 397 function template_preprocess_views_ui_style_plugin_table(&$variables) {
Chris@0 398 $form = $variables['form'];
Chris@0 399
Chris@0 400 $header = [
Chris@0 401 t('Field'),
Chris@0 402 t('Column'),
Chris@0 403 t('Align'),
Chris@0 404 t('Separator'),
Chris@0 405 [
Chris@0 406 'data' => t('Sortable'),
Chris@0 407 'align' => 'center',
Chris@0 408 ],
Chris@0 409 [
Chris@0 410 'data' => t('Default order'),
Chris@0 411 'align' => 'center',
Chris@0 412 ],
Chris@0 413 [
Chris@0 414 'data' => t('Default sort'),
Chris@0 415 'align' => 'center',
Chris@0 416 ],
Chris@0 417 [
Chris@0 418 'data' => t('Hide empty column'),
Chris@0 419 'align' => 'center',
Chris@0 420 ],
Chris@0 421 [
Chris@0 422 'data' => t('Responsive'),
Chris@0 423 'align' => 'center',
Chris@0 424 ],
Chris@0 425 ];
Chris@0 426 $rows = [];
Chris@0 427 foreach (Element::children($form['columns']) as $id) {
Chris@0 428 $row = [];
Chris@0 429 $row[]['data'] = $form['info'][$id]['name'];
Chris@0 430 $row[]['data'] = $form['columns'][$id];
Chris@0 431 $row[]['data'] = $form['info'][$id]['align'];
Chris@0 432 $row[]['data'] = $form['info'][$id]['separator'];
Chris@0 433
Chris@0 434 if (!empty($form['info'][$id]['sortable'])) {
Chris@0 435 $row[] = [
Chris@0 436 'data' => $form['info'][$id]['sortable'],
Chris@0 437 'align' => 'center',
Chris@0 438 ];
Chris@0 439 $row[] = [
Chris@0 440 'data' => $form['info'][$id]['default_sort_order'],
Chris@0 441 'align' => 'center',
Chris@0 442 ];
Chris@0 443 $row[] = [
Chris@0 444 'data' => $form['default'][$id],
Chris@0 445 'align' => 'center',
Chris@0 446 ];
Chris@0 447 }
Chris@0 448 else {
Chris@0 449 $row[] = '';
Chris@0 450 $row[] = '';
Chris@0 451 $row[] = '';
Chris@0 452 }
Chris@0 453 $row[] = [
Chris@0 454 'data' => $form['info'][$id]['empty_column'],
Chris@0 455 'align' => 'center',
Chris@0 456 ];
Chris@0 457 $row[] = [
Chris@0 458 'data' => $form['info'][$id]['responsive'],
Chris@0 459 'align' => 'center',
Chris@0 460 ];
Chris@0 461 $rows[] = $row;
Chris@0 462 }
Chris@0 463
Chris@0 464 // Add the special 'None' row.
Chris@0 465 $rows[] = [['data' => t('None'), 'colspan' => 6], ['align' => 'center', 'data' => $form['default'][-1]], ['colspan' => 2]];
Chris@0 466
Chris@0 467 // Unset elements from the form array that are used to build the table so that
Chris@0 468 // they are not rendered twice.
Chris@0 469 unset($form['default']);
Chris@0 470 unset($form['info']);
Chris@0 471 unset($form['columns']);
Chris@0 472
Chris@0 473 $variables['table'] = [
Chris@0 474 '#type' => 'table',
Chris@0 475 '#theme' => 'table__views_ui_style_plugin_table',
Chris@0 476 '#header' => $header,
Chris@0 477 '#rows' => $rows,
Chris@0 478 ];
Chris@0 479 $variables['form'] = $form;
Chris@0 480 }
Chris@0 481
Chris@0 482 /**
Chris@0 483 * Prepares variables for views UI view preview section templates.
Chris@0 484 *
Chris@0 485 * Default template: views-ui-view-preview-section.html.twig.
Chris@0 486 *
Chris@0 487 * @param array $variables
Chris@0 488 * An associative array containing:
Chris@0 489 * - view: The view object.
Chris@0 490 * - section: The section name of a View (e.g. title, rows or pager).
Chris@0 491 */
Chris@0 492 function template_preprocess_views_ui_view_preview_section(&$variables) {
Chris@0 493 switch ($variables['section']) {
Chris@0 494 case 'title':
Chris@0 495 $variables['title'] = t('Title');
Chris@0 496 $links = views_ui_view_preview_section_display_category_links($variables['view'], 'title', $variables['title']);
Chris@0 497 break;
Chris@0 498 case 'header':
Chris@0 499 $variables['title'] = t('Header');
Chris@0 500 $links = views_ui_view_preview_section_handler_links($variables['view'], $variables['section']);
Chris@0 501 break;
Chris@0 502 case 'empty':
Chris@0 503 $variables['title'] = t('No results behavior');
Chris@0 504 $links = views_ui_view_preview_section_handler_links($variables['view'], $variables['section']);
Chris@0 505 break;
Chris@0 506 case 'exposed':
Chris@0 507 // @todo Sorts can be exposed too, so we may need a better title.
Chris@0 508 $variables['title'] = t('Exposed Filters');
Chris@0 509 $links = views_ui_view_preview_section_display_category_links($variables['view'], 'exposed_form_options', $variables['title']);
Chris@0 510 break;
Chris@0 511 case 'rows':
Chris@0 512 // @todo The title needs to depend on what is being viewed.
Chris@0 513 $variables['title'] = t('Content');
Chris@0 514 $links = views_ui_view_preview_section_rows_links($variables['view']);
Chris@0 515 break;
Chris@0 516 case 'pager':
Chris@0 517 $variables['title'] = t('Pager');
Chris@0 518 $links = views_ui_view_preview_section_display_category_links($variables['view'], 'pager_options', $variables['title']);
Chris@0 519 break;
Chris@0 520 case 'more':
Chris@0 521 $variables['title'] = t('More');
Chris@0 522 $links = views_ui_view_preview_section_display_category_links($variables['view'], 'use_more', $variables['title']);
Chris@0 523 break;
Chris@0 524 case 'footer':
Chris@0 525 $variables['title'] = t('Footer');
Chris@0 526 $links = views_ui_view_preview_section_handler_links($variables['view'], $variables['section']);
Chris@0 527 break;
Chris@0 528 case 'attachment_before':
Chris@0 529 // @todo: Add links to the attachment configuration page.
Chris@0 530 $variables['title'] = t('Attachment before');
Chris@0 531 break;
Chris@0 532 case 'attachment_after':
Chris@0 533 // @todo: Add links to the attachment configuration page.
Chris@0 534 $variables['title'] = t('Attachment after');
Chris@0 535 break;
Chris@0 536 }
Chris@0 537
Chris@0 538 if (isset($links)) {
Chris@0 539 $build = [
Chris@0 540 '#theme' => 'links__contextual',
Chris@0 541 '#links' => $links,
Chris@0 542 '#attributes' => ['class' => ['contextual-links']],
Chris@0 543 '#attached' => [
Chris@0 544 'library' => ['contextual/drupal.contextual-links'],
Chris@0 545 ],
Chris@0 546 ];
Chris@0 547 $variables['links'] = $build;
Chris@0 548 }
Chris@0 549 }