Projet

Général

Profil

Révision d7f58da2

Ajouté par Florent Torregrosa il y a presque 10 ans

Switch MAYO on version 7.x-2.0 to be adaptative.

Voir les différences:

drupal7/sites/all/themes/mayo/theme-settings.php
1 1
<?php
2

  
3 2
/**
3
 * @file
4 4
 * Implements hook_form_system_theme_settings_alter().
5 5
 *
6 6
 * Custom theme settings
......
8 8
function mayo_form_system_theme_settings_alter(&$form, &$form_state) {
9 9

  
10 10
  drupal_add_js(drupal_get_path('theme', 'mayo') . '/js/mayo.js');
11
    // 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);
11 37

  
12
  /*--------------- Font settings --------------*/
38
    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 -------------- */
13 55
  $form['font'] = array(
14 56
    '#type' => 'fieldset',
15 57
    '#title' => t('Font settings'),
......
71 113
    '#suffix' => '</div>',
72 114
  );
73 115

  
74
  /*--------------- Layout settings --------------*/
116
  /* --------------- Layout settings -------------- */
75 117
  $form['layout'] = array(
76 118
    '#type' => 'fieldset',
77 119
    '#title' => t('Layout settings'),
......
87 129
    '#description' => t('Specify the base vertical (top/bottom) margin which is vertical spaces between page edge and browser screen in px.'),
88 130
    '#prefix' => '<img src="/' . drupal_get_path('theme', 'mayo') . '/images/base-layout.png" /><br />',
89 131
  );
90
  $form['layout']['page_width'] = array(
91
    '#type' => 'textfield',
92
    '#title' => t('Page width'),
93
    '#default_value' => theme_get_setting('page_width'),
94
    '#size' => 12,
95
    '#maxlength' => 8,
96
    '#description' => t('Specify the page width including sidebars either in percent ratio (50-100%) for liquid layout, or in px (700-1600px) for fixed layout. If an invalid value is specified, the default value (90%) is used instead. You can leave this field blank to use the default value. Do not forget to add either % or px after the number.'),
97
    '#element_validate' => array('mayo_page_width_validate'),
98
  );
99 132
  $form['layout']['page_margin'] = array(
100 133
    '#type' => 'textfield',
101 134
    '#title' => t('Page margin'),
......
115 148
    '#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 looks better.'),
116 149
  );
117 150

  
118
  /*--------------- Advanced sidebar settings --------------*/
119
  $form['layout']['sidebar'] = array(
151
  /* --------------- Responsive sidebar layout settings -------------- */
152
  /* -----------Big screen as in desktop pc monitor------------- */
153
  $form['layout']['bigscreen'] = array(
120 154
    '#type' => 'fieldset',
121
    '#title' => t('Sidebar layout settings'),
155
    '#title' => t('Big Screen Sidebar layout'),
122 156
    '#collapsible' => TRUE,
123 157
    '#collapsed' => TRUE,
158
    '#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'),
124 167
  );
125
  $form['layout']['sidebar']['sidebar_layout_style'] = array(
168
    // 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(
126 307
    '#type' => 'radios',
127
    '#title' => t('Sidebar layout style'),
128
    '#default_value' => theme_get_setting('sidebar_layout_style'),
129
    '#options' => array(
130
      1 => t('1. Sidebar first comes left, sidebar second comes right.'),
131
      2 => t('2. Both sidebars come left.'),
132
      3 => t('3. Both sidebars come right.'),
308
    '#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
      ),
133 343
    ),
134
    '#prefix' => '<img src="/' . drupal_get_path('theme', 'mayo') . '/images/sidebar-layout.png" />',
135 344
  );
136
  $form['layout']['sidebar']['sidebar_first_width'] = array(
345

  
346
  // Sidebar second
347
  $form['layout']['tablet']['landscape']['tablet-landscape-sidebar-width-wrapper']['tablet_landscape_sidebar_second'] = array(
137 348
    '#type' => 'textfield',
138
    '#title' => t('Sidebar first width'),
139
    '#default_value' => theme_get_setting('sidebar_first_width'),
140
    '#size' => 12,
141
    '#maxlength' => 8,
142
    '#description' => t('Specify the width of the sidebar first in % (15-40%). px value can not be used.'),
143
    '#element_validate' => array('mayo_sidebar_width_validate'),
349
    '#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
    ),
144 376
  );
145
  $form['layout']['sidebar']['sidebar_second_width'] = array(
377
  $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(
146 420
    '#type' => 'textfield',
147
    '#title' => t('Sidebar second width'),
148
    '#default_value' => theme_get_setting('sidebar_second_width'),
149
    '#size' => 12,
150
    '#maxlength' => 8,
151
    '#description' => t('Specify the width of the sidebar first in % (15-40%). px value can not be used.'),
152
    '#element_validate' => array('mayo_sidebar_width_validate'),
421
    '#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,
153 426
  );
154
  $form['layout']['sidebar']['note'] = array(
155
    '#type' => 'item',
156
    '#title' => t('Note:'),
157
    '#markup' => t('Main contents width is automatically determined based on the width of the sidebar and number of sidebar used.'),
427

  
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
    ),
158 509
  );
159 510

  
511
  // 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
  );
160 625

  
161
  /*--------------- Style settings --------------*/
626
  $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 -------------- */
162 737
  $form['style'] = array(
163 738
    '#type' => 'fieldset',
164 739
    '#title' => t('Style settings'),
165 740
    '#collapsible' => TRUE,
166 741
    '#collapsed' => TRUE,
167 742
  );
743
  $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
  );
168 756
  $form['style']['round_corners'] = array(
169 757
    '#type' => 'select',
170 758
    '#title' => t('Content box round corners'),
171 759
    '#default_value' => theme_get_setting('round_corners'),
172
    '#description' => t('Make the corner of sidebar block and/or node rounded.<br/><b>Note:</b> This feature does not work with IE. Currently, it works with Safari, Firefox, Opera, Google Chrome.'),
760
    '#description' => t('Make the corner of sidebar block and/or node rounded.'),
173 761
    '#options' => array(
174
      0 => t('No round corners'),
175
      1 => t('Sidebar block only'),
176
      2 => t('Node only'),
177
      3 => t('Both sidebar block and node'),
762
      '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'),
178 766
    ),
179 767
    '#suffix' => '<img src="/' . drupal_get_path('theme', 'mayo') . '/images/round-corners.png" /><br />',
180 768
  );
......
195 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.'),
196 784
  );
197 785

  
198
  /*--------------- Advanced header settings --------------*/
786
  $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 -------------- */
199 803
  $form['adv_header'] = array(
200 804
    '#type' => 'fieldset',
201 805
    '#title' => t('Advanced header settings'),
......
337 941
    '#suffix' => '<img src="/' . drupal_get_path('theme', 'mayo') . '/images/watermark-sample.png" /><br />',
338 942
  );
339 943

  
340
  /*--------------- Misellanenous settings --------------*/
944
  /* --------------- Misellanenous settings -------------- */
341 945
  $form['misc'] = array(
342 946
    '#type' => 'fieldset',
343 947
    '#title' => t('Miscellaneous settings'),
......
354 958
    '#type' => 'checkbox',
355 959
    '#title' => t('Use dark message colors'),
356 960
    '#default_value' => theme_get_setting('dark_messages'),
961
    '#value' => 'dark-messages',
357 962
    '#description' => t('Check here if you use the dark color set. Colors for the status/warning/error messages are adjusted.'),
358 963
  );
359 964

  
965
  /*
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';
360 1008
}
361 1009

  
362 1010
/**
......
389 1037
    $width = $element['#value'];
390 1038

  
391 1039
    // check if it is liquid (%) or fixed width (px)
392
    if(preg_match("/(\d+)\s*%/", $width, $match)) {
1040
    if (preg_match("/(\d+)\s*%/", $width, $match)) {
393 1041
      $num = intval($match[0]);
394
      if(50 <= $num && $num <= 100) {
1042
      if (50 <= $num && $num <= 100) {
395 1043
        return;
396 1044
      }
397 1045
      else {
398 1046
        form_error($element, t('The width for the liquid layout must be a value between 50% and 100%.'));
399 1047
      }
400 1048
    }
401
    else if(preg_match("/(\d+)\s*px/", $width, $match)) {
1049
    elseif (preg_match("/(\d+)\s*px/", $width, $match)) {
402 1050
      $num = intval($match[0]);
403
      if(700 <= $num && $num < 1600) {
1051
      if (700 <= $num && $num < 1600) {
404 1052
        return;
405 1053
      }
406 1054
      else {
......
418 1066
    $width = $element['#value'];
419 1067

  
420 1068
    // check if it is liquid (%) or fixed width (px)
421
    if(preg_match("/(\d+)\s*%/", $width, $match)) {
1069
    if (preg_match("/(\d+)\s*%/", $width, $match)) {
422 1070
      $num = intval($match[0]);
423
      if(15 <= $num && $num <= 40) {
1071
      if (15 <= $num && $num <= 40) {
424 1072
        return;
425 1073
      }
426 1074
      else {
427 1075
        form_error($element, t('The width of the sidebar must be a value between 15% and 40%.'));
428 1076
      }
429 1077
    }
430
    else if(preg_match("/(\d+)\s*px/", $width, $match)) {
1078
    elseif (preg_match("/(\d+)\s*px/", $width, $match)) {
431 1079
      form_error($element, t('The width of the sidebar must be a value between 15% and 40%. Do not forget to add % character.'));
432 1080
    }
433 1081
  }

Formats disponibles : Unified diff