1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
class stylizer_ui extends ctools_export_ui {
|
7 |
|
|
|
8 |
|
|
function access($op, $item) {
|
9 |
|
|
$access = parent::access($op, $item);
|
10 |
|
|
if ($op == 'add' && $access && empty($this->base_types)) {
|
11 |
|
|
|
12 |
|
|
$access = FALSE;
|
13 |
|
|
}
|
14 |
|
|
return $access;
|
15 |
|
|
}
|
16 |
|
|
|
17 |
|
|
function list_form(&$form, &$form_state) {
|
18 |
|
|
ctools_include('stylizer');
|
19 |
|
|
parent::list_form($form, $form_state);
|
20 |
|
|
|
21 |
|
|
$all = array('all' => t('- All -'));
|
22 |
|
|
|
23 |
|
|
if (empty($this->base_types)) {
|
24 |
|
|
|
25 |
|
|
drupal_set_message($this->plugin['strings']['message']['missing base type'], 'warning');
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
$types = $all;
|
29 |
|
|
foreach ($this->base_types as $module => $info) {
|
30 |
|
|
foreach ($info as $key => $base_type) {
|
31 |
|
|
$types[$module . '-' . $key] = $base_type['title'];
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
$form['top row']['type'] = array(
|
36 |
|
|
'#type' => 'select',
|
37 |
|
|
'#title' => t('Type'),
|
38 |
|
|
'#options' => $types,
|
39 |
|
|
'#default_value' => 'all',
|
40 |
|
|
'#weight' => -10,
|
41 |
|
|
'#attributes' => array('class' => array('ctools-auto-submit')),
|
42 |
|
|
);
|
43 |
|
|
|
44 |
|
|
$plugins = ctools_get_style_bases();
|
45 |
|
|
$form_state['style_plugins'] = $plugins;
|
46 |
|
|
|
47 |
|
|
$options = $all;
|
48 |
|
|
|
49 |
|
|
foreach ($plugins as $name => $plugin) {
|
50 |
|
|
$options[$name] = $plugin['title'];
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
$form['top row']['base'] = array(
|
54 |
|
|
'#type' => 'select',
|
55 |
|
|
'#title' => t('Base'),
|
56 |
|
|
'#options' => $all + $options,
|
57 |
|
|
'#default_value' => 'all',
|
58 |
|
|
'#weight' => -9,
|
59 |
|
|
'#attributes' => array('class' => array('ctools-auto-submit')),
|
60 |
|
|
);
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
function list_sort_options() {
|
64 |
|
|
return array(
|
65 |
|
|
'disabled' => t('Enabled, title'),
|
66 |
|
|
'title' => t('Title'),
|
67 |
|
|
'name' => t('Name'),
|
68 |
|
|
'base' => t('Base'),
|
69 |
|
|
'type' => t('Type'),
|
70 |
|
|
'storage' => t('Storage'),
|
71 |
|
|
);
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
function list_filter($form_state, $item) {
|
75 |
|
|
if (empty($form_state['style_plugins'][$item->settings['style_base']])) {
|
76 |
|
|
$this->style_plugin = array(
|
77 |
|
|
'name' => 'broken',
|
78 |
|
|
'title' => t('Missing plugin'),
|
79 |
|
|
'type' => t('Unknown'),
|
80 |
|
|
'module' => '',
|
81 |
|
|
);
|
82 |
|
|
}
|
83 |
|
|
else {
|
84 |
|
|
$this->style_plugin = $form_state['style_plugins'][$item->settings['style_base']];
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
$item->plugin_title = $this->style_plugin['title'];
|
90 |
|
|
|
91 |
|
|
if ($form_state['values']['type'] != 'all') {
|
92 |
|
|
list($module, $type) = explode('-', $form_state['values']['type']);
|
93 |
|
|
if ($module != $this->style_plugin['module'] || $type != $this->style_plugin['type']) {
|
94 |
|
|
return TRUE;
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
if ($form_state['values']['base'] != 'all' && $form_state['values']['base'] != $this->style_plugin['name']) {
|
99 |
|
|
return TRUE;
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
return parent::list_filter($form_state, $item);
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
function list_search_fields() {
|
106 |
|
|
$fields = parent::list_search_fields();
|
107 |
|
|
$fields[] = 'plugin_title';
|
108 |
|
|
return $fields;
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
function list_build_row($item, &$form_state, $operations) {
|
112 |
|
|
|
113 |
|
|
switch ($form_state['values']['order']) {
|
114 |
|
|
case 'disabled':
|
115 |
|
|
$this->sorts[$item->name] = empty($item->disabled) . $item->admin_title;
|
116 |
|
|
break;
|
117 |
|
|
case 'title':
|
118 |
|
|
$this->sorts[$item->name] = $item->admin_title;
|
119 |
|
|
break;
|
120 |
|
|
case 'name':
|
121 |
|
|
$this->sorts[$item->name] = $item->name;
|
122 |
|
|
break;
|
123 |
|
|
case 'type':
|
124 |
|
|
$this->sorts[$item->name] = $this->style_plugin['type'] . $item->admin_title;
|
125 |
|
|
break;
|
126 |
|
|
case 'base':
|
127 |
|
|
$this->sorts[$item->name] = $this->style_plugin['title'] . $item->admin_title;
|
128 |
|
|
break;
|
129 |
|
|
case 'storage':
|
130 |
|
|
$this->sorts[$item->name] = $item->type . $item->admin_title;
|
131 |
|
|
break;
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
if (!empty($this->base_types[$this->style_plugin['module']][$this->style_plugin['type']])) {
|
135 |
|
|
$type = $this->base_types[$this->style_plugin['module']][$this->style_plugin['type']]['title'];
|
136 |
|
|
}
|
137 |
|
|
else {
|
138 |
|
|
$type = t('Unknown');
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
$ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
|
142 |
|
|
|
143 |
|
|
$this->rows[$item->name] = array(
|
144 |
|
|
'data' => array(
|
145 |
|
|
array('data' => $type, 'class' => array('ctools-export-ui-type')),
|
146 |
|
|
array('data' => check_plain($item->name), 'class' => array('ctools-export-ui-name')),
|
147 |
|
|
array('data' => check_plain($item->admin_title), 'class' => array('ctools-export-ui-title')),
|
148 |
|
|
array('data' => check_plain($this->style_plugin['title']), 'class' => array('ctools-export-ui-base')),
|
149 |
|
|
array('data' => check_plain($item->type), 'class' => array('ctools-export-ui-storage')),
|
150 |
|
|
array('data' => $ops, 'class' => array('ctools-export-ui-operations')),
|
151 |
|
|
),
|
152 |
|
|
'title' => check_plain($item->admin_description),
|
153 |
|
|
'class' => array(!empty($item->disabled) ? 'ctools-export-ui-disabled' : 'ctools-export-ui-enabled'),
|
154 |
|
|
);
|
155 |
|
|
}
|
156 |
|
|
|
157 |
|
|
function list_table_header() {
|
158 |
|
|
return array(
|
159 |
|
|
array('data' => t('Type'), 'class' => array('ctools-export-ui-type')),
|
160 |
|
|
array('data' => t('Name'), 'class' => array('ctools-export-ui-name')),
|
161 |
|
|
array('data' => t('Title'), 'class' => array('ctools-export-ui-title')),
|
162 |
|
|
array('data' => t('Base'), 'class' => array('ctools-export-ui-base')),
|
163 |
|
|
array('data' => t('Storage'), 'class' => array('ctools-export-ui-storage')),
|
164 |
|
|
array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')),
|
165 |
|
|
);
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
function init($plugin) {
|
169 |
|
|
ctools_include('stylizer');
|
170 |
|
|
$this->base_types = ctools_get_style_base_types();
|
171 |
|
|
|
172 |
|
|
parent::init($plugin);
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
function get_wizard_info(&$form_state) {
|
176 |
|
|
$form_info = parent::get_wizard_info($form_state);
|
177 |
|
|
ctools_include('stylizer');
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
if (!empty($form_state['type'])) {
|
183 |
|
|
$form_state['form type'] = 'add';
|
184 |
|
|
$form_info['show back'] = TRUE;
|
185 |
|
|
}
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
$form_state['item']->settings['name'] = $form_state['item']->name;
|
189 |
|
|
$form_state['settings'] = $form_state['item']->settings;
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
$plugin = NULL;
|
193 |
|
|
if (!empty($form_state['item']->settings['style_base'])) {
|
194 |
|
|
$plugin = ctools_get_style_base($form_state['item']->settings['style_base']);
|
195 |
|
|
ctools_stylizer_add_plugin_forms($form_info, $plugin, $form_state['op']);
|
196 |
|
|
}
|
197 |
|
|
else {
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
$form_info['order']['next'] = t('Configure style');
|
202 |
|
|
|
203 |
|
|
}
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
if (!empty($form_state['item']->style_module)) {
|
207 |
|
|
$form_state['module'] = $form_state['item']->style_module;
|
208 |
|
|
$form_state['type'] = $form_state['item']->style_type;
|
209 |
|
|
}
|
210 |
|
|
|
211 |
|
|
$form_state['base_style_plugin'] = $plugin;
|
212 |
|
|
$form_state['settings'] = $form_state['item']->settings;
|
213 |
|
|
return $form_info;
|
214 |
|
|
}
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
|
|
function store_stylizer_info(&$form_state) {
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
if ($form_state['step'] != 'import') {
|
232 |
|
|
$form_state['item']->settings = $form_state['settings'];
|
233 |
|
|
}
|
234 |
|
|
|
235 |
|
|
$form_state['item']->settings['name'] = $form_state['item']->name;
|
236 |
|
|
}
|
237 |
|
|
|
238 |
|
|
function edit_wizard_next(&$form_state) {
|
239 |
|
|
$this->store_stylizer_info($form_state);
|
240 |
|
|
parent::edit_wizard_next($form_state);
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
function edit_wizard_finish(&$form_state) {
|
244 |
|
|
|
245 |
|
|
if (isset($form_state['settings']['old_settings'])) {
|
246 |
|
|
unset($form_state['settings']['old_settings']);
|
247 |
|
|
}
|
248 |
|
|
$this->store_stylizer_info($form_state);
|
249 |
|
|
parent::edit_wizard_finish($form_state);
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
function edit_form_type(&$form, &$form_state) {
|
253 |
|
|
foreach ($this->base_types as $module => $info) {
|
254 |
|
|
foreach ($info as $key => $base_type) {
|
255 |
|
|
$types[$module . '-' . $key] = $base_type['title'];
|
256 |
|
|
}
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
$form['type'] = array(
|
260 |
|
|
'#type' => 'select',
|
261 |
|
|
'#title' => t('Type'),
|
262 |
|
|
'#options' => $types,
|
263 |
|
|
'#default_value' => 'all',
|
264 |
|
|
'#weight' => -10,
|
265 |
|
|
'#attributes' => array('class' => array('ctools-auto-submit')),
|
266 |
|
|
);
|
267 |
|
|
}
|
268 |
|
|
|
269 |
|
|
function edit_form_type_submit(&$form, &$form_state) {
|
270 |
|
|
list($form_state['item']->style_module, $form_state['item']->style_type) = explode('-', $form_state['values']['type']);
|
271 |
|
|
}
|
272 |
|
|
} |