function claro_views_ui_display_tab_alter
Same name in other branches
- 9 core/themes/claro/claro.theme \claro_views_ui_display_tab_alter()
- 8.9.x core/themes/claro/claro.theme \claro_views_ui_display_tab_alter()
- 11.x core/themes/claro/claro.theme \claro_views_ui_display_tab_alter()
Implements hook_views_ui_display_tab_alter().
File
-
core/
themes/ claro/ claro.theme, line 797
Code
function claro_views_ui_display_tab_alter(&$element) {
// We process the dropbutton-like element on views edit form's
// display settings top section.
//
// That element should be a regular Dropbutton.
//
// After that the reported issue is fixed and the element is rendered with
// the Dropbutton type, we just have to set it's '#dropbutton_type' to
// 'extrasmall'.
//
// @todo Revisit after https://www.drupal.org/node/3057577 is fixed.
$dummy_dropbutton =& $element['details']['top']['actions'];
if ($dummy_dropbutton) {
$child_keys = Element::children($dummy_dropbutton);
$prefix_regex = '/(<.*class\\s*= *["\']?)([^"\']*)(.*)/i';
$child_count = 0;
foreach ($child_keys as $key) {
if (in_array($key, [
'prefix',
'suffix',
])) {
continue;
}
$nested_child_keys = Element::children($dummy_dropbutton[$key], TRUE);
if (!empty($nested_child_keys)) {
foreach ($nested_child_keys as $nested_key) {
$child_count++;
$prefix = $dummy_dropbutton[$key][$nested_key]['#prefix'];
$dummy_dropbutton[$key][$nested_key]['#prefix'] = preg_replace($prefix_regex, '$1$2 dropbutton__item$3', $prefix);
}
}
else {
$child_count++;
$prefix = $dummy_dropbutton[$key]['#prefix'];
$dummy_dropbutton[$key]['#prefix'] = preg_replace($prefix_regex, '$1$2 dropbutton__item$3', $prefix);
}
}
if (!empty($dummy_dropbutton['prefix']) && !empty($dummy_dropbutton['prefix']['#markup'])) {
$classes = 'dropbutton--extrasmall ';
$classes .= $child_count > 1 ? 'dropbutton--multiple' : 'dropbutton--single';
$prefix = $dummy_dropbutton['prefix']['#markup'];
$dummy_dropbutton['prefix']['#markup'] = preg_replace($prefix_regex, '$1$2 ' . $classes . '$3', $prefix);
}
}
// If the top details have both actions and title, the `actions` weights need
// to be adjusted so the DOM order matches the order of appearance.
if (isset($element['details']['top']['actions'], $element['details']['top']['display_title'])) {
$top =& $element['details']['top'];
$top['actions']['#weight'] = 10;
$top['#attributes']['class'] = array_diff($top['#attributes']['class'], [
'clearfix',
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.