Skip to content

Commit

Permalink
Merge branch 'pull-request/configurable-view-for-eds' of github.com:T…
Browse files Browse the repository at this point in the history
…hoWagen/vufind into pull-request/configurable-view-for-eds
  • Loading branch information
ThoWagen committed Jan 27, 2025
2 parents 51ed27a + 2b0fbe3 commit c66dd46
Show file tree
Hide file tree
Showing 41 changed files with 768 additions and 89 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"laminas/laminas-servicemanager": "3.22.1",
"laminas/laminas-session": "2.21.0",
"laminas/laminas-stdlib": "3.19.0",
"laminas/laminas-text": "2.11.0",
"laminas/laminas-validator": "2.64.2",
"laminas/laminas-view": "2.27.0",
"laminas/laminas-translator": "^1",
Expand Down
23 changes: 12 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions config/vufind/combined.ini
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ columns = 3
stack_placement = distributed
; Jump links appear above the search results and link to each result module
;jump_links = true
; If jump_links is true, this setting can control what types of links are used:
; 'anchor' will create anchor links that jump to the matching column on the page
; 'link' will link directly to the expanded search results
; The default is 'anchor'
;jump_links_mode = anchor

[Solr]
label = Catalog
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE INDEX login_token_user_id_idx ON login_token (user_id);
CREATE INDEX login_token_series_idx ON login_token (series);
DROP INDEX login_token_user_id_series_idx;
3 changes: 2 additions & 1 deletion module/VuFind/sql/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ CREATE TABLE `login_token` (
`expires` int NOT NULL,
`last_session_id` varchar(255) NULL,
PRIMARY KEY (`id`),
KEY `user_id_series` (`user_id`, `series`)
KEY `user_id` (`user_id`),
KEY `series` (`series`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
3 changes: 2 additions & 1 deletion module/VuFind/sql/pgsql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ CREATE TABLE login_token (
last_session_id varchar(255),
PRIMARY KEY (id)
);
CREATE INDEX login_token_user_id_series_idx ON login_token (user_id, series);
CREATE INDEX login_token_user_id_idx ON login_token (user_id);
CREATE INDEX login_token_series_idx ON login_token (series);

-- --------------------------------------------------------

Expand Down
11 changes: 9 additions & 2 deletions module/VuFind/src/VuFind/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,14 @@ public function newitemresultsAction()
$this->getRequest()->getQuery()->set('hiddenFilters', $hiddenFilters);
}

// Don't save to history -- history page doesn't handle correctly:
// Flag this as a specialized search to avoid bleeding defaults into the
// standard search box:
$this->getRequest()->getQuery()->set('specializedSearch', true);

// Don't save to history or memory -- history page doesn't handle correctly
// and we don't want hidden filters bleeding to weird places:
$this->saveToHistory = false;
$this->getSearchMemory()->disable();

// Call rather than forward, so we can use custom template
$view = $this->resultsAction();
Expand All @@ -310,11 +316,12 @@ public function newitemresultsAction()
$view->results->getUrlQuery()
->setDefaultParameter('range', $range)
->setDefaultParameter('department', $dept)
->disableHiddenFilters()
->setSuppressQuery(true);
}

// We don't want new items hidden filters to propagate to other searches:
$view->ignoreHiddenFilterMemory = true;
$this->serviceLocator->get('ViewHelperManager')->get('searchTabs')->disableCurrentHiddenFilterParams();
$view->ignoreHiddenFiltersInRequest = true;

return $view;
Expand Down
14 changes: 11 additions & 3 deletions module/VuFind/src/VuFind/Controller/UpgradeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,12 @@ public function fixdatabaseAction()
}
}

// If we have SQL to show, stop at this point to allow the changes to be made before progressing any
// further:
if (!empty($this->session->sql)) {
return $this->forwardTo('Upgrade', 'ShowSql');
}

// Now that database structure is addressed, we can fix database
// content -- the checks below should be platform-independent.

Expand Down Expand Up @@ -621,9 +627,6 @@ public function fixdatabaseAction()
}

$this->cookie->databaseOkay = true;
if (!empty($this->session->sql)) {
return $this->forwardTo('Upgrade', 'ShowSql');
}
return $this->redirect()->toRoute('upgrade-home');
}

Expand All @@ -634,6 +637,11 @@ public function fixdatabaseAction()
*/
public function showsqlAction()
{
$recheck = $this->params()->fromPost('recheck');
if ($recheck) {
unset($this->session->sql);
return $this->redirect()->toRoute('upgrade-fixdatabase');
}
$continue = $this->params()->fromPost('continue', 'nope');
if ($continue == 'Next') {
unset($this->session->sql);
Expand Down
4 changes: 3 additions & 1 deletion module/VuFind/src/VuFind/Search/Base/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ abstract class Options implements TranslatorAwareInterface
*/
public function __construct(\VuFind\Config\PluginManager $configLoader)
{
$this->limitOptions = [$this->defaultLimit];
$this->setConfigLoader($configLoader);

$id = $this->getSearchClassId();
Expand Down Expand Up @@ -545,6 +544,9 @@ public function getDefaultLimit()
*/
public function getLimitOptions()
{
if (empty($this->limitOptions)) {
$this->limitOptions = [$this->getDefaultLimit()];
}
return $this->limitOptions;
}

Expand Down
20 changes: 20 additions & 0 deletions module/VuFind/src/VuFind/Search/Base/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ class Params
*/
protected $queryAdapterClass = QueryAdapter::class;

/**
* Is this a specialized search (i.e. a customized scenario like new items,
* rather than a "normal" backend search)?
*
* @var bool
*/
protected $isSpecializedSearch = false;

/**
* Constructor
*
Expand Down Expand Up @@ -376,6 +384,7 @@ public function initFromRequest($request)
$this->initSort($request);
$this->initFilters($request);
$this->initHiddenFilters($request);
$this->isSpecializedSearch = $request->get('specializedSearch', false);
}

/**
Expand Down Expand Up @@ -2122,4 +2131,15 @@ public function supportsFacetFiltering($facet)
$translatedFacets = $this->getOptions()->getTranslatedFacets();
return method_exists($this, 'setFacetContains') && !in_array($facet, $translatedFacets);
}

/**
* Is this a specialized search (i.e. a customized scenario like new items,
* rather than a "normal" backend search)?
*
* @return bool
*/
public function isSpecializedSearch(): bool
{
return $this->isSpecializedSearch;
}
}
11 changes: 11 additions & 0 deletions module/VuFind/src/VuFind/Search/UrlQueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ public function getParamsWithConfiguredDefaults()
return array_keys($this->config['defaults'] ?? []);
}

/**
* Disable hidden filters
*
* @return UrlQueryHelper
*/
public function disableHiddenFilters()
{
unset($this->urlParams['hiddenFilters']);
return $this;
}

/**
* Control query suppression
*
Expand Down
21 changes: 21 additions & 0 deletions module/VuFind/src/VuFind/View/Helper/Root/SearchTabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ class SearchTabs extends \Laminas\View\Helper\AbstractHelper
*/
protected $cachedHiddenFilterParams = [];

/**
* Should we force getCurrentHiddenFilterParams() to return an empty string?
*
* @var bool
*/
protected $currentHiddenFilterParamsDisabled = false;

/**
* Constructor
*
Expand Down Expand Up @@ -229,6 +236,9 @@ public function getCurrentHiddenFilterParams(
$ignoreHiddenFilterMemory = false,
$prepend = '&'
) {
if ($this->currentHiddenFilterParamsDisabled) {
return '';
}
if (!isset($this->cachedHiddenFilterParams[$searchClassId])) {
$view = $this->getView();
$hiddenFilters = $this->getHiddenFilters(
Expand Down Expand Up @@ -371,4 +381,15 @@ protected function buildUrlHiddenFilters(
}
return '';
}

/**
* Force getCurrentHiddenFilterParams() to return an empty string (used in contexts like
* New Items where we don't want to persist hidden filters through links).
*
* @return void
*/
public function disableCurrentHiddenFilterParams(): void
{
$this->currentHiddenFilterParamsDisabled = true;
}
}
5 changes: 5 additions & 0 deletions module/VuFind/tests/fixtures/configs/eds/EDS.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Facets]
foo = bar

[General]
default_view = test
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,14 @@ public function testGlobalCacheClearing()
$this->waitForPageLoad($page);

$page = $this->setUpFinesEnvironment();
// Check storage
$storage = $this->getJSStorage();
$this->assertNotNull($storage['fines']);
// Clear all cache
// Clear all cached data
$session->evaluateScript('VuFind.account.clearCache();');
// Wait for reload
$this->waitForPageLoad($page);
// Check storage again
$storage = $this->getJSStorage();
// Status code MISSING is -2 * Math.PI, but we just round it here to avoid trouble
$fines = json_decode($storage['fines'], true);
$this->assertEquals(-6, ceil($fines[$this->getCurrentTheme()]));
$this->assertNull($storage['fines']);
}

/**
Expand Down
Loading

0 comments on commit c66dd46

Please sign in to comment.