1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Generate form elments for the font settings.
|
6
|
*/
|
7
|
function at_core_fonts_form(&$form) {
|
8
|
// Get the font elements array, this holds options and settings for each font type
|
9
|
$form_elements = font_elements();
|
10
|
|
11
|
// Get the font size lists
|
12
|
$font_sizes_em = font_sizes('em');
|
13
|
$font_sizes_p = font_sizes('p');
|
14
|
|
15
|
// Get the google charsets and styles
|
16
|
$google_charsets = google_font_charsets();
|
17
|
$google_styles = google_font_styles();
|
18
|
|
19
|
// Build a message for fonts depending on what is enabled
|
20
|
$fonts_message = t('<h3>Fonts</h3><p>First select the font type — websafe, google or custom — then select or enter the required information depending on the type. Adaptivetheme can also support any font supplied by the <a href="!module_fyf" target="_blank">@font-your-face module</a>, new settings and instructions will appear after you have installed @font-your-face.</p><p>To preview and gather required information for adding Google fonts see: <a href="!gwf" target="_blank">google.com/webfonts</a>. If you are adding extra styles or character sets these must exist for the specified font — use the <em>Quick-use</em> feature in Google fonts to check this information.</p>',
|
21
|
array(
|
22
|
'!gwf' => 'http://www.google.com/webfonts',
|
23
|
'!cfs' => 'http://coding.smashingmagazine.com/2009/09/22/complete-guide-to-css-font-stacks/',
|
24
|
'!module_fyf' => 'http://drupal.org/project/fontyourface',
|
25
|
)
|
26
|
);
|
27
|
|
28
|
// Build a list of font type options
|
29
|
$font_type_options = array(
|
30
|
'<none>' => 'None',
|
31
|
'' => 'Websafe fonts',
|
32
|
'gwf' => 'Basic Google font',
|
33
|
'cfs' => 'Custom font stack',
|
34
|
);
|
35
|
|
36
|
// Do some stuff if @font-your-face is enabled
|
37
|
$font_your_face_enabled = FALSE;
|
38
|
if (module_exists('fontyourface')) {
|
39
|
// add an option to the font type settings
|
40
|
$font_your_face_enabled = font_your_face_fonts_enabled();
|
41
|
if ($font_your_face_enabled == TRUE) {
|
42
|
$fyf_type = array('fyf' => '@font-your-face');
|
43
|
$font_type_options = array_merge($font_type_options, $fyf_type);
|
44
|
}
|
45
|
|
46
|
// Special message once font your face in installed
|
47
|
$browse_fyf = l(t('@font-your-face library'), 'admin/appearance/fontyourface/browse', array('attributes' => array('target' => array('_blank'))));
|
48
|
$settings_fyf = l(t('"add selector in theme CSS"'), 'admin/appearance/fontyourface', array('attributes' => array('target' => array('_blank'))));
|
49
|
$fonts_message = t('<h3>Fonts</h3><p>First select the font type — websafe, google, custom or @font-your-face — then select or enter the required information depending on the type. To use @font-your-face you must first enable fonts in the !browse_fyf, then set those fonts to !settings_fyf. When you have done this the @font-your-face fonts will be availble here for you to apply to your content and titles. @font-your-face integration has only been tested with Google and Font Squirrel.</p><p>To preview and gather required information for adding Google fonts see: <a href="!gwf" target="_blank">google.com/webfonts</a>. If you are adding extra styles or character sets these must exist for the specified font — use the <em>Quick-use</em> feature in Google fonts to check this information.</p>',
|
50
|
array(
|
51
|
'!gwf' => 'http://www.google.com/webfonts',
|
52
|
'!cfs' => 'http://coding.smashingmagazine.com/2009/09/22/complete-guide-to-css-font-stacks/',
|
53
|
'!browse_fyf' => $browse_fyf,
|
54
|
'!settings_fyf' => $settings_fyf,
|
55
|
)
|
56
|
);
|
57
|
}
|
58
|
|
59
|
// Some re-usable strings, fixing things in multiple places annoys me
|
60
|
$google_font_description = t('Paste the Google font name, e.g. <code>Open Sans Condensed</code>. Only add one font.');
|
61
|
$custom_stack_description = t("Enter a comma seperated list of fonts, with no trailing comma. Names with spaces should be wrapped in single quotes, for example <code>'Times New Roman'</code>.");
|
62
|
|
63
|
// Fonts
|
64
|
$form['at']['font'] = array(
|
65
|
'#type' => 'fieldset',
|
66
|
'#title' => t('Fonts'),
|
67
|
'#description' => $fonts_message,
|
68
|
'#attributes' => array('class' => array('font-element-wrapper')),
|
69
|
'#weight' => -110,
|
70
|
);
|
71
|
|
72
|
// Base font - global font family unless overridden by a more specific selector
|
73
|
$form['at']['font']['base-font'] = array(
|
74
|
'#type' => 'fieldset',
|
75
|
'#title' => t('Default font'),
|
76
|
);
|
77
|
$form['at']['font']['base-font']['base_font_type'] = array(
|
78
|
'#type' => 'select',
|
79
|
'#title' => t('Type'),
|
80
|
'#options' => $font_type_options,
|
81
|
'#default_value' => at_get_setting('base_font_type'),
|
82
|
);
|
83
|
$form['at']['font']['base-font']['base_font'] = array(
|
84
|
'#type' => 'select',
|
85
|
'#title' => t('Font'),
|
86
|
'#default_value' => at_get_setting('base_font'),
|
87
|
'#options' => str_replace("'", "", font_list('wsf', 'bf')),
|
88
|
'#states' => array('visible' => array('select[name="base_font_type"]' => array('value' => ''))),
|
89
|
);
|
90
|
|
91
|
// Google web font
|
92
|
$form['at']['font']['base-font']['base_font_gwf'] = array(
|
93
|
'#type' => 'textfield',
|
94
|
'#title' => t('Google Font Name'),
|
95
|
'#default_value' => filter_xss_admin(at_get_setting('base_font_gwf')),
|
96
|
'#description' => $google_font_description,
|
97
|
'#states' => array('visible' => array('select[name="base_font_type"]' => array('value' => 'gwf'))),
|
98
|
);
|
99
|
$form['at']['font']['base-font']['base_font_gwf_styles'] = array(
|
100
|
'#type' => 'fieldset',
|
101
|
'#title' => t('Add Google Font Styles'),
|
102
|
'#states' => array('visible' => array('select[name="base_font_type"]' => array('value' => 'gwf'))),
|
103
|
);
|
104
|
$form['at']['font']['base-font']['base_font_gwf_styles']['base_font_gwf_add_styles'] = array(
|
105
|
'#type' => 'checkbox',
|
106
|
'#title' => t('Styles'),
|
107
|
'#default_value' => at_get_setting('base_font_gwf_add_styles'),
|
108
|
);
|
109
|
foreach ($google_styles as $style_key => $style_value) {
|
110
|
$form['at']['font']['base-font']['base_font_gwf_styles']["base_font_gwf_add_styles_$style_key"] = array(
|
111
|
'#type' => 'checkbox',
|
112
|
'#title' => t($style_value),
|
113
|
'#default_value' => at_get_setting("base_font_gwf_add_styles_$style_key"),
|
114
|
'#states' => array('visible' => array('input[name="base_font_gwf_add_styles"]' => array('checked' => TRUE))),
|
115
|
);
|
116
|
}
|
117
|
$form['at']['font']['base-font']['base_font_gwf_charsets'] = array(
|
118
|
'#type' => 'fieldset',
|
119
|
'#title' => t('Add Google Font Character Sets'),
|
120
|
'#states' => array('visible' => array('select[name="base_font_type"]' => array('value' => 'gwf'))),
|
121
|
);
|
122
|
$form['at']['font']['base-font']['base_font_gwf_charsets']['base_font_gwf_add_charsets'] = array(
|
123
|
'#type' => 'checkbox',
|
124
|
'#title' => t('Character Sets'),
|
125
|
'#default_value' => at_get_setting('base_font_gwf_add_charsets'),
|
126
|
'#states' => array('visible' => array('select[name="base_font_type"]' => array('value' => 'gwf'))),
|
127
|
);
|
128
|
foreach ($google_charsets as $charset_key => $charset_value) {
|
129
|
$form['at']['font']['base-font']['base_font_gwf_charsets']["base_font_gwf_add_charsets_$charset_key"] = array(
|
130
|
'#type' => 'checkbox',
|
131
|
'#title' => t($charset_value),
|
132
|
'#default_value' => at_get_setting("base_font_gwf_add_charsets_$charset_key"),
|
133
|
'#states' => array('visible' => array('input[name="base_font_gwf_add_charsets"]' => array('checked' => TRUE))),
|
134
|
);
|
135
|
}
|
136
|
|
137
|
// Custom font stack
|
138
|
$form['at']['font']['base-font']['base_font_cfs'] = array(
|
139
|
'#type' => 'textfield',
|
140
|
'#title' => t('Font'),
|
141
|
'#default_value' => filter_xss_admin(at_get_setting('base_font_cfs')),
|
142
|
'#description' => $custom_stack_description,
|
143
|
'#states' => array(
|
144
|
'visible' => array('select[name="base_font_type"]' => array('value' => 'cfs')),
|
145
|
'required' => array('select[name="base_font_type"]' => array('value' => 'cfs')),
|
146
|
)
|
147
|
);
|
148
|
|
149
|
// Font your face
|
150
|
if ($font_your_face_enabled == TRUE) {
|
151
|
$form['at']['font']['base-font']['base_font_fyf'] = array(
|
152
|
'#type' => 'select',
|
153
|
'#title' => t('Font'),
|
154
|
'#default_value' => at_get_setting('base_font_fyf'),
|
155
|
'#options' => font_list('fyf', 'bf'),
|
156
|
'#states' => array('visible' => array('select[name="base_font_type"]' => array('value' => 'fyf'))),
|
157
|
);
|
158
|
}
|
159
|
|
160
|
// Size
|
161
|
$form['at']['font']['base-font']['base_font_size'] = array(
|
162
|
'#type' => 'select',
|
163
|
'#title' => t('Size'),
|
164
|
'#options' => $font_sizes_p,
|
165
|
'#description' => t('The default font size is set on the HTML element. All elements, margins, padding and widths using a relative unit such as em or % will scale relative to this value. Use "Not set" if you prefer to set this in your CSS. You can override this value in your responsive stylesheets also, to use a larger or smaller default size for different device types.'),
|
166
|
'#default_value' => at_get_setting('base_font_size'),
|
167
|
'#attributes' => array('class' => array('font-size-wrapper')),
|
168
|
);
|
169
|
|
170
|
// Titles
|
171
|
$form['at']['font']['titles'] = array(
|
172
|
'#type' => 'fieldset',
|
173
|
'#title' => t('Titles'),
|
174
|
'#collapsible' => TRUE,
|
175
|
'#collapsed' => TRUE,
|
176
|
);
|
177
|
foreach ($form_elements as $key => $value) {
|
178
|
|
179
|
$form_type = $key;
|
180
|
$font_element_type = $value['type'];
|
181
|
|
182
|
if ($font_element_type === 'title') {
|
183
|
|
184
|
$element = $value['element']; // e.g. "bf" (base-font), this is used to set array keys
|
185
|
$setting = $value['setting']; // the theme setting used to retrieve the font values, e.g. "site_name_font"
|
186
|
|
187
|
$setting_container = str_replace('_', '-', $setting) . '-selector'; // a nicer string for fielset classes
|
188
|
$title = str_replace('_', ' ', drupal_ucfirst($form_type)); // use the key for titles, it doesnt have "font" in it
|
189
|
|
190
|
// Set easy reusable variables
|
191
|
$setting_type = $setting . '_type';
|
192
|
$setting_font = $setting . '_font';
|
193
|
$setting_gwf = $setting . '_gwf';
|
194
|
$setting_cfs = $setting . '_cfs';
|
195
|
$setting_yfy = $setting . '_fyf';
|
196
|
$setting_size = $setting . '_size';
|
197
|
|
198
|
$form['at']['font']['titles'][$setting_container] = array(
|
199
|
'#type' => 'fieldset',
|
200
|
'#title' => t($title),
|
201
|
);
|
202
|
$form['at']['font']['titles'][$setting_container][$setting_type] = array(
|
203
|
'#type' => 'select',
|
204
|
'#title' => t('Type'),
|
205
|
'#options' => $font_type_options,
|
206
|
'#default_value' => at_get_setting($setting_type),
|
207
|
);
|
208
|
$form['at']['font']['titles'][$setting_container][$setting] = array(
|
209
|
'#type' => 'select',
|
210
|
'#title' => t('Font'),
|
211
|
'#default_value' => at_get_setting($setting),
|
212
|
'#options' => str_replace("'", "", font_list('wsf', $element)),
|
213
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => ''))),
|
214
|
);
|
215
|
|
216
|
// Google web fonts
|
217
|
$form['at']['font']['titles'][$setting_container][$setting_gwf] = array(
|
218
|
'#type' => 'textfield',
|
219
|
'#title' => t('Google Font Name'),
|
220
|
'#default_value' => filter_xss_admin(at_get_setting($setting_gwf)),
|
221
|
'#description' => $google_font_description,
|
222
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
223
|
);
|
224
|
$title_styles_setting = $setting_gwf . '_add_styles';
|
225
|
$form['at']['font']['titles'][$setting_container][$setting_container . '_gwf_styles'] = array(
|
226
|
'#type' => 'fieldset',
|
227
|
'#title' => t('Add Google Font Styles'),
|
228
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
229
|
);
|
230
|
$form['at']['font']['titles'][$setting_container][$setting_container . '_gwf_styles'][$title_styles_setting] = array(
|
231
|
'#type' => 'checkbox',
|
232
|
'#title' => t('Styles'),
|
233
|
'#default_value' => at_get_setting($title_styles_setting),
|
234
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
235
|
);
|
236
|
foreach ($google_styles as $style_key => $style_value) {
|
237
|
$form['at']['font']['titles'][$setting_container][$setting_container . '_gwf_styles'][$title_styles_setting . '_' . $style_key] = array(
|
238
|
'#type' => 'checkbox',
|
239
|
'#title' => t($style_value),
|
240
|
'#default_value' => at_get_setting($title_styles_setting . '_' . $style_key),
|
241
|
'#states' => array('visible' => array(":input[name=$title_styles_setting]" => array('checked' => TRUE))),
|
242
|
);
|
243
|
}
|
244
|
$title_charsets_setting = $setting_gwf . '_add_charsets';
|
245
|
$form['at']['font']['titles'][$setting_container][$setting_container . '_gwf_charsets'] = array(
|
246
|
'#type' => 'fieldset',
|
247
|
'#title' => t('Add Google Font Character Sets'),
|
248
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
249
|
);
|
250
|
$form['at']['font']['titles'][$setting_container][$setting_container . '_gwf_charsets'][$title_charsets_setting] = array(
|
251
|
'#type' => 'checkbox',
|
252
|
'#title' => t('Character Sets'),
|
253
|
'#default_value' => at_get_setting($title_charsets_setting),
|
254
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
255
|
);
|
256
|
foreach ($google_charsets as $charset_key => $charset_value) {
|
257
|
$form['at']['font']['titles'][$setting_container][$setting_container . '_gwf_charsets'][$title_charsets_setting . '_' . $charset_key] = array(
|
258
|
'#type' => 'checkbox',
|
259
|
'#title' => t($charset_value),
|
260
|
'#default_value' => at_get_setting($title_charsets_setting . '_' . $charset_key),
|
261
|
'#states' => array('visible' => array(":input[name=$title_charsets_setting]" => array('checked' => TRUE))),
|
262
|
);
|
263
|
}
|
264
|
|
265
|
// Custom font stack
|
266
|
$form['at']['font']['titles'][$setting_container][$setting_cfs] = array(
|
267
|
'#type' => 'textfield',
|
268
|
'#title' => t('Font'),
|
269
|
'#default_value' => drupal_strip_dangerous_protocols(at_get_setting($setting_cfs)),
|
270
|
'#description' => $custom_stack_description,
|
271
|
'#states' => array(
|
272
|
'visible' => array('select[name=' . $setting_type . ']' => array('value' => 'cfs')),
|
273
|
'required' => array('select[name=' . $setting_type . ']' => array('value' => 'cfs')),
|
274
|
),
|
275
|
);
|
276
|
|
277
|
// Font your face
|
278
|
if ($font_your_face_enabled == TRUE) {
|
279
|
$form['at']['font']['titles'][$setting_container][$setting_yfy] = array(
|
280
|
'#type' => 'select',
|
281
|
'#title' => t('Font'),
|
282
|
'#default_value' => at_get_setting($setting_yfy),
|
283
|
'#options' => font_list('fyf', $element),
|
284
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'fyf'))),
|
285
|
);
|
286
|
}
|
287
|
|
288
|
// Size
|
289
|
$form['at']['font']['titles'][$setting_container][$setting_size] = array(
|
290
|
'#type' => 'select',
|
291
|
'#title' => t('Size'),
|
292
|
'#options' => $font_sizes_em,
|
293
|
'#default_value' => at_get_setting($setting_size),
|
294
|
'#attributes' => array('class' => array('font-size-wrapper')),
|
295
|
);
|
296
|
}
|
297
|
}
|
298
|
|
299
|
// In Content Headings
|
300
|
$form['at']['font']['headings'] = array(
|
301
|
'#type' => 'fieldset',
|
302
|
'#title' => t('Headings'),
|
303
|
'#collapsible' => TRUE,
|
304
|
'#collapsed' => TRUE,
|
305
|
);
|
306
|
foreach ($form_elements as $key => $value) {
|
307
|
|
308
|
$form_type = $key;
|
309
|
$font_element_subtype = $value['subtype'];
|
310
|
|
311
|
// we have to handle subgroups seperatly
|
312
|
if ($font_element_subtype === 'heading_group') {
|
313
|
|
314
|
// e.g. "bf" (base-font), this is used to set array keys
|
315
|
$element = $value['element'];
|
316
|
|
317
|
// the theme setting used to retrieve the font values, e.g. "site_name_font"
|
318
|
$setting = $value['setting'];
|
319
|
|
320
|
// a nicer string for fielset classes
|
321
|
$setting_container = str_replace('_', '-', $setting) . '-selector';
|
322
|
|
323
|
// Custom titles
|
324
|
if ($element === 'h1h4') {
|
325
|
$title = 'h1 to h4';
|
326
|
}
|
327
|
else {
|
328
|
$title = 'h5 and h6';
|
329
|
}
|
330
|
|
331
|
// Set easy reusable variables
|
332
|
$setting_type = $setting . '_type';
|
333
|
$setting_font = $setting . '_font';
|
334
|
$setting_gwf = $setting . '_gwf';
|
335
|
$setting_cfs = $setting . '_cfs';
|
336
|
$setting_yfy = $setting . '_fyf';
|
337
|
|
338
|
$form['at']['font']['headings'][$setting_container] = array(
|
339
|
'#type' => 'fieldset',
|
340
|
'#title' => t($title),
|
341
|
);
|
342
|
$form['at']['font']['headings'][$setting_container][$setting_type] = array(
|
343
|
'#type' => 'select',
|
344
|
'#title' => t('Type'),
|
345
|
'#options' => $font_type_options,
|
346
|
'#default_value' => at_get_setting($setting_type),
|
347
|
);
|
348
|
$form['at']['font']['headings'][$setting_container][$setting] = array(
|
349
|
'#type' => 'select',
|
350
|
'#title' => t('Font'),
|
351
|
'#default_value' => at_get_setting($setting),
|
352
|
'#options' => str_replace("'", "", font_list('wsf', $element)),
|
353
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => ''))),
|
354
|
);
|
355
|
|
356
|
// Google web fonts
|
357
|
$form['at']['font']['headings'][$setting_container][$setting_gwf] = array(
|
358
|
'#type' => 'textfield',
|
359
|
'#title' => t('Google Font Name'),
|
360
|
'#default_value' => filter_xss_admin(at_get_setting($setting_gwf)),
|
361
|
'#description' => $google_font_description,
|
362
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
363
|
);
|
364
|
$headings_styles_setting = $setting_gwf . '_add_styles';
|
365
|
$form['at']['font']['headings'][$setting_container][$setting_container . '_gwf_styles'] = array(
|
366
|
'#type' => 'fieldset',
|
367
|
'#title' => t('Add Google Font Styles'),
|
368
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
369
|
);
|
370
|
$form['at']['font']['headings'][$setting_container][$setting_container . '_gwf_styles'][$headings_styles_setting] = array(
|
371
|
'#type' => 'checkbox',
|
372
|
'#title' => t('Styles'),
|
373
|
'#default_value' => at_get_setting($headings_styles_setting),
|
374
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
375
|
);
|
376
|
foreach ($google_styles as $style_key => $style_value) {
|
377
|
$form['at']['font']['headings'][$setting_container][$setting_container . '_gwf_styles'][$headings_styles_setting . '_' . $style_key] = array(
|
378
|
'#type' => 'checkbox',
|
379
|
'#title' => t($style_value),
|
380
|
'#default_value' => at_get_setting($headings_styles_setting . '_' . $style_key),
|
381
|
'#states' => array('visible' => array(":input[name=$headings_styles_setting]" => array('checked' => TRUE))),
|
382
|
);
|
383
|
}
|
384
|
$headings_charsets_setting = $setting_gwf . '_add_charsets';
|
385
|
$form['at']['font']['headings'][$setting_container][$setting_container . '_gwf_charsets'] = array(
|
386
|
'#type' => 'fieldset',
|
387
|
'#title' => t('Add Google Font Character Sets'),
|
388
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
389
|
);
|
390
|
$form['at']['font']['headings'][$setting_container][$setting_container . '_gwf_charsets'][$headings_charsets_setting] = array(
|
391
|
'#type' => 'checkbox',
|
392
|
'#title' => t('Character Sets'),
|
393
|
'#default_value' => at_get_setting($headings_charsets_setting),
|
394
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
395
|
);
|
396
|
foreach ($google_charsets as $charset_key => $charset_value) {
|
397
|
$form['at']['font']['headings'][$setting_container][$setting_container . '_gwf_charsets'][$headings_charsets_setting . '_' . $charset_key] = array(
|
398
|
'#type' => 'checkbox',
|
399
|
'#title' => t($charset_value),
|
400
|
'#default_value' => at_get_setting($headings_charsets_setting . '_' . $charset_key),
|
401
|
'#states' => array('visible' => array(":input[name=$headings_charsets_setting]" => array('checked' => TRUE))),
|
402
|
);
|
403
|
}
|
404
|
|
405
|
// Custom font stacks
|
406
|
$form['at']['font']['headings'][$setting_container][$setting_cfs] = array(
|
407
|
'#type' => 'textfield',
|
408
|
'#title' => t('Font'),
|
409
|
'#default_value' => filter_xss_admin(at_get_setting($setting_cfs)),
|
410
|
'#description' => $custom_stack_description,
|
411
|
'#states' => array(
|
412
|
'visible' => array('select[name=' . $setting_type . ']' => array('value' => 'cfs')),
|
413
|
'required' => array('select[name=' . $setting_type . ']' => array('value' => 'cfs')),
|
414
|
),
|
415
|
);
|
416
|
|
417
|
// Font your face
|
418
|
if ($font_your_face_enabled == TRUE) {
|
419
|
$form['at']['font']['headings'][$setting_container][$setting_yfy] = array(
|
420
|
'#type' => 'select',
|
421
|
'#title' => t('Font'),
|
422
|
'#default_value' => at_get_setting($setting_yfy),
|
423
|
'#options' => font_list('fyf', $element),
|
424
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'fyf'))),
|
425
|
);
|
426
|
}
|
427
|
}
|
428
|
}
|
429
|
|
430
|
// Size for in-content headings
|
431
|
$form['at']['font']['headings']['sizes'] = array(
|
432
|
'#type' => 'fieldset',
|
433
|
'#title' => t('Size'),
|
434
|
'#attributes' => array('class' => array('font-element-wrapper'))
|
435
|
);
|
436
|
foreach ($form_elements as $key => $value) {
|
437
|
|
438
|
$form_type = $key;
|
439
|
$font_element_subtype = $value['subtype'];
|
440
|
|
441
|
// we have to handle subgroups seperatly
|
442
|
if ($font_element_subtype === 'heading_level') {
|
443
|
|
444
|
// e.g. "bf" (base-font), this is used to set array keys
|
445
|
$element = $value['element'];
|
446
|
|
447
|
// the theme setting used to retrieve the font values, e.g. "site_name_font"
|
448
|
$setting = $value['setting'];
|
449
|
|
450
|
// Set easy reusable variables
|
451
|
$setting_type = $setting . '_type';
|
452
|
$setting_size = $setting . '_size';
|
453
|
|
454
|
$form['at']['font']['headings']['sizes'][$setting_size] = array(
|
455
|
'#type' => 'select',
|
456
|
'#title' => t($element), // element as title is fine in this context
|
457
|
'#options' => $font_sizes_em,
|
458
|
'#default_value' => at_get_setting($setting_size),
|
459
|
'#attributes' => array('class' => array('font-size-wrapper')),
|
460
|
);
|
461
|
}
|
462
|
}
|
463
|
|
464
|
// Menus
|
465
|
$form['at']['font']['menus'] = array(
|
466
|
'#type' => 'fieldset',
|
467
|
'#title' => t('Menus'),
|
468
|
'#collapsible' => TRUE,
|
469
|
'#collapsed' => TRUE,
|
470
|
);
|
471
|
foreach ($form_elements as $key => $value) {
|
472
|
|
473
|
$form_type = $key;
|
474
|
$font_element_type = $value['type'];
|
475
|
|
476
|
if ($font_element_type === 'menu') {
|
477
|
|
478
|
// e.g. "bf" (base-font), this is used to set array keys
|
479
|
$element = $value['element'];
|
480
|
|
481
|
// the theme setting used to retrieve the font values, e.g. "site_name_font"
|
482
|
$setting = $value['setting'];
|
483
|
|
484
|
// a nicer string for fielset classes
|
485
|
$setting_container = str_replace('_', '-', $setting) . '-selector';
|
486
|
|
487
|
// use the key for titles, it doesnt have "font" in it
|
488
|
$title = str_replace('_', ' ', drupal_ucfirst($form_type));
|
489
|
|
490
|
// Set easy reusable variables
|
491
|
$setting_type = $setting . '_type';
|
492
|
$setting_font = $setting . '_font';
|
493
|
$setting_gwf = $setting . '_gwf';
|
494
|
$setting_cfs = $setting . '_cfs';
|
495
|
$setting_yfy = $setting . '_fyf';
|
496
|
$setting_size = $setting . '_size';
|
497
|
|
498
|
$form['at']['font']['menus'][$setting_container] = array(
|
499
|
'#type' => 'fieldset',
|
500
|
'#title' => t($title),
|
501
|
);
|
502
|
$form['at']['font']['menus'][$setting_container][$setting_type] = array(
|
503
|
'#type' => 'select',
|
504
|
'#title' => t('Type'),
|
505
|
'#options' => $font_type_options,
|
506
|
'#default_value' => at_get_setting($setting_type),
|
507
|
);
|
508
|
$form['at']['font']['menus'][$setting_container][$setting] = array(
|
509
|
'#type' => 'select',
|
510
|
'#title' => t('Font'),
|
511
|
'#default_value' => at_get_setting($setting),
|
512
|
'#options' => str_replace("'", "", font_list('wsf', $element)),
|
513
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => ''))),
|
514
|
);
|
515
|
|
516
|
// Google web fonts
|
517
|
$form['at']['font']['menus'][$setting_container][$setting_gwf] = array(
|
518
|
'#type' => 'textfield',
|
519
|
'#title' => t('Google Font Name'),
|
520
|
'#default_value' => filter_xss_admin(at_get_setting($setting_gwf)),
|
521
|
'#description' => $google_font_description,
|
522
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
523
|
);
|
524
|
$menus_styles_setting = $setting_gwf . '_add_styles';
|
525
|
$form['at']['font']['menus'][$setting_container][$setting_container . '_gwf_styles'] = array(
|
526
|
'#type' => 'fieldset',
|
527
|
'#title' => t('Add Google Font Styles'),
|
528
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
529
|
);
|
530
|
$form['at']['font']['menus'][$setting_container][$setting_container . '_gwf_styles'][$menus_styles_setting] = array(
|
531
|
'#type' => 'checkbox',
|
532
|
'#title' => t('Styles'),
|
533
|
'#default_value' => at_get_setting($menus_styles_setting),
|
534
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
535
|
);
|
536
|
foreach ($google_styles as $style_key => $style_value) {
|
537
|
$form['at']['font']['menus'][$setting_container][$setting_container . '_gwf_styles'][$menus_styles_setting . '_' . $style_key] = array(
|
538
|
'#type' => 'checkbox',
|
539
|
'#title' => t($style_value),
|
540
|
'#default_value' => at_get_setting($menus_styles_setting . '_' . $style_key),
|
541
|
'#states' => array('visible' => array(":input[name=$menus_styles_setting]" => array('checked' => TRUE))),
|
542
|
);
|
543
|
}
|
544
|
$menus_charsets_setting = $setting_gwf . '_add_charsets';
|
545
|
$form['at']['font']['menus'][$setting_container][$setting_container . '_gwf_charsets'] = array(
|
546
|
'#type' => 'fieldset',
|
547
|
'#title' => t('Add Google Font Character Sets'),
|
548
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
549
|
);
|
550
|
$form['at']['font']['menus'][$setting_container][$setting_container . '_gwf_charsets'][$menus_charsets_setting] = array(
|
551
|
'#type' => 'checkbox',
|
552
|
'#title' => t('Character Sets'),
|
553
|
'#default_value' => at_get_setting($menus_charsets_setting),
|
554
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'gwf'))),
|
555
|
);
|
556
|
foreach ($google_charsets as $charset_key => $charset_value) {
|
557
|
$form['at']['font']['menus'][$setting_container][$setting_container . '_gwf_charsets'][$menus_charsets_setting . '_' . $charset_key] = array(
|
558
|
'#type' => 'checkbox',
|
559
|
'#title' => t($charset_value),
|
560
|
'#default_value' => at_get_setting($menus_charsets_setting . '_' . $charset_key),
|
561
|
'#states' => array('visible' => array(":input[name=$menus_charsets_setting]" => array('checked' => TRUE))),
|
562
|
);
|
563
|
}
|
564
|
|
565
|
// Custom font stacks
|
566
|
$form['at']['font']['menus'][$setting_container][$setting_cfs] = array(
|
567
|
'#type' => 'textfield',
|
568
|
'#title' => t('Font'),
|
569
|
'#default_value' => filter_xss_admin(at_get_setting($setting_cfs)),
|
570
|
'#description' => $custom_stack_description,
|
571
|
'#states' => array(
|
572
|
'visible' => array('select[name=' . $setting_type . ']' => array('value' => 'cfs')),
|
573
|
'required' => array('select[name=' . $setting_type . ']' => array('value' => 'cfs')),
|
574
|
),
|
575
|
);
|
576
|
|
577
|
// Font your face
|
578
|
if ($font_your_face_enabled == TRUE) {
|
579
|
$form['at']['font']['menus'][$setting_container][$setting_yfy] = array(
|
580
|
'#type' => 'select',
|
581
|
'#title' => t('Font'),
|
582
|
'#default_value' => at_get_setting($setting_yfy),
|
583
|
'#options' => font_list('fyf', $element),
|
584
|
'#states' => array('visible' => array('select[name=' . $setting_type . ']' => array('value' => 'fyf'))),
|
585
|
);
|
586
|
}
|
587
|
|
588
|
// Size
|
589
|
$form['at']['font']['menus'][$setting_container][$setting_size] = array(
|
590
|
'#type' => 'select',
|
591
|
'#title' => t('Size'),
|
592
|
'#options' => $font_sizes_em,
|
593
|
'#default_value' => at_get_setting($setting_size),
|
594
|
'#attributes' => array('class' => array('font-size-wrapper')),
|
595
|
);
|
596
|
}
|
597
|
}
|
598
|
|
599
|
// Custom CSS selectors
|
600
|
$form['at']['font']['css'] = array(
|
601
|
'#type' => 'fieldset',
|
602
|
'#title' => t('Custom Selectors'),
|
603
|
'#collapsible' => TRUE,
|
604
|
'#collapsed' => TRUE,
|
605
|
);
|
606
|
$form['at']['font']['css']['selectors_font_type'] = array(
|
607
|
'#type' => 'select',
|
608
|
'#title' => t('Type'),
|
609
|
'#options' => $font_type_options,
|
610
|
'#default_value' => at_get_setting('selectors_font_type')
|
611
|
);
|
612
|
$form['at']['font']['css']['selectors_font'] = array(
|
613
|
'#type' => 'select',
|
614
|
'#title' => t('Font'),
|
615
|
'#default_value' => at_get_setting('selectors_font'),
|
616
|
'#options' => font_list('wsf', 'css'),
|
617
|
'#states' => array('visible' => array('select[name="selectors_font_type"]' => array('value' => ''))),
|
618
|
);
|
619
|
|
620
|
// Google fonts
|
621
|
$form['at']['font']['css']['selectors_font_gwf'] = array(
|
622
|
'#type' => 'textfield',
|
623
|
'#title' => t('Google Font Name'),
|
624
|
'#default_value' => filter_xss_admin(at_get_setting('selectors_font_gwf')),
|
625
|
'#description' => $google_font_description,
|
626
|
'#states' => array('visible' => array('select[name="selectors_font_type"]' => array('value' => 'gwf'))),
|
627
|
);
|
628
|
$css_styles_setting = 'selectors_font_add_styles';
|
629
|
$form['at']['font']['css']['selectors_font_gwf_styles'] = array(
|
630
|
'#type' => 'fieldset',
|
631
|
'#title' => t('Add Google Font Styles'),
|
632
|
'#states' => array('visible' => array('select[name="selectors_font_type"]' => array('value' => 'gwf'))),
|
633
|
);
|
634
|
$form['at']['font']['css']['selectors_font_gwf_styles'][$css_styles_setting] = array(
|
635
|
'#type' => 'checkbox',
|
636
|
'#title' => t('Styles'),
|
637
|
'#default_value' => at_get_setting($css_styles_setting),
|
638
|
'#states' => array('visible' => array('select[name="selectors_font_type"]' => array('value' => 'gwf'))),
|
639
|
);
|
640
|
foreach ($google_styles as $style_key => $style_value) {
|
641
|
$form['at']['font']['css']['selectors_font_gwf_styles'][$css_styles_setting . '_' . $style_key] = array(
|
642
|
'#type' => 'checkbox',
|
643
|
'#title' => t($style_value),
|
644
|
'#default_value' => at_get_setting($css_styles_setting . '_' . $style_key),
|
645
|
'#states' => array('visible' => array(":input[name=$css_styles_setting]" => array('checked' => TRUE))),
|
646
|
);
|
647
|
}
|
648
|
$css_charsets_setting = 'selectors_font_add_charsets';
|
649
|
$form['at']['font']['css']['selectors_font_gwf_charsets'] = array(
|
650
|
'#type' => 'fieldset',
|
651
|
'#title' => t('Add Google Font Character Sets'),
|
652
|
'#states' => array('visible' => array('select[name="selectors_font_type"]' => array('value' => 'gwf'))),
|
653
|
);
|
654
|
$form['at']['font']['css']['selectors_font_gwf_charsets'][$css_charsets_setting] = array(
|
655
|
'#type' => 'checkbox',
|
656
|
'#title' => t('Character Sets'),
|
657
|
'#default_value' => at_get_setting($css_charsets_setting),
|
658
|
'#states' => array('visible' => array('select[name="selectors_font_type"]' => array('value' => 'gwf'))),
|
659
|
);
|
660
|
foreach ($google_charsets as $charset_key => $charset_value) {
|
661
|
$form['at']['font']['css']['selectors_font_gwf_charsets'][$css_charsets_setting . '_' . $charset_key] = array(
|
662
|
'#type' => 'checkbox',
|
663
|
'#title' => t($charset_value),
|
664
|
'#default_value' => at_get_setting($css_charsets_setting . '_' . $charset_key),
|
665
|
'#states' => array('visible' => array(":input[name=$css_charsets_setting]" => array('checked' => TRUE))),
|
666
|
);
|
667
|
}
|
668
|
|
669
|
// Custom font stacks
|
670
|
$form['at']['font']['css']['selectors_font_cfs'] = array(
|
671
|
'#type' => 'textfield',
|
672
|
'#title' => t('Font'),
|
673
|
'#default_value' => filter_xss_admin(at_get_setting('selectors_font_cfs')),
|
674
|
'#description' => $custom_stack_description,
|
675
|
'#states' => array(
|
676
|
'visible' => array('select[name="selectors_font_type"]' => array('value' => 'cfs')),
|
677
|
'required' => array('select[name="selectors_font_type"]' => array('value' => 'cfs')),
|
678
|
)
|
679
|
);
|
680
|
|
681
|
// Font your face
|
682
|
if ($font_your_face_enabled == TRUE) {
|
683
|
$form['at']['font']['css']['selectors_font_fyf'] = array(
|
684
|
'#type' => 'select',
|
685
|
'#title' => t('Font'),
|
686
|
'#default_value' => at_get_setting('selectors_font_fyf'),
|
687
|
'#options' => font_list('fyf', 'css'),
|
688
|
'#states' => array('visible' => array('select[name="selectors_font_type"]' => array('value' => 'fyf'))),
|
689
|
);
|
690
|
}
|
691
|
|
692
|
// CSS selectors
|
693
|
$form['at']['font']['css']['selectors_css'] = array(
|
694
|
'#type' => 'textarea',
|
695
|
'#title' => t('CSS Selectors'),
|
696
|
'#rows' => 3,
|
697
|
'#default_value' => filter_xss_admin(at_get_setting('selectors_css')),
|
698
|
'#description' => t("Enter a comma seperated list of valid CSS selectors, with no trailing comma, such as <code>.node-content, .block-content</code>. Note that due to security reason you cannot use the greater than symbol (>) as a child combinator selector."),
|
699
|
'#states' => array('disabled' => array('select[name="selectors_font_type"]' => array('value' => '<none>'))),
|
700
|
);
|
701
|
}
|