Project

General

Profile

« Previous | Next » 

Revision 947ee97b

Added by Andreas Kohlbecker over 3 years ago

fix #9306 filtering designated by reference out for registration list

View differences:

modules/cdm_dataportal/cdm_api/tagged_text.inc
320 320
}
321 321

  
322 322
/**
323
 * Extracts from a tagged text array the tagged text for a references which is concatenated with citation
323
 * Extracts from a tagged text array all tagged text for references which is concatenated with citation
324 324
 * detail separator and citation detail into one single element.
325 325
 *
326 326
 * @param $tagged_text
327 327
 *    The tagged text to operate on
328 328
 * @param string $ref_tag_type
329
 *    The tagtype for a secreference is "secReference", but "relSecReference" is also used in case of relationships.
329
 *    The tag type for a reference is "reference", this is uses as default.
330 330
 * @param bool $replace_with_placeholder
331 331
 *    Indicates the method to add a empty placeholder tagged text alement as relpacement for the extrated tagged text
332 332
 *    elements.
333
 * @param string $ref_detail_tag_type
334 333
 * @return array
335 334
 */
336 335
function tagged_text_extract_reference(&$tagged_text, $ref_tag_type = "reference", $replace_with_placeholder = false) {
......
338 337
  $extracted_tt = array();
339 338
  if (is_array($tagged_text)) {
340 339
    $extract_pos = null;
341
    for ($i = 0; $i < count($tagged_text); $i++) {
340
    $tt_legth = count($tagged_text);
341
    for ($i = 0; $i < $tt_legth; $i++) {
342 342
      if ($tagged_text[$i]->type == $ref_tag_type){
343 343
        if ($i > 0 && $tagged_text[$i - 1]->type == 'separator') {
344 344
          // the reference may be preceeded by a separator in case it is not a in-reference
345 345
          $extracted_tt[] = $tagged_text[$i - 1];
346 346
          unset($tagged_text[$i - 1]);
347 347
        } else {
348
          // need to add a separator to since the reference tagged text will become the first element
348
          // need to add a separator since the reference tagged text will become the first element
349 349
          // ant thus will not be preceded by a separator
350 350
          $extracted_tt[] = tagged_text_new('separator', ' ');
351 351
        }
......
356 356
        } else {
357 357
          unset($tagged_text[$i]);
358 358
        }
359
        break;
360 359
      }
361 360
    }
362 361
  }
......
381 380
  $extracted_tt = array();
382 381
  if (is_array($tagged_text)) {
383 382
    $extract_pos = null;
384
    for ($i = 0; $i < count($tagged_text) - 1; $i++) {
383
    $tt_length = count($tagged_text);
384
    for ($i = 0; $i < $tt_length - 1; $i++) {
385 385
      if ($tagged_text[$i + 1]->type == $ref_tag_type && $tagged_text[$i]->type == "separator"){
386 386
        $extracted_tt[0] = $tagged_text[$i];
387 387
        $extracted_tt[1] = $tagged_text[$i + 1];
modules/cdm_dataportal/includes/name.inc
783 783
    );
784 784
  }
785 785
  cdm_tagged_text_add_options($registration_dto->summaryTaggedText, $tagged_text_options);
786
  $taggged_text_expanded = cdm_tagged_text_expand_entity_references($registration_dto->summaryTaggedText);
787
  foreach ($taggged_text_expanded  as $tagged_text){
786
  tagged_text_extract_reference($registration_dto->summaryTaggedText);
787
  $tagged_text_expanded = cdm_tagged_text_expand_entity_references($registration_dto->summaryTaggedText);
788
  foreach ($tagged_text_expanded  as $tagged_text){
788 789
    if(isset($tagged_text->entityReference->type) && $tagged_text->entityReference->type == 'SpecimenTypeDesignation') {
789 790
      $mediaDTOs = cdm_ws_get('typedesignation/$0/media', array($tagged_text->entityReference->uuid));
790 791
      if(isset($mediaDTOs[0]->uri)){
......
794 795
      }
795 796
    }
796 797
  }
797
  $registation_markup = cdm_tagged_text_to_markup($taggged_text_expanded);
798
  $registation_markup = cdm_tagged_text_to_markup($tagged_text_expanded);
798 799
  foreach($media_link_map as $media_url_key => $link){
799 800
    $registation_markup = str_replace($media_url_key, $link, $registation_markup);
800 801
  }

Also available in: Unified diff