Browse Source

Added Tripal Views to Tripal v3 (non legacy) and renamed Tripal Chado Views. Fixed several bugs, removed unneeded files

Stephen Ficklin 8 years ago
parent
commit
298111586d
78 changed files with 791 additions and 7205 deletions
  1. 1 1
      legacy/tripal_analysis/tripal_analysis.info
  2. 1 1
      legacy/tripal_contact/tripal_contact.info
  3. 1 1
      legacy/tripal_cv/tripal_cv.info
  4. 1 1
      legacy/tripal_db/tripal_db.info
  5. 0 41
      legacy/tripal_db/tripal_db.module
  6. 0 370
      legacy/tripal_db/tripal_db.views_default.inc
  7. 1 1
      legacy/tripal_example/tripal_example.info
  8. 1 1
      legacy/tripal_feature/tripal_feature.info
  9. 1 1
      legacy/tripal_featuremap/tripal_featuremap.info
  10. 1 1
      legacy/tripal_genetic/tripal_genetic.info
  11. 1 1
      legacy/tripal_library/tripal_library.info
  12. 1 1
      legacy/tripal_natural_diversity/tripal_natural_diversity.info
  13. 1 1
      legacy/tripal_organism/tripal_organism.info
  14. 1 1
      legacy/tripal_phenotype/tripal_phenotype.info
  15. 1 1
      legacy/tripal_project/tripal_project.info
  16. 1 1
      legacy/tripal_pub/tripal_pub.info
  17. 1 1
      legacy/tripal_stock/tripal_stock.info
  18. 1 1
      tripal_bulk_loader/tripal_bulk_loader.info
  19. 1 1
      tripal_chado/api/modules/tripal_chado.db.api.inc
  20. 1 1
      tripal_chado/api/tripal_chado.schema.api.inc
  21. 2 2
      tripal_chado/api/tripal_chado.views.api.inc
  22. 0 337
      tripal_chado/includes/TripalFields.old/chado_base__dbxref_id.inc
  23. 0 235
      tripal_chado/includes/TripalFields.old/chado_base__organism_id.inc
  24. 0 92
      tripal_chado/includes/TripalFields.old/chado_feature__md5checksum.inc
  25. 0 618
      tripal_chado/includes/TripalFields.old/chado_feature__residues.inc
  26. 0 83
      tripal_chado/includes/TripalFields.old/chado_feature__seqlen.inc
  27. 0 168
      tripal_chado/includes/TripalFields.old/chado_gene__transcripts.inc
  28. 0 312
      tripal_chado/includes/TripalFields.old/chado_linker__contact.inc
  29. 0 370
      tripal_chado/includes/TripalFields.old/chado_linker__cvterm.inc
  30. 0 197
      tripal_chado/includes/TripalFields.old/chado_linker__cvterm_adder.inc
  31. 0 418
      tripal_chado/includes/TripalFields.old/chado_linker__dbxref.inc
  32. 0 184
      tripal_chado/includes/TripalFields.old/chado_linker__expression.inc
  33. 0 306
      tripal_chado/includes/TripalFields.old/chado_linker__featureloc.inc
  34. 0 157
      tripal_chado/includes/TripalFields.old/chado_linker__featurepos.inc
  35. 0 150
      tripal_chado/includes/TripalFields.old/chado_linker__genotype.inc
  36. 0 150
      tripal_chado/includes/TripalFields.old/chado_linker__phenotype.inc
  37. 0 204
      tripal_chado/includes/TripalFields.old/chado_linker__prop.inc
  38. 0 306
      tripal_chado/includes/TripalFields.old/chado_linker__prop_adder.inc
  39. 0 260
      tripal_chado/includes/TripalFields.old/chado_linker__pub.inc
  40. 0 1247
      tripal_chado/includes/TripalFields.old/chado_linker__relationship.inc
  41. 0 331
      tripal_chado/includes/TripalFields.old/chado_linker__synonym.inc
  42. 0 90
      tripal_chado/includes/TripalFields.old/chado_organism__type_id.inc
  43. 2 2
      tripal_chado/includes/TripalFields/data__accession/data__accession_widget.inc
  44. 7 0
      tripal_chado/includes/TripalFields/sbo__database_cross_reference/sbo__database_cross_reference.inc
  45. 1 1
      tripal_chado/includes/TripalFields/sbo__database_cross_reference/sbo__database_cross_reference_widget.inc
  46. 5 7
      tripal_chado/includes/TripalFields/schema__publication/schema__publication_formatter.inc
  47. 28 32
      tripal_chado/includes/tripal_chado.db.inc
  48. 2 2
      tripal_chado/includes/tripal_chado.install.inc
  49. 39 59
      tripal_chado/includes/tripal_chado.semweb.inc
  50. 107 167
      tripal_chado/includes/tripal_chado.setup.inc
  51. 2 1
      tripal_chado/tripal_chado.info
  52. 38 1
      tripal_chado/tripal_chado.module
  53. 345 0
      tripal_chado/tripal_chado.views_default.inc
  54. 17 17
      tripal_chado_views/api/tripal_chado_views.DEPRECATED.inc
  55. 17 17
      tripal_chado_views/api/tripal_chado_views.api.inc
  56. 10 10
      tripal_chado_views/includes/tripal_chado_views_integration.inc
  57. 43 43
      tripal_chado_views/includes/tripal_chado_views_integration_UI.inc
  58. 6 6
      tripal_chado_views/includes/tripal_chado_views_integration_port.inc
  59. 0 0
      tripal_chado_views/theme/css/tripal_views_admin_views.css
  60. 0 0
      tripal_chado_views/theme/tripal_chado_views_help.tpl.php
  61. 0 0
      tripal_chado_views/theme/tripal_chado_views_search_biological_content.tpl.php
  62. 1 1
      tripal_chado_views/tripal_chado_views.coder_ignores.txt
  63. 3 3
      tripal_chado_views/tripal_chado_views.info
  64. 14 108
      tripal_chado_views/tripal_chado_views.install
  65. 54 52
      tripal_chado_views/tripal_chado_views.module
  66. 19 19
      tripal_chado_views/tripal_chado_views.views.inc
  67. 11 11
      tripal_chado_views/tripal_chado_views.views_default.inc
  68. 0 0
      tripal_chado_views/tripal_views_integration_fields_form.tpl.php
  69. 0 0
      tripal_chado_views/views-sql-compliant-three-tier-naming-1971160-22.patch
  70. 0 0
      tripal_chado_views/views/handlers/tripal_views_handler_area_action_links.inc
  71. 0 0
      tripal_chado_views/views/handlers/tripal_views_handler_field_sequence.inc
  72. 0 0
      tripal_chado_views/views/handlers/tripal_views_handler_filter_file_upload.inc
  73. 0 0
      tripal_chado_views/views/handlers/tripal_views_handler_filter_no_results.inc
  74. 0 0
      tripal_chado_views/views/handlers/tripal_views_handler_filter_select_cvterm.inc
  75. 0 0
      tripal_chado_views/views/handlers/tripal_views_handler_filter_select_id.inc
  76. 0 0
      tripal_chado_views/views/handlers/tripal_views_handler_filter_select_string.inc
  77. 0 0
      tripal_chado_views/views/handlers/tripal_views_handler_filter_sequence.inc
  78. 0 0
      tripal_chado_views/views/handlers/tripal_views_handler_filter_textarea.inc

+ 1 - 1
legacy/tripal_analysis/tripal_analysis.info

@@ -7,6 +7,6 @@ version = 7.x-3.0-alpha1
 configure = admin/tripal/legacy/tripal_analysis/configuration
 configure = admin/tripal/legacy/tripal_analysis/configuration
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_db
 dependencies[] = tripal_db
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv

+ 1 - 1
legacy/tripal_contact/tripal_contact.info

@@ -6,5 +6,5 @@ package = Tripal v2 Legacy
 version = 7.x-3.0-alpha1
 version = 7.x-3.0-alpha1
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv

+ 1 - 1
legacy/tripal_cv/tripal_cv.info

@@ -7,5 +7,5 @@ version = 7.x-3.0-alpha1
 configure = admin/tripal/vocab
 configure = admin/tripal/vocab
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_db
 dependencies[] = tripal_db

+ 1 - 1
legacy/tripal_db/tripal_db.info

@@ -7,4 +7,4 @@ version = 7.x-3.0-alpha1
 configure = admin/tripal/legacy/tripal_db
 configure = admin/tripal/legacy/tripal_db
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views

+ 0 - 41
legacy/tripal_db/tripal_db.module

@@ -7,8 +7,6 @@
 //require_once 'api/tripal_db.api.inc';
 //require_once 'api/tripal_db.api.inc';
 require_once 'api/tripal_db.DEPRECATED.inc';
 require_once 'api/tripal_db.DEPRECATED.inc';
 
 
-require_once 'includes/tripal_db.admin.inc';
-
 /**
 /**
  * @defgroup tripal_db Database Reference Module
  * @defgroup tripal_db Database Reference Module
  * @ingroup tripal_modules
  * @ingroup tripal_modules
@@ -29,45 +27,6 @@ require_once 'includes/tripal_db.admin.inc';
 function tripal_db_menu() {
 function tripal_db_menu() {
   $items = array();
   $items = array();
 
 
-
-  $items['admin/tripal/legacy/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/legacy/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/legacy/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/legacy/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/legacy/tripal_db/views/dbs/enable'] = array(
   $items['admin/tripal/legacy/tripal_db/views/dbs/enable'] = array(
     'title' => 'Enable Database Administrative View',
     'title' => 'Enable Database Administrative View',
     'page callback' => 'tripal_enable_view',
     'page callback' => 'tripal_enable_view',

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

@@ -12,379 +12,9 @@
 function tripal_db_views_default_views() {
 function tripal_db_views_default_views() {
   $views = array();
   $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;
   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/legacy/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/legacy/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/legacy/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/legacy/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/legacy/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;
-}

+ 1 - 1
legacy/tripal_example/tripal_example.info

@@ -45,6 +45,6 @@ scripts[]          = theme/js/tripal_example.js
 ; These modules must be enabled before this module can be enabled
 ; These modules must be enabled before this module can be enabled
 ;
 ;
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_db
 dependencies[] = tripal_db
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv

+ 1 - 1
legacy/tripal_feature/tripal_feature.info

@@ -9,7 +9,7 @@ stylesheets[all][] = theme/css/tripal_feature.css
 scripts[]          = theme/js/tripal_feature.js
 scripts[]          = theme/js/tripal_feature.js
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_db
 dependencies[] = tripal_db
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv
 dependencies[] = tripal_organism
 dependencies[] = tripal_organism

+ 1 - 1
legacy/tripal_featuremap/tripal_featuremap.info

@@ -6,7 +6,7 @@ package = Tripal v2 Legacy
 version = 7.x-3.0-alpha1
 version = 7.x-3.0-alpha1
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_organism
 dependencies[] = tripal_organism
 dependencies[] = tripal_feature
 dependencies[] = tripal_feature
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv

+ 1 - 1
legacy/tripal_genetic/tripal_genetic.info

@@ -6,7 +6,7 @@ package = Tripal v2 Legacy
 version = 7.x-3.0-alpha1
 version = 7.x-3.0-alpha1
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv
 dependencies[] = tripal_feature
 dependencies[] = tripal_feature
 dependencies[] = tripal_phenotype
 dependencies[] = tripal_phenotype

+ 1 - 1
legacy/tripal_library/tripal_library.info

@@ -6,7 +6,7 @@ package = Tripal v2 Legacy
 version = 7.x-3.0-alpha1
 version = 7.x-3.0-alpha1
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_organism
 dependencies[] = tripal_organism
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv
 
 

+ 1 - 1
legacy/tripal_natural_diversity/tripal_natural_diversity.info

@@ -6,7 +6,7 @@ package = Tripal v2 Legacy
 version = 7.x-3.0-alpha1
 version = 7.x-3.0-alpha1
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv
 dependencies[] = tripal_db
 dependencies[] = tripal_db
 dependencies[] = tripal_genetic
 dependencies[] = tripal_genetic

+ 1 - 1
legacy/tripal_organism/tripal_organism.info

@@ -11,4 +11,4 @@ stylesheets[all][] = theme/css/tripal_organism.css
 dependencies[] = tripal_core
 dependencies[] = tripal_core
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv
 dependencies[] = tripal_db
 dependencies[] = tripal_db
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views

+ 1 - 1
legacy/tripal_phenotype/tripal_phenotype.info

@@ -6,6 +6,6 @@ package = Tripal v2 Legacy
 version = 7.x-3.0-alpha1
 version = 7.x-3.0-alpha1
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv
 dependencies[] = tripal_feature
 dependencies[] = tripal_feature

+ 1 - 1
legacy/tripal_project/tripal_project.info

@@ -7,6 +7,6 @@ version = 7.x-3.0-alpha1
 configure = admin/tripal/legacy/tripal_project
 configure = admin/tripal/legacy/tripal_project
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv
 dependencies[] = tripal_contact
 dependencies[] = tripal_contact

+ 1 - 1
legacy/tripal_pub/tripal_pub.info

@@ -8,7 +8,7 @@ version = 7.x-3.0-alpha1
 stylesheets[all][] = theme/css/tripal_pub.css
 stylesheets[all][] = theme/css/tripal_pub.css
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_cv
 dependencies[] = tripal_cv
 dependencies[] = tripal_db
 dependencies[] = tripal_db
 dependencies[] = tripal_contact
 dependencies[] = tripal_contact

+ 1 - 1
legacy/tripal_stock/tripal_stock.info

@@ -6,5 +6,5 @@ package = Tripal v2 Legacy
 version = 7.x-3.0-alpha1
 version = 7.x-3.0-alpha1
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views
 dependencies[] = tripal_organism
 dependencies[] = tripal_organism

+ 1 - 1
tripal_bulk_loader/tripal_bulk_loader.info

@@ -6,4 +6,4 @@ package = Tripal
 version = 7.x-3.0-alpha1
 version = 7.x-3.0-alpha1
 
 
 dependencies[] = tripal_core
 dependencies[] = tripal_core
-dependencies[] = tripal_views
+dependencies[] = tripal_chado_views

+ 1 - 1
tripal_chado/api/modules/tripal_chado.db.api.inc

@@ -582,4 +582,4 @@ function tripal_autocomplete_dbxref($db_id, $string = '') {
   }
   }
 
 
   drupal_json_output($items);
   drupal_json_output($items);
-}
+}

+ 1 - 1
tripal_chado/api/tripal_chado.schema.api.inc

@@ -489,7 +489,7 @@ function chado_get_table_names($include_custom = NULL) {
 function chado_get_schema($table) {
 function chado_get_schema($table) {
 
 
   // first get the chado version that is installed
   // first get the chado version that is installed
-  $v = $GLOBALS["chado_version"];
+  $v = array_key_exists("chado_version", $GLOBALS) ? $GLOBALS["chado_version"] : '';
 
 
   // get the table array from the proper chado schema
   // get the table array from the proper chado schema
   $v = preg_replace("/\./", "_", $v); // reformat version for hook name
   $v = preg_replace("/\./", "_", $v); // reformat version for hook name

+ 2 - 2
tripal_chado/api/tripal_chado.views.api.inc

@@ -150,7 +150,7 @@ function tripal_make_view_compatible_with_external($view) {
  * @param $redirect_link
  * @param $redirect_link
  *   The path to redirect to. FALSE if no redirect needed
  *   The path to redirect to. FALSE if no redirect needed
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_disable_view($view_name, $redirect_link = FALSE) {
 function tripal_disable_view($view_name, $redirect_link = FALSE) {
 
 
@@ -205,7 +205,7 @@ function tripal_disable_view($view_name, $redirect_link = FALSE) {
  * @param $redirect_link
  * @param $redirect_link
  *   The path to redirect to. FALSE if no redirect needed
  *   The path to redirect to. FALSE if no redirect needed
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_enable_view($view_name, $redirect_link = FALSE) {
 function tripal_enable_view($view_name, $redirect_link = FALSE) {
 
 

+ 0 - 337
tripal_chado/includes/TripalFields.old/chado_base__dbxref_id.inc

@@ -1,337 +0,0 @@
-<?php
-
-class chado_base__dbxref_id extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Accession';
-
-  // The default description for this field.
-  public static $default_description = 'The unique stable accession (ID) for
-        this record on this site.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    foreach ($items as $delta => $item) {
-      if ($item['value']) {
-        $content = $item['value']['vocabulary'] . ':' . $item['value']['accession'];
-        $element[$delta] = array(
-          '#type' => 'markup',
-          '#markup' => $content,
-        );
-      }
-    }
-  }
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the field defaults.
-    $fk_val = '';
-    $db_id = '';
-    $accession = '';
-    $version = '';
-    $description = '';
-
-    // If the field already has a value then it will come through the $items
-    // array.  This happens when editing an existing record.
-    if (count($items) > 0 and array_key_exists($delta, $items)) {
-      $fk_val = $items[$delta]['chado-' . $field_table . '__' . $field_column];
-      $db_id = $items[$delta]['db_id'];
-      $accession = $items[$delta]['accession'];
-      $version = $items[$delta]['version'];
-      $description = $items[$delta]['description'];
-    }
-
-    // Check $form_state['values'] to see if an AJAX call set the values.
-    if (array_key_exists('values', $form_state)) {
-      $fk_val = isset($form_state['values'][$field_name]['und'][$delta]['chado-' . $field_table . '__' . $field_column]) ? $form_state['values'][$field_name]['und'][$delta]['chado-' . $field_table . '__' . $field_column] : '';
-      $db_id = isset($form_state['values'][$field_name]['und'][$delta]['db_id']) ? $form_state['values'][$field_name]['und'][$delta]['db_id'] : '';
-      $accession = isset($form_state['values'][$field_name]['und'][$delta]['accession']) ? $form_state['values'][$field_name]['und'][$delta]['accession'] : '';
-      $version = isset($form_state['values'][$field_name]['und'][$delta]['version']) ? $form_state['values'][$field_name]['und'][$delta]['version'] : '';
-      $description = isset($form_state['values'][$field_name]['und'][$delta]['description']) ? $form_state['values'][$field_name]['und'][$delta]['description'] : '';
-    }
-
-    $schema = chado_get_schema('dbxref');
-    $options = tripal_get_db_select_options();
-
-    //$widget['#element_validate'] = array('chado_base__dbxref_id_widget_validate');
-    $widget['#prefix'] =  "<span id='$field_name-dbxref--db-id'>";
-    $widget['#suffix'] =  "</span>";
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-
-    $widget['chado-' . $field_table . '__' . $field_column] = array(
-      '#type' => 'value',
-      '#default_value' => $fk_val,
-    );
-
-    $widget['db_id'] = array(
-      '#type' => 'select',
-      '#title' => t('Database'),
-      '#options' => $options,
-      '#required' => $element['#required'],
-      '#default_value' => $db_id,
-      '#ajax' => array(
-        'callback' => "chado_base__dbxref_id_widget_form_ajax_callback",
-        'wrapper' => "$field_name-dbxref--db-id",
-        'effect' => 'fade',
-        'method' => 'replace'
-      ),
-    );
-    $widget['accession'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Accession'),
-      '#default_value' => $accession,
-      '#required' => $element['#required'],
-      '#maxlength' => array_key_exists('length', $schema['fields']['accession']) ? $schema['fields']['accession']['length'] : 255,
-      '#size' => 15,
-      '#autocomplete_path' => 'admin/tripal/storage/chado/auto_name/dbxref/' . $db_id,
-      '#ajax' => array(
-        'callback' => "tripal_chado_dbxref_widget_form_ajax_callback",
-        'wrapper' => "$field_name-dbxref--db-id",
-        'effect' => 'fade',
-        'method' => 'replace'
-      ),
-      '#disabled' => $db_id ? FALSE : TRUE,
-    );
-    $widget['version'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Version'),
-      '#default_value' => $version,
-      '#maxlength' => array_key_exists('length', $schema['fields']['version']) ? $schema['fields']['version']['length'] : 255,
-      '#size' => 5,
-      '#disabled' => $db_id ? FALSE : TRUE,
-    );
-    $widget['description'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Description'),
-      '#default_value' => $description,
-      '#size' => 20,
-      '#disabled' => $db_id ? FALSE : TRUE,
-    );
-    $widget['links'] = array(
-      '#type' => 'item',
-      '#markup' => l('Add a new database', 'admin/tripal/legacy/tripal_db/add', array('attributes' => array('target' => '_blank')))
-    );
-  }
-
-
-  /**
-   * @see TripalField::validate()
-   */
-  public function validate($entity_type, $entity, $field, $items, &$errors) {
-
-    $field_name = $this->field['field_name'];
-    $settings = $this->field['settings'];
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the field values.
-    foreach ($items as $delta => $values) {
-      $fk_val = $values['chado-' . $field_table . '__' . $field_column];
-      $db_id = $values['db_id'];
-      $accession = $values['accession'];
-      $version = $values['version'];
-      $description = $values['description'];
-
-      // Make sure that if a database ID is provided that an accession is also
-      // provided.  Here we use the form_set_error function rather than the
-      // form_error function because the form_error will add a red_highlight
-      // around all of the fields in the fieldset which is confusing as it's not
-      // clear to the user what field is required and which isn't. Therefore,
-      // we borrow the code from the 'form_error' function and append the field
-      // so that the proper field is highlighted on error.
-      if (!$db_id and $accession) {
-        $errors[$field_name][$delta]['und'][] = array(
-          'message' => t("A database and the accession must both be provided for the primary cross reference."),
-          'error' => 'chado_base__dbxref',
-        );
-      }
-      if ($db_id and !$accession) {
-        $errors[$field_name][$delta]['und'][] = array(
-          'message' => t("A database and the accession must both be provided for the primary cross reference."),
-          'error' => 'chado_base__dbxref',
-        );
-      }
-      if (!$db_id and !$accession and ($version or $description)) {
-        $errors[$field_name][$delta]['und'][] = array(
-          'message' => t("A database and the accession must both be provided for the primary cross reference."),
-          'error' => 'chado_base__dbxref',
-        );
-      }
-    }
-  }
-
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-    $field_name = $this->field['field_name'];
-    $settings = $this->field['settings'];
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    $fk_val = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__' . $field_column]) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__' . $field_column] : '';
-    $db_id = isset($form_state['values'][$field_name][$langcode][$delta]['db_id']) ? $form_state['values'][$field_name][$langcode][$delta]['db_id'] : '';
-    $accession = isset($form_state['values'][$field_name][$langcode][$delta]['accession']) ? $form_state['values'][$field_name][$langcode][$delta]['accession'] : '';
-    $version = isset($form_state['values'][$field_name][$langcode][$delta]['version']) ? $form_state['values'][$field_name][$langcode][$delta]['version'] : '';
-
-    // If user did not select a database, we want to remove dbxref_id from the
-    // field.
-    if (!$db_id) {
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__dbxref_id'] = '__NULL__';
-    }
-    // If the dbxref_id does not match the db_id + accession then the user
-    // has selected a new dbxref record and we need to update the hidden
-    // value accordingly.
-    if ($db_id and $accession) {
-      $dbxref = chado_generate_var('dbxref', array('db_id' => $db_id, 'accession' => $accession));
-      if ($dbxref and $dbxref->dbxref_id != $fk_val) {
-        $form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__dbxref_id'] = $dbxref->dbxref_id;
-      }
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $record = $details['record'];
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-
-    // Set some defauls for the empty record
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(
-        'vocabulary' => '',
-        'accession' => '',
-        'URL' => '',
-      ),
-      'chado-' . $field_table . '__' . $field_column => '',
-      'db_id' => '',
-      'accession' => '',
-      'version' => '',
-      'description' => '',
-    );
-
-    // Get the primary dbxref record (if it's not NULL).  Because we have a
-    // dbxref_id passed in by the base record, we will only have one record.
-    if ($record->$field_column) {
-      $dbxref = $record->$field_column;
-      $value = $dbxref->db_id->name . ':' . $dbxref->accession;
-      $entity->{$field_name}['und'][0] = array(
-        'value' => array(
-          'vocabulary' => $dbxref->db_id->name,
-          'accession' => $dbxref->accession,
-          'URL' => tripal_get_dbxref_url($dbxref),
-        ),
-        'chado-' . $field_table . '__' . $field_column => $record->$field_column->$field_column,
-        'db_id'       => $dbxref->db_id->db_id,
-        'accession'   => $dbxref->accession,
-        'version'     => $dbxref->version,
-        'description' => $dbxref->description,
-      );
-    }
-  }
-}
-
-/**
- * An Ajax callback for the tripal_chado_admin_publish_form..
- */
-function chado_base__dbxref_id_widget_form_ajax_callback($form, $form_state) {
-  $field_name = $form_state['triggering_element']['#parents'][0];
-  $field = field_info_field($field_name);
-  $field_type = $field['type'];
-  $field_table = $field['settings']['chado_table'];
-  $field_column = $field['settings']['chado_column'];
-  $field_prefix = 'chado-' . $field_table . '__' . $field_column;
-
-//   $db_id = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--db_id');
-//   $accession = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--accession');
-  if ($db_id and $accession) {
-    $values = array(
-      'db_id' => $db_id,
-      'accession' => $accession,
-    );
-    $options = array('is_duplicate' => TRUE);
-    $has_duplicate = chado_select_record('dbxref', array('*'), $values, $options);
-    if (!$has_duplicate) {
-      drupal_set_message('The selected cross reference is new and will be added for future auto completions.', 'warning');
-    }
-  }
-
-  return $form[$field_name];
-}
-
-function theme_chado_base__dbxref_id_widget($variables) {
-  $element = $variables['element'];
-  $field_name = $element['#field_name'];
-  $field = field_info_field($field_name);
-  $field_type = $field['type'];
-  $field_table = $field['settings']['chado_table'];
-  $field_column = $field['settings']['chado_column'];
-  $field_prefix = 'chado-' . $field_table . '__' . $field_column;
-
-  $layout = "
-      <div class=\"primary-dbxref-widget\">
-        <div class=\"primary-dbxref-widget-item\">" .
-        drupal_render($element['db_id']) . "
-        </div>
-        <div class=\"primary-dbxref-widget-item\">" .
-        drupal_render($element['accession']) . "
-        </div>
-        <div class=\"primary-dbxref-widget-item\">" .
-        drupal_render($element['version']) . "
-        </div>
-        <div class=\"primary-dbxref-widget-item\">" .
-        drupal_render($element['description']) . "
-        </div>
-        <div class=\"primary-dbxref-widget-links\">" . drupal_render($element['links']) . "</div>
-      </div>
-    ";
-
-  $fieldset = array(
-    '#title' => $element['#title'],
-    '#value' => '',
-    '#description' => $element['#description'],
-    '#children' => $layout,
-    //    '#attributes' => array('class' => $classes),
-  );
-
-  return theme('fieldset', array('element' => $fieldset));
-}

+ 0 - 235
tripal_chado/includes/TripalFields.old/chado_base__organism_id.inc

@@ -1,235 +0,0 @@
-<?php
-
-class chado_base__organism_id extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Organism';
-
-  // The default description for this field.
-  public static $default_description = 'A field for specifying an organism.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'field_display_string' => '<i>[organism.genus] [organism.species]</i>',
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    if (count($items) > 0) {
-      $content = $items[0]['value']['label'];
-      if (array_key_exists('entity', $items[0]['value'])) {
-        list($entity_type, $entity_id) = explode(':', $items[0]['value']['entity']);
-        $content = l(strip_tags($items[0]['value']['label']), 'bio_data/' . $entity_id);
-      }
-
-      // The cardinality of this field is 1 so we don't have to
-      // iterate through the items array, as there will never be more than 1.
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => $content,
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::widget()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $settings = $this->field['settings'];
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    $organism_id = 0;
-    if (count($items) > 0 and array_key_exists('chado-' . $field_table . '__organism_id', $items[0])) {
-      $organism_id = $items[0]['chado-' . $field_table . '__organism_id'];
-    }
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-    $options = tripal_get_organism_select_options(FALSE);
-    $widget['chado-' . $field_table . '__organism_id'] = array(
-      '#type' => 'select',
-      '#title' => $element['#title'],
-      '#description' => $element['#description'],
-      '#options' => $options,
-      '#default_value' => $organism_id,
-      '#required' => $element['#required'],
-      '#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
-      '#delta' => $delta,
-    );
-  }
-
-  /**
-   * @see TripalField::validate()
-   */
-  public function validate($entity_type, $entity, $field, $items, &$errors) {
-
-    $settings = $this->field['settings'];
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the field values.
-    foreach ($items as $delta => $values) {
-
-      // Get the field values.
-      $organism_id = $values['chado-' . $field_table . '__organism_id'];
-      if (!$organism_id or $organism_id == 0) {
-        $errors[$field_name]['und'][0][] = array(
-          'message' =>  t("Please specify an organism."),
-          'error' => 'chado_base__organism_id'
-        );
-      }
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $record = $details['record'];
-    $settings = $this->field['settings'];
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(
-        'label' => '',
-        'genus' => '',
-        'species' => '',
-      ),
-      'semantic_web' => array(
-        'label' => 'rdfs:label',
-        'genus' => tripal_get_chado_semweb_term('organism', 'genus'),
-        'species' => tripal_get_chado_semweb_term('organism', 'species'),
-        'infraspecific_name' => tripal_get_chado_semweb_term('organism', 'infraspecific_name'),
-        'infraspecific_type' => tripal_get_chado_semweb_term('organism', 'type_id'),
-      ),
-      'chado_mapping' => array(
-        'genus' => 'organism_id,genus',
-        'species' => 'organism_id,genus',
-        'infraspecific_name' => 'organism_id,infraspecific_name',
-        'infraspecific_type' => 'organism_id,infraspecific_type',
-      )
-    );
-
-    if ($record) {
-      $organism = $record->organism_id;
-      $string = $settings['field_display_string'];
-      $label = tripal_replace_chado_tokens($string, $organism);
-      $entity->{$field_name}['und'][0]['value'] = array(
-        'label' => $label,
-        'genus' => $organism->genus,
-        'species' => $organism->species,
-      );
-      // The infraspecific fiels were introdcued in Chado v1.3.
-      if (property_exists($organism, 'infraspecific_name')) {
-        $entity->{$field_name}['und'][0]['value']['infraspecific_type'] = NULL;
-        $entity->{$field_name}['und'][0]['value']['infraspecific_name'] = $organism->infraspecific_name;
-        if ($organism->type_id) {
-          $entity->{$field_name}['und'][0]['value']['infraspecific_type'] =  $organism->type_id->name;
-        }
-      }
-      $entity->{$field_name}['und'][0]['chado-' . $field_table . '__organism_id'] = $organism->organism_id;
-
-      // Is there a published entity for this organism?
-      if (property_exists($entity->chado_record->$field_column, 'entity_id')) {
-        $fk_entity_id = $entity->chado_record->$field_column->entity_id;
-        $entity->{$field_name}['und'][0]['value']['entity'] = 'TripalEntity:' . $fk_entity_id;
-      }
-    }
-  }
-
-  /**
-   * @see TripalField::globalSettingsForm()
-   */
-  public function globalSettingsForm($has_data) {
-    $element = parent::globalSettingsForm($has_data);
-
-    $settings = $this->field['settings'];
-
-    $element['instructions'] = array(
-      '#type' => 'item',
-      '#markup' => 'You may rewrite the way this field is presented to the end-user.
-        The Rewrite Value field allows you to use tokens to indicate how the
-        value should be displayed.  Tokens will be substituted with appriorate
-        data from the database.  See the Available tokens list for the
-        tokens you may use.'
-    );
-
-    $element['field_display_string'] = array(
-      '#type' => 'textfield',
-      '#title' => 'Rewrite Value',
-      '#description' => t('Provide a mixture of text and/or tokens for the format.
-          For example: [organism.genus] [organism.species].  When displayed,
-          the tokens will be replaced with the actual value.'),
-      '#default_value' => $settings['field_display_string'],
-    );
-
-    $element['tokens'] = array(
-      '#type' => 'fieldset',
-      '#collapsed' => TRUE,
-      '#collapsible' => TRUE,
-      '#title' => 'Available Tokens'
-    );
-    $headers = array('Token', 'Description');
-    $rows = array();
-
-    // Here we use the tripal_get_chado_tokens rather than the
-    // tripal_get_entity_tokens because we can't gurantee that all organisms
-    // have entities.
-    $tokens = tripal_get_chado_tokens('organism');
-    foreach ($tokens as $token) {
-      $rows[] = array(
-        $token['token'],
-        $token['description'],
-      );
-    }
-
-    $table_vars = array(
-      'header'     => $headers,
-      'rows'       => $rows,
-      'attributes' => array(),
-      'sticky'     => FALSE,
-      'caption'    => '',
-      'colgroups'  => array(),
-      'empty'      => 'There are no tokens',
-    );
-    $element['tokens']['list'] = array(
-      '#type' => 'item',
-      '#markup' => theme_table($table_vars),
-    );
-
-    // Add in the semantic web fields.
-    $parent_elements = parent::settings_form($field, $instance, $has_data);
-    $element = array_merge($element, $parent_elements);
-
-    return $element;
-  }
-
-}

+ 0 - 92
tripal_chado/includes/TripalFields.old/chado_feature__md5checksum.inc

@@ -1,92 +0,0 @@
-<?php
-
-class chado_feature__md5checksum  extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Sequence MD5 checksum';
-
-  // The default description for this field.
-  public static $default_description = 'A field for generating MD5 checksum for a sequence.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-    foreach ($items as $delta => $item) {
-      $content = key_exists('value', $item) ? $item['value'] : '';
-      $element[$delta] = array(
-        // We create a render array to produce the desired markup,
-        '#type' => 'markup',
-        '#markup' => $content,
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $settings = $this->field['settings'];
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the field defaults.
-    $md5checksum = '';
-    if (count($items) > 0 and array_key_exists('chado-feature__md5checksum', $items[0])) {
-      $md5checksum = $items[0]['chado-feature__md5checksum'];
-    }
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => $md5checksum,
-    );
-    $widget['chado-feature__md5checksum'] = array(
-      '#type' => 'value',
-      '#value' => $md5checksum,
-    );
-  }
-
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-    $field = $this->field;
-    $settings = $field['settings'];
-    $field_name = $field['field_name'];
-    $field_type = $field['type'];
-    $field_table = $field['settings']['chado_table'];
-    $field_column = $field['settings']['chado_column'];
-
-    // Get the residues so we can calculate teh length.
-    $residues = isset($form_state['values']['feature__residues'][$langcode][0]['chado-feature__residues']) ? $form_state['values']['feature__residues'][$langcode][0]['chado-feature__residues'] : '';
-
-    if ($residues) {
-      // Remove spaces and new lines from the residues string.
-      $residues = preg_replace('/\s/', '', $residues);
-      $form_state['values']['feature__residues'][$langcode][0]['chado-feature__residues'] = $residues;
-      $form_state['values'][$field_name][$langcode][$delta]['chado-feature__md5checksum'] = md5($residues);
-    }
-    else {
-      // Otherwise, remove the md5 value
-      $form_state['values'][$field_name][$langcode][$delta]['chado-feature__md5checksum'] = '__NULL__';
-    }
-  }
-}

+ 0 - 618
tripal_chado/includes/TripalFields.old/chado_feature__residues.inc

@@ -1,618 +0,0 @@
-<?php
-
-class chado_feature__residues extends TripalField {
-
-  // The default lable for this field.
-  public static $default_label = 'Sequences';
-
-  // The default description for this field.
-  public static $default_description = 'A field for managing nucleotide and protein residues.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-
-    $element[0] = array(
-      // We create a render array to produce the desired markup,
-      '#type' => 'markup',
-      '#markup' => '',
-    );
-
-    $num_bases = 50;
-    foreach ($items as $delta => $item) {
-      // If there are no residues then skip this one.
-      if (!is_array($item['value']) or !array_key_exists('residues', $item['value'])) {
-        continue;
-      }
-
-      $residues = $item['value']['residues'];
-      $label = $item['value']['label'];
-      $defline = $item['value']['defline'];
-
-      $content = '<p>' . $label . '<p>';
-      $content .= '<pre class="residues-formatter">';
-      $content .= '>' . $defline . "<br>";
-      $content .= wordwrap($residues, $num_bases, "<br>", TRUE);
-      $content .= '</pre>';
-
-      $element[$delta] = array(
-        // We create a render array to produce the desired markup,
-        '#type' => 'markup',
-        '#markup' => $content,
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $settings = $this->field['settings'];
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the field defaults.
-    $residues = '';
-    if (count($items) > 0 and array_key_exists('chado-feature__residues', $items[0])) {
-      $residues = $items[0]['chado-feature__residues'];
-    }
-    if (array_key_exists('values', $form_state)) {
-      //$residues = tripal_chado_get_field_form_values($field_name, $form_state, 0, 'feature__residues');
-    }
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-    $widget['chado-feature__residues'] = array(
-      '#type' => 'textarea',
-      '#title' => $element['#title'],
-      '#description' => $element['#description'],
-      '#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
-      '#default_value' => $residues,
-      '#delta' => $delta,
-      '#cols' => 30,
-    );
-  }
-
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-
-    $field_name = $this->field['field_name'];
-
-    // Remove any white spaces.
-    $residues = isset($form_state['values'][$field_name][$langcode][$delta]['chado-feature__residues']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-feature__residues'] : '';
-    if ($residues) {
-      $residues = preg_replace('/\s/', '', $residues);
-      $form_state['values'][$field_name][$langcode][$delta]['chado-feature__residues'] = $residues;
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $field_name = $this->field['field_name'];
-    $feature = $details['record'];
-    $num_seqs = 0;
-
-    // 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
-    // reasonable to print them on a page.
-    if(strcmp($feature->type_id->name,'scaffold') == 0 or
-       strcmp($feature->type_id->name,'chromosome') == 0 or
-       strcmp($feature->type_id->name,'supercontig') == 0 or
-       strcmp($feature->type_id->name,'pseudomolecule') == 0) {
-      $entity->{$field_name}['und'][$num_seqs]['value'] = array(
-        '@type' => 'SO:0000110',
-        'type' => 'sequence_feature',
-        'label' => 'Residues',
-        'defline' => ">This sequence is too large for this display.",
-        'residues' => '',
-      );
-      $entity->{$field_name}['und'][$num_seqs]['chado-feature__residues'] = '';
-    }
-    else {
-      $feature = chado_expand_var($feature,'field','feature.residues');
-      if ($feature->residues) {
-        $entity->{$field_name}['und'][$num_seqs]['value'] = array(
-          '@type' => 'SO:0000110',
-          'type' => 'sequence_feature',
-          'label' => 'Raw Sequence',
-          'defline' => tripal_get_fasta_defline($feature, '', NULL, '', strlen($feature->residues)),
-          'residues' => $feature->residues,
-        );
-        $entity->{$field_name}['und'][$num_seqs]['chado-feature__residues'] = $feature->residues;
-      }
-      else {
-        $entity->{$field_name}['und'][$num_seqs]['value'] = array();
-        $entity->{$field_name}['und'][$num_seqs]['chado-feature__residues'] = '';
-      }
-    }
-    $num_seqs++;
-
-    // Add in the protein sequences. It's faster to provide the SQL rather than
-    // to use chado_generate_var based on the type.
-    $sql = "
-      SELECT F.*
-      FROM {feature_relationship} FR
-        INNER JOIN {feature} F on FR.subject_id = F.feature_id
-        INNER JOIN {cvterm} CVT on CVT.cvterm_id = F.type_id
-        INNER JOIN {cvterm} RCVT on RCVT.cvterm_id = FR.type_id
-      WHERE
-        FR.object_id = :feature_id and
-        CVT.name = 'polypeptide' and
-        RCVT.name = 'derives_from'
-      ORDER BY FR.rank ASC
-    ";
-    $results = chado_query($sql, array(':feature_id' => $feature->feature_id));
-    while ($protein = $results->fetchObject()) {
-      if ($protein->residues) {
-        $entity->{$field_name}['und'][$num_seqs++]['value'] = array(
-          '@type' => 'SO:0000104',
-          'type' => 'polypeptide',
-          'label' => 'Protein Sequence',
-          'defline' => tripal_get_fasta_defline($protein, '', NULL, '', strlen($protein->residues)),
-          'residues' => $protein->residues,
-        );
-      }
-    }
-
-
-    // Add in sequences from alignments.
-    $options = array(
-      'return_array' => 1,
-      'include_fk' => array(
-        'srcfeature_id' => array(
-          'type_id' => 1
-        ),
-        'feature_id' => array(
-          'type_id' => 1
-        ),
-      ),
-    );
-    $feature = chado_expand_var($feature, 'table', 'featureloc', $options);
-    $featureloc_sequences = $this->get_featureloc_sequences($feature->feature_id, $feature->featureloc->feature_id);
-
-    // Add in the coding sequences. It's faster to provide the SQL rather than
-    // to use chado_generate_var based on the type.
-    $sql = "
-      SELECT F.*
-      FROM {feature_relationship} FR
-        INNER JOIN {feature} F on FR.subject_id = F.feature_id
-        INNER JOIN {cvterm} CVT on CVT.cvterm_id = F.type_id
-        INNER JOIN {cvterm} RCVT on RCVT.cvterm_id = FR.type_id
-        INNER JOIN {featureloc} FL on FL.feature_id = F.feature_id
-      WHERE
-        FR.object_id = :feature_id and
-        CVT.name = 'CDS' and
-        RCVT.name = 'part_of'
-      ORDER BY FR.rank ASC
-    ";
-    $results = chado_query($sql, array(':feature_id' => $feature->feature_id));
-    $coding_seq = '';
-    while ($CDS = $results->fetchObject()) {
-      if ($CDS->residues) {
-        $coding_seq .= $CDS->residues;
-      }
-    }
-    if ($coding_seq) {
-      $entity->{$field_name}['und'][$num_seqs++]['value'] = array(
-        '@type' => 'SO:0000316',
-        'type' => 'coding_sequence',
-        'label' => 'Coding sequence (CDS)',
-        'defline' => tripal_get_fasta_defline($feature, 'CDS', NULL, '', strlen($coding_seq)),
-        'residues' => $coding_seq,
-      );
-    }
-
-    foreach($featureloc_sequences as $src => $attrs){
-      // the $attrs array has the following keys
-      //   * id:  a unique identifier combining the feature id with the cvterm id
-      //   * type: the type of sequence (e.g. mRNA, etc)
-      //   * location:  the alignment location
-      //   * defline: the definition line
-      //   * formatted_seq: the formatted sequences
-      //   * featureloc:  the feature object aligned to
-      $entity->{$field_name}['und'][$num_seqs++]['value'] = array(
-        'residues' => $attrs['residues'],
-        '@type' => 'SO:0000110',
-        'type' => 'sequence_feature',
-        'defline' => tripal_get_fasta_defline($feature, '', $attrs['featureloc'], 'CDS', strlen($attrs['residues'])),
-        'label' => 'Sequence from alignment at ' . $attrs['location'],
-      );
-
-
-      // check to see if this alignment has any CDS. If so, generate a CDS sequence
-      $cds_sequence = tripal_get_feature_sequences(
-        array(
-          'feature_id' => $feature->feature_id,
-          'parent_id' => $attrs['featureloc']->srcfeature_id->feature_id,
-          'name' => $feature->name,
-          'featureloc_id' => $attrs['featureloc']->featureloc_id,
-        ),
-        array(
-          'derive_from_parent' => 1, // CDS are in parent-child relationships so we want to use the sequence from the parent
-          'aggregate' => 1, // we want to combine all CDS for this feature into a single sequence
-          'sub_feature_types' => array('CDS'), // we're looking for CDS features
-          'is_html' => 0
-        )
-      );
-
-      if (count($cds_sequence) > 0) {
-        // the tripal_get_feature_sequences() function can return multiple sequences
-        // if a feature is aligned to multiple places. In the case of CDSs we expect
-        // 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']) {
-          $entity->{$field_name}['und'][$num_seqs++]['value'] = array(
-            'residues' => $cds_sequence[0]['residues'],
-            '@type' => 'SO:0000316',
-            'type' => 'coding_sequence',
-            'defline' => tripal_get_fasta_defline($feature, '', $attrs['featureloc'], 'CDS', $cds_sequence[0]['length']),
-            'label' => 'Coding sequence (CDS) from alignment at  ' . $attrs['location'],
-          );
-        }
-      }
-    }
-  }
-
-  /**
-   *
-   * @param unknown $feature_id
-   * @param unknown $featurelocs
-   * @return multitype:|Ambigous <multitype:, an>
-   */
-  private function get_featureloc_sequences($feature_id, $featurelocs) {
-
-    // if we don't have any featurelocs then no point in continuing
-    if (!$featurelocs) {
-      return array();
-    }
-
-    // get the list of relationships (including any aggregators) and iterate
-    // through each one to find information needed to color-code the reference sequence
-    $relationships = $this->get_aggregate_relationships($feature_id);
-    if (!$relationships) {
-      return array();
-    }
-
-
-    // iterate through each of the realtionships features and get their
-    // locations
-    foreach ($relationships as $rindex => $rel) {
-      // get the featurelocs for each of the relationship features
-      $rel_featurelocs = $this->get_featurelocs($rel->subject_id, 'as_child', 0);
-      foreach ($rel_featurelocs as $rfindex => $rel_featureloc) {
-        // keep track of this unique source feature
-        $src = $rel_featureloc->src_feature_id . "-" . $rel_featureloc->src_cvterm_id;
-
-        // copy over the results to the relationship object.  Since there can
-        // be more than one feature location for each relationship feature we
-        // use the '$src' variable to keep track of these.
-        $rel->featurelocs = new stdClass();
-        $rel->featurelocs->$src = new stdClass();
-        $rel->featurelocs->$src->src_uniquename = $rel_featureloc->src_uniquename;
-        $rel->featurelocs->$src->src_cvterm_id  = $rel_featureloc->src_cvterm_id;
-        $rel->featurelocs->$src->src_cvname     = $rel_featureloc->src_cvname;
-        $rel->featurelocs->$src->fmin           = $rel_featureloc->fmin;
-        $rel->featurelocs->$src->fmax           = $rel_featureloc->fmax;
-        $rel->featurelocs->$src->src_name       = $rel_featureloc->src_name;
-
-        // keep track of the individual parts for each relationship
-        $start = $rel->featurelocs->$src->fmin;
-        $end   = $rel->featurelocs->$src->fmax;
-        $type  = $rel->subject_type;
-        $rel_locs[$src]['parts'][$start][$type]['start'] = $start;
-        $rel_locs[$src]['parts'][$start][$type]['end']   = $end;
-        $rel_locs[$src]['parts'][$start][$type]['type']  = $type;
-      }
-    }
-
-    // the featurelocs array provided to the function contains the locations
-    // where this feature is found.   We want to get the sequence for each
-    // location and then annotate it with the parts found from the relationships
-    // locations determiend above.
-    $floc_sequences = array();
-    foreach ($featurelocs as $featureloc) {
-
-      // build the src name so we can keep track of the different parts for each feature
-      $src = $featureloc->srcfeature_id->feature_id . "-" . $featureloc->srcfeature_id->type_id->cvterm_id;
-
-      // orient the parts to the beginning of the feature sequence
-      if (!empty($rel_locs[$src]['parts'])) {
-        $parts = $rel_locs[$src]['parts'];
-        $rparts = array();  // we will fill this up if we're on the reverse strand
-
-        foreach ($parts as $start => $types) {
-          foreach ($types as $type_name => $type) {
-            if ($featureloc->strand >= 0) {
-              // this is on the forward strand.  We need to convert the start on the src feature to the
-              // start on this feature's sequence
-              $parts[$start][$type_name]['start'] = $parts[$start][$type_name]['start'] - $featureloc->fmin;
-              $parts[$start][$type_name]['end']   = $parts[$start][$type_name]['end'] - $featureloc->fmin;
-              $parts[$start][$type_name]['type']  = $type_name;
-            }
-            else {
-              // this is on the reverse strand.  We need to swap the start and stop and calculate from the
-              // begining of the reverse sequence
-              $size = ($featureloc->fmax - $featureloc->fmin);
-              $start_orig = $parts[$start][$type_name]['start'];
-              $end_orig = $parts[$start][$type_name]['end'];
-              $new_start = $size - ($end_orig - $featureloc->fmin);
-              $new_end = $size - ($start_orig - $featureloc->fmin);
-
-              $rparts[$new_start][$type_name]['start'] = $new_start;
-              $rparts[$new_start][$type_name]['end']   = $new_end;
-              $rparts[$new_start][$type_name]['type']  = $type_name;
-            }
-          }
-        }
-
-        // now sort the parts
-        // if we're on the reverse strand we need to resort
-        if ($featureloc->strand >= 0) {
-          usort($parts, 'chado_feature__residues_sort_rel_parts_by_start');
-        }
-        else {
-          usort($rparts, 'chado_feature__residues_sort_rel_parts_by_start');
-          $parts = $rparts;
-        }
-
-        $floc_sequences[$src]['id'] = $src;
-        $floc_sequences[$src]['type'] = $featureloc->feature_id->type_id->name;
-        $args = array(':feature_id' => $featureloc->srcfeature_id->feature_id);
-        $start = $featureloc->fmin + 1;
-        $size = $featureloc->fmax - $featureloc->fmin;
-
-        // TODO: fix the hard coded $start and $size
-        // the $start and $size variables are hard-coded in the SQL statement
-        // because the db_query function places quotes around all placeholders
-        // (e.g. :start & :size) and screws up the substring function
-        $sql = "
-          SELECT substring(residues from $start for $size) as residues
-          FROM {feature}
-          WHERE feature_id = :feature_id
-        ";
-        $sequence = chado_query($sql, $args)->fetchObject();
-        $residues = $sequence->residues;
-        if ($featureloc->strand < 0) {
-          $residues = tripal_reverse_compliment_sequence($residues);
-        }
-        $strand = '.';
-        if ($featureloc->strand == 1) {
-          $strand = '+';
-        }
-        elseif ($featureloc->strand == -1) {
-          $strand = '-';
-        }
-        $floc_sequences[$src]['location'] = tripal_get_location_string($featureloc);
-        $floc_sequences[$src]['defline'] = tripal_get_fasta_defline($featureloc->feature_id, '', $featureloc, '', strlen($residues));
-        $floc_sequences[$src]['featureloc'] = $featureloc;
-        $floc_sequences[$src]['residues'] = $residues;
-        //$floc_sequences[$src]['formatted_seq'] =  tripal_feature_color_sequence($residues, $parts, $floc_sequences[$src]['defline']);
-      }
-    }
-    return $floc_sequences;
-  }
-
-  /**
-   * 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
-   */
-  private function 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 $this->get_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
-   */
-  private function get_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;
-    $esql = "
-        SELECT entity_id
-        FROM {chado_entity}
-        WHERE data_table = 'feature' AND record_id = :feature_id";
-    $relationships = array();
-    while ($rel = $results->fetchObject()) {
-      $entity = db_query($esql, array(':feature_id' => $rel->subject_id))->fetchObject();
-      if ($entity) {
-        $rel->subject_entity_id = $entity->entity_id;
-      }
-      $entity = db_query($esql, array(':feature_id' => $rel->object_id))->fetchObject();
-      if ($entity) {
-        $rel->object_entity_id = $entity->entity_id;
-      }
-      $relationships[$i++] = $rel;
-    }
-    return $relationships;
-  }
-
-  /**
-   * Load the locations for a given feature
-   *
-   * @param $feature_id
-   *   The feature to look up locations for
-   * @param $side
-   *   Whether the feature is the scrfeature, 'as_parent', or feature, 'as_child'
-   * @param $aggregate
-   *   Whether or not to get the locations for related features
-   *
-   * @ingroup tripal_feature
-   */
-  private function get_featurelocs($feature_id, $side = 'as_parent', $aggregate = 1) {
-
-    $sql = "
-    SELECT
-       F.name, F.feature_id, F.uniquename,
-       FS.name as src_name, FS.feature_id as src_feature_id, FS.uniquename as src_uniquename,
-       CVT.name as cvname, CVT.cvterm_id,
-       CVTS.name as src_cvname, CVTS.cvterm_id as src_cvterm_id,
-       FL.fmin, FL.fmax, FL.is_fmin_partial, FL.is_fmax_partial,FL.strand, FL.phase
-     FROM {featureloc} FL
-       INNER JOIN {feature} F   ON FL.feature_id = F.feature_id
-       INNER JOIN {feature} FS  ON FS.feature_id = FL.srcfeature_id
-       INNER JOIN {cvterm} CVT  ON F.type_id     = CVT.cvterm_id
-       INNER JOIN {cvterm} CVTS ON FS.type_id    = CVTS.cvterm_id
-   ";
-    if (strcmp($side, 'as_parent')==0) {
-      $sql .= "WHERE FL.srcfeature_id = :feature_id ";
-    }
-    if (strcmp($side, 'as_child')==0) {
-      $sql .= "WHERE FL.feature_id = :feature_id ";
-    }
-
-    $flresults = chado_query($sql, array(':feature_id' => $feature_id));
-
-    // copy the results into an array
-    $i=0;
-    $featurelocs = array();
-    while ($loc = $flresults->fetchObject()) {
-      // if a drupal node exists for this feature then add the nid to the
-      // results object
-
-      $loc->feid = tripal_get_chado_entity_id('feature', $loc->feature_id);
-      $loc->seid = tripal_get_chado_entity_id('feature', $loc->src_feature_id);
-      // add the result to the array
-      $featurelocs[$i++] = $loc;
-    }
-
-    // Add the relationship feature locs if aggregate is turned on
-    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);
-      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);
-        foreach ($rel_featurelocs as $findex => $rfloc) {
-          $featurelocs[$i++] = $rfloc;
-        }
-      }
-    }
-
-    usort($featurelocs, 'chado_feature__residues_sort_locations');
-    return $featurelocs;
-  }
-}
-
-/**
- * Callback function for validating the chado_feature__residues_widget.
- */
-function chado_feature__residues_widget_validate($element, &$form_state) {
-
-}
-
-/**
- * Used to sort the list of relationship parts by start position
- *
- * @ingroup tripal_feature
- */
-function chado_feature__residues_sort_rel_parts_by_start($a, $b) {
-  foreach ($a as $type_name => $details) {
-    $astart = $a[$type_name]['start'];
-    break;
-  }
-  foreach ($b as $type_name => $details) {
-    $bstart = $b[$type_name]['start'];
-    break;
-  }
-  return strnatcmp($astart, $bstart);
-}
-/**
- * Used to sort the feature locs by start position
- *
- * @param $a
- *   One featureloc record (as an object)
- * @param $b
- *   The other featureloc record (as an object)
- *
- * @return
- *   Which feature location comes first
- *
- * @ingroup tripal_feature
- */
-function chado_feature__residues_sort_locations($a, $b) {
-  return strnatcmp($a->fmin, $b->fmin);
-}

+ 0 - 83
tripal_chado/includes/TripalFields.old/chado_feature__seqlen.inc

@@ -1,83 +0,0 @@
-<?php
-
-class chado_feature__seqlen extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Sequence length';
-
-  // The default description for this field.
-  public static $default_description = 'A field for calculating the length of a sequence.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-   /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    foreach ($items as $delta => $item) {
-      $element[$delta] = array(
-        '#type' => 'markup',
-        '#markup' => $item['value'],
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-
-    $widget['chado-feature__seqlen'] =  array(
-      '#type' => 'value',
-      '#value' => 0,
-      '#title' => $element['#title'],
-      '#description' => $element['#description'],
-      '#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
-      '#delta' => $delta,
-    );
-  }
-
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the residues so we can calculate teh length.
-    $residues = $form_state['values']['feature__residues']['und'][0]['chado-feature__residues'];
-    // Remove any white spaces.
-    if ($residues) {
-      $residues = preg_replace('/\s/', '', $residues);
-      $form_state['values']['feature__residues']['und'][0]['chado-feature__residues'] = $residues;
-      $items[0]['chado-feature__seqlen'] = strlen($residues);
-    }
-    else {
-      $items[0]['chado-feature__seqlen'] = '__NULL__';
-    }
-  }
-}

+ 0 - 168
tripal_chado/includes/TripalFields.old/chado_gene__transcripts.inc

@@ -1,168 +0,0 @@
-<?php
-
-class chado_gene__transcripts extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Transcripts';
-
-  // The default description for this field.
-  public static $default_description = 'Transcripts of genes.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatter_settings_summary()
-   */
-  public function formatterSettingsSummary($view_mode) {
-
-  }
-
-  /**
-   * @see TripalField::formatter_settings_form()
-   */
-  public function formatterSettingsForm($view_mode, $form, &$form_state) {
-
-  }
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    // Get the settings
-    $settings = $display['settings'];
-
-    $headers = array('Transcript Name', 'Identifier', 'Type', 'Location');
-    $rows = array();
-    foreach ($items as $delta => $item) {
-
-      if (!$item['value']) {
-        continue;
-      }
-      $transcript = $item['value'];
-
-      // Get the field values
-      $feature_name = $transcript['name'];
-      $feature_uname = $transcript['identifier'];
-      $loc = $transcript['location'];
-      $type = $transcript['type'];
-
-      // Add a link i there is an entity.
-      if (array_key_exists('entity', $item['value']) and $item['value']['entity']) {
-        list($entity_type, $entity_id) = explode(':', $item['value']['entity']);
-        $feature_name = l($feature_name, "bio_data/" . $entity_id, array('attributes' => array('target' => "_blank")));
-      }
-      $rows[] = array($feature_name, $feature_uname, $type, $loc);
-    }
-    $table = array(
-      'header' => $headers,
-      'rows' => $rows,
-      'attributes' => array(
-        'id' => 'tripal_feature-table-transcripts-object',
-        'class' => 'tripal-data-table'
-      ),
-      'sticky' => FALSE,
-      'caption' => "",
-      'colgroups' => array(),
-      'empty' => 'This feature has no transcripts',
-    );
-    $content = theme_table($table);
-
-    // once we have our table array structure defined, we call Drupal's theme_table()
-    // function to generate the table.
-    if (count($items) > 0) {
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => $content,
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $record = $details['record'];
-
-    $field_name = $this->field['field_name'];
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(
-        'type' => '',
-        'name' => '',
-        'identifier' => '',
-        'location' => '',
-      ),
-    );
-
-    // TODO: If the tripal_get_feature_relationships() slows this down then
-    // we may need to write a custom function to get the data.
-    $rels = tripal_get_feature_relationships($record);
-
-    // TODO: what if other transcripts names from SO are used. In that
-    // case we should support those too (using cvtermpath table to find them).
-    // mRNA should not be hard-coded below.
-
-    // Set the value to be a array of "table" rows.
-    $transcripts = array();
-    if (key_exists('part of', $rels['object']) &&
-        key_exists('mRNA', $rels['object']['part of'])) {
-     $transcripts =  $rels['object']['part of']['mRNA'];
-    }
-
-    $headers = array('Name' ,'Identifier', 'Location');
-    $rows = array();
-    $i = 0;
-    foreach ($transcripts as $transcript) {
-      // link the feature to it's node
-      $feature_name = $transcript->record->subject_id->name;
-
-      $locations = $transcript->child_featurelocs;
-      $loc = "";
-      foreach ($locations AS $location) {
-        $loc .= $location->srcfeature_name . ":" . $location->fmin . ".." . $location->fmax;
-      }
-      $type = $transcript->record->subject_id->type_id;
-      $entity->{$field_name}['und'][$i]['value'] = array(
-        'type' => $type->name,
-        'name' => $feature_name,
-        'identifier' => $transcript->record->subject_id->uniquename,
-        'location' => $loc,
-
-      );
-      // Add in the semantic web information that describes each key in the
-      // value array.
-      $entity->{$field_name}['und'][$i]['semantic_web'] = array(
-        'type' => $type->dbxref_id->db_id->name . ":" . $type->dbxref_id->accession,
-        'name' => tripal_get_chado_semweb_term('cvterm', 'name'),
-        'identifier' => tripal_get_chado_semweb_term('feature', 'uniquename'),
-        'location' => '',
-      );
-      if (property_exists($transcript->record->subject_id, 'entity_id')) {
-        $entity_id = $transcript->record->subject_id->entity_id;
-        $entity->{$field_name}['und'][$i]['value']['entity'] = 'TripalEntity:' . $entity_id;
-      }
-      $i++;
-    }
-  }
-
-  /**
-   * We don't want a widget so override this function.
-   */
-  public static function widgetInfo() {
-    return array();
-  }
-}

+ 0 - 312
tripal_chado/includes/TripalFields.old/chado_linker__contact.inc

@@ -1,312 +0,0 @@
-<?php
-
-class chado_linker__contact extends TripalField {
-
-  // The default lable for this field.
-  public static $default_label = 'Contacts';
-
-  // The default description for this field.
-  public static $default_description = 'Associates an indviddual or organization with
-          this record';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-    // Get the settings
-    $settings = $display['settings'];
-
-    $headers = array('Name', 'Description', 'Type');
-    $rows = array();
-
-    foreach ($items as $delta => $item) {
-      $contact = $item['value'];
-      if (!$contact) {
-        continue;
-      }
-
-      // Get the field values
-      $contact_name = $contact['name'];
-      $description = $contact['description'];
-      $type = $contact['type'];
-
-      // Add a link i there is an entity.
-      if (array_key_exists('entity', $item['value']) and $item['value']['entity']) {
-        list($entity_type, $entity_id) = explode(':', $item['value']['entity']);
-        $contact_name = l($contact_name, "bio_data/" . $entity_id, array('attributes' => array('target' => "_blank")));
-      }
-      $rows[] = array($contact_name, $description, $type);
-    }
-    $table = array(
-      'header' => $headers,
-      'rows' => $rows,
-      'attributes' => array(
-        'id' => 'tripal_linker-table-contact-object',
-        'class' => 'tripal-data-table'
-      ),
-      'sticky' => FALSE,
-      'caption' => "",
-      'colgroups' => array(),
-      'empty' => 'No contacts available',
-    );
-    $content = theme_table($table);
-
-    if (count($items) > 0) {
-      // once we have our table array structure defined, we call Drupal's theme_table()
-      // function to generate the table.
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => $content,
-      );
-    }
-  }
-
-
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $entity = $form['#entity'];
-    $field_name = $this->field['field_name'];
-
-    // Get the FK column that links to the base table.
-    $table_name = $this->instance['settings']['chado_table'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-
-    // Get the field defaults.
-    $record_id = '';
-    $fkey_value = $element['#entity']->chado_record_id;
-    $contact_id = '';
-    $name = '';
-
-    // If the field already has a value then it will come through the $items
-    // array.  This happens when editing an existing record.
-    if (count($items) > 0 and array_key_exists($delta, $items)) {
-      $record_id = tripal_get_field_item_keyval($items, $delta, 'chado-' . $table_name . '__' . $pkey, $record_id);
-      $contact_id = tripal_get_field_item_keyval($items, $delta, 'chado-' . $table_name . '__contact_id', $contact_id);
-      if ($contact_id) {
-        $contact = chado_generate_var('contact', array('contact_id' => $contact_id));
-        $name = $contact->name;
-      }
-    }
-
-    $schema = chado_get_schema('contact');
-
-    $widget['#table_name'] = $table_name;
-    $widget['#fkey_field'] = $fkey;
-    $widget['#theme'] = 'chado_linker__contact_widget';
-    $widget['#prefix'] =  "<span id='$table_name-$delta'>";
-    $widget['#suffix'] =  "</span>";
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-
-    $widget['chado-' . $table_name . '__' . $pkey] = array(
-      '#type' => 'value',
-      '#default_value' => $record_id,
-    );
-    $widget['chado-' . $table_name . '__' . $fkey] = array(
-      '#type' => 'value',
-      '#default_value' => $fkey_value,
-    );
-    $widget['chado-' . $table_name . '__contact_id'] = array(
-      '#type' => 'value',
-      '#default_value' => $contact_id,
-    );
-
-    $widget['name'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Contact'),
-      '#default_value' => $name,
-      '#autocomplete_path' => 'admin/tripal/storage/chado/auto_name/contact',
-      '#ajax' => array(
-        'callback' => "chado_linker__contact_widget_form_ajax_callback",
-        'wrapper' => "$table_name-$delta",
-        'effect' => 'fade',
-        'method' => 'replace'
-      ),
-      '#maxlength' => 100000,
-    );
-  }
-
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-
-    // Get the FK column that links to the base table.
-    $table_name = $this->instance['settings']['chado_table'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-    $field_name = $this->field['field_name'];
-
-    // Get the field values.
-    $fkey_value = isset($form_state['values'][$field_name][$langcode][$delta]['value']) ? $form_state['values'][$field_name][$langcode][$delta]['value'] : '';
-    $contact_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__contact_id']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__contact_id'] : '';
-    $name = isset($form_state['values'][$field_name][$langcode][$delta]['name']) ? $form_state['values'][$field_name][$langcode][$delta]['name'] : '';
-
-    // If the user provided a name then we want to set the foreign key
-    // value to be the chado_record_id
-    if ($name and !$contact_id) {
-      $contact = chado_generate_var('contact', array('name' => $name));
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__contact_id'] = $contact->contact_id;
-    }
-
-    // In the widgetForm function we automatically add the foreign key
-    // record.  But if the user did not provide a contact we want to take
-    // it out so that the Chado field_storage infrastructure won't try to
-    // write a record.
-    if (!$name and !$contact_id) {
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey] = '';
-    }
-
-    // If the user removed the contact from the contact_name field
-    // then we want to clear out the rest of the hidden values.
-    // Leave the primary key so the record can be deleted.
-    if (!$name and $contact_id) {
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__contact_id'] = '';
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $record = $details['record'];
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the FK that links to the base record.
-    $schema = chado_get_schema($field_table);
-    $base_table = $details['record']->tablename;
-    $pkey = $schema['primary key'][0];
-    $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
-    $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
-
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(),
-      'chado-' . $field_table . '__' . $pkey => '',
-      'chado-' . $field_table . '__' . $fkey_lcolumn => '',
-      'chado-' . $field_table . '__' . 'contact_id' => '',
-      // Ignore the synonym_sgml column for now.
-    );
-
-    $linker_table = $base_table . '_contact';
-    $options = array(
-      'return_array' => 1,
-      'include_fk' => array(
-        'contact_id' => array(
-          'type_id' => array(
-            'dbxref_id' => array(
-              'db_id' => TRUE,
-            ),
-          ),
-        ),
-        $fkey_lcolumn => TRUE,
-      ),
-    );
-    $record = chado_expand_var($record, 'table', $linker_table, $options);
-    $contact_linkers = $record->$linker_table;
-    if ($contact_linkers) {
-      foreach ($contact_linkers as $i => $contact_linker) {
-        $contact = $contact_linker->contact_id;
-        $entity->{$field_name}['und'][$i] = array(
-          'value' => array(
-            'type' => $contact->type_id ? $contact->type_id->name : '',
-            'name' => $contact->name,
-            'description' => $contact->description,
-          ),
-          // Add in the semantic web settings.  This array is expected by
-          // other Tripal modules that handle semantic web for fields.
-          'semantic_web' => array(
-            'type' => $contact->type_id ? $contact->type_id->dbxref_id->db_id->name . ':' . $contact->type_id->dbxref_id->accession : '',
-            'name' => tripal_get_chado_semweb_term('contact', 'name'),
-            'description' => tripal_get_chado_semweb_term('contact', 'description'),
-          ),
-          // Add in subfield mapping to Chado tables. This is used by the
-          // chado_field_storage for performing queries on sub element values.
-          // It should be a comma-separated list (no spacing) of the field names
-          // as foreign keys are followed starting from the Chado table to which
-          // this field maps.
-          'chado_mapping' => array(
-            'type' => 'type_id,name',
-            'name' => 'contact_id,name',
-            'description' => 'contact_id,name'
-          ),
-          'chado-' . $field_table . '__' . $pkey => $contact_linker->$pkey,
-          'chado-' . $field_table . '__' . $fkey_lcolumn => $contact_linker->$fkey_lcolumn->$fkey_lcolumn,
-          'chado-' . $field_table . '__' . 'contact_id' => $contact->contact_id
-        );
-
-        if (property_exists($contact, 'entity_id')) {
-          $entity->{$field_name}['und'][$i]['value']['entity'] = 'TripalEntity:' . $contact->entity_id;
-        }
-      }
-    }
-  }
-}
-
-/**
- * An Ajax callback for the pub widget.
- */
-function chado_linker__contact_widget_form_ajax_callback($form, $form_state) {
-
-  $field_name = $form_state['triggering_element']['#parents'][0];
-  $delta = $form_state['triggering_element']['#parents'][2];
-
-  return $form[$field_name]['und'][$delta];
-}
-/**
- * Theme function for the pub widget.
- *
- * @param $variables
- */
-function theme_chado_linker__contact_widget($variables) {
-  $element = $variables['element'];
-
-  // These two fields were added to the widget to help identify the fields
-  // for layout.
-  $table_name = $element['#table_name'];
-  $fkey = $element['#fkey_field'];
-
-  $layout = "
-      <div class=\"pub-widget\">
-        <div class=\"pub-widget-item\">" .
-        drupal_render($element['name']) . "
-        </div>
-      </div>
-    ";
-
-  return $layout;
-}

+ 0 - 370
tripal_chado/includes/TripalFields.old/chado_linker__cvterm.inc

@@ -1,370 +0,0 @@
-<?php
-
-class chado_linker__cvterm extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Annotations';
-
-  // The default description for this field.
-  public static $default_description = 'This record can be annotated with terms
-            from other vocabularies.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    $headers = array('Term', 'Definition', 'Is Not', 'Reference');
-    $rows = array();
-
-    $chado_table = $this->instance['settings']['chado_table'];
-    foreach ($items as $delta => $item) {
-      if ($item['chado-' . $chado_table . '__cvterm_id']) {
-        $cvterm = chado_generate_var('cvterm', array('cvterm_id' => $item['chado-' . $chado_table . '__cvterm_id']));
-        $dbxref = $cvterm->dbxref_id;
-
-        // Build the accession.
-        $accession = $dbxref->db_id->name . ':' . $dbxref->accession;
-        if ($dbxref->db_id->urlprefix) {
-          $accession = l($accession, tripal_get_dbxref_url($dbxref), array('attributes' => array('target' => '_blank')));
-        }
-
-        // Build the publication reference.
-        $pub_ref = '';
-        $pub_id = $item['chado-' . $chado_table . '__pub_id'];
-        if ($pub_id) {
-          $pub = chado_generate_var('pub', array('pub_id' => $pub_id));
-          $pub_ref = $pub->title;
-        }
-        $rows[] = array(
-          $accession,
-          $cvterm->definition,
-          $item['chado-' . $chado_table . '__is_not'] ? 'Yes' : '',
-          '',
-        );
-      }
-    }
-
-    // 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' => "$chado_table-table-terms",
-        'class' => 'tripal-data-table'
-      ),
-      'caption' => '',
-      'sticky' => FALSE,
-      'colgroups' => array(),
-      'empty' => 'There are no annotations of this type',
-    );
-
-    if (count($items) > 0) {
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => theme_table($table),
-      );
-    }
-  }
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $field_name = $this->field['field_name'];
-
-    $matches = array();
-    preg_match('/(.*?)__(\d+)/', $field_name, $matches);
-    // If the field name is not properly formatted then we can't tell what
-    // table and type this is.  So just return.
-    if (count($matches) != 3) {
-      return $widget;
-    }
-    $table_name = $matches[1];
-    $cv_id = $matches[2];
-
-    // Get the FK column that links to the base table.
-    $chado_table = $this->instance['settings']['chado_table'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($chado_table);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-
-    // Get the field defaults.
-    $record_id = '';
-    $fkey_value = $element['#entity']->chado_record_id;
-    $cvterm_name = '';
-    $cvterm_id = '';
-    $pub_id = '';
-    $uname = '';
-    $is_not = '';
-    $cvterm = NULL;
-
-    // If the field already has a value then it will come through the $items
-    // array.  This happens when editing an existing record.
-    if (array_key_exists($delta, $items)) {
-      $record_id = $items[$delta]['value'];
-      $cvterm_name = $items[$delta]['cvterm__name'];
-      $pub_id =$items[$delta]['chado-' . $table_name . '__pub_id'];
-      if ($pub_id && $pub_id != 1) {
-        $pub = chado_generate_var('pub', array('pub_id' => $pub_id));
-        $uname = $pub->uniquename;
-      }
-      $is_not = $items[$delta]['chado-' . $table_name . '__is_not'];
-      $cvterm_id = $items[$delta]['chado-' . $table_name . '__cvterm_id'];
-    }
-
-    // Check $form_state['values'] to see if an AJAX call set the values.
-    if (array_key_exists('values', $form_state) and array_key_exists($delta, $form_state['values'])) {
-      // See example in chado_linker_contact.inc
-//       $record_id = tripal_chado_get_field_form_values($table_name, $form_state, $delta, $table_name);
-//       $fkey_value = tripal_chado_get_field_form_values($table_name, $form_state, $delta, $table_name . '__' . $fkey);
-//       $is_not = tripal_chado_get_field_form_values($table_name, $form_state, $delta, $table_name . '__is_not');
-//       $cvterm_name = tripal_chado_get_field_form_values($table_name, $form_state, $delta, $table_name . '--cvterm__name');
-    }
-
-    if ($cvterm_name) {
-      $cvterm = chado_generate_var('cvterm', array('cv_id' => $cv_id, 'name' => $cvterm_name));
-    }
-
-    $schema = chado_get_schema('cvterm');
-    $options = tripal_get_cv_select_options();
-
-    $widget['#table_name'] = $chado_table;
-    $widget['#fkey_field'] = $fkey;
-    $widget['#theme'] = 'chado_linker__cvterm_widget';
-    $widget['#prefix'] =  "<span id='$table_name-$delta'>";
-    $widget['#suffix'] =  "</span>";
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-
-    $widget['chado-' . $table_name . '__' . $pkey] = array(
-      '#type' => 'value',
-      '#default_value' => $record_id,
-    );
-    $widget['cv__cv_id'] = array(
-      '#type' => 'value',
-      '#default_value' => $cv_id,
-    );
-    $widget['chado-' . $table_name . '__cvterm_id'] = array(
-      '#type' => 'value',
-      '#default_value' => $cvterm ? $cvterm->cvterm_id : '',
-    );
-    $widget['chado-' . $table_name . '__' . $fkey] = array(
-      '#type' => 'value',
-      '#default_value' => $fkey_value,
-    );
-
-    $widget['cvterm__name'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Term Name'),
-      '#default_value' => $cvterm_name,
-      '#required' => $element['#required'],
-      '#maxlength' => array_key_exists('length', $schema['fields']['name']) ? $schema['fields']['name']['length'] : 255,
-      '#autocomplete_path' => 'admin/tripal/storage/chado/auto_name/cvterm/' . $cv_id,
-      '#size' => 30
-    );
-
-    $widget['pub'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Publication'),
-      '#default_value' => $uname,
-      '#autocomplete_path' => 'admin/tripal/storage/chado/auto_name/pub',
-      '#ajax' => array(
-        'callback' => "chado_linker__pub_widget_form_ajax_callback",
-        'wrapper' => "$table_name-$delta",
-        'effect' => 'fade',
-        'method' => 'replace'
-      ),
-      '#maxlength' => 100000,
-    );
-
-    $widget['chado-' . $table_name . '__pub_id'] = array(
-      '#type' => 'value',
-      '#default_value' => $pub_id ? $pub_id : 1,
-    );
-
-    $widget['chado-' . $table_name . '__is_not'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Is Not'),
-      '#default_value' => $is_not,
-      '#required' => $element['#required'],
-    );
-
-    $widget['cvterm__definition'] = array(
-      '#type' => 'item',
-      '#markup' => '',
-    );
-
-  }
-
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-
-    $field_name = $this->field['field_name'];
-    $table_name = $this->instance['settings']['chado_table'];
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $base_table = $this->instance['settings']['base_table'];
-    $lfkey_field = key($schema['foreign keys'][$base_table]['columns']);
-    $rfkey_field = $schema['foreign keys'][$base_table]['columns'][$lfkey_field];
-
-
-    // If the form ID is field_ui_field_edit_form, then the user is editing the
-    // field's values in the manage fields form of Drupal.  We don't want
-    // to validate it as if it were being used in a data entry form.
-    if ($form_state['build_info']['form_id'] =='field_ui_field_edit_form') {
-      return;
-    }
-
-    // If the user provided a cv_id and a name then we want to set the
-    // foreign key value to be the chado_record_idd
-    $cvterm_name = isset($form_state['values'][$field_name][$langcode][$delta]['cvterm__name']) ? $form_state['values'][$field_name][$langcode][$delta]['cvterm__name'] : '';
-
-    if (!$cvterm_name) {
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__cvterm_id'] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $lfkey_field] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] = '';
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $base_table = $this->instance['settings']['base_table'];
-
-    $matches = array();
-    preg_match('/(.*?)__(\d+)/', $field_name, $matches);
-    $table_name = $matches[1];
-    $cv_id = $matches[2];
-
-    // Get the FK that links to the base record.
-    $schema = chado_get_schema($field_table);
-    $pkey = $schema['primary key'][0];
-    $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
-    $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
-
-    // Set some defaults for the empty record.
-    $chado_record = $entity->chado_record;
-    $entity->{$field_name}['und'][0] = array(
-      'value' => '',
-      'chado-' . $field_table . '__' . $fkey_lcolumn => '',
-      'chado-' . $field_table . '__' . 'cvterm_id' => '',
-      // The pub column is present in the cell_line_cvterm, feature_cvterm,
-      // library_cvterm, phenotype_comparision_cvterm, phenotype_cvterm,
-      // stock_cvterm, and stock_relationship_cvterm.
-      'chado-' . $field_table . '__' . 'pub_id' => '',
-      // The is_not column is present in feature_cvterm and stock_cvterm tables.
-      'chado-' . $field_table . '__' . 'is_not' => '',
-      // The rank column is present in the cell_line_cvterm, expression_cvterm,
-      // feature_cvterm, phenotype_comparision_cvterm, phenotype_cvterm,
-      // and stock_cvterm tables.
-      'chado-' . $field_table . '__' . 'rank' => '',
-      // The cvterm_type_id is present in the expression_cvterm table.
-      'cvterm_type_id' => '',
-      // The following field are to help link the cvterm.
-      'cv__cv_id' => '',
-      'cvterm__name' => '',
-    );
-
-    // Get the annotations associated with this base record for this fields type.
-    $columns = array('*');
-    $match = array(
-      $fkey_lcolumn => $chado_record->$fkey_rcolumn,
-      'cvterm_id' => array(
-        'cv_id' => $cv_id,
-      ),
-    );
-    $options = array(
-      'return_array' => TRUE,
-      'order_by' => array('rank' => 'ASC')
-    );
-    $fcvterms = chado_select_record($field_table, $columns, $match, $options);
-    for ($i = 0; $i < count($fcvterms); $i++) {
-      $linker = $fcvterms[$i];
-      $cvterm = chado_generate_var('cvterm', array('cvterm_id' => $linker->cvterm_id));
-      $entity->{$field_name}['und'][$i] = array(
-        'value' => $linker->$pkey,
-        'chado-' . $field_table . '__' . $fkey_lcolumn => $linker->$fkey_lcolumn,
-        'chado-' . $field_table . '__' . 'cvterm_id' => $linker->cvterm_id,
-        'chado-' . $field_table . '__' . 'pub_id' => property_exists($linker, 'pub_id') ? $linker->pub_id : '',
-        'chado-' . $field_table . '__' . 'is_not' => property_exists($linker, 'is_not') ? $linker->is_not : '',
-        'chado-' . $field_table . '__' . 'rank' => property_exists($linker, 'rank') ? $linker->rank : '',
-        'chado-' . $field_table . '__' . 'cvterm_type_id' => property_exists($linker, 'cvterm_type_id') ? $linker->cvterm_type_id : '',
-        'cv__cv_id' => $cvterm->cv_id->cv_id,
-        'cvterm__name' => $cvterm->name,
-      );
-    }
-  }
-}
-
-/**
- * Theme function for the dbxref_id_widget.
- *
- * @param $variables
- */
-function theme_chado_linker__cvterm_widget($variables) {
-  $element = $variables['element'];
-
-  // These two fields were added to the widget to help identify the fields
-  // for layout.
-  $table_name = $element['#table_name'];
-  $fkey = $element['#fkey_field'];
-
-  $layout = "
-      <div class=\"annotation-cvterm-widget\">
-        <div class=\"annotation-cvterm-widget-item\">" .
-        drupal_render($element['cv__cv_id']) . "
-        </div>
-        <div class=\"annotation-cvterm-widget-item\">" .
-        drupal_render($element['cvterm__name']) . "
-        </div>
-        <div class=\"annotation-cvterm-widget-item\">" .
-        drupal_render($element['pub']) . "
-        </div>
-        <div class=\"annotation-cvterm-widget-item\">" .
-        drupal_render($element['chado-' . $table_name . '__is_not']) . "
-        </div>
-      </div>
-    ";
-
-  return $layout;
-}
-
-/**
- * An Ajax callback for the dbxref widget.
- */
-function chado_linker__cvterm_widget_form_ajax_callback($form, $form_state) {
-
-  $field_name = $form_state['triggering_element']['#parents'][0];
-  $delta = $form_state['triggering_element']['#parents'][2];
-
-
-  return $form[$field_name]['und'][$delta];
-}

+ 0 - 197
tripal_chado/includes/TripalFields.old/chado_linker__cvterm_adder.inc

@@ -1,197 +0,0 @@
-<?php
-class chado_linker__cvterm_adder extends TripalField {
-
-  // The default lable for this field.
-  public static $default_label = 'Add an Annotation Type';
-
-  // The default description for this field.
-  public static $default_description = 'This record may have any number of types of
-        annotations. Use this field to first add the type.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-    // This field should never be viewed. It's to help add new cvterms
-    // when editing an entity.  So return nothing.
-    return '';
-  }
-
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-
-    // This field has no value field.  Just a fieldset for adding new annotation types.
-    $widget['#type'] = 'fieldset';
-    $widget['#title'] = $element['#title'];
-    $widget['#description'] = $element['#description'];
-    $widget['#group'] = 'entity_form_vtabs';
-
-    $widget['cvterm_class_adder_instructions'] = array(
-      '#type' => 'item',
-      '#markup' => t('You may add annotation types to this form by
-          providing a vocabulary name in the field above
-          and clicking the "Add Annotation Type" button.  This will add a
-          new field to the form above for the vocabulary you entered which
-          will allow users to associate terms from that vocabulary to
-          this record.'),
-    );
-
-    $options = tripal_get_cv_select_options();
-    $widget['value'] = array(
-      '#type' => 'select',
-      '#title' => t('Vocabulary'),
-      '#options' => $options,
-      '#description' => t("Please enter the vocabulary that contains terms
-          you want to allow users to use for annotations."),
-    );
-
-    //    $widget['#element_validate'] = array('chado_linker__cvterm_adder_widget_validate');
-
-    // When this button is clicked, the form will be validated and submitted.
-    // Therefore, we set custom submit and validate functions to override the
-    // default form submit.  In the validate function we set the form_state
-    // to rebuild the form so the submit function never actually gets called,
-    // but we need it or Drupal will run the default validate anyway.
-    // we also set #limit_validation_errors to empty so fields that
-    // are required that don't have values won't generate warnings.
-    $widget['cvterm_class_adder_button'] = array(
-      '#value' => t('Add Annotation Type'),
-      '#type' => 'submit',
-      '#name' => 'cvterm_class_adder_button',
-//      '#submit' => array('chado_linker__cvterm_adder_widget_submit'),
-      '#limit_validation_errors' => array(array($this->field['field_name'])),
-    );
-  }
-
-  /**
-   * @see TripalField::widgetFormValidate()
-   */
-  public function widgetFormValidate($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-
-    if (array_key_exists('triggering_element', $form_state) and
-        $form_state['triggering_element']['#name'] == 'cvterm_class_adder_button') {
-          $this_field = $this->field;
-          $field_name = $this_field['field_name'];
-          $bundle = $entity->bundle;
-
-          // Get the base table name from the field annotations.
-          $base_table = $entity->chado_table;
-          $cvterm_class_adder = $form_state['values'][$base_table . '_cvterm'][$langcode][$delta]['value'];
-          $cv = chado_generate_var('cv', array('cv_id' => $cvterm_class_adder));
-
-          // Make sure a valid vocabulary is selected
-          if (!$cv) {
-            form_set_error("$field_name][$langcode][$delta][value", "Please select a vocabulary.");
-          }
-          else {
-            // Make sure this vocabulary doesn't already have a field
-            if (key_exists($field_name . '__' . $cv->cv_id, $form_state['values'])) {
-              form_set_error("$field_name][$langcode][$delta][wrapper][terms_name", "Field for this vocabulary already exists. Please select another vocabulary.");
-            }
-          }
-        }
-  }
-
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-
-    // Add the new field to the entity
-    if (array_key_exists('triggering_element', $form_state) and
-        $form_state['triggering_element']['#name'] == 'cvterm_class_adder_button') {
-
-          $form_state['rebuild'] = TRUE;
-          $this_field = $this->field;
-          $field_name = $this_field['field_name'];
-          $bundle = $entity->bundle;
-
-          // Get the base table name from the field annotations.
-          $base_table = $entity->chado_table;
-          $cvterm_class_adder = $form_state['values'][$base_table . '_cvterm'][$langcode][$delta]['value'];
-
-          // Get the vocabulary.
-          //$cvterm_class_adder = tripal_chado_get_field_form_values($field_name, $form_state);
-          $cv = chado_generate_var('cv', array('cv_id' => $cvterm_class_adder));
-
-          if (!$cv) {
-            return;
-          }
-
-          $type_field_name = $field_name . '__' . $cv->cv_id;
-
-          // The field name is the table name in this case. We want to get the
-          // primary key as this should be the field that maps th the value.
-          $schema = chado_get_schema($field_name);
-          $pkey = $schema['primary key'][0];
-
-          // Add the field if it doesn't already exists.
-          $field = field_info_field($type_field_name);
-          if (!$field) {
-            $create_info = array(
-              'field_name' => $type_field_name,
-              'type' => 'chado_linker__cvterm',
-              'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-              'locked' => FALSE,
-              'storage' => array(
-                'type' => 'field_chado_storage',
-              ),
-              'settings' => array(
-                'chado_table' => $field_name,
-                'chado_column' => $pkey,
-                'base_table' => $base_table,
-              ),
-            );
-            $field = field_create_field($create_info);
-          }
-
-          // Attach the field to the bundle if it isn't already.
-          if (!$field or !array_key_exists('bundles', $field) or
-              !array_key_exists('TripalEntity', $field['bundles']) or
-              !in_array($bundle, $field['bundles']['TripalEntity'])) {
-                $createInstanceInfo = array(
-                  'field_name' => $type_field_name,
-                  'entity_type' => 'TripalEntity',
-                  'bundle' => $bundle,
-                  'label' => ucfirst(preg_replace('/_/', ' ', $cv->name)),
-                  'description' => "Annotations from the $cv->name vocabulary",
-                  'required' => FALSE,
-                  'settings' => array(),
-                  'widget' => array(
-                    'type' => 'chado_linker__cvterm_widget',
-                    'settings' => array(
-                      'display_label' => 1,
-                    ),
-                  ),
-                  'display' => array(
-                    'default' => array(
-                      'label' => 'above',
-                      'type' => 'chado_linker__cvterm_formatter',
-                      'settings' => array(),
-                    ),
-                  ),
-                );
-                $instance = field_create_instance($createInstanceInfo);
-              }
-        }
-  }
-
-}

+ 0 - 418
tripal_chado/includes/TripalFields.old/chado_linker__dbxref.inc

@@ -1,418 +0,0 @@
-<?php
-
-/**
- * This class provides fields for adding database cross-references.
- *
- * It supports two types of cross-references. The primary cross reference
- * which is usually in the base table as an FK to the dbxref table, and
- * secondary cross references which are in a linking table that connects
- * the base table with the dbxref table.
- *
- */
-class chado_linker__dbxref extends TripalField {
-
-  // The default lable for this field.
-  public static $default_label = 'Cross references';
-
-  // The default description for this field.
-  public static $default_description = 'This record can be cross referenced with a record in
-          another online database. This field is intended for one or more
-          references.  At a minimum, the database and accession must be provided.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    $chado_table = $this->instance['settings']['chado_table'];
-    $content = '';
-    foreach ($items as $delta => $item) {
-      if (!$item['value']) {
-        continue;
-      }
-      $content = $item['value']['vocabulary'] . ':' . $item['value']['accession'];
-      if ($item['value']['URL']) {
-        $content = l($content, $item['value']['URL'], array('attributes' => array('target' => '_blank')));
-      }
-      $element[$delta] = array(
-        '#type' => 'markup',
-        '#markup' => $content,
-      );
-    }
-
-    if (count($element) == 0) {
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => '',
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the FK column that links to the base table.
-    $chado_table = $this->instance['settings']['chado_table'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($chado_table);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-
-    // Get the field defaults.
-    $record_id = '';
-    $fkey_value = $element['#entity']->chado_record_id;
-    $dbxref_id = '';
-    $db_id = '';
-    $accession = '';
-    $version = '';
-    $description = '';
-
-    // If the field already has a value then it will come through the $items
-    // array.  This happens when editing an existing record.
-    if (count($items) > 0 and array_key_exists($delta, $items)) {
-      $record_id = tripal_get_field_item_keyval($items, $delta, 'chado-' . $field_table . '__' . $pkey, $record_id);
-      $fkey_value = tripal_get_field_item_keyval($items, $delta, 'chado-' . $field_table . '__' . $fkey, $fkey_value);
-      $dbxref_id = tripal_get_field_item_keyval($items, $delta, 'chado-' . $field_table . '__dbxref_id', $dbxref_id);
-      $db_id = tripal_get_field_item_keyval($items, $delta, 'db_id', $db_id);
-      $accession = tripal_get_field_item_keyval($items, $delta, 'accession', $accession);
-      $version = tripal_get_field_item_keyval($items, $delta, 'version', $version);
-      $description = tripal_get_field_item_keyval($items, $delta, 'description', $description);
-    }
-
-    // Check $form_state['values'] to see if an AJAX call set the values.
-    if (array_key_exists('values', $form_state) and array_key_exists($delta, $form_state['values'])) {
-      $record_id = $form_state['values'][$field_name]['und'][$delta][$field_table . '__' . $pkey];
-      $fkey_value = $form_state['values'][$field_name]['und'][$delta][$field_table . '__' . $fkey];
-      $dbxref_id = $form_state['values'][$field_name]['und'][$delta][$field_table . '__dbxref_id'];
-      $db_id = $form_state['values'][$field_name]['und'][$delta]['db_id'];
-      $accession = $form_state['values'][$field_name]['und'][$delta]['accession'];
-      $version = $form_state['values'][$field_name]['und'][$delta]['version'];
-      $description = $form_state['values'][$field_name]['und'][$delta]['description'];
-    }
-
-    $schema = chado_get_schema('dbxref');
-    $options = tripal_get_db_select_options();
-
-    $widget['#table_name'] = $chado_table;
-    $widget['#fkey_field'] = $fkey;
-    //$widget['#element_validate'] = array('chado_linker__dbxref_widget_validate');
-    $widget['#theme'] = 'chado_linker__dbxref_widget';
-    $widget['#prefix'] =  "<span id='$field_name-dbxref--db-id-$delta'>";
-    $widget['#suffix'] =  "</span>";
-
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-
-    $widget['chado-' . $field_table . '__' . $pkey] = array(
-      '#type' => 'value',
-      '#default_value' => $record_id,
-    );
-    $widget['chado-' . $field_table . '__' . $fkey] = array(
-      '#type' => 'value',
-      '#default_value' => $fkey_value,
-    );
-    $widget['chado-' . $field_table . '__dbxref_id'] = array(
-      '#type' => 'value',
-      '#default_value' => $dbxref_id,
-    );
-    $widget['dbxref_id'] = array(
-      '#type' => 'value',
-      '#default_value' => $dbxref_id,
-    );
-    $widget['db_id'] = array(
-      '#type' => 'select',
-      '#title' => t('Database'),
-      '#options' => $options,
-      '#required' => $element['#required'],
-      '#default_value' => $db_id,
-      '#ajax' => array(
-        'callback' => "chado_linker__dbxref_widget_form_ajax_callback",
-        'wrapper' => "$field_name-dbxref--db-id-$delta",
-        'effect' => 'fade',
-        'method' => 'replace'
-      ),
-    );
-    $widget['accession'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Accession'),
-      '#default_value' => $accession,
-      '#required' => $element['#required'],
-      '#maxlength' => array_key_exists('length', $schema['fields']['accession']) ? $schema['fields']['accession']['length'] : 255,
-      '#size' => 15,
-      '#autocomplete_path' => 'admin/tripal/storage/chado/auto_name/dbxref/' . $db_id,
-      '#ajax' => array(
-        'callback' => "chado_linker__dbxref_widget_form_ajax_callback",
-        'wrapper' => "$field_name-dbxref--db-id-$delta",
-        'effect' => 'fade',
-        'method' => 'replace'
-      ),
-      '#disabled' => $db_id ? FALSE : TRUE,
-    );
-    $widget['version'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Version'),
-      '#default_value' => $version,
-      '#maxlength' => array_key_exists('length', $schema['fields']['version']) ? $schema['fields']['version']['length'] : 255,
-      '#size' => 5,
-      '#disabled' => $db_id ? FALSE : TRUE,
-    );
-    $widget['description'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Description'),
-      '#default_value' => $description,
-      '#size' => 20,
-      '#disabled' => $db_id ? FALSE : TRUE,
-    );
-    if (!$db_id) {
-      $widget['links'] = array(
-        '#type' => 'item',
-        '#markup' => l('Add a database', 'admin/tripal/legacy/tripal_db/add', array('attributes' => array('target' => '_blank')))
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::validate()
-   */
-  public function validate($entity_type, $entity, $field, $items, &$errors) {
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $table_name = $this->instance['settings']['chado_table'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-
-
-    // Get the field values.
-    foreach ($items as $delta => $values) {
-
-      // Get the field values.
-      $dbxref_id = $values['chado-' . $field_table . '__dbxref_id'];
-      $db_id = $values['db_id'];
-      $accession = $values['accession'];
-      $version = $values['version'];
-      $description = $values['description'];
-
-      // Make sure that if a database ID is provided that an accession is also
-      // provided.  Here we use the form_set_error function rather than the
-      // form_error function because the form_error will add a red_highlight
-      // around all of the fields in the fieldset which is confusing as it's not
-      // clear to the user what field is required and which isn't. Therefore,
-      // we borrow the code from the 'form_error' function and append the field
-      // so that the proper field is highlighted on error.
-      if (!$db_id and $accession) {
-        $errors[$field_name][$delta]['und'][] = array(
-          'message' => t("A database and the accession must both be provided."),
-          'error' => 'chado_linker__dbxref',
-        );
-      }
-      if ($db_id and !$accession) {
-        $errors[$field_name][$delta]['und'][] = array(
-          'message' => t("A database and the accession must both be provided."),
-          'error' => 'chado_linker__dbxref',
-        );
-      }
-      if (!$db_id and !$accession and ($version or $description)) {
-        $errors[$field_name][$delta]['und'][] = array(
-          'message' => t("A database and the accession must both be provided."),
-          'error' => 'chado_linker__dbxref',
-        );
-      }
-    }
-  }
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $table_name = $this->instance['settings']['chado_table'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-
-    // Get the field values.
-    $dbxref_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__dbxref_id']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__dbxref_id'] : '';
-    $db_id = isset($form_state['values'][$field_name][$langcode][$delta]['db_id']) ? $form_state['values'][$field_name][$langcode][$delta]['db_id'] : '';
-    $accession = isset($form_state['values'][$field_name][$langcode][$delta]['accession']) ? $form_state['values'][$field_name][$langcode][$delta]['accession'] : '';
-    $version = isset($form_state['values'][$field_name][$langcode][$delta]['version']) ? $form_state['values'][$field_name][$langcode][$delta]['version'] : '';
-    $description = isset($form_state['values'][$field_name][$langcode][$delta]['description']) ? $form_state['values'][$field_name][$langcode][$delta]['description'] : '';
-
-    // If the dbxref_id does not match the db_id + accession then the user
-    // has selected a new dbxref record and we need to update the hidden
-    // value accordingly.
-    if ($db_id and $accession) {
-      $dbxref = chado_generate_var('dbxref', array('db_id' => $db_id, 'accession' => $accession));
-      if ($dbxref and $dbxref->dbxref_id != $dbxref_id) {
-        $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__dbxref_id'] = $dbxref->dbxref_id;
-        $form_state['values'][$field_name][$langcode][$delta]['dbxref_id'] = $dbxref->dbxref_id;
-      }
-    }
-    // If the db_id and accession are not set, then remove the linker FK
-    // value to the base table, but leave the primary key so the record
-    // can be deleted.
-    else {
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__dbxref_id'] = '';
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $record = $details['record'];
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $base_table = $record->tablename;
-
-    $schema = chado_get_schema($field_table);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(),
-      'chado-' . $field_table . '__' . $pkey => '',
-      'chado-' . $field_table . '__' . $fkey => '',
-      'chado-' . $field_table . '__dbxref_id' => '',
-      'dbxref_id' => '',
-      'db_id' => '',
-      'accession' => '',
-      'version' => '',
-      'description' => '',
-    );
-
-    $linker_table = $base_table . '_dbxref';
-    $options = array('return_array' => 1);
-    $record = chado_expand_var($record, 'table', $linker_table, $options);
-    if (count($record->$linker_table) > 0) {
-      $i = 0;
-      foreach ($record->$linker_table as $index => $linker) {
-        $dbxref = $linker->dbxref_id;
-        $URL = tripal_get_dbxref_url($dbxref);
-        $entity->{$field_name}['und'][$i] = array(
-          'value' => array(
-            'vocabulary' => $dbxref->db_id->name,
-            'accession' => $dbxref->accession,
-            'URL' => $URL,
-          ),
-          'chado-' . $field_table . '__' . $pkey => $linker->$pkey,
-          'chado-' . $field_table . '__' . $fkey => $linker->$fkey->$fkey,
-          'chado-' . $field_table . '__dbxref_id' => $dbxref->dbxref_id,
-          'dbxref_id' => $dbxref->dbxref_id,
-          'db_id' => $dbxref->db_id->db_id,
-          'accession' => $dbxref->accession,
-          'version' => $dbxref->version,
-          'description' => $dbxref->description,
-        );
-        $i++;
-      }
-    }
-  }
-}
-/**
- * Theme function for the dbxref_id_widget.
- *
- * @param $variables
- */
-function theme_chado_linker__dbxref_widget($variables) {
-  $element = $variables['element'];
-
-  // These two fields were added to the widget to help identify the fields
-  // for layout.
-  $table_name = $element['#table_name'];
-  $fkey = $element['#fkey_field'];
-
-  $layout = "
-      <div class=\"secondary-dbxref-widget\">
-        <div class=\"secondary-dbxref-widget-item\">" .
-        drupal_render($element['db_id']) . "
-        </div>
-        <div class=\"secondary-dbxref-widget-item\">" .
-        drupal_render($element['accession']) . "
-        </div>
-        <div class=\"secondary-dbxref-widget-item\">" .
-        drupal_render($element['version']) . "
-        </div>
-        <div class=\"secondary-dbxref-widget-item\">" .
-        drupal_render($element['description']) . "
-        </div>
-        <div class=\"secondary-dbxref-widget-links\">" . drupal_render($element['links']) . "</div>
-      </div>
-    ";
-
-  return $layout;
-}
-
-/**
- * An Ajax callback for the dbxref widget.
- */
-function chado_linker__dbxref_widget_form_ajax_callback($form, $form_state) {
-
-  $field_name = $form_state['triggering_element']['#parents'][0];
-  $delta = $form_state['triggering_element']['#parents'][2];
-  $field = field_info_field($field_name);
-  $field_type = $field['type'];
-  $field_table = $field['settings']['chado_table'];
-  $field_column = $field['settings']['chado_column'];
-  $field_prefix = 'chado-' . $field_table . '__dbxref_id';
-
-  // Check to see if this dbxref already exists. If not then
-  // give a notice to the user that the dbxref will be added.
-  $db_id = $form_state['values'][$field_name]['und'][$delta]['db_id'];
-  $db_id = $form_state['values'][$field_name]['und'][$delta]['accession'];
-  if ($db_id and $accession) {
-    $values = array(
-      'db_id' => $db_id,
-      'accession' => $accession,
-    );
-    $options = array('is_duplicate' => TRUE);
-    $has_duplicate = chado_select_record('dbxref', array('*'), $values, $options);
-    if (!$has_duplicate) {
-      drupal_set_message('The selected cross reference is new and will be added for future auto completions.');
-    }
-  }
-
-  return $form[$field_name]['und'][$delta];
-}

+ 0 - 184
tripal_chado/includes/TripalFields.old/chado_linker__expression.inc

@@ -1,184 +0,0 @@
-<?php
-
-class chado_linker__expression extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Expression';
-
-  // The default description for this field.
-  public static $default_description = 'Associates an expression with
-          this record.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    // Get the settings
-    $settings = $display['settings'];
-
-    $content = '';
-    $rows = array();
-    foreach ($items as $delta => $item) {
-      if (!$item['value']) {
-        continue;
-      }
-      // Iterate through all of the children of the $item['value']. Add each
-      // one as an independent row in the table.
-
-      foreach ($item['value'] as $key => $value) {
-
-        // If this key is the name, then we want to link to the entity if one
-        // exists.
-        if ($key == 'name') {
-          if (array_key_exists('entity', $item['value']) and $item['value']['$entity_id']) {
-            list($entity_type, $entity_id) = explode(':', $item['value']['entity']);
-            $value = l($value, "bio_data/" . $entity_id, array('attributes' => array('target' => "_blank")));
-          }
-        }
-        // If this key is the publication then we want to get the citation
-        // and link to the pub if an entity exits.
-        if ($key == 'publication') {
-          $pub = $value['Citation'];
-          if (array_key_exists('publication', $item) and array_key_exists('entity', $item['publication'][0])) {
-            $entity_id = $item['publication'][0]['entity_id'];
-            $title =  $item['value']['publication']['Title'];
-            $link = l($title, 'bio_data/' . $entity_id);
-            $pub = preg_replace("/$title/", $link, $pub);
-          }
-          $value = $pub;
-        }
-        // Add the item as a new row.
-        $rows[] = array(
-          array(
-            'data' => ucfirst(str_replace('_', ' ', $key)),
-            'header' => TRUE,
-            'width' => '20%',
-          ),
-          $value
-        );
-      }
-    }
-    $table = array(
-      'header' => array(),
-      'rows' => $rows,
-      'attributes' => array(
-        'id' => 'tripal_linker-table-expression-object',
-        'class' => 'tripal-data-table'
-      ),
-      'sticky' => FALSE,
-      'caption' => "",
-      'colgroups' => array(),
-      'empty' => 'There is no curated expression data.',
-    );
-    $content = theme_table($table);
-    if (count($items) > 0) {
-      // once we have our table array structure defined, we call Drupal's theme_table()
-      // function to generate the table.
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => $content,
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-    $record = $details['record'];
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the FK that links to the base record.
-    $schema = chado_get_schema($field_table);
-    $base_table = $details['record']->tablename;
-    $pkey = $schema['primary key'][0];
-    $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
-    $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(),
-    );
-
-    $linker_table = $base_table . '_expression';
-    $options = array(
-      'return_array' => 1,
-    );
-    $record = chado_expand_var($record, 'table', $linker_table, $options);
-    $exp_linkers = $record->$linker_table;
-    if ($exp_linkers) {
-      foreach ($exp_linkers as $i => $exp_linker) {
-
-        // Because the unqiuename is a text field we must expand it.
-        $expression = $exp_linker->expression_id;
-        $expression = chado_expand_var($expression, 'field', 'expression.uniquename', $options);
-
-        // Set the values that will be seen by the user on the page and in
-        // web services, or anwhere this field is viewed.
-        $entity->{$field_name}['und'][$i]['value'] = array(
-          'name' => $expression->uniquename,
-          'description' => $expression->description,
-          //'md5checksum' => $expression->md5checksum,
-        );
-
-        // Add the pub information if a real pub is associated with the record.
-        $pub = $exp_linker->pub_id;
-        if ($pub->uniquename != 'null') {
-          $pub_details = tripal_get_minimal_pub_info($pub);
-
-          $entity->{$field_name}['und'][$i]['value']['publication'] = $pub_details;
-          $entity->{$field_name}['und'][$i]['value']['publication']['type'] = $pub->type_id->name;
-          if (property_exists($pub, 'entity_id')) {
-            $entity->{$field_name}['und'][$i]['publication'][0]['value']['entity'] = 'TripalEntity:' . $pub->entity_id;
-          }
-        }
-
-        // Add the linker_expressionprop
-        $linkerprop_table =  $linker_table . 'prop';
-        if (chado_table_exists($linkerprop_table)) {
-          $exp_linker = chado_expand_var($exp_linker, 'table', $linkerprop_table, $options);
-          $exp_linkerprops = $exp_linker->feature_expressionprop;
-          if ($exp_linkerprops) {
-            foreach ($exp_linkerprops AS $linkerprop) {
-              $entity->{$field_name}['und'][$i]['value'][$linkerprop->type_id->name] = $linkerprop->value;
-            }
-          }
-        }
-        // Add the fields for the widget form.  The name requres the following
-        // format if the fields should be used as values for insertint/updating
-        // into the chado table:  [table_name]__[field_name]
-        $entity->{$field_name}['und'][$i][$linker_table . '__expression_id'] = $expression->expression_id;
-        $entity->{$field_name}['und'][$i][$linker_table . '__uniquename'] = $expression->uniquename;
-        //$entity->{$field_name}['und'][$i][$linker_table . '__md5checksum'] = $expression->md5checksum;
-        $entity->{$field_name}['und'][$i][$linker_table . '__description'] = $expression->description;
-
-      }
-    }
-  }
-
-  /**
-   * We don't want a widget so override this function.
-   */
-  public static function widgetInfo() {
-    return array();
-  }
-
-}

+ 0 - 306
tripal_chado/includes/TripalFields.old/chado_linker__featureloc.inc

@@ -1,306 +0,0 @@
-<?php
-
-class chado_linker__featureloc extends TripalField {
-
-  // The default lable for this field.
-  public static $default_label = 'Aligned Locations';
-
-  // The default description for this field.
-  public static $default_description = 'Locations on landmark sequences where the feature is aligned.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatter_settings_summary()
-   */
-  public function formatter_settings_summary($field, $instance,
-      $view_mode) {
-
-  }
-
-  /**
-   * @see TripalField::formatter_settings_form()
-   */
-  public function formatter_settings_form($field, $instance,
-      $view_mode, $form, &$form_state) {
-
-
-
-  }
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    // Get the settings
-    $settings = $display['settings'];
-
-    $rows = array();
-    $headers = array('Aligned Feature' ,'Feature Type', 'Alignment Location');
-
-    foreach ($items as $delta => $item) {
-      if (!$item['value']) {
-        continue;
-      }
-
-      $alignment = $item['value'];
-      $feature_name = $alignment['name'];
-      $feature_loc = '';
-      $strand = '.';
-      if ($alignment['strand'] == -1) {
-        $strand = '-';
-      }
-      elseif ($alignment['strand'] == 1) {
-         $strand = '+';
-      }
-      // if this is a match then make the other location
-      if(array_key_exists('right_feature', $alignment)){
-        $rstrand = '.';
-        if ($alignment['right_strand'] == -1) {
-          $rstrand = '-';
-        }
-        elseif ($alignment['right_strand'] == 1) {
-          $rstrand = '+';
-        }
-        $feature_loc = $feature['name'] .":". ($alignment['fmin'] + 1) . ".." . $alignment['fmax'] . " " . $strand;
-        $feature_loc .= "<br>" . $alignment['name'] .":". ($alignment['right_fmin'] + 1) . ".." . $alignment['right_fmax'] . " " . $rstrand;
-      }
-      else {
-        $feature_loc = $alignment['name'] .":". ($alignment['fmin'] + 1) . ".." . $alignment['fmax'] . " " . $strand;
-      }
-
-      $rows[] = array(
-        $feature_name,
-        $alignment['type'],
-        $feature_loc
-      );
-    }
-
-
-    // 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_feature-table-alignments',
-        'class' => 'tripal-data-table'
-      ),
-      'sticky' => FALSE,
-      'caption' => '',
-      'colgroups' => array(),
-      'empty' => 'This record is not aligned to any locations.',
-    );
-
-    // once we have our table array structure defined, we call Drupal's theme_table()
-    // function to generate the table.
-    if (count($items) > 0) {
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => theme_table($table),
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-    $record = $details['record'];
-    $settings = $this->field['settings'];
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(),
-    );
-
-    $options = array(
-      'return_array' => TRUE,
-      'include_fk' => array(
-        'srcfeature_id' => array(
-          'type_id' => 1,
-        ),
-        'feature_id' => array(
-          'type_id' => 1
-        ),
-      )
-    );
-    $feature = chado_expand_var($record, 'table', 'featureloc', $options);
-
-    // Get alignments as child
-    $cfeaturelocs = $feature->featureloc->feature_id;
-    if (!$cfeaturelocs) {
-      $cfeaturelocs = array();
-    }
-    // Get alignment as parent
-    $pfeaturelocs = $feature->featureloc->srcfeature_id;
-    if (!$pfeaturelocs) {
-      $pfeaturelocs = array();
-    }
-
-    // Get matched alignments (those with an itermediate 'match' or 'EST_match', etc
-    $mfeaturelocs = self::get_matched_alignments($feature);
-    $feature->matched_featurelocs = $mfeaturelocs;
-
-    // Combine all three alignments into a single array for printing together in
-    // a single list
-    $alignments = array();
-    foreach ($pfeaturelocs as $featureloc) {
-      // if type is a 'match' then ignore it. We will handle those below
-      if (preg_match('/(^match$|^.*?_match|match_part)$/', $featureloc->feature_id->type_id->name)) {
-        continue;
-      }
-      $alignments[] = array(
-        'name' => $featureloc->feature_id->name,
-        'type' => $featureloc->feature_id->type_id->name,
-        'fmin' => $featureloc->fmin,
-        'fmax' => $featureloc->fmax,
-        'phase' => $featureloc->phase,
-        'strand' => $featureloc->strand,
-      );
-    }
-    foreach ($cfeaturelocs as $featureloc) {
-      // if type is a 'match' then ignore it. We will handle those below
-      if (preg_match('/(^match$|^.*?_match|match_part)$/', $featureloc->feature_id->type_id->name)) {
-        continue;
-      }
-      $alignments[] = array(
-        'name' => $featureloc->srcfeature_id->name,
-        'type' => $featureloc->srcfeature_id->type_id->name,
-        'fmin' => $featureloc->fmin,
-        'is_fmin_partial' => $featureloc->is_fmin_partial,
-        'fmax' => $featureloc->fmax,
-        'is_fmax_partial' => $featureloc->is_fmax_partial,
-        'phase' => $featureloc->phase,
-        'strand' => $featureloc->strand,
-      );
-    }
-    // in matching features, the left feature is always the feature
-    // provided to this function.
-    foreach ($mfeaturelocs as $featureloc) {
-      // get more information about the right feature
-      $select = array('feature_id' => $featureloc->right_srcfeature_id);
-      $rfeature = chado_generate_var('feature', $select);
-      // now add to the list
-      $alignments[] = array(
-        'name' => $rfeature->name,
-        'type' => $rfeature->type_id->name,
-        'fmin' => $featureloc->left_fmin,
-        'is_fmin_partial' => $featureloc->left_is_fmin_partial,
-        'fmax' => $featureloc->left_fmax,
-        'is_fmax_partial' => $featureloc->left_is_fmax_partial,
-        'phase' => $featureloc->left_phase,
-        'strand' => $featureloc->left_strand,
-        'right_fmin' => $featureloc->right_fmin,
-        'right_is_fmin_partial' => $featureloc->right_is_fmin_partial,
-        'right_fmax' => $featureloc->right_fmax,
-        'right_is_fmax_partial' => $featureloc->right_is_fmax_partial,
-        'right_phase' => $featureloc->right_phase,
-        'right_strand' => $featureloc->right_strand,
-      );
-    }
-    $i = 0;
-    foreach ($alignments as $alignment) {
-      $entity->{$field_name}['und'][$i]['value'] = $alignment;
-      $i++;
-    }
-  }
-  /**
-   * This function is for features that align through an intermediate such
-   * as 'EST_match' or 'match'.  This occurs in the case where two sequences
-   * align but where one does not align perfectly.  Some ESTs may be in a contig
-   * but not all of the EST.  Portions may overhang and not be included in the
-   * consensus if quality is bad.
-   * For example:
-   *    Feature 1: Contig --------------------
-   *    Feature 2: EST_match           -------
-   *    Feature 3: EST                 ---------
-   *
-   * The feature provided to the function will always be the feature 1.  The
-   * featureloc columns prefixed with 'right' (e.g. right_fmin) belong to the
-   * alignment of feature 3 with feature 2
-   *
-   * Features may align to more than one feature and are not matches. We do
-   * not want to include these, so we have to filter on the SO terms:
-   * match, or %_match
-   *
-   * @ingroup tripal_feature
-   */
-   static public function get_matched_alignments($feature) {
-
-     $sql = "
-       SELECT
-         FL1.featureloc_id    as left_featureloc_id,
-         FL1.srcfeature_id    as left_srcfeature_id,
-         FL1.feature_id       as left_feature_id,
-         FL1.fmin             as left_fmin,
-         FL1.is_fmin_partial  as left_is_fmin_partial,
-         FL1.fmax             as left_fmax,
-         FL1.is_fmax_partial  as left_is_fmax_partial,
-         FL1.strand           as left_strand,
-         FL1.phase            as left_phase,
-         FL1.locgroup         as left_locgroup,
-         FL1.rank             as left_rank,
-         FL2.featureloc_id    as right_featureloc_id,
-         FL2.srcfeature_id    as right_srcfeature_id,
-         FL2.feature_id       as right_feature_id,
-         FL2.fmin             as right_fmin,
-         FL2.is_fmin_partial  as right_is_fmin_partial,
-         FL2.fmax             as right_fmax,
-         FL2.is_fmax_partial  as right_is_fmax_partial,
-         FL2.strand           as right_strand,
-         FL2.phase            as right_phase,
-         FL2.locgroup         as right_locgroup,
-         FL2.rank             as right_rank
-       FROM {feature} F1
-         INNER JOIN {featureloc} FL1 on FL1.srcfeature_id = F1.feature_id
-         INNER JOIN {feature} F2 on FL1.feature_id = F2.feature_id
-         INNER JOIN {featureloc} FL2 on FL2.feature_id = F2.feature_id
-         INNER JOIN {cvterm} CVT2 on F2.type_id = CVT2.cvterm_id
-       WHERE
-         F1.feature_id = :feature_id  AND
-         (CVT2.name = 'match' or CVT2.name like '%_match')
-       ORDER BY FL1.fmin
-     ";
-
-     $results = chado_query($sql, array(':feature_id' => $feature->feature_id));
-
-     // iterate through the results and add them to our featurelocs array
-     $featurelocs = array();
-     while ($fl = $results->fetchObject()) {
-       // ignore featurelocs where the left and right srcfeature is the same
-       if (strcmp($fl->left_srcfeature_id, $fl->right_srcfeature_id) == 0) {
-         continue;
-       }
-       $featurelocs[] = $fl ;
-     }
-     return $featurelocs;
-   }
-
-  /**
-   * We don't want a widget so override this function.
-   */
-  public static function widgetInfo() {
-    return array();
-  }
-
-}
-

+ 0 - 157
tripal_chado/includes/TripalFields.old/chado_linker__featurepos.inc

@@ -1,157 +0,0 @@
-<?php
-
-class chado_linker__featurepos extends TripalField {
-
-  // The default lable for this field.
-  public static $default_label = 'Map positions';
-
-  // The default description for this field.
-  public static $default_description = 'Map position of a sequence.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatter_settings_summary()
-   */
-  public function formatter_settings_summary($field, $instance,
-      $view_mode) {
-
-  }
-
-  /**
-   * @see TripalField::formatter_settings_form()
-   */
-  public function formatter_settings_form($field, $instance,
-      $view_mode, $form, &$form_state) {
-
-
-
-  }
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    // Get the settings
-    $settings = $display['settings'];
-
-    $rows = array();
-    $headers = array('Map', 'Mapped Feature', 'Position');
-
-    foreach ($items as $delta => $item) {
-      if (!$item['value']) {
-        continue;
-      }
-      $val = $item['value'];
-      $map_name = $val['map_name'];
-      $mapped_feature_name = $val['mapped_feature_name'];
-      $position = $val['position'];
-
-      $rows[] = array(
-        $map_name,
-        $mapped_feature_name,
-        $position
-      );
-    }
-
-
-    // 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_feature-table-map-positions',
-        'class' => 'tripal-data-table'
-      ),
-      'sticky' => FALSE,
-      'caption' => '',
-      'colgroups' => array(),
-      'empty' => 'This record is not found on any map.',
-    );
-
-    // once we have our table array structure defined, we call Drupal's theme_table()
-    // function to generate the table.
-    if (count($items) > 0) {
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => theme_table($table),
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-    $record = $details['record'];
-    $settings = $this->field['settings'];
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(),
-    );
-
-    $options = array(
-      'return_array' => TRUE,
-      'include_fk' => array(
-        'srcfeature_id' => array(
-          'type_id' => 1,
-        ),
-        'feature_id' => array(
-          'type_id' => 1
-        ),
-      )
-    );
-    $feature = chado_expand_var($record, 'table', 'featurepos', $options);
-
-    // iterate through the results and add them to our featureposes array
-    $featureposes = array();
-    if (isset($feature->featurepos->feature_id)) {
-       foreach ($feature->featurepos->feature_id AS $featurepos) {
-         $featuremap_id = $featurepos->featuremap_id;
-         $featuremap = chado_generate_var('featuremap', array('featuremap_id' => $featuremap_id));
-         $map_feature_id = $featurepos->map_feature_id;
-         $map_feature = chado_generate_var('feature', array('feature_id' => $map_feature_id));
-         $mappos = $featurepos->mappos;
-         $featureposes [] = array (
-           'map_name' => $featuremap->name,
-           'mapped_feature_name' => $map_feature->name,
-           'position' => $mappos
-         );
-      }
-    }
-    $i = 0;
-    foreach ($featureposes as $position) {
-      $entity->{$field_name}['und'][$i]['value'] = $position;
-      $i++;
-    }
-  }
-
-  /**
-   * We don't want a widget so override this function.
-   */
-  public static function widgetInfo() {
-    return array();
-  }
-
-}
-

+ 0 - 150
tripal_chado/includes/TripalFields.old/chado_linker__genotype.inc

@@ -1,150 +0,0 @@
-<?php
-
-class chado_linker__genotype extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Genotypes';
-
-  // The default description for this field.
-  public static $default_description = 'Associates an indviddual or organization with
-          this record.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    // Get the settings
-    $settings = $display['settings'];
-
-    $headers = array('Name', 'Description', 'Type');
-    $rows = array();
-
-    foreach ($items as $delta => $item) {
-      $genotype = $item['value'];
-      if (!$genotype) {
-        continue;
-      }
-
-      // Get the field values
-      $genotype_name = $genotype['name'];
-      $description = $genotype['description'];
-      $type = $genotype['type'];
-
-      // Add a link i there is an entity.
-      if (array_key_exists('entity', $item['value']) and $item['value']['entity']) {
-        list($entity_type, $entity_id) = explode(':', $item['value']['entity']);
-        $genotype_name = l($genotype_name, "bio_data/" . $entity_id, array('attributes' => array('target' => "_blank")));
-      }
-      $rows[] = array($genotype_name, $description, $type);
-    }
-
-    $table = array(
-      'header' => $headers,
-      'rows' => $rows,
-      'attributes' => array(
-        'id' => 'tripal_linker-table-genotype-object',
-        'class' => 'tripal-data-table'
-      ),
-      'sticky' => FALSE,
-      'caption' => "",
-      'colgroups' => array(),
-      'empty' => 'No genotypes available.',
-    );
-    $content = theme_table($table);
-    if (count($items) > 0) {
-      // once we have our table array structure defined, we call Drupal's theme_table()
-      // function to generate the table.
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => $content,
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-    $record = $details['record'];
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the FK that links to the base record.
-    $schema = chado_get_schema($field_table);
-    $base_table = $details['record']->tablename;
-    $pkey = $schema['primary key'][0];
-    $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
-    $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
-
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(),
-      $field_table . '__' . $pkey => '',
-      $field_table . '__' . $fkey_lcolumn => '',
-      $field_table . '__' . 'genotype_id' => '',
-      // Ignore the synonym_sgml column for now.
-    );
-
-    $linker_table = $base_table . '_genotype';
-    $options = array(
-      'return_array' => 1,
-      'include_fk' => array(
-        'genotype_id' => array(
-          'type_id' => array(
-            'dbxref_id' => array(
-              'db_id' => TRUE,
-            ),
-          ),
-        ),
-        $fkey_lcolumn => TRUE,
-      ),
-    );
-    $record = chado_expand_var($record, 'table', $linker_table, $options);
-    $genotype_linkers = $record->$linker_table->$fkey_rcolumn;
-    if ($genotype_linkers) {
-      foreach ($genotype_linkers as $i => $genotype_linker) {
-        $genotype = $genotype_linker->genotype_id;
-        $entity->{$field_name}['und'][$i] = array(
-          'value' => array(
-            '@type' => $genotype->type_id->dbxref_id->db_id->name . ':' . $genotype->type_id->dbxref_id->accession,
-            'type' => $genotype->type_id->name,
-            'name' => $genotype->name,
-            'description' => $genotype->description,
-          ),
-          $field_table . '__' . $pkey => $genotype_linker->$pkey,
-          $field_table . '__' . $fkey_lcolumn => $genotype_linker->$fkey_lcolumn->$fkey_lcolumn,
-          $field_table . '__' . 'genotype_id' => $genotype->genotype_id
-        );
-
-        if ($genotype && property_exists($genotype, 'entity_id')) {
-          $entity->{$field_name}['und'][$i]['value']['entity'] = 'TripalEntity:' . $genotype->entity_id;
-        }
-      }
-    }
-  }
-
-  /**
-   * We don't want a widget so override this function.
-   */
-  public static function widgetInfo() {
-    return array();
-  }
-
-}

+ 0 - 150
tripal_chado/includes/TripalFields.old/chado_linker__phenotype.inc

@@ -1,150 +0,0 @@
-<?php
-
-class chado_linker__phenotype extends TripalField {
-
-  // The default lable for this field.
-  public static $default_label = 'Phenotypes';
-
-  // The default description for this field.
-  public static $default_description = 'Associates phenotypes with this record.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-    // Get the settings
-    $settings = $display['settings'];
-
-    $headers = array('Name', 'Value', 'Type');
-    $rows = array();
-
-    foreach ($items as $delta => $item) {
-      $phenotype = $item['value'];
-      if (!$phenotype) {
-        continue;
-      }
-
-      // Get the field values
-      $phenotype_name = $phenotype['name'];
-      $value = $phenotype['value'];
-      $type = $phenotype['type'];
-
-      // Add a link i there is an entity.
-      if (array_key_exists('entity', $item['value']) and $item['value']['entity']) {
-        list($entity_type, $entity_id) = explode(':', $item['value']['entity']);
-        $phenotype_name = l($phenotype_name, "bio_data/" . $entity_id, array('attributes' => array('target' => "_blank")));
-      }
-      $rows[] = array($phenotype_name, $value, $type);
-    }
-    $table = array(
-      'header' => $headers,
-      'rows' => $rows,
-      'attributes' => array(
-        'id' => 'tripal_linker-table-phenotype-object',
-        'class' => 'tripal-data-table'
-      ),
-      'sticky' => FALSE,
-      'caption' => "",
-      'colgroups' => array(),
-      'empty' => 'No phenotypes available',
-    );
-    $content = theme_table($table);
-
-    // once we have our table array structure defined, we call Drupal's theme_table()
-    // function to generate the table.
-    if (count($items) > 0) {
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => $content,
-      );
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $record = $details['record'];
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the FK that links to the base record.
-    $schema = chado_get_schema($field_table);
-    $base_table = $details['record']->tablename;
-    $pkey = $schema['primary key'][0];
-    $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
-    $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
-
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(),
-      $field_table . '__' . $pkey => '',
-      $field_table . '__' . $fkey_lcolumn => '',
-      $field_table . '__' . 'phenotype_id' => '',
-      // Ignore the synonym_sgml column for now.
-    );
-
-    $linker_table = $base_table . '_phenotype';
-    $options = array(
-      'return_array' => 1,
-      'include_fk' => array(
-        'phenotype_id' => array(
-          'attr_id' => array(
-            'dbxref_id' => array(
-              'db_id' => TRUE,
-            ),
-          ),
-        ),
-        $fkey_lcolumn => TRUE,
-      ),
-    );
-    $record = chado_expand_var($record, 'table', $linker_table, $options);
-    $phenotype_linkers = $record->$linker_table;
-    if ($phenotype_linkers) {
-      foreach ($phenotype_linkers as $i => $phenotype_linker) {
-        $phenotype = $phenotype_linker->phenotype_id;
-        $entity->{$field_name}['und'][$i] = array(
-          'value' => array(
-       '@type' => $phenotype->attr_id->dbxref_id->db_id->name . ':' . $phenotype->attr_id->dbxref_id->accession,
-            'type' => $phenotype->attr_id->name,
-            'name' => $phenotype->name,
-            'value' => $phenotype->value,
-          ),
-          $field_table . '__' . $pkey => $phenotype_linker->$pkey,
-          $field_table . '__' . $fkey_lcolumn => $phenotype_linker->$fkey_lcolumn->$fkey_lcolumn,
-          $field_table . '__' . 'phenotype_id' => $phenotype->phenotype_id
-        );
-
-        if ($phenotype && property_exists($phenotype, 'entity_id')) {
-          $entity->{$field_name}['und'][$i]['value']['entity'] = 'TripalEntity:' . $phenotype->entity_id;
-        }
-      }
-    }
-  }
-
-  /**
-   * We don't want a widget so override this function.
-   */
-  public static function widgetInfo() {
-    return array();
-  }
-
-}

+ 0 - 204
tripal_chado/includes/TripalFields.old/chado_linker__prop.inc

@@ -1,204 +0,0 @@
-<?php
-
-class chado_linker__prop extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Property';
-
-  // The default description for this field.
-  public static $default_description = 'Add details about this property.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    $field_name = $this->field['field_name'];
-    $chado_table = $this->instance['settings']['chado_table'];
-
-    $properties = array();
-    foreach ($items as $delta => $item) {
-      $properties[] = $item['chado-' . $chado_table . '__value'];
-    }
-    $content = implode(', ', $properties);
-
-    if (count($items) > 0) {
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => $content,
-      );
-    }
-  }
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $instance = $this->instance;
-
-    // Get the table name and cvterm that this field maps to.
-    $matches = array();
-    preg_match('/(.*?)__(\d+)/', $field_name, $matches);
-    // If the field name is not properly formatted then we can't tell what
-    // table and type this is.  So just return.
-    if (count($matches) != 3) {
-      return $widget;
-    }
-    $table_name = $matches[1];
-    $cvterm_id = $matches[2];
-
-    // Get the name of the pkey field for this property table and the name
-    // of the FK field that links to the base table.
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $base_table = $this->instance['settings']['base_table'];
-    $lfkey_field = key($schema['foreign keys'][$base_table]['columns']);
-    $rfkey_field = $schema['foreign keys'][$base_table]['columns'][$lfkey_field];
-
-    // Get the field defaults.
-    $fk_value =key_exists(0, $items) ? $items[0]['chado-' . $field_table . '__' . $lfkey_field] : '';
-    $propval = '';
-    if (array_key_exists($delta, $items)) {
-      $propval = tripal_get_field_item_keyval($items, $delta, 'chado-' . $table_name . '__value', $propval);
-    }
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-
-    $widget['chado-' . $table_name . '__' . $pkey] = array(
-      '#type' => 'hidden',
-      '#default_value' => !empty($items[$delta]['chado-' . $field_table . '__' . $pkey]) ? $items[$delta]['chado-' . $field_table . '__' . $pkey] : '',
-    );
-    $widget['chado-' . $table_name . '__' . $lfkey_field] = array(
-      '#type' => 'hidden',
-      '#value' => $fk_value,
-    );
-    $widget['chado-' . $table_name . '__value'] = array(
-      '#type' => 'textfield',
-      '#default_value' => $propval,
-      '#title' => $instance['label'] . ' value',
-      '#description' => $instance['description'],
-    );
-    $widget['chado-' . $table_name . '__type_id'] = array(
-      '#type' => 'hidden',
-      '#value' => $cvterm_id,
-    );
-    $widget['chado-' . $table_name . '__rank'] = array(
-      '#type' => 'hidden',
-      '#value' => $delta,
-    );
-  }
-
-
-  /**
-   * @see TripalField::validate()
-   */
-  public function validate($entity_type, $entity, $field, $items, &$errors) {
-
-  }
-
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-
-    $field_name = $this->field['field_name'];
-    $table_name = $this->instance['settings']['chado_table'];
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $base_table = $this->instance['settings']['base_table'];
-    $lfkey_field = key($schema['foreign keys'][$base_table]['columns']);
-    $rfkey_field = $schema['foreign keys'][$base_table]['columns'][$lfkey_field];
-
-    $prop_value = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__value']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__value'] : '';
-
-    // If the user removed the contact from the contact_name field
-    // then we want to clear out the rest of the hidden values.
-    // Leave the primary key so the record can be deleted.
-    if (!$prop_value) {
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $pkey] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__rank'] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__type_id'] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $lfkey_field] = '';
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $base_table = $this->instance['settings']['base_table'];
-
-    $matches = array();
-    preg_match('/(.*?)__(\d+)/', $field_name, $matches);
-    $table_name = $matches[1];
-    $cvterm_id = $matches[2];
-    // Get the FK that links to the base record.
-    $schema = chado_get_schema($field_table);
-    $pkey = $schema['primary key'][0];
-    $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
-    $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
-
-    // Set some defaults for the empty record.
-    $chado_record = $entity->chado_record;
-    $entity->{$field_name}['und'][0] = array(
-      'value' => '',
-      'chado-' . $field_table . '__' . $pkey => '',
-      'chado-' . $field_table . '__' . $fkey_lcolumn => $chado_record->{$fkey_lcolumn},
-      'chado-' . $field_table . '__value' => '',
-      'chado-' . $field_table . '__type_id' => '',
-      'chado-' . $field_table . '__rank' => '',
-    );
-
-    // Get the properties associated with this base record for this fields
-    // given type.
-    $columns = array('*');
-    $match = array(
-      $fkey_lcolumn => $chado_record->{$fkey_lcolumn},
-      'type_id' => $cvterm_id,
-    );
-    $options = array(
-      'return_array' => TRUE,
-      'order_by' => array('rank' => 'ASC')
-    );
-    $properties = chado_select_record($field_table, $columns, $match, $options);
-    for ($i = 0; $i < count($properties); $i++) {
-      $property = $properties[$i];
-      foreach ($schema['fields'] as $fname => $details) {
-        $entity->{$field_name}['und'][$i] = array(
-          'value' => array(),
-          'chado-' . $field_table . '__' . $pkey => $property->$pkey,
-          'chado-' . $field_table . '__' . $fkey_lcolumn => $property->$fkey_lcolumn,
-          'chado-' . $field_table . '__value' => $property->value,
-          'chado-' . $field_table . '__type_id' => $property->type_id,
-          'chado-' . $field_table . '__rank' => $property->rank,
-        );
-      }
-    }
-  }
-}

+ 0 - 306
tripal_chado/includes/TripalFields.old/chado_linker__prop_adder.inc

@@ -1,306 +0,0 @@
-<?php
-
-class chado_linker__prop_adder extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Add a Property Type';
-
-  // The default description for this field.
-  public static $default_description = 'This record may have any number of properties. Use
-            this field to first add the type.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-    // This field should never be viewed. It's to help add new properties
-    // when editing an entity.  So return nothing.
-    return '';
-  }
-
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $field_name = $widget['#field_name'];
-
-    $widget['#type'] = 'fieldset';
-    $widget['#title'] = $element['#title'];
-    $widget['#description'] = $element['#description'];
-    $widget['#group'] = 'entity_form_vtabs';
-
-
-     $widget['kvproperty_instructions'] = array(
-      '#type' => 'item',
-      '#markup' => t('You may add additional properties to this form by
-          providing a property name (from a vocabulary) in the field below
-          and clicking the "Lookup Term" button.  Terms that match the value
-          entered will be displayed for selection.  After selecting the
-          appropriate term click the "Use this term" button and a
-          new field will be added to the form above for the property you selected.
-          In the future, this field will be present for all records
-          of this type.'),
-    );
-
-    $term_name = isset($form_state['values'][$field_name]['und'][0]['wrapper']['term_name']) ? $form_state['values'][$field_name]['und'][0]['wrapper']['term_name'] : '';
-
-    // Drupal's vertical feild set is a bit quirky in that we can't just
-    // add a prefix and suffix to the weidget.  If we do, then the
-    // field doesn't show up on the page after an AJAX call.  We have to add
-    // an internal wrapper (below) for AJAX calls.
-    $widget['wrapper'] = array(
-      '#prefix' =>  "<span id='$field_name-lookup-form'>",
-      '#suffix' => '</span>',
-    );
-
-    // If no term has been selected yet then provide the auto complete field.
-    $widget['wrapper']['term_name'] = array(
-      '#title'       => t('Term'),
-      '#type'        => 'textfield',
-      '#description' => t("The content type must be the name of a term in
-        a controlled vocabulary and the controlled vocabulary should
-        already be loaded into Tripal.  For example, to create a content
-        type for storing 'genes', use the 'gene' term from the
-        Sequence Ontology (SO)."),
-      '#default_value' => $term_name,
-      '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/cvterm/",
-    );
-
-    $widget['wrapper']['select_button'] = array(
-      '#type' => 'button',
-      '#value' => t('Lookup Term'),
-      '#name' => 'select_cvterm',
-      '#ajax' => array(
-        'callback' => "tripal_chado_prop_adder_form_ajax_callback",
-        'wrapper' => "$field_name-lookup-form",
-        'effect' => 'fade',
-        'method' => 'replace'
-      ),
-    );
-    if ($term_name) {
-      $widget['wrapper']['terms_list'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Matching Terms'),
-        '#description' => t('Please select the term the best matches the
-          content type you want to create. If the same term exists in
-          multiple vocabularies you will see more than one option below.')
-      );
-      $match = array(
-        'name' => $term_name,
-      );
-      $terms = chado_generate_var('cvterm', $match, array('return_array' => TRUE));
-      $terms = chado_expand_var($terms, 'field', 'cvterm.definition');
-      $num_terms = 0;
-      foreach ($terms as $term) {
-        // Save the user a click by setting the default value as 1 if there's
-        // only one matching term.
-        $default = FALSE;
-        $attrs = array();
-        if ($num_terms == 0 and count($terms) == 1) {
-          $default = TRUE;
-          $attrs = array('checked' => 'checked');
-        }
-        $widget['wrapper']['terms_list']['term-' . $term->cvterm_id] = array(
-          '#type' => 'checkbox',
-          '#title' =>  $term->name,
-          '#default_value' => $default,
-          '#attributes' => $attrs,
-          '#description' => '<b>Vocabulary:</b> ' . $term->cv_id->name . ' (' . $term->dbxref_id->db_id->name . ') ' . $term->cv_id->definition .
-          '<br><b>Term: </b> ' . $term->dbxref_id->db_id->name . ':' . $term->dbxref_id->accession . '.  ' .
-          '<br><b>Definition:</b>  ' . $term->definition,
-        );
-        $num_terms++;
-      }
-      if ($num_terms == 0) {
-        $widget['wrapper']['terms_list']['none'] = array(
-          '#type' => 'item',
-          '#markup' => '<i>' . t('There is no term that matches the entered text.') . '</i>'
-        );
-      }
-      else {
-        $widget['wrapper']['cardinality'] = array(
-          '#title'       => t('Number of Values'),
-          '#type'        => 'textfield',
-          '#description' => t("A number of 1 or more indicating the number of values allowed for this property. Enter -1 for unlimited values"),
-          '#size' => 10,
-          '#default_value' => 1,
-        );
-        // Add in the button for the cases of no terms or too many.
-        $widget['wrapper']['submit_button'] = array(
-          '#type' => 'submit',
-          '#value' => t('Use this term'),
-          '#name' => 'use_term_button',
-        );
-      }
-    }
-  }
-
-  /**
-   * @see TripalField::widgetFormValidate()
-   */
-  public function widgetFormValidate($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-    $field = $this->field;
-    $field_name = $field['field_name'];
-
-    if ($form_state['triggering_element']['#name'] == 'use_term_button') {
-      // If the user has clicked the 'user_term_button' then we need to makes
-      // sure that the cardinality textbox contains a positive integer.
-      $cardinality = $form_state['values'][$field_name][$langcode][$delta]['wrapper']['cardinality'];
-      if (!preg_match('/^-*\d+$/', $cardinality) or $cardinality < -2 or $cardinality == 0) {
-        form_set_error("$field_name][$langcode][$delta][wrapper][cardinality", "Please provide positive number for the number of values, or -1 for unlimited.");
-      }
-
-      // Get selected terms
-      $terms_list = $form_state['values'][$field_name][$langcode][$delta]['wrapper']['terms_list'];
-      $counter = 0;
-      $selected_term_id = '';
-      foreach ($terms_list AS $term => $selected) {
-        if ($selected) {
-          $selected_term_id = str_replace('term-', '', $term);
-          $counter ++;
-        }
-      }
-      // Make sure at least a term is selected
-      if ($counter == 0) {
-        form_set_error("$field_name][$langcode][$delta][wrapper][terms_list", "Please select a term.");
-      }
-      // Make sure only one term is selected
-      if ($counter > 1) {
-        form_set_error("$field_name][$langcode][$delta][wrapper][terms_list", "Please select only one term.");
-      }
-      // Make sure this property doesn't already have a field
-      if (key_exists($field_name . '__' . $selected_term_id, $form_state['values'])) {
-        form_set_error("$field_name][$langcode][$delta][wrapper][terms_name", "Property already exists. Please select another term.");
-      }
-    }
-  }
-
-  /**
-   * @see TripalField::widgetFormValidate
-   */
-  public function validate($entity_type, $entity, $field, $items, &$errors) {
-    // This form doesn't manage data in the database so we don't need to
-    // validate anything here.
-  }
-
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-
-    // Add the new field to the entity but only if the property adder button
-    // was clicked
-    if (!array_key_exists('triggering_element', $form_state) or
-      $form_state['triggering_element']['#name'] != 'use_term_button') {
-      return;
-    }
-    else {
-      // Because we're going to add a new property we want to rebuild the form
-      // rather than have it fully submit.
-      $form_state['rebuild'] = TRUE;
-    }
-
-    // Get the table and base table.
-    $base_table = $this->instance['settings']['base_table'];
-
-    // Get the term for the property
-    $field = $this->field;
-    $fname = $field['field_name'];
-    $cardinality = $form_state['values'][$fname][$langcode][$delta]['wrapper']['cardinality'];
-    // Get selected terms
-    $terms_list = $form_state['values'][$fname][$langcode][$delta]['wrapper']['terms_list'];
-    $selected_term_id = '';
-    foreach ($terms_list AS $term => $selected) {
-      if ($selected) {
-        $selected_term_id = str_replace('term-', '', $term);
-      }
-    }
-    $cvterm = chado_generate_var('cvterm', array('cvterm_id' => $selected_term_id));
-
-    // Generate the name for the property table and the field name that we'll
-    // be creating.
-    $prop_table = $base_table . 'prop';
-    $field_name = $prop_table . '__' . $cvterm->cvterm_id;
-
-    // The field name is the table name in this case. We want to get the
-    // primary key as this should be the field that maps th the value.
-    $schema = chado_get_schema($prop_table);
-    $pkey = $schema['primary key'][0];
-
-    // Add the field if it doesn't already exists.
-    $field = field_info_field($field_name);
-    if (!$field) {
-      $field = field_create_field(array(
-        'field_name' => $field_name,
-        'type' => 'chado_linker__prop',
-        'cardinality' => $cardinality,
-        'locked' => FALSE,
-        'storage' => array(
-          'type' => 'field_chado_storage',
-        ),
-        'settings' => array(
-          'chado_table' => $prop_table,
-          'chado_column' => $pkey,
-          'base_table' => $base_table,
-          'semantic_web' => $cvterm->dbxref_id->db_id->name . ':' . $cvterm->dbxref_id->accession,
-        ),
-      ));
-    }
-
-    // Create an instance of the field.
-    $instance = field_info_instance($entity_type, $field_name,  $entity->bundle);
-    if (!$instance) {
-      $instance = field_create_instance(array(
-        'field_name' => $field_name,
-        'entity_type' => 'TripalEntity',
-        'bundle' => $entity->bundle,
-        'label' => ucfirst(preg_replace('/_/', ' ', $cvterm->name)),
-        'description' => $cvterm->definition ? $cvterm->definition : '',
-        'required' => FALSE,
-        'settings' => array(
-          'auto_attach' => FALSE,
-        ),
-        'widget' => array(
-          'type' => 'chado_linker__prop_widget',
-          'settings' => array(
-            'display_label' => 1,
-          ),
-        ),
-        'display' => array(
-          'default' => array(
-            'label' => 'inline',
-            'type' => 'chado_linker__prop_formatter',
-            'settings' => array(),
-          ),
-        ),
-      ));
-    }
-  }
-}
-
-/**
- *
- */
-function tripal_chado_prop_adder_form_ajax_callback($form, $form_state) {
-  $field_name = $form_state['triggering_element']['#parents'][0];
-
-  // Because this field is inside a vertical fieldset we can't just
-  // return $form[$field_name]. We have set the AJAX call to replace
-  // everything inside of the 'wrapper' element, so we must return that.
-  return $form[$field_name]['und'][0]['wrapper'];
-}

+ 0 - 260
tripal_chado/includes/TripalFields.old/chado_linker__pub.inc

@@ -1,260 +0,0 @@
-<?php
-
-class chado_linker__pub extends TripalField {
-
-  // The default lable for this field.
-  public static $default_label = 'Publications';
-
-  // The default description for this field.
-  public static $default_description = 'Associates a publication (e.g. journal article,
-            conference proceedings, book chapter, etc.) with this record.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    $list_items = array();
-    $chado_table = $this->instance['settings']['chado_table'];
-    foreach ($items as $delta => $item) {
-      if ($item['chado-' . $chado_table . '__pub_id']) {
-        $pub = chado_generate_var('pub', array('pub_id' => $item['chado-' . $chado_table . '__pub_id']));
-        $list_items[$pub->pyear] = $pub->uniquename;
-      }
-    }
-
-    krsort($list_items, SORT_NUMERIC);
-
-    $list = array(
-      'title' => '',
-      'items' => $list_items,
-      'type' => 'ol',
-      'attributes' => array(),
-    );
-
-    if (count($items) > 0) {
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => theme_item_list($list),
-      );
-    }
-  }
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $entity = $form['#entity'];
-    $field_name = $this->field['field_name'];
-
-    // Get the FK column that links to the base table.
-    $table_name = $this->instance['settings']['chado_table'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-
-    // Get the field defaults.
-    $record_id = '';
-    $fkey_value = $element['#entity']->chado_record_id;
-    $pub_id = '';
-    $uname = '';
-
-    // If the field already has a value then it will come through the $items
-    // array.  This happens when editing an existing record.
-    if (count($items) > 0 and array_key_exists($delta, $items)) {
-      $record_id = tripal_get_field_item_keyval($items, $delta, 'chado-' . $table_name . '__' . $pkey, $record_id);
-      $pub_id = tripal_get_field_item_keyval($items, $delta, 'chado-' . $table_name . '__pub_id', $pub_id);
-      $uname = tripal_get_field_item_keyval($items, $delta, 'uniquename', $uname);
-    }
-
-    $schema = chado_get_schema('pub');
-
-    $widget['#table_name'] = $table_name;
-    $widget['#fkey_field'] = $fkey;
-    $widget['#theme'] = 'chado_linker__pub_widget';
-    $widget['#prefix'] =  "<span id='$table_name-$delta'>";
-    $widget['#suffix'] =  "</span>";
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-
-    $widget['chado-' . $table_name . '__' . $pkey] = array(
-      '#type' => 'value',
-      '#default_value' => $record_id,
-    );
-    $widget['chado-' . $table_name . '__' . $fkey] = array(
-      '#type' => 'value',
-      '#default_value' => $fkey_value,
-    );
-    $widget['chado-' . $table_name . '__pub_id'] = array(
-      '#type' => 'value',
-      '#default_value' => $pub_id,
-    );
-
-    $widget['uniquename'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Publication'),
-      '#default_value' => $uname,
-      '#autocomplete_path' => 'admin/tripal/storage/chado/auto_name/pub',
-      '#ajax' => array(
-        'callback' => "chado_linker__pub_widget_form_ajax_callback",
-        'wrapper' => "$table_name-$delta",
-        'effect' => 'fade',
-        'method' => 'replace'
-      ),
-      '#maxlength' => 100000,
-    );
-  }
-
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-
-    // Get the FK column that links to the base table.
-    $table_name = $this->instance['settings']['chado_table'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-    $field_name = $this->field['field_name'];
-
-    // Get the field values.
-    $fkey_value = isset($form_state['values'][$field_name][$langcode][$delta]['value']) ? $form_state['values'][$field_name][$langcode][$delta]['value'] : '';
-    $pub_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] : '';
-    $uname = isset($form_state['values'][$field_name][$langcode][$delta]['uniquename']) ? $form_state['values'][$field_name][$langcode][$delta]['uniquename'] : '';
-
-    // If the user provided a uniquename then we want to set the foreign key
-    // value to be the chado_record_id
-    if ($uname and !$pub_id) {
-      $pub = chado_generate_var('pub', array('uniquename' => $uname));
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] = $pub->pub_id;
-    }
-
-    // In the widgetFrom function we automatically add the foreign key
-    // record.  But if the user did not provide a publication we want to take
-    // it out so that the Chado field_storage infrastructure won't try to
-    // write a record.
-    if (!$uname and !$pub_id) {
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey] = '';
-    }
-
-    // If the user removed the publication from the pub_uniquename field
-    // then we want to clear out the rest of the hidden values.
-    // Leave the primary key so the record can be deleted.
-    if (!$uname and $pub_id) {
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] = '';
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $record = $details['record'];
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $base_table = $this->instance['settings']['base_table'];
-
-    // Get the FK that links to the base record.
-    $schema = chado_get_schema($field_table);
-    $pkey = $schema['primary key'][0];
-    $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
-    $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(),
-      'chado-' . $field_table . '__' . $pkey => '',
-      'chado-' . $field_table . '__' . $fkey_lcolumn => '',
-      'chado-' . $field_table . '__' . 'pub_id' => '',
-      'uniquename' => '',
-    );
-
-    $linker_table = $base_table . '_pub';
-    $options = array(
-      'return_array' => 1,
-    );
-    $record = chado_expand_var($record, 'table', $linker_table, $options);
-
-    if (count($record->$linker_table) > 0) {
-      $i = 0;
-      foreach ($record->$linker_table as $index => $linker) {
-        $pub = $linker->pub_id;
-        $pub_details = tripal_get_minimal_pub_info($pub);
-        $pub_details['@type'] = $pub->type_id->dbxref_id->db_id->name . ':' . $pub->type_id->dbxref_id->accession;
-        $pub_details['publication']['type'] = $pub->type_id->name;
-
-        $entity->{$field_name}['und'][$i]['value'] = $pub_details;
-        $entity->{$field_name}['und'][$i]['chado-' . $field_table . '__' . $pkey] = $linker->$pkey;
-        $entity->{$field_name}['und'][$i]['chado-' . $field_table . '__' . $fkey_lcolumn] = $linker->$fkey_lcolumn->$fkey_lcolumn;
-        $entity->{$field_name}['und'][$i]['chado-' . $field_table . '__' . 'pub_id'] = $pub->pub_id;
-        $entity->{$field_name}['und'][$i]['uniquename'] =  $pub->uniquename;
-
-        if (property_exists($pub, 'entity_id')) {
-          $entity->{$field_name}['und'][$i]['value']['entity'] = 'TripalEntity:' . $pub->entity_id;
-        }
-        $i++;
-      }
-    }
-  }
-}
-
-/**
- * An Ajax callback for the pub widget.
- */
-function chado_linker__pub_widget_form_ajax_callback($form, $form_state) {
-
-  $field_name = $form_state['triggering_element']['#parents'][0];
-  $delta = $form_state['triggering_element']['#parents'][2];
-
-  return $form[$field_name]['und'][$delta];
-}
-/**
- * Theme function for the pub widget.
- *
- * @param $variables
- */
-function theme_chado_linker__pub_widget($variables) {
-  $element = $variables['element'];
-
-  // These two fields were added to the widget to help identify the fields
-  // for layout.
-  $table_name = $element['#table_name'];
-  $fkey = $element['#fkey_field'];
-
-  $layout = "
-      <div class=\"pub-widget\">
-        <div class=\"pub-widget-item\">" .
-        drupal_render($element['uniquename']) . "
-        </div>
-      </div>
-    ";
-
-  return $layout;
-}

+ 0 - 1247
tripal_chado/includes/TripalFields.old/chado_linker__relationship.inc

@@ -1,1247 +0,0 @@
-<?php
-
-class chado_linker__relationship extends TripalField {
-  // The default lable for this field.
-  public static $default_label = 'Relationships';
-
-  // The default description for this field.
-  public static $default_description = 'Relationships between records.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Provide a list of instance specific settings. These can be access within
-  // the instanceSettingsForm.  When the instanceSettingsForm is submitted
-  // then Drupal with automatically change these settings for the instnace.
-  // It is recommended to put settings at the instance level whenever possible.
-  public static $default_instance_settings = array(
-    'relationships' => array(
-      'option1_vocabs' => '',
-      'option2_vocab' => '',
-      'option2_parent' => '',
-      'relationship_types' => '',
-    ),
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-    // Get the settings
-    $settings = $display['settings'];
-
-    $rows = array();
-    $headers = array('Subject' ,'Type', 'Object');
-    $headers = array('Relationship');
-
-    foreach ($items as $delta => $item) {
-      if (!$item['value']) {
-        continue;
-      }
-      $subject_name = $item['value']['subject']['name'];
-      $subject_type = $item['value']['subject']['type'];
-      $object_name = $item['value']['object']['name'];
-      $object_type = $item['value']['object']['type'];
-      $phrase = $item['value']['phrase'];
-
-      // Handle some special cases.
-      // For mRNA objects we don't want to show the CDS, exons, 5' UTR, etc.
-      // we want to show the parent gene and the protein.
-      if ($object_type == 'mRNA' and ($subject_type != 'polypeptide')) {
-        continue;
-      }
-      if ($subject_type == 'mRNA' and ($object_type != 'gene')) {
-        continue;
-      }
-
-      $phrase = preg_replace("/$subject_type/", "<b>$subject_type</b>", $phrase);
-      $phrase = preg_replace("/$object_type/", "<b>$object_type</b>", $phrase);
-
-      if (array_key_exists('entity', $item['value']['object'])) {
-        list($entity_type, $object_entity_id) = explode(':', $item['value']['object']['entity']);
-        if ($object_entity_id != $entity->id) {
-          $link = l($object_name, 'bio_data/' . $object_entity_id);
-          $phrase = preg_replace("/$object_name/", $link, $phrase);
-        }
-      }
-      if (array_key_exists('entity', $item['value']['subject'])) {
-        list($entity_type, $subject_entity_id) = explode(':', $item['value']['subject']['entity']);
-        if ($subject_entity_id != $entity->id) {
-          $link = l($subject_name, 'bio_data/' . $subject_entity_id);
-          $phrase = preg_replace("/$subject_name/", $link, $phrase);
-        }
-      }
-
-      $rows[] = array($phrase);
-    }
-
-
-    // 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' => 'chado-linker--relationship-table',
-        'class' => 'tripal-data-table'
-      ),
-      'sticky' => FALSE,
-      'caption' => '',
-      'colgroups' => array(),
-      'empty' => 'There are no relationships',
-    );
-
-    // once we have our table array structure defined, we call Drupal's theme_table()
-    // function to generate the table.
-    if (count($items) > 0) {
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => theme_table($table),
-      );
-    }
-  }
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the instance settings
-    $instance = $this->instance;
-    $settings = $instance['settings']['relationships'];
-
-    $option1_vocabs = $settings['option1_vocabs'];
-    $option2_vocab  = $settings['option2_vocab'];
-    $option2_parent = $settings['option2_parent'];
-    $option3_rtypes = $settings['relationship_types'];
-
-    // For testing if there are selected vocabs for option1 we'll copy the
-    // contents in a special variable for later.
-    $option1_test   = $option1_vocabs;
-
-    // Get the FK column that links to the base table.
-    $chado_table = $this->instance['settings']['chado_table'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($chado_table);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-
-    // Get the field defaults.
-    $record_id = '';
-    $fkey_value = $element['#entity'] ? $element['#entity']->chado_record_id : '';
-    $subject_id = '';
-    $subject_uniquename = '';
-    $type_id = '';
-    $type = '';
-    $object_id = '';
-    $object_uniquename = '';
-    $value = '';
-    $rank = '';
-
-    // Handle special cases
-    $subject_id_key = 'subject_id';
-    $object_id_key = 'object_id';
-    if ($chado_table == 'organism_relationship') {
-      $subject_id_key = 'subject_organism_id';
-      $object_id_key = 'object_organism_id';
-    }
-    else if ($chado_table == 'nd_reagent_relationship') {
-      $subject_id_key = 'subject_reagent_id';
-      $object_id_key = 'object_reagent_id';
-    }
-    else if ($chado_table == 'project_relationship') {
-      $subject_id_key = 'subject_project_id';
-      $object_id_key = 'object_project_id';
-    }
-
-    // If the field already has a value then it will come through the $items
-    // array.  This happens when editing an existing record.
-    if (array_key_exists($delta, $items)) {
-      $record_id = isset($items[$delta][$field_table . '__' . $pkey]) ? $items[$delta][$field_table . '__' . $pkey] : '';
-      $subject_id = isset($items[$delta][$field_table . '__' . $subject_id_key]) ? $items[$delta][$field_table . '__' . $subject_id_key] : '';
-      $type_id = isset($items[$delta][$field_table . '__type_id']) ? $items[$delta][$field_table . '__type_id'] : '';
-      $object_id = isset($items[$delta][$field_table . '__' . $object_id_key]) ? $items[$delta][$field_table . '__' . $object_id_key] : '';
-
-      if (isset($items[$delta][$field_table . '__value'])) {
-        $value = $items[$delta][$field_table . '__value'];
-      }
-      if (isset($items[$delta][$field_table . '__rank'])) {
-        $rank = $items[$delta][$field_table . '__rank'];
-      }
-
-      $object_uniquename = isset($items[$delta]['object_name']) ? $items[$delta]['object_name'] : '';
-      $subject_uniquename = isset($items[$delta]['subject_name']) ? $items[$delta]['subject_name'] : '';
-      $type = isset($items[$delta]['type_name']) ? $items[$delta]['type_name'] : '';
-    }
-
-    // Check $form_state['values'] to see if an AJAX call set the values.
-    if (array_key_exists('values', $form_state) and array_key_exists($delta, $form_state['values'])) {
-//       $record_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__' . $pkey);
-//       $subject_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__subject_id');
-//       $subject_uniquename = tripal_chado_get_field_form_values($field_name, $form_state, $delta, 'subject_name');
-//       $type_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__type_id');
-//       $type = tripal_chado_get_field_form_values($field_name, $form_state, $delta, 'type_name');
-//       $object_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__object_id');
-//       $object_uniquename = tripal_chado_get_field_form_values($field_name, $form_state, $delta, 'object_name');
-//       $value = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__value');
-//       $rank = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $field_table . '__rank');
-    }
-
-    $widget['#table_name'] = $chado_table;
-
-    $widget['#fkeys'] = $schema['foreign keys'];
-    $widget['#base_table'] = $base_table;
-    $widget['#chado_record_id'] = isset($form['#entity']) ? $form['#entity']->chado_record_id : '';
-    //$widget['#element_validate'] = array('chado_linker__relationship_validate');
-    $widget['#theme'] = 'chado_linker__relationship_widget';
-    $widget['#prefix'] =  "<span id='$chado_table-$delta'>";
-    $widget['#suffix'] =  "</span>";
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-    $widget[$field_table . '__' . $pkey] = array(
-      '#type' => 'value',
-      '#default_value' => $record_id,
-    );
-    $widget[$field_table . '__' . $subject_id_key] = array(
-      '#type' => 'value',
-      '#default_value' => $subject_id,
-    );
-    $widget[$field_table . '__type_id'] = array(
-      '#type' => 'value',
-      '#default_value' => $type_id,
-    );
-    $widget[$field_table . '__' . $object_id_key] = array(
-      '#type' => 'value',
-      '#default_value' => $object_id,
-    );
-    if (array_key_exists('value', $schema['fields'])) {
-      $widget[$field_table . '__value'] = array(
-        '#type' => 'value',
-        '#default_value' => $value,
-      );
-    }
-    if (array_key_exists('rank', $schema['fields'])) {
-      $widget[$field_table . '__rank'] = array(
-        '#type' => 'value',
-        '#default_value' => $rank,
-      );
-    }
-    $widget['subject_name'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Subject'),
-      '#default_value' => $subject_uniquename,
-      '#required' => $element['#required'],
-      '#maxlength' => array_key_exists('length', $schema['fields'][$subject_id_key]) ? $schema['fields'][$subject_id_key]['length'] : 255,
-      '#size' => 35,
-      '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/$base_table",
-    );
-
-    // Getting default values
-    $default_voc = '';
-    if (isset($form_state['field'][$field_name]['und']['instance']['default_value'][0]['vocabulary'])) {
-      $default_voc = $form_state['field'][$field_name]['und']['instance']['default_value'][0]['vocabulary'];
-    }
-    $default_term = '';
-    if (isset($form_state['field'][$field_name]['und']['instance']['default_value'][0]['type_name'])) {
-      $default_term = $form_state['field'][$field_name]['und']['instance']['default_value'][0]['type_name'];
-    }
-
-    $default_type_id = $type_id;
-    if (!$type_id && isset($form_state['field'][$field_name]['und']['instance']['default_value'][0]['type_id'])) {
-      $default_type_id = $form_state['field'][$field_name]['und']['instance']['default_value'][0]['type_id'];
-    }
-    // Option 3: Custom list of Relationship Types
-    $rtype_options = array();
-    $rtype_options[] = 'Select a Type';
-    if ($option3_rtypes) {
-      $rtypes = explode(PHP_EOL, $option3_rtypes);
-      foreach($rtypes AS $rtype) {
-        // Ignore empty lines
-        if (trim($rtype) == '') {
-          continue;
-        }
-        $term = tripal_get_cvterm(array('name' => trim($rtype)));
-        // Try to get term with vocabulary specified
-        if (!$term) {
-          $tmp = explode('|', trim($rtype), 2);
-          $cv = tripal_get_cv(array('name' => trim($tmp[0])));
-          $rtype = trim($tmp[1]);
-          $term = tripal_get_cvterm(array('name' => $rtype, 'cv_id' => $cv->cv_id));
-        }
-        $rtype_options[$term->cvterm_id] = $term->name;
-      }
-      $widget['type_id'] = array(
-        '#type' => 'select',
-        '#title' => t('Relationship Type'),
-        '#options' => $rtype_options,
-        '#default_value' => $default_type_id,
-      );
-      if ($type_id && !key_exists($type_id, $rtype_options)) {
-        form_set_error($this->field['field_name'] . '[' . $langcode . '][' . $delta . '][type_id]', 'Illegal option detected for Relationship Type. Please contact site administrator to fix the problem');
-      }
-    }
-    // Option 2: Child terms of a selected cvterm
-    else if ($option2_vocab) {
-      $values = array(
-        'cv_id' => $option2_vocab,
-        'name' => $option2_parent
-      );
-      $parent_term = tripal_get_cvterm($values);
-
-      // If the term wasn't found then see if it's a synonym.
-      if(!$parent_term) {
-        $values = array(
-          'synonym' => array(
-            'name' => trim($option2_parent),
-          )
-        );
-        $synonym = tripal_get_cvterm($values);
-        if ($synonym && $synonym->cv_id->cv_id == $option2_vocab) {
-          $parent_term = $synonym;
-        }
-      }
-      // Get the child terms of the parent term found above.
-      $sql =
-        "SELECT
-           subject_id,
-           (SELECT name from {cvterm} where cvterm_id = subject_id) AS name
-         FROM {cvtermpath}
-         WHERE
-           object_id = :parent_cvterm_id
-         AND
-           cv_id = :parent_cv_id
-         ORDER BY name
-       ";
-      $args = array(
-        ':parent_cvterm_id' => $parent_term->cvterm_id,
-        ':parent_cv_id' => $parent_term->cv_id->cv_id
-      );
-      $results = chado_query($sql, $args);
-      while($child = $results->fetchObject()) {
-        $rtype_options[$child->subject_id] = $child->name;
-      }
-      $widget['type_id'] = array(
-        '#type' => 'select',
-        '#title' => t('Relationship Type'),
-        '#options' => $rtype_options,
-        '#default_value' => $default_type_id,
-      );
-      if ($type_id && !key_exists($type_id, $rtype_options)) {
-        form_set_error($this->field['field_name'] . '[' . $langcode . '][' . $delta . '][type_id]', 'Illegal option detected for Relationship Type. Please contact site administrator to fix the problem');
-      }
-    }
-    // Option 1: All terms of selected vocabularies
-    else if ($option1_test && array_pop($option1_test)) {
-      $sql = "SELECT cvterm_id, name FROM {cvterm} WHERE cv_id IN (:cv_id) ORDER BY name";
-      $results = chado_query($sql, array(':cv_id' => $option1_vocabs));
-      while ($obj = $results->fetchObject()) {
-        $rtype_options[$obj->cvterm_id] = $obj->name;
-      }
-      $widget['type_id'] = array(
-        '#type' => 'select',
-        '#title' => t('Relationship Type'),
-        '#options' => $rtype_options,
-        '#default_value' => $default_type_id,
-      );
-      if ($type_id && !key_exists($type_id, $rtype_options)) {
-        form_set_error($this->field['field_name'] . '[' . $langcode . '][' . $delta . '][type_id]', 'Illegal option detected for Relationship Type. Please contact site administrator to fix the problem');
-      }
-    }
-    // Default option:
-    else {
-      // Set up available cvterms for selection
-      $vocs = array(0 => 'Select a vocabulary');
-      $vocs = tripal_get_cv_select_options();
-      $cv_id = isset($form_state['values'][$field_name]['und'][0]['vocabulary']) ? $form_state['values'][$field_name]['und'][0]['vocabulary'] : 0;
-      // Try getting the cv_id from cvterm for existing records
-      if (!$cv_id && $type_id) {
-        $cvterm = tripal_get_cvterm(array('cvterm_id' => $type_id));
-        if (isset($cvterm->cv_id->cv_id)) {
-          $cv_id = $cvterm->cv_id->cv_id;
-          $default_term = $cvterm->name;
-        }
-      }
-      if (!$cv_id) {
-        $cv_id = $default_voc;
-      }
-      $widget['vocabulary'] = array(
-        '#type' => 'select',
-        '#title' => t('Vocabulary'),
-        '#options' => $vocs,
-        '#required' => $element['#required'],
-        '#default_value' => $cv_id,
-        '#ajax' => array(
-          'callback' => "chado_linker__relationship_widget_form_ajax_callback",
-          'wrapper' => "$chado_table-$delta",
-          'effect' => 'fade',
-          'method' => 'replace'
-        ),
-      );
-      if ($cv_id) {
-        $options = array();
-        $widget['type_name'] = array(
-          '#type' => 'textfield',
-          '#title' => t('Relationship Type'),
-          '#size' => 15,
-          '#default_value' => $default_term,
-          '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/cvterm/$cv_id"
-        );
-      }
-    }
-
-    $widget['object_name'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Object'),
-      '#default_value' => $object_uniquename,
-      '#required' => $element['#required'],
-      '#maxlength' => array_key_exists('length', $schema['fields'][$object_id_key]) ? $schema['fields'][$object_id_key]['length'] : 255,
-      '#size' => 35,
-      '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/$base_table",
-    );
-  }
-  /**
-   * @see TripalField::validate()
-   */
-  function validate($entity_type, $entity, $langcode, $items, &$errors) {
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $base_table = $this->instance['settings']['base_table'];
-
-    $schema = chado_get_schema($field_table);
-    $fkeys = $schema['foreign keys'];
-
-    // Handle special cases
-    $subject_id_key = 'subject_id';
-    $object_id_key = 'object_id';
-    if ($field_table == 'organism_relationship') {
-      $subject_id_key = 'subject_organism_id';
-      $object_id_key = 'object_organism_id';
-    }
-    else if ($field_table == 'nd_reagent_relationship') {
-      $subject_id_key = 'subject_reagent_id';
-      $object_id_key = 'object_reagent_id';
-    }
-    else if ($field_table == 'project_relationship') {
-      $subject_id_key = 'subject_project_id';
-      $object_id_key = 'object_project_id';
-    }
-
-    foreach ($items as $delta => $item) {
-      $subject_id = $item[$field_table . '__' . $subject_id_key];
-      $object_id = $item[ $field_table . '__' . $object_id_key];
-      $type_id = $item[$field_table . '__type_id'];
-      $type_id = isset($item['type_id']) ? $item['type_id'] : $type_id;
-      $type_name = isset($item['type_name']) ? $item['type_name'] : '';
-      $subject_name = $item['subject_name'];
-      $object_name = $item['object_name'];
-
-
-      // If the row is empty then just continue, there's nothing to validate.
-      if (!$type_id and !$type_name and !$subject_name and !$object_name) {
-        continue;
-      }
-
-      // Make sure we have values for all of the fields.
-      $form_error = FALSE;
-      if (!$type_name && !$type_id) {
-        $errors[$this->field['field_name']][$langcode][$delta][] = array(
-          'error' => 'chado_linker__relationship',
-          'message' => t("Please provide the type of relationship."),
-        );
-      }
-      if ($entity and !$subject_name) {
-        $errors[$this->field['field_name']][$langcode][$delta][] = array(
-          'error' => 'chado_linker__relationship',
-          'message' => t("Please provide the subject of the relationship."),
-        );
-      }
-      if ($entity and !$object_name) {
-        $errors[$this->field['field_name']][$langcode][$delta][] = array(
-          'error' => 'chado_linker__relationship',
-          'message' => t("Please provide the object of the relationship."),
-        );
-      }
-      if ($form_error) {
-        continue;
-      }
-
-      // Before submitting this form we need to make sure that our subject_id and
-      // object_ids are real values.  There are two ways to get the value, either
-      // just with the text value or with an [id: \d+] string embedded.  If the
-      // later we will pull it out.
-      $subject_id = '';
-      $fkey_rcolumn = $fkeys[$base_table]['columns'][$subject_id_key];
-      $matches = array();
-      if ($entity) {
-        if(preg_match('/\[id: (\d+)\]/', $subject_name, $matches)) {
-          $subject_id =  $matches[1];
-          $values = array($fkey_rcolumn => $subject_id);
-          $subject = chado_select_record($base_table, array($fkey_rcolumn), $values);
-          if (count($subject) == 0) {
-            $errors[$this->field['field_name']][$langcode][$delta][] = array(
-              'error' => 'chado_linker__relationship',
-              'message' => t("The subject record cannot be found using the specified id (e.g. [id: xx])."),
-            );
-          }
-        }
-        else {
-          $values = array('uniquename' => $subject_name);
-          $subject = chado_select_record($base_table, array($fkey_rcolumn), $values);
-          if (count($subject) == 0) {
-            $errors[$this->field['field_name']][$langcode][$delta][] = array(
-              'error' => 'chado_linker__relationship',
-              'message' => t("The subject record cannot be found. Please check spelling."),
-            );
-          }
-          elseif (count($subject) > 1) {
-            $errors[$this->field['field_name']][$langcode][$delta][] = array(
-              'error' => 'chado_linker__relationship',
-              'message' => t("The subject is not unique and therefore the relationship cannot be made."),
-            );
-          }
-        }
-      }
-
-      // Now check for a matching object.
-      $object_id = '';
-      $fkey_rcolumn = $fkeys[$base_table]['columns'][$object_id_key];
-      $matches = array();
-      if ($entity) {
-        if (preg_match('/\[id: (\d+)\]/', $object_name, $matches)) {
-          $object_id = $matches[1];
-          $values = array($fkey_rcolumn => $object_id);
-          $object = chado_select_record($base_table, array($fkey_rcolumn), $values);
-          if (count($subject) == 0) {
-            $errors[$this->field['field_name']][$langcode][$delta][] = array(
-              'error' => 'chado_linker__relationship',
-              'message' => t("The object record cannot be found using the specified id (e.g. [id: xx])."),
-            );
-          }
-        }
-        else {
-          $values = array('uniquename' => $object_name);
-          $object = chado_select_record($base_table, array($fkey_rcolumn), $values);
-          if (count($object) == 0) {
-            $errors[$this->field['field_name']][$langcode][$delta][] = array(
-              'error' => 'chado_linker__relationship',
-              'message' => t("The object record cannot be found. Please check spelling."),
-            );;
-          }
-          elseif (count($object) > 1) {
-            $errors[$this->field['field_name']][$langcode][$delta][] = array(
-              'error' => 'chado_linker__relationship',
-              'message' =>  t("The object is not unique and therefore the relationship cannot be made."),
-            );
-          }
-        }
-      }
-
-      // Make sure that either our object or our subject refers to the base record.
-      if ($entity) {
-        $chado_record_id = $entity->chado_record_id;
-        if ($object_id != $chado_record_id  and $subject_id != $chado_record_id) {
-          $errors[$this->field['field_name']][$langcode][$delta][] = array(
-            'error' => 'chado_linker__relationship',
-            'message' =>  t("Either the subject or the object in the relationship must refer to this record."),
-          );
-        }
-
-        // Make sure that the object and subject are not both the same thing.
-        if ($object_id == $subject_id) {
-          $errors[$this->field['field_name']][$langcode][$delta][] = array(
-            'error' => 'chado_linker__relationship',
-            'message' =>  t("The subject and the object in the relationship cannot both refer to the same record."),
-          );
-        }
-      }
-    }
-  }
-  /**
-   * @see TripalField::submit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-return;
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $base_table = $this->instance['settings']['base_table'];
-    $chado_record_id = $entity->chado_record_id;
-
-    $schema = chado_get_schema($field_table);
-    $fkeys = $schema['foreign keys'];
-
-    $type_name = array_key_exists('type_name', $item) ? $item['type_name'] : '';
-    $subject_id = $form_state['values'][$field_name][$langcode][$delta][$field_table . '__subject_id'];
-    $object_id = $form_state['values'][$field_name][$langcode][$delta][ $field_table . '__object_id'];
-    $type_id = $form_state['values'][$field_name][$langcode][$delta][$field_table . '__type_id'];
-
-    $subject_name = $form_state['values'][$field_name][$langcode][$delta]['subject_name'];
-    $object_name = $form_state['values'][$field_name][$langcode][$delta]['object_name'];
-
-    // If the row is empty then skip this one, there's nothing to validate.
-    if (!($type_id or !$type_name) and !$subject_name and !$object_name) {
-      return;
-    }
-
-    // Get the subject ID.
-    $subject_id = '';
-    $fkey_rcolumn = $fkeys[$base_table]['columns']['subject_id'];
-    $matches = array();
-    if (preg_match('/\[id: (\d+)\]/', $subject_name, $matches)) {
-      $subject_id =  $matches[1];
-    }
-    else {
-      $values = array('uniquename' => $subject_name);
-      $subject = chado_select_record($base_table, array($fkey_rcolumn), $values);
-      $subject_id = $subject[0]->$fkey_rcolumn;
-    }
-
-    // Get the object ID.
-    $object_id = '';
-    $fkey_rcolumn = $fkeys[$base_table]['columns']['object_id'];
-    $matches = array();
-    if (preg_match('/\[id: (\d+)\]/', $object_name, $matches)) {
-      $object_id = $matches[1];
-    }
-    else {
-      $values = array('uniquename' => $object_name);
-      $object = chado_select_record($base_table, array($fkey_rcolumn), $values);
-      $object_id = $object[0]->$fkey_rcolumn;
-    }
-
-    // Set the IDs according to the values that were determined above.
-    $form_state['values'][$field_name][$langcode][$delta][$field_table . '__subject_id'] = $subject_id;
-    $form_state['values'][$field_name][$langcode][$delta][$field_table . '__object_id'] = $object_id;
-    $form_state['values'][$field_name][$langcode][$delta][$field_table . '__type_id'] = $type_name;
-    $form_state['values'][$field_name][$langcode][$delta][$field_table . '__rank'] = $item['_weight'];
-
-  }
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-    $settings = $this->field['settings'];
-
-    $record = $details['record'];
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $base_table = $this->instance['settings']['base_table'];
-
-    // Get the PKey for this table
-    $schema = chado_get_schema($field_table);
-    $pkey = $schema['primary key'][0];
-
-    // Get the Pkeys for the subject and object tables
-    $subject_fkey_table = '';
-    $object_fkey_table = '';
-    $fkeys = $schema['foreign keys'];
-    foreach ($fkeys as $fktable => $details) {
-      foreach ($details['columns'] as $fkey_lcolumn => $fkey_rcolumn) {
-        if ($fkey_lcolumn == 'subject_id') {
-          $subject_fkey_table = $fktable;
-        }
-        if ($fkey_lcolumn == 'object_id') {
-          $object_fkey_table = $fktable;
-        }
-      }
-    }
-    $subject_schema = chado_get_schema($subject_fkey_table);
-    $object_schema = chado_get_schema($object_fkey_table);
-    $subject_pkey = $subject_schema['primary key'][0];
-    $object_pkey = $object_schema['primary key'][0];
-
-    // Get the FK that links to the base record.
-    $schema = chado_get_schema($field_table);
-    $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
-    $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(),
-      $field_table . '__' . $pkey => '',
-      $field_table . '__subject_id' => '',
-      $field_table . '__object_id' => '',
-      $field_table . '__type_id' => '',
-      // These elements don't need to follow the naming scheme above
-      // becasue we don't need the chado_field_storage to try and
-      // save these values.
-      'object_name' => '',
-      'subject_name' => '',
-      'type_name' => '',
-    );
-
-    // If the table has rank and value fields then add those to the default
-    // value array.
-    if (array_key_exists('value', $schema['fields'])) {
-      $entity->{$field_name}['und'][0][$field_table . '__value'] = '';
-    }
-    if (array_key_exists('rank', $schema['fields'])) {
-      $entity->{$field_name}['und'][0][$field_table . '__rank'] = '';
-    }
-
-    // If we have no record then just return.
-    if (!$record) {
-      return;
-    }
-
-    // Expand the object to include the relationships.
-    $options = array(
-      'return_array' => 1,
-      // we don't want to fully recurse we only need information about the
-      // relationship type and the object and subject
-      'include_fk' => array(
-        'type_id' => 1,
-        'object_id' => array(
-          'type_id' => 1,
-        ),
-        'subject_id'  => array(
-          'type_id' => 1,
-        ),
-      ),
-    );
-    $rel_table = $base_table . '_relationship';
-    $schema = chado_get_schema($rel_table);
-    if (array_key_exists('rank', $schema['fields'])) {
-      $options['order_by'] = array('rank' => 'ASC');
-    }
-    $record = chado_expand_var($record, 'table', $rel_table, $options);
-    if (!$record->$rel_table) {
-      return;
-    }
-    $srelationships = null;
-    $orelationships = null;
-    if ($rel_table == 'organism_relationship') {
-      $srelationships = $record->$rel_table->subject_organism_id;
-      $orelationships = $record->$rel_table->object_organism_id;
-    }
-    else if ($rel_table == 'nd_reagent_relationship') {
-      $srelationships = $record->$rel_table->subject_reagent_id;
-      $orelationships = $record->$rel_table->object_reagent_id;
-    }
-    else if ($rel_table == 'project_relationship') {
-      $srelationships = $record->$rel_table->subject_project_id;
-      $orelationships = $record->$rel_table->object_project_id;
-    }
-    else {
-      $srelationships = $record->$rel_table->subject_id;
-      $orelationships = $record->$rel_table->object_id;
-    }
-
-    $i = 0;
-    if ($orelationships) {
-      foreach ($orelationships as $relationship) {
-        $rel_acc = $relationship->type_id->dbxref_id->db_id->name . ':' . $relationship->type_id->dbxref_id->accession;
-        $rel_type = $relationship->type_id->name;
-        $verb = self::get_rel_verb($rel_type);
-        $subject_name = $relationship->subject_id->name;
-        $subject_type = $relationship->subject_id->type_id->name;
-        $object_name = $relationship->object_id->name;
-        $object_type = $relationship->object_id->type_id->name;
-        $entity->{$field_name}['und'][$i]['value'] = array(
-          'type' => $relationship->type_id->name,
-          'subject' => array(
-            'type' => $subject_type,
-            'name' => $subject_name,
-          ),
-          'type' => $relationship->type_id->name,
-          'object' => array(
-            'type' => $object_type,
-            'name' => $object_name,
-            'entity' => 'TripalEntity:' . $entity->id,
-          )
-        );
-        if (property_exists($relationship->subject_id, 'uniquename')) {
-          $entity->{$field_name}['und'][$i]['value']['subject']['identifier'] =  $relationship->subject_id->uniquename;;
-        }
-        if (property_exists($relationship->object_id, 'uniquename')) {
-          $entity->{$field_name}['und'][$i]['value']['object']['identifier'] = $relationship->object_id->uniquename;
-        }
-        if (property_exists($relationship->subject_id, 'entity_id')) {
-          $entity_id = $relationship->subject_id->entity_id;
-          $entity->{$field_name}['und'][$i]['value']['subject']['entity'] = 'TripalEntity:' . $entity_id;
-        }
-        $rel_type_clean = lcfirst(preg_replace('/_/', ' ', $rel_type));
-        $entity->{$field_name}['und'][$i]['value']['phrase'] = 'The ' . $subject_type . ', ' .
-          $subject_name . ', ' . $verb . ' '  . $rel_type_clean . ' this '  .
-          $object_type . '.';
-
-        $entity->{$field_name}['und'][$i]['semantic_web'] = array(
-          'type' => $rel_acc,
-          'subject' => $relationship->subject_id->type_id->dbxref_id->db_id->name . ':' . $relationship->subject_id->type_id->dbxref_id->accession,
-          'object' => $relationship->object_id->type_id->dbxref_id->db_id->name . ':' . $relationship->object_id->type_id->dbxref_id->accession,
-        );
-
-        $entity->{$field_name}['und'][$i][$field_table . '__' . $pkey] = $relationship->$pkey;
-        $entity->{$field_name}['und'][$i][$field_table . '__subject_id'] = $relationship->subject_id->$subject_pkey;
-        $entity->{$field_name}['und'][$i][$field_table . '__type_id'] = $relationship->type_id->cvterm_id;
-        $entity->{$field_name}['und'][$i][$field_table . '__object_id'] = $relationship->object_id->$object_pkey;
-
-        $entity->{$field_name}['und'][$i]['type_name'] = $relationship->type_id->name;
-        $entity->{$field_name}['und'][$i]['subject_name'] = $relationship->subject_id->name . ' [id: ' . $relationship->subject_id->$fkey_rcolumn . ']';
-        $entity->{$field_name}['und'][$i]['object_name'] = $relationship->object_id->name  . ' [id: ' . $relationship->object_id->$fkey_rcolumn . ']';
-        if (array_key_exists('value', $schema['fields'])) {
-          $entity->{$field_name}['und'][$i][$field_table . '__value'] = $relationship->value;
-        }
-        if (array_key_exists('rank', $schema['fields'])) {
-          $entity->{$field_name}['und'][$i][$field_table . '__rank'] = $relationship->rank;
-        }
-        $i++;
-      }
-    }
-
-    if ($srelationships) {
-      foreach ($srelationships as $relationship) {
-        $rel_acc = $relationship->type_id->dbxref_id->db_id->name . ':' . $relationship->type_id->dbxref_id->accession;
-        $rel_type = $relationship->type_id->name;
-        $verb = self::get_rel_verb($rel_type);
-        $subject_name = $relationship->subject_id->name;
-        $subject_type = $relationship->subject_id->type_id->name;
-        $object_name = $relationship->object_id->name;
-        $object_type = $relationship->object_id->type_id->name;
-        $entity->{$field_name}['und'][$i]['value'] = array(
-          '@type' => $relationship->type_id->name,
-          'subject' => array(
-            'type' => $subject_type,
-            'name' => $subject_name,
-            'entity' => 'TripalEntity:' . $entity->id,
-          ),
-          'type' => $relationship->type_id->name,
-          'object' => array(
-            'type' =>  $object_type,
-            'name' => $object_name,
-          )
-        );
-        if (property_exists($relationship->subject_id, 'uniquename')) {
-          $entity->{$field_name}['und'][$i]['value']['subject']['identifier'] = $relationship->subject_id->uniquename;
-        }
-        if (property_exists($relationship->object_id, 'uniquename')) {
-          $entity->{$field_name}['und'][$i]['value']['object']['identifier'] = $relationship->object_id->uniquename;
-        }
-        if (property_exists($relationship->object_id, 'entity_id')) {
-          $entity_id = $relationship->object_id->entity_id;
-          $entity->{$field_name}['und'][$i]['value']['object']['entity'] = 'TripalEntity:' . $entity_id;
-        }
-        $rel_type_clean = lcfirst(preg_replace('/_/', ' ', $rel_type));
-        $entity->{$field_name}['und'][$i]['value']['phrase'] = 'This  ' .
-          $subject_type . ' ' . $verb . ' '  . $rel_type_clean . ' the '  .
-          $object_type . ', ' . $object_name . '.';
-
-
-        $entity->{$field_name}['und'][$i]['semantic_web'] = array(
-          'type' => $rel_acc,
-          'subject' => $relationship->subject_id->type_id->dbxref_id->db_id->name . ':' . $relationship->subject_id->type_id->dbxref_id->accession,
-          'object' => $relationship->object_id->type_id->dbxref_id->db_id->name . ':' . $relationship->object_id->type_id->dbxref_id->accession,
-        );
-
-
-        $entity->{$field_name}['und'][$i][$field_table . '__' . $pkey] = $relationship->$pkey;
-        $entity->{$field_name}['und'][$i][$field_table . '__subject_id'] = $relationship->subject_id->$subject_pkey;
-        $entity->{$field_name}['und'][$i][$field_table . '__type_id'] = $relationship->type_id->cvterm_id;
-        $entity->{$field_name}['und'][$i][$field_table . '__object_id'] = $relationship->object_id->$object_pkey;
-
-        $entity->{$field_name}['und'][$i]['type_name'] = $relationship->type_id->name;
-        $entity->{$field_name}['und'][$i]['subject_name'] = $relationship->subject_id->name  . ' [id: ' . $relationship->subject_id->$fkey_rcolumn . ']';
-        $entity->{$field_name}['und'][$i]['object_name'] = $relationship->object_id->name  . ' [id: ' . $relationship->object_id->$fkey_rcolumn . ']';
-
-        if (array_key_exists('value', $schema['fields'])) {
-          $entity->{$field_name}['und'][$i][$field_table . '__value'] = $relationship->value;
-        }
-        if (array_key_exists('rank', $schema['fields'])) {
-          $entity->{$field_name}['und'][$i][$field_table . '__rank'] = $relationship->rank;
-        }
-        $i++;
-      }
-    }
-  }
-  /**
-   * A helper function to define English verbs for relationship types.
-   *
-   * @param $rel_type
-   *   The vocabulary term name for the relationship.
-   *
-   * @return
-   *   The verb to use when creating a sentence of the relationship.
-   */
-  public static function get_rel_verb($rel_type) {
-    $rel_type_clean = lcfirst(preg_replace('/_/', ' ', $rel_type));
-    $verb = $rel_type_clean;
-    switch ($rel_type_clean) {
-      case 'integral part of':
-      case 'instance of':
-        $verb = 'is an';
-        break;
-      case 'proper part of':
-      case 'transformation of':
-      case 'genome of':
-      case 'part of':
-        $verb = 'is a';
-      case 'position of':
-      case 'sequence of':
-      case 'variant of':
-        $verb = 'is a';
-        break;
-      case 'derives from':
-      case 'connects on':
-      case 'contains':
-      case 'finishes':
-      case 'guides':
-      case 'has origin':
-      case 'has part':
-      case 'has quality':
-      case 'is consecutive sequence of':
-      case 'maximally overlaps':
-      case 'overlaps':
-      case 'starts':
-        break;
-      default:
-        $verb = 'is';
-    }
-
-    return $verb;
-  }
-
-  /**
-   * @see TripalField::instanceSettingsForm()
-   */
-  public function instanceSettingsForm() {
-
-    $element = parent::instanceSettingsForm();
-
-    //$element = parent::instanceSettingsForm();
-    $element['relationships'] = array(
-      '#type' => 'fieldset',
-      '#title' => 'Allowed Relationship Types',
-      '#description' => t('There are three ways that relationship types
-          can be limited for users who have permission to add new relationships.
-          Please select the most appropriate for you use case.  By default
-          all vocabularies are provided to the user which allows use of any
-          term for the relationship type.'),
-      '#collapsed' => TRUE,
-      '#collapsible' => TRUE,
-      '#theme' => 'chado_linker__relationship_instance_settings'
-    );
-//     $element['instructions'] = array(
-//       '#type' => 'item',
-//       '#markup' => 'You may provide a list of terms that will be available in a select box
-//         as the relationship types. This select box will replace the vocabulary select box if the
-//         following value is set.'
-//     );
-    $vocs = tripal_get_cv_select_options();
-    $element['relationships']['option1'] = array(
-      '#type' => 'item',
-      '#title' => 'Option #1',
-      '#description' => t('Use this option to limit the vocabularies that a user .
-        could use to specify relationship types. With this option any term in .
-        the vocabulary can be used for the relationship type. You may select
-        more than one vocabulary.'),
-
-    );
-    $element['relationships']['option1_vocabs'] = array(
-      '#type' => 'select',
-      '#multiple' => TRUE,
-      '#options' => $vocs,
-      '#size' => 6,
-      '#default_value' => $this->instance['settings']['relationships']['option1_vocabs'],
-      // TODO add ajax here so that the relationship autocomplete below works
-    );
-
-    $element['relationships']['option2'] = array(
-      '#type' => 'item',
-      '#title' => '<b>Option #2</b>',
-      '#description' => 'Some vocabularies are heirarchichal (an ontology). Within this
-         heirarchy groups of related terms typically fall under a common parent. If you
-         wish to limit the list of terms that a user can use for the relationship type,
-         you can provide the parent term here.  Then, only that term\'s children will
-         be avilable for use as a relationship type.',
-    );
-    $element['relationships']['option2_vocab'] = array(
-      '#type' => 'select',
-      '#description' => 'Specify Default Vocabulary',
-      '#multiple' => FALSE,
-      '#options' => $vocs,
-      '#default_value' => $this->instance['settings']['relationships']['option2_vocab'],
-      '#ajax' => array(
-        'callback' => "chado_linker__relationship_instance_settings_form_ajax_callback",
-        'wrapper' => 'relationships-option2-parent',
-        'effect' => 'fade',
-        'method' => 'replace'
-      ),
-    );
-    $element['relationships']['option2_parent'] = array(
-      '#type' => 'textfield',
-      '#description' => 'Specify a Heirarchical Parent Term',
-      '#default_value' => $this->instance['settings']['relationships']['option2_parent'],
-      '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/cvterm/",
-      '#prefix' => '<div id=relationships-option2-parent>',
-      '#suffix' => '</div>'
-    );
-    $element['relationships']['option3'] = array(
-      '#type' => 'item',
-      '#title' => 'Option #3',
-      '#description' => 'Provide terms separated by a new line. The term provided should be
-        unique and distinguishable by the name. You can use a bar | to separate a vocabulary
-        and a term to allow more specific assignment.',
-    );
-    $element['relationships']['relationship_types'] = array(
-      '#type' => 'textarea',
-      '#default_value' => $this->instance['settings']['relationships']['relationship_types'],
-    );
-
-    return $element;
-
-  }
-  /**
-   * @see TripalField::instanceSettingsFormValidate()
-   */
-  public function instanceSettingsFormValidate($form, &$form_state) {
-
-    $element = parent::instanceSettingsFormValidate();
-
-    // Get relationships settings
-    $settings = $form_state['values']['instance']['settings']['relationships'];
-    $form_state['values']['instance']['settings']['relationships']['relationship_types']= trim($settings['relationship_types']);
-
-    // Make sure only one option is selected
-    $option1test = $settings['option1_vocabs'];
-    $option1 = isset($settings['option1_vocabs']) && array_pop($option1test);
-    $option2 = (isset($settings['option2_vocab']) && $settings['option2_vocab']) || $settings['option2_parent'];
-    $option3 = isset($settings['relationship_types']) && trim($settings['relationship_types']);
-    if ($option1 && ($option2 || $option3) == 1 ||
-         $option2 && ($option1 || $option3) == 1 ||
-          $option3 && ($option1 || $option2) == 1
-        ) {
-      form_set_error(
-        "instance][settings][relationships",
-         t("Only one option is allowed to limit the relationship types.")
-      );
-      return;
-    }
-
-    // For option3, make sure the supplied types are valid cvterms
-    if ($option3) {
-      $rel_types = explode(PHP_EOL, $settings['relationship_types']);
-      foreach($rel_types AS $type) {
-        $type =  trim($type);
-        // Ignore empty lines
-        if ($type == '') {
-          continue;
-        }
-        // Find the matching cvterm
-        $sql = "SELECT cvterm_id FROM {cvterm} WHERE name = :name";
-        $results = chado_query($sql, array(':name' => $type));
-        $terms = array();
-        while ($obj = $results->fetchObject()) {
-          $terms[] = $obj;
-        }
-        // Don't save the form  if a term can not be found or it matches more than one cvterm
-        $cv = '';
-        if (count($terms) == 0) {
-          // If a term can not be found, maybe the type contains '|', parse it as 'vocabulary|cvterm'
-          if (strpos($type, '|')) {
-            $tmp = explode('|', $type, 2);
-            $type = trim($tmp[1]);
-            $cv = tripal_get_cv(array('name' => trim($tmp[0])));
-            if($cv) {
-              $sql = "SELECT cvterm_id FROM {cvterm} WHERE name = :name AND cv_id = :cv_id";
-              $results = chado_query($sql, array(':name' => $type, ':cv_id' => $cv->cv_id));
-              while ($obj = $results->fetchObject()) {
-                $terms[] = $obj;
-              }
-            }
-            else {
-              $cv = $tmp[0];
-            }
-          }
-          if (count($terms) != 1) {
-            $message = "The term '@type' can not be found.";
-            $token = array('@type' => $type);
-            if ($cv) {
-              $message =  "The term '@type' can not be found within the vocabulary '@vocab'.";
-              $token['@vocab'] = $cv;
-            }
-            form_set_error(
-              "instance][settings][relationships][relationship_types",
-              t($message, $token)
-            );
-          }
-        }
-        else if (count($terms) > 1) {
-          // If a type matches more than one term, parse it as 'vocabulary|cvterm' and try again
-          if (strpos($type, '|')) {
-            $tmp = explode('|', $type, 2);
-            $type = trim($tmp[1]);
-            $cv = tripal_get_cv(array('name' => trim($tmp[0])));
-            if ($cv) {
-              $sql = "SELECT cvterm_id FROM {cvterm} WHERE name = :name AND cv_id = :cv_id";
-              $results = chado_query($sql, array(':name' => $type, ':cv_id' => $cv->cv_id));
-              while ($obj = $results->fetchObject()) {
-                $terms[] = $obj;
-              }
-            }
-          }
-          if(count($terms) != 1) {
-            form_set_error(
-              "instance][settings][relationships][relationship_types",
-              t("The term '@type' matches more than one term. Please specify its vocabulary in
-                  the format of 'vocabulary|@type'.", array('@type' => $type))
-            );
-          }
-        }
-      }
-    }
-
-    // For option2: Make sure the parent term is a valid cvterm
-    if ($option2) {
-      $cv_id = $settings['option2_vocab'];
-      $supertype = $settings['option2_parent'];
-      $term = tripal_get_cvterm(array(
-        'name' => trim($supertype),
-        'cv_id' => $cv_id,
-      ));
-      // Tripal cv autocomplete also allow cvterm synonyms, if the parent term doesn't match
-      // a cvterm, try cvtermsynonym
-      if (!$term) {
-        $synonym = tripal_get_cvterm(
-          array(
-            'synonym' => array(
-              'name' => trim($supertype),
-            )
-          )
-        );
-        if ($synonym && $synonym->cv_id->cv_id == $cv_id) {
-          $term = $synonym;
-        }
-      }
-      if (!isset($term->cvterm_id)) {
-        form_set_error(
-          "instance][settings][relationships][option2_parent",
-          t("The term '@type' is not a valid term for the vocabulary selected.", array('@type' => $supertype))
-        );
-      }
-    }
-  }
-}
-
-/**
- * Theme function for the chado_linker__relationship_widget.
- */
-function theme_chado_linker__relationship_widget($variables) {
-  $element = $variables['element'];
-  $field_name = $element['#field_name'];
-  $field = field_info_field($field_name);
-  $field_type = $field['type'];
-  $field_table = $field['settings']['chado_table'];
-  $field_column = $field['settings']['chado_column'];
-  $layout = "
-      <div class=\"chado-linker--relationship-widget\">
-        <div class=\"chado-linker--relationship-widget-item\">" .
-          drupal_render($element['subject_name']) . "
-        </div>
-        <div class=\"chado-linker--relationship-widget-item\">" .
-          drupal_render($element['vocabulary']) . "
-        </div>
-        <div class=\"chado-linker--relationship-widget-item\">" .
-          drupal_render($element['type_name']) . "
-        </div>
-        <div class=\"chado-linker--relationship-widget-item\">" .
-          drupal_render($element['type_id']) . "
-        </div>
-        <div class=\"chado-linker--relationship-widget-item\">" .
-          drupal_render($element['object_name']) . "
-        </div>
-      </div>
-    ";
-  return $layout;
-}
-
-function theme_chado_linker__relationship_instance_settings ($variables) {
-  $element = $variables['element'];
-  $option1 = $element['option1'];
-  $option1_vocabs = $element['option1_vocabs'];
-  $option2 = $element['option2'];
-  $option2_vocab = $element['option2_vocab'];
-  $option2_parent = $element['option2_parent'];
-  $option3 = $element['option3'];
-  $rtype = $element['relationship_types'];
-  $layout = drupal_render($option1);
-  $layout .= drupal_render($option1_vocabs);
-  $layout .=
-    drupal_render($option2) .
-    "<div class=\"chado-linker--relationship-instance-settings-option2\">" .
-        "<div class=\"chado-linker--relationship-instance-settings-option2-item\">" .
-            drupal_render($option2_vocab) .
-        "</div>" .
-        "<div class=\"chado-linker--relationship-instance-settings-option2-item\">" .
-            drupal_render($option2_parent) .
-        "</div>" .
-    "</div>";
-  $layout .= drupal_render($option3);
-  $layout .= drupal_render($rtype);
-  return $layout;
-}
-
-/**
- * An Ajax callback for the relationshp widget.
- */
-function chado_linker__relationship_widget_form_ajax_callback(&$form, $form_state) {
-
-  // Get the triggering element
-  $form_element_name = $form_state['triggering_element']['#name'];
-  preg_match('/(.+?)\[(.+?)\]\[(.+?)\]/', $form_element_name, $matches);
-  $field = $matches[1];
-  $lang = $matches[2];
-  $delta = $matches[3];
-  // Return the widget that triggered the AJAX call
-  if (isset($form[$field][$lang][$delta])) {
-    return $form[$field][$lang][$delta];
-  }
-  // Alternatively, return the default value widget for the widget setting form
-  else {
-    return $form['instance']['default_value_widget'][$field];
-  }
-}
-
-/**
- * An Ajax callback for the relationshp instance setting form.
- */
-function chado_linker__relationship_instance_settings_form_ajax_callback(&$form, &$form_state) {
-  $acpath  = $form['instance']['settings']['relationships']['option2_parent']['#autocomplete_path'];
-  $acpath .=  $form_state['values']['instance']['settings']['relationships']['option2_vocab'] . '/';
-  $urlval  = $form['instance']['settings']['relationships']['option2_parent']['#autocomplete_input']['#url_value'];
-  $urlval .=  $form_state['values']['instance']['settings']['relationships']['option2_vocab'];
-  // Reset value if a different vocabulary is selected
-  $form['instance']['settings']['relationships']['option2_parent']['#value'] = NULL;
-  $form_state['values']['instance']['settings']['relationships']['option2_parent'] = NULL;
-  $form['instance']['settings']['relationships']['option2_parent']['#autocomplete_path'] = $acpath;
-  $form['instance']['settings']['relationships']['option2_parent']['#autocomplete_input']['#url_value'] = $urlval;
-  return $form['instance']['settings']['relationships']['option2_parent'];
-}
-

+ 0 - 331
tripal_chado/includes/TripalFields.old/chado_linker__synonym.inc

@@ -1,331 +0,0 @@
-<?php
-
-class chado_linker__synonym extends TripalField {
-
-  // The default lable for this field.
-  public static $default_label = 'Synonyms';
-
-  // The default description for this field.
-  public static $default_description = 'Adds an alternative name (synonym or alias) to this record.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::formatterView()
-   */
-  public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {
-
-    $chado_table = $this->instance['settings']['chado_table'];
-    foreach ($items as $delta => $item) {
-      if (array_key_exists('chado-' . $chado_table . '__synonym_id', $item) and
-          $item['chado-' . $chado_table . '__synonym_id']) {
-        $synonym = chado_generate_var('synonym', array('synonym_id' => $item['chado-' . $chado_table . '__synonym_id']));
-        $name = $synonym->name;
-        if ($synonym->type_id->name != 'exact') {
-          $name .= ' (<i>' . $synonym->type_id->name . '</i>)';
-        }
-        $element[$delta] = array(
-          '#type' => 'markup',
-          '#markup' => $name,
-        );
-      }
-    }
-  }
-  /**
-   * @see TripalField::widgetForm()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $entity = $form['#entity'];
-    $field_name = $this->field['field_name'];
-
-    // Get the FK column that links to the base table.
-    $table_name = $this->instance['settings']['chado_table'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-
-    // Get the field defaults.
-    $record_id = '';
-    $fkey_value = $element['#entity']->chado_record_id;
-    $synonym_id = '';
-    $pub_id = '';
-    $is_current = TRUE;
-    $is_internal = FALSE;
-    $syn_name = '';
-    $syn_type = '';
-
-    // If the field already has a value then it will come through the $items
-    // array.  This happens when editing an existing record.
-    if (array_key_exists($delta, $items)) {
-      $record_id = $items[$delta]['chado-' . $table_name . '__' . $pkey];
-      $synonym_id = $items[$delta]['chado-' . $table_name . '__synonym_id'];
-      $pub_id = $items[$delta]['chado-' . $table_name . '__pub_id'];
-      $is_current = $items[$delta]['chado-' . $table_name . '__is_current'];
-      $is_internal = $items[$delta]['chado-' . $table_name . '__is_internal'];
-      $syn_name = $items[$delta]['name'];
-      $syn_type = $items[$delta]['type_id'];
-    }
-
-    // Check $form_state['values'] to see if an AJAX call set the values.
-    if (array_key_exists('values', $form_state) and array_key_exists($delta, $form_state['values'])) {
-      $record_id = $form_state['values'][$field_name]['und'][$delta]['chado-' . $table_name . '__' . $pkey];
-      $synonym_id = $form_state['values'][$field_name]['und'][$delta]['chado-' . $table_name . '__synonym_id'];
-      $pub_id = $form_state['values'][$field_name]['und'][$delta]['chado-' . $table_name . '__pub_id'];
-      $is_current = $form_state['values'][$field_name]['und'][$delta]['chado-' . $table_name . '__is_current'];
-      $is_internal = $form_state['values'][$field_name]['und'][$delta]['chado-' . $table_name . '__is_internal'];
-      $syn_name = $form_state['values'][$field_name]['und'][$delta]['name'];
-      $syn_type = $form_state['values'][$field_name]['und'][$delta]['type_id'];
-    }
-
-    $options = array();
-    $value = array('cv_id' => array('name' => 'synonym_type'));
-    $op = array('return_array' => 1);
-    $types = chado_generate_var('cvterm', $value, $op);
-    if ($types) {
-      foreach($types AS $type) {
-        $options[$type->cvterm_id] = $type->name;
-      }
-    }
-
-    // Get the schema for the synonym table so we can make sure we limit the
-    // size of the name field to the proper size.
-    $schema = chado_get_schema('synonym');
-
-    $widget['#table_name'] = $table_name;
-    $widget['#fkey_field'] = $fkey;
-    $widget['#theme'] = 'chado_linker__synonym_widget';
-    $widget['#prefix'] =  "<span id='$table_name-$delta'>";
-    $widget['#suffix'] =  "</span>";
-
-    $widget['value'] = array(
-      '#type' => 'value',
-      '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-
-    $widget['chado-' . $table_name . '__' . $pkey] = array(
-      '#type' => 'value',
-      '#default_value' => $record_id,
-    );
-    $widget['chado-' . $table_name . '__synonym_id'] = array(
-      '#type' => 'value',
-      '#default_value' => $synonym_id,
-    );
-    $widget['chado-' . $table_name . '__' . $fkey] = array(
-      '#type' => 'value',
-      '#default_value' => $fkey_value,
-    );
-    // TODO: add a widget for selecting a publication.
-    $widget['chado-' . $table_name . '__pub_id'] = array(
-      '#type' => 'value',
-      '#default_value' => $pub_id,
-    );
-    $widget['type_id'] = array(
-      '#type' => 'select',
-      '#title' => t('Type'),
-      '#options' => $options,
-      '#default_value' => $syn_type,
-    );
-    $widget['name'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Synonym Name'),
-      '#default_value' => $syn_name,
-      '#size' => 25,
-    );
-
-    $widget['chado-' . $table_name . '__is_current'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Is Current'),
-      '#default_value' => $is_current,
-      '#required' => $element['#required'],
-    );
-
-    $widget['chado-' . $table_name . '__is_internal'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Is Internal'),
-      '#default_value' => $is_internal,
-      '#required' => $element['#required'],
-    );
-  }
-
-  /**
-   * @see TripalField::widgetFormSubmit()
-   */
-  public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $table_name = $this->instance['settings']['chado_table'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-    $base_table = $this->instance['settings']['base_table'];
-    $schema = chado_get_schema($table_name);
-    $pkey = $schema['primary key'][0];
-    $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
-    $fkey = $fkeys[0];
-
-    $record_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $pkey]) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $pkey] : '';
-    $fkey_value = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey]) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey] : '';
-    $synonym_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__synonym_id']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__synonym_id'] : '';
-    $pub_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] : '';
-    $is_current = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_current']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_current'] : '';
-    $is_internal = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_internal']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_internal'] : '';
-    $syn_name = isset($form_state['values'][$field_name][$langcode][$delta]['name']) ? $form_state['values'][$field_name][$langcode][$delta]['name'] : '';
-    $syn_type = isset($form_state['values'][$field_name][$langcode][$delta]['type_id']) ? $form_state['values'][$field_name][$langcode][$delta]['type_id'] : '';
-
-    // If the user provided a $syn_name and a $syn_type then we want to set
-    // the foreign key value to be the chado_record_id.
-    if ($syn_name and $syn_type) {
-
-      // Get the synonym. If one with the same name and type is already present
-      // then use that. Otherwise, insert a new one.
-      if (!$synonym_id) {
-        $synonym = chado_generate_var('synonym', array('name' => $syn_name, 'type_id' => $syn_type));
-        if (!$synonym) {
-          $synonym = chado_insert_record('synonym', array(
-            'name' => $syn_name,
-            'type_id' => $syn_type,
-            'synonym_sgml' => '',
-          ));
-          $synonym = (object) $synonym;
-        }
-
-        // Set the synonym_id and FK value
-        $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__synonym_id'] = $synonym->synonym_id;
-      }
-
-      if (!$pub_id) {
-        $pub = chado_generate_var('pub', array('uniquename' => 'null'));
-        $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] = $pub->pub_id;
-      }
-    }
-    else {
-      // If the $syn_name is not set, then remove the linker FK value to the base table.
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__synonym_id'] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_internal'] = '';
-      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_current'] = '';
-    }
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $record = $details['record'];
-    $base_table = $this->instance['settings']['base_table'];
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Get the PKey for this table
-    $schema = chado_get_schema($field_table);
-    $pkey = $schema['primary key'][0];
-
-    // Get the FK that links to the base record.
-    $schema = chado_get_schema($field_table);
-    $fkey_lcolumn = key($schema['foreign keys'][$base_table]['columns']);
-    $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => array(),
-      'chado-' . $field_table . '__' . $pkey => '',
-      'chado-' . $field_table . '__' . $fkey_lcolumn => '',
-      'chado-' . $field_table . '__' . 'synonym_id' => '',
-      'chado-' . $field_table . '__' . 'pub_id' => '',
-      'chado-' . $field_table . '__' . 'is_current' => TRUE,
-      'chado-' . $field_table . '__' . 'is_internal' => '',
-      'name' => '',
-      'type_id' => '',
-      // Ignore the synonym_sgml column for now.
-    );
-
-    $linker_table = $base_table . '_synonym';
-    $options = array('return_array' => 1);
-    $record = chado_expand_var($record, 'table', $linker_table, $options);
-    if (count($record->$linker_table) > 0) {
-      $i = 0;
-      foreach ($record->$linker_table as $index => $linker) {
-        $synonym = $linker->synonym_id;
-        $entity->{$field_name}['und'][$i] = array(
-          'value' => array(
-            '@type' => $synonym->type_id->dbxref_id->db_id->name . ':' . $synonym->type_id->dbxref_id->accession,
-            'type' => $synonym->type_id->name,
-            'name' => $synonym->name,
-          ),
-          'chado-' . $field_table . '__' . $pkey => $linker->$pkey,
-          'chado-' . $field_table . '__' . $fkey_lcolumn => $linker->$fkey_lcolumn->$fkey_lcolumn,
-          'chado-' . $field_table . '__' . 'synonym_id' => $synonym->synonym_id,
-          'chado-' . $field_table . '__' . 'pub_id' => $linker->pub_id->pub_id,
-          'chado-' . $field_table . '__' . 'is_current' => $linker->is_current,
-          'chado-' . $field_table . '__' . 'is_internal' => $linker->is_internal,
-          'name' => $synonym->name,
-          'type_id' => $synonym->type_id->cvterm_id,
-        );
-        $i++;
-      }
-    }
-  }
-}
-
-/**
- * Theme function for the synonym widget.
- *
- * @param $variables
- */
-function theme_chado_linker__synonym_widget($variables) {
-  $element = $variables['element'];
-
-  // These two fields were added to the widget to help identify the fields
-  // for layout.
-  $table_name = $element['#table_name'];
-  $fkey = $element['#fkey_field'];
-
-  $layout = "
-      <div class=\"synonym-widget\">
-        <div class=\"synonym-widget-item\">" .
-          drupal_render($element['name']) . "
-        </div>
-        <div>" .
-          drupal_render($element['type_id']) . "
-        </div>
-        <div class=\"synonym-widget-item\">" .
-          drupal_render($element['chado-' . $table_name . '__is_internal']) . "
-        </div>
-        <div>" .
-          drupal_render($element['chado-' . $table_name . '__is_current']) . "
-        </div>
-      </div>
-    ";
-
-  return $layout;
-}
-
-/**
- * An Ajax callback for the synonym widget.
- */
-function chado_linker__synonym_widget_form_ajax_callback($form, $form_state) {
-
-  $field_name = $form_state['triggering_element']['#parents'][0];
-  $delta = $form_state['triggering_element']['#parents'][2];
-
-  return $form[$field_name]['und'][$delta];
-}

+ 0 - 90
tripal_chado/includes/TripalFields.old/chado_organism__type_id.inc

@@ -1,90 +0,0 @@
-<?php
-
-class chado_organism__type_id extends TripalField {
-
-  // The default lable for this field.
-  public static $default_label = 'Infraspecific Type';
-
-  // The default description for this field.
-  public static $default_description = 'Specifies the infraspecific type of an organism.';
-
-  // Add any default settings elements.  If you override the globalSettingsForm()
-  // or the instanceSettingsForm() functions then you need to be sure that
-  // any settings you want those functions to manage are listed in this
-  // array.
-  public static $default_settings = array(
-    'chado_table' => '',
-    'chado_column' => '',
-    'base_table' => '',
-  );
-
-  // Set this to the name of the storage backend that by default will support
-  // this field.
-  public static $default_storage = 'field_chado_storage';
-
-  /**
-   * @see TripalField::widget()
-   */
-  public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    $settings = $this->field['settings'];
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    $type_id = 0;
-    if (count($items) > 0 and array_key_exists('organism__type_id', $items[0])) {
-      $type_id = $items[0]['organism__type_id'];
-    }
-
-    $form['value'] = array(
-      '#type' => 'value',
-      '#value' =>  array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
-    );
-
-    $cv = tripal_get_default_cv($field_table, $field_column);
-    $options = array();
-    if ($cv) {
-      $options = tripal_get_cvterm_select_options($cv->cv_id);
-    }
-    $widget['organism__type_id'] = array(
-      '#type' => 'select',
-      '#title' => $element['#title'],
-      '#description' => $element['#description'],
-      '#options' => $options,
-      '#default_value' => $type_id,
-      '#required' => $element['#required'],
-      '#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
-      '#delta' => $delta,
-    );
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity, $details = array()) {
-
-    $record = $details['record'];
-    $settings = $this->field['settings'];
-
-    $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
-    $field_table = $this->instance['settings']['chado_table'];
-    $field_column = $this->instance['settings']['chado_column'];
-
-    // Set some defaults for the empty record.
-    $entity->{$field_name}['und'][0] = array(
-      'value' => '',
-      'organism__type_id' => '',
-    );
-
-    if ($record->type_id) {
-      $entity->{$field_name}['und'][0]['value'] = $record->type_id->name;
-      $entity->{$field_name}['und'][0]['organism__type_id'] = $record->type_id->cvterm_id;
-    }
-  }
-
-}
-

+ 2 - 2
tripal_chado/includes/TripalFields/data__accession/data__accession_widget.inc

@@ -106,7 +106,7 @@ class data__accession_widget extends ChadoFieldWidget {
     );
     );
     $widget['links'] = array(
     $widget['links'] = array(
       '#type' => 'item',
       '#type' => 'item',
-      '#markup' => l('Add a new database', 'admin/tripal/legacy/tripal_db/add', array('attributes' => array('target' => '_blank')))
+      '#markup' => l('Add a new database', 'admin/tripal/storage/chado/db/add', array('attributes' => array('target' => '_blank')))
     );
     );
   }
   }
 
 
@@ -183,7 +183,7 @@ class data__accession_widget extends ChadoFieldWidget {
  * An Ajax callback for the tripal_chado_admin_publish_form..
  * An Ajax callback for the tripal_chado_admin_publish_form..
  */
  */
 function data__accession_widget_form_ajax_callback($form, $form_state) {
 function data__accession_widget_form_ajax_callback($form, $form_state) {
-  
+
   $instance = $form['#instance'];
   $instance = $form['#instance'];
   $field_name = $form_state['triggering_element']['#parents'][0];
   $field_name = $form_state['triggering_element']['#parents'][0];
   $field = field_info_field($field_name);
   $field = field_info_field($field_name);

+ 7 - 0
tripal_chado/includes/TripalFields/sbo__database_cross_reference/sbo__database_cross_reference.inc

@@ -103,6 +103,13 @@ class sbo__database_cross_reference extends ChadoField {
       $i = 0;
       $i = 0;
       foreach ($record->$linker_table as $index => $linker) {
       foreach ($record->$linker_table as $index => $linker) {
         $dbxref = $linker->dbxref_id;
         $dbxref = $linker->dbxref_id;
+
+        // Ignore the GFF_source database. This is a weird thing required by
+        // GBrowse and is added by the GFF loader. We don't want to show it.
+        if ($dbxref->db_id->name == 'GFF_source') {
+          continue;
+        }
+
         $URL = tripal_get_dbxref_url($dbxref);
         $URL = tripal_get_dbxref_url($dbxref);
         $entity->{$field_name}['und'][$i] = array(
         $entity->{$field_name}['und'][$i] = array(
           'value' => array(
           'value' => array(

+ 1 - 1
tripal_chado/includes/TripalFields/sbo__database_cross_reference/sbo__database_cross_reference_widget.inc

@@ -136,7 +136,7 @@ class sbo__database_cross_reference_widget extends ChadoFieldWidget {
     if (!$db_id) {
     if (!$db_id) {
       $widget['links'] = array(
       $widget['links'] = array(
         '#type' => 'item',
         '#type' => 'item',
-        '#markup' => l('Add a database', 'admin/tripal/legacy/tripal_db/add', array('attributes' => array('target' => '_blank')))
+        '#markup' => l('Add a database', 'admin/tripal/storage/chado/db/add', array('attributes' => array('target' => '_blank')))
       );
       );
     }
     }
   }
   }

+ 5 - 7
tripal_chado/includes/TripalFields/schema__publication/schema__publication_formatter.inc

@@ -45,13 +45,11 @@ class schema__publication_formatter extends ChadoFieldFormatter {
         'type' => 'ol',
         'type' => 'ol',
         'attributes' => array(),
         'attributes' => array(),
       );
       );
+      $list = theme_item_list($list);
     }
     }
-
-    if (count($items) > 0) {
-      $element[0] = array(
-        '#type' => 'markup',
-        '#markup' => theme_item_list($list),
-      );
-    }
+    $element[0] = array(
+      '#type' => 'markup',
+      '#markup' => $list,
+    );
   }
   }
 }
 }

+ 28 - 32
legacy/tripal_db/includes/tripal_db.admin.inc → tripal_chado/includes/tripal_chado.db.inc

@@ -1,15 +1,11 @@
 <?php
 <?php
-/**
- * @file
- * Provide administration of dbs & dbxrefs
- */
 
 
 /**
 /**
  * Launchpad for database reference administration
  * Launchpad for database reference administration
  *
  *
  * @ingroup tripal_db
  * @ingroup tripal_db
  */
  */
-function tripal_db_admin_db_listing() {
+function tripal_chado_admin_db_listing() {
   $output = '';
   $output = '';
 
 
   // set the breadcrumb
   // set the breadcrumb
@@ -17,8 +13,9 @@ function tripal_db_admin_db_listing() {
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
-  $breadcrumb[] = l('Chado Modules', 'admin/tripal/legacy');
-  $breadcrumb[] = l('Databases', 'admin/tripal/legacy/tripal_db');
+  $breadcrumb[] = l('Data Storage', 'admin/tripal/storage');
+  $breadcrumb[] = l('Chado', 'admin/tripal/storage/chado');
+  $breadcrumb[] = l('Databases', 'admin/tripal/storage/chado/db');
   drupal_set_breadcrumb($breadcrumb);
   drupal_set_breadcrumb($breadcrumb);
 
 
   // Add the view
   // Add the view
@@ -29,15 +26,15 @@ function tripal_db_admin_db_listing() {
   }
   }
   else {
   else {
     $output .= '<p>The Tripal DB Module uses primarily views to provide an '
     $output .= '<p>The Tripal DB 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>';
+        . '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 .= '<ul>';
     if (!isset($dbs_view)) {
     if (!isset($dbs_view)) {
-      $output .= '<li>'.l('DB Admin', 'admin/tripal/legacy/tripal_db/views/dbs/enable').'</li>';
+      $output .= '<li>'.l('DB Admin', 'admin/tripal/storage/chado/db/views/dbs/enable').'</li>';
     }
     }
     if (!isset($dbxrefs_view)) {
     if (!isset($dbxrefs_view)) {
-      $output .= '<li>'.l('DB Reference Admin', 'admin/tripal/legacy/tripal_db/views/dbxrefs/enable').'</li>';
+      $output .= '<li>'.l('DB Reference Admin', 'admin/tripal/storage/chado/db/views/dbxrefs/enable').'</li>';
     }
     }
     $output .= '</ul>';
     $output .= '</ul>';
   }
   }
@@ -51,7 +48,7 @@ function tripal_db_admin_db_listing() {
  *
  *
  * @ingroup tripal_db
  * @ingroup tripal_db
  */
  */
-function tripal_db_db_edit_form($form, &$form_state) {
+function tripal_chado_db_edit_form($form, &$form_state) {
 
 
   // get the dbid if form was submitted via AJAX
   // get the dbid if form was submitted via AJAX
   $dbid = 0;
   $dbid = 0;
@@ -77,7 +74,7 @@ function tripal_db_db_edit_form($form, &$form_state) {
     '#type' => 'select',
     '#type' => 'select',
     '#options' => $dbs,
     '#options' => $dbs,
     '#ajax' => array(
     '#ajax' => array(
-      'callback' => 'tripal_db_edit_form_ajax',
+      'callback' => 'tripal_chado_edit_form_ajax',
       'wrapper'  => 'db-edit-div',
       'wrapper'  => 'db-edit-div',
       'effect'   => 'fade',
       'effect'   => 'fade',
       'event'    => 'change',
       'event'    => 'change',
@@ -90,7 +87,7 @@ function tripal_db_db_edit_form($form, &$form_state) {
   // if we don't have a db_id then we can  return the form, otherwise
   // if we don't have a db_id then we can  return the form, otherwise
   // add in the other fields
   // add in the other fields
   if ($dbid) {
   if ($dbid) {
-    tripal_db_add_db_form_fields($form, $form_state, $dbid);
+    tripal_chado_add_db_form_fields($form, $form_state, $dbid);
 
 
     $form['update'] = array(
     $form['update'] = array(
       '#type'         => 'submit',
       '#type'         => 'submit',
@@ -120,10 +117,10 @@ function tripal_db_db_edit_form($form, &$form_state) {
  *
  *
  * @ingroup tripal_db
  * @ingroup tripal_db
  */
  */
-function tripal_db_db_add_form($form, &$form_state) {
+function tripal_chado_db_add_form($form, &$form_state) {
 
 
   // add in the form fields to this form
   // add in the form fields to this form
-  tripal_db_add_db_form_fields($form, $form_state);
+  tripal_chado_add_db_form_fields($form, $form_state);
 
 
   $form['add'] = array(
   $form['add'] = array(
     '#type'         => 'submit',
     '#type'         => 'submit',
@@ -138,7 +135,7 @@ function tripal_db_db_add_form($form, &$form_state) {
  *
  *
  * @ingroup tripal_db
  * @ingroup tripal_db
  */
  */
-function tripal_db_add_db_form_fields(&$form, $form_state, $dbid = NULL) {
+function tripal_chado_add_db_form_fields(&$form, $form_state, $dbid = NULL) {
 
 
   $default_db        = '';
   $default_db        = '';
   $default_desc      = '';
   $default_desc      = '';
@@ -201,8 +198,8 @@ function tripal_db_add_db_form_fields(&$form, $form_state, $dbid = NULL) {
  *
  *
  * @ingroup tripal_db
  * @ingroup tripal_db
  */
  */
-function tripal_db_db_add_form_validate($form, &$form_state) {
-  tripal_db_form_fields_validate($form, $form_state);
+function tripal_chado_db_add_form_validate($form, &$form_state) {
+  tripal_chado_db_form_fields_validate($form, $form_state);
 }
 }
 
 
 /**
 /**
@@ -210,8 +207,8 @@ function tripal_db_db_add_form_validate($form, &$form_state) {
  *
  *
  * @ingroup tripal_db
  * @ingroup tripal_db
  */
  */
-function tripal_db_db_edit_form_validate($form, &$form_state) {
-  tripal_db_form_fields_validate($form, $form_state);
+function tripal_chado_db_edit_form_validate($form, &$form_state) {
+  tripal_chado_db_form_fields_validate($form, $form_state);
 }
 }
 
 
 /**
 /**
@@ -219,7 +216,7 @@ function tripal_db_db_edit_form_validate($form, &$form_state) {
  *
  *
  * @ingroup tripal_db
  * @ingroup tripal_db
  */
  */
-function tripal_db_form_fields_validate($form, &$form_state) {
+function tripal_chado_db_form_fields_validate($form, &$form_state) {
   $name =  array_key_exists('name', $form_state['values'])        ? trim($form_state['values']['name']) : '';
   $name =  array_key_exists('name', $form_state['values'])        ? trim($form_state['values']['name']) : '';
   $desc =  array_key_exists('description', $form_state['values']) ? trim($form_state['values']['description']) : '';
   $desc =  array_key_exists('description', $form_state['values']) ? trim($form_state['values']['description']) : '';
   $url  =  array_key_exists('url', $form_state['values'])         ? trim($form_state['values']['url']) : '';
   $url  =  array_key_exists('url', $form_state['values'])         ? trim($form_state['values']['url']) : '';
@@ -237,9 +234,8 @@ function tripal_db_form_fields_validate($form, &$form_state) {
 /**
 /**
  * Submit for add db form
  * Submit for add db form
  *
  *
- * @ingroup tripal_db
  */
  */
-function tripal_db_db_add_form_submit($form, &$form_state) {
+function tripal_chado_db_add_form_submit($form, &$form_state) {
 
 
   $name =  array_key_exists('name', $form_state['values'])        ? trim($form_state['values']['name']) : '';
   $name =  array_key_exists('name', $form_state['values'])        ? trim($form_state['values']['name']) : '';
   $desc =  array_key_exists('description', $form_state['values']) ? trim($form_state['values']['description']) : '';
   $desc =  array_key_exists('description', $form_state['values']) ? trim($form_state['values']['description']) : '';
@@ -264,9 +260,8 @@ function tripal_db_db_add_form_submit($form, &$form_state) {
 /**
 /**
  * Submit for edit db form
  * Submit for edit db form
  *
  *
- * @ingroup tripal_db
  */
  */
-function tripal_db_db_edit_form_submit($form, &$form_state) {
+function tripal_chado_db_edit_form_submit($form, &$form_state) {
 
 
   $name =  array_key_exists('name', $form_state['values'])        ? trim($form_state['values']['name']) : '';
   $name =  array_key_exists('name', $form_state['values'])        ? trim($form_state['values']['name']) : '';
   $desc =  array_key_exists('description', $form_state['values']) ? trim($form_state['values']['description']) : '';
   $desc =  array_key_exists('description', $form_state['values']) ? trim($form_state['values']['description']) : '';
@@ -287,6 +282,7 @@ function tripal_db_db_edit_form_submit($form, &$form_state) {
     $success = chado_update_record('db', $match, $values);
     $success = chado_update_record('db', $match, $values);
     if ($success) {
     if ($success) {
       drupal_set_message(t("External database updated"));
       drupal_set_message(t("External database updated"));
+      drupal_goto('admin/tripal/storage/chado/db');
     }
     }
     else {
     else {
       drupal_set_message(t("Failed to update external database."));
       drupal_set_message(t("Failed to update external database."));
@@ -297,6 +293,7 @@ function tripal_db_db_edit_form_submit($form, &$form_state) {
     $success = chado_delete_record('db', $match);
     $success = chado_delete_record('db', $match);
     if ($success) {
     if ($success) {
       drupal_set_message(t("External database deleted"));
       drupal_set_message(t("External database deleted"));
+      drupal_goto('admin/tripal/storage/chado/db');
     }
     }
     else {
     else {
       drupal_set_message(t("Failed to delete external database."));
       drupal_set_message(t("Failed to delete external database."));
@@ -305,11 +302,10 @@ function tripal_db_db_edit_form_submit($form, &$form_state) {
 }
 }
 
 
 /**
 /**
- * Ajax callback for the tripal_db_form
+ * Ajax callback for the tripal_chado_db_form
  *
  *
- * @ingroup tripal_db
  */
  */
-function tripal_db_edit_form_ajax($form, $form_state) {
+function tripal_chado_db_edit_form_ajax($form, $form_state) {
 
 
   $elements = array();
   $elements = array();
 
 
@@ -320,7 +316,7 @@ function tripal_db_edit_form_ajax($form, $form_state) {
     $elements['delete'] = $form['delete'];
     $elements['delete'] = $form['delete'];
   }
   }
 
 
-   // add back in the db-edit-div that is used for the next round of AJAX
+  // add back in the db-edit-div that is used for the next round of AJAX
   $elements['fields']['#prefix'] =  '<div id="db-edit-div">';
   $elements['fields']['#prefix'] =  '<div id="db-edit-div">';
   $elements['fields']['#suffix'] =  '</div">';
   $elements['fields']['#suffix'] =  '</div">';
 
 
@@ -333,4 +329,4 @@ function tripal_db_edit_form_ajax($form, $form_state) {
   //drupal_set_message('<pre>' . print_r($elements, TRUE) . '</pre>', "status");
   //drupal_set_message('<pre>' . print_r($elements, TRUE) . '</pre>', "status");
 
 
   return $elements;
   return $elements;
-}
+}

+ 2 - 2
tripal_chado/includes/tripal_chado.install.inc

@@ -140,9 +140,9 @@ function tripal_chado_load_form_validate($form, &$form_state) {
       $form_state['values']['action_to_do'] == "Install Chado v1.11") {
       $form_state['values']['action_to_do'] == "Install Chado v1.11") {
 
 
     $modules = system_get_info('module');
     $modules = system_get_info('module');
-    // The tripal_views module should not be included as it's a rquired
+    // The tripal_chado_iews module should not be included as it's a required
     // dependency of tripal_chado
     // dependency of tripal_chado
-    unset($modules['tripal_views']);
+    unset($modules['tripal_chado_views']);
     $list = array();
     $list = array();
     foreach ($modules as $mname => $module) {
     foreach ($modules as $mname => $module) {
       if (array_key_exists('dependencies', $module) and in_array('tripal_chado', $module['dependencies'])) {
       if (array_key_exists('dependencies', $module) and in_array('tripal_chado', $module['dependencies'])) {

+ 39 - 59
tripal_chado/includes/tripal_chado.semweb.inc

@@ -5,20 +5,6 @@
  */
  */
 function tripal_chado_populate_chado_semweb_table() {
 function tripal_chado_populate_chado_semweb_table() {
 
 
-  // Insert commonly used ontologies into the tables.
-  $ontologies = array(
-    // array('Relationship Ontology', 'http://purl.obolibrary.org/obo/ro.obo'),
-    array('Relationship Ontology (legacy)', '{tripal_chado}/files/legacy_ro.obo'),
-    array('Sequence Ontology', 'http://purl.obolibrary.org/obo/so.obo'),
-    array('Gene Ontology', 'http://purl.obolibrary.org/obo/go.obo'),
-    //    array('Cell Ontology', 'https://raw.githubusercontent.com/obophenotype/cell-ontology/master/cl.obo'),
-    //    array('Plant Structure Ontology', 'http://palea.cgrb.oregonstate.edu/viewsvn/Poc/trunk/ontology/OBO_format/po_anatomy.obo?view=co'),
-    //    array('Plant Growth and Development Stages Ontology', 'http://palea.cgrb.oregonstate.edu/viewsvn/Poc/trunk/ontology/OBO_format/po_temporal.obo?view=co')
-  );
-  foreach ($ontologies as $o) {
-  db_query("INSERT INTO {tripal_cv_obo} (name,path) VALUES (:name, :path)", array(':name' => $o[0], ':path' => $o[1]));
-  }
-
   // Add in all tables and fields into the chado_semweb table.
   // Add in all tables and fields into the chado_semweb table.
   $chado_tables = chado_get_table_names(TRUE);
   $chado_tables = chado_get_table_names(TRUE);
   foreach ($chado_tables as $chado_table) {
   foreach ($chado_tables as $chado_table) {
@@ -48,53 +34,10 @@ function tripal_chado_populate_chado_semweb_table() {
   tripal_chado_populate_vocab_SO();
   tripal_chado_populate_vocab_SO();
   tripal_chado_populate_vocab_SWO();
   tripal_chado_populate_vocab_SWO();
   tripal_chado_populate_vocab_TAXRANK();
   tripal_chado_populate_vocab_TAXRANK();
+  tripal_chado_populate_vocab_TCONTACT();
   tripal_chado_populate_vocab_TPUB();
   tripal_chado_populate_vocab_TPUB();
   tripal_chado_populate_vocab_UO();
   tripal_chado_populate_vocab_UO();
 
 
-  // Add TAXRANK vocabulary for full import.
-  $obo_id = tripal_insert_obo('Taxonomic Rank', 'http://purl.obolibrary.org/obo/taxrank.obo');
-  $cv = chado_select_record('cv', array('name'), array('name' => 'taxonomic_rank'));
-  if (count($cv) == 0 and $obo_id) {
-    tripal_chado_load_obo_v1_2_id($obo_id);
-  }
-  //tripal_submit_obo_job(array('obo_id' => $obo_id));
-
-  // Add Tripal Contact vocabulary for full import.
-  $obo_path = '{tripal_chado}/files/tcontact.obo';
-  $obo_id = tripal_insert_obo('Tripal Contacts', $obo_path);
-  $cv = chado_select_record('cv', array('name'), array('name' => 'tripal_contact'));
-  if (count($cv) == 0 and $obo) {
-    tripal_chado_load_obo_v1_2_id($obo_id);
-  }
-  //tripal_submit_obo_job(array('obo_id' => $obo_id));
-
-  // Add Tripal Publication vocabulary for full import.
-  $obo_path = '{tripal_chado}/files/tpub.obo';
-  $obo_id = tripal_insert_obo('Tripal Publication', $obo_path);
-  $cv = chado_select_record('cv', array('name'), array('name' => 'tripal_pub'));
-  if (count($cv) == 0 and $obo) {
-    tripal_chado_load_obo_v1_2_id($obo_id);
-  }
-
-  // Load the sequence ontology if it isn't already loaded
-  $cv = chado_select_record('cv', array('name'), array('name' => 'sequence'));
-  $obo = tripal_get_obo(array('obo_name' => 'Sequence Ontology'));
-  if (count($cv) == 0 and $obo) {
-    print "Installing the Sequence Ontology... This may take a while...\n";
-    tripal_chado_load_obo_v1_2_id($obo->obo_id);
-  }
-
-  // Add the Chado ontology CV.
-  //$obo_path = '{tripal_chado}/files/cv_property.obo';
-  //$obo_id = tripal_insert_obo('Chado CV Properties', $obo_path);
-  //tripal_chado_load_obo_v1_2_id($obo_id);
-  //tripal_submit_obo_job(array('obo_id' => $obo_id));
-
-  // $obo_path = '{tripal_feature}/files/feature_property.obo';
-  // $obo_id = tripal_insert_obo('Chado Feature Properties', $obo_path);
-  // tripal_chado_load_obo_v1_2_id($obo_id);
-  //// tripal_submit_obo_job(array('obo_id' => $obo_id));
-
 }
 }
 
 
 /**
 /**
@@ -473,6 +416,10 @@ function tripal_chado_populate_vocab_IAO() {
  */
  */
 function tripal_chado_populate_vocab_LOCAL() {
 function tripal_chado_populate_vocab_LOCAL() {
 
 
+  tripal_insert_db(array(
+    'name' => 'null',
+    'description' => 'No online database.'
+  ));
   tripal_insert_db(array(
   tripal_insert_db(array(
     'name' => 'local',
     'name' => 'local',
     'description' => 'Terms created for this site.',
     'description' => 'Terms created for this site.',
@@ -1235,9 +1182,42 @@ function tripal_chado_populate_vocab_SWO() {
 }
 }
 
 
 /**
 /**
- * Adds the pub table mapping.
+ * Adds the contact table mapping.
+ */
+function tripal_chado_populate_vocab_TCONTACT() {
+  tripal_insert_db(array(
+    'name' => 'TContact',
+    'description' => 'The Tripal Contact controlled vocabulary.',
+  ));
+}
+
+/**
+ * Adds the pub table mappings.
  */
  */
 function tripal_chado_populate_vocab_TPUB() {
 function tripal_chado_populate_vocab_TPUB() {
+
+  tripal_insert_db(array(
+    'name' => 'TPUB',
+    'description' => 'The Tripal Publication controlled vocabulary.',
+  ));
+  // make sure we have our supported databases
+  tripal_insert_db(
+      array(
+        'name' => 'PMID',
+        'description' => 'PubMed',
+        'url' => 'http://www.ncbi.nlm.nih.gov/pubmed',
+        'urlprefix' => 'http://www.ncbi.nlm.nih.gov/pubmed/'
+      ),
+      array('update_existing' => TRUE)
+  );
+  tripal_insert_db(
+      array(
+        'name' => 'AGL',
+        'description' => 'USDA National Agricultural Library',
+        'url' => 'http://agricola.nal.usda.gov/'
+      ),
+      array('update_existing' => TRUE)
+  );
   $term = tripal_get_cvterm(array('id' => 'TPUB:0000039'));
   $term = tripal_get_cvterm(array('id' => 'TPUB:0000039'));
   tripal_associate_chado_semweb_term('pub', 'title', $term);
   tripal_associate_chado_semweb_term('pub', 'title', $term);
 
 

+ 107 - 167
tripal_chado/includes/tripal_chado.setup.inc

@@ -63,163 +63,123 @@ function tripal_chado_prepare_form_submit($form, $form_state) {
    }
    }
 }
 }
 
 
+/**
+ *
+ */
+function tripal_chado_load_ontologies() {
+
+  // Insert commonly used ontologies into the tables.
+  $ontologies = array(
+    array(
+      'name' => 'Relationship Ontology (legacy)',
+      'path' => '{tripal_chado}/files/legacy_ro.obo',
+      'auto_load' => FALSE,
+    ),
+    array(
+      'name' => 'Gene Ontology',
+      'path' => 'http://purl.obolibrary.org/obo/go.obo',
+      'auto_load' => FALSE,
+    ),
+    array(
+      'name' => 'Taxonomic Rank',
+      'path' => 'http://purl.obolibrary.org/obo/taxrank.obo',
+      'auto_load' => TRUE,
+    ),
+    array(
+      'name' => 'Tripal Contact',
+      'path' => '{tripal_chado}/files/tcontact.obo',
+      'auto_load' => TRUE,
+    ),
+    array(
+      'name' => 'Tripal Publication',
+      'path' => '{tripal_chado}/files/tpub.obo',
+      'auto_load' => TRUE,
+    ),
+    array(
+      'name' => 'Sequence Ontology',
+      'path' => 'http://purl.obolibrary.org/obo/so.obo',
+      'auto_load' => TRUE,
+    ),
+
+  );
+  for ($i = 0; $i < count($ontologies); $i++) {
+    $obo_id = tripal_insert_obo($ontologies[$i]['name'], $ontologies[$i]['path']);
+    if ($ontologies[$i]['auto_load'] == TRUE) {
+      tripal_chado_load_obo_v1_2_id($obo_id);
+    }
+  }
+}
 /**
 /**
  * Prepares Chado for use by Tripal.
  * Prepares Chado for use by Tripal.
  */
  */
 function tripal_chado_prepare_chado() {
 function tripal_chado_prepare_chado() {
 
 
   try {
   try {
-    // we want to force the version of Chado to be set properly
-    $real_version = chado_get_version(TRUE);
 
 
-    // get the effective version.  Pass true as second argument
-    // to warn the user if the current version is not compatible
+    // Get the effective version.  Pass true as second argument
+    // to warn the user if the current version is not compatible.
     $version = chado_get_version(FALSE, FALSE);
     $version = chado_get_version(FALSE, FALSE);
 
 
+    // We want to force the version of Chado to be set properly.
+    $real_version = chado_get_version(TRUE);
+
+    // Import commonly used ontologies if needed.
+    tripal_chado_load_ontologies();
 
 
-    ///////////////////////////////////////////////////////////////////////////
-    //                          Chado DB Module
-    ///////////////////////////////////////////////////////////////////////////
-    tripal_insert_db(array(
-      'name' => 'null',
-      'description' => 'No online database.'
-    ));
-    tripal_insert_db(array(
-      'name' => 'local',
-      'description' => variable_get('site_name', 'This site.'),
-    ));
+    // Populate the semantic web associations for Chado tables/fields.
+    module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.semweb');
+    tripal_chado_populate_chado_semweb_table();
 
 
-    ///////////////////////////////////////////////////////////////////////////
-    //                          Chado CV Module
-    ///////////////////////////////////////////////////////////////////////////
-    // Add the cv_root_mview.
-    tripal_cv_add_cv_root_mview();
+    // Initialize the population of the chado_cvterm_mapping table.  This will
+    // map existing data types already in Chado so that when users want to
+    // add new content types it simplifies the form for them.
+    tripal_chado_map_cvterms();
 
 
+    // Add the cv_root_mview.
+    tripal_chado_add_cv_root_mview_mview();
 
 
     // Create the temp table we will use for loading OBO files.
     // Create the temp table we will use for loading OBO files.
-    tripal_cv_create_tripal_obo_temp();
+    tripal_chado_add_tripal_obo_temp_table();
 
 
-
-    /////////////////////////////////////////////////////////////////////////////
-    //                        Chado CompAnalysis Module
-    /////////////////////////////////////////////////////////////////////////////
+    // Support for Analyses
     // we may need the analysisfeatureprop table if it doesn't already exist
     // we may need the analysisfeatureprop table if it doesn't already exist
-    tripal_analysis_create_analysisfeatureprop();
+    tripal_chado_add_analysisfeatureprop_table();
 
 
     // add materialized views
     // add materialized views
-    tripal_analysis_add_mview_analysis_organism();
-
-    // set the default vocabularies
-    //tripal_set_default_cv('analysisprop', 'type_id', 'analysis_property');
+    tripal_chado_add_analysis_organism_mview();
 
 
-    /////////////////////////////////////////////////////////////////////////////
-    //                        Chado Contact Module
-    /////////////////////////////////////////////////////////////////////////////
+    // Support for Contacts
     // Add the contactprop table to Chado.
     // Add the contactprop table to Chado.
-    tripal_contact_add_custom_tables();
-
-    tripal_insert_db(array(
-      'name' => 'TContact',
-      'description' => 'The Tripal Contact controlled vocabulary.',
-    ));
-    tripal_insert_db(array(
-      'name' => 'TPUB',
-      'description' => 'The Tripal Publication controlled vocabulary.',
-    ));
-
-    // Set the default vocabularies.
-    //('contact', 'type_id', 'tripal_contact');
-    //tripal_set_default_cv('contactprop', 'type_id', 'tripal_contact');
-    //tripal_set_default_cv('contact_relationship', 'type_id', 'contact_relationship');
-
-    /////////////////////////////////////////////////////////////////////////////
-    //                        Chado Feature Module
-    /////////////////////////////////////////////////////////////////////////////
-    // Note: the feature_property OBO that came with Chado v1.2 should not
-    // be automatically installed.  Some of the terms are duplicates of
-    // others in better maintained vocabularies.  New Tripal sites should
-    // use those.
+    tripal_chado_add_contactprop_table();
 
 
+    // Support for Features
     // Add the materialized view.
     // Add the materialized view.
-    tripal_feature_add_organism_count_mview();
-
-    // Add the custom tables.
-    tripal_feature_add_tripal_gff_temp_table();
-    tripal_feature_add_tripal_gffcds_temp_table();
-    tripal_feature_add_tripal_gffprotein_temp_table();
+    tripal_chado_add_organism_feature_count_mview();
 
 
-    // Set the default vocabularies.
-    //tripal_set_default_cv('feature', 'type_id', 'sequence');
-    //tripal_set_default_cv('featureprop', 'type_id', 'feature_property');
-    //tripal_set_default_cv('feature_relationship', 'type_id', 'feature_relationship');
+    // Add the custom tables for the GFF loader.
+    tripal_chado_add_tripal_gff_temp_table();
+    tripal_chado_add_tripal_gffcds_temp_table();
+    tripal_chado_add_tripal_gffprotein_temp_table();
 
 
-    /////////////////////////////////////////////////////////////////////////////
-    //                            Chado Map Module
-    /////////////////////////////////////////////////////////////////////////////
+    // Support for FeatureMaps.
     // add the featuremapprop table to Chado
     // add the featuremapprop table to Chado
-    tripal_featuremap_add_custom_tables();
+    tripal_chado_add_featuremap_dbxref_table();
+    tripal_chado_add_featuremapprop_table();
+    tripal_chado_add_featuremappos_table();
 
 
-    // set the default vocabularies
-    //tripal_set_default_cv('featuremapprop', 'type_id', 'featuremap_property');
-    //tripal_set_default_cv('featureposprop', 'type_id', 'featurepos_property');
-    //tripal_set_default_cv('featuremap', 'unittype_id', 'featuremap_units');
-
-    /////////////////////////////////////////////////////////////////////////////
-    //                          Chado Library Module
-    /////////////////////////////////////////////////////////////////////////////
+    // Support for Libraries.
     // add the materialized view
     // add the materialized view
-    tripal_library_add_mview_library_feature_count();
-
-    // set the default vocabularies
-    //tripal_set_default_cv('libraryprop', 'type_id', 'library_property');
-    //tripal_set_default_cv('library', 'type_id', 'library_type');
-
-
-    /////////////////////////////////////////////////////////////////////////////
-    //                          Chado Project Module
-    /////////////////////////////////////////////////////////////////////////////
-
-    // set the default vocabularies
-    //tripal_set_default_cv('projectprop', 'type_id', 'project_property');
-    ///tripal_set_default_cv('project_relationship', 'type_id', 'project_relationship');
-
-    /////////////////////////////////////////////////////////////////////////////
-    //                          Chado Pub Module
-    /////////////////////////////////////////////////////////////////////////////
-    global $base_path;
-
-    tripal_pub_add_dbs();
+    tripal_chado_add_library_feature_count_mview();
 
 
+    // Support for Pubs.
     // add the custom tables
     // add the custom tables
-    tripal_pub_add_custom_tables();
-
-    // set the default vocabularies
-    //tripal_set_default_cv('pub', 'type_id', 'tripal_pub');
-    //tripal_set_default_cv('pubprop', 'type_id', 'tripal_pub');
-    //tripal_set_default_cv('pub_relationship', 'type_id', 'pub_relationship');
-
+    tripal_chado_add_pubauthor_contact_table();
     // Add the supported loaders
     // Add the supported loaders
     variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));
     variable_set('tripal_pub_supported_dbs', array('PMID', 'AGL'));
 
 
-    /////////////////////////////////////////////////////////////////////////////
-      //                          Chado Stock Module
-      /////////////////////////////////////////////////////////////////////////////
-    // set the default vocabularies
-    //tripal_set_default_cv('stock', 'type_id', 'stock_type');
-    //tripal_set_default_cv('stockprop', 'type_id', 'stock_property');
-    //tripal_set_default_cv('stock_relationship', 'type_id', 'stock_relationship');
-
+    // Support for Stocks.
     // add the materialized view
     // add the materialized view
-    tripal_stock_add_organism_count_mview();
-
-    /////////////////////////////////////////////////////////////////////////////
-    //                              Entity Bundles
-    /////////////////////////////////////////////////////////////////////////////
-
-    // First, populate the semantic web associations for Chado tables/fields.
-    module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.semweb');
-    tripal_chado_populate_chado_semweb_table();
-
+    tripal_chado_add_organism_stock_count_mview();
 
 
     // We want to provide a set of commonly used entity types by default. This
     // We want to provide a set of commonly used entity types by default. This
     // way when a user first installs Tripal there are some commonly used
     // way when a user first installs Tripal there are some commonly used
@@ -327,9 +287,6 @@ function tripal_chado_prepare_chado() {
       throw new Exception($error['!message']);
       throw new Exception($error['!message']);
     }
     }
 
 
-    // Initialize the population of the chado_cvterm_mapping table.
-    tripal_chado_map_cvterms();
-
     // Set a variable to indicate the site is prepared.
     // Set a variable to indicate the site is prepared.
     variable_set('tripal_chado_is_prepared', TRUE);
     variable_set('tripal_chado_is_prepared', TRUE);
   }
   }
@@ -343,7 +300,7 @@ function tripal_chado_prepare_chado() {
  *
  *
  * @ingroup tripal_stock
  * @ingroup tripal_stock
  */
  */
-function tripal_stock_add_organism_count_mview() {
+function tripal_chado_add_organism_stock_count_mview() {
   $view_name = 'organism_stock_count';
   $view_name = 'organism_stock_count';
   $comment = 'Stores the type and number of stocks per organism';
   $comment = 'Stores the type and number of stocks per organism';
 
 
@@ -414,7 +371,7 @@ function tripal_stock_add_organism_count_mview() {
  *
  *
  * @ingroup tripal_pub
  * @ingroup tripal_pub
  */
  */
-function tripal_pub_add_custom_tables() {
+function tripal_chado_add_pubauthor_contact_table() {
   $schema = array (
   $schema = array (
     'table' => 'pubauthor_contact',
     'table' => 'pubauthor_contact',
     'fields' => array (
     'fields' => array (
@@ -458,38 +415,13 @@ function tripal_pub_add_custom_tables() {
   chado_create_custom_table('pubauthor_contact', $schema, TRUE);
   chado_create_custom_table('pubauthor_contact', $schema, TRUE);
 }
 }
 
 
-/**
- * Adds dbs related to publications
- *
- * @ingroup tripal_pub
- */
-function tripal_pub_add_dbs() {
-  // make sure we have our supported databases
-  tripal_insert_db(
-      array(
-        'name' => 'PMID',
-        'description' => 'PubMed',
-        'url' => 'http://www.ncbi.nlm.nih.gov/pubmed',
-        'urlprefix' => 'http://www.ncbi.nlm.nih.gov/pubmed/'
-      ),
-      array('update_existing' => TRUE)
-  );
-  tripal_insert_db(
-      array(
-        'name' => 'AGL',
-        'description' => 'USDA National Agricultural Library',
-        'url' => 'http://agricola.nal.usda.gov/'
-      ),
-      array('update_existing' => TRUE)
-  );
-}
 
 
 /**
 /**
  * Adds a materialized view keeping track of the type of features associated with each library
  * Adds a materialized view keeping track of the type of features associated with each library
  *
  *
  * @ingroup tripal_library
  * @ingroup tripal_library
  */
  */
-function tripal_library_add_mview_library_feature_count(){
+function tripal_chado_add_library_feature_count_mview(){
   $view_name = 'library_feature_count';
   $view_name = 'library_feature_count';
   $comment = 'Provides count of feature by type that are associated with all libraries';
   $comment = 'Provides count of feature by type that are associated with all libraries';
 
 
@@ -545,7 +477,7 @@ function tripal_library_add_mview_library_feature_count(){
  *
  *
  * @ingroup tripal_featuremap
  * @ingroup tripal_featuremap
  */
  */
-function tripal_featuremap_add_custom_tables(){
+function tripal_chado_add_featuremapprop_table(){
   // add the featuremaprop table to Chado
   // add the featuremaprop table to Chado
   $schema = array (
   $schema = array (
     'table' => 'featuremapprop',
     'table' => 'featuremapprop',
@@ -606,7 +538,11 @@ function tripal_featuremap_add_custom_tables(){
     ),
     ),
   );
   );
   chado_create_custom_table('featuremapprop', $schema, TRUE);
   chado_create_custom_table('featuremapprop', $schema, TRUE);
-
+}
+/**
+ *
+ */
+function tripal_chado_add_featuremap_dbxref_table(){
   // add the featuremap_dbxref table to Chado
   // add the featuremap_dbxref table to Chado
   $schema = array (
   $schema = array (
     'table' => 'featuremap_dbxref',
     'table' => 'featuremap_dbxref',
@@ -658,7 +594,11 @@ function tripal_featuremap_add_custom_tables(){
     'referring_tables' => NULL,
     'referring_tables' => NULL,
   );
   );
   chado_create_custom_table('featuremap_dbxref', $schema, TRUE);
   chado_create_custom_table('featuremap_dbxref', $schema, TRUE);
-
+}
+/**
+ *
+ */
+function tripal_chado_add_featureposprop_table(){
   $schema = array (
   $schema = array (
     'table' => 'featureposprop',
     'table' => 'featureposprop',
     'fields' => array (
     'fields' => array (
@@ -723,7 +663,7 @@ function tripal_featuremap_add_custom_tables(){
 /**
 /**
  *
  *
  */
  */
-function tripal_feature_add_tripal_gff_temp_table() {
+function tripal_chado_add_tripal_gff_temp_table() {
   $schema = array(
   $schema = array(
     'table' => 'tripal_gff_temp',
     'table' => 'tripal_gff_temp',
     'fields' => array(
     'fields' => array(
@@ -761,7 +701,7 @@ function tripal_feature_add_tripal_gff_temp_table() {
 /**
 /**
  *
  *
  */
  */
-function tripal_feature_add_tripal_gffcds_temp_table($skip_recreate = TRUE) {
+function tripal_chado_add_tripal_gffcds_temp_table($skip_recreate = TRUE) {
   $schema = array(
   $schema = array(
     'table' => 'tripal_gffcds_temp',
     'table' => 'tripal_gffcds_temp',
     'fields' => array(
     'fields' => array(
@@ -801,7 +741,7 @@ function tripal_feature_add_tripal_gffcds_temp_table($skip_recreate = TRUE) {
 /**
 /**
  *
  *
  */
  */
-function tripal_feature_add_tripal_gffprotein_temp_table() {
+function tripal_chado_add_tripal_gffprotein_temp_table() {
   $schema = array(
   $schema = array(
     'table' => 'tripal_gffprotein_temp',
     'table' => 'tripal_gffprotein_temp',
     'fields' => array(
     'fields' => array(
@@ -837,7 +777,7 @@ function tripal_feature_add_tripal_gffprotein_temp_table() {
  *
  *
  * @ingroup tripal_feature
  * @ingroup tripal_feature
  */
  */
-function tripal_feature_add_organism_count_mview() {
+function tripal_chado_add_organism_feature_count_mview() {
   $view_name = 'organism_feature_count';
   $view_name = 'organism_feature_count';
   $comment = 'Stores the type and number of features per organism';
   $comment = 'Stores the type and number of features per organism';
 
 
@@ -907,7 +847,7 @@ function tripal_feature_add_organism_count_mview() {
  *
  *
  * @ingroup tripal_contact
  * @ingroup tripal_contact
  */
  */
-function tripal_contact_add_custom_tables(){
+function tripal_chado_add_contactprop_table(){
   $schema = array (
   $schema = array (
     'table' => 'contactprop',
     'table' => 'contactprop',
     'fields' => array (
     'fields' => array (
@@ -974,7 +914,7 @@ function tripal_contact_add_custom_tables(){
  *
  *
  * @ingroup tripal_analysis
  * @ingroup tripal_analysis
  */
  */
-function tripal_analysis_create_analysisfeatureprop() {
+function tripal_chado_add_analysisfeatureprop_table() {
 
 
   // Create analysisfeatureprop table in chado.  This is needed for Chado
   // Create analysisfeatureprop table in chado.  This is needed for Chado
   // version 1.11, the table exists in Chado 1.2.
   // version 1.11, the table exists in Chado 1.2.
@@ -999,7 +939,7 @@ function tripal_analysis_create_analysisfeatureprop() {
  *
  *
  * @ingroup tripal_analysis
  * @ingroup tripal_analysis
  */
  */
-function tripal_analysis_add_mview_analysis_organism() {
+function tripal_chado_add_analysis_organism_mview() {
   $view_name = 'analysis_organism';
   $view_name = 'analysis_organism';
   $comment = t('This view is for associating an organism (via it\'s associated features) to an analysis.');
   $comment = t('This view is for associating an organism (via it\'s associated features) to an analysis.');
 
 
@@ -1059,7 +999,7 @@ function tripal_analysis_add_mview_analysis_organism() {
  *
  *
  * @ingroup tripal_cv
  * @ingroup tripal_cv
  */
  */
-function tripal_cv_add_cv_root_mview() {
+function tripal_chado_add_cv_root_mview_mview() {
   $mv_name = 'cv_root_mview';
   $mv_name = 'cv_root_mview';
   $comment = 'A list of the root terms for all controlled vocabularies. This is needed for viewing CV trees';
   $comment = 'A list of the root terms for all controlled vocabularies. This is needed for viewing CV trees';
   $schema = array(
   $schema = array(
@@ -1110,7 +1050,7 @@ function tripal_cv_add_cv_root_mview() {
  *
  *
  * @ingroup tripal_cv
  * @ingroup tripal_cv
  */
  */
-function tripal_cv_create_tripal_obo_temp() {
+function tripal_chado_add_tripal_obo_temp_table() {
   // the tripal_obo_temp table is used for temporary housing of records when loading OBO files
   // the tripal_obo_temp table is used for temporary housing of records when loading OBO files
   // we create it here using plain SQL because we want it to be in the chado schema but we
   // we create it here using plain SQL because we want it to be in the chado schema but we
   // do not want to use the Tripal Custom Table API because we don't want it to appear in the
   // do not want to use the Tripal Custom Table API because we don't want it to appear in the

+ 2 - 1
tripal_chado/tripal_chado.info

@@ -14,4 +14,5 @@ stylesheets[all][] = theme/css/tripal_chado.css
 
 
 dependencies[] = tripal
 dependencies[] = tripal
 dependencies[] = date
 dependencies[] = date
-dependencies[] = image
+dependencies[] = image
+dependencies[] = tripal_chado_views

+ 38 - 1
tripal_chado/tripal_chado.module

@@ -585,8 +585,45 @@ function tripal_chado_menu() {
     'file path' => drupal_get_path('module', 'tripal_chado'),
     'file path' => drupal_get_path('module', 'tripal_chado'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
-  return $items;
 
 
+
+  //////////////////////////////////////////////////////////////////////////////
+  //                           Databases
+  //////////////////////////////////////////////////////////////////////////////
+  $items['admin/tripal/storage/chado/db'] = array(
+    'title' => 'Databases',
+    'description' => 'References to External Database sites such as NCBI',
+    'page callback' => 'tripal_chado_admin_db_listing',
+    'access arguments' => array('administer db cross-references'),
+    'file' => 'includes/tripal_chado.db.inc',
+    'file path' => drupal_get_path('module', 'tripal_chado'),
+    'type' => MENU_NORMAL_ITEM,
+  );
+  $items['admin/tripal/storage/chado/db/edit/%'] = array(
+    'title' => 'Edit a Database Reference',
+    'description' => 'Edit existing Database References.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_chado_db_edit_form',6),
+    'access callback' => 'user_access',
+    'access arguments' => array('administer db cross-references'),
+    'file' => 'includes/tripal_chado.db.inc',
+    'file path' => drupal_get_path('module', 'tripal_chado'),
+    'type' => MENU_CALLBACK,
+  );
+
+  $items['admin/tripal/storage/chado/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_chado_db_add_form'),
+    'access callback' => 'user_access',
+    'access arguments' => array('administer db cross-references'),
+    'file' => 'includes/tripal_chado.db.inc',
+    'file path' => drupal_get_path('module', 'tripal_chado'),
+    'type' => MENU_CALLBACK,
+  );
+
+  return $items;
 }
 }
 
 
 /**
 /**

+ 345 - 0
tripal_chado/tripal_chado.views_default.inc

@@ -30,6 +30,16 @@ function tripal_chado_views_default_views() {
   $view = tripal_make_view_compatible_with_external($view);
   $view = tripal_make_view_compatible_with_external($view);
   $views[$view->name] = $view;
   $views[$view->name] = $view;
 
 
+  // Default Tripal Admin View: DB
+  $view = tripal_chado_defaultview_admin_db_listing();
+  $view = tripal_make_view_compatible_with_external($view);
+  $views[$view->name] = $view;
+
+  // Default Tripal Admin View: DB References
+  $view = tripal_chado_defaultview_admin_dbxref_listing();
+  $view = tripal_make_view_compatible_with_external($view);
+  $views[$view->name] = $view;
+
   return $views;
   return $views;
 }
 }
 
 
@@ -867,5 +877,340 @@ function tripal_chado_defaultview_admin_cvterms_listing() {
    $handler->display->display_options['filters']['name_1']['expose']['max_length'] = 40;
    $handler->display->display_options['filters']['name_1']['expose']['max_length'] = 40;
    */
    */
 
 
+  return $view;
+}
+/**
+ * Default Admin View for db management
+ *
+ * @ingroup tripal_db
+ */
+function tripal_chado_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' => '',
+    ),
+    '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/storage/chado/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: 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/storage/chado/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'] = 'items';
+  $handler->display->display_options['fields']['nothing_1']['alter']['make_link'] = TRUE;
+  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/storage/chado/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'] = 'Actions';
+  $handler->display->display_options['fields']['nothing_2']['alter']['text'] = '[nothing] | [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']['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/storage/chado/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_chado_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/storage/chado/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;
   return $view;
 }
 }

+ 17 - 17
legacy/tripal_views/api/tripal_views.DEPRECATED.inc → tripal_chado_views/api/tripal_chado_views.DEPRECATED.inc

@@ -11,7 +11,7 @@
  *
  *
  * @see tripal_enable_view().
  * @see tripal_enable_view().
  */
  */
-function tripal_views_admin_enable_view($view_name, $redirect_link) {
+function tripal_chado_views_admin_enable_view($view_name, $redirect_link) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -33,7 +33,7 @@ function tripal_views_admin_enable_view($view_name, $redirect_link) {
  *
  *
  * @see tripal_disable_view().
  * @see tripal_disable_view().
  */
  */
-function tripal_views_admin_disable_view($view_name, $redirect_link) {
+function tripal_chado_views_admin_disable_view($view_name, $redirect_link) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -55,7 +55,7 @@ function tripal_views_admin_disable_view($view_name, $redirect_link) {
  *
  *
  * @see tripal_make_view_compatible_with_external().
  * @see tripal_make_view_compatible_with_external().
  */
  */
-function tripal_views_make_view_compatible_with_external($view) {
+function tripal_chado_views_make_view_compatible_with_external($view) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -77,7 +77,7 @@ function tripal_views_make_view_compatible_with_external($view) {
  *
  *
  * @see tripal_get_lightest_views_integration_priority().
  * @see tripal_get_lightest_views_integration_priority().
  */
  */
-function tripal_views_get_table_lightest_priority($table_name) {
+function tripal_chado_views_get_table_lightest_priority($table_name) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -99,7 +99,7 @@ function tripal_views_get_table_lightest_priority($table_name) {
  *
  *
  * @see tripal_get_lightest_views_integration_setup().
  * @see tripal_get_lightest_views_integration_setup().
  */
  */
-function tripal_views_get_lightest_priority_setup($table_name) {
+function tripal_chado_views_get_lightest_priority_setup($table_name) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -121,7 +121,7 @@ function tripal_views_get_lightest_priority_setup($table_name) {
  *
  *
  * @see tripal_get_views_integration_setup_id().
  * @see tripal_get_views_integration_setup_id().
  */
  */
-function tripal_views_get_setup_id($table_name, $priority) {
+function tripal_chado_views_get_setup_id($table_name, $priority) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -143,7 +143,7 @@ function tripal_views_get_setup_id($table_name, $priority) {
  *
  *
  * @see tripal_is_table_integrated().
  * @see tripal_is_table_integrated().
  */
  */
-function tripal_views_is_integrated($table_name, $priority = NULL) {
+function tripal_chado_views_is_integrated($table_name, $priority = NULL) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -165,7 +165,7 @@ function tripal_views_is_integrated($table_name, $priority = NULL) {
  *
  *
  * @see tripal_is_lightest_priority_setup().
  * @see tripal_is_lightest_priority_setup().
  */
  */
-function tripal_views_is_lightest_priority_setup($setup_id, $table_name) {
+function tripal_chado_views_is_lightest_priority_setup($setup_id, $table_name) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -187,7 +187,7 @@ function tripal_views_is_lightest_priority_setup($setup_id, $table_name) {
  *
  *
  * @see tripal_rebuild_views_integrations().
  * @see tripal_rebuild_views_integrations().
  */
  */
-function tripal_views_rebuild_views_integrations($delete_first = FALSE) {
+function tripal_chado_views_rebuild_views_integrations($delete_first = FALSE) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -209,7 +209,7 @@ function tripal_views_rebuild_views_integrations($delete_first = FALSE) {
  *
  *
  * @see tripal_add_views_integration().
  * @see tripal_add_views_integration().
  */
  */
-function tripal_views_integration_add_entry($defn_array, $setup_id = FALSE) {
+function tripal_chado_views_integration_add_entry($defn_array, $setup_id = FALSE) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -231,7 +231,7 @@ function tripal_views_integration_add_entry($defn_array, $setup_id = FALSE) {
  *
  *
  * @see tripal_export_views_integration().
  * @see tripal_export_views_integration().
  */
  */
-function tripal_views_integration_export_entry($setup_id) {
+function tripal_chado_views_integration_export_entry($setup_id) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -253,7 +253,7 @@ function tripal_views_integration_export_entry($setup_id) {
  *
  *
  * @see tripal_remove_views_integration().
  * @see tripal_remove_views_integration().
  */
  */
-function tripal_views_integration_remove_entry_by_table_name($table_name, $priority) {
+function tripal_chado_views_integration_remove_entry_by_table_name($table_name, $priority) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -275,7 +275,7 @@ function tripal_views_integration_remove_entry_by_table_name($table_name, $prior
  *
  *
  * @see tripal_remove_views_integration().
  * @see tripal_remove_views_integration().
  */
  */
-function tripal_views_integration_remove_entry_by_setup_id($setup_id) {
+function tripal_chado_views_integration_remove_entry_by_setup_id($setup_id) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -297,7 +297,7 @@ function tripal_views_integration_remove_entry_by_setup_id($setup_id) {
  *
  *
  * @see tripal_update_views_integration().
  * @see tripal_update_views_integration().
  */
  */
-function tripal_views_integration_update_entry($setup_id, $defn_array) {
+function tripal_chado_views_integration_update_entry($setup_id, $defn_array) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -319,7 +319,7 @@ function tripal_views_integration_update_entry($setup_id, $defn_array) {
  *
  *
  * @see tripal_clone_views_integration().
  * @see tripal_clone_views_integration().
  */
  */
-function tripal_views_clone_integration($table_name, $new_priority = NULL, $template_priority = NULL) {
+function tripal_chado_views_clone_integration($table_name, $new_priority = NULL, $template_priority = NULL) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -341,7 +341,7 @@ function tripal_views_clone_integration($table_name, $new_priority = NULL, $temp
  *
  *
  * @see tripal_add_field_to_views_integration().
  * @see tripal_add_field_to_views_integration().
  */
  */
-function tripal_views_add_field_to_integration($table_name, $priority, $field) {
+function tripal_chado_views_add_field_to_integration($table_name, $priority, $field) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',
@@ -363,7 +363,7 @@ function tripal_views_add_field_to_integration($table_name, $priority, $field) {
  *
  *
  * @see tripal_remove_join_from_views_integration().
  * @see tripal_remove_join_from_views_integration().
  */
  */
-function tripal_views_remove_join_from_integration($setup_id, $base_table, $base_field, $left_table, $left_field) {
+function tripal_chado_views_remove_join_from_integration($setup_id, $base_table, $base_field, $left_table, $left_field) {
 
 
   tripal_report_error(
   tripal_report_error(
     'tripal_deprecated',
     'tripal_deprecated',

+ 17 - 17
legacy/tripal_views/api/tripal_views.api.inc → tripal_chado_views/api/tripal_chado_views.api.inc

@@ -5,7 +5,7 @@
  */
  */
 
 
  /**
  /**
- * @defgroup tripal_views_api Tripal Views Module API
+ * @defgroup tripal_chado_views_api Tripal Views Module API
  * @ingroup tripal_api
  * @ingroup tripal_api
  * @{
  * @{
  * Provides functions to help extension modules add their own tripal views integrations
  * Provides functions to help extension modules add their own tripal views integrations
@@ -193,7 +193,7 @@ function mymodule_admin_landing_page() {
  *   returns the lowest priority.  If the table has not been integrated, a priority of 10
  *   returns the lowest priority.  If the table has not been integrated, a priority of 10
  *   is returned.
  *   is returned.
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_get_lightest_views_integration_priority($table_name) {
 function tripal_get_lightest_views_integration_priority($table_name) {
 
 
@@ -223,7 +223,7 @@ function tripal_get_lightest_views_integration_priority($table_name) {
  * @return
  * @return
  *   On success, the setup_id to use for integration of this table; otherwise FALSE
  *   On success, the setup_id to use for integration of this table; otherwise FALSE
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_get_lightest_views_integration_setup($table_name) {
 function tripal_get_lightest_views_integration_setup($table_name) {
 
 
@@ -251,7 +251,7 @@ function tripal_get_lightest_views_integration_setup($table_name) {
  * @return
  * @return
  *   On success, the setup_id to use for integration of this table; otherwise FALSE
  *   On success, the setup_id to use for integration of this table; otherwise FALSE
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_get_views_integration_setup_id($table_name, $priority) {
 function tripal_get_views_integration_setup_id($table_name, $priority) {
 
 
@@ -280,7 +280,7 @@ function tripal_get_views_integration_setup_id($table_name, $priority) {
  *  record is returned (If priority is not specified this will be the lightest record);
  *  record is returned (If priority is not specified this will be the lightest record);
  *  Otherwise the table is not already integrated and FALSE is returned.
  *  Otherwise the table is not already integrated and FALSE is returned.
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_is_table_integrated($table_name, $priority = NULL) {
 function tripal_is_table_integrated($table_name, $priority = NULL) {
 
 
@@ -315,7 +315,7 @@ function tripal_is_table_integrated($table_name, $priority = NULL) {
  *
  *
  * @return TRUE is this is the lightest priority; FALSE otherwise
  * @return TRUE is this is the lightest priority; FALSE otherwise
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_is_lightest_priority_setup($setup_id, $table_name) {
 function tripal_is_lightest_priority_setup($setup_id, $table_name) {
 
 
@@ -341,15 +341,15 @@ function tripal_is_lightest_priority_setup($setup_id, $table_name) {
  * @param $delete_first
  * @param $delete_first
  *   If TRUE then all integrations are first deleted.
  *   If TRUE then all integrations are first deleted.
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_rebuild_views_integrations($delete_first = FALSE) {
 function tripal_rebuild_views_integrations($delete_first = FALSE) {
 
 
   if ($delete_first) {
   if ($delete_first) {
-    tripal_views_delete_all_integrations();
+    tripal_chado_views_delete_all_integrations();
   }
   }
 
 
-  tripal_views_integrate_all_chado_tables();
+  tripal_chado_views_integrate_all_chado_tables();
 
 
   // TODO: the function above should have a return value from which we can
   // TODO: the function above should have a return value from which we can
   // determine if the message below is approprite.
   // determine if the message below is approprite.
@@ -414,7 +414,7 @@ function tripal_rebuild_views_integrations($delete_first = FALSE) {
   tripal_add_views_integration($defn_array);
   tripal_add_views_integration($defn_array);
  * @endcode
  * @endcode
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_add_views_integration($defn_array, $setup_id = FALSE) {
 function tripal_add_views_integration($defn_array, $setup_id = FALSE) {
   $no_errors = TRUE;
   $no_errors = TRUE;
@@ -630,7 +630,7 @@ function tripal_add_views_integration($defn_array, $setup_id = FALSE) {
  * @return
  * @return
  *   A views integration definition array as used by tripal_add_views_integration()
  *   A views integration definition array as used by tripal_add_views_integration()
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_export_views_integration($setup_id) {
 function tripal_export_views_integration($setup_id) {
 
 
@@ -703,7 +703,7 @@ function tripal_export_views_integration($setup_id) {
  * @return
  * @return
  *   TRUE on Success; FALSE otherwise
  *   TRUE on Success; FALSE otherwise
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_remove_views_integration($identifiers, $options = array()) {
 function tripal_remove_views_integration($identifiers, $options = array()) {
 
 
@@ -750,7 +750,7 @@ function tripal_remove_views_integration($identifiers, $options = array()) {
  *   An array describing the structure and fields of the table as is used in
  *   An array describing the structure and fields of the table as is used in
  *   tripal_add_views_integration().
  *   tripal_add_views_integration().
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_update_views_integration($setup_id, $defn_array) {
 function tripal_update_views_integration($setup_id, $defn_array) {
 
 
@@ -774,7 +774,7 @@ function tripal_update_views_integration($setup_id, $defn_array) {
  *   The priority of the template to be used for the clone; this is an existing integration.
  *   The priority of the template to be used for the clone; this is an existing integration.
  *   If no priority is supplied then the lightest priority will be used.
  *   If no priority is supplied then the lightest priority will be used.
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_clone_views_integration($table_name, $new_priority = NULL, $template_priority = NULL) {
 function tripal_clone_views_integration($table_name, $new_priority = NULL, $template_priority = NULL) {
 
 
@@ -833,7 +833,7 @@ function tripal_clone_views_integration($table_name, $new_priority = NULL, $temp
  * @return
  * @return
  *   TRUE if the field was added successfully; FALSE otherwise
  *   TRUE if the field was added successfully; FALSE otherwise
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_add_field_to_views_integration($table_name, $priority, $field) {
 function tripal_add_field_to_views_integration($table_name, $priority, $field) {
   $no_errors = TRUE;
   $no_errors = TRUE;
@@ -1014,7 +1014,7 @@ function tripal_add_field_to_views_integration($table_name, $priority, $field) {
  * @return
  * @return
  *   TRUE if the field was added successfully; FALSE otherwise
  *   TRUE if the field was added successfully; FALSE otherwise
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_add_join_to_views_integration($table_name, $priority, $join) {
 function tripal_add_join_to_views_integration($table_name, $priority, $join) {
   $no_errors = TRUE;
   $no_errors = TRUE;
@@ -1061,7 +1061,7 @@ function tripal_add_join_to_views_integration($table_name, $priority, $join) {
  * @param $left_field
  * @param $left_field
  *   The name of the field from the other table involved in the join
  *   The name of the field from the other table involved in the join
  *
  *
- * @ingroup tripal_views_api
+ * @ingroup tripal_chado_views_api
  */
  */
 function tripal_remove_join_from_views_integration($setup_id, $base_table, $base_field, $left_table, $left_field) {
 function tripal_remove_join_from_views_integration($setup_id, $base_table, $base_field, $left_table, $left_field) {
   db_query(
   db_query(

+ 10 - 10
legacy/tripal_views/includes/tripal_views_integration.inc → tripal_chado_views/includes/tripal_chado_views_integration.inc

@@ -7,9 +7,9 @@
 /**
 /**
  * Purpose: Deletes ALL Tripal Views Integrations.
  * Purpose: Deletes ALL Tripal Views Integrations.
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_delete_all_integrations() {
+function tripal_chado_views_delete_all_integrations() {
 
 
   db_query("DELETE FROM {tripal_views}");
   db_query("DELETE FROM {tripal_views}");
   db_query("DELETE FROM {tripal_views_field}");
   db_query("DELETE FROM {tripal_views_field}");
@@ -24,10 +24,10 @@ function tripal_views_delete_all_integrations() {
  * Integrate all chado tables in the schema api.  This integration only occurs
  * Integrate all chado tables in the schema api.  This integration only occurs
  * once and sets all Chado tables to a priority of 10
  * once and sets all Chado tables to a priority of 10
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integrate_all_chado_tables() {
-return;
+function tripal_chado_views_integrate_all_chado_tables() {
+
   // First integrate all of the Chado tables. Those that are base tables
   // First integrate all of the Chado tables. Those that are base tables
   // get special treatment.
   // get special treatment.
   $tables = chado_get_table_names(TRUE);
   $tables = chado_get_table_names(TRUE);
@@ -58,10 +58,10 @@ return;
       // Assuming that we have a default chado table, genereate an integration
       // Assuming that we have a default chado table, genereate an integration
       // array describing it's Tripal Views integration.
       // array describing it's Tripal Views integration.
       if (in_array($tablename, $base_tables) OR (is_array($mview_tables) and in_array($tablename, $mview_tables))) {
       if (in_array($tablename, $base_tables) OR (is_array($mview_tables) and in_array($tablename, $mview_tables))) {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
+        $table_integration_array = tripal_chado_views_get_integration_array_for_chado_table($tablename, TRUE, $priority);
       }
       }
       else {
       else {
-        $table_integration_array = tripal_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
+        $table_integration_array = tripal_chado_views_get_integration_array_for_chado_table($tablename, FALSE, $priority);
       }
       }
 
 
       // Check to see if this table is a Materialized view and if it is,
       // Check to see if this table is a Materialized view and if it is,
@@ -88,9 +88,9 @@ return;
  *   The tripal views integration array which is the parameter for
  *   The tripal views integration array which is the parameter for
  *   tripal_add_views_integration($defn_array)
  *   tripal_add_views_integration($defn_array)
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_get_integration_array_for_chado_table($table_name, $base_table = TRUE, $priority = 9) {
+function tripal_chado_views_get_integration_array_for_chado_table($table_name, $base_table = TRUE, $priority = 9) {
 
 
   // Get the schema for this table (via the chado schema api)
   // Get the schema for this table (via the chado schema api)
   $schema = chado_get_schema($table_name);
   $schema = chado_get_schema($table_name);
@@ -107,7 +107,7 @@ function tripal_views_get_integration_array_for_chado_table($table_name, $base_t
   );
   );
   // Add fields
   // Add fields
   if (!isset($schema['fields'])) {
   if (!isset($schema['fields'])) {
-    tripal_report_error('tripal_views', TRIPAL_NOTICE,
+    tripal_report_error('tripal_chado_views', TRIPAL_NOTICE,
       'There are no fields defined for %table in the Chado Schema API.', array('%table' => $table_name));
       'There are no fields defined for %table in the Chado Schema API.', array('%table' => $table_name));
     return FALSE;
     return FALSE;
   }
   }

+ 43 - 43
legacy/tripal_views/includes/tripal_views_integration_UI.inc → tripal_chado_views/includes/tripal_chado_views_integration_UI.inc

@@ -12,15 +12,15 @@
  * @return
  * @return
  *    a themed HTML table
  *    a themed HTML table
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_setup_list() {
+function tripal_chado_views_integration_setup_list() {
   $output = '';
   $output = '';
 
 
   // TODO: change the following to use theme_item_list()
   // TODO: change the following to use theme_item_list()
   $output .= '<ul class="action-links">';
   $output .= '<ul class="action-links">';
-  $output .=  '<li>' . l(t('Add a New Entry'), "admin/tripal/views-integration/new") . '</li>';
-  $output .=  '<li style="float: right;">' . l(t('Delete ALL Entries'), "admin/tripal/views-integration/delete-all/confirm") . '</li>';
+  $output .=  '<li>' . l(t('Add a New Entry'), "admin/tripal/storage/chado/views-integration/new") . '</li>';
+  $output .=  '<li style="float: right;">' . l(t('Delete ALL Entries'), "admin/tripal/storage/chado/views-integration/delete-all/confirm") . '</li>';
   $output .= '</ul>';
   $output .= '</ul>';
 
 
   $output .= '<p>' . t('The following tables are available for integration with Drupal Views. If '
   $output .= '<p>' . t('The following tables are available for integration with Drupal Views. If '
@@ -43,9 +43,9 @@ function tripal_views_integration_setup_list() {
                      .'ORDER BY tv.table_name ASC, tv.priority ASC');
                      .'ORDER BY tv.table_name ASC, tv.priority ASC');
   foreach ($tviews as $tview) {
   foreach ($tviews as $tview) {
     $rows[] = array(
     $rows[] = array(
-      l(t('Edit'), "admin/tripal/views-integration/edit/" . $tview->setup_id) . "<br />"
-        . l(t('Export'), "admin/tripal/views-integration/export/" . $tview->setup_id) . "<br />"
-        . l(t('Delete'), "admin/tripal/views-integration/delete/" . $tview->setup_id),
+      l(t('Edit'), "admin/tripal/storage/chado/views-integration/edit/" . $tview->setup_id) . "<br />"
+        . l(t('Export'), "admin/tripal/storage/chado/views-integration/export/" . $tview->setup_id) . "<br />"
+        . l(t('Delete'), "admin/tripal/storage/chado/views-integration/delete/" . $tview->setup_id),
       $tview->name,
       $tview->name,
       $tview->table_name,
       $tview->table_name,
       ($tview->table_id) ? 'No' : 'Yes',
       ($tview->table_id) ? 'No' : 'Yes',
@@ -75,9 +75,9 @@ function tripal_views_integration_setup_list() {
                      .'ORDER BY table_name ASC, priority ASC');
                      .'ORDER BY table_name ASC, priority ASC');
   foreach ($tviews as $tview) {
   foreach ($tviews as $tview) {
     $rows[] = array(
     $rows[] = array(
-      l(t('Edit'), "admin/tripal/views-integration/edit/" . $tview->setup_id) . "<br />"
-        . l(t('Export'), "admin/tripal/views-integration/export/" . $tview->setup_id) . "<br />"
-        . l(t('Delete'), "admin/tripal/views-integration/delete/" . $tview->setup_id),
+      l(t('Edit'), "admin/tripal/storage/chado/views-integration/edit/" . $tview->setup_id) . "<br />"
+        . l(t('Export'), "admin/tripal/storage/chado/views-integration/export/" . $tview->setup_id) . "<br />"
+        . l(t('Delete'), "admin/tripal/storage/chado/views-integration/delete/" . $tview->setup_id),
       $tview->name,
       $tview->name,
       $tview->table_name,
       $tview->table_name,
       $tview->priority,
       $tview->priority,
@@ -105,9 +105,9 @@ function tripal_views_integration_setup_list() {
                      .'ORDER BY table_name ASC, priority ASC');
                      .'ORDER BY table_name ASC, priority ASC');
   foreach ($tviews as $tview) {
   foreach ($tviews as $tview) {
     $rows[] = array(
     $rows[] = array(
-      l(t('Edit'), "admin/tripal/views-integration/edit/" . $tview->setup_id) . "<br />"
-        . l(t('Export'), "admin/tripal/views-integration/export/" . $tview->setup_id) . "<br />"
-        . l(t('Delete'), "admin/tripal/views-integration/delete/" . $tview->setup_id),
+      l(t('Edit'), "admin/tripal/storage/chado/views-integration/edit/" . $tview->setup_id) . "<br />"
+        . l(t('Export'), "admin/tripal/storage/chado/views-integration/export/" . $tview->setup_id) . "<br />"
+        . l(t('Delete'), "admin/tripal/storage/chado/views-integration/delete/" . $tview->setup_id),
       $tview->name,
       $tview->name,
       $tview->table_name,
       $tview->table_name,
       $tview->priority,
       $tview->priority,
@@ -127,13 +127,13 @@ function tripal_views_integration_setup_list() {
  * @param $setup_id
  * @param $setup_id
  *    the unique setup id for the integrated table
  *    the unique setup id for the integrated table
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_delete($setup_id) {
+function tripal_chado_views_integration_delete($setup_id) {
 
 
   tripal_remove_views_integration(array('setup_id' => ($setup_id)));
   tripal_remove_views_integration(array('setup_id' => ($setup_id)));
   drupal_set_message(t("Record Deleted"));
   drupal_set_message(t("Record Deleted"));
-  drupal_goto('admin/tripal/views-integration');
+  drupal_goto('admin/tripal/storage/chado/views-integration');
 
 
 }
 }
 
 
@@ -142,9 +142,9 @@ function tripal_views_integration_delete($setup_id) {
  *   function is meant to be called from a menu item. After completion it
  *   function is meant to be called from a menu item. After completion it
  *   redirects the user to the views intergation page.
  *   redirects the user to the views intergation page.
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_delete_all_form($form, &$form_state) {
+function tripal_chado_views_integration_delete_all_form($form, &$form_state) {
 
 
   $form['extra'] = array(
   $form['extra'] = array(
     '#type' => 'item',
     '#type' => 'item',
@@ -168,7 +168,7 @@ function tripal_views_integration_delete_all_form($form, &$form_state) {
   $form['actions']['cancel'] = array(
   $form['actions']['cancel'] = array(
     '#type' => 'link',
     '#type' => 'link',
     '#title' => t('Cancel'),
     '#title' => t('Cancel'),
-    '#href' => 'admin/tripal/views-integration/list',
+    '#href' => 'admin/tripal/storage/chado/views-integration/list',
   );
   );
 
 
   // By default, render the form using theme_confirm_form().
   // By default, render the form using theme_confirm_form().
@@ -184,13 +184,13 @@ function tripal_views_integration_delete_all_form($form, &$form_state) {
  *   function is meant to be called from a menu item. After completion it
  *   function is meant to be called from a menu item. After completion it
  *   redirects the user to the views intergation page.
  *   redirects the user to the views intergation page.
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_delete_all_form_submit($form, &$form_state) {
+function tripal_chado_views_integration_delete_all_form_submit($form, &$form_state) {
 
 
   tripal_rebuild_views_integrations(TRUE);
   tripal_rebuild_views_integrations(TRUE);
 
 
-  $form_state['redirect'] = 'admin/tripal/views-integration/list';
+  $form_state['redirect'] = 'admin/tripal/storage/chado/views-integration/list';
 
 
 }
 }
 
 
@@ -211,9 +211,9 @@ function tripal_views_integration_delete_all_form_submit($form, &$form_state) {
  * D7 @todo: Add ability to manage custom fields
  * D7 @todo: Add ability to manage custom fields
  * D7 @todo: Update relationship handler to work with the new tripal_views_join method
  * D7 @todo: Update relationship handler to work with the new tripal_views_join method
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_form($form, &$form_state) {
+function tripal_chado_views_integration_form($form, &$form_state) {
 
 
   $data = array();
   $data = array();
   $form['#cache'] = TRUE;
   $form['#cache'] = TRUE;
@@ -316,7 +316,7 @@ function tripal_views_integration_form($form, &$form_state) {
     '#default_value' => $default,
     '#default_value' => $default,
     '#ajax' => array(
     '#ajax' => array(
        //D6: 'path' => 'tripal/views-integration/ajax/view_setup_table',
        //D6: 'path' => 'tripal/views-integration/ajax/view_setup_table',
-       'callback' => 'tripal_views_integration_ajax_view_setup_table',
+       'callback' => 'tripal_chado_views_integration_ajax_view_setup_table',
        'wrapper' => 'tripal-views-integration-form',
        'wrapper' => 'tripal-views-integration-form',
        'effect' => 'fade',
        'effect' => 'fade',
        'event' => 'change',
        'event' => 'change',
@@ -348,7 +348,7 @@ function tripal_views_integration_form($form, &$form_state) {
       '#default_value' => $default,
       '#default_value' => $default,
       '#ajax' => array(
       '#ajax' => array(
          //D6: 'path' => 'tripal/views-integration/ajax/view_setup_table',
          //D6: 'path' => 'tripal/views-integration/ajax/view_setup_table',
-         'callback' => 'tripal_views_integration_ajax_view_setup_table',
+         'callback' => 'tripal_chado_views_integration_ajax_view_setup_table',
          'wrapper' => 'tripal-views-integration-form',
          'wrapper' => 'tripal-views-integration-form',
          'effect' => 'fade',
          'effect' => 'fade',
          'event' => 'change',
          'event' => 'change',
@@ -541,7 +541,7 @@ function tripal_views_integration_form($form, &$form_state) {
     $chado_join_tables = array_merge(array('Select a Join Table'), $chado_join_tables);
     $chado_join_tables = array_merge(array('Select a Join Table'), $chado_join_tables);
 
 
     // get list of all handlers
     // get list of all handlers
-    $all_handlers = tripal_views_integration_discover_handlers();
+    $all_handlers = tripal_chado_views_integration_discover_handlers();
     $handlers_fields = array(0 => "Select a field handler");
     $handlers_fields = array(0 => "Select a field handler");
     $handlers_filters = array(0 => "Select a filter handler");
     $handlers_filters = array(0 => "Select a filter handler");
     $handlers_sort = array(0 => "Select a sort handler");
     $handlers_sort = array(0 => "Select a sort handler");
@@ -1042,7 +1042,7 @@ function tripal_views_integration_form($form, &$form_state) {
       '#type' => 'select',
       '#type' => 'select',
       '#options' => $chado_join_tables,
       '#options' => $chado_join_tables,
       '#ajax' => array(
       '#ajax' => array(
-        'callback' => 'tripal_views_integration_ajax_new_join_left_field_callback',
+        'callback' => 'tripal_chado_views_integration_ajax_new_join_left_field_callback',
         'wrapper' => 'new-join',
         'wrapper' => 'new-join',
       )
       )
     );
     );
@@ -1102,12 +1102,12 @@ function tripal_views_integration_form($form, &$form_state) {
   $form['#prefix'] = '<div id="tripal-views-integration-form">';
   $form['#prefix'] = '<div id="tripal-views-integration-form">';
   $form['#suffix'] = '</div>';
   $form['#suffix'] = '</div>';
 
 
-  $form['#redirect'] = 'admin/tripal/views-integration/list';
+  $form['#redirect'] = 'admin/tripal/storage/chado/views-integration/list';
   return $form;
   return $form;
 }
 }
 
 
 /**
 /**
- * Purpose: validates the tripal_views_integration_form after submission
+ * Purpose: validates the tripal_chado_views_integration_form after submission
  *
  *
  * @param $form
  * @param $form
  *    The form object which is passed automatically by drupal
  *    The form object which is passed automatically by drupal
@@ -1115,9 +1115,9 @@ function tripal_views_integration_form($form, &$form_state) {
  * @param $form_state
  * @param $form_state
  *    The form state pbject which is passed automatically by drupal
  *    The form state pbject which is passed automatically by drupal
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_form_validate($form, &$form_state) {
+function tripal_chado_views_integration_form_validate($form, &$form_state) {
   $name_array = explode(" ", $form_state['values']['row_name']);
   $name_array = explode(" ", $form_state['values']['row_name']);
   $mview_id = $form_state['values']['mview_id'];
   $mview_id = $form_state['values']['mview_id'];
   $table_name = $form_state['values']['table_name'];
   $table_name = $form_state['values']['table_name'];
@@ -1161,9 +1161,9 @@ function tripal_views_integration_form_validate($form, &$form_state) {
  * @param $form_state
  * @param $form_state
  *    The form state pbject which is passed automatically by drupal
  *    The form state pbject which is passed automatically by drupal
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_form_submit($form, &$form_state) {
+function tripal_chado_views_integration_form_submit($form, &$form_state) {
   $name       = trim($form_state['values']['row_name']);
   $name       = trim($form_state['values']['row_name']);
   $mview_id   = $form_state['values']['mview_id'];
   $mview_id   = $form_state['values']['mview_id'];
   $table_name = $form_state['values']['table_name'];
   $table_name = $form_state['values']['table_name'];
@@ -1321,7 +1321,7 @@ function tripal_views_integration_form_submit($form, &$form_state) {
     drupal_set_message(t('Record Added'));
     drupal_set_message(t('Record Added'));
   }
   }
 
 
-  $form_state['redirect'] = 'admin/tripal/views-integration/integrations';
+  $form_state['redirect'] = 'admin/tripal/storage/chado/views-integration/integrations';
 
 
   // now clear all the caches so that Drupal views picks up our chages
   // now clear all the caches so that Drupal views picks up our chages
   views_invalidate_cache();
   views_invalidate_cache();
@@ -1329,9 +1329,9 @@ function tripal_views_integration_form_submit($form, &$form_state) {
 
 
 /**
 /**
  * AJAX callback to replace the left field select list in the new join fieldset of the
  * AJAX callback to replace the left field select list in the new join fieldset of the
- * tripal_views_integration_form form
+ * tripal_chado_views_integration_form form
  */
  */
-function tripal_views_integration_ajax_new_join_left_field_callback($form, $form_state) {
+function tripal_chado_views_integration_ajax_new_join_left_field_callback($form, $form_state) {
   return $form['view_setup_join']['new_join'];
   return $form['view_setup_join']['new_join'];
 }
 }
 
 
@@ -1343,9 +1343,9 @@ function tripal_views_integration_ajax_new_join_left_field_callback($form, $form
  * @return
  * @return
  *   Returns an array of handler names
  *   Returns an array of handler names
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_discover_handlers() {
+function tripal_chado_views_integration_discover_handlers() {
 
 
   $handlers = array();
   $handlers = array();
 
 
@@ -1420,9 +1420,9 @@ function tripal_views_integration_discover_handlers() {
  * Ajax Callback: Tripal Views Integration Form
  * Ajax Callback: Tripal Views Integration Form
  * Replaces the entire fields table when the table or materialized view is set/changed
  * Replaces the entire fields table when the table or materialized view is set/changed
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_ajax_view_setup_table($form, $form_state) {
+function tripal_chado_views_integration_ajax_view_setup_table($form, $form_state) {
   //return $form['view_setup_table'];
   //return $form['view_setup_table'];
   return $form;
   return $form;
 }
 }
@@ -1431,9 +1431,9 @@ function tripal_views_integration_ajax_view_setup_table($form, $form_state) {
  * Ajax Callback: Tripal Views Integration Form
  * Ajax Callback: Tripal Views Integration Form
  * Replaces the join db field dropdown when the join table dropdown is changed
  * Replaces the join db field dropdown when the join table dropdown is changed
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_ajax_join_field($form, $form_state) {
+function tripal_chado_views_integration_ajax_join_field($form, $form_state) {
 
 
   // Determine which row we are dealing with from the name of the triggering element
   // Determine which row we are dealing with from the name of the triggering element
   if (preg_match('/fields_join_(\w+-\d+)/', $form_state['triggering_element']['#name'], $matches)) {
   if (preg_match('/fields_join_(\w+-\d+)/', $form_state['triggering_element']['#name'], $matches)) {

+ 6 - 6
legacy/tripal_views/includes/tripal_views_integration_port.inc → tripal_chado_views/includes/tripal_chado_views_integration_port.inc

@@ -16,9 +16,9 @@
  * @param $setup_id
  * @param $setup_id
  *   The tripal views integration setup id
  *   The tripal views integration setup id
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_export_form($form, &$form_state, $setup_id) {
+function tripal_chado_views_integration_export_form($form, &$form_state, $setup_id) {
   $form = array();
   $form = array();
 
 
   $defn_array = tripal_export_views_integration($setup_id);
   $defn_array = tripal_export_views_integration($setup_id);
@@ -44,9 +44,9 @@ function tripal_views_integration_export_form($form, &$form_state, $setup_id) {
 /**
 /**
  * Form: Imports a tripal views integration
  * Form: Imports a tripal views integration
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_import_form() {
+function tripal_chado_views_integration_import_form() {
   $form = array();
   $form = array();
 
 
   $form['name'] = array(
   $form['name'] = array(
@@ -92,9 +92,9 @@ function tripal_views_integration_import_form() {
  * @param $form
  * @param $form
  * @param $form_state
  * @param $form_state
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_integration_import_form_submit($form, &$form_state) {
+function tripal_chado_views_integration_import_form_submit($form, &$form_state) {
 
 
   //$defn_array = unserialize($form_state['values']['import']);
   //$defn_array = unserialize($form_state['values']['import']);
   // convert the array into a real PHP array
   // convert the array into a real PHP array

+ 0 - 0
legacy/tripal_views/theme/css/tripal_views_admin_views.css → tripal_chado_views/theme/css/tripal_views_admin_views.css


+ 0 - 0
legacy/tripal_views/theme/tripal_views_help.tpl.php → tripal_chado_views/theme/tripal_chado_views_help.tpl.php


+ 0 - 0
legacy/tripal_views/theme/tripal_views_search_biological_content.tpl.php → tripal_chado_views/theme/tripal_chado_views_search_biological_content.tpl.php


+ 1 - 1
legacy/tripal_views/tripal_views.coder_ignores.txt → tripal_chado_views/tripal_chado_views.coder_ignores.txt

@@ -3,7 +3,7 @@
 ; where warning-type is one of security, style, sql, i18n, comment, etc.
 ; where warning-type is one of security, style, sql, i18n, comment, etc.
 
 
 ; All variables are filtered
 ; All variables are filtered
-tripal_views_integration.inc:814:security
+tripal_chado_iews_integration.inc:814:security
 
 
 
 
 ; SQL queries the pg_tables table to check if a table exists in chado; drupal
 ; SQL queries the pg_tables table to check if a table exists in chado; drupal

+ 3 - 3
legacy/tripal_views/tripal_views.info → tripal_chado_views/tripal_chado_views.info

@@ -1,10 +1,10 @@
-name = Tripal Views
+name = Tripal Chado Views
 description = Integrates all Chado tables with Drupal Views and provides basic searching for administrators and site visitors and provides a range of flexibility for creating custom pages without the need for programming.
 description = Integrates all Chado tables with Drupal Views and provides basic searching for administrators and site visitors and provides a range of flexibility for creating custom pages without the need for programming.
 core = 7.x
 core = 7.x
 project = tripal
 project = tripal
-package = Tripal v2 Legacy
+package = Tripal
 version = 7.x-3.0-alpha1
 version = 7.x-3.0-alpha1
-configure = admin/tripal/views-integration
+configure = admin/tripal/storage/chado/views-integration
 
 
 files[] = views/handlers/tripal_views_handler_filter_textarea.inc
 files[] = views/handlers/tripal_views_handler_filter_textarea.inc
 files[] = views/handlers/tripal_views_handler_filter_file_upload.inc
 files[] = views/handlers/tripal_views_handler_filter_file_upload.inc

+ 14 - 108
legacy/tripal_views/tripal_views.install → tripal_chado_views/tripal_chado_views.install

@@ -7,15 +7,15 @@
 /**
 /**
  * Implementation of hook_requirements().
  * Implementation of hook_requirements().
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_requirements($phase) {
+function tripal_chado_views_requirements($phase) {
   $requirements = array();
   $requirements = array();
   if ($phase == 'install') {
   if ($phase == 'install') {
     // make sure chado is installed
     // make sure chado is installed
     if (!$GLOBALS["chado_is_installed"]) {
     if (!$GLOBALS["chado_is_installed"]) {
-      $requirements ['tripal_views'] = array(
-        'title' => "tripal_views",
+      $requirements ['tripal_chado_views'] = array(
+        'title' => "tripal_chado_views",
         'value' => "ERROR: Chado must be installed before this module can be enabled",
         'value' => "ERROR: Chado must be installed before this module can be enabled",
         'severity' => REQUIREMENT_ERROR,
         'severity' => REQUIREMENT_ERROR,
       );
       );
@@ -27,9 +27,9 @@ function tripal_views_requirements($phase) {
 /**
 /**
  * Implementation of hook_install().
  * Implementation of hook_install().
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_install() {
+function tripal_chado_views_install() {
 
 
   // we want views to pick up our changes
   // we want views to pick up our changes
   views_invalidate_cache();
   views_invalidate_cache();
@@ -39,10 +39,10 @@ function tripal_views_install() {
 /**
 /**
  * Implementation of hook_schema().
  * Implementation of hook_schema().
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_schema() {
-  $schema = tripal_views_get_schemas();
+function tripal_chado_views_schema() {
+  $schema = tripal_chado_views_get_schemas();
   return $schema;
   return $schema;
 }
 }
 
 
@@ -52,12 +52,12 @@ function tripal_views_schema() {
  * can easily provide the entire list for hook_install or individual
  * can easily provide the entire list for hook_install or individual
  * tables for an update.
  * tables for an update.
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_get_schemas() {
+function tripal_chado_views_get_schemas() {
   $schema = array();
   $schema = array();
 
 
-  $temp = tripal_views_views_schema();
+  $temp = tripal_chado_views_views_schema();
   foreach ($temp as $table => $arr) {
   foreach ($temp as $table => $arr) {
     $schema[$table] = $arr;
     $schema[$table] = $arr;
   }
   }
@@ -65,100 +65,6 @@ function tripal_views_get_schemas() {
   return $schema;
   return $schema;
 }
 }
 
 
-/**
- * Tripal Views Update for 6.x-0.4
- *   - Add priority field to tripal_views
- *   - Add handler field to tripal_views_join
- *   - Add tripal_views_field table to keep track of fields for views integration
- *
- * @ingroup tripal_views
- */
-function tripal_views_update_6040() {
-
-  // Add Priority to tripal_views
-  db_add_field(
-    'tripal_views',
-    'priority',
-    array('type' => 'int')
-  );
-  db_add_unique_key('tripal_views', 'priority', array('table_name', 'priority'));
-  db_add_index('tripal_views', 'priority', array('table_name', 'priority'));
-
-  // Add handler to tripal_views_join
-  db_add_field(
-    'tripal_views_join',
-    'handler',
-    array(
-      'type' => 'varchar',
-      'length' => '255',
-      'not null' => TRUE,
-      'default' => ''
-    )
-  );
-
-  // Add tripal_views_field to keep track of fields for views integration
-  $schema = tripal_views_views_schema();
-  db_create_table('tripal_views_field', $schema['tripal_views_field']);
-
-  // Add base_table TRUE/FALSE to tripal_views
-  db_add_field(
-    'tripal_views',
-    'base_table',
-    array(
-      'type' => 'int',
-      'not null ' => TRUE,
-      'default' => 1
-    )
-  );
-
-  // Add arguments to joins
-  db_add_field(
-    'tripal_views_join',
-    'arguments',
-    array(
-      'description' => 'arguments that may get passed to the handler',
-      'type' => 'text',
-      'size' => 'normal'
-    )
-  );
-
-  return t('Updated Tripal Views to handle multiple Integrations and keep track of fields.');
-}
-
-/**
- * Tripal Views Update for 7.x-2.0
- *   - Add relationship_only field to tripal_views_join
- *   - Add relationship_handler field to tripal_views_join
- *
- */
-function tripal_views_update_7200() {
-
-  // Add relationship_handler to tripal_views_join
-  db_add_field(
-    'tripal_views_join',
-    'relationship_handler',
-    array(
-      'type' => 'varchar',
-      'length' => '255',
-      'not null' => TRUE,
-      'default' => 'views_handler_relationship'
-    )
-  );
-
-  // Add relationship_only to tripal_views_join
-  db_add_field(
-    'tripal_views_join',
-    'relationship_only',
-    array(
-      'type' => 'int',
-      'not null ' => TRUE,
-      'default' => 0
-    )
-  );
-
-  return t('Updated Tripal Views to better handle relationships. Relationships are now handled through joins rather than handlers (backwards compatible).');
-}
-
 /**
 /**
  * Describe the Tripal Views Schema
  * Describe the Tripal Views Schema
  *
  *
@@ -169,9 +75,9 @@ function tripal_views_update_7200() {
  *       and other tables.
  *       and other tables.
  *   - tripal_views_handlers: keeps track of which handlers to use for a given field
  *   - tripal_views_handlers: keeps track of which handlers to use for a given field
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_views_schema() {
+function tripal_chado_views_views_schema() {
   $schema = array();
   $schema = array();
   $schema['tripal_views'] = array(
   $schema['tripal_views'] = array(
     'description' => 'contains the setups, their materialized view id and base table name that was used.',
     'description' => 'contains the setups, their materialized view id and base table name that was used.',

+ 54 - 52
legacy/tripal_views/tripal_views.module → tripal_chado_views/tripal_chado_views.module

@@ -5,36 +5,36 @@
  */
  */
 
 
 /**
 /**
- * @defgroup tripal_views Tripal Views Module
+ * @defgroup tripal_chado_views Tripal Chado Views Module
  * @ingroup tripal_modules
  * @ingroup tripal_modules
  * @{
  * @{
  * Provides functions for integrating chado with Drupal Views.
  * Provides functions for integrating chado with Drupal Views.
  * @}
  * @}
  */
  */
 
 
-require_once 'api/tripal_views.api.inc';
-//require_once 'api/tripal_views.DEPRECATED.inc';
+require_once 'api/tripal_chado_views.api.inc';
+//require_once 'api/tripal_chado_views.DEPRECATED.inc';
 
 
-require_once 'tripal_views.views.inc';
+require_once 'tripal_chado_views.views.inc';
 
 
-require_once 'includes/tripal_views_integration.inc';
-require_once 'includes/tripal_views_integration_UI.inc';
-require_once 'includes/tripal_views_integration_port.inc';
+require_once 'includes/tripal_chado_views_integration.inc';
+require_once 'includes/tripal_chado_views_integration_UI.inc';
+require_once 'includes/tripal_chado_views_integration_port.inc';
 
 
 /**
 /**
  * Implements hook_menu().
  * Implements hook_menu().
  * This hook provides details about new menu items added by this module
  * This hook provides details about new menu items added by this module
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_menu() {
+function tripal_chado_views_menu() {
   $items = array();
   $items = array();
 
 
   $items['chado'] = array(
   $items['chado'] = array(
     'title' => 'Search Data',
     'title' => 'Search Data',
     'description' => 'Listings of the various biological data available categorized by type.',
     'description' => 'Listings of the various biological data available categorized by type.',
     'page callback' => 'theme',
     'page callback' => 'theme',
-    'page arguments' => array('tripal_views_search_biological_content'),
+    'page arguments' => array('tripal_chado_views_search_biological_content'),
     'access arguments' => array('access content'),
     'access arguments' => array('access content'),
     'expanded' => TRUE,
     'expanded' => TRUE,
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
@@ -44,17 +44,17 @@ function tripal_views_menu() {
   $items['admin/tripal/storage/chado/views-integration'] = array(
   $items['admin/tripal/storage/chado/views-integration'] = array(
     'title' => 'Views Integration',
     'title' => 'Views Integration',
     'description' => 'Integration of all the chado tables and fields with Drupal Views.',
     'description' => 'Integration of all the chado tables and fields with Drupal Views.',
-    'page callback' => 'tripal_views_admin_integration_view',
+    'page callback' => 'tripal_chado_views_admin_integration_view',
     'access arguments' => array('manage tripal_views_integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => 10
     'weight' => 10
   );
   );
 
 
   /**
   /**
-  $items['admin/tripal/views-integration/list'] = array(
+  $items['admin/tripal/storage/chado/views-integration/list'] = array(
     'title' => 'List of Integrated Tables',
     'title' => 'List of Integrated Tables',
     'description' => 'Provide a list of all integrated tables and allows for adding new tables or editing already integrated tables.',
     'description' => 'Provide a list of all integrated tables and allows for adding new tables or editing already integrated tables.',
-    'page callback' => 'tripal_views_integration_setup_list',
+    'page callback' => 'tripal_chado_views_integration_setup_list',
     'access arguments' => array('manage tripal_views_integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => 0,
     'weight' => 0,
@@ -74,14 +74,14 @@ function tripal_views_menu() {
   $items['admin/tripal/storage/chado/views-integration/edit/%'] = array(
   $items['admin/tripal/storage/chado/views-integration/edit/%'] = array(
     'title' => 'Edit Views Integration',
     'title' => 'Edit Views Integration',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_views_integration_form', 4),
+    'page arguments' => array('tripal_chado_views_integration_form', 4),
     'access arguments' => array('manage tripal_views_integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
 
 
   $items['admin/tripal/storage/chado/views-integration/delete/%'] = array(
   $items['admin/tripal/storage/chado/views-integration/delete/%'] = array(
     'title' => 'Delete Views Integration',
     'title' => 'Delete Views Integration',
-    'page callback' => 'tripal_views_integration_delete',
+    'page callback' => 'tripal_chado_views_integration_delete',
     'page arguments' => array(4),
     'page arguments' => array(4),
     'access arguments' => array('manage tripal_views_integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
@@ -90,7 +90,7 @@ function tripal_views_menu() {
   $items['admin/tripal/storage/chado/views-integration/delete-all/confirm'] = array(
   $items['admin/tripal/storage/chado/views-integration/delete-all/confirm'] = array(
     'title' => 'Delete ALL Views Integration',
     'title' => 'Delete ALL Views Integration',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_views_integration_delete_all_form'),
+    'page arguments' => array('tripal_chado_views_integration_delete_all_form'),
     'access arguments' => array('manage tripal_views_integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
@@ -99,7 +99,7 @@ function tripal_views_menu() {
     'title' => 'Import Views Integration',
     'title' => 'Import Views Integration',
     'description' => 'Import a Tripal Views Integration from another site.',
     'description' => 'Import a Tripal Views Integration from another site.',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_views_integration_import_form'),
+    'page arguments' => array('tripal_chado_views_integration_import_form'),
     'access arguments' => array('manage tripal_views_integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
     'weight' => 2,
     'weight' => 2,
@@ -109,7 +109,7 @@ function tripal_views_menu() {
     'title' => 'Export Views Integration',
     'title' => 'Export Views Integration',
     'description' => 'Export a Tripal Views Integration for use in another Tripal site',
     'description' => 'Export a Tripal Views Integration for use in another Tripal site',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_views_integration_export_form', 4),
+    'page arguments' => array('tripal_chado_views_integration_export_form', 4),
     'access arguments' => array('manage tripal_views_integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
     'weight' => 3,
     'weight' => 3,
@@ -119,16 +119,16 @@ function tripal_views_menu() {
     'title' => 'Export Views Integration',
     'title' => 'Export Views Integration',
     'description' => 'Export a Tripal Views Integration for use in another Tripal site',
     'description' => 'Export a Tripal Views Integration for use in another Tripal site',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
-    'page arguments' => array('tripal_views_integration_export_form', 4),
+    'page arguments' => array('tripal_chado_views_integration_export_form', 4),
     'access arguments' => array('manage tripal_views_integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
 
 
   $items['admin/tripal/storage/chado/views-integration/help'] = array(
   $items['admin/tripal/storage/chado/views-integration/help'] = array(
     'title' => 'Help',
     'title' => 'Help',
-    'description' => "A description of the Tripal Views module including a short description of it's usage.",
+    'description' => "A description of the Tripal Chado Views module including a short description of it's usage.",
     'page callback' => 'theme',
     'page callback' => 'theme',
-    'page arguments' => array('tripal_views_help'),
+    'page arguments' => array('tripal_chado_views_help'),
     'access arguments' => array('manage tripal_views_integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10,
     'weight' => 10,
@@ -137,7 +137,7 @@ function tripal_views_menu() {
   $items['admin/tripal/storage/chado/views-integrations/views/integrations/enable'] = array(
   $items['admin/tripal/storage/chado/views-integrations/views/integrations/enable'] = array(
     'title' => 'Enable Integrations Administrative View',
     'title' => 'Enable Integrations Administrative View',
     'page callback' => 'tripal_enable_view',
     'page callback' => 'tripal_enable_view',
-    'page arguments' => array('tripal_views_admin_integrations', 'admin/tripal/views-integrations'),
+    'page arguments' => array('tripal_chado_views_admin_integrations', 'admin/tripal/storage/chado/views-integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'access arguments' => array('manage tripal_views_integration'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
@@ -148,9 +148,9 @@ function tripal_views_menu() {
 /**
 /**
  * Implements hook_init().
  * Implements hook_init().
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_init() {
+function tripal_chado_views_init() {
 return;
 return;
   // Need to ensure that all chado tables are integrated w/out making
   // Need to ensure that all chado tables are integrated w/out making
   // the user go to views UI. It would be ideal to do this in a hook called only once
   // the user go to views UI. It would be ideal to do this in a hook called only once
@@ -169,9 +169,9 @@ return;
  * Implements hook_help().
  * Implements hook_help().
  * Adds a help page to the module list
  * Adds a help page to the module list
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_help ($path, $arg) {
+function tripal_chado_views_help ($path, $arg) {
   if ($path == 'admin/help#tripal_views') {
   if ($path == 'admin/help#tripal_views') {
     return theme('tripal_views_help', array());
     return theme('tripal_views_help', array());
   }
   }
@@ -182,13 +182,13 @@ function tripal_views_help ($path, $arg) {
  *
  *
  * Set the permission types that the chado module uses.
  * Set the permission types that the chado module uses.
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_permission() {
+function tripal_chado_views_permission() {
   return array(
   return array(
     'manage tripal_views_integration' => array(
     'manage tripal_views_integration' => array(
-      'title' => t('Administrate Tripal Views Integration'),
-      'description' => t('Permission to manage Tripal Views Integration.')
+      'title' => t('Administrate Tripal Chado Views Integration'),
+      'description' => t('Permission to manage Tripal Chado Views Integration.')
     ),
     ),
   );
   );
 }
 }
@@ -197,12 +197,12 @@ function tripal_views_permission() {
  * Implements hook_views_api().
  * Implements hook_views_api().
  *
  *
  * Purpose: Essentially this hook tells drupal that there is views support for
  * Purpose: Essentially this hook tells drupal that there is views support for
- *  for this module which then includes tripal_views.views.inc where all the
+ *  for this module which then includes tripal_chado_views.views.inc where all the
  *  views integration code is
  *  views integration code is
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_views_api() {
+function tripal_chado_views_views_api() {
   return array(
   return array(
     'api' => 3.0,
     'api' => 3.0,
   );
   );
@@ -214,12 +214,12 @@ function tripal_views_views_api() {
  * This hook provides details about themable objects added by
  * This hook provides details about themable objects added by
  *   this module
  *   this module
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_theme($existing, $type, $theme, $path) {
+function tripal_chado_views_theme($existing, $type, $theme, $path) {
   return array(
   return array(
-    'tripal_views_integration_form' => array(
-      'template'  => 'tripal_views_integration_fields_form',
+    'tripal_chado_views_integration_form' => array(
+      'template'  => 'tripal_chado_views_integration_fields_form',
       'render element'=> 'form',
       'render element'=> 'form',
     ),
     ),
     'file_upload_combo' => array(
     'file_upload_combo' => array(
@@ -229,16 +229,16 @@ function tripal_views_theme($existing, $type, $theme, $path) {
       'variables' => array('element' => NULL)
       'variables' => array('element' => NULL)
     ),
     ),
     // instructions page for the views module
     // instructions page for the views module
-    'tripal_views_help' => array(
-      'template' => 'tripal_views_help',
+    'tripal_chado_views_help' => array(
+      'template' => 'tripal_chado_views_help',
       'variables' =>  array(NULL),
       'variables' =>  array(NULL),
-      'path' => drupal_get_path('module', 'tripal_views') . '/theme'
+      'path' => drupal_get_path('module', 'tripal_chado_views') . '/theme'
     ),
     ),
     // search biological content page
     // search biological content page
-    'tripal_views_search_biological_content' => array(
-      'template' => 'tripal_views_search_biological_content',
+    'tripal_chado_views_search_biological_content' => array(
+      'template' => 'tripal_chado_views_search_biological_content',
       'variables' =>  array(NULL),
       'variables' =>  array(NULL),
-      'path' => drupal_get_path('module', 'tripal_views') . '/theme'
+      'path' => drupal_get_path('module', 'tripal_chado_views') . '/theme'
     ),
     ),
   );
   );
 }
 }
@@ -247,9 +247,9 @@ function tripal_views_theme($existing, $type, $theme, $path) {
  * Implements hook_coder_ignore().
  * Implements hook_coder_ignore().
  * Defines the path to the file (tripal_views.coder_ignores.txt) where ignore rules for coder are stored
  * Defines the path to the file (tripal_views.coder_ignores.txt) where ignore rules for coder are stored
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_coder_ignore() {
+function tripal_chado_views_coder_ignore() {
   return array(
   return array(
     'path' => drupal_get_path('module', 'tripal_views'),
     'path' => drupal_get_path('module', 'tripal_views'),
     'line prefix' => drupal_get_path('module', 'tripal_views'),
     'line prefix' => drupal_get_path('module', 'tripal_views'),
@@ -260,9 +260,9 @@ function tripal_views_coder_ignore() {
  * A landing page for all views of chado content. Simply lists all menu items that
  * A landing page for all views of chado content. Simply lists all menu items that
  * are children of it.
  * are children of it.
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_biological_data_page() {
+function tripal_chado_views_biological_data_page() {
   $output = '';
   $output = '';
 
 
   $item = menu_get_item();
   $item = menu_get_item();
@@ -281,9 +281,9 @@ function tripal_views_biological_data_page() {
 /**
 /**
  * Admin launchpad
  * Admin launchpad
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_admin_integration_view() {
+function tripal_chado_views_admin_integration_view() {
   $output = '';
   $output = '';
 
 
   // set the breadcrumb
   // set the breadcrumb
@@ -291,7 +291,9 @@ function tripal_views_admin_integration_view() {
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
-  $breadcrumb[] = l('Intgrations', 'admin/tripal/views-integrations');
+  $breadcrumb[] = l('Data Storage', 'admin/tripal/storage');
+  $breadcrumb[] = l('Chado', 'admin/tripal/storage/chado');
+  $breadcrumb[] = l('Views Integration', 'admin/tripal/storage/chado/views-integration');
   drupal_set_breadcrumb($breadcrumb);
   drupal_set_breadcrumb($breadcrumb);
 
 
   // Add the view
   // Add the view
@@ -300,12 +302,12 @@ function tripal_views_admin_integration_view() {
     $output .= $view;
     $output .= $view;
   }
   }
   else {
   else {
-    $output .= '<p>The Tripal Views Module uses primarily views to provide an '
+    $output .= '<p>The Tripal Chado Views Module uses primarily views to provide an '
       . 'administrative interface. Currently one or more views needed for this '
       . 'administrative interface. Currently one or more views needed for this '
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'enable the pertinent views</strong>:</p>';
       . 'enable the pertinent views</strong>:</p>';
     $output .= '<ul>';
     $output .= '<ul>';
-      $output .= '<li>'.l('Tripal Views Admin', 'admin/tripal/views-integrations/views/integrations/enable').'</li>';
+      $output .= '<li>'.l('Tripal Views Admin', 'admin/tripal/storage/chado/views-integration/views/integrations/enable').'</li>';
     $output .= '</ul>';
     $output .= '</ul>';
   }
   }
 
 

+ 19 - 19
legacy/tripal_views/tripal_views.views.inc → tripal_chado_views/tripal_chado_views.views.inc

@@ -16,13 +16,13 @@ include 'views/handlers/tripal_views_handler_area_action_links.inc';
  * @return
  * @return
  *   An array of handler definitions
  *   An array of handler definitions
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_views_handlers() {
+function tripal_chado_views_views_handlers() {
 
 
   return array(
   return array(
     'info' => array(
     'info' => array(
-      'path' => drupal_get_path('module', 'tripal_views') . '/views/handlers',
+      'path' => drupal_get_path('module', 'tripal_chado_views') . '/views/handlers',
     ),
     ),
     'handlers' => array(
     'handlers' => array(
 
 
@@ -77,9 +77,9 @@ function tripal_views_views_handlers() {
  *   Looking up the NID here ensures the query is only executed once
  *   Looking up the NID here ensures the query is only executed once
  *   for all stocks in the table.
  *   for all stocks in the table.
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_views_pre_render(&$view) {
+function tripal_chado_views_views_pre_render(&$view) {
 
 
   // We need to unset the exposed_input for the view so we can repopulate that
   // We need to unset the exposed_input for the view so we can repopulate that
   // variable. This is necessary if we're using the file_upload_combo
   // variable. This is necessary if we're using the file_upload_combo
@@ -89,7 +89,7 @@ function tripal_views_views_pre_render(&$view) {
 
 
   // Add css if tripal admin tagged view
   // Add css if tripal admin tagged view
   if ($view->tag == 'tripal admin') {
   if ($view->tag == 'tripal admin') {
-    $tripal_admin_view_css = drupal_get_path('module', 'tripal_views') . '/theme/css/tripal_views_admin_views.css';
+    $tripal_admin_view_css = drupal_get_path('module', 'tripal_chado_views') . '/theme/css/tripal_views_admin_views.css';
     drupal_add_css($tripal_admin_view_css);
     drupal_add_css($tripal_admin_view_css);
   }
   }
 
 
@@ -109,16 +109,16 @@ function tripal_views_views_pre_render(&$view) {
  *
  *
  * D7 @todo: Add support for materialized views relationships using the new method
  * D7 @todo: Add support for materialized views relationships using the new method
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_views_data() {
+function tripal_chado_views_views_data() {
   $data = array();
   $data = array();
 
 
   // Manually integrate the drupal.tripal_views* tables
   // Manually integrate the drupal.tripal_views* tables
-  $data = tripal_views_views_data_tripal_views_tables($data);
+  $data = tripal_chado_views_views_data_tripal_views_tables($data);
 
 
   // MAKE SURE ALL CHADO TABLES ARE INTEGRATED
   // MAKE SURE ALL CHADO TABLES ARE INTEGRATED
-  tripal_views_integrate_all_chado_tables();
+  tripal_chado_views_integrate_all_chado_tables();
 
 
   // DEFINE GLOBAL FIELDS
   // DEFINE GLOBAL FIELDS
   // Filter handler that lets the admin say:
   // Filter handler that lets the admin say:
@@ -263,7 +263,7 @@ function tripal_views_views_data() {
         );
         );
 
 
         tripal_report_error(
         tripal_report_error(
-          'tripal_views',
+          'tripal_chado_views',
           TRIPAL_WARNING,
           TRIPAL_WARNING,
           "The name and help were not set for %table.%column. As a consequence the column
           "The name and help were not set for %table.%column. As a consequence the column
             name has been used... You should ensure that the 'name' and 'help' keys for
             name has been used... You should ensure that the 'name' and 'help' keys for
@@ -304,7 +304,7 @@ function tripal_views_views_data() {
       // If there were no handlers applied to the current field then warn the administrator!
       // If there were no handlers applied to the current field then warn the administrator!
       if ($num_handlers == 0) {
       if ($num_handlers == 0) {
         tripal_report_error(
         tripal_report_error(
-          'tripal_views',
+          'tripal_chado_views',
           TRIPAL_WARNING,
           TRIPAL_WARNING,
           "No handlers were registered for %table.%column. This means there is no views
           "No handlers were registered for %table.%column. This means there is no views
             functionality for this column. To register handlers, make sure the 'handlers'
             functionality for this column. To register handlers, make sure the 'handlers'
@@ -360,7 +360,7 @@ function tripal_views_views_data() {
 
 
       // warn if deprecated method of relationship addition was used (ie: through handlers)
       // warn if deprecated method of relationship addition was used (ie: through handlers)
       if (isset($data[$base_table][$base_field]['relationship'])) {
       if (isset($data[$base_table][$base_field]['relationship'])) {
-        tripal_report_error('tripal_views', TRIPAL_NOTICE,
+        tripal_report_error('tripal_chado_views', TRIPAL_NOTICE,
           'DEPRECATED: Currently using tripal_views_handlers to store relationship for %base => %left when you should be using tripal_views_joins.',
           'DEPRECATED: Currently using tripal_views_handlers to store relationship for %base => %left when you should be using tripal_views_joins.',
           array('%base' => $base_table, '%left' => $left_table));
           array('%base' => $base_table, '%left' => $left_table));
       }
       }
@@ -416,9 +416,9 @@ function tripal_views_views_data() {
 /**
 /**
  * Describes the tripal views integration tables to views for the administration views
  * Describes the tripal views integration tables to views for the administration views
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_views_data_tripal_views_tables($data) {
+function tripal_chado_views_views_data_tripal_views_tables($data) {
 
 
   $data['tripal_views']['table']['group'] = t('Tripal Views Integration');
   $data['tripal_views']['table']['group'] = t('Tripal Views Integration');
   $data['tripal_views']['table']['base'] = array(
   $data['tripal_views']['table']['base'] = array(
@@ -568,9 +568,9 @@ function tripal_views_views_data_tripal_views_tables($data) {
  * Used to add Chado <-> Node Joins & Relationships
  * Used to add Chado <-> Node Joins & Relationships
  *   since you need to add to the $data['node'] to do this
  *   since you need to add to the $data['node'] to do this
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_views_data_alter(&$data) {
+function tripal_chado_views_views_data_alter(&$data) {
 
 
     // ADD IN NODE JOINS & RELATIONSHIPS
     // ADD IN NODE JOINS & RELATIONSHIPS
     // D7 @todo: Create custom handler to allow join from Node => Base (ie: organism)
     // D7 @todo: Create custom handler to allow join from Node => Base (ie: organism)
@@ -659,8 +659,8 @@ function tripal_views_views_data_alter(&$data) {
  * file uploads require $_POST. We need to make sure these two modules
  * file uploads require $_POST. We need to make sure these two modules
  * have access to everything needed for this view to work properly.
  * have access to everything needed for this view to work properly.
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_views_pre_view(&$view, &$display_id, &$args) {
+function tripal_chado_views_views_pre_view(&$view, &$display_id, &$args) {
   $_GET = array_merge($_GET, $_POST);
   $_GET = array_merge($_GET, $_POST);
 }
 }

+ 11 - 11
legacy/tripal_views/tripal_views.views_default.inc → tripal_chado_views/tripal_chado_views.views_default.inc

@@ -6,12 +6,12 @@
 /**
 /**
  * Implements hook_views_default_views().
  * Implements hook_views_default_views().
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_views_default_views() {
+function tripal_chado_views_views_default_views() {
   $views = array();
   $views = array();
 
 
-  $view = tripal_views_defaultview_admin_integrations();
+  $view = tripal_chado_views_defaultview_admin_integrations();
   $views[$view->name] = $view;
   $views[$view->name] = $view;
 
 
   return $views;
   return $views;
@@ -20,9 +20,9 @@ function tripal_views_views_default_views() {
 /**
 /**
  * Default integrations administration view
  * Default integrations administration view
  *
  *
- * @ingroup tripal_views
+ * @ingroup tripal_chado_views
  */
  */
-function tripal_views_defaultview_admin_integrations() {
+function tripal_chado_views_defaultview_admin_integrations() {
 
 
   $view = new view();
   $view = new view();
   $view->name = 'tripal_views_admin_integrations';
   $view->name = 'tripal_views_admin_integrations';
@@ -116,11 +116,11 @@ function tripal_views_defaultview_admin_integrations() {
   $handler->display->display_options['header']['action_links_area']['empty'] = TRUE;
   $handler->display->display_options['header']['action_links_area']['empty'] = TRUE;
   $handler->display->display_options['header']['action_links_area']['link-1'] = array(
   $handler->display->display_options['header']['action_links_area']['link-1'] = array(
     'label-1' => 'Add New Integration',
     'label-1' => 'Add New Integration',
-    'path-1' => 'admin/tripal/views-integration/new',
+    'path-1' => 'admin/tripal/storage/chado/views-integration/new',
   );
   );
   $handler->display->display_options['header']['action_links_area']['link-2'] = array(
   $handler->display->display_options['header']['action_links_area']['link-2'] = array(
     'label-2' => 'Import Integration',
     'label-2' => 'Import Integration',
-    'path-2' => 'admin/tripal/views-integration/import',
+    'path-2' => 'admin/tripal/storage/chado/views-integration/import',
   );
   );
   $handler->display->display_options['header']['action_links_area']['link-3'] = array(
   $handler->display->display_options['header']['action_links_area']['link-3'] = array(
     'label-3' => '',
     'label-3' => '',
@@ -138,7 +138,7 @@ function tripal_views_defaultview_admin_integrations() {
   $handler->display->display_options['header']['action_links_area_1']['empty'] = TRUE;
   $handler->display->display_options['header']['action_links_area_1']['empty'] = TRUE;
   $handler->display->display_options['header']['action_links_area_1']['link-1'] = array(
   $handler->display->display_options['header']['action_links_area_1']['link-1'] = array(
     'label-1' => 'Delete ALL Integrations',
     'label-1' => 'Delete ALL Integrations',
-    'path-1' => 'admin/tripal/views-integration/delete-all/confirm',
+    'path-1' => 'admin/tripal/storage/chado/views-integration/delete-all/confirm',
   );
   );
   $handler->display->display_options['header']['action_links_area_1']['link-2'] = array(
   $handler->display->display_options['header']['action_links_area_1']['link-2'] = array(
     'label-2' => '',
     'label-2' => '',
@@ -193,7 +193,7 @@ function tripal_views_defaultview_admin_integrations() {
   $handler->display->display_options['fields']['nothing']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing']['alter']['text'] = 'edit';
   $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']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing']['alter']['path'] = 'admin/tripal/views-integration/edit/[setup_id]';
+  $handler->display->display_options['fields']['nothing']['alter']['path'] = 'admin/tripal/storage/chado/views-integration/edit/[setup_id]';
   /* Field: Global: Custom text */
   /* Field: Global: Custom text */
   $handler->display->display_options['fields']['nothing_1']['id'] = 'nothing_1';
   $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']['table'] = 'views';
@@ -202,7 +202,7 @@ function tripal_views_defaultview_admin_integrations() {
   $handler->display->display_options['fields']['nothing_1']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing_1']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing_1']['alter']['text'] = 'delete';
   $handler->display->display_options['fields']['nothing_1']['alter']['text'] = 'delete';
   $handler->display->display_options['fields']['nothing_1']['alter']['make_link'] = TRUE;
   $handler->display->display_options['fields']['nothing_1']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/views-integration/delete/[setup_id]';
+  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/storage/chado/views-integration/delete/[setup_id]';
   /* Field: Global: Custom text */
   /* Field: Global: Custom text */
   $handler->display->display_options['fields']['nothing_2']['id'] = 'nothing_2';
   $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']['table'] = 'views';
@@ -211,7 +211,7 @@ function tripal_views_defaultview_admin_integrations() {
   $handler->display->display_options['fields']['nothing_2']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing_2']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing_2']['alter']['text'] = 'export';
   $handler->display->display_options['fields']['nothing_2']['alter']['text'] = 'export';
   $handler->display->display_options['fields']['nothing_2']['alter']['make_link'] = TRUE;
   $handler->display->display_options['fields']['nothing_2']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing_2']['alter']['path'] = 'admin/tripal/views-integration/export/[setup_id]';
+  $handler->display->display_options['fields']['nothing_2']['alter']['path'] = 'admin/tripal/storage/chado/views-integration/export/[setup_id]';
   /* Field: Global: Custom text */
   /* Field: Global: Custom text */
   $handler->display->display_options['fields']['nothing_3']['id'] = 'nothing_3';
   $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']['table'] = 'views';

+ 0 - 0
legacy/tripal_views/tripal_views_integration_fields_form.tpl.php → tripal_chado_views/tripal_views_integration_fields_form.tpl.php


+ 0 - 0
legacy/tripal_views/views-sql-compliant-three-tier-naming-1971160-22.patch → tripal_chado_views/views-sql-compliant-three-tier-naming-1971160-22.patch


+ 0 - 0
legacy/tripal_views/views/handlers/tripal_views_handler_area_action_links.inc → tripal_chado_views/views/handlers/tripal_views_handler_area_action_links.inc


+ 0 - 0
legacy/tripal_views/views/handlers/tripal_views_handler_field_sequence.inc → tripal_chado_views/views/handlers/tripal_views_handler_field_sequence.inc


+ 0 - 0
legacy/tripal_views/views/handlers/tripal_views_handler_filter_file_upload.inc → tripal_chado_views/views/handlers/tripal_views_handler_filter_file_upload.inc


+ 0 - 0
legacy/tripal_views/views/handlers/tripal_views_handler_filter_no_results.inc → tripal_chado_views/views/handlers/tripal_views_handler_filter_no_results.inc


+ 0 - 0
legacy/tripal_views/views/handlers/tripal_views_handler_filter_select_cvterm.inc → tripal_chado_views/views/handlers/tripal_views_handler_filter_select_cvterm.inc


+ 0 - 0
legacy/tripal_views/views/handlers/tripal_views_handler_filter_select_id.inc → tripal_chado_views/views/handlers/tripal_views_handler_filter_select_id.inc


+ 0 - 0
legacy/tripal_views/views/handlers/tripal_views_handler_filter_select_string.inc → tripal_chado_views/views/handlers/tripal_views_handler_filter_select_string.inc


+ 0 - 0
legacy/tripal_views/views/handlers/tripal_views_handler_filter_sequence.inc → tripal_chado_views/views/handlers/tripal_views_handler_filter_sequence.inc


+ 0 - 0
legacy/tripal_views/views/handlers/tripal_views_handler_filter_textarea.inc → tripal_chado_views/views/handlers/tripal_views_handler_filter_textarea.inc