Переглянути джерело

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

Stephen Ficklin 11 роки тому
батько
коміт
87555e96cc
44 змінених файлів з 1238 додано та 1097 видалено
  1. 12 7
      tripal_core/api/tripal_core.DEPRECATED.inc
  2. 22 77
      tripal_core/api/tripal_core.chado_nodes.properties.api.inc
  3. 19 6
      tripal_feature/api/tripal_feature.api.inc
  4. 9 5
      tripal_project/includes/tripal_project.admin.inc
  5. 17 16
      tripal_project/includes/tripal_project.chado_node.inc
  6. 20 8
      tripal_project/tripal_project.install
  7. 29 17
      tripal_project/tripal_project.module
  8. 12 3
      tripal_project/tripal_project.views_default.inc
  9. 78 15
      tripal_pub/api/tripal_pub.api.inc
  10. 94 18
      tripal_pub/includes/importers/tripal_pub.AGL.inc
  11. 120 13
      tripal_pub/includes/importers/tripal_pub.PMID.inc
  12. 24 10
      tripal_pub/includes/tripal_pub.admin.inc
  13. 91 68
      tripal_pub/includes/tripal_pub.chado_node.inc
  14. 51 31
      tripal_pub/includes/tripal_pub.pub_citation.inc
  15. 91 59
      tripal_pub/includes/tripal_pub.pub_importers.inc
  16. 64 38
      tripal_pub/includes/tripal_pub.pub_search.inc
  17. 8 2
      tripal_pub/tripal_pub.drush.inc
  18. 25 10
      tripal_pub/tripal_pub.install
  19. 38 33
      tripal_pub/tripal_pub.module
  20. 12 2
      tripal_pub/tripal_pub.views_default.inc
  21. 3 4
      tripal_stock/api/tripal_stock.api.inc
  22. 0 64
      tripal_stock/includes/other_module_api_functions.inc
  23. 12 6
      tripal_stock/includes/tripal_stock.admin.inc
  24. 25 11
      tripal_stock/includes/tripal_stock.chado_node.inc
  25. 0 292
      tripal_stock/includes/tripal_stock.sync_stocks.inc
  26. 100 0
      tripal_stock/theme/tripal_stock.theme.inc
  27. 10 3
      tripal_stock/tripal_stock.install
  28. 33 116
      tripal_stock/tripal_stock.module
  29. 12 2
      tripal_stock/tripal_stock.views_default.inc
  30. 10 4
      tripal_views/api/tripal_views.api.inc
  31. 14 12
      tripal_views/includes/tripal_views_integration.inc
  32. 23 7
      tripal_views/includes/tripal_views_integration_port.inc
  33. 5 2
      tripal_views/tripal_views.install
  34. 26 28
      tripal_views/tripal_views.module
  35. 15 47
      tripal_views/tripal_views.views.inc
  36. 10 2
      tripal_views/tripal_views.views_default.inc
  37. 22 1
      tripal_views/views/handlers/tripal_views_handler_area_action_links.inc
  38. 13 9
      tripal_views/views/handlers/tripal_views_handler_field_sequence.inc
  39. 9 8
      tripal_views/views/handlers/tripal_views_handler_filter_file_upload.inc
  40. 10 2
      tripal_views/views/handlers/tripal_views_handler_filter_no_results.inc
  41. 6 4
      tripal_views/views/handlers/tripal_views_handler_filter_select_cvterm.inc
  42. 19 15
      tripal_views/views/handlers/tripal_views_handler_filter_select_string.inc
  43. 16 13
      tripal_views/views/handlers/tripal_views_handler_filter_sequence.inc
  44. 9 7
      tripal_views/views/handlers/tripal_views_handler_filter_textarea.inc

+ 12 - 7
tripal_core/api/tripal_core.DEPRECATED.inc

@@ -622,12 +622,18 @@ function tripal_update_mview($mview_id) {
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
  * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by @see chado_delete_property().
+ * This function is considered to be no easier to use than chado_delete_record directly
+ * @see chado_delete_record().
  */
-function tripal_core_delete_property_by_id($basetable, $record_id) {
-  //New API Function
-  // D7 @todo: change parameters
-  return chado_delete_property($basetable, $record_id);
+function tripal_core_delete_property_by_id($basetable, $property_id) {
+
+  // construct the array that will match the exact record to update
+  $match = array(
+    $basetable.'prop_id' => $property_id,
+  );
+
+  return chado_delete_record($basetable.'prop', $match);
+
 }
 
 /**
@@ -680,8 +686,7 @@ $cv_name, $value, $update_if_present = 0) {
 function tripal_core_update_property_by_id($basetable, $record_id, $property,
 $cv_name, $value) {
   //New API Function
-  // D7 @todo: change parameters
-  return chado_update_property($basetable, $record_id, $property, $cv_name, $value);
+  return chado_update_property($basetable, FALSE, $property, $cv_name, $value, FALSE, $record_id);
 }
 
 /**

+ 22 - 77
tripal_core/api/tripal_core.chado_nodes.properties.api.inc

@@ -118,7 +118,7 @@
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_get_property($basetable, $record_id, $property, $cv_name) {
+function chado_get_property($basetable, $record_id, $property, $cv_name, $property_id = FALSE) {
   // get the foreign key for this property table
   $table_desc = chado_get_schema($basetable . 'prop');
   $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
@@ -134,6 +134,11 @@ function chado_get_property($basetable, $record_id, $property, $cv_name) {
       'is_obsolete' => 0
     ),
   );
+  // if we have the unique property_id make sure to add that to the values
+  if ($property_id) {
+    $property_pkey = $table_desc['primary key'][0];
+    $values[$property_pkey] = $property_id;
+  }
   $results = chado_generate_var($basetable . 'prop', $values);
   if ($results) {
     $results = chado_expand_var($results, 'field', $basetable . 'prop.value');
@@ -272,10 +277,10 @@ $cv_name, $value, $update_if_present = 0) {
  * @ingroup tripal_chado_node_api
  */
 function chado_update_property($basetable, $record_id, $property,
-$cv_name, $value, $insert_if_missing = 0) {
+$cv_name, $value, $insert_if_missing = FALSE, $property_id = FALSE) {
 
   // first see if the property is missing (we can't update a missing property
-  $prop = chado_get_property($basetable, $record_id, $property, $cv_name);
+  $prop = chado_get_property($basetable, $record_id, $property, $cv_name, $property_id);
   if (count($prop)==0) {
     if ($insert_if_missing) {
       return chado_insert_property($basetable, $record_id, $property, $cv_name, $value);
@@ -299,61 +304,29 @@ $cv_name, $value, $insert_if_missing = 0) {
       'name' => $property,
     ),
   );
+  // If we have the unique property_id, make sure to use it in the match to ensure
+  // we get the exact record. Doesn't rely on there only being one property of that type
+  if ($property_id) {
+    $property_pkey = $table_desc['primary key'][0];
+    $match = array(
+      $property_pkey => $property_id
+    );
+  }
 
   // construct the array of values to be updated
   $values = array(
     'value' => $value,
   );
-
-  return chado_update_record($basetable . 'prop', $match, $values);
-}
-
-/**
- * Update a property for a given base table record.  This function should be
- * used if multiple records of the same property will be present. Also, use this
- * function to change the property name of an existing property.
- *
- * @param $basetable
- *   The base table for which the property should be updated. The property table
- *   is constructed using  a combination of the base table name and the suffix
- *   'prop' (e.g. basetable = feature then property tabie is featureprop).
- * @param $record_id
- *   The primary key of the base table. This should be in integer.
- *   For example, if the basetable is 'feature' then the $record_id should be the featureprop_id
- * @param $property
- *   The cvterm name of property to be updated
- * @param $cv_name
- *   The name of the cv that the above cvterm is part of
- * @param $value
- *   The value of the property to be inserted (can be empty)
- *
- * @return
- *   Return True on Update/Insert and False otherwise
- *
- * @ingroup tripal_chado_node_api
- */
-function chado_update_propertyID($basetable, $record_id, $property,
-$cv_name, $value) {
-
-  // get the primary key for this property table
-  $table_desc = chado_get_schema($basetable . 'prop');
-  $pkcol = $table_desc['primary key'][0];
-
-  // construct the array that will match the exact record to update
-  $match = array(
-    $pkcol => $record_id,
-  );
-
-  // construct the array of values to be updated
-  $values = array(
-    'type_id' => array(
+  // If we have the unique property_id then we can also update the type
+  // thus add it to the values to be updated
+  if ($property_id) {
+    $values['type_id'] = array(
       'cv_id' => array(
         'name' => $cv_name,
       ),
       'name' => $property,
-    ),
-    'value' => $value,
-  );
+    );
+  }
 
   return chado_update_record($basetable . 'prop', $match, $values);
 }
@@ -398,34 +371,6 @@ function chado_delete_property($basetable, $record_id, $property, $cv_name) {
   return chado_delete_record($basetable . 'prop', $match);
 }
 
-/**
- * Deletes a property using the property ID
- *
- * @param $basetable
- *   The base table for which the property should be deleted. Thus to deleted a property
- *   for a feature the basetable=feature and property is deleted from featureprop
- * @param $record_id
- *   The primary key of the basetable to delete a property for. This should be in integer.
- *
- * @return
- *   Return True on Delete and False otherwise
- *
- * @ingroup tripal_chado_node_api
- */
-function chado_delete_propertyID($basetable, $record_id) {
-
-  // get the foreign key for this property table
-  $table_desc = chado_get_schema($basetable . 'prop');
-  $pkcol = $table_desc['primary key'][0];
-
-  // construct the array that will match the exact record to update
-  $match = array(
-    $pkcol => $record_id,
-  );
-
-  return chado_delete_record($basetable . 'prop', $match);
-}
-
 /**
  * @section
  * Properties Form to be added to node forms

+ 19 - 6
tripal_feature/api/tripal_feature.api.inc

@@ -204,8 +204,8 @@ function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
   $property, $value, $cv_name = 'tripal') {
 
     // update the property.
-    return chado_update_propertyID('analysisfeature',
-      $analysisfeatureprop_id, $property, $cv_name, $value);
+    return chado_update_property('analysisfeature',
+      NULL, $property, $cv_name, $value, FALSE, $analysisfeatureprop_id);
 }
 
 /**
@@ -274,8 +274,14 @@ function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_i
  * @ingroup tripal_feature_api
  */
 function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id) {
-  // get the property.
-  return chado_delete_propertyID('analysisfeature', $analysisfeatureprop_id);
+
+  // construct the array that will match the exact record to update
+  $match = array(
+    'analysisfeatureprop_id' => $analysisfeatureprop_id,
+  );
+
+  return chado_delete_record('analysisfeatureprop', $match);
+
 }
 
 /**
@@ -373,7 +379,7 @@ function tripal_feature_update_property($feature_id, $property,
  */
 function tripal_feature_update_property_by_id($featureprop_id, $property,
   $value, $cv_name = 'tripal') {
-    return chado_update_propertyID('feature', $featureprop_id, $property, $cv_name, $value);
+    return chado_update_property('feature', NULL, $property, $cv_name, $value, FALSE, $featureprop_id);
 }
 
 /**
@@ -412,7 +418,14 @@ function tripal_feature_delete_property($feature_id, $property, $cv_name='tripal
  * @ingroup tripal_feature_api
  */
 function tripal_feature_delete_property_by_id($featureprop_id) {
-  return chado_delete_propertyID('feature', $featureprop_id);
+
+  // construct the array that will match the exact record to update
+  $match = array(
+    'featureprop_id' => $featureprop_id,
+  );
+
+  return chado_delete_record('featureprop', $match);
+
 }
 
 /**

+ 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() {