Browse Source

Merge branch '6.x-1617096-unify_coding_style' into 6.x-0.4-dev

laceysanderson 13 years ago
parent
commit
838979fdc0
83 changed files with 4293 additions and 4200 deletions
  1. 285 284
      tripal_analysis/tripal_analysis.admin.inc
  2. 18 18
      tripal_analysis/tripal_analysis.api.inc
  3. 54 55
      tripal_analysis/tripal_analysis.install
  4. 343 332
      tripal_analysis/tripal_analysis.module
  5. 9 9
      tripal_analysis/tripal_analysis.views.inc
  6. 71 69
      tripal_analysis/tripal_analysis_privacy.inc
  7. 69 67
      tripal_analysis/views/analysis.views.inc
  8. 24 23
      tripal_analysis/views/chado_analysis.views.inc
  9. 13 14
      tripal_analysis/views/handlers/views_handler_field_computed_analysis_nid.inc
  10. 6 5
      tripal_analysis/views/misc_tables.views.inc
  11. 29 29
      tripal_analysis/views/template.node_join.views.inc
  12. 28 28
      tripal_analysis/views/template.table_defn.views.inc
  13. 28 28
      tripal_contact/views/template.node_join.views.inc
  14. 27 27
      tripal_contact/views/template.table_defn.views.inc
  15. 66 63
      tripal_feature/tripal_feature-db_references.inc
  16. 41 42
      tripal_feature/tripal_feature-delete.inc
  17. 68 64
      tripal_feature/tripal_feature-properties.inc
  18. 147 126
      tripal_feature/tripal_feature-relationships.inc
  19. 34 25
      tripal_feature/tripal_feature-secondary_tables.inc
  20. 184 180
      tripal_feature/tripal_feature.admin.inc
  21. 96 105
      tripal_feature/tripal_feature.api.inc
  22. 29 29
      tripal_feature/tripal_feature.install
  23. 222 219
      tripal_feature/tripal_feature.module
  24. 11 11
      tripal_feature/tripal_feature.views.inc
  25. 23 22
      tripal_feature/views/chado_feature.views.inc
  26. 38 36
      tripal_feature/views/feature.views.inc
  27. 12 12
      tripal_feature/views/handlers/views_handler_field_computed_feature_nid.inc
  28. 8 8
      tripal_feature/views/handlers/views_handler_field_residues.inc
  29. 7 6
      tripal_feature/views/misc_tables.views.inc
  30. 28 28
      tripal_feature/views/template.node_join.views.inc
  31. 27 27
      tripal_feature/views/template.table_defn.views.inc
  32. 18 17
      tripal_genetic/tripal_genetic.api.inc
  33. 10 10
      tripal_genetic/tripal_genetic.module
  34. 23 23
      tripal_genetic/views/genotype.views.inc
  35. 28 28
      tripal_genetic/views/template.node_join.views.inc
  36. 27 27
      tripal_genetic/views/template.table_defn.views.inc
  37. 25 25
      tripal_library/tripal_library.api.inc
  38. 18 18
      tripal_library/tripal_library.install
  39. 209 199
      tripal_library/tripal_library.module
  40. 11 11
      tripal_library/tripal_library.views.inc
  41. 24 23
      tripal_library/views/chado_library.views.inc
  42. 12 12
      tripal_library/views/handlers/views_handler_field_computed_library_nid.inc
  43. 131 129
      tripal_library/views/library.views.inc
  44. 7 6
      tripal_library/views/misc_tables.views.inc
  45. 28 28
      tripal_library/views/template.node_join.views.inc
  46. 27 27
      tripal_library/views/template.table_defn.views.inc
  47. 64 64
      tripal_natural_diversity/tripal_natural_diversity.api.inc
  48. 11 10
      tripal_natural_diversity/tripal_natural_diversity.module
  49. 11 11
      tripal_natural_diversity/tripal_natural_diversity.views.inc
  50. 72 72
      tripal_natural_diversity/views/handlers/views_handler_field_chado_relationship_all.inc
  51. 14 14
      tripal_natural_diversity/views/handlers/views_handler_field_chado_relationship_by_type.inc
  52. 25 25
      tripal_natural_diversity/views/nd_experiment.views.inc
  53. 15 15
      tripal_natural_diversity/views/nd_experimentprop.views.inc
  54. 19 19
      tripal_natural_diversity/views/nd_geolocation.views.inc
  55. 16 16
      tripal_natural_diversity/views/nd_geolocationprop.views.inc
  56. 29 29
      tripal_natural_diversity/views/nd_reagent.views.inc
  57. 15 15
      tripal_natural_diversity/views/nd_reagentprop.views.inc
  58. 28 28
      tripal_natural_diversity/views/template.node_join.views.inc
  59. 27 27
      tripal_natural_diversity/views/template.table_defn.views.inc
  60. 36 30
      tripal_organism/tripal_organism.api.inc
  61. 15 10
      tripal_organism/tripal_organism.install
  62. 230 222
      tripal_organism/tripal_organism.module
  63. 11 11
      tripal_organism/tripal_organism.views.inc
  64. 24 23
      tripal_organism/views/chado_organism.views.inc
  65. 12 12
      tripal_organism/views/handlers/views_handler_field_computed_organism_nid.inc
  66. 26 24
      tripal_organism/views/organism.views.inc
  67. 28 28
      tripal_organism/views/template.node_join.views.inc
  68. 27 27
      tripal_organism/views/template.table_defn.views.inc
  69. 4 4
      tripal_phenotype/tripal_phenotype.module
  70. 28 28
      tripal_phenotype/views/template.node_join.views.inc
  71. 27 27
      tripal_phenotype/views/template.table_defn.views.inc
  72. 34 33
      tripal_project/tripal_project.admin.inc
  73. 33 34
      tripal_project/tripal_project.install
  74. 58 58
      tripal_project/tripal_project.module
  75. 24 24
      tripal_project/views/chado_project.views.inc
  76. 30 29
      tripal_project/views/project.views.inc
  77. 28 28
      tripal_project/views/template.node_join.views.inc
  78. 27 27
      tripal_project/views/template.table_defn.views.inc
  79. 47 48
      tripal_pub/tripal_pub.install
  80. 487 486
      tripal_pub/tripal_pub.module
  81. 28 28
      tripal_pub/views/template.node_join.views.inc
  82. 27 27
      tripal_pub/views/template.table_defn.views.inc
  83. 13 13
      tripal_search/tripal_search.module

+ 285 - 284
tripal_analysis/tripal_analysis.admin.inc

@@ -6,7 +6,7 @@
 /**
  * Purpose: Provide Guidance to new Tripal Admin
  *
- * @return 
+ * @return
  *   HTML Formatted text
  *
  * @ingroup tripal_analysis
@@ -15,9 +15,9 @@ function tripal_analysis_module_description_page() {
 
   $text .= '<h3>Tripal Analysis Administrative Tools Quick Links:</h3>';
   $text .= "<ul>
-             <li><a href=\"".url("admin/tripal/tripal_analysis/configuration") . "\">Analysis Configuration</a></li>
+             <li><a href=\"" . url("admin/tripal/tripal_analysis/configuration") . "\">Analysis Configuration</a></li>
            </ul>";
- 
+
 
   $text .= '<h3>Module Description:</h3>';
   $text .= '<p>The Tripal Analysis module provides a generic analysis content type that is intended to be
@@ -30,66 +30,66 @@ function tripal_analysis_module_description_page() {
   $text .= '<h3>Setup Instructions:</h3>';
   $text .= '<p>After installation of the analysis module or any specialized analysis module.  The following tasks should be performed
             <ol>
-              <li><p><b>Set Permissions</b>: Each analysis module supports the Drupal user permissions interface for 
-               controlling access to the content and functions. These permissions include viewing, 
+              <li><p><b>Set Permissions</b>: Each analysis module supports the Drupal user permissions interface for
+               controlling access to the content and functions. These permissions include viewing,
                creating, editing or administering of
-               analysis content. The default is that only the original site administrator has these 
-               permissions.  You can <a href="'.url('admin/user/roles').'">add roles</a> for classifying users, 
-               <a href="'.url('admin/user/user').'">assign users to roles</a> and
-               <a href="'.url('admin/user/permissions').'">assign permissions</a> for the analysis content to 
-               those roles.  For a simple setup, allow anonymous users access to view organism content and 
+               analysis content. The default is that only the original site administrator has these
+               permissions.  You can <a href="' . url('admin/user/roles') .  '">add roles</a> for classifying users,
+               <a href="' . url('admin/user/user') . '">assign users to roles</a> and
+               <a href="' . url('admin/user/permissions') . '">assign permissions</a> for the analysis content to
+               those roles.  For a simple setup, allow anonymous users access to view organism content and
                allow the site administrator all other permissions.</p></li>
 
 
-               <li><p><b>Create Analysis</b>:  An analysis should be <a href="'.url('node/add').'">created</a> before data is imported into
+               <li><p><b>Create Analysis</b>:  An analysis should be <a href="' . url('node/add') . '">created</a> before data is imported into
                chado.  The generic analysis type should only be used when a more specialized analysis module
-               (e.g. Tripal Analysis Blast module) does not already exists.  All data imported into 
-               Chado should be associated with an analysis.    
+               (e.g. Tripal Analysis Blast module) does not already exists.  All data imported into
+               Chado should be associated with an analysis.
 
                <li><p><b>Sync Analyses</b>:  If Chado has preloaded analyses then you can sync those.  This process is what
-               creates the pages for viewing an analysis on the site.  Analyses can be synced using the 
-               <a href="'.url('admin/tripal/tripal_analysis/configuration').'">Analysis Configuration page</a>. 
+               creates the pages for viewing an analysis on the site.  Analyses can be synced using the
+               <a href="' . url('admin/tripal/tripal_analysis/configuration') . '">Analysis Configuration page</a>.
                However, syncing an analyses will always create a generic analysis content type.  If you would like
                to use a specialized analysis module for visualization of data then do not sync the analysis but recreate it
                using the appropriate specialized analysis content type.</p></li>
- 
+
             </ol>
             </p>';
-  
-  
+
+
   $text .= '<h3>Features of this Module:</h3>';
   $text .= '<p>Aside from providing a generic content type the Tripal Analysis module also provides the following functionality
             <ul>
-            
-              <li><p><b>Basic Analysis Lookup View</b>: This module provides a basic <a href="'.url('analyses').'">analysis search 
+
+              <li><p><b>Basic Analysis Lookup View</b>: This module provides a basic <a href="' . url('analyses') . '">analysis search
               tool</a> for finding or listing analyses in Chado. It does not require indexing for Drupal searching but relies
-              on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a> must be installed. </p></li>              
+              on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a> must be installed. </p></li>
 
             </ul>
             </p>';
 
    $text .= '<h3>Page Customizations</h3>';
-   $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal. 
+   $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
              Below is a description of several methods.  These methods may be used in conjunction with one another to
-             provide fine-grained control. 
+             provide fine-grained control.
              <ul>
 
-             <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a> 
-              allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming.  
-              Tripal comes with pre-set layouts for analysis pages.  However, 
+             <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a>
+              allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming.
+              Tripal comes with pre-set layouts for analysis pages.  However,
               Panels become useful if you prefer a layout that is different from the pre-set layouts.  Chado content
-              is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the 
+              is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the
               Panel\'s GUI.</p></li>
 
-             <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the 
+             <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the
              <a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a> is a powerful way to add non-Chado content
              to any page without need to edit template files or knowing PHP.  You must first download and install CCK.
              With CCK, the site administartor can create a new field to appear on the page.  For example, currently,
-             the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text 
+             the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text
              field to the analysis pages.  This content is not stored in Chado, but will appear on the analysis page.  A field
              added by CCK will also appear in the form when editing a analysis to allow users to manually enter the appropriate
              text.  If the default pre-set layout and themeing for Tripal is used, it is better to create the CCK element,
-             indicate that it is not to be shown (using the CCK interface), then manually add the new content type 
+             indicate that it is not to be shown (using the CCK interface), then manually add the new content type
              where desired by editing the templates (as described below).  If using Panels, the CCK field can be added to the
              location desired using the Panels interface.</p></li>
 
@@ -97,18 +97,18 @@ function tripal_analysis_module_description_page() {
              themeing for Chado content.    The analysis module has a template file for analysis "nodes" (Tripal analysis pages).  This file
              is named "node-chado_analysis.tpl.php", and provides javascript, HTML and PHP code for display of the analysis
              pages.  Specialized analysis modules will have their own template files as well, such as "node-chado_analysis-blast.tpl.php" for the
-             Tripal Analysis Blast module.  You can edit the template file to control which types of information (or which analysis "blocks") are displayed 
-             for analysis. Be sure to 
+             Tripal Analysis Blast module.  You can edit the template file to control which types of information (or which analysis "blocks") are displayed
+             for analysis. Be sure to
              copy these template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
              future Tripal updates may overwrite your customizations. See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
              for instructions on how to access variables and other Chado content within the template file.</p></li>
 
              <li><p><b>Analysis "Block" Templates</b>:  In the "theme_tripal" directory are subdirectories named after each tripal module (e.g. "tripal_feature", "tripal_library", etc.).
              Inside each directory is a set of templates that control distinct types of information for each content type.  For example,
-             there is a "base" template for displaying of data directly from the Chado feature table, and a "references" 
-             template for showing external site references for a feature (data from the feature_dbxref table). 
+             there is a "base" template for displaying of data directly from the Chado feature table, and a "references"
+             template for showing external site references for a feature (data from the feature_dbxref table).
               These templates are used both by Drupal blocks
-             for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template 
+             for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template
              provides (also desribed above).  Analyses block templates can exist in any of these directories.  For example, the Tripal Analysis Unigene
              module uses templates in the tripal_analysis_unigene, tripal_organism, and tripal_feature directories.  Content for a unigene is then
              cusotmizable within each of these contexts.
@@ -120,9 +120,9 @@ function tripal_analysis_module_description_page() {
 
              <li><p><b>Adding Links to the "Resources" Sidebar</b>: If you use the pre-set default Tripal layout for theming, you
              will see a "Resources" sidebar on each page.  The links that appear on the sidebar are automatically generated
-             using Javascript for all of the analysis "Blocks" that appear on the page. If you want to add additional links 
-             (e.g. a dynamic link to GBrowse for the analysis) and you want that link to appear in the 
-             "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the 
+             using Javascript for all of the analysis "Blocks" that appear on the page. If you want to add additional links
+             (e.g. a dynamic link to GBrowse for the analysis) and you want that link to appear in the
+             "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the
              section at the bottom of the template file where the resources section is found.</p></li>
 
              </ul>
@@ -140,66 +140,67 @@ function tripal_analysis_module_description_page() {
  * @ingroup tripal_analysis
  */
 function tripal_analysis_admin() {
-	// Create a new administrative form. We'll add main functions to the form
-	// first (Sync, Reindex, Clean, Taxonify). Thereafter, any sub-module that
-	// has a setting will be added.
-	$form = array();
-
-	// before proceeding check to see if we have any
-	// currently processing jobs. If so, we don't want
-	// to give the opportunity to sync libraries
-	$active_jobs = FALSE;
-	if(tripal_get_module_active_jobs('tripal_organism')){
-		$active_jobs = TRUE;
-	}
-
-	// add the field set for syncing libraries
-	if(!$active_jobs){
-		// add the field set for syncing analyses
-		get_tripal_analysis_admin_form_sync_set($form);
-//		get_tripal_analysis_admin_form_reindex_set($form);
-//		get_tripal_analysis_admin_form_taxonomy_set($form);
-		get_tripal_analysis_admin_form_cleanup_set($form);
-	} else {
-		$form['notice'] = array(
-		   '#type' => 'fieldset',
-		   '#title' => t('Analysis Management Temporarily Unavailable')
-		);
-		$form['notice']['message'] = array(
+  // Create a new administrative form. We'll add main functions to the form
+  // first (Sync, Reindex, Clean, Taxonify). Thereafter, any sub-module that
+  // has a setting will be added.
+  $form = array();
+
+  // before proceeding check to see if we have any
+  // currently processing jobs. If so, we don't want
+  // to give the opportunity to sync libraries
+  $active_jobs = FALSE;
+  if (tripal_get_module_active_jobs('tripal_organism')) {
+    $active_jobs = TRUE;
+  }
+
+  // add the field set for syncing libraries
+  if (!$active_jobs) {
+    // add the field set for syncing analyses
+    get_tripal_analysis_admin_form_sync_set($form);
+//    get_tripal_analysis_admin_form_reindex_set($form);
+//    get_tripal_analysis_admin_form_taxonomy_set($form);
+    get_tripal_analysis_admin_form_cleanup_set($form);
+  }
+  else {
+    $form['notice'] = array(
+       '#type' => 'fieldset',
+       '#title' => t('Analysis Management Temporarily Unavailable')
+    );
+    $form['notice']['message'] = array(
           '#value' => t('Currently, analysis management jobs are waiting or are running. . Managemment features have been hidden until these jobs complete.  Please check back later once these jobs have finished.  You can view the status of pending jobs in the Tripal jobs page.'),
-		);
-	}
-
-	// Add sub-module settings. Pull all sub-module information from
-	// {tripal_analysis} table
-	$sql = "SELECT modulename FROM {tripal_analysis}";
-	$result = db_query($sql);
-	$counter = 0;  //keep track of the number of sub-modules
-	while ($data = db_fetch_object($result)) {
-
-		// Check if the hook_get_settings() function is already defined.
-		$func = $data->modulename."_get_settings";
-		$functions = get_defined_functions();
-		$settings;
-		foreach($functions['user'] as $function) {
-			if ($function == $func) {
-				$settings = $func();
-			}
-		}
-		
-		// Add sub-module's specific settings to the administrative view
-		if ($settings) {
-			// Define a fieldset for the sub-module
-			$form["field$counter"] = array(
+    );
+  }
+
+  // Add sub-module settings. Pull all sub-module information from
+  // {tripal_analysis} table
+  $sql = "SELECT modulename FROM {tripal_analysis}";
+  $result = db_query($sql);
+  $counter = 0;  //keep track of the number of sub-modules
+  while ($data = db_fetch_object($result)) {
+
+    // Check if the hook_get_settings() function is already defined.
+    $func = $data->modulename . "_get_settings";
+    $functions = get_defined_functions();
+    $settings;
+    foreach ($functions['user'] as $function) {
+      if ($function == $func) {
+        $settings = $func();
+      }
+    }
+
+    // Add sub-module's specific settings to the administrative view
+    if ($settings) {
+      // Define a fieldset for the sub-module
+      $form["field$counter"] = array(
             '#type' => 'fieldset',
             '#title' => "$settings->title",
             '#collapsible' => TRUE
-			);
-			$form["field$counter"]["$settings->title"] = $settings->form;
-		}
-		$counter ++;
-	}
-	return system_settings_form($form);
+      );
+      $form["field$counter"]["$settings->title"] = $settings->form;
+    }
+    $counter ++;
+  }
+  return system_settings_form($form);
 }
 
 /**
@@ -207,32 +208,32 @@ function tripal_analysis_admin() {
  * @ingroup tripal_analysis
  */
 function get_tripal_analysis_admin_form_taxonomy_set(&$form) {
-	$form['taxonify'] = array(
+  $form['taxonify'] = array(
       '#type' => 'fieldset',
       '#title' => t('Assign Drupal Taxonomy to Analysis Features')
-	);
+  );
 
-	// get the list of analyses
-	$sql = "SELECT * FROM {Analysis} ORDER BY name";
-	$previous_db = tripal_db_set_active('chado');  // use chado database
-	$lib_rset = db_query($sql);
-	tripal_db_set_active($previous_db);  // now use drupal database
+  // get the list of analyses
+  $sql = "SELECT * FROM {Analysis} ORDER BY name";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $lib_rset = db_query($sql);
+  tripal_db_set_active($previous_db);  // now use drupal database
 
-	// iterate through all of the libraries
-	$lib_boxes = array();
-	while($analysis = db_fetch_object($lib_rset)){
-		$lib_boxes[$analysis->analysis_id] = "$analysis->name";
-	}
+  // iterate through all of the libraries
+  $lib_boxes = array();
+  while ($analysis = db_fetch_object($lib_rset)) {
+    $lib_boxes[$analysis->analysis_id] = "$analysis->name";
+  }
 
-	$form['taxonify']['description'] = array(
+  $form['taxonify']['description'] = array(
        '#type' => 'item',
        '#value' => t("Drupal allows for assignment of \"taxonomy\" or catagorical terms to " .
           "nodes. These terms allow for advanced filtering during searching. This option allows ".
           "for setting taxonomy only for features that belong to the selected analyses below.  All other features will be unaffected.  To set taxonomy for all features in the site see the Feature Administration page."),
-		 '#weight' => 1,
-	);
+     '#weight' => 1,
+  );
 
-	$form['taxonify']['tx-analyses'] = array (
+  $form['taxonify']['tx-analyses'] = array(
      '#title'       => t('Analyses'),
      '#type'        => t('checkboxes'),
      '#description' => t("Check the analyses whose features you want to reset taxonomy.  Note: this list contains all analyses, even those that may not be synced."),
@@ -241,42 +242,42 @@ function get_tripal_analysis_admin_form_taxonomy_set(&$form) {
      '#suffix'      => '</div>',
      '#options'     => $lib_boxes,
      '#weight'      => 2
-	);
-	$form['taxonify']['tx-button'] = array(
+  );
+  $form['taxonify']['tx-button'] = array(
       '#type' => 'submit',
       '#value' => t('Set Feature Taxonomy'),
       '#weight'      => 3
-	);
+  );
 }
-/** 
+/**
  *
  * @ingroup tripal_analysis
  */
 function get_tripal_analysis_admin_form_reindex_set(&$form) {
-	// define the fieldsets
-	$form['reindex'] = array(
+  // define the fieldsets
+  $form['reindex'] = array(
       '#type' => 'fieldset',
       '#title' => t('Reindex Analysis Features')
-	);
-
-	// get the list of libraries
-	$sql = "SELECT * FROM {Analysis} ORDER BY name";
-	$previous_db = tripal_db_set_active('chado');  // use chado database
-	$lib_rset = db_query($sql);
-	tripal_db_set_active($previous_db);  // now use drupal database
-
-	// iterate through all of the libraries
-	$lib_boxes = array();
-	while($analysis = db_fetch_object($lib_rset)){
-		$lib_boxes[$analysis->analysis_id] = "$analysis->name";
-	}
-	$form['reindex']['description'] = array(
+  );
+
+  // get the list of libraries
+  $sql = "SELECT * FROM {Analysis} ORDER BY name";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $lib_rset = db_query($sql);
+  tripal_db_set_active($previous_db);  // now use drupal database
+
+  // iterate through all of the libraries
+  $lib_boxes = array();
+  while ($analysis = db_fetch_object($lib_rset)) {
+    $lib_boxes[$analysis->analysis_id] = "$analysis->name";
+  }
+  $form['reindex']['description'] = array(
        '#type' => 'item',
        '#value' => t("This option allows for reindexing of only those features that belong to the selected analyses below. All other features will be unaffected.  To reindex all features in the site see the Feature Administration page."),
-		 '#weight' => 1,
-	);
+     '#weight' => 1,
+  );
 
-	$form['reindex']['re-analyses'] = array (
+  $form['reindex']['re-analyses'] = array(
      '#title'       => t('Libraries'),
      '#type'        => t('checkboxes'),
      '#description' => t("Check the analyses whoee features you want to reindex. Note: this list contains all analyses, even those that may not be synced."),
@@ -285,23 +286,23 @@ function get_tripal_analysis_admin_form_reindex_set(&$form) {
      '#suffix'      => '</div>',
      '#options'     => $lib_boxes,
      '#weight' => 2,
-	);
-	$form['reindex']['re-button'] = array(
+  );
+  $form['reindex']['re-button'] = array(
       '#type' => 'submit',
       '#value' => t('Reindex Features'),
       '#weight' => 3,
-	);
+  );
 }
-/** 
+/**
  *
  * @ingroup tripal_analysis
  */
 function get_tripal_analysis_admin_form_cleanup_set(&$form) {
-	$form['cleanup'] = array(
+  $form['cleanup'] = array(
       '#type' => 'fieldset',
       '#title' => t('Clean Up')
-	);
-	$form['cleanup']['description'] = array(
+  );
+  $form['cleanup']['description'] = array(
        '#type' => 'item',
        '#value' => t("With Drupal and chado residing in different databases ".
           "it is possible that nodes in Drupal and analyses in Chado become ".
@@ -309,62 +310,62 @@ function get_tripal_analysis_admin_form_cleanup_set(&$form) {
           "deleted but the corresponding chado analysis is not and/or vice ".
           "versa. Click the button below to resolve these discrepancies."),
        '#weight' => 1,
-	);
-	$form['cleanup']['button'] = array(
+  );
+  $form['cleanup']['button'] = array(
       '#type' => 'submit',
       '#value' => t('Clean up orphaned analyses'),
       '#weight' => 2,
-	);
+  );
 }
-/** 
+/**
  *
  * @ingroup tripal_analysis
  */
-function get_tripal_analysis_admin_form_sync_set (&$form) {
-	// define the fieldsets
-	$form['sync'] = array(
+function get_tripal_analysis_admin_form_sync_set(&$form) {
+  // define the fieldsets
+  $form['sync'] = array(
       '#type' => 'fieldset',
       '#title' => t('Sync Analyses')
-	);
-
-	// before proceeding check to see if we have any
-	// currently processing jobs. If so, we don't want
-	// to give the opportunity to sync analyses
-	$active_jobs = FALSE;
-	if(tripal_get_module_active_jobs('tripal_analysis')){
-		$active_jobs = TRUE;
-	}
-
-	if(!$active_jobs){
-			
-		// get the list of analyses
-		$sql = "SELECT * FROM {analysis} ORDER BY name";
-		$previous_db = tripal_db_set_active('chado');  // use chado database
-		$ana_rset = db_query($sql);
-		tripal_db_set_active($previous_db);  // now use drupal database
-			
-		// if we've added any analyses to the list that can be synced
-		// then we want to build the form components to allow the user
-		// to select one or all of them.  Otherwise, just present
-		// a message stating that all analyses are currently synced.
-		$ana_boxes = array();
-		$added = 0;
-		while($analysis = db_fetch_object($ana_rset)){
-			// check to see if the analysis is already present as a node in drupal.
-			// if so, then skip it.
-			$sql = "SELECT * FROM {chado_analysis} WHERE analysis_id = %d";
-			if(!db_fetch_object(db_query($sql,$analysis->analysis_id))){
-				$ana_boxes[$analysis->analysis_id] = "$analysis->name";
-				$added++;
-			}
-		}
-
-		// if we have analyses we need to add to the checkbox then
-		// build that form element
-		if($added > 0){
-			$ana_boxes['all'] = "All analyses";
-
-			$form['sync']['analyses'] = array (
+  );
+
+  // before proceeding check to see if we have any
+  // currently processing jobs. If so, we don't want
+  // to give the opportunity to sync analyses
+  $active_jobs = FALSE;
+  if (tripal_get_module_active_jobs('tripal_analysis')) {
+    $active_jobs = TRUE;
+  }
+
+  if (!$active_jobs) {
+
+    // get the list of analyses
+    $sql = "SELECT * FROM {analysis} ORDER BY name";
+    $previous_db = tripal_db_set_active('chado');  // use chado database
+    $ana_rset = db_query($sql);
+    tripal_db_set_active($previous_db);  // now use drupal database
+
+    // if we've added any analyses to the list that can be synced
+    // then we want to build the form components to allow the user
+    // to select one or all of them.  Otherwise, just present
+    // a message stating that all analyses are currently synced.
+    $ana_boxes = array();
+    $added = 0;
+    while ($analysis = db_fetch_object($ana_rset)) {
+      // check to see if the analysis is already present as a node in drupal.
+      // if so, then skip it.
+      $sql = "SELECT * FROM {chado_analysis} WHERE analysis_id = %d";
+      if (!db_fetch_object(db_query($sql, $analysis->analysis_id))) {
+        $ana_boxes[$analysis->analysis_id] = "$analysis->name";
+        $added++;
+      }
+    }
+
+    // if we have analyses we need to add to the checkbox then
+    // build that form element
+    if ($added > 0) {
+      $ana_boxes['all'] = "All analyses";
+
+      $form['sync']['analyses'] = array(
            '#title'       => t('Available analyses'),
            '#type'        => t('checkboxes'),
            '#description' => t("Check the analyses you want to sync.  Drupal ".
@@ -374,112 +375,112 @@ function get_tripal_analysis_admin_form_sync_set (&$form) {
            '#prefix'      => '<div id="ana_boxes">',
            '#suffix'      => '</div>',
            '#options'     => $ana_boxes,
-			);
-			$form['sync']['button'] = array(
+      );
+      $form['sync']['button'] = array(
             '#type' => 'submit',
             '#value' => t('Submit Sync Job')
-			);
-		}
-		// we don't have any analyses to select from
-		else {
-			$form['sync']['value'] = array(
+      );
+    }
+    // we don't have any analyses to select from
+    else {
+      $form['sync']['value'] = array(
             '#value' => t('All analyses in Chado are currently synced with Drupal.')
-			);
-		}
-	}
-	// we don't want to present a form since we have an active job running
-	else {
-		$form['sync']['value'] = array(
+      );
+    }
+  }
+  // we don't want to present a form since we have an active job running
+  else {
+    $form['sync']['value'] = array(
           '#value' => t('Currently, jobs exist related to chado analyses. Please check back later for analyses that can by synced once these jobs have finished.  You can view the status of pending jobs in the Tripal jobs page.')
-		);
-	}
+    );
+  }
 }
 /**
  *
  * @ingroup tripal_analysis
  */
 function tripal_analysis_admin_validate($form, &$form_state) {
-	global $user;  // we need access to the user info
-	$job_args = array();
-
-	if ($form_state['values']['op'] == t('Submit Sync Job')) {
-
-		// check to see if the user wants to sync chado and drupal.  If
-		// so then we need to register a job to do so with tripal
-		$analyses = $form_state['values']['analyses'];
-		$do_all = FALSE;
-		$to_sync = array();
-
-		foreach ($analyses as $analysis_id){
-			if(preg_match("/^all$/i",$analysis_id)){
-				$do_all = TRUE;
-			}
-			if($analysis_id and preg_match("/^\d+$/i",$analysis_id)){
-				// get the list of analyses
-				$sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
-				$previous_db = tripal_db_set_active('chado');  // use chado database
-				$analysis = db_fetch_object(db_query($sql,$analysis_id));
-				tripal_db_set_active($previous_db);  // now use drupal database
-				$to_sync[$analysis_id] = $analysis->name;
-			}
-		}
-
-		// submit the job the tripal job manager
-		if($do_all){
-			tripal_add_job('Sync all analyses','tripal_analysis','tripal_analysis_sync_analyses',$job_args,$user->uid);
-		}
-		else{
-			foreach($to_sync as $analysis_id => $name){
-				$job_args[0] = $analysis_id;
-				tripal_add_job("Sync analysis: $name",'tripal_analysis','tripal_analysis_sync_analyses',$job_args,$user->uid);
-			}
-		}
-	}
-	// -------------------------------------
-	// Submit the Reindex Job if selected
-	if ($form_state['values']['op'] == t('Reindex Features')) {
-		global $user;  // we need access to the user info
-		$job_args = array();
-		$analyses = $form_state['values']['re-analyses'];
-		foreach ($analyses as $analysis_id){
-			if($analysis_id and preg_match("/^\d+$/i",$analysis_id)){
-				// get the analysis info
-				$sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
-				$previous_db = tripal_db_set_active('chado');  // use chado database
-				$analysis = db_fetch_object(db_query($sql,$analysis_id));
-				tripal_db_set_active($previous_db);  // now use drupal database
-				$job_args[0] = $analysis_id;
-				tripal_add_job("Reindex features for analysis: $analysis->name",'tripal_analysis',
-             'tripal_analysis_reindex_features',$job_args,$user->uid);
-			}
-		}
-	}
-
-	// -------------------------------------
-	// Submit the Taxonomy Job if selected
-	if ($form_state['values']['op'] == t('Set Feature Taxonomy')) {
-		global $user;  // we need access to the user info
-		$job_args = array();
-		$analyses = $form_state['values']['tx-analyses'];
-		foreach ($analyses as $analysis_id){
-			if($analysis_id and preg_match("/^\d+$/i",$analysis_id)){
-				// get the analysis info
-				$sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
-				$previous_db = tripal_db_set_active('chado');  // use chado database
-				$analysis = db_fetch_object(db_query($sql,$analysis_id));
-				tripal_db_set_active($previous_db);  // now use drupal database
-				$job_args[0] = $analysis_id;
-				tripal_add_job("Set taxonomy for features in analysis: $analysis->name",'tripal_analysis',
-             'tripal_analysis_taxonify_features',$job_args,$user->uid);
-			}
-		}
-	}
-
-	// -------------------------------------
-	// Submit the Cleanup Job if selected
-	if ($form_state['values']['op'] == t('Clean up orphaned analyses')) {
-		tripal_add_job('Cleanup orphaned analyses','tripal_analysis',
-         'tripal_analyses_cleanup',$job_args,$user->uid);
-	}
+  global $user;  // we need access to the user info
+  $job_args = array();
+
+  if ($form_state['values']['op'] == t('Submit Sync Job')) {
+
+    // check to see if the user wants to sync chado and drupal.  If
+    // so then we need to register a job to do so with tripal
+    $analyses = $form_state['values']['analyses'];
+    $do_all = FALSE;
+    $to_sync = array();
+
+    foreach ($analyses as $analysis_id) {
+      if (preg_match("/^all$/i", $analysis_id)) {
+        $do_all = TRUE;
+      }
+      if ($analysis_id and preg_match("/^\d+$/i", $analysis_id)) {
+        // get the list of analyses
+        $sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
+        $previous_db = tripal_db_set_active('chado');  // use chado database
+        $analysis = db_fetch_object(db_query($sql, $analysis_id));
+        tripal_db_set_active($previous_db);  // now use drupal database
+        $to_sync[$analysis_id] = $analysis->name;
+      }
+    }
+
+    // submit the job the tripal job manager
+    if ($do_all) {
+      tripal_add_job('Sync all analyses', 'tripal_analysis', 'tripal_analysis_sync_analyses', $job_args, $user->uid);
+    }
+    else{
+      foreach ($to_sync as $analysis_id => $name) {
+        $job_args[0] = $analysis_id;
+        tripal_add_job("Sync analysis: $name", 'tripal_analysis', 'tripal_analysis_sync_analyses', $job_args, $user->uid);
+      }
+    }
+  }
+  // -------------------------------------
+  // Submit the Reindex Job if selected
+  if ($form_state['values']['op'] == t('Reindex Features')) {
+    global $user;  // we need access to the user info
+    $job_args = array();
+    $analyses = $form_state['values']['re-analyses'];
+    foreach ($analyses as $analysis_id) {
+      if ($analysis_id and preg_match("/^\d+$/i", $analysis_id)) {
+        // get the analysis info
+        $sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
+        $previous_db = tripal_db_set_active('chado');  // use chado database
+        $analysis = db_fetch_object(db_query($sql, $analysis_id));
+        tripal_db_set_active($previous_db);  // now use drupal database
+        $job_args[0] = $analysis_id;
+        tripal_add_job("Reindex features for analysis: $analysis->name", 'tripal_analysis',
+             'tripal_analysis_reindex_features', $job_args, $user->uid);
+      }
+    }
+  }
+
+  // -------------------------------------
+  // Submit the Taxonomy Job if selected
+  if ($form_state['values']['op'] == t('Set Feature Taxonomy')) {
+    global $user;  // we need access to the user info
+    $job_args = array();
+    $analyses = $form_state['values']['tx-analyses'];
+    foreach ($analyses as $analysis_id) {
+      if ($analysis_id and preg_match("/^\d+$/i", $analysis_id)) {
+        // get the analysis info
+        $sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
+        $previous_db = tripal_db_set_active('chado');  // use chado database
+        $analysis = db_fetch_object(db_query($sql, $analysis_id));
+        tripal_db_set_active($previous_db);  // now use drupal database
+        $job_args[0] = $analysis_id;
+        tripal_add_job("Set taxonomy for features in analysis: $analysis->name", 'tripal_analysis',
+             'tripal_analysis_taxonify_features', $job_args, $user->uid);
+      }
+    }
+  }
+
+  // -------------------------------------
+  // Submit the Cleanup Job if selected
+  if ($form_state['values']['op'] == t('Clean up orphaned analyses')) {
+    tripal_add_job('Cleanup orphaned analyses', 'tripal_analysis',
+         'tripal_analyses_cleanup', $job_args, $user->uid);
+  }
 }
 

+ 18 - 18
tripal_analysis/tripal_analysis.api.inc

@@ -20,9 +20,9 @@
  */
 function tripal_analysis_chado_analysis_schema() {
   $description = array();
-  
+
   // Default table description in tripal_core.schema.api.inc: tripal_core_chado_analysis_schema()
-  
+
   $referring_tables = array(
       'analysisfeature',
       'analysisprop',
@@ -30,7 +30,7 @@ function tripal_analysis_chado_analysis_schema() {
       'quantification'
   );
   $description['referring_tables'] = $referring_tables;
-  
+
   return $description;
 }
 
@@ -60,7 +60,7 @@ function tripal_analysis_chado_analysisfeature_schema() {
           'analysis_id' => 'analysis_id',
         ),
   );
-  
+
   return $description;
 }
 
@@ -137,8 +137,8 @@ function tripal_analysis_chado_analysisprop_schema() {
  *
  * @ingroup tripal_analysis_api
  */
-function tripal_analysis_get_property($analysis_id,$property){
-   return tripal_core_get_property('analysis',$analysis_id,$property,'tripal');
+function tripal_analysis_get_property($analysis_id, $property) {
+   return tripal_core_get_property('analysis', $analysis_id, $property, 'tripal');
 }
 
 /**
@@ -158,8 +158,8 @@ function tripal_analysis_get_property($analysis_id,$property){
  *
  * @ingroup tripal_analysis_api
  */
-function tripal_analysis_insert_property($analysis_id,$property,$value,$update_if_present = 0){
-    return tripal_core_insert_property('analysis',$analysis_id,$property,'tripal',$value,$update_if_present);
+function tripal_analysis_insert_property($analysis_id, $property, $value, $update_if_present = 0) {
+    return tripal_core_insert_property('analysis', $analysis_id, $property, 'tripal', $value, $update_if_present);
 }
 
 /**
@@ -171,7 +171,7 @@ function tripal_analysis_insert_property($analysis_id,$property,$value,$update_i
  *   The cvterm name of the property to update
  * @param $value
  *   The value of the property to update
- * @param $insert_if_missing 
+ * @param $insert_if_missing
  *   A boolean indicated whether to insert the record if it's absent
  *
  * Note: The property will be identified using the unique combination of the $analysis_id and $property
@@ -182,8 +182,8 @@ function tripal_analysis_insert_property($analysis_id,$property,$value,$update_i
  *
  * @ingroup tripal_analysis_api
  */
-function tripal_analysis_update_property($analysis_id,$property,$value,$insert_if_missing = 0){
-   return tripal_core_update_property('analysis',$analysis_id,$property,'tripal',$value, $insert_if_missing);
+function tripal_analysis_update_property($analysis_id, $property, $value, $insert_if_missing = 0) {
+   return tripal_core_update_property('analysis', $analysis_id, $property, 'tripal', $value, $insert_if_missing);
 }
 
 /**
@@ -198,12 +198,12 @@ function tripal_analysis_update_property($analysis_id,$property,$value,$insert_i
  * and then it will be deleted
  *
  * @return
- *   True of success, False otherwise 
+ *   True of success, False otherwise
  *
  * @ingroup tripal_analysis_api
  */
-function tripal_analysis_delete_property($analysis_id,$property){
-   return tripal_core_delete_property('analysis',$analysis_id,$property,'tripal');
+function tripal_analysis_delete_property($analysis_id, $property) {
+   return tripal_core_delete_property('analysis', $analysis_id, $property, 'tripal');
 }
 /**
  * Retreives the node of a sync'ed analysis
@@ -212,15 +212,15 @@ function tripal_analysis_delete_property($analysis_id,$property){
  *   The analysis_id of the property to delete
  *
  * @return
- *   node of analysis on success, null otherwise 
+ *   node of analysis on success, null otherwise
  *
  * @ingroup tripal_analysis_api
  */
-function tripal_analysis_get_node($analysis_id){
-   $sql = "SELECT * 
+function tripal_analysis_get_node($analysis_id) {
+   $sql = "SELECT *
            FROM chado_analysis CA
               INNER JOIN node N on CA.nid = N.nid
            WHERE analysis_id = %d";
-   $node = db_fetch_object(db_query($sql,$analysis_id));
+   $node = db_fetch_object(db_query($sql, $analysis_id));
    return $node;
 }

+ 54 - 55
tripal_analysis/tripal_analysis.install

@@ -1,54 +1,53 @@
 <?php
-//$Id:
 
 /*******************************************************************************
  * Implementation of hook_install().
  */
 function tripal_analysis_install() {
 
-	// create the module's data directory
-	tripal_create_moddir('tripal_analysis');
+  // create the module's data directory
+  tripal_create_moddir('tripal_analysis');
 
-	// Use schema API to create database table.
-	drupal_install_schema('tripal_analysis');
-	
-	// Create analysisfeatureprop table in chado. This cannot be accomplished
-	// by calling drupal_install_schema because it's not in the drupal db. This
-	// table is used to store Blast xml and Interpro html/goterms
-	$previous_db = tripal_db_set_active('chado');
-	if (!db_table_exists('analysisfeatureprop')) {
-	   $sql = "CREATE TABLE {analysisfeatureprop} (".
-	          "  analysisfeatureprop_id SERIAL PRIMARY KEY, ".
-	          "  analysisfeature_id INTEGER NOT NULL REFERENCES analysisfeature(analysisfeature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
-	          "  type_id INTEGER NOT NULL REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
-	          "  value TEXT, ".
-	          "  rank INTEGER NOT NULL, ".
-	          "  CONSTRAINT analysisfeature_id_type_id_rank UNIQUE(analysisfeature_id, type_id, rank)".
-	          ")";
-	   db_query($sql);
-	}
-	tripal_db_set_active($previous_db);
+  // Use schema API to create database table.
+  drupal_install_schema('tripal_analysis');
 
-   tripal_cv_add_cvterm(array('name' => 'analysis_type','def' => 'The type of analysis was performed. This value is automatically set by each Tripal Analysis module and should be equal to the module name (e.g. tripal_analysis_blast, tripal_analysis_go).'),'tripal',0,1,'tripal');
-	tripal_cv_add_cvterm(array('name' => 'analysis_date','def' => 'The date that an analysis was performed.'),'tripal',0,1,'tripal');
-	tripal_cv_add_cvterm(array('name' => 'analysis_short_name','def' => 'A computer legible (no spaces '.
-      'or special characters) abbreviation for the analysis.'),'tripal',0,1,'tripal');
+  // Create analysisfeatureprop table in chado. This cannot be accomplished
+  // by calling drupal_install_schema because it's not in the drupal db. This
+  // table is used to store Blast xml and Interpro html/goterms
+  $previous_db = tripal_db_set_active('chado');
+  if (!db_table_exists('analysisfeatureprop')) {
+     $sql = "CREATE TABLE {analysisfeatureprop} (".
+            "  analysisfeatureprop_id SERIAL PRIMARY KEY, ".
+            "  analysisfeature_id INTEGER NOT NULL REFERENCES analysisfeature(analysisfeature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
+            "  type_id INTEGER NOT NULL REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
+            "  value TEXT, ".
+            "  rank INTEGER NOT NULL, ".
+            "  CONSTRAINT analysisfeature_id_type_id_rank UNIQUE(analysisfeature_id, type_id, rank)".
+            ")";
+     db_query($sql);
+  }
+  tripal_db_set_active($previous_db);
+
+   tripal_cv_add_cvterm(array('name' => 'analysis_type', 'def' => 'The type of analysis was performed. This value is automatically set by each Tripal Analysis module and should be equal to the module name (e.g. tripal_analysis_blast, tripal_analysis_go).'), 'tripal', 0, 1, 'tripal');
+  tripal_cv_add_cvterm(array('name' => 'analysis_date', 'def' => 'The date that an analysis was performed.'), 'tripal', 0, 1, 'tripal');
+  tripal_cv_add_cvterm(array('name' => 'analysis_short_name', 'def' => 'A computer legible (no spaces ' .
+      'or special characters) abbreviation for the analysis.'), 'tripal', 0, 1 , 'tripal');
 }
 
 /*******************************************************************************
  * Implementation of hook_uninstall().
  */
 function tripal_analysis_uninstall() {
-	// Use schema API to delete database table.
-	drupal_uninstall_schema('tripal_analysis');
-	// Remove analysis nodes from drupal.
-	$sql_ana_id = "SELECT nid, vid ".
+  // Use schema API to delete database table.
+  drupal_uninstall_schema('tripal_analysis');
+  // Remove analysis nodes from drupal.
+  $sql_ana_id = "SELECT nid, vid ".
                  "FROM {node} ".
                  "WHERE type like 'chado_analysi%'";
-	$result = db_query($sql_ana_id);
-	while ($ana = db_fetch_object($result)) {
-		node_delete($ana->nid);
-	}
+  $result = db_query($sql_ana_id);
+  while ($ana = db_fetch_object($result)) {
+    node_delete($ana->nid);
+  }
 }
 
 /*******************************************************************************
@@ -58,39 +57,39 @@ function tripal_analysis_uninstall() {
  * tripal_analysis_blast, that are registered with this module.
  */
 function tripal_analysis_schema() {
-	// chado_analysis table
-	$schema['chado_analysis'] = array(
+  // chado_analysis table
+  $schema['chado_analysis'] = array(
       'fields' => array(
          'vid' => array(
             'type' => 'int',
             'unsigned' => TRUE,
             'not null' => TRUE,
             'default' => 0
-	),
+  ),
          'nid' => array(
             'type' => 'int',
             'unsigned' => TRUE,
             'not null' => TRUE,
             'default' => 0
-	),
+  ),
          'analysis_id' => array(
             'type' => 'int',
             'not null' => TRUE,
             'default' => 0
-	)
-	),
+  )
+  ),
       'indexes' => array(
          'analysis_id' => array('analysis_id')
-	),
+  ),
       'unique keys' => array(
-         'nid_vid' => array('nid','vid'),
+         'nid_vid' => array('nid', 'vid'),
          'vid' => array('vid')
-	),
+  ),
       'primary key' => array('nid'),
-	);
+  );
 
-	// tripal_analysis table
-	$schema['tripal_analysis'] = array(
+  // tripal_analysis table
+  $schema['tripal_analysis'] = array(
       'description' => t('Table to store analysis sub-modules'),
       'fields' => array(
          'modulename' => array(
@@ -99,13 +98,13 @@ function tripal_analysis_schema() {
             'not null' => TRUE,
             'description' => t('The module name. Tripal Analysis will use the '.
                                'module name to call module_setting_form()')
-	)
-	),
+  )
+  ),
       'unique keys' => array(
          'modulename' => array('modulename')
-	)
-	);
-	return $schema;
+  )
+  );
+  return $schema;
 }
 
 /*******************************************************************************
@@ -129,12 +128,12 @@ function tripal_analysis_requirements($phase) {
 /*******************************************************************************
  * Provide update script for adding new cvterms
  */
-function tripal_analysis_update_6001(){
+function tripal_analysis_update_6001() {
    // we have some new cvterms to add
-   tripal_cv_add_cvterm(array('name' => 'based_on_analysis','def' => 'The analysis that this analysis was based on. For example, blast/kegg/interpro analyses are based on a unigene analysis. The unigene analysis_id should be stored in analysisprop as the rank using this cvterm. The name of said unigene analysis can be inserted as the value in analysisprop.'),'tripal',0,1,'tripal');
-   tripal_cv_add_cvterm(array('name' => 'additional_files', 'def' => 'Additional files for this analysis. Each file should be separated by a semi-colon and have this format: <file description>, <file path>;'),'tripal',0,1,'tripal');
+   tripal_cv_add_cvterm(array('name' => 'based_on_analysis', 'def' => 'The analysis that this analysis was based on. For example, blast/kegg/interpro analyses are based on a unigene analysis. The unigene analysis_id should be stored in analysisprop as the rank using this cvterm. The name of said unigene analysis can be inserted as the value in analysisprop.'), 'tripal', 0, 1, 'tripal');
+   tripal_cv_add_cvterm(array('name' => 'additional_files', 'def' => 'Additional files for this analysis. Each file should be separated by a semi-colon and have this format: <file description>, <file path>;'), 'tripal', 0, 1, 'tripal');
    $ret = array(
       '#finished' => 1,
-   );   
+   );
    return $ret;
 }

File diff suppressed because it is too large
+ 343 - 332
tripal_analysis/tripal_analysis.module


+ 9 - 9
tripal_analysis/tripal_analysis.views.inc

@@ -6,7 +6,7 @@
  *  chado/tripal analysis tables. Supplementary functions can be found in
  *  ./views/
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
@@ -18,7 +18,7 @@
 
 require('views/analysis.views.inc');
 require('views/chado_analysis.views.inc');
-require('views/misc_tables.views.inc'); 
+require('views/misc_tables.views.inc');
 /**
  * Implements hook_views_data()
  *
@@ -26,7 +26,7 @@ require('views/misc_tables.views.inc');
  *
  * @return: a data array which follows the structure outlined in the
  *   views2 documentation for this hook. Essentially, it's an array of table
- *   definitions keyed by chado/tripal table name. Each table definition 
+ *   definitions keyed by chado/tripal table name. Each table definition
  *   includes basic details about the table, fields in that table and
  *   relationships between that table and others (joins)
  *
@@ -46,7 +46,7 @@ function tripal_analysis_views_data()  {
  * Implements hook_views_handlers()
  *
  * Purpose: Register all custom handlers with views
- *   where a handler describes either "the type of field", 
+ *   where a handler describes either "the type of field",
  *   "how a field should be filtered", "how a field should be sorted"
  *
  * @return
@@ -75,7 +75,7 @@ function tripal_analysis_views_views_handlers() {
  */
 function tripal_analysis_views_data_alter(&$data) {
 
-  if( !(is_array($db_url) and array_key_exists('chado',$db_url)) ){
+  if (!(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
 
     // Add featuer relationship to node
     $data['node']['analysis_chado_nid'] = array(
@@ -93,7 +93,7 @@ function tripal_analysis_views_data_alter(&$data) {
       ),
     );
   }
-  
+
 }
 
 /**
@@ -101,9 +101,9 @@ function tripal_analysis_views_data_alter(&$data) {
  *
  * @ingroup tripal_analysis_views
  */
-function tripal_analysis_views_default_views () {
+function tripal_analysis_views_default_views() {
   $views = array();
-  
+
   // Main default view
   // List all cvterms based on cv
   $view = new view;
@@ -541,6 +541,6 @@ function tripal_analysis_views_default_views () {
     'name' => 'navigation',
   ));
   $views[$view->name] = $view;
-  
+
   return $views;
 }

+ 71 - 69
tripal_analysis/tripal_analysis_privacy.inc

@@ -3,80 +3,82 @@
 /*
  *  Perform permission check by analysis_id only if 'node_privacy_byrole' module is enabled
  */
-function tripal_analysis_check_permission ($analysis_id) {
-	if (module_exists('node_privacy_byrole')) {
-		global $user;
-		$roles = $user->roles;
-		$node_access = 0;
-		foreach ($roles AS $rid => $role) {
-			$p_sql = "SELECT grant_view FROM {node_access} NA INNER JOIN {chado_analysis} CA ON NA.nid = CA.nid WHERE analysis_id=%d AND gid = %d";
-			$access = db_result(db_query($p_sql,$analysis_id, $rid));
-			if ($access == 1) {
-				$node_access = 1;
-				break;
-			}
-		}
-		if ($node_access == 1 || $user->uid == 1) {
-			return TRUE;
-		} else {
-			return FALSE;
-		}
-	
-	// If 'node_privacy_byrole' module is not enabled, return TRUE;
-	} else {
-		return TRUE;
-	}
+function tripal_analysis_check_permission($analysis_id) {
+  if (module_exists('node_privacy_byrole')) {
+    global $user;
+    $roles = $user->roles;
+    $node_access = 0;
+    foreach ($roles AS $rid => $role) {
+      $p_sql = "SELECT grant_view FROM {node_access} NA INNER JOIN {chado_analysis} CA ON NA.nid = CA.nid WHERE analysis_id=%d AND gid = %d";
+      $access = db_result(db_query($p_sql, $analysis_id, $rid));
+      if ($access == 1) {
+        $node_access = 1;
+        break;
+      }
+    }
+    if ($node_access == 1 || $user->uid == 1) {
+      return TRUE;
+    }
+    else {
+      return FALSE;
+    }
+
+  // If 'node_privacy_byrole' module is not enabled, return TRUE;
+  }
+  else {
+    return TRUE;
+  }
 }
 
 /*
  * Set permissions for features associated with an analysis
  */
-function tripal_analysis_set_feature_permission ($analysis_id, $nid) {
-	
-	print "Updating feature permissions:\n";
-	
-	// Get features associated with the analysis
-	$sql = "SELECT feature_id FROM {analysisfeature} WHERE analysis_id = %d";
-	$previous_db = db_set_active('chado');
-	$features = db_query($sql, $analysis_id);
-	db_set_active($previous_db);
-	
-	// Convert feature_id into node_id
-	$feature_nids = array ();
-	$counter = 0;
-	$sql = "SELECT nid FROM {chado_feature} WHERE feature_id = %d";
-	while ($feature = db_fetch_object($features)) {
-		$feature_nids [$counter] = db_result(db_query($sql, $feature->feature_id));
-		$counter ++;
-	}
-	
-	//Convert analysis_id into node_id
-	$ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = $analysis_id"));
-	// Get available roles
-	$roles = array_keys(user_roles());
-	
-	$interval = intval(($counter + 1) * 0.01);
-	$idx_iterations = 1;
-	
-	// Update permission node by node
-	foreach ($feature_nids AS $fnid) {
-		if ($idx_iterations % $interval == 0) {
-			$percentage = (int) ($idx_iterations / ($counter + 1) * 100);
-			tripal_job_set_progress($job_id, $percentage);
-			print $percentage."% ";
-		}
+function tripal_analysis_set_feature_permission($analysis_id, $nid) {
+
+  print "Updating feature permissions:\n";
+
+  // Get features associated with the analysis
+  $sql = "SELECT feature_id FROM {analysisfeature} WHERE analysis_id = %d";
+  $previous_db = db_set_active('chado');
+  $features = db_query($sql, $analysis_id);
+  db_set_active($previous_db);
+
+  // Convert feature_id into node_id
+  $feature_nids = array();
+  $counter = 0;
+  $sql = "SELECT nid FROM {chado_feature} WHERE feature_id = %d";
+  while ($feature = db_fetch_object($features)) {
+    $feature_nids [$counter] = db_result(db_query($sql, $feature->feature_id));
+    $counter ++;
+  }
 
-		db_query("DELETE FROM {node_privacy_byrole} WHERE nid = %d AND realm = 'node_privacy_byrole_role'", $fnid);
-		foreach($roles AS $rid) {
-			// Get permissions of this analysis for this role
-			$rsql = "SELECT * FROM {node_privacy_byrole} WHERE gid = %d AND nid = %d AND realm = 'node_privacy_byrole_role'";
-			$ana_perm = db_fetch_object(db_query($rsql, $rid, $ana_nid));
-			db_query("INSERT INTO {node_privacy_byrole} (nid, gid, realm, grant_view, grant_update, grant_delete)
+  //Convert analysis_id into node_id
+  $ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = $analysis_id"));
+  // Get available roles
+  $roles = array_keys(user_roles());
+
+  $interval = intval(($counter + 1) * 0.01);
+  $idx_iterations = 1;
+
+  // Update permission node by node
+  foreach ($feature_nids AS $fnid) {
+    if ($idx_iterations % $interval == 0) {
+      $percentage = (int) ($idx_iterations / ($counter + 1) * 100);
+      tripal_job_set_progress($job_id, $percentage);
+      print $percentage . "% ";
+    }
+
+    db_query("DELETE FROM {node_privacy_byrole} WHERE nid = %d AND realm = 'node_privacy_byrole_role'", $fnid);
+    foreach ($roles AS $rid) {
+      // Get permissions of this analysis for this role
+      $rsql = "SELECT * FROM {node_privacy_byrole} WHERE gid = %d AND nid = %d AND realm = 'node_privacy_byrole_role'";
+      $ana_perm = db_fetch_object(db_query($rsql, $rid, $ana_nid));
+      db_query("INSERT INTO {node_privacy_byrole} (nid, gid, realm, grant_view, grant_update, grant_delete)
                   VALUES (%d, %d, '%s', %d, %d, %d)", $fnid, $rid, 'node_privacy_byrole_role', $ana_perm->grant_view,
                   $ana_perm->grant_update, $ana_perm->grant_delete);
-		}
-		$node = node_load($fnid);
-		node_save($node);
-		$idx_iterations ++;
-	}	
-}
+    }
+    $node = node_load($fnid);
+    node_save($node);
+    $idx_iterations ++;
+  }
+}

+ 69 - 67
tripal_analysis/views/analysis.views.inc

@@ -1,6 +1,7 @@
 <?php
-	/**
- * Purpose: this function returns the portion of the data array 
+  /**
+ * @file
+ * Purpose: this function returns the portion of the data array
  *   which describes the analysis table, it's fields and any joins between it and other tables
  * @see tripal_analysis_views_data() --in tripal_analysis.views.inc
  *
@@ -29,24 +30,24 @@
  * @ingroup tripal_analysis_views
  */
 function retrieve_analysis_views_data() {
-	global $db_url;
-	$data = array();
+  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)) {
      $database = 'chado';
   }
-	
+
   // Basic table definition
   $data['analysis']['table']['group'] = 'Chado Analysis';
- 	$data['analysis']['table']['base'] = array(
- 		'field' => 'analysis_id',
- 		'title' => t('Chado Analysis'),
- 		'help' => t("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."),
- 	);
-  if($database){
+   $data['analysis']['table']['base'] = array(
+     'field' => 'analysis_id',
+     'title' => t('Chado Analysis'),
+     'help' => t("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."),
+   );
+  if ($database) {
      $data['analysis']['table']['base']['database'] = $database;
   }
 
@@ -63,20 +64,20 @@ function retrieve_analysis_views_data() {
   );
 
   // Analysis properties?
- 	$data['analysisprop']['table'] = array(
+   $data['analysisprop']['table'] = array(
 'group' => 'Chado analysis Properties',
- 		'field' => 'analysisprop_id',
- 		'title' => t('Chado analysis Properties'),
- 		'help' => '  ',
- 	);
- 	
- 	$data['analysisprop']['table']['join']['analysis'] = array(
+     'field' => 'analysisprop_id',
+     'title' => t('Chado analysis Properties'),
+     'help' => '  ',
+   );
+
+   $data['analysisprop']['table']['join']['analysis'] = array(
     'left_field' => 'analysis_id',
     'field' => 'analysis_id',
     'handler' => 'views_handler_join_chado_aggregator'
- 	);
- 	
- 	$data['analysisprop']['value'] = array(
+   );
+
+   $data['analysisprop']['value'] = array(
     'title' => t('Value'),
     'help' => t(' '),
     'field' => array(
@@ -92,9 +93,9 @@ function retrieve_analysis_views_data() {
     'argument' => array(
       'handler' => 'views_handler_argument_string',
     ),
- 	);
- 	
- 	$data['analysisprop']['all'] = array(
+   );
+
+   $data['analysisprop']['all'] = array(
     'title' => t('All'),
     'help' => t('An aggregate field that contains all fields for a row.'),
     'field' => array(
@@ -110,37 +111,38 @@ function retrieve_analysis_views_data() {
     'argument' => array(
       'handler' => 'views_handler_argument_string',
     ),
- 	);
- 	
-	// Table Field Definitions----------------------
-	// Field: analysis_id (primary key)
-	$data['analysis']['analysis_id'] = array(
-	  'title' => 'analysis ID',
-	  'help' => 'The primary key of the analysis table.',
-	  'field' => array(
-	    'handler' => 'views_handler_field_numeric',
-	    'click sortable' => TRUE,
-	  ),
-	  'filter' => array(
-	    'handler' => 'views_handler_filter_numeric',
-	  ),
-	  'sort' => array(
-	    'handler' => 'chado_views_handler_sort',
-	  ),
-	);
-	
+   );
+
+  // Table Field Definitions----------------------
+  // Field: analysis_id (primary key)
+  $data['analysis']['analysis_id'] = array(
+    'title' => 'analysis ID',
+    'help' => 'The primary key of the analysis table.',
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+      'handler' => 'chado_views_handler_sort',
+    ),
+  );
+
   // 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){
-		$data['analysis']['analysis_nid'] = array(
-	  	'title' => 'Node ID',
-	  	'help' => 'The node ID for the current analysis',
-	  	'field' => array(
-	    	'handler' => 'views_handler_field_computed_analysis_nid',
-	  	),
-		);
-  } else {
+  if ($database) {
+    $data['analysis']['analysis_nid'] = array(
+      'title' => 'Node ID',
+      'help' => 'The node ID for the current analysis',
+      'field' => array(
+        'handler' => 'views_handler_field_computed_analysis_nid',
+      ),
+    );
+  }
+  else {
     // Add relationship between chado_analysis and analysis
     $data['analysis']['analysis_nid'] = array(
       'group' => 'Analysis',
@@ -158,9 +160,9 @@ function retrieve_analysis_views_data() {
     );
 
   }
-	
-	// Field: name (varchar 255)
- 	$data['analysis']['name'] = array(
+
+  // Field: name (varchar 255)
+   $data['analysis']['name'] = array(
     'title' => t('Name'),
     'help' => t(''),
     'field' => array(
@@ -177,13 +179,13 @@ function retrieve_analysis_views_data() {
       '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['analysis']['name']['field']['handler'] = 'views_handler_field_node_optional';
   }
 
   // Field: description (text)
- 	$data['analysis']['description'] = array(
+   $data['analysis']['description'] = array(
     'title' => t('Description'),
     'help' => t(''),
     'field' => array(
@@ -202,7 +204,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: program (varchar 255)
- 	$data['analysis']['program'] = array(
+   $data['analysis']['program'] = array(
     'title' => t('Program'),
     'help' => t('Program name, e.g. blastx, blastp, sim4, genscan.'),
     'field' => array(
@@ -221,7 +223,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: program version (varchar 255)
- 	$data['analysis']['programversion'] = array(
+   $data['analysis']['programversion'] = array(
     'title' => t('Program Version'),
     'help' => t('Version description, e.g. TBLASTX 2.0MP-WashU [09-Nov-2000].'),
     'field' => array(
@@ -240,7 +242,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: algorithm (varchar 255)
- 	$data['analysis']['algorithm'] = array(
+   $data['analysis']['algorithm'] = array(
     'title' => t('Algorithm'),
     'help' => t('Algorithm name, e.g. blast.'),
     'field' => array(
@@ -258,7 +260,7 @@ function retrieve_analysis_views_data() {
     ),
   );
 
- 	$data['analysis']['sourcename'] = array(
+   $data['analysis']['sourcename'] = array(
     'title' => t('Source Name'),
     'help' => t('Source name, e.g. cDNA, SwissProt.'),
     'field' => array(
@@ -277,7 +279,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: source version (varchar 255)
- 	$data['analysis']['sourceversion'] = array(
+   $data['analysis']['sourceversion'] = array(
     'title' => t('Source Version'),
     'help' => t('The version of the source.'),
     'field' => array(
@@ -296,7 +298,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: source URI/URL (text)
- 	$data['analysis']['sourceuri'] = array(
+   $data['analysis']['sourceuri'] = array(
     'title' => t('Source URL'),
     'help' => t('This is an optional, permanent URL or URI for the source of the analysis.'),
     'field' => array(
@@ -315,7 +317,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: time executed (datetime)
- 	$data['analysis']['timeexecuted'] = array(
+   $data['analysis']['timeexecuted'] = array(
     'title' => 'Time Executed',
     'help' => 'The date & time when this analysis was executed.',
     'field' => array(
@@ -327,5 +329,5 @@ function retrieve_analysis_views_data() {
     ),
   );
 
- 	return $data;
-}
+   return $data;
+}

+ 24 - 23
tripal_analysis/views/chado_analysis.views.inc

@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Purpose: this function returns the portion of the data array 
+ * @file
+ * Purpose: this function returns the portion of the data array
  *   which describes the chado_analysis drupal table, it's fields and any joins between it and other tables
  * @see tripal_analysis_views_data() --in tripal_analysis.views.inc
  *
@@ -10,14 +11,14 @@
  *
  * @ingroup tripal_analysis_views
  */
-function retrieve_chado_analysis_views_data () {
-	global $db_url;
+function retrieve_chado_analysis_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;
   }
@@ -32,37 +33,37 @@ function retrieve_chado_analysis_views_data () {
     'title' => t('Analysis Node ID'),
     'help' => t('The node ID for this analysis'),
     'field' => array(
-     	'handler' => 'views_handler_field_numeric',
- 		  'click sortable' => TRUE,
+       'handler' => 'views_handler_field_numeric',
+       'click sortable' => TRUE,
     ),
     'filter' => array(
-     	'handler' => 'views_handler_filter_numeric',
+       'handler' => 'views_handler_filter_numeric',
     ),
     'sort' => array(
-     	'handler' => 'views_handler_sort',
+       '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',
+    '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',
+    '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',
-  );  
+    'left_table' => 'chado_analysis',
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
 
   // Add relationship between chado_analysis and analysis
   $data['chado_analysis']['analysis_nid'] = array(
@@ -95,6 +96,6 @@ function retrieve_chado_analysis_views_data () {
       'base field' => 'nid'
     ),
   );
-  
-	return $data;
+
+  return $data;
 }

+ 13 - 14
tripal_analysis/views/handlers/views_handler_field_computed_analysis_nid.inc

@@ -6,18 +6,17 @@
  * @ingroup tripal_analysis
  */
 class views_handler_field_computed_analysis_nid extends views_handler_field_numeric {
-	function construct() {
-		parent::construct();
-		drupal_set_message('Computed Analysis NID Handler loaded');
-		$this->additional_fields['analysis_id'] = array('table' => 'analysis', 'field' => 'analysis_id');
-	}
+  function construct() {
+    parent::construct();
+    drupal_set_message('Computed Analysis NID Handler loaded');
+    $this->additional_fields['analysis_id'] = array('table' => 'analysis', 'field' => 'analysis_id');
+  }
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
 
-	function query() { 
-		$this->ensure_my_table();
-		$this->add_additional_fields(); 
-	}
-
-	function render($values) { 
-		return $values->analysis_nid;
-	}
-} 
+  function render($values) {
+    return $values->analysis_nid;
+  }
+}

+ 6 - 5
tripal_analysis/views/misc_tables.views.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Purpose: Allows the analysis module to add fields to other module views
  *
  *   For example, a field counting the number of analysis' associted with a given feature would be
@@ -13,14 +14,14 @@
           'handler' => 'views_handler_field_chado_count',
           'table_to_query' => 'analysis_feature',
         ),
-      ); 
+      );
  *   @endcode
  *
  * @ingroup tripal_analysis_views
  */
 function retrieve_analysis_misc_tables_views_data() {
   $data = array();
- 
+
   // Table: Feature---------------------------------------------------------------------------------
   // Calculated Field: Number of analysis' (Count -Int)
   // Provides the number of analysis' for a given feature
@@ -31,7 +32,7 @@ function retrieve_analysis_misc_tables_views_data() {
       'handler' => 'views_handler_field_chado_count',
       'table_to_query' => 'analysisfeature',
     ),
-  );  
-  
+  );
+
   return $data;
-}
+}

+ 29 - 29
tripal_analysis/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 
- *        retrieve_XXX_views_data() function from ../tripal_analysis.views.inc in 
+ *
+ *  NOTE: Creating the table definition file is not enough. You also need to call the
+ *        retrieve_XXX_views_data() function from ../tripal_analysis.views.inc in
  *        tripal_analysis_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_analysis.views.inc --in tripal_analysis_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_analysis_views_data() --in tripal_analysis.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;
+}

+ 28 - 28
tripal_analysis/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 
- *        retrieve_XXX_views_data() function from ../tripal_analysis.views.inc in 
+ *
+ *  NOTE: Creating the table definition file is not enough. You also need to call the
+ *        retrieve_XXX_views_data() function from ../tripal_analysis.views.inc in
  *        tripal_analysis_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_analysis.views.inc --in tripal_analysis_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_analysis_views_data() --in tripal_analysis.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;
-}
+}

+ 28 - 28
tripal_contact/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_contact.views.inc:tripal_contact_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_contact.views.inc --in tripal_contact_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_contact_views_data() --in tripal_contact.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_contact/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_contact.views.inc:tripal_contact_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_contact.views.inc --in tripal_contact_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_contact_views_data() --in tripal_contact.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;
-}
+}

+ 66 - 63
tripal_feature/tripal_feature-db_references.inc

@@ -1,14 +1,14 @@
 <?php
 
 /**
- * 
+ *
  *
  * @ingroup tripal_feature
  */
 function tripal_feature_add_ALL_dbreferences_page($node) {
   $output = '';
 
-  $output .= tripal_feature_implement_add_chado_properties_progress('db_references').'<br>';
+  $output .= tripal_feature_implement_add_chado_properties_progress('db_references') . '<br>';
   $output .= '<b>All Database References should strictly pertain to THE CURRENT Individual</b><br>';
   $output .= '<br><b>Current Database References</b><br>';
   $output .= list_dbreferences_for_node($node->db_references);
@@ -87,23 +87,23 @@ function tripal_feature_add_ONE_dbreference_form_validate($form, &$form_state) {
 
    // Check database is valid db_id in chado
    $previous_db = tripal_db_set_active('chado');
-   $tmp_obj = db_fetch_object(db_query("SELECT count(*) as count FROM db WHERE db_id=%d",$db_id));
-   tripal_db_set_active($previous_db);    	
+   $tmp_obj = db_fetch_object(db_query("SELECT count(*) as count FROM {db} WHERE db_id=%d", $db_id));
+   tripal_db_set_active($previous_db);
    if ($tmp_obj->count != 1) {
-      form_set_error('database', 'The database you selected is not valid. Please choose another one.'); 
+      form_set_error('database', 'The database you selected is not valid. Please choose another one.');
    }
 
    // Check Accession is unique for database
    $previous_db = tripal_db_set_active('chado');
-   $sql = "SELECT count(*) as count FROM dbxref WHERE accession='%s' and db_id = %d";
-   $tmp_obj = db_fetch_object(db_query($sql,$accession,$db_id));
+   $sql = "SELECT count(*) as count FROM {dbxref} WHERE accession='%s' and db_id = %d";
+   $tmp_obj = db_fetch_object(db_query($sql, $accession, $db_id));
    tripal_db_set_active($previous_db);
 
    if ($tmp_obj->count > 0) {
-      form_set_error('accession', 'This accession has already been assigned to another feature in the selected database.'); 
+      form_set_error('accession', 'This accession has already been assigned to another feature in the selected database.');
    }
 
-} 
+}
 
 /**
  *
@@ -120,23 +120,24 @@ function tripal_feature_add_ONE_dbreference_form_submit($form, &$form_state) {
 
    // create dbxref
    $previous_db = tripal_db_set_active('chado');
-   $isql =  "INSERT INTO dbxref (db_id, accession, description) VALUES (%d, '%s', '%s')";
-   db_query($isql,$db_id,$accession,$description);
+   $isql =  "INSERT INTO {dbxref} (db_id, accession, description) VALUES (%d, '%s', '%s')";
+   db_query($isql, $db_id, $accession, $description);
    tripal_db_set_active($previous_db);
 
    //create feature_dbxref
-   $dbxref = tripal_db_get_dbxref( array('db_id'=>array('type'=>'INT','value'=>$form_state['values']['db_id']), 
- 											'accession'=>array('type'=>'STRING','exact'=>TRUE,'value'=>$form_state['values']['accession']) ) );
-
-	if (!empty($dbxref->dbxref_id)) {
-		$previous_db = tripal_db_set_active('chado');
-      $isql = "INSERT INTO feature_dbxref (feature_id, dbxref_id) VALUES (%d, %d)";
- 	   db_query($isql,$feature_id,$dbxref->dbxref_id);
-		tripal_db_set_active($previous_db);
-    	drupal_set_message('Successfully Added Database Reference');
-      drupal_goto('node/'.$nid);
-   } else {
- 	   drupal_set_message('Database reference NOT successfully created...','error');
+   $dbxref = tripal_db_get_dbxref( array('db_id' => array('type' => 'INT', 'value' => $form_state['values']['db_id']),
+                       'accession' => array('type' => 'STRING', 'exact' => TRUE, 'value' => $form_state['values']['accession']) ) );
+
+  if (!empty($dbxref->dbxref_id)) {
+    $previous_db = tripal_db_set_active('chado');
+      $isql = "INSERT INTO {feature_dbxref} (feature_id, dbxref_id) VALUES (%d, %d)";
+      db_query($isql, $feature_id, $dbxref->dbxref_id);
+    tripal_db_set_active($previous_db);
+      drupal_set_message('Successfully Added Database Reference');
+      drupal_goto('node/' . $nid);
+   }
+   else {
+      drupal_set_message('Database reference NOT successfully created...', 'error');
    } //end of if dbxref was created successfully
 
 }
@@ -159,12 +160,12 @@ function tripal_feature_edit_ALL_dbreferences_page($node) {
   return $output;
 }
 
-/**                                           
- * Implements Hook_form()                      
+/**
+ * Implements Hook_form()
  * Handles adding of DB References to Features
  *
  * @ingroup tripal_feature
- */                                        
+ */
 function tripal_feature_edit_ALL_db_references_form($form_state, $node) {
   $form = array();
 
@@ -176,7 +177,7 @@ function tripal_feature_edit_ALL_db_references_form($form_state, $node) {
   $i=0;
 
   $feature = $node->feature;
-  $references = tripal_feature_load_references ($feature->feature_id);
+  $references = tripal_feature_load_references($feature->feature_id);
 
   // pre populate the database options
   $db_options = tripal_db_get_db_options();
@@ -188,7 +189,7 @@ function tripal_feature_edit_ALL_db_references_form($form_state, $node) {
        $i++;
        $form["num-$i"] = array(
          '#type' => 'fieldset',
-         '#title' => t("Database Reference")." $i"
+         '#title' => t("Database Reference") . " $i"
        );
 
        $form["num-$i"]["accession-$i"] = array(
@@ -199,11 +200,11 @@ function tripal_feature_edit_ALL_db_references_form($form_state, $node) {
          '#default_value' => $ref->accession
        );
 
-       $form["num-$i"]["db_id-$i"] = array( 
-         '#type' => 'select', 
+       $form["num-$i"]["db_id-$i"] = array(
+         '#type' => 'select',
          '#title' => t('Database'),
          '#options' => $db_options,
-         '#required' => TRUE, 
+         '#required' => TRUE,
          '#default_value' => $ref->db_id
        );
 
@@ -246,29 +247,30 @@ function tripal_feature_edit_ALL_db_references_form_submit($form, &$form_state)
   $button = $form_state['clicked_button']['#name'];
   $nid = $form_state['values']['nid'];
 
-  if (strcmp($action,'Update All References')==0) {
+  if (strcmp($action, 'Update All References')==0) {
      for ($i=1; $i<=$num_refs; $i++) {
-		 $dbxref_id = $form_state['values']["dbxref_id-$i"]; 
-		 $db_id = $form_state['values']["db_id-$i"];
-		 $accession = $form_state['values']["accession-$i"];
-       tripal_feature_update_db_reference($dbxref_id,$db_id,$accession);
+     $dbxref_id = $form_state['values']["dbxref_id-$i"];
+     $db_id = $form_state['values']["db_id-$i"];
+     $accession = $form_state['values']["accession-$i"];
+       tripal_feature_update_db_reference($dbxref_id, $db_id, $accession);
      }
      drupal_set_message("Updated all Database References");
-     drupal_goto('node/'.$nid);
-  } 
-  elseif (strcmp($action,'Delete')==0){
-     if(preg_match('/delete-(\d+)/', $button, $matches) ) {
+     drupal_goto('node/' . $nid);
+  }
+  elseif (strcmp($action, 'Delete')==0) {
+     if (preg_match('/delete-(\d+)/', $button, $matches) ) {
         $i = $matches[1];
-	     $dbxref_id = $form_state['values']["dbxref_id-$i"]; 
+       $dbxref_id = $form_state['values']["dbxref_id-$i"];
         tripal_feature_delete_db_reference($dbxref_id);
         drupal_set_message("Deleted Database Reference");
-        drupal_goto('node/'.$nid);
-     } else {
-        drupal_set_message("Could not remove database reference: ",'error');
+        drupal_goto('node/' . $nid);
+     }
+     else {
+        drupal_set_message("Could not remove database reference: ", 'error');
      }
-  } 
+  }
   else {
-    drupal_set_message("Unrecognized Button Pressed",'error');
+    drupal_set_message("Unrecognized Button Pressed", 'error');
   }
 
 }
@@ -281,8 +283,8 @@ function tripal_feature_edit_ALL_db_references_form_submit($form, &$form_state)
 function tripal_feature_update_db_reference($dbxref_id, $db_id, $accession) {
 
   $previous_db = tripal_db_set_active('chado');
-  $sql =  "UPDATE dbxref SET db_id=%d, accession='%s' WHERE dbxref_id=%d";
-  db_query($sql,$db_id,$accession,$dbxref_id);
+  $sql =  "UPDATE {dbxref} SET db_id=%d, accession='%s' WHERE dbxref_id=%d";
+  db_query($sql, $db_id, $accession, $dbxref_id);
   tripal_db_set_active($previous_db);
 
 }
@@ -296,12 +298,12 @@ function tripal_feature_delete_db_reference($dbxref_id) {
 
   $previous_db = tripal_db_set_active('chado');
   db_query(
-    "DELETE FROM dbxref WHERE dbxref_id=%d",
+    "DELETE FROM {dbxref} WHERE dbxref_id=%d",
     $dbxref_id
   );
 
   db_query(
-    "DELETE FROM feature_dbxref WHERE dbxref_id=%d",
+    "DELETE FROM {feature_dbxref} WHERE dbxref_id=%d",
     $dbxref_id
   );
   tripal_db_set_active($previous_db);
@@ -313,21 +315,21 @@ function tripal_feature_delete_db_reference($dbxref_id) {
  *
  * @ingroup tripal_feature
  */
-function theme_tripal_feature_edit_ALL_db_references_form ($form) {
+function theme_tripal_feature_edit_ALL_db_references_form($form) {
   $output = '';
 
   $output .= '<br><fieldset>';
   $output .= '<legend>Edit Existing Database References<span class="form-optional" title="This field is optional">(optional)</span></legend>';
   $output .= '<p>Below is a list of already existing database references, one per line. When entering a database reference, the accession '
-  	     .'is a unique identifier for this feature in the specified database.</p>';
+         .'is a unique identifier for this feature in the specified database.</p>';
   $output .= '<table>';
   $output .= '<tr><th>#</th><th>Database</th><th>Accession</th><th></th></tr>';
 
   for ($i=1; $i<=$form['num_db_references']['#value']; $i++) {
-    $output .= '<tr><td>'.drupal_render($form["num-$i"]).'</td><td>'
-    	       .drupal_render($form["database-$i"]).'</td><td>'
-	       .drupal_render($form["accession-$i"]).'</td><td>'
-	       .drupal_render($form["submit-$i"]).'</td></tr>';
+    $output .= '<tr><td>' . drupal_render($form["num-$i"]) . '</td><td>'
+             . drupal_render($form["database-$i"]) . '</td><td>'
+         . drupal_render($form["accession-$i"]) . '</td><td>'
+         . drupal_render($form["submit-$i"]) . '</td></tr>';
   }
 
   $output .= '</table><br>';
@@ -338,7 +340,7 @@ function theme_tripal_feature_edit_ALL_db_references_form ($form) {
 }
 
 /**
- * 
+ *
  *
  * @ingroup tripal_feature
  */
@@ -349,14 +351,15 @@ function list_dbreferences_for_node($db_references) {
     $output .= '<tr><th>Database</th><th>Accession</th></tr>';
 
     foreach ($db_references as $db) {
-        $output .= '<tr><td>'.$db->db_name.'</td><td>'.$db->accession.'</td></tr>';
-    } // end of foreach db reference 
+        $output .= '<tr><td>' . $db->db_name . '</td><td>' . $db->accession . '</td></tr>';
+    } // end of foreach db reference
 
-    $output .= '</table>'; 
+    $output .= '</table>';
 
-  } else {
+  }
+  else {
     $output = 'No Database References Added to the Current Feature';
-  }              
+  }
 
   return $output;
-}     
+}

+ 41 - 42
tripal_feature/tripal_feature-delete.inc

@@ -1,7 +1,7 @@
 <?php
 
 
-function tripal_feature_delete_form (){
+function tripal_feature_delete_form() {
    // get the list of organisms
    $sql = "SELECT * FROM {organism} ORDER BY genus, species";
    $previous_db = tripal_db_set_active('chado');  // use chado database
@@ -9,34 +9,34 @@ function tripal_feature_delete_form (){
    tripal_db_set_active($previous_db);  // now use drupal database
    $organisms = array();
    $organisms[''] = '';
-   while($organism = db_fetch_object($org_rset)){
+   while ($organism = db_fetch_object($org_rset)) {
       $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
    }
    $form['desc'] = array(
       '#type' => 'markup',
-      '#value' => t("Use one or more of the following fields to identify sets of features to be deleted."), 
+      '#value' => t("Use one or more of the following fields to identify sets of features to be deleted."),
    );
 
    $form['feature_names']= array(
       '#type' => 'textarea',
       '#title' => t('Feature Names'),
-      '#description' => t('Please provide a list of feature names or unique names, 
+      '#description' => t('Please provide a list of feature names or unique names,
          separated by spaces or by new lines to be delete. If you specify feature names then
          all other options below will be ignored (except the unique checkbox).'),
    );
-	$form['is_unique'] = array(
+  $form['is_unique'] = array(
       '#title' => t('Names are Unique Names'),
       '#type' => 'checkbox',
-      '#description' => t('Select this checbox if the names listed in the feature 
+      '#description' => t('Select this checbox if the names listed in the feature
         names box above are the unique name of the feature rather than the human readable names.'),
-	);
+  );
    $form['seq_type']= array(
       '#type' => 'textfield',
       '#title' => t('Sequence Type'),
       '#description' => t('Please enter the Sequence Ontology term that describes the features to be deleted. Use in conjunction with an organism or anaylysis.'),
    );
 
-   $form['organism_id'] = array (
+   $form['organism_id'] = array(
      '#title'       => t('Organism'),
      '#type'        => t('select'),
      '#description' => t("Choose the organism for which features will be deleted."),
@@ -51,7 +51,7 @@ function tripal_feature_delete_form (){
    tripal_db_set_active($previous_db);  // now use drupal database
    $analyses = array();
    $analyses[''] = '';
-   while($analysis = db_fetch_object($org_rset)){
+   while ($analysis = db_fetch_object($org_rset)) {
       $analyses[$analysis->analysis_id] = "$analysis->name ($analysis->program $analysis->programversion, $analysis->sourcename)";
    }
 //  TODO: ADD THIS BACK IN LATER
@@ -70,32 +70,32 @@ function tripal_feature_delete_form (){
    return $form;
 }
 
-function tripal_feature_delete_form_validate ($form, &$form_state){
+function tripal_feature_delete_form_validate($form, &$form_state) {
    $organism_id   = $form_state['values']['organism_id'];
    $seq_type      = trim($form_state['values']['seq_type']);
    $analysis_id   = $form_state['values']['analysis_id'];
    $is_unique     = $form_state['values']['is_unique'];
    $feature_names = $form_state['values']['feature_names'];
 
-   if (!$organism_id and !$anaysis_id and !$seq_type and !$feature_names){
-      form_set_error('feature_names',t("Please select at least one option"));
+   if (!$organism_id and !$anaysis_id and !$seq_type and !$feature_names) {
+      form_set_error('feature_names', t("Please select at least one option"));
    }
 
    // check to make sure the types exists
-   if($seq_type){
+   if ($seq_type) {
       $cvtermsql = "SELECT CVT.cvterm_id
                     FROM {cvterm} CVT
                        INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
                        LEFT JOIN {cvtermsynonym} CVTS on CVTS.cvterm_id = CVT.cvterm_id
                     WHERE cv.name = '%s' and (CVT.name = '%s' or CVTS.synonym = '%s')";
-      $cvterm = db_fetch_object(db_query($cvtermsql,'sequence',$seq_type,$seq_type));
-      if(!$cvterm){
-         form_set_error('seq_type',t("The Sequence Ontology (SO) term selected for the sequence type is not available in the database. Please check spelling or select another."));
+      $cvterm = db_fetch_object(db_query($cvtermsql, 'sequence', $seq_type, $seq_type));
+      if (!$cvterm) {
+         form_set_error('seq_type', t("The Sequence Ontology (SO) term selected for the sequence type is not available in the database. Please check spelling or select another."));
       }
    }
 }
 
-function tripal_feature_delete_form_submit ($form, &$form_state){
+function tripal_feature_delete_form_submit($form, &$form_state) {
    global $user;
 
    $organism_id   = $form_state['values']['organism_id'];
@@ -104,47 +104,47 @@ function tripal_feature_delete_form_submit ($form, &$form_state){
    $is_unique     = $form_state['values']['is_unique'];
    $feature_names = $form_state['values']['feature_names'];
 
-   $args = array($organism_id,$analysis_id,$seq_type,$is_unique,$feature_names);
+   $args = array($organism_id, $analysis_id, $seq_type, $is_unique, $feature_names);
 
-   tripal_add_job("Delete features",'tripal_feature',
-      'tripal_feature_delete_features',$args,$user->uid);
+   tripal_add_job("Delete features", 'tripal_feature',
+      'tripal_feature_delete_features', $args, $user->uid);
 }
 
 
-function tripal_feature_delete_features($organism_id,$analysis_id,$seq_type,
-   $is_unique,$feature_names,$job = NULL)
-{
+function tripal_feature_delete_features($organism_id, $analysis_id, $seq_type,
+   $is_unique, $feature_names, $job = NULL) {
 
    global $user;
-   $match = array();   
+   $match = array();
 
    // if feature names have been provided then handle that separately
-   if($feature_names){
-      $names = preg_split('/\s+/',$feature_names);
-      if(sizeof($names) == 1){
+   if ($feature_names) {
+      $names = preg_split('/\s+/', $feature_names);
+      if (sizeof($names) == 1) {
          $names = $names[0];
       }
-      if($is_unique){
+      if ($is_unique) {
          $match['uniquename'] = $names;
-      } else {
+      }
+      else {
          $match['name'] = $names;
       }
-      $num_deletes = tripal_core_chado_select('feature',array('count(*) as cnt'),$match);
-      print "Deleting ".$num_deletes[0]->cnt ." features\n"; 
-      tripal_core_chado_delete('feature',$match);
+      $num_deletes = tripal_core_chado_select('feature', array('count(*) as cnt'), $match);
+      print "Deleting " . $num_deletes[0]->cnt . " features\n";
+      tripal_core_chado_delete('feature', $match);
    }
 
    // if the user has provided an analysis_id then handle that separately
-   elseif($analysis_id){
+   elseif ($analysis_id) {
       tripal_feature_delete_by_analysis();
    }
    else {
 
 
-      if($organism_id){
+      if ($organism_id) {
          $match['organism_id'] = $organism_id;
       }
-      if($seq_type){
+      if ($seq_type) {
          $match['type_id'] = array(
             'name' => $seq_type,
             'cv_id' => array(
@@ -152,18 +152,17 @@ function tripal_feature_delete_features($organism_id,$analysis_id,$seq_type,
             ),
          );
       }
-      $num_deletes = tripal_core_chado_select('feature',array('count(*) as cnt'),$match);
-      print "Deleting ".$num_deletes[0]->cnt ." features\n"; 
-      tripal_core_chado_delete('feature',$match);
+      $num_deletes = tripal_core_chado_select('feature', array('count(*) as cnt'), $match);
+      print "Deleting " . $num_deletes[0]->cnt . " features\n";
+      tripal_core_chado_delete('feature', $match);
    }
 
    print "Removing orphaned feature pages\n";
-   tripal_features_cleanup(array(),$user->uid);
+   tripal_features_cleanup(array(), $user->uid);
 }
 
-function tripal_feature_delete_by_analysis($organism_id,$analysis_id,$seq_type,
-   $is_unique,$feature_names,$job = NULL)
-{
+function tripal_feature_delete_by_analysis($organism_id, $analysis_id, $seq_type,
+   $is_unique, $feature_names, $job = NULL) {
 
 }
 

+ 68 - 64
tripal_feature/tripal_feature-properties.inc

@@ -10,12 +10,12 @@ function tripal_feature_edit_ALL_properties_page($node) {
 
   // get the list of properties for this feature
   $values  = array('feature_id' => $node->feature->feature_id);
-  $options = array('order_by' => array('type_id' => 'ASC','rank'=>'ASC'));
-  $properties = tripal_core_generate_chado_var('featureprop',$values,$options);
-  $properties = tripal_core_expand_chado_vars($properties,'field','featureprop.value');
-  
+  $options = array('order_by' => array('type_id' => 'ASC', 'rank' => 'ASC'));
+  $properties = tripal_core_generate_chado_var('featureprop', $values, $options);
+  $properties = tripal_core_expand_chado_vars($properties, 'field', 'featureprop.value');
+
   $expand_add = (sizeof($properties)) ? FALSE : TRUE;
-  
+
   // add the appopriate form sections
   $output .= drupal_get_form('tripal_feature_add_ONE_property_form', $node, $expand_add);
   $output .= drupal_get_form('tripal_feature_edit_ALL_properties_form', $node, $properties);
@@ -25,7 +25,7 @@ function tripal_feature_edit_ALL_properties_page($node) {
 }
 
 /**
- * 
+ *
  *
  * @ingroup tripal_feature
  */
@@ -38,35 +38,35 @@ function tripal_feature_add_ONE_property_form($form_state, $node, $expand) {
     '#title' => t('Add Property'),
     '#collapsible' => TRUE,
     '#collapsed' => ($expand) ? FALSE : TRUE,
-  ); 
+  );
 
   $form['prop_nid'] = array(
     '#type' => 'hidden',
     '#value' => $node->nid
   );
-  
+
   $form['add_properties']['feature_id'] = array(
     '#type' => 'value',
     '#value' => $feature_id,
     '#required' => TRUE
   );
-  
+
   // right now this defaults to the 'feature_property' CV
   // but in the future it should be more flexible
   $form['cv_name'] = array(
     '#type' => 'hidden',
     '#value' => 'feature_property'
   );
-	
+
   // get the list of property types
   $prop_type_options = array();
-  $columns = array('cvterm_id','name');
+  $columns = array('cvterm_id', 'name');
   $values = array(
     'cv_id' => array(
       'name' => $form['cv_name']['#value'],
     )
   );
-  $results = tripal_core_chado_select('cvterm',$columns,$values);
+  $results = tripal_core_chado_select('cvterm', $columns, $values);
   foreach ($results as $r) {
     $prop_type_options[$r->name] = $r->name;
   }
@@ -83,7 +83,7 @@ function tripal_feature_add_ONE_property_form($form_state, $node, $expand) {
   );
 
   $form['add_properties']['submit-add'] = array(
-    '#type' => 'submit',         
+    '#type' => 'submit',
     '#value' => t('Add Property')
   );
 
@@ -91,7 +91,7 @@ function tripal_feature_add_ONE_property_form($form_state, $node, $expand) {
 }
 
 /**
- * 
+ *
  *
  * @ingroup tripal_feature
  */
@@ -99,34 +99,35 @@ function tripal_feature_add_ONE_property_form_validate($form, &$form_state) {
 
    // Only Require if Adding Property
    if ($form_state['clicked_button']['#value'] == t('Add Property') ) {
-   
+
       // Check that there is a feature
       if ( $form_state['values']['feature_id'] <= 0 ) {
          form_set_error('feature_id', 'There is no associated feature.');
       }
-		
+
       // Check that Selected a type
       if ( !$form_state['values']['property']) {
          form_set_error('property', 'Please select a type of property.');
-      } 
-   } 
+      }
+   }
 }
 
 /**
- * 
+ *
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_add_ONE_property_form_submit($form, &$form_state) {	
+function tripal_feature_add_ONE_property_form_submit($form, &$form_state) {
    $feature_id = $form_state['values']['feature_id'];
    $property = $form_state['values']['property'];
-   $value = $form_state['values']['prop_value'];       
-   $cv_name = $form_state['values']['cv_name'];       
-       
-   $succes = tripal_feature_insert_property($feature_id,$property,$value,0,$cv_name);
-   if($succes){
+   $value = $form_state['values']['prop_value'];
+   $cv_name = $form_state['values']['cv_name'];
+
+   $succes = tripal_feature_insert_property($feature_id, $property, $value, 0, $cv_name);
+   if ($succes) {
       drupal_set_message("Successfully Added Property: $property => $value");
-   } else {
+   }
+   else {
       drupal_set_message("Failed to Add Property: $property => $value");
    }
 }
@@ -136,114 +137,114 @@ function tripal_feature_add_ONE_property_form_submit($form, &$form_state) {
  * Handles adding of Properties for features
  *
  * @ingroup tripal_feature
- */ 
+ */
 function tripal_feature_edit_ALL_properties_form($form_state, $node, $properties) {
   $form = array();
   $feature_id = $node->feature->feature_id;
-  
+
   $form['nid'] = array(
     '#type' => 'hidden',
     '#value' => $node->nid
   );
-  
+
   $form['add_properties']['feature_id'] = array(
     '#type' => 'value',
     '#value' => $feature_id,
     '#required' => TRUE
   );
-    
+
   // right now this defaults to the 'feature_property' CV
   // but in the future it should be more flexible
   $form['cv_name'] = array(
     '#type' => 'hidden',
     '#value' => 'feature_property'
   );
-  
+
   if (sizeof($properties)) {
-    
+
     // build the select box options for the property name
     $prop_type_options = array();
-    $columns = array('cvterm_id','name');
+    $columns = array('cvterm_id', 'name');
     $values = array(
        'cv_id' => array(
           'name' => $form['cv_name']['#value']
        )
     );
-    $results = tripal_core_chado_select('cvterm',$columns, $values);
+    $results = tripal_core_chado_select('cvterm', $columns, $values);
     foreach ($results as $r) {
       $prop_type_options[$r->name] = $r->name;
     }
-    
-    // iterate through all of the properties and create a set of form elements 
+
+    // iterate through all of the properties and create a set of form elements
     foreach ($properties as $i => $property) {
        $form["num-$i"] = array(
           '#type' => 'fieldset',
           '#value' => "Property $i"
-       );      
+       );
        $form["num-$i"]["id-$i"] = array(
           '#type' => 'hidden',
           '#value' => $property->featureprop_id
-       );      
-       $default = array_search($property->type, $prop_type_options);  
+       );
+       $default = array_search($property->type, $prop_type_options);
        $form["num-$i"]["type-$i"] = array(
           '#type' => 'select',
           '#options' => $prop_type_options,
           '#default_value' => $property->type_id->name
-       );     
+       );
        $form["num-$i"]["value-$i"] = array(
           '#type' => 'textfield',
           '#default_value' => $property->value
-       );      
+       );
        $form["num-$i"]["delete-$i"] = array(
           '#type' => 'submit',
           '#value' => t("Delete"),
          '#name' => "delete-$i",
        );
     } //end of foreach property
-  
+
     $form['num_properties'] = array(
       '#type' => 'hidden',
       '#value' => $i
     );
-  
+
     $form["submit-edits"] = array(
       '#type' => 'submit',
       '#value' => t('Update All Properties')
     );
   }
-  
+
   return $form;
 }
 
 /**
- * 
+ *
  *
  * @ingroup tripal_feature
  */
 function tripal_feature_edit_ALL_properties_form_submit($form, &$form_state) {
 
-  $cv_name = $form_state['values']['cv_name'];  
+  $cv_name = $form_state['values']['cv_name'];
   $feature_id = $form_state['values']["feature_id"];
   $all_good = 1;
 
   // if the update button was clicked then do the update
   if ($form_state['clicked_button']['#value'] == t('Update All Properties') ) {
-     // iterate through each of the properties and set each one               
+     // iterate through each of the properties and set each one
      for ($i=1; $i<=$form_state['values']['num_properties']; $i++) {
        $featureprop_id = $form_state['values']["id-$i"];
        $property = $form_state['values']["type-$i"];
        $value = $form_state['values']["value-$i"];
-       $success = tripal_feature_update_property_by_id($featureprop_id,$property,$value,$cv_name);       
-       if(!$success){
+       $success = tripal_feature_update_property_by_id($featureprop_id, $property, $value, $cv_name);
+       if (!$success) {
           drupal_set_message("Failed to Update Property: $property => $value");
           $all_good = 0;
        }
      }
-     if($all_good){
+     if ($all_good) {
         drupal_set_message("Updated all Properties");
      }
-     drupal_goto('node/'.$form_state['values']['nid']);
-  } 
+     drupal_goto('node/' . $form_state['values']['nid']);
+  }
   // if the delete button was clicked then remove the property
   elseif (preg_match('/delete-(\d+)/', $form_state['clicked_button']['#name'], $matches) ) {
      $i = $matches[1];
@@ -251,33 +252,35 @@ function tripal_feature_edit_ALL_properties_form_submit($form, &$form_state) {
      $property = $form_state['values']["type-$i"];
      $value = $form_state['values']["value-$i"];
      $success = tripal_feature_delete_property_by_id($featureprop_id);
-     if($success){
+     if ($success) {
         drupal_set_message("Deleted Property");
-     } else {
+     }
+     else {
         drupal_set_message("Unable to Delete Property");
      }
-  } else {
-    drupal_set_message("Unrecognized Button Pressed",'error');
+  }
+  else {
+    drupal_set_message("Unrecognized Button Pressed", 'error');
   }
 }
 /**
- * 
+ *
  *
  * @ingroup tripal_feature
  */
-function theme_tripal_feature_edit_ALL_properties_form ($form) {
+function theme_tripal_feature_edit_ALL_properties_form($form) {
   $output = '';
-  
+
   $output .= '<br><fieldset>';
   $output .= '<legend>Edit Already Existing Properties<span class="form-optional" title="This field is optional">(optional)</span></legend>';
   $output .= '<p>Below is a list of already existing properties for this feature, one property per line. The type refers to the type of '
-  	     .'property and the value is the value for that property. </p>';
+         .'property and the value is the value for that property. </p>';
   $output .= '<table>';
   $output .= '<tr><th>#</th><th>Type</th><th>Value</th><th></th></tr>';
 
   for ($i=0; $i<=$form['num_properties']['#value']; $i++) {
     if (isset($form["num-$i"])) {
-      $output .= '<tr><td>'.($i+1).'</td><td>'.drupal_render($form["num-$i"]["type-$i"]).'</td><td>'.drupal_render($form["num-$i"]["value-$i"]).'</td><td>'.drupal_render($form["num-$i"]["delete-$i"]).'</td></tr>';
+      $output .= '<tr><td>' . ($i+1) . '</td><td>' . drupal_render($form["num-$i"]["type-$i"]) . '</td><td>' . drupal_render($form["num-$i"]["value-$i"]) . '</td><td>' . drupal_render($form["num-$i"]["delete-$i"]) . '</td></tr>';
       unset($form["num-$i"]);
     }
   }
@@ -290,7 +293,7 @@ function theme_tripal_feature_edit_ALL_properties_form ($form) {
 }
 
 /**
- * 
+ *
  *
  * @ingroup tripal_feature
  */
@@ -303,13 +306,14 @@ function tripal_feature_list_properties_for_node($properties) {
 
     if (!empty($properties) ) {
       foreach ($properties as $p) {
-        $output .= '<tr><td>'.$p->type.'</td><td>'.$p->value.'</td></tr>';
+        $output .= '<tr><td>' . $p->type . '</td><td>' . $p->value . '</td></tr>';
       } // end of foreach property
     }
 
     $output .= '</table>';
 
-  } else {
+  }
+  else {
     $output = 'No properties exist for the current feature';
   }
 

+ 147 - 126
tripal_feature/tripal_feature-relationships.inc

@@ -9,8 +9,8 @@
 function tripal_feature_add_ALL_relationships_page($node) {
   $output = '';
 
-  $output .= tripal_feature_implement_add_chado_properties_progress('relationships').'<br>';
-  $output .= '<b>All Relationships should include the CURRENT Individual ('.$node->uniquename.')</b><br>';
+  $output .= tripal_feature_implement_add_chado_properties_progress('relationships') . '<br>';
+  $output .= '<b>All Relationships should include the CURRENT Individual (' . $node->uniquename . ')</b><br>';
   $output .= '<br><b>Current Relationships</b><br>';
   $output .= list_relationships_for_node($node->uniquename, $node->subject_relationships, $node->object_relationships);
   $output .= '<br><br>';
@@ -33,9 +33,9 @@ function tripal_feature_add_ONE_relationship_form($form_state, $node) {
   $_SESSION['organism'] = $organism_id; //needed for autocomplete enter feature to work
 
   $form['rel_nid'] = array(
-    '#type' => 'hidden', 
+    '#type' => 'hidden',
     '#value' => $node->nid
-  ); 
+  );
 
   $form['add_relationships'] = array(
     '#type' => 'fieldset',
@@ -88,7 +88,7 @@ function tripal_feature_add_ONE_relationship_form($form_state, $node) {
 
   );
 
-  $form['add_relationships']['r_feature_uniquename'] = array( 
+  $form['add_relationships']['r_feature_uniquename'] = array(
     '#type' => 'value',
     '#value' => $node->uniquename,
     '#required' => TRUE
@@ -109,49 +109,56 @@ function tripal_feature_add_ONE_relationship_form_validate($form, &$form_state)
   if ($form_state['clicked_button']['#value'] == t('Add a Relationship') ) {
 
     // check valid feature selected for subject
-    $criteria = array('unknown' => array('value'=> $form_state['values']['subject_id'], 
-      																		'columns'=>array('name','uniquename','accession','synonym') ));
-    $subject_results = get_chado_stocks($criteria,'ANY',$_SESSION['organism']);
+    $criteria = array('unknown' => array('value' => $form_state['values']['subject_id'],
+                                          'columns' => array('name', 'uniquename', 'accession', 'synonym') ));
+    $subject_results = get_chado_stocks($criteria, 'ANY', $_SESSION['organism']);
     if (sizeof($subject_results) > 1) {
       $links= array();
-      for ($i=0; $i<sizeof($subject_results); $i++) { $links[] = l($i+1, "node/".$subject_results[$i]->nid); }
-      $message = "Too many stocks match '".$form_state['values']['subject_id']."'! "
-      	       	 . " Please refine your input to match ONLY ONE stock. <br>"
-		 . "To aid in this process, here are the stocks that match your initial input: "
-		 .join(', ',$links);
+      for ($i=0; $i<sizeof($subject_results); $i++) {
+      $links[] = l($i+1, "node/" . $subject_results[$i]->nid); }
+      $message = "Too many stocks match '" . $form_state['values']['subject_id'] . "'! "
+                  . " Please refine your input to match ONLY ONE stock. <br>"
+     . "To aid in this process, here are the stocks that match your initial input: "
+     . join(', ', $links);
       form_set_error('subject_id', $message);
-    } elseif (sizeof($subject_results) < 1) {
-      form_set_error('subject_id', "There are no stocks matching your input. Please check your input for typos and/or lookup the stock ".l('here', 'stocks'));
-    } elseif (sizeof($subject_results) == 1) {
+    }
+    elseif (sizeof($subject_results) < 1) {
+      form_set_error('subject_id', "There are no stocks matching your input. Please check your input for typos and/or lookup the stock " . l('here', 'stocks'));
+    }
+    elseif (sizeof($subject_results) == 1) {
       $form_state['values']['subject_id'] = $subject_results[0]->stock_id;
     }
 
     // check valid stock selected for object
-    $criteria = array('unknown' => array('value'=> $form_state['values']['object_id'], 
-      																		'columns'=>array('name','uniquename','accession','synonym') ));
-    $object_results = get_chado_stocks($criteria,'ANY',$_SESSION['organism']);
+    $criteria = array('unknown' => array('value' => $form_state['values']['object_id'],
+                                          'columns' => array('name', 'uniquename', 'accession', 'synonym') ));
+    $object_results = get_chado_stocks($criteria, 'ANY', $_SESSION['organism']);
     if (sizeof($object_results) > 1) {
       $links= array();
-      for ($i=0; $i<sizeof($object_results); $i++) { $links[] = l($i+1, "node/".$object_results[$i]->nid); } 
-      $message = "Too many stocks match '".$form_state['values']['object_id']."'! "
+      for ($i=0; $i<sizeof($object_results); $i++) {
+      $links[] = l($i+1, "node/" . $object_results[$i]->nid); }
+      $message = "Too many stocks match '" . $form_state['values']['object_id'] . "'! "
                  . "Please refine your input to match ONLY ONE stock. <br>"
                  . "To aid in this process, here are the stocks that match your initial input: "
-                 .join(', ',$links);
+                 . join(', ', $links);
       form_set_error('object_id', $message);
-    } elseif (sizeof($object_results) < 1) {
-      form_set_error('object_id', "There are no stocks matching your input. Please check your input for typos and/or lookup the stock ".l('here', 'stocks'));                                                                         
-    } elseif (sizeof($object_results) == 1) {
+    }
+    elseif (sizeof($object_results) < 1) {
+      form_set_error('object_id', "There are no stocks matching your input. Please check your input for typos and/or lookup the stock " . l('here', 'stocks'));
+    }
+    elseif (sizeof($object_results) == 1) {
       $form_state['values']['object_id'] = $object_results[0]->stock_id;
     }
 
     // check valid type selected
     if ($form_state['values']['type_id'] == 0) {
       form_set_error('type_id', 'Please select a type of relationship.');
-    } else {
-    	$previous_db = tripal_db_set_active('chado');
-    	$tmp_obj = db_fetch_object(db_query("SELECT count(*) as count FROM cvterm WHERE cvterm_id=%d",$form_state['values']['type_id']));
-    	tripal_db_set_active($previous_db);
-    	
+    }
+    else {
+      $previous_db = tripal_db_set_active('chado');
+      $tmp_obj = db_fetch_object(db_query("SELECT count(*) as count FROM {cvterm} WHERE cvterm_id=%d", $form_state['values']['type_id']));
+      tripal_db_set_active($previous_db);
+
       if ($tmp_obj->count != 1) {
         form_set_error('type_id', 'The type you selected is not valid. Please choose another one.');
       }
@@ -160,7 +167,7 @@ function tripal_feature_add_ONE_relationship_form_validate($form, &$form_state)
     // check either subject or object is the current stock
     if ( $subject_results[0]->nid != $form_state['values']['rel_nid'] ) {
       if ( $object_results[0]->nid != $form_state['values']['rel_nid'] ) {
-        form_set_error('subject_id', 'Either Subject or Object must be the current stock ('.$form_state['values']['r_stock_uniquename'].').');
+        form_set_error('subject_id', 'Either Subject or Object must be the current stock (' . $form_state['values']['r_stock_uniquename'] . ').');
       }
     }
   } //end of require validation if adding relationship
@@ -176,7 +183,7 @@ function tripal_feature_add_ONE_relationship_form_submit($form, &$form_state) {
   if ($form_state['values']['subject_id'] > 0) {
     $previous_db = db_set_active('chado');
     db_query(
-      "INSERT INTO stock_relationship (subject_id, type_id, object_id, value) VALUES (%d, %d, %d, '%s')",
+      "INSERT INTO {stock_relationship} (subject_id, type_id, object_id, value) VALUES (%d, %d, %d, '%s')",
       $form_state['values']['subject_id'],
       $form_state['values']['type_id'],
       $form_state['values']['object_id'],
@@ -189,14 +196,14 @@ function tripal_feature_add_ONE_relationship_form_submit($form, &$form_state) {
 
 }
 
-/** 
+/**
  *
  *
  * @ingroup tripal_feature
  */
 function tripal_feature_edit_ALL_relationships_page($node) {
   $output = '';
-	
+
   $output .= drupal_get_form('tripal_feature_edit_ALL_relationships_form', $node);
   $output .= '<br>';
   $output .= drupal_get_form('tripal_feature_add_ONE_relationship_form', $node);
@@ -205,13 +212,13 @@ function tripal_feature_edit_ALL_relationships_page($node) {
 
   return $output;
 }
-                                                      
-/**                                                 
- * Implements Hook_form()                             
- * Handles adding of Properties & Synonyms to Stocks  
+
+/**
+ * Implements Hook_form()
+ * Handles adding of Properties & Synonyms to Stocks
  *
  * @ingroup tripal_feature
- */                                                   
+ */
 function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
   $form = array();
 
@@ -219,7 +226,7 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
     '#type' => 'hidden',
     '#value' => $node->nid
   );
-  
+
   $form['r_feature_uniquename'] = array(
     '#type' => 'hidden',
     '#value' => $node->uniquename
@@ -228,9 +235,9 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
   $i=0;
 
   $feature = $node->feature;
-  $orelationships = tripal_feature_load_relationships ($feature->feature_id,'as_object');
-  $srelationships = tripal_feature_load_relationships ($feature->feature_id,'as_subject');
-  $relationships = array_merge($orelationships,$srelationships);
+  $orelationships = tripal_feature_load_relationships($feature->feature_id, 'as_object');
+  $srelationships = tripal_feature_load_relationships($feature->feature_id, 'as_subject');
+  $relationships = array_merge($orelationships, $srelationships);
 
   if (sizeof($relationships) != 0) {
      foreach ($relationships as $r) {
@@ -247,45 +254,47 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
        );
 
        //Enter relationship specific fields
-       if ( !empty($r->subject_id) ) { 
+       if ( !empty($r->subject_id) ) {
          $default = $r->subject_uniquename;
-         $description = l($r->subject_name, 'node/'.$r->subject_nid); 
-       } else { 
-          $default = $node->uniquename; 
-          $description = "Current Feature"; 
+         $description = l($r->subject_name, 'node/' . $r->subject_nid);
+       }
+       else {
+          $default = $node->uniquename;
+          $description = "Current Feature";
        }
-       $description .= " (".$r->subject_type.")";
+       $description .= " (" . $r->subject_type . ")";
        $form["num-$i"]["subject_id-$i"] = array(
-         '#type' => 'textfield',      
-         //'#title' => t('Subject'), 
+         '#type' => 'textfield',
+         //'#title' => t('Subject'),
          '#required'   => TRUE,
          '#size' => 30,
          '#default_value' => $default,
          '#description' => $description,
-       ); 
+       );
 
        $cv = tripal_cv_get_cv_by_name('relationship');
        $type_options = tripal_cv_get_cvterm_options($cv->cv_id);
-       ksort($type_options);          
-       $form["num-$i"]["type_id-$i"] = array(  
-         '#type' => 'select',    
-         //'#title' => t('Type of Relationship'), 
+       ksort($type_options);
+       $form["num-$i"]["type_id-$i"] = array(
+         '#type' => 'select',
+         //'#title' => t('Type of Relationship'),
          '#options' => $type_options,
          '#required' => TRUE,
          '#default_value' => $r->relationship_type_id
        );
 
-       if (!empty($r->object_id) ) { 
+       if (!empty($r->object_id) ) {
          $default = $r->object_uniquename;
-         $description = l($r->object_name, 'node/'.$r->object_nid);
-       } else { 
-         $default = $node->uniquename; 
-         $description = 'Current Feature'; 
+         $description = l($r->object_name, 'node/' . $r->object_nid);
+       }
+       else {
+         $default = $node->uniquename;
+         $description = 'Current Feature';
        }
-       $description .= " (".$r->object_type.")";
+       $description .= " (" . $r->object_type . ")";
        $form["num-$i"]["object_id-$i"] = array(
-         '#type' => 'textfield',          
-         //'#title' => t('Object'),      
+         '#type' => 'textfield',
+         //'#title' => t('Object'),
          '#required'   => TRUE,
          '#size' => 30,
          '#default_value' => $default,
@@ -308,12 +317,13 @@ function tripal_feature_edit_ALL_relationships_form($form_state, $node) {
        '#type' => 'submit',
        '#value' => t('Update All Relationships')
      );
-  } else {
+  }
+  else {
      $form["info"] = array(
        '#type' => 'markup',
        '#value' => t('No relationships currently exist for this feature.')
      );
-  } 
+  }
 
 
 
@@ -331,52 +341,59 @@ function tripal_feature_edit_ALL_relationships_form_validate($form, &$form_state
   if ($form_state['clicked_button']['#value'] == t('Update All Relationships') ) {
 
     for ($i=1; $i<=$form_state['values']['num_relationships']; $i++) {
-      
+
       // check valid stock selected for subject
-      $criteria = array('unknown' => array('value'=>$form_state['values']["subject_id-$i"], 
-      																		'columns'=>array('name','uniquename','accession','synonym') ));
-      $subject_results = get_chado_stocks($criteria,'ANY',$_SESSION['organism']);
+      $criteria = array('unknown' => array('value' => $form_state['values']["subject_id-$i"],
+                                          'columns' => array('name', 'uniquename', 'accession', 'synonym') ));
+      $subject_results = get_chado_stocks($criteria, 'ANY', $_SESSION['organism']);
       if (sizeof($subject_results) > 1) {
         $links= array();
-        for ($j=0; $j<sizeof($subject_results); $j++) { $links[] = l($j+1, "node/".$subject_results[$j]->nid); }
-        $message = "Too many stocks match '".$form_state['values']["subject_id-$i"]."'! "
-                 . "Please refine your input to match ONLY ONE stock. <br>" 
+        for ($j=0; $j<sizeof($subject_results); $j++) {
+        $links[] = l($j+1, "node/" . $subject_results[$j]->nid); }
+        $message = "Too many stocks match '" . $form_state['values']["subject_id-$i"] . "'! "
+                 . "Please refine your input to match ONLY ONE stock. <br>"
                  . "To aid in this process, here are the stocks that match your initial input: "
-                 .join(', ',$links);
+                 . join(', ', $links);
         form_set_error("subject_id-$i", $message);
-      } elseif (sizeof($subject_results) < 1) { 
-        form_set_error("subject_id-$i", "There are no stocks matching your input. Please check your input for typos and/or lookup the stock ".l('here', 'stocks'));
-      } elseif (sizeof($subject_results) == 1) {
+      }
+      elseif (sizeof($subject_results) < 1) {
+        form_set_error("subject_id-$i", "There are no stocks matching your input. Please check your input for typos and/or lookup the stock " . l('here', 'stocks'));
+      }
+      elseif (sizeof($subject_results) == 1) {
         $form_state['values']["subject_id-$i"] = $subject_results[0]->stock_id;
-      } 
+      }
 
       // check valid stock selected for object
-      $criteria = array('unknown' => array('value'=> $form_state['values']["object_id-$i"], 
-      																		'columns'=>array('name','uniquename','accession','synonym') ));
-      $object_results = get_chado_stocks($criteria,'ANY',$_SESSION['organism']);
+      $criteria = array('unknown' => array('value' => $form_state['values']["object_id-$i"],
+                                          'columns' => array('name', 'uniquename', 'accession', 'synonym') ));
+      $object_results = get_chado_stocks($criteria, 'ANY' , $_SESSION['organism']);
       if (sizeof($object_results) > 1) {
         $links= array();
-        for ($j=0; $j<sizeof($object_results); $j++) { $links[] = l($j+1, "node/".$object_results[$j]->nid); }
-        $message = "Too many stocks match '".$form_state['values']["object_id-$i"]."'! "
-                 . "Please refine your input to match ONLY ONE stock. <br>" 
+        for ($j=0; $j<sizeof($object_results); $j++) {
+        $links[] = l($j+1, "node/" . $object_results[$j]->nid); }
+        $message = "Too many stocks match '" . $form_state['values']["object_id-$i"] . "'! "
+                 . "Please refine your input to match ONLY ONE stock. <br>"
                  . "To aid in this process, here are the stocks that match your initial input: "
-                 .join(', ',$links);
+                 . join(', ', $links);
         form_set_error("object_id-$i", $message);
-      } elseif (sizeof($object_results) < 1) {
-        form_set_error("object_id-$i", "There are no stocks matching your input. Please check your input for typos and/or lookup the stock ".l('here', 'stocks'));
-      } elseif (sizeof($object_results) == 1) {
+      }
+      elseif (sizeof($object_results) < 1) {
+        form_set_error("object_id-$i", "There are no stocks matching your input. Please check your input for typos and/or lookup the stock " . l('here', 'stocks'));
+      }
+      elseif (sizeof($object_results) == 1) {
         $form_state['values']["object_id-$i"] = $object_results[0]->stock_id;
-      } 
+      }
 
       // check valid type selected
       if ($form_state['values']["type_id-$i"] == 0) {
         form_set_error('type_id', 'Please select a type of relationship.');
-      } else {
-    		$previous_db = tripal_db_set_active('chado');
-    		$tmp_obj = db_fetch_object(db_query("SELECT count(*) as count FROM cvterm WHERE cvterm_id=%d",$form_state['values']["type_id-$i"]));
-    		tripal_db_set_active($previous_db);
-    	
-      	if ($tmp_obj->count != 1) {
+      }
+      else {
+        $previous_db = tripal_db_set_active('chado');
+        $tmp_obj = db_fetch_object(db_query("SELECT count(*) as count FROM {cvterm} WHERE cvterm_id=%d" , $form_state['values']["type_id-$i"]));
+        tripal_db_set_active($previous_db);
+
+        if ($tmp_obj->count != 1) {
           form_set_error("type_id-$i", 'The type you selected is not valid. Please choose another one.');
         }
       }
@@ -384,7 +401,7 @@ function tripal_feature_edit_ALL_relationships_form_validate($form, &$form_state
       // check either subject or object is the current stock
       if ( $subject_results[0]->nid != $form_state['values']['nid'] ) {
         if ( $object_results[0]->nid != $form_state['values']['nid'] ) {
-          form_set_error("subject_id-$i", 'Either Subject or Object must be the current stock ('.$form_state['values']['r_stock_uniquename'].').');
+          form_set_error("subject_id-$i", 'Either Subject or Object must be the current stock (' . $form_state['values']['r_stock_uniquename'] . ').');
         }
       }
 
@@ -406,25 +423,28 @@ function tripal_feature_edit_ALL_relationships_form_submit($form, &$form_state)
 
        //process stock textfields
        tripal_feature_update_relationship(
-				$form_state['values']["id-$i"], 
-				$form_state['values']["subject_id-$i"],
-				$form_state['values']["type_id-$i"], 
-				$form_state['values']["object_id-$i"]
-			);
+        $form_state['values']["id-$i"],
+        $form_state['values']["subject_id-$i"],
+        $form_state['values']["type_id-$i"],
+        $form_state['values']["object_id-$i"]
+      );
      }
      drupal_set_message("Updated all Relationships");
-     drupal_goto('node/'.$form_state['values']['nid']);
+     drupal_goto('node/' . $form_state['values']['nid']);
 
-  } elseif ( preg_match('/Delete #(\d+)/', $form_state['clicked_button']['#value'], $matches) ) {
+  }
+  elseif ( preg_match('/Delete #(\d+)/', $form_state['clicked_button']['#value'], $matches) ) {
 
      $i = $matches[1];
      tripal_feature_delete_relationship($form_state['values']["id-$i"]);
      drupal_set_message("Deleted Relationship");
 
-  } elseif ($form_state['clicked_button']['#value'] == t('Back to Stock') ) {
-    drupal_goto('node/'.$form_state['values']['nid']);
-  } else {
-    drupal_set_message("Unrecognized Button Pressed",'error');
+  }
+  elseif ($form_state['clicked_button']['#value'] == t('Back to Stock') ) {
+    drupal_goto('node/' . $form_state['values']['nid']);
+  }
+  else {
+    drupal_set_message("Unrecognized Button Pressed", 'error');
   }
 
 }
@@ -434,13 +454,13 @@ function tripal_feature_edit_ALL_relationships_form_submit($form, &$form_state)
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_update_relationship ($stock_relationship_id, $subject_id, $cvterm_id, $object_id) {
+function tripal_feature_update_relationship($stock_relationship_id, $subject_id, $cvterm_id, $object_id) {
 
   $previous_db = db_set_active('chado');
   db_query(
-    "UPDATE stock_relationship SET subject_id=%d, type_id=%d, object_id=%d WHERE stock_relationship_id=%d",
+    "UPDATE {stock_relationship} SET subject_id=%d, type_id=%d, object_id=%d WHERE stock_relationship_id=%d",
     $subject_id,
-    $cvterm_id, 
+    $cvterm_id,
     $object_id,
     $stock_relationship_id
   );
@@ -453,11 +473,11 @@ function tripal_feature_update_relationship ($stock_relationship_id, $subject_id
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_delete_relationship ($stock_relationship_id) {
+function tripal_feature_delete_relationship($stock_relationship_id) {
 
   $previous_db = db_set_active('chado');
   db_query(
-    "DELETE FROM stock_relationship WHERE stock_relationship_id=%d",
+    "DELETE FROM {stock_relationship} WHERE stock_relationship_id=%d",
     $stock_relationship_id
   );
   db_set_active($previous_db);
@@ -469,23 +489,23 @@ function tripal_feature_delete_relationship ($stock_relationship_id) {
  *
  * @ingroup tripal_feature
  */
-function theme_tripal_feature_edit_ALL_relationships_form ($form) {
+function theme_tripal_feature_edit_ALL_relationships_form($form) {
   $output = '';
-  
+
   $output .= '<br><fieldset>';
   $output .= '<legend>Edit Already Existing Relationships<span class="form-optional" title="This field is optional">(optional)</span></legend>';
   $output .= '<p>Each relationship for this stock is listed below, one per line. The textboxes indicating '
-  	    .'the subject and object of the relationship can contain the uniquename, name, database '
-	    .'reference or synonym of a stock of the same organism.</p>';
+        .'the subject and object of the relationship can contain the uniquename, name, database '
+      .'reference or synonym of a stock of the same organism.</p>';
   $output .= '<table>';
   $output .= '<tr><th>#</th><th>Subject</th><th>Type</th><th>Object</th><th></th></tr>';
 
-  for ($i=1; $i<=$form['num_relationships']['#value']; $i++) {
-    $output .= '<tr><td>'.drupal_render($form["num-$i"]).'</td>'.
-      	      '<td>'.drupal_render($form["subject_id-$i"]).'</td>'.
-	            '<td>'.drupal_render($form["type_id-$i"]).'</td>'.
-     	         '<td>'.drupal_render($form["object_id-$i"]).'</td>'.
-	            '<td>'.drupal_render($form["submit-$i"]).'</td></tr>';
+  for ($i=1; $i <= $form['num_relationships']['#value']; $i++) {
+    $output .= '<tr><td>' . drupal_render($form["num-$i"]) . '</td>' .
+              '<td>' . drupal_render($form["subject_id-$i"]) . '</td>' .
+              '<td>' . drupal_render($form["type_id-$i"]) . '</td>' .
+                '<td>' . drupal_render($form["object_id-$i"]) . '</td>' .
+              '<td>' . drupal_render($form["submit-$i"]) . '</td></tr>';
   }
 
   $output .= '</table><br>';
@@ -508,19 +528,20 @@ function tripal_feature_list_relationships_for_node($feature_name, $subject_rela
 
     if (!empty($subject_relationships) ) {
       foreach ($subject_relationships as $s) {
-        $output .= '<tr><td>'.$s->subject_name.'</td><td>'.$s->relationship_type.'</td><td>'.$feature_name.'</td></tr>';
+        $output .= '<tr><td>' . $s->subject_name . '</td><td>' . $s->relationship_type . '</td><td>' . $feature_name . '</td></tr>';
       }
     }
 
     if (!empty($object_relationships) ) {
       foreach ($object_relationships as $o) {
-        $output .= '<tr><td>'.$feature_name.'</td><td>'.$o->relationship_type.'</td><td>'.$o->object_name.'</td></tr>';
+        $output .= '<tr><td>' . $feature_name . '</td><td>' . $o->relationship_type . '</td><td>' . $o->object_name . '</td></tr>';
       } // end of foreach property
     }
 
     $output .= '</table>';
-  } else {
-    $output = 'No Relationships For the Current Feature'; 
+  }
+  else {
+    $output = 'No Relationships For the Current Feature';
   }
 
   return $output;

+ 34 - 25
tripal_feature/tripal_feature-secondary_tables.inc

@@ -1,5 +1,4 @@
 <?php
-// $Id$
 
 /**
  *
@@ -14,9 +13,9 @@ function tripal_feature_implement_back_to_feature_button($form_state, $nid) {
     '#value' => $nid
   );
 
-  $form["submit-back"] = array( 
+  $form["submit-back"] = array(
     '#type' => 'submit',
-    '#value' => t('Back to Stock') 
+    '#value' => t('Back to Stock')
   );
 
   return $form;
@@ -28,7 +27,7 @@ function tripal_feature_implement_back_to_feature_button($form_state, $nid) {
  * @ingroup tripal_feature
  */
 function tripal_feature_implement_back_to_feature_button_submit($form, $form_state) {
-  drupal_goto('node/'.$form_state['values']['nid']);
+  drupal_goto('node/' . $form_state['values']['nid']);
 }
 
 /**
@@ -38,24 +37,28 @@ function tripal_feature_implement_back_to_feature_button_submit($form, $form_sta
  */
 function tripal_feature_implement_add_chado_properties_progress($current) {
 
-    $value = '<div class="form_progress"><div class="form_progress-text">'; 
+    $value = '<div class="form_progress"><div class="form_progress-text">';
 
-    if ($current == 'main') { $value .= '<span id="form-step-current">Create Basic Feature</span>'; } 
+    if ($current == 'main') {
+    $value .= '<span id="form-step-current">Create Basic Feature</span>'; }
     else { $value .= '<span id="form-step">Create Basic Stock</span>'; }
 
     $value .= '<span id="form-segway">  >>  </span>';
 
-    if ($current == 'properties') { $value .= '<span id="form-step-current">Add Synonyms & Properties</span>'; }
+    if ($current == 'properties') {
+    $value .= '<span id="form-step-current">Add Synonyms & Properties</span>'; }
     else { $value .= '<span id="form-step">Add Synonyms & Properties</span>'; }
 
-    $value .= '<span id="form-segway">  >>  </span>';                       
+    $value .= '<span id="form-segway">  >>  </span>';
 
-    if ($current == 'db_references') { $value .= '<span id="form-step-current">Add Database References</span>'; }
+    if ($current == 'db_references') {
+    $value .= '<span id="form-step-current">Add Database References</span>'; }
     else { $value .= '<span id="form-step">Add Database References</span>'; }
 
-    $value .= '<span id="form-segway">  >>  </span>';         
+    $value .= '<span id="form-segway">  >>  </span>';
 
-    if ($current == 'relationships') { $value .= '<span id="form-step-current">Add Relationships</span>'; }
+    if ($current == 'relationships') {
+    $value .= '<span id="form-step-current">Add Relationships</span>'; }
     else { $value .= '<span id="form-step">Add Relationships</span>'; }
 
     $value .= '</div></div>';
@@ -85,7 +88,8 @@ function tripal_feature_implement_add_chado_properties_navigate($form_state, $st
     'relationships' => 'node/%node/relationships'
   );
   $steps_value = array();
-  foreach ($steps as $k => $v) { $steps_value[] = $k.';'.$v; }
+  foreach ($steps as $k => $v) {
+  $steps_value[] = $k . ';' . $v; }
   $form['steps'] = array(
     '#type' => 'hidden',
     '#value' => implode('::', $steps_value)
@@ -114,7 +118,7 @@ function tripal_feature_implement_add_chado_properties_navigate($form_state, $st
   }
 
   if ($step != $form['last_step']['#value']) {
-    $form['submit-next'] = array( 
+    $form['submit-next'] = array(
       '#type' => 'submit',
       '#value' => t('Next Step')
     );
@@ -122,7 +126,7 @@ function tripal_feature_implement_add_chado_properties_navigate($form_state, $st
 
   if ($step == $form['last_step']['#value']) {
     $form['submit-finish'] = array(
-      '#type' => 'submit', 
+      '#type' => 'submit',
       '#value' => t('Finish')
     );
   }
@@ -137,7 +141,7 @@ function tripal_feature_implement_add_chado_properties_navigate($form_state, $st
  */
 function tripal_feature_implement_add_chado_properties_navigate_submit($form, $form_state) {
 
-  $raw_steps = preg_split('/::/', $form_state['values']['steps']); 
+  $raw_steps = preg_split('/::/', $form_state['values']['steps']);
 
   $steps = array();
   $current_index = 'EMPTY';
@@ -146,7 +150,7 @@ function tripal_feature_implement_add_chado_properties_navigate_submit($form, $f
   foreach ($raw_steps as $raw_step) {
     $step = preg_split('/;/', $raw_step);
     $steps[$i] = $step;
-    
+
     if ($step[0] == $form_state['values']['current_step']) {
       $current_index = $i;
     }
@@ -154,16 +158,19 @@ function tripal_feature_implement_add_chado_properties_navigate_submit($form, $f
     $i++;
   }
   $num_steps = $i;
-  
-  if (strcmp($current_index,'EMPTY') == 0) {
+
+  if (strcmp($current_index, 'EMPTY') == 0) {
     // No Matching Step
-    drupal_set_message('Could not determine next step -'.$form_state['values']['current_step'].', please contact the administrator', 'error');
-  } elseif ($current_index == 0) {
+    drupal_set_message('Could not determine next step -' . $form_state['values']['current_step'] . ', please contact the administrator', 'error');
+  }
+  elseif ($current_index == 0) {
     $next_goto = $steps[$current_index+1][1];
-  } elseif ($current_index == ($num_steps-1)) {
+  }
+  elseif ($current_index == ($num_steps-1)) {
     $prev_goto = $steps[$current_index-1][1];
     $next_goto = 'node/%node';
-  } else {
+  }
+  else {
     $prev_goto = $steps[$current_index-1][1];
     $next_goto = $steps[$current_index+1][1];
   }
@@ -172,10 +179,12 @@ function tripal_feature_implement_add_chado_properties_navigate_submit($form, $f
     //replace %node
     $prev_goto = preg_replace('/%node/', $form_state['values']['nid'], $prev_goto);
     $_REQUEST['destination'] = $prev_goto;
-  } elseif ($form_state['clicked_button']['#value'] == t('Next Step') ) {
+  }
+  elseif ($form_state['clicked_button']['#value'] == t('Next Step') ) {
     $next_goto = preg_replace('/%node/', $form_state['values']['nid'], $next_goto);
     $_REQUEST['destination'] = $next_goto;
-  } elseif ($form_state['clicked_button']['#value'] == t('Finish') ) {
+  }
+  elseif ($form_state['clicked_button']['#value'] == t('Finish') ) {
     $next_goto = preg_replace('/%node/', $form_state['values']['nid'], $next_goto);
     $_REQUEST['destination'] = $next_goto;
   }
@@ -213,7 +222,7 @@ function tripal_feature_is_obsolete_form_submit($form, &$form_state) {
 
   $previous_db = db_set_active('chado');
   db_query(
-    "UPDATE stock SET is_obsolete='t' WHERE stock_id=%d",
+    "UPDATE {stock} SET is_obsolete='t' WHERE stock_id=%d",
     $form_state['values']['make_obsolete_stock_id']
   );
   db_set_active($previous_db);

+ 184 - 180
tripal_feature/tripal_feature.admin.inc

@@ -3,7 +3,7 @@
 /**
  * Purpose: Provide Guidance to new Tripal Admin
  *
- * @return 
+ * @return
  *   HTML Formatted text
  *
  * @ingroup tripal_feature
@@ -12,31 +12,31 @@ function tripal_feature_module_description_page() {
 
   $text .= '<h3>Tripal Feature Administrative Tools Quick Links:</h3>';
   $text .= "<ul>
-             <li><a href=\"".url("admin/tripal/tripal_feature/configuration") . "\">Feature Configuration</a></li>
-             <li><a href=\"".url("admin/tripal/tripal_feature/fasta_loader"). "\">Import a multi-FASTA file</a></li>
-             <li><a href=\"".url("admin/tripal/tripal_feature/gff3_load"). "\">Import a GFF3 file</a></li>
-             <li><a href=\"".url("admin/tripal/tripal_feature/sync") . "\">Sync Features</a></li>
-             <li><a href=\"".url("admin/tripal/tripal_feature/delete") . "\">Delete Features</a></li>
+             <li><a href=\"" . url("admin/tripal/tripal_feature/configuration") . "\">Feature Configuration</a></li>
+             <li><a href=\"" . url("admin/tripal/tripal_feature/fasta_loader") . "\">Import a multi-FASTA file</a></li>
+             <li><a href=\"" . url("admin/tripal/tripal_feature/gff3_load") . "\">Import a GFF3 file</a></li>
+             <li><a href=\"" . url("admin/tripal/tripal_feature/sync") . "\">Sync Features</a></li>
+             <li><a href=\"" . url("admin/tripal/tripal_feature/delete") . "\">Delete Features</a></li>
            </ul>";
-#             <li><a href=\"".url("admin/tripal/tripal_feature/aggregate"). "\">Feature Relationship Aggegators</a></li> 
+#             <li><a href=\"".url("admin/tripal/tripal_feature/aggregate"). "\">Feature Relationship Aggegators</a></li>
 
   $text .= '<h3>Module Description:</h3>';
   $text .= '<p>This module provides an interface for the Chado feature module which stores information
             related to genomic features.  This module provides support for bulk loading of data in
-            FASTA or GFF format, visualization of "feature" pages, editing and updating.  
+            FASTA or GFF format, visualization of "feature" pages, editing and updating.
             </p>';
 
   $text .= '<h3>Setup Instructions:</h3>';
   $text .= '<p>After installation of the feature module.  The following tasks should be performed
             <ol>
-              <li><p><b>Set Permissions</b>: The feature module supports the Drupal user permissions interface for 
-               controlling access to feature content and functions. These permissions include viewing, 
+              <li><p><b>Set Permissions</b>: The feature module supports the Drupal user permissions interface for
+               controlling access to feature content and functions. These permissions include viewing,
                creating, editing or administering of
-               feature content. The default is that only the original site administrator has these 
-               permissions.  You can <a href="'.url('admin/user/roles').'">add roles</a> for classifying users, 
-               <a href="'.url('admin/user/user').'">assign users to roles</a> and
-               <a href="'.url('admin/user/permissions').'">assign permissions</a> for the feature content to 
-               those roles.  For a simple setup, allow anonymous users access to view organism content and 
+               feature content. The default is that only the original site administrator has these
+               permissions.  You can <a href="' . url('admin/user/roles') . '">add roles</a> for classifying users,
+               <a href="' . url('admin/user/user') . '">assign users to roles</a> and
+               <a href="' . url('admin/user/permissions') . '">assign permissions</a> for the feature content to
+               those roles.  For a simple setup, allow anonymous users access to view organism content and
                allow the site administrator all other permissions.</p></li>
 
                <li><p><b>Themeing</b>:  Before content from Chado can be visualized the Tripal base theme must
@@ -46,8 +46,8 @@ function tripal_feature_module_description_page() {
 
                <li><p><b>Loading of Ontologies</b>:  If you
                used Tripal to create the Chado database, then you must load ontologies before proceeding.  Visit the
-               page to <a href="'.url('admin/tripal/tripal_cv/obo_loader').'">load ontologies</a> and load at 
-               least the following ontologies:  
+               page to <a href="' . url('admin/tripal/tripal_cv/obo_loader') . '">load ontologies</a> and load at
+               least the following ontologies:
                <ul>
                   <li>Chado Feature Properties</li>
                   <li>Relationship Ontology</li>
@@ -55,80 +55,80 @@ function tripal_feature_module_description_page() {
                   <li>Gene Ontology (if loading GO terms for features)</li>
                </ul></p></li>
 
-               <li><p><b>Create Organisms</b>:  Before adding feature data you must already have the 
-               organisms loaded in the database.  See the 
-               <a href="'.url('admin/tripal/tripal_organism').'">Tripal Organism Admin page</a> for 
+               <li><p><b>Create Organisms</b>:  Before adding feature data you must already have the
+               organisms loaded in the database.  See the
+               <a href="' . url('admin/tripal/tripal_organism') . '">Tripal Organism Admin page</a> for
                instructions for adding and Syncing organisms.</p></li>
 
                <li><p><b>Create Analysis</b>:  Tripal requires that feature data loaded using the Tripal loaders
                be associated with an analyis.  This provides a grouping for the feature data and can be used
                later to visualize data pipelines.  Before loading feature data through the FASTA or GFF loaders
-               you will need to <a href="'.url('node/add').'">create an analysis</a> for the data.</p></li>
+               you will need to <a href="' . url('node/add') . '">create an analysis</a> for the data.</p></li>
 
-               <li><p><b>Create Referring Database Entries</b>:  If you would like to associate your feature data with an 
-               external reference database, check to ensure that the <a href="'.url('admin/tripal/tripal_db/edit_db').'">
-               database record already exists</a>.  If not you should <a href="'.url('admin/tripal/tripal_db/add_db').'">add a new database record</a> before importing
+               <li><p><b>Create Referring Database Entries</b>:  If you would like to associate your feature data with an
+               external reference database, check to ensure that the <a href="' . url('admin/tripal/tripal_db/edit_db') . '">
+               database record already exists</a>.  If not you should <a href="' . url('admin/tripal/tripal_db/add_db') . '">add a new database record</a> before importing
                feature data.</p></li>
 
-               <li><p><b>Data Import</b>:  if you do not already have an existing Chado database with preloaded data 
+               <li><p><b>Data Import</b>:  if you do not already have an existing Chado database with preloaded data
                then you will want
-               to import data.  You can do so using the Chado perl scripts that come with the normal 
-               <a href="http://gmod.org/wiki/Chado">distribution of Chado</a> or you can use the <a href="'.url('admin/tripal/tripal_feature/fasta_loader').'">FASTA loader</a> and 
-               <a href="'.url('admin/tripal/tripal_feature/gff3_load').'">GFF loader</a> provided here.  If you
+               to import data.  You can do so using the Chado perl scripts that come with the normal
+               <a href="http://gmod.org/wiki/Chado">distribution of Chado</a> or you can use the <a href="' . url('admin/tripal/tripal_feature/fasta_loader') . '">FASTA loader</a> and
+               <a href="' . url('admin/tripal/tripal_feature/gff3_load') . '">GFF loader</a> provided here.  If you
                created the Chado database using Tripal then you\'ll most likely want to use the Tripal loaders.  If your data
-               is not condusive for loading with these loaders you may have to write your own loaders. 
+               is not condusive for loading with these loaders you may have to write your own loaders.
                </p></li>
 
                <li><p><b>Sync Features</b>:  After data is loaded you need to sync features.  This process is what
                creates the pages for viewing online.  Not all features need be synced.  For instance, if you
                have loaded whole genome sequence with fully defined gene models with several features to define
                a gene and its products (e.g. gene, mRNA, CDS, 5\'UTR, 3\'UTR, etc) you probably only want to create
-               pages for genes or genes and mRNA.  You probably do not want a page for a 5\'UTR.  
-               Using the <a href="'.url('admin/tripal/tripal_feature/configuration/sync').'">Feature Sync page</a> 
+               pages for genes or genes and mRNA.  You probably do not want a page for a 5\'UTR.
+               Using the <a href="' . url('admin/tripal/tripal_feature/configuration/sync') . '">Feature Sync page</a>
                you can sync (or create pages) for the desired feature types. </p></li>
 
-               <li><p><b>Set Feature URL</b>:  It is often convenient to have a simple URL for each feature page. 
+               <li><p><b>Set Feature URL</b>:  It is often convenient to have a simple URL for each feature page.
                For example, http://www.mygenomesite.org/[feature], where [feature] is a unique identifier for a feature page.
-               With this, people can easily include links to feature pages of interest. Use the 
-               <a href="'.url('admin/tripal/tripal_feature/configuration').'">Feature Configuration page</a> 
+               With this, people can easily include links to feature pages of interest. Use the
+               <a href="' . url('admin/tripal/tripal_feature/configuration') . '">Feature Configuration page</a>
                to specify whether to use the feature name, unique name or internal ID as the [feature] portion of the
                URL.  Select the one that will guarantee a unique identifier for feature pages.</p></li>
 
                <li><p><b>Indexing</b>:  Once all data has been loaded (including analysis data--e.g. blast, interpro, etc.)
-               you can index all feature pages for searching if you want to ues the Drupal default search mechanism. 
-               Use the <a href="'.url('admin/tripal/tripal_feature/configuration').'">Feature Configuration page</a> 
+               you can index all feature pages for searching if you want to ues the Drupal default search mechanism.
+               Use the <a href="' . url('admin/tripal/tripal_feature/configuration') . '">Feature Configuration page</a>
                to either Index (for the first time) or "Reindex" (after adding new data)
                the feature pages for searching.  Once the site is 100% indexed the pages will be searchable using Drupal\'s
-               full text searching.  You can find the percent indexed for the entire site by visiting the 
-               <a href="'.url('admin/settings/search').'">Search settings page</a>. Indexing
+               full text searching.  You can find the percent indexed for the entire site by visiting the
+               <a href="' . url('admin/settings/search') . '">Search settings page</a>. Indexing
                can take quite a while if you have a lot of data</p></li>
 
-               <li><p><b>Set Taxonomy</b>:  Drupal provides a mechanism for categorizing content to allow 
-               for advanced searching.  Drupal calls this "Taxonomy", but is essentially categorizing the pages.  
-               You can categorize feature pages by their type (e.g. gene, mRNA, contig, EST, etc.) and by the 
-               organism to which they belong.  This allows for filtering of search results by organism and feature type. 
-               Use the <a href="'.url('admin/tripal/tripal_feature/configuration').'">Feature Configuration page</a> to
+               <li><p><b>Set Taxonomy</b>:  Drupal provides a mechanism for categorizing content to allow
+               for advanced searching.  Drupal calls this "Taxonomy", but is essentially categorizing the pages.
+               You can categorize feature pages by their type (e.g. gene, mRNA, contig, EST, etc.) and by the
+               organism to which they belong.  This allows for filtering of search results by organism and feature type.
+               Use the <a href="' . url('admin/tripal/tripal_feature/configuration') . '">Feature Configuration page</a> to
                set the Taxonomy.</p></li>
             </ol>
             </p>';
-  
-  
+
+
   $text .= '<h3>Features of this Module:</h3>';
-  $text .= '<p>Aside from data loading and feature page setup (as described in the Setup section above), 
+  $text .= '<p>Aside from data loading and feature page setup (as described in the Setup section above),
             The Tripal feature module also provides the following functionality
             <ul>
-              <li><p><b>Feature Browser:</b>  The feature browser is a tabular list of features with links to their 
-               feature pages which appears on the organism 
+              <li><p><b>Feature Browser:</b>  The feature browser is a tabular list of features with links to their
+               feature pages which appears on the organism
                page.  It was created to provide a mechanism to allow site visitors to quickly
                accesss feature pages when they do not know what to search for.  For sites with large numbers of features, this
-               method for finding a specific pages is inadequate, but may still be included to aid new site 
-               visitors.    This browser can be toggled on or off using the 
-               <a href="'.url('admin/tripal/tripal_feature/configuration').'">Feature Configuration page</a></p></li>
- 
+               method for finding a specific pages is inadequate, but may still be included to aid new site
+               visitors.    This browser can be toggled on or off using the
+               <a href="' . url('admin/tripal/tripal_feature/configuration') . '">Feature Configuration page</a></p></li>
+
               <li><p><b>Feature Summary Report:</b>  The feature summary report is a pie chart that indicates the types and quantities
-              of feature types (Sequence Ontology terms) that are loaded in the database. It appears on the organism 
-              page.  The summary can be toggled on or off using the 
-              <a href="'.url('admin/tripal/tripal_feature/configuration').'">Feature Configuration page</a></p></li>             
+              of feature types (Sequence Ontology terms) that are loaded in the database. It appears on the organism
+              page.  The summary can be toggled on or off using the
+              <a href="' . url('admin/tripal/tripal_feature/configuration') . '">Feature Configuration page</a></p></li>
 
               <li><p><b>Integration with Drupal Views</b>: <a href="http://drupal.org/project/views">Drupal Views</a> is
               a powerful tool that allows the site administrator to create lists or basic searching forms of Chado content.
@@ -136,56 +136,56 @@ function tripal_feature_module_description_page() {
               and create custom lists without PHP programming or customization of Tripal source code.  Views can also
               be created to filter content that has not yet been synced with Druapl in order to protect access to non
               published data (only works if Chado was installed using Tripal).  You can see a list of available pre-existing
-              Views <a href="'.url('admin/build/views/').'">here</a>, as well as create your own. </p></li>
+              Views <a href="' . url('admin/build/views/') . '">here</a>, as well as create your own. </p></li>
 
-              <li><p><b>Basic Feature Lookup View</b>: This module provides a basic <a href="'.url('features').'">feature search 
+              <li><p><b>Basic Feature Lookup View</b>: This module provides a basic <a href="' . url('features') . '">feature search
               tool</a> for finding or listing features in Chado. It does not require indexing for Drupal searching but relies
-              on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a> must be installed. </p></li>              
+              on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a> must be installed. </p></li>
 
-              <li><p><b>Delete Features</b>: This module provides a <a href="'.url('admin/tripal/tripal_feature/delete').'">Delete Feature page</a>
+              <li><p><b>Delete Features</b>: This module provides a <a href="' . url('admin/tripal/tripal_feature/delete') . '">Delete Feature page</a>
               for bulk deltions of features. You may delete features using a list of feature names, or for a specific organism
-              or for a specific feature type.</p></li>              
+              or for a specific feature type.</p></li>
 
             </ul>
             </p>';
 
    $text .= '<h3>Page Customizations</h3>';
-   $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal. 
+   $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
              Below is a description of several methods.  These methods may be used in conjunction with one another to
-             provide fine-grained control. 
+             provide fine-grained control.
              <ul>
 
-             <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a> 
-              allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming.  Tripal comes with pre-set layouts for feature pages.  However, 
+             <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a>
+              allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming.  Tripal comes with pre-set layouts for feature pages.  However,
               Panels become useful if you prefer a layout that is different from the pre-set layouts.  Chado content
-              is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the 
+              is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the
               Panel\'s GUI.</p></li>
 
-             <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the 
+             <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the
              <a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a> is a powerful way to add non-Chado content
              to any page without need to edit template files or knowing PHP.  You must first download and install CCK.
              With CCK, the site administartor can create a new field to appear on the page.  For example, currently,
-             the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text 
+             the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text
              field to the feature pages.  This content is not stored in Chado, but will appear on the feature page.  A field
              added by CCK will also appear in the form when editing a feature to allow users to manually enter the appropriate
              text.  If the default pre-set layout and themeing for Tripal is used, it is better to create the CCK element,
-             indicate that it is not to be shown (using the CCK interface), then manually add the new content type 
+             indicate that it is not to be shown (using the CCK interface), then manually add the new content type
              where desired by editing the templates (as described below).  If using Panels, the CCK field can be added to the
              location desired using the Panels interface.</p></li>
 
              <li><p><b>Drupal Node Templates</b>:  The Tripal packages comes with a "theme_tripal" directory that contains the
              themeing for Chado content.    The feature module has a template file for feature "nodes" (Tripal feature pages).  This file
              is named "node-chado_feature.tpl.php", and provides javascript, HTML and PHP code for display of the feature
-             pages.  You can edit this file to control which types of information (or which feature "blocks") are displayed for features. Be sure to 
+             pages.  You can edit this file to control which types of information (or which feature "blocks") are displayed for features. Be sure to
              copy these template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
              future Tripal updates may overwrite your customizations. See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
              for instructions on how to access variables and other Chado content within the template file.</p></li>
 
              <li><p><b>Feature "Block" Templates</b>:  In the "theme_tripal" directory is a subdirectory named "tripal_feature".
              Inside this directory is a set of templates that control distinct types of information for features.  For example,
-             there is a "base" template for displaying of data directly from the Chado feature table, and a "references" 
+             there is a "base" template for displaying of data directly from the Chado feature table, and a "references"
              template for showing external site references for a feature (data from the feature_dbxref table).  These templates are used both by Drupal blocks
-             for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template 
+             for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template
              provides (also desribed above).  You can customize this template as you desire.  Be sure to copy the
              template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
              future Tripal updates may overwrite your customizations.  See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
@@ -194,9 +194,9 @@ function tripal_feature_module_description_page() {
 
              <li><p><b>Adding Links to the "Resources" Sidebar</b>: If you use the pre-set default Tripal layout for theming, you
              will see a "Resources" sidebar on each page.  The links that appear on the sidebar are automatically generated
-             using Javascript for all of the feature "Blocks" that appear on the page. If you want to add additional links 
-             (e.g. a dynamic link to GBrowse for the feature) and you want that link to appear in the 
-             "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the 
+             using Javascript for all of the feature "Blocks" that appear on the page. If you want to add additional links
+             (e.g. a dynamic link to GBrowse for the feature) and you want that link to appear in the
+             "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the
              section at the bottom of the template file where the resources section is found.</p></li>
 
              </ul>
@@ -210,16 +210,16 @@ function tripal_feature_module_description_page() {
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_admin () {
+function tripal_feature_admin() {
 
    // before proceeding check to see if we have any
    // currently processing jobs. If so, we don't want
    // to give the opportunity to sync libraries
    $active_jobs = FALSE;
-   if(tripal_get_module_active_jobs('tripal_feature')){
+   if (tripal_get_module_active_jobs('tripal_feature')) {
       $active_jobs = TRUE;
    }
-   if(!$active_jobs){
+   if (!$active_jobs) {
 
       get_tripal_feature_admin_form_url_set($form);
 
@@ -229,7 +229,7 @@ function tripal_feature_admin () {
          '#collapsible' => 1,
          '#collapsed' => 1 ,
       );
-      $allowedoptions1  = array (
+      $allowedoptions1  = array(
         'show_feature_browser' => "Show the feature browser on the organism page. The browser loads when page loads. This may be slow for large sites.",
         'hide_feature_browser' => "Hide the feature browser on the organism page. Disables the feature browser completely.",
       );
@@ -237,7 +237,7 @@ function tripal_feature_admin () {
 
       $form['browser']['browser_desc'] = array(
          '#type'        => 'markup',
-         '#value' => 'A feature browser can be added to an organism page to allow users to quickly '. 
+         '#value' => 'A feature browser can be added to an organism page to allow users to quickly '.
             'access a feature.  This will most likely not be the ideal mechanism for accessing feature '.
             'information, especially for large sites, but it will alow users exploring the site (such '.
             'as students) to better understand the data types available on the site.',
@@ -246,9 +246,9 @@ function tripal_feature_admin () {
       $form['browser']['feature_types'] = array(
          '#title'       => t('Feature Types'),
          '#type'        => 'textarea',
-         '#description' => t("Enter the Sequence Ontology (SO) terms for the feature types that ".
+         '#description' => t("Enter the Sequence Ontology (SO) terms for the feature types that " .
                              "will be shown in the feature browser."),
-         '#default_value' => variable_get('chado_browser_feature_types','gene contig'),
+         '#default_value' => variable_get('chado_browser_feature_types', 'gene contig'),
       );
 
 
@@ -256,9 +256,9 @@ function tripal_feature_admin () {
          '#title' => 'Feature Browser on Organism Page',
          '#type' => 'radios',
          '#options' => $allowedoptions1,
-         '#default_value'=>variable_get('tripal_feature_browse_setting', 'show_feature_browser'),
+         '#default_value' => variable_get('tripal_feature_browse_setting', 'show_feature_browser'),
       );
-      
+
       $form['browser']['browse_features_library'] = array(
          '#title' => 'Feature Browser on Library Page',
          '#type' => 'radios',
@@ -266,7 +266,7 @@ function tripal_feature_admin () {
           'show_feature_browser' => "Show the feature browse on the library page. The browser loads when page loads. This may be slow for large sites.",
           'hide_feature_browser' => "Hide the feature browser on the library page. Disables the feature browser completely.",
          ),
-         '#default_value'=>variable_get('tripal_library_feature_browse_setting', 'show_feature_browser'),
+         '#default_value' => variable_get('tripal_library_feature_browse_setting', 'show_feature_browser'),
       );
 
       $form['browser']['browse_features_analysis'] = array(
@@ -276,9 +276,9 @@ function tripal_feature_admin () {
           'show_feature_browser' => "Show the feature browse on the analysis page. The browser loads when page loads. This may be slow for large sites.",
           'hide_feature_browser' => "Hide the feature browser on the analysis page. Disables the feature browser completely.",
          ),
-         '#default_value'=>variable_get('tripal_analysis_feature_browse_setting', 'show_feature_browser'),
+         '#default_value' => variable_get('tripal_analysis_feature_browse_setting', 'show_feature_browser'),
       );
-      
+
       $form['browser']['set_browse_button'] = array(
          '#type' => 'submit',
          '#value' => t('Set Browser'),
@@ -305,7 +305,7 @@ function tripal_feature_admin () {
          '#title'       => t('Feature Types'),
          '#type'        => 'textarea',
          '#description' => t("Enter the Sequence Ontology (SO) terms for the allowed feature types when creating or editing features."),
-         '#default_value' => variable_get('chado_edit_feature_types','gene contig EST mRNA'),
+         '#default_value' => variable_get('chado_edit_feature_types', 'gene contig EST mRNA'),
       );
 
       $form['feature_edit']['set_feature_types'] = array(
@@ -328,7 +328,7 @@ function tripal_feature_admin () {
             'type and quantity of features available for the organism.',
          '#type' => 'radios',
          '#options' => $allowedoptions2,
-         '#default_value'=>variable_get('tripal_feature_summary_setting', 'show_feature_summary'),
+         '#default_value' => variable_get('tripal_feature_summary_setting', 'show_feature_summary'),
       );
       $form['summary']['feature_mapping'] = array(
          '#title' => 'Map feature types',
@@ -339,7 +339,7 @@ function tripal_feature_admin () {
             'SO term to be more human readable form, use an \'=\' sign after the SO term (e.g. \'polypeptide = Protein\')'),
          '#type' => 'textarea',
          '#rows' => 15,
-         '#default_value'=>variable_get('tripal_feature_summary_report_mapping', ''),
+         '#default_value' => variable_get('tripal_feature_summary_report_mapping', ''),
       );
       $form['summary']['set_summary_button'] = array(
          '#type' => 'submit',
@@ -350,7 +350,8 @@ function tripal_feature_admin () {
       get_tripal_feature_admin_form_taxonomy_set($form);
       get_tripal_feature_admin_form_reindex_set($form);
       get_tripal_feature_admin_form_cleanup_set($form);
-   } else {
+   }
+   else {
       $form['notice'] = array(
          '#type' => 'fieldset',
          '#title' => t('Feature Management Temporarily Unavailable')
@@ -375,51 +376,51 @@ function tripal_feature_admin_validate($form, &$form_state) {
    global $user;  // we need access to the user info
    $job_args = array();
 
-   variable_set('chado_browser_feature_types',$form_state['values']['feature_types']);
+   variable_set('chado_browser_feature_types', $form_state['values']['feature_types']);
 
    // if the user wants to sync up the chado features then
    // add the job to the management queue
-   switch ($form_state['values']['op']){
+   switch ($form_state['values']['op']) {
 
       case  t('Sync all Features') :
-         tripal_add_job('Sync all features','tripal_feature',
-            'tripal_feature_sync_features',$job_args,$user->uid);
+         tripal_add_job('Sync all features', 'tripal_feature',
+            'tripal_feature_sync_features', $job_args, $user->uid);
          break;
 
       case t('Set/Reset Taxonomy for all feature nodes') :
-         tripal_add_job('Set all feature taxonomy','tripal_feature',
-            'tripal_features_set_taxonomy',$job_args,$user->uid);
+         tripal_add_job('Set all feature taxonomy', 'tripal_feature',
+            'tripal_features_set_taxonomy', $job_args, $user->uid);
          break;
 
       case t('Reindex all feature nodes') :
-         tripal_add_job('Reindex all features','tripal_feature',
-            'tripal_features_reindex',$job_args,$user->uid);
+         tripal_add_job('Reindex all features', 'tripal_feature',
+            'tripal_features_reindex', $job_args, $user->uid);
          break;
 
       case t('Clean up orphaned features') :
-         tripal_add_job('Cleanup orphaned features','tripal_feature',
-            'tripal_features_cleanup',$job_args,$user->uid);
+         tripal_add_job('Cleanup orphaned features', 'tripal_feature',
+            'tripal_features_cleanup', $job_args, $user->uid);
          break;
 
       case t('Set Browser') :
-         variable_set('tripal_feature_browse_setting',$form_state['values']['browse_features']);
+         variable_set('tripal_feature_browse_setting', $form_state['values']['browse_features']);
          variable_set('tripal_library_feature_browse_setting', $form_state['values']['browse_features_library']);
          variable_set('tripal_analysis_feature_browse_setting', $form_state['values']['browse_features_analysis']);
          break;
 
       case t('Set Feature Types') :
-         variable_set('tripal_feature_type_setting',$form_state['values']['feature_edit_types']);
+         variable_set('tripal_feature_type_setting', $form_state['values']['feature_edit_types']);
          break;
 
       case t('Set Summary') :
-         variable_set('tripal_feature_summary_setting',$form_state['values']['feature_summary']);
-         variable_set('tripal_feature_summary_report_mapping',$form_state['values']['feature_mapping']);
+         variable_set('tripal_feature_summary_setting', $form_state['values']['feature_summary']);
+         variable_set('tripal_feature_summary_report_mapping', $form_state['values']['feature_mapping']);
          break;
 
       case t('Set Feature URLs') :
-         variable_set('chado_feature_url',$form_state['values']['feature_url']);
-         tripal_add_job('Set Feature URLs','tripal_feature',
-            'tripal_feature_set_urls',$job_args,$user->uid);
+         variable_set('chado_feature_url', $form_state['values']['feature_url']);
+         tripal_add_job('Set Feature URLs', 'tripal_feature',
+            'tripal_feature_set_urls', $job_args, $user->uid);
          break;
    }
 }
@@ -488,7 +489,7 @@ function get_tripal_feature_admin_form_reindex_set(&$form) {
  *
  * @ingroup tripal_feature
  */
-function get_tripal_feature_admin_form_taxonomy_set (&$form) {
+function get_tripal_feature_admin_form_taxonomy_set(&$form) {
 
 
    $form['taxonomy'] = array(
@@ -505,13 +506,13 @@ function get_tripal_feature_admin_form_taxonomy_set (&$form) {
           "filtering during searching."),
        '#weight' => 1,
    );
-   $tax_options = array (
+   $tax_options = array(
       'organism' => t('Organism name'),
       'feature_type'  => t('Feature Type (e.g. EST, mRNA, etc.)'),
       'analysis' => t('Analysis Name'),
       'library'  => t('Library Name'),
    );
-   $form['taxonomy']['tax_classes'] = array (
+   $form['taxonomy']['tax_classes'] = array(
      '#title'       => t('Available Taxonomic Classes'),
      '#type'        => t('checkboxes'),
      '#description' => t("Please select the class of terms to assign to ".
@@ -521,7 +522,7 @@ function get_tripal_feature_admin_form_taxonomy_set (&$form) {
      '#suffix'      => '</div>',
      '#options'     => $tax_options,
      '#weight'      => 2,
-     '#default_value' => variable_get('tax_classes',''),
+     '#default_value' => variable_get('tax_classes', ''),
    );
    $form['taxonomy']['button'] = array(
       '#type' => 'submit',
@@ -531,13 +532,13 @@ function get_tripal_feature_admin_form_taxonomy_set (&$form) {
 
 }
 
-function get_tripal_feature_admin_form_url_set (&$form) {
+function get_tripal_feature_admin_form_url_set(&$form) {
 
    $form['url'] = array(
       '#type' => 'fieldset',
       '#title' => t('Feature URL Path')
    );
-   $form['url']['desc'] = array (
+   $form['url']['desc'] = array(
       '#type'        => 'markup',
       '#value' => t('Each synced feature will have a unique URL which consists of '.
                           'the site domain followed by a unique identifer: for '.
@@ -557,19 +558,19 @@ function get_tripal_feature_admin_form_url_set (&$form) {
                           'It only need be unique among the synced dataset.'),
       '#required'    => FALSE,
       '#options'     => array('internal ID' => 'internal ID (Chado feature_id)',
-                              'feature unique name' => 'feature unique name', 
+                              'feature unique name' => 'feature unique name',
                               'feature name' => 'feature name'),
-      '#default_value' => variable_get('chado_feature_url','internal ID'),
+      '#default_value' => variable_get('chado_feature_url', 'internal ID'),
    );
 
-   $form['url']['chado_feature_accession_prefix'] = array (
+   $form['url']['chado_feature_accession_prefix'] = array(
       '#title'       => t('ID Prefix'),
       '#type'        => t('textfield'),
       '#description' => t("If you choose an Internal ID above you must also enter an ID prefix.".
                           "this prefix will be prepended to the internal ID number (e.g. ID38294). ".
                           "if you chose to use the feature name or unique name then this prfix is not used"),
       '#required'    => TRUE,
-      '#default_value' => variable_get('chado_feature_accession_prefix','ID'),
+      '#default_value' => variable_get('chado_feature_accession_prefix', 'ID'),
    );
 
    $form['url']['button'] = array(
@@ -583,9 +584,9 @@ function get_tripal_feature_admin_form_url_set (&$form) {
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_aggregator_page(){
+function tripal_feature_aggregator_page() {
    $add_url = url("admin/tripal/tripal_feature/aggregate/new");
-   $output = "<a href=\"$add_url\">Add a new aggregator</a>"; 
+   $output = "<a href=\"$add_url\">Add a new aggregator</a>";
    $output .= drupal_get_form('tripal_feature_aggregator_select_form');
    $output .= '<div id="db-edit-div">Please select an aggregator base type to view or edit</div>';
    return $output;
@@ -596,23 +597,23 @@ function tripal_feature_aggregator_page(){
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_aggregator_select_form(){
+function tripal_feature_aggregator_select_form() {
+
+  // get a list of base terms from chado for user to choose
+  $sql = "SELECT DISTINCT type_id FROM {tripal_feature_relagg} ORDER BY type_id ";
+  $results = db_query($sql);
 
-	// get a list of base terms from chado for user to choose
-	$sql = "SELECT DISTINCT type_id FROM {tripal_feature_relagg} ORDER BY type_id ";
-	$results = db_query ($sql);
-   
    $sql = "SELECT * FROM {cvterm} WHERE cvterm_id = %d";
    $previous_db = tripal_db_set_active('chado');
-	$types = array();
+  $types = array();
    $types[] = '';
-   while($base = db_fetch_object($results)){
-      $term = db_fetch_object(db_query($sql,$base->type_id));
-		$types[$base->type_id] = $term->name;
+   while ($base = db_fetch_object($results)) {
+      $term = db_fetch_object(db_query($sql, $base->type_id));
+    $types[$base->type_id] = $term->name;
    }
    tripal_db_set_active($previous_db);
 
-	$form['type_id'] = array(
+  $form['type_id'] = array(
       '#title' => t('Aggregator Base Type'),
       '#type' => 'select',
       '#options' => $types,
@@ -623,7 +624,7 @@ function tripal_feature_aggregator_select_form(){
          'event' => 'change',
          'method' => 'replace',
       ),
-	);
+  );
 
    return $form;
 }
@@ -633,28 +634,29 @@ function tripal_feature_aggregator_select_form(){
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_aggregator_form(&$form_state = NULL,$type_id = NULL){
+function tripal_feature_aggregator_form(&$form_state = NULL, $type_id = NULL) {
 
    // get this requested database
-   if($type_id){
+   if ($type_id) {
       $sql = "SELECT * FROM {tripal_feature_relagg} WHERE type_id = %d ";
       $tsql = "SELECT * FROM {cvterm} WHERE cvterm_id = %d ";
 
       // get the default list of terms
-      $results = db_query($sql,$type_id);
-      while($type = db_fetch_object($results)){
+      $results = db_query($sql, $type_id);
+      while ($type = db_fetch_object($results)) {
          $previous_db = tripal_db_set_active('chado');
-         $term = db_fetch_object(db_query($tsql,$type->rel_type_id));
+         $term = db_fetch_object(db_query($tsql, $type->rel_type_id));
          tripal_db_set_active($previous_db);
          $default_others .= $term->name . " ";
       }
-      $default_base = $base->name;     
+      $default_base = $base->name;
       $action = 'Update';
       $form['type_id'] = array(
          '#type' => 'hidden',
          '#value' => $type_id
       );
-   } else {
+   }
+   else {
       $action = 'Add';
       $form['base']= array(
          '#type'          => 'textfield',
@@ -674,22 +676,23 @@ function tripal_feature_aggregator_form(&$form_state = NULL,$type_id = NULL){
       '#required'      => TRUE,
       '#weight'        => 2
    );
- 
-   if(strcmp($action,'Update')==0){
-      $form['update'] = array (
+
+   if (strcmp($action, 'Update')==0) {
+      $form['update'] = array(
         '#type'         => 'submit',
         '#value'        => t('Update'),
         '#weight'       => 5,
         '#executes_submit_callback' => TRUE,
       );
-      $form['delete'] = array (
+      $form['delete'] = array(
         '#type'         => 'submit',
         '#value'        => t('Delete'),
         '#weight'       => 6,
         '#executes_submit_callback' => TRUE,
       );
-   } else {
-      $form['add'] = array (
+   }
+   else {
+      $form['add'] = array(
         '#type'         => 'submit',
         '#value'        => t('Add'),
         '#weight'       => 5,
@@ -707,49 +710,49 @@ function tripal_feature_aggregator_form(&$form_state = NULL,$type_id = NULL){
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_aggregator_form_validate($form, &$form_state){
+function tripal_feature_aggregator_form_validate($form, &$form_state) {
    $type_id  = $form_state['values']['type_id'];
    $base     = $form_state['values']['base'];
    $others   = $form_state['values']['others'];
    $op      =  $form_state['values']['op'];
 
    // split apart the feature types to be aggregated
-   $types = preg_split('/\s+/',$others);
+   $types = preg_split('/\s+/', $others);
 
    // the SQL for finding the term
    $tsql = "
-      SELECT * 
-      FROM {cvterm} CVT 
-         INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id 
+      SELECT *
+      FROM {cvterm} CVT
+         INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
       WHERE CVT.name = '%s' and CV.name = 'sequence'";
 
 
    // make sure the base type exists
-   if($base){
+   if ($base) {
       $previous_db = tripal_db_set_active('chado');
-      $term = db_fetch_object(db_query($tsql,$base));
+      $term = db_fetch_object(db_query($tsql, $base));
       tripal_db_set_active($previous_db);
-      if(!$term){
-         form_set_error('base',t('The specified base type is not a valid SO term'));
+      if (!$term) {
+         form_set_error('base', t('The specified base type is not a valid SO term'));
       }
 
       // make sure this type doesn't already in the table
       $sql = "SELECT * FROM {tripal_feature_relagg} WHERE type_id = %d ";
-      $agg = db_fetch_object(db_query($sql,$term->cvterm_id));
-      if($agg){
-         form_set_error('base',t('The specified base type is already used as a base type for another aggregator and cannot be readded.'));
-      }      
+      $agg = db_fetch_object(db_query($sql, $term->cvterm_id));
+      if ($agg) {
+         form_set_error('base', t('The specified base type is already used as a base type for another aggregator and cannot be readded.'));
+      }
    }
 
    // iterate through each type to be aggregated and make sure they are valid
-   foreach($types as $type){
+   foreach ($types as $type) {
       $previous_db = tripal_db_set_active('chado');
-      $term = db_fetch_object(db_query($tsql,$type));
+      $term = db_fetch_object(db_query($tsql, $type));
       tripal_db_set_active($previous_db);
-      if(!$term){
-         form_set_error('others',t('The specified type ') . $type . t(' is not a valid SO term'));
+      if (!$term) {
+         form_set_error('others', t('The specified type ') . $type . t(' is not a valid SO term'));
       }
-   }   
+   }
 }
 
 /**
@@ -757,7 +760,7 @@ function tripal_feature_aggregator_form_validate($form, &$form_state){
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_aggregator_form_submit($form, &$form_state){
+function tripal_feature_aggregator_form_submit($form, &$form_state) {
 
    $type_id  = $form_state['values']['type_id'];
    $base     = $form_state['values']['base'];
@@ -765,13 +768,13 @@ function tripal_feature_aggregator_form_submit($form, &$form_state){
    $op      =  $form_state['values']['op'];
 
    // split apart the feature types to be aggregated
-   $types = preg_split('/\s+/',$others);
+   $types = preg_split('/\s+/', $others);
 
    // the SQL for finding the term
    $tsql = "
-      SELECT * 
-      FROM {cvterm} CVT 
-         INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id 
+      SELECT *
+      FROM {cvterm} CVT
+         INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
       WHERE CVT.name = '%s' and CV.name = 'sequence'";
 
    // the SQL for deleting an aggregator
@@ -782,43 +785,44 @@ function tripal_feature_aggregator_form_submit($form, &$form_state){
 
    // if this is an insert then we have a base type name.  We
    // need to get the corresponding term id
-   if($base){
+   if ($base) {
       $previous_db = tripal_db_set_active('chado');
-      $term = db_fetch_object(db_query($tsql,$base));
+      $term = db_fetch_object(db_query($tsql, $base));
       tripal_db_set_active($previous_db);
       $type_id = $term->cvterm_id;
    }
 
-   if(strcmp($op,'Delete')==0){
-      $result = db_query($dsql,$type_id);
-      if($result){
+   if (strcmp($op, 'Delete')==0) {
+      $result = db_query($dsql, $type_id);
+      if ($result) {
         drupal_set_message("Aggregator deleted");
-      } else {
+      }
+      else {
         drupal_set_message("Failed to delete mailing list.");
       }
    }
    else {
       // for an update, first remove all the current aggregator settings
       // and we'll add them again
-      $result = db_query($dsql,$type_id);
+      $result = db_query($dsql, $type_id);
 
       // the SQL for inserting the aggregated types
       $isql = "
          INSERT INTO {tripal_feature_relagg}
           (type_id,rel_type_id)
-         VALUES 
+         VALUES
           (%d,%d)
       ";
 
       // iterate through each type to be aggregated and add an entry in the table
-      foreach($types as $type){
+      foreach ($types as $type) {
          $previous_db = tripal_db_set_active('chado');
-         $term = db_fetch_object(db_query($tsql,$type));
+         $term = db_fetch_object(db_query($tsql, $type));
          tripal_db_set_active($previous_db);
-         $result = db_query($isql,$type_id,$term->cvterm_id);
+         $result = db_query($isql, $type_id, $term->cvterm_id);
       }
       drupal_set_message("Aggregator added");
-   } 
+   }
    return '';
 }
 
@@ -827,9 +831,9 @@ function tripal_feature_aggregator_form_submit($form, &$form_state){
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_aggregator_ajax_edit (){ 
+function tripal_feature_aggregator_ajax_edit() {
    // get the database id, build the form and then return the JSON object
    $type_id = $_POST['type_id'];
-   $form = drupal_get_form('tripal_feature_aggregator_form',$type_id);
+   $form = drupal_get_form('tripal_feature_aggregator_form', $type_id);
    drupal_json(array('status' => TRUE, 'data' => $form));
 }

+ 96 - 105
tripal_feature/tripal_feature.api.inc

@@ -1,5 +1,5 @@
 <?php
- 
+
 /**
  * Implements hook_chado_feature_schema()
  * Purpose: To add descriptions and foreign keys to default table description
@@ -21,21 +21,21 @@ function tripal_feature_chado_feature_schema() {
           'organism_id' => 'organism_id',
         ),
   );
-  
+
   $description['foreign keys']['dbxref'] = array(
         'table' => 'dbxref',
         'columns' => array(
           'dbxref_id' => 'dbxref_id',
         ),
   );
-  
+
   $description['foreign keys']['cvterm'] = array(
         'table' => 'cvterm',
         'columns' => array(
           'type_id' => 'cvterm_id',
         ),
   );
-  
+
   $referring_tables = array('analysisfeature',
     'element',
     'feature_cvterm',
@@ -80,14 +80,14 @@ function tripal_feature_chado_featureprop_schema() {
           'feature_id' => 'feature_id',
         ),
   );
-  
+
   $description['foreign keys']['cvterm'] = array(
         'table' => 'cvterm',
         'columns' => array(
           'type_id' => 'cvterm_id',
         ),
   );
-  
+
   $referring_tables = array('analysisfeature',
     'featureprop_pub',
   );
@@ -118,7 +118,7 @@ function tripal_feature_chado_featureloc_schema() {
           'srcfeature_id' => 'feature_id'
         ),
   );
-  
+
   $referring_tables = array('analysisfeature',
     'featureloc_pub',
   );
@@ -264,12 +264,12 @@ function tripal_feature_chado_feature_synonym_schema() {
  *    The feature ID for the analysis feature. This argument is optional but
  *    if specified it must also be accompanied with an analysis ID.
  * @param $analysisfeature_id
- *    The analysis feature ID for the analysis feature. This argument is 
- *    optional and can be used rather than specifying the $analysis_id and 
+ *    The analysis feature ID for the analysis feature. This argument is
+ *    optional and can be used rather than specifying the $analysis_id and
  *    $feature_id arguments.  If all three arguments are specified (e.g.
- *    an $analysis_id, $feature_id and $analysisfeature_id, then the 
+ *    an $analysis_id, $feature_id and $analysisfeature_id, then the
  *    $analysisfeature_id is used and the other two arguments are ignored.
- * @param $property 
+ * @param $property
  *    The cvterm name of the properties to retrieve
  * @param $cv_name
  *    Optional.  The name of the cv to which the property belongs.  By
@@ -280,28 +280,27 @@ function tripal_feature_chado_feature_synonym_schema() {
  *
  * @ingroup tripal_feature_api
  */
-function tripal_feature_analysis_get_property($analysis_id = NULL ,$feature_id = NUll, 
-   $analysisfeature_id = NULL, $property, $cv_name = 'tripal')
-{
-   
+function tripal_feature_analysis_get_property($analysis_id = NULL, $feature_id = NUll,
+   $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
+
    // check that the incoming arguments are correct
-   if(($analysis_id and !$feature_id) or
-       (!$analysis_id and $feature_id)){
-       watchdog('tripal_feature', 
-          'tripal_feature_analysis_get_property: Both an analysis ID and feature ID should be specified', 
-           array(), WATCHDOG_WARNING);       
+   if (($analysis_id and !$feature_id) or
+       (!$analysis_id and $feature_id)) {
+       watchdog('tripal_feature',
+          'tripal_feature_analysis_get_property: Both an analysis ID and feature ID should be specified',
+           array(), WATCHDOG_WARNING);
    }
 
    // get the analysisfeature_id if one is not provided
-   if(!$analysisfeature_id){
+   if (!$analysisfeature_id) {
       $columns = array('analysisfeature_id');
       $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
-      $result = tripal_core_chado_select('analysisfeature',$columns,$values);
+      $result = tripal_core_chado_select('analysisfeature', $columns, $values);
       $analysisfeature_id = $result[0]->analysisfeature_id;
    }
 
    // get the property.
-   return tripal_core_get_property('analysisfeature',$analysisfeature_id,$property,$cv_name);
+   return tripal_core_get_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
 }
 
 /**
@@ -314,10 +313,10 @@ function tripal_feature_analysis_get_property($analysis_id = NULL ,$feature_id =
  *    The feature ID for the analysis feature. This argument is optional but
  *    if specified it must also be accompanied with an analysis ID.
  * @param $analysisfeature_id
- *    The analysis feature ID for the analysis feature. This argument is 
- *    optional and can be used rather than specifying the $analysis_id and 
+ *    The analysis feature ID for the analysis feature. This argument is
+ *    optional and can be used rather than specifying the $analysis_id and
  *    $feature_id arguments.  If all three arguments are specified (e.g.
- *    an $analysis_id, $feature_id and $analysisfeature_id, then the 
+ *    an $analysis_id, $feature_id and $analysisfeature_id, then the
  *    $analysisfeature_id is used and the other two arguments are ignored.
  * @param $property
  *   The cvterm name of the property to insert
@@ -335,35 +334,34 @@ function tripal_feature_analysis_get_property($analysis_id = NULL ,$feature_id =
  * @ingroup tripal_feature_api
  */
 function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_id = NUll,
-   $analysisfeature_id = NULL, $property, $value, $update_if_present = 0, 
-   $cv_name = 'tripal')
-{
-   
+   $analysisfeature_id = NULL, $property, $value, $update_if_present = 0,
+   $cv_name = 'tripal') {
+
    // check that the incoming arguments are correct
-   if(($analysis_id and !$feature_id) or
-       (!$analysis_id and $feature_id)){
-       watchdog('tripal_feature', 
-          'tripal_feature_analysis_insert_property: Both an analysis ID and feature ID should be specified', 
-           array(), WATCHDOG_WARNING);       
+   if (($analysis_id and !$feature_id) or
+       (!$analysis_id and $feature_id)) {
+       watchdog('tripal_feature',
+          'tripal_feature_analysis_insert_property: Both an analysis ID and feature ID should be specified',
+           array(), WATCHDOG_WARNING);
    }
 
    // get the analysisfeature_id if one is not provided
-   if(!$analysisfeature_id){
+   if (!$analysisfeature_id) {
       $columns = array('analysisfeature_id');
       $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
-      $result = tripal_core_chado_select('analysisfeature',$columns,$values);
+      $result = tripal_core_chado_select('analysisfeature', $columns, $values);
       $analysisfeature_id = $result[0]->analysisfeature_id;
    }
 
    // insert the property.
-   return tripal_core_insert_property('analysisfeature',$analysisfeature_id,
-      $property,$cv_name,$value,$update_if_present);
+   return tripal_core_insert_property('analysisfeature', $analysisfeature_id,
+      $property, $cv_name, $value, $update_if_present);
 }
 
 /**
  * Update an analysis feature property using the property name. Use this
  * when a property only exists once for a given analysis feature.  When more
- * than one value can exist for the same property use the 
+ * than one value can exist for the same property use the
  * tripal_feature_analysis_update_property_by_id() function.
  *
  * @param $analysis_id
@@ -373,16 +371,16 @@ function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_i
  *    The feature ID for the analysis feature. This argument is optional but
  *    if specified it must also be accompanied with an analysis ID.
  * @param $analysisfeature_id
- *    The analysis feature ID for the analysis feature. This argument is 
- *    optional and can be used rather than specifying the $analysis_id and 
+ *    The analysis feature ID for the analysis feature. This argument is
+ *    optional and can be used rather than specifying the $analysis_id and
  *    $feature_id arguments.  If all three arguments are specified (e.g.
- *    an $analysis_id, $feature_id and $analysisfeature_id, then the 
+ *    an $analysis_id, $feature_id and $analysisfeature_id, then the
  *    $analysisfeature_id is used and the other two arguments are ignored.
  * @param $property
  *   The cvterm name of the property to update
  * @param $value
  *   The value of the property to update
- * @param $insert_if_missing 
+ * @param $insert_if_missing
  *   A boolean indicated whether to insert the record if it's absent
  * @param $cv_name
  *    Optional.  The name of the cv to which the property belongs.  By
@@ -396,36 +394,35 @@ function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_i
  *
  * @ingroup tripal_feature_api
  */
-function tripal_feature_analysis_update_property($analysis_id = NULL, $feature_id = NUll, 
-   $analysisfeature_id = NULL, $property, $value, $insert_if_missing = 0, 
-   $cv_name = 'tripal')
-{
-  
+function tripal_feature_analysis_update_property($analysis_id = NULL, $feature_id = NUll,
+   $analysisfeature_id = NULL, $property, $value, $insert_if_missing = 0,
+   $cv_name = 'tripal') {
+
    // check that the incoming arguments are correct
-   if(($analysis_id and !$feature_id) or
-       (!$analysis_id and $feature_id)){
-       watchdog('tripal_feature', 
-          'tripal_feature_analysis_update_property: Both an analysis ID and feature ID should be specified', 
-           array(), WATCHDOG_WARNING);       
+   if (($analysis_id and !$feature_id) or
+       (!$analysis_id and $feature_id)) {
+       watchdog('tripal_feature',
+          'tripal_feature_analysis_update_property: Both an analysis ID and feature ID should be specified',
+           array(), WATCHDOG_WARNING);
    }
 
    // get the analysisfeature_id if one is not provided
-   if(!$analysisfeature_id){
+   if (!$analysisfeature_id) {
       $columns = array('analysisfeature_id');
       $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
-      $result = tripal_core_chado_select('analysisfeature',$columns,$values);
+      $result = tripal_core_chado_select('analysisfeature', $columns, $values);
       $analysisfeature_id = $result[0]->analysisfeature_id;
    }
 
    // update the property.
-   return tripal_core_update_property('analysisfeature',$analysisfeature_id,$property,$cv_name,$value, $insert_if_missing);
+   return tripal_core_update_property('analysisfeature', $analysisfeature_id, $property, $cv_name, $value, $insert_if_missing);
 }
 
 /**
  * Update a property for an analysis feature using the analysisfeatureprop_id.
  *
  * @param $analysisfeatureprop_id
- *    The analysis feature property ID for the analysis feature. 
+ *    The analysis feature property ID for the analysis feature.
  * @param $property
  *   The cvterm name of the property
  * @param $value
@@ -439,17 +436,17 @@ function tripal_feature_analysis_update_property($analysis_id = NULL, $feature_i
  *
  * @ingroup tripal_feature_api
  */
-function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id, 
-   $property, $value, $cv_name = 'tripal')
-{  
+function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
+   $property, $value, $cv_name = 'tripal') {
+
    // update the property.
    return tripal_core_update_property_by_id('analysisfeature',
-      $analysisfeatureprop_id,$property,$cv_name,$value);
+      $analysisfeatureprop_id, $property, $cv_name, $value);
 }
 /**
  * Delete an analysis feature property using the property name.  Use this
  * when a property only exists once for a given analysis feature.  When more
- * than one value can exist for the same property use the 
+ * than one value can exist for the same property use the
  * tripal_feature_analysis_delete_property_by_id() function.
  *
  * @param $analysis_id
@@ -459,10 +456,10 @@ function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
  *    The feature ID for the analysis feature. This argument is optional but
  *    if specified it must also be accompanied with an analysis ID.
  * @param $analysisfeature_id
- *    The analysis feature ID for the analysis feature. This argument is 
- *    optional and can be used rather than specifying the $analysis_id and 
+ *    The analysis feature ID for the analysis feature. This argument is
+ *    optional and can be used rather than specifying the $analysis_id and
  *    $feature_id arguments.  If all three arguments are specified (e.g.
- *    an $analysis_id, $feature_id and $analysisfeature_id, then the 
+ *    an $analysis_id, $feature_id and $analysisfeature_id, then the
  *    $analysisfeature_id is used and the other two arguments are ignored.
  * @param $property
  *    The cvterm name of the property to delete
@@ -474,47 +471,45 @@ function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
  * and then it will be deleted
  *
  * @return
- *   True of success, False otherwise 
+ *   True of success, False otherwise
  *
  * @ingroup tripal_feature_api
  */
-function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_id = NUll, 
-   $analysisfeature_id = NULL, $property, $cv_name = 'tripal')
-{
+function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_id = NUll,
+   $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
    // check that the incoming arguments are correct
-   if(($analysis_id and !$feature_id) or
-       (!$analysis_id and $feature_id)){
-       watchdog('tripal_feature', 
-          'tripal_feature_analysis_delete_property: Both an analysis ID and feature ID should be specified', 
-           array(), WATCHDOG_WARNING);       
+   if (($analysis_id and !$feature_id) or
+       (!$analysis_id and $feature_id)) {
+       watchdog('tripal_feature',
+          'tripal_feature_analysis_delete_property: Both an analysis ID and feature ID should be specified',
+           array(), WATCHDOG_WARNING);
    }
 
    // get the analysisfeature_id if one is not provided
-   if(!$analysisfeature_id){
+   if (!$analysisfeature_id) {
       $columns = array('analysisfeature_id');
       $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
-      $result = tripal_core_chado_select('analysisfeature',$columns,$values);
+      $result = tripal_core_chado_select('analysisfeature', $columns, $values);
       $analysisfeature_id = $result[0]->analysisfeature_id;
    }
 
-   // get the property.   
-   return tripal_core_delete_property('analysisfeature',$analysisfeature_id,$property,$cv_name);
+   // get the property.
+   return tripal_core_delete_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
 }
 /**
  * Delete a property using the analysisfeatureprop_id
  *
  * @param $analysisfeatureprop_id
- *    The analysis feature property ID for the analysis feature. 
+ *    The analysis feature property ID for the analysis feature.
  *
  * @return
- *   True of success, False otherwise 
+ *   True of success, False otherwise
  *
  * @ingroup tripal_feature_api
  */
-function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id)
-{
-   // get the property.   
-   return tripal_core_delete_property_by_id('analysisfeature',$analysisfeatureprop_id);
+function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id) {
+   // get the property.
+   return tripal_core_delete_property_by_id('analysisfeature', $analysisfeatureprop_id);
 }
 /**
  * Retrieve properties of a given type for a given feature
@@ -532,9 +527,8 @@ function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id)
  *
  * @ingroup tripal_feature_api
  */
-function tripal_feature_get_property($feature_id,$property,$cv_name='tripal')
-{
-   return tripal_core_get_property('feature',$feature_id,$property,$cv_name);
+function tripal_feature_get_property($feature_id, $property, $cv_name='tripal') {
+   return tripal_core_get_property('feature', $feature_id, $property, $cv_name);
 }
 
 /**
@@ -558,8 +552,7 @@ function tripal_feature_get_property($feature_id,$property,$cv_name='tripal')
  * @ingroup tripal_feature_api
  */
 function tripal_feature_insert_property($feature_id, $property, $value,
-   $update_if_present = 0, $cv_name = 'tripal')
-{
+   $update_if_present = 0, $cv_name = 'tripal') {
     return tripal_core_insert_property('feature', $feature_id, $property,
        $cv_name, $value, $update_if_present);
 }
@@ -573,7 +566,7 @@ function tripal_feature_insert_property($feature_id, $property, $value,
  *   The cvterm name of the property to update
  * @param $value
  *   The value of the property to update
- * @param $insert_if_missing 
+ * @param $insert_if_missing
  *   A boolean indicated whether to insert the record if it's absent
  * @param $cv_name
  *   Optional.  The name of the cv to which the property belongs.  By
@@ -587,10 +580,9 @@ function tripal_feature_insert_property($feature_id, $property, $value,
  *
  * @ingroup tripal_feature_api
  */
-function tripal_feature_update_property($feature_id, $property, 
-  $value, $insert_if_missing = 0, $cv_name = 'tripal')
-{
-   return tripal_core_update_property('feature',$feature_id,$property,$cv_name,$value, $insert_if_missing);
+function tripal_feature_update_property($feature_id, $property,
+  $value, $insert_if_missing = 0, $cv_name = 'tripal') {
+   return tripal_core_update_property('feature', $feature_id, $property, $cv_name, $value, $insert_if_missing);
 }
 
 /**
@@ -611,10 +603,9 @@ function tripal_feature_update_property($feature_id, $property,
  *
  * @ingroup tripal_feature_api
  */
-function tripal_feature_update_property_by_id($featureprop_id, $property, 
-  $value, $cv_name = 'tripal')
-{
-   return tripal_core_update_property_by_id('feature',$featureprop_id,$property,$cv_name,$value);
+function tripal_feature_update_property_by_id($featureprop_id, $property,
+  $value, $cv_name = 'tripal') {
+   return tripal_core_update_property_by_id('feature', $featureprop_id, $property, $cv_name, $value);
 }
 
 /**
@@ -633,12 +624,12 @@ function tripal_feature_update_property_by_id($featureprop_id, $property,
  * and then it will be deleted
  *
  * @return
- *   True of success, False otherwise 
+ *   True of success, False otherwise
  *
  * @ingroup tripal_feature_api
  */
-function tripal_feature_delete_property($feature_id,$property,$cv_name='tripal'){
-   return tripal_core_delete_property('feature',$feature_id,$property,$cv_name);
+function tripal_feature_delete_property($feature_id, $property, $cv_name='tripal') {
+   return tripal_core_delete_property('feature', $feature_id, $property, $cv_name);
 }
 /**
  * Delete a given feature property using the featureprop_id
@@ -647,10 +638,10 @@ function tripal_feature_delete_property($feature_id,$property,$cv_name='tripal')
  *   The feature_id of the property to delete
  *
  * @return
- *   True of success, False otherwise 
+ *   True of success, False otherwise
  *
  * @ingroup tripal_feature_api
  */
-function tripal_feature_delete_property_by_id($featureprop_id){
-   return tripal_core_delete_property_by_id('feature',$featureprop_id);
+function tripal_feature_delete_property_by_id($featureprop_id) {
+   return tripal_core_delete_property_by_id('feature', $featureprop_id);
 }

+ 29 - 29
tripal_feature/tripal_feature.install

@@ -5,14 +5,14 @@
 *
 * @ingroup tripal_feature
 */
-function tripal_feature_install(){
+function tripal_feature_install() {
    // create the module's data directory
    tripal_create_moddir('tripal_feature');
 
-   // create the tables that correlate drupal nodes with chado 
+   // create the tables that correlate drupal nodes with chado
    // features, organisms, etc....
    drupal_install_schema('tripal_feature');
-  
+
    // add the materialized view
    tripal_feature_add_organism_count_mview();
 
@@ -23,13 +23,13 @@ function tripal_feature_install(){
 *
 * @ingroup tripal_feature
 */
-function tripal_feature_update_6000(){
+function tripal_feature_update_6000() {
    // recreate the materialized view
    tripal_feature_add_organism_count_mview();
    $ret = array(
       '#finished' => 1,
    );
-   
+
    return $ret;
 }
 
@@ -37,25 +37,25 @@ function tripal_feature_update_6000(){
 *
 * @ingroup tripal_feature
 */
-function tripal_feature_update_6300(){
+function tripal_feature_update_6300() {
    // add the relationship aggregator table to the database
    $schema = tripal_feature_get_schemas('tripal_feature_relagg');
    $ret = array();
    db_create_table($ret, 'tripal_feature_relagg', $schema['tripal_feature_relagg']);
-   
+
    return $ret;
 }
 /**
 *
 * @ingroup tripal_feature
 */
-function tripal_feature_add_organism_count_mview(){
+function tripal_feature_add_organism_count_mview() {
    $view_name = 'organism_feature_count';
 
    // Drop the MView table if it exists
    $mview_id = tripal_mviews_get_mview_id($view_name);
-   if($mview_id){
-      tripal_mviews_action("delete",$mview_id);
+   if ($mview_id) {
+      tripal_mviews_action("delete", $mview_id);
    }
 
    // Create the MView
@@ -75,12 +75,12 @@ function tripal_feature_add_organism_count_mview(){
       // columns for indexing
       'organism_id,cvterm_id,feature_type',
       // SQL statement to populate the view
-      'SELECT O.organism_id, O.genus, O.species, O.common_name, 
-          count(F.feature_id) as num_features, 
-          CVT.cvterm_id, CVT.name as feature_type 
-       FROM {Organism} O 
-          INNER JOIN Feature F           ON O.Organism_id = F.organism_id 
-          INNER JOIN Cvterm CVT          ON F.type_id = CVT.cvterm_id 
+      'SELECT O.organism_id, O.genus, O.species, O.common_name,
+          count(F.feature_id) as num_features,
+          CVT.cvterm_id, CVT.name as feature_type
+       FROM {Organism} O
+          INNER JOIN Feature F           ON O.Organism_id = F.organism_id
+          INNER JOIN Cvterm CVT          ON F.type_id = CVT.cvterm_id
        GROUP BY O.Organism_id, O.genus, O.species, O.common_name,
           CVT.cvterm_id, CVT.name',
       // special index
@@ -90,8 +90,8 @@ function tripal_feature_add_organism_count_mview(){
    // add a job to the job queue so this view gets updated automatically next
    // time the job facility is run
    $mview_id = tripal_mviews_get_mview_id($view_name);
-   if($mview_id){
-      tripal_mviews_action('update',$mview_id);
+   if ($mview_id) {
+      tripal_mviews_action('update', $mview_id);
    }
 }
 /**
@@ -108,19 +108,19 @@ function tripal_feature_schema() {
 *
 * @ingroup tripal_feature
 */
-function tripal_feature_uninstall(){
+function tripal_feature_uninstall() {
 
    // Drop the MView table if it exists
    $mview_id = tripal_mviews_get_mview_id('organism_feature_count');
-   if($mview_id){
-      tripal_mviews_action("delete",$mview_id);
+   if ($mview_id) {
+      tripal_mviews_action("delete", $mview_id);
    }
 
    drupal_uninstall_schema('tripal_feature');
 
    // Get the list of nodes to remove
-   $sql_feature_id = "SELECT nid, vid ".
-                 "FROM {node} ".
+   $sql_feature_id = "SELECT nid, vid " .
+                 "FROM {node} " .
                  "WHERE type='chado_feature'";
    $result = db_query($sql_feature_id);
    while ($node = db_fetch_object($result)) {
@@ -130,35 +130,35 @@ function tripal_feature_uninstall(){
 
 /**
 * This function simply defines all tables needed for the module to work
-* correctly.  By putting the table definitions in a separate function we 
+* correctly.  By putting the table definitions in a separate function we
 * can easily provide the entire list for hook_install or individual
 * tables for an update.
 *
 * @ingroup tripal_feature
 */
-function tripal_feature_get_schemas ($table = NULL){  
+function tripal_feature_get_schemas($table = NULL) {
   $schema = array();
 
 
-  if(!$table or strcmp($table,'chado_feature')==0){
+  if (!$table or strcmp($table, 'chado_feature')==0) {
      $schema['chado_feature'] = array(
          'fields' => array(
             'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
             'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
             'feature_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
-            'sync_date' => array ('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer sync date/time'),
+            'sync_date' => array('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer sync date/time'),
          ),
          'indexes' => array(
             'feature_id' => array('feature_id')
           ),
          'unique keys' => array(
-            'nid_vid' => array('nid','vid'),
+            'nid_vid' => array('nid', 'vid'),
             'vid' => array('vid')
          ),
          'primary key' => array('nid'),
      );
   }
-  if(!$table or strcmp($table,'tripal_feature_relagg')==0){
+  if (!$table or strcmp($table, 'tripal_feature_relagg')==0) {
      $schema['tripal_feature_relagg'] = array(
         'fields' => array(
            'type_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),

File diff suppressed because it is too large
+ 222 - 219
tripal_feature/tripal_feature.module


+ 11 - 11
tripal_feature/tripal_feature.views.inc

@@ -6,7 +6,7 @@
  *  chado/tripal organism tables. Supplementary functions can be found in
  *  ./views/
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
@@ -15,7 +15,7 @@
  * @ingroup views
  * @ingroup tripal_feature
  */
- 
+
 /**
  * Implements hook_views_data()
  *
@@ -23,7 +23,7 @@
  *
  * @return: a data array which follows the structure outlined in the
  *   views2 documentation for this hook. Essentially, it's an array of table
- *   definitions keyed by chado/tripal table name. Each table definition 
+ *   definitions keyed by chado/tripal table name. Each table definition
  *   includes basic details about the table, fields in that table and
  *   relationships between that table and others (joins)
  *
@@ -34,11 +34,11 @@ require_once('views/chado_feature.views.inc');
 require_once('views/misc_tables.views.inc');
 function tripal_feature_views_data()  {
   $data = array();
-  
+
   $data = array_merge($data, retrieve_feature_views_data());
   $data = array_merge($data, retrieve_chado_feature_views_data());
   $data = array_merge($data, retrieve_feature_misc_tables_views_data());
-  
+
   return $data;
 }
 
@@ -46,7 +46,7 @@ function tripal_feature_views_data()  {
  * Implements hook_views_handlers()
  *
  * Purpose: Register all custom handlers with views
- *   where a handler describes either "the type of field", 
+ *   where a handler describes either "the type of field",
  *   "how a field should be filtered", "how a field should be sorted"
  *
  * @return: An array of handler definitions
@@ -74,7 +74,7 @@ function tripal_feature_views_handlers() {
  */
 function tripal_feature_views_data_alter(&$data) {
 
-  if( !(is_array($db_url) and array_key_exists('chado',$db_url)) ){
+  if ( !(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
 
     // Add featuer relationship to node
     $data['node']['feature_chado_nid'] = array(
@@ -92,16 +92,16 @@ function tripal_feature_views_data_alter(&$data) {
       ),
     );
   }
-  
+
 }
 
 /**
  *
  * @ingroup tripal_feature_views
  */
-function tripal_feature_views_default_views () {
+function tripal_feature_views_default_views() {
   $views = array();
-  
+
   // Main default view
   // List all cvterms based on cv
   $view = new view;
@@ -431,6 +431,6 @@ function tripal_feature_views_default_views () {
     'name' => 'navigation',
   ));
   $views[$view->name] = $view;
-  
+
   return $views;
 }

+ 23 - 22
tripal_feature/views/chado_feature.views.inc

@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Purpose: this function returns the portion of the data array 
+ * @file
+ * Purpose: this function returns the portion of the data array
  *   which describes the chado_feature drupal table, it's fields and any joins between it and other tables
  * @see tripal_feature_views_data() --in tripal_feature.views.inc
  *
@@ -9,14 +10,14 @@
  *
  * @ingroup tripal_feature_views
  */
-function retrieve_chado_feature_views_data () {
-	global $db_url;
+function retrieve_chado_feature_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;
   }
@@ -26,43 +27,43 @@ function retrieve_chado_feature_views_data () {
     '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,
+       'handler' => 'views_handler_field_numeric',
+       'click sortable' => TRUE,
     ),
     'filter' => array(
-     	'handler' => 'views_handler_filter_numeric',
+       'handler' => 'views_handler_filter_numeric',
     ),
     'sort' => array(
-     	'handler' => 'views_handler_sort',
+       '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',
+    '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',
+    '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',
+    'left_table' => 'chado_feature',
+    'left_field' => 'nid',
+    'field' => 'nid',
   );
-  
+
   // Add relationship between chado_feature and feature
   $data['chado_feature']['feature_nid'] = array(
     'group' => 'Feature',
@@ -95,5 +96,5 @@ function retrieve_chado_feature_views_data () {
     ),
   );
 
-	return $data;
+  return $data;
 }

+ 38 - 36
tripal_feature/views/feature.views.inc

@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Purpose: this function returns the portion of the data array 
+ * @file
+ * Purpose: this function returns the portion of the data array
  *   which describes the feature table, it's fields and any joins between it and other tables
  * @see tripal_feature_views_data() --in tripal_feature.views.inc
  *
@@ -36,17 +37,17 @@
  * @ingroup tripal_feature_views
  */
  function retrieve_feature_views_data() {
-	global $db_url;
-	$data = array();
-	
+  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)) {
      $database = 'chado';
   }
 
-	
+
    // Basic table definition
    $data['feature']['table']['group'] = 'Chado Feature';
    $data['feature']['table']['base'] = array(
@@ -55,17 +56,17 @@
      'help' => 'Features are Sequence Data Records in Chado.',
    );
 
-	if($database){
-		$data['feature']['table']['base']['database'] = $database;
-	}
-	
+  if ($database) {
+    $data['feature']['table']['base']['database'] = $database;
+  }
+
 
   //Relationship Definitions---------------------------------
   //Join: feature => nd_reagent
   $data['feature']['table']['join']['nd_reagent'] = array(
     'left_field' => 'feature_id',
     'field' => 'feature_id',
-  );  
+  );
 
   // Table Field Definitions----------------------
   // Field: feature_id (primary key)
@@ -73,29 +74,30 @@
     'title' => 'Feature ID',
     'help' => 'The primary key of a feature',
     'field' => array(
-     	'handler' => 'views_handler_field_numeric',
- 		  'click sortable' => TRUE,
+       'handler' => 'views_handler_field_numeric',
+       'click sortable' => TRUE,
     ),
     'filter' => array(
-     	'handler' => 'views_handler_filter_numeric',
+       'handler' => 'views_handler_filter_numeric',
     ),
     'sort' => array(
-     	'handler' => 'views_handler_sort',
+       'handler' => 'views_handler_sort',
     ),
   );
 
   // 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){
-  	$data['feature']['feature_nid'] = array(
-    	'title' => 'Node ID',
-			'help' => 'This is the node ID of this feature. It can be used as a link to the node.',
-    	'field' => array(
-      	'handler' => 'views_handler_field_computed_feature_nid',
+  if ($database) {
+    $data['feature']['feature_nid'] = array(
+      'title' => 'Node ID',
+      'help' => 'This is the node ID of this feature. It can be used as a link to the node.',
+      'field' => array(
+        'handler' => 'views_handler_field_computed_feature_nid',
       ),
-  	);
-  } else {
+    );
+  }
+  else {
     // Add relationship between chado_feature and feature
     $data['feature']['feature_nid'] = array(
       'group' => 'Feature',
@@ -113,16 +115,16 @@
     );
 
   }
-  
+
   // Field: organism_id (forgeign key)
   //  join between organism table and this one in tripal_organism/views/organism.views.inc
-  
+
   // Field: dbxref_id (forgeign key)
   //  join between dbxref table and this one in tripal_db/views/dbxref.views.inc
-  
+
   // Field: type_id (forgeign key)
   //  join between cvterm table and this one in tripal_cv/views/cvterm.views.inc
-  
+
   // Field: name (varchar 255)
   $data['feature']['name'] = array(
     'title' => 'Name',
@@ -141,7 +143,7 @@
       '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 && module_exists('tripal_views')) {
     $data['feature']['name']['field']['handler'] = 'views_handler_field_node_optional';
   }
@@ -164,7 +166,7 @@
       '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 && module_exists('tripal_views')) {
     $data['feature']['uniquename']['field']['handler'] = 'views_handler_field_node_optional';
   }
@@ -273,14 +275,14 @@
   // Calculated Field: Number of Analysis' (Count -Int)
   // Provides the number of analysis' for a given feature
   // @see tripal_analysis/views/misc_tables.views.inc
-  
+
   //Calculated Field: Number of Libraries (Count -Int)
   // Provides the number of libraries for a given feature
-  // @see tripal_library/views/misc_tables.views.inc 
+  // @see tripal_library/views/misc_tables.views.inc
 
-	// Calculated Field: feature relationships
-	// uses a custom field handler which pulls results from the view
-	$data['feature']['relationships'] = array(
+  // Calculated Field: feature relationships
+  // uses a custom field handler which pulls results from the view
+  $data['feature']['relationships'] = array(
     'title' => t('Feature Relationships'),
     'help' => t('Relationships including the current feature.'),
     'field' => array(
@@ -288,7 +290,7 @@
       'help' => t('Display a given type of relationships including the current feature.'),
       'handler' => 'views_handler_field_chado_rel_by_type',
     ),
-  ); 
-  
+  );
+
   return $data;
  }

+ 12 - 12
tripal_feature/views/handlers/views_handler_field_computed_feature_nid.inc

@@ -7,17 +7,17 @@
  * @ingroup views_field_handlers
  */
 class views_handler_field_computed_feature_nid extends views_handler_field_numeric {
-	function construct() {
-		parent::construct();
-		$this->additional_fields['feature_id'] = array('table' => 'feature', 'field' => 'feature_id');
-	}
+  function construct() {
+    parent::construct();
+    $this->additional_fields['feature_id'] = array('table' => 'feature', 'field' => 'feature_id');
+  }
 
-	function query() { 
-		$this->ensure_my_table();
-		$this->add_additional_fields(); 
-	}
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
 
-	function render($values) { 
-		return $values->feature_nid;
-	}
-} 
+  function render($values) {
+    return $values->feature_nid;
+  }
+}

+ 8 - 8
tripal_feature/views/handlers/views_handler_field_residues.inc

@@ -7,19 +7,19 @@
  */
 class views_handler_field_residues extends views_handler_field {
 
-	function construct() {
-		parent::construct();
+  function construct() {
+    parent::construct();
       $this->additional_fields['residues'] = array('table' => 'feature', 'field' => 'residues');
-	}
+  }
 
-	function query() { 
-		$this->ensure_my_table();
-		$this->add_additional_fields(); 
-	}
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
 
   function render($values) {
     // add a <br> every 100 bp
-    return ereg_replace("(.{100})","\\1<br>",$values->feature_residues);
+    return ereg_replace("(.{100})", "\\1<br>", $values->feature_residues);
 
   }
 }

+ 7 - 6
tripal_feature/views/misc_tables.views.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Purpose: Allows the feature module to add fields to other module views
  *
  *   For example, a field counting the number of features associted with a given organism would be
@@ -13,14 +14,14 @@
           'handler' => 'views_handler_field_chado_count',
           'table_to_query' => 'feature',
         ),
-      ); 
+      );
  *   @endcode
  *
  * @ingroup tripal_feature_views
  */
 function retrieve_feature_misc_tables_views_data() {
   $data = array();
- 
+
   // Table: Organism--------------------------------------------------------------------------------
   // Calculated Field: Number of features (Count -Int)
   // Provides the number of features for a given organism
@@ -31,7 +32,7 @@ function retrieve_feature_misc_tables_views_data() {
       'handler' => 'views_handler_field_chado_count',
       'table_to_query' => 'feature',
     ),
-  );  
+  );
 
   // Table: Library---------------------------------------------------------------------------------
   // Calculated Field: Number of features (Count -Int)
@@ -43,7 +44,7 @@ function retrieve_feature_misc_tables_views_data() {
       'handler' => 'views_handler_field_chado_count',
       'table_to_query' => 'library_feature',
     ),
-  );   
+  );
 
   // Table: Analysis--------------------------------------------------------------------------------
   // Calculated Field: Number of features (Count -Int)
@@ -55,6 +56,6 @@ function retrieve_feature_misc_tables_views_data() {
       'handler' => 'views_handler_field_chado_count',
       'table_to_query' => 'analysisfeature',
     ),
-  ); 
+  );
   return $data;
-}
+}

+ 28 - 28
tripal_feature/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_feature.views.inc:tripal_feature_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_feature.views.inc --in tripal_feature_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_feature_views_data() --in tripal_feature.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_feature/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_feature.views.inc:tripal_feature_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_feature.views.inc --in tripal_feature_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_feature_views_data() --in tripal_feature.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;
-}
+}

+ 18 - 17
tripal_genetic/tripal_genetic.api.inc

@@ -1,9 +1,9 @@
-<?php 
+<?php
 
 /**
  *
  */
-function tripal_genetic_get_genotypes_by_feature_id ($feature_id) {
+function tripal_genetic_get_genotypes_by_feature_id($feature_id) {
 
   /**
   $sql = 'SELECT nd_experiment_id FROM nd_experiment_genotype WHERE genotype_id IN (SELECT genotype_id FROM feature_genotype WHERE feature_id=%d)';
@@ -13,24 +13,25 @@ function tripal_genetic_get_genotypes_by_feature_id ($feature_id) {
   while ($r = db_fetch_object($resource)) {
     $values['nd_experiment_id'][] = $r->nd_experiment_id;
   }
-  
+
   $object = tripal_core_generate_chado_var('nd_experiment',$values);
   $object = tripal_core_expand_chado_vars($object, 'table', 'nd_experiment_genotype');
   $object = tripal_core_expand_chado_vars($object, 'table', 'feature_genotype');
   $object = tripal_core_expand_chado_vars($object, 'table', 'nd_experiment_stock');
   */
 
-  $sql = 'SELECT genotype_id FROM genotype WHERE genotype_id IN (SELECT genotype_id FROM feature_genotype WHERE feature_id=%d)';
+  $sql = 'SELECT genotype_id FROM {genotype} WHERE genotype_id IN (SELECT genotype_id FROM {feature_genotype} WHERE feature_id=%d)';
   $resource = db_query($sql, $feature_id);
 
   $values['genotype_id'] = array();
   while ($r = db_fetch_object($resource)) {
     $values['genotype_id'][] = $r->genotype_id;
   }
-  
+
   if (!empty($values['genotype_id'])) {
-    $object = tripal_core_generate_chado_var('genotype',$values);  
-  } else {
+    $object = tripal_core_generate_chado_var('genotype', $values);
+  }
+  else {
     $object = array();
   }
   return $object;
@@ -47,9 +48,9 @@ function tripal_genetic_get_genotypes_by_feature_id ($feature_id) {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_genetic_chado_genotype_schema () {
+function tripal_genetic_chado_genotype_schema() {
   $description = array();
- 
+
   $referring_tables = array('analysisfeature',
     'feature_genotype',
     'phendesc',
@@ -58,9 +59,9 @@ function tripal_genetic_chado_genotype_schema () {
     'stock_genotype',
   );
   $description['referring_tables'] = $referring_tables;
-  
+
   return $description;
-  
+
 }
 
 /**
@@ -73,7 +74,7 @@ function tripal_genetic_chado_genotype_schema () {
  *
  * @ingroup tripal_schema_api
  */
-function tripal_genetic_chado_feature_genotype_schema () {
+function tripal_genetic_chado_feature_genotype_schema() {
   $description = array();
 
   $description['foreign keys']['feature'] = array(
@@ -82,14 +83,14 @@ function tripal_genetic_chado_feature_genotype_schema () {
           'feature_id' => 'feature_id',
           'chromosome_id' => 'feature_id',
         ),
-  ); 
+  );
 
   $description['foreign keys']['genotype'] = array(
         'table' => 'genotype',
         'columns' => array(
           'genotype_id' => 'genotype_id',
         ),
-  );  
+  );
 
   $description['foreign keys']['cvterm'] = array(
         'table' => 'cvterm',
@@ -97,7 +98,7 @@ function tripal_genetic_chado_feature_genotype_schema () {
           'cvterm_id' => 'cvterm_id',
         ),
   );
-  
+
   return $description;
-  
-}
+
+}

+ 10 - 10
tripal_genetic/tripal_genetic.module

@@ -3,9 +3,9 @@
 /**
  *  @file
  * This file contains the basic functions needed for this drupal module.
- * The drupal tripal_genetic module maps directly to the chado X module. 
+ * The drupal tripal_genetic module maps directly to the chado X module.
  *
- * For documentation regarding the Chado X module: 
+ * For documentation regarding the Chado X module:
  * @see http://gmod.org/wiki/Chado_General_Module
  */
 
@@ -16,7 +16,7 @@ require('tripal_genetic.api.inc');
  * Purpose: Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_genetic.views.inc where all the
  *  views integration code is
- */ 
+ */
 function tripal_genetic_views_api() {
    return array(
       'api' => 2.0,
@@ -25,17 +25,17 @@ function tripal_genetic_views_api() {
 
 function tripal_genetic_theme() {
   return array(
-    'tripal_feature_genotypes' => array (
-       'arguments' => array('node'=> null),
+    'tripal_feature_genotypes' => array(
+       'arguments' => array('node' => NULL),
        'template' => 'tripal_feature_genotypes',
-    ),  
+    ),
   );
 }
 
 /**
  *
  */
-function tripal_genetic_nodeapi (&$node, $op, $teaser, $page) {
+function tripal_genetic_nodeapi(&$node, $op, $teaser, $page) {
   switch ($op) {
     case 'view':
       if ($node->type == 'chado_feature') {
@@ -51,7 +51,7 @@ function tripal_genetic_nodeapi (&$node, $op, $teaser, $page) {
 /**
  *
  */
-function tripal_genetic_preprocess_tripal_feature_genotypes(&$variables){
-    $feature = $variables['node']->feature;   
+function tripal_genetic_preprocess_tripal_feature_genotypes(&$variables) {
+    $feature = $variables['node']->feature;
     $variables['tripal_feature']['genotypes'] = tripal_genetic_get_genotypes_by_feature_id($feature->feature_id);
-}
+}

+ 23 - 23
tripal_genetic/views/genotype.views.inc

@@ -1,5 +1,5 @@
-<?php 
- 
+<?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_genetic.views.inc --in tripal_genetic_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 genotype table, it's fields and any joins between it and other tables
  * @see tripal_genetic_views_data() --in tripal_genetic.views.inc
  *
@@ -28,33 +28,33 @@
   // 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['genotype']['table']['group'] = t('Chado Genotype');
-  
+
   $data['genotype']['table']['base'] = array(
     'field' => 'genotype_id',
     'title' => t('Chado Genotype'),
     'help' => t('A genotype is defined by a collection of features, mutations, balancers, deficiencies, haplotype blocks, or engineered constructs.'),
   );
-  if($database){
+  if ($database) {
      $data['genotype']['table']['base']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
 
   //Join: feature => feature_genotype => feature
   // 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['feature']['table']['join']['feature_genotype'] = array(
     'left_field' => 'feature_id',
     'field' => 'feature_id',
-  );  
+  );
   $data['feature']['table']['join']['genotype'] = array(
     'left_table' => 'feature_genotype',
     'left_field' => 'feature_id',
@@ -67,12 +67,12 @@
 
   //Join: feature => feature_genotype => feature
   // 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['genotype']['table']['join']['feature_genotype'] = array(
     'left_field' => 'genotype_id',
     'field' => 'genotype_id',
-  );  
+  );
   $data['genotype']['table']['join']['feature'] = array(
     'left_table' => 'feature_genotype',
     'left_field' => 'genotype_id',
@@ -82,15 +82,15 @@
     'left_field' => 'feature_id',
     'field' => 'feature_id',
   );
-  
+
    //Join: stock => stock_genotype => stock
   // This relationship should be described in both directions
-  // in the appropriate files (ie: for stock => library 
+  // in the appropriate files (ie: for stock => library
   // describe in both stock.views.inc and library.views.inc)
   $data['stock']['table']['join']['stock_genotype'] = array(
     'left_field' => 'stock_id',
     'field' => 'stock_id',
-  );  
+  );
   $data['stock']['table']['join']['genotype'] = array(
     'left_table' => 'stock_genotype',
     'left_field' => 'stock_id',
@@ -100,9 +100,9 @@
     'left_field' => 'genotype_id',
     'field' => 'genotype_id',
   );
-  
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: genotype_id (primary key)
   $data['genotype']['genotype_id'] = array(
     'title' => t('Genotype Primary Key'),
@@ -119,7 +119,7 @@
     ),
   );
 
-  //Field: name (text)  
+  //Field: name (text)
   $data['genotype']['name'] = array(
     'title' => t('Name'),
     'help' => t('Human-readable Name of the genotype.'),
@@ -138,7 +138,7 @@
     ),
   );
 
-  //Field: uniquename (text)  
+  //Field: uniquename (text)
   $data['genotype']['uniquename'] = array(
     'title' => t('Unique Name'),
     'help' => t('Unique Name of the genotype.'),
@@ -157,7 +157,7 @@
     ),
   );
 
-  //Field: description (varchar -255)   
+  //Field: description (varchar -255)
   $data['genotype']['description'] = array(
     'title' => t('Description/Value'),
     'help' => t('A Description of the genotype.'),
@@ -175,6 +175,6 @@
       'handler' => 'views_handler_argument_string',
     ),
   );
-    
+
   return $data;
-}
+}

+ 28 - 28
tripal_genetic/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_genetic.views.inc:tripal_genetic_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_genetic.views.inc --in tripal_genetic_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_genetic_views_data() --in tripal_genetic.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_genetic/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_genetic.views.inc:tripal_genetic_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_genetic.views.inc --in tripal_genetic_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_genetic_views_data() --in tripal_genetic.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;
-}
+}

+ 25 - 25
tripal_library/tripal_library.api.inc

@@ -5,7 +5,7 @@
  * @ingroup tripal_api
  * @ingroup tripal_library
  */
- 
+
 /**
  * Implements hook_chado_library_schema()
  * Purpose: To add descriptions and foreign keys to default table description
@@ -18,7 +18,7 @@
  */
 function tripal_library_chado_library_schema() {
   $description = array();
-  
+
   // Default table description in tripal_core.schema.api.inc: tripal_core_chado_feature_schema()
 
   $description['foreign keys']['organism'] = array(
@@ -26,24 +26,24 @@ function tripal_library_chado_library_schema() {
         'columns' => array(
           'organism_id' => 'organism_id',
         ),
-  );  
-  
+  );
+
   $description['foreign keys']['cvterm'] = array(
         'table' => 'cvterm',
         'columns' => array(
           'type_id' => 'cvterm_id',
         ),
   );
-  
+
   $referring_tables = array(
       'library_cvterm',
       'library_feature',
       'library_pub',
       'library_synonym',
-      'libraryprop' 
+      'libraryprop'
   );
   $description['referring_tables'] = $referring_tables;
-  
+
   return $description;
 }
 
@@ -59,7 +59,7 @@ function tripal_library_chado_library_schema() {
  */
 function tripal_library_chado_library_feature_schema() {
   $description = array();
-  
+
   // Default table description in tripal_core.schema.api.inc: tripal_core_chado_library_feature_schema()
 
   $description['foreign keys']['library'] = array(
@@ -67,15 +67,15 @@ function tripal_library_chado_library_feature_schema() {
         'columns' => array(
           'library_id' => 'library_id',
         ),
-  );  
-  
+  );
+
   $description['foreign keys']['feature'] = array(
         'table' => 'feature',
         'columns' => array(
           'feature_id' => 'feature_id',
         ),
   );
-  
+
   return $description;
 }
 /**
@@ -90,7 +90,7 @@ function tripal_library_chado_library_feature_schema() {
  */
 function tripal_library_chado_libraryprop_schema() {
   $description = array();
-  
+
   // Default table description in tripal_core.schema.api.inc: tripal_core_chado_library_feature_schema()
 
   $description['foreign keys']['library'] = array(
@@ -98,15 +98,15 @@ function tripal_library_chado_libraryprop_schema() {
         'columns' => array(
           'library_id' => 'library_id',
         ),
-  );  
-  
+  );
+
   $description['foreign keys']['cvterm'] = array(
         'table' => 'cvterm',
         'columns' => array(
           'type_id' => 'cvterm_id',
         ),
   );
-  
+
   return $description;
 }
 
@@ -123,8 +123,8 @@ function tripal_library_chado_libraryprop_schema() {
  *
  * @ingroup tripal_library_api
  */
-function tripal_library_get_property($library_id,$property){
-   return tripal_core_get_property('library',$library_id,$property,'tripal');
+function tripal_library_get_property($library_id, $property) {
+   return tripal_core_get_property('library', $library_id, $property, 'tripal');
 }
 
 /**
@@ -144,8 +144,8 @@ function tripal_library_get_property($library_id,$property){
  *
  * @ingroup tripal_library_api
  */
-function tripal_library_insert_property($library_id,$property,$value,$update_if_present = 0){
-   return tripal_core_insert_property('library',$library_id,$property,'tripal',$value,$update_if_present);
+function tripal_library_insert_property($library_id, $property, $value, $update_if_present = 0) {
+   return tripal_core_insert_property('library', $library_id, $property, 'tripal', $value, $update_if_present);
 }
 
 /**
@@ -157,7 +157,7 @@ function tripal_library_insert_property($library_id,$property,$value,$update_if_
  *   The cvterm name of the property to update
  * @param $value
  *   The value of the property to update
- * @param $insert_if_missing 
+ * @param $insert_if_missing
  *   A boolean indicated whether to insert the record if it's absent
  *
  * Note: The property will be identified using the unique combination of the $library_id and $property
@@ -168,8 +168,8 @@ function tripal_library_insert_property($library_id,$property,$value,$update_if_
  *
  * @ingroup tripal_library_api
  */
-function tripal_library_update_property($library_id,$property,$value,$insert_if_missing = 0){
-   return tripal_core_update_property('library',$library_id,$property,'tripal',$value, $insert_if_missing);
+function tripal_library_update_property($library_id, $property, $value, $insert_if_missing = 0) {
+   return tripal_core_update_property('library', $library_id, $property, 'tripal', $value, $insert_if_missing);
 }
 /**
  * Delete a given property
@@ -183,10 +183,10 @@ function tripal_library_update_property($library_id,$property,$value,$insert_if_
  * and then it will be deleted
  *
  * @return
- *   True of success, False otherwise 
+ *   True of success, False otherwise
  *
  * @ingroup tripal_library_api
  */
-function tripal_library_delete_property($library_id,$property){
-   return tripal_core_delete_property('library',$library_id,$property,'tripal');
+function tripal_library_delete_property($library_id, $property) {
+   return tripal_core_delete_property('library', $library_id, $property, 'tripal');
 }

+ 18 - 18
tripal_library/tripal_library.install

@@ -5,7 +5,7 @@
 *
 * @ingroup tripal_library
 */
-function tripal_library_install(){
+function tripal_library_install() {
    // create the module's data directory
    tripal_create_moddir('tripal_library');
 
@@ -16,14 +16,14 @@ function tripal_library_install(){
    // Insert cvterm 'library_description' into cvterm table of chado
    // database. This CV term is used to keep track of the library
    // description in the libraryprop table.
-   tripal_cv_add_cvterm(array('name' => 'library_description','def' => 'Description of a library'),'tripal',0,1,'tripal');
-   
+   tripal_cv_add_cvterm(array('name' => 'library_description', 'def' => 'Description of a library'), 'tripal', 0, 1, 'tripal');
+
    // Add CVTerms for the library types
-   tripal_cv_add_cvterm(array('name' => 'cdna_library','def' => 'cDNA Library'),'tripal',0,1,'tripal');
-   tripal_cv_add_cvterm(array('name' => 'bac_library','def' => 'BAC Library'),'tripal',0,1,'tripal');
-   tripal_cv_add_cvterm(array('name' => 'fosmid_library','def' => 'FOSMID Library'),'tripal',0,1,'tripal');
-   tripal_cv_add_cvterm(array('name' => 'cosmid_library','def' => 'COSMID Library'),'tripal',0,1,'tripal');
-   tripal_cv_add_cvterm(array('name' => 'yac_library','def' => 'YAC Library'),'tripal',0,1,'tripal');
+   tripal_cv_add_cvterm(array('name' => 'cdna_library', 'def' => 'cDNA Library'), 'tripal', 0, 1, 'tripal');
+   tripal_cv_add_cvterm(array('name' => 'bac_library', 'def' => 'BAC Library'), 'tripal', 0, 1, 'tripal');
+   tripal_cv_add_cvterm(array('name' => 'fosmid_library', 'def' => 'FOSMID Library'), 'tripal', 0, 1, 'tripal');
+   tripal_cv_add_cvterm(array('name' => 'cosmid_library', 'def' => 'COSMID Library'), 'tripal', 0, 1, 'tripal');
+   tripal_cv_add_cvterm(array('name' => 'yac_library', 'def' => 'YAC Library'), 'tripal', 0, 1, 'tripal');
 
    // Add the materialized view needed to count the features for the library
    // Drop the MView table if it exists
@@ -34,12 +34,12 @@ function tripal_library_install(){
    }
    tripal_db_set_active($previous_db);
    // Create the MView
-   tripal_add_mview('library_feature_count','tripal_library',
+   tripal_add_mview('library_feature_count', 'tripal_library',
       'library_feature_count',
       'library_id integer, name character varying(255), '.
-		'  num_features integer, feature_type character varying(255)',
-	   'library_id',
-	   'SELECT '.
+    '  num_features integer, feature_type character varying(255)',
+     'library_id',
+     'SELECT '.
       '   L.library_id, '.
       '   L.name, '.
       '    count(F.feature_id) as num_features, '.
@@ -49,7 +49,7 @@ function tripal_library_install(){
       '    INNER JOIN Feature F           ON LF.feature_id = F.feature_id '.
       '    INNER JOIN Cvterm CVT          ON F.type_id = CVT.cvterm_id '.
       'GROUP BY L.library_id, L.name, CVT.name',
-	   ''
+     ''
    );
 
 }
@@ -69,7 +69,7 @@ function tripal_library_schema() {
  *
  * @ingroup tripal_library
  */
-function tripal_library_uninstall(){
+function tripal_library_uninstall() {
    drupal_uninstall_schema('tripal_library');
 
    // remove the materialized view
@@ -78,8 +78,8 @@ function tripal_library_uninstall(){
 
    if (db_table_exists('tripal_mviews')) {
       $mview = db_fetch_object(db_query($sql));
-      if($mview){
-         tripal_mviews_action('delete',$mview->mview_id);
+      if ($mview) {
+         tripal_mviews_action('delete', $mview->mview_id);
       }
    }
 
@@ -101,7 +101,7 @@ function tripal_library_uninstall(){
  *
  * @ingroup tripal_library
  */
-function tripal_library_get_schemas (){
+function tripal_library_get_schemas() {
   $schema = array();
   $schema['chado_library'] = array(
       'fields' => array(
@@ -127,7 +127,7 @@ function tripal_library_get_schemas (){
          'library_id' => array('library_id')
       ),
       'unique keys' => array(
-         'nid_vid' => array('nid','vid'),
+         'nid_vid' => array('nid', 'vid'),
          'vid' => array('vid')
       ),
       'primary key' => array('nid'),

File diff suppressed because it is too large
+ 209 - 199
tripal_library/tripal_library.module


+ 11 - 11
tripal_library/tripal_library.views.inc

@@ -6,7 +6,7 @@
  *  chado/tripal organism tables. Supplementary functions can be found in
  *  ./views/
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
@@ -18,13 +18,13 @@
 
 require_once('views/library.views.inc');
 require_once('views/chado_library.views.inc');
-require_once('views/misc_tables.views.inc'); 
+require_once('views/misc_tables.views.inc');
 /*************************************************************************
  * Implements hook_views_data()
  * Purpose: Describe chado/tripal tables & fields to views
  * @return: a data array which follows the structure outlined in the
  *   views2 documentation for this hook. Essentially, it's an array of table
- *   definitions keyed by chado/tripal table name. Each table definition 
+ *   definitions keyed by chado/tripal table name. Each table definition
  *   includes basic details about the table, fields in that table and
  *   relationships between that table and others (joins)
  *
@@ -32,18 +32,18 @@ require_once('views/misc_tables.views.inc');
  */
 function tripal_library_views_data()  {
   $data = array();
-  
+
   $data = array_merge($data, retrieve_library_views_data());
   $data = array_merge($data, retrieve_chado_library_views_data());
   $data = array_merge($data, retrieve_library_misc_tables_views_data());
-  
+
   return $data;
 }
 
 /*************************************************************************
  * Implements hook_views_handlers()
  * Purpose: Register all custom handlers with views
- *   where a handler describes either "the type of field", 
+ *   where a handler describes either "the type of field",
  *   "how a field should be filtered", "how a field should be sorted"
  * @return: An array of handler definitions
  *
@@ -67,7 +67,7 @@ function tripal_library_views_handlers() {
  */
 function tripal_library_views_data_alter(&$data) {
 
-  if( !(is_array($db_url) and array_key_exists('chado',$db_url)) ){
+  if ( !(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
 
     // Add featuer relationship to node
     $data['node']['library_chado_nid'] = array(
@@ -85,7 +85,7 @@ function tripal_library_views_data_alter(&$data) {
       ),
     );
   }
-  
+
 }
 
 /**
@@ -93,9 +93,9 @@ function tripal_library_views_data_alter(&$data) {
  *
  * @ingroup tripal_library_views
  */
-function tripal_library_views_default_views () {
+function tripal_library_views_default_views() {
   $views = array();
-  
+
   // Main default view
   // List all cvterms based on cv
   $view = new view;
@@ -389,6 +389,6 @@ function tripal_library_views_default_views () {
     'name' => 'navigation',
   ));
   $views[$view->name] = $view;
-  
+
   return $views;
 }

+ 24 - 23
tripal_library/views/chado_library.views.inc

@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Purpose: this function returns the portion of the data array 
+ * @file
+ * Purpose: this function returns the portion of the data array
  *   which describes the chado_library drupal table, it's fields and any joins between it and other tables
  * @see tripal_library_views_data() --in tripal_library.views.inc
  *
@@ -9,14 +10,14 @@
  *
  * @ingroup tripal_library_views
  */
-function retrieve_chado_library_views_data () {
-	global $db_url;
+function retrieve_chado_library_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;
   }
@@ -26,42 +27,42 @@ function retrieve_chado_library_views_data () {
     '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,
+       'handler' => 'views_handler_field_numeric',
+       'click sortable' => TRUE,
     ),
     'filter' => array(
-     	'handler' => 'views_handler_filter_numeric',
+       'handler' => 'views_handler_filter_numeric',
     ),
     'sort' => array(
-     	'handler' => 'views_handler_sort',
+       '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',
+    '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',
+    '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',
-  );  
+    'left_table' => 'chado_library',
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
 
   // Add relationship between chado_library and library
   $data['chado_library']['library_nid'] = array(
@@ -94,6 +95,6 @@ function retrieve_chado_library_views_data () {
       'base field' => 'nid'
     ),
   );
-  
-	return $data;
+
+  return $data;
 }

+ 12 - 12
tripal_library/views/handlers/views_handler_field_computed_library_nid.inc

@@ -1,17 +1,17 @@
 <?php
 
 class views_handler_field_computed_library_nid extends views_handler_field_numeric {
-	function construct() {
-		parent::construct();
-		$this->additional_fields['library_id'] = array('table' => 'library', 'field' => 'library_id');
-	}
+  function construct() {
+    parent::construct();
+    $this->additional_fields['library_id'] = array('table' => 'library', 'field' => 'library_id');
+  }
 
-	function query() { 
-		$this->ensure_my_table();
-		$this->add_additional_fields(); 
-	}
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
 
-	function render($values) { 
-		return $values->library_nid;
-	}
-} 
+  function render($values) {
+    return $values->library_nid;
+  }
+}

+ 131 - 129
tripal_library/views/library.views.inc

@@ -1,6 +1,7 @@
 <?php
-	/**
- * Purpose: this function returns the portion of the data array 
+  /**
+ *@file
+ * Purpose: this function returns the portion of the data array
  *   which describes the library table, it's fields and any joins between it and other tables
  * @see tripal_library_views_data() --in tripal_library.views.inc
  *
@@ -29,28 +30,28 @@
  * @ingroup tripal_library_views
  */
 function retrieve_library_views_data() {
-	global $db_url;
+  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)) {
      $database = 'chado';
   }
-  
+
   // Basic table definition
-	$data['library']['table']['group'] = 'Chado Library';
-	$data['library']['table']['base'] = array(
-	  'field' => 'library_id',
-	  'title' => 'Chado Library',
-	  'help' => 'Library existing in the Chado Database',                                                                                                                                                                          
-	);
-	if($database){
-	  $data['library']['table']['base']['database'] = $database;
-	}
-	
-	// Define relationships between this table and others
+  $data['library']['table']['group'] = 'Chado Library';
+  $data['library']['table']['base'] = array(
+    'field' => 'library_id',
+    'title' => 'Chado Library',
+    'help' => 'Library existing in the Chado Database',
+  );
+  if ($database) {
+    $data['library']['table']['base']['database'] = $database;
+  }
+
+  // Define relationships between this table and others
   $data['library']['table']['join'] = array(
     'library_feature' => array(
       'left_field' => 'library_id',
@@ -70,36 +71,37 @@ function retrieve_library_views_data() {
       'field' => 'feature_id',
     ),
   );
-	
-	// Table Field Definitions----------------------
-	// Field: library_id (primary key)
-	$data['library']['library_id'] = array(
-	  'title' => 'Library ID',
-	  'help' => 'The primary key of the library table.',
-	  'field' => array(
-	    'handler' => 'views_handler_field_numeric',
-	    'click sortable' => TRUE,
-	  ),
-	  'filter' => array(
-	    'handler' => 'views_handler_filter_numeric',
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort',
-	  ),
-	);
-	
+
+  // Table Field Definitions----------------------
+  // Field: library_id (primary key)
+  $data['library']['library_id'] = array(
+    'title' => 'Library ID',
+    'help' => 'The primary key of the library table.',
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+
   // 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){
-		$data['library']['library_nid'] = array(
-	  	'title' => 'Node ID',
-	  	'help' => 'The node ID for the current library',
-	  	'field' => array(
-	    	'handler' => 'views_handler_field_computed_library_nid',
-	  	),
-		);
-  } else {
+  if ($database) {
+    $data['library']['library_nid'] = array(
+      'title' => 'Node ID',
+      'help' => 'The node ID for the current library',
+      'field' => array(
+        'handler' => 'views_handler_field_computed_library_nid',
+      ),
+    );
+  }
+  else {
     // Add relationship between chado_library and library
     $data['library']['library_nid'] = array(
       'group' => 'Library',
@@ -117,100 +119,100 @@ function retrieve_library_views_data() {
     );
 
   }
-	
-	// Field: organism_id (forgeign key)
+
+  // Field: organism_id (forgeign key)
   //  join between organism table and this one in tripal_organism/views/organism.views.inc
-	
-	// Field: type_id (forgeign key)
+
+  // Field: type_id (forgeign key)
   //  join between cvterm table and this one in tripal_cv/views/cvterm.views.inc
-  
-	// Field: Name (varchar 255)
-	$data['library']['name'] = array(
-	  'title' => 'Name',
-	  'help' => 'The human-readable name of the current library.',
-	  'field' => array(
-	    'handler' => 'views_handler_field',
-	    'click sortable' => TRUE,
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort',
-	  ),
-	  'filter' => array(
-	    'handler' => 'views_handler_filter_chado_select_string',
-	  ),
-	  'argument' => array(
-	    'handler' => 'views_handler_argument_string',
-	  ),
-	);
-  // if joined to the node table add a "Link to Node" option for the field  
+
+  // Field: Name (varchar 255)
+  $data['library']['name'] = array(
+    'title' => 'Name',
+    'help' => 'The human-readable name of the current library.',
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_chado_select_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+  // if joined to the node table add a "Link to Node" option for the field
   if (!$database) {
     $data['library']['name']['field']['handler'] = 'views_handler_field_node_optional';
   }
-	
-	// Field: Unique name (text)
-	$data['library']['uniquename'] = array(
-	  'title' => 'Unique Name',
-	  'help' => 'The unique name of the current library.',
-	  'field' => array(
-	    'handler' => 'views_handler_field',
-	    'click sortable' => TRUE,
-	  ),
-	  'filter' => array(
-	    'handler' => 'views_handler_filter_string',
-	  ),
-	  'argument' => array(
-	    'handler' => 'views_handler_argument_string',
-	  ),
-	);
-  // if joined to the node table add a "Link to Node" option for the field  
+
+  // Field: Unique name (text)
+  $data['library']['uniquename'] = array(
+    'title' => 'Unique Name',
+    'help' => 'The unique name of the current library.',
+    'field' => array(
+      'handler' => 'views_handler_field',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+  // if joined to the node table add a "Link to Node" option for the field
   if (!$database) {
     $data['library']['uniquename']['field']['handler'] = 'views_handler_field_node_optional';
   }
-	
-	// Field: Is obsolete (integer 0/1)
-	$data['library']['is_obsolete'] = array(
-	  'title' => t('Is Obsolete?'),
-	  'help' => t('Indicates whether a given library is obsolete or not.'),
-	  'field' => array(
-	    'handler' => 'views_handler_field_boolean',
-	    'click sortable' => TRUE,
-	  ),
-	  'filter' => array(
+
+  // Field: Is obsolete (integer 0/1)
+  $data['library']['is_obsolete'] = array(
+    'title' => t('Is Obsolete?'),
+    'help' => t('Indicates whether a given library is obsolete or not.'),
+    'field' => array(
+      'handler' => 'views_handler_field_boolean',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
        'handler' => 'views_handler_filter_chado_boolean',
        'label' => t('Is Obsolete?'),
        'type' => 'yes-no',
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort',
-	  ),
-	);
-	
-	// Field: time accessioned (datetime)
-	$data['library']['timeaccessioned'] = array(
-	  'title' => t('Date Accessioned'),
-	  'help' => t('Indicates the date a given library was accessioned (entered into the database).'),
-	  'field' => array(
-	    'handler' => 'views_handler_field_readable_date',
-	    'click sortable' => TRUE,
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort_date',
-	  ),
-	);
-	
-	// Field: time last modified (datetime)
-	$data['library']['timelastmodified'] = array(
-	  'title' => t('Date Last Modified'),
-	  'help' => t('Indicates the date that a given library was last modified.'),
-	  'field' => array(
-	    'handler' => 'views_handler_field_readable_date',
-	    'click sortable' => TRUE,
-	  ),
-	  'sort' => array(
-	    'handler' => 'views_handler_sort_date',
-	  ),
-	);
-	
-	return $data;
-	
-}
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+
+  // Field: time accessioned (datetime)
+  $data['library']['timeaccessioned'] = array(
+    'title' => t('Date Accessioned'),
+    'help' => t('Indicates the date a given library was accessioned (entered into the database).'),
+    'field' => array(
+      'handler' => 'views_handler_field_readable_date',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+
+  // Field: time last modified (datetime)
+  $data['library']['timelastmodified'] = array(
+    'title' => t('Date Last Modified'),
+    'help' => t('Indicates the date that a given library was last modified.'),
+    'field' => array(
+      'handler' => 'views_handler_field_readable_date',
+      'click sortable' => TRUE,
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort_date',
+    ),
+  );
+
+  return $data;
+
+}

+ 7 - 6
tripal_library/views/misc_tables.views.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Purpose: Allows the library module to add fields to other module views
  *
  *   For example, a field counting the number of libraries associted with a given feature would be
@@ -13,14 +14,14 @@
           'handler' => 'views_handler_field_chado_count',
           'table_to_query' => 'library_feature',
         ),
-      ); 
+      );
  *   @endcode
  *
  * @ingroup tripal_library_views
  */
 function retrieve_library_misc_tables_views_data() {
   $data = array();
- 
+
   // Table: Feature---------------------------------------------------------------------------------
   // Calculated Field: Number of Libraries (Count -Int)
   // Provides the number of libraries for a given feature
@@ -31,7 +32,7 @@ function retrieve_library_misc_tables_views_data() {
       'handler' => 'views_handler_field_chado_count',
       'table_to_query' => 'library_feature',
     ),
-  ); 
+  );
 
   // Table: Organism--------------------------------------------------------------------------------
   // Calculated Field: Number of Libraries (Count -Int)
@@ -43,7 +44,7 @@ function retrieve_library_misc_tables_views_data() {
       'handler' => 'views_handler_field_chado_count',
       'table_to_query' => 'library',
     ),
-  );  
-  
+  );
+
   return $data;
-}
+}

+ 28 - 28
tripal_library/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_library.views.inc:tripal_library_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_library.views.inc --in tripal_library_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_library_views_data() --in tripal_library.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_library/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_library.views.inc:tripal_library_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_library.views.inc --in tripal_library_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_library_views_data() --in tripal_library.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;
-}
+}

+ 64 - 64
tripal_natural_diversity/tripal_natural_diversity.api.inc

@@ -1,8 +1,8 @@
 <?php
 
-function tripal_natural_diversity_chado_nd_experiment_schema () {
+function tripal_natural_diversity_chado_nd_experiment_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment',
     'fields' => array(
@@ -48,13 +48,13 @@ function tripal_natural_diversity_chado_nd_experiment_schema () {
       'nd_experimentprop'
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_contact_schema () {
+function tripal_natural_diversity_chado_nd_experiment_contact_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_contact',
     'fields' => array(
@@ -92,13 +92,13 @@ function tripal_natural_diversity_chado_nd_experiment_contact_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_dbxref_schema () {
+function tripal_natural_diversity_chado_nd_experiment_dbxref_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_dbxref',
     'fields' => array(
@@ -136,13 +136,13 @@ function tripal_natural_diversity_chado_nd_experiment_dbxref_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_genotype_schema () {
+function tripal_natural_diversity_chado_nd_experiment_genotype_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_genotype',
     'fields' => array(
@@ -180,13 +180,13 @@ function tripal_natural_diversity_chado_nd_experiment_genotype_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_phenotype_schema () {
+function tripal_natural_diversity_chado_nd_experiment_phenotype_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_phenotype',
     'fields' => array(
@@ -224,13 +224,13 @@ function tripal_natural_diversity_chado_nd_experiment_phenotype_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_project_schema () {
+function tripal_natural_diversity_chado_nd_experiment_project_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_project',
     'fields' => array(
@@ -268,13 +268,13 @@ function tripal_natural_diversity_chado_nd_experiment_project_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_protocol_schema () {
+function tripal_natural_diversity_chado_nd_experiment_protocol_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_protocol',
     'fields' => array(
@@ -312,13 +312,13 @@ function tripal_natural_diversity_chado_nd_experiment_protocol_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_pub_schema () {
+function tripal_natural_diversity_chado_nd_experiment_pub_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_pub',
     'fields' => array(
@@ -356,13 +356,13 @@ function tripal_natural_diversity_chado_nd_experiment_pub_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_stock_schema () {
+function tripal_natural_diversity_chado_nd_experiment_stock_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_stock',
     'fields' => array(
@@ -411,13 +411,13 @@ function tripal_natural_diversity_chado_nd_experiment_stock_schema () {
       'nd_experiment_stockprop',
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_stockprop_schema () {
+function tripal_natural_diversity_chado_nd_experiment_stockprop_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_stockprop',
     'fields' => array(
@@ -462,13 +462,13 @@ function tripal_natural_diversity_chado_nd_experiment_stockprop_schema () {
     'referring_tables' => array(
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experiment_stock_dbxref_schema () {
+function tripal_natural_diversity_chado_nd_experiment_stock_dbxref_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experiment_stock_dbxref',
     'fields' => array(
@@ -506,13 +506,13 @@ function tripal_natural_diversity_chado_nd_experiment_stock_dbxref_schema () {
 
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_experimentprop_schema () {
+function tripal_natural_diversity_chado_nd_experimentprop_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_experimentprop',
     'fields' => array(
@@ -557,13 +557,13 @@ function tripal_natural_diversity_chado_nd_experimentprop_schema () {
     'referring_tables' => array(
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_geolocation_schema () {
+function tripal_natural_diversity_chado_nd_geolocation_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_reagent',
     'fields' => array(
@@ -595,13 +595,13 @@ function tripal_natural_diversity_chado_nd_geolocation_schema () {
       'nd_geolocationprop'
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_geolocationprop_schema () {
+function tripal_natural_diversity_chado_nd_geolocationprop_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_geolocationprop',
     'fields' => array(
@@ -646,13 +646,13 @@ function tripal_natural_diversity_chado_nd_geolocationprop_schema () {
     'referring_tables' => array(
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_protocol_schema () {
+function tripal_natural_diversity_chado_nd_protocol_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_protocol',
     'fields' => array(
@@ -671,23 +671,23 @@ function tripal_natural_diversity_chado_nd_protocol_schema () {
     'referring_tables' => array(
       'nd_experiment_protocol',
       'nd_protocol_reagent',
-      'nd_protocolprop'  
+      'nd_protocolprop'
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_protocol_reagent_schema () {
+function tripal_natural_diversity_chado_nd_protocol_reagent_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_protocol_reagent',
     'fields' => array(
       'nd_protocol_reagent_id' => array(
         'type' => 'serial',
         'not null' => 1,
-      ),    
+      ),
       'nd_protocol_id' => array(
         'type' => 'int',
         'not null' => 1,
@@ -702,7 +702,7 @@ function tripal_natural_diversity_chado_nd_protocol_reagent_schema () {
       ),
     ),
     'primary key' => array(
-      '0' => 'nd_protocol_reagent_id',   
+      '0' => 'nd_protocol_reagent_id',
     ),
     'foreign keys' => array(
       'nd_protocol' => array(
@@ -725,16 +725,16 @@ function tripal_natural_diversity_chado_nd_protocol_reagent_schema () {
       ),
     ),
     'referring_tables' => array(
-    
+
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_protocolprop_schema () {
+function tripal_natural_diversity_chado_nd_protocolprop_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_protocolprop',
     'fields' => array(
@@ -779,13 +779,13 @@ function tripal_natural_diversity_chado_nd_protocolprop_schema () {
     'referring_tables' => array(
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_reagent_schema () {
+function tripal_natural_diversity_chado_nd_reagent_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_reagent',
     'fields' => array(
@@ -819,13 +819,13 @@ function tripal_natural_diversity_chado_nd_reagent_schema () {
       ),
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_reagent_relationship_schema () {
+function tripal_natural_diversity_chado_nd_reagent_relationship_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_reagent_relationship',
     'fields' => array(
@@ -865,13 +865,13 @@ function tripal_natural_diversity_chado_nd_reagent_relationship_schema () {
       ),
     ),
   );
-  
+
   return $description;
 }
 
-function tripal_natural_diversity_chado_nd_reagentprop_schema () {
+function tripal_natural_diversity_chado_nd_reagentprop_schema() {
   $description = array();
-  
+
   $description = array(
     'table' => 'nd_reagentprop',
     'fields' => array(
@@ -916,6 +916,6 @@ function tripal_natural_diversity_chado_nd_reagentprop_schema () {
     'referring_tables' => array(
     ),
   );
-  
+
   return $description;
 }

+ 11 - 10
tripal_natural_diversity/tripal_natural_diversity.module

@@ -5,9 +5,9 @@ require_once('tripal_natural_diversity.api.inc');
 /**
  *  @file
  * This file contains the basic functions needed for this drupal module.
- * The drupal tripal_natural_diversity module maps directly to the chado X module. 
+ * The drupal tripal_natural_diversity module maps directly to the chado X module.
  *
- * For documentation regarding the Chado X module: 
+ * For documentation regarding the Chado X module:
  * @see http://gmod.org/wiki/Chado_General_Module
  */
 
@@ -16,7 +16,7 @@ require_once('tripal_natural_diversity.api.inc');
  * Purpose: Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_natural_diversity.views.inc where all the
  *  views integration code is
- */ 
+ */
 function tripal_natural_diversity_views_api() {
    return array(
       'api' => 2.0,
@@ -30,11 +30,11 @@ function tripal_natural_diversity_theme() {
   return array(
     'tripal_feature_genotype_experiments' => array(
       'arguments' => array('node' => NULL),
-      'template' => 'tripal_feature-genotype_experiments',      
+      'template' => 'tripal_feature-genotype_experiments',
     ),
     'tripal_stock_genotype_experiments' => array(
       'arguments' => array('node' => NULL),
-      'template' => 'tripal_feature-stock_experiments',      
+      'template' => 'tripal_feature-stock_experiments',
     ),
   );
 }
@@ -42,17 +42,18 @@ function tripal_natural_diversity_theme() {
 /**
  *
  */
-function tripal_natural_diversity_nodeapi (&$node, $op, $teaser, $page) {
+function tripal_natural_diversity_nodeapi(&$node, $op, $teaser, $page) {
   switch ($op) {
     case 'view':
       if ($node->type == 'chado_feature') {
         $node->content['tripal_feature_genotype_experiments'] = array(
            '#value' => theme('tripal_feature_genotype_experiments', $node),
-        );      
-      } elseif ($node->type == 'chado_stock') {
+        );
+      }
+      elseif ($node->type == 'chado_stock') {
         $node->content['tripal_stock_genotype_experiments'] = array(
            '#value' => theme('tripal_stock_genotype_experiments', $node),
-        );      
+        );
       }
   }
-}
+}

+ 11 - 11
tripal_natural_diversity/tripal_natural_diversity.views.inc

@@ -6,17 +6,17 @@
  *  chado/tripal_natural_diversity tables. Supplementary functions can be found in
  *  ./views/
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
- 
+
 /*************************************************************************
  * Implements hook_views_data()
  * Purpose: Describe chado/tripal tables & fields to views
  *
  * @return: a data array which follows the structure outlined in the
  *   views2 documentation for this hook. Essentially, it's an array of table
- *   definitions keyed by chado/tripal table name. Each table definition 
+ *   definitions keyed by chado/tripal table name. Each table definition
  *   includes basic details about the table, fields in that table and
  *   relationships between that table and others (joins)
  */
@@ -28,26 +28,26 @@ require_once('views/nd_reagent.views.inc');
 require_once('views/nd_reagentprop.views.inc');
 function tripal_natural_diversity_views_data()  {
   $data = array();
-  
+
   //EXPERIMENT
   $data = array_merge($data, retrieve_nd_experiment_views_data());
   $data = array_merge($data, retrieve_nd_experimentprop_views_data());
-  
+
   // GEOLOCATION
   $data = array_merge($data, retrieve_nd_geolocation_views_data());
   $data = array_merge($data, retrieve_nd_geolocationprop_views_data());
-  
+
   // REAGENTS
   $data = array_merge($data, retrieve_nd_reagent_views_data());
   $data = array_merge($data, retrieve_nd_reagentprop_views_data());
-  
+
   return $data;
 }
 
 /*************************************************************************
  * Implements hook_views_handlers()
  * Purpose: Register all custom handlers with views
- *   where a handler describes either "the type of field", 
+ *   where a handler describes either "the type of field",
  *   "how a field should be filtered", "how a field should be sorted"
  *
  * @return: An array of handler definitions
@@ -58,12 +58,12 @@ function tripal_natural_diversity_views_handlers() {
      'path' => drupal_get_path('module', 'tripal_natural_diversity') . '/views/handlers',
    ),
    'handlers' => array(
-		'views_handler_field_chado_relationship_all' => array(
+  'views_handler_field_chado_relationship_all' => array(
        'parent' => 'views_handler_field_prerender_list',
      ),
-		'views_handler_field_chado_relationship_by_type' => array(
+  'views_handler_field_chado_relationship_by_type' => array(
        'parent' => 'views_handler_field_prerender_list',
      ),
    ),
  );
-}
+}

+ 72 - 72
tripal_natural_diversity/views/handlers/views_handler_field_chado_relationship_all.inc

@@ -1,6 +1,4 @@
 <?php
-// $Id: views_handler_field_term_node_tid.inc,v 1.4 2009/07/01 23:07:14 merlinofchaos Exp $
-
 /**
  * Field handler for terms.
  */
@@ -14,87 +12,89 @@ class views_handler_field_chado_relationship_all extends views_handler_field_pre
     $this->add_additional_fields();
   }
 
-	function pre_render($values) {
-		$this->aliases['relationships'] = 'relationships';
-		$this->aliases['primary_id'] = $this->view->base_table.'_id';
-		$this->field_alias = $this->aliases['primary_id'];
-		$relationship_tablename = $this->view->base_table.'_relationship';
-		$this->aliases['relationship_primary_id'] = $relationship_tablename . '_id';
-		$table_desc = module_invoke_all('chado_'.$relationship_tablename.'_schema');
-		foreach($table_desc['foreign keys'][$this->view->base_table]['columns'] as $k => $v) {
-		  if (preg_match('/subject/',$k)) { $subject_id = $k; }
-		  if (preg_match('/object/', $k)) { $object_id = $k; }
-		}
-		$this->aliases['subject_id'] = $subject_id;
-		$this->aliases['object_id'] = $object_id;
-		  
+  function pre_render($values) {
+    $this->aliases['relationships'] = 'relationships';
+    $this->aliases['primary_id'] = $this->view->base_table . '_id';
+    $this->field_alias = $this->aliases['primary_id'];
+    $relationship_tablename = $this->view->base_table . '_relationship';
+    $this->aliases['relationship_primary_id'] = $relationship_tablename . '_id';
+    $table_desc = module_invoke_all('chado_' . $relationship_tablename . '_schema');
+    foreach ($table_desc['foreign keys'][$this->view->base_table]['columns'] as $k => $v) {
+      if (preg_match('/subject/', $k)) {
+      $subject_id = $k;}
+      if (preg_match('/object/', $k)) {
+      $object_id = $k;}
+    }
+    $this->aliases['subject_id'] = $subject_id;
+    $this->aliases['object_id'] = $object_id;
+
     //Add values for all if possible
     if (!$this->view->result[0]->relationships) {
       //get base table primary keys
       $primary_ids = array();
-		  foreach ($this->view->result as $row_num => $row) {
-			  $primary_ids[$row_num] = $row->{$this->aliases['primary_id']};
-		  }
-		
-		  //generate results from db
-      $sql = "SELECT ".$relationship_tablename.".*, cvterm.name as type_name, "
-					."subject_parent.name as subject_name, object_parent.name as object_name "
-					."FROM ".$relationship_tablename." "
-					."LEFT JOIN ".$this->view->base_table." subject_parent ON "
-					  .$relationship_tablename.".".$subject_id."=subject_parent.".$this->aliases['primary_id']." "
-					."LEFT JOIN ".$this->view->base_table." object_parent ON "
-					  .$relationship_tablename.".".$object_id."=object_parent.".$this->aliases['primary_id']." "
-					."LEFT JOIN cvterm cvterm ON "
-					  .$relationship_tablename.".type_id = cvterm.cvterm_id "
-					."WHERE ".$relationship_tablename.".".$subject_id." IN (".implode(',',$primary_ids).") "
-					."OR ".$relationship_tablename.".".$object_id." IN (".implode(',',$primary_ids).") ";
-			$previous_db = tripal_db_set_active('chado');
-			$resource = db_query($sql);
-			tripal_db_set_active($previous_db);
-			
-			//add results to views results
-			while ($r = db_fetch_object($resource)) {
-				if (in_array($r->{$subject_id}, $primary_ids)) {
-					$key = array_search($r->{$subject_id}, $primary_ids);
-					$r->{$this->aliases['primary_id']} = $r->{$subject_id};
-					$this->view->result[$key]->relationships[] = clone $r;
-				}
-				if (in_array($r->{$object_id}, $primary_ids)) {
-					$key = array_search($r->{$object_id}, $primary_ids);
-					$r->{$this->aliases['primary_id']} = $r->{$object_id};
-					$this->view->result[$key]->relationships[] = clone $r;
-				}
-			} //end of while
+      foreach ($this->view->result as $row_num => $row) {
+        $primary_ids[$row_num] = $row->{$this->aliases['primary_id']};
+      }
+
+      //generate results from db
+      $sql = "SELECT " . $relationship_tablename . ".*, cvterm.name as type_name, "
+          ."subject_parent.name as subject_name, object_parent.name as object_name "
+          ."FROM " . $relationship_tablename . " "
+          ."LEFT JOIN " . $this->view->base_table . " subject_parent ON "
+            . $relationship_tablename . "." . $subject_id . "=subject_parent." . $this->aliases['primary_id'] . " "
+          ."LEFT JOIN " . $this->view->base_table . " object_parent ON "
+            . $relationship_tablename . "." . $object_id . "=object_parent." . $this->aliases['primary_id'] . " "
+          ."LEFT JOIN cvterm cvterm ON "
+            . $relationship_tablename . ".type_id = cvterm.cvterm_id "
+          . "WHERE " . $relationship_tablename . "." . $subject_id . " IN (" . implode(',', $primary_ids) . ") "
+          . "OR " . $relationship_tablename . "." . $object_id . " IN (" . implode(',', $primary_ids) . ") ";
+      $previous_db = tripal_db_set_active('chado');
+      $resource = db_query($sql);
+      tripal_db_set_active($previous_db);
+
+      //add results to views results
+      while ($r = db_fetch_object($resource)) {
+        if (in_array($r->{$subject_id}, $primary_ids)) {
+          $key = array_search($r->{$subject_id}, $primary_ids);
+          $r->{$this->aliases['primary_id']} = $r->{$subject_id};
+          $this->view->result[$key]->relationships[] = clone $r;
+        }
+        if (in_array($r->{$object_id}, $primary_ids)) {
+          $key = array_search($r->{$object_id}, $primary_ids);
+          $r->{$this->aliases['primary_id']} = $r->{$object_id};
+          $this->view->result[$key]->relationships[] = clone $r;
+        }
+      } //end of while
     }// end of if add values
 
-		//for each stock in this view page, add the values
-		foreach ($values as $result) {
-			if (!empty($result->{$this->aliases['relationships']})) {
-				
-				// all relationships including the current stock
-				$relationships = $result->{$this->aliases['relationships']};
-				foreach ($relationships as $relationship) {			
-					// Add relationship to the list of items to be rendered
-					// Note: $this->aliases['primary_id'] = base table primary key
-					
-					$elements = array(
-					  $this->aliases['primary_id'] => $relationship->{$this->aliases['primary_id']},
-					  $this->aliases['relationship_primary_id'] => $relationship->{$this->aliases['relationship_primary_id']},
-					  'subject_id' => $relationship->{$this->aliases['subject_id']},
-					  'subject_name' => $relationship->subject_name,
-					  'object_id' => $relationship->{$this->aliases['object_id']},
+    //for each stock in this view page, add the values
+    foreach ($values as $result) {
+      if (!empty($result->{$this->aliases['relationships']})) {
+
+        // all relationships including the current stock
+        $relationships = $result->{$this->aliases['relationships']};
+        foreach ($relationships as $relationship) {
+          // Add relationship to the list of items to be rendered
+          // Note: $this->aliases['primary_id'] = base table primary key
+
+          $elements = array(
+            $this->aliases['primary_id'] => $relationship->{$this->aliases['primary_id']},
+            $this->aliases['relationship_primary_id'] => $relationship->{$this->aliases['relationship_primary_id']},
+            'subject_id' => $relationship->{$this->aliases['subject_id']},
+            'subject_name' => $relationship->subject_name,
+            'object_id' => $relationship->{$this->aliases['object_id']},
             'object_name' => $relationship->object_name,
             'type_id' => $relationship->type_id,
             'type_name' => $relationship->type_name,
-					);
-					$this->items[$relationship->{$this->aliases['primary_id']}][$relationship->{$this->aliases['relationship_primary_id']}] = $elements;
-				}
-			}
-		}
-	}
+          );
+          $this->items[$relationship->{$this->aliases['primary_id']}][$relationship->{$this->aliases['relationship_primary_id']}] = $elements;
+        }
+      }
+    }
+  }
 
   function render_item($count, $item) {
-		return $item['subject_name'].' '.$item['type_name'].' '.$item['object_name'];
+    return $item['subject_name'] . ' ' . $item['type_name'] . ' ' . $item['object_name'];
   }
 
 }

+ 14 - 14
tripal_natural_diversity/views/handlers/views_handler_field_chado_relationship_by_type.inc

@@ -1,5 +1,4 @@
 <?php
-// $Id: views_handler_field_term_node_tid.inc,v 1.4 2009/07/01 23:07:14 merlinofchaos Exp $
 
 /**
  * Field handler for terms.
@@ -10,7 +9,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
 
     // Boolean to determine whether
     //    TRUE =>  value (property type)      -more than one property type displayed
-    //    FALSE => or just value is rendered  -only 1 porperty type is displayed    
+    //    FALSE => or just value is rendered  -only 1 porperty type is displayed
     $this->display_type = TRUE;
 
   }
@@ -18,7 +17,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
   function option_definition() {
     $options = parent::option_definition();
     $options['stockrel_type_ids'] = array('default' => array());
-    $options['stockrel_display_options'] = array('default' => array('subject','type','object'));
+    $options['stockrel_display_options'] = array('default' => array('subject', 'type', 'object'));
     return $options;
   }
 
@@ -42,7 +41,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
       ),
       '#default_value' => array($this->options['stockrel_display_parts']['subject'], $this->options['stockrel_display_parts']['type'], $this->options['stockrel_display_parts']['object']),
     );
-    
+
     $form['stockrel_display_rels'] = array(
       '#type' => 'radios',
       '#title' => t('Display Relationships Where'),
@@ -59,7 +58,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
       ),
       '#default_value' => $this->options['stockrel_display_rels'],
     );
-    
+
     $options = tripal_cv_get_cvterm_options( variable_get('chado_stock_relationship_cv', 'null') );
     $form['stockrel_type_ids'] = array(
       '#type' => 'checkboxes',
@@ -80,14 +79,14 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
     $this->aliases['relationships'] = 'relationships';
     $this->aliases['stock_id'] = 'stock_id';
     $this->field_alias = $this->aliases['stock_id'];
-    
+
     //for each stock in this view page
     foreach ($values as $result) {
       if (!empty($result->{$this->aliases['relationships']})) {
-          
+
         // all relationships including the current stock
         $relationships = $result->{$this->aliases['relationships']};
-        foreach ($relationships as $relationship) {      
+        foreach ($relationships as $relationship) {
           // perform filtering------
           //type
           if (!empty($this->options['stockrel_type_ids'])) {
@@ -96,18 +95,19 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
               continue;
             }
           }
-          
+
           //"Display Relationships Where" criteria
           if (preg_match('/subject/', $this->options['stockrel_display_rels'])) {
             if ($relationship->stock_id != $relationship->subject_id) {
               continue;
-            }      
-          } elseif (preg_match('/object/', $this->options['stockrel_display_rels'])) {
+            }
+          }
+          elseif (preg_match('/object/', $this->options['stockrel_display_rels'])) {
             if ($relationship->stock_id != $relationship->object_id) {
               continue;
             }
           }
-          
+
           // Add relationship to the list of items to be rendered
           $this->items[$relationship->stock_id][$relationship->stock_relationship_id]['stock_id'] = $relationship->stock_id;
           $this->items[$relationship->stock_id][$relationship->stock_relationship_id]['stock_relationship_id'] = $relationship->stock_relationship_id;
@@ -124,7 +124,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
 
   function render_item($count, $item) {
     $text = array();
-    
+
     // Render Parts
     if ($this->options['stockrel_display_parts']['subject']) {
       $text[] = $item['subject_name'];
@@ -135,7 +135,7 @@ class views_handler_field_chado_relationship_by_type extends views_handler_field
     if ($this->options['stockrel_display_parts']['object']) {
       $text[] = $item['object_name'];
     }
-    
+
     return implode(' ', $text);
   }
 

+ 25 - 25
tripal_natural_diversity/views/nd_experiment.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_natural_diversity.views.inc --in tripal_natural_diversity_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 nd_experiment table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -23,7 +23,7 @@
   CREATE TABLE nd_experiment (
     nd_experiment_id serial PRIMARY KEY NOT NULL,
     nd_geolocation_id integer NOT NULL references nd_geolocation (nd_geolocation_id) on delete cascade INITIALLY DEFERRED,
-    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED 
+    type_id integer NOT NULL references cvterm (cvterm_id) on delete cascade INITIALLY DEFERRED
   );
  * @endcode
  */
@@ -34,32 +34,32 @@
   // 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['nd_experiment']['table']['group'] = t('Chado ND Experiment');
-  
+
   $data['nd_experiment']['table']['base'] = array(
     'field' => 'nd_experiment_id',
     'title' => t('Chado Natural Diversity Experiment'),
     'help' => t('Represents one data point in a natural diversity project.'),
   );
-  if($database){
+  if ($database) {
      $data['nd_experiment']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: nd_experiment => nd_geolocation
   // In nd_experiment.views.inc
-  
+
   //Join: nd_experiment => nd_experiment_contact => contact
   $data['nd_experiment']['table']['join']['nd_experiment_contact'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['contact'] = array(
     'left_table' => 'nd_experiment_contact',
     'left_field' => 'nd_experiment_id',
@@ -69,12 +69,12 @@
     'left_field' => 'contact_id',
     'field' => 'contact_id',
   );
-  
+
   //Join: nd_experiment => nd_experiment_dbxref => dbxref
   $data['nd_experiment']['table']['join']['nd_experiment_dbxref'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['dbxref'] = array(
     'left_table' => 'nd_experiment_dbxref',
     'left_field' => 'nd_experiment_id',
@@ -84,12 +84,12 @@
     'left_field' => 'dbxref_id',
     'field' => 'dbxref_id',
   );
-  
+
   //Join: nd_experiment => nd_experiment_genotype => genotype
   $data['nd_experiment']['table']['join']['nd_experiment_genotype'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['genotype'] = array(
     'left_table' => 'nd_experiment_genotype',
     'left_field' => 'nd_experiment_id',
@@ -99,12 +99,12 @@
     'left_field' => 'genotype_id',
     'field' => 'genotype_id',
   );
-  
+
   //Join: nd_experiment => nd_experiment_phenotype => phenotype
   $data['nd_experiment']['table']['join']['nd_experiment_phenotype'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['phenotype'] = array(
     'left_table' => 'nd_experiment_phenotype',
     'left_field' => 'nd_experiment_id',
@@ -114,12 +114,12 @@
     'left_field' => 'phenotype_id',
     'field' => 'phenotype_id',
   );
-  
+
   //Join: nd_experiment => nd_experiment_project => project
   $data['nd_experiment']['table']['join']['nd_experiment_project'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['project'] = array(
     'left_table' => 'nd_experiment_project',
     'left_field' => 'nd_experiment_id',
@@ -129,12 +129,12 @@
     'left_field' => 'project_id',
     'field' => 'project_id',
   );
-  
+
   //Join: nd_experiment => nd_experiment_pub => pub
   $data['nd_experiment']['table']['join']['nd_experiment_pub'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['pub'] = array(
     'left_table' => 'nd_experiment_pub',
     'left_field' => 'nd_experiment_id',
@@ -149,7 +149,7 @@
   $data['nd_experiment']['table']['join']['nd_experiment_stock'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
-  );  
+  );
   $data['nd_experiment']['table']['join']['stock'] = array(
     'left_table' => 'nd_experiment_stock',
     'left_field' => 'nd_experiment_id',
@@ -161,7 +161,7 @@
   );
 
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_experiment_id (primary key)
   $data['nd_experiment']['nd_experiment_id'] = array(
     'title' => t('ND Experiment Primary Key'),
@@ -177,6 +177,6 @@
       'handler' => 'views_handler_filter_numeric',
     ),
   );
-    
+
   return $data;
-}
+}

+ 15 - 15
tripal_natural_diversity/views/nd_experimentprop.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_natural_diversity.views.inc --in tripal_natural_diversity_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 nd_experimentprop table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -28,10 +28,10 @@
   // 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['nd_experimentprop']['table'] = array(
     'group' => t('Chado ND Experiment Properties'),
@@ -39,20 +39,20 @@
     'title' => t('Chado ND Experiment Property'),
     'help' => t('Properties of a given Natural Diversity Experiment.'),
   );
-  if($database){
+  if ($database) {
      $data['nd_experimentprop']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: nd_experimentprop => nd_experiment
   $data['nd_experimentprop']['table']['join']['nd_experiment'] = array(
     'left_field' => 'nd_experiment_id',
     'field' => 'nd_experiment_id',
   );
-  
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_experimentprop_id (primary key)
   $data['nd_experimentprop']['nd_experimentprop_id'] = array(
     'title' => t('ND Experiment Property Primary Key'),
@@ -69,7 +69,7 @@
     ),
   );
 
-  //Field: value (varchar 255)   
+  //Field: value (varchar 255)
   $data['nd_experimentprop']['value'] = array(
     'title' => t('Property Value'),
     'help' => t('The value of a given property.'),
@@ -88,7 +88,7 @@
     ),
   );
 
-  //Field: rank (int)   
+  //Field: rank (int)
   $data['nd_experimentprop']['rank'] = array(
     'title' => t('Property Rank'),
     'help' => t('The rank of a given propery.'),
@@ -104,7 +104,7 @@
     ),
   );
 
-  //Calculated Field: type/cvterm name (varchar 255)   
+  //Calculated Field: type/cvterm name (varchar 255)
   $data['nd_experimentprop']['nd_experimentprop_cvterm_name'] = array(
     'title' => t('Property Type'),
     'help' => t('The type of property.'),
@@ -121,7 +121,7 @@
     'argument' => array(
       'handler' => 'views_handler_argument_string',
     ),
-  );  
-  
+  );
+
   return $data;
-}
+}

+ 19 - 19
tripal_natural_diversity/views/nd_geolocation.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_natural_diversity.views.inc --in tripal_natural_diversity_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 nd_geolocation table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -28,32 +28,32 @@
   // 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['nd_geolocation']['table']['group'] = t('Chado ND geolocation');
-  
+
   $data['nd_geolocation']['table']['base'] = array(
     'field' => 'nd_geolocation_id',
     'title' => t('Chado Natural Diversity Geolocation'),
     'help' => t('A listing of locations where Natural Diversity Experiments can be performed.'),
   );
-  if($database){
+  if ($database) {
      $data['nd_geolocation']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: nd_geolocation => nd_experiment
   $data['nd_geolocation']['table']['join']['nd_experiment'] = array(
     'left_field' => 'nd_geolocation_id',
     'field' => 'nd_geolocation_id',
-  );  
-  
+  );
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_geolocation_id (primary key)
   $data['nd_geolocation']['nd_geolocation_id'] = array(
     'title' => t('ND Geolocation Primary Key'),
@@ -70,7 +70,7 @@
     ),
   );
 
-  //Field: description (varchar 255)   
+  //Field: description (varchar 255)
   $data['nd_geolocation']['description'] = array(
     'title' => t('Description'),
     'help' => t('A short description of a given geolocation.'),
@@ -89,7 +89,7 @@
     ),
   );
 
-  //Field: latitude (real)   
+  //Field: latitude (real)
   $data['nd_geolocation']['latitude'] = array(
     'title' => t('Latitude'),
     'help' => t('The decimal latitude coordinate of the georeference, using positive and negative sign to indicate N and S, respectively.'),
@@ -105,7 +105,7 @@
     ),
   );
 
-  //Field: longitude (real)   
+  //Field: longitude (real)
   $data['nd_geolocation']['longitude'] = array(
     'title' => t('Longitude'),
     'help' => t('The decimal longitude coordinate of the georeference, using positive and negative sign to indicate E and W, respectively.'),
@@ -121,7 +121,7 @@
     ),
   );
 
-  //Field: altitude (real)   
+  //Field: altitude (real)
   $data['nd_geolocation']['altitude'] = array(
     'title' => t('Altitude'),
     'help' => t('The altitude (elevation) of the location in meters. If the altitude is only known as a range, this is the average, and altitude_dev will hold half of the width of the range.'),
@@ -137,7 +137,7 @@
     ),
   );
 
-  //Field: geodetic_datum (varchar 255)   
+  //Field: geodetic_datum (varchar 255)
   $data['nd_geolocation']['geodetic_datum'] = array(
     'title' => t('Deodetic Datum'),
     'help' => t('The geodetic system on which the geo-reference coordinates are based. For geo-references measured between 1984 and 2010, this will typically be WGS84.'),
@@ -155,7 +155,7 @@
       'handler' => 'views_handler_argument_string',
     ),
   );
-  
-    
+
+
   return $data;
-}
+}

+ 16 - 16
tripal_natural_diversity/views/nd_geolocationprop.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_natural_diversity.views.inc --in tripal_natural_diversity_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 nd_geolocationprop table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -28,10 +28,10 @@
   // 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['nd_geolocationprop']['table'] = array(
     'field' => 'nd_geolocationprop_id',
@@ -39,20 +39,20 @@
     'help' => t('Properties of Natural Diversity Geolocations.'),
     'group' => t('Chado ND Geolocation Properties'),
   );
-  if($database){
+  if ($database) {
      $data['nd_geolocationprop']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: nd_geolocation => nd_geolocationprop
   $data['nd_geolocationprop']['table']['join']['nd_geolocation'] = array(
     'left_field' => 'nd_geolocation_id',
     'field' => 'nd_geolocation_id',
   );
-  
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_geolocationprop_id (primary key)
   $data['nd_geolocationprop']['field_name'] = array(
     'title' => t('ND Geolocation Property Primary Key'),
@@ -68,8 +68,8 @@
       'handler' => 'views_handler_filter_numeric',
     ),
   );
-  
-  //Field: value (varchar 255)   
+
+  //Field: value (varchar 255)
   $data['nd_geolocationprop']['value'] = array(
     'title' => t('Property Value'),
     'help' => t('The value of a given property.'),
@@ -88,7 +88,7 @@
     ),
   );
 
-  //Field: rank (int)   
+  //Field: rank (int)
   $data['nd_geolocationprop']['rank'] = array(
     'title' => t('Property Rank'),
     'help' => t('The rank of a given propery.'),
@@ -104,7 +104,7 @@
     ),
   );
 
-  //Calculated Field: type/cvterm name (varchar 255)   
+  //Calculated Field: type/cvterm name (varchar 255)
   $data['nd_geolocationprop']['nd_geolocationprop_cvterm_name'] = array(
     'title' => t('Property Type'),
     'help' => t('The type of property.'),
@@ -121,7 +121,7 @@
     'argument' => array(
       'handler' => 'views_handler_argument_string',
     ),
-  );  
-    
+  );
+
   return $data;
-}
+}

+ 29 - 29
tripal_natural_diversity/views/nd_reagent.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_natural_diversity.views.inc --in tripal_natural_diversity_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 nd_reagent table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -33,24 +33,24 @@
   // 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['nd_reagent']['table']['group'] = t('Chado ND Reagent');
-  
+
   $data['nd_reagent']['table']['base'] = array(
     'field' => 'nd_reagent_id',
     'title' => t('Chado Natural Diversity Reagent'),
     'help' => t('Reagents used in Natural Diversity Experiments.'),
   );
-  if($database){
+  if ($database) {
      $data['nd_reagent']['table']['base']['database'] = $database;
   }
-   
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_reagent_id (primary key)
   $data['nd_reagent']['nd_reagent_id'] = array(
     'title' => t('ND Reagent Primary Key'),
@@ -67,7 +67,7 @@
     ),
   );
 
-  //Field: name (varchar 255)   
+  //Field: name (varchar 255)
   $data['nd_reagent']['name'] = array(
     'title' => t('Name'),
     'help' => t('The name of the reagent.'),
@@ -88,27 +88,27 @@
 
   //Field: type_id (foreign key)
   // Join described in cvterm.views.inc
-  
+
   //Field: feature_id (foreign key)
   // Join described in feature.views.inc
- 
- 	//Calculated Field: stock relationships (ALL)
-	// uses a custom field handler which pulls results from the view
-	// actual query performed in chado_stock_views_views_pre_render	(&$view) -file:tripal_stock.views.inc
-	$data['nd_reagent']['all_relationships'] = array(
-  	'title' => t('All Reagent Relationships'),
-  	'help' => t('Relationships including the current reagent.'),
-  	'field' => array(
-    	'title' => t('All Relationships'),
-    	'help' => t('Display all relationships including the current reagent.'),
-    	'handler' => 'views_handler_field_chado_relationship_all',
-  	),
-	);
 
-	//Calculated Field: stock relationships
-	// uses a custom field handler which pulls results from the view
-	// actual query performed in chado_stock_views_views_pre_render	(&$view) -file:tripal_stock.views.inc
-	$data['nd_reagent']['relationships'] = array(
+   //Calculated Field: stock relationships (ALL)
+  // uses a custom field handler which pulls results from the view
+  // actual query performed in chado_stock_views_views_pre_render  (&$view) -file:tripal_stock.views.inc
+  $data['nd_reagent']['all_relationships'] = array(
+    'title' => t('All Reagent Relationships'),
+    'help' => t('Relationships including the current reagent.'),
+    'field' => array(
+      'title' => t('All Relationships'),
+      'help' => t('Display all relationships including the current reagent.'),
+      'handler' => 'views_handler_field_chado_relationship_all',
+    ),
+  );
+
+  //Calculated Field: stock relationships
+  // uses a custom field handler which pulls results from the view
+  // actual query performed in chado_stock_views_views_pre_render  (&$view) -file:tripal_stock.views.inc
+  $data['nd_reagent']['relationships'] = array(
     'title' => t('ND Reagent Relationships'),
     'help' => t('Relationships including the current reagent.'),
     'field' => array(
@@ -118,4 +118,4 @@
     ),
   );
   return $data;
-}
+}

+ 15 - 15
tripal_natural_diversity/views/nd_reagentprop.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_natural_diversity.views.inc --in tripal_natural_diversity_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 nd_reagentprop table, it's fields and any joins between it and other tables
  * @see tripal_natural_diversity_views_data() --in tripal_natural_diversity.views.inc
  *
@@ -28,18 +28,18 @@
   // 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-----------------------------------  
+
+  //Basic table definition-----------------------------------
   $data['nd_reagentprop']['table'] = array(
     'field' => 'primary_id',
     'title' => t('Chado ND Reagent Property'),
     'help' => t('Properties of Natural Diversity Reagents.'),
     'group' => t('Chado ND Reagent Property'),
   );
-  if($database){
+  if ($database) {
      $data['nd_reagentprop']['table']['database'] = $database;
   }
 
@@ -49,9 +49,9 @@
     'left_field' => 'nd_reagent_id',
     'field' => 'nd_reagent_id',
   );
-   
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: nd_reagentprop_id (primary key)
   $data['nd_reagentprop']['nd_reagentprop_id'] = array(
     'title' => t('ND Reagent Propery Primary Key'),
@@ -67,7 +67,7 @@
       'handler' => 'views_handler_filter_numeric',
     ),
   );
-  //Field: value (varchar 255)   
+  //Field: value (varchar 255)
   $data['nd_reagentprop']['value'] = array(
     'title' => t('Property Value'),
     'help' => t('The value of a given property.'),
@@ -86,7 +86,7 @@
     ),
   );
 
-  //Field: rank (int)   
+  //Field: rank (int)
   $data['nd_reagentprop']['rank'] = array(
     'title' => t('Property Rank'),
     'help' => t('The rank of a given propery.'),
@@ -102,7 +102,7 @@
     ),
   );
 
-  //Calculated Field: type/cvterm name (varchar 255)   
+  //Calculated Field: type/cvterm name (varchar 255)
   $data['nd_reagentprop']['nd_reagentprop_cvterm_name'] = array(
     'title' => t('Property Type'),
     'help' => t('The type of property.'),
@@ -119,7 +119,7 @@
     'argument' => array(
       'handler' => 'views_handler_argument_string',
     ),
-  );  
-    
+  );
+
   return $data;
-}
+}

+ 28 - 28
tripal_natural_diversity/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_natural_diversity.views.inc:tripal_natural_diversity_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_natural_diversity.views.inc --in tripal_natural_diversity_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_natural_diversity_views_data() --in tripal_natural_diversity.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_natural_diversity/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_natural_diversity.views.inc:tripal_natural_diversity_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_natural_diversity.views.inc --in tripal_natural_diversity_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_natural_diversity_views_data() --in tripal_natural_diversity.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;
-}
+}

+ 36 - 30
tripal_organism/tripal_organism.api.inc

@@ -1,10 +1,15 @@
 <?php
- 
-/*************************************************************************
+
+/**
+ * @file
+ * Provides an API to tripal organisms
+ */
+
+/**
  * Purpose: Create an options array to be used in a form element
  *   which provides a list of all chado organisms
  *
- * @return an array(organism_id => common_name) 
+ * @return an array(organism_id => common_name)
  *   for each organism in the chado organism table
  *
  * @ingroup tripal_organism_api
@@ -13,7 +18,7 @@ function tripal_organism_get_organism_options() {
 
   $previous_db = tripal_db_set_active('chado');
   $result = db_query(
-    "SELECT organism_id, common_name FROM organism"
+    "SELECT organism_id, common_name FROM {organism}"
   );
   tripal_db_set_active($previous_db);
 
@@ -26,41 +31,42 @@ function tripal_organism_get_organism_options() {
 
 }
 
-/*************************************************************************
+/**
  * Purpose: Return a given organism object using the nid
  *
  * @return organism object created by node load
  *
  * @ingroup tripal_organism_api
  */
-function tripal_organism_get_organism_by_nid ($nid) {
+function tripal_organism_get_organism_by_nid($nid) {
+
+  return node_load($nid);
 
-	return node_load($nid);
-	
 }
 
-/*************************************************************************
+/**
  * Purpose: Return a given organism object using the organism id
  *
  * @return organism object created by node load
  *
  * @ingroup tripal_organism_api
  */
-function tripal_organism_get_organism_by_organism_id ($organism_id) {
-
-	$sql = "SELECT nid FROM {chado_organism} WHERE organism_id=%d";
-	$r = db_fetch_object(db_query($sql, $organism_id));
-	if (!empty($r->nid)) {
-		return node_load($r->nid);
-	} else {
-		drupal_set_message("Function: tripal_organism_get_organism_by_organism_id() -no organism with that organism id sync'd with drupal", 'error');
-	}
-	
-	return 0;
-	
+function tripal_organism_get_organism_by_organism_id($organism_id) {
+
+  $sql = "SELECT nid FROM {chado_organism} WHERE organism_id=%d";
+  $r = db_fetch_object(db_query($sql, $organism_id));
+  if (!empty($r->nid)) {
+    return node_load($r->nid);
+  }
+  else {
+    drupal_set_message("Function: tripal_organism_get_organism_by_organism_id() -no organism with that organism id sync'd with drupal", 'error');
+  }
+
+  return 0;
+
 }
 
-/****************************************************************************
+/*****
  * @section Chado Table Descriptions
  * There should be a default table description for all chado tables included
  * in core.
@@ -79,7 +85,7 @@ function tripal_organism_get_organism_by_organism_id ($organism_id) {
  */
 function tripal_organism_chado_organism_schema() {
   $description = array();
-  
+
   $referring_tables = array(
     'biomaterial',
     'feature',
@@ -91,7 +97,7 @@ function tripal_organism_chado_organism_schema() {
     'wwwuser_organism'
   );
   $description['referring_tables'] = $referring_tables;
-  
+
   return $description;
 }
 
@@ -108,21 +114,21 @@ function tripal_organism_chado_organism_schema() {
  */
 function tripal_organism_chado_organismprop_schema() {
   $description = array();
-  
+
   $description['foreign keys']['cvterm'] = array(
         'table' => 'cvterm',
         'columns' => array(
           'type_id' => 'cvterm_id',
         ),
   );
-  
+
   $description['foreign keys']['organism'] = array(
         'table' => 'organism',
         'columns' => array(
           'organism_id' => 'organism_id',
         ),
   );
-  
+
   return $description;
 }
 /**
@@ -142,11 +148,11 @@ function tripal_organism_get_synced() {
    $org_list = array();
 
    // iterate through the organisms and build an array of those that are synced
-   while($org = db_fetch_object($orgs)){
+   while ($org = db_fetch_object($orgs)) {
       $previous_db = tripal_db_set_active('chado');  // use chado database
-      $info = db_fetch_object(db_query($csql,$org->organism_id));
+      $info = db_fetch_object(db_query($csql, $org->organism_id));
       tripal_db_set_active($previous_db);  // now use drupal database
       $org_list[] = $info;
-   }  
+   }
    return $org_list;
 }

+ 15 - 10
tripal_organism/tripal_organism.install

@@ -1,22 +1,27 @@
 <?php
 
+/**
+ * @file
+ * Functions pertaining to the install/uninstall of this module
+ */
+
 /**
 *  Implementation of hook_install();
 *
 * @ingroup tripal_organism
 */
-function tripal_organism_install(){
+function tripal_organism_install() {
 
    // create the module's data directory
    tripal_create_moddir('tripal_organism');
 
-   // create the directory where image files will be stored.  We create this 
+   // create the directory where image files will be stored.  We create this
    // here otherwise it will get created when the first organism is synced.
-   // The user that performs the syncing will receive ownership of the 
+   // The user that performs the syncing will receive ownership of the
    // images directory which may not allow for write access by the web server
    // user.  So, we create it here
    $dest = file_directory_path() . "/tripal/tripal_organism/images";
-   file_check_directory($dest,FILE_CREATE_DIRECTORY);
+   file_check_directory($dest, FILE_CREATE_DIRECTORY);
 
    // create the tables that correlate drupal nodes with chado
    // features, organisms, etc....
@@ -31,7 +36,7 @@ function tripal_organism_install(){
 */
 function tripal_organism_schema() {
    $schema = tripal_organism_get_schemas();
-	return $schema;
+  return $schema;
 }
 
 /**
@@ -39,7 +44,7 @@ function tripal_organism_schema() {
 *
 * @ingroup tripal_organism
 */
-function tripal_organism_uninstall(){
+function tripal_organism_uninstall() {
    drupal_uninstall_schema('tripal_organism');
 
    // Get the list of nodes to remove
@@ -52,11 +57,11 @@ function tripal_organism_uninstall(){
    }
 
    // remove the materialized views
-   
+
    // Remove the custom view if exists
    if (db_table_exists('tripal_organism_views_common_name')) {
       $sql = "DROP TABLE {tripal_organism_views_common_name}";
-      db_query ($sql);
+      db_query($sql);
    }
 }
 
@@ -68,7 +73,7 @@ function tripal_organism_uninstall(){
 *
 * @ingroup tripal_organism
 */
-function tripal_organism_get_schemas (){
+function tripal_organism_get_schemas() {
   $schema = array();
 
   $schema['chado_organism'] = array(
@@ -95,7 +100,7 @@ function tripal_organism_get_schemas (){
          'organism_id' => array('organism_id')
       ),
       'unique keys' => array(
-         'nid_vid' => array('nid','vid'),
+         'nid_vid' => array('nid', 'vid'),
          'vid' => array('vid')
       ),
       'primary key' => array('nid'),

File diff suppressed because it is too large
+ 230 - 222
tripal_organism/tripal_organism.module


+ 11 - 11
tripal_organism/tripal_organism.views.inc

@@ -6,7 +6,7 @@
  *  chado/tripal organism tables. Supplementary functions can be found in
  *  ./views/
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
@@ -17,13 +17,13 @@
  */
 
 require_once('views/organism.views.inc');
-require_once('views/chado_organism.views.inc'); 
+require_once('views/chado_organism.views.inc');
 /**
  * Implements hook_views_data()
  * Purpose: Describe chado/tripal tables & fields to views
  * @return: a data array which follows the structure outlined in the
  *   views2 documentation for this hook. Essentially, it's an array of table
- *   definitions keyed by chado/tripal table name. Each table definition 
+ *   definitions keyed by chado/tripal table name. Each table definition
  *   includes basic details about the table, fields in that table and
  *   relationships between that table and others (joins)
  *
@@ -31,17 +31,17 @@ require_once('views/chado_organism.views.inc');
  */
 function tripal_organism_views_data()  {
   $data = array();
-  
+
   $data = array_merge($data, retrieve_organism_views_data());
   $data = array_merge($data, retrieve_chado_organism_views_data());
-  
+
   return $data;
 }
 
 /**
  * Implements hook_views_handlers()
  * Purpose: Register all custom handlers with views
- *   where a handler describes either "the type of field", 
+ *   where a handler describes either "the type of field",
  *   "how a field should be filtered", "how a field should be sorted"
  * @return: An array of handler definitions
  *
@@ -68,7 +68,7 @@ function tripal_organism_views_handlers() {
  */
 function tripal_organism_views_data_alter(&$data) {
 
-  if( !(is_array($db_url) and array_key_exists('chado',$db_url)) ){
+  if ( !(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
 
     // Add featuer relationship to node
     $data['node']['organism_chado_nid'] = array(
@@ -86,16 +86,16 @@ function tripal_organism_views_data_alter(&$data) {
       ),
     );
   }
-  
+
 }
 
 /**
  *
  * @ingroup tripal_organism_views
  */
-function tripal_organism_views_default_views () {
+function tripal_organism_views_default_views() {
   $views = array();
-  
+
   // Main default view
   // List all cvterms based on cv
   $view = new view;
@@ -375,6 +375,6 @@ function tripal_organism_views_default_views () {
     'name' => 'navigation',
   ));
   $views[$view->name] = $view;
-  
+
   return $views;
 }

+ 24 - 23
tripal_organism/views/chado_organism.views.inc

@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Purpose: this function returns the portion of the data array 
+ * @file
+ * Purpose: this function returns the portion of the data array
  *   which describes the chado_organism drupal table, it's fields and any joins between it and other tables
  * @see tripal_organism_views_data() --in tripal_organism.views.inc
  *
@@ -9,14 +10,14 @@
  *
  * @ingroup tripal_organism_views
  */
-function retrieve_chado_organism_views_data () {
-	global $db_url;
+function retrieve_chado_organism_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;
   }
@@ -26,42 +27,42 @@ function retrieve_chado_organism_views_data () {
     '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,
+       'handler' => 'views_handler_field_numeric',
+       'click sortable' => TRUE,
     ),
     'filter' => array(
-     	'handler' => 'views_handler_filter_numeric',
+       'handler' => 'views_handler_filter_numeric',
     ),
     'sort' => array(
-     	'handler' => 'views_handler_sort',
+       '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',
+    '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',
+    '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',
-  );  
+    'left_table' => 'chado_organism',
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
 
   // Add relationship between chado_organism and organism
   $data['chado_organism']['organism_id'] = array(
@@ -94,6 +95,6 @@ function retrieve_chado_organism_views_data () {
       'base field' => 'nid'
     ),
   );
-*/  
-	return $data;
+*/
+  return $data;
 }

+ 12 - 12
tripal_organism/views/handlers/views_handler_field_computed_organism_nid.inc

@@ -1,17 +1,17 @@
 <?php
 
 class views_handler_field_computed_organism_nid extends views_handler_field_numeric {
-	function construct() {
-		parent::construct();
-		$this->additional_fields['organism_id'] = array('table' => 'organism', 'field' => 'organism_id');
-	}
+  function construct() {
+    parent::construct();
+    $this->additional_fields['organism_id'] = array('table' => 'organism', 'field' => 'organism_id');
+  }
 
-	function query() { 
-		$this->ensure_my_table();
-		$this->add_additional_fields(); 
-	}
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
 
-	function render($values) { 
-		return $values->organism_nid;
-	}
-} 
+  function rend) {er($values) {
+    return $values->organism_nid;
+  }
+}

+ 26 - 24
tripal_organism/views/organism.views.inc

@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Purpose: this function returns the portion of the data array 
+ * @file
+ * Purpose: this function returns the portion of the data array
  *   which describes the organism table, it's fields and any joins between it and other tables
  * @see tripal_organism_views_data() --in tripal_organism.views.inc
  *
@@ -25,25 +26,25 @@
  * @ingroup tripal_organism_views
  */
 function retrieve_organism_views_data() {
-	global $db_url;
-	$data = array();
-	
-	// if the chado database is not local to the drupal database
+  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)) {
      $database = 'chado';
   }
 
-	
+
   // Basic table definition
   $data['organism']['table']['group'] = 'Chado Organism';
   $data['organism']['table']['base'] = array(
     'field' => 'organism_id',
     'title' => 'Chado Organism',
-    'help' => 'Organisms existing in the Chado Database',                                                                                                                                                                          
+    'help' => 'Organisms existing in the Chado Database',
   );
-  if($database){
+  if ($database) {
      $data['organism']['table']['base']['database'] = $database;
   }
 
@@ -61,7 +62,7 @@ function retrieve_organism_views_data() {
       'left_field' => 'organism_id',
       'field' => 'organism_id',
     ),
-  ); 
+  );
 
   // Table Field Definitions----------------------
   // Field: organism_id (primary key)
@@ -79,22 +80,23 @@ function retrieve_organism_views_data() {
        'handler' => 'views_handler_sort',
      ),
      'argument' => array(
-     	 'handler' => 'views_handler_argument',
+        'handler' => 'views_handler_argument',
      ),
   );
 
   // 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 && module_exists('tripal_views')){
-	  $data['organism']['organism_nid'] = array(
-  	  'title' => 'Node ID',
-    	'help' => 'This is the node ID of this organism. It can be used as a link to the node.',
-    	'field' => array(
-      	'handler' => 'views_handler_field_computed_organism_nid',
-    	),    
-  	);
-  } else {
+  if ($database && module_exists('tripal_views')) {
+    $data['organism']['organism_nid'] = array(
+      'title' => 'Node ID',
+      'help' => 'This is the node ID of this organism. It can be used as a link to the node.',
+      'field' => array(
+        'handler' => 'views_handler_field_computed_organism_nid',
+      ),
+    );
+  }
+  else {
     // Add relationship between chado_organism and organism
     $data['organism']['organism_id'] = array(
       'group' => 'Organism',
@@ -112,7 +114,7 @@ function retrieve_organism_views_data() {
     );
 
   }
-	
+
   // Field: abbreviation (varchar 255)
   $data['organism']['abbreviation'] = array(
     'title' => 'Abbreviation',
@@ -131,7 +133,7 @@ function retrieve_organism_views_data() {
        '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 && module_exists('tripal_views')) {
     $data['organism']['abbreviation']['field']['handler'] = 'views_handler_field_node_optional';
   }
@@ -192,7 +194,7 @@ function retrieve_organism_views_data() {
        '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 && module_exists('tripal_views')) {
     $data['organism']['common_name']['field']['handler'] = 'views_handler_field_node_optional';
   }
@@ -212,7 +214,7 @@ function retrieve_organism_views_data() {
        'handler' => 'views_handler_argument_string',
      ),
   );
-  
+
   //Calculated Field: Count (Int)
   // Provides the number of features for a given organism
   // @see tripal_feature/views/misc_tables.views.inc

+ 28 - 28
tripal_organism/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_organism.views.inc:tripal_organism_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_organism.views.inc --in tripal_organism_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_organism_views_data() --in tripal_organism.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_organism/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_organism.views.inc:tripal_organism_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_organism.views.inc --in tripal_organism_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_organism_views_data() --in tripal_organism.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;
-}
+}

+ 4 - 4
tripal_phenotype/tripal_phenotype.module

@@ -3,9 +3,9 @@
 /**
  *  @file
  * This file contains the basic functions needed for this drupal module.
- * The drupal tripal_phenotype module maps directly to the chado X module. 
+ * The drupal tripal_phenotype module maps directly to the chado X module.
  *
- * For documentation regarding the Chado X module: 
+ * For documentation regarding the Chado X module:
  * @see http://gmod.org/wiki/Chado_General_Module
  */
 
@@ -14,9 +14,9 @@
  * Purpose: Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_phenotype.views.inc where all the
  *  views integration code is
- */ 
+ */
 function tripal_phenotype_views_api() {
    return array(
       'api' => 2.0,
    );
-}
+}

+ 28 - 28
tripal_phenotype/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_phenotype.views.inc:tripal_phenotype_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_phenotype.views.inc --in tripal_phenotype_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_phenotype_views_data() --in tripal_phenotype.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_phenotype/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_phenotype.views.inc:tripal_phenotype_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_phenotype.views.inc --in tripal_phenotype_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_phenotype_views_data() --in tripal_phenotype.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;
-}
+}

+ 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 - 34
tripal_project/tripal_project.install

@@ -1,11 +1,10 @@
 <?php
-// $Id$
 
 /**
  * @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 +14,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 +29,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;
-}
+}

+ 47 - 48
tripal_pub/tripal_pub.install

@@ -1,11 +1,10 @@
 <?php
-// $Id$
 
 /**
  * @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
@@ -17,23 +16,23 @@
  */
 function tripal_pub_install() {
 
-	drupal_install_schema('tripal_pub');
-	$dbxref = array('accession' => 'abstract', 'db_id'=>array('name'=>'tripal'));
-	$success = tripal_core_chado_insert('dbxref',$dbxref);
-	if ($success) {
-		tripal_core_chado_insert('cvterm',array('name'=>'abstract','cv_id'=>array('name'=>'tripal'), 'db
-xref_id'=>$dbxref));
-	}
+  drupal_install_schema('tripal_pub');
+  $dbxref = array('accession' => 'abstract', 'db_id' => array('name' => 'tripal'));
+  $success = tripal_core_chado_insert('dbxref', $dbxref);
+  if ($success) {
+    tripal_core_chado_insert('cvterm', array('name' => 'abstract', 'cv_id' => array('name' => 'tripal'), 'db
+xref_id' => $dbxref));
+  }
 }
 
 
 /**
- * Implementation of hook_uninstall() 
+ * Implementation of hook_uninstall()
  */
 function tripal_pub_uninstall() {
-	//Remove tables
-	drupal_uninstall_schema('tripal_pub');
-	
+  //Remove tables
+  drupal_uninstall_schema('tripal_pub');
+
 }
 
 
@@ -42,49 +41,49 @@ function tripal_pub_uninstall() {
  */
 function tripal_pub_schema() {
 //specification for 'tripal_pub_instances'
-	$schema['chado_pub'] = array(
-		
-		'fields' => array(
-      
-	    //a int field that cannot be null and acts as a unique identifier for all nid's
+  $schema['chado_pub'] = 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
-    	 'pub_id' => array(
-   	   	'type' => 'int',
-   	   	'unsigned' => TRUE,
-   	   	'not null' => TRUE,
-    	),	
-    	
-    	 //a intfield, not null and project_id is the unique_id of the project in chado
-    	 'pubmed_id' => array(
-   	   	'type' => 'int',
-   	   	'unsigned' => TRUE,
-   	   	'not null' => FALSE,
-    	),
-    	'author' => array(
+       'pub_id' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+      ),
+
+       //a intfield, not null and project_id is the unique_id of the project in chado
+       'pubmed_id' => array(
+          'type' => 'int',
+          'unsigned' => TRUE,
+          'not null' => FALSE,
+      ),
+      'author' => array(
         'type' => 'text',
         'size' => 'normal',
         'not null' => TRUE,
         'default' => '',
         'description' => 'The Author Name.',
       ),
-  	 ), 	
+     ),
      //end of shema
-  	
-  	'primary key' => array('nid'),
-	
-	);
+
+    'primary key' => array('nid'),
+
+  );
 
   return $schema;
 }

File diff suppressed because it is too large
+ 487 - 486
tripal_pub/tripal_pub.module


+ 28 - 28
tripal_pub/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_pub.views.inc:tripal_pub_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_pub.views.inc --in tripal_pub_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_pub_views_data() --in tripal_pub.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_pub/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_pub.views.inc:tripal_pub_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_pub.views.inc --in tripal_pub_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_pub_views_data() --in tripal_pub.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;
-}
+}

+ 13 - 13
tripal_search/tripal_search.module

@@ -5,9 +5,9 @@
 /*******************************************************************************
  * Tripal Search initiation
  ******************************************************************************/
-function tripal_search_init(){
+function tripal_search_init() {
    // Add javascript
-   drupal_add_js(drupal_get_path('theme', 'tripal').
+   drupal_add_js(drupal_get_path('theme', 'tripal') .
                                   '/js/tripal_search.js');
 }
 /*******************************************************************************
@@ -35,11 +35,11 @@ function tripal_search_form_alter(&$form, $form_state, $form_id) {
   if ($form_id == 'search_form' && arg(2)) {
     // for pagination etc.
     $get = drupal_query_string_encode($_GET, array('q'));
-    if(preg_match("/node/",arg(1))){
+    if (preg_match("/node/", arg(1))) {
       $form['basic']['inline']['fasta'] = array('#type' => 'markup',
           '#value' => "<br><br><a id=\"tripal_search_link\" href=\"".
                       url('tripal_search/'. arg(1) .'/'. urlencode(search_get_keys()),
-                      array('query' => trim($get)?$get:NULL)).
+                      array('query' => trim($get)?$get:NULL)) .
                       "\">Download features (multi-FASTA format)</a><br><br>");
 
     }
@@ -58,8 +58,8 @@ function tripal_search_view() {
     return drupal_not_found();
   }
 
-  if (trim($keys)) {  	
-    $results = tripal_do_search($keys,$type);    //var_dump($pager_total['0']);
+  if (trim($keys)) {
+    $results = tripal_do_search($keys, $type);    //var_dump($pager_total['0']);
     return tripal_search_file($type, $keys, $results);
   }
 }
@@ -71,24 +71,24 @@ function tripal_search_file($type, $keys, $results) {
 
   drupal_set_header('Content-Type: text');
   drupal_set_header('Content-Disposition: attachment; filename="searchresults.fasta"');
-	
+
   foreach ($results as $result) {
     // Get feature id from drupal database
     $sqld = "SELECT * FROM {chado_feature} CF INNER JOIN {node} N on N.nid = CF.nid WHERE CF.nid = %d";
-    if($f_objd = db_fetch_object(db_query($sqld, $result->sid))){
+    if ($f_objd = db_fetch_object(db_query($sqld, $result->sid))) {
 
        // Get sequence from chado database
        $previous_db = tripal_db_set_active('chado');  // use chado database
        $sqlc = "SELECT * FROM {feature} WHERE feature_id = '%s'";
-       $f_objc = db_fetch_object(db_query($sqlc,$f_objd->feature_id));
+       $f_objc = db_fetch_object(db_query($sqlc, $f_objd->feature_id));
        tripal_db_set_active($previous_db);  // now use drupal database
        print tripal_feature_return_fasta($f_objc, $desc);
-    } 
+    }
   }
 }
 
 /*******************************************************************************
- *  This code is a duplicate of the do_search function but with the paging 
+ *  This code is a duplicate of the do_search function but with the paging
  *  call replaced by a simle db_query call.
  */
 function tripal_do_search($keywords, $type, $join1 = '', $where1 = '1 = 1', $arguments1 = array(), $columns2 = 'i.relevance AS score', $join2 = '', $arguments2 = array(), $sort_parameters = 'ORDER BY score DESC') {
@@ -129,10 +129,10 @@ function tripal_do_search($keywords, $type, $join1 = '', $where1 = '1 = 1', $arg
   $select = "SELECT i.type, i.sid, $columns2 FROM {search_index} i $join $join2 WHERE $conditions GROUP BY i.type, i.sid HAVING COUNT(*) >= %d";
   $count_select =  "SELECT COUNT(*) FROM ($select) n1";
   $arguments = array_merge($arguments2, $arguments1, array($query[4]));
- 
+
   // Do actual search query
 //  $result = pager_query("$select $sort_parameters", 10, 0, $count_select, $arguments);
-  $result = db_query("$select $sort_parameters",$arguments);
+  $result = db_query("$select $sort_parameters", $arguments);
   $results = array();
   while ($item = db_fetch_object($result)) {
     $results[] = $item;

Some files were not shown because too many files changed in this diff