Project

General

Profile

« Previous | Next » 

Revision 0991781d

Added by Andreas Kohlbecker over 2 years ago

ref #9388 showing media specimen sources in compact registration dto (fixes search reults and 1 case in name page)

View differences:

modules/cdm_dataportal/cdm_api/tagged_text.inc
439 439
  return $extracted_tt;
440 440
}
441 441

  
442
/**
443
 * Tries to find a tagged text elements that matches the $type and $regex_pattern
444
 * and returns all preceding elements as new array.
445
 *
446
 * @param $tagged_text
447
 *  The tagged text to crop
448
 * @param $type
449
 *  The tagged text type to match
450
 * @param $regex_pattern
451
 *  A PREG regex pattern
452
 *
453
 * @return array
454
 *  A new tagged text array
455
 */
456
function tagged_text_crop_at(&$tagged_text, $type, $regex_pattern) {
457
  $cropped_tagged_text = array();
458
  if (is_array($tagged_text)) {
459
    for ($i = 0; $i < count($tagged_text); $i++) {
460
      if ($tagged_text[$i]->type == $type && preg_match($regex_pattern, $tagged_text[$i]->text)) {
461
        break;
462
      }
463
      $cropped_tagged_text[] = $tagged_text[$i];
464
    }
465
  }
466
  return $cropped_tagged_text;
467
}
468

  
442 469
function tagged_text_extract(&$tagged_text, $type, $replace_with_placeholder = false) {
443 470
  $matching_elements = array();
444 471
  if (is_array($tagged_text)) {

Also available in: Unified diff