/
d_demo.module
151 lines (141 loc) · 7.67 KB
/
d_demo.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
/**
* @file
* d_demo module.
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_content_structure_alter().
*/
function d_demo_content_structure_alter(&$structure, $context) {
$path = drupal_get_path('module', 'd_demo') . '/pages';
if ($context == 'all') {
$structure['homepage'] = ['file' => "$path/homepage.yml", 'link' => 'Home', 'weight' => -50];
$structure['invest'] = ['file' => "$path/invest.yml"];
$structure['documentation'] = [
'file' => "$path/documentation.yml",
'link' => 'Documentation',
'weight' => 30,
'children' => [
'shortcodes' => ['file' => "$path/shortcodes.yml", 'link' => 'Shortcodes', 'weight' => 0],
'd_p_banner' => ['file' => "$path/d_p_banner.yml", 'link' => 'Banner Paragraph', 'weight' => 10],
'd_p_form' => ['file' => "$path/d_p_form.yml", 'link' => 'Form Paragraph', 'weight' => 20],
'd_p_text_blocks' => ['file' => "$path/d_p_text_blocks.yml", 'link' => 'Text Blocks Paragraph', 'weight' => 30],
'd_p_sidebar_image' => ['file' => "$path/d_p_sidebar_image.yml", 'link' => 'Sidebar Image Paragraph', 'weight' => 40],
'd_p_subscribe' => ['file' => "$path/d_p_subscribe.yml", 'link' => 'Subscribe File Paragraph', 'weight' => 50],
'd_p_text' => ['file' => "$path/d_p_text.yml", 'link' => 'Text Paragraph', 'weight' => 60],
'd_p_text_bg' => ['file' => "$path/d_p_text_bg.yml", 'link' => 'Text With Background Paragraph', 'weight' => 70],
'd_p_counters' => ['file' => "$path/d_p_counters.yml", 'link' => 'Counters Paragraph', 'weight' => 80],
'd_p_gallery' => ['file' => "$path/d_p_gallery.yml", 'link' => 'Gallery Paragraph', 'weight' => 90],
'd_p_carousel' => ['file' => "$path/d_p_carousel.yml", 'link' => 'Carousel Paragraph', 'weight' => 90],
'd_p_embed' => ['file' => "$path/d_p_embed.yml", 'link' => 'Side Embed Paragraph', 'weight' => 100],
'd_p_tiles' => ['file' => "$path/d_p_tiles.yml", 'link' => 'Tiles Paragraphs', 'weight' => 110],
'd_p_reference_content' => ['file' => "$path/d_p_reference_content.yml", 'link' => 'Reference Content Paragraph', 'weight' => 120],
'd_p_side_by_side' => ['file' => "$path/d_p_side_by_side.yml", 'link' => 'Side By Side Paragraph', 'weight' => 130],
],
];
$structure['services'] = ['file' => "$path/services.yml", 'link' => 'Services', 'weight' => 20];
$structure['services_engine_installation'] = ['file' => "$path/services_engine_installation.yml"];
$structure['services_engine_overhaul'] = ['file' => "$path/services_engine_overhaul.yml"];
$structure['services_monitoring_and_assessment'] = ['file' => "$path/services_monitoring_and_assessment.yml"];
$structure['services_engine_repair_and_overhaul'] = ['file' => "$path/services_engine_repair_and_overhaul.yml"];
$structure['services_engine_repair'] = ['file' => "$path/services_engine_repair.yml"];
$structure['services_engine_oil_change'] = ['file' => "$path/services_engine_oil_change.yml"];
$structure['services_engine_testing_services'] = ['file' => "$path/services_engine_testing_services.yml"];
$structure['services_for_aircrafts'] = ['file' => "$path/services_for_aircrafts.yml"];
$structure['services_for_boats'] = ['file' => "$path/services_for_boats.yml"];
$structure['services_for_cars'] = ['file' => "$path/services_for_cars.yml"];
$structure['services_regular_servicing '] = ['file' => "$path/services_regular_servicing.yml"];
$structure['services_ad_hoc_engine_repairs'] = ['file' => "$path/services_ad_hoc_engine_repairs.yml"];
$structure['services_regular_servicing'] = ['file' => "$path/services_regular_servicing.yml"];
$structure['services_for_spacecrafts'] = ['file' => "$path/services_for_spacecrafts.yml"];
$structure['contact'] = ['file' => "$path/contact.yml"];
$structure['about_us'] = ['file' => "$path/about_us.yml"];
$structure['careers'] = ['file' => "$path/careers.yml"];
$structure['engines_car'] = [
'file' => "$path/engines_car.yml",
'link' => 'Car Engines',
'parent' => 'd_demo.engines',
'children' => [
'engines_car_diesel' => ['file' => "$path/engines_car_diesel.yml", 'link' => 'Diesel Engines', 'weight' => 0],
'engines_car_gasoline' => ['file' => "$path/engines_car_gasoline.yml", 'link' => 'Gasoline Engines', 'weight' => 1],
],
];
$structure['engines_boat'] = ['file' => "$path/engines_boat.yml", 'link' => 'Boat Engines', 'parent' => 'd_demo.engines'];
$structure['engines_aircraft'] = ['file' => "$path/engines_aircraft.yml", 'link' => 'Aircraft Engines', 'parent' => 'd_demo.engines'];
$structure['gdpr'] = ['file' => "$path/gdpr.yml"];
$structure['terms_of_service'] = ['file' => "$path/terms_of_service.yml"];
$structure['privacy_policy'] = ['file' => "$path/privacy_policy.yml"];
}
}
/**
* Implements hook_block_structure_alter().
*/
function d_demo_block_structure_alter(&$structure, $context) {
$path = drupal_get_path('module', 'd_demo') . '/blocks';
if ($context == 'all') {
$structure['cars'] = ['file' => "$path/mega_submenu_services_for_cars.yml"];
$structure['boats'] = ['file' => "$path/mega_submenu_services_for_boats.yml"];
$structure['aircrafts'] = ['file' => "$path/mega_submenu_services_for_aircrafts.yml"];
$structure['spacecrafts'] = ['file' => "$path/mega_submenu_services_for_spacecrafts.yml"];
$structure['footer_office_1'] = ['file' => "$path/footer_office_1.yml"];
$structure['footer_office_2'] = ['file' => "$path/footer_office_2.yml"];
$structure['footer_engines'] = ['file' => "$path/footer_engines.yml"];
$structure['footer_services'] = ['file' => "$path/footer_services.yml"];
$structure['footer_others'] = ['file' => "$path/footer_others.yml"];
$structure['footer_secondary_menu'] = ['file' => "$path/footer_secondary_menu.yml"];
$structure['d_social_media_footer'] = ['file' => "$path/d_social_media_footer.yml"];
$structure['header_search_link'] = ['file' => "$path/header_search_link.yml"];
$structure['secondary_menu'] = ['file' => "$path/secondary_menu.yml"];
$structure['bottom_footer_menu'] = ['file' => "$path/bottom_footer_menu.yml"];
}
}
/**
* Implements hook_form_alter().
*/
function d_demo_form_alter(&$form, FormStateInterface &$form_state, $form_id) {
switch ($form_id) {
case 'contact_message_feedback_form':
unset($form['actions']['preview']);
foreach ($form as &$formElement) {
if (isset($formElement['#type'])) {
switch ($formElement['#type']) {
case 'text':
case 'textfield':
case 'email':
$formElement['#attributes']['placeholder'] = $formElement['#title'];
$formElement['#title_display'] = 'invisible';
break;
case 'item':
case 'container':
if (!empty($formElement['widget']['#title'])) {
$title = $formElement['widget']['#title'];
$formElement['widget'][0]['value']['#attributes']['placeholder'] = $title;
$formElement['widget'][0]['value']['#title_display'] = 'invisible';
}
break;
}
}
}
// Add wrapper for name and mail field.
$wrapper = [
'#type' => 'container',
'#weight' => -666,
'#attributes' => [
'class' => ['name-and-mail'],
],
];
$wrapper['name'] = $form['name'];
$wrapper['mail'] = $form['mail'];
$form['name_and_mail'] = $wrapper;
unset($form['name']);
unset($form['mail']);
break;
}
}
/**
* Implements hook_attachments().
*/
function d_demo_page_attachments(array &$page) {
$page['#attached']['library'][] = 'd_demo/d_demo_random_price';
}