1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Validatation for theme settings.
|
6
|
*
|
7
|
* @param $form
|
8
|
* @param $form_state
|
9
|
*/
|
10
|
function at_core_settings_validate($form, &$form_state) {
|
11
|
$values = $form_state['values'];
|
12
|
$theme_name = $form_state['build_info']['args'][0];
|
13
|
|
14
|
// "Design approach" uses radios, if this becomes unset for some reason bad
|
15
|
// things can happen.
|
16
|
if (empty($values['global_default_layout'])) {
|
17
|
form_set_error('global_default_layout', t('No setting detected for <b>Mobile first or Desktop first</b>. Please review "Settings > Mobile first or Desktop first" and select an option.'));
|
18
|
}
|
19
|
|
20
|
// For each breakpoint we need to have a layout selected
|
21
|
if (empty($values['bigscreen_layout'])) {
|
22
|
form_set_error('bigscreen_layout', t('No layout selection detected for the <b>Standard Layout</b>. Please review "Standard Layout > Choose sidebar positions" and select an option.'));
|
23
|
}
|
24
|
if (empty($values['tablet_landscape_layout'])) {
|
25
|
form_set_error('tablet_landscape_layout', t('No layout selection detected for the <b>Tablet Landscape Layout</b>. Please review "Tablet Layout > Landscape > Choose sidebar positions" and select an option.'));
|
26
|
}
|
27
|
if (empty($values['tablet_portrait_layout'])) {
|
28
|
form_set_error('tablet_portrait_layout', t('No layout selection detected for the <b>Tablet Portrait Layout</b>. Please review "Tablet Layout > Portrait > Choose sidebar positions" and select an option.'));
|
29
|
}
|
30
|
if (empty($values['smalltouch_landscape_layout'])) {
|
31
|
form_set_error('smalltouch_landscape_layout', t('No layout selection detected for the <b>Smalltouch Landscape Layout</b>. Please review "Smalltouch Layout > Landscape > Choose sidebar positions" and select an option.'));
|
32
|
}
|
33
|
|
34
|
// Validate our form #state required fields, #states are UI only.
|
35
|
|
36
|
// Bigscreen
|
37
|
if (empty($values['bigscreen_sidebar_first'])) {
|
38
|
form_set_error('bigscreen_sidebar_first', t('Standard Layout <em>First sidebar</em> width is empty - you must enter a value.'));
|
39
|
}
|
40
|
if (empty($values['bigscreen_sidebar_second'])) {
|
41
|
form_set_error('bigscreen_sidebar_second', t('Standard Layout <em>Second sidebar</em> width is empty - you must enter a value.'));
|
42
|
}
|
43
|
if ($values['bigscreen_set_max_width'] === 1) {
|
44
|
if (empty($values['bigscreen_max_width'])) {
|
45
|
form_set_error('bigscreen_max_width', t('Standard layout max-width is empty - enter a value or deselect "Set a max width".'));
|
46
|
}
|
47
|
}
|
48
|
|
49
|
// Tablet
|
50
|
if (empty($values['tablet_landscape_sidebar_first'])) {
|
51
|
form_set_error('tablet_landscape_sidebar_first', t('Tablet Landscape <em>First sidebar</em> width is empty - you must enter a value.'));
|
52
|
}
|
53
|
if ($values['tablet_landscape_layout'] === 'three_col_grail' || $values['tablet_landscape_layout'] === 'two_sidebars_left' || $values['tablet_landscape_layout'] === 'two_sidebars_right') {
|
54
|
if (empty($values['tablet_landscape_sidebar_second'])) {
|
55
|
form_set_error('tablet_landscape_sidebar_second', t('Tablet Landscape <em>First sidebar</em> width is empty - you must enter a value. The layout you selected requires values for both sidebars.'));
|
56
|
}
|
57
|
}
|
58
|
|
59
|
// Smalltouch
|
60
|
if ($values['smalltouch_landscape_layout'] === 'one_col_vert') {
|
61
|
if (empty($values['smalltouch_landscape_sidebar_first'])) {
|
62
|
form_set_error('smalltouch_landscape_sidebar_first', t('Smalltouch First Sidebar width is empty - enter a value or choose another layout.'));
|
63
|
}
|
64
|
if (empty($values['smalltouch_landscape_sidebar_second'])) {
|
65
|
form_set_error('smalltouch_landscape_sidebar_second', t('Smalltouch Second Sidebar width is empty - enter a value or choose another layout.'));
|
66
|
}
|
67
|
}
|
68
|
|
69
|
// Validate extensions
|
70
|
if (isset($values['enable_extensions']) && $values['enable_extensions'] === 1) {
|
71
|
// Apple touch icon paths
|
72
|
if (isset($values['enable_apple_touch_icons']) && $values['enable_apple_touch_icons'] === 1) {
|
73
|
if (!empty($values['apple_touch_icon_path_l'])) {
|
74
|
$l = drupal_get_path('theme', $theme_name) . '/' . $values['apple_touch_icon_path_l'];
|
75
|
if (!file_exists($l)) {
|
76
|
form_set_error('apple_touch_icon_path_l', t('Ops! The Apple touch 57x57 icon path is not right, check the file exists or the path to the file is correct.'));
|
77
|
}
|
78
|
}
|
79
|
if (!empty($values['apple_touch_icon_path_m'])) {
|
80
|
$m = drupal_get_path('theme', $theme_name) . '/' . $values['apple_touch_icon_path_m'];
|
81
|
if (!file_exists($m)) {
|
82
|
form_set_error('apple_touch_icon_path_m', t('Ops! The Apple touch 72x72 icon path is not right, check the file exists or the path to the file is correct.'));
|
83
|
}
|
84
|
}
|
85
|
if (!empty($values['apple_touch_icon_path_h'])) {
|
86
|
$h = drupal_get_path('theme', $theme_name) . '/' . $values['apple_touch_icon_path_h'];
|
87
|
if (!file_exists($h)) {
|
88
|
form_set_error('apple_touch_icon_path_h', t('Ops! The Apple touch 114x114 icon path is not right, check the file exists or the path to the file is correct.'));
|
89
|
}
|
90
|
}
|
91
|
}
|
92
|
// Gutter value
|
93
|
if (isset($values['enable_markup_overides']) && $values['enable_markup_overides'] === 1) {
|
94
|
if (!empty($values['global_gutter_width']) && !is_numeric($values['global_gutter_width'])) {
|
95
|
$invalid_gutter_value = check_plain($values['global_gutter_width']);
|
96
|
form_set_error('global_gutter_width', t('The gutter width is not valid: <b>!invalid_gutter_value</b> is not a usable value', array('!invalid_gutter_value' => $invalid_gutter_value)));
|
97
|
}
|
98
|
}
|
99
|
}
|
100
|
|
101
|
// Check if the custom files directory exists
|
102
|
if ($values['global_files_path'] == 'custom_path') {
|
103
|
$directory = $values['custom_files_path'];
|
104
|
if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) {
|
105
|
// If the directory does not exists and cannot be created.
|
106
|
form_set_error('custom_files_path', t('The directory %directory does not exist and could not be created.', array('%directory' => $directory)));
|
107
|
watchdog('file system', 'The directory %directory does not exist and could not be created.', array('%directory' => $directory), WATCHDOG_ERROR);
|
108
|
}
|
109
|
}
|
110
|
}
|