getCachedSearchResults($SearchParams); if (is_null($SearchResults)) { $SearchResults = $Engine->search($SearchParams); $Plugin->cacheSearchResults( $SearchParams, $SearchResults ); } return array_intersect_key( $SearchResults, array_fill_keys($AllItemIds, true) ); } /** * Get HTML for browsing records by subject area. * @param string $LaunchId LaunchId for current page. * @param string $BaseLink Base link for page. * @param array $AllItemIds IDs of all publicly visible items that * could be shown via the current page. * @return string Html */ function getBrowsingHtml( string $LaunchId, string $BaseLink, array $AllItemIds ) : string { $Plugin = EduLink::getInstance(); $BrowsingFieldId = $Plugin->getConfigSetting("BrowsingField"); if (strlen($BrowsingFieldId) == 0) { return ""; } $Html = $Plugin->getCachedSubjectListHtml($AllItemIds); if (!is_null($Html)) { return str_replace("X-LAUNCHID-X", $LaunchId, $Html); } $Html = "
"; $BrowsingField = MetadataField::getField($BrowsingFieldId); $ClassFactory = $BrowsingField->getFactory(); $ToplevelTerms = $ClassFactory->getItems("Depth = 0"); $Engine = new SearchEngine(); foreach ($ToplevelTerms as $Term) { $SearchParams = new SearchParameterSet(); $SearchParams->addParameter( "^".$Term->id(), $BrowsingField ); $SearchParams->itemTypes(MetadataSchema::SCHEMAID_DEFAULT); $SearchResults = getResultsForTerm($SearchParams, $AllItemIds); if (count($SearchResults) == 0) { continue; } $TermName = $Term->segmentName(); $TermId = $Term->id(); $SearchParamString = $SearchParams->urlParameterString(); $ParentHtml = "" .$TermName.""; $Children = $ClassFactory->getItems("ParentId = ".$TermId); $ChildHtml = ""; foreach ($Children as $Child) { $SearchParams = new SearchParameterSet(); $SearchParams->itemTypes(MetadataSchema::SCHEMAID_DEFAULT); $SearchParams->addParameter( "^".$Child->id(), $BrowsingField ); $SearchResults = getResultsForTerm($SearchParams, $AllItemIds); if (count($SearchResults) == 0) { continue; } $ChildName = $Child->segmentName(); $SearchParamString = $SearchParams->urlParameterString(); $ChildHtml .= "
- " .$ChildName."
"; } $ChildHtml = strlen($ChildHtml) > 0 ? "

".$ChildHtml."

" : ""; $Html .= "
" ."

" ."[+]" ."[-] ".$TermName."

" ."

- ".$ParentHtml .$ChildHtml ."

"; } $Html .= "
"; $Plugin->cacheSubjectListHtml( $AllItemIds, str_replace($LaunchId, "X-LAUNCHID-X", $Html) ); return $Html; } # ----- SETUP ---------------------------------------------------------------- if (!isset($H_AllRecords)) { throw new Exception("H_AllRecords not defined."); } if (!isset($H_BaseLink)) { throw new Exception("H_BaseLink not defined."); } if (!isset($H_LaunchId)) { throw new Exception("H_LaunchId not defined."); } if (!isset($H_SearchParams)) { throw new Exception("H_SearchParams not defined."); } if (!isset($H_SearchParamsProvided)) { throw new Exception("H_SearchParamsProvided not defined."); } if (!isset($H_SelectedRecordIds)) { throw new Exception("H_SelectedRecordIds not defined."); } if (!isset($H_Records)) { throw new Exception("H_Records not defined."); } if (!isset($H_TransportUI)) { throw new Exception("H_TransportUI not defined."); } if (!isset($H_FacetUI)) { throw new Exception("H_FacetUI not defined."); } $AF = ApplicationFramework::getInstance(); $Plugin = EduLink::getInstance(); $User = User::getCurrentUser(); $Keywords = implode(" ", $H_SearchParams->getKeywordSearchStrings()); $IconFiles = [ 'ArrowUpInsideCircle.svg', 'Bullhorn2.svg', 'SearchResults.svg', 'Meeple.svg', 'OpenFolder.svg', ]; foreach ($IconFiles as $IconFile) { $AF->doNotUrlFingerprint($IconFile); } $SelectionUI = new ResourceSelectionUI( $H_Records, $H_SelectedRecordIds ); $SearchButton = new HtmlButton(""); $SearchButton->setIcon("MagnifyingGlass.svg"); $SearchButton->setValue("Search"); $SearchButton->setAriaLabel("Search"); # ----- DISPLAY -------------------------------------------------------------- // phpcs:disable Generic.Files.LineLength.MaxExceeded // phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect // phpcs:disable Squiz.WhiteSpace.ScopeClosingBrace.Indent include($AF->gUIFile("EduLink-StdPageStart.html")); ?>
selectedRecordListHtml() ?>

## inlineUIFile('SearchResults.svg') ?> Search Results

0) { ?>

itemCount() ?> results for

display() ?>

## inlineUIFile('Bullhorn2.svg') ?> New Resources

recordListHtml() ?>
getHtml(); ?>
getHtml(); ?>
gUIFile("EduLink-StdPageEnd.html"));