Projet

Général

Profil

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

root / drupal7 / sites / all / themes / mayo / inc / forms / mayo.validate.inc @ d7f58da2

1
<?php
2

    
3
/**
4
 * @file
5
 * Validatation for some of the theme settings.
6
 *
7
 * @param $form
8
 * @param $form_state
9
 */
10
function mayo_settings_validate($form, &$form_state) {
11
  $values = $form_state['values'];
12
  $theme_name = $form_state['build_info']['args'][0];
13

    
14
  // Validate our form #state required fields, #states are UI only.
15
  // Bigscreen
16
  if (empty($values['bigscreen_sidebar_first'])) {
17
    form_set_error('bigscreen_sidebar_first', t('Standard Layout <em>First sidebar</em> width is empty - you must enter a value.'));
18
  }
19
  if (empty($values['bigscreen_sidebar_second'])) {
20
    form_set_error('bigscreen_sidebar_second', t('Standard Layout <em>Second sidebar</em> width is empty - you must enter a value.'));
21
  }
22

    
23
  // Tablet
24
  if (empty($values['tablet_landscape_sidebar_first'])) {
25
    form_set_error('tablet_landscape_sidebar_first', t('Tablet Landscape <em>First sidebar</em> width is empty - you must enter a value.'));
26
  }
27
  if ($values['tablet_landscape_layout'] === 'three_col_grail' || $values['tablet_landscape_layout'] === 'two_sidebars_left' || $values['tablet_landscape_layout'] === 'two_sidebars_right') {
28
    if (empty($values['tablet_landscape_sidebar_second'])) {
29
      form_set_error('tablet_landscape_sidebar_second', t('Tablet Landscape <em>First sidebar</em> width is empty - you must enter a value. The layout you selected requires values for both sidebars.'));
30
    }
31
  }
32

    
33
  // Smalltouch
34
  if ($values['smalltouch_landscape_layout'] === 'one_col_vert') {
35
    if (empty($values['smalltouch_landscape_sidebar_first'])) {
36
      form_set_error('smalltouch_landscape_sidebar_first', t('Smalltouch First Sidebar width is empty - enter a value or choose another layout.'));
37
    }
38
    if (empty($values['smalltouch_landscape_sidebar_second'])) {
39
      form_set_error('smalltouch_landscape_sidebar_second', t('Smalltouch Second Sidebar width is empty - enter a value or choose another layout.'));
40
    }
41
  }
42
}