Project

General

Profile

« Previous | Next » 

Revision 20bfe15b

Added by Andreas Kohlbecker over 4 years ago

fix #8779 harmonization of taxon display in descriptions

View differences:

modules/cdm_dataportal/cdm_dataportal.module
1823 1823

  
1824 1824
      // Render the description page.
1825 1825
      $render_array = compose_description_table($description->uuid, $descriptive_dataset_uuid);
1826
      if($render_array['title']){
1827
        $page_title = strip_tags($render_array['title']['#markup']);
1828
        drupal_set_title($page_title);
1829
        unset($render_array['title']);
1830
      }
1826 1831
      $description_page->content = drupal_render($render_array);
1827 1832
    }
1828 1833

  
modules/cdm_dataportal/includes/descriptions.inc
2178 2178
 *
2179 2179
 * @ingroup compose
2180 2180
 */
2181
function compose_description_table($description_uuid, $descriptive_dataset_uuid = NULL) {
2181
function  compose_description_table($description_uuid, $descriptive_dataset_uuid = NULL) {
2182

  
2182 2183
  RenderHints::pushToRenderStack('description_table');
2183 2184

  
2184 2185
  $render_array = [];
......
2194 2195
      }
2195 2196
    }
2196 2197
  }
2198

  
2197 2199
  if(!empty($description->descriptiveDataSets)) {
2198 2200
    // only one dataset present
2199 2201
    if (!isset($dataSet) && sizeof($description->descriptiveDataSets) == 1) {
......
2201 2203
        break;
2202 2204
      }
2203 2205
    }
2204
    // generate page title
2206

  
2207
    // generate description title
2208
    RenderHints::pushToRenderStack('title');
2205 2209
    if (isset($dataSet)) {
2206
      $associated_description_cdm_entity = isset($description->describedSpecimenOrObservation)
2207
        ? $description->describedSpecimenOrObservation->titleCache
2208
        : (isset($description->taxon) ? $description->taxon->titleCache : NULL);
2209
      $title = 'Descriptive Data ' . $dataSet->titleCache;
2210
      if (isset($associated_description_cdm_entity)) {
2211
        $title .= ' for ' . $associated_description_cdm_entity;
2210

  
2211
      $described_entity_title = NULL;
2212
      if(isset($description->describedSpecimenOrObservation)){
2213
        $described_entity_title = $description->describedSpecimenOrObservation->titleCache;
2214
      } else if($description->taxon) {
2215
          $described_entity_title = render_taxon_or_name($description->taxon);
2216
      }
2217
      $title = 'Descriptive Data ' . $dataSet->titleCache .
2218
        ($described_entity_title ? ' for ' . $described_entity_title : '');
2212 2219
      }
2213
      drupal_set_title($title);
2220
      $render_array['title'] = markup_to_render_array($title, null, '<h3 class="title">', '</h3>');
2221
    RenderHints::popFromRenderStack();
2222

  
2214 2223
      if (isset($description->types)) {
2215 2224
        foreach ($description->types as $type) {
2216 2225
          if ($type == 'CLONE_FOR_SOURCE') {
2217
            $render_array[] = markup_to_render_array("Aggregation source from " . $description->created . '<br><br>');
2226
            $render_array['source'] = markup_to_render_array("Aggregation source from " . $description->created . '<br><br>');
2218 2227
            break;
2219 2228
          }
2220 2229
        }
2221 2230
      }
2222 2231
    }
2223
    // multiple datasets present
2232
    // multiple datasets present see #8714 "Show multiple datasets per description as list of links"
2224 2233
    else {
2225 2234
      $items = [];
2226 2235
      foreach ($description->descriptiveDataSets as $dataSet) {
......
2230 2239
          'data' => $dataSet->titleCache . icon_link($path),
2231 2240
        ];
2232 2241
      }
2233
      $render_array[] = [
2242
      $render_array['description_elements'] = [
2234 2243
        '#title' => 'Available data sets for description',
2235 2244
        '#theme' => 'item_list',
2236 2245
        '#type' => 'ul',
2237 2246
        '#items' => $items,
2238 2247
      ];
2239 2248
    }
2240
  }
2249

  
2241 2250

  
2242 2251
  if (isset($description->describedSpecimenOrObservation)) {
2243
    $render_array[] = markup_to_render_array("<b>Specimen</b><br>");
2244
    $render_array[] = markup_to_render_array(render_cdm_specimen_link($description->describedSpecimenOrObservation));
2252
    $render_array['specimen'] = markup_to_render_array("<b>Specimen</b><br>");
2253
    $render_array['specimen_link'] = markup_to_render_array(render_cdm_specimen_link($description->describedSpecimenOrObservation));
2245 2254
  }
2246 2255
  if (isset($description->taxon)) {
2247
    $render_array[] = markup_to_render_array("<b>Taxon</b><br>");
2248
    $render_array[] = markup_to_render_array(render_cdm_taxon($description->taxon));
2256
    $render_array['taxon'] = markup_to_render_array("<b>Taxon</b><br>");
2257
    $render_array['taxon_link'] = markup_to_render_array(render_taxon_or_name($description->taxon, path_to_taxon($description->taxon->uuid)));
2249 2258
  }
2250 2259

  
2251 2260
  $root_nodes = get_root_nodes_for_dataset($description);
......
2292 2301
    ];
2293 2302
  }
2294 2303

  
2295

  
2296 2304
  RenderHints::popFromRenderStack();
2305

  
2297 2306
  return $render_array;
2298 2307
}
2299 2308

  
modules/cdm_dataportal/includes/name.inc
253 253
 *
254 254
 * @param $taxonName
255 255
 *    cdm TaxonName instance
256
 * @param $nameLink
256
 * @param $name_link
257 257
 *    URI to the taxon, @see path_to_taxon(), must be processed by url() before passing to this method
258
 * @param $refenceLink
258
 * @param $reference_link
259 259
 *    URI to the reference, @see path_to_reference(), must be processed by url() before passing to this method
260 260
 * @param $show_annotations
261 261
 *    turns the display of annotations on
......
273 273
 *  The markup for a taxon name.
274 274
 *
275 275
 */
276
function render_taxon_or_name($taxon_name_or_taxon_base, $nameLink = NULL, $refenceLink = NULL,
276
function render_taxon_or_name($taxon_name_or_taxon_base, $name_link = NULL, $reference_link = NULL,
277 277
  $show_annotations = true, $is_type_designation = false, $skiptags = array(), $is_invalid = false) {
278 278

  
279 279
  $is_doubtful = false;
......
294 294
  }
295 295

  
296 296

  
297
  $renderTemplate = get_nameRenderTemplate(RenderHints::getRenderPath(), $nameLink, $refenceLink);
297
  $renderTemplate = get_nameRenderTemplate(RenderHints::getRenderPath(), $name_link, $reference_link);
298 298
  $partDefinition = get_partDefinition($taxonName->nameType);
299 299

  
300 300
  // Apply definitions to template.
......
499 499
  $descriptionHtml = '';
500 500
  if (array_setr('description', TRUE, $renderTemplate)) {
501 501
    $descriptions = cdm_ws_get(CDM_WS_PORTAL_NAME_DESCRIPTIONS, $taxonName->uuid);
502
    foreach ($descriptions as $description) {
503
      if (!empty($description)) {
504
        foreach ($description->elements as $description_element) {
505
          $second_citation = '';
506
          if (isset($description_element->multilanguageText_L10n) && $description_element->multilanguageText_L10n->text) {
507
            $second_citation = '[& ' . $description_element->multilanguageText_L10n->text . '].';
508
          }
509
          $descriptionHtml .= $second_citation;
510
          $descriptionHtml .= cdm_description_element_media(
511
              $description_element,
512
              array(
513
                'application/pdf',
514
                'image/png',
515
                'image/jpeg',
516
                'image/gif',
517
                'text/html',
518
              )
519
          );
502
    if($descriptions){
503
      foreach ($descriptions as $description) {
504
        if (!empty($description)) {
505
          foreach ($description->elements as $description_element) {
506
            $second_citation = '';
507
            if (isset($description_element->multilanguageText_L10n) && $description_element->multilanguageText_L10n->text) {
508
              $second_citation = '[& ' . $description_element->multilanguageText_L10n->text . '].';
509
            }
510
            $descriptionHtml .= $second_citation;
511
            $descriptionHtml .= cdm_description_element_media(
512
                $description_element,
513
                array(
514
                  'application/pdf',
515
                  'image/png',
516
                  'image/jpeg',
517
                  'image/gif',
518
                  'text/html',
519
                )
520
            );
520 521

  
522
          }
521 523
        }
522 524
      }
523 525
    }
modules/cdm_dataportal/includes/pages.inc
640 640
  return $specimen->titleCache.icon_link($path);
641 641
}
642 642

  
643
/**
644
 * Renders the link which will lead to the taxon detail page
645
 * @param object $taxon
646
 *    the taxon which will be linked to
647
 *
648
 * @return string
649
 *     the markup for the link
650
 */
651
function render_cdm_taxon($taxon) {
652
  $path = path_to_taxon($taxon->uuid);
653
  $attributes['class'][] = html_class_attribute_ref($taxon);
654
  return $taxon->titleCache.icon_link($path);
655
}
656

  
657 643
/**
658 644
 * Returns HTML containing the synonymy for the accepted taxon.
659 645
 *

Also available in: Unified diff