diff --git a/collections/search/index.php b/collections/search/index.php index 139ad5d1f2..f9c7fb9073 100644 --- a/collections/search/index.php +++ b/collections/search/index.php @@ -12,6 +12,8 @@ if($LANG_TAG != 'en' && file_exists($SERVER_ROOT.'/content/lang/collections/search/index.' . $LANG_TAG . '.php')) include_once($SERVER_ROOT.'/content/lang/collections/search/index.' . $LANG_TAG . '.php'); else include_once($SERVER_ROOT . '/content/lang/collections/search/index.en.php'); +$collIdsFromUrl = array_key_exists("db",$_GET) ? explode(",", str_replace(array('[',']'), '', $_GET["db"])) : ''; + $collManager = new OccurrenceManager(); $collectionSource = $collManager->getQueryTermStr(); @@ -567,31 +569,15 @@ ul.outerWidth(this.element.outerWidth()); } const collectionSource = ; + const collIdsFromUrl = ; + if (collIdsFromUrl && Array.isArray(collIdsFromUrl) && collIdsFromUrl.length > 0) { + uncheckEverything(); + checkTheCollectionsThatShouldBeChecked(collIdsFromUrl); + } const sanitizedCollectionSource = collectionSource.replace('db=',''); - - if(collectionSource){ - // go through all collections and set them all to unchecked - const collectionCheckboxes = document.querySelectorAll('input[id^="coll"]'); - collectionCheckboxes.forEach(collection => { - collection.checked = false; - }); - - //go through all collections and set the parent collections to unchecked - const parentCollectionCheckboxes = document.querySelectorAll('input[id^="cat-"]'); - parentCollectionCheckboxes.forEach(collection => { - collection.checked = false; - }); - - // set the one with collectionSource as checked - const targetCheckbox = document.querySelectorAll('input[id^="coll-' + sanitizedCollectionSource + '"]'); - targetCheckbox.forEach(collection => { - collection.checked = true; - }); - //do the same for collections with slightly different format - const targetCheckboxAlt = document.querySelectorAll('input[id^="collection-' + sanitizedCollectionSource + '"]'); - targetCheckboxAlt.forEach(collection => { - collection.checked = true; - }); + if (collectionSource) { + uncheckEverything(); + checkTheCollectionsThatShouldBeChecked(sanitizedCollectionSource); updateChip(); }