Revision ff162af3
Added by Katja Luther almost 2 years ago
modules/cdm_dataportal/cdm_api/tagged_text.inc | ||
---|---|---|
414 | 414 |
return $extracted_tt; |
415 | 415 |
} |
416 | 416 |
|
417 |
/** |
|
418 |
* Extracts the tagged text for sec references name in source with separator from a tagged text array. |
|
419 |
* @param $tagged_text |
|
420 |
* The tagged text to operate on |
|
421 |
* @param bool $replace_with_placeholder |
|
422 |
* Indicates the method to add a empty placeholder tagged text alement as relpacement for the extrated tagged text |
|
423 |
* elements. |
|
424 |
* |
|
425 |
* @return array |
|
426 |
*/ |
|
427 |
function tagged_text_extract_secReference_name_in_source(&$tagged_text) { |
|
428 |
|
|
429 |
$extracted_tt = array(); |
|
430 |
if (is_array($tagged_text)) { |
|
431 |
|
|
432 |
$tt_length = count($tagged_text); |
|
433 |
$index = -1; |
|
434 |
for ($i = 0; $i < $tt_length; $i++) { |
|
435 |
if ($i < $tt_length -1 && isset($tagged_text[$i]) && $tagged_text[$i+1]->type == 'name' && $tagged_text[$i]->type == "secNameInSourceSeparator") { |
|
436 |
$extracted_tt[++$index] = $tagged_text[$i]; |
|
437 |
$extracted_tt[++$index] = $tagged_text[$i + 1]; |
|
438 |
|
|
439 |
unset($tagged_text[$i]); |
|
440 |
unset($tagged_text[$i + 1]); |
|
441 |
continue; |
|
442 |
//search for all elements with type secNameInSource and the last separator |
|
443 |
} |
|
444 |
if (isset($tagged_text[$i]) && $tagged_text[$i]->type == 'secNameInSourceSeparator') { |
|
445 |
$extracted_tt[++$index] = $tagged_text[$i]; |
|
446 |
|
|
447 |
unset($tagged_text[$i]); |
|
448 |
break; |
|
449 |
//search for all elements with type secNameInSource and the last separator |
|
450 |
} |
|
451 |
if(isset($tagged_text[$i]) && $index >0){ |
|
452 |
$extracted_tt[++$index] = $tagged_text[$i]; |
|
453 |
unset($tagged_text[$i]); |
|
454 |
} |
|
455 |
|
|
456 |
|
|
457 |
} |
|
458 |
} |
|
459 |
$tagged_text = array_values($tagged_text); // re-index array to make it continuous again |
|
460 |
return $extracted_tt; |
|
461 |
} |
|
462 |
|
|
417 | 463 |
function tagged_text_extract_nomstatus(&$tagged_text) { |
418 | 464 |
|
419 | 465 |
$extracted_tt = []; |
Also available in: Unified diff
ref #10081: adapt nameInSource handling in portal