1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Generate form elments for the Panel and Gpanel Reponsive Layout settings.
|
6 |
|
|
*/
|
7 |
74f6bef0
|
Assos Assos
|
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 |
|
|
);
|
15 |
85ad3d82
|
Assos Assos
|
|
16 |
74f6bef0
|
Assos Assos
|
// Get the configuration array for panel layouts
|
17 |
|
|
$rpl = responsive_panels_data_structure();
|
18 |
85ad3d82
|
Assos Assos
|
|
19 |
74f6bef0
|
Assos Assos
|
// Check if panels exists
|
20 |
|
|
$panels = module_exists('panels') ? TRUE : FALSE;
|
21 |
85ad3d82
|
Assos Assos
|
|
22 |
74f6bef0
|
Assos Assos
|
// Set variables here for active Gpanels, we need to test on this later
|
23 |
|
|
$active_gpanels = array();
|
24 |
|
|
$active_gpanels_arrays = array();
|
25 |
85ad3d82
|
Assos Assos
|
|
26 |
74f6bef0
|
Assos Assos
|
// 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 |
|
|
}
|
31 |
85ad3d82
|
Assos Assos
|
|
32 |
74f6bef0
|
Assos Assos
|
// Get the standard Gpanel regions list
|
33 |
|
|
$gpanel_regions = gpanel_regions();
|
34 |
85ad3d82
|
Assos Assos
|
|
35 |
74f6bef0
|
Assos Assos
|
// 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 |
|
|
}
|
42 |
85ad3d82
|
Assos Assos
|
}
|
43 |
|
|
|
44 |
74f6bef0
|
Assos Assos
|
// Make certain we only list each Gpanel once
|
45 |
|
|
array_unique($active_gpanels);
|
46 |
85ad3d82
|
Assos Assos
|
|
47 |
74f6bef0
|
Assos Assos
|
// 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))));
|
54 |
85ad3d82
|
Assos Assos
|
}
|
55 |
|
|
|
56 |
74f6bef0
|
Assos Assos
|
// 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 |
|
|
}
|
63 |
85ad3d82
|
Assos Assos
|
}
|
64 |
|
|
}
|
65 |
|
|
|
66 |
74f6bef0
|
Assos Assos
|
// 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;
|
77 |
85ad3d82
|
Assos Assos
|
}
|
78 |
|
|
|
79 |
74f6bef0
|
Assos Assos
|
// 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 |
|
|
}
|
86 |
85ad3d82
|
Assos Assos
|
|
87 |
74f6bef0
|
Assos Assos
|
// Set title and message
|
88 |
|
|
$panels_title = t('Panels & 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));
|
90 |
85ad3d82
|
Assos Assos
|
|
91 |
74f6bef0
|
Assos Assos
|
// 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,
|
97 |
85ad3d82
|
Assos Assos
|
);
|
98 |
|
|
|
99 |
74f6bef0
|
Assos Assos
|
// 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 |
|
|
);
|
106 |
85ad3d82
|
Assos Assos
|
}
|
107 |
74f6bef0
|
Assos Assos
|
|
108 |
|
|
$form['at-settings']['panels']['panels-wrapper'] = array(
|
109 |
85ad3d82
|
Assos Assos
|
'#type' => 'fieldset',
|
110 |
74f6bef0
|
Assos Assos
|
'#attributes' => array('class' => array('panel-option-lists')),
|
111 |
|
|
'#states' => array(
|
112 |
|
|
'disabled' => array('input[name="disable_responsive_styles"]' => array('checked' => TRUE)),
|
113 |
|
|
),
|
114 |
85ad3d82
|
Assos Assos
|
);
|
115 |
74f6bef0
|
Assos Assos
|
|
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 |
|
|
}
|
152 |
85ad3d82
|
Assos Assos
|
}
|
153 |
|
|
}
|
154 |
|
|
}
|
155 |
|
|
}
|
156 |
|
|
}
|
157 |
|
|
}
|
158 |
|
|
} |