-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheasyddb_frontend_layout.module
More file actions
338 lines (312 loc) · 11 KB
/
easyddb_frontend_layout.module
File metadata and controls
338 lines (312 loc) · 11 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<?php
/**
* @file
* easyOPAC frontend layout module.
*/
include_once 'easyddb_frontend_layout.features.inc';
/**
* Implements hook_ctools_plugin_directory().
*/
function easyddb_frontend_layout_ctools_plugin_directory($module, $plugin) {
return 'plugins/' . $plugin;
}
/**
* Implements hook_form_system_theme_settings_alter().
*/
function easyddb_frontend_layout_form_system_theme_settings_alter(&$form, &$form_state) {
if (isset($form_state['build_info']['args'][0]) && ($theme = $form_state['build_info']['args'][0]) && color_get_info($theme) && function_exists('gd_info')) {
$theme_backup = variable_get('theme_ddbasic_settings_backup', []);
if (!empty($theme_backup) && $theme == 'ddbasic') {
$fields = [
'topbar' => 'topbar_background_color',
'extended_search_pane' => 'header_background_color',
'primary' => 'navigation_background_color',
'secondary' => 'link',
];
$theme_info = color_get_info('ddbasic');
$colors = [];
foreach ($fields as $new => $old) {
if (!empty($theme_backup['palette'][$old])) {
$colors[$new] = $theme_backup['palette'][$old];
}
else {
$colors[$new] = $theme_info['schemes']['default']['colors'][$new];
}
}
$form['color']['restore_colors'] = [
'#prefix' => '<div style="margin-top: 25px">',
'#suffix' => '</div>',
'#type' => 'button',
'#name' => 'colors_revert',
'#value' => 'Revert colors',
'#attached' => [
'js' => [
[
'data' => ['colors' => $colors],
'type' => 'setting',
],
[
'data' => drupal_get_path('module', 'easyddb_frontend_layout') . '/js/easyddb_frontend_layout.js',
'type' => 'file',
],
],
],
];
}
}
// Custom link on logo image.
$form['logo']['custom_url_on_logo'] = [
'#type' => 'textfield',
'#title' => t('Custom URL on logo'),
'#description' => t('URL to which the logo image will be linked. Ex: https://example.com.'),
'#default_value' => variable_get('easyddb_frontend_layout_custom_url_on_logo', ''),
];
$form['#validate'][] = 'easyddb_frontend_layout_custom_url_on_logo_validate';
$form['#submit'][] = 'easyddb_frontend_layout_custom_url_on_logo_submit';
}
/**
* Custom logo URL field form submit callback.
*/
function easyddb_frontend_layout_custom_url_on_logo_submit($form, &$form_state) {
if (isset($form_state['values']['custom_url_on_logo'])) {
variable_set('easyddb_frontend_layout_custom_url_on_logo', $form_state['values']['custom_url_on_logo']);
}
}
/**
* Custom logo URL field validation handler.
*/
function easyddb_frontend_layout_custom_url_on_logo_validate($form, &$form_state) {
if (!empty($form_state['values']['custom_url_on_logo'])) {
if (!valid_url($form_state['values']['custom_url_on_logo'], TRUE)) {
form_set_error('custom_url_on_logo', t('Custom logo URL is not valid.'));
}
}
}
/**
* Implements hook_preprocess_HOOK().
*/
function easyddb_frontend_layout_preprocess_pane_header(&$variables) {
if (!empty(variable_get('easyddb_frontend_layout_custom_url_on_logo', ''))) {
$variables['front_page'] = variable_get('easyddb_frontend_layout_custom_url_on_logo', '');
}
}
/**
* Implements hook_preprocess().
*
* Hide "Email Format" information provided by "Mimemail" from displaying on
* frontend.
*/
function easyddb_frontend_layout_preprocess(&$variables, $hook) {
if ($hook == 'user_profile') {
unset($variables['user_profile']['mimemail']);
}
}
/**
* Implements hook_image_styles_alter().
*/
function easyddb_frontend_layout_image_styles_alter(&$styles) {
$styles['ting_cover_large'] = [
'name' => 'ting_cover_large',
'label' => 'Ting cover large',
'effects' => [
7 => [
'label' => 'Manual Crop: Custom crop',
'help' => 'Crop a freely user-selected area.',
'effect callback' => 'manualcrop_crop_effect',
'form callback' => 'manualcrop_crop_form',
'summary theme' => 'manualcrop_crop_summary',
'module' => 'manualcrop',
'name' => 'manualcrop_crop',
'data' => [
'width' => 500,
'height' => '',
'keepproportions' => 0,
'reuse_crop_style' => '',
'style_name' => 'ting_cover_large',
],
'weight' => 0,
],
8 => [
'label' => 'Scale',
'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.',
'effect callback' => 'image_scale_effect',
'dimensions callback' => 'image_scale_dimensions',
'form callback' => 'image_scale_form',
'summary theme' => 'image_scale_summary',
'module' => 'image',
'name' => 'image_scale',
'data' => [
'width' => 500,
'height' => '',
'upscale' => 1,
],
'weight' => 2,
],
],
];
$styles['ting_cover_medium'] = [
'name' => 'ting_cover_medium',
'label' => 'Ting cover medium',
'effects' => [
5 => [
'label' => 'Manual Crop: Custom crop',
'help' => 'Crop a freely user-selected area.',
'effect callback' => 'manualcrop_crop_effect',
'form callback' => 'manualcrop_crop_form',
'summary theme' => 'manualcrop_crop_summary',
'module' => 'manualcrop',
'name' => 'manualcrop_crop',
'data' => [
'width' => 260,
'height' => '',
'keepproportions' => 0,
'reuse_crop_style' => '',
'style_name' => 'ting_cover_medium',
],
'weight' => 0,
],
6 => [
'label' => 'Scale',
'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.',
'effect callback' => 'image_scale_effect',
'dimensions callback' => 'image_scale_dimensions',
'form callback' => 'image_scale_form',
'summary theme' => 'image_scale_summary',
'module' => 'image',
'name' => 'image_scale',
'data' => [
'width' => 260,
'height' => '',
'upscale' => 1,
],
'weight' => 2,
],
],
];
$styles['ting_cover_small'] = [
'name' => 'ting_cover_small',
'label' => 'Ting cover small',
'effects' => [
3 => [
'label' => 'Manual Crop: Custom crop',
'help' => 'Crop a freely user-selected area.',
'effect callback' => 'manualcrop_crop_effect',
'form callback' => 'manualcrop_crop_form',
'summary theme' => 'manualcrop_crop_summary',
'module' => 'manualcrop',
'name' => 'manualcrop_crop',
'data' => [
'width' => 180,
'height' => '',
'keepproportions' => 0,
'reuse_crop_style' => '',
'style_name' => 'ting_cover_small',
],
'weight' => 0,
],
4 => [
'label' => 'Scale',
'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.',
'effect callback' => 'image_scale_effect',
'dimensions callback' => 'image_scale_dimensions',
'form callback' => 'image_scale_form',
'summary theme' => 'image_scale_summary',
'module' => 'image',
'name' => 'image_scale',
'data' => [
'width' => 180,
'height' => '',
'upscale' => 1,
],
'weight' => 2,
],
],
];
$styles['ting_cover_mini'] = [
'name' => 'ting_cover_mini',
'label' => 'Ting cover mini',
'effects' => [
1 => [
'label' => 'Manual Crop: Custom crop',
'help' => 'Crop a freely user-selected area.',
'effect callback' => 'manualcrop_crop_effect',
'form callback' => 'manualcrop_crop_form',
'summary theme' => 'manualcrop_crop_summary',
'module' => 'manualcrop',
'name' => 'manualcrop_crop',
'data' => [
'width' => 100,
'height' => '',
'keepproportions' => 0,
'reuse_crop_style' => '',
'style_name' => 'ting_cover_mini',
],
'weight' => 0,
],
2 => [
'label' => 'Scale',
'help' => 'Scaling will maintain the aspect-ratio of the original image. If only a single dimension is specified, the other dimension will be calculated.',
'effect callback' => 'image_scale_effect',
'dimensions callback' => 'image_scale_dimensions',
'form callback' => 'image_scale_form',
'summary theme' => 'image_scale_summary',
'module' => 'image',
'name' => 'image_scale',
'data' => [
'width' => 100,
'height' => '',
'upscale' => 1,
],
'weight' => 2,
],
],
];
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function easyddb_frontend_layout_form_og_admin_menu_overview_form_alter(&$form, &$form_state, $form_id) {
// Allow translation of description text on `/admin/structure/og_menu` page.
$form['update_defaults_overview']['#markup'] = '<p>' . t('These actions will remove and replace the default OG Menu links defined in the !settings_link.', ['!settings_link' => l(t('OG Menu Settings'), 'admin/config/group/og_menu/default-links')]) . '</p>';
}
/**
* Implements hook_module_implements_alter().
*/
function easyddb_frontend_layout_module_implements_alter(&$implementations, $hook) {
if (($hook == 'form_og_admin_menu_overview_form_alter' || $hook == 'form_alter') && isset($implementations['easyddb_frontend_layout'])) {
$group = $implementations['easyddb_frontend_layout'];
unset($implementations['easyddb_frontend_layout']);
$implementations['easyddb_frontend_layout'] = $group;
}
}
/**
* Implements hook_form_alter().
*/
function easyddb_frontend_layout_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'ding_news_node_form') {
$paragraphs = $form['field_ding_news_paragraphs'][LANGUAGE_NONE]['add_more']['type']['#options'];
// @TODO: It's wrong to pass variables into `t()` function.
foreach ($paragraphs as $key => $paragraph_type) {
$form['field_ding_news_paragraphs'][LANGUAGE_NONE]['add_more']['type']['#options'][$key] = t($paragraph_type);
}
}
if ($form_id == 'eu_cookie_compliance_admin_form') {
$options = [
'bottom' => t('Bottom'),
'top' => t('Top'),
];
$form['appearance']['eu_cookie_compliance']['popup_position']['#options'] = $options;
}
if ($form_id == 'taxonomy_overview_vocabularies') {
// @TODO: It's wrong to pass variables into `t()` function.
foreach (element_children($form) as $key) {
if (isset($form[$key]['name'])) {
$vocabulary = &$form[$key];
$form[$key]['name']['#markup'] = t($vocabulary['name']['#markup']);
}
}
}
if (in_array($form_id, ['contact_site_form', 'contact_personal_form'])) {
$form['mail']['#default_value'] = '';
}
}