*/
/**
* @defgroup compose Compose functions
* @{
* Functions which are composing Drupal render arrays
*
* The cdm_dataportal module needs to compose rather complex render arrays from
* the data returned by the CDM REST service. The compose functions are
* responsible for creating the render arrays.
*
* All these functions are also implementations of the compose_hook()
* which is used in the proxy_content() function.
* @}
*/
define('TAXON_TYPE_SYNONYM', 'Synonym');
define('TAXON_TYPE_MISAPPLIEDNAME', 'misapplied-name');
/**
* Returns HTML for misapplied names and invalid designations.
*
* Both relation types are currently treated the same!
*
* @param object taxonRelationships
* A TaxonRelationshipsDTO, see taxon/{uuid}/taxonRelationshipsDTO
*
* @param object focusedTaxon
* The taxon being in the focus of the application
*
* @return string
* the rendered html
*/
function cdm_taxonRelationships($taxonRelationshipsDTO, $focusedTaxon){
static $relationship_type_order_weights = [
//
UUID_PROPARTE_MISAPPLIEDNAME_FOR => 0,
UUID_PARTIAL_MISAPPLIEDNAME_FOR => 0,
//
UUID_INVALID_DESIGNATION_FOR => 1,
//
UUID_MISAPPLIED_NAME_FOR => 2,
//
UUID_PROPARTE_SYNONYM_FOR => 3,
UUID_PARTIAL_SYNONYM_FOR => 3
];
if (!$taxonRelationshipsDTO || $taxonRelationshipsDTO->size < 1) {
return null;
}
static $dedup_rel_type_uuids = array(
UUID_MISAPPLIED_NAME_FOR,
UUID_INVALID_DESIGNATION_FOR,
UUID_PARTIAL_MISAPPLIEDNAME_FOR,
UUID_PROPARTE_MISAPPLIEDNAME_FOR
);
RenderHints::pushToRenderStack('taxon_relationships');
$footnote_list_key = 'taxon_relationships';
RenderHints::setFootnoteListKey($footnote_list_key);
$misapplied = array();
$joined_refs = array();
$taxon_relationship_types = variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT));
// Aggregate misapplied names having the same fullname:
// - deduplicate misapplied names, so that the same name it not shown multiple times in case it
// the duplicates only have different sensu references with detail and appended phrase (see #5647)
// - show only the author team as short citation for the sec reference
// - show the according reference as footnote to this short citation
//
// Example:
// "Xenoxylum foobar" sensu Grumbach¹; sensu Lem²
// 1. Novel marsian species, Grumbach, 2022
// 2. Flora solaris, Lem, 2019
if (isset($taxonRelationshipsDTO->relations[0])) {
foreach($taxonRelationshipsDTO->relations as $taxon_relation){
if (in_array($taxon_relation->type->uuid, $taxon_relationship_types)) {
if (in_array($taxon_relation->type->uuid, $dedup_rel_type_uuids)) {
RenderHints::pushToRenderStack('misapplied_name_for'); // TODO the render path string should in future come from $taxonRelation->type->...
// full name with relation symbol, rel sec as de-duplication key
// the sensu part will be removed from the key below in case it is present
$name_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('name')));
$full_name_key = cdm_tagged_text_to_string($taxon_relation->taggedText, array('symbol', 'appendedPhrase'));
$symbol_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('symbol')));
$full_name_key = $name_text . ' ' . str_replace($name_text, '', $full_name_key) . ' ' . $symbol_text;
cdm_taxonRelationships_process_relationship_dto($taxon_relation, $misapplied, $joined_refs, $relationship_type_order_weights , $full_name_key);
RenderHints::popFromRenderStack();
} else {
RenderHints::pushToRenderStack('other_taxon_relationship');
// All relationship types except misapplied_name_for and invalid_designation_for.
$taxon_relationships_lines[] = cdm_tagged_text_to_markup($taxon_relation->taggedText);
RenderHints::popFromRenderStack();
}
}
} // END loop over $taxonRelationshipsDTO->relations
}
// Sort the $joined_refs and create footnotes and footnote keys.
uasort($joined_refs, function($a, $b) {
if ($a['order_by_key'] == $b['order_by_key']) {
return 0;
}
return ($a['order_by_key'] < $b['order_by_key']) ? -1 : 1;
});
foreach ($joined_refs as $ref_key => $sensu_strings) {
if(!empty($sensu_strings)) {
$ref_key_tokens = explode('#', $ref_key);
$sensu_uuid = $ref_key_tokens[0];
$sensu_reference = cdm_ws_get(CDM_WS_REFERENCE, $sensu_uuid);
if(!$sensu_reference){
drupal_set_message("Problem fetching sensu reference with uuid " . $sensu_uuid, 'error');
}
if($sensu_strings['order_by_key'] != $sensu_reference->titleCache){
$sensu_reference_markup = cdm_reference_markup($sensu_reference);
$footnote_key = FootnoteManager::addNewFootnote($footnote_list_key, $sensu_reference_markup);
$footnote_key = theme('cdm_footnote_key', array('footnoteKey' => $footnote_key));
$joined_refs[$ref_key]['markup'] = '' . $sensu_strings['markup'] . $footnote_key . '';
}
}
}
// ---- Generate output ---- //
$out = '
';
if (count($misapplied) > 0) {
ksort($misapplied); // order the misapplied by scientific name
$out .= '
';
// create the list entries per misapplied name
foreach ($misapplied as $misapplied_name) {
$misapplied_name_markup = $misapplied_name['out'];
// all sensu and auct. for this MAN
if (isset($misapplied_name['sensu_uuids'])) {
$sensu_refs_with_fkey = array();
foreach ($misapplied_name['sensu_uuids'] as $sensu_data) {
if($sensu_data['uuid']){
$joined_ref_key = $sensu_data['uuid'] . ($sensu_data['citation_detail'] ? '#' . $sensu_data['citation_detail'] : '');
$sensu_refs_with_fkey[$sensu_data['prefix'] . $joined_refs[$joined_ref_key]['order_by_key']] = $sensu_data['prefix'] . $joined_refs[$joined_ref_key]['markup'];
} else {
$sensu_refs_with_fkey[$sensu_data['prefix']] = $sensu_data['prefix'];
}
}
ksort($sensu_refs_with_fkey);
$sensu_refs_with_fkey_markup = join('; ', $sensu_refs_with_fkey);
if(strpos($misapplied_name_markup, '{PLACEHOLDER_secReference}') !== false){
$misapplied_name_markup = str_replace('{PLACEHOLDER_secReference}', $sensu_refs_with_fkey_markup, $misapplied_name_markup);
// just remove the appendedPhrase placeholder as was included in the sensu_refs_with_fkey_markup
$misapplied_name_markup = str_replace('{PLACEHOLDER_appendedPhrase}', '', $misapplied_name_markup);
} else {
// no sec ref so there could only be the appended phrase
$misapplied_name_markup = str_replace('{PLACEHOLDER_appendedPhrase}', $sensu_refs_with_fkey_markup, $misapplied_name_markup);
}
}
// append the err. sec. if there is any for this MAN
if (isset($misapplied_name['relsec_uuids'])) {
$relsec_refs_with_fkey = array();
foreach ($misapplied_name['relsec_uuids'] as $relsec_data) {
if($relsec_data['uuid']) {
$relsec_refs_with_fkey[$relsec_data['prefix'] . $joined_refs[$relsec_data['uuid']]['order_by_key']] = $relsec_data['prefix'] . $joined_refs[$relsec_data['uuid']]['markup'];
}
}
ksort($relsec_refs_with_fkey);
$relsec_refs_with_fkey_markup = join('; ', $relsec_refs_with_fkey);
$misapplied_name_markup = str_replace('{PLACEHOLDER_relSecReference}', $relsec_refs_with_fkey_markup, $misapplied_name_markup);
}
// final line
$out .= '- ' . $misapplied_name_markup . '
';
}
$out .= '
';
}
if (isset($taxon_relationships_lines) && is_array($taxon_relationships_lines) && count($taxon_relationships_lines) > 0) {
$out .= '
';
foreach ($taxon_relationships_lines as $taxon_relationship_line) {
$out .= '- ' . $taxon_relationship_line . '
';
}
$out .= '
';
}
$footnotes = theme('cdm_footnotes', array('footnoteListKey' => $footnote_list_key, 'enclosingTag' => 'li'));
$footnotes .= theme('cdm_annotation_footnotes', array('footnoteListKey' => $footnote_list_key, 'enclosingTag' => 'li'));
$out .= '';
$out .= '
';
RenderHints::popFromRenderStack();
return $out;
}
/**
* @param $taxon_relation
* @param $misapplied
* @param $joined_refs
* @param $relationship_type_weights
* @param $name_dedup_key
*/
function cdm_taxonRelationships_process_relationship_dto($taxon_relation, &$misapplied, &$joined_refs, $relationship_type_weights, $name_dedup_key) {
$appended_phrase_text = join(' ', cdm_tagged_text_values($taxon_relation->taggedText, array('appendedPhrase')));
// remove/extract appendedPhrase, secReference, relSecReference and add placeholders if needed
tagged_text_extract($taxon_relation->taggedText, 'appendedPhrase', true);
$sensu_tagged_text = tagged_text_extract_reference_and_detail($taxon_relation->taggedText, "secReference", true);
$relsec_tagged_text = tagged_text_extract_reference_and_detail($taxon_relation->taggedText, "relSecReference", true);
// prepend the weight value for the relationship type to the $name_dedup_key so that the key can be used for ordering the
// entries in the $misapplied array
if(isset($relationship_type_weights[$taxon_relation->type->uuid])){
$reltype_weight = $relationship_type_weights[$taxon_relation->type->uuid];
} else {
$reltype_weight = 99;
}
$name_dedup_key = str_pad( $reltype_weight, 2, '0', STR_PAD_LEFT) . '-' . $name_dedup_key;
if (isset($sensu_tagged_text[1])) {
// for de-duplication everything else needs to be equal except for appendedPhrase + MAN.sec + MAN.secDetail. see #7658#note-21
$name_dedup_key = str_replace(cdm_tagged_text_to_string($sensu_tagged_text), ' ', $name_dedup_key);
$appended_phrase_text = $appended_phrase_text . array_shift($sensu_tagged_text)->text; // remove first element which contains the "sensu", this will be added later in this code
$sensu_citation_detail = trim(join(' ', cdm_tagged_text_values($sensu_tagged_text, array('secMicroReference'))));
$sensu_citation_short_markup = cdm_tagged_text_to_markup($sensu_tagged_text);
$sensu_citation_short = cdm_tagged_text_to_string($sensu_tagged_text);
$sensu_uuid = $sensu_tagged_text[0]->entityReference->uuid;
$name_dedup_key = preg_replace('/\s+/', ' ', $name_dedup_key); // sanitize multiple whitespace characters
$misapplied[$name_dedup_key]['sensu_uuids'][] = array('uuid' => $sensu_uuid, 'prefix' => $appended_phrase_text, 'citation_detail' => $sensu_citation_detail);
$ref_key = $sensu_uuid . ($sensu_citation_detail ? '#' . $sensu_citation_detail : '');
if (!isset($joined_refs[$ref_key])) {
$joined_refs[$ref_key] = array(
'order_by_key' => $sensu_citation_short,
'markup' => $sensu_citation_short_markup // the footnote key will be appended later
);
}
} else if ($appended_phrase_text) {
// appended phrase without reference
$name_dedup_key = preg_replace('/\s+/', ' ', $name_dedup_key); // sanitize multiple whitespace characters
$misapplied[$name_dedup_key]['sensu_uuids'][] = array('uuid' => null, 'prefix' => $appended_phrase_text);
}
if (isset($relsec_tagged_text[1])) {
$appended_phrase_text = array_shift($relsec_tagged_text)->text; // remove first element which contains the "err. sec", this will be added later in this code
$relsec_citation_detail = trim(join(' ', cdm_tagged_text_values($relsec_tagged_text, array('secMicroReference'))));
$relsec_citation_short_markup = cdm_tagged_text_to_markup($relsec_tagged_text);
$relsec_citation_short = cdm_tagged_text_to_string($relsec_tagged_text);
$relsec_uuid = $relsec_tagged_text[0]->entityReference->uuid;
$misapplied[$name_dedup_key]['relsec_uuids'][] = array('uuid' => $relsec_uuid, 'prefix' => $appended_phrase_text, 'citation_detail' => $relsec_citation_detail);;
$ref_key = $relsec_uuid . ($relsec_citation_detail ? '#' . $relsec_citation_detail : '');
if (!isset($joined_refs[$ref_key])) {
$joined_refs[$ref_key] = array(
'order_by_key' => $relsec_citation_short,
'markup' => $relsec_citation_short_markup // the footnote key will be appended later
);
}
}
if (!isset($misapplied[$name_dedup_key]['out'])) {
// helpful for debugging: // cdm_tagged_text_add_options($taxon_relation->taggedText, array(array('filter-type' => 'symbol', 'attributes' => array('title' => array($taxon_relation->type->representations[0]->label)))));
$misapplied[$name_dedup_key]['out'] = cdm_tagged_text_to_markup($taxon_relation->taggedText);
} else {
// We need to add the anchors for all of the other misapplied names not
// being rendered explicitly.
$misapplied[$name_dedup_key]['out'] = uuid_anchor($taxon_relation->taxonUuid, $misapplied[$name_dedup_key]['out']);
}
}
/**
* Renders a representation of the given taxon relationship.
*
* According name relationships are also being rendered.
*
* @param $taxon
* The CDM TaxonBase entity
* @param $reltype_uuid
* The UUID of the TaxonRelationshipType
* @param $relsign
* Optional. Can be used to override the internal decision strategy on finding a suitable icon for the relationship
* @param $reltype_representation
* Optional: Defines the value for the title attribute of the html element enclosing the relsign
* @param $doubtful
* TODO
* @param $doLinkTaxon
* The taxon will be rendered as clickable link when true.
*
* @return string
* Markup for the taxon relationship.
*
* @throws Exception
*/
function cdm_related_taxon($taxon, $reltype_uuid = NULL, $relsign = NULL, $reltype_representation = NULL, $doubtful=false, $doLinkTaxon = FALSE) {
static $relsign_homo = '≡';
static $relsign_hetero = '=';
static $relsign_invalid = '–';
static $nom_status_invalid_type_uuids = array(
UUID_NOMENCLATURALSTATUS_TYPE_INVALID,
UUID_NOMENCLATURALSTATUS_TYPE_NUDUM,
UUID_NOMENCLATURALSTATUS_TYPE_COMBINATIONINVALID,
UUID_NOMENCLATURALSTATUS_TYPE_PROVISIONAL
);
// 'taxonRelationships';
$footnoteListKey = NULL;
$skip_tags = array();
$is_invalid = false;
if (!$relsign) {
switch ($reltype_uuid) {
case UUID_HETEROTYPIC_SYNONYM_OF:
case UUID_SYNONYM_OF:
$relsign = $relsign_hetero;
break;
case UUID_HOMOTYPIC_SYNONYM_OF:
$relsign = $relsign_homo;
break;
case UUID_MISAPPLIED_NAME_FOR:
case UUID_INVALID_DESIGNATION_FOR:
$skip_tags[] = 'authors';
$is_invalid = true;
$relsign = $relsign_invalid;
break;
default:
$relsign = $relsign_invalid;
}
}
if($doubtful) {
$relsign = '?' . $relsign;
}
/*
Names with status invalid or nudum are to be displayed with the
$relsign_invalid, these names appear at the end of all names in their
homotypic group (ordered correctly by the java cdm_lib).
*/
if (isset($taxon->name->status) && is_array($taxon->name->status)) {
foreach ($taxon->name->status as $status) {
if (in_array($status->type->uuid , $nom_status_invalid_type_uuids)) {
$relsign = $relsign_invalid;
break;
}
}
}
// Now rendering starts ..
RenderHints::pushToRenderStack('related_taxon');
if (isset($taxon->name->nomenclaturalReference)) {
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
}
$taxonUri = '';
if ($doLinkTaxon) {
$taxonUri = url(path_to_taxon($taxon->uuid, "synonymy"));
}
// Printing the taxonName and the handling the special case of annotations.
if (!isset($referenceUri)) {
$referenceUri = FALSE;
}
$out_taxon_part = render_taxon_or_name($taxon, $taxonUri, $referenceUri, TRUE, FALSE, $skip_tags, $is_invalid);
$taxon_footnotes = theme('cdm_entities_annotations_as_footnotekeys',
array('cdmBase_list' => array(
$taxon->name,
$taxon,
),
'footnote_list_key' => $footnoteListKey)
);
$name_relations = cdm_name_relationships_for_taxon($taxon);
$name_relations_render_array = compose_name_relationships_inline($name_relations, $taxon->name->uuid, $taxon->uuid);
$out = '' . $relsign . ''
. $out_taxon_part . $taxon_footnotes;
if(isset($name_relations_render_array['list']['items'][0])){
$out .= ' ' . drupal_render($name_relations_render_array);
}
$out = uuid_anchor($taxon->uuid, $out);
RenderHints::popFromRenderStack();
return $out;
}
/**
* Creates markup for a taxon which is the accepted of another one
*
* @param $accepted_for_uuid
* The uuid of the accepted taxon
*/
function cdm_accepted_for($accepted_for_uuid) {
if(!is_uuid($accepted_for_uuid)){
return '';
}
RenderHints::pushToRenderStack('acceptedFor');
$out = '';
$synonym = cdm_ws_get(CDM_WS_PORTAL_TAXON, $accepted_for_uuid);
if ($synonym) {
$out .= '';
$out .= t('is accepted for ');
$referenceUri = null;
if (isset($synonym->name->nomenclaturalReference)) {
$referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
}
$out .= render_taxon_or_name($synonym->name, NULL, $referenceUri);
$out .= theme('cdm_entities_annotations_as_footnotekeys', array('cdmBase_list' => $synonym));
$out .= '';
}
RenderHints::popFromRenderStack();
return $out;
}
/**
* Compose function for a list of taxa.
*
* This function is for used to:
*
* 1. Display search results
* 2. List the taxa for a taxon name in the name page.
*
* @param $taxon_list array
* The list of CDM Taxon entities. e.g. The records array as contained in a pager object.
* @param $freetext_search_results array
* @param $show_classification boolean
*
* @ingroup compose
*
*/
function compose_list_of_taxa($taxon_list, $freetext_search_results = array(), $show_classification = false) {
$unclassified_snippet = '' . t('unclassified') . '';
RenderHints::pushToRenderStack('list_of_taxa');
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
$showMedia_taxa = $gallery_settings['cdm_dataportal_show_taxon_thumbnails'];
$showMedia_synonyms = $gallery_settings['cdm_dataportal_show_synonym_thumbnails'];
$searched_in_classification = cdm_dataportal_searched_in_classification();
$searched_in_classification_uuid = null;
if(isset($searched_in_classification->uuid)){
$searched_in_classification_uuid = $searched_in_classification->uuid;
}
// .. Well, for sure not as performant as before, but better than nothing.
$synonym_uuids = array();
$misapplied_uuids = array();
foreach ($taxon_list as $taxon) {
if ($taxon->class == "Synonym") {
if (!array_key_exists($taxon->uuid, $synonym_uuids)) {
$synonym_uuids[$taxon->uuid] = $taxon->uuid;
}
}
elseif (!_cdm_dataportal_acceptedByCurrentView($taxon)) {
// Assuming that it is a misapplied name, will be further examined below.
$misapplied_uuids[$taxon->uuid] = $taxon->uuid;
}
}
// Batch service not jet implemented:
// $table_of_accepted = cdm_ws_property(CDM_WS_PORTAL_TAXON_ACCEPTED,
// join(',', $synonym_uuids));
// thus ...
$table_of_accepted = array();
foreach ($synonym_uuids as $relatedUuid) {
$classification_filter = '';
if($searched_in_classification_uuid){
$classification_filter = 'classificationFilter=' . $searched_in_classification_uuid;
}
$table_of_accepted[$relatedUuid] = cdm_ws_get(
CDM_WS_PORTAL_TAXON_ACCEPTED,
array($relatedUuid),
$classification_filter
);
}
foreach ($misapplied_uuids as $relatedUuid) {
$taxonRelations = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, array(
$relatedUuid,
));
foreach ($taxonRelations as $relation) {
if ($relation->type->uuid == UUID_MISAPPLIED_NAME_FOR && _cdm_dataportal_acceptedByCurrentView($relation->toTaxon)) {
$table_of_accepted[$relatedUuid][] = $relation->toTaxon;
}
}
}
$out = '';
$itemCnt = -1;
foreach ($taxon_list as $taxon) {
$itemCnt++;
if (isset($table_of_accepted[$taxon->uuid])) {
// Its a synonym or misapplied name.
$is_synonym = isset($synonym_uuids[$taxon->uuid]); //TODO better use the $taxon->class attribute?
$taxon_type = $is_synonym ? TAXON_TYPE_SYNONYM :TAXON_TYPE_MISAPPLIEDNAME;
$acceptedTaxa = $table_of_accepted[$taxon->uuid];
if (!is_array($acceptedTaxa)) {
$acceptedTaxa = array($acceptedTaxa);
}
foreach ($acceptedTaxa as $acceptedTaxon) {
if (is_object($acceptedTaxon)) {
$taxonUri = uri_to_synonym($taxon->uuid, $acceptedTaxon->uuid);
$referenceUri = '';
if (isset($acceptedTaxon->name->nomenclaturalReference)) {
$referenceUri = url(path_to_reference($acceptedTaxon->name->nomenclaturalReference->uuid));
}
$taxon_or_name = $is_synonym ? $taxon->name : $taxon;
// $taxon_or_name this is a trick to suppress the sec reference for synonyms
// supplying the name will cause render_taxon_or_name() to not show the sec reference
$out .= "
" . render_taxon_or_name($taxon_or_name, $taxonUri, $referenceUri);
if($taxon_type == TAXON_TYPE_MISAPPLIEDNAME && is_object($taxon->sec)){
if(isset($taxon->sec->authorship)){
$authorship = $taxon->sec->authorship->titleCache;
} else {
$authorship = $taxon->sec->titleCache;
}
$out .= ' sensu ' . $authorship;
}
if ($show_classification) {
$classifications = get_classifications_for_taxon($taxon);
$classification_titles = array();
foreach ($classifications as $classification) {
if (isset($classification->titleCache)) {
$classification_titles[] = $classification->titleCache;
}
}
if (count($classification_titles) == 0) {
$classification_titles[] = $unclassified_snippet;
}
$out .= '
: ' . implode(', ', $classification_titles) . '';
}
$out .= theme('cdm_entities_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
if ($showMedia_synonyms) {
$out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $acceptedTaxon));
}
}
}
}
else {
// 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));
}
$out .= '
' . render_taxon_or_name($taxon, $taxonUri, $referenceUri);
if ($show_classification) {
$classifications = get_classifications_for_taxon($taxon);
$classification_titles = array();
foreach ($classifications as $classification) {
if (isset($classification->titleCache)) {
$classification_titles[] = $classification->titleCache;
}
}
if(count($classification_titles) == 0){
$classification_titles[] = $unclassified_snippet;
}
$out .= '
: ' . implode(', ', $classification_titles) . '';
}
$out .= theme('cdm_entities_annotations_as_footnotekeys', array('cdmBase_list' => $taxon));
if ($showMedia_taxa) {
$out .= theme('cdm_taxon_list_thumbnails', array('taxon' => $taxon));
}
}
/*
* the score field will be empty in case of MultiTermQueries like
* WildcardQueries, since these are constant score by default
* since Lucene 2.9
*/
if(isset($freetext_search_results[$itemCnt]) && $freetext_search_results[$itemCnt]->score && $freetext_search_results[$itemCnt]->maxScore){
$percentage = ( $freetext_search_results[$itemCnt]->score / $freetext_search_results[$itemCnt]->maxScore ) * 100;
$out .= '
';
$out .= '
' . number_format($percentage, 2) .'%
';
}
// Render highlighted fragments, these are made available by free text
// searches.
if (isset($freetext_search_results[$itemCnt]->fieldHighlightMap)) {
$field_fragments = (array) $freetext_search_results[$itemCnt]->fieldHighlightMap;
if (count($field_fragments) > 0) {
$fragments_out = '';
foreach ($field_fragments as $fieldName => $fragments) {
$fragments_out .= '...
' . filter_xss(join(" ... ", $fragments), array('b') ) . '';
}
$out .= '
' . $fragments_out . ' ...
';
}
}
$out .= '
';
}
$out .= '
';
RenderHints::popFromRenderStack();
return markup_to_render_array($out); // TODO create render array of all list items in function
}
/**
* Compose function for the taxonomic children
*
* @param $taxon_uuid
* The uuuid of the taxon to compose the list of taxonomic children for
* @return
* A drupal render array.
*
* @ingroup compose
*/
function compose_taxonomic_children($taxon_uuid){
$render_array = array();
if($taxon_uuid) {
$children = cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_CHILDNODES_OF_TAXON, array(
get_current_classification_uuid(),
$taxon_uuid
));
if($children){
$taxonomic_children = theme('cdm_taxontree', array('tree' => $children));
$render_array = markup_to_render_array($taxonomic_children);
}
}
return $render_array;
}