| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @file 4 * Views default views implementation. 5 */ 6 7 /** 8 * Implementation of hook_views_default_views(). 9 */ 10 function data_ui_views_default_views() { 11 $views = array(); 12 $tables = data_get_all_tables(); 13 14 foreach ($tables as $table) { 15 // Create new view for each table. 16 $view = new view; 17 $view->name = $table->get('name'); 18 $view->description = t('Default view for data table !title', array('!title' => $table->get('title'))); 19 $view->tag = 'data table'; 20 21 // Try to link a table to an existing table. If there are no linked tables, 22 // check whether this table is a base table. If not, continue. 23 // @todo: allow relationships to tables, 2 or more joins away. 24 $schema = $table->get('table_schema'); 25 $meta = $table->get('meta'); 26 if (isset($meta['join']) && is_array($meta['join'])) { 27 $left_table = key($meta['join']); 28 $left_table_schema = drupal_get_schema($left_table); 29 30 if (isset($left_table_schema['primary key']) && count($left_table_schema['primary key'])) { 31 $view->base_table = $left_table; 32 } 33 } 34 elseif (isset($schema['primary key']) && count($schema['primary key'])) { 35 $view->base_table = $table->get('name'); 36 } 37 else { 38 continue; 39 } 40 41 // @todo: maybe yes? 42 $view->is_cacheable = FALSE; 43 $view->api_version = 2; 44 $view->disabled = FALSE; 45 $handler = $view->new_display('default', 'Default', 'default'); 46 47 // Add our columns to the view's fields. 48 $fields = array(); 49 $meta_fields = $meta['fields']; 50 foreach ($schema['fields'] as $field_name => $field) { 51 $fields[$field_name] = array( 52 'label' => $meta_fields[$field_name]['label'] ? $meta_fields[$field_name]['label'] : $field_name, 53 'id' => $field_name, 54 'table' => $table->get('name'), 55 'field' => $field_name, 56 'exclude' => 0, 57 'relationship' => 'none', 58 ); 59 } 60 $handler->override_option('fields', $fields); 61 62 // Add a default argument for the first column. 63 $first = key($schema['fields']); 64 $handler->override_option('arguments', array( 65 $first => array( 66 'default_action' => 'ignore', 67 'style_plugin' => 'default_summary', 68 'style_options' => array(), 69 'wildcard' => 'all', 70 'wildcard_substitution' => 'All', 71 'title' => $table->get('title') .' %1', 72 'id' => $first, 73 'table' => $table->get('name'), 74 'field' => $first, 75 ), 76 )); 77 78 $handler->override_option('access', array( 79 'type' => 'none', 80 )); 81 $handler->override_option('title', $table->get('title')); 82 $handler->override_option('empty', 'There is no data in this table.'); 83 $handler->override_option('empty_format', '1'); 84 $handler->override_option('items_per_page', 50); 85 $handler->override_option('use_pager', '1'); 86 $handler->override_option('style_plugin', 'table'); 87 88 // Add $fields into the style options. 89 $field_names = array(); 90 $info = array(); 91 foreach ($schema['fields'] as $field_name => $field) { 92 $field_names[$field_name] = $field_name; 93 $info[$field_name] = array( 94 'sortable' => 1, 95 'separator' => '', 96 ); 97 } 98 $handler->override_option('style_options', array( 99 'grouping' => '', 100 'override' => 1, 101 'sticky' => 1, 102 'order' => 'asc', 103 'columns' => $field_names, 104 'info' => $info, 105 'default' => -1, 106 )); 107 108 // Add a page. 109 $handler = $view->new_display('page', 'Page', 'page_1'); 110 $handler->override_option('path', data_ui_get_default_path($table->get('name'))); 111 $handler->override_option('menu', array( 112 'type' => 'normal', 113 'title' => $table->get('title'), 114 'description' => '', 115 'weight' => '0', 116 'name' => 'navigation', 117 )); 118 $handler->override_option('tab_options', array( 119 'type' => 'none', 120 'title' => '', 121 'description' => '', 122 'weight' => 0, 123 )); 124 $views[$view->name] = $view; 125 } 126 127 return $views; 128 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |