Parcourir la source

Tripal Project adheres to Drupal coding standards

Pubudu Basnayaka il y a 12 ans
Parent
commit
76242c5aad

+ 34 - 33
tripal_project/tripal_project.admin.inc

@@ -1,54 +1,54 @@
 <?php
 
-function tripal_project_administration_description_page () {
+function tripal_project_administration_description_page() {
  $output = '';
- 
- 
+
+
  return $output;
 }
 
-function tripal_project_configuration_page () {
+function tripal_project_configuration_page() {
   $output = '';
-  
+
   $output .= drupal_get_form('tripal_project_sync_projects_form');
-  
+
   return $output;
 }
 
-function tripal_project_sync_projects_form ($form_state = NULL) {
+function tripal_project_sync_projects_form($form_state = NULL) {
   $form = array();
-  
+
   $form['sync'] = array(
     '#type' => 'fieldset',
     '#title' => 'Sync Projects'
   );
-  
+
   $form['sync']['description'] = array(
     '#type' => 'item',
     '#value' => 'Many of the details for projects are stored in chado. Often other tripal '
       .'modules may create projects as a means of grouping data together. Sync\'ing projects '
       .'in chado created drupal pages (known as nodes) which display the data to priviledged users.'
   );
-  
+
   $form['sync']['submit'] = array(
     '#type' => 'submit',
     '#value' => 'Sync All Projects',
-    
+
   );
-  
+
   return $form;
 }
 
-function tripal_project_sync_projects_form_submit ($form, &$form_state) {
+function tripal_project_sync_projects_form_submit($form, &$form_state) {
   global $user;
-  
+
   //sync'ing is done by a tripal_job that is added here
-  $job_id = tripal_add_job('Sync Projects', 'tripal_project', 
-	'tripal_project_sync_all_projects', array(), $user->uid);
+  $job_id = tripal_add_job('Sync Projects', 'tripal_project',
+  'tripal_project_sync_all_projects', array(), $user->uid);
 
 }
 
-function tripal_project_sync_all_projects () {
+function tripal_project_sync_all_projects() {
 
   //retrieve all projects in drupal
   $resource = db_query('SELECT project_id FROM {chado_project}');
@@ -56,11 +56,11 @@ function tripal_project_sync_all_projects () {
   while ($r = db_fetch_object($resource)) {
     $drupal_projects[$r->project_id] = $r->project_id;
   }
-  
+
   // retrieve all projects in chado
   $chado_projects = array();
   $previous_db = tripal_db_set_active('chado');
-  $resource = db_query('SELECT project_id FROM project');
+  $resource = db_query('SELECT project_id FROM {project}');
   tripal_db_set_active($previous_db);
   while ($r = db_fetch_object($resource)) {
     // if not already in drupal add to list to be sync'd
@@ -68,12 +68,12 @@ function tripal_project_sync_all_projects () {
       $chado_projects[$r->project_id] = $r->project_id;
     }
   }
-  
-  print 'Number of Projects to Sync: '.sizeof($chado_projects)."\n";
-  
+
+  print 'Number of Projects to Sync: ' . sizeof($chado_projects) . "\n";
+
   foreach ($chado_projects as $project_id) {
-    $project = tripal_core_chado_select('project',array('name','description'),array('project_id'=>$project_id));
-    
+    $project = tripal_core_chado_select('project', array('name', 'description'), array('project_id' => $project_id));
+
     // create node
     $new_node = new stdClass();
     $new_node->type = 'chado_project';
@@ -83,18 +83,19 @@ function tripal_project_sync_all_projects () {
     $new_node->description = $project[0]->description;
     node_validate($new_node);
     $errors = form_get_errors();
-    if(!$errors){
+    if (!$errors) {
       $node = node_submit($new_node);
       node_save($node);
-      if($node->nid){
-         print "Added ".$project[0]->name." (Node ID:".$node->nid.")\n";
+      if ($node->nid) {
+         print "Added " . $project[0]->name . " (Node ID:" . $node->nid . ")\n";
       }
-    } else {
-      print "Failed to insert project: ".$project[0]->name."\n";
-      print "Errors: ".print_r($errors, TRUE)."\n";
     }
-    
+    else {
+      print "Failed to insert project: " . $project[0]->name . "\n";
+      print "Errors: " . print_r($errors, TRUE) . "\n";
+    }
+
   }
-  
-  
+
+
 }

+ 33 - 33
tripal_project/tripal_project.install

@@ -4,8 +4,8 @@
 /**
  * @file
  * This file contains all the functions which describe and implement drupal database tables
- * needed by this module. This module was developed by Chad N.A. Krilow and Lacey-Anne Sanderson, 
- * University of Saskatchewan. 
+ * needed by this module. This module was developed by Chad N.A. Krilow and Lacey-Anne Sanderson,
+ * University of Saskatchewan.
  *
  * The project manamgenet module allows you to sync data in a chado/Tripal instance with
  * multiple project/mysql instances as well as manage and create such project instances
@@ -15,14 +15,14 @@
  * Implementation of hook_install()
  */
 function tripal_project_install() {
-	drupal_install_schema('tripal_project');
+  drupal_install_schema('tripal_project');
 }
 
 /**
- * Implementation of hook_uninstall() 
+ * Implementation of hook_uninstall()
  */
 function tripal_project_uninstall() {
-	drupal_uninstall_schema('tripal_project');
+  drupal_uninstall_schema('tripal_project');
 }
 
 /**
@@ -30,37 +30,37 @@ function tripal_project_uninstall() {
  */
 function tripal_project_schema() {
 
-	//specification for 'tripal_project_instances'
-	$schema['chado_project'] = array(
-		
-		'fields' => array(
-      
-	    //a int field that cannot be null and acts as a unique identifier for all nid's
+  //specification for 'tripal_project_instances'
+  $schema['chado_project'] = array(
+
+    'fields' => array(
+
+      //a int field that cannot be null and acts as a unique identifier for all nid's
       'nid' => array(
-				'type' => 'int',
-				'unsigned' => TRUE,
-				'not null' => TRUE,
- 	 	  ),
-		
-	    //a int field that cannot be null and is vid 	  
-  		'vid' => array(
-   	   	'type' => 'int',
-   	   	'not null' => TRUE,
-  	  ),
-   	 	
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        ),
+
+      //a int field that cannot be null and is vid
+      'vid' => array(
+          'type' => 'int',
+          'not null' => TRUE,
+      ),
+
       //a intfield, not null and project_id is the unique_id of the project in chado
-    	 'project_id' => array(
-   	   	'type' => 'int',
-   	   	'unsigned' => TRUE,
-   	   	'not null' => TRUE,
-    	),
-    	 	
-  	  	
+       'project_id' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+      ),
+
+
     ),//end of shema
-  	
-  	'primary key' => array('nid','vid','project_id'),
-	
-	);
+
+    'primary key' => array('nid', 'vid', 'project_id'),
+
+  );
 
   return $schema;
 }

+ 58 - 58
tripal_project/tripal_project.module

@@ -5,9 +5,9 @@ require('tripal_project.admin.inc');
 /**
  *  @file
  * This file contains the basic functions needed for this drupal module.
- * The drupal tripal_project module maps directly to the chado general module. 
+ * The drupal tripal_project module maps directly to the chado general module.
  *
- * For documentation regarding the Chado General module: 
+ * For documentation regarding the Chado General module:
  * @see http://gmod.org/wiki/Chado_General_Module
  */
 
@@ -23,7 +23,7 @@ require('tripal_project.admin.inc');
  *  for this module which then includes tripal_project.views.inc where all the
  *  views integration code is
  *
- */ 
+ */
 function tripal_project_views_api() {
    return array(
       'api' => 2.0,
@@ -39,15 +39,15 @@ function tripal_project_menu() {
     'page callback' => 'tripal_project_administration_description_page',
     'access arguments' => array('administer site configuration'),
     'type' => MENU_NORMAL_ITEM
-  ); 
+  );
 
   $items[ 'admin/tripal/tripal_project/configuration' ]= array(
     'title' => t('Configuration'),
     'page callback' => 'tripal_project_configuration_page',
     'access arguments' => array('administer site configuration'),
     'type' => MENU_NORMAL_ITEM
-  ); 
-  
+  );
+
   return $items;
 }
 
@@ -62,7 +62,7 @@ function tripal_project_perm() {
 
   return array(
     'access chado_projects',
-    'create chado_projects', 
+    'create chado_projects',
     'edit own chado_projects'
   );
 }
@@ -76,10 +76,10 @@ function tripal_project_perm() {
  *    The operation that is to be performed
  *
  *  @parm $node
- *    The specific node that is to have the operation performed  
+ *    The specific node that is to have the operation performed
  *
  *  @parm $account
- *    The account of the user that is performing the operations  
+ *    The account of the user that is performing the operations
  *
  *  @return
  *    True if a operation was performed
@@ -88,29 +88,29 @@ function tripal_project_perm() {
 function chado_project_access($op, $node, $account) {
 
   if ($op == 'create') {
-  
+
     // Only users with permission to do so may create this node type.
-    if(!user_access('create chado_projects', $account)){
+    if (!user_access('create chado_projects', $account)) {
       return FALSE;
     }
   }
 
   // Users who create a node may edit or delete it later, assuming they have the necessary permissions.
   if ($op == 'update' || $op == 'delete') {
-  
-    if(!user_access('edit own chado_projects',$account)){
+
+    if (!user_access('edit own chado_projects', $account)) {
        return FALSE;
     }
-    if(user_access('edit own chado_projects',$account) &&
-       $account->uid != $node->uid){
+    if (user_access('edit own chado_projects', $account) &&
+       $account->uid != $node->uid) {
       return FALSE;
     }
   }
-  
+
   if ($op == 'view') {
-    if(!user_access('access chado_projects', $account)){
+    if (!user_access('access chado_projects', $account)) {
       return FALSE;
-    }  
+    }
   }
   return NULL;
 }
@@ -133,10 +133,10 @@ function tripal_project_node_info() {
       'name' => t('Project'),
       'module' => 'chado_project',
       'description' => t('A module for interfacing the GMOD chado database with Drupal, providing viewing of projects'),
-    	'has_title' => TRUE,
-    	'title_label' =>t('Project Name'),
-    	'had_body' => TRUE,
-    	'body_label' =>t('Full Description'),
+      'has_title' => TRUE,
+      'title_label' => t('Project Name'),
+      'had_body' => TRUE,
+      'body_label' => t('Full Description'),
     )
   );
 }
@@ -150,7 +150,7 @@ function tripal_project_node_info() {
 *    The initialized node
 *
 *  @parm $form_state
-*    The state of the form, that has the user entered information that is neccessary for adding 
+*    The state of the form, that has the user entered information that is neccessary for adding
 *    information to the project
 *
 *  @return $form
@@ -174,15 +174,15 @@ function chado_project_form(&$node, $form_state) {
     '#maxlength' => 255,
     '#title' => 'Short Description',
     '#default_value' => $node->project->description,
-  ); 
-  
+  );
+
   $form['body_filter']['body'] = array(
     '#type' => 'textarea',
     '#title' => check_plain($type->body_label),
     '#default_value' => $node->body,
   );
   $form['body_filter']['filter'] = filter_form($node->format);
-  
+
   // whether or not the project exists in chado
   $form['project_id'] = array(
     '#type' => 'value',
@@ -200,21 +200,21 @@ function chado_project_form(&$node, $form_state) {
 *
 */
 function chado_project_insert($node) {
-		
-	$values =  array(
+
+  $values =  array(
      'name' => $node->title,
      'description' => $node->description,
    );
-   
+
    if (!$node->project_id) {
      //inserts info into chado table.
-     $result = tripal_core_chado_insert('project',$values);
+     $result = tripal_core_chado_insert('project', $values);
      $node->project_id = $result['project_id'];
-  } 
-  
-	//inserts the row of vid,nid,project_id into the chado_project table
+  }
+
+  //inserts the row of vid,nid,project_id into the chado_project table
   db_query("INSERT INTO {chado_project} (vid, nid, project_id) VALUES (%d, %d, %d)", $node->vid, $node->nid, $node->project_id);
-  
+
 }
 
 /**
@@ -222,19 +222,19 @@ function chado_project_insert($node) {
 * Implementation of hook_delete().
 *
 * @param $node
-* The node which is to be deleted, only chado project and chado_project need to be dealt with 
+* The node which is to be deleted, only chado project and chado_project need to be dealt with
 * since the drupal node is deleted automagically
 *
 */
 function chado_project_delete($node) {
   // Notice that we're matching all revision, by using the node's nid.
-  
+
   // Find the project to delete
   $values =  array(
      'project_id' => $node->project->project_id,
    );
-  tripal_core_chado_delete('project',$values);
-  
+  tripal_core_chado_delete('project', $values);
+
   //deleteing in drupal chado_project table
   db_query('DELETE FROM {chado_project} WHERE nid = %d', $node->nid);
 
@@ -248,20 +248,20 @@ function chado_project_delete($node) {
 *  pertaining to the specific project
 *
 */
-function chado_project_update($node){
-	
-	// Find the project to update
-	$match= array(
-		'project_id'=>$node->project_id,
-	);
-	
-	// New values
-	$values =  array(
+function chado_project_update($node) {
+
+  // Find the project to update
+  $match= array(
+    'project_id' => $node->project_id,
+  );
+
+  // New values
+  $values =  array(
     'name' => $node->title,
     'description' => $node->description,
   );
 
-  $result = tripal_core_chado_update('project',$match,$values);
+  $result = tripal_core_chado_update('project', $match, $values);
 
 }
 
@@ -277,17 +277,17 @@ function chado_project_update($node){
 */
 function chado_project_load($node) {
 
-	//selecting the coresponding table information
-	$result = db_fetch_object(db_query('SELECT * FROM {chado_project} WHERE nid=%d AND vid=%d',$node->nid, $node->vid));
-	
-	//assigning the project-Id to a variable
-	$values = array(
-	  'project_id' => $result->project_id,
+  //selecting the coresponding table information
+  $result = db_fetch_object(db_query('SELECT * FROM {chado_project} WHERE nid=%d AND vid=%d', $node->nid, $node->vid));
+
+  //assigning the project-Id to a variable
+  $values = array(
+    'project_id' => $result->project_id,
   );
-	
-	//the current project set to the 'project' with the $values(project-Id)
-  $node->project = tripal_core_generate_chado_var('project',$values);
-  
+
+  //the current project set to the 'project' with the $values(project-Id)
+  $node->project = tripal_core_generate_chado_var('project', $values);
+
   return $node;
 
 }

+ 24 - 24
tripal_project/views/chado_project.views.inc

@@ -1,5 +1,5 @@
 <?php
- 
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -7,31 +7,31 @@
  *  with this module in:
  *  @see tripal_project.views.inc --in tripal_project_views_data()
  *
- *  Note: All chado tables are joined to their drupal nodes through the chado_project linking table. 
+ *  Note: All chado tables are joined to their drupal nodes through the chado_project linking table.
  *        This file simply defines this linking table and joins the three tables together.
  *        No modification of project.views.inc is needed.
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
- 
+
 /**
- * Purpose: this function returns the portion of the data array 
- *   which describes the chado_project drupal table, it's fields and any joins between it 
+ * Purpose: this function returns the portion of the data array
+ *   which describes the chado_project drupal table, it's fields and any joins between it
  *   and other tables
  * @see tripal_project_views_data() --in tripal_project.views.inc
  *
  * The main need for description of this table to views is to join chado data with drupal nodes
  *
  */
-function retrieve_chado_project_views_data () {
-	global $db_url;
+function retrieve_chado_project_views_data() {
+  global $db_url;
   $data = array();
-  
+
   // 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)){
+  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;
   }
@@ -40,28 +40,28 @@ function retrieve_chado_project_views_data () {
   $data['chado_project']['table'] = array(
     'field' => 'nid',
   );
-  
+
   //Relationship Definitions---------------------------------
   // Note: No joins need to be made from $data['project']['table']
-  
+
   // Join the chado_project table to project
   $data['chado_project']['table']['join']['project'] = array(
-  	'left_field' => 'project_id',
-  	'field' => 'project_id',
+    'left_field' => 'project_id',
+    'field' => 'project_id',
   );
-  
+
   // Join the node table to chado_project
   $data['node']['table']['join']['chado_project'] = array(
-  	'left_field' => 'nid',
-  	'field' => 'nid',
+    'left_field' => 'nid',
+    'field' => 'nid',
   );
-  
+
   // Join the node table to project
   $data['node']['table']['join']['project'] = array(
-  	'left_table' => 'chado_project',
-  	'left_field' => 'nid',
-  	'field' => 'nid',
-  );  
+    'left_table' => 'chado_project',
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
 
   // Add relationship between chado_project and project
   $data['chado_project']['project_nid'] = array(
@@ -94,5 +94,5 @@ function retrieve_chado_project_views_data () {
       'base field' => 'nid'
     ),
   );
-	return $data;
-}
+  return $data;
+}

+ 30 - 29
tripal_project/views/project.views.inc

@@ -1,5 +1,5 @@
 <?php
- 
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -7,12 +7,12 @@
  *  with this module in:
  *  @see tripal_project.views.inc --in tripal_project_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
 /*************************************************************************
- * Purpose: this function returns the portion of the data array 
+ * Purpose: this function returns the portion of the data array
  *   which describes the project table, it's fields and any joins between it and other tables
  * @see tripal_project_views_data() --in tripal_project.views.inc
  *
@@ -28,23 +28,23 @@
   // 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)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
     $database = 'chado';
   }
-   
+
   //Basic table definition-----------------------------------
   $data['project']['table']['group'] = t('Chado Project');
-  
+
   $data['project']['table']['base'] = array(
     'field' => 'project_id',
     'title' => t('Chado Project'),
     'help' => t('Another way of grouping chado content together.'),
   );
-  if($database){
+  if ($database) {
      $data['project']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: YYY => project
   // Notice that this relationship tells the primary table to show it's fields to the
@@ -54,18 +54,18 @@
   $data['project']['table']['join']['YYY'] = array(
     'left_field' => 'foreign key in YYY table',
     'field' => 'primary key in project table',
-  ); 
+  );
   */
-  
+
   //Join: project => XY => YYY
   // This relationship should be described in both directions
-  // in the appropriate files (ie: for feature => library 
+  // in the appropriate files (ie: for feature => library
   // describe in both feature.views.inc and library.views.inc)
   /**
   $data['project']['table']['join']['XY'] = array(
     'left_field' => 'matching project key in the XY table',
     'field' => 'primary key in project table',
-  );  
+  );
   $data['project']['table']['join']['YYY'] = array(
     'left_table' => 'XY',
     'left_field' => 'matching project key in the XY table',
@@ -76,9 +76,9 @@
     'field' => 'matching YYY key in the XY table',
   );
   */
-   
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: project_id (primary key)
   $data['project']['project_id'] = array(
     'title' => t('Project Primary Key'),
@@ -98,9 +98,10 @@
   // Calculated Field: Node ID
   //  use custom field handler to query drupal for the node ID
   //  this is only needed if chado is in a separate database from drupal
-	if ($database){
+  if ($database) {
 
-  } else {
+  }
+  else {
     // Add relationship between chado_project and project
     $data['project']['project_nid'] = array(
       'group' => 'project',
@@ -118,7 +119,7 @@
     );
 
   }
-  //Field: name (varchar -255)   
+  //Field: name (varchar -255)
   $data['project']['name'] = array(
     'title' => t('Name'),
     'help' => t('The name of the project.'),
@@ -136,12 +137,12 @@
       'handler' => 'views_handler_argument_string',
     ),
   );
-  // if joined to the node table add a "Link to Node" option for the field  
+  // if joined to the node table add a "Link to Node" option for the field
   if (!$database) {
     $data['project']['name']['field']['handler'] = 'views_handler_field_node_optional';
   }
-  
-  //Field: description (varchar -255)   
+
+  //Field: description (varchar -255)
   $data['project']['description'] = array(
     'title' => t('Description'),
     'help' => t('A short description of the project'),
@@ -159,12 +160,12 @@
       'handler' => 'views_handler_argument_string',
     ),
   );
-  
+
   /*.......................................................
    * Beginning of Example Field definitions
    * Remove this section when done
 
-  //Field: plain_text_field (chado datatype)   
+  //Field: plain_text_field (chado datatype)
   $data['project']['plain_text_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -183,7 +184,7 @@
     ),
   );
 
-  //Field: numeric_field (chado datatype)   
+  //Field: numeric_field (chado datatype)
   $data['project']['numeric_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -199,7 +200,7 @@
     ),
   );
 
-  //Field: boolean_field (chado datatype)   
+  //Field: boolean_field (chado datatype)
   $data['project']['boolean_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -215,7 +216,7 @@
     ),
   );
 
-  //Field: unix_timestamp (chado datatype)   
+  //Field: unix_timestamp (chado datatype)
   $data['project']['unix_timestamp'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -231,7 +232,7 @@
     ),
   );
 
-  //Field: human_readable_date (chado datatype)   
+  //Field: human_readable_date (chado datatype)
   $data['project']['human_readable_date'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -243,9 +244,9 @@
       'handler' => 'views_handler_sort_date',
     ),
   );
-   
+
     * End of Example Field definitions
     */
-    
+
   return $data;
-}
+}

+ 28 - 28
tripal_project/views/template.node_join.views.inc

@@ -5,18 +5,18 @@
  *
  *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
  *    (ie: If you want to join features to their drupal nodes then XXX=feature)
- * 
- *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *
+ *  NOTE: Creating the table definition file is not enough. You also need to call the
  *        retrieve_XXX_views_data() function from ../tripal_project.views.inc:tripal_project_views_data()
  *        by adding the following line:
  *           $data = array_merge($data, retrieve_XXX_views_data());
- *        to the function and including the file directly above the function (blow the function 
+ *        to the function and including the file directly above the function (blow the function
  *        header by adding:
  *           require_once('views/XXX.views.inc');
  *
  *  REMOVE THIS COMMENT IN THE COPY!
- */ 
- 
+ */
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -24,31 +24,31 @@
  *  with this module in:
  *  @see tripal_project.views.inc --in tripal_project_views_data()
  *
- *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table.
  *        This file simply defines this linking table and joins the three tables together.
  *        No modification of XXX.views.inc is needed.
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
- 
+
 /**
- * Purpose: this function returns the portion of the data array 
- *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ * Purpose: this function returns the portion of the data array
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it
  *   and other tables
  * @see tripal_project_views_data() --in tripal_project.views.inc
  *
  * The main need for description of this table to views is to join chado data with drupal nodes
  *
  */
-function retrieve_chado_XXX_views_data () {
-	global $db_url;
+function retrieve_chado_XXX_views_data() {
+  global $db_url;
   $data = array();
-  
+
   // 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)){
+  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;
   }
@@ -57,28 +57,28 @@ function retrieve_chado_XXX_views_data () {
   $data['chado_XXX']['table'] = array(
     'field' => 'nid',
   );
-  
+
   //Relationship Definitions---------------------------------
   // Note: No joins need to be made from $data['XXX']['table']
-  
+
   // Join the chado_XXX table to XXX
   $data['chado_XXX']['table']['join']['XXX'] = array(
-  	'left_field' => 'XXX_id',
-  	'field' => 'XXX_id',
+    'left_field' => 'XXX_id',
+    'field' => 'XXX_id',
   );
-  
+
   // Join the node table to chado_XXX
   $data['node']['table']['join']['chado_XXX'] = array(
-  	'left_field' => 'nid',
-  	'field' => 'nid',
+    'left_field' => 'nid',
+    'field' => 'nid',
   );
-  
+
   // Join the node table to XXX
   $data['node']['table']['join']['XXX'] = array(
-  	'left_table' => 'chado_XXX',
-  	'left_field' => 'nid',
-  	'field' => 'nid',
-  );  
+    'left_table' => 'chado_XXX',
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
 
-	return $data;
-}
+  return $data;
+}

+ 27 - 27
tripal_project/views/template.table_defn.views.inc

@@ -5,7 +5,7 @@
  *
  *   - Every instance of XXX should be replaced with the name of your table
  *   - If this is a base table (you want a view where every row is a row from this table)
- *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base']
  *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
  *   - Relationships between this table and others: YYY is the table you are trying to join to this
  *     one. You want to join a table to this one if this table contains a foreign key to the other
@@ -15,18 +15,18 @@
  *   - Create a field definition for each field in this table using the example fields already
  *     listed. Match the type of the database field to the field definition listed below.
  *     (ie: for a text/varchar field from the database use plain_text_field below)
- * 
- *  NOTE: Creating the table definition file is not enough. You also need to call the 
+ *
+ *  NOTE: Creating the table definition file is not enough. You also need to call the
  *        retrieve_XXX_views_data() function from ../tripal_project.views.inc:tripal_project_views_data()
  *        by adding the following line:
  *           $data = array_merge($data, retrieve_XXX_views_data());
- *        to the function and including the file directly above the function (blow the function 
+ *        to the function and including the file directly above the function (blow the function
  *        header by adding:
  *           require_once('views/XXX.views.inc');
  *
  *  REMOVE THIS COMMENT IN THE COPY!
- */ 
- 
+ */
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -34,12 +34,12 @@
  *  with this module in:
  *  @see tripal_project.views.inc --in tripal_project_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
 /*************************************************************************
- * Purpose: this function returns the portion of the data array 
+ * Purpose: this function returns the portion of the data array
  *   which describes the XXX table, it's fields and any joins between it and other tables
  * @see tripal_project_views_data() --in tripal_project.views.inc
  *
@@ -55,23 +55,23 @@
   // 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)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
     $database = 'chado';
   }
-   
+
   //Basic table definition-----------------------------------
   $data['XXX']['table']['group'] = t('Chado XXX');
-  
+
   $data['XXX']['table'] = array(
     'field' => 'primary_id',
     'title' => t('Chado XXX'),
     'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
   );
-  if($database){
+  if ($database) {
      $data['XXX']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: YYY => XXX
   // Notice that this relationship tells the primary table to show it's fields to the
@@ -80,16 +80,16 @@
   $data['XXX']['table']['join']['YYY'] = array(
     'left_field' => 'foreign key in YYY table',
     'field' => 'primary key in XXX table',
-  );  
-  
+  );
+
   //Join: XXX => XY => YYY
   // This relationship should be described in both directions
-  // in the appropriate files (ie: for feature => library 
+  // in the appropriate files (ie: for feature => library
   // describe in both feature.views.inc and library.views.inc)
   $data['XXX']['table']['join']['XY'] = array(
     'left_field' => 'matching XXX key in the XY table',
     'field' => 'primary key in XXX table',
-  );  
+  );
   $data['XXX']['table']['join']['YYY'] = array(
     'left_table' => 'XY',
     'left_field' => 'matching XXX key in the XY table',
@@ -99,9 +99,9 @@
     'left_field' => 'primary key in YYY table',
     'field' => 'matching YYY key in the XY table',
   );
-   
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: XXX_id (primary key)
   $data['XXX']['field_name'] = array(
     'title' => t('XXX Primary Key'),
@@ -123,7 +123,7 @@
    * Remove this section when done
    */
 
-  //Field: plain_text_field (chado datatype)   
+  //Field: plain_text_field (chado datatype)
   $data['XXX']['plain_text_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -142,7 +142,7 @@
     ),
   );
 
-  //Field: numeric_field (chado datatype)   
+  //Field: numeric_field (chado datatype)
   $data['XXX']['numeric_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -158,7 +158,7 @@
     ),
   );
 
-  //Field: boolean_field (chado datatype)   
+  //Field: boolean_field (chado datatype)
   $data['XXX']['boolean_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -174,7 +174,7 @@
     ),
   );
 
-  //Field: unix_timestamp (chado datatype)   
+  //Field: unix_timestamp (chado datatype)
   $data['XXX']['unix_timestamp'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -190,7 +190,7 @@
     ),
   );
 
-  //Field: human_readable_date (chado datatype)   
+  //Field: human_readable_date (chado datatype)
   $data['XXX']['human_readable_date'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -202,10 +202,10 @@
       'handler' => 'views_handler_sort_date',
     ),
   );
-   
+
    /*
     * End of Example Field definitions
     */
-    
+
   return $data;
-}
+}