Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/NatLibFi/NDL-VuFind2 into fi…
Browse files Browse the repository at this point in the history
…nna-1240
  • Loading branch information
tmikkonen committed Dec 13, 2023
2 parents 1648905 + ff29870 commit c9c79bd
Show file tree
Hide file tree
Showing 24 changed files with 173 additions and 121 deletions.
2 changes: 1 addition & 1 deletion composer.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"jaybizzle/crawler-detect": "^1.2.111",
"league/mime-type-detection": "1.9.0",
"natlibfi/besimple-soap": "2.0.0",
"natlibfi/finna-code-sets": "0.3.0",
"natlibfi/finna-code-sets": "0.4.0",
"natlibfi/php-html-parser": "4.0.1",
"paytrail/paytrail-php-sdk": "2.5.2",
"picqer/php-barcode-generator": "2.0.1",
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

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

9 changes: 9 additions & 0 deletions local/config/finna/KohaRest.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ enabled = true
; The field to display as the SMS number. Default is sms_number.
; Set to empty string for "none".
;smsNumberField = ""
; The field to display as the hold identifier number. Default is other_name.
; Set to empty string for "none".
;holdIdentifierField = ""
; The field to display as the hold identifier number. Default is other_name.
; Set to empty string for "none".
;holdIdentifierField = ""
; The field to display as the calling name. Not displayed by default.
; Set to empty string for "none".
;callingNameField = ""
; Whether to display messaging settings. Default is true.
;messagingSettings = false

Expand Down
1 change: 1 addition & 0 deletions local/languages/finna/Aipa/fi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ learningAreas = "Oppimisen alueet"
lowerSecondarySchool = "Yläkoulu"
lrmi_assignment_ideas = "Tehtäväideat"
lrmi_objectives = "Tavoite ja sisältöalue"
More Information = "Lisätietoa"
primarySchool = "Alakoulu"
questions_feedback = "Kysymyksiä tai palautetta aineistopaketista?"
rights_coverage_text_and_materials = "Käyttöoikeus koskee paketin tekstisisältöjä ja sen aineistoja."
Expand Down
1 change: 1 addition & 0 deletions local/languages/finna/Aipa/sv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ learningAreas = "Lärområden"
lowerSecondarySchool = "Högstadiet"
lrmi_assignment_ideas = "Uppgiftsidéer"
lrmi_objectives = "Mål och innehållsområden"
More Information = "Mer information"
primarySchool = "Lågstadiet"
questions_feedback = "Frågor eller respons angående materialetpaketet?"
studyContents = "Innehållsområden"
Expand Down
1 change: 1 addition & 0 deletions local/languages/finna/en-gb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ browse_extended_Journal = "Browse for journals"
browse_extended_Journal_html = '<span class="hidden-sm">Browse for journals </span><strong><span class="index">%%start%% - %%end%%</strong> / <strong><span class="total">%%total%%</span></strong>'
cached_record_warning = "This record has been removed. Last cached version is shown."
Call Slips = "Requests"
Calling Name = "Calling Name"
cannot cancel = "Cannot cancel"
cannot cancel any interlibrary loan requests = "Cannot cancel any Interlibrary Loan Requests"
Cannot renew yet = "Cannot renew yet"
Expand Down
1 change: 1 addition & 0 deletions local/languages/finna/fi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ browse_extended_Journal_html = '<span class="hidden-sm">Selaa lehtiä </span><st
browse_extended_description_Journal_html = ""
cached_record_warning = "Tämä aineistosivu on poistettu. Näytetään viimeinen välimuistiin tallennettu versio."
Call Slips = "Tilaukset"
Calling Name = "Kutsumanimi"
cannot cancel = "Ei voi perua"
cannot cancel any interlibrary loan requests = "Yhtään kaukolainatilausta ei voi perua"
Cannot renew yet = "Ei voida uusia vielä"
Expand Down
1 change: 1 addition & 0 deletions local/languages/finna/sv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ browse_extended_Journal = "Bläddra bland tidskrifter"
browse_extended_Journal_html = '<span class="hidden-sm">Bläddra bland tidskrifter </span><strong><span class="index">%%start%%</span> - %%end%%</strong> / strong><span class="total">%%total%%</span></strong>'
cached_record_warning = "Denna materialsida har tagits bort. Den senaste versionen som sparats i cacheminnet visas."
Call Slips = "Beställningar"
Calling Name = "Tilltalsnamn"
cannot cancel = "Kan inte återkalla"
cannot cancel any interlibrary loan requests = "Kan inte återkalla inga fjärrlånebeställningar"
Cannot renew yet = "Kan ännu inte förnyas"
Expand Down
12 changes: 6 additions & 6 deletions module/Finna/src/Finna/ILS/Driver/KohaRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,15 @@ public function getMyProfile($patron)
];
}

$phoneField = $this->config['Profile']['phoneNumberField']
?? 'mobile';

$smsField = $this->config['Profile']['smsNumberField']
?? 'sms_number';
$phoneField = $this->config['Profile']['phoneNumberField'] ?? 'mobile';
$smsField = $this->config['Profile']['smsNumberField'] ?? 'sms_number';
$holdIdentifierField = $this->config['Profile']['holdIdentifierField'] ?? 'other_name';
$callingNameField = $this->config['Profile']['callingNameField'] ?? '';

$profile = [
'firstname' => $result['firstname'],
'lastname' => $result['surname'],
'calling_name' => $result[$callingNameField] ?? '',
'email' => $result['email'],
'address1' => $result['address'],
'address2' => $result['address2'],
Expand All @@ -428,7 +428,7 @@ public function getMyProfile($patron)
'expiration_date' => $expirationDate,
'expiration_soon' => !empty($result['expiry_date_near']),
'expired' => !empty($result['blocks']['Patron::CardExpired']),
'hold_identifier' => $result['other_name'],
'hold_identifier' => $result[$holdIdentifierField] ?? '',
'guarantors' => $guarantors,
'guarantees' => $guarantees,
'loan_history' => $result['privacy'],
Expand Down
35 changes: 20 additions & 15 deletions module/Finna/src/Finna/Search/Solr/SolrExtensionsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@
*/
class SolrExtensionsListener
{
/**
* Terms filter prefix for a filter (%s is the field name)
*
* @var string
*/
public const TERMS_FILTER_PREFIX = "{!terms f=%s separator=\"\u{001f}\"}";

/**
* Terms filter prefix for a source filter
*
Expand Down Expand Up @@ -473,12 +480,6 @@ protected function handleAvailabilityFilters(EventInterface $event)
$filters = $params->get('fq');
if (null !== $filters) {
$sources = explode(',', $searchConfig->Records->sources);
$sources = array_map(
function ($s) {
return "\"$s\"";
},
$sources
);

if (!empty($searchConfig->Records->deduplication)) {
$prefixes = [
Expand All @@ -488,9 +489,10 @@ function ($s) {
foreach ($filters as $key => $value) {
if ($value === $prefix . '_boolean:"1"') {
unset($filters[$key]);
$filter = $prefix . '_str_mv:('
. implode(' OR ', $sources) . ')';
$filters[] = $filter;
$filters[] = sprintf(
static::TERMS_FILTER_PREFIX,
$prefix . '_str_mv'
) . implode("\u{001f}", $sources);
$params->set('fq', $filters);
break;
}
Expand All @@ -501,20 +503,23 @@ function ($s) {
foreach ($filters as $key => $value) {
if ($value === 'source_available_str_mv:*') {
$buildings = [];
$buildingRegExp
= '/\{!tag=building_filter\}building:\(building:(".*")/';
$buildingRegExp = '/\{!tag=building_filter\}building:\(building:"(.*)"/';
foreach ($filters as $value2) {
if (preg_match($buildingRegExp, $value2, $matches)) {
$buildings[] = $matches[1];
}
}
unset($filters[$key]);
if ($buildings) {
$filter = 'building_available_str_mv:('
. implode(' OR ', $buildings) . ')';
$filter = sprintf(
static::TERMS_FILTER_PREFIX,
'building_available_str_mv'
) . implode("\u{001f}", $buildings);
} else {
$filter = 'source_available_str_mv:('
. implode(' OR ', $sources) . ')';
$filter = sprintf(
static::TERMS_FILTER_PREFIX,
'source_available_str_mv'
) . implode("\u{001f}", $sources);
}
$filters[] = $filter;
$params->set('fq', $filters);
Expand Down
43 changes: 25 additions & 18 deletions module/Finna/src/Finna/View/Helper/Root/Aipa.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,8 @@ public function renderEducationalLevelsAndSubjects(array $educationalData): stri
$component = $this->getView()->plugin('component');
$langcode = $this->view->layout()->userLang;

// Basic education levels are mapped to primary school and lower secondary
// school levels.
$levelCodeValues = EducationalData::getMappedLevelCodeValues(
$educationalData[EducationalData::EDUCATIONAL_LEVELS] ?? []
);

usort($levelCodeValues, [$this, 'sortEducationalLevels']);

$html = '';
foreach ($levelCodeValues as $levelCodeValue) {
foreach ($this->getEducationalLevelCodeValues($educationalData) as $levelCodeValue) {
$levelData = EducationalData::getEducationalLevelData($levelCodeValue, $educationalData);
if (empty($levelData)) {
continue;
Expand Down Expand Up @@ -205,17 +197,9 @@ public function renderStudyContentsAndObjectives(array $educationalData): string
$transEsc = $this->getView()->plugin('transEsc');
$langcode = $this->view->layout()->userLang;

// Basic education levels are mapped to primary school and lower secondary
// school levels.
$levelCodeValues = EducationalData::getMappedLevelCodeValues(
$educationalData[EducationalData::EDUCATIONAL_LEVELS] ?? []
);

usort($levelCodeValues, [$this, 'sortEducationalLevels']);

$html = '';
$levelsHtml = [];
foreach ($levelCodeValues as $levelCodeValue) {
foreach ($this->getEducationalLevelCodeValues($educationalData) as $levelCodeValue) {
$levelData = EducationalData::getEducationalLevelData($levelCodeValue, $educationalData);
if (empty($levelData)) {
continue;
Expand Down Expand Up @@ -325,6 +309,29 @@ public function renderStudyContentsAndObjectives(array $educationalData): string
return $html;
}

/**
* Get processed educational level code values.
*
* @param array $educationalData Educational data from record driver
*
* @return array
*/
protected function getEducationalLevelCodeValues(array $educationalData): array
{
// Basic education levels are mapped to primary school and lower secondary
// school levels.
$levelCodeValues = EducationalData::getMappedLevelCodeValues(
$educationalData[EducationalData::EDUCATIONAL_LEVELS] ?? []
);

// Remove basic education root level, data should be entered at lower levels.
unset($levelCodeValues[EducationalLevelInterface::BASIC_EDUCATION]);

usort($levelCodeValues, [$this, 'sortEducationalLevels']);

return $levelCodeValues;
}

/**
* Sort educational levels.
*
Expand Down
16 changes: 16 additions & 0 deletions module/Finna/src/Finna/View/Helper/Root/RecordDataFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,21 @@ public function filterForwardFields($coreFields)
return $this->filterFields($coreFields, $include);
}

/**
* Filter unnecessary fields from AIPA records.
*
* @param array $coreFields data to filter.
*
* @return array
*/
public function filterAipaFields($coreFields)
{
$aipaFields = $this->filterQDCFields($coreFields);
unset($aipaFields['Language']);
unset($aipaFields['Subjects']);
return $aipaFields;
}

/**
* Get default configuration.
*
Expand All @@ -575,6 +590,7 @@ public function getDefaults($key = 'core'): array
}
switch ($type) {
case 'aipa':
return $this->filterAipaFields($defaults);
case 'dc':
case 'qdc':
return $this->filterQDCFields($defaults);
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap3/js/searchbox_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ VuFind.register('searchbox_controls', function SearchboxControls() {
if (triggerInputEvent) {
_textInput.dispatchEvent(new Event('input'));
}
_textInput.focus();
}

function _showKeyboard() {
Expand Down Expand Up @@ -154,6 +153,7 @@ VuFind.register('searchbox_controls', function SearchboxControls() {
if (_resetButton) {
_resetButton.addEventListener('click', function resetOnClick() {
_handleInputChange('');
_textInput.focus();
});
}

Expand Down
6 changes: 5 additions & 1 deletion themes/finna2/js/finna-fines.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ finna.fines = (function finnaFines() {
*/
function formatAmount(currency, template)
{
return template.replace('11', getWhole(currency)).replace('22', getFraction(currency));
// Prevent cases where whole with 22 or 122 gets overwritten with the fraction
return template.replace('11', '{whole}')
.replace('22', '{fraction}')
.replace('{whole}', getWhole(currency))
.replace('{fraction}', getFraction(currency));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
flex-wrap: wrap;
gap: 5px;
& dt {
font-weight: normal;
font-weight: bold;
padding: 5px 10px 5px 0;
&:not(:only-child):after {
content: ':';
Expand All @@ -14,6 +14,5 @@
border-radius: .5em;
background-color: #f4f4f4;
padding: 5px 10px;
text-transform: lowercase;
}
}
Loading

0 comments on commit c9c79bd

Please sign in to comment.