123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- <?php
- /**
- * @file
- * This is a temporary function holding all the old-style views integration
- * needed to link the base tables to their node. This will remain to keep things working
- * until it has been best determined how to do this via the new tripal_views integration
- *
- * It's called att the bottom of tripal_views_views_data()
- */
- function tripal_views_TEMPORARY_chado_linking_data($data) {
- global $db_url;
- // if the chado database is not local to the drupal database
- // then we need to set the database name. This should always
- // be 'chado'.
- if (is_array($db_url) and array_key_exists('chado', $db_url)) {
- // return empty data array b/c if chado is external then no join to the nodetable can be made
- return $data;
- }
- // FEATURE ====================================
- if (module_exists('tripal_feature')) {
- // Basic table definition
- $data['chado_feature']['table'] = array(
- 'field' => 'nid',
- 'group' => 'Chado Feature'
- );
- $data['chado_feature']['nid'] = array(
- 'title' => t('Feature Node ID'),
- 'help' => t('The node ID for this feature'),
- 'field' => array(
- 'handler' => 'views_handler_field_numeric',
- 'click sortable' => TRUE,
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_numeric',
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort',
- ),
- );
- // Note: No joins need to be made from $data['feature']['table']
- // Join the chado feature table to feature
- $data['chado_feature']['table']['join']['feature'] = array(
- 'left_field' => 'feature_id',
- 'field' => 'feature_id',
- );
- // Join the node table to chado feature
- $data['node']['table']['join']['chado_feature'] = array(
- 'left_field' => 'nid',
- 'field' => 'nid',
- );
- // Join the node table to feature
- $data['node']['table']['join']['feature'] = array(
- 'left_table' => 'chado_feature',
- 'left_field' => 'nid',
- 'field' => 'nid',
- );
- // Add relationship between chado_feature and feature
- $data['chado_feature']['feature_nid'] = array(
- 'group' => 'Feature',
- 'title' => 'Feature Node',
- 'help' => 'Links Chado Feature Fields/Data to the Nodes in the current View.',
- 'real field' => 'feature_id',
- 'relationship' => array(
- 'handler' => 'views_handler_relationship',
- 'title' => t('Chado => Feature'),
- 'label' => t('Chado => Feature'),
- 'real field' => 'feature_id',
- 'base' => 'feature',
- 'base field' => 'feature_id'
- ),
- );
- // Add node relationship to feature
- $data['chado_feature']['feature_chado_nid'] = array(
- 'group' => 'Feature',
- 'title' => 'Feature Node',
- 'help' => 'Links Chado Feature Fields/Data to the Nodes in the current View.',
- 'real field' => 'nid',
- 'relationship' => array(
- 'handler' => 'views_handler_relationship',
- 'title' => t('Chado => Node'),
- 'label' => t('Chado => Node'),
- 'real field' => 'nid',
- 'base' => 'node',
- 'base field' => 'nid'
- ),
- );
- }
- // ANALYSIS ===================================
- if (module_exists('tripal_analysis')) {
- // Basic table definition
- $data['chado_analysis']['table'] = array(
- 'field' => 'nid',
- 'group' => 'Chado Analysis'
- );
- $data['chado_analysis']['nid'] = array(
- 'title' => t('Analysis Node ID'),
- 'help' => t('The node ID for this analysis'),
- 'field' => array(
- 'handler' => 'views_handler_field_numeric',
- 'click sortable' => TRUE,
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_numeric',
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort',
- ),
- );
- // Note: No joins need to be made from $data['analysis']['table']
- // Join the chado analysis table to analysis
- $data['chado_analysis']['table']['join']['analysis'] = array(
- 'left_field' => 'analysis_id',
- 'field' => 'analysis_id',
- );
- // Join the node table to chado analysis
- $data['node']['table']['join']['chado_analysis'] = array(
- 'left_field' => 'nid',
- 'field' => 'nid',
- );
- // Join the node table to analysis
- $data['node']['table']['join']['analysis'] = array(
- 'left_table' => 'chado_analysis',
- 'left_field' => 'nid',
- 'field' => 'nid',
- );
- // Add relationship between chado_analysis and analysis
- $data['chado_analysis']['analysis_nid'] = array(
- 'group' => 'Analysis',
- 'title' => 'Analysis Node',
- 'help' => 'Links Chado Analysis Fields/Data to the Nodes in the current View.',
- 'real field' => 'analysis_id',
- 'relationship' => array(
- 'handler' => 'views_handler_relationship',
- 'title' => t('Chado => Analysis'),
- 'label' => t('Chado => Analysis'),
- 'real field' => 'analysis_id',
- 'base' => 'analysis',
- 'base field' => 'analysis_id'
- ),
- );
- // Add node relationship to analysis
- $data['chado_analysis']['analysis_chado_nid'] = array(
- 'group' => 'Analysis',
- 'title' => 'Analysis Node',
- 'help' => 'Links Chado Analysis Fields/Data to the Nodes in the current View.',
- 'real field' => 'nid',
- 'relationship' => array(
- 'handler' => 'views_handler_relationship',
- 'title' => t('Chado => Node'),
- 'label' => t('Chado => Node'),
- 'real field' => 'nid',
- 'base' => 'node',
- 'base field' => 'nid'
- ),
- );
- }
- // ORGANISM ===================================
- if (module_exists('tripal_organism')) {
- // Basic table definition
- $data['chado_organism']['table'] = array(
- 'field' => 'nid',
- 'group' => 'Chado Organism'
- );
- $data['chado_organism']['nid'] = array(
- 'title' => t('Organism Node ID'),
- 'help' => t('The node ID for this organism'),
- 'field' => array(
- 'handler' => 'views_handler_field_numeric',
- 'click sortable' => TRUE,
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_numeric',
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort',
- ),
- );
- // Note: No joins need to be made from $data['organism']['table']
- // Join the chado organism table to organism
- $data['chado_organism']['table']['join']['organism'] = array(
- 'left_field' => 'organism_id',
- 'field' => 'organism_id',
- );
- // Join the node table to chado organism
- $data['node']['table']['join']['chado_organism'] = array(
- 'left_field' => 'nid',
- 'field' => 'nid',
- );
- // Join the node table to organism
- $data['node']['table']['join']['organism'] = array(
- 'left_table' => 'chado_organism',
- 'left_field' => 'nid',
- 'field' => 'nid',
- );
- // Add relationship between chado_organism and organism
- $data['chado_organism']['organism_id'] = array(
- 'group' => 'Organism',
- 'title' => 'Organism Node',
- 'help' => 'Links Chado Organism Fields/Data to the Nodes in the current View.',
- 'real field' => 'organism_id',
- 'relationship' => array(
- 'handler' => 'views_handler_relationship',
- 'title' => t('Chado => Organism'),
- 'label' => t('Chado => Organism'),
- 'real field' => 'organism_id',
- 'base' => 'organism',
- 'base field' => 'organism_id'
- ),
- );
- /*
- // Add node relationship to organism
- $data['chado_organism']['nid'] = array(
- 'group' => 'Organism',
- 'title' => 'Organism Node',
- 'help' => 'Links Chado Organism Fields/Data to the Nodes in the current View.',
- 'real field' => 'nid',
- 'relationship' => array(
- 'handler' => 'views_handler_relationship',
- 'title' => t('Chado => Node'),
- 'label' => t('Chado => Node'),
- 'real field' => 'nid',
- 'base' => 'node',
- 'base field' => 'nid'
- ),
- );
- */
- }
- // LIBRARY ====================================
- if (module_exists('tripal_library')) {
- // Basic table definition
- $data['chado_library']['table'] = array(
- 'field' => 'nid',
- 'group' => 'Chado Library'
- );
- $data['chado_library']['nid'] = array(
- 'title' => t('Library Node ID'),
- 'help' => t('The node ID for this library'),
- 'field' => array(
- 'handler' => 'views_handler_field_numeric',
- 'click sortable' => TRUE,
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_numeric',
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort',
- ),
- );
- // Note: No joins need to be made from $data['library']['table']
- // Join the chado library table to library
- $data['chado_library']['table']['join']['library'] = array(
- 'left_field' => 'library_id',
- 'field' => 'library_id',
- );
- // Join the node table to chado library
- $data['node']['table']['join']['chado_library'] = array(
- 'left_field' => 'nid',
- 'field' => 'nid',
- );
- // Join the node table to library
- $data['node']['table']['join']['library'] = array(
- 'left_table' => 'chado_library',
- 'left_field' => 'nid',
- 'field' => 'nid',
- );
- // Add relationship between chado_library and library
- $data['chado_library']['library_nid'] = array(
- 'group' => 'Library',
- 'title' => 'Library Node',
- 'help' => 'Links Chado Library Fields/Data to the Nodes in the current View.',
- 'real field' => 'library_id',
- 'relationship' => array(
- 'handler' => 'views_handler_relationship',
- 'title' => t('Chado => Library'),
- 'label' => t('Chado => Library'),
- 'real field' => 'library_id',
- 'base' => 'library',
- 'base field' => 'library_id'
- ),
- );
- // Add node relationship to library
- $data['chado_library']['library_chado_nid'] = array(
- 'group' => 'Library',
- 'title' => 'Library Node',
- 'help' => 'Links Chado Library Fields/Data to the Nodes in the current View.',
- 'real field' => 'nid',
- 'relationship' => array(
- 'handler' => 'views_handler_relationship',
- 'title' => t('Chado => Node'),
- 'label' => t('Chado => Node'),
- 'real field' => 'nid',
- 'base' => 'node',
- 'base field' => 'nid'
- ),
- );
- }
- // STOCK ======================================
- if (module_exists('tripal_stock')) {
- // Basic table definition
- $data['chado_stock']['table'] = array(
- 'field' => 'stock_id',
- 'group' => 'Chado Stock',
- );
- $data['chado_stock']['nid'] = array(
- 'title' => t('Stock Node ID'),
- 'help' => t('The node ID for this analysis'),
- 'field' => array(
- 'handler' => 'views_handler_field_numeric',
- 'click sortable' => TRUE,
- ),
- 'filter' => array(
- 'handler' => 'views_handler_filter_numeric',
- ),
- 'sort' => array(
- 'handler' => 'views_handler_sort',
- ),
- );
- // Note: No joins need to be made from $data['stock']['table']
- // Join the chado stock table to stock
- $data['chado_stock']['table']['join']['stock'] = array(
- 'left_field' => 'stock_id',
- 'field' => 'stock_id',
- );
- // Join the node table to chado stock
- $data['node']['table']['join']['chado_stock'] = array(
- 'left_field' => 'nid',
- 'field' => 'nid',
- );
- // Join the node table to stock
- $data['node']['table']['join']['stock'] = array(
- 'left_table' => 'chado_stock',
- 'left_field' => 'nid',
- 'field' => 'nid',
- );
- // Add relationship between chado_stock and stock
- $data['chado_stock']['stock_nid'] = array(
- 'group' => 'Stock',
- 'title' => 'Stock Node',
- 'help' => 'Links Chado Stock Fields/Data to the Nodes in the current View.',
- 'real field' => 'stock_id',
- 'relationship' => array(
- 'handler' => 'views_handler_relationship',
- 'title' => t('Chado => Stock'),
- 'label' => t('Chado => Stock'),
- 'real field' => 'stock_id',
- 'base' => 'stock',
- 'base field' => 'stock_id'
- ),
- );
- // Add node relationship to stock
- $data['chado_stock']['stock_chado_nid'] = array(
- 'group' => 'Stock',
- 'title' => 'Stock Node',
- 'help' => 'Links Chado Stock Fields/Data to the Nodes in the current View.',
- 'real field' => 'nid',
- 'relationship' => array(
- 'handler' => 'views_handler_relationship',
- 'title' => t('Chado => Node'),
- 'label' => t('Chado => Node'),
- 'real field' => 'nid',
- 'base' => 'node',
- 'base field' => 'nid'
- ),
- );
- }
- return $data;
- }
|