diff --git a/module/VuFind/src/VuFind/Controller/CombinedController.php b/module/VuFind/src/VuFind/Controller/CombinedController.php index d9a54b5c49a..f21aec850d9 100644 --- a/module/VuFind/src/VuFind/Controller/CombinedController.php +++ b/module/VuFind/src/VuFind/Controller/CombinedController.php @@ -125,7 +125,7 @@ public function resultAction() 'domId' => 'combined_' . str_replace(':', '____', $sectionId), ]; // Initialize theme resources: - ($this->getViewRenderer()->plugin('headThemeResources'))(); + ($this->getViewRenderer()->plugin('headThemeResources'))(true); // Render content: $html = $this->getViewRenderer()->render( 'combined/results-list.phtml', diff --git a/module/VuFind/src/VuFind/View/Helper/Root/AccountMenu.php b/module/VuFind/src/VuFind/View/Helper/Root/AccountMenu.php index f7e116a5888..c479c71a366 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/AccountMenu.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/AccountMenu.php @@ -360,10 +360,11 @@ protected function getIlsConnection(): IlsConnection * Render account menu * * @param string $activeItem The name of current active item + * @param string $idPrefix Element ID prefix * * @return string */ - public function render(string $activeItem): string + public function render(string $activeItem, string $idPrefix = ''): string { $contextHelper = $this->getView()->plugin('context'); return $contextHelper->renderInContext( @@ -371,6 +372,7 @@ public function render(string $activeItem): string [ 'items' => $this->getItems(), 'active' => $activeItem, + 'idPrefix' => $idPrefix, ] ); } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php b/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php index d85e745df0e..df155d109c7 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/SearchBox.php @@ -426,7 +426,6 @@ protected function getCombinedHandlers($activeSearchClass, $activeHandler) { // Build settings: $handlers = []; - $selectedFound = false; $backupSelectedIndex = false; $addedBrowseHandlers = false; $settings = $this->getCombinedHandlerConfig($activeSearchClass); @@ -447,10 +446,9 @@ protected function getCombinedHandlers($activeSearchClass, $activeHandler) $j++; $selected = $target == $activeSearchClass && $activeHandler == $searchVal; - if ($selected) { - $selectedFound = true; - } elseif ( - $backupSelectedIndex === false + if ( + !$selected + && $backupSelectedIndex === false && $target == $activeSearchClass ) { $backupSelectedIndex = count($handlers); @@ -503,7 +501,8 @@ protected function getCombinedHandlers($activeSearchClass, $activeHandler) } // If we didn't find an exact match for a selected index, use a fuzzy - // match: + // match (do the check here since it could be an AlphaBrowse index too): + $selectedFound = in_array(true, array_column($handlers, 'selected'), true); if (!$selectedFound && $backupSelectedIndex !== false) { $handlers[$backupSelectedIndex]['selected'] = true; } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/OaiTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/OaiTest.php index 16e1dc242ce..a3d13d23ba3 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/OaiTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/OaiTest.php @@ -81,6 +81,7 @@ public static function serverProvider(): array * * @dataProvider serverProvider */ + #[\VuFindTest\Attribute\HtmlValidation(false)] public function testDisabledByDefault(string $path): void { $session = $this->getMinkSession(); diff --git a/module/VuFindTheme/src/VuFindTheme/View/Helper/SetupThemeResources.php b/module/VuFindTheme/src/VuFindTheme/View/Helper/SetupThemeResources.php index fabf2b6ef70..c891b264393 100644 --- a/module/VuFindTheme/src/VuFindTheme/View/Helper/SetupThemeResources.php +++ b/module/VuFindTheme/src/VuFindTheme/View/Helper/SetupThemeResources.php @@ -64,12 +64,16 @@ public function __construct(\VuFindTheme\ResourceContainer $container) /** * Set up items based on contents of theme resource container. * + * @param bool $partial Whether rendering an HTML snippet instead of a full page + * * @return void */ - public function __invoke() + public function __invoke(bool $partial = false) { - $this->addMetaTags(); - $this->addLinks(); + if (!$partial) { + $this->addMetaTags(); + } + $this->addLinks($partial); $this->addScripts(); } @@ -97,9 +101,11 @@ protected function addMetaTags() /** * Add links to header. * + * @param bool $partial Whether rendering an HTML snippet instead of a full page + * * @return void */ - protected function addLinks() + protected function addLinks(bool $partial = false) { // Convenient shortcut to view helper: $headLink = $this->getView()->plugin('headLink'); @@ -125,8 +131,7 @@ protected function addLinks() // If `favicon` is a string then treat it as a single file path to an .ico icon. // If `favicon` is an array then treat each item as an assoc array of html attributes and render // a link element for each. - $favicon = $this->container->getFavicon(); - if (!empty($favicon)) { + if (!$partial && ($favicon = $this->container->getFavicon())) { $imageLink = $this->getView()->plugin('imageLink'); if (is_array($favicon)) { foreach ($favicon as $attrs) { diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js index 1f3c25df610..4f4c478880e 100644 --- a/themes/bootstrap3/js/common.js +++ b/themes/bootstrap3/js/common.js @@ -408,9 +408,11 @@ var VuFind = (function VuFind() { link.addEventListener('click', function toggleQRCode() { var holder = this.nextElementSibling; if (holder.querySelectorAll('img').length === 0) { - // We need to insert the QRCode image - var template = holder.querySelector('.qrCodeImgTag').innerHTML; - holder.innerHTML = template; + // Replace the QRCode template with the image: + const templateEl = holder.querySelector('.qrCodeImgTag'); + if (templateEl) { + templateEl.parentNode.innerHTML = templateEl.innerHTML; + } } }); }); diff --git a/themes/bootstrap3/templates/Recommend/SideFacets.phtml b/themes/bootstrap3/templates/Recommend/SideFacets.phtml index a4e7557ea28..b170f39d900 100644 --- a/themes/bootstrap3/templates/Recommend/SideFacets.phtml +++ b/themes/bootstrap3/templates/Recommend/SideFacets.phtml @@ -54,7 +54,7 @@ icon('collapse', 'facet-title-icon') ?> -
data-force-in="1"> +
data-force-in="1"> context($this)->renderInContext( 'Recommend/SideFacets/facet.phtml', diff --git a/themes/bootstrap3/templates/Recommend/SideFacets/cluster-list.phtml b/themes/bootstrap3/templates/Recommend/SideFacets/cluster-list.phtml index 38d0c821429..e76a0764d56 100644 --- a/themes/bootstrap3/templates/Recommend/SideFacets/cluster-list.phtml +++ b/themes/bootstrap3/templates/Recommend/SideFacets/cluster-list.phtml @@ -13,7 +13,7 @@ 'more-label' => $this->transEsc('more_ellipsis'), 'less-label' => $this->transEsc('less_ellipsis'), 'wrapper-class' => false, - 'wrapper-tagname' => 'div', + 'wrapper-tagname' => 'li', ]; $facetLightboxParams = http_build_query( [ diff --git a/themes/bootstrap3/templates/Recommend/SideFacets/single-facet.phtml b/themes/bootstrap3/templates/Recommend/SideFacets/single-facet.phtml index 454cd2a5790..4c18bbac654 100644 --- a/themes/bootstrap3/templates/Recommend/SideFacets/single-facet.phtml +++ b/themes/bootstrap3/templates/Recommend/SideFacets/single-facet.phtml @@ -53,12 +53,12 @@ - + facet['isApplied']): ?> title="transEscAttr('applied_filter') ?>" data-lightbox-ignore> diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/explain.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/explain.phtml index 5cbf71424e4..c5bdbdcfa09 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/explain.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/explain.phtml @@ -20,7 +20,7 @@ $link = $this->recordLinker()->getUrl($this->driver);

translate('explain_relevance', [ - '%%recordId%%' => '' . $recordId . '', + '%%recordId%%' => '' . $this->escapeHtml($recordId) . '', '%%relevanceValue%%' => $this->localizedNumber($totalScore, $decimalPlaces)]) ?> diff --git a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/list-entry.phtml b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/list-entry.phtml index 99a53222d6a..75f4939aa78 100644 --- a/themes/bootstrap3/templates/RecordDriver/DefaultRecord/list-entry.phtml +++ b/themes/bootstrap3/templates/RecordDriver/DefaultRecord/list-entry.phtml @@ -226,7 +226,7 @@ 'buttonLink' => $deleteUrlGet, 'buttonIcon' => 'user-list-remove', 'buttonLabel' => 'Delete', - 'confirmId' => "confirm_delete_item_$id", + 'confirmId' => 'confirm_delete_item_' . urlencode($id), ] ) ?> diff --git a/themes/bootstrap3/templates/header.phtml b/themes/bootstrap3/templates/header.phtml index 19e09b0c107..3a9d7b20cb0 100644 --- a/themes/bootstrap3/templates/header.phtml +++ b/themes/bootstrap3/templates/header.phtml @@ -43,7 +43,7 @@

diff --git a/themes/bootstrap3/templates/hierarchy/tree.phtml b/themes/bootstrap3/templates/hierarchy/tree.phtml index d9fca576494..73da3ace684 100644 --- a/themes/bootstrap3/templates/hierarchy/tree.phtml +++ b/themes/bootstrap3/templates/hierarchy/tree.phtml @@ -17,8 +17,7 @@ // Function for rendering a tree level. Optimized to avoid extra objects or // template calls and defined as array to avoid interfering with the plugin __call // magic. - $this->renderTreeLevel = [function ($nodes, $context, $hierarchyID, $driver, $selectedID) { - $this->parentNodeId ??= ''; + $this->renderTreeLevel = [function ($nodes, $context, $hierarchyID, $driver, $selectedID, $parentNodeId = '') { $nodeId = 0; $icons = [ 'hierarchy-collection' => $this->icon('hierarchy-collection'), @@ -62,10 +61,10 @@ if ($hasChildren) { echo ''; ++$nodeId; - $childUlId = 'hierarchy_' . $context . '_' . $this->parentNodeId . '_' . $nodeId; + $childUlIdEsc = $escapeAttr('hierarchy_' . $context . '_' . $parentNodeId . '_' . $nodeId); echo ''; echo " $itemHtml "; - echo '
    '; - ($this->renderTreeLevel[0])($node->children, $context, $hierarchyID, $driver, $selectedID); + echo '
      '; + ($this->renderTreeLevel[0])($node->children, $context, $hierarchyID, $driver, $selectedID, "{$parentNodeId}_$nodeId"); echo '
    '; } else { echo '' diff --git a/themes/bootstrap3/templates/myresearch/menu.phtml b/themes/bootstrap3/templates/myresearch/menu.phtml index 03450158878..85381aca056 100644 --- a/themes/bootstrap3/templates/myresearch/menu.phtml +++ b/themes/bootstrap3/templates/myresearch/menu.phtml @@ -2,8 +2,8 @@ $user = $this->auth()->getUserObject(); ?> component('hide-offcanvas-button')?> -

    transEsc('Your Account')?>

    -