Tripal v1.0 (6.x-1.0)
|
00001 <?php 00002 00013 /************************************************************************* 00014 * Implements hook_views_data() 00015 * Purpose: Describe chado/tripal tables & fields to views 00016 * 00017 * @return: a data array which follows the structure outlined in the 00018 * views2 documentation for this hook. Essentially, it's an array of table 00019 * definitions keyed by chado/tripal table name. Each table definition 00020 * includes basic details about the table, fields in that table and 00021 * relationships between that table and others (joins) 00022 * 00023 * @ingroup tripal_contact 00024 */ 00025 function tripal_contact_views_data() { 00026 $data = array(); 00027 00028 if (module_exists('tripal_views')) { 00029 00030 // Base Table: contact 00031 $tablename = 'contact'; 00032 $priority = 9; 00033 00034 // check to see if the table is integrated. If it is then integrate it's 00035 // corresponding 'chado_[table]' table. 00036 if (!tripal_views_is_integrated($tablename, $priority)) { 00037 $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority); 00038 $status = tripal_views_integration_add_entry($table_integration_array); 00039 if (!$status) { 00040 drupal_set_message(t('Tripal Contact is unable to integrate %table', array('%table' => $tablename)), 'error'); 00041 } 00042 } 00043 00044 // Additional tables 00045 $tables = array( 00046 'contact_relationship', 00047 ); 00048 foreach ($tables as $tablename) { 00049 $priority = 9; 00050 if (!tripal_views_is_integrated($tablename, $priority)) { 00051 $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority); 00052 $status = tripal_views_integration_add_entry($table_integration_array); 00053 if (!$status) { 00054 drupal_set_message(t('Tripal Contact is unable to integrate %table', array('%table' => $tablename)), 'error'); 00055 } 00056 } 00057 } 00058 } 00059 00060 return $data; 00061 } 00062 00063 /************************************************************************* 00064 * Implements hook_views_handlers() 00065 * Purpose: Register all custom handlers with views 00066 * where a handler describes either "the type of field", 00067 * "how a field should be filtered", "how a field should be sorted" 00068 * 00069 * @return: An array of handler definitions 00070 * 00071 * @ingroup tripal_contact 00072 */ 00073 function tripal_contact_views_handlers() { 00074 return array( 00075 'info' => array( 00076 'path' => drupal_get_path('module', 'tripal_contact') . '/views/handlers', 00077 ), 00078 'handlers' => array( 00079 00080 ), 00081 ); 00082 } 00083 00088 function tripal_contact_views_default_views() { 00089 $views = array(); 00090 00091 if (!module_exists('tripal_views')) { 00092 return $views; 00093 } 00094 00095 // Main default view 00096 $view = new view; 00097 $view->name = 'contact_listing'; 00098 $view->description = 'A listing of chado contacts'; 00099 $view->tag = 'chado default'; 00100 $view->base_table = 'contact'; 00101 $view->core = 6; 00102 $view->api_version = '2'; 00103 $view->disabled = TRUE; /* Edit this to true to make a default view disabled initially */ 00104 $handler = $view->new_display('default', 'Defaults', 'default'); 00105 $handler->override_option('fields', array( 00106 'name' => array( 00107 'label' => 'Name', 00108 'alter' => array( 00109 'alter_text' => 0, 00110 'text' => '', 00111 'make_link' => 0, 00112 'path' => '', 00113 'absolute' => 0, 00114 'link_class' => '', 00115 'alt' => '', 00116 'rel' => '', 00117 'prefix' => '', 00118 'suffix' => '', 00119 'target' => '', 00120 'help' => '', 00121 'trim' => 0, 00122 'max_length' => '', 00123 'word_boundary' => 1, 00124 'ellipsis' => 1, 00125 'html' => 0, 00126 'strip_tags' => 0, 00127 ), 00128 'empty' => '', 00129 'hide_empty' => 0, 00130 'empty_zero' => 0, 00131 'hide_alter_empty' => 1, 00132 'type' => 'separator', 00133 'separator' => ', ', 00134 'exclude' => 0, 00135 'id' => 'name', 00136 'table' => 'contact', 00137 'field' => 'name', 00138 'relationship' => 'none', 00139 ), 00140 'name_1' => array( 00141 'label' => 'Type', 00142 'alter' => array( 00143 'alter_text' => 0, 00144 'text' => '', 00145 'make_link' => 0, 00146 'path' => '', 00147 'absolute' => 0, 00148 'link_class' => '', 00149 'alt' => '', 00150 'rel' => '', 00151 'prefix' => '', 00152 'suffix' => '', 00153 'target' => '', 00154 'help' => '', 00155 'trim' => 0, 00156 'max_length' => '', 00157 'word_boundary' => 1, 00158 'ellipsis' => 1, 00159 'html' => 0, 00160 'strip_tags' => 0, 00161 ), 00162 'empty' => '', 00163 'hide_empty' => 0, 00164 'empty_zero' => 0, 00165 'hide_alter_empty' => 1, 00166 'type' => 'separator', 00167 'separator' => ', ', 00168 'exclude' => 0, 00169 'id' => 'name_1', 00170 'table' => 'cvterm', 00171 'field' => 'name', 00172 'relationship' => 'none', 00173 ), 00174 'description' => array( 00175 'label' => 'Description', 00176 'alter' => array( 00177 'alter_text' => 0, 00178 'text' => '', 00179 'make_link' => 0, 00180 'path' => '', 00181 'absolute' => 0, 00182 'link_class' => '', 00183 'alt' => '', 00184 'rel' => '', 00185 'prefix' => '', 00186 'suffix' => '', 00187 'target' => '', 00188 'help' => '', 00189 'trim' => 0, 00190 'max_length' => '', 00191 'word_boundary' => 1, 00192 'ellipsis' => 1, 00193 'html' => 0, 00194 'strip_tags' => 0, 00195 ), 00196 'empty' => '', 00197 'hide_empty' => 0, 00198 'empty_zero' => 0, 00199 'hide_alter_empty' => 1, 00200 'type' => 'separator', 00201 'separator' => ', ', 00202 'exclude' => 0, 00203 'id' => 'description', 00204 'table' => 'contact', 00205 'field' => 'description', 00206 'relationship' => 'none', 00207 ), 00208 )); 00209 $handler->override_option('filters', array( 00210 'search_results' => array( 00211 'operator' => '=', 00212 'value' => '', 00213 'group' => '0', 00214 'exposed' => FALSE, 00215 'expose' => array( 00216 'operator' => FALSE, 00217 'label' => '', 00218 ), 00219 'id' => 'search_results', 00220 'table' => 'views', 00221 'field' => 'search_results', 00222 'relationship' => 'none', 00223 'apply_button' => 'Show', 00224 'no_results_text' => 'Click "Show" to see a list of all contacts matching the entered criteria. If you leave a any of the criteria blank then the contacts will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all contacts will be listed.', 00225 ), 00226 'type_id' => array( 00227 'operator' => '=', 00228 'value' => '', 00229 'group' => '0', 00230 'exposed' => TRUE, 00231 'expose' => array( 00232 'use_operator' => 0, 00233 'operator' => 'type_id_op', 00234 'identifier' => 'type_id', 00235 'label' => 'Type', 00236 'remember' => 0, 00237 ), 00238 'case' => 1, 00239 'id' => 'type_id', 00240 'table' => 'contact', 00241 'field' => 'type_id', 00242 'relationship' => 'none', 00243 'values_form_type' => 'select', 00244 'multiple' => 1, 00245 'optional' => 0, 00246 'show_all' => 0, 00247 'agg' => array( 00248 'records_with' => 1, 00249 'aggregates_with' => 1, 00250 ), 00251 ), 00252 'name' => array( 00253 'operator' => '~', 00254 'value' => '', 00255 'group' => '0', 00256 'exposed' => TRUE, 00257 'expose' => array( 00258 'use_operator' => 0, 00259 'operator' => 'name_op', 00260 'identifier' => 'name', 00261 'label' => 'Name Contains', 00262 'remember' => 0, 00263 ), 00264 'case' => 0, 00265 'id' => 'name', 00266 'table' => 'contact', 00267 'field' => 'name', 00268 'relationship' => 'none', 00269 'agg' => array( 00270 'records_with' => 1, 00271 'aggregates_with' => 1, 00272 ), 00273 ), 00274 'description' => array( 00275 'operator' => '~', 00276 'value' => '', 00277 'group' => '0', 00278 'exposed' => TRUE, 00279 'expose' => array( 00280 'use_operator' => 0, 00281 'operator' => 'description_op', 00282 'identifier' => 'description', 00283 'label' => 'Description Contains', 00284 'remember' => 0, 00285 ), 00286 'case' => 0, 00287 'id' => 'description', 00288 'table' => 'contact', 00289 'field' => 'description', 00290 'relationship' => 'none', 00291 'agg' => array( 00292 'records_with' => 1, 00293 'aggregates_with' => 1, 00294 ), 00295 ), 00296 )); 00297 $handler->override_option('access', array( 00298 'type' => 'perm', 00299 'perm' => 'access content', 00300 )); 00301 $handler->override_option('cache', array( 00302 'type' => 'none', 00303 )); 00304 $handler->override_option('title', 'Contacts'); 00305 $handler->override_option('header', 'Click "Show" to see a list of all contacts matching the entered criteria. If you leave a any of the criteria blank then the contacts will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all contacts will be listed.'); 00306 $handler->override_option('header_format', '2'); 00307 $handler->override_option('header_empty', 0); 00308 $handler->override_option('empty', 'No contacts match the current criteria.'); 00309 $handler->override_option('empty_format', '2'); 00310 $handler->override_option('items_per_page', 50); 00311 $handler->override_option('use_pager', '1'); 00312 $handler->override_option('style_plugin', 'table'); 00313 $handler->override_option('style_options', array( 00314 'grouping' => '', 00315 'override' => 1, 00316 'sticky' => 0, 00317 'order' => 'asc', 00318 'summary' => '', 00319 'columns' => array( 00320 'name' => 'name', 00321 'name_1' => 'name_1', 00322 'description' => 'description', 00323 ), 00324 'info' => array( 00325 'name' => array( 00326 'sortable' => 1, 00327 'separator' => '', 00328 ), 00329 'name_1' => array( 00330 'sortable' => 1, 00331 'separator' => '', 00332 ), 00333 'description' => array( 00334 'sortable' => 0, 00335 'separator' => '', 00336 ), 00337 ), 00338 'default' => 'name', 00339 )); 00340 $handler = $view->new_display('page', 'Page', 'page_1'); 00341 $handler->override_option('path', 'chado/contacts'); 00342 $handler->override_option('menu', array( 00343 'type' => 'normal', 00344 'title' => 'Contacts', 00345 'description' => 'Contacts can be persons, institutes, groups, or organizations.', 00346 'weight' => '10', 00347 'name' => 'navigation', 00348 )); 00349 $handler->override_option('tab_options', array( 00350 'type' => 'none', 00351 'title' => '', 00352 'description' => '', 00353 'weight' => 0, 00354 'name' => 'navigation', 00355 )); 00356 $views[$view->name] = $view; 00357 00358 return $views; 00359 }