Revert "Re-applying patch from http://drupal.org/files/views_integration-588728-11...
[sandbox/ergonlogic/1226310.git] / modules / hosting / site / hosting_site.views.inc
1 <?php
2 /**
3 * @file Hosting site views integration.
4 */
5
6
7
8 /**
9 * Implements hook_views_data().
10 */
11 function hosting_site_views_data() {
12 $data['hosting_site']['table'] = array(
13 'group' => 'Hosting Site',
14 'title' => 'Site',
15 'join' => array(
16 'node' => array(
17 'left_field' => 'vid',
18 'field' => 'vid',
19 ),
20 ),
21 );
22
23 $data['hosting_site']['client'] = array(
24 'title' => t('Client'),
25 'help' => t('Relate a node revision to the user who created the revision.'),
26 'relationship' => array(
27 'handler' => 'views_handler_relationship',
28 'base' => 'node',
29 'field' => 'nid',
30 'label' => t('client'),
31 ),
32 );
33
34 $data['hosting_site']['db_server'] = array(
35 'title' => t('Database Server'),
36 'help' => t('Database where the site is installed.'),
37 'relationship' => array(
38 'handler' => 'views_handler_relationship',
39 'base' => 'node',
40 'field' => 'nid',
41 'label' => t('db server'),
42 ),
43 );
44
45 $data['hosting_site']['profile'] = array(
46 'title' => t('Install Profile'),
47 'help' => t('Type of drupal site.'),
48 'relationship' => array(
49 'handler' => 'views_handler_relationship',
50 'base' => 'node',
51 'field' => 'nid',
52 'label' => t('profile'),
53 ),
54 );
55 $data['hosting_site']['platform'] = array(
56 'title' => t('Platform'),
57 'help' => t('Platform'),
58 'relationship' => array(
59 'handler' => 'views_handler_relationship',
60 'base' => 'node',
61 'field' => 'nid',
62 'label' => t('platform'),
63 ),
64 );
65
66 $data['hosting_site']['verified'] = array(
67 'title' => t('Verified'),
68 'help' => t('The last date verified task run on this site.'),
69 'field' => array(
70 'handler' => 'hosting_views_field_handler_interval',
71 'click sortable' => TRUE,
72 ),
73 );
74
75 $data['hosting_site']['last_cron'] = array(
76 'title' => t('Last Cron Run'),
77 'help' => t('The time the last cron run was executed on this site.'),
78 'field' => array(
79 'handler' => 'hosting_views_field_handler_interval',
80 'click sortable' => TRUE,
81 ),
82 );
83 $data['hosting_site']['language'] = array(
84 'title' => t('Language'),
85 'help' => t('The default language of this site.'),
86 'field' => array(
87 'handler' => 'views_handler_field_hosting_language',
88 'click sortable' => TRUE,
89 ),
90 );
91
92 $data['hosting_site']['status'] = array(
93 'title' => t('Status'),
94 'help' => t('The current state of this site.'),
95 'field' => array(
96 'handler' => 'views_handler_field_hosting_site_status',
97 ),
98 'filter' => array(
99 'handler' => 'views_handler_filter_numeric',
100 ),
101 );
102
103 return $data;
104 }
105
106 function hosting_site_views_handlers() {
107 return array(
108 'info' => array(
109 'path' => drupal_get_path('module', 'hosting_site'),
110 ),
111 'handlers' => array(
112 // field handlers
113 'views_handler_field_hosting_language' => array(
114 'parent' => 'views_handler_field',
115 ),
116 // field handlers
117 'views_handler_field_hosting_site_status' => array(
118 'parent' => 'views_handler_field',
119 ),
120
121 ),
122 );
123 }
124
125 function hosting_site_views_plugins() {
126 return array(
127 'style' => array(
128 'hosting_site_list' => array(
129 'title' => t('Site listing'),
130 'help' => t('Displays sites in a table.'),
131 'handler' => 'views_plugin_style_site_table',
132 'theme' => 'views_view_table',
133 'parent' => 'table',
134 'path' => drupal_get_path('module', 'hosting_site'),
135 'uses row plugin' => FALSE,
136 'uses fields' => TRUE,
137 'uses options' => TRUE,
138 'type' => 'normal',
139 ),
140 )
141 );
142
143 }
144
145
146 function hosting_site_views_default_views() {
147 $view = new view;
148 $view->name = 'hosting_site_list';
149 $view->description = 'Display a list of sites hosted in aegir';
150 $view->tag = '';
151 $view->view_php = '';
152 $view->base_table = 'node';
153 $view->is_cacheable = FALSE;
154 $view->api_version = 2;
155 $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
156 $handler = $view->new_display('default', 'Defaults', 'default');
157 $handler->override_option('relationships', array(
158 'client' => array(
159 'id' => 'client',
160 'table' => 'hosting_site',
161 'field' => 'client',
162 ),
163 'db_server' => array(
164 'id' => 'db_server',
165 'table' => 'hosting_site',
166 'field' => 'db_server',
167 ),
168 'profile' => array(
169 'id' => 'profile',
170 'table' => 'hosting_site',
171 'field' => 'profile',
172 ),
173 'platform' => array(
174 'id' => 'platform',
175 'table' => 'hosting_site',
176 'field' => 'platform',
177 ),
178 'web_server' => array(
179 'label' => 'web server',
180 'required' => 0,
181 'id' => 'web_server',
182 'table' => 'hosting_platform',
183 'field' => 'web_server',
184 'relationship' => 'platform',
185 ),
186 ));
187 $handler->override_option('fields', array(
188 'status' => array(
189 'label' => '',
190 'alter' => array(
191 'alter_text' => 0,
192 'text' => '',
193 'make_link' => 0,
194 'path' => '',
195 'link_class' => '',
196 'alt' => '',
197 'prefix' => '',
198 'suffix' => '',
199 'help' => '',
200 'trim' => 0,
201 'max_length' => '',
202 'word_boundary' => 1,
203 'ellipsis' => 1,
204 'strip_tags' => 0,
205 'html' => 0,
206 ),
207 'status_icon' => '1',
208 'exclude' => 0,
209 'id' => 'status',
210 'table' => 'hosting_site',
211 'field' => 'status',
212 'relationship' => 'none',
213 'override' => array(
214 'button' => 'Override',
215 ),
216 ),
217 'title' => array(
218 'label' => 'Domain',
219 'alter' => array(
220 'alter_text' => 0,
221 'text' => '',
222 'make_link' => 0,
223 'path' => '',
224 'link_class' => '',
225 'alt' => '',
226 'prefix' => '',
227 'suffix' => '',
228 'help' => '',
229 'trim' => 0,
230 'max_length' => '',
231 'word_boundary' => 1,
232 'ellipsis' => 1,
233 'strip_tags' => 0,
234 'html' => 0,
235 ),
236 'link_to_node' => 1,
237 'exclude' => 0,
238 'id' => 'title',
239 'table' => 'node',
240 'field' => 'title',
241 'relationship' => 'none',
242 ),
243 'title_3' => array(
244 'label' => 'Install Profile',
245 'alter' => array(
246 'alter_text' => 0,
247 'text' => '',
248 'make_link' => 0,
249 'path' => '',
250 'link_class' => '',
251 'alt' => '',
252 'prefix' => '',
253 'suffix' => '',
254 'help' => '',
255 'trim' => 0,
256 'max_length' => '',
257 'word_boundary' => 1,
258 'ellipsis' => 1,
259 'strip_tags' => 0,
260 'html' => 0,
261 ),
262 'link_to_node' => 1,
263 'exclude' => 0,
264 'id' => 'title_3',
265 'table' => 'node',
266 'field' => 'title',
267 'relationship' => 'profile',
268 ),
269 'language' => array(
270 'label' => 'Language',
271 'alter' => array(
272 'alter_text' => 0,
273 'text' => '',
274 'make_link' => 0,
275 'path' => '',
276 'link_class' => '',
277 'alt' => '',
278 'prefix' => '',
279 'suffix' => '',
280 'help' => '',
281 'trim' => 0,
282 'max_length' => '',
283 'word_boundary' => 1,
284 'ellipsis' => 1,
285 'strip_tags' => 0,
286 'html' => 0,
287 ),
288 'exclude' => 0,
289 'id' => 'language',
290 'table' => 'hosting_site',
291 'field' => 'language',
292 'relationship' => 'none',
293 ),
294 'title_1' => array(
295 'label' => 'Client',
296 'alter' => array(
297 'alter_text' => 0,
298 'text' => '',
299 'make_link' => 0,
300 'path' => '',
301 'link_class' => '',
302 'alt' => '',
303 'prefix' => '',
304 'suffix' => '',
305 'help' => '',
306 'trim' => 1,
307 'max_length' => '10',
308 'word_boundary' => 1,
309 'ellipsis' => 1,
310 'strip_tags' => 0,
311 'html' => 0,
312 ),
313 'link_to_node' => 1,
314 'exclude' => 0,
315 'id' => 'title_1',
316 'table' => 'node',
317 'field' => 'title',
318 'relationship' => 'client',
319 'override' => array(
320 'button' => 'Override',
321 ),
322 ),
323 'verified' => array(
324 'label' => 'Verified',
325 'alter' => array(
326 'alter_text' => 0,
327 'text' => '',
328 'make_link' => 0,
329 'path' => '',
330 'link_class' => '',
331 'alt' => '',
332 'prefix' => '',
333 'suffix' => '',
334 'help' => '',
335 'trim' => 0,
336 'max_length' => '',
337 'word_boundary' => 1,
338 'ellipsis' => 1,
339 'strip_tags' => 0,
340 'html' => 0,
341 ),
342 'date_format' => 'small',
343 'custom_date_format' => '',
344 'exclude' => 0,
345 'id' => 'verified',
346 'table' => 'hosting_site',
347 'field' => 'verified',
348 'relationship' => 'none',
349 ),
350 'title_2' => array(
351 'label' => 'Platform',
352 'alter' => array(
353 'alter_text' => 0,
354 'text' => '',
355 'make_link' => 0,
356 'path' => '',
357 'link_class' => '',
358 'alt' => '',
359 'prefix' => '',
360 'suffix' => '',
361 'help' => '',
362 'trim' => 1,
363 'max_length' => '20',
364 'word_boundary' => 1,
365 'ellipsis' => 1,
366 'strip_tags' => 0,
367 'html' => 0,
368 ),
369 'link_to_node' => 1,
370 'exclude' => 0,
371 'id' => 'title_2',
372 'table' => 'node',
373 'field' => 'title',
374 'relationship' => 'platform',
375 'override' => array(
376 'button' => 'Override',
377 ),
378 ),
379 'title_5' => array(
380 'label' => 'Web Server',
381 'alter' => array(
382 'alter_text' => 0,
383 'text' => '',
384 'make_link' => 0,
385 'path' => '',
386 'link_class' => '',
387 'alt' => '',
388 'prefix' => '',
389 'suffix' => '',
390 'help' => '',
391 'trim' => 0,
392 'max_length' => '',
393 'word_boundary' => 1,
394 'ellipsis' => 1,
395 'strip_tags' => 0,
396 'html' => 0,
397 ),
398 'link_to_node' => 1,
399 'exclude' => 0,
400 'id' => 'title_5',
401 'table' => 'node',
402 'field' => 'title',
403 'relationship' => 'web_server',
404 'override' => array(
405 'button' => 'Override',
406 ),
407 ),
408 'title_4' => array(
409 'label' => 'Database Server',
410 'alter' => array(
411 'alter_text' => 0,
412 'text' => '',
413 'make_link' => 0,
414 'path' => '',
415 'link_class' => '',
416 'alt' => '',
417 'prefix' => '',
418 'suffix' => '',
419 'help' => '',
420 'trim' => 0,
421 'max_length' => '',
422 'word_boundary' => 1,
423 'ellipsis' => 1,
424 'strip_tags' => 0,
425 'html' => 0,
426 ),
427 'link_to_node' => 1,
428 'exclude' => 0,
429 'id' => 'title_4',
430 'table' => 'node',
431 'field' => 'title',
432 'relationship' => 'db_server',
433 'override' => array(
434 'button' => 'Override',
435 ),
436 ),
437 ));
438 $handler->override_option('sorts', array(
439 'title' => array(
440 'order' => 'ASC',
441 'id' => 'title',
442 'table' => 'node',
443 'field' => 'title',
444 'relationship' => 'none',
445 ),
446 ));
447 $handler->override_option('filters', array(
448 'type' => array(
449 'operator' => 'in',
450 'value' => array(
451 'site' => 'site',
452 ),
453 'group' => '0',
454 'exposed' => FALSE,
455 'expose' => array(
456 'operator' => FALSE,
457 'label' => '',
458 ),
459 'id' => 'type',
460 'table' => 'node',
461 'field' => 'type',
462 'relationship' => 'none',
463 ),
464 'status' => array(
465 'operator' => '!=',
466 'value' => array(
467 'value' => '-2',
468 'min' => '',
469 'max' => '',
470 ),
471 'group' => '0',
472 'exposed' => FALSE,
473 'expose' => array(
474 'operator' => FALSE,
475 'label' => '',
476 ),
477 'id' => 'status',
478 'table' => 'hosting_site',
479 'field' => 'status',
480 'relationship' => 'none',
481 ),
482 ));
483 $handler->override_option('access', array(
484 'type' => 'none',
485 ));
486 $handler->override_option('cache', array(
487 'type' => 'none',
488 ));
489 $handler->override_option('items_per_page', 30);
490 $handler->override_option('use_pager', 'mini');
491 $handler->override_option('style_plugin', 'hosting_site_list');
492 $handler->override_option('style_options', array(
493 'grouping' => '',
494 'override' => 1,
495 'sticky' => 0,
496 'order' => 'asc',
497 'columns' => array(
498 'title' => 'title',
499 'status' => 'status',
500 ),
501 'info' => array(
502 'title' => array(
503 'sortable' => 0,
504 'separator' => '',
505 ),
506 'status' => array(
507 'separator' => '',
508 ),
509 ),
510 'default' => '-1',
511 ));
512
513 $views[$view->name] = $view;
514
515 return $views;
516 }
517
518