';
$variables['secondary']['#prefix'] .= '';
$output .= drupal_render($variables['secondary']);
}
return $output;
}
/**
* Overrides theme_menu_local_task().
*
* Returns HTML for a local task.
*/
function seven_menu_local_task($variables) {
$link = $variables['element']['#link'];
$link += array(
'localized_options' => array(),
);
$link_text = $link['title'];
if (!empty($variables['element']['#active'])) {
// Add text to indicate active tab for non-visual users.
$active = '' . t('(active tab)') . '';
// If the link does not contain HTML already, String::checkPlain() it now.
// After we set 'html'=TRUE the link will not be sanitized by l().
if (empty($link['localized_options']['html'])) {
$link['title'] = String::checkPlain($link['title']);
}
$link['localized_options']['html'] = TRUE;
$link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));
}
if (!empty($link['href'])) {
// @todo - remove this once all pages are converted to routes.
$a_tag = l($link_text, $link['href'], $link['localized_options']);
}
else {
$a_tag = \Drupal::l($link_text, $link['route_name'], $link['route_parameters'], $link['localized_options']);
}
return '
' . $a_tag . '
';
}
/**
* Implements hook_preprocess_HOOK() for list of available node type templates.
*/
function seven_preprocess_node_add_list(&$variables) {
if (!empty($variables['content'])) {
foreach ($variables['content'] as $type) {
$variables['types'][$type->type]['label'] = String::checkPlain($type->name);
$variables['types'][$type->type]['description'] = Xss::filterAdmin($type->description);
$variables['types'][$type->type]['url'] = \Drupal::url('node.add', array('node_type' => $type->type));
}
}
}
/**
* 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, description, and url.
*/
function seven_preprocess_block_content_add_list(&$variables) {
if (!empty($variables['content'])) {
foreach ($variables['content'] as $type) {
$variables['types'][$type->id()]['label'] = String::checkPlain($type->label());
$variables['types'][$type->id()]['description'] = Xss::filterAdmin($type->description);
$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_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 tablesort indicator templates.
*
* Uses Seven's image versions, so the arrows show up as black and not gray on
* gray.
*/
function seven_preprocess_tablesort_indicator(&$variables) {
$theme_path = drupal_get_path('theme', 'seven');
$variables['arrow_asc'] = file_create_url($theme_path . '/images/arrow-asc.png');
$variables['arrow_desc'] = file_create_url($theme_path . '/images/arrow-desc.png');
}
/**
* Overrides theme_menu_local_action().
*/
function seven_menu_local_action($variables) {
$link = $variables['element']['#link'];
$link += array(
'href' => '',
'localized_options' => array(),
'route_parameters' => array(),
);
$link['localized_options']['attributes']['class'][] = 'button';
$link['localized_options']['attributes']['class'][] = 'button--primary';
$link['localized_options']['attributes']['class'][] = 'button--small';
// @todo Replace with a generalized solution for icons.
// See http://drupal.org/node/1849712
$link['localized_options']['attributes']['class'][] = 'button-action';
// We require Modernizr's touch test for button styling.
$libraries = array(
'#attached' => array(
'library' => array(
'core/modernizr',
),
),
);
drupal_render($libraries);
$output = '
';
// @todo Remove this check and the call to l() when all pages are converted to
// routes.
// @todo Figure out how to support local actions without a href properly.
if ($link['href'] === '' && !empty($link['route_name'])) {
$output .= Drupal::l($link['title'], $link['route_name'], $link['route_parameters'], $link['localized_options']);
}
else {
$output .= l($link['title'], $link['href'], $link['localized_options']);
}
$output .= "
";
return $output;
}
/**
* 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) {
$page_object = $variables['page']['#page'];
$attributes = $page_object->getHtmlAttributes();
$classes = $attributes['class'];
$classes[] = 'install-background';
$attributes['class'] = $classes;
// Normally we could attach libraries via hook_page_alter(), but when the
// database is inactive it's not called so we add them here.
$libraries = array(
'#attached' => array(
'library' => array(
'seven/maintenance-page',
'seven/install-page',
),
),
);
drupal_render($libraries);
}
/**
* Implements hook_preprocess_maintenance_page().
*/
function seven_preprocess_maintenance_page(&$variables) {
$page_object = $variables['page']['#page'];
$attributes = $page_object->getHtmlAttributes();
$classes = $attributes['class'];
$classes[] = 'maintenance-background';
$attributes['class'] = $classes;
// // Normally we could attach libraries via hook_page_alter(), but when the
// // database is inactive it's not called so we add them here.
$libraries = array(
'#attached' => array(
'library' => array(
'seven/maintenance-page',
),
),
);
drupal_render($libraries);
}
/**
* Implements hook_form_BASE_FORM_ID_alter().
*
* 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']['css'][] = drupal_get_path('module', 'node') . '/css/node.module.css';
$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' => 'item',
'#wrapper_attributes' => array('class' => array('published')),
'#markup' => $node->isPublished() ? t('Published') : t('Not published'),
'#access' => !$node->isNew(),
),
'changed' => array(
'#type' => 'item',
'#wrapper_attributes' => array('class' => array('changed', 'container-inline')),
'#markup' => '