Tripal v1.0 (6.x-1.0)
tripal_featuremap.views.inc
Go to the documentation of this file.
00001 <?php
00002 
00018 /*************************************************************************
00019  * Implements hook_views_data()
00020  * Purpose: Describe chado/tripal tables & fields to views
00021  * @return: a data array which follows the structure outlined in the
00022  *   views2 documentation for this hook. Essentially, it's an array of table
00023  *   definitions keyed by chado/tripal table name. Each table definition
00024  *   includes basic details about the table, fields in that table and
00025  *   relationships between that table and others (joins)
00026  *
00027  * @ingroup tripal_featuremap_views
00028  */
00029 function tripal_featuremap_views_data()  {
00030   $data = array();
00031 
00032   if (module_exists('tripal_views')) {
00033     $tables = array(
00034       'featuremap'
00035     );
00036     foreach ($tables as $tablename) {
00037       $priority = 9;
00038 
00039       // check to see if the table is integrated. If it is then integrate it's
00040       // corresponding 'chado_[table]' table.
00041       if (!tripal_views_is_integrated($tablename, $priority)) {
00042         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
00043 
00044         // Add custom handle to handle type_ids
00045         $table_integration_array['fields']['unittype_id']['handlers']['filter']['name'] = 'tripal_views_handler_filter_select_cvterm';
00046 
00047         // Add in node relationships if chado is in the same db as drupal
00048         if (tripal_core_chado_schema_exists()) {
00049           $integrations = tripal_views_add_node_relationship_to_chado_table_integration($table_integration_array);
00050           foreach ($integrations as $integration) {
00051             tripal_views_integration_add_entry($integration);
00052           }
00053         }
00054         else {
00055           tripal_views_integration_add_entry($table_integration_array);
00056         }
00057 
00058       }
00059     }
00060 
00061     $tables = array(
00062       'map_cvterm',
00063       'map_feature',
00064       'map_pub',
00065       'map_synonym',
00066       'mapprop'
00067     );
00068     foreach ($tables as $tablename) {
00069       $priority = 9;
00070       if (!tripal_views_is_integrated($tablename, $priority)) {
00071         $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
00072         tripal_views_integration_add_entry($table_integration_array);
00073       }
00074     }
00075   }
00076 
00077   return $data;
00078 }
00079 
00080 /*************************************************************************
00081  * Implements hook_views_handlers()
00082  * Purpose: Register all custom handlers with views
00083  *   where a handler describes either "the type of field",
00084  *   "how a field should be filtered", "how a field should be sorted"
00085  * @return: An array of handler definitions
00086  *
00087  * @ingroup tripal_featuremap_views
00088  */
00089 function tripal_featuremap_views_handlers() {
00090   return array(
00091    'info' => array(
00092      'path' => drupal_get_path('module', 'tripal_featuremap') . '/views/handlers',
00093       ),
00094    'handlers' => array(
00095      'views_handler_field_computed_map_nid' => array(
00096        'parent' => 'views_handler_field_numeric',
00097       ),
00098     ),
00099   );
00100 }
00101 
00105 function tripal_featuremap_views_data_alter(&$data) {
00106 
00107   if ( !(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
00108 
00109     // Add featuer relationship to node
00110     $data['node']['map_chado_nid'] = array(
00111       'group' => 'Map',
00112       'title' => 'Map Node',
00113       'help' => 'Links Chado Map Fields/Data to the Nodes in the current View.',
00114       'real field' => 'nid',
00115       'relationship' => array(
00116         'handler' => 'views_handler_relationship',
00117         'title' => t('Node => Chado'),
00118         'label' => t('Node => Chado'),
00119         'real field' => 'nid',
00120         'base' => 'chado_map',
00121         'base field' => 'nid'
00122       ),
00123     );
00124   }
00125 
00126 }
00127 
00133 function tripal_featuremap_views_default_views() {
00134   $views = array();
00135 
00136   if (!module_exists('tripal_views')) {
00137     return $views;
00138   }
00139 
00140   // Main default view
00141   $view = new view;
00142   $view->name = 'featuremap_listing';
00143   $view->description = 'A listing of all chado feature maps';
00144   $view->tag = 'chado default';
00145   $view->base_table = 'featuremap';
00146   $view->core = 6;
00147   $view->api_version = '2';
00148   $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
00149   $handler = $view->new_display('default', 'Defaults', 'default');
00150   $handler->override_option('fields', array(
00151     'name' => array(
00152       'label' => 'Name',
00153       'alter' => array(
00154         'alter_text' => 0,
00155         'text' => '',
00156         'make_link' => 0,
00157         'path' => '',
00158         'absolute' => 0,
00159         'link_class' => '',
00160         'alt' => '',
00161         'rel' => '',
00162         'prefix' => '',
00163         'suffix' => '',
00164         'target' => '',
00165         'help' => '',
00166         'trim' => 0,
00167         'max_length' => '',
00168         'word_boundary' => 1,
00169         'ellipsis' => 1,
00170         'html' => 0,
00171         'strip_tags' => 0,
00172       ),
00173       'empty' => '',
00174       'hide_empty' => 0,
00175       'empty_zero' => 0,
00176       'hide_alter_empty' => 1,
00177       'type' => 'separator',
00178       'separator' => ', ',
00179       'exclude' => 0,
00180       'id' => 'name',
00181       'table' => 'featuremap',
00182       'field' => 'name',
00183       'relationship' => 'none',
00184     ),
00185     'description' => array(
00186       'label' => 'Description',
00187       'alter' => array(
00188         'alter_text' => 0,
00189         'text' => '',
00190         'make_link' => 0,
00191         'path' => '',
00192         'absolute' => 0,
00193         'link_class' => '',
00194         'alt' => '',
00195         'rel' => '',
00196         'prefix' => '',
00197         'suffix' => '',
00198         'target' => '',
00199         'help' => '',
00200         'trim' => 0,
00201         'max_length' => '',
00202         'word_boundary' => 1,
00203         'ellipsis' => 1,
00204         'html' => 0,
00205         'strip_tags' => 0,
00206       ),
00207       'empty' => '',
00208       'hide_empty' => 0,
00209       'empty_zero' => 0,
00210       'hide_alter_empty' => 1,
00211       'type' => 'separator',
00212       'separator' => ', ',
00213       'exclude' => 0,
00214       'id' => 'description',
00215       'table' => 'featuremap',
00216       'field' => 'description',
00217       'relationship' => 'none',
00218     ),
00219     'name_1' => array(
00220       'label' => 'Map Units',
00221       'alter' => array(
00222         'alter_text' => 0,
00223         'text' => '',
00224         'make_link' => 0,
00225         'path' => '',
00226         'absolute' => 0,
00227         'link_class' => '',
00228         'alt' => '',
00229         'rel' => '',
00230         'prefix' => '',
00231         'suffix' => '',
00232         'target' => '',
00233         'help' => '',
00234         'trim' => 0,
00235         'max_length' => '',
00236         'word_boundary' => 1,
00237         'ellipsis' => 1,
00238         'html' => 0,
00239         'strip_tags' => 0,
00240       ),
00241       'empty' => '',
00242       'hide_empty' => 0,
00243       'empty_zero' => 0,
00244       'hide_alter_empty' => 1,
00245       'type' => 'separator',
00246       'separator' => ', ',
00247       'exclude' => 0,
00248       'id' => 'name_1',
00249       'table' => 'cvterm',
00250       'field' => 'name',
00251       'relationship' => 'none',
00252     ),
00253   ));
00254   $handler->override_option('sorts', array(
00255     'name' => array(
00256       'order' => 'ASC',
00257       'id' => 'name',
00258       'table' => 'featuremap',
00259       'field' => 'name',
00260       'relationship' => 'none',
00261     ),
00262   ));
00263   $handler->override_option('filters', array(
00264     'unittype_id' => array(
00265       'operator' => '=',
00266       'value' => '',
00267       'group' => '0',
00268       'exposed' => TRUE,
00269       'expose' => array(
00270         'use_operator' => 0,
00271         'operator' => 'unittype_id_op',
00272         'identifier' => 'unittype_id',
00273         'label' => 'Map Units',
00274         'remember' => 0,
00275       ),
00276       'case' => 1,
00277       'id' => 'unittype_id',
00278       'table' => 'featuremap',
00279       'field' => 'unittype_id',
00280       'relationship' => 'none',
00281       'values_form_type' => 'select',
00282       'multiple' => 1,
00283       'optional' => 0,
00284       'show_all' => 0,
00285       'agg' => array(
00286         'records_with' => 1,
00287         'aggregates_with' => 1,
00288       ),
00289     ),
00290     'name_1' => array(
00291       'operator' => '~',
00292       'value' => '',
00293       'group' => '0',
00294       'exposed' => TRUE,
00295       'expose' => array(
00296         'use_operator' => 0,
00297         'operator' => 'name_1_op',
00298         'identifier' => 'name_1',
00299         'label' => 'Name',
00300         'remember' => 0,
00301       ),
00302       'case' => 0,
00303       'id' => 'name_1',
00304       'table' => 'featuremap',
00305       'field' => 'name',
00306       'relationship' => 'none',
00307       'agg' => array(
00308         'records_with' => 1,
00309         'aggregates_with' => 1,
00310       ),
00311     ),
00312     'description' => array(
00313       'operator' => '~',
00314       'value' => '',
00315       'group' => '0',
00316       'exposed' => TRUE,
00317       'expose' => array(
00318         'use_operator' => 0,
00319         'operator' => 'description_op',
00320         'identifier' => 'description',
00321         'label' => 'Description',
00322         'remember' => 0,
00323       ),
00324       'case' => 0,
00325       'id' => 'description',
00326       'table' => 'featuremap',
00327       'field' => 'description',
00328       'relationship' => 'none',
00329       'agg' => array(
00330         'records_with' => 1,
00331         'aggregates_with' => 1,
00332       ),
00333     ),
00334     'search_results' => array(
00335       'operator' => '=',
00336       'value' => '',
00337       'group' => '0',
00338       'exposed' => FALSE,
00339       'expose' => array(
00340         'operator' => FALSE,
00341         'label' => '',
00342       ),
00343       'id' => 'search_results',
00344       'table' => 'views',
00345       'field' => 'search_results',
00346       'relationship' => 'none',
00347       'apply_button' => 'Show',
00348       'no_results_text' => 'Click "Show" to see a list of all feature maps matching the entered criteria. If you leave a any of the criteria blank then the maps will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all maps will be listed.',
00349     ),
00350   ));
00351   $handler->override_option('access', array(
00352     'type' => 'perm',
00353     'perm' => 'access chado_featuremap content',
00354   ));
00355   $handler->override_option('cache', array(
00356     'type' => 'none',
00357   ));
00358   $handler->override_option('title', 'Maps');
00359   $handler->override_option('header', 'Click "Show" to see a list of all feature maps matching the entered criteria. If you leave a any of the criteria blank then the maps will be not be filtered based on that field. Furthermore, if you leave all criteria blank then all maps will be listed.');
00360   $handler->override_option('header_format', '1');
00361   $handler->override_option('header_empty', 1);
00362   $handler->override_option('empty', 'No feature maps match the current criteria.');
00363   $handler->override_option('empty_format', '1');
00364   $handler->override_option('items_per_page', 25);
00365   $handler->override_option('use_pager', '1');
00366   $handler->override_option('style_plugin', 'table');
00367   $handler->override_option('style_options', array(
00368     'grouping' => '',
00369     'override' => 1,
00370     'sticky' => 0,
00371     'order' => 'asc',
00372     'summary' => '',
00373     'columns' => array(
00374       'name' => 'name',
00375       'description' => 'description',
00376       'name_1' => 'name_1',
00377     ),
00378     'info' => array(
00379       'name' => array(
00380         'sortable' => 1,
00381         'separator' => '',
00382       ),
00383       'description' => array(
00384         'sortable' => 1,
00385         'separator' => '',
00386       ),
00387       'name_1' => array(
00388         'sortable' => 1,
00389         'separator' => '',
00390       ),
00391     ),
00392     'default' => '-1',
00393   ));
00394   $handler = $view->new_display('page', 'Page', 'page_1');
00395   $handler->override_option('path', 'chado/featuremaps');
00396   $handler->override_option('menu', array(
00397     'type' => 'normal',
00398     'title' => 'Maps',
00399     'description' => 'A listing of chado feature maps.',
00400     'weight' => '0',
00401     'name' => 'navigation',
00402   ));
00403   $handler->override_option('tab_options', array(
00404     'type' => 'none',
00405     'title' => '',
00406     'description' => '',
00407     'weight' => 0,
00408     'name' => 'navigation',
00409   ));
00410   $views[$view->name] = $view;
00411 
00412   return $views;
00413 }
 All Classes Files Functions Variables