|
Tripal 0.3b
|
00001 <?php 00002 00003 /************************************************************************* 00004 * @file: THIS IS A TEMPLATE AND SHOULD NOT BE INCLUDED IN THE MODULE CODE 00005 * 00006 * - simply replace all XXX with the original chado table you want to join to it's drupal nodes. 00007 * (ie: If you want to join features to their drupal nodes then XXX=feature) 00008 * 00009 * NOTE: Creating the table definition file is not enough. You also need to call the 00010 * retrieve_XXX_views_data() function from ../tripal_pub.views.inc:tripal_pub_views_data() 00011 * by adding the following line: 00012 * $data = array_merge($data, retrieve_XXX_views_data()); 00013 * to the function and including the file directly above the function (blow the function 00014 * header by adding: 00015 * require_once('views/XXX.views.inc'); 00016 * 00017 * REMOVE THIS COMMENT IN THE COPY! 00018 */ 00019 00020 /** 00021 * @file 00022 * This file defines the data array for a given chado table. This array 00023 * is merged into a larger array containing definitions of all tables associated 00024 * with this module in: 00025 * @see tripal_pub.views.inc --in tripal_pub_views_data() 00026 * 00027 * Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 00028 * This file simply defines this linking table and joins the three tables together. 00029 * No modification of XXX.views.inc is needed. 00030 * 00031 * Documentation on views integration can be found at 00032 * http://views2.logrus.com/doc/html/index.html. 00033 */ 00034 00035 /** 00036 * Purpose: this function returns the portion of the data array 00037 * which describes the chado_XXX drupal table, it's fields and any joins between it 00038 * and other tables 00039 * @see tripal_pub_views_data() --in tripal_pub.views.inc 00040 * 00041 * The main need for description of this table to views is to join chado data with drupal nodes 00042 * 00043 */ 00044 function retrieve_chado_XXX_views_data () { 00045 global $db_url; 00046 $data = array(); 00047 00048 // if the chado database is not local to the drupal database 00049 // then we need to set the database name. This should always 00050 // be 'chado'. 00051 if(is_array($db_url) and array_key_exists('chado',$db_url)){ 00052 // return empty data array b/c if chado is external then no join to the nodetable can be made 00053 return $data; 00054 } 00055 00056 //Basic table definition----------------------------------- 00057 $data['chado_XXX']['table'] = array( 00058 'field' => 'nid', 00059 ); 00060 00061 //Relationship Definitions--------------------------------- 00062 // Note: No joins need to be made from $data['XXX']['table'] 00063 00064 // Join the chado_XXX table to XXX 00065 $data['chado_XXX']['table']['join']['XXX'] = array( 00066 'left_field' => 'XXX_id', 00067 'field' => 'XXX_id', 00068 ); 00069 00070 // Join the node table to chado_XXX 00071 $data['node']['table']['join']['chado_XXX'] = array( 00072 'left_field' => 'nid', 00073 'field' => 'nid', 00074 ); 00075 00076 // Join the node table to XXX 00077 $data['node']['table']['join']['XXX'] = array( 00078 'left_table' => 'chado_XXX', 00079 'left_field' => 'nid', 00080 'field' => 'nid', 00081 ); 00082 00083 return $data; 00084 }