-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsitestudio_gin.module
86 lines (75 loc) · 2.81 KB
/
sitestudio_gin.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* @file
* Module hooks and alters for Admin UI customizations.
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_preprocess_HOOK() for page templates.
*/
function sitestudio_gin_preprocess_page(&$variables) {
// Global CSS overrides.
$variables['#attached']['library'][] = 'sitestudio_gin/sitestudio_gin-global-overrides';
// Overrides only if Gin is the active theme.
$theme = \Drupal::theme()->getActiveTheme()->getName();
if ($theme == 'gin') {
$variables['#attached']['library'][] = 'sitestudio_gin/sitestudio_gin-gin-overrides';
$route = \Drupal::routeMatch()->getRouteName();
if ($route == 'sitestudio-page-builder.layout_canvas.frontend_edit_component'
&& !empty($variables['page']['gin_secondary_toolbar'])) {
// Remove the gin secondary toolbar from the Site Studio iframe.
unset($variables['page']['gin_secondary_toolbar']);
}
}
}
/**
* Implements hook_form_BASE_FORM_ID_alter() for \Drupal\cohesion_elements\Form\ComponentContentForm.
*
* Changes vertical tabs to container.
*
* Note: Adapted from cohesion_elements_form_component_content_edit_form_alter()
* for gin admin theme.
*
* @see cohesion_elements_form_component_content_edit_form_alter()
* @see claro_form_node_form_alter()
*/
function sitestudio_gin_form_component_content_edit_form_alter(&$form, FormStateInterface $form_state) {
$theme = \Drupal::theme()->getActiveTheme()->getName();
if ($theme == 'gin') {
$form['#theme'] = ['node_edit_form'];
$form['#attached']['library'][] = 'claro/node-form';
$form['advanced']['#type'] = 'container';
$form['advanced']['#accordion'] = TRUE;
$form['meta']['#type'] = 'container';
$form['meta']['#access'] = TRUE;
$form['meta']['changed']['#wrapper_attributes']['class'][] = 'container-inline';
$form['meta']['author']['#wrapper_attributes']['class'][] = 'container-inline';
$form['revision_information']['#type'] = 'container';
$form['revision_information']['#group'] = 'meta';
}
}
/**
* Implements hook_form_BASE_FORM_ID_alter() for \ Drupal\cohesion_elements\Form\ComponentContentForm.
*
* Changes vertical tabs to container.
*
* Note: Adapted from cohesion_elements_form_component_content_edit_form_alter()
* for gin admin theme.
*
* @see sitestudio_gin_form_component_content_edit_form_alter()
*/
function sitestudio_gin_form_component_content_add_form_alter(&$form, FormStateInterface $form_state) {
sitestudio_gin_form_component_content_edit_form_alter($form, $form_state);
}
/**
* Implements hook_gin_content_form_routes().
*
* Register routes to apply the Gin content edit form layout.
*/
function sitestudio_gin_gin_content_form_routes() {
return [
// Layout a component content using node form.
'entity.component_content.add_form',
'entity.component_content.edit_form',
];
}