commit 6679207a899188bbae8fba986cf4655a6fd2e87d
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Wed Sep 9 10:12:08 2020 +0200

    ref #9222 adapting dataportal and tests to single sourced classes

diff --git a/modules/cdm_dataportal/cdm_dataportal.module b/modules/cdm_dataportal/cdm_dataportal.module
index 61874cbb..851a44b4 100755
--- a/modules/cdm_dataportal/cdm_dataportal.module
+++ b/modules/cdm_dataportal/cdm_dataportal.module
@@ -1342,9 +1342,8 @@ function cdm_dataportal_view_media($mediaUuid, $mediarepresentation_uuid = FALSE
  */
 function _load_taxonBase(&$taxonBase) {
   if (isset($taxonBase->uuid)) {
-    $taxonBase->name = cdm_ws_get(CDM_WS_TAXON, array($taxonBase->uuid, "name"));
-    $taxonBase->name->taggedName = cdm_ws_get(CDM_WS_NAME, array($taxonBase->name->uuid, "taggedName"));
-    $taxonBase->name->nomenclaturalReference = cdm_ws_get(CDM_WS_NAME, array($taxonBase->name->uuid, "nomenclaturalReference"));
+    $taxonBase->name = cdm_ws_get(CDM_WS_PORTAL_TAXON, array($taxonBase->uuid, "name"));
+    $taxonBase->name->nomenclaturalSource = cdm_ws_get(CDM_WS_NAME, array($taxonBase->name->uuid, "nomenclaturalSource"));
   }
 }
 
diff --git a/modules/cdm_dataportal/includes/footnotes.inc b/modules/cdm_dataportal/includes/footnotes.inc
index 1af0461b..18f385e4 100644
--- a/modules/cdm_dataportal/includes/footnotes.inc
+++ b/modules/cdm_dataportal/includes/footnotes.inc
@@ -289,11 +289,11 @@ function handle_name_relationship_as_footnote($name_rel)
   if (isset($name_rel->ruleConsidered) && $name_rel->ruleConsidered) {
     $footnote_markup = '<span class="rule_considered">' . $name_rel->ruleConsidered . '</span> ';
   }
-  if (isset($name_rel->citation)) {
-    $footnote_markup .= '<span class="reference">' . $name_rel->citation->titleCache . '</span>';
+  if (isset($name_rel->source->citation)) {
+    $footnote_markup .= '<span class="reference">' . $name_rel->source->citation->titleCache . '</span>';
   }
-  if (isset($name_rel->citationMicroReference) && $name_rel->citationMicroReference) {
-    $footnote_markup .= (isset($name_rel->citation) ? ':' : '') . ' <span class="reference_detail">' . $name_rel->citationMicroReference . '</span>';
+  if (isset($name_rel->source->citationMicroReference) && $name_rel->source->citationMicroReference) {
+    $footnote_markup .= (isset($name_rel->source->citation) ? ':' : '') . ' <span class="reference_detail">' . $name_rel->source->citationMicroReference . '</span>';
   }
   if ($footnote_markup) {
     $fnkey = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $footnote_markup);
@@ -332,11 +332,11 @@ function handle_nomenclatural_reference_as_footnote($name)
 {
   $footnote_markup = '';
   $footnote_key_markup = '';
-  if (isset($name->nomenclaturalReference) && $name->nomenclaturalReference) {
-    $footnote_markup .= '<span class="reference">' . $name->nomenclaturalReference->titleCache . '</span>';
+  if (isset($name->nomenclaturalSource->citation) && $name->nomenclaturalSource->citation) {
+    $footnote_markup .= '<span class="reference">' . $name->nomenclaturalSource->citation->titleCache . '</span>';
   }
-  if (isset($name->nomenclaturalMicroReference)) {
-    $footnote_markup .= ($footnote_key_markup ? ':' : '') . '<span class="reference_detail">' . $name->nomenclaturalMicroReference . '</span>';
+  if (isset($name->nomenclaturalSource->citationMicroReference)) {
+    $footnote_markup .= ($footnote_key_markup ? ':' : '') . '<span class="reference_detail">' . $name->nomenclaturalSource->citationMicroReference . '</span>';
   }
   if ($footnote_markup) {
     $fnkey = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $footnote_markup);
diff --git a/modules/cdm_dataportal/includes/name.inc b/modules/cdm_dataportal/includes/name.inc
index a9a9b722..5c4e38e7 100644
--- a/modules/cdm_dataportal/includes/name.inc
+++ b/modules/cdm_dataportal/includes/name.inc
@@ -251,27 +251,26 @@ function get_partDefinition($taxonNameType) {
  * part_definitions and render_templates (see get_partDefinition() and
  * get_nameRenderTemplate())
  *
- * @param $taxonName
- *    cdm TaxonName instance
+ * @param $taxon_name_or_taxon_base
+ *    A cdm TaxonBase or TaxonName entity
  * @param $name_link
- *    URI to the taxon, @see path_to_taxon(), must be processed by url() before passing to this method
- * @param $reference_link
- *    URI to the reference, @see path_to_reference(), must be processed by url() before passing to this method
- * @param $show_annotations
+ *    URI to the taxon, @param $reference_link
+ *    URI to the reference, @param bool $show_annotations
  *    turns the display of annotations on
- * @param $is_type_designation
+ * @param bool $is_type_designation
  *    To indicate that the supplied taxon name is a name type designation.
- * @param $skiptags
+ * @param array $skiptags
  *    an array of name elements tags like 'name', 'rank' to skip. The name part
  *          'authors' will not ber affected by this filter. This part is managed though the render template
  *          mechanism.
- * @param $is_invalid
+ * @param bool $is_invalid
  *   Indicates that this taxon is invalid. In this case the name part will be shown in double quotes.
  *   This is useful when rendering taxon relation ships.
  *
  * @return string
  *  The markup for a taxon name.
- *
+ * @see path_to_taxon(), must be processed by url() before passing to this method
+ * @see path_to_reference(), must be processed by url() before passing to this method
  */
 function render_taxon_or_name($taxon_name_or_taxon_base, $name_link = NULL, $reference_link = NULL,
   $show_annotations = true, $is_type_designation = false, $skiptags = array(), $is_invalid = false) {
@@ -413,12 +412,12 @@ function render_taxon_or_name($taxon_name_or_taxon_base, $name_link = NULL, $ref
     // Komma nach dem Autornamen ist überall dort falsch, wo ein "in" folgt."
     if (isset($renderTemplate['referencePart']['reference'])) {
       $microreference = NULL;
-      if (isset($renderTemplate['referencePart']['microreference'])&& isset($taxonName->nomenclaturalMicroReference)) {
-        $microreference = $taxonName->nomenclaturalMicroReference;
+      if (isset($renderTemplate['referencePart']['microreference'])&& isset($taxonName->nomenclaturalSource->citationMicroReference)) {
+        $microreference = $taxonName->nomenclaturalSource->citationMicroReference;
       }
-      if(count($nomref_tagged_text) == 0 && isset($taxonName->nomenclaturalReference)){
+      if(count($nomref_tagged_text) == 0 && isset($taxonName->nomenclaturalSource->citation)){
         // TODO is this case still relevant? The tagged text should already contain all information!
-        $citation = cdm_ws_getNomenclaturalReference($taxonName->nomenclaturalReference->uuid, $microreference);
+        $citation = cdm_ws_getNomenclaturalReference($taxonName->nomenclaturalSource->citation->uuid, $microreference);
         // Find preceding element of the reference.
         $precedingKey = get_preceding_contentElementKey('reference', $renderTemplate);
         if (str_beginsWith($citation, ", in")) {
@@ -460,8 +459,8 @@ function render_taxon_or_name($taxon_name_or_taxon_base, $name_link = NULL, $ref
 
   $is_reference_year = false;
   if (isset($renderTemplate['referenceYearPart']['reference.year'])) {
-    if(isset($taxonName->nomenclaturalReference->datePublished)){
-      $referenceArray['#html'] = ' <span class="reference">' . timePeriodToString($taxonName->nomenclaturalReference->datePublished) . '</span>';
+    if(isset($taxonName->nomenclaturalSource->citation->datePublished)){
+      $referenceArray['#html'] = ' <span class="reference">' . timePeriodToString($taxonName->nomenclaturalSource->citation->datePublished) . '</span>';
       array_setr('reference.year', $referenceArray, $renderTemplate);
       $is_reference_year = true;
     }
@@ -935,8 +934,8 @@ function render_type_designations($type_designations, $enclosing_tag = 'ul', $el
 
         }
         $referenceUri = '';
-        if (isset($name_type_designation->typeName->nomenclaturalReference)) {
-          $referenceUri = url(path_to_reference($name_type_designation->typeName->nomenclaturalReference->uuid));
+        if (isset($name_type_designation->typeName->nomenclaturalSource->citation)) {
+          $referenceUri = url(path_to_reference($name_type_designation->typeName->nomenclaturalSource->citation->uuid));
         }
         $out .= ': ' . render_taxon_or_name($name_type_designation->typeName, $link_to_name_page, $referenceUri, TRUE, TRUE);
       }
diff --git a/modules/cdm_dataportal/includes/pages.inc b/modules/cdm_dataportal/includes/pages.inc
index ef0a675d..d82c29a0 100755
--- a/modules/cdm_dataportal/includes/pages.inc
+++ b/modules/cdm_dataportal/includes/pages.inc
@@ -700,8 +700,8 @@ function compose_cdm_taxon_page_synonymy($taxon, $add_accepted_taxon) {
       $label = variable_get(CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL, CDM_SYNONYMY_ACCEPTED_TAXON_SEC_SEPARATE_LABEL_DEFAULT);
       $accepted_name .= '<div class="secReference"><span class="label">' . t($label) . ':</span> ' . $taxon->sec->titleCache . '</div>';
     }
-    if (isset($taxon->name->nomenclaturalReference)) {
-      $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
+    if (isset($taxon->name->nomenclaturalSource->citation)) {
+      $referenceUri = url(path_to_reference($taxon->name->nomenclaturalSource->citation->uuid));
     }
 
     $accepted_name .= '<div class="accepted-name">';
diff --git a/modules/cdm_dataportal/includes/taxon.inc b/modules/cdm_dataportal/includes/taxon.inc
index e01f54dc..ebfd5a09 100644
--- a/modules/cdm_dataportal/includes/taxon.inc
+++ b/modules/cdm_dataportal/includes/taxon.inc
@@ -380,8 +380,8 @@ function cdm_related_taxon($taxon, $reltype_uuid = NULL, $relsign = NULL, $relty
   // Now rendering starts ..
   RenderHints::pushToRenderStack('related_taxon');
 
-  if (isset($taxon->name->nomenclaturalReference)) {
-    $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
+  if (isset($taxon->name->nomenclaturalSource->citation)) {
+    $referenceUri = url(path_to_reference($taxon->name->nomenclaturalSource->citation->uuid));
   }
   $taxonUri = '';
   if ($doLinkTaxon) {
@@ -464,8 +464,8 @@ function cdm_accepted_for($accepted_for_uuid) {
     $out .= '<span class="acceptedFor">';
     $out .= t('is accepted for ');
     $referenceUri = null;
-    if (isset($synonym->name->nomenclaturalReference)) {
-      $referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
+    if (isset($synonym->name->nomenclaturalSource->citation)) {
+      $referenceUri = url(path_to_reference($synonym->name->nomenclaturalSource->citation->uuid));
     }
     $out .= render_taxon_or_name($synonym->name, NULL, $referenceUri);
     $annotations_and_sources = handle_annotations_and_sources(
@@ -576,8 +576,8 @@ function compose_list_of_taxa($taxon_list, $freetext_search_results = array(), $
 
           $taxonUri = uri_to_synonym($taxon->uuid, $acceptedTaxon->uuid);
           $referenceUri = '';
-          if (isset($acceptedTaxon->name->nomenclaturalReference)) {
-            $referenceUri = url(path_to_reference($acceptedTaxon->name->nomenclaturalReference->uuid));
+          if (isset($acceptedTaxon->name->nomenclaturalSource->citation)) {
+            $referenceUri = url(path_to_reference($acceptedTaxon->name->nomenclaturalSource->citation->uuid));
           }
           $taxon_or_name = $is_synonym ? $taxon->name : $taxon;
           // $taxon_or_name this is a trick to suppress the sec reference for synonyms
@@ -615,8 +615,8 @@ function compose_list_of_taxa($taxon_list, $freetext_search_results = array(), $
       // Its a Taxon.
       $taxonUri = url(path_to_taxon($taxon->uuid));
       $referenceUri = '';
-      if (isset($taxon->name->nomenclaturalReference)) {
-        $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
+      if (isset($taxon->name->nomenclaturalSource->citation)) {
+        $referenceUri = url(path_to_reference($taxon->name->nomenclaturalSource->citation->uuid));
       }
       $out .= '<div class="item Taxon">' . render_taxon_or_name($taxon, $taxonUri, $referenceUri);
       if ($show_classification) {
diff --git a/modules/cdm_dataportal/theme/cdm_dataportal.page.theme b/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
index d92f47a3..611eb67d 100755
--- a/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
+++ b/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
@@ -32,8 +32,8 @@ function theme_cdm_taxon_page_title($variables) {
   RenderHints::pushToRenderStack('taxon_page_title');
   $referenceUri = '';
   $out = '';
-  if (isset($taxon->name->nomenclaturalReference)) {
-    $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
+  if (isset($taxon->name->nomenclaturalSource->citation)) {
+    $referenceUri = url(path_to_reference($taxon->name->nomenclaturalSource->citation->uuid));
   }
 
   $out .= render_taxon_or_name($taxon, NULL, $referenceUri, FALSE);
@@ -192,8 +192,8 @@ function theme_cdm_name_page_title($variables) {
   RenderHints::pushToRenderStack('name_page_title');
 
   $referenceUri = NULL;
-  if (isset($taxon_name->nomenclaturalReference)) {
-    $referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
+  if (isset($taxon_name->nomenclaturalSource->citation)) {
+    $referenceUri = url(path_to_reference($taxon_name->nomenclaturalSource->citation->uuid));
   }
 
   $out = '<span class="' . html_class_attribute_ref($taxon_name) . '">'
