Browse Source

Updated version to 6.x-1.1 in anticipation of upcoming release. Fixed bug in Features view so that the name field appears.

spficklin 12 years ago
parent
commit
7e1b88f37e
38 changed files with 1581 additions and 1501 deletions
  1. 12 12
      tripal_analysis/theme/tripal_analysis_admin.tpl.php
  2. 1 1
      tripal_analysis/tripal_analysis.info
  3. 1 1
      tripal_bulk_loader/tripal_bulk_loader.info
  4. 1 1
      tripal_contact/tripal_contact.info
  5. 3 3
      tripal_core/theme/tripal_core_customize.tpl.php
  6. 1 1
      tripal_core/tripal_core.info
  7. 1 1
      tripal_cv/theme/tripal_cv_admin.tpl.php
  8. 1 1
      tripal_cv/tripal_cv.info
  9. 1 1
      tripal_db/tripal_db.info
  10. 5 6
      tripal_feature/theme/tripal_feature_admin.tpl.php
  11. 1 1
      tripal_feature/tripal_feature.info
  12. 1 1
      tripal_feature/tripal_feature.views.inc
  13. 1 1
      tripal_featuremap/tripal_featuremap.info
  14. 1 1
      tripal_genetic/tripal_genetic.info
  15. 1 1
      tripal_library/tripal_library.info
  16. 1 1
      tripal_natural_diversity/tripal_natural_diversity.info
  17. 29 30
      tripal_organism/theme/tripal_organism_admin.tpl.php
  18. 1 1
      tripal_organism/tripal_organism.info
  19. 1 1
      tripal_phenotype/tripal_phenotype.info
  20. 1 1
      tripal_project/theme/tripal_project_admin.tpl.php
  21. 1 1
      tripal_project/tripal_project.info
  22. 251 251
      tripal_pub/api/tripal_pub.api.inc
  23. 176 176
      tripal_pub/includes/importers/AGL.inc
  24. 185 185
      tripal_pub/includes/importers/PMID.inc
  25. 190 190
      tripal_pub/includes/pub_form.inc
  26. 165 165
      tripal_pub/includes/pub_importers.inc
  27. 105 105
      tripal_pub/includes/pub_search.inc
  28. 13 13
      tripal_pub/includes/pub_sync.inc
  29. 12 12
      tripal_pub/includes/tripal_pub.admin.inc
  30. 108 73
      tripal_pub/theme/tripal_pub_admin.tpl.php
  31. 10 10
      tripal_pub/tripal_pub.drush.inc
  32. 1 1
      tripal_pub/tripal_pub.info
  33. 29 29
      tripal_pub/tripal_pub.install
  34. 166 166
      tripal_pub/tripal_pub.module
  35. 15 15
      tripal_pub/tripal_pub.views.inc
  36. 87 40
      tripal_stock/theme/tripal_stock_admin.tpl.php
  37. 1 1
      tripal_stock/tripal_stock.info
  38. 1 1
      tripal_views/tripal_views.info

+ 12 - 12
tripal_analysis/theme/tripal_analysis_admin.tpl.php

@@ -14,7 +14,7 @@
 </p>
 
 <h3>Setup Instructions:</h3>
-<p>After installation of the analysis module or any specialized analysis module.  The following tasks should be performed
+<p>After installation of the analysis module or any specialized analysis module.  The following tasks should be performed</p>
 <ol>
   <li><p><b>Set Permissions</b>: By default only the site administrator account has access to create, edit, delete
    or administer analyses. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
@@ -22,18 +22,18 @@
    users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
 
 
-<li><p><b>Create an Analysis</b>:  An analysis should be <?php print l('created', 'node/add/chado-analysis')?> before 
-data is imported into chado.  The generic analysis type should only be used when a more specialized analysis module
-(e.g. Tripal Analysis Blast module) does not already exists.  All data imported into Chado should be associated with 
-an analysis to help keep track of the source for data.</p></li>
+  <li><p><b>Create an Analysis</b>:  An analysis should be <?php print l('created', 'node/add/chado-analysis')?> before 
+  data is imported into chado.  The generic analysis type should only be used when a more specialized analysis module
+  (e.g. Tripal Analysis Blast module) does not already exists.  All data imported into Chado should be associated with 
+  an analysis to help keep track of the source for data.</p></li>
 
-<li><p><b>Sync Analyses</b>:  If you have analyses already stored in Chado and would like to create pages for them, then
-analyses can be synced using the
- <?php print l('analysis configuration page', 'admin/tripal/tripal_analysis/configuration') ?>. The process of 'syncing'
- automatically creates the pages as if you had created them using the step above.
-</p></li>
+  <li><p><b>Sync Analyses</b>:  If you have analyses already stored in Chado and would like to create pages for them, then
+  analyses can be synced using the
+   <?php print l('analysis configuration page', 'admin/tripal/tripal_analysis/configuration') ?>. The process of 'syncing'
+   automatically creates the pages as if you had created them using the step above.
+  </p></li>
 </ol>
-</p>
+
 
 <h3>Additional Features of this Module:</h3>
   <ul>
@@ -42,4 +42,4 @@ analyses can be synced using the
     which must be installed to see the search tool.  Look for it in the navigation menu under the item 
     "Search Biological Data". </p></li>
 </ul>
-</p>
+

+ 1 - 1
tripal_analysis/tripal_analysis.info

@@ -3,7 +3,7 @@ description = A module that controls the display of all analysis sub-modules. Th
 core = 6.x
 project = tripal_analysis
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_db
 dependencies[] = tripal_cv

+ 1 - 1
tripal_bulk_loader/tripal_bulk_loader.info

@@ -3,5 +3,5 @@ description = A module for uploading tab-delimit data into GMOD chado database u
 core = 6.x
 project = tripal_bulk_loader
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core

+ 1 - 1
tripal_contact/tripal_contact.info

@@ -3,6 +3,6 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_contact
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_cv

+ 3 - 3
tripal_core/theme/tripal_core_customize.tpl.php

@@ -17,7 +17,7 @@ been exposed to Drupal Views</p></li>
 <h3>Customizations Without Programming</h3>
 <p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
 Below is a description of several methods.  These methods may be used in conjunction with one another to
-provide fine-grained control.
+provide fine-grained control.</p>
 <ul>
 
 <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a>
@@ -39,7 +39,7 @@ If using Panels, the CCK field can be added to the location desired using the Pa
 
 <li><p><b>Adding Links to the "Resources" Sidebar</b>: You can add new items to the resources side-bar of any Tripal node using the 
 <a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a>module and adding new field types to Tripal node types.  Instructions for adding these fields can be found
-on the <?php l('Tripal v1.0 Tutorial', 'http://www.gmod.org/wiki/Tripal_Tutorial_(v1.0)#Adding_Additional_Resources')?>  </p></li>
+on the <?php l('Tripal v1.0 Tutorial', 'http://www.gmod.org/wiki/Tripal_Tutorial_(v1.0)#Adding_Additional_Resources')?>  </p>
 </li>
 
 </ul>
@@ -56,7 +56,7 @@ section at the bottom of the template file where the resources section is found.
 <li><p><b>Editing Templates and Creating Custom Extension Modules</b>:There are several ways to customize the look-and-feel
   for the way Chado data is presented through Tripal.
   See the <a href="http://www.gmod.org/wiki/Tripal_Developer's_Handbook">Developers Handbook</a> for further infromation.   
-</p>
+</p></li>
 
 <li><p><b>Sharing your customizations</b>: If you create a custom extension module that uses the Tripal API in
 accordance with the instructions in the Developers Handbook you can share your modules with other Tripal users.

+ 1 - 1
tripal_core/tripal_core.info

@@ -3,5 +3,5 @@ description = The core module for the Tripal package that integrates Drupal and
 core = 6.x
 project = tripal_core
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 

+ 1 - 1
tripal_cv/theme/tripal_cv_admin.tpl.php

@@ -25,7 +25,7 @@
    permissions under the 'tripal_cv' section as appropriate for your site. For a simple setup, allow anonymous 
    users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
 
-      <li><b>Loading of Ontologies/Controlled Vocabularies</b>: You can access this loader at <?php 
+      <li><p><b>Loading of Ontologies/Controlled Vocabularies</b>: You can access this loader at <?php 
         print l('Admin->Tripal Management->Tripal CV->Load Ontology With OBO File', 'admin/tripal/tripal_cv/obo_loader')
         ?>. This loader allows you to choose from a list of common ontologies or
         enter the URL or location to an OBO file. Even the list of common

+ 1 - 1
tripal_cv/tripal_cv.info

@@ -3,6 +3,6 @@ description = The controlled vocabulary module for the Tripal package that integ
 core = 6.x
 project = tripal_cv
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_db

+ 1 - 1
tripal_db/tripal_db.info

@@ -3,5 +3,5 @@ description = The database module for the Tripal package that integrates Drupal
 core = 6.x
 project = tripal_db
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core

+ 5 - 6
tripal_feature/theme/tripal_feature_admin.tpl.php

@@ -22,13 +22,14 @@
    <li><p><b>Loading of Ontologies</b>:  
      Before loading genomic features you must also have several vocabularies loaded as well. Using the
      <?php print l('OGO loader','admin/tripal/tripal_cv/obo_loader')?> you should load the following
-     ontologies:
+     ontologies:</p>
      <ul>
         <li>Chado Feature Properties</li>
         <li>Relationship Ontology</li>
         <li>Sequence Ontology</li>
         <li>Gene Ontology (if loading GO terms for features)</li>
-     </ul></p></li>
+     </ul>
+   </li>
 
      <li><p><b>Create Organisms</b>:  Before adding feature data you must already have the
      organisms loaded in the database.  See the
@@ -73,12 +74,11 @@
      URL.  Select the one that will guarantee a unique identifier for feature pages.</p></li>
 
   </ol>
-  </p>
 
 
   <h3>Features of this Module:</h3>
   <p>Aside from data loading and feature page setup (as described in the Setup section above),
-  The Tripal feature module also provides the following functionality
+  The Tripal feature module also provides the following functionality</p>
   <ul>
     <li><p><b>Retrieve Sequences</b>: A tool to <?php print l('retrieve sequences','find/sequences') ?> is provided 
      which allows end-users to download sequences in FASTA format.  The site admin must first load sequence residues
@@ -130,5 +130,4 @@
     <li><p><b>Delete Features</b>: You can  <a href="<?php print url('admin/tripal/tripal_feature/delete') ?>">bulk delete features</a>
     by providing a list of feature names, or for a specific organism or for a specific feature type. Be sure you have
     a full backup of your site before performing a bulk delete.</p></li>
-  </ul>
-</p>
+  </ul>

+ 1 - 1
tripal_feature/tripal_feature.info

@@ -3,7 +3,7 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_feature
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = search
 dependencies[] = path
 dependencies[] = tripal_core

+ 1 - 1
tripal_feature/tripal_feature.views.inc

@@ -478,7 +478,7 @@ function tripal_feature_views_default_views() {
       ),
     ),
     'name_1' => array(
-      'operator' => 'allwords',
+      'operator' => '~',
       'value' => '',
       'group' => '0',
       'exposed' => TRUE,

+ 1 - 1
tripal_featuremap/tripal_featuremap.info

@@ -3,7 +3,7 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_featuremap
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_organism
 dependencies[] = tripal_feature

+ 1 - 1
tripal_genetic/tripal_genetic.info

@@ -3,7 +3,7 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_genetic
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_cv
 dependencies[] = tripal_feature

+ 1 - 1
tripal_library/tripal_library.info

@@ -3,7 +3,7 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_library
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_organism
 dependencies[] = search

+ 1 - 1
tripal_natural_diversity/tripal_natural_diversity.info

@@ -3,7 +3,7 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_natural_diversity
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_cv
 dependencies[] = tripal_db

+ 29 - 30
tripal_organism/theme/tripal_organism_admin.tpl.php

@@ -1,47 +1,46 @@
   
 
-  <h3>Tripal Organism Administrative Tools Quick Links:</h3>
+  <h3>Tripal Organism Quick Links:</h3>
   <ul>
-             <li><a href="<?php print url("admin/tripal/tripal_organism/configuration") ?>">Organism Configuration</a></li>
-           </ul>
-
+    <li><a href="<?php print url("admin/tripal/tripal_organism/configuration") ?>">Organism Configuration</a></li>
+  </ul>
+<br>
   <h3>Module Description:</h3>
   <p>The Tripal Organism module allows you to add, edit and/or delete chado organisms.
-            Furthermore, it also provides listing of organisms and details page for each organism.
-            Basically, the chado organism module is designed to hold information about a given species.
-            For more information on the chado organism module see the
-             <a href="http://gmod.org/wiki/Chado_Organism_Module">GMOD wiki page</a></p>
+    Furthermore, it also provides listing of organisms and details page for each organism.
+    Basically, the chado organism module is designed to hold information about a given species.
+    For more information on the chado organism module see the
+     <a href="http://gmod.org/wiki/Chado_Organism_Module">GMOD wiki page</a></p>
 
   <h3>Setup Instructions:</h3>
-  <p>After installation of the organism module.  The following tasks should be performed.
-            <ol>
-                <li><p><b>Set Permissions</b>: By default only the site administrator account has access to create, edit, delete
-   or administer features. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
-   permissions under the 'tripal_organism' section as appropriate for your site. For a simple setup, allow anonymous 
-   users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
-
-              <li><p><b>Create an Organism</b>: Organism pages can be created in two ways:
-                 <ol>
-                  <li><b>Sync Organisms</b>: If your organism has been pre-loaded into Chado then you need to sync the organism.
-                   This process is what creates the pages for viewing online.  Not all organisms need be synced, only those
-                   that you want shown on the site.  Use the the
-                   <a href="<?php print url('admin/tripal/tripal_organism/configuration') ?>">Organism Configuration page</a>
-                   to sync organisms. </li>
-                   <li><b>Manually Add An Organism</b>: If your organism is not already present in the Chado database
-                   you can create an organism using the <a href="<?php print url('node/add/chado-organism') ?>">Create Organism page</a>.
-                   Once saved, the organism will be present in Chado and also "synced".
-                 </ol></p></li>
+  <p>After installation of the organism module.  The following tasks should be performed.</p>
+  <ul>
+      <li><p><b>Set Permissions</b>: By default only the site administrator account has access to create, edit, delete
+       or administer features. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
+       permissions under the 'tripal_organism' section as appropriate for your site. For a simple setup, allow anonymous 
+       users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
 
-             </ol>
+      <li><p><b>Create an Organism</b>: Organism pages can be created in two ways:</p>
+         <ol>
+          <li><p><b>Sync Organisms</b>: If your organism has been pre-loaded into Chado then you need to sync the organism.
+           This process is what creates the pages for viewing online.  Not all organisms need be synced, only those
+           that you want shown on the site.  Use the the
+           <a href="<?php print url('admin/tripal/tripal_organism/configuration') ?>">Organism Configuration page</a>
+           to sync organisms. </p></li>
+           <li><p><b>Manually Add An Organism</b>: If your organism is not already present in the Chado database
+           you can create an organism using the <a href="<?php print url('node/add/chado-organism') ?>">Create Organism page</a>.
+           Once saved, the organism will be present in Chado and also "synced".</p>
+         </ol>
+       </li>
+   </ul>
 
   <h3>Features of this Module:</h3>
   <p>Aside from organism page setup (as described in the Setup section above),
-            The Tripal organism module also provides the following functionality
+            The Tripal organism module also provides the following functionality</p>
             <ul>
 
     <li><p><b>Simple Search Tool</b>: A <?php print l('simple search tool','chado/organisms') ?> is provided for 
     finding organisms. This tool relies on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a>
     which must be installed to see the search tool.  Look for it in the navigation menu under the item 
     "Search Biological Data". </p></li>
-            </ul>
-            </p>
+            </ul>

+ 1 - 1
tripal_organism/tripal_organism.info

@@ -3,7 +3,7 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_organism
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = search
 dependencies[] = path

+ 1 - 1
tripal_phenotype/tripal_phenotype.info

@@ -3,7 +3,7 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_phenotype
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_cv
 dependencies[] = tripal_feature

+ 1 - 1
tripal_project/theme/tripal_project_admin.tpl.php

@@ -20,7 +20,7 @@
 
 <h3>Features of this Module:</h3>
 <ul>
-  <li><b>Add/Edit/Delete Projects</b>: Projects can be created ' . l('here', 'node/add/chado-project') ?>. 
+  <li><b>Add/Edit/Delete Projects</b>: Projects can be created <?php print l('here', 'node/add/chado-project') ?>. 
   After creation, projects (regardless of the method used to create them) can be
   edited or deleted by clicking the Edit tab at the top of the Project Page.</li>
     <li><p><b>Simple Search Tool</b>: A <?php print l('simple search tool','chado/projects') ?> is provided for 

+ 1 - 1
tripal_project/tripal_project.info

@@ -3,6 +3,6 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_project
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_cv

File diff suppressed because it is too large
+ 251 - 251
tripal_pub/api/tripal_pub.api.inc


+ 176 - 176
tripal_pub/includes/importers/AGL.inc

@@ -1,40 +1,40 @@
 <?php
 /**
- *  
+ *
  */
 function tripal_pub_remote_alter_form_AGL(&$form, $form_state) {
   $num_criteria = $form['num_criteria']['#default_value'];
-  
-  // So far we haven't been able to get AGL to filter results to only 
+
+  // 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
   $form['days']['#title'] = t('Year');
   $form['days']['#description']  = t('Please enter a year to limit records by the year they were published, created or modified in the database.');
-  
+
   // The Journal Name filter doesn't seem to work, so remove it
   for($i = 1; $i <= $num_criteria; $i++) {
     unset($form['criteria'][$i]["scope-$i"]['#options']['journal']);
   }
-  
+
 }
 /**
- *  
+ *
  */
 function tripal_pub_remote_validate_form_AGL(&$form, $form_state) {
   $days =  trim($form_state['values']["days"]);
   $num_criteria = $form['num_criteria']['#default_value'];
-  
+
   if ($days and !preg_match('/^\d\d\d\d$/', $days)) {
     form_set_error("days", "Please enter a four digit year.");
   }
-  
+
   $num_ids = 0;
-  for ($i = 1; $i <= $num_criteria; $i++) {            
+  for ($i = 1; $i <= $num_criteria; $i++) {
     $search_terms =  trim($form_state['values']["search_terms-$i"]);
     $scope =  $form_state['values']["scope-$i"];
     if ($scope == 'id' and !preg_match('/^AGL:\d+$/', $search_terms)) {
-      form_set_error("search_terms-$i", "The AGL accession be a numeric value, prefixed with 'AGL:' (e.g. AGL:3890740).");  
-    }       
+      form_set_error("search_terms-$i", "The AGL accession be a numeric value, prefixed with 'AGL:' (e.g. AGL:3890740).");
+    }
     if ($scope == 'id') {
       $num_ids++;
     }
@@ -47,15 +47,15 @@ function tripal_pub_remote_validate_form_AGL(&$form, $form_state) {
  *
  */
 function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id) {
-  // get some values from the serach array  
+  // get some values from the serach array
   $num_criteria = $search_array['num_criteria'];
-  $days = $search_array['days'];   
+  $days = $search_array['days'];
 
   // set some defaults
   $search_array['limit'] = $num_to_retrieve;
-  
+
   // To build the CCL search string we want to have a single entry for 'author', 'title', 'abstract'
-  // or 'id', and also the corresponding 'not for each of those. 
+  // or 'id', and also the corresponding 'not for each of those.
   // But the search form allows the user to have multiple rows of the same type. So, we will build the
   // search string separately for each category and it's negative category (if NOT is selected as the op)
   // and at the end we will put them together into a single search string.  We need to keep
@@ -89,7 +89,7 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
     $scope = $search_array['criteria'][$i]['scope'];
     $is_phrase = $search_array['criteria'][$i]['is_phrase'];
     $op = $search_array['criteria'][$i]['operation'];
-    
+
     if ($op) {
       $op = strtolower($op);
     }
@@ -99,43 +99,43 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
       $search_terms = preg_replace('/ OR /', ' or ', $search_terms);
       $search_terms = preg_replace('/ AND /', ' and ', $search_terms);
     }
-    // else make sure the search terms are surrounded by quotes 
+    // else make sure the search terms are surrounded by quotes
     else {
-      $search_terms = "\"$search_terms\""; 
-    }   
-    
+      $search_terms = "\"$search_terms\"";
+    }
+
     // if this is a 'not' operation then we want to change it to an
     // and
-    $negate = '';    
+    $negate = '';
     if ($op == 'not') {
       $scope = "negate_$scope";
       $op = 'or';
     }
     $order[] = array('scope' => $scope, 'op' => $op);
-    
+
     // build each category
     if ($scope == 'title') {
       if ($first_title) {
         $title .= "($search_terms) ";
         $first_title = 0;
-      } 
+      }
       else {
-        $title .= "$op ($search_terms) "; 
+        $title .= "$op ($search_terms) ";
       }
-    }  
+    }
     if ($scope == 'negate_title') {
       if ($first_negate_title) {
         $negate_title .= "($search_terms) ";
         $first_negate_title = 0;
-      } 
+      }
       else {
-        $negate_title .= "$op ($search_terms) "; 
+        $negate_title .= "$op ($search_terms) ";
       }
-    } 
+    }
     elseif ($scope == 'author') {
       if ($first_author) {
         $author .= "($search_terms) ";
-        $first_author = 0;  
+        $first_author = 0;
       }
       else {
         $author .= "$op ($search_terms) ";
@@ -144,12 +144,12 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
     elseif ($scope == 'negate_author') {
       if ($first_negate_author) {
         $negate_author .= "($search_terms) ";
-        $first_negate_author = 0;  
+        $first_negate_author = 0;
       }
       else {
         $negate_author .= "$op ($search_terms) ";
       }
-    } 
+    }
     elseif ($scope == 'abstract') {
       if ($first_abstract) {
         $abstract .= "($search_terms) ";
@@ -189,21 +189,21 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
     elseif ($scope == 'id') {
       if ($first_id) {
         $id .= "(" . preg_replace('/AGL:([^\s]*)/', '$1', $search_terms) . ") ";
-        $first_id = 0; 
+        $first_id = 0;
       }
       else {
         $id .= "$op (" . preg_replace('/AGL:([^\s]*)/', '$1', $search_terms) . ") ";
       }
-    } 
+    }
     elseif ($scope == 'negate_id') {
       if ($first_negate_id) {
         $negate_id .= "(" . preg_replace('/AGL:([^\s]*)/', '$1', $search_terms) . ") ";
-        $first_negate_id = 0; 
+        $first_negate_id = 0;
       }
       else {
         $negate_id .= "$op (" . preg_replace('/AGL:([^\s]*)/', '$1', $search_terms) . ") ";
       }
-    } 
+    }
     elseif ($scope == 'any'){
       if ($first_any) {
         $any .= "($search_terms) ";
@@ -211,7 +211,7 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
       }
       else {
         $any .= "$op ($search_terms) ";
-      } 
+      }
     }
     elseif ($scope == 'negate_any'){
       if ($first_negate_any) {
@@ -220,10 +220,10 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
       }
       else {
         $negate_any .= "$op ($search_terms) ";
-      } 
+      }
     }
-  } 
-  // now build the CCL string in order 
+  }
+  // now build the CCL string in order
   $abstract_done = 0;
   $author_done = 0;
   $journal_done = 0;
@@ -264,7 +264,7 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
       $ccl .= "not author=($negate_journal) ";
       $negate_journal_done = 1;
     }
-    if ($order[$i]['scope'] == 'id' and !$id_done) {      
+    if ($order[$i]['scope'] == 'id' and !$id_done) {
       $op = $order[$i]['op'];
       $ccl .= "$op id=($id) ";
       $id_done = 1;
@@ -300,21 +300,21 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
 
   // remove any preceeding 'and' or 'or'
   $ccl = preg_replace('/^\s*(and|or)/', '', $ccl);
-    
-  // yaz_connect() prepares for a connection to a Z39.50 server. This function is non-blocking 
-  // and does not attempt to establish a connection - it merely prepares a connect to be 
+
+  // yaz_connect() prepares for a connection to a Z39.50 server. This function is non-blocking
+  // and does not attempt to establish a connection - it merely prepares a connect to be
   // performed later when yaz_wait() is called.
   //$yazc = yaz_connect('agricola.nal.usda.gov:7090/voyager'); // NAL Catalog
   $yazc = yaz_connect('agricola.nal.usda.gov:7190/voyager');  // NAL Article Citation Database
-    
+
   // use the USMARC record type.  But OPAC is also supported by Agricola
   yaz_syntax($yazc, "usmarc");
-  
+
   // the search query is built using CCL, we need to first
   // configure it so it can map the attributes to defined identifiers
   // The attribute set used by AGL can be found at the bottom of this page:
-  // http://agricola.nal.usda.gov/help/z3950.html  
-  // 
+  // http://agricola.nal.usda.gov/help/z3950.html
+  //
   // More in depth details:  http://www.loc.gov/z3950/agency/bib1.html
   //
   // CCL Syntax: http://www.indexdata.com/yaz/doc/tools.html#CCL
@@ -326,31 +326,31 @@ function tripal_pub_remote_search_AGL($search_array, $num_to_retrieve, $pager_id
     "id"       => "u=12",
     "year"     => "u=30 r=o", 
     "journal"  => "u=1033"
-  );
-  yaz_ccl_conf($yazc, $fields);
-    
-  if (!yaz_ccl_parse($yazc, $ccl, &$cclresult)) {
-    drupal_set_message('Error parsing search string: ' . $cclresult["errorstring"], "error");
-    watchdog('tripal_pub', 'Error: %errstr', array('%errstr' => $cclresult["errorstring"]), WATCHDOG_ERROR);
-    return array();
-  } 
-  $search_str = $cclresult["rpn"];    
-  
-  $search_array['search_string'] = $search_str;
-    
-  // save the YAZ connection in the session for use by other functions
-  $_SESSION['tripal_pub_AGL_query'][$search_str]['yaz_connection'] = $yazc;
-  
-  //dpm($search_array);
-  // we want to get the list of pubs using the search terms but using a Drupal style pager
-  $pubs = tripal_pager_callback('tripal_pub_AGL_range',  $num_to_retrieve, $pager_id, 
+    );
+    yaz_ccl_conf($yazc, $fields);
+
+    if (!yaz_ccl_parse($yazc, $ccl, &$cclresult)) {
+      drupal_set_message('Error parsing search string: ' . $cclresult["errorstring"], "error");
+      watchdog('tripal_pub', 'Error: %errstr', array('%errstr' => $cclresult["errorstring"]), WATCHDOG_ERROR);
+      return array();
+    }
+    $search_str = $cclresult["rpn"];
+
+    $search_array['search_string'] = $search_str;
+
+    // save the YAZ connection in the session for use by other functions
+    $_SESSION['tripal_pub_AGL_query'][$search_str]['yaz_connection'] = $yazc;
+
+    //dpm($search_array);
+    // we want to get the list of pubs using the search terms but using a Drupal style pager
+    $pubs = tripal_pager_callback('tripal_pub_AGL_range',  $num_to_retrieve, $pager_id,
     'tripal_pub_AGL_count', $search_array);
-  
-  // close the connection
-  unset($_SESSION['tripal_pub_AGL_query'][$search_str]['yaz_connection']);
-  yaz_close($yazc);  
-  
-  return $pubs;
+
+    // close the connection
+    unset($_SESSION['tripal_pub_AGL_query'][$search_str]['yaz_connection']);
+    yaz_close($yazc);
+
+    return $pubs;
 }
 /*
  * This function is used as the callback function when used with the
@@ -361,7 +361,7 @@ function tripal_pub_AGL_count($search_array) {
   $search_str = $search_array['search_string'];
   $days       = $search_array['days'];
   $limit      = $search_array['limit'];
-  
+
   $yazc = $_SESSION['tripal_pub_AGL_query'][$search_str]['yaz_connection'];
   //yaz_sort($yazc, "1=31 id"); // sort by publication date descending
   if (!yaz_search($yazc, "rpn", $search_str)){
@@ -372,7 +372,7 @@ function tripal_pub_AGL_count($search_array) {
       $error_msg .= " $additional";
     }
     drupal_set_message("ERROR preparing search at AGL: ($error_no) $error_msg", "error");
-    return 0;    
+    return 0;
   }
   if (!yaz_wait()) {
     $error_no = yaz_errno($yazc);
@@ -384,10 +384,10 @@ function tripal_pub_AGL_count($search_array) {
     drupal_set_message("ERROR waiting on search at AGL: ($error_no) $error_msg", "error");
     return 0;
   }
-  
+
   // get the total number of results from the serach
-  $count = yaz_hits($yazc);  
-  $_SESSION['tripal_pub_AGL_query'][$search_str]['Count'] = $count; 
+  $count = yaz_hits($yazc);
+  $_SESSION['tripal_pub_AGL_query'][$search_str]['Count'] = $count;
   return $count;
 }
 
@@ -398,14 +398,14 @@ function tripal_pub_AGL_count($search_array) {
  */
 function tripal_pub_AGL_range($search_array, $start = 0, $limit = 10) {
   $pubs = array();
-  
+
   $search_str = $search_array['search_string'];
   $days       = $search_array['days'];
   $limit      = $search_array['limit'];
-  
+
   $yazc  = $_SESSION['tripal_pub_AGL_query'][$search_str]['yaz_connection'];
   $count = $_SESSION['tripal_pub_AGL_query'][$search_str]['Count'];
-  yaz_range($yazc, 1, $num_pubs); 
+  yaz_range($yazc, 1, $num_pubs);
   if (!yaz_present($yazc)) {
     $error_no = yaz_errno($yazc);
     $error_msg = yaz_error($yazc);
@@ -415,43 +415,43 @@ function tripal_pub_AGL_range($search_array, $start = 0, $limit = 10) {
     }
     drupal_set_message("ERROR waiting on search at AGL: ($error_no) $error_msg", "error");
     return $pubs;
-  }  
-     
+  }
+   
   if ($start + $limit > $count) {
     $limit = $count - $start;
   }
-  for($i = $start; $i < $start + $limit; $i++) { 
+  for($i = $start; $i < $start + $limit; $i++) {
     $pub_xml = yaz_record($yazc, $i + 1, 'xml; charset=marc-8,utf-8');
     $pub     = tripal_pub_AGL_parse_pubxml($pub_xml);
-    $pubs[]  = $pub;     
-  } 
+    $pubs[]  = $pub;
+  }
   return $pubs;
 }
 
 /*
  * Description of XML format:
  * http://www.loc.gov/marc/bibliographic/bdsummary.html
- * 
+ *
  */
 function tripal_pub_AGL_parse_pubxml($pub_xml) {
   $pub = array();
-  
+
   // publications from the NAL Article Citation Database are all journal articles
   $pub['Publication Type'][] = 'Journal Article';
-  
+
   if (!$pub_xml) {
     return $pub;
   }
-  
+
   // read the XML and iterate through it.
   $xml = new XMLReader();
   $xml->xml(trim($pub_xml));
-  while ($xml->read()) {    
-    $element = $xml->name; 
+  while ($xml->read()) {
+    $element = $xml->name;
 
-    if ($xml->nodeType == XMLReader::ELEMENT and $element == 'controlfield') {      
+    if ($xml->nodeType == XMLReader::ELEMENT and $element == 'controlfield') {
       $tag = $xml->getAttribute('tag');
-      $xml->read(); 
+      $xml->read();
       $value = $xml->value;
       switch ($tag) {
         case '001':  // control number
@@ -471,31 +471,31 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
             '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
-          $date1 = substr($value, 7, 4);  // year of publication
-          $date2 = substr($value, 11, 4); // month of publication
-          $place = substr($value, 15, 3);
-          $lang  = substr($value, 35, 3);
-          if (preg_match('/\d\d\d\d/', $date1)) {
-            $pub['Year'] = $date1;
-            $pub['Publication Date'] = $date1;
-          }
-          if (preg_match('/\d\d/', $date2)) {
-            $pub['Publication Date'] = $date1 . " " . $month[substr($date2, 0, 2)] . " " . substr($date2, 3, 2);
-          }
-          if (!preg_match('/\s+/', $place)) {
-            $pub['Published Location'] = $place;
-          }
-          if (!preg_match('/\s+/', $lang)) {
-            $pub['Language Abbr'] = $lang;
-          }
-          break;
+            );
+            $date0 = substr($value, 0, 6);  // date entered on file
+            $date1 = substr($value, 7, 4);  // year of publication
+            $date2 = substr($value, 11, 4); // month of publication
+            $place = substr($value, 15, 3);
+            $lang  = substr($value, 35, 3);
+            if (preg_match('/\d\d\d\d/', $date1)) {
+              $pub['Year'] = $date1;
+              $pub['Publication Date'] = $date1;
+            }
+            if (preg_match('/\d\d/', $date2)) {
+              $pub['Publication Date'] = $date1 . " " . $month[substr($date2, 0, 2)] . " " . substr($date2, 3, 2);
+            }
+            if (!preg_match('/\s+/', $place)) {
+              $pub['Published Location'] = $place;
+            }
+            if (!preg_match('/\s+/', $lang)) {
+              $pub['Language Abbr'] = $lang;
+            }
+            break;
         default:  // unhandled tag
           break;
-      }          
+      }
     }
-    elseif ($xml->nodeType == XMLReader::ELEMENT and $element == 'datafield') { 
+    elseif ($xml->nodeType == XMLReader::ELEMENT and $element == 'datafield') {
       $tag  = $xml->getAttribute('tag');
       $ind1 = $xml->getAttribute('ind1');
       $ind2 = $xml->getAttribute('ind2');
@@ -505,8 +505,8 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
         case '35':  // System Control Number
           $author = array();
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {    
-            switch ($code) {                
+          foreach ($codes as $code => $value) {
+            switch ($code) {
               case 'a': // System control number
                 $pub['Publication Accession'] = $value;
                 break;
@@ -515,8 +515,8 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
         case '40':  // Cataloging Source (NR)
           $author = array();
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {    
-            switch ($code) {                
+          foreach ($codes as $code => $value) {
+            switch ($code) {
               case 'a':  // original cataolging agency
                 $pub['Publication Database'] = $value;
                 break;
@@ -527,13 +527,13 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
           break;
         case '100':  // main entry-personal name
           $author = tripal_pub_remote_search_AGL_get_author($xml, $ind1);
-          $pub['Author List'][] = $author; 
+          $pub['Author List'][] = $author;
           break;
         case '110':  // main entry-corporate nmae
           $author = array();
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {    
-            switch ($code) {                
+          foreach ($codes as $code => $value) {
+            switch ($code) {
               case 'a': // Corporate name or jurisdiction name as entry elemen
                 $author['Collective'] = $value;
                 break;
@@ -542,7 +542,7 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
                 break;
             }
           }
-          $pub['Author List'][] = $author; 
+          $pub['Author List'][] = $author;
           break;
         case '111':  // main entry-meeting name
           break;
@@ -561,8 +561,8 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
           break;
         case '245':  // title statement
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {          
-            switch ($code) {                
+          foreach ($codes as $code => $value) {
+            switch ($code) {
               case 'a':
                 $pub['Title'] = trim(preg_replace('/\.$/', '', $value));
                 break;
@@ -578,7 +578,7 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
         case '246':  // varying form of title
           break;
         case '247':  // former title
-          break;            
+          break;
 
         case '250':  // edition statement
           break;
@@ -586,7 +586,7 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
           break;
         case '255':  // cartographic mathematical data
           break;
-        case '256':  // computer file characteristics 
+        case '256':  // computer file characteristics
           break;
         case '257':  // country of producing entity
           break;
@@ -594,14 +594,14 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
           break;
         case '260':  // publication, distribution ,etc (imprint)
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {          
-            switch ($code) {                
+          foreach ($codes as $code => $value) {
+            switch ($code) {
               case 'a':
                 $pub['Published Location'] = $value;
                 break;
               case 'b':
                 $pub['Publisher'] = $value;
-                break;                
+                break;
               case 'c':
                 $pub['Publication Date'] = $value;
                 break;
@@ -614,25 +614,25 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
           break;
         case '270':  // Address
           break;
-          
+
         case '300':  // Address
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {          
-            switch ($code) {                
+          foreach ($codes as $code => $value) {
+            switch ($code) {
               case 'a':
                 $pages = $value;
                 $pages = preg_replace('/^p\. /', '', $pages);
                 $pages = preg_replace('/\.$/', '' , $pages);
                 if(preg_match('/p$/', $pages)) {
                   // skip this, it's the number of pages not the page numbers
-                } 
+                }
                 else {
                   $pub['Pages'] = $pages;
                 }
                 break;
             }
           }
-          break;                      
+          break;
 
 
         case '500':  // series statements
@@ -642,8 +642,8 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
           break;
         case '520':  // Summary, etc
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {    
-            switch ($code) {                
+          foreach ($codes as $code => $value) {
+            switch ($code) {
               case 'a':
                 $pub['Abstract'] = $value;
                 break;
@@ -652,33 +652,33 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
           break;
         case '650':  // Subject Added Entry-Topical Term
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {    
+          foreach ($codes as $code => $value) {
             switch ($code) {
               case 'a':
                 $pub['Keywords'][] = $value;
-                break;  
+                break;
             }
-          }          
+          }
           break;
         case '653':  // Index Term-Uncontrolled
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {    
+          foreach ($codes as $code => $value) {
             switch ($code) {
               case 'a':
                 $pub['Keywords'][] = $value;
-                break;  
+                break;
             }
           }
           break;
         case '700':  // Added Entry-Personal Name
           $author = tripal_pub_remote_search_AGL_get_author($xml, $ind1);
-          $pub['Author List'][] = $author; 
+          $pub['Author List'][] = $author;
           break;
         case '710':  // Added Entry-Corporate Name
           $author = array();
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {    
-            switch ($code) {                
+          foreach ($codes as $code => $value) {
+            switch ($code) {
               case 'a': // Corporate name or jurisdiction name as entry elemen
                 $author['Collective'] = $value;
                 break;
@@ -687,13 +687,13 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
                 break;
             }
           }
-          $pub['Author List'][] = $author; 
+          $pub['Author List'][] = $author;
           break;
         case '773': // host item entry
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {    
-            switch ($code) {                
-              case 't':                
+          foreach ($codes as $code => $value) {
+            switch ($code) {
+              case 't':
                 $pub['Journal Name'] = preg_replace('/\.$/', '', $value);
                 break;
               case 'g':
@@ -705,17 +705,17 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
                   $year = $matches[4];
                   $month = $matches[1];
                   $day = $matches[3];
-                  $pub['Publication Date'] = "$year $month $day"; 
+                  $pub['Publication Date'] = "$year $month $day";
                 }
                 elseif (preg_match('/\((.*?)(\.|\s+)(\d\d\d\d)\)/', $value, $matches)) {
                   $year = $matches[3];
                   $month = $matches[1];
-                  $pub['Publication Date'] = "$year $month"; 
+                  $pub['Publication Date'] = "$year $month";
                 }
                 elseif (preg_match('/^(.*?) (\d\d\d\d)/', $value, $matches)) {
                   $year = $matches[2];
                   $month = $matches[1];
-                  $pub['Publication Date'] = "$year $month"; 
+                  $pub['Publication Date'] = "$year $month";
                 }
                 if (preg_match('/v\. (.*?)(,|\s+)/', $value, $matches)) {
                   $pub['Volume'] = $matches[1];
@@ -741,11 +741,11 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
           break;
         case '856': // Electronic Location and Access
           $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-          foreach ($codes as $code => $value) {    
+          foreach ($codes as $code => $value) {
             switch ($code) {
               case 'u':
-                $pub['URL'] = $value; 
-                break;    
+                $pub['URL'] = $value;
+                break;
             }
           }
           break;
@@ -757,10 +757,10 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
     }
   }
   //dpm($unhandled);
-  
+
   // build the Dbxref
   if ($pub['Publication Database'] != 'AGL') {
-    
+
   }
   if ($pub['Publication Accession'] and $pub['Publication Database']) {
     $pub['Publication Dbxref'] = $pub['Publication Database'] . ":" . $pub['Publication Accession'];
@@ -771,7 +771,7 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
   // build the full authors list
   foreach ($pub['Author List'] as $author) {
     if ($author['valid'] == 'N') {
-      // skip non-valid entries.  A non-valid entry should have 
+      // skip non-valid entries.  A non-valid entry should have
       // a corresponding corrected entry so we can saftely skip it.
       continue;
     }
@@ -779,32 +779,32 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
       $authors .= $author['Collective'] . ', ';
     }
     else {
-      $authors .= $author['Surname'] . ' ' . $author['First Initials'] . ', '; 
-    }             
+      $authors .= $author['Surname'] . ' ' . $author['First Initials'] . ', ';
+    }
   }
   $authors = substr($authors, 0, -2);
   $pub['Authors'] = $authors;
-  
+
   // build the citation
   $pub['Citation'] = tripal_pub_create_citation($pub);
-  
+
   $pub['raw'] = $pub_xml;
   return $pub;
-}      
+}
 
 /*
- * 
- * 
+ *
+ *
  */
 function tripal_pub_remote_search_AGL_get_subfield($xml) {
   $codes = array();
-  while ($xml->read()) {    
+  while ($xml->read()) {
     $sub_element = $xml->name;
     // when we've reached the end of the datafield element then break out of the while loop
     if ($xml->nodeType == XMLReader::END_ELEMENT and $sub_element == 'datafield') {
-      return $codes; 
-    }    
-    // if inside the subfield element then get the code 
+      return $codes;
+    }
+    // if inside the subfield element then get the code
     if ($xml->nodeType == XMLReader::ELEMENT and $sub_element == 'subfield') {
       $code = $xml->getAttribute('code');
       $xml->read();
@@ -816,25 +816,25 @@ function tripal_pub_remote_search_AGL_get_subfield($xml) {
 }
 
 /*
- * 
- * 
+ *
+ *
  */
 function tripal_pub_remote_search_AGL_get_author($xml, $ind1) {
   $author = array();
   $codes = tripal_pub_remote_search_AGL_get_subfield($xml);
-  foreach ($codes as $code => $value) {          
-    switch ($code) {                
+  foreach ($codes as $code => $value) {
+    switch ($code) {
       case 'a':
         // remove any trailing commas
         $value = preg_replace('/,$/', '', $value);
         if ($ind1 == 0) { // Given Name is first
           $author['Given Name'] = $names[0];
         }
-        if ($ind1 == 1) { // Surname is first          
+        if ($ind1 == 1) { // Surname is first
           // split the parts of the name using a comma
           $names = explode(',', $value);
           $author['Surname'] = $names[0];
-          $author['Given Name'] = ''; 
+          $author['Given Name'] = '';
           unset($names[0]);
           foreach($names as $index => $name) {
             $author['Given Name'] .= $name . ' ';
@@ -842,11 +842,11 @@ function tripal_pub_remote_search_AGL_get_author($xml, $ind1) {
           $first_names = explode(' ', $author['Given Name']);
           $author['First Initials'] = '';
           foreach ($first_names as $index => $name) {
-            $author['First Initials'] .= substr($name, 0, 1); 
+            $author['First Initials'] .= substr($name, 0, 1);
           }
         }
         if ($ind1 == 3) { // A family name
-          
+
         }
         break;
     }

+ 185 - 185
tripal_pub/includes/importers/PMID.inc

@@ -1,4 +1,4 @@
-<?php 
+<?php
 /**
  * @file
  * Tripal Pub PubMed Interface
@@ -7,11 +7,11 @@
  * @ingroup tripal_pub
  */
 /**
- *  
+ *
  */
 function tripal_pub_remote_alter_form_PMID(&$form, $form_state) {
   $num_criteria = $form['num_criteria']['#default_value'];
-  
+
   // PubMed doesn't have an 'Abstract' field, so we need to convert the criteria
   // from 'Abstract' to 'Title/Abstract'
   for($i = 1; $i <= $num_criteria; $i++) {
@@ -19,53 +19,53 @@ function tripal_pub_remote_alter_form_PMID(&$form, $form_state) {
   }
 }
 /**
- *  
+ *
  */
 function tripal_pub_remote_validate_form_PMID(&$form, $form_state) {
   $num_criteria = $form['num_criteria']['#default_value'];
-    
-  for ($i = 1; $i <= $num_criteria; $i++) {            
+
+  for ($i = 1; $i <= $num_criteria; $i++) {
     $search_terms =  trim($form_state['values']["search_terms-$i"]);
     $scope =  $form_state['values']["scope-$i"];
     if ($scope == 'id' and !preg_match('/^PMID:\d+$/', $search_terms)) {
-      form_set_error("search_terms-$i", "The PubMed accession must be a numeric value, prefixed with 'PMID:' (e.g. PMID:23024789).");  
-    }       
-  }  
+      form_set_error("search_terms-$i", "The PubMed accession must be a numeric value, prefixed with 'PMID:' (e.g. PMID:23024789).");
+    }
+  }
 }
 /**
  *
  */
 function tripal_pub_remote_search_PMID($search_array, $num_to_retrieve, $pager_id) {
-  
+
   // convert the terms list provicded by the caller into a string with words
   // separated by a '+' symbol.
   $num_criteria = $search_array['num_criteria'];
   $days = $search_array['days'];
 
   $search_str = '';
-  
+
   for ($i = 1; $i <= $num_criteria; $i++) {
     $search_terms = trim($search_array['criteria'][$i]['search_terms']);
     $scope = $search_array['criteria'][$i]['scope'];
     $is_phrase = $search_array['criteria'][$i]['is_phrase'];
     $op = $search_array['criteria'][$i]['operation'];
-    
+
     if ($op) {
       $search_str .= "$op ";
-    }    
-    
+    }
+
     // if this is phrase make sure the search terms are surrounded by quotes
     if ($is_phrase) {
-      $search_terms = "\"$search_terms\""; 
+      $search_terms = "\"$search_terms\"";
     }
     $search_str .= '(';
-    
+
     if ($scope == 'title') {
       $search_str .= $search_terms . '[Title]';
-    }    
+    }
     elseif ($scope == 'author') {
       $search_str .= $search_terms . '[Author]';
-    }    
+    }
     elseif ($scope == 'abstract') {
       $search_str .= $search_terms . '[Title/Abstract]';
     }
@@ -74,28 +74,28 @@ function tripal_pub_remote_search_PMID($search_array, $num_to_retrieve, $pager_i
     }
     elseif ($scope == 'id') {
       $search_terms = preg_replace('/PMID:([^\s]*)/', '$1', $search_terms);
-      $search_str .=  $search_terms . '[Uid]';      
+      $search_str .=  $search_terms . '[Uid]';
     }
     else {
       $search_str .= $search_terms;
-    }    
-    $search_str .= ')'; 
-  }  
+    }
+    $search_str .= ')';
+  }
   if ($days) {
     // get the date of the day suggested
     $past_timestamp = time() - ($days * 86400);
-    $past_date = getdate($past_timestamp); 
+    $past_date = getdate($past_timestamp);
     $search_str .= " AND (\"" . sprintf("%04d/%02d/%02d", $past_date['year'], $past_date['mon'], $past_date['mday']) . "\"[Date - Create] : \"3000\"[Date - Create]))";
-  }  
-  
+  }
+
   $search_array['limit'] = $num_to_retrieve;
-  $search_array['search_string'] = $search_str;  
-  
+  $search_array['search_string'] = $search_str;
+
   unset($_SESSION['tripal_pub_PMID_query']);
   // we want to get the list of pubs using the search terms but using a Drupal style pager
-  $pubs = tripal_pager_callback('tripal_pub_PMID_range',  $num_to_retrieve, $pager_id, 
+  $pubs = tripal_pager_callback('tripal_pub_PMID_range',  $num_to_retrieve, $pager_id,
     'tripal_pub_PMID_count', $search_array);
- 
+
   return $pubs;
 }
 
@@ -107,7 +107,7 @@ function tripal_pub_remote_search_PMID($search_array, $num_to_retrieve, $pager_i
 function tripal_pub_PMID_count($search_array) {
   $search_str = $search_array['search_string'];
   $limit = $search_array['limit'];
-  
+
   $results = tripal_pub_PMID_search_init($search_str, $limit);
   $_SESSION['tripal_pub_PMID_query'][$search_str]['Count'] = $results['Count'];
   $_SESSION['tripal_pub_PMID_query'][$search_str]['WebEnv'] = $results['WebEnv'];
@@ -125,29 +125,29 @@ function tripal_pub_PMID_count($search_array) {
 function tripal_pub_PMID_range($search_array, $start = 0, $limit = 10) {
   $search_str = $search_array['search_string'];
   $limit = $search_array['limit'];
-  
+
   $count = $_SESSION['tripal_pub_PMID_query'][$search_str]['Count'];
   if ($count == 0) {
     return array();
   }
-    
+
   // get the query_key and the web_env from the previous count query.
   $query_key = $_SESSION['tripal_pub_PMID_query'][$search_str]['QueryKey'];
   $web_env   = $_SESSION['tripal_pub_PMID_query'][$search_str]['WebEnv'];
-  
+
   // if this function has been called without calling the count function
   // then we need to do the query.
   if (!$query_key) {
     $results = tripal_pub_PMID_search_init($search_str, $limit);
     $_SESSION['tripal_pub_PMID_query']['WebEnv'] = $results['WebEnv'];
-    $_SESSION['tripal_pub_PMID_query']['QueryKey'] = $results['QueryKey']; 
+    $_SESSION['tripal_pub_PMID_query']['QueryKey'] = $results['QueryKey'];
     $query_key =  $results['QueryKey'];
     $web_env = $results['WebEnv'];
   }
 
-  // now get the list of PMIDs from the previous search  
+  // now get the list of PMIDs from the previous search
   $pmids_txt = tripal_pub_PMID_fetch($query_key, $web_env, 'uilist', 'text', $start, $limit);
- 
+
   // iterate through each PMID and get the publication record. This requires a new search and new fetch
   $pmids = explode("\n", trim($pmids_txt));
   $pubs = array();
@@ -155,13 +155,13 @@ function tripal_pub_PMID_range($search_array, $start = 0, $limit = 10) {
     // now retrieve the individual record
     $pub_xml = tripal_pub_PMID_fetch($query_key, $web_env, 'null', 'xml', 0, 1, array('id' => $pmid));
     $pub     = tripal_pub_PMID_parse_pubxml($pub_xml);
-    $pubs[]  = $pub;    
-  } 
+    $pubs[]  = $pub;
+  }
   return $pubs;
 }
 
 /*
- * 
+ *
  */
 function tripal_pub_PMID_search_init($search_str, $retmax){
    
@@ -178,9 +178,9 @@ function tripal_pub_PMID_search_init($search_str, $retmax){
   $rfh = fopen($query_url, "r");
   if (!$rfh) {
     drupal_set_message('Could not perform Pubmed query. Cannot connect to Entrez.', 'error');
-    return 0;    
+    return 0;
   }
-  
+
   // retrieve the XML results
   $query_xml = '';
   while (!feof($rfh)) {
@@ -190,24 +190,24 @@ function tripal_pub_PMID_search_init($search_str, $retmax){
   //dpm("<pre>$query_xml</pre>");
   $xml = new XMLReader();
   $xml->xml($query_xml);
-  
+
   // iterate though the child nodes of the <eSearchResult> tag and get the count, history and query_id
   $result = array();
   while ($xml->read()) {
     $element = $xml->name;
-  
+
     if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'WebEnv') {
-      // we've read as much as we need. If we go too much further our counts 
+      // we've read as much as we need. If we go too much further our counts
       // will get messed up by other 'Count' elements.  so we're done.
       break;
     }
     if ($xml->nodeType == XMLReader::ELEMENT) {
-      
+
       switch ($element) {
         case 'Count':
           $xml->read();
           $result['Count'] = $xml->value;
-          break;        
+          break;
         case 'WebEnv':
           $xml->read();
           $result['WebEnv'] = $xml->value;
@@ -218,15 +218,15 @@ function tripal_pub_PMID_search_init($search_str, $retmax){
           break;
       }
     }
-  }  
+  }
   return $result;
 }
 
 /*
- * 
+ *
  */
-function tripal_pub_PMID_fetch($query_key, $web_env, $rettype = 'null', 
-  $retmod = 'null', $start = 0, $limit = 10, $args = array()){
+function tripal_pub_PMID_fetch($query_key, $web_env, $rettype = 'null',
+$retmod = 'null', $start = 0, $limit = 10, $args = array()){
 
   // repeat the search performed previously (using WebEnv & QueryKey) to retrieve
   // the PMID's within the range specied.  The PMIDs will be returned as a text list
@@ -238,14 +238,14 @@ function tripal_pub_PMID_fetch($query_key, $web_env, $rettype = 'null',
     "&db=Pubmed" .
     "&query_key=$query_key".
     "&WebEnv=$web_env";
-  
+
   foreach ($args as $key => $value) {
     if(is_array($value)) {
       $fetch_url .= "&$key=";
       foreach ($value as $item) {
         $fetch_url .= "$item,";
       }
-      $fetch_url = substr($fetch_url, 0, -1); // remove trailing comma  
+      $fetch_url = substr($fetch_url, 0, -1); // remove trailing comma
     }
     else {
       $fetch_url .= "&$key=$value";
@@ -255,45 +255,45 @@ function tripal_pub_PMID_fetch($query_key, $web_env, $rettype = 'null',
   $rfh = fopen($fetch_url, "r");
   if (!$rfh) {
     drupal_set_message('ERROR: Could not perform PubMed query.', 'error');
-    return '';    
+    return '';
   }
   $results = '';
   if($rfh) {
     while (!feof($rfh)) {
       $results .= fread($rfh, 255);
-    }  
+    }
     fclose($rfh);
   }
-  
+
   return $results;
 }
 
 /*
  * This function parses the XML containing details of a publication and
- * converts it into an associative array of where keys are Tripal Pub 
+ * converts it into an associative array of where keys are Tripal Pub
  * ontology terms and the values are extracted from the XML. The
- * XML should contain only a single publication record.  
- * 
+ * XML should contain only a single publication record.
+ *
  * Information about the valid elements in the PubMed XML can be found here:
  * http://www.nlm.nih.gov/bsd/licensee/elements_descriptions.html
- * 
+ *
  * Information about PubMed's citation format can be found here
  * http://www.nlm.nih.gov/bsd/policy/cit_format.html
  */
 function tripal_pub_PMID_parse_pubxml($pub_xml) {
   $pub = array();
-  
+
   if (!$pub_xml) {
     return $pub;
   }
-  
+
   // read the XML and iterate through it.
   $xml = new XMLReader();
   $xml->xml(trim($pub_xml));
-  while ($xml->read()) {    
-    $element = $xml->name;    
+  while ($xml->read()) {
+    $element = $xml->name;
     if ($xml->nodeType == XMLReader::ELEMENT) {
-      
+
       switch ($element) {
         case 'ERROR':
           $xml->read(); // get the value for this element
@@ -303,14 +303,14 @@ function tripal_pub_PMID_parse_pubxml($pub_xml) {
           // thre are multiple places where a PMID is present in the XML and
           // since this code does not descend into every branch of the XML tree
           // we will encounter many of them here.  Therefore, we only want the
-          // PMID that we first encounter. If we already have the PMID we will 
+          // PMID that we first encounter. If we already have the PMID we will
           // just skip it.  Examples of other PMIDs are in the articles that
           // cite this one.
           $xml->read(); // get the value for this element
           if(!$pub['Publication Dbxref']) {
             $pub['Publication Dbxref'] = 'PMID:' . $xml->value;
           }
-          break;        
+          break;
         case 'Article':
           $pub_model = $xml->getAttribute('PubModel');
           $pub['Publication Model'] = $pub_model;
@@ -326,7 +326,7 @@ function tripal_pub_PMID_parse_pubxml($pub_xml) {
           // TODO: meant for protocol list
           break;
         case 'CitationSubset':
-          // TODO: not sure this is needed.         
+          // TODO: not sure this is needed.
           break;
         case 'CommentsCorrections':
           // TODO: handle this
@@ -360,31 +360,31 @@ function tripal_pub_PMID_parse_pubxml($pub_xml) {
           break;
         case 'DeleteCitation':
           // TODO: need to know how to handle this
-          break;          
+          break;
         default:
           break;
       }
     }
   }
   $pub['Citation'] = tripal_pub_create_citation($pub);
-  
+
   $pub['raw'] = $pub_xml;
   return $pub;
 }
 
 /*
- * 
+ *
  */
 function tripal_pub_PMID_parse_medline_journal_info($xml, &$pub) {
   while ($xml->read()) {
     // get this element name
-    $element = $xml->name;     
-        
+    $element = $xml->name;
+
     // if we're at the </Article> element then we're done with the article...
     if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'MedlineJournalInfo') {
-      return;  
+      return;
     }
-    if ($xml->nodeType == XMLReader::ELEMENT) { 
+    if ($xml->nodeType == XMLReader::ELEMENT) {
       switch ($element) {
         case 'Country':
           // the place of publication of the journal
@@ -399,7 +399,7 @@ function tripal_pub_PMID_parse_medline_journal_info($xml, &$pub) {
           break;
         case 'ISSNLinking':
           // TODO: not sure how this is different from ISSN
-          break;  
+          break;
         default:
           break;
       }
@@ -408,19 +408,19 @@ function tripal_pub_PMID_parse_medline_journal_info($xml, &$pub) {
 }
 
 /*
- * 
+ *
  */
 function tripal_pub_PMID_parse_article($xml, &$pub) {
-    
+
   while ($xml->read()) {
     // get this element name
-    $element = $xml->name;     
-        
+    $element = $xml->name;
+
     // if we're at the </Article> element then we're done with the article...
     if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'Article') {
-      return;  
+      return;
     }
-    if ($xml->nodeType == XMLReader::ELEMENT) {    
+    if ($xml->nodeType == XMLReader::ELEMENT) {
       switch ($element) {
         case 'Journal':
           tripal_pub_PMID_parse_journal($xml, $pub);
@@ -428,14 +428,14 @@ function tripal_pub_PMID_parse_article($xml, &$pub) {
         case 'ArticleTitle':
           $xml->read();
           // remoave any trailing period from the title
-          $pub['Title'] = trim(preg_replace('/\.$/', '', $xml->value)); 
+          $pub['Title'] = trim(preg_replace('/\.$/', '', $xml->value));
           break;
         case 'Abstract':
           tripal_pub_PMID_parse_abstract($xml, $pub);
           break;
         case 'Pagination':
           tripal_pub_PMID_parse_pagination($xml, $pub);
-          break;  
+          break;
         case 'ELocationID':
           $type = $xml->getAttribute('EIdType');
           $valid = $xml->getAttribute('ValidYN');
@@ -448,7 +448,7 @@ function tripal_pub_PMID_parse_article($xml, &$pub) {
             $pub['PII'] = $elocation;
           }
           $pub['Elocation'] = $elocation;
-          break;        
+          break;
         case 'Affiliation':
           // the affiliation tag at this level is meant solely for the first author
           $xml->read();
@@ -459,8 +459,8 @@ function tripal_pub_PMID_parse_article($xml, &$pub) {
           tripal_pub_PMID_parse_authorlist($xml, $pub);
           break;
         case 'InvestigatorList':
-          // TODO: perhaps handle this one day.  The investigator list is to list the names of people who 
-          // are members of a collective or corporate group that is an author in the paper. 
+          // TODO: perhaps handle this one day.  The investigator list is to list the names of people who
+          // are members of a collective or corporate group that is an author in the paper.
           break;
         case 'Language':
           $xml->read();
@@ -482,13 +482,13 @@ function tripal_pub_PMID_parse_article($xml, &$pub) {
           $xml->read();
           $pub['Vernacular Title'][] = $xml->value;
           break;
-        case 'ArticleDate': 
+        case 'ArticleDate':
           // TODO: figure out what to do with this element. We already have the
           // published date in the <PubDate> field, but this date should be in numeric
-          // form and may have more information.         
+          // form and may have more information.
           break;
         default:
-          break;     
+          break;
       }
     }
   }
@@ -496,66 +496,66 @@ function tripal_pub_PMID_parse_article($xml, &$pub) {
 /*
  * 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 
+ *
+ * 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.
  */
 function tripal_pub_PMID_parse_publication_type($xml, &$pub) {
-  
+
   while ($xml->read()) {
-    $element = $xml->name;    
-      
+    $element = $xml->name;
+
     if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'PublicationTypeList') {
       // we've reached the </PublicationTypeList> element so we're done.
       return;
     }
     if ($xml->nodeType == XMLReader::ELEMENT) {
       switch ($element) {
-        case 'PublicationType':  
+        case 'PublicationType':
           $xml->read();
           $pub_cvterm = tripal_cv_get_cvterm_by_name($xml->value, NULL, 'tripal_pub');
           if (!$pub_cvterm) {
             // see if this we can find the name using a synonym
             $pub_cvterm = tripal_cv_get_cvterm_by_synonym($xml->value, NULL, 'tripal_pub');
             if (!$pub_cvterm) {
-              watchdog('tpub_pubmed', 'Cannot find a valid vocabulary term for the publication type: "%term".', 
-                array('%term' => $xml->value), WATCHDOG_ERROR);
+              watchdog('tpub_pubmed', 'Cannot find a valid vocabulary term for the publication type: "%term".',
+              array('%term' => $xml->value), WATCHDOG_ERROR);
             }
           }
           else {
             $pub['Publication Type'][] = $pub_cvterm->name;
-          }            
-          break;          
+          }
+          break;
         default:
           break;
       }
     }
-  }  
+  }
 }
 /*
- * 
+ *
  */
 function tripal_pub_PMID_parse_abstract($xml, &$pub) {
   $abstract = '';
-  
+
   while ($xml->read()) {
     $element = $xml->name;
-      
+
     if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'Abstract') {
-      // we've reached the </Abstract> element so return   
-      $pub['Abstract'] = $abstract;        
+      // we've reached the </Abstract> element so return
+      $pub['Abstract'] = $abstract;
       return;
     }
     // the abstract text can be just a singe paragraph or be broken into multiple
-    // abstract texts for structured abstracts.  Here we will just combine then 
+    // abstract texts for structured abstracts.  Here we will just combine then
     // into a single element in the order that they arrive in HTML format
     if ($xml->nodeType == XMLReader::ELEMENT) {
       switch ($element) {
         case 'AbstractText':
           $label = $xml->getAttribute('Label');
           $xml->read();
-          if ($label) { 
-            $part = "<p><b>$label</b></br>" . $xml->value . '</p>';           
+          if ($label) {
+            $part = "<p><b>$label</b></br>" . $xml->value . '</p>';
             $abstract .= $part;
             $pub['Structured Abstract Part'][] = $part;
           }
@@ -566,7 +566,7 @@ function tripal_pub_PMID_parse_abstract($xml, &$pub) {
         case 'CopyrightInformation':
           $xml->read();
           $pub['Copyright'] = $xml->value;
-          break;          
+          break;
         default:
           break;
       }
@@ -574,24 +574,24 @@ function tripal_pub_PMID_parse_abstract($xml, &$pub) {
   }
 }
 /*
- * 
+ *
  */
 function tripal_pub_PMID_parse_pagination($xml, &$pub) {
   while ($xml->read()) {
     $element = $xml->name;
-      
+
     if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'Pagination') {
       // we've reached the </Pagination> element so we're done.
       return;
     }
     if ($xml->nodeType == XMLReader::ELEMENT) {
       switch ($element) {
-        case 'MedlinePgn':  
+        case 'MedlinePgn':
           $xml->read();
           if(trim($xml->value)) {
             $pub['Pages'] = $xml->value;
           }
-          break;          
+          break;
         default:
           break;
       }
@@ -599,42 +599,42 @@ function tripal_pub_PMID_parse_pagination($xml, &$pub) {
   }
 }
 /*
- * 
+ *
  */
 function tripal_pub_PMID_parse_journal($xml, &$pub) {
-  
+
   while ($xml->read()) {
     $element = $xml->name;
-      
+
     if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'Journal') {
       return;
     }
     if ($xml->nodeType == XMLReader::ELEMENT) {
       switch ($element) {
-        case 'ISSN':  
-          $issn_type = $xml->getAttribute('IssnType');          
+        case 'ISSN':
+          $issn_type = $xml->getAttribute('IssnType');
           $xml->read();
           $issn = $xml->value;
           $pub['ISSN'] = $issn;
-          if ($issn_type == 'Electronic') {            
-            $pub['eISSN'] = $issn;  
+          if ($issn_type == 'Electronic') {
+            $pub['eISSN'] = $issn;
+          }
+          if ($issn_type == 'Print') {
+            $pub['pISSN'] = $issn;
           }
-          if ($issn_type == 'Print') {            
-            $pub['pISSN'] = $issn;  
-          }                 
           break;
-        case 'JournalIssue':   
+        case 'JournalIssue':
           // valid values of cited_medium are 'Internet' and 'Print'
-          $cited_medium = $xml->getAttribute('CitedMedium');                    
-          tripal_pub_PMID_parse_journal_issue($xml, $pub);       
-          break;        
-        case 'Title': 
+          $cited_medium = $xml->getAttribute('CitedMedium');
+          tripal_pub_PMID_parse_journal_issue($xml, $pub);
+          break;
+        case 'Title':
           $xml->read();
-          $pub['Journal Name'] = $xml->value;          
+          $pub['Journal Name'] = $xml->value;
           break;
-        case 'ISOAbbreviation': 
+        case 'ISOAbbreviation':
           $xml->read();
-          $pub['Journal Abbreviation'] = $xml->value;         
+          $pub['Journal Abbreviation'] = $xml->value;
           break;
         default:
           break;
@@ -643,35 +643,35 @@ function tripal_pub_PMID_parse_journal($xml, &$pub) {
   }
 }
 /*
- * 
+ *
  */
 function tripal_pub_PMID_parse_journal_issue($xml, &$pub) {
-  
+
   while ($xml->read()) {
     $element = $xml->name;
-      
+
     if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'JournalIssue'){
-      // if we're at the </JournalIssue> element then we're done 
+      // if we're at the </JournalIssue> element then we're done
       return;
     }
     if ($xml->nodeType == XMLReader::ELEMENT) {
       switch ($element) {
-        case 'Volume': 
+        case 'Volume':
           $xml->read();
-          $pub['Volume'] = $xml->value;         
+          $pub['Volume'] = $xml->value;
           break;
         case 'Issue':
           $xml->read();
-          $pub['Issue'] = $xml->value;           
+          $pub['Issue'] = $xml->value;
           break;
         case 'PubDate':
           $date = tripal_pub_PMID_parse_date($xml, 'PubDate');
           $year = $date['year'];
           $month = $date['month'];
-          $day = $date['day']; 
+          $day = $date['day'];
           $medline = $date['medline'];
            
-          $pub['Year'] = $year;            
+          $pub['Year'] = $year;
           if ($month and $day and $year) {
             $pub['Publication Date'] = "$year $month $day";
           }
@@ -680,70 +680,70 @@ function tripal_pub_PMID_parse_journal_issue($xml, &$pub) {
           }
           elseif (!$month and !$day and $year) {
             $pub['Publication Date'] = $year;
-          } 
+          }
           elseif ($medline) {
             $pub['Publication Date'] = $medline;
           }
           else {
             $pub['Publication Date'] = "Date Unknown";
-          }             
+          }
           break;
         default:
           break;
       }
     }
-  }  
+  }
 }
 
 /*
- * 
+ *
  */
 function tripal_pub_PMID_parse_date ($xml, $element_name) {
   $date = array();
-  
+
   while ($xml->read()) {
     $element = $xml->name;
-      
+
     if ($xml->nodeType == XMLReader::END_ELEMENT and $element == $element_name){
-      // if we're at the </$element_name> then we're done 
+      // if we're at the </$element_name> then we're done
       return $date;
     }
-    if ($xml->nodeType == XMLReader::ELEMENT) {           
+    if ($xml->nodeType == XMLReader::ELEMENT) {
       switch ($element) {
         case 'Year':
-          $xml->read(); 
-          $date['year'] = $xml->value;         
+          $xml->read();
+          $date['year'] = $xml->value;
           break;
         case 'Month':
-          $xml->read(); 
-          $month = 
-          $date['month'] = $xml->value;          
+          $xml->read();
+          $month =
+          $date['month'] = $xml->value;
           break;
         case 'Day':
-          $xml->read(); 
-          $date['day'] = $xml->value;          
+          $xml->read();
+          $date['day'] = $xml->value;
           break;
         case 'MedlineDate':
           // the medline date is when the date cannot be broken into distinct month day year.
-          $xml->read(); 
+          $xml->read();
           $date['year'] = preg_replace('/^(\d{4}).*$/', '\1', $xml->value);
-          $date['medline'] = $xml->value;          
+          $date['medline'] = $xml->value;
           break;
         default:
           break;
-      }    
+      }
     }
-  } 
+  }
 }
 /*
- * 
+ *
  */
 function tripal_pub_PMID_parse_authorlist($xml, &$pub) {
   $num_authors = 0;
-  
+
   while ($xml->read()) {
     $element = $xml->name;
-      
+
     if ($xml->nodeType == XMLReader::END_ELEMENT){
       // if we're at the </AuthorList> element then we're done with the article...
       if($element == 'AuthorList') {
@@ -751,7 +751,7 @@ function tripal_pub_PMID_parse_authorlist($xml, &$pub) {
         $authors = '';
         foreach ($pub['Author List'] as $author) {
           if ($author['valid'] == 'N') {
-            // skip non-valid entries.  A non-valid entry should have 
+            // skip non-valid entries.  A non-valid entry should have
             // a corresponding corrected entry so we can saftely skip it.
             continue;
           }
@@ -759,8 +759,8 @@ function tripal_pub_PMID_parse_authorlist($xml, &$pub) {
             $authors .= $author['Collective'] . ', ';
           }
           else {
-            $authors .= $author['Surname'] . ' ' . $author['First Initials'] . ', '; 
-          }             
+            $authors .= $author['Surname'] . ' ' . $author['First Initials'] . ', ';
+          }
         }
         $authors = substr($authors, 0, -2);
         $pub['Authors'] = $authors;
@@ -770,36 +770,36 @@ function tripal_pub_PMID_parse_authorlist($xml, &$pub) {
       // start a new one.
       if($element == 'Author') {
         $num_authors++;
-      }  
+      }
     }
     if ($xml->nodeType == XMLReader::ELEMENT) {
       switch ($element) {
         case 'Author':
           $valid = $xml->getAttribute('ValidYN');
-          $pub['Author List'][$num_authors]['valid'] = $valid;          
+          $pub['Author List'][$num_authors]['valid'] = $valid;
           break;
-        case 'LastName':  
-          $xml->read(); 
-          $pub['Author List'][$num_authors]['Surname'] = $xml->value;         
+        case 'LastName':
+          $xml->read();
+          $pub['Author List'][$num_authors]['Surname'] = $xml->value;
           break;
-        case 'ForeName': 
-          $xml->read(); 
-          $pub['Author List'][$num_authors]['Given Name'] = $xml->value;          
+        case 'ForeName':
+          $xml->read();
+          $pub['Author List'][$num_authors]['Given Name'] = $xml->value;
           break;
-        case 'Initials': 
-          $xml->read(); 
-          $pub['Author List'][$num_authors]['First Initials'] = $xml->value;          
+        case 'Initials':
+          $xml->read();
+          $pub['Author List'][$num_authors]['First Initials'] = $xml->value;
           break;
-        case 'Suffix': 
-          $xml->read(); 
-          $pub['Author List'][$num_authors]['Suffix'] = $xml->value;          
+        case 'Suffix':
+          $xml->read();
+          $pub['Author List'][$num_authors]['Suffix'] = $xml->value;
           break;
-        case 'CollectiveName': 
-          $xml->read(); 
-          $pub['Author List'][$num_authors]['Collective'] = $xml->value;          
+        case 'CollectiveName':
+          $xml->read();
+          $pub['Author List'][$num_authors]['Collective'] = $xml->value;
           break;
-        case 'Identifier': 
-          // according to the specification, this element is not yet used.                  
+        case 'Identifier':
+          // according to the specification, this element is not yet used.
           break;
         default:
           break;
@@ -809,7 +809,7 @@ function tripal_pub_PMID_parse_authorlist($xml, &$pub) {
 }
 
 /*
- * Language abbreviations were obtained here: 
+ * Language abbreviations were obtained here:
  * http://www.nlm.nih.gov/bsd/language_table.html
  */
 function tripal_pub_remote_search_get_language($lang_abbr) {

+ 190 - 190
tripal_pub/includes/pub_form.inc

@@ -1,17 +1,17 @@
-<?php 
+<?php
 
 /**
  * This is the chado_pub node form callback. The arguments
- * are out of order from a typical form because it's a defined callback 
+ * are out of order from a typical form because it's a defined callback
  */
 
-function chado_pub_form($node, $form_state) { 
+function chado_pub_form($node, $form_state) {
   tripal_core_ahah_init_form();
   $form = array();
-  
-  $pub = $node->pub;  
+
+  $pub = $node->pub;
   $pub_id = $pub->pub_id;
-    
+
   $d_title        = $form_state['values']['pubtitle']     ? $form_state['values']['pubtitle']    : $pub->title;
   $d_uniquename   = $form_state['values']['uniquename']   ? $form_state['values']['uniquename']  : $pub->uniquename;
   $d_type_id      = $form_state['values']['type_id']      ? $form_state['values']['type_id']     : $pub->type_id->cvterm_id;
@@ -25,22 +25,22 @@ function chado_pub_form($node, $form_state) {
   $d_publisher    = $form_state['values']['publisher']    ? $form_state['values']['publisher']   : $pub->publisher;
   $d_pubplace     = $form_state['values']['pubplace']     ? $form_state['values']['pubplace']    : $pub->pubplace;
   $d_is_obsolete  = $form_state['values']['is_obsolete']  ? $form_state['values']['is_obsolete'] : $pub->is_obsolete;
-  
+
   // if the obsolete value is set by the database then it is in the form of
   // 't' or 'f', we need to convert to 1 or 0
   $d_is_obsolete = $d_is_obsolete == 't' ? 1 : $d_is_obsolete;
   $d_is_obsolete = $d_is_obsolete == 'f' ? 0 : $d_is_obsolete;
 
-  // on AHAH callbacks we want to keep a list of all the properties that have been removed 
+  // on AHAH callbacks we want to keep a list of all the properties that have been removed
   // we'll store this info in a hidden field and retrieve it here
-  $d_removed = $form_state['values']['removed']; 
-    
+  $d_removed = $form_state['values']['removed'];
+
   // get the number of new fields that have been aded via AHAH callbacks
   $num_new = $form_state['values']['num_new'] ? $form_state['values']['num_new'] : 0;
 
   // initialze default properties array. This is where we store the property defaults
-  $d_properties = array();      
-  
+  $d_properties = array();
+
   // get the list of publication types.  In the Tripal publication
   // ontologies these are all grouped under the term 'Publication Type'
   // we want the default to be 'Journal Article'
@@ -63,8 +63,8 @@ function chado_pub_form($node, $form_state) {
       $d_type_id = $pub_type->cvterm_id;
     }
   }
-  
-  // get publication properties list 
+
+  // get publication properties list
   $properties_select = array();
   $properties_select[] = 'Select a Property';
   $properties_list = array();
@@ -79,7 +79,7 @@ function chado_pub_form($node, $form_state) {
       NOT CVTS.is_obsolete = 1
     ORDER BY CVTS.name ASC 
   ";
-  $prop_types = chado_query($sql); 
+  $prop_types = chado_query($sql);
   while ($prop = db_fetch_object($prop_types)) {
     // the 'Citation' term is special because it serves
     // both as a property and as the uniquename for the publiation table
@@ -88,26 +88,26 @@ function chado_pub_form($node, $form_state) {
     }
     $properties_list[$prop->cvterm_id] = $prop;
   }
-  
+
   $form['pub_id'] = array(
     '#type' => 'hidden',
     '#value' => $pub_id,
   );
-  
+
   // a drupal title can only be 255 characters, but the Chado title can be much longer.
   // we use the publication title as the drupal title, but we'll need to truncate it.
   $form['title'] = array(
     '#type' => 'hidden',
     '#value' => substr($d_title, 0, 255),
   );
-  
+
   $form['pubtitle'] = array(
     '#type' => 'textarea',
     '#title' => t('Publication Title'),
     '#default_value' => $d_title,
     '#required' => TRUE,
   );
-  
+
   $form['type_id'] = array(
     '#type' => 'select',
     '#title' => t('Publication Type'),
@@ -115,14 +115,14 @@ function chado_pub_form($node, $form_state) {
     '#required' => TRUE,
     '#default_value' => $d_type_id,
   );
-    
+
   $form['pyear'] = array(
     '#type' => 'textfield',
     '#title' => t('Publication Year'),
     '#default_value' => $d_pyear,
     '#required' => TRUE,
     '#size' => 5,
-  );  
+  );
   $form['uniquename'] = array(
     '#type' => 'textarea',
     '#title' => t('Citation'),
@@ -135,21 +135,21 @@ function chado_pub_form($node, $form_state) {
         suffer taxonomic influence?</a> J Ethnopharmacol. 2013 Apr 19; 146(3):842-52.</pre>'),
     '#required' => TRUE,
   );
-  
+
   // add in the properties that are actually stored in the pub table fields.
-  $num_properties = chado_pub_node_form_add_pub_table_props($form, $form_state, $properties_list, 
-    $d_properties, $d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages, $d_series_name);
-  
-  // add in the properties from the pubprop table   
+  $num_properties = chado_pub_node_form_add_pub_table_props($form, $form_state, $properties_list,
+  $d_properties, $d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages, $d_series_name);
+
+  // add in the properties from the pubprop table
   $num_properties += chado_pub_node_form_add_pubprop_table_props($form, $form_state, $pub_id, $d_properties, $d_removed);
-    
-  // add in any new properties that have been added by the user through an AHAH callback  
+
+  // add in any new properties that have been added by the user through an AHAH callback
   $num_new = chado_pub_node_form_add_new_props($form, $form_state, $d_properties, $d_removed);
-  
+
   // add an empty row of field to allow for addition of a new property
   chado_pub_node_form_add_new_empty_props($form, $properties_select);
-  
-  
+
+
   $form['removed'] = array(
     '#type' => 'hidden',
     '#value' => $d_removed,
@@ -163,7 +163,7 @@ function chado_pub_form($node, $form_state) {
     '#type' => 'hidden',
     '#value' => $num_properties,
   );
-  
+
   $form['is_obsolete'] = array(
     '#type' => 'checkbox',
     '#title' => t('Is Obsolete? (Check for Yes)'),
@@ -174,10 +174,10 @@ function chado_pub_form($node, $form_state) {
 
 }
 /*
- * 
+ *
  */
 function chado_pub_validate($node, &$form) {
-  
+
   // get the submitted values
   $title        = trim($node->pubtitle);
   $uniquename   = trim($node->uniquename);
@@ -195,7 +195,7 @@ function chado_pub_validate($node, &$form) {
   $pub_id       = $node->pub_id;
   $num_properties = $node->num_properties;
   $num_new = $node->num_new;
-  
+
   // if this is a delete then don't validate
   if($node->op == 'Delete') {
     return;
@@ -206,7 +206,7 @@ function chado_pub_validate($node, &$form) {
     form_set_error('pyear', t('The publication year should be a 4 digit year.'));
     return;
   }
-  
+
   // get the type of publication
   $values = array('cvterm_id' => $type_id);
   $options = array('statement_name' => 'sel_pub_ty');
@@ -216,7 +216,7 @@ function chado_pub_validate($node, &$form) {
     form_set_error('type_id', $message);
     return;
   }
-  
+
   // get the media name looking at the properties
   foreach ($node as $element => $value) {
     // if this is an existing property (either previously in the database or
@@ -226,10 +226,10 @@ function chado_pub_validate($node, &$form) {
       $prop_type = tripal_cv_get_cvterm_by_id($prop_type_id);
       if($prop_type->name == 'Conference Name' or $prop_type->name == 'Journal Name') {
         $series_name = $value;
-      }  
+      }
       if($prop_type->name == 'Citation') {
         $uniquename = $value;
-      }  
+      }
     }
     // if this is a new property (added by this submit of the form)
     elseif ($element = 'new_id') {
@@ -239,43 +239,43 @@ function chado_pub_validate($node, &$form) {
       }
       if($prop_type->name == 'Citation') {
         $uniquename = $value;
-      }    
+      }
     }
   }
-  
-  $skip_duplicate_check = 0; 
-  
+
+  $skip_duplicate_check = 0;
+
   // if this publication is a Patent then skip the validation below.  Patents can have the title
-  // name and year but be different    
+  // name and year but be different
   if (strcmp($cvterm[0]->name,'Patent') == 0) {
     $skip_duplicate_check = 1;
   }
- 
+
   // on an update ($pub_id is set), check to see if there have been  changes to fields that
-  // are used to check for duplicates. If not, then no need to check for duplicates  
+  // are used to check for duplicates. If not, then no need to check for duplicates
   if ($pub_id) {
     // first get the original title, type and year before it was changed
     $values = array('pub_id' => $pub_id);
     $columns =  array('title', 'pyear', 'type_id', 'series_name');
     $options = array('statement_name' => 'sel_pub_id');
-    $pub = tripal_core_chado_select('pub', $columns, $values, $options);       
+    $pub = tripal_core_chado_select('pub', $columns, $values, $options);
 
-    // if the title, type,  year or series_name have changed then check the pub 
+    // if the title, type,  year or series_name have changed then check the pub
     // to see if it is a duplicate of another
     if((strcmp(strtolower($pub[0]->title), strtolower($title)) == 0) and
-       (strcmp(strtolower($pub[0]->series_name), strtolower($series_name)) == 0) and
-       ($pub[0]->type_id == $type_id) and
-       ($pub[0]->year == $pyear)) {
-       $skip_duplicate_check = 1;
+    (strcmp(strtolower($pub[0]->series_name), strtolower($series_name)) == 0) and
+    ($pub[0]->type_id == $type_id) and
+    ($pub[0]->year == $pyear)) {
+      $skip_duplicate_check = 1;
     }
   }
-  
+
   // check to see if a duplicate publication already exists
-  if (!$skip_duplicate_check) {  
+  if (!$skip_duplicate_check) {
 
     // make sure the publication is unique using the prefereed import duplication check
     $import_dups_check = variable_get('tripal_pub_import_duplicate_check', 'title_year_media');
-    switch ($import_dups_check) {            
+    switch ($import_dups_check) {
       case 'title_year':
         $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, NULL, $pyear, NULL);
         // make sure we don't capture our pub_id in the list (remove it)
@@ -283,43 +283,43 @@ function chado_pub_validate($node, &$form) {
           if($found_pub_id == $pub_id){
             unset($results[$index]);
           }
-        }         
+        }
         if (count($results) > 0) {
-          $message = t('A publication with this title and publication year, already exists.'); 
+          $message = t('A publication with this title and publication year, already exists.');
           form_set_error('pyear', $message);
         }
-        break;        
-      case 'title_year_type':          
+        break;
+      case 'title_year_type':
         $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, $cvterm[0]->name, $pyear, NULL);
-    
+
         // make sure we don't capture our pub_id in the list (remove it)
         foreach ($results as $index => $found_pub_id) {
           if($found_pub_id == $pub_id){
             unset($results[$index]);
           }
-        }         
+        }
         if (count($results) > 0) {
-          $message = t('A publication with this title, type and publication year, already exists.'); 
+          $message = t('A publication with this title, type and publication year, already exists.');
           form_set_error('pyear', $message);
         }
-        break;        
-      case 'title_year_media':          
+        break;
+      case 'title_year_media':
         $results = tripal_pub_get_pubs_by_title_type_pyear_series($title, NULL, $pyear, $series_name);
-    
+
         // make sure we don't capture our pub_id in the list (remove it)
         foreach ($results as $index => $found_pub_id) {
           if($found_pub_id == $pub_id){
             unset($results[$index]);
           }
-        }         
+        }
         if (count($results) > 0) {
-          $message = t('A publication with this title, media name (e.g. Journal Name) and publication year, already exists.'); 
+          $message = t('A publication with this title, media name (e.g. Journal Name) and publication year, already exists.');
           form_set_error('pyear', $message);
         }
         break;
-    }      
-  } 
-  // even though we are skipping the duplication checks above we must make sure the uniquename is unique 
+    }
+  }
+  // even though we are skipping the duplication checks above we must make sure the uniquename is unique
   // as that is the offical table constraint
   else {
     $results = tripal_pub_get_pub_by_uniquename($uniquename);
@@ -328,18 +328,18 @@ function chado_pub_validate($node, &$form) {
       if($found_pub_id == $pub_id){
         unset($results[$index]);
       }
-    }         
+    }
     if (count($results) > 0) {
-      $message = t('A publication with this unique citation already exists.'); 
+      $message = t('A publication with this unique citation already exists.');
       form_set_error('uniquename', $message);
-    }  
+    }
   }
 }
 /*
- * 
+ *
  */
 function chado_pub_node_form_add_new_empty_props(&$form, $properties_select) {
-  
+
   // add one more blank set of property fields
   $form['properties']['new']["new_id"] = array(
     '#type'          => 'select',
@@ -349,7 +349,7 @@ function chado_pub_node_form_add_new_empty_props(&$form, $properties_select) {
       'wrapper' => 'tripal-pub-new_value-desc',
       'event'   => 'change',
       'method'  => 'replace',          
-    ),   
+  ),
   );
   $form['properties']['new']["new_value"] = array(
     '#type'          => 'textarea',
@@ -357,8 +357,8 @@ function chado_pub_node_form_add_new_empty_props(&$form, $properties_select) {
     '#cols'          => 5,
     '#rows'          => $rows,
     '#description'   => '<div id="tripal-pub-new_value-desc"></div>'
-  );
-  $form['properties']['new']["add"] = array(
+    );
+    $form['properties']['new']["add"] = array(
     '#type'         => 'image_button',      
     '#value'        => t('Add'),
     '#src'          => drupal_get_path('theme', 'tripal') . '/images/add.png',
@@ -367,16 +367,16 @@ function chado_pub_node_form_add_new_empty_props(&$form, $properties_select) {
       'wrapper' => 'tripal-pub-edit-properties-table',
       'event'   => 'click',
       'method'  => 'replace',          
-    ),   
+    ),
     '#attributes' => array('onClick' => 'return false;'),
-  );   
+    );
 }
 /*
- * 
+ *
  */
 function chado_pub_node_form_add_new_props(&$form, $form_state, &$d_properties, &$d_removed) {
    
-  // first, add in all of the new properties that were added through a previous AHAH callback 
+  // first, add in all of the new properties that were added through a previous AHAH callback
   $j = 0;
   $num_properties++;
 
@@ -386,7 +386,7 @@ function chado_pub_node_form_add_new_props(&$form, $form_state, &$d_properties,
       if (preg_match('/new_value-(\d+)-(\d+)/', $element_name, $matches)) {
         $new_id = $matches[1];
         $rank = $matches[2];
-        
+
         // skip any properties that the user requested to delete through a previous
         // AHAH callback or through the current AHAH callback
         if($d_removed["$new_id-$rank"]) {
@@ -396,17 +396,17 @@ function chado_pub_node_form_add_new_props(&$form, $form_state, &$d_properties,
           $d_removed["$new_id-$rank"] = 1;
           continue;
         }
-        
+
         // get this new_id information
         $cvterm = tripal_core_chado_select('cvterm', array('name', 'definition'), array('cvterm_id' => $new_id));
-        
+
         // add it to the $d_properties array
         $d_properties[$new_id][$rank]['name']  = $cvterm->name;
         $d_properties[$new_id][$rank]['id']    = $new_id;
         $d_properties[$new_id][$rank]['value'] = $value;
         $d_properties[$new_id][$rank]['definition']  = $cvterm->definition;
-        $num_properties++; 
-      
+        $num_properties++;
+
         // determine how many rows we need in the textarea
         $rows = 1;
         if (preg_match('/Abstract/', $cvterm[0]->name)) {
@@ -415,7 +415,7 @@ function chado_pub_node_form_add_new_props(&$form, $form_state, &$d_properties,
         if ($cvterm[0]->name == 'Authors') {
           $rows = 2;
         }
-        
+
         // add the new fields
         $form['properties']['new'][$new_id][$rank]["new_id-$new_id-$rank"] = array(
           '#type'          => 'item',
@@ -428,7 +428,7 @@ function chado_pub_node_form_add_new_props(&$form, $form_state, &$d_properties,
           '#rows'          => $rows,
           '#description'   => $cvterm->definition,
         );
-        
+
         $form['properties']['new'][$new_id][$rank]["remove-$new_id-$rank"] = array(
           '#type'         => 'image_button',
           '#value'        => t('Remove'),
@@ -438,32 +438,32 @@ function chado_pub_node_form_add_new_props(&$form, $form_state, &$d_properties,
             'wrapper' => 'tripal-pub-edit-properties-table',
             'event'   => 'click',
             'method'  => 'replace',
-          ), 
+        ),
           '#attributes' => array('onClick' => 'return false;'),
-        );  
-      }           
+        );
+      }
     }
   }
-  
-  
+
+
   // second add in any new properties added during this callback
   if($form_state['post']['add']) {
     $new_id = $form_state['values']['new_id'];
     $new_value = $form_state['values']['new_value'];
-    
-    // get the rank by counting the number of entries 
+
+    // get the rank by counting the number of entries
     $rank = count($d_properties[$new_id]);
-    
+
     // get this new_id information
     $cvterm = tripal_core_chado_select('cvterm', array('name', 'definition'), array('cvterm_id' => $new_id));
-    
+
     // add it to the $d_properties array
     $d_properties[$new_id][$rank]['name']  = $cvterm->name;
     $d_properties[$new_id][$rank]['id']    = $new_id;
     $d_properties[$new_id][$rank]['value'] = $value;
     $d_properties[$new_id][$rank]['definition']  = $cvterm->definition;
-    $num_properties++; 
-  
+    $num_properties++;
+
     // determine how many rows we need in the textarea
     $rows = 1;
     if (preg_match('/Abstract/', $cvterm[0]->name)) {
@@ -472,7 +472,7 @@ function chado_pub_node_form_add_new_props(&$form, $form_state, &$d_properties,
     if ($cvterm[0]->name == 'Authors') {
       $rows = 2;
     }
-    
+
     // add the new fields
     $form['properties']['new'][$new_id][$rank]["new_id-$new_id-$rank"] = array(
       '#type'          => 'item',
@@ -485,7 +485,7 @@ function chado_pub_node_form_add_new_props(&$form, $form_state, &$d_properties,
       '#rows'          => $rows,
       '#description'   => $cvterm->definition,
     );
-    
+
     $form['properties']['new'][$new_id][$rank]["remove-$new_id-$rank"] = array(
       '#type'         => 'image_button',
       '#value'        => t('Remove'),
@@ -495,26 +495,26 @@ function chado_pub_node_form_add_new_props(&$form, $form_state, &$d_properties,
         'wrapper' => 'tripal-pub-edit-properties-table',
         'event'   => 'click',
         'method'  => 'replace',
-      ), 
+    ),
       '#attributes' => array('onClick' => 'return false;'),
     );
-    
+
   }
-    
+
   return $num_properties;
 }
 /*
- * 
+ *
  */
 function chado_pub_node_form_add_pubprop_table_props(&$form, $form_state, $pub_id, &$d_properties, &$d_removed) {
-  
+
   // get the properties for this publication
   $num_properties = 0;
-    
+
   if(!$pub_id) {
-    return $num_properties; 
+    return $num_properties;
   }
-  
+
   $sql = "
     SELECT CVT.cvterm_id, CVT.name, CVT.definition, PP.value, PP.rank
     FROM {pubprop} PP
@@ -524,17 +524,17 @@ function chado_pub_node_form_add_pubprop_table_props(&$form, $form_state, $pub_i
   ";
   $pub_props = chado_query($sql, $pub_id);
   while ($prop = db_fetch_object($pub_props)) {
-    
+
     $type_id = $prop->cvterm_id;
     $rank = count($d_properties[$type_id]);
-    
+
     // skip properties that are found in the pub table
-    if($prop->name == "Volume" or $prop->name == "Volume Title" or 
-       $prop->name == "Issue"  or $prop->name == "Pages" or
-       $prop->name == "Citation" or $prop->name == "Journal Name") {
-         continue;
+    if($prop->name == "Volume" or $prop->name == "Volume Title" or
+    $prop->name == "Issue"  or $prop->name == "Pages" or
+    $prop->name == "Citation" or $prop->name == "Journal Name") {
+      continue;
     }
-    
+
     // skip any properties that the user requested to delete through a previous
     // AHAH callback or through the current AHAH callback
     if($d_removed["$type_id-$rank"]) {
@@ -544,13 +544,13 @@ function chado_pub_node_form_add_pubprop_table_props(&$form, $form_state, $pub_i
       $d_removed["$type_id-$rank"] = 1;
       continue;
     }
-    
+
     $d_properties[$type_id][$rank]['name']  = $prop->name;
     $d_properties[$type_id][$rank]['id']    = $type_id;
     $d_properties[$type_id][$rank]['value'] = $prop->value;
     $d_properties[$type_id][$rank]['definition']  = $prop->definition;
-    $num_properties++; 
-  
+    $num_properties++;
+
     // determine how many rows we need in the textarea
     $rows = 1;
     if (preg_match('/Abstract/', $prop->name)) {
@@ -559,7 +559,7 @@ function chado_pub_node_form_add_pubprop_table_props(&$form, $form_state, $pub_i
     if ($prop->name == 'Authors') {
       $rows = 2;
     }
-  
+
     $form['properties'][$type_id][$rank]["prop_id-$type_id-$rank"] = array(
       '#type'          => 'item',
       '#value'         => $prop->name,
@@ -571,7 +571,7 @@ function chado_pub_node_form_add_pubprop_table_props(&$form, $form_state, $pub_i
       '#rows'          => $rows,
       '#description'   => $prop->definition,
     );
-    
+
     $form['properties'][$type_id][$rank]["remove-$type_id-$rank"] = array(
       '#type'         => 'image_button',
       '#value'        => t('Remove'),
@@ -581,23 +581,23 @@ function chado_pub_node_form_add_pubprop_table_props(&$form, $form_state, $pub_i
         'wrapper' => 'tripal-pub-edit-properties-table',
         'event'   => 'click',
         'method'  => 'replace',
-      ), 
+    ),
       '#attributes' => array('onClick' => 'return false;'),
-    );      
+    );
   }
   return $num_properties;
 }
 /*
- * 
+ *
  */
 function chado_pub_node_form_add_pub_table_props(&$form, $form_state, $properties_list,
-    &$d_properties, &$d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages, $d_series_name) {
-      
+&$d_properties, &$d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages, $d_series_name) {
+
   $num_properties = 0;
   $rank = 0;
-  
-  // add properties that are actually part of the pub table  
-  foreach($properties_list as $type_id => $prop) {     
+
+  // add properties that are actually part of the pub table
+  foreach($properties_list as $type_id => $prop) {
 
     // skip any properties that the user requested to delete through a previous
     // AHAH callback or through the current AHAH callback
@@ -608,20 +608,20 @@ function chado_pub_node_form_add_pub_table_props(&$form, $form_state, $propertie
       $d_removed["$type_id-$rank"] = 1;
       continue;
     }
-        
-    // if any of the properties match the fields in the pub table then we 
+
+    // if any of the properties match the fields in the pub table then we
     // want to include those automatically
-    if (($prop->name == 'Volume' and $d_volume) or         
-        ($prop->name == 'Issue' and $d_issue) or 
-        ($prop->name == 'Pages' and $d_pages) or
-        ($prop->name == 'Volume Title' and $d_volumetitle) or
-        ($prop->name == 'Journal Name' and $d_series_name)) {
-          
-      $d_properties[$type_id][$rank]['name']  = $prop->name;           
-      $d_properties[$type_id][$rank]['id']    = $type_id;            
+    if (($prop->name == 'Volume' and $d_volume) or
+    ($prop->name == 'Issue' and $d_issue) or
+    ($prop->name == 'Pages' and $d_pages) or
+    ($prop->name == 'Volume Title' and $d_volumetitle) or
+    ($prop->name == 'Journal Name' and $d_series_name)) {
+
+      $d_properties[$type_id][$rank]['name']  = $prop->name;
+      $d_properties[$type_id][$rank]['id']    = $type_id;
       $d_properties[$type_id][$rank]['definition']  = $prop->definition;
       $num_properties++;
-      
+
       if ($prop->name == 'Volume') {
         $d_properties[$type_id][$rank]['value'] = $d_volume;
       }
@@ -637,7 +637,7 @@ function chado_pub_node_form_add_pub_table_props(&$form, $form_state, $propertie
       if ($prop->name == 'Journal Name') {
         $d_properties[$type_id][$rank]['value'] = $d_series_name;
       }
-      
+
       // determine how many rows we need in the textarea
       $rows = 1;
       if (preg_match('/Abstract/', $prop->name)) {
@@ -646,7 +646,7 @@ function chado_pub_node_form_add_pub_table_props(&$form, $form_state, $propertie
       if ($prop->name == 'Authors') {
         $rows = 2;
       }
-      
+
       // add in the fields
       $form['properties'][$type_id][$rank]["prop_id-$type_id-$rank"] = array(
         '#type'          => 'item',
@@ -659,7 +659,7 @@ function chado_pub_node_form_add_pub_table_props(&$form, $form_state, $propertie
         '#rows'          => $rows,
         '#description'   => $description,
       );
-      
+
       $form['properties'][$type_id][$rank]["remove-$type_id-$rank"] = array(
         '#type'         => 'image_button',
         '#value'        => t('Remove'),
@@ -669,20 +669,20 @@ function chado_pub_node_form_add_pub_table_props(&$form, $form_state, $propertie
           'wrapper' => 'tripal-pub-edit-properties-table',
           'event'   => 'click',
           'method'  => 'replace',
-        ), 
+      ),
         '#attributes' => array('onClick' => 'return false;'),
-      ); 
+      );
     }
   }
   return $num_properties;
 }
 /*
- * 
+ *
  */
 function theme_chado_pub_node_form($form) {
 
   $properties_table = tripal_pub_theme_node_form_properties($form);
-  
+
   $markup  = drupal_render($form['pub_id']);
   $markup .= drupal_render($form['pubtitle']);
   $markup .= drupal_render($form['type_id']);
@@ -692,7 +692,7 @@ function theme_chado_pub_node_form($form) {
   $markup .= "<b>Include Additional Details</b><br>You may add additional properties to this publication by scrolling to the bottom of this table, selecting a property type from the dropdown and adding text.  You may add as many properties as desired by clicking the plus button on the right.  To remove a property, click the minus button";
   $markup .= $properties_table;
   $markup .= drupal_render($form['is_obsolete']);
-  
+
   $form['properties'] = array(
     '#type' => 'markup',
     '#value' =>  $markup,
@@ -701,128 +701,128 @@ function theme_chado_pub_node_form($form) {
 }
 
 /*
- * 
+ *
  */
 function tripal_pub_theme_node_form_properties($form) {
   $rows = array();
-  
+
   if ($form['properties']) {
-    
-    // first add in the properties derived from the pub and pubprop tables 
+
+    // first add in the properties derived from the pub and pubprop tables
     // the array tree for these properties looks like this:
     // $form['properties'][$type_id][$rank]["prop_id-$type_id-$rank"]
     foreach ($form['properties'] as $type_id => $elements) {
       // there are other fields in the properties array so we only
       // want the numeric ones those are our type_id
-      if (is_numeric($type_id)) {     
+      if (is_numeric($type_id)) {
         foreach ($elements as $rank => $element) {
-          if (is_numeric($rank)) {          
-            $rows[] = array(  
-              drupal_render($element["prop_id-$type_id-$rank"]),    
-              drupal_render($element["prop_value-$type_id-$rank"]),
-              drupal_render($element["remove-$type_id-$rank"]),
+          if (is_numeric($rank)) {
+            $rows[] = array(
+            drupal_render($element["prop_id-$type_id-$rank"]),
+            drupal_render($element["prop_value-$type_id-$rank"]),
+            drupal_render($element["remove-$type_id-$rank"]),
             );
           }
         }
       }
-    }  
+    }
 
     // second, add in any new properties added by the user through AHAH callbacks
-    // the array tree for these properties looks like this: 
+    // the array tree for these properties looks like this:
     // $form['properties']['new'][$type_id][$rank]["new_id-$new_id-$rank"]
     foreach ($form['properties']['new'] as $type_id => $elements) {
-      if (is_numeric($type_id)) {    
+      if (is_numeric($type_id)) {
         foreach ($elements as $rank => $element) {
-          if (is_numeric($rank)) {          
-            $rows[] = array(  
-              drupal_render($element["new_id-$type_id-$rank"]),    
-              drupal_render($element["new_value-$type_id-$rank"]),
-              drupal_render($element["remove-$type_id-$rank"]),
+          if (is_numeric($rank)) {
+            $rows[] = array(
+            drupal_render($element["new_id-$type_id-$rank"]),
+            drupal_render($element["new_value-$type_id-$rank"]),
+            drupal_render($element["remove-$type_id-$rank"]),
             );
           }
         }
       }
     }
-  
+
     // finally add in a set of blank field for adding a new property
     $rows[] = array(
-      drupal_render($form['properties']['new']['new_id']),     
-      drupal_render($form['properties']['new']['new_value']),
-      drupal_render($form['properties']['new']['add']), 
-    ); 
+    drupal_render($form['properties']['new']['new_id']),
+    drupal_render($form['properties']['new']['new_value']),
+    drupal_render($form['properties']['new']['add']),
+    );
   }
-  
-  $headers = array('Property Type','Value', '');      
+
+  $headers = array('Property Type','Value', '');
   return theme('table', $headers, $rows, array('id'=> "tripal-pub-edit-properties-table"));
 }
 
 /*
- * 
+ *
  */
 function tripal_pub_property_add() {
   $status = TRUE;
 
   // prepare and render the form
-  $form = tripal_core_ahah_prepare_form(); 
+  $form = tripal_core_ahah_prepare_form();
 
   // we only want to return the properties as that's all we'll replace with this AHAh callback
   $data = tripal_pub_theme_node_form_properties($form);
-  
-  // bind javascript events to the new objects that will be returned 
+
+  // bind javascript events to the new objects that will be returned
   // so that AHAH enabled elements will work.
   $settings = tripal_core_ahah_bind_events();
 
   // return the updated JSON
   drupal_json(
-    array(
+  array(
       'status'   => $status, 
       'data'     => $data,
       'settings' => $settings,
-    )  
+  )
   );
 }
 /*
- * 
+ *
  */
 function tripal_pub_property_delete() {
   $status = TRUE;
 
   // prepare and render the form
-  $form = tripal_core_ahah_prepare_form(); 
+  $form = tripal_core_ahah_prepare_form();
 
   // we only want to return the properties as that's all we'll replace with this AHAh callback
   $data = tripal_pub_theme_node_form_properties($form);
 
-  // bind javascript events to the new objects that will be returned 
+  // bind javascript events to the new objects that will be returned
   // so that AHAH enabled elements will work.
   $settings = tripal_core_ahah_bind_events();
 
   // return the updated JSON
   drupal_json(
-    array(
+  array(
       'status'   => $status, 
       'data'     => $data,
       'settings' => $settings,
-    )  
+  )
   );
 }
 /*
- * 
+ *
  */
 function tripal_pub_property_get_description() {
   $new_id = $_POST['new_id'];
-  
+
   $values = array('cvterm_id' => $new_id);
   $cvterm = tripal_core_chado_select('cvterm', array('definition'), $values);
-  
+
   $description = '&nbsp;';
   if ($cvterm[0]->definition) {
     $description = $cvterm[0]->definition;
   }
   drupal_json(
-    array(
+  array(
       'status' => TRUE,
       'data'   => '<div id="tripal-pub-new_value-desc">' . $description . '</div>',
-    )    
+  )
   );
 }

+ 165 - 165
tripal_pub/includes/pub_importers.inc

@@ -5,12 +5,12 @@
  * @ingroup tripal_pub
  */
 function tripal_pub_importers_list() {
-  // clear out the session variable when we view the 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");    
+  $importers = db_query("SELECT * FROM {tripal_pub_import} ORDER BY name");
 
   while ($importer = db_fetch_object($importers)) {
     $criteria = unserialize($importer->criteria);
@@ -23,23 +23,23 @@ function tripal_pub_importers_list() {
       $operation = $criteria['criteria'][$i]['operation'];
       $criteria_str .= "$operation ($scope: $search_terms) ";
     }
- 
+
     $rows[] = array(
-      l(t('Edit/Test'), "admin/tripal/tripal_pub/import/edit/$importer->pub_import_id"),
-      $importer->name,
-      $criteria['remote_db'],
-      $criteria_str,
-      $importer->disabled ? 'Yes' : 'No',
-      $importer->do_contact ? 'Yes' : 'No',
-      l(t('Delete'), "admin/tripal/tripal_pub/import/delete/$importer->pub_import_id"),
+    l(t('Edit/Test'), "admin/tripal/tripal_pub/import/edit/$importer->pub_import_id"),
+    $importer->name,
+    $criteria['remote_db'],
+    $criteria_str,
+    $importer->disabled ? 'Yes' : 'No',
+    $importer->do_contact ? 'Yes' : 'No',
+    l(t('Delete'), "admin/tripal/tripal_pub/import/delete/$importer->pub_import_id"),
     );
   }
 
   $rows[] = array(
     'data' => array(
-      array('data' => l(t('Create a new publication importer.'), "admin/tripal/tripal_pub/import/new"),
+  array('data' => l(t('Create a new publication importer.'), "admin/tripal/tripal_pub/import/new"),
         'colspan' => 7),
-    )
+  )
   );
 
   $page = theme('table', $header, $rows);
@@ -47,17 +47,17 @@ function tripal_pub_importers_list() {
 }
 
 /*
- * 
+ *
  */
 function tripal_pub_importer_setup($action = 'new', $pub_import_id = NULL) {
   global $pager_total, $pager_total_items;
-  
+
   $pager_id = 0;
   $limit = 20;
-    
-  // generate the search form 
+
+  // generate the search form
   $form = drupal_get_form('tripal_pub_importer_setup_form',  $pub_import_id, $action);
-  
+
   $output = l("Return to publication importers list", "admin/tripal/tripal_pub/import_list");
   $output .= $form;
 
@@ -65,30 +65,30 @@ function tripal_pub_importer_setup($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;
-  $search_array['days'] = $days; 
+  $search_array['days'] = $days;
   for ($i = 1; $i <= $num_criteria; $i++) {
     $search_array['criteria'][$i]['search_terms'] = $_SESSION['tripal_pub_import']['criteria'][$i]['search_terms'];
-    $search_array['criteria'][$i]['scope']        = $_SESSION['tripal_pub_import']['criteria'][$i]['scope'];  
+    $search_array['criteria'][$i]['scope']        = $_SESSION['tripal_pub_import']['criteria'][$i]['scope'];
     $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 ($_SESSION['tripal_pub_import']['perform_search']) {
-    // get the list of publications from the remote database using the search criteria.  
+    // get the list of publications from the remote database using the search criteria.
     $pubs = tripal_pub_get_remote_search_results($remote_db, $search_array, $limit, $pager_id);
     //dpm($pubs);
-    
+
     // generate the pager
     $total_pages = $pager_total[$pager_id];
     $total_items = $pager_total_items[$pager_id];
     $page = isset($_GET['page']) ? $_GET['page'] : '0';
     $pager = theme('pager');
-    
+
     // iterate through the results and construct the table displaying the publications
     $rows = array();
     $i = $page * $limit + 1;
@@ -100,39 +100,39 @@ function tripal_pub_importer_setup($action = 'new', $pub_import_id = NULL) {
           $raw_link = l('raw', 'admin/tripal/tripal_pub/import/raw/' . $pub['Publication Dbxref'], array('attributes' => array('target' => '_blank')));
         }
         $rows[] = array(
-          number_format($i), 
-          $citation, 
-          $raw_link,
-        );        
+        number_format($i),
+        $citation,
+        $raw_link,
+        );
         $i++;
       }
     }
     $headers = array('', 'Publication', '');
-    $table = theme('table', $headers, $rows);   
-  
+    $table = theme('table', $headers, $rows);
+
     // join all to form the results
-    $output .= "<br><p><b>Found " . number_format($total_items) .  
+    $output .= "<br><p><b>Found " . number_format($total_items) .
       ". Page " . ($page + 1) . " of $total_pages. " .
       " Results</b></br>" . $table . '</p>' . $pager;    
   }
   return $output;
 }
 /*
- * 
+ *
  */
 function theme_tripal_pub_importer_setup_form($form) {
   $rows = array();
   foreach ($form['criteria'] as $i => $element) {
     if(is_numeric($i)) {
-      $rows[] = array(  
-        drupal_render($element["operation-$i"]),    
-        drupal_render($element["scope-$i"]),
-        drupal_render($element["search_terms-$i"]),
-        drupal_render($element["is_phrase-$i"]),
-        drupal_render($element["add-$i"]) . drupal_render($element["remove-$i"]),
+      $rows[] = array(
+      drupal_render($element["operation-$i"]),
+      drupal_render($element["scope-$i"]),
+      drupal_render($element["search_terms-$i"]),
+      drupal_render($element["is_phrase-$i"]),
+      drupal_render($element["add-$i"]) . drupal_render($element["remove-$i"]),
       );
     }
-  } 
+  }
   $headers = array('Operation','Scope', 'Search Terms', '','');
 
   $markup  = '';
@@ -141,10 +141,10 @@ function theme_tripal_pub_importer_setup_form($form) {
   $markup .= '  <div id="pub-search-form-col1">' . drupal_render($form['loader_name']) . '</div>';
   $markup .= '  <div id="pub-search-form-col3">' . drupal_render($form['days']) . '</div>';
   $markup .= '</div>';
-  $markup .= '<div id="pub-search-form-row2">' . drupal_render($form['disabled']) . '</div>'; 
+  $markup .= '<div id="pub-search-form-row2">' . drupal_render($form['disabled']) . '</div>';
   $markup .= '<div id="pub-search-form-row3">' . drupal_render($form['do_contact']) . '</div>';
   $markup .= theme('table', $headers, $rows, array('id' => 'tripal-pub-importer-table'));
-  
+
   $form['criteria'] = array(
     '#type' => 'markup',
     '#value' =>  $markup,
@@ -155,65 +155,65 @@ function theme_tripal_pub_importer_setup_form($form) {
 /**
  * Purpose: Provides the form to search pubmed
  *
-  * @ingroup tripal_pub
+ * @ingroup tripal_pub
  */
 function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NULL, $action = 'new') {
   tripal_core_ahah_init_form();
-     
-  // Set the default values. If the pub_import_id isn't already defined by the form values 
+   
+  // 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;
   if ($action == "edit" and !$form_state['values']) {
     $sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = %d";
     $importer = db_fetch_object(db_query($sql, $pub_import_id));
-    
+
     $criteria       = unserialize($importer->criteria);
     $remote_db      = $criteria['remote_db'];
     $days           = $criteria['days'];
     $disabled       = $criteria['disabled'];
     $do_contact     = $criteria['do_contact'];
-    $num_criteria   = $criteria['num_criteria'];    
-    $loader_name    = $criteria['loader_name'];  
+    $num_criteria   = $criteria['num_criteria'];
+    $loader_name    = $criteria['loader_name'];
   }
 
   // if we're here because the form was posted then load from the session variable (we lost the form state)
-  $num_criteria = isset($_SESSION['tripal_pub_import']['num_criteria']) ? $_SESSION['tripal_pub_import']['num_criteria'] : $num_criteria;    
+  $num_criteria = isset($_SESSION['tripal_pub_import']['num_criteria']) ? $_SESSION['tripal_pub_import']['num_criteria'] : $num_criteria;
   $loader_name  = isset($_SESSION['tripal_pub_import']['loader_name'])  ? $_SESSION['tripal_pub_import']['loader_name']  : $loader_name;
   $remote_db    = isset($_SESSION['tripal_pub_import']['remote_db'])    ? $_SESSION['tripal_pub_import']['remote_db']    : $remote_db;
-  $disabled     = isset($_SESSION['tripal_pub_import']['disabled'])     ? $_SESSION['tripal_pub_import']['disabled']     : $disabled;    
+  $disabled     = isset($_SESSION['tripal_pub_import']['disabled'])     ? $_SESSION['tripal_pub_import']['disabled']     : $disabled;
   $do_contact   = isset($_SESSION['tripal_pub_import']['do_contact'])   ? $_SESSION['tripal_pub_import']['do_contact']   : $do_contact;
   $days         = isset($_SESSION['tripal_pub_import']['days'])         ? $_SESSION['tripal_pub_import']['days']         : $days;
-      
-  
-  // If the form_state has variables then use those.  This happens when an error occurs on the form or the 
+
+
+  // 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 ($form_state['values']) {
-    $num_criteria = $form_state['values']['num_criteria'] ? $form_state['values']['num_criteria'] : $num_criteria;    
+    $num_criteria = $form_state['values']['num_criteria'] ? $form_state['values']['num_criteria'] : $num_criteria;
     $loader_name  = $form_state['values']['loader_name']  ? $form_state['values']['loader_name']  : $loader_name;
     $remote_db    = $form_state['values']['remote_db']    ? $form_state['values']['remote_db']    : $remote_db;
     $disabled     = $form_state['values']['disabled']     ? $form_state['values']['disabled']     : $disabled;
     $do_contact   = $form_state['values']['do_contact']   ? $form_state['values']['do_contact']   : $do_contact;
     $days         = $form_state['values']['days']         ? $form_state['values']['days']         : $days;
-  }    
-  
+  }
+
   // 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']);
   }
-  
+
    
   // change the number of criteria based on form_state post data.
   if (!$num_criteria) {
     $num_criteria = 1;
   }
-  if($form_state['post']["add-$num_criteria"]) {    
+  if($form_state['post']["add-$num_criteria"]) {
     $num_criteria++;
   }
-  if($form_state['post']["remove-$num_criteria"]) {    
+  if($form_state['post']["remove-$num_criteria"]) {
     $num_criteria--;
   }
-    
+
   $form['pub_import_id'] = array(
     '#type'          => 'hidden',
     '#value'         => $pub_import_id,
@@ -224,7 +224,7 @@ function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NU
     '#value'         => $action,
     '#required'      => TRUE,
   );
-  
+
   $form['loader_name'] = array(
     '#type'          => 'textfield',
     '#title'         => t('Loader Name'),
@@ -232,7 +232,7 @@ function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NU
     '#default_value' => $loader_name,
     '#required'      => TRUE,
   );
-  
+
   $supported_dbs = variable_get('tripal_pub_supported_dbs', array());
   $remote_dbs = array();
   $values = array(
@@ -256,7 +256,7 @@ function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NU
       'wrapper' => 'tripal-pub-importer-setup-form',
       'event'   => 'click',
       'method'  => 'replace',
-    ), 
+  ),
   );
 
   $form['num_criteria']= array(
@@ -267,7 +267,7 @@ function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NU
     '#type'          => 'hidden',
     '#default_value' => $pub_import_id,
   );
-  
+
   $form['days'] = array(
     '#type'          => 'textfield',
     '#title'         => t('Days since record modified'),
@@ -288,7 +288,7 @@ function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NU
        additional information such as affilation, etc. Otherwise, only authors names are retrieved.'),
     '#default_value' => $do_contact,
   );
-  
+
   // choices array
   $scope_choices = array(
     'any'      => 'Any Field',
@@ -297,78 +297,78 @@ function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NU
     'id'       => 'Accession',
     'title'    => 'Title',
     'journal'   => 'Journal Name'
-  );
+    );
 
-  $first_op_choices = array(
+    $first_op_choices = array(
     ''    => '',
     'NOT' => 'NOT'
-  ); 
-  $op_choices = array(
+    );
+    $op_choices = array(
     'AND' => 'AND',
     'OR'  => 'OR',
     'NOT' => 'NOT'
-  );
-  for($i = 1; $i <= $num_criteria; $i++) {
-    
-    // if we have criteria supplied from the database then use that as the initial defaults
-    if ($criteria) {
-      $search_terms = $criteria['criteria'][$i]['search_terms'];
-      $scope = $criteria['criteria'][$i]['scope'];
-      $is_phrase = $criteria['criteria'][$i]['is_phrase'];
-      $operation = $criteria['criteria'][$i]['operation'];
-    }
-    // if we're here because the form was posted then load from the session variable (we lost the form state)
-    $search_terms = isset($_SESSION['tripal_pub_import']['criteria'][$i]['search_terms']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['search_terms'] : $search_terms;
-    $scope        = isset($_SESSION['tripal_pub_import']['criteria'][$i]['scope'])        ? $_SESSION['tripal_pub_import']['criteria'][$i]['scope']        : $scope;
-    $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 ($form_state['values']) {
-      $search_terms = $form_state['values']["search_terms-$i"];
-      $scope        = $form_state['values']["scope-$i"];
-      $is_phrase    = $form_state['values']["is_phrase-$i"];
-      $operation    = $form_state['values']["operation-$i"];
-    }
-      
-    $form['criteria'][$i]["search_terms-$i"] = array(
+    );
+    for($i = 1; $i <= $num_criteria; $i++) {
+
+      // if we have criteria supplied from the database then use that as the initial defaults
+      if ($criteria) {
+        $search_terms = $criteria['criteria'][$i]['search_terms'];
+        $scope = $criteria['criteria'][$i]['scope'];
+        $is_phrase = $criteria['criteria'][$i]['is_phrase'];
+        $operation = $criteria['criteria'][$i]['operation'];
+      }
+      // if we're here because the form was posted then load from the session variable (we lost the form state)
+      $search_terms = isset($_SESSION['tripal_pub_import']['criteria'][$i]['search_terms']) ? $_SESSION['tripal_pub_import']['criteria'][$i]['search_terms'] : $search_terms;
+      $scope        = isset($_SESSION['tripal_pub_import']['criteria'][$i]['scope'])        ? $_SESSION['tripal_pub_import']['criteria'][$i]['scope']        : $scope;
+      $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 ($form_state['values']) {
+        $search_terms = $form_state['values']["search_terms-$i"];
+        $scope        = $form_state['values']["scope-$i"];
+        $is_phrase    = $form_state['values']["is_phrase-$i"];
+        $operation    = $form_state['values']["operation-$i"];
+      }
+
+      $form['criteria'][$i]["search_terms-$i"] = array(
       '#type'          => 'textfield',
       '#description'   => t('Please provide a list of words for searching. You may use 
         conjunctions such as "AND" or "OR" to separate words if they are expected in 
         the same scope. Uncheck the "Is Phrase" checkbox to use conjunctions'),
       '#default_value' => $search_terms,
       '#required'      => TRUE,
-    );
-    $form['criteria'][$i]["scope-$i"] = array(
+      );
+      $form['criteria'][$i]["scope-$i"] = array(
       '#type'          => 'select',
       '#description'   => t('Please select the fields to search for this term.'),
       '#options'       => $scope_choices,
       '#default_value' => $scope,
-    );  
-    $form['criteria'][$i]["is_phrase-$i"] = array(
+      );
+      $form['criteria'][$i]["is_phrase-$i"] = array(
       '#type'    => 'checkbox',
       '#title'   => t('Is Phrase?'),    
       '#default_value' => $is_phrase,
-    );  
-    
-    if ($i == 1) {
-      /*
-      $form['criteria'][$i]["operation-$i"] = array(
-        '#type'          => 'select',
-        '#options'       => $first_op_choices,
-        '#default_value' => $operation,
-      );*/
-    }
-    if ($i > 1) {
-      $form['criteria'][$i]["operation-$i"] = array(
+      );
+
+      if ($i == 1) {
+        /*
+         $form['criteria'][$i]["operation-$i"] = array(
+         '#type'          => 'select',
+         '#options'       => $first_op_choices,
+         '#default_value' => $operation,
+         );*/
+      }
+      if ($i > 1) {
+        $form['criteria'][$i]["operation-$i"] = array(
         '#type'          => 'select',
         '#options'       => $op_choices,
         '#default_value' => $operation,
-      );
-    }
-    if ($i == $num_criteria) {    
-      if($i > 1) {
-        $form['criteria'][$i]["remove-$i"] = array(
+        );
+      }
+      if ($i == $num_criteria) {
+        if($i > 1) {
+          $form['criteria'][$i]["remove-$i"] = array(
           '#type'         => 'image_button',
           '#value'        => t('Remove'),
           '#src'          => drupal_get_path('theme', 'tripal') . '/images/minus.png',
@@ -377,11 +377,11 @@ function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NU
             'wrapper' => 'tripal-pub-importer-setup-form',
             'event'   => 'click',
             'method'  => 'replace',
-          ), 
+          ),
           '#attributes' => array('onClick' => 'return false;'),
-        );
-      }
-      $form['criteria'][$i]["add-$i"] = array(
+          );
+        }
+        $form['criteria'][$i]["add-$i"] = array(
         '#type'         => 'image_button',      
         '#value'        => t('Add'),
         '#src'          => drupal_get_path('theme', 'tripal') . '/images/add.png',
@@ -390,35 +390,35 @@ function tripal_pub_importer_setup_form(&$form_state = NULL, $pub_import_id = NU
           'wrapper' => 'tripal-pub-importer-setup-form',
           'event'   => 'click',
           'method'  => 'replace',          
-        ),   
+        ),
         '#attributes' => array('onClick' => 'return false;'),
-      );
+        );
+      }
     }
-  }
-  
-  $form['test'] = array(
+
+    $form['test'] = array(
     '#type'         => 'submit',
     '#value'        => t('Test Importer'),
-  );
-  $form['save'] = array(
+    );
+    $form['save'] = array(
     '#type'         => 'submit',
     '#value'        => t('Save Importer'),
-  );
-  /*
-  $form['import'] = array(
-    '#type'         => 'submit',
-    '#value'        => t('Save & Import Now'),
-  );*/
-  $form['delete'] = array(
+    );
+    /*
+     $form['import'] = array(
+     '#type'         => 'submit',
+     '#value'        => t('Save & Import Now'),
+     );*/
+    $form['delete'] = array(
     '#type'         => 'submit',
     '#value'        => t('Delete Importer'),
-  );
+    );
 
-  // allow the selected remote database to make changes to the form if needed
-  $callback = "tripal_pub_remote_alter_form_$remote_db";  
-  call_user_func($callback, &$form, $form_state);
+    // allow the selected remote database to make changes to the form if needed
+    $callback = "tripal_pub_remote_alter_form_$remote_db";
+    call_user_func($callback, &$form, $form_state);
 
-  return $form;
+    return $form;
 }
 
 /**
@@ -432,11 +432,11 @@ function tripal_pub_importer_setup_form_validate($form, &$form_state) {
   $do_contact =  $form_state['values']["do_contact"];
   $loader_name =  trim($form_state['values']["loader_name"]);
 
-  for ($i = 1; $i <= $num_criteria; $i++) {            
+  for ($i = 1; $i <= $num_criteria; $i++) {
     $search_terms =  trim($form_state['values']["search_terms-$i"]);
     $scope =  $form_state['values']["scope-$i"];
     $is_phrase =  $form_state['values']["is_phrase-$i"];
-    $operation =  $form_state['values']["operation-$i"];    
+    $operation =  $form_state['values']["operation-$i"];
   }
 
   if ($days and !is_numeric($days) or preg_match('/\./', $days)) {
@@ -474,7 +474,7 @@ function tripal_pub_importer_setup_form_submit($form, &$form_state) {
     $scope =  $form_state['values']["scope-$i"];
     $is_phrase =  $form_state['values']["is_phrase-$i"];
     $operation =  $form_state['values']["operation-$i"];
-    
+
     $_SESSION['tripal_pub_import']['criteria'][$i] = array(
       'search_terms' => $search_terms,
       'scope' => $scope,
@@ -487,8 +487,8 @@ function tripal_pub_importer_setup_form_submit($form, &$form_state) {
   if ($form_state['values']['op'] == 'Test Importer') {
     $_SESSION['tripal_pub_import']['perform_search'] = 1;
   }
-  if ($form_state['values']['op'] == 'Save Importer' or 
-      $form_state['values']['op'] == 'Save & Import Now') {    
+  if ($form_state['values']['op'] == 'Save Importer' or
+  $form_state['values']['op'] == 'Save & Import Now') {
     $record = array(
       'name' => $loader_name,
       'criteria' => serialize($_SESSION['tripal_pub_import']),
@@ -496,7 +496,7 @@ function tripal_pub_importer_setup_form_submit($form, &$form_state) {
       'do_contact' => $do_contact
     );
     // first check to see if this pub_import_id is already present. If so,
-    // do an update rather than an insert    
+    // do an update rather than an insert
     $sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = %d";
     $importer = db_fetch_object(db_query($sql, $pub_import_id));
     if($importer) {
@@ -505,17 +505,17 @@ function tripal_pub_importer_setup_form_submit($form, &$form_state) {
       if(drupal_write_record('tripal_pub_import', $record, 'pub_import_id')){
         unset($_SESSION['tripal_pub_import']);
         drupal_set_message('Publication import settings updated.');
-        drupal_goto('admin/tripal/tripal_pub/import_list');       
+        drupal_goto('admin/tripal/tripal_pub/import_list');
       }
       else {
         drupal_set_message('Could not update publication import settings.', 'error');
       }
-    }     
-    else {         
-      // do the insert        
+    }
+    else {
+      // do the insert
       if(drupal_write_record('tripal_pub_import', $record)){
         unset($_SESSION['tripal_pub_import']);
-        drupal_set_message('Publication import settings saved.');        
+        drupal_set_message('Publication import settings saved.');
         // if the user wants to do the import now then do it (may time out
         // for long jobs)
         if ($form_state['values']['op'] == 'Save & Import Now') {
@@ -526,30 +526,30 @@ function tripal_pub_importer_setup_form_submit($form, &$form_state) {
       else {
         drupal_set_message('Could not save publication import settings.', 'error');
       }
-    }    
+    }
   }
   if ($form_state['values']['op'] == 'Delete Importer') {
     $sql = "DELETE FROM {tripal_pub_import} WHERE pub_import_id = %d";
     $success = db_query($sql, $pub_import_id);
     if ($success) {
       drupal_set_message('Publication importer deleted.');
-      drupal_goto('admin/tripal/tripal_pub/import_list');  
+      drupal_goto('admin/tripal/tripal_pub/import_list');
     }
     else {
       drupal_set_message('Could not delete publication importer.', 'error');
     }
-  } 
+  }
 }
 
 /*
- * 
+ *
  */
 function tripal_pub_importer_delete($pub_import_id) {
   $sql = "DELETE FROM {tripal_pub_import} WHERE pub_import_id = %d";
   $success = db_query($sql, $pub_import_id);
   if ($success) {
     drupal_set_message('Publication importer deleted.');
-    drupal_goto('admin/tripal/tripal_pub/import_list');  
+    drupal_goto('admin/tripal/tripal_pub/import_list');
   }
   else {
     drupal_set_message('Could not delete publication importer.', 'error');
@@ -562,20 +562,20 @@ function tripal_pub_importer_setup_page_update_remotedb() {
   $status = TRUE;
 
   // prepare and render the form
-  $form = tripal_core_ahah_prepare_form();   
-  $data = theme('tripal_pub_importer_setup_form', $form);  
+  $form = tripal_core_ahah_prepare_form();
+  $data = theme('tripal_pub_importer_setup_form', $form);
 
-  // bind javascript events to the new objects that will be returned 
+  // bind javascript events to the new objects that will be returned
   // so that AHAH enabled elements will work.
   $settings = tripal_core_ahah_bind_events();
 
   // return the updated JSON
   drupal_json(
-    array(
+  array(
       'status'   => $status, 
       'data'     => $data,
       'settings' => $settings,
-    )  
+  )
   );
 }
 /*
@@ -585,19 +585,19 @@ function tripal_pub_importer_setup_page_update_criteria($action, $i) {
   $status = TRUE;
 
   // prepare and render the form
-  $form = tripal_core_ahah_prepare_form();   
-  $data = theme('tripal_pub_importer_setup_form', $form);  
+  $form = tripal_core_ahah_prepare_form();
+  $data = theme('tripal_pub_importer_setup_form', $form);
 
-  // bind javascript events to the new objects that will be returned 
+  // bind javascript events to the new objects that will be returned
   // so that AHAH enabled elements will work.
   $settings = tripal_core_ahah_bind_events();
 
   // return the updated JSON
   drupal_json(
-    array(
+  array(
       'status'   => $status, 
       'data'     => $data,
       'settings' => $settings,
-    )  
+  )
   );
 }

+ 105 - 105
tripal_pub/includes/pub_search.inc

@@ -1,18 +1,18 @@
 <?php
 /*
- * 
+ *
  */
 function tripal_pub_search_page() {
   global $pager_total, $pager_total_items;
 
   $pager_id = 0;
   $limit = 25;
-  
-  // generate the search form 
-  $form = drupal_get_form('tripal_pub_search_form');  
+
+  // generate the search form
+  $form = drupal_get_form('tripal_pub_search_form');
   $output .= $form;
 
-  // retrieve any results       
+  // retrieve any results
   if ($_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'];
@@ -24,20 +24,20 @@ function tripal_pub_search_page() {
     $search_array['to_year'] = $to_year;
     for ($i = 0; $i <= $num_criteria; $i++) {
       $search_array['criteria'][$i]['search_terms'] = $_SESSION['tripal_pub_search_form']['criteria'][$i]['search_terms'];
-      $search_array['criteria'][$i]['scope']        = $_SESSION['tripal_pub_search_form']['criteria'][$i]['scope'];  
+      $search_array['criteria'][$i]['scope']        = $_SESSION['tripal_pub_search_form']['criteria'][$i]['scope'];
       $search_array['criteria'][$i]['mode']         = $_SESSION['tripal_pub_search_form']['criteria'][$i]['mode'];
       $search_array['criteria'][$i]['operation']    = $_SESSION['tripal_pub_search_form']['criteria'][$i]['operation'];
     }
-  
-    // get the list of publications from the remote database using the search criteria.  
+
+    // get the list of publications from the remote database using the search criteria.
     $pubs = tripal_pub_get_search_results($search_array, $limit, $pager_id);
-  
+
     // generate the pager
     $total_pages = $pager_total[$pager_id];
     $total_items = $pager_total_items[$pager_id];
     $page = isset($_GET['page']) ? $_GET['page'] : '0';
     $pager = theme('pager');
-    
+
     // iterate through the results and construct the table displaying the publications
     $rows = array();
     $i = $page * $limit + 1;
@@ -47,34 +47,34 @@ function tripal_pub_search_page() {
         'pub_id' => $pub->pub_id, 
         'type_id' => array(
           'name' => 'Citation',
-        ),
+      ),
       );
-      $citation_rec = tripal_core_generate_chado_var('pubprop', $values); 
+      $citation_rec = tripal_core_generate_chado_var('pubprop', $values);
       $citation_rec = tripal_core_expand_chado_vars($citation_rec, 'field', 'pubprop.value');
-      
+
       // if we have the citation then use it, otherwise, just use the title
       $title = htmlspecialchars($pub->title);
       $result = $title;
       if ($pub->nid) {
         $result = l($title ,'node/' . $pub->nid, array('attributes' => array('target' => '_blank')));
-      }      
+      }
       if ($citation_rec->value) {
         $citation = htmlspecialchars($citation_rec->value);
         $result .= '<br>' . $citation;
-      } 
+      }
       $rows[] = array(
-        number_format($i) . ".", 
-        $pub->pyear, 
-        $result
+      number_format($i) . ".",
+      $pub->pyear,
+      $result
       );
       $i++;
     }
 
     $headers = array('', 'Year', 'Publication');
-    $table = theme('table', $headers, $rows);   
-  
+    $table = theme('table', $headers, $rows);
+
     // join all to form the results
-    $output .= "<br><p><b>Found " . number_format($total_items) .  
+    $output .= "<br><p><b>Found " . number_format($total_items) .
       ". Page " . ($page + 1) . " of $total_pages. " .
       " Results</b></br>" . $table . '</p>' . $pager;    
   }
@@ -83,38 +83,38 @@ function tripal_pub_search_page() {
 /**
  * Purpose: Provides the form to search pubmed
  *
-  * @ingroup tripal_pub
+ * @ingroup tripal_pub
  */
 function tripal_pub_search_form(&$form_state = NULL) {
   tripal_core_ahah_init_form();
- 
-  // Set the default values. If the pub_import_id isn't already defined by the form values 
+
+  // 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;
 
   // if the session has variables then use those.  This should only happen when
   // the 'Test Criteria' button is clicked.
-  $num_criteria = $_SESSION['tripal_pub_search_form']['num_criteria'] ? $_SESSION['tripal_pub_search_form']['num_criteria'] : $num_criteria;    
+  $num_criteria = $_SESSION['tripal_pub_search_form']['num_criteria'] ? $_SESSION['tripal_pub_search_form']['num_criteria'] : $num_criteria;
   $from_year = $_SESSION['tripal_pub_search_form']['from_year'] ? $_SESSION['tripal_pub_search_form']['from_year'] : '';
   $to_year = $_SESSION['tripal_pub_search_form']['to_year'] ? $_SESSION['tripal_pub_search_form']['to_year'] : '';
- 
-  
-  // If the form_state has variables then use those.  This happens when an error occurs on the form or the 
+
+
+  // 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
-  $num_criteria = $form_state['values']['num_criteria'] ? $form_state['values']['num_criteria'] : $num_criteria;    
-  
+  $num_criteria = $form_state['values']['num_criteria'] ? $form_state['values']['num_criteria'] : $num_criteria;
+
    
   // change the number of criteria based on form_state post data.
   if (!$num_criteria) {
     $num_criteria = 2;
   }
-  if($form_state['post']["add-$num_criteria"]) {    
+  if($form_state['post']["add-$num_criteria"]) {
     $num_criteria++;
   }
-  if($form_state['post']["remove-$num_criteria"]) {    
+  if($form_state['post']["remove-$num_criteria"]) {
     $num_criteria--;
   }
-  
+
   $form['num_criteria']= array(
     '#type'          => 'hidden',
     '#default_value' => $num_criteria,
@@ -123,8 +123,8 @@ function tripal_pub_search_form(&$form_state = NULL) {
     '#type'  => 'item',
     '#value' => 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 plus and minus symbols to add additional fields for searching. '),
   );
-  
-  // get publication properties list 
+
+  // get publication properties list
   $properties = array();
   $properties[] = 'Any Field';
   $sql = "
@@ -139,19 +139,19 @@ function tripal_pub_search_form(&$form_state = NULL) {
     ORDER BY CVTS.name ASC 
   ";
   $allowed_fields = variable_get('tripal_pub_allowed_search_fields', array());
-  $prop_types = chado_query($sql); 
+  $prop_types = chado_query($sql);
   while ($prop = db_fetch_object($prop_types)) {
     if($allowed_fields[$prop->cvterm_id] > 0) {
       $properties[$prop->cvterm_id] = $prop->name;
     }
   }
-  
+
   for($i = 1; $i <= $num_criteria; $i++) {
     $search_terms = '';
     $scope = '';
     $operation = '';
     $mode = '';
-    
+
     // if we have criteria supplied from the database then use that, othrewise look from the form_state or the session
     if ($criteria) {
       $search_terms = $criteria['criteria'][$i]['search_terms'];
@@ -164,18 +164,18 @@ function tripal_pub_search_form(&$form_state = NULL) {
     $scope        = $_SESSION['tripal_pub_search_form']['criteria'][$i]['scope']        ? $_SESSION['tripal_pub_search_form']['criteria'][$i]['scope']        : $scope;
     $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;
-    
+
     // next populate defaults using any form values
     $search_terms = $form_state['values']["search_terms-$i"] ? $form_state['values']["search_terms-$i"] : $search_terms;
     $scope        = $form_state['values']["scope-$i"]        ? $form_state['values']["scope-$i"]        : $scope;
     $mode         = $form_state['values']["mode-$i"]         ? $form_state['values']["mode-$i"]         : $mode;
     $operation    = $form_state['values']["operation-$i"]    ? $form_state['values']["operation-$i"]    : $operation;
-    
+
     // default to searching the title and abstract
     if (!$scope) {
       $scope = 'abstract';
     }
-  
+
     $form['criteria'][$i]["search_terms-$i"] = array(
       '#type'          => 'textfield',
       '#default_value' => $search_terms,
@@ -186,18 +186,18 @@ function tripal_pub_search_form(&$form_state = NULL) {
       '#options'       => $properties,
       '#default_value' => $scope,
       '#attributes' => array('class' => 'tripal-pub-search-form-scope-select'),
-    );  
+    );
     /*
-    $form['criteria'][$i]["mode-$i"] = array(
-      '#type'          => 'select',
-      '#options'       => array(
-        'Contains'    => 'Contains',
-        'Starts With' => 'Starts With',
-        'Ends With'   => 'Ends With',
-        'Exactly'     => 'Exactly'),
-      '#default_value' => $mode,
-    );*/   
-    
+     $form['criteria'][$i]["mode-$i"] = array(
+     '#type'          => 'select',
+     '#options'       => array(
+     'Contains'    => 'Contains',
+     'Starts With' => 'Starts With',
+     'Ends With'   => 'Ends With',
+     'Exactly'     => 'Exactly'),
+     '#default_value' => $mode,
+     );*/
+
     if ($i > 1) {
       $form['criteria'][$i]["operation-$i"] = array(
         '#type'          => 'select',
@@ -208,7 +208,7 @@ function tripal_pub_search_form(&$form_state = NULL) {
         '#default_value' => $operation,
       );
     }
-    if ($i == $num_criteria) {    
+    if ($i == $num_criteria) {
       if($i > 1) {
         $form['criteria'][$i]["remove-$i"] = array(
           '#type'         => 'image_button',
@@ -219,7 +219,7 @@ function tripal_pub_search_form(&$form_state = NULL) {
             'wrapper' => 'tripal-pub-search-form',
             'event'   => 'click',
             'method'  => 'replace',
-          ), 
+        ),
           '#attributes' => array('onClick' => 'return false;'),
         );
       }
@@ -232,7 +232,7 @@ function tripal_pub_search_form(&$form_state = NULL) {
           'wrapper' => 'tripal-pub-search-form',
           'event'   => 'click',
           'method'  => 'replace',          
-        ),   
+      ),
         '#attributes' => array('onClick' => 'return false;'),
       );
     }
@@ -258,7 +258,7 @@ function tripal_pub_search_form(&$form_state = NULL) {
     '#size'          => 4,
     '#maxlength'     => 4,
   );
-    
+
   $form['search'] = array(
     '#type'         => 'submit',
     '#value'        => t('Search'),
@@ -271,49 +271,49 @@ function tripal_pub_search_form(&$form_state = NULL) {
   return $form;
 }
 /*
- * 
+ *
  */
 function theme_tripal_pub_search_form($form) {
   $rows = array();
   foreach ($form['criteria'] as $i => $element) {
     if(is_numeric($i)) {
-      $rows[] = array(  
-        drupal_render($element["operation-$i"]),    
-        drupal_render($element["scope-$i"]),
-        //drupal_render($element["mode-$i"]) . 
-        drupal_render($element["search_terms-$i"]),
-        drupal_render($element["add-$i"]) . drupal_render($element["remove-$i"]),
+      $rows[] = array(
+      drupal_render($element["operation-$i"]),
+      drupal_render($element["scope-$i"]),
+      //drupal_render($element["mode-$i"]) .
+      drupal_render($element["search_terms-$i"]),
+      drupal_render($element["add-$i"]) . drupal_render($element["remove-$i"]),
       );
     }
-  } 
-    
+  }
+
   $rows[] = array(
     '&nbsp;',
-    drupal_render($form['criteria']['date']),
-    array(
+  drupal_render($form['criteria']['date']),
+  array(
       'data' =>
         "<div id=\"pub-search-form-dates-row\"> 
            <div id=\"pub-search-form-dates\"> ".
-            drupal_render($form['criteria']['from_year']) . 
-            drupal_render($form['criteria']['to_year']) . "
+  drupal_render($form['criteria']['from_year']) .
+  drupal_render($form['criteria']['to_year']) . "
           </div>
          </div>",
-    ),
+  ),
     ''
-  );
-  $table = theme('table', $headers, $rows, array('id' => 'tripal-pub-search-form-table', 'border' => '0')); 
-  $headers = array();  
-  $markup  = drupal_render($form['instructions']) . "
+    );
+    $table = theme('table', $headers, $rows, array('id' => 'tripal-pub-search-form-table', 'border' => '0'));
+    $headers = array();
+    $markup  = drupal_render($form['instructions']) . "
      <div id=\"pub-search-form-row1\">$table</div>
      <div style=\"clear: both;\"></div>
   "; 
-  
-  $form['criteria'] = array(
+
+    $form['criteria'] = array(
     '#type' => 'markup',
     '#value' =>  $markup,
     '#weight' => -10,
-  );
-  return drupal_render($form);
+    );
+    return drupal_render($form);
 }
 /**
  *
@@ -328,10 +328,10 @@ function tripal_pub_search_form_validate($form, &$form_state) {
   if ($op == 'Reset') {
     return;
   }
-    
+
   if($from_year and !$to_year) {
     form_set_error('to_year', 'Please provide a 4-digit year.');
-  }  
+  }
   if(!$from_year and $to_year) {
     form_set_error('from_year', 'Please provide a 4-digit year.');
   }
@@ -353,7 +353,7 @@ function tripal_pub_search_form_submit($form, &$form_state) {
 
   // set the session variables
   if($op == 'Search') {
-    $_SESSION['tripal_pub_search_form']['num_criteria'] = $num_criteria;  
+    $_SESSION['tripal_pub_search_form']['num_criteria'] = $num_criteria;
     unset($_SESSION['tripal_pub_search_form']['criteria']);
     for ($i = 0; $i <= $num_criteria; $i++) {
       $search_terms =  trim($form_state['values']["search_terms-$i"]);
@@ -361,7 +361,7 @@ function tripal_pub_search_form_submit($form, &$form_state) {
       //$mode =  $form_state['values']["mode-$i"];
       $mode = 'Contains';
       $operation =  $form_state['values']["operation-$i"];
-      
+
       $_SESSION['tripal_pub_search_form']['criteria'][$i] = array(
         'search_terms' => $search_terms,
         'scope' => $scope,
@@ -385,24 +385,24 @@ function tripal_pub_search_page_update_criteria($action, $i) {
   $status = TRUE;
 
   // prepare and render the form
-  $form = tripal_core_ahah_prepare_form();   
-  $data = theme('tripal_pub_search_form', $form);  
+  $form = tripal_core_ahah_prepare_form();
+  $data = theme('tripal_pub_search_form', $form);
 
-  // bind javascript events to the new objects that will be returned 
+  // bind javascript events to the new objects that will be returned
   // so that AHAH enabled elements will work.
   $settings = tripal_core_ahah_bind_events();
 
   // return the updated JSON
   drupal_json(
-    array(
+  array(
       'status'   => $status, 
       'data'     => $data,
       'settings' => $settings,
-    )  
+  )
   );
 }
 /*
- * 
+ *
  */
 function tripal_pub_get_search_results($search_array, $limit, $pager_id) {
 
@@ -417,24 +417,24 @@ function tripal_pub_get_search_results($search_array, $limit, $pager_id) {
   $fargs = array(); // arguments for from, inner join clause
   $wargs = array();  // arguments for where clause
   $join = 0;
-  
+
   $num_criteria = $search_array['num_criteria'];
   $from_year    = $search_array['from_year'];
   $to_year      = $search_array['to_year'];
-  
+
   for ($i = 1; $i <= $num_criteria; $i++) {
     $value = $search_array['criteria'][$i]['search_terms'];
     $type_id = $search_array['criteria'][$i]['scope'];
     $mode = $search_array['criteria'][$i]['mode'];
     $op = $search_array['criteria'][$i]['operation'];
-    
+
     // skip criteria with no values
     if(!$value) {
       continue;
     }
-    
+
     // to prevent SQL injection make sure our operator is
-    // what we expect    
+    // what we expect
     if ($op and $op != "AND" and $op != "OR" and $op != 'NOT') {
       $op = 'AND';
     }
@@ -444,18 +444,18 @@ function tripal_pub_get_search_results($search_array, $limit, $pager_id) {
     if (!$op) {
       $op = 'AND';
     }
-    
+
     $action = "= lower('%s')";
     if($mode == 'Contains') {
       $action = 'LIKE lower(\'%%%s%%\')';
     }
     if($mode == 'Starts With') {
-      $action = '= lower(\'%%%s\')';  
+      $action = '= lower(\'%%%s\')';
     }
     if($mode == 'Ends With') {
-      $action = '= lower(\'%s%%\')';  
+      $action = '= lower(\'%s%%\')';
     }
-   
+     
     // get the scope type
     $values = array('cvterm_id' => $type_id);
     $cvterm = tripal_core_chado_select('cvterm', array('name'), $values);
@@ -477,16 +477,16 @@ function tripal_pub_get_search_results($search_array, $limit, $pager_id) {
       $wargs[] = $value;
     }
     elseif ($type_name == 'Journal Name') {
-      $from .= " LEFT JOIN {pubprop} PP$i ON PP$i.pub_id = P.pub_id AND PP$i.type_id = %d ";      
-      $where .= " $op ((lower(P.series_name) $action and CVT.name = 'Journal Article') OR 
+      $from .= " LEFT JOIN {pubprop} PP$i ON PP$i.pub_id = P.pub_id AND PP$i.type_id = %d ";
+      $where .= " $op ((lower(P.series_name) $action and CVT.name = 'Journal Article') OR
                        (lower(PP$i.value) $action)) ";
       $fargs[] = $type_id;
       $wargs[] = $value;
-      $wargs[] = $value;            
+      $wargs[] = $value;
     }
     elseif ($type_name == 'Conference Name') {
-      $from .= " LEFT JOIN {pubprop} PP$i ON PP$i.pub_id = P.pub_id AND PP$i.type_id = %d ";      
-      $where .= " $op ((lower(P.series_name) $action and CVT.name = 'Conference Proceedings') OR 
+      $from .= " LEFT JOIN {pubprop} PP$i ON PP$i.pub_id = P.pub_id AND PP$i.type_id = %d ";
+      $where .= " $op ((lower(P.series_name) $action and CVT.name = 'Conference Proceedings') OR
                        (lower(PP$i.value) $action)) ";
       $fargs[] = $type_id;
       $wargs[] = $value;
@@ -498,7 +498,7 @@ function tripal_pub_get_search_results($search_array, $limit, $pager_id) {
     }
     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)  $action OR 
+      $where .= " $op (lower(PP$i.value)  $action OR
                        lower(P.title) $action OR 
                        lower(P.volumetitle) $action OR
                        lower(P.publisher) $action OR
@@ -507,7 +507,7 @@ function tripal_pub_get_search_results($search_array, $limit, $pager_id) {
                        lower(P.miniref) $action OR
                        lower(P.series_name) $action) ";
       $wargs[] = $value;
-      $wargs[] = $value;  
+      $wargs[] = $value;
       $wargs[] = $value;
       $wargs[] = $value;
       $wargs[] = $value;
@@ -523,7 +523,7 @@ function tripal_pub_get_search_results($search_array, $limit, $pager_id) {
       $wargs[] = $value;
     }
 
-  }  
+  }
   if($from_year and $to_year) {
     $where .= " AND (P.pyear ~ '....' AND to_number(P.pyear,'9999') >= %d AND to_number(P.pyear,'9999') <= %d) ";
     $wargs[] = $from_year;

+ 13 - 13
tripal_pub/includes/pub_sync.inc

@@ -1,6 +1,6 @@
 <?php
 /*
- * 
+ *
  */
 function tripal_pub_sync_form() {
 
@@ -8,7 +8,7 @@ function tripal_pub_sync_form() {
     '#type' => 'item',
     '#value' => t('Syncing a publication will create a Drupal page for every publicatoin record in the Chado database. Click the button below to sync all publications in Chado that currently are not already synced with Drupal.'),
   );
-  
+
 
 
   $form['submit'] = array(
@@ -22,7 +22,7 @@ function tripal_pub_sync_form() {
 
 
 /*
- * 
+ *
  */
 function tripal_pub_sync_form_submit($form, $form_state) {
   global $user;    //needed to make the current users details available so access of user id is available
@@ -36,7 +36,7 @@ function tripal_pub_sync_form_submit($form, $form_state) {
  * @ingroup tripal_pub
  */
 function tripal_pub_sync_pubs($job_id = NULL) {
-  
+
   // get the list of pubs that have not yet been synced
   // and ignore the default 'NULL' pub. we don't want
   // to sync that one.
@@ -56,20 +56,20 @@ function tripal_pub_sync_pubs($job_id = NULL) {
 /**
  * @param $pub
  *   A publication object
- *   
+ *
  * @return
  *   A new Drupal node object on success. FALSE on failure
- *   
+ *
  * @ingroup tripal_pub
  */
 function tripal_pub_sync_pub($pub) {
   global $user;
-  
+
   if(!$pub->pyear) {
     watchdog('tpub_sync', "Skipping pub without published year: %title.", array('%title' => $pub->title), WATCHDOG_WARNING);
-    return FALSE;  
+    return FALSE;
   }
-  
+
   $new_node = new stdClass();
   $new_node->pub_id      = $pub->pub_id;
   $new_node->type        = 'chado_pub';
@@ -87,7 +87,7 @@ function tripal_pub_sync_pub($pub) {
     $node = node_submit($new_node);
     node_save($node);
     if ($node->nid) {
-      print "Added " . $pub->pub_id . "\n";      
+      print "Added " . $pub->pub_id . "\n";
     }
     else {
       watchdog('tpub_sync', "Unable to create publication node: %title.", array('%title' => $pub->title), WATCHDOG_ERROR);
@@ -97,9 +97,9 @@ function tripal_pub_sync_pub($pub) {
   // if there are form errors then we need to reset the form errors cache, print a message and return
   else {
     form_set_error(NULL,'',TRUE);
-    watchdog('tpub_sync', "Unable to create publication node: %title\n%errs", 
-      array('%title' => $pub->title, '%errs' => print_r($errors, TRUE)), WATCHDOG_ERROR);
+    watchdog('tpub_sync', "Unable to create publication node: %title\n%errs",
+    array('%title' => $pub->title, '%errs' => print_r($errors, TRUE)), WATCHDOG_ERROR);
     return FALSE;
   }
-  return $node; 
+  return $node;
 }

+ 12 - 12
tripal_pub/includes/tripal_pub.admin.inc

@@ -1,4 +1,4 @@
-<?php 
+<?php
 
 /**
  * Administrative settings form
@@ -18,7 +18,7 @@ function tripal_pub_admin() {
 
   // add the field set for syncing publications
   if (!$active_jobs) {
-    get_tripal_pub_admin_form_select_search_list($form);    
+    get_tripal_pub_admin_form_select_search_list($form);
     get_tripal_pub_admin_form_importing_set($form);
     get_tripal_pub_admin_form_cleanup_set($form);
   }
@@ -51,7 +51,7 @@ function get_tripal_pub_admin_form_importing_set(&$form) {
       'title_year' => t('Title and Year'), 
       'title_year_media' => t('Title, Year, Media name (e.g. Journal Name, etc.)'), 
       'title_year_type' => t('Title, Year, Media type (e.g. Journal, Conference Proceedings, etc.'),
-    ),
+  ),
     '#description' => t('During import, Tripal will attempt to find duplicate publications. 
        There are several options for how to find a duplicate publication.  Choose the
        option that best suits your needs.'),
@@ -95,7 +95,7 @@ function get_tripal_pub_admin_form_select_search_list(&$form) {
     '#type' => 'fieldset',
     '#title' => t('Searching Options')
   );
-  // get publication properties list 
+  // get publication properties list
   $properties = array();
   $properties[] = 'Any Field';
   $sql = "
@@ -109,7 +109,7 @@ function get_tripal_pub_admin_form_select_search_list(&$form) {
       NOT CVTS.is_obsolete = 1
     ORDER BY CVTS.name ASC 
   ";
-  $prop_types = chado_query($sql); 
+  $prop_types = chado_query($sql);
   while ($prop = db_fetch_object($prop_types)) {
     $properties[$prop->cvterm_id] = $prop->name;
   }
@@ -136,15 +136,15 @@ function tripal_pub_admin_validate($form, &$form_state) {
   foreach ($allowed_fields as $cvterm_id => $selected) {
     if (!$selected) {
       unset($allowed_fields[$cvterm_id]);
-    }  
+    }
   }
   variable_set('tripal_pub_allowed_search_fields', $allowed_fields);
-  
+
   $import_duplicate_check = $form_state['values']['import_duplicate_check'];
   variable_set('tripal_pub_import_duplicate_check', $import_duplicate_check);
-    
+
   // -------------------------------------
-  // Submit the Cleanup Job if selected  
+  // Submit the Cleanup Job if selected
   if ($form_state['values']['op'] == t('Clean up orphaned publications')) {
     tripal_add_job('Cleanup orphaned publications', 'tripal_pub',
        'tripal_pub_cleanup', $job_args, $user->uid);
@@ -164,14 +164,14 @@ function tripal_pub_admin_validate($form, &$form_state) {
 function tripal_pub_cleanup($dummy = NULL, $job_id = NULL) {
 
   return tripal_core_clean_orphaned_nodes('pub', $job_id);
-  
+
 }
 
 /**
  *
  */
 function tripal_pub_set_pub_url($node, $pub_id) {
-  
+
   $node_url = "node/$node->nid";
   $url_alias = "pub/$pub_id";
 
@@ -179,6 +179,6 @@ function tripal_pub_set_pub_url($node, $pub_id) {
   db_query("DELETE FROM {url_alias} WHERE src = '%s'", $node_url);
   // add the new alias
   path_set_alias($node_url, $url_alias);
-  
+
   return $url_alias;
 }

+ 108 - 73
tripal_pub/theme/tripal_pub_admin.tpl.php

@@ -1,85 +1,120 @@
-<br /><h3>Tripal Publication Quick Links</h3>
+<br />
+<h3>Tripal Publication Quick Links</h3>
 <ul>
-  <li><?php print l('Search for Publications', 'find/publications') ?></li>
-  <li><?php print l('Configuration', 'admin/tripal/tripal_pub/configuration') ?></li>
-  <li><?php print l('Sync Publications', 'admin/tripal/tripal_pub/sync') ?></li>
-  <li><?php print l('List of Importers', 'admin/tripal/tripal_pub/import_list') ?></li>
-  <li><?php print l('Add a New Importer', 'admin/tripal/tripal_pub/import/new') ?></li>
+	<li><?php print l('Search for Publications', 'find/publications') ?></li>
+	<li><?php print l('Configuration', 'admin/tripal/tripal_pub/configuration') ?></li>
+	<li><?php print l('Sync Publications', 'admin/tripal/tripal_pub/sync') ?></li>
+	<li><?php print l('List of Importers', 'admin/tripal/tripal_pub/import_list') ?></li>
+	<li><?php print l('Add a New Importer', 'admin/tripal/tripal_pub/import/new') ?></li>
 </ul>
 
 <h3>Module Description:</h3>
-<p>The Tripal Publication Module provides the functionality for adding, editing, deleting viewing and bulk 
-importing of publications.  This module additionally provides a search tool for finding publications that have
-been added to Chado database.
- </p>
+<p>The Tripal Publication Module provides the functionality for adding,
+editing, deleting viewing and bulk importing of publications. This
+module additionally provides a search tool for finding publications that
+have been added to Chado database.</p>
 <h3>Setup Instructions:</h3>
 <ol>
-  <li><p><b>Set Permissions</b>: The publication module supports the Drupal user permissions interface for
-    controlling access to publication content and functions. These permissions include viewing,
-    creating, editing or administering of
-    publications. The default is that only the original site administrator has these
-    permissions.  You can <a href="<?php print url('admin/user/roles') ?>">add roles</a> for classifying users,
-    <a href="<?php print url('admin/user/user') ?>">assign users to roles</a> and
-    <a href="<?php print url('admin/user/permissions') ?>">assign permissions</a> for the publication content to
-    those roles.  For a simple setup, allow anonymous users access to view publication content and
-    allow the site administrator all other permissions.</p></li>
-  <li><p><b>Sync Publications</b>:  If you already have publications in your Chado database, or you loaded them
-    through a means other than Tripal, and you want those publications to appear on your site then you will need
-    to "sync" them with Drupal.  Use the <?php print l('sync publications', 'admin/tripal/tripal_pub/sync') ?>
-    page to sync all publications.</p></li>
-  <li><p><b>Configure the Search Behavior</b>: Before allowing site visitors to search for publications 
-    visit the <?php print l('configuration page', 'admin/tripal/tripal_pub/configuration') ?> to disable or enable
-    fields for searching.  Tripal uses its own ontology for storing publication information in Chado, and all 
-    child terms of the "Publication Details" are made available for searching. However, some of these
-    may not be desired for searching and can be disabled.</p></li>
-  <li><p><b>AGL Importer</b>: Initially, the Tripal publication module supports creating publication 
-    importers using PubMed and the USDA National Agricultural Library (AGL).  The AGL database uses 
-    a Z39.50 protocol for querying and therefore Tripal requires the 'YAZ' library to connect.  Before
-    you can query AGL you must install the YAZ library and the PHP YAZ library.  The following steps can
-    be used on an Ubuntu 12.04 server to intall the necessary pre-requisites:
-    <ol>
-      <li>Install the YAZ libraries: sudo apt-get install yaz libyaz4-dev</li>
-      <li>Install the PHP YAZ extension: sudo pecl install yaz</li>
-      <li>Add the text 'extesion=yaz.so' to the appropriate php.ini file (e.g. /etc/php5/apache2filter/php.ini)</li>
-      <li>Restart the webserver</li>
-    </ol>
-    </p></li>
-  <li><p><b>Automate Importers:</b> Site administrators can <?php print l('create publication importers', 'admin/tripal/tripal_pub/import/new') ?> 
-    that can be used to query remote databases (e.g. PubMed) and import publications into this database.
-    After creation of importers you can automate import of publications into
-    the site by creating a cron job with a <?php print l('Drush', "http://drupal.org/project/drush")?> command. The 
-    cron job can be setup to run the importers periodically.  The following
-    is an example entry, added to the 'root' crontab, that would run importers on a weekly bases (Friday at 9am):  <br>
-    <pre>0 9 * * 5  su - [web user] -c 'cd [drupal install path]; drush -l http://[site url] tpubs-import --report=[email]'
-    </pre>
-    Where:<br>
-     [web user] is the name of the user on the system under which the web server runs</br>
-     [drupal install path] is the location where drupal is installed</br>
-     [site url] is the URL path for the site </br>
-     [email] is the email address of the person who should receive an HTML report of the publications added.  Separate multiple emails with a comma (no spaces).</br>
-     The --report=Y option indicates that an HTML style report should be generated listing the publications
-     that were added.  If this options is not used then no report is generated.
-    </p></li>
+	<li>
+	<p><b>Set Permissions</b>: The publication module supports the Drupal
+	user permissions interface for controlling access to publication
+	content and functions. These permissions include viewing, creating,
+	editing or administering of publications. The default is that only the
+	original site administrator has these permissions. You can <a
+		href="<?php print url('admin/user/roles') ?>">add roles</a> for
+	classifying users, <a href="<?php print url('admin/user/user') ?>">assign
+	users to roles</a> and <a
+		href="<?php print url('admin/user/permissions') ?>">assign permissions</a>
+	for the publication content to those roles. For a simple setup, allow
+	anonymous users access to view publication content and allow the site
+	administrator all other permissions.</p>
+	</li>
+	<li>
+	<p><b>Sync Publications</b>: If you already have publications in your
+	Chado database, or you loaded them through a means other than Tripal,
+	and you want those publications to appear on your site then you will
+	need to "sync" them with Drupal. Use the <?php print l('sync publications', 'admin/tripal/tripal_pub/sync') ?>
+	page to sync all publications.</p>
+	</li>
+	<li>
+	<p><b>Configure the Search Behavior</b>: Before allowing site visitors
+	to search for publications visit the <?php print l('configuration page', 'admin/tripal/tripal_pub/configuration') ?>
+	to disable or enable fields for searching. Tripal uses its own ontology
+	for storing publication information in Chado, and all child terms of
+	the "Publication Details" are made available for searching. However,
+	some of these may not be desired for searching and can be disabled.</p>
+	</li>
+	<li>
+	<p><b>AGL Importer</b>: Initially, the Tripal publication module
+	supports creating publication importers using PubMed and the USDA
+	National Agricultural Library (AGL). The AGL database uses a Z39.50
+	protocol for querying and therefore Tripal requires the 'YAZ' library
+	to connect. Before you can query AGL you must install the YAZ library
+	and the PHP YAZ library. The following steps can be used on an Ubuntu
+	12.04 server to intall the necessary pre-requisites:</p>
+	<ol>
+		<li>Install the YAZ libraries: sudo apt-get install yaz libyaz4-dev</li>
+		<li>Install the PHP YAZ extension: sudo pecl install yaz</li>
+		<li>Add the text 'extesion=yaz.so' to the appropriate php.ini file
+		(e.g. /etc/php5/apache2filter/php.ini)</li>
+		<li>Restart the webserver</li>
+	</ol>
+	</li>
+	<li>
+	<p><b>Automate Importers:</b> Site administrators can <?php print l('create publication importers', 'admin/tripal/tripal_pub/import/new') ?>
+	that can be used to query remote databases (e.g. PubMed) and import
+	publications into this database. After creation of importers you can
+	automate import of publications into the site by creating a cron job
+	with a <?php print l('Drush', "http://drupal.org/project/drush")?>
+	command. The cron job can be setup to run the importers periodically.
+	The following is an example entry, added to the 'root' crontab, that
+	would run importers on a weekly bases (Friday at 9am): <br>
+	</p>
+	<pre>0 9 * * 5  su - [web user] -c 'cd [drupal install path]; drush -l http://[site url] tpubs-import --report=[email]'</pre>
+	Where:<br>
+	<p>[web user] is the name of the user on the system under which the web
+	server runs<br>
+	[drupal install path] is the location where drupal is installed<br>
+	[site url] is the URL path for the site <br>
+	[email] is the email address of the person who should receive an HTML
+	report of the publications added. Separate multiple emails with a comma
+	(no spaces).<br>
+	The --report=Y option indicates that an HTML style report should be
+	generated listing the publications that were added. If this options is
+	not used then no report is generated.</p>
+	</li>
 </ol>
 <h3>Features of this Module:</h3>
 <ul>
-     
-  <li><p><b>Add/Edit/Delete Publications</b>: Publications can be maually added <?php  l('here', 'node/add/chado-pub') ?>. 
-    Once added, publications can be modified or deleted by clicking the Edit tab at the top of a publication page.</p></li>
-  
-  <li><p><b>Publication Search Tool</b>: A <?php print l('search tool','find/publications') ?> is provided for 
-    finding publications. Unlike most default search tools for Tripal, this tool does not rely on Drupal Views</p></li>
-    
-  <li><p><b>Bulk Import of Publications</b>: Site administrators can  <?php print l('add a new publication importer', 'admin/tripal/tripal_pub/import/new') ?> 
-    which provides a set of search terms for querying a remote publication database (e.g. PubMed). Publications
-    that matche the search terms can be imported when the publication import cron command is executed.  The
-    cron command can be executed using the Drush command: drush tpubs-import.  This drush command can be added
-    as a system-wide cron (in the same way the Tripal jobs cron is implemented) to be executed on a periodic basis.
-    This will allow the site to import publications which have been newly added to remote databases and which 
-    are relative to the site.  Site administrators can <?php print l('see the list of importers', 'admin/tripal/tripal_pub/import_list') ?> 
-    and edit, disable or delete the importers.</p></li>
-    
-  
+
+	<li>
+	<p><b>Add/Edit/Delete Publications</b>: Publications can be maually
+	added <?php  l('here', 'node/add/chado-pub') ?>. Once added,
+	publications can be modified or deleted by clicking the Edit tab at the
+	top of a publication page.</p>
+	</li>
+
+	<li>
+	<p><b>Publication Search Tool</b>: A <?php print l('search tool','find/publications') ?>
+	is provided for finding publications. Unlike most default search tools
+	for Tripal, this tool does not rely on Drupal Views</p>
+	</li>
+
+	<li>
+	<p><b>Bulk Import of Publications</b>: Site administrators can <?php print l('add a new publication importer', 'admin/tripal/tripal_pub/import/new') ?>
+	which provides a set of search terms for querying a remote publication
+	database (e.g. PubMed). Publications that matche the search terms can
+	be imported when the publication import cron command is executed. The
+	cron command can be executed using the Drush command: drush
+	tpubs-import. This drush command can be added as a system-wide cron (in
+	the same way the Tripal jobs cron is implemented) to be executed on a
+	periodic basis. This will allow the site to import publications which
+	have been newly added to remote databases and which are relative to the
+	site. Site administrators can <?php print l('see the list of importers', 'admin/tripal/tripal_pub/import_list') ?>
+	and edit, disable or delete the importers.</p>
+	</li>
+
+
 
 </ul>
 

+ 10 - 10
tripal_pub/tripal_pub.drush.inc

@@ -33,12 +33,12 @@ function tripal_pub_drush_command() {
       'dbxref' => dt('An accession number for a publication from a remote database (e.g. PMID:23582642).'),
       'report' => dt("Set to the email address of the recipient who should receive an HTML report of the publications that have been added."),
       'update' => dt("Set to 'Y' to update existing pubs.  By default only new pubs are inserted."),
-    ),
+  ),
     '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',  
-    ),
+  ),
     'aliases' => array('tpubs-import'),
   );
   $items['tripal-pubs-update'] = array(
@@ -47,17 +47,17 @@ function tripal_pub_drush_command() {
       'create_contacts' => dt('provide this option to create or update contacts for authors. By default contacts are not created or updated.'),
       'dbxref' => dt('An accession number for a publication from a remote database (e.g. PMID:23582642)'),
       'db' => dt('The database name (e.g. PMID or AGL)'),
-    ),
+  ),
     'examples' => array(
       'Standard example' => 'drush tripal-pubs-update',
       'Create contacts during update' => 'drush tripal-pubs-update --create_contacts=1',
       'Update a single record' => 'drush tripal-pubs-update --dbxref=PMID:23582642',
       'Update all records for a single database' => 'drush tripal-pubs-update --db=PMID'
-    ),
+      ),
     'aliases' => array('tpubs-update'),
-  );
+      );
 
-  return $items;
+      return $items;
 }
 
 /**
@@ -69,16 +69,16 @@ function drush_tripal_pub_tripal_pubs_import() {
   $dbxref = drush_get_option('dbxref');
   $do_report = drush_get_option('report');
   $update = drush_get_option('$update');
-  
+
   if($update == 'Y') {
     $update = TRUE;
   }
   else {
     $update = FALSE;
   }
-  
+
   if ($dbxref) {
-    tripal_pub_import_by_dbxref($dbxref, $create_contacts);  
+    tripal_pub_import_by_dbxref($dbxref, $create_contacts);
   }
   else {
     tripal_pub_import_publications($do_report, $update);
@@ -92,6 +92,6 @@ function drush_tripal_pub_tripal_pubs_update() {
   $create_contacts = drush_get_option('create_contacts');
   $dbxref = drush_get_option('dbxref');
   $db = drush_get_option('db');
-    
+
   tripal_pub_update_publications($create_contacts, $dbxref, $db);
 }

+ 1 - 1
tripal_pub/tripal_pub.info

@@ -3,7 +3,7 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_pub
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_cv
 dependencies[] = tripal_db

+ 29 - 29
tripal_pub/tripal_pub.install

@@ -15,28 +15,28 @@
  * Implementation of hook_install().
  */
 function tripal_pub_install() {
-  
+
   // create the module's data directory
   tripal_create_moddir('tripal_pub');
 
   // install the tripal_oub
   drupal_install_schema('tripal_pub');
-    
+
   // add loading of the the tripal pub ontology to the job queue
   $obo_path =  realpath('./') . '/' . drupal_get_path('module', 'tripal_pub') . '/files/tpub.obo';
   $obo_id = tripal_cv_add_obo_ref('Tripal Publication', $obo_path);
   tripal_cv_submit_obo_job($obo_id);
-  
+
   // add the custom tables
   tripal_pub_add_custom_tables();
-  
+
 }
 
 function tripal_pub_enable() {
   // make sure we have our supported databases
   tripal_db_add_db('PMID', 'PubMed', 'http://www.ncbi.nlm.nih.gov/pubmed', 'http://www.ncbi.nlm.nih.gov/pubmed/', TRUE);
   tripal_db_add_db('AGL', 'USDA National Agricultural Library', 'http://agricola.nal.usda.gov/', '', TRUE);
-  
+
   variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));
 }
 /**
@@ -52,21 +52,21 @@ function tripal_pub_uninstall() {
  * Implementation of hook_schema().
  */
 function tripal_pub_schema() {
-  
+
   $schema['chado_pub'] = array(
     'fields' => array(
       'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
       'pub_id' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
       'sync_date' => array('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer sync date/time'),
-    ),
+  ),
     'indexes' => array(
       'pub_id' => array('pub_id')
-    ),
+  ),
     'unique keys' => array(
       'nid_vid' => array('nid', 'vid'),
       'vid' => array('vid')
-    ),
+  ),
     'primary key' => array('nid'),
   );
   $schema['tripal_pub_import'] = array(
@@ -76,20 +76,20 @@ function tripal_pub_schema() {
       'criteria' => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE, 'description' => 'Contains a serialized PHP array containing the search criteria'),
       'disabled'  => array('type' => 'int', 'unsigned' => TRUE, 'not NULL' => TRUE, 'default' => 0),      
       'do_contact'  => array('type' => 'int', 'unsigned' => TRUE, 'not NULL' => TRUE, 'default' => 0),
-    ),
+  ),
     'primary key' => array('pub_import_id'),
     'indexes' => array(
       'name' => array('name')
-    ),
+  ),
   );
-       
+   
   return $schema;
 }
 
 
 
 /**
- * Implementation of hook_requirements(). 
+ * Implementation of hook_requirements().
  */
 function tripal_pub_requirements($phase) {
   $requirements = array();
@@ -107,7 +107,7 @@ function tripal_pub_requirements($phase) {
 }
 
 /*
- * 
+ *
  */
 function tripal_pub_add_custom_tables() {
   $schema = array (
@@ -116,39 +116,39 @@ function tripal_pub_add_custom_tables() {
       'pubauthor_contact_id' => array (
         'type' => 'serial',
         'not null' => true,
-      ),
+  ),
       'contact_id' => array (
         'type' => 'int',
         'not null' => true,
-      ),
+  ),
       'pubauthor_id' => array (
         'type' => 'int',
         'not null' => true,
-      ),
-    ),
+  ),
+  ),
     'primary key' => array (
-      0 => 'pubauthor_contact_id',
-    ),
+  0 => 'pubauthor_contact_id',
+  ),
     'unique keys' => array (
       'pubauthor_contact_c1' => array (
-        0 => 'contact_id',
-        1 => 'pubauthor_id',
-      ),
-    ),
+  0 => 'contact_id',
+  1 => 'pubauthor_id',
+  ),
+  ),
     'foreign keys' => array (
       'contact' => array (
         'table' => 'contact',
         'columns' => array (
           'contact_id' => 'contact_id',
-        ),
-      ),
+  ),
+  ),
       'pubauthor' => array (
         'table' => 'pubauthor',
         'columns' => array (
           'pubauthor_id' => 'pubauthor_id',
-        ),
-      ),
-    ),
+  ),
+  ),
+  ),
   );
   tripal_core_create_custom_table(&$ret, 'pubauthor_contact', $schema, TRUE);
 }

+ 166 - 166
tripal_pub/tripal_pub.module

@@ -24,7 +24,7 @@ require_once "includes/importers/AGL.inc";
  */
 function tripal_pub_init() {
   drupal_add_js(drupal_get_path('theme', 'tripal') . '/js/tripal_pub.js');
-  drupal_add_css(drupal_get_path('theme', 'tripal') . '/css/tripal_pub.css');  
+  drupal_add_css(drupal_get_path('theme', 'tripal') . '/css/tripal_pub.css');
 }
 
 
@@ -45,7 +45,7 @@ function tripal_pub_node_info() {
       'body_label' => t('Abstract'),
       'has_title' => TRUE,
       'has_body' => FALSE,
-    ),
+  ),
   );
 }
 
@@ -61,8 +61,8 @@ function tripal_pub_node_info() {
  */
 function tripal_pub_menu() {
   $items = array();
-  
-  
+
+
   $items['find/publications' ]= array(
     'title' => 'Publication Search',
     'description' => ('Search for publications'),
@@ -70,14 +70,14 @@ function tripal_pub_menu() {
     'access arguments' => array('access chado_pub content'),
     'type' => MENU_CALLBACK
   );
-  
+
   $items['find/publications/criteria/%/%'] = array(
     'page callback' => 'tripal_pub_search_page_update_criteria',
     'page arguments' => array(5, 6),
     'access arguments' => array('access chado_pub content'),    
     'type ' => MENU_CALLBACK,
   );
-  
+
   $items['admin/tripal/tripal_pub']= array(
     'title' => 'Publications',
     'description' => ('A module for interfacing the GMOD chado database with Drupal, providing viewing of publications'),
@@ -86,7 +86,7 @@ function tripal_pub_menu() {
     'access arguments' => array('administer tripal pubs'),
     'type' => MENU_NORMAL_ITEM
   );
-  
+
   $items['admin/tripal/tripal_pub/configuration'] = array(
     'title' => 'Configuration',
     'description' => 'Configure the Tripal publication module.',
@@ -95,7 +95,7 @@ function tripal_pub_menu() {
     'access arguments' => array('administer tripal pubs'),
     'type' => MENU_NORMAL_ITEM,
   );
-  
+
   $items['admin/tripal/tripal_pub/sync'] = array(
     'title' => ' Sync Publications',
     'description' => 'Sync publications in Chado with Drupal',
@@ -104,7 +104,7 @@ function tripal_pub_menu() {
     'access arguments' => array('administer tripal pubs'),
     'type' => MENU_NORMAL_ITEM,
   );
-  
+
 
   $items['admin/tripal/tripal_pub/import_list'] = array(
     'title' => t('Importers List'),
@@ -113,7 +113,7 @@ function tripal_pub_menu() {
     'access arguments' => array('administer tripal pubs'),
     'type ' => MENU_CALLBACK,
   );
-  
+
   $items['admin/tripal/tripal_pub/import/new'] = array(
     'title' => t('Add an Importer'),
     'description' => t('Add a new publication importer.'),
@@ -122,22 +122,22 @@ function tripal_pub_menu() {
     'access arguments' => array('administer tripal pubs'),
     'type ' => MENU_CALLBACK,
   );
-  
+
   $items['admin/tripal/tripal_pub/import/raw/%'] = array(
     'page callback' => 'tripal_pub_get_raw_data',
     'page arguments' => array(5),
     'access arguments' => array('administer tripal pubs'),
     'type ' => MENU_CALLBACK,
   );
-  
-  $items['admin/tripal/tripal_pub/import/edit/%'] = array(    
+
+  $items['admin/tripal/tripal_pub/import/edit/%'] = array(
     'page callback' => 'tripal_pub_importer_setup',
     'page arguments' => array(4, 5),
     'access arguments' => array('administer tripal pubs'),
     'type ' => MENU_CALLBACK,
   );
-  
-  $items['admin/tripal/tripal_pub/import/delete/%'] = array(    
+
+  $items['admin/tripal/tripal_pub/import/delete/%'] = array(
     'page callback' => 'tripal_pub_importer_delete',
     'page arguments' => array(5),
     'access arguments' => array('administer tripal pubs'),
@@ -149,32 +149,32 @@ function tripal_pub_menu() {
     'access arguments' => array('administer tripal pubs'),    
     'type ' => MENU_CALLBACK,
   );
-  
+
   $items['admin/tripal/tripal_pub/import/criteria/%/%'] = array(
     'page callback' => 'tripal_pub_importer_setup_page_update_criteria',
     'page arguments' => array(5, 6),
     'access arguments' => array('administer tripal pubs'),    
     'type ' => MENU_CALLBACK,
   );
- 
-  $items['tripal_pub/properties/add'] = array(    
+
+  $items['tripal_pub/properties/add'] = array(
     'page callback' => 'tripal_pub_property_add',
     'access arguments' => array('edit chado_pub content'),
     'type ' => MENU_CALLBACK,
   );
-  $items['tripal_pub/properties/description'] = array(    
+  $items['tripal_pub/properties/description'] = array(
     'page callback' => 'tripal_pub_property_get_description',
     'access arguments' => array('edit chado_pub content'),
     'type ' => MENU_CALLBACK,
   );
-  $items['tripal_pub/properties/minus/%/%'] = array(    
+  $items['tripal_pub/properties/minus/%/%'] = array(
     'page callback' => 'tripal_pub_property_delete',
     'page arguments' => array(3, 4),
     'access arguments' => array('edit chado_pub content'),
     'type ' => MENU_CALLBACK,
   );
-  
-  
+
+
   return $items;
 }
 
@@ -190,58 +190,58 @@ function tripal_pub_menu() {
 function tripal_pub_theme() {
 
   $themes = array(
-    // node templates
+  // node templates
     'tripal_pub_base' => array(
       'arguments' => array('node' => NULL),
-    ),
+  ),
     'tripal_pub_properties' => array(
       'arguments' => array('node' => NULL)
-    ),
+  ),
     'tripal_pub_authors' => array(
       'arguments' => array('node' => NULL)
-    ),
+  ),
     'tripal_pub_references' => array(
       'arguments' => array('node' => NULL)
-    ),
+  ),
     'tripal_pub_relationships' => array(
       'arguments' => array('node' => NULL)
-    ),
+  ),
     'tripal_pub_featuremaps' => array(
       'arguments' => array('node' => NULL)
-    ),
+  ),
     'tripal_pub_features' => array(
       'arguments' => array('node' => NULL)
-    ),
+  ),
     'tripal_pub_libraries' => array(
       'arguments' => array('node' => NULL)
-    ),
+  ),
     'tripal_pub_projects' => array(
       'arguments' => array('node' => NULL)
-    ),
+  ),
     'tripal_pub_stocks' => array(
       'arguments' => array('node' => NULL)
-    ),
-    
-    // instructions page for the pub module
+  ),
+
+  // instructions page for the pub module
     'tripal_pub_admin' => array(
       'template' => 'tripal_pub_admin',  
       'arguments' =>  array(NULL),  
       'path' => drupal_get_path('module', 'tripal_pub') . '/theme' 
-    ),
-    
-    // themed forms
+      ),
+
+      // themed forms
     'tripal_pub_importer_setup_form' => array(
        'arguments' => array('form'),
-    ),
+      ),
     'tripal_pub_search_form' => array(
        'arguments' => array('form'),
-    ),
+      ),
     'chado_pub_node_form' => array(
        'arguments' => array('form'),
-    ),   
-  );
-  
-  return $themes;
+      ),
+      );
+
+      return $themes;
 }
 
 /**
@@ -281,7 +281,7 @@ function chado_pub_access($op, $node, $account ) {
   if ($op == 'create') {
     if (!user_access('create chado_pub content', $account)) {
       return FALSE;
-      }
+    }
   }
 
   if ($op == 'update') {
@@ -317,9 +317,9 @@ function chado_pub_access($op, $node, $account ) {
  *
  *
  */
-function chado_pub_insert($node) { 
- 
-  // if a pub_id already exists for this node then it already exists in Chado and 
+function chado_pub_insert($node) {
+
+  // if a pub_id already exists for this node then it already exists in Chado and
   // we get here because we are syncing the node.  Therefore, we can skip the insert
   // but we always want to set the URL path alias to be the Chado pub ID
   if ($node->pub_id) {
@@ -328,7 +328,7 @@ function chado_pub_insert($node) {
   else {
     $properties = array(); // stores all of the properties we need to add
     $cross_refs = array(); // stores any cross references for this publication
-    
+
     // get the list of properties for easy lookup (without doing lots of database queries
     $properties_list = array();
     $sql = "
@@ -341,36 +341,36 @@ function chado_pub_insert($node) {
         NOT CVTS.is_obsolete = 1
       ORDER BY CVTS.name ASC 
     ";
-    $prop_types = chado_query($sql); 
+    $prop_types = chado_query($sql);
     while ($prop = db_fetch_object($prop_types)) {
       $properties_list[$prop->cvterm_id] = $prop->name;
       // The 'Citation' term is special because it serves
       // both as a property and as the uniquename for the
       // pub and we want it stored in both the pub table and the pubprop table
       if ($prop->name == 'Citation') {
-        $properties[$prop->name][0] = $node->uniquename;   
+        $properties[$prop->name][0] = $node->uniquename;
       }
-    }    
-    
-    // get the properties that should be added. Properties are in one of two forms: 
+    }
+
+    // get the properties that should be added. Properties are in one of two forms:
     //  1) prop_value-[type id]-[index]
     //  2) new_value-[type id]-[index]
-    //  3) new_id, new_value  
+    //  3) new_id, new_value
     foreach ($node as $name => $value) {
       if (preg_match('/^new_value-(\d+)-(\d+)/', $name, $matches)) {
         $type_id = $matches[1];
         $index = $matches[2];
         $name = $properties_list[$type_id];
         $properties[$name][$index] = trim($value);
-      }      
+      }
     }
     if ($node->new_id and $node->new_value) {
       $type_id = $node->new_id;
       $index = count($properties[$name]);
       $name = $properties_list[$type_id];
-      $properties[$name][$index] = trim($node->new_value);    
-    } 
-    
+      $properties[$name][$index] = trim($node->new_value);
+    }
+
     // iterate through all of the properties and remove those that really are
     // part of the pub table fields
     foreach ($properties as $name => $element) {
@@ -378,7 +378,7 @@ function chado_pub_insert($node) {
       if ($name == "Volume") {
         $volume = $value;
         unset($properties[$name]);
-      } 
+      }
       elseif ($name == "Volume Title") {
         $volumetitle = $value;
         unset($properties[$name]);
@@ -409,7 +409,7 @@ function chado_pub_insert($node) {
         $cross_refs[] = $value;
       }
     }
-    
+
     // insert the pub record
     $values = array(
       'title'       => trim($node->pubtitle),
@@ -431,38 +431,38 @@ function chado_pub_insert($node) {
       drupal_set_message("Error inserting publication", "error");
       watchdog('tripal_pub', "Error inserting publication", array(), WATCHDOG_ERROR);
       return;
-    }       
-    
-    // now add in the properties 
+    }
+
+    // now add in the properties
     foreach ($properties as $property => $elements) {
-      foreach ($elements as $rank => $value) {   
-           
+      foreach ($elements as $rank => $value) {
+         
         $status = tripal_pub_insert_property($pub['pub_id'], $property, $value, FALSE);
         if (!$status) {
           drupal_set_message("Error cannot add property: $property", "error");
-          watchdog('tripal_pub', "Error cannot add property: %prop", 
-            array('%property' => $property), WATCHDOG_ERROR);
+          watchdog('tripal_pub', "Error cannot add property: %prop",
+          array('%property' => $property), WATCHDOG_ERROR);
         }
-      } 
+      }
     }
-    
+
     // add in any database cross-references
     foreach ($cross_refs as $index => $ref) {
       $pub_dbxref = tripal_pub_add_pub_dbxref($pub['pub_id'], trim($ref));
-      if (!$pub_dbxref) { 
+      if (!$pub_dbxref) {
         drupal_set_message("Error cannot add publication cross reference: $ref", "error");
-        watchdog('tripal_pub', "Error cannot add publication cross reference: %ref", 
-          array('%ref' => $ref), WATCHDOG_ERROR);
-      }   
-    }          
-  } // if ($node->pub_id) {} else 
+        watchdog('tripal_pub', "Error cannot add publication cross reference: %ref",
+        array('%ref' => $ref), WATCHDOG_ERROR);
+      }
+    }
+  } // if ($node->pub_id) {} else
 
-  if ($pub) {   
+  if ($pub) {
     // make sure the entry for this feature doesn't already exist in the chado_pub table
     // if it doesn't exist then we want to add it.
     $pub_id = chado_get_id_for_node('pub', $node) ;
     if (!$pub_id) {
-       // next add the item to the drupal table
+      // next add the item to the drupal table
       $sql = "INSERT INTO {chado_pub} (nid, vid, pub_id) ".
              "VALUES (%d, %d, %d)";
       db_query($sql, $node->nid, $node->vid, $pub['pub_id']);
@@ -471,7 +471,7 @@ function chado_pub_insert($node) {
   else {
     drupal_set_message(t('Unable to add publication.', 'warning'));
     watchdog('tripal_pub', 'Insert publication: Unable to create pub where values: %values',
-      array('%values' => print_r($values, TRUE)), WATCHDOG_WARNING);
+    array('%values' => print_r($values, TRUE)), WATCHDOG_WARNING);
   }
 }
 
@@ -493,12 +493,12 @@ function chado_pub_update($node) {
     // there is no way to handle revisions in Chado but leave
     // this here just to make not we've addressed it.
   }
- 
+
   // get the publication ID for this publication
   $pub_id = chado_get_id_for_node('pub', $node) ;
-  
+
   $properties = array(); // stores all of the properties we need to add
-  $cross_refs = array(); // stores any cross references for this publication  
+  $cross_refs = array(); // stores any cross references for this publication
    
   // get the list of properties for easy lookup (without doing lots of database queries
   $properties_list = array();
@@ -513,43 +513,43 @@ function chado_pub_update($node) {
       NOT CVTS.is_obsolete = 1
     ORDER BY CVTS.name ASC 
   ";
-  $prop_types = chado_query($sql);   
+  $prop_types = chado_query($sql);
   while ($prop = db_fetch_object($prop_types)) {
     $properties_list[$prop->cvterm_id] = $prop->name;
     // The 'Citation' term is special because it serves
     // both as a property and as the uniquename for the
     // pub and we want it stored in both the pub table and the pubprop table
     if ($prop->name == 'Citation') {
-      $properties[$prop->name][0] = $node->uniquename;   
+      $properties[$prop->name][0] = $node->uniquename;
     }
   }
-  
-  // get the properties that should be added. Properties are in one of three forms: 
+
+  // get the properties that should be added. Properties are in one of three forms:
   //  1) prop_value-[type id]-[index]
   //  2) new_value-[type id]-[index]
-  //  3) new_id, new_value  
-//  dpm($node);
+  //  3) new_id, new_value
+  //  dpm($node);
   foreach ($node as $key => $value) {
     if (preg_match('/^prop_value-(\d+)-(\d+)/', $key, $matches)) {
       $type_id = $matches[1];
-      $index = $matches[2];  
-      $name = $properties_list[$type_id];  
-      $properties[$name][$index] = trim($value);     
+      $index = $matches[2];
+      $name = $properties_list[$type_id];
+      $properties[$name][$index] = trim($value);
     }
     if (preg_match('/^new_value-(\d+)-(\d+)/', $key, $matches)) {
       $type_id = $matches[1];
       $index = $matches[2];
       $name = $properties_list[$type_id];
       $properties[$name][$index] = trim($value);
-    }      
+    }
   }
   if ($node->new_id and $node->new_value) {
-    $type_id = $node->new_id;    
+    $type_id = $node->new_id;
     $name = $properties_list[$type_id];
     $index = count($properties[$name]);
-    $properties[$name][$index] = trim($node->new_value);    
-  } 
-  
+    $properties[$name][$index] = trim($node->new_value);
+  }
+
   // iterate through all of the properties and remove those that really are
   // part of the pub table fields
   foreach ($properties as $name => $element) {
@@ -557,7 +557,7 @@ function chado_pub_update($node) {
       if ($name == "Volume") {
         $volume = $value;
         unset($properties[$name]);
-      } 
+      }
       elseif ($name == "Volume Title") {
         $volumetitle = $value;
         unset($properties[$name]);
@@ -586,10 +586,10 @@ function chado_pub_update($node) {
         // we will add the cross-references to the pub_dbxref table
         // but we also want to keep the property in the pubprop table so don't unset it
         $cross_refs[] = $value;
-      } 
-    }   
+      }
+    }
   }
-  
+
   // update the pub record
   $match = array(
     'pub_id' => $pub_id,
@@ -615,31 +615,31 @@ function chado_pub_update($node) {
     watchdog('tripal_pub', "Error updating publication", array(), WATCHDOG_ERROR);
     return;
   }
-  
+
   // now add in the properties by first removing any the publication
   // already has and adding the ones we have
-  tripal_core_chado_delete('pubprop', array('pub_id' => $pub_id));  
+  tripal_core_chado_delete('pubprop', array('pub_id' => $pub_id));
   foreach ($properties as $property => $elements) {
-    foreach ($elements as $rank => $value) {      
+    foreach ($elements as $rank => $value) {
       $status = tripal_pub_insert_property($pub_id, $property, $value, FALSE);
       if (!$status) {
         drupal_set_message("Error cannot add property: '$property'", "error");
-        watchdog('tripal_pub', "Error cannot add property: '%prop'", 
-          array('%prop' => $property), WATCHDOG_ERROR);
+        watchdog('tripal_pub', "Error cannot add property: '%prop'",
+        array('%prop' => $property), WATCHDOG_ERROR);
       }
-    } 
+    }
   }
-  
-  // add in any database cross-references after first removing 
+
+  // add in any database cross-references after first removing
   tripal_core_chado_delete('pub_dbxref', array('pub_id' => $pub_id));
   foreach ($cross_refs as $index => $ref) {
     $pub_dbxref = tripal_pub_add_pub_dbxref($pub_id, trim($ref));
-    if (!$pub_dbxref) { 
+    if (!$pub_dbxref) {
       drupal_set_message("Error cannot add publication cross reference: $ref", "error");
-      watchdog('tripal_pub', "Error cannot add publication cross reference: %ref", 
-        array('%ref' => $ref), WATCHDOG_ERROR);
-    }   
-  }   
+      watchdog('tripal_pub', "Error cannot add publication cross reference: %ref",
+      array('%ref' => $ref), WATCHDOG_ERROR);
+    }
+  }
 }
 
 
@@ -659,16 +659,16 @@ function chado_pub_load($node) {
   $pub_id = chado_get_id_for_node('pub', $node);
 
   $values = array('pub_id' => $pub_id);
-  $pub = tripal_core_generate_chado_var('pub', $values); 
-    
+  $pub = tripal_core_generate_chado_var('pub', $values);
+
   // expand the 'text' fields as those aren't included by default
   // and they really shouldn't be so large to cause problems
   if (is_array($pub) or is_object($pub)) {
     $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.title');
-    $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.volumetitle');  
+    $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.volumetitle');
     $pub = tripal_core_expand_chado_vars($pub, 'field', 'pub.uniquename');
   }
-    
+
   // set the URL path
   $path = "pub/$pub_id";
 
@@ -721,43 +721,43 @@ function chado_pub_delete(&$node) {
 
 /**
  * Because we are using AJAX with a node form we need to provide a callback
- * for the chado_pub node form.  This callback is different from the 
+ * for the chado_pub node form.  This callback is different from the
  * default 'chado_pub_form' callback
  */
 /*
-function tripal_pub_forms($form_id, $args) {
-  $forms = array();
-  if($form_id == 'chado_pub_node_form') {
-    $forms[$form_id] = array(
-      'callback' => 'chado_pub_node_form',
-      'callback arguments' => array($args)
-    );
-  }
-  return $forms;
-}*/
+ function tripal_pub_forms($form_id, $args) {
+ $forms = array();
+ if($form_id == 'chado_pub_node_form') {
+ $forms[$form_id] = array(
+ 'callback' => 'chado_pub_node_form',
+ 'callback arguments' => array($args)
+ );
+ }
+ return $forms;
+ }*/
 
 /*
- * 
+ *
  */
 
 function tripal_pub_form_alter(&$form, &$form_state, $form_id) {
-  if ($form_id == "tripal_pub_importer_setup_form") {    
+  if ($form_id == "tripal_pub_importer_setup_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 ($form_state['values']['action'] == 'edit') {
       $form['#action'] = url("admin/tripal/tripal_pub/import/edit/" . $form_state['values']['pub_import_id']);
-    } 
+    }
     if ($form_state['values']['action'] == 'new') {
       $form['#action'] = url("admin/tripal/tripal_pub/import/new");
     }
   }
-  if ($form_id == "tripal_pub_search_form") {    
+  if ($form_id == "tripal_pub_search_form") {
     $form['#action'] = url("find/publications");
   }
   if ($form_id == "chado_pub_node_form") {
   }
-} 
+}
 
 /**
  *
@@ -799,39 +799,39 @@ function tripal_pub_preprocess_tripal_pub_relationships(&$variables) {
   // iterate through the object relationships
   while ($relationship = db_fetch_object($as_object)) {
 
-     // get the relationship and child types
-     $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type));
-     $sub_type = t(preg_replace('/_/', " ", $relationship->sub_type));
-
-     if (!array_key_exists($rel_type, $relationships['object'])) {
-       $relationships['object'][$rel_type] = array();
-     }
-     if (!array_key_exists($sub_type, $relationships['object'][$rel_type])) {
-       $relationships['object'][$rel_type][$sub_type] = array();
-     }
-     $relationships['object'][$rel_type][$sub_type][] = $relationship;
+    // get the relationship and child types
+    $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type));
+    $sub_type = t(preg_replace('/_/', " ", $relationship->sub_type));
+
+    if (!array_key_exists($rel_type, $relationships['object'])) {
+      $relationships['object'][$rel_type] = array();
+    }
+    if (!array_key_exists($sub_type, $relationships['object'][$rel_type])) {
+      $relationships['object'][$rel_type][$sub_type] = array();
+    }
+    $relationships['object'][$rel_type][$sub_type][] = $relationship;
   }
 
   // now add in the subject relationships
   while ($relationship = db_fetch_object($as_subject)) {
 
-     // get the relationship and child types
-     $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type));
-     $obj_type = t(preg_replace('/_/', " ", $relationship->obj_type));
-
-     if (!array_key_exists($rel_type, $relationships['subject'])) {
-       $relationships['subject'][$rel_type] = array();
-     }
-     if (!array_key_exists($obj_type, $relationships['subject'][$rel_type])) {
-       $relationships['subject'][$rel_type][$obj_type] = array();
-     }
-     $relationships['subject'][$rel_type][$obj_type][] = $relationship;
+    // get the relationship and child types
+    $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type));
+    $obj_type = t(preg_replace('/_/', " ", $relationship->obj_type));
+
+    if (!array_key_exists($rel_type, $relationships['subject'])) {
+      $relationships['subject'][$rel_type] = array();
+    }
+    if (!array_key_exists($obj_type, $relationships['subject'][$rel_type])) {
+      $relationships['subject'][$rel_type][$obj_type] = array();
+    }
+    $relationships['subject'][$rel_type][$obj_type][] = $relationship;
   }
 
   $pub->all_relationships = $relationships;
 }
 /**
- * 
+ *
  */
 function tripal_pub_mail($key, &$message, $params) {
   $language = $message['language'];
@@ -843,18 +843,18 @@ function tripal_pub_mail($key, &$message, $params) {
         'Content-Type' => 'text/html; charset=UTF-8; format=flowed',
         'Content-Transfer-Encoding' => '8Bit',
         'X-Mailer' => 'Drupal'
-      );
-      foreach ($headers as $key => $value) {
-        $message['headers'][$key] = $value;
-      }
-      $message['subject'] = t('Publication import from !site', $variables, $language->language);
-      $message['body'][] = $params['message'];
-      break;
+        );
+        foreach ($headers as $key => $value) {
+          $message['headers'][$key] = $value;
+        }
+        $message['subject'] = t('Publication import from !site', $variables, $language->language);
+        $message['body'][] = $params['message'];
+        break;
   }
 }
 
 /*
- * 
+ *
  */
 function tripal_pub_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
   // we want the publications to always have a URL of http://[base url]/pub/[pub id]
@@ -865,14 +865,14 @@ function tripal_pub_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
   // of the node and when the node is loaded if it hasn't yet been set.
   if ($node->type == 'chado_pub') {
     switch ($op) {
-      case 'presave':                        
+      case 'presave':
         break;
       case 'insert':
         $pub_id = chado_get_id_for_node('pub', $node);
         tripal_pub_set_pub_url($node, $pub_id);
         break;
       case 'load':
-        if (!$node->path) {          
+        if (!$node->path) {
           $pub_id = chado_get_id_for_node('pub', $node);
           $path = tripal_pub_set_pub_url($node, $pub_id);
         }

+ 15 - 15
tripal_pub/tripal_pub.views.inc

@@ -26,26 +26,26 @@ function tripal_pub_views_data()  {
   if (module_exists('tripal_views')) {
     $tables = array(
       'pub'
-    );
-    foreach ($tables as $tablename) {
-      if (!tripal_views_is_integrated($tablename, 10)) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
-        tripal_views_integration_add_entry($table_integration_array);
+      );
+      foreach ($tables as $tablename) {
+        if (!tripal_views_is_integrated($tablename, 10)) {
+          $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE);
+          tripal_views_integration_add_entry($table_integration_array);
+        }
       }
-    }
 
-    $tables = array(
+      $tables = array(
       'pub_dbxref',
       'pub_relationship',
       'pubauthor',
       'pubprop'
-    );
-    foreach ($tables as $tablename) {
-      if (!tripal_views_is_integrated($tablename, 10)) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE);
-        tripal_views_integration_add_entry($table_integration_array);
+      );
+      foreach ($tables as $tablename) {
+        if (!tripal_views_is_integrated($tablename, 10)) {
+          $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE);
+          tripal_views_integration_add_entry($table_integration_array);
+        }
       }
-    }
   }
 
   return $data;
@@ -63,9 +63,9 @@ function tripal_pub_views_handlers() {
   return array(
    'info' => array(
      'path' => drupal_get_path('module', 'tripal_pub') . '/views/handlers',
-    ),
+  ),
    'handlers' => array(
 
-    ),
+  ),
   );
 }

+ 87 - 40
tripal_stock/theme/tripal_stock_admin.tpl.php

@@ -1,60 +1,107 @@
-  <h3>Tripal Stock Administrative Tools Quick Links</h3>
+  <h3>Tripal Stock Quick Links</h3>
     <ul>
       <li><?php print l(t('Configuration'), 'admin/tripal/tripal_stock/configuration') ?></li>
       <li><?php print l(t('Stock Listing'), 'stocks') ?></li>
     </ul>
-
+<br>
   <h3>Module Description:</h3>
   <p>The Tripal Stock Module provides functionality for adding, editing, deleting and accessing chado stocks. The stock module was designed to store information about stock collections in a laboratory. What is called a stock could also be called a strain or an accession. There is a lot in common between a Drosophila stock and a Saccharomyces strain and an Arabidopsis line. They all come from some taxon, have genotypes, physical locations in the lab, some conceivable relationship with a publication, some conceivable relationship with a sequence feature (such as a transgene), and could be described by some ontology term. For more information about the chado Stock Module <a href="http://gmod.org/wiki/Chado_Stock_Module">see the GMOD Wiki Page</a></p>
 
   <h3>Setup Instructions:</h3>
-  <ol>
- <li><p><b>Set Permissions</b>: By default only the site administrator account has access to create, edit, delete
-   or administer analyses. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
-   permissions under the 'tripal_stock' section as appropriate for your site. For a simple setup, allow anonymous 
-   users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
+  <ul>
+   <li><p><b>Set Permissions</b>: By default only the site administrator account has access to create, edit, delete
+     or administer analyses. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
+     permissions under the 'tripal_stock' section as appropriate for your site. For a simple setup, allow anonymous 
+     users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
 
-  <li><b>Set Ontologies</b>: Since at the time of this modules developement there is no accepted ontology for
-            describing stocks, their properties and relationships, this module allows you to select the controlled
-            vocabularies (CVs) in your Chado Database you would like to govern these data. To Set the Controlled Vocabularies for Stocks:
-            First, ensure your Controlled Vocabulary is in Chado. This can be done by either loading an existing Ontology into Chado using
-            the <a href="tripal_cv/ontology_loader">Tripal Ontology Loader</a> OR create your ontology from scratch by first
-            <a href="tripal_cv/add_cv">creating a controlled vocabulary</a> and then <a href="tripal_cv/add_cvterm">adding terms to it</a>.
-            Then go to the <a href="tripal_stock/configuration">Configuration Page for Stocks</a> and, in the "Set Stock Controlled Vocabularies" Fieldset,
-            select the Controlled Vocaulary name for Stock Types, Stock Properties and Stock Relationship Types.</li>
+    <li><p><b>Set Ontologies</b>: Since at the time of this modules developement there is no accepted ontology for
+      describing stocks, their properties and relationships, this module allows you to select the controlled
+      vocabularies (CVs) in your Chado Database you would like to govern these data. To Set the Controlled Vocabularies for Stocks:
+      First, ensure your Controlled Vocabulary is in Chado. This can be done by either loading an existing Ontology into Chado using
+      the <a href="tripal_cv/ontology_loader">Tripal Ontology Loader</a> OR create your ontology from scratch by first
+      <a href="tripal_cv/add_cv">creating a controlled vocabulary</a> and then <a href="tripal_cv/add_cvterm">adding terms to it</a>.
+      Then go to the <a href="tripal_stock/configuration">Configuration Page for Stocks</a> and, in the "Set Stock Controlled Vocabularies" Fieldset,
+      select the Controlled Vocaulary name for Stock Types, Stock Properties and Stock Relationship Types.</p>
       <ol type="i">
         <li>Stock Types: When you are creating stocks, the type of each stock must be indicated. This might include "DNA extraction", "Individual Plant/Animal" or even "Progeny Population".</li>
         <li>Stock Properties: This module also allows you to assign properties to any stock. Each property has a type and a value where type is required an value is not. Therefore, if you want to say that a stock was grown at 23 degrees Celcius then the Type would be "temperature grown at" and the value would be 23 degrees Celcius. As such the Stock Properties controlled vocabulary might include "temperature grown at", "diet", "extraction date", "stock location", etc.</li>
         <li>Stock Relationship Types: You can also specify relationships between stocks. For example, a stock of type="DNA extraction" (Stock 1a) is related to the stock of type="Individual Plant/Animal" (Stock 1) that it was extracted from. Thus you might specify the relationship Stock 1 is the source material for Stock 1a where the relationship type is "is the source material for". As such Stock Relationship Types might include "is the source material for", "is maternal parent of", "is individual of population", etc.</li>
       </ol>
+    </li>
 
-  <li><p><b>Set Permissions</b>: The stock module supports the Drupal user permissions interface for
-               controlling access to stock content and functions. These permissions include viewing,
-               creating, editing or administering of
-               stock content. The default is that only the original site administrator has these
-               permissions.  You can <a href="<?php url('admin/user/roles') ?>">add roles</a> for classifying users,
-               <a href="<?php url('admin/user/user') ?>">assign users to roles</a> and
-               <a href="<?php url('admin/user/permissions') ?>">assign permissions</a> for the stock content to
-               those roles.  For a simple setup, allow anonymous users access to view organism content and
-               allow the site administrator all other permissions.</p></li>
-
-  <li><b>Sync Stocks</b>: if you chado database already contains stocks, they need to be sync'd with Drupal</b>. This creates Drupal Content including detail pages for each stock (known as nodes in Drupal). To sync' Chado with Drupal simply go to the <a href="tripal_stock/configuration">Configuration Page for Stocks</a> and in the "Sync Stocks" Fieldset select the Organisms whose associated stocks you would like to sync. If this list doesn't contain an organism which you know is in Chado go to the Organism Configuration Page and make sure it is sync'd with Drupal.</p>
-  </ol>
+    <li><p><b>Set Permissions</b>: The stock module supports the Drupal user permissions interface for
+     controlling access to stock content and functions. These permissions include viewing,
+     creating, editing or administering of
+     stock content. The default is that only the original site administrator has these
+     permissions.  You can <a href="<?php url('admin/user/roles') ?>">add roles</a> for classifying users,
+     <a href="<?php url('admin/user/user') ?>">assign users to roles</a> and
+     <a href="<?php url('admin/user/permissions') ?>">assign permissions</a> for the stock content to
+     those roles.  For a simple setup, allow anonymous users access to view organism content and
+     allow the site administrator all other permissions.</p></li>
+    <li><p><b>Sync Stocks</b>: if you chado database already contains stocks, they need to be sync'd with Drupal. 
+      This creates Drupal Content including detail pages for each stock (known as nodes in Drupal). To sync' Chado 
+      with Drupal simply go to the <?php print l('stock configuration page', 'admin/tripal/tripal_stock/configuration') ?>
+      and in the "Sync Stocks" Fieldset select the Organisms whose associated stocks you would like 
+      to sync. If this list doesn't contain an organism which you know is in Chado go to the 
+      Organism Configuration Page and make sure it is sync'd with Drupal.</p></li>
+  </ul>
   <h3>Features of this Module:</h3>
   <ul>
-  <li><b><a href="../../node/add/chado_stock">Create a Generic Stock:</a></b>
-  <p>This allows you to create content in your drupal and chado for a stock (only the unique stock identifier is duplicated). A Generic Stock must have a unique name, a type and an organism. In addition, you can optionally supply a more human-readable name, a primary database reference and even a short description. The Create Generic Stock form is a multistep form with the first step creating the Basic stock (stored in the stock table). All the remaining steps are optional and descriptions of each follow:</p>
+    <li><p><b><a href="../../node/add/chado_stock">Create a Generic Stock:</a></b>
+      This allows you to create content in your drupal and chado for a stock (only the unique stock identifier 
+      is duplicated). A Generic Stock must have a unique name, a type and an organism. In addition, you can 
+      optionally supply a more human-readable name, a primary database reference and even a short description.
+      The Create Generic Stock form is a multistep form with the first step creating the Basic stock (stored 
+      in the stock table). All the remaining steps are optional and descriptions of each follow:</p>
       <ol type="i">
-        <li>The Next Step is to Add Properties to the newly created stock. Properties allow you to specify additional details about a given stock. Since the types of properties you can add are goverened by a controlled vocaulary that you can create, you have complete control over what additional properties you want to allow.</li>
-        <li>Then you can Add External Database References. A Database Reference can be thought of as a synonym for the current stock where you want to specify a source for that synonym. The source would then be thought of as the database where a database can either be online and provide automatic linking out to the synonymous record or offline and simply be a text name of the source. To create a database reference with a given source you must first add the database to chado <a href="tripal_db/add_db">here</a>.</li>
-        <li>Finally you can Add Relationships between Stocks. This allows you to specify, for example, the source material of a stock or one of it's parents. To create a relationship between your newly added stock and another stock, the other stock must first be created as this one was. Also, since the types of relationships is governed by a controlled vocabulary, just like with properties you have complete control over which relationships you want to allow. Once you click "Finish" you will be re-directed to the Details Page of the new Stock.</li>
-      </ol></li>
+        <li>The Next Step is to Add Properties to the newly created stock. Properties allow you to specify 
+        additional details about a given stock. Since the types of properties you can add are goverened by 
+        a controlled vocaulary that you can create, you have complete control over what additional properties 
+        you want to allow.</li>
+        <li>Then you can Add External Database References. A Database Reference can be thought of as a 
+        synonym for the current stock where you want to specify a source for that synonym. The source 
+        would then be thought of as the database where a database can either be online and provide automatic 
+        linking out to the synonymous record or offline and simply be a text name of the source. To create a 
+        database reference with a given source you must first add the database to 
+        chado <?php print l('here', 'admin/tripal/tripal_db/')?><a href="tadmin/tripal/tripal_db/add_db">here</a>.</li>
+        <li>Finally you can Add Relationships between Stocks. This allows you to specify, for example, the source 
+        material of a stock or one of it's parents. To create a relationship between your newly added stock and 
+        another stock, the other stock must first be created as this one was. Also, since the types of 
+        relationships is governed by a controlled vocabulary, just like with properties you have complete 
+        control over which relationships you want to allow. Once you click "Finish" you will be re-directed 
+        to the Details Page of the new Stock.</li>
+      </ol>
+    </li>
 
-  <li><b>Details Page of a Stock:</b>
-  <p>Each stock get's it's own page on this website. This page is meant to give an overall picture of the stock including listing the basic details, as well as, all properties, database references and relationships. To understand where it is -All page content in Drupal is known as a node and is given a unique identifier or nid. Thus every drupal page has a path of node/<nid>. You can get to the Details page for a given stock from either of the stock listings described below.</p>
-  <p>If you want to customize the look of the stock Details page simply copy the PHP/HTML template node-chado_stock.tpl.php from theme_tripal to the base theme you are currently using. Then edit it as desired. There are plans to integrate this details page with Drupal Panels which will provide a much more user-friendly and no-programming-needed method to customize this page.</p>
+    <li><p><b>Details Page of a Stock:</b> Each stock get's it's own page on this website. This page is meant 
+    to give an overall picture of 
+    the stock including listing the basic details, as well as, all properties, database references and 
+    relationships. To understand where it is -All page content in Drupal is known as a node and is given 
+    a unique identifier or nid. Thus every drupal page has a path of node/[nid]. You can get to the 
+    Details page for a given stock from either of the stock listings described below.
+    If you want to customize the look of the stock Details page simply copy the PHP/HTML template 
+    node-chado_stock.tpl.php from theme_tripal to the base theme you are currently using. Then edit it 
+    as desired. There are plans to integrate this details page with Drupal Panels which will provide a 
+    much more user-friendly and no-programming-needed method to customize this page.</p></li>
 
-  <li><b>Adding/Updating/Deleting Stocks and their Properties, Database References and Relationships:</b>
-  <p>The Stock Details Page also acts as a landing pad for updating/deleting stocks. To <b>update a stock</b>, go to the stocks details page and click on the Edit tab near the top of the page. This tab will only be visable if you have permission to edit chado stock content (See post installation steps above for information on setting user permissions). If you want to <b>delete a stock</b>, click the Edit tab and then near the bottom of the form, click the Delete button. This will delete the entire stock including it's properties, database references and any relationships including it.</p>
-  <p>To <b>update/delete a given property of a stock</b>, click the "Edit Properties" Tab near the top of the stock details page. This form provides a listing of all existing properties for the given stock with form elements allowing you to change their value. After editing the properties you wanted to, simply click the "Update Properties" button to update all the properties for that stock. To delete a given property simply click the "Delete" Button beside the property you want to delete. You cannot undo this action! To <b>add a property to the given stock</b> simply fill out the "Add Property" form at the bottom of the "Edit Properties" Tab.</p>
-  <p><b>Adding, updating and deleting Database References and Relationships</b> for a given stock is exactly the same as the method for properties. To edit Database References, click the "Edit DB References" tab and to add/edit/update stock relationships, click the "Edit Relationships" tab.</p></li>
+    <li><p><b>Adding/Updating/Deleting Stocks and their Properties, Database References and Relationships:</b>
+      The Stock Details Page also acts as a landing pad for updating/deleting stocks.</p> 
+      <p>To <b>update a stock</b>, 
+      go to the stocks details page and click on the Edit tab near the top of the page. This tab will only be 
+      visable if you have permission to edit chado stock content (See post installation steps above for 
+      information on setting user permissions). </p>
+      <p>To <b>delete a stock</b>, click the Edit tab and 
+      then near the bottom of the form, click the Delete button. This will delete the entire stock including 
+      it's properties, database references and any relationships including it.</p>
+      <p>To <b>update/delete a given property of a stock</b>, click the "Edit Properties" Tab near the top of 
+      the stock details page. This form provides a listing of all existing properties for the given stock with 
+      form elements allowing you to change their value. After editing the properties you wanted to, simply click 
+      the "Update Properties" button to update all the properties for that stock. To delete a given property 
+      simply click the "Delete" Button beside the property you want to delete. You cannot undo this action!</p>
+      <p>To <b>add a property to the given stock</b> simply fill out the "Add Property" form at the bottom of 
+      the "Edit Properties" Tab.</p>
+      <p>For <b>Adding, updating and deleting Database References and Relationships</b> for a given stock is 
+      exactly the same as the method for properties. To edit Database References, click the "Edit DB References" 
+      tab and to add/edit/update stock relationships, click the "Edit Relationships" tab.</p>
+    </li>
+</ul>

+ 1 - 1
tripal_stock/tripal_stock.info

@@ -3,6 +3,6 @@ description = A module for interfacing the GMOD chado database with Drupal, prov
 core = 6.x
 project = tripal_stock
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = tripal_core
 dependencies[] = tripal_organism

+ 1 - 1
tripal_views/tripal_views.info

@@ -3,7 +3,7 @@ description = This module provides integration with Drupal Views. Other Tripal m
 core = 6.x
 project = tripal_core
 package = Tripal
-version = 6.x-1.0-fix1
+version = 6.x-1.1
 dependencies[] = views
 dependencies[] = views_data_export
 dependencies[] = tripal_core

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