function details_tcs_synonym($id) { $entry = Synonym::find($id); $nomenclaturalCode = "Zoological"; $scientific = "true"; if ($entry->synonym_relation && $entry->synonym_relation->translation && strtolower($entry->synonym_relation->translation->label) == "common name") { $scientific = "false"; } $return = ""; $return .= " <TaxonNames>\n"; $return .= " <TaxonName id='n" . $entry->name->id . "' nomenclaturalCode='{$nomenclaturalCode}'>\n"; $return .= " <Simple>" . htmlspecialchars($entry->name->string) . "</Simple>\n"; if ($scientific == "true") { $return .= " <CanonicalName>\n"; $return .= " <Simple>" . htmlspecialchars($entry->name->canonical_form->string) . "</Simple>\n"; $return .= " </CanonicalName>\n"; } if ($agents = $entry->agents) { $return .= " <ProviderSpecificData>\n"; $return .= " <NameSources>\n"; foreach ($agents as $k => $v) { $return .= " <NameSource>\n"; $return .= " <Simple>" . htmlspecialchars($v->agent->display_name) . "</Simple>\n"; $return .= " <Role>" . htmlspecialchars($v->agent_role->translation->label) . "</Role>\n"; $return .= " </NameSource>\n"; } $return .= " </NameSources>\n"; $return .= " </ProviderSpecificData>\n"; } $return .= " </TaxonName>\n"; $return .= " </TaxonNames>\n"; $return .= " <TaxonConcepts>\n"; $return .= " <TaxonConcept id='c" . $entry->id . "'>\n"; $return .= " <Name scientific='{$scientific}' "; if (@$entry->language->iso_639_1) { $return .= "language='" . $entry->language->iso_639_1 . "' "; } $return .= "ref='n" . $entry->name->id . "'>" . htmlspecialchars($entry->name->string) . "</Name>\n"; $return .= " </TaxonConcept>\n"; $return .= " </TaxonConcepts>\n"; return $return; }