Tripal v1.0 (6.x-1.0)
|
00001 <?php 00002 00031 function tripal_analysis_views_data() { 00032 $data = array(); 00033 00034 if (module_exists('tripal_views')) { 00035 // Base Table: Analysis 00036 $tablename = 'analysis'; 00037 // get the setup with the lightest priority. That's the table 00038 // that currently integrated with views. 00039 $priority = 9; 00040 00041 // check to see if the table is integrated. If it is then integrate it's 00042 // corresponding 'chado_[table]' table. 00043 if (!tripal_views_is_integrated($tablename, $priority)) { 00044 $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority); 00045 00046 // Make table-specific modifications 00047 $table_integration_array['fields']['program']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_string'; 00048 $table_integration_array['fields']['algorithm']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_string'; 00049 00050 // Add in node relationships if chado is in the same db as drupal 00051 if (tripal_core_chado_schema_exists()) { 00052 $integrations = tripal_views_add_node_relationship_to_chado_table_integration($table_integration_array); 00053 foreach ($integrations as $integration) { 00054 tripal_views_integration_add_entry($integration); 00055 } 00056 } 00057 else { 00058 tripal_views_integration_add_entry($table_integration_array); 00059 } 00060 } 00061 00062 00063 $tables = array( 00064 'analysisfeature', 00065 'analysisprop' 00066 ); 00067 foreach ($tables as $tablename) { 00068 $priority = 9; 00069 if (!tripal_views_is_integrated($tablename, $priority)) { 00070 $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority); 00071 tripal_views_integration_add_entry($table_integration_array); 00072 } 00073 } 00074 00075 } 00076 00077 return $data; 00078 } 00079 00092 function tripal_analysis_views_views_handlers() { 00093 return array( 00094 'info' => array( 00095 'path' => drupal_get_path('module', 'tripal_analysis') . '/views/handlers', 00096 ), 00097 'handlers' => array( 00098 'views_handler_field_computed_analysis_nid' => array( 00099 'parent' => 'views_handler_field_numeric', 00100 ), 00101 'views_handler_field_readable_date' => array( 00102 'parent' => 'views_handler_field', 00103 ), 00104 ), 00105 ); 00106 } 00107 00111 function tripal_analysis_views_data_alter(&$data) { 00112 00113 if (!(is_array($db_url) and array_key_exists('chado', $db_url)) ) { 00114 00115 // Add featuer relationship to node 00116 $data['node']['analysis_chado_nid'] = array( 00117 'group' => 'Analysis', 00118 'title' => 'Analysis Node', 00119 'help' => 'Links Chado analysis Fields/Data to the Nodes in the current View.', 00120 'real field' => 'nid', 00121 'relationship' => array( 00122 'handler' => 'views_handler_relationship', 00123 'title' => t('Node => Chado'), 00124 'label' => t('Node => Chado'), 00125 'real field' => 'nid', 00126 'base' => 'chado_analysis', 00127 'base field' => 'nid' 00128 ), 00129 ); 00130 } 00131 00132 } 00133 00139 function tripal_analysis_views_default_views() { 00140 $views = array(); 00141 00142 if (!module_exists('tripal_views')) { 00143 return $views; 00144 } 00145 00146 // Main default view 00147 $view = new view; 00148 $view->name = 'analysis_listing'; 00149 $view->description = 'A default listing of analyses provided by Tripal'; 00150 $view->tag = 'chado default'; 00151 $view->base_table = 'analysis'; 00152 $view->core = 0; 00153 $view->api_version = '2'; 00154 $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ 00155 $handler = $view->new_display('default', 'Defaults', 'default'); 00156 $handler->override_option('fields', array( 00157 'name' => array( 00158 'label' => 'Name', 00159 'alter' => array( 00160 'alter_text' => 0, 00161 'text' => '', 00162 'make_link' => 0, 00163 'path' => '', 00164 'absolute' => 0, 00165 'link_class' => '', 00166 'alt' => '', 00167 'rel' => '', 00168 'prefix' => '', 00169 'suffix' => '', 00170 'target' => '', 00171 'help' => '', 00172 'trim' => 0, 00173 'max_length' => '', 00174 'word_boundary' => 1, 00175 'ellipsis' => 1, 00176 'html' => 0, 00177 'strip_tags' => 0, 00178 ), 00179 'empty' => '', 00180 'hide_empty' => 0, 00181 'empty_zero' => 0, 00182 'hide_alter_empty' => 1, 00183 'type' => 'separator', 00184 'separator' => ', ', 00185 'exclude' => 0, 00186 'link_to_node' => 1, 00187 'id' => 'name', 00188 'table' => 'analysis', 00189 'field' => 'name', 00190 'relationship' => 'none', 00191 ), 00192 'program' => array( 00193 'label' => 'Program', 00194 'alter' => array( 00195 'alter_text' => 0, 00196 'text' => '', 00197 'make_link' => 0, 00198 'path' => '', 00199 'absolute' => 0, 00200 'link_class' => '', 00201 'alt' => '', 00202 'rel' => '', 00203 'prefix' => '', 00204 'suffix' => '', 00205 'target' => '', 00206 'help' => '', 00207 'trim' => 0, 00208 'max_length' => '', 00209 'word_boundary' => 1, 00210 'ellipsis' => 1, 00211 'html' => 0, 00212 'strip_tags' => 0, 00213 ), 00214 'empty' => '', 00215 'hide_empty' => 0, 00216 'empty_zero' => 0, 00217 'hide_alter_empty' => 1, 00218 'exclude' => 0, 00219 'id' => 'program', 00220 'table' => 'analysis', 00221 'field' => 'program', 00222 'relationship' => 'none', 00223 ), 00224 'sourcename' => array( 00225 'label' => 'Source', 00226 'alter' => array( 00227 'alter_text' => 0, 00228 'text' => '', 00229 'make_link' => 0, 00230 'path' => '', 00231 'absolute' => 0, 00232 'link_class' => '', 00233 'alt' => '', 00234 'rel' => '', 00235 'prefix' => '', 00236 'suffix' => '', 00237 'target' => '', 00238 'help' => '', 00239 'trim' => 0, 00240 'max_length' => '', 00241 'word_boundary' => 1, 00242 'ellipsis' => 1, 00243 'html' => 0, 00244 'strip_tags' => 0, 00245 ), 00246 'empty' => '', 00247 'hide_empty' => 0, 00248 'empty_zero' => 0, 00249 'hide_alter_empty' => 1, 00250 'exclude' => 0, 00251 'id' => 'sourcename', 00252 'table' => 'analysis', 00253 'field' => 'sourcename', 00254 'relationship' => 'none', 00255 ), 00256 'timeexecuted' => array( 00257 'label' => 'Time Executed', 00258 'alter' => array( 00259 'alter_text' => 0, 00260 'text' => '', 00261 'make_link' => 0, 00262 'path' => '', 00263 'absolute' => 0, 00264 'link_class' => '', 00265 'alt' => '', 00266 'rel' => '', 00267 'prefix' => '', 00268 'suffix' => '', 00269 'target' => '', 00270 'help' => '', 00271 'trim' => 0, 00272 'max_length' => '', 00273 'word_boundary' => 1, 00274 'ellipsis' => 1, 00275 'html' => 0, 00276 'strip_tags' => 0, 00277 ), 00278 'empty' => '', 00279 'hide_empty' => 0, 00280 'empty_zero' => 0, 00281 'hide_alter_empty' => 1, 00282 'date_format' => 'custom', 00283 'custom_date_format' => 'F j, Y', 00284 'exclude' => 0, 00285 'id' => 'timeexecuted', 00286 'table' => 'analysis', 00287 'field' => 'timeexecuted', 00288 'override' => array( 00289 'button' => 'Override', 00290 ), 00291 'relationship' => 'none', 00292 ), 00293 )); 00294 $handler->override_option('filters', array( 00295 'search_results' => array( 00296 'operator' => '=', 00297 'value' => '', 00298 'group' => '0', 00299 'exposed' => FALSE, 00300 'expose' => array( 00301 'operator' => FALSE, 00302 'label' => '', 00303 ), 00304 'id' => 'search_results', 00305 'table' => 'views', 00306 'field' => 'search_results', 00307 'relationship' => 'none', 00308 'apply_button' => 'Show ', 00309 'no_results_text' => 'Click "Show" to see a list of all analysis matching the entered criteria. If you leave a any of the criteria blank then the analysis will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all analysis will be listed.', 00310 ), 00311 'program' => array( 00312 'operator' => '=', 00313 'value' => '', 00314 'group' => '0', 00315 'exposed' => TRUE, 00316 'expose' => array( 00317 'use_operator' => 0, 00318 'operator' => 'program_op', 00319 'identifier' => 'program', 00320 'label' => 'Program', 00321 'remember' => 0, 00322 ), 00323 'case' => 1, 00324 'id' => 'program', 00325 'table' => 'analysis', 00326 'field' => 'program', 00327 'relationship' => 'none', 00328 'values_form_type' => 'select', 00329 'multiple' => 1, 00330 'optional' => 0, 00331 'agg' => array( 00332 'records_with' => 1, 00333 'aggregates_with' => 0, 00334 ), 00335 ), 00336 'timeexecuted' => array( 00337 'operator' => '>', 00338 'value' => array( 00339 'type' => 'date', 00340 'value' => '', 00341 'min' => '', 00342 'max' => '', 00343 ), 00344 'group' => '0', 00345 'exposed' => TRUE, 00346 'expose' => array( 00347 'use_operator' => 1, 00348 'operator' => 'timeexecuted_op', 00349 'identifier' => 'timeexecuted', 00350 'label' => 'Time Executed', 00351 'optional' => 1, 00352 'remember' => 0, 00353 ), 00354 'id' => 'timeexecuted', 00355 'table' => 'analysis', 00356 'field' => 'timeexecuted', 00357 'relationship' => 'none', 00358 'agg' => array( 00359 'records_with' => 1, 00360 'aggregates_with' => 0, 00361 ), 00362 ), 00363 'name' => array( 00364 'operator' => '~', 00365 'value' => '', 00366 'group' => '0', 00367 'exposed' => TRUE, 00368 'expose' => array( 00369 'use_operator' => 0, 00370 'operator' => 'name_op', 00371 'identifier' => 'name', 00372 'label' => 'Name Contains', 00373 'bef_filter_description' => '', 00374 'remember' => 0, 00375 ), 00376 'case' => 0, 00377 'id' => 'name', 00378 'table' => 'analysis', 00379 'field' => 'name', 00380 'relationship' => 'none', 00381 'values_form_type' => 'textfield', 00382 'multiple' => 0, 00383 'optional' => 0, 00384 ), 00385 'sourcename' => array( 00386 'operator' => '~', 00387 'value' => '', 00388 'group' => '0', 00389 'exposed' => TRUE, 00390 'expose' => array( 00391 'use_operator' => 0, 00392 'operator' => 'sourcename_op', 00393 'identifier' => 'sourcename', 00394 'label' => 'Source Contains', 00395 'bef_filter_description' => '', 00396 'remember' => 0, 00397 ), 00398 'case' => 0, 00399 'id' => 'sourcename', 00400 'table' => 'analysis', 00401 'field' => 'sourcename', 00402 'relationship' => 'none', 00403 ), 00404 )); 00405 $handler->override_option('access', array( 00406 'type' => 'perm', 00407 'perm' => 'access chado_analysis content', 00408 )); 00409 $handler->override_option('cache', array( 00410 'type' => 'none', 00411 )); 00412 $handler->override_option('title', 'Analysis'); 00413 $handler->override_option('header', 'Click "Show" to see a list of all analysis matching the entered criteria. If you leave a any of the criteria blank then the analysis will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all analysis will be listed.'); 00414 $handler->override_option('header_format', '2'); 00415 $handler->override_option('header_empty', 1); 00416 $handler->override_option('empty', 'No analyses match the supplied criteria.'); 00417 $handler->override_option('empty_format', '1'); 00418 $handler->override_option('items_per_page', 50); 00419 $handler->override_option('use_pager', '1'); 00420 $handler->override_option('style_plugin', 'table'); 00421 $handler->override_option('style_options', array( 00422 'grouping' => '', 00423 'override' => 1, 00424 'sticky' => 0, 00425 'order' => 'asc', 00426 'summary' => '', 00427 'columns' => array( 00428 'name' => 'name', 00429 'program' => 'program', 00430 'sourcename' => 'sourcename', 00431 'num_features' => 'num_features', 00432 'timeexecuted' => 'timeexecuted', 00433 ), 00434 'info' => array( 00435 'name' => array( 00436 'sortable' => 1, 00437 'separator' => '', 00438 ), 00439 'program' => array( 00440 'sortable' => 1, 00441 'separator' => '', 00442 ), 00443 'sourcename' => array( 00444 'sortable' => 1, 00445 'separator' => '', 00446 ), 00447 'num_features' => array( 00448 'separator' => '', 00449 ), 00450 'timeexecuted' => array( 00451 'sortable' => 1, 00452 'separator' => '', 00453 ), 00454 ), 00455 'default' => 'name', 00456 )); 00457 // this is needed so that fields/filters can be added to the default display later 00458 $default_handler = $handler; 00459 $handler = $view->new_display('page', 'Page', 'page_1'); 00460 $handler->override_option('path', 'chado/analyses'); 00461 $handler->override_option('menu', array( 00462 'type' => 'normal', 00463 'title' => 'Analyses', 00464 'description' => 'An analysis is a particular type of a computational analysis; it may be a blast of one sequence against another, or an all by all blast, or a different kind of analysis altogether. It is a single unit of computation.', 00465 'weight' => '10', 00466 'name' => 'navigation', 00467 )); 00468 $handler->override_option('tab_options', array( 00469 'type' => 'none', 00470 'title' => '', 00471 'description' => '', 00472 'weight' => 0, 00473 'name' => 'navigation', 00474 )); 00475 // Add code specific to a local chado installation 00476 // NOTE: Edit $handler above to $default_handler for the default display 00477 if (tripal_core_chado_schema_exists()) { 00478 // Add nid field 00479 $fields = $view->get_items('field', 'default'); 00480 $new_fields = array( 00481 'nid' => array( 00482 'label' => 'Nid', 00483 'alter' => array( 00484 'alter_text' => 0, 00485 'text' => '', 00486 'make_link' => 0, 00487 'path' => '', 00488 'absolute' => 0, 00489 'link_class' => '', 00490 'alt' => '', 00491 'rel' => '', 00492 'prefix' => '', 00493 'suffix' => '', 00494 'target' => '', 00495 'help' => '', 00496 'trim' => 0, 00497 'max_length' => '', 00498 'word_boundary' => 1, 00499 'ellipsis' => 1, 00500 'html' => 0, 00501 'strip_tags' => 0, 00502 ), 00503 'empty' => '', 00504 'hide_empty' => 0, 00505 'empty_zero' => 0, 00506 'hide_alter_empty' => 1, 00507 'link_to_node' => 0, 00508 'exclude' => 1, 00509 'id' => 'nid', 00510 'table' => 'node', 00511 'field' => 'nid', 00512 'relationship' => 'none', 00513 ) 00514 ); 00515 $fields = $new_fields + $fields; 00516 // Adds analysis => Node relationship 00517 $default_handler->override_option('relationships', array( 00518 'nid' => array( 00519 'label' => 'Analysis to Node', 00520 'required' => 0, 00521 'id' => 'nid', 00522 'table' => 'chado_analysis', 00523 'field' => 'nid', 00524 'relationship' => 'none', 00525 ), 00526 )); 00527 // Change analysis.name to have a link to the node 00528 $fields['name']['link_to_node'] = 1; 00529 $default_handler->override_option('fields', $fields); 00530 // Only show records with published nodes 00549 } 00550 $views[$view->name] = $view; 00551 00552 return $views; 00553 }