2009-07-31 19:35:57 +00:00
<?php
2010-05-12 09:22:24 +00:00
/**
2012-04-19 15:30:31 +00:00
* @file
* Functions to support theming in the Seven theme.
*/
/**
2013-05-24 16:53:16 +00:00
* Implements hook_preprocess_HOOK() for maintenance-page.html.twig.
2010-05-12 09:22:24 +00:00
*/
function seven_preprocess_maintenance_page(&$vars) {
// While markup for normal pages is split into page.tpl.php and html.tpl.php,
// the markup for the maintenance page is all in the single
2013-05-24 16:53:16 +00:00
// maintenance-page.html.twig template. So, to have what's done in
2010-05-12 09:22:24 +00:00
// seven_preprocess_html() also happen on the maintenance page, it has to be
// called here.
seven_preprocess_html($vars);
}
2009-07-31 19:35:57 +00:00
/**
2012-04-19 15:30:31 +00:00
* Implements hook_preprocess_HOOK() for html.tpl.php.
2009-07-31 19:35:57 +00:00
*/
2010-02-25 20:57:39 +00:00
function seven_preprocess_html(&$vars) {
2012-11-02 06:28:14 +00:00
drupal_add_library('system', 'normalize');
2009-09-15 17:10:39 +00:00
}
2010-02-25 20:57:39 +00:00
/**
2012-04-19 15:30:31 +00:00
* Implements hook_preprocess_HOOK() for page.tpl.php.
2010-02-25 20:57:39 +00:00
*/
2009-07-31 19:35:57 +00:00
function seven_preprocess_page(&$vars) {
2010-11-20 04:03:51 +00:00
$vars['primary_local_tasks'] = $vars['tabs'];
unset($vars['primary_local_tasks']['#secondary']);
$vars['secondary_local_tasks'] = array(
'#theme' => 'menu_local_tasks',
2013-02-18 17:03:05 +00:00
'#secondary' => isset($vars['tabs']['#secondary']) ? $vars['tabs']['#secondary'] : '',
2010-11-20 04:03:51 +00:00
);
2009-07-31 19:35:57 +00:00
}
/**
2012-04-19 15:30:31 +00:00
* Displays the list of available node types for node creation.
2009-07-31 19:35:57 +00:00
*/
2009-10-09 01:00:08 +00:00
function seven_node_add_list($variables) {
$content = $variables['content'];
2009-07-31 19:35:57 +00:00
$output = '';
if ($content) {
2010-10-03 02:46:12 +00:00
$output = '<ul class="admin-list">';
2012-05-14 02:50:42 +00:00
foreach ($content as $type) {
2009-07-31 19:35:57 +00:00
$output .= '<li class="clearfix">';
2012-11-06 13:42:12 +00:00
$content = '<span class="label">' . check_plain($type->name) . '</span>';
$content .= '<div class="description">' . filter_xss_admin($type->description) . '</div>';
$options['html'] = TRUE;
$output .= l($content, 'node/add/' . $type->type, $options);
2009-07-31 19:35:57 +00:00
$output .= '</li>';
}
$output .= '</ul>';
}
2010-10-03 00:09:28 +00:00
else {
$output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '</p>';
}
2009-07-31 19:35:57 +00:00
return $output;
}
2013-02-18 22:17:49 +00:00
/**
* Overrides theme_custom_block_add_list().
*
* Displays the list of available custom block types for creation.
*/
function seven_custom_block_add_list($variables) {
$content = $variables['content'];
$output = '';
if ($content) {
$output = '<ul class="admin-list">';
foreach ($content as $type) {
$output .= '<li class="clearfix">';
$content = '<span class="label">' . check_plain($type->label()) . '</span>';
$content .= '<div class="description">' . filter_xss_admin($type->description) . '</div>';
$options['html'] = TRUE;
$output .= l($content, 'block/add/' . $type->id(), $options);
$output .= '</li>';
}
$output .= '</ul>';
}
return $output;
}
2009-07-31 19:35:57 +00:00
/**
2010-10-01 15:24:18 +00:00
* Overrides theme_admin_block_content().
2009-07-31 19:35:57 +00:00
*
2012-04-19 15:30:31 +00:00
* Uses an unordered list markup in both compact and extended mode.
2009-07-31 19:35:57 +00:00
*/
2009-10-09 01:00:08 +00:00
function seven_admin_block_content($variables) {
$content = $variables['content'];
2009-07-31 19:35:57 +00:00
$output = '';
if (!empty($content)) {
$output = system_admin_compact_mode() ? '<ul class="admin-list compact">' : '<ul class="admin-list">';
foreach ($content as $item) {
2012-11-06 13:42:12 +00:00
$output .= '<li>';
$content = '<span class="label">' . filter_xss_admin($item['title']) . '</span>';
$options = $item['localized_options'];
$options['html'] = TRUE;
2010-10-01 15:24:18 +00:00
if (isset($item['description']) && !system_admin_compact_mode()) {
2012-11-06 13:42:12 +00:00
$content .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
2009-07-31 19:35:57 +00:00
}
2012-11-06 13:42:12 +00:00
$output .= l($content, $item['href'], $options);
2009-07-31 19:35:57 +00:00
$output .= '</li>';
}
$output .= '</ul>';
}
return $output;
}
/**
2012-04-19 15:30:31 +00:00
* Overrides theme_tablesort_indicator().
2009-07-31 19:35:57 +00:00
*
2012-04-19 15:30:31 +00:00
* Uses Seven's image versions, so the arrows show up as black and not gray on
* gray.
2009-07-31 19:35:57 +00:00
*/
2009-10-09 01:00:08 +00:00
function seven_tablesort_indicator($variables) {
2009-07-31 19:35:57 +00:00
$theme_path = drupal_get_path('theme', 'seven');
2013-06-09 18:08:59 +00:00
if($variables['style'] == 'asc') {
$image_uri = $theme_path . '/images/arrow-asc.png';
$text = t('sort ascending');
2009-07-31 19:35:57 +00:00
}
else {
2013-06-09 18:08:59 +00:00
$image_uri = $theme_path . '/images/arrow-desc.png';
$text = t('sort descending');
2009-07-31 19:35:57 +00:00
}
2013-06-09 18:08:59 +00:00
$image = array(
'#theme' => 'image',
'#uri' => $image_uri,
'#alt' => $text,
'#width' => 13,
'#height' => 13,
'#title' => $text,
);
return drupal_render($image);
2009-07-31 19:35:57 +00:00
}
2009-08-12 11:32:07 +00:00
2012-12-29 08:52:15 +00:00
/**
* Implements hook_preprocess_install_page().
*/
function seven_preprocess_install_page(&$variables) {
drupal_add_js(drupal_get_path('theme', 'seven') . '/js/mobile.install.js');
}
2013-02-09 00:13:30 +00:00
/**
* Implements hook_form_BASE_FORM_ID_alter().
*
* Changes vertical tabs to container and adds meta information.
*/
function seven_form_node_form_alter(&$form, &$form_state) {
2013-04-29 23:46:14 +00:00
$node = $form_state['controller']->getEntity();
2013-02-09 00:13:30 +00:00
2013-02-16 18:33:45 +00:00
$form['#theme'] = array('node_edit_form');
$form['#attached'] = array(
2013-06-07 10:48:55 +00:00
'css' => array(drupal_get_path('module', 'node') . '/css/node.module.css'),
2013-02-16 18:33:45 +00:00
);
2013-02-09 00:13:30 +00:00
$form['advanced']['#type'] = 'container';
$form['meta'] = array (
'#type' => 'fieldset',
'#attributes' => array('class' => array('entity-meta-header')),
'#type' => 'container',
'#group' => 'advanced',
'#weight' => -100,
'published' => array(
'#type' => 'item',
'#wrapper_attributes' => array('class' => array('published')),
'#markup' => !empty($node->status) ? t('Published') : t('Not published'),
'#access' => !empty($node->nid),
),
'changed' => array(
'#type' => 'item',
'#wrapper_attributes' => array('class' => array('changed', 'container-inline')),
'#title' => t('Last saved'),
'#markup' => !$node->isNew() ? format_date($node->changed, 'short') : t('Not saved yet'),
),
'author' => array(
'#type' => 'item',
'#wrapper_attributes' => array('class' => array('author', 'container-inline')),
'#title' => t('Author'),
'#markup' => user_format_name(user_load($node->uid)),
),
);
$form['revision_information']['#type'] = 'container';
$form['revision_information']['#group'] = 'meta';
}