Browse Source

bringing things up to date

Shawna Spoor 6 years ago
parent
commit
738af9cf63
100 changed files with 5271 additions and 3989 deletions
  1. 2 2
      .github/PULL_REQUEST_TEMPLATE.md
  2. 6 1
      .gitignore
  3. 10 3
      .travis.yml
  4. 5 0
      composer.json
  5. 3 2
      docs/contributing.rst
  6. 2 0
      docs/contributing/documentation.rst
  7. 7 0
      docs/contributing/funding.rst
  8. 138 0
      docs/contributing/governance.rst
  9. 0 0
      docs/contributing/pull_requests.rst
  10. 0 0
      docs/contributing/tests.rst
  11. 1 1
      docs/dev_guide.rst
  12. 1 1
      docs/dev_guide/best_practices.rst
  13. 0 19
      docs/dev_guide/contributing/governance.rst
  14. 3 2
      docs/dev_guide/custom_data_loader.rst
  15. 3 0
      docs/dev_guide/custom_field.rst
  16. 114 0
      docs/dev_guide/custom_field/ajax_custom_formatter.rst
  17. 223 0
      docs/dev_guide/custom_field/create_instance.rst
  18. BIN
      docs/dev_guide/custom_field/custom_formatter.pager.1.png
  19. 208 0
      docs/dev_guide/custom_field/custom_formatter.rst
  20. BIN
      docs/dev_guide/custom_field/custom_formatter.settings.1.png
  21. BIN
      docs/dev_guide/custom_field/custom_formatter.settings.2.png
  22. 52 12
      docs/dev_guide/custom_field/custom_widget.rst
  23. 1 19
      docs/dev_guide/custom_field/manual_field_creation.rst
  24. 55 0
      docs/dev_guide/rtd.rst
  25. 5 28
      docs/extensions.rst
  26. 12 0
      docs/extensions/3rd_party.rst
  27. BIN
      docs/extensions/Tripal-Bronze.png
  28. 0 0
      docs/extensions/Tripal-Bronze.svg
  29. BIN
      docs/extensions/Tripal-Gold.png
  30. 0 0
      docs/extensions/Tripal-Gold.svg
  31. BIN
      docs/extensions/Tripal-Silver.png
  32. 0 0
      docs/extensions/Tripal-Silver.svg
  33. 4 0
      docs/extensions/administrative.rst
  34. 8 0
      docs/extensions/data_input.rst
  35. 8 0
      docs/extensions/in_development.rst
  36. 33 0
      docs/extensions/instructions.rst
  37. 83 0
      docs/extensions/module_rating.rst
  38. 9 0
      docs/extensions/visualization.rst
  39. 1 0
      docs/index.rst
  40. 1 1
      docs/tripal_doxygen.config
  41. 5 1
      docs/user_guide/example_genomics.rst
  42. 18 4
      docs/user_guide/install_tripal/drush_installation.rst
  43. 6 6
      docs/user_guide/install_tripal/manual_install/install_drupal.rst
  44. 1 1
      docs/user_guide/install_tripal/rapid_install.rst
  45. 1 1
      docs/user_guide/install_tripal/server_setup/ubuntu_18.04.rst
  46. 1 1
      docs/user_guide/install_tripal/upgrade_from_tripal2.rst
  47. 2 2
      docs/user_guide/job_management.rst
  48. 68 65
      legacy/tripal_analysis/api/tripal_analysis.DEPRECATED.inc
  49. 26 21
      legacy/tripal_analysis/includes/tripal_analysis.admin.inc
  50. 193 186
      legacy/tripal_analysis/includes/tripal_analysis.chado_node.inc
  51. 33 34
      legacy/tripal_analysis/includes/tripal_analysis.delete.inc
  52. 27 15
      legacy/tripal_analysis/includes/tripal_analysis_privacy.inc
  53. 48 48
      legacy/tripal_analysis/theme/templates/tripal_analysis_base.tpl.php
  54. 45 24
      legacy/tripal_analysis/theme/templates/tripal_analysis_help.tpl.php
  55. 19 17
      legacy/tripal_analysis/theme/templates/tripal_analysis_properties.tpl.php
  56. 11 11
      legacy/tripal_analysis/theme/templates/tripal_analysis_teaser.tpl.php
  57. 1 1
      legacy/tripal_analysis/tripal_analysis.info
  58. 25 25
      legacy/tripal_analysis/tripal_analysis.views_default.inc
  59. 62 61
      legacy/tripal_contact/api/tripal_contact.DEPRECATED.inc
  60. 24 22
      legacy/tripal_contact/includes/tripal_contact.admin.inc
  61. 174 158
      legacy/tripal_contact/includes/tripal_contact.chado_node.inc
  62. 24 24
      legacy/tripal_contact/theme/templates/tripal_contact_base.tpl.php
  63. 39 19
      legacy/tripal_contact/theme/templates/tripal_contact_help.tpl.php
  64. 24 22
      legacy/tripal_contact/theme/templates/tripal_contact_properties.tpl.php
  65. 40 35
      legacy/tripal_contact/theme/templates/tripal_contact_publications.tpl.php
  66. 103 97
      legacy/tripal_contact/theme/templates/tripal_contact_relationships.tpl.php
  67. 15 15
      legacy/tripal_contact/theme/templates/tripal_contact_teaser.tpl.php
  68. 23 23
      legacy/tripal_contact/theme/tripal_contact.theme.inc
  69. 1 1
      legacy/tripal_contact/tripal_contact.info
  70. 33 33
      legacy/tripal_contact/tripal_contact.views_default.inc
  71. 241 232
      legacy/tripal_core/api/tripal_core.DEPRECATED.inc
  72. 281 265
      legacy/tripal_core/api/tripal_core.chado_nodes.api.inc
  73. 278 252
      legacy/tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc
  74. 312 285
      legacy/tripal_core/api/tripal_core.chado_nodes.properties.api.inc
  75. 330 299
      legacy/tripal_core/api/tripal_core.chado_nodes.relationships.api.inc
  76. 340 302
      legacy/tripal_core/api/tripal_core.chado_nodes.title_and_path.inc
  77. 9 8
      legacy/tripal_core/api/tripal_core.tripal_variables.api.inc
  78. 39 39
      legacy/tripal_core/includes/tripal_core.form_elements.inc
  79. 87 71
      legacy/tripal_core/includes/tripal_core.search.inc
  80. 103 104
      legacy/tripal_core/includes/tripal_core.toc.inc
  81. 64 60
      legacy/tripal_core/theme/templates/node--chado-generic.tpl.php
  82. 5 3
      legacy/tripal_core/theme/templates/tripal_core_jobs_help.tpl.php
  83. 5 3
      legacy/tripal_core/theme/templates/tripal_core_mviews_help.tpl.php
  84. 84 84
      legacy/tripal_core/tripal_core.drush.inc
  85. 1 1
      legacy/tripal_core/tripal_core.info
  86. 9 9
      legacy/tripal_core/tripal_core.views_default.inc
  87. 112 111
      legacy/tripal_cv/api/tripal_cv.DEPRECATED.inc
  88. 25 22
      legacy/tripal_cv/api/tripal_cv.api.inc
  89. 96 96
      legacy/tripal_cv/includes/tripal_cv.cv_defaults.inc
  90. 54 34
      legacy/tripal_cv/theme/templates/tripal_cv_help.tpl.php
  91. 1 1
      legacy/tripal_cv/tripal_cv.info
  92. 1 1
      legacy/tripal_cv/tripal_cv.views_default.inc
  93. 74 74
      legacy/tripal_db/api/tripal_db.DEPRECATED.inc
  94. 38 20
      legacy/tripal_db/theme/templates/tripal_db_help.tpl.php
  95. 1 1
      legacy/tripal_db/tripal_db.info
  96. 1 2
      legacy/tripal_db/tripal_db.views_default.inc
  97. 184 182
      legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc
  98. 72 70
      legacy/tripal_feature/includes/tripal_feature.admin.inc
  99. 290 249
      legacy/tripal_feature/includes/tripal_feature.chado_node.inc
  100. 44 45
      legacy/tripal_feature/includes/tripal_feature.delete.inc

+ 2 - 2
.github/PULL_REQUEST_TEMPLATE.md

@@ -6,7 +6,7 @@
 
 <!---  Please set the header below based on the PR type:
 # New Feature
-# Bux Fix
+# Bug Fix
 # Documentation  --->
 
 #
@@ -28,4 +28,4 @@ Issue #
 ## Additional Notes (if any):
 
 <!--- New features should include in-line code documentation. -->
-<!--- Would a user or developer guide be helpful for this feature? -->
+<!--- Would a user or developer guide be helpful for this feature? -->

+ 6 - 1
.gitignore

@@ -5,4 +5,9 @@ tests/.env
 .buildpath
 .project
 .settings/
-docs/_build/
+docs/_build
+docs/docs
+docs/html
+docs/latex
+docs/xml
+

+ 10 - 3
.travis.yml

@@ -7,14 +7,16 @@ services:
 sudo: required
 
 php:
-  - 7.0
   - 7.1
+  - 7.2
+#  PHP 7.3 is not yet supported (issue: https://www.drupal.org/project/drupal/issues/3012308)
+#  - 7.3
 
 env:
   - BASE_URL="http://127.0.0.1:8080"
 
 install:
-  - composer global require drush/drush:8
+  - composer global require "drush/drush:~8"
 
 before_script:
   - docker pull statonlab/tripal2
@@ -46,12 +48,16 @@ before_script:
   - drush en -y field_group, field_group_table, field_formatter_class, field_formatter_settings, ctools, date, devel,
               ds, link, entity, libraries, redirect, token uuid, jquery_update, views, webform
 
+  # up memory limit of PHP
+  - echo "memory_limit=2G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
+
+
 script:
   # Link our repo to the modules directory
   - mv ../tripal sites/all/modules/tripal
 
   # Run a docker container with tripal 2 pre-installed
-  - docker run -it -d --rm --name tripal2 -v "$(pwd)/tripal":/modules/tripal statonlab/tripal2
+  - docker run -it -d --rm --name tripal2 -v "$(pwd)/sites/all/modules/tripal":/tripal statonlab/tripal2
 
   # Apply patches
   - wget --no-check-certificate https://drupal.org/files/drupal.pgsql-bytea.27.patch
@@ -76,4 +82,5 @@ script:
 
   # Test Tripal v2 to v3 upgrade steps
   - docker exec -it tripal2 drush pm-disable tripal_core -y
+  - docker exec -it tripal2 bash -c "rm -rf /modules/tripal && ln -s /tripal /modules/tripal"
   - docker exec -it tripal2 drush en -y tripal

+ 5 - 0
composer.json

@@ -5,6 +5,11 @@
     "doctrine/instantiator": "1.0.*",
     "statonlab/tripal-test-suite": "1.*"
   },
+  "autoload": {
+    "files": [
+      "tests/TripalFieldTestHelper.php"
+    ]
+  },
   "require": {
   }
 }

+ 3 - 2
docs/dev_guide/contributing.rst → docs/contributing.rst

@@ -1,5 +1,5 @@
-Contributing to Tripal Core Code
-================================
+Tripal Community
+==================
 
 
 
@@ -12,3 +12,4 @@ Contributing to Tripal Core Code
    contributing/tests
    contributing/documentation
    contributing/governance
+   contributing/funding

+ 2 - 0
docs/dev_guide/contributing/documentation.rst → docs/contributing/documentation.rst

@@ -1,3 +1,5 @@
+.. _tripal_rtd:
+
 Contributing to the Documentation
 ==================================
 

+ 7 - 0
docs/contributing/funding.rst

@@ -0,0 +1,7 @@
+
+Funding Proposal Development
+==============================
+
+Tripal fully supports all community members who want to submit grant proposals for Tripal extensions. Extension development is outside the purview of the Tripal governance structure, although the Tripal Project Management Committee (TPMC) and Tripal Steering Committee (TSC) are available to help with grant submissions, through alignment with Tripal core long term goals, letters of support, etc.
+
+PIs planning to write a grant that would fund any development related to Tripal core are strongly encouraged to engage the TPMC and TSC early in the planning process to ensure the grant aligns with the long term community goals. Any core development plans are still required to go through the Tripal governance structure. Specifically, only development approved by the TPMC and TSC will be implemented or accepted in core. PIs, especially if funded, are strongly encouraged to engage with the Tripal community and to request membership in the TPMC and/or TSC.

+ 138 - 0
docs/contributing/governance.rst

@@ -0,0 +1,138 @@
+Tripal Governance
+==================
+
+We wish to maintain Tripal as an open source project and therefore want to empower  Tripal adopters and developers as much as possible in the development of Tripal, while keeping the project coherent, focused, and useable to a wide range of adopters. As the Tripal community grows, it is prudent to set up a formal governance model. This document describes this model.
+
+The Tripal project recognizes these roles:
+ - **End-Users**: They are users of Tripal-based websites (not developers of a site).
+ - **Adopters**: They have downloaded Tripal. Maybe they even have a site!
+ - **Extension Contributors**: they extend Tripal through modules, themes, views, data loaders, fields, and/or libraries.
+ - **Core Code Contributors**: contribute code to the `Tripal "core" <https://github.com/tripal/tripal>`_, comments, discussion, questions, bug reports.
+ - **Core Code Committers**: write access to the `Tripal "core" repository <https://github.com/tripal/tripal>`_.
+ - **Tripal Project Management Committee (TPMC)**: make *code relevant* decisions, (i.e. ensure code standards, robustness, and long-term design objectives are maintained).
+ - **Tripal Steering Committee (TSC)**: Provide guidance to the TPMC for *policy-level* and *future planning* recommendations.
+
+Adopters
+----------
+
+Any person who wishes to or has downloaded/set up a Tripal site.  Everyone in this group is invited to the monthly user meetings and is encouraged to ask questions and make suggestions.
+
+Extension Contributors
+-----------------------
+
+These are developers who are extending Tripal. Extension contributors are encouraged to make their extensions available on the `Tripal GitHub organization <https://github.com/tripal>`_ and list them on the `Tripal Documentation <https://tripal.readthedocs.io/en/latest/extensions.html>`_. Extension contributors are also encouraged to use the `Tripal Module Rating System <https://tripal.readthedocs.io/en/latest/extensions/module_rating.html>`_ as a guideline for developing high quality modules, which are easier to adopt by the greater Tripal community.
+
+Core Code Contributors
+------------------------
+Core Code Contributors are active members of the Tripal community who make suggestions to improve and/or contribute code to Tripal Core. Core Code Contributors are encouraged to submit pull requests to the Tripal core and attend monthly user calls. For more information, see the `Guidelines for Contributing to Tripal core <https://tripal.readthedocs.io/en/latest/dev_guide/contributing/pull_requests.html>`_.
+
+Responsibilities include:
+ - Monitor Tripal core issue queue.
+ - Submit pull requests.
+
+Committers
+------------
+
+These are dedicated Tripal developers who are trusted to commit pull requests directly to the Tripal core repository. They are encouraged to be active in the Tripal community and routinely review pull requests. Developers are added to to committers group by unanimous agreement from the TPMC.
+
+Responsibilities include:
+ - Monitor Tripal core issue queue.
+ - Review and merge pull requests.
+
+See the `guidelines for contributors <https://tripal.readthedocs.io/en/latest/dev_guide/contributing/pull_requests.html>`_ for more details.
+
+The Tripal Project Management Committee (TPMC)
+------------------------------------------------
+
+This group consists of experienced Tripal developers.
+
+Responsibilities include:
+ - Ensure good practices, for example, submitting errors, questions, and requests via GitHub.
+ - Monitor issue queue (though this responsibility isn't limited to the TPMC).
+ - Resolve questions and differences of opinions among Contributors.
+ - Work with the TSC to make decisions about significant new features. Examples:
+     - a new core module,
+     - designing a module-specific REST API,
+     - new technologies or libraries used by the core code.
+ - Avoid feature bloat; judge what contributions benefit many versus those that are specific to the needs of the contributor.
+ - Final approval of submitting guidelines (see `guidelines for contribution <https://tripal.readthedocs.io/en/latest/dev_guide/contributing.html>`_).
+ - Set coding standards.
+ - Ensure Tripal remains generic and useful to a wide range of groups.
+
+The TPMC will strive to obtain consensus, and all members ensure that the Tripal community and the TSC are informed on decisions. Any individual member can call a meeting. The term will be two years with the possibility of extension. At least one member will serve on the TSC; this person will be elected by vote within the TPMC.
+
+Communication and Meetings
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The TPMC will meet as necessary. It is expected that frequent decisions will need to be made, some through GitHub issue comments, Slack, e-mail, or conference calls.
+
+Tripal Steering Committee (TSC)
+---------------------------------
+The Tripal Steering Committee (TSC) provides leadership, guidance, future planning, advocacy and coordination for Tripal. The TSC acts in an advisory capacity only by determining sets of recommendations for Tripal. All recommendations will be provided to the TPMC. Topics include recommended technologies, overall approach, software architecture, development priorities, timelines, funding strategies, best practices, support for a fair and focused open source development strategy.
+
+At least one member of the TPMC must be on the TSC to ensure that the reality of what is and is not feasible for the developers is not lost. Additionally, close communication between the TSC and TPMC is critical, as is transparency of the TSC discussions to the entire Tripal community. All members of the TPMC are welcome at TSC meetings.
+
+Membership
+^^^^^^^^^^^^
+The TSC should include "internal" and "external" members. Internal members are individuals who manage Tripal websites or lead teams engaged in active development, possibly with funding to do so. External members may be outside the Tripal community altogether, and may include government, non-profit, or industry representatives who are stakeholders for one or more Tripal databases (but not active managers of a Tripal site) and/or specialists in such disciplines as cyberinfrastructure, bioinformatics, genomics, breeding.
+
+- Terms are for two years.
+- Two year memberships can be renewed for individuals who wish to stay on to complete a particular objective.
+- Membership is capped at 15.
+   - Initial Setup:
+      - Start small and move larger as needed.
+      - Set minimum sizes for number of internal and external members.
+      - Committee should be organized before inviting external members.
+      - Stagger ends of terms to ensure continuity.
+- The minimum number of internal members is 3.
+- The number of internal members should not be less than 1/2.
+- The target number of external members is 5.
+- If the TSC decides to replace a leaving member, the current members will develop a list of possible candidates. The chair will contact each in turn until the membership slot is filled.
+- Members will be asked to serve by the current TSC.
+
+Responsibilities include:
+ - Serving a minimum two year term, beginning with the yearly board meeting (see below) in conjunction with the January Plant and Animal Genome Conference in San Diego.
+ - Respond to issues in a timely manner when contacted directly. Members are strongly encouraged to become part of the TSC GitHub group, and if they wish to comment or discuss agenda items directly with the community, to do so in the GitHub issue queue (instead of the email list serve).
+ - Attend the annual January meeting at PAG and at least three of the quarterly meetings.
+ - Review agenda and supporting materials prior to meetings.
+ - Stay informed about Tripal, its member databases, developers, and users.
+
+In addition, internal members are responsible for:
+ - Actively communicating with the Tripal community, both to collect ideas and concerns and to inform the community about TSC plans for Tripal.
+ - Engaging in the Tripal Core GitHub Issue queue on “discussion” issues.
+
+TSC Chair
+^^^^^^^^^^^
+
+The board will be led by a chair to be elected by TSC members at the January meeting annually (see below). One or more vice-chairs can be designated by the chair. The chair will ensure that the following is accomplished, delegating responsibilities as needed:
+ - Organize, announce and lead TSC meetings.
+ - Write the meeting agenda and post to Tripal.info.
+ - Provide supporting materials for review at least 1 week before TSC meetings.
+ - Ensure that the agenda items that would benefit from review by the community are posted to the GitHub Tripal core issue queue. Ensure that any GitHub issue discussions are linked on the agenda and available for review by the TSC.
+ - Ensure meeting notes are taken by someone present at the meeting and posted to Tripal.info.
+ - Call for votes on TSC recommendations when community voting is required.
+ - Call additional meetings if needed.
+ - Facilitate communication between the TSC and TPMC.
+ - Filling vacant slots on the TSC.
+ - The chair has voting privileges.
+
+TSC Meeting Agenda Items
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Strongly encouraged to be posted to the GitHub Tripal core issue queue as well as to tripal.info, to inform and solicit community comment. TSC meeting agendas will include issues tagged “TSC Next Meeting” on the GitHub Tripal core issue queue. Other agenda items may be added by the TSC chair or members, or by the TPMC. These issues will be closed after the meeting.
+
+Communication and Meetings
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The primary TSC meeting will be held in January of each year, at the Tripal codefest. In-person attendance is strongly encouraged, but a teleconference option will be provided. Each issue on the agenda will be discussed, and if needed, the chair will call for a vote to determine the final recommendation of the TSC. Votes carry based on simple majority. All discussion, votes and objections will be recorded in meeting notes, which will be posted on Tripal.info.
+
+Additional teleconference TSC meetings will be held once per quarter (April, July, October).  These could be held in place of the monthly Tripal User's Meeting to avoid meeting overload.
+
+TSC meetings outside the above schedule may be called by the TSC chair. These will only be called in urgent situations. In less urgent situations, the TSC chair or the TPMC can contact the internal members of the TSC and request a meeting or solicit comments via email, GitHub issue, or Slack.
+
+At any time the TPMC may communicate with members of the TSC with expertise in specific areas if needed to assist in decision making.
+
+Changes to this Document
+--------------------------
+
+These guidelines define the structure for official Tripal Management and Governance. If you have comments or questions, please `post them as a Github issue <https://github.com/tripal/tripal/issues/new?template=discussion.md>`_ or ask them at the user's meeting. Changes to this document will be made after adequate discussion has occurred and the project management committee has voted in favor of the change.

+ 0 - 0
docs/dev_guide/contributing/pull_requests.rst → docs/contributing/pull_requests.rst


+ 0 - 0
docs/dev_guide/contributing/tests.rst → docs/contributing/tests.rst


+ 1 - 1
docs/dev_guide.rst

@@ -15,5 +15,5 @@ Developer's Guide
    dev_guide/exporting_field_settings
    dev_guide/custom_data_loader
    dev_guide/custom_web_services
-   dev_guide/contributing
+   dev_guide/rtd
    dev_guide/tutorials

+ 1 - 1
docs/dev_guide/best_practices.rst

@@ -13,7 +13,7 @@ Before staring your development work, it is suggested that you download and inst
 Add your module to Tripal.info
 ------------------------------
 
-Do your best to list and upate your modules at http://tripal.info/extensions.
+Add your modules to the Tripal ReadtheDocs :doc:`../extensions` list. The :doc:`../extensions/module_rating` was designed to give guidance on Tripal module development best practices.
 
 
 Coding Best Practices

+ 0 - 19
docs/dev_guide/contributing/governance.rst

@@ -1,19 +0,0 @@
-Tripal Governance
-==================
-
-Changes to this Document
---------------------------
-
-
-These guidelines are binding to the Tripal Community. If you have comments or questions, please `comment on the Github issue <https://github.com/tripal/tripal/issues/344>`_. Changes to this document will be made after adequate discussion has occurred and the project management committee has voted in favor of the change.
-
-Governance Structure
----------------------
-
-The Tripal project recognizes these roles:
-
-- Users: They have downloaded Tripal!  Maybe they even have a site!
-- Contributors: contributing!  Code, comments, discussion, questions, bug reports.
-- Committers: write access to the repository.
-- PMC: Makes **code relevant** decisions.
-- Oversight committee: Makes **policy level** decisions.  This may overlap with PMC, but the idea is the oversight committee includes parties who are **not necessarily coders** and therefore not reviewing Pull requests etc.

+ 3 - 2
docs/dev_guide/custom_data_loader.rst

@@ -343,8 +343,9 @@ To import data into Chado we will use the Tripal API. After splitting each line
     // to load the entire file into memory but rather to iterate over each
     // line separately.
     $bytes_read = 0;
-    while ($line = fgets($file_path)) {
-
+    $in_fh = fopen($file_path, "r");
+    while ($line = fgets($in_fh)) {
+  
       // Calculate how many bytes we have read from the file and let the
       // importer know how many have been processed so it can provide a
       // progress indicator.

+ 3 - 0
docs/dev_guide/custom_field.rst

@@ -43,4 +43,7 @@ The rest of this section will walk you through these steps.
    custom_field/select_vocab_terms
    custom_field/manual_field_creation
    custom_field/custom_widget
+   custom_field/custom_formatter
+   custom_field/ajax_custom_formatter
+   custom_field/create_instance
    custom_field/tripal_field_generator

+ 114 - 0
docs/dev_guide/custom_field/ajax_custom_formatter.rst

@@ -0,0 +1,114 @@
+AJAX Responsive Formatters
+===========================
+
+
+Some fields need to be responsive.  For example, a user might select an analysis or organism to display data from. Drupal developers often use AJAX to rebuild the page based on user input.
+
+Drupal and AJAX
+---------------
+
+Drupal has its own special way of doing AJAX! This is important to ensure that changes are executed in the correct order. You should `read the documentation carefully! <https://api.drupal.org/api/drupal/includes%21ajax.inc/group/ajax/7.x>`_  The Drupal AJAX API works best on forms, and field formatters **are not forms**.  Instead, they are `renderable arrays. <https://www.drupal.org/docs/7/api/render-arrays/render-arrays-overview>`_
+As such, rather than accepting ``$form`` and ``&$form_state``, they accept ``&$element``, ``$entity_type``, ``$entity``, ``$langcode``, ``$items``, and ```$display``, where ``$element`` is the renderable array.
+
+This means if you want to add an AJAX callback to a field formatter, you  need a **separate form function** that gets added in using ``drupal_get_form()``.  If you do this, you can build the AJAX as Drupal expects it.
+
+
+Example form and field
+----------------------
+
+Here's an example form file below: as you can see it's a standard form following Drupal AJAX conventions.  We provide a ``rendered_maps`` fieldset with the prefix defining the wrapper (``examplemap-featuremap-organism-selector-wrapper``).  This is what we want to re-draw depending on what the user selects.
+
+The selector has specified that wrapper, and the AJAX callback function ``examplemap_organism_featuremap_callback``.  We then define that function to simply return  the piece of the form that should be rebuilt: the ``rendered_maps`` fieldset!
+
+
+
+.. code-block:: php
+
+  /**
+   * AJAX-enabled form for [field formatter name].
+   */
+  function tripal_example_map_organism_featuremap_selector_form($form, &$form_state, $select) {
+
+    $selected = 0;
+
+    // $form_state['values'] will be set if the form has been submitted via AJAX
+    if (isset($form_state['values']['featuremap_select'])) {
+      $selected = isset($form_state['values']['featuremap_select']);
+    }
+
+    // We need to provide a container for Dupal AJAX to replace.
+    // Here we use a fieldset with a set ID which we can refer to below.
+    $form['rendered_maps'] = [
+      '#type' => 'fieldset',
+      '#collapsible' => FALSE,
+      '#prefix' => '<div id="examplemap-featuremap-organism-selector-wrapper">',
+      '#suffix' => '</div>',
+    ];
+
+    // This is the element which will trigger AJAX.
+    $form['rendered_maps']['featuremap_select'] = [
+      '#type' => 'select',
+      '#options' => $select,
+      '#title' => 'Please select a map to view',
+      '#default_value' => $selected,
+      '#ajax' => [
+        // Your Drupal AJAX callback
+        // which simply returns the form element to be re-rendered.
+        'callback' => 'examplemap_organism_featuremap_callback',
+        // This should be the ID you set above on your container to be replaced.
+        'wrapper' => 'examplemap-featuremap-organism-selector-wrapper',
+        'effect' => 'fade',
+      ],
+    ];
+
+    // Check the AJAX submitted values...
+    $chosen = 0;
+    if (isset($form_state['values']['featuremap_select'])) {
+      $chosen = $form_state['input']['featuremap_select'];
+    }
+
+    // If the user chose an option (triggered AJAX).
+    if ($chosen != 0) {
+      // Then change the form accordingly...
+      // Notice that you react to the AJAX change in the form
+      // not in the AJAX callback.
+      $mini_form = tripal_example_map_genetic_map_overview_form([], $form_state, $chosen);
+
+      $form['rendered_maps']['map'] = $mini_form;
+
+      return $form;
+    }
+
+    return $form;
+  }
+
+  /**
+   * The callback will return the part of the form you want to re-draw.
+   */
+  function examplemap_organism_featuremap_callback($form, &$form_state) {
+
+    return $form['rendered_maps'];
+  }
+
+
+
+In the field formatter, we simply add this form and put the markup in the element:
+
+.. code-block:: php
+
+    /**
+     * In our Our__field_formatter.inc
+     */
+    public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
+
+      // Select choices would be loaded in the base field's load method.
+      $select = $items[0]['select_choices'];
+
+      $form = drupal_get_form('tripal_example_map_organism_featuremap_selector_form', $select);
+      $content = drupal_render($form);
+      $element[] = [
+          '#type' => 'markup',
+          '#markup' => $content,
+      ];
+      return $element;
+    }

+ 223 - 0
docs/dev_guide/custom_field/create_instance.rst

@@ -0,0 +1,223 @@
+Attach Fields to Content Types
+==============================
+In summary, creation of a new field requires creation of three classes that inherit from the ``TripalField``, ``TripalFieldWidget`` and ``TripalFieldFormatter`` base classes.  If the fields are created correctly and placed in the ``includes/TripalFields`` directory of your module then Tripal will automatically find them.  However, the field is not yet attached to any content type. They must be attached.  Fields can be attached programmatically or via the online Drupal interface by a site admin. 
+
+The hook_bundle_field_info() function
+-------------------------------------
+ The three TripalField classes simply define how the field will function, but Drupal does not yet know about the field.  The ``hook_bundle_field_info`` function tells Drupal about your field. It must be implemented in a custom Drupal module, and provides an array that tells Drupal about the fields and the classes to use for the field.  Suppose we were creating a field named ``obi__genus`` which displays the Genus for a species and we have a custom module named ``tripal_org2``.  The hook function would be named ``tripal_org2_bundle_field_info()``:
+
+.. code-block:: php
+  :linenos:
+
+  function tripal_org2_bundle_field_info($entity_type, $bundle) {
+    $info = [];
+    
+    // Make sure this bundle is an organism (OBI:0100026) then we'll attach our 
+    // field to display the genus.
+    $term = tripal_load_term_entity(array('term_id' => $bundle->term_id));
+    $term_accession = $term->vocab->vocabulary . '__' . $term->accession;
+    if ($term_accession == 'OBI:0100026') {
+      $field_name = 'obi__genus';
+      $field_type = 'obi__genus';
+      $info[$field_name] = [
+        'field_name' => $field_name,
+        'type' => $field_type,
+        'cardinality' => 1,
+        'locked' => FALSE,
+        'storage' => [
+          'type' => 'field_chado_storage',
+        ],
+        'settings' => [],
+      ];
+   }
+    
+    return $info
+  }
+  
+This function receives as its second argument the ``$bundle`` object. This is the bundle that Drupal is requesting new fields for.  For this example we only want to attach the field if the content type is the organism content type.  The format of the returned ``$info`` array should have the field name as the key and an array that follows the instructions provided by Drupal's `field_create_field() <https://api.drupal.org/api/drupal/modules%21field%21field.crud.inc/function/field_create_field/7.x>`_ function. 
+
+The settings indicate the field name, the field type, the cardinality (how many values are allowed), any default settings and the storage type.  Because we expect our data to come from Chado we set the ``field_chado_storage`` as the type.  The ``locked`` setting is set to FALSE indicating that Drupal will allow the field to be deleted if the site developer desires.
+
+When the site administrator navigates to **Administer > Structure > Tripal Content Types**, clicks on a content type, and then the **manage fields** tab, a link appears at the top titled **Checkfor new fields**.  When that link is clicked, this hook function is called.
+
+Programmatically Attaching Fields
+---------------------------------
+You probably want to programmatically attach fields to content types if your have existing data that you know should be made available. For example, an organism always has a genus and only one genus.  If we have a field that displays the genus for an organism then we will want it automatically attached on installation of our module.  We can do this programmatically using two hook functions: ``hook_bundle_field_info()`` and ``hook_bundle_instance_info()``.  Both functions are required to attach a field to a content type. 
+
+The hook_bundle_instance_info() function.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The previous hook tells Drupal that our field exists and is allowed to be connected to the organism bundle.  Next we need to create an actual instance of this field for the bundle.  We do this with the ``hook_bundle_instance_info()`` function.  The format is the same as the previous hook but the info array is different.  For example:
+
+.. code-block:: php
+  :linenos:
+
+  function tripal_org2_bundle_instances_info($entity_type, $bundle) {
+    $info = []
+    
+    // Make sure this bundle is an organism (OBI:0100026) then we'll attach our 
+    // field to display the genus.
+    $term = tripal_load_term_entity(array('term_id' => $bundle->term_id));
+    $term_accession = $term->vocab->vocabulary . '__' . $term->accession;
+    if ($term_accession == 'OBI:0100026') {
+    
+      $field_name = 'obi__genus';
+      $is_required = FALSE;
+      $info[$field_name] =  [
+        'field_name' => $field_name,
+        'entity_type' => $entity_type,
+        'bundle' => $bundle->name,
+        'label' => 'Genus',
+        'description' => 'The genus for the organism',
+        'required' => TRUE,
+        'settings' => [
+          'auto_attach' => TRUE,
+          'chado_table' => 'organism',
+          'chado_column' => 'genus',
+          'base_table' => 'organism',
+          'term_accession' => '0000005',
+          'term_vocabulary' => 'TAXRANK',
+          'term_name' => 'Genus',
+        ],
+        'widget' => [
+          'type' => 'obi__genus_widget',
+          'settings' => [
+            'display_label' => 1,
+          ),
+        ],
+        'display' => [
+          'default' => [
+            'label' => 'inline',
+            'type' => 'obi__genus_formatter',
+            'settings' => [],
+          ],
+        ],
+      ];
+    }
+    return $info;
+  }
+  
+The format of the returned ``$info`` array should have the field name as the key and an array that follows the instructions provided by Drupal's `field_create_instance() <https://api.drupal.org/api/drupal/modules%21field%21field.crud.inc/function/field_create_instance/7.x>`_ function. 
+
+Unique to this info array are the settings related to Chado.  Because we expect our data to be loaded from Chado we must specify these settings:
+
+ - ``base_table``: the name of the base table to which the record will be associated. In our case the ``organism`` table of Chado is the base table.
+ - ``chado_table``: the name of the actual table form which the value of the field will be loaded or saved to.  In our case the ``organism`` table is also the ``chado_table``.  
+ - ``chado_column``: the name of the column in the ``chado_table`` where the data is loaded from. if the ``base_table`` and ``chado_table`` are the same then this is the name of the column. In our case the ``genus`` columns.  If the base and chado tables are different then it is the name o the primary key column in the ``chado_table``
+ - ``auto_attach``:  set this to TRUE if you want the field to automatically be added to an entity when it is generated for viewing.  Set it to FALSE to allow the field to be added via AJAX. For fields that require time to load setting to FALSE is preferred. 
+ 
+.. note::
+  A base table is one that contains the primary records to which ancilliary data (e.g. properties, cross references, CV terms, publications, contacts, etc) are associated via linker tables. For example some base tables include: ``feature``, ``organism``, ``stock``, ``library``, etc.).  The ``base_table`` and ``chado_table`` will always be the same when you are mapping a field to data in a column in a base table. If your field maps data to a "linker" table where ancilliary data is stored then the ``chado_table`` will be the linker table.
+
+Notice as well that the ``display`` and ``widget`` sections list the name of our TripalEntityWidget and TripalEntityFormatter calsses respectively.  This tells drupal to use our widget and formatter classes by default.
+
+When the site administrator navigates to **Administer > Structure > Tripal Content Types**, clicks on a content type, and then the **manage fields** tab, a link appears at the top titled **Checkfor new fields**.  When that link is clicked, this hook function is called.  
+
+.. note::
+
+  Both hook functions must be properly constructed for the field to be automatically attached to the content type.
+  
+Allowing Manual Attachment of Fields
+------------------------------------
+Not all fields are created equal.  Some field can be added by the site developer to a bundle and some cannot.  When the ``TripalField`` class is implemented for a class the ``$no_ui`` parameter is set to indicate if a field can be added via the web interface or not.  See the :doc:`manual_field_creation` page for more details. But in short the following setting does not allow a field to be added using the web interface
+
+.. code-block::  php
+
+ public static $no_ui = FALSE;
+ 
+The following setting will allow the field to be added:
+
+.. code-block::  php
+
+ public static $no_ui = TRUE;
+
+Next, we must let Drupal know that our field exists.  We do this by adding an entry to the ``$info`` array of in the ``hook_bundle_field_info()`` function described above.  This lets Drupal know about our field. However, because we are not programmatically creating an instance of the field on a content type, but allowing the user to create them we do not need to implement the ``hook_bundle_instance_info()`` function. Instead, we must implement the ``hook_bundle_create_user_field()``.  This function is called when the user attempts to add our new field to a bundle.  One field that comes with Tripal is the ``chado_linker__prop`` field.  Most Chado base tables have an associated property table (e.g. ``organismprop``, ``featureprop``, ``stockprop``, etc). By default, the ``tripal_chado`` module automatically adds this field to all bundles that have existing properties. It adds a new instance for every property type.  However, new properties can be added to bundle, and the site admin may want to add those properties via the user interface rather. Therefore, this field has the ``$no_ui`` set to TRUE and uses the  ``hook_bundle_create_user_field()`` to create the new field instance for the user.
+
+The following code is a snippet from the ``tripal_chado_bundle_create_user_field`` function of the ``tripal_chado`` module. Note that it uses the ``field_create_field`` function and the ``field_create_instance`` functions directly.  The arrays passed to these functions are identical to the ``$info`` arrays of both the ``hook_bundle_field_info`` and ``hook_bundle_instance_info`` functions described above.
+
+.. code-block:: php
+  :linenos:
+  
+  function tripal_chado_bundle_create_user_field($new_field, $bundle) {
+
+    // Get the table this bundle is mapped to.
+    $term = tripal_load_term_entity(array('term_id' => $bundle->term_id));
+    $vocab = $term->vocab;
+    $params = array(
+      'vocabulary' => $vocab->vocabulary,
+      'accession' => $term->accession,
+    );
+    $chado_table = $bundle->data_table;
+    $chado_type_table = $bundle->type_linker_table;
+    $chado_type_column = $bundle->type_column;
+    $chado_type_id = $bundle->type_id;
+    $chado_type_value = $bundle->type_value;
+  
+    // We allow site admins to add new chado_linker__prop fields to an entity.
+    // This function will allow us to properly add them.  But at this point we
+    // don't know the controlled vocabulary term.  We'll have to use the
+    // defaults and let the user set it using the interface.
+    if ($new_field['type'] == 'chado_linker__prop') {
+      $table_name = $chado_table . 'prop';
+  
+      if (chado_table_exists($table_name)) {
+        $schema = chado_get_schema($table_name);
+        $pkey = $schema['primary key'][0];
+        $field_name = $new_field['field_name'];
+        $field_type = 'chado_linker__prop';
+  
+        // First add the field.
+        field_create_field(array(
+          'field_name' => $field_name,
+          'type' => $field_type,
+          'cardinality' => FIELD_CARDINALITY_UNLIMITED,
+          'locked' => FALSE,
+          'storage' => array(
+            'type' => 'field_chado_storage',
+          ),
+        ));
+  
+        // Now add the instance
+        field_create_instance(array(
+          'field_name' => $field_name,
+          'entity_type' => 'TripalEntity',
+          'bundle' => $bundle->name,
+          'label' => $new_field['label'],
+          'description' => '',
+          'required' => FALSE,
+          'settings' => array(
+            'auto_attach' => TRUE,
+            'base_table' => $chado_table,
+            'chado_table' => $table_name,
+            'chado_column' => $pkey,
+            'term_vocabulary' => '',
+            'term_accession' => '',
+            'term_name' => ''
+          ),
+          '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(),
+            ),
+          ),
+        ));
+      }
+      else {
+        drupal_set_message('Cannot add a property field to this entity. Chado does not support properties for this data type.', 'error');
+      }
+    }
+  }
+
+
+
+.. note::
+  
+  It is possible to have a field that is both programmtically attached to some content types but is also allowed to be attached to another content type by the site admin using the web interface. To do this, programmatically add the field to the content types using the ``hook_bundle_instance_info`` function and also implement the ``hook_bundle_create_user_field`` function to support manual adding.
+  
+ 

BIN
docs/dev_guide/custom_field/custom_formatter.pager.1.png


+ 208 - 0
docs/dev_guide/custom_field/custom_formatter.rst

@@ -0,0 +1,208 @@
+Creating a Custom Formatter
+===========================
+The third component of a field is the formatter.  Thus far we have introduced how to create a field class and a widget class for a field.  The field class is responsible for describing the field, loading data into it, and providing search support.  The widget class provided a Drupal form for online editing of the field.  Finally, the formatter is responsible for display of the field on a Tripal site.  
+ 
+.. note::
+  This guide assumes you already have your formatter class file created. For more information, see :doc:`manual_field_creation` or, :doc:`tripal_field_generator`. 
+  
+The formatter class is the simplest of all the Tripal field classes.  Here we will again use the **obi__organism** field that comes with the ``tripal_chado`` module.  
+
+The view() function.
+~~~~~~~~~~~~~~~~~~~~
+In most cases the only function you need to implement is the ``view()`` function. This function is called whenever your field needs to be displayed on a page. The following code is from the ``obi__organism_formatter.inc`` class file.  
+
+.. code-block:: php
+  :linenos:
+
+  public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
+  
+    if ($items[0]['value']) {
+      $content = $items[0]['value']['rdfs: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']['rdfs: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,
+      );
+    }
+  }
+  
+In the code above the input arguments have the following meaning:
+  - ``$element`` is the first argument. It is an array into which you should set the contents to be displayed.  
+  - ``$entity_type`` will always have the value ``Tripal Entity``.
+  - ``$entity`` is the entity object which contains all information about the entity including the loaded data values.
+  -  ``$langcode`` is the language. This is used by Drupal to provide translations of data into other spoken languages. By default, Tripal does not use a language, as biological data is generally language agnostic.  Consider for example a gene sequence or a feature coordinate.
+  - ``$items`` is an array containing all of the loaded data for this field.  
+  - ``$display`` is the name of the display such as full page, a teaser, etc. Currently, Tripal does not distinguish between displays.
+  
+The purpose of the ``view()`` function is to iterate through the values in the ``$items`` array, and format them into an appropriate display for viewing.  Here you must remember the structure of the data in the ``$items`` array.  
+ 
+To demonstrate this function, let's look at what we expect in our ``$items`` array. Using the `Citrus sinesis` organism from the User's Guide. We would expect an items array to look like the following:
+ 
+.. code::
+
+  $items = [
+    0 => [
+      "value" => [
+        "rdfs:label" =>  "Citrus sinensis",
+        "rdfs:type" =>  "Organism",
+        "local:abbreviation" =>  "C. sinensis",
+        "TAXRANK:0000005" => "Citrus",
+        "TAXRANK:0000006" => "sinensis",
+        "entity" => "TripalEntity:3",
+      ],
+      "chado-feature__organism_id" => 12,
+    ],    
+  ];
+  
+You may recall that the ``$items`` array structure is the same as that created by the ``load()`` function described in the :doc:`manual_field_creation` page. Note that each key in the ``value`` array is an accession for a controlled vocabulary term.  These accessions are used to unambiguously describe the value. To display the organism on a page we need the element named ``rdfs:label``.  Thus, we set the ``$content`` variable to contain this value as shown on line 4 of the ``view()`` function above.
+
+Because our organisms are also published entities we want to link to their respective pages each time an organism is displayed.  Because the ``value`` array has an element named ``entity`` we know that this item is published.  Lines 5-6 of the ``view()`` function shown above use this information to create a clickable link to the organism page.   Finally, the ``$element`` argument is set to provide content of type ``markup``.  This ``$element`` array is a `Drupal renderable array <https://www.drupal.org/docs/7/api/render-arrays/render-arrays-overview>`_.
+
+Lastly, notice the element named ``chado-feature__organsim_id``.  This element is at the same level as the ``value`` element.  This data is meant to be used internally by the field. It maps this fields values to the appropriate table in Chado where the data is stored.  
+
+.. warning:: 
+
+  You should never show the user any data that is outside of ``value`` element.  Remember that your field can be shown by other viewers, including web services.  By ensuring that data in the ``value`` element is mean to be displayed we ensure that information on the web page, web services, or any othe future form of display is always consistent.
+
+In summary, the following should be observed when processing the ``$items`` array for viewing:
+
+  - A field with only one value (a cardinality of 1) will always have only one element in the ``$items`` array and can use the index 0. This is what has been done in this example code. 
+  - A field with more than one value can have any number of elements in the ``$items`` array.  You should therefore iterate through all of them.
+  - For every index in ``$item`` you should create a matching index in ``$element`` to display the data found in that ``$item``.
+  - If there are no items, then nothing you return will be displayed.
+  - For each element in the ``$items`` array there is a ``value`` key.  Only the data in the ``value`` key should be shown to the user.
+  - Each element in the ``$items`` array may have more than a ``value`` key.  These values are meant to help manage the data. 
+
+.. warning::
+
+  You should never have SQL statments or any API calls that retreive data in the foramter ``view()`` function. The formatter should strictly format data for viewing.
+  
+Creating Pagers
+~~~~~~~~~~~~~~~
+The example shown in the previous section was for a field that will always only contain a single element.  However some fields may contain a large number of elements.  Consider an mRNA and it's relationships to subfeatures: exons, 5' UTRs, 3'UTRs, CDS, etc.).  A large mRNA can have many relationships.  Alternatively, consider the case where a genentic map content type may have a field that lists all of the markers on the map.  Such a list could become extremely long on the page.  In these cases it may be best to only list a few items at a time and to provide a pager to let the user cycle through the items.  An example of a pager added to the bottom of relationships is shown in the example below.
+
+.. image:: custom_formatter.pager.1.png
+
+To create a pager we first need to calculate the number of items we want to display per page and the total number of pages required to display all of the data.  
+
+.. code-block:: php
+  
+  $items_per_page = 10;
+  $total_records = count($items);
+  $total_pages = (int) ($total_records / $items_per_page) + 1;
+  
+Next, we must initialize the pager by calling the ``pager_default_initialize`` function.  We pass it the total number of records, the number of items per page and the index (i.e. ``$pelement``) for this pager on the page.  
+
+.. code-block:: php
+
+  $pelement = 0; 
+  $current_page = pager_default_initialize($total_records, $items_per_page, $pelement);
+  
+The call to ``pager_default_initialize`` will return the current page.  The current page is a numeric number indicating which page the pager is currently showing. The first time the page is loaded this will always be the first page.  Each time the user navigates to other pages by clicking the "next" link or the numeric links then this ``view()`` function is called and the current page is set to the page being viewed. Next, we must theme the pager so that it follows the look-and-feel prescribed for the site. For this we use the Drupal ``theme()`` function.
+
+.. code-block:: php
+
+  $pager = theme('pager', array(
+    'tags' => array(),
+    'element' => $pelement,
+    'parameters' => array(),
+    'quantity' => $total_pages,
+  ));
+  
+By default, all links in the pager cause the page to reload.  We do not want the page to reload, rather we only want to update the contents of the field.  The TripalFieldFormatter class provides a function named ``ajaxifyPager`` to convert a pager into an AJAX pager:
+
+.. code-block:: php
+
+  $pager = $this->ajaxifyPager($pager, $entity);
+  
+Now that we have a pager, it has been setup for AJAX and we know the current page that the user is viewing we can now display only the items from the ``$items`` array that are appropriate for the page being viewed. A common way to provide multiple items on a page is within a table. When we set the ``$element`` array we need to be sure to provide both the content and the pager:
+
+.. code-block:: php
+
+    $element[0] = array(
+      '#type' => 'markup',
+      '#markup' => $content . $pager,
+    );
+    
+The settingsForm() Funtion.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Sometimes you may want to provide some control to the site developer for the formatter.  For example, the ``sbo__relationship_formater`` allows the site developer to customize the title that appears above the table that houses relationships and the text the appears if there are no relationships.  By default the title is "Relationships" and the empty text indicates there are no relationships. Both are a bit too generic.  The ``settingsForm()`` function allows you to provide a Drupal form for the field that appears on the **Administer > Strucutre > Tripal Content Types** on any content type's **manage display** page:
+
+.. image:: custom_formatter.settings.1.png
+
+The form shown in the screenshot above is provided by the ``settingsForm()`` function.  The following code generates this form:
+
+.. code-block:: php
+  :linenos:
+  
+  public function settingsForm($view_mode, $form, &$form_state) {
+
+    $display = $this->instance['display'][$view_mode];
+    $settings = $display['settings'];
+    $element = array();
+    $element['title'] = array(
+      '#type' => 'textfield',
+      '#title' => 'Table Header',
+      '#default_value' => array_key_exists('title', $settings) ? $settings['title'] : 'Relationship',
+    );
+    $element['empty'] = array(
+      '#type' => 'textfield',
+      '#title' => 'Empty text',
+      '#default_value' => array_key_exists('empty', $settings) ? $settings['empty'] : 'There are no relationships',
+    );
+  
+    return $element;
+  }
+  
+The form is typical of any form.  Note, however that the ``#default_value`` is set using the current settings values.
+
+A settings form is useful but it only works when Drupal knows what settings you want for your field.  You must provide the settings names (e.g. "title" and "empty" in this case) when you  attach your field to a given content type (i.e. bundle).  You tell Drupal to attach this field to a content type using the ``hook_bundle_instance_info`` function.  See 
+the :doc:`create_instance` to learn more about this function.  Briefly, the ``display`` section of the info array for the ``sbo__relationship`` field contains the following settings for the ``display``:
+
+.. code-block:: php
+
+    'display' => array(
+      'default' => array(
+        'label' => 'hidden',
+        'type' => 'sbo__relationship_formatter',
+        'settings' => array(
+          'title' => 'Relationships',
+          'empty' => 'There are no relationships'
+        ),
+      ),
+    ),
+
+.. warning::
+
+    In order for the ``settingsForm()`` implemented to be available on the "Manage Display" page, you must also implement ``settingsSummary()`` as described below.
+The settingsSummary() Function.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The ``settingsSummary()`` function provides a summary of the current settings values for a field on the **manage display** page.  The following shows the same relationship field from the previous section, but with the settings form closed, and a summary of the current values shown:
+
+.. image:: custom_formatter.settings.2.png
+
+An example of the ``settingsSummary()`` function that generates the summary in the image above is as follows:
+
+.. code-block:: php
+  :linenos:
+  
+  public function settingsSummary($view_mode) {
+    $display = $this->instance['display'][$view_mode];
+    $settings = $display['settings'];
+
+    $summary = t('Title: @title<br>Empty: @empty',
+        array(
+          '@title' => $settings['title'],
+          '@empty' => $settings['empty'])
+        );
+
+    return $summary;
+  }
+
+  

BIN
docs/dev_guide/custom_field/custom_formatter.settings.1.png


BIN
docs/dev_guide/custom_field/custom_formatter.settings.2.png


+ 52 - 12
docs/dev_guide/custom_field/custom_widget.rst

@@ -1,14 +1,14 @@
 Creating a Custom Widget
 ========================
 
-In Drupal/Tripal terminology, **widget** refers to the form elements for a specific Tripal Field on the "Edit" form of a piece of Tripal Content. For example, the ``obi__organism`` widget creates the "Organism" drop-down on the edit form of a specific gene. All fields come with a default widget; however, you can create a custom widget if the default one doesn't meet your needs.
+In Drupal/Tripal terminology, **widget** refers to the form elements for a specific Tripal Field on the "Edit" form of a piece of Tripal Content. For example, the ``obi__organism`` field widget creates the "Organism" drop-down on the edit form of a gene. All fields come with a default widget; however, you can create a custom widget if the default one doesn't meet your needs.
 
 .. note::
-  This guide is going to assume you already have your widget file created. For more information, see :doc:`manual_field_creation` or, :doc:`tripal_field_generator`.
+  This guide assumes you already have your widget class file created. For more information, see :doc:`manual_field_creation` or, :doc:`tripal_field_generator`.
 
 .. note::
 	If you are only creating a widget and not the whole field, you still need to follow the expected directory structure. For example, if your widget is going to be named ``obi__organism_fancy`` then your file would be ``[your_module]/includes/TripalField/obi__organism_fancy/obi__organism_fancy_widget.inc``.
-	
+
 The Form
 --------
 
@@ -38,9 +38,9 @@ The form elements of your widget are defined in the ``form()`` method of your wi
     if (count($items) > 0 and array_key_exists($linker_field, $items[0])) {
       $organism_id = $items[0][$linker_field];
     }
-    
+
     // Define a drop-down form element where the options are organisms retrieved using
-    // the Tripal API, the default is what we looked up above, and the title and 
+    // the Tripal API, the default is what we looked up above, and the title and
     // description are those set when defining the field.
     $widget[$linker_field] = array(
       '#type' => 'select',
@@ -54,7 +54,7 @@ The form elements of your widget are defined in the ``form()`` method of your wi
 
   }
 
-At a minimum, the form must have a ``value`` element.  For Tripal, the ``value`` element of a field always corresponds to the value that is presented to the end-user either directly on the page (with formatting) or via web services, or some other mechanism. Convention is to store the value of the field as a hidden ``value`` form element as is shown in the above example. 
+At a minimum, the form must have a ``value`` element.  For Tripal, the ``value`` element of a field always corresponds to the value that is presented to the end-user either directly on the page (with formatting) or via web services, or some other mechanism. Convention is to store the value of the field as a hidden ``value`` form element as is shown in the above example.
 
 .. note::
 	For more information on how to use the Drupal Form API, check out the `official Drupal Documentation <https://www.drupal.org/docs/7/api/form-api>`_.
@@ -69,17 +69,17 @@ Validation
 The ``validate()`` function of your widget allows you to confirm that the values entered by the user are valid. It is recommended to consider each form element you created above and consider what is required for that element to be entered "correctly". For example, for an organism drop-down, the organism chosen must exist in our chado database (since this is a ``ChadoFieldWidget``). Luckily this doesn't need to be validated since Drupal ensures only elements in our select list are chosen.
 
 .. warning::
-	The ``value`` key of this field must be set in the ``$form_state['values']`` array to a **TRUE** value (e.g. a string or non-zero integer) anytime data is entered by the user. 
-	
+	The ``value`` key of this field must be set in the ``$form_state['values']`` array to a **TRUE** value (e.g. a string or non-zero integer) anytime data is entered by the user.
+
 .. note::
 	For more information on how to validate your data, see the official `Drupal Form Validation Documentation <https://www.drupal.org/docs/7/creating-custom-modules/validating-the-data>`_
-   
+
 Saving the Data
 ---------------
 
-The Drupal Storage Backend handles saving of your widget data. As such, **you do not and should not insert, update or delete the data yourself**. It should happen automatically, assuming you've followed the conventions of the specific storage backend. 
+The Drupal Storage Backend handles saving of your widget data. As such, **you do not and should not insert, update or delete the data yourself**. It should happen automatically, assuming you've followed the conventions of the specific storage backend.
 
-Chado Fields utilize the chado storage backend to save your data. Thus to ensure your data is saved, you set the columns of your chado table to the values you want them set via the ``$form_state['values']`` array using the ``chado-[table]__[column]`` convention. This should be done at the end of the validation function above, if the data submitted is valid. 
+Chado Fields utilize the chado storage backend to save your data. Thus to ensure your data is saved, you set the columns of your chado table to the values you want them set via the ``$form_state['values']`` array using the ``chado-[table]__[column]`` convention. This should be done at the end of the validation function above, if the data submitted is valid.
 
 For our ``obi__organism`` example, the drop-down returns the chado organism_id of the record chosen by the user. We would like to save that as the organism_id of the chado table the field references, which the following code specifies.
 
@@ -108,6 +108,46 @@ For our ``obi__organism`` example, the drop-down returns the chado organism_id o
     }
   }
 
-Drupal typically does not provide a submit hook for fields because, as mentioned above, saving should be done by the storage backend. However, the TripalField provides a ``TripalFieldWidget::submit()`` to allow for behind-the-scenes actions to occur. This function should never be used for updates, deletes or inserts for the Chado table associated with the field as these actions should be handled by the storage backend. 
+But what do you do if the record you want to link to via foreign key constraint doesn't yet exist? Luckily the Chado Storage API has a solution for this as well. Consider the example of the ``sbo__relationship_widget``. When this widget is on the create form for a given content type, we will first need to create the base record before we can create a relationship to it. This is done by setting the values you do know (e.g. ``chado-feature__type_id`` and ``chado-feature__object_id``) but nnot setting the column mapping to the base record. The Chado Storage API will then fill it in automatically once the base record is created.
+
+.. code-block:: php
+
+  /**
+   * @see TripalFieldWidget::validate()
+   */
+  public function validate($element, $form, &$form_state, $langcode, $delta) {
+
+    $field_name = $this->field['field_name'];
+    $field_table = $this->instance['settings']['chado_table'];
+    $linker_field = 'chado-' . $field_table . '__organism_id';
+
+    //...
+    // Validate your data here
+    //...
+
+    //...
+    // Determine the subject_id, object_id and type_id based on user input.
+    // User input is found in $form_state['values'].
+    //...
+
+    // If we have all the keys then set the columns as in the obi__organism ex.
+    if ($subject_id && $object_id && $type_id) {
+      // Set all chado fields to their values.
+    }
+    // Otherwise, maybe we are creating the entity...
+    // The storage API should handle this case and automagically add the key in // once the chado record is created... so all we need to do is set the
+    // other columns.
+    elseif ($subject_name && $object_id && $type_id) {
+      $form_state['values'][$field_name][$langcode][$delta]['value'] = 'value must be set but is not used';
+      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__' . $object_id_key] = $object_id;
+      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__type_id'] = $type_id;
+      // Notice that the subject_id is not set here.
+    }
+    // Otherwise, we don't have a value to insert so leave them blank.
+    else {
+      // Set all chado fields to empty string.
+    }
+
+Drupal typically does not provide a submit hook for fields because, as mentioned above, saving should be done by the storage backend. However, the TripalField provides a ``TripalFieldWidget::submit()`` to allow for behind-the-scenes actions to occur. This function should never be used for updates, deletes or inserts for the Chado table associated with the field as these actions should be handled by the storage backend.
 
 However, it is permissible to perform inserts, updates or deletions within Chado using this function.  Those operations can be performed if needed but on other tables not directly associated with the field. An example is the ``chado.feature_synonym`` table.  The ``chado_linker__synonym`` field allows the user to provide a brand new synonynm and it must add it to the chado.synonym table prior to the record in the chado.feature_synonym table.

+ 1 - 19
docs/dev_guide/custom_field/manual_field_creation.rst

@@ -1,17 +1,13 @@
 Manual Field Creation
 ======================
-
 To show how a TripalField works we will break down a class implementation section by section.  Here we will use the **obi__organism** field that comes with Tripal and which extends the ChadoField class.  The ChadoField class is almost identical to the TripalField class except that it provides a few extra settings for working with Chado tables.   To create your own class you need to create a new class that implements the necessary functions.
 
 .. note::
   Creation of your first field may not seem easy!  The following document is a lot to think about and consider. Therefore, when you write your first field, don't try to do everything at once. Take it one piece at a time.  The variables and functions described here are in order with the most critical components described first.  Take it at an even pace.
 
 
-
 Directory Structure for Fields
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
 Before we create our class we must first create a proper directory structure.  Tripal expects that all new Tripal field classes are located inside of a custom module in the following directory structure:
 
 .. code-block:: bash
@@ -31,7 +27,6 @@ In the directories above the token [your_module] can be substituted with the nam
 
 Anatomy of the ChadoField Class
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
 The following describes a ChadoField class from top to bottom. The code for the obi__organism field is shown in order that it appears in the class with descriptions provided for the meaning of each piece of code.  To write your own class, duplicate the variables and function and customize accordingly.  First, let's look at the definition of the class.  The following line defines the class and indicates that it extends the ChadoField class:
 
 .. code-block:: php
@@ -133,8 +128,6 @@ Finally, the last item in our Class variables is the **download_formatters**.  T
 
 .. .. code-block::
 
-  
-
   // Indicates the download formats for this field.  The list must be the
   // name of a child class of the TripalFieldDownloader.
   public static $download_formatters = array(
@@ -154,7 +147,6 @@ To get started, the load() function receives a single argument. The entity objec
 
 .. code-block:: php
 
-
   public function load($entity) {
 
 
@@ -162,7 +154,6 @@ Because this is a ChadoField and the TripalChado module supports this field and
 
 .. code-block:: php
 
-
     $record = $entity->chado_record;
 
 Having the record helps tremendously.  Our **obi__organism** field is meant to be attached to genomic feature content types (e.g. genes, mRNA, etc.), germplasm, etc.  Therefore, the entity will be a record of one of those types. In the case of a genomic feature, these come from the **feature** table of Chado.  In the case of a germplam, these records come from the **stock** table of Chado.  Both of these records have an **organism_id** field which is a foreign key to the organism table where we find out details about the organism.
@@ -171,7 +162,6 @@ Before we set the values for our field, we need a little bit more information.
 
 .. code-block:: php
 
-
     $settings = $this->instance['settings'];
     $field_table = $this->instance['settings']['chado_table'];
     $field_column = $this->instance['settings']['chado_column'];
@@ -180,7 +170,6 @@ Next, we want to get this field name and its type.  We obviously know our field
 
 .. code-block:: php
 
-
     $field_name = $this->field['field_name'];
     $field_type = $this->field['type'];
 
@@ -189,7 +178,6 @@ Now, let's plan how we want our values to appear in our field.  The organism rec
 
 .. code-block:: php
 
-
     // Get the terms for each of the keys for the 'values' property.
     $label_term = 'rdfs:label';
     $genus_term = tripal_get_chado_semweb_term('organism', 'genus');
@@ -204,7 +192,6 @@ Next, let's initialize our field's value to be empty.  When setting a field valu
 
 .. code-block:: php
 
-
     // Set some defaults for the empty record.
     $entity->{$field_name}['und'][0] = array(
       'value' => array(),
@@ -217,7 +204,6 @@ Now that we've got some preliminary values and we've initialized our value array
 
 .. code-block:: php
 
-
     if ($record) {
 
 
@@ -225,7 +211,6 @@ Now if we do have a record we need to get the value  The first step is to actual
 
 .. code-block:: php
 
-
       if ($field_table == 'biomaterial') {
         $organism = $record->taxon_id;
       }
@@ -235,9 +220,7 @@ Now if we do have a record we need to get the value  The first step is to actual
 
 We can easily get all of the values we need from this organism object.   We can now access the values for this organism using the Chado organism table column names (e.g. $organism->genus, $organism->species).
 
-.. code-block:: php
-
-  
+.. code-block:: php 
 
       $label = tripal_replace_chado_tokens($string, $organism);
       $entity->{$field_name}['und'][0]['value'] = array(
@@ -260,7 +243,6 @@ Okay, so, we have our values set. However, remember,  our fields must support tw
 
 .. code-block:: php
 
-
     // Set the linker field appropriately.
     if ($field_table == 'biomaterial') {
       $linker_field = 'chado-biomaterial__taxon_id';

+ 55 - 0
docs/dev_guide/rtd.rst

@@ -0,0 +1,55 @@
+Using ReadTheDocs
+=================
+
+.. note::
+
+  For Tripal's own ReadTheDocs guidelines: :ref:`tripal_rtd`.
+
+
+What is ReadTheDocs?
+--------------------
+
+Documentation is important. It tells users how to use our product, and developers how to read our code.  We recommend hosting documentation for your custom module somewhere easily accessible, like ReadTheDocs.
+
+`ReadTheDocs <https://readthedocs.org/>`_ (RTD) uses the `Sphinx <http://www.sphinx-doc.org/en/master/>`_ framework to build a website in a Continuous Integration setup. Your RTD-compatible documentation is added directly to your module and when code changes are pushed to GitHub, the documentation website as defined by sphinx is built, and the "live" documentation website is updated.
+
+Benefits to housing documentation inside of your module code are:
+
+- Code changes can include documentation updates **in the same pull request**.
+- Changes to the documentation is **subject to review, just like code changes**.
+- Documentation changes are under **version control**.
+
+How do I add ReadTheDocs to my project?
+---------------------------------------
+Below is a quick overview of steps for integrating your module's documentation with RTD:
+
+- Set up your ReadTheDocs account and import your project.
+- Install Sphinx.
+- Create a ``docs`` folder at the root of your project and navigate into it.
+- Run the quickstart command: ``sphinx-quickstart``.
+  - This creates necessary site configuration files (``conf.py``) as well as the make script to build your site.
+- Write your documentation (we're using reStructuredText (RST) format):
+  - Create an ``index.rst`` as the home page.
+  - Link other RST documents in your ``index.rst``.
+- Once the guide is on your master branch on GitHub, ReadTheDocs will handle the rest!
+
+For a detailed walkthrough, please see the `official ReadTheDocs getting started guide <https://docs.readthedocs.io/en/latest/getting_started.html>`_.
+
+For RTD integration we recommend using reStructuredText (RST) to write your documentation. It might seem a little more complicated than markdown (and it is), but it's also more powerful.  The choice is yours for which format to use.
+
+ReadTheDocs also provides **versioning** tools, allowing you to post releases of the documentation so users can go back and find older documentation with almost no effort on your part.
+
+What should my documentation include?
+-------------------------------------
+
+We suggest that your module include the following sections:
+
+- Overview
+- Installation and Setup Guide
+- User's Manual
+
+The Overview section should describe what features your module offers.
+
+The Installation and setup section should guide a site administrator through installing and setting up your module.  Any site-wide settings that need to be configured, environmental variables set, or anything else not handled by the automated Drupal install should be covered.
+
+The User's guide should walk through the day-to-day usage of your module.  This may include using custom importers, dashboards, or simply summaries of the new content this module provides.

+ 5 - 28
docs/extensions.rst

@@ -17,33 +17,10 @@ The below modules are Tripal 3 compatible and grouped roughly by category:
 
 If you don't see the module you are looking for here, try a `Tripal-specific search on GitHub <https://github.com/search?q=topic%3Atripal>`__.
 
-Add your Module to this list!
------------------------------
+Informational links for this extension module list:
 
-**We would love for you to contribute your own module to this list!** This is done by creating a Pull Request (PR) to `Tripal <https://github.com/tripal/tripal>`__ modify our documentation.
-
-Instructions
-^^^^^^^^^^^^^
-
-1. From the current page, click the category in the list above that best fits your module.
-2. Click the "Edit on Github" link at the top of the page.
-3. Add your module using the following template.
-
-.. code:: RST
-
-  Module Name
-  ------------
-
-  This module loads in X, Y, and Z.  It provides admin for A and B, and user area C.
-
-  `Documentation <https://yourmodule.readthedocs.io/en/latest/index.html>`__
-  `Repository <https://github.com/you/yourmodule>`__
-
-Guidelines
-^^^^^^^^^^^
+.. toctree::
+   :maxdepth: 1
 
-- Make sure to follow alphabetical order when choosing where on the category page to add your module.
-- Please write two sentences MAXIMUM about the function of the module.
-- Include links to both the documentation (even if it's your README) and the repository (e.g. Github, Gitlab)
-- If your module doesn't fit well in any of the existing categories, still pick the best one but then feel free to suggest a new category in the PR description.
-- Extension Modules must be publicly available for download
+   extensions/module_rating
+   extensions/instructions

+ 12 - 0
docs/extensions/3rd_party.rst

@@ -3,6 +3,14 @@ Third-party Integration
 
 The following modules provide integration with external third-party tools. For example, they may allow you to easily embed the tool in Drupal/Tripal pages and/or expose data from the tool on your Tripal site.
 
+BrAPI
+-----
+
+This module provides a Breeding API end point on your Tripal site as well as a user query interface and an auto-query system to integrate external BrAPI end point data into your site dynamically. An administrative interface allows you to adjust the module settings according to the way you use Chado. A couple of hooks are also provided for module developers in order to allow customization/extension of calls.
+
+`Documentation <https://brapi.readthedocs.io/en/latest/>`__
+`Repository <https://github.com/tripal/brapi>`__
+
 Tripal Blast
 ------------
 
@@ -14,6 +22,10 @@ This module provides a basic interface to allow your users to utilize your serve
 Tripal Galaxy
 -------------
 
+.. image:: https://tripal.readthedocs.io/en/7.x-3.x/_images/Tripal-Gold.png
+  :target: https://tripal.readthedocs.io/en/7.x-3.x/extensions/module_rating.html#Gold
+  :alt: Tripal Rating: Gold
+
 This module is for integration of Tripal and the Galaxy Project. It facilitates the creation of forms on your Tripal site that submit jobs to a galaxy instance.
 
 `Documentation <https://tripal-galaxy.readthedocs.io/en/latest/?badge=latest>`__

BIN
docs/extensions/Tripal-Bronze.png


File diff suppressed because it is too large
+ 0 - 0
docs/extensions/Tripal-Bronze.svg


BIN
docs/extensions/Tripal-Gold.png


File diff suppressed because it is too large
+ 0 - 0
docs/extensions/Tripal-Gold.svg


BIN
docs/extensions/Tripal-Silver.png


File diff suppressed because it is too large
+ 0 - 0
docs/extensions/Tripal-Silver.svg


+ 4 - 0
docs/extensions/administrative.rst

@@ -23,6 +23,10 @@ Tripal Curator is a Toolbox for curating Chado Properties.  Split properties int
 Tripal HeadQuarters
 -------------------
 
+.. image:: https://tripal.readthedocs.io/en/7.x-3.x/_images/Tripal-Gold.png
+  :target: https://tripal.readthedocs.io/en/7.x-3.x/extensions/module_rating.html#Gold
+  :alt: Tripal Rating: Gold
+
 Tripal HeadQuarters (HQ) provides an administrative layer for Tripal, giving users limited access to content creation forms which must be approved by an admin before they are inserted into the database. Admins can use Chado-specific permissions to define organism or project-specific administrative rights.
 
 `Documentation <https://tripal-hq.readthedocs.io/en/latest/index.html>`__

+ 8 - 0
docs/extensions/data_input.rst

@@ -42,3 +42,11 @@ The Tripal Plant PopGen Submit (TPPS) Module supports a flexible submission inte
 
 `Documentation <https://tpps.readthedocs.io/en/latest/>`__
 `Repository <https://gitlab.com/TreeGenes/TGDR>`__
+
+Migrate Chado
+-------------
+
+This module is a collection of destination plugins to import biological data to a Chado database using `Drupal Migrate <https://www.drupal.org/project/migrate>`_. The Migrate module provides a flexible framework for migrating content into Drupal from other sources (e.g., when converting a web site to Drupal). Content is imported and rolled back using a bundled web interface (Migrate UI module) or included Drush commands (strongly recommended).
+
+`Documentation <https://www.drupal.org/docs/7/modules/migrate-chado>`__
+`Repository <https://www.drupal.org/project/migrate_chado>`__

+ 8 - 0
docs/extensions/in_development.rst

@@ -20,3 +20,11 @@ Tripal Apollo lets you manage user accounts for your JBrowse Apollo instances on
 
 `Documentation <https://tripal-apollo.readthedocs.io/en/latest/>`__
 `Repository <https://github.com/NAL-i5K/tripal_apollo>`__
+
+Tripal Multi-Chado
+------------------
+
+The Multi-Chado module is an extension for Tripal 2.x and 3.x (dev branch under testing) that can be used to install more than one Chado instance across different schemata of your choice and it also enables the use of different PostgreSQL database credentials allowing the administrator to do fine tuning of database accesses. With it you can use a *same Drupal instance* for both a *public* and a *private* Chado instance, have *different releases* or *separated species*, provide a *sandbox*, run *tests* on a blank instance and more (dev-staging-prod, etc.).
+
+`Documentation <http://cgit.drupalcode.org/tripal_mc/plain/README.md?h=7.x-1.x>`__
+`Repository <https://www.drupal.org/project/tripal_mc>`__

+ 33 - 0
docs/extensions/instructions.rst

@@ -0,0 +1,33 @@
+
+Adding your Module to this list!
+==================================
+
+**We would love for you to contribute your own module to this list!** This is done by creating a Pull Request (PR) to `Tripal <https://github.com/tripal/tripal>`__ modify our documentation.
+
+Instructions
+-------------
+
+1. From the current page, click the category in the list above that best fits your module.
+2. Click the "Edit on Github" link at the top of the page.
+3. Add your module using the following template.
+
+.. code:: RST
+
+  Module Name
+  ------------
+
+  This module loads in X, Y, and Z.  It provides admin for A and B, and user area C.
+
+  `Documentation <https://yourmodule.readthedocs.io/en/latest/index.html>`__
+  `Repository <https://github.com/you/yourmodule>`__
+
+4. Rate your module using the :doc:`./module_rating` and mention in your PR description which requirements your module meets.
+
+Guidelines
+------------
+
+- Make sure to follow alphabetical order when choosing where on the category page to add your module.
+- Please write two sentences MAXIMUM about the function of the module.
+- Include links to both the documentation (even if it's your README) and the repository (e.g. Github, Gitlab)
+- If your module doesn't fit well in any of the existing categories, still pick the best one but then feel free to suggest a new category in the PR description.
+- Extension Modules must be publicly available for download

+ 83 - 0
docs/extensions/module_rating.rst

@@ -0,0 +1,83 @@
+
+Tripal Module Rating System
+=============================
+
+This module rating system is meant to aid Tripal Site Administrators in choosing extension modules for their site. It is also meant to guide developers in module best practices and celebrate modules which achieve these goals.
+
+Bronze
+-------
+
+.. image:: Tripal-Bronze.png
+
+- Has a public release.
+- Should install on a Tripal site appropriate for the versions it supports.
+- Defines any custom tables or materialized views in the install file (if applicable).
+- Adds any needed controlled vocabulary terms in the install file (Tripal3).
+- Provides Installation and admin instructions README.md (or `RTD <https://tripal.readthedocs.io/en/latest/dev_guide/rtd.html>`_).
+- Has a license (distributed with module).
+
+Silver
+-------
+
+.. image:: Tripal-Silver.png
+
+- Follows basic Drupal Coding standards; specifically, `code format <https://www.drupal.org/docs/develop/standards/coding-standards>`_ and `API documentation <https://www.drupal.org/docs/develop/standards/api-documentation-and-comment-standards#drupal>`_.
+- Uses Tripal API functions. Specifically, it should use the
+    - Chado Query API for querying chado (if using chado as the storage system). (`API <http://api.tripal.info/api/tripal/tripal_chado%21api%21tripal_chado.query.api.inc/group/tripal_chado_query_api/3.x>`_, :doc:`Tutorial <../dev_guide/chado>`)
+    - Tripal Jobs API for long running processes. (`API  <http://api.tripal.info/api/tripal/tripal%21api%21tripal.jobs.api.inc/group/tripal_jobs_api/3.x>`_)
+    - TripalField class to add data to pages (Tripal3). (:doc:`Tutorial <../dev_guide/custom_field>`)
+- Provides ways to customize the module (e.g. drush options, field/formatter settings, admin UI).
+- Latest releases should follow Drupal naming best practices.
+    - e.g. first release for Drupal 7 should be: ``7.x-1.0``.
+
+Gold
+-----
+
+.. image:: Tripal-Gold.png
+
+- Extensive documentation for the module (similar to Tripal User's Guide). ( `Tutorial <https://tripal.readthedocs.io/en/latest/dev_guide/rtd.html>`_)
+- Unit testing is implemented using PHPUnit with the TripalTestSuite or something similar.
+- Continuous integration is setup (e.g. such as with TravisCI).
+- Imports data via Tripal's importer class (Tripal3) (:doc:`Tutorial <../dev_guide/custom_data_loader>`).
+- Tripal 3 fields are (:doc:`Tutorial <../dev_guide/custom_field/manual_field_creation>`)
+    - Fully compatible with web services.
+    - The elementInfo function is fully implemented.
+    - The query and queryOrder functions fully implemented.
+- Web Services uses Tripal's Web Service Classes (Tripal3). (:doc:`Tutorial <../dev_guide/custom_web_services>`)
+- Code sniffing and testing coverage reports (optional but encouraged).
+- Drupal.org vetted release (optional but encouraged).
+
+Rate your Extension Module!
+-----------------------------
+
+We encourage Tripal module developers to rate their modules. This can be done by :doc:`./instructions`
+
+The following badges are for inclusion on your module README and documentation; however, they are only valid if your module has been included in :doc:`../extensions` with the given rating.
+
+reStructuredText
+
+.. code-block:: RST
+
+    .. image:: https://tripal.readthedocs.io/en/7.x-3.x/_images/Tripal-Bronze.png
+      :target: https://tripal.readthedocs.io/en/7.x-3.x/extensions/module_rating.html#Bronze
+      :alt: Tripal Rating: Bronze
+
+
+Markdown
+
+.. code-block:: MD
+
+    [![Tripal Rating Bronze Status](https://tripal.readthedocs.io/en/7.x-3.x/_images/Tripal-Bronze.png)](https://tripal.readthedocs.io/en/7.x-3.x/extensions/module_rating.html#Bronze)
+
+
+HTML
+
+.. code-block:: html
+
+    <a href='https://tripal.readthedocs.io/en/7.x-3.x/extensions/module_rating.html#Bronze'>
+        <img src='https://tripal.readthedocs.io/en/7.x-3.x/_images/Tripal-Bronze.png' alt='Tripal Rating: Bronze' />
+    </a>
+
+.. note::
+
+   Replace all instances of ``Bronze`` with either ``Silver`` or ``Gold`` for those badges.

+ 9 - 0
docs/extensions/visualization.rst

@@ -35,6 +35,15 @@ This module provides support and visualization of genotypic data stored in a mod
 `Documentation <https://nd-genotypes.readthedocs.io/en/latest/>`__
 `Repository <https://github.com/UofS-Pulse-Binfo/nd_genotypes>`__
 
+Phylotree
+-------------------
+
+This extension provides a simple file formatter for `Newick <http://evolution.genetics.washington.edu/phylip/newicktree.html>`__ tree files using
+the Javascript library `Phylotree <https://github.com/veg/phylotree.js/tree/master>`__ for display.
+
+`Documentation <https://cgit.drupalcode.org/phylotree/tree/README.md>`__
+`Repository <https://www.drupal.org/project/phylotree>`__
+
 Tripal Fancy Fields
 -------------------
 

+ 1 - 0
docs/index.rst

@@ -13,3 +13,4 @@ Welcome to Tripal's documentation!
    user_guide
    dev_guide
    extensions
+   contributing

+ 1 - 1
docs/tripal_doxygen.config

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

+ 5 - 1
docs/user_guide/example_genomics.rst

@@ -1,7 +1,11 @@
 Setup of an Example Site
 =================================
 
-The following tutorial will walk you through creating content and loading genomic data. This is a good introduction to Tripal v3.x Content Types and the new Administrative User Interface regardless of whether you intend to store genomic data in your particular Tripal v3 site.
+The following tutorial will walk you through creating content and loading genomic data. This is a good introduction to Tripal v3.x Content Types and the new Administrative User Interface regardless of whether you intend to store genomic data in your particular Tripal v3 site.  This demonstration uses three extension modules:  `Tripal Analysis Blast <https://github.com/tripal/tripal_analysis_blast>`_, `Tripal Analysis KEGG <https://github.com/tripal/tripal_analysis_kegg>`_, and `Tripal Analysis InterPro <https://github.com/tripal/tripal_analysis_interpro>`_.  
+
+.. note:: 
+
+  As a rule, extension modules are not documented in the Tripal User's Guide.  You can find documentation for extension modules that enhance Tripal functionality on the :doc:`../extensions` page.  However, to provide a functioning demonstration the three analysis extension modules are described here. 
 
 .. toctree::
    :maxdepth: 1

+ 18 - 4
docs/user_guide/install_tripal/drush_installation.rst

@@ -1,12 +1,26 @@
 Drush Installation
 ==================
 
-Drush is a command-line utility that allows for non-graphical access to the Drupal website. You can use it to automatically download and install themes and modules, clear the Drupal cache, upgrade the site and more. Tripal v3 supports Drush. For this tutorial we will use Drush and therefore we want the most recent version installed. Drush can be found on a GitHub page at https://github.com/drush-ops/drush.
+Drush is a command-line utility that allows for non-graphical access to the Drupal website. You can use it to automatically download and install themes and modules, clear the Drupal cache, upgrade the site and more. Tripal v3 supports Drush. For this tutorial we will use Drush and therefore we want the most recent, Drupal7-compatible version installed: we recommend Drush 8.x (see compatibility chart below.)
+
+==============  =============  ==========  ===========================
+Drush Version   Drush Branch   PHP         Compatible Drupal versions
+==============  =============  ==========  ===========================
+Drush 9         master 	       5.6+ 	     D8.4+
+Drush 8         8.x 	         5.4.5+      D6, D7, D8.3
+Drush 7         7.x 	         5.3.0+      D6, D7
+Drush 6         6.x 	         5.3.0+      D6, D7
+Drush 5         5.x 	         5.2.0+      D6, D7
+==============  =============  ==========  ===========================
+
+*As you can see from the above table, the newest version of Drupal which supports Drupal 7 is Drush 8.*
 
 Install Drush
 -------------
 
-An extensive list of platforms and their corresponding install instructions can be found here: https://www.drupal.org/node/1791676.  Below are quick links for installation of Drush on Ubuntu and CentOS
+The official documentation for installing Drush 8 can be found here: https://docs.drush.org/en/8.x/install/.
+
+.. warning::
+
+  Don't accidentally follow the Drupal 8 installation method for your Drupal 7 site!  The "site-local" Drush installation won't work for Drupal 7.
 
-- `Installing Drush on Ubuntu <https://www.drupal.org/node/1248790>`_
-- `Installing Drush on CentOS (with H-Sphere) <https://www.drupal.org/node/2009426>`_

+ 6 - 6
docs/user_guide/install_tripal/manual_install/install_drupal.rst

@@ -52,26 +52,26 @@ Substitute [user] for the name of the user that will own the web files.
 
   The apache web server runs as the user 'www-data'.  For security reasons you should chose a user other than 'www-data' to be the owner of the Drupal root directory.
 
-Tripal 3.x requires version 7.x of Drupal. Drupal can be freely downloaded from the http://www.drupal.org website. At the writing of this Tutorial the most recent version of Drupal 7 is version 7.59. The software can be downloaded manually from the Drupal website through a web browser or we can use the ``wget`` command to retrieve it:
+Tripal 3.x requires version 7.x of Drupal. Drupal can be freely downloaded from the http://www.drupal.org website. At the writing of this Tutorial the most recent version of Drupal 7 is version 7.64. The software can be downloaded manually from the Drupal website through a web browser or we can use the ``wget`` command to retrieve it:
 
 .. code-block:: bash
 
   cd $DRUPAL_HOME
-  wget http://ftp.drupal.org/files/projects/drupal-7.59.tar.gz
+  wget http://ftp.drupal.org/files/projects/drupal-7.64.tar.gz
 
 
 Next, we want to install Drupal. We will use the tar command to uncompress the software:
 
 .. code-block:: bash
 
-  tar -zxvf drupal-7.59.tar.gz
+  tar -zxvf drupal-7.64.tar.gz
 
-Notice that we now have a drupal-7.59 directory with all of the Drupal files. We want the Drupal files to be in our document root, not in a 'drupal-7.59' subdirectory. So, we'll move the contents of the directory up one level:
+Notice that we now have a drupal-7.64 directory with all of the Drupal files. We want the Drupal files to be in our document root, not in a 'drupal-7.64' subdirectory. So, we'll move the contents of the directory up one level:
 
 .. code-block:: bash
 
-  mv drupal-7.59/* ./
-  mv drupal-7.59/.htaccess ./
+  mv drupal-7.64/* ./
+  mv drupal-7.64/.htaccess ./
 
 If an index.html file is present (as is the case with Ubuntu installations) you can move it out of the way so that it does not interfere with Drupal by executing the following:
 

+ 1 - 1
docs/user_guide/install_tripal/rapid_install.rst

@@ -163,7 +163,7 @@ Next, the required modules will be downloaded:
   Project libraries (7.x-2.3) downloaded to /var/www/html/sites/all/modules/libraries.
   redirect (7.x-1.0-rc3) downloaded to /var/www/html/sites/all/modules/redirect.
   Project token (7.x-1.7) downloaded to /var/www/html/sites/all/modules/token.
-  Project tripal (7.x-3.0-rc1) downloaded to /var/www/html/sites/all/modules/tripal.
+  Project tripal (7.x-3.1) downloaded to /var/www/html/sites/all/modules/tripal.
   Project tripal contains 24 modules: tripal_daemon, tripal, tripal_chado, tripal_ws, tripal_bulk_loader, tripal_chado_views, tripal_ds, tripal_contact, tripal_natural_diversity, tripal_views, tripal_core, tripal_library, tripal_organism, tripal_featuremap, tripal_genetic, tripal_db, tripal_analysis, tripal_phenotype, tripal_pub, tripal_stock, tripal_project, tripal_cv, tripal_phylogeny, tripal_feature.
   Project uuid (7.x-1.0) downloaded to /var/www/html/sites/all/modules/uuid.
   Project uuid contains 4 modules: uuid_services, uuid_path, uuid_services_example, uuid_path

+ 1 - 1
docs/user_guide/install_tripal/server_setup/ubuntu_18.04.rst

@@ -63,7 +63,7 @@ Drupal uses PHP.   In Ubuntu 18.04 there are two different instances of PHP that
 
 .. code-block:: bash
 
-  sudo apt-get install php php-dev php-cli libapache2-mod-php
+  sudo apt-get install php php-dev php-cli libapache2-mod-php php7.2-mbstring
 
 You may notice that installing the libapach2-mod-php module will automatically restart the Apache web server which will allow it to parse PHP files.  Next, we need a few additional extension modules for PHP that support connection to a PostgreSQL database server, JSON and the GD graphics library:
 

+ 1 - 1
docs/user_guide/install_tripal/upgrade_from_tripal2.rst

@@ -48,7 +48,7 @@ Step 1: Upgrade Tripal
 
   .. code-block:: bash
 
-    drush pm-download tripal-7.x-3.0-rc3
+    drush pm-download tripal-7.x-3.1
 
 5. Enable the tripal module
 

+ 2 - 2
docs/user_guide/job_management.rst

@@ -25,8 +25,8 @@ The Tripal Daemon requires the `Libraries API <https://www.drupal.org/project/li
 
 .. code-block:: shell
 
-  drush pm-download Libraries
-  drush pm-enable Libraries
+  drush pm-download libraries
+  drush pm-enable libraries
 
 Next, we need the `PHP-Daemon Library version 2.0 <https://github.com/shaneharter/PHP-Daemon>`_. You must download the PHP-Daemon Library and extract it in your ``sites/all/libraries`` directory. The folder must be named "PHP-Daemon".  The following commands can be used to do this:
 

+ 68 - 65
legacy/tripal_analysis/api/tripal_analysis.DEPRECATED.inc

@@ -1,13 +1,14 @@
 <?php
 /**
  * @file
- * Wrapper functions to provide backwards compatibility for the tripal analysis api
+ * Wrapper functions to provide backwards compatibility for the tripal analysis
+ *   api
  */
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_register_analysis_child().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_register_analysis_child().
  *
  * @see tripal_register_analysis_child().
  */
@@ -17,10 +18,10 @@ function tripal_analysis_register_child($modulename) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_analysis_register_child',
-      '%new_function' => 'tripal_register_analysis_child'
-    )
+    [
+      '%old_function' => 'tripal_analysis_register_child',
+      '%new_function' => 'tripal_register_analysis_child',
+    ]
   );
 
   return tripal_register_analysis_child($modulename);
@@ -28,8 +29,9 @@ function tripal_analysis_register_child($modulename) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_unregister_analysis_child().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by
+ *   tripal_unregister_analysis_child().
  *
  * @see tripal_unregister_analysis_child().
  */
@@ -39,10 +41,10 @@ function tripal_analysis_unregister_child($modulename) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_analysis_unregister_child',
-      '%new_function' => 'tripal_unregister_analysis_child'
-    )
+    [
+      '%old_function' => 'tripal_analysis_unregister_child',
+      '%new_function' => 'tripal_unregister_analysis_child',
+    ]
   );
 
   return tripal_unregister_analysis_child($modulename);
@@ -50,8 +52,8 @@ function tripal_analysis_unregister_child($modulename) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_get_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_get_property().
  *
  * @see chado_get_property().
  */
@@ -61,28 +63,28 @@ function tripal_analysis_get_property($analysis_id, $property, $cv_name = 'tripa
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_analysis_get_property',
-      '%new_function' => 'chado_get_property'
-    )
+    [
+      '%old_function' => 'tripal_analysis_get_property',
+      '%new_function' => 'chado_get_property',
+    ]
   );
-  
-  $record = array(
+
+  $record = [
     'table' => 'analysis',
     'id' => $analysis_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
-  );
+  ];
 
   return chado_get_property($record, $property);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_insert_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_insert_property().
  *
  * @see chado_insert_property().
  */
@@ -92,31 +94,31 @@ function tripal_analysis_insert_property($analysis_id, $property, $value, $updat
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_analysis_insert_property',
-      '%new_function' => 'chado_insert_property'
-    )
+    [
+      '%old_function' => 'tripal_analysis_insert_property',
+      '%new_function' => 'chado_insert_property',
+    ]
   );
 
-  $record = array(
+  $record = [
     'table' => 'analysis',
     'id' => $analysis_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
     'value' => $value,
-  );
-  $options = array(
+  ];
+  $options = [
     'update_if_present' => $update_if_present,
-  );
+  ];
   return chado_insert_property($record, $property, $options);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_update_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_update_property().
  *
  * @see chado_update_property().
  */
@@ -126,31 +128,32 @@ function tripal_analysis_update_property($analysis_id, $property, $value, $inser
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_analysis_update_property',
-      '%new_function' => 'chado_update_property'
-    )
+    [
+      '%old_function' => 'tripal_analysis_update_property',
+      '%new_function' => 'chado_update_property',
+    ]
   );
 
-  $record = array(
+  $record = [
     'table' => 'analysis',
     'id' => $analysis_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
     'value' => $value,
-  );
-  $options = array(
+  ];
+  $options = [
     'insert_if_missing' => $insert_if_missing,
-  );
+  ];
   return chado_update_property($record, $property, $options);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by the more generic chado_delete_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by the more generic
+ *   chado_delete_property().
  *
  * @see chado_delete_property().
  */
@@ -158,26 +161,26 @@ function tripal_analysis_delete_property($analysis_id, $property, $cv_name = 'tr
 
   tripal_report_error('tripal_deprecated', TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_analysis_delete_property',
-      '%new_function' => 'chado_delete_property'
-    )
+    [
+      '%old_function' => 'tripal_analysis_delete_property',
+      '%new_function' => 'chado_delete_property',
+    ]
   );
-  $record = array(
+  $record = [
     'table' => 'analysis',
     'id' => $analysis_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
-  );
+  ];
   return chado_delete_property($record, $property);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_analysis().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_analysis().
  *
  * @see tripal_get_analysis().
  */
@@ -187,11 +190,11 @@ function tripal_analysis_get_node($analysis_id) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_analysis_get_node',
-      '%new_function' => 'tripal_get_analysis'
-    )
+    [
+      '%old_function' => 'tripal_analysis_get_node',
+      '%new_function' => 'tripal_get_analysis',
+    ]
   );
 
-  return tripal_get_analysis(array('analysis_id' => $analysis_id));
+  return tripal_get_analysis(['analysis_id' => $analysis_id]);
 }

+ 26 - 21
legacy/tripal_analysis/includes/tripal_analysis.admin.inc

@@ -8,7 +8,8 @@
  */
 
 /**
- * Landing page for administration. Ensures Views are enabled & if not provides links to do so.
+ * Landing page for administration. Ensures Views are enabled & if not provides
+ * links to do so.
  *
  * @ingroup tripal_legacy_analysis
  */
@@ -16,7 +17,7 @@ function tripal_analysis_admin_analysis_view() {
   $output = '';
 
   // set the breadcrumb
-  $breadcrumb = array();
+  $breadcrumb = [];
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
@@ -25,7 +26,7 @@ function tripal_analysis_admin_analysis_view() {
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
-  $view = views_embed_view('tripal_analysis_admin_analyses','default');
+  $view = views_embed_view('tripal_analysis_admin_analyses', 'default');
   if (isset($view)) {
     $output .= $view;
   }
@@ -35,7 +36,7 @@ function tripal_analysis_admin_analysis_view() {
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'enable the pertinent views</strong>:</p>';
     $output .= '<ul>';
-      $output .= '<li>'.l('Analysis View', 'admin/tripal/legacy/tripal_analysis/views/analyses/enable').'</li>';
+    $output .= '<li>' . l('Analysis View', 'admin/tripal/legacy/tripal_analysis/views/analyses/enable') . '</li>';
     $output .= '</ul>';
   }
 
@@ -54,36 +55,38 @@ function tripal_analysis_admin() {
   // Create a new administrative form. We'll add main functions to the form
   // first (Sync, Reindex, Clean, Taxonify). Thereafter, any sub-module that
   // has a setting will be added.
-  $form = array();
+  $form = [];
 
   // If your module is using the Chado Node: Title & Path API to allow custom titles
   // for your node type then you need to add the configuration form for this functionality.
-  $details = array(
-    'module' => 'tripal_analysis',       // the name of the MODULE implementing the content type
-    'content_type' => 'chado_analysis',   // the name of the content type
-      // An array of options to use under "Page Titles"
-      // the key should be the token and the value should be the human-readable option
-    'options' => array(
+  $details = [
+    'module' => 'tripal_analysis',
+    // the name of the MODULE implementing the content type
+    'content_type' => 'chado_analysis',
+    // the name of the content type
+    // An array of options to use under "Page Titles"
+    // the key should be the token and the value should be the human-readable option
+    'options' => [
       '[analysis.name]' => 'Analysis Name Only',
-        // there should always be one options matching the unique constraint.
-      '[analysis.name] ([analysis.sourcename]) [analysis.program] version [analysis.programversion]' => 'Unique Contraint: Includes the name, source and program name/version'
-    ),
+      // there should always be one options matching the unique constraint.
+      '[analysis.name] ([analysis.sourcename]) [analysis.program] version [analysis.programversion]' => 'Unique Contraint: Includes the name, source and program name/version',
+    ],
     // the token indicating the unique constraint in the options array
-    'unique_option' => '[analysis.name] ([analysis.sourcename]) [analysis.program] version [analysis.programversion]'
-  );
+    'unique_option' => '[analysis.name] ([analysis.sourcename]) [analysis.program] version [analysis.programversion]',
+  ];
   // This call adds the configuration form to your current form
   // This sub-form handles it's own validation & submit
   chado_add_admin_form_set_title($form, $form_state, $details);
 
   // URL ALIAS
-  $details = array(
+  $details = [
     'module' => 'tripal_analysis',
     'content_type' => 'chado_analysis',
-    'options' => array(
+    'options' => [
       '/analysis/[analysis.analysis_id]' => 'Analysis ID',
-      '/analysis/[analysis.program]/[analysis.programversion]/[analysis.sourcename]' => 'Unique Contraint: Includes the program name & version as well as the source name'
-    ),
-  );
+      '/analysis/[analysis.program]/[analysis.programversion]/[analysis.sourcename]' => 'Unique Contraint: Includes the program name & version as well as the source name',
+    ],
+  ];
 
   // This call adds the configuration form to your current form
   // This sub-form handles it's own validation & submit
@@ -94,10 +97,12 @@ function tripal_analysis_admin() {
 
 /**
  * Validate the administrative form
+ *
  * @todo Stephen: Why is validate used rather then submit?
  *
  * @param $form
  *   The form API array of the form to be validated
+ *
  * @form_state
  *   The user submitted values
  *

+ 193 - 186
legacy/tripal_analysis/includes/tripal_analysis.chado_node.inc

@@ -15,27 +15,27 @@
  * @ingroup tripal_legacy_analysis
  */
 function tripal_analysis_node_info() {
-  $nodes = array();
-  $nodes['chado_analysis'] = array(
-    'name'        => t('Analysis (Tripal v2 legacy)'),
-    'base'        => 'chado_analysis',
+  $nodes = [];
+  $nodes['chado_analysis'] = [
+    'name' => t('Analysis (Tripal v2 legacy)'),
+    'base' => 'chado_analysis',
     'description' => t('An analysis'),
-    'has_title'   => TRUE,
-    'locked'      => TRUE,
-    'chado_node_api' => array(
+    'has_title' => TRUE,
+    'locked' => TRUE,
+    'chado_node_api' => [
       'base_table' => 'analysis',
       'hook_prefix' => 'chado_analysis',
-      'record_type_title' => array(
+      'record_type_title' => [
         'singular' => t('Analysis'),
-        'plural' => t('Analyses')
-      ),
-      'sync_filters' => array(
+        'plural' => t('Analyses'),
+      ],
+      'sync_filters' => [
         'type_id' => FALSE,
         'organism_id' => FALSE,
-        'checkboxes' => array('name'),
-      ),
-    )
-  );
+        'checkboxes' => ['name'],
+      ],
+    ],
+  ];
   return $nodes;
 }
 
@@ -51,6 +51,7 @@ function chado_analysis_chado_node_sync_form($form, &$form_state) {
   }
   return $form;
 }
+
 /**
  * Implements hook_form().
  * When editing or creating a new node of type 'chado_analysis' we need
@@ -59,7 +60,7 @@ function chado_analysis_chado_node_sync_form($form, &$form_state) {
  * @ingroup tripal_legacy_analysis
  */
 function chado_analysis_form($node, &$form_state) {
-  $form = array();
+  $form = [];
 
   // Default values can come in the following ways:
   //
@@ -70,18 +71,18 @@ function chado_analysis_form($node, &$form_state) {
   //    form elements and the form is being rebuilt
   //
   // set form field defaults
-  $analysis_id    = null;
-  $analysisname   = '';
-  $program        = '';
+  $analysis_id = NULL;
+  $analysisname = '';
+  $program = '';
   $programversion = '';
-  $algorithm      = '';
-  $sourcename     = '';
-  $sourceversion  = '';
-  $sourceuri      = '';
-  $timeexecuted   = '';
-  $description    = '';
-  $d_removed      = array(); // lists removed properties
-  $num_new        = 0;  // the number of new rows
+  $algorithm = '';
+  $sourcename = '';
+  $sourceversion = '';
+  $sourceuri = '';
+  $timeexecuted = '';
+  $description = '';
+  $d_removed = []; // lists removed properties
+  $num_new = 0;  // the number of new rows
 
   // if we are editing an existing node then the analysis is already part of the node
   if (property_exists($node, 'analysis')) {
@@ -90,62 +91,62 @@ function chado_analysis_form($node, &$form_state) {
     $analysis_id = $analysis->analysis_id;
 
     // get form defaults
-    $analysisname   = $analysis->name;
-    $program        = $analysis->program;
+    $analysisname = $analysis->name;
+    $program = $analysis->program;
     $programversion = $analysis->programversion;
-    $algorithm      = $analysis->algorithm;
-    $sourcename     = $analysis->sourcename;
-    $sourceversion  = $analysis->sourceversion;
-    $sourceuri      = $analysis->sourceuri;
-    $timeexecuted   = $analysis->timeexecuted;
-    $description    = $analysis->description;
-    $analysis_type  = $node->type;
+    $algorithm = $analysis->algorithm;
+    $sourcename = $analysis->sourcename;
+    $sourceversion = $analysis->sourceversion;
+    $sourceuri = $analysis->sourceuri;
+    $timeexecuted = $analysis->timeexecuted;
+    $description = $analysis->description;
+    $analysis_type = $node->type;
 
 
     // set the analysis_id in the form
-    $form['analysis_id'] = array(
+    $form['analysis_id'] = [
       '#type' => 'value',
       '#value' => $analysis->analysis_id,
-    );
+    ];
   }
   // if we are re constructing the form from a failed validation or ajax callback
   // then use the $form_state['values'] values
   if (array_key_exists('values', $form_state)) {
-    $analysisname   = $form_state['values']['analysisname'];
-    $program        = $form_state['values']['program'];
+    $analysisname = $form_state['values']['analysisname'];
+    $program = $form_state['values']['program'];
     $programversion = $form_state['values']['programversion'];
-    $algorithm      = $form_state['values']['algorithm'];
-    $sourcename     = $form_state['values']['sourcename'];
-    $sourceversion  = $form_state['values']['sourceversion'];
-    $sourceuri      = $form_state['values']['sourceuri'];
-    $timeexecuted   = $form_state['values']['timeexecuted'];
-    $description    = $form_state['values']['description'];
-    $d_removed      = $form_state['values']['removed'];
-    $num_new        = $form_state['values']['num_new'] ? $form_state['values']['num_new'] : 0;
-    $analysis_type  = $form_state['values']['analysis_type'];
+    $algorithm = $form_state['values']['algorithm'];
+    $sourcename = $form_state['values']['sourcename'];
+    $sourceversion = $form_state['values']['sourceversion'];
+    $sourceuri = $form_state['values']['sourceuri'];
+    $timeexecuted = $form_state['values']['timeexecuted'];
+    $description = $form_state['values']['description'];
+    $d_removed = $form_state['values']['removed'];
+    $num_new = $form_state['values']['num_new'] ? $form_state['values']['num_new'] : 0;
+    $analysis_type = $form_state['values']['analysis_type'];
   }
   // if we are re building the form from after submission (from ajax call) then
   // the values are in the $form_state['input'] array
   if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
-    $analysisname   = $form_state['input']['analysisname'];
-    $program        = $form_state['input']['program'];
+    $analysisname = $form_state['input']['analysisname'];
+    $program = $form_state['input']['program'];
     $programversion = $form_state['input']['programversion'];
-    $algorithm      = $form_state['input']['algorithm'];
-    $sourcename     = $form_state['input']['sourcename'];
-    $sourceversion  = $form_state['input']['sourceversion'];
-    $sourceuri      = $form_state['input']['sourceuri'];
-    $timeexecuted   = $form_state['input']['timeexecuted'];
-    $description    = $form_state['input']['description'];
-    $d_removed      = isset($form_state['input']['removed']) ? $form_state['input']['removed'] : array();
-    $num_new        = isset($form_state['input']['num_new']) ? $form_state['input']['num_new'] : 0;
-    $analysis_type  = isset($form_state['input']['analysis_type']) ? $form_state['input']['analysis_type'] : '';
+    $algorithm = $form_state['input']['algorithm'];
+    $sourcename = $form_state['input']['sourcename'];
+    $sourceversion = $form_state['input']['sourceversion'];
+    $sourceuri = $form_state['input']['sourceuri'];
+    $timeexecuted = $form_state['input']['timeexecuted'];
+    $description = $form_state['input']['description'];
+    $d_removed = isset($form_state['input']['removed']) ? $form_state['input']['removed'] : [];
+    $num_new = isset($form_state['input']['num_new']) ? $form_state['input']['num_new'] : 0;
+    $analysis_type = isset($form_state['input']['analysis_type']) ? $form_state['input']['analysis_type'] : '';
   }
 
-  $form['title']= array(
+  $form['title'] = [
     '#type' => 'value',
     '#default_value' => $node->title,
-  );
-  $form['instructions'] = array(
+  ];
+  $form['instructions'] = [
     '#markup' => t('When adding any type of data it is good to associate it with
         an analysis so that site visitors can identify the source of the data including
         necessary materials and methods.  The fields below imply that all analyses
@@ -153,52 +154,52 @@ function chado_analysis_form($node, &$form_state) {
         from an external source or an analysis pipeline with multipel software components.
         In these cases, provide values for the fields below that best makes sense
      '),
-  );
-  $form['analysisname']= array(
+  ];
+  $form['analysisname'] = [
     '#type' => 'textfield',
     '#title' => t('Analysis Name'),
     '#required' => TRUE,
     '#default_value' => $analysisname,
     '#description' => t("This should be a brief name that
        describes the analysis succintly. This name will helps the user find analyses."),
-  );
-  $form['program']= array(
+  ];
+  $form['program'] = [
     '#type' => 'textfield',
     '#title' => t('Program, Pipeline Name or Method Name'),
     '#required' => TRUE,
     '#default_value' => $program,
     '#description' => t("Program name, e.g. blastx, blastp, sim4, genscan. If the analysis was not derived from a software package, provide a very brief description of the pipeline or method."),
-  );
-  $form['programversion']= array(
+  ];
+  $form['programversion'] = [
     '#type' => 'textfield',
     '#title' => t('Program, Pipeline  or Method Version'),
     '#required' => TRUE,
     '#default_value' => $programversion,
     '#description' => t("Version description, e.g. TBLASTX 2.0MP-WashU [09-Nov-2000]. Enter 'n/a' if no version is available or applicable."),
-  );
-  $form['algorithm']= array(
+  ];
+  $form['algorithm'] = [
     '#type' => 'textfield',
     '#title' => t('Algorithm'),
     '#required' => FALSE,
     '#default_value' => $algorithm,
     '#description' => t("Algorithm name, e.g. blast."),
-  );
-  $form['sourcename']= array(
+  ];
+  $form['sourcename'] = [
     '#type' => 'textfield',
     '#title' => t('Source Name'),
     '#required' => TRUE,
     '#default_value' => $sourcename,
     '#description' => t('The name of the source data.  This could be a file name, data set name or a
          small description for how the data was collected.  For long descriptions use the description field below'),
-  );
-  $form['sourceversion']= array(
+  ];
+  $form['sourceversion'] = [
     '#type' => 'textfield',
     '#title' => t('Source Version'),
     '#required' => FALSE,
     '#default_value' => $sourceversion,
     '#description' => t('If the source dataset has a version, include it here'),
-  );
-  $form['sourceuri']= array(
+  ];
+  $form['sourceuri'] = [
     '#type' => 'textfield',
     '#title' => t('Source URI'),
     '#required' => FALSE,
@@ -206,7 +207,7 @@ function chado_analysis_form($node, &$form_state) {
     '#description' => t("This is a permanent URL or URI for the source of the analysis.
        Someone could recreate the analysis directly by going to this URI and
        fetching the source data (e.g. the blast database, or the training model)."),
-  );
+  ];
 
   // Get time saved in chado
   $default_time = $timeexecuted;
@@ -216,21 +217,21 @@ function chado_analysis_form($node, &$form_state) {
   // If the time is not set, use current time
   if (!$default_time) {
     $default_time = REQUEST_TIME;
-    $year  = format_date($default_time, 'custom', 'Y');
+    $year = format_date($default_time, 'custom', 'Y');
     $month = format_date($default_time, 'custom', 'n');
-    $day   = format_date($default_time, 'custom', 'j');
+    $day = format_date($default_time, 'custom', 'j');
   }
-  $form['timeexecuted']= array(
+  $form['timeexecuted'] = [
     '#type' => 'date',
     '#title' => t('Time Executed'),
     '#required' => TRUE,
-    '#default_value' => array(
-       'year' => $year,
-       'month' => $month,
-       'day' => $day,
-    ),
-  );
-  $form['description']= array(
+    '#default_value' => [
+      'year' => $year,
+      'month' => $month,
+      'day' => $day,
+    ],
+  ];
+  $form['description'] = [
     '#type' => 'text_format',
     '#rows' => 15,
     '#title' => t('Materials & Methods (Description and/or Program Settings)'),
@@ -239,7 +240,7 @@ function chado_analysis_form($node, &$form_state) {
     '#description' => t('Please provide all necessary information to allow
        someone to recreate the analysis, including materials and methods
        for collection of the source data and performing the analysis'),
-  );
+  ];
 
   /*
   // get node types from analysis extension modules
@@ -270,13 +271,16 @@ function chado_analysis_form($node, &$form_state) {
   $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the analysis_property vocabulary", "admin/tripal/loaders/chado_cv/cvterm/add") . ".");
   $prop_cv = tripal_get_default_cv('analysisprop', 'type_id');
   $cv_id = $prop_cv ? $prop_cv->cv_id : NULL;
-  $details = array(
-    'property_table' => 'analysisprop',       // the name of the prop table
-    'chado_id' => $analysis_id,               // the value of analysis_id for this record
-    'cv_id' => $cv_id,                        // the cv.cv_id of the cv governing analysisprop.type_id
+  $details = [
+    'property_table' => 'analysisprop',
+    // the name of the prop table
+    'chado_id' => $analysis_id,
+    // the value of analysis_id for this record
+    'cv_id' => $cv_id,
+    // the cv.cv_id of the cv governing analysisprop.type_id
     'fieldset_title' => 'Properties',
-    'additional_instructions' => $instructions
-  );
+    'additional_instructions' => $instructions,
+  ];
   chado_add_node_form_properties($form, $form_state, $details);
 
   return $form;
@@ -307,7 +311,7 @@ function tripal_analysis_validate($node, $form, &$form_state) {
   // Since this validate can be called on AJAX and Deletion of the node
   // we need to make this check to ensure queries are not executed
   // without the proper values.
-  if($node->op != 'Save') {
+  if ($node->op != 'Save') {
     return;
   }
 
@@ -330,14 +334,14 @@ function tripal_analysis_validate($node, $form, &$form_state) {
   if (!is_null($node->nid)) {
 
     // get the existing node
-    $values = array('analysis_id' => $node->analysis_id);
-    $result = chado_select_record('analysis', array('*'), $values);
+    $values = ['analysis_id' => $node->analysis_id];
+    $result = chado_select_record('analysis', ['*'], $values);
     $analysis = $result[0];
 
     // if the name has changed make sure it doesn't conflict with an existing name
     if ($analysis->name != $node->analysisname) {
-      $values = array('name' => $node->analysisname);
-      $result = chado_select_record('analysis', array('analysis_id'), $values);
+      $values = ['name' => $node->analysisname];
+      $result = chado_select_record('analysis', ['analysis_id'], $values);
       if ($result and count($result) > 0) {
         form_set_error('analysisname', 'Cannot update the analysis with this analysis name. An analysis with this name already exists.');
         return;
@@ -347,13 +351,13 @@ function tripal_analysis_validate($node, $form, &$form_state) {
     // if the unique constraint has changed check to make sure it doesn't conflict with an
     // existing record
     if ($analysis->program != $node->program or $analysis->programversion != $node->programversion or
-       $analysis->sourcename != $node->sourcename) {
-      $values = array(
+      $analysis->sourcename != $node->sourcename) {
+      $values = [
         'program' => $node->program,
         'programversion' => $node->programversion,
         'sourcename' => $node->sourcename,
-      );
-      $result = chado_select_record('analysis', array('analysis_id'), $values);
+      ];
+      $result = chado_select_record('analysis', ['analysis_id'], $values);
       if ($result and count($result) > 0) {
         if ($analysis->program != $node->program) {
           $field = 'program';
@@ -372,12 +376,12 @@ function tripal_analysis_validate($node, $form, &$form_state) {
   }
   // Validating for an insert
   else {
-    $values = array(
+    $values = [
       'program' => $node->program,
       'programversion' => $node->programversion,
       'sourcename' => $node->sourcename,
-    );
-    $analysis = chado_select_record('analysis', array('analysis_id'), $values);
+    ];
+    $analysis = chado_select_record('analysis', ['analysis_id'], $values);
     if ($analysis and count($analysis) > 0) {
       form_set_error('program', 'Cannot add the analysis with this program,
         program version and source name. An analysis with these values already exists.');
@@ -387,8 +391,8 @@ function tripal_analysis_validate($node, $form, &$form_state) {
     // make sure we have a unique analysis name. This is not a requirement
     // for the analysis table but we use the analysis name for the Drupal node
     // title, so it should be unique
-    $values = array('name' => $node->analysisname);
-    $result = chado_select_record('analysis', array('analysis_id'), $values);
+    $values = ['name' => $node->analysisname];
+    $result = chado_select_record('analysis', ['analysis_id'], $values);
     if ($result and count($result) > 0) {
       form_set_error('analysisname', 'Cannot add the analysis with this analysis name. An analysis with this name already exists.');
       return;
@@ -413,7 +417,7 @@ function chado_analysis_insert($node) {
   $node->sourcename = trim($node->sourcename);
   $node->sourceversion = trim($node->sourceversion);
   $node->sourceuri = trim($node->sourceuri);
-  $node->description  = trim($node->description['value']);
+  $node->description = trim($node->description['value']);
 
   // if there is an analysis_id in the $node object then this must be a sync so
   // we can skip adding the analysis as it is already there, although
@@ -421,40 +425,40 @@ function chado_analysis_insert($node) {
   if (!property_exists($node, 'analysis_id')) {
 
     // Create a timestamp so we can insert it into the chado database
-    $time  = $node->timeexecuted;
+    $time = $node->timeexecuted;
     $month = $time['month'];
-    $day   = $time['day'];
-    $year  = $time['year'];
+    $day = $time['day'];
+    $year = $time['year'];
     $timestamp = $month . '/' . $day . '/' . $year;
 
     // Insert and then get the newly inserted analysis record
-    $values = array(
-      'name'           => $node->analysisname,
-      'description'    => $node->description,
-      'program'        => $node->program,
+    $values = [
+      'name' => $node->analysisname,
+      'description' => $node->description,
+      'program' => $node->program,
       'programversion' => $node->programversion,
-      'algorithm'      => $node->algorithm,
-      'sourcename'     => $node->sourcename,
-      'sourceversion'  => $node->sourceversion,
-      'sourceuri'      => $node->sourceuri,
-      'timeexecuted'   => $timestamp
-    );
+      'algorithm' => $node->algorithm,
+      'sourcename' => $node->sourcename,
+      'sourceversion' => $node->sourceversion,
+      'sourceuri' => $node->sourceuri,
+      'timeexecuted' => $timestamp,
+    ];
     $analysis = chado_insert_record('analysis', $values);
     if (!$analysis) {
       drupal_set_message(t('Unable to add analysis.'), 'warning');
       tripal_report_error('tripal_analysis', TRIPAL_ERROR, 'Insert analysis: Unable to create analysis where values:%values',
-        array('%values' => print_r($values, TRUE)));
+        ['%values' => print_r($values, TRUE)]);
       return;
     }
     $analysis_id = $analysis['analysis_id'];
 
     // now add in the properties
-    $details = array(
+    $details = [
       'property_table' => 'analysisprop',
       'base_table' => 'analysis',
       'foreignkey_name' => 'analysis_id',
-      'foreignkey_value' => $analysis_id
-    );
+      'foreignkey_value' => $analysis_id,
+    ];
     chado_update_node_form_properties($node, $details);
   }
   else {
@@ -495,14 +499,14 @@ function chado_analysis_delete($node) {
 
   // Remove data from the {chado_analysis}, {node}, and {node_revisions} tables
   $sql_del = "DELETE FROM {chado_analysis} WHERE nid = :nid AND vid = :vid";
-  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
+  db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
   $sql_del = "DELETE FROM {node} WHERE nid = :nid AND vid = :vid";
-  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
+  db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
   $sql_del = "DELETE FROM {node_revision} WHERE nid = :nid AND vid = :vid";
-  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
+  db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
 
   //Remove from analysis and analysisprop tables of chado database as well
-  chado_query("DELETE FROM {analysis} WHERE analysis_id = :analysis_id", array(':analysis_id' => $analysis_id));
+  chado_query("DELETE FROM {analysis} WHERE analysis_id = :analysis_id", [':analysis_id' => $analysis_id]);
 }
 
 /**
@@ -519,7 +523,7 @@ function chado_analysis_update($node) {
   $node->sourcename = trim($node->sourcename);
   $node->sourceversion = trim($node->sourceversion);
   $node->sourceuri = trim($node->sourceuri);
-  $node->description  = trim($node->description['value']);
+  $node->description = trim($node->description['value']);
 
   // Create a timestamp so we can insert it into the chado database
   $time = $node->timeexecuted;
@@ -530,36 +534,36 @@ function chado_analysis_update($node) {
 
   // update the record in Chado
   $analysis_id = chado_get_id_from_nid('analysis', $node->nid);
-  $match = array(
+  $match = [
     'analysis_id' => $node->analysis_id,
-  );
-  $values = array(
-    'name'           => $node->analysisname,
-    'description'    => $node->description,
-    'program'        => $node->program,
+  ];
+  $values = [
+    'name' => $node->analysisname,
+    'description' => $node->description,
+    'program' => $node->program,
     'programversion' => $node->programversion,
-    'algorithm'      => $node->algorithm,
-    'sourcename'     => $node->sourcename,
-    'sourceversion'  => $node->sourceversion,
-    'sourceuri'      => $node->sourceuri,
-    'timeexecuted'   => $timestamp,
-    'analysis_id'    => $analysis_id
-  );
+    'algorithm' => $node->algorithm,
+    'sourcename' => $node->sourcename,
+    'sourceversion' => $node->sourceversion,
+    'sourceuri' => $node->sourceuri,
+    'timeexecuted' => $timestamp,
+    'analysis_id' => $analysis_id,
+  ];
   $status = chado_update_record('analysis', $match, $values);
   if (!$status) {
     drupal_set_message(t('Unable to update analysis.', 'warning'));
     tripal_report_error('tripal_analysis', TRIPAL_ERROR, 'Update analysis: Unable to update analysis where values: %values',
-    array('%values' => print_r($values, TRUE)));
+      ['%values' => print_r($values, TRUE)]);
   }
 
   // now add in the properties by first removing any the analysis
   // already has and adding the ones we have
-  $details = array(
+  $details = [
     'property_table' => 'analysisprop',
     'base_table' => 'analysis',
     'foreignkey_name' => 'analysis_id',
-    'foreignkey_value' => $analysis_id
-  );
+    'foreignkey_value' => $analysis_id,
+  ];
   chado_update_node_form_properties($node, $details);
 }
 
@@ -583,7 +587,7 @@ function chado_analysis_load($nodes) {
     }
 
     // build the analysis variable
-    $values = array('analysis_id' => $analysis_id);
+    $values = ['analysis_id' => $analysis_id];
     $analysis = chado_generate_var('analysis', $values);
 
     // add in the description field
@@ -600,21 +604,22 @@ function chado_analysis_load($nodes) {
  *
  * This hook allows node modules to limit access to the node types they define.
  *
- *  @param $node
- *  The node on which the operation is to be performed, or, if it does not yet exist, the
- *  type of node to be created
+ * @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet
+ *   exist, the type of node to be created
  *
- *  @param $op
+ * @param $op
  *  The operation to be performed
  *
- *  @param $account
- *  A user object representing the user for whom the operation is to be performed
+ * @param $account
+ *  A user object representing the user for whom the operation is to be
+ *   performed
  *
- *  @return
- *  If the permission for the specified operation is not set then return FALSE. If the
- *  permission is set then return NULL as this allows other modules to disable
- *  access.  The only exception is when the $op == 'create'.  We will always
- *  return TRUE if the permission is set.
+ * @return
+ *  If the permission for the specified operation is not set then return FALSE.
+ *   If the permission is set then return NULL as this allows other modules to
+ *   disable access.  The only exception is when the $op == 'create'.  We will
+ *   always return TRUE if the permission is set.
  *
  * @ingroup tripal_legacy_analysis
  */
@@ -625,7 +630,7 @@ function tripal_analysis_node_access($node, $op, $account) {
     $node_type = $node->type;
   }
 
-  if($node_type == 'chado_analysis') {
+  if ($node_type == 'chado_analysis') {
     if ($op == 'create') {
       if (!user_access('create chado_analysis content', $account)) {
         return NODE_ACCESS_DENY;
@@ -662,25 +667,25 @@ function tripal_analysis_node_view($node, $view_mode, $langcode) {
     case 'chado_analysis':
       // Show feature browser and counts
       if ($view_mode == 'full') {
-        $node->content['tripal_analysis_base'] = array(
+        $node->content['tripal_analysis_base'] = [
           '#theme' => 'tripal_analysis_base',
           '#node' => $node,
-          '#tripal_toc_id'    => 'base',
+          '#tripal_toc_id' => 'base',
           '#tripal_toc_title' => 'Overview',
           '#weight' => -100,
-        );
-        $node->content['tripal_analysis_properties'] = array(
+        ];
+        $node->content['tripal_analysis_properties'] = [
           '#theme' => 'tripal_analysis_properties',
           '#node' => $node,
-          '#tripal_toc_id'    => 'properties',
+          '#tripal_toc_id' => 'properties',
           '#tripal_toc_title' => 'Properties',
-        );
+        ];
       }
       if ($view_mode == 'teaser') {
-        $node->content['tripal_analysis_teaser'] = array(
+        $node->content['tripal_analysis_teaser'] = [
           '#theme' => 'tripal_analysis_teaser',
           '#node' => $node,
-        );
+        ];
       }
       break;
   }
@@ -711,12 +716,12 @@ function tripal_analysis_node_presave($node) {
   // modules will use this module as a type of "inherited" class, so we don't know
   // for sure when type of analysis we have.  If this is a sync then
   if (property_exists($node, 'program') and
-      property_exists($node, 'programversion') and
-      property_exists($node, 'sourcename')) {
-    $name           = $node->analysisname;
-    $program        = $node->program;
+    property_exists($node, 'programversion') and
+    property_exists($node, 'sourcename')) {
+    $name = $node->analysisname;
+    $program = $node->program;
     $programversion = $node->programversion;
-    $sourcename     = $node->sourcename;
+    $sourcename = $node->sourcename;
     // now construct the title
     $node->title = "$program ($programversion) $sourcename";
     if ($name) {
@@ -725,17 +730,19 @@ function tripal_analysis_node_presave($node) {
     // reset the type
     //$node->type = $node->analysis_type;
   }
-  else if (property_exists($node, 'analysis')) {
-    $name           = $node->analysis->name;
-    $program        = $node->analysis->program;
-    $programversion = $node->analysis->programversion;
-    $sourcename     = $node->analysis->sourcename;
-    // now construct the title
-    $node->title = "$program ($programversion) $sourcename";
-    if ($name) {
-      $node->title = $name;
+  else {
+    if (property_exists($node, 'analysis')) {
+      $name = $node->analysis->name;
+      $program = $node->analysis->program;
+      $programversion = $node->analysis->programversion;
+      $sourcename = $node->analysis->sourcename;
+      // now construct the title
+      $node->title = "$program ($programversion) $sourcename";
+      if ($name) {
+        $node->title = $name;
+      }
+      //$node->type = $node->analysis_type;
     }
-    //$node->type = $node->analysis_type;
   }
 }
 
@@ -754,7 +761,7 @@ function tripal_analysis_node_insert($node) {
       // we need to simulate one so that the right values are available for
       // the URL to be determined.
       $analysis_id = chado_get_id_from_nid('analysis', $node->nid);
-      $values = array('analysis_id' => $analysis_id);
+      $values = ['analysis_id' => $analysis_id];
       $analysis = chado_generate_var('analysis', $values);
       $node->analysis = $analysis;
 

+ 33 - 34
legacy/tripal_analysis/includes/tripal_analysis.delete.inc

@@ -2,41 +2,41 @@
 
 /**
  * @file
-* Administration Interface for deleting multiple analyses
-*/
+ * Administration Interface for deleting multiple analyses
+ */
 
 /**
  * A form for indicating the analyses to delete
-*
-* @ingroup tripal_legacy_analysis
-*/
+ *
+ * @ingroup tripal_legacy_analysis
+ */
 function tripal_analysis_delete_form() {
   // get the list of analyses
   $sql = "SELECT * FROM {analysis} ORDER BY name";
   $org_rset = chado_query($sql);
-  $analyses = array();
+  $analyses = [];
   while ($analysis = $org_rset->fetchObject()) {
     $analyses[$analysis->analysis_id] = "$analysis->name";
   }
 
-  $form['desc'] = array(
-      '#markup' => t("Use the following form to delete analyses which may or may
+  $form['desc'] = [
+    '#markup' => t("Use the following form to delete analyses which may or may
         not be synced. Please be cautious. Deleting an analysis will cause all
         data associated with the analysis to also be deleted."),
-  );
-
-  $form['analyses'] = array(
-      '#title'       => t('analysis'),
-      '#type'        => 'checkboxes',
-      '#options'     => $analyses,
-      '#prefix'      => '<div style="height: 400px; overflow: scroll">',
-      '#suffix'      => '</div><br>',
-  );
-
-  $form['button'] = array(
-      '#type' => 'submit',
-      '#value' => t('Delete analyses'),
-  );
+  ];
+
+  $form['analyses'] = [
+    '#title' => t('analysis'),
+    '#type' => 'checkboxes',
+    '#options' => $analyses,
+    '#prefix' => '<div style="height: 400px; overflow: scroll">',
+    '#suffix' => '</div><br>',
+  ];
+
+  $form['button'] = [
+    '#type' => 'submit',
+    '#value' => t('Delete analyses'),
+  ];
   return $form;
 }
 
@@ -49,8 +49,8 @@ function tripal_analysis_delete_form_submit($form, &$form_state) {
   global $user;
 
   // Convert the analyses input into an array of just ids.
-  $analyses   = $form_state['values']['analyses'];
-  $org_ids = array();
+  $analyses = $form_state['values']['analyses'];
+  $org_ids = [];
   foreach ($analyses as $id => $val) {
     if ($val != 0) {
       $org_ids[] = $id;
@@ -58,10 +58,10 @@ function tripal_analysis_delete_form_submit($form, &$form_state) {
   }
 
   if (count($org_ids) > 0) {
-    $args = array($org_ids);
+    $args = [$org_ids];
 
     tripal_add_job("Delete analysis", 'tripal_analysis',
-    'tripal_analysis_delete_analyses', $args, $user->uid);
+      'tripal_analysis_delete_analyses', $args, $user->uid);
     drupal_set_message(t("analyses will disappear from the list below once the job completes."));
   }
   else {
@@ -92,21 +92,20 @@ function tripal_analysis_delete_analyses($analyses, $job = NULL) {
   // begin the transaction
   $transaction = db_transaction();
   print "\nNOTE: Deleting analyses is performed using a database transaction. \n" .
-      "If the load fails or is terminated prematurely then the entire set of \n" .
-      "deletions is rolled back and will not be found in the database\n\n";
+    "If the load fails or is terminated prematurely then the entire set of \n" .
+    "deletions is rolled back and will not be found in the database\n\n";
 
   try {
-    $values = array(
-        'analysis_id' => $analyses
-    );
-    $num_deletes = chado_select_record('analysis', array('count(*) as cnt'), $values);
+    $values = [
+      'analysis_id' => $analyses,
+    ];
+    $num_deletes = chado_select_record('analysis', ['count(*) as cnt'], $values);
     print "Deleting " . $num_deletes[0]->cnt . " analyses\n";
     chado_delete_record('analysis', $values);
 
     print "Removing orphaned analysis pages\n";
     chado_cleanup_orphaned_nodes('analysis');
-  }
-  catch (Exception $e) {
+  } catch (Exception $e) {
     print "\n"; // make sure we start errors on new line
     $transaction->rollback();
     print "FAILED: Rolling back database changes...\n";

+ 27 - 15
legacy/tripal_analysis/includes/tripal_analysis_privacy.inc

@@ -7,7 +7,8 @@
  */
 
 /**
- * Perform permission check by analysis_id only if 'node_privacy_byrole' module is enabled
+ * Perform permission check by analysis_id only if 'node_privacy_byrole' module
+ * is enabled
  *
  * @param $analysis_id
  *   Which analysis to check if the user has permission to view
@@ -25,7 +26,10 @@ function tripal_analysis_check_permission($analysis_id) {
         FROM {node_access} NA
           INNER JOIN {chado_analysis} CA ON NA.nid = CA.nid
         WHERE analysis_id = :analysis_id AND gid = :gid";
-      $access = db_query($p_sql, array(':analysis_id' => $analysis_id, ':gid' => $rid))->fetchField();
+      $access = db_query($p_sql, [
+        ':analysis_id' => $analysis_id,
+        ':gid' => $rid,
+      ])->fetchField();
       if ($access == 1) {
         $node_access = 1;
         break;
@@ -38,7 +42,7 @@ function tripal_analysis_check_permission($analysis_id) {
       return FALSE;
     }
 
-  // If 'node_privacy_byrole' module is not enabled, return TRUE;
+    // If 'node_privacy_byrole' module is not enabled, return TRUE;
   }
   else {
     return TRUE;
@@ -47,6 +51,7 @@ function tripal_analysis_check_permission($analysis_id) {
 
 /**
  * Set permissions for features associated with an analysis
+ *
  * @todo Stephen: ensure the $nid param is defined correctly
  *
  * @param $analysis_id
@@ -62,19 +67,19 @@ function tripal_analysis_set_feature_permission($analysis_id, $nid) {
 
   // Get features associated with the analysis
   $sql = "SELECT feature_id FROM {analysisfeature} WHERE analysis_id = :analysis_id";
-  $features = chado_query($sql, array(':analysis_id' => $analysis_id));
+  $features = chado_query($sql, [':analysis_id' => $analysis_id]);
 
   // Convert feature_id into node_id
-  $feature_nids = array();
+  $feature_nids = [];
   $counter = 0;
   $sql = "SELECT nid FROM {chado_feature} WHERE feature_id = :feature_id";
   while ($feature = $features->fetchObject()) {
-    $feature_nids[$counter] = db_query($sql, array(':feature_id' => $feature->feature_id))->fetchField();
-    $counter ++;
+    $feature_nids[$counter] = db_query($sql, [':feature_id' => $feature->feature_id])->fetchField();
+    $counter++;
   }
 
   //Convert analysis_id into node_id
-  $ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = :analysis_id", array(':analysis_id' => $analysis_id)));
+  $ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = :analysis_id", [':analysis_id' => $analysis_id]));
   // Get available roles
   $roles = array_keys(user_roles());
 
@@ -89,20 +94,27 @@ function tripal_analysis_set_feature_permission($analysis_id, $nid) {
       print $percentage . "% ";
     }
 
-    db_query("DELETE FROM {node_privacy_byrole} WHERE nid = :nid AND realm = 'node_privacy_byrole_role'", array(':nid' => $fnid));
+    db_query("DELETE FROM {node_privacy_byrole} WHERE nid = :nid AND realm = 'node_privacy_byrole_role'", [':nid' => $fnid]);
     foreach ($roles AS $rid) {
       // Get permissions of this analysis for this role
       $rsql = "SELECT * FROM {node_privacy_byrole} WHERE gid = :gid AND nid = :nid AND realm = 'node_privacy_byrole_role'";
-      $ana_perm = db_query($rsql, array(':gid' => $rid, ':nid' => $ana_nid))->fetchObject();
+      $ana_perm = db_query($rsql, [
+        ':gid' => $rid,
+        ':nid' => $ana_nid,
+      ])->fetchObject();
       db_query("INSERT INTO {node_privacy_byrole} (nid, gid, realm, grant_view, grant_update, grant_delete)
                 VALUES (:nid, :gid, :realm, :grant_view, :grant_update, :grant_delete)",
-                array(':nid' => $fnid, ':gid' => $rid, ':realm' => 'node_privacy_byrole_role',
-                      ':grant_view' => $ana_perm->grant_view,
-                      ':grant_update' => $ana_perm->grant_update,
-                      ':grant_delete' => $ana_perm->grant_delete));
+        [
+          ':nid' => $fnid,
+          ':gid' => $rid,
+          ':realm' => 'node_privacy_byrole_role',
+          ':grant_view' => $ana_perm->grant_view,
+          ':grant_update' => $ana_perm->grant_update,
+          ':grant_delete' => $ana_perm->grant_delete,
+        ]);
     }
     $node = node_load($fnid);
     node_save($node);
-    $idx_iterations ++;
+    $idx_iterations++;
   }
 }

+ 48 - 48
legacy/tripal_analysis/theme/templates/tripal_analysis_base.tpl.php

@@ -1,112 +1,112 @@
 <?php
 $analysis = $variables['node']->analysis;
-$analysis = chado_expand_var($analysis,'field','analysis.description'); ?>
+$analysis = chado_expand_var($analysis, 'field', 'analysis.description'); ?>
+
+<div class="tripal__analysis-data-block-desc tripal-data-block-desc"></div><?php
 
-<div class="tripal__analysis-data-block-desc tripal-data-block-desc"></div><?php 
-  
 // the $headers array is an array of fields to use as the colum headers. 
 // additional documentation can be found here 
 // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
 // This table for the analysis has a vertical header (down the first column)
 // so we do not provide headers here, but specify them in the $rows array below.
-$headers = array();
+$headers = [];
 
 // the $rows array contains an array of rows where each row is an array
 // of values for each column of the table in that row.  Additional documentation
 // can be found here:
 // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7 
-$rows = array();
+$rows = [];
 
 // Analysis Name row
-$rows[] = array(
-  array(
+$rows[] = [
+  [
     'data' => 'Analysis Name',
     'header' => TRUE,
     'width' => '20%',
-  ),
-  $analysis->name
-);
+  ],
+  $analysis->name,
+];
 
 // Implementation row
 $software = $analysis->program;
-if($analysis->programversion != 'n/a'){
-  $software .=  " (" . $analysis->programversion . ")";
+if ($analysis->programversion != 'n/a') {
+  $software .= " (" . $analysis->programversion . ")";
 }
-if($analysis->algorithm){
+if ($analysis->algorithm) {
   $software .= ". " . $analysis->algorithm;
 }
-$rows[] = array(
-  array(
+$rows[] = [
+  [
     'data' => 'Method',
-    'header' => TRUE
-  ),
-  $software
-);
+    'header' => TRUE,
+  ],
+  $software,
+];
 
 // Source row
 $source = '';
-if($analysis->sourceuri){
+if ($analysis->sourceuri) {
   $source = "<a href=\"$analysis->sourceuri\">$analysis->sourcename</a>";
-} 
+}
 else {
   $source = $analysis->sourcename;
 }
-if($analysis->sourceversion){
+if ($analysis->sourceversion) {
   $source = " (" . $analysis->sourceversion . ")";
 }
-$rows[] = array(
-  array(
+$rows[] = [
+  [
     'data' => 'Source',
-    'header' => TRUE
-  ),
-  $source
-);
+    'header' => TRUE,
+  ],
+  $source,
+];
 
 // Date performed row
-$rows[] = array(
-  array(
+$rows[] = [
+  [
     'data' => 'Date performed',
-    'header' => TRUE
-  ),
-  preg_replace("/^(\d+-\d+-\d+) .*/","$1", $analysis->timeexecuted),
-); 
+    'header' => TRUE,
+  ],
+  preg_replace("/^(\d+-\d+-\d+) .*/", "$1", $analysis->timeexecuted),
+];
 
 // allow site admins to see the analysis ID
 if (user_access('view ids')) {
   // Analysis ID
-  $rows[] = array(
-    array(
+  $rows[] = [
+    [
       'data' => 'Analysis ID',
       'header' => TRUE,
       'class' => 'tripal-site-admin-only-table-row',
-    ),
-    array(
+    ],
+    [
       'data' => $analysis->analysis_id,
       'class' => 'tripal-site-admin-only-table-row',
-    ),
-  );
+    ],
+  ];
 }
 // the $table array contains the headers and rows array as well as other
 // options for controlling the display of the table.  Additional
 // documentation can be found here:
 // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-$table = array(
+$table = [
   'header' => $headers,
   'rows' => $rows,
-  'attributes' => array(
+  'attributes' => [
     'id' => 'tripal_analysis-table-base',
-    'class' => 'tripal-data-table'
-  ),
+    'class' => 'tripal-data-table',
+  ],
   'sticky' => FALSE,
   'caption' => '',
-  'colgroups' => array(),
+  'colgroups' => [],
   'empty' => '',
-);
+];
 
 // once we have our table array structure defined, we call Drupal's theme_table()
 // function to generate the table.
-print theme_table($table); 
+print theme_table($table);
 if (property_exists($analysis, 'description')) { ?>
-  <div style="text-align: justify"><?php print $analysis->description; ?></div> <?php  
+    <div style="text-align: justify"><?php print $analysis->description; ?></div> <?php
 } ?>
 

+ 45 - 24
legacy/tripal_analysis/theme/templates/tripal_analysis_help.tpl.php

@@ -1,38 +1,59 @@
 <h3>Module Description:</h3>
-<p>The Tripal Analysis module provides a new analysis content type that is intended to be
-  used when a more specialized analysis module does not exist.  Because it is generic, it does not
-  provide any visualization or data loading tools for analysis data.  Specialized analysis modules,
-  such as the Tripal Analysis Blast or Tripal Analysis KEGG modules provide loading and custom
-  visualizations for the analysis results.  These modules must be installed separately.
+<p>The Tripal Analysis module provides a new analysis content type that is
+    intended to be
+    used when a more specialized analysis module does not exist. Because it is
+    generic, it does not
+    provide any visualization or data loading tools for analysis data.
+    Specialized analysis modules,
+    such as the Tripal Analysis Blast or Tripal Analysis KEGG modules provide
+    loading and custom
+    visualizations for the analysis results. These modules must be installed
+    separately.
 </p>
 
 <h3>Setup Instructions:</h3>
-<p>After installation of the analysis module or any specialized analysis module.  The following tasks should be performed</p>
+<p>After installation of the analysis module or any specialized analysis module.
+    The following tasks should be performed</p>
 <ol>
-  <li><p><b>Set Permissions</b>: By default only the site administrator account has access to create, edit, delete
-   or administer analyses. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
-   permissions under the 'tripal_analysis' section as appropriate for your site. For a simple setup, allow anonymous
-   users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
+    <li><p><b>Set Permissions</b>: By default only the site administrator
+            account has access to create, edit, delete
+            or administer analyses. Navigate to
+            the <?php print l('permissions page', 'admin/user/permissions') ?>
+            and set the
+            permissions under the 'tripal_analysis' section as appropriate for
+            your site. For a simple setup, allow anonymous
+            users access to view content and create a special role for creating,
+            editing and other administrative tasks.</p></li>
 
 
-  <li><p><b>Create an Analysis</b>:  An analysis should be <?php print l('created', 'node/add/chado-analysis')?> before
-  data is imported into chado.  The generic analysis type should only be used when a more specialized analysis module
-  (e.g. Tripal Analysis Blast module) does not already exists.  All data imported into Chado should be associated with
-  an analysis to help keep track of the source for data.</p></li>
+    <li><p><b>Create an Analysis</b>: An analysis should
+            be <?php print l('created', 'node/add/chado-analysis') ?> before
+            data is imported into chado. The generic analysis type should only
+            be used when a more specialized analysis module
+            (e.g. Tripal Analysis Blast module) does not already exists. All
+            data imported into Chado should be associated with
+            an analysis to help keep track of the source for data.</p></li>
 
-  <li><p><b>Sync Analyses</b>:  If you have analyses already stored in Chado and would like to create pages for them, then
-  analyses can be synced using the
-   <?php print l('analysis configuration page', 'admin/tripal/tripal_analysis/configuration') ?>. The process of 'syncing'
-   automatically creates the pages as if you had created them using the step above.
-  </p></li>
+    <li><p><b>Sync Analyses</b>: If you have analyses already stored in Chado
+            and would like to create pages for them, then
+            analyses can be synced using the
+        <?php print l('analysis configuration page', 'admin/tripal/tripal_analysis/configuration') ?>
+            . The process of 'syncing'
+            automatically creates the pages as if you had created them using the
+            step above.
+        </p></li>
 </ol>
 
 
 <h3>Additional Features of this Module:</h3>
-  <ul>
-    <li><p><b>Simple Search Tool</b>: A <?php print l('simple search tool','chado/analyses') ?> is provided for
-    finding analyses. This tool relies on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a>
-    which must be installed to see the search tool.  Look for it in the navigation menu under the item
-    "Search Data". </p></li>
+<ul>
+    <li><p><b>Simple Search Tool</b>:
+            A <?php print l('simple search tool', 'chado/analyses') ?> is
+            provided for
+            finding analyses. This tool relies on Drupal Views. <a
+                    href="http://drupal.org/project/views">Drupal Views</a>
+            which must be installed to see the search tool. Look for it in the
+            navigation menu under the item
+            "Search Data". </p></li>
 </ul>
 

+ 19 - 17
legacy/tripal_analysis/theme/templates/tripal_analysis_properties.tpl.php

@@ -2,45 +2,47 @@
 
 // get the analysis object and expand it to include the records from the analysisprop table
 $analysis = $variables['node']->analysis;
-$analysis = chado_expand_var($analysis,'table', 'analysisprop', array('return_array' => 1));
+$analysis = chado_expand_var($analysis, 'table', 'analysisprop', ['return_array' => 1]);
 $properties = $analysis->analysisprop;
 
 if (count($properties) > 0) { ?>
-  <div class="tripal_analysis-data-block-desc tripal-data-block-desc">Additional information about this analysis:</div><?php
-  
+    <div class="tripal_analysis-data-block-desc tripal-data-block-desc">
+        Additional information about this analysis:
+    </div><?php
+
   // the $headers array is an array of fields to use as the colum headers.
   // additional documentation can be found here
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $headers = array('Property Name', 'Value');
-  
+  $headers = ['Property Name', 'Value'];
+
   // the $rows array contains an array of rows where each row is an array
   // of values for each column of the table in that row.  Additional documentation
   // can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $rows = array();      
+  $rows = [];
   foreach ($properties as $property) {
-    $rows[] = array(
+    $rows[] = [
       ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
-      $property->value
-    );
-  } 
+      $property->value,
+    ];
+  }
   // the $table array contains the headers and rows array as well as other
   // options for controlling the display of the table.  Additional
   // documentation can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $table = array(
+  $table = [
     'header' => $headers,
     'rows' => $rows,
-    'attributes' => array(
+    'attributes' => [
       'id' => 'tripal_analysis-table-properties',
-      'class' => 'tripal-data-table'
-    ),
+      'class' => 'tripal-data-table',
+    ],
     'sticky' => FALSE,
     'caption' => '',
-    'colgroups' => array(),
+    'colgroups' => [],
     'empty' => '',
-  );
-  
+  ];
+
   // once we have our table array structure defined, we call Drupal's theme_table()
   // function to generate the table.
   print theme_table($table);

+ 11 - 11
legacy/tripal_analysis/theme/templates/tripal_analysis_teaser.tpl.php

@@ -1,16 +1,16 @@
 <?php
 $node = $variables['node'];
 $analysis = $variables['node']->analysis;
-$analysis = chado_expand_var($analysis,'field','analysis.description'); ?>
+$analysis = chado_expand_var($analysis, 'field', 'analysis.description'); ?>
 
-<div class="tripal_analysis_blast-teaser tripal-teaser"> 
-  <div class="tripal-analysis-blast-teaser-title tripal-teaser-title"><?php 
-    print l($node->title, "node/$node->nid", array('html' => TRUE));?>
-  </div>
-  <div class="tripal-analysis-blast-teaser-text tripal-teaser-text"><?php 
-    print substr($analysis->description, 0, 650);
-    if (strlen($analysis->description) > 650) {
-      print "... " . l("[more]", "node/$node->nid");
-    } ?>
-  </div>
+<div class="tripal_analysis_blast-teaser tripal-teaser">
+    <div class="tripal-analysis-blast-teaser-title tripal-teaser-title"><?php
+      print l($node->title, "node/$node->nid", ['html' => TRUE]); ?>
+    </div>
+    <div class="tripal-analysis-blast-teaser-text tripal-teaser-text"><?php
+      print substr($analysis->description, 0, 650);
+      if (strlen($analysis->description) > 650) {
+        print "... " . l("[more]", "node/$node->nid");
+      } ?>
+    </div>
 </div>

+ 1 - 1
legacy/tripal_analysis/tripal_analysis.info

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

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

@@ -13,7 +13,7 @@
  * @ingroup tripal_legacy_analysis
  */
 function tripal_analysis_views_default_views() {
-  $views = array();
+  $views = [];
 
   // User View ("Search Biological Content")
   // Remember, if you change the name/path of this view,
@@ -104,57 +104,57 @@ function tripal_analysis_defaultvalue_admin_analysis() {
   $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(
+  $handler->display->display_options['style_options']['columns'] = [
     'name' => 'name',
     'program' => 'program',
     'sourcename' => 'sourcename',
     'num_features' => 'num_features',
     'timeexecuted' => 'timeexecuted',
-  );
+  ];
   $handler->display->display_options['style_options']['default'] = 'name';
-  $handler->display->display_options['style_options']['info'] = array(
-    'name' => array(
+  $handler->display->display_options['style_options']['info'] = [
+    'name' => [
       'sortable' => 1,
       'separator' => '',
-    ),
-    'program' => array(
+    ],
+    'program' => [
       'sortable' => 1,
       'separator' => '',
-    ),
-    'sourcename' => array(
+    ],
+    'sourcename' => [
       'sortable' => 1,
       'separator' => '',
-    ),
-    'num_features' => array(
+    ],
+    'num_features' => [
       'separator' => '',
-    ),
-    'timeexecuted' => array(
+    ],
+    'timeexecuted' => [
       'sortable' => 1,
       'separator' => '',
-    ),
-  );
+    ],
+  ];
   /* Header: Global: Action Links */
   $handler->display->display_options['header']['action_links_area']['id'] = 'action_links_area';
   $handler->display->display_options['header']['action_links_area']['table'] = 'views';
   $handler->display->display_options['header']['action_links_area']['field'] = 'action_links_area';
   $handler->display->display_options['header']['action_links_area']['label'] = 'Action Links';
   $handler->display->display_options['header']['action_links_area']['empty'] = TRUE;
-  $handler->display->display_options['header']['action_links_area']['link-1'] = array(
+  $handler->display->display_options['header']['action_links_area']['link-1'] = [
     'label-1' => 'Add Analysis',
     'path-1' => 'node/add/tripal-analysis',
-  );
-  $handler->display->display_options['header']['action_links_area']['link-2'] = array(
+  ];
+  $handler->display->display_options['header']['action_links_area']['link-2'] = [
     'label-2' => '',
     'path-2' => '',
-  );
-  $handler->display->display_options['header']['action_links_area']['link-3'] = array(
+  ];
+  $handler->display->display_options['header']['action_links_area']['link-3'] = [
     'label-3' => '',
     'path-3' => '',
-  );
-  $handler->display->display_options['header']['action_links_area']['link-4'] = array(
+  ];
+  $handler->display->display_options['header']['action_links_area']['link-4'] = [
     'label-4' => '',
     'path-4' => '',
-  );
+  ];
   /* No results behavior: Global: Text area */
   $handler->display->display_options['empty']['text']['id'] = 'text';
   $handler->display->display_options['empty']['text']['table'] = 'views';
@@ -244,11 +244,11 @@ function tripal_analysis_defaultvalue_admin_analysis() {
   $handler->display->display_options['filters']['program']['expose']['label'] = 'Program Name Contains';
   $handler->display->display_options['filters']['program']['expose']['operator'] = 'program_op';
   $handler->display->display_options['filters']['program']['expose']['identifier'] = 'program';
-  $handler->display->display_options['filters']['program']['expose']['remember_roles'] = array(
+  $handler->display->display_options['filters']['program']['expose']['remember_roles'] = [
     2 => '2',
     1 => 0,
     3 => 0,
-  );
+  ];
   /* Filter criterion: Chado Analysis: Sourcename */
   $handler->display->display_options['filters']['sourcename']['id'] = 'sourcename';
   $handler->display->display_options['filters']['sourcename']['table'] = 'analysis';

+ 62 - 61
legacy/tripal_contact/api/tripal_contact.DEPRECATED.inc

@@ -1,13 +1,14 @@
 <?php
 /**
  * @file
- * Wrapper functions to provide backwards compatibility for the tripal contact api
+ * Wrapper functions to provide backwards compatibility for the tripal contact
+ *   api
  */
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_get_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_get_property().
  *
  * @see chado_get_property().
  */
@@ -17,28 +18,28 @@ function tripal_contact_get_property($contact_id, $property) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_contact_get_property',
-      '%new_function' => 'chado_get_property'
-    )
+    [
+      '%old_function' => 'tripal_contact_get_property',
+      '%new_function' => 'chado_get_property',
+    ]
   );
-  
-  $record = array(
+
+  $record = [
     'table' => 'contact',
-    'id' => $contact_id
-  );
-  $property = array(
+    'id' => $contact_id,
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => 'contact_property',
-  );
+  ];
 
   return chado_get_property($record, $property);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_insert_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_insert_property().
  *
  * @see chado_insert_property().
  */
@@ -48,31 +49,31 @@ function tripal_contact_insert_property($contact_id, $property, $value, $update_
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_contact_insert_property',
-      '%new_function' => 'chado_insert_property'
-    )
+    [
+      '%old_function' => 'tripal_contact_insert_property',
+      '%new_function' => 'chado_insert_property',
+    ]
   );
 
-  $record = array(
+  $record = [
     'table' => 'contact',
-    'id' => $contact_id
-  );
-  $property = array(
+    'id' => $contact_id,
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => 'contact_property',
     'value' => $value,
-  );
-  $options = array(
-    'update_if_present' => $update_if_present
-  );
+  ];
+  $options = [
+    'update_if_present' => $update_if_present,
+  ];
   return chado_insert_property($record, $property, $options);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_update_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_update_property().
  *
  * @see chado_update_property().
  */
@@ -82,30 +83,30 @@ function tripal_contact_update_property($contact_id, $property, $value, $insert_
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_contact_update_property',
-      '%new_function' => 'chado_update_property'
-    )
+    [
+      '%old_function' => 'tripal_contact_update_property',
+      '%new_function' => 'chado_update_property',
+    ]
   );
-  $record = array(
+  $record = [
     'table' => 'contact',
-    'id' => $contact_id
-  );
-  $property = array(
+    'id' => $contact_id,
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => 'contact_property',
     'value' => $value,
-  );
-  $options = array(
-    'insert_if_missing' => $insert_if_missing
-  );
+  ];
+  $options = [
+    'insert_if_missing' => $insert_if_missing,
+  ];
   return chado_update_property($record, $property, $options);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_delete_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_delete_property().
  *
  * @see chado_delete_property().
  */
@@ -115,26 +116,26 @@ function tripal_contact_delete_property($contact_id, $property) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_contact_delete_property',
-      '%new_function' => 'chado_delete_property'
-    )
+    [
+      '%old_function' => 'tripal_contact_delete_property',
+      '%new_function' => 'chado_delete_property',
+    ]
   );
-  $record = array(
+  $record = [
     'table' => 'contact',
-    'id' => $contact_id
-  );
-  $property = array(
+    'id' => $contact_id,
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => 'contact_property',
-  );
+  ];
   return chado_delete_property($record, $property);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_insert_contact().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_insert_contact().
  *
  * @see tripal_insert_contact().
  */
@@ -144,16 +145,16 @@ function tripal_contact_add_contact($name, $description, $type, $properties) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_contact_add_contact',
-      '%new_function' => 'tripal_insert_contact'
-    )
+    [
+      '%old_function' => 'tripal_contact_add_contact',
+      '%new_function' => 'tripal_insert_contact',
+    ]
   );
 
-  return tripal_insert_contact(array(
+  return tripal_insert_contact([
     'name' => $name,
     'description' => $description,
     'type_name' => $type,
-    'properties' => $properties
-  ));
+    'properties' => $properties,
+  ]);
 }

+ 24 - 22
legacy/tripal_contact/includes/tripal_contact.admin.inc

@@ -7,8 +7,8 @@
  */
 
 /**
- * Launchpage for contact administration. Makes sure views are enabled and if not provides
- * links to enable them.
+ * Launchpage for contact administration. Makes sure views are enabled and if
+ * not provides links to enable them.
  *
  * @ingroup tripal_legacy_contact
  */
@@ -16,7 +16,7 @@ function tripal_contact_admin_contact_view() {
   $output = '';
 
   // set the breadcrumb
-  $breadcrumb = array();
+  $breadcrumb = [];
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
@@ -25,7 +25,7 @@ function tripal_contact_admin_contact_view() {
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
-  $view = views_embed_view('tripal_contact_admin_contacts','default');
+  $view = views_embed_view('tripal_contact_admin_contacts', 'default');
   if (isset($view)) {
     $output .= $view;
   }
@@ -35,7 +35,7 @@ function tripal_contact_admin_contact_view() {
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'enable the pertinent views</strong>:</p>';
     $output .= '<ul>';
-      $output .= '<li>'.l('Contacts View', 'admin/tripal/legacy/tripal_contact/views/contacts/enable').'</li>';
+    $output .= '<li>' . l('Contacts View', 'admin/tripal/legacy/tripal_contact/views/contacts/enable') . '</li>';
     $output .= '</ul>';
   }
 
@@ -48,36 +48,38 @@ function tripal_contact_admin_contact_view() {
  * @ingroup tripal_legacy_contact
  */
 function tripal_contact_admin() {
-  $form = array();
+  $form = [];
 
   // If your module is using the Chado Node: Title & Path API to allow custom titles
   // for your node type then you need to add the configuration form for this functionality.
-  $details = array(
-    'module' => 'tripal_contact',       // the name of the MODULE implementing the content type
-    'content_type' => 'chado_contact',   // the name of the content type
-      // An array of options to use under "Page Titles"
-      // the key should be the token and the value should be the human-readable option
-    'options' => array(
+  $details = [
+    'module' => 'tripal_contact',
+    // the name of the MODULE implementing the content type
+    'content_type' => 'chado_contact',
+    // the name of the content type
+    // An array of options to use under "Page Titles"
+    // the key should be the token and the value should be the human-readable option
+    'options' => [
       '[contact.name]' => 'Contact Name Only',
-        // there should always be one options matching the unique constraint.
-      '[contact.name]' => 'Unique Contraint: The name of the contact'
-    ),
+      // there should always be one options matching the unique constraint.
+      '[contact.name]' => 'Unique Contraint: The name of the contact',
+    ],
     // the token indicating the unique constraint in the options array
-    'unique_option' => '[contact.name]'
-  );
+    'unique_option' => '[contact.name]',
+  ];
   // This call adds the configuration form to your current form
   // This sub-form handles it's own validation & submit
   chado_add_admin_form_set_title($form, $form_state, $details);
 
   // URL ALIAS
-  $details = array(
+  $details = [
     'module' => 'tripal_contact',
     'content_type' => 'chado_contact',
-    'options' => array(
+    'options' => [
       '/contact/[contact.contact_id]' => 'Contact ID',
-      '/contact/[contact.name]' => 'Unique Contraint: The name of the contact'
-    ),
-  );
+      '/contact/[contact.name]' => 'Unique Contraint: The name of the contact',
+    ],
+  ];
 
   // This call adds the configuration form to your current form
   // This sub-form handles it's own validation & submit

+ 174 - 158
legacy/tripal_contact/includes/tripal_contact.chado_node.inc

@@ -8,52 +8,53 @@
 
 /**
  * Implementation of hook_node_info().
- * This node_info, is a simple node that describes the functionallity of the module.
+ * This node_info, is a simple node that describes the functionallity of the
+ * module.
  *
  * @ingroup tripal_legacy_contact
  */
 function tripal_contact_node_info() {
 
-  return array(
-    'chado_contact' => array(
-      'name'        => t('Contact (Tripal v2 legacy)'),
-      'base'        => 'chado_contact',
+  return [
+    'chado_contact' => [
+      'name' => t('Contact (Tripal v2 legacy)'),
+      'base' => 'chado_contact',
       'description' => t('A contact from the Chado database'),
-      'has_title'   => TRUE,
-      'locked'      => TRUE,
-      'chado_node_api' => array(
+      'has_title' => TRUE,
+      'locked' => TRUE,
+      'chado_node_api' => [
         'base_table' => 'contact',
         'hook_prefix' => 'chado_contact',
-        'record_type_title' => array(
+        'record_type_title' => [
           'singular' => t('Contact'),
-          'plural' => t('Contacts')
-        ),
-        'sync_filters' => array(
+          'plural' => t('Contacts'),
+        ],
+        'sync_filters' => [
           'type_id' => FALSE,
-          'organism_id' => FALSE
-        ),
-      )
-    ),
-  );
+          'organism_id' => FALSE,
+        ],
+      ],
+    ],
+  ];
 }
 
 /**
  * Implementation of hook_form().
  *
- *  @parm $node
+ * @parm $node
  *    The node that is created when the database is initialized
  *
- *  @parm $form_state
- *    The state of the form, that has the user entered information that is neccessary for, setting
- *    up the database tables for the contact
+ * @parm $form_state
+ *    The state of the form, that has the user entered information that is
+ *   neccessary for, setting up the database tables for the contact
  *
- *  @return $form
+ * @return $form
  *    The information that was enterd allong with
  *
  * @ingroup tripal_legacy_contact
  */
 function chado_contact_form(&$node, $form_state) {
-  $form = array();
+  $form = [];
   // Default values can come in the following ways:
   //
   // 1) as elements of the $node object.  This occurs when editing an existing contact
@@ -63,9 +64,9 @@ function chado_contact_form(&$node, $form_state) {
   //    form elements and the form is being rebuilt
   //
   // set form field defaults
-  $contact_id  = null;
-  $type_id     = 0;
-  $contactname       = '';
+  $contact_id = NULL;
+  $type_id = 0;
+  $contactname = '';
   $description = '';
 
   // if we are editing an existing node then the contact is already part of the node
@@ -74,8 +75,8 @@ function chado_contact_form(&$node, $form_state) {
     $contact_id = $contact->contact_id;
 
     // get form defaults
-    $type_id     = $contact->type_id->cvterm_id;
-    $contactname       = $contact->name;
+    $type_id = $contact->type_id->cvterm_id;
+    $contactname = $contact->name;
 
     // get the contact default values.  When this module was first created
     // the contact description was incorrectly stored in the $node->body field.
@@ -96,30 +97,30 @@ function chado_contact_form(&$node, $form_state) {
     }
     if (!$description) {
       $contactprop = chado_get_property(
-        array('table' => 'contact', 'id' => $contact->contact_id),
-        array('type_name' => 'contact_description', 'cv_name' => 'tripal_contact')
+        ['table' => 'contact', 'id' => $contact->contact_id],
+        ['type_name' => 'contact_description', 'cv_name' => 'tripal_contact']
       );
       $description = (isset($contactprop->value)) ? $contactprop->value : '';
     }
 
     // set the contact_id in the form
-    $form['contact_id'] = array(
+    $form['contact_id'] = [
       '#type' => 'value',
       '#value' => $contact->contact_id,
-    );
+    ];
   }
   // if we are re constructing the form from a failed validation or ajax callback
   // then use the $form_state['values'] values
   if (array_key_exists('values', $form_state)) {
-    $type_id     = $form_state['values']['type_id'];
-    $contactname       = $form_state['values']['contactname'];
+    $type_id = $form_state['values']['type_id'];
+    $contactname = $form_state['values']['contactname'];
     $description = $form_state['values']['description'];
   }
   // if we are re building the form from after submission (from ajax call) then
   // the values are in the $form_state['input'] array
   if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
-    $type_id     = $form_state['input']['type_id'];
-    $contactname       = $form_state['input']['contactname'];
+    $type_id = $form_state['input']['type_id'];
+    $contactname = $form_state['input']['contactname'];
     $description = $form_state['input']['description'];
   }
 
@@ -153,41 +154,41 @@ function chado_contact_form(&$node, $form_state) {
   else {
     $contact_types = tripal_get_cvterm_default_select_options('contact', 'type_id', 'contact types');
   }
-  $form['type_id'] = array(
+  $form['type_id'] = [
     '#type' => 'select',
     '#title' => t('Contact Type'),
     '#options' => $contact_types,
     '#required' => TRUE,
     '#default_value' => $type_id,
-  );
+  ];
 
-  $form['contactname']= array(
-    '#type'          => 'textfield',
-    '#title'         => t('Contact Name'),
-    '#description'   => t('Enter the name of this contact'),
-    '#required'      => TRUE,
+  $form['contactname'] = [
+    '#type' => 'textfield',
+    '#title' => t('Contact Name'),
+    '#description' => t('Enter the name of this contact'),
+    '#required' => TRUE,
     '#default_value' => $contactname,
-    '#maxlength'     => 255,
-  );
-
-  $form['description']= array(
-    '#type'          => 'text_format',
-    '#title'         => t('Contact Description'),
-    '#description'   => t('A brief description of the contact'),
-    '#required'      => TRUE,
+    '#maxlength' => 255,
+  ];
+
+  $form['description'] = [
+    '#type' => 'text_format',
+    '#title' => t('Contact Description'),
+    '#description' => t('A brief description of the contact'),
+    '#required' => TRUE,
     '#default_value' => $description,
-  );
+  ];
 
   // Properties Form
   // ----------------------------------
   $prop_cv = tripal_get_default_cv('contactprop', 'type_id');
   $cv_id = $prop_cv ? $prop_cv->cv_id : NULL;
-  $select_options = array();
+  $select_options = [];
 
   // the Tripal contact vocabulary is heirarchical so if that vocab is default we
   // want to use the subset of terms not under the type 'Contact Type' for our
   // properties list.
-  if($prop_cv->name == 'tripal_contact') {
+  if ($prop_cv->name == 'tripal_contact') {
     // Need to pass in our own select_options since we use cvtermpath to filter ours
     $select_options[] = 'Select a Property';
     $sql = "
@@ -211,27 +212,34 @@ function chado_contact_form(&$node, $form_state) {
     }
   }
 
-  $details = array(
+  $details = [
     'property_table' => 'contactprop',
     'chado_id' => $contact_id,
     'cv_id' => $cv_id,
     'select_options' => $select_options,
-  );
+  ];
   chado_add_node_form_properties($form, $form_state, $details);
 
   // RELATIONSHIPS FORM
   //---------------------------------------------
   $relationship_cv = tripal_get_default_cv('contact_relationship', 'type_id');
   $cv_id = $relationship_cv ? $relationship_cv->cv_id : NULL;
-  $details = array(
-    'relationship_table' => 'contact_relationship', // the name of the _relationship table
-    'base_table' => 'contact',                      // the name of your chado base table
-    'base_foreign_key' => 'contact_id',             // the name of the key in your base chado table
-    'base_key_value' => $contact_id,                // the value of example_id for this record
-    'nodetype' => 'contact',                        // the human-readable name of your node type
-    'cv_id' => $cv_id,                              // the cv.cv_id of the cv governing contact_relationship.type_id
-    'base_name_field' => 'name',                    // the base table field you want to be used as the name
-  );
+  $details = [
+    'relationship_table' => 'contact_relationship',
+    // the name of the _relationship table
+    'base_table' => 'contact',
+    // the name of your chado base table
+    'base_foreign_key' => 'contact_id',
+    // the name of the key in your base chado table
+    'base_key_value' => $contact_id,
+    // the value of example_id for this record
+    'nodetype' => 'contact',
+    // the human-readable name of your node type
+    'cv_id' => $cv_id,
+    // the cv.cv_id of the cv governing contact_relationship.type_id
+    'base_name_field' => 'name',
+    // the base table field you want to be used as the name
+  ];
   // Adds the form elements to your current form
   chado_add_node_form_relationships($form, $form_state, $details);
 
@@ -250,7 +258,7 @@ function chado_contact_validate($node, $form, &$form_state) {
   // Since this validate can be called on AJAX and Deletion of the node
   // we need to make this check to ensure queries are not executed
   // without the proper values.
-  if(property_exists($node, "op") and $node->op != 'Save') {
+  if (property_exists($node, "op") and $node->op != 'Save') {
     return;
   }
 
@@ -266,14 +274,14 @@ function chado_contact_validate($node, $form, &$form_state) {
   // Validating for an update
   if (!is_null($node->nid)) {
     // get the existing node
-    $values = array('contact_id' => $node->contact_id);
-    $result = chado_select_record('contact', array('*'), $values);
+    $values = ['contact_id' => $node->contact_id];
+    $result = chado_select_record('contact', ['*'], $values);
     $contact = $result[0];
 
     // if the name has changed make sure it doesn't conflict with an existing name
     if ($contact->name != $node->contactname) {
-      $values = array('name' => $node->contactname);
-      $result = chado_select_record('contact', array('contact_id'), $values);
+      $values = ['name' => $node->contactname];
+      $result = chado_select_record('contact', ['contact_id'], $values);
       if ($result and count($result) > 0) {
         form_set_error('contactname', 'Cannot update the contact with this contact name. A contact with this name already exists.');
         return;
@@ -283,10 +291,10 @@ function chado_contact_validate($node, $form, &$form_state) {
   // Validating for an insert
   else {
     // The unique constraint for the chado contact table is: name
-    $values = array(
+    $values = [
       'name' => $node->contactname,
-    );
-    $contact = chado_select_record('contact', array('contact_id'), $values);
+    ];
+    $contact = chado_select_record('contact', ['contact_id'], $values);
     if ($contact and count($contact) > 0) {
       form_set_error('contactname', 'Cannot add the contact with this name. A contact with these values already exists.');
       return;
@@ -299,32 +307,33 @@ function chado_contact_validate($node, $form, &$form_state) {
  *
  * This hook allows node modules to limit access to the node types they define.
  *
- *  @param $node
- *  The node on which the operation is to be performed, or, if it does not yet exist, the
- *  type of node to be created
+ * @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet
+ *   exist, the type of node to be created
  *
- *  @param $op
+ * @param $op
  *  The operation to be performed
  *
- *  @param $account
- *  A user object representing the user for whom the operation is to be performed
+ * @param $account
+ *  A user object representing the user for whom the operation is to be
+ *   performed
  *
- *  @return
- *  If the permission for the specified operation is not set then return FALSE. If the
- *  permission is set then return NULL as this allows other modules to disable
- *  access.  The only exception is when the $op == 'create'.  We will always
- *  return TRUE if the permission is set.
+ * @return
+ *  If the permission for the specified operation is not set then return FALSE.
+ *   If the permission is set then return NULL as this allows other modules to
+ *   disable access.  The only exception is when the $op == 'create'.  We will
+ *   always return TRUE if the permission is set.
  *
  * @ingroup tripal_legacy_contact
  */
-function tripal_contact_node_access($node, $op, $account ) {
+function tripal_contact_node_access($node, $op, $account) {
 
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;
   }
 
-  if($node_type == 'chado_contact') {
+  if ($node_type == 'chado_contact') {
     if ($op == 'create') {
       if (!user_access('create chado_contact content', $account)) {
         return NODE_ACCESS_DENY;
@@ -352,14 +361,15 @@ function tripal_contact_node_access($node, $op, $account ) {
 }
 
 
-
 /**
  * Implements of hook_insert().
  *
- * This function inserts user entered information pertaining to the contact instance into the
- * 'contactauthor', 'contactprop', 'chado_contact', 'contact' talble of the database.
+ * This function inserts user entered information pertaining to the contact
+ * instance into the
+ * 'contactauthor', 'contactprop', 'chado_contact', 'contact' talble of the
+ * database.
  *
- *  @parm $node
+ * @parm $node
  *    Then node which contains the information stored within the node-ID
  *
  * @ingroup tripal_legacy_contact
@@ -377,43 +387,45 @@ function chado_contact_insert($node) {
 
 
     // insert and then get the newly inserted contact record
-    $values = array(
-      'name'           => $node->contactname,
-      'description'    => '',
-      'type_id'        => $node->type_id,
-    );
+    $values = [
+      'name' => $node->contactname,
+      'description' => '',
+      'type_id' => $node->type_id,
+    ];
     $contact = chado_insert_record('contact', $values);
     if (!$contact) {
       drupal_set_message(t('Unable to add contact.', 'warning'));
       tripal_report_error('tripal_contact', TRIPAL_ERROR,
         'Insert contact: Unable to create contact where values: %values',
-        array('%values' => print_r($values, TRUE)));
+        ['%values' => print_r($values, TRUE)]);
       return;
     }
     $contact_id = $contact['contact_id'];
 
-      // Add the description property
+    // Add the description property
     $properties = chado_retrieve_node_form_properties($node);
-    $contact_descrip_id = tripal_get_cvterm(array(
+    $contact_descrip_id = tripal_get_cvterm([
       'name' => 'contact_description',
-      'cv_id' => array('name' =>  'tripal_contact')
-    ));
+      'cv_id' => ['name' => 'tripal_contact'],
+    ]);
     $properties[$contact_descrip_id->cvterm_id][0] = $node->description;
 
     // * Properties Form *
-    $details = array(
+    $details = [
       'property_table' => 'contactprop',
       'base_table' => 'contact',
       'foreignkey_name' => 'contact_id',
-      'foreignkey_value' => $contact_id
-    );
+      'foreignkey_value' => $contact_id,
+    ];
     chado_update_node_form_properties($node, $details, $properties);
 
     // * Relationships Form *
-    $details = array(
-      'relationship_table' => 'contact_relationship',  // name of the _relationship table
-      'foreignkey_value' => $contact_id                // value of the contact_id key
-    );
+    $details = [
+      'relationship_table' => 'contact_relationship',
+      // name of the _relationship table
+      'foreignkey_value' => $contact_id
+      // value of the contact_id key
+    ];
     chado_update_node_form_relationships($node, $details);
   }
   else {
@@ -452,48 +464,50 @@ function chado_contact_update($node) {
   $node->contactname = trim($node->contactname);
   $node->description = trim($node->description['value']);
 
-  $contact_id = chado_get_id_from_nid('contact', $node->nid) ;
+  $contact_id = chado_get_id_from_nid('contact', $node->nid);
 
   // update the contact record
-  $match = array(
+  $match = [
     'contact_id' => $contact_id,
-  );
-  $values = array(
+  ];
+  $values = [
     'name' => $node->contactname,
     'description' => '',
-    'type_id' => $node->type_id
-  );
+    'type_id' => $node->type_id,
+  ];
   $status = chado_update_record('contact', $match, $values);
   if (!$status) {
     drupal_set_message("Error updating contact", "error");
     tripal_report_error('tripal_contact', TRIPAL_ERROR,
-      "Error updating contact", array());
+      "Error updating contact", []);
     return;
   }
 
   // Add the description property
   $properties = chado_retrieve_node_form_properties($node);
-  $contact_descrip_id = tripal_get_cvterm(array(
+  $contact_descrip_id = tripal_get_cvterm([
     'name' => 'contact_description',
-    'cv_id' => array('name' => 'tripal_contact')
-  ));
+    'cv_id' => ['name' => 'tripal_contact'],
+  ]);
   $properties[$contact_descrip_id->cvterm_id][0] = $node->description;
 
   // now add in the properties by first removing any the contact
   // already has and adding the ones we have
-  $details = array(
+  $details = [
     'property_table' => 'contactprop',
     'base_table' => 'contact',
     'foreignkey_name' => 'contact_id',
-    'foreignkey_value' => $contact_id
-  );
+    'foreignkey_value' => $contact_id,
+  ];
   chado_update_node_form_properties($node, $details, $properties);
 
   // * Relationships Form *
-  $details = array(
-    'relationship_table' => 'contact_relationship',  // name of the _relationship table
-    'foreignkey_value' => $contact_id                // value of the contact_id key
-  );
+  $details = [
+    'relationship_table' => 'contact_relationship',
+    // name of the _relationship table
+    'foreignkey_value' => $contact_id
+    // value of the contact_id key
+  ];
   chado_update_node_form_relationships($node, $details);
 }
 
@@ -522,22 +536,22 @@ function chado_contact_load($nodes) {
     }
 
     // get the contact
-    $values = array('contact_id' => $contact_id);
+    $values = ['contact_id' => $contact_id];
     $contact = chado_generate_var('contact', $values);
 
     // get the contact description from the contactprop table and replace
     // the contact.description field with this one (we don't use the contact.description
     // field because it is only 255 characters (too small)).
-    $values = array(
+    $values = [
       'contact_id' => $contact->contact_id,
-      'type_id' => array(
+      'type_id' => [
         'name' => 'contact_description',
-      ),
-    );
-    $options = array(
+      ],
+    ];
+    $options = [
       'return_array' => 1,
-      'include_fk' => array('type_id' => 1),
-    );
+      'include_fk' => ['type_id' => 1],
+    ];
     $description = chado_generate_var('contactprop', $values, $options);
     if (count($description) == 1) {
       $description = chado_expand_var($description, 'field', 'contactprop.value');
@@ -554,11 +568,11 @@ function chado_contact_load($nodes) {
 /**
  * Implements hook_delete().
  *
- * This function takes a node and if the delete button has been chosen by the user, the contact
- * and it's details will be removed.Following,given the node-ID, the instance will be deleted from
- * the 'chado_contact' table.
+ * This function takes a node and if the delete button has been chosen by the
+ * user, the contact and it's details will be removed.Following,given the
+ * node-ID, the instance will be deleted from the 'chado_contact' table.
  *
- *  @parm $node
+ * @parm $node
  *    Then node which contains the information stored within the node-ID
  *
  * @ingroup tripal_legacy_contact
@@ -576,15 +590,15 @@ function chado_contact_delete(&$node) {
   // Remove data from {chado_contact}, {node} and {node_revisions} tables of
   // drupal database
   $sql_del = "DELETE FROM {chado_contact} WHERE nid = :nid AND vid = :vid";
-  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
+  db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
   $sql_del = "DELETE FROM {node_revision} WHERE nid = :nid AND vid = :vid";
-  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
+  db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
   $sql_del = "DELETE FROM {node} WHERE nid = :nid AND vid = :vid";
-  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
+  db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
 
   // Remove data from contact and contactprop tables of chado database as well
-  chado_query("DELETE FROM {contactprop} WHERE contact_id = :contact_id", array(':contact_id' => $contact_id));
-  chado_query("DELETE FROM {contact} WHERE contact_id = :contact_id", array(':contact_id' => $contact_id));
+  chado_query("DELETE FROM {contactprop} WHERE contact_id = :contact_id", [':contact_id' => $contact_id]);
+  chado_query("DELETE FROM {contact} WHERE contact_id = :contact_id", [':contact_id' => $contact_id]);
 }
 
 
@@ -598,39 +612,39 @@ function tripal_contact_node_view($node, $view_mode, $langcode) {
     case 'chado_contact':
       // Show feature browser and counts
       if ($view_mode == 'full') {
-        $node->content['tripal_contact_base'] = array(
+        $node->content['tripal_contact_base'] = [
           '#theme' => 'tripal_contact_base',
           '#node' => $node,
-          '#tripal_toc_id'    => 'base',
+          '#tripal_toc_id' => 'base',
           '#tripal_toc_title' => 'Overview',
           '#weight' => -100,
-        );
-        $node->content['tripal_contact_properties'] = array(
+        ];
+        $node->content['tripal_contact_properties'] = [
           '#theme' => 'tripal_contact_properties',
           '#node' => $node,
-          '#tripal_toc_id'    => 'properties',
+          '#tripal_toc_id' => 'properties',
           '#tripal_toc_title' => 'Properties',
-        );
+        ];
         if (module_exists('tripal_pub')) {
-          $node->content['tripal_contact_publications'] = array(
+          $node->content['tripal_contact_publications'] = [
             '#theme' => 'tripal_contact_publications',
             '#node' => $node,
-            '#tripal_toc_id'    => 'publications',
+            '#tripal_toc_id' => 'publications',
             '#tripal_toc_title' => 'Publications',
-          );
+          ];
         }
-        $node->content['tripal_contact_relationships'] = array(
+        $node->content['tripal_contact_relationships'] = [
           '#theme' => 'tripal_contact_relationships',
           '#node' => $node,
-          '#tripal_toc_id'    => 'relationships',
+          '#tripal_toc_id' => 'relationships',
           '#tripal_toc_title' => 'Relationships',
-        );
+        ];
       }
       if ($view_mode == 'teaser') {
-        $node->content['tripal_contact_teaser'] = array(
+        $node->content['tripal_contact_teaser'] = [
           '#theme' => 'tripal_contact_teaser',
           '#node' => $node,
-        );
+        ];
       }
       break;
   }
@@ -650,8 +664,10 @@ function tripal_contact_node_presave($node) {
         // set the title
         $node->title = $node->contactname;
       }
-      else if (property_exists($node, 'contact')) {
-        $node->title = $node->contact->name;
+      else {
+        if (property_exists($node, 'contact')) {
+          $node->title = $node->contact->name;
+        }
       }
       break;
   }
@@ -672,7 +688,7 @@ function tripal_contact_node_insert($node) {
       $contact_id = chado_get_id_from_nid('contact', $node->nid);
 
       // get the contact
-      $values = array('contact_id' => $contact_id);
+      $values = ['contact_id' => $contact_id];
       $contact = chado_generate_var('contact', $values);
       $node->contact = $contact;
 

+ 24 - 24
legacy/tripal_contact/theme/templates/tripal_contact_base.tpl.php

@@ -8,67 +8,67 @@ $contact = $variables['node']->contact; ?>
 // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
 // This table for the contact has a vertical header (down the first column)
 // so we do not provide headers here, but specify them in the $rows array below.
-$headers = array();
+$headers = [];
 
 // the $rows array contains an array of rows where each row is an array
 // of values for each column of the table in that row.  Additional documentation
 // can be found here:
 // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7 
-$rows = array();
+$rows = [];
 
 // Contact Name row
-$rows[] = array(
-  array(
+$rows[] = [
+  [
     'data' => 'Name',
     'header' => TRUE,
     'width' => '20%',
-  ),
+  ],
   $contact->name,
-);
+];
 // Contact Type row
-$rows[] = array(
-  array(
+$rows[] = [
+  [
     'data' => 'Type',
-    'header' => TRUE
-  ),
+    'header' => TRUE,
+  ],
   $contact->type_id->name,
-);
+];
 // allow site admins to see the contact ID
 if (user_access('view ids')) {
   // Pub ID
-  $rows[] = array(
-    array(
+  $rows[] = [
+    [
       'data' => 'Contact ID',
       'header' => TRUE,
       'class' => 'tripal-site-admin-only-table-row',
-    ),
-    array(
+    ],
+    [
       'data' => $contact->contact_id,
       'class' => 'tripal-site-admin-only-table-row',
-    ),
-  );
+    ],
+  ];
 }
 
 // the $table array contains the headers and rows array as well as other
 // options for controlling the display of the table.  Additional
 // documentation can be found here:
 // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-$table = array(
+$table = [
   'header' => $headers,
   'rows' => $rows,
-  'attributes' => array(
+  'attributes' => [
     'id' => 'tripal_contact-table-base',
-    'class' => 'tripal-data-table'
-  ),
+    'class' => 'tripal-data-table',
+  ],
   'sticky' => FALSE,
   'caption' => '',
-  'colgroups' => array(),
+  'colgroups' => [],
   'empty' => '',
-);
+];
 
 // once we have our table array structure defined, we call Drupal's theme_table()
 // function to generate the table.
 print theme_table($table);
 if (property_exists($contact, 'description')) { ?>
-  <div style="text-align: justify"><?php print $contact->description; ?></div> <?php 
+    <div style="text-align: justify"><?php print $contact->description; ?></div> <?php
 } ?>

+ 39 - 19
legacy/tripal_contact/theme/templates/tripal_contact_help.tpl.php

@@ -1,30 +1,50 @@
 <h3>Module Description:</h3>
-<p>The Tripal Contact module is an interface for the Chado Contact module which provides information about
-   people or organizations.  This module provides support for visualization of "contact" pages, editing and updating.
+<p>The Tripal Contact module is an interface for the Chado Contact module which
+    provides information about
+    people or organizations. This module provides support for visualization of
+    "contact" pages, editing and updating.
 </p>
 
 <h3>Setup Instructions:</h3>
 <ol>
-   <li><p><b>Set Permissions</b>: By default only the site administrator account has access to create, edit, delete
-   or administer contacts. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
-   permissions under the 'tripal_contact' section as appropriate for your site. For a simple setup, allow anonymous 
-   users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
- 
- <li><p><b>Create a Contact</b>:  An contact can be <?php print l('created', 'node/add/chado-contact')?> 
- manually in the same way any other data type.  Contacts may also be created automatically by using the 
- publication module publication importers. Alternatively, the Tripal bulk loader may also be used to load contacts.</p></li>
- 
- <li><p><b>Sync any Existing Contacts</b>: Before Contacts can be viewed on the website, they must first be <?php print l('created manually', 'node/add/chado-contact')  ?> 
-          or if they already exist in the Chado database they <?php print l('must be synced', 'admin/tripal/tripal_contact/sync') ?> with Drupal.
-          Once synced, contact pages will appear on the site.</p></li> 
+    <li><p><b>Set Permissions</b>: By default only the site administrator
+            account has access to create, edit, delete
+            or administer contacts. Navigate to
+            the <?php print l('permissions page', 'admin/user/permissions') ?>
+            and set the
+            permissions under the 'tripal_contact' section as appropriate for
+            your site. For a simple setup, allow anonymous
+            users access to view content and create a special role for creating,
+            editing and other administrative tasks.</p></li>
+
+    <li><p><b>Create a Contact</b>: An contact can
+            be <?php print l('created', 'node/add/chado-contact') ?>
+            manually in the same way any other data type. Contacts may also be
+            created automatically by using the
+            publication module publication importers. Alternatively, the Tripal
+            bulk loader may also be used to load contacts.</p></li>
+
+    <li><p><b>Sync any Existing Contacts</b>: Before Contacts can be viewed on
+            the website, they must first
+            be <?php print l('created manually', 'node/add/chado-contact') ?>
+            or if they already exist in the Chado database
+            they <?php print l('must be synced', 'admin/tripal/tripal_contact/sync') ?>
+            with Drupal.
+            Once synced, contact pages will appear on the site.</p></li>
 </ol>
 
 
 <h3>Features of this Module:</h3>
 <ul>
-  <li><p><b>Edit or Delete Contacts</b>: Contacts can be manually edited or deleted by navigating to the map page and clicking the "Edit" button.</p></li>  
-    <li><p><b>Simple Search Tool</b>: A <?php print l('simple search tool','chado/contacts') ?> is provided for 
-    finding contacts. This tool relies on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a>
-    which must be installed to see the search tool.  Look for it in the navigation menu under the item 
-    "Search Data". </p></li>
+    <li><p><b>Edit or Delete Contacts</b>: Contacts can be manually edited or
+            deleted by navigating to the map page and clicking the "Edit"
+            button.</p></li>
+    <li><p><b>Simple Search Tool</b>:
+            A <?php print l('simple search tool', 'chado/contacts') ?> is
+            provided for
+            finding contacts. This tool relies on Drupal Views. <a
+                    href="http://drupal.org/project/views">Drupal Views</a>
+            which must be installed to see the search tool. Look for it in the
+            navigation menu under the item
+            "Search Data". </p></li>
 </ul>

+ 24 - 22
legacy/tripal_contact/theme/templates/tripal_contact_properties.tpl.php

@@ -2,17 +2,17 @@
 
 // expand the contact to include the properties.
 $contact = $variables['node']->contact;
-$contact = chado_expand_var($contact,'table', 'contactprop', array('return_array' => 1));
+$contact = chado_expand_var($contact, 'table', 'contactprop', ['return_array' => 1]);
 $contactprops = $contact->contactprop;
 
 // put the properties in an array so we can remove the contact_description property
-$properties = array();
+$properties = [];
 if ($contactprops) {
   foreach ($contactprops as $property) {
     // we want to keep all properties but the contact_description as that
     // property is shown on the base template page.
-    if($property->type_id->name != 'contact_description') {
-      $property = chado_expand_var($property,'field','contactprop.value');
+    if ($property->type_id->name != 'contact_description') {
+      $property = chado_expand_var($property, 'field', 'contactprop.value');
       $properties[] = $property;
     }
   }
@@ -20,44 +20,46 @@ if ($contactprops) {
 
 
 if (count($properties) > 0) { ?>
-  <div class="tripal_contact-data-block-desc tripal-data-block-desc">Additional information about this contact:</div><?php
+    <div class="tripal_contact-data-block-desc tripal-data-block-desc">
+        Additional information about this contact:
+    </div><?php
   // the $headers array is an array of fields to use as the colum headers.
   // additional documentation can be found here
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $headers = array('Property Name', 'Value');
-  
+  $headers = ['Property Name', 'Value'];
+
   // the $rows array contains an array of rows where each row is an array
   // of values for each column of the table in that row.  Additional documentation
   // can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $rows = array();
-  
+  $rows = [];
+
   // add the properties as individual rows
   foreach ($properties as $property) {
-    $rows[] = array(
+    $rows[] = [
       ucfirst(preg_replace('/_/', ' ', $property->type_id->name)),
-      $property->value
-    );
-  } 
-  
+      $property->value,
+    ];
+  }
+
   // the $table array contains the headers and rows array as well as other
   // options for controlling the display of the table.  Additional
   // documentation can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-  $table = array(
+  $table = [
     'header' => $headers,
     'rows' => $rows,
-    'attributes' => array(
+    'attributes' => [
       'id' => 'tripal_contact-table-properties',
-      'class' => 'tripal-data-table'
-    ),
+      'class' => 'tripal-data-table',
+    ],
     'sticky' => FALSE,
     'caption' => '',
-    'colgroups' => array(),
+    'colgroups' => [],
     'empty' => '',
-  );
-  
+  ];
+
   // once we have our table array structure defined, we call Drupal's theme_table()
   // function to generate the table.
-  print theme_table($table); 
+  print theme_table($table);
 }

+ 40 - 35
legacy/tripal_contact/theme/templates/tripal_contact_publications.tpl.php

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

+ 103 - 97
legacy/tripal_contact/theme/templates/tripal_contact_relationships.tpl.php

@@ -23,106 +23,112 @@ $object_rels = $all_relationships['object'];
 $subject_rels = $all_relationships['subject'];
 
 if (count($object_rels) > 0 or count($subject_rels) > 0) { ?>
-  <div class="tripal_contact-data-block-desc tripal-data-block-desc"></div> <?php
+    <div class="tripal_contact-data-block-desc tripal-data-block-desc"></div> <?php
   // first add in the subject relationships.  
-  foreach ($subject_rels as $rel_type => $rels){
-    foreach ($rels as $obj_type => $objects){ ?>
-      <p>This <?php print strtolower($contact->type_id->name);?>  <b><?php print $rel_type ?></b> with the following <?php print strtolower($obj_type) ?> contact(s): <?php
-       
-      // the $headers array is an array of fields to use as the colum headers.
-      // additional documentation can be found here
-      // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-      $headers = array('Name');
-      
-      // the $rows array contains an array of rows where each row is an array
-      // of values for each column of the table in that row.  Additional documentation
-      // can be found here:
-      // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-      $rows = array();
-      
-      foreach ($objects as $object){
-        // link the contact to it's node
-        $contact_name = $object->record->object_id->name;
-        if (property_exists($object->record, 'nid')) {
-          $contact_name = "<a href=\"" . url("node/" . $object->record->nid) . "\" target=\"_blank\">" . $object->record->object_id->name . "</a>";
-        }
+  foreach ($subject_rels as $rel_type => $rels) {
+    foreach ($rels as $obj_type => $objects) { ?>
+        <p>This <?php print strtolower($contact->type_id->name); ?>
+            <b><?php print $rel_type ?></b> with the
+            following <?php print strtolower($obj_type) ?> contact(s): <?php
 
-        $rows[] = array(
-          $contact_name, 
-        ); 
-       } 
-       // the $table array contains the headers and rows array as well as other
-       // options for controlling the display of the table.  Additional
-       // documentation can be found here:
-       // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-       $table = array(
-         'header' => $headers,
-         'rows' => $rows,
-         'attributes' => array(
-           'id' => 'tripal_contact-table-relationship-object',
-           'class' => 'tripal-data-table'
-         ),
-         'sticky' => FALSE,
-         'caption' => '',
-         'colgroups' => array(),
-         'empty' => '',
-       );
-       
-       // once we have our table array structure defined, we call Drupal's theme_table()
-       // function to generate the table.
-       print theme_table($table); ?>
-       </p>
-       <br><?php
-     }
+          // the $headers array is an array of fields to use as the colum headers.
+          // additional documentation can be found here
+          // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+          $headers = ['Name'];
+
+          // the $rows array contains an array of rows where each row is an array
+          // of values for each column of the table in that row.  Additional documentation
+          // can be found here:
+          // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+          $rows = [];
+
+          foreach ($objects as $object) {
+            // link the contact to it's node
+            $contact_name = $object->record->object_id->name;
+            if (property_exists($object->record, 'nid')) {
+              $contact_name = "<a href=\"" . url("node/" . $object->record->nid) . "\" target=\"_blank\">" . $object->record->object_id->name . "</a>";
+            }
+
+            $rows[] = [
+              $contact_name,
+            ];
+          }
+          // the $table array contains the headers and rows array as well as other
+          // options for controlling the display of the table.  Additional
+          // documentation can be found here:
+          // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+          $table = [
+            'header' => $headers,
+            'rows' => $rows,
+            'attributes' => [
+              'id' => 'tripal_contact-table-relationship-object',
+              'class' => 'tripal-data-table',
+            ],
+            'sticky' => FALSE,
+            'caption' => '',
+            'colgroups' => [],
+            'empty' => '',
+          ];
+
+          // once we have our table array structure defined, we call Drupal's theme_table()
+          // function to generate the table.
+          print theme_table($table); ?>
+        </p>
+        <br><?php
+    }
   }
-  
+
   // second add in the object relationships.  
-  foreach ($object_rels as $rel_type => $rels){
-    foreach ($rels as $subject_type => $subjects){?>
-      <p>The following <b><?php print $subjects[0]->record->subject_id->type_id->name ?></b> contact(s) are <?php print $rel_type ?> this <?php print $contact->type_id->name;?>: <?php 
-      // the $headers array is an array of fields to use as the colum headers.
-      // additional documentation can be found here
-      // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-      $headers = array('Name');
-      
-      // the $rows array contains an array of rows where each row is an array
-      // of values for each column of the table in that row.  Additional documentation
-      // can be found here:
-      // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-      $rows = array();
-      
-      foreach ($subjects as $subject){
-        // link the contact to it's node
-        $contact_name = $subject->record->subject_id->name;
-        if (property_exists($subject->record, 'nid')) {
-          $contact_name = "<a href=\"" . url("node/" . $subject->record->nid) . "\" target=\"_blank\">" . $subject->record->subject_id->name . "</a>";
-        }
-        $rows[] = array(
-          $contact_name, 
-        ); 
-       } 
-       // the $table array contains the headers and rows array as well as other
-       // options for controlling the display of the table.  Additional
-       // documentation can be found here:
-       // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
-       $table = array(
-         'header' => $headers,
-         'rows' => $rows,
-         'attributes' => array(
-           'id' => 'tripal_contact-table-relationship-subject',
-           'class' => 'tripal-data-table'
-         ),
-         'sticky' => FALSE,
-         'caption' => '',
-         'colgroups' => array(),
-         'empty' => '',
-       );
-       
-       // once we have our table array structure defined, we call Drupal's theme_table()
-       // function to generate the table.
-       print theme_table($table); ?>
-       </p>
-       <br><?php
-     }
+  foreach ($object_rels as $rel_type => $rels) {
+    foreach ($rels as $subject_type => $subjects) {
+      ?>
+        <p>The following
+            <b><?php print $subjects[0]->record->subject_id->type_id->name ?></b>
+            contact(s) are <?php print $rel_type ?>
+            this <?php print $contact->type_id->name; ?>: <?php
+          // the $headers array is an array of fields to use as the colum headers.
+          // additional documentation can be found here
+          // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+          $headers = ['Name'];
+
+          // the $rows array contains an array of rows where each row is an array
+          // of values for each column of the table in that row.  Additional documentation
+          // can be found here:
+          // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+          $rows = [];
+
+          foreach ($subjects as $subject) {
+            // link the contact to it's node
+            $contact_name = $subject->record->subject_id->name;
+            if (property_exists($subject->record, 'nid')) {
+              $contact_name = "<a href=\"" . url("node/" . $subject->record->nid) . "\" target=\"_blank\">" . $subject->record->subject_id->name . "</a>";
+            }
+            $rows[] = [
+              $contact_name,
+            ];
+          }
+          // the $table array contains the headers and rows array as well as other
+          // options for controlling the display of the table.  Additional
+          // documentation can be found here:
+          // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+          $table = [
+            'header' => $headers,
+            'rows' => $rows,
+            'attributes' => [
+              'id' => 'tripal_contact-table-relationship-subject',
+              'class' => 'tripal-data-table',
+            ],
+            'sticky' => FALSE,
+            'caption' => '',
+            'colgroups' => [],
+            'empty' => '',
+          ];
+
+          // once we have our table array structure defined, we call Drupal's theme_table()
+          // function to generate the table.
+          print theme_table($table); ?>
+        </p>
+        <br><?php
+    }
   }
 }

+ 15 - 15
legacy/tripal_contact/theme/templates/tripal_contact_teaser.tpl.php

@@ -2,19 +2,19 @@
 $node = $variables['node'];
 $contact = $variables['node']->contact; ?>
 
-<div class="tripal_contact-teaser tripal-teaser"> 
-  <div class="tripal-contact-teaser-title tripal-teaser-title"><?php 
-    print l($node->title, "node/$node->nid", array('html' => TRUE));?>
-  </div>
-  <div class="tripal-contact-teaser-text tripal-teaser-text"><?php 
-    if ($contact->description) {
-      print substr($contact->description, 0, 650);
-      if (strlen($contact->description) > 650) {
-        print "... " . l("[more]", "node/$node->nid");
-      } 
-    } 
-    else {
-      print $node->title; 
-    } ?>
-  </div>
+<div class="tripal_contact-teaser tripal-teaser">
+    <div class="tripal-contact-teaser-title tripal-teaser-title"><?php
+      print l($node->title, "node/$node->nid", ['html' => TRUE]); ?>
+    </div>
+    <div class="tripal-contact-teaser-text tripal-teaser-text"><?php
+      if ($contact->description) {
+        print substr($contact->description, 0, 650);
+        if (strlen($contact->description) > 650) {
+          print "... " . l("[more]", "node/$node->nid");
+        }
+      }
+      else {
+        print $node->title;
+      } ?>
+    </div>
 </div>

+ 23 - 23
legacy/tripal_contact/theme/tripal_contact.theme.inc

@@ -6,22 +6,22 @@
  */
 function tripal_contact_preprocess_tripal_contact_relationships(&$variables) {
   $contact = $variables['node']->contact;
-  
-   // expand the contact object to include the contact relationships.
-  $options = array(
+
+  // expand the contact object to include the contact relationships.
+  $options = [
     'return_array' => 1,
     // we don't want to fully recurse we only need information about the
     // relationship type and the object and subject contacts (including contact type)
-    'include_fk' => array(
+    'include_fk' => [
       'type_id' => 1,
-      'object_id' => array(
+      'object_id' => [
         'type_id' => 1,
-      ),
-      'subject_id'  => array(
+      ],
+      'subject_id' => [
         'type_id' => 1,
-      ),
-    ),
-  );
+      ],
+    ],
+  ];
   $contact = chado_expand_var($contact, 'table', 'contact_relationship', $options);
 
   // get the subject relationships
@@ -29,32 +29,32 @@ function tripal_contact_preprocess_tripal_contact_relationships(&$variables) {
   $orelationships = $contact->contact_relationship->object_id;
 
   // combine both object and subject relationshisp into a single array
-  $relationships = array();
-  $relationships['object'] = array();
-  $relationships['subject'] = array();
+  $relationships = [];
+  $relationships['object'] = [];
+  $relationships['subject'] = [];
 
   // iterate through the object relationships
   if ($orelationships) {
     foreach ($orelationships as $relationship) {
       $rel = new stdClass();
       $rel->record = $relationship;
-       
+
       // get the relationship and child types
       $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
       $child_type = $relationship->subject_id->type_id->name;
-       
+
       // get the node id of the subject
       $sql = "SELECT nid FROM {chado_contact} WHERE contact_id = :contact_id";
-      $n = db_query($sql, array(':contact_id' => $relationship->subject_id->contact_id))->fetchObject();
+      $n = db_query($sql, [':contact_id' => $relationship->subject_id->contact_id])->fetchObject();
       if ($n) {
         $rel->record->nid = $n->nid;
       }
 
       if (!array_key_exists($rel_type, $relationships['object'])) {
-        $relationships['object'][$rel_type] = array();
+        $relationships['object'][$rel_type] = [];
       }
       if (!array_key_exists($child_type, $relationships['object'][$rel_type])) {
-        $relationships['object'][$rel_type][$child_type] = array();
+        $relationships['object'][$rel_type][$child_type] = [];
       }
       $relationships['object'][$rel_type][$child_type][] = $rel;
     }
@@ -67,19 +67,19 @@ function tripal_contact_preprocess_tripal_contact_relationships(&$variables) {
       $rel->record = $relationship;
       $rel_type = t(preg_replace('/_/', " ", $relationship->type_id->name));
       $parent_type = $relationship->object_id->type_id->name;
-       
+
       // get the node id of the subject
       $sql = "SELECT nid FROM {chado_contact} WHERE contact_id = :contact_id";
-      $n = db_query($sql, array(':contact_id' => $relationship->object_id->contact_id))->fetchObject();
+      $n = db_query($sql, [':contact_id' => $relationship->object_id->contact_id])->fetchObject();
       if ($n) {
         $rel->record->nid = $n->nid;
       }
-       
+
       if (!array_key_exists($rel_type, $relationships['subject'])) {
-        $relationships['subject'][$rel_type] = array();
+        $relationships['subject'][$rel_type] = [];
       }
       if (!array_key_exists($parent_type, $relationships['subject'][$rel_type])) {
-        $relationships['subject'][$rel_type][$parent_type] = array();
+        $relationships['subject'][$rel_type][$parent_type] = [];
       }
       $relationships['subject'][$rel_type][$parent_type][] = $rel;
     }

+ 1 - 1
legacy/tripal_contact/tripal_contact.info

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

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

@@ -12,7 +12,7 @@
  * @ingroup tripal_legacy_contact
  */
 function tripal_contact_views_default_views() {
-  $views = array();
+  $views = [];
 
   // User View ("Search Biological Content")
   // Remember, if you change the name/path of this view,
@@ -48,12 +48,12 @@ function tripal_contact_defaultvalue_user_contacts() {
 
   // Change the path
   $view->display['page_1']->display_options['path'] = 'chado/contact';
-  $view->display['page_1']->display_options['menu'] = array(
+  $view->display['page_1']->display_options['menu'] = [
     'type' => 'normal',
     'title' => 'Contacts',
     'description' => 'Contacts can be persons, institutes, groups, or organizations.',
-    'weight' => '-10'
-  );
+    'weight' => '-10',
+  ];
   unset($view->display['page_1']->display_options['tab_options']);
 
   // Change the permission
@@ -107,48 +107,48 @@ function tripal_contact_defaultview_admin_contacts() {
   $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(
+  $handler->display->display_options['style_options']['columns'] = [
     'name' => 'name',
     'name_1' => 'name_1',
     'description' => 'description',
-  );
+  ];
   $handler->display->display_options['style_options']['default'] = 'name';
-  $handler->display->display_options['style_options']['info'] = array(
-    'name' => array(
+  $handler->display->display_options['style_options']['info'] = [
+    'name' => [
       'sortable' => 1,
       'separator' => '',
-    ),
-    'name_1' => array(
+    ],
+    'name_1' => [
       'sortable' => 1,
       'separator' => '',
-    ),
-    'description' => array(
+    ],
+    'description' => [
       '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(
+  $handler->display->display_options['header']['action_links_area']['link-1'] = [
     'label-1' => 'Add Contact',
     'path-1' => 'node/add/tripal-contact',
-  );
-  $handler->display->display_options['header']['action_links_area']['link-2'] = array(
+  ];
+  $handler->display->display_options['header']['action_links_area']['link-2'] = [
     'label-2' => '',
     'path-2' => '',
-  );
-  $handler->display->display_options['header']['action_links_area']['link-3'] = array(
+  ];
+  $handler->display->display_options['header']['action_links_area']['link-3'] = [
     'label-3' => '',
     'path-3' => '',
-  );
-  $handler->display->display_options['header']['action_links_area']['link-4'] = array(
+  ];
+  $handler->display->display_options['header']['action_links_area']['link-4'] = [
     'label-4' => '',
     'path-4' => '',
-  );
+  ];
   /* No results behavior: Global: Text area */
   $handler->display->display_options['empty']['text']['id'] = 'area';
   $handler->display->display_options['empty']['text']['table'] = 'views';
@@ -224,11 +224,11 @@ function tripal_contact_defaultview_admin_contacts() {
   $handler->display->display_options['filters']['type_id']['expose']['label'] = 'Type';
   $handler->display->display_options['filters']['type_id']['expose']['operator'] = 'type_id_op';
   $handler->display->display_options['filters']['type_id']['expose']['identifier'] = 'type_id';
-  $handler->display->display_options['filters']['type_id']['expose']['remember_roles'] = array(
+  $handler->display->display_options['filters']['type_id']['expose']['remember_roles'] = [
     2 => '2',
     1 => 0,
     3 => 0,
-  );
+  ];
   /* Filter criterion: Chado Contact: Name */
   $handler->display->display_options['filters']['name']['id'] = 'name';
   $handler->display->display_options['filters']['name']['table'] = 'contact';
@@ -240,11 +240,11 @@ function tripal_contact_defaultview_admin_contacts() {
   $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(
+  $handler->display->display_options['filters']['name']['expose']['remember_roles'] = [
     2 => '2',
     1 => 0,
     3 => 0,
-  );
+  ];
   /* Filter criterion: Chado Contact: Description */
   $handler->display->display_options['filters']['description']['id'] = 'description';
   $handler->display->display_options['filters']['description']['table'] = 'contact';
@@ -256,11 +256,11 @@ function tripal_contact_defaultview_admin_contacts() {
   $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(
+  $handler->display->display_options['filters']['description']['expose']['remember_roles'] = [
     2 => '2',
     1 => 0,
     3 => 0,
-  );
+  ];
 
   /** MANUALLY ADD since filter handler no exporting correctly */
   $handler->display->display_options['filters']['type_id']['expose']['values_form_type'] = 'select';
@@ -281,10 +281,10 @@ function tripal_contact_defaultview_admin_contacts() {
   $handler->display->display_options['tab_options']['weight'] = '0';
 
   /** MANUALLY ADD since filter handler no exporting correctly
-  $handler->display->display_options['filters']['type_id']['expose']['values_form_type'] = 'select';
-  $handler->display->display_options['filters']['type_id']['expose']['select_multiple'] = FALSE;
-  $handler->display->display_options['filters']['type_id']['expose']['select_optional'] = TRUE;
-  $handler->display->display_options['filters']['type_id']['expose']['max_length'] = 40;
-  */
+   * $handler->display->display_options['filters']['type_id']['expose']['values_form_type'] = 'select';
+   * $handler->display->display_options['filters']['type_id']['expose']['select_multiple'] = FALSE;
+   * $handler->display->display_options['filters']['type_id']['expose']['select_optional'] = TRUE;
+   * $handler->display->display_options['filters']['type_id']['expose']['max_length'] = 40;
+   */
   return $view;
 }

File diff suppressed because it is too large
+ 241 - 232
legacy/tripal_core/api/tripal_core.DEPRECATED.inc


+ 281 - 265
legacy/tripal_core/api/tripal_core.chado_nodes.api.inc

@@ -1,35 +1,39 @@
 <?php
 /**
  * @file
- * API to handle much of the common functionality implemented when creating a drupal node type.
+ * API to handle much of the common functionality implemented when creating a
+ *   drupal node type.
  */
 
 /**
  * @defgroup tripal_legacy_chado_node_api Legacy Chado Nodes
  * @ingroup tripal_legacy_api
  * @{
- * Many Tripal modules implement Drupal node types as a means of displaying chado
- * records individually through Drupal as a single web page. In order to do this, many of
- * the same drupal hooks are implemented and the code between modules is actually quite
- * similar. This API aims to abstract much of the common functionality in order to make
- * it easier for new Tripal modules to implement drupal node types and to centralize the
- * maintenance effort as much as possible.
+ * Many Tripal modules implement Drupal node types as a means of displaying
+ *   chado records individually through Drupal as a single web page. In order
+ *   to do this, many of the same drupal hooks are implemented and the code
+ *   between modules is actually quite similar. This API aims to abstract much
+ *   of the common functionality in order to make it easier for new Tripal
+ *   modules to implement drupal node types and to centralize the maintenance
+ *   effort as much as possible.
  *
  * A generic sync form has been created. See chado_node_sync_form() for
  * instructions on how to implement this form in your module.
  *
- * Many of the base chado tables also have associated prop, _dbxref and _relationship
- * tables. Generic mini-forms have been created to help you handle these forms. To
- * implement this functionality you call the mini-form from your module node form and
- * then call the associated update functions from both your hook_insert and hook_update.
- * The functions of interest are as follows:
+ * Many of the base chado tables also have associated prop, _dbxref and
+ *   _relationship tables. Generic mini-forms have been created to help you
+ *   handle these forms. To implement this functionality you call the mini-form
+ *   from your module node form and then call the associated update functions
+ *   from both your hook_insert and hook_update. The functions of interest are
+ *   as follows:
  *   - chado_add_node_form_properties() and chado_update_node_form_properties()
  *     to provide an interface for adding/removing properties
  *   - chado_add_node_form_dbxrefs() and chado_update_node_form_dbxrefs()
- *     to provide an interface for adding/removing additional database references
- *   - chado_add_node_form_relationships() and chado_update_node_form_relationships()
- *     to provide an interface for adding/removing relationships between chado records
- *     from your base table
+ *     to provide an interface for adding/removing additional database
+ *   references
+ *   - chado_add_node_form_relationships() and
+ *   chado_update_node_form_relationships() to provide an interface for
+ *   adding/removing relationships between chado records from your base table
  * @}
  */
 
@@ -60,7 +64,7 @@ function chado_get_id_from_nid($table, $nid, $linking_table = NULL) {
   }
 
   $sql = "SELECT " . $table . "_id as id FROM {$linking_table} WHERE nid = :nid";
-  return db_query($sql, array(':nid' => $nid))->fetchField();
+  return db_query($sql, [':nid' => $nid])->fetchField();
 }
 
 /**
@@ -82,7 +86,7 @@ function chado_get_id_from_nid($table, $nid, $linking_table = NULL) {
  * @return
  *   The nid of the associated node
  *
- *  @ingroup tripal_legacy_chado_node_api
+ * @ingroup tripal_legacy_chado_node_api
  */
 function chado_get_nid_from_id($table, $id, $linking_table = NULL) {
   if (empty($linking_table)) {
@@ -90,7 +94,7 @@ function chado_get_nid_from_id($table, $id, $linking_table = NULL) {
   }
 
   $sql = "SELECT nid FROM {" . $linking_table . "} WHERE " . $table . "_id = :" . $table . "_id";
-  return db_query($sql, array(":" . $table . "_id" => $id))->fetchField();
+  return db_query($sql, [":" . $table . "_id" => $id])->fetchField();
 }
 
 /**
@@ -106,7 +110,7 @@ function chado_get_nid_from_id($table, $id, $linking_table = NULL) {
  * @return
  *    The name of the chado base table for the specified content type
  *
- *  @ingroup tripal_legacy_chado_node_api
+ * @ingroup tripal_legacy_chado_node_api
  */
 function chado_node_get_base_table($content_type, $module = FALSE) {
 
@@ -141,18 +145,19 @@ function chado_node_get_base_table($content_type, $module = FALSE) {
 /**
  * Validate the Triggering element from a node form.
  *
- * We are going to inspect the post to determine what PHP knows is the triggering
- * element and if it doesn't agree with Drupal then we are actually going to
- * change it in Drupal.
+ * We are going to inspect the post to determine what PHP knows is the
+ * triggering element and if it doesn't agree with Drupal then we are actually
+ * going to change it in Drupal.
  *
  * This fixes an obscure bug triggered when a property is added and then
  * a relationship removed, Drupal thinks the first property remove button was
- * clicked and instead removes a property (not a relationship) and renders the new
- * property table in the relationship table page space.
+ * clicked and instead removes a property (not a relationship) and renders the
+ * new property table in the relationship table page space.
  *
  * NOTE: Many Drupal issues state that this problem is solved if the #name
- * of the button is unique (which it is in our case) but we are still experiencing
- * incorrectly determined triggering elements so we need to handle it ourselves.
+ * of the button is unique (which it is in our case) but we are still
+ * experiencing incorrectly determined triggering elements so we need to handle
+ * it ourselves.
  */
 function chado_validate_node_form_triggering_element($form, &$form_state) {
 
@@ -180,7 +185,7 @@ function chado_add_node_form_subtables_add_button_validate($form, &$form_state)
   if (preg_match('/^([a-z]+).*/', $form_state['triggering_element']['#name'], $matches)) {
     $subsection = $matches[1];
 
-    switch($subsection) {
+    switch ($subsection) {
       case 'properties':
         chado_add_node_form_properties_add_button_validate($form, $form_state);
         break;
@@ -209,7 +214,7 @@ function chado_add_node_form_subtables_add_button_submit($form, &$form_state) {
   if (preg_match('/^([a-z]+).*/', $form_state['triggering_element']['#name'], $matches)) {
     $subsection = $matches[1];
 
-     switch($subsection) {
+    switch ($subsection) {
       case 'properties':
         chado_add_node_form_properties_add_button_submit($form, $form_state);
         break;
@@ -232,9 +237,10 @@ function chado_add_node_form_subtables_add_button_submit($form, &$form_state) {
  * Supported subtables: Properties, Relationships, Additional DBxrefs.
  *
  * Since Removing isn't associated with any user input the only thing we
- * need to validate is that Drupal has determined the triggering element correctly.
- * That said, we will call each subtables associated validate function just incase
- * there is some case-specific validation we do not know of or have not anticipated.
+ * need to validate is that Drupal has determined the triggering element
+ * correctly. That said, we will call each subtables associated validate
+ * function just incase there is some case-specific validation we do not know
+ * of or have not anticipated.
  *
  * @param array $form
  * @param array $form_state
@@ -252,7 +258,7 @@ function chado_add_node_form_subtables_remove_button_validate($form, &$form_stat
   if (preg_match('/^([a-z]+).*/', $form_state['triggering_element']['#name'], $matches)) {
     $subsection = $matches[1];
 
-      switch($subsection) {
+    switch ($subsection) {
       case 'properties':
         chado_add_node_form_properties_remove_button_validate($form, $form_state);
         break;
@@ -281,7 +287,7 @@ function chado_add_node_form_subtables_remove_button_submit($form, &$form_state)
   if (preg_match('/^([a-z]+).*/', $form_state['triggering_element']['#name'], $matches)) {
     $subsection = $matches[1];
 
-    switch($subsection) {
+    switch ($subsection) {
       case 'properties':
         chado_add_node_form_properties_remove_button_submit($form, $form_state);
         break;
@@ -318,7 +324,7 @@ function chado_add_node_form_subtable_ajax_update($form, &$form_state) {
   if (preg_match('/^([a-z]+).*/', $form_state['triggering_element']['#name'], $matches)) {
     $subsection = $matches[1];
 
-    switch($subsection) {
+    switch ($subsection) {
       case 'properties':
         return $form['properties']['property_table'];
         break;
@@ -338,83 +344,87 @@ function chado_add_node_form_subtable_ajax_update($form, &$form_state) {
  */
 
 /**
- * Generic Sync Form to aid in sync'ing (create drupal nodes linking to chado content)
- * any chado node type.
+ * Generic Sync Form to aid in sync'ing (create drupal nodes linking to chado
+ * content) any chado node type.
  *
  * To use this you need to add a call to it from your hook_menu() and
- * add some additional information to your hook_node_info(). The Following code gives an
- * example of how this might be done:
+ * add some additional information to your hook_node_info(). The Following code
+ * gives an example of how this might be done:
+ *
  * @code
-
-  function modulename_menu() {
-
-    //  the machine name of your module
-    $module_name = 'tripal_example';
-
-    // the base specified in hook_node_info
-    $node_type = 'chado_example';
-
-    // This menu item will be a tab on the admin/tripal/legacy/tripal_example page
-    // that is not selected by default
-    $items['admin/tripal/legacy/tripal_example/sync'] = array(
-      'title' => ' Sync',
-      'description' => 'Sync examples from Chado with Drupal',
-      'page callback' => 'drupal_get_form',
-      'page arguments' => array('chado_node_sync_form', $module_name, $node_type),
-      'access arguments' => array('administer tripal examples'),
-      'type' => MENU_LOCAL_TASK,
-      'weight' => 0
-    );
-
-    return $items;
-  }
-
-  function modulename_node_info() {
-    return array(
-      'chado_example' => array(
-        'name' => t('example'),
-        'base' => 'chado_example',
-        'description' => t('A Chado example is a collection of material that can be sampled and have experiments performed on it.'),
-        'has_title' => TRUE,
-        'locked' => TRUE,
-
-        // this is what differs from the regular Drupal-documented hook_node_info()
-        'chado_node_api' => array(
-          'base_table' => 'example',            // The name of the chado base table
-          'hook_prefix' => 'chado_example',     // Usually the name of the node type
-          'linking_table' => 'chado_example',   // Specifies the linking table used
-                                                // to map records to Drupal nodes.
-                                                // if 'linking_table' is not specified
-                                                // it defaults to the node_type name.
-          'record_type_title' => array(
-            'singular' => t('Example'),         // Singular human-readable title
-            'plural' => t('Examples')           // Plural human-readable title
-          ),
-          'sync_filters' => array( // filters for syncing
-            'type_id'     => TRUE,     // TRUE if there is an example.type_id field
-            'organism_id' => TRUE,     // TRUE if there is an example.organism_id field
-            'checkboxes'  => array('name')  // If the 'checkboxes' key is present then the
-                                            // value must be an array of column names in
-                                            // base table. The values from these columns will
-                                            // be retreived, contentated with a space delimeter
-                                            // and provided in a list of checkboxes
-                                            // for the user to choose which to sync.
-          ),
-        )
-      ),
-    );
-  }
+ *
+ * function modulename_menu() {
+ *
+ * //  the machine name of your module
+ * $module_name = 'tripal_example';
+ *
+ * // the base specified in hook_node_info
+ * $node_type = 'chado_example';
+ *
+ * // This menu item will be a tab on the admin/tripal/legacy/tripal_example
+ *   page
+ * // that is not selected by default
+ * $items['admin/tripal/legacy/tripal_example/sync'] = array(
+ * 'title' => ' Sync',
+ * 'description' => 'Sync examples from Chado with Drupal',
+ * 'page callback' => 'drupal_get_form',
+ * 'page arguments' => array('chado_node_sync_form', $module_name, $node_type),
+ * 'access arguments' => array('administer tripal examples'),
+ * 'type' => MENU_LOCAL_TASK,
+ * 'weight' => 0
+ * );
+ *
+ * return $items;
+ * }
+ *
+ * function modulename_node_info() {
+ * return array(
+ * 'chado_example' => array(
+ * 'name' => t('example'),
+ * 'base' => 'chado_example',
+ * 'description' => t('A Chado example is a collection of material that can be
+ *   sampled and have experiments performed on it.'),
+ * 'has_title' => TRUE,
+ * 'locked' => TRUE,
+ *
+ * // this is what differs from the regular Drupal-documented hook_node_info()
+ * 'chado_node_api' => array(
+ * 'base_table' => 'example',            // The name of the chado base table
+ * 'hook_prefix' => 'chado_example',     // Usually the name of the node type
+ * 'linking_table' => 'chado_example',   // Specifies the linking table used
+ * // to map records to Drupal nodes.
+ * // if 'linking_table' is not specified
+ * // it defaults to the node_type name.
+ * 'record_type_title' => array(
+ * 'singular' => t('Example'),         // Singular human-readable title
+ * 'plural' => t('Examples')           // Plural human-readable title
+ * ),
+ * 'sync_filters' => array( // filters for syncing
+ * 'type_id'     => TRUE,     // TRUE if there is an example.type_id field
+ * 'organism_id' => TRUE,     // TRUE if there is an example.organism_id field
+ * 'checkboxes'  => array('name')  // If the 'checkboxes' key is present then
+ *   the
+ * // value must be an array of column names in
+ * // base table. The values from these columns will
+ * // be retreived, contentated with a space delimeter
+ * // and provided in a list of checkboxes
+ * // for the user to choose which to sync.
+ * ),
+ * )
+ * ),
+ * );
+ * }
  * @endcode
  *
- * For more information on how you can override some of this behaviour while still
- * benifiting from as much of the common architecture as possible see the following
- * functions: hook_chado_node_sync_create_new_node(), hook_chado_node_sync_form(),
- * hook_chado_node_sync_select_query().
+ * For more information on how you can override some of this behaviour while
+ *   still benifiting from as much of the common architecture as possible see
+ *   the following functions: hook_chado_node_sync_create_new_node(),
+ *   hook_chado_node_sync_form(), hook_chado_node_sync_select_query().
  *
  * @ingroup tripal_legacy_chado_node_api
  */
 function chado_node_sync_form($form, &$form_state) {
-  $form = array();
+  $form = [];
 
   if (isset($form_state['build_info']['args'][0])) {
     $module = $form_state['build_info']['args'][0];
@@ -433,56 +443,56 @@ function chado_node_sync_form($form, &$form_state) {
     $form_state['chado_node_api'] = $args;
   }
 
-  $form['linking_table'] = array(
+  $form['linking_table'] = [
     '#type' => 'hidden',
-    '#value' => $linking_table
-  );
+    '#value' => $linking_table,
+  ];
 
-  $form['node_type'] = array(
+  $form['node_type'] = [
     '#type' => 'hidden',
-    '#value' => $node_type
-  );
+    '#value' => $node_type,
+  ];
 
   // define the fieldsets
-  $form['sync'] = array(
+  $form['sync'] = [
     '#type' => 'fieldset',
     '#title' => 'Sync ' . $args['record_type_title']['plural'],
     '#descrpition' => '',
-  );
-
-  $form['sync']['description'] = array(
-  '#type' => 'item',
-  '#value' => t("%title_plural of the types listed ".
-     "below in the %title_singular Types box will be synced (leave blank to sync all types). You may limit the ".
-     "%title_plural to be synced by a specific organism. Depending on the ".
-     "number of %title_plural in the chado database this may take a long ".
-     "time to complete. ",
-     array(
-      '%title_singular' => $args['record_type_title']['singular'],
-      '%title_plural' => $args['record_type_title']['plural']
-    )),
-  );
+  ];
+
+  $form['sync']['description'] = [
+    '#type' => 'item',
+    '#value' => t("%title_plural of the types listed " .
+      "below in the %title_singular Types box will be synced (leave blank to sync all types). You may limit the " .
+      "%title_plural to be synced by a specific organism. Depending on the " .
+      "number of %title_plural in the chado database this may take a long " .
+      "time to complete. ",
+      [
+        '%title_singular' => $args['record_type_title']['singular'],
+        '%title_plural' => $args['record_type_title']['plural'],
+      ]),
+  ];
 
   if ($args['sync_filters']['type_id']) {
-    $form['sync']['type_ids'] = array(
-      '#title'       => t('%title_singular Types',
-         array(
+    $form['sync']['type_ids'] = [
+      '#title' => t('%title_singular Types',
+        [
           '%title_singular' => $args['record_type_title']['singular'],
-          '%title_plural' => $args['record_type_title']['plural']
-      )),
-      '#type'        => 'textarea',
+          '%title_plural' => $args['record_type_title']['plural'],
+        ]),
+      '#type' => 'textarea',
       '#description' => t("Enter the names of the %title_singular types to sync. " .
-         "Leave blank to sync all %title_plural. Separate each type with a comma ".
-         "or new line. Pages for these %title_singular ".
-         "types will be created automatically for %title_plural that exist in the ".
-         "chado database. The names must match ".
-         "exactly (spelling and case) with terms in the ontologies",
-         array(
+        "Leave blank to sync all %title_plural. Separate each type with a comma " .
+        "or new line. Pages for these %title_singular " .
+        "types will be created automatically for %title_plural that exist in the " .
+        "chado database. The names must match " .
+        "exactly (spelling and case) with terms in the ontologies",
+        [
           '%title_singular' => strtolower($args['record_type_title']['singular']),
-          '%title_plural' => strtolower($args['record_type_title']['plural'])
-        )),
+          '%title_plural' => strtolower($args['record_type_title']['plural']),
+        ]),
       '#default_value' => (isset($form_state['values']['type_id'])) ? $form_state['values']['type_id'] : '',
-    );
+    ];
   }
 
   // get the list of organisms
@@ -493,17 +503,17 @@ function chado_node_sync_form($form, &$form_state) {
     foreach ($results as $organism) {
       $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
     }
-    $form['sync']['organism_id'] = array(
-      '#title'       => t('Organism'),
-      '#type'        => t('select'),
+    $form['sync']['organism_id'] = [
+      '#title' => t('Organism'),
+      '#type' => t('select'),
       '#description' => t("Choose the organism for which %title_plural types set above will be synced.",
-         array(
+        [
           '%title_singular' => $args['record_type_title']['singular'],
-          '%title_plural' => $args['record_type_title']['plural']
-        )),
-      '#options'     => $organisms,
+          '%title_plural' => $args['record_type_title']['plural'],
+        ]),
+      '#options' => $organisms,
       '#default_value' => (isset($form_state['values']['organism_id'])) ? $form_state['values']['organism_id'] : 0,
-    );
+    ];
   }
   // get the list of organisms
   if (array_key_exists('checkboxes', $args['sync_filters'])) {
@@ -515,29 +525,29 @@ function chado_node_sync_form($form, &$form_state) {
     // we can't proceed, otherwise, generate the checkboxes
     if (array_key_exists('primary key', $table_info) and count($table_info['primary key']) == 1) {
       $pkey = $table_info['primary key'][0];
-      $columns  = $args['sync_filters']['checkboxes'];
+      $columns = $args['sync_filters']['checkboxes'];
       $select_cols = '';
       foreach ($columns as $column) {
         $select_cols .= $base_table . '.' . $column . "|| ' ' ||";
       }
       // Remove trailing || ' ' ||
       $select_cols = substr($select_cols, 0, -9);
-      $base_table_id  = $base_table . '_id';
+      $base_table_id = $base_table . '_id';
 
-      $select = array($base_table . '.' . $pkey, $select_cols . ' as value');
-      $joins = array();
-      $where_clauses = array();
-      $where_args = array();
+      $select = [$base_table . '.' . $pkey, $select_cols . ' as value'];
+      $joins = [];
+      $where_clauses = [];
+      $where_args = [];
 
       // Allow module to update the query.
       $hook_query_alter = $node_type . '_chado_node_sync_select_query';
       if (function_exists($hook_query_alter)) {
-        $update = call_user_func($hook_query_alter, array(
+        $update = call_user_func($hook_query_alter, [
           'select' => $select,
           'joins' => $joins,
           'where_clauses' => $where_clauses,
           'where_args' => $where_args,
-        ));
+        ]);
         // Now add in any new changes
         if ($update and is_array($update)) {
           $select = $update['select'];
@@ -551,13 +561,13 @@ function chado_node_sync_form($form, &$form_state) {
       // so that if no criteria are specified we only get those items that have not
       // yet been synced.
       $query = "SELECT " . implode(', ', $select) . ' ' .
-               'FROM {' . $base_table . '} ' . $base_table . ' ' . implode(' ', $joins) . ' '.
-               "  LEFT JOIN [" . $linking_table . "] CT ON CT.$base_table_id = $base_table.$base_table_id " .
-               "WHERE CT.$base_table_id IS NULL";
+        'FROM {' . $base_table . '} ' . $base_table . ' ' . implode(' ', $joins) . ' ' .
+        "  LEFT JOIN [" . $linking_table . "] CT ON CT.$base_table_id = $base_table.$base_table_id " .
+        "WHERE CT.$base_table_id IS NULL";
 
       // extend the where clause if needed
       $where = '';
-      $sql_args = array();
+      $sql_args = [];
       foreach ($where_clauses as $category => $items) {
         $where .= ' AND (';
         foreach ($items as $item) {
@@ -574,71 +584,71 @@ function chado_node_sync_form($form, &$form_state) {
       $query .= " ORDER BY $base_table." . implode(", $base_table.", $columns);
       $results = chado_query($query, $sql_args);
 
-      $values = array();
+      $values = [];
       foreach ($results as $result) {
         $values[$result->$pkey] = $result->value;
       }
       if (count($values) > 0) {
-        $form['sync']['ids'] = array(
-          '#title'         => 'Avaliable ' . $args['record_type_title']['plural'],
-          '#type'          => 'checkboxes',
-          '#options'       => $values,
-          '#default_value' => (isset($form_state['values']['ids'])) ? $form_state['values']['ids'] : array(),
-          '#suffix'        => '</div><br>',
-          '#prefix'        => t("The following  %title_plural have not been synced. Check those to be synced or leave all unchecked to sync them all.",
-              array(
+        $form['sync']['ids'] = [
+          '#title' => 'Avaliable ' . $args['record_type_title']['plural'],
+          '#type' => 'checkboxes',
+          '#options' => $values,
+          '#default_value' => (isset($form_state['values']['ids'])) ? $form_state['values']['ids'] : [],
+          '#suffix' => '</div><br>',
+          '#prefix' => t("The following  %title_plural have not been synced. Check those to be synced or leave all unchecked to sync them all.",
+              [
                 '%title_singular' => strtolower($args['record_type_title']['singular']),
-                '%title_plural'   => strtolower($args['record_type_title']['plural'])
-              )) . '<div style="height: 200px; overflow: scroll">',
-        );
+                '%title_plural' => strtolower($args['record_type_title']['plural']),
+              ]) . '<div style="height: 200px; overflow: scroll">',
+        ];
       }
       else {
-        $form['sync']['no_ids'] = array(
-          '#markup' => "<p>There are no " .  strtolower($args['record_type_title']['plural']) . " to sync.</p>",
-        );
+        $form['sync']['no_ids'] = [
+          '#markup' => "<p>There are no " . strtolower($args['record_type_title']['plural']) . " to sync.</p>",
+        ];
       }
     }
   }
   // if we provide a list of checkboxes we shouldn't need a max_sync
   else {
-    $form['sync']['max_sync'] = array(
+    $form['sync']['max_sync'] = [
       '#type' => 'textfield',
       '#title' => t('Maximum number of records to Sync'),
       '#description' => t('Leave this field empty to sync all records, regardless of number'),
       '#default_value' => (isset($form_state['values']['max_sync'])) ? $form_state['values']['max_sync'] : '',
-    );
+    ];
   }
 
-  $form['sync']['button'] = array(
+  $form['sync']['button'] = [
     '#type' => 'submit',
     '#value' => t('Sync ' . $args['record_type_title']['plural']),
     '#weight' => 3,
-  );
+  ];
 
 
-  $form['cleanup'] = array(
+  $form['cleanup'] = [
     '#type' => 'fieldset',
-    '#title' => t('Clean Up')
-  );
-  $form['cleanup']['description'] = array(
+    '#title' => t('Clean Up'),
+  ];
+  $form['cleanup']['description'] = [
     '#markup' => t("<p>With Drupal and chado residing in different databases " .
-        "it is possible that nodes in Drupal and " . strtolower($args['record_type_title']['plural']) . " in Chado become " .
-        "\"orphaned\".  This can occur if a node in Drupal is " .
-        "deleted but the corresponding chado records is not and/or vice " .
-        "versa. Click the button below to resolve these discrepancies.</p>"),
+      "it is possible that nodes in Drupal and " . strtolower($args['record_type_title']['plural']) . " in Chado become " .
+      "\"orphaned\".  This can occur if a node in Drupal is " .
+      "deleted but the corresponding chado records is not and/or vice " .
+      "versa. Click the button below to resolve these discrepancies.</p>"),
     '#weight' => -10,
-  );
-  $form['cleanup']['cleanup_batch_size'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Batch Size'),
-      '#description' => t('The number of records to analyze together in a batch. If you are having memory issues you might want to decrease this number.'),
-      '#default_value' => variable_get('chado_node_api_cleanup_batch_size', 25000),
-  );
-  $form['cleanup']['button'] = array(
+  ];
+  $form['cleanup']['cleanup_batch_size'] = [
+    '#type' => 'textfield',
+    '#title' => t('Batch Size'),
+    '#description' => t('The number of records to analyze together in a batch. If you are having memory issues you might want to decrease this number.'),
+    '#default_value' => variable_get('chado_node_api_cleanup_batch_size', 25000),
+  ];
+  $form['cleanup']['button'] = [
     '#type' => 'submit',
     '#value' => 'Clean up orphaned ' . strtolower($args['record_type_title']['plural']),
     '#weight' => 2,
-  );
+  ];
 
   // Allow each module to alter this form as needed
   $hook_form_alter = $args['hook_prefix'] . '_chado_node_sync_form';
@@ -693,13 +703,13 @@ function chado_node_sync_form_submit($form, $form_state) {
     }
 
     // Get the types separated into a consistent string
-    $types = array();
+    $types = [];
     if (isset($form_state['values']['type_ids'])) {
       // seperate by new line or comma.
       $temp_types = preg_split("/[,\n\r]+/", $form_state['values']['type_ids']);
 
       // remove any extra spacing around the types
-      for($i = 0; $i < count($temp_types); $i++) {
+      for ($i = 0; $i < count($temp_types); $i++) {
         // skip empty types
         if (trim($temp_types[$i]) == '') {
           continue;
@@ -709,8 +719,8 @@ function chado_node_sync_form_submit($form, $form_state) {
     }
 
     // Get the ids to be synced
-    $ids = array();
-    if (array_key_exists('ids', $form_state['values'])){
+    $ids = [];
+    if (array_key_exists('ids', $form_state['values'])) {
       foreach ($form_state['values']['ids'] as $id => $selected) {
         if ($selected) {
           $ids[] = $id;
@@ -720,20 +730,20 @@ function chado_node_sync_form_submit($form, $form_state) {
 
     // get the organism to be synced
     $organism_id = FALSE;
-    if (array_key_exists('organism_id',  $form_state['values'])) {
+    if (array_key_exists('organism_id', $form_state['values'])) {
       $organism_id = $form_state['values']['organism_id'];
     }
 
     // Job Arguments
-    $job_args = array(
+    $job_args = [
       'base_table' => $base_table,
       'max_sync' => (!empty($form_state['values']['max_sync'])) ? $form_state['values']['max_sync'] : FALSE,
       'organism_id' => $organism_id,
       'types' => $types,
       'ids' => $ids,
       'linking_table' => $linking_table,
-      'node_type' => $node_type
-    );
+      'node_type' => $node_type,
+    ];
 
     $title = "Sync " . $args['record_type_title']['plural'];
     tripal_add_job($title, $module, 'chado_node_sync_records', $job_args, $user->uid);
@@ -743,7 +753,12 @@ function chado_node_sync_form_submit($form, $form_state) {
     $base_table = $form_state['chado_node_api']['base_table'];
     $linking_table = $form_state['values']['linking_table'];
     $node_type = $form_state['values']['node_type'];
-    $job_args = array($base_table, $form_state['values']['cleanup_batch_size'], $linking_table, $node_type);
+    $job_args = [
+      $base_table,
+      $form_state['values']['cleanup_batch_size'],
+      $linking_table,
+      $node_type,
+    ];
     variable_set('chado_node_api_cleanup_batch_size', $form_state['values']['cleanup_batch_size']);
     tripal_add_job($form_state['values']['op'], $module, 'chado_cleanup_orphaned_nodes', $job_args, $user->uid);
   }
@@ -755,7 +770,8 @@ function chado_node_sync_form_submit($form, $form_state) {
  * @param $base_table
  *   The name of the Chado table containing the record that should be synced
  * @param $max_sync
- *   Optional: A numeric value to indicate the maximum number of records to sync.
+ *   Optional: A numeric value to indicate the maximum number of records to
+ *   sync.
  * @param $organism_id
  *   Optional: Limit the list of records to be synced to only those that
  *   are associated with this organism_id. If the record is not assocaited
@@ -784,8 +800,8 @@ function chado_node_sync_form_submit($form, $form_state) {
  * @ingroup tripal_legacy_chado_node_api
  */
 function chado_node_sync_records($base_table, $max_sync = FALSE,
-    $organism_id = FALSE, $types = array(), $ids = array(),
-    $linking_table = FALSE, $node_type = FALSE, $job_id = NULL) {
+                                 $organism_id = FALSE, $types = [], $ids = [],
+                                 $linking_table = FALSE, $node_type = FALSE, $job_id = NULL) {
 
   global $user;
   $base_table_id = $base_table . '_id';
@@ -800,20 +816,20 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
   print "\nSync'ing $base_table records.  ";
 
   // START BUILDING QUERY TO GET ALL RECORD FROM BASE TABLE THAT MATCH
-  $select = array("$base_table.*");
-  $joins = array();
-  $where_clauses = array();
-  $where_args = array();
+  $select = ["$base_table.*"];
+  $joins = [];
+  $where_clauses = [];
+  $where_args = [];
 
   // If types are supplied then handle them
   $restrictions = '';
   if (count($types) > 0) {
-    $restrictions .= "  Type(s): " . implode(', ',$types) . "\n";
+    $restrictions .= "  Type(s): " . implode(', ', $types) . "\n";
 
     $select[] = 'cvterm.name as cvtname';
     $joins[] = "LEFT JOIN {cvterm} cvterm ON $base_table.type_id = cvterm.cvterm_id";
     foreach ($types as $type) {
-      $sanitized_type = str_replace(' ','_',$type);
+      $sanitized_type = str_replace(' ', '_', $type);
       $where_clauses['type'][] = "cvterm.name = :type_name_$sanitized_type";
       $where_args['type'][":type_name_$sanitized_type"] = $type;
     }
@@ -830,7 +846,7 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
 
   // If Organism is supplied
   if ($organism_id) {
-    $organism = chado_select_record('organism', array('*'), array('organism_id' => $organism_id));
+    $organism = chado_select_record('organism', ['*'], ['organism_id' => $organism_id]);
     $restrictions .= "  Organism: " . $organism[0]->genus . " " . $organism[0]->species . "\n";
 
     $select[] = 'organism.*';
@@ -842,12 +858,12 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
   // Allow module to add to query
   $hook_query_alter = $node_type . '_chado_node_sync_select_query';
   if (function_exists($hook_query_alter)) {
-    $update = call_user_func($hook_query_alter, array(
+    $update = call_user_func($hook_query_alter, [
       'select' => $select,
       'joins' => $joins,
       'where_clauses' => $where_clauses,
       'where_args' => $where_args,
-    ));
+    ]);
     // Now add in any new changes
     if ($update and is_array($update)) {
       $select = $update['select'];
@@ -861,13 +877,13 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
   // yet been synced.
   $query = "
     SELECT " . implode(', ', $select) . ' ' .
-    'FROM {' . $base_table . '} ' . $base_table . ' ' . implode(' ', $joins) . ' '.
+    'FROM {' . $base_table . '} ' . $base_table . ' ' . implode(' ', $joins) . ' ' .
     "  LEFT JOIN [" . $linking_table . "] CT ON CT.$base_table_id = $base_table.$base_table_id " .
     "WHERE CT.$base_table_id IS NULL ";
 
   // extend the where clause if needed
   $where = '';
-  $sql_args = array();
+  $sql_args = [];
   foreach ($where_clauses as $category => $items) {
     $where .= ' AND (';
     foreach ($items as $item) {
@@ -911,8 +927,8 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
   $i = 0;
   $transaction = db_transaction();
   print "\nNOTE: Syncing is performed using a database transaction. \n" .
-      "If the sync fails or is terminated prematurely then the entire set of \n" .
-      "synced items is rolled back and will not be found in the database\n\n";
+    "If the sync fails or is terminated prematurely then the entire set of \n" .
+    "synced items is rolled back and will not be found in the database\n\n";
   try {
     $percent = 0;
     foreach ($results as $record) {
@@ -920,13 +936,13 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
       if ($job_id and $i % $interval == 0) {
         $percent = sprintf("%.2f", (($i + 1) / $count) * 100);
         print "Syncing $base_table " . ($i + 1) . " of $count (" . $percent . "%). Memory: " . number_format(memory_get_usage()) . " bytes.\r";
-        tripal_set_job_progress($job_id, intval(($i/$count)*100));
+        tripal_set_job_progress($job_id, intval(($i / $count) * 100));
       }
 
       // Check if the record is already in the chado linking table
       // (ie: check to see if it is already linked to a node).
       $result = db_select($linking_table, 'lnk')
-        ->fields('lnk',array('nid'))
+        ->fields('lnk', ['nid'])
         ->condition($base_table_id, $record->{$base_table_id}, '=')
         ->execute()
         ->fetchObject();
@@ -948,8 +964,8 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
         }
 
         // Validate and Save New Node
-        $form = array();
-        $form_state = array();
+        $form = [];
+        $form_state = [];
         node_validate($new_node, $form, $form_state);
 
         if (!form_get_errors()) {
@@ -959,15 +975,13 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
           node_save($node);
         }
         else {
-          throw new Exception(t("Failed to insert $base_table: %title", array('%title' => $new_node->title)));
+          throw new Exception(t("Failed to insert $base_table: %title", ['%title' => $new_node->title]));
         }
       }
       $i++;
     }
     print "\n\nComplete!\n";
-  }
-
-  catch (Exception $e) {
+  } catch (Exception $e) {
     $transaction->rollback();
     print "\n"; // make sure we start errors on new line
     watchdog_exception('trp-fsync', $e);
@@ -1001,7 +1015,7 @@ function chado_node_sync_records($base_table, $max_sync = FALSE,
  * @ingroup tripal_legacy_chado_node_api
  */
 function chado_cleanup_orphaned_nodes($table, $nentries = 25000,
-    $linking_table = NULL, $node_type = NULL, $job_id = NULL) {
+                                      $linking_table = NULL, $node_type = NULL, $job_id = NULL) {
 
   // The max number of records either as nodes or linked records.
   $count = 0;
@@ -1019,10 +1033,10 @@ function chado_cleanup_orphaned_nodes($table, $nentries = 25000,
   // Find the number nodes of type chado_$table and find the number of entries
   // in chado_$table; keep the larger of the two numbers.
   $dsql = "SELECT COUNT(*) FROM {node} WHERE type = :node_type";
-  $ndat = db_query($dsql, array(':node_type' => $node_type));
+  $ndat = db_query($dsql, [':node_type' => $node_type]);
   $temp = $ndat->fetchObject();
   $ncount = $temp->count;
-  $clsql= "SELECT COUNT(*) FROM {" . $linking_table . "}";
+  $clsql = "SELECT COUNT(*) FROM {" . $linking_table . "}";
   $cdat = db_query($clsql);
   $clcount = $cdat->fetchObject();
   if ($ncount < $clcount) {
@@ -1041,10 +1055,9 @@ function chado_cleanup_orphaned_nodes($table, $nentries = 25000,
     for ($i = 0; $i < $m; $i++) {
       $offset = ($nentries * $i);
       chado_cleanup_orphaned_nodes_part($table, $job_id, $nentries, $offset,
-          $linking_table, $node_type);
+        $linking_table, $node_type);
     }
-  }
-  catch (Exception $e) {
+  } catch (Exception $e) {
     $transaction->rollback();
     print "\n"; // make sure we start errors on new line
     watchdog_exception('trp-fsync', $e);
@@ -1067,15 +1080,15 @@ function chado_cleanup_orphaned_nodes($table, $nentries = 25000,
  * @ingroup tripal_legacy_chado_node_api
  */
 function chado_cleanup_orphaned_nodes_part($table, $job_id = NULL, $nentries,
-    $offset, $linking_table, $node_type) {
+                                           $offset, $linking_table, $node_type) {
 
   $count = 0;
 
   // Retrieve all of the entries in the linker table for a given node type
   // and place into an array.
   print "Verifying $linking_table records...\n";
-  $cnodes = array();
-  $clsql= "
+  $cnodes = [];
+  $clsql = "
     SELECT *
     FROM {" . $linking_table . "} LT
     ORDER BY LT.nid LIMIT $nentries OFFSET $offset";
@@ -1104,23 +1117,26 @@ function chado_cleanup_orphaned_nodes_part($table, $job_id = NULL, $nentries,
 
       // See if the node exits, if not remove the entry from linking table table.
       $nsql = "SELECT * FROM {node} WHERE nid = :nid AND type = :node_type";
-      $results = db_query($nsql, array(':nid' => $linker->nid, ':node_type' => $node_type));
+      $results = db_query($nsql, [
+        ':nid' => $linker->nid,
+        ':node_type' => $node_type,
+      ]);
       $node = $results->fetchObject();
       if (!$node) {
         $deleted++;
-        db_query("DELETE FROM {" . $linking_table . "} WHERE nid = :nid", array(':nid' => $linker->nid));
+        db_query("DELETE FROM {" . $linking_table . "} WHERE nid = :nid", [':nid' => $linker->nid]);
         //print "$linking_table missing node.... DELETING where nid=".$linker->nid." $linking_table entry.\n";
       }
 
       // Does record in chado exists, if not remove entry from $linking_table.
       $table_id = $table . "_id";
       $lsql = "SELECT * FROM {" . $table . "} where " . $table_id . " = :chado_id";
-      $results = chado_query($lsql, array(":chado_id" => $linker->$table_id));
+      $results = chado_query($lsql, [":chado_id" => $linker->$table_id]);
       $record = $results->fetchObject();
       if (!$record) {
         $deleted++;
         $sql = "DELETE FROM {" . $linking_table . "} WHERE " . $table_id . " = :chado_id";
-        db_query($sql, array(":chado_id" => $linker->$table_id));
+        db_query($sql, [":chado_id" => $linker->$table_id]);
         //print "$linking_table missing $table.... DELETING where $table_id=".$linker->$table_id." $linking_table entry.\n";
       }
       $i++;
@@ -1141,8 +1157,8 @@ function chado_cleanup_orphaned_nodes_part($table, $job_id = NULL, $nentries,
     LIMIT $nentries OFFSET $offset
   ";
 
-  $dsql_args = array(':node_type' => $node_type);
-  $nodes = array();
+  $dsql_args = [':node_type' => $node_type];
+  $nodes = [];
   $res = db_query($dsql, $dsql_args);
   $count = 0;
   foreach ($res as $node) {
@@ -1169,21 +1185,21 @@ function chado_cleanup_orphaned_nodes_part($table, $job_id = NULL, $nentries,
 
       // check to see if the node has a corresponding entry
       // in the $linking_table table. If not then delete the node.
-       $csql = "SELECT * FROM {" . $linking_table . "} WHERE nid = :nid ";
-       $results = db_query($csql, array(':nid' => $node->nid));
-       $link = $results->fetchObject();
-       if (!$link) {
-         // Checking node_access creates a memory leak. Commenting out for now
-         // assuming that this code can only be run by a site administrator
-         // anyway.
-//         if (node_access('delete', $node)) {
-           $deleted++;
-           node_delete($node->nid);
-//         }
-//         else {
-//           print "\nNode missing in $linking_table table.... but cannot delete due to improper permissions (node $node->nid)\n";
-//         }
-       }
+      $csql = "SELECT * FROM {" . $linking_table . "} WHERE nid = :nid ";
+      $results = db_query($csql, [':nid' => $node->nid]);
+      $link = $results->fetchObject();
+      if (!$link) {
+        // Checking node_access creates a memory leak. Commenting out for now
+        // assuming that this code can only be run by a site administrator
+        // anyway.
+        //         if (node_access('delete', $node)) {
+        $deleted++;
+        node_delete($node->nid);
+        //         }
+        //         else {
+        //           print "\nNode missing in $linking_table table.... but cannot delete due to improper permissions (node $node->nid)\n";
+        //         }
+      }
       $i++;
     }
     $percent = sprintf("%.2f", ($i / $count) * 100);
@@ -1201,9 +1217,9 @@ function chado_cleanup_orphaned_nodes_part($table, $job_id = NULL, $nentries,
  * Note: For your own module, replace hook in the function name with the
  * machine-name of your chado node type (ie: chado_feature).
  *
- * @param $new_node:
+ * @param $new_node :
  *   a basic new node object
- * @param $record:
+ * @param $record :
  *   the record object from chado specifying the biological data for this node
  *
  * @return
@@ -1257,11 +1273,11 @@ function hook_chado_node_sync_form($form, &$form_state) {
  *
  * @ingroup tripal_legacy_chado_node_api
  */
-function hook_chado_node_sync_form_submit ($form, $form_state) {
+function hook_chado_node_sync_form_submit($form, $form_state) {
 
   global $user;
 
-  $job_args = array(
+  $job_args = [
     // The base chado table (ie: feature).
     $base_table,
     // The maximum number of records to sync or FALSE for sync all that match.
@@ -1269,12 +1285,12 @@ function hook_chado_node_sync_form_submit ($form, $form_state) {
     // The organism_id to restrict records to or FALSE if not to restrict by organism_id.
     $organism_id,
     // A string with the cvterm.name of the types to restrict to separated by |||
-    $types
-  );
+    $types,
+  ];
 
   // You should register a tripal job
   tripal_add_job(
-    // The title of the job -be descriptive.
+  // The title of the job -be descriptive.
     $title,
     // The name of your module.
     $module,

+ 278 - 252
legacy/tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc

@@ -6,91 +6,105 @@
  *
  * How To Use:
  * @code
-
-  function chado_example_form($form, &$form_state) {
-
-    // Default values for form elements can come in the following ways:
-    //
-    // 1) as elements of the $node object.  This occurs when editing an existing node
-    // 2) in the $form_state['values'] array which occurs on a failed validation or
-    //    ajax callbacks when the ajax call originates from non-submit fields other
-    //    than button
-    // 3) in the $form_state['input'] array which occurs on ajax callbacks from submit
-    //    form elements (e.g. buttons) and the form is being rebuilt but has not yet
-    //    been validated
-    //
-    // The reference elements added by this function do use AJAX calls from buttons,
-    // therefore, it is important to check for form values in the $form_state['values']
-    // for case #2 above, and in the $form_state['input'] for case #3.
-    // See the chado analysis node form for an example.
-
-
-    // Next, add in all the form array definition particular to your node type
-
-    // To add in the additional database reference form elements, you first need to prepare the arguments
-    // for the function call.
-
-    $details = array(
-      'linking_table' => 'example_dbxref',         // the name of the table linking additional dbxrefs to this node
-      'base_foreign_key' => 'example_id',          // key to link to the chado content created by this node
-      'base_key_value' => $example_id,             // the value of the above key
-      'fieldset_title' => 'Additional References', // the non-translated title for this fieldset
-      'additional_instructions' => ''              // a non-stranslated string providing additional instructions
-    );
-
-    // Finally, and add the additional form elements to the form
-    chado_add_node_form_dbxrefs($form, $form_state, $details);
-
-    return $form;
-  }
-
-  function chado_example_insert($node) {
-
-    // if there is an example_id in the $node object then this must be a sync so
-    // we can skip adding the chado_example as it is already there, although
-    // we do need to proceed with the rest of the insert
-    if (!property_exists($node, 'example_id')) {
-
-      // Add record to chado example table
-
-      // Add to any other tables needed
-
-      // Add all additional database references
-      // This function will create new database references as needed and select existing ones.
-      // Existing _dbxref links will be cleared and then re-added
-      chado_update_node_form_dbxrefs(
-        $node,              // the node object passed in via hook_insert()
-        'example_dbxref',   // the name of the _dbxref linking table
-        'example_id',       // key to link to the chado content created by this node
-        $node->example_id   // value of the above key
-      );
-    }
-
-    // Add record to chado_example linking example_id to new node
-
-  }
-
-  function chado_example_update($node) {
-
-
-      // Update record in chado example table
-
-      // Update any other tables needed
-
-      // Update all additional database references
-      // This function will create new database references as needed and select existing ones.
-      // Existing _dbxref links will be cleared and then re-added
-      chado_update_node_form_dbxrefs(
-        $node,              // the node object passed in via hook_insert()
-        'example_dbxref',   // the name of the _dbxref linking table
-        'example_id',       // key to link to the chado content created by this node
-        $node->example_id   // value of the above key
-      );
-
-    // Don't need to update chado_example linking table since niether example_id or nid can be changed in update
-
-  }
-
+ *
+ * function chado_example_form($form, &$form_state) {
+ *
+ * // Default values for form elements can come in the following ways:
+ * //
+ * // 1) as elements of the $node object.  This occurs when editing an existing
+ *   node
+ * // 2) in the $form_state['values'] array which occurs on a failed validation
+ *   or
+ * //    ajax callbacks when the ajax call originates from non-submit fields
+ *   other
+ * //    than button
+ * // 3) in the $form_state['input'] array which occurs on ajax callbacks from
+ *   submit
+ * //    form elements (e.g. buttons) and the form is being rebuilt but has not
+ *   yet
+ * //    been validated
+ * //
+ * // The reference elements added by this function do use AJAX calls from
+ *   buttons,
+ * // therefore, it is important to check for form values in the
+ *   $form_state['values']
+ * // for case #2 above, and in the $form_state['input'] for case #3.
+ * // See the chado analysis node form for an example.
+ *
+ *
+ * // Next, add in all the form array definition particular to your node type
+ *
+ * // To add in the additional database reference form elements, you first need
+ *   to prepare the arguments
+ * // for the function call.
+ *
+ * $details = array(
+ * 'linking_table' => 'example_dbxref',         // the name of the table
+ *   linking additional dbxrefs to this node
+ * 'base_foreign_key' => 'example_id',          // key to link to the chado
+ *   content created by this node
+ * 'base_key_value' => $example_id,             // the value of the above key
+ * 'fieldset_title' => 'Additional References', // the non-translated title for
+ *   this fieldset
+ * 'additional_instructions' => ''              // a non-stranslated string
+ *   providing additional instructions
+ * );
+ *
+ * // Finally, and add the additional form elements to the form
+ * chado_add_node_form_dbxrefs($form, $form_state, $details);
+ *
+ * return $form;
+ * }
+ *
+ * function chado_example_insert($node) {
+ *
+ * // if there is an example_id in the $node object then this must be a sync so
+ * // we can skip adding the chado_example as it is already there, although
+ * // we do need to proceed with the rest of the insert
+ * if (!property_exists($node, 'example_id')) {
+ *
+ * // Add record to chado example table
+ *
+ * // Add to any other tables needed
+ *
+ * // Add all additional database references
+ * // This function will create new database references as needed and select
+ *   existing ones.
+ * // Existing _dbxref links will be cleared and then re-added
+ * chado_update_node_form_dbxrefs(
+ * $node,              // the node object passed in via hook_insert()
+ * 'example_dbxref',   // the name of the _dbxref linking table
+ * 'example_id',       // key to link to the chado content created by this node
+ * $node->example_id   // value of the above key
+ * );
+ * }
+ *
+ * // Add record to chado_example linking example_id to new node
+ *
+ * }
+ *
+ * function chado_example_update($node) {
+ *
+ *
+ * // Update record in chado example table
+ *
+ * // Update any other tables needed
+ *
+ * // Update all additional database references
+ * // This function will create new database references as needed and select
+ *   existing ones.
+ * // Existing _dbxref links will be cleared and then re-added
+ * chado_update_node_form_dbxrefs(
+ * $node,              // the node object passed in via hook_insert()
+ * 'example_dbxref',   // the name of the _dbxref linking table
+ * 'example_id',       // key to link to the chado content created by this node
+ * $node->example_id   // value of the above key
+ * );
+ *
+ * // Don't need to update chado_example linking table since niether example_id
+ *   or nid can be changed in update
+ *
+ * }
  * @endcode
  *
  * @ingroup tripal_legacy_chado_node_api
@@ -110,15 +124,18 @@
  *   The corresponding form_state array for the form
  * @param $details
  *   An array defining details needed by this form. Required Keys are:
- *     - linking_table: the name of the dbxref linking table (ie: feature_dbxref)
- *     - base_foreign_key: the name of the foreign key linking this table to the non-dbxref table (ie: feature_id)
- *     - base_key_value: the value of the base_foreign_key for the current form (ie: 999 if the feature_id=999)
- *   Optional keys include:
+ *     - linking_table: the name of the dbxref linking table (ie:
+ *   feature_dbxref)
+ *     - base_foreign_key: the name of the foreign key linking this table to
+ *   the non-dbxref table (ie: feature_id)
+ *     - base_key_value: the value of the base_foreign_key for the current form
+ *   (ie: 999 if the feature_id=999) Optional keys include:
  *     - fieldset_title: the non-translated title for this fieldset
- *     - additional_instructions: a non-translated string providing additional instructions
+ *     - additional_instructions: a non-translated string providing additional
+ *   instructions
  *     - select_options: must be an array where the [key] is a valid db_id and
- *       the [value] is the human-readable name of the option. This includes all databases
- *       in the chado db table by default
+ *       the [value] is the human-readable name of the option. This includes
+ *   all databases in the chado db table by default
  *
  * @ingroup tripal_legacy_chado_node_api
  */
@@ -135,10 +152,10 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
   }
   else {
     // get the list of databases from the db table
-    $db_options = array(0 => 'Select a Database');
-    $options = array('order_by' => array('name' => 'ASC'));
-    $select = chado_select_record('db', array('db_id','name'), array(), $options);
-    foreach($select as $db) {
+    $db_options = [0 => 'Select a Database'];
+    $options = ['order_by' => ['name' => 'ASC']];
+    $select = chado_select_record('db', ['db_id', 'name'], [], $options);
+    foreach ($select as $db) {
       $db_options[$db->db_id] = $db->name;
     }
   }
@@ -151,23 +168,23 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
   $tripal_message = tripal_set_message(
     t('To add databases to the drop down list, you need to <a href="@dblink">add
       an external database reference</a>.',
-      array(
-        '@dblink' => url('admin/tripal/legacy/tripal_db/add')
-      )
+      [
+        '@dblink' => url('admin/tripal/legacy/tripal_db/add'),
+      ]
     ),
     $importance,
-    array('return_html' => TRUE)
+    ['return_html' => TRUE]
   );
 
   // Group all of the chado node api fieldsets into vertical tabs.
-  $form['chado_node_api'] = array(
+  $form['chado_node_api'] = [
     '#type' => 'vertical_tabs',
-    '#attached' => array(
-      'css' => array(
+    '#attached' => [
+      'css' => [
         'chado-node-api' => drupal_get_path('module', 'tripal_core') . '/theme/css/chado_node_api.css',
-      ),
-    ),
-  );
+      ],
+    ],
+  ];
 
   // the fieldset of the dbxref elements
   $instructions = 'To add an external reference, select the database you want to reference from the
@@ -177,47 +194,47 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
     depending upon what is available. To remove incorrect references, click the
     "Remove" button. Note: you cannot edit previously added references but instead
     need to remove and re-add them.';
-  $form['addtl_dbxrefs'] = array(
+  $form['addtl_dbxrefs'] = [
     '#type' => 'fieldset',
     '#title' => t($details['fieldset_title']),
     '#description' => t('<p><strong>Indicate that this %nodetype either originates from
-      or is present in another database.</strong></p><p>'. $instructions . $details['additional_instructions'] . '</p>',
-      array('%nodetype' => $details['nodetype'])),
+      or is present in another database.</strong></p><p>' . $instructions . $details['additional_instructions'] . '</p>',
+      ['%nodetype' => $details['nodetype']]),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
     '#group' => 'chado_node_api',
-    '#weight'      => 9,
-    '#attributes' => array('class' => array('chado-node-api','dbxrefs')),
-    '#attached' => array(
-      'js' => array(
+    '#weight' => 9,
+    '#attributes' => ['class' => ['chado-node-api', 'dbxrefs']],
+    '#attached' => [
+      'js' => [
         'chado-node-api-vertical-tabs' => drupal_get_path('module', 'tripal_core') . '/theme/js/chadoNodeApi_updateVerticalTabSummary.js',
-      ),
-    ),
-  );
+      ],
+    ],
+  ];
 
   // this form element is a tree, so that we don't puke all of the values into then node variable
   // it is set as a tree, and keeps them in the $form_state['values']['dbxref_table'] heading.
-  $form['addtl_dbxrefs']['dbxref_table'] = array(
+  $form['addtl_dbxrefs']['dbxref_table'] = [
     '#type' => 'markup',
     '#tree' => TRUE,
     '#prefix' => '<div id="tripal-generic-edit-addtl_dbxrefs-table">',
     '#suffix' => '</div>',
-    '#theme' => 'chado_node_additional_dbxrefs_form_table'
-  );
+    '#theme' => 'chado_node_additional_dbxrefs_form_table',
+  ];
 
   // We need to provide feedback to the user that changes made
   // are not saved until the node is saved.
-  $form['addtl_dbxrefs']['dbxref_table']['save_warning'] = array(
+  $form['addtl_dbxrefs']['dbxref_table']['save_warning'] = [
     '#type' => 'markup',
     '#prefix' => '<div id="dbxref-save-warning" class="messages warning" style="display:none;">',
     '#suffix' => '</div>',
     '#markup' => '* The changes to these references will not be saved until the "Save" button at the bottom of this form is clicked. <span class="specific-changes"></span>',
-    '#attached' => array(
-      'js' => array(
+    '#attached' => [
+      'js' => [
         'chado-node-api-unsaved' => drupal_get_path('module', 'tripal_core') . '/theme/js/chadoNodeApi_unsavedNotify.js',
-      ),
-    ),
-  );
+      ],
+    ],
+  ];
 
   /* DBxrefs can come to us in two ways:
    *
@@ -243,10 +260,10 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
          dbxref.version
        FROM {dbxref} dbxref
          LEFT JOIN {db} db ON db.db_id = dbxref.db_id
-         LEFT JOIN {".$details['linking_table']."} linking_table ON linking_table.dbxref_id = dbxref.dbxref_id
-       WHERE linking_table.".$details['base_foreign_key']."= :base_key_value
+         LEFT JOIN {" . $details['linking_table'] . "} linking_table ON linking_table.dbxref_id = dbxref.dbxref_id
+       WHERE linking_table." . $details['base_foreign_key'] . "= :base_key_value
        ORDER BY db.name ASC, dbxref.version ASC",
-       array(':base_key_value' => $details['base_key_value'])
+      [':base_key_value' => $details['base_key_value']]
     );
   }
   /* The format of the $existing_dbxref's array is either:
@@ -290,66 +307,66 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
 
       $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['#type'] = 'markup';
       $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['#value'] = '';
-      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['#attributes'] = array(
-        'class' => array('dbxref', 'saved')
-      );
+      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['#attributes'] = [
+        'class' => ['dbxref', 'saved'],
+      ];
 
       // Determine whether this dbxref is unsaved or not.
       // We can tell this by looking at the dbxref_id: if it's not
       // saved yet we will have entered a TEMP###.
       if (preg_match('/^TEMP/', $dbxref->dbxref_id)) {
-        $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['#attributes'] = array(
-          'class' => array('dbxref', 'unsaved')
-        );
+        $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['#attributes'] = [
+          'class' => ['dbxref', 'unsaved'],
+        ];
       }
 
-      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['db_id'] = array(
+      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['db_id'] = [
         '#type' => 'hidden',
-        '#value' => $dbxref->db_id
-      );
+        '#value' => $dbxref->db_id,
+      ];
 
-      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['accession'] = array(
+      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['accession'] = [
         '#type' => 'hidden',
-        '#value' => $dbxref->accession
-      );
+        '#value' => $dbxref->accession,
+      ];
 
-      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['version'] = array(
+      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['version'] = [
         '#type' => 'hidden',
         '#value' => $dbxref->version,
-      );
+      ];
 
-      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['dbxref_id'] = array(
+      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['dbxref_id'] = [
         '#type' => 'hidden',
-        '#value' => $dbxref->dbxref_id
-      );
+        '#value' => $dbxref->dbxref_id,
+      ];
 
-      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['db'] = array(
+      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['db'] = [
         '#type' => 'markup',
         '#markup' => $dbxref->db_name,
-        '#prefix' => '<span class="row-unsaved-warning"></span>'
-      );
+        '#prefix' => '<span class="row-unsaved-warning"></span>',
+      ];
 
-      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['dbxref_version'] = array(
+      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['dbxref_version'] = [
         '#type' => 'markup',
         '#markup' => $dbxref->version,
-      );
+      ];
 
-      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['dbxref_accession'] = array(
+      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['dbxref_accession'] = [
         '#type' => 'markup',
-        '#markup' => $dbxref->accession
-      );
+        '#markup' => $dbxref->accession,
+      ];
       // remove button
-      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['dbxref_action'] = array(
+      $form['addtl_dbxrefs']['dbxref_table'][$dbxref->db_id][$dbxref->dbxref_id]['dbxref_action'] = [
         '#type' => 'submit',
         '#value' => t('Remove'),
-        '#name' => "dbxrefs_remove-".$dbxref->db_id.'-'.$dbxref->dbxref_id,
-        '#ajax' => array(
+        '#name' => "dbxrefs_remove-" . $dbxref->db_id . '-' . $dbxref->dbxref_id,
+        '#ajax' => [
           'callback' => "chado_add_node_form_subtable_ajax_update",
           'wrapper' => 'tripal-generic-edit-addtl_dbxrefs-table',
-          'effect'   => 'fade',
-          'method'   => 'replace',
-          'prevent'  => 'click'
-        ),
+          'effect' => 'fade',
+          'method' => 'replace',
+          'prevent' => 'click',
+        ],
         // When this button is clicked, the form will be validated and submitted.
         // Therefore, we set custom submit and validate functions to override the
         // default node form submit.  In the validate function we validate only the
@@ -357,60 +374,61 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
         // from the chado_additional_dbxrefs array. In order to keep validate errors
         // from the node form validate and Drupal required errors for non-dbxref fields
         // preventing the user from removing dbxrefs we set the #limit_validation_errors below
-        '#validate' => array('chado_add_node_form_subtables_remove_button_validate'),
-        '#submit' => array('chado_add_node_form_subtables_remove_button_submit'),
+        '#validate' => ['chado_add_node_form_subtables_remove_button_validate'],
+        '#submit' => ['chado_add_node_form_subtables_remove_button_submit'],
         // Limit the validation of the form upon clicking this button to the dbxref_table tree
         // No other fields will be validated (ie: no fields from the main form or any other api
         // added form).
-        '#limit_validation_errors' => array(
-          array('dbxref_table')  // Validate all fields within $form_state['values']['dbxref_table']
-        )
-      );
+        '#limit_validation_errors' => [
+          ['dbxref_table']
+          // Validate all fields within $form_state['values']['dbxref_table']
+        ],
+      ];
     }
   }
 
   // Quickly add a hidden field stating how many dbxrefs are currently added.
-  $form['addtl_dbxrefs']['num_dbxrefs'] = array(
+  $form['addtl_dbxrefs']['num_dbxrefs'] = [
     '#type' => 'hidden',
     '#value' => $num_dbxrefs,
-    '#attributes' => array('class' => 'num-dbxrefs')
-  );
+    '#attributes' => ['class' => 'num-dbxrefs'],
+  ];
 
   // Form elements for adding a new dbxref
   //---------------------------------------------
-  $form['addtl_dbxrefs']['dbxref_table']['new'] = array(
+  $form['addtl_dbxrefs']['dbxref_table']['new'] = [
     '#type' => 'markup',
     '#prefix' => '<span class="addtl-dbxrefs-add-new-dbxref">',
-    '#suffix' => '</span>'
-  );
+    '#suffix' => '</span>',
+  ];
 
   // add in the existing databases
-  $form['addtl_dbxrefs']['dbxref_table']['new']['db'] = array(
+  $form['addtl_dbxrefs']['dbxref_table']['new']['db'] = [
     '#type' => 'select',
     '#options' => $db_options,
-  );
+  ];
 
-  $form['addtl_dbxrefs']['dbxref_table']['new']['dbxref_accession'] = array(
+  $form['addtl_dbxrefs']['dbxref_table']['new']['dbxref_accession'] = [
     '#type' => 'textfield',
-  );
+  ];
 
-  $form['addtl_dbxrefs']['dbxref_table']['new']['dbxref_version'] = array(
+  $form['addtl_dbxrefs']['dbxref_table']['new']['dbxref_version'] = [
     '#type' => 'textfield',
     '#size' => 10,
-  );
+  ];
 
   // add button
-  $form['addtl_dbxrefs']['dbxref_table']['new']['dbxref_action'] = array(
+  $form['addtl_dbxrefs']['dbxref_table']['new']['dbxref_action'] = [
     '#type' => 'submit',
     '#value' => t('Add'),
     '#name' => "dbxrefs-add",
-    '#ajax' => array(
+    '#ajax' => [
       'callback' => "chado_add_node_form_subtable_ajax_update",
       'wrapper' => 'tripal-generic-edit-addtl_dbxrefs-table',
-      'effect'   => 'fade',
-      'method'   => 'replace',
-      'prevent'  => 'click'
-    ),
+      'effect' => 'fade',
+      'method' => 'replace',
+      'prevent' => 'click',
+    ],
     // When this button is clicked, the form will be validated and submitted.
     // Therefore, we set custom submit and validate functions to override the
     // default node form submit.  In the validate function we validate only the
@@ -418,20 +436,21 @@ function chado_add_node_form_dbxrefs(&$form, &$form_state, $details) {
     // array. In order to keep validate errors from the node form validate and Drupal
     // required errors for non-dbxref fields preventing the user from adding dbxrefs we
     // set the #limit_validation_errors below
-    '#validate' => array('chado_add_node_form_subtables_add_button_validate'),
-    '#submit' => array('chado_add_node_form_subtables_add_button_submit'),
+    '#validate' => ['chado_add_node_form_subtables_add_button_validate'],
+    '#submit' => ['chado_add_node_form_subtables_add_button_submit'],
     // Limit the validation of the form upon clicking this button to the dbxref_table tree
     // No other fields will be validated (ie: no fields from the main form or any other api
     // added form).
-    '#limit_validation_errors' => array(
-      array('dbxref_table')  // Validate all fields within $form_state['values']['dbxref_table']
-    )
-  );
+    '#limit_validation_errors' => [
+      ['dbxref_table']
+      // Validate all fields within $form_state['values']['dbxref_table']
+    ],
+  ];
 
-  $form['addtl_dbxrefs']['admin_message'] = array(
+  $form['addtl_dbxrefs']['admin_message'] = [
     '#type' => 'markup',
-    '#markup' => $tripal_message
-  );
+    '#markup' => $tripal_message,
+  ];
 }
 
 /**
@@ -443,8 +462,8 @@ function chado_add_node_form_dbxrefs_add_button_validate($form, &$form_state) {
   // Ensure the db_id is supplied & Valid
   $db = chado_select_record(
     'db',
-    array('db_id', 'name'),
-    array('db_id' => $form_state['values']['dbxref_table']['new']['db'])
+    ['db_id', 'name'],
+    ['db_id' => $form_state['values']['dbxref_table']['new']['db']]
   );
   if (!isset($db[0])) {
     form_set_error('dbxref_table][new][db', 'Please select a database before attempting to add a new database reference.');
@@ -455,7 +474,7 @@ function chado_add_node_form_dbxrefs_add_button_validate($form, &$form_state) {
 
   // Ensure accession is supplied
   if (empty($form_state['values']['dbxref_table']['new']['dbxref_accession'])) {
-    form_set_error('dbxref_table][new][dbxref_accession','You must enter the accession before attempting to add a new database reference.');
+    form_set_error('dbxref_table][new][dbxref_accession', 'You must enter the accession before attempting to add a new database reference.');
   }
 
 }
@@ -463,8 +482,8 @@ function chado_add_node_form_dbxrefs_add_button_validate($form, &$form_state) {
 /**
  * Called by the add button in chado_add_node_form_dbxrefs
  *
- * Create an array of additional dbxrefs in the form state. This array will then be
- * used to rebuild the form in subsequent builds
+ * Create an array of additional dbxrefs in the form state. This array will
+ * then be used to rebuild the form in subsequent builds
  *
  */
 function chado_add_node_form_dbxrefs_add_button_submit($form, &$form_state) {
@@ -476,13 +495,13 @@ function chado_add_node_form_dbxrefs_add_button_submit($form, &$form_state) {
   }
 
   // get details for the new dbxref
-  $dbxref = array(
+  $dbxref = [
     'db_id' => $form_state['values']['dbxref_table']['new']['db'],
     'db_name' => $form_state['values']['dbxref_table']['new']['db_name'],
     'dbxref_id' => 'TEMP' . uniqid(),
     'version' => $form_state['values']['dbxref_table']['new']['dbxref_version'],
     'accession' => $form_state['values']['dbxref_table']['new']['dbxref_accession'],
-  );
+  ];
   $key = $dbxref['db_id'] . '-' . $dbxref['dbxref_id'];
   $form_state['chado_additional_dbxrefs'][$key] = (object) $dbxref;
 
@@ -516,7 +535,7 @@ function chado_add_node_form_dbxrefs_remove_button_submit(&$form, &$form_state)
   }
 
   // remove the specified dbxref from the form dbxref table
-  if(preg_match('/dbxrefs_remove-([^-]+-[^-]+)/',$form_state['triggering_element']['#name'],$match)) {
+  if (preg_match('/dbxrefs_remove-([^-]+-[^-]+)/', $form_state['triggering_element']['#name'], $match)) {
     $key = $match[1];
     if (array_key_exists($key, $form_state['chado_additional_dbxrefs'])) {
       unset($form_state['chado_additional_dbxrefs'][$key]);
@@ -525,16 +544,18 @@ function chado_add_node_form_dbxrefs_remove_button_submit(&$form, &$form_state)
 }
 
 /**
- * Creates an array in form_state containing the existing addtl_dbxrefs. This array is
- * then modified by the add/remove buttons and used as a source for rebuilding the form.
- * This function get's called at each button (add and remove) button submits the first
- * time one of the button's is clicked to instantiates the $form_state['chado_additional_dbxrefs'] array
+ * Creates an array in form_state containing the existing addtl_dbxrefs. This
+ * array is then modified by the add/remove buttons and used as a source for
+ * rebuilding the form. This function get's called at each button (add and
+ * remove) button submits the first time one of the button's is clicked to
+ * instantiates the $form_state['chado_additional_dbxrefs'] array
  *
  * $form_state['chado_additional_dbxrefs'] = array(
  *   '[db_id]-[version]' => array(
  *     'db_id' => [the db.db_id value]
  *     'db_name' => [the db.name value]
- *     'dbxref_id' => [the dbxref.dbxref_id value, or temporary value if it doesn't yet exists],
+ *     'dbxref_id' => [the dbxref.dbxref_id value, or temporary value if it
+ * doesn't yet exists],
  *     'version' => [the dbxref.version value],
  *     'accession' => [the dbxref.accession value],
  *   ),
@@ -543,21 +564,21 @@ function chado_add_node_form_dbxrefs_remove_button_submit(&$form, &$form_state)
  */
 function chado_add_node_form_dbxrefs_create_dbxref_formstate_array($form, &$form_state) {
 
-  $form_state['chado_additional_dbxrefs'] = array();
+  $form_state['chado_additional_dbxrefs'] = [];
 
   foreach (element_children($form['addtl_dbxrefs']['dbxref_table']) as $db_id) {
     if ($db_id != 'new') {
       foreach (element_children($form['addtl_dbxrefs']['dbxref_table'][$db_id]) as $version) {
-          $element = $form['addtl_dbxrefs']['dbxref_table'][$db_id][$version];
-          $dbxref = array(
-            'db_id' => $element['db_id']['#value'],
-            'db_name' => $element['db']['#markup'],
-            'dbxref_id' => $element['dbxref_id']['#value'],
-            'version' => $element['dbxref_version']['#markup'],
-            'accession' => $element['dbxref_accession']['#markup'],
-          );
-          $key = $dbxref['db_id'] . '-' . $dbxref['dbxref_id'];
-          $form_state['chado_additional_dbxrefs'][$key] = (object) $dbxref;
+        $element = $form['addtl_dbxrefs']['dbxref_table'][$db_id][$version];
+        $dbxref = [
+          'db_id' => $element['db_id']['#value'],
+          'db_name' => $element['db']['#markup'],
+          'dbxref_id' => $element['dbxref_id']['#value'],
+          'version' => $element['dbxref_version']['#markup'],
+          'accession' => $element['dbxref_accession']['#markup'],
+        ];
+        $key = $dbxref['db_id'] . '-' . $dbxref['dbxref_id'];
+        $form_state['chado_additional_dbxrefs'][$key] = (object) $dbxref;
       }
     }
   }
@@ -570,29 +591,29 @@ function chado_add_node_form_dbxrefs_create_dbxref_formstate_array($form, &$form
 function theme_chado_add_node_form_dbxrefs_table($variables) {
   $element = $variables['element'];
 
-  $header = array(
+  $header = [
     'db' => t('Database'),
     'dbxref_accession' => t('Accession'),
     'dbxref_version' => t('Version'),
     'dbxref_action' => t('Actions'),
-  );
+  ];
 
-  $rows = array();
+  $rows = [];
   foreach (element_children($element) as $db_id) {
     if ($db_id == 'new') {
-      $row = array();
+      $row = [];
 
-        $row['data'] = array();
-        foreach ($header as $fieldname => $title) {
-          $row['data'][] = drupal_render($element[$db_id][$fieldname]);
-        }
-        $rows[] = $row;
+      $row['data'] = [];
+      foreach ($header as $fieldname => $title) {
+        $row['data'][] = drupal_render($element[$db_id][$fieldname]);
+      }
+      $rows[] = $row;
     }
     else {
       foreach (element_children($element[$db_id]) as $version) {
-        $row = array();
+        $row = [];
 
-        $row['data'] = array();
+        $row['data'] = [];
         $row['class'] = $element[$db_id][$version]['#attributes']['class'];
         foreach ($header as $fieldname => $title) {
           $row['data'][] = drupal_render($element[$db_id][$version][$fieldname]);
@@ -602,31 +623,31 @@ function theme_chado_add_node_form_dbxrefs_table($variables) {
     }
   }
 
-  return render($element['save_warning']) . theme('table', array(
-    'header' => $header,
-    'rows' => $rows
-  ));
+  return render($element['save_warning']) . theme('table', [
+      'header' => $header,
+      'rows' => $rows,
+    ]);
 }
 
 /**
  * This function is used in a hook_insert, hook_update for a node form
- * when the additional_dbxrefs form has been added to the form.  It retrieves all of the dbxrefs
- * and returns them in an array of the format:
+ * when the additional_dbxrefs form has been added to the form.  It retrieves
+ * all of the dbxrefs and returns them in an array of the format:
  *
  *   $dbxefs[<db_id>][<version>][<dbxref_id>] = <accession>
  *
- * This array can then be used for inserting or updating dbxrefs using the API call
- * tripal_hook_insert_dbxref()
+ * This array can then be used for inserting or updating dbxrefs using the API
+ * call tripal_hook_insert_dbxref()
  *
  * @param $node
  *
  * @return
  *   A dbxref array
  *
- *  @ingroup tripal_legacy_chado_node_api
+ * @ingroup tripal_legacy_chado_node_api
  */
 function chado_retrieve_node_form_dbxrefs($node) {
-  $dbxrefs = array();
+  $dbxrefs = [];
 
   if (isset($node->dbxref_table)) {
     foreach ($node->dbxref_table as $db_id => $elements) {
@@ -643,18 +664,23 @@ function chado_retrieve_node_form_dbxrefs($node) {
 }
 
 /**
- * This function is used in hook_insert or hook_update and handles inserting of any new
- * dbxrefs and creation of links between those dbxrefs and node content
+ * This function is used in hook_insert or hook_update and handles inserting of
+ * any new dbxrefs and creation of links between those dbxrefs and node content
  *
  * @param $node
  *    The node passed into hook_insert & hook_update
  * @param $details
- *   - linking_table: the name of the _dbxref linking table (ie: feature_dbxref)
- *   - foreignkey_name: the name of the foreign key used to link to the node content (ie: feature_id)
- *   - foreignkey_value: the value of the foreign key (ie: 445, if there exists a feature where feature_id=445)
+ *   - linking_table: the name of the _dbxref linking table (ie:
+ *   feature_dbxref)
+ *   - foreignkey_name: the name of the foreign key used to link to the node
+ *   content (ie: feature_id)
+ *   - foreignkey_value: the value of the foreign key (ie: 445, if there exists
+ *   a feature where feature_id=445)
  * @param $retrieved_dbxrefs
- *   An array of databa references from chado_retrieve_node_form_dbxrefs($node).
- *   This can be used if you need special handling for some of the database references
+ *   An array of databa references from
+ *   chado_retrieve_node_form_dbxrefs($node).
+ *   This can be used if you need special handling for some of the database
+ *   references
  *
  * @ingroup tripal_legacy_chado_node_api
  */
@@ -666,7 +692,7 @@ function chado_update_node_form_dbxrefs($node, $details, $retrieved_dbxrefs = FA
 
   if (isset($node->dbxref_table) AND ($foreignkey_value > 0)) {
     // First remove existing dbxref links
-    chado_delete_record($linking_table, array($foreignkey_name => $foreignkey_value));
+    chado_delete_record($linking_table, [$foreignkey_name => $foreignkey_value]);
 
     // Add back in dbxref links and insert dbxrefs as needed
     if ($retrieved_dbxrefs) {
@@ -679,14 +705,14 @@ function chado_update_node_form_dbxrefs($node, $details, $retrieved_dbxrefs = FA
       foreach ($versions as $version => $elements) {
         foreach ($elements as $dbxref_id => $accession) {
           // If there is no dbxref then we have to create that first
-          if (preg_match('/^TEMP/',$dbxref_id)) {
+          if (preg_match('/^TEMP/', $dbxref_id)) {
             $version = ($version == 'NONE') ? '' : $version;
-            $success = tripal_insert_dbxref(array(
+            $success = tripal_insert_dbxref([
               'db_id' => $db_id,
               'accession' => $accession,
               'version' => $version,
-              'description' => NULL
-            ));
+              'description' => NULL,
+            ]);
             if ($success) {
               $dbxref_id = $success->dbxref_id;
             }
@@ -697,13 +723,13 @@ function chado_update_node_form_dbxrefs($node, $details, $retrieved_dbxrefs = FA
 
           // add _dbxref linker
           if ($dbxref_id) {
-            if (preg_match('/(\w+)_dbxref/',$linking_table,$matches)) {
+            if (preg_match('/(\w+)_dbxref/', $linking_table, $matches)) {
               $base_table = $matches[1];
 
               $success_link = tripal_associate_dbxref(
                 $base_table,
                 $foreignkey_value,
-                array('dbxref_id' => $dbxref_id)
+                ['dbxref_id' => $dbxref_id]
               );
             }
           }

File diff suppressed because it is too large
+ 312 - 285
legacy/tripal_core/api/tripal_core.chado_nodes.properties.api.inc


File diff suppressed because it is too large
+ 330 - 299
legacy/tripal_core/api/tripal_core.chado_nodes.relationships.api.inc


File diff suppressed because it is too large
+ 340 - 302
legacy/tripal_core/api/tripal_core.chado_nodes.title_and_path.inc


+ 9 - 8
legacy/tripal_core/api/tripal_core.tripal_variables.api.inc

@@ -48,8 +48,8 @@ function tripal_add_node_variable($nid, $name, $value, $rank = 0) {
       // rank is already used then don't continue.
       if ($rank > 0 and $rank == $value->rank) {
         tripal_report_error('tripal_core', TRIPAL_ERROR,
-            "The rank for the term, '$term', is already used for node $nid. " .
-            "Cannot add the variable.", array());
+          "The rank for the term, '$term', is already used for node $nid. " .
+          "Cannot add the variable.", []);
         return FALSE;
       }
       if ($value->rank > $max_rank) {
@@ -61,13 +61,13 @@ function tripal_add_node_variable($nid, $name, $value, $rank = 0) {
 
   // Add the new variable.
   $node_variable_id = db_insert('tripal_node_variables')
-    ->fields(array(
+    ->fields([
       'variable_id' => $variable->variable_id,
       'nid' => $nid,
       'value' => $value,
-      'rank' => $rank
-     ))
-     ->execute();
+      'rank' => $rank,
+    ])
+    ->execute();
   return $node_variable_id;
 }
 
@@ -84,11 +84,12 @@ function tripal_add_node_variable($nid, $name, $value, $rank = 0) {
  *   Optional.  The name of the variable.
  * @param $rank
  *   Optional.  The rank of the variable to retreive.
+ *
  * @return
  *   An array of variable objects.
  */
 function tripal_get_node_variables($nid, $name = '', $rank = '') {
-  $variables = array();
+  $variables = [];
   if (!$nid) {
     return $variables;
   }
@@ -105,7 +106,7 @@ function tripal_get_node_variables($nid, $name = '', $rank = '') {
   $results = $query->execute();
 
   // Build the  variables array and return it.
-  while($variable = $results->fetchObject()) {
+  while ($variable = $results->fetchObject()) {
     $variables[] = $variable;
   }
   return $variables;

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

@@ -10,24 +10,24 @@
  * @ingroup tripal_legacy_core
  */
 function tripal_core_element_info() {
-  $elements = array();
+  $elements = [];
 
-  $elements['file_upload_combo'] = array(
+  $elements['file_upload_combo'] = [
     '#input' => TRUE,
-    '#process' => array('expand_file_upload_combo'),
-    '#value_callback' =>'file_upload_combo_value_callback',
+    '#process' => ['expand_file_upload_combo'],
+    '#value_callback' => 'file_upload_combo_value_callback',
     '#theme' => 'theme_file_upload_combo',
-    '#theme_wrappers' => array('form_element'),
-  );
+    '#theme_wrappers' => ['form_element'],
+  ];
 
-  $elements['sequence_combo'] = array(
+  $elements['sequence_combo'] = [
     '#input' => TRUE,
-    '#process' => array('expand_sequence_combo'),
+    '#process' => ['expand_sequence_combo'],
     '#value_callback' => 'sequence_combo_value_callback',
     '#theme' => 'theme_sequence_combo',
-    '#theme_wrappers' => array('form_element'),
+    '#theme_wrappers' => ['form_element'],
     '#tree' => TRUE,
-  );
+  ];
 
   return $elements;
 }
@@ -41,11 +41,11 @@ function expand_file_upload_combo($element, $form_state, $complete_form) {
 
   // set the default values for each field
   if (empty($element['#value'])) {
-    $element['#value'] = array(
+    $element['#value'] = [
       'items' => '',
       'items_file' => '',
       'file_path' => '',
-    );
+    ];
   }
 
   $element['#tree'] = TRUE;
@@ -53,27 +53,27 @@ function expand_file_upload_combo($element, $form_state, $complete_form) {
   // add items text area element
   $parents = $element['#parents'];
   $parents[] = 'items';
-  $element['items'] = array(
+  $element['items'] = [
     '#type' => 'textarea',
     '#default_value' => (isset($element['#value']['items'])) ? $element['#value']['items'] : '',
-  );
+  ];
 
   // add file upload element
   $parents = $element['#parents'];
   $parents[] = 'items_file';
-  $element['items_file'] = array(
+  $element['items_file'] = [
     '#type' => 'file',
-    '#title' =>  'File upload',
+    '#title' => 'File upload',
     '#default_value' => (isset($element['#value']['items_file'])) ? $element['#value']['items_file'] : '',
-  );
+  ];
 
   // add hidden elelment
   $parents = $element['#parents'];
   $parents[] = 'file_path';
-  $element['file_path'] = array(
+  $element['file_path'] = [
     '#type' => 'hidden',
     '#default_value' => (isset($element['#value']['file_path'])) ? $element['#value']['file_path'] : '',
-  );
+  ];
 
   return $element;
 }
@@ -102,7 +102,7 @@ function theme_file_upload_combo($variables) {
  * @ingroup tripal_legacy_core
  */
 function file_upload_combo_value_callback($element, $input = FALSE, &$form_state) {
-  $values = array();
+  $values = [];
 
   if ($input == FALSE) {
     if (!empty($element['#default_value'])) {
@@ -114,10 +114,10 @@ function file_upload_combo_value_callback($element, $input = FALSE, &$form_state
   }
 
   // get the items in the textbox
-  $items =  $input['items'];
+  $items = $input['items'];
   if ($items) {
     // split on new line or comma
-    $vals  = preg_split("/[\n,]+/", $items);
+    $vals = preg_split("/[\n,]+/", $items);
     // iterate through the values and trim surrounding space
     foreach ($vals as $i => $value) {
       $values[] = trim($value);
@@ -125,7 +125,7 @@ function file_upload_combo_value_callback($element, $input = FALSE, &$form_state
   }
 
   // merge any items from the file upload
-  $file = file_save_upload($element['#name'], array());
+  $file = file_save_upload($element['#name'], []);
   if ($file) {
     $file_path = $file->uri;
 
@@ -139,7 +139,7 @@ function file_upload_combo_value_callback($element, $input = FALSE, &$form_state
       $items = trim($line);
 
       // split on new line or comma
-      $vals  = preg_split("/[\n,]+/", $items);
+      $vals = preg_split("/[\n,]+/", $items);
       // iterate through the values and trim surrounding space
       foreach ($vals as $i => $value) {
         $values[] = trim($value);
@@ -163,10 +163,10 @@ function expand_sequence_combo($element, $form_state, $complete_form) {
 
   // set the default values for each field
   if (empty($element['#value'])) {
-    $element['#value'] = array(
+    $element['#value'] = [
       'upstream' => '',
       'downstream' => '',
-    );
+    ];
   }
 
   $element['#tree'] = TRUE;
@@ -174,22 +174,22 @@ function expand_sequence_combo($element, $form_state, $complete_form) {
   // add the upstream box
   $parents = $element['#parents'];
   $parents[] = 'upstream';
-  $element['upstream'] = array(
-     '#type' => 'textfield',
-     '#title' => t('Get Upstream Bases'),
-     '#description' => t('Specify the number of upstream bases to include in the sequence'),
-     '#default_value' => $element['#value']['upstream'],
-  );
+  $element['upstream'] = [
+    '#type' => 'textfield',
+    '#title' => t('Get Upstream Bases'),
+    '#description' => t('Specify the number of upstream bases to include in the sequence'),
+    '#default_value' => $element['#value']['upstream'],
+  ];
   // add the downstream box
   $parents = $element['#parents'];
   $parents[] = 'downstream';
-  $element['downstream'] = array(
-     '#type' => 'textfield',
-     '#prefix' => '<br>',
-     '#title' => t('Get Downstream Bases'),
-     '#description' => t('Specify the number of downstream bases to include in the sequence'),
-     '#default_value' => $element['#value']['downstream'],
-  );
+  $element['downstream'] = [
+    '#type' => 'textfield',
+    '#prefix' => '<br>',
+    '#title' => t('Get Downstream Bases'),
+    '#description' => t('Specify the number of downstream bases to include in the sequence'),
+    '#default_value' => $element['#value']['downstream'],
+  ];
   return $element;
 }
 

+ 87 - 71
legacy/tripal_core/includes/tripal_core.search.inc

@@ -9,26 +9,27 @@
 /**
  * Implements hook_search_include_chado_fields().
  *
- * This hook allows Tripal Admin/modules to specify which chado fields should be indexed
- * for searching in a simple manner.
+ * This hook allows Tripal Admin/modules to specify which chado fields should
+ * be indexed for searching in a simple manner.
  *
  * @return
- *   An array of chado fields you would like available for indexing. Each element should
- *   be the name of the table followed by the field and separated by a period. For example.
- *   feature.uniquename to indicate the uniquename field from the feature table.
+ *   An array of chado fields you would like available for indexing. Each
+ *   element should be the name of the table followed by the field and
+ *   separated by a period. For example. feature.uniquename to indicate the
+ *   uniquename field from the feature table.
  */
 function tripal_core_search_include_chado_fields() {
-  return array(
+  return [
     'organism.genus',
     'organism.species',
-  );
+  ];
 }
 
 /**
  * Implements hook_entity_property_info_alter().
  *
- * This is where we actually add the properties to the node entity in order to indicate
- * which chado fields should be indexed.
+ * This is where we actually add the properties to the node entity in order to
+ * indicate which chado fields should be indexed.
  */
 function tripal_core_entity_property_info_alter(&$info) {
 
@@ -60,21 +61,21 @@ function tripal_core_entity_property_info_alter(&$info) {
         $machine_name = $n['chado_node_api']['base_table'] . '.' . $field_name;
 
         // Try to create a readable label.
-        $label = ucwords(str_replace(array('.','_'),' ',$machine_name));
+        $label = ucwords(str_replace(['.', '_'], ' ', $machine_name));
 
         // We want to add all name fields and any fields previously indicated to be indexed.
         if (preg_match('/name/', $field_name) OR in_array($machine_name, $fields_to_include)) {
 
-          if (!isset($info['node']['bundles'][ $n['base'] ]['properties'][$machine_name])) {
-            $info['node']['bundles'][ $n['base'] ]['properties'][$machine_name] = array(
+          if (!isset($info['node']['bundles'][$n['base']]['properties'][$machine_name])) {
+            $info['node']['bundles'][$n['base']]['properties'][$machine_name] = [
               'label' => $label,
               'description' => (isset($details['description'])) ? $details['description'] : '',
               'type' => ($details['type'] == 'varchar') ? 'text' : $details['type'],
               'schema field' => '[' . $machine_name . ']',
               // The following getter callback is a generic function that can retrieve
               // values for any chado field.
-              'getter callback' => 'tripal_search_chado_token_getter_callback'
-            );
+              'getter callback' => 'tripal_search_chado_token_getter_callback',
+            ];
           }
         }
       }
@@ -90,7 +91,7 @@ function tripal_core_entity_property_info_alter(&$info) {
 
           // Try to create a readable label.
           $label = $table . ' (' . $machine_name . ')';
-          if (preg_match('/(\w+)_id/',$left_field,$matches)) {
+          if (preg_match('/(\w+)_id/', $left_field, $matches)) {
             // Key only field.
             $key_label = ucwords(str_replace('_', ' ', $matches[1]));
 
@@ -106,7 +107,7 @@ function tripal_core_entity_property_info_alter(&$info) {
           // First, create the key version. This is best used for facets since it
           // won't/can't be tokenized along with the other fields. This will be shared
           // among node types to facillitate use as a facet.
-          $info['node']['properties'][$table . '.' . $right_field .' key'] = array(
+          $info['node']['properties'][$table . '.' . $right_field . ' key'] = [
             'label' => $key_label . ' (All Content Types)',
             'description' => (isset($field_details['description'])) ? $field_details['description'] : '',
             'type' => 'text',
@@ -116,23 +117,23 @@ function tripal_core_entity_property_info_alter(&$info) {
             'schema field' => $format,
             // The following getter callback is a generic function that can retrieve
             // values for any chado foreign key.
-            'getter callback' => 'tripal_search_chado_token_across_nodetypes_getter_callback'
-          );
+            'getter callback' => 'tripal_search_chado_token_across_nodetypes_getter_callback',
+          ];
 
           $pretoken = '[' . $n['chado_node_api']['base_table'] . '.' . $left_field . '>' . $table . '.' . $right_field . ']';
           $format = chado_node_get_readable_format($pretoken);
 
           // Add a more readable version that will be tokenized so users can
           // search for fruitfly and get all features with that as an organism.
-          $info['node']['bundles'][ $n['base'] ]['properties'][$machine_name .' expanded'] = array(
+          $info['node']['bundles'][$n['base']]['properties'][$machine_name . ' expanded'] = [
             'label' => $label . ' (Expanded)',
             'description' => (isset($field_details['description'])) ? $field_details['description'] : '',
             'type' => 'text',
             'schema field' => $format,
             // The following getter callback is a generic function that can retrieve
             // values for any chado foreign key.
-            'getter callback' => 'tripal_search_chado_token_getter_callback'
-          );
+            'getter callback' => 'tripal_search_chado_token_getter_callback',
+          ];
         }
       }
     }
@@ -143,32 +144,40 @@ function tripal_core_entity_property_info_alter(&$info) {
 }
 
 /**
- * Allows tripal admin to alter entity property information after it has. This is currently
- * being used to indicate chado fields to be indexed for search.
+ * Allows tripal admin to alter entity property information after it has. This
+ * is currently being used to indicate chado fields to be indexed for search.
  *
- * NOTE: If you simply need to add a field to be indexed, use hook_search_include_chado_fields()
- * which provides the much easier method of simply listing fields to include.
+ * NOTE: If you simply need to add a field to be indexed, use
+ * hook_search_include_chado_fields() which provides the much easier method of
+ * simply listing fields to include.
  *
- * This function is most useful if you want to change the way the value is retrieved
- * (done by changing the 'getter callback') or add your own custom computed field.
+ * This function is most useful if you want to change the way the value is
+ * retrieved
+ * (done by changing the 'getter callback') or add your own custom computed
+ * field.
  */
-function hook_tripal_search_properties_alter(&$info) { }
+function hook_tripal_search_properties_alter(&$info) {
+}
 
 /**
  * Implements a getter callback for chado token formats.
  *
  * A chado token format is a string containing chado tokens.
  *
- * Chado tokens are expected to follow the format of tokens auto-generated using
- *   chado_node_generate_tokens(). For example, [feature.uniquename] indicates you
- *   should return the uniquename of a feature node and [feature.organism_id>organism.species]
- *   indicates you should return the organism genus of the feature node.
+ * Chado tokens are expected to follow the format of tokens auto-generated
+ * using
+ *   chado_node_generate_tokens(). For example, [feature.uniquename] indicates
+ * you should return the uniquename of a feature node and
+ * [feature.organism_id>organism.species] indicates you should return the
+ * organism genus of the feature node.
  *
- * The chado token format must be stored in the 'schema field' when defining the property in
- *  hook_entity_property_info() in order for this getter to work.
+ * The chado token format must be stored in the 'schema field' when defining
+ * the property in hook_entity_property_info() in order for this getter to
+ * work.
  *
  * @param $data
- *   The entity object (in our case the node we need to retrieve feature properties for).
+ *   The entity object (in our case the node we need to retrieve feature
+ *   properties for).
  * @param $options
  * @param $field_name
  *   The machine name for the entity property.
@@ -185,14 +194,16 @@ function tripal_search_chado_token_getter_callback($data, $options, $field_name,
       $format = $info['schema field'];
 
       // Determine our base table so we know if this is even the right node type.
-      if (preg_match('/\[(\w+)\.(\w+)/',$format, $matches)) {
+      if (preg_match('/\[(\w+)\.(\w+)/', $format, $matches)) {
         $base_table = $matches[1];
         $field_name = $matches[2];
 
         // For some weird reason nodes of all types are trying to get a value for fields
         // that we defined as specific to a given node type (ie: bundle). As such we need
         // this check here to ensure this field is actually for this node type.
-        if (!isset($data->{$base_table})) return NULL;
+        if (!isset($data->{$base_table})) {
+          return NULL;
+        }
 
         $format = tripal_core_get_token_value_for_property($base_table, $field_name, $format, $data, $info);
         return $format;
@@ -203,7 +214,7 @@ function tripal_search_chado_token_getter_callback($data, $options, $field_name,
           'tripal_search',
           TRIPAL_ERROR,
           'Unable to extract the base table from the format (:format) for :field because it didn\'t match the expected format: [tablename.field...',
-          array(':field' => $field_name, ':format' => $format)
+          [':field' => $field_name, ':format' => $format]
         );
         return NULL;
       }
@@ -213,7 +224,7 @@ function tripal_search_chado_token_getter_callback($data, $options, $field_name,
         'tripal_search',
         TRIPAL_ERROR,
         'Unable to get value for :field because the schema field was not set.',
-        array(':field' => $field_name)
+        [':field' => $field_name]
       );
       return NULL;
     }
@@ -224,7 +235,8 @@ function tripal_search_chado_token_getter_callback($data, $options, $field_name,
  * Implements a getter callback for foreign keys collon between content types.
  *
  * @param $data
- *   The entity object (in our case the node we need to retrieve feature properties for).
+ *   The entity object (in our case the node we need to retrieve feature
+ *   properties for).
  * @param $options
  * @param $field_name
  *   The machine name for the entity property.
@@ -239,7 +251,7 @@ function tripal_search_chado_token_across_nodetypes_getter_callback($data, $opti
   // First, make sure this is a chado node.
   // Assumption #1: All chado node types are prefixed with chado_
   if (isset($data->nid)) {
-    if (preg_match('/^chado_(\w+)/',$data->type,$matches)) {
+    if (preg_match('/^chado_(\w+)/', $data->type, $matches)) {
       if (isset($info['schema field'])) {
 
         // Assumption #2: The base table is the suffix of the node type.
@@ -258,7 +270,7 @@ function tripal_search_chado_token_across_nodetypes_getter_callback($data, $opti
           'tripal_search',
           TRIPAL_ERROR,
           'Unable to extract the base table from the format (:format) for :field because it didn\'t match the expected format: [tablename.field...',
-          array(':field' => $field_name, ':format' => $format)
+          [':field' => $field_name, ':format' => $format]
         );
       }
     }
@@ -267,7 +279,7 @@ function tripal_search_chado_token_across_nodetypes_getter_callback($data, $opti
         'tripal_search',
         TRIPAL_ERROR,
         'Unable to get value for :field because the schema field was not set.',
-        array(':field' => $field_name)
+        [':field' => $field_name]
       );
     }
   }
@@ -290,25 +302,27 @@ function tripal_core_get_token_value_for_property($base_table, $field_name, $for
         'tripal_search',
         TRIPAL_NOTICE,
         'Returned static text for :field since there were no tokens in the supplied format: :format',
-        array(':field' => $field_name, ':format' => $format)
+        [':field' => $field_name, ':format' => $format]
       );
       return $format;
     }
 
     // Get the value of each token.
-    $null_tokens = array();
+    $null_tokens = [];
     foreach ($used_tokens as $token) {
-      $token_info = array(
-          'name' => $info['label'],
-          'table' => $base_table,
-          'field' => $field_name,
-          'token' => $token,
-          'description' => $info['description'],
-          'location' => chado_node_get_location_from_token($token),
-      );
-
-      $value = chado_get_token_value($token_info, $data, array('supress_errors' => TRUE));
-      if (empty($value)) $null_tokens[] = $token;
+      $token_info = [
+        'name' => $info['label'],
+        'table' => $base_table,
+        'field' => $field_name,
+        'token' => $token,
+        'description' => $info['description'],
+        'location' => chado_node_get_location_from_token($token),
+      ];
+
+      $value = chado_get_token_value($token_info, $data, ['supress_errors' => TRUE]);
+      if (empty($value)) {
+        $null_tokens[] = $token;
+      }
 
       // And sub it in to the format.
       $format = str_replace($token, $value, $format);
@@ -316,14 +330,16 @@ function tripal_core_get_token_value_for_property($base_table, $field_name, $for
 
     // If none of the tokens had values then this node doesn't have this field.
     // As such we return null so the search api doesn't bother indexing an empty format.
-    if (sizeof($used_tokens) == sizeof($null_tokens)) return NULL;
+    if (sizeof($used_tokens) == sizeof($null_tokens)) {
+      return NULL;
+    }
   }
   else {
     tripal_report_error(
       'tripal_search',
       TRIPAL_NOTICE,
       'Returned static text for :field since there were no tokens of a recognized format in the supplied format: :format',
-      array(':field' => $field_name, ':format' => $format)
+      [':field' => $field_name, ':format' => $format]
     );
   }
 
@@ -334,12 +350,12 @@ function tripal_core_get_token_value_for_property($base_table, $field_name, $for
  * Implements hook_modules_enabled().
  *
  * This hook is called when ANY module is enabled. This allows us to update the
- * the search api "Default node index" when any Tripal module is enabled thus allowing us
- * to catch new node types right after they're created.
+ * the search api "Default node index" when any Tripal module is enabled thus
+ * allowing us to catch new node types right after they're created.
  */
 function tripal_core_modules_enabled($modules) {
   if (module_exists('search_api')) {
-    $index_enabled = db_query('SELECT enabled FROM search_api_index WHERE machine_name=:name', array(':name' => 'default_node_index'))->fetchField();
+    $index_enabled = db_query('SELECT enabled FROM search_api_index WHERE machine_name=:name', [':name' => 'default_node_index'])->fetchField();
     if ($index_enabled) {
       tripal_search_update_default_index();
     }
@@ -355,14 +371,14 @@ function tripal_core_modules_enabled($modules) {
  * This function should be called whenever new nodes might have been
  * added to ensure that their fields are added as well.
  *
- * We should only modify the default node index if it has no database service yet.
- * That way we ensure we don't override user changes!
+ * We should only modify the default node index if it has no database service
+ * yet. That way we ensure we don't override user changes!
  */
 function tripal_search_update_default_index() {
 
   // First we need the index object for the "Default node index".
   $index_id = db_query('SELECT id FROM search_api_index WHERE machine_name=:name',
-    array(':name' => 'default_node_index'))->fetchField();
+    [':name' => 'default_node_index'])->fetchField();
   if (!$index_id) {
     // ERROR
     return FALSE;
@@ -370,7 +386,7 @@ function tripal_search_update_default_index() {
   $index = search_api_index_load($index_id);
 
   // Collect all the fields already added to the search index.
-  $changes = array('options' => $index->options);
+  $changes = ['options' => $index->options];
 
   // Now we only want to update the index if it's both enabled and has no server indicated.
   // That way we can be reasonably sure that it was been untouched by admin users.
@@ -394,7 +410,7 @@ function tripal_search_update_default_index() {
 
             // Furthermore if this is a name then we want to add a boost to ensure it carries
             // more weight in the search results.
-            if (preg_match('/name/',$field_name)) {
+            if (preg_match('/name/', $field_name)) {
               $changes['options']['fields'][$field_name]['boost'] = '3.0';
             }
           }
@@ -406,18 +422,18 @@ function tripal_search_update_default_index() {
     // We also want to enable highlighting to ensure an excerpt is generated since this
     // will be used in the default search view distributed with Tripal.
     if (!isset($index->options['processors']['search_api_highlighting'])) {
-      $changes['options']['processors']['search_api_highlighting'] = array(
+      $changes['options']['processors']['search_api_highlighting'] = [
         'status' => 1,
         'weight' => 35,
-        'settings' => array(
+        'settings' => [
           'prefix' => '<strong>',
           'suffix' => '</strong>',
           'excerpt' => 1,
           'excerpt_length' => 256,
-          'exclude_fields' => array(),
+          'exclude_fields' => [],
           'highlight' => 'always',
-        ),
-      );
+        ],
+      ];
     }
     else {
       $changes['options']['processors']['search_api_highlighting']['status'] = 1;

+ 103 - 104
legacy/tripal_core/includes/tripal_core.toc.inc

@@ -11,18 +11,18 @@ function tripal_core_node_toc_form($form, &$form_state, $node) {
 
   $form["#tree"] = TRUE;
 
-  $form["instructions"] = array(
+  $form["instructions"] = [
     '#type' => 'fieldset',
     '#collapsed' => TRUE,
     '#collapsible' => TRUE,
     '#title' => 'Instructions',
-  );
+  ];
   $admin_link = l(
     $type_info->name . " TOC administrative page",
     "admin/tripal/legacy/" . $type_info->module . "/" . $node->type . "toc",
-    array('attributes' => array('target' => '_blank'))
+    ['attributes' => ['target' => '_blank']]
   );
-  $form["instructions"]["main"] = array(
+  $form["instructions"]["main"] = [
     '#markup' => '<p>' . t("Below is a list of the titles of
       content panes that can appear on this page.  These titles appear in the
       the following order in the Table of Contents (TOC). You may rename
@@ -32,12 +32,12 @@ function tripal_core_node_toc_form($form, &$form_state, $node) {
       '<p>' . t('The list below shows all possible content panes that can appear.
       However, those without content are automatically hidden and do not
       appear in the TOC.' . '</p>'),
-  );
+  ];
 
-  $form['node'] = array(
+  $form['node'] = [
     '#type' => 'value',
     '#value' => $node,
-  );
+  ];
 
   // Get the content array for this node, then pass it through the
   // tripal_core_node_view_alter which generates the TOC.  After that
@@ -51,7 +51,7 @@ function tripal_core_node_toc_form($form, &$form_state, $node) {
   tripal_core_node_view_alter($build);
 
   // Iterate through the built items and add form elemetns for each one.
-  foreach(element_children($build) as $key) {
+  foreach (element_children($build) as $key) {
     $element = $build[$key];
 
     if (array_key_exists('#tripal_toc_id', $element)) {
@@ -65,102 +65,103 @@ function tripal_core_node_toc_form($form, &$form_state, $node) {
       // interface that created the link.
       $is_link = array_key_exists('#is_link', $element) ? $element['#is_link'] : FALSE;
       if (!$is_link) {
-        $form['toc_items'][$toc_id]['title'] = array(
+        $form['toc_items'][$toc_id]['title'] = [
           '#type' => 'textfield',
           '#default_value' => $toc_title,
-        );
+        ];
       }
       else {
-        $form['toc_items'][$toc_id]['title'] = array(
+        $form['toc_items'][$toc_id]['title'] = [
           '#markup' => '<i>link title:</i> ' . $toc_title,
           '#value' => $toc_title,
-        );
+        ];
       }
-      $form['toc_items'][$toc_id]['hide'] = array(
+      $form['toc_items'][$toc_id]['hide'] = [
         '#type' => 'checkbox',
         '#default_value' => $toc_hide,
-      );
-      $form['toc_items'][$toc_id]['weight'] = array(
+      ];
+      $form['toc_items'][$toc_id]['weight'] = [
         '#type' => 'textfield',
         '#default_value' => $toc_weight,
-        '#attributes' => array(
-          'class' => array('tripal-node-toc-items-weights'),
-        ),
+        '#attributes' => [
+          'class' => ['tripal-node-toc-items-weights'],
+        ],
         '#size' => 5,
-      );
+      ];
     }
   }
   $form['toc_items']['#theme'] = 'tripal_node_toc_items_table';
 
-  $form['submit'] = array(
+  $form['submit'] = [
     '#type' => 'submit',
     '#name' => 'toc_submit',
     '#value' => t('Submit'),
-  );
-  $form['unset'] = array(
+  ];
+  $form['unset'] = [
     '#type' => 'submit',
     '#name' => 'toc_unset',
     '#value' => t('Unset Node Customizations'),
-  );
+  ];
 
   // Check to see if this node's TOC is specifically being managed.
   $sql = "SELECT count(*) FROM {tripal_toc} where nid = :nid";
-  $managed_items = db_query($sql, array(':nid' => $node->nid))->fetchField();
+  $managed_items = db_query($sql, [':nid' => $node->nid])->fetchField();
 
   if ($managed_items > 0) {
-    $form['is_managed'] = array(
+    $form['is_managed'] = [
       '#markup' => '<p><font color="red">' .
-      t('This page currently has customiations to the TOC.</font> This means
+        t('This page currently has customiations to the TOC.</font> This means
         that any customzations for the content type are overriden. Click the
         "Unset Node Customizations" button above to remove page-level
         customizations and default to the content type settings.') . '</p>',
-    );
+    ];
   }
 
 
   return $form;
 }
+
 /**
  *
  * @param $variables
  */
 function theme_tripal_node_toc_items_table($variables) {
   $elements = $variables['element'];
-  $toc_items = array();
+  $toc_items = [];
 
   // Sort the toc_items using a custom sort function. But we need to include
   // only the items we want in the table (exclude renderable stuff).
-  foreach(element_children($elements) as $key) {
+  foreach (element_children($elements) as $key) {
     $toc_items[] = $elements[$key];
   }
   usort($toc_items, 'theme_tripal_node_sort_toc_items');
 
   // Build the table header.
-  $headers = array('Content Pane Name', 'Hide', 'Weight');
+  $headers = ['Content Pane Name', 'Hide', 'Weight'];
 
   // Format the form elements as rows in the table.
-  $rows = array();
+  $rows = [];
   foreach ($toc_items as $key => $item) {
-    $rows[] = array(
-      'data' => array(
+    $rows[] = [
+      'data' => [
         drupal_render($item['title']),
         drupal_render($item['hide']),
         drupal_render($item['weight']),
-      ),
-      'class' => array('draggable'),
-    );
+      ],
+      'class' => ['draggable'],
+    ];
   }
 
   // Theme and return the table.
-  $table = array(
+  $table = [
     'header' => $headers,
     'rows' => $rows,
-    'attributes' => array("id" => 'tripal-node-toc-items-table'),
+    'attributes' => ["id" => 'tripal-node-toc-items-table'],
     'sticky' => TRUE,
     'caption' => t('Content Panes Available in the TOC'),
-    'colgroups' => array(),
+    'colgroups' => [],
     'empty' => t('There are no content panes for this page'),
-  );
+  ];
   drupal_add_tabledrag('tripal-node-toc-items-table', 'order', 'sibling', 'tripal-node-toc-items-weights');
   return theme_table($table);
 }
@@ -196,12 +197,13 @@ function tripal_core_node_toc_form_validate($form, &$form_state) {
     }
   }
 }
+
 /**
  * Implements hook_submit for the tripal_core_node_toc_form.
  */
 function tripal_core_node_toc_form_submit($form, &$form_state) {
   $toc_items = $form_state['values']['toc_items'];
-  $node      = $form_state['values']['node'];
+  $node = $form_state['values']['node'];
 
   if ($form_state['clicked_button']['#name'] == "toc_submit") {
     $transaction = db_transaction();
@@ -214,19 +216,18 @@ function tripal_core_node_toc_form_submit($form, &$form_state) {
       // Second add in any new settings for this node
       foreach ($toc_items as $toc_id => $item) {
         db_insert('tripal_toc')
-          ->fields(array(
+          ->fields([
             'node_type' => $node->type,
             'key' => $toc_id,
             'title' => array_key_exists('title', $item) ? $item['title'] : '',
             'weight' => $item['weight'],
             'nid' => $node->nid,
             'hide' => $item['hide'],
-          ))
+          ])
           ->execute();
       }
       drupal_set_message("TOC changes successfully applied to this node only.");
-    }
-    catch (Exception $e) {
+    } catch (Exception $e) {
       $transaction->rollback();
       drupal_set_message("Failed to apply TOC changes.", "error");
     }
@@ -240,8 +241,7 @@ function tripal_core_node_toc_form_submit($form, &$form_state) {
         ->execute();
 
       drupal_set_message("TOC is no longer customized specifically for this page. Now using the content type settings.");
-    }
-    catch (Exception $e) {
+    } catch (Exception $e) {
       $transaction->rollback();
       drupal_set_message("Failed to apply TOC changes.", "error");
     }
@@ -281,7 +281,7 @@ function tripal_core_node_view_build_toc(&$build) {
 
   $cache = cache_get("theme_registry:$theme", 'cache');
   $node = $build['#node'];
-  $toc = array();
+  $toc = [];
   $toc_html = '';
 
   // If we are looking at a Tripal node template then we want to
@@ -291,7 +291,7 @@ function tripal_core_node_view_build_toc(&$build) {
 
     // Iterate through all the elements of the $build array and for those
     // that are wanting to provide content for this node.
-    $markup = array();
+    $markup = [];
     foreach ($build as $key => $value) {
       $value = $build[$key];
 
@@ -358,7 +358,7 @@ function tripal_core_node_view_build_toc(&$build) {
           // Add the link to the TOC
           $parts = explode("|", $element['#markup']);
           if (count($parts) == 2) {
-            $toc[$weight][$parts[0]] = "<div id=\"$toc_item_id\" class=\"tripal_toc_list_item\">" . l($parts[0], $parts[1], array('attributes' => array('target' => '_blank'))) . "</div>";
+            $toc[$weight][$parts[0]] = "<div id=\"$toc_item_id\" class=\"tripal_toc_list_item\">" . l($parts[0], $parts[1], ['attributes' => ['target' => '_blank']]) . "</div>";
           }
           else {
             $toc[$weight][$parts[0]] = "<div id=\"$toc_item_id\" class=\"tripal_toc_list_item\">" . $element['#markup'] . "</div>";
@@ -446,8 +446,8 @@ function tripal_core_node_view_build_toc(&$build) {
       // INITIALIZE THE CONTENT VARIABLES
       //-----------------------
       $toc_item_title = $key;
-      $toc_item_id    = $key;
-      $toc_item_link  = '';
+      $toc_item_id = $key;
+      $toc_item_link = '';
       $weight = 0;
       $hide = 0;
 
@@ -508,16 +508,16 @@ function tripal_core_node_view_build_toc(&$build) {
       }
 
       // Setup the content array for this element
-      $build[$key] = array(
+      $build[$key] = [
         '#markup' => $markup,
         '#tripal_toc_id' => $toc_item_id,
         '#tripal_toc_title' => $toc_item_title,
         '#weight' => $weight,
         '#hide' => $hide,
-      );
+      ];
 
 
-        // if we still don't have markup then skip this one
+      // if we still don't have markup then skip this one
       if (!$markup) {
         continue;
       }
@@ -537,10 +537,10 @@ function tripal_core_node_view_build_toc(&$build) {
             customize the way the content above is presented.  Tripal provides a template
             file for each pane of content.  To customize, copy the template file to your
             site's default theme, edit then " .
-            l('clear the Drupal cache', 'admin/config/development/performance', array('attributes' => array('target' => '_blank'))) . ".
+            l('clear the Drupal cache', 'admin/config/development/performance', ['attributes' => ['target' => '_blank']]) . ".
             Currently, the content above is provided by this template: <br><br>$path",
             TRIPAL_INFO,
-            array('return_html' => 1)
+            ['return_html' => 1]
           );
         }
       }
@@ -602,7 +602,7 @@ function tripal_core_get_toc_overrides($nid, $key, $node_type, $mode) {
   if ($mode != "manage_type") {
     // First look to see if the node has customizations for this item.
     $toc_item_overrides = db_select('tripal_toc', 'tc')
-      ->fields('tc', array('title', 'weight', 'hide'))
+      ->fields('tc', ['title', 'weight', 'hide'])
       ->condition('key', $key)
       ->condition('nid', $nid)
       ->execute()
@@ -611,18 +611,18 @@ function tripal_core_get_toc_overrides($nid, $key, $node_type, $mode) {
       $override_title = $toc_item_overrides->title;
       $override_weight = $toc_item_overrides->weight;
       $override_hide = $toc_item_overrides->hide;
-      return array(
-        'title'  => $override_title,
+      return [
+        'title' => $override_title,
         'weight' => $override_weight,
-        'hide'   => $override_hide,
-      );
+        'hide' => $override_hide,
+      ];
     }
   }
 
   // If there are no specific node customizations then look to see if there
   // are customizations for this content type.
   $toc_item_overrides = db_select('tripal_toc', 'tc')
-    ->fields('tc', array('title', 'weight', 'hide'))
+    ->fields('tc', ['title', 'weight', 'hide'])
     ->condition('node_type', $node_type)
     ->condition('key', $key)
     ->isNull('nid')
@@ -634,11 +634,11 @@ function tripal_core_get_toc_overrides($nid, $key, $node_type, $mode) {
     $override_hide = $toc_item_overrides->hide;
   }
 
-  return array(
+  return [
     'title' => $override_title,
     'weight' => $override_weight,
     'hide' => $override_hide,
-  );
+  ];
 
 }
 
@@ -656,13 +656,13 @@ function tripal_core_content_type_toc_form($form, &$form_state, $content_type) {
   // Get a single node of this type so we can get all the possible content
   // for it.
   $sql = "SELECT nid FROM {node} WHERE type = :type LIMIT 1 OFFSET 0";
-  $nid = db_query($sql, array(':type' => $content_type))->fetchField();
+  $nid = db_query($sql, [':type' => $content_type])->fetchField();
   if (!$nid) {
-    $form["not_available"] = array(
+    $form["not_available"] = [
       '#markup' => t('Please sync at least one %type_name record. A node
           must exist before customizations to the Table of Contents (TOC) can
-          be performed.', array('%type_name' => $type_info->name)),
-    );
+          be performed.', ['%type_name' => $type_info->name]),
+    ];
     return $form;
   }
 
@@ -681,32 +681,32 @@ function tripal_core_content_type_toc_form($form, &$form_state, $content_type) {
   $build["#node"] = $node;
   tripal_core_node_view_alter($build);
 
-  $form["instructions"] = array(
+  $form["instructions"] = [
     '#type' => 'fieldset',
     '#collapsed' => TRUE,
     '#collapsible' => TRUE,
     '#title' => 'Instructions',
-  );
-  $form["instructions"]["main"] = array(
+  ];
+  $form["instructions"]["main"] = [
     '#markup' => '</p>' . t('Below is a list of the titles of
       content panes that can appear on all %type_name pages.  You may rename
       the titles or drag and drop them to change the order.  Content that appears
       only on a single page can not be ordered here, but must be ordered using
       the TOC tab on the page itself.  If a page has customized TOC settings
       then those settings will take precedent over these.',
-        array('%type_name' => $type_info->name)) . '</p>' .
-    '<p>' . t('The list below shows all possible content
+        ['%type_name' => $type_info->name]) . '</p>' .
+      '<p>' . t('The list below shows all possible content
       panes that can appear. However, those without content are automatically
       hidden and do not appear in the TOC.' . '</p>'),
-  );
+  ];
 
-  $form['content_type'] = array(
+  $form['content_type'] = [
     '#type' => 'value',
     '#value' => $content_type,
-  );
+  ];
 
   // Iterate through the built items and add form elemetns for each one.
-  foreach(element_children($build) as $key) {
+  foreach (element_children($build) as $key) {
     $element = $build[$key];
 
     if (array_key_exists('#tripal_toc_id', $element)) {
@@ -714,36 +714,36 @@ function tripal_core_content_type_toc_form($form, &$form_state, $content_type) {
       $toc_title = $element['#tripal_toc_title'];
       $toc_weight = $element['#weight'];
       $toc_hide = $element['#hide'];
-      $form['toc_items'][$toc_id]['title'] = array(
+      $form['toc_items'][$toc_id]['title'] = [
         '#type' => 'textfield',
         '#default_value' => $toc_title,
-      );
-      $form['toc_items'][$toc_id]['hide'] = array(
+      ];
+      $form['toc_items'][$toc_id]['hide'] = [
         '#type' => 'checkbox',
         '#default_value' => $toc_hide,
-      );
-      $form['toc_items'][$toc_id]['weight'] = array(
+      ];
+      $form['toc_items'][$toc_id]['weight'] = [
         '#type' => 'textfield',
         '#default_value' => $toc_weight,
-        '#attributes' => array(
-          'class' => array('tripal-node-toc-items-weights'),
-        ),
+        '#attributes' => [
+          'class' => ['tripal-node-toc-items-weights'],
+        ],
         '#size' => 5,
-      );
+      ];
     }
   }
   $form['toc_items']['#theme'] = 'tripal_node_toc_items_table';
 
-  $form['submit'] = array(
+  $form['submit'] = [
     '#type' => 'submit',
     '#name' => 'toc_submit',
     '#value' => t('Submit'),
-  );
-  $form['unset'] = array(
+  ];
+  $form['unset'] = [
     '#type' => 'submit',
     '#name' => 'toc_unset',
     '#value' => t('Reset to Defaults'),
-  );
+  ];
 
   return $form;
 }
@@ -762,11 +762,12 @@ function tripal_core_content_type_toc_form_validate($form, &$form_state) {
     }
   }
 }
+
 /**
  * Implements hook_submit for the tripal_core_node_toc_form.
  */
 function tripal_core_content_type_toc_form_submit($form, &$form_state) {
-  $toc_items    = $form_state['values']['toc_items'];
+  $toc_items = $form_state['values']['toc_items'];
   $content_type = $form_state['values']['content_type'];
 
   if ($form_state['clicked_button']['#name'] == "toc_submit") {
@@ -781,18 +782,17 @@ function tripal_core_content_type_toc_form_submit($form, &$form_state) {
       // Second add in any new settings for this node
       foreach ($toc_items as $toc_id => $item) {
         db_insert('tripal_toc')
-        ->fields(array(
-          'node_type' => $content_type,
-          'key' => $toc_id,
-          'title' => $item['title'],
-          'weight' => $item['weight'],
-          'hide' => $item['hide'],
-        ))
-        ->execute();
+          ->fields([
+            'node_type' => $content_type,
+            'key' => $toc_id,
+            'title' => $item['title'],
+            'weight' => $item['weight'],
+            'hide' => $item['hide'],
+          ])
+          ->execute();
       }
       drupal_set_message("TOC changes successfully applied to this content type.");
-    }
-    catch (Exception $e) {
+    } catch (Exception $e) {
       $transaction->rollback();
       drupal_set_message("Failed to apply TOC changes.", "error");
     }
@@ -807,8 +807,7 @@ function tripal_core_content_type_toc_form_submit($form, &$form_state) {
         ->execute();
 
       drupal_set_message("The TOC is reset to defaults for this content type.");
-    }
-    catch (Exception $e) {
+    } catch (Exception $e) {
       $transaction->rollback();
       drupal_set_message("Failed to apply TOC changes.", "error");
     }

+ 64 - 60
legacy/tripal_core/theme/templates/node--chado-generic.tpl.php

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

+ 5 - 3
legacy/tripal_core/theme/templates/tripal_core_jobs_help.tpl.php

@@ -1,3 +1,5 @@
-<p>The Tripal Jobs Management System provides a framework for Biological jobs to be run
-via the command-line in order to eliminate the problems associated with long running
-jobs in the web browser (ie: timeout errors).</p>
+<p>The Tripal Jobs Management System provides a framework for Biological jobs to
+    be run
+    via the command-line in order to eliminate the problems associated with long
+    running
+    jobs in the web browser (ie: timeout errors).</p>

+ 5 - 3
legacy/tripal_core/theme/templates/tripal_core_mviews_help.tpl.php

@@ -1,3 +1,5 @@
-<p>The Tripal Jobs Management System provides a framework for Biological jobs to be run
-via the command-line in order to eliminate the problems associated with long running
-jobs in the web browser (ie: timeout errors).</p>
+<p>The Tripal Jobs Management System provides a framework for Biological jobs to
+    be run
+    via the command-line in order to eliminate the problems associated with long
+    running
+    jobs in the web browser (ie: timeout errors).</p>

+ 84 - 84
legacy/tripal_core/tripal_core.drush.inc

@@ -45,107 +45,107 @@ function tripal_core_drush_help($command) {
  * @ingroup tripal_drush
  */
 function tripal_core_drush_command() {
-  $items = array();
+  $items = [];
 
-  $items['trp-clean-nodes'] = array(
+  $items['trp-clean-nodes'] = [
     'description' => dt('Removes orphaned Drupal nodes.'),
-    'arguments' => array(),
-    'examples' => array(
-      'Standard Example' => 'drush trp-clean-nodes table=feature'
-    ),
-    'options' => array(
-      'table' => array(
+    'arguments' => [],
+    'examples' => [
+      'Standard Example' => 'drush trp-clean-nodes table=feature',
+    ],
+    'options' => [
+      'table' => [
         'description' => dt('The name of the table that corresonds to the node type to ' .
           'clean up. (e.g organism, feature, stock, library, analysis, pub, etc.)'),
         'required' => TRUE,
-      ),
-    ),
-  );
+      ],
+    ],
+  ];
 
   // DEPRECATED COMMANDS. Deprecated as of Tripal v2.0-rc
-  $items['tripal-mview-update'] = array(
+  $items['tripal-mview-update'] = [
     'description' => dt('DEPRECATED. Please see: trp-refresh-mview.'),
-    'arguments' => array(),
-    'examples' => array(
+    'arguments' => [],
+    'examples' => [
       'By Materialized View ID' => 'drush tripal-update-mview --mview_id=5',
-      'By Table Name' => 'drush tripal-update-mview --table_name=organism_feature_count'
-    ),
-    'options' => array(
+      'By Table Name' => 'drush tripal-update-mview --table_name=organism_feature_count',
+    ],
+    'options' => [
       'mview_id' => dt('The ID of the materialized view to update'),
       'table_name' => dt('The name of the materialized view table to update.'),
-    ),
-    'aliases' => array('trpmv-up')
-  );
-  $items['tripal-jobs-current'] = array(
+    ],
+    'aliases' => ['trpmv-up'],
+  ];
+  $items['tripal-jobs-current'] = [
     'description' => dt('DEPRECATED. Please see: trp-get-currjob.'),
-    'arguments'   => array(),
-    'examples' => array(
+    'arguments' => [],
+    'examples' => [
       'Standard example' => 'drush tripal-jobs-current',
-    ),
-    'aliases' => array('trpjob-cur'),
-  );
-  $items['tripal-jobs-launch'] = array(
+    ],
+    'aliases' => ['trpjob-cur'],
+  ];
+  $items['tripal-jobs-launch'] = [
     'description' => dt('DEPRECATED. Please see: trp-run-jobs. '),
-    'examples' => array(
+    'examples' => [
       'Normal Job' => 'drush tripal-jobs-launch admin',
-      'Parallel Job' => 'drush tripal-jobs-launch admin --parallel=1'
-    ),
-    'arguments' => array(
+      'Parallel Job' => 'drush tripal-jobs-launch admin --parallel=1',
+    ],
+    'arguments' => [
       'username' => dt('The Drupal username under which the job should be run.  The permissions for this user will be used.'),
-    ),
-    'options' => array(
+    ],
+    'options' => [
       'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
       'job_id' => dt('Provide a job_id to run a specific job. Only jobs that have not been run already can be used'),
-    ),
-    'aliases' => array('trpjob-run')
-  );
-  $items['tripal-jobs-rerun'] = array(
+    ],
+    'aliases' => ['trpjob-run'],
+  ];
+  $items['tripal-jobs-rerun'] = [
     'description' => dt('DEPRECATED. Please see: trp-rerun-job. '),
-    'examples' => array(
+    'examples' => [
       'Normal Job' => 'drush tripal-jobs-rerun admin 2',
-      'Parallel Job' => 'drush tripal-jobs-rerun admin  2 --parallel=1'
-    ),
-    'arguments' => array(
+      'Parallel Job' => 'drush tripal-jobs-rerun admin  2 --parallel=1',
+    ],
+    'arguments' => [
       'username' => dt('The Drupal username under which the job should be run.  The permissions for this user will be used.'),
       'job_id' => dt('The job ID to run.'),
-    ),
-    'options' => array(
+    ],
+    'options' => [
       'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
-    ),
-    'aliases' => array('trpjob-rerun')
-  );
-  $items['tripal-chado-version'] = array(
+    ],
+    'aliases' => ['trpjob-rerun'],
+  ];
+  $items['tripal-chado-version'] = [
     'description' => dt('DEPRECATED. Please see: trp-get-cversion. '),
-    'arguments' => array(),
-    'examples' => array(
+    'arguments' => [],
+    'examples' => [
       'Standard Example' => 'drush tripal-chado-version',
-    ),
-    'aliases' => array('trpchado-ver')
-  );
-  $items['tripal-chadotable-desc'] = array(
+    ],
+    'aliases' => ['trpchado-ver'],
+  ];
+  $items['tripal-chadotable-desc'] = [
     'description' => dt('DEPRECATED. Please see: trp-get-table. '),
-    'arguments' => array(
+    'arguments' => [
       'table_name' => dt('The name of the chado table.'),
-    ),
-    'examples' => array(
-      'By Table Name' => 'drush tripal-chadotable-desc --table_name=feature'
-    ),
-    'options' => array(
+    ],
+    'examples' => [
+      'By Table Name' => 'drush tripal-chadotable-desc --table_name=feature',
+    ],
+    'options' => [
       'section' => dt('Only return the specified section of the schema table description. Possible sections include: description, fields, primary key, unique keys, foreign keys, indexes, referring_tables.'),
-    ),
-    'aliases' => array('trpschema-tbl')
-  );
-  $items['tripal-node-clean'] = array(
+    ],
+    'aliases' => ['trpschema-tbl'],
+  ];
+  $items['tripal-node-clean'] = [
     'description' => dt('DEPRECATED. Please see: trp-clean-nodes.'),
-    'arguments' => array(
+    'arguments' => [
       'module' => dt('The name of the chado-centric module to clean-up.'),
-    ),
-    'examples' => array(
-      'By Table Name' => 'drush tripal-node-clean feature'
-    ),
-    'options' => array(),
-    'aliases' => array('trpnode-cln')
-  );
+    ],
+    'examples' => [
+      'By Table Name' => 'drush tripal-node-clean feature',
+    ],
+    'options' => [],
+    'aliases' => ['trpnode-cln'],
+  ];
 
   return $items;
 }
@@ -172,7 +172,7 @@ function drush_tripal_core_tripal_jobs_launch($username) {
 
   drush_tripal_core_set_user($username);
 
-  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will ".
+  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will " .
     "continue to work but please consider using the 'trp-run-jobs' command.\n\n");
 
   if ($parallel) {
@@ -198,8 +198,8 @@ function drush_tripal_core_tripal_jobs_launch($username) {
  */
 function drush_tripal_core_tripal_jobs_rerun($username, $job_id) {
 
-  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will ".
-      "continue to work but please consider using the 'trp-rerun-job' command.\n\n");
+  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will " .
+    "continue to work but please consider using the 'trp-rerun-job' command.\n\n");
 
   drush_tripal_core_set_user($username);
   $new_job_id = tripal_rerun_job($job_id, FALSE);
@@ -215,8 +215,8 @@ function drush_tripal_core_tripal_jobs_rerun($username, $job_id) {
  * @ingroup tripal_drush
  */
 function drush_tripal_core_tripal_jobs_current() {
-  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will ".
-      "continue to work but please consider using the 'trp-get-currjob' command.\n\n");
+  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will " .
+    "continue to work but please consider using the 'trp-get-currjob' command.\n\n");
 
   drush_tripal_core_trp_get_currjob();
 }
@@ -231,20 +231,20 @@ function drush_tripal_core_tripal_update_mview() {
   $mview_id = drush_get_option('mview_id');
   $table_name = drush_get_option('table_name');
 
-  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will ".
-      "continue to work but please consider using the 'trp-refresh-mview' command.\n\n");
+  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will " .
+    "continue to work but please consider using the 'trp-refresh-mview' command.\n\n");
 
   // Either table_name or mview is required
   if (!$mview_id) {
     if ($table_name) {
       // if table_name supplied use that to get mview_id
       $sql = "SELECT mview_id FROM {tripal_mviews} WHERE mv_table = :mv_table";
-      $results = db_query($sql, array(':mv_table' => $table_name));
+      $results = db_query($sql, [':mv_table' => $table_name]);
       $r = $resuls->fetchObject();
       if (!$r->mview_id) {
         drush_set_error('No Materialized View associated with that table_name.');
       }
-      $mview_id=$r->mview_id;
+      $mview_id = $r->mview_id;
     }
     else {
       drush_set_error('Either mview_id OR table_name are required.');
@@ -267,8 +267,8 @@ function drush_tripal_core_tripal_update_mview() {
  * @ingroup tripal_drush
  */
 function drush_tripal_core_tripal_chado_version() {
-  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will ".
-      "continue to work but please consider using the 'trp-get-cversion' command.\n\n");
+  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will " .
+    "continue to work but please consider using the 'trp-get-cversion' command.\n\n");
 
   drush_tripal_core_trp_get_cversion();
 }
@@ -285,8 +285,8 @@ function drush_tripal_core_tripal_chado_version() {
 function drush_tripal_core_tripal_chadotable_desc($table_name) {
   $section = drush_get_option('section');
 
-  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will ".
-      "continue to work but please consider using the 'trp-get-table' command.\n\n");
+  drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will " .
+    "continue to work but please consider using the 'trp-get-table' command.\n\n");
 
   drush_print("Schema API Description for $table_name:");
   $desc = chado_get_schema($table_name);

+ 1 - 1
legacy/tripal_core/tripal_core.info

@@ -3,7 +3,7 @@ description = Provides support for all Tripal modules and includes the Tripal AP
 core = 7.x
 project = tripal
 package = Tripal v2 Legacy
-version = 7.x-3.0
+version = 7.x-3.1
 configure = admin/tripal
 
 stylesheets[all][] = theme/css/tripal_core.css

+ 9 - 9
legacy/tripal_core/tripal_core.views_default.inc

@@ -1,21 +1,21 @@
 <?php
 /**
  * @file
-* Describes core default views
-*/
+ * Describes core default views
+ */
 
 /**
  * Describes core default views
-*
-* @ingroup tripal_legacy_core
-*/
+ *
+ * @ingroup tripal_legacy_core
+ */
 function tripal_core_views_default_views() {
-  $views = array();
+  $views = [];
 
   // We only want to make this view available if the Search API module is installed
   // and the "Default Node Index has been enabled.
   if (module_exists('search_api')) {
-    $index_enabled = db_query('SELECT enabled FROM search_api_index WHERE machine_name=:name', array(':name' => 'default_node_index'))->fetchField();
+    $index_enabled = db_query('SELECT enabled FROM search_api_index WHERE machine_name=:name', [':name' => 'default_node_index'])->fetchField();
     if ($index_enabled) {
       $view = tripal_core_search_default_node_index();
       $views[$view->name] = $view;
@@ -84,11 +84,11 @@ function tripal_core_search_default_node_index() {
   $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['label'] = 'Keywords';
   $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['operator'] = 'search_api_views_fulltext_op';
   $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['identifier'] = 'keywords';
-  $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['remember_roles'] = array(
+  $handler->display->display_options['filters']['search_api_views_fulltext']['expose']['remember_roles'] = [
     2 => '2',
     1 => 0,
     3 => 0,
-  );
+  ];
 
   /* Display: Page */
   $handler = $view->new_display('page', 'Page', 'page');

+ 112 - 111
legacy/tripal_cv/api/tripal_cv.DEPRECATED.inc

@@ -6,8 +6,8 @@
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_cv().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_cv().
  *
  * @see tripal_get_cv().
  */
@@ -17,10 +17,10 @@ function tripal_cv_get_cv($select_values) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_get_cv',
-      '%new_function' => 'tripal_get_cv'
-    )
+    [
+      '%old_function' => 'tripal_cv_get_cv',
+      '%new_function' => 'tripal_get_cv',
+    ]
   );
 
   return tripal_get_cv($select_values);
@@ -28,8 +28,8 @@ function tripal_cv_get_cv($select_values) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_cv().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_cv().
  *
  * @see tripal_get_cv().
  */
@@ -39,19 +39,19 @@ function tripal_cv_get_cv_by_name($name) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_get_cv_by_name',
-      '%new_function' => 'tripal_get_cv'
-    )
+    [
+      '%old_function' => 'tripal_cv_get_cv_by_name',
+      '%new_function' => 'tripal_get_cv',
+    ]
   );
 
-  return tripal_get_cv(array('name' => $name));
+  return tripal_get_cv(['name' => $name]);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_cv().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_cv().
  *
  * @see tripal_get_cv().
  */
@@ -61,19 +61,19 @@ function tripal_cv_get_cv_by_id($cv_id) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_get_cv_by_id',
-      '%new_function' => 'tripal_get_cv'
-    )
+    [
+      '%old_function' => 'tripal_cv_get_cv_by_id',
+      '%new_function' => 'tripal_get_cv',
+    ]
   );
 
-  return tripal_get_cv(array('cv_id' => $id));
+  return tripal_get_cv(['cv_id' => $id]);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_cv().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_cv().
  *
  * @see tripal_get_cv().
  */
@@ -83,13 +83,13 @@ function tripal_cv_get_cv_id($cv_name) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_get_cv_id',
-      '%new_function' => 'tripal_get_cv'
-    )
+    [
+      '%old_function' => 'tripal_cv_get_cv_id',
+      '%new_function' => 'tripal_get_cv',
+    ]
   );
 
-  $cv = tripal_get_cv(array('name' => $cv_name));
+  $cv = tripal_get_cv(['name' => $cv_name]);
   if (isset($cv->cv_id)) {
     return $cv->cv_id;
   }
@@ -100,8 +100,8 @@ function tripal_cv_get_cv_id($cv_name) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_cv_select_options().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_cv_select_options().
  *
  * @see tripal_get_cv_select_options().
  */
@@ -111,10 +111,10 @@ function tripal_cv_get_cv_options() {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_get_cv_options',
-      '%new_function' => 'tripal_get_cv_select_options'
-    )
+    [
+      '%old_function' => 'tripal_cv_get_cv_options',
+      '%new_function' => 'tripal_get_cv_select_options',
+    ]
   );
 
   return tripal_get_cv_select_options();
@@ -122,8 +122,8 @@ function tripal_cv_get_cv_options() {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_cvterm().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_cvterm().
  *
  * @see tripal_get_cvterm().
  */
@@ -133,19 +133,19 @@ function tripal_cv_get_cvterm_by_id($cvterm_id) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_get_cvterm_by_id',
-      '%new_function' => 'tripal_get_cvterm'
-    )
+    [
+      '%old_function' => 'tripal_cv_get_cvterm_by_id',
+      '%new_function' => 'tripal_get_cvterm',
+    ]
   );
 
-  return tripal_get_cvterm(array('cvterm_id' => $cvterm_id));
+  return tripal_get_cvterm(['cvterm_id' => $cvterm_id]);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_cvterm().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_cvterm().
  *
  * @see tripal_get_cvterm().
  */
@@ -155,20 +155,20 @@ function tripal_cv_get_cvterm_by_name($name, $cv_id = NULL, $cv_name = 'tripal')
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_get_cvterm_by_name',
-      '%new_function' => 'tripal_get_cvterm'
-    )
+    [
+      '%old_function' => 'tripal_cv_get_cvterm_by_name',
+      '%new_function' => 'tripal_get_cvterm',
+    ]
   );
 
-  $identifiers = array('name' => $name);
+  $identifiers = ['name' => $name];
   if (isset($cv_id)) {
     $identifiers['cv_id'] = $cv_id;
   }
   if (isset($cv_name)) {
-    $identifiers['cv_id'] = array(
-      'name' => $cv_name
-    );
+    $identifiers['cv_id'] = [
+      'name' => $cv_name,
+    ];
   }
 
   return tripal_get_cvterm($identifiers);
@@ -176,8 +176,8 @@ function tripal_cv_get_cvterm_by_name($name, $cv_id = NULL, $cv_name = 'tripal')
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_cvterm().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_cvterm().
  *
  * @see tripal_get_cvterm().
  */
@@ -187,25 +187,26 @@ function tripal_cv_get_cvterm_by_synonym($synonym, $cv_id = NULL, $cv_name = 'tr
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_get_cvterm_by_synonym',
-      '%new_function' => 'tripal_get_cvterm'
-    )
+    [
+      '%old_function' => 'tripal_cv_get_cvterm_by_synonym',
+      '%new_function' => 'tripal_get_cvterm',
+    ]
   );
 
-  return tripal_get_cvterm(array(
-    'synonym' => array(
+  return tripal_get_cvterm([
+    'synonym' => [
       'name' => $synonym,
       'cv_id' => $cv_id,
-      'cv_name' => $cv_name
-    )
-  ));
+      'cv_name' => $cv_name,
+    ],
+  ]);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_cvterm_select_options().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by
+ *   tripal_get_cvterm_select_options().
  *
  * @see tripal_get_cvterm_select_options().
  */
@@ -215,10 +216,10 @@ function tripal_cv_get_cvterm_options($cv_id = 0) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_get_cvterm_options',
-      '%new_function' => 'tripal_get_cvterm_select_options'
-    )
+    [
+      '%old_function' => 'tripal_cv_get_cvterm_options',
+      '%new_function' => 'tripal_get_cvterm_select_options',
+    ]
   );
 
   return tripal_get_cvterm_select_options($cv_id);
@@ -226,8 +227,8 @@ function tripal_cv_get_cvterm_options($cv_id = 0) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_update_cvtermpath().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_update_cvtermpath().
  *
  * @see tripal_update_cvtermpath().
  */
@@ -237,10 +238,10 @@ function tripal_cv_update_cvtermpath($cvid, $job_id = NULL) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_update_cvtermpath',
-      '%new_function' => 'tripal_update_cvtermpath'
-    )
+    [
+      '%old_function' => 'tripal_cv_update_cvtermpath',
+      '%new_function' => 'tripal_update_cvtermpath',
+    ]
   );
 
   return tripal_update_cvtermpath($cvid, $job_id);
@@ -248,8 +249,8 @@ function tripal_cv_update_cvtermpath($cvid, $job_id = NULL) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_insert_cv().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_insert_cv().
  *
  * @see tripal_insert_cv().
  */
@@ -259,10 +260,10 @@ function tripal_cv_add_cv($name, $definition) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_add_cv',
-      '%new_function' => 'tripal_insert_cv'
-    )
+    [
+      '%old_function' => 'tripal_cv_add_cv',
+      '%new_function' => 'tripal_insert_cv',
+    ]
   );
 
   return tripal_insert_cv($name, $definition);
@@ -270,8 +271,8 @@ function tripal_cv_add_cv($name, $definition) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_insert_cvterm().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_insert_cvterm().
  *
  * @see tripal_insert_cvterm().
  */
@@ -281,10 +282,10 @@ function tripal_cv_add_cvterm($term, $defaultcv = '_global', $is_relationship =
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_add_cvterm',
-      '%new_function' => 'tripal_insert_cvterm'
-    )
+    [
+      '%old_function' => 'tripal_cv_add_cvterm',
+      '%new_function' => 'tripal_insert_cvterm',
+    ]
   );
 
   $term['cv_name'] = $defaultcv;
@@ -298,16 +299,16 @@ function tripal_cv_add_cvterm($term, $defaultcv = '_global', $is_relationship =
 
   return tripal_insert_cvterm(
     $term,
-    array(
-      'update_existing' => $update
-    )
+    [
+      'update_existing' => $update,
+    ]
   );
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_submit_obo_job().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_submit_obo_job().
  *
  * @see tripal_submit_obo_job().
  */
@@ -317,26 +318,26 @@ function tripal_cv_submit_obo_job($obo_id = NULL, $obo_name = NULL, $obo_url = N
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_submit_obo_job',
-      '%new_function' => 'tripal_submit_obo_job'
-    )
+    [
+      '%old_function' => 'tripal_cv_submit_obo_job',
+      '%new_function' => 'tripal_submit_obo_job',
+    ]
   );
 
   return tripal_submit_obo_job(
-    array(
+    [
       'obo_id' => $obo_id,
-      'name'   => $obo_name,
-      'url'    => $obo_url,
-      'file'   => $obo_file
-    )
+      'name' => $obo_name,
+      'url' => $obo_url,
+      'file' => $obo_file,
+    ]
   );
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_insert_obo().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_insert_obo().
  *
  * @see tripal_insert_obo().
  */
@@ -346,10 +347,10 @@ function tripal_cv_add_obo_ref($name, $path) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_add_obo_ref',
-      '%new_function' => 'chado_insert_obo'
-    )
+    [
+      '%old_function' => 'tripal_cv_add_obo_ref',
+      '%new_function' => 'chado_insert_obo',
+    ]
   );
 
   return tripal_insert_obo($name, $path);
@@ -357,8 +358,8 @@ function tripal_cv_add_obo_ref($name, $path) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_autocomplete_cvterm().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_autocomplete_cvterm().
  *
  * @see tripal_autocomplete_cvterm().
  */
@@ -368,10 +369,10 @@ function tripal_cv_cvterm_name_autocomplete($cv_id, $string = '') {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_cv_cvterm_name_autocomplete',
-      '%new_function' => 'tripal_autocomplete_cvterm'
-    )
+    [
+      '%old_function' => 'tripal_cv_cvterm_name_autocomplete',
+      '%new_function' => 'tripal_autocomplete_cvterm',
+    ]
   );
 
   return tripal_autocomplete_cvterm($cv_id, $string);

+ 25 - 22
legacy/tripal_cv/api/tripal_cv.api.inc

@@ -48,9 +48,12 @@ function tripal_get_default_cv($table, $field) {
     FROM {tripal_cv_defaults}
     WHERE table_name = :table and field_name = :field
   ";
-  $cv_id = db_query($sql, array(':table' => $table, ':field' => $field))->fetchField();
+  $cv_id = db_query($sql, [
+    ':table' => $table,
+    ':field' => $field,
+  ])->fetchField();
 
-  return tripal_get_cv(array('cv_id' => $cv_id));
+  return tripal_get_cv(['cv_id' => $cv_id]);
 }
 
 /**
@@ -78,7 +81,7 @@ function tripal_get_default_cv($table, $field) {
  */
 function tripal_get_default_cv_table($cv_id) {
   $default = db_select('tripal_cv_defaults', 't')
-    ->fields('t', array('table_name', 'field_name'))
+    ->fields('t', ['table_name', 'field_name'])
     ->condition('cv_id', $cv_id)
     ->execute()
     ->fetchObject();
@@ -111,28 +114,28 @@ function tripal_get_default_cv_table($cv_id) {
 function tripal_get_cvterm_default_select_options($table, $field, $field_desc) {
 
   $default_cv = tripal_get_default_cv($table, $field);
-  $options = array();
+  $options = [];
 
   if ($default_cv) {
     $options = tripal_get_cvterm_select_options($default_cv->cv_id);
 
     if (count($options) == 0) {
       tripal_set_message('There are no ' . $field_desc . '. Please ' .
-          l('add terms',
-              'admin/tripal/loaders/chado_vocabs/chado_cv/' .$default_cv->cv_id. '/cvterm/add',
-              array('attributes' => array('target' => '_blank'))) . ' to the ' .
-          $default_cv->name .' vocabulary.',
-          TRIPAL_WARNING);
+        l('add terms',
+          'admin/tripal/loaders/chado_vocabs/chado_cv/' . $default_cv->cv_id . '/cvterm/add',
+          ['attributes' => ['target' => '_blank']]) . ' to the ' .
+        $default_cv->name . ' vocabulary.',
+        TRIPAL_WARNING);
     }
 
   }
   else {
-    tripal_set_message('There is not a default vocabulary set for ' . $field_desc . '. '.
-        'Please set one using the ' .
-        l('vocabulary defaults configuration page',
-            'admin/tripal/vocab/defaults',
-            array('attributes' => array('target' => '_blank'))) . '.',
-        TRIPAL_WARNING);
+    tripal_set_message('There is not a default vocabulary set for ' . $field_desc . '. ' .
+      'Please set one using the ' .
+      l('vocabulary defaults configuration page',
+        'admin/tripal/vocab/defaults',
+        ['attributes' => ['target' => '_blank']]) . '.',
+      TRIPAL_WARNING);
   }
 
   return $options;
@@ -160,10 +163,10 @@ function tripal_set_default_cv($table, $field, $cv_name, $cv_id = FALSE) {
 
   // Get the CV object
   if ($cv_id) {
-    $cv = tripal_get_cv(array('cv_id' => $cv_id));
+    $cv = tripal_get_cv(['cv_id' => $cv_id]);
   }
   else {
-    $cv = tripal_get_cv(array('name' => $cv_name));
+    $cv = tripal_get_cv(['name' => $cv_name]);
   }
 
   if ($cv) {
@@ -175,24 +178,24 @@ function tripal_set_default_cv($table, $field, $cv_name, $cv_id = FALSE) {
 
     // now add the default value
     $cv_default_id = db_insert('tripal_cv_defaults')
-      ->fields(array(
+      ->fields([
         'table_name' => $table,
         'field_name' => $field,
-        'cv_id'      => $cv->cv_id,
-      ))
+        'cv_id' => $cv->cv_id,
+      ])
       ->execute();
 
     if (!$cv_default_id) {
       tripal_report_error('tripal_chado', TRIPAL_WARNING,
         "Cannot set default vocabulary for %table.%field. Check the error logs.",
-        array('%table' => $table, '%field' => $field));
+        ['%table' => $table, '%field' => $field]);
       return FALSE;
     }
   }
   else {
     tripal_report_error('tripal_chado', TRIPAL_WARNING,
       "Cannot set default vocabulary for %table.%field. The vocabulary name, '%cvname', doesn't exist.",
-      array('%table' => $table, '%field' => $field, '%cvname' => $cv_name));
+      ['%table' => $table, '%field' => $field, '%cvname' => $cv_name]);
     return FALSE;
   }
 }

+ 96 - 96
legacy/tripal_cv/includes/tripal_cv.cv_defaults.inc

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

+ 54 - 34
legacy/tripal_cv/theme/templates/tripal_cv_help.tpl.php

@@ -1,45 +1,65 @@
-  <h3>Module Description:</h3>
-  <p>The Tripal CV (Controlled Vocabularies) Module provides
+<h3>Module Description:</h3>
+<p>The Tripal CV (Controlled Vocabularies) Module provides
     functionality for managing controlled vocabularies and the terms they are
     comprised of. The flexibility and extendibility of the chado schema depends
-    on controlled vocabularies. For example, by using a controlled vocabulary for
+    on controlled vocabularies. For example, by using a controlled vocabulary
+    for
     feature types the chado schema can describe features of any type, even those
     we have not concieved of yet.</p>
 
-  <h3>Setup Instructions:</h3>
-  <p>After installation of the controlled vocabulary module, the following tasks should be performed:</p>
-    <ol>
-        <li><p><b>Set Permissions</b>: By default only the site administrator account has access to create, edit, delete
-   or administer vocabularies and terms. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
-   permissions under the 'tripal_cv' section as appropriate for your site. For a simple setup, allow anonymous
-   users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
+<h3>Setup Instructions:</h3>
+<p>After installation of the controlled vocabulary module, the following tasks
+    should be performed:</p>
+<ol>
+    <li><p><b>Set Permissions</b>: By default only the site administrator
+            account has access to create, edit, delete
+            or administer vocabularies and terms. Navigate to
+            the <?php print l('permissions page', 'admin/user/permissions') ?>
+            and set the
+            permissions under the 'tripal_cv' section as appropriate for your
+            site. For a simple setup, allow anonymous
+            users access to view content and create a special role for creating,
+            editing and other administrative tasks.</p></li>
 
-      <li><p><b>Loading of Ontologies/Controlled Vocabularies</b>: You can access this loader at <?php
+    <li><p><b>Loading of Ontologies/Controlled Vocabularies</b>: You can access
+            this loader at <?php
         print l('Admin->Tripal Management->Tripal CV->Load Ontology With OBO File', 'admin/tripal/loaders/chado_vocabs/obo_loader')
         ?>. This loader allows you to choose from a list of common ontologies or
-        enter the URL or location to an OBO file. Even the list of common
-        ontologies is using a URL ensuring you get the most up to date ontology.</p>
-      <p>NOTE: in some cases, community developed ontologies for your
-        data may not yet be developed. In this case, it is suggested that you begin
-        developement of an ontology using one of the online tools. You might find
-        that many researchers are trying to deal with the same data and are willing
-        to help you in this endevor. </p></li>
-    </ol>
+            enter the URL or location to an OBO file. Even the list of common
+            ontologies is using a URL ensuring you get the most up to date
+            ontology.</p>
+        <p>NOTE: in some cases, community developed ontologies for your
+            data may not yet be developed. In this case, it is suggested that
+            you begin
+            developement of an ontology using one of the online tools. You might
+            find
+            that many researchers are trying to deal with the same data and are
+            willing
+            to help you in this endevor. </p></li>
+</ol>
 
-  <h3>Features of this Module:</h3>
-  <p>Aside from the data loading described above, the Tripal Controlled Vocabulary (CV) module also provides the following functionality:</p>
-    <ul>
-      <li><p><b>Create/Update/Delete A Controlled Vocaulbulary</b>: to create your own controlled vocabulary go to
-        <?php l('the page for adding a vocbulary', 'admin/tripal/tripal_cv/cv/add') ?> and
-        fill out the form provided. To Update/Delete a controlled vocabulary go to
-        <?php print l('the page for editing a vocuabulary', 'admin/tripal/tripal_cv/cv/edit') ?>,
-        select the existing vocabulary you want to modify and then
-        edit it as desired. This only modifies the vocabulary itself. See the next section for adding, removing, editing
-        the terms of a vocabulary.</p></li>
+<h3>Features of this Module:</h3>
+<p>Aside from the data loading described above, the Tripal Controlled Vocabulary
+    (CV) module also provides the following functionality:</p>
+<ul>
+    <li><p><b>Create/Update/Delete A Controlled Vocaulbulary</b>: to create your
+            own controlled vocabulary go to
+        <?php l('the page for adding a vocbulary', 'admin/tripal/tripal_cv/cv/add') ?>
+            and
+            fill out the form provided. To Update/Delete a controlled vocabulary
+            go to
+        <?php print l('the page for editing a vocuabulary', 'admin/tripal/tripal_cv/cv/edit') ?>
+            ,
+            select the existing vocabulary you want to modify and then
+            edit it as desired. This only modifies the vocabulary itself. See
+            the next section for adding, removing, editing
+            the terms of a vocabulary.</p></li>
 
-      <li><p><b>Create a Controlled Vocaulbulary Term</b>: Use
-        <?php print l('the page for adding a new CV term', 'admin/tripal/tripal_cv/cvterm/add') ?>,
-        select the controlled vocabulary you want to add terms to and then fill
-        out the form.</p></li>
+    <li><p><b>Create a Controlled Vocaulbulary Term</b>: Use
+        <?php print l('the page for adding a new CV term', 'admin/tripal/tripal_cv/cvterm/add') ?>
+            ,
+            select the controlled vocabulary you want to add terms to and then
+            fill
+            out the form.</p></li>
 
-    </ul>
+</ul>

+ 1 - 1
legacy/tripal_cv/tripal_cv.info

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

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

@@ -10,7 +10,7 @@
  * @ingroup tripal_legacy_cv
  */
 function tripal_cv_views_default_views() {
-  $views = array();
+  $views = [];
 
   return $views;
 }

+ 74 - 74
legacy/tripal_db/api/tripal_db.DEPRECATED.inc

@@ -6,8 +6,8 @@
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_db().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_db().
  *
  * @see tripal_get_db().
  */
@@ -17,10 +17,10 @@ function tripal_db_get_db($select_values) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_db_get_db',
-      '%new_function' => 'tripal_get_db'
-    )
+    [
+      '%old_function' => 'tripal_db_get_db',
+      '%new_function' => 'tripal_get_db',
+    ]
   );
 
   return tripal_get_db($select_values);
@@ -28,8 +28,8 @@ function tripal_db_get_db($select_values) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_db().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_db().
  *
  * @see tripal_get_db().
  */
@@ -39,19 +39,19 @@ function tripal_db_get_db_by_db_id($db_id) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_db_get_db_by_db_id',
-      '%new_function' => 'tripal_get_db'
-    )
+    [
+      '%old_function' => 'tripal_db_get_db_by_db_id',
+      '%new_function' => 'tripal_get_db',
+    ]
   );
 
-  return tripal_get_db(array('db_id' => $db_id));
+  return tripal_get_db(['db_id' => $db_id]);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_db().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_db().
  *
  * @see tripal_get_db().
  */
@@ -61,19 +61,19 @@ function tripal_db_get_db_by_name($name) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_db_get_db_by_name',
-      '%new_function' => 'tripal_get_db'
-    )
+    [
+      '%old_function' => 'tripal_db_get_db_by_name',
+      '%new_function' => 'tripal_get_db',
+    ]
   );
 
-  return tripal_get_db(array('name' => $name));
+  return tripal_get_db(['name' => $name]);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_db_select_options().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_db_select_options().
  *
  * @see tripal_get_db_select_options().
  */
@@ -83,10 +83,10 @@ function tripal_db_get_db_options() {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_db_get_db_options',
-      '%new_function' => 'tripal_get_db_select_options'
-    )
+    [
+      '%old_function' => 'tripal_db_get_db_options',
+      '%new_function' => 'tripal_get_db_select_options',
+    ]
   );
 
   return tripal_get_db_select_options();
@@ -94,8 +94,8 @@ function tripal_db_get_db_options() {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_db().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_db().
  *
  * @see tripal_get_dbxref().
  */
@@ -105,10 +105,10 @@ function tripal_db_get_dbxref($select_values) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_db_get_dbxref',
-      '%new_function' => 'tripal_get_dbxref'
-    )
+    [
+      '%old_function' => 'tripal_db_get_dbxref',
+      '%new_function' => 'tripal_get_dbxref',
+    ]
   );
 
   return tripal_get_dbxref($select_values);
@@ -116,38 +116,38 @@ function tripal_db_get_dbxref($select_values) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_get_db().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_get_db().
  *
  * @see tripal_get_dbxref().
  */
-function tripal_db_get_dbxref_by_accession($accession, $db_id=0) {
+function tripal_db_get_dbxref_by_accession($accession, $db_id = 0) {
 
   tripal_report_error(
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_db_get_dbxref_by_accession',
-      '%new_function' => 'tripal_get_dbxref'
-    )
+    [
+      '%old_function' => 'tripal_db_get_dbxref_by_accession',
+      '%new_function' => 'tripal_get_dbxref',
+    ]
   );
 
-  $identifiers = array(
-    'accession' => $accession
-  );
+  $identifiers = [
+    'accession' => $accession,
+  ];
   if ($db_id > 0) {
-    $identifiers['db'] = array(
-      'db_id' => $db_id
-    );
+    $identifiers['db'] = [
+      'db_id' => $db_id,
+    ];
   }
   return tripal_get_dbxref($identifiers);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_insert_db().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_insert_db().
  *
  * @see tripal_insert_db().
  */
@@ -157,29 +157,29 @@ function tripal_db_add_db($dbname, $description = '', $url = '', $urlprefix = ''
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_db_add_db',
-      '%new_function' => 'tripal_insert_db'
-    )
+    [
+      '%old_function' => 'tripal_db_add_db',
+      '%new_function' => 'tripal_insert_db',
+    ]
   );
 
   return tripal_insert_db(
-    array(
+    [
       'name' => $dbname,
       'description' => $description,
       'url' => $url,
-      'urlprefix' => $urlprefix
-    ),
-    array(
-      'update_existing' => $update
-    )
+      'urlprefix' => $urlprefix,
+    ],
+    [
+      'update_existing' => $update,
+    ]
   );
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_insert_dbxref().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_insert_dbxref().
  *
  * @see tripal_insert_dbxref().
  */
@@ -189,24 +189,24 @@ function tripal_db_add_dbxref($db_id, $accession, $version = '', $description =
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_db_add_dbxref',
-      '%new_function' => 'tripal_insert_dbxref'
-    )
+    [
+      '%old_function' => 'tripal_db_add_dbxref',
+      '%new_function' => 'tripal_insert_dbxref',
+    ]
   );
 
-  return tripal_insert_dbxref(array(
+  return tripal_insert_dbxref([
     'db_id' => $db_id,
     'accession' => $accession,
     'version' => $version,
-    'description' => $description
-  ));
+    'description' => $description,
+  ]);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_associate_dbxref().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_associate_dbxref().
  *
  * @see tripal_associate_dbxref().
  */
@@ -216,16 +216,16 @@ function tripal_db_add_dbxref_link($linking_table, $dbxref_id, $foreignkey_name,
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_db_add_dbxref_link',
-      '%new_function' => 'tripal_associate_dbxref'
-    )
+    [
+      '%old_function' => 'tripal_db_add_dbxref_link',
+      '%new_function' => 'tripal_associate_dbxref',
+    ]
   );
 
-  if (preg_match('/(\w+)_dbxref/',$linking_table,$matches)) {
+  if (preg_match('/(\w+)_dbxref/', $linking_table, $matches)) {
     $basetable = $matches[1];
 
-    return tripal_associate_dbxref($basetable, $foreignkey_id, array('dbxref_id' => $dbxref_id));
+    return tripal_associate_dbxref($basetable, $foreignkey_id, ['dbxref_id' => $dbxref_id]);
   }
   else {
     return FALSE;

+ 38 - 20
legacy/tripal_db/theme/templates/tripal_db_help.tpl.php

@@ -1,29 +1,47 @@
 <h3>Module Description:</h3>
-<p>The Tripal DB Module provides the ability to add database cross reference to the
-  data in your Tripal Website.  Typically an external database (such as NCBI Genbank, Gene Ontology (GO),
-  stocks database) contains a collection of objects (genomic sequences, vocabulary terms, stocks) that are
-  uniquely identified using an accession number (or identifier).  Data loaded into Tripal can be a
-  associated with these objects in remote databases, and links can appear on pages allowing site visitors
-  to view the associated objects on the remote database\'s website </p>
+<p>The Tripal DB Module provides the ability to add database cross reference to
+    the
+    data in your Tripal Website. Typically an external database (such as NCBI
+    Genbank, Gene Ontology (GO),
+    stocks database) contains a collection of objects (genomic sequences,
+    vocabulary terms, stocks) that are
+    uniquely identified using an accession number (or identifier). Data loaded
+    into Tripal can be a
+    associated with these objects in remote databases, and links can appear on
+    pages allowing site visitors
+    to view the associated objects on the remote database\'s website </p>
 
 <h3>Setup Instructions:</h3>
 <ol>
-    <li><p><b>Set Permissions</b>: By default only the site administrator account has access to
-   or administer databases. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
-   permissions under the 'tripal_db' section as appropriate for your site. For a simple setup, allow anonymous
-   users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
+    <li><p><b>Set Permissions</b>: By default only the site administrator
+            account has access to
+            or administer databases. Navigate to
+            the <?php print l('permissions page', 'admin/user/permissions') ?>
+            and set the
+            permissions under the 'tripal_db' section as appropriate for your
+            site. For a simple setup, allow anonymous
+            users access to view content and create a special role for creating,
+            editing and other administrative tasks.</p></li>
 
-<li><p><b>Adding or Editing an External Databases</b>. Many resources such as NCBI nr or ExPASy SwissProt (to name a few)
-          come pre-loaded with Chado.  However, you can add new entries or edit existing entries. Also, when loading
-          ontologies (controlled vocabularies) using the Tripal CV module new databases are added automaticaly for
-          each ontology.  To enable linking of accession on a page to the page for that accession on the external
-          database, simply add the URL and the URL prefix when adding or editing a database.</p></li>
+    <li><p><b>Adding or Editing an External Databases</b>. Many resources such
+            as NCBI nr or ExPASy SwissProt (to name a few)
+            come pre-loaded with Chado. However, you can add new entries or edit
+            existing entries. Also, when loading
+            ontologies (controlled vocabularies) using the Tripal CV module new
+            databases are added automaticaly for
+            each ontology. To enable linking of accession on a page to the page
+            for that accession on the external
+            database, simply add the URL and the URL prefix when adding or
+            editing a database.</p></li>
 
-<li><p><b>Associate Data with Accessions</b>.  The Tripal loaders (e.g. GFF, OBO) can associate accessions from
-          remote data to genomic features and controlled vocabularies automatically.  Use the loaders to load genomic
-          features and controlled vocabularies respectively.  Additionally, the bulk loader can be used to create
-          loading templates for associating external database accessions.
-         </p></li>
+    <li><p><b>Associate Data with Accessions</b>. The Tripal loaders (e.g. GFF,
+            OBO) can associate accessions from
+            remote data to genomic features and controlled vocabularies
+            automatically. Use the loaders to load genomic
+            features and controlled vocabularies respectively. Additionally, the
+            bulk loader can be used to create
+            loading templates for associating external database accessions.
+        </p></li>
 </ol>
 
 

+ 1 - 1
legacy/tripal_db/tripal_db.info

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

+ 1 - 2
legacy/tripal_db/tripal_db.views_default.inc

@@ -10,8 +10,7 @@
  * @ingroup tripal_legacy_db
  */
 function tripal_db_views_default_views() {
-  $views = array();
-
+  $views = [];
 
 
   return $views;

+ 184 - 182
legacy/tripal_feature/api/tripal_feature.DEPRECATED.inc

@@ -1,52 +1,53 @@
 <?php
 /**
  * @file
- * Wrapper functions to provide backwards compatibility for the tripal feature api
+ * Wrapper functions to provide backwards compatibility for the tripal feature
+ *   api
  */
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_get_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_get_property().
  *
  * @see chado_get_property().
  */
-function tripal_feature_analysis_get_property($analysis_id = NULL, $feature_id = NUll, $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
+function tripal_feature_analysis_get_property($analysis_id = NULL, $feature_id = NULL, $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
 
   tripal_report_error(
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_analysis_get_property',
-      '%new_function' => 'chado_get_property'
-    )
+    [
+      '%old_function' => 'tripal_feature_analysis_get_property',
+      '%new_function' => 'chado_get_property',
+    ]
   );
 
   // check that the incoming arguments are correct
   if (($analysis_id and !$feature_id) or
-      (!$analysis_id and $feature_id)) {
-      tripal_report_error('tripal_feature', TRIPAL_WARNING,
+    (!$analysis_id and $feature_id)) {
+    tripal_report_error('tripal_feature', TRIPAL_WARNING,
       'tripal_feature_analysis_get_property: Both an analysis ID and feature ID should be specified',
-      array());
+      []);
   }
 
   // get the analysisfeature_id if one is not provided
   if (!$analysisfeature_id) {
-    $columns = array('analysisfeature_id');
-    $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
+    $columns = ['analysisfeature_id'];
+    $values = ['analysis_id' => $analysis_id, 'feature_id' => $feature_id];
     $result = chado_select_record('analysisfeature', $columns, $values);
     $analysisfeature_id = $result[0]->analysisfeature_id;
   }
 
-  $record = array(
+  $record = [
     'table' => 'analysisfeature',
     'id' => $analysisfeature_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
-  );
+  ];
 
   // get the property.
   return chado_get_property($record, $property);
@@ -54,52 +55,52 @@ function tripal_feature_analysis_get_property($analysis_id = NULL, $feature_id =
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_insert_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_insert_property().
  *
  * @see chado_insert_property().
  */
-function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_id = NUll, $analysisfeature_id = NULL, $property, $value, $update_if_present = 0, $cv_name = 'tripal') {
+function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_id = NULL, $analysisfeature_id = NULL, $property, $value, $update_if_present = 0, $cv_name = 'tripal') {
 
   tripal_report_error(
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_analysis_insert_property',
-      '%new_function' => 'chado_insert_property'
-    )
+    [
+      '%old_function' => 'tripal_feature_analysis_insert_property',
+      '%new_function' => 'chado_insert_property',
+    ]
   );
 
-    // check that the incoming arguments are correct
+  // check that the incoming arguments are correct
   if (($analysis_id and !$feature_id) or
-      (!$analysis_id and $feature_id)) {
+    (!$analysis_id and $feature_id)) {
     tripal_report_error('tripal_feature', TRIPAL_WARNING,
       'tripal_feature_analysis_insert_property: Both an analysis ID and feature ID should be specified',
-      array());
+      []);
   }
 
   // get the analysisfeature_id if one is not provided
   if (!$analysisfeature_id) {
-    $columns = array('analysisfeature_id');
-    $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
+    $columns = ['analysisfeature_id'];
+    $values = ['analysis_id' => $analysis_id, 'feature_id' => $feature_id];
     $result = chado_select_record('analysisfeature', $columns, $values);
     $analysisfeature_id = $result[0]->analysisfeature_id;
   }
 
-  $record = array(
+  $record = [
     'table' => 'analysisfeature',
     'id' => $analysisfeature_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
-    'value' => $value
-  );
-  $options = array(
+    'value' => $value,
+  ];
+  $options = [
     'update_if_present' => $update_if_present,
-  );
-  
+  ];
+
   // insert the property.
   return chado_insert_property($record, $property, $options);
 
@@ -107,60 +108,60 @@ function tripal_feature_analysis_insert_property($analysis_id = NULL, $feature_i
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_update_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_update_property().
  *
  * @see chado_update_property().
  */
-function tripal_feature_analysis_update_property($analysis_id = NULL, $feature_id = NUll, $analysisfeature_id = NULL, $property, $value, $insert_if_missing = 0, $cv_name = 'tripal') {
+function tripal_feature_analysis_update_property($analysis_id = NULL, $feature_id = NULL, $analysisfeature_id = NULL, $property, $value, $insert_if_missing = 0, $cv_name = 'tripal') {
 
   tripal_report_error(
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_analysis_update_property',
-      '%new_function' => 'chado_update_property'
-    )
+    [
+      '%old_function' => 'tripal_feature_analysis_update_property',
+      '%new_function' => 'chado_update_property',
+    ]
   );
 
   // check that the incoming arguments are correct
   if (($analysis_id and !$feature_id) or
     (!$analysis_id and $feature_id)) {
-      tripal_report_error('tripal_feature', TRIPAL_WARNING,
+    tripal_report_error('tripal_feature', TRIPAL_WARNING,
       'tripal_feature_analysis_update_property: Both an analysis ID and feature ID should be specified',
-      array());
+      []);
   }
 
   // get the analysisfeature_id if one is not provided
   if (!$analysisfeature_id) {
-    $columns = array('analysisfeature_id');
-    $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
+    $columns = ['analysisfeature_id'];
+    $values = ['analysis_id' => $analysis_id, 'feature_id' => $feature_id];
     $result = chado_select_record('analysisfeature', $columns, $values);
     $analysisfeature_id = $result[0]->analysisfeature_id;
   }
 
-  $record = array(
+  $record = [
     'table' => 'analysisfeature',
     'id' => $analysisfeature_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
-    'value' => $value
-  );
-  $options = array(
+    'value' => $value,
+  ];
+  $options = [
     'insert_if_missing' => $insert_if_missing,
-  );
-  
+  ];
+
   // update the property.
   return chado_update_property($record, $property, $options);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_update_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_update_property().
  *
  * @see chado_update_property().
  */
@@ -170,68 +171,68 @@ function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_analysis_update_property_by_id',
-      '%new_function' => 'chado_update_property'
-    )
+    [
+      '%old_function' => 'tripal_feature_analysis_update_property_by_id',
+      '%new_function' => 'chado_update_property',
+    ]
   );
 
-  $record = array(
+  $record = [
     'table' => 'analysisfeature',
     'prop_id' => $analysisfeatureprop_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
-    'value' => $value
-  );
+    'value' => $value,
+  ];
   // update the property.
   return chado_update_property($record, $property);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_delete_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_delete_property().
  *
  * @see chado_delete_property().
  */
-function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_id = NUll, $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
+function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_id = NULL, $analysisfeature_id = NULL, $property, $cv_name = 'tripal') {
 
   tripal_report_error(
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_analysis_delete_property',
-      '%new_function' => 'chado_delete_property'
-    )
+    [
+      '%old_function' => 'tripal_feature_analysis_delete_property',
+      '%new_function' => 'chado_delete_property',
+    ]
   );
 
   // check that the incoming arguments are correct
   if (($analysis_id and !$feature_id) or
     (!$analysis_id and $feature_id)) {
-      tripal_report_error('tripal_feature', TRIPAL_WARNING,
+    tripal_report_error('tripal_feature', TRIPAL_WARNING,
       'tripal_feature_analysis_delete_property: Both an analysis ID and feature ID should be specified',
-        array());
+      []);
   }
 
   // get the analysisfeature_id if one is not provided
   if (!$analysisfeature_id) {
-    $columns = array('analysisfeature_id');
-    $values = array('analysis_id' => $analysis_id, 'feature_id' => $feature_id);
+    $columns = ['analysisfeature_id'];
+    $values = ['analysis_id' => $analysis_id, 'feature_id' => $feature_id];
     $result = chado_select_record('analysisfeature', $columns, $values);
     $analysisfeature_id = $result[0]->analysisfeature_id;
   }
-  
-  $record = array(
+
+  $record = [
     'table' => 'analysisfeature',
     'id' => $analysisfeature_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
-  );
+  ];
 
   // get the property.
   return chado_delete_property($record, $property);
@@ -240,8 +241,8 @@ function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_i
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_delete_record().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_delete_record().
  *
  * @see chado_delete_record().
  */
@@ -251,55 +252,55 @@ function tripal_feature_analysis_delete_property_by_id($analysisfeatureprop_id)
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_analysis_delete_property_by_id',
-      '%new_function' => 'chado_delete_record'
-    )
+    [
+      '%old_function' => 'tripal_feature_analysis_delete_property_by_id',
+      '%new_function' => 'chado_delete_record',
+    ]
   );
 
   // construct the array that will match the exact record to update
-  $match = array(
+  $match = [
     'analysisfeatureprop_id' => $analysisfeatureprop_id,
-  );
+  ];
 
   return chado_delete_record('analysisfeatureprop', $match);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_get_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_get_property().
  *
  * @see chado_get_property().
  */
-function tripal_feature_get_property($feature_id, $property, $cv_name='tripal') {
+function tripal_feature_get_property($feature_id, $property, $cv_name = 'tripal') {
 
   tripal_report_error(
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_get_property',
-      '%new_function' => 'chado_get_property'
-    )
+    [
+      '%old_function' => 'tripal_feature_get_property',
+      '%new_function' => 'chado_get_property',
+    ]
   );
-  
-  $record = array(
+
+  $record = [
     'table' => 'feature',
     'id' => $feature_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
-  );
+  ];
 
   return chado_get_property($record, $property);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_insert_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_insert_property().
  *
  * @see chado_insert_property().
  */
@@ -309,32 +310,32 @@ function tripal_feature_insert_property($feature_id, $property, $value, $update_
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_insert_property',
-      '%new_function' => 'chado_insert_property'
-    )
+    [
+      '%old_function' => 'tripal_feature_insert_property',
+      '%new_function' => 'chado_insert_property',
+    ]
   );
 
-  $record = array(
+  $record = [
     'table' => 'feature',
     'id' => $feature_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
     'value' => $value,
-  );
-  $options = array(
+  ];
+  $options = [
     'update_if_present' => $update_if_present,
-  );
-  
+  ];
+
   return chado_insert_property($record, $property, $options);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_update_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_update_property().
  *
  * @see chado_update_property().
  */
@@ -344,31 +345,31 @@ function tripal_feature_update_property($feature_id, $property, $value, $insert_
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_update_property',
-      '%new_function' => 'chado_update_property'
-    )
+    [
+      '%old_function' => 'tripal_feature_update_property',
+      '%new_function' => 'chado_update_property',
+    ]
   );
 
-  $record = array(
+  $record = [
     'table' => 'feature',
     'id' => $feature_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
     'value' => $value,
-  );
-  $options = array(
+  ];
+  $options = [
     'insert_if_missing' => insert_if_missing,
-  );
+  ];
   return chado_update_property($record, $property, $options);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_update_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_update_property().
  *
  * @see chado_update_property().
  */
@@ -378,59 +379,59 @@ function tripal_feature_update_property_by_id($featureprop_id, $property, $value
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_update_property_by_id',
-      '%new_function' => 'chado_update_property'
-    )
+    [
+      '%old_function' => 'tripal_feature_update_property_by_id',
+      '%new_function' => 'chado_update_property',
+    ]
   );
 
-  $record = array(
+  $record = [
     'table' => 'feature',
     'prop_id' => $featureprop_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
     'value' => $value,
-  );
+  ];
   return chado_update_property($record, $property);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_delete_property().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_delete_property().
  *
  * @see chado_delete_property().
  */
-function tripal_feature_delete_property($feature_id, $property, $cv_name='tripal') {
+function tripal_feature_delete_property($feature_id, $property, $cv_name = 'tripal') {
 
   tripal_report_error(
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_delete_property',
-      '%new_function' => 'chado_delete_property'
-    )
+    [
+      '%old_function' => 'tripal_feature_delete_property',
+      '%new_function' => 'chado_delete_property',
+    ]
   );
-  
-  $record = array(
+
+  $record = [
     'table' => 'feature',
     'id' => $feature_id,
-  );
-  $property = array(
+  ];
+  $property = [
     'type_name' => $property,
     'cv_name' => $cv_name,
-  );
+  ];
 
   return chado_delete_property($record, $property);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by chado_delete_record().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by chado_delete_record().
  *
  * @see chado_delete_record().
  */
@@ -440,24 +441,25 @@ function tripal_feature_delete_property_by_id($featureprop_id) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_delete_property_by_id',
-      '%new_function' => 'chado_delete_record'
-    )
+    [
+      '%old_function' => 'tripal_feature_delete_property_by_id',
+      '%new_function' => 'chado_delete_record',
+    ]
   );
 
   // construct the array that will match the exact record to update
-  $match = array(
+  $match = [
     'featureprop_id' => $featureprop_id,
-  );
+  ];
 
   return chado_delete_record('featureprop', $match);
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_reverse_compliment_sequence().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by
+ *   tripal_reverse_compliment_sequence().
  *
  * @see tripal_reverse_compliment_sequence().
  */
@@ -467,10 +469,10 @@ function tripal_feature_reverse_complement($sequence) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_reverse_complement',
-      '%new_function' => 'tripal_reverse_compliment_sequence'
-    )
+    [
+      '%old_function' => 'tripal_feature_reverse_complement',
+      '%new_function' => 'tripal_reverse_compliment_sequence',
+    ]
   );
 
   return tripal_reverse_compliment_sequence($sequence);
@@ -478,8 +480,8 @@ function tripal_feature_reverse_complement($sequence) {
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_associate_dbxref().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_associate_dbxref().
  *
  * @see tripal_associate_dbxref().
  */
@@ -489,26 +491,26 @@ function tripal_feature_add_dbxref($feature_id, $dbname, $accession) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_add_dbxref',
-      '%new_function' => 'tripal_associate_dbxref'
-    )
+    [
+      '%old_function' => 'tripal_feature_add_dbxref',
+      '%new_function' => 'tripal_associate_dbxref',
+    ]
   );
 
   return tripal_associate_dbxref(
     'feature',
     $feature_id,
-    array(
+    [
       'accession' => $accession,
-      'db_name' => $dbname
-    )
+      'db_name' => $dbname,
+    ]
   );
 }
 
 /**
  * @deprecated Restructured API to make naming more readable and consistent.
- * Function was deprecated in Tripal 2.0 and will be removed 2 releases from now.
- * This function has been replaced by tripal_associate_cvterm().
+ * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
+ *   now. This function has been replaced by tripal_associate_cvterm().
  *
  * @see tripal_associate_cvterm().
  */
@@ -518,18 +520,18 @@ function tripal_feature_add_cvterm($feature_id, $cvname, $cvterm) {
     'tripal_deprecated',
     TRIPAL_NOTICE,
     "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
-    array(
-      '%old_function'=>'tripal_feature_add_cvterm',
-      '%new_function' => 'tripal_associate_cvterm'
-    )
+    [
+      '%old_function' => 'tripal_feature_add_cvterm',
+      '%new_function' => 'tripal_associate_cvterm',
+    ]
   );
 
   return tripal_associate_cvterm(
     'feature',
     $feature_id,
-    array(
+    [
       'name' => $cvterm,
-      'cv_name' => $cvname
-    )
+      'cv_name' => $cvname,
+    ]
   );
 }

+ 72 - 70
legacy/tripal_feature/includes/tripal_feature.admin.inc

@@ -13,7 +13,7 @@ function tripal_feature_admin_feature_view() {
   $output = '';
 
   // set the breadcrumb
-  $breadcrumb = array();
+  $breadcrumb = [];
   $breadcrumb[] = l('Home', '<front>');
   $breadcrumb[] = l('Administration', 'admin');
   $breadcrumb[] = l('Tripal', 'admin/tripal');
@@ -22,7 +22,7 @@ function tripal_feature_admin_feature_view() {
   drupal_set_breadcrumb($breadcrumb);
 
   // Add the view
-  $view = views_embed_view('tripal_feature_admin_features','default');
+  $view = views_embed_view('tripal_feature_admin_features', 'default');
   if (isset($view)) {
     $output .= $view;
   }
@@ -32,7 +32,7 @@ function tripal_feature_admin_feature_view() {
       . 'administrative interface are disabled. <strong>Click each of the following links to '
       . 'enable the pertinent views</strong>:</p>';
     $output .= '<ul>';
-      $output .= '<li>'.l('Features View', 'admin/tripal/legacy/tripal_feature/views/features/enable').'</li>';
+    $output .= '<li>' . l('Features View', 'admin/tripal/legacy/tripal_feature/views/features/enable') . '</li>';
     $output .= '</ul>';
   }
 
@@ -58,93 +58,93 @@ function tripal_feature_admin() {
 
   // FEATURE PAGE TITLES
   // Using the Chado Node: Title & Path API
-  $details = array(
+  $details = [
     'module' => 'tripal_feature',
     'content_type' => 'chado_feature',
-      // An array of options to use under "Page Titles"
-      // the key should be the token and the value should be the human-readable option
-    'options' => array(
+    // An array of options to use under "Page Titles"
+    // the key should be the token and the value should be the human-readable option
+    'options' => [
       '[feature.name]' => 'Feature Name Only',
       '[feature.uniquename]' => 'Feature Unique Name Only',
       // there should always be one options matching the unique constraint.
-      '[feature.name], [feature.uniquename] ([feature.type_id>cvterm.name]) [feature.organism_id>organism.genus] [feature.organism_id>organism.species]' => 'Unique Contraint: Includes the name, uniquename, type and scientific name'
-    ),
+      '[feature.name], [feature.uniquename] ([feature.type_id>cvterm.name]) [feature.organism_id>organism.genus] [feature.organism_id>organism.species]' => 'Unique Contraint: Includes the name, uniquename, type and scientific name',
+    ],
     // the token indicating the unique constraint in the options array
-    'unique_option' => '[feature.name], [feature.uniquename] ([feature.type_id>cvterm.name]) [feature.organism_id>organism.genus] [feature.organism_id>organism.species]'
-  );
+    'unique_option' => '[feature.name], [feature.uniquename] ([feature.type_id>cvterm.name]) [feature.organism_id>organism.genus] [feature.organism_id>organism.species]',
+  ];
   // This call adds the configuration form to your current form
   // This sub-form handles it's own validation & submit
   chado_add_admin_form_set_title($form, $form_state, $details);
 
   // FEATURE NODE URL
   // Using the Chado Node: Title & Path API
-  $details = array(
+  $details = [
     'module' => 'tripal_feature',
     'content_type' => 'chado_feature',
-      // An array of options to use under "Page URL"
-      // the key should be the token and the value should be the human-readable option
-    'options' => array(
+    // An array of options to use under "Page URL"
+    // the key should be the token and the value should be the human-readable option
+    'options' => [
       '/feature/[feature.feature_id]' => 'Feature ID',
-        // there should always be one options matching the unique constraint.
-      '/feature/[feature.organism_id>organism.genus]/[feature.organism_id>organism.species]/[feature.type_id>cvterm.name]/[feature.uniquename]' => 'Unique Contraint: Includes the name, uniquename, type and scientific name'
-    )
-  );
+      // there should always be one options matching the unique constraint.
+      '/feature/[feature.organism_id>organism.genus]/[feature.organism_id>organism.species]/[feature.type_id>cvterm.name]/[feature.uniquename]' => 'Unique Contraint: Includes the name, uniquename, type and scientific name',
+    ],
+  ];
   // This call adds the configuration form to your current form
   // This sub-form handles it's own validation & submit
   chado_add_admin_form_set_url($form, $form_state, $details);
 
   // FEATURE BROWSER
-  $form['browser'] = array(
-     '#type' => 'fieldset',
-     '#title' => t('Feature Browser'),
-     '#collapsible' => TRUE,
-     '#collapsed' => TRUE,
-  );
-  $form['browser']['browser_desc'] = array(
-     '#markup' => t('A feature browser can be added to an organism page to allow users to quickly ' .
-        'access a feature.  This will most likely not be the ideal mechanism for accessing feature ' .
-        'information, especially for large sites, but it will alow users exploring the site (such ' .
-        'as students) to better understand the data types available on the site.'),
-
-  );
-  $form['browser']['feature_types'] = array(
-     '#title'       => t('Feature Types'),
-     '#type'        => 'textarea',
-     '#description' => t("Enter the Sequence Ontology (SO) terms for the feature types that " .
-                         "will be shown in the feature browser."),
-     '#default_value' => variable_get('chado_browser_feature_types', 'gene mRNA'),
-  );
-
-
-  $form['browser']['set_browse_button'] = array(
-     '#type' => 'submit',
-     '#value' => t('Set Browser'),
-     '#weight' => 2,
-  );
+  $form['browser'] = [
+    '#type' => 'fieldset',
+    '#title' => t('Feature Browser'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  ];
+  $form['browser']['browser_desc'] = [
+    '#markup' => t('A feature browser can be added to an organism page to allow users to quickly ' .
+      'access a feature.  This will most likely not be the ideal mechanism for accessing feature ' .
+      'information, especially for large sites, but it will alow users exploring the site (such ' .
+      'as students) to better understand the data types available on the site.'),
+
+  ];
+  $form['browser']['feature_types'] = [
+    '#title' => t('Feature Types'),
+    '#type' => 'textarea',
+    '#description' => t("Enter the Sequence Ontology (SO) terms for the feature types that " .
+      "will be shown in the feature browser."),
+    '#default_value' => variable_get('chado_browser_feature_types', 'gene mRNA'),
+  ];
+
+
+  $form['browser']['set_browse_button'] = [
+    '#type' => 'submit',
+    '#value' => t('Set Browser'),
+    '#weight' => 2,
+  ];
 
   // FEATURE SUMMARY REPORT
-  $form['summary'] = array(
-     '#type' => 'fieldset',
-     '#title' => t('Feature Summary Report'),
-     '#collapsible' => TRUE,
-     '#collapsed' => TRUE,
-  );
-  $form['summary']['feature_mapping'] = array(
-     '#title' => 'Map feature types',
-     '#description' => t('You may specify which Sequence Ontology (SO) terms to show in the ' .
-        'feature summary report by listing them in the following text area.   Enter one per line. ' .
-        'If left blank, all SO terms for all features will be shown in the report. Only those terms ' .
-        'listed below will be shown in the report. Terms will appear in the report in the same order listed. To rename a ' .
-        'SO term to be more human readable form, use an \'=\' sign after the SO term (e.g. \'polypeptide = Protein\')'),
-     '#type' => 'textarea',
-     '#rows' => 15,
-     '#default_value' => variable_get('tripal_feature_summary_report_mapping', ''),
-  );
-  $form['summary']['set_summary_button'] = array(
-     '#type' => 'submit',
-     '#value' => t('Set Summary'),
-     '#weight' => 2,
-  );
+  $form['summary'] = [
+    '#type' => 'fieldset',
+    '#title' => t('Feature Summary Report'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  ];
+  $form['summary']['feature_mapping'] = [
+    '#title' => 'Map feature types',
+    '#description' => t('You may specify which Sequence Ontology (SO) terms to show in the ' .
+      'feature summary report by listing them in the following text area.   Enter one per line. ' .
+      'If left blank, all SO terms for all features will be shown in the report. Only those terms ' .
+      'listed below will be shown in the report. Terms will appear in the report in the same order listed. To rename a ' .
+      'SO term to be more human readable form, use an \'=\' sign after the SO term (e.g. \'polypeptide = Protein\')'),
+    '#type' => 'textarea',
+    '#rows' => 15,
+    '#default_value' => variable_get('tripal_feature_summary_report_mapping', ''),
+  ];
+  $form['summary']['set_summary_button'] = [
+    '#type' => 'submit',
+    '#value' => t('Set Summary'),
+    '#weight' => 2,
+  ];
 
   return system_settings_form($form);
 }
@@ -156,7 +156,7 @@ function tripal_feature_admin() {
  */
 function tripal_feature_admin_validate($form, &$form_state) {
   global $user;  // we need access to the user info
-  $job_args = array();
+  $job_args = [];
 
   variable_set('chado_browser_feature_types', $form_state['values']['feature_types']);
 
@@ -175,6 +175,8 @@ function tripal_feature_admin_validate($form, &$form_state) {
  * Not meant to be called directly.
  */
 function tripal_feature_admin_summary_sort($a, $b) {
-  if ($a['total_features'] == $b['total_features']) return 0;
+  if ($a['total_features'] == $b['total_features']) {
+    return 0;
+  }
   return $b['total_features'] - $a['total_features'];
 }

+ 290 - 249
legacy/tripal_feature/includes/tripal_feature.chado_node.inc

@@ -13,27 +13,27 @@
  * @ingroup tripal_legacy_feature
  */
 function tripal_feature_node_info() {
-  $nodes = array();
+  $nodes = [];
 
-  $nodes['chado_feature'] = array(
-    'name'        => t('Feature (Tripal v2 legacy)'),
-    'base'        => 'chado_feature',
+  $nodes['chado_feature'] = [
+    'name' => t('Feature (Tripal v2 legacy)'),
+    'base' => 'chado_feature',
     'description' => t('A feature from the chado database'),
-    'has_title'   => TRUE,
-    'locked'      => TRUE,
-    'chado_node_api' => array(
+    'has_title' => TRUE,
+    'locked' => TRUE,
+    'chado_node_api' => [
       'base_table' => 'feature',
       'hook_prefix' => 'chado_feature',
-      'record_type_title' => array(
+      'record_type_title' => [
         'singular' => t('Feature'),
-        'plural' => t('Features')
-      ),
-      'sync_filters' => array(
+        'plural' => t('Features'),
+      ],
+      'sync_filters' => [
         'type_id' => TRUE,
-        'organism_id' => TRUE
-      ),
-    )
-  );
+        'organism_id' => TRUE,
+      ],
+    ],
+  ];
   return $nodes;
 }
 
@@ -44,7 +44,7 @@ function tripal_feature_node_info() {
  */
 function chado_feature_form($node, &$form_state) {
 
-  $form = array();
+  $form = [];
 
   // Default values can come in the following ways:
   //
@@ -55,121 +55,121 @@ function chado_feature_form($node, &$form_state) {
   //    form elements and the form is being rebuilt
   //
   // set form field defaults
-  $feature      = null;
-  $feature_id   = null;
-  $uniquename   = '';
-  $fname        = '';
+  $feature = NULL;
+  $feature_id = NULL;
+  $uniquename = '';
+  $fname = '';
   $feature_type = '';
-  $organism_id  = '';
-  $residues     = '';
-  $is_obsolete  = '';
-  $analyses     = '';
-  $references   = '';
-  $synonyms     = '';
+  $organism_id = '';
+  $residues = '';
+  $is_obsolete = '';
+  $analyses = '';
+  $references = '';
+  $synonyms = '';
 
   // if we are editing an existing node then the feature is already part of the node
   if (property_exists($node, 'feature')) {
     $feature = $node->feature;
     $feature = chado_expand_var($feature, 'field', 'feature.residues');
-    $feature_id   = $feature->feature_id;
-    $uniquename   = $feature->uniquename;
-    $fname        = $feature->name;
+    $feature_id = $feature->feature_id;
+    $uniquename = $feature->uniquename;
+    $fname = $feature->name;
     $feature_type = $feature->type_id->name;
-    $organism_id  = $feature->organism_id->organism_id;
-    $residues     = $feature->residues;
-    $is_obsolete  = $feature->is_obsolete;
+    $organism_id = $feature->organism_id->organism_id;
+    $residues = $feature->residues;
+    $is_obsolete = $feature->is_obsolete;
 
     // get the synonyms from a previous post
     $synonyms = '';
-    if(property_exists($node, 'synonyms')) {
+    if (property_exists($node, 'synonyms')) {
       $synonyms = $node->synonyms;
     }
 
     // get synonyms from the database if we don't already have them
     if (!$synonyms) {
-      $options = array('return_array' => 1);
+      $options = ['return_array' => 1];
       $feature = chado_expand_var($feature, 'table', 'feature_synonym', $options);
-      $feature_synonyms = (isset($feature->feature_synonym)) ? $feature->feature_synonym : array();
+      $feature_synonyms = (isset($feature->feature_synonym)) ? $feature->feature_synonym : [];
       foreach ($feature_synonyms as $index => $synonym) {
         $synonyms .= $synonym->synonym_id->name . "\n";
       }
     }
     // keep track of the feature id
-    $form['feature_id'] = array(
+    $form['feature_id'] = [
       '#type' => 'value',
       '#value' => $feature_id,
-    );
+    ];
   }
   // if we are re constructing the form from a failed validation or ajax callback
   // then use the $form_state['values'] values
   if (array_key_exists('values', $form_state) and isset($form_state['values']['uniquename'])) {
-    $uniquename   = $form_state['values']['uniquename'];
-    $fname        = $form_state['values']['fname'];
+    $uniquename = $form_state['values']['uniquename'];
+    $fname = $form_state['values']['fname'];
     $feature_type = $form_state['values']['feature_type'];
-    $organism_id  = $form_state['values']['organism_id'];
-    $residues     = $form_state['values']['residues'];
-    $is_obsolete  = $form_state['values']['is_obsolete'];
-    $synonyms     = $form_state['values']['synonyms'];
+    $organism_id = $form_state['values']['organism_id'];
+    $residues = $form_state['values']['residues'];
+    $is_obsolete = $form_state['values']['is_obsolete'];
+    $synonyms = $form_state['values']['synonyms'];
   }
   // if we are re building the form from after submission (from ajax call) then
   // the values are in the $form_state['input'] array
   if (array_key_exists('input', $form_state) and !empty($form_state['input'])) {
-    $uniquename   = $form_state['input']['uniquename'];
-    $fname        = $form_state['input']['fname'];
+    $uniquename = $form_state['input']['uniquename'];
+    $fname = $form_state['input']['fname'];
     $feature_type = $form_state['input']['feature_type'];
-    $organism_id  = $form_state['input']['organism_id'];
-    $residues     = $form_state['input']['residues'];
-    $is_obsolete  = array_key_exists('is_obsolete', $form_state['input']) ? $form_state['input']['is_obsolete'] : FALSE;
-    $synonyms     = $form_state['input']['synonyms'];
+    $organism_id = $form_state['input']['organism_id'];
+    $residues = $form_state['input']['residues'];
+    $is_obsolete = array_key_exists('is_obsolete', $form_state['input']) ? $form_state['input']['is_obsolete'] : FALSE;
+    $synonyms = $form_state['input']['synonyms'];
   }
 
-  $form['fname']= array(
+  $form['fname'] = [
     '#type' => 'textfield',
     '#title' => t('Feature Name'),
     '#required' => TRUE,
     '#default_value' => $fname,
     '#description' => t('Enter the name used by humans to refer to this feature.'),
-    '#maxlength' => 255
-  );
-  $form['uniquename']= array(
+    '#maxlength' => 255,
+  ];
+  $form['uniquename'] = [
     '#type' => 'textfield',
     '#title' => t('Unique Feature Name'),
     '#required' => TRUE,
     '#default_value' => $uniquename,
     '#description' => t('Enter a unique name for this feature.  This name must be unique for the organism and feature type.'),
-    '#maxlength' => 255
-  );
+    '#maxlength' => 255,
+  ];
 
   //$type_options = tripal_get_cvterm_default_select_options('feature', 'type_id', 'feature types');
   //$type_options[0] = 'Select a Type';
   $type_cv = tripal_get_default_cv('feature', 'type_id');
   $cv_id = $type_cv->cv_id;
 
-  $form['feature_type'] = array(
-   '#title'       => t('Feature Type'),
-   '#type'        => 'textfield',
-   '#description' => t("Choose the feature type."),
-   '#required'    => TRUE,
-   '#default_value' => $feature_type,
-   '#autocomplete_path' => "aadmin/tripal/storage/chado/auto_name/cvterm/$cv_id",
-  );
+  $form['feature_type'] = [
+    '#title' => t('Feature Type'),
+    '#type' => 'textfield',
+    '#description' => t("Choose the feature type."),
+    '#required' => TRUE,
+    '#default_value' => $feature_type,
+    '#autocomplete_path' => "aadmin/tripal/storage/chado/auto_name/cvterm/$cv_id",
+  ];
 
   // get the list of organisms
   $sql = "SELECT * FROM {Organism} ORDER BY genus, species";
   $org_rset = chado_query($sql);
-  $organisms = array();
+  $organisms = [];
   $organisms[''] = '';
   while ($organism = $org_rset->fetchObject()) {
     $organisms[$organism->organism_id] = "$organism->genus $organism->species ($organism->common_name)";
   }
-  $form['organism_id'] = array(
-    '#title'       => t('Organism'),
-    '#type'        => t('select'),
+  $form['organism_id'] = [
+    '#title' => t('Organism'),
+    '#type' => t('select'),
     '#description' => t("Choose the organism with which this feature is associated"),
-    '#required'    => TRUE,
+    '#required' => TRUE,
     '#default_value' => $organism_id,
-    '#options'     => $organisms,
-  );
+    '#options' => $organisms,
+  ];
 
   // Get synonyms
   $syn_text = '';
@@ -183,66 +183,72 @@ function chado_feature_form($node, &$form_state) {
       $syn_text = $synonyms;
     }
   }
-  $form['synonyms']= array(
+  $form['synonyms'] = [
     '#type' => 'textarea',
     '#title' => t('Synonyms'),
     '#required' => FALSE,
     '#default_value' => $syn_text,
     '#description' => t('Enter alternate names (synonmys) for this feature to help in searching and identification. You may enter as many alternate names as needed each on different lines.'),
-  );
+  ];
 
-  $form['residues']= array(
+  $form['residues'] = [
     '#type' => 'textarea',
     '#title' => t('Residues'),
     '#required' => FALSE,
     '#default_value' => $residues,
     '#description' => t('Enter the nucelotide sequences for this feature'),
-  );
+  ];
 
   $checked = '';
   if ($is_obsolete == 't') {
     $checked = '1';
   }
-  $form['is_obsolete']= array(
+  $form['is_obsolete'] = [
     '#type' => 'checkbox',
     '#title' => t('Is Obsolete'),
     '#required' => FALSE,
     '#default_value' => $checked,
     '#description' => t('Check this box if this sequence should be retired'),
-  );
+  ];
 
   // PROPERTIES FORM
   //---------------------------------------------
   $prop_cv = tripal_get_default_cv('featureprop', 'type_id');
   $cv_id = $prop_cv ? $prop_cv->cv_id : NULL;
-  $details = array(
-    'property_table' => 'featureprop',      // the name of the prop table
-    'chado_id' => $feature_id,              // the value of feature_id for this record
-    'cv_id' => $cv_id                       // the cv.cv_id of the cv governing featureprop.type_id
-  );
+  $details = [
+    'property_table' => 'featureprop',
+    // the name of the prop table
+    'chado_id' => $feature_id,
+    // the value of feature_id for this record
+    'cv_id' => $cv_id
+    // the cv.cv_id of the cv governing featureprop.type_id
+  ];
   chado_add_node_form_properties($form, $form_state, $details);
 
   // ADDITIONAL DBXREFS FORM
   //---------------------------------------------
-  $details = array(
-    'linking_table' => 'feature_dbxref',  // the name of the _dbxref table
-    'base_foreign_key' => 'feature_id',   // the name of the key in your base chado table
-    'base_key_value' => $feature_id       // the value of feature_id for this record
-  );
+  $details = [
+    'linking_table' => 'feature_dbxref',
+    // the name of the _dbxref table
+    'base_foreign_key' => 'feature_id',
+    // the name of the key in your base chado table
+    'base_key_value' => $feature_id
+    // the value of feature_id for this record
+  ];
   chado_add_node_form_dbxrefs($form, $form_state, $details);
 
   // RELATIONSHIPS FORM
   //---------------------------------------------
   $relationship_cv = tripal_get_default_cv('feature_relationship', 'type_id');
   $cv_id = $relationship_cv ? $relationship_cv->cv_id : NULL;
-  $details = array(
+  $details = [
     'relationship_table' => 'feature_relationship',
     'base_table' => 'feature',
     'base_foreign_key' => 'feature_id',
     'base_key_value' => $feature_id,
     'nodetype' => 'feature',
-    'cv_id' => $cv_id
-  );
+    'cv_id' => $cv_id,
+  ];
   chado_add_node_form_relationships($form, $form_state, $details);
 
   return $form;
@@ -265,7 +271,7 @@ function chado_feature_validate($node, $form, &$form_state) {
   // Since this validate can be called on AJAX and Deletion of the node
   // we need to make this check to ensure queries are not executed
   // without the proper values.
-  if(property_exists($node, "op") and $node->op != 'Save') {
+  if (property_exists($node, "op") and $node->op != 'Save') {
     return;
   }
 
@@ -276,19 +282,19 @@ function chado_feature_validate($node, $form, &$form_state) {
   }
 
   // remove surrounding white-space on submitted values
-  $node->uniquename   = property_exists($node, 'uniquename') ? trim($node->uniquename) : '';
-  $node->fname        = property_exists($node, 'fname') ? trim($node->fname) : '';
+  $node->uniquename = property_exists($node, 'uniquename') ? trim($node->uniquename) : '';
+  $node->fname = property_exists($node, 'fname') ? trim($node->fname) : '';
   $node->feature_type = property_exists($node, 'feature_type') ? trim($node->feature_type) : '';
-  $node->residues     = property_exists($node, 'residues') ? trim($node->residues) : '';
+  $node->residues = property_exists($node, 'residues') ? trim($node->residues) : '';
 
   // Validating for an update
   if (property_exists($node, 'nid')) {
 
     // make sure the feature type is a real sequence ontology term
-    $type = tripal_get_cvterm(array(
+    $type = tripal_get_cvterm([
       'name' => $node->feature_type,
-      'cv_id' => array('name' =>'sequence')
-    ));
+      'cv_id' => ['name' => 'sequence'],
+    ]);
     if (!$type) {
       form_set_error('feature_type', t("The feature type is not a valid name from the Sequence Ontology."));
     }
@@ -307,8 +313,12 @@ function chado_feature_validate($node, $form, &$form_state) {
           CVT.name         = :cvtname AND
           NOT f.feature_id = :feature_id
       ";
-      $args = array(':uname' => $node->uniquename, ':organism_id' => $node->organism_id,
-        ':cvtname' => $node->feature_type, ':feature_id' => $node->feature_id);
+      $args = [
+        ':uname' => $node->uniquename,
+        ':organism_id' => $node->organism_id,
+        ':cvtname' => $node->feature_type,
+        ':feature_id' => $node->feature_id,
+      ];
       $result = chado_query($sql, $args)->fetchObject();
       if ($result) {
         form_set_error('uniquename', t("Feature update cannot proceed. The feature name '$node->uniquename' is not unique for this organism. Please provide a unique name for this feature."));
@@ -319,10 +329,10 @@ function chado_feature_validate($node, $form, &$form_state) {
   else {
 
     // make sure the feature type is a real sequence ontology term
-    $type = tripal_get_cvterm(array(
+    $type = tripal_get_cvterm([
       'name' => $node->feature_type,
-      'cv_id' => array('name' => 'sequence')
-    ));
+      'cv_id' => ['name' => 'sequence'],
+    ]);
     if (!$type) {
       form_set_error('feature_type', t("The feature type is not a valid name from the Sequence Ontology."));
     }
@@ -338,7 +348,11 @@ function chado_feature_validate($node, $form, &$form_state) {
         F.organism_id = :organism_id AND
         CVT.name      = :cvtname
     ";
-    $args = array(':name' => $node->uniquename, ':organism_id' => $node->organism_id, ':cvtname' => $node->feature_type);
+    $args = [
+      ':name' => $node->uniquename,
+      ':organism_id' => $node->organism_id,
+      ':cvtname' => $node->feature_type,
+    ];
 
     $result = chado_query($sql, $args)->fetchObject();
     if ($result) {
@@ -352,21 +366,22 @@ function chado_feature_validate($node, $form, &$form_state) {
  *
  * This hook allows node modules to limit access to the node types they define.
  *
- *  @param $node
- *  The node on which the operation is to be performed, or, if it does not yet exist, the
- *  type of node to be created
+ * @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet
+ *   exist, the type of node to be created
  *
- *  @param $op
+ * @param $op
  *  The operation to be performed
  *
- *  @param $account
- *  A user object representing the user for whom the operation is to be performed
+ * @param $account
+ *  A user object representing the user for whom the operation is to be
+ *   performed
  *
- *  @return
- *  If the permission for the specified operation is not set then return FALSE. If the
- *  permission is set then return NULL as this allows other modules to disable
- *  access.  The only exception is when the $op == 'create'.  We will always
- *  return TRUE if the permission is set.
+ * @return
+ *  If the permission for the specified operation is not set then return FALSE.
+ *   If the permission is set then return NULL as this allows other modules to
+ *   disable access.  The only exception is when the $op == 'create'.  We will
+ *   always return TRUE if the permission is set.
  *
  * @ingroup tripal_legacy_feature
  */
@@ -376,7 +391,7 @@ function tripal_feature_node_access($node, $op, $account) {
     $node_type = $node->type;
   }
 
-  if($node_type == 'chado_feature') {
+  if ($node_type == 'chado_feature') {
     if ($op == 'create') {
       if (!user_access('create chado_feature content', $account)) {
         return NODE_ACCESS_DENY;
@@ -420,10 +435,10 @@ function chado_feature_insert($node) {
   // we can skip adding the feature as it is already there, although
   // we do need to proceed with insertion into the chado/drupal linking table.
   if (!property_exists($node, 'feature_id')) {
-    $node->uniquename   = trim($node->uniquename);
-    $node->fname        = trim($node->fname);
+    $node->uniquename = trim($node->uniquename);
+    $node->fname = trim($node->fname);
     $node->feature_type = trim($node->feature_type);
-    $node->residues     = trim($node->residues);
+    $node->residues = trim($node->residues);
 
     // remove spaces, newlines from residues
     $residues = preg_replace("/[\n\r\s]/", "", $node->residues);
@@ -433,15 +448,15 @@ function chado_feature_insert($node) {
     }
 
     // get the feature type id
-    $values = array(
-        'cv_id' => array(
-            'name' => 'sequence'
-        ),
-        'name' => $node->feature_type
-    );
-    $type = chado_select_record('cvterm', array('cvterm_id'), $values);
+    $values = [
+      'cv_id' => [
+        'name' => 'sequence',
+      ],
+      'name' => $node->feature_type,
+    ];
+    $type = chado_select_record('cvterm', ['cvterm_id'], $values);
 
-    $values = array(
+    $values = [
       'organism_id' => $node->organism_id,
       'name' => $node->fname,
       'uniquename' => $node->uniquename,
@@ -449,13 +464,13 @@ function chado_feature_insert($node) {
       'seqlen' => drupal_strlen($residues),
       'is_obsolete' => $obsolete,
       'type_id' => $type[0]->cvterm_id,
-      'md5checksum' => md5($residues)
-    );
+      'md5checksum' => md5($residues),
+    ];
     $feature = chado_insert_record('feature', $values);
     if (!$feature) {
       drupal_set_message(t('Unable to add feature.'), 'warning');
       tripal_report_error('tripal_feature', TRIPAL_WARNING, 'Insert feature: Unable to create feature where values: %values',
-      array('%values' => print_r($values, TRUE)));
+        ['%values' => print_r($values, TRUE)]);
       return;
     }
     $feature_id = $feature['feature_id'];
@@ -464,27 +479,34 @@ function chado_feature_insert($node) {
     chado_feature_add_synonyms($node->synonyms, $feature_id);
 
     // * Properties Form *
-    $details = array(
-      'property_table' => 'featureprop',   // the name of the prop table
-      'base_table' => 'feature',           // the name of your chado base table
-      'foreignkey_name' => 'feature_id',   // the name of the key in your base table
-      'foreignkey_value' => $feature_id    // the value of the feature_id key
-    );
+    $details = [
+      'property_table' => 'featureprop',
+      // the name of the prop table
+      'base_table' => 'feature',
+      // the name of your chado base table
+      'foreignkey_name' => 'feature_id',
+      // the name of the key in your base table
+      'foreignkey_value' => $feature_id
+      // the value of the feature_id key
+    ];
     chado_update_node_form_properties($node, $details);
 
     // * Additional DBxrefs Form *
-    $details = array(
-      'linking_table' => 'feature_dbxref',   // the name of your _dbxref table
-      'foreignkey_name' => 'feature_id',     // the name of the key in your base table
-      'foreignkey_value' => $feature_id      // the value of the feature_id key
-    );
+    $details = [
+      'linking_table' => 'feature_dbxref',
+      // the name of your _dbxref table
+      'foreignkey_name' => 'feature_id',
+      // the name of the key in your base table
+      'foreignkey_value' => $feature_id
+      // the value of the feature_id key
+    ];
     chado_update_node_form_dbxrefs($node, $details);
 
     // * Relationships Form *
-    $details = array(
+    $details = [
       'relationship_table' => 'feature_relationship',
-      'foreignkey_value' => $feature_id
-    );
+      'foreignkey_value' => $feature_id,
+    ];
     chado_update_node_form_relationships($node, $details);
 
   }
@@ -511,10 +533,10 @@ function chado_feature_insert($node) {
  */
 function chado_feature_update($node) {
 
-  $node->uniquename   = trim($node->uniquename);
-  $node->fname        = trim($node->fname);
+  $node->uniquename = trim($node->uniquename);
+  $node->fname = trim($node->fname);
   $node->feature_type = trim($node->feature_type);
-  $node->residues     = trim($node->residues);
+  $node->residues = trim($node->residues);
 
 
   $residues = preg_replace("/[\n\r\s]/", "", $node->residues);
@@ -524,21 +546,21 @@ function chado_feature_update($node) {
   }
 
   // get the feature type id
-  $values = array(
-    'cv_id' => array(
-      'name' => 'sequence'
-    ),
-    'name' => $node->feature_type
-  );
-  $type = chado_select_record('cvterm', array('cvterm_id'), $values);
+  $values = [
+    'cv_id' => [
+      'name' => 'sequence',
+    ],
+    'name' => $node->feature_type,
+  ];
+  $type = chado_select_record('cvterm', ['cvterm_id'], $values);
 
-  $feature_id = chado_get_id_from_nid('feature', $node->nid) ;
+  $feature_id = chado_get_id_from_nid('feature', $node->nid);
 
   if (sizeof($type) > 0) {
-    $match = array(
+    $match = [
       'feature_id' => $feature_id,
-    );
-    $values = array(
+    ];
+    $values = [
       'organism_id' => $node->organism_id,
       'name' => $node->fname,
       'uniquename' => $node->uniquename,
@@ -546,44 +568,51 @@ function chado_feature_update($node) {
       'seqlen' => drupal_strlen($residues),
       'is_obsolete' => $obsolete,
       'type_id' => $type[0]->cvterm_id,
-      'md5checksum' => md5($residues)
-    );
-    $options = array('return_record' => TRUE);
+      'md5checksum' => md5($residues),
+    ];
+    $options = ['return_record' => TRUE];
     $status = chado_update_record('feature', $match, $values, $options);
 
     // add the genbank synonyms
     chado_feature_add_synonyms($node->synonyms, $feature_id);
 
     // * Properties Form *
-    $details = array(
-      'property_table' => 'featureprop',   // the name of the prop table
-      'base_table' => 'feature',           // the name of your chado base table
-      'foreignkey_name' => 'feature_id',   // the name of the key in your base table
-      'foreignkey_value' => $feature_id    // the value of the feature_id key
-    );
+    $details = [
+      'property_table' => 'featureprop',
+      // the name of the prop table
+      'base_table' => 'feature',
+      // the name of your chado base table
+      'foreignkey_name' => 'feature_id',
+      // the name of the key in your base table
+      'foreignkey_value' => $feature_id
+      // the value of the feature_id key
+    ];
     chado_update_node_form_properties($node, $details);
 
     // * Additional DBxrefs Form *
-    $details = array(
-      'linking_table' => 'feature_dbxref',   // the name of your _dbxref table
-      'foreignkey_name' => 'feature_id',     // the name of the key in your base table
-      'foreignkey_value' => $feature_id      // the value of the feature_id key
-    );
+    $details = [
+      'linking_table' => 'feature_dbxref',
+      // the name of your _dbxref table
+      'foreignkey_name' => 'feature_id',
+      // the name of the key in your base table
+      'foreignkey_value' => $feature_id
+      // the value of the feature_id key
+    ];
     chado_update_node_form_dbxrefs($node, $details);
 
     // * Relationships Form *
-    $details = array(
+    $details = [
       'relationship_table' => 'feature_relationship',
-      'foreignkey_value' => $feature_id
-    );
+      'foreignkey_value' => $feature_id,
+    ];
     chado_update_node_form_relationships($node, $details);
 
   }
   else {
     drupal_set_message(t('Unable to update feature.'), 'warning');
     tripal_report_error('tripal_feature', TRIPAL_WARNING,
-     'Update feature: Unable to update feature where values: %values',
-     array('%values' => print_r($values, TRUE))
+      'Update feature: Unable to update feature where values: %values',
+      ['%values' => print_r($values, TRUE)]
     );
   }
 
@@ -597,7 +626,7 @@ function chado_feature_update($node) {
  */
 function chado_feature_delete($node) {
 
-  $feature_id  = chado_get_id_from_nid('feature', $node->nid);
+  $feature_id = chado_get_id_from_nid('feature', $node->nid);
 
   // If we don't have a feature id for this node then this isn't a node of
   // type chado_library or the entry in the chado_library table was lost.
@@ -607,11 +636,11 @@ function chado_feature_delete($node) {
 
   // Remove the drupal content.
   $sql_del = "DELETE FROM {chado_feature} WHERE nid = :nid AND vid = :vid";
-  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
+  db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
   $sql_del = "DELETE FROM {node} WHERE nid = :nid AND vid = :vid";
-  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
+  db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
   $sql_del = "DELETE FROM {node_revision} WHERE nid = :nid AND vid = :vid";
-  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
+  db_query($sql_del, [':nid' => $node->nid, ':vid' => $node->vid]);
 
 
   // Remove data from feature tables of chado database.  This will
@@ -622,16 +651,16 @@ function chado_feature_delete($node) {
   // the chado_query function can handle this problem so we specificall delete
   // from that table to prevent the error. The same problem exists for the
   // frange.featuregroup table
-  $previous_db = chado_set_active('chado') ;
-  db_query("DELETE FROM frange.featuregroup WHERE subject_id = :feature_id", array(':feature_id' => $feature_id));
-  db_query("DELETE FROM frange.featuregroup WHERE object_id = :feature_id", array(':feature_id' => $feature_id));
-  db_query("DELETE FROM frange.featuregroup WHERE group_id = :feature_id", array(':feature_id' => $feature_id));
-  db_query("DELETE FROM frange.featuregroup WHERE srcfeature_id = :feature_id", array(':feature_id' => $feature_id));
+  $previous_db = chado_set_active('chado');
+  db_query("DELETE FROM frange.featuregroup WHERE subject_id = :feature_id", [':feature_id' => $feature_id]);
+  db_query("DELETE FROM frange.featuregroup WHERE object_id = :feature_id", [':feature_id' => $feature_id]);
+  db_query("DELETE FROM frange.featuregroup WHERE group_id = :feature_id", [':feature_id' => $feature_id]);
+  db_query("DELETE FROM frange.featuregroup WHERE srcfeature_id = :feature_id", [':feature_id' => $feature_id]);
   chado_set_active($previous_db);
 
-  chado_query("DELETE FROM {featureloc} WHERE feature_id = :feature_id", array(':feature_id' => $feature_id));
-  chado_query("DELETE FROM {featureloc} WHERE srcfeature_id = :feature_id", array(':feature_id' => $feature_id));
-  chado_query("DELETE FROM {feature} WHERE feature_id = :feature_id", array(':feature_id' => $feature_id));
+  chado_query("DELETE FROM {featureloc} WHERE feature_id = :feature_id", [':feature_id' => $feature_id]);
+  chado_query("DELETE FROM {featureloc} WHERE srcfeature_id = :feature_id", [':feature_id' => $feature_id]);
+  chado_query("DELETE FROM {feature} WHERE feature_id = :feature_id", [':feature_id' => $feature_id]);
 
   drupal_set_message(t("The feature and all associated data were removed"));
 }
@@ -651,14 +680,14 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
   // separate synomys by carriage returns
   $synonyms = preg_replace("/[\n\r]+/", " ", $synonyms);
   // split the synonyms into an array based on a space as the delimieter
-  $syn_array = array();
+  $syn_array = [];
   $syn_array = explode(" ", $synonyms);
 
 
   // remove any old synonyms
   $feature_syn_dsql = "DELETE FROM {feature_synonym} WHERE feature_id = :feature_id";
-  if (!chado_query($feature_syn_dsql, array(':feature_id' => $feature_id))) {
-    tripal_report_error('tripal_feature', TRIPAL_ERROR, "Could not remove synonyms from feature. ", array());
+  if (!chado_query($feature_syn_dsql, [':feature_id' => $feature_id])) {
+    tripal_report_error('tripal_feature', TRIPAL_ERROR, "Could not remove synonyms from feature. ", []);
     return;
   }
 
@@ -677,7 +706,7 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
     // if so then don't add it again. it messes up drupal if the insert fails.
     // It is possible for the accession number to be present and not the feature
     $synonym_sql = "SELECT synonym_id FROM {synonym} WHERE name = :name";
-    $synonym = chado_query($synonym_sql, array(':name' => $syn))->fetchObject();
+    $synonym = chado_query($synonym_sql, [':name' => $syn])->fetchObject();
     if (!$synonym) {
       $synonym_isql = "
         INSERT INTO {synonym} (name, synonym_sgml, type_id)
@@ -688,22 +717,29 @@ function chado_feature_add_synonyms($synonyms, $feature_id) {
            WHERE CV.name = 'feature_property' and CVT.name = 'synonym')
           )
       ";
-      if (!chado_query($synonym_isql, array(':name' => $syn, ':synonym_sgml' => $syn))) {
-        tripal_report_error('tripal_feature', "Could not add synonym. ", array(), TRIPAL_WARNING);
+      if (!chado_query($synonym_isql, [
+        ':name' => $syn,
+        ':synonym_sgml' => $syn,
+      ])) {
+        tripal_report_error('tripal_feature', "Could not add synonym. ", [], TRIPAL_WARNING);
         return;
       }
       // now get the synonym we just added
       $synonym_sql = "SELECT synonym_id FROM {synonym} WHERE name = :name";
-      $synonym = chado_query($synonym_sql, array(':name' => $syn))->fetchObject();
+      $synonym = chado_query($synonym_sql, [':name' => $syn])->fetchObject();
     }
 
     // now add in our new sysnonym
     $feature_syn_isql = "
       INSERT INTO {feature_synonym} (synonym_id,feature_id,pub_id)
       VALUES (:synonym_id, :feature_id, :pub_id)";
-    $args = array(':synonym_id' => $synonym->synonym_id, ':feature_id' => $feature_id, ':pub_id'=> 1);
+    $args = [
+      ':synonym_id' => $synonym->synonym_id,
+      ':feature_id' => $feature_id,
+      ':pub_id' => 1,
+    ];
     if (!chado_query($feature_syn_isql, $args)) {
-      tripal_report_error('tripal_feature', "Could not associate synonym with feature. ", array(), TRIPAL_WARNING);
+      tripal_report_error('tripal_feature', "Could not associate synonym with feature. ", [], TRIPAL_WARNING);
       return;
     }
   }
@@ -730,7 +766,7 @@ function chado_feature_load($nodes) {
     }
 
     // build the feature variable
-    $values = array('feature_id' => $feature_id);
+    $values = ['feature_id' => $feature_id];
     $feature = chado_generate_var('feature', $values);
     $nodes[$nid]->feature = $feature;
 
@@ -761,22 +797,27 @@ function tripal_feature_node_presave($node) {
       $name = '';
       $uname = '';
       $type = '';
-      $organism_id = null;
-      if(property_exists($node, 'uniquename')) {
+      $organism_id = NULL;
+      if (property_exists($node, 'uniquename')) {
         $organism_id = $node->organism_id;
-        $name        = $node->name;
-        $uname       = $node->uniquename;
-        $type        = $node->feature_type;
+        $name = $node->name;
+        $uname = $node->uniquename;
+        $type = $node->feature_type;
       }
-      else if (property_exists($node, 'feature')) {
-        $organism_id = $node->feature->organism_id;
-        $name        = $node->feature->name;
-        $uname       = $node->feature->uniquename;
-        $type        = $node->feature->cvtname;
+      else {
+        if (property_exists($node, 'feature')) {
+          $organism_id = $node->feature->organism_id;
+          $name = $node->feature->name;
+          $uname = $node->feature->uniquename;
+          $type = $node->feature->cvtname;
+        }
       }
 
-      $values = array('organism_id' => $organism_id);
-      $organism = chado_select_record('organism', array('genus', 'species'), $values);
+      $values = ['organism_id' => $organism_id];
+      $organism = chado_select_record('organism', [
+        'genus',
+        'species',
+      ], $values);
       $node->title = "$name, $uname ($type) " . $organism[0]->genus . ' ' . $organism[0]->species;
 
       break;
@@ -799,7 +840,7 @@ function tripal_feature_node_insert($node) {
       // we need to simulate one so that the right values are available for
       // the URL to be determined.
       $feature_id = chado_get_id_from_nid('feature', $node->nid);
-      $node->feature = chado_generate_var('feature', array('feature_id' => $feature_id));
+      $node->feature = chado_generate_var('feature', ['feature_id' => $feature_id]);
 
       // Now use the API to set the path.
       chado_set_node_url($node);
@@ -844,93 +885,93 @@ function tripal_feature_node_view($node, $view_mode, $langcode) {
     case 'chado_feature':
       // Show feature browser and counts
       if ($view_mode == 'full') {
-        $node->content['tripal_feature_alignments'] = array(
+        $node->content['tripal_feature_alignments'] = [
           '#theme' => 'tripal_feature_alignments',
           '#node' => $node,
-          '#tripal_toc_id'    => 'alignments',
+          '#tripal_toc_id' => 'alignments',
           '#tripal_toc_title' => 'Alignments',
-        );
-        $node->content['tripal_feature_analyses'] = array(
+        ];
+        $node->content['tripal_feature_analyses'] = [
           '#theme' => 'tripal_feature_analyses',
           '#node' => $node,
-          '#tripal_toc_id'    => 'analyses',
+          '#tripal_toc_id' => 'analyses',
           '#tripal_toc_title' => 'Analyses',
-        );
-        $node->content['tripal_feature_base'] = array(
+        ];
+        $node->content['tripal_feature_base'] = [
           '#theme' => 'tripal_feature_base',
           '#node' => $node,
-          '#tripal_toc_id'    => 'base',
+          '#tripal_toc_id' => 'base',
           '#tripal_toc_title' => 'Overview',
           '#weight' => -100,
-        );
-        $node->content['tripal_feature_properties'] = array(
+        ];
+        $node->content['tripal_feature_properties'] = [
           '#theme' => 'tripal_feature_properties',
           '#node' => $node,
-          '#tripal_toc_id'    => 'properties',
+          '#tripal_toc_id' => 'properties',
           '#tripal_toc_title' => 'Properties',
-        );
-        $node->content['tripal_feature_publications'] = array(
+        ];
+        $node->content['tripal_feature_publications'] = [
           '#theme' => 'tripal_feature_publications',
           '#node' => $node,
-          '#tripal_toc_id'    => 'publications',
+          '#tripal_toc_id' => 'publications',
           '#tripal_toc_title' => 'Publications',
-        );
-        $node->content['tripal_feature_references'] = array(
+        ];
+        $node->content['tripal_feature_references'] = [
           '#theme' => 'tripal_feature_references',
           '#node' => $node,
-          '#tripal_toc_id'    => 'references',
+          '#tripal_toc_id' => 'references',
           '#tripal_toc_title' => 'Cross References',
-        );
-        $node->content['tripal_feature_relationships'] = array(
+        ];
+        $node->content['tripal_feature_relationships'] = [
           '#theme' => 'tripal_feature_relationships',
           '#node' => $node,
-          '#tripal_toc_id'    => 'relationships',
+          '#tripal_toc_id' => 'relationships',
           '#tripal_toc_title' => 'Relationships',
-        );
-        $node->content['tripal_feature_seqence'] = array(
+        ];
+        $node->content['tripal_feature_seqence'] = [
           '#theme' => 'tripal_feature_sequence',
           '#node' => $node,
-          '#tripal_toc_id'    => 'sequences',
+          '#tripal_toc_id' => 'sequences',
           '#tripal_toc_title' => 'Sequences',
-        );
-        $node->content['tripal_feature_synonyms'] = array(
+        ];
+        $node->content['tripal_feature_synonyms'] = [
           '#theme' => 'tripal_feature_synonyms',
           '#node' => $node,
-          '#tripal_toc_id'    => 'synonyms',
+          '#tripal_toc_id' => 'synonyms',
           '#tripal_toc_title' => 'Synonyms',
-        );
-        $node->content['tripal_feature_terms'] = array(
+        ];
+        $node->content['tripal_feature_terms'] = [
           '#theme' => 'tripal_feature_terms',
           '#node' => $node,
-          '#tripal_toc_id'    => 'terms',
+          '#tripal_toc_id' => 'terms',
           '#tripal_toc_title' => 'Annotated Terms',
-        );
+        ];
       }
       if ($view_mode == 'teaser') {
-        $node->content['tripal_feature_teaser'] = array(
+        $node->content['tripal_feature_teaser'] = [
           '#theme' => 'tripal_feature_teaser',
           '#node' => $node,
-        );
+        ];
       }
       break;
     case 'chado_organism':
       // Show feature browser and counts
       if ($view_mode == 'full') {
-        $node->content['tripal_organism_feature_counts'] = array(
+        $node->content['tripal_organism_feature_counts'] = [
           '#theme' => 'tripal_organism_feature_counts',
           '#node' => $node,
-          '#tripal_toc_id'    => 'feature_counts',
+          '#tripal_toc_id' => 'feature_counts',
           '#tripal_toc_title' => 'Feature Summary',
-        );
-        $node->content['tripal_organism_feature_browser'] = array(
+        ];
+        $node->content['tripal_organism_feature_browser'] = [
           '#theme' => 'tripal_organism_feature_browser',
           '#node' => $node,
-          '#tripal_toc_id'    => 'feature_browser',
+          '#tripal_toc_id' => 'feature_browser',
           '#tripal_toc_title' => 'Feature Browser',
-        );
+        ];
       }
       break;
-      // TODO: handle these node types. Should we also have a feature browser?
+    // TODO: handle these node types. Should we also have a feature browser?
     case 'chado_library':
       break;
     case 'chado_stock':

+ 44 - 45
legacy/tripal_feature/includes/tripal_feature.delete.inc

@@ -10,51 +10,51 @@
  * @ingroup tripal_legacy_feature
  */
 function tripal_feature_delete_form() {
-  $form['desc'] = array(
+  $form['desc'] = [
     '#markup' => t("Use one or more of the following fields to identify sets of features to be deleted."),
-  );
+  ];
 
-  $form['feature_names']= array(
+  $form['feature_names'] = [
     '#type' => 'textarea',
     '#title' => t('Feature Names'),
     '#description' => t('Please provide a list of feature names or unique names,
        separated by spaces or by new lines to be delete. If you specify feature names then
        all other options below will be ignored (except the unique checkbox).'),
-  );
-  $form['is_unique'] = array(
+  ];
+  $form['is_unique'] = [
     '#title' => t('Names are Unique Names'),
     '#type' => 'checkbox',
     '#description' => t('Select this checbox if the names listed in the feature
       names box above are the unique name of the feature rather than the human readable names.'),
-  );
-  $cv = tripal_get_cv(array('name' => 'sequence'));
-  $form['seq_type']= array(
-   '#title'       => t('Feature Type'),
-   '#type'        => 'textfield',
-   '#description' => t("Choose the feature type."),
-   '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/cvterm/$cv->cv_id",
-  );
+  ];
+  $cv = tripal_get_cv(['name' => 'sequence']);
+  $form['seq_type'] = [
+    '#title' => t('Feature Type'),
+    '#type' => 'textfield',
+    '#description' => t("Choose the feature type."),
+    '#autocomplete_path' => "admin/tripal/storage/chado/auto_name/cvterm/$cv->cv_id",
+  ];
 
   $organisms = tripal_get_organism_select_options(FALSE);
-  $form['organism_id'] = array(
-   '#title'       => t('Organism'),
-   '#type'        => 'select',
-   '#description' => t("Choose the organism for which features will be deleted."),
-   '#options'     => $organisms,
-  );
+  $form['organism_id'] = [
+    '#title' => t('Organism'),
+    '#type' => 'select',
+    '#description' => t("Choose the organism for which features will be deleted."),
+    '#options' => $organisms,
+  ];
 
   $analyses = tripal_get_analysis_select_options(FALSE);
-  $form['analysis_id'] = array (
-    '#title'       => t('Analysis'),
-    '#type'        => t('select'),
+  $form['analysis_id'] = [
+    '#title' => t('Analysis'),
+    '#type' => t('select'),
     '#description' => t("Choose the analysis for which associated features will be deleted."),
-    '#options'     => $analyses,
-  );
+    '#options' => $analyses,
+  ];
 
-  $form['button'] = array(
+  $form['button'] = [
     '#type' => 'submit',
     '#value' => t('Delete Features'),
-  );
+  ];
   return $form;
 }
 
@@ -64,10 +64,10 @@ function tripal_feature_delete_form() {
  * @ingroup tripal_legacy_feature
  */
 function tripal_feature_delete_form_validate($form, &$form_state) {
-  $organism_id   = $form_state['values']['organism_id'];
-  $seq_type      = trim($form_state['values']['seq_type']);
-  $analysis_id   = $form_state['values']['analysis_id'];
-  $is_unique     = $form_state['values']['is_unique'];
+  $organism_id = $form_state['values']['organism_id'];
+  $seq_type = trim($form_state['values']['seq_type']);
+  $analysis_id = $form_state['values']['analysis_id'];
+  $is_unique = $form_state['values']['is_unique'];
   $feature_names = $form_state['values']['feature_names'];
 
   if (!$analysis_id and !$organism_id and !$seq_type and !$feature_names) {
@@ -83,13 +83,13 @@ function tripal_feature_delete_form_validate($form, &$form_state) {
 function tripal_feature_delete_form_submit($form, &$form_state) {
   global $user;
 
-  $organism_id   = $form_state['values']['organism_id'];
-  $seq_type      = trim($form_state['values']['seq_type']);
-  $analysis_id   = $form_state['values']['analysis_id'];
-  $is_unique     = $form_state['values']['is_unique'];
+  $organism_id = $form_state['values']['organism_id'];
+  $seq_type = trim($form_state['values']['seq_type']);
+  $analysis_id = $form_state['values']['analysis_id'];
+  $is_unique = $form_state['values']['is_unique'];
   $feature_names = $form_state['values']['feature_names'];
 
-  $args = array($organism_id, $analysis_id, $seq_type, $is_unique, $feature_names);
+  $args = [$organism_id, $analysis_id, $seq_type, $is_unique, $feature_names];
   tripal_add_job("Delete features", 'tripal_feature',
     'tripal_feature_delete_features', $args, $user->uid);
 }
@@ -104,8 +104,8 @@ function tripal_feature_delete_form_submit($form, &$form_state) {
  * @param $seq_type
  *   (Optional) The cvterm.name of the feature types to delete
  * @param $is_unique
- *   (Optional) A Boolean stating whether the names are unique (ie: feature.uniquename)
- *   or not (ie: feature.name)
+ *   (Optional) A Boolean stating whether the names are unique (ie:
+ *   feature.uniquename) or not (ie: feature.name)
  * @param $feature_names
  *   (Optional) A space separated list of the names of features to delete
  * @param $job
@@ -114,16 +114,16 @@ function tripal_feature_delete_form_submit($form, &$form_state) {
  * @ingroup tripal_legacy_feature
  */
 function tripal_feature_delete_features($organism_id, $analysis_id, $seq_type,
-  $is_unique, $feature_names, $job = NULL) {
+                                        $is_unique, $feature_names, $job = NULL) {
 
   global $user;
-  $match = array();
+  $match = [];
 
   // Begin the transaction.
   $transaction = db_transaction();
   print "\nNOTE: Deleting features is performed using a database transaction. \n" .
-      "If the load fails or is terminated prematurely then the entire set of \n" .
-      "deletions is rolled back and will not be found in the database\n\n";
+    "If the load fails or is terminated prematurely then the entire set of \n" .
+    "deletions is rolled back and will not be found in the database\n\n";
   try {
 
     // If feature names have been provided then handle those
@@ -138,7 +138,7 @@ function tripal_feature_delete_features($organism_id, $analysis_id, $seq_type,
       else {
         $match['name'] = $names;
       }
-      $num_deletes = chado_select_record('feature', array('count(*) as cnt'), $match);
+      $num_deletes = chado_select_record('feature', ['count(*) as cnt'], $match);
       print "Deleting " . $num_deletes[0]->cnt . " features\n";
 
       chado_delete_record('feature', $match);
@@ -146,7 +146,7 @@ function tripal_feature_delete_features($organism_id, $analysis_id, $seq_type,
     }
 
     // Now handle the combintation of all other inputs.
-    $args = array();
+    $args = [];
     $sql = "";
     $join = '';
     $where = '';
@@ -194,8 +194,7 @@ function tripal_feature_delete_features($organism_id, $analysis_id, $seq_type,
 
     print "Now removing orphaned feature pages\n";
     chado_cleanup_orphaned_nodes('feature');
-  }
-  catch (Exception $e) {
+  } catch (Exception $e) {
     print "\n"; // make sure we start errors on new line
     $transaction->rollback();
     print "FAILED: Rolling back database changes...\n";

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