Projet

Général

Profil

Révision 74f6bef0

Ajouté par Assos Assos il y a plus de 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/themes/adaptivetheme/at_core/inc/forms/settings.responsivepanels.inc
4 4
 * @file
5 5
 * Generate form elments for the Panel and Gpanel Reponsive Layout settings.
6 6
 */
7
function at_core_responsive_panels_form(&$form, $theme_name, $info_array) {
8
  // Supported devices
9
  $devices = array(
10
    'bigscreen',
11
    'tablet_landscape',
12
    'tablet_portrait',
13
    'smalltouch_landscape',
14
  );
7 15

  
8
// Supported devices
9
$devices = array(
10
  'bigscreen',
11
  'tablet_landscape',
12
  'tablet_portrait',
13
  'smartphone_landscape',
14
);
15

  
16
// Get the configuration array for panel layouts
17
$rpl = responsive_panels_data_structure();
18

  
19
// Check if panels exists
20
$panels = module_exists('panels') ? TRUE : FALSE;
16
  // Get the configuration array for panel layouts
17
  $rpl = responsive_panels_data_structure();
21 18

  
22
// Set variables here for active Gpanels, we need to test on this later
23
$active_gpanels = array();
24
$active_gpanels_arrays = array();
19
  // Check if panels exists
20
  $panels = module_exists('panels') ? TRUE : FALSE;
25 21

  
26
// Get the active themes info array
27
$info_array = at_get_info($theme_name);
22
  // Set variables here for active Gpanels, we need to test on this later
23
  $active_gpanels = array();
24
  $active_gpanels_arrays = array();
28 25

  
29
// Build a keyed array of the regions, we need to reset the keys for
30
// array_intersect() to figure out which Gpanels are being used
31
foreach ($info_array['regions'] as $key => $value) {
32
  $theme_regions[] = $key;
33
}
26
  // Build a keyed array of the regions, we need to reset the keys for
27
  // array_intersect() to figure out which Gpanels are being used
28
  foreach ($info_array['regions'] as $key => $value) {
29
    $theme_regions[] = $key;
30
  }
34 31

  
35
// Get the standard Gpanel regions list
36
$gpanel_regions = gpanel_regions();
32
  // Get the standard Gpanel regions list
33
  $gpanel_regions = gpanel_regions();
37 34

  
38
// Figure out which gpanels are actually being used in the theme
39
$active_gpanels = array();
40
foreach ($gpanel_regions as $gpanel => $gpanel_array) {
41
  if (array_intersect($theme_regions, $gpanel_array['regions'])) {
42
    $active_gpanels[] = $gpanel;
43
    $active_gpanels_arrays[] = $gpanel_array;
35
  // Figure out which gpanels are actually being used in the theme
36
  $active_gpanels = array();
37
  foreach ($gpanel_regions as $gpanel => $gpanel_array) {
38
    if (array_intersect($theme_regions, $gpanel_array['regions'])) {
39
      $active_gpanels[] = $gpanel;
40
      $active_gpanels_arrays[] = $gpanel_array;
41
    }
44 42
  }
45
}
46 43

  
47
// Make certain we only list each Gpanel once
48
array_unique($active_gpanels);
44
  // Make certain we only list each Gpanel once
45
  array_unique($active_gpanels);
49 46

  
50
// Make a list of all active Gpanel titles, if any
51
$used_gpanels = '';
52
if (!empty($active_gpanels)) {
53
  foreach ($active_gpanels_arrays as $active_gpanel) {
54
    $gpanels_titles[] = $active_gpanel['title'];
47
  // Make a list of all active Gpanel titles, if any
48
  $used_gpanels = '';
49
  if (!empty($active_gpanels)) {
50
    foreach ($active_gpanels_arrays as $active_gpanel) {
51
      $gpanels_titles[] = $active_gpanel['title'];
52
    }
53
    $used_gpanels = t('<p>Your theme currently uses these Gpanels:</p>!used_gpanels', array('!used_gpanels' => theme('item_list', array('items' => $gpanels_titles))));
55 54
  }
56
  $used_gpanels = t('<p>Your theme currently uses these Gpanels:</p>!used_gpanels', array('!used_gpanels' => theme('item_list', array('items' => $gpanels_titles))));
57
}
58 55

  
59
// Get all standard Plugin layout names
60
foreach ($rpl as $rpl_key => $values) {
61
  foreach ($values as $value) {
62
    foreach ($value as $k => $v) {
63
      $active_rpl[] = $v['theme'];
64
      $active_types[] = $v['type'];
56
  // Get all standard Plugin layout names
57
  foreach ($rpl as $rpl_key => $values) {
58
    foreach ($values as $value) {
59
      foreach ($value as $k => $v) {
60
        $active_rpl[] = $v['theme'];
61
        $active_types[] = $v['type'];
62
      }
65 63
    }
66 64
  }
67
}
68 65

  
69
// This is will not be sustaintable, what I need is a function that sorts the
70
// layouts properly, alphabetical is no good, it needs to be in a very precise
71
// order to make sense in the UI.
72
if (isset($rpl['one'])) {
73
  unset($rpl['one']);
74
}
75
if (isset($rpl['six'])) {
76
  $six = $rpl['six']; unset($rpl['six']); $rpl['six'] = $six;
77
}
78
if (isset($rpl['inset'])) {
79
  $inset = $rpl['inset']; unset($rpl['inset']); $rpl['inset'] = $inset;
80
}
81

  
82
// Get the admin css files for each plugin
83
$panels_admin_css_files = responsive_plugins_admin_css($theme_name, $plugin_type = 'panels');
84
foreach ($panels_admin_css_files as $filepath) {
85
  if (file_exists($filepath)) {
86
    $panels_css_files['css'][] = array('type' => 'file', 'data' => $filepath, 'weight' => 100);
66
  // This is will not be sustaintable, what I need is a function that sorts the
67
  // layouts properly, alphabetical is no good, it needs to be in a very precise
68
  // order to make sense in the UI.
69
  if (isset($rpl['one'])) {
70
    unset($rpl['one']);
71
  }
72
  if (isset($rpl['six'])) {
73
    $six = $rpl['six']; unset($rpl['six']); $rpl['six'] = $six;
74
  }
75
  if (isset($rpl['inset'])) {
76
    $inset = $rpl['inset']; unset($rpl['inset']); $rpl['inset'] = $inset;
87 77
  }
88
}
89

  
90
// Set title and message
91
$panels_title = t('Panels &amp; Gpanels');
92
$panels_message = t('<h3>!panels_title</h3><p>Adaptivetheme supports responsive Panels and Gpanel layouts. To use this capability you can use the <a href="!panels_link" target="_blank">Panels module</a>, <a href="!ds_link" target="_blank">Display Suite</a> (with Panels) or Adaptivethemes native <a href="!gpanels_link" target="_blank">Gpanels</a> layouts. To views all layouts on one page and test your settings you can enable the panels test, see the Debuggers tab.</p><p><b>Usage:</b> select options for each device range and layout type.</p>!gpanels_message', array('!panels_title' => $panels_title, '!panels_link' => 'http://drupal.org/project/panels', '!gpanels_link' => 'http://adaptivethemes.com/documentation/using-gpanels', '!ds_link' => 'http://drupal.org/project/ds', '!gpanels_message' => $used_gpanels));
93 78

  
94
// Gpanels and Panels top level wrapper
95
$form['at-settings']['panels'] = array(
96
  '#type' => 'fieldset',
97
  '#title' => $panels_title,
98
  '#description' => $panels_message,
99
  '#attached' => $panels_css_files,
100
);
79
  // Get the admin css files for each plugin
80
  $panels_admin_css_files = responsive_plugins_admin_css($theme_name, $plugin_type = 'panels');
81
  foreach ($panels_admin_css_files as $filepath) {
82
    if (file_exists($filepath)) {
83
      $panels_css_files['css'][] = array('type' => 'file', 'data' => $filepath, 'weight' => 100);
84
    }
85
  }
101 86

  
102
// Disabled message
103
$panels_disable_message = t('<p>The responsive layout is disabled, only the default layout for each Gpanel and Panel layout will be used.</p><p>To re-enable uncheck the "Disable responsive layout and styles" checkbox under the "Settings" tab.</p>');
87
  // Set title and message
88
  $panels_title = t('Panels &amp; Gpanels');
89
  $panels_message = t('<h3>!panels_title</h3><p>Adaptivetheme supports responsive Panels and Gpanel layouts. To use this capability you can use the <a href="!panels_link" target="_blank">Panels module</a>, <a href="!ds_link" target="_blank">Display Suite</a> (with Panels) or Adaptivethemes native <a href="!gpanels_link" target="_blank">Gpanels</a> layouts. To views all layouts on one page and test your settings you can enable the panels test, see the Debuggers tab.</p><p><b>Usage:</b> select options for each device range and layout type.</p>!gpanels_message', array('!panels_title' => $panels_title, '!panels_link' => 'http://drupal.org/project/panels', '!gpanels_link' => 'http://adaptivethemes.com/documentation/using-gpanels', '!ds_link' => 'http://drupal.org/project/ds', '!gpanels_message' => $used_gpanels));
104 90

  
105
if(at_get_setting('disable_responsive_styles') === 1) {
106
  $form['at-settings']['panels']['disabled'] = array(
107
    '#markup' => '<div class="messages warning">' . $panels_disable_message . '</div>',
91
  // Gpanels and Panels top level wrapper
92
  $form['at-settings']['panels'] = array(
93
    '#type' => 'fieldset',
94
    '#title' => $panels_title,
95
    '#description' => $panels_message,
96
    '#attached' => $panels_css_files,
108 97
  );
109
}
110 98

  
111
$form['at-settings']['panels']['panels-wrapper'] = array(
112
  '#type' => 'fieldset',
113
  '#attributes' => array('class' => array('panel-option-lists')),
114
  '#states' => array(
115
    'disabled' => array('input[name="disable_responsive_styles"]' => array('checked' => TRUE)),
116
  ),
117
);
118

  
119
foreach ($devices as $device) {
120
  $title = str_replace('_', ' ', drupal_ucfirst($device));
121
  if ($device == 'bigscreen') {
122
    $title = 'Standard layout';
99
  // Disabled message
100
  $panels_disable_message = t('<p>The responsive layout is disabled, only the default layout for each Gpanel and Panel layout will be used.</p><p>To re-enable uncheck the "Disable responsive layout and styles" checkbox under the "Global Settings" tab.</p>');
101

  
102
  if(at_get_setting('disable_responsive_styles') === 1) {
103
    $form['at-settings']['panels']['disabled'] = array(
104
      '#markup' => '<div class="messages warning">' . $panels_disable_message . '</div>',
105
    );
123 106
  }
124
  $form['at-settings']['panels']['panels-wrapper'][$device] = array(
107

  
108
  $form['at-settings']['panels']['panels-wrapper'] = array(
125 109
    '#type' => 'fieldset',
126
    '#title' => t($title),
127
    '#collapsible' => TRUE,
128
    '#collapsed' => TRUE,
129
    '#description' => t('Select the layouts you want to use when the site is being viewed in !device.', array('!device' => strtolower($title))),
110
    '#attributes' => array('class' => array('panel-option-lists')),
111
    '#states' => array(
112
      'disabled' => array('input[name="disable_responsive_styles"]' => array('checked' => TRUE)),
113
    ),
130 114
  );
131
  if (isset($rpl)) {
132
    foreach ($rpl as $group => $layouts) {
133
      if (!empty($layouts)) {
134
        $form['at-settings']['panels']['panels-wrapper'][$device][$group] = array(
135
          '#type' => 'fieldset',
136
          '#title' => t($group),
137
          '#collapsible' => TRUE,
138
          '#collapsed' => TRUE,
139
        );
140
        foreach ($layouts as $layout) {
141
          foreach ($layout as $key => $value) {
142
            if (isset($value['theme'])) {
143
              $form['at-settings']['panels']['panels-wrapper'][$device][$group][$device . '_' . $value['theme']] = array(
144
                '#type' => 'radios',
145
                '#title' => t($value['title']),
146
                '#default_value' => at_get_setting($device . '_' . $value['theme']),
147
                '#options' => $value['options'],
148
              );
115

  
116
  foreach ($devices as $device) {
117
    $title = str_replace('_', ' ', drupal_ucfirst($device));
118
    if ($device == 'bigscreen') {
119
      $title = 'Standard layout';
120
    }
121
    $form['at-settings']['panels']['panels-wrapper'][$device] = array(
122
      '#type' => 'fieldset',
123
      '#title' => t($title),
124
      '#collapsible' => TRUE,
125
      '#collapsed' => TRUE,
126
      '#description' => t('Select the layouts you want to use when the site is being viewed in !device.', array('!device' => strtolower($title))),
127
    );
128
    if (isset($rpl)) {
129
      foreach ($rpl as $group => $layouts) {
130
        if (!empty($layouts)) {
131
          $form['at-settings']['panels']['panels-wrapper'][$device][$group] = array(
132
            '#type' => 'fieldset',
133
            '#title' => t($group),
134
            '#collapsible' => TRUE,
135
            '#collapsed' => TRUE,
136
          );
137
          foreach ($layouts as $layout) {
138
            foreach ($layout as $key => $value) {
139
              if (isset($value['theme'])) {
140
                $default_value = at_get_setting($device . '_' . $value['theme']);
141
                // Add a check for backwards compatibility with pre 7.x-3.2 themes
142
                if ($device == 'smalltouch_landscape') {
143
                  $default_value = at_get_setting('smalltouch_landscape_' . $value['theme']) ? at_get_setting('smalltouch_landscape_' . $value['theme']) : at_get_setting('smartphone_landscape_' . $value['theme']);
144
                }
145
                $form['at-settings']['panels']['panels-wrapper'][$device][$group][$device . '_' . $value['theme']] = array(
146
                  '#type' => 'radios',
147
                  '#title' => t($value['title']),
148
                  '#default_value' => $default_value,
149
                  '#options' => $value['options'],
150
                );
151
              }
149 152
            }
150 153
          }
151 154
        }

Formats disponibles : Unified diff