فهرست منبع

Merge pull request #3 from tripal/7.x-3.x

7.x 3.x
Abdullah Almsaeed 7 سال پیش
والد
کامیت
6fe417c5c1
100فایلهای تغییر یافته به همراه2030 افزوده شده و 6226 حذف شده
  1. 113 0
      README.md
  2. 0 48
      README.txt
  3. 1 1
      docs/tripal_doxygen.config
  4. 3 3
      legacy/tripal_analysis/includes/tripal_analysis.admin.inc
  5. 4 4
      legacy/tripal_analysis/includes/tripal_analysis.chado_node.inc
  6. 2 3
      legacy/tripal_analysis/includes/tripal_analysis.delete.inc
  7. 3 3
      legacy/tripal_analysis/tripal_analysis.info
  8. 10 117
      legacy/tripal_analysis/tripal_analysis.install
  9. 12 11
      legacy/tripal_analysis/tripal_analysis.module
  10. 1 1
      legacy/tripal_analysis/tripal_analysis.views_default.inc
  11. 3 3
      legacy/tripal_contact/includes/tripal_contact.admin.inc
  12. 9 7
      legacy/tripal_contact/includes/tripal_contact.chado_node.inc
  13. 2 2
      legacy/tripal_contact/tripal_contact.info
  14. 3 182
      legacy/tripal_contact/tripal_contact.install
  15. 9 7
      legacy/tripal_contact/tripal_contact.module
  16. 1 1
      legacy/tripal_contact/tripal_contact.views_default.inc
  17. 6 6
      legacy/tripal_core/api/tripal_core.DEPRECATED.inc
  18. 23 22
      legacy/tripal_core/api/tripal_core.chado_nodes.api.inc
  19. 14 14
      legacy/tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc
  20. 9 9
      legacy/tripal_core/api/tripal_core.chado_nodes.properties.api.inc
  21. 6 3
      legacy/tripal_core/api/tripal_core.chado_nodes.relationships.api.inc
  22. 121 11
      legacy/tripal_core/api/tripal_core.chado_nodes.title_and_path.inc
  23. 2 2
      legacy/tripal_core/includes/tripal_core.form_elements.inc
  24. 439 0
      legacy/tripal_core/includes/tripal_core.search.inc
  25. 79 60
      legacy/tripal_core/includes/tripal_core.toc.inc
  26. 1 69
      legacy/tripal_core/theme/css/tripal_core.css
  27. 0 0
      legacy/tripal_core/theme/js/tripal_core.js
  28. 18 19
      legacy/tripal_core/theme/templates/node--chado-generic.tpl.php
  29. 4 4
      legacy/tripal_core/tripal_core.info
  30. 4 4
      legacy/tripal_core/tripal_core.install
  31. 180 2
      legacy/tripal_core/tripal_core.module
  32. 104 0
      legacy/tripal_core/tripal_core.views_default.inc
  33. 117 0
      legacy/tripal_cv/api/tripal_cv.api.inc
  34. 0 320
      legacy/tripal_cv/includes/tripal_cv.admin.inc
  35. 282 0
      legacy/tripal_cv/includes/tripal_cv.cv_defaults.inc
  36. 0 256
      legacy/tripal_cv/includes/tripal_cv.cv_form.inc
  37. 0 474
      legacy/tripal_cv/includes/tripal_cv.cvterm_form.inc
  38. 0 68
      legacy/tripal_cv/includes/tripal_cv.cvtermpath_form.inc
  39. 1 1
      legacy/tripal_cv/theme/templates/tripal_cv_help.tpl.php
  40. 2 2
      legacy/tripal_cv/tripal_cv.info
  41. 45 0
      legacy/tripal_cv/tripal_cv.install
  42. 27 37
      legacy/tripal_cv/tripal_cv.module
  43. 0 447
      legacy/tripal_cv/tripal_cv.views_default.inc
  44. 3 3
      legacy/tripal_db/tripal_db.info
  45. 6 47
      legacy/tripal_db/tripal_db.module
  46. 0 370
      legacy/tripal_db/tripal_db.views_default.inc
  47. 0 110
      legacy/tripal_example/README.txt
  48. 0 35
      legacy/tripal_example/api/tripal_example.api.inc
  49. 0 96
      legacy/tripal_example/includes/tripal_example.admin.inc
  50. 0 880
      legacy/tripal_example/includes/tripal_example.chado_node.inc
  51. 0 9
      legacy/tripal_example/theme/js/tripal_example.js
  52. 0 85
      legacy/tripal_example/theme/templates/tripal_example_base.tpl.php
  53. 0 8
      legacy/tripal_example/theme/templates/tripal_example_help.tpl.php
  54. 0 70
      legacy/tripal_example/theme/templates/tripal_example_properties.tpl.php
  55. 0 70
      legacy/tripal_example/theme/templates/tripal_example_references.tpl.php
  56. 0 151
      legacy/tripal_example/theme/templates/tripal_example_relationships.tpl.php
  57. 0 14
      legacy/tripal_example/theme/templates/tripal_example_teaser.tpl.php
  58. 0 113
      legacy/tripal_example/theme/tripal_example.theme.inc
  59. 0 50
      legacy/tripal_example/tripal_example.info
  60. 0 608
      legacy/tripal_example/tripal_example.install
  61. 0 365
      legacy/tripal_example/tripal_example.module
  62. 0 9
      legacy/tripal_example/tripal_example.views.inc
  63. 0 25
      legacy/tripal_example/tripal_example.views_default.inc
  64. 3 3
      legacy/tripal_feature/includes/tripal_feature.admin.inc
  65. 4 6
      legacy/tripal_feature/includes/tripal_feature.chado_node.inc
  66. 1 1
      legacy/tripal_feature/includes/tripal_feature.delete.inc
  67. 18 20
      legacy/tripal_feature/theme/templates/tripal_feature_help.tpl.php
  68. 29 29
      legacy/tripal_feature/theme/templates/tripal_feature_sequence.tpl.php
  69. 12 12
      legacy/tripal_feature/theme/templates/tripal_feature_terms.tpl.php
  70. 7 2
      legacy/tripal_feature/theme/templates/tripal_organism_feature_browser.tpl.php
  71. 6 6
      legacy/tripal_feature/theme/templates/tripal_organism_feature_counts.tpl.php
  72. 8 88
      legacy/tripal_feature/theme/tripal_feature.theme.inc
  73. 10 3
      legacy/tripal_feature/tripal_feature.drush.inc
  74. 2 2
      legacy/tripal_feature/tripal_feature.info
  75. 15 204
      legacy/tripal_feature/tripal_feature.install
  76. 33 163
      legacy/tripal_feature/tripal_feature.module
  77. 1 1
      legacy/tripal_feature/tripal_feature.views_default.inc
  78. 1 1
      legacy/tripal_feature/views_handlers/views_handler_field_residues.inc
  79. 3 3
      legacy/tripal_featuremap/includes/tripal_featuremap.admin.inc
  80. 2 2
      legacy/tripal_featuremap/includes/tripal_featuremap.chado_node.inc
  81. 24 19
      legacy/tripal_featuremap/theme/templates/tripal_feature_featurepos.tpl.php
  82. 27 22
      legacy/tripal_featuremap/theme/templates/tripal_featuremap_featurepos.tpl.php
  83. 16 16
      legacy/tripal_featuremap/theme/templates/tripal_featuremap_publication.tpl.php
  84. 2 2
      legacy/tripal_featuremap/tripal_featuremap.info
  85. 3 178
      legacy/tripal_featuremap/tripal_featuremap.install
  86. 10 8
      legacy/tripal_featuremap/tripal_featuremap.module
  87. 1 1
      legacy/tripal_featuremap/tripal_featuremap.views_default.inc
  88. 3 3
      legacy/tripal_genetic/includes/tripal_genetic.admin.inc
  89. 38 33
      legacy/tripal_genetic/theme/templates/tripal_feature_genotypes.tpl.php
  90. 32 27
      legacy/tripal_genetic/theme/templates/tripal_stock_genotypes.tpl.php
  91. 2 2
      legacy/tripal_genetic/tripal_genetic.info
  92. 7 5
      legacy/tripal_genetic/tripal_genetic.module
  93. 1 1
      legacy/tripal_genetic/tripal_genetic.views_default.inc
  94. 3 3
      legacy/tripal_library/includes/tripal_library.admin.inc
  95. 24 14
      legacy/tripal_library/includes/tripal_library.chado_node.inc
  96. 1 1
      legacy/tripal_library/theme/templates/tripal_library_base.tpl.php
  97. 6 1
      legacy/tripal_library/theme/templates/tripal_library_features.tpl.php
  98. 3 0
      legacy/tripal_library/theme/templates/tripal_library_properties.tpl.php
  99. 1 1
      legacy/tripal_library/theme/templates/tripal_organism_libraries.tpl.php
  100. 2 2
      legacy/tripal_library/tripal_library.info

+ 113 - 0
README.md

@@ -0,0 +1,113 @@
+![alt tag](https://raw.githubusercontent.com/tripal/tripal/7.x-3.x/tripal/theme/images/tripal_logo.png)
+
+Tripal is a toolkit for construction of online biological (genetics, genomics,
+breeding, etc), community database, and is a member of the 
+[GMOD](http://www.gmod.org) family of tools. Tripal v3 provides by default
+integration with the [GMOD Chado database](http://gmod.org/wiki/Chado_-_Getting_Started).
+Tripal's primary goals are: 
+
+Genomics, genetics, breeding and other biological data are increasingly complicated and time consuming to publish online for other researchers to search, browse and make discoveries.   Tripal provides a framework to reduce the complexity of creating such a site, and provides access to a community of similar groups that share community-standards, and interact to address questions and learn best practices for sharing, storing and visualizing complex biological data.
+
+1. Provide a framework for those with genomic, genetic and breeding data that
+can facility creation of an online site for display, search and visualization.
+2. To use community-derived standards and ontologies to facility continuity
+between sites which in turn fosters collaboration and sharing 
+3. Provide an out-of-the-box setup for a genomics site for those who simply 
+want to put new genome assemblies and annotations online.
+4. Provide Application Programming Interfaces (APIs) for complete customization 
+such that more advanced displays, look-and-feel, and new functionality
+can be supported. 
+
+
+# Features
+The following major features
+are available in Tripal v3.
+
+* Tripal v3's design is centered around controlled vocabularies and ontologies. 
+  This allows for greater integration with the semantic web and will help
+  support data exchange between Tripal sites.
+* RESTful web services.  Tripal v3 introduces RESTful web services for Tripal.
+  The resources provided by these web services uses JSON-LD and WC3 Hydra 
+  vocabulary to deliver content. 
+* Tripal v3 introduces new content pages. In older versions of Tripal all 
+  content was provided via Drupal "nodes".  Now content is delivered using
+  new content types (e.g. gene, genetic_marker, organism, germplasm, etc.)
+  and the site admin controls which content types are available on the site. 
+* Chado support:
+  * Tripal v3 represents a major redesign from previous versions.  Previously,
+    Chado was the only storage backend supported. Tripal v3 provides by default
+    support for Chado, but also sports a new design that affords integration of
+    other storage backends (including noSQL options).  
+  * A Chado v1.2 or v1.3 installer
+  * Data loaders for ontologies (controlled vocabularies), GFF files, and 
+    FASTA files, publications (from PubMed and AGIRCOLA). 
+  * Generic Bulk Data Loader Modules allows for creation of custom loaders 
+    without programming (requires an understanding of Chado). 
+  * Supports creation of materialized views for faster data queries.
+
+
+# Required Dependencies
+* Drupal: 
+  * Drupal 7.x
+  * Drupal core modules: Search, Path and PHP modules.
+  * Drupal contributed modules: 
+    * [Views](http://drupal.org/project/views)
+    * [Entity API](http://drupal.org/project/entity)
+* PostgreSQL
+* PHP 5.5+
+* UNIX/Linux
+
+
+# Installation
+Please follow the instructions in the online Tripal User's Guide:
+http://tripal.info/tutorials/v2.0/installation
+
+
+# Upgrade from Tripal v2.x to v3.x
+Note:  Upgrade can only be performed using 'drush' command.
+
+Note: Deprecated API functions from Tripal v1.x have been removed from Tripal
+v3.  Therefore, use of deprecated API functions in templates or custom 
+modules may cause a white screen of death (WSOD).  Check teh server logs if this
+occurs to find where deprecated functions may be used.
+
+Upgrade Instructions:
+
+Step 1: Put the site in maintenance mode.
+
+Step 2: Disable tripal modules. Disabling the core module will disable all
+other Tripal modules:
+
+  drush pm-disable tripal_core
+  
+Step 3: Remove old Tripal v2 package and replace with Tripal v3 package
+Step 4: Enable the tripal module
+
+  drush pm-enable tripal
+ 
+Step 5: Enable the tripal_chado module  
+
+  drush pm-enable tripal_chado
+  
+Step 6:  Tripal v2 modules are now called 'legacy modules'. these are the
+modules that were disabled in step #2.  For backwards compatibility, you 
+should re-enable these modules:
+
+  drush pm-enable tripal_core, tripal_views, tripal_db, tripal_cv, \
+    tripal_analysis, tripal_organism, tripal_feature, tripal_pub, \
+    tripal_stock
+
+Be sure to enable any additional modules not included in the example
+drush command above.
+
+Step 7:  Return to your Tripal site, and click the link that appears for
+preparing Chado and launch the job.
+
+
+# Customization
+Tripal can be used “as is” but also allows for complete customization.
+PHP-based template files are provided for all data types to allow for 
+precise customizations as required by the community. A well-developed 
+Tripal API provides a uniform set of variables and functions for 
+accessing any and all data within the Chado database. See the Tripal 3.x
+Developer's Handbook for additional details.

+ 0 - 48
README.txt

@@ -1,48 +0,0 @@
-What is Tripal?
---------------
-Tripal is a collection of open-source freely available Drupal modules 
-and is a member of the GMOD family of tools. Tripal serves as a web 
-interface for the GMOD Chado database and is designed to reduce the
-time and cost required for construction of an online genomic, genetic
-and breeding database.
-
-
-Features
---------------
- - a Chado installer
- - Data loaders for ontologies (controlled vocabularies), GFF files, 
-   and FASTA files, publications (from PubMed and AGIRCOLA). 
- - Generic Bulk Data Loader Modules allows for creation of custom 
-   loading templates.
- - Drupal nodes (web pages) are automatically generated for organisms,
-   genomic features, biological libraries, and stocks
- - Supports creation of materialized views for faster data queries.
- - Display templates are provided for all content types for
-   easier customization.
- - Views Integration allows for custom listings of data
- - Content pieces exposed as blocks allowing the use of Panels for 
-   custom layouts of Tripal Nodes
-
-
-Required Modules
---------------
- - Drupal 7.x 
- - Drupal Core Modules: Search, Path and PHP modules.
- - Drupal contributed modules: Views
- - Database containing GMOD Chado Schema (can be installed by the 
-   Tripal Core module)
-NOTE: A PostgreSQL database is required for installation of the 
-Chado Schema
-
-Installation
---------------
-Please follow the instructions in the online Tripal User's Guide:
-http://tripal.info/tutorials/v2.0/installation
-
-Customization
---------------
-Tripal can be used “as is” but also allows for complete customization.
-PHP-based template files are provided for all data types to allow for 
-precise customizations as required by the community. A well-developed 
-Tripal API provides a uniform set of variables and functions for 
-accessing any and all data within the Chado database.

+ 1 - 1
docs/tripal_doxygen.config

@@ -31,7 +31,7 @@ PROJECT_NAME           = Tripal
 # This could be handy for archiving the generated documentation or
 # if some version control system is used.
 
-PROJECT_NUMBER         = "v1.1 (6.x-1.1)"
+PROJECT_NUMBER         = "v3.0 (7.x-3.0)"
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer

+ 3 - 3
legacy/tripal_analysis/includes/tripal_analysis.admin.inc

@@ -20,8 +20,8 @@ function tripal_analysis_admin_analysis_view() {
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
-  $breadcrumb[] = l('Chado', 'admin/tripal/chado');
-  $breadcrumb[] = l('Analysis', 'admin/tripal/chado/tripal_analysis');
+  $breadcrumb[] = l('Chado', 'admin/tripal/legacy');
+  $breadcrumb[] = l('Analysis', 'admin/tripal/legacy/tripal_analysis');
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
@@ -35,7 +35,7 @@ function tripal_analysis_admin_analysis_view() {
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'enable the pertinent views</strong>:</p>';
     $output .= '<ul>';
-      $output .= '<li>'.l('Analysis View', 'admin/tripal/chado/tripal_analysis/views/analyses/enable').'</li>';
+      $output .= '<li>'.l('Analysis View', 'admin/tripal/legacy/tripal_analysis/views/analyses/enable').'</li>';
     $output .= '</ul>';
   }
 

+ 4 - 4
legacy/tripal_analysis/includes/tripal_analysis.chado_node.inc

@@ -171,7 +171,7 @@ function chado_analysis_form($node, &$form_state) {
   );
   $form['programversion']= array(
     '#type' => 'textfield',
-    '#title' => t('Program, Pipeline  or Method version'),
+    '#title' => t('Program, Pipeline  or Method Version'),
     '#required' => TRUE,
     '#default_value' => $programversion,
     '#description' => t("Version description, e.g. TBLASTX 2.0MP-WashU [09-Nov-2000]. Enter 'n/a' if no version is available or applicable."),
@@ -267,7 +267,7 @@ function chado_analysis_form($node, &$form_state) {
 
   // Properties Form
   // ----------------------------------
-  $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the analysis_property vocabulary", "admin/tripal/vocab/cvterm/add") . ".");
+  $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the analysis_property vocabulary", "admin/tripal/loaders/chado_cv/cvterm/add") . ".");
   $prop_cv = tripal_get_default_cv('analysisprop', 'type_id');
   $cv_id = $prop_cv ? $prop_cv->cv_id : NULL;
   $details = array(
@@ -441,7 +441,7 @@ function chado_analysis_insert($node) {
     );
     $analysis = chado_insert_record('analysis', $values);
     if (!$analysis) {
-      drupal_set_message(t('Unable to add analysis.', 'warning'));
+      drupal_set_message(t('Unable to add analysis.'), 'warning');
       tripal_report_error('tripal_analysis', TRIPAL_ERROR, 'Insert analysis: Unable to create analysis where values:%values',
         array('%values' => print_r($values, TRUE)));
       return;
@@ -618,7 +618,7 @@ function chado_analysis_load($nodes) {
  *
  * @ingroup tripal_analysis
  */
-function chado_analysis_node_access($node, $op, $account) {
+function tripal_analysis_node_access($node, $op, $account) {
 
   $node_type = $node;
   if (is_object($node)) {

+ 2 - 3
legacy/tripal_analysis/includes/tripal_analysis.delete.inc

@@ -84,11 +84,10 @@ function tripal_analysis_delete_analyses($analyses, $job = NULL) {
   global $user;
 
   // Deleting of analyses will cause a cascade delete on the
-  // fassociated tables which may include the fatureloc table. The create_point
+  // fassociated tables which may include the featureloc table. The create_point
   // function which is not prefix with the schema, and an error occurs.
   // Therefore, we set the active database to chado to get around that
   // problem.
-//  $previous_db = chado_set_active('chado');
 
   // begin the transaction
   $transaction = db_transaction();
@@ -114,6 +113,6 @@ function tripal_analysis_delete_analyses($analyses, $job = NULL) {
     watchdog_exception('tripal_analysis', $e);
     return 0;
   }
-//  chado_set_active($previous_db);
+
   print "\nDone\n";
 }

+ 3 - 3
legacy/tripal_analysis/tripal_analysis.info

@@ -3,10 +3,10 @@ description = Supports the companalyses tables of Chado by providing pages for v
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
-configure = admin/tripal/chado/tripal_analysis/configuration
+version = 7.x-3.0-rc1
+configure = admin/tripal/legacy/tripal_analysis/configuration
 
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_db
 dependencies[] = tripal_cv

+ 10 - 117
legacy/tripal_analysis/tripal_analysis.install

@@ -81,7 +81,8 @@ function tripal_analysis_uninstall() {
  *
  * @ingroup tripal_analysis
  */
-function tripal_analysis_create_analysisfeatureprop() {
+// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
+/* function tripal_analysis_create_analysisfeatureprop() {
 
   // Create analysisfeatureprop table in chado.  This is needed for Chado
   // version 1.11, the table exists in Chado 1.2.
@@ -100,7 +101,7 @@ function tripal_analysis_create_analysisfeatureprop() {
     ";
     chado_query($sql);
   }
-}
+} */
 
 /**
  * Add cvs related to analyses
@@ -148,7 +149,7 @@ function tripal_analysis_add_cvterms() {
         . 'abbreviation for the analysis.',
       'cv_name' => 'tripal',
       'is_relationship' => 0,
-      'db_name' => 'tripal'
+      'db_name' => 'local'
     ),
     array('update_existing' => TRUE)
   );
@@ -162,7 +163,7 @@ function tripal_analysis_add_cvterms() {
       'definition' => 'The type of analysis that was performed.',
       'cv_name' => 'analysis_property',
       'is_relationship' => 0,
-      'db_name' => 'tripal'
+      'db_name' => 'local'
     ),
     array('update_existing' => TRUE)
   );
@@ -236,7 +237,8 @@ function tripal_analysis_schema() {
  *
  * @ingroup tripal_analysis
  */
-function tripal_analysis_add_mview_analysis_organism() {
+// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
+/* function tripal_analysis_add_mview_analysis_organism() {
   $view_name = 'analysis_organism';
   $comment = t('This view is for associating an organism (via it\'s associated features) to an analysis.');
 
@@ -257,10 +259,12 @@ function tripal_analysis_add_mview_analysis_organism() {
     'description' => $comment,
     'fields' => array(
       'analysis_id' => array(
+        'size' => 'big',
         'type' => 'int',
         'not null' => TRUE,
       ),
       'organism_id' => array(
+        'size' => 'big',
         'type' => 'int',
         'not null' => TRUE,
       ),
@@ -287,115 +291,4 @@ function tripal_analysis_add_mview_analysis_organism() {
 
   // add the view
   tripal_add_mview($view_name, 'tripal_analysis', $schema, $sql, $comment);
-}
-
-/**
- * This is the required update for tripal_organism when upgrading from Drupal core API 6.x.
- *
- */
-function tripal_analysis_update_7200() {
-  // We cannot use the Tripal API calls in the 7200 update
-  // because during upgrade the tripal_core should also be disabled
-
-  // set the analysis_property as default
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'analysis_property'")->fetchField();
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-        'table_name' => 'analysisprop',
-        'field_name' => 'type_id',
-        'cv_id' => $cv_id
-      ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add analysis_property vocabulary: '. $error);
-  }
-
-
-  // During the upgrade from D6 to D7 the vocabulary terms assigned to organisms were
-  // copied to the field_data_taxonomyextra table rather than to the correct
-  // field_data_taxonomy_vocabulary_[vid] table. We'll move them.
-  $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE name = 'Analysis'")->fetchField();
-  if ($vid) {
-    try {
-      // first move from the field_data_taxonomyextra table
-      $sql = "
-        INSERT INTO {field_data_taxonomy_vocabulary_$vid}
-          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
-        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
-         FROM field_data_taxonomyextra
-         WHERE bundle = 'chado_feature')
-      ";
-      db_query($sql);
-      $sql = "DELETE FROM field_data_taxonomyextra WHERE bundle = 'chado_analysis'";
-      db_query($sql);
-
-      // next move from the field_revision_taxonomyextra table
-      $sql = "
-        INSERT INTO {field_revision_taxonomy_vocabulary_$vid}
-          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
-        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
-         FROM field_revision_taxonomyextra
-         WHERE bundle = 'chado_feature')
-      ";
-      db_query($sql);
-      $sql = "DELETE FROM field_revision_taxonomyextra WHERE bundle = 'chado_analysis'";
-      db_query($sql);
-    }
-    catch (\PDOException $e) {
-      $error = $e->getMessage();
-      throw new DrupalUpdateException('Could not move organism taxonomy terms: '. $error);
-    }
-  }
-}
-
-/**
- * Implementation of hook_update_dependencies().  It specifies a list of
- * other modules whose updates must be run prior to this one.
- */
-function tripal_analysis_update_dependencies() {
-  $dependencies = array();
-
-  // the tripal_cv update 7200 must run prior to update 7200 of this module
-  $dependencies['tripal_analysis'][7200] = array(
-    'tripal_cv' => 7200
-  );
-
-  return $dependencies;
-}
-
-/**
- * Fixes an error with the materialized view installation
- *
- */
-function tripal_analysis_update_7201() {
-
-  // there is a bug in the Tripal v2.0-alpha release that didn't add the
-  // materialized view schema to the mviews table.
-  // get the schema for the materialized view from the custom_tables table
-  // as there is a copy there, but only if the schema is missing from the
-  // materialized view table
-  $view_name = 'analysis_organism';
-  $schema = db_select('tripal_mviews', 'tm')
-    ->fields('tm', array('mv_schema'))
-    ->condition('name', $view_name)
-    ->execute()
-    ->fetchField();
-  if (!$schema or $schema == 'Array') {
-    $schema = db_select('tripal_custom_tables', 'tct')
-      ->fields('tct', array('schema'))
-      ->condition('table_name', $view_name)
-      ->execute()
-      ->fetchField();
-    $schema_str = var_export(unserialize($schema), TRUE);
-    $schema_str = preg_replace('/=>\s+\n\s+array/', '=> array', $schema_str);
-    db_update('tripal_mviews')
-      ->fields(array(
-        'mv_schema' => $schema_str
-      ))
-      ->condition('name', $view_name)
-      ->execute();
-  }
-}
+} */

+ 12 - 11
legacy/tripal_analysis/tripal_analysis.module

@@ -7,8 +7,6 @@
  * @ingroup tripal_analysis
  */
 
-require_once 'api/tripal_analysis.api.inc';
-require_once 'api/tripal_analysis.schema.api.inc';
 require_once 'api/tripal_analysis.DEPRECATED.inc';
 
 require_once 'includes/tripal_analysis.delete.inc';
@@ -42,9 +40,10 @@ function tripal_analysis_init() {
  * @ingroup tripal_analysis
  */
 function tripal_analysis_menu() {
-
+  $items = array();
   // Tripal Analysis administrative settings
-  $items['admin/tripal/chado/tripal_analysis'] = array(
+
+  $items['admin/tripal/legacy/tripal_analysis'] = array(
     'title' => 'Analyses',
     'description' => 'A bioinformatics analysis producing features.',
     'page callback' => 'tripal_analysis_admin_analysis_view',
@@ -52,7 +51,7 @@ function tripal_analysis_menu() {
     'type' => MENU_NORMAL_ITEM,
   );
 
-  $items['admin/tripal/chado/tripal_analysis/help'] = array(
+  $items['admin/tripal/legacy/tripal_analysis/help'] = array(
     'title' => 'Help',
     'description' => "A description of the Tripal Analysis module including a short description of it's usage.",
     'page callback' => 'theme',
@@ -62,7 +61,7 @@ function tripal_analysis_menu() {
     'weight' => 10,
   );
 
-  $items['admin/tripal/chado/tripal_analysis/configuration'] = array(
+  $items['admin/tripal/legacy/tripal_analysis/configuration'] = array(
     'title' => 'Settings',
     'description' => 'Settings for the displays of analysis results.',
     'page callback' => 'drupal_get_form',
@@ -72,7 +71,7 @@ function tripal_analysis_menu() {
     'weight' => 5
   );
 
-  $items['admin/tripal/chado/tripal_analysis/sync'] = array(
+  $items['admin/tripal/legacy/tripal_analysis/sync'] = array(
     'title' => ' Sync',
     'description' => 'Create pages on this site for analyses stored in Chado',
     'page callback' => 'drupal_get_form',
@@ -81,7 +80,7 @@ function tripal_analysis_menu() {
     'type' => MENU_LOCAL_TASK,
     'weight' => 1
   );
-  $items['admin/tripal/chado/tripal_analysis/delete'] = array(
+  $items['admin/tripal/legacy/tripal_analysis/delete'] = array(
       'title' => ' Delete',
       'description' => 'Delete multiple analyses from Chado',
       'page callback' => 'drupal_get_form',
@@ -92,7 +91,7 @@ function tripal_analysis_menu() {
       'file' =>  'includes/tripal_analysis.delete.inc',
       'weight' => 2
   );
-  $items['admin/tripal/chado/tripal_analysis/chado_analysis_toc'] = array(
+  $items['admin/tripal/legacy/tripal_analysis/chado_analysis_toc'] = array(
     'title' => ' TOC',
     'description' => 'Manage the table of contents for analysis nodes.',
     'page callback' => 'drupal_get_form',
@@ -103,7 +102,7 @@ function tripal_analysis_menu() {
     'file path' => drupal_get_path('module', 'tripal_core'),
     'weight' => 3
   );
-  
+
   return $items;
 }
 
@@ -146,6 +145,7 @@ function tripal_analysis_help ($path, $arg) {
  */
 function tripal_analysis_permission() {
   return array(
+    /*
     'access chado_analysis content' => array(
       'title' => t('View Analyses'),
       'description' => t('Allow users to view analysis pages.'),
@@ -166,6 +166,7 @@ function tripal_analysis_permission() {
       'title' => t('Administer Analyses'),
       'description' => t('Allow users to administer all analyses.'),
     ),
+    */
   );
 }
 
@@ -241,7 +242,7 @@ function tripal_analysis_form_alter(&$form, &$form_state, $form_id) {
   // turn of preview button for insert/updates
   if ($form_id == "chado_analysis_node_form") {
     $form['actions']['preview']['#access'] = FALSE;
-    
+
     //remove the body field
     unset($form['body']);
   }

+ 1 - 1
legacy/tripal_analysis/tripal_analysis.views_default.inc

@@ -263,7 +263,7 @@ function tripal_analysis_defaultvalue_admin_analysis() {
 
   /* Display: Page */
   $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->display->display_options['path'] = 'admin/tripal/chado/tripal_analysis/analysis';
+  $handler->display->display_options['path'] = 'admin/tripal/legacy/tripal_analysis/analysis';
   $handler->display->display_options['menu']['type'] = 'default tab';
   $handler->display->display_options['menu']['title'] = 'Analyses';
   $handler->display->display_options['menu']['weight'] = '-10';

+ 3 - 3
legacy/tripal_contact/includes/tripal_contact.admin.inc

@@ -20,8 +20,8 @@ function tripal_contact_admin_contact_view() {
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
-  $breadcrumb[] = l('Chado', 'admin/tripal/chado');
-  $breadcrumb[] = l('Contacts', 'admin/tripal/chado/tripal_contact');
+  $breadcrumb[] = l('Chado', 'admin/tripal/legacy');
+  $breadcrumb[] = l('Contacts', 'admin/tripal/legacy/tripal_contact');
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
@@ -35,7 +35,7 @@ function tripal_contact_admin_contact_view() {
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'enable the pertinent views</strong>:</p>';
     $output .= '<ul>';
-      $output .= '<li>'.l('Contacts View', 'admin/tripal/chado/tripal_contact/views/contacts/enable').'</li>';
+      $output .= '<li>'.l('Contacts View', 'admin/tripal/legacy/tripal_contact/views/contacts/enable').'</li>';
     $output .= '</ul>';
   }
 

+ 9 - 7
legacy/tripal_contact/includes/tripal_contact.chado_node.inc

@@ -317,7 +317,7 @@ function chado_contact_validate($node, $form, &$form_state) {
  *
  * @ingroup tripal_contact
  */
-function chado_contact_node_access($node, $op, $account ) {
+function tripal_contact_node_access($node, $op, $account ) {
 
   $node_type = $node;
   if (is_object($node)) {
@@ -611,12 +611,14 @@ function tripal_contact_node_view($node, $view_mode, $langcode) {
           '#tripal_toc_id'    => 'properties',
           '#tripal_toc_title' => 'Properties',
         );
-        $node->content['tripal_contact_publications'] = array(
-          '#theme' => 'tripal_contact_publications',
-          '#node' => $node,
-          '#tripal_toc_id'    => 'publications',
-          '#tripal_toc_title' => 'Publications',
-        );
+        if (module_exists('tripal_pub')) {
+          $node->content['tripal_contact_publications'] = array(
+            '#theme' => 'tripal_contact_publications',
+            '#node' => $node,
+            '#tripal_toc_id'    => 'publications',
+            '#tripal_toc_title' => 'Publications',
+          );
+        }
         $node->content['tripal_contact_relationships'] = array(
           '#theme' => 'tripal_contact_relationships',
           '#node' => $node,

+ 2 - 2
legacy/tripal_contact/tripal_contact.info

@@ -3,8 +3,8 @@ description = Supports the contact tables of Chado by providing pages for viewin
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-rc1
 
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_cv

+ 3 - 182
legacy/tripal_contact/tripal_contact.install

@@ -172,7 +172,8 @@ function tripal_contact_schema() {
  *
  * @ingroup tripal_contact
  */
-function tripal_contact_add_custom_tables(){
+// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
+/* function tripal_contact_add_custom_tables(){
   $schema = array (
     'table' => 'contactprop',
     'fields' => array (
@@ -232,184 +233,4 @@ function tripal_contact_add_custom_tables(){
     ),
   );
   chado_create_custom_table('contactprop', $schema, TRUE);
-}
-
-/**
- * This is the required update for tripal_contact when upgrading from Drupal core API 6.x.
- *
- */
-function tripal_contact_update_7200() {
-
-  // We cannot use the Tripal API calls in the 7200 update
-  // because during upgrade the tripal_core will be disabled
-
-  // add the contact_type CV
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'tripal_contact'")->fetchField();
-    if (!$cv_id) {
-      // add the vocabulary
-      $cv_id = db_insert('chado.cv')
-      ->fields(array(
-        'name' => 'tripal_contact',
-        'definition' => 'A heirarchical set of terms for describing a contact. It is intended to be used as the default vocabularies in Tripal for contact types and contact properties.'
-      ))
-      ->execute();
-    }
-    // make this CV the defaults for the contact properties and contact types
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-         'table_name' => 'contact',
-         'field_name' => 'type_id',
-         'cv_id' => $cv_id
-       ))
-      ->execute();
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-        'table_name' => 'contactprop',
-        'field_name' => 'type_id',
-        'cv_id' => $cv_id
-      ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add tripal_contact vocabulary: '. $error);
-  }
-
-
-  // add the contact_relationship CV
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'contact_relationship'")->fetchField();
-    if (!$cv_id) {
-      // add the vocabulary
-      $cv_id = db_insert('chado.cv')
-      ->fields(array(
-        'name' => 'contact_relationship',
-        'definition' => 'Contains types of relationships between contacts.'
-      ))
-      ->execute();
-    }
-    // add the default
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-        'table_name' => 'contact_relationship',
-        'field_name' => 'type_id',
-        'cv_id' => $cv_id
-        ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add contact_type vocabulary: '. $error);
-  }
-
-  // add the contact_type CV
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'contact_type'")->fetchField();
-    if (!$cv_id) {
-      // add the vocabulary
-      $cv_id = db_insert('chado.cv')
-      ->fields(array(
-        'name' => 'contact_type',
-        'definition' => 'Contains types of contacts. This can be used if the tripal_contact vocabulary (which is default for contacts in Tripal) is not desired.'
-      ))
-      ->execute();
-    }
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add contact_type vocabulary: '. $error);
-  }
-
-  // add the contact_property CV
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'contact_property'")->fetchField();
-    if (!$cv_id) {
-      // add the vocabulary
-      $cv_id = db_insert('chado.cv')
-      ->fields(array(
-        'name' => 'contact_property',
-        'definition' => 'Contains properties for contacts. This can be used if the tripal_contact vocabulary (which is default for contacts in Tripal) is not desired.'
-      ))
-      ->execute();
-    }
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add contact_property vocabulary: '. $error);
-  }
-}
-
-/**
- * Implementation of hook_update_dependencies().  It specifies a list of
- * other modules whose updates must be run prior to this one.
- */
-function tripal_contact_update_dependencies() {
-  $dependencies = array();
-
-  // the tripal_cv update 7200 must run prior to update 7200 of this module
-  $dependencies['tripal_contact'][7200] = array(
-    'tripal_cv' => 7200
-  );
-
-  return $dependencies;
-}
-
-/**
- * Adds missing foreign key constraints
- *
- */
-function tripal_contact_update_7201() {
-  // there was a bug in the function for creating a custom table that
-  // kept foreign key constraints from being added.  So, we need to add those
-  // to keep from error messages appear, we will drop the FK if it already
-  // exists and then re-add it.
-  try {
-    $fkey_exists = db_query('SELECT TRUE FROM pg_constraint WHERE conname = :constraint', array(':constraint' => 'contactprop_type_id_fkey'))->fetchField();
-    if ($fkey_exists) {
-      db_query('
-        ALTER TABLE chado.contactprop
-        DROP CONSTRAINT contactprop_type_id_fkey CASCADE
-      ');
-      db_query('
-        ALTER TABLE chado.contactprop
-        DROP CONSTRAINT contactprop_contact_id_fkey CASCADE
-      ');
-    }
-    db_query('
-      ALTER TABLE chado.contactprop
-      ADD CONSTRAINT contactprop_type_id_fkey
-      FOREIGN KEY (type_id) REFERENCES chado.cvterm (cvterm_id)
-      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
-    ');
-    db_query('
-      ALTER TABLE chado.contactprop
-      ADD CONSTRAINT contactprop_contact_id_fkey
-      FOREIGN KEY (contact_id) REFERENCES chado.contact (contact_id)
-      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
-    ');
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to update foriegn key: '. $error);
-  }
-}
-/**
- * Updates path of tripal_contact OBO to be relative.
- */
-function tripal_contact_update_7202() {
-  try {
-    // Remove duplicates.
-    db_delete('tripal_cv_obo')
-      ->condition('name', 'Tripal Contacts')
-      ->execute();
-
-    // Add in the updated path.
-    $obo_path = '{tripal_contact}/files/tcontact.obo';
-    $obo_id = tripal_insert_obo('Tripal Contacts', $obo_path);
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to update tripal_contact OBO path: '. $error);
-  }
-}
+} */

+ 9 - 7
legacy/tripal_contact/tripal_contact.module

@@ -14,7 +14,6 @@
  * @}
  */
 
-require_once 'api/tripal_contact.api.inc';
 require_once 'api/tripal_contact.DEPRECATED.inc';
 
 require_once 'theme/tripal_contact.theme.inc';
@@ -51,7 +50,7 @@ function tripal_contact_menu() {
 
   $items = array();
 
-  $items['admin/tripal/chado/tripal_contact']= array(
+  $items['admin/tripal/legacy/tripal_contact']= array(
     'title' => 'Contacts',
     'description' => ('Model persons, institutes, groups, organizations, etc.'),
     'page callback' => 'tripal_contact_admin_contact_view',
@@ -59,7 +58,7 @@ function tripal_contact_menu() {
     'type' => MENU_NORMAL_ITEM
   );
 
-  $items['admin/tripal/chado/tripal_contact/configuration'] = array(
+  $items['admin/tripal/legacy/tripal_contact/configuration'] = array(
     'title' => 'Settings',
     'description' => 'Integration of Chado contacts.',
     'page callback' => 'drupal_get_form',
@@ -69,7 +68,7 @@ function tripal_contact_menu() {
     'weight' => 5
   );
 
-  $items['admin/tripal/chado/tripal_contact/help']= array(
+  $items['admin/tripal/legacy/tripal_contact/help']= array(
     'title' => 'Help',
     'description' => ('Help with the contact module.'),
     'page callback' => 'theme',
@@ -79,7 +78,7 @@ function tripal_contact_menu() {
     'weight' => 10
   );
 
-  $items['admin/tripal/chado/tripal_contact/sync'] = array(
+  $items['admin/tripal/legacy/tripal_contact/sync'] = array(
     'title' => ' Sync',
     'description' => 'Sync contacts in Chado with Drupal',
     'page callback' => 'drupal_get_form',
@@ -90,7 +89,7 @@ function tripal_contact_menu() {
     'weight' => 0
   );
 
-  $items['admin/tripal/chado/tripal_contact/chado_contact_toc'] = array(
+  $items['admin/tripal/legacy/tripal_contact/chado_contact_toc'] = array(
     'title' => ' TOC',
     'description' => 'Manage the table of contents for contact nodes.',
     'page callback' => 'drupal_get_form',
@@ -102,12 +101,13 @@ function tripal_contact_menu() {
     'weight' => 3
   );
 
-  $items['admin/tripal/chado/tripal_contact/contact/auto_name/%'] = array(
+  $items['admin/tripal/legacy/tripal_contact/contact/auto_name/%'] = array(
     'page callback' => 'tripal_autocomplete_contact',
     'page arguments' => array(6),
     'access arguments' => array('administer tripal contact'),
     'type' => MENU_CALLBACK,
   );
+
   return $items;
 }
 
@@ -186,6 +186,7 @@ function tripal_contact_theme($existing, $type, $theme, $path) {
  */
 function tripal_contact_permission() {
   return array(
+    /*
     'access chado_contact content' => array(
       'title' => t('View Contacts'),
       'description' => t('Allow users to view contact pages.'),
@@ -206,6 +207,7 @@ function tripal_contact_permission() {
       'title' => t('Administer Contacts'),
       'description' => t('Allow users to administer all contacts.'),
     ),
+    */
   );
 }
 

+ 1 - 1
legacy/tripal_contact/tripal_contact.views_default.inc

@@ -270,7 +270,7 @@ function tripal_contact_defaultview_admin_contacts() {
 
   /* Display: Page */
   $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->display->display_options['path'] = 'admin/tripal/chado/tripal_contact/contacts';
+  $handler->display->display_options['path'] = 'admin/tripal/legacy/tripal_contact/contacts';
   $handler->display->display_options['menu']['type'] = 'default tab';
   $handler->display->display_options['menu']['title'] = 'Contacts';
   $handler->display->display_options['menu']['description'] = 'Contacts can be persons, institutes, groups, or organizations.';

+ 6 - 6
legacy/tripal_core/api/tripal_core.DEPRECATED.inc

@@ -794,7 +794,7 @@ function tripal_job_set_progress($job_id, $percentage) {
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
  * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_refresh_mview(),  and 
+ * This function has been replaced by tripal_refresh_mview(),  and
  * tripal_delete_mview().
  *
  * @see tripal_refresh_mview() or tripal_delete_mview().
@@ -897,7 +897,7 @@ function tripal_mviews_get_mview_id($view_name) {
       '%new_function' => 'tripal_get_mview_id'
     )
   );
-  
+
   //New API Function
   return tripal_get_mview_id($view_name);
 }
@@ -915,7 +915,7 @@ function tripal_core_delete_property_by_id($basetable, $property_id) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. This requires manual
-      intervention since the arguements for the two functions are different.
+      intervention since the arguments for the two functions are different.
       Please update your code.",
     array(
       '%old_function'=>'tripal_core_delete_property_by_id',
@@ -958,7 +958,7 @@ function tripal_core_delete_property($basetable, $record_id, $property, $cv_name
     'type_name' => $property,
     'cv_name' => $cv_name,
   );
-  
+
   //New API Function
   return chado_delete_property($record, $property);
 }
@@ -980,7 +980,7 @@ function tripal_core_get_property($basetable, $record_id, $property, $cv_name) {
       '%new_function' => 'chado_get_property'
     )
   );
-  
+
   $record = array(
     'table' => $basetable,
     'id' => $record_id
@@ -1101,7 +1101,7 @@ function tripal_core_update_property_by_id($basetable, $record_id, $property,
     'cv_name' => $cv_name,
     'value' => $value,
   );
-  
+
   // New API Function.
   return chado_update_property($record, $property);
 }

+ 23 - 22
legacy/tripal_core/api/tripal_core.chado_nodes.api.inc

@@ -354,9 +354,9 @@ function chado_add_node_form_subtable_ajax_update($form, &$form_state) {
     // the base specified in hook_node_info
     $node_type = 'chado_example';
 
-    // This menu item will be a tab on the admin/tripal/chado/tripal_example page
+    // This menu item will be a tab on the admin/tripal/legacy/tripal_example page
     // that is not selected by default
-    $items['admin/tripal/chado/tripal_example/sync'] = array(
+    $items['admin/tripal/legacy/tripal_example/sync'] = array(
       'title' => ' Sync',
       'description' => 'Sync examples from Chado with Drupal',
       'page callback' => 'drupal_get_form',
@@ -552,7 +552,7 @@ function chado_node_sync_form($form, &$form_state) {
       // yet been synced.
       $query = "SELECT " . implode(', ', $select) . ' ' .
                'FROM {' . $base_table . '} ' . $base_table . ' ' . implode(' ', $joins) . ' '.
-               "  LEFT JOIN public.$linking_table CT ON CT.$base_table_id = $base_table.$base_table_id " .
+               "  LEFT JOIN [" . $linking_table . "] CT ON CT.$base_table_id = $base_table.$base_table_id " .
                "WHERE CT.$base_table_id IS NULL";
 
       // extend the where clause if needed
@@ -862,7 +862,7 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
   $query = "
     SELECT " . implode(', ', $select) . ' ' .
     'FROM {' . $base_table . '} ' . $base_table . ' ' . implode(' ', $joins) . ' '.
-    "  LEFT JOIN public.$linking_table CT ON CT.$base_table_id = $base_table.$base_table_id " .
+    "  LEFT JOIN [" . $linking_table . "] CT ON CT.$base_table_id = $base_table.$base_table_id " .
     "WHERE CT.$base_table_id IS NULL ";
 
   // extend the where clause if needed
@@ -1000,7 +1000,9 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
  *
  * @ingroup tripal_chado_node_api
  */
-function chado_cleanup_orphaned_nodes($table, $nentries = 25000, $linking_table = NULL, $node_type = NULL, $job_id = NULL) {
+function chado_cleanup_orphaned_nodes($table, $nentries = 25000,
+    $linking_table = NULL, $node_type = NULL, $job_id = NULL) {
+
   // The max number of records either as nodes or linked records.
   $count = 0;
   // Will hold the number of nodes of this type.
@@ -1038,7 +1040,8 @@ function chado_cleanup_orphaned_nodes($table, $nentries = 25000, $linking_table
     $m = ceil($count / $nentries);
     for ($i = 0; $i < $m; $i++) {
       $offset = ($nentries * $i);
-      chado_cleanup_orphaned_nodes_part($table, $job_id, $nentries, $offset, $linking_table, $node_type);
+      chado_cleanup_orphaned_nodes_part($table, $job_id, $nentries, $offset,
+          $linking_table, $node_type);
     }
   }
   catch (Exception $e) {
@@ -1075,10 +1078,8 @@ function chado_cleanup_orphaned_nodes_part($table, $job_id = NULL, $nentries,
   $clsql= "
     SELECT *
     FROM {" . $linking_table . "} LT
-      INNER JOIN {node} N ON N.nid = LT.nid
-    WHERE N.type = :node_type
     ORDER BY LT.nid LIMIT $nentries OFFSET $offset";
-  $res = db_query($clsql, array(':node_type' => $node_type));
+  $res = db_query($clsql);
   foreach ($res as $node) {
     $cnodes[$count] = $node;
     $count++;
@@ -1093,40 +1094,40 @@ function chado_cleanup_orphaned_nodes_part($table, $job_id = NULL, $nentries,
     if ($interval < 1) {
       $interval = 1;
     }
-    foreach ($cnodes as $nid) {
+    foreach ($cnodes as $linker) {
       // Update the job status every 1% analyses
       if ($job_id and $i % $interval == 0) {
         $percent = sprintf("%.2f", ($i / $count) * 100);
         tripal_set_job_progress($job_id, intval($percent));
-        print "Percent complete: $percent%. Memory: " . number_format(memory_get_usage()) . " bytes.\r";
+        print "Percent complete: $percent%. Memory: " . number_format(memory_get_usage()) . " bytes.\n";
       }
 
       // See if the node exits, if not remove the entry from linking table table.
-      $nsql = "SELECT * FROM {node} WHERE nid = :nid";
-      $results = db_query($nsql, array(':nid' => $nid->nid));
+      $nsql = "SELECT * FROM {node} WHERE nid = :nid AND type = :node_type";
+      $results = db_query($nsql, array(':nid' => $linker->nid, ':node_type' => $node_type));
       $node = $results->fetchObject();
       if (!$node) {
         $deleted++;
-        db_query("DELETE FROM {" . $linking_table . "} WHERE nid = :nid", array(':nid' => $nid->nid));
-        //print "$linking_table missing node.... DELETING: $nid->nid\n";
+        db_query("DELETE FROM {" . $linking_table . "} WHERE nid = :nid", array(':nid' => $linker->nid));
+        //print "$linking_table missing node.... DELETING where nid=".$linker->nid." $linking_table entry.\n";
       }
 
       // Does record in chado exists, if not remove entry from $linking_table.
       $table_id = $table . "_id";
-      $lsql = "SELECT * FROM {" . $table . "} where " . $table . "_id = :" . $table . "_id";
-      $results = chado_query($lsql, array(":" . $table . "_id" => $nid->$table_id));
+      $lsql = "SELECT * FROM {" . $table . "} where " . $table_id . " = :chado_id";
+      $results = chado_query($lsql, array(":chado_id" => $linker->$table_id));
       $record = $results->fetchObject();
       if (!$record) {
         $deleted++;
-        $sql = "DELETE FROM {" . $linking_table . "} WHERE " . $table . "_id = :" . $table . "_id";
-        db_query($sql, array(":" . $table . "_id" => $nid->$table_id));
-        //print "$linking_table missing $table.... DELETING entry.\n";
+        $sql = "DELETE FROM {" . $linking_table . "} WHERE " . $table_id . " = :chado_id";
+        db_query($sql, array(":chado_id" => $linker->$table_id));
+        //print "$linking_table missing $table.... DELETING where $table_id=".$linker->$table_id." $linking_table entry.\n";
       }
       $i++;
     }
     $percent = sprintf("%.2f", ($i / $count) * 100);
     tripal_set_job_progress($job_id, intval($percent));
-    print "Percent complete: $percent%. Memory: " . number_format(memory_get_usage()) . " bytes.\r";
+    print "Percent complete: $percent%. Memory: " . number_format(memory_get_usage()) . " bytes.\n";
   }
   print "\nDeleted $deleted record(s) from $linking_table missing either a node or chado entry.\n";
 
@@ -1247,7 +1248,7 @@ function hook_chado_node_sync_form($form, &$form_state) {
  *
  * Allows you to use this function as your own submit.
  *
- * This might be necessary if you want to add additional arguements to the
+ * This might be necessary if you want to add additional arguments to the
  * tripal job or to call your own sync'ing function if the generic
  * chado_node_sync_records() is not sufficient.
  *

+ 14 - 14
legacy/tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc

@@ -142,7 +142,7 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
       $db_options[$db->db_id] = $db->name;
     }
   }
-  
+
   // Determine the node type using the name of the foreign key.
   $details['nodetype'] = str_replace('_id', '', $details['base_foreign_key']);
 
@@ -152,7 +152,7 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
     t('To add databases to the drop down list, you need to <a href="@dblink">add
       an external database reference</a>.',
       array(
-        '@dblink' => url('admin/tripal/chado/tripal_db/add')
+        '@dblink' => url('admin/tripal/legacy/tripal_db/add')
       )
     ),
     $importance,
@@ -170,18 +170,18 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
   );
 
   // the fieldset of the dbxref elements
-  $instructions = 'To add an external reference, select the database you want to reference from the 
-    drop-down below. Then enter the name/accession (as it is shown in the external database) of this 
-    particular %nodetype into the text box before clicking "Add". The version can be used to 
-    indicate the version of the external database or the version of the reference 
-    depending upon what is available. To remove incorrect references, click the 
-    "Remove" button. Note: you cannot edit previously added references but instead 
+  $instructions = 'To add an external reference, select the database you want to reference from the
+    drop-down below. Then enter the name/accession (as it is shown in the external database) of this
+    particular %nodetype into the text box before clicking "Add". The version can be used to
+    indicate the version of the external database or the version of the reference
+    depending upon what is available. To remove incorrect references, click the
+    "Remove" button. Note: you cannot edit previously added references but instead
     need to remove and re-add them.';
   $form['addtl_dbxrefs'] = array(
     '#type' => 'fieldset',
     '#title' => t($details['fieldset_title']),
-    '#description' => t('<p><strong>Indicate that this %nodetype either originates from 
-      or is present in another database.</strong></p><p>'. $instructions . $details['additional_instructions'] . '</p>', 
+    '#description' => t('<p><strong>Indicate that this %nodetype either originates from
+      or is present in another database.</strong></p><p>'. $instructions . $details['additional_instructions'] . '</p>',
       array('%nodetype' => $details['nodetype'])),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
@@ -235,11 +235,11 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
   else {
     $existing_dbxrefs = chado_query(
       "SELECT
-         db.name as db_name, 
+         db.name as db_name,
          db.db_id as db_id,
-         dbxref.dbxref_id, 
+         dbxref.dbxref_id,
          dbxref.accession as accession,
-         dbxref.description as description, 
+         dbxref.description as description,
          dbxref.version
        FROM {dbxref} dbxref
          LEFT JOIN {db} db ON db.db_id = dbxref.db_id
@@ -441,7 +441,7 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
  * @ingroup tripal_core
  */
 function chado_add_node_form_dbxrefs_add_button_validate($form, &$form_state) {
-  
+
   // Ensure the db_id is supplied & Valid
   $db = chado_select_record(
     'db',

+ 9 - 9
legacy/tripal_core/api/tripal_core.chado_nodes.properties.api.inc

@@ -293,7 +293,7 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
         to the %cv_name controlled vocabulary.',
         array(
           '%cv_name' => $details['cv_name'],
-          '@cvtermlink' => url('admin/tripal/vocab/cv/' . $details['cv_id'] . '/cvterm/add')
+          '@cvtermlink' => url('admin/tripal/loaders/chado_cv/' . $details['cv_id'] . '/cvterm/add')
         )
       ),
       TRIPAL_NOTICE,
@@ -306,7 +306,7 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
         a controlled vocabulary term</a> to the %cv_name controlled vocabulary.',
         array(
           '%cv_name' => $details['cv_name'],
-          '@cvtermlink' => url('admin/tripal/vocab/cv/' . $details['cv_id'] . '/cvterm/add')
+          '@cvtermlink' => url('admin/tripal/loaders/chado_cv/' . $details['cv_id'] . '/cvterm/add')
         )
       ),
       TRIPAL_INFO,
@@ -325,15 +325,15 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
   );
 
   // the fieldset of the property elements
-  $instructions = 'To add properties of the current %nodetype, select the type of 
-      information from the drop-down below and enter the information in the text box before 
-      clicking "Add". To remove incorrect information, click the "Remove" button. 
-      Note: you cannot edit previously added information but instead need to 
+  $instructions = 'To add properties of the current %nodetype, select the type of
+      information from the drop-down below and enter the information in the text box before
+      clicking "Add". To remove incorrect information, click the "Remove" button.
+      Note: you cannot edit previously added information but instead need to
       remove and re-add it.';
   $form['properties'] = array(
     '#type' => 'fieldset',
     '#title' => t($details['fieldset_title']),
-    '#description' => t('<p><strong>Additional information about a 
+    '#description' => t('<p><strong>Additional information about a
       %nodetype.</strong></p><p>'. $instructions . $details['additional_instructions'] . '</p>', array('%nodetype' => $details['nodetype'])) ,
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
@@ -363,7 +363,7 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
     '#type' => 'markup',
     '#prefix' => '<div id="property-save-warning" class="messages warning" style="display:none;">',
     '#suffix' => '</div>',
-    '#markup' => '* The changes to these properties will not be saved until the 
+    '#markup' => '* The changes to these properties will not be saved until the
       "Save" button at the bottom of this form is clicked. <span class="specific-changes"></span>',
     '#attached' => array(
       'js' => array(
@@ -649,7 +649,7 @@ function chado_add_node_form_properties(&$form, &$form_state, $details) {
  * @ingroup tripal_core
  */
 function chado_add_node_form_properties_add_button_validate($form, &$form_state) {
-  
+
   // Ensure the type_id is supplied & Valid
   $cvterm = chado_select_record(
     'cvterm',

+ 6 - 3
legacy/tripal_core/api/tripal_core.chado_nodes.relationships.api.inc

@@ -254,7 +254,7 @@ function chado_add_node_form_relationships(&$form, &$form_state, $details) {
         to the %cv_name controlled vocabulary.',
         array(
           '%cv_name' => $details['cv_name'],
-          '@cvtermlink' => url('admin/tripal/vocab/cv/'.$details['cv_id'].'/cvterm/add')
+          '@cvtermlink' => url('admin/tripal/loaders/chado_cv/'.$details['cv_id'].'/cvterm/add')
         )
       ),
       TRIPAL_WARNING,
@@ -267,7 +267,7 @@ function chado_add_node_form_relationships(&$form, &$form_state, $details) {
         a controlled vocabulary term</a> to the %cv_name controlled vocabulary.',
         array(
           '%cv_name' => $details['cv_name'],
-          '@cvtermlink' => url('admin/tripal/vocab/cv/' . $details['cv_id'] . '/cvterm/add')
+          '@cvtermlink' => url('admin/tripal/loaders/chado_cv/' . $details['cv_id'] . '/cvterm/add')
         )
       ),
       TRIPAL_INFO,
@@ -1046,7 +1046,10 @@ function chado_add_node_form_relationships_name_to_id_callback($base_table, $nam
 
   $base_key = $base_table.'_id';
 
-  $query = db_select('chado.'.$base_table, 'b')
+  // determine the chado schema.
+  $chado = tripal_get_schema_name('chado');
+
+  $query = db_select($chado . '.' . $base_table, 'b')
     ->fields('b', array($base_key, $name_field))
     ->condition($name_field, '%' . db_like($string) . '%', 'LIKE');
 

+ 121 - 11
legacy/tripal_core/api/tripal_core.chado_nodes.title_and_path.inc

@@ -1304,12 +1304,14 @@ function chado_node_generate_tokens($base_table, $token_prefix = FALSE, $locatio
  * @return
  *   The value of the token
  */
-function chado_get_token_value($token_info, $node) {
+function chado_get_token_value($token_info, $node, $options = array()) {
 
   $token = $token_info['token'];
   $table = $token_info['table'];
   $var = $node;
 
+  $supress_errors = (isset($options['supress_errors'])) ? $options['supress_errors'] : FALSE;
+
   // Iterate through each portion of the location string. An example string
   // might be:  stock > type_id > name.
   $location = explode('>', $token_info['location']);
@@ -1325,11 +1327,13 @@ function chado_get_token_value($token_info, $node) {
         $var = $var->$index;
       }
       else {
-        tripal_report_error('chado_node_api', TRIPAL_WARNING,
-          'Tokens: Unable to determine the value of %token. Things went awry when trying ' .
-          'to access \'%index\' for the following: \'%var\'.',
-          array('%token' => $token, '%index' => $index, '%var' => print_r($var,TRUE))
-        );
+        if (!$supress_errors) {
+          tripal_report_error('chado_node_api', TRIPAL_WARNING,
+            'Tokens: Unable to determine the value of %token. Things went awry when trying ' .
+            'to access \'%index\' for the following: \'%var\'.',
+            array('%token' => $token, '%index' => $index, '%var' => print_r($var,TRUE))
+          );
+        }
         return '';
       }
     }
@@ -1339,11 +1343,13 @@ function chado_get_token_value($token_info, $node) {
       $var = $var[$index];
     }
     else {
-      tripal_report_error('chado_node_api', TRIPAL_WARNING,
-        'Tokens: Unable to determine the value of %token. Things went awry when trying ' .
-        'to access \'%index\' for the following: \'%var\'.',
-        array('%token' => $token, '%index' => $index, '%var' => print_r($var,TRUE))
-      );
+      if (!$supress_errors) {
+        tripal_report_error('chado_node_api', TRIPAL_WARNING,
+          'Tokens: Unable to determine the value of %token. Things went awry when trying ' .
+          'to access \'%index\' for the following: \'%var\'.',
+          array('%token' => $token, '%index' => $index, '%var' => print_r($var,TRUE))
+        );
+      }
       return '';
     }
   }
@@ -1431,3 +1437,107 @@ function tripal_sort_key_length_asc($a, $b) {
     return -1;
   }
 }
+
+/**
+ * Generate a Readable but not necessarily unique format based on a given primary
+ * key token.
+ *
+ * For example, given the token [feature.type_id>cvterm.cvterm_id] you don't
+ * want the actual id indexed but instead would want the term name, [feature.type_id>cvterm.name]
+ */
+function chado_node_get_readable_format($token) {
+
+  // First, lets break down the token into it's parts.
+  // 1. Remove containing brackets.
+  $parts = str_replace(array('[',']'),'',$token);
+  // 2. Break into table clauses.
+  $parts = explode('>',$parts);
+  // 3. Break each table clause into table & field.
+  foreach ($parts as $k => $v) {
+    $parts[$k] = explode('.', $v);
+    if (sizeof($parts[$k]) == 1) {
+      $parts[$k] = explode(':', $v);
+    }
+  }
+  $last_k = $k;
+
+  // Now, we want to find readable fields for the last table specified in the token.
+  // (ie: for cvterm in [feature.type_id>cvterm.cvterm_id])
+  $table = $parts[$last_k][0];
+  $format = array();
+  if ($table == 'organism') {
+    $format[] = preg_replace('/(\w+)\]$/', 'genus]', $token);
+    $format[] = preg_replace('/(\w+)\]$/', 'species]', $token);
+    $format[] = preg_replace('/(\w+)\]$/', 'common_name]', $token);
+    $format = $format[0] . ' ' . $format[1] . ' (' . $format[2] . ')';
+   }
+   elseif ($table == 'dbxref') {
+     $format[] = preg_replace('/(\w+)\]$/', 'accession]', $token);
+     $format[] = preg_replace('/(\w+)\]$/', 'db_id>db.name]', $token);
+     $format = $format[0] . ' (' . $format[1] . ')';
+   }
+   else {
+     $schema = chado_get_schema($table);
+     foreach ($schema['fields'] as $field_name => $details) {
+       if (preg_match('/name/',$field_name)) {
+         $format[] = preg_replace('/(\w+)\]$/', $field_name.']', $token);
+       }
+     }
+     $format = implode(', ',$format);
+   }
+   if (empty($format)) {
+     return FALSE;
+   }
+   return $format;
+ }
+
+ /**
+  * Returns the "location" as specified in the token information based on the
+  * token.
+  */
+ function chado_node_get_location_from_token($token) {
+
+   if (is_array($token) and isset($token['location'])) {
+     return $token['location'];
+   }
+   // If we have been given the token as a string, we can still determine the location
+   // but it takes more work...
+   // First, lets clarify what the location is: the location shows which keys in which
+   // order need to be travelled in order to access the value. For example, the token
+   // [feature.organism_id>organism.genus] would have a location of
+   // feature > organism_id > genus to show that the value is at
+   // $node->feature->organism->genus.
+   elseif (is_string($token)) {
+
+     // First, lets break down the token into it's parts.
+     // 1. Remove containing brackets.
+     $parts = str_replace(array('[',']'),'',$token);
+     // 2. Break into table clauses.
+     $parts = explode('>',$parts);
+     // 3. Break each table clause into table & field.
+     foreach ($parts as $k => $v) {
+       $parts[$k] = explode('.', $v);
+       if (sizeof($parts[$k]) == 1) {
+         $parts[$k] = explode(':', $v);
+       }
+     }
+
+     // This is a base level field that is not a foreign key.
+     if (sizeof($parts) == 1 AND sizeof($parts[0]) == 2) {
+       return $parts[0][0] . ' > ' . $parts[0][1];
+     }
+     // Darn, we have at least one foreign key...
+     elseif (sizeof($parts) > 1 AND sizeof($parts[0]) == 2) {
+       $location = $parts[0][0] . ' > ' . $parts[0][1];
+       foreach ($parts as $k => $p) {
+         if ($k != 0 AND isset($p[1])) {
+           $location .= ' > ' . $p[1];
+         }
+       }
+       return $location;
+     }
+     else {
+       return FALSE;
+     }
+   }
+ }

+ 2 - 2
legacy/tripal_core/includes/tripal_core.form_elements.inc

@@ -177,7 +177,7 @@ function expand_sequence_combo($element, $form_state, $complete_form) {
   $element['upstream'] = array(
      '#type' => 'textfield',
      '#title' => t('Get Upstream Bases'),
-     '#description' => t('Specify the number of upstream bases to include in the sequnce'),
+     '#description' => t('Specify the number of upstream bases to include in the sequence'),
      '#default_value' => $element['#value']['upstream'],
   );
   // add the downstream box
@@ -187,7 +187,7 @@ function expand_sequence_combo($element, $form_state, $complete_form) {
      '#type' => 'textfield',
      '#prefix' => '<br>',
      '#title' => t('Get Downstream Bases'),
-     '#description' => t('Specify the number of downstream bases to include in the sequnce'),
+     '#description' => t('Specify the number of downstream bases to include in the sequence'),
      '#default_value' => $element['#value']['downstream'],
   );
   return $element;

+ 439 - 0
legacy/tripal_core/includes/tripal_core.search.inc

@@ -0,0 +1,439 @@
+<?php
+/**
+ * @file
+ * Adds support for Drupal indexing of Chado.
+ * It's important to note that not all of Chado is indexed but instead
+ * Only fields indicated in hook_search_include_chado_fields().
+ */
+
+/**
+ * Implements hook_search_include_chado_fields().
+ *
+ * This hook allows Tripal Admin/modules to specify which chado fields should be indexed
+ * for searching in a simple manner.
+ *
+ * @return
+ *   An array of chado fields you would like available for indexing. Each element should
+ *   be the name of the table followed by the field and separated by a period. For example.
+ *   feature.uniquename to indicate the uniquename field from the feature table.
+ */
+function tripal_core_search_include_chado_fields() {
+  return array(
+    'organism.genus',
+    'organism.species',
+  );
+}
+
+/**
+ * Implements hook_entity_property_info_alter().
+ *
+ * This is where we actually add the properties to the node entity in order to indicate
+ * which chado fields should be indexed.
+ */
+function tripal_core_entity_property_info_alter(&$info) {
+
+  // We provide a hook to allow Tripal admin to easily add fields to the search api.
+  // We want to invoke all implementations of that hook now for use below.
+  $fields_to_include = module_invoke_all('search_include_chado_fields');
+  $fields_to_include = array_unique($fields_to_include);
+
+  // Retrieve information for all nodes.
+  // We focus on nodes at this point because we need to link search results back to
+  // the entity and we have no entites for non-node chado content in Tripal2.
+  $node_info = module_invoke_all('node_info');
+
+  foreach ($node_info as $n) {
+
+    // Now keep in mind this hook is defined for ALL THE NODE TYPES and we only want
+    // to add extra support for chado so we onle care about chado node types.
+    // We can distinguish chado node types from all others by the existence of
+    // the 'chado_node_api' key which is used for all sorts of beautiful tripal/chado
+    // node integration (ie: adding properties, relationships and dbxrefs to node forms).
+    if (isset($n['chado_node_api'])) {
+      $schema = chado_get_schema($n['chado_node_api']['base_table']);
+
+      // Now we are going to start by adding some defaults. It feels safe to say, we
+      // probably want to index all the "names" so we are going to look through
+      // all the fields and if they contain "name" we are going to add them automatically.
+      foreach ($schema['fields'] as $field_name => $details) {
+
+        $machine_name = $n['chado_node_api']['base_table'] . '.' . $field_name;
+
+        // Try to create a readable label.
+        $label = ucwords(str_replace(array('.','_'),' ',$machine_name));
+
+        // We want to add all name fields and any fields previously indicated to be indexed.
+        if (preg_match('/name/', $field_name) OR in_array($machine_name, $fields_to_include)) {
+
+          if (!isset($info['node']['bundles'][ $n['base'] ]['properties'][$machine_name])) {
+            $info['node']['bundles'][ $n['base'] ]['properties'][$machine_name] = array(
+              'label' => $label,
+              'description' => (isset($details['description'])) ? $details['description'] : '',
+              'type' => ($details['type'] == 'varchar') ? 'text' : $details['type'],
+              'schema field' => '[' . $machine_name . ']',
+              // The following getter callback is a generic function that can retrieve
+              // values for any chado field.
+              'getter callback' => 'tripal_search_chado_token_getter_callback'
+            );
+          }
+        }
+      }
+
+      // We want to add any base foreign keys. This allows you to search for all features
+      // from a given organism. Furthermore, we want to add a single field for each foreign
+      // key that will span content types in order to be exposed as facets.
+      foreach ($schema['foreign keys'] as $table => $fk_details) {
+        foreach ($fk_details['columns'] as $left_field => $right_field) {
+
+          $machine_name = $n['chado_node_api']['base_table'] . '.' . $left_field;
+          $field_details = $schema['fields'][$left_field];
+
+          // Try to create a readable label.
+          $label = $table . ' (' . $machine_name . ')';
+          if (preg_match('/(\w+)_id/',$left_field,$matches)) {
+            // Key only field.
+            $key_label = ucwords(str_replace('_', ' ', $matches[1]));
+
+            // Expanded field.
+            $label = str_replace('_', ' ', $n['chado_node_api']['base_table']);
+            $label .= ' ' . str_replace('_', ' ', $matches[1]);
+            $label = ucwords($label);
+          }
+
+          $keytoken = '[BASE.' . $left_field . '>' . $table . '.' . $right_field . ']';
+          $format = chado_node_get_readable_format($keytoken);
+
+          // First, create the key version. This is best used for facets since it
+          // won't/can't be tokenized along with the other fields. This will be shared
+          // among node types to facillitate use as a facet.
+          $info['node']['properties'][$table . '.' . $right_field .' key'] = array(
+            'label' => $key_label . ' (All Content Types)',
+            'description' => (isset($field_details['description'])) ? $field_details['description'] : '',
+            'type' => 'text',
+            // We include both the token for the current node type and the token for
+            // the parent table. That way the organism node will appear in the results
+            // for the organism key.
+            'schema field' => $format,
+            // The following getter callback is a generic function that can retrieve
+            // values for any chado foreign key.
+            'getter callback' => 'tripal_search_chado_token_across_nodetypes_getter_callback'
+          );
+
+          $pretoken = '[' . $n['chado_node_api']['base_table'] . '.' . $left_field . '>' . $table . '.' . $right_field . ']';
+          $format = chado_node_get_readable_format($pretoken);
+
+          // Add a more readable version that will be tokenized so users can
+          // search for fruitfly and get all features with that as an organism.
+          $info['node']['bundles'][ $n['base'] ]['properties'][$machine_name .' expanded'] = array(
+            'label' => $label . ' (Expanded)',
+            'description' => (isset($field_details['description'])) ? $field_details['description'] : '',
+            'type' => 'text',
+            'schema field' => $format,
+            // The following getter callback is a generic function that can retrieve
+            // values for any chado foreign key.
+            'getter callback' => 'tripal_search_chado_token_getter_callback'
+          );
+        }
+      }
+    }
+  }
+
+  // Provide our own hook for altering properties to make it easier for our users.
+  drupal_alter('tripal_search_properties', $info);
+}
+
+/**
+ * Allows tripal admin to alter entity property information after it has. This is currently
+ * being used to indicate chado fields to be indexed for search.
+ *
+ * NOTE: If you simply need to add a field to be indexed, use hook_search_include_chado_fields()
+ * which provides the much easier method of simply listing fields to include.
+ *
+ * This function is most useful if you want to change the way the value is retrieved
+ * (done by changing the 'getter callback') or add your own custom computed field.
+ */
+function hook_tripal_search_properties_alter(&$info) { }
+
+/**
+ * Implements a getter callback for chado token formats.
+ *
+ * A chado token format is a string containing chado tokens.
+ *
+ * Chado tokens are expected to follow the format of tokens auto-generated using
+ *   chado_node_generate_tokens(). For example, [feature.uniquename] indicates you
+ *   should return the uniquename of a feature node and [feature.organism_id>organism.species]
+ *   indicates you should return the organism genus of the feature node.
+ *
+ * The chado token format must be stored in the 'schema field' when defining the property in
+ *  hook_entity_property_info() in order for this getter to work.
+ *
+ * @param $data
+ *   The entity object (in our case the node we need to retrieve feature properties for).
+ * @param $options
+ * @param $field_name
+ *   The machine name for the entity property.
+ * @param $info
+ *   The full property definition from entity property info.
+ *
+ * @return
+ *   A string representing the "value" of the field.
+ */
+function tripal_search_chado_token_getter_callback($data, $options, $field_name, $type, $info) {
+
+  if (isset($data->nid)) {
+    if (isset($info['schema field'])) {
+      $format = $info['schema field'];
+
+      // Determine our base table so we know if this is even the right node type.
+      if (preg_match('/\[(\w+)\.(\w+)/',$format, $matches)) {
+        $base_table = $matches[1];
+        $field_name = $matches[2];
+
+        // For some weird reason nodes of all types are trying to get a value for fields
+        // that we defined as specific to a given node type (ie: bundle). As such we need
+        // this check here to ensure this field is actually for this node type.
+        if (!isset($data->{$base_table})) return NULL;
+
+        $format = tripal_core_get_token_value_for_property($base_table, $field_name, $format, $data, $info);
+        return $format;
+      }
+      else {
+        // Not able to determine table?
+        tripal_report_error(
+          'tripal_search',
+          TRIPAL_ERROR,
+          'Unable to extract the base table from the format (:format) for :field because it didn\'t match the expected format: [tablename.field...',
+          array(':field' => $field_name, ':format' => $format)
+        );
+        return NULL;
+      }
+    }
+    else {
+      tripal_report_error(
+        'tripal_search',
+        TRIPAL_ERROR,
+        'Unable to get value for :field because the schema field was not set.',
+        array(':field' => $field_name)
+      );
+      return NULL;
+    }
+  }
+}
+
+/**
+ * Implements a getter callback for foreign keys collon between content types.
+ *
+ * @param $data
+ *   The entity object (in our case the node we need to retrieve feature properties for).
+ * @param $options
+ * @param $field_name
+ *   The machine name for the entity property.
+ * @param $info
+ *   The full property definition from entity property info.
+ *
+ * @return
+ *   A string representing the "value" of the field.
+ */
+function tripal_search_chado_token_across_nodetypes_getter_callback($data, $options, $field_name, $type, $info) {
+
+  // First, make sure this is a chado node.
+  // Assumption #1: All chado node types are prefixed with chado_
+  if (isset($data->nid)) {
+    if (preg_match('/^chado_(\w+)/',$data->type,$matches)) {
+      if (isset($info['schema field'])) {
+
+        // Assumption #2: The base table is the suffix of the node type.
+        $base_table = $matches[1];
+
+        // Substitute in the  base table for "BASE" in the schema field.
+        $format = str_replace('BASE', $base_table, $info['schema field']);
+
+        // Replace all tokens for values and return the result.
+        $format = tripal_core_get_token_value_for_property($base_table, $field_name, $format, $data, $info);
+        return $format;
+      }
+      else {
+        // Not able to determine table?
+        tripal_report_error(
+          'tripal_search',
+          TRIPAL_ERROR,
+          'Unable to extract the base table from the format (:format) for :field because it didn\'t match the expected format: [tablename.field...',
+          array(':field' => $field_name, ':format' => $format)
+        );
+      }
+    }
+    else {
+      tripal_report_error(
+        'tripal_search',
+        TRIPAL_ERROR,
+        'Unable to get value for :field because the schema field was not set.',
+        array(':field' => $field_name)
+      );
+    }
+  }
+
+  return NULL;
+}
+
+/**
+ * Retrieve values for all tokens for an entity property getter function.
+ */
+function tripal_core_get_token_value_for_property($base_table, $field_name, $format, $data, $info) {
+
+  // Determine which tokens were used in the format string
+  if (preg_match_all('/\[[^]]+\]/', $format, $used_tokens)) {
+    $used_tokens = $used_tokens[0];
+
+    // If there are no tokens then return the format as is...
+    if (empty($used_tokens)) {
+      tripal_report_error(
+        'tripal_search',
+        TRIPAL_NOTICE,
+        'Returned static text for :field since there were no tokens in the supplied format: :format',
+        array(':field' => $field_name, ':format' => $format)
+      );
+      return $format;
+    }
+
+    // Get the value of each token.
+    $null_tokens = array();
+    foreach ($used_tokens as $token) {
+      $token_info = array(
+          'name' => $info['label'],
+          'table' => $base_table,
+          'field' => $field_name,
+          'token' => $token,
+          'description' => $info['description'],
+          'location' => chado_node_get_location_from_token($token),
+      );
+
+      $value = chado_get_token_value($token_info, $data, array('supress_errors' => TRUE));
+      if (empty($value)) $null_tokens[] = $token;
+
+      // And sub it in to the format.
+      $format = str_replace($token, $value, $format);
+    }
+
+    // If none of the tokens had values then this node doesn't have this field.
+    // As such we return null so the search api doesn't bother indexing an empty format.
+    if (sizeof($used_tokens) == sizeof($null_tokens)) return NULL;
+  }
+  else {
+    tripal_report_error(
+      'tripal_search',
+      TRIPAL_NOTICE,
+      'Returned static text for :field since there were no tokens of a recognized format in the supplied format: :format',
+      array(':field' => $field_name, ':format' => $format)
+    );
+  }
+
+  return $format;
+}
+
+/**
+ * Implements hook_modules_enabled().
+ *
+ * This hook is called when ANY module is enabled. This allows us to update the
+ * the search api "Default node index" when any Tripal module is enabled thus allowing us
+ * to catch new node types right after they're created.
+ */
+function tripal_core_modules_enabled($modules) {
+  if (module_exists('search_api')) {
+    $index_enabled = db_query('SELECT enabled FROM search_api_index WHERE machine_name=:name', array(':name' => 'default_node_index'))->fetchField();
+    if ($index_enabled) {
+      tripal_search_update_default_index();
+    }
+  }
+}
+
+/**
+ * The Search API provides a default node index which has a number of
+ * node-specific fields enabled by default. We want to ensure our
+ * chado fields are also enabled by default thus making for easier
+ * enabling of Tripal search.
+ *
+ * This function should be called whenever new nodes might have been
+ * added to ensure that their fields are added as well.
+ *
+ * We should only modify the default node index if it has no database service yet.
+ * That way we ensure we don't override user changes!
+ */
+function tripal_search_update_default_index() {
+
+  // First we need the index object for the "Default node index".
+  $index_id = db_query('SELECT id FROM search_api_index WHERE machine_name=:name',
+    array(':name' => 'default_node_index'))->fetchField();
+  if (!$index_id) {
+    // ERROR
+    return FALSE;
+  }
+  $index = search_api_index_load($index_id);
+
+  // Collect all the fields already added to the search index.
+  $changes = array('options' => $index->options);
+
+  // Now we only want to update the index if it's both enabled and has no server indicated.
+  // That way we can be reasonably sure that it was been untouched by admin users.
+  if ($index->enabled == FALSE AND $index->server == NULL) {
+
+    // We need information about all the fields available to nodes before we can
+    // go crazy enabling them... That information is stored as properties of nodes
+    // so we'll grab that.
+    $info = entity_get_property_info('node');
+
+    // Now we want to loop through each node type and add all the properties for the
+    // chado node types.
+    // Assumption #1: We are assuming that all chado node types are prefixed 'chado_'.
+    foreach ($info['bundles'] as $node_type => $details) {
+      if (preg_match('/^chado_/', $node_type)) {
+
+        // Now add each chado fields to the index but only if they are not already added.
+        foreach ($details['properties'] as $field_name => $field_details) {
+          if (!isset($changes['options']['fields'][$field_name])) {
+            $changes['options']['fields'][$field_name]['type'] = ($field_details['type'] == 'varchar') ? 'text' : $field_details['type'];
+
+            // Furthermore if this is a name then we want to add a boost to ensure it carries
+            // more weight in the search results.
+            if (preg_match('/name/',$field_name)) {
+              $changes['options']['fields'][$field_name]['boost'] = '3.0';
+            }
+          }
+        }
+
+      }
+    }
+
+    // We also want to enable highlighting to ensure an excerpt is generated since this
+    // will be used in the default search view distributed with Tripal.
+    if (!isset($index->options['processors']['search_api_highlighting'])) {
+      $changes['options']['processors']['search_api_highlighting'] = array(
+        'status' => 1,
+        'weight' => 35,
+        'settings' => array(
+          'prefix' => '<strong>',
+          'suffix' => '</strong>',
+          'excerpt' => 1,
+          'excerpt_length' => 256,
+          'exclude_fields' => array(),
+          'highlight' => 'always',
+        ),
+      );
+    }
+    else {
+      $changes['options']['processors']['search_api_highlighting']['status'] = 1;
+      $changes['options']['processors']['search_api_highlighting']['settings']['excerpt'] = 1;
+    }
+
+    // Finally we save all of our changes :-).
+    search_api_index_edit($index_id, $changes);
+    drupal_set_message('The Search API "Default Node Index" was updated.');
+  }
+  else {
+    tripal_report_error(
+      'tripal_search',
+      TRIPAL_NOTICE,
+      'The Search API "Default Node Index" was not updated with Tripal Fields. If you would like to enable more Tripal/Chado fields to be indexed, edit the Field Listing for the "Default Node Index" now.'
+    );
+  }
+}
+

+ 79 - 60
legacy/tripal_core/includes/tripal_core.toc.inc

@@ -1,16 +1,16 @@
 <?php
 
 /**
- * 
+ *
  */
 function tripal_core_node_toc_form($form, &$form_state, $node) {
-  
+
   // Get info about this content type
   $all_types = node_type_get_types();
   $type_info = $all_types[$node->type];
-  
+
   $form["#tree"] = TRUE;
-  
+
   $form["instructions"] = array(
     '#type' => 'fieldset',
     '#collapsed' => TRUE,
@@ -18,28 +18,28 @@ function tripal_core_node_toc_form($form, &$form_state, $node) {
     '#title' => 'Instructions',
   );
   $admin_link = l(
-    $type_info->name . " TOC administrative page", 
-    "admin/tripal/chado/" . $type_info->module . "/" . $node->type . "toc",
+    $type_info->name . " TOC administrative page",
+    "admin/tripal/legacy/" . $type_info->module . "/" . $node->type . "toc",
     array('attributes' => array('target' => '_blank'))
   );
   $form["instructions"]["main"] = array(
     '#markup' => '<p>' . t("Below is a list of the titles of
-      content panes that can appear on this page.  These titles appear in the 
-      the following order in the Table of Contents (TOC). You may rename 
+      content panes that can appear on this page.  These titles appear in the
+      the following order in the Table of Contents (TOC). You may rename
       the titles or drag and drop them to change the order.  <b>Any changes will
       only apply to this page</b>. If you would like to make changes apply to multiple
-      pages of the same tpye, please visit the $admin_link. ") . '</p>' .
+      pages of the same type, please visit the $admin_link. ") . '</p>' .
       '<p>' . t('The list below shows all possible content panes that can appear.
-      However, those without content are automatically hidden and do not 
+      However, those without content are automatically hidden and do not
       appear in the TOC.' . '</p>'),
   );
-  
+
   $form['node'] = array(
     '#type' => 'value',
     '#value' => $node,
   );
-  
-  // Get the content array for this node, then pass it through the 
+
+  // Get the content array for this node, then pass it through the
   // tripal_core_node_view_alter which generates the TOC.  After that
   // we can use the $build array to build the form. We have to add
   // a 'tripal_toc_mode' to the $node because we need to give the mode
@@ -91,7 +91,7 @@ function tripal_core_node_toc_form($form, &$form_state, $node) {
     }
   }
   $form['toc_items']['#theme'] = 'tripal_node_toc_items_table';
-  
+
   $form['submit'] = array(
     '#type' => 'submit',
     '#name' => 'toc_submit',
@@ -102,11 +102,11 @@ function tripal_core_node_toc_form($form, &$form_state, $node) {
     '#name' => 'toc_unset',
     '#value' => t('Unset Node Customizations'),
   );
-  
+
   // Check to see if this node's TOC is specifically being managed.
   $sql = "SELECT count(*) FROM {tripal_toc} where nid = :nid";
   $managed_items = db_query($sql, array(':nid' => $node->nid))->fetchField();
-  
+
   if ($managed_items > 0) {
     $form['is_managed'] = array(
       '#markup' => '<p><font color="red">' .
@@ -116,12 +116,12 @@ function tripal_core_node_toc_form($form, &$form_state, $node) {
         customizations and default to the content type settings.') . '</p>',
     );
   }
-  
-  
+
+
   return $form;
 }
 /**
- * 
+ *
  * @param $variables
  */
 function theme_tripal_node_toc_items_table($variables) {
@@ -137,7 +137,7 @@ function theme_tripal_node_toc_items_table($variables) {
 
   // Build the table header.
   $headers = array('Content Pane Name', 'Hide', 'Weight');
-  
+
   // Format the form elements as rows in the table.
   $rows = array();
   foreach ($toc_items as $key => $item) {
@@ -150,7 +150,7 @@ function theme_tripal_node_toc_items_table($variables) {
       'class' => array('draggable'),
     );
   }
-  
+
   // Theme and return the table.
   $table = array(
     'header' => $headers,
@@ -166,7 +166,7 @@ function theme_tripal_node_toc_items_table($variables) {
 }
 
 /**
- * 
+ *
  * @param $a
  * @param $b
  */
@@ -202,16 +202,16 @@ function tripal_core_node_toc_form_validate($form, &$form_state) {
 function tripal_core_node_toc_form_submit($form, &$form_state) {
   $toc_items = $form_state['values']['toc_items'];
   $node      = $form_state['values']['node'];
-  
-  if ($form_state['clicked_button']['#name'] == "toc_submit") { 
+
+  if ($form_state['clicked_button']['#name'] == "toc_submit") {
     $transaction = db_transaction();
     try {
       // First delete any settings for this node
       db_delete('tripal_toc')
         ->condition('nid', $node->nid)
         ->execute();
-  
-      // Second add in any new settings for this node 
+
+      // Second add in any new settings for this node
       foreach ($toc_items as $toc_id => $item) {
         db_insert('tripal_toc')
           ->fields(array(
@@ -250,7 +250,7 @@ function tripal_core_node_toc_form_submit($form, &$form_state) {
 
 /**
  * To be called by tripal_core_node_view_alter() to generate the TOC.
- * 
+ *
  * @param $build
  *   The build array passed to hook_node_view_alter()
  *
@@ -262,10 +262,10 @@ function tripal_core_node_view_build_toc(&$build) {
   if ($build['#view_mode'] != 'full' OR !array_key_exists('#tripal_generic_node_template', $build)) {
     return;
   }
-  
+
   $node_type = $build["#node"]->type;
   $nid = $build["#node"]->nid;
-  
+
   // The mode alters the format of the build array. There are three types of
   // modes: "display", "manage_node", "manage_type".  If "display" is provided
   // then the build array is formatted for the display of the content.
@@ -277,29 +277,29 @@ function tripal_core_node_view_build_toc(&$build) {
   // specific nodes and therefore should not be used when managing the
   // TOC for a content type.
   $mode = isset($build["#node"]->tripal_toc_mode) ? $build["#node"]->tripal_toc_mode : "display";
-  
-  
+
+
   $cache = cache_get("theme_registry:$theme", 'cache');
   $node = $build['#node'];
   $toc = array();
   $toc_html = '';
-  
+
   // If we are looking at a Tripal node template then we want to
   // make some changes to each pane of content so that we can associate
   // a table of contents and add administrator and curator messages.
   if ($build['#tripal_generic_node_template'] == TRUE) {
-  
+
     // Iterate through all the elements of the $build array and for those
     // that are wanting to provide content for this node.
     $markup = array();
     foreach ($build as $key => $value) {
       $value = $build[$key];
-      
+
       // Skip the body element as the Tripal node types do not use it.
       if ($key == 'body') {
         continue;
       }
-  
+
       // Skip the table of contents and links as those will be placed elsewhere.
       if (preg_match('/^#/', $key) or $key == 'tripal_toc' or $key == 'links') {
         continue;
@@ -337,6 +337,24 @@ function tripal_core_node_view_build_toc(&$build) {
             continue;
           }
 
+          // This field supports tokens, so we need to perform the substitutions
+          // if one is needed. Get the tokens and format
+          $base_table = preg_replace('/^chado_(.*)$/', '\1', $node_type);
+          $tokens = chado_node_generate_tokens($base_table);
+          $markup = $element['#markup'];
+          // Determine which tokens were used in the format string
+          if (preg_match_all('/\[[^]]+\]/', $markup, $used_tokens)) {
+            // Get the value for each token used
+            foreach ($used_tokens[0] as $token) {
+              $token_info = $tokens[$token];
+              if (!empty($token_info)) {
+                $value = chado_get_token_value($token_info, $node);
+                $markup = str_replace($token, $value, $markup);
+              }
+            }
+            $element['#markup'] = $markup;
+          }
+
           // Add the link to the TOC
           $parts = explode("|", $element['#markup']);
           if (count($parts) == 2) {
@@ -346,7 +364,7 @@ function tripal_core_node_view_build_toc(&$build) {
             $toc[$weight][$parts[0]] = "<div id=\"$toc_item_id\" class=\"tripal_toc_list_item\">" . $element['#markup'] . "</div>";
           }
 
-          // Add to the build array but do not add markup. This way 
+          // Add to the build array but do not add markup. This way
           // when the TOC is managed by the node 'TOC' menu these links can
           // be ordered as well.
           $build[$toc_item_id]['#toc_handled'] = TRUE;
@@ -414,7 +432,7 @@ function tripal_core_node_view_build_toc(&$build) {
         unset($build["field_resource_titles"]);
         continue;
       } // end if ($mode != "manage_type" and $key == "field_resource_blocks") {
-  
+
       // Skip any keys we may have already handled. This is the case for
       // the field_resource_blocks where we removed the old CCK fields
       // and added new ones.  We don't want these new ones to be processed
@@ -449,11 +467,11 @@ function tripal_core_node_view_build_toc(&$build) {
       if (array_key_exists('#tripal_toc_id', $build[$key])) {
         $toc_item_id = $build[$key]['#tripal_toc_id'];
       }
-      
+
       // Get any overrides for this key.
       $overrides = tripal_core_get_toc_overrides($nid, $toc_item_id, $node_type, $mode);
 
-      
+
       // If the element should be hidden then unset this key the build
       // array continue to the next one
       if ($mode == "display" and $overrides['hide'] == 1) {
@@ -472,7 +490,7 @@ function tripal_core_node_view_build_toc(&$build) {
       // GET THE MARKUP FOR EACH ELEMENT
       //-----------------------
       $markup = '';
-  
+
       // find the markup. Some fields will have a '#markup' and others, such
       // as CCK elements may have a set of '#markup' elements organized by
       // numerical keys.
@@ -497,13 +515,13 @@ function tripal_core_node_view_build_toc(&$build) {
         '#weight' => $weight,
         '#hide' => $hide,
       );
-      
-  
+
+
         // if we still don't have markup then skip this one
       if (!$markup) {
         continue;
       }
-  
+
       //-----------------------
       // FIND THE TEMPLATE PATH
       //-----------------------
@@ -512,9 +530,9 @@ function tripal_core_node_view_build_toc(&$build) {
       if (!array_key_exists('#tripal_template_show', $build[$key]) or
         $build[$key]['#tripal_template_show'] == TRUE) {
         if ($cache and array_key_exists($key, $cache->data) and array_key_exists('path', $cache->data[$key])) {
-    
+
           $path = $cache->data[$key]['path'] . '/' . $key . '.tpl.php';
-    
+
           $path = tripal_set_message("Administrators, you can
             customize the way the content above is presented.  Tripal provides a template
             file for each pane of content.  To customize, copy the template file to your
@@ -526,7 +544,7 @@ function tripal_core_node_view_build_toc(&$build) {
           );
         }
       }
-    
+
       //-----------------------
       // ADD THIS PANE TO THE TOC BY ORDER OF WEIGHT
       //-----------------------
@@ -550,11 +568,11 @@ function tripal_core_node_view_build_toc(&$build) {
           </div>
         </div>
       ";
-  
+
       $build[$key]['#markup'] = $updated_markup;
     } // end foreach ($build as $key => $value) {
   } // end if ($build['#tripal_generic_node_template'] == TRUE) {
-  
+
   //-----------------------
   // BUILD THE TABLE OF CONTENTS LINKS
   //-----------------------
@@ -572,7 +590,7 @@ function tripal_core_node_view_build_toc(&$build) {
 }
 
 /**
- * 
+ *
  * @param $build
  */
 function tripal_core_get_toc_overrides($nid, $key, $node_type, $mode) {
@@ -580,7 +598,7 @@ function tripal_core_get_toc_overrides($nid, $key, $node_type, $mode) {
   $override_title = '';
   $override_weight = '';
   $override_hide = 0;
-  
+
   if ($mode != "manage_type") {
     // First look to see if the node has customizations for this item.
     $toc_item_overrides = db_select('tripal_toc', 'tc')
@@ -600,7 +618,7 @@ function tripal_core_get_toc_overrides($nid, $key, $node_type, $mode) {
       );
     }
   }
-  
+
   // If there are no specific node customizations then look to see if there
   // are customizations for this content type.
   $toc_item_overrides = db_select('tripal_toc', 'tc')
@@ -632,21 +650,22 @@ function tripal_core_content_type_toc_form($form, &$form_state, $content_type) {
   // Get the type details
   $all_types = node_type_get_types();
   $type_info = $all_types[$content_type];
-  
+
   $form["#tree"] = TRUE;
 
-  // Get a single node of this type so we can get all the possible content for it
+  // Get a single node of this type so we can get all the possible content
+  // for it.
   $sql = "SELECT nid FROM {node} WHERE type = :type LIMIT 1 OFFSET 0";
   $nid = db_query($sql, array(':type' => $content_type))->fetchField();
   if (!$nid) {
     $form["not_available"] = array(
-      '#markup' => t('Please sync at least one %type_name record. A node 
-          must exist before customizations to the Table of Contents (TOC) can 
+      '#markup' => t('Please sync at least one %type_name record. A node
+          must exist before customizations to the Table of Contents (TOC) can
           be performed.', array('%type_name' => $type_info->name)),
     );
     return $form;
-  } 
-  
+  }
+
   // Load the node
   $node = node_load($nid);
 
@@ -656,12 +675,12 @@ function tripal_core_content_type_toc_form($form, &$form_state, $content_type) {
   // a 'tripal_toc_mode' to the $node because we need to give the mode
   // to the tripal_core_node_view_build_toc function.
   $node->tripal_toc_mode = 'manage_type';
-  
+
   node_build_content($node);
   $build = $node->content;
   $build["#node"] = $node;
   tripal_core_node_view_alter($build);
-  
+
   $form["instructions"] = array(
     '#type' => 'fieldset',
     '#collapsed' => TRUE,
@@ -680,7 +699,7 @@ function tripal_core_content_type_toc_form($form, &$form_state, $content_type) {
       panes that can appear. However, those without content are automatically
       hidden and do not appear in the TOC.' . '</p>'),
   );
-  
+
   $form['content_type'] = array(
     '#type' => 'value',
     '#value' => $content_type,

+ 1 - 69
legacy/tripal_core/theme/css/tripal.css → legacy/tripal_core/theme/css/tripal_core.css

@@ -131,13 +131,13 @@
 /**
  * Within the pane data
  */
+
  .tripal-data-table {
    margin-top: 0px;
    margin-bottom: 10px;
  }
 
 
-
 /******************************************************************************
  * The teaser appears anywhere that a small snippet of the content is required.
  * When any node in Drupal is published to the home page a teaser is used.
@@ -179,71 +179,3 @@
   padding-bottom: 5px;
 }
 
-/******************************************************************************
- * Administrative CSS classes
- *****************************************************************************/
-
- /**
-  * This class is used when providing hints or other instructions to the
-  * site administrator
-  */
-
-div.messages.tripal-site-admin-only{
-  background-image: url("../images/TripalLogo-sm.png");
-  background-repeat: no-repeat;
-  background-color: #cce3ff;
-  margin-top: 10px;
-  margin-bottom: 10px;
-  margin-left: 0px;
-  margin-right: 0px;
-  border: 1px solid #7DA1D4;
-  min-height: 65px;
-  clear: both;
-  padding: 0px;
-}
-
-.tripal-code {
-  font-family: "Courier New", Courier, monospace;
-  word-wrap: break-word;
-  display: block;
-  padding-top: 10px;
-  padding-bottom: 10px;
-}
-
-.tripal-severity-string {
-  font-weight: bold;
-}
-
-.tripal-severity-string-critical, .tripal-severity-string-error, 
-.tripal-severity-string.critical, .tripal-severity-string.error {
-  color: #FF0000;
-}
-
-.tripal-severity-string-warning,
-.tripal-severity-string.warning {
-  color: #FF8000;
-}
-
-.tripal-site-admin-message {
-  padding: 15px 10px 10px 70px;
-  font-style: italic;
-}
-
-.tripal-site-admin-only-table-row {
-  background-color: #cce3ff;
-  /* border: 1px solid #7DA1D4; */
-  color: black;
-}
-
-/******************************************************************************
- * Misc CSS classes
- *****************************************************************************/
-.tripal-dl {
-  width: 100%;
-  overflow: hidden;
-}
-.tripal-dl dt {
-  float: left;
-}
-.tripal-dl dd {
-}

+ 0 - 0
legacy/tripal_core/theme/js/tripal.js → legacy/tripal_core/theme/js/tripal_core.js


+ 18 - 19
legacy/tripal_core/theme/templates/node--chado-generic.tpl.php

@@ -1,28 +1,27 @@
 <?php
-
-if($teaser) {
+if ($teaser) {
   print render($content);
 }
 else {
   $node_type = $node->type; ?>
-  
+
   <script type="text/javascript">
     // We do not use Drupal Behaviors because we do not want this
-    // code to be executed on AJAX callbacks. This code only needs to 
+    // code to be executed on AJAX callbacks. This code only needs to
     // be executed once the page is ready.
     jQuery(document).ready(function($){
 
-      // Hide all but the first data pane 
+      // Hide all but the first data pane
       $(".tripal-data-pane").hide().filter(":first-child").show();
-  
-      // When a title in the table of contents is clicked, then 
-      // show the corresponding item in the details box 
+
+      // When a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
       $(".tripal_toc_list_item_link").click(function(){
         var id = $(this).attr('id') + "-tripal-data-pane";
         $(".tripal-data-pane").hide().filter("#"+ id).fadeIn('fast');
         return false;
       });
-  
+
       // If a ?pane= is specified in the URL then we want to show the
       // requested content pane. For previous version of Tripal,
       // ?block=, was used.  We support it here for backwards
@@ -47,34 +46,34 @@ else {
       $("a.active").removeClass('active');
     });
   </script>
-  
+
   <div id="tripal_<?php print $node_type?>_contents" class="tripal-contents">
     <table id ="tripal-<?php print $node_type?>-contents-table" class="tripal-contents-table">
       <tr class="tripal-contents-table-tr">
         <td nowrap class="tripal-contents-table-td tripal-contents-table-td-toc"  align="left"><?php
-        
-          // print the table of contents. It's found in the content array 
+
+          // print the table of contents. It's found in the content array
           if (array_key_exists('tripal_toc', $content)) {
             print $content['tripal_toc']['#markup'];
-          
+
             // we may want to add the links portion of the contents to the sidebar
             //print render($content['links']);
-            
-            // remove the table of contents and links so thye doent show up in the 
+
+            // remove the table of contents and links so thye doent show up in the
             // data section when the rest of the $content array is rendered
             unset($content['tripal_toc']);
-            unset($content['links']); 
+            unset($content['links']);
           } ?>
 
         </td>
         <td class="tripal-contents-table-td-data" align="left" width="100%"> <?php
-         
-          // print the rendered content 
+
+          // print the rendered content
           print render($content); ?>
         </td>
       </tr>
     </table>
-  </div> <?php 
+  </div> <?php
 }
 
 

+ 4 - 4
legacy/tripal_core/tripal_core.info

@@ -3,14 +3,14 @@ description = Provides support for all Tripal modules and includes the Tripal AP
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-rc1
 configure = admin/tripal
 
-stylesheets[all][] = theme/css/tripal.css
-scripts[]          = theme/js/tripal.js
+stylesheets[all][] = theme/css/tripal_core.css
+scripts[]          = theme/js/tripal_core.js
 
 dependencies[] = views
 dependencies[] = path
-dependencies[] = search
 dependencies[] = php
 dependencies[] = tripal
+dependencies[] = tripal_chado

+ 4 - 4
legacy/tripal_core/tripal_core.install

@@ -49,10 +49,10 @@ function tripal_core_uninstall() {
 
   // drop the foreign key between tripal_custom_tables and tripal_mviews
   // so that Drupal can then drop the tables
-  db_query('
-    ALTER TABLE {tripal_custom_tables}
-    DROP CONSTRAINT tripal_custom_tables_fk1 CASCADE
-  ');
+//   db_query('
+//     ALTER TABLE {tripal_custom_tables}
+//     DROP CONSTRAINT tripal_custom_tables_fk1 CASCADE
+//   ');
 }
 
 /**

+ 180 - 2
legacy/tripal_core/tripal_core.module

@@ -12,6 +12,7 @@ require_once 'api/tripal_core.chado_nodes.dbxrefs.api.inc';
 require_once 'api/tripal_core.chado_nodes.relationships.api.inc';
 require_once 'api/tripal_core.tripal_variables.api.inc';
 require_once 'includes/tripal_core.form_elements.inc';
+require_once 'includes/tripal_core.search.inc';
 
 /**
  * @defgroup tripal_core Tripal Core Module
@@ -49,6 +50,17 @@ function tripal_core_init() {
 function tripal_core_menu() {
   $items = array();
 
+  // Triapl setting groups
+  $items['admin/tripal/legacy'] = array(
+    'title' => 'Tripal Legacy',
+    'description' => t("Legacy functionality from Tripal v2.0."),
+    'weight' => -8,
+    'page callback' => 'system_admin_menu_block_page',
+    'access arguments' => array('administer tripal'),
+    'file' => 'system.admin.inc',
+    'file path' => drupal_get_path('module', 'system'),
+  );
+
   // Relationshi API autocomplete callback
   $items['tripal_ajax/relationship_nodeform/%/%/name_to_id'] = array(
     'page callback' => 'chado_add_node_form_relationships_name_to_id_callback',
@@ -158,7 +170,11 @@ function tripal_core_theme($existing, $type, $theme, $path) {
     // Theme function for the extension admin page.
     'tripal_core_extensions_form_tables' => array(
       'render element' => 'element',
-    )
+    ),
+    'administer controlled vocabularies' => array(
+      'title' => t('Administer controlled vocabularies (CVs).'),
+      'description' => t('Allow a user to add, edit and delete controlled vocabularies as well as add and edit terms.')
+    ),
   );
 }
 
@@ -212,7 +228,6 @@ function tripal_core_node_view($node, $view_mode, $langcode) {
   // the we want to add a table of contents to it's content list
   // this table of contents will be an empty
   if (preg_match('/^chado_/', $node->type)) {
-    // Show feature browser and counts
     if ($view_mode == 'full') {
       if (!isset($node->content['#tripal_generic_node_template'])) {
         $node->content['#tripal_generic_node_template'] = TRUE;
@@ -220,3 +235,166 @@ function tripal_core_node_view($node, $view_mode, $langcode) {
     }
   }
 }
+
+/**
+ * Adds support for tokens in the field_resource_links field.
+ *
+ * The field_resource_links field is a special field that can be manually
+ * added by the site admin for providing links on the Tripal TOC sidebar.
+ * Using tokens will allow for creation of custom links. This function
+ * will add a fieldset contiaining the list of appropriate tokens for the
+ * content type.
+ *
+ * @param unknown $element
+ * @param unknown $form_state
+ * @param unknown $context
+ */
+function tripal_core_field_widget_form_alter(&$element, &$form_state, $context) {
+
+  // If the name of the field is 'field_resource_links' then we want to
+  // add a fieldset of tokens.
+  if (isset($element['#field_name']) AND $element['#field_name'] == 'field_resource_links') {
+
+    // Add the tokens fieldset to the last element.
+    $num_elements = count($context['items']);
+    if ($num_elements == $element['#delta']) {
+      $bundle = $element['#bundle'];
+      $base_table = preg_replace('/^chado_(.*)$/', '\1', $bundle);
+      $tokens = chado_node_generate_tokens($base_table);
+      $token_list = chado_node_format_tokens($tokens);
+      $element['tokens'] = array(
+        '#type' => 'fieldset',
+        '#title' => 'Available tokens',
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+        '#weight' => 100
+      );
+      $element['tokens']['tokens_table'] = array(
+        '#type' => 'item',
+        '#markup' => $token_list
+      );
+    }
+  }
+}
+
+/**
+ * Implements hook_block_info().
+ */
+function tripal_core_block_info() {
+
+  $blocks['tripal_search'] = array(
+    'info' => t('Tripal Search Block'),
+    'cache' => DRUPAL_NO_CACHE,
+  );
+
+  return $blocks;
+}
+
+/**
+ * Implements hook_block_view().
+ */
+function tripal_core_block_view($delta = '') {
+  $block = array();
+
+  switch ($delta) {
+    case 'tripal_search':
+      $block['title'] = 'Search';
+
+      $form_render_arr = drupal_get_form('tripal_core_search_block');
+      $block['content'] = array(
+        '#markup' => drupal_render($form_render_arr),
+      );
+      break;
+  }
+
+  return $block;
+}
+
+/**
+ * A simple search box form.
+ */
+function tripal_core_search_block($form, $form_state) {
+
+  $form['wrapper'] = array(
+    '#prefix' => '<div id="search-block-form" class="container-inline">',
+    '#suffix' => '</div>',
+  );
+
+  $form['wrapper']['title'] = array(
+    '#markup' => '<h2 class="element-invisible">Search form</h2>',
+  );
+
+  $form['wrapper']['search_block_form'] = array(
+    '#title' => 'Search',
+    '#title_display' => 'invisible',
+    '#type' => 'textfield',
+    '#size' => 15,
+    '#maxlength' => 128,
+    '#attributes' =>array('placeholder' => t(variable_get('tripal_search_placeholder', 'Keywords')))
+  );
+
+  $form['wrapper']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => 'Search',
+    '#prefix' => '<div class="form-actions form-wrapper" id="edit-actions">',
+    '#suffix' => '</div>'
+  );
+
+  $form['search_placeholder'] = array(
+    '#type' => 'textfield',
+    '#title' => 'Placeholder Text',
+    '#description' => 'Change the text that shows up within the search box until the user enters any of their own text.',
+    '#default_value' => variable_get('tripal_search_placeholder', 'Keywords'),
+  );
+
+  return $form;
+}
+
+/**
+ * Submit for tripal_core_search_block form.
+ */
+function tripal_core_search_block_submit($form, &$form_state) {
+
+  $form_state['redirect'] = array(
+    variable_get('tripal_search_block_url', 'search/data'),
+    array(
+      'query' => array(
+        'keywords' => $form_state['values']['search_block_form']
+      ),
+    ),
+  );
+
+}
+
+/**
+ * Implements hook_block_configure().
+ */
+function tripal_core_block_configure ($delta = '') {
+  $form = array();
+
+  $form['search_url'] = array(
+    '#type' => 'textfield',
+    '#title' => 'Search Page URL',
+    '#description' => 'The URL for the page you would like to redirect to when the user
+        clicks "Search". It is expected that this page will be a view with an exposed
+        filter having a "Filter Identifier" (in "More" fieldset on the edit filter form)
+        of "keywords".',
+    '#default_value' => variable_get('tripal_search_block_url', 'search/data'),
+  );
+
+  return $form;
+}
+
+/**
+ * Implements hook_block_save().
+ */
+function tripal_core_block_save($delta = '', $edit = array()) {
+
+  // We simply want to save this information in a Drupal variable for use in the form submit.
+  if (!empty($edit['search_url'])) {
+    variable_set('tripal_search_block_url', $edit['search_url']);
+  }
+  if (!empty($edit['search_placeholder'])) {
+    variable_set('tripal_search_placeholder', $edit['search_placeholder']);
+  }
+}

+ 104 - 0
legacy/tripal_core/tripal_core.views_default.inc

@@ -0,0 +1,104 @@
+<?php
+/**
+ * @file
+* Describes core default views
+*/
+
+/**
+ * Describes core default views
+*
+* @ingroup tripal_core
+*/
+function tripal_core_views_default_views() {
+  $views = array();
+
+  // We only want to make this view available if the Search API module is installed
+  // and the "Default Node Index has been enabled.
+  if (module_exists('search_api')) {
+    $index_enabled = db_query('SELECT enabled FROM search_api_index WHERE machine_name=:name', array(':name' => 'default_node_index'))->fetchField();
+    if ($index_enabled) {
+      $view = tripal_core_search_default_node_index();
+      $views[$view->name] = $view;
+    }
+  }
+  return $views;
+}
+
+
+/**
+ * Provides a default search view for the Search API "Default Node Index".
+ */
+function tripal_core_search_default_node_index() {
+
+  $view = new view();
+  $view->name = 'search_api_default_node_search';
+  $view->description = 'A default keyword-based search view using the search API "Default node index".';
+  $view->tag = 'search';
+  $view->base_table = 'search_api_index_default_node_index';
+  $view->human_name = 'Search';
+  $view->core = 7;
+  $view->api_version = '3.0';
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+  /* Display: Master */
+  $handler = $view->new_display('default', 'Master', 'default');
+  $handler->display->display_options['title'] = 'Search';
+  $handler->display->display_options['use_more_always'] = FALSE;
+  $handler->display->display_options['access']['type'] = 'none';
+  $handler->display->display_options['cache']['type'] = 'none';
+  $handler->display->display_options['query']['type'] = 'views_query';
+  $handler->display->display_options['exposed_form']['type'] = 'input_required';
+  $handler->display->display_options['exposed_form']['options']['submit_button'] = 'Search';
+  $handler->display->display_options['exposed_form']['options']['expose_sort_order'] = FALSE;
+  $handler->display->display_options['exposed_form']['options']['text_input_required'] = '';
+  $handler->display->display_options['exposed_form']['options']['text_input_required_format'] = 'filtered_html';
+  $handler->display->display_options['pager']['type'] = 'full';
+  $handler->display->display_options['pager']['options']['items_per_page'] = '25';
+  $handler->display->display_options['pager']['options']['offset'] = '0';
+  $handler->display->display_options['pager']['options']['id'] = '0';
+  $handler->display->display_options['pager']['options']['quantity'] = '9';
+  $handler->display->display_options['style_plugin'] = 'default';
+  $handler->display->display_options['row_plugin'] = 'fields';
+  /* Field: Content: Rendered Node */
+  $handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
+  $handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_node';
+  $handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
+  $handler->display->display_options['fields']['rendered_entity']['label'] = '';
+  $handler->display->display_options['fields']['rendered_entity']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
+  $handler->display->display_options['fields']['rendered_entity']['display'] = 'view';
+  $handler->display->display_options['fields']['rendered_entity']['view_mode'] = 'teaser';
+  $handler->display->display_options['fields']['rendered_entity']['bypass_access'] = 0;
+  /* Sort criterion: Search: Relevance */
+  $handler->display->display_options['sorts']['search_api_relevance']['id'] = 'search_api_relevance';
+  $handler->display->display_options['sorts']['search_api_relevance']['table'] = 'search_api_index_default_node_index';
+  $handler->display->display_options['sorts']['search_api_relevance']['field'] = 'search_api_relevance';
+  $handler->display->display_options['sorts']['search_api_relevance']['order'] = 'DESC';
+  /* Filter criterion: Search: Fulltext search */
+  $handler->display->display_options['filters']['search_api_views_fulltext']['id'] = 'search_api_views_fulltext';
+  $handler->display->display_options['filters']['search_api_views_fulltext']['table'] = 'search_api_index_default_node_index';
+  $handler->display->display_options['filters']['search_api_views_fulltext']['field'] = 'search_api_views_fulltext';
+  $handler->display->display_options['filters']['search_api_views_fulltext']['operator'] = 'OR';
+  $handler->display->display_options['filters']['search_api_views_fulltext']['exposed'] = TRUE;
+  $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['operator_id'] = 'search_api_views_fulltext_op';
+  $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['label'] = 'Keywords';
+  $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['operator'] = 'search_api_views_fulltext_op';
+  $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['identifier'] = 'keywords';
+  $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['remember_roles'] = array(
+    2 => '2',
+    1 => 0,
+    3 => 0,
+  );
+
+  /* Display: Page */
+  $handler = $view->new_display('page', 'Page', 'page');
+  $handler->display->display_options['path'] = 'chado';
+  $handler->display->display_options['menu']['type'] = 'normal';
+  $handler->display->display_options['menu']['title'] = 'Search';
+  $handler->display->display_options['menu']['description'] = 'General keyword search of all content.';
+  $handler->display->display_options['menu']['weight'] = '0';
+  $handler->display->display_options['menu']['context'] = 0;
+  $handler->display->display_options['menu']['context_only_inline'] = 0;
+
+  return $view;
+}

+ 117 - 0
legacy/tripal_cv/api/tripal_cv.api.inc

@@ -0,0 +1,117 @@
+<?php
+/**
+ * Retreives the default vocabulary for a given table and field.
+ *
+ * Each table in Chado that has a 'type_id' (or foreign key constraint to
+ * the cvterm table) will have a default vocabulary assigned. This indicates to
+ * Tripal that terms in that vocabulary are used to set the type_id for that
+ * table. An example where this is used is the
+ * tripal_get_cvterm_select_options() function which generates a list of options
+ * for a select box used in a Drupal form.  The select box will list the terms
+ * from the default vocabulary in the drop down.
+ *
+ * This function uses the Chado table and field name (e.g. 'type_id') to
+ * retreive the vocabulary assgined.
+ *
+ * @param $table
+ *   The name of the table that contains a field with a foreign key
+ *   relationship to the cvterm table
+ * @param $field
+ *   The table field name that has the foreign key relationship to the
+ *   cvterm table for which the default vocabulary will be set
+ *
+ * @return
+ *   The cv object of the default vocabulary or an empty array if not
+ *   available.
+ */
+function tripal_get_default_cv($table, $field) {
+  $sql = "
+    SELECT cv_id
+    FROM {tripal_cv_defaults}
+    WHERE table_name = :table and field_name = :field
+  ";
+  $cv_id = db_query($sql, array(':table' => $table, ':field' => $field))->fetchField();
+
+  return tripal_get_cv(array('cv_id' => $cv_id));
+}
+
+/**
+ * Retrieves the Chado table to which a vocbulary is set as default.
+ *
+ * Each table in Chado that has a 'type_id' (or foreign key constraint to
+ * the cvterm table) will have a default vocabulary assigned. This indicates to
+ * Tripal that terms in that vocabulary are used to set the type_id for that
+ * table. An example where this is used is the
+ * tripal_get_cvterm_select_options() function which generates a list of options
+ * for a select box used in a Drupal form.  The select box will list the terms
+ * from the default vocabulary in the drop down.
+ *
+ * This function uses the vocabulary ID to get the Chado table to which it
+ * is assigned.
+ *
+ * @param $cv_id
+ *  The ID of the vocabulary.
+ *
+ * @return
+ *   If an assignment is present, an object containing the 'table_name' and
+ *   'field_name' is returned.
+ */
+function tripal_get_default_cv_table($cv_id) {
+  $default = db_select('tripal_cv_defaults', 't')
+    ->fields('t', array('table_name', 'field_name'))
+    ->condition('cv_id', $cv_id)
+    ->execute()
+    ->fetchObject();
+  return $default;
+}
+
+/**
+ * Create an options array to be used in a form element
+ * which provides a list of all chado cvterms. Unlike the
+ * tripal_get_cvterm_select_option, this function retreives the cvterms using
+ * the default vocabulary set for a given table and field.  It will also
+ * notify the administrative user if a default vocabulary is missing for the
+ * field and if the vocabulary is empty.
+ *
+ * @param $table
+ *   The name of the table that contains the field with a foreign key
+ *   relationship to the cvterm table
+ * @param $field
+ *   The table field name that has the foreign key relationship to the
+ *   cvterm table for which the default vocabulary will be set
+ * @param $field_desc
+ *   A human readable descriptive name for the field
+ *
+ * @return
+ *   An array(cvterm_id => name)
+ *   for each cvterm in the chado cvterm table where cv_id=that supplied
+ */
+function tripal_get_cvterm_default_select_options($table, $field, $field_desc) {
+
+  $default_cv = tripal_get_default_cv($table, $field);
+  $options = array();
+
+  if ($default_cv) {
+    $options = tripal_get_cvterm_select_options($default_cv->cv_id);
+
+    if (count($options) == 0) {
+      tripal_set_message('There are no ' . $field_desc . '. Please ' .
+          l('add terms',
+              'admin/tripal/loaders/chado_cv/' .$default_cv->cv_id. '/cvterm/add',
+              array('attributes' => array('target' => '_blank'))) . ' to the ' .
+          $default_cv->name .' vocabulary.',
+          TRIPAL_WARNING);
+    }
+
+  }
+  else {
+    tripal_set_message('There is not a default vocabulary set for ' . $field_desc . '. '.
+        'Please set one using the ' .
+        l('vocabulary defaults configuration page',
+            'admin/tripal/vocab/defaults',
+            array('attributes' => array('target' => '_blank'))) . '.',
+        TRIPAL_WARNING);
+  }
+
+  return $options;
+}

+ 0 - 320
legacy/tripal_cv/includes/tripal_cv.admin.inc

@@ -4,323 +4,3 @@
  * Provides administration of controlled vocabularies & their terms.
  */
 
-/**
- * Provide landing page to the new admin pages
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_admin_cv_listing() {
-  $output = '';
-
-  // set the breadcrumb
-  $breadcrumb = array();
-  $breadcrumb[] = l('Home', '<front>');
-  $breadcrumb[] = l('Administration', 'admin');
-  $breadcrumb[] = l('Tripal', 'admin/tripal');
-  $breadcrumb[] = l('Chado Modules', 'admin/tripal/chado');
-  $breadcrumb[] = l('Vocabularies', 'admin/tripal/vocab');
-  drupal_set_breadcrumb($breadcrumb);
-
-  // Add the view
-  $cvs_view = views_embed_view('tripal_cv_admin_cvs','default');
-  $cvterms_view = views_embed_view('tripal_cv_admin_cvterms','default');
-  if (isset($cvs_view) && isset($cvterms_view)) {
-    $output .= $cvs_view;
-  }
-  else {
-    $output .= '<p>The Tripal Controlled Vocabulary module uses primarily views to provide an '
-      . 'administrative interface. Currently one or more views needed for this '
-      . 'administrative interface are disabled. <strong>Click each of the following links to '
-      . 'enable the pertinent views</strong>:</p>';
-    $output .= '<ul>';
-    if (!isset($cvs_view)) {
-      $output .= '<li>'.l('Tripal Vocabularies', 'admin/tripal/vocab/views/cvs/enable').'</li>';
-    }
-    if (!isset($cvterm_view)) {
-      $output .= '<li>'.l('Tripal Vocabulary Terms', 'admin/tripal/vocab/views/cvterms/enable').'</li>';
-    }
-    $output .= '</ul>';
-  }
-
-  return $output;
-}
-
-/**
- *
- */
-function tripal_cv_admin_set_defaults_form($form, &$form_state) {
-
-  $form['instructions'] = array(
-    '#markup' => t('Much of the data housed in Chado is typed, meaning that a ' .
-        'controlled vocabulary describes what type of data the record is. For example, '.
-        'a feature must have a "type" which is typically a term from ' .
-        'the Sequence Ontology. Record properties typically have a type as well. '.
-        'Tripal allows the administrator to set a default type for each table in '.
-        'Chado that requires a type from a vocabulary. By default, autocomplete fields, '.
-        'type select boxes and type validation occur using the default vocabularies set below. '),
-  );
-
-  // get the list of all tables that use the cvterm table as an FK
-  $cvterm_schema = chado_get_schema('cvterm');
-  $referring_tables = $cvterm_schema['referring_tables'];
-
-  // get the list of tables that already have default set
-  $cv_defaults = db_select('tripal_cv_defaults', 'TCD')
-    ->fields('TCD', array('cv_default_id', 'table_name', 'field_name', 'cv_id'))
-    ->orderBy('table_name', 'ASC')
-    ->execute();
-
-  // get the list of vocabularies
-  $cvs = tripal_get_cv_select_options();
-
-  $form['settings'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Configured Defaults'),
-    '#description' => t('The following tables have a default vocabulary'),
-    '#tree' => TRUE,
-  );
-  foreach ($cv_defaults as $cv_default) {
-    $cv_default_id = $cv_default->cv_default_id;
-    $cv = tripal_get_cv(array('cv_id' => $cv_default->cv_id));
-
-    $form['settings']['existing'][$cv_default_id]["id"] = array(
-      '#type' => 'hidden',
-      '#value' => $cv_default_id,
-    );
-
-    // Display
-    $form['settings']['existing'][$cv_default_id]["table_name-display"] = array(
-      '#type' => 'markup',
-      '#markup' => $cv_default->table_name
-    );
-    $form['settings']['existing'][$cv_default_id]["field_name-display"] = array(
-      '#type' => 'markup',
-      '#markup' => $cv_default->field_name
-    );
-
-    // Save for use in submit
-    $form['settings']['existing'][$cv_default_id]["table_name"] = array(
-      '#type' => 'hidden',
-      '#value' => $cv_default->table_name
-    );
-    $form['settings']['existing'][$cv_default_id]["field_name"] = array(
-      '#type' => 'hidden',
-      '#value' => $cv_default->field_name
-    );
-
-    // Selectbox to set the vocabulary
-    if (!empty($cv)) {
-      $default_cv = $cv_default->cv_id;
-    }
-    else {
-      $cvs[0] = 'NONE SET';
-      $default_cv = 0;
-    }
-    $form['settings']['existing'][$cv_default_id]["vocabulary"] = array(
-      '#type' => 'select',
-      '#options' => $cvs,
-      '#default_value' => $default_cv,
-    );
-
-    // Actions
-    $view_terms = l('New Vocabulary', 'admin/tripal/vocab/cv/add');
-    $add_term = '';
-    if (!empty($cv)) {
-      $view_terms = l(
-        'View Terms',
-        'admin/tripal/vocab/cvterms',
-        array('query' => array('cv' => $cv->name))
-      );
-
-      $add_term = l(
-        'Add Term',
-        'admin/tripal/vocab/cv/' . $cv->cv_id . '/cvterm/add'
-      );
-    }
-    $form['settings']['existing'][$cv_default_id]["view-terms"] = array(
-      '#type' => 'markup',
-      '#markup' => $view_terms
-    );
-    $form['settings']['existing'][$cv_default_id]["add-new-term"] = array(
-      '#type' => 'markup',
-      '#markup' => $add_term
-    );
-
-  }
-
-  $form['settings']['submit'] = array(
-    '#type' => 'submit',
-    '#value' => 'Update Defaults'
-  );
-
-  // Adding new CV Defaults
-  $form['new'] = array(
-    '#type' => 'fieldset',
-    '#title' => 'Add New Defaults',
-    '#description' => 'You can use the form below to add a default controlled vocabulary
-      for a table/field combination not available in the "Configured Defaults" section above.',
-    '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
-    '#tree' => TRUE,
-    '#prefix' => '<div id="new-default">',
-    '#suffix' => '</div>',
-  );
-
-  $tripal_msg = tripal_set_message(
-    'If you are developing a custom module and would like to use the Default Controlled
-      Vocabulary API to flexibly set the controlled vocabulary, then it is better to set
-      the default programatically rather than through this interface. To do this <ol>
-        <li>Tell Tripal about the table/field you would like to set the default for. This
-          is done by implementing hook_install() in your modules .install file and adding
-          a call to <code>tripal_set_default_cv([table name], [field name], [cv name])</code> which
-          will set the default for <code>[table name].[field name]</code> to the <code>[cv name]</code> controlled
-          vocabulary. This vocabulary must already exist.</li>
-        <li>Then everywhere in your module that you need to know the controlled vocabulary,
-          you call <code>tripal_get_default_cv([table name], [field name])</code> which will return
-          an object describing the set default controlled vocabulary or call
-          <code>tripal_get_cvterm_default_select_options([table name], [field name], [field friendly name])</code>
-          if you would like an array of options for use in a select or autocomplete form element.</li></ol>
-      ',
-    TRIPAL_NOTICE,
-    array('return_html' => TRUE)
-  );
-
-  $form['new']['instructions'] = array(
-    '#type' => 'markup',
-    '#markup' => $tripal_msg
-  );
-
-  $chado_tables = chado_get_table_names(TRUE);
-  $chado_tables[0] = 'Select a Table';
-  $form['new']['table'] = array(
-    '#type' => 'select',
-    '#title' => 'Table Name',
-    '#description' => 'The name of the table you would like to set a controlled vocabulary default for.',
-    '#options' => $chado_tables,
-    '#default_value' => 0,
-    '#ajax' => array(
-      'callback' => 'tripal_cv_admin_ajax_new_default_field_callback',
-      'wrapper' => 'new-default',
-    )
-  );
-
-  $table = (isset($form_state['values']['new']['table']))? $form_state['values']['new']['table'] : FALSE;
-  $columns = array('Select a Field');
-  if ($table) {
-    // get the table description
-    $table_desc = chado_get_schema($table);
-    if (isset($table_desc['foreign keys']['cvterm'])) {
-      foreach ($table_desc['foreign keys']['cvterm']['columns'] as $left_column => $right_column) {
-        $columns[$left_column] = $left_column;
-      }
-    }
-  }
-  $form['new']['field'] = array(
-    '#type' => 'select',
-    '#title' => 'Field Name',
-    '#description' => 'The name of the field you would like to set a controlled vocabulary default for.',
-    '#options' => $columns,
-    '#default_value' => 0
-  );
-
-  $cvs[0] = 'Select a Vocabulary';
-  $form['new']['vocabulary'] = array(
-    '#type' => 'select',
-    '#title' => 'Vocabulary',
-    '#description' => 'The default controlled vocabulary you would like to set for this field.',
-    '#options' => $cvs,
-    '#default_value' => 0
-  );
-
-  $form['new']['add_new'] = array(
-    '#type' => 'submit',
-    '#value' => 'Set New Default'
-  );
-
-  return $form;
-}
-
-function tripal_cv_admin_set_defaults_form_submit($form, $form_state) {
-
-  if ($form_state['triggering_element']['#value'] == 'Update Defaults') {
-    foreach ($form_state['values']['settings']['existing'] as $default_cv) {
-      if (!empty($default_cv['vocabulary'])) {
-        tripal_set_default_cv(
-          $default_cv['table_name'],
-          $default_cv['field_name'],
-          '', // We are passing in the cv_id so we don't need the name
-          $default_cv['vocabulary']
-        );
-      }
-    }
-  }
-
-  if ($form_state['triggering_element']['#value'] == 'Set New Default') {
-    if (!empty($form_state['values']['new']['vocabulary'])) {
-      tripal_set_default_cv(
-        $form_state['values']['new']['table'],
-        $form_state['values']['new']['field'],
-        '', // We are passing in the cv_id so we don't need the name
-        $form_state['values']['new']['vocabulary']
-      );
-    }
-  }
-}
-
-function tripal_cv_admin_ajax_new_default_field_callback($form, $form_state) {
-  return $form['new'];
-}
-
-/**
- *
- * @param unknown $variables
- */
-function theme_tripal_cv_admin_set_defaults_form($variables) {
-  $element = $variables['element'];
-
-  $header = array(
-    'table_name'      => array('data' => t('Table Name'),         'width' => '20%'),
-    'field_name'      => array('data' => t('Field Name'),         'width' => '20%'),
-    'vocabulary'      => array('data' => t('Default Vocabulary'), 'width' => '30%'),
-    'actions'         => array('data' => t('Actions'),            'width' => '30%'),
-  );
-
-  $rows = array();
-
-  foreach ($element['settings']['existing'] as $key => $value) {
-    if (is_numeric($key)) {
-
-      $action_links = '<ul class="links inline">';
-      if (!empty($value['view-terms'])) {
-        $action_links .= '<li>' . drupal_render($value['view-terms']) . '</li>';
-      }
-      if (!empty($value['add-new-term'])) {
-        $action_links .= '<li>' . drupal_render($value['add-new-term']) . '</li>';
-      }
-      $action_links .= '</li></ul>';
-
-      $rows[] = array(
-        drupal_render($value['table_name-display']),
-        drupal_render($value['field_name-display']),
-        drupal_render($value['vocabulary']),
-        $action_links
-      );
-    }
-  }
-  $settings_table = theme('table', array(
-    'header' => $header,
-    'rows' => $rows
-  ));
-  $element['settings']['existing'] = array(
-    '#type' => 'markup',
-    '#markup' => $settings_table,
-  );
-
-  // TODO: I believe rendering of the form should not happen here. But rather
-  // the form should be returned as is. This way other modules can have access
-  // to the form elements via the hook_form_alter.  Rather, there should
-  // be a theme function for the form where the rendering in the table
-  // should occur.  See the tripal_pub_importer_setup_form() for an exmaple.
-  return drupal_render_children($element);
-
-}

+ 282 - 0
legacy/tripal_cv/includes/tripal_cv.cv_defaults.inc

@@ -0,0 +1,282 @@
+<?php
+
+
+/**
+ *
+ */
+function tripal_cv_admin_set_defaults_form($form, &$form_state) {
+
+  $form['instructions'] = array(
+    '#markup' => t('Much of the data housed in Chado is typed, meaning that a ' .
+        'controlled vocabulary describes what type of data the record is. For example, '.
+        'a feature must have a "type" which is typically a term from ' .
+        'the Sequence Ontology. Record properties typically have a type as well. '.
+        'Tripal allows the administrator to set a default type for each table in '.
+        'Chado that requires a type from a vocabulary. By default, autocomplete fields, '.
+        'type select boxes and type validation occur using the default vocabularies set below. '),
+  );
+
+  // get the list of all tables that use the cvterm table as an FK
+  $cvterm_schema = chado_get_schema('cvterm');
+  $referring_tables = $cvterm_schema['referring_tables'];
+
+  // get the list of tables that already have default set
+  $cv_defaults = db_select('tripal_cv_defaults', 'TCD')
+    ->fields('TCD', array('cv_default_id', 'table_name', 'field_name', 'cv_id'))
+    ->orderBy('table_name', 'ASC')
+    ->execute();
+
+  // get the list of vocabularies
+  $cvs = tripal_get_cv_select_options();
+
+  $form['settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Configured Defaults'),
+    '#description' => t('The following tables have a default vocabulary'),
+    '#tree' => TRUE,
+  );
+  foreach ($cv_defaults as $cv_default) {
+    $cv_default_id = $cv_default->cv_default_id;
+    $cv = tripal_get_cv(array('cv_id' => $cv_default->cv_id));
+
+    $form['settings']['existing'][$cv_default_id]["id"] = array(
+      '#type' => 'hidden',
+      '#value' => $cv_default_id,
+    );
+
+    // Display
+    $form['settings']['existing'][$cv_default_id]["table_name-display"] = array(
+      '#type' => 'markup',
+      '#markup' => $cv_default->table_name
+    );
+    $form['settings']['existing'][$cv_default_id]["field_name-display"] = array(
+      '#type' => 'markup',
+      '#markup' => $cv_default->field_name
+    );
+
+    // Save for use in submit
+    $form['settings']['existing'][$cv_default_id]["table_name"] = array(
+      '#type' => 'hidden',
+      '#value' => $cv_default->table_name
+    );
+    $form['settings']['existing'][$cv_default_id]["field_name"] = array(
+      '#type' => 'hidden',
+      '#value' => $cv_default->field_name
+    );
+
+    // Selectbox to set the vocabulary
+    if (!empty($cv)) {
+      $default_cv = $cv_default->cv_id;
+    }
+    else {
+      $cvs[0] = 'NONE SET';
+      $default_cv = 0;
+    }
+    $form['settings']['existing'][$cv_default_id]["vocabulary"] = array(
+      '#type' => 'select',
+      '#options' => $cvs,
+      '#default_value' => $default_cv,
+    );
+
+    // Actions
+    $view_terms = l('New Vocabulary', 'admin/tripal/loaders/chado_cv/add');
+    $add_term = '';
+    if (!empty($cv)) {
+      $view_terms = l(
+          'View Terms',
+          'admin/tripal/loaders/chado_cvterms',
+          array('query' => array('cv' => $cv->name))
+      );
+
+      $add_term = l(
+          'Add Term',
+          'admin/tripal/loaders/chado_cv/' . $cv->cv_id . '/cvterm/add'
+      );
+    }
+    $form['settings']['existing'][$cv_default_id]["view-terms"] = array(
+      '#type' => 'markup',
+      '#markup' => $view_terms
+    );
+    $form['settings']['existing'][$cv_default_id]["add-new-term"] = array(
+      '#type' => 'markup',
+      '#markup' => $add_term
+    );
+
+  }
+
+  $form['settings']['submit'] = array(
+    '#type' => 'submit',
+    '#value' => 'Update Defaults'
+  );
+
+  // Adding new CV Defaults
+  $form['new'] = array(
+    '#type' => 'fieldset',
+    '#title' => 'Add New Defaults',
+    '#description' => 'You can use the form below to add a default controlled vocabulary
+      for a table/field combination not available in the "Configured Defaults" section above.',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#tree' => TRUE,
+    '#prefix' => '<div id="new-default">',
+    '#suffix' => '</div>',
+  );
+
+  $tripal_msg = tripal_set_message(
+      'If you are developing a custom module and would like to use the Default Controlled
+      Vocabulary API to flexibly set the controlled vocabulary, then it is better to set
+      the default programatically rather than through this interface. To do this <ol>
+        <li>Tell Tripal about the table/field you would like to set the default for. This
+          is done by implementing hook_install() in your modules .install file and adding
+          a call to <code>tripal_set_default_cv([table name], [field name], [cv name])</code> which
+          will set the default for <code>[table name].[field name]</code> to the <code>[cv name]</code> controlled
+          vocabulary. This vocabulary must already exist.</li>
+        <li>Then everywhere in your module that you need to know the controlled vocabulary,
+          you call <code>tripal_get_default_cv([table name], [field name])</code> which will return
+          an object describing the set default controlled vocabulary or call
+          <code>tripal_get_cvterm_default_select_options([table name], [field name], [field friendly name])</code>
+          if you would like an array of options for use in a select or autocomplete form element.</li></ol>
+      ',
+      TRIPAL_NOTICE,
+      array('return_html' => TRUE)
+  );
+
+  $form['new']['instructions'] = array(
+    '#type' => 'markup',
+    '#markup' => $tripal_msg
+  );
+
+  $chado_tables = chado_get_table_names(TRUE);
+  $chado_tables[0] = 'Select a Table';
+  $form['new']['table'] = array(
+    '#type' => 'select',
+    '#title' => 'Table Name',
+    '#description' => 'The name of the table you would like to set a controlled vocabulary default for.',
+    '#options' => $chado_tables,
+    '#default_value' => 0,
+    '#ajax' => array(
+      'callback' => 'tripal_cv_admin_ajax_new_default_field_callback',
+      'wrapper' => 'new-default',
+    )
+  );
+
+  $table = (isset($form_state['values']['new']['table']))? $form_state['values']['new']['table'] : FALSE;
+  $columns = array('Select a Field');
+  if ($table) {
+    // get the table description
+    $table_desc = chado_get_schema($table);
+    if (isset($table_desc['foreign keys']['cvterm'])) {
+      foreach ($table_desc['foreign keys']['cvterm']['columns'] as $left_column => $right_column) {
+        $columns[$left_column] = $left_column;
+      }
+    }
+  }
+  $form['new']['field'] = array(
+    '#type' => 'select',
+    '#title' => 'Field Name',
+    '#description' => 'The name of the field you would like to set a controlled vocabulary default for.',
+    '#options' => $columns,
+    '#default_value' => 0
+  );
+
+  $cvs[0] = 'Select a Vocabulary';
+  $form['new']['vocabulary'] = array(
+    '#type' => 'select',
+    '#title' => 'Vocabulary',
+    '#description' => 'The default controlled vocabulary you would like to set for this field.',
+    '#options' => $cvs,
+    '#default_value' => 0
+  );
+
+  $form['new']['add_new'] = array(
+    '#type' => 'submit',
+    '#value' => 'Set New Default'
+  );
+
+  return $form;
+}
+
+function tripal_cv_admin_set_defaults_form_submit($form, $form_state) {
+
+  if ($form_state['triggering_element']['#value'] == 'Update Defaults') {
+    foreach ($form_state['values']['settings']['existing'] as $default_cv) {
+      if (!empty($default_cv['vocabulary'])) {
+        tripal_set_default_cv(
+            $default_cv['table_name'],
+            $default_cv['field_name'],
+            '', // We are passing in the cv_id so we don't need the name
+            $default_cv['vocabulary']
+        );
+      }
+    }
+  }
+
+  if ($form_state['triggering_element']['#value'] == 'Set New Default') {
+    if (!empty($form_state['values']['new']['vocabulary'])) {
+      tripal_set_default_cv(
+          $form_state['values']['new']['table'],
+          $form_state['values']['new']['field'],
+          '', // We are passing in the cv_id so we don't need the name
+          $form_state['values']['new']['vocabulary']
+      );
+    }
+  }
+}
+
+function tripal_cv_admin_ajax_new_default_field_callback($form, $form_state) {
+  return $form['new'];
+}
+
+/**
+ *
+ * @param unknown $variables
+ */
+function theme_tripal_cv_admin_set_defaults_form($variables) {
+  $element = $variables['element'];
+
+  $header = array(
+    'table_name'      => array('data' => t('Table Name'),         'width' => '20%'),
+    'field_name'      => array('data' => t('Field Name'),         'width' => '20%'),
+    'vocabulary'      => array('data' => t('Default Vocabulary'), 'width' => '30%'),
+    'actions'         => array('data' => t('Actions'),            'width' => '30%'),
+  );
+
+  $rows = array();
+
+  foreach ($element['settings']['existing'] as $key => $value) {
+    if (is_numeric($key)) {
+
+//       $action_links = '<ul class="links inline">';
+//       if (!empty($value['view-terms'])) {
+//         $action_links .= '<li>' . drupal_render($value['view-terms']) . '</li>';
+//       }
+//       if (!empty($value['add-new-term'])) {
+//         $action_links .= '<li>' . drupal_render($value['add-new-term']) . '</li>';
+//       }
+//       $action_links .= '</li></ul>';
+
+      $rows[] = array(
+        drupal_render($value['table_name-display']),
+        drupal_render($value['field_name-display']),
+        drupal_render($value['vocabulary']),
+        $action_links
+      );
+    }
+  }
+  $settings_table = theme('table', array(
+    'header' => $header,
+    'rows' => $rows
+  ));
+  $element['settings']['existing'] = array(
+    '#type' => 'markup',
+    '#markup' => $settings_table,
+  );
+
+  // TODO: I believe rendering of the form should not happen here. But rather
+  // the form should be returned as is. This way other modules can have access
+  // to the form elements via the hook_form_alter.  Rather, there should
+  // be a theme function for the form where the rendering in the table
+  // should occur.  See the tripal_pub_importer_setup_form() for an exmaple.
+  return drupal_render_children($element);
+
+}

+ 0 - 256
legacy/tripal_cv/includes/tripal_cv.cv_form.inc

@@ -4,260 +4,4 @@
  * Provides a form for creating & editing chado controlled vocabularies
  */
 
-/**
- * Provides the actual "Select CV" form on the Update/Delete Controlled
- *   Vocabulary page. This form also triggers the edit javascript
- * @todo Modify this form to use Drupal AJAX
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cv_edit_form($form, &$form_state) {
-
-  // get the cv_d if form was submitted via AJAX
-  $cv_id = 0;
-  if (array_key_exists('values', $form_state)) {
-    $cv_id = $form_state['values']['cv_id'];
-  }
-  elseif (isset($form_state['build_info']['args'][0])) {
-    $cv_id = $form_state['build_info']['args'][0];
-  }
-
-  // get a list of db from chado for user to choose
-  $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
-  $results = chado_query($sql);
-
-  $cvs = array();
-  $cvs[] = 'Select a vocabulary';
-  foreach ($results as $cv) {
-    $cvs[$cv->cv_id] = $cv->name;
-  }
-
-  $form['cv_id'] = array(
-    '#title' => t('Controlled Vocabulary Name'),
-    '#type' => 'select',
-    '#options' => $cvs,
-    '#ajax' => array(
-      'callback' => 'tripal_cv_edit_form_ajax',
-      'wrapper'  => 'cv-edit-div',
-      'effect'   => 'fade',
-      'event'    => 'change',
-      'method'   => 'replace',
-    ),
-    '#default_value' => $cv_id,
-  );
-
-
-  // if we don't have a db_id then we can  return the form, otherwise
-  // add in the other fields
-  if ($cv_id) {
-    tripal_cv_add_cv_form_fields($form, $form_state, $cv_id);
-
-    $form['update'] = array(
-      '#type'         => 'submit',
-      '#value'        => t('Update'),
-    );
-    $form['delete'] = array(
-      '#type'         => 'submit',
-      '#value'        => t('Delete'),
-      '#attributes'   => array('onclick' => 'if(!confirm("Really Delete?")){return false;}'),
-    );
-  }
-  else {
-    // if we don't have a dbid then this is the first time the form has
-    // benn loaded and we need to create the div where ajax replacement elements get stored
-    $form['div_replace'] = array(
-      '#type' => 'item',
-      '#prefix' => '<div id="cv-edit-div">',
-      '#suffix' => '</div>',
-    );
-  }
-  return $form;
-}
-
-/**
- * Form to add contolled vocabularies
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cv_add_form($form, &$form_state) {
-
-  // add in the form fields to this form
-  tripal_cv_add_cv_form_fields($form, $form_state);
-
-  $form['add'] = array(
-    '#type'         => 'submit',
-    '#value'        => t('Add'),
-    '#weight'       => 5,
-  );
-  return $form;
-}
-
-/**
- * Form fields in common between the cv add & edit form.
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_add_cv_form_fields(&$form, $form_state, $cv_id = NULL) {
-
-  $default_name = '';
-  $default_desc = '';
-
-  if ($cv_id) {
-    $values = array('cv_id' => $cv_id);
-    $result = chado_select_record('cv', array('*'), $values);
-    $cv = $result[0];
-    $default_name = $cv->name;
-    $default_desc = $cv->definition;
-  }
-
-  // add a fieldset for the Drupal Schema API
-  $form['fields'] = array(
-    '#type' => 'fieldset',
-    '#title' => 'Controlled Vocabulary Details',
-    '#collapsible' => 0,
-  );
-
-  $form['fields']['name']= array(
-    '#type'          => 'textfield',
-    '#title'         => t("Controlled Vocabulary name"),
-    '#description'   => t('Please enter the name for this vocabulary.'),
-    '#required'      => TRUE,
-    '#default_value' => $default_name,
-    '#maxlength'     => 255,
-  );
-
-  $form['fields']['definition']= array(
-    '#type'          => 'textarea',
-    '#title'         => t('Description'),
-    '#description'   => t('Please enter a definition for this vocabulary'),
-    '#default_value' => $default_desc,
-  );
-
-  return $form;
-}
-
-/**
- * Validation fucntion for tripal_cv_cv_add_form
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cv_add_form_validate($form, &$form_state) {
-  tripal_cv_form_fields_validate($form, $form_state);
-}
-
-/**
- * Validation fucntion for tripal_cv_cv_edit_form
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cv_edit_form_validate($form, &$form_state) {
-  tripal_cv_form_fields_validate($form, $form_state);
-}
-
-/**
- * Generic validation form for shared fields of both the edit and add forms
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_form_fields_validate($form, &$form_state) {
-  $name =  array_key_exists('name', $form_state['values'])       ? trim($form_state['values']['name']) : '';
-  $desc =  array_key_exists('definition', $form_state['values']) ? trim($form_state['values']['definition']) : '';
-  $cv_id = array_key_exists('cv_id', $form_state['values'])      ? trim($form_state['values']['cv_id']) : '';
-
-
-  // make sure the cv name is unique
-  $values = array('name' => $name);
-  $results = chado_select_record('cv', array('cv_id'), $values);
-  if (count($results) > 0 and $results[0]->cv_id != $cv_id) {
-    form_set_error('name', 'The vocabulary name must be unique');
-  }
-}
-
-/**
- * Submit cv add form
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cv_add_form_submit($form, &$form_state) {
-
-  $name =  array_key_exists('name', $form_state['values'])       ? trim($form_state['values']['name']) : '';
-  $desc =  array_key_exists('definition', $form_state['values']) ? trim($form_state['values']['definition']) : '';
-
-  $values = array(
-    'name' => $name,
-    'definition' => $desc,
-  );
-  $success = chado_insert_record('cv', $values);
-  if ($success) {
-    drupal_set_message(t("Controlled vocabulary added"));
-  }
-  else {
-    drupal_set_message(t("Failed to add controlled vocabulary."));
-  }
-}
-
-/**
- * Submit cv edit form
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cv_edit_form_submit($form, &$form_state) {
-  $name  = array_key_exists('name', $form_state['values'])       ? trim($form_state['values']['name']) : '';
-  $desc  = array_key_exists('definition', $form_state['values']) ? trim($form_state['values']['definition']) : '';
-  $cv_id = array_key_exists('cv_id', $form_state['values'])      ? trim($form_state['values']['cv_id']) : '';
-  $op    = array_key_exists('op', $form_state['values'])         ? trim($form_state['values']['op']) : '';
-
-  $values = array(
-    'name' => $name,
-    'definition' => $desc,
-  );
-  if (strcmp($op, 'Update')==0) {
-    $match = array('cv_id' => $cv_id);
-    $success = chado_update_record('cv', $match, $values);
-    if ($success) {
-      drupal_set_message(t("Controlled vocabulary updated"));
-    }
-    else {
-      drupal_set_message(t("Failed to update controlled vocabulary."));
-    }
-  }
-  if (strcmp($op, 'Delete')==0) {
-    $match = array('cv_id' => $cv_id);
-    $success = chado_delete_record('cv', $match);
-    if ($success) {
-      drupal_set_message(t("Controlled vocabulary deleted"));
-    }
-    else {
-      drupal_set_message(t("Failed to delete controlled vocabulary."));
-    }
-  }
-}
-
-/**
- * Ajax callback for the tripal_cv_form
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_edit_form_ajax($form, $form_state) {
-
-  $elements = array();
-
-  // add in the form fields and the buttons
-  if (array_key_exists('cv_id', $form_state['values'])) {
-    $elements['fields'] = $form['fields'];
-    $elements['update'] = $form['update'];
-    $elements['delete'] = $form['delete'];
-  }
-
-   // add back in the cv-edit-div that is used for the next round of AJAX
-  $elements['fields']['#prefix'] =  '<div id="cv-edit-div">';
-  $elements['fields']['#suffix'] =  '</div">';
-
-  // reset the values for the fields to the defaults
-  $elements['fields']['name']['#value']        = $elements['fields']['name']['#default_value'];
-  $elements['fields']['definition']['#value']  = $elements['fields']['definition']['#default_value'];
-
-  //drupal_set_message('<pre>' . print_r($elements, TRUE) . '</pre>', "status");
 
-  return $elements;
-}

+ 0 - 474
legacy/tripal_cv/includes/tripal_cv.cvterm_form.inc

@@ -3,477 +3,3 @@
  * @file
  * Provides a form for creating & editing chado controlled vocabularies
  */
-
-/**
- * Form for editing cvterms
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvterm_edit_form($form, &$form_state) {
-
-  $step = 0;
-  if (empty($form_state['storage']['step'])) {
-    $form_state['storage']['step'] = 0;
-  }
-  else {
-    $step = $form_state['storage']['step'];
-  }
-
-  $cv_id = 0;
-  if ($step == 1) {
-    $cv_id = $form_state['storage']['cv_id'];
-    $cvterm_name = $form_state['storage']['name'];
-    $cvterm_id = $form_state['storage']['cvterm_id'];
-  }
-  // get the cv if form was submitted via AJAX
-  $cvterm = '';
-  if (array_key_exists('values', $form_state)) {
-    $cv_id = $form_state['values']['cv_id'];
-    if (array_key_exists('cvterm', $form_state['values'])) {
-      $cvterm = $form_state['values']['cvterm'];
-    }
-  }
-  elseif (isset($form_state['build_info']['args'][0])) {
-    $cv_id = $form_state['build_info']['args'][0];
-    $cvterm_id = $form_state['build_info']['args'][1];
-    if ($form_state['build_info']['args'][1]) {
-      $result = db_select('chado.cvterm','c')
-        ->fields('c', array('name'))
-        ->condition('c.cvterm_id',$cvterm_id)
-        ->execute();
-      $cvterm_name = $result->fetchObject()->name;
-      $step = 1;
-    }
-  }
-
-  // get a list of CVs
-  $cvs = array();
-  $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
-  $results = chado_query($sql);
-  $cvs[] = 'Select a vocabulary';
-  foreach ($results as $cv) {
-    $cvs[$cv->cv_id] = $cv->name;
-  }
-  $form['cv_id'] = array(
-    '#title' => t('Controlled Vocabulary (Ontology) Name'),
-    '#type' => 'select',
-    '#options' => $cvs,
-    '#required' => TRUE,
-    '#default_value' => $cv_id,
-    '#ajax' => array(
-       'callback'    => 'tripal_cv_cvterm_edit_form_ajax',
-       'wrapper' => 'cvterm-edit-div',
-       'event'   => 'change',
-       'method'  => 'replace',
-       'event'    => 'change',
-    ),
-  );
-
-  if ($cv_id and $step == 0) {
-
-    $form['name']= array(
-      '#type'          => 'textfield',
-      '#title'         => t("Term Name"),
-      '#default_value' => $cvterm,
-      '#required'      => TRUE,
-      '#autocomplete_path' => "admin/tripal/tripal_cv/cvterm/auto_name/$cv_id",
-      '#description'   => t('Enter the term to edit.')
-    );
-    $form['continue']= array(
-      '#type'          => 'submit',
-      '#value'         => 'continue',
-    );
-  }
-  elseif ($step == 1) {
-
-    tripal_cv_add_cvterm_form_fields($form, $form_state, $cv_id, $cvterm_name);
-
-    // when editing there are certain fields the user should not change for a term
-    // let's mark those as disabled
-    $form['cv_id']['#disabled'] = TRUE;
-    $form['fields']['db_id']['#disabled'] = TRUE;
-    $form['fields']['accession']['#disabled'] = TRUE;
-
-    // add in the div for replacing the fields if needed
-    $form['fields']['#prefix'] = '<div id="cvterm-edit-div">';
-    $form['fields']['#suffix'] = '</div>';
-
-    // add in the cvterm id
-    $form['fields']['cvterm_id'] = array(
-      '#type' => 'hidden',
-      '#value' =>  $cvterm_id,
-    );
-
-    $form['update'] = array(
-      '#type'         => 'submit',
-      '#value'        => t('Update'),
-    );
-    $form['delete'] = array(
-      '#type'         => 'submit',
-      '#value'        => t('Delete'),
-      '#attributes'   => array('onclick' => 'if(!confirm("Really Delete?")){return false;}'),
-    );
-  }
-
-  if ($step == 0) {
-    // if we don't have a cv_id then this is the first time the form has
-    // benn loaded and we need to create the div where ajax replacement elements get stored
-    $form['div_replace'] = array(
-      '#type' => 'item',
-      '#prefix' => '<div id="cvterm-edit-div">',
-      '#suffix' => '</div>',
-    );
-  }
-  return $form;
-}
-
-/**
- * Form for adding cvterms
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvterm_add_form($form, &$form_state) {
-  $cv_id = 0;
-  if (array_key_exists('values', $form_state)) {
-    $cv_id = $form_state['values']['cv_id'];
-  }
-  elseif (isset($form_state['build_info']['args'][0])) {
-    $cv_id = $form_state['build_info']['args'][0];
-  }
-
-  // get a list of CVs
-  $cvs = array();
-  $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
-  $results = chado_query($sql);
-  $cvs[] = 'Select a vocabulary';
-  foreach ($results as $cv) {
-    $cvs[$cv->cv_id] = $cv->name;
-  }
-  $form['cv_id'] = array(
-    '#title' => t('Controlled Vocabulary (Ontology) Name'),
-    '#type' => 'select',
-    '#options' => $cvs,
-    '#required' => TRUE,
-    '#default_value' => $cv_id,
-  );
-  tripal_cv_add_cvterm_form_fields($form, $form_state);
-
-  $form['add'] = array(
-    '#type'         => 'submit',
-    '#value'        => t('Add Term'),
-  );
-
-  return $form;
-}
-
-/**
- * Form fields in common between add/edit forms
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_add_cvterm_form_fields(&$form, $form_state, $cv_id = 0, $cvterm_name = '') {
-
-  $name = '';
-  $definition = '';
-  $is_relationship = '';
-  $is_obsolete = '';
-  $db_id = '';
-  $accession = '';
-
-  // get default values
-  if ($cvterm_name) {
-    $values = array('cv_id' => $cv_id, 'name' => $cvterm_name);
-    $cvterm = chado_generate_var('cvterm', $values);
-    $name = $cvterm->name;
-    $definition = $cvterm->definition;
-    $is_relationship = $cvterm->is_relationshiptype;
-    $is_obsolete = $cvterm->is_obsolete;
-    $db_id = $cvterm->dbxref_id->db_id->db_id;
-    $accession = $cvterm->dbxref_id->accession;
-  }
-
-  // add a fieldset for the Drupal Schema API
-  $form['fields'] = array(
-    '#type' => 'fieldset',
-    '#title' => 'Term Details',
-    '#collapsible' => 0,
-  );
-
-  $form['fields']['name']= array(
-    '#type'          => 'textfield',
-    '#title'         => t("Term Name"),
-    '#default_value' => $name,
-    '#description'   => t('The term must be unique within the database selected below.'),
-    '#required'      => TRUE,
-  );
-
-  $form['fields']['internal_id']= array(
-    '#type'          => 'item',
-    '#title'         => t("Internal ID"),
-    '#markup'        => $cvterm->cvterm_id,
-  );
-
-  $form['fields']['definition']= array(
-    '#type'          => 'textarea',
-    '#title'         => t('Description'),
-    '#description'   => t('Please enter a description for this term'),
-    '#default_value' => $definition,
-  );
-
-  $form['fields']['is_relationship'] = array(
-    '#type'          => 'checkbox',
-    '#title'         => t('This term describes a relationship?'),
-    '#default_value' => $is_relationship,
-  );
-
-  $form['fields']['is_obsolete'] = array(
-    '#type'          => 'checkbox',
-    '#title'         => t('This term is obsolete?'),
-    '#default_value' => $is_obsolete,
-  );
-
-  $values = array();
-  $columns = array('db_id', 'name');
-  $options = array('order_by' => array('name' => 'ASC'));
-  $results = chado_select_record('db', $columns, $values, $options);
-  $dbs = array();
-  $dbs[] = '';
-  foreach ($results as $db) {
-    $dbs[$db->db_id] = $db->name;
-  }
-  $form['fields']['db_id'] = array(
-    '#type'         => 'select',
-    '#title'         => t('Database'),
-    '#description'   => t('All terms must be assocated with a database. If there is no database for this term (e.g. it is a custom term specific to this site) then select the database \'null\' or consider creating a database specific for your site and use that anytime you would like to add terms.'),
-    '#options'      => $dbs,
-    '#default_value' => $db_id,
-    '#required' => TRUE,
-  );
-
-  $form['fields']['accession']= array(
-    '#type'          => 'textfield',
-    '#title'         => t("Accession"),
-    '#description'   => t('If this term has an existing accession (unique identifier) in the database
-       please enter that here.  If the accession is numeric with a database prefix (e.g. GO:003023), please
-       enter just the numeric value.  The database prefix will be appended whenever the term is displayed.
-       If you do not have a numeric value consider entering the term name as the accession.'),
-    '#required'      => TRUE,
-    '#default_value' => $accession,
-  );
-}
-
-/**
- * Validate cvterm edit form
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvterm_edit_form_validate($form, &$form_state) {
-  $cv_id = array_key_exists('cv_id', $form_state['values']) ? $form_state['values']['cv_id'] : '';
-  $db_id = array_key_exists('db_id', $form_state['values']) ? $form_state['values']['db_id'] : '';
-  $name = array_key_exists('name', $form_state['values']) ? $form_state['values']['name'] : '';
-  $cvterm_id = array_key_exists('cvterm_id', $form_state['values']) ? $form_state['values']['cvterm_id'] : '';
-  $accession = array_key_exists('accession', $form_state['values']) ? $form_state['values']['accession'] : '';
-
-  $step = $form_state['storage']['step'];
-
-  // make sure the cv term name is unique for this vocabulary
-  if ($step == 1) {
-    $values = array('name' => $name, 'cv_id' => $cv_id);
-    $results = chado_select_record('cvterm', array('cvterm_id'), $values);
-    foreach ($results as $r) {
-      if ($r->cvterm_id != $cvterm_id) {
-        form_set_error('name', 'The term name must be unique for this vocabulary. Another term with this name already exists.');
-      }
-    }
-  }
-}
-
-/**
- * Validate cv add form
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvterm_add_form_validate($form, &$form_state) {
-  $cv_id = array_key_exists('cv_id', $form_state['values']) ? $form_state['values']['cv_id'] : '';
-  $db_id = array_key_exists('db_id', $form_state['values']) ? $form_state['values']['db_id'] : '';
-  $name = array_key_exists('name', $form_state['values']) ? $form_state['values']['name'] : '';
-  $accession = array_key_exists('accession', $form_state['values']) ? $form_state['values']['accession'] : '';
-
-  $values = array('cv_id' => $cv_id);
-  $results = chado_select_record('cv', array('name'), $values);
-  if (!$results or count($results) == 0) {
-    form_set_error('cv_id', 'The controlled vocabulary does not exist');
-  }
-
-  // make sure the DB exists
-  $values = array('db_id' => $db_id);
-  $results = chado_select_record('db', array('name'), $values);
-  if (!$results or count($results) == 0) {
-    form_set_error('db_id', 'The database name does not exist');
-  }
-
-  // make sure the cv term name is unique for this vocabulary
-  $values = array('name' => $name, 'cv_id' => $cv_id);
-  $results = chado_select_record('cvterm', array('cvterm_id'), $values);
-  if (count($results) > 0) {
-    form_set_error('name', 'The term name must be unique for this vocabulary. Another term with this name already exists.');
-  }
-
-  // make sure this accession is unique for the database
-  $values = array('accession' => $accession, 'db_id' => $db_id);
-  $results = chado_select_record('dbxref', array('dbxref_id'), $values);
-  if (count($results) > 0 ) {
-    form_set_error('accession', 'The accession is not uniuqe for this vocabulary\'s database.');
-  }
-
-}
-
-/**
- * Edits existing controlled vocabulary terms
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvterm_edit_form_submit($form, &$form_state) {
-
-  $cv_id           = array_key_exists('cv_id', $form_state['values'])           ? trim($form_state['values']['cv_id']) : '';
-  $name            = array_key_exists('name', $form_state['values'])            ? trim($form_state['values']['name']) : '';
-  $definition      = array_key_exists('definition', $form_state['values'])      ? trim($form_state['values']['definition']) : '';
-  $is_relationship = array_key_exists('is_relationship', $form_state['values']) ? trim($form_state['values']['is_relationship']) : '';
-  $is_obsolete     = array_key_exists('is_obsolete', $form_state['values'])     ? trim($form_state['values']['is_obsolete']) : '';
-  $cvterm_id       = array_key_exists('cvterm_id', $form_state['values'])       ? trim($form_state['values']['cvterm_id']) : '';
-  $db_id           = array_key_exists('db_id', $form_state['values'])           ? trim($form_state['values']['db_id']) : '';
-  $accession       = array_key_exists('accession', $form_state['values'])       ? trim($form_state['values']['accession']) : '';
-  $op              = array_key_exists('op', $form_state['values'])              ? trim($form_state['values']['op']) : '';
-
-
-  $step = $form_state['storage']['step'];
-
-  switch ($step) {
-    case 0:  // a cvterm name has been selected
-      $cv_id = array_key_exists('cv_id', $form_state['values']) ? trim($form_state['values']['cv_id']) : '';
-      $name  = array_key_exists('name', $form_state['values'])  ? trim($form_state['values']['name'])  : '';
-
-      // get the original cvterm_id
-      $values = array('name' => $name, 'cv_id' => $cv_id);
-      $results = chado_select_record('cvterm', array('cvterm_id'), $values);
-      $cvterm = $results[0];
-
-      $form_state['storage']['cv_id'] = $cv_id;
-      $form_state['storage']['name'] = $name;
-      $form_state['storage']['step'] = 1;
-      $form_state['storage']['cvterm_id'] = $cvterm->cvterm_id;
-      $form_state['rebuild'] = TRUE;
-      break;
-
-    case 1:  // update/delete button has been clicked
-
-      if ($op == 'Update') {
-        // get the cv
-        $values = array('cv_id' => $cv_id);
-        $results = chado_select_record('cv', array('name'), $values);
-        $cv = $results[0];
-
-        // get the db
-        $values = array('db_id' => $db_id);
-        $results = chado_select_record('db', array('name'), $values);
-        $db = $results[0];
-
-        // now add the term
-        $term = array(
-          'name' => $name,
-          'namespace' => $cv->name,
-          'id' => $accession,
-          'definition' => $definition,
-          'is_obsolete' => $is_obsolete,
-          'cv_name' => $cv->name,
-          'is_relationship' => $is_relationship,
-          'db_name' => $db_name
-        );
-
-        $cvterm = tripal_insert_cvterm($term, array('update_existing' => TRUE));
-        if ($cvterm) {
-          drupal_set_message('Term updated successfully.');
-        }
-        else {
-          drupal_set_message('Could not add term. Check Drupal recent logs for error messages.', 'error');
-        }
-      }
-      if ($op == 'Delete') {
-        $values = array('cvterm_id' => $cvterm_id);
-        $success = chado_delete_record('cvterm', $values);
-        if ($success) {
-          drupal_set_message('Term deleted successfully.');
-        }
-        else {
-          drupal_set_message('Could not delete term term. Check Drupal recent logs for error messages.', 'error');
-        }
-      }
-      break;
-  }
-}
-
-/**
- * Adds new terms to an existing cv
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvterm_add_form_submit($form, &$form_state) {
-  $cv_id = array_key_exists('cv_id', $form_state['values']) ? $form_state['values']['cv_id'] : '';
-  $name = array_key_exists('name', $form_state['values']) ? $form_state['values']['name'] : '';
-  $definition = array_key_exists('definition', $form_state['values']) ? $form_state['values']['definition'] : '';
-  $is_relationship = array_key_exists('is_relationship', $form_state['values']) ? $form_state['values']['is_relationship'] : '';
-  $is_obsolete = array_key_exists('is_obsolete', $form_state['values']) ? $form_state['values']['is_obsolete'] : '';
-
-  $db_id = array_key_exists('db_id', $form_state['values']) ? $form_state['values']['db_id'] : '';
-  $accession = array_key_exists('accession', $form_state['values']) ? $form_state['values']['accession'] : '';
-
-  // get the database
-  $values = array('db_id' => $db_id);
-  $results = chado_select_record('db', array('name'), $values);
-  $db = $results[0];
-
-  // get the cv
-  $values = array('cv_id' => $cv_id);
-  $results = chado_select_record('cv', array('name'), $values);
-  $cv = $results[0];
-
-  // now add the term
-  $term = array(
-    'name' => $name,
-    'namespace' => $cv->name,
-    'id' => $accession,
-    'definition' => $definition,
-    'is_obsolete' => $is_obsolete,
-    'cv_name' => $cv->name,
-    'is_relationship' => $is_relationship,
-    'db_name' => $db->name
-  );
-
-  $cvterm = tripal_insert_cvterm($term, array('update_existing' => TRUE));
-  if ($cvterm) {
-    drupal_set_message('Term added successfully.');
-  }
-  else {
-    drupal_set_message('Could not add term. Check Drupal recent logs for error messages.', 'error');
-  }
-}
-
-/**
- * Ajax callback for the tripal_cv_form
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvterm_edit_form_ajax($form, $form_state) {
-
-  $elements = array();
-
-  $elements['name'] = $form['name'];
-  $elements['continue'] = $form['continue'];
-
-  // add back in the cv-edit-div that is used for the next round of AJAX
-  $elements['name']['#prefix'] =  '<div id="cvterm-edit-div">';
-  $elements['name']['#suffix'] =  '</div">';
-
-
-  return $elements;
-}

+ 0 - 68
legacy/tripal_cv/includes/tripal_cv.cvtermpath_form.inc

@@ -1,68 +0,0 @@
-<?php
-/**
- * @file
- * Provides a form for updating controlled vocabularies path
- */
-
-/**
- * Form for re-doing the cvterm path
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvtermpath_form() {
-
-  // get a list of db from chado for user to choose
-  $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
-  $results = chado_query($sql);
-
-  $cvs = array();
-  $cvs[] = '';
-  foreach ($results as $cv) {
-    $cvs[$cv->cv_id] = $cv->name;
-  }
-
-  $form['cvid'] = array(
-    '#title' => t('Controlled Vocabulary/Ontology Name'),
-    '#type' => 'select',
-    '#options' => $cvs,
-    '#description' => t('The Chado cvtermpath is a database table that provides lineage for ontology terms
-      and is useful for quickly finding any ancestor parent of a term.  This table must be populated for each
-      ontology.  Select a controlled vocabulary for which you would like to upate the cvtermpath.'),
-  );
-
-  $form['description'] = array(
-    '#type' => 'item',
-    '#value' => t("Submit a job to update chado cvtermpath table."),
-    '#weight' => 1,
-  );
-
-  $form['button'] = array(
-    '#type' => 'submit',
-    '#value' => t('Update cvtermpath'),
-    '#weight' => 2,
-  );
-
-  return $form;
-}
-
-/**
- * Cvterm path form submit
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_cvtermpath_form_submit($form, &$form_state) {
-  global $user;
-
-  $cvid =  $form_state['values']['cvid'];
-
-  // first get the controlled vocabulary name:
-  $sql = "SELECT * FROM {cv} WHERE cv_id = :cv_id";
-  $cv = chado_query($sql, array(':cv_id' => $cvid))->fetchObject();
-
-  // Submit a job to update cvtermpath
-  $job_args = array($cvid);
-  if ($form_state['values']['op'] == t('Update cvtermpath')) {
-    tripal_add_job("Update cvtermpath: $cv->name", 'tripal_cv',
-       'tripal_cv_update_cvtermpath', $job_args, $user->uid);
-  }
-}

+ 1 - 1
legacy/tripal_cv/theme/templates/tripal_cv_help.tpl.php

@@ -15,7 +15,7 @@
    users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
 
       <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')
+        print l('Admin->Tripal Management->Tripal CV->Load Ontology With OBO File', 'admin/tripal/loaders/chado_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
         ontologies is using a URL ensuring you get the most up to date ontology.</p>

+ 2 - 2
legacy/tripal_cv/tripal_cv.info

@@ -3,9 +3,9 @@ description = Supports the Controlled Vocabulary (CV) tables of Chado by providi
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-rc1
 configure = admin/tripal/vocab
 
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_db

+ 45 - 0
legacy/tripal_cv/tripal_cv.install

@@ -58,4 +58,49 @@ function tripal_cv_install() {
  */
 function tripal_cv_uninstall() {
 
+}
+
+/**
+ * Implements hook_schema().
+ */
+function tripal_cv_schema() {
+  $schema['tripal_cv_defaults'] = tripal_chado_tripal_cv_defaults_schema();
+  return $schema;
+}
+
+/**
+ * * Table definition for the tripal_cv_defaults table
+ * @param unknown $schema
+ */
+function tripal_chado_tripal_cv_defaults_schema() {
+  return array(
+    'fields' => array(
+      'cv_default_id' => array(
+        'type' => 'serial',
+        'unsigned' => TRUE,
+        'not null' => TRUE
+      ),
+      'table_name' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+      ),
+      'field_name' => array(
+        'type' => 'varchar',
+        'length' => 128,
+        'not null' => TRUE,
+      ),
+      'cv_id' => array(
+        'type' => 'int',
+        'not null' => TRUE,
+      )
+    ),
+    'indexes' => array(
+      'tripal_cv_defaults_idx1' => array('table_name', 'field_name'),
+    ),
+    'unique keys' => array(
+      'tripal_cv_defaults_unq1' => array('table_name', 'field_name', 'cv_id'),
+    ),
+    'primary key' => array('cv_default_id')
+  );
 }

+ 27 - 37
legacy/tripal_cv/tripal_cv.module

@@ -15,11 +15,11 @@
  */
 
 require_once 'api/tripal_cv.DEPRECATED.inc';
-
+require_once 'api/tripal_cv.api.inc';
 require_once 'includes/tripal_cv.admin.inc';
 require_once 'includes/tripal_cv.cv_form.inc';
+require_once 'includes/tripal_cv.cv_defaults.inc';
 require_once 'includes/tripal_cv.cvterm_form.inc';
-require_once 'includes/tripal_cv.cvtermpath_form.inc';
 
 /**
  * Implements hook_init().
@@ -40,7 +40,7 @@ function tripal_cv_init() {
 function tripal_cv_menu() {
   $items = array();
 
- /*  $items['admin/tripal/vocab'] = array(
+   $items['admin/tripal/legacy/vocab'] = array(
     'title' => 'Controlled Vocabularies',
     'description' => 'Controlled Vocabularies control the types available for entities and fields.',
     'page callback' => 'tripal_cv_admin_cv_listing',
@@ -49,17 +49,8 @@ function tripal_cv_menu() {
     'weight' => 2,
   );
 
-  $items['admin/tripal/vocab/defaults'] = array(
-    'title' => 'Defaults',
-    'description' => 'Set the default vocabularies for properties and relationships.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_cv_admin_set_defaults_form'),
-    'access arguments' => array('administer controlled vocabularies'),
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 5
-  );
 
-  $items['admin/tripal/vocab/help'] = array(
+  $items['admin/tripal/legacy/vocab/help'] = array(
     'title' => 'Help',
     'description' => "A description of the Tripal Controlled Vocabulary module including a short description of it's usage.",
     'page callback' => 'theme',
@@ -69,16 +60,7 @@ function tripal_cv_menu() {
     'weight' => 10
   );
 
-  $items['admin/tripal/vocab/cvtermpath'] = array(
-    'title' => 'Update Chado cvtermpath table',
-    'description' => 'The Chado cvtermpath table provides lineage for terms and is useful for quickly finding any ancestor parent of a term.  However, this table must be populated.  This page allows for populating of this table one vocabulary at a time',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_cv_cvtermpath_form'),
-    'access arguments' => array('administer controlled vocabularies'),
-    'type' => MENU_CALLBACK,
-  );
-
-  $items['admin/tripal/vocab/cv/edit/%'] = array(
+  $items['admin/tripal/legacy/vocab/cv/edit/%'] = array(
     'title' => 'Edit a Controlled Vocabulary',
     'description' => 'Edit the details such as name and description for an existing controlled vocabulary.',
     'page callback' => 'drupal_get_form',
@@ -88,7 +70,7 @@ function tripal_cv_menu() {
     'type' => MENU_CALLBACK,
   );
 
-  $items['admin/tripal/vocab/cv/add'] = array(
+  $items['admin/tripal/legacy/vocab/cv/add'] = array(
     'title' => 'Add a Controlled Vocabulary',
     'description' => 'Manually a new controlled vocabulary.',
     'page callback' => 'drupal_get_form',
@@ -98,7 +80,7 @@ function tripal_cv_menu() {
     'type' => MENU_CALLBACK,
   );
 
-  $items['admin/tripal/vocab/cv/%/cvterm/add'] = array(
+  $items['admin/tripal/legacy/vocab/cv/%/cvterm/add'] = array(
     'title' => 'Add a Controlled Vocabulary Term',
     'description' => 'Add a new controlled vocabulary term.',
     'page callback' => 'drupal_get_form',
@@ -106,7 +88,7 @@ function tripal_cv_menu() {
     'access arguments' => array('administer controlled vocabularies'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/tripal/vocab/cvterm/add'] = array(
+  $items['admin/tripal/legacy/vocab/cvterm/add'] = array(
     'title' => 'Add a Controlled Vocabulary Term',
     'description' => 'Add a new controlled vocabulary term.',
     'page callback' => 'drupal_get_form',
@@ -114,7 +96,7 @@ function tripal_cv_menu() {
     'access arguments' => array('administer controlled vocabularies'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/tripal/vocab/cv/%/cvterm/edit/%'] = array(
+  $items['admin/tripal/legacy/vocab/cv/%/cvterm/edit/%'] = array(
     'title' => 'Edit a Controlled Vocabulary Term',
     'description' => 'Edit an existing controlled vocabulary term.',
     'page callback' => 'drupal_get_form',
@@ -122,28 +104,37 @@ function tripal_cv_menu() {
     'access arguments' => array('administer controlled vocabularies'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/tripal/vocab/cvterm/auto_name/%/%'] = array(
-    'page callback' => 'tripal_cv_cvterm_name_autocomplete',
+  $items['admin/tripal/legacy/vocab/cvterm/auto_name/%/%'] = array(
+    'page callback' => 'tripal_autocomplete_cvterm',
     'page arguments' => array(6, 7),
     'access arguments' => array('administer controlled vocabularies'),
     'type' => MENU_CALLBACK,
   );
 
-  $items['admin/tripal/vocab/views/cvs/enable'] = array(
+  $items['admin/tripal/legacy/vocab/views/cvs/enable'] = array(
     'title' => 'Enable Vocabulary Administrative View',
     'page callback' => 'tripal_enable_view',
     'page arguments' => array('tripal_cv_admin_cvs', 'admin/tripal/vocab'),
     'access arguments' => array('administer controlled vocabularies'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/tripal/vocab/views/cvterms/enable'] = array(
+  $items['admin/tripal/legacy/vocab/views/cvterms/enable'] = array(
     'title' => 'Enable Vocabulary Terms Administrative View',
     'page callback' => 'tripal_enable_view',
     'page arguments' => array('tripal_cv_admin_cvterms', 'admin/tripal/vocab'),
     'access arguments' => array('administer controlled vocabularies'),
     'type' => MENU_CALLBACK,
   );
- */
+
+  $items['admin/tripal/legacy/chado/tripal_cv/defaults'] = array(
+    'title' => 'Defaults',
+    'description' => 'Set the default vocabularies for properties and relationships.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_cv_admin_set_defaults_form'),
+    'access arguments' => array('administer controlled vocabularies'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 5
+  );
 
   $items['tripal_cv_chart'] = array(
     'path' => 'tripal_cv_chart',
@@ -283,11 +274,10 @@ function tripal_cv_theme($existing, $type, $theme, $path) {
       'variables' =>  array(NULL),
       'path' => "$path/theme/templates"
     ),
-    // Default CV form
-    'tripal_cv_admin_set_defaults_form' => array(
-      'function' => 'theme_tripal_cv_admin_set_defaults_form',
-      'render element' => 'element',
-    ),
+   'tripal_cv_admin_set_defaults_form' => array(
+     'function' => 'theme_tripal_cv_admin_set_defaults_form',
+     'render element' => 'element',
+   ),
   );
 
   return $items;

+ 0 - 447
legacy/tripal_cv/tripal_cv.views_default.inc

@@ -12,454 +12,7 @@
 function tripal_cv_views_default_views() {
   $views = array();
 
-  // Default Tripal Admin View: CVs
-  $view = tripal_cv_defaultview_admin_cvs_listing();
-  $view = tripal_make_view_compatible_with_external($view);
-  $views[$view->name] = $view;
-
-  // Default Tripal Admin View: CV Terms
-  $view = tripal_cv_defaultview_admin_cvterms_listing();
-  $view = tripal_make_view_compatible_with_external($view);
-  $views[$view->name] = $view;
-
   return $views;
 }
 
-/**
- * Default Admin View for cv management
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_defaultview_admin_cvs_listing() {
-
-  $view = new view();
-  $view->name = 'tripal_cv_admin_cvs';
-  $view->description = 'DO NOT DISABLE';
-  $view->tag = 'tripal admin';
-  $view->base_table = 'cv';
-  $view->human_name = 'CVs Admin';
-  $view->core = 6;
-  $view->api_version = '3.0';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-
-  /* Display: Defaults */
-  $handler = $view->new_display('default', 'Defaults', 'default');
-  $handler->display->display_options['title'] = 'Controlled Vocabularies';
-  $handler->display->display_options['use_more_always'] = FALSE;
-  $handler->display->display_options['access']['type'] = 'perm';
-  $handler->display->display_options['access']['perm'] = 'administer controlled vocabularies';
-  $handler->display->display_options['cache']['type'] = 'none';
-  $handler->display->display_options['query']['type'] = 'views_query';
-  $handler->display->display_options['exposed_form']['type'] = 'input_required';
-  $handler->display->display_options['exposed_form']['options']['submit_button'] = 'Search';
-  $handler->display->display_options['exposed_form']['options']['text_input_required'] = 'Click search to see a listing of controlled vocabularies that meet the filter requirements. Use the filters to restrict this set to a more reasonable number of vocabularies or to find a specific vocabulary.';
-  $handler->display->display_options['exposed_form']['options']['text_input_required_format'] = 'full_html';
-  $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['pager']['options']['items_per_page'] = '25';
-  $handler->display->display_options['pager']['options']['offset'] = '0';
-  $handler->display->display_options['pager']['options']['id'] = '0';
-  $handler->display->display_options['pager']['options']['quantity'] = '9';
-  $handler->display->display_options['style_plugin'] = 'table';
-  $handler->display->display_options['style_options']['grouping'] = '';
-  $handler->display->display_options['style_options']['columns'] = array(
-    'name' => 'name',
-    'definition' => 'definition',
-    'nothing' => 'nothing',
-  );
-  $handler->display->display_options['style_options']['default'] = 'name';
-  $handler->display->display_options['style_options']['info'] = array(
-    'name' => array(
-      'sortable' => 1,
-      'separator' => '',
-    ),
-    'definition' => array(
-      'sortable' => 0,
-      'separator' => '',
-    ),
-    'nothing' => array(
-      'separator' => '',
-    ),
-  );
-/* Header: Global: Action Links */
-  $handler->display->display_options['header']['action_links_area']['id'] = 'action_links_area';
-  $handler->display->display_options['header']['action_links_area']['table'] = 'views';
-  $handler->display->display_options['header']['action_links_area']['field'] = 'action_links_area';
-  $handler->display->display_options['header']['action_links_area']['label'] = 'Action Links';
-  $handler->display->display_options['header']['action_links_area']['empty'] = TRUE;
-  $handler->display->display_options['header']['action_links_area']['link-1'] = array(
-    'label-1' => 'Add Vocabulary',
-    'path-1' => 'admin/tripal/vocab/cv/add',
-  );
-  $handler->display->display_options['header']['action_links_area']['link-2'] = array(
-    'label-2' => 'Load Ontology',
-    'path-2' => 'admin/tripal/vocab/obo_loader',
-  );
-  /* No results behavior: Global: Text area */
-  $handler->display->display_options['empty']['text']['id'] = 'area';
-  $handler->display->display_options['empty']['text']['table'] = 'views';
-  $handler->display->display_options['empty']['text']['field'] = 'area';
-  $handler->display->display_options['empty']['text']['content'] = 'No controlled vocabularies match the supplied criteria.';
-  $handler->display->display_options['empty']['text']['format'] = '2';
-  /* Field: Chado Cv: Cv Id */
-  $handler->display->display_options['fields']['cv_id']['id'] = 'cv_id';
-  $handler->display->display_options['fields']['cv_id']['table'] = 'cv';
-  $handler->display->display_options['fields']['cv_id']['field'] = 'cv_id';
-  $handler->display->display_options['fields']['cv_id']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['cv_id']['separator'] = '';
-  /* Field: Chado Cv: Name */
-  $handler->display->display_options['fields']['name']['id'] = 'name';
-  $handler->display->display_options['fields']['name']['table'] = 'cv';
-  $handler->display->display_options['fields']['name']['field'] = 'name';
-  /* Field: Chado Cv: Definition */
-  $handler->display->display_options['fields']['definition']['id'] = 'definition';
-  $handler->display->display_options['fields']['definition']['table'] = 'cv';
-  $handler->display->display_options['fields']['definition']['field'] = 'definition';
-  /* Field: Global: Custom text */
-  $handler->display->display_options['fields']['nothing_1']['id'] = 'nothing_1';
-  $handler->display->display_options['fields']['nothing_1']['table'] = 'views';
-  $handler->display->display_options['fields']['nothing_1']['field'] = 'nothing';
-  $handler->display->display_options['fields']['nothing_1']['label'] = 'Edit Link';
-  $handler->display->display_options['fields']['nothing_1']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['nothing_1']['alter']['text'] = 'edit';
-  $handler->display->display_options['fields']['nothing_1']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/vocab/cv/edit/[cv_id]';
-  /* Field: Global: Custom text */
-  $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
-  $handler->display->display_options['fields']['nothing']['table'] = 'views';
-  $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
-  $handler->display->display_options['fields']['nothing']['label'] = 'View Terms link';
-  $handler->display->display_options['fields']['nothing']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['nothing']['alter']['text'] = 'View Terms';
-  $handler->display->display_options['fields']['nothing']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing']['alter']['path'] = 'admin/tripal/vocab/cvterms?cv=[name]';
-  $handler->display->display_options['fields']['nothing']['hide_alter_empty'] = TRUE;
-  /* Field: Global: Custom text */
-  $handler->display->display_options['fields']['nothing_3']['id'] = 'nothing_3';
-  $handler->display->display_options['fields']['nothing_3']['table'] = 'views';
-  $handler->display->display_options['fields']['nothing_3']['field'] = 'nothing';
-  $handler->display->display_options['fields']['nothing_3']['label'] = 'Add term';
-  $handler->display->display_options['fields']['nothing_3']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['nothing_3']['alter']['text'] = 'Add Term';
-  $handler->display->display_options['fields']['nothing_3']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing_3']['alter']['path'] = 'admin/tripal/vocab/cv/[cv_id]/cvterm/add';
-  /* Field: Global: Custom text */
-  $handler->display->display_options['fields']['nothing_2']['id'] = 'nothing_2';
-  $handler->display->display_options['fields']['nothing_2']['table'] = 'views';
-  $handler->display->display_options['fields']['nothing_2']['field'] = 'nothing';
-  $handler->display->display_options['fields']['nothing_2']['label'] = '';
-  $handler->display->display_options['fields']['nothing_2']['alter']['text'] = '[nothing_1]<br />
-    [nothing]   [nothing_3]';
-  $handler->display->display_options['fields']['nothing_2']['element_class'] = 'short-column';
-  $handler->display->display_options['fields']['nothing_2']['element_label_class'] = 'short-column';
-  $handler->display->display_options['fields']['nothing_2']['element_label_colon'] = FALSE;
-  /* Sort criterion: Chado Cv: Name */
-  $handler->display->display_options['sorts']['name']['id'] = 'name';
-  $handler->display->display_options['sorts']['name']['table'] = 'cv';
-  $handler->display->display_options['sorts']['name']['field'] = 'name';
-  /* Filter criterion: Chado Cv: Name */
-  $handler->display->display_options['filters']['name']['id'] = 'name';
-  $handler->display->display_options['filters']['name']['table'] = 'cv';
-  $handler->display->display_options['filters']['name']['field'] = 'name';
-  $handler->display->display_options['filters']['name']['operator'] = 'contains';
-  $handler->display->display_options['filters']['name']['group'] = '0';
-  $handler->display->display_options['filters']['name']['exposed'] = TRUE;
-  $handler->display->display_options['filters']['name']['expose']['operator_id'] = 'name_op';
-  $handler->display->display_options['filters']['name']['expose']['label'] = 'Name Contains';
-  $handler->display->display_options['filters']['name']['expose']['operator'] = 'name_op';
-  $handler->display->display_options['filters']['name']['expose']['identifier'] = 'name';
-  $handler->display->display_options['filters']['name']['expose']['remember_roles'] = array(
-    2 => '2',
-    1 => 0,
-    3 => 0,
-  );
-  /* Filter criterion: Chado Cv: Definition */
-  $handler->display->display_options['filters']['definition']['id'] = 'definition';
-  $handler->display->display_options['filters']['definition']['table'] = 'cv';
-  $handler->display->display_options['filters']['definition']['field'] = 'definition';
-  $handler->display->display_options['filters']['definition']['operator'] = 'contains';
-  $handler->display->display_options['filters']['definition']['group'] = '0';
-  $handler->display->display_options['filters']['definition']['exposed'] = TRUE;
-  $handler->display->display_options['filters']['definition']['expose']['operator_id'] = 'definition_op';
-  $handler->display->display_options['filters']['definition']['expose']['label'] = 'Definition Contains';
-  $handler->display->display_options['filters']['definition']['expose']['operator'] = 'definition_op';
-  $handler->display->display_options['filters']['definition']['expose']['identifier'] = 'definition';
-  $handler->display->display_options['filters']['definition']['expose']['remember_roles'] = array(
-    2 => '2',
-    1 => 0,
-    3 => 0,
-  );
-
-  /** MANUALLY ADD since filter handler not exporting correctly */
-  $handler->display->display_options['filters']['name']['expose']['values_form_type'] = 'textfield';
-  $handler->display->display_options['filters']['name']['expose']['select_multiple'] = FALSE;
-  $handler->display->display_options['filters']['name']['expose']['select_optional'] = FALSE;
-  $handler->display->display_options['filters']['name']['expose']['max_length'] = 40;
-
-  /* Display: Page */
-  $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->display->display_options['path'] = 'admin/tripal/vocab/cvs';
-  $handler->display->display_options['menu']['type'] = 'default tab';
-  $handler->display->display_options['menu']['title'] = 'Vocabularies';
-  $handler->display->display_options['menu']['description'] = 'A listing of all controlled vocabularies';
-  $handler->display->display_options['menu']['weight'] = '-10';
-  $handler->display->display_options['menu']['name'] = 'management';
-  $handler->display->display_options['menu']['context'] = 0;
-  $handler->display->display_options['menu']['context_only_inline'] = 0;
-  $handler->display->display_options['tab_options']['weight'] = '0';
-
-
-  /** MANUALLY ADD since filter handler no exporting correctly
-  $handler->display->display_options['filters']['name']['expose']['values_form_type'] = 'textfield';
-  $handler->display->display_options['filters']['name']['expose']['select_multiple'] = FALSE;
-  $handler->display->display_options['filters']['name']['expose']['select_optional'] = FALSE;
-  $handler->display->display_options['filters']['name']['expose']['max_length'] = 40;
-  */
-
-  return $view;
-}
 
-/**
- * Default Admin View for cvterm management
- *
- * @ingroup tripal_cv
- */
-function tripal_cv_defaultview_admin_cvterms_listing() {
-
-  $view = new view();
-  $view->name = 'tripal_cv_admin_cvterms';
-  $view->description = 'DO NOT DISABLE';
-  $view->tag = 'tripal admin';
-  $view->base_table = 'cvterm';
-  $view->human_name = 'CV Terms Admin';
-  $view->core = 0;
-  $view->api_version = '3.0';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-
-  /* Display: Defaults */
-  $handler = $view->new_display('default', 'Defaults', 'default');
-  $handler->display->display_options['title'] = 'Controlled Vocabulary Terms';
-  $handler->display->display_options['use_more_always'] = FALSE;
-  $handler->display->display_options['access']['type'] = 'perm';
-  $handler->display->display_options['access']['perm'] = 'administer controlled vocabularies';
-  $handler->display->display_options['cache']['type'] = 'none';
-  $handler->display->display_options['query']['type'] = 'views_query';
-  $handler->display->display_options['exposed_form']['type'] = 'input_required';
-  $handler->display->display_options['exposed_form']['options']['submit_button'] = 'Search';
-  $handler->display->display_options['exposed_form']['options']['text_input_required'] = 'Click search to see a listing of controlled vocabulary terms that meet the filter requirements. Use the filters to restrict this set to a more reasonable number of terms or to find a specific term.';
-  $handler->display->display_options['exposed_form']['options']['text_input_required_format'] = 'full_html';
-  $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['pager']['options']['items_per_page'] = '25';
-  $handler->display->display_options['pager']['options']['offset'] = '0';
-  $handler->display->display_options['pager']['options']['id'] = '0';
-  $handler->display->display_options['pager']['options']['quantity'] = '9';
-  $handler->display->display_options['style_plugin'] = 'table';
-  $handler->display->display_options['style_options']['grouping'] = '';
-  $handler->display->display_options['style_options']['columns'] = array(
-    'name_1' => 'name_1',
-    'name' => 'name',
-    'definition' => 'definition',
-    'is_obsolete' => 'is_obsolete',
-    'is_relationshiptype' => 'is_relationshiptype',
-  );
-  $handler->display->display_options['style_options']['default'] = '-1';
-  $handler->display->display_options['style_options']['info'] = array(
-    'name_1' => array(
-      'sortable' => 1,
-      'separator' => '',
-    ),
-    'name' => array(
-      'sortable' => 1,
-      'separator' => '',
-    ),
-    'definition' => array(
-      'sortable' => 0,
-      'separator' => '',
-    ),
-    'is_obsolete' => array(
-      'sortable' => 1,
-      'separator' => '',
-    ),
-    'is_relationshiptype' => array(
-      'sortable' => 1,
-      'separator' => '',
-    ),
-  );
-/* Header: Global: Action Links */
-  $handler->display->display_options['header']['action_links_area']['id'] = 'action_links_area';
-  $handler->display->display_options['header']['action_links_area']['table'] = 'views';
-  $handler->display->display_options['header']['action_links_area']['field'] = 'action_links_area';
-  $handler->display->display_options['header']['action_links_area']['label'] = 'Action Links';
-  $handler->display->display_options['header']['action_links_area']['empty'] = TRUE;
-  $handler->display->display_options['header']['action_links_area']['link-1'] = array(
-    'label-1' => 'Add Term',
-    'path-1' => 'admin/tripal/vocab/cvterm/add',
-  );
-  /* No results behavior: Global: Text area */
-  $handler->display->display_options['empty']['text']['id'] = 'area';
-  $handler->display->display_options['empty']['text']['table'] = 'views';
-  $handler->display->display_options['empty']['text']['field'] = 'area';
-  $handler->display->display_options['empty']['text']['content'] = 'There are no terms associated with the selected controlled vocabulary. Please select a different vocabulary from the list above.';
-  $handler->display->display_options['empty']['text']['format'] = '1';
-  /* Field: Chado Cv: Cv Id */
-  $handler->display->display_options['fields']['cv_id']['id'] = 'cv_id';
-  $handler->display->display_options['fields']['cv_id']['table'] = 'cv';
-  $handler->display->display_options['fields']['cv_id']['field'] = 'cv_id';
-  $handler->display->display_options['fields']['cv_id']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['cv_id']['separator'] = '';
-  /* Field: Chado Cv: Name */
-  $handler->display->display_options['fields']['name_1']['id'] = 'name_1';
-  $handler->display->display_options['fields']['name_1']['table'] = 'cv';
-  $handler->display->display_options['fields']['name_1']['field'] = 'name';
-  $handler->display->display_options['fields']['name_1']['label'] = 'Vocabulary';
-  $handler->display->display_options['fields']['name_1']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['name_1']['alter']['path'] = 'admin/tripal/vocab/cvs?name=[name_1]';
-  /* Field: Chado Cvterm: Cvterm Id */
-  $handler->display->display_options['fields']['cvterm_id']['id'] = 'cvterm_id';
-  $handler->display->display_options['fields']['cvterm_id']['table'] = 'cvterm';
-  $handler->display->display_options['fields']['cvterm_id']['field'] = 'cvterm_id';
-  $handler->display->display_options['fields']['cvterm_id']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['cvterm_id']['separator'] = '';
-  /* Field: Chado Cvterm: Name */
-  $handler->display->display_options['fields']['name']['id'] = 'name';
-  $handler->display->display_options['fields']['name']['table'] = 'cvterm';
-  $handler->display->display_options['fields']['name']['field'] = 'name';
-  /* Field: Chado Cvterm: Definition */
-  $handler->display->display_options['fields']['definition']['id'] = 'definition';
-  $handler->display->display_options['fields']['definition']['table'] = 'cvterm';
-  $handler->display->display_options['fields']['definition']['field'] = 'definition';
-  $handler->display->display_options['fields']['definition']['element_class'] = 'wide-column';
-  $handler->display->display_options['fields']['definition']['element_label_class'] = 'wide-column';
-  /* Field: Chado Cvterm: Is Obsolete */
-  $handler->display->display_options['fields']['is_obsolete']['id'] = 'is_obsolete';
-  $handler->display->display_options['fields']['is_obsolete']['table'] = 'cvterm';
-  $handler->display->display_options['fields']['is_obsolete']['field'] = 'is_obsolete';
-  $handler->display->display_options['fields']['is_obsolete']['label'] = 'Obsolete?';
-  $handler->display->display_options['fields']['is_obsolete']['alter']['alter_text'] = TRUE;
-  $handler->display->display_options['fields']['is_obsolete']['alter']['text'] = 'Yes';
-  $handler->display->display_options['fields']['is_obsolete']['element_class'] = 'short-column';
-  $handler->display->display_options['fields']['is_obsolete']['element_label_class'] = 'short-column';
-  $handler->display->display_options['fields']['is_obsolete']['empty'] = 'No';
-  $handler->display->display_options['fields']['is_obsolete']['empty_zero'] = TRUE;
-  $handler->display->display_options['fields']['is_obsolete']['separator'] = '';
-  /* Field: Chado Cvterm: Is Relationshiptype */
-  $handler->display->display_options['fields']['is_relationshiptype']['id'] = 'is_relationshiptype';
-  $handler->display->display_options['fields']['is_relationshiptype']['table'] = 'cvterm';
-  $handler->display->display_options['fields']['is_relationshiptype']['field'] = 'is_relationshiptype';
-  $handler->display->display_options['fields']['is_relationshiptype']['label'] = 'Relation-ship?';
-  $handler->display->display_options['fields']['is_relationshiptype']['alter']['alter_text'] = TRUE;
-  $handler->display->display_options['fields']['is_relationshiptype']['alter']['text'] = 'Yes';
-  $handler->display->display_options['fields']['is_relationshiptype']['element_class'] = 'short-column';
-  $handler->display->display_options['fields']['is_relationshiptype']['element_label_class'] = 'short-column';
-  $handler->display->display_options['fields']['is_relationshiptype']['empty'] = 'No';
-  $handler->display->display_options['fields']['is_relationshiptype']['empty_zero'] = TRUE;
-  $handler->display->display_options['fields']['is_relationshiptype']['separator'] = '';
-  /* Field: Global: Custom text */
-  $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
-  $handler->display->display_options['fields']['nothing']['table'] = 'views';
-  $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
-  $handler->display->display_options['fields']['nothing']['label'] = 'Edit Link';
-  $handler->display->display_options['fields']['nothing']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['nothing']['alter']['text'] = 'edit';
-  $handler->display->display_options['fields']['nothing']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing']['alter']['path'] = 'admin/tripal/vocab/cv/[cv_id]/cvterm/edit/[cvterm_id]';
-  /* Field: Global: Custom text */
-  $handler->display->display_options['fields']['nothing_1']['id'] = 'nothing_1';
-  $handler->display->display_options['fields']['nothing_1']['table'] = 'views';
-  $handler->display->display_options['fields']['nothing_1']['field'] = 'nothing';
-  $handler->display->display_options['fields']['nothing_1']['label'] = '';
-  $handler->display->display_options['fields']['nothing_1']['alter']['text'] = '[nothing]';
-  $handler->display->display_options['fields']['nothing_1']['element_class'] = 'short-column';
-  $handler->display->display_options['fields']['nothing_1']['element_label_class'] = 'short-column';
-  $handler->display->display_options['fields']['nothing_1']['element_label_colon'] = FALSE;
-  /* Sort criterion: Chado Cv: Name */
-  $handler->display->display_options['sorts']['name']['id'] = 'name';
-  $handler->display->display_options['sorts']['name']['table'] = 'cv';
-  $handler->display->display_options['sorts']['name']['field'] = 'name';
-  /* Sort criterion: Chado Cvterm: Name */
-  $handler->display->display_options['sorts']['name_1']['id'] = 'name_1';
-  $handler->display->display_options['sorts']['name_1']['table'] = 'cvterm';
-  $handler->display->display_options['sorts']['name_1']['field'] = 'name';
-  /* Filter criterion: Chado Cv: Name */
-  $handler->display->display_options['filters']['name']['id'] = 'name';
-  $handler->display->display_options['filters']['name']['table'] = 'cv';
-  $handler->display->display_options['filters']['name']['field'] = 'name';
-  $handler->display->display_options['filters']['name']['value'] = 'All';
-  $handler->display->display_options['filters']['name']['group'] = '0';
-  $handler->display->display_options['filters']['name']['exposed'] = TRUE;
-  $handler->display->display_options['filters']['name']['expose']['operator_id'] = 'name_op';
-  $handler->display->display_options['filters']['name']['expose']['label'] = 'Vocabulary';
-  $handler->display->display_options['filters']['name']['expose']['operator'] = 'name_op';
-  $handler->display->display_options['filters']['name']['expose']['identifier'] = 'cv';
-  $handler->display->display_options['filters']['name']['expose']['remember_roles'] = array(
-    2 => '2',
-    1 => 0,
-    3 => 0,
-  );
-  /* Filter criterion: Chado Cvterm: Name */
-  $handler->display->display_options['filters']['name_1']['id'] = 'name_1';
-  $handler->display->display_options['filters']['name_1']['table'] = 'cvterm';
-  $handler->display->display_options['filters']['name_1']['field'] = 'name';
-  $handler->display->display_options['filters']['name_1']['operator'] = 'contains';
-  $handler->display->display_options['filters']['name_1']['group'] = '0';
-  $handler->display->display_options['filters']['name_1']['exposed'] = TRUE;
-  $handler->display->display_options['filters']['name_1']['expose']['operator_id'] = '';
-  $handler->display->display_options['filters']['name_1']['expose']['label'] = 'Name Contains';
-  $handler->display->display_options['filters']['name_1']['expose']['identifier'] = 'name';
-  $handler->display->display_options['filters']['name_1']['expose']['remember_roles'] = array(
-    2 => '2',
-    1 => 0,
-    3 => 0,
-  );
-  /* Filter criterion: Chado Cvterm: Definition */
-  $handler->display->display_options['filters']['definition']['id'] = 'definition';
-  $handler->display->display_options['filters']['definition']['table'] = 'cvterm';
-  $handler->display->display_options['filters']['definition']['field'] = 'definition';
-  $handler->display->display_options['filters']['definition']['operator'] = 'contains';
-  $handler->display->display_options['filters']['definition']['group'] = '0';
-  $handler->display->display_options['filters']['definition']['exposed'] = TRUE;
-  $handler->display->display_options['filters']['definition']['expose']['operator_id'] = 'definition_op';
-  $handler->display->display_options['filters']['definition']['expose']['label'] = 'Definition Contains';
-  $handler->display->display_options['filters']['definition']['expose']['operator'] = 'definition_op';
-  $handler->display->display_options['filters']['definition']['expose']['identifier'] = 'definition';
-  $handler->display->display_options['filters']['definition']['expose']['remember_roles'] = array(
-    2 => '2',
-    1 => 0,
-    3 => 0,
-  );
-
-  /** MANUALLY ADDED since filter handler no exporting correctly */
-  $handler->display->display_options['filters']['name']['expose']['values_form_type'] = 'select';
-  $handler->display->display_options['filters']['name']['expose']['select_multiple'] = FALSE;
-  $handler->display->display_options['filters']['name']['expose']['select_optional'] = TRUE;
-  $handler->display->display_options['filters']['name']['expose']['max_length'] = 40;
-
-  $handler->display->display_options['filters']['name_1']['expose']['values_form_type'] = 'textfield';
-  $handler->display->display_options['filters']['name_1']['expose']['select_multiple'] = FALSE;
-  $handler->display->display_options['filters']['name_1']['expose']['select_optional'] = FALSE;
-  $handler->display->display_options['filters']['name_1']['expose']['max_length'] = 40;
-
-  /* Display: Page */
-  $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->display->display_options['path'] = 'admin/tripal/vocab/cvterms';
-  $handler->display->display_options['menu']['type'] = 'tab';
-  $handler->display->display_options['menu']['title'] = 'Terms';
-  $handler->display->display_options['menu']['description'] = 'A listing of a controlled vocabulary terms for a given vocabulary';
-  $handler->display->display_options['menu']['weight'] = '-8';
-  $handler->display->display_options['menu']['name'] = 'management';
-  $handler->display->display_options['menu']['context'] = 0;
-  $handler->display->display_options['menu']['context_only_inline'] = 0;
-
-  /** MANUALLY ADD since filter handler no exporting correctly
-  $handler->display->display_options['filters']['name']['expose']['values_form_type'] = 'select';
-  $handler->display->display_options['filters']['name']['expose']['select_multiple'] = FALSE;
-  $handler->display->display_options['filters']['name']['expose']['select_optional'] = TRUE;
-  $handler->display->display_options['filters']['name']['expose']['max_length'] = 40;
-
-  $handler->display->display_options['filters']['name_1']['expose']['values_form_type'] = 'textfield';
-  $handler->display->display_options['filters']['name_1']['expose']['select_multiple'] = FALSE;
-  $handler->display->display_options['filters']['name_1']['expose']['select_optional'] = FALSE;
-  $handler->display->display_options['filters']['name_1']['expose']['max_length'] = 40;
-  */
-
-  return $view;
-}

+ 3 - 3
legacy/tripal_db/tripal_db.info

@@ -3,8 +3,8 @@ description = Supports the database cross-reference tables of Chado by providing
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
-configure = admin/tripal/chado/tripal_db
+version = 7.x-3.0-rc1
+configure = admin/tripal/legacy/tripal_db
 
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views

+ 6 - 47
legacy/tripal_db/tripal_db.module

@@ -7,8 +7,6 @@
 //require_once 'api/tripal_db.api.inc';
 require_once 'api/tripal_db.DEPRECATED.inc';
 
-require_once 'includes/tripal_db.admin.inc';
-
 /**
  * @defgroup tripal_db Database Reference Module
  * @ingroup tripal_modules
@@ -29,66 +27,27 @@ require_once 'includes/tripal_db.admin.inc';
 function tripal_db_menu() {
   $items = array();
 
-  /*
-  $items['admin/tripal/chado/tripal_db'] = array(
-    'title' => 'Databases',
-    'description' => 'References to External Database sites such as NCBI',
-    'page callback' => 'tripal_db_admin_db_listing',
-    'access arguments' => array('administer db cross-references'),
-    'type' => MENU_NORMAL_ITEM,
-  );
-
-  $items['admin/tripal/chado/tripal_db/help'] = array(
-    'title' => 'Help',
-    'description' => "A description of the Tripal Database module including a short description of it's usage.",
-    'page callback' => 'theme',
-    'page arguments' => array('tripal_db_admin'),
-    'access arguments' => array('administer db cross-references'),
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 10
-  );
-
-  $items['admin/tripal/chado/tripal_db/edit/%'] = array(
-    'title' => 'Edit a Database Reference',
-    'description' => 'Edit existing Database References.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_db_db_edit_form',5),
-    'access callback' => 'user_access',
-    'access arguments' => array('administer db cross-references'),
-    'type' => MENU_CALLBACK,
-  );
-
-  $items['admin/tripal/chado/tripal_db/add'] = array(
-    'title' => 'Create a Database Reference',
-    'description' => 'Create a new reference to an External Database.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_db_db_add_form'),
-    'access callback' => 'user_access',
-    'access arguments' => array('administer db cross-references'),
-    'type' => MENU_CALLBACK,
-  );
-
-  $items['admin/tripal/chado/tripal_db/views/dbs/enable'] = array(
+  $items['admin/tripal/legacy/tripal_db/views/dbs/enable'] = array(
     'title' => 'Enable Database Administrative View',
     'page callback' => 'tripal_enable_view',
-    'page arguments' => array('tripal_db_admin_dbs', 'admin/tripal/chado/tripal_db'),
+    'page arguments' => array('tripal_db_admin_dbs', 'admin/tripal/legacy/tripal_db'),
     'access arguments' => array('administer db cross-references'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/tripal/chado/tripal_db/views/dbxrefs/enable'] = array(
+  $items['admin/tripal/legacy/tripal_db/views/dbxrefs/enable'] = array(
     'title' => 'Enable Reference Administrative View',
     'page callback' => 'tripal_enable_view',
-    'page arguments' => array('tripal_db_admin_dbxrefs', 'admin/tripal/chado/tripal_db'),
+    'page arguments' => array('tripal_db_admin_dbxrefs', 'admin/tripal/legacy/tripal_db'),
     'access arguments' => array('administer db cross-references'),
     'type' => MENU_CALLBACK,
   );
-  $items['admin/tripal/chado/tripal_db/dbxref/auto_name/%/%'] = array(
+  $items['admin/tripal/legacy/tripal_db/dbxref/auto_name/%/%'] = array(
     'page callback' => 'tripal_db_dbxref_accession_autocomplete',
     'page arguments' => array(6, 7),
     'access arguments' => array('administer db cross-references'),
     'type' => MENU_CALLBACK,
   );
- */
+
   return $items;
 }
 

+ 0 - 370
legacy/tripal_db/tripal_db.views_default.inc

@@ -12,379 +12,9 @@
 function tripal_db_views_default_views() {
   $views = array();
 
-  // Default Tripal Admin View: DB
-  $view = tripal_db_defaultview_admin_db_listing();
-  $view = tripal_make_view_compatible_with_external($view);
-  $views[$view->name] = $view;
 
-  // Default Tripal Admin View: DB References
-  $view = tripal_db_defaultview_admin_dbxref_listing();
-  $view = tripal_make_view_compatible_with_external($view);
-  $views[$view->name] = $view;
 
   return $views;
 }
 
-/**
- * Default Admin View for db management
- *
- * @ingroup tripal_db
- */
-function tripal_db_defaultview_admin_db_listing() {
-
-  $view = new view();
-  $view->name = 'tripal_db_admin_dbs';
-  $view->description = 'DO NOT DISABLE';
-  $view->tag = 'tripal admin';
-  $view->base_table = 'db';
-  $view->human_name = 'DB Admin';
-  $view->core = 6;
-  $view->api_version = '3.0';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-
-  /* Display: Defaults */
-  $handler = $view->new_display('default', 'Defaults', 'default');
-  $handler->display->display_options['title'] = 'Databases';
-  $handler->display->display_options['use_more_always'] = FALSE;
-  $handler->display->display_options['access']['type'] = 'perm';
-  $handler->display->display_options['access']['perm'] = 'access chado_db content';
-  $handler->display->display_options['cache']['type'] = 'none';
-  $handler->display->display_options['query']['type'] = 'views_query';
-  $handler->display->display_options['exposed_form']['type'] = 'input_required';
-  $handler->display->display_options['exposed_form']['options']['submit_button'] = 'Search';
-  $handler->display->display_options['exposed_form']['options']['text_input_required'] = 'Click search to see a listing of external databases that meet the filter requirements. Use the filters to restrict this set to a more reasonable number of databases or to find a specific database.';
-  $handler->display->display_options['exposed_form']['options']['text_input_required_format'] = 'full_html';
-  $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['pager']['options']['items_per_page'] = '50';
-  $handler->display->display_options['pager']['options']['offset'] = '0';
-  $handler->display->display_options['pager']['options']['id'] = '0';
-  $handler->display->display_options['pager']['options']['quantity'] = '9';
-  $handler->display->display_options['style_plugin'] = 'table';
-  $handler->display->display_options['style_options']['grouping'] = '';
-  $handler->display->display_options['style_options']['columns'] = array(
-    'name' => 'name',
-    'url' => 'url',
-    'urlprefix' => 'urlprefix',
-    'description' => 'description',
-  );
-  $handler->display->display_options['style_options']['default'] = 'name';
-  $handler->display->display_options['style_options']['info'] = array(
-    'name' => array(
-      'sortable' => 1,
-      'separator' => '',
-    ),
-    'url' => array(
-      'sortable' => 1,
-      'separator' => '',
-    ),
-    'urlprefix' => array(
-      'sortable' => 0,
-      'separator' => '',
-    ),
-    'description' => array(
-      'sortable' => 0,
-      'separator' => '',
-    ),
-  );
-  /* Header: Global: Action Links */
-  $handler->display->display_options['header']['action_links_area']['id'] = 'action_links_area';
-  $handler->display->display_options['header']['action_links_area']['table'] = 'views';
-  $handler->display->display_options['header']['action_links_area']['field'] = 'action_links_area';
-  $handler->display->display_options['header']['action_links_area']['label'] = 'Action Links';
-  $handler->display->display_options['header']['action_links_area']['empty'] = TRUE;
-  $handler->display->display_options['header']['action_links_area']['link-1'] = array(
-    'label-1' => 'Add Database',
-    'path-1' => 'admin/tripal/chado/tripal_db/add',
-  );
-  /* No results behavior: Global: Text area */
-  $handler->display->display_options['empty']['text']['id'] = 'area';
-  $handler->display->display_options['empty']['text']['table'] = 'views';
-  $handler->display->display_options['empty']['text']['field'] = 'area';
-  $handler->display->display_options['empty']['text']['content'] = 'No databases match the supplied criteria.';
-  $handler->display->display_options['empty']['text']['format'] = '2';
-  /* Field: Chado Db: Db Id */
-  $handler->display->display_options['fields']['db_id']['id'] = 'db_id';
-  $handler->display->display_options['fields']['db_id']['table'] = 'db';
-  $handler->display->display_options['fields']['db_id']['field'] = 'db_id';
-  $handler->display->display_options['fields']['db_id']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['db_id']['separator'] = '';
-  /* Field: Chado Db: Name */
-  $handler->display->display_options['fields']['name']['id'] = 'name';
-  $handler->display->display_options['fields']['name']['table'] = 'db';
-  $handler->display->display_options['fields']['name']['field'] = 'name';
-  /* Field: Chado Db: Urlprefix */
-  $handler->display->display_options['fields']['urlprefix']['id'] = 'urlprefix';
-  $handler->display->display_options['fields']['urlprefix']['table'] = 'db';
-  $handler->display->display_options['fields']['urlprefix']['field'] = 'urlprefix';
-  $handler->display->display_options['fields']['urlprefix']['exclude'] = TRUE;
-  /* Field: Chado Db: Url */
-  $handler->display->display_options['fields']['url']['id'] = 'url';
-  $handler->display->display_options['fields']['url']['table'] = 'db';
-  $handler->display->display_options['fields']['url']['field'] = 'url';
-  $handler->display->display_options['fields']['url']['alter']['alter_text'] = TRUE;
-  $handler->display->display_options['fields']['url']['alter']['text'] = '[url]<br />[urlprefix]';
-  $handler->display->display_options['fields']['url']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['url']['alter']['path'] = '[url]';
-  $handler->display->display_options['fields']['url']['alter']['absolute'] = TRUE;
-  $handler->display->display_options['fields']['url']['alter']['target'] = '_blank';
-  /* Field: Chado Db: Description */
-  $handler->display->display_options['fields']['description']['id'] = 'description';
-  $handler->display->display_options['fields']['description']['table'] = 'db';
-  $handler->display->display_options['fields']['description']['field'] = 'description';
-  /* Field: Global: Custom text */
-  $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
-  $handler->display->display_options['fields']['nothing']['table'] = 'views';
-  $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
-  $handler->display->display_options['fields']['nothing']['label'] = 'Edit Link';
-  $handler->display->display_options['fields']['nothing']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['nothing']['alter']['text'] = 'edit';
-  $handler->display->display_options['fields']['nothing']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing']['alter']['path'] = 'admin/tripal/chado/tripal_db/edit/[db_id]';
-  /* Field: Global: Custom text */
-  $handler->display->display_options['fields']['nothing_1']['id'] = 'nothing_1';
-  $handler->display->display_options['fields']['nothing_1']['table'] = 'views';
-  $handler->display->display_options['fields']['nothing_1']['field'] = 'nothing';
-  $handler->display->display_options['fields']['nothing_1']['label'] = 'View DBxrefs';
-  $handler->display->display_options['fields']['nothing_1']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['nothing_1']['alter']['text'] = 'References';
-  $handler->display->display_options['fields']['nothing_1']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/chado/tripal_db/dbxrefs?db_name=[name]';
-  /* Field: Global: Custom text */
-  $handler->display->display_options['fields']['nothing_2']['id'] = 'nothing_2';
-  $handler->display->display_options['fields']['nothing_2']['table'] = 'views';
-  $handler->display->display_options['fields']['nothing_2']['field'] = 'nothing';
-  $handler->display->display_options['fields']['nothing_2']['label'] = '';
-  $handler->display->display_options['fields']['nothing_2']['alter']['text'] = '[nothing]<br />
-    [nothing_1]';
-  $handler->display->display_options['fields']['nothing_2']['element_label_colon'] = FALSE;
-  /* Filter criterion: Chado Db: Name */
-  $handler->display->display_options['filters']['name']['id'] = 'name';
-  $handler->display->display_options['filters']['name']['table'] = 'db';
-  $handler->display->display_options['filters']['name']['field'] = 'name';
-  $handler->display->display_options['filters']['name']['operator'] = 'contains';
-  $handler->display->display_options['filters']['name']['group'] = '0';
-  $handler->display->display_options['filters']['name']['exposed'] = TRUE;
-  $handler->display->display_options['filters']['name']['expose']['operator_id'] = 'name_op';
-  $handler->display->display_options['filters']['name']['expose']['label'] = 'Name Contains';
-  $handler->display->display_options['filters']['name']['expose']['operator'] = 'name_op';
-  $handler->display->display_options['filters']['name']['expose']['identifier'] = 'name';
-  $handler->display->display_options['filters']['name']['expose']['values_form_type'] = 'textfield';
-  $handler->display->display_options['filters']['name']['expose']['select_multiple'] = FALSE;
-  $handler->display->display_options['filters']['name']['expose']['select_optional'] = FALSE;
-  $handler->display->display_options['filters']['name']['expose']['max_length'] = 40;
-  $handler->display->display_options['filters']['name']['expose']['remember_roles'] = array(
-    2 => '2',
-    1 => 0,
-    3 => 0,
-  );
-  /* Filter criterion: Chado Db: Description */
-  $handler->display->display_options['filters']['description']['id'] = 'description';
-  $handler->display->display_options['filters']['description']['table'] = 'db';
-  $handler->display->display_options['filters']['description']['field'] = 'description';
-  $handler->display->display_options['filters']['description']['operator'] = 'contains';
-  $handler->display->display_options['filters']['description']['group'] = '0';
-  $handler->display->display_options['filters']['description']['exposed'] = TRUE;
-  $handler->display->display_options['filters']['description']['expose']['operator_id'] = 'description_op';
-  $handler->display->display_options['filters']['description']['expose']['label'] = 'Description Contains';
-  $handler->display->display_options['filters']['description']['expose']['operator'] = 'description_op';
-  $handler->display->display_options['filters']['description']['expose']['identifier'] = 'description';
-  $handler->display->display_options['filters']['description']['expose']['remember_roles'] = array(
-    2 => '2',
-    1 => 0,
-    3 => 0,
-  );
-
-  /* Display: Page */
-  $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->display->display_options['path'] = 'admin/tripal/chado/tripal_db/dbs';
-  $handler->display->display_options['menu']['type'] = 'default tab';
-  $handler->display->display_options['menu']['title'] = 'Databases';
-  $handler->display->display_options['menu']['description'] = 'Lists all databases available to create database references for.';
-  $handler->display->display_options['menu']['weight'] = '-8';
-  $handler->display->display_options['menu']['name'] = 'management';
-  $handler->display->display_options['menu']['context'] = 0;
-  $handler->display->display_options['menu']['context_only_inline'] = 0;
-  $handler->display->display_options['tab_options']['weight'] = '0';
-
-  return $view;
-}
 
-/**
- * Default Admin View for dbxref management
- *
- * @ingroup tripal_db
- */
-function tripal_db_defaultview_admin_dbxref_listing() {
-
-  $view = new view();
-  $view->name = 'tripal_db_admin_dbxrefs';
-  $view->description = 'DO NOT DISABLE';
-  $view->tag = 'tripal admin';
-  $view->base_table = 'dbxref';
-  $view->human_name = 'DB Reference Admin';
-  $view->core = 7;
-  $view->api_version = '3.0';
-  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
-
-  /* Display: Master */
-  $handler = $view->new_display('default', 'Master', 'default');
-  $handler->display->display_options['title'] = 'DB Reference Admin';
-  $handler->display->display_options['use_more_always'] = FALSE;
-  $handler->display->display_options['access']['type'] = 'perm';
-  $handler->display->display_options['access']['perm'] = 'administer db cross-references';
-  $handler->display->display_options['cache']['type'] = 'none';
-  $handler->display->display_options['query']['type'] = 'views_query';
-  $handler->display->display_options['exposed_form']['type'] = 'input_required';
-  $handler->display->display_options['exposed_form']['options']['submit_button'] = 'Search';
-  $handler->display->display_options['exposed_form']['options']['text_input_required'] = 'Click search to see a listing of external database references that meet the filter requirements. Use the filters to restrict this set to a more reasonable number of references or to find a specific reference.';
-  $handler->display->display_options['exposed_form']['options']['text_input_required_format'] = 'full_html';
-  $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['pager']['options']['items_per_page'] = '50';
-  $handler->display->display_options['style_plugin'] = 'table';
-  $handler->display->display_options['style_options']['columns'] = array(
-    'dbxref_id' => 'dbxref_id',
-    'name' => 'name',
-    'accession' => 'accession',
-    'description' => 'description',
-    'version' => 'version',
-  );
-  $handler->display->display_options['style_options']['default'] = '-1';
-  $handler->display->display_options['style_options']['info'] = array(
-    'dbxref_id' => array(
-      'sortable' => 0,
-      'default_sort_order' => 'asc',
-      'align' => '',
-      'separator' => '',
-      'empty_column' => 0,
-    ),
-    'name' => array(
-      'sortable' => 1,
-      'default_sort_order' => 'asc',
-      'align' => '',
-      'separator' => '',
-      'empty_column' => 0,
-    ),
-    'accession' => array(
-      'sortable' => 1,
-      'default_sort_order' => 'asc',
-      'align' => '',
-      'separator' => '',
-      'empty_column' => 0,
-    ),
-    'description' => array(
-      'sortable' => 0,
-      'default_sort_order' => 'asc',
-      'align' => '',
-      'separator' => '',
-      'empty_column' => 0,
-    ),
-    'version' => array(
-      'sortable' => 1,
-      'default_sort_order' => 'asc',
-      'align' => '',
-      'separator' => '',
-      'empty_column' => 0,
-    ),
-  );
-  /* Field: Chado Dbxref: Dbxref Id */
-  $handler->display->display_options['fields']['dbxref_id']['id'] = 'dbxref_id';
-  $handler->display->display_options['fields']['dbxref_id']['table'] = 'dbxref';
-  $handler->display->display_options['fields']['dbxref_id']['field'] = 'dbxref_id';
-  $handler->display->display_options['fields']['dbxref_id']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['dbxref_id']['separator'] = '';
-  /* Field: Chado Db: Name */
-  $handler->display->display_options['fields']['name']['id'] = 'name';
-  $handler->display->display_options['fields']['name']['table'] = 'db';
-  $handler->display->display_options['fields']['name']['field'] = 'name';
-  $handler->display->display_options['fields']['name']['label'] = 'Database';
-  /* Field: Chado Dbxref: Accession */
-  $handler->display->display_options['fields']['accession']['id'] = 'accession';
-  $handler->display->display_options['fields']['accession']['table'] = 'dbxref';
-  $handler->display->display_options['fields']['accession']['field'] = 'accession';
-  /* Field: Chado Dbxref: Description */
-  $handler->display->display_options['fields']['description']['id'] = 'description';
-  $handler->display->display_options['fields']['description']['table'] = 'dbxref';
-  $handler->display->display_options['fields']['description']['field'] = 'description';
-  /* Field: Chado Dbxref: Version */
-  $handler->display->display_options['fields']['version']['id'] = 'version';
-  $handler->display->display_options['fields']['version']['table'] = 'dbxref';
-  $handler->display->display_options['fields']['version']['field'] = 'version';
-  /* Sort criterion: Chado Db: Name */
-  $handler->display->display_options['sorts']['name']['id'] = 'name';
-  $handler->display->display_options['sorts']['name']['table'] = 'db';
-  $handler->display->display_options['sorts']['name']['field'] = 'name';
-  /* Sort criterion: Chado Dbxref: Accession */
-  $handler->display->display_options['sorts']['accession']['id'] = 'accession';
-  $handler->display->display_options['sorts']['accession']['table'] = 'dbxref';
-  $handler->display->display_options['sorts']['accession']['field'] = 'accession';
-  /* Sort criterion: Chado Dbxref: Version */
-  $handler->display->display_options['sorts']['version']['id'] = 'version';
-  $handler->display->display_options['sorts']['version']['table'] = 'dbxref';
-  $handler->display->display_options['sorts']['version']['field'] = 'version';
-  $handler->display->display_options['sorts']['version']['order'] = 'DESC';
-  /* Filter criterion: Chado Db: Name */
-  $handler->display->display_options['filters']['name']['id'] = 'name';
-  $handler->display->display_options['filters']['name']['table'] = 'db';
-  $handler->display->display_options['filters']['name']['field'] = 'name';
-  $handler->display->display_options['filters']['name']['value'] = array(
-    'All' => 'All',
-  );
-  $handler->display->display_options['filters']['name']['group'] = 1;
-  $handler->display->display_options['filters']['name']['exposed'] = TRUE;
-  $handler->display->display_options['filters']['name']['expose']['operator_id'] = '';
-  $handler->display->display_options['filters']['name']['expose']['label'] = 'Database';
-  $handler->display->display_options['filters']['name']['expose']['identifier'] = 'db_name';
-  $handler->display->display_options['filters']['name']['expose']['values_form_type'] = 'select';
-  $handler->display->display_options['filters']['name']['expose']['select_multiple'] = TRUE;
-  $handler->display->display_options['filters']['name']['expose']['select_optional'] = TRUE;
-  $handler->display->display_options['filters']['name']['expose']['max_length'] = 40;
-  $handler->display->display_options['filters']['name']['expose']['remember_roles'] = array(
-    2 => '2',
-    1 => 0,
-    3 => 0,
-  );
-  /* Filter criterion: Chado Dbxref: Accession */
-  $handler->display->display_options['filters']['accession']['id'] = 'accession';
-  $handler->display->display_options['filters']['accession']['table'] = 'dbxref';
-  $handler->display->display_options['filters']['accession']['field'] = 'accession';
-  $handler->display->display_options['filters']['accession']['operator'] = 'contains';
-  $handler->display->display_options['filters']['accession']['group'] = 1;
-  $handler->display->display_options['filters']['accession']['exposed'] = TRUE;
-  $handler->display->display_options['filters']['accession']['expose']['operator_id'] = 'accession_op';
-  $handler->display->display_options['filters']['accession']['expose']['label'] = 'Accession Contains';
-  $handler->display->display_options['filters']['accession']['expose']['operator'] = 'accession_op';
-  $handler->display->display_options['filters']['accession']['expose']['identifier'] = 'accession';
-  $handler->display->display_options['filters']['accession']['expose']['remember_roles'] = array(
-    2 => '2',
-    1 => 0,
-    3 => 0,
-  );
-  /* Filter criterion: Chado Dbxref: Description */
-  $handler->display->display_options['filters']['description']['id'] = 'description';
-  $handler->display->display_options['filters']['description']['table'] = 'dbxref';
-  $handler->display->display_options['filters']['description']['field'] = 'description';
-  $handler->display->display_options['filters']['description']['operator'] = 'contains';
-  $handler->display->display_options['filters']['description']['group'] = 1;
-  $handler->display->display_options['filters']['description']['exposed'] = TRUE;
-  $handler->display->display_options['filters']['description']['expose']['operator_id'] = 'description_op';
-  $handler->display->display_options['filters']['description']['expose']['label'] = 'Description Contains';
-  $handler->display->display_options['filters']['description']['expose']['operator'] = 'description_op';
-  $handler->display->display_options['filters']['description']['expose']['identifier'] = 'description';
-  $handler->display->display_options['filters']['description']['expose']['remember_roles'] = array(
-    2 => '2',
-    1 => 0,
-    3 => 0,
-  );
-
-  /* Display: Page */
-  $handler = $view->new_display('page', 'Page', 'page');
-  $handler->display->display_options['path'] = 'admin/tripal/chado/tripal_db/dbxrefs';
-  $handler->display->display_options['menu']['type'] = 'tab';
-  $handler->display->display_options['menu']['title'] = 'References';
-  $handler->display->display_options['menu']['weight'] = '0';
-  $handler->display->display_options['menu']['name'] = 'management';
-  $handler->display->display_options['menu']['context'] = 0;
-  $handler->display->display_options['menu']['context_only_inline'] = 0;
-
-  return $view;
-}

+ 0 - 110
legacy/tripal_example/README.txt

@@ -1,110 +0,0 @@
-This module is provided as a template for creating a custom Tripal Extension
-Module for Drupal 7 and Tripal 2.x.
-
-Drupal does provide quite a bit of documentation on its website at
-http://www.drupal.org but the easiest way to learn to program a Drupal module
-is to purchase the following book:
-
-  Tomlinson, VanDyk.  Pro Drupal Development. 2010. ISBN-13: 978-1430228387
-
-But this quick link can help get you started:
-
-  https://drupal.org/developing/modules/7
-
-Briefly, to create a Drupal module you must
-
-1) Create a directory to house all of your module's files
-2) Create a .info inside of the directory which provides information about your
-   module to Drupal
-3) Create a .module file which contains the functions used by your module
-4) Create a .install file which contains the functions used for installation,
-   enabling, disabling and uninstallation of your module.
-
-Examine the example functions and documentation in each of the files in this
-example module to learn how Tripal uses the Drupal API.
-
--------------------------
-DIRECTORY AND FILE NAMING
--------------------------
-When creating your Tripal Extension module, the following directory structure
-and file naming is suggested:
-
-For the required files:
-[module dir]/[module name].info
-[module dir]/[module name].module
-[module dir]/[module name].install
-
-If you want to include Drush commands for your module
-[module dir]/[module name].drush.inc
-
-If you want to integrate with Drupal Views 3.x:
-[module dir]/[module name].views.inc
-[module dir]/[module name].views_default.inc
-
-
-Include Files
--------------
-To limit the size of files, some functionality can be placed inside of
-"include" files. Include files are placed inside of an 'includes' directory.
-[module dir]/includes
-
-If your module creates a node type that uses data housed in Chado, you should
-place all of the Drupal hooks for nodes inside of an include named:
-[module dir]/includes/[module name].chado_node.inc
-
-If your module has an administrative interface, all of the functions related to
-administration should go in an include file named:
-[module dir]/includes/[module name].admin.inc
-
-All other include files should be named in the following way:
-[module dir]/includes/[module name].[function].inc
-
-where [function] is a brief description of the functionality provided by the
-include file. Please only use underscores inside of the [function] (no dashes
-or periods).
-
-
-Theme Files
--------------
-Tripal primarily uses template files for displaying content from Chado. This
-allows anyone to easily change the way data is displayed without needing to
-delve into the module's source code. A template typically provides data for
-a single data type (e.g. feature) or association (e.g. properties associated to
-features, or publications associated with featurmaps, etc.). These template
-files and any JavaScript, CSS or images needed to support them are all
-housed inside of a 'theme' directory with the following structure:
-[module dir]/theme
-[module dir]/theme/css       (for CSS files)
-[module dir]/theme/js        (for JS files)
-[module dir]/theme/images    (for images)
-[module dir]/theme/templates (for all Drupal template files)
-
-All Drupal hooks and functions related to theming of content should go in the
-file named:
-[module dir]/theme/[module name].theme.inc
-
-The functions in that file will typically be functions which directly
-generate content for a page or "preprocess" hooks that prepare variables that
-are passed to templates.
-
-Template files are named in the following way
-[module dir]/theme/templates/[module name]_[function].tpl.php.
-
-Notice that templates have an underscore separating the [module name] from the
-[function]. Typically a period is used (as with include files) but for
-backwards compatibility the underscores are kept.
-
-API Files
----------
-If your module will provide a set of functions that can be used as an
-Application Programming Interface (API), then those functions should be placed
-in files housed in the 'api' directory:
-[module dir]/api
-
-When creating API functions try to organize them into groups of related function
-and separate them into files by function with the following naming:
-[module dir]/api/[module name].[function].api.inc
-
-
-
-

+ 0 - 35
legacy/tripal_example/api/tripal_example.api.inc

@@ -1,35 +0,0 @@
-<?php
-
-/**
- * @file
- * Provides an application programming interface (API) for working the example
- * module
- */
-
-/**
- * @defgroup tripal_example_api Example API
- * @ingroup tripal_api
- * @{
- * Provides an application programming interface (API) for working with features
- * @}
- */
-
-// EXPLANATION: This file is used for housing any API function that your module
-// creates. It is suggested you follow the naming style for Tripal API
-// functions. Below are naming rules for Tripal API functions:
-//
-// 1) Prefix the function with 'chado_' for all insert, updates, delete or get
-//    function on a table in the chado schema. Tripal should provide all of
-//    these functions for tables that come with Chado. But, you can use this
-//    prefix for API functions on custom tables that your module may add.
-// 2) For all other functions prefix the function with your module name. So
-//    for this example module the prefix would be 'tripal_example_'
-// 3) A 'verb' should follow the function prefix indicating the action that
-//    the function performs. Commonly used verbs are 'get', 'insert', 'update'
-//    'associate', 'execute', etc. An exception is for functions that
-//    test state rather than perform an action (e.g. does something exist).
-//    For functions that test state use 'does' instead of a verb
-//    (e.g. tripal_example_does_pub_exist)
-// 4) Follow the verb with a short predicate describing what is being acted
-//    upon.
-//

+ 0 - 96
legacy/tripal_example/includes/tripal_example.admin.inc

@@ -1,96 +0,0 @@
-<?php
-/**
- * @file
- * This file contains the functions used for administration of the module
- *
- */
-
-function tripal_example_admin_examples_listing() {
-  $output = '';
-
-  // set the breadcrumb
-  $breadcrumb = array();
-  $breadcrumb[] = l('Home', '<front>');
-  $breadcrumb[] = l('Administration', 'admin');
-  $breadcrumb[] = l('Tripal', 'admin/tripal');
-  $breadcrumb[] = l('Chado', 'admin/tripal/chado');
-  $breadcrumb[] = l('Examples', 'admin/tripal/chado/tripal_example');
-  drupal_set_breadcrumb($breadcrumb);
-
-
-  // EXPLANATION:  Typically for all Tripal modules the home administrative page
-  // for the module contains a search form to help the adminstrator locate
-  // records. The following example code adds a default View to the page
-  /*
-  // Add the view
-  $view = views_embed_view('tripal_example_admin_examples','default');
-  if (isset($view)) {
-    $output .= $view;
-  }
-  else {
-    $output .= '<p>The Tripal Example Module uses primarily views to provide an '
-      . 'administrative interface. Currently one or more views needed for this '
-      . 'administrative interface are disabled. <strong>Click each of the following links to '
-      . 'enable the pertinent views</strong>:</p>';
-    $output .= '<ul>';
-      $output .= '<li>'.l('Example Admin', 'admin/tripal/chado/tripal_example/views/examples/enable').'</li>';
-    $output .= '</ul>';
-  }
-  */
-  $output = 'Typically a search view goes here';
-
-  return $output;
-}
-
-/**
- * Administrative settings form
- *
- * @ingroup tripal_example
- */
-function tripal_example_admin() {
-  $form = array();
-
-  $form['nothing'] = array(
-    '#markup' => t('There are currently no settings to configure.')
-  );
-
-  // If your module is using the Chado Node: Title & Path API to allow custom
-  // titles for your node type then you need to add the configuration form for
-  // this functionality. To do so, we first have to preapre a $details array
-  // the describe our node type.  Then we call the function to create the form
-  // elements.
-  $details = array(
-      // the name of the MODULE implementing the content type
-    'module' => 'tripal_example',
-    'content_type' => 'chado_example',
-      // An array of options to use under "Page Titles"
-      // the key should be the token and the value should be the human-readable
-      // option
-    'options' => array(
-      '[example.name]' => 'Germplasm Name Only',
-      '[example.uniquename]' => 'Germplasm Unique Name Only',
-        // there should always be one options matching the unique constraint.
-        // If you have a more human-readable constraint, then that is
-        // preferable.
-        // See the tripal feature module for a good example of this.
-      '[example.example_id]' => 'Unique Constraint: The Chado ID for Examples'
-    ),
-    // the token indicating the unique constraint in the options array
-    'unique_option' => '[example.example_id]'
-  );
-  // This call adds the configuration form to your current form
-  // This sub-form handles it's own validation & submit
-  chado_add_admin_form_set_title($form, $form_state, $details);
-
-  return system_settings_form($form);
-}
-
-
-
-/**
- *
- * @ingroup tripal_example
- */
-function tripal_example_admin_validate($form, &$form_state) {
-
-}

+ 0 - 880
legacy/tripal_example/includes/tripal_example.chado_node.inc

@@ -1,880 +0,0 @@
-<?php
-
-/**
- * @file
- * This file should contain all Drupal hooks for interacting with nodes.
- *
- */
-
-/**
- *  Implementation of hook_node_info().
- *
- *  This hook provides information to Drupal about any node types that are being
- *  created by this module. If your module does not create any node types then
- *  this function is not required.
- *
- * @ingroup tripal_example
- */
-function tripal_example_node_info() {
-  $nodes = array();
-
-  // EXPLANATION: this array describes all of the node types that are created
-  // by this module. For many Tripal modules (e.g. tripal_example, tripal_stock,
-  // tripal_library, tripal_pub, etc.) new node types are created. It is
-  // customary to name all new node types that interact with data in Chado
-  // with a 'chado_' prefix.
-
-  $nodes['chado_example'] = array(
-    'name'        => t('Example'),
-    'base'        => 'chado_example',
-    'description' => t('A record from the fake chado example table'),
-    'has_title'   => TRUE,
-    'locked'      => TRUE,
-    // EXPLANATION: This section of the node type array specifies how Tripal
-    // will sync the node types with data in Chado. When Drupal creates a node
-    // it has no way of coordinating which node belongs to which record in
-    // Chado. Therefore, Tripal maintains tables in the Drupal schema that maps
-    // Drupal nodes to records in Chado. Syncing is the process of creating
-    // Drupal nodes and linking them to the appropriate record.
-    'chado_node_api' => array(
-      // the base table name (e.g. example, example, contact)
-      'base_table' => 'example',
-      // the node type hook prefix
-      'hook_prefix' => 'chado_example',
-      'record_type_title' => array(
-        // how to refer to the record
-        'singular' => t('Example'),
-        // how to refer to the record in plurals
-        'plural' => t('Examples')
-      ),
-      'sync_filters' => array(
-        'type_id' => TRUE,     // if the record has a type_id set to TRUE
-        'organism_id' => TRUE  // if the record has an organism_id set to TRUE
-      ),
-    )
-  );
-
-  return $nodes;
-}
-
-/**
- * Implement hook_access(). This hook provides instructions to Drupal for which
- * users can access the custom content types created in the function above. The
- * available permissions are set in the chado_example_permissions() hook in the
- * tripal_example.module file. This hook is not needed if no node types were
- * defined in the hook_node_info() hook.
- *
- * @return
- * This function should return null if it does not specifically deny access.
- * This allows for other mechanisms to to deny or reject access. If the return
- * value is TRUE then access is granted regardless of any other rules that might
- * be implemented by other modules.
- */
-function chado_example_node_access($node, $op, $account) {
-  $node_type = $node;
-  if (is_object($node)) {
-    $node_type = $node->type;
-  }
-  // EXPLANATION:  in the tripal_example_permissions() function we created the
-  // permission types that are used here to check for access permissions to the
-  // 'chado_exmaple' node type.
-  if($node_type == 'chado_example') {
-    if ($op == 'create') {
-      if (!user_access('create chado_example content', $account)) {
-        return NODE_ACCESS_DENY;
-      }
-      return NODE_ACCESS_ALLOW;
-    }
-    if ($op == 'update') {
-      if (!user_access('edit chado_example content', $account)) {
-        return NODE_ACCESS_DENY;
-      }
-    }
-    if ($op == 'delete') {
-      if (!user_access('delete chado_example content', $account)) {
-        return NODE_ACCESS_DENY;
-      }
-    }
-    if ($op == 'view') {
-      if (!user_access('access chado_example content', $account)) {
-        return NODE_ACCESS_DENY;
-      }
-    }
-  }
-  return NODE_ACCESS_IGNORE;
-}
-
-/**
- * Implementation of hook_form()
- *
- * Creates the form for editing or inserting a record
- *
- * @ingroup tripal_example
- */
-function chado_example_form($node, &$form_state) {
-
-  // EXPLANATION: This function should construct a form array that is used by
-  // Drupal to construct a form for inserting or editing our new node type.
-  // See this page for information about the Form API:
-  // https://api.drupal.org/api/drupal/includes!form.inc/group/form_api/7
-  //
-  // The code below is laid out in the following order
-  // 1) Set default values
-  // 2) Add form elements used by this node type
-  // 3) Use the Tripal API to add form elements for properties,
-  //    dbxref's and relationships
-  //
-  // For the example code below we assume that the fake 'example' table only has
-  // a uniquename, organism_id, type_id and example_id.
-
-  $form = array();
-
-  // Default values can come in the following ways:
-  //
-  // 1) as elements of the $node object. This occurs when editing an existing
-  //    example
-  // 2) in the $form_state['values'] array which occurs on a failed validation
-  //    or ajax callbacks from non submit form elements
-  // 3) in the $form_state['input'[ array which occurs on ajax callbacks from
-  //    submit form elements and the form is being rebuilt
-  //
-  // set form field defaults
-
-
-  // SET FORM DEFAULTS
-  //---------------------------------------------
-  $example      = null; // holds the example object record
-  $example_id   = null; // when editing an example record we'll have an example_id
-
-  // initialize the defaults for the form fields
-  $uniquename   = '';
-  $example_type = '';
-  $organism_id  = '';
-  $description  = '';
-
-  // if we are editing an existing node then the 'example' record from Chado
-  // is already part of the node, so we set the defaults from that object
-  if (property_exists($node, 'example')) {
-    $example = $node->example;
-    $example_id   = $example->example_id;
-    $uniquename   = $example->uniquename;
-    $description  = $example->description;
-    $organism_id  = $example->organism_id;
-
-    // keep track of the example id
-    $form['example_id'] = array(
-      '#type' => 'value',
-      '#value' => $example_id,
-    );
-  }
-  // if we are re constructing the form from a failed validation or ajax
-  // callback then use the $form_state['values'] values
-  if (array_key_exists('values', $form_state)) {
-     $uniquename   = $form_state['values']['uniquename'];
-     $example_type = $form_state['values']['example_type'];
-     $description  = $form_state['values']['description'];
-     $organism_id  = $form_state['values']['organism_id'];
-  }
-  // if we are re building the form from after submission (from ajax call) then
-  // the values are in the $form_state['input'] array
-  if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
-     $uniquename   = $form_state['input']['uniquename'];
-     $example_type = $form_state['input']['example_type'];
-     $organism_id  = $form_state['input']['organism_id'];
-  }
-
-
-  // FORM ELEMENTS
-  //---------------------------------------------
-  $form['uniquename'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Unique Name'),
-    '#required' => TRUE,
-    '#default_value' => $uniquename,
-    '#description' => t('Enter a unique name for this example. This name must be unique.'),
-    '#maxlength' => 255
-  );
-
-  // for the type_id we want to use the default vocabulary so that this field
-  // can have auto-complete functionality
-  $type_cv = tripal_get_default_cv('example', 'type_id');
-  $cv_id = $type_cv->cv_id;
-  $form['example_type'] = array(
-    '#title'       => t('Example Type'),
-    '#type'        => 'textfield',
-    '#description' => t("Choose the example type (e.g. Test Type)."),
-    '#required'    => TRUE,
-    '#default_value' => $example_type,
-    '#autocomplete_path' => "admin/tripal/vocab/cvterm/auto_name/$cv_id",
-  );
-
-  // add a select box of organisms
-  $organisms = tripal_get_organism_select_options();
-  $form['organism_id'] = array(
-    '#title'       => t('Organism'),
-    '#type'        => t('select'),
-    '#description' => t("Choose the organism with which this example is associated"),
-    '#required'    => TRUE,
-    '#default_value' => $organism_id,
-    '#options'     => $organisms,
-  );
-
-  $form['description'] = array(
-    '#type' => 'text_format',
-    '#title' => t('Description'),
-    '#required' => TRUE,
-    '#default_value' => $description,
-    '#description' => t('Enter a description for this example.'),
-  );
-
-  // PROPERTIES FORM
-  //---------------------------------------------
-  // If there is a exampleprop table and you want to allow users to add/remove
-  // entries from it through your node form then add this section to your own
-  // node form
-  $prop_cv = tripal_get_default_cv('exampleprop', 'type_id');
-  $cv_id = $prop_cv ? $prop_cv->cv_id : NULL;
-  $details = array(
-    // the name of the prop table
-    'property_table' => 'exampleprop',
-    // the value of example_id for this record
-    'chado_id' => $example_id,
-    // the cv.cv_id of the cv governing exampleprop.type_id
-    'cv_id' => $cv_id
-  );
-  // Adds the form elements to your current form
-  chado_add_node_form_properties($form, $form_state, $details);
-
-  // ADDITIONAL DBXREFS FORM
-  //---------------------------------------------
-  // If there is a example_dbxref table and you want to allow users to
-  // add/remove entries from it through your node form then add this section to
-  // your own node form
-  $details = array(
-    // the name of the _dbxref table
-    'linking_table' => 'example_dbxref',
-    // the name of the key in your base chado table
-    'base_foreign_key' => 'example_id',
-    // the value of example_id for this record
-    'base_key_value' => $example_id
-  );
-  // Adds the form elements to your current form
-  chado_add_node_form_dbxrefs($form, $form_state, $details);
-
-  // RELATIONSHIPS FORM
-  //---------------------------------------------
-  // If there is a example_relationship table and you want to allow users to
-  // add/remove entries from it through your node form then add this section to
-  // your own node form
-  $rels_cv = tripal_get_default_cv('example_relationship', 'type_id');
-  $cv_id = $rels_cv ? $rels_cv->cv_id : NULL;
-  $details = array(
-    // the name of the _relationship table
-    'relationship_table' => 'example_relationship',
-    // the name of your chado base table
-    'base_table' => 'example',
-    // the name of the key in your base chado table
-    'base_foreign_key' => 'example_id',
-    // the value of example_id for this record
-    'base_key_value' => $example_id,
-    // the human-readable name of your node type
-    'nodetype' => 'example',
-    // the cv.cv_id of the cv governing example_relationship.type_id
-    'cv_id' => $cv_id
-  );
-  // Adds the form elements to your current form
-  chado_add_node_form_relationships($form, $form_state, $details);
-
-  // return the form
-  return $form;
-}
-
-/**
- * Implementation of hook_validate
- *
- * This function validates a form prior to insert or update. If an error is
- * detected, it sets the error using form_set_error() which takes the user back
- * to the form to make corrections.
- *
- * This validation is being used for three activities:
- *   CASE A: Update a node that exists in both Drupal and Chado
- *   CASE B: Synchronizing a node from Chado to Drupal
- *   CASE C: Inserting a new node that exists in neither Drupal nor Chado
- *
- * @param $node
- *
- *
- * @ingroup tripal_example
- */
-function chado_example_validate($node, $form, &$form_state) {
-
-  // We only want to validate when the node is saved.
-  // Since this validate can be called on AJAX and Deletion of the node
-  // we need to make this check to ensure queries are not executed
-  // without the proper values.
-  if(property_exists($node, "op") and $node->op != 'Save') {
-    return;
-  }
-
-  // we are syncing if we do not have a node ID but we do have a example_id. We
-  // don't need to validate during syncing so just skip it.
-  if (!property_exists($node, 'nid') and property_exists($node, 'example_id') and $node->example_id != 0) {
-    return;
-  }
-
-  // be sure to always trim text fields
-  $node->uniquename   = property_exists($node, 'uniquename') ? trim($node->uniquename) : '';
-
-  // Validating for an update. If the 'nid' property is present in the node then
-  // this is an update and validation can be different for updates
-  if (property_exists($node, 'nid')) {
-
-    // make sure the example type is an allowed term
-    $type_cv = tripal_get_default_cv('example', 'type_id');
-    $type = tripal_get_cvterm(array(
-      'name' => $node->example_type,
-      'cv_id' => $type_cv->cv_id,
-    ));
-    if (!$type) {
-      form_set_error('example_type', t("The example type is not a valid name from the Sequence Ontology."));
-    }
-
-    // TODO: also we should check that the unique constraint is not invalidated
-    // by changing either the type_id, organism_id or uniquename.
-  }
-  // Validating for an insert
-  else {
-    // make sure the example type is an allowed term
-    $type_cv = tripal_get_default_cv('example', 'type_id');
-    $type = tripal_get_cvterm(array(
-      'name' => $node->example_type,
-      'cv_id' => $type_cv->cv_id,
-    ));
-    if (!$type) {
-      form_set_error('example_type', t("The example type is not a valid name from the Sequence Ontology."));
-    }
-
-    // TODO: also we should check that the unique constraint doesn't already exist
-  }
-}
-
-/**
- *  Implementation of hook_insert(). This function is called after the node is
- * inserted into the database. We need it so that we can insert appropriate
- * fields as provided by the user into the database. And so that we can link the
- * new Drupal node to the data in Chado via the chado_example linking table. We
- * can get to this function also during "syncing".
- * With syncing, however, the data already exists in Chado and we do not want
- * to try to re-add it. But we do need to add an entry to the chado_example
- * table to link the Drupal node with the data in the 'example' table of Chado.
- *
- *  This function is not required if the hook_node_info() does not define
- *  any custom node types.
- *
- * @ingroup tripal_example
- */
-function chado_example_insert($node) {
-
-  $example_id = '';
-
-  // if there is an example_id in the $node object then this must be a sync so
-  // we can skip adding the example as it is already there, although we do need
-  // to proceed with insertion into the chado/drupal linking table.
-  if (!property_exists($node, 'example_id')) {
-
-    // be sure to always trim text fields
-    $node->uniquename   = trim($node->uniquename);
-    $node->description  = trim($node->description['value']);
-
-    // get the example type record
-    $type_cv = tripal_get_default_cv('example', 'type_id');
-    $type = tripal_get_cvterm(array(
-        'name' => $node->example_type,
-        'cv_id' => $type_cv->cv_id,
-    ));
-
-    // perform the insert using the chado_insert_record function();
-    $values = array(
-      'uniquename' => $node->uniquename,
-      'description' => $node->description,
-      'type_id' => $type->cvterm_id,
-      'organism_id' => $node->organism_id,
-    );
-    $example = chado_insert_record('example', $values);
-    if (!$example) {
-      drupal_set_message(t('Unable to add example.'), 'warning');
-      tripal_report_error('tripal_example', TRIPAL_WARNING, 'Insert example: Unable to create example where values: %values',
-        array('%values' => print_r($values, TRUE)));
-      return;
-    }
-
-    // get the example_id for linking Drupal node with Chado data
-    $example_id = $example['example_id'];
-
-    // Only add to other Chado tables if the base record was inserted properly
-    if ($example_id > 0) {
-
-      // If you implemented the properties form in chado_example_form then you
-      // need to handle inserting these properties into your Chado prop table.
-      $details = array(
-        // the name of the prop table
-        'property_table'   => 'exampleprop',
-        // the name of your Chado base table
-        'base_table'       => 'example',
-        // the name of the key in your base table
-        'foreignkey_name'  => 'example_id',
-        // the value of the example_id key
-        'foreignkey_value' => $example_id
-      );
-      chado_update_node_form_properties($node, $details);
-
-      // If you implemented the dbxrefs form in chado_example_form then you need
-      // to handle inserting these database references into your Chado _dbxref
-      // table.
-      $details = array(
-        // the name of your _dbxref table
-        'linking_table'    => 'example_dbxref',
-        // the name of the key in your base table
-        'foreignkey_name'  => 'example_id',
-        // the value of the example_id key
-        'foreignkey_value' => $example_id
-      );
-      chado_update_node_form_dbxrefs($node, $details);
-
-      // If you implemented the relationships form in chado_example_form then
-      // you need to handle inserting these relationships into your Chado
-      // _relationship table.
-      $details = array(
-        // name of the _relationship table
-        'relationship_table' => 'example_relationship',
-        // value of the example_id key
-        'foreignkey_value' => $example_id
-      );
-      chado_update_node_form_relationships($node, $details);
-    }
-  }
-  else {
-    // the node has an example_id so get it for linking Drupal node with Chado
-    // data
-    $example_id = $node->example_id;
-  }
-
-  // Make sure the entry for this example doesn't already exist in the
-  // chado_example table if it doesn't exist then we want to add it.
-   $check_org_id = chado_get_id_from_nid('example', $node->nid);
-  if (!$check_org_id) {
-    $record = new stdClass();
-    $record->nid = $node->nid;
-    $record->vid = $node->vid;
-    $record->example_id = $example_id;
-    drupal_write_record('chado_example', $record);
-  }
-}
-
-/**
- * Implementation of hook_update(). This function runs after the node has been
- * inserted into the Drupal schema and allows us to update the record in Chado.
- *
- * This function is not required if the hook_node_info() does not define any
- * custom node types.
- *
- * @ingroup tripal_example
- */
-function chado_example_update($node) {
-  // be sure to always trim text fields
-  $node->uniquename   = trim($node->uniquename);
-  $node->description  = trim($node->description['value']);
-
-  // use the chado_update_record() function to update the record
-  $match = array(
-    'example_id' => $example_id,
-  );
-  $values = array(
-    'uniquename' => $node->uniquename,
-  );
-  $options = array('return_record' => TRUE);
-  $status = chado_update_record('example', $match, $values, $options);
-
-  if (!$status) {
-    drupal_set_message(t('Unable to update example.'), 'warning');
-    tripal_report_error('tripal_example', TRIPAL_WARNING, 'Update example: Unable to update example where values: %values',
-      array('%values' => print_r($values, TRUE)));
-  }
-
-  // If you implemented the properties form in chado_example_form then you need
-  // to handle updating these properties into your Chado prop table.
-  $details = array(
-    'property_table' => 'exampleprop', // the name of the prop table
-    'base_table' => 'example',         // the name of your Chado base table
-    'foreignkey_name' => 'example_id', // the name of the key in your base table
-    'foreignkey_value' => $example_id  // the value of the example_id key
-  );
-  chado_update_node_form_properties($node, $details);
-
-  // If you implemented the dbxrefs form in chado_example_form then you need to
-  // handle updating these database references into your Chado _dbxref table.
-  $details = array(
-    'linking_table' => 'example_dbxref', // the name of your _dbxref table
-    'foreignkey_name' => 'example_id',   // the name of the key in your base table
-    'foreignkey_value' => $example_id    // the value of the example_id key
-  );
-  chado_update_node_form_dbxrefs($node, $details);
-
-  // If you implemented the relationships form in chado_example_form then you
-  // need to handle updating these relationships into your Chado _relationship
-  // table.
-  $details = array(
-    // name of the _relationship table
-    'relationship_table' => 'example_relationship',
-    // value of the example_id key
-    'foreignkey_value' => $example_id
-  );
-  chado_update_node_form_relationships($node, $details);
-
-}
-/**
- * Implementation of hook_delete(). This function runs after the node has been
- * deleted from the Drupal schema and allows us to delete the corresponding
- * record in Chado.
- *
- * This function is not required if the hook_node_info() does not define any
- * custom node types.
- *
- * @ingroup tripal_example
- */
-function chado_example_delete($node) {
-
-  // get the example id from the node
-  $example_id  = chado_get_id_from_nid('example', $node->nid);
-
-  // if we don't have a example id for this node then this isn't a node of type
-  // chado_example or the entry in the chado_example table was lost.
-  if (!$example_id) {
-    return;
-  }
-
-  // remove the entry in the chado_exapmle table linking the deleted
-  // Drupal node with the data in Chado
-  $sql_del = "DELETE FROM {chado_example} WHERE nid = :nid AND vid = :vid";
-  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
-
-  // Remove data from example tables of Chado database. This will
-  // cause a cascade delete and remove all data in referencing tables
-  // for this example
-  chado_query("DELETE FROM {example} WHERE example_id = :example_id", array(':example_id' => $example_id));
-
-  // inform the user that the data was deleted
-  drupal_set_message(t("The example and all associated data were removed from Chado"));
-
-}
-
-/**
- * Implementation of hook_load(). This function is necessary to load into the
- * $node object the fields of the table form Chado. For example for the example
- * table, the chado_example_load() function adds in a example object which
- * contains all of the fields and sub objects for data in tables with foreign
- * key relationships.
- *
- * This function is not required if the hook_node_info() does not define any
- * custom node types.
- *
- * @ingroup tripal_example
- */
-function chado_example_load($nodes) {
-
-  // EXPLANATION: when displaying or node or accessing the node in a template
-  // we need the data from Chado. This function finds the record in Chado that
-  // this node belongs to and adds the record.
-
-  // there may be multiple nodes that get passed in so we have to iterate
-  // through them all
-  foreach ($nodes as $nid => $node) {
-    // find the example and add in the details
-    $example_id = chado_get_id_from_nid('example', $nid);
-
-    // if the nid does not have a matching record then skip this node.
-    // this can happen with orphaned nodes.
-    if (!$example_id) {
-      continue;
-    }
-
-    // build the example variable by using the chado_generate_var() function
-    $values = array('example_id' => $example_id);
-    $example = chado_generate_var('example', $values);
-
-    // for fields in the table that are of type 'text' you may want to include
-    // those by default, the chado_generate_var does not include text fields as
-    // they may be very large and including a large text field can slow the page
-    // load.
-    // If you know a text field will never be large and it is important for the
-    // other functions that will see the node to have access to a field you can
-    // include it here using the chado_expand_var() function. In most
-    // cases it is probably best to let the end-user decide if text fields
-    // should be included by using this function in the templates.
-    $example = chado_expand_var($example, 'field', 'example.description');
-
-    // add the new example object to this node.
-    $nodes[$nid]->example = $example;
-
-    // If your module is using the Chado Node: Title & Path API to allow custom
-    // titles for your node type. Every time you want the title of the node, you
-    // need to use the following API function:
-    $node->title = chado_get_node_title($node);
-
-  }
-}
-
-/**
- * Implementation of hook_node_presave().
- *
- * Performs actions on a node object prior to it being saved
- *
- * @ingroup tripal_example
- */
-function tripal_example_node_presave($node) {
-
-  // EXPLANATION: This node is useful for making changes to the node prior to it
-  // being saved to the database.
-  // One useful case for this is to set the title of a node using values
-  // supplied by the user.
-  //
-  // This function is not required. You probably won't need it if you don't
-  // define a custom node type in the hook_node_info() function. But it is node
-  // type agnostic, so you can use this function to change the contents of any
-  // node regardless of it's type.
-
-  // set the node title
-  switch ($node->type) {
-    // This step is for setting the title for the Drupal node. This title is
-    // permanent and thus is created to be unique. Title changes provided by
-    // tokens are generated on the fly dynamically, but the node title seen in
-    // the content listing needs to be set here. Do not call the
-    // chado_get_node_title() function here to set the title as the node object
-    // isn't properly filled out and the function will fail.
-    case 'chado_example':
-      // for a form submission the 'uniquename' field will be set,
-      // for a sync, we must pull from the example object
-      if (property_exists($node, 'uniquename')) {
-        // set the title
-        $node->title = $node->uniquename;
-      }
-      else if (property_exists($node, 'example')) {
-        $node->title = $node->example->uniquename;
-      }
-      break;
-  }
-}
-
-/**
- * Implementation of hook node_insert().
- *
- * Performs actions after any node has been inserted.
- *
- * @ingroup tripal_example
- */
-function tripal_example_node_insert($node) {
-
-  // EXPLANATION: This function is used after any a node is inserted into the
-  // database. It is different from the hook_insert() function above in that it
-  // is called after any node is saved, regardless of it's type. This function
-  // is useful for making changes to the database after a node is inserted.
-  // An example comes from the tripal_feature module where the URL alias of a
-  // node cannot be set in the hook_insert() function. Therefore the
-  // tripal_feature module uses this function to set the URL path of a newly
-  // inserted example node.
-  //
-  // This function is not required. You probably won't need it if you don't
-  // define a custom node type in the hook_node_info() function. But it is node
-  // type agnostic, so you can use this function to do any activity after insert
-  // of any node.
-
-  // the Example code below will set the URL path after inserting. We do it here
-  // because we do not know the example_id in the pre-save and cannot do it in
-  // the hook_insert()
-  switch ($node->type) {
-    case 'chado_example':
-
-      // find the example and add in the details
-      $example_id = chado_get_id_from_nid('example', $nid);
-
-      // build the example variable by using the chado_generate_var() function
-      $values = array('example_id' => $example_id);
-      $example = chado_generate_var('example', $values);
-      $node->example = $example;
-
-
-      // EXPLANATION: You can allow the site admin to customize the
-      // title and URL of your node.  The 'Chado Node: Title & Path API'
-      // contains two functions that can be called to generate the title and
-      // URL based a schema provided by the site admin. These functions are
-      // named chado_get_node_title() and chado_set_node_url().  These
-      // functions use a string of tokens to build the URL and titles and the
-      // site admin has the ability to set these tokens.  There are
-      // form elements made available in the tripal_example_admin() function
-      // that allow the admin to set these tokens.  The default token string
-      // is provided to Tripal using two hook functions, and are found below.
-      // These are: chado_exmaple_chado_node_default_title() and
-      // chado_example_chdo_node_default_url().
-
-      // Set the Title and URL for this node.
-      $example->title = chado_get_node_title($node);
-      chado_set_node_url($node);
-      break;
-  }
-}
-
-/**
- * Implementation of hook node_update().
- *
- * Performs actions after any node has been updated.
- *
- */
-function tripal_example_node_update($node) {
-
-  // EXPLANATION: This function is used after any a node is updated in the
-  // database. It is different from the hook_update() function above in that it
-  // is called after any node is updated, regardless of it's type.
-  // An example comes from the tripal_feature module where the URL alias of a
-  // node cannot be set in the hook_update() function. Therefore the
-  // tripal_feature module uses this function to reset the URL path of an
-  // updated feature node.
-  //
-  // This function is not required. You probably won't need it if you don't
-  // define a custom node type in the hook_node_info() function. But it is node
-  // type agnostic, so you can use this function to do any activity after insert
-  // of a node.
-
-  // add items to other nodes, build index and search results
-  switch ($node->type) {
-    case 'chado_example':
-
-      // If your module is using the Chado Node: Title & Path API to allow
-      // custom titles for your node type. Every time you want the title of the
-      // node, you need to use the following API function:
-      $example->title = chado_get_node_title($node);
-
-      // set the URL for this example page
-      // see the code in the tripal_feature/includes/tripal_feature.chado_node.inc
-      // file in the function tripal_feature_node_insert for an example of how
-      // that module sets the URL. It uses a configuration file to allow the
-      // user to dynamically build a URL schema and then uses that schema to
-      // generate a URL string.
-      break;
-  }
-}
-/**
- * Implementation of hook_node_view().
- *
- * @ingroup tripal_example
- */
-function tripal_example_node_view($node, $view_mode, $langcode) {
-
-  // EXPLANATION: This function defines the content "blocks" that appear when
-  // the node is displayed. It is node type agnostic so we can add content to
-  // any node type. So, we use this function to add the content from all of our
-  // theme templates onto our new node type. We will also use this function to
-  // add content to other node types.
-
-  switch ($node->type) {
-    case 'chado_example':
-      // there are different ways a node can be viewed. Primarily Tripal
-      // supports full page view and teaser view.
-      if ($view_mode == 'full') {
-
-        // If you want to use the default Tripal node template then you need to
-        // tell Tripal to generate the Table of Contents. This is done by
-        // setting the following to TRUE. If your content type follows the
-        // chado_<base table> convention then this is the default. In this case
-        // if you don't want to use the default template then you need to set
-        // the following to FALSE.
-        $node->content['#tripal_generic_node_template'] = TRUE;
-
-        // There is always a base template. This is the template that is first
-        // shown when the example node type is first displayed.
-        // If you are using the default Tripal node template, then you should
-        // also set two additional items in each array:  tripal_toc_id and
-        // tripal_toc_title. The tripal_tock_id should be a single unique
-        // world that is used to reference the template. This ID is used for
-        // constructing URLs for the content. The tripal_toc_title contains
-        // the title that should appear in the table of contents for this
-        // content. You should only set the '#weight' element for the base
-        // template (or Overview) to ensure that it appears at the top of the
-        // list. Otherwise items are sorted alphabetically.
-        $node->content['tripal_example_base'] = array(
-          '#theme' => 'tripal_example_base',
-          '#node' => $node,
-          '#tripal_toc_id'    => 'base',
-          '#tripal_toc_title' => 'Overview',
-          '#weight' => -100,
-        );
-        // we can add other templates as well for properties, publications,
-        // dbxrefs, etc...
-        $node->content['tripal_example_properties'] = array(
-          '#theme' => 'tripal_example_properties',
-          '#node' => $node,
-          '#tripal_toc_id'    => 'properties',
-          '#tripal_toc_title' => 'Properties',
-        );
-        $node->content['tripal_example_references'] = array(
-          '#theme' => 'tripal_example_references',
-          '#node' => $node,
-          '#tripal_toc_id'    => 'references',
-          '#tripal_toc_title' => 'Cross References',
-        );
-        $node->content['tripal_example_relationships'] = array(
-          '#theme' => 'tripal_example_relationships',
-          '#node' => $node,
-          '#tripal_toc_id'    => 'relationships',
-          '#tripal_toc_title' => 'Relationships',
-        );
-
-        // Note: if you create a template that you do not want a user to know
-        // where it is (discourage editing of it), you can add the following
-        // key:  '#tripal_template_show' => FALSE. If this key/value is set the
-        // administrator message that Tripal provides indicating where the
-        // template is housed will not be shown.
-      }
-      // set the content for the teaser view
-      if ($view_mode == 'teaser') {
-        // The teaser is also a required template
-        $node->content['tripal_example_teaser'] = array(
-          '#theme' => 'tripal_example_teaser',
-          '#node' => $node,
-        );
-      }
-      break;
-    // you can add custom content to any node type by adding content to the node
-    // in the same way as above.
-    case 'chado_organism':
-      if ($view_mode == 'full') {
-        $node->content['tripal_organism_examples'] = array(
-          '#theme' => 'tripal_organism_examples',
-          '#node' => $node,
-          '#tripal_toc_id'    => 'examples',
-          '#tripal_toc_title' => 'Examples',
-        );
-      }
-      break;
-    // ... etc
-  }
-}
-
-
-/**
- * Implements [content_type]_chado_node_default_title_format().
- *
- * Defines a default title format for the Chado Node API to set the titles on
- * Chado example nodes based on chado fields.
- */
-function chado_example_chado_node_default_title_format() {
-  return '[example.name], [example.uniquename] ([example.type_id>cvterm.name]) [example.organism_id>organism.genus] [example.organism_id>organism.species]';
-}
-
-/**
- * Implements hook_chado_node_default_url_format().
- *
- * Designates a default URL format for example nodes.
- */
-function chado_example_chado_node_default_url_format() {
-  return '/example/[example.organism_id>organism.genus]/[example.organism_id>organism.species]/[example.type_id>cvterm.name]/[example.uniquename]';
-}

+ 0 - 9
legacy/tripal_example/theme/js/tripal_example.js

@@ -1,9 +0,0 @@
-(function($) {
-  Drupal.behaviors.tripal_exampleBehavior = {
-    attach: function (context, settings){
-
-      // Place JavaScript code here
-
-    }
-  };
-})(jQuery);

+ 0 - 85
legacy/tripal_example/theme/templates/tripal_example_base.tpl.php

@@ -1,85 +0,0 @@
-<?php
-$example  = $variables['node']->example;  ?>
-
-<div class="tripal_example-data-block-desc tripal-data-block-desc"></div> <?php
-
-// the $headers array is an array of fields to use as the column headers.
-// additional documentation can be found here
-// https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-// This table for the analysis has a vertical header (down the first column)
-// so we do not provide headers here, but specify them in the $rows array below.
-$headers = array();
-
-// the $rows array contains an array of rows where each row is an array
-// of values for each column of the table in that row. Additional documentation
-// can be found here:
-// https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-$rows = array();
-
-// Unique Name row
-$rows[] = array(
-  array(
-    'data' => 'Unique Name',
-    'header' => TRUE
-  ),
-  $example->uniquename
-);
-// Type row
-$rows[] = array(
-  array(
-    'data' => 'Type',
-    'header' => TRUE
-  ),
-  $example->type_id->name
-);
-// Organism row
-$organism = $example->organism_id->genus ." " . $example->organism_id->species ." (" . $example->organism_id->common_name .")";
-if (property_exists($example->organism_id, 'nid')) {
-  $organism = l("<i>" . $example->organism_id->genus . " " . $example->organism_id->species . "</i> (" . $example->organism_id->common_name .")", "node/".$example->organism_id->nid, array('html' => TRUE));
-}
-$rows[] = array(
-  array(
-    'data' => 'Organism',
-    'header' => TRUE,
-  ),
-  $organism
-);
-
-// allow site admins to see the example ID
-if (user_access('view ids')) {
-  // Feature ID
-  $rows[] = array(
-    array(
-      'data' => 'Example ID',
-      'header' => TRUE,
-      'class' => 'tripal-site-admin-only-table-row',
-    ),
-    array(
-      'data' => $example->example_id,
-      'class' => 'tripal-site-admin-only-table-row',
-    ),
-  );
-}
-
-
-// the $table array contains the headers and rows array as well as other options
-// for controlling the display of the table. Additional documentation can be
-// found here:
-// https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-$table = array(
-  'header' => $headers,
-  'rows' => $rows,
-  'attributes' => array(
-    'id' => 'tripal_example-table-base',
-    'class' => 'tripal-data-table'
-  ),
-  'sticky' => FALSE,
-  'caption' => '',
-  'colgroups' => array(),
-  'empty' => '',
-);
-
-// once we have our table array structure defined, we call Drupal's
-// theme_table() function to generate the table.
-print theme_table($table); ?>
-<div style="text-align: justify"><?php print $example->description ?></div>

+ 0 - 8
legacy/tripal_example/theme/templates/tripal_example_help.tpl.php

@@ -1,8 +0,0 @@
-<h3>Module Description:</h3>
-<p>Place details about this module here.</p>
-
-<h3>Setup Instructions:</h3>
-<p>Instructions for setup of this module go here.</p>
-
-<h3>Features of this Module:</h3>
-<p>A description of this module's features go here.</p>

+ 0 - 70
legacy/tripal_example/theme/templates/tripal_example_properties.tpl.php

@@ -1,70 +0,0 @@
-<?php
-$example = $node->example;
-
-// expand the example to include the properties.
-$options = array(
-  'return_array' => 1,
-  'order_by' => array('rank' => 'ASC'),
-);
-$example = chado_expand_var($example,'table', 'exampleprop', $options);
-$exampleprops = $example->exampleprop;
-$properties = array();
-
-if (count($properties)) { ?>
-  <div class="tripal_example-data-block-desc tripal-data-block-desc">Additional details for this example include:</div> <?php
-
-  // the $headers array is an array of fields to use as the column headers.
-  // additional documentation can be found here
-  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $headers = array('Property Name', 'Value');
-
-  // the $rows array contains an array of rows where each row is an array
-  // of values for each column of the table in that row. Additional
-  // documentation can be found here:
-  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $rows = array();
-
-  $keywords = array();
-  foreach ($properties as $property) {
-    // each keyword is stored as a separate properties. We want to show them
-    // only in a single field not as a bunch of individual properties, so when
-    // we see one, save it in an array for later and don't add it yet to the
-    // table yet.
-    if ($property->type_id->name == 'Keywords') {
-      $keywords[] = $property->value;
-      continue;
-    }
-    $rows[] = array(
-      $property->type_id->name,
-      $property->value
-    );
-  }
-  // now add in a single row for all keywords
-  if (count($keywords) > 0) {
-    $rows[] = array(
-      'Keywords',
-      implode(', ', $keywords),
-    );
-  }
-
-  // the $table array contains the headers and rows array as well as other
-  // options for controlling the display of the table. Additional documentation
-  // can be found here:
-  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $table = array(
-    'header' => $headers,
-    'rows' => $rows,
-    'attributes' => array(
-      'id' => 'tripal_example-table-properties',
-      'class' => 'tripal-data-table'
-    ),
-    'sticky' => FALSE,
-    'caption' => '',
-    'colgroups' => array(),
-    'empty' => '',
-  );
-
-  // once we have our table array structure defined, we call Drupal's
-  // theme_table() function to generate the table.
-  print theme_table($table);
-}

+ 0 - 70
legacy/tripal_example/theme/templates/tripal_example_references.tpl.php

@@ -1,70 +0,0 @@
-<?php
-$example = $variables['node']->example;
-
-// expand the example object to include the records from the example_dbxref
-// table
-$options = array('return_array' => 1);
-$example = chado_expand_var($example, 'table', 'example_dbxref', $options);
-$example_dbxrefs = $example->example_dbxref;
-
-$references = array();
-if (count($example_dbxrefs) > 0 ) {
-  foreach ($example_dbxrefs as $example_dbxref) {
-    $references[] = $example_dbxref->dbxref_id;
-  }
-}
-
-if(count($references) > 0){ ?>
-  <div class="tripal_example-data-block-desc tripal-data-block-desc">This example is also available in the following databases:</div><?php
-
-  // the $headers array is an array of fields to use as the colum headers.
-  // additional documentation can be found here
-  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $headers = array('Database', 'Accession');
-
-  // the $rows array contains an array of rows where each row is an array
-  // of values for each column of the table in that row. Additional
-  // documentation can be found here:
-  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $rows = array();
-
-  foreach ($references as $dbxref){
-    $database = $dbxref->db_id->name . ': ' . $dbxref->db_id->description;
-    if ($dbxref->db_id->url) {
-      $database = l($dbxref->db_id->name, $dbxref->db_id->url, array('attributes' => array('target' => '_blank'))) . ': ' . $dbxref->db_id->description;
-    }
-    $accession = $dbxref->db_id->name . ':' . $dbxref->accession;
-    if ($dbxref->db_id->urlprefix) {
-      $accession = l($accession, $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));
-    }
-    if (property_exists($dbxref, 'is_primary')) {
-      $accession .= " <i>(primary cross-reference)</i>";
-    }
-
-    $rows[] = array(
-      $database,
-      $accession
-    );
-  }
-  // the $table array contains the headers and rows array as well as other
-  // options for controlling the display of the table. Additional documentation
-  // can be found here:
-  // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $table = array(
-    'header' => $headers,
-    'rows' => $rows,
-    'attributes' => array(
-      'id' => 'tripal_example-table-references',
-      'class' => 'tripal-data-table'
-    ),
-    'sticky' => FALSE,
-    'caption' => '',
-    'colgroups' => array(),
-    'empty' => '',
-  );
-
-  // once we have our table array structure defined, we call Drupal's theme_table()
-  // function to generate the table.
-  print theme_table($table);
-}
-

+ 0 - 151
legacy/tripal_example/theme/templates/tripal_example_relationships.tpl.php

@@ -1,151 +0,0 @@
-<?php
-/* Typically in a Tripal template, the data needed is retrieved using a call to
- * chado_expand_var function. For example, to retrieve all of the example
- * relationships for this node, the following function call would be made:
- *
- *   $example = chado_expand_var($example,'table','example_relationship');
- *
- * However, this function call can be extremely slow when there are numerous
- * relationships. This is because the chado_expand_var function is recursive and
- * expands all data following the foreign key relationships tree. Therefore, to
- * speed retrieval of data, a special variable is provided to this template:
- *
- *   $example->all_relationships;
- *
- * This variable is an array with two sub arrays with the keys 'object' and
- * 'subject'. The array with key 'object' contains relationships where the
- * example is the object, and the array with the key 'subject' contains
- * relationships where the example is the subject.
- */
-$example = $variables['node']->example;
-
-$all_relationships = $example->all_relationships;
-$object_rels = $all_relationships['object'];
-$subject_rels = $all_relationships['subject'];
-
-if (count($object_rels) > 0 or count($subject_rels) > 0) { ?>
-  <div class="tripal_example-data-block-desc tripal-data-block-desc"></div> <?php
-
-  // first add in the subject relationships.
-  foreach ($subject_rels as $rel_type => $rels){
-    foreach ($rels as $obj_type => $objects){ ?>
-      <p>This <?php print $example->type_id->name;?> is <?php print $rel_type ?> the following <b><?php print $obj_type ?></b> example(s): <?php
-
-      // the $headers array is an array of fields to use as the colum headers.
-      // additional documentation can be found here
-      // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-      $headers = array('Publication');
-
-      // the $rows array contains an array of rows where each row is an array
-      // of values for each column of the table in that row. Additional
-      // documentation can be found here:
-      // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-      $rows = array();
-
-      foreach ($objects as $object){
-        // link the example to it's node
-        $title = $object->record->object_id->title;
-        if (property_exists($object->record, 'nid')) {
-          $title = l($title, "node/" . $object->record->nid, array('attributes' => array('target' => "_blank")));
-        }
-
-        // get the citation
-        $values = array(
-          'example_id' => $object->record->object_id->example_id,
-          'type_id' => array(
-            'name' => 'Citation',
-          ),
-        );
-        $citation = chado_generate_var('exampleprop', $values);
-        $citation = chado_expand_var($citation, 'field', 'exampleprop.value');
-
-        $rows[] = array(
-          $title . '<br>' . htmlspecialchars($citation->value),
-        );
-       }
-       // the $table array contains the headers and rows array as well as other
-       // options for controlling the display of the table. Additional
-       // documentation can be found here:
-       // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-       $table = array(
-         'header' => $headers,
-         'rows' => $rows,
-         'attributes' => array(
-           'id' => 'tripal_example-table-relationship-object',
-           'class' => 'tripal-data-table'
-         ),
-         'sticky' => FALSE,
-         'caption' => '',
-         'colgroups' => array(),
-         'empty' => '',
-       );
-
-       // once we have our table array structure defined, we call Drupal's
-       // theme_table() function to generate the table.
-       print theme_table($table); ?>
-       </p>
-       <br><?php
-     }
-  }
-
-  // second add in the object relationships.
-  foreach ($object_rels as $rel_type => $rels){
-    foreach ($rels as $subject_type => $subjects){?>
-      <p>The following <b><?php print $subjects[0]->record->subject_id->type_id->name ?></b> example(s) are <?php print $rel_type ?> this <?php print $example->type_id->name;?>: <?php
-      // the $headers array is an array of fields to use as the colum headers.
-      // additional documentation can be found here
-      // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-      $headers = array('Publication');
-
-      // the $rows array contains an array of rows where each row is an array
-      // of values for each column of the table in that row. Additional
-      // documentation can be found here:
-      // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-      $rows = array();
-
-      foreach ($subjects as $subject){
-        // link the example to it's node
-        $title = $subject->record->subject_id->title;
-        if (property_exists($subject->record, 'nid')) {
-          $title = l($title, "node/" . $subject->record->nid, array('attributes' => array('target' => "_blank")));
-        }
-
-        // get the citation
-        $values = array(
-          'example_id' => $subject->record->subject_id->example_id,
-          'type_id' => array(
-            'name' => 'Citation',
-          ),
-        );
-        $citation = chado_generate_var('exampleprop', $values);
-        $citation = chado_expand_var($citation, 'field', 'exampleprop.value');
-
-        $rows[] = array(
-          $title . '<br>' . htmlspecialchars($citation->value),
-        );
-       }
-       // the $table array contains the headers and rows array as well as other
-       // options for controlling the display of the table. Additional
-       // documentation can be found here:
-       // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-       $table = array(
-         'header' => $headers,
-         'rows' => $rows,
-         'attributes' => array(
-           'id' => 'tripal_example-table-relationship-subject',
-           'class' => 'tripal-data-table'
-         ),
-         'sticky' => FALSE,
-         'caption' => '',
-         'colgroups' => array(),
-         'empty' => '',
-       );
-
-       // once we have our table array structure defined, we call Drupal's
-       // theme_table() function to generate the table.
-       print theme_table($table); ?>
-       </p>
-       <br><?php
-     }
-  }
-}

+ 0 - 14
legacy/tripal_example/theme/templates/tripal_example_teaser.tpl.php

@@ -1,14 +0,0 @@
-<?php
-$example  = $variables['node']->example; ?>
-
-<div class="tripal_example-teaser tripal-teaser"> 
-  <div class="tripal-example-teaser-title tripal-teaser-title"><?php 
-    print l("<i>$example->uniquename", "node/$node->nid", array('html' => TRUE));?>
-  </div>
-  <div class="tripal-example-teaser-text tripal-teaser-text"> <?php
-    print substr($example->description, 0, 650);
-    if (strlen($example->description) > 650) {
-      print "... " . l("[more]", "node/$node->nid");
-    } ?>
-  </div>
-</div>

+ 0 - 113
legacy/tripal_example/theme/tripal_example.theme.inc

@@ -1,113 +0,0 @@
-<?php
-
-/**
- * @file
- *
- * This file should contain all Drupal hooks for theming content. For templates
- * that need specific the hook_preprocess functions should be included here
- *
- */
-
-/**
- * implementation of hook_preprocess_HOOK()
- *
- * Used to alter or add to theme variables. The variables are passed into
- * templates when processing. This function organizes the relationships
- * into more simple structures for parsing in the template file.
- *
- * @ingroup tripal_example
- */
-function tripal_example_preprocess_tripal_example_relationships(&$variables) {
-  // EXPLANATION:  If you have implemented a new Chado node type and the record
-  // that belongs to the node has a corresponding xxxx_relationship table
-  // this this function can be used to provide relationships to the template
-  // in a format that is easier to parse. This is one example where specific SQL
-  // statements can improve performance over Tripal API calls. SQL is not
-  // recommended inside of template files, but rather the Tripal API calls only.
-  // Therefore, this function queries the relationships and then organizes them
-  // into arrays that are easier and faster to parse. You should be able to
-  // copy the content of this function and adjust as necessary to change table
-  // names if your record has relationships.
-
-  $example = $variables['node']->example;
-
-   // expand the example object to include the example relationships.
-  $options = array(
-    'return_array' => 1,
-    // we don't want to fully recurs we only need information about the
-    // relationship type and the object and subject examples (including example
-    // type)
-    'include_fk' => array(
-      'type_id' => 1,
-      'object_id' => array(
-        'type_id' => 1,
-      ),
-      'subject_id'  => array(
-        'type_id' => 1,
-      ),
-    ),
-  );
-  $example = chado_expand_var($example, 'table', 'example_relationship', $options);
-
-  // get the subject relationships
-  $srelationships = $example->example_relationship->subject_id;
-  $orelationships = $example->example_relationship->object_id;
-
-  // combine both object and subject relationships into a single array
-  $relationships = array();
-  $relationships['object'] = array();
-  $relationships['subject'] = array();
-
-  // iterate through the object relationships
-  if ($orelationships) {
-    foreach ($orelationships as $relationship) {
-      $rel = new stdClass();
-      $rel->record = $relationship;
-
-      // get the relationship and child types
-      $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
-      $child_type = $relationship->subject_id->type_id->name;
-
-      // get the node id of the subject
-      $sql = "SELECT nid FROM {chado_example} WHERE example_id = :example_id";
-      $n = db_query($sql, array(':example_id' => $relationship->subject_id->example_id))->fetchObject();
-      if ($n) {
-        $rel->record->nid = $n->nid;
-      }
-
-      if (!array_key_exists($rel_type, $relationships['object'])) {
-        $relationships['object'][$rel_type] = array();
-      }
-      if (!array_key_exists($child_type, $relationships['object'][$rel_type])) {
-        $relationships['object'][$rel_type][$child_type] = array();
-      }
-      $relationships['object'][$rel_type][$child_type][] = $rel;
-    }
-  }
-
-  // now add in the subject relationships
-  if ($srelationships) {
-    foreach ($srelationships as $relationship) {
-      $rel = new stdClass();
-      $rel->record = $relationship;
-      $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
-      $parent_type = $relationship->object_id->type_id->name;
-
-      // get the node id of the subject
-      $sql = "SELECT nid FROM {chado_example} WHERE example_id = :example_id";
-      $n = db_query($sql, array(':example_id' => $relationship->object_id->example_id))->fetchObject();
-      if ($n) {
-        $rel->record->nid = $n->nid;
-      }
-
-      if (!array_key_exists($rel_type, $relationships['subject'])) {
-        $relationships['subject'][$rel_type] = array();
-      }
-      if (!array_key_exists($parent_type, $relationships['subject'][$rel_type])) {
-        $relationships['subject'][$rel_type][$parent_type] = array();
-      }
-      $relationships['subject'][$rel_type][$parent_type][] = $rel;
-    }
-  }
-  $example->all_relationships = $relationships;
-}

+ 0 - 50
legacy/tripal_example/tripal_example.info

@@ -1,50 +0,0 @@
-;
-; Provide details about your module in this file. Instruction for setup of this
-; file can be found here: https://drupal.org/node/542202
-;
-name = Tripal Example
-description = An example module that can be used as a template for anyone wanting to create a custom extension module for Tripal.
-
-;
-; The version of Drupal with which this module is compatible.
-;
-core = 7.x
-
-;
-; The computer-readable name for this module
-;
-project = tripal_example
-
-;
-; In order for this module to appear in the 'Tripal Extensions' section when
-; viewing the module administrative page, the package must be set to
-; 'Tripal Extensions'
-;
-package = Tripal v2 Legacy Extensions
-
-;
-; Follow these instructions when specifying the version:
-; https://drupal.org/node/1015226
-;
-version = 7.x-3.0-alpha1
-
-;
-; Style-sheets containing CSS that should always be available for the
-; module should be specified here.
-;
-stylesheets[all][] = theme/css/tripal_example.css
-
-;
-; Javascript files that should always be available for the
-; module should be specified here.
-;
-scripts[]          = theme/js/tripal_example.js
-
-;
-; Add additional dependencies for other modules using the module project name.
-; These modules must be enabled before this module can be enabled
-;
-dependencies[] = tripal_core
-dependencies[] = tripal_views
-dependencies[] = tripal_db
-dependencies[] = tripal_cv

+ 0 - 608
legacy/tripal_example/tripal_example.install

@@ -1,608 +0,0 @@
-<?php
-/**
- * @file
- * Installation of the example module
- */
-
-/**
- * Implements hook_disable().
- *
- * Perform actions when the module is disabled by the site administrator
- *
- * @ingroup tripal_example
- */
-function tripal_example_disable() {
-
-  // EXPLANATION: If you are using Drupal Views you want to ensure that any
-  // default views that your module provides are disabled when the module is
-  // disabled. Default views are specified in the
-  // [module name].views.default.inc file. The following code will disable these
-  // views. If your module does not create any default views you can remove the
-  // following code.
-
-  // Disable all default views provided by this module
-  require_once("tripal_example.views_default.inc");
-  $views = tripal_example_views_default_views();
-  foreach (array_keys($views) as $view_name) {
-    tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
-  }
-
-}
-
-/**
- * Implements hook_requirements().
- *
- * Performs check to see if all required dependencies are met. Drupal will
- * automatically check for module dependencies but here you can check for other
- * requirements.
- *
- * @ingroup tripal_example
- */
-function tripal_example_requirements($phase) {
-
-
-  $requirements = array();
-  if ($phase == 'install') {
-    // EXPLANATION: It is essential that Chado be installed for almost all
-    // Tripal modules. Therefore, the following code checks to ensure Chado is
-    // installed and available. If your module does not require that Chado be
-    // installed, you can remove the following check.
-
-    // make sure chado is installed
-    if (!$GLOBALS["chado_is_installed"]) {
-      $requirements ['tripal_example'] = array(
-          'title' => "tripal_example",
-          'value' => "ERROR: Chado must be installed before this module can be enabled",
-          'severity' => REQUIREMENT_ERROR,
-      );
-    }
-  }
-  return $requirements;
-}
-
-/**
- * Implements hook_install().
- *
- * Performs actions when the modules is first installed.
- *
- * @ingroup tripal_example
- */
-function tripal_example_install() {
-
-  // EXPLANATION: Here is a good place to add any materialized views, controlled
-  // vocabularies CV, databases or CV terms needed by your module.
-  // To keep this module code short, create functions to do each of those tasks
-
-  // add any materialized view
-  tripal_example_add_mviews();
-
-  // add any external databases used by the example module.
-  tripal_example_add_dbs();
-
-  // add any controlled vocabularies used by the example module. You may need
-  // to add a vocabulary if you to set it as default (see next lines of code).
-  // For example, the Sequence Ontology (SO) is used by the feature module as
-  // the default vocabulary for the feature type_id field. But, that vocabulary
-  // does not yet exist in Chado until after the SO is loaded using the Tripal
-  // OBO loader. But, we can add it here as a place-holder so that we can then
-  // set it as a default vocabulary (see below).
-  tripal_example_add_cvs();
-
-
-  // add any controlled vocabulary terms
-  tripal_example_add_cvterms();
-
-  // EXPLANATION: Many tables in Chado have a 'type_id' column which allows for
-  // association of controlled vocabularies to describe the record. Chado places
-  // no restrictions on which vocabularies can be used, but Tripal can be
-  // instructed to provide a default vocabulary for any given field. For
-  // example, the feature.type_id column will typically use the Sequence
-  // Ontology. In that case, we can use the tripal_set_default_cv() function to
-  // specify the Sequence Ontology (sequence) as the default vocabulary.
-  tripal_set_default_cv('example', 'type_id', 'example_type');
-  tripal_set_default_cv('exampleprop', 'type_id', 'example_property');
-  tripal_set_default_cv('example_relationship', 'type_id', 'example_relationship');
-
-  // add any custom tables. For this case we will add an 'example' table to the
-  // chado schema
-  tripal_example_add_custom_tables();
-}
-
-
-/**
- * Implements hook_uninstall().
- *
- * Performs actions when the modules is uninstalled.
- *
- * @ingroup tripal_example
- */
-function tripal_example_uninstall() {
-
-}
-
-/**
- * Implementation of hook_schema().
- *
- * Provides a list of tables to be created inside of the Drupal schema (the
- * 'public' schema by default). It uses the Drupal Schema API array structure to
- * define the table, its indexes and constraints.
- *
- * Schema API documentation is here:
- * https://api.drupal.org/api/drupal/includes%21database%21schema.inc/group/schemaapi/7
- *
- * @ingroup tripal_example
- */
-function tripal_example_schema() {
-
-  // EXPLANATION: If your module creates a node type for data in the Chado
-  // database then you probably need to link Drupal nodes with a respective ID
-  // in the Chado table. The following is an example array for a table that will
-  // link the 'chado_example' node type (created by this example module) with a
-  // record in the fake Chado example table. This table will link the 'nid' of
-  // the node with the 'example_id' of the example record.
-  $schema['chado_example'] = 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
-       ),
-      'example_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(
-      'chado_example_idx1' => array('example_id')
-    ),
-    'unique keys' => array(
-      'chado_example_uq1' => array('nid', 'vid'),
-      'chado_example_uq2' => array('vid')
-    ),
-    'primary key' => array('nid'),
-  );
-
-  return $schema;
-};
-
-/**
- * Creates a materialized view that stores the type & number of examples per
- * organism.
- *
- * @ingroup tripal_example
- */
-function tripal_example_add_mviews() {
-
-  // EXPLANATION: use the tripal_add_mview() function to add a materialized view
-  // needed by your module. If you have more than one materialized view it is
-  // best to create a single function for each one and call each function here.
-  // Otherwise this function can become quite long.
-
-}
-/**
- * Add cvs related to publications
- *
- * @ingroup tripal_example
- */
-function tripal_example_add_dbs() {
-  // EXPLANATION: use the tripal_insert_db() function to add any external
-  // databases needed by your module. If the database already exists then the
-  // function will gracefully return.
-
-  tripal_insert_db(array(
-    'name' => 'example_db',
-    'description' => 'An example database.'
-  ));
-}
-/**
- * Add cvs related to publications
- *
- * @ingroup tripal_example
- */
-function tripal_example_add_cvs() {
-
-  // EXPLANATION: use the tripal_insert_cv() function to add any controlled
-  // vocabularies needed by your module. If the vocabulary already exists then
-  // the function will gracefully return. Chado conventions use a singular name
-  // for CV names (not plural).
-
-  tripal_insert_cv(
-    'example_property',
-    'Contains property terms for examples.'
-  );
-
-  tripal_insert_cv(
-    'example_type',
-    'Contains terms describing types of examples.'
-  );
-
-  tripal_insert_cv(
-   'example_relationship',
-   'Contains terms for describing relationship types between examples.'
-  );
-
-}
-
-/**
- * Adds controlled vocabulary terms needed by this module.
- *
- * @ingroup tripal_example
- */
-function tripal_example_add_cvterms() {
-
-  // EXPLANATION: for our test module to work we need to add some terms to our
-  // example_type controlled vocabulary. Ideally we should have a full OBO file
-  // for loading but sometimes we just have a small list that won't really
-  // change so we can add those terms here.
-  tripal_insert_cvterm(array(
-    'id'         => 'test',         // the term accession
-    'name'       => 'Test type',    // the human readable term name
-    'cv_name'    => 'example_type', // the CV name this term belongs to.
-    'definition' => 'A test type for the example module.',
-    'db_name'    => 'example_db',   // the database in which the term is found.
-  ));
-}
-
-/**
- * Add custom tables to Chado that are required by this module
- *
- * @ingroup tripal_example
- */
-function tripal_example_add_custom_tables() {
-
-  // EXPLANATION: for this example module we will create a set of example tables
-  // that mimic Chado tables. These tables are:
-  //
-  //   1) example     (for storing the primary example records)
-  //   2) exampleprop (for sorting properties about the example)
-  //   3) example_relationship (for storing relationships about examples)
-  //   4) example_dbxref (for storing cross-references about an example)
-  //
-  // To make the code easier to read, each table is created by a separate
-  // function called here:
-
-  tripal_example_add_example_table();
-  tripal_example_add_exampleprop_table();
-  tripal_example_add_example_relationship_table();
-  tripal_example_add_example_dbxref_table();
-}
-
-/**
- * Adds the 'example' custom table to Chado.
- *
- * @ingroup tripal_example
- */
-function tripal_example_add_example_table() {
-  // EXPLANATION: use the Drupal Schema API to describe the custom table. Then
-  // add the table using the chado_create_custom_table() function.
-  $schema = array(
-    'table' => 'example',
-    'fields' => array(
-      'example_id' => array(
-        'type' => 'serial',
-        'not null' => true,
-      ),
-      'uniquename' => array(
-        'type' => 'varchar',
-        'length' => '255',
-        'not null' => TRUE,
-      ),
-      'type_id' => array(
-        'type' => 'int',
-        'not null' => true,
-      ),
-      'organism_id' => array(
-        'type' => 'int',
-        'not null' => true,
-      ),
-      'description' => array(
-        'type' => 'text',
-      ),
-    ),
-    'primary key' => array(
-      0 => 'example_id',
-    ),
-    'unique keys' => array(
-      'example_uq1' => array(
-        0 => 'uniquename',
-        1 => 'type_id',
-        2 => 'organism_id',
-      ),
-    ),
-    'indexes' => array(
-      'example_idx1' => array(
-        0 => 'example_id',
-      ),
-      'example_idx2' => array(
-        0 => 'uniquename',
-      ),
-    ),
-    'foreign keys' => array(
-      'cvterm' => array(
-        'table' => 'cvterm',
-        'columns' => array(
-          'type_id' => 'cvterm_id',
-        ),
-      ),
-      'organism' => array(
-        'table' => 'organism',
-        'columns' => array(
-          'organism_id' => 'organism_id',
-        ),
-      ),
-    ),
-    // EXPLANATION: the 'referring_tables' array is the list of tables that have
-    // a foreign key relationships with this table. This information is required
-    // for the Tripal API to be able to expand tables in templates.
-    'referring_tables' => array(
-      0 => 'example_relationship',
-      1 => 'exampleprop',
-      2 => 'example_dbxref',
-    ),
-  );
-  chado_create_custom_table('example', $schema, TRUE);
-}
-/**
- * Adds the 'example_relationship' custom table to Chado.
- *
- * @ingroup tripal_example
- */
-function tripal_example_add_exampleprop_table() {
-  // EXPLANATION: use the Drupal Schema API to describe the custom table. Then
-  // add the table using the chado_create_custom_table() function.
-
-  // Add the exampleprop table
-  $schema =  array(
-    'table' => 'exampleprop',
-    'fields' => array(
-      'exampleprop_id' => array(
-        'type' => 'serial',
-        'not null' => TRUE,
-      ),
-      'example_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'type_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'value' => array(
-        'type' => 'text',
-        'not null' => FALSE,
-      ),
-      'rank' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-    ),
-    'primary key' => array(
-      0 => 'exampleprop_id',
-    ),
-    'unique keys' => array(
-      'example_id_type_id_rank' => array(
-        0 => 'example_id',
-        1 => 'type_id',
-        2 => 'rank',
-      ),
-    ),
-    'foreign keys' => array(
-      'cvterm' => array(
-        'table' => 'cvterm',
-        'columns' => array(
-          'type_id' => 'cvterm_id',
-        ),
-      ),
-      'example' => array(
-        'table' => 'example',
-        'columns' => array(
-          'example_id' => 'example_id',
-        ),
-      ),
-    ),
-  );
-  chado_create_custom_table('exampleprop', $schema, TRUE);
-}
-
-/**
- * Adds the 'example_relationship' custom table to Chado.
- *
- * @ingroup tripal_example
- */
-function tripal_example_add_example_relationship_table() {
-  // EXPLANATION: use the Drupal Schema API to describe the custom table. Then
-  // add the table using the chado_create_custom_table() function.
-
-  $schema =  array(
-    'table' => 'example_relationship',
-    'fields' => array(
-      'example_relationship_id' => array(
-        'type' => 'serial',
-        'not null' => TRUE,
-      ),
-      'subject_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'object_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'type_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'value' => array(
-        'type' => 'text',
-        'not null' => FALSE,
-      ),
-      'rank' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-        'default' => 0,
-      ),
-    ),
-    'primary key' => array(
-      0 => 'example_relationship_id',
-    ),
-    'unique keys' => array(
-      'example_relationship_c1' => array(
-        0 => 'subject_id',
-        1 => 'object_id',
-        2 => 'type_id',
-        3 => 'rank',
-      ),
-    ),
-    'indexes' => array(
-      'example_relationship_idx1' => array(
-        0 => 'subject_id',
-      ),
-      'example_relationship_idx2' => array(
-        0 => 'object_id',
-      ),
-      'example_relationship_idx3' => array(
-        0 => 'type_id',
-      ),
-    ),
-    'foreign keys' => array(
-      'cvterm' => array(
-        'table' => 'cvterm',
-        'columns' => array(
-          'type_id' => 'cvterm_id',
-        ),
-      ),
-      'example' => array(
-        'table' => 'example',
-        'columns' => array(
-          'subject_id' => 'example_id',
-          'object_id' => 'example_id',
-        ),
-      ),
-    ),
-  );
-  chado_create_custom_table('example_relationship', $schema, TRUE);
-}
-
-/**
- * Adds the 'example_dbxref' custom table to Chado.
- *
- * @ingroup tripal_example
- */
-function tripal_example_add_example_dbxref_table() {
-
-  // EXPLANATION: use the Drupal Schema API to describe the custom table. Then
-  // add the table using the chado_create_custom_table() function.
-
-  $schema =  array(
-    'table' => 'example_dbxref',
-    'fields' => array(
-      'example_dbxref_id' => array(
-        'type' => 'serial',
-        'not null' => TRUE,
-      ),
-      'example_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'dbxref_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'is_current' => array(
-        'type' => 'int',
-        'size' => 'tiny',
-        'not null' => TRUE,
-        'default' => 1,
-      ),
-    ),
-    'primary key' => array(
-      0 => 'example_dbxref_id',
-    ),
-    'unique keys' => array(
-      'example_dbxref_unq1' => array(
-        0 => 'example_id',
-        1 => 'dbxref_id',
-      ),
-    ),
-    'indexes' => array(
-      'example_dbxref_idx1' => array(
-        0 => 'example_id',
-      ),
-      'example_dbxref_idx2' => array(
-        0 => 'dbxref_id',
-      ),
-    ),
-    'foreign keys' => array(
-      'dbxref' => array(
-        'table' => 'dbxref',
-        'columns' => array(
-          'dbxref_id' => 'dbxref_id',
-        ),
-      ),
-      'example' => array(
-        'table' => 'example',
-        'columns' => array(
-          'example_id' => 'example_id',
-        ),
-      ),
-    ),
-  );
-  chado_create_custom_table('example_dbxref', $schema, TRUE);
-}
-/**
- * This is the required update for tripal_example.
- */
-function tripal_example_update_7200() {
-  // EXPLANATION: as you create new releases of your module you may find that
-  // tables your module created, or data may need to be adjusted. This function
-  // allows you to do that. This function is executed using the
-  // http://[your site]/update.php  URL or using the drush command 'updatedb'.
-  // This function should be named according to the instructions provided here:
-  // https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_update_N/7
-  //
-  // It is best not to use Tripal API calls inside of this function because an
-  // upgrade from Drupal 6 to Drupal 7 requires that all modules be disabled
-  // which means the Tripal API is not available. This is an unfortunate
-  // requirement, but will prevent errors during a major upgrade.
-
-  // it is good to wrap any database changes inside of a try catch block:
-  try {
-   // perform database changes
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Could not apply updates: '. $error);
-  }
-}
-
-/**
- * Implementation of hook_update_dependencies(). It specifies a list of other
- * modules whose updates must be run prior to this one.
- */
-function tripal_example_update_dependencies() {
-  $dependencies = array();
-
-  // EXPLANATION: here we can specify which modules must be updated prior to
-  // applying the updates in this module. This is useful because it prevents
-  // updates from being executed out of order. The following example code shows
-  // that the 'tripal_example' module update number 7200 must be executed after
-  // the 'tripal_cv' module's 7200 update.
-  $dependencies['tripal_example'][7200] = array(
-    'tripal_cv' => 7200
-  );
-
-  return $dependencies;
-}

+ 0 - 365
legacy/tripal_example/tripal_example.module

@@ -1,365 +0,0 @@
-<?php
-
-/**
- * @file
- * This file contains all Drupal hooks for the module other than any node hooks
- * and block hooks. Those go in the [module name].chado_node.inc file and
- * [module_name].blocks.inc respectively
- *
- */
-
-// EXPLANATION: include any files needed for this module. That includes any API
-// file, the theme file, or files with functions for new node types.  Try to
-// include other files only when needed so as to reduce the loading time
-// for the module.
-require('api/tripal_example.api.inc');
-require('theme/tripal_example.theme.inc');
-require('includes/tripal_example.chado_node.inc');
-
-
-/**
- * Implementation of hook_permissions()
- *
- * Set the permission types that this module uses.
- *
- * @ingroup tripal_example
- */
-function tripal_example_permission() {
-
-  // EXPLANATION:  here we want to setup any of the permission types that this
-  // module needs. Our example module creates a new chado node type called
-  // 'chado_example'. Therefore, we need permissions to view, edit, delete,
-  // create our new node type. Additionally, we want to add a permission that
-  // allows for administration of this module. These permissions will appear in
-  // the 'People' -> 'Permissions' configuration page and allow the site admin
-  // to specify which user roles are allowed to perform specific actions.
-  return array(
-    'access chado_example content' => array(
-      'title' => t('View Examples'),
-      'description' => t('Allow users to view example pages.'),
-    ),
-    'create chado_example content' => array(
-      'title' => t('Create Examples'),
-      'description' => t('Allow users to create new example pages.'),
-    ),
-    'delete chado_example content' => array(
-      'title' => t('Delete Examples'),
-      'description' => t('Allow users to delete example pages.'),
-    ),
-    'edit chado_example content' => array(
-      'title' => t('Edit Examples'),
-      'description' => t('Allow users to edit example pages.'),
-    ),
-    'administer tripal example' => array(
-      'title' => t('Administer Examples'),
-      'description' => t('Allow users to administer all examples.'),
-    ),
-  );
-}
-
-/**
- * Implements hook_menu()
- *
- * Specifies menu items and URLs used by this module.
- *
- * @ingroup tripal_example
- */
-function tripal_example_menu() {
-  $items = array();
-
-  // EXPLANATION:  the $items array should be populated to contain a list of
-  // menu items or URL callbacks that our module needs.
-  // all Tripal Extension modules should provide at least these menu items:
-  //  * A menu item for an administrative home page
-  //  * A menu item for 'Help' documentation
-  //  * A menu item for a module configuration page
-  //
-  // Additionally, if your module defines a custom node type that is linked
-  // to a record in Chado:
-  //  * A menu item for syncing drupal nodes with Chado records.
-  //
-
-  // EXPLANATION:  all extension modules should have an administrative menu item
-  // with the path set to 'admin/tripal/extension/[module name]'. This will
-  // place the menu item in the 'Tripal' -> 'Extension Modules' page. Because
-  // this is an administrative menu item we must be sure to set the
-  // 'access arguments' to be 'administer tripal example' which is a permission
-  // type we created in the tripal_example_permissions() function above.
-  $items['admin/tripal/extension/tripal_example'] = array(
-    'title' => 'Examples',
-    'description' => 'Example module for help with development of new extension modules.',
-    'page callback' => 'tripal_example_admin_examples_listing',
-    'access arguments' => array('administer tripal example'),
-    'type' => MENU_NORMAL_ITEM,
-    // We include the file where the 'page callback' function
-    // is located.  This removes the need to include all of the
-    // include files at the top of the module, and speeds
-    // module loading time.
-    'file' => '/includes/tripal_example.admin.inc',
-  );
-
-  // EXPLANATION: all extension modules should provide help documentation to
-  // describe the functionality of the module and any installation or setup
-  // tasks that may be required. The menu 'type' is MENU_LOCAL_TASK so that the
-  // link appears in a tab on the extension module's administrative page.
-  // Here the 'page callback' specifies that we are using Drupal's theme
-  // function and the 'page_arguments' indicate the name of the template file
-  // Thus, all help documentation should be provided in the
-  // [module name]/theme/tripal_example_help.tpl.php file.
-  $items['admin/tripal/extension/tripal_example/help'] = array(
-    'title' => 'Help',
-    'description' => 'Basic Description of Tripal Library Module Functionality',
-    'page callback' => 'theme',
-    'page arguments' => array('tripal_example_help'),
-    'access arguments' => array('administer tripal example'),
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 10,
-  );
-
-  // EXPLANATION: all extension modules should provide a configuration page.
-  // Even if your module does not need configuration the menu item and page
-  // should be created. This helps users recognize that the module is installed
-  // and working. The configuration page can simply state that no configuration
-  // settings are available. Typically a form is provided for the module's
-  // configuration settings. Therefore the 'page callback' uses the
-  // drupal_get_form() function and the 'page argument' indicates the form
-  // to call is named 'tripal_eample_admin'. The function that describes
-  // to form is in the includes/tripal_example.admin.inc file.
-  $items['admin/tripal/extension/tripal_example/configuration'] = array(
-    'title' => 'Settings',
-    'description' => 'Configure the Tripal Library module',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_example_admin'),
-    'access arguments' => array('administer tripal example'),
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 5,
-  );
-
-  // EXPLANATION: If your module defines a new chado node type and that node
-  // type directly links to a record in Chado, then you can use the Tripal API
-  // to quickly provide syncing functionality. See the API documentation here
-  // for more information on how that is setup:
-  // http://api.tripal.info/api/tripal/tripal_core%21api%21tripal_core.chado_nodes.api.inc/function/chado_node_sync_form/2.x
-  $items['admin/tripal/extension/tripal_example/sync'] = array(
-    'title' => ' Sync',
-    'description' => 'Create pages on this site for examples stored in Chado',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('chado_node_sync_form', 'tripal_example', 'chado_example'),
-    'access arguments' => array('administer tripal example'),
-    'type' => MENU_LOCAL_TASK,
-    'weight' => 2,
-  );
-
-  // EXPLANATION: If your module defines a new node type that uses the default
-  // table of contents (left-side bar of content panes on a page). Then a 'TOC'
-  // link will automatically appear on the node page to allow for customization
-  // of the TOC. However those customizations are only node specific. To provide
-  // a tab in the module's administrative pages add the following menu item.
-  // This menu will provide a form similar to the one found on the node that
-  // allows the user to set global TOC settings for the content type. Be sure to
-  // always use a menu path of the form:
-  //   admin/tripal/chado/[module name]/[content type name]_toc
-  // this allows for a module to support TOC management when there are multiple
-  // content types provided by the module, as the content type is specified
-  // in the menu path.
-  $items['admin/tripal/chado/tripal_example/chado_example_toc'] = array(
-    'title' => ' TOC',
-    'description' => 'Manage the table of contents for example nodes.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_core_content_type_toc_form', 'chado_example'),
-    'access arguments' => array('administer tripal example'),
-    'type' => MENU_LOCAL_TASK,
-    'file' =>  'includes/tripal_core.toc.inc',
-    'file path' => drupal_get_path('module', 'tripal_core'),
-    'weight' => 3
-  );
-
-  return $items;
-}
-
-/**
- * Implements hook_views_api()
- *
- * This hook tells Drupal that there is views support for this module which then
- * automatically includes the tripal_db.views.inc where all the views
- * integration code is found.
- *
- * @ingroup tripal_example
- */
-function tripal_example_views_api() {
-  return array(
-    'api' => 3.0,
-  );
-}
-
-
-/**
- * We need to let Drupal know about our theme functions and their arguments.
- * We create theme functions to allow users of the module to customize the look
- * and feel of the output generated in this module.
- *
- * @ingroup tripal_example
- */
-function tripal_example_theme($existing, $type, $theme, $path) {
-  $core_path = drupal_get_path('module', 'tripal_core');
-
-  // EXPLANATION: this function defines all of the functions and templates that
-  // this module needs to provide content. These details are provided in the
-  // form of an array the indicates which functions or templates provide
-  // content. Please see the Drupal theming guide for an in-depth description
-  // for how theming works in Drupal:
-  // https://drupal.org/documentation/theme
-
-  $items = array(
-
-    // EXPLANATION:  If this module defines a new node type that displays Chado
-    // data then we should use Tripal's default node template. This template
-    // ensures that all content provided by Tripal and Tripal extension modules
-    // has the same look and feel. It is designed to be generic such that it
-    // won't interfere with the look-and-feel of the default theme. This generic
-    // template will organize the node into a table of contents found on the
-    // left-side of the page and place the content in the center of the page.
-    // User's will cycle through content on the page by clicking the links in
-    // the table of contents. If you do not want to use the default Tripal
-    // template you can change this array to your liking.
-    'node__chado_example' => array(
-      'template' => 'node--chado-generic',
-      'render element' => 'node',
-      'base hook' => 'node',
-      'path' => "$core_path/theme/templates",
-    ),
-
-    // EXPLANATION: the following defines all of the template files used for
-    // this module. Templates are named with underscores separating words, and
-    // correspond directly to a file with the extension '.tpl.php'. For example
-    // the 'tripal_example_base' template will have a corresponding
-    // tripal_example_base.tpl.php file where the display code is housed.
-    // The only required templates are the 'base',  'help' and 'teaser'
-    // templates. The base template provides the basic information about the
-    // record in Chado. The 'help' template provides the administrative help
-    // documentation, and the teaser provides a brief summary of the record that
-    // can be used as short description of the record in aggregated lists.
-
-    // the base template
-    'tripal_example_base' => array(
-      'variables' => array('node' => NULL),
-      'template' => 'tripal_example_base',
-      'path' => "$path/theme/templates",
-    ),
-    // the help template
-    'tripal_example_help' => array(
-      'template' => 'tripal_example_help',
-      'variables' =>  array(NULL),
-      'path' => "$path/theme/templates",
-    ),
-    // the teaser template.
-    'tripal_example_teaser' => array(
-      'variables' => array('node' => NULL),
-      'template' => 'tripal_example_teaser',
-      'path' => "$path/theme/templates",
-    ),
-
-
-    // EXPLANATION: Typically, a different template is created for each subset
-    // of data.
-    // For example, most Chado tables have a 'XXXXprop', 'XXXX_cvterm',
-    // 'XXXX_dbxref', 'XXXX_synonyms', 'XXXX_relationships' tables. Therefore,
-    // a template is created to display data from each of these tables.
-
-    'tripal_example_properties' => array(
-      'variables' => array('node' => NULL),
-      'template' => 'tripal_example_properties',
-      'path' => "$path/theme/templates",
-    ),
-    'tripal_example_references' => array(
-      'variables' => array('node' => NULL),
-      'template' => 'tripal_example_references',
-      'path' => "$path/theme/templates",
-    ),
-    'tripal_example_relationships' => array(
-      'variables' => array('node' => NULL),
-      'template' => 'tripal_example_relationships',
-      'path' => "$path/theme/templates",
-    ),
-
-    // EXPLANATION: sometimes a module may want to add content to another
-    // modules' node types. For example, the feature module does this by
-    // adding a 'feature summary' data to an organism. To add data to another
-    // module's node, the templates belong to this module and are specified in
-    // the same way as above. However, the naming of the template is changed to
-    // include the name of the module that supplies the node type followed by
-    // our record name:
-
-    // tripal_organism templates
-    'tripal_organism_examples' => array(
-      'variables' => array('node' => NULL),
-      'template' => 'tripal_organism_examples',
-      'path' => "$path/theme/templates",
-    ),
-  );
-
-  return $items;
-}
-
-/**
- * Implements hook_help()
- *
- * Adds a help page to the module list
- */
-function tripal_example_help ($path, $arg) {
-
-  // EXPLANATION: in the tripal_example_menu() function above we created a menu
-  // item for the help documentation. The menu item specified a function that
-  // should be called when the menu item is clicked. This is that function. But,
-  // rather than place HTML code in this function we want to have our help
-  // documentation in a template file. We specified in the
-  // tripal_example_theme() function that we have a template file so now we want
-  // to use get the contents of that template file and return it.
-  if ($path == 'admin/help#tripal_example') {
-    return theme('tripal_example_help', array());
-  }
-}
-
-
-/**
- * Implements hook_cron()
- *
- * @ingroup tripal_example
- */
-function tripal_example_cron() {
-
-  // EXPLANATION: here we can add any code that needs to be executed when the
-  // Drupal cron is run.
-}
-
-
-/**
- * Implementation of hook_form_alter()
- *
- * Allows a module to alter any form prior to it being rendered. For more
- * details about Drupal's Form API see this page:
- *
- * https://api.drupal.org/api/drupal/includes!form.inc/group/form_api/7
- *
- */
-function tripal_example_form_alter(&$form, &$form_state, $form_id) {
-
-  if ($form_id == "chado_example_node_form") {
-
-    // EXPLANATION:  The hook_form_alter() Drupal hook is used to alter a form
-    // before it is displayed. This allows any module to provide new form
-    // elements or change the form that another module creates. We do not need
-    // to alter a form created by another module, but we do want to alter the
-    // form for our new node type. For example, all node types will
-    // automatically have a 'Preview' button. For inserting or updating data
-    // for Chado we don't really need a Preview button and it complicates the
-    // form. So, we use the following code to disable the Preview button. If
-    // you want to keep the preview button then remove this code. turn of
-    // preview button for insert/updates
-    $form['actions']['preview']['#access'] = FALSE;
-
-    // EXPLANATION: Drupal always adds a 'body' field to all node types.
-    // Our node type doesn't use the 'body' field so we remove it from the form.
-    unset($form['body']);
-  }
-}

+ 0 - 9
legacy/tripal_example/tripal_example.views.inc

@@ -1,9 +0,0 @@
-<?php
-/**
- *  @file
- *  This file contains the basic functions for views integration of chado/tripal
- *  example tables
- */
-
-// EXPLANATION: see another tripal module (e.g. tripal_feature) for example
-// functions that can be used in this file.

+ 0 - 25
legacy/tripal_example/tripal_example.views_default.inc

@@ -1,25 +0,0 @@
-<?php
-/**
- * @file
-* Describe default example views
-*/
-
-/**
- * Implements hook_views_default_views().
-*
-* @ingroup tripal_example
-*/
-function tripal_example_views_default_views() {
-  $views = array();
-
-  // EXPLANATION: use this function to programmatically define any default
-  // Drupal views that your module will provide automatically. Typically there
-  // are two default views: 1) one for the administrator to quickly find data
-  // managed by your module, or 2) one for users to be able to search for public
-  // data.
-  //
-  // See another Tripal module such as tripal_feature for an example of how to
-  // setup a default views.
-
-  return $views;
-}

+ 3 - 3
legacy/tripal_feature/includes/tripal_feature.admin.inc

@@ -17,8 +17,8 @@ function tripal_feature_admin_feature_view() {
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
-  $breadcrumb[] = l('Chado', 'admin/tripal/chado');
-  $breadcrumb[] = l('Features', 'admin/tripal/chado/tripal_feature');
+  $breadcrumb[] = l('Chado', 'admin/tripal/legacy');
+  $breadcrumb[] = l('Features', 'admin/tripal/legacy/tripal_feature');
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
@@ -32,7 +32,7 @@ function tripal_feature_admin_feature_view() {
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'enable the pertinent views</strong>:</p>';
     $output .= '<ul>';
-      $output .= '<li>'.l('Features View', 'admin/tripal/chado/tripal_feature/views/features/enable').'</li>';
+      $output .= '<li>'.l('Features View', 'admin/tripal/legacy/tripal_feature/views/features/enable').'</li>';
     $output .= '</ul>';
   }
 

+ 4 - 6
legacy/tripal_feature/includes/tripal_feature.chado_node.inc

@@ -151,7 +151,7 @@ function chado_feature_form($node, &$form_state) {
    '#description' => t("Choose the feature type."),
    '#required'    => TRUE,
    '#default_value' => $feature_type,
-   '#autocomplete_path' => "admin/tripal/vocab/cvterm/auto_name/$cv_id",
+   '#autocomplete_path' => "aadmin/tripal/storage/chado/auto_name/cvterm/$cv_id",
   );
 
   // get the list of organisms
@@ -370,7 +370,7 @@ function chado_feature_validate($node, $form, &$form_state) {
  *
  * @ingroup tripal_feature
  */
-function chado_feature_node_access($node, $op, $account) {
+function tripal_feature_node_access($node, $op, $account) {
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;
@@ -772,10 +772,7 @@ function tripal_feature_node_presave($node) {
         $organism_id = $node->feature->organism_id;
         $name        = $node->feature->name;
         $uname       = $node->feature->uniquename;
-        $type_id     = $node->feature->type_id;
-        $values = array('cvterm_id' => $type_id);
-        $ftype = chado_select_record('cvterm', array('name'), $values);
-        $type = $ftype[0]->name;
+        $type        = $node->feature->cvtname;
       }
 
       $values = array('organism_id' => $organism_id);
@@ -842,6 +839,7 @@ function tripal_feature_node_update($node) {
  * @ingroup tripal_feature
  */
 function tripal_feature_node_view($node, $view_mode, $langcode) {
+
   switch ($node->type) {
     case 'chado_feature':
       // Show feature browser and counts

+ 1 - 1
legacy/tripal_feature/includes/tripal_feature.delete.inc

@@ -32,7 +32,7 @@ function tripal_feature_delete_form() {
    '#title'       => t('Feature Type'),
    '#type'        => 'textfield',
    '#description' => t("Choose the feature type."),
-   '#autocomplete_path' => "admin/tripal/vocab/cvterm/auto_name/$cv->cv_id",
+   '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/cvterm/$cv->cv_id",
   );
 
   $organisms = tripal_get_organism_select_options(FALSE);

+ 18 - 20
legacy/tripal_feature/theme/templates/tripal_feature_help.tpl.php

@@ -6,16 +6,14 @@
   <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_feature' section as appropriate for your site. For a simple setup, allow anonymous 
+   permissions under the 'tripal_feature' 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>Loading of Ontologies</b>:  
+
+   <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:</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>
@@ -40,7 +38,7 @@
      <li><p><b>Data Import</b>:  if you do not already have an existing Chado database with preloaded data
      then you will want
      to import data.  You can do so using the Chado perl scripts that come with the normal
-     <a href="http://gmod.org/wiki/Chado">distribution of Chado</a> or you can use 
+     <a href="http://gmod.org/wiki/Chado">distribution of Chado</a> or you can use
      the <a href="<?php print url('admin/tripal/tripal_feature/fasta_loader') ?>">FASTA loader</a> and
      <a href="<?php print url('admin/tripal/tripal_feature/gff3_load') ?>">GFF loader</a> provided here.  If you
      created the Chado database using Tripal then you'll most likely want to use the Tripal loaders.  If your data
@@ -70,27 +68,27 @@
   <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</p>
   <ul>
-    <li><p><b>Retrieve Sequences</b>: A tool to <?php print l('retrieve sequences','find/sequences') ?> is provided 
+    <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
-     as well as alignments.  The <?php  print l('organism_feature_count', 'admin/tripal/mviews') ?> and 
+     as well as alignments.  The <?php  print l('organism_feature_count', 'admin/tripal/mviews') ?> and
      <?php print l('analysis_organism', 'admin/tripal/mviews') ?> materialized
-     views must be populated before using this tool.  Those views should be re-populated 
+     views must be populated before using this tool.  Those views should be re-populated
      when new data is added.  If you use the <?php print l('jquery_update module', 'http://drupal.org/project/jquery_update') ?>
-     the tool may break.  You will need to update the jquery_update/replace/jquery.form.js file with <?php 
+     the tool may break.  You will need to update the jquery_update/replace/jquery.form.js file with <?php
      print l('a more recent version','https://raw.github.com/malsup/form/master/jquery.form.js') ?>. </p></li>
-    
-     <li><p><b>Generic Feature URL</b>:  As described in the setup instructions above, it is often convenient to have a 
-     simple URL for each feature page. For example, http://www.mygenomesite.org/[feature], where [feature] is a 
+
+     <li><p><b>Generic Feature URL</b>:  As described in the setup instructions above, it is often convenient to have a
+     simple URL for each feature page. For example, http://www.mygenomesite.org/[feature], where [feature] is a
      unique identifier for a feature page.  The
-     <?php print l('Feature Configuration page','admin/tripal/tripal_feature/configuration') ?> allows a 
+     <?php print l('Feature Configuration page','admin/tripal/tripal_feature/configuration') ?> allows a
      site admin to generate unique URLs for all feature.  The unique URL is necessary, however, sometimes
      it is easier to allow for links to the feature name without knowing the unique URL.  This is possible
-     using the URL: http://[site url]/feature/[feature name], where [site url] is the URL for the site and 
+     using the URL: http://[site url]/feature/[feature name], where [site url] is the URL for the site and
      [feature name] is the name of the feature.  If the feature name is not unique then a page will be
-     presented listing all of the features with the same name and allow the user to choose which one to 
-     view.  If the feature name is unique then the user will automatically be redirected to the 
+     presented listing all of the features with the same name and allow the user to choose which one to
+     view.  If the feature name is unique then the user will automatically be redirected to the
      unique URL for the feature.</p></li>
-     
+
     <li><p><b>Feature Browser:</b>  The feature browser is a tabular list of features with links to their
      feature pages which appears on the organism
      page.  It was created to provide a mechanism to allow site visitors to quickly
@@ -112,9 +110,9 @@
     published data (only works if Chado was installed using Tripal).  You can see a list of available pre-existing
     Views <a href="<?php print url('admin/build/views/') ?>">here</a>, as well as create your own. </p></li>
 
-    <li><p><b>Simple Search Tool</b>: A <?php print l('simple search tool','chado/features') ?> is provided for 
+    <li><p><b>Simple Search Tool</b>: A <?php print l('simple search tool','chado/features') ?> is provided for
     finding features. 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 
+    which must be installed to see the search tool.  Look for it in the navigation menu under the item
     "Search Data". </p></li>
 
     <li><p><b>Delete Features</b>: You can  <a href="<?php print url('admin/tripal/tripal_feature/delete') ?>">bulk delete features</a>

+ 29 - 29
legacy/tripal_feature/theme/templates/tripal_feature_sequence.tpl.php

@@ -1,10 +1,10 @@
 <?php
 /*
- * There are several ways that sequences can be displayed.  They can come from the 
+ * There are several ways that sequences can be displayed.  They can come from the
  * feature.residues column,  they can come from an alignment with another feature,
  * they can come from a protein sequence that has relationship with this sequence,
  * or they can come from sub children (e.g. CDS coding sequences).
- *   
+ *
  * This template will show all types depending on the data available.
  *
  */
@@ -12,7 +12,7 @@
 $feature = $variables['node']->feature;
 
 // number of bases per line in FASTA format
-$num_bases = 50; 
+$num_bases = 50;
 
 // we don't want to get the sequence for traditionally large types. They are
 // too big,  bog down the web browser, take longer to load and it's not
@@ -24,37 +24,37 @@ if(strcmp($feature->type_id->name,'scaffold') !=0 and
    strcmp($feature->type_id->name,'pseudomolecule') !=0) {
   $feature = chado_expand_var($feature,'field','feature.residues');
   $residues = $feature->residues;
-} 
+}
 
 // get the sequence derived from alignments
 $feature = $variables['node']->feature;
 $featureloc_sequences = $feature->featureloc_sequences;
 
-if ($residues or count($featureloc_sequences) > 0) { 
+if ($residues or count($featureloc_sequences) > 0) {
 
   $sequences_html = '';  // a variable for holding all sequences HTML text
   $list_items = array(); // a list to be used for theming of content on this page
-  
+
   // ADD IN RESIDUES FOR THIS FEATURE
   // add in the residues if they are present
   if ($residues) {
     $list_items[] = '<a href="#residues">' . $feature->type_id->name . ' sequence</a>';
-     
+
     // format the sequence to break every 50 residues
     $sequences_html .= '<a name="residues"></a>';
     $sequences_html .= '<div id="residues" class="tripal_feature-sequence-item">';
     $sequences_html .= '<p><b>' . $feature->type_id->name . ' sequence</b></p>';
     $sequences_html .= '<pre class="tripal_feature-sequence">';
-    $sequences_html .= '>' . tripal_get_fasta_defline($feature, '', NULL, '', strlen($feature->residues)) . "\n";
+    $sequences_html .= '>' . tripal_get_fasta_defline($feature, '', NULL, '', strlen($feature->residues)) . "<br>";
     $sequences_html .= wordwrap($feature->residues, $num_bases, "<br>", TRUE);
     $sequences_html .= '</pre>';
     $sequences_html .= '<a href="#sequences-top">back to top</a>';
     $sequences_html .= '</div>';
-    
+
   }
-  
+
   // ADD IN RELATIONSHIP SEQUENCES (e.g. proteins)
-  // see the explanation in the tripal_feature_relationships.tpl.php 
+  // see the explanation in the tripal_feature_relationships.tpl.php
   // template for how the 'all_relationships' is provided. It is this
   // variable that we use to get the proteins.
   $all_relationships = $feature->all_relationships;
@@ -64,27 +64,27 @@ if ($residues or count($featureloc_sequences) > 0) {
   foreach ($object_rels as $rel_type => $rels){
     foreach ($rels as $subject_type => $subjects){
       foreach ($subjects as $subject){
-        
+
         // add in protein sequence if it has residues
         if ($rel_type == 'derives from' and $subject_type == 'polypeptide') {
           $protein = $subject->record->subject_id;
           $protein = chado_expand_var($protein, 'field', 'feature.residues');
-          
+
           if ($protein->residues) {
             $list_items[] = '<a href="#residues">protein sequence</a>';
             $sequences_html .= '<a name="protein-' . $protein->feature_id . '"></a>';
             $sequences_html .= '<div id="protein-' . $protein->feature_id . '" class="tripal_feature-sequence-item">';
             $sequences_html .= '<p><b>protein sequence of ' . $protein->name . '</b></p>';
             $sequences_html .= '<pre class="tripal_feature-sequence">';
-            $sequences_html .= '>' . tripal_get_fasta_defline($protein, '', NULL, '', strlen($protein->residues)) . "\n";
+            $sequences_html .= '>' . tripal_get_fasta_defline($protein, '', NULL, '', strlen($protein->residues)) . "<br>";
             $sequences_html .= wordwrap($protein->residues, $num_bases, "<br>", TRUE);
             $sequences_html .= '</pre>';
             $sequences_html .= '<a href="#sequences-top">back to top</a>';
             $sequences_html .= '</div>';
           }
         }
-        
-        // If the CDS has sequences then concatenate those. The objects 
+
+        // If the CDS has sequences then concatenate those. The objects
         // should be returned in order of rank
         if ($rel_type == 'part of' and $subject_type == 'CDS') {
           $cds = $subject->record->subject_id;
@@ -94,14 +94,14 @@ if ($residues or count($featureloc_sequences) > 0) {
             $coding_seq .= $cds->residues;
           }
         }
-        
+
         // add any other sequences that are related through a relationship
         // and that have values in the 'residues' column
-        
+
       }
     }
   }
-  
+
   // CODING SEQUENCES FROM RELATIONSHIPS
   // add in any CDS sequences.
   if ($has_coding_seq) {
@@ -115,7 +115,7 @@ if ($residues or count($featureloc_sequences) > 0) {
     $sequences_html .= '<a href="#sequences-top">back to top</a>';
     $sequences_html .= '</div>';
   }
-  
+
   /* ADD IN ALIGNMENT SEQUENCES FOR THIS FEATURE
    * For retreiving the sequence from an alignment we would typically make a call to
    * chado_expand_var function.  For example, to retrieve all
@@ -127,7 +127,7 @@ if ($residues or count($featureloc_sequences) > 0) {
    * Then all of the sequences would need to be retreived from the alignments and
    * formatted for display below.  However, to simplify this template, this has already
    * been done by the tripal_feature module and the sequences are made available in
-   * the variable: 
+   * the variable:
    *
    *   $feature->featureloc_sequences
    */
@@ -148,7 +148,7 @@ if ($residues or count($featureloc_sequences) > 0) {
       $sequences_html .= '<a href="#sequences-top">back to top</a>';
       $sequences_html .= '</div>';
     }
-    
+
     // check to see if this alignment has any CDS. If so, generate a CDS sequence
     $cds_sequence = tripal_get_feature_sequences(
         array(
@@ -171,7 +171,7 @@ if ($residues or count($featureloc_sequences) > 0) {
       // that one mRNA is only aligned to a single location on the assembly so we
       // can access the CDS sequence with index 0.
       if ($cds_sequence[0]['residues']) {
-        $list_items[] = '<a href="#coding_' . $attrs['id'] . '">coding sequnece from alignment at  ' . $attrs['location'] . "</a>";
+        $list_items[] = '<a href="#coding_' . $attrs['id'] . '">coding sequence from alignment at  ' . $attrs['location'] . "</a>";
         $sequences_html .= '<a name="ccoding_' . $attrs['id'] . '"></a>';
         $sequences_html .= '<div id="coding_' . $attrs['id'] . '" class="tripal_feature-sequence-item">';
         $sequences_html .= '<p><b>Coding sequence (CDS) from alignment at  ' . $attrs['location'] . '</b></p>';
@@ -183,14 +183,14 @@ if ($residues or count($featureloc_sequences) > 0) {
         $sequences_html .= '</div>';
       }
     }
-  } 
+  }
   ?>
 
-  <div class="tripal_feature-data-block-desc tripal-data-block-desc">The following sequences are available for this feature:</div> 
+  <div class="tripal_feature-data-block-desc tripal-data-block-desc">The following sequences are available for this feature:</div>
   <?php
-  
+
   // first add a list at the top of the page that can be formatted as the
-  // user desires.  We use the theme_item_list function of Drupal to create 
+  // user desires.  We use the theme_item_list function of Drupal to create
   // the list rather than hard-code the HTML here.  Instructions for how
   // to create the list can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_item_list/7
@@ -216,7 +216,7 @@ if ($residues or count($featureloc_sequences) > 0) {
           is associated with an mRNA feature and protein sequences will appear on the mRNA page.</li>
       <li>This feature has one or more CDS features associated via the "feature_relationship" table of Chado with a
           relationship of type "part of". If the CDS features have residues then those will be concatenated
-          and presented as a sequence. Typically, CDSs are associated with an mRNA feature and CDS sequences 
+          and presented as a sequence. Typically, CDSs are associated with an mRNA feature and CDS sequences
           will appear on the mRNA page.</li>
       <li>This feature is aligned to another feature (e.g. scaffold, or chromosome) and this feature has
           one or more CDS features associated.  The CDS sequenes underlying the alignment will be
@@ -224,7 +224,7 @@ if ($residues or count($featureloc_sequences) > 0) {
     </ul>
     </p>';
   print tripal_set_message($message, TRIPAL_INFO, array('return_html' => 1));
-  
+
   // now print the sequences
   print $sequences_html;
 }

+ 12 - 12
legacy/tripal_feature/theme/templates/tripal_feature_terms.tpl.php

@@ -10,50 +10,50 @@ $terms = $feature->feature_cvterm;
 $s_terms = array();
 if ($terms) {
   foreach ($terms as $term) {
-    $s_terms[$term->cvterm_id->cv_id->name][] = $term;  
+    $s_terms[$term->cvterm_id->cv_id->name][] = $term;
   }
 }
 
 if (count($s_terms) > 0) { ?>
   <div class="tripal_feature-data-block-desc tripal-data-block-desc">The following terms have been associated with this <?php print $node->feature->type_id->name ?>:</div>  <?php
-  
+
   // iterate through each term
   $i = 0;
-  foreach ($s_terms as $cv => $terms) {  
+  foreach ($s_terms as $cv => $terms) {
     // the $headers array is an array of fields to use as the colum headers.
     // additional documentation can be found here
     // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
     $headers = array('Term', 'Definition');
-    
+
     // the $rows array contains an array of rows where each row is an array
     // of values for each column of the table in that row.  Additional documentation
     // can be found here:
     // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
     $rows = array();
 
-    foreach ($terms as $term) { 
+    foreach ($terms as $term) {
       $accession = $term->cvterm_id->dbxref_id->accession;
       if (is_numeric($term->cvterm_id->dbxref_id->accession)) {
         $accession = $term->cvterm_id->dbxref_id->db_id->name . ":" . $term->cvterm_id->dbxref_id->accession;
       }
       if ($term->cvterm_id->dbxref_id->db_id->urlprefix) {
         $accession = l($accession, $term->cvterm_id->dbxref_id->db_id->urlprefix . $accession, array('attributes' => array("target" => '_blank')));
-      } 
-      
+      }
+
       $rows[] = array(
         array('data' => $accession, 'width' => '15%'),
         $term->cvterm_id->name
       );
-    } 
-    
+    }
+
     // generate the link to configure a database, b ut only if the user is
     // a tripal administrator
     $configure_link = '';
     if (user_access('view ids')) {
       $db_id = $term->cvterm_id->dbxref_id->db_id->db_id;
-      $configure_link = l('[configure term links]', "admin/tripal/chado/tripal_db/edit/$db_id", array('attributes' => array("target" => '_blank')));
+      $configure_link = l('[configure term links]', "admin/tripal/legacy/tripal_db/edit/$db_id", array('attributes' => array("target" => '_blank')));
     }
-    
+
     // the $table array contains the headers and rows array as well as other
     // options for controlling the display of the table.  Additional
     // documentation can be found here:
@@ -70,7 +70,7 @@ if (count($s_terms) > 0) { ?>
       'colgroups' => array(),
       'empty' => '',
     );
-    
+
     // once we have our table array structure defined, we call Drupal's theme_table()
     // function to generate the table.
     print theme_table($table);

+ 7 - 2
legacy/tripal_feature/theme/templates/tripal_organism_feature_browser.tpl.php

@@ -67,7 +67,7 @@ if (count($so_terms) > 0) {
     print tripal_set_message("Administrators, you can specify the feature types ".
       "that should appear in this browser or remove it from the list of resources ".
       "by navigating to the ".
-      l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank'))),
+      l("Tripal feature settings page", "admin/tripal/legacy/tripal_feature/configuration", array('attributes' => array('target' => '_blank'))),
       TRIPAL_INFO,
       array('return_html' => 1)
     );
@@ -109,15 +109,20 @@ if (count($so_terms) > 0) {
     // here we add the paramter 'block' => 'feature_browser'. This is because
     // the pager is not on the default block that appears. When the user clicks a
     // page number we want the browser to re-appear with the page is loaded.
+    // We remove the 'pane' parameter from the original query parameters because
+    // Drupal won't reset the parameter if it already exists.
+    $get = $_GET;
+    unset($_GET['pane']);
     $pager = array(
       'tags' => array(),
       'element' => $element,
       'parameters' => array(
-        'block' => 'feature_browser'
+        'pane' => 'feature_browser'
       ),
       'quantity' => $num_per_page,
     );
     print theme_pager($pager);
+    $_GET = $get;
 
     print tripal_set_message("
       Administrators, please note that the feature browser will be retired in

+ 6 - 6
legacy/tripal_feature/theme/templates/tripal_organism_feature_counts.tpl.php

@@ -12,15 +12,15 @@ if(property_exists($organism, 'feature_counts')) {
 
 // let admins know they can customize the terms that appear in the list
 print tripal_set_message("
-  Administrators, you can customize the types of terms that appear in this report by navigating to the " . 
-  l('Tripal feature configuration page', 'admin/tripal/chado/tripal_feature/configuration', array('attributes' => array('target' => '_blank'))) . "
+  Administrators, you can customize the types of terms that appear in this report by navigating to the " .
+  l('Tripal feature configuration page', 'admin/tripal/legacy/tripal_feature/configuration', array('attributes' => array('target' => '_blank'))) . "
   opening the section \"Feature Summary Report\" and adding the list of
   terms you want to appear in the list. You can rename terms as well. To refresh the data,re-populate the " .
-  l('organism_feature_count', 'admin/tripal/storage/chado/mviews', array('attributes' => array('target' => '_blank'))) . " 
+  l('organism_feature_count', 'admin/tripal/storage/legacy/mviews', array('attributes' => array('target' => '_blank'))) . "
   materialized view.",
   TRIPAL_INFO,
   array('return_html' => 1)
-); 
+);
 
 // the $headers array is an array of fields to use as the colum headers.
 // additional documentation can be found here
@@ -36,12 +36,12 @@ $rows = array();
 for ($j = 0; $j < count($types); $j++) {
   $type = $types[$j];
   $name = $names[$j];
-  
+
   $rows[] = array(
     "<span title=\"" . $type->definition . "\">$name</span>",
     number_format($type->num_features),
   );
-} 
+}
 // the $table array contains the headers and rows array as well as other
 // options for controlling the display of the table.  Additional
 // documentation can be found here:

+ 8 - 88
legacy/tripal_feature/theme/tripal_feature.theme.inc

@@ -31,7 +31,7 @@ function tripal_feature_preprocess_tripal_feature_sequence(&$variables) {
   // if this feature has associated protein sequences (or others via relationships
   // then we want to make sure the relationships are added so that we can
   // show the protein sequences
-  if (!$feature->all_relationships) {
+  if (!property_exists($feature, 'all_relationships')) {
     $feature->all_relationships = tripal_feature_get_feature_relationships($feature);
   }
 }
@@ -53,7 +53,7 @@ function tripal_feature_load_featureloc_sequences($feature_id, $featurelocs) {
 
   // get the list of relationships (including any aggregators) and iterate
   // through each one to find information needed to color-code the reference sequence
-  $relationships = tripal_feature_get_aggregate_relationships($feature_id);
+  $relationships = _tripal_feature_get_aggregate_relationships($feature_id);
   if (!$relationships) {
     return array();
   }
@@ -243,7 +243,7 @@ function tripal_feature_load_featurelocs($feature_id, $side = 'as_parent', $aggr
   if ($aggregate and strcmp($side, 'as_parent')==0) {
     // get the relationships for this feature without substituting any children
     // for the parent. We want all relationships
-    $relationships = tripal_feature_get_aggregate_relationships($feature_id, 0);
+    $relationships = _tripal_feature_get_aggregate_relationships($feature_id, 0);
     foreach ($relationships as $rindex => $rel) {
       // get the featurelocs for each of the relationship features
       $rel_featurelocs = tripal_feature_load_featurelocs($rel->subject_id, 'as_child', 0);
@@ -274,91 +274,6 @@ function tripal_feature_sort_locations($a, $b) {
   return strnatcmp($a->fmin, $b->fmin);
 }
 
-
-/**
- * Get features related to the current feature to a given depth. Recursive function.
- *
- * @param $feature_id
- * @param $substitute
- * @param $levels
- * @param $base_type_id
- * @param $depth
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_get_aggregate_relationships($feature_id, $substitute=1,
-    $levels=0, $base_type_id=NULL, $depth=0) {
-
-  // we only want to recurse to as many levels deep as indicated by the
-  // $levels variable, but only if this variable is > 0. If 0 then we
-  // recurse until we reach the end of the relationships tree.
-  if ($levels > 0 and $levels == $depth) {
-    return NULL;
-  }
-
-  // first get the relationships for this feature
-  return tripal_feature_load_relationships($feature_id, 'as_object');
-
-}
-/**
- * Get the relationships for a feature.
- *
- * @param $feature_id
- *   The feature to get relationships for
- * @param $side
- *   The side of the relationship this feature is (ie: 'as_subject' or 'as_object')
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_load_relationships($feature_id, $side = 'as_subject') {
-  // get the relationships for this feature.  The query below is used for both
-  // querying the object and subject relationships
-  $sql = "
-    SELECT
-      FS.name as subject_name, FS.uniquename as subject_uniquename,
-      CVTS.name as subject_type, CVTS.cvterm_id as subject_type_id,
-      FR.subject_id, FR.type_id as relationship_type_id, FR.object_id, FR.rank,
-      CVT.name as rel_type,
-      FO.name as object_name, FO.uniquename as object_uniquename,
-      CVTO.name as object_type, CVTO.cvterm_id as object_type_id
-    FROM {feature_relationship} FR
-     INNER JOIN {cvterm} CVT  ON FR.type_id    = CVT.cvterm_id
-     INNER JOIN {feature} FS  ON FS.feature_id = FR.subject_id
-     INNER JOIN {feature} FO  ON FO.feature_id = FR.object_id
-     INNER JOIN {cvterm} CVTO ON FO.type_id    = CVTO.cvterm_id
-     INNER JOIN {cvterm} CVTS ON FS.type_id    = CVTS.cvterm_id
-  ";
-  if (strcmp($side, 'as_object')==0) {
-    $sql .= " WHERE FR.object_id = :feature_id";
-  }
-  if (strcmp($side, 'as_subject')==0) {
-    $sql .= " WHERE FR.subject_id = :feature_id";
-  }
-  $sql .= " ORDER BY FR.rank";
-
-  // get the relationships
-  $results = chado_query($sql, array(':feature_id' => $feature_id));
-
-
-  // iterate through the relationships, put these in an array and add
-  // in the Drupal node id if one exists
-  $i=0;
-  $nodesql = "SELECT nid FROM {chado_feature} WHERE feature_id = :feature_id";
-  $relationships = array();
-  while ($rel = $results->fetchObject()) {
-    $node = db_query($nodesql, array(':feature_id' => $rel->subject_id))->fetchObject();
-    if ($node) {
-      $rel->subject_nid = $node->nid;
-    }
-    $node = db_query($nodesql, array(':feature_id' => $rel->object_id))->fetchObject();
-    if ($node) {
-      $rel->object_nid = $node->nid;
-    }
-    $relationships[$i++] = $rel;
-  }
-  return $relationships;
-}
-
 /**
  * Returns the marked up fasta sequence for the described feature
  *
@@ -688,6 +603,11 @@ function tripal_feature_load_organism_feature_counts($organism) {
   $order = array();
   $names = array();
 
+  // We should not assume this table is present since it is a materialized view.
+  if (!chado_table_exists('organism_feature_count')) {
+      return NULL;
+  }
+
   // build the where clause for the SQL statement if we have a custom term list
   // we'll also keep track of the names the admin provided (if any) and the
   // order that the terms should appear.

+ 10 - 3
legacy/tripal_feature/tripal_feature.drush.inc

@@ -106,11 +106,18 @@ function drush_tripal_feature_tripal_get_sequence() {
     'sub_feature_types' => explode(',', $child),
     'relationship_type' => $relationship,
     'relationship_part' => $rel_part,
-    'print' => TRUE,
     'width' => $width
   );
-  
-  tripal_get_bulk_feature_sequences($options);
+
+  $seqs = tripal_get_bulk_feature_sequences($options);
+  if (count($seqs) == 0) {
+      print "No sequences found that match the criteria.";
+  }
+
+  foreach ($seqs as $seq) {
+    print ">" . $seq['defline'] . "\r\n";
+    print $seq['residues'] . "\r\n";
+  }
 }
 
 /**

+ 2 - 2
legacy/tripal_feature/tripal_feature.info

@@ -3,13 +3,13 @@ description = Supports the sequence (feature) tables of Chado by providing pages
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-rc1
 
 stylesheets[all][] = theme/css/tripal_feature.css
 scripts[]          = theme/js/tripal_feature.js
 
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_db
 dependencies[] = tripal_cv
 dependencies[] = tripal_organism

+ 15 - 204
legacy/tripal_feature/tripal_feature.install

@@ -82,8 +82,8 @@ function tripal_feature_install() {
 function tripal_feature_uninstall() {
 
 }
-
-function tripal_feature_add_tripal_gff_temp_table() {
+// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
+/* function tripal_feature_add_tripal_gff_temp_table() {
   $schema = array(
     'table' => 'tripal_gff_temp',
     'fields' => array(
@@ -116,12 +116,13 @@ function tripal_feature_add_tripal_gff_temp_table() {
     ),
   );
   chado_create_custom_table('tripal_gff_temp', $schema, TRUE);
-}
+} */
 
 /**
  *
  */
-function tripal_feature_add_tripal_gffcds_temp_table($skip_recreate = TRUE) {
+// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
+/* function tripal_feature_add_tripal_gffcds_temp_table($skip_recreate = TRUE) {
   $schema = array(
     'table' => 'tripal_gffcds_temp',
     'fields' => array(
@@ -135,7 +136,7 @@ function tripal_feature_add_tripal_gffcds_temp_table($skip_recreate = TRUE) {
       ),
       'phase' => array(
         'type' => 'int',
-        'not null' => TRUE,
+        'not null' => FALSE,
       ),
       'strand' => array(
         'type' => 'int',
@@ -156,12 +157,13 @@ function tripal_feature_add_tripal_gffcds_temp_table($skip_recreate = TRUE) {
     ),
   );
   chado_create_custom_table('tripal_gffcds_temp', $schema, $skip_recreate);
-}
+} */
 
 /**
  *
  */
-function tripal_feature_add_tripal_gffprotein_temp_table() {
+// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
+/* function tripal_feature_add_tripal_gffprotein_temp_table() {
   $schema = array(
     'table' => 'tripal_gffprotein_temp',
     'fields' => array(
@@ -191,7 +193,7 @@ function tripal_feature_add_tripal_gffprotein_temp_table() {
     ),
   );
   chado_create_custom_table('tripal_gffprotein_temp', $schema, TRUE);
-}
+} */
 
 /**
  * Implementation of hook_schema().
@@ -243,7 +245,8 @@ function tripal_feature_schema() {
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_add_organism_count_mview() {
+// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
+/* function tripal_feature_add_organism_count_mview() {
   $view_name = 'organism_feature_count';
   $comment = 'Stores the type and number of features per organism';
 
@@ -252,6 +255,7 @@ function tripal_feature_add_organism_count_mview() {
     'table' => $view_name,
     'fields' => array(
       'organism_id' => array(
+        'size' => 'big',
         'type' => 'int',
         'not null' => TRUE,
       ),
@@ -275,6 +279,7 @@ function tripal_feature_add_organism_count_mview() {
         'not null' => TRUE,
       ),
       'cvterm_id' => array(
+        'size' => 'big',
         'type' => 'int',
         'not null' => TRUE,
       ),
@@ -304,7 +309,7 @@ function tripal_feature_add_organism_count_mview() {
   ";
 
   tripal_add_mview($view_name, 'tripal_feature', $schema, $sql, $comment);
-}
+} */
 /**
  * Add cvs related to publications
  *
@@ -335,197 +340,3 @@ function tripal_feature_add_cvs() {
     'The Sequence Ontology'
   );
 }
-
-/**
- * This is the required update for tripal_feature when upgrading from Drupal core API 6.x.
- * This update may take some time to complete.
- */
-function tripal_feature_update_7200() {
-  // During the upgrade from D6 to D7 the vocabulary terms assigned to features were
-  // copied to the field_data_taxonomyextra table rather than to the correct
-  // field_data_taxonomy_vocabulary_[vid] table. We'll move them.
-  $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE name = 'Feature Type'")->fetchField();
-  if ($vid) {
-    try {
-      // first move from the field_data_taxonomyextra table
-      $sql = "
-        INSERT INTO {field_data_taxonomy_vocabulary_$vid}
-          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
-        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
-         FROM field_data_taxonomyextra
-         WHERE bundle = 'chado_feature')
-      ";
-      db_query($sql);
-      $sql = "DELETE FROM field_data_taxonomyextra WHERE bundle = 'chado_feature'";
-      db_query($sql);
-
-      // next move from the field_revision_taxonomyextra table
-      $sql = "
-        INSERT INTO {field_revision_taxonomy_vocabulary_$vid}
-          (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
-        (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
-         FROM field_revision_taxonomyextra
-         WHERE bundle = 'chado_feature')
-      ";
-      db_query($sql);
-      $sql = "DELETE FROM field_revision_taxonomyextra WHERE bundle = 'chado_feature'";
-      db_query($sql);
-    }
-    catch (\PDOException $e) {
-      $error = $e->getMessage();
-      throw new DrupalUpdateException('Could not move feature taxonomy terms: '. $error);
-    }
-  }
-
-  // set the default feature property vocabulary
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'feature_property'")->fetchField();
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-        'table_name' => 'featureprop',
-        'field_name' => 'type_id',
-        'cv_id' => $cv_id
-        ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to set feature_property vocabulary as default: '. $error);
-  }
-
-  // add the feature_relationshp CV
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'feature_relationship'")->fetchField();
-    if (!$cv_id) {
-      // add the vocabulary
-      $cv_id = db_insert('chado.cv')
-      ->fields(array(
-        'name' => 'feature_relationship',
-        'definition' => 'Contains types of relationships between features.'
-      ))
-      ->execute();
-    }
-    // use the new feature_relationship CV we just added
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-        'table_name' => 'feature_relationship',
-        'field_name' => 'type_id',
-        'cv_id' => $cv_id
-      ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add feature_relationship vocabulary: '. $error);
-  }
-
-  // set the feature_type as the 'sequence' ontology
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'sequence'")->fetchField();
-    if (!$cv_id) {
-      // add the vocabulary
-      $cv_id = db_insert('chado.cv')
-      ->fields(array(
-        'name' => 'sequence',
-        'definition' => 'The Sequence Ontology.'
-      ))
-      ->execute();
-    }
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-        'table_name' => 'feature',
-        'field_name' => 'type_id',
-        'cv_id' => $cv_id
-      ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add sequence vocabulary which will be used for the sequence ontology: '. $error);
-  }
-
-
-}
-
-/**
- * Implementation of hook_update_dependencies().  It specifies a list of
- * other modules whose updates must be run prior to this one.
- */
-function tripal_feature_update_dependencies() {
-  $dependencies = array();
-
-  // the tripal_cv update 7200 must run prior to update 7200 of this module
-  $dependencies['tripal_feature'][7200] = array(
-    'tripal_cv' => 7200
-  );
-
-  return $dependencies;
-}
-
-/**
- * Fixes an error with the materialized view installation
- *
- */
-function tripal_feature_update_7201() {
-
-  try {
-    // there is a bug in the Tripal v2.0-alpha release that didn't add the
-    // materialized view schema to the mviews table.
-    // get the schema for the materialized view from the custom_tables table
-    // as there is a copy there, but only if the schema is missing from the
-    // materialized view table
-    $view_name = 'organism_feature_count';
-    $schema = db_select('tripal_mviews', 'tm')
-      ->fields('tm', array('mv_schema'))
-      ->condition('name', $view_name)
-      ->execute()
-      ->fetchField();
-    if (!$schema or $schema == 'Array') {
-      $schema = db_select('tripal_custom_tables', 'tct')
-        ->fields('tct', array('schema'))
-        ->condition('table_name', $view_name)
-        ->execute()
-        ->fetchField();
-      $schema_str = var_export(unserialize($schema), TRUE);
-      $schema_str = preg_replace('/=>\s+\n\s+array/', '=> array', $schema_str);
-      db_update('tripal_mviews')
-        ->fields(array(
-        'mv_schema' => $schema_str
-        ))
-        ->condition('name', $view_name)
-        ->execute();
-    }
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to complete update' . $error);
-  }
-}
-
-/**
- * Adds the temporary tables used for loading GFF files.
- */
-function tripal_feature_update_7202() {
-  try {
-    tripal_feature_add_tripal_gff_temp_table();
-    tripal_feature_add_tripal_gffcds_temp_table();
-    tripal_feature_add_tripal_gffprotein_temp_table();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to complete update' . $error);
-  }
-}
-
-/**
- * Removes the unique constraint on the tripal_gffcds_temp table.
- */
-function tripal_feature_update_7203() {
-  try {
-    tripal_feature_add_tripal_gffcds_temp_table(FALSE);
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to complete update' . $error);
-  }
-}

+ 33 - 163
legacy/tripal_feature/tripal_feature.module

@@ -12,15 +12,11 @@
  * @}
  */
 
-require_once 'api/tripal_feature.api.inc';
 require_once 'api/tripal_feature.DEPRECATED.inc';
 
 require_once 'theme/tripal_feature.theme.inc';
 
 require_once 'includes/tripal_feature.admin.inc';
-require_once 'includes/tripal_feature.fasta_loader.inc';
-require_once 'includes/tripal_feature.gff_loader.inc';
-require_once 'includes/tripal_feature.seq_extract.inc';
 require_once 'includes/tripal_feature.delete.inc';
 require_once 'includes/tripal_feature.chado_node.inc';
 
@@ -75,6 +71,7 @@ function tripal_feature_help($path, $arg) {
  */
 function tripal_feature_permission() {
   return array(
+    /*
     'access chado_feature content' => array(
       'title' => t('View Features'),
       'description' => t('Allow users to view feature pages.'),
@@ -95,6 +92,7 @@ function tripal_feature_permission() {
       'title' => t('Administer Features'),
       'description' => t('Allow users to administer all features.'),
     ),
+    */
   );
 }
 
@@ -111,31 +109,7 @@ function tripal_feature_menu() {
   $items = array();
 
   // the administative settings menu
-  $items['find/sequences'] = array(
-    'title' => 'Sequence Retrieval',
-    'description' => 'Download a file of sequences',
-    'page callback' => 'tripal_feature_seq_extract_page',
-    'access arguments' => array('access chado_feature content'),
-    'type' => MENU_CALLBACK,
-  );
-
-  $items['find/sequences/ajax'] = array(
-    'title' => 'Sequence Retrieval',
-    'page callback' => 'tripal_feature_seq_extract_form_ahah_update',
-    'access arguments' => array('access chado_feature content'),
-    'type' => MENU_CALLBACK,
-  );
-
-  // the menu link for addressing any feature (by name, uniquename, synonym)
-  $items['feature/%'] = array(
-    'page callback' => 'tripal_feature_match_features_page',
-    'page arguments' => array(1),
-    'access arguments' => array('access chado_feature content'),
-    'type' => MENU_LOCAL_TASK,
-  );
-
-  // the administative settings menu
-  $items['admin/tripal/chado/tripal_feature'] = array(
+  $items['admin/tripal/legacy/tripal_feature'] = array(
     'title' => 'Features',
     'description' => 'A biological sequence or a section of a biological sequence, or a collection of such sections.',
     'page callback' => 'tripal_feature_admin_feature_view',
@@ -143,7 +117,7 @@ function tripal_feature_menu() {
     'type' => MENU_NORMAL_ITEM,
   );
 
-  $items['admin/tripal/chado/tripal_feature/delete'] = array(
+  $items['admin/tripal/legacy/tripal_feature/delete'] = array(
     'title' => ' Delete',
     'description' => 'Delete multiple features from Chado',
     'page callback' => 'drupal_get_form',
@@ -152,7 +126,7 @@ function tripal_feature_menu() {
     'type' => MENU_LOCAL_TASK,
     'weight' => 2
   );
-  $items['admin/tripal/chado/tripal_feature/sync'] = array(
+  $items['admin/tripal/legacy/tripal_feature/sync'] = array(
     'title' => ' Sync',
     'description' => 'Create pages on this site for features stored in Chado',
     'page callback' => 'drupal_get_form',
@@ -161,7 +135,7 @@ function tripal_feature_menu() {
     'type' => MENU_LOCAL_TASK,
     'weight' => 1
   );
-  $items['admin/tripal/chado/tripal_feature/chado_feature_toc'] = array(
+  $items['admin/tripal/legacy/tripal_feature/chado_feature_toc'] = array(
     'title' => ' TOC',
     'description' => 'Manage the table of contents for feature nodes.',
     'page callback' => 'drupal_get_form',
@@ -172,7 +146,7 @@ function tripal_feature_menu() {
     'file path' => drupal_get_path('module', 'tripal_core'),
     'weight' => 3
   );
-  $items['admin/tripal/chado/tripal_feature/configuration'] = array(
+  $items['admin/tripal/legacy/tripal_feature/configuration'] = array(
     'title' => 'Settings',
     'description' => 'Configure the Tripal Feature module.',
     'page callback' => 'drupal_get_form',
@@ -181,7 +155,7 @@ function tripal_feature_menu() {
     'type' => MENU_LOCAL_TASK,
     'weight' => 5
   );
-  $items['admin/tripal/chado/tripal_feature/help'] = array(
+  $items['admin/tripal/legacy/tripal_feature/help'] = array(
     'title' => 'Help',
     'description' => 'Help with the Tripal Feature module.',
     'page callback' => 'theme',
@@ -191,33 +165,14 @@ function tripal_feature_menu() {
     'weight' =>  10
   );
 
-  /** Loaders */
-  $items['admin/tripal/loaders/fasta_loader'] = array(
-    'title' => 'FASTA file Loader',
-    'description' => 'Load sequences from a multi-FASTA file into Chado',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_feature_fasta_load_form'),
-    'access arguments' => array('administer tripal feature'),
-    'type' => MENU_NORMAL_ITEM,
-  );
-  $items['admin/tripal/loaders/gff3_load'] = array(
-    'title' => 'GFF3 file Loader',
-    'description' => 'Import a GFF3 file into Chado',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_feature_gff3_load_form'),
-    'access arguments' => array('administer tripal feature'),
-    'type' => MENU_NORMAL_ITEM,
-  );
-
   // Enable admin view
-  $items['admin/tripal/chado/tripal_feature/views/features/enable'] = array(
+  $items['admin/tripal/legacy/tripal_feature/views/features/enable'] = array(
     'title' => 'Enable feature Administrative View',
     'page callback' => 'tripal_enable_view',
-    'page arguments' => array('tripal_feature_admin_features', 'admin/tripal/chado/tripal_feature'),
+    'page arguments' => array('tripal_feature_admin_features', 'admin/tripal/legacy/tripal_feature'),
     'access arguments' => array('administer tripal feature'),
     'type' => MENU_CALLBACK,
   );
-
   return $items;
 }
 
@@ -341,11 +296,6 @@ function tripal_feature_theme($existing, $type, $theme, $path) {
     'path' => "$path/theme/templates"
   );
 
-  // Themed Forms
-  $items['tripal_feature_seq_extract_form'] = array(
-     'arguments' => array('form'),
-  );
-
   // D3 Charts.
   // Feature Type/Organism Stacked Bar Chart.
   $items['tripal_feature_bar_chart_type_organism_summary'] = array(
@@ -367,31 +317,38 @@ function tripal_feature_job_describe_args($callback, $args) {
   $new_args = array();
   if ($callback == 'tripal_feature_load_fasta') {
     $new_args['FASTA file'] = $args[0];
-    $organism = chado_select_record('organism', array('genus', 'species'), array('organism_id' => $args[1]));
-    $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species;
-    $new_args['Sequence Type'] = $args[2];
-    $new_args['Name Match Type'] = $args[14];
-    $new_args['Name RE'] = $args[4];
-    $new_args['Unique Name RE'] = $args[5];
 
+    // Add in the organism.
+    if ($args[1] AND is_numeric($args[1])) {
+      $organism = chado_select_record('organism', array('genus', 'species'), array('organism_id' => $args[1]));
+      $new_args['Organism'] = $organism[0]->genus . " " . $organism[0]->species;
+    }
+    $new_args['Sequence Type'] = $args[2];
+    if (isset($args[14])) {
+      $new_args['Name Match Type'] = $args[14];
+      $new_args['Name RE'] = $args[4];
+      $new_args['Unique Name RE'] = $args[5];
+    }
     // add in the relationship arguments
-    $new_args['Relationship Type'] = $args[8];
-    $new_args['Relationship Parent RE'] = $args[9];
-    $new_args['Relationship Parent Type'] = $args[10];
+    if ($args[8]) {
+      $new_args['Relationship Type'] = $args[8];
+      $new_args['Relationship Parent RE'] = $args[9];
+      $new_args['Relationship Parent Type'] = $args[10];
+    }
 
     // add in the database reference arguments
-    if ($args[7]) {
+    if ($args[7] AND is_numeric($args[7])) {
       $db = chado_select_record('db', array('name'), array('db_id' => $args[7]));
+      $new_args['Database Reference'] = $db[0]->name;
+      $new_args['Accession RE'] = $args[6];
+      $new_args['Method'] = $args[11];
     }
-    $new_args['Database Reference'] = $db[0]->name;
-    $new_args['Accession RE'] = $args[6];
-    $new_args['Method'] = $args[11];
 
     // add in the analysis
-    if ($args[13]) {
-      $analysis = chado_select_record('analysis', array('name'), array('analysis_id' => $args[13]));
+    if ($args[12] AND is_numeric($args[12])) {
+      $analysis = chado_select_record('analysis', array('name'), array('analysis_id' => $args[12]));
+      $new_args['Analysis'] = $analysis[0]->name;
     }
-    $new_args['Analysis'] = $analysis[0]->name;
   }
   if ($callback == 'tripal_feature_delete_features') {
     if ($args[0]) {
@@ -458,87 +415,6 @@ function tripal_feature_coder_ignore() {
   );
 }
 
-/*
- * Uses the value provided in the $id argument to find all features that match
- * that ID by name, featurename or synonym.  If it matches uniquenly to a single
- * feature it will redirect to that feature page, otherwise, a list of matching
- * features is shown.
- *
- * @ingroup tripal_feature
- */
-function tripal_feature_match_features_page($id) {
-
-  // first check to see if the URL (e.g. /feature/$id) is already
-  // assigned to a node. If so, then just go there.  Otherwise,
-  // try to find the feature.
-  $sql = "
-    SELECT source
-    FROM {url_alias}
-    WHERE alias = :alias
-  ";
-  $match = db_query($sql, array(':alias' => "feature/$id"))->fetchObject();
-  if ($match) {
-    drupal_goto($match->source);
-    return;
-  }
-  $sql = "
-    SELECT
-      F.name, F.uniquename, F.feature_id,
-      O.genus, O.species, O.organism_id,
-      CVT.cvterm_id, CVT.name as type_name,
-      CF.nid,
-      array_agg(S.name) as synonyms
-    FROM {feature} F
-      INNER JOIN {organism} O on F.organism_id = O.organism_id
-      INNER JOIN {cvterm} CVT on CVT.cvterm_id = F.type_id
-      LEFT JOIN {feature_synonym} FS on FS.feature_id = F.feature_id
-      LEFT JOIN {synonym} S on S.synonym_id = FS.synonym_id
-      INNER JOIN public.chado_feature CF on CF.feature_id = F.feature_id
-    WHERE
-      F.uniquename = :uname or
-      F.name = :fname or
-      S.name = :sname
-    GROUP BY F.name, F.uniquename, F.feature_id, O.genus, O.species,
-      O.organism_id, CVT.cvterm_id, CVT.name, CF.nid
-  ";
-
-  $args = array(':uname' => $id, ':fname' => $id, ':sname' => $id);
-  $results = chado_query($sql, $args);
-
-  $num_matches = 0;
-
-  // iterate through the matches and build the table for showing matches
-  $header = array('Uniquename', 'Name', 'Type', 'Species', 'Synonyms');
-  $rows = array();
-  $curr_match;
-  while ($match = $results->fetchObject()) {
-    $curr_match = $match;
-    $synonyms = $match->synonyms;
-    $synonyms = preg_replace('/[\"\{\}]/', '', $synonyms);
-    $rows[] = array(
-       $match->uniquename,
-       "<a href=\"" . url("node/" . $match->nid) . "\">" . $match->name . "</a>",
-       $match->type_name,
-       '<i>' . $match->genus . ' ' . $match->species . '</i>',
-       $synonyms,
-    );
-    $num_matches++;
-  }
-
-  // if we have more than one match then generate the table, otherwise, redirect
-  // to the matched feature
-  if ($num_matches == 1) {
-    drupal_goto("node/" . $curr_match->nid);
-  }
-  if ($num_matches == 0) {
-    return "<p>No features matched the given name '$id'</p>";
-  }
-
-  $table_attrs = array('class' => 'tripal-data-table');
-  $output = "<p>The following features match the name '$id'.</p>";
-  $output .= theme_table($header, $rows, $table_attrs, $caption);
-  return $output;
-}
 
 /**
  * Implementation of hook_form_alter()
@@ -550,12 +426,6 @@ function tripal_feature_match_features_page($id) {
  * @ingroup tripal_feature
  */
 function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
-  if ($form_id == "tripal_feature_seq_extract_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
-    $form['#action'] = url("find/sequences");
-  }
   // turn off preview button for insert/updates
   if ($form_id == "chado_feature_node_form") {
     $form['actions']['preview']['#access'] = FALSE;

+ 1 - 1
legacy/tripal_feature/tripal_feature.views_default.inc

@@ -526,7 +526,7 @@ function tripal_feature_defaultview_admin_features() {
 
   /* Display: Page */
   $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->display->display_options['path'] = 'admin/tripal/chado/tripal_feature/features';
+  $handler->display->display_options['path'] = 'admin/tripal/legacy/tripal_feature/features';
   $handler->display->display_options['menu']['type'] = 'default tab';
   $handler->display->display_options['menu']['title'] = 'Features';
   $handler->display->display_options['menu']['description'] = 'A feature is a biological sequence or a section of a biological sequence, or a collection of such sections.';

+ 1 - 1
legacy/tripal_feature/views_handlers/views_handler_field_residues.inc

@@ -17,7 +17,7 @@ class views_handler_field_residues extends views_handler_field {
    */
   function construct() {
     parent::construct();
-      $this->additional_fields['residues'] = array('table' => 'feature', 'field' => 'residues');
+    $this->additional_fields['residues'] = array('table' => 'feature', 'field' => 'residues');
   }
 
   /**

+ 3 - 3
legacy/tripal_featuremap/includes/tripal_featuremap.admin.inc

@@ -17,8 +17,8 @@ function tripal_featuremap_admin_featuremaps_listing() {
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
-  $breadcrumb[] = l('Chado', 'admin/tripal/chado');
-  $breadcrumb[] = l('Maps', 'admin/tripal/chado/tripal_featuremap');
+  $breadcrumb[] = l('Chado', 'admin/tripal/legacy');
+  $breadcrumb[] = l('Maps', 'admin/tripal/legacy/tripal_featuremap');
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
@@ -32,7 +32,7 @@ function tripal_featuremap_admin_featuremaps_listing() {
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'enable the pertinent views</strong>:</p>';
     $output .= '<ul>';
-      $output .= '<li>'.l('Feature Map Admin', 'admin/tripal/chado/tripal_featuremap/views/featuremaps/enable').'</li>';
+      $output .= '<li>'.l('Feature Map Admin', 'admin/tripal/legacy/tripal_featuremap/views/featuremaps/enable').'</li>';
     $output .= '</ul>';
   }
 

+ 2 - 2
legacy/tripal_featuremap/includes/tripal_featuremap.chado_node.inc

@@ -172,7 +172,7 @@ function chado_featuremap_validate($node, $form, &$form_state) {
   if ($node->unittype_id == 0) {
     form_set_error('unittype_id', 'Please provide a unit type for this map.');
   }
-  
+
   // trim white space from text fields
   $node->fmapname = property_exists($node, 'fmapname') ? trim($node->fmapname) : '';
 
@@ -221,7 +221,7 @@ function chado_featuremap_validate($node, $form, &$form_state) {
  *
  * @ingroup tripal_featuremap
  */
-function chado_featuremap_node_access($node, $op, $account) {
+function tripal_featuremap_node_access($node, $op, $account) {
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;

+ 24 - 19
legacy/tripal_featuremap/theme/templates/tripal_feature_featurepos.tpl.php

@@ -2,18 +2,18 @@
 
 // expand the feature object to include the records from the featurepos table
 // specify the number of features to show by default and the unique pager ID
-$num_results_per_page = 25; 
+$num_results_per_page = 5;
 $featurepos_pager_id = 20;
 
 // get the maps associated with this feature
 $feature = $variables['node']->feature;
-$options = array(  
+$options = array(
   'return_array' => 1,
   'order_by' => array(
     'map_feature_id' => 'ASC'
   ),
   'pager' => array(
-    'limit' => $num_results_per_page, 
+    'limit' => $num_results_per_page,
     'element' => $featurepos_pager_id
   ),
   'include_fk' => array(
@@ -29,7 +29,7 @@ $options = array(
 
 $feature = chado_expand_var($feature, 'table', 'featurepos', $options);
 
-// because the featurepos table has  FK relationships with map_feature_id and feature_id with the feature table 
+// because the featurepos table has  FK relationships with map_feature_id and feature_id with the feature table
 // the function call above will try to expand both and will create an array of matches for each FK.
 // we only want to show the map that this feature belongs to
 $map_positions = $feature->featurepos->map_feature_id;
@@ -39,20 +39,20 @@ $total_records = chado_pager_get_count($featurepos_pager_id);
 
 
 if(count($map_positions) > 0){ ?>
-  <div class="tripal_feature-data-block-desc tripal-data-block-desc">This feature is contained in the following <?php print number_format($total_records) ?> map(s):</div><?php 
+  <div class="tripal_feature-data-block-desc tripal-data-block-desc">This feature is contained in the following <?php print number_format($total_records) ?> map(s):</div><?php
 
   // the $headers array is an array of fields to use as the colum headers.
   // additional documentation can be found here
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $headers = array('Map Name', 'Landmark', 'Type', 'Position');
-  
+
   // the $rows array contains an array of rows where each row is an array
   // of values for each column of the table in that row.  Additional documentation
   // can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $rows = array();
 
-  // iterate through our map positions    
+  // iterate through our map positions
   foreach ($map_positions as $position){
     $map_feature = $position->map_feature_id;
 
@@ -61,7 +61,7 @@ if(count($map_positions) > 0){ ?>
     $options = array(
       'return_array' => 1,
       'include_fk' => array(
-        'type_id' => 1,            
+        'type_id' => 1,
       ),
     );
     $position = chado_expand_var($position, 'table', 'featureposprop', $options);
@@ -76,8 +76,8 @@ if(count($map_positions) > 0){ ?>
          if ($property->type_id->name == 'stop') {
            $stop = $property->value;
          }
-      }      
-    }  
+      }
+    }
     if ($start and $stop and $start != $stop) {
       $mappos = "$start-$stop";
     }
@@ -87,20 +87,20 @@ if(count($map_positions) > 0){ ?>
     if ($start and $stop and $start == $stop) {
       $mappos = $start;
     }
-    
+
     // get the map name feature
     $map_name =  $position->featuremap_id->name;
     if (property_exists($position->featuremap_id, 'nid')) {
       $map_name = l($map_name, 'node/' . $position->featuremap_id->nid, array('attributes' => array('target' => '_blank')));
     }
-    
-    
+
+
     // get the landmark
     $landmark = $map_feature->name;
     if (property_exists($map_feature, 'nid')) {
       $landmark =  l($landmark, 'node/' . $map_feature->nid, array('attributes' => array('target' => '_blank')));
     }
-    
+
     $rows[] = array(
       $map_name,
       $landmark,
@@ -127,22 +127,27 @@ if(count($map_positions) > 0){ ?>
 
   // once we have our table array structure defined, we call Drupal's theme_table()
   // function to generate the table.
-  print theme_table($table); 
-  
+  print theme_table($table);
+
   // the $pager array values that control the behavior of the pager.  For
   // documentation on the values allows in this array see:
   // https://api.drupal.org/api/drupal/includes!pager.inc/function/theme_pager/7
   // here we add the paramter 'block' => 'features'. This is because
   // the pager is not on the default block that appears. When the user clicks a
   // page number we want the browser to re-appear with the page is loaded.
+  // We remove the 'pane' parameter from the original query parameters because
+  // Drupal won't reset the parameter if it already exists.
+  $get = $_GET;
+  unset($_GET['pane']);
   $pager = array(
     'tags' => array(),
     'element' => $featurepos_pager_id,
     'parameters' => array(
-      'block' => 'featurepos'
+      'pane' => 'featurepos'
     ),
     'quantity' => $num_results_per_page,
   );
-  print theme_pager($pager); 
-}?>
+  print theme_pager($pager);
+  $_GET = $get;
+}
 

+ 27 - 22
legacy/tripal_featuremap/theme/templates/tripal_featuremap_featurepos.tpl.php

@@ -4,15 +4,15 @@ $feature_positions = array();
 
 // expand the featuremap object to include the records from the featurepos table
 // specify the number of features to show by default and the unique pager ID
-$num_results_per_page = 25; 
+$num_results_per_page = 25;
 $featurepos_pager_id = 0;
 
 // get the features aligned on this map
-$options = array(  
+$options = array(
   'return_array' => 1,
   'order_by' => array('map_feature_id' => 'ASC'),
   'pager' => array(
-    'limit' => $num_results_per_page, 
+    'limit' => $num_results_per_page,
     'element' => $featurepos_pager_id
   ),
   'include_fk' => array(
@@ -38,30 +38,30 @@ $total_features = chado_pager_get_count($featurepos_pager_id);
 
 
 if(count($feature_positions) > 0){ ?>
-  <div class="tripal_featuremap-data-block-desc tripal-data-block-desc">This map contains <?php print number_format($total_features) ?> features:</div> <?php 
-  
+  <div class="tripal_featuremap-data-block-desc tripal-data-block-desc">This map contains <?php print number_format($total_features) ?> features:</div> <?php
+
   // the $headers array is an array of fields to use as the colum headers.
   // additional documentation can be found here
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $headers = array('Landmark', 'Type', 'Organism', 'Feature Name', 'Type', 'Position');
-  
+
   // the $rows array contains an array of rows where each row is an array
   // of values for each column of the table in that row.  Additional documentation
   // can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $rows = array();
-  
+
   foreach ($feature_positions as $position){
     $map_feature = $position->map_feature_id;
-    $feature     = $position->feature_id;  
-    $organism    = $map_feature->organism_id; 
+    $feature     = $position->feature_id;
+    $organism    = $map_feature->organism_id;
 
     // check if there are any values in the featureposprop table for the start and stop
     $mappos = $position->mappos;
     $options = array(
       'return_array' => 1,
       'include_fk' => array(
-        'type_id' => 1,            
+        'type_id' => 1,
       ),
     );
     $position = chado_expand_var($position, 'table', 'featureposprop', $options);
@@ -76,18 +76,18 @@ if(count($feature_positions) > 0){ ?>
          if ($property->type_id->name == 'stop') {
            $stop = $property->value;
          }
-      }      
-    }  
+      }
+    }
     if ($start and $stop and $start != $stop) {
       $mappos = "$start-$stop";
     }
     if ($start and !$stop) {
       $mappos = $start;
-    } 
+    }
     if ($start and $stop and $start == $stop) {
       $mappos = $start;
     }
-    
+
     $mfname = $map_feature->name;
     if (property_exists($map_feature, 'nid')) {
       $mfname =  l($mfname, 'node/' . $map_feature->nid, array('attributes' => array('target' => '_blank')));
@@ -95,18 +95,18 @@ if(count($feature_positions) > 0){ ?>
     $orgname = $organism->genus ." " . $organism->species ." (" . $organism->common_name .")";
     if (property_exists($organism, 'nid')) {
       $orgname = l(
-        "<i>" . $organism->genus . " " . $organism->species . "</i> (" . $organism->common_name .")", 
-        "node/". $organism->nid, 
+        "<i>" . $organism->genus . " " . $organism->species . "</i> (" . $organism->common_name .")",
+        "node/". $organism->nid,
         array('html' => TRUE, 'attributes' => array('target' => '_blank'))
       );
     }
     $organism =  $organism->genus . ' ' . $organism->species;
-    
+
     $fname = $feature->name;
     if (property_exists($feature, 'nid')) {
       $fname = l($fname, 'node/' . $feature->nid, array('attributes' => array('target' => '_blank')));
     }
-      
+
     $rows[] = array(
       $mfname,
       $map_feature->type_id->name,
@@ -115,7 +115,7 @@ if(count($feature_positions) > 0){ ?>
       $feature->type_id->name,
       $mappos . ' ' . $position->featuremap_id->unittype_id->name
     );
-  } 
+  }
   // the $table array contains the headers and rows array as well as other
   // options for controlling the display of the table.  Additional
   // documentation can be found here:
@@ -132,7 +132,7 @@ if(count($feature_positions) > 0){ ?>
     'colgroups' => array(),
     'empty' => '',
   );
-  
+
   // once we have our table array structure defined, we call Drupal's theme_table()
   // function to generate the table.
   print theme_table($table);
@@ -143,14 +143,19 @@ if(count($feature_positions) > 0){ ?>
   // here we add the paramter 'block' => 'features'. This is because
   // the pager is not on the default block that appears. When the user clicks a
   // page number we want the browser to re-appear with the page is loaded.
+  // We remove the 'pane' parameter from the original query parameters because
+  // Drupal won't reset the parameter if it already exists.
+  $get = $_GET;
+  unset($_GET['pane']);
   $pager = array(
     'tags' => array(),
     'element' => $featurepos_pager_id,
     'parameters' => array(
-      'block' => 'featurepos'
+      'pane' => 'featurepos'
     ),
     'quantity' => $num_results_per_page,
   );
-  print theme_pager($pager); 
+  print theme_pager($pager);
+  $_GET = $get;
 }
 

+ 16 - 16
legacy/tripal_featuremap/theme/templates/tripal_featuremap_publication.tpl.php

@@ -1,65 +1,65 @@
 <?php
 $featuremap = $variables['node']->featuremap;
 
-// expand featuremap to include pubs 
+// expand featuremap to include pubs
 $options = array('return_array' => 1);
 $featuremap = chado_expand_var($featuremap, 'table', 'featuremap_pub', $options);
-$featuremap_pubs = $featuremap->featuremap_pub; 
+$featuremap_pubs = $featuremap->featuremap_pub;
 
 
 if (count($featuremap_pubs) > 0) { ?>
-  <div class="tripal_featuremap_pub-data-block-desc tripal-data-block-desc"></div> <?php 
+  <div class="tripal_featuremap_pub-data-block-desc tripal-data-block-desc"></div> <?php
 
   // the $headers array is an array of fields to use as the colum headers.
   // additional documentation can be found here
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $headers = array('Year', 'Publication');
-  
+
   // the $rows array contains an array of rows where each row is an array
   // of values for each column of the table in that row.  Additional documentation
   // can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $rows = array();
-  
+
   foreach ($featuremap_pubs as $featuremap_pub) {
     $pub = $featuremap_pub->pub_id;
     $pub = chado_expand_var($pub, 'field', 'pub.title');
     $citation = $pub->title;  // use the title as the default citation
-    
+
     // get the citation for this pub if it exists
     $values = array(
-      'pub_id' => $pub->pub_id, 
+      'pub_id' => $pub->pub_id,
       'type_id' => array(
         'name' => 'Citation',
       ),
     );
     $options = array('return_array' => 1);
-    $citation_prop = chado_generate_var('pubprop', $values, $options); 
+    $citation_prop = chado_generate_var('pubprop', $values, $options);
     if (count($citation_prop) == 1) {
       $citation_prop = chado_expand_var($citation_prop, 'field', 'pubprop.value');
       $citation = $citation_prop[0]->value;
     }
-    
+
     // if the publication is synced then link to it
     if (property_exists($pub, 'nid')) {
       // replace the title with a link
       $link = l($pub->title, 'node/' . $pub->nid ,array('attributes' => array('target' => '_blank')));
       $patterns = array(
-        '/(\()/', '/(\))/', 
+        '/(\()/', '/(\))/',
         '/(\])/', '/(\[)/',
         '/(\{)/', '/(\})/',
-        '/(\+)/', '/(\.)/', '/(\?)/', 
+        '/(\+)/', '/(\.)/', '/(\?)/',
       );
       $fixed_title = preg_replace($patterns, "\\\\$1", $pub->title);
-      $citation = preg_replace('/' . $fixed_title . '/', $link, $citation);
+      $citation = preg_replace('/' . str_replace('/', ' ', $fixed_title) . '/', $link, $citation);
     }
-    
+
     $rows[] = array(
       $pub->pyear,
       $citation,
     );
   }
-  
+
   // the $table array contains the headers and rows array as well as other
   // options for controlling the display of the table.  Additional
   // documentation can be found here:
@@ -76,8 +76,8 @@ if (count($featuremap_pubs) > 0) { ?>
     'colgroups' => array(),
     'empty' => '',
   );
-  
+
   // once we have our table array structure defined, we call Drupal's theme_table()
   // function to generate the table.
-  print theme_table($table);  
+  print theme_table($table);
 }

+ 2 - 2
legacy/tripal_featuremap/tripal_featuremap.info

@@ -3,10 +3,10 @@ description = Supports the map tables of Chado by providing pages for viewing an
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-rc1
 
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_organism
 dependencies[] = tripal_feature
 dependencies[] = tripal_cv

+ 3 - 178
legacy/tripal_featuremap/tripal_featuremap.install

@@ -309,7 +309,8 @@ function tripal_featuremap_add_cvterms() {
  *
  * @ingroup tripal_featuremap
  */
-function tripal_featuremap_add_custom_tables(){
+// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
+/* function tripal_featuremap_add_custom_tables(){
   // add the featuremaprop table to Chado
   $schema = array (
     'table' => 'featuremapprop',
@@ -482,180 +483,4 @@ function tripal_featuremap_add_custom_tables(){
     ),
   );
   chado_create_custom_table('featureposprop', $schema, TRUE);
-}
-
-
-/**
- * This is the required update for tripal_featuremap when upgrading from Drupal core API 6.x.
- * This update may take some time to complete.
- */
-function tripal_featuremap_update_7200() {
-  // We can't use the Tripal API during an upgrade from D6 to D7 Tripal  because the tripal_core
-  // module is disabled. So, we have to manually make database additions/changes to chado.
-
-  // set the default vocabularies
-  // featuremap_units
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'featuremap_units'")->fetchField();
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-        'table_name' => 'featuremap',
-        'field_name' => 'unittype_id',
-        'cv_id' => $cv_id
-      ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to set featuremap_units vocabulary as default: '. $error);
-  }
-
-  // featurepos_property
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'featurepos_property'")->fetchField();
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-        'table_name' => 'featureposprop',
-        'field_name' => 'type_id',
-        'cv_id' => $cv_id
-      ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to set featurepos_property vocabulary as default: '. $error);
-  }
-
-  // featuremap_property
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'featuremap_property'")->fetchField();
-    db_insert('tripal_cv_defaults')
-     ->fields(array(
-       'table_name' => 'featuremapprop',
-       'field_name' => 'type_id',
-       'cv_id' => $cv_id
-      ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to set featuremap_property vocabulary as default: '. $error);
-  }
-
-}
-
-/**
- * Implementation of hook_update_dependencies().  It specifies a list of
- * other modules whose updates must be run prior to this one.
- */
-function tripal_featuremap_update_dependencies() {
-  $dependencies = array();
-
-  // the tripal_cv update 7200 must run prior to update 7200 of this module
-  $dependencies['tripal_featuremap'][7200] = array(
-    'tripal_cv' => 7200
-  );
-
-  return $dependencies;
-}
-
-/**
- * Adds missing foreign key constraints
- *
- */
-function tripal_featuremap_update_7201() {
-  // there was a bug in the function for creating a custom table that
-  // kept foreign key constraints from being added.  So, we need to add those
-  // to keep from error messages appear, we will drop the FK if it already
-  // exists and then re-add it.
-  try {
-    $fkey_exists = db_query('SELECT TRUE FROM pg_constraint WHERE conname = :constraint', array(':constraint' => 'featuremapprop_type_id_fkey'))->fetchField();
-    if ($fkey_exists) {
-      // featuremapprop table
-      db_query('
-        ALTER TABLE chado.featuremapprop
-        DROP CONSTRAINT featuremapprop_type_id_fkey CASCADE
-      ');
-      db_query('
-        ALTER TABLE chado.featuremapprop
-        DROP CONSTRAINT featuremapprop_featuremap_id_fkey CASCADE
-      ');
-    }
-    db_query('
-      ALTER TABLE chado.featuremapprop
-      ADD CONSTRAINT featuremapprop_type_id_fkey
-      FOREIGN KEY (type_id) REFERENCES chado.cvterm (cvterm_id)
-      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
-    ');
-    db_query('
-      ALTER TABLE chado.featuremapprop
-      ADD CONSTRAINT featuremapprop_featuremap_id_fkey
-      FOREIGN KEY (featuremap_id) REFERENCES chado.featuremap (featuremap_id)
-      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
-    ');
-
-    // featuremap_dbref table
-    if ($fkey_exists) {
-      db_query('
-        ALTER TABLE chado.featuremap_dbxref
-        DROP CONSTRAINT featuremap_dbxref_dbxref_id_fkey CASCADE
-      ');
-      db_query('
-        ALTER TABLE chado.featuremap_dbxref
-        DROP CONSTRAINT featuremap_dbxref_featuremap_id_fkey CASCADE
-      ');
-    }
-    db_query('
-      ALTER TABLE chado.featuremap_dbxref
-      ADD CONSTRAINT featuremap_dbxref_dbxref_id_fkey
-      FOREIGN KEY (dbxref_id) REFERENCES chado.dbxref (dbxref_id)
-      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
-    ');
-    db_query('
-      ALTER TABLE chado.featuremap_dbxref
-      ADD CONSTRAINT featuremap_dbxref_featuremap_id_fkey
-      FOREIGN KEY (featuremap_id) REFERENCES chado.featuremap (featuremap_id)
-      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
-    ');
-
-    // featureposprop
-    if ($fkey_exists) {
-      db_query('
-        ALTER TABLE chado.featureposprop
-        DROP CONSTRAINT featureposprop_type_id_fkey CASCADE
-      ');
-      db_query('
-        ALTER TABLE chado.featureposprop
-        DROP CONSTRAINT featureposprop_featurepos_id_fkey CASCADE
-      ');
-    }
-    db_query('
-      ALTER TABLE chado.featureposprop
-      ADD CONSTRAINT featureposprop_type_id_fkey
-      FOREIGN KEY (type_id) REFERENCES chado.cvterm (cvterm_id)
-      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
-    ');
-    db_query('
-      ALTER TABLE chado.featureposprop
-      ADD CONSTRAINT featureposprop_featurepos_id_fkey
-      FOREIGN KEY (featurepos_id) REFERENCES chado.featurepos (featurepos_id)
-      ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED
-    ');
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to update foriegn key: '. $error);
-  }
-}
-/**
- * Fixes a typo when setting the default CV for the unittype_id field of the featuremap table.
- */
-function tripal_featuremap_update_7202() {
-  try {
-    tripal_set_default_cv('featuremap', 'unittype_id', 'featuremap_units');
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to update featurmap CV default: '. $error);
-  }
-}
+} */

+ 10 - 8
legacy/tripal_featuremap/tripal_featuremap.module

@@ -55,6 +55,7 @@ function tripal_featuremap_help($path, $arg) {
  */
 function tripal_featuremap_permission() {
   return array(
+    /*
     'access chado_featuremap content' => array(
       'title' => t('View Maps'),
       'description' => t('Allow users to view map pages.'),
@@ -75,6 +76,7 @@ function tripal_featuremap_permission() {
       'title' => t('Administer Maps'),
       'description' => t('Allow users to administer all maps.'),
     ),
+    */
   );
 }
 
@@ -91,7 +93,8 @@ function tripal_featuremap_menu() {
   $items = array();
 
   // The administative settings menu
-  $items['admin/tripal/chado/tripal_featuremap'] = array(
+
+  $items['admin/tripal/legacy/tripal_featuremap'] = array(
     'title' => 'Feature Maps',
     'description' => 'A map of features from the chado database (e.g. genetic map)',
     'page callback' => 'tripal_featuremap_admin_featuremaps_listing',
@@ -99,7 +102,7 @@ function tripal_featuremap_menu() {
     'type' => MENU_NORMAL_ITEM,
   );
 
-  $items['admin/tripal/chado/tripal_featuremap/help'] = array(
+  $items['admin/tripal/legacy/tripal_featuremap/help'] = array(
     'title' => 'Help',
     'description' => 'Basic Description of Tripal Map Module Functionality',
     'page callback' => 'theme',
@@ -109,7 +112,7 @@ function tripal_featuremap_menu() {
     'weight' => 10
   );
 
-  $items['admin/tripal/chado/tripal_featuremap/configuration'] = array(
+  $items['admin/tripal/legacy/tripal_featuremap/configuration'] = array(
     'title' => 'Settings',
     'description' => 'Manage integration of Chado maps including associated features.',
     'page callback' => 'drupal_get_form',
@@ -119,7 +122,7 @@ function tripal_featuremap_menu() {
     'weight' => 2
   );
 
-  $items['admin/tripal/chado/tripal_featuremap/sync'] = array(
+  $items['admin/tripal/legacy/tripal_featuremap/sync'] = array(
     'title' => ' Sync',
     'description' => 'Sync featuremaps from Chado with Drupal',
     'page callback' => 'drupal_get_form',
@@ -129,7 +132,7 @@ function tripal_featuremap_menu() {
     'weight' => 0
   );
 
-  $items['admin/tripal/chado/tripal_featuremap/chado_featuremap_toc'] = array(
+  $items['admin/tripal/legacy/tripal_featuremap/chado_featuremap_toc'] = array(
     'title' => ' TOC',
     'description' => 'Manage the table of contents for feature map nodes.',
     'page callback' => 'drupal_get_form',
@@ -141,14 +144,13 @@ function tripal_featuremap_menu() {
     'weight' => 3
   );
 
-  $items['admin/tripal/chado/tripal_featuremap/views/featuremaps/enable'] = array(
+  $items['admin/tripal/legacy/tripal_featuremap/views/featuremaps/enable'] = array(
     'title' => 'Enable featuremap Administrative View',
     'page callback' => 'tripal_enable_view',
-    'page arguments' => array('tripal_featuremap_admin_featuremaps', 'admin/tripal/chado/tripal_featuremap'),
+    'page arguments' => array('tripal_featuremap_admin_featuremaps', 'admin/tripal/legacy/tripal_featuremap'),
     'access arguments' => array('administer tripal featuremap'),
     'type' => MENU_CALLBACK,
   );
-
   return $items;
 }
 

+ 1 - 1
legacy/tripal_featuremap/tripal_featuremap.views_default.inc

@@ -253,7 +253,7 @@ function tripal_featuremap_defaultview_admin_featuremaps() {
 
   /* Display: Page */
   $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->display->display_options['path'] = 'admin/tripal/chado/tripal_featuremap/featuremaps';
+  $handler->display->display_options['path'] = 'admin/tripal/legacy/tripal_featuremap/featuremaps';
   $handler->display->display_options['menu']['type'] = 'default tab';
   $handler->display->display_options['menu']['title'] = 'Maps';
   $handler->display->display_options['menu']['description'] = 'A listing of chado feature maps.';

+ 3 - 3
legacy/tripal_genetic/includes/tripal_genetic.admin.inc

@@ -17,8 +17,8 @@ function tripal_genetic_admin_genetics_listing() {
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
-  $breadcrumb[] = l('Chado', 'admin/tripal/chado');
-  $breadcrumb[] = l('Genetics', 'admin/tripal/chado/tripal_genetic');
+  $breadcrumb[] = l('Chado', 'admin/tripal/legacy');
+  $breadcrumb[] = l('Genetics', 'admin/tripal/legacy/tripal_genetic');
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
@@ -32,7 +32,7 @@ function tripal_genetic_admin_genetics_listing() {
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'enable the pertinent views</strong>:</p>';
     $output .= '<ul>';
-      $output .= '<li>'.l('Genetic Admin', 'admin/tripal/chado/tripal_genetic/views/genetics/enable').'</li>';
+      $output .= '<li>'.l('Genetic Admin', 'admin/tripal/legacy/tripal_genetic/views/genetics/enable').'</li>';
     $output .= '</ul>';
   }
 

+ 38 - 33
legacy/tripal_genetic/theme/templates/tripal_feature_genotypes.tpl.php

@@ -1,31 +1,31 @@
 <?php
 /*
  * Details about genotypes associated with features can be found in the following way:
- * 
+ *
  * feature => feature_genotype => genotype
- *   
- * There are two ways that features with genotypes can be associated with stocks.  The first, 
+ *
+ * There are two ways that features with genotypes can be associated with stocks.  The first,
  * more simple method, is by traversion the FK relationships in this manner:
- * 
+ *
  *   Simple Method: feature => feature_genotype => genotype => stock_genotype => stock
- *   
+ *
  * The second method involves use of the natural diversity tables which allows for association
- * or more ancilliary information. Within the Natural Diversity tables, if a feature has genotypes then 
- * you can find the corresponding stock by traversing the FK relationships 
- * in this manner: 
- * 
+ * or more ancilliary information. Within the Natural Diversity tables, if a feature has genotypes then
+ * you can find the corresponding stock by traversing the FK relationships
+ * in this manner:
+ *
  *   ND Method:     feature => feature_genotype => nd_experiment_genotype => nd_experiment => nd_experiment_stock => stock
- * 
- * The tripal_natural_diversity module handles association of stocks using the ND method.  
+ *
+ * The tripal_natural_diversity module handles association of stocks using the ND method.
  * This template handles association of stocks when stored using the simple method.
  * If the tripal_natural_diversity module is enabled then this template will not show.
  * You should instead see the tripal_feature.nd_genotypes.tpl.php template
- * 
+ *
  */
 $feature = $variables['node']->feature;
 
 // specify the number of genotypes to show by default and the unique pager ID
-$num_results_per_page = 25; 
+$num_results_per_page = 25;
 $feature_pager_id = 15;
 
 // get the genotypes from the feature_genotype table
@@ -36,7 +36,7 @@ $options = array(
     'element' => $feature_pager_id
   ),
 );
-$feature = chado_expand_var($feature, 'table', 'feature_genotype', $options); 
+$feature = chado_expand_var($feature, 'table', 'feature_genotype', $options);
 $feature_genotypes = $feature->feature_genotype->feature_id;
 
 // get the total number of records
@@ -44,8 +44,8 @@ $total_records = chado_pager_get_count($feature_pager_id);
 
 // now iterate through the feature genotypes and print a paged table.
 if (count($feature_genotypes) > 0) {?>
-  <div class="tripal_feature-data-block-desc tripal-data-block-desc">This following <?php print number_format($total_records) ?> genotype(s) have been recorded for this feature.</div><?php 
-  
+  <div class="tripal_feature-data-block-desc tripal-data-block-desc">This following <?php print number_format($total_records) ?> genotype(s) have been recorded for this feature.</div><?php
+
   // the $headers array is an array of fields to use as the colum headers.
   // additional documentation can be found here
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
@@ -56,26 +56,26 @@ if (count($feature_genotypes) > 0) {?>
   // can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $rows = array();
-  
+
   foreach($feature_genotypes as $feature_genotype) {
     $genotype = $feature_genotype->genotype_id;
-    
+
     // show the uniquename for the genotype unless a name exists
     $name = $genotype->uniquename;
     if ($genotype->name){
       $name = $genotype->name;
     }
-    
+
     // get the genotype type
     $type = 'N/A';
     if ($genotype->type_id) {
       $type = ucwords(preg_replace('/_/', ' ', $genotype->type_id->name));
     }
-    
+
     // get the genotype properties
     $options = array('return_array' => 1);
     $genotype = chado_expand_var($genotype, 'table', 'genotypeprop', $options);
-    $properties = $genotype->genotypeprop; 
+    $properties = $genotype->genotypeprop;
     $details = '';
     if(count($properties) > 0) {
       foreach ($properties as $property){
@@ -83,7 +83,7 @@ if (count($feature_genotypes) > 0) {?>
       }
       $details = substr($details, 0, -4); // remove trailing <br>
     }
-    
+
     // add in stocks associated with this genotype if any
     $options = array(
       'return_array' => 1,
@@ -94,21 +94,21 @@ if (count($feature_genotypes) > 0) {?>
       ),
     );
     $genotype = chado_expand_var($genotype, 'table', 'stock_genotype', $options);
-    $stock_genotypes = $genotype->stock_genotype; 
+    $stock_genotypes = $genotype->stock_genotype;
 
     // build the list of germplasm.
     $stock_names = '';
-    if(count($stock_genotypes) > 0) { 
-      foreach ($stock_genotypes as $stock_genotype){ 
-        $stock = $stock_genotype->stock_id; 
-        $stock_name = $stock->name . ' (' . $stock->uniquename . ')'; 
+    if(count($stock_genotypes) > 0) {
+      foreach ($stock_genotypes as $stock_genotype){
+        $stock = $stock_genotype->stock_id;
+        $stock_name = $stock->name . ' (' . $stock->uniquename . ')';
         if(property_exists($stock, 'nid')) {
           $stock_name = l($stock_name, 'node/' . $stock->nid, array('attributes' => array('target' => '_blank')));
         }
         $stock_names .= $stock_name . '<br>';
       }
       $stock_names = substr($stock_names, 0, -4); // remove trailing <br>
-    } 
+    }
     // add the fields to the table row
     $rows[] = array(
       $name,
@@ -118,7 +118,7 @@ if (count($feature_genotypes) > 0) {?>
       $stock_names
     );
   }
-   
+
   // the $table array contains the headers and rows array as well as other
   // options for controlling the display of the table.  Additional
   // documentation can be found here:
@@ -135,24 +135,29 @@ if (count($feature_genotypes) > 0) {?>
     'colgroups' => array(),
     'empty' => '',
   );
-  
+
   // once we have our table array structure defined, we call Drupal's theme_table()
   // function to generate the table.
-  print theme_table($table); 
-  
+  print theme_table($table);
+
   // the $pager array values that control the behavior of the pager.  For
   // documentation on the values allows in this array see:
   // https://api.drupal.org/api/drupal/includes!pager.inc/function/theme_pager/7
   // here we add the paramter 'block' => 'features'. This is because
   // the pager is not on the default block that appears. When the user clicks a
   // page number we want the browser to re-appear with the page is loaded.
+  // We remove the 'pane' parameter from the original query parameters because
+  // Drupal won't reset the parameter if it already exists.
+  $get = $_GET;
+  unset($_GET['pane']);
   $pager = array(
     'tags' => array(),
     'element' => $feature_pager_id,
     'parameters' => array(
-      'block' => 'genotypes'
+      'pane' => 'genotypes'
     ),
     'quantity' => $num_results_per_page,
   );
   print theme_pager($pager);
+  $_GET = $get;
 }

+ 32 - 27
legacy/tripal_genetic/theme/templates/tripal_stock_genotypes.tpl.php

@@ -1,35 +1,35 @@
 <?php
 /*
- * Details about genotypes associated with stocks can be found in two ways by 
+ * Details about genotypes associated with stocks can be found in two ways by
  * traversing the the foreign key (FK) relationships in these ways:
- * 
+ *
  *   Simple Method: stock => stock_genotype => genotype
  *   ND Method:     stock => nd_experiment_stock => nd_experiment => nd_experiment_genotype => genotype
- *   
- * The tripal_natural_diversity module handles display of genotypes when stored using the 
+ *
+ * The tripal_natural_diversity module handles display of genotypes when stored using the
  * ND method.  This template handles display of genotype when stored using
  * the Simple Method.  If the tripal_natural_diversity module is enabled then this template
  * will not show.  You should instead see the tripal_stock.nd_genotypes.tpl.php template
- *  
+ *
  */
 $stock = $variables['node']->stock;
 
 // specify the number of genotypes to show by default and the unique pager ID
-$num_results_per_page = 25; 
+$num_results_per_page = 25;
 $stock_pager_id = 15;
 
 // get the genotypes from the stock_genotype table
 $options = array(
-  'return_array' => 1, 
+  'return_array' => 1,
   'pager' => array(
-    'limit' => $num_results_per_page, 
+    'limit' => $num_results_per_page,
     'element' => $stock_pager_id
   ),
   'fk_include' => array(
     'genotype_id' => 1
   ),
 );
-$stock = chado_expand_var($stock, 'table', 'stock_genotype', $options); 
+$stock = chado_expand_var($stock, 'table', 'stock_genotype', $options);
 $stock_genotypes = $stock->stock_genotype;
 
 // get the total number of records
@@ -38,26 +38,26 @@ $total_records = chado_pager_get_count($stock_pager_id);
 // now iterate through the stock genotypes and print a paged table.
 if (count($stock_genotypes) > 0) {?>
   <div class="tripal_stock-data-block-desc tripal-data-block-desc">The following <?php print number_format($total_records) ?> genotype(s) have been recorded for this stock.</div> <?php
-  
+
   // the $headers array is an array of fields to use as the colum headers.
   // additional documentation can be found here
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $headers = array('Name', 'Type', 'Genotype', 'Details', 'Markers');
-  
+
   // the $rows array contains an array of rows where each row is an array
   // of values for each column of the table in that row.  Additional documentation
   // can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $rows = array();
-  
-  foreach($stock_genotypes as $stock_genotype) {       
+
+  foreach($stock_genotypes as $stock_genotype) {
     $genotype = $stock_genotype->genotype_id;
-    
+
     // get the genotype properties
     $options = array('return_array' => 1);
     $genotype = chado_expand_var($genotype, 'table', 'genotypeprop', $options);
-    $properties = $genotype->genotypeprop; 
-    
+    $properties = $genotype->genotypeprop;
+
     // add in markers associated with this genotype if any
     $options = array(
       'return_array' => 1,
@@ -68,8 +68,8 @@ if (count($stock_genotypes) > 0) {?>
       ),
     );
     $genotype = chado_expand_var($genotype, 'table', 'feature_genotype', $options);
-    $feature_genotypes = $genotype->feature_genotype; 
-    
+    $feature_genotypes = $genotype->feature_genotype;
+
     // show the uniquename for the genotype unless a name exists
     $name = $genotype->uniquename;
     if ($genotype->name){
@@ -80,7 +80,7 @@ if (count($stock_genotypes) > 0) {?>
     if ($genotype->type_id) {
       $type = ucwords(preg_replace('/_/', ' ', $genotype->type_id->name));
     }
-    
+
     // get the genotype properties
     $details = '';
     if(count($properties) > 0) {
@@ -89,7 +89,7 @@ if (count($stock_genotypes) > 0) {?>
       }
       $details = substr($details, 0, -4); // remove trailing <br>
     }
-    
+
     // build the list of marker features.
     $feature_names = 'N/A';
     if(count($feature_genotypes) > 0) {
@@ -104,7 +104,7 @@ if (count($stock_genotypes) > 0) {?>
       }
       $feature_names = substr($feature_names, 0, -4); // remove trailing <br>
     }
-      
+
     // add the fields to the table row
     $rows[] = array(
       $name,
@@ -113,8 +113,8 @@ if (count($stock_genotypes) > 0) {?>
       $details,
       $feature_names
     );
-  } 
-  
+  }
+
   // the $table array contains the headers and rows array as well as other
   // options for controlling the display of the table.  Additional
   // documentation can be found here:
@@ -134,20 +134,25 @@ if (count($stock_genotypes) > 0) {?>
   // once we have our table array structure defined, we call Drupal's theme_table()
   // function to generate the table.
   print theme_table($table);
-  
+
   // the $pager array values that control the behavior of the pager.  For
   // documentation on the values allows in this array see:
   // https://api.drupal.org/api/drupal/includes!pager.inc/function/theme_pager/7
   // here we add the paramter 'block' => 'features'. This is because
   // the pager is not on the default block that appears. When the user clicks a
   // page number we want the browser to re-appear with the page is loaded.
+  // We remove the 'pane' parameter from the original query parameters because
+  // Drupal won't reset the parameter if it already exists.
+  $get = $_GET;
+  unset($_GET['pane']);
   $pager = array(
     'tags' => array(),
     'element' => $stock_pager_id,
     'parameters' => array(
-      'block' => 'genotypes'
+      'pane' => 'genotypes'
     ),
     'quantity' => $num_results_per_page,
   );
-  print theme_pager($pager); 
-} 
+  print theme_pager($pager);
+  $_GET = $get;
+}

+ 2 - 2
legacy/tripal_genetic/tripal_genetic.info

@@ -3,10 +3,10 @@ description = Supports the genetic tables of Chado by providing pages for viewin
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-rc1
 
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_cv
 dependencies[] = tripal_feature
 dependencies[] = tripal_phenotype

+ 7 - 5
legacy/tripal_genetic/tripal_genetic.module

@@ -14,7 +14,6 @@
 
 require_once 'theme/tripal_genetic.theme.inc';
 
-require_once 'includes/tripal_genetic.schema.inc';
 require_once 'includes/tripal_genetic.admin.inc';
 
 /**
@@ -27,10 +26,12 @@ require_once 'includes/tripal_genetic.admin.inc';
  */
 function tripal_genetic_permission() {
   return array(
+    /*
     'administer tripal genetic' => array(
       'title' => t('Administer Genetic Module'),
       'description' => t('Allow users to administer the genetic module.'),
     ),
+    */
   );
 }
 
@@ -47,7 +48,8 @@ function tripal_genetic_menu() {
   $items = array();
 
     // the administative settings menu
-  $items['admin/tripal/chado/tripal_genetic'] = array(
+
+  $items['admin/tripal/legacy/tripal_genetic'] = array(
    'title' => 'Genetics',
    'description' => 'Genetic data including Genotypes.',
    'page callback' => 'tripal_genetic_admin_genetics_listing',
@@ -55,7 +57,7 @@ function tripal_genetic_menu() {
    'type' => MENU_NORMAL_ITEM,
   );
 
-  $items['admin/tripal/chado/tripal_genetic/help'] = array(
+  $items['admin/tripal/legacy/tripal_genetic/help'] = array(
    'title' => 'Help',
    'description' => "A description of the Tripal genetic module including a short description of it's usage.",
    'page callback' => 'theme',
@@ -64,10 +66,10 @@ function tripal_genetic_menu() {
    'type' => MENU_LOCAL_TASK,
   );
 
-  $items['admin/tripal/chado/tripal_genetic/views/genetics/enable'] = array(
+  $items['admin/tripal/legacy/tripal_genetic/views/genetics/enable'] = array(
     'title' => 'Enable genetic Administrative View',
     'page callback' => 'tripal_enable_view',
-    'page arguments' => array('tripal_genetic_admin_genetics', 'admin/tripal/chado/tripal_genetic'),
+    'page arguments' => array('tripal_genetic_admin_genetics', 'admin/tripal/legacy/tripal_genetic'),
     'access arguments' => array('administer tripal genetic'),
     'type' => MENU_CALLBACK,
   );

+ 1 - 1
legacy/tripal_genetic/tripal_genetic.views_default.inc

@@ -180,7 +180,7 @@ function tripal_genetic_defaultviews_admin_genotypes() {
 
   /* Display: Page */
   $handler = $view->new_display('page', 'Page', 'page_1');
-  $handler->display->display_options['path'] = 'admin/tripal/chado/tripal_genetic/genotypes';
+  $handler->display->display_options['path'] = 'admin/tripal/legacy/tripal_genetic/genotypes';
   $handler->display->display_options['menu']['type'] = 'default tab';
   $handler->display->display_options['menu']['title'] = 'Genotypes';
   $handler->display->display_options['menu']['description'] = 'A genotype is defined by a collection of features, mutations, etc.';

+ 3 - 3
legacy/tripal_library/includes/tripal_library.admin.inc

@@ -17,8 +17,8 @@ function tripal_library_admin_libraries_listing() {
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
-  $breadcrumb[] = l('Chado', 'admin/tripal/chado');
-  $breadcrumb[] = l('Libraries', 'admin/tripal/chado/tripal_library');
+  $breadcrumb[] = l('Chado', 'admin/tripal/legacy');
+  $breadcrumb[] = l('Libraries', 'admin/tripal/legacy/tripal_library');
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
@@ -32,7 +32,7 @@ function tripal_library_admin_libraries_listing() {
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'enable the pertinent views</strong>:</p>';
     $output .= '<ul>';
-      $output .= '<li>'.l('Library Admin', 'admin/tripal/chado/tripal_library/views/libraries/enable').'</li>';
+      $output .= '<li>'.l('Library Admin', 'admin/tripal/legacy/tripal_library/views/libraries/enable').'</li>';
     $output .= '</ul>';
   }
 

+ 24 - 14
legacy/tripal_library/includes/tripal_library.chado_node.inc

@@ -128,7 +128,7 @@ function chado_library_form($node, &$form_state) {
   $lt_message = tripal_set_message("To add additional items to the library type drop down list,
      add a term to the " .
      l($lt_cv->name . " controlled vocabulary",
-       "admin/tripal/vocab/cv/" . $lt_cv->cv_id . "/cvterm/add",
+       "admin/tripal/loaders/chado_cv/" . $lt_cv->cv_id . "/cvterm/add",
        array('attributes' => array('target' => '_blank'))
       ),
      TRIPAL_INFO, array('return_html' => TRUE)
@@ -174,34 +174,44 @@ function chado_library_form($node, &$form_state) {
 
   // PROPERTIES FORM
   //---------------------------------------------
-  $select_options = array();
   $prop_cv = tripal_get_default_cv('libraryprop', 'type_id');
   $cv_id = $prop_cv ? $prop_cv->cv_id : NULL;
-  // if the default is the 'library_property' vocabulary then we want
-  // to exclude the 'Library Description' term since it has it's own form element above
+
+  $details = array(
+    // The name of the prop table.
+    'property_table' => 'libraryprop',
+    // The value of library_id for this record.
+    'chado_id' => $library_id,
+    // The cv.cv_id of the cv governing libraryprop.type_id.
+    'cv_id' => $cv_id,
+  );
+
+  // If the default is the 'library_property' vocabulary then we want
+  // to exclude the 'Library Description' term since it has it's own form
+  // element above
   if ($prop_cv->name == 'library_property') {
     // Generate our own select list so we can exclude the description element
+    $select_options = array();
     $cv_result = chado_select_record('cv', array('cv_id'), array('name' => 'library_property'));
     $cv_id = $cv_result[0]->cv_id;
     $select_options = tripal_get_cvterm_select_options($cv_id);
     $descrip_id = array_search('Library Description', $select_options);
     unset($select_options[$descrip_id]);
+    $details['select_options'] = $select_options;
   }
-  $details = array(
-    'property_table' => 'libraryprop',      // the name of the prop table
-    'chado_id' => $library_id,              // the value of library_id for this record
-    'cv_id' => $cv_id,                      // the cv.cv_id of the cv governing libraryprop.type_id
-    'select_options' => $select_options
-  );
+
   // Adds the form elements to your current form
   chado_add_node_form_properties($form, $form_state, $details);
 
   // ADDITIONAL DBXREFS FORM
   //---------------------------------------------
   $details = array(
-    'linking_table' => 'library_dbxref',  // the name of the _dbxref table
-    'base_foreign_key' => 'library_id',   // the name of the key in your base chado table
-    'base_key_value' => $library_id       // the value of library_id for this record
+    // The name of the _dbxref table.
+    'linking_table' => 'library_dbxref',
+    // The name of the key in your base chado table.
+    'base_foreign_key' => 'library_id',
+    // The value of library_id for this record.
+    'base_key_value' => $library_id
   );
   // Adds the form elements to your current form
   chado_add_node_form_dbxrefs($form, $form_state, $details);
@@ -478,7 +488,7 @@ function chado_library_delete(&$node) {
  *
  * @ingroup tripal_library
  */
-function chado_library_node_access($node, $op, $account) {
+function tripal_library_node_access($node, $op, $account) {
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;

+ 1 - 1
legacy/tripal_library/theme/templates/tripal_library_base.tpl.php

@@ -12,7 +12,7 @@ $property = array(
   'cv_name' => 'library_property'
 );
 $libprop = chado_get_property($record, $property);
-$description = $libprop->value; ?>
+$description = isset($libprop->value) ? $libprop->value : ''; ?>
 
 <div class="tripal_library-data-block-desc tripal-data-block-desc"></div> <?php 
 

+ 6 - 1
legacy/tripal_library/theme/templates/tripal_library_features.tpl.php

@@ -86,15 +86,20 @@ if (count($features) > 0) { ?>
   // here we add the paramter 'block' => 'feature_browser'. This is because
   // the pager is not on the default block that appears. When the user clicks a
   // page number we want the browser to re-appear with the page is loaded.
+  // We remove the 'pane' parameter from the original query parameters because
+  // Drupal won't reset the parameter if it already exists.
+  $get = $_GET;
+  unset($_GET['pane']);
   $pager = array(
     'tags' => array(),
     'element' => $element,
     'parameters' => array(
-      'block' => 'features'
+      'pane' => 'features'
     ),
     'quantity' => $num_per_page,
   );
   print theme_pager($pager);
+  $_GET = $get;
 }
 
 

+ 3 - 0
legacy/tripal_library/theme/templates/tripal_library_properties.tpl.php

@@ -4,6 +4,9 @@ $library = $variables['node']->library;
 $options = array('return_array' => 1);
 $library = chado_expand_var($library, 'table', 'libraryprop', $options);
 $props = $library->libraryprop;
+if (!$props) {
+  return;
+}
 
 // iterate through the properties and remove the 'library_description' as it is
 // already displayed on the base template.

+ 1 - 1
legacy/tripal_library/theme/templates/tripal_organism_libraries.tpl.php

@@ -26,7 +26,7 @@ if (count($libraries) > 0) {?>
   foreach ($libraries as $library){ 
     
     $libname = $library->name;
-    if ($library->nid) {
+    if (isset($library->nid)) {
       $libname = l($libname, "node/".$library->nid, array('attributes' => array('target' => '_blank')));
     }
     

+ 2 - 2
legacy/tripal_library/tripal_library.info

@@ -3,10 +3,10 @@ description = Supports the library tables of Chado by providing pages for viewin
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0-alpha1
+version = 7.x-3.0-rc1
 
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_organism
 dependencies[] = tripal_cv
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است