From 1d8ac48cc486ce78bf088c1a21944c3e86c9bccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Wed, 2 Oct 2024 13:12:56 +0300 Subject: [PATCH 01/16] Function for checking record or record's highest hierarchy format type. --- local/languages/finna/fi.ini | 1 + module/Finna/config/module.config.php | 2 + .../src/Finna/RecordDriver/SolrDefault.php | 14 +++++ .../Finna/RecordDriver/SolrDefaultFactory.php | 1 + .../Finna/src/Finna/RecordDriver/SolrEad3.php | 25 +++++++++ .../RecordTab/CollectionHierarchyTree.php | 6 +- .../src/Finna/RecordTab/CollectionList.php | 55 +++++++++++++++++++ .../src/Finna/RecordTab/HierarchyTree.php | 6 +- .../DefaultRecord/collection-record.phtml | 21 +++++++ 9 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 module/Finna/src/Finna/RecordTab/CollectionList.php create mode 100644 themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml diff --git a/local/languages/finna/fi.ini b/local/languages/finna/fi.ini index f2941650a8d..98cc79a0058 100644 --- a/local/languages/finna/fi.ini +++ b/local/languages/finna/fi.ini @@ -1232,6 +1232,7 @@ verification_email_sent = "Ohjeet sähköpostiosoitteen vahvistamiseksi on lähe verification_email_subject = "Sähköpostiosoitteen vahvistaminen" verification_email_url_pretext = "Voit vahvistaa uuden sähköpostiosoitteesi seuraavassa osoitteessa: <%%url%%>. Klikkaa linkkiä vain, jos olet lisäämässä tai vaihtamassa sähköpostiosoitettasi." View Book Bag = "Näytä kori" +View Full Archive = "Näytä koko arkisto" widen_prefix_info = "Tämä haku on kohdennettu tiettyyn kenttään." With the search you can find = "Haulla löydät" work_expressions_title = "Muut versiot" diff --git a/module/Finna/config/module.config.php b/module/Finna/config/module.config.php index a76b1d9701a..550736f0e6b 100644 --- a/module/Finna/config/module.config.php +++ b/module/Finna/config/module.config.php @@ -978,6 +978,7 @@ 'Finna\RecordTab\AuthorityRecordsAuthor' => 'Finna\RecordTab\AuthorityRecordsFactory', 'Finna\RecordTab\AuthorityRecordsTopic' => 'Finna\RecordTab\AuthorityRecordsFactory', 'Finna\RecordTab\CollectionHierarchyTree' => 'VuFind\RecordTab\CollectionHierarchyTreeFactory', + 'Finna\RecordTab\CollectionList' => 'VuFind\RecordTab\CollectionListFactory', 'Finna\RecordTab\HoldingsArchive' => 'Finna\RecordTab\Factory::getHoldingsArchive', 'Finna\RecordTab\HierarchyTree' => 'VuFind\RecordTab\HierarchyTreeFactory', 'Finna\RecordTab\Map' => 'Finna\RecordTab\Factory::getMap', @@ -994,6 +995,7 @@ // Overrides: 'VuFind\RecordTab\CollectionHierarchyTree' => 'Finna\RecordTab\CollectionHierarchyTree', + 'VuFind\RecordTab\CollectionList' => 'Finna\RecordTab\CollectionList', 'VuFind\RecordTab\HierarchyTree' => 'Finna\RecordTab\HierarchyTree', 'VuFind\RecordTab\Map' => 'Finna\RecordTab\Map', 'VuFind\RecordTab\UserComments' => 'Finna\RecordTab\UserComments', diff --git a/module/Finna/src/Finna/RecordDriver/SolrDefault.php b/module/Finna/src/Finna/RecordDriver/SolrDefault.php index 5fd2f28c4dd..8b97efc4fc8 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrDefault.php +++ b/module/Finna/src/Finna/RecordDriver/SolrDefault.php @@ -43,6 +43,8 @@ class SolrDefault extends \VuFind\RecordDriver\SolrDefault { use Feature\SolrFinnaTrait; + use Feature\ContainerFormatTrait; + use Feature\FinnaXmlReaderTrait; /** * Constructor @@ -75,4 +77,16 @@ public function getCollectionSearchId(): string } return $this->getUniqueID(); } + + /** + * Get record driver + * + * @param string $id Record id + * + * @return \VuFind\RecordDriver\AbstractBase + */ + public function getRecord($id): \VuFind\RecordDriver\AbstractBase + { + return $this->recordLoader->load($id, 'Solr'); + } } diff --git a/module/Finna/src/Finna/RecordDriver/SolrDefaultFactory.php b/module/Finna/src/Finna/RecordDriver/SolrDefaultFactory.php index eae986fc475..8e5cc283dd9 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrDefaultFactory.php +++ b/module/Finna/src/Finna/RecordDriver/SolrDefaultFactory.php @@ -79,6 +79,7 @@ public function __invoke( ); $driver->attachVideoHandler($container->get(\Finna\Video\Video::class)); $driver->attachLocaleSettings($container->get(\VuFind\I18n\Locale\LocaleSettings::class)); + $driver->attachRecordLoader($container->get(\Finna\Record\Loader::class)); return $driver; } } diff --git a/module/Finna/src/Finna/RecordDriver/SolrEad3.php b/module/Finna/src/Finna/RecordDriver/SolrEad3.php index 1530d6bada6..ae58fd2aec1 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrEad3.php +++ b/module/Finna/src/Finna/RecordDriver/SolrEad3.php @@ -172,6 +172,31 @@ class SolrEad3 extends SolrEad 'Kuva/Aukeama', ]; + /** + * Check if record is or is part of an archive + * + * @return bool + */ + public function isArchive(): bool + { + if ($topId = $this->getHierarchyTopID()[0]) { + if ($topId !== $this->getUniqueID()) { + $driver = $this->getRecord($topId); + return $driver->isArchive(); + } + } + $record = $this->getXmlRecord(); + foreach ($record->controlaccess->genreform->part ?? [] as $part) { + if (trim($part) === 'Arkisto') { + return true; + } + if (trim($part) === 'Kokoelma') { + return false; + } + } + return true; + } + /** * Get the institutions holding the record. * diff --git a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php index b34ee2d8fe9..026698871dc 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php @@ -47,7 +47,9 @@ class CollectionHierarchyTree extends \VuFind\RecordTab\CollectionHierarchyTree */ public function getDescription() { - return $this->getRecordDriver() instanceof \Finna\RecordDriver\SolrEad - ? 'hierarchy_tree_archive' : 'hierarchy_tree_collection'; + if ($this->driver->tryMethod('isArchive')) { + return 'hierarchy_tree_archive'; + } + return 'hierarchy_tree_collection'; } } diff --git a/module/Finna/src/Finna/RecordTab/CollectionList.php b/module/Finna/src/Finna/RecordTab/CollectionList.php new file mode 100644 index 00000000000..2770c889172 --- /dev/null +++ b/module/Finna/src/Finna/RecordTab/CollectionList.php @@ -0,0 +1,55 @@ + + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:plugins:record_tabs Wiki + */ + +namespace Finna\RecordTab; + +/** + * Collection list tab + * + * @category VuFind + * @package RecordTabs + * @author Demian Katz + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development:plugins:record_tabs Wiki + */ +class CollectionList extends \VuFind\RecordTab\CollectionList +{ + /** + * Get the on-screen description for this tab. + * + * @return string + */ + public function getDescription() + { + if ($this->driver->tryMethod('isArchive')) { + return 'Arkiston sisältö'; + } + return 'Collection Items'; + } +} diff --git a/module/Finna/src/Finna/RecordTab/HierarchyTree.php b/module/Finna/src/Finna/RecordTab/HierarchyTree.php index 1db0a30331c..1d7937b51df 100644 --- a/module/Finna/src/Finna/RecordTab/HierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/HierarchyTree.php @@ -47,7 +47,9 @@ class HierarchyTree extends \VuFind\RecordTab\HierarchyTree */ public function getDescription() { - return $this->getRecordDriver() instanceof \Finna\RecordDriver\SolrEad - ? 'hierarchy_tree_archive' : 'hierarchy_tree_collection'; + if ($this->driver->tryMethod('isArchive')) { + return 'hierarchy_tree_archive'; + } + return 'hierarchy_tree_collection'; } } diff --git a/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml b/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml new file mode 100644 index 00000000000..0a57f5144f7 --- /dev/null +++ b/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml @@ -0,0 +1,21 @@ +driver->isCollection()) { + $term = $this->driver->isArchive() ? 'Archive' : 'Collection'; + } else { + $term = 'Record'; + } +?> +

escapeHtml($this->driver->getShortTitle() . ' ' . $this->driver->getSubtitle() . ' ' . $this->driver->getTitleSection())?>

+ + transEsc('View Full ' . $term)?> + + +record($this->driver)->renderTemplate( + 'core-fields.phtml', + [ + 'driver' => $this->driver, + 'defaults' => 'collection-record', + ] + ); +?> From aaeccb49bb4b846f1c54bc1e6e96ae7edc5a834e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Tue, 12 Nov 2024 15:31:53 +0200 Subject: [PATCH 02/16] Changes to function fetching the items overall type information. --- .../src/Finna/RecordDriver/SolrDefault.php | 14 -------------- .../Finna/RecordDriver/SolrDefaultFactory.php | 1 - .../Finna/src/Finna/RecordDriver/SolrEad3.php | 17 +++-------------- 3 files changed, 3 insertions(+), 29 deletions(-) diff --git a/module/Finna/src/Finna/RecordDriver/SolrDefault.php b/module/Finna/src/Finna/RecordDriver/SolrDefault.php index 8b97efc4fc8..5fd2f28c4dd 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrDefault.php +++ b/module/Finna/src/Finna/RecordDriver/SolrDefault.php @@ -43,8 +43,6 @@ class SolrDefault extends \VuFind\RecordDriver\SolrDefault { use Feature\SolrFinnaTrait; - use Feature\ContainerFormatTrait; - use Feature\FinnaXmlReaderTrait; /** * Constructor @@ -77,16 +75,4 @@ public function getCollectionSearchId(): string } return $this->getUniqueID(); } - - /** - * Get record driver - * - * @param string $id Record id - * - * @return \VuFind\RecordDriver\AbstractBase - */ - public function getRecord($id): \VuFind\RecordDriver\AbstractBase - { - return $this->recordLoader->load($id, 'Solr'); - } } diff --git a/module/Finna/src/Finna/RecordDriver/SolrDefaultFactory.php b/module/Finna/src/Finna/RecordDriver/SolrDefaultFactory.php index 8e5cc283dd9..eae986fc475 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrDefaultFactory.php +++ b/module/Finna/src/Finna/RecordDriver/SolrDefaultFactory.php @@ -79,7 +79,6 @@ public function __invoke( ); $driver->attachVideoHandler($container->get(\Finna\Video\Video::class)); $driver->attachLocaleSettings($container->get(\VuFind\I18n\Locale\LocaleSettings::class)); - $driver->attachRecordLoader($container->get(\Finna\Record\Loader::class)); return $driver; } } diff --git a/module/Finna/src/Finna/RecordDriver/SolrEad3.php b/module/Finna/src/Finna/RecordDriver/SolrEad3.php index ae58fd2aec1..192fc833053 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrEad3.php +++ b/module/Finna/src/Finna/RecordDriver/SolrEad3.php @@ -179,20 +179,9 @@ class SolrEad3 extends SolrEad */ public function isArchive(): bool { - if ($topId = $this->getHierarchyTopID()[0]) { - if ($topId !== $this->getUniqueID()) { - $driver = $this->getRecord($topId); - return $driver->isArchive(); - } - } - $record = $this->getXmlRecord(); - foreach ($record->controlaccess->genreform->part ?? [] as $part) { - if (trim($part) === 'Arkisto') { - return true; - } - if (trim($part) === 'Kokoelma') { - return false; - } + $xml = $this->getXmlRecord(); + if ($xml->{'add-data'}->archive->attributes()->type === 'collection') { + return false; } return true; } From aca3c26422a9c7528fabfe1beae5d8a454d8b147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Wed, 11 Dec 2024 10:42:41 +0200 Subject: [PATCH 03/16] Change archive type function to return string and alter others accordingly. --- local/languages/finna/en-gb.ini | 2 ++ local/languages/finna/fi.ini | 2 ++ local/languages/finna/sv.ini | 2 ++ module/Finna/src/Finna/RecordDriver/SolrEad3.php | 10 +++++----- .../src/Finna/RecordTab/CollectionHierarchyTree.php | 6 +++--- module/Finna/src/Finna/RecordTab/CollectionList.php | 6 +++--- module/Finna/src/Finna/RecordTab/HierarchyTree.php | 6 +++--- .../templates/Recommend/CollectionSideFacets.phtml | 7 ++++++- .../RecordDriver/DefaultRecord/collection-record.phtml | 6 +++++- 9 files changed, 31 insertions(+), 16 deletions(-) diff --git a/local/languages/finna/en-gb.ini b/local/languages/finna/en-gb.ini index e305cbf2ee9..aa248f94c55 100644 --- a/local/languages/finna/en-gb.ini +++ b/local/languages/finna/en-gb.ini @@ -89,6 +89,7 @@ Appraisal = "Appraisal" Archive = "Archive" archive_authors = "Authors" Archive Citation = "Archive Citation" +Archive Content = "Archive Content" Archive File = "Archive Item" Archive Films = "Archive Material" Archive Origination = "Records Creator" @@ -396,6 +397,7 @@ Film Festivals = "Attended Film Festivals" Filming Date = "Filming date" Filming Location Notes = "Location notes" Filming Locations = "Locations" +Filter Archive = "Filter Archive" Filter Collection = "Filter collection" filter_by_geo_location = "Limit by map location" Filters = "Filters" diff --git a/local/languages/finna/fi.ini b/local/languages/finna/fi.ini index da916b2e40f..1646cb2f427 100644 --- a/local/languages/finna/fi.ini +++ b/local/languages/finna/fi.ini @@ -81,6 +81,7 @@ Appraisal = "Arvonmääritys" Archive = "Kuuluu arkistoon" archive_authors = "Tekijät" Archive Citation = "Arkistoviite" +Archive Content = "Arkiston sisältö" Archive File = "Kuuluu arkistoyksikköön" Archive Films = "Arkistoaineisto" Archive Origination = "Arkistonmuodostaja" @@ -385,6 +386,7 @@ field_info_other_language_alt_labels = "Kieliversiot" Field of Activity = "Toimiala" Filing Unit = "Säilytysyksikkö" Fill mandatory fields = "Täytä pakolliset tiedot" +Filter Archive = "Rajaa arkiston sisältöä" Filter Collection = "Rajaa kokoelman sisältöä" filter_by_geo_location = "Rajaa karttasijainnilla" Filters = "Rajaukset" diff --git a/local/languages/finna/sv.ini b/local/languages/finna/sv.ini index 448e9c330d0..898a5ee1097 100644 --- a/local/languages/finna/sv.ini +++ b/local/languages/finna/sv.ini @@ -83,6 +83,7 @@ Appraisal = "Informationsvärdering" Archive = "Arkiv" archive_authors = "Skapare" Archive Citation = "Arkivreferens" +Archive Content = "Arkivets innehåll" Archive File = "Arkivenhet" Archive Films = "Arkivmaterial" Archive Origination = "Arkivbildare" @@ -387,6 +388,7 @@ Film Festivals = "Deltagande i filmfestivaler" Filming Date = "Inspelningsdatum" Filming Location Notes = "Anmärkningar om inspelningsplatser" Filming Locations = "Inspelningsplatser" +Filter Archive = "Begränsä arkivet" Filter Collection = "Begränsa samlingen" filter_by_geo_location = "Begränsa med kartposition" Filters = "Begränsningar" diff --git a/module/Finna/src/Finna/RecordDriver/SolrEad3.php b/module/Finna/src/Finna/RecordDriver/SolrEad3.php index a04817ab12a..4d5bc8e32a8 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrEad3.php +++ b/module/Finna/src/Finna/RecordDriver/SolrEad3.php @@ -183,17 +183,17 @@ class SolrEad3 extends SolrEad ]; /** - * Check if record is or is part of an archive + * Get archive type * - * @return bool + * @return string */ - public function isArchive(): bool + public function getArchiveType(): string { $xml = $this->getXmlRecord(); if ($xml->{'add-data'}->archive->attributes()->type === 'collection') { - return false; + return 'collection'; } - return true; + return 'archive'; } /** diff --git a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php index 026698871dc..c6f50a1b314 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php @@ -47,9 +47,9 @@ class CollectionHierarchyTree extends \VuFind\RecordTab\CollectionHierarchyTree */ public function getDescription() { - if ($this->driver->tryMethod('isArchive')) { - return 'hierarchy_tree_archive'; + if ($this->driver instanceof \Finna\RecordDriver\SolrLido || $this->driver->tryMethod('getArchiveType') === 'collection') { + return 'hierarchy_tree_collection'; } - return 'hierarchy_tree_collection'; + return 'hierarchy_tree_archive'; } } diff --git a/module/Finna/src/Finna/RecordTab/CollectionList.php b/module/Finna/src/Finna/RecordTab/CollectionList.php index 2770c889172..a6a501070aa 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionList.php +++ b/module/Finna/src/Finna/RecordTab/CollectionList.php @@ -47,9 +47,9 @@ class CollectionList extends \VuFind\RecordTab\CollectionList */ public function getDescription() { - if ($this->driver->tryMethod('isArchive')) { - return 'Arkiston sisältö'; + if ($this->driver instanceof \Finna\RecordDriver\SolrLido || $this->driver->tryMethod('getArchiveType') === 'collection') { + return 'Collection Items'; } - return 'Collection Items'; + return 'Archive Content'; } } diff --git a/module/Finna/src/Finna/RecordTab/HierarchyTree.php b/module/Finna/src/Finna/RecordTab/HierarchyTree.php index 1d7937b51df..f283c6f8f5f 100644 --- a/module/Finna/src/Finna/RecordTab/HierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/HierarchyTree.php @@ -47,9 +47,9 @@ class HierarchyTree extends \VuFind\RecordTab\HierarchyTree */ public function getDescription() { - if ($this->driver->tryMethod('isArchive')) { - return 'hierarchy_tree_archive'; + if ($this->driver instanceof \Finna\RecordDriver\SolrLido || $this->driver->tryMethod('getArchiveType') === 'collection') { + return 'hierarchy_tree_collection'; } - return 'hierarchy_tree_collection'; + return 'hierarchy_tree_archive'; } } diff --git a/themes/finna2/templates/Recommend/CollectionSideFacets.phtml b/themes/finna2/templates/Recommend/CollectionSideFacets.phtml index 0d423f417dc..19b4be126ea 100644 --- a/themes/finna2/templates/Recommend/CollectionSideFacets.phtml +++ b/themes/finna2/templates/Recommend/CollectionSideFacets.phtml @@ -1,6 +1,11 @@ slot('side-facet-caption')->set('Filter Collection'); + if ($this->driver instanceof \Finna\RecordDriver\SolrLido || $this->driver->tryMethod('getArchiveType') === 'collection') { + $term = 'Filter Collection'; + } else { + $term = 'Filter Archive'; + } + $this->slot('side-facet-caption')->set($term); ?> baseUriExtra = $this->recommend->getResults()->getParams()->getCollectionId(); ?> render('Recommend/SideFacets.phtml')?> diff --git a/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml b/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml index 0a57f5144f7..a86c7cb1115 100644 --- a/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml +++ b/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml @@ -1,6 +1,10 @@ driver->isCollection()) { - $term = $this->driver->isArchive() ? 'Archive' : 'Collection'; + if ($this->driver instanceof \Finna\RecordDriver\SolrLido || $this->driver->tryMethod('getArchiveType') === 'collection') { + $term = 'Collection'; + } else { + $term = 'Archive'; + } } else { $term = 'Record'; } From 5293e5a9699a4250488c5324a8028c3b5f60400d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Wed, 11 Dec 2024 10:57:28 +0200 Subject: [PATCH 04/16] Line breaks. --- module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php | 5 ++++- module/Finna/src/Finna/RecordTab/CollectionList.php | 5 ++++- module/Finna/src/Finna/RecordTab/HierarchyTree.php | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php index c6f50a1b314..f56e36645b0 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php @@ -47,7 +47,10 @@ class CollectionHierarchyTree extends \VuFind\RecordTab\CollectionHierarchyTree */ public function getDescription() { - if ($this->driver instanceof \Finna\RecordDriver\SolrLido || $this->driver->tryMethod('getArchiveType') === 'collection') { + if ( + $this->driver instanceof \Finna\RecordDriver\SolrLido + || $this->driver->tryMethod('getArchiveType') === 'collection' + ) { return 'hierarchy_tree_collection'; } return 'hierarchy_tree_archive'; diff --git a/module/Finna/src/Finna/RecordTab/CollectionList.php b/module/Finna/src/Finna/RecordTab/CollectionList.php index a6a501070aa..e002b6eb11c 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionList.php +++ b/module/Finna/src/Finna/RecordTab/CollectionList.php @@ -47,7 +47,10 @@ class CollectionList extends \VuFind\RecordTab\CollectionList */ public function getDescription() { - if ($this->driver instanceof \Finna\RecordDriver\SolrLido || $this->driver->tryMethod('getArchiveType') === 'collection') { + if ( + $this->driver instanceof \Finna\RecordDriver\SolrLido + || $this->driver->tryMethod('getArchiveType') === 'collection' + ) { return 'Collection Items'; } return 'Archive Content'; diff --git a/module/Finna/src/Finna/RecordTab/HierarchyTree.php b/module/Finna/src/Finna/RecordTab/HierarchyTree.php index f283c6f8f5f..7bc586b9ace 100644 --- a/module/Finna/src/Finna/RecordTab/HierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/HierarchyTree.php @@ -47,7 +47,10 @@ class HierarchyTree extends \VuFind\RecordTab\HierarchyTree */ public function getDescription() { - if ($this->driver instanceof \Finna\RecordDriver\SolrLido || $this->driver->tryMethod('getArchiveType') === 'collection') { + if ( + $this->driver instanceof \Finna\RecordDriver\SolrLido + || $this->driver->tryMethod('getArchiveType') === 'collection' + ) { return 'hierarchy_tree_collection'; } return 'hierarchy_tree_archive'; From 13a5cdebd2ed2f361c73938655e4a412883d5bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Fri, 13 Dec 2024 17:12:41 +0200 Subject: [PATCH 05/16] Add the term checks to result templates and impacted record page fields. --- .../Finna/src/Finna/RecordDriver/SolrEad3.php | 17 +++++++++++- .../View/Helper/Root/RecordDataFormatter.php | 2 +- .../Root/RecordDataFormatterFactory.php | 26 ++++++++++++++++++- .../DefaultRecord/result-compact.phtml | 3 ++- .../RecordDriver/SolrEad/core-fields.phtml | 2 +- .../SolrEad/result-condensed.phtml | 10 ++++--- .../RecordDriver/SolrEad/result-list.phtml | 10 ++++--- themes/finna2/templates/collection/view.phtml | 2 +- 8 files changed, 60 insertions(+), 12 deletions(-) diff --git a/module/Finna/src/Finna/RecordDriver/SolrEad3.php b/module/Finna/src/Finna/RecordDriver/SolrEad3.php index 4d5bc8e32a8..ebbc3390800 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrEad3.php +++ b/module/Finna/src/Finna/RecordDriver/SolrEad3.php @@ -370,7 +370,7 @@ public function getOriginationExtended(): array $value = (string)$name; $localType = (string)$attr->localtype; $data = [ - 'id' => $id, 'name' => $value, 'detail' => $localType, + 'id' => $id, 'name' => $value, 'detail' => $localType, 'type' => $this->getArchiveType(), ]; if ($localType !== self::RELATOR_TIME_INTERVAL) { if ($nextEl = $names[$i + 1] ?? null) { @@ -1901,6 +1901,21 @@ public function getParentSeries(): array return $this->getHierarchyParents(); } + /** + * Get parent archives with type + * + * @return array + */ + public function getParentArchivesExtended(): array + { + $results = []; + $archives = parent::getParentArchives(); + foreach ($archives as $archive) { + $results[] = array_merge($archive, ['type' => $this->getArchiveType()]); + } + return $results; + } + /** * Get the hierarchy_parent_id(s) associated with this item (empty if none). * diff --git a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatter.php b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatter.php index bcc0213bf69..1a4cc9a9f7f 100644 --- a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatter.php +++ b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatter.php @@ -386,7 +386,7 @@ public function filterEAD3Fields($coreFields) 'Access Restrictions Extended', 'Additional Information Extended', 'Appraisal', - 'Archive', + 'Archive Extended', 'archive_authors', 'Archive File', 'Archive Origination', diff --git a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php index 0f89b28254c..c44fa52f5a3 100644 --- a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php +++ b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php @@ -404,7 +404,14 @@ protected function getDefaultCoreFields() 'getOriginationExtended', 'data-origination.phtml', [ - 'context' => ['class' => 'record-origination'], + 'context' => ['class' => 'record-origination',], + 'labelFunction' => function ($data) { + $label = isset($data[0]['type']) + && $data[0]['type'] === 'collection' + ? 'CreatorRoles::rda:collector' + : 'Archive Origination'; + return $label; + }, ] ); $setTemplateLine( @@ -415,6 +422,21 @@ protected function getDefaultCoreFields() 'context' => ['class' => 'recordHierarchyLinks'], ] ); + $setTemplateLine( + 'Archive Extended', + 'getParentArchivesExtended', + 'data-hierarchyLinks.phtml', + [ + 'context' => ['class' => 'recordHierarchyLinks'], + 'labelFunction' => function ($data) { + $label = isset($data[0]['type']) + && $data[0]['type'] === 'collection' + ? 'Parent Collection' + : 'Archive'; + return $label; + }, + ] + ); $setTemplateLine( 'Archive Series', 'getParentSeries', @@ -1651,6 +1673,8 @@ protected function getDefaultCoreFields() // Add arcrole-relations as multiple fields with role as field header $getRelations = function ($data, $options) { + var_dump($data); + //var_dump($options); // Group relations by role $relationsByRole = []; foreach ($data as $relation) { diff --git a/themes/finna2/templates/RecordDriver/DefaultRecord/result-compact.phtml b/themes/finna2/templates/RecordDriver/DefaultRecord/result-compact.phtml index 3e9ecc0c72e..d489100e61d 100644 --- a/themes/finna2/templates/RecordDriver/DefaultRecord/result-compact.phtml +++ b/themes/finna2/templates/RecordDriver/DefaultRecord/result-compact.phtml @@ -95,10 +95,11 @@ if (!empty($trees)): ?> $hierarchyTitle): ?> diff --git a/themes/finna2/templates/RecordDriver/SolrEad/core-fields.phtml b/themes/finna2/templates/RecordDriver/SolrEad/core-fields.phtml index 3ea395a129c..d8a8349169a 100644 --- a/themes/finna2/templates/RecordDriver/SolrEad/core-fields.phtml +++ b/themes/finna2/templates/RecordDriver/SolrEad/core-fields.phtml @@ -6,7 +6,7 @@ = ['access_restrictions_general']; $coreFieldGroups = $formatter->getGroupedData($this->driver, $formatter->getGroupedFields([ ['label' => 'Context', - 'lines' => ['Archive Origination', 'Archive', 'Archive Series', 'Archive File'], + 'lines' => ['Archive Origination', 'Archive', 'Archive Extended', 'Archive Series', 'Archive File'], ], [ 'lines' => ['Format', 'Unit ID', 'Unit IDs',], diff --git a/themes/finna2/templates/RecordDriver/SolrEad/result-condensed.phtml b/themes/finna2/templates/RecordDriver/SolrEad/result-condensed.phtml index b5a3a46c119..11e20ff105b 100644 --- a/themes/finna2/templates/RecordDriver/SolrEad/result-condensed.phtml +++ b/themes/finna2/templates/RecordDriver/SolrEad/result-condensed.phtml @@ -4,6 +4,7 @@ $img = $this->recordImage($this->record($this->driver)); $thumbnail = false; $thumbnailAlignment = $this->record($this->driver)->getThumbnailAlignment('result'); + $typeIsArchive = $this->driver->tryMethod('getArchiveType') !== 'collection'; if ($img): ob_start(); ?> render('list', ['small' => ['w' => 100, 'h' => 100], 'medium' => ['w' => 250, 'h' => 250]]) ?> @@ -53,11 +54,12 @@ if (!empty($trees)): ?> $hierarchyTitle): ?> @@ -79,7 +81,8 @@
driver->tryMethod('getOriginations', [], $this->driver->getOrigination())): $originations = (array)$originations; ?> - transEsc('Archive Origination')?>: + + transEsc($term)?>: $origination): ?> 0 ? ' ; ' : ''?>escapeHtml($origination)?> @@ -95,7 +98,8 @@ $topTitles = $this->driver->getHierarchyParentTitle(); ?> 0) : ?> - transEsc('Archive')?>: + + transEsc($term)?>: $parentId): ?> ">truncate($topTitles[$index], 180) : ''?> diff --git a/themes/finna2/templates/RecordDriver/SolrEad/result-list.phtml b/themes/finna2/templates/RecordDriver/SolrEad/result-list.phtml index 374286b6174..50eec522521 100644 --- a/themes/finna2/templates/RecordDriver/SolrEad/result-list.phtml +++ b/themes/finna2/templates/RecordDriver/SolrEad/result-list.phtml @@ -6,6 +6,7 @@ $thumbnailAlignment = $this->record($this->driver)->getThumbnailAlignment('result'); $recordLinker = $this->recordLinker($this->results); $coverDetails = $this->record($this->driver)->getCoverDetails('result-list', 'medium', $recordLinker->getUrl($this->driver)); + $typeIsArchive = $this->driver->tryMethod('getArchiveType') !== 'collection'; if ($img): ob_start(); ?> render('list', ['small' => ['w' => 100, 'h' => 100], 'medium' => ['w' => 250, 'h' => 250]]) ?> @@ -66,7 +67,8 @@ if ($img): translationEmpty('Archive Repository')): ?>transEsc('Archive Repository')?>: escapeHtml($this->organisationDisplayName($this->driver)) ?> driver->tryMethod('getOriginationExtended', [])): ?> -
transEsc('Archive Origination')?>: + +
transEsc($term)?>: $origination): ?> 0 ? ' ; ' : ''?> record($this->driver)->getLinkedFieldElement('author', $origination['name'], $origination, ['authorityType' => $origination['type'] ?? null, 'description' => false])?> @@ -82,7 +84,8 @@ if ($img): $topTitles = $this->driver->getHierarchyParentTitle(); ?> driver->isCollection()): ?> -
transEsc('Archive')?>: + +
transEsc($term)?>: $parentId): ?> ">truncate($topTitles[$index], 180) : ''?> @@ -135,11 +138,12 @@ if ($img): if (!empty($trees)): ?> $hierarchyTitle): ?> diff --git a/themes/finna2/templates/collection/view.phtml b/themes/finna2/templates/collection/view.phtml index 5284930fc62..efcee0af008 100644 --- a/themes/finna2/templates/collection/view.phtml +++ b/themes/finna2/templates/collection/view.phtml @@ -102,7 +102,7 @@ $coreFields = $formatter->getDefaults(); $coreFieldGroups = $formatter->getGroupedData($driver, $formatter->getGroupedFields([ ['label' => 'Context', - 'lines' => ['Archive Origination', 'Archive', 'Archive Series', 'Archive File'], + 'lines' => ['Archive Origination', 'Archive', 'Archive Extended', 'Archive Series', 'Archive File'], ], [ 'lines' => ['Format', 'Unit ID', 'Unit IDs'], From d806ad3b9b0a617258570c4688ac27b7362f7158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Fri, 13 Dec 2024 17:26:17 +0200 Subject: [PATCH 06/16] Removed printing. --- .../src/Finna/View/Helper/Root/RecordDataFormatterFactory.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php index c44fa52f5a3..6da57c2b2f9 100644 --- a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php +++ b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php @@ -1673,8 +1673,6 @@ protected function getDefaultCoreFields() // Add arcrole-relations as multiple fields with role as field header $getRelations = function ($data, $options) { - var_dump($data); - //var_dump($options); // Group relations by role $relationsByRole = []; foreach ($data as $relation) { From 62546150badf19f0bf16722fa01e8acd346c696e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Mon, 16 Dec 2024 15:45:14 +0200 Subject: [PATCH 07/16] Own type function for lido and other checks changed accordingly, capitalized collection, simplified label assign. --- local/languages/finna/en-gb.ini | 2 +- .../Finna/src/Finna/RecordDriver/SolrEad3.php | 23 ++++---------- .../Finna/src/Finna/RecordDriver/SolrLido.php | 10 +++++++ .../src/Finna/RecordTab/CollectionList.php | 7 ++--- .../src/Finna/RecordTab/HierarchyTree.php | 5 +--- .../View/Helper/Root/RecordDataFormatter.php | 2 +- .../Root/RecordDataFormatterFactory.php | 30 +++++++------------ .../Recommend/CollectionSideFacets.phtml | 6 +--- .../DefaultRecord/collection-record.phtml | 6 +--- .../RecordDriver/SolrEad/core-fields.phtml | 2 +- 10 files changed, 33 insertions(+), 60 deletions(-) diff --git a/local/languages/finna/en-gb.ini b/local/languages/finna/en-gb.ini index aa248f94c55..b2024f3932c 100644 --- a/local/languages/finna/en-gb.ini +++ b/local/languages/finna/en-gb.ini @@ -398,7 +398,7 @@ Filming Date = "Filming date" Filming Location Notes = "Location notes" Filming Locations = "Locations" Filter Archive = "Filter Archive" -Filter Collection = "Filter collection" +Filter Collection = "Filter Collection" filter_by_geo_location = "Limit by map location" Filters = "Filters" fine_type = "Type" diff --git a/module/Finna/src/Finna/RecordDriver/SolrEad3.php b/module/Finna/src/Finna/RecordDriver/SolrEad3.php index ebbc3390800..43c537a6611 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrEad3.php +++ b/module/Finna/src/Finna/RecordDriver/SolrEad3.php @@ -190,8 +190,10 @@ class SolrEad3 extends SolrEad public function getArchiveType(): string { $xml = $this->getXmlRecord(); - if ($xml->{'add-data'}->archive->attributes()->type === 'collection') { - return 'collection'; + if ($type = $xml->{'add-data'}->archive->attributes()->type) { + if ($type === 'collection') { + return 'collection'; + } } return 'archive'; } @@ -370,7 +372,7 @@ public function getOriginationExtended(): array $value = (string)$name; $localType = (string)$attr->localtype; $data = [ - 'id' => $id, 'name' => $value, 'detail' => $localType, 'type' => $this->getArchiveType(), + 'id' => $id, 'name' => $value, 'detail' => $localType, ]; if ($localType !== self::RELATOR_TIME_INTERVAL) { if ($nextEl = $names[$i + 1] ?? null) { @@ -1901,21 +1903,6 @@ public function getParentSeries(): array return $this->getHierarchyParents(); } - /** - * Get parent archives with type - * - * @return array - */ - public function getParentArchivesExtended(): array - { - $results = []; - $archives = parent::getParentArchives(); - foreach ($archives as $archive) { - $results[] = array_merge($archive, ['type' => $this->getArchiveType()]); - } - return $results; - } - /** * Get the hierarchy_parent_id(s) associated with this item (empty if none). * diff --git a/module/Finna/src/Finna/RecordDriver/SolrLido.php b/module/Finna/src/Finna/RecordDriver/SolrLido.php index b8febe0cc2a..a75ba20a229 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrLido.php +++ b/module/Finna/src/Finna/RecordDriver/SolrLido.php @@ -1221,6 +1221,16 @@ public function getCollections() return $this->getAllLanguageSpecificItems($results, $this->getLocale()); } + /** + * Get archive type + * + * @return string + */ + public function getArchiveType(): string + { + return 'collection'; + } + /** * Get an array of events for the record. * diff --git a/module/Finna/src/Finna/RecordTab/CollectionList.php b/module/Finna/src/Finna/RecordTab/CollectionList.php index e002b6eb11c..73f87d8500b 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionList.php +++ b/module/Finna/src/Finna/RecordTab/CollectionList.php @@ -5,7 +5,7 @@ * * PHP version 8 * - * Copyright (C) Villanova University 2010. + * Copyright (C) The National Library of Finland 2024. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, @@ -47,10 +47,7 @@ class CollectionList extends \VuFind\RecordTab\CollectionList */ public function getDescription() { - if ( - $this->driver instanceof \Finna\RecordDriver\SolrLido - || $this->driver->tryMethod('getArchiveType') === 'collection' - ) { + if ($this->driver->tryMethod('getArchiveType') === 'collection') { return 'Collection Items'; } return 'Archive Content'; diff --git a/module/Finna/src/Finna/RecordTab/HierarchyTree.php b/module/Finna/src/Finna/RecordTab/HierarchyTree.php index 7bc586b9ace..7b1bda426dc 100644 --- a/module/Finna/src/Finna/RecordTab/HierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/HierarchyTree.php @@ -47,10 +47,7 @@ class HierarchyTree extends \VuFind\RecordTab\HierarchyTree */ public function getDescription() { - if ( - $this->driver instanceof \Finna\RecordDriver\SolrLido - || $this->driver->tryMethod('getArchiveType') === 'collection' - ) { + if ($this->driver->tryMethod('getArchiveType') === 'collection') { return 'hierarchy_tree_collection'; } return 'hierarchy_tree_archive'; diff --git a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatter.php b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatter.php index 1a4cc9a9f7f..bcc0213bf69 100644 --- a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatter.php +++ b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatter.php @@ -386,7 +386,7 @@ public function filterEAD3Fields($coreFields) 'Access Restrictions Extended', 'Additional Information Extended', 'Appraisal', - 'Archive Extended', + 'Archive', 'archive_authors', 'Archive File', 'Archive Origination', diff --git a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php index 6da57c2b2f9..7cec0ec8c57 100644 --- a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php +++ b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php @@ -405,12 +405,11 @@ protected function getDefaultCoreFields() 'data-origination.phtml', [ 'context' => ['class' => 'record-origination',], - 'labelFunction' => function ($data) { - $label = isset($data[0]['type']) - && $data[0]['type'] === 'collection' - ? 'CreatorRoles::rda:collector' - : 'Archive Origination'; - return $label; + 'labelFunction' => function ($data, $driver) { + return match ($driver->tryMethod('getArchiveType')) { + 'collection' => 'CreatorRoles::rda:collector', + default => 'Archive Origination', + }; }, ] ); @@ -420,20 +419,11 @@ protected function getDefaultCoreFields() 'data-hierarchyLinks.phtml', [ 'context' => ['class' => 'recordHierarchyLinks'], - ] - ); - $setTemplateLine( - 'Archive Extended', - 'getParentArchivesExtended', - 'data-hierarchyLinks.phtml', - [ - 'context' => ['class' => 'recordHierarchyLinks'], - 'labelFunction' => function ($data) { - $label = isset($data[0]['type']) - && $data[0]['type'] === 'collection' - ? 'Parent Collection' - : 'Archive'; - return $label; + 'labelFunction' => function ($data, $driver) { + return match ($driver->tryMethod('getArchiveType')) { + 'collection' => 'Parent Collection', + default => 'Parent Archive', + }; }, ] ); diff --git a/themes/finna2/templates/Recommend/CollectionSideFacets.phtml b/themes/finna2/templates/Recommend/CollectionSideFacets.phtml index 19b4be126ea..1be7de1042f 100644 --- a/themes/finna2/templates/Recommend/CollectionSideFacets.phtml +++ b/themes/finna2/templates/Recommend/CollectionSideFacets.phtml @@ -1,10 +1,6 @@ driver instanceof \Finna\RecordDriver\SolrLido || $this->driver->tryMethod('getArchiveType') === 'collection') { - $term = 'Filter Collection'; - } else { - $term = 'Filter Archive'; - } + $term = $this->driver->tryMethod('getArchiveType') === 'collection' ? 'Filter Collection' : 'Filter Archive'; $this->slot('side-facet-caption')->set($term); ?> baseUriExtra = $this->recommend->getResults()->getParams()->getCollectionId(); ?> diff --git a/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml b/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml index a86c7cb1115..756df750e70 100644 --- a/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml +++ b/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml @@ -1,10 +1,6 @@ driver->isCollection()) { - if ($this->driver instanceof \Finna\RecordDriver\SolrLido || $this->driver->tryMethod('getArchiveType') === 'collection') { - $term = 'Collection'; - } else { - $term = 'Archive'; - } + $term = $this->driver->tryMethod('getArchiveType') === 'collection' ? 'Collection' : 'Archive'; } else { $term = 'Record'; } diff --git a/themes/finna2/templates/RecordDriver/SolrEad/core-fields.phtml b/themes/finna2/templates/RecordDriver/SolrEad/core-fields.phtml index d8a8349169a..3ea395a129c 100644 --- a/themes/finna2/templates/RecordDriver/SolrEad/core-fields.phtml +++ b/themes/finna2/templates/RecordDriver/SolrEad/core-fields.phtml @@ -6,7 +6,7 @@ = ['access_restrictions_general']; $coreFieldGroups = $formatter->getGroupedData($this->driver, $formatter->getGroupedFields([ ['label' => 'Context', - 'lines' => ['Archive Origination', 'Archive', 'Archive Extended', 'Archive Series', 'Archive File'], + 'lines' => ['Archive Origination', 'Archive', 'Archive Series', 'Archive File'], ], [ 'lines' => ['Format', 'Unit ID', 'Unit IDs',], From a9684c4808f1d9585a127b0b2707b1008563a31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Mon, 16 Dec 2024 15:53:50 +0200 Subject: [PATCH 08/16] Removed mention of non-existing thing. --- themes/finna2/templates/collection/view.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/finna2/templates/collection/view.phtml b/themes/finna2/templates/collection/view.phtml index efcee0af008..5284930fc62 100644 --- a/themes/finna2/templates/collection/view.phtml +++ b/themes/finna2/templates/collection/view.phtml @@ -102,7 +102,7 @@ $coreFields = $formatter->getDefaults(); $coreFieldGroups = $formatter->getGroupedData($driver, $formatter->getGroupedFields([ ['label' => 'Context', - 'lines' => ['Archive Origination', 'Archive', 'Archive Extended', 'Archive Series', 'Archive File'], + 'lines' => ['Archive Origination', 'Archive', 'Archive Series', 'Archive File'], ], [ 'lines' => ['Format', 'Unit ID', 'Unit IDs'], From df3226bd4229b8c6e60bbf46f808fff885422d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Mon, 16 Dec 2024 16:07:42 +0200 Subject: [PATCH 09/16] Removed unnecessary lido check. --- module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php index f56e36645b0..32dbd659768 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php @@ -47,10 +47,7 @@ class CollectionHierarchyTree extends \VuFind\RecordTab\CollectionHierarchyTree */ public function getDescription() { - if ( - $this->driver instanceof \Finna\RecordDriver\SolrLido - || $this->driver->tryMethod('getArchiveType') === 'collection' - ) { + if ($this->driver->tryMethod('getArchiveType') === 'collection') { return 'hierarchy_tree_collection'; } return 'hierarchy_tree_archive'; From 23047c04d80c403e2a60e5df51de0a15fa13bf34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Thu, 19 Dec 2024 20:37:16 +0200 Subject: [PATCH 10/16] Comparison as string. --- module/Finna/src/Finna/RecordDriver/SolrEad3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/Finna/src/Finna/RecordDriver/SolrEad3.php b/module/Finna/src/Finna/RecordDriver/SolrEad3.php index 43c537a6611..f65a9a6075d 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrEad3.php +++ b/module/Finna/src/Finna/RecordDriver/SolrEad3.php @@ -191,7 +191,7 @@ public function getArchiveType(): string { $xml = $this->getXmlRecord(); if ($type = $xml->{'add-data'}->archive->attributes()->type) { - if ($type === 'collection') { + if (trim((string)$type) === 'collection') { return 'collection'; } } From 2b494720cba0b9765c3be8e8f30e1bb769a4e98a Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Fri, 20 Dec 2024 11:09:03 +0200 Subject: [PATCH 11/16] Update module/Finna/src/Finna/RecordTab/CollectionList.php --- module/Finna/src/Finna/RecordTab/CollectionList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/Finna/src/Finna/RecordTab/CollectionList.php b/module/Finna/src/Finna/RecordTab/CollectionList.php index 98f06f24360..cb12d77224b 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionList.php +++ b/module/Finna/src/Finna/RecordTab/CollectionList.php @@ -39,7 +39,7 @@ * @link https://vufind.org/wiki/development:plugins:record_tabs Wiki */ class CollectionList extends \VuFind\RecordTab\CollectionList -{ +{ /** * Is this tab active? * Override to allow this tab to be displayed for records which are part of a collection. From dbac57e445d19b85bb66c6a575c6655486cbe44d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Fri, 20 Dec 2024 11:55:13 +0200 Subject: [PATCH 12/16] Removed unnecessary variables and structure as well as appointed them to more appropriate names. --- module/Finna/src/Finna/RecordTab/HierarchyTree.php | 6 ++---- .../View/Helper/Root/RecordDataFormatterFactory.php | 12 ++++-------- .../DefaultRecord/collection-record.phtml | 6 +++--- .../RecordDriver/DefaultRecord/result-compact.phtml | 4 ++-- .../RecordDriver/SolrEad/result-condensed.phtml | 10 ++++------ .../templates/RecordDriver/SolrEad/result-list.phtml | 10 ++++------ 6 files changed, 19 insertions(+), 29 deletions(-) diff --git a/module/Finna/src/Finna/RecordTab/HierarchyTree.php b/module/Finna/src/Finna/RecordTab/HierarchyTree.php index 7b1bda426dc..a35bef60e0c 100644 --- a/module/Finna/src/Finna/RecordTab/HierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/HierarchyTree.php @@ -47,9 +47,7 @@ class HierarchyTree extends \VuFind\RecordTab\HierarchyTree */ public function getDescription() { - if ($this->driver->tryMethod('getArchiveType') === 'collection') { - return 'hierarchy_tree_collection'; - } - return 'hierarchy_tree_archive'; + return $this->driver->tryMethod('getArchiveType') === 'collection' + ? 'hierarchy_tree_collection' : 'hierarchy_tree_archive'; } } diff --git a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php index 7cec0ec8c57..7478a96ae31 100644 --- a/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php +++ b/module/Finna/src/Finna/View/Helper/Root/RecordDataFormatterFactory.php @@ -406,10 +406,8 @@ protected function getDefaultCoreFields() [ 'context' => ['class' => 'record-origination',], 'labelFunction' => function ($data, $driver) { - return match ($driver->tryMethod('getArchiveType')) { - 'collection' => 'CreatorRoles::rda:collector', - default => 'Archive Origination', - }; + return $driver->tryMethod('getArchiveType') === 'collection' + ? 'CreatorRoles::rda:collector' : 'Archive Origination'; }, ] ); @@ -420,10 +418,8 @@ protected function getDefaultCoreFields() [ 'context' => ['class' => 'recordHierarchyLinks'], 'labelFunction' => function ($data, $driver) { - return match ($driver->tryMethod('getArchiveType')) { - 'collection' => 'Parent Collection', - default => 'Parent Archive', - }; + return $driver->tryMethod('getArchiveType') === 'collection' + ? 'Parent Collection' : 'Parent Archive'; }, ] ); diff --git a/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml b/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml index 756df750e70..fdc2721aa24 100644 --- a/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml +++ b/themes/finna2/templates/RecordDriver/DefaultRecord/collection-record.phtml @@ -1,13 +1,13 @@ driver->isCollection()) { - $term = $this->driver->tryMethod('getArchiveType') === 'collection' ? 'Collection' : 'Archive'; + $linkText = $this->driver->tryMethod('getArchiveType') === 'collection' ? 'View Full Collection' : 'View Full Archive'; } else { - $term = 'Record'; + $linkText = 'View Full Record'; } ?>

escapeHtml($this->driver->getShortTitle() . ' ' . $this->driver->getSubtitle() . ' ' . $this->driver->getTitleSection())?>

- transEsc('View Full ' . $term)?> + transEsc($linkText)?> $hierarchyTitle): ?> diff --git a/themes/finna2/templates/RecordDriver/SolrEad/result-condensed.phtml b/themes/finna2/templates/RecordDriver/SolrEad/result-condensed.phtml index 11e20ff105b..3e51582c66c 100644 --- a/themes/finna2/templates/RecordDriver/SolrEad/result-condensed.phtml +++ b/themes/finna2/templates/RecordDriver/SolrEad/result-condensed.phtml @@ -54,12 +54,12 @@ if (!empty($trees)): ?> $hierarchyTitle): ?> @@ -81,8 +81,7 @@
driver->tryMethod('getOriginations', [], $this->driver->getOrigination())): $originations = (array)$originations; ?> - - transEsc($term)?>: + transEsc($typeIsArchive ? 'Archive Origination' : 'CreatorRoles::rda:collector')?>: $origination): ?> 0 ? ' ; ' : ''?>escapeHtml($origination)?> @@ -98,8 +97,7 @@ $topTitles = $this->driver->getHierarchyParentTitle(); ?> 0) : ?> - - transEsc($term)?>: + transEsc($typeIsArchive ? 'Archive' : 'Parent Collection')?>: $parentId): ?> ">truncate($topTitles[$index], 180) : ''?> diff --git a/themes/finna2/templates/RecordDriver/SolrEad/result-list.phtml b/themes/finna2/templates/RecordDriver/SolrEad/result-list.phtml index 50eec522521..4ac561c3739 100644 --- a/themes/finna2/templates/RecordDriver/SolrEad/result-list.phtml +++ b/themes/finna2/templates/RecordDriver/SolrEad/result-list.phtml @@ -67,8 +67,7 @@ if ($img): translationEmpty('Archive Repository')): ?>transEsc('Archive Repository')?>: escapeHtml($this->organisationDisplayName($this->driver)) ?> driver->tryMethod('getOriginationExtended', [])): ?> - -
transEsc($term)?>: +
transEsc($typeIsArchive ? 'Archive Origination' : 'CreatorRoles::rda:collector')?>: $origination): ?> 0 ? ' ; ' : ''?> record($this->driver)->getLinkedFieldElement('author', $origination['name'], $origination, ['authorityType' => $origination['type'] ?? null, 'description' => false])?> @@ -84,8 +83,7 @@ if ($img): $topTitles = $this->driver->getHierarchyParentTitle(); ?> driver->isCollection()): ?> - -
transEsc($term)?>: +
transEsc($typeIsArchive ? 'Archive' : 'Parent Collection')?>: $parentId): ?> ">truncate($topTitles[$index], 180) : ''?> @@ -138,12 +136,12 @@ if ($img): if (!empty($trees)): ?> $hierarchyTitle): ?> From 77ee08e2732ff3c8a1f4b22cbdee5cb0cd0ce32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Fri, 20 Dec 2024 12:00:30 +0200 Subject: [PATCH 13/16] Shorten the returns for tab names. --- module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php | 5 +---- module/Finna/src/Finna/RecordTab/CollectionList.php | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php index 32dbd659768..094074bc8f1 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php @@ -47,9 +47,6 @@ class CollectionHierarchyTree extends \VuFind\RecordTab\CollectionHierarchyTree */ public function getDescription() { - if ($this->driver->tryMethod('getArchiveType') === 'collection') { - return 'hierarchy_tree_collection'; - } - return 'hierarchy_tree_archive'; + return $this->driver->tryMethod('getArchiveType') === 'collection' ? 'hierarchy_tree_collection' : 'hierarchy_tree_archive'; } } diff --git a/module/Finna/src/Finna/RecordTab/CollectionList.php b/module/Finna/src/Finna/RecordTab/CollectionList.php index cb12d77224b..c4ee14f8b22 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionList.php +++ b/module/Finna/src/Finna/RecordTab/CollectionList.php @@ -59,9 +59,6 @@ public function isActive() */ public function getDescription() { - if ($this->driver->tryMethod('getArchiveType') === 'collection') { - return 'Collection Items'; - } - return 'Archive Content'; + return $this->driver->tryMethod('getArchiveType') === 'collection' ? 'Collection Items' : 'Archive Content'; } } From f981044345a99cf37946bb80f4c21ef4540512dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Fri, 20 Dec 2024 12:06:26 +0200 Subject: [PATCH 14/16] Line breaks added. --- module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php | 3 ++- module/Finna/src/Finna/RecordTab/CollectionList.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php index 094074bc8f1..15ae7adfd9a 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php +++ b/module/Finna/src/Finna/RecordTab/CollectionHierarchyTree.php @@ -47,6 +47,7 @@ class CollectionHierarchyTree extends \VuFind\RecordTab\CollectionHierarchyTree */ public function getDescription() { - return $this->driver->tryMethod('getArchiveType') === 'collection' ? 'hierarchy_tree_collection' : 'hierarchy_tree_archive'; + return $this->driver->tryMethod('getArchiveType') === 'collection' + ? 'hierarchy_tree_collection' : 'hierarchy_tree_archive'; } } diff --git a/module/Finna/src/Finna/RecordTab/CollectionList.php b/module/Finna/src/Finna/RecordTab/CollectionList.php index c4ee14f8b22..5044d791596 100644 --- a/module/Finna/src/Finna/RecordTab/CollectionList.php +++ b/module/Finna/src/Finna/RecordTab/CollectionList.php @@ -59,6 +59,7 @@ public function isActive() */ public function getDescription() { - return $this->driver->tryMethod('getArchiveType') === 'collection' ? 'Collection Items' : 'Archive Content'; + return $this->driver->tryMethod('getArchiveType') === 'collection' + ? 'Collection Items' : 'Archive Content'; } } From 8ddc92132b924c354922859798f6b83301153b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Fri, 20 Dec 2024 12:10:45 +0200 Subject: [PATCH 15/16] Variable is clearer for a title. --- themes/finna2/templates/Recommend/CollectionSideFacets.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/finna2/templates/Recommend/CollectionSideFacets.phtml b/themes/finna2/templates/Recommend/CollectionSideFacets.phtml index 1be7de1042f..df1654a1fca 100644 --- a/themes/finna2/templates/Recommend/CollectionSideFacets.phtml +++ b/themes/finna2/templates/Recommend/CollectionSideFacets.phtml @@ -1,7 +1,7 @@ driver->tryMethod('getArchiveType') === 'collection' ? 'Filter Collection' : 'Filter Archive'; - $this->slot('side-facet-caption')->set($term); + $title = $this->driver->tryMethod('getArchiveType') === 'collection' ? 'Filter Collection' : 'Filter Archive'; + $this->slot('side-facet-caption')->set($title); ?> baseUriExtra = $this->recommend->getResults()->getParams()->getCollectionId(); ?> render('Recommend/SideFacets.phtml')?> From 466c748e7930bb44afcdae5e87985b5bb74d3fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Siiri=20Yl=C3=B6nen?= Date: Fri, 20 Dec 2024 13:04:44 +0200 Subject: [PATCH 16/16] Backup. --- module/Finna/src/Finna/RecordDriver/SolrEad3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/Finna/src/Finna/RecordDriver/SolrEad3.php b/module/Finna/src/Finna/RecordDriver/SolrEad3.php index f65a9a6075d..e590b813ce0 100644 --- a/module/Finna/src/Finna/RecordDriver/SolrEad3.php +++ b/module/Finna/src/Finna/RecordDriver/SolrEad3.php @@ -190,7 +190,7 @@ class SolrEad3 extends SolrEad public function getArchiveType(): string { $xml = $this->getXmlRecord(); - if ($type = $xml->{'add-data'}->archive->attributes()->type) { + if ($type = $xml->{'add-data'}->archive->attributes()->type ?? '') { if (trim((string)$type) === 'collection') { return 'collection'; }