Projet

Général

Profil

Paste
Télécharger (4,18 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / adaptivetheme / at_core / inc / forms / settings.floatregionblocks.inc @ 74f6bef0

1
<?php
2

    
3
/**
4
 * @file
5
 * Generate form elments for the Float Region Blocks settings.
6
 */
7
function at_core_float_region_blocks_form(&$form, $info_array) {
8
  // Regions we don't want to include
9
  $unset_regions = array(
10
    'dashboard_main',
11
    'dashboard_sidebar',
12
    'dashboard_inactive',
13
    'page_bottom',
14
    'page_top',
15
    'content', // exclude the main content region
16
  );
17

    
18
  // Prepare regions
19
  foreach ($info_array['regions'] as $key => $value) {
20
    if (in_array($key, $unset_regions)) {
21
      unset($key);
22
    }
23
    if (isset($key)) {
24
      $regions[$key] = $value;
25
    }
26
  }
27

    
28
  // Setup the options for the select list
29
  $fbr_options = array(
30
    '<none>' => t('none'),
31
    '2' => '2',
32
    '3' => '3',
33
    '4' => '4',
34
    '5' => '5',
35
    '6' => '6',
36
    '7' => '7',
37
    '8' => '8',
38
    '9' => '9',
39
    '10' => '10',
40
    '11' => '11',
41
    '12' => '12',
42
  );
43

    
44
  $direction_options = array(
45
    'left' => t('Left'),
46
    'right' => t('Right'),
47
  );
48

    
49
  // Don't include this feature for now, its too late in the cycle
50
  // $breakpoints = array(
51
  //   '<none>' => t('none - I can handle this in CSS'),
52
  //   'smalltouch_portrait' => t('Smalltouch Portrait'),
53
  //   'smalltouch_landscape' => t('Smalltouch Landscape'),
54
  //   'tablet_portrait' => t('Tablet Portrait'),
55
  //   'tablet_landscape' => t('Tablet Landscape'),
56
  // );
57

    
58
  // Top level wrapper fieldset
59
  $form['at']['float-region-blocks'] = array(
60
    '#type' => 'fieldset',
61
    '#title' => t('Float Region Blocks'),
62
    '#description' => t('<h3>Float Region Blocks</h3><p>Select number of columns<sup>(i)</sup> for each region. For example if you want four blocks to line horizontally up choose 4, then select the float direction. Clearing<sup>(ii)</sup> (if you are trying to create a grid) and mobile displays<sup>(iii)</sup> must be accounted for in your theme.<p><ol><li>This will not create real columns, it merely sets a width on each block in the region. For example if you select 4, each block will be 25% wide, if you then add a fifth block to that region it will wrap below the other four, and so on.</li><li>There is no automagical clearing for uneven height blocks, so be weary of trying to create a grid with this. If you need real columns use a <a href="!gpanels_link" target="_blank">Gpanel</a> or the <a href="!panels_link" target="_blank">Panels module</a>.</li><li>See <code>responsive.custom.css</code> in your theme for an example of how to control blocks in mobile displays.</li></ol>', array('!gpanels_link' => 'http://adaptivethemes.com/documentation/using-gpanels', '!panels_link' => 'http://drupal.org/project/panels')),
63
    '#weight' => 35,
64
  );
65

    
66
  // Build form elements for each region
67
  foreach ($regions as $region_name => $region_label) {
68

    
69
    $title = check_plain($region_label);
70
    $region_name = check_plain($region_name);
71

    
72
    $form['at']['float-region-blocks']['region-options-' . $region_name] = array(
73
      '#type' => 'fieldset',
74
      '#title' => t("Options for the $title region"),
75
    );
76
    $form['at']['float-region-blocks']['region-options-' . $region_name]['float_block_' . $region_name] = array(
77
      '#type' => 'select',
78
      '#title' => t($title),
79
      '#default_value' => at_get_setting('float_block_' . $region_name),
80
      '#options' => $fbr_options,
81
    );
82
    $form['at']['float-region-blocks']['region-options-' . $region_name]['float_block_direction_' . $region_name] = array(
83
      '#type' => 'radios',
84
      '#title' => t('Float'),
85
      '#default_value' => at_get_setting('float_block_direction_' . $region_name) ? at_get_setting('float_block_direction_' . $region_name) : 'left',
86
      '#options' => $direction_options,
87
      '#states' => array('invisible' => array('select[name=float_block_' . $region_name . ']' => array('value' => '<none>'))),
88
    );
89

    
90
    // Don't include this feature for now, its too late in the cycle, better to
91
    // work on a much improved way of doing this for a point release later on.
92
    //$form['at']['float-region-blocks']['region-options-' . $region_name]['float_block_breakpoint_' . $region_name] = array(
93
    //  '#type' => 'select',
94
    //  '#title' => t('Breakpoint'),
95
    //  '#default_value' => at_get_setting('float_block_breakpoint_' . $region_name),
96
    //  '#options' => $breakpoints,
97
    //);
98
  }
99
}