1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
function kanji_form_system_theme_settings_alter(&$form, &$form_state, $form_id = NULL) {
|
6 |
|
|
if (isset($form_id)) {
|
7 |
|
|
return;
|
8 |
|
|
}
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
$form['kanji'] = array(
|
12 |
|
|
|
13 |
|
|
'#default_tab' => 'defaults',
|
14 |
|
|
);
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
$form['kanji']['breadcrumb'] = array(
|
18 |
|
|
'#type' => 'fieldset',
|
19 |
|
|
'#weight' => '5',
|
20 |
|
|
'#title' => t('Breadcrumbs'),
|
21 |
|
|
);
|
22 |
|
|
$form['kanji']['breadcrumb']['bd']['breadcrumb_display'] = array(
|
23 |
|
|
'#type' => 'select',
|
24 |
|
|
'#title' => t('Show breadcrumbs'),
|
25 |
|
|
'#default_value' => theme_get_setting('breadcrumb_display'),
|
26 |
|
|
'#options' => array(
|
27 |
|
|
'yes' => t('Yes'),
|
28 |
|
|
'no' => t('No'),
|
29 |
|
|
),
|
30 |
|
|
);
|
31 |
|
|
|
32 |
|
|
$form['background'] = array(
|
33 |
|
|
'#type' => 'fieldset',
|
34 |
|
|
'#title' => t('Background settings'),
|
35 |
|
|
);
|
36 |
|
|
|
37 |
|
|
$form['background']['default_background'] = array(
|
38 |
|
|
'#type' => 'checkbox',
|
39 |
|
|
'#title' => t('Use the default background-image'),
|
40 |
|
|
'#default_value' => (theme_get_setting('default_background') == 0 ? theme_get_setting('default_background') : 1),
|
41 |
|
|
);
|
42 |
|
|
|
43 |
|
|
$form['background']['settings'] = array(
|
44 |
|
|
'#type' => 'container',
|
45 |
|
|
'#states' => array(
|
46 |
|
|
'invisible' => array(
|
47 |
|
|
'input[name="default_background"]' => array('checked' => TRUE),
|
48 |
|
|
),
|
49 |
|
|
),
|
50 |
|
|
);
|
51 |
|
|
|
52 |
|
|
$form['background']['settings']['path_background'] = array(
|
53 |
|
|
'#type' => 'textfield',
|
54 |
|
|
'#title' => t('Current used background-image'),
|
55 |
|
|
'#default_value' => variable_get('kanji:path_background', ''),
|
56 |
|
|
);
|
57 |
|
|
|
58 |
|
|
$form['background']['settings']['upload_background'] = array(
|
59 |
|
|
'#type' => 'file',
|
60 |
|
|
'#title' => t('Upload a background image'),
|
61 |
|
|
);
|
62 |
|
|
|
63 |
|
|
$form['background']['settings']['background_color'] = array(
|
64 |
|
|
'#type' => 'checkbox',
|
65 |
|
|
'#title' => t('Use background color'),
|
66 |
|
|
'#description' => t('This will remove the background-image'),
|
67 |
|
|
'#default_value' => (theme_get_setting('background_color') == 0 ? theme_get_setting('background_color') : 1),
|
68 |
|
|
);
|
69 |
|
|
|
70 |
|
|
$form['background']['settings']['background_color_value'] = array(
|
71 |
|
|
'#type' => 'textfield',
|
72 |
|
|
'#title' => t('Provide the backgroundcolor'),
|
73 |
|
|
'#description' => t('Give the value for the background-color, example: FFF, 000'),
|
74 |
|
|
'#default_value' => variable_get('kanji:background_color_value', ''),
|
75 |
|
|
'#field_prefix' => '#',
|
76 |
|
|
'#states' => array(
|
77 |
|
|
'invisible' => array(
|
78 |
|
|
'input[name="background_color"]' => array('checked' => FALSE),
|
79 |
|
|
),
|
80 |
|
|
),
|
81 |
|
|
);
|
82 |
|
|
|
83 |
|
|
$form['#validate'][] = 'kanji_theme_settings_validate';
|
84 |
|
|
$form['#submit'][] = 'kanji_theme_settings_submit';
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
function kanji_theme_settings_validate($form, &$form_state) {
|
88 |
|
|
|
89 |
|
|
$validators = array('file_validate_is_image' => array());
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
$file = file_save_upload('upload_background', $validators, FALSE, FILE_EXISTS_REPLACE);
|
93 |
|
|
|
94 |
|
|
if (isset($file)) {
|
95 |
|
|
|
96 |
|
|
if ($file) {
|
97 |
|
|
|
98 |
|
|
$form_state['values']['upload_background'] = $file;
|
99 |
|
|
}
|
100 |
|
|
else {
|
101 |
|
|
|
102 |
|
|
form_set_error('upload_background', t('The header could not be uploaded.'));
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
if ($form_state['values']['path_background']) {
|
109 |
|
|
$path = _system_theme_settings_validate_path($form_state['values']['path_background']);
|
110 |
|
|
if (!$path) {
|
111 |
|
|
form_set_error('path_background', t('The custom header path is invalid.'));
|
112 |
|
|
}
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
if ($form_state['values']['background_color'] == true && !empty($form_state['values']['background_color_value'])) {
|
116 |
|
|
if (!preg_match("/^[A-Za-z0-9]+$/", $form_state['values']['background_color_value'])) {
|
117 |
|
|
form_set_error('background_color_value', t('The color must be a HEX value, example ff0000'));
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
function kanji_theme_settings_submit($form, &$form_state) {
|
123 |
|
|
$values = $form_state['values'];
|
124 |
|
|
|
125 |
|
|
|
126 |
|
|
if ($file = $values['upload_background']) {
|
127 |
|
|
unset($values['upload_background']);
|
128 |
|
|
$filename = file_unmanaged_copy($file->uri, NULL, FILE_EXISTS_REPLACE);
|
129 |
|
|
$values['path_background'] = $filename;
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
if (!empty($values['path_background'])) {
|
135 |
|
|
$values['path_background'] = _system_theme_settings_validate_path($values['path_background']);
|
136 |
|
|
variable_set('kanji:path_background', $values['path_background']);
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
if (!empty($values['background_color_value'])) {
|
140 |
|
|
variable_set('kanji:background_color_value', $values['background_color_value']);
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
if ($values['default_background'] == 1) {
|
145 |
|
|
variable_del('kanji:path_background');
|
146 |
|
|
variable_del('kanji:background_color_value');
|
147 |
|
|
}
|
148 |
|
|
}
|