Tripal v1.0 (6.x-1.0)
|
00001 <?php 00002 00029 function tripal_organism_views_data() { 00030 $data = array(); 00031 00032 if (module_exists('tripal_views')) { 00033 // Base Table 00034 $tables = array( 00035 'organism' 00036 ); 00037 foreach ($tables as $tablename) { 00038 $priority = 9; 00039 00040 // check to see if the table is integrated. If it is then integrate it's 00041 // corresponding 'chado_[table]' table. 00042 if (!tripal_views_is_integrated($tablename, $priority)) { 00043 $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority); 00044 00045 // Add specialty handlers 00046 $table_integration_array['fields']['common_name']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_string'; 00047 $table_integration_array['fields']['genus']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_string'; 00048 $table_integration_array['fields']['species']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_string'; 00049 $table_integration_array['fields']['abbreviation']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_string'; 00050 00051 // Add in node relationships if chado is in the same db as drupal 00052 if (tripal_core_chado_schema_exists()) { 00053 $integrations = tripal_views_add_node_relationship_to_chado_table_integration($table_integration_array); 00054 foreach ($integrations as $integration) { 00055 tripal_views_integration_add_entry($integration); 00056 } 00057 } 00058 else { 00059 tripal_views_integration_add_entry($table_integration_array); 00060 } 00061 } 00062 } 00063 00064 // Additional Tables 00065 $tables = array( 00066 'organismprop', 00067 'organism_dbxref' 00068 ); 00069 foreach ($tables as $tablename) { 00070 $priority = 9; 00071 if (!tripal_views_is_integrated($tablename, $priority)) { 00072 $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority); 00073 tripal_views_integration_add_entry($table_integration_array); 00074 } 00075 } 00076 } 00077 00078 return $data; 00079 } 00080 00090 function tripal_organism_views_handlers() { 00091 return array( 00092 'info' => array( 00093 'path' => drupal_get_path('module', 'tripal_organism') . '/views/handlers', 00094 ), 00095 'handlers' => array( 00096 'views_handler_field_computed_organism_nid' => array( 00097 'parent' => 'views_handler_field_numeric', 00098 ), 00099 'views_handler_filter_organism_common_name' => array( 00100 'parent' => 'views_handler_filter_string', 00101 ), 00102 ), 00103 ); 00104 } 00105 00109 function tripal_organism_views_data_alter(&$data) { 00110 00111 if ( !(is_array($db_url) and array_key_exists('chado', $db_url)) ) { 00112 00113 // Add featuer relationship to node 00114 $data['node']['organism_chado_nid'] = array( 00115 'group' => 'Organism', 00116 'title' => 'Organism Node', 00117 'help' => 'Links Chado Organism Fields/Data to the Nodes in the current View.', 00118 'real field' => 'nid', 00119 'relationship' => array( 00120 'handler' => 'views_handler_relationship', 00121 'title' => t('Node => Chado'), 00122 'label' => t('Node => Chado'), 00123 'real field' => 'nid', 00124 'base' => 'chado_organism', 00125 'base field' => 'nid' 00126 ), 00127 ); 00128 } 00129 00130 } 00131 00136 function tripal_organism_views_default_views() { 00137 $views = array(); 00138 00139 if (!module_exists('tripal_views')) { 00140 return $views; 00141 } 00142 00143 // Main default view 00144 $view = new view; 00145 $view->name = 'organism_listing'; 00146 $view->description = 'A listing of all organism in chado'; 00147 $view->tag = 'chado default'; 00148 $view->base_table = 'organism'; 00149 $view->core = 0; 00150 $view->api_version = '2'; 00151 $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ 00152 $handler = $view->new_display('default', 'Defaults', 'default'); 00153 $handler->override_option('fields', array( 00154 'common_name' => array( 00155 'label' => 'Common Name', 00156 'alter' => array( 00157 'alter_text' => 0, 00158 'text' => '', 00159 'make_link' => 0, 00160 'path' => '', 00161 'link_class' => '', 00162 'alt' => '', 00163 'prefix' => '', 00164 'suffix' => '', 00165 'target' => '', 00166 'help' => '', 00167 'trim' => 0, 00168 'max_length' => '', 00169 'word_boundary' => 1, 00170 'ellipsis' => 1, 00171 'html' => 0, 00172 'strip_tags' => 0, 00173 ), 00174 'empty' => '', 00175 'hide_empty' => 0, 00176 'empty_zero' => 0, 00177 'link_to_node' => 1, 00178 'exclude' => 0, 00179 'id' => 'common_name', 00180 'table' => 'organism', 00181 'field' => 'common_name', 00182 'relationship' => 'none', 00183 ), 00184 'genus' => array( 00185 'label' => 'Genus', 00186 'alter' => array( 00187 'alter_text' => 0, 00188 'text' => '', 00189 'make_link' => 0, 00190 'path' => '', 00191 'link_class' => '', 00192 'alt' => '', 00193 'prefix' => '', 00194 'suffix' => '', 00195 'target' => '', 00196 'help' => '', 00197 'trim' => 0, 00198 'max_length' => '', 00199 'word_boundary' => 1, 00200 'ellipsis' => 1, 00201 'html' => 0, 00202 'strip_tags' => 0, 00203 ), 00204 'empty' => '', 00205 'hide_empty' => 0, 00206 'empty_zero' => 0, 00207 'exclude' => 0, 00208 'id' => 'genus', 00209 'table' => 'organism', 00210 'field' => 'genus', 00211 'relationship' => 'none', 00212 ), 00213 'species' => array( 00214 'label' => 'Species', 00215 'alter' => array( 00216 'alter_text' => 0, 00217 'text' => '', 00218 'make_link' => 0, 00219 'path' => '', 00220 'link_class' => '', 00221 'alt' => '', 00222 'prefix' => '', 00223 'suffix' => '', 00224 'target' => '', 00225 'help' => '', 00226 'trim' => 0, 00227 'max_length' => '', 00228 'word_boundary' => 1, 00229 'ellipsis' => 1, 00230 'html' => 0, 00231 'strip_tags' => 0, 00232 ), 00233 'empty' => '', 00234 'hide_empty' => 0, 00235 'empty_zero' => 0, 00236 'exclude' => 0, 00237 'id' => 'species', 00238 'table' => 'organism', 00239 'field' => 'species', 00240 'relationship' => 'none', 00241 ), 00242 'abbreviation' => array( 00243 'label' => 'Abbreviation', 00244 'alter' => array( 00245 'alter_text' => 0, 00246 'text' => '', 00247 'make_link' => 0, 00248 'path' => '', 00249 'link_class' => '', 00250 'alt' => '', 00251 'prefix' => '', 00252 'suffix' => '', 00253 'target' => '', 00254 'help' => '', 00255 'trim' => 0, 00256 'max_length' => '', 00257 'word_boundary' => 1, 00258 'ellipsis' => 1, 00259 'html' => 0, 00260 'strip_tags' => 0, 00261 ), 00262 'empty' => '', 00263 'hide_empty' => 0, 00264 'empty_zero' => 0, 00265 'link_to_node' => 0, 00266 'exclude' => 0, 00267 'id' => 'abbreviation', 00268 'table' => 'organism', 00269 'field' => 'abbreviation', 00270 'relationship' => 'none', 00271 ), 00272 )); 00273 $handler->override_option('sorts', array( 00274 'genus' => array( 00275 'order' => 'ASC', 00276 'id' => 'genus', 00277 'table' => 'organism', 00278 'field' => 'genus', 00279 'relationship' => 'none', 00280 ), 00281 'species' => array( 00282 'order' => 'ASC', 00283 'id' => 'species', 00284 'table' => 'organism', 00285 'field' => 'species', 00286 'relationship' => 'none', 00287 ), 00288 )); 00289 $handler->override_option('access', array( 00290 'type' => 'perm', 00291 'perm' => 'access chado_organism content', 00292 )); 00293 $handler->override_option('cache', array( 00294 'type' => 'none', 00295 )); 00296 $handler->override_option('title', 'Organisms'); 00297 $handler->override_option('empty', 'No organisms matched the supplied criteria.'); 00298 $handler->override_option('empty_format', '1'); 00299 $handler->override_option('items_per_page', 0); 00300 $handler->override_option('style_plugin', 'table'); 00301 $handler->override_option('style_options', array( 00302 'grouping' => '', 00303 'override' => 1, 00304 'sticky' => 0, 00305 'order' => 'asc', 00306 'summary' => '', 00307 'columns' => array( 00308 'common_name' => 'common_name', 00309 'genus' => 'genus', 00310 'species' => 'species', 00311 'abbreviation' => 'abbreviation', 00312 ), 00313 'info' => array( 00314 'common_name' => array( 00315 'sortable' => 1, 00316 'separator' => '', 00317 ), 00318 'genus' => array( 00319 'sortable' => 1, 00320 'separator' => '', 00321 ), 00322 'species' => array( 00323 'sortable' => 1, 00324 'separator' => '', 00325 ), 00326 'abbreviation' => array( 00327 'sortable' => 1, 00328 'separator' => '', 00329 ), 00330 ), 00331 'default' => '-1', 00332 )); 00333 $default_handler = $handler; 00334 $handler = $view->new_display('page', 'Page', 'page_1'); 00335 $handler->override_option('path', 'chado/organisms'); 00336 $handler->override_option('menu', array( 00337 'type' => 'normal', 00338 'title' => 'Organisms', 00339 'description' => 'A biological organism.', 00340 'weight' => '10', 00341 'name' => 'navigation', 00342 )); 00343 $handler->override_option('tab_options', array( 00344 'type' => 'none', 00345 'title' => '', 00346 'description' => '', 00347 'weight' => 0, 00348 'name' => 'navigation', 00349 )); 00350 // Add code specific to a local chado installation 00351 // NOTE: Edit $handler above to $default_handler for the default display 00352 if (tripal_core_chado_schema_exists()) { 00353 // Add nid field 00354 $fields = $view->get_items('field', 'default'); 00355 $new_fields = array( 00356 'nid' => array( 00357 'label' => 'Nid', 00358 'alter' => array( 00359 'alter_text' => 0, 00360 'text' => '', 00361 'make_link' => 0, 00362 'path' => '', 00363 'absolute' => 0, 00364 'link_class' => '', 00365 'alt' => '', 00366 'rel' => '', 00367 'prefix' => '', 00368 'suffix' => '', 00369 'target' => '', 00370 'help' => '', 00371 'trim' => 0, 00372 'max_length' => '', 00373 'word_boundary' => 1, 00374 'ellipsis' => 1, 00375 'html' => 0, 00376 'strip_tags' => 0, 00377 ), 00378 'empty' => '', 00379 'hide_empty' => 0, 00380 'empty_zero' => 0, 00381 'hide_alter_empty' => 1, 00382 'link_to_node' => 0, 00383 'exclude' => 1, 00384 'id' => 'nid', 00385 'table' => 'node', 00386 'field' => 'nid', 00387 'relationship' => 'none', 00388 ) 00389 ); 00390 $fields = $new_fields + $fields; 00391 // Adds organism => Node relationship 00392 $default_handler->override_option('relationships', array( 00393 'nid' => array( 00394 'label' => 'Organism to Node', 00395 'required' => 0, 00396 'id' => 'nid', 00397 'table' => 'chado_organism', 00398 'field' => 'nid', 00399 'relationship' => 'none', 00400 ), 00401 )); 00402 // Change analysis.name to have a link to the node 00403 $fields['common_name']['alter']['link_to_node'] = 1; 00404 $default_handler->override_option('fields', $fields); 00405 // Only show records with published nodes 00424 } 00425 $views[$view->name] = $view; 00426 00427 return $views; 00428 }