Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-10.1' into release-10.1-…
Browse files Browse the repository at this point in the history
…fix-narrow-lightbox-close
  • Loading branch information
EreMaijala committed Dec 16, 2024
2 parents b85e135 + 419cd9f commit 0951ae0
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 69 deletions.
6 changes: 6 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,9 @@ return [
<exec executable="psql" checkreturn="true">
<arg line="-c &quot;GRANT ALL ON DATABASE ${vufinddb} TO ${vufinddbuser};&quot; ${pgsqlrootuser}" />
</exec>
<exec executable="psql" checkreturn="true">
<arg line="-c &quot;ALTER DATABASE ${vufinddb} OWNER TO ${vufinddbuser};&quot; ${pgsqlrootuser}" />
</exec>
</then>
<else>
<exec executable="sudo">
Expand All @@ -849,6 +852,9 @@ return [
<exec executable="sudo" checkreturn="true">
<arg line="su -c &quot;psql -c 'GRANT ALL ON DATABASE ${vufinddb} TO ${vufinddbuser};'&quot; ${pgsqlrootuser}" />
</exec>
<exec executable="sudo" checkreturn="true">
<arg line="su -c &quot;psql -c 'ALTER DATABASE ${vufinddb} OWNER TO ${vufinddbuser};'&quot; ${pgsqlrootuser}" />
</exec>
</else>
</if>

Expand Down
Binary file added import/lib_local/postgresql-42.7.4.jar
Binary file not shown.
Binary file removed import/lib_local/postgresql-9.1-902.jdbc4.jar
Binary file not shown.
103 changes: 60 additions & 43 deletions module/VuFindTheme/src/VuFindTheme/Initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class Initializer
*/
protected $config;

/**
* Map of theme aliases to theme names (null if uninitialized)
*
* @var ?array
*/
protected $themeMap = null;

/**
* Laminas MVC Event
*
Expand Down Expand Up @@ -191,6 +198,32 @@ public function init()
}
}

/**
* Get a map of theme aliases to theme names.
*
* @return array
*/
protected function getThemeAliasMap(): array
{
if ($this->themeMap === null) {
// Set up special-case 'standard' and 'mobile' aliases:
$this->themeMap = ['standard' => $this->config->theme];
if ($this->mobile->enabled()) {
$this->themeMap['mobile'] = $this->config->mobile_theme;
}

// Parse the alternate theme settings for additional options:
$parts = explode(',', $this->config->alternate_themes ?? '');
foreach ($parts as $part) {
$subparts = explode(':', $part);
if (!empty($subparts[1])) {
$this->themeMap[trim($subparts[0])] = $subparts[1];
}
}
}
return $this->themeMap;
}

/**
* Support method for init() -- figure out which theme option is active.
*
Expand All @@ -217,59 +250,29 @@ protected function pickTheme(?Request $request)
}

// Load standard configuration options:
$standardTheme = $this->config->theme;
$themes = $this->getThemeAliasMap();
if (PHP_SAPI == 'cli') {
return $standardTheme;
return $themes['standard'];
}
$mobileTheme = $this->mobile->enabled()
? $this->config->mobile_theme : false;

// Find out if the user has a saved preference in the POST, URL or cookies:
$selectedUI = null;
if (isset($request)) {
$selectedUI = $request->getPost()->get(
'ui',
$request->getQuery()->get(
'ui',
$request->getCookie()->ui ?? null
)
);
$selectedUI = $request->getPost()->get('ui')
?? $request->getQuery()->get('ui')
?? $request->getCookie()->ui
?? null;
}
if (empty($selectedUI)) {
$selectedUI = ($mobileTheme && $this->mobile->detect())
$selectedUI = (isset($themes['mobile']) && $this->mobile->detect())
? 'mobile' : 'standard';
}

// Save the current setting to a cookie so it persists:
$this->cookieManager->set('ui', $selectedUI);

// Do we have a valid mobile selection?
if ($mobileTheme && $selectedUI == 'mobile') {
return $mobileTheme;
}

// Do we have a non-standard selection?
if (
$selectedUI != 'standard'
&& isset($this->config->alternate_themes)
) {
// Check the alternate theme settings for a match:
$parts = explode(',', $this->config->alternate_themes);
foreach ($parts as $part) {
$subparts = explode(':', $part);
if (
(trim($subparts[0]) == trim($selectedUI))
&& isset($subparts[1]) && !empty($subparts[1])
) {
return $subparts[1];
}
}
}

// If we got this far, we either have a standard option or the user chose
// an invalid non-standard option; either way, we need to default to the
// standard theme:
return $standardTheme;
// Pick the selected theme (fall back to standard if unrecognized):
return $themes[$selectedUI] ?? $themes['standard'];
}

/**
Expand Down Expand Up @@ -303,16 +306,30 @@ protected function getThemeOptions($currentTheme)
$options = [];
if (isset($this->config->selectable_themes)) {
$parts = explode(',', $this->config->selectable_themes);
$foundSelected = false;
$uiCookie = $this->cookieManager->get('ui');
foreach ($parts as $part) {
$subparts = explode(':', $part);
$name = trim($subparts[0]);
$desc = isset($subparts[1]) ? trim($subparts[1]) : '';
$desc = empty($desc) ? $name : $desc;
// Easiest and most accurate way to pick a selected theme is to check
// if the name matches the current value of the ui cookie:
$selected = $uiCookie === $name;
$foundSelected = $foundSelected || $selected;
if (!empty($name)) {
$options[] = [
'name' => $name, 'desc' => $desc,
'selected' => ($currentTheme == $name),
];
$options[] = compact('name', 'desc', 'selected');
}
}
// If we have some options, but none are selected, we need to figure
// out which option matches the provided theme.
if (!empty($options) && !$foundSelected) {
$aliasMap = $this->getThemeAliasMap();
foreach ($options as $i => $currentOptions) {
if ($aliasMap[$currentOptions['name']] === $currentTheme) {
$options[$i]['selected'] = true;
break;
}
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions themes/bootstrap3/js/combined-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ VuFind.combinedSearch = (function CombinedSearch() {
function init(container, url) {
VuFind.loadHtml(container, url, '', function containerLoad(responseText) {
if (!responseText || responseText.length === 0) {
if (container.style) {
container.style.display = "none";
}
let parent = container.parentNode;
while (parent && parent.classList.contains('js-hide-if-empty')) {
if (parent.style) {
var element = typeof container === 'string' ? document.querySelector(container) : container;
if (element) {
element.style.display = "none";
let parent = element.parentNode;
while (parent && parent.classList.contains('js-hide-if-empty')) {
parent.style.display = "none";
parent = parent.parentNode;
}
parent = parent.parentNode;
}
} else {
VuFind.initResultScripts(container);
Expand Down
3 changes: 3 additions & 0 deletions themes/bootstrap3/js/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function applyPreviewUrl($link, url) {
// Update associated record thumbnail, if any:
$link.parents('.result,.record')
.find('.recordcover[data-linkpreview="true"]').parents('a').attr('href', url)
.off('click') // disable custom click handling
.attr('data-lightbox-image', null) // disable opening in lightbox
.attr('target', '_blank') // open consistently with preview button
.attr('rel', 'noopener');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2><?=$this->transEsc('Similar Items')?></h2>
<?php $similarRecords = $this->tab->getResults(); ?>
<?php if (!empty($similarRecords)): ?>
<?php if (count($similarRecords)): ?>
<?php $perPage = 4 ?>
<div id="similar-items-carousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap3/templates/Related/MoreByAuthorSolr.phtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php $similarRecords = $this->related->getResults(); ?>
<?php if (!empty($similarRecords)): ?>
<?php if (count($similarRecords)): ?>
<h2><?=$this->transEsc('more_by_author', ['%%name%%' => $this->related->getName()])?></h2>
<ul class="list-group">
<?php foreach ($similarRecords as $data): ?>
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap3/templates/Related/Similar.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2><?=$this->transEsc('Similar Items')?></h2>
<?php $similarRecords = $this->related->getResults(); ?>
<?php if (!empty($similarRecords)): ?>
<?php if (count($similarRecords)): ?>
<ul class="list-group">
<?php foreach ($similarRecords as $data): ?>
<li class="list-group-item"><?=$this->render('Related/Similar/item.phtml', compact('data'))?></li>
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap3/templates/myresearch/editlist.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<h2><?=$this->transEsc($pageTitle); ?></h2>

<form class="form-edit-list" method="post" name="<?=$this->newList ? 'newList' : 'editListForm'?>" action="<?=$this->url('editList'); ?>">
<input type="hidden" name="id" value="<?=empty($listId = $this->list->getId()) ? 'NEW' : $this->escapeHtmlAttr($listId) ?>">
<input type="hidden" name="id" value="<?=$this->newList || empty($listId = $this->list->getId()) ? 'NEW' : $this->escapeHtmlAttr($listId) ?>">
<?=$this->context($this)->renderInContext('cart/form-record-hidden-inputs.phtml', []); ?>
<div class="form-group">
<label class="control-label" for="list_title"><?=$this->transEsc('List'); ?>:</label>
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap3/templates/record/save.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<?php endif; ?>
</select>
<?php endif; ?>
<button type="submit" name="newList" class="btn btn-link" id="make-list"><?=$showLists ? $this->transEsc('or create a new list') : $this->transEsc('Create a List'); ?></button>
<button type="submit" name="newList" value="1" class="btn btn-link" id="make-list"><?=$showLists ? $this->transEsc('or create a new list') : $this->transEsc('Create a List'); ?></button>
</div>

<?php if ($showLists): ?>
Expand Down
3 changes: 1 addition & 2 deletions themes/bootstrap5/js/account_ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ VuFind.register('account', function Account() {
accountIconEl.dataset.bsToggle = 'tooltip';
accountIconEl.dataset.bsPlacement = 'bottom';
accountIconEl.title = VuFind.translate('account_has_alerts');
const tooltip = bootstrap.Tooltip.getOrCreateInstance(accountIconEl);
tooltip.show();
bootstrap.Tooltip.getOrCreateInstance(accountIconEl);
} else {
const tooltip = bootstrap.Tooltip.getOrCreateInstance(accountIconEl);
tooltip.dispose();
Expand Down
13 changes: 6 additions & 7 deletions themes/bootstrap5/js/combined-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ VuFind.combinedSearch = (function CombinedSearch() {
function init(container, url) {
VuFind.loadHtml(container, url, '', function containerLoad(responseText) {
if (!responseText || responseText.length === 0) {
if (container.style) {
container.style.display = "none";
}
let parent = container.parentNode;
while (parent && parent.classList.contains('js-hide-if-empty')) {
if (parent.style) {
var element = typeof container === 'string' ? document.querySelector(container) : container;
if (element) {
element.style.display = "none";
let parent = element.parentNode;
while (parent && parent.classList.contains('js-hide-if-empty')) {
parent.style.display = "none";
parent = parent.parentNode;
}
parent = parent.parentNode;
}
} else {
VuFind.initResultScripts(container);
Expand Down
3 changes: 3 additions & 0 deletions themes/bootstrap5/js/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function applyPreviewUrl($link, url) {
// Update associated record thumbnail, if any:
$link.parents('.result,.record')
.find('.recordcover[data-linkpreview="true"]').parents('a').attr('href', url)
.off('click') // disable custom click handling
.attr('data-lightbox-image', null) // disable opening in lightbox
.attr('target', '_blank') // open consistently with preview button
.attr('rel', 'noopener');
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2><?=$this->transEsc('Similar Items')?></h2>
<?php $similarRecords = $this->tab->getResults(); ?>
<?php if (!empty($similarRecords)): ?>
<?php if (count($similarRecords)): ?>
<?php $perPage = 4 ?>
<div id="similar-items-carousel" class="carousel slide" data-bs-ride="carousel">
<!-- Indicators -->
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/templates/Related/MoreByAuthorSolr.phtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php $similarRecords = $this->related->getResults(); ?>
<?php if (!empty($similarRecords)): ?>
<?php if (count($similarRecords)): ?>
<h2><?=$this->transEsc('more_by_author', ['%%name%%' => $this->related->getName()])?></h2>
<ul class="list-group">
<?php foreach ($similarRecords as $data): ?>
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/templates/Related/Similar.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2><?=$this->transEsc('Similar Items')?></h2>
<?php $similarRecords = $this->related->getResults(); ?>
<?php if (!empty($similarRecords)): ?>
<?php if (count($similarRecords)): ?>
<ul class="list-group">
<?php foreach ($similarRecords as $data): ?>
<li class="list-group-item"><?=$this->render('Related/Similar/item.phtml', compact('data'))?></li>
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/templates/myresearch/editlist.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<h2><?=$this->transEsc($pageTitle); ?></h2>

<form class="form-edit-list" method="post" name="<?=$this->newList ? 'newList' : 'editListForm'?>" action="<?=$this->url('editList'); ?>">
<input type="hidden" name="id" value="<?=empty($listId = $this->list->getId()) ? 'NEW' : $this->escapeHtmlAttr($listId) ?>">
<input type="hidden" name="id" value="<?=$this->newList || empty($listId = $this->list->getId()) ? 'NEW' : $this->escapeHtmlAttr($listId) ?>">
<?=$this->context($this)->renderInContext('cart/form-record-hidden-inputs.phtml', []); ?>
<div class="form-group">
<label class="control-label" for="list_title"><?=$this->transEsc('List'); ?>:</label>
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/templates/record/save.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<?php endif; ?>
</select>
<?php endif; ?>
<button type="submit" name="newList" class="btn btn-link" id="make-list"><?=$showLists ? $this->transEsc('or create a new list') : $this->transEsc('Create a List'); ?></button>
<button type="submit" name="newList" value="1" class="btn btn-link" id="make-list"><?=$showLists ? $this->transEsc('or create a new list') : $this->transEsc('Create a List'); ?></button>
</div>

<?php if ($showLists): ?>
Expand Down

0 comments on commit 0951ae0

Please sign in to comment.