Skip to content
Snippets Groups Projects
Commit 71f619d2 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #1838114 follow-up by swentel, sun: Move styling to an alter hook off of...

Issue #1838114 follow-up by swentel, sun: Move styling to an alter hook off of Seven theme + other clean-ups.
parent 254d709b
No related branches found
No related tags found
No related merge requests found
...@@ -56,20 +56,6 @@ protected function prepareEntity(EntityInterface $node) { ...@@ -56,20 +56,6 @@ protected function prepareEntity(EntityInterface $node) {
* Overrides Drupal\Core\Entity\EntityFormController::form(). * Overrides Drupal\Core\Entity\EntityFormController::form().
*/ */
public function form(array $form, array &$form_state, EntityInterface $node) { public function form(array $form, array &$form_state, EntityInterface $node) {
// Visual representation of the node content form depends on following
// parameters:
// - the current user has access to view the administration theme.
// - the current path is an admin path.
// - the node/add / edit pages are configured to be represented in the
// administration theme.
$container_type = 'vertical_tabs';
$request = drupal_container()->get('request');
$path = $request->attributes->get('system_path');
if (user_access('view the administration theme') && path_is_admin($path)) {
$container_type = 'container';
}
$user_config = config('user.settings'); $user_config = config('user.settings');
// Some special stuff when previewing a node. // Some special stuff when previewing a node.
if (isset($form_state['node_preview'])) { if (isset($form_state['node_preview'])) {
...@@ -124,43 +110,16 @@ public function form(array $form, array &$form_state, EntityInterface $node) { ...@@ -124,43 +110,16 @@ public function form(array $form, array &$form_state, EntityInterface $node) {
); );
$form['advanced'] = array( $form['advanced'] = array(
'#type' => $container_type, '#type' => 'vertical_tabs',
'#attributes' => array('class' => array('entity-meta')), '#attributes' => array('class' => array('entity-meta')),
'#weight' => 99, '#weight' => 99,
); );
$form['meta'] = array (
'#type' => 'fieldset',
'#attributes' => array('class' => array('entity-meta-header')),
'#type' => 'container',
'#group' => 'advanced',
'#weight' => -100,
'#access' => $container_type == 'container',
// @todo Geez. Any .status is styled as OK icon? Really?
'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)),
),
);
// Add a log field if the "Create new revision" option is checked, or if the // Add a log field if the "Create new revision" option is checked, or if
// current user has the ability to check that option. // the current user has the ability to check that option.
$form['revision_information'] = array( $form['revision_information'] = array(
'#type' => $container_type == 'container' ? 'container' : 'details', '#type' => 'details',
'#group' => $container_type == 'container' ? 'meta' : 'advanced', '#group' => 'advanced',
'#title' => t('Revision information'), '#title' => t('Revision information'),
// Collapsed by default when "Create new revision" is unchecked. // Collapsed by default when "Create new revision" is unchecked.
'#collapsed' => !$node->isNewRevision(), '#collapsed' => !$node->isNewRevision(),
......
...@@ -111,3 +111,41 @@ function seven_tablesort_indicator($variables) { ...@@ -111,3 +111,41 @@ function seven_tablesort_indicator($variables) {
function seven_preprocess_install_page(&$variables) { function seven_preprocess_install_page(&$variables) {
drupal_add_js(drupal_get_path('theme', 'seven') . '/js/mobile.install.js'); drupal_add_js(drupal_get_path('theme', 'seven') . '/js/mobile.install.js');
} }
/**
* 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) {
$node = $form_state['controller']->getEntity($form_state);
$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';
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment