1
|
<?php
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
function adminimal_form_system_theme_settings_alter(&$form, &$form_state) {
|
18
|
|
19
|
|
20
|
global $base_url;
|
21
|
$adminimal_path = drupal_get_path('theme', 'adminimal');
|
22
|
$old_css_path = $adminimal_path . '/css/custom.css';
|
23
|
$custom_css_path = 'public://adminimal-custom.css';
|
24
|
$custom_css_dir = str_replace($base_url . '/', "", file_create_url($custom_css_path));
|
25
|
$custom_css_url = file_create_url($custom_css_path);
|
26
|
|
27
|
|
28
|
if (!file_exists($custom_css_path)) {
|
29
|
|
30
|
|
31
|
if (file_exists($old_css_path)) {
|
32
|
file_unmanaged_copy($old_css_path, $custom_css_path, FILE_EXISTS_ERROR);
|
33
|
}
|
34
|
|
35
|
else {
|
36
|
file_unmanaged_save_data("", $custom_css_path, FILE_EXISTS_ERROR);
|
37
|
}
|
38
|
|
39
|
}
|
40
|
|
41
|
|
42
|
if (file_exists($old_css_path)) {
|
43
|
drupal_set_message(t('Please delete the old @css_location file, as its no longer used.', array('@css_location file' => $old_css_path)), 'warning');
|
44
|
}
|
45
|
|
46
|
$form['adminimal_custom'] = array(
|
47
|
'#type' => 'fieldset',
|
48
|
'#title' => t('Adminimal Customization'),
|
49
|
'#weight' => -10,
|
50
|
);
|
51
|
|
52
|
$form['adminimal_custom']['display_icons_config'] = array(
|
53
|
'#type' => 'checkbox',
|
54
|
'#title' => t('Display icons in Configuration page'),
|
55
|
'#default_value' => theme_get_setting('display_icons_config'),
|
56
|
);
|
57
|
|
58
|
$form['adminimal_custom']['use_custom_media_queries'] = array(
|
59
|
'#type' => 'checkbox',
|
60
|
'#title' => t('Use Custom Media Queries'),
|
61
|
'#description' => t('You can override the mobile and tablet media queries from this option. Use it only if you know what media queries are and how to use them.'),
|
62
|
'#default_value' => theme_get_setting('use_custom_media_queries'),
|
63
|
);
|
64
|
|
65
|
$form['adminimal_custom']['media_queries'] = array(
|
66
|
'#type' => 'fieldset',
|
67
|
'#title' => t('Custom Media Queries'),
|
68
|
'#states' => array(
|
69
|
|
70
|
'visible' => array(
|
71
|
':input[name="use_custom_media_queries"]' => array('checked' => TRUE),
|
72
|
),
|
73
|
),
|
74
|
);
|
75
|
|
76
|
$form['adminimal_custom']['media_queries']['media_query_mobile'] = array(
|
77
|
'#type' => 'textfield',
|
78
|
'#title' => t('Mobile media query'),
|
79
|
'#description' => t('The media query to load the mobile.css styles.'),
|
80
|
'#default_value' => theme_get_setting('media_query_mobile'),
|
81
|
);
|
82
|
|
83
|
$form['adminimal_custom']['media_queries']['media_query_tablet'] = array(
|
84
|
'#type' => 'textfield',
|
85
|
'#title' => t('Tablet media query'),
|
86
|
'#description' => t('The media query to load the tablet.css styles.'),
|
87
|
'#default_value' => theme_get_setting('media_query_tablet'),
|
88
|
);
|
89
|
|
90
|
$form['adminimal_custom']['custom_css'] = array(
|
91
|
'#type' => 'checkbox',
|
92
|
'#title' => t('Use "adminimal-custom.css"'),
|
93
|
'#description' => t('Include adminimal-custom.css file to override or add custom css code without subthememing/hacking Adminimal Theme.'),
|
94
|
'#default_value' => theme_get_setting('custom_css'),
|
95
|
);
|
96
|
|
97
|
$form['adminimal_custom']['adminimal_custom_check'] = array(
|
98
|
'#type' => 'fieldset',
|
99
|
'#title' => t('Custom CSS file check'),
|
100
|
'#weight' => 50,
|
101
|
'#states' => array(
|
102
|
|
103
|
'visible' => array(
|
104
|
':input[name="custom_css"]' => array('checked' => TRUE),
|
105
|
),
|
106
|
),
|
107
|
);
|
108
|
|
109
|
if (file_exists($custom_css_path)) {
|
110
|
$form['adminimal_custom']['adminimal_custom_check']['custom_css_description'] = array(
|
111
|
'#markup' => t('Custom CSS file Found in: !css', array('!css' => "<span class='css_path'>" . $custom_css_dir . "</span>")),
|
112
|
'#prefix' => '<div class="messages status custom_css_found">',
|
113
|
'#suffix' => '</div>',
|
114
|
);
|
115
|
}
|
116
|
else {
|
117
|
$form['adminimal_custom']['adminimal_custom_check']['custom_css_not_found'] = array(
|
118
|
'#markup' => t('Custom CSS file not found. You must create the !css file manually.', array('!css' => "<span class='css_path'>" . $custom_css_dir . "</span>")),
|
119
|
'#prefix' => '<div class="messages error custom_css_not_found">',
|
120
|
'#suffix' => '</div>',
|
121
|
);
|
122
|
}
|
123
|
}
|