Chris@0: getPathInfo()); Chris@0: if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) { Chris@0: foreach ($suggestions as $suggestion) { Chris@0: if ($suggestion === 'page-node-edit' || strpos($suggestion, 'page-node-add') !== FALSE) { Chris@0: $variables['attributes']['class'][] = 'node-form-layout'; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_preprocess_HOOK() for menu-local-tasks templates. Chris@0: * Chris@0: * Use preprocess hook to set #attached to child elements Chris@0: * because they will be processed by Twig and drupal_render will Chris@0: * be invoked. Chris@0: */ Chris@0: function seven_preprocess_menu_local_tasks(&$variables) { Chris@0: if (!empty($variables['primary'])) { Chris@0: $variables['primary']['#attached'] = [ Chris@0: 'library' => [ Chris@0: 'seven/drupal.nav-tabs', Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: elseif (!empty($variables['secondary'])) { Chris@0: $variables['secondary']['#attached'] = [ Chris@0: 'library' => [ Chris@0: 'seven/drupal.nav-tabs', Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_preprocess_HOOK() for menu-local-task templates. Chris@0: */ Chris@0: function seven_preprocess_menu_local_task(&$variables) { Chris@0: $variables['attributes']['class'][] = 'tabs__tab'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_preprocess_HOOK() for list of available node type templates. Chris@0: */ Chris@0: function seven_preprocess_node_add_list(&$variables) { Chris@0: if (!empty($variables['content'])) { Chris@0: /** @var \Drupal\node\NodeTypeInterface $type */ Chris@0: foreach ($variables['content'] as $type) { Chris@0: $variables['types'][$type->id()]['label'] = $type->label(); Chris@18: $variables['types'][$type->id()]['url'] = Url::fromRoute('node.add', ['node_type' => $type->id()])->toString(); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_preprocess_HOOK() for block content add list templates. Chris@0: * Chris@0: * Displays the list of available custom block types for creation, adding Chris@0: * separate variables for the label and url. Chris@0: */ Chris@0: function seven_preprocess_block_content_add_list(&$variables) { Chris@0: if (!empty($variables['content'])) { Chris@0: foreach ($variables['content'] as $type) { Chris@0: $variables['types'][$type->id()]['label'] = $type->label(); Chris@0: $options = ['query' => \Drupal::request()->query->all()]; Chris@18: $variables['types'][$type->id()]['url'] = Url::fromRoute('block_content.add_form', ['block_content_type' => $type->id()], $options)->toString(); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_preprocess_block() for block content. Chris@0: * Chris@0: * Disables contextual links for all blocks. Chris@0: */ Chris@0: function seven_preprocess_block(&$variables) { Chris@0: if (isset($variables['title_suffix']['contextual_links'])) { Chris@0: unset($variables['title_suffix']['contextual_links']); Chris@0: unset($variables['elements']['#contextual_links']); Chris@0: Chris@0: $variables['attributes']['class'] = array_diff($variables['attributes']['class'], ['contextual-region']); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_preprocess_HOOK() for block admin page templates. Chris@0: */ Chris@0: function seven_preprocess_admin_block_content(&$variables) { Chris@0: if (!empty($variables['content'])) { Chris@0: foreach ($variables['content'] as $key => $item) { Chris@0: $variables['content'][$key]['url'] = $item['url']->toString(); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_preprocess_HOOK() for menu-local-action templates. Chris@0: */ Chris@0: function seven_preprocess_menu_local_action(array &$variables) { Chris@0: $variables['link']['#options']['attributes']['class'][] = 'button--primary'; Chris@0: $variables['link']['#options']['attributes']['class'][] = 'button--small'; Chris@0: Chris@0: // We require Modernizr's touch test for button styling. Chris@0: $variables['#attached']['library'][] = 'core/modernizr'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_element_info_alter(). Chris@0: */ Chris@0: function seven_element_info_alter(&$type) { Chris@0: // We require Modernizr for button styling. Chris@0: if (isset($type['button'])) { Chris@0: $type['button']['#attached']['library'][] = 'core/modernizr'; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_preprocess_install_page(). Chris@0: */ Chris@0: function seven_preprocess_install_page(&$variables) { Chris@0: // Seven has custom styling for the install page. Chris@0: $variables['#attached']['library'][] = 'seven/install-page'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_preprocess_maintenance_page(). Chris@0: */ Chris@0: function seven_preprocess_maintenance_page(&$variables) { Chris@0: // Seven has custom styling for the maintenance page. Chris@0: $variables['#attached']['library'][] = 'seven/maintenance-page'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_form_BASE_FORM_ID_alter() for \Drupal\node\NodeForm. Chris@0: * Chris@0: * Changes vertical tabs to container. Chris@0: */ Chris@0: function seven_form_node_form_alter(&$form, FormStateInterface $form_state) { Chris@0: $form['#theme'] = ['node_edit_form']; Chris@0: $form['#attached']['library'][] = 'seven/node-form'; Chris@0: Chris@0: $form['advanced']['#type'] = 'container'; Chris@0: $form['meta']['#type'] = 'container'; Chris@0: $form['meta']['#access'] = TRUE; Chris@0: $form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline'; Chris@0: $form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline'; Chris@0: Chris@0: $form['revision_information']['#type'] = 'container'; Chris@0: $form['revision_information']['#group'] = 'meta'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Implements hook_form_BASE_FORM_ID_alter() for \Drupal\media\MediaForm. Chris@0: */ Chris@0: function seven_form_media_form_alter(&$form, FormStateInterface $form_state) { Chris@17: // Only attach CSS from core if this form comes from Media core, and not from Chris@17: // the contrib Media Entity 1.x branch. Chris@17: if (\Drupal::moduleHandler()->moduleExists('media') && $form_state->getFormObject() instanceof MediaForm) { Chris@17: // @todo Revisit after https://www.drupal.org/node/2892304 is in. It Chris@17: // introduces a footer region to these forms which will allow for us to Chris@17: // display a top border over the published checkbox by defining a Chris@17: // media-edit-form.html.twig template the same way node does. Chris@17: $form['#attached']['library'][] = 'seven/media-form'; Chris@17: } Chris@0: } Chris@18: Chris@18: /** Chris@18: * Implements hook_form_FORM_ID_alter() for language_content_settings_form(). Chris@18: */ Chris@18: function seven_form_language_content_settings_form_alter(array &$form, FormStateInterface $form_state) { Chris@18: $form['#attached']['library'][] = 'seven/layout_builder_content_translation_admin'; Chris@18: }