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-558
  • Loading branch information
tmikkonen committed Apr 12, 2024
2 parents 2d23d7d + 0244467 commit fb363dd
Show file tree
Hide file tree
Showing 29 changed files with 331 additions and 254 deletions.
3 changes: 3 additions & 0 deletions config/vufind/SierraRest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ client_secret = "very_secret"
; 6
; - patron authentication with global patron data access using a method other
; than "native"
; Innovative recommends using the latest available API version for best performance,
; but please note that any backward-incompatible changes in the API may require code
; adjustments.
;api_version = 6
; Statistic group to use e.g. when renewing loans or placing holds (requires Sierra
; 6.0 or later and API version set to 6 or later above):
Expand Down
3 changes: 2 additions & 1 deletion local/languages/finna/en-gb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ Limit to Open Libraries = "Limit to Open Libraries"
Limits = "Limits"
Link to full results = "Link to full results"
Link to video = "Link to video"
link_external_sketchfab.com = "Open in Sketchfab"
linked_event_homepage = "Event homepage"
linked_event_related_events = "Related events"
linked_event_search = "Find"
Expand Down Expand Up @@ -1327,7 +1328,7 @@ tooltip_tabs_pci_html = ""
tooltip_tabs_summon_html = ""
tooltip_facet_html = ""
tooltip_blended_search_html = "<h4>Search from all collections</h4><p>Search using title, author, subject or other keywords related to your topic of interest. You can use <strong>Finnish</strong> or <strong>English</strong> keywords.<p>Keyword truncating is possible with * (asterisk), for example neuro*.</p><p->Search terms can be combined with boolean operators <strong>AND, OR, NOT</strong>.</p><p>For exact search use quotation marks around your keyword.</p>"
tooltip_local_search_html = "<h4>Search from library/museum/archive collections</h4><p>Search using title, author, subject or other keywords related to your topic of interest. You can use <strong>Finnish</strong> or <strong>English</strong> keywords.<p>Keyword truncating is possible with * (asterisk), for example neuro*.</p><p>Search terms can be combined with boolean operators <strong>AND, OR, NOT</strong>.</p><p>For exact search use quotation marks around your keyword.</p>"
tooltip_local_search_html = "<h4>Search from library/museum/archive collections</h4><p>Search using title, author, subject or other keywords related to your topic of interest. </p><p>The search finds different forms of Finnish-language search terms. Words in other languages can be truncated with an asterisk, for example, neuro*.</p><p>Search terms can be combined with Boolean operators <strong>AND, OR or NOT</strong>.</p><p>For exact search use quotation marks around your keyword.</p><p><a href='/Content/help-basic'>Read more about search techniques.</a></p>"
tooltip_eds_search_html = ""
tooltip_pci_search_html = ""
tooltip_summon_search_html = ""
Expand Down
3 changes: 2 additions & 1 deletion local/languages/finna/fi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ Limit to Open Libraries = "Vain avoimet kirjastot"
Limits = "Rajaukset"
Link to full results = "Linkki koko tulokseen"
Link to video = "Linkki videoon"
link_external_sketchfab.com = "Avaa Sketchfabissa"
linked_event_homepage = "Tapahtuman verkkosivu"
linked_event_related_events = "Liittyvät tapahtumat"
linked_event_search = "Hae"
Expand Down Expand Up @@ -1316,7 +1317,7 @@ tooltip_tabs_summon_html = "<h4>Kansainväliset e-aineistot</h4><p>Kansainvälis
tooltip_facet_html = "<h4>Rajaa hakua</h4><p>Rajaa hakua tarkemmaksi esimerkiksi saatavuuden, toimialan, organisaation tai aineistotyypin perusteella.</p><p>Rajausvaihtoehdot vaihtelevat hakuvälilehden ja hakusanan antamien tuloksien mukaan.</p><p>Voit rajata useamman vaihtoehdon kerralla sekä poistaa tekemiäsi rajauksia.</p>"
tooltip_blended_search_html = "<h4>Haku kaikista kokoelmista</h4><p>Kirjoita hakukenttään teoksen nimi, tekijä, aihe tai muita asiaan liittyviä hakusanoja.</p><p>Katkaise hakusana tähdellä *, esim. kasvatustie*. </p><p>Yhdistä hakusanat Boolen operaattoreilla AND, OR ja NOT. </p><p>Tarkan fraasihaun voit tehdä kirjoittamalla hakusanat lainausmerkkeihin.</p><p>Haun jälkeen käytettävissä on lisää rajaustyökaluja.</p>"
tooltip_eds_search_html = "<h4>Haku kansainvälisistä aineistoista</h4><p>Kirjoita hakukenttään teoksen nimi, tekijä, aihe tai muita asiaan liittyviä hakusanoja. Käytä hakukielenä suomea tai englantia. </p><p>Katkaise hakusana tähdellä *, esim. kasvatustie*. </p><p>Yhdistä hakusanat Boolen operaattoreilla AND tai OR. </p><p>Tarkan fraasihaun voit tehdä kirjoittamalla hakusanat lainausmerkkeihin.</p><p>Haun jälkeen käytettävissä on lisää rajaustyökaluja.</p>"
tooltip_local_search_html = "<h4>Haku kirjaston/museon/arkiston kokoelmista</h4><p>Kirjoita hakukenttään teoksen nimi, tekijä, aihe tai muita asiaan liittyviä hakusanoja.</p><p>Katkaise hakusana tähdellä *, esim. kasvatustie*. </p><p>Yhdistä hakusanat Boolen operaattoreilla AND, OR ja NOT. </p><p>Tarkan fraasihaun voit tehdä kirjoittamalla hakusanat lainausmerkkeihin.</p><p>Haun jälkeen käytettävissä on lisää rajaustyökaluja.</p>"
tooltip_local_search_html = "<h4>Haku kirjaston/museon/arkiston kokoelmista</h4><p>Kirjoita hakukenttään teoksen nimi, tekijä, aihe tai muita asiaan liittyviä hakusanoja.</p><p>Haku löytää suomenkielisten hakusanojen eri muodot. Muunkieliset sanat voit katkaista tähdellä, esimerkiksi neuro*.</p><p>Yhdistä hakusanat Boolen operaattoreilla <strong>AND, OR ja NOT</strong>.</p><p>Tarkan fraasihaun voit tehdä kirjoittamalla hakusanat lainausmerkkeihin.</p><p><a href='/Content/help-basic'>Lisää ohjeita hakuun</a></p>"
tooltip_pci_search_html = "<h4>Haku kansainvälisistä aineistoista</h4><p>Kirjoita hakukenttään teoksen nimi, tekijä, aihe tai muita asiaan liittyviä hakusanoja. Käytä hakukielenä suomea tai englantia. </p><p>Katkaise hakusana tähdellä *, esim. kasvatustie*. </p><p>Yhdistä hakusanat Boolen operaattoreilla AND tai OR. </p><p>Tarkan fraasihaun voit tehdä kirjoittamalla hakusanat lainausmerkkeihin.</p><p>Haun jälkeen käytettävissä on lisää rajaustyökaluja.</p>"
tooltip_R2_search_html = ""
tooltip_summon_search_html = "<h4>Haku kansainvälisistä aineistoista</h4><p>Kirjoita hakukenttään teoksen nimi, tekijä, aihe tai muita asiaan liittyviä hakusanoja. Käytä hakukielenä suomea tai englantia. </p><p>Katkaise hakusana tähdellä *, esim. kasvatustie*. </p><p>Yhdistä hakusanat Boolen operaattoreilla AND tai OR. </p><p>Tarkan fraasihaun voit tehdä kirjoittamalla hakusanat lainausmerkkeihin.</p><p>Haun jälkeen käytettävissä on lisää rajaustyökaluja.</p>"
Expand Down
3 changes: 2 additions & 1 deletion local/languages/finna/sv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ Limit to Open Libraries = "Endast öppna bibliotek"
Limits = "Begränsningar"
Link to full results = "Länk till hela resultatet"
Link to video = "Länk till video"
link_external_sketchfab.com = "Öppna i Sketchfab"
linked_event_homepage = "Evenemangs hemsida"
linked_event_related_events = "Relaterat evenemang"
linked_event_search = "Sök"
Expand Down Expand Up @@ -1310,7 +1311,7 @@ tooltip_tabs_summon_html = ""
tooltip_facet_html = ""
tooltip_blended_search_html = ""
tooltip_eds_search_html = ""
tooltip_local_search_html = ""
tooltip_local_search_html = "<h4>Sök i bibliotekets/museets/arkivets samlingar</h4><p>Skriv verkets namn, upphovsman, ämne eller andra relaterade sökord i sökrutan.<p>Sökningen hittar de olika formerna av finska sökord. Ord på andra språk kan du trunkera med en asterisk, till exempel neuro*.</p><p>Kombinera sökord med de Booleska operatorerna <strong>AND, OR och NOT</strong>.</p><p>Du kan söka med en exakt fras genom att använda sökord inom citattecken.</p><p><a href='/Content/help-basic'>Läs mera om sökteknik</a></p>"
tooltip_pci_search_html = ""
tooltip_summon_search_html = ""
tooltip_myaccount_html = "<h4>Mitt konto</h4><p>Hantera dina användaruppgifter och bibliotekskort på undersidorna Min profil och Bibliotekskort.</p><p>Dina lån, reserveringar och eventuella betalningar finns på separata undersidor.</p><p>Favoriter som du valt samt dina senaste och sparade sökningar kan redigeras på undersidorna Favoriter och Sparade sökningar.</p>"
Expand Down
32 changes: 6 additions & 26 deletions module/Finna/src/Finna/ILS/Driver/SierraRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ public function getPickUpLocations($patron = false, $holdDetails = null)
[
'limit' => 10000,
'offset' => 0,
'fields' => 'code,name',
'language' => $this->getTranslatorLocale(),
],
'GET',
Expand Down Expand Up @@ -380,8 +379,7 @@ public function getMyProfile($patron)
$result = $this->makeRequest(
[$this->apiBase, 'patrons', $patron['id']],
[
'fields' => 'names,emails,phones,addresses,birthDate,expirationDate'
. ',message,homeLibraryCode,fixedFields',
'fields' => 'default,names,emails,phones,addresses,message,homeLibraryCode,fixedFields',
],
'GET',
$patron
Expand Down Expand Up @@ -615,8 +613,7 @@ public function getMyFines($patron)
[$this->apiBase, 'patrons', $patron['id'], 'fines'],
[
'limit' => 10000,
'fields' => 'item,assessedDate,description,chargeType,itemCharge'
. ',processingFee,billingFee,paidAmount,location,invoiceNumber',
'fields' => 'default,invoiceNumber',
],
'GET',
$patron
Expand Down Expand Up @@ -1110,14 +1107,7 @@ protected function getItemStatusesForBib(string $id, bool $checkHoldings, ?array
}
}

$fields = [
'location',
'status',
'barcode',
'callNumber',
'fixedFields',
'varFields',
];
$fields = ['default', 'fixedFields', 'varFields'];
$statuses = [];
$sort = 0;
// Fetch hold count for items if needed:
Expand Down Expand Up @@ -1618,19 +1608,9 @@ protected function getIMMSAuthToken(array $config): string
*/
protected function getItemBarcode(string $itemId, array $patron): string
{
// Get item barcode using same request as elsewhere for cacheability
$item = $this->makeRequest(
[$this->apiBase, 'items', $itemId],
['fields' => 'bibIds,varFields'],
'GET',
$patron
);
foreach ($item['varFields'] ?? [] as $field) {
if ('b' === $field['fieldTag']) {
return $field['content'];
}
}
return '';
$items = $this->getItemRecords([$itemId], null, $patron);
$item = reset($items);
return $item['barcode'] ?? '';
}

/**
Expand Down
22 changes: 22 additions & 0 deletions module/Finna/src/Finna/RecordDriver/Feature/SolrFinnaTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -1321,4 +1321,26 @@ protected function addVersionsFilters(\VuFindSearch\ParamBag $paramBag)
);
}
}

/**
* Parse an URL safely. Checks if the URL contains http or https for parse_url to work properly
*
* @param string $url The URL to parse.
* @param int $component Specify one of PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT,
* PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT
* to retrieve just a specific URL component as a string (except when PHP_URL_PORT is given,
* in which case the return value will be an int).
*
* @return int|string|array
*/
protected function safeParseUrl(string $url, int $component = -1): int|string|array
{
if (!$url) {
return [];
}
if (!preg_match('/^https?:/', $url)) {
$url = '//' . $url;
}
return parse_url($url, $component);
}
}
4 changes: 2 additions & 2 deletions module/Finna/src/Finna/RecordDriver/SolrEad3.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ class SolrEad3 extends SolrEad

// unitid is shown when label-attribute is missing or is one of:
public const UNIT_IDS = [
'Tekninen', 'Analoginen', 'Vanha analoginen', 'Vanha tekninen',
'Diaarinumero', 'Asiaryhmän numero',
'Tekninen', 'Analoginen', 'Vanha analoginen', 'Diaarinumero',
'Asiaryhmän numero', 'Arkistotunnus',
];

// If any of these values are found in ocr image title, do not place
Expand Down
66 changes: 49 additions & 17 deletions module/Finna/src/Finna/RecordDriver/SolrLido.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

namespace Finna\RecordDriver;

use VuFind\I18n\TranslatableString;

use function boolval;
use function call_user_func_array;
use function count;
Expand Down Expand Up @@ -212,6 +214,11 @@ class SolrLido extends \VuFind\RecordDriver\SolrDefault implements \Laminas\Log\
*/
protected $excludedSubjectTypes = ['aihe', 'iconclass'];

/**
* Array of types for linkResources to be displayed as external URL
*/
protected $displayExternalLinks = ['provided_3D'];

/**
* Events used for author information.
*
Expand Down Expand Up @@ -556,7 +563,32 @@ protected function getRepresentations(string $language): array
?? reset($foundDescriptions);
}
}

// Representation is a document or wanted to be displayed also as an document
if (
in_array($type, $documentTypeKeys)
|| ($displayAsLink = in_array($type, $this->displayExternalLinks))
) {
$documentDesc = $description;
if ($displayAsLink ??= false && !$documentDesc) {
$host = $this->safeParseUrl($url, PHP_URL_HOST);
$documentDesc = new TranslatableString(
"external_$host",
$host
);
}
$documentRights = $this->getResourceRights($resourceSet, $language, false);
if (
$document = $this->getDocument(
$url,
$format,
$documentDesc,
$documentRights,
$displayAsLink
)
) {
$documentUrls = array_merge($documentUrls, $document);
}
}
// Representation is an image
if (in_array($type, $imageTypeKeys)) {
$image = $this->getImage(
Expand Down Expand Up @@ -604,13 +636,6 @@ protected function getRepresentations(string $language): array
}
continue;
}
// Representation is a document
if (in_array($type, $documentTypeKeys)) {
$documentRights = $this->getResourceRights($resourceSet, $language, false);
if ($document = $this->getDocument($url, $format, $description, $documentRights)) {
$documentUrls = array_merge($documentUrls, $document);
}
}
}
// Save all the found results here as a new object
// If current set has no links, continue to next one
Expand Down Expand Up @@ -775,9 +800,8 @@ protected function getModel(
): array {
$type = $this->modelTypes[$type];
$format = strtolower($format);
if ('preview' === $type && !in_array($format, $this->displayableModelFormats)) {
// If we can not display the file, then tag it as a provided 3D model
$type = 'provided';
if ('preview' !== $type || !in_array($format, $this->displayableModelFormats)) {
return [];
}
return [
'url' => $url,
Expand Down Expand Up @@ -914,24 +938,32 @@ protected function getVideo(
/**
* Function to return document in associative array
*
* @param string $url Url of the document
* @param string $format Format of the document
* @param string $description Description of the document
* @param array $rights Array of document rights
* @param string $url Url of the document
* @param string $format Format of the document
* @param string $description Description of the document
* @param array $rights Array of document rights
* @param bool $displayAsLink Display the document as a link, default is false
*
* @return array
*/
protected function getDocument(
string $url,
string $format,
string $description,
array $rights
array $rights,
bool $displayAsLink = false
): array {
$format = strtolower($format);
// Do not display text/html mediatype
if ('text/html' === $format) {
$format = '';
}
return [
'description' => $description ?: false,
'url' => $url,
'format' => strtolower($format),
'format' => $format,
'rights' => $rights,
'displayAsLink' => $displayAsLink,
];
}

Expand Down
3 changes: 3 additions & 0 deletions module/Finna/tests/fixtures/lido/lido_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@
<resourceRepresentation type="preview_3D">
<linkResource formatResource="glb">https://glbmalli.glb</linkResource>
</resourceRepresentation>
<resourceRepresentation type="provided_3D">
<linkResource formatResource="text/html">https://sketchfab.com/test</linkResource>
</resourceRepresentation>
<rightsResource>
<rightsType>
<conceptID type="copyright">InC</conceptID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,25 @@ public static function getRepresentationsData(): array
'getDocuments',
[
0 => [
'description' => 'external_sketchfab.com',
'url' => 'https://sketchfab.com/test',
'format' => '',
'rights' => [
'copyright' => 'InC',
'description' => [
0 => 'Tässä on mallien copyright.',
],
],
'displayAsLink' => true,
],
1 => [
'description' => 'PDFTesti.pdf',
'url' => 'https://linkkiPDF.fi',
'format' => 'pdf',
'rights' => [],
'displayAsLink' => false,
],
1 => [
2 => [
'description' => 'DocxTesti.docx',
'url' => 'https://linkkiDocx.fi',
'format' => 'docx',
Expand All @@ -233,6 +246,7 @@ public static function getRepresentationsData(): array
0 => 'Tekstitiedoston tarkempi käyttöoikeuskuvaus',
],
],
'displayAsLink' => false,
],
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public function onDispatch(\Laminas\Mvc\MvcEvent $event)
if ('development' == APPLICATION_ENV) {
$this->flashMessenger()->addErrorMessage($exception->getMessage());
}
return $this->ilsExceptionResponse ?? $this->createViewModel();
$actionResponse = $this->ilsExceptionResponse ?? $this->createViewModel();
$event->setResult($actionResponse);
return $actionResponse;
}
}
}
7 changes: 7 additions & 0 deletions module/VuFind/src/VuFind/Controller/HoldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ public function listAction()
*/
public function editAction()
{
$this->ilsExceptionResponse = $this->createViewModel(
[
'selectedIDS' => [],
'fields' => [],
]
);

// Stop now if the user does not have valid catalog credentials available:
if (!is_array($patron = $this->catalogLogin())) {
return $patron;
Expand Down
Loading

0 comments on commit fb363dd

Please sign in to comment.