Projet

Général

Profil

Paste
Télécharger (45,1 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / mayo / theme-settings.php @ 578c6d8f

1 85ad3d82 Assos Assos
<?php
2
/**
3 d7f58da2 Florent Torregrosa
 * @file
4 85ad3d82 Assos Assos
 * Implements hook_form_system_theme_settings_alter().
5
 *
6
 * Custom theme settings
7
 */
8
function mayo_form_system_theme_settings_alter(&$form, &$form_state) {
9
10
  drupal_add_js(drupal_get_path('theme', 'mayo') . '/js/mayo.js');
11 d7f58da2 Florent Torregrosa
    // Get our plugin system functions.
12
  require_once(drupal_get_path('theme', 'mayo') . '/inc/plugins.inc');
13
14
  // We need some getters.
15
  require_once(drupal_get_path('theme', 'mayo') . '/inc/get.inc');
16
  $path_to_mayo = drupal_get_path('theme', 'mayo');
17
18
  // General "alters" use a form id. Settings should not be set here. The only
19
  // thing useful about this is if you need to alter the form for the running
20
  // theme and *not* the theme setting.
21
  // @see http://drupal.org/node/943212
22
  if (isset($form_id)) {
23
    return;
24
  }
25
26
  // Get an array of device groups with option values
27
  $device_group_options = page_layouts_device_group_options('mayo');
28
29
  // Unit options
30
  $unit_options = array('%' => '%', 'px' => 'px', 'em' => 'em');
31
32
  // Assign $options for each device group
33
  foreach ($device_group_options as $device_group => $options) {
34
35
    // About here we need to call a custom sort function, this is what we got for now
36
    sort($options, SORT_STRING);
37 85ad3d82 Assos Assos
38 d7f58da2 Florent Torregrosa
    foreach ($options as $option) {
39
      if ($device_group === 'bigscreen') {
40
        $bigscreen_options[$option] = drupal_ucfirst(str_replace('_', ' ', $option)); // human readable option names for accessibility
41
      }
42
      if ($device_group === 'tablet_landscape') {
43
        $tablet_landscape_options[$option] = drupal_ucfirst(str_replace('_', ' ', $option));
44
      }
45
      if ($device_group === 'tablet_portrait') {
46
        $tablet_portrait_options[$option] = drupal_ucfirst(str_replace('_', ' ', $option));
47
      }
48
      if ($device_group === 'smalltouch_landscape') {
49
        $smalltouch_landscape_options[$option] = drupal_ucfirst(str_replace('_', ' ', $option));
50
      }
51
    }
52
  }
53
54
  /* --------------- Font settings -------------- */
55 85ad3d82 Assos Assos
  $form['font'] = array(
56
    '#type' => 'fieldset',
57
    '#title' => t('Font settings'),
58
    '#collapsed' => TRUE,
59
    '#collapsible' => TRUE,
60
  );
61
  $form['font']['base_font_size'] = array(
62
    '#type' => 'select',
63
    '#title' => t('Base font size'),
64
    '#default_value' => theme_get_setting('base_font_size'),
65
    '#options' => array(
66
      '75%'    => '75% (=12px)',
67
      '81.25%' => '81.25% (=13px)',
68
      '87.5%'  => '87.5% (=14px)',
69
      '93.75%' => '93.75% (=15px)',
70
      '100%'   => '100% (=16px)',
71
      '112.5%' => '112.5% (=18px)'
72
    ),
73
    '#description' => t('To support text size enlargement/reduction, percent ratio based on the browser\'s regular font size (which is mostly 16px) is used.'),
74
  );
75
  $form['font']['base_font_family'] = array(
76
    '#type' => 'select',
77
    '#title' => t('Base font family'),
78
    '#default_value' => theme_get_setting('base_font_family'),
79
    '#options' => array(
80
      0 => t('Serif: Georgia, Palatino Linotype, Book Antiqua, URW Palladio L, Baskerville, serif'),
81
      1 => t('Sans-Serif: Verdana, Geneva, Arial, Bitstream Vera Sans, DejaVu Sans, sans-serif'),
82
      2 => t('Custom'),
83
    ),
84
    '#description' => t('Font used for most part of the contents.'),
85
  );
86
  $form['font']['base_custom_font_family'] = array(
87
    '#type' => 'textfield',
88
    '#title' => t('Custom base font family'),
89
    '#default_value' => theme_get_setting('base_custom_font_family'),
90
    '#size' => 80,
91
    '#description' => t('Enter the base font-family you want to use. No need to start with <b>font-family:</b> and end with <b>;</b>. Just enter comma separated font names.'),
92
    '#prefix' => '<div id="base-custom-font-family-wrapper">',
93
    '#suffix' => '</div>',
94
  );
95
  $form['font']['heading_font_family'] = array(
96
    '#type' => 'select',
97
    '#title' => t('Heading font family (except for the site name and slogan)'),
98
    '#default_value' => theme_get_setting('heading_font_family'),
99
    '#options' => array(
100
      0 => t('Serif: Georgia, Palatino Linotype, Book Antiqua, URW Palladio L, Baskerville, serif'),
101
      1 => t('Sans-Serif: Verdana, Geneva, Arial, Bitstream Vera Sans, DejaVu Sans, sans-serif'),
102
      2 => t('Custom'),
103
    ),
104
    '#description' => t('Font used for the headings (h1, h2, h3, h4, h5). Font used for the site name and slogan can not be changed here. If you want to change it, please manually edit style.css in the theme\'s css subdirectory.'),
105
  );
106
  $form['font']['heading_custom_font_family'] = array(
107
    '#type' => 'textfield',
108
    '#title' => t('Custom heading font family'),
109
    '#default_value' => theme_get_setting('heading_custom_font_family'),
110
    '#size' => 80,
111
    '#description' => t('Enter the font-family you want to use for the headings. No need to start with <b>font-family:</b> and end with <b>;</b>. Just enter comma separated font names.'),
112
    '#prefix' => '<div id="heading-custom-font-family-wrapper">',
113
    '#suffix' => '</div>',
114
  );
115
116 d7f58da2 Florent Torregrosa
  /* --------------- Layout settings -------------- */
117 85ad3d82 Assos Assos
  $form['layout'] = array(
118
    '#type' => 'fieldset',
119
    '#title' => t('Layout settings'),
120
    '#collapsed' => TRUE,
121
    '#collapsible' => TRUE,
122
  );
123
  $form['layout']['base_vmargin'] = array(
124
    '#type' => 'textfield',
125
    '#title' => t('Base vertical (top/bottom) margin'),
126
    '#default_value' => theme_get_setting('base_vmargin'),
127
    '#size' => 12,
128
    '#maxlength' => 8,
129
    '#description' => t('Specify the base vertical (top/bottom) margin which is vertical spaces between page edge and browser screen in px.'),
130
    '#prefix' => '<img src="/' . drupal_get_path('theme', 'mayo') . '/images/base-layout.png" /><br />',
131
  );
132
  $form['layout']['page_margin'] = array(
133
    '#type' => 'textfield',
134
    '#title' => t('Page margin'),
135
    '#default_value' => theme_get_setting('page_margin'),
136
    '#size' => 12,
137
    '#maxlength' => 8,
138
    '#description' => t('Specify the page margin which is spaces between page edge and contents in px.'),
139
  );
140
  $form['layout']['layout_style'] = array(
141
    '#type' => 'radios',
142
    '#title' => t('Layout style'),
143
    '#default_value' => theme_get_setting('layout_style'),
144
    '#options' => array(
145
      1 => t('1. Apply page margin to all (header, footer and main contents).'),
146
      2 => t('2. Apply page margin to main contents only.'),
147
    ),
148 578c6d8f Assos Assos
    '#description' => '<img src="/' . drupal_get_path('theme', 'mayo') . '/images/page-layout.png" /><br />' . t('When the layout 2 is selected, or header background image is selected, header borders are not drawn to make it look better.'),
149 85ad3d82 Assos Assos
  );
150
151 d7f58da2 Florent Torregrosa
  /* --------------- Responsive sidebar layout settings -------------- */
152
  /* -----------Big screen as in desktop pc monitor------------- */
153
  $form['layout']['bigscreen'] = array(
154 85ad3d82 Assos Assos
    '#type' => 'fieldset',
155 d7f58da2 Florent Torregrosa
    '#title' => t('Big Screen Sidebar layout'),
156 85ad3d82 Assos Assos
    '#collapsible' => TRUE,
157
    '#collapsed' => TRUE,
158 d7f58da2 Florent Torregrosa
    '#attributes' => array(
159
      'class' => array('mayo-layout-form'),
160
    ),
161
  );
162
163
    // Big screen Layout
164
  $form['layout']['bigscreen']['bigscreen-layout-wrapper'] = array(
165
    '#type' => 'fieldset',
166
    '#title' => t('Choose sidebar layout'),
167 85ad3d82 Assos Assos
  );
168 d7f58da2 Florent Torregrosa
    // Options
169
170
  $form['layout']['bigscreen']['bigscreen-layout-wrapper']['bigscreen_layout'] = array(
171
     '#type' => 'radios',
172
     '#title' => t('<strong>Choose sidebar positions</strong>'),
173
     '#default_value' => str_replace('-', '_', theme_get_setting('bigscreen_layout')),
174
     '#options' => $bigscreen_options,
175
  );
176
177
  // Sidebars
178
  $form['layout']['bigscreen']['bigscreen-sidebar-wrapper'] = array(
179
    '#type' => 'fieldset',
180
    '#title' => t('Set sidebar widths'),
181
    '#description' => t('<strong>Set the width of each sidebar</strong>'),
182
    '#collapsible' => FALSE,
183
  );
184
185
  // Units
186
  $form['layout']['bigscreen']['bigscreen-sidebar-wrapper']['bigscreen_sidebar_unit'] = array(
187
    '#type' => 'select',
188
    '#title' => t('Unit'),
189
    '#default_value' => theme_get_setting('bigscreen_sidebar_unit'),
190
    '#options' => $unit_options,
191
  );
192
193
  // Sidebar first
194
  $form['layout']['bigscreen']['bigscreen-sidebar-wrapper']['bigscreen_sidebar_first'] = array(
195
    '#type' => 'textfield',
196
    '#title' => t('First sidebar'),
197
    '#default_value' => check_plain(theme_get_setting('bigscreen_sidebar_first')),
198
    '#size' => 4,
199
    '#maxlenght' => 4,
200
    '#states' => array(
201
      'required' => array(
202
        array('input[name="bigscreen_layout"]' => array('value' => 'three_col_grail')),
203
        array('input[name="bigscreen_layout"]' => array('value' => 'two_sidebars_left')),
204
        array('input[name="bigscreen_layout"]' => array('value' => 'two_sidebars_right')),
205
      ),
206
    ),
207
  );
208
209
  // Sidebar second
210
  $form['layout']['bigscreen']['bigscreen-sidebar-wrapper']['bigscreen_sidebar_second'] = array(
211
    '#type' => 'textfield',
212
    '#title' => t('Second sidebar'),
213
    '#default_value' => check_plain(theme_get_setting('bigscreen_sidebar_second')),
214
    '#size' => 4,
215
    '#maxlenght' => 4,
216
    '#states' => array(
217
      'required' => array(
218
        array('input[name="bigscreen_layout"]' => array('value' => 'three_col_grail')),
219
        array('input[name="bigscreen_layout"]' => array('value' => 'two_sidebars_left')),
220
        array('input[name="bigscreen_layout"]' => array('value' => 'two_sidebars_right')),
221
      ),
222
    ),
223
  );
224
225
  // Page width
226
  $form['layout']['bigscreen']['bigscreen-width-wrapper'] = array(
227
    '#type' => 'fieldset',
228
    '#title' => t('Set the page width'),
229
    '#description' => t('<strong>Set the page width</strong>'),
230
  );
231
232
  // Unit
233
  $form['layout']['bigscreen']['bigscreen-width-wrapper']['bigscreen_page_unit'] = array(
234
    '#type' => 'select',
235
    '#title' => t('Unit'),
236
    '#default_value' => theme_get_setting('bigscreen_page_unit'),
237
    '#options' => $unit_options,
238
  );
239
240
  // Width
241
  $form['layout']['bigscreen']['bigscreen-width-wrapper']['bigscreen_page_width'] = array(
242
    '#type'  => 'textfield',
243
    '#title' => t('Page width'),
244
    '#default_value' => check_plain(theme_get_setting('bigscreen_page_width')),
245
    '#size' => 4,
246
    '#maxlenght' => 4,
247
    '#required' => TRUE,
248
  );
249
250
  // Media queries
251
  $form['layout']['bigscreen']['media-queries-wrapper'] = array(
252
    '#type' => 'fieldset',
253
    '#title' => t('Standard Screen Media Queries'),
254
    '#weight' => 1,
255
    '#attributes' => array(
256
      'class' => array('at-media-queries'),
257
    ),
258
  );
259
260
  // Media query
261
  $form['layout']['bigscreen']['media-queries-wrapper']['bigscreen_media_query'] = array(
262
    '#type' => 'textfield',
263
    '#title' => t('Media query for this layout'),
264
    '#default_value' => check_plain(theme_get_setting('bigscreen_media_query')),
265
    '#description' => t('Do not include @media, it\'s included automatically.'),
266
    '#size' => 100,
267
    '#required' => TRUE,
268
  );
269
270
  /* ****************************************************************************
271
   *
272
   * Tablet
273
   *
274
   * ************************************************************************** */
275
276
  $form['layout']['tablet'] = array(
277
    '#type' => 'fieldset',
278
    '#title' => t('Tablet Sidebar Layout'),
279
    '#description' => t('<h3>Tablet Layout</h3><p>Tablet devices such as iPad, Android and Windows tablets have two orientations - landscape and portrait, which can also be thought of as wide and narrow tablets. You can configure a different layout for each orientation.</p>'),
280
    '#attributes' => array(
281
      'class' => array('mayo-layout-form'),
282
    ),
283
    '#collapsible' => TRUE,
284
    '#collapsed' => TRUE,
285
  );
286
287
  /* ******************
288
   * Tablet landscape
289
   * **************** */
290
291
  $form['layout']['tablet']['landscape'] = array(
292
    '#type' => 'fieldset',
293
    '#title' => t('Landscape'),
294
    '#description' => t('<h4>Landscape tablet <span class="field-description-info">(wide)</span></h4>'),
295
    '#collapsible' => TRUE,
296
    '#collapsed' => TRUE,
297
  );
298
299
  // Tablet landscape Layout options
300
  $form['layout']['tablet']['landscape']['tablet-landscape-layout-wrapper'] = array(
301
    '#type' => 'fieldset',
302
    '#title' => t('Choose sidebar layout'),
303
  );
304
305
  // Options
306
  $form['layout']['tablet']['landscape']['tablet-landscape-layout-wrapper']['tablet_landscape_layout'] = array(
307 85ad3d82 Assos Assos
    '#type' => 'radios',
308 d7f58da2 Florent Torregrosa
    '#title' => t('<strong>Choose sidebar positions</strong>'),
309
    '#default_value' => str_replace('-', '_', theme_get_setting('tablet_landscape_layout')),
310
    '#options' => $tablet_landscape_options,
311
  );
312
313
  // Sidebars
314
  $form['layout']['tablet']['landscape']['tablet-landscape-sidebar-width-wrapper'] = array(
315
    '#type' => 'fieldset',
316
    '#title' => t('Set sidebar widths'),
317
    '#description' => t('<strong>Set the width of each sidebar</strong>'),
318
  );
319
320
  // Units
321
  $form['layout']['tablet']['landscape']['tablet-landscape-sidebar-width-wrapper']['tablet_landscape_sidebar_unit'] = array(
322
    '#type' => 'select',
323
    '#title' => t('Unit'),
324
    '#default_value' => theme_get_setting('tablet_landscape_sidebar_unit'),
325
    '#options' => $unit_options,
326
  );
327
328
  // Sidebar first
329
  $form['layout']['tablet']['landscape']['tablet-landscape-sidebar-width-wrapper']['tablet_landscape_sidebar_first'] = array(
330
    '#type' => 'textfield',
331
    '#title' => t('First sidebar'),
332
    '#default_value' => check_plain(theme_get_setting('tablet_landscape_sidebar_first')),
333
    '#size' => 4,
334
    '#maxlenght' => 4,
335
    '#states' => array(
336
      'required' => array(
337
        array('input[name="tablet_landscape_layout"]' => array('value' => 'three_col_grail')),
338
        array('input[name="tablet_landscape_layout"]' => array('value' => 'two_sidebars_left')),
339
        array('input[name="tablet_landscape_layout"]' => array('value' => 'two_sidebars_left_stack')),
340
        array('input[name="tablet_landscape_layout"]' => array('value' => 'two_sidebars_right')),
341
        array('input[name="tablet_landscape_layout"]' => array('value' => 'two_sidebars_right_stack')),
342
      ),
343 85ad3d82 Assos Assos
    ),
344
  );
345 d7f58da2 Florent Torregrosa
346
  // Sidebar second
347
  $form['layout']['tablet']['landscape']['tablet-landscape-sidebar-width-wrapper']['tablet_landscape_sidebar_second'] = array(
348 85ad3d82 Assos Assos
    '#type' => 'textfield',
349 d7f58da2 Florent Torregrosa
    '#title' => t('Second sidebar'),
350
    '#default_value' => check_plain(theme_get_setting('tablet_landscape_sidebar_second')),
351
    '#size' => 4,
352
    '#maxlenght' => 4,
353
    '#states' => array(
354
      'invisible' => array(
355
        array('input[name="tablet_landscape_layout"]' => array('value' => 'two_sidebars_left_stack')),
356
        array('input[name="tablet_landscape_layout"]' => array('value' => 'two_sidebars_right_stack')),
357
      ),
358
      'required' => array(
359
        array('input[name="tablet_landscape_layout"]' => array('value' => 'three_col_grail')),
360
        array('input[name="tablet_landscape_layout"]' => array('value' => 'two_sidebars_left')),
361
        array('input[name="tablet_landscape_layout"]' => array('value' => 'two_sidebars_right')),
362
      ),
363
    ),
364
  );
365
366
  // Conditional messages for sidebar layouts
367
  $form['layout']['tablet']['landscape']['tablet-landscape-sidebar-width-wrapper']['tablet-landscape-sidebar-message-wrapper'] = array(
368
    '#type' => 'fieldset',
369
    '#states' => array(
370
      'invisible' => array(
371
        array('input[name="tablet_landscape_layout"]' => array('value' => 'three_col_grail')),
372
        array('input[name="tablet_landscape_layout"]' => array('value' => 'two_sidebars_left')),
373
        array('input[name="tablet_landscape_layout"]' => array('value' => 'two_sidebars_right')),
374
      ),
375
    ),
376 85ad3d82 Assos Assos
  );
377 d7f58da2 Florent Torregrosa
  $form['layout']['tablet']['landscape']['tablet-landscape-sidebar-width-wrapper']['tablet-landscape-sidebar-message-wrapper']['message'] = array(
378
    '#markup' => t('<div class="description">In this layout <em>Second sidebar</em> wraps below.</div>'),
379
  );
380
381
  // Page width
382
  $form['layout']['tablet']['landscape']['tablet-landscape-page-width-wrapper'] = array(
383
    '#type' => 'fieldset',
384
    '#title' => t('Set the page width'),
385
    '#description' => t('<strong>Set the page width</strong>'),
386
  );
387
388
  // Unit
389
  $form['layout']['tablet']['landscape']['tablet-landscape-page-width-wrapper']['tablet_landscape_page_unit'] = array(
390
    '#type' => 'select',
391
    '#title' => t('Unit'),
392
    '#default_value' => theme_get_setting('tablet_landscape_page_unit'),
393
    '#options' => $unit_options,
394
  );
395
396
  // Width
397
  $form['layout']['tablet']['landscape']['tablet-landscape-page-width-wrapper']['tablet_landscape_page_width'] = array(
398
    '#type'  => 'textfield',
399
    '#title' => t('Page width'),
400
    '#default_value' => check_plain(theme_get_setting('tablet_landscape_page_width')),
401
    '#size' => 4,
402
    '#maxlenght' => 4,
403
    '#required' => TRUE,
404
  );
405
406
  // Media Queries
407
  $form['layout']['tablet']['landscape']['tablet-landscape-media-queries-wrapper'] = array(
408
    '#type' => 'fieldset',
409
    '#title' => t('Tablet Landscape Media Queries'),
410
    '#weight' => 1,
411
    '#attributes' => array(
412
      'class' => array(
413
        'at-media-queries',
414
      ),
415
    ),
416
  );
417
418
  // Media query
419
  $form['layout']['tablet']['landscape']['tablet-landscape-media-queries-wrapper']['tablet_landscape_media_query'] = array(
420 85ad3d82 Assos Assos
    '#type' => 'textfield',
421 d7f58da2 Florent Torregrosa
    '#title' => t('Media query for this layout'),
422
    '#default_value' => check_plain(theme_get_setting('tablet_landscape_media_query')),
423
    '#description' => t('Do not include @media, it\'s included automatically.'),
424
    '#size' => 100,
425
    '#required' => TRUE,
426 85ad3d82 Assos Assos
  );
427 d7f58da2 Florent Torregrosa
428
429
  /* *****************
430
   * Tablet portrait
431
   * *************** */
432
433
  $form['layout']['tablet']['portrait'] = array(
434
    '#type' => 'fieldset',
435
    '#title' => t('Portrait'),
436
    '#description' => t('<h4>Portrait tablet <span class="field-description-info">(narrow)</span></h4>'),
437
    '#collapsible' => TRUE,
438
    '#collapsed' => TRUE,
439
  );
440
441
  // Tablet portrait Layout options
442
  $form['layout']['tablet']['portrait']['tablet-portrait-layout-wrapper'] = array(
443
    '#type' => 'fieldset',
444
    '#title' => t('Choose sidebar layout'),
445
  );
446
447
  // Options
448
  $form['layout']['tablet']['portrait']['tablet-portrait-layout-wrapper']['tablet_portrait_layout'] = array(
449
    '#type' => 'radios',
450
    '#title' => t('<strong>Choose sidebar positions</strong>'),
451
    '#default_value' => str_replace('-', '_', theme_get_setting('tablet_portrait_layout')),
452
    '#options' => $tablet_portrait_options,
453
  );
454
455
  // Tablet portrait Sidebars
456
  $form['layout']['tablet']['portrait']['tablet-portrait-sidebar-width-wrapper'] = array(
457
    '#type' => 'fieldset',
458
    '#title' => t('Set sidebar widths'),
459
    '#description' => t('<strong>Set the width of each sidebar</strong>'),
460
    '#states' => array(
461
      'invisible' => array('input[name="tablet_portrait_layout"]' => array('value' => 'one_col_stack')),
462
    ),
463
  );
464
465
  // Units
466
  $form['layout']['tablet']['portrait']['tablet-portrait-sidebar-width-wrapper']['tablet_portrait_sidebar_unit'] = array(
467
    '#type' => 'select',
468
    '#title' => t('Unit'),
469
    '#default_value' => theme_get_setting('tablet_portrait_sidebar_unit'),
470
    '#options' => $unit_options,
471
  );
472
473
  // Sidebar first
474
  $form['layout']['tablet']['portrait']['tablet-portrait-sidebar-width-wrapper']['tablet_portrait_sidebar_first'] = array(
475
    '#type' => 'textfield',
476
    '#title' => t('First sidebar'),
477
    '#default_value' => check_plain(theme_get_setting('tablet_portrait_sidebar_first')),
478
    '#size' => 4,
479
    '#maxlenght' => 4,
480
    '#states' => array(
481
      'invisible' => array(
482
        array('input[name="tablet_portrait_layout"]' => array('value' => 'one_col_stack')),
483
      ),
484
      'required' => array(
485
        array('input[name="tablet_portrait_layout"]' => array('value' => 'one_col_vert')),
486
        array('input[name="tablet_portrait_layout"]' => array('value' => 'two_sidebars_left_stack')),
487
        array('input[name="tablet_portrait_layout"]' => array('value' => 'two_sidebars_right_stack')),
488
      ),
489
    ),
490
  );
491
492
  // Sidebar second
493
  $form['layout']['tablet']['portrait']['tablet-portrait-sidebar-width-wrapper']['tablet_portrait_sidebar_second'] = array(
494
    '#type' => 'textfield',
495
    '#title' => t('Second sidebar'),
496
    '#default_value' => check_plain(theme_get_setting('tablet_portrait_sidebar_second')),
497
    '#size' => 4,
498
    '#maxlenght' => 4,
499
    '#states' => array(
500
      'invisible' => array(
501
        array('input[name="tablet_portrait_layout"]' => array('value' => 'one_col_stack')),
502
        array('input[name="tablet_portrait_layout"]' => array('value' => 'two_sidebars_left_stack')),
503
        array('input[name="tablet_portrait_layout"]' => array('value' => 'two_sidebars_right_stack')),
504
      ),
505
      'required' => array(
506
        array('input[name="tablet_portrait_layout"]' => array('value' => 'one_col_vert')),
507
      ),
508
    ),
509 85ad3d82 Assos Assos
  );
510
511 d7f58da2 Florent Torregrosa
  // Conditional messages for sidebar layouts
512
  $form['layout']['tablet']['portrait']['tablet-portrait-sidebar-width-wrapper']['tablet-portrait-sidebar-message-wrapper'] = array(
513
    '#type' => 'fieldset',
514
    '#states' => array(
515
      'invisible' => array(
516
        array('input[name="tablet_portrait_layout"]' => array('value' => 'one_col_vert')),
517
        array('input[name="tablet_portrait_layout"]' => array('value' => 'one_col_stack')),
518
      ),
519
    ),
520
  );
521
  $form['layout']['tablet']['portrait']['tablet-portrait-sidebar-width-wrapper']['tablet-portrait-sidebar-message-wrapper']['message'] = array(
522
    '#markup' => t('<div class="description">In this layout <em>Second sidebar</em> wraps below.</div>'),
523
  );
524
525
  // Tablet portrait Page width
526
  $form['layout']['tablet']['portrait']['tablet-portrait-page-width-wrapper'] = array(
527
    '#type' => 'fieldset',
528
    '#title' => t('Set the page width'),
529
    '#description' => t('<strong>Set the page width</strong>'),
530
  );
531
532
  // Unit
533
  $form['layout']['tablet']['portrait']['tablet-portrait-page-width-wrapper']['tablet_portrait_page_unit'] = array(
534
    '#type' => 'select',
535
    '#title' => t('Unit'),
536
    '#default_value' => theme_get_setting('tablet_portrait_page_unit'),
537
    '#options' => $unit_options,
538
  );
539
540
  // Width
541
  $form['layout']['tablet']['portrait']['tablet-portrait-page-width-wrapper']['tablet_portrait_page_width'] = array(
542
    '#type'  => 'textfield',
543
    '#title' => t('Page width'),
544
    '#default_value' => check_plain(theme_get_setting('tablet_portrait_page_width')),
545
    '#size' => 4,
546
    '#maxlenght' => 4,
547
    '#required' => TRUE,
548
  );
549
550
  // Tablet portrait Media queries
551
  $form['layout']['tablet']['portrait']['tablet-portrait-media-queries-wrapper'] = array(
552
    '#type' => 'fieldset',
553
    '#title' => t('Tablet Portrait Media Queries'),
554
    '#weight' => 1,
555
    '#attributes' => array(
556
      'class' => array('at-media-queries'),
557
    ),
558
  );
559
560
  // Media query
561
  $form['layout']['tablet']['portrait']['tablet-portrait-media-queries-wrapper']['tablet_portrait_media_query'] = array(
562
    '#type' => 'textfield',
563
    '#title' => t('Media query for this layout'),
564
    '#default_value' => check_plain(theme_get_setting('tablet_portrait_media_query')),
565
    '#description' => t('Do not include @media, it\'s included automatically.'),
566
    '#size' => 100,
567
    '#required' => TRUE,
568
  );
569
  /* ****************************************************************************
570
   *
571
   * Smalltouch
572
   *
573
   * ************************************************************************** */
574
575
  $form['layout']['smalltouch'] = array(
576
    '#type' => 'fieldset',
577
    '#title' => t('Smalltouch Sidebar Layout'),
578
    '#description' => t('<h3>Smalltouch Layout</h3><p>Smalltouch devices such as iPhone, Android and Windows phones have two orientations - landscape and portrait, which can also be thought of as wide and arrow smalltouch devices. You can configure a layout for landscape orientation only - portrait orientation (narrow) will always display in one column (all regions full width and stacked) with sidebars below the main content.</p>'),
579
    '#attributes' => array(
580
      'class' => array('mayo-layout-form'),
581
    ),
582
    '#collapsible' => TRUE,
583
    '#collapsed' => TRUE,
584
  );
585
586
  /* **********************
587
   * Smalltouch landscape
588
   * ******************** */
589
590
  $form['layout']['smalltouch']['landscape'] = array(
591
    '#type' => 'fieldset',
592
    '#title' => t('Landscape'),
593
    '#description' => t('<h4>Landscape smalltouch <span class="field-description-info">(wide)</span></h4>'),
594
    '#collapsible' => TRUE,
595
    '#collapsed' => TRUE,
596
  );
597
598
  $form['layout']['smalltouch']['landscape']['smalltouch-landscape-layout-wrapper'] = array(
599
    '#type' => 'fieldset',
600
    '#title' => t('Choose sidebar layout'),
601
  );
602
603
  $form['layout']['smalltouch']['landscape']['smalltouch-landscape-layout-wrapper']['smalltouch_landscape_layout'] = array(
604
    '#type' => 'radios',
605
    '#title' => t('<strong>Choose sidebar positions</strong>'),
606
    '#default_value' => theme_get_setting('smalltouch_landscape_layout') ? str_replace('-', '_', theme_get_setting('smalltouch_landscape_layout')) : str_replace('-', '_', theme_get_setting('smartphone_landscape_layout')),
607
    '#options' => $smalltouch_landscape_options,
608
  );
609
610
  $form['layout']['smalltouch']['landscape']['smalltouch-landscape-sidebar-width-wrapper'] = array(
611
    '#type' => 'fieldset',
612
    '#title' => t('Set sidebar widths'),
613
    '#description' => t('<strong>Set the width of each sidebar</strong>'),
614
    '#states' => array(
615
      '!visible' => array('input[name="smalltouch_landscape_layout"]' => array('value' => 'one_col_stack')),
616
    ),
617
  );
618
619
  $form['layout']['smalltouch']['landscape']['smalltouch-landscape-sidebar-width-wrapper']['smalltouch_landscape_sidebar_unit'] = array(
620
    '#type' => 'select',
621
    '#title' => t('Unit'),
622
    '#default_value' => theme_get_setting('smalltouch_landscape_sidebar_unit') ? theme_get_setting('smalltouch_landscape_sidebar_unit') : theme_get_setting('smartphone_landscape_sidebar_unit'),
623
    '#options' => $unit_options,
624
  );
625 85ad3d82 Assos Assos
626 d7f58da2 Florent Torregrosa
  $form['layout']['smalltouch']['landscape']['smalltouch-landscape-sidebar-width-wrapper']['smalltouch_landscape_sidebar_first'] = array(
627
    '#type' => 'textfield',
628
    '#title' => t('First sidebar'),
629
    '#default_value' => theme_get_setting('smalltouch_landscape_sidebar_first') ? check_plain(theme_get_setting('smalltouch_landscape_sidebar_first')) : check_plain(theme_get_setting('smartphone_landscape_sidebar_first')),
630
    '#size' => 4,
631
    '#maxlenght' => 4,
632
    '#states' => array(
633
      'required' => array('input[name="smalltouch_landscape_layout"]' => array('value' => 'one_col_vert')),
634
    ),
635
  );
636
637
  $form['layout']['smalltouch']['landscape']['smalltouch-landscape-sidebar-width-wrapper']['smalltouch_landscape_sidebar_second'] = array(
638
    '#type' => 'textfield',
639
    '#title' => t('Second sidebar'),
640
    '#default_value' => theme_get_setting('smalltouch_landscape_sidebar_second') ? check_plain(theme_get_setting('smalltouch_landscape_sidebar_second')) : check_plain(theme_get_setting('smartphone_landscape_sidebar_second')),
641
    '#size' => 4,
642
    '#maxlenght' => 4,
643
    '#states' => array(
644
      'required' => array('input[name="smalltouch_landscape_layout"]' => array('value' => 'one_col_vert')),
645
    ),
646
  );
647
648
  $form['layout']['smalltouch']['landscape']['smalltouch-landscape-media-queries-wrapper'] = array(
649
    '#type' => 'fieldset',
650
    '#title' => t('Smalltouch Landscape Media Queries'),
651
    '#weight' => 1,
652
    '#attributes' => array(
653
      'class' => array('at-media-queries'),
654
    ),
655
  );
656
657
  $form['layout']['smalltouch']['landscape']['smalltouch-landscape-media-queries-wrapper']['smalltouch_landscape_media_query'] = array(
658
    '#type' => 'textfield',
659
    '#title' => t('Media query for this layout'),
660
    '#default_value' => theme_get_setting('smalltouch_landscape_media_query') ? check_plain(theme_get_setting('smalltouch_landscape_media_query')) : check_plain(theme_get_setting('smartphone_landscape_media_query')),
661
    '#description' => t('Do not include @media, it\'s included automatically.'),
662
    '#size' => 100,
663
    //'#required' => TRUE,
664
  );
665
666
  // Pass hidden values to the sumbit function, these values are required but the user can't change them via the UI
667
  $form['layout']['smalltouch']['landscape']['hidden']['smalltouch_landscape_page_width'] = array(
668
    '#type' => 'hidden',
669
    '#default_value' => theme_get_setting('smalltouch_landscape_page_width') ? check_plain(theme_get_setting('smalltouch_landscape_page_width')) : check_plain(theme_get_setting('smartphone_landscape_page_width')),
670
  );
671
  $form['layout']['smalltouch']['landscape']['hidden']['smalltouch_landscape_page_unit'] = array(
672
    '#type' => 'hidden',
673
    '#default_value' => theme_get_setting('smalltouch_landscape_page_unit') ? theme_get_setting('smalltouch_landscape_page_unit') : theme_get_setting('smartphone_landscape_page_unit'),
674
  );
675
676
  /* *********************
677
   * Smalltouch portrait
678
   * ******************* */
679
680
  $form['layout']['smalltouch']['portrait'] = array(
681
    '#type' => 'fieldset',
682
    '#title' => t('Portrait'),
683
    '#description' => t('<h4>Portrait smalltouch <span class="field-description-info">(narrow)</span></h4><div class="smalltouch-portrait-layout">One column</div><p>The smalltouch portrait layout always displays in one column with sidebars stacked horizontally below the main content. All widths are always 100%.</p>'),
684
    '#collapsible' => TRUE,
685
    '#collapsed' => TRUE,
686
  );
687
688
  $form['layout']['smalltouch']['portrait']['smalltouch-portrait-media-queries-wrapper'] = array(
689
    '#type' => 'fieldset',
690
    '#title' => t('Smalltouch Portrait Media Queries'),
691
    '#weight' => 1,
692
    '#attributes' => array(
693
      'class' => array('at-media-queries'),
694
    ),
695
  );
696
697
  $form['layout']['smalltouch']['portrait']['smalltouch-portrait-media-queries-wrapper']['smalltouch_portrait_media_query'] = array(
698
    '#type' => 'textfield',
699
    '#title' => t('Media query for this layout'),
700
    '#default_value' => theme_get_setting('smalltouch_portrait_media_query') ? check_plain(theme_get_setting('smalltouch_portrait_media_query')) : check_plain(theme_get_setting('smartphone_portrait_media_query')),
701
    '#description' => t('Do not include @media, it\'s included automatically.'),
702
    '#size' => 100,
703
  );
704
705
  // Pass hidden values to the sumbit function, these values are required but the user can't change them via the UI
706
  $form['layout']['smalltouch']['portrait']['hidden']['smalltouch_portrait_page_width'] = array(
707
    '#type' => 'hidden',
708
    '#default_value' => theme_get_setting('smalltouch_portrait_page_width') ? check_plain(theme_get_setting('smalltouch_portrait_page_width')) : check_plain(theme_get_setting('smartphone_portrait_page_width')),
709
  );
710
711
  $form['layout']['smalltouch']['portrait']['hidden']['smalltouch_portrait_page_unit'] = array(
712
    '#type' => 'hidden',
713
    '#default_value' => theme_get_setting('smalltouch_portrait_page_unit') ? theme_get_setting('smalltouch_portrait_page_unit') : theme_get_setting('smartphone_portrait_page_unit'),
714
  );
715
716
  $form['layout']['smalltouch']['portrait']['hidden']['smalltouch_portrait_sidebar_first'] = array(
717
    '#type' => 'hidden',
718
    '#default_value' => theme_get_setting('smalltouch_portrait_sidebar_first') ? check_plain(theme_get_setting('smalltouch_portrait_sidebar_first')) : check_plain(theme_get_setting('smartphone_portrait_sidebar_first')),
719
  );
720
721
  $form['layout']['smalltouch']['portrait']['hidden']['smalltouch_portrait_sidebar_second'] = array(
722
    '#type' => 'hidden',
723
    '#default_value' => theme_get_setting('smalltouch_portrait_sidebar_second') ? check_plain(theme_get_setting('smalltouch_portrait_sidebar_second')) : check_plain(theme_get_setting('smartphone_portrait_sidebar_second')),
724
  );
725
726
  $form['layout']['smalltouch']['portrait']['hidden']['smalltouch_portrait_sidebar_unit'] = array(
727
    '#type' => 'hidden',
728
    '#default_value' => theme_get_setting('smalltouch_portrait_sidebar_unit') ? check_plain(theme_get_setting('smalltouch_portrait_sidebar_unit')) : check_plain(theme_get_setting('smartphone_portrait_sidebar_unit')),
729
  );
730
731
  $form['layout']['smalltouch']['portrait']['hidden']['smalltouch_portrait_layout'] = array(
732
    '#type' => 'hidden',
733
    '#default_value' => theme_get_setting('smalltouch_portrait_layout') ? str_replace('-', '_', theme_get_setting('smalltouch_portrait_layout')) : str_replace('-', '_', theme_get_setting('smartphone_portrait_layout')),
734
  );
735
736
   /* --------------- Style settings -------------- */
737 85ad3d82 Assos Assos
  $form['style'] = array(
738
    '#type' => 'fieldset',
739
    '#title' => t('Style settings'),
740
    '#collapsible' => TRUE,
741
    '#collapsed' => TRUE,
742
  );
743 d7f58da2 Florent Torregrosa
  $form['style']['legacy_superfish_styles'] = array(
744
    '#type' => 'checkbox',
745
    '#title' => t('Use old legacy MAYO styles for Superfish.'),
746
    '#default_value' => theme_get_setting('legacy_superfish_styles'),
747
    '#description' => t('Check here if you want to add mayo-superfish.css.'),
748
  );
749
  $form['style']['superfish_note'] = array(
750
    '#type' => 'item',
751
    '#title' => t('Note:'),
752
    '#markup' => t('Use this only when coming from the older non-responsive versions of MAYO
753
     and your Superfish menu is broken without it. If you haven\'t been using Superfish or are
754
     installing MAYO for the first time you shouldn\'t need it and can leave it unchecked.'),
755
  );
756 85ad3d82 Assos Assos
  $form['style']['round_corners'] = array(
757
    '#type' => 'select',
758
    '#title' => t('Content box round corners'),
759
    '#default_value' => theme_get_setting('round_corners'),
760 d7f58da2 Florent Torregrosa
    '#description' => t('Make the corner of sidebar block and/or node rounded.'),
761 85ad3d82 Assos Assos
    '#options' => array(
762 d7f58da2 Florent Torregrosa
      'rc-0' => t('No round corners'),
763
      'rc-1' => t('Sidebar block only'),
764
      'rc-2' => t('Node only'),
765
      'rc-3' => t('Both sidebar block and node'),
766 85ad3d82 Assos Assos
    ),
767
    '#suffix' => '<img src="/' . drupal_get_path('theme', 'mayo') . '/images/round-corners.png" /><br />',
768
  );
769
770
  $form['style']['menubar_style'] = array(
771
    '#type' => 'radios',
772
    '#title' => t('Menubar style'),
773
    '#default_value' => theme_get_setting('menubar_style'),
774
    '#options' => array(
775
      1 => t('1. Normal (based on the colors specified by the color set)'),
776
      2 => t('2. Gloss black image background.'),
777
    ),
778
    '#suffix' => '<img src="/' . drupal_get_path('theme', 'mayo') . '/images/menubar-type.png" />',
779
  );
780
  $form['style']['note'] = array(
781
    '#type' => 'item',
782
    '#title' => t('Note:'),
783
    '#markup' => t('When the menubar type 2 is selected, the menu text color, menu highlight color, menu divier color from the color set are ignored and the fixed colors that match to the menubar are used instead.  Besides, highlight color and menu divider color from the color set are still used for other places such as tabs and sub-menubar for superfish and nice_menus menu.'),
784
  );
785
786 d7f58da2 Florent Torregrosa
  $form['style']['menubar_background'] = array(
787
    '#type' => 'checkbox',
788
    '#title' => t('Allow Menubar background color.'),
789
    '#default_value' => theme_get_setting('menubar_background'),
790
    '#description' => t('Add your own hex background color below.'),
791
  );
792
793
  $form['style']['menubar_bg_value'] = array(
794
    '#type' => 'textfield',
795
    '#title' => t('Meubar background color'),
796
    '#default_value' => theme_get_setting('menubar_bg_value'),
797
    '#size' => 7,
798
    '#maxlength' => 7,
799
    '#description' => t('Specify the background color for the menubar. This setting is used only when the <em>Allow Meubar background</em> option is checked above.'),
800
  );
801
802
  /* --------------- Advanced header settings -------------- */
803 85ad3d82 Assos Assos
  $form['adv_header'] = array(
804
    '#type' => 'fieldset',
805
    '#title' => t('Advanced header settings'),
806
    '#collapsible' => TRUE,
807
    '#collapsed' => TRUE,
808
  );
809
  $form['adv_header']['header_searchbox'] = array(
810
    '#type' => 'checkbox',
811
    '#title' => t('Add search form to the header'),
812
    '#default_value' => theme_get_setting('header_searchbox'),
813
    '#description' => t('Check here if you want to add search form block to the right side of the header.'),
814
  );
815
  $form['adv_header']['header_fontsizer'] = array(
816
    '#type' => 'checkbox',
817
    '#title' => t('Add font resizing controls'),
818
    '#default_value' => theme_get_setting('header_fontsizer'),
819
    '#description' => t('Check here if you want to add font resizing controls at side of the header.'),
820
  );
821
  $form['adv_header']['header_height'] = array(
822
    '#type' => 'textfield',
823
    '#title' => t('Header height'),
824
    '#default_value' => theme_get_setting('header_height'),
825
    '#size' => 12,
826
    '#maxlength' => 8,
827
    '#description' => t('Specify the header height in px.'),
828
    '#prefix' => '<img src="/' . drupal_get_path('theme', 'mayo') . '/images/header-layout.png" /><br />',
829
  );
830
  $form['adv_header']['header_border_width'] = array(
831
    '#type' => 'textfield',
832
    '#title' => t('Header border width'),
833
    '#default_value' => theme_get_setting('header_border_width'),
834
    '#size' => 12,
835
    '#maxlength' => 8,
836
    '#description' => t('Specify the header border width in px. Note that header border is not drawn when you use header background image or when you use layout style 2.'),
837
  );
838
  $form['adv_header']['logo_left_margin'] = array(
839
    '#type' => 'textfield',
840
    '#title' => t('Logo left margin'),
841
    '#default_value' => theme_get_setting('logo_left_margin'),
842
    '#size' => 12,
843
    '#maxlength' => 8,
844
    '#description' => t('Specify the left margin of the logo in px. This setting is used only when the logo option is enabled.'),
845
  );
846
  $form['adv_header']['logo_top_margin'] = array(
847
    '#type' => 'textfield',
848
    '#title' => t('Logo top margin'),
849
    '#default_value' => theme_get_setting('logo_top_margin'),
850
    '#size' => 12,
851
    '#maxlength' => 8,
852
    '#description' => t('Specify the top margin of the logo in px. This setting is used only when the logo option is enabled.'),
853
  );
854
  $form['adv_header']['sitename_left_margin'] = array(
855
    '#type' => 'textfield',
856
    '#title' => t('Site name left margin'),
857
    '#default_value' => theme_get_setting('sitename_left_margin'),
858
    '#size' => 12,
859
    '#maxlength' => 8,
860
    '#description' => t('Specify the left margin of the site name in px. This setting is used only when the sitename option is enabled.'),
861
  );
862
  $form['adv_header']['sitename_top_margin'] = array(
863
    '#type' => 'textfield',
864
    '#title' => t('Site name top margin'),
865
    '#default_value' => theme_get_setting('sitename_top_margin'),
866
    '#size' => 12,
867
    '#maxlength' => 8,
868
    '#description' => t('Specify the top margin of the site name in px. This setting is used only when the sitename option is enabled.'),
869
  );
870
  $form['adv_header']['searchbox_right_margin'] = array(
871
    '#type' => 'textfield',
872
    '#title' => t('Search form right margin'),
873
    '#default_value' => theme_get_setting('searchbox_right_margin'),
874
    '#size' => 12,
875
    '#maxlength' => 8,
876
    '#description' => t('Specify the right margin of the search form in px. This setting is used only when the header search form option is enabled.'),
877
  );
878
  $form['adv_header']['searchbox_top_margin'] = array(
879
    '#type' => 'textfield',
880
    '#title' => t('Search form top margin'),
881
    '#default_value' => theme_get_setting('searchbox_top_margin'),
882
    '#size' => 12,
883
    '#maxlength' => 8,
884
    '#description' => t('Specify the right margin of the search form in px. This setting is used only when the header search form option is enabled.'),
885
  );
886
  $form['adv_header']['searchbox_size'] = array(
887
    '#type' => 'textfield',
888
    '#title' => t('Search form textfield width'),
889
    '#default_value' => theme_get_setting('searchbox_size'),
890
    '#size' => 10,
891
    '#maxlength' => 6,
892
    '#description' => t('Specify the width of the text field of the search forms in characters. This size is also applied for the search form in a block. NOTE: do not add px since this is not px size.'),
893
  );
894
  $form['adv_header']['header_bg_file'] = array(
895
    '#type' => 'textfield',
896
    '#title' => t('URL of the header background image'),
897
    '#default_value' => theme_get_setting('header_bg_file'),
898
    '#description' => t('If the background image is bigger than the header area, it is clipped. If it\'s smaller than the header area, it is tiled to fill the header area. To remove the background image, blank this field and save the settings.'),
899
    '#size' => 40,
900
    '#maxlength' => 120,
901
  );
902
  $form['adv_header']['header_bg'] = array(
903
    '#type' => 'file',
904
    '#title' => t('Upload header background image'),
905
    '#size' => 40,
906
    '#attributes' => array('enctype' => 'multipart/form-data'),
907
    '#description' => t('If you don\'t jave direct access to the server, use this field to upload your header background image'),
908
    '#element_validate' => array('mayo_header_bg_validate'),
909
  );
910
  $form['adv_header']['header_bg_alignment'] = array(
911
    '#type' => 'select',
912
    '#title' => t('Header backgeround image alignment'),
913
    '#default_value' => theme_get_setting('header_bg_alignment'),
914
    '#description' => t('Select the alignment of the header background image.'),
915
    '#options' => array(
916
      'top left' => t('Top left'),
917
      'top center' => t('Top center'),
918
      'top right' => t('Top right'),
919
      'center left' => t('Center left'),
920
      'center center' => t('Center center'),
921
      'center right' => t('Center right'),
922
      'bottom left' => t('Bottom left'),
923
      'bottom center' => t('Bottom center'),
924
      'bottom right' => t('Bottom right'),
925
    ),
926
  );
927
  $form['adv_header']['header_watermark'] = array(
928
    '#type' => 'select',
929
    '#title' => t('Header watermark'),
930
    '#default_value' => theme_get_setting('header_watermark'),
931
    '#description' => t('Select the watermark you want from the list below. The sample below is scaled down and the actual size of the watermark is bigger.'),
932
    '#options' => array(
933
      0 => t('-None-'),
934
      1 => t('Pixture'),
935
      2 => t('Wave'),
936
      3 => t('Bubble'),
937
      4 => t('Flower'),
938
      5 => t('Star'),
939
      6 => t('Metal'),
940
    ),
941
    '#suffix' => '<img src="/' . drupal_get_path('theme', 'mayo') . '/images/watermark-sample.png" /><br />',
942
  );
943
944 d7f58da2 Florent Torregrosa
  /* --------------- Misellanenous settings -------------- */
945 85ad3d82 Assos Assos
  $form['misc'] = array(
946
    '#type' => 'fieldset',
947
    '#title' => t('Miscellaneous settings'),
948
    '#collapsible' => TRUE,
949
    '#collapsed' => TRUE,
950
  );
951
  $form['misc']['display_breadcrumb'] = array(
952
    '#type' => 'checkbox',
953
    '#title' => t('Display breadcrumb'),
954
    '#default_value' => theme_get_setting('display_breadcrumb'),
955
    '#description' => t('Check here if you want to display breadcrumb.'),
956
  );
957
  $form['misc']['dark_messages'] = array(
958
    '#type' => 'checkbox',
959
    '#title' => t('Use dark message colors'),
960
    '#default_value' => theme_get_setting('dark_messages'),
961 578c6d8f Assos Assos
    '#return_value' => 'dark-messages',
962 85ad3d82 Assos Assos
    '#description' => t('Check here if you use the dark color set. Colors for the status/warning/error messages are adjusted.'),
963
  );
964
965 d7f58da2 Florent Torregrosa
  /*
966
   * Originally posted by dvessel (http://drupal.org/user/56782).
967
   * The following will be processed even if the theme is inactive.
968
   * If you are on a theme specific settings page but it is not an active
969
   * theme (example.com/admin/apearance/settings/THEME_NAME), it will
970
   * still be processed.
971
   *
972
   * Build a list of themes related to the theme specific form. If the form
973
   * is specific to a sub-theme, all parent themes leading to it will have
974
   * hook_form_theme_settings invoked. For example, if a theme named
975
   * 'grandchild' has its settings form in focus, the following will be invoked.
976
   * - parent_form_theme_settings()
977
   * - child_form_theme_settings()
978
   * - grandchild_form_theme_settings()
979
   *
980
   * If 'child' was in focus it will invoke:
981
   * - parent_form_theme_settings()
982
   * - child_form_theme_settings()
983
   *
984
   *  @see http://drupal.org/node/943212
985
   */
986
  $form_themes = array();
987
  $themes = list_themes();
988
  $_theme = $GLOBALS['theme_key'];
989
  while (isset($_theme)) {
990
    $form_themes[$_theme] = $_theme;
991
    $_theme = isset($themes[$_theme]->base_theme) ? $themes[$_theme]->base_theme : NULL;
992
  }
993
  $form_themes = array_reverse($form_themes);
994
995
  foreach ($form_themes as $theme_key) {
996
    if (function_exists($form_settings = "{$theme_key}_form_theme_settings")) {
997
      $form_settings($form, $form_state);
998
    }
999
  }
1000
1001
  // Include custom form validation and submit functions
1002
  require_once(drupal_get_path('theme', 'mayo') . '/inc/forms/mayo.validate.inc');
1003
  require_once(drupal_get_path('theme', 'mayo') . '/inc/forms/mayo.submit.inc');
1004
1005
  // Custom validate and submit functions
1006
  $form['#validate'][] = 'mayo_settings_validate';
1007
  $form['#submit'][] = 'mayo_settings_submit';
1008 85ad3d82 Assos Assos
}
1009
1010
/**
1011
 * Check and save the uploaded header background image
1012
 */
1013
function mayo_header_bg_validate($element, &$form_state) {
1014
  global $base_url;
1015
1016
  $validators = array('file_validate_is_image' => array());
1017
  $file = file_save_upload('header_bg', $validators, "public://", FILE_EXISTS_REPLACE);
1018
1019
  if ($file) {
1020
    // change file's status from temporary to permanent and update file database
1021
    $file->status = FILE_STATUS_PERMANENT;
1022
    file_save($file);
1023
1024
    $file_url = file_create_url($file->uri);
1025
    $file_url = str_ireplace($base_url, '', $file_url);
1026
1027
    // set to form
1028
    $form_state['values']['header_bg_file'] = $file_url;
1029
  }
1030
}
1031
1032
/**
1033
 * Validate page width
1034
 */
1035
function mayo_page_width_validate($element, &$form_state) {
1036
  if (!empty($element['#value'])) {
1037
    $width = $element['#value'];
1038
1039
    // check if it is liquid (%) or fixed width (px)
1040 d7f58da2 Florent Torregrosa
    if (preg_match("/(\d+)\s*%/", $width, $match)) {
1041 85ad3d82 Assos Assos
      $num = intval($match[0]);
1042 d7f58da2 Florent Torregrosa
      if (50 <= $num && $num <= 100) {
1043 85ad3d82 Assos Assos
        return;
1044
      }
1045
      else {
1046
        form_error($element, t('The width for the liquid layout must be a value between 50% and 100%.'));
1047
      }
1048
    }
1049 d7f58da2 Florent Torregrosa
    elseif (preg_match("/(\d+)\s*px/", $width, $match)) {
1050 85ad3d82 Assos Assos
      $num = intval($match[0]);
1051 d7f58da2 Florent Torregrosa
      if (700 <= $num && $num < 1600) {
1052 85ad3d82 Assos Assos
        return;
1053
      }
1054
      else {
1055
        form_error($element, t('The width for the fixed layout must be a value between 700px and 1600px.'));
1056
      }
1057
    }
1058
  }
1059
}
1060
1061
/**
1062
 * Validate sidebar width
1063
 */
1064
function mayo_sidebar_width_validate($element, &$form_state) {
1065
  if (!empty($element['#value'])) {
1066
    $width = $element['#value'];
1067
1068
    // check if it is liquid (%) or fixed width (px)
1069 d7f58da2 Florent Torregrosa
    if (preg_match("/(\d+)\s*%/", $width, $match)) {
1070 85ad3d82 Assos Assos
      $num = intval($match[0]);
1071 d7f58da2 Florent Torregrosa
      if (15 <= $num && $num <= 40) {
1072 85ad3d82 Assos Assos
        return;
1073
      }
1074
      else {
1075
        form_error($element, t('The width of the sidebar must be a value between 15% and 40%.'));
1076
      }
1077
    }
1078 d7f58da2 Florent Torregrosa
    elseif (preg_match("/(\d+)\s*px/", $width, $match)) {
1079 85ad3d82 Assos Assos
      form_error($element, t('The width of the sidebar must be a value between 15% and 40%. Do not forget to add % character.'));
1080
    }
1081
  }
1082
}