'
', '#weight' => 100, ]; $variables['title_suffix']['shortcut_wrapper'] = [ '#markup' => '
', '#weight' => -99, ]; // Make sure the shortcut link is the first item in title_suffix. $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100; } } /** * Implements hook_preprocess_HOOK() for maintenance-page.html.twig. */ function bartik_preprocess_maintenance_page(&$variables) { // By default, site_name is set to Drupal if no db connection is available // or during site installation. Setting site_name to an empty string makes // the site and update pages look cleaner. // @see template_preprocess_maintenance_page if (!$variables['db_is_active']) { $variables['site_name'] = ''; } // Bartik has custom styling for the maintenance page. $variables['#attached']['library'][] = 'bartik/maintenance_page'; } /** * Implements hook_preprocess_HOOK() for node.html.twig. */ function bartik_preprocess_node(&$variables) { // Remove the "Add new comment" link on teasers or when the comment form is // displayed on the page. if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) { unset($variables['content']['links']['comment']['#links']['comment-add']); } } /** * Implements hook_preprocess_HOOK() for block.html.twig. */ function bartik_preprocess_block(&$variables) { // Add a clearfix class to system branding blocks. if ($variables['plugin_id'] == 'system_branding_block') { $variables['attributes']['class'][] = 'clearfix'; } } /** * Implements hook_preprocess_HOOK() for menu.html.twig. */ function bartik_preprocess_menu(&$variables) { $variables['attributes']['class'][] = 'clearfix'; } /** * Implements hook_theme_suggestions_HOOK_alter() for form templates. */ function bartik_theme_suggestions_form_alter(array &$suggestions, array $variables) { if ($variables['element']['#form_id'] == 'search_block_form') { $suggestions[] = 'form__search_block_form'; } } /** * Implements hook_form_alter(). */ function bartik_form_alter(&$form, FormStateInterface $form_state, $form_id) { // Add classes to the search form. if (in_array($form_id, ['search_block_form', 'search_form'])) { $key = ($form_id == 'search_block_form') ? 'actions' : 'basic'; if (!isset($form[$key]['submit']['#attributes'])) { $form[$key]['submit']['#attributes'] = new Attribute(); } $form[$key]['submit']['#attributes']->addClass('search-form__submit'); } $form_object = $form_state->getFormObject(); // Add class to the Media Library views form. if ($form_object instanceof ViewsForm && strpos($form_object->getBaseFormId(), 'views_form_media_library') === 0) { // The conditional below exists because the media-library-views-form class // is currently added by Classy, but Umami will eventually not use Classy as // a base theme. // @todo remove conditional, keep class addition in // https://drupal.org/node/3110137 // @see https://www.drupal.org/node/3109287 // @see classy_form_alter() if (!isset($form['#attributes']['class']) || !in_array('media-library-views-form', $form['#attributes']['class'])) { $form['#attributes']['class'][] = 'media-library-views-form'; } } } /** * Implements hook_preprocess_links__media_library_menu(). * * This targets the menu of available media types in the media library's modal * dialog. * * @todo Do this in the relevant template once * https://www.drupal.org/project/drupal/issues/3088856 is resolved. */ function bartik_preprocess_links__media_library_menu(array &$variables) { foreach ($variables['links'] as &$link) { // This conditional exists because the media-library-menu__link class is // currently added by Classy, but Bartik will eventually not use Classy as a // base theme. // @todo remove conditional, keep class addition in // https://drupal.org/node/3110137 // @see https://www.drupal.org/node/3109287 // @see classy_preprocess_links__media_library_menu() if (!isset($link['link']['#options']['attributes']['class']) || !in_array('media-library-menu__link', $link['link']['#options']['attributes']['class'])) { $link['link']['#options']['attributes']['class'][] = 'media-library-menu__link'; } } } /** * Implements hook_preprocess_image_widget(). * * @todo Revisit in https://drupal.org/node/3117430 */ function bartik_preprocess_image_widget(&$variables) { if (!empty($variables['element']['fids']['#value'])) { $file = reset($variables['element']['#files']); $variables['data']["file_{$file->id()}"]['filename']['#suffix'] = ' (' . format_size($file->getSize()) . ') '; } }