Quellcode durchsuchen

Merge branch '7.x-2.x' of git.drupal.org:sandbox/spficklin/1337878 into 7.x-2.x

Lacey Sanderson vor 11 Jahren
Ursprung
Commit
2e42460830
95 geänderte Dateien mit 2726 neuen und 1912 gelöschten Zeilen
  1. 1 0
      tripal_analysis/tripal_analysis.module
  2. 15 33
      tripal_db/api/tripal_db.api.inc
  3. 22 24
      tripal_db/includes/tripal_db.admin.inc
  4. 5 1
      tripal_db/tripal_db.install
  5. 18 18
      tripal_db/tripal_db.module
  6. 13 2
      tripal_db/tripal_db.views_default.inc
  7. 25 7
      tripal_feature/api/tripal_feature.api.inc
  8. 4 0
      tripal_feature/api/tripal_feature.schema.api.inc
  9. 16 17
      tripal_feature/includes/tripal_feature.admin.inc
  10. 6 2
      tripal_feature/includes/tripal_feature.blocks.inc
  11. 46 22
      tripal_feature/includes/tripal_feature.chado_node.inc
  12. 58 13
      tripal_feature/includes/tripal_feature.delete.inc
  13. 161 109
      tripal_feature/includes/tripal_feature.fasta_loader.inc
  14. 208 166
      tripal_feature/includes/tripal_feature.gff_loader.inc
  15. 124 103
      tripal_feature/includes/tripal_feature.seq_extract.inc
  16. 17 11
      tripal_feature/tripal_feature.drush.inc
  17. 15 6
      tripal_feature/tripal_feature.install
  18. 111 67
      tripal_feature/tripal_feature.module
  19. 4 7
      tripal_feature/tripal_feature.views.inc
  20. 11 0
      tripal_feature/tripal_feature.views_default.inc
  21. 10 1
      tripal_feature/views_handlers/views_handler_field_residues.inc
  22. 15 2
      tripal_featuremap/api/tripal_featuremap.api.inc
  23. 6 10
      tripal_featuremap/includes/tripal_featuremap.admin.inc
  24. 28 7
      tripal_featuremap/includes/tripal_featuremap.chado_node.inc
  25. 22 8
      tripal_featuremap/tripal_featuremap.install
  26. 35 34
      tripal_featuremap/tripal_featuremap.module
  27. 12 1
      tripal_featuremap/tripal_featuremap.views_default.inc
  28. 1 1
      tripal_genetic/api/tripal_genetic.api.inc
  29. 9 0
      tripal_genetic/includes/tripal_genetic.admin.inc
  30. 5 0
      tripal_genetic/includes/tripal_genetic.schema.inc
  31. 7 0
      tripal_genetic/tripal_genetic.install
  32. 17 7
      tripal_genetic/tripal_genetic.module
  33. 12 1
      tripal_genetic/tripal_genetic.views_default.inc
  34. 6 0
      tripal_library/api/tripal_library.api.inc
  35. 9 11
      tripal_library/includes/tripal_library.admin.inc
  36. 33 8
      tripal_library/includes/tripal_library.chado_node.inc
  37. 26 11
      tripal_library/tripal_library.install
  38. 33 23
      tripal_library/tripal_library.module
  39. 12 2
      tripal_library/tripal_library.views_default.inc
  40. 1 1
      tripal_natural_diversity/api/tripal_natural_diversity.api.inc
  41. 7 1
      tripal_natural_diversity/includes/tripal_natural_diversity.admin.inc
  42. 3 2
      tripal_natural_diversity/includes/tripal_natural_diversity.schema.inc
  43. 12 1
      tripal_natural_diversity/tripal_natural_diversity.install
  44. 25 7
      tripal_natural_diversity/tripal_natural_diversity.module
  45. 30 2
      tripal_natural_diversity/tripal_natural_diversity.views_default.inc
  46. 29 8
      tripal_organism/api/tripal_organism.api.inc
  47. 20 1
      tripal_organism/includes/tripal_organism.admin.inc
  48. 144 115
      tripal_organism/includes/tripal_organism.chado_node.inc
  49. 11 3
      tripal_organism/tripal_organism.install
  50. 32 22
      tripal_organism/tripal_organism.module
  51. 12 2
      tripal_organism/tripal_organism.views_default.inc
  52. 7 0
      tripal_phenotype/tripal_phenotype.install
  53. 18 3
      tripal_phenotype/tripal_phenotype.module
  54. 12 2
      tripal_phenotype/tripal_phenotype.views_default.inc
  55. 9 5
      tripal_project/includes/tripal_project.admin.inc
  56. 17 16
      tripal_project/includes/tripal_project.chado_node.inc
  57. 20 8
      tripal_project/tripal_project.install
  58. 29 17
      tripal_project/tripal_project.module
  59. 12 3
      tripal_project/tripal_project.views_default.inc
  60. 78 15
      tripal_pub/api/tripal_pub.api.inc
  61. 94 18
      tripal_pub/includes/importers/tripal_pub.AGL.inc
  62. 120 13
      tripal_pub/includes/importers/tripal_pub.PMID.inc
  63. 24 10
      tripal_pub/includes/tripal_pub.admin.inc
  64. 91 68
      tripal_pub/includes/tripal_pub.chado_node.inc
  65. 51 31
      tripal_pub/includes/tripal_pub.pub_citation.inc
  66. 91 59
      tripal_pub/includes/tripal_pub.pub_importers.inc
  67. 64 38
      tripal_pub/includes/tripal_pub.pub_search.inc
  68. 8 2
      tripal_pub/tripal_pub.drush.inc
  69. 25 10
      tripal_pub/tripal_pub.install
  70. 38 33
      tripal_pub/tripal_pub.module
  71. 12 2
      tripal_pub/tripal_pub.views_default.inc
  72. 3 4
      tripal_stock/api/tripal_stock.api.inc
  73. 0 64
      tripal_stock/includes/other_module_api_functions.inc
  74. 12 6
      tripal_stock/includes/tripal_stock.admin.inc
  75. 25 11
      tripal_stock/includes/tripal_stock.chado_node.inc
  76. 0 292
      tripal_stock/includes/tripal_stock.sync_stocks.inc
  77. 100 0
      tripal_stock/theme/tripal_stock.theme.inc
  78. 10 3
      tripal_stock/tripal_stock.install
  79. 33 116
      tripal_stock/tripal_stock.module
  80. 12 2
      tripal_stock/tripal_stock.views_default.inc
  81. 10 4
      tripal_views/api/tripal_views.api.inc
  82. 14 12
      tripal_views/includes/tripal_views_integration.inc
  83. 23 7
      tripal_views/includes/tripal_views_integration_port.inc
  84. 5 2
      tripal_views/tripal_views.install
  85. 26 28
      tripal_views/tripal_views.module
  86. 15 47
      tripal_views/tripal_views.views.inc
  87. 10 2
      tripal_views/tripal_views.views_default.inc
  88. 22 1
      tripal_views/views/handlers/tripal_views_handler_area_action_links.inc
  89. 13 9
      tripal_views/views/handlers/tripal_views_handler_field_sequence.inc
  90. 9 8
      tripal_views/views/handlers/tripal_views_handler_filter_file_upload.inc
  91. 10 2
      tripal_views/views/handlers/tripal_views_handler_filter_no_results.inc
  92. 6 4
      tripal_views/views/handlers/tripal_views_handler_filter_select_cvterm.inc
  93. 19 15
      tripal_views/views/handlers/tripal_views_handler_filter_select_string.inc
  94. 16 13
      tripal_views/views/handlers/tripal_views_handler_filter_sequence.inc
  95. 9 7
      tripal_views/views/handlers/tripal_views_handler_filter_textarea.inc

+ 1 - 0
tripal_analysis/tripal_analysis.module

@@ -97,6 +97,7 @@ function tripal_analysis_help ($path, $arg) {
 
 /**
  *  Implements hook_permission().
+ *
  *  Set the permission types that the chado module uses.  Essentially we
  *  want permissionis that protect creation, editing and deleting of chado
  *  data objects

+ 15 - 33
tripal_db/api/tripal_db.api.inc

@@ -1,7 +1,11 @@
 <?php
-
 /**
+ * @file
+ * Provides an application programming interface (API) to manage references to
+ * external databases
+ */
 
+/**
  * @defgroup tripal_db_api Database Reference API
  * @ingroup tripal_api
  * @{
@@ -10,7 +14,7 @@
  */
 
 /**
- * Purpose: To retrieve a chado database object
+ * To retrieve a chado database object
  *
  * @param $select_values
  *   An array meant to uniquely select a given database
@@ -70,7 +74,7 @@ function tripal_db_get_db($select_values) {
 }
 
 /**
- * Purpose: To retrieve a chado db object
+ * To retrieve a chado db object
  *
  * @param $db_id
  *   db.db_id
@@ -86,7 +90,7 @@ function tripal_db_get_db_by_db_id($db_id) {
 }
 
 /**
- * Purpose: To retrieve a chado db object
+ * To retrieve a chado db object
  *
  * @param $name
  *   db.name
@@ -112,21 +116,8 @@ function tripal_db_get_db_by_name($name) {
   }
 }
 
-// Purpose: To retrieve a chado db object
-//
-// @params where_options: array(
-//                          <column_name> => array(
-//                            'type' => <type of column: INT/**STRING>,
-//                            'value' => <the vlaue you want to filter on>,
-//                            'exact' => <if TRUE use =; if FALSE use ~>,
-//                          )
-//        )
-// @return chado db object with all fields from the chado db table
-//
-//function tripal_db_get_db ($where_options) {
-
 /**
- * Purpose: Create an options array to be used in a form element
+ * Create an options array to be used in a form element
  *   which provides a list of all chado dbs
  *
  * @return
@@ -147,21 +138,8 @@ function tripal_db_get_db_options() {
 
 }
 
-// Purpose: To retrieve a chado dbxref object
-//
-// @param where_options: array(
-//                          <column_name> => array(
-//                            'type' => <type of column: INT/**STRING>,
-//                            'value' => <the vlaue you want to filter on>,
-//                            'exact' => <if TRUE use =; if FALSE use ~>,
-//                          )
-//        )
-// @return chado dbxref object with all fields from the chado dbxref table
-//
-//function tripal_db_get_dbxref ($where_options) {
-
 /**
- * Purpose: To retrieve a chado database reference object
+ * To retrieve a chado database reference object
  *
  * @param $select_values
  *   An array meant to uniquely select a given database reference
@@ -321,7 +299,9 @@ function tripal_db_add_db($dbname, $description = '', $url = '',
   return $result[0];
 
 }
+
 /**
+ * Add a database reference
  *
  * @ingroup tripal_db_api
  */
@@ -361,7 +341,9 @@ function tripal_db_add_dbxref($db_id, $accession, $version = '', $description =
 }
 
 /**
+ * Add a record to a database reference linking table (ie: feature_dbxref)
  *
+ * @ingroup tripal_db_api
  */
 function tripal_db_add_dbxref_link($linking_table, $dbxref_id, $foreignkey_name, $foreignkey_id) {
 
@@ -388,4 +370,4 @@ function tripal_db_add_dbxref_link($linking_table, $dbxref_id, $foreignkey_name,
   else {
     return FALSE;
   }
-}
+}

+ 22 - 24
tripal_db/includes/tripal_db.admin.inc

@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Provide administration of dbs & dbxrefs
+ */
 
 /**
+ * Launchpad for database reference administration
  *
+ * @ingroup tripal_db
  */
 function tripal_db_admin_db_listing() {
   $output = '';
@@ -40,9 +46,8 @@ function tripal_db_admin_db_listing() {
 }
 
 /**
- *
- * @param $form
- * @param $form_state
+ * Form to edit existing databases.
+ * Implements hook_form().
  *
  * @ingroup tripal_db
  */
@@ -108,10 +113,10 @@ function tripal_db_db_edit_form($form, &$form_state) {
   }
   return $form;
 }
+
 /**
- *
- * @param $form
- * @param $form_state
+ * Form to add new databases.
+ * Implements hook_form().
  *
  * @ingroup tripal_db
  */
@@ -127,11 +132,9 @@ function tripal_db_db_add_form($form, $form_state) {
   );
   return $form;
 }
+
 /**
- *
- * @param $form
- * @param $form_state
- * @param $dbid
+ * Fields commmon between the add/edit forms
  *
  * @ingroup tripal_db
  */
@@ -195,28 +198,24 @@ function tripal_db_add_db_form_fields(&$form, $form_state, $dbid = NULL) {
 
 /**
  * Validation fucntion for tripal_db_db_add_form
- * @param $form
- * @param $form_state
  *
  * @ingroup tripal_db
  */
 function tripal_db_db_add_form_validate($form, &$form_state) {
   tripal_db_form_fields_validate($form, $form_state);
 }
+
 /**
  * Validation fucntion for tripal_db_db_edit_form
- * @param unknown_type $form
- * @param unknown_type $form_state
  *
  * @ingroup tripal_db
  */
 function tripal_db_db_edit_form_validate($form, &$form_state) {
   tripal_db_form_fields_validate($form, $form_state);
 }
+
 /**
- * Genetic validation form for shared fields of both the edit and add forms
- * @param $form
- * @param $form_state
+ * Generic form validation for shared fields of both the edit and add forms
  *
  * @ingroup tripal_db
  */
@@ -234,10 +233,9 @@ function tripal_db_form_fields_validate($form, &$form_state) {
     form_set_error('name', 'The database name must be unique');
   }
 }
+
 /**
- *
- * @param $form
- * @param $form_state
+ * Submit for add db form
  *
  * @ingroup tripal_db
  */
@@ -264,9 +262,7 @@ function tripal_db_db_add_form_submit($form, &$form_state) {
 }
 
 /**
- *
- * @param $form
- * @param $form_state
+ * Submit for edit db form
  *
  * @ingroup tripal_db
  */
@@ -307,8 +303,10 @@ function tripal_db_db_edit_form_submit($form, &$form_state) {
     }
   }
 }
+
 /**
  * Ajax callback for the tripal_db_form
+ *
  * @ingroup tripal_db
  */
 function tripal_db_edit_form_ajax($form, $form_state) {
@@ -335,4 +333,4 @@ function tripal_db_edit_form_ajax($form, $form_state) {
   //drupal_set_message('<pre>' . print_r($elements, TRUE) . '</pre>', "status");
 
   return $elements;
-}
+}

+ 5 - 1
tripal_db/tripal_db.install

@@ -1,12 +1,14 @@
 <?php
-
 /**
  * @file
  * Contains functions related to the installation of this module
  */
 
 /**
+ * Implements hook_disable().
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_db
  */
 function tripal_db_disable() {
 
@@ -21,6 +23,8 @@ function tripal_db_disable() {
 
 /**
  * Implementation of hook_requirements().
+ *
+ * @ingroup tripal_db
  */
 function tripal_db_requirements($phase) {
   $requirements = array();

+ 18 - 18
tripal_db/tripal_db.module

@@ -1,7 +1,11 @@
 <?php
+/**
+ * @file
+ * General functions for the db module
+ */
 
-require_once "api/tripal_db.api.inc";
-require_once "includes/tripal_db.admin.inc";
+require_once 'api/tripal_db.api.inc';
+require_once 'includes/tripal_db.admin.inc';
 
 /**
  * @defgroup tripal_db Database Reference Module
@@ -16,13 +20,7 @@ require_once "includes/tripal_db.admin.inc";
  */
 
 /**
- *
- * @ingroup tripal_db
- */
-function tripal_db_init() {
-
-}
-/**
+ * Implements hook_menu().
  *
  * @ingroup tripal_db
  */
@@ -86,7 +84,8 @@ function tripal_db_menu() {
 }
 
 /**
- * Implements hook_help()
+ * Implements hook_help().
+ (
  * Purpose: Adds a help page to the module list
  */
 function tripal_db_help ($path, $arg) {
@@ -95,7 +94,6 @@ function tripal_db_help ($path, $arg) {
   }
 }
 
-
 /**
  * Implements hook_permission().
  *
@@ -108,26 +106,28 @@ function tripal_db_help ($path, $arg) {
 function tripal_db_permission() {
   return array(
     'administer db cross-references' => array(
-      'title' => t('Administer the list of external databases used for data cross-references.'),
-      'description' => t('Allows the user to add, edit or delete databases stored in the Chado database.'),
+      'title' => t('Administer External Database Cross-references.'),
+      'description' => t('Allows the user to add, edit or delete external databases references stored in the Chado database.'),
     ),
   );
 }
 
 /**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
+ * Implements hook_views_api().
+ *
+ * Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_db.views.inc where all the
  *  views integration code is
  *
  * @ingroup tripal_db
  */
 function tripal_db_views_api() {
-  return array('api' => 2.0);
+  return array('api' => 3.0);
 }
 
-
 /**
+ *  Implements hook_theme().
+ *
  *  We need to let drupal know about our theme functions and their arguments.
  *  We create theme functions to allow users of the module to customize the
  *  look and feel of the output generated in this module
@@ -144,4 +144,4 @@ function tripal_db_theme($existing, $type, $theme, $path) {
     )
   );
   return $items;
-}
+}

+ 13 - 2
tripal_db/tripal_db.views_default.inc

@@ -1,6 +1,13 @@
 <?php
 /**
- * Implements hook_views_default_views()
+ * @file
+ * Describe db default views
+ */
+
+/**
+ * Implements hook_views_default_views().
+ *
+ * @ingroup tripal_db
  */
 function tripal_db_views_default_views() {
   $views = array();
@@ -18,6 +25,8 @@ function tripal_db_views_default_views() {
 
 /**
  * Default Admin View for db management
+ *
+ * @ingroup tripal_db
  */
 function tripal_db_defaultview_admin_db_listing() {
 
@@ -197,6 +206,8 @@ function tripal_db_defaultview_admin_db_listing() {
 
 /**
  * Default Admin View for dbxref management
+ *
+ * @ingroup tripal_db
  */
 function tripal_db_defaultview_admin_dbxref_listing() {
 
@@ -368,4 +379,4 @@ function tripal_db_defaultview_admin_dbxref_listing() {
   $handler->display->display_options['menu']['context_only_inline'] = 0;
 
   return $view;
-}
+}

+ 25 - 7
tripal_feature/api/tripal_feature.api.inc

@@ -1,4 +1,9 @@
 <?php
+/**
+ * @file
+ * Provides an application programming interface (API) for working with features
+ */
+
 /**
  * @defgroup tripal_feature_api Feature API
  * @ingroup tripal_api
@@ -202,6 +207,7 @@ function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
     return chado_update_property('analysisfeature',
       NULL, $property, $cv_name, $value, FALSE, $analysisfeatureprop_id);
 }
+
 /**
  * Delete an analysis feature property using the property name.  Use this
  * when a property only exists once for a given analysis feature.  When more
@@ -255,6 +261,7 @@ function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_i
   // get the property.
   return chado_delete_property('analysisfeature', $analysisfeature_id, $property, $cv_name);
 }
+
 /**
  * Delete a property using the analysisfeatureprop_id
  *
@@ -276,6 +283,7 @@ function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id)
   return chado_delete_record('analysisfeatureprop', $match);
 
 }
+
 /**
  * Retrieve properties of a given type for a given feature
  *
@@ -321,6 +329,7 @@ function tripal_feature_insert_property($feature_id, $property, $value,
   return chado_insert_property('feature', $feature_id, $property,
     $cv_name, $value, $update_if_present);
 }
+
 /**
  * Update a feature property using the property name. Only use this
  * if the property is unique and only exist once for the feature.
@@ -396,6 +405,7 @@ function tripal_feature_update_property_by_id($featureprop_id, $property,
 function tripal_feature_delete_property($feature_id, $property, $cv_name='tripal') {
   return chado_delete_property('feature', $feature_id, $property, $cv_name);
 }
+
 /**
  * Delete a given feature property using the featureprop_id
  *
@@ -449,6 +459,7 @@ function tripal_feature_reverse_complement($sequence) {
   $seq = str_replace("B", "v", $seq);
   return strtoupper($seq);
 }
+
 /**
  * Retrieves the sequence for a feature.
  *
@@ -844,11 +855,9 @@ function tripal_feature_get_formatted_sequence($feature_id, $feature_name,
   return $residues;
 }
 
-
-
-/*
+/**
  * This function adds an entry to the feature_dbxref table.
-  *
+ *
  * @param $feature_id
  *   The numeric feature_if of the feature
  * @param $dbname
@@ -904,9 +913,9 @@ function tripal_feature_add_dbxref($feature_id, $dbname, $accession) {
   return TRUE;
 }
 
-/*
+/**
  * This function adds an entry to the feature_cvterm table.
-  *
+ *
  * @param $feature_id
  *   The numeric feature_if of the feature
  * @param $cvname
@@ -963,9 +972,18 @@ function tripal_feature_add_cvterm($feature_id, $cvname, $cvterm) {
 }
 
 /**
+ * Returns a fasta record for the passed in feature
  *
+ * @param $feature
+ *   A single feature object containing all the fields from the chado.feature table
+ * @param $desc
+ *   A string containing any additional details you want added to the definition line of
+ *   the fasta record.
  *
- * @ingroup tripal_feature
+ * Note: the feature accession and name separated by a | will be added
+ *   before the description but on the same line
+ *
+ * @ingroup tripal_feature_api
  */
 function tripal_feature_return_fasta($feature, $desc) {
   $fasta  = ">" . variable_get('chado_feature_accession_prefix', 'FID') . "$feature->feature_id|$feature->name";

+ 4 - 0
tripal_feature/api/tripal_feature.schema.api.inc

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Further describe some of the feature tables to the tripal schema
+ */
 
 /**
  * Implements hook_chado_schema_v1_2_tripal_gff_temp()

+ 16 - 17
tripal_feature/includes/tripal_feature.admin.inc

@@ -1,12 +1,13 @@
 <?php
-
 /**
  * @file
- * @todo Add file header description
+ * Administration of features
  */
 
 /**
+ * Launchpad for feature administration.
  *
+ * @ingroup tripal_feature
  */
 function tripal_feature_admin_feature_view() {
   $output = '';
@@ -38,9 +39,8 @@ function tripal_feature_admin_feature_view() {
   return $output;
 }
 
-
 /**
- *
+ * Feature Settings page
  *
  * @ingroup tripal_feature
  */
@@ -178,7 +178,7 @@ function tripal_feature_admin() {
 }
 
 /**
- *
+ * Validate the feature settings forms
  *
  * @ingroup tripal_feature
  */
@@ -220,9 +220,8 @@ function tripal_feature_admin_validate($form, &$form_state) {
 
 }
 
-
 /**
- *
+ * Form: Reindex feature nodes for the drupal search
  *
  * @ingroup tripal_feature
  */
@@ -250,7 +249,7 @@ function get_tripal_feature_admin_form_reindex_set(&$form) {
 }
 
 /**
- *
+ * Form: Set taxonomy for features
  *
  * @ingroup tripal_feature
  */
@@ -297,8 +296,9 @@ function get_tripal_feature_admin_form_taxonomy_set(&$form) {
 }
 
 /**
+ * Form: Set the definition of titles for features
  *
- * @param $form
+ * @ingroup tripal_feature
  */
 function get_tripal_feature_admin_form_title_set(&$form) {
 
@@ -333,13 +333,14 @@ function get_tripal_feature_admin_form_title_set(&$form) {
     '#default_value' => variable_get('chado_feature_title', 'unique_constraint'),
   );
 }
+
 /**
+ * Form: Set the URL definition for feature nodes
  *
- * @param $form
+ * @ingroup tripal_feature
  */
 function get_tripal_feature_admin_form_url_set(&$form) {
 
-
   $form['url'] = array(
     '#type' => 'fieldset',
     '#title' => t('Feature URL Path'),
@@ -401,7 +402,7 @@ function get_tripal_feature_admin_form_url_set(&$form) {
 }
 
 /**
- *
+ * Set feature taxonomy
  *
  * @ingroup tripal_feature
  */
@@ -444,7 +445,7 @@ function tripal_features_set_taxonomy($max_sync = 0, $job_id = NULL) {
 }
 
 /**
- *
+ * Set taxonomy for a single feature
  *
  * @ingroup tripal_feature
  */
@@ -550,7 +551,6 @@ function tripal_feature_set_taxonomy($node, $feature_id) {
 
 }
 
-
 /**
  *  This function is an extension of the chado_feature_view by providing
  *  the markup for the feature object THAT WILL BE INDEXED.
@@ -610,9 +610,8 @@ function theme_tripal_feature_search_results($node) {
   return $content;
 }
 
-
 /**
- *
+ * Set the vocabulary to use taxonomy terms from
  *
  * @ingroup tripal_feature
  */
@@ -720,4 +719,4 @@ function tripal_feature_set_vocabulary() {
     drupal_form_submit('taxonomy_form_vocabulary', $form_state, $values);
     drupal_form_submit('taxonomy_form_vocabulary', $form_state);
   }
-}
+}

+ 6 - 2
tripal_feature/includes/tripal_feature.blocks.inc

@@ -1,7 +1,11 @@
 <?php
+/**
+ * @file
+ *  Describes the feature blocks to drupal
+ */
 
 /**
- *
+ * Implements hook_block().
  *
  * @ingroup tripal_feature
  */
@@ -44,7 +48,7 @@ function tripal_feature_block_info() {
 }
 
 /**
- *
+ * Implements hook_block_view().
  *
  * @ingroup tripal_feature
  */

+ 46 - 22
tripal_feature/includes/tripal_feature.chado_node.inc

@@ -1,6 +1,13 @@
 <?php
 /**
- *  Provide information to drupal about the node types that we're creating
+ * @file
+ * Implementation of hooks to create a feature content type
+ */
+
+/**
+ * Implements hook_node_info().
+ *
+ * Provide information to drupal about the node types that we're creating
  *  in this module
  *
  * @ingroup tripal_feature
@@ -32,14 +39,9 @@ function tripal_feature_node_info() {
   );
   return $nodes;
 }
+
 /**
- * Implementation of hook_form
- *
- * @param  $node
- * @param  $param
- *
- * @return
- *   Drupal form array
+ * Implementation of hook_form().
  *
  * @ingroup tripal_feature
  */
@@ -236,16 +238,13 @@ function chado_feature_form($node, &$form_state) {
 }
 
 /**
- * Implementation of hook_validate
+ * Implementation of hook_validate().
  *
  * This validation is being used for three activities:
  *   CASE A: Update a node that exists in both drupal and chado
  *   CASE B: Synchronizing a node from chado to drupal
  *   CASE C: Inserting a new node that exists in niether drupal nor chado
  *
- * @param $node
- *
- *
  * @ingroup tripal_feature
  */
 function chado_feature_validate($node, $form, &$form_state) {
@@ -325,9 +324,8 @@ function chado_feature_validate($node, $form, &$form_state) {
   }
 }
 
-
 /**
- * Implement hook_access().
+ * Implement hook_node_access().
  *
  * This hook allows node modules to limit access to the node types they define.
  *
@@ -374,7 +372,10 @@ function chado_feature_node_access($node, $op, $account) {
   }
   return NULL;
 }
+
 /**
+ * Implements hook_insert().
+ *
  *  When a new chado_feature node is created we also need to add information
  *  to our chado_feature table.  This function is called on insert of a new node
  *  of type 'chado_feature' and inserts the necessary information.
@@ -467,7 +468,7 @@ function chado_feature_insert($node) {
 }
 
 /**
- *
+ * Implements hook_update().
  *
  * @ingroup tripal_feature
  */
@@ -544,8 +545,9 @@ function chado_feature_update($node) {
 
 
 }
+
 /**
- *
+ * Implements hook_delete().
  *
  * @ingroup tripal_feature
  */
@@ -579,7 +581,12 @@ function chado_feature_delete($node) {
 }
 
 /**
+ * Add synonyms to a feature
  *
+ * @param $synonyms
+ *   A string containing synonyms separated by a return character
+ * @param $feature_id
+ *   The feature to attach the synonyms to
  *
  * @ingroup tripal_feature
  */
@@ -647,7 +654,9 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
 }
 
 /**
- *  When a node is requested by the user this function is called to allow us
+ * Implements hook_load().
+ *
+ * When a node is requested by the user this function is called to allow us
  *  to add auxiliary data to the node object.
  *
  * @ingroup tripal_feature
@@ -687,7 +696,10 @@ function chado_feature_load($nodes) {
     }
   }
 }
+
 /**
+ * Implements hook_node_presave().
+ * Acts on all content types.
  *
  * @ingroup tripal_feature
  */
@@ -717,19 +729,21 @@ function tripal_feature_node_presave($node) {
         $ftype = chado_select_record('cv', array('name'), $values);
         $type = $ftype[0]->name;
       }
-     
+
       $values = array('organism_id' => $organism_id);
       $organism = chado_select_record('organism', array('genus', 'species'), $values);
       $node->title = "$name, $uname ($type) " . $organism[0]->genus . ' ' . $organism[0]->species;
-      
+
       if ($name == $uname) {
-        $node->title = "$name ($type) " . $organism[0]->genus . ' ' . $organism[0]->species; 
+        $node->title = "$name ($type) " . $organism[0]->genus . ' ' . $organism[0]->species;
       }
       break;
   }
 }
 
 /**
+ * Implements hook_node_insert().
+ * Acts on all content types.
  *
  * @ingroup tripal_feature
  */
@@ -755,7 +769,9 @@ function tripal_feature_node_insert($node) {
       break;
   }
 }
+
 /**
+ * Return the url alias for a feature
  *
  * @param $node
  *   A node object containing at least the feature_id and nid
@@ -765,6 +781,8 @@ function tripal_feature_node_insert($node) {
  *   and [type].  These placeholders will be substituted for actual values.
  *   If this parameter is not provided then the value of the
  *   chado_feature_url_string Drupal variable will be used.
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_get_feature_url($node, $url_alias = NULL) {
 
@@ -822,7 +840,10 @@ function tripal_feature_get_feature_url($node, $url_alias = NULL) {
 
   return $url_alias;
 }
+
 /**
+ * Implements hook_node_view().
+ * Acts on all content types.
  *
  * @ingroup tripal_feature
  */
@@ -848,7 +869,7 @@ function tripal_feature_node_view($node, $view_mode, $langcode) {
           '#weight' => -100,
         );
         $node->content['tripal_feature_featurepos'] = array(
-          '#markup' => theme('tripal_feature_featurepos', array('node' => $node)),          
+          '#markup' => theme('tripal_feature_featurepos', array('node' => $node)),
           '#tripal_toc_id'    => 'featurepos',
           '#tripal_toc_title' => 'Maps',
         );
@@ -918,7 +939,10 @@ function tripal_feature_node_view($node, $view_mode, $langcode) {
       break;
   }
 }
+
 /**
+ * Implements hook_node_update().
+ * Acts on all content types.
  *
  * @ingroup tripal_feature
  */
@@ -936,4 +960,4 @@ function tripal_feature_node_update($node) {
       path_save($path_alias);
       break;
   }
-}
+}

+ 58 - 13
tripal_feature/includes/tripal_feature.delete.inc

@@ -1,9 +1,14 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Administration Interface for deleting multiple features
  */
 
+/**
+ * A form for indicating the features to delete
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_delete_form() {
   // get the list of organisms
   $sql = "SELECT * FROM {organism} ORDER BY genus, species";
@@ -69,6 +74,11 @@ function tripal_feature_delete_form() {
   return $form;
 }
 
+/**
+ * Validation for the delete features form
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_delete_form_validate($form, &$form_state) {
   $organism_id   = $form_state['values']['organism_id'];
   $seq_type      = trim($form_state['values']['seq_type']);
@@ -89,7 +99,7 @@ function tripal_feature_delete_form_validate($form, &$form_state) {
         LEFT JOIN {cvtermsynonym} CVTS on CVTS.cvterm_id = CVT.cvterm_id
       WHERE cv.name = :cvname and (CVT.name = :name or CVTS.synonym = :synonym)
     ";
-    $cvterm = chado_query($cvtermsql, 
+    $cvterm = chado_query($cvtermsql,
       array(':cvname' => 'sequence', ':name' => $seq_type, ':synonym' => $seq_type))->fetchObject();
     if (!$cvterm) {
       form_set_error('seq_type', t("The Sequence Ontology (SO) term selected for the " .
@@ -98,6 +108,11 @@ function tripal_feature_delete_form_validate($form, &$form_state) {
   }
 }
 
+/**
+ * Submit for the delete features form
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_delete_form_submit($form, &$form_state) {
   global $user;
 
@@ -113,7 +128,25 @@ function tripal_feature_delete_form_submit($form, &$form_state) {
     'tripal_feature_delete_features', $args, $user->uid);
 }
 
-
+/**
+ * Function to actually delete the features indicated
+ *
+ * @param $organism_id
+ *   (Optional) The organism_id of the features to delete
+ * @param $analysis_id
+ *   (Optional) The analysis_id of the features to delete
+ * @param $seq_type
+ *   (Optional) The cvterm.name of the feature types to delete
+ * @param $is_unique
+ *   (Optional) A Boolean stating whether the names are unique (ie: feature.uniquename)
+ *   or not (ie: feature.name)
+ * @param $feature_names
+ *   (Optional) A space separated list of the names of features to delete
+ * @param $job
+ *   The tripal_job id
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_delete_features($organism_id, $analysis_id, $seq_type,
   $is_unique, $feature_names, $job = NULL) {
 
@@ -163,17 +196,29 @@ function tripal_feature_delete_features($organism_id, $analysis_id, $seq_type,
   tripal_features_cleanup(array(), $user->uid);
 }
 
+/**
+ * Function to delete features based on an analysis passed in. This has not yet been
+ * implemented in the form
+ *
+ * @todo: Implement this functionality and then add back in the form field
+ *
+ * @param $organism_id
+ *   (Optional) The organism_id of the features to delete
+ * @param $analysis_id
+ *   (Optional) The analysis_id of the features to delete
+ * @param $seq_type
+ *   (Optional) The cvterm.name of the feature types to delete
+ * @param $is_unique
+ *   (Optional) A Boolean stating whether the names are unique (ie: feature.uniquename)
+ *   or not (ie: feature.name)
+ * @param $feature_names
+ *   (Optional) A space separated list of the names of features to delete
+ * @param $job
+ *   The tripal_job id
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_delete_by_analysis($organism_id, $analysis_id, $seq_type,
   $is_unique, $feature_names, $job = NULL) {
 
 }
-
-
-
-
-
-
-
-
-
-

+ 161 - 109
tripal_feature/includes/tripal_feature.fasta_loader.inc

@@ -1,26 +1,26 @@
 <?php
-
 /**
  * @file
- * @todo Add file header description
+ * Provides fasta loading functionality. Creates features based on their specification
+ * in a fasta file.
  */
 
-
 /**
  * @defgroup fasta_loader FASTA Feature Loader
  * @ingroup tripal_feature
  * @{
- * Provides fasta loading functionality. Creates features based on their specification in a fasta file.
+ * Provides fasta loading functionality. Creates features based on their specification
+ * in a fasta file.
  * @}
- * 
+ *
  */
 
 /**
- *
+ * The form to submit a fasta loading job
  *
  * @ingroup fasta_loader
  */
-function tripal_feature_fasta_load_form( ) {
+function tripal_feature_fasta_load_form() {
 
   $form['fasta_file']= array(
     '#type'          => 'textfield',
@@ -100,7 +100,7 @@ function tripal_feature_fasta_load_form( ) {
       t('Name'),
       t('Unique name'),
     ),
-    '#description' => t('Used for "updates only" or "insert and update" methods. Not required if method type is "insert".  
+    '#description' => t('Used for "updates only" or "insert and update" methods. Not required if method type is "insert".
       Feature data is stored in Chado with both a human-readable
       name and a unique name. If the features in your FASTA file are uniquely identified using
       a human-readable name then select the "Name" button. If your features are
@@ -267,7 +267,7 @@ function tripal_feature_fasta_load_form( ) {
 }
 
 /**
- *
+ * Validate the fasta loader job form
  *
  * @ingroup fasta_loader
  */
@@ -312,7 +312,7 @@ function tripal_feature_fasta_load_form_validate($form, &$form_state) {
   if (!$re_name and $re_uname and strcmp($match_type, 'Name')==0) {
     form_set_error('re_name', t("You must provide a regular expression to identify the sequence name"));
   }
-  
+
   // check to see if the file is located local to Drupal
   $fasta_file = trim($fasta_file);
   $dfile = $_SERVER['DOCUMENT_ROOT'] . base_path() . $fasta_file;
@@ -367,7 +367,7 @@ function tripal_feature_fasta_load_form_validate($form, &$form_state) {
 }
 
 /**
- *
+ * Submit a fasta loading job
  *
  * @ingroup fasta_loader
  */
@@ -410,14 +410,49 @@ function tripal_feature_fasta_load_form_submit($form, &$form_state) {
   $args = array($dfile, $organism_id, $type, $library_id, $re_name, $re_uname,
           $re_accession, $db_id, $rel_type, $re_subject, $parent_type, $method,
           $user->uid, $analysis_id, $match_type);
-  
-  $fname = preg_replace("/.*\/(.*)/", "$1", $dfile);         
+
+  $fname = preg_replace("/.*\/(.*)/", "$1", $dfile);
   tripal_add_job("Import FASTA file: $fname", 'tripal_feature',
     'tripal_feature_load_fasta', $args, $user->uid);
 }
 
 /**
+ * Actually load a fasta file. This is the function called by tripal jobs
  *
+ * @param $dfile
+ *  The full path to the fasta file to load
+ * @param $organism_id
+ *  The organism_id of the organism these features are from
+ * @param $type
+ *  The type of features contained in the fasta file
+ * @param $library_id
+ *  (Optional) The library_id to associate the features with
+ * @param $re_name
+ *  A regular expression to extract the feature.name from the fasta header
+ * @param $re_uname
+ *  A regular expression to extract the feature.uniquename from the fasta header
+ * @param $re_accession
+ *  A regular expression to extract the accession of the feature.dbxref_id
+ * @param $db_id
+ *  The db_id of the above dbxref
+ * @param $rel_type
+ *  The type of relationship when creating a feature_relationship between this
+ *   feature (object) and an extracted subject
+ * @param $re_subject
+ *  The regular expression to extract the uniquename of the feature to be the subject
+ *   of the above specified relationship
+ * @param $parent_type
+ *  The type of the parent feature
+ * @param $method
+ *  The method of feature adding. (ie: 'Insert only', 'Update only', 'Insert and update')
+ * @param $uid
+ *   The user id of the user who submitted the job
+ * @param $analysis_id
+ *   The analysis_id to associate the features in this fasta file with
+ * @param $match_type
+ *   Whether to match existing features based on the 'Name' or 'Unique name'
+ * @param $job = NULL
+ *   The tripal job
  *
  * @ingroup fasta_loader
  */
@@ -428,7 +463,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
 
   // begin the transaction
   $connection = tripal_db_start_transaction();
-      
+
   // if we cannot get a connection then let the user know the loading will be slow
   if (!$connection) {
      print "A persistant connection was not obtained. Loading will be slow\n";
@@ -445,7 +480,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
                   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 = :cvname and (CVT.name = :name or CVTS.synonym = :synonym)";
-  $cvterm = chado_query($cvtermsql, array(':cvname' => 'sequence', ':name' => $type, ':synonym' => $type))->fetchObject();     
+  $cvterm = chado_query($cvtermsql, array(':cvname' => 'sequence', ':name' => $type, ':synonym' => $type))->fetchObject();
   if (!$cvterm) {
     tripal_report_error("T_fasta_loader", TRIPAL_ERROR, "Cannot find the term type: '%type'", array('%type' => $type));
     return 0;
@@ -464,7 +499,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
       return 0;
     }
   }
-  
+
   print "Opening FASTA file $dfile\n";
 
   //$lines = file($dfile, FILE_SKIP_EMPTY_LINES);
@@ -478,22 +513,22 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
 
   $name = '';
   $uname = '';
-  $residues = '';  
+  $residues = '';
   $interval = intval($filesize * 0.01);
   if ($interval < 1) {
     $interval = 1;
   }
   $inv_read = 0;
-  
-  // we need to get the table schema to make sure we don't overrun the 
+
+  // we need to get the table schema to make sure we don't overrun the
   // size of fields with what our regular expressions retrieve
   $feature_tbl = chado_get_schema('feature');
   $dbxref_tbl = chado_get_schema('dbxref');
 
-  //foreach ($lines as $line_num => $line) {  
+  //foreach ($lines as $line_num => $line) {
   while ($line = fgets($fh)) {
     $i++;  // update the line count
-    $num_read += drupal_strlen($line);   
+    $num_read += drupal_strlen($line);
     $intv_read += drupal_strlen($line);
 
     // if we encounter a definition line then get the name, uniquename,
@@ -501,7 +536,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
     if (preg_match('/^>/', $line)) {
       // if we have a feature name then we are starting a new sequence
       // so lets handle the previous one before moving on
-      if ($name or $uname) {       
+      if ($name or $uname) {
         tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id,
           $accession, $subject, $rel_type, $parent_type, $analysis_id, $organism_id, $cvterm,
           $source, $residues, $method, $re_name, $match_type, $parentcvterm, $relcvterm);
@@ -511,18 +546,18 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
       }
 
       $line = preg_replace("/^>/", '', $line); // remove the > symbol from the defline
-     
+
       // get the feature name
       if ($re_name) {
         if (!preg_match("/$re_name/", $line, $matches)) {
           tripal_report_error('trp-fasta', "ERROR: Regular expression for the feature name finds nothing. Line %line.", array('%line' => $i), 'error');
         }
         elseif (strlen($matches[1]) > $feature_tbl['fields']['name']['length']) {
-          tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves a value too long for the feature name. Line %line.", array('%line' => $i), 'error');  
+          tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves a value too long for the feature name. Line %line.", array('%line' => $i), 'error');
         }
         else {
           $name = trim($matches[1]);
-        }        
+        }
       }
       else {
         // if the match_type is name and no regular expression was provided
@@ -530,18 +565,18 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
         if (strcmp($match_type, 'Name')==0) {
           if (preg_match("/^\s*(.*?)[\s\|].*$/", $line, $matches)) {
             if (strlen($matches[1]) > $feature_tbl['fields']['name']['length']) {
-              tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves a feature name too long for the feature name. Line %line.", array('%line' => $i), 'error');  
+              tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves a feature name too long for the feature name. Line %line.", array('%line' => $i), 'error');
             }
             else {
               $name = trim($matches[1]);
             }
           }
           else {
-            tripal_report_error('trp-fasta', "ERROR: Cannot find a feature name. Line %line.", array('%line' => $i), 'error');  
+            tripal_report_error('trp-fasta', "ERROR: Cannot find a feature name. Line %line.", array('%line' => $i), 'error');
           }
         }
       }
-      
+
       // get the feature unique name
       if ($re_uname) {
         if (!preg_match("/$re_uname/", $line, $matches)) {
@@ -557,14 +592,14 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
             $uname = trim($matches[1]);
           }
           else {
-            tripal_report_error('trp-fasta', "ERROR: Cannot find a feature unique name. Line %line.", array('%line' => $i), 'error');  
+            tripal_report_error('trp-fasta', "ERROR: Cannot find a feature unique name. Line %line.", array('%line' => $i), 'error');
           }
         }
       }
       // get the accession
       preg_match("/$re_accession/", $line, $matches);
       if (strlen($matches[1]) > $dbxref_tbl['fields']['accession']['length']) {
-        tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves an accession too long for the feature name. Cannot add cross reference. Line %line.", array('%line' => $i), 'warning');  
+        tripal_report_error('trp-fasta', "WARNING: Regular expression retrieves an accession too long for the feature name. Cannot add cross reference. Line %line.", array('%line' => $i), 'warning');
       }
       else {
         $accession = trim($matches[1]);
@@ -576,7 +611,7 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
     }
     else {
       $residues .= trim($line);
-      
+
       // update the job status every % features
       if ($job and $intv_read >= $interval) {
         $intv_read = 0;
@@ -585,25 +620,43 @@ function tripal_feature_load_fasta($dfile, $organism_id, $type,
           print "Parsing Line $i (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes. Current feature: $name\r";
         }
         else {
-          print "Parsing Line $i (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes. Current feature: $uname\r";  
+          print "Parsing Line $i (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes. Current feature: $uname\r";
         }
         tripal_set_job_progress($job, intval(($num_read / $filesize) * 100));
       }
     }
   }
-  
+
   // now load the last sequence in the file
   tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id,
     $accession, $subject, $rel_type, $parent_type, $analysis_id, $organism_id, $cvterm,
     $source, $residues, $method, $re_name, $match_type, $parentcvterm, $relcvterm);
-  
+
   // commit the transaction
   tripal_db_commit_transaction();
   print "\nDone\n";
 }
 
 /**
+ * A helper function for tripal_feature_load_fasta() to load a single feature
  *
+ * @param $name
+ * @param $uname
+ * @param $db_id
+ * @param $accession
+ * @param $parent
+ * @param $rel_type
+ * @param $parent_type
+ * @param $analysis_id
+ * @param $organism_id
+ * @param $cvterm
+ * @param $source
+ * @param $residues
+ * @param $method
+ * @param $re_name
+ * @param $match_type
+ * @param $parentcvterm
+ * @param $relcvterm
  *
  * @ingroup fasta_loader
  */
@@ -616,44 +669,44 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     $values = array(
       'organism_id' => $organism_id,
       'name' => $name,
-      'type_id' => $cvterm->cvterm_id,    
+      'type_id' => $cvterm->cvterm_id,
     );
     $options = array('statement_name' => 'sel_feature_ornaty');
     $results = chado_select_record('feature', array('feature_id'), $values, $options);
     if (count($results) > 1) {
-      tripal_report_error('T_fasta_loader', "Multiple features exist with the name '%name' of type 
+      tripal_report_error('T_fasta_loader', "Multiple features exist with the name '%name' of type
                '%type' for the organism.  skipping", array('%name' => $name, '%type' => $type));
       return 0;
-    } 
-    if (count($results) == 1) {  
+    }
+    if (count($results) == 1) {
       $feature = $results[0];
-    }     
+    }
   }
   // check to see if this feature already exists if the match_type is 'Unique Name'
   if (strcmp($match_type, 'Unique name')==0) {
     $values = array(
       'organism_id' => $organism_id,
       'uniquename' => $uname,
-      'type_id' => $cvterm->cvterm_id,    
+      'type_id' => $cvterm->cvterm_id,
     );
 
     $options = array('statement_name' => 'sel_feature_oruqty');
     $results = chado_select_record('feature', array('feature_id'), $values, $options);
     if (count($results) > 1) {
-      tripal_report_error('T_fasta_loader', "Multiple features exist with the name '%name' of type 
+      tripal_report_error('T_fasta_loader', "Multiple features exist with the name '%name' of type
                '%type' for the organism.  skipping", array('%name' => $name, '%type' => $type));
       return 0;
-    } 
-    if (count($results) == 1) {  
+    }
+    if (count($results) == 1) {
       $feature = $results[0];
-    }     
-    
-    // if the feature exists but this is an "insert only" method then skip this feature 
+    }
+
+    // if the feature exists but this is an "insert only" method then skip this feature
     if ($feature and (strcmp($method, 'Insert only')==0)) {
-      tripal_report_error('T_fasta_loader', TRIPAL_WARNING, "Feature already exists '%name' ('%uname') while matching on %type. Skipping insert.", 
+      tripal_report_error('T_fasta_loader', TRIPAL_WARNING, "Feature already exists '%name' ('%uname') while matching on %type. Skipping insert.",
         array('%name' => $name, '%uname' => $uname, '%type' => drupal_strtolower($match_type)));
       return 0;
-    } 
+    }
   }
 
   // if we don't have a feature and we're doing an insert then do the insert
@@ -666,7 +719,7 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     elseif (!$name) {
       $name = $uname;
     }
-    
+
     // insert the feature
     $values = array(
       'organism_id' => $organism_id,
@@ -680,44 +733,44 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
       'is_obsolete' => 'FALSE',
     );
     $options = array('statement_name' => 'ins_feature_all');
-    $success = chado_insert_record('feature', $values, $options);    
+    $success = chado_insert_record('feature', $values, $options);
     if (!$success) {
-      tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to insert feature '%name (%uname)'", 
+      tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to insert feature '%name (%uname)'",
         array('%name' => $name, '%uname' => $numane));
       return 0;
     }
-    
-    // now get the feature we just inserted    
+
+    // now get the feature we just inserted
     $values = array(
       'organism_id' => $organism_id,
       'uniquename' => $uname,
-      'type_id' => $cvterm->cvterm_id,    
+      'type_id' => $cvterm->cvterm_id,
     );
     $options = array('statement_name' => 'sel_feature_oruqty');
     $results = chado_select_record('feature', array('feature_id'), $values, $options);
     if (count($results) == 1) {
        $inserted = 1;
        $feature = $results[0];
-    } 
+    }
     else {
-      tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to retreive newly inserted feature '%name (%uname)'", 
+      tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to retreive newly inserted feature '%name (%uname)'",
         array('%name' => $name, '%uname' => $numane));
-      return 0;  
-    }     
+      return 0;
+    }
   }
-  
+
   // if we don't have a feature and the user wants to do an update then fail
   if (!$feature and (strcmp($method, 'Update only')==0 or drupal_strcmp($method, 'Insert and update')==0)) {
-    tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to find feature '%name' ('%uname') while matching on " . 
+    tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to find feature '%name' ('%uname') while matching on " .
       drupal_strtolower($match_type), array('%name' => $name, '%uname' => $uname));
     return 0;
   }
-  
+
   // if we do have a feature and this is an update then proceed with the update
   if ($feature and !$inserted and (strcmp($method, 'Update only')==0 or strcmp($method, 'Insert and update')==0)) {
     // if the user wants to match on the Name field
     if (strcmp($match_type, 'Name')==0) {
-      // if we're matching on the name but do not have a unique name then we don't want to update the uniquename.  
+      // if we're matching on the name but do not have a unique name then we don't want to update the uniquename.
       $values = array();
       if ($uname) {
         // first check to make sure that by changing the unique name of this feature that we won't conflict with
@@ -725,17 +778,17 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
         $values = array(
           'organism_id' => $organism_id,
           'uniquename' => $uname,
-          'type_id' => $cvterm->cvterm_id,    
-        );    
+          'type_id' => $cvterm->cvterm_id,
+        );
         $options = array('statement_name' => 'sel_feature_oruqty');
         $results = chado_select_record('feature', array('feature_id'), $values, $options);
         if (count($results) > 0) {
-          tripal_report_error('T_fasta_loader', "Cannot update the feature '%name' with a uniquename of '%uname' and type of '%type' as it 
-            conflicts with an existing feature with the same uniquename and type.", 
+          tripal_report_error('T_fasta_loader', "Cannot update the feature '%name' with a uniquename of '%uname' and type of '%type' as it
+            conflicts with an existing feature with the same uniquename and type.",
             array('%name' => $name, '%uname' => $uname, '%type' => $type));
           return 0;
-        } 
-        
+        }
+
         // the changes to the uniquename don't conflict so proceed with the update
         $values = array(
           'uniquename' => $uname,
@@ -746,15 +799,15 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
           'is_obsolete' => 'false',
         );
         $match = array(
-          'name' => $name,        
+          'name' => $name,
           'organism_id' => $organism_id,
-          'type_id' => $cvterm->cvterm_id,        
+          'type_id' => $cvterm->cvterm_id,
         );
-        $options = array('statement_name' => 'upd_feature_resemdisis_naorty_un');        
+        $options = array('statement_name' => 'upd_feature_resemdisis_naorty_un');
       }
       // if we do not have a new unique name then don't change the existing uniquename field
       else {
-        $values = array(                 
+        $values = array(
           'residues' => $residues,
           'seqlen' => drupal_strlen($residues),
           'md5checksum' => md5($residues),
@@ -762,24 +815,24 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
           'is_obsolete' => 'false',
         );
         $match = array(
-          'name' => $name,       
+          'name' => $name,
           'organism_id' => $organism_id,
-          'type_id' => $cvterm->cvterm_id,        
+          'type_id' => $cvterm->cvterm_id,
         );
-        $options = array('statement_name' => 'upd_feature_unresemdisis_naorty'); 
+        $options = array('statement_name' => 'upd_feature_unresemdisis_naorty');
       }
-      
+
       // perform the update
       $success = chado_update_record('feature', $match, $values, $options);
       if (!$success) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, 
-          "Failed to update feature '%name' ('%name')", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR,
+          "Failed to update feature '%name' ('%name')",
           array('%name' => $name, '%uiname' => $uname));
         return 0;
       }
     }
     if (strcmp($match_type, 'Unique name')==0) {
-      // if we're matching on the uniquename but do not have a new name then we don't want to update the name.  
+      // if we're matching on the uniquename but do not have a new name then we don't want to update the name.
       $values = array();
       if ($name) {
         $values = array(
@@ -792,14 +845,14 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
         );
         $match = array(
           'uniquename' => $uname,
-          'organism_id' => $organism_id,          
-          'type_id' => $cvterm->cvterm_id,        
+          'organism_id' => $organism_id,
+          'type_id' => $cvterm->cvterm_id,
         );
-        $options = array('statement_name' => 'upd_feature_resemdisis_unorty_na');       
+        $options = array('statement_name' => 'upd_feature_resemdisis_unorty_na');
       }
       // if we have a unique name then update it after matching by the name
       else {
-        $values = array(                  
+        $values = array(
           'residues' => $residues,
           'seqlen' => drupal_strlen($residues),
           'md5checksum' => md5($residues),
@@ -807,21 +860,21 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
           'is_obsolete' => 'false',
         );
         $match = array(
-          'uniquename' => $uname,       
+          'uniquename' => $uname,
           'organism_id' => $organism_id,
-          'type_id' => $cvterm->cvterm_id,        
+          'type_id' => $cvterm->cvterm_id,
         );
-        $options = array('statement_name' => 'upd_feature_naresemdisis_unorty'); 
+        $options = array('statement_name' => 'upd_feature_naresemdisis_unorty');
       }
       $success = chado_update_record('feature', $match, $values, $options);
       if (!$success) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to update feature '%name' ('%name')", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to update feature '%name' ('%name')",
           array('%name' => $name, '%uiname' => $uname));
         return 0;
       }
-    }    
+    }
   }
-  
+
   // add in the analysis link
   if ($analysis_id) {
     // if the association doens't alredy exist then add one
@@ -833,11 +886,11 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     $results = chado_select_record('analysisfeature', array('analysisfeature_id'), $values, $sel_options);
     if (count($results) == 0) {
       $ins_options = array('statement_name' => 'ins_analysisfeature_anfe');
-      $success = chado_insert_record('analysisfeature', $values, $ins_options);      
+      $success = chado_insert_record('analysisfeature', $values, $ins_options);
       if (!$success) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to associate analysis and feature '%name' ('%name')", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to associate analysis and feature '%name' ('%name')",
           array('%name' => $name, '%uname' => $uname));
-        return 0;  
+        return 0;
       }
     }
   }
@@ -852,11 +905,11 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     $sel_options = array('statement_name' => 'sel_dbxref_dbac');
     $results = chado_select_record('dbxref', array('dbxref_id'), $values, $sel_options);
     // if the accession doesn't exist then add it
-    if (count($results) == 0) {   
+    if (count($results) == 0) {
       $ins_options = array('statement_name' => 'ins_dbxref_dbac');
       $results = chado_insert_record('dbxref', $values, $ins_options);
       if (!$results) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add database accession '%accession'", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add database accession '%accession'",
           array('%accession' => $accession));
         return 0;
       }
@@ -864,12 +917,12 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
       if (count($results) == 1) {
         $dbxref = $results[0];
       }
-      else { 
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to retreive newly inserted dbxref '%name (%uname)'", 
+      else {
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to retreive newly inserted dbxref '%name (%uname)'",
           array('%name' => $name, '%uname' => $numane));
         return 0;
       }
-    } 
+    }
     else {
       $dbxref = $results[0];
     }
@@ -881,15 +934,15 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     );
     $sel_options = array('statement_name' => 'sel_featuredbxref_fedb');
     $results = chado_select_record('feature_dbxref', array('feature_dbxref_id'), $values, $sel_options);
-    if (count($results) == 0) {  
+    if (count($results) == 0) {
       $ins_options = array('statement_name' => 'ins_featuredbxref_fedb');
       $success = chado_insert_record('feature_dbxref', $values, $ins_options);
       if (!$success) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add associate database accession '%accession' with feature", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add associate database accession '%accession' with feature",
           array('%accession' => $accession));
         return 0;
       }
-    }              
+    }
   }
 
    // now add in the relationship if one exists. If not, then add it
@@ -897,34 +950,33 @@ function tripal_feature_fasta_loader_handle_feature($name, $uname, $db_id, $acce
     $values = array(
       'organism_id' => $organism_id,
       'uniquename' => $parent,
-      'type_id' => $parentcvterm->cvterm_id,    
+      'type_id' => $parentcvterm->cvterm_id,
     );
     $options = array('statement_name' => 'sel_feature_oruqty');
     $results = chado_select_record('feature', array('feature_id'), $values, $options);
     if (count($results) != 1) {
-      tripal_report_error('T_fasta_loader', "Cannot find a unique fature for the parent '%parent' of type 
+      tripal_report_error('T_fasta_loader', "Cannot find a unique fature for the parent '%parent' of type
                '%type' for the feature.", array('%parent' => $parent, '%type' => $parent_type));
       return 0;
-    } 
+    }
     $parent_feature = $results[0];
-    
+
    // check to see if the relationship already exists if not then add it
     $values = array(
       'subject_id' => $feature->feature_id,
       'object_id' => $parent_feature->feature_id,
-      'type_id' => $relcvterm->cvterm_id,    
+      'type_id' => $relcvterm->cvterm_id,
     );
     $sel_options = array('statement_name' => 'sel_featurerelationship_suojty');
     $results = chado_select_record('feature_relationship', array('feature_relationship_id'), $values, $sel_options);
-    if (count($results) == 0) {    
+    if (count($results) == 0) {
       $ins_options = array('statement_name' => 'ins_featurerelationship_suojty');
       $success = chado_insert_record('feature_relationship', $values, $ins_options);
       if (!$success) {
-        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add associate database accession '%accession' with feature", 
+        tripal_report_error('T_fasta_loader', TRIPAL_ERROR, "Failed to add associate database accession '%accession' with feature",
           array('%accession' => $accession));
         return 0;
       }
-    }        
+    }
   }
 }
-

Datei-Diff unterdrückt, da er zu groß ist
+ 208 - 166
tripal_feature/includes/tripal_feature.gff_loader.inc


+ 124 - 103
tripal_feature/includes/tripal_feature.seq_extract.inc

@@ -1,10 +1,17 @@
 <?php
-/*
- * 
+/**
+ * @file
+ * Interface for downloading feature sequences
+ */
+
+/**
+ * The page allowing users to download feature sequences
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_seq_extract_page() {
-  
-  if ($_SESSION['tripal_feature_seq_extract']['download']) {   
+
+  if ($_SESSION['tripal_feature_seq_extract']['download']) {
     $genus      = $_SESSION['tripal_feature_seq_extract']['genus'];
     $species    = $_SESSION['tripal_feature_seq_extract']['species'];
     $analysis   = $_SESSION['tripal_feature_seq_extract']['analysis'];
@@ -18,7 +25,7 @@ function tripal_feature_seq_extract_page() {
     $agg_types  = $_SESSION['tripal_feature_seq_extract']['agg_types'];
 
     unset($_SESSION['tripal_feature_seq_extract']['download']);
-     
+
     if ($format == 'fasta_html') {
       drupal_add_http_header('Content-Type: text/html');
     }
@@ -26,32 +33,35 @@ function tripal_feature_seq_extract_page() {
       drupal_add_http_header('Content-Type: text');
       drupal_add_http_header('Content-Disposition: attachment; filename="sequences.fasta.txt"');
     }
-    
-    tripal_feature_seq_extract_get_features(NULL, $genus, $species, $analysis, 
-      $ftype, $fnames['items_array'], $upstream, $downstream, $format, $use_parent, $aggregate, 
+
+    tripal_feature_seq_extract_get_features(NULL, $genus, $species, $analysis,
+      $ftype, $fnames['items_array'], $upstream, $downstream, $format, $use_parent, $aggregate,
       $agg_types);
-      
+
     return;
   }
- 
-  
-  // generate the search form 
+
+
+  // generate the search form
   $output .= '';
-  if (user_access('access administration pages')) { 
+  if (user_access('access administration pages')) {
     $output .= theme('tripal_admin_message', array('message' => "
-        Administrators, the " . l('organism_feature_count', 'admin/tripal/schema/mviews') . " and 
+        Administrators, the " . l('organism_feature_count', 'admin/tripal/schema/mviews') . " and
         " . l('analysis_organism', 'admin/tripal/schema/mviews') . " materialized
-        views must be populated before using this form.  Those views should be re-populated 
+        views must be populated before using this form.  Those views should be re-populated
         when new data is added."
     ));
   }
   $output .= "<div id=\"tripal-feature-seq-extract-form-block\">";
-  $output .= drupal_get_form('tripal_feature_seq_extract_form');  
+  $output .= drupal_get_form('tripal_feature_seq_extract_form');
   $output .= "</div>";
   return $output;
 }
-/*
- * 
+
+/**
+ * Theme the Form to choose which features to extract sequence for
+ *
+ * @ingroup tripal_feature
  */
 function theme_tripal_feature_seq_extract_form($form) {
   $rows = array(
@@ -65,9 +75,9 @@ function theme_tripal_feature_seq_extract_form($form) {
     ),
     2 => array(
       array('data' => drupal_render($form['analysis']), 'colspan' => 3),
-      //drupal_render($form['format']),    
+      //drupal_render($form['format']),
     ),
-    3 => array(     
+    3 => array(
       array('data' =>  drupal_render($form['fnames']), 'colspan' => 2),
       drupal_render($form['upstream']) . drupal_render($form['downstream']) ,
     ),
@@ -75,18 +85,18 @@ function theme_tripal_feature_seq_extract_form($form) {
       array(
         'data' =>  drupal_render($form['advanced']),
         'colspan' => 3,
-      ),    
+      ),
     ),
     5 => array(
       array(
         'data' =>  drupal_render($form['retrieve_btn']) . drupal_render($form['reset_btn']),
         'colspan' => 3,
-      ),    
+      ),
     ),
   );
   $headers = array();
-  $table = theme('table', $headers, $rows, array('id' => 'tripal-feature-seq-extract-form-table', 'border' => '0'));   
-    
+  $table = theme('table', $headers, $rows, array('id' => 'tripal-feature-seq-extract-form-table', 'border' => '0'));
+
   $markup .= $table;
   $form['criteria'] = array(
     '#type' => 'markup',
@@ -95,42 +105,45 @@ function theme_tripal_feature_seq_extract_form($form) {
   );
   return drupal_render($form);
 }
+
 /**
-*
+ * Form to choose which features to extract sequence for
+ *
+ * @ingroup tripal_feature
  */
-function tripal_feature_seq_extract_form(&$form_state = NULL) {   
+function tripal_feature_seq_extract_form(&$form_state = NULL) {
   tripal_core_ahah_init_form();
-  
+
   // we want to allow the query string to provide values for the form
   if ($_GET['fnames']) {
-    $form_state['values']['fnames']['items'] = $_GET['fnames'];  
+    $form_state['values']['fnames']['items'] = $_GET['fnames'];
   }
   if ($_GET['genus']) {
-    $form_state['values']['genus'] = $_GET['genus'];  
+    $form_state['values']['genus'] = $_GET['genus'];
   }
   if ($_GET['species']) {
-    $form_state['values']['species'] = $_GET['species'];  
+    $form_state['values']['species'] = $_GET['species'];
   }
   if ($_GET['ftype']) {
-    $form_state['values']['ftype'] = $_GET['ftype'];  
+    $form_state['values']['ftype'] = $_GET['ftype'];
   }
   if ($_GET['analysis']) {
-    $form_state['values']['analysis'] = $_GET['analysis'];  
+    $form_state['values']['analysis'] = $_GET['analysis'];
   }
   if ($_GET['upstream']) {
-    $form_state['values']['upstream'] = $_GET['upstream'];  
+    $form_state['values']['upstream'] = $_GET['upstream'];
   }
   if ($_GET['downstream']) {
-    $form_state['values']['downstream'] = $_GET['downstream'];  
+    $form_state['values']['downstream'] = $_GET['downstream'];
   }
   if ($_GET['use_parent']) {
-    $form_state['values']['use_parent'] = $_GET['use_parent'];  
+    $form_state['values']['use_parent'] = $_GET['use_parent'];
   }
   if ($_GET['aggregate']) {
-    $form_state['values']['aggregate'] = $_GET['aggregate'];  
+    $form_state['values']['aggregate'] = $_GET['aggregate'];
   }
   if ($_GET['agg_types']) {
-    $form_state['values']['agg_types'] = $_GET['agg_types'];  
+    $form_state['values']['agg_types'] = $_GET['agg_types'];
   }
 
   // get defaults
@@ -146,36 +159,36 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
   $daggregate  = isset($form_state['values']['aggregate'])  ? $form_state['values']['aggregate']  : $_SESSION['tripal_feature_seq_extract']['aggregate'];
   $dagg_types  = isset($form_state['values']['agg_types'])  ? $form_state['values']['agg_types']  : $_SESSION['tripal_feature_seq_extract']['agg_types'];
 
-  
+
   $form = array();
-  
+
   // because we're using Tripal's file_upload_combo form element we
   // need to allow the form to upload files
   $form['#attributes']['enctype'] = 'multipart/form-data';
   $form['#method'] = 'POST';
-    
+
   $form['description'] = array(
     '#type' => 'markup',
     '#value' => t('Use this form to retrieve sequences in FASTA format.')
   );
-  
+
   $sql = "
-    SELECT DISTINCT genus 
-    FROM {organism} 
+    SELECT DISTINCT genus
+    FROM {organism}
     ORDER BY genus
   ";
   $results = chado_query($sql);
   $genus = array();
   $genus[] = '';
   while ($organism = $results->fetchObject()) {
-    $genus[$organism->genus] = $organism->genus;  
+    $genus[$organism->genus] = $organism->genus;
   }
-  
+
   $form['genus'] = array(
     '#title'         => t('Genus'),
     '#type'          => 'select',
-    '#options'       => $genus, 
-    '#default_value' => $dgenus,    
+    '#options'       => $genus,
+    '#default_value' => $dgenus,
     '#multiple'      => FALSE,
     '#description'   => t('The organism\'s genus. If specified, features for all organism with this genus will be retrieved.'),
     '#ahah' => array(
@@ -183,28 +196,28 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
       'wrapper' => 'tripal-feature-seq-extract-form-block',
       'event'   => 'change',
       'method'  => 'replace',
-    ), 
+    ),
   );
-  
-  $species = array();  
+
+  $species = array();
   $species[] = '';
   if ($dgenus) {
     $sql = "
-      SELECT DISTINCT species 
-      FROM {organism} 
+      SELECT DISTINCT species
+      FROM {organism}
       WHERE genus = :genus
       ORDER BY species
     ";
     $results = chado_query($sql, array(':genus' => $dgenus));
     while ($organism = $results->fetchObject()) {
-      $species[$organism->species] = $organism->species;  
+      $species[$organism->species] = $organism->species;
     }
-  }  
+  }
   $form['species'] = array(
     '#title'         => t('Species'),
     '#type'          => 'select',
     '#options'       => $species,
-    '#default_value' => $dspecies,     
+    '#default_value' => $dspecies,
     '#multiple'      => FALSE,
     '#description'   => t('The organism\'s species name. If specified, features for all organisms with this species will be retrieved.  Please first select a genus'),
     '#ahah' => array(
@@ -212,7 +225,7 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
       'wrapper' => 'tripal-feature-seq-extract-form-block',
       'event'   => 'change',
       'method'  => 'replace',
-    ), 
+    ),
   );
 
   $analyses = array();
@@ -220,7 +233,7 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
   if ($dgenus) {
     $sql = "
       SELECT DISTINCT A.analysis_id, A.name
-      FROM {analysis_organism} AO 
+      FROM {analysis_organism} AO
         INNER JOIN {analysis} A ON A.analysis_id = AO.analysis_id
         INNER JOIN {organism} O ON O.organism_id = AO.organism_id
       WHERE O.genus = :genus
@@ -232,26 +245,26 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
       $args[':species'] = $dspecies;
     }
     $sql .=" ORDER BY A.name ";
-    $results = chado_query($sql, $args);  
+    $results = chado_query($sql, $args);
     while ($analysis = $results->fetchObject()) {
-      $analyses[$analysis->name] = $analysis->name;  
+      $analyses[$analysis->name] = $analysis->name;
     }
   }
   $form['analysis'] = array(
     '#title'         => t('Analyses'),
     '#type'          => 'select',
-    '#options'       => $analyses, 
-    '#default_value' => $danalysis,    
+    '#options'       => $analyses,
+    '#default_value' => $danalysis,
     '#multiple'      => FALSE,
     '#description'  => t('You can limit sequences by the analyses to which it was derived or was used. If specified, only features associated with the specific analysis will be retrieved.'),
   );
-  
+
   $ftype = array();
   $ftype[] = '';
-  if ($dgenus) {  
+  if ($dgenus) {
     $sql = "
       SELECT DISTINCT OFC.cvterm_id, OFC.feature_type
-      FROM {organism_feature_count} OFC 
+      FROM {organism_feature_count} OFC
       WHERE OFC.genus = :genus
     ";
     $args = array();
@@ -262,20 +275,20 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
     }
     $sql .= " ORDER BY OFC.feature_type ";
     $results = chado_query($sql, $args);
-    
+
     while ($type = $results->fetchObject()) {
-      $ftype[$type->feature_type] = $type->feature_type;  
+      $ftype[$type->feature_type] = $type->feature_type;
     }
   }
   $form['ftype'] = array(
     '#title'         => t('Feature Type'),
     '#type'          => 'select',
-    '#options'       => $ftype,     
+    '#options'       => $ftype,
     '#multiple'      => FALSE,
     '#default_value' => $dftype,
     '#description'   => t('The type of feature to retrieve (e.g. mRNA). All features that match this type will be retrieved.'),
   );
-  
+
   $form['fnames'] = array(
     '#title'         => t('Feature Name'),
     '#type'          => 'file_upload_combo',
@@ -312,7 +325,7 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
     '#collapsible' => TRUE,
     '#collapsed' => TRUE
   );
-  
+
   $form['advanced']['use_parent'] = array(
     '#title'         => t('Use Parent'),
     '#type'          => 'checkbox',
@@ -343,40 +356,44 @@ function tripal_feature_seq_extract_form(&$form_state = NULL) {
 }
 
 /**
- * 
+ * AJAX callback
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_seq_extract_form_ahah_update() {
   $status = TRUE;
-  
+
   // prepare and render the form. If no form is returned that means
   // we got here by an AHAH call after the form has been submitted.  This
   // is possible because results are downloaded and the page is not refreshed
   // but the form_id goes away.  So, we need to rebuild the form in this case.
   // otherwise, if the form already exists we just theme it.
-  $form = tripal_core_ahah_prepare_form();  
-  if ($form) { 
+  $form = tripal_core_ahah_prepare_form();
+  if ($form) {
     $data = theme('tripal_feature_seq_extract_form', $form);
   }
-  else {    
-    $data = drupal_get_form('tripal_feature_seq_extract_form');    
-  }  
+  else {
+    $data = drupal_get_form('tripal_feature_seq_extract_form');
+  }
 
-  // bind javascript events to the new objects that will be returned 
+  // bind javascript events to the new objects that will be returned
   // so that AHAH enabled elements will work.
   $settings = tripal_core_ahah_bind_events();
 
   // return the updated JSON
   drupal_json(
     array(
-      'status'   => $status, 
+      'status'   => $status,
       'data'     => $data,
       'settings' => $settings,
-    )  
+    )
   );
 }
 
 /**
- * 
+ * Validate the extract sequence form
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_seq_extract_form_validate($form, &$form_state) {
   $genus      = $form_state['values']['genus'];
@@ -389,9 +406,9 @@ function tripal_feature_seq_extract_form_validate($form, &$form_state) {
   $format     = $form_state['values']['format'];
   $use_parent = $form_state['values']['use_parent'];
   $aggregate  = $form_state['values']['aggregate'];
-  $agg_types  = $form_state['values']['agg_types'];  
+  $agg_types  = $form_state['values']['agg_types'];
   $op         = $form_state['values']['op'];
-  
+
   if ($op == 'Retrieve') {
     if ($upstream and !preg_match('/^\d+$/', $upstream)) {
       form_set_error('upstream', 'Please enter a positive numeric value for the upstream bases');
@@ -406,7 +423,9 @@ function tripal_feature_seq_extract_form_validate($form, &$form_state) {
 }
 
 /**
- * 
+ * Submit the extract sequence form
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_seq_extract_form_submit($form, &$form_state) {
   $genus      = $form_state['values']['genus'];
@@ -422,12 +441,12 @@ function tripal_feature_seq_extract_form_submit($form, &$form_state) {
   $agg_types  = $form_state['values']['agg_types'];
   $op         = $form_state['values']['op'];
 
-  // we must use the parent sequence if the user has selected 
+  // we must use the parent sequence if the user has selected
   // the upstream, downstream or to aggregate
   if ($upstream or $downstream or $aggregate) {
     $use_parent = 1;
   }
-  
+
   if ($op == 'Retrieve') {
     $_SESSION['tripal_feature_seq_extract']['genus']      = $genus;
     $_SESSION['tripal_feature_seq_extract']['species']    = $species;
@@ -447,19 +466,21 @@ function tripal_feature_seq_extract_form_submit($form, &$form_state) {
   }
 }
 
-/*
- * 
+/**
+ * Actually extract the sequences
+ *
+ * @ingroup tripal_feature
  */
-function tripal_feature_seq_extract_get_features($org_commonname, $genus, $species, $analysis_name, 
-  $type, $feature_name, $upstream, $downstream, $output_format, $derive_from_parent, $aggregate, 
+function tripal_feature_seq_extract_get_features($org_commonname, $genus, $species, $analysis_name,
+  $type, $feature_name, $upstream, $downstream, $output_format, $derive_from_parent, $aggregate,
   $child, $relationship, $rel_part) {
-    
+
   $sub_features = explode(',', $child);
-    
+
   if (!$output_format) {
     $output_format = 'fasta_txt';
   }
-  
+
   if (!$type and !$feature_name and !$genus) {
     print "Please provide a type, feature name or genus\n";
      return;
@@ -474,7 +495,7 @@ function tripal_feature_seq_extract_get_features($org_commonname, $genus, $speci
   if ($analysis_name) {
      $sql .= "  INNER JOIN {analysisfeature} AF on AF.feature_id = F.feature_id " .
              "  INNER JOIN {analysis} A on AF.analysis_id = A.analysis_id ";
-  }         
+  }
   $sql .= "WHERE (1=1) ";
   if ($org_commonname) {
     $sql .= "AND O.common_name = :common_name ";
@@ -490,7 +511,7 @@ function tripal_feature_seq_extract_get_features($org_commonname, $genus, $speci
   }
   if ($type) {
     $sql .= "AND CVT.name = ':cvtname ";
-    $vars[':cvtname'] = $type; 
+    $vars[':cvtname'] = $type;
   }
   if ($feature_name) {
     if (is_array($feature_name)) {
@@ -498,7 +519,7 @@ function tripal_feature_seq_extract_get_features($org_commonname, $genus, $speci
       foreach ($feature_name as $i => $fname) {
         $sql .= ":fname$i, ";
         $vars[":fname$i"] = $fname;
-      } 
+      }
       // remove the trailing comma and close the paren
       $sql = substr($sql, 0, -2) . ")";
     }
@@ -514,29 +535,29 @@ function tripal_feature_seq_extract_get_features($org_commonname, $genus, $speci
   $num_bases_per_line = 50;
   $num_seqs = 0;
   $q = chado_query($sql, $vars);
-  
+
   while ($feature = $q->fetchObject()) {
-    
+
     $feature_id = $feature->feature_id;
-    
+
     // build the header for each FASTA entry
     if ($feature->uniquename == $feature->name) {
       $feature_name = "$feature->uniquename $feature->feature_type ($feature->genus $feature->species)";
-    } 
+    }
     else {
       $feature_name = "$feature->uniquename $feature->name $feature->feature_type ($feature->genus $feature->species)";
     }
-      
+
     // generate the sequence
-    $sequence = tripal_feature_get_formatted_sequence($feature_id, $feature_name, 
+    $sequence = tripal_feature_get_formatted_sequence($feature_id, $feature_name,
       $num_bases_per_line, $derive_from_parent, $aggregate, $output_format,
       $upstream, $downstream, $sub_features, $relationship, $rel_part);
-    
+
     // print the sequence
     print $sequence;
     $num_seqs++;
   }
-  if ($num_seqs == 0) {    
+  if ($num_seqs == 0) {
     print "No Sequences Found";
   }
 }

+ 17 - 11
tripal_feature/tripal_feature.drush.inc

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * Contains function relating to drush-integration of this module.
@@ -10,6 +9,8 @@
  *
  * @return
  *   The first line of description when executing the help for a given command
+ *
+ * @ingroup tripal_drush
  */
 function tripal_feature_drush_help($command) {
   switch ($command) {
@@ -23,6 +24,8 @@ function tripal_feature_drush_help($command) {
  *
  * @return
  *   And array of command descriptions
+ *
+ * @ingroup tripal_drush
  */
 function tripal_feature_drush_command() {
   $items = array();
@@ -63,16 +66,16 @@ function tripal_feature_drush_command() {
 }
 
 /**
- * Executes jobs in the Tripal Jobs Queue
+ * Retrieves the sequence of the indicated features
  *
- * NOTE: The following code is executed when drush 'trpjob-run' or 'drush tripal-launch-jobs' is called
+ * @ingroup tripal_drush
  */
 function drush_tripal_feature_tripal_get_sequence() {
 
-  $org_commonname = drush_get_option('org');  
+  $org_commonname = drush_get_option('org');
   $genus = drush_get_option('genus');
   $species = drush_get_option('species');
-  $analysis_name = drush_get_option('analysis');  
+  $analysis_name = drush_get_option('analysis');
   $type = drush_get_option('type');
   $feature_name = drush_get_option('name');
   $upstream = drush_get_option('up');
@@ -88,15 +91,18 @@ function drush_tripal_feature_tripal_get_sequence() {
     print "Please specify both 'relationship' and a 'rel_part' arguments. Both must be used together\n";
     return;
   }
-    
-  tripal_feature_seq_extract_get_features($org_commonname, $genus, $species, $analysis_name, 
-    $type, $feature_name, $upstream, $downstream, $output_format, $derive_from_parent, 
+
+  tripal_feature_seq_extract_get_features($org_commonname, $genus, $species, $analysis_name,
+    $type, $feature_name, $upstream, $downstream, $output_format, $derive_from_parent,
     $aggregate, $child, $relationship, $rel_part);
 }
-/*
- * 
+
+/**
+ * Sync Chado Features with Drupal (ie: create nodes)
+ *
+ * @ingroup tripal_drush
  */
 function drush_tripal_feature_sync() {
-  $feature_id = drush_get_option('id');  
+  $feature_id = drush_get_option('id');
   tripal_feature_sync_feature($feature_id);
 }

+ 15 - 6
tripal_feature/tripal_feature.install

@@ -1,11 +1,15 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Installation of the feature module
  */
 
 /**
+ * Implements hook_disable().
+ *
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_disable() {
 
@@ -19,7 +23,9 @@ function tripal_feature_disable() {
 }
 
 /**
- * Implementation of hook_requirements().
+ * Implements hook_requirements().
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_requirements($phase) {
   $requirements = array();
@@ -37,7 +43,7 @@ function tripal_feature_requirements($phase) {
 }
 
 /**
- * Implementation of hook_install().
+ * Implements hook_install().
  *
  * @ingroup tripal_feature
  */
@@ -47,13 +53,13 @@ function tripal_feature_install() {
 
   // add the materialized view
   tripal_feature_add_organism_count_mview();
-  
+
   // create the temp table we will use for loading GFF files
   tripal_cv_create_tripal_gff_temp();
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Implements hook_uninstall().
  *
  * @ingroup tripal_feature
  */
@@ -62,7 +68,9 @@ function tripal_feature_uninstall() {
 }
 
 /**
- * 
+ * Create a temporary table used for loading gff3 files
+ *
+ * @ingroup tripal_feature
  */
 function tripal_cv_create_tripal_gff_temp() {
   // the tripal_obo_temp table is used for temporary housing of records when loading OBO files
@@ -137,6 +145,7 @@ function tripal_feature_schema() {
 };
 
 /**
+ * Creates a materialized view that stores the type & number of features per organism
  *
  * @ingroup tripal_feature
  */

+ 111 - 67
tripal_feature/tripal_feature.module

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Basic functionality for the tripal module
+ */
 
 /**
  * @defgroup tripal_feature Feature Module
@@ -8,30 +12,23 @@
  * @}
  */
 
-require_once "api/tripal_feature.api.inc";
-require_once "api/tripal_feature.schema.api.inc";
-require_once "theme/tripal_feature.theme.inc";
-require_once "includes/tripal_feature.admin.inc";
-require_once "includes/tripal_feature.fasta_loader.inc";
-require_once "includes/tripal_feature.gff_loader.inc";
-require_once "includes/tripal_feature.seq_extract.inc";
-require_once "includes/tripal_feature.delete.inc";
-require_once "includes/tripal_feature.chado_node.inc";
-require_once "includes/tripal_feature.blocks.inc";
+require_once 'api/tripal_feature.api.inc';
+require_once 'api/tripal_feature.schema.api.inc';
 
+require_once 'theme/tripal_feature.theme.inc';
 
-/**
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_init() {
-
-}
+require_once 'includes/tripal_feature.admin.inc';
+require_once 'includes/tripal_feature.fasta_loader.inc';
+require_once 'includes/tripal_feature.gff_loader.inc';
+require_once 'includes/tripal_feature.seq_extract.inc';
+require_once 'includes/tripal_feature.delete.inc';
+require_once 'includes/tripal_feature.chado_node.inc';
+require_once 'includes/tripal_feature.blocks.inc';
 
 /**
- * Implements hook_views_api()
+ * Implements hook_views_api().
  *
- * Purpose: Essentially this hook tells drupal that there is views support for
+ * Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_db.views.inc where all the
  *  views integration code is
  *
@@ -39,11 +36,13 @@ function tripal_feature_init() {
  */
 function tripal_feature_views_api() {
   return array(
-    'api' => 2.0,
+    'api' => 3.0,
   );
 }
 
 /**
+ * Implements hook_help().
+ *
  * Display help and module information
  *
  * @param
@@ -66,8 +65,6 @@ function tripal_feature_help($path, $arg) {
   return $output;
 }
 
-
-
 /**
  * Implements hook_permission().
  *
@@ -102,9 +99,10 @@ function tripal_feature_permission() {
   );
 }
 
-
 /**
- *  Menu items are automatically added for the new node types created
+ * Implements hook_menu().
+ *
+ * Menu items are automatically added for the new node types created
  *  by this module to the 'Create Content' Navigation menu item.  This function
  *  adds more menu items needed for this module.
  *
@@ -212,8 +210,11 @@ function tripal_feature_menu() {
 
   return $items;
 }
+
 /**
- *  We need to let drupal know about our theme functions and their arguments.
+ * Implements hook_theme().
+ *
+ * We need to let drupal know about our theme functions and their arguments.
  *  We create theme functions to allow users of the module to customize the
  *  look and feel of the output generated in this module
  *
@@ -323,9 +324,15 @@ function tripal_feature_theme($existing, $type, $theme, $path) {
   return $items;
 }
 
-
 /**
+ * Load the locations for a given feature
  *
+ * @param $feature_id
+ *   The feature to look up locations for
+ * @param $side
+ *   Whether the feature is the scrfeature, 'as_parent', or feature, 'as_child'
+ * @param $aggregate
+ *   Whether or not to get the locations for related features
  *
  * @ingroup tripal_feature
  */
@@ -382,16 +389,31 @@ function tripal_feature_load_featurelocs($feature_id, $side = 'as_parent', $aggr
   usort($featurelocs, 'tripal_feature_sort_locations');
   return $featurelocs;
 }
+
 /**
- *  used to sort the feature locs by start position
+ * Used to sort the feature locs by start position
+ *
+ * @param $a
+ *   One featureloc record (as an object)
+ * @param $b
+ *   The other featureloc record (as an object)
+ *
+ * @return
+ *   Which feature location comes first
  *
  * @ingroup tripal_feature
  */
 function tripal_feature_sort_locations($a, $b) {
   return strnatcmp($a->fmin, $b->fmin);
 }
+
 /**
+ * Get the relationships for a feature.
  *
+ * @param $feature_id
+ *   The feature to get relationships for
+ * @param $side
+ *   The side of the relationship this feature is (ie: 'as_subject' or 'as_object')
  *
  * @ingroup tripal_feature
  */
@@ -443,8 +465,15 @@ function tripal_feature_load_relationships($feature_id, $side = 'as_subject') {
   }
   return $relationships;
 }
+
 /**
+ * Get features related to the current feature to a given depth. Recursive function.
  *
+ * @param $feature_id
+ * @param $substitute
+ * @param $levels
+ * @param $base_type_id
+ * @param $depth
  *
  * @ingroup tripal_feature
  */
@@ -462,8 +491,12 @@ function tripal_feature_get_aggregate_relationships($feature_id, $substitute=1,
   return tripal_feature_load_relationships($feature_id, 'as_object');
 
 }
+
 /**
+ * Get the sequence this feature is located on
  *
+ * @param $feature_id
+ * @param $featurelocs
  *
  * @ingroup tripal_feature
  */
@@ -595,31 +628,30 @@ function tripal_feature_load_featureloc_sequences($feature_id, $featurelocs) {
   }
   return $floc_sequences;
 }
+
 /**
+ * This function is for features that align through an intermediate such
+ * as 'EST_match' or 'match'.  This occurs in the case where two sequences
+ * align but where one does not align perfectly.  Some ESTs may be in a contig
+ * but not all of the EST.  Portions may overhang and not be included in the
+ * consensus if quality is bad.
+ * For example:
+ *    Feature 1: Contig --------------------
+ *    Feature 2: EST_match           -------
+ *    Feature 3: EST                 ---------
  *
+ * The feature provided to the function will always be the feature 1.  The
+ * featureloc columns prefixed with 'right' (e.g. right_fmin) belong to the
+ * alignment of feature 3 with feature 2
+ *
+ * Features may align to more than one feature and are not matches. We do
+ * not want to include these, so we have to filter on the SO terms:
+ * match, or %_match
  *
  * @ingroup tripal_feature
  */
 function tripal_feature_get_matched_alignments($feature) {
-  // This function is for features that align through an intermediate such
-  // as 'EST_match' or 'match'.  This occurs in the case where two sequences
-  // align but where one does not align perfectly.  Some ESTs may be in a contig
-  // but not all of the EST.  Portions may overhang and not be included in the
-  // consensus if quality is bad.
-  // For example:
-  //
-  //    Feature 1: Contig --------------------
-  //    Feature 2: EST_match           -------
-  //    Feature 3: EST                 ---------
-  //
-  // The feature provided to the function will always be the feature 1.  The
-  // featureloc columns prefixed with 'right' (e.g. right_fmin) belong to the
-  // alignment of feature 3 with feature 2
-  //
-  // Features may align to more than one feature and are not matches. We do
-  // not want to include these, so we have to filter on the SO terms:
-  // match, or %_match
-  //
+
    $sql = "
      SELECT
        FL1.featureloc_id    as left_featureloc_id,
@@ -668,8 +700,12 @@ function tripal_feature_get_matched_alignments($feature) {
    }
    return $featurelocs;
 }
+
 /**
+ * Load the arguments for the organism feature counts browser
  *
+ * @param $organism
+ *  The organism of interest
  *
  * @ingroup tripal_feature
  */
@@ -751,7 +787,7 @@ function tripal_feature_load_organism_feature_counts($organism) {
 }
 
 /**
- *  used to sort the list of relationship parts by start position
+ * Used to sort the list of relationship parts by start position
  *
  * @ingroup tripal_feature
  */
@@ -768,7 +804,7 @@ function tripal_feature_sort_rel_parts_by_start($a, $b) {
 }
 
 /**
- *  used to sort the list of relationship parts by start position
+ * Used to sort the list of relationship parts by start position
  *
  * @ingroup tripal_feature
  */
@@ -781,7 +817,11 @@ function tripal_feature_sort_rel_parts_by_end($a, $b) {
 }
 
 /**
+ * Returns the marked up fasta sequence for the described feature
  *
+ * @param $sequence
+ * @param $parts
+ * @param $defline
  *
  * @ingroup tripal_feature
  */
@@ -868,11 +908,12 @@ function tripal_feature_color_sequence($sequence, $parts, $defline) {
   return $newseq;
 }
 
-
-
-
 /**
- *
+ * The CV module will create the JSON array necessary for buillding a
+ * pie chart using jgChart and Google Charts.  We have to pass to it
+ * a table that contains count information, tell it which column
+ * contains the cvterm_id and provide a filter for getting the
+ * results we want from the table.
  *
  * @ingroup tripal_feature
  */
@@ -896,11 +937,6 @@ function tripal_feature_cv_chart($chart_id) {
 
   $organism_id = preg_replace("/^tripal_feature_cv_chart_(\d+)$/", "$1", $chart_id);
 
-  // The CV module will create the JSON array necessary for buillding a
-  // pie chart using jgChart and Google Charts.  We have to pass to it
-  // a table that contains count information, tell it which column
-  // contains the cvterm_id and provide a filter for getting the
-  // results we want from the table.
   $options = array(
     count_mview      => 'organism_feature_count',
     cvterm_id_column => 'cvterm_id',
@@ -912,17 +948,16 @@ function tripal_feature_cv_chart($chart_id) {
 }
 
 /**
- *
+ * The CV module will create the JSON array necessary for buillding a
+ * pie chart using jgChart and Google Charts.  We have to pass to it
+ * a table that contains count information, tell it which column
+ * contains the cvterm_id and provide a filter for getting the
+ * results we want from the table.
  *
  * @ingroup tripal_feature
  */
 function tripal_feature_cv_tree($tree_id) {
 
-  // The CV module will create the JSON array necessary for buillding a
-  // pie chart using jgChart and Google Charts.  We have to pass to it
-  // a table that contains count information, tell it which column
-  // contains the cvterm_id and provide a filter for getting the
-  // results we want from the table.
   $organism_id = preg_replace("/^tripal_feature_cv_tree_(\d+)$/", "$1", $tree_id);
   $options = array(
     cv_id            => tripal_cv_get_cv_id('sequence'),
@@ -936,7 +971,7 @@ function tripal_feature_cv_tree($tree_id) {
 }
 
 /**
- *
+ * Delete the drupal taxonomy associated with our features
  *
  * @ingroup tripal_feature
  */
@@ -970,7 +1005,8 @@ function tripal_feature_del_vocabulary() {
 }
 
 /**
- *
+ * Implements hook_job_describe_args() in order to describe the various feature jobs
+ * to the tripal jobs interface.
  *
  * @ingroup tripal_feature
  */
@@ -1058,7 +1094,11 @@ function tripal_feature_job_describe_args($callback, $args) {
 
 /**
  * Implements hook_coder_ignore().
- * Defines the path to the file (tripal_core.coder_ignores.txt) where ignore rules for coder are stored
+ *
+ * Defines the path to the file (tripal_core.coder_ignores.txt) where ignore rules for
+ * coder are stored
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_coder_ignore() {
   return array(
@@ -1072,6 +1112,8 @@ function tripal_feature_coder_ignore() {
  * that ID by name, featurename or synonym.  If it matches uniquenly to a single
  * feature it will redirect to that feature page, otherwise, a list of matching
  * features is shown.
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_match_features_page($id) {
 
@@ -1152,6 +1194,8 @@ function tripal_feature_match_features_page($id) {
  * @param $form
  * @param $form_state
  * @param $form_id
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == "tripal_feature_seq_extract_form") {
@@ -1164,4 +1208,4 @@ function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == "chado_feature_node_form") {
     $form['actions']['preview']['#access'] = FALSE;
   }
-}
+}

+ 4 - 7
tripal_feature/tripal_feature.views.inc

@@ -1,23 +1,20 @@
 <?php
-
 /**
  *  @file
  *  This file contains the basic functions for views integration of
- *  chado/tripal organism tables. Supplementary functions can be found in
- *  ./views/
- *
- *  Documentation on views integration can be found at
- *  http://views2.logrus.com/doc/html/index.html.
+ *  chado/tripal feature tables
  */
 
 /**
- * Implements hook_views_handlers()
+ * Implements hook_views_handlers().
  *
  * Purpose: Register all custom handlers with views
  *   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
+ *
+ * @ingroup tripal_feature
  */
 function tripal_feature_views_handlers() {
   return array(

+ 11 - 0
tripal_feature/tripal_feature.views_default.inc

@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Describe default feature views
+ */
 
 /**
+ * Implements hook_views_default_views().
  *
+ * @ingroup tripal_feature
  */
 function tripal_feature_views_default_views() {
   $views = array();
@@ -12,6 +18,11 @@ function tripal_feature_views_default_views() {
   return $views;
 }
 
+/**
+ * The default feature administration view
+ *
+ * @ingroup tripal_feature
+ */
 function tripal_feature_defaultview_admin_features() {
 
   $view = new view();

+ 10 - 1
tripal_feature/views_handlers/views_handler_field_residues.inc

@@ -1,7 +1,7 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Contains views_handler_field_residues field handler
  */
 
 /**
@@ -12,16 +12,25 @@
  */
 class views_handler_field_residues extends views_handler_field {
 
+  /**
+   * {@inheritdoc}
+   */
   function construct() {
     parent::construct();
       $this->additional_fields['residues'] = array('table' => 'feature', 'field' => 'residues');
   }
 
+  /**
+   * {@inheritdoc}
+   */
   function query() {
     $this->ensure_my_table();
     $this->add_additional_fields();
   }
 
+  /**
+   * {@inheritdoc}
+   */
   function render($values) {
     // add a <br> every 100 bp
     return ereg_replace("(.{100})", "\\1<br />", $values->feature_residues);

+ 15 - 2
tripal_featuremap/api/tripal_featuremap.api.inc

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Provides an application programming interface (API) to manage chado feature maps
+ */
 
 /**
  * @defgroup tripal_featuremap_api Feature Map API
@@ -69,6 +73,7 @@ function tripal_featuremap_insert_property($featuremap_id, $property, $value, $u
 function tripal_featuremap_update_property($featuremap_id, $property, $value, $insert_if_missing = 0) {
   return chado_update_property('featuremap', $featuremap_id, $property, 'featuremap_property', $value, $insert_if_missing);
 }
+
 /**
  * Delete a given property
  *
@@ -89,8 +94,16 @@ function tripal_featuremap_delete_property($featuremap_id, $property) {
   return chado_delete_property('featuremap', $featuremap_id, $property, 'featuremap_property');
 }
 
-/*
+/**
+ * Add a dbxref to the featuremap_dbxref table
  *
+ * @param $featuremap_id
+ *  The id of the featuremap of interest
+ * @param $featuremap_dbxref
+ *  A string describing the dbxref with the db name separated from the dbxref accession
+ *  by a colon (:)
+ *
+ * @ingroup tripal_featuremap_api
  */
 function tripal_featuremap_add_featuremap_dbxref($featuremap_id, $featuremap_dbxref) {
 
@@ -150,4 +163,4 @@ function tripal_featuremap_add_featuremap_dbxref($featuremap_id, $featuremap_dbx
     return FALSE;
   }
   return $results;
-}
+}

+ 6 - 10
tripal_featuremap/includes/tripal_featuremap.admin.inc

@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Administration of feature maps
+ */
 
 /**
  * Admin launchpad
+ *
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_admin_featuremaps_listing() {
   $output = '';
@@ -47,13 +53,3 @@ function tripal_featuremap_admin() {
 
   return system_settings_form($form);
 }
-
-
-/**
- *
- * @ingroup tripal_featuremap
- */
-function tripal_featuremap_admin_validate($form, &$form_state) {
-
-}
-

+ 28 - 7
tripal_featuremap/includes/tripal_featuremap.chado_node.inc

@@ -1,5 +1,12 @@
 <?php
 /**
+ * @file
+ * Hooks implementing the feature map node content type
+ */
+
+/**
+ * Implements hook_node_info().
+ *
  * Provide information to drupal about the node types that we're creating
  * in this module
  *
@@ -31,6 +38,7 @@ function tripal_featuremap_node_info() {
   );
   return $nodes;
 }
+
 /**
  *  When editing or creating a new node of type 'chado_featuremap' we need
  *  a form.  This function creates the form that will be used for this.
@@ -150,8 +158,9 @@ function chado_featuremap_form($node, &$form_state) {
 
   return $form;
 }
+
 /**
- *  validates submission of form when adding or updating a map node
+ * Validates submission of form when adding or updating a map node
  *
  * @ingroup tripal_featuremap
  */
@@ -192,9 +201,8 @@ function chado_featuremap_validate($node, $form, &$form_state) {
   }
 }
 
-
 /**
- * Implement hook_access().
+ * Implement hook_node_access().
  *
  * This hook allows node modules to limit access to the node types they define.
  *
@@ -249,7 +257,9 @@ function chado_featuremap_node_access($node, $op, $account) {
 }
 
 /**
- *  When a new chado_featuremap node is created we also need to add information
+ * Implements hook_insert().
+ *
+ * When a new chado_featuremap node is created we also need to add information
  *  to our chado_featuremap table.  This function is called on insert of a new node
  *  of type 'chado_featuremap' and inserts the necessary information.
  *
@@ -331,8 +341,9 @@ function chado_featuremap_insert($node) {
     drupal_write_record('chado_featuremap', $record);
   }
 }
+
 /**
- * Update nodes
+ * Implements hook_update(). Update nodes
  *
  * @ingroup tripal_featuremap
  */
@@ -396,7 +407,10 @@ function chado_featuremap_update($node) {
   chado_update_node_form_dbxrefs($node, $details);
 
 }
+
 /**
+ * Implements hook_load().
+ *
  *  When a node is requested by the user this function is called to allow us
  *  to add auxiliary data to the node object.
  *
@@ -417,7 +431,10 @@ function chado_featuremap_load($nodes) {
   }
 
 }
+
 /**
+ * Implements hook_delete().
+ *
  * Delete data from drupal and chado databases when a node is deleted
  * @ingroup tripal_featuremap
  */
@@ -446,9 +463,11 @@ function chado_featuremap_delete(&$node) {
   chado_query("DELETE FROM {featuremap}        WHERE featuremap_id = :featuremap_id", array(':featuremap_id' => $featuremap_id));
 
 }
+
 /**
+ * Implements hook_node_presave(). Acts on all content types.
  *
- * @param $node
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_node_presave($node) {
   switch ($node->type) {
@@ -465,7 +484,9 @@ function tripal_featuremap_node_presave($node) {
       break;
   }
 }
+
 /**
+ * Implements hook_node_view(). Acts on all content types.
  *
  * @ingroup tripal_feature
  */
@@ -508,4 +529,4 @@ function tripal_featuremap_node_view($node, $view_mode, $langcode) {
       }
       break;
   }
-}
+}

+ 22 - 8
tripal_featuremap/tripal_featuremap.install

@@ -1,11 +1,14 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Handles installation of the feature map module
  */
 
 /**
+ * Implements hook_disable().
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_disable() {
 
@@ -20,6 +23,8 @@ function tripal_featuremap_disable() {
 
 /**
  * Implementation of hook_requirements().
+ *
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_requirements($phase) {
   $requirements = array();
@@ -102,20 +107,22 @@ function tripal_featuremap_schema() {
 }
 
 /**
+ * Add cvs needed by the featuremap module
  *
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_add_cvs() {
-  
+
   tripal_cv_add_cv(
-    'featuremap_units', 
+    'featuremap_units',
     'Contains map unit types for the unittype_id column of the featuremap table.'
   );
-  
+
   tripal_cv_add_cv(
-    'featurepos_property', 
+    'featurepos_property',
     'Contains terms map properties.'
   );
-  
+
   tripal_cv_add_cv(
     'featuremap_property',
     'Contains positional types for the feature positions'
@@ -123,7 +130,9 @@ function tripal_featuremap_add_cvs() {
 }
 
 /**
+ * Add cv terms needed by the featuremap module
  *
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_add_cvterms() {
 
@@ -163,7 +172,7 @@ function tripal_featuremap_add_cvterms() {
      ),
      'featuremap_units', 0, 1, 'tripal'
    );
-   
+
    // featurepos properties
    tripal_cv_add_cvterm(
      array(
@@ -240,8 +249,13 @@ function tripal_featuremap_add_cvterms() {
 
 }
 
-/*
+/**
+ * Add custom tables needed by the feature map module
+ *  - featuremapprop
+ *  - featuremap_dbxref
+ *  - featureposprop
  *
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_add_custom_tables(){
   // add the featuremaprop table to Chado

+ 35 - 34
tripal_featuremap/tripal_featuremap.module

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Integrates the Chado Map module with Drupal Nodes & Views
+ */
 
 /**
  * @defgroup tripal_featuremap Feature Map Module
@@ -8,26 +12,23 @@
  * @}
  */
 
-require('api/tripal_featuremap.api.inc');
-require('theme/tripal_featuremap.theme.inc');
-require('includes/tripal_featuremap.admin.inc');
-require('includes/tripal_featuremap.chado_node.inc');
-
-/**
- *
- * @ingroup tripal_featuremap
- */
-function tripal_featuremap_init() {
+require 'api/tripal_featuremap.api.inc';
 
-}
+require 'theme/tripal_featuremap.theme.inc';
 
+require 'includes/tripal_featuremap.admin.inc';
+require 'includes/tripal_featuremap.chado_node.inc';
 
 /**
+ * Implements hook_help().
  * Display help and module information
- * @param path which path of the site we're displaying help
- * @param arg array that holds the current path as would be returned from arg()
- * function
- * @return help text for the path
+ *
+ * @param path
+ *   which path of the site we're displaying help
+ * @param arg
+ *   array that holds the current path as would be returned from arg() function
+ * @return
+ *  help text for the path
  *
  * @ingroup tripal_featuremap
  */
@@ -43,8 +44,6 @@ function tripal_featuremap_help($path, $arg) {
   return $output;
 }
 
-
-
 /**
  * Implements hook_permission().
  *
@@ -80,6 +79,8 @@ function tripal_featuremap_permission() {
 }
 
 /**
+ * Implements hook_menu().
+ *
  * Menu items are automatically added for the new node types created
  * by this module to the 'Create Content' Navigation menu item.  This function
  * adds more menu items needed for this module.
@@ -148,21 +149,24 @@ function tripal_featuremap_menu() {
 }
 
 /**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
- *  for this module which then includes tripal_db.views.inc where all the
+ * Implements hook_views_api().
+ *
+ * Essentially this hook tells drupal that there is views support for
+ *  for this module which then includes tripal_featuremap.views.inc where all the
  *  views integration code is
  *
  * @ingroup tripal_featuremap
  */
 function tripal_featuremap_views_api() {
   return array(
-    'api' => 2.0,
+    'api' => 3.0,
   );
 }
 
 /**
- *  We need to let drupal know about our theme functions and their arguments.
+ * Implements hook_theme().
+ *
+ * We need to let drupal know about our theme functions and their arguments.
  *  We create theme functions to allow users of the module to customize the
  *  look and feel of the output generated in this module
  *
@@ -218,7 +222,9 @@ function tripal_featuremap_theme($existing, $type, $theme, $path) {
 }
 
 /**
- * @ingroup tripal_library
+ * Implements hook_block_info().
+ *
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_block_info() {
 
@@ -239,8 +245,11 @@ function tripal_featuremap_block_info() {
 
   return $blocks;
 }
+
 /**
- * @ingroup tripal_library
+ * Implements hook_block_view().
+ *
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_block_view($delta = '') {
 
@@ -276,21 +285,14 @@ function tripal_featuremap_block_view($delta = '') {
   }
 }
 
-/**
- *
- * @ingroup tripal_featuremap
- */
-function tripal_featuremap_cron() {
-
-}
-
-
 /**
  * Implementation of hook_form_alter()
  *
  * @param $form
  * @param $form_state
  * @param $form_id
+ *
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_form_alter(&$form, &$form_state, $form_id) {
   // turn of preview button for insert/updates
@@ -298,4 +300,3 @@ function tripal_featuremap_form_alter(&$form, &$form_state, $form_id) {
     $form['actions']['preview']['#access'] = FALSE;
   }
 }
-

+ 12 - 1
tripal_featuremap/tripal_featuremap.views_default.inc

@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Default feature map views
+ */
 
 /**
+ * Implements hook_views_default_views().
  *
+ * @ingroup tripal_featuremap
  */
 function tripal_featuremap_views_default_views() {
   $views = array();
@@ -12,6 +18,11 @@ function tripal_featuremap_views_default_views() {
   return $views;
 }
 
+/**
+ * Describes the default featuremap admin view
+ *
+ * @ingroup tripal_featuremap
+ */
 function tripal_featuremap_defaultview_admin_featuremaps() {
 
   $view = new view();
@@ -185,4 +196,4 @@ function tripal_featuremap_defaultview_admin_featuremaps() {
   $handler->display->display_options['tab_options']['weight'] = '0';
 
   return $view;
-}
+}

+ 1 - 1
tripal_genetic/api/tripal_genetic.api.inc

@@ -1,5 +1,5 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * API for managing genetic data
  */

+ 9 - 0
tripal_genetic/includes/tripal_genetic.admin.inc

@@ -1,5 +1,14 @@
 <?php
+/**
+ * @file
+ * Provides administration of chado genetic data
+ */
 
+/**
+ * Administration launchpad
+ *
+ * @ingroup tripal_genetic
+ */
 function tripal_genetic_admin_genetics_listing() {
   $output = '';
 

+ 5 - 0
tripal_genetic/includes/tripal_genetic.schema.inc

@@ -1,4 +1,9 @@
 <?php
+/**
+ * @file
+ * Add to the tripal schema definitions
+ */
+
 /**
  * Implements hook_chado_schema_v1_11_table()
  * Purpose: To add descriptions and foreign keys to default table description

+ 7 - 0
tripal_genetic/tripal_genetic.install

@@ -1,7 +1,14 @@
 <?php
+/**
+ * @file
+ * Installation of the tripal genetic module
+ */
 
 /**
+ * Implements hook_disable().
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_genetic
  */
 function tripal_genetic_disable() {
 

+ 17 - 7
tripal_genetic/tripal_genetic.module

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Basic functionality for the genetic
+ */
 
 /**
  * @defgroup tripal_genetic Genetic Module
@@ -8,10 +12,12 @@
  * @}
  */
 
-require('api/tripal_genetic.api.inc');
-require('theme/tripal_genetic.theme.inc');
-require('includes/tripal_genetic.schema.inc');
-require('includes/tripal_genetic.admin.inc');
+require 'api/tripal_genetic.api.inc';
+
+require 'theme/tripal_genetic.theme.inc';
+
+require 'includes/tripal_genetic.schema.inc';
+require 'includes/tripal_genetic.admin.inc';
 
 /**
  * Implements hook_permission().
@@ -29,7 +35,10 @@ function tripal_genetic_permission() {
     ),
   );
 }
+
 /**
+ *  Implements hook_menu().
+ *
  *  Menu items are automatically added for the new node types created
  *  by this module to the 'Create Content' Navigation menu item.  This function
  *  adds more menu items needed for this module.
@@ -69,8 +78,9 @@ function tripal_genetic_menu() {
 }
 
 /**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
+ * Implements hook_views_api().
+ *
+ * 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
  *
@@ -111,7 +121,7 @@ function tripal_genetic_theme($existing, $type, $theme, $path) {
 }
 
 /**
- * Implements hook_nodeapi().
+ * Implements hook_node_view(). Acts on all content types
  *
  * @ingroup tripal_genetic
  */

+ 12 - 1
tripal_genetic/tripal_genetic.views_default.inc

@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Describe default genetic views
+ */
 
 /**
  * Implements hook_views_default_views().
+ *
+ * @ingroup tripal_genetic
  */
 function tripal_genetic_views_default_views() {
   $views = array();
@@ -12,6 +18,11 @@ function tripal_genetic_views_default_views() {
   return $views;
 }
 
+/**
+ * Describes the default administration genetic view
+ *
+ * @ingroup tripal_genetic
+ */
 function tripal_genetic_defaultviews_admin_genotypes() {
 
   $view = new view();
@@ -123,4 +134,4 @@ function tripal_genetic_defaultviews_admin_genotypes() {
   $handler->display->display_options['tab_options']['weight'] = '0';
 
   return $view;
-}
+}

+ 6 - 0
tripal_library/api/tripal_library.api.inc

@@ -1,4 +1,9 @@
 <?php
+/**
+ * @file
+ * Provides an application programming interface (API) to manage libraries
+ */
+
 /**
  * @defgroup tripal_library_api Library API
  * @ingroup tripal_api
@@ -68,6 +73,7 @@ function tripal_library_insert_property($library_id, $property, $value, $update_
 function tripal_library_update_property($library_id, $property, $value, $insert_if_missing = 0) {
   return chado_update_property('library', $library_id, $property, 'library_property', $value, $insert_if_missing);
 }
+
 /**
  * Delete a given property
  *

+ 9 - 11
tripal_library/includes/tripal_library.admin.inc

@@ -1,5 +1,14 @@
 <?php
+/**
+ * @file
+ * Admin launchpad
+ */
 
+/**
+ * Admin launchpad
+ *
+ * @ingroup tripal_library
+ */
 function tripal_library_admin_libraries_listing() {
   $output = '';
 
@@ -44,14 +53,3 @@ function tripal_library_admin() {
 
   return system_settings_form($form);
 }
-
-
-
-/**
- *
- * @ingroup tripal_library
- */
-function tripal_library_admin_validate($form, &$form_state) {
-  
-}
-

+ 33 - 8
tripal_library/includes/tripal_library.chado_node.inc

@@ -1,6 +1,12 @@
 <?php
+/**
+ * @file
+ * Implements the library node content type
+ */
 
 /**
+ * Implements hook_node_info().
+ *
  * Provide information to drupal about the node types that we're creating
  * in this module
  *
@@ -33,7 +39,9 @@ function tripal_library_node_info() {
 }
 
 /**
- *  When editing or creating a new node of type 'chado_library' we need
+ *  Implements hook_form().
+ *
+ * When editing or creating a new node of type 'chado_library' we need
  *  a form.  This function creates the form that will be used for this.
  *
  * @ingroup tripal_library
@@ -196,8 +204,11 @@ function chado_library_form($node, &$form_state) {
 
   return $form;
 }
+
 /**
- *  validates submission of form when adding or updating a library node
+ * Implements hook_validate().
+ *
+ * Validates submission of form when adding or updating a library node
  *
  * @ingroup tripal_library
  */
@@ -226,7 +237,10 @@ function chado_library_validate($node, $form, &$form_state) {
     form_set_error('uniquename', t('The unique library name already exists. Please choose another'));
   }
 }
+
 /**
+ *  Implements hook_insert().
+ *
  *  When a new chado_library node is created we also need to add information
  *  to our chado_library table.  This function is called on insert of a new node
  *  of type 'chado_library' and inserts the necessary information.
@@ -296,8 +310,9 @@ function chado_library_insert($node) {
     drupal_write_record('chado_library', $record);
   }
 }
+
 /**
- * Update nodes
+ * Implements hook_update().
  *
  * @ingroup tripal_library
  */
@@ -312,7 +327,7 @@ function chado_library_update($node) {
   $match = array(
     'library_id' => $library_id,
   );
-  
+
   $values = array(
     'name'        => $node->libraryname,
     'uniquename'  => $node->uniquename,
@@ -349,7 +364,10 @@ function chado_library_update($node) {
   chado_update_node_form_dbxrefs($node, $details);
 
 }
+
 /**
+ *  Implements hook_load().
+ *
  *  When a node is requested by the user this function is called to allow us
  *  to add auxiliary data to the node object.
  *
@@ -372,7 +390,10 @@ function chado_library_load($nodes) {
 }
 
 /**
+ * Implements hook_delete().
+ *
  * Delete data from drupal and chado databases when a node is deleted
+ *
  * @ingroup tripal_library
  */
 function chado_library_delete(&$node) {
@@ -400,7 +421,7 @@ function chado_library_delete(&$node) {
 }
 
 /**
- * Implement hook_access().
+ * Implement hook_node_access().
  *
  * This hook allows node modules to limit access to the node types they define.
  *
@@ -446,7 +467,10 @@ function chado_library_node_access($node, $op, $account) {
   }
   return NULL;
 }
+
 /**
+ * Implements hook_node_view(). Acts on all content types
+ *
  * @ingroup tripal_library
  */
 function tripal_library_node_view($node, $view_mode, $langcode) {
@@ -514,11 +538,12 @@ function tripal_library_node_view($node, $view_mode, $langcode) {
 }
 
 /**
+ * Implements hook_node_presave(). Acts on all node content types.
  *
- * @param $node
+ * @ingroup tripal_library
  */
 function tripal_library_node_presave($node) {
-  
+
   switch ($node->type) {
     case 'chado_library':
       // for a form submission the 'libraryname' field will be set,
@@ -532,4 +557,4 @@ function tripal_library_node_presave($node) {
       }
       break;
   }
-}
+}

+ 26 - 11
tripal_library/tripal_library.install

@@ -1,11 +1,14 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Installation of the library module
  */
 
 /**
+ * Implements hook_disable().
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_library
  */
 function tripal_library_disable() {
 
@@ -20,6 +23,8 @@ function tripal_library_disable() {
 
 /**
  * Implementation of hook_requirements().
+ *
+ * @ingroup tripal_library
  */
 function tripal_library_requirements($phase) {
   $requirements = array();
@@ -35,6 +40,7 @@ function tripal_library_requirements($phase) {
   }
   return $requirements;
 }
+
 /**
  * Implementation of hook_install().
  *
@@ -101,6 +107,8 @@ function tripal_library_schema() {
 }
 
 /**
+ * Adds a materialized view keeping track of the type of features associated with each library
+ *
  * @ingroup tripal_library
  */
 function tripal_library_add_mview_library_feature_count(){
@@ -152,18 +160,23 @@ function tripal_library_add_mview_library_feature_count(){
 
 /**
  * Adds new CV's used by this module
+ *
+ * @ingroup tripal_library
  */
 function tripal_library_add_cvs(){
   tripal_cv_add_cv(
-    'library_property', 
+    'library_property',
     'Contains properties for libraries'
   );
   tripal_cv_add_cv(
-    'library_type', 
+    'library_type',
     'Contains terms for types of libraries (e.g. BAC, cDNA, FOSMID, etc).'
   );
 }
+
 /**
+ * Adds cvterms needed for the library module
+ *
  * @ingroup tripal_library
  */
 function tripal_library_add_cvterms() {
@@ -173,7 +186,7 @@ function tripal_library_add_cvterms() {
   // description in the libraryprop table.
   tripal_cv_add_cvterm(
      array(
-       'name' => 'Library Description', 
+       'name' => 'Library Description',
        'def' => 'Description of a library'
      ),
     'library_property', 0, 1, 'tripal'
@@ -224,10 +237,12 @@ function tripal_library_add_cvterms() {
 }
 
 /**
- * This is the required update for tripal_library when upgrading from Drupal core API 6.x. 
+ * This is the required update for tripal_library when upgrading from Drupal core API 6.x.
+ *
+ * @ingroup tripal_library
  */
 function tripal_library_update_7000() {
-  
+
   // the library types were formerly in a vocabulary named 'tripal_library_types'.
   // rename that to just be 'library_type'
   $cv = tripal_cv_get_cv_by_name('tripal_library_types');
@@ -241,11 +256,11 @@ function tripal_library_update_7000() {
   if (!$success) {
     throw new DrupalUpdateException('Failed to rename tripal_library_types CV.');
   }
-  
-  
-  // For Tripal in Drupal 6 the library_description cvterm was stored in the 
+
+
+  // For Tripal in Drupal 6 the library_description cvterm was stored in the
   // 'tripal' CV.  It should be stored in the new library_property CV that
-  // is added by this module for Tripal 2.0 and Drupal 7.  So, we need to 
+  // is added by this module for Tripal 2.0 and Drupal 7.  So, we need to
   // reset the CV ID for that term and rename the term to 'Library Description'
   tripal_library_add_cvs();
   $cv = tripal_cv_get_cv_by_name('library_property');
@@ -261,4 +276,4 @@ function tripal_library_update_7000() {
   if (!$success) {
     throw new DrupalUpdateException('Failed to move library properties to new library_property CV.');
   }
-}
+}

+ 33 - 23
tripal_library/tripal_library.module

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Integrates the Chado Library module with Drupal Nodes & Views
+ */
 
 /**
  * @defgroup tripal_library Library Module
@@ -8,22 +12,23 @@
  * @}
  */
 
-require('api/tripal_library.api.inc');
-require('theme/tripal_library.theme.inc');
-require('includes/tripal_library.admin.inc');
-require('includes/tripal_library.chado_node.inc');
-
+require 'api/tripal_library.api.inc';
 
+require 'theme/tripal_library.theme.inc';
 
+require 'includes/tripal_library.admin.inc';
+require 'includes/tripal_library.chado_node.inc';
 
 /**
+ * Implements hook_permission().
+ *
  * Set the permission types that the chado module uses.  Essentially we
  * want permissionis that protect creation, editing and deleting of chado
  * data objects
  *
  * @ingroup tripal_library
  */
-function tripal_library_permisssions() {
+function tripal_library_permisssion() {
   return array(
     'access chado_library content' => array(
       'title' => t('View Libraries'),
@@ -49,6 +54,8 @@ function tripal_library_permisssions() {
 }
 
 /**
+ * Implements hook_menu().
+ *
  * Menu items are automatically added for the new node types created
  * by this module to the 'Create Content' Navigation menu item.  This function
  * adds more menu items needed for this module.
@@ -107,8 +114,9 @@ function tripal_library_menu() {
 }
 
 /**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
+ * Implements hook_views_api().
+ *
+ * Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_db.views.inc where all the
  *  views integration code is
  *
@@ -116,13 +124,14 @@ function tripal_library_menu() {
  */
 function tripal_library_views_api() {
   return array(
-    'api' => 2.0,
+    'api' => 3.0,
   );
 }
 
-
 /**
- *  We need to let drupal know about our theme functions and their arguments.
+ *  Implements hook_theme().
+ *
+ * We need to let drupal know about our theme functions and their arguments.
  *  We create theme functions to allow users of the module to customize the
  *  look and feel of the output generated in this module
  *
@@ -202,15 +211,20 @@ function tripal_library_theme($existing, $type, $theme, $path) {
 }
 
 /**
- * Implements hook_help()
- * Purpose: Adds a help page to the module list
+ * Implements hook_help().
+ * Adds a help page to the module list
+ *
+ * @ingroup tripal_library
  */
 function tripal_library_help ($path, $arg) {
   if ($path == 'admin/help#tripal_library') {
     return theme('tripal_library_help', array());
   }
 }
+
 /**
+ * Implements hook_block_info().
+ *
  * @ingroup tripal_library
  */
 function tripal_library_block_info() {
@@ -238,7 +252,10 @@ function tripal_library_block_info() {
 
   return $blocks;
 }
+
 /**
+ * Implements hook_block_view().
+ *
  * @ingroup tripal_library
  */
 function tripal_library_block_view($delta = '') {
@@ -284,20 +301,13 @@ function tripal_library_block_view($delta = '') {
 }
 
 /**
- *
- * @ingroup tripal_library
- */
-function tripal_library_cron() {
-
-}
-
-
-/**
- * Implementation of hook_form_alter()
+ * Implementation of hook_form_alter().
  *
  * @param $form
  * @param $form_state
  * @param $form_id
+ *
+ * @ingroup tripal_library
  */
 function tripal_library_form_alter(&$form, &$form_state, $form_id) {
   // turn of preview button for insert/updates

+ 12 - 2
tripal_library/tripal_library.views_default.inc

@@ -1,8 +1,13 @@
 <?php
+/**
+ * @file
+ * Describes library default views
+ */
 
 /**
+ * Implements hook_views_default_views().
  *
- *
+ * @ingroup tripal_library
  */
 function tripal_library_views_default_views() {
   $views = array();
@@ -13,6 +18,11 @@ function tripal_library_views_default_views() {
   return $views;
 }
 
+/**
+ * Default administration library view
+ *
+ * @ingroup tripal_library
+ */
 function tripal_library_admin_defaultviews_library() {
 
   $view = new view();
@@ -220,4 +230,4 @@ function tripal_library_admin_defaultviews_library() {
   */
 
   return $view;
-}
+}

+ 1 - 1
tripal_natural_diversity/api/tripal_natural_diversity.api.inc

@@ -1,6 +1,6 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * API for natural diversity data
  */
 

+ 7 - 1
tripal_natural_diversity/includes/tripal_natural_diversity.admin.inc

@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Administration of the natural diversity module
+ */
 
 /**
+ * Admin Launchpad
  *
+ * @ingroup tripal_natural_diversity
  */
 function tripal_natural_diversity_admin_natdiv_view() {
   $output = '';
@@ -31,4 +37,4 @@ function tripal_natural_diversity_admin_natdiv_view() {
   }
 
   return $output;
-}
+}

+ 3 - 2
tripal_natural_diversity/includes/tripal_natural_diversity.schema.inc

@@ -1,12 +1,13 @@
 <?php
 /**
  * @file
- * 
+ * Adds to the tripal schema description.
+ *
  * This file contains hooks for specifying the natural diversity tables
  * when Chado v1.11 is installed.  This is only useful for some specific
  * sites that required the ND tables before they were released.  These
  * files should not be needed for most sites as the ND tables are now part
- * of Chado v1.2. However these hooks remain here for backwards compatibility. 
+ * of Chado v1.2. However these hooks remain here for backwards compatibility.
  */
 
 /**

+ 12 - 1
tripal_natural_diversity/tripal_natural_diversity.install

@@ -5,7 +5,10 @@
  */
 
 /**
+ * Implements hook_disable().
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_natural_diversity
  */
 function tripal_natural_diversity_disable() {
 
@@ -20,6 +23,8 @@ function tripal_natural_diversity_disable() {
 
 /**
  * Implementation of hook_requirements().
+ *
+ * @ingroup tripal_natural_diversity
  */
 function tripal_natural_diversity_requirements($phase) {
   $requirements = array();
@@ -38,6 +43,8 @@ function tripal_natural_diversity_requirements($phase) {
 
 /**
  * Implementation of hook_install().
+ *
+ * @ingroup tripal_natural_diversity
  */
 function tripal_natural_diversity_install() {
 
@@ -51,13 +58,17 @@ function tripal_natural_diversity_install() {
 
 /**
  * Implementation of hook_uninstall().
+ *
+ * @ingroup tripal_natural_diversity
  */
 function tripal_natural_diversity_uninstall() {
 
 }
 
-/*
+/**
+ * Add cvterms related to natural diversity
  *
+ * @ingroup tripal_natural_diversity
  */
 function tripal_natural_diversity_add_cvterms(){
 

+ 25 - 7
tripal_natural_diversity/tripal_natural_diversity.module

@@ -1,9 +1,16 @@
 <?php
+/**
+ * @file
+ * Basic function for the natural diversity module
+ */
+
+require_once 'api/tripal_natural_diversity.api.inc';
+
+require_once 'theme/tripal_natural_diversity.theme.inc';
+
+require_once 'includes/tripal_natural_diversity.schema.inc';
+require_once 'includes/tripal_natural_diversity.admin.inc';
 
-require_once('api/tripal_natural_diversity.api.inc');
-require_once('theme/tripal_natural_diversity.theme.inc');
-require_once('includes/tripal_natural_diversity.schema.inc');
-require_once('includes/tripal_natural_diversity.admin.inc');
 /**
  * @defgroup tripal_natural_diversity Natural Diversity Module
  * @ingroup tripal_modules
@@ -28,7 +35,10 @@ function tripal_natural_diversity_permission() {
     ),
   );
 }
+
 /**
+ *  Implements hook_menu().
+ *
  *  Menu items are automatically added for the new node types created
  *  by this module to the 'Create Content' Navigation menu item.  This function
  *  adds more menu items needed for this module.
@@ -69,8 +79,9 @@ function tripal_natural_diversity_menu() {
 }
 
 /**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
+ * Implements hook_views_api().
+ *
+ * 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
  *
@@ -83,7 +94,7 @@ function tripal_natural_diversity_views_api() {
 }
 
 /**
- * Implements hook_theme
+ * Implements hook_theme().
  *
  * @ingroup tripal_natural_diversity
  */
@@ -118,6 +129,8 @@ function tripal_natural_diversity_theme($existing, $type, $theme, $path) {
 }
 
 /**
+ * Implements hook_block_info().
+ *
  * @ingroup tripal_library
  */
 function tripal_natural_diversity_block_info() {
@@ -133,7 +146,10 @@ function tripal_natural_diversity_block_info() {
 
   return $blocks;
 }
+
 /**
+ * Implements hook_block_view().
+ *
  * @ingroup tripal_library
  */
 function tripal_natural_diversity_block_view($delta = '') {
@@ -161,7 +177,9 @@ function tripal_natural_diversity_block_view($delta = '') {
     return $block;
   }
 }
+
 /**
+ * Implements hook_node_view(). Acts on all content types.
  *
  * @ingroup tripal_natural_diversity
  */

+ 30 - 2
tripal_natural_diversity/tripal_natural_diversity.views_default.inc

@@ -1,6 +1,14 @@
 <?php
+/**
+ * @file
+ * Describes default natural diversity views
+ */
 
-
+/**
+ * Implements hook_views_default_views().
+ *
+ * @ingroup tripal_natural_diversity
+ */
 function tripal_natural_diversity_views_default_views() {
   $views = array();
 
@@ -23,6 +31,11 @@ function tripal_natural_diversity_views_default_views() {
   return $views;
 }
 
+/**
+ * Describes the default experiment administration view
+ *
+ * @ingroup tripal_natural_diversity
+ */
 function tripal_natural_diversity_defaultview_admin_natdiv_exp() {
 
   $view = new view();
@@ -140,6 +153,11 @@ function tripal_natural_diversity_defaultview_admin_natdiv_exp() {
   return $view;
 }
 
+/**
+ * Describes the default geological locations administration view
+ *
+ * @ingroup tripal_natural_diversity
+ */
 function tripal_natural_diversity_defaultview_admin_geolocations() {
 
   $view = new view();
@@ -309,6 +327,11 @@ function tripal_natural_diversity_defaultview_admin_geolocations() {
   return $view;
 }
 
+/**
+ * Describes the default reagents administration view
+ *
+ * @ingroup tripal_natural_diversity
+ */
 function tripal_natural_diversity_defaultview_admin_reagents() {
 
   $view = new view();
@@ -411,6 +434,11 @@ function tripal_natural_diversity_defaultview_admin_reagents() {
   return $view;
 }
 
+/**
+ * Describes the default protocols administration view
+ *
+ * @ingroup tripal_natural_diversity
+ */
 function tripal_natural_diversity_defaultview_admin_protocols() {
 
   $view = new view();
@@ -484,4 +512,4 @@ function tripal_natural_diversity_defaultview_admin_protocols() {
   $handler->display->display_options['menu']['context_only_inline'] = 0;
 
   return $view;
-}
+}

+ 29 - 8
tripal_organism/api/tripal_organism.api.inc

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Provides an application programming interface (API) to manage organisms
+ */
 
 /**
  * @defgroup tripal_organism_api Organism API
@@ -9,22 +13,28 @@
  */
 
 /**
- * Purpose: Return a given organism object using the nid
+ * Return a given organism object using the nid
  *
- * @return organism object created by node load
+ * @param $nid
+ *  The node id (nid) of the organism node of interest
+ *
+ * @return
+ *  organism object created by node load
  *
  * @ingroup tripal_organism_api
  */
 function tripal_organism_get_organism_by_nid($nid) {
-
   return node_load($nid);
-
 }
 
 /**
- * Purpose: Return a given organism object using the organism id
+ * Return a given organism object using the organism id
  *
- * @return organism object created by node load
+ * @param $organism_id
+ *   The chado organism.organism_id of the organism of interest
+ *
+ * @return
+ *   organism object created by node load
  *
  * @ingroup tripal_organism_api
  */
@@ -44,7 +54,11 @@ function tripal_organism_get_organism_by_organism_id($organism_id) {
 }
 
 /**
- *  Returns a list of organisms that are currently synced with Drupal
+ * Returns a list of organisms that are currently synced with Drupal
+ *
+ * @return
+ *   An array of organisms sync'd with Drupal where each value is an organism table record
+ *
  * @ingroup tripal_organism_api
  */
 function tripal_organism_get_synced() {
@@ -65,13 +79,20 @@ function tripal_organism_get_synced() {
     $org = chado_query($csql, $args)->fetchObject();
     $org_list[] = $org;
   }
+
   return $org_list;
 }
 
 /**
+ * Return the URL for the organism image
  *
  * @param $organism
+ *   An organism table record
  * @param $nid
+ *   (Optional) the node id of the organism node. if not supplied it will be looked up
+ *
+ * @return
+ *   The fully qualified url to the image
  */
 function tripal_organism_get_image_url($organism, $nid = NULL) {
   $url = '';
@@ -94,4 +115,4 @@ function tripal_organism_get_image_url($organism, $nid = NULL) {
      }
   }
   return $url;
-}
+}

+ 20 - 1
tripal_organism/includes/tripal_organism.admin.inc

@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Administration of organisms
+ */
 
 /**
+ * Admin launchpad
  *
+ * @ingroup tripal_organism
  */
 function tripal_organism_admin_organism_view() {
   $output = '';
@@ -51,6 +57,7 @@ function tripal_organism_admin() {
 
 
 /**
+ * Validate the organism settings form
  *
  * @ingroup tripal_organism
  */
@@ -93,8 +100,13 @@ function tripal_organism_admin_validate($form, &$form_state) {
   }
 }
 
-
 /**
+ * Add a job to reindex the features associated with an organism for drupal search
+ *
+ * @param $organism_id
+ *  The organism_id of the organism to re-index features of
+ * @param $job_id
+ *  (optional) specify a tripal job_id to create
  *
  * @ingroup tripal_organism
  */
@@ -129,7 +141,14 @@ function tripal_organism_reindex_features($organism_id = NULL, $job_id = NULL) {
     $i++;
   }
 }
+
 /**
+ * Add a tripal job to add drupal taxonomy to organisms
+ *
+ * @param $organism_id
+ *  The organism_id of the organism to add taxonomy to
+ * @param $job_id
+ *  (optional) specify a tripal job_id to create
  *
  * @ingroup tripal_organism
  */

+ 144 - 115
tripal_organism/includes/tripal_organism.chado_node.inc

@@ -1,6 +1,13 @@
 <?php
 /**
- *  Provide information to drupal about the node types that we're creating
+ * @file
+ * Implements the organims node content type
+ */
+
+/**
+ *  Implements hook_node_info().
+ *
+ * Provide information to drupal about the node types that we're creating
  *  in this module
  *
  * @ingroup tripal_organism
@@ -30,8 +37,9 @@ function tripal_organism_node_info() {
   );
   return $nodes;
 }
+
 /**
- * Implement hook_access().
+ * Implement hook_node_access().
  *
  * This hook allows node modules to limit access to the node types they define.
  *
@@ -78,14 +86,124 @@ function chado_organism_node_access($node, $op, $account) {
   }
   return NULL;
 }
+
 /**
- * Implementation of hook_validate
+ *  Implement hook_form().
+ *
+ *  When editing or creating a new node of type 'chado_organism' we need
+ *  a form.  This function creates the form that will be used for this.
+ *
+ * @ingroup tripal_organism
+ */
+function chado_organism_form($node, $form_state) {
+  $form = array();
+
+  // we have a file upload element on the form soe we need the multipart encoding type
+  $form['#attributes']['enctype'] = 'multipart/form-data';
+
+  // if the organism is part of the node object then we are editing. If not we are inserting
+  if (property_exists($node, 'organism')) {
+    $organism = $node->organism;
+
+    // add in the comment since it is a text field and may not be included if too big
+    $organism = chado_expand_var($organism, 'field', 'organism.comment');
+
+    // get form defaults
+    $abbreviation   = property_exists($node, 'abbreviation')   ? property_exists($node, 'abbreviation')   : $organism->abbreviation;
+    $genus          = property_exists($node, 'genus')          ? property_exists($node, 'genus')          : $organism->genus;
+    $species        = property_exists($node, 'species')        ? property_exists($node, 'species')        : $organism->species;
+    $common_name    = property_exists($node, 'common_name')    ? property_exists($node, 'common_name')    : $organism->common_name;
+    $description    = property_exists($node, 'description')    ? property_exists($node, 'description')    : $organism->comment;
+    $organism_image = property_exists($node, 'organism_image') ? property_exists($node, 'organism_image') : '';
+
+    // set the organism_id in the form
+    $form['organism_id'] = array(
+      '#type' => 'value',
+      '#value' => $organism->organism_id,
+    );
+    $organism_id = $organism->organism_id;
+  }
+  else {
+    // get form defaults
+    $abbreviation   = property_exists($node, 'abbreviation')   ? property_exists($node, 'abbreviation')   : '';
+    $genus          = property_exists($node, 'genus')          ? property_exists($node, 'genus')          : '';
+    $species        = property_exists($node, 'species')        ? property_exists($node, 'species')        : '';
+    $common_name    = property_exists($node, 'common_name')    ? property_exists($node, 'common_name')    : '';
+    $description    = property_exists($node, 'description')    ? property_exists($node, 'description')    : '';
+    $organism_image = property_exists($node, 'organism_image') ? property_exists($node, 'organism_image') : '';
+
+    $organism_id = NULL;
+  }
+
+  $form['genus']= array(
+    '#type' => 'textfield',
+    '#title' => t('Genus'),
+    '#required' => TRUE,
+    '#default_value' => $genus,
+  );
+  $form['species']= array(
+    '#type' => 'textfield',
+    '#title' => t('Species'),
+    '#required' => TRUE,
+    '#default_value' => $species,
+  );
+  $form['abbreviation']= array(
+    '#type' => 'textfield',
+    '#title' => t('Abbreviation'),
+    '#required' => TRUE,
+    '#default_value' => $abbreviation,
+  );
+  $form['common_name']= array(
+    '#type' => 'textfield',
+    '#title' => t('Common Name'),
+    '#required' => TRUE,
+    '#default_value' => $common_name,
+  );
+  $form['description']= array(
+    '#type' => 'textarea',
+    '#rows' => 15,
+    '#title' => t('Description'),
+    '#default_value' => $description,
+  );
+  $form['organism_image']= array(
+    '#type' => 'file',
+    '#title' => t('Organism Image'),
+    '#description' => 'Add an image for this organism',
+    '#progress_indicator' => 'bar',
+  );
+
+  // PROPERTIES FORM
+  //---------------------------------------------
+  $details = array(
+    'property_table' => 'organismprop',      // the name of the prop table
+    'base_foreign_key' => 'organism_id',     // the name of the key in your base chado table
+    'base_key_value' => $organism_id,        // the value of organism_id for this record
+    'cv_name' => 'organism_property'         // the cv.name of the cv governing organismprop.type_id
+  );
+  // Adds the form elements to your current form
+  chado_add_node_form_properties($form, $form_state, $details);
+
+  // ADDITIONAL DBXREFS FORM
+  //---------------------------------------------
+  $details = array(
+    'linking_table' => 'organism_dbxref',  // the name of the _dbxref table
+    'base_foreign_key' => 'organism_id',   // the name of the key in your base chado table
+    'base_key_value' => $organism_id       // the value of organism_id for this record
+  );
+  // Adds the form elements to your current form
+  chado_add_node_form_dbxrefs($form, $form_state, $details);
+
+  return $form;
+}
+
+/**
+ * Implementation of hook_validate().
  *
  * @param $node
  * @param $form
  * @param $form_state
  *
- *  @ingroup tripal_organism
+ * @ingroup tripal_organism
  */
 function chado_organism_validate($node, $form, &$form_state) {
   // remove any white space around values
@@ -143,7 +261,10 @@ function chado_organism_validate($node, $form, &$form_state) {
     }
   }
 }
+
 /**
+ *  Implements hook_insert().
+ *
  *  When a new chado_organism node is created we also need to add information
  *  to our chado_organism table.  This function is called on insert of a new node
  *  of type 'chado_organism' and inserts the necessary information.
@@ -216,8 +337,9 @@ function chado_organism_insert($node) {
   // add the image
   chado_organism_add_image($node);
 }
+
 /**
- * Update organisms
+ * Implements hook_update().
  *
  * @ingroup tripal_organism
  */
@@ -267,7 +389,10 @@ function chado_organism_update($node) {
   );
   chado_update_node_form_dbxrefs($node, $details);
 }
+
 /**
+ * Implements hook_delete().
+ *
  * Delete organism from both drupal and chado databases. Check dependency before
  * deleting from chado.
  *
@@ -309,7 +434,12 @@ function chado_organism_delete($node) {
 }
 
 /**
+ * Add an image to an organims node
+ *
+ * @param $node
+ *   The node to add an image to
  *
+ * The file is specified in the $_FILES array created by Drupal
  *
  * @ingroup tripal_organism
  */
@@ -337,115 +467,9 @@ function chado_organism_add_image($node) {
   }
 }
 
-
 /**
- *  When editing or creating a new node of type 'chado_organism' we need
- *  a form.  This function creates the form that will be used for this.
+ *  Implements hook_load().
  *
- * @ingroup tripal_organism
- */
-function chado_organism_form($node, $form_state) {
-  $form = array();
-
-  // we have a file upload element on the form soe we need the multipart encoding type
-  $form['#attributes']['enctype'] = 'multipart/form-data';
-
-  // if the organism is part of the node object then we are editing. If not we are inserting
-  if (property_exists($node, 'organism')) {
-    $organism = $node->organism;
-
-    // add in the comment since it is a text field and may not be included if too big
-    $organism = chado_expand_var($organism, 'field', 'organism.comment');
-
-    // get form defaults
-    $abbreviation   = property_exists($node, 'abbreviation')   ? property_exists($node, 'abbreviation')   : $organism->abbreviation;
-    $genus          = property_exists($node, 'genus')          ? property_exists($node, 'genus')          : $organism->genus;
-    $species        = property_exists($node, 'species')        ? property_exists($node, 'species')        : $organism->species;
-    $common_name    = property_exists($node, 'common_name')    ? property_exists($node, 'common_name')    : $organism->common_name;
-    $description    = property_exists($node, 'description')    ? property_exists($node, 'description')    : $organism->comment;
-    $organism_image = property_exists($node, 'organism_image') ? property_exists($node, 'organism_image') : '';
-
-    // set the organism_id in the form
-    $form['organism_id'] = array(
-      '#type' => 'value',
-      '#value' => $organism->organism_id,
-    );
-    $organism_id = $organism->organism_id;
-  }
-  else {
-    // get form defaults
-    $abbreviation   = property_exists($node, 'abbreviation')   ? property_exists($node, 'abbreviation')   : '';
-    $genus          = property_exists($node, 'genus')          ? property_exists($node, 'genus')          : '';
-    $species        = property_exists($node, 'species')        ? property_exists($node, 'species')        : '';
-    $common_name    = property_exists($node, 'common_name')    ? property_exists($node, 'common_name')    : '';
-    $description    = property_exists($node, 'description')    ? property_exists($node, 'description')    : '';
-    $organism_image = property_exists($node, 'organism_image') ? property_exists($node, 'organism_image') : '';
-
-    $organism_id = NULL;
-  }
-
-  $form['genus']= array(
-    '#type' => 'textfield',
-    '#title' => t('Genus'),
-    '#required' => TRUE,
-    '#default_value' => $genus,
-  );
-  $form['species']= array(
-    '#type' => 'textfield',
-    '#title' => t('Species'),
-    '#required' => TRUE,
-    '#default_value' => $species,
-  );
-  $form['abbreviation']= array(
-    '#type' => 'textfield',
-    '#title' => t('Abbreviation'),
-    '#required' => TRUE,
-    '#default_value' => $abbreviation,
-  );
-  $form['common_name']= array(
-    '#type' => 'textfield',
-    '#title' => t('Common Name'),
-    '#required' => TRUE,
-    '#default_value' => $common_name,
-  );
-  $form['description']= array(
-    '#type' => 'textarea',
-    '#rows' => 15,
-    '#title' => t('Description'),
-    '#default_value' => $description,
-  );
-  $form['organism_image']= array(
-    '#type' => 'file',
-    '#title' => t('Organism Image'),
-    '#description' => 'Add an image for this organism',
-    '#progress_indicator' => 'bar',
-  );
-
-  // PROPERTIES FORM
-  //---------------------------------------------
-  $details = array(
-    'property_table' => 'organismprop',      // the name of the prop table
-    'base_foreign_key' => 'organism_id',     // the name of the key in your base chado table
-    'base_key_value' => $organism_id,        // the value of organism_id for this record
-    'cv_name' => 'organism_property'         // the cv.name of the cv governing organismprop.type_id
-  );
-  // Adds the form elements to your current form
-  chado_add_node_form_properties($form, $form_state, $details);
-
-  // ADDITIONAL DBXREFS FORM
-  //---------------------------------------------
-  $details = array(
-    'linking_table' => 'organism_dbxref',  // the name of the _dbxref table
-    'base_foreign_key' => 'organism_id',   // the name of the key in your base chado table
-    'base_key_value' => $organism_id       // the value of organism_id for this record
-  );
-  // Adds the form elements to your current form
-  chado_add_node_form_dbxrefs($form, $form_state, $details);
-
-  return $form;
-}
-
-/**
  *  When a node is requested by the user this function is called to allow us
  *  to add auxiliary data to the node object.
  *
@@ -469,11 +493,14 @@ function chado_organism_load($nodes) {
 }
 
 /**
+ * Implements hook_node_presave(). Acts on all content types.
  *
  * @param $node
+ *  The node to be saved
+ *
+ * @ingroup tripal_organism
  */
 function tripal_organism_node_presave($node) {
- print_r($node->organism);
   switch ($node->type) {
     case 'chado_organism':
       // for a form submission the 'genus' field will be set,
@@ -489,9 +516,11 @@ function tripal_organism_node_presave($node) {
       break;
   }
 }
+
 /**
+ * Implements hook_node_view().
  *
- * @ingroup tripal_feature
+ * @ingroup tripal_organism
  */
 function tripal_organism_node_view($node, $view_mode, $langcode) {
   switch ($node->type) {
@@ -522,4 +551,4 @@ function tripal_organism_node_view($node, $view_mode, $langcode) {
       }
       break;
   }
-}
+}

+ 11 - 3
tripal_organism/tripal_organism.install

@@ -1,12 +1,14 @@
 <?php
-
 /**
  * @file
  * Functions pertaining to the install/uninstall of this module
  */
 
 /**
+ * Implements hook_disable().
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_organism
  */
 function tripal_organism_disable() {
 
@@ -87,6 +89,7 @@ function tripal_organism_uninstall() {
 /**
  * Implementation of hook_requirements().
  *
+ * @ingroup tripal_organism
  */
 function tripal_organism_requirements($phase) {
   $requirements = array();
@@ -104,15 +107,18 @@ function tripal_organism_requirements($phase) {
 }
 
 /**
+ * Add cvterms related to organisms
  *
+ * @ingroup tripal_organism
  */
 function tripal_organism_add_cvs() {
-
   tripal_cv_add_cv('organism_property', 'Contains properties for organisms');
-
 }
+
 /**
+ * Add cvterms pertaining to organisms
  *
+ * @ingroup tripal_organism
  */
 function tripal_organism_add_cvterms() {
 
@@ -120,6 +126,8 @@ function tripal_organism_add_cvterms() {
 
 /**
  * This is the required update for tripal_organism when upgrading from Drupal core API 6.x.
+ *
+ * @ingroup tripal_organism
  */
 function tripal_organism_update_7000() {
 

+ 32 - 22
tripal_organism/tripal_organism.module

@@ -1,8 +1,13 @@
 <?php
+/**
+ * @file
+ * Integrates the Chado Organism module with Drupal Nodes & Views
+ */
+
+require_once 'api/tripal_organism.api.inc';
 
-require_once "api/tripal_organism.api.inc";
-require_once "includes/tripal_organism.admin.inc";
-require_once "includes/tripal_organism.chado_node.inc";
+require_once 'includes/tripal_organism.admin.inc';
+require_once 'includes/tripal_organism.chado_node.inc';
 
 /**
  * @defgroup tripal_organism Organism Module
@@ -13,16 +18,7 @@ require_once "includes/tripal_organism.chado_node.inc";
  */
 
 /**
- *
- * @ingroup tripal_organism
- */
-function tripal_organism_init() {
-
-}
-
-
-
-/**
+ * Implements hook_block_info().
  *
  * @ingroup tripal_organism
  */
@@ -34,7 +30,9 @@ function tripal_organism_block_info() {
   return $blocks;
 
 }
+
 /**
+ * Implements hook_block_view().
  *
  * @ingroup tripal_organism
  */
@@ -55,8 +53,11 @@ function tripal_organism_block_view($delta = '') {
     return $block;
   }
 }
+
 /**
- *  Menu items are automatically added for the new node types created
+ *  Implements hook_menu().
+ *
+ * Menu items are automatically added for the new node types created
  *  by this module to the 'Create Content' Navigation menu item.  This function
  *  adds more menu items needed for this module.
  *
@@ -117,8 +118,10 @@ function tripal_organism_menu() {
 }
 
 /**
- * Implements hook_help()
- * Purpose: Adds a help page to the module list
+ * Implements hook_help().
+ * Adds a help page to the module list
+ *
+ * @ingroup tripal_organism
  */
 function tripal_organism_help ($path, $arg) {
   if ($path == 'admin/help#tripal_organism') {
@@ -127,6 +130,8 @@ function tripal_organism_help ($path, $arg) {
 }
 
 /**
+ *  Implements hook_theme().
+ *
  *  We need to let drupal know about our theme functions and their arguments.
  *  We create theme functions to allow users of the module to customize the
  *  look and feel of the output generated in this module
@@ -205,9 +210,11 @@ function tripal_organism_permission() {
     ),
   );
 }
+
 /**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
+ * Implements hook_views_api().
+ *
+ * Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_db.views.inc where all the
  *  views integration code is
  *
@@ -215,11 +222,12 @@ function tripal_organism_permission() {
  */
 function tripal_organism_views_api() {
   return array(
-    'api' => 2.0,
+    'api' => 3.0,
   );
 }
+
 /**
- *
+ * Implements hook_job_describe_args().
  *
  * @ingroup tripal_organism
  */
@@ -235,15 +243,17 @@ function tripal_organism_job_describe_args($callback, $args) {
 
 
 /**
- * Implementation of hook_form_alter()
+ * Implementation of hook_form_alter().
  *
  * @param $form
  * @param $form_state
  * @param $form_id
+ *
+ * @ingroup tripal_organism
  */
 function tripal_organism_form_alter(&$form, &$form_state, $form_id) {
   // turn of preview button for insert/updates
   if ($form_id == "chado_organism_node_form") {
     $form['actions']['preview']['#access'] = FALSE;
   }
-}
+}

+ 12 - 2
tripal_organism/tripal_organism.views_default.inc

@@ -1,8 +1,13 @@
 <?php
+/**
+ * @file
+ * Organism default views
+ */
 
 /**
+ * Implements hook_views_default_views().
  *
- *
+ * @ingroup tripal_organism
  */
 function tripal_organism_views_default_views() {
   $views = array();
@@ -13,6 +18,11 @@ function tripal_organism_views_default_views() {
   return $views;
 }
 
+/**
+ * Describe the organism administration view.
+ *
+ * @ingroup tripal_organism
+ */
 function tripal_organism_admin_defaultview_organisms() {
 
   $view = new view();
@@ -206,4 +216,4 @@ function tripal_organism_admin_defaultview_organisms() {
   */
 
   return $view;
-}
+}

+ 7 - 0
tripal_phenotype/tripal_phenotype.install

@@ -1,7 +1,14 @@
 <?php
+/**
+ * @file
+ * Installation of the phenotype module
+ */
 
 /**
+ * Implements hook_disable().
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_phenotype
  */
 function tripal_phenotype_disable() {
 

+ 18 - 3
tripal_phenotype/tripal_phenotype.module

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Basic functionality for the phenotype module
+ */
 
 /**
  * @defgroup tripal_phenotype Phenotype Module
@@ -26,6 +30,8 @@ function tripal_phenotype_permission() {
 }
 
 /**
+ *  Implements hook_menu().
+ *
  *  Menu items are automatically added for the new node types created
  *  by this module to the 'Create Content' Navigation menu item.  This function
  *  adds more menu items needed for this module.
@@ -65,6 +71,8 @@ function tripal_phenotype_menu() {
 }
 
 /**
+ *  Implements hook_theme().
+ *
  *  We need to let drupal know about our theme functions and their arguments.
  *  We create theme functions to allow users of the module to customize the
  *  look and feel of the output generated in this module
@@ -90,8 +98,9 @@ function tripal_phenotype_theme($existing, $type, $theme, $path) {
 }
 
 /**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
+ * Implements hook_views_api().
+ *
+ * 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
  *
@@ -103,6 +112,11 @@ function tripal_phenotype_views_api() {
   );
 }
 
+/**
+ * Admin Launchpad
+ *
+ * @ingroup tripal_phenotype
+ */
 function tripal_phenotype_admin_phenotypes_listing() {
   $output = '';
 
@@ -134,6 +148,7 @@ function tripal_phenotype_admin_phenotypes_listing() {
 }
 
 /**
+ * Implements hook_node_view().
  *
  * @ingroup tripal_phenotype
  */
@@ -150,4 +165,4 @@ function tripal_phenotype_node_view($node, $view_mode, $langcode) {
       }
       break;
   }
-}
+}

+ 12 - 2
tripal_phenotype/tripal_phenotype.views_default.inc

@@ -1,8 +1,13 @@
 <?php
+/**
+ * @file
+ * Describe phenotype default views
+ */
 
 /**
+ * Implements hook_views_default_views().
  *
- *
+ * @ingroup tripal_phenotype
  */
 function tripal_phenotype_views_default_views() {
   $views = array();
@@ -13,6 +18,11 @@ function tripal_phenotype_views_default_views() {
   return $views;
 }
 
+/**
+ * Default phenotype administration view
+ *
+ * @ingroup tripal_phenotype
+ */
 function tripal_phenotype_defaultview_admin_phenotypes() {
 
   $view = new view();
@@ -196,4 +206,4 @@ function tripal_phenotype_defaultview_admin_phenotypes() {
   $handler->display->display_options['tab_options']['weight'] = '0';
 
   return $view;
-}
+}

+ 9 - 5
tripal_project/includes/tripal_project.admin.inc

@@ -1,11 +1,13 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Administration of projects
  */
 
 /**
+ * Admin launchpad
  *
+ * @ingroup tripal_project
  */
 function tripal_project_admin_project_view() {
   $output = '';
@@ -37,10 +39,11 @@ function tripal_project_admin_project_view() {
   return $output;
 }
 /**
- * 
- * @param $form_state
+ * Project settings
+ *
+ * @ingroup tripal_project
  */
-function tripal_project_admin($form_state) {
+function tripal_project_admin($form, $form_state) {
   $form = array();
 
   $form['nothing'] = array(
@@ -51,9 +54,10 @@ function tripal_project_admin($form_state) {
 }
 
 /**
+ * Validate project settings
  *
  * @ingroup tripal_project
  */
 function tripal_project_admin_validate($form, &$form_state) {
 
-}
+}

+ 17 - 16
tripal_project/includes/tripal_project.chado_node.inc

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Implement the project node content type
+ */
 
 /**
  * Implementation of hook_node_info().
@@ -7,7 +11,6 @@
  * that the title(Project Name) and body(Description) set to true so that they information can be
  * entered
  *
- *
  * @ingroup tripal_project
  */
 function tripal_project_node_info() {
@@ -35,6 +38,7 @@ function tripal_project_node_info() {
     ),
   );
 }
+
 /**
  * Implementation of hook_form().
  *
@@ -188,8 +192,10 @@ function chado_project_form(&$node, $form_state) {
   return $form;
 
 }
+
 /**
- *  validates submission of form when adding or updating a project node
+ * Implements hook_validate().
+ * Validates submission of form when adding or updating a project node
  *
  * @ingroup tripal_project
  */
@@ -224,13 +230,13 @@ function chado_project_validate($node, $form, &$form_state) {
     form_set_error('title', t('The unique project name already exists. Please choose another'));
   }
 }
+
 /**
  * Implementation of hook_insert().
  *
  *  @parm $node
  *    Then node that has the information stored within, accessed given the nid
  *
- *
  * @ingroup tripal_project
  */
 function chado_project_insert($node) {
@@ -294,13 +300,11 @@ 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
- * since the drupal node is deleted automagically
- *
+ *  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
  *
  * @ingroup tripal_project
  */
@@ -335,7 +339,6 @@ function chado_project_delete($node) {
  *  The node which is to have its containing information updated when the user modifies information
  *  pertaining to the specific project
  *
- *
  * @ingroup tripal_project
  */
 function chado_project_update($node) {
@@ -380,15 +383,11 @@ function chado_project_update($node) {
 }
 
 /**
- * Implementation of node_load().
+ * Implementation of hook_load().
  *
  * @param $node
  *   The node that is to have its containing information loaded
  *
- * @return $node
- *   The node, containing the loaded project with the current nid
- *
- *
  * @ingroup tripal_project
  */
 function chado_project_load($nodes) {
@@ -406,7 +405,7 @@ function chado_project_load($nodes) {
 }
 
 /**
- * Implement hook_access().
+ * Implement hook_node_access().
  *
  * This hook allows node modules to limit access to the node types they define.
  *
@@ -454,9 +453,11 @@ function chado_project_node_access($node, $op, $account) {
   }
   return NULL;
 }
+
 /**
+ * Implements hook_node_view().
  *
- * @ingroup tripal_feature
+ * @ingroup tripal_project
  */
 function tripal_project_node_view($node, $view_mode, $langcode) {
   switch ($node->type) {
@@ -497,4 +498,4 @@ function tripal_project_node_view($node, $view_mode, $langcode) {
       }
       break;
   }
-}
+}

+ 20 - 8
tripal_project/tripal_project.install

@@ -1,17 +1,14 @@
 <?php
-
 /**
  * @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.
- *
- * 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
+ * Install the tripal project
  */
 
 /**
+ * Implements hook_disable().
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_project
  */
 function tripal_project_disable() {
 
@@ -27,6 +24,7 @@ function tripal_project_disable() {
 /**
  * Implementation of hook_requirements().
  *
+ * @ingroup tripal_project
  */
 function tripal_project_requirements($phase) {
   $requirements = array();
@@ -42,8 +40,11 @@ function tripal_project_requirements($phase) {
   }
   return $requirements;
 }
+
 /**
  * Implementation of hook_install().
+ *
+ * @ingroup tripal_project
  */
 function tripal_project_install() {
 
@@ -56,6 +57,8 @@ function tripal_project_install() {
 
 /**
  * Implementation of hook_uninstall().
+ *
+ * @ingroup tripal_project
  */
 function tripal_project_uninstall() {
 
@@ -63,6 +66,8 @@ function tripal_project_uninstall() {
 
 /**
  * Implementation of hook_schema().
+ *
+ * @ingroup tripal_project
  */
 function tripal_project_schema() {
   $schema['chado_project'] = array(
@@ -88,7 +93,9 @@ function tripal_project_schema() {
 }
 
 /**
+ * Add cvs pertaining to projects
  *
+ * @ingroup tripal_project
  */
 function tripal_project_add_cvs() {
   tripal_cv_add_cv('project_property', 'Contains properties for projects');
@@ -99,8 +106,11 @@ function tripal_project_add_cvs() {
     'Contains Types of relationships between projects.'
   );
 }
+
 /**
+ * Add cvterms pertaining to projects
  *
+ * @ingroup tripal_project
  */
 function tripal_project_add_cvterms() {
 
@@ -133,6 +143,8 @@ function tripal_project_add_cvterms() {
 
 /**
  * This is the required update for tripal_project when upgrading from Drupal core API 6.x.
+ *
+ * @ingroup tripal_project
  */
 function tripal_project_update_7000() {
 
@@ -156,4 +168,4 @@ function tripal_project_update_7000() {
 
   // add in new CVterms
   tripal_project_add_cvterms();
-}
+}

+ 29 - 17
tripal_project/tripal_project.module

@@ -1,8 +1,15 @@
 <?php
-require('api/tripal_project.api.inc');
-require('theme/tripal_project.theme.inc');
-require('includes/tripal_project.admin.inc');
-require('includes/tripal_project.chado_node.inc');
+/**
+ * @file
+ * Integrates the Chado Project tables with Drupal Nodes & Views
+ */
+
+require 'api/tripal_project.api.inc';
+
+require 'theme/tripal_project.theme.inc';
+
+require 'includes/tripal_project.admin.inc';
+require 'includes/tripal_project.chado_node.inc';
 
 /**
  * @defgroup tripal_project Project Module
@@ -13,23 +20,22 @@ require('includes/tripal_project.chado_node.inc');
  */
 
 /**
- * Implements hook_views_api()
+ * Implements hook_views_api().
  *
- * Purpose: Essentially this hook tells drupal that there is views support for
+ * Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_project.views.inc where all the
  *  views integration code is
  *
  * @ingroup tripal_project
- *
  */
 function tripal_project_views_api() {
   return array(
-      'api' => 2.0,
+      'api' => 3.0,
   );
 }
 
 /**
- * Implements hook_menu
+ * Implements hook_menu().
  *
  * @ingroup tripal_project
  */
@@ -83,8 +89,10 @@ function tripal_project_menu() {
 }
 
 /**
- * Implements hook_help()
- * Purpose: Adds a help page to the module list
+ * Implements hook_help().
+ * Adds a help page to the module list
+ *
+ * @ingroup tripal_project
  */
 function tripal_project_help ($path, $arg) {
   if ($path == 'admin/help#tripal_project') {
@@ -93,12 +101,11 @@ function tripal_project_help ($path, $arg) {
 }
 
 /**
- * Implements hook_perm()
+ * Implements hook_permission()
  *
  *  This function sets the permission for the user to access the information in the database.
  *  This includes creating, inserting, deleting and updating of information in the database
  *
- *
  * @ingroup tripal_project
  */
 function tripal_project_permission() {
@@ -126,9 +133,9 @@ function tripal_project_permission() {
   );
 }
 
-
-
 /**
+ *  Implements hook_theme().
+ *
  *  We need to let drupal know about our theme functions and their arguments.
  *  We create theme functions to allow users of the module to customize the
  *  look and feel of the output generated in this module
@@ -185,6 +192,7 @@ function tripal_project_theme($existing, $type, $theme, $path) {
 }
 
 /**
+ * Implements hook_block_info().
  *
  * @ingroup tripal_project
  */
@@ -207,7 +215,9 @@ function tripal_project_block_info() {
 
   return $blocks;
 }
+
 /**
+ * Implements hook_block_view().
  *
  * @ingroup tripal_project
  */
@@ -246,15 +256,17 @@ function tripal_project_block_view($delta = '') {
 }
 
 /**
- * Implementation of hook_form_alter()
+ * Implementation of hook_form_alter().
  *
  * @param $form
  * @param $form_state
  * @param $form_id
+ *
+ * @ingroup tripal_project
  */
 function tripal_project_form_alter(&$form, &$form_state, $form_id) {
   // turn of preview button for insert/updates
   if ($form_id == "chado_project_node_form") {
     $form['actions']['preview']['#access'] = FALSE;
   }
-}
+}

+ 12 - 3
tripal_project/tripal_project.views_default.inc

@@ -1,9 +1,13 @@
 <?php
+/**
+ * @file
+ * Project Default Views
+ */
 
 /**
+ * Implements hook_views_default_views().
  *
- *
- *
+ * @ingroup tripal_project
  */
 function tripal_project_views_default_views() {
   $views = array();
@@ -14,6 +18,11 @@ function tripal_project_views_default_views() {
   return $views;
 }
 
+/**
+ * Project administration view
+ *
+ * @ingroup tripal_project
+ */
 function tripal_project_defaultview_admin_projects() {
 
   $view = new view();
@@ -189,4 +198,4 @@ function tripal_project_defaultview_admin_projects() {
   $handler->display->display_options['tab_options']['weight'] = '0';
 
   return $view;
-}
+}

+ 78 - 15
tripal_pub/api/tripal_pub.api.inc

@@ -1,4 +1,9 @@
 <?php
+/**
+ * @file
+ * Provides an application programming interface (API) to manage chado publications
+ */
+
 /**
  * @defgroup tripal_pub_api Publication Module API
  * @ingroup tripal_api
@@ -7,7 +12,7 @@
  * @}
  */
 
-/*
+/**
  * Retrieves a list of publications as an associated array where
  *  keys correspond directly with Tripal Pub CV terms.
  *
@@ -61,7 +66,15 @@ function tripal_pub_get_remote_search_results($remote_db, $search_array, $num_to
   }
   return $pubs;
 }
-/*
+
+/**
+ * @stephen
+ *
+ * @param $dbxref
+ *
+ * @return
+ *
+ *
  * @ingroup tripal_pub_api
  */
 function tripal_pub_get_raw_data($dbxref) {
@@ -94,7 +107,14 @@ function tripal_pub_get_raw_data($dbxref) {
   }
   return 'Invalid DB xref';
 }
-/*
+
+/**
+ * @stephen
+ *
+ * @param $do_contact
+ * @param $dbxref
+ * @param $db
+ *
  * @ingroup tripal_pub_api
  */
 function tripal_pub_update_publications($do_contact = FALSE, $dbxref = NULL, $db = NULL) {
@@ -181,9 +201,14 @@ function tripal_pub_update_publications($do_contact = FALSE, $dbxref = NULL, $db
   }
   print "Done.\n";
 }
+
 /**
+ * @stephen
+ *
+ * @param $import_id
+ * @param $job_id
  *
- * @param $pub_importer_id
+ * @ingroup tripal_pub_api
  */
 function tripal_pub_import_publications_by_import_id($import_id, $job_id = NULL) {
   print "\nNOTE: Loading of publications is performed using a database transaction. \n" .
@@ -243,7 +268,13 @@ function tripal_pub_import_publications_by_import_id($import_id, $job_id = NULL)
   }
   print "Done.\n";
 }
-/*
+
+/**
+ * @stephen
+ *
+ * @param $report_email
+ * @param $do_update
+ *
  * @ingroup tripal_pub_api
  */
 function tripal_pub_import_publications($report_email = FALSE, $do_update = FALSE) {
@@ -331,7 +362,14 @@ function tripal_pub_import_publications($report_email = FALSE, $do_update = FALS
   }
   print "Done.\n";
 }
-/*
+
+/**
+ * @stephen
+ *
+ * @param $pub_dbxref
+ * @param $do_contact
+ * @param $do_update
+ *
  * @ingroup tripal_pub_api
  */
 function tripal_pub_import_by_dbxref($pub_dbxref, $do_contact = FALSE, $do_update) {
@@ -390,11 +428,17 @@ function tripal_pub_import_by_dbxref($pub_dbxref, $do_contact = FALSE, $do_updat
 
   print "Done.\n";
 }
+
 /**
+ * @stephen
  *
  * @param $pubs
  * @param $do_contact
  * @param $update
+ *
+ * @return
+ *
+ * @ingroup tripal_pub_api
  */
 function tripal_pub_add_publications($pubs, $do_contact, $update = FALSE) {
   $report = array();
@@ -439,8 +483,18 @@ function tripal_pub_add_publications($pubs, $do_contact, $update = FALSE) {
   print "\n";
   return $report;
 }
+
 /**
  * Adds a dbxref record to a publication
+ *
+ * @stephen
+ *
+ * @param $pub_id
+ * @param $pub_dbxref
+ *
+ * @return
+ *
+ * @ingroup tripal_pub_api
  */
 function tripal_pub_add_pub_dbxref($pub_id, $pub_dbxref) {
 
@@ -501,6 +555,7 @@ function tripal_pub_add_pub_dbxref($pub_id, $pub_dbxref) {
   }
   return $results;
 }
+
 /**
  * Returns the list of publications that are assigned the database
  * cross-reference provided
@@ -516,7 +571,6 @@ function tripal_pub_add_pub_dbxref($pub_id, $pub_dbxref) {
  *   is returned.
  *
  * @ingroup tripal_pub_api
- *
  */
 function tripal_pub_get_pubs_by_dbxref($pub_dbxref) {
 
@@ -542,6 +596,7 @@ function tripal_pub_get_pubs_by_dbxref($pub_dbxref) {
   }
   return $return;
 }
+
 /**
  * Returns the list of publications that match a given title, type and year
  *
@@ -550,7 +605,7 @@ function tripal_pub_get_pubs_by_dbxref($pub_dbxref) {
  * @param type
  *   Optional. The publication type. The value of this field should come from
  *   the Tripal Pub vocabulary. This should be the type name (e.g. cvterm.name)
- * @param year
+ * @param pyear
  *   Optional. The year the publication was published.
  * @param series_name
  *   Optional.  The name of the series (e.g. Journal name)
@@ -561,7 +616,6 @@ function tripal_pub_get_pubs_by_dbxref($pub_dbxref) {
  *   is returned.
  *
  * @ingroup tripal_pub_api
- *
  */
 function tripal_pub_get_pubs_by_title_type_pyear_series($title, $type = NULL, $pyear = NULL, $series_name = NULL) {
 
@@ -601,6 +655,7 @@ function tripal_pub_get_pubs_by_title_type_pyear_series($title, $type = NULL, $p
   }
   return $return;
 }
+
 /**
  * Returns the list of publications that match a given title, type and year
  *
@@ -620,7 +675,6 @@ function tripal_pub_get_pubs_by_title_type_pyear_series($title, $type = NULL, $p
  *   is returned.
  *
  * @ingroup tripal_pub_api
- *
  */
 function tripal_pub_get_pub_by_uniquename($name) {
 
@@ -642,6 +696,7 @@ function tripal_pub_get_pub_by_uniquename($name) {
   }
   return $return;
 }
+
 /**
  * Adds a new publication to the Chado, along with all properties and
  * database cross-references. If the publication does not already exist
@@ -670,6 +725,7 @@ function tripal_pub_get_pub_by_uniquename($name) {
  *   the $action variable is set to 'inserted'.  If the function failes then the
  *   $action variable is set to 'error'
  *
+ * @ingroup tripal_pub_api
  */
 function tripal_pub_add_publication($pub_details, &$action, $do_contact = FALSE, $update_if_exists = FALSE) {
   $pub_id = 0;
@@ -852,8 +908,14 @@ function tripal_pub_add_publication($pub_details, &$action, $do_contact = FALSE,
   return $pub_id;
 }
 
-/*
+/**
+ * @stephen
+ *
+ * @param $pub_id
+ * @param $authors
+ * @param $do_contact
  *
+ * @ingroup tripal_pub_api
  */
 function tripal_pub_add_authors($pub_id, $authors, $do_contact) {
   $rank = 0;
@@ -987,6 +1049,7 @@ function tripal_pub_insert_property($pub_id, $property, $value, $update_if_prese
 function tripal_pub_update_property($pub_id, $property, $value, $insert_if_missing = 0) {
   return chado_update_property('pub', $pub_id, $property, 'tripal_pub', $value, $insert_if_missing);
 }
+
 /**
  * Delete a given property
  *
@@ -1007,8 +1070,6 @@ function tripal_pub_delete_property($pub_id, $property) {
   return chado_delete_property('pub', $pub_id, $property, 'tripal_pub');
 }
 
-
-
 /**
  * This function generates an array suitable for use with the
  * tripal_pub_create_citation function for any publication
@@ -1024,8 +1085,9 @@ function tripal_pub_delete_property($pub_id, $property) {
  * @return
  *   An array suitable for the trpial_pub_create_citation function. On
  *   failure returns FALSE.
+ *
+ * @ingroup tripal_pub_api
  */
-
 function tripal_pub_get_publication_array($pub_id, $skip_existing = TRUE) {
 
   $options = array('return_array' => 1);
@@ -1197,7 +1259,6 @@ function tripal_pub_get_publication_array($pub_id, $skip_existing = TRUE) {
   return $pub_array;
 }
 
-
 /**
  * This function generates citations for publications.  It requires
  * an array structure with keys being the terms in the Tripal
@@ -1222,6 +1283,8 @@ function tripal_pub_get_publication_array($pub_id, $skip_existing = TRUE) {
  *
  * @return
  *   A text string containing the citation
+ *
+ * @ingroup tripal_pub_api
  */
 function tripal_pub_create_citation($pub) {
   $citation = '';

+ 94 - 18
tripal_pub/includes/importers/tripal_pub.AGL.inc

@@ -1,9 +1,23 @@
 <?php
 /**
+ * @file
+ * @stephen
+ */
+
+/**
+ * @stephen
+ *
+ * @param $form
+ * @param $form_state
+ * @param $num_criteria
+ *
+ * @return
+ *   The form (drupal form api)
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_remote_alter_form_AGL($form, $form_state, $num_criteria = 1) {
-  
+
   // So far we haven't been able to get AGL to filter results to only
   // include pubs by the XX number days in the past.  So, we will
   // change the 'days' element to be the year to query
@@ -16,8 +30,17 @@ function tripal_pub_remote_alter_form_AGL($form, $form_state, $num_criteria = 1)
   }
   return $form;
 }
+
 /**
+ * @stephen
+ *
+ * @param $form
+ * @param $form_state
  *
+ * @return
+ *  The form (drupal form api)
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_remote_validate_form_AGL($form, $form_state) {
   $days =  trim($form_state['values']["days"]);
@@ -43,8 +66,18 @@ function tripal_pub_remote_validate_form_AGL($form, $form_state) {
   }
   return $form;
 }
+
 /**
+ * @stephen
  *
+ * @param $search_array
+ * @param $num_to_retrieve
+ * @param $page
+ *
+ * @return
+ *
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $page) {
   // get some values from the serach array
@@ -324,7 +357,7 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $page) {
     "author"   => "u=1003",
     "abstract" => "u=62",
     "id"       => "u=12",
-    "year"     => "u=30 r=o", 
+    "year"     => "u=30 r=o",
     "journal"  => "u=1033"
   );
   yaz_ccl_conf($yazc, $fields);
@@ -339,10 +372,10 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $page) {
     );
   }
   $search_str = $cclresult["rpn"];
- 
-  // get the total number of records 
+
+  // get the total number of records
   $total_records = tripal_pub_AGL_count($yazc, $search_str);
-  
+
   // get the pubs in the specified rang
   $start = $page * $num_to_retrieve;
   $results = tripal_pub_AGL_range($yazc, $search_str, $start, $num_to_retrieve, $total_records);
@@ -352,8 +385,20 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $page) {
 
   return $results;
 }
+
 /**
- * 
+ * @stephen
+ *
+ * @param $yazc
+ * @param $search_str
+ * @param $start
+ * @param $num_to_retrieve
+ * @param $total_records
+ *
+ * @return
+ *
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_AGL_range($yazc, $search_str, $start, $num_to_retrieve, $total_records) {
   yaz_range($yazc, 1, $total_records);
@@ -376,7 +421,7 @@ function tripal_pub_AGL_range($yazc, $search_str, $start, $num_to_retrieve, $tot
   if ($start + $num_to_retrieve > $total_records) {
     $num_to_retrieve = $total_records - $start;
   }
-  
+
   $pubs = array();
   for($i = $start; $i < $start + $num_to_retrieve; $i++) {
     $pub_xml = yaz_record($yazc, $i + 1, 'xml; charset=marc-8,utf-8');
@@ -389,10 +434,20 @@ function tripal_pub_AGL_range($yazc, $search_str, $start, $num_to_retrieve, $tot
     'pubs'          => $pubs,
   );
 }
-/*
+
+/**
  * This function is used as the callback function when used with the
- * tripal_pager_callback function.  This function returns a count of
- * the dataset to be paged.
+ * tripal_pager_callback function.
+ *
+ * @stephen
+ *
+ * @param $yazc
+ * @param $search_str
+ *
+ * @return
+ * a count of the dataset to be paged.
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_AGL_count($yazc, $search_str) {
 
@@ -427,11 +482,19 @@ function tripal_pub_AGL_count($yazc, $search_str) {
   return $count;
 }
 
-
-/*
+/**
+ * Parse publication XML for a single publication
+ *
  * Description of XML format:
  * http://www.loc.gov/marc/bibliographic/bdsummary.html
  *
+ * @param $pub_xml
+ *  A string containing the XML for a single publications
+ *
+ * @return
+ *  An array containing the details of the publication
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_AGL_parse_pubxml($pub_xml) {
   $pub = array();
@@ -469,9 +532,9 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
           break;
         case '008':  // fixed length data elements
           $month = array(
-            '01' => 'Jan', '02' => 'Feb', '03' => 'Mar', 
-            '04' => 'Apr', '05' => 'May', '06' => 'Jun', 
-            '07' => 'Jul', '08' => 'Aug', '09' => 'Sep', 
+            '01' => 'Jan', '02' => 'Feb', '03' => 'Mar',
+            '04' => 'Apr', '05' => 'May', '06' => 'Jun',
+            '07' => 'Jul', '08' => 'Aug', '09' => 'Sep',
             '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'
             );
             $date0 = substr($value, 0, 6);  // date entered on file
@@ -809,7 +872,7 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
     $pub['Authors'] = $authors;
   }
   else {
-    $pub['Authors'] = $pub['Author List'];  
+    $pub['Authors'] = $pub['Author List'];
   }
 
   // build the citation
@@ -819,9 +882,15 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
   return $pub;
 }
 
-/*
+/**
+ * @stephen
+ *
+ * @param $xml
  *
+ * @return
  *
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_remote_search_AGL_get_subfield($xml) {
   $codes = array();
@@ -842,9 +911,16 @@ function tripal_pub_remote_search_AGL_get_subfield($xml) {
   return $codes;
 }
 
-/*
+/**
+ * @stephen
+ *
+ * @param $xml
+ * @param $ind1
+ *
+ * @return
  *
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_remote_search_AGL_get_author($xml, $ind1) {
   $author = array();

+ 120 - 13
tripal_pub/includes/importers/tripal_pub.PMID.inc

@@ -5,7 +5,13 @@
  */
 
 /**
+ * @stephen
  *
+ * @param $form
+ * @param $form_state
+ * @param $num_criteria
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_remote_alter_form_PMID($form, $form_state, $num_criteria = 1) {
   // PubMed doesn't have an 'Abstract' field, so we need to convert the criteria
@@ -18,7 +24,15 @@ function tripal_pub_remote_alter_form_PMID($form, $form_state, $num_criteria = 1
 }
 
 /**
+ * Validate the pub med form
+ *
+ * @param $form
+ * @param $form_state
  *
+ * @return
+ *   The form (drupal form api)
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_remote_validate_form_PMID($form, $form_state) {
   $num_criteria = $form_state['values']['num_criteria'];
@@ -32,8 +46,15 @@ function tripal_pub_remote_validate_form_PMID($form, $form_state) {
   }
   return $form;
 }
+
 /**
+ * @stephen
  *
+ * @param $search_array
+ * @param $num_to_retrieve
+ * @param $page
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_remote_search_PMID($search_array, $num_to_retrieve, $page) {
   // convert the terms list provicded by the caller into a string with words
@@ -144,8 +165,13 @@ function tripal_pub_remote_search_PMID($search_array, $num_to_retrieve, $page) {
   );
 }
 
-/*
+/**
+ * @stephen
  *
+ * @param $search_str
+ * @param $retmax
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_search_init($search_str, $retmax){
 
@@ -208,8 +234,18 @@ function tripal_pub_PMID_search_init($search_str, $retmax){
   return $result;
 }
 
-/*
+/**
+ * @stephen
+ *
+ * @param $query_key
+ * @param $web_env
+ * @param $rettype
+ * @param $retmod
+ * @param $start
+ * @param $limit
+ * @param $args
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_fetch($query_key, $web_env, $rettype = 'null',
 $retmod = 'null', $start = 0, $limit = 10, $args = array()){
@@ -267,6 +303,14 @@ $retmod = 'null', $start = 0, $limit = 10, $args = array()){
  *
  * Information about PubMed's citation format can be found here
  * http://www.nlm.nih.gov/bsd/policy/cit_format.html
+ *
+ * @param $pub_xml
+ *  An XML string describing a single publication
+ *
+ * @return
+ *  An array describing the publication
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_parse_pubxml($pub_xml) {
   $pub = array();
@@ -360,8 +404,13 @@ function tripal_pub_PMID_parse_pubxml($pub_xml) {
   return $pub;
 }
 
-/*
+/**
+ * @stephen
  *
+ * @param $xml
+ * @param $pub
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_parse_medline_journal_info($xml, &$pub) {
   while ($xml->read()) {
@@ -395,8 +444,13 @@ function tripal_pub_PMID_parse_medline_journal_info($xml, &$pub) {
   }
 }
 
-/*
+/**
+ * @stephen
+ *
+ * @param $xml
+ * @param $pub
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_parse_article($xml, &$pub) {
 
@@ -481,12 +535,20 @@ function tripal_pub_PMID_parse_article($xml, &$pub) {
     }
   }
 }
-/*
+
+/**
+ * @stephen
+ *
  * A full list of publication types can be found here:
  * http://www.nlm.nih.gov/mesh/pubtypes.html.
  *
  * The Tripal Pub ontology doesn't yet have terms for all of the
  * publication types so we store the value in the 'publication_type' term.
+ *
+ * @param $xml
+ * @param $pub
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_parse_publication_type($xml, &$pub) {
 
@@ -521,8 +583,14 @@ function tripal_pub_PMID_parse_publication_type($xml, &$pub) {
     }
   }
 }
-/*
+
+/**
+ * @stephen
+ *
+ * @param $xml
+ * @param $pub
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_parse_abstract($xml, &$pub) {
   $abstract = '';
@@ -562,8 +630,14 @@ function tripal_pub_PMID_parse_abstract($xml, &$pub) {
     }
   }
 }
-/*
+
+/**
+ * @stephen
+ *
+ * @param $xml
+ * @param $pub
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_parse_pagination($xml, &$pub) {
   while ($xml->read()) {
@@ -587,8 +661,14 @@ function tripal_pub_PMID_parse_pagination($xml, &$pub) {
     }
   }
 }
-/*
+
+/**
+ * @stephen
  *
+ * @param $xml
+ * @param $pub
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_parse_journal($xml, &$pub) {
 
@@ -631,8 +711,14 @@ function tripal_pub_PMID_parse_journal($xml, &$pub) {
     }
   }
 }
-/*
+
+/**
+ * @stephen
+ *
+ * @param $xml
+ * @param $pub
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_parse_journal_issue($xml, &$pub) {
 
@@ -684,10 +770,15 @@ function tripal_pub_PMID_parse_journal_issue($xml, &$pub) {
   }
 }
 
-/*
+/**
+ * @stephen
  *
+ * @param $xml
+ * @param $element_name
+ *
+ * @ingroup tripal_pub
  */
-function tripal_pub_PMID_parse_date ($xml, $element_name) {
+function tripal_pub_PMID_parse_date($xml, $element_name) {
   $date = array();
 
   while ($xml->read()) {
@@ -724,8 +815,14 @@ function tripal_pub_PMID_parse_date ($xml, $element_name) {
     }
   }
 }
-/*
+
+/**
+ * @stephen
+ *
+ * @param $xml
+ * @param $pub
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_PMID_parse_authorlist($xml, &$pub) {
   $num_authors = 0;
@@ -797,9 +894,19 @@ function tripal_pub_PMID_parse_authorlist($xml, &$pub) {
   }
 }
 
-/*
+/**
+ * Get the name of the language based on an abbreviation
+ *
  * Language abbreviations were obtained here:
  * http://www.nlm.nih.gov/bsd/language_table.html
+ *
+ * @param $lang_abbr
+ *   The abbreviation of the language to return
+ *
+ * @return
+ *   The full name of the language
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_remote_search_get_language($lang_abbr) {
   $languages = array(

+ 24 - 10
tripal_pub/includes/tripal_pub.admin.inc

@@ -1,7 +1,13 @@
 <?php
+/**
+ * @file
+ * Administration of publications
+ */
 
 /**
+ * Admin launchpad
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_admin_pub_view() {
   $output = '';
@@ -33,7 +39,6 @@ function tripal_pub_admin_pub_view() {
   return $output;
 }
 
-
 /**
  * Administrative settings form
  *
@@ -41,17 +46,17 @@ function tripal_pub_admin_pub_view() {
  */
 function tripal_pub_admin() {
   $form = array();
-  
+
   // -----------------------------------------
   // add in the fields for selecting which fields are used when search for pubs
   $form['searching'] = array(
     '#type' => 'fieldset',
     '#title' => t('Searching Options'),
-    '#description' => t("The list of checkboxes below indicate which fields a user 
-      can search with when using the publication search tool.  Check the fields that you want 
+    '#description' => t("The list of checkboxes below indicate which fields a user
+      can search with when using the publication search tool.  Check the fields that you want
       to allow users to search with.  Click the 'Save configuration' button below to save changes."),
   );
-  
+
   // get publication properties list
   $properties = array();
   $properties[] = 'Any Field';
@@ -79,7 +84,7 @@ function tripal_pub_admin() {
   );
 
   // -----------------------------------------
-  // add the field set for syncing publications 
+  // add the field set for syncing publications
   $form['import'] = array(
     '#type' => 'fieldset',
     '#title' => t('Import Settings'),
@@ -136,7 +141,7 @@ function tripal_pub_admin() {
     '#type' => 'select',
     '#title' => t('Publication Type'),
     '#options' => $pub_types,
-    '#description' => t('Please set a default publiation type used for manual entry of a new 
+    '#description' => t('Please set a default publiation type used for manual entry of a new
       publication.  This is useful in the event that someone is manually adding the same
       publication type repetitively'),
     '#default_value' => $d_type_id
@@ -145,8 +150,8 @@ function tripal_pub_admin() {
   return system_settings_form($form);
 }
 
-
 /**
+ * Validate the admin settings form
  *
  * @ingroup tripal_pub
  */
@@ -171,9 +176,18 @@ function tripal_pub_admin_validate($form, &$form_state) {
 
 }
 
-
 /**
+ * Set the URL for a publication
+ *
+ * @param $node
+ *   The publication node from pub_load().
+ * @param $pub_id
+ *   The chado pub_id of the publication to set the url for
  *
+ * @return
+ *   The url alias set
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_set_pub_url($node, $pub_id) {
 
@@ -187,4 +201,4 @@ function tripal_pub_set_pub_url($node, $pub_id) {
   path_save($path_alias);
 
   return $url_alias;
-}
+}

+ 91 - 68
tripal_pub/includes/tripal_pub.chado_node.inc

@@ -1,10 +1,13 @@
 <?php
+/**
+ * @file
+ * Implements the pub node content type
+ */
 
 /**
- * Implementation of hook_tripal_pub_node_info().
- *
- * This node_info, is a simple node that describes the functionallity of the module.
+ * Implements hook_node_info().
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_node_info() {
 
@@ -34,10 +37,10 @@ function tripal_pub_node_info() {
 }
 
 /**
- * This is the chado_pub node form callback. The arguments
- * are out of order from a typical form because it's a defined callback
+ * Implements hook_form().
+ *
+ * @ingroup tripal_pub
  */
-
 function chado_pub_form($node, $form_state) {
   $form = array();
 
@@ -294,8 +297,11 @@ function chado_pub_form($node, $form_state) {
   return $form;
 
 }
-/*
+
+/**
+ * Implements hook_validate().
  *
+ * @ingroup tripal_pub
  */
 function chado_pub_validate($node, $form, &$form_state) {
 
@@ -414,9 +420,14 @@ function chado_pub_validate($node, $form, &$form_state) {
     chado_pub_validate_check_uniquename($uniquename);
   }
 }
+
 /**
+ * Validate the publication uniquename. To be called from hook_validate().
  *
- * @param unknown $uniquename
+ * @param $uniquename
+ *  The uniquename of the publication
+ *
+ * @ingroup tripal_pub
  */
 function chado_pub_validate_check_uniquename($uniquename, $pub_id = NULL) {
 
@@ -432,8 +443,22 @@ function chado_pub_validate_check_uniquename($uniquename, $pub_id = NULL) {
     form_set_error('uniquename', $message);
   }
 }
+
 /**
+ * Check for duplicate publications. To be called from hook_validate().
  *
+ * @param $title
+ *   The title of the publication
+ * @param $pyear
+ *   The year the publication was published
+ * @param $series_name
+ *   The series name of the publication
+ * @param $cvterm
+ *   The type of publication
+ * @param $pub_id
+ *   the unique id of the publication
+ *
+ * @ingroup tripal_pub
  */
 function chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvterm, $pub_id = NULL) {
 
@@ -484,9 +509,8 @@ function chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvter
   }
 }
 
-
 /**
- * Implement hook_access().
+ * Implement hook_node_access().
  *
  * This hook allows node modules to limit access to the node types they define.
  *
@@ -506,8 +530,9 @@ function chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvter
  *  access.  The only exception is when the $op == 'create'.  We will always
  *  return TRUE if the permission is set.
  *
+ * @ingroup tripal_pub
  */
-function chado_pub_node_access($node, $op, $account ) {
+function chado_pub_node_access($node, $op, $account) {
   if ($op == 'create') {
     if (!user_access('create chado_pub content', $account)) {
       return FALSE;
@@ -533,20 +558,10 @@ function chado_pub_node_access($node, $op, $account ) {
   return NULL;
 }
 
-
-
-
-
 /**
- * Implementation of tripal_pub_insert().
- *
- * This function inserts user entered information pertaining to the Publication instance into the
- * 'pubauthor', 'pubprop', 'chado_pub', 'pub' talble of the database.
- *
- *  @parm $node
- *    Then node which contains the information stored within the node-ID
- *
+ * Implements hook_insert().
  *
+ * @ingroup tripal_pub
  */
 function chado_pub_insert($node) {
 
@@ -737,19 +752,18 @@ function chado_pub_insert($node) {
 
 }
 
-/*
+/**
+ * Implements hook_update().
  *
-* Implements hook_update
-*
-* The purpose of the function is to allow the module to take action when an edited node is being
-* updated. It updates any name changes to the database tables that werec reated upon registering a Publication.
-* As well, the database will be changed, so the user changed information will be saved to the database.
-*
-* @param $node
-*   The node being updated
-*
-* @ingroup tripal_pub
-*/
+ * The purpose of the function is to allow the module to take action when an edited node is being
+ * updated. It updates any name changes to the database tables that werec reated upon registering a Publication.
+ * As well, the database will be changed, so the user changed information will be saved to the database.
+ *
+ * @param $node
+ *   The node being updated
+ *
+ * @ingroup tripal_pub
+ */
 function chado_pub_update($node) {
   $title        = trim($node->pubtitle);
   $pyear        = trim($node->pyear);
@@ -924,17 +938,16 @@ function chado_pub_update($node) {
   chado_update_node_form_dbxrefs($node, $details);
 }
 
-
 /**
- * Implementation of tripal_pub_load().
- *
+ * Implements hook_load().
  *
  * @param $node
- *   The node that is to be accessed from the database
+ *   The node that is to be loaded
  *
  * @return $node
  *   The node with the information to be loaded into the database
  *
+ * @ingroup tripal_pub
  */
 function chado_pub_load($nodes) {
 
@@ -959,15 +972,16 @@ function chado_pub_load($nodes) {
 }
 
 /**
- * Implementation of tripal_pub_delete().
+ * Implements hook_delete().
  *
  * This function takes a node and if the delete button has been chosen by the user, the publication
  * and it's details will be removed.Following,given the node-ID, the instance will be deleted from
  * the 'chado_pub' table.
  *
- *  @parm $node
- *    Then node which contains the information stored within the node-ID
+ * @parm $node
+ *    Then node to be deleted
  *
+ * @ingroup tripal_pub
  */
 function chado_pub_delete(&$node) {
 
@@ -993,11 +1007,10 @@ function chado_pub_delete(&$node) {
   chado_query("DELETE FROM {pub} WHERE pub_id = :pub_id", array(':pub_id' => $pub_id));
 }
 
-
-
 /**
+ * Implements hook_node_view(). Acts on all content types.
  *
- * @ingroup tripal_feature
+ * @ingroup tripal_pub
  */
 function tripal_pub_node_view($node, $view_mode, $langcode) {
   switch ($node->type) {
@@ -1064,35 +1077,41 @@ function tripal_pub_node_view($node, $view_mode, $langcode) {
       break;
   }
 }
+
 /**
+ * Implements hook_node_insert(). Acts on all content types.
  *
- * @param $node
+ * We want the publications to always have a URL of http://[base url]/pub/[pub id]
+ * where [pub id] is the Chado publication ID.  This will allow for easy linking
+ * into the publication without needing to know the node.  Of course if you know the
+ * node that will still work too (e.g. http://[base url]/node/[node id]
+ * so the nodeapi function ensures that the URL path is set after insert or update
+ * of the node and when the node is loaded if it hasn't yet been set.
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_node_insert($node) {
-  // we want the publications to always have a URL of http://[base url]/pub/[pub id]
-  // where [pub id] is the Chado publication ID.  This will allow for easy linking
-  // into the publication without needing to know the node.  Of course if you know the
-  // node that will still work too (e.g. http://[base url]/node/[node id]
-  // so the nodeapi function ensures that the URL path is set after insert or update
-  // of the node and when the node is loaded if it hasn't yet been set.
+
   if ($node->type == 'chado_pub') {
     $pub_id = chado_get_id_from_nid('pub', $node->nid);
     tripal_pub_set_pub_url($node, $pub_id);
   }
 }
+
 /**
+ * Implements hook_node_load(). Acts on all content types.
  *
- * @param $node
- * @param $types
+ * We want the publications to always have a URL of http://[base url]/pub/[pub id]
+ * where [pub id] is the Chado publication ID.  This will allow for easy linking
+ * into the publication without needing to know the node.  Of course if you know the
+ * node that will still work too (e.g. http://[base url]/node/[node id]
+ * so the nodeapi function ensures that the URL path is set after insert or update
+ * of the node and when the node is loaded if it hasn't yet been set.
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_node_load($nodes, $types) {
 
-  // we want the publications to always have a URL of http://[base url]/pub/[pub id]
-  // where [pub id] is the Chado publication ID.  This will allow for easy linking
-  // into the publication without needing to know the node.  Of course if you know the
-  // node that will still work too (e.g. http://[base url]/node/[node id]
-  // so the nodeapi function ensures that the URL path is set after insert or update
-  // of the node and when the node is loaded if it hasn't yet been set.
   if (count(array_intersect(array('chado_pub'), $types))) {
     foreach ($nodes as $nid => $node) {
       if ($node->type == 'chado_pub' and !property_exists($node, 'path')) {
@@ -1102,19 +1121,23 @@ function tripal_pub_node_load($nodes, $types) {
     }
   }
 }
+
 /**
+ * Implements hook_node_update(). Acts on all content types.
  *
- * @param $node
+ * We want the publications to always have a URL of http://[base url]/pub/[pub id]
+ * where [pub id] is the Chado publication ID.  This will allow for easy linking
+ * into the publication without needing to know the node.  Of course if you know the
+ * node that will still work too (e.g. http://[base url]/node/[node id]
+ * so the nodeapi function ensures that the URL path is set after insert or update
+ * of the node and when the node is loaded if it hasn't yet been set.
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_node_update($node) {
-  // we want the publications to always have a URL of http://[base url]/pub/[pub id]
-  // where [pub id] is the Chado publication ID.  This will allow for easy linking
-  // into the publication without needing to know the node.  Of course if you know the
-  // node that will still work too (e.g. http://[base url]/node/[node id]
-  // so the nodeapi function ensures that the URL path is set after insert or update
-  // of the node and when the node is loaded if it hasn't yet been set.
+
   if ($node->type == 'chado_pub') {
     $pub_id = chado_get_id_from_nid('pub', $node->nid);
     tripal_pub_set_pub_url($node, $pub_id);
   }
-}
+}

+ 51 - 31
tripal_pub/includes/tripal_pub.pub_citation.inc

@@ -1,27 +1,36 @@
 <?php
-/*
+/**
+ * @file
+ * Functions to manage citations
+ */
+
+/**
  * The admin form for submitting job to create citations
-*/
+ *
+ * @param $form_state
+ *
+ * @ingroup tripal_pub
+ */
 function tripal_pub_citation_form($form_state) {
 
   $form['instructions'] = array(
     '#markup' => '<p>Use this form to unify publication citations. Citations are created automtically when
-      importing publications but citations are set by the user when publications are added manually.  
-      Or publications added to the Chado database by tools other than the Tripal Publication Importer may 
-      not have citations set. If you are certain that all necessary information for all publications is present (e.g. 
+      importing publications but citations are set by the user when publications are added manually.
+      Or publications added to the Chado database by tools other than the Tripal Publication Importer may
+      not have citations set. If you are certain that all necessary information for all publications is present (e.g.
       authors, volume, issue, page numbers, etc.) but citations are not consistent, then you can
       choose to update all citations for all publications using the form below. Alternatively, you
       can update citations only for publication that do not already have one.</p>'
   );
-  
+
   $form['options'] = array(
     '#type' => 'radios',
     '#options' => array(
-      'all' => 'Create citation for all publications. Replace the existing citation if it exists.', 
+      'all' => 'Create citation for all publications. Replace the existing citation if it exists.',
       'new' => 'Create citation for publication only if it does not already have one.'),
     '#default_value' => 'all'
   );
-  
+
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Submit')
@@ -30,43 +39,54 @@ function tripal_pub_citation_form($form_state) {
   return $form;
 }
 
-/*
+/**
  * Submit form. Create Tripal job for citations
+ *
+ * @param $form_state
+ *
+ * @ingroup tripal_pub
  */
-
 function tripal_pub_citation_form_submit(&$form_state) {
   $options [0] = $form_state['options']['#value'];
   tripal_add_job("Create citations ($options[0])", 'tripal_pub', 'tripal_pub_create_citations', $options, $user->uid);
 }
 
-/*
- * Launch the Tripal job to generate citations
+/**
+ * Launch the Tripal job to generate citations. Called by tripal jobs
+ *
+ * @param $options
+ *  Options pertaining to what publications to generate citations for.
+ *  One of the following must be present:
+ *   - all: Create and replace citation for all pubs
+ *   - new: Create citation for pubs that don't already have one
+ *
+ * @ingroup tripal_pub
  */
-function tripal_pub_create_citations ($options) {
+function tripal_pub_create_citations($options) {
   $skip_existing = TRUE;
   $sql = "
-    SELECT cvterm_id 
-    FROM {cvterm} 
-    WHERE 
-      name = 'Citation' AND 
+    SELECT cvterm_id
+    FROM {cvterm}
+    WHERE
+      name = 'Citation' AND
       cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal_pub')
   ";
   $citation_type_id = chado_query($sql)->fetchField();
-  
+
   // Create and replace citation for all pubs
   if ($options == 'all') {
     $sql = "SELECT pub_id FROM {pub} P WHERE pub_id <> 1";
-    $skip_existing = FALSE;  
-  } 
+    $skip_existing = FALSE;
+  }
   // Create citation for pubs that don't already have one
   else if ($options == 'new') {
     $sql = "
-      SELECT pub_id 
-      FROM {pub} P 
-      WHERE 
-        (SELECT value 
-         FROM {pubprop} PB 
-         WHERE type_id = :type_id AND P.pub_id = PB.pub_id AND rank = 0) IS NULL 
+      SELECT pub_id
+      FROM {pub} P
+      WHERE
+        (SELECT value
+         FROM {pubprop} PB
+         WHERE type_id = :type_id AND P.pub_id = PB.pub_id AND rank = 0) IS NULL
         AND  pub_id <> 1
     ";
     $skip_existing = TRUE;
@@ -83,23 +103,23 @@ function tripal_pub_create_citations ($options) {
       // Replace if citation exists. This condition is never TRUE if $skip_existing is TRUE
       if ($pub_arr['Citation']) {
         $sql = "
-          UPDATE {pubprop} SET value = :value 
+          UPDATE {pubprop} SET value = :value
           WHERE pub_id = :pub_id  AND type_id = :type_id AND rank = :rank
         ";
-        chado_query($sql, array(':value' => $citation, ':pub_id' => $pub->pub_id, 
+        chado_query($sql, array(':value' => $citation, ':pub_id' => $pub->pub_id,
           ':type_id' => $citation_type_id, ':rank' => 0));
         $counter_updated ++;
       // Generate a new citation
       } else {
         $sql = "
-          INSERT INTO {pubprop} (pub_id, type_id, value, rank) 
+          INSERT INTO {pubprop} (pub_id, type_id, value, rank)
           VALUES (:pub_id, :type_id, :value, :rank)
         ";
-        chado_query($sql, array(':pub_id' => $pub->pub_id, ':type_id' => $citation_type_id, 
+        chado_query($sql, array(':pub_id' => $pub->pub_id, ':type_id' => $citation_type_id,
           ':value' => $citation, ':rank' => 0));
         $counter_generated ++;
       }
     }
   }
   print "$counter_generated citations generated. $counter_updated citations updated.\n";
-}
+}

+ 91 - 59
tripal_pub/includes/tripal_pub.pub_importers.inc

@@ -1,4 +1,9 @@
 <?php
+/**
+ * @file
+ * Management of importers
+ */
+
 /**
  * A function to generate a table containing the list of publication importers
  *
@@ -7,7 +12,7 @@
 function tripal_pub_importers_list() {
   // clear out the session variable when we view the list.
   unset($_SESSION['tripal_pub_import']);
-  
+
   $header = array('', 'Importer Name', 'Database', 'Search String', 'Disabled', 'Create Contact', '');
   $rows = array();
   $importers = db_query("SELECT * FROM {tripal_pub_import} ORDER BY name");
@@ -43,37 +48,38 @@ function tripal_pub_importers_list() {
   $page  = "<ul class='action-links'>";
   $page .= '  <li>' . l('New Importer', 'admin/tripal/chado/tripal_pub/import/new') . '</li>';
   $page .= '</ul>';
-  
+
   $page .= '<p>' . t(
     "A publication importer is used to create a set of search criteria that can be used
-     to query a remote database, find publications that match the specified criteria 
+     to query a remote database, find publications that match the specified criteria
      and then import those publications into the Chado database. An example use case would
      be to peridocially add new publications to this Tripal site that have appeared in PubMed
      in the last 30 days.  You can import publications in one of two ways:
      <ol>
       <li>Create a new importer by clicking the 'New Importer' link above, and after saving it should appear in the list below.  Click the
           link labeled 'Import Pubs' to schedule a job to import the publications</li>
-      <li>The first method only performs the import once.  However, you can schedule the 
-          importer to run peridically by adding a cron job. See the " . 
-     l("Pub Module help instructions", "admin/tripal/chado/tripal_pub/help") . " to learn how to 
+      <li>The first method only performs the import once.  However, you can schedule the
+          importer to run peridically by adding a cron job. See the " .
+     l("Pub Module help instructions", "admin/tripal/chado/tripal_pub/help") . " to learn how to
      set the importers to run automatically.") . '</li>
      </ol><br>';
 
   $page .= theme('table', array('header' => $header, 'rows' => $rows));
-  
+
   return $page;
 }
 
 /**
- * 
- * @param  action
+ * @stephen
+ *
+ * @param $action
  * @param $pub_import_id
- * 
- * 
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL) {
   global $base_path;
-  
+
   // make sure the tripal_pub and tripal_contact ontologies are loaded
   $values = array('name' => 'tripal_pub');
   $tpub_cv = chado_select_record('cv', array('cv_id'), $values);
@@ -85,7 +91,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
   if (count($tpub_cv) == 0) {
     drupal_set_message(t('If you want to create contact pages for authors, you must first ') . l(t('load the Tripal Contact Ontology'), 'admin/tripal/tripal_cv/obo_loader'), 'error');
   }
-  
+
   if(!extension_loaded ('yaz')){
     drupal_set_message(t('<b>Note:</b> In order to create an importer using the USDA National Agricultural Library (AGL) you must install the yaz libraries. See the ') . l(t('Pub Module help page'), 'admin/tripal/chado/tripal_pub/help') . ' for assistance.  If you do not want to use AGL you can ignore this warning.', 'warning');
   }
@@ -101,7 +107,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
     $remote_db = $_SESSION['tripal_pub_import']['remote_db'];
     $num_criteria = $_SESSION['tripal_pub_import']['num_criteria'];
     $days = $_SESSION['tripal_pub_import']['days'];
-  
+
     $search_array = array();
     $search_array['remote_db'] = $remote_db;
     $search_array['num_criteria'] = $num_criteria;
@@ -112,19 +118,19 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
       $search_array['criteria'][$i]['is_phrase']    = $_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase'];
       $search_array['criteria'][$i]['operation']    = $_SESSION['tripal_pub_import']['criteria'][$i]['operation'];
     }
-  
+
     // if the form has been submitted with the 'test' button then get the results
     if ($_SESSION['tripal_pub_import']['perform_search']) {
-      
+
       $limit = 25;
-      
+
       // get the list of publications from the remote database using the search criteria.
       $page = isset($_GET['page']) ? $_GET['page'] : '0';
       $results = tripal_pub_get_remote_search_results($remote_db, $search_array, $limit, $page);
       $total_records = $results['total_records'];
       $search_str    = $results['search_str'];
       $pubs          = $results['pubs'];
-      
+
       // iterate through the results and construct the table displaying the publications
       $rows = array();
       $i = $page * $limit + 1;
@@ -143,7 +149,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
           $i++;
         }
       }
-      
+
       if (count($rows) == 0) {
         $rows[] = array(
           array(
@@ -152,7 +158,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
           ),
         );
       }
-      
+
       $headers = array('', 'Publication', 'Raw Results');
       $table = array(
         'header' => $headers,
@@ -168,7 +174,7 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
       // once we have our table array structure defined, we call Drupal's theme_table()
       // function to generate the table.
       $table = theme_table($table);
-      
+
       // generate the pager
       pager_default_initialize($total_records, $limit);
       $pager = array(
@@ -178,11 +184,11 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
         'quantity' => $limit,
       );
       $pager = theme_pager($pager);
-      
+
       // because this is an ajax callback, the theme_pager will set the URL to be
       // "system/ajax", so we need to reset that
       $pager = str_replace($base_path . "system/ajax", "", $pager) ;
-      
+
       // join all to form the results
       $total_pages = (int) ($total_records / $limit) + 1;
       $page = isset($_GET['page']) ? $_GET['page'] : '0';
@@ -194,7 +200,14 @@ function tripal_pub_importer_setup_page($action = 'new', $pub_import_id = NULL)
 }
 
 /**
- * Purpose: Provides the form to search pubmed
+ * Provides the form to search pubmed
+ *
+ * @stephen
+ *
+ * @param $form
+ * @param $form_state
+ * @param $pub_import_id
+ * @param $action
  *
  * @ingroup tripal_pub
  */
@@ -202,14 +215,14 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
 
   // Default values can come in the following ways:
   //
-  // 1) as elements of the $pub_importer object.  This occurs when editing an existing importer 
+  // 1) as elements of the $pub_importer object.  This occurs when editing an existing importer
   // 2) in the $form_state['values'] array which occurs on a failed validation or
   //    ajax callbacks from non submit form elements
   // 3) in the $form_state['input'] array which occurs on ajax callbacks from submit
   //    form elements and the form is being rebuilt
   //
   // set form field defaults
-    
+
   // Set the default values. If the pub_import_id isn't already defined by the form values
   // and one is provided then look it up in the database
   $criteria = NULL;
@@ -219,7 +232,7 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
   $do_contact = '';
   $num_criteria = 1;
   $loader_name = '';
-  
+
   // if this is an edit the we are pulling an import object from the database
   if ($action == "edit") {
     $sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = :pub_import_id";
@@ -233,7 +246,7 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
     $num_criteria   = $criteria['num_criteria'];
     $loader_name    = $criteria['loader_name'];
   }
-  
+
   // if there are any session variables then use those
   if (array_key_exists('tripal_pub_import', $_SESSION)) {
     $remote_db    = $_SESSION['tripal_pub_import']['remote_db'];
@@ -242,14 +255,14 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
     $do_contact   = $_SESSION['tripal_pub_import']['do_contact'];
     $num_criteria = $_SESSION['tripal_pub_import']['num_criteria'];
     $loader_name  = $_SESSION['tripal_pub_import']['loader_name'];
-    
+
     // check if the pub_import_id in the session variable is not the same as the one we've been provided
     // if so, then clear the session variable
     if ($pub_import_id and $pub_import_id != $_SESSION['tripal_pub_import']['pub_import_id']) {
       unset($_SESSION['tripal_pub_import']);
     }
   }
-  
+
   // if we are re constructing the form from a failed validation or ajax callback
   // then use the $form_state['values'] values
   if (array_key_exists('values', $form_state)) {
@@ -268,7 +281,7 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
     $disabled     = $form_state['input']['disabled'];
     $do_contact   = $form_state['input']['do_contact'];
     $loader_name  = $form_state['input']['loader_name'];
-    
+
     // because the num_criteria is a value and not a visible or hidden form
     // element it is not part of the ['input'] array, so we need to get it from the form
     $num_criteria = $form_state['complete form']['num_criteria']['#value'];
@@ -282,9 +295,9 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
   $form_state['triggering_element']['#name'] == 'remove') {
     $num_criteria--;
   }
-  
 
-  
+
+
   // set the values we need for later but that should not be shown on the form
   $form['num_criteria']= array(
     '#type'  => 'value',
@@ -353,7 +366,7 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
        additional information such as affilation, etc. Otherwise, only authors names are retrieved.'),
     '#default_value' => $do_contact,
   );
-  
+
   // add in the form for the criteria
   tripal_pub_importer_setup_add_criteria_fields($form, $form_state, $num_criteria, $criteria);
 
@@ -371,30 +384,33 @@ function tripal_pub_importer_setup_form($form, &$form_state = NULL, $pub_import_
     '#value'        => t('Delete Importer'),
     '#attributes'  => array('style' => 'float: right;')
   );
-  
+
   // add in the section where the test results will appear
   $form['results'] = array(
     '#markup' => '<div id="tripal-pub-importer-test-section"></div>',
   );
-  
+
   // allow the selected remote database to make changes to the form if needed
   $callback = "tripal_pub_remote_alter_form_$remote_db";
   $form = call_user_func($callback, $form, $form_state, $num_criteria);
- 
+
   $form['themed_element']['#theme'] = 'tripal_pub_importer_setup_form_elements';
-  
+
   return $form;
 }
 
 /**
- * 
+ * @stephen
+ *
  * @param $form
  * @param $form_state
  * @param $num_criteria
  * @param $criteria
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $num_criteria, $criteria){
-  
+
   // choices array
   $scope_choices = array(
     'any'      => 'Any Field',
@@ -404,7 +420,7 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
     'title'    => 'Title',
     'journal'   => 'Journal Name'
   );
-  
+
   $first_op_choices = array(
     ''    => '',
     'NOT' => 'NOT'
@@ -414,15 +430,15 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
     'OR'  => 'OR',
     'NOT' => 'NOT'
   );
-  
+
   for($i = 1; $i <= $num_criteria; $i++) {
     $is_phrase = 1;
-    
+
     $search_terms = '';
     $scope = '';
     $is_phrase = '';
     $operation = '';
-  
+
     // if we have criteria supplied from the database then use that as the initial defaults
     if ($criteria) {
       $search_terms = $criteria['criteria'][$i]['search_terms'];
@@ -438,7 +454,7 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
       $is_phrase    = isset($_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase'])    ? $_SESSION['tripal_pub_import']['criteria'][$i]['is_phrase']    : $is_phrase;
       $operation    = isset($_SESSION['tripal_pub_import']['criteria'][$i]['operation'])    ? $_SESSION['tripal_pub_import']['criteria'][$i]['operation']    : $operation;
     }
-    
+
     // If the form_state has variables then use those.  This happens when an error occurs on the form or the
     // form is resbumitted using AJAX
     if (array_key_exists('values', $form_state)) {
@@ -467,7 +483,7 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
       '#title'   => t('Is Phrase?'),
       '#default_value' => $is_phrase,
     );
-  
+
     if ($i == 1) {
       /*
        $form['criteria'][$i]["operation-$i"] = array(
@@ -533,23 +549,32 @@ function tripal_pub_importer_setup_add_criteria_fields(&$form, &$form_state, $nu
     }
   }
 }
+
 /**
  * This function is used to rebuild the form if an ajax call is made vai a button.
  * The button causes the form to be submitted. We don't want this so we override
  * the validate and submit routines on the form button. Therefore, this function
  * only needs to tell Drupal to rebuild the form
+ *
+ * @ingroup tripal_pub
  */
 function  tripal_pub_setup_form_ajax_button_validate($form, &$form_state){
   $form_state['rebuild'] = TRUE;
 }
+
 /**
  * This function is just a dummy to override the default form submit on ajax calls for buttons
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_setup_form_ajax_button_submit($form, &$form_state){
   // do nothing
 }
+
 /**
+ * Validate the tripal_pub_importer_setup_form form
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_importer_setup_form_validate($form, &$form_state) {
   $num_criteria = $form_state['values']['num_criteria'];
@@ -564,7 +589,7 @@ function tripal_pub_importer_setup_form_validate($form, &$form_state) {
     $scope =  $form_state['values']["scope-$i"];
     $is_phrase =  $form_state['values']["is_phrase-$i"];
     $operation = '';
-    if($i > 1) {      
+    if($i > 1) {
       $operation =  $form_state['values']["operation-$i"];
     }
 
@@ -586,7 +611,9 @@ function tripal_pub_importer_setup_form_validate($form, &$form_state) {
 }
 
 /**
+ * Submit the tripal_pub_importer_setup_form form
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_importer_setup_form_submit($form, &$form_state) {
 
@@ -681,18 +708,21 @@ function tripal_pub_importer_setup_form_submit($form, &$form_state) {
     }
   }
 }
+
 /**
- * AJAX callback for updating the form.  
+ * AJAX callback for updating the form.
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pubs_setup_form_ajax_update($form, $form_state) {
   return $form['themed_element'];
 }
 
 /**
- * 
- * @param $form
+ * Theme the tripal_pub_importer_setup_form form.
+ *
+ * @ingroup tripal_pub
  */
-
 function theme_tripal_pub_importer_setup_form_elements($variables) {
   $form = $variables['form'];
 
@@ -721,7 +751,7 @@ function theme_tripal_pub_importer_setup_form_elements($variables) {
       );
     }
   }
-  
+
   $headers = array('Operation','Scope', 'Search Terms', '','');
   $table = array(
     'header' => $headers,
@@ -734,34 +764,36 @@ function theme_tripal_pub_importer_setup_form_elements($variables) {
   );
   $criteria_table = theme_table($table);
   $markup .= $criteria_table;
-  
+
   // add the rendered form
   $form = array(
     '#markup' => $markup,
     '#prefix' => '<div id="tripal-pubs-importer-setup">',
     '#suffix' => '</div>',
   );
-  
+
   return drupal_render($form);
 }
 
 /**
  * Add a job to import publications
- * 
+ *
  * @param $pub_importer_id
+ *   The id of the importer to submit a job to update
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_importer_submit_job($import_id) {
   global $user;
-  
+
   // get all of the loaders
   $args = array(':import_id' => $import_id);
   $sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = :import_id ";
   $import = db_query($sql, $args)->fetchObject();
-  
+
   $args = array($import_id);
   tripal_add_job("Import publications $import->name", 'tripal_pub',
     'tripal_pub_import_publications_by_import_id', $args, $user->uid);
-  
+
   drupal_goto('admin/tripal/chado/tripal_pub/import_list');
 }
-

+ 64 - 38
tripal_pub/includes/tripal_pub.pub_search.inc

@@ -1,6 +1,13 @@
 <?php
-/*
+/**
+ * @file
+ * Functions related to searching remote publication databases
+ */
+
+/**
+ * @stephen
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_search_page() {
 
@@ -11,12 +18,12 @@ function tripal_pub_search_page() {
   $output = drupal_render($form);
 
   // retrieve any results
-  if (array_key_exists('tripal_pub_search_form', $_SESSION) and 
+  if (array_key_exists('tripal_pub_search_form', $_SESSION) and
       $_SESSION['tripal_pub_search_form']['perform_search']) {
     $num_criteria = $_SESSION['tripal_pub_search_form']['num_criteria'];
     $from_year    = $_SESSION['tripal_pub_search_form']['from_year'];
     $to_year      = $_SESSION['tripal_pub_search_form']['to_year'];
-     
+
     $search_array = array();
     $search_array['num_criteria'] = $num_criteria;
     $search_array['from_year']    = $from_year;
@@ -40,7 +47,7 @@ function tripal_pub_search_page() {
     foreach ($pubs as $pub) {
       // get the citation for this publication
       $values = array(
-        'pub_id' => $pub->pub_id, 
+        'pub_id' => $pub->pub_id,
         'type_id' => array(
           'name' => 'Citation',
         ),
@@ -65,7 +72,7 @@ function tripal_pub_search_page() {
       );
       $i++;
     }
-    
+
     if (count($rows) == 0) {
       $rows[] = array(
         array(
@@ -86,7 +93,7 @@ function tripal_pub_search_page() {
       'empty' => '',
     );
     $results = theme_table($table);
-    
+
     // generate the pager
     pager_default_initialize($total_records, $limit);
     $pager = array(
@@ -96,16 +103,17 @@ function tripal_pub_search_page() {
       'quantity' => $limit,
     );
     $pager = theme_pager($pager);
-    
+
     // join all to form the results
     $output .= "<br><p><b>Found " . number_format($total_records) .
       ". Page " . ($page + 1) . " of $total_pages. " .
-      " Results</b></br>" . $results . $pager;    
+      " Results</b></br>" . $results . $pager;
   }
   return $output;
 }
+
 /**
- * Purpose: Provides the form to search pubmed
+ * Provides the form to search pubmed
  *
  * @ingroup tripal_pub
  */
@@ -118,7 +126,7 @@ function tripal_pub_search_form($form, &$form_state) {
   // 3) in the $form_state['input'] array which occurs on ajax callbacks from submit
   //    form elements and the form is being rebuilt
   //
-  
+
   // Set the default values. If the pub_import_id isn't already defined by the form values
   // and one is provided then look it up in the database
   $criteria = NULL;
@@ -142,7 +150,7 @@ function tripal_pub_search_form($form, &$form_state) {
     $num_criteria = $form_state['input']['num_criteria'] ? $form_state['input']['num_criteria'] : $num_criteria;
     $from_year    = $form_state['input']['from_year']    ? $form_state['input']['from_year']    : $from_year;
     $to_year      = $form_state['input']['to_year']      ? $form_state['input']['to_year']      : $to_year;
-    
+
   }
 
   if (array_key_exists('triggering_element', $form_state) and
@@ -153,22 +161,22 @@ function tripal_pub_search_form($form, &$form_state) {
   $form_state['triggering_element']['#name'] == 'remove') {
     $num_criteria--;
   }
-  
+
   $form['num_criteria']= array(
     '#type'          => 'hidden',
     '#default_value' => $num_criteria,
   );
-  
+
   $form['admin-instructions'] = array(
-    '#markup'  =>  theme('tripal_admin_message', array('message' => 
+    '#markup'  =>  theme('tripal_admin_message', array('message' =>
       t('Administrators, you can select the fields with which a user can use to search,
          by checking the desired fields on the ' .
          l('Publication Module Settings Page', 'admin/tripal/chado/tripal_pub/configuration'). ' in
         the section titled "Search Options".  The selected fields will appear in the dropdowns below.'))),
-  ); 
+  );
   $form['instructions'] = array(
-    '#markup'  =>  t('To search for publications enter keywords in the text boxes below.  
-        You can limit your search by selecting the field in the dropdown box. Click the 
+    '#markup'  =>  t('To search for publications enter keywords in the text boxes below.
+        You can limit your search by selecting the field in the dropdown box. Click the
         add and remove buttons to add additional fields for searching. '),
   );
 
@@ -181,10 +189,10 @@ function tripal_pub_search_form($form, &$form_state) {
       INNER JOIN {cvterm} CVTS ON CVTP.subject_id = CVTS.cvterm_id
       INNER JOIN {cvterm} CVTO ON CVTP.object_id = CVTO.cvterm_id
       INNER JOIN {cv} ON CVTO.cv_id = CV.cv_id
-    WHERE CV.name = 'tripal_pub' and 
-      (CVTO.name = 'Publication Details' or CVTS.name = 'Publication Type') and 
+    WHERE CV.name = 'tripal_pub' and
+      (CVTO.name = 'Publication Details' or CVTS.name = 'Publication Type') and
       NOT CVTS.is_obsolete = 1
-    ORDER BY CVTS.name ASC 
+    ORDER BY CVTS.name ASC
   ";
   $allowed_fields = variable_get('tripal_pub_allowed_search_fields', array());
   $prop_types = chado_query($sql);
@@ -207,7 +215,7 @@ function tripal_pub_search_form($form, &$form_state) {
       $mode         = $_SESSION['tripal_pub_search_form']['criteria'][$i]['mode']         ? $_SESSION['tripal_pub_search_form']['criteria'][$i]['mode']         : $mode;
       $operation    = $_SESSION['tripal_pub_search_form']['criteria'][$i]['operation']    ? $_SESSION['tripal_pub_search_form']['criteria'][$i]['operation']    : $operation;
     }
-    if (array_key_exists('values', $form_state)) {      
+    if (array_key_exists('values', $form_state)) {
       $search_terms = array_key_exists("search_terms-$i", $form_state['values']) ? $form_state['values']["search_terms-$i"] : $search_terms;
       $scope        = array_key_exists("scope-$i", $form_state['values'])        ? $form_state['values']["scope-$i"]        : $scope;
       $mode         = array_key_exists("mode-$i", $form_state['values'])         ? $form_state['values']["mode-$i"]         : $mode;
@@ -283,7 +291,7 @@ function tripal_pub_search_form($form, &$form_state) {
         );
       }
       $form['criteria'][$i]["add-$i"] = array(
-        '#type'  => 'button',      
+        '#type'  => 'button',
         '#name'  => 'add',
         '#value' => t('Add'),
         '#ajax' => array(
@@ -336,30 +344,37 @@ function tripal_pub_search_form($form, &$form_state) {
     '#type'         => 'submit',
     '#value'        => t('Reset'),
   );
-  
+
   $form['criteria']['#theme'] = 'tripal_pub_search_setup_form_elements';
 
   return $form;
 }
+
 /**
  * This function is used to rebuild the form if an ajax call is made vai a button.
  * The button causes the form to be submitted. We don't want this so we override
  * the validate and submit routines on the form button. Therefore, this function
  * only needs to tell Drupal to rebuild the form
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_search_form_ajax_button_submit() {
   $form_state['rebuild'] = TRUE;
-  
 }
+
 /**
  * This function is just a dummy to override the default form submit on ajax calls for buttons
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_search_form_ajax_button_validate() {
   // do nothing
 }
 
 /**
+ * Validate the tripal_pub_search_form form
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_search_form_validate($form, &$form_state) {
   $num_criteria = $form_state['values']['num_criteria'];
@@ -385,8 +400,11 @@ function tripal_pub_search_form_validate($form, &$form_state) {
     form_set_error('to_year', 'Please provide a 4-digit year.');
   }
 }
+
 /**
+ * Submit the tripal_pub_search_form form
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_search_form_submit($form, &$form_state) {
   $num_criteria = $form_state['values']['num_criteria'];
@@ -413,14 +431,14 @@ function tripal_pub_search_form_submit($form, &$form_state) {
         $operation =  $form_state['values']["operation-$i"];
       }
       //$mode =  $form_state['values']["mode-$i"];
-      
+
       $_SESSION['tripal_pub_search_form']['criteria'][$i] = array(
         'search_terms' => $search_terms,
         'scope' => $scope,
         'mode' => $mode,
         'operation' => $operation
       );
-      
+
     }
     $_SESSION['tripal_pub_search_form']['from_year'] = $from_year;
     $_SESSION['tripal_pub_search_form']['to_year'] = $to_year;
@@ -431,8 +449,10 @@ function tripal_pub_search_form_submit($form, &$form_state) {
   }
 }
 
-/*
+/**
  * AHAH callback
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_search_page_update_criteria($action, $i) {
   $status = TRUE;
@@ -448,21 +468,24 @@ function tripal_pub_search_page_update_criteria($action, $i) {
   // return the updated JSON
   drupal_json(
   array(
-      'status'   => $status, 
+      'status'   => $status,
       'data'     => $data,
       'settings' => $settings,
   )
   );
 }
+
 /**
+ * @stephen
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_get_search_results($search_array, $limit) {
 
   // build the SQL based on the criteria provided by the user
   $select = "SELECT DISTINCT P.*, CP.nid ";
   $from   = "FROM {pub} P
-               LEFT JOIN public.chado_pub CP on P.pub_id = CP.pub_id 
+               LEFT JOIN public.chado_pub CP on P.pub_id = CP.pub_id
                INNER JOIN {cvterm} CVT on CVT.cvterm_id = P.type_id
             ";
   $where  = "WHERE (NOT P.title = 'null') "; // always exclude the dummy pub
@@ -539,7 +562,7 @@ function tripal_pub_get_search_results($search_array, $limit) {
     elseif ($type_id == 0) { //'Any Field'
       $from .= " LEFT JOIN {pubprop} PP$i ON PP$i.pub_id = P.pub_id ";
       $where .= " $op (lower(PP$i.value)  LIKE lower(:crit$i) OR
-                       lower(P.title) LIKE lower(:crit$i) OR 
+                       lower(P.title) LIKE lower(:crit$i) OR
                        lower(P.volumetitle) LIKE lower(:crit$i) OR
                        lower(P.publisher) LIKE lower(:crit$i) OR
                        lower(P.uniquename) LIKE lower(:crit$i) OR
@@ -567,16 +590,19 @@ function tripal_pub_get_search_results($search_array, $limit) {
 }
 
 /**
- * 
+ * Ajax callback to update the form
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pubs_search_form_ajax_update($form, $form_state) {
   return $form['criteria'];
 }
 
 /**
-*
-* @param unknown $form
-*/
+ * Theme the tripal_pub_search_setup_form form
+ *
+ * @ingroup tripal_pub
+ */
 function theme_tripal_pub_search_setup_form_elements($variables) {
   $form = $variables['form'];
 
@@ -591,7 +617,7 @@ function theme_tripal_pub_search_setup_form_elements($variables) {
         drupal_render($element["search_terms-$i"]),
         array(
           'data' => drupal_render($element["add-$i"]) . drupal_render($element["remove-$i"]),
-          'nowrap' => 'nowrap', 
+          'nowrap' => 'nowrap',
         ),
       );
     }
@@ -613,8 +639,8 @@ function theme_tripal_pub_search_setup_form_elements($variables) {
     ),
     ''
   );
-  
-  $headers = array();  
+
+  $headers = array();
   $table = array(
     'header' => $headers,
     'rows' => $rows,
@@ -628,4 +654,4 @@ function theme_tripal_pub_search_setup_form_elements($variables) {
   $results .= theme_table($table);
   $results .= '</div>';
   return $results;
-}
+}

+ 8 - 2
tripal_pub/tripal_pub.drush.inc

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * Contains function relating to drush-integration of this module.
@@ -10,6 +9,8 @@
  *
  * @return
  *   The first line of description when executing the help for a given command
+ *
+ * @ingroup tripal_drush
  */
 function tripal_pub_drush_help($command) {
   switch ($command) {
@@ -23,6 +24,8 @@ function tripal_pub_drush_help($command) {
  *
  * @return
  *   And array of command descriptions
+ *
+ * @ingroup tripal_drush
  */
 function tripal_pub_drush_command() {
   $items = array();
@@ -37,7 +40,7 @@ function tripal_pub_drush_command() {
     'examples' => array(
       'Standard example' => 'drush tripal-pubs-import',
       'Standard example' => 'drush -l http://[site url] tripal-pubs-import --report=[email]. Where [site url] is the URL of the website and [email] is the email address of the recipient to receive the HTML report',
-      'Import single publication' => 'drush tripal-pub-import --dbxref=PMID:23582642',  
+      'Import single publication' => 'drush tripal-pub-import --dbxref=PMID:23582642',
   ),
     'aliases' => array('tpubs-import'),
   );
@@ -63,6 +66,7 @@ function tripal_pub_drush_command() {
 /**
  * Imports publications into Chado
  *
+ * @ingroup tripal_drush
  */
 function drush_tripal_pub_tripal_pubs_import() {
   $create_contacts = drush_get_option('create_contacts');
@@ -84,9 +88,11 @@ function drush_tripal_pub_tripal_pubs_import() {
     tripal_pub_import_publications($do_report, $update);
   }
 }
+
 /**
  * Imports publications into Chado
  *
+ * @ingroup tripal_drush
  */
 function drush_tripal_pub_tripal_pubs_update() {
   $create_contacts = drush_get_option('create_contacts');

+ 25 - 10
tripal_pub/tripal_pub.install

@@ -1,17 +1,14 @@
 <?php
-
 /**
  * @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.
- *
- * 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
+ * Installation of the publication module
  */
 
 /**
+ * Implements hook_disable().
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_disable() {
 
@@ -26,6 +23,8 @@ function tripal_pub_disable() {
 
 /**
  * Implementation of hook_requirements().
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_requirements($phase) {
   $requirements = array();
@@ -44,6 +43,8 @@ function tripal_pub_requirements($phase) {
 
 /**
  * Implementation of hook_install().
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_install() {
   global $base_path;
@@ -66,13 +67,17 @@ function tripal_pub_install() {
 
 /**
  * Implementation of hook_uninstall().
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_uninstall() {
 
 }
 
 /**
+ * Implements hook_enable().
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_enable() {
   // make sure we have our supported databases
@@ -82,9 +87,10 @@ function tripal_pub_enable() {
   variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));
 }
 
-
 /**
  * Implementation of hook_schema().
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_schema() {
 
@@ -161,9 +167,11 @@ function tripal_pub_schema() {
   return $schema;
 }
 
-
-/*
+/**
+ * Add custom table related to publications
+ *  - pubauthor_contact
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_add_custom_tables() {
   $schema = array (
@@ -210,7 +218,9 @@ function tripal_pub_add_custom_tables() {
 }
 
 /**
+ * Add cvs related to publications
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_add_cvs() {
 
@@ -220,8 +230,11 @@ function tripal_pub_add_cvs() {
     'Contains Types of relationships between publications.'
   );
 }
+
 /**
+ * Add cvterms related to publications
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_add_cvterms() {
 
@@ -229,6 +242,8 @@ function tripal_pub_add_cvterms() {
 
 /**
  * This is the required update for tripal_contact when upgrading from Drupal core API 6.x.
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_update_7000() {
 

+ 38 - 33
tripal_pub/tripal_pub.module

@@ -1,14 +1,20 @@
 <?php
+/**
+ * @file
+ * Basic functionality of the pub module
+ */
+
+require_once 'api/tripal_pub.api.inc';
+
+require_once 'theme/tripal_pub.theme.inc';
 
-require_once "api/tripal_pub.api.inc";
-require_once "theme/tripal_pub.theme.inc";
-require_once "includes/tripal_pub.admin.inc";
-require_once "includes/tripal_pub.chado_node.inc";
-require_once "includes/tripal_pub.pub_importers.inc";
-require_once "includes/tripal_pub.pub_search.inc";
-require_once "includes/tripal_pub.pub_citation.inc";
-require_once "includes/importers/tripal_pub.PMID.inc";
-require_once "includes/importers/tripal_pub.AGL.inc";
+require_once 'includes/tripal_pub.admin.inc';
+require_once 'includes/tripal_pub.chado_node.inc';
+require_once 'includes/tripal_pub.pub_importers.inc';
+require_once 'includes/tripal_pub.pub_search.inc';
+require_once 'includes/tripal_pub.pub_citation.inc';
+require_once 'includes/importers/tripal_pub.PMID.inc';
+require_once 'includes/importers/tripal_pub.AGL.inc';
 
 /**
  * @defgroup tripal_pub Publication Module
@@ -24,24 +30,17 @@ require_once "includes/importers/tripal_pub.AGL.inc";
  * @}
  */
 
-
 /**
+ * Implements hook_menu().
  *
- * @ingroup tripal_pub
- */
-function tripal_pub_init() {
-
-}
-
-/**
- * Tripal-Publication-Menu
- *
- * Implements hook_menu(): Adds menu items for the tripal_pub module menu. This section
+ * Adds menu items for the tripal_pub module menu. This section
  * gives the outline for the main menu of the Tripal-Publication module
  *
  * @return
  *   An array of menu items that is visible within the Drupal Menu, returned as soon
  *   as the program is ran
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_menu() {
   $items = array();
@@ -181,14 +180,14 @@ function tripal_pub_menu() {
   return $items;
 }
 
-
 /**
- * Implements hook_theme(): Register themeing functions for this module
- *
+ * Implements hook_theme().
+ * Register themeing functions for this module
  *
  * @return
  *   An array of themeing functions to register
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_theme($existing, $type, $theme, $path) {
   $core_path = drupal_get_path('module', 'tripal_core');
@@ -279,8 +278,10 @@ function tripal_pub_theme($existing, $type, $theme, $path) {
 }
 
 /**
- * Implements hook_help()
- * Purpose: Adds a help page to the module list
+ * Implements hook_help().
+ * Adds a help page to the module list
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_help ($path, $arg) {
   if ($path == 'admin/help#tripal_pub') {
@@ -289,8 +290,9 @@ function tripal_pub_help ($path, $arg) {
 }
 
 /**
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
+ * Implements hook_views_api().
+ *
+ * Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_db.views.inc where all the
  *  views integration code is
  *
@@ -332,11 +334,10 @@ function tripal_pub_permission() {
   );
 }
 
-
-
-
 /**
+ * Implements hook_mail().
  *
+ * @ingroup tripal_pub
  */
 function tripal_pub_mail($key, &$message, $params) {
   $language = $message['language'];
@@ -358,13 +359,14 @@ function tripal_pub_mail($key, &$message, $params) {
   }
 }
 
-
 /**
- * Implementation of hook_form_alter()
+ * Implementation of hook_form_alter().
  *
  * @param $form
  * @param $form_state
  * @param $form_id
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_form_alter(&$form, &$form_state, $form_id) {
   // turn of preview button for insert/updates
@@ -391,9 +393,12 @@ function tripal_pub_form_alter(&$form, &$form_state, $form_id) {
 }
 
 /**
+ * Implements hook_job_describe_args().
  *
  * @param $callback
  * @param $args
+ *
+ * @ingroup tripal_pub
  */
 function tripal_pub_job_describe_args($callback, $args) {
 
@@ -407,4 +412,4 @@ function tripal_pub_job_describe_args($callback, $args) {
     $new_args['Importer'] = $import->name;
   }
   return $new_args;
-}
+}

+ 12 - 2
tripal_pub/tripal_pub.views_default.inc

@@ -1,8 +1,13 @@
 <?php
+/**
+ * @file
+ * Describe publication default views
+ */
 
 /**
+ * Implements hook_views_default_views().
  *
- *
+ * @ingroup tripal_pub
  */
 function tripal_pub_views_default_views() {
   $views = array();
@@ -14,6 +19,11 @@ function tripal_pub_views_default_views() {
   return $views;
 }
 
+/**
+ * Default publication administration view
+ *
+ * @ingroup tripal_pub
+ */
 function tripal_pub_defaultview_admin_publications() {
 
   $view = new view();
@@ -195,4 +205,4 @@ function tripal_pub_defaultview_admin_publications() {
   */
 
   return $view;
-}
+}

+ 3 - 4
tripal_stock/api/tripal_stock.api.inc

@@ -53,7 +53,7 @@ function tripal_stock_get_stock_by_stock_id($stock_id) {
 }
 
 /**
- * Purpose: Returns all stocks currently sync'd with drupal
+ * Returns all stocks currently sync'd with drupal
  *
  * @return
  *   An array of node objects keyed by stock_id
@@ -129,7 +129,7 @@ function tripal_stock_get_stocks($values) {
 }
 
 /**
- * Purpose: Retrieve stocks based on associated stock properties
+ * Retrieve stocks based on associated stock properties
  *
  * @param $stockprop_values
  *   An array of column_name => value where column_name is any column in the stockprop table
@@ -194,7 +194,7 @@ function tripal_stock_get_stocks_by_stockprop($stockprop_values, $stock_values)
 }
 
 /**
- * Purpose: Return all stocks with a given name identifier
+ * Return all stocks with a given name identifier
  *  which might match stock.name, stock.uniquename, dbxref.accession,
  *  stockprop.value where stockprop.type='synonym'
  *
@@ -320,4 +320,3 @@ function tripal_stock_get_stock_by_name_identifier($name, $organism_id) {
 
   return $stocks;
 }
-

+ 0 - 64
tripal_stock/includes/other_module_api_functions.inc

@@ -1,64 +0,0 @@
-<?php
-/**
- * @file
- * @todo Add file header description
- */
-
-/*************************************************************************
- * Purpose: Get max rank for a given set of criteria
- *   This function was developed with the many property tables in chado in mind
- *
- * @params tablename: the name of the chado table you want to select the max rank from
- *    this table must contain a rank column of type integer
- * @params where_options: array(
- *                          <column_name> => array(
- *                            'type' => <type of column: INT/STRING>,
- *                            'value' => <the value you want to filter on>,
- *                            'exact' => <if TRUE use =; if FALSE use ~>,
- *                          )
- *        )
- *     where options should include the id and type for that table to correctly
- *     group a set of records together where the only difference are the value and rank
- * @return the maximum rank
- *
- */
-function get_max_chado_rank($tablename, $where_options) {
-
-  $where = array();
-  //generate the where clause from supplied options
-  // the key is the column name
-  $args = array();
-  $i = 0;
-  $sql = "
-    SELECT max(rank) as max_rank, count(rank) as count 
-    FROM {:table} 
-    WHERE 1=1
-  ";
-  $args[":table"] = $tablename;
-  foreach ($where_options as $key => $val_array) {
-    if (preg_match('/INT/', $val_array['type'])) {
-      $sql .= " AND $key = :$key$i ";
-      $args[":$key$i"] = $val_array['value'];
-    }
-    else {
-      if ($val_array['exact']) {
-        $operator = '='; 
-      }
-      else { 
-        $operator = '~'; 
-      }
-      $sql .= " AND $key $operator :$key$i ";
-      $args[":$key$i"] = $val_array['value'];
-    }
-    $i++;
-  }
-   
-  $result = chado_query($sql, $tablename, $args)->fetchObject();
-  //drupal_set_message("Max Rank Query=SELECT max(rank) as max_rank, count(rank) as count FROM ".$tablename." WHERE ".implode(' AND ',$where));
-  if ($result->count > 0) {
-    return $result->max_rank;
-  }
-  else {
-    return -1;
-  }
-}

+ 12 - 6
tripal_stock/includes/tripal_stock.admin.inc

@@ -1,11 +1,13 @@
 <?php
 /**
  * @file
- * @todo Add file header description
+ * Administration of stocks
  */
 
 /**
+ * Admin launchpad
  *
+ * @ingroup tripal_stock
  */
 function tripal_stock_admin_stock_view() {
   $output = '';
@@ -37,9 +39,8 @@ function tripal_stock_admin_stock_view() {
   return $output;
 }
 
-
 /**
- * Purpose: Provide administration options for chado_stocks
+ * Provide administration options for chado_stocks
  *
  * @return
  *   Form array (as described by the drupal form api)
@@ -96,8 +97,9 @@ function tripal_stock_admin_validate($form, &$form_state) {
 }
 
 /**
+ * Form: Set the title type to be used for all stocks
  *
- * @param $form
+ * @ingroup tripal_stock
  */
 function get_tripal_stock_admin_form_title_set(&$form) {
 
@@ -132,9 +134,11 @@ function get_tripal_stock_admin_form_title_set(&$form) {
     '#default_value' => variable_get('chado_stock_title', 'unique_constraint'),
   );
 }
+
 /**
+ * Form: Set UR for stocks
  *
- * @param  $form
+ * @ingroup tripal_stock
  */
 function get_tripal_stock_admin_form_url_set(&$form) {
 
@@ -197,9 +201,11 @@ function get_tripal_stock_admin_form_url_set(&$form) {
     '#value' => t('Set Stock URLs'),
   );
 }
+
 /**
+ * Set Controlled vocabularies used in stock tables
  *
- * @param $form
+ * @ingroup tripal_stock
  */
 function get_tripal_stock_admin_form_vocabulary_set(&$form) {
 

+ 25 - 11
tripal_stock/includes/tripal_stock.chado_node.inc

@@ -1,11 +1,11 @@
 <?php
-
 /**
  * @file Stock Node Functionality
  */
 
 /**
- * Implements hook_node_info(): registers a stock node type
+ * Implements hook_node_info().
+ * Registers a stock node type
  *
  * @return
  *   An array describing various details of the node
@@ -37,7 +37,8 @@ function tripal_stock_node_info() {
 }
 
 /**
- * Implements hook_load(): Prepares the chado_stock node
+ * Implements hook_load().
+ * Prepares the chado_stock node
  *
  * @param $node
  *   The basic node containing all variables common to all nodes
@@ -100,9 +101,9 @@ function chado_stock_load($nodes) {
   return $new_nodes;
 }
 
-
 /**
- * Implements hook_form(): Creates the main Add/Edit/Delete Form for chado stocks
+ * Implements hook_form().
+ * Creates the main Add/Edit/Delete Form for chado stocks
  *
  * Parts to be added by this form
  *     name,
@@ -332,7 +333,8 @@ function chado_stock_form($node, $form_state) {
 }
 
 /**
- * Implements hook_validate(): Validate the input from the chado_stock node form
+ * Implements hook_validate().
+ * Validate the input from the chado_stock node form
  *
  * @param $node
  *   The current node including fields with the form element names and submitted values
@@ -448,9 +450,9 @@ function chado_stock_validate(&$node, $form, &$form_state) {
   }
 }
 
-
 /**
- * Implements hook_insert(): Inserts data from chado_stock_form() into drupal and chado
+ * Implements hook_insert().
+ * Inserts data from chado_stock_form() into drupal and chado
  *
  * @param $node
  *   The current node including fields with the form element names and submitted values
@@ -584,7 +586,8 @@ function chado_stock_insert($node) {
 }
 
 /**
- * Implements hook_update(): Handles Editing/Updating of main stock info
+ * Implements hook_update().
+ * Handles Editing/Updating of main stock info
  *
  * NOTE: Currently just writes over all old data
  *
@@ -729,7 +732,8 @@ function chado_stock_update($node) {
 }
 
 /**
- * Implements hook_delete(): Handles deleting of chado_stocks
+ * Implements hook_delete().
+ * Handles deleting of chado_stocks
  *
  * NOTE: Currently deletes data -no undo or record-keeping functionality
  *
@@ -752,6 +756,8 @@ function chado_stock_delete($node) {
 
 /**
  * Used by Tripal Chado Node API during sync'ing of nodes
+ *
+ * @ingroup tripal_stock
  */
 function chado_stock_chado_node_sync_create_new_node($new_node, $record) {
 
@@ -764,6 +770,8 @@ function chado_stock_chado_node_sync_create_new_node($new_node, $record) {
 }
 
 /**
+ * Implements hook_node_presave(). Acts on all content types.
+ *
  * @ingroup tripal_stock
  */
 function tripal_stock_node_presave($node) {
@@ -802,6 +810,8 @@ function tripal_stock_node_presave($node) {
 }
 
 /**
+ * Implements hook_node_insert(). Acts on all content types.
+ *
  * @ingroup tripal_stock
  */
 function tripal_stock_node_insert($node) {
@@ -825,6 +835,8 @@ function tripal_stock_node_insert($node) {
 }
 
 /**
+ * Implements hook_node_update(). Acts on all content types.
+ *
  * @ingroup tripal_stock
  */
 function tripal_stock_node_update($node) {
@@ -844,6 +856,8 @@ function tripal_stock_node_update($node) {
 }
 
 /**
+ * Implements hook_node_view(). Acts on all content types.
+ *
  * @ingroup tripal_stock
  */
 function tripal_stock_node_view($node, $view_mode, $langcode) {
@@ -904,4 +918,4 @@ function tripal_stock_node_view($node, $view_mode, $langcode) {
       }
       break;
   }
-}
+}

+ 0 - 292
tripal_stock/includes/tripal_stock.sync_stocks.inc

@@ -1,292 +0,0 @@
-<?php
-
-/**
- * @file
- * @todo Add file header description
- */
-
-
-# This script can be run as a stand-alone script to sync all the stocks from chado to drupal
-// Parameter f specifies the stock_id to sync
-// -f 0 will sync all stocks
-
-$arguments = getopt("f:t:");
-
-if (isset($arguments['f']) and isset($arguments['t']) and $arguments['t'] == 'chado_stock') {
-  $drupal_base_url = parse_url('http://www.example.com');
-  $_SERVER['HTTP_HOST'] = $drupal_base_url['host'];
-  $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
-  $_SERVER['REMOTE_ADDR'] = NULL;
-  $_SERVER['REQUEST_METHOD'] = NULL;
-
-  require_once 'includes/bootstrap.inc';
-  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
-
-  $stock_id = $arguments['f'];
-
-  if ($stock_id > 0 ) {
-    tripal_stock_sync_stock($stock_id);
-  }
-  else{
-    print "syncing all stocks...\n";
-    tripal_stock_sync_stocks();
-  }
-}
-/**
- *
- */
-function tripal_stock_sync_form() {
-
-  $form['description'] = array(
-  '#type' => 'item',
-  '#value' => t("Stocks of the types listed ".
-     "below in the Stock Types box will be synced (leave blank to sync all types). You may limit the ".
-     "stocks to be synced by a specific organism. Depending on the ".
-     "number of stocks in the chado database this may take a long ".
-     "time to complete. "),
-  );
-
-  $form['stock_types'] = array(
-    '#title'       => t('Stock Types'),
-    '#type'        => 'textarea',
-    '#description' => t("Enter the names of the stock types to sync. " .
-       "Leave blank to sync all stocks. Pages for these stock ".
-       "types will be created automatically for stocks that exist in the ".
-       "chado database.  The names listed here should be spearated by ".
-       "spaces or entered separately on new lines. The names must match ".
-       "exactly (spelling and case) with terms in the sequence ontology"),
-    '#default_value' => variable_get('chado_sync_stock_types', ''),
-  );
-
-  // get the list of organisms
-  $sql = "SELECT * FROM {organism} ORDER BY genus, species";
-  $orgs = tripal_organism_get_synced();
-  $organisms[] = '';
-  foreach ($orgs as $organism) {
-    $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
-  }
-  $form['organism_id'] = array(
-    '#title'       => t('Organism'),
-    '#type'        => t('select'),
-    '#description' => t("Choose the organism for which stocks types set above will be synced. Only organisms which also have been synced will appear in this list."),
-    '#options'     => $organisms,
-  );
-
-
-  $form['button'] = array(
-    '#type' => 'submit',
-    '#value' => t('Sync all Stocks'),
-    '#weight' => 3,
-  );
-
-  return $form;
-}
-/**
- *
- */
-function tripal_stock_sync_form_validate($form, &$form_state) {
-  $organism_id   = $form_state['values']['organism_id'];
-  $stock_types = $form_state['values']['stock_types'];
-
-  // nothing to do
-}
-/**
- *
- */
-function tripal_stock_sync_form_submit($form, &$form_state) {
-
-  global $user;
-
-  $organism_id   = $form_state['values']['organism_id'];
-  $stock_types = $form_state['values']['stock_types'];
-
-  $job_args = array(0, $organism_id, $stock_types);
-
-  if ($organism_id) {
-    $organism = chado_select_record('organism', array('genus', 'species'), array('organism_id' => $organism_id));
-    $title = "Sync stocks for " .  $organism[0]->genus . " " . $organism[0]->species;
-  }
-  else {
-    $title = 'Sync stocks';
-  }
-
-  variable_set('chado_sync_stock_types', $stock_types);
-
-  tripal_add_job($title, 'tripal_stock', 'tripal_stock_sync_stocks', $job_args, $user->uid);
-}
-/**
- *
- * @param $na
- *   Tripal expects all jobs to have at least one argument. For this function
- *   we don't need any, so we have this dummy argument as a filler
- * @param $job_id
- */
-function tripal_stock_set_urls($na = NULL, $job = NULL) {
-
-  // begin the transaction
-  db_query("BEGIN");
-
-  print "\nNOTE: Setting of URLs is performed using a database transaction. \n" .
-        "If the load fails or is terminated prematurely then the entire set of \n" .
-        "new URLs will be rolled back and no changes will be made\n\n";
-
-  // get the number of records we need to set URLs for
-  $csql = "SELECT count(*) FROM {chado_stock}";
-  $num_nodes = db_query($csql)->fetchField();
-
-  // calculate the interval at which we will print an update on the screen
-  $num_set = 0;
-  $num_per_interval = 100;
-
-  // prepate the statements which will quickly add url alias. Because these
-  // are not Chado tables we must manually prepare them
-  $psql = "
-    PREPARE del_url_alias_by_src (text) AS
-    DELETE FROM {url_alias} WHERE src = \$1
-  ";
-  db_query($psql);
-  $psql = "
-    PREPARE ins_url_alias_nisrds (text, text) AS
-    INSERT INTO url_alias (src, dst) VALUES (\$1, \$2)
-  ";
-  db_query($psql);
-
-  // get the URL alias syntax string
-  $url_alias = variable_get('chado_stock_url_string', '/stock/[genus]/[species]/[type]/[uniquename]');
-  if (!$url_alias) {
-    $url_alias = '/stock/[genus]/[species]/[type]/[uniquename]';
-  }
-  $url_alias = preg_replace('/^\//', '', $url_alias); // remove any preceeding forward slash
-
-
-  // get the list of stocks that have been synced
-  $sql = "SELECT * FROM {chado_stock}";
-  $nodes = db_query($sql);
-  while ($node = $nodes->fetchObject()) {
-
-    // get the URL alias
-    $src = "node/$node->nid";
-    $dst = tripal_stock_get_stock_url($node, $url_alias);
-    if (!$dst) {
-      db_query('DEALLOCATE "del_url_alias_by_src"');
-      db_query('DEALLOCATE "ins_url_alias_nisrds"');
-      db_query("ROLLBACK");
-      return;
-    }
-
-    // if the src and dst is the same (the URL alias couldn't be set)
-    // then skip to the next one. There's nothing we can do about this one.
-    if($src == $dst) {
-      continue;
-    }
-
-    // remove any previous alias and then add the new one
-    $success = db_query("EXECUTE del_url_alias_by_src(':src')", array(':src' => $src));
-    if (!$success) {
-      db_query('DEALLOCATE "del_url_alias_by_src"');
-      db_query('DEALLOCATE "ins_url_alias_nisrds"');
-      db_query("ROLLBACK");
-      tripal_report_error('trp-seturl', TRIPAL_ERROR, "Failed Removing URL Alias: %src", array('%src' => $src));
-      return;
-    }
-    $success = db_query("EXECUTE ins_url_alias_nisrds(:src, :dst)", array(':src' => $src, ':dst' => $dst));
-    if (!$success) {
-      db_query('DEALLOCATE "del_url_alias_by_src"');
-      db_query('DEALLOCATE "ins_url_alias_nisrds"');
-      db_query("ROLLBACK");
-      tripal_report_error('trp-seturl', TRIPAL_ERROR, "Failed Adding URL Alias: %dst", array('%dst' => $dst));
-      return;
-    }
-
-    // update the job status every 1% stocks
-    if ($job and $num_set % $num_per_interval == 0) {
-      $percent = ($num_set / $num_nodes) * 100;
-      tripal_set_job_progress($job, intval($percent));
-      $percent = sprintf("%.2f", $percent);
-      print "Setting URLs (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes.\r";
-
-    }
-    $num_set++;
-  }
-  $percent = ($num_set / $num_nodes) * 100;
-  tripal_set_job_progress($job, intval($percent));
-  $percent = sprintf("%.2f", $percent);
-  print "Setting URLs (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes.\r";
-  print "\nDone. Set " . number_format($num_set) . " URLs\n";
-
-  // unprepare the statements
-  db_query('DEALLOCATE "del_url_alias_by_src"');
-  db_query('DEALLOCATE "ins_url_alias_nisrds"');
-
-  db_query("COMMIT");
-}
-/**
- *
- * @param $node
- *   A node object containing at least the stock_id and nid
- * @param $url_alias
- *   Optional.  This should be the URL alias syntax string that contains
- *   placeholders such as [id], [genus], [species], [name], [uniquename],
- *   and [type].  These placeholders will be substituted for actual values.
- *   If this parameter is not provided then the value of the
- *   chado_stock_url_string Drupal variable will be used.
- */
-function tripal_stock_get_stock_url($node, $url_alias = NULL) {
-
-  // get the starting URL alias
-  if(!$url_alias) {
-    $url_alias = variable_get('chado_stock_url_string', '/stock/[genus]/[species]/[type]/[uniquename]');
-    if (!$url_alias) {
-      $url_alias = '/stock/[genus]/[species]/[type]/[uniquename]';
-    }
-    $url_alias = preg_replace('/^\//', '', $url_alias); // remove any preceeding forward slash
-  }
-
-  // get the stock
-  $values = array('stock_id' => $node->stock_id);
-  $options = array('statement_name' => 'sel_stock_id');
-  $stock = chado_select_record('stock', array('*'), $values, $options);
-  if (!$stock) {
-    tripal_report_error('trp-seturl', TRIPAL_ERROR, "Cannot find stock when setting URL alias for stock: %id", array('%id' => $node->stock_id));
-    return FALSE;
-  }
-  $stock = (object) $stock[0];
-
-  // get the organism
-  $values = array('organism_id' => $stock->organism_id);
-  $options = array('statement_name' => 'sel_organism_id');
-  $organism  = chado_select_record('organism', array('*'), $values, $options);
-  if (!$organism) {
-    tripal_report_error('trp-seturl', TRIPAL_ERROR, "Cannot find organism when setting URL alias for stock: %id", array('%id' => $node->stock_id));
-    return FALSE;
-  }
-  $genus = preg_replace('/\s/', '_', strtolower($organism[0]->genus));
-  $species = preg_replace('/\s/', '_', strtolower($organism[0]->species));
-
-  // get the type
-  $values = array('cvterm_id' => $stock->type_id);
-  $options = array('statement_name' => 'sel_cvterm_id');
-  $cvterm = chado_select_record('cvterm', array('name'), $values, $options);
-  if (!$cvterm) {
-    tripal_report_error('trp-seturl', TRIPAL_ERROR, "Cannot find type when setting URL alias for stock: %id", array('%id' => $node->stock_id));
-    return FALSE;
-  }
-  $type = preg_replace('/\s/', '_', $cvterm[0]->name);
-
-  // now substitute in the values
-  $url_alias = preg_replace('/\[id\]/', $stock->stock_id, $url_alias);
-  $url_alias = preg_replace('/\[genus\]/', $genus, $url_alias);
-  $url_alias = preg_replace('/\[species\]/', $species, $url_alias);
-  $url_alias = preg_replace('/\[type\]/', $type, $url_alias);
-  $url_alias = preg_replace('/\[name\]/', $stock->name, $url_alias);
-  $url_alias = preg_replace('/\[uniquename\]/', $stock->uniquename, $url_alias);
-
-  // the dst field of the url_alias table is only 128 characters long.
-  // if this is the case then simply return the node URL, we can't set this one
-  if (strlen($url_alias) > 128) {
-    tripal_report_error('trp-seturl', TRIPAL_ERROR, "Cannot set alias longer than 128 characters: %alias.", array('%alias' => $url_alias));
-    return "node/" . $node->nid;
-  }
-
-  return $url_alias;
-}

+ 100 - 0
tripal_stock/theme/tripal_stock.theme.inc

@@ -0,0 +1,100 @@
+<?php
+/**
+ * @file
+ * Contains functions related to theme-ing including preprocess hooks
+ */
+
+ /**
+ * Implements hook_preprocess_tripal_stock_relationships() which is the preprocess
+ * hook for the tripal_stock_relationships template
+ *
+ * @ingroup tripal_stock
+ */
+function tripal_stock_preprocess_tripal_stock_relationships(&$variables) {
+  // we want to provide a new variable that contains the matched stocks.
+  $stock = $variables['node']->stock;
+
+  // expand the stock object to include the stock relationships.
+  $options = array(
+    'return_array' => 1,
+    'order_by' => array('rank' => 'ASC'),
+    // we don't want to fully recurse we only need information about the
+    // relationship type and the object and subject stocks (including stock type
+    // and organism)
+    'include_fk' => array(
+      'type_id' => 1,
+      'object_id' => array(
+        'type_id' => 1,
+        'organism_id' => 1
+      ),
+      'subject_id'  => array(
+        'type_id' => 1,
+        'organism_id' => 1
+      ),
+    ),
+  );
+  $stock = chado_expand_var($stock, 'table', 'stock_relationship', $options);
+
+  // get the subject relationships
+  $srelationships = $stock->stock_relationship->subject_id;
+  $orelationships = $stock->stock_relationship->object_id;
+
+  // combine both object and subject relationshisp into a single array
+  $relationships = array();
+  $relationships['object'] = array();
+  $relationships['subject'] = array();
+
+  // iterate through the object relationships
+  if ($orelationships) {
+    foreach ($orelationships as $relationship) {
+      $rel = new stdClass();
+      $rel->record = $relationship;
+
+      // get the relationship and child types
+      $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
+      $child_type = $relationship->subject_id->type_id->name;
+
+      // get the node id of the subject
+      $sql = "SELECT nid FROM {chado_stock} WHERE stock_id = :stock_id";
+      $n = db_query($sql, array(':stock_id' => $relationship->subject_id->stock_id))->fetchObject();
+      if ($n) {
+        $rel->record->nid = $n->nid;
+      }
+
+      if (!array_key_exists($rel_type, $relationships['object'])) {
+        $relationships['object'][$rel_type] = array();
+      }
+      if (!array_key_exists($child_type, $relationships['object'][$rel_type])) {
+        $relationships['object'][$rel_type][$child_type] = array();
+      }
+      $relationships['object'][$rel_type][$child_type][] = $rel;
+    }
+  }
+
+  // now add in the subject relationships
+  if ($srelationships) {
+    foreach ($srelationships as $relationship) {
+      $rel = new stdClass();
+      $rel->record = $relationship;
+      $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
+      $parent_type = $relationship->object_id->type_id->name;
+
+      // get the node id of the subject
+      $sql = "SELECT nid FROM {chado_stock} WHERE stock_id = :stock_id";
+      $n = db_query($sql, array(':stock_id' => $relationship->object_id->stock_id))->fetchObject();
+      if ($n) {
+        $rel->record->nid = $n->nid;
+      }
+
+      if (!array_key_exists($rel_type, $relationships['subject'])) {
+        $relationships['subject'][$rel_type] = array();
+      }
+      if (!array_key_exists($parent_type, $relationships['subject'][$rel_type])) {
+        $relationships['subject'][$rel_type][$parent_type] = array();
+      }
+      $relationships['subject'][$rel_type][$parent_type][] = $rel;
+    }
+  }
+  $stock->all_relationships = $relationships;
+
+}

+ 10 - 3
tripal_stock/tripal_stock.install

@@ -1,13 +1,14 @@
 <?php
-
-
 /**
  * Install the tripal stock module including it's content type
  * @file
  */
 
 /**
+ * Implements hook_disable().
  * Disable default views when module is disabled
+ *
+ * @ingroup tripal_stock
  */
 function tripal_stock_disable() {
 
@@ -23,6 +24,7 @@ function tripal_stock_disable() {
 /**
  * Implementation of hook_requirements().
  *
+ * @ingroup tripal_stock
  */
 function tripal_stock_requirements($phase) {
   $requirements = array();
@@ -41,6 +43,8 @@ function tripal_stock_requirements($phase) {
 
 /**
  * Implementation of hook_install().
+ *
+ * @ingroup tripal_stock
  */
 function tripal_stock_install() {
   // create the module's data directory
@@ -49,14 +53,17 @@ function tripal_stock_install() {
 
 /**
  * Implementation of hook_uninstall().
+ *
+ * @ingroup tripal_stock
  */
-
 function tripal_stock_uninstall() {
 
 }
 
 /**
  * Implementation of hook_schema().
+ *
+ * @ingroup tripal_stock
  */
 function tripal_stock_schema() {
   $schema['chado_stock'] = array(

+ 33 - 116
tripal_stock/tripal_stock.module

@@ -1,10 +1,16 @@
 <?php
-
 /**
  * @file
- * Implements Tripal Stock Module hooks
+ * Basic functionality for stocks
  */
 
+require_once 'api/tripal_stock.api.inc';
+
+require_once 'theme/tripal_stock.theme.inc';
+
+require_once 'includes/tripal_stock.admin.inc';
+require_once 'includes/tripal_stock.chado_node.inc';
+
 /**
  * @defgroup tripal_stock Stock Module
  * @ingroup tripal_modules
@@ -21,15 +27,10 @@
  * Stock Module see the GMOD Wiki Page (http://gmod.org/wiki/Chado_Stock_Module)
  * @}
  */
-require_once("includes/tripal_stock.admin.inc");
-require_once("includes/tripal_stock.sync_stocks.inc");
-require_once("includes/other_module_api_functions.inc");
-require_once("includes/tripal_stock.chado_node.inc");
-
-require_once("api/tripal_stock.api.inc");
 
 /**
- * Implements hook_menu(): Adds menu items for the tripal_stock
+ * Implements hook_menu().
+ * Adds menu items for the tripal_stock
  *
  * @return
  *   Menu definitions for the tripal_stock
@@ -94,7 +95,7 @@ function tripal_stock_menu() {
 /**
  * Implements Menu wildcard_load hook
  *
- * Purpose: Allows the node ID of a chado stock to be dynamically
+ * Allows the node ID of a chado stock to be dynamically
  *   pulled from the path. The node is loaded from this node ID
  *   and supplied to the page as an arguement. This is an example
  *   of dynamic argument replacement using wildcards in the path.
@@ -119,9 +120,8 @@ function cs_node_load($nid) {
 }
 
 /**
- * Implementation of hook_permission().
- *
- * Purpose: Set the permission types that the chado stock module uses
+ * Implements hook_permission().
+ * Set the permission types that the chado stock module uses
  *
  * @return
  *   Listing of the possible permission catagories
@@ -154,7 +154,7 @@ function tripal_stock_permission() {
 }
 
 /**
- * Implement hook_access().
+ * Implement hook_node_access().
  *
  * This hook allows node modules to limit access to the node types they define.
  *
@@ -202,7 +202,7 @@ function chado_stock_node_access($node, $op, $account) {
 }
 
 /**
- * Implements hook_views_api()
+ * Implements hook_views_api().
  *
  * Purpose: Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_stock.views.inc where all the
@@ -215,12 +215,13 @@ function chado_stock_node_access($node, $op, $account) {
  */
 function tripal_stock_views_api() {
   return array(
-    'api' => 2.0,
+    'api' => 3.0,
   );
 }
 
 /**
- * Implements hook_theme(): Register themeing functions for this module
+ * Implements hook_theme().
+ * Register themeing functions for this module
  *
  * @return
  *   An array of themeing functions to register
@@ -318,9 +319,12 @@ function tripal_stock_theme($existing, $type, $theme, $path) {
   );
   return $items;
 }
+
 /**
- * Implements hook_help()
- * Purpose: Adds a help page to the module list
+ * Implements hook_help().
+ * Adds a help page to the module list
+ *
+ * @ingroup tripal_stock
  */
 function tripal_stock_help ($path, $arg) {
   if ($path == 'admin/help#tripal_stock') {
@@ -329,6 +333,8 @@ function tripal_stock_help ($path, $arg) {
 }
 
 /**
+ * Implements hook_block_info().
+ *
  * @ingroup tripal_stock
  */
 function tripal_stock_block_info() {
@@ -364,7 +370,9 @@ function tripal_stock_block_info() {
 
   return $blocks;
 }
+
 /**
+ * Implements hook_block_view().
  *
  * @ingroup tripal_stock
  */
@@ -431,105 +439,13 @@ function tripal_stock_block_view($delta = '') {
   }
 }
 
-/**
- *
- *
- * @ingroup tripal_stock
- */
-function tripal_stock_preprocess_tripal_stock_relationships(&$variables) {
-  // we want to provide a new variable that contains the matched stocks.
-  $stock = $variables['node']->stock;
-
-  // expand the stock object to include the stock relationships.
-  $options = array(
-    'return_array' => 1,
-    'order_by' => array('rank' => 'ASC'),
-    // we don't want to fully recurse we only need information about the
-    // relationship type and the object and subject stocks (including stock type
-    // and organism)
-    'include_fk' => array(
-      'type_id' => 1,
-      'object_id' => array(
-        'type_id' => 1,
-        'organism_id' => 1
-      ),
-      'subject_id'  => array(
-        'type_id' => 1,
-        'organism_id' => 1
-      ),
-    ),
-  );
-  $stock = chado_expand_var($stock, 'table', 'stock_relationship', $options);
-
-  // get the subject relationships
-  $srelationships = $stock->stock_relationship->subject_id;
-  $orelationships = $stock->stock_relationship->object_id;
-
-  // combine both object and subject relationshisp into a single array
-  $relationships = array();
-  $relationships['object'] = array();
-  $relationships['subject'] = array();
-
-  // iterate through the object relationships
-  if ($orelationships) {
-    foreach ($orelationships as $relationship) {
-      $rel = new stdClass();
-      $rel->record = $relationship;
-
-      // get the relationship and child types
-      $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
-      $child_type = $relationship->subject_id->type_id->name;
-
-      // get the node id of the subject
-      $sql = "SELECT nid FROM {chado_stock} WHERE stock_id = :stock_id";
-      $n = db_query($sql, array(':stock_id' => $relationship->subject_id->stock_id))->fetchObject();
-      if ($n) {
-        $rel->record->nid = $n->nid;
-      }
-
-      if (!array_key_exists($rel_type, $relationships['object'])) {
-        $relationships['object'][$rel_type] = array();
-      }
-      if (!array_key_exists($child_type, $relationships['object'][$rel_type])) {
-        $relationships['object'][$rel_type][$child_type] = array();
-      }
-      $relationships['object'][$rel_type][$child_type][] = $rel;
-    }
-  }
-
-  // now add in the subject relationships
-  if ($srelationships) {
-    foreach ($srelationships as $relationship) {
-      $rel = new stdClass();
-      $rel->record = $relationship;
-      $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
-      $parent_type = $relationship->object_id->type_id->name;
-
-      // get the node id of the subject
-      $sql = "SELECT nid FROM {chado_stock} WHERE stock_id = :stock_id";
-      $n = db_query($sql, array(':stock_id' => $relationship->object_id->stock_id))->fetchObject();
-      if ($n) {
-        $rel->record->nid = $n->nid;
-      }
-
-      if (!array_key_exists($rel_type, $relationships['subject'])) {
-        $relationships['subject'][$rel_type] = array();
-      }
-      if (!array_key_exists($parent_type, $relationships['subject'][$rel_type])) {
-        $relationships['subject'][$rel_type][$parent_type] = array();
-      }
-      $relationships['subject'][$rel_type][$parent_type][] = $rel;
-    }
-  }
-  $stock->all_relationships = $relationships;
-
-}
-
 /*
  * Uses the value provided in the $id argument to find all stocks that match
  * that ID by name, stockname or synonym.  If it matches uniquenly to a single
  * stock it will redirect to that stock page, otherwise, a list of matching
  * stocks is shown.
+ *
+ * @ingroup tripal_stock
  */
 function tripal_stock_match_stocks_page($id) {
 
@@ -545,7 +461,6 @@ function tripal_stock_match_stocks_page($id) {
     drupal_goto($id);
   }
 
-
   $sql = "
     SELECT
       S.name, S.uniquename, S.stock_id,
@@ -596,15 +511,17 @@ function tripal_stock_match_stocks_page($id) {
 }
 
 /**
- * Implementation of hook_form_alter()
+ * Implementation of hook_form_alter().
  *
  * @param $form
  * @param $form_state
  * @param $form_id
+ *
+ * @ingroup tripal_stock
  */
 function tripal_stock_form_alter(&$form, &$form_state, $form_id) {
   // turn of preview button for insert/updates
   if ($form_id == "chado_stock_node_form") {
     $form['actions']['preview']['#access'] = FALSE;
   }
-}
+}

+ 12 - 2
tripal_stock/tripal_stock.views_default.inc

@@ -1,8 +1,13 @@
 <?php
+/**
+ * @file
+ * Describes stock default views.
+ */
 
 /**
+ * Implements hook_views_default_views().
  *
- *
+ * @ingroup tripal_stock
  */
 function tripal_stock_views_default_views() {
   $views = array();
@@ -13,6 +18,11 @@ function tripal_stock_views_default_views() {
   return $views;
 }
 
+/**
+ * Default stock administration view
+ *
+ * @ingroup tripal_stock
+ */
 function tripal_stock_defaultview_admin_stocks() {
 
   $view = new view();
@@ -242,4 +252,4 @@ function tripal_stock_defaultview_admin_stocks() {
   $handler->display->display_options['filters']['type_id']['expose']['max_length'] = 40;
   */
   return $view;
-}
+}

+ 10 - 4
tripal_views/api/tripal_views.api.inc

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * API functions for Tripal Views Integration
@@ -169,6 +168,8 @@ function tripal_views_is_lightest_priority_setup($setup_id, $table_name) {
  *   The machine-name of the view to be enabled
  * @param $redirect_link
  *   The path to redirect to. FALSE if no redirect needed
+ *
+ * @ingroup tripal_views_api
  */
 function tripal_views_admin_enable_view($view_name, $redirect_link = FALSE) {
 
@@ -193,6 +194,8 @@ function tripal_views_admin_enable_view($view_name, $redirect_link = FALSE) {
  *   The machine-name of the view to be enabled
  * @param $redirect_link
  *   The path to redirect to. FALSE if no redirect needed
+ *
+ * @ingroup tripal_views_api
  */
 function tripal_views_admin_disable_view($view_name, $redirect_link = FALSE) {
 
@@ -212,6 +215,8 @@ function tripal_views_admin_disable_view($view_name, $redirect_link = FALSE) {
 
 /**
  * Purpose: Deletes ALL Tripal Views Integrations.
+ *
+ * @ingroup tripal_views_api
  */
 function tripal_views_delete_all_integrations() {
 
@@ -224,12 +229,13 @@ function tripal_views_delete_all_integrations() {
 
 }
 
-
 /**
  * Rebuilds all the default integrations
  *
  * @param $delete_first
  *   If TRUE then all integrations are first deleted.
+ *
+ * @ingroup tripal_views_api
  */
 function tripal_views_rebuild_views_integrations($delete_first = FALSE) {
 
@@ -645,7 +651,7 @@ function tripal_views_get_integration_array_for_chado_table($table_name, $base_t
   );
   // Add fields
   if (!isset($schema['fields'])) {
-    tripal_report_error('tripal_views', TRIPAL_NOTICE, 
+    tripal_report_error('tripal_views', TRIPAL_NOTICE,
       'There are no fields defined for %table in the Chado Schema API.', array('%table' => $table_name));
     return FALSE;
   }
@@ -1041,4 +1047,4 @@ function tripal_views_remove_join_from_integration($setup_id, $base_table, $base
       ':left-field' => $left_field
     )
   );
-}
+}

+ 14 - 12
tripal_views/includes/tripal_views_integration.inc

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * Functions related to the UI for integrating tables with views
@@ -13,7 +12,7 @@
  * @return
  *    a themed HTML table
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 function tripal_views_integration_setup_list() {
   $output = '';
@@ -127,7 +126,7 @@ function tripal_views_integration_setup_list() {
  * @param $setup_id
  *    the unique setup id for the integrated table
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 function tripal_views_integration_delete($setup_id) {
 
@@ -142,7 +141,7 @@ function tripal_views_integration_delete($setup_id) {
  *   function is meant to be called from a menu item. After completion it
  *   redirects the user to the views intergation page.
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 function tripal_views_integration_delete_all_form ($form, $form_state) {
 
@@ -184,7 +183,7 @@ function tripal_views_integration_delete_all_form ($form, $form_state) {
  *   function is meant to be called from a menu item. After completion it
  *   redirects the user to the views intergation page.
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 function tripal_views_integration_delete_all_form_submit ($form, &$form_state) {
 
@@ -212,7 +211,7 @@ function tripal_views_integration_delete_all_form_submit ($form, &$form_state) {
  * D7 @todo: Add ability to manage custom fields
  * D7 @todo: Update relationship handler to work with the new tripal_views_join method
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 function tripal_views_integration_form($form, $form_state, $arg) {
 
@@ -994,7 +993,6 @@ function tripal_views_integration_form($form, $form_state, $arg) {
   return $form;
 }
 
-
 /**
  * Purpose: validates the tripal_views_integration_form after submission
  *
@@ -1004,7 +1002,7 @@ function tripal_views_integration_form($form, $form_state, $arg) {
  * @param $form_state
  *    The form state pbject which is passed automatically by drupal
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 function tripal_views_integration_form_validate($form, &$form_state) {
   $name_array = explode(" ", $form_state['values']['row_name']);
@@ -1039,7 +1037,7 @@ function tripal_views_integration_form_validate($form, &$form_state) {
  * @param $form_state
  *    The form state pbject which is passed automatically by drupal
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 function tripal_views_integration_form_submit($form, &$form_state) {
   $name = $form_state['values']['row_name'];
@@ -1196,7 +1194,7 @@ function tripal_views_integration_form_submit($form, &$form_state) {
  * @return
  *   Returns an array of handler names
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 function tripal_views_integration_discover_handlers() {
 
@@ -1273,6 +1271,8 @@ function tripal_views_integration_discover_handlers() {
 /*
  * Ajax Callback: Tripal Views Integration Form
  * Replaces the entire fields table when the table or materialized view is set/changed
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_integration_ajax_view_setup_table($form, $form_state) {
   return $form['view_setup_table'];
@@ -1281,6 +1281,8 @@ function tripal_views_integration_ajax_view_setup_table($form, $form_state) {
 /*
  * Ajax Callback: Tripal Views Integration Form
  * Replaces the join db field dropdown when the join table dropdown is changed
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_integration_ajax_join_field($form, $form_state) {
 
@@ -1292,8 +1294,8 @@ function tripal_views_integration_ajax_join_field($form, $form_state) {
     return $form['view_setup_table'][$field]['column-3'][$join_field];
   }
   else {
-    tripal_report_error('tripal_views', TRIPAL_ERROR, 
+    tripal_report_error('tripal_views', TRIPAL_ERROR,
       'Tripal Views Integration Ajax failed due to being unable to determine which row needs updating', array());
     return $form;
   }
-}
+}

+ 23 - 7
tripal_views/includes/tripal_views_integration_port.inc

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @file
  * This file contains the UI to import/export tripal views integration setups
@@ -7,19 +6,29 @@
  */
 
 /**
- * The form to export a particular tripal views integration
+ * Form: The form to export a particular tripal views integration
+ *
+ * No submit is needed since the setup_id is in the path and the export code is
+ * rendered based on that
+ *
+ * @param $form_state
+ *   The state of the form
+ * @param $setup_id
+ *   The tripal views integration setup id
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_integration_export_form($form_state, $setup_id) {
   $form = array();
 
   $defn_array = tripal_views_integration_export_entry($setup_id);
-  
+
   $t = var_export($defn_array, TRUE);
   $t = preg_replace("/\n\s+array/", "array", $t); // move array( to previous line
   $t = preg_replace("/true/", "TRUE", $t); // upper case true
   $t = preg_replace("/false/", "FALSE", $t); // upper case false
-  $t = preg_replace("/array\(/", "array (", $t); // put a space between array and paren   
-        
+  $t = preg_replace("/array\(/", "array (", $t); // put a space between array and paren
+
   $form['export'] = array(
     '#type' => 'textarea',
     '#title' => 'Export',
@@ -33,7 +42,9 @@ function tripal_views_integration_export_form($form_state, $setup_id) {
 }
 
 /**
- * Imports a tripal views integration
+ * Form: Imports a tripal views integration
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_integration_import_form() {
   $form = array();
@@ -76,7 +87,12 @@ function tripal_views_integration_import_form() {
 }
 
 /**
- * Imports a tripal views integration
+ * Submit: Imports a tripal views integration
+ *
+ * @param $form
+ * @param $form_state
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_integration_import_form_submit($form, &$form_state) {
 

+ 5 - 2
tripal_views/tripal_views.install

@@ -1,14 +1,13 @@
 <?php
-
 /**
  * @file
  * Functions related to installing/uninstalling this module
  */
 
-
 /**
  * Implementation of hook_requirements().
  *
+ * @ingroup tripal_views
  */
 function tripal_views_requirements($phase) {
   $requirements = array();
@@ -74,6 +73,8 @@ function tripal_views_get_schemas() {
  *   - Add priority field to tripal_views
  *   - Add handler field to tripal_views_join
  *   - Add tripal_views_field table to keep track of fields for views integration
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_update_6040() {
 
@@ -131,6 +132,8 @@ function tripal_views_update_6040() {
  * Tripal Views Update for 7.x-2.0
  *   - Add relationship_only field to tripal_views_join
  *   - Add relationship_handler field to tripal_views_join
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_update_7020() {
 

+ 26 - 28
tripal_views/tripal_views.module

@@ -1,4 +1,8 @@
 <?php
+/**
+ * @file
+ * Basic Tripal Views functionality
+ */
 
 /**
  * @defgroup tripal_views Tripal Views Module
@@ -8,14 +12,14 @@
  * @}
  */
 
-require_once "tripal_views.views.inc";
+require_once 'tripal_views.views.inc';
 
-require_once "includes/tripal_views_integration.inc";
-require_once "includes/tripal_views_integration_port.inc";
+require_once 'includes/tripal_views_integration.inc';
+require_once 'includes/tripal_views_integration_port.inc';
 
 /**
- * Implements hook_menu()
- * Purpose: this hook provides details about new menu items added by this module
+ * Implements hook_menu().
+ * This hook provides details about new menu items added by this module
  *
  * @ingroup tripal_views
  */
@@ -136,6 +140,8 @@ function tripal_views_menu() {
 
 /**
  * Implements hook_init().
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_init() {
 
@@ -153,8 +159,10 @@ function tripal_views_init() {
 }
 
 /**
- * Implements hook_help()
- * Purpose: Adds a help page to the module list
+ * Implements hook_help().
+ * Adds a help page to the module list
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_help ($path, $arg) {
   if ($path == 'admin/help#tripal_views') {
@@ -179,7 +187,7 @@ function tripal_views_permission() {
 }
 
 /**
- * Implements hook_views_api()
+ * Implements hook_views_api().
  *
  * Purpose: Essentially this hook tells drupal that there is views support for
  *  for this module which then includes tripal_views.views.inc where all the
@@ -194,9 +202,9 @@ function tripal_views_views_api() {
 }
 
 /**
- * Implements hook_theme()
+ * Implements hook_theme().
  *
- * Purpose: this hook provides details about themable objects added by
+ * This hook provides details about themable objects added by
  *   this module
  *
  * @ingroup tripal_views
@@ -225,6 +233,8 @@ function tripal_views_theme($existing, $type, $theme, $path) {
 /**
  * Implements hook_coder_ignore().
  * Defines the path to the file (tripal_views.coder_ignores.txt) where ignore rules for coder are stored
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_coder_ignore() {
   return array(
@@ -236,6 +246,8 @@ function tripal_views_coder_ignore() {
 /**
  * A landing page for all views of chado content. Simply lists all menu items that
  * are children of it.
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_biological_data_page() {
   $output = '';
@@ -253,25 +265,11 @@ function tripal_views_biological_data_page() {
   return $output;
 }
 
-/*
+/**
+ * Admin launchpad
  *
+ * @ingroup tripal_views
  */
-function tripal_views_form_alter($form, $form_state, $form_id) {
-  if ($form_id == "tripal_views_integration_form") {
-    // updating the form through the ahah callback sets the action of
-    // the form to the ahah callback URL. We need to set it back
-    // to the normal form URL
-    /**
-    if (isset($form_state['input']['setup_id'])) {
-      $form['#action'] = url("admin/tripal/views/integration/edit/" . $form_state['input']['setup_id']);
-    }
-    else {
-      $form['#action'] = url("admin/tripal/views/integration/new");
-    }
-    */
-  }
-}
-
 function tripal_views_admin_integration_view() {
   $output = '';
 
@@ -299,4 +297,4 @@ function tripal_views_admin_integration_view() {
   }
 
   return $output;
-}
+}

+ 15 - 47
tripal_views/tripal_views.views.inc

@@ -1,51 +1,14 @@
 <?php
-
-include('api/tripal_views.api.inc');
-include('views/handlers/tripal_views_handler_area_action_links.inc');
-
 /**
  * @file
  * Tripal Views Integration
  */
 
-/**
- * @defgroup views_handlers Views Integration Handlers
- * @ingroup views
- * @{
- * Provide rules for formatting and composition of fields
- * @}
- */
-/**
- * @defgroup views_field_handlers Views Field Handlers
- * @ingroup views_handlers
- * @{
- * Provide rules for formatting and composition of fields
- * @}
- */
-/**
- * @defgroup views_filter_handlers Views Filter Handlers
- * @ingroup views_handlers
- * @{
- * Provide the ability to filter based on specified data
- * @}
- */
-/**
- * @defgroup views_sort_handlers Views Sort Handlers
- * @ingroup views_handlers
- * @{
- * Provide methods describing how specific data should be sorted
- * @}
- */
-/**
- * @defgroup views_argument_handlers Views Arguement Handlers
- * @ingroup views_handlers
- * @{
- * Provide the ability to filter pased on arguments in the path of the view
- * @}
- */
+include 'api/tripal_views.api.inc';
+include 'views/handlers/tripal_views_handler_area_action_links.inc';
 
 /**
- * Implements hook_views_handlers()
+ * Implements hook_views_handlers().
  *
  * Purpose: Register all custom handlers with views
  *   where a handler describes either "the type of field",
@@ -105,7 +68,7 @@ function tripal_views_views_handlers() {
 }
 
 /**
- * Implements hook_views_pre_render
+ * Implements hook_views_pre_render().
  *
  * Purpose: Intercepts the view after the query has been executed
  *   All the results are stored in $view->result
@@ -131,9 +94,10 @@ function tripal_views_views_pre_render(&$view) {
 }
 
 /**
+ * Implements hook_views_date().
  * Generates a dynamic data array for Views
  *
- * Purpose: This function is a hook used by the Views module. It populates and
+ * This function is a hook used by the Views module. It populates and
  *   returns a data array that specifies for the Views module the base table,
  *   the tables it joins with and handlers.  The data array is populated
  *   using the data stored in the tripal_views tables.
@@ -370,7 +334,9 @@ function tripal_views_views_data() {
 }
 
 /**
+ * Describes the tripal views integration tables to views for the administration views
  *
+ * @ingroup tripal_views
  */
 function tripal_views_views_data_tripal_views_tables($data) {
 
@@ -607,12 +573,14 @@ function tripal_views_views_data_alter(&$data) {
 
 /**
  * Implementation of hook_views_pre_view().
+ *
+ * Merge the $_GET and $_POST into the $_GET. This is because
+ * Views and Views Data Export modules only uses the $_GET variable but
+ * file uploads require $_POST. We need to make sure these two modules
+ * have access to everything needed for this view to work properly.
+ *
+ * @ingroup tripal_views
  */
 function tripal_views_views_pre_view(&$view, &$display_id, &$args) {
-
-  // merge the $_GET and $_POST into the $_GET. This is because
-  // Views and Views Data Export modules only uses the $_GET variable but
-  // file uploads require $_POST. We need to make sure these two modules
-  // have access to everything needed for this view to work properly
   $_GET = array_merge($_GET, $_POST);
 }

+ 10 - 2
tripal_views/tripal_views.views_default.inc

@@ -1,7 +1,10 @@
 <?php
+/**
+ * Describes default views for tripal views integrations
+ */
 
 /**
- *
+ * Implements hook_views_default_views().
  *
  * @ingroup tripal_views
  */
@@ -14,6 +17,11 @@ function tripal_views_views_default_views() {
   return $views;
 }
 
+/**
+ * Default integrations administration view
+ *
+ * @ingroup tripal_views
+ */
 function tripal_views_defaultview_admin_integrations() {
 
   $view = new view();
@@ -312,4 +320,4 @@ function tripal_views_defaultview_admin_integrations() {
   $handler->display->display_options['tab_options']['weight'] = '0';
 
   return $view;
-}
+}

+ 22 - 1
tripal_views/views/handlers/tripal_views_handler_area_action_links.inc

@@ -1,7 +1,19 @@
 <?php
-
+/**
+ * @file
+ * Contains tripal_views_handler_area_action_links Area Handler
+ */
+
+/**
+ * Provides an area for adding action links to a view.
+ *
+ * @ingroup tripal_views
+ */
 class tripal_views_handler_area_action_links extends views_handler_area {
 
+  /**
+   * {@inheritdoc}
+   */
   function option_definition() {
     $options = parent::option_definition();
 
@@ -20,6 +32,9 @@ class tripal_views_handler_area_action_links extends views_handler_area {
     return $options;
   }
 
+  /**
+   * {@inheritdoc}
+   */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
 
@@ -103,6 +118,9 @@ class tripal_views_handler_area_action_links extends views_handler_area {
 
   }
 
+  /**
+   * {@inheritdoc}
+   */
   function options_submit(&$form, &$form_state) {
     parent::options_submit($form, $form_state);
     ddl($form_state, 'form state in submit');
@@ -119,6 +137,9 @@ class tripal_views_handler_area_action_links extends views_handler_area {
     $this->options['link-4']['path-4'] = $form_state['values']['options']['link-4']['path-4'];
   }
 
+  /**
+   * {@inheritdoc}
+   */
   function render($empty = FALSE) {
     if (!$empty || !empty($this->options['empty'])) {
       $output = '<ul class="action-links">';

+ 13 - 9
tripal_views/views/handlers/tripal_views_handler_field_sequence.inc

@@ -1,16 +1,19 @@
 <?php
-
 /**
  * @file
- * A chado wrapper for the views_handler_field.
- *
+ * Contains tripal_views_handler_field_sequence
+ */
+
+/**
  * Handles display of sequence data.  If will aggregate sequences that need
  * to be aggregated (e.g. coding sequences) and provide
+ *
+ * @ingroup tripal_views
  */
 class tripal_views_handler_field_sequence extends views_handler_field {
 
   /**
-   * Defines the options form (form available to admin when they add a field to a view)
+   * {@inheritdoc}
    */
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
@@ -69,8 +72,8 @@ class tripal_views_handler_field_sequence extends views_handler_field {
   }
 
   /**
-  * We need to add a few fields to our query
-  */
+   * {@inheritdoc}
+   */
   function query() {
     parent::query();
 
@@ -85,8 +88,10 @@ class tripal_views_handler_field_sequence extends views_handler_field {
   }
 
   /**
-  * Prior to display of results we want to format the sequence
-  */
+   * {@inheritdoc}
+   *
+   * Prior to display of results we want to format the sequence
+   */
   function render($values) {
     $residues = '';
 
@@ -260,5 +265,4 @@ class tripal_views_handler_field_sequence extends views_handler_field {
     return $residues;
   }
 
-
 }

+ 9 - 8
tripal_views/views/handlers/tripal_views_handler_filter_file_upload.inc

@@ -1,17 +1,19 @@
 <?php
-
 /**
  * @file
- * Purpose: This Handler provides a file upload field by extending the
+ * Contains tripal_views_handler_filter_file_upload filter handler
+ */
+
+/**
+ * This Handler provides a file upload field by extending the
  * views_handler_filter object.
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 class tripal_views_handler_filter_file_upload extends views_handler_filter {
 
   /**
-   * Defines the value field in both the views filter options form
-   *   and the exposed form
+   * {@inheritdoc}
    */
   function value_form(&$form, &$form_state) {
     parent::value_form($form, $form_state);
@@ -28,8 +30,7 @@ class tripal_views_handler_filter_file_upload extends views_handler_filter {
   }
 
   /**
-   * Ensures the upload field gets rendered when the filter is exposed. It also
-   * changes the form type from a GET to a POST so that file uploads will work.
+   * {@inheritdoc}
    */
   function exposed_form(&$form, &$form_state) {
 
@@ -57,7 +58,7 @@ class tripal_views_handler_filter_file_upload extends views_handler_filter {
   }
 
   /**
-   * Add the where clause
+   * {@inheritdoc}
    */
   function query() {
     $this->ensure_my_table();

+ 10 - 2
tripal_views/views/handlers/tripal_views_handler_filter_no_results.inc

@@ -1,10 +1,15 @@
 <?php
-
 /**
  * @file
+ * Contains tripal_views_handler_filter_no_results
+ */
+
+/**
  * This filter ensures that when a page is first loaded, there are no results (ie: the
  * query is not run). This imitates an advanced search form allowing users to fist
  * enter other filter values and then retrieve results.
+ *
+ * @ingroup tripal_views
  */
 class tripal_views_handler_filter_no_results extends views_handler_filter {
 
@@ -16,7 +21,7 @@ class tripal_views_handler_filter_no_results extends views_handler_filter {
   }
 
   /**
-   * Defines the options form (form available to admin when they add a field to a view)
+   * {@inheritdoc}
    */
   function options_form(&$form, &$form_state) {
 
@@ -46,6 +51,9 @@ class tripal_views_handler_filter_no_results extends views_handler_filter {
 
   }
 
+  /**
+   * {@inheritdoc}
+   */
   function query() {
     global $base_url;
     $jquery_loaded = FALSE;

+ 6 - 4
tripal_views/views/handlers/tripal_views_handler_filter_select_cvterm.inc

@@ -1,14 +1,16 @@
 <?php
-
 /**
  * @file
- * Purpose: This Handler provides a select list for the type field
+ * Contains tripal_views_handler_filter_select_cvterm
+ */
+
+/**
+ * This Handler provides a select list for the type field
  *
  *  NOTE: This handler only works when applied to the type_id field in the base_table of
  *  this view.
  *
- * @ingroup views_filter_handlers
- * @ingroup tripal_core
+ * @ingroup tripal_views
  */
 class tripal_views_handler_filter_select_cvterm extends tripal_views_handler_filter_select_string {
 

+ 19 - 15
tripal_views/views/handlers/tripal_views_handler_filter_select_string.inc

@@ -1,17 +1,19 @@
 <?php
-
 /**
  * @file
- * Purpose: This Handler provides a generic select list for any chado field that is a string
+ * Contains tripal_views_handler_filter_select_string Filter Handler
+ */
+
+/**
+ * This Handler provides a generic select list for any chado field that is a string
  *  The select list includes all distinct values for that field.
  *
- * @ingroup views_filter_handlers
- * @ingroup tripal_core
+ * @ingroup tripal_views
  */
 class tripal_views_handler_filter_select_string extends views_handler_filter_string {
 
   /**
-   * Define our new options (needed for export!)
+   * {@inheritdoc}
    */
   function options_definition() {
     $options = parent::option_definition();
@@ -95,6 +97,9 @@ class tripal_views_handler_filter_select_string extends views_handler_filter_str
     return $options;
   }
 
+  /**
+   * {@inheritdoc}
+   */
   function expose_form(&$form, &$form_state) {
     parent::expose_form($form, $form_state);
 
@@ -141,7 +146,7 @@ class tripal_views_handler_filter_select_string extends views_handler_filter_str
   }
 
   /**
-   * Set values for my options
+   * {@inheritdoc}
    */
   function expose_submit($form, &$form_state) {
     $this->options['expose']['values_form_type'] = $form_state['values']['options']['expose']['values_form_type'];
@@ -151,7 +156,7 @@ class tripal_views_handler_filter_select_string extends views_handler_filter_str
   }
 
   /**
-   * Assign defaults for our new options
+   * {@inheritdoc}
    */
   function expose_options() {
     $this->options['expose']['values_form_type'] = 'textfield';
@@ -160,10 +165,9 @@ class tripal_views_handler_filter_select_string extends views_handler_filter_str
     $this->options['expose']['max_length'] = 40;
   }
 
- /**
-  * Defines the value field in both the views filter options form
-  *   and the exposed form
-  */
+  /**
+   * {@inheritdoc}
+   */
   function value_form(&$form, &$form_state) {
     parent::value_form($form, $form_state);
 
@@ -195,7 +199,7 @@ class tripal_views_handler_filter_select_string extends views_handler_filter_str
   }
 
   /**
-   * Ensure the value form gets exposed correctly
+   * {@inheritdoc}
    */
   function exposed_form(&$form, &$form_state) {
     parent::exposed_form($form, $form_state);
@@ -207,9 +211,9 @@ class tripal_views_handler_filter_select_string extends views_handler_filter_str
     }
   }
 
- /**
-  * Adds this filter to the where clause of the views query
-  */
+  /**
+   * {@inheritdoc}
+   */
   function query() {
 
     // make optional

+ 16 - 13
tripal_views/views/handlers/tripal_views_handler_filter_sequence.inc

@@ -1,17 +1,19 @@
 <?php
-
 /**
  * @file
- * Purpose: This Handler provides a file upload field by extending the
+ * Contains tripal_views_handler_filter_sequence Filter handler
+ */
+
+/**
+ * This Handler provides a file upload field by extending the
  * views_handler_filter object.
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 class tripal_views_handler_filter_sequence extends views_handler_filter {
- 
- /**
-   * Defines the value field in both the views filter options form
-   *   and the exposed form
+
+  /**
+   * {@inheritdoc}
    */
   function value_form(&$form, &$form_state) {
     parent::value_form($form, $form_state);
@@ -20,12 +22,13 @@ class tripal_views_handler_filter_sequence extends views_handler_filter {
        '#type' => 'sequence_combo',
        '#title' => t('%label', array('%label' => $this->options['expose']['label'])),
        '#default_value' => $this->value,
-       '#multiple' => FALSE,       
+       '#multiple' => FALSE,
     );
     $form['value'] = &$this->value_form;
   }
 
   /**
+   * {@inheritdoc}
    * Ensures the upload field gets rendered when the filter is exposed. It also
    * changes the form type from a GET to a POST so that file uploads will work.
    */
@@ -49,16 +52,16 @@ class tripal_views_handler_filter_sequence extends views_handler_filter {
     }
   }
 
- 
+
   /**
-   *
+   * {@inheritdoc}
    */
   function query() {
     $this->ensure_my_table();
 
     $upstream = $this->value[0]['upstream'];
-    $downstream = $this->value[0]['downstream'];       
-    
+    $downstream = $this->value[0]['downstream'];
+
     // we need the values provided by the user so that the field
     // handler can generate the results properly.  Saving these as session
     // variables may not be the best way but it works.
@@ -67,6 +70,6 @@ class tripal_views_handler_filter_sequence extends views_handler_filter {
     }
     if ($downstream) {
       $_SESSION['downstream'] = $downstream;
-    }    
+    }
   }
 }

+ 9 - 7
tripal_views/views/handlers/tripal_views_handler_filter_textarea.inc

@@ -1,17 +1,19 @@
 <?php
-
 /**
  * @file
- * Purpose: This Handler provides a file upload field by extending the
+ * Contants tripal_views_handler_filter_textarea Filter Handler
+ */
+
+/**
+ * This Handler provides a file upload field by extending the
  * views_handler_filter object.
  *
- * @ingroup tripal_views_integration
+ * @ingroup tripal_views
  */
 class tripal_views_handler_filter_textarea extends views_handler_filter {
 
   /**
-   * Defines the value field in both the views filter options form
-   *   and the exposed form
+   * {@inheritdoc}
    */
   function value_form(&$form, &$form_state) {
     parent::value_form($form, $form_state);
@@ -28,7 +30,7 @@ class tripal_views_handler_filter_textarea extends views_handler_filter {
   }
 
   /**
-   * Ensures the textarea field gets rendered when the filter is exposed.
+   * {@inheritdoc}
    */
   function exposed_form(&$form, &$form_state) {
 
@@ -53,7 +55,7 @@ class tripal_views_handler_filter_textarea extends views_handler_filter {
   }
 
   /**
-   *
+   * {@inheritdoc}
    */
   function query() {
 

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.