diff --git a/modules/fontane/index-processor.xqm b/modules/fontane/index-processor.xqm index c7f8d8ffebb59d80e6bf8b0fbebf0074220331ec..2ae151f0166b033624f954f2f12fb4a3634a1c46 100644 --- a/modules/fontane/index-processor.xqm +++ b/modules/fontane/index-processor.xqm @@ -779,16 +779,9 @@ return (: note :) ixp:note($note), (: where :) - for $where in $wheres return - element xhtml:li { - attribute class { "where" }, - element xhtml:a { - attribute href { "register.html?e="|| $where }, - , - " ", - $ixp:dataCollection/id($where)/*[1]/string() - } - }, + for $where in $wheres + return + ixp:data-loader($ixp:dataCollection/id($where)), (: bibl :) ixp:bibl($bibl), (: links :) @@ -1092,14 +1085,7 @@ else for $member in $members let $memberId := $members/@target => substring-after(" ") => substring-after("#") return - element xhtml:li { - element xhtml:a { - attribute href { "?e=" || $memberId }, - , - " ", - $ixp:dataCollection/id($memberId)/*[1]/string() - } - } + ixp:data-loader($ixp:dataCollection/id($memberId)) } }, if (not(exists($creator))) then () else @@ -1210,6 +1196,15 @@ else let $tookPlaceAt := $place/tei:linkGrp/tei:link[@corresp="http://erlangen-crm.org/current/P7_took_place_at"] let $formerCurrentLocation := $place/tei:linkGrp/tei:link[@corresp="http://erlangen-crm.org/current/P53_has_former_or_current_location"] let $links := $place/tei:linkGrp/tei:link[@corresp="https://schema.org/mentions"] + + let $itemRefs := $ixp:dataCollection//tei:link + [@corresp="http://erlangen-crm.org/current/P53_has_former_or_current_location"] + [ends-with(@target, " plc:" || $id)]/parent::tei:linkGrp/parent::tei:* + let $itemsRefNodes := for $item in $itemRefs + let $node := ixp:data-loader($item) + order by string($node) + return + $node return element xhtml:li { attribute id { string($id) }, @@ -1270,17 +1265,13 @@ else for $l in $tookPlaceAt let $id := $l/@target => substring-after(":") => substring-before(" ") return - element xhtml:li { - attribute class { "took-place-at" }, - element xhtml:a { - attribute href { "?e=" || $id }, - , - " ", - $ixp:dataCollection/id($id)/*[1]/string() - } - }, + ixp:data-loader($ixp:dataCollection/id($id)), (: former_or_current_location :) ixp:has-former-or-current-location($formerCurrentLocation), + (: entries referencing this entity :) + if($itemsRefNodes) + then { $itemsRefNodes } + else (), (: links :) ixp:links($place), ixp:li-code($place), @@ -1493,3 +1484,35 @@ else } } }; + +(:~ + : A generic list item that is enabled for loading the entry it points to + : via ajax call. + : @author Mathias Göbel + : @param $targetNode The TEI element to load in place + : @return a xhtml:li with the title and an icon to click for loading the entry +:) +declare function ixp:data-loader($targetNode as element()) +as element(xhtml:li) { + let $targetId := string($targetNode/@xml:id) + let $title := string($targetNode/*[1]) + return + element xhtml:li { + attribute class { "registerEintrag", $targetNode/local-name() }, + element xhtml:a { + attribute href { "register.html?e=" || string-join($targetId) }, + if($targetNode[2]) + then "two entities with same ID: " || $targetId + else $title + }, + text{ " " }, + element xhtml:span { + attribute class { "load-entity" }, + attribute data-load { $targetId }, + element xhtml:i { + attribute class {"fa fa-plus-square-o"}, + attribute aria-hidden {"true"} + } + } + } +};