forked from david-robinson-practiceweb/Bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme-settings.php
462 lines (392 loc) · 14.9 KB
/
theme-settings.php
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
<?php
function bootstrap_settings($saved_settings) {
$defaults = array(
'layout_front_display_page_title' => 1,
'layout_front_display_page_content' => 1,
'layout_front_offcanvas_sidebar' => 1,
'mobile_contact_btns_icons' => 1,
'layout_staff_directory_layout' => 'grid',
'mobile_breadcrumb_btn_text' => 'Where am I?',
'mobile_offcanvas_btn_text' => 'What else is in this section?',
);
$settings = array_merge($defaults, $saved_settings);
// Staff directory layout
$staff_directory_layout = array(
'rows' => t('rows'),
'grid' => t('grid'),
);
// Form processing
if ($file = file_save_upload('bootstrap_touch_icon_default_upload',
array('file_validate_is_image' => array()))) {
$parts = pathinfo($file->filename);
$filename = $file->filename;
if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
$settings['bootstrap_touch_icon_default_path'] = $file->filepath;
}else{
dsm('Failed to upload the default touch icon.');
}
}
if ($file = file_save_upload('bootstrap_touch_icon_ipad_upload',
array('file_validate_is_image' => array()))) {
$parts = pathinfo($file->filename);
$filename = $file->filename;
if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
$settings['bootstrap_touch_icon_ipad_path'] = $file->filepath;
}else{
dsm('Failed to upload the iPad touch icon.');
}
}
if ($file = file_save_upload('bootstrap_touch_icon_iphone_r_upload',
array('file_validate_is_image' => array()))) {
$parts = pathinfo($file->filename);
$filename = $file->filename;
if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
$settings['bootstrap_touch_icon_iphone_r_path'] = $file->filepath;
}else{
dsm('Failed to upload the iPhone Retina touch icon.');
}
}
if ($file = file_save_upload('bootstrap_touch_icon_ipad_r_upload',
array('file_validate_is_image' => array()))) {
$parts = pathinfo($file->filename);
$filename = $file->filename;
if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
$settings['bootstrap_touch_icon_ipad_r_path'] = $file->filepath;
}else{
dsm('Failed to upload the iPad Retina touch icon.');
}
}
if ($file = file_save_upload('bootstrap_touch_icon_windows_metro_upload',
array('file_validate_is_image' => array()))) {
$parts = pathinfo($file->filename);
$filename = $file->filename;
if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
$settings['bootstrap_touch_icon_windows_metro_path'] = $file->filepath;
}else{
dsm('Failed to upload the iPad Retina touch icon.');
}
}
if ($file = file_save_upload('mobile_logo_upload',
array('file_validate_is_image' => array()))) {
$parts = pathinfo($file->filename);
$filename = $file->filename;
if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
$settings['mobile_logo_path'] = $file->filepath;
}else{
dsm('Failed to upload the mobile logo.');
}
}
// Mobile
$form['mobile'] = array(
'#type' => 'fieldset',
'#title' => t('Mobile'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Mobile header
$form['mobile']['mobile_nav_bg'] = array(
'#type' => 'textfield',
'#title' => t('Override header background color'),
'#size' => 6,
'#description' => t('The 6 digit hexidecimal color value. Do not include hash (#).'),
'#default_value' => $settings['mobile_nav_bg'],
);
// Mobile breadcrumb button text
$form['mobile']['mobile_breadcrumb_btn_text'] = array(
'#type' => 'textfield',
'#title' => t('Breadcumb toggle text'),
'#description' => t('Change the text on the breadcrumb toggle button.'),
'#default_value' => $settings['mobile_breadcrumb_btn_text'],
);
// Mobile offcanvas toggle button text
$form['mobile']['mobile_offcanvas_btn_text'] = array(
'#type' => 'textfield',
'#title' => t('Sidebar toggle text'),
'#description' => t('Change the text on the sidebar toggle button.'),
'#default_value' => $settings['mobile_offcanvas_btn_text'],
);
// Custom contact action buttons
$form['mobile']['mobile_contact_btns'] = array(
'#type' => 'fieldset',
'#title' => t('Mobile contact buttons'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['mobile']['mobile_contact_btns']['mobile_contact_btns_icons'] = array(
'#type' => 'checkbox',
'#title' => t('Display icons?'),
'#default_value' => $settings['mobile_contact_btns_icons'],
);
// Custom mobile logo
$form['mobile']['mobile_logo'] = array(
'#type' => 'fieldset',
'#title' => t('Mobile logo'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['mobile']['mobile_logo']['mobile_logo_markup'] = array(
'#type' => 'markup',
'#value' => t('<p>Optional. Upload a logo to replace the default on small devices.</p>'),
);
$form['mobile']['mobile_logo']['mobile_logo_use'] = array(
'#type' => 'checkbox',
'#title' => t('Replace logo with mobile logo on small devices?'),
'#default_value' => $settings['mobile_logo_use'],
);
$form['mobile']['mobile_logo']['mobile_logo_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to logo'),
'#value' => $settings['mobile_logo_path'],
'#default_value' => '',
);
$form['mobile']['mobile_logo']['mobile_logo_upload'] = array(
'#type' => 'file',
'#title' => t('Upload image'),
);
// If file exists then show image
if (!empty($settings['mobile_logo_path'])) {
$form['mobile']['mobile_logo']['mobile_logo_preview'] = array(
'#type' => 'markup',
'#value' => !empty($settings['mobile_logo_path']) ?
theme('image', $settings['mobile_logo_path']) : '',
);
};
/*
* Form components
*/
// Touch icons fieldset
$form['touch_icons'] = array(
'#type' => 'fieldset',
'#title' => t('Touch icons'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Default touch icon fieldset
$form['touch_icons']['default_touch_icon'] = array(
'#type' => 'fieldset',
'#title' => t('Default icon'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
$form['touch_icons']['default_touch_icon']['bootstrap_touch_icon_default_description'] = array(
'#type' => 'markup',
'#value' => t('The default touch icon used for older Apple and Android devices.<br />Size: 57x57px.'),
);
// Use apple touch icon
$form['touch_icons']['default_touch_icon']['bootstrap_touch_icon_default_use'] = array(
'#type' => 'checkbox',
'#title' => t('Use default touch icon?'),
'#default_value' => $settings['bootstrap_touch_icon_default_use'],
);
// Default touch icon path
$form['touch_icons']['default_touch_icon']['bootstrap_touch_icon_default_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to touch icon'),
'#value' => $settings['bootstrap_touch_icon_default_path'],
'#default_value' => '',
);
// Default touch icon file upload
$form['touch_icons']['default_touch_icon']['bootstrap_touch_icon_default_upload'] = array(
'#type' => 'file',
'#title' => t('Upload image'),
);
// Default touch icon preview
// If file exists then show image
if (!empty($settings['bootstrap_touch_icon_default_path'])) {
$form['touch_icons']['default_touch_icon']['bootstrap_touch_icon_default_preview'] = array(
'#type' => 'markup',
'#value' => !empty($settings['bootstrap_touch_icon_default_path']) ?
theme('image', $settings['bootstrap_touch_icon_default_path']) : '',
);
};
// ipad touch icon fieldset
$form['touch_icons']['ipad_touch_icon'] = array(
'#type' => 'fieldset',
'#title' => t('iPad icon'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
// Use ipad touch icon
$form['touch_icons']['ipad_touch_icon']['bootstrap_touch_icon_ipad_use'] = array(
'#type' => 'checkbox',
'#title' => t('Use iPad touch icon?'),
'#default_value' => $settings['bootstrap_touch_icon_ipad_use'],
);
// ipad icon path
$form['touch_icons']['ipad_touch_icon']['bootstrap_touch_icon_ipad_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to iPad touch icon'),
'#value' => $settings['bootstrap_touch_icon_ipad_path'],
'#default_value' => '',
);
// ipad icon file upload
$form['touch_icons']['ipad_touch_icon']['bootstrap_touch_icon_ipad_upload'] = array(
'#type' => 'file',
'#title' => t('Upload image'),
);
// ipad icon preview
// If file exists then show image
if (!empty($settings['bootstrap_touch_icon_ipad_path'])) {
$form['touch_icons']['ipad_touch_icon']['bootstrap_apple_touch_icon_ipad_preview'] = array(
'#type' => 'markup',
'#value' => !empty($settings['bootstrap_touch_icon_ipad_path']) ?
theme('image', $settings['bootstrap_touch_icon_ipad_path']) : '',
);
};
// iPhone Retina touch icon fieldset
$form['touch_icons']['iphone_r_touch_icon'] = array(
'#type' => 'fieldset',
'#title' => t('iPhone Retina icon'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
// Use iPhone Retina touch icon
$form['touch_icons']['iphone_r_touch_icon']['bootstrap_touch_icon_iphone_r_use'] = array(
'#type' => 'checkbox',
'#title' => t('Use iPhone retina touch icon?'),
'#default_value' => $settings['bootstrap_touch_icon_iphone_r_use'],
);
// iPhone Retina icon path
$form['touch_icons']['iphone_r_touch_icon']['bootstrap_touch_icon_iphone_r_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to iPhone Retina touch icon'),
'#value' => $settings['bootstrap_touch_icon_iphone_r_path'],
'#default_value' => '',
);
// iPhone Retina icon file upload
$form['touch_icons']['iphone_r_touch_icon']['bootstrap_touch_icon_iphone_r_upload'] = array(
'#type' => 'file',
'#title' => t('Upload image'),
);
// iPhone Retina icon preview
// If file exists then show image
if (!empty($settings['bootstrap_touch_icon_iphone_r_path'])) {
$form['touch_icons']['iphone_r_touch_icon']['bootstrap_apple_touch_icon_iphone_r_preview'] = array(
'#type' => 'markup',
'#value' => !empty($settings['bootstrap_touch_icon_iphone_r_path']) ?
theme('image', $settings['bootstrap_touch_icon_iphone_r_path']) : '',
);
};
// iPad Retina touch icon fieldset
$form['touch_icons']['ipad_r_touch_icon'] = array(
'#type' => 'fieldset',
'#title' => t('iPad Retina icon'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
// Use iPad Retina touch icon
$form['touch_icons']['ipad_r_touch_icon']['bootstrap_touch_icon_ipad_r_use'] = array(
'#type' => 'checkbox',
'#title' => t('Use iPad retina touch icon?'),
'#default_value' => $settings['bootstrap_touch_icon_ipad_r_use'],
);
// iPad Retina icon path
$form['touch_icons']['ipad_r_touch_icon']['bootstrap_touch_icon_ipad_r_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to iPad Retina touch icon'),
'#value' => $settings['bootstrap_touch_icon_ipad_r_path'],
'#default_value' => '',
);
// iPad Retina icon file upload
$form['touch_icons']['ipad_r_touch_icon']['bootstrap_touch_icon_ipad_r_upload'] = array(
'#type' => 'file',
'#title' => t('Upload image'),
);
// iPad Retina icon preview
// If file exists then show image
if (!empty($settings['bootstrap_touch_icon_ipad_r_path'])) {
$form['touch_icons']['ipad_r_touch_icon']['bootstrap_apple_touch_icon_ipad_r_preview'] = array(
'#type' => 'markup',
'#value' => !empty($settings['bootstrap_touch_icon_ipad_r_path']) ?
theme('image', $settings['bootstrap_touch_icon_ipad_r_path']) : '',
);
};
// Windows metro touch icon fieldset
$form['touch_icons']['windows_metro_touch_icon'] = array(
'#type' => 'fieldset',
'#title' => t('Windows metro tile'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
// Use Windows metro touch icon
$form['touch_icons']['windows_metro_touch_icon']['bootstrap_touch_icon_windows_metro_use'] = array(
'#type' => 'checkbox',
'#title' => t('Use Windows metro touch icon?'),
'#default_value' => $settings['bootstrap_touch_icon_windows_metro_use'],
);
// Use Windows metro touch color
$form['touch_icons']['windows_metro_touch_icon']['bootstrap_touch_icon_windows_metro_color'] = array(
'#type' => 'textfield',
'#title' => t('Hex color value'),
'#size' => 6,
'#description' => t('The 6 digit hexidecimal color value. Do not include hash (#).'),
'#default_value' => $settings['bootstrap_touch_icon_windows_metro_color'],
);
// Windows metro icon path
$form['touch_icons']['windows_metro_touch_icon']['bootstrap_touch_icon_windows_metro_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to Windows metro icon'),
'#value' => $settings['bootstrap_touch_icon_windows_metro_path'],
'#default_value' => '',
);
// Windows metro icon file upload
$form['touch_icons']['windows_metro_touch_icon']['bootstrap_touch_icon_windows_metro_upload'] = array(
'#type' => 'file',
'#title' => t('Upload image'),
);
// Windows metro icon preview
// If file exists then show image
$windows_metro_icon = '<div style="width:144px; height: 144px; padding: 20px 20px; background-color: #' . $settings['bootstrap_touch_icon_windows_metro_color'] . ';"><img src="/' . $settings['bootstrap_touch_icon_windows_metro_path'] . '"></div>';
if (!empty($settings['bootstrap_touch_icon_windows_metro_path'])) {
$form['touch_icons']['windows_metro_touch_icon']['bootstrap_apple_touch_icon_windows_metro_preview'] = array(
'#type' => 'markup',
'#value' => $windows_metro_icon,
);
};
// Layout
$form['layout'] = array(
'#type' => 'fieldset',
'#title' => t('Layout'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Layout - Front
$form['layout']['layout_front'] = array(
'#type' => 'fieldset',
'#title' => t('Front'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['layout']['layout_front']['layout_front_display_page_title'] = array(
'#type' => 'checkbox',
'#title' => t('Show page title?'),
'#description' => t('Some designs dont require the page title to be visible. Uncheck if its not needed.'),
'#default_value' => $settings['layout_front_display_page_title'],
);
$form['layout']['layout_front']['layout_front_display_page_content'] = array(
'#type' => 'checkbox',
'#title' => t('Show page content?'),
'#description' => t('Some designs dont require the page content. Uncheck if its not needed.'),
'#default_value' => $settings['layout_front_display_page_content'],
);
$form['layout']['layout_front']['layout_front_offcanvas_sidebar'] = array(
'#type' => 'checkbox',
'#title' => t('Stop off canvas sidebar?'),
'#description' => t('By default, the left sidebar will hide off the screen on small devices. Check box to stop this on the front page.'),
'#default_value' => $settings['layout_front_offcanvas_sidebar'],
);
// Layout - Staff directory
$form['layout']['layout_staff_directory'] = array(
'#type' => 'fieldset',
'#title' => t('Staff directory'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['layout']['layout_staff_directory']['layout_staff_directory_layout'] = array(
'#type' => 'select',
'#title' => t('Layout'),
'#default_value' => $settings['layout_staff_directory_layout'],
'#options' => $staff_directory_layout,
);
return $form;
}