Move into nested docroot
This commit is contained in:
parent
83a0d3a149
commit
c8b70abde9
13405 changed files with 0 additions and 0 deletions
188
web/core/themes/seven/seven.theme
Normal file
188
web/core/themes/seven/seven.theme
Normal file
|
@ -0,0 +1,188 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Functions to support theming in the Seven theme.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for HTML document templates.
|
||||
*/
|
||||
function seven_preprocess_html(&$variables) {
|
||||
// If on a node add or edit page, add a node-layout class.
|
||||
$path_args = explode('/', \Drupal::request()->getPathInfo());
|
||||
if ($suggestions = theme_get_suggestions($path_args, 'page', '-')) {
|
||||
foreach ($suggestions as $suggestion) {
|
||||
if ($suggestion === 'page-node-edit' || strpos($suggestion, 'page-node-add') !== FALSE) {
|
||||
$variables['attributes']['class'][] = 'node-form-layout';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_pre_render_HOOK() for menu-local-tasks templates.
|
||||
*
|
||||
* Use preprocess hook to set #attached to child elements
|
||||
* because they will be processed by Twig and drupal_render will
|
||||
* be invoked.
|
||||
*/
|
||||
function seven_preprocess_menu_local_tasks(&$variables) {
|
||||
if (!empty($variables['primary'])) {
|
||||
$variables['primary']['#attached'] = array(
|
||||
'library' => array(
|
||||
'seven/drupal.nav-tabs',
|
||||
),
|
||||
);
|
||||
}
|
||||
elseif (!empty($variables['secondary'])) {
|
||||
$variables['secondary']['#attached'] = array(
|
||||
'library' => array(
|
||||
'seven/drupal.nav-tabs',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for menu-local-task templates.
|
||||
*/
|
||||
function seven_preprocess_menu_local_task(&$variables) {
|
||||
$variables['attributes']['class'][] = 'tabs__tab';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for list of available node type templates.
|
||||
*/
|
||||
function seven_preprocess_node_add_list(&$variables) {
|
||||
if (!empty($variables['content'])) {
|
||||
/** @var \Drupal\node\NodeTypeInterface $type */
|
||||
foreach ($variables['content'] as $type) {
|
||||
$variables['types'][$type->id()]['label'] = $type->label();
|
||||
$variables['types'][$type->id()]['url'] = \Drupal::url('node.add', array('node_type' => $type->id()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for block content add list templates.
|
||||
*
|
||||
* Displays the list of available custom block types for creation, adding
|
||||
* separate variables for the label and url.
|
||||
*/
|
||||
function seven_preprocess_block_content_add_list(&$variables) {
|
||||
if (!empty($variables['content'])) {
|
||||
foreach ($variables['content'] as $type) {
|
||||
$variables['types'][$type->id()]['label'] = $type->label();
|
||||
$options = array('query' => \Drupal::request()->query->all());
|
||||
$variables['types'][$type->id()]['url'] = \Drupal::url('block_content.add_form', array('block_content_type' => $type->id()), $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_block() for block content.
|
||||
*
|
||||
* Disables contextual links for all blocks.
|
||||
*/
|
||||
function seven_preprocess_block(&$variables) {
|
||||
if (isset($variables['title_suffix']['contextual_links'])) {
|
||||
unset($variables['title_suffix']['contextual_links']);
|
||||
unset($variables['elements']['#contextual_links']);
|
||||
|
||||
$variables['attributes']['class'] = array_diff($variables['attributes']['class'], ['contextual-region']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for block admin page templates.
|
||||
*/
|
||||
function seven_preprocess_admin_block_content(&$variables) {
|
||||
if (!empty($variables['content'])) {
|
||||
foreach ($variables['content'] as $key => $item) {
|
||||
$variables['content'][$key]['url'] = $item['url']->toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for menu-local-action templates.
|
||||
*/
|
||||
function seven_preprocess_menu_local_action(array &$variables) {
|
||||
$variables['link']['#options']['attributes']['class'][] = 'button--primary';
|
||||
$variables['link']['#options']['attributes']['class'][] = 'button--small';
|
||||
|
||||
// We require Modernizr's touch test for button styling.
|
||||
$variables['#attached']['library'][] = 'core/modernizr';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_element_info_alter().
|
||||
*/
|
||||
function seven_element_info_alter(&$type) {
|
||||
// We require Modernizr for button styling.
|
||||
if (isset($type['button'])) {
|
||||
$type['button']['#attached']['library'][] = 'core/modernizr';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_install_page().
|
||||
*/
|
||||
function seven_preprocess_install_page(&$variables) {
|
||||
// Seven has custom styling for the install page.
|
||||
$variables['#attached']['library'][] = 'seven/install-page';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_maintenance_page().
|
||||
*/
|
||||
function seven_preprocess_maintenance_page(&$variables) {
|
||||
// Seven has custom styling for the maintenance page.
|
||||
$variables['#attached']['library'][] = 'seven/maintenance-page';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_BASE_FORM_ID_alter() for \Drupal\node\NodeForm.
|
||||
*
|
||||
* Changes vertical tabs to container and adds meta information.
|
||||
*/
|
||||
function seven_form_node_form_alter(&$form, FormStateInterface $form_state) {
|
||||
/** @var \Drupal\node\NodeInterface $node */
|
||||
$node = $form_state->getFormObject()->getEntity();
|
||||
|
||||
$form['#theme'] = array('node_edit_form');
|
||||
$form['#attached']['library'][] = 'seven/node-form';
|
||||
|
||||
$form['advanced']['#type'] = 'container';
|
||||
$is_new = !$node->isNew() ? format_date($node->getChangedTime(), 'short') : t('Not saved yet');
|
||||
$form['meta'] = array(
|
||||
'#attributes' => array('class' => array('entity-meta__header')),
|
||||
'#type' => 'container',
|
||||
'#group' => 'advanced',
|
||||
'#weight' => -100,
|
||||
'published' => array(
|
||||
'#type' => 'html_tag',
|
||||
'#tag' => 'h3',
|
||||
'#value' => $node->isPublished() ? t('Published') : t('Not published'),
|
||||
'#access' => !$node->isNew(),
|
||||
'#attributes' => array(
|
||||
'class' => 'entity-meta__title',
|
||||
),
|
||||
),
|
||||
'changed' => array(
|
||||
'#type' => 'item',
|
||||
'#wrapper_attributes' => array('class' => array('entity-meta__last-saved', 'container-inline')),
|
||||
'#markup' => '<h4 class="label inline">' . t('Last saved') . '</h4> ' . $is_new,
|
||||
),
|
||||
'author' => array(
|
||||
'#type' => 'item',
|
||||
'#wrapper_attributes' => array('class' => array('author', 'container-inline')),
|
||||
'#markup' => '<h4 class="label inline">' . t('Author') . '</h4> ' . $node->getOwner()->getUsername(),
|
||||
),
|
||||
);
|
||||
$form['revision_information']['#type'] = 'container';
|
||||
$form['revision_information']['#group'] = 'meta';
|
||||
}
|
Reference in a new issue