diff --git a/composer.local.0.finc.json b/composer.local.0.finc.json index 87f48624f598df40c8c23365e728c7e1970d3b7c..4bc3bf8c419127ef97648a6a49be4b036b869eb8 100644 --- a/composer.local.0.finc.json +++ b/composer.local.0.finc.json @@ -5,7 +5,8 @@ "require": { "finc/rules-evaluator": "0.0.3", "sabre/vobject": "3.5.3", - "symfony/filesystem": "^3.4" + "symfony/filesystem": "^3.4", + "zendframework/zend-i18n-resources": "^2.6" }, "scripts": { "post-install-cmd": ["@copy-themes-force", "@dump-modules"], diff --git a/composer.lock b/composer.lock index ce5272ed6a99472982ff7ea3f6c5d6ec2a5eccec..f5fa8831d4cb01c3ee2695daa232bcdfff8b57c4 100644 --- a/composer.lock +++ b/composer.lock @@ -6506,6 +6506,7 @@ "rbac", "zf2" ], + "abandoned": true, "time": "2017-05-07T08:45:27+00:00" }, { diff --git a/module/finc/config/module.config.php b/module/finc/config/module.config.php index 515cee83dffde153dc95b8c1f5e2ee32ed7a3658..319b82072a07f2dcb357d1db33b3f2192a2bca09 100644 --- a/module/finc/config/module.config.php +++ b/module/finc/config/module.config.php @@ -20,8 +20,12 @@ $config = [ 'VuFindSearch\Service' => [ 'finc\Service\MungerInjectionDelegatorFactory', ], + 'Zend\Mvc\I18n\Translator' => [ + 'finc\I18n\Translator\ZendI18nResourcesInjector', + ], ], 'aliases' => [ + 'MvcTranslator' => 'Zend\Mvc\I18n\Translator', 'VuFind\Cache\Manager' => 'finc\Cache\Manager', 'VuFind\ILS\Connection' => 'finc\ILS\Connection', 'VuFind\ILS\Logic\Holds' => 'finc\ILS\Logic\Holds', @@ -46,6 +50,7 @@ $config = [ 'VuFind\Controller\MyResearchController' => 'finc\Controller\MyResearchController', 'VuFind\Controller\RecordController' => 'finc\Controller\RecordController', 'VuFind\Controller\RecordsController' => 'finc\Controller\RecordsController', + 'VuFind\Controller\AjaxController' => 'finc\Controller\AjaxController', ], ], 'controller_plugins' => [ @@ -58,6 +63,14 @@ $config = [ 'newItems' => 'finc\Controller\Plugin\NewItems' ] ], + 'view_helpers' => [ + 'aliases' => [ + 'formLabel' => 'finc\Form\View\Helper\FormLabel', + ], + 'factories' => [ + 'finc\Form\View\Helper\FormLabel' => 'Zend\ServiceManager\Factory\InvokableFactory', + ], + ], 'vufind' => [ 'plugin_managers' => [ 'ajaxhandler' => [ diff --git a/module/finc/src/finc/Controller/AmslResourceController.php b/module/finc/src/finc/Controller/AmslResourceController.php index 07348329e9d5ef9032901c435e1b8022978416b5..af1e7d03d53b2fc9d84e89ed79afe50eea096e3e 100644 --- a/module/finc/src/finc/Controller/AmslResourceController.php +++ b/module/finc/src/finc/Controller/AmslResourceController.php @@ -111,8 +111,9 @@ class AmslResourceController extends AbstractBase // Make view $view = $this->createViewModel(); $view->setTemplate('amsl/sources-list'); + $cacheKey = "rendered-{$this->layout()->userLang}"; - if ($data = $this->getCacheData('rendered')) { + if ($data = $this->getCacheData($cacheKey)) { $view->rendered_html = $data; } else { try { @@ -124,7 +125,7 @@ class AmslResourceController extends AbstractBase ); } $rendered = $this->getViewRenderer()->render($view); - $this->setCacheData($rendered, 'rendered'); + $this->setCacheData($rendered, $cacheKey); $view->rendered_html = $rendered; } diff --git a/module/finc/src/finc/Form/View/Helper/FormLabel.php b/module/finc/src/finc/Form/View/Helper/FormLabel.php new file mode 100644 index 0000000000000000000000000000000000000000..058f46dd7589b53e46ed5fb18b2b61d34f722247 --- /dev/null +++ b/module/finc/src/finc/Form/View/Helper/FormLabel.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright (C) 2020 Leipzig University Library + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + */ + +namespace finc\Form\View\Helper; + +use Zend\Form\Element; +use Zend\Form\View\Helper\FormLabel as Base; + +class FormLabel extends Base +{ + public function openTag($element = null) + { + if ($element instanceof Element) { + $element->setLabelAttributes( + [ + 'data-type' => $element->getAttribute('type'), + 'data-name' => $element->getAttribute('name'), + 'data-required' => $element->getAttribute('required') + ? 'true' : 'false' + ] + $element->getLabelAttributes() + ); + } + return parent::openTag($element); + } +} \ No newline at end of file diff --git a/module/finc/src/finc/I18n/Translator/ZendI18nResourcesInjector.php b/module/finc/src/finc/I18n/Translator/ZendI18nResourcesInjector.php new file mode 100644 index 0000000000000000000000000000000000000000..f9b7b898402f45706a9343c74ce416c1781888b9 --- /dev/null +++ b/module/finc/src/finc/I18n/Translator/ZendI18nResourcesInjector.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright (C) 2020 Leipzig University Library + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + */ +namespace finc\I18n\Translator; + +use Psr\Container\ContainerInterface; +use Zend\I18n\Translator\Resources; + +class ZendI18nResourcesInjector +{ + public function __invoke( + ContainerInterface $container, + $name, + callable $callback + ) { + $translator = call_user_func($callback); + + $translator->addTranslationFilePattern( + 'phpArray', + Resources::getBasePath(), + Resources::getPatternForValidator() + ); + $translator->addTranslationFilePattern( + 'phpArray', + Resources::getBasePath(), + Resources::getPatternForCaptcha() + ); + return $translator; + } +} \ No newline at end of file diff --git a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php index 219103baabbb5f9ef8d371f230536b27db727561..84838f47913e106156487e6a4de4131fe8c965f8 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php @@ -808,7 +808,7 @@ trait SolrMarcFincTrait $this->getLocalMarcFieldOfLibrary() ); if (!$fields) { - return null; + return []; } foreach ($fields as $key => $field) { if ($q = $field->getSubfield('q')) { @@ -1707,34 +1707,91 @@ trait SolrMarcFincTrait */ public function getAllSubjectHeadingsExtended() { - // define a false indicator - $firstindicator = 'x'; $retval = []; $fields = $this->getMarcRecord()->getFields('689'); foreach ($fields as $field) { - $subjectrow = $field->getIndicator('1'); - if ($subjectrow != $firstindicator) { - $key = (isset($key) ? $key + 1 : 0); - $firstindicator = $subjectrow; + $key = $field->getIndicator('1'); + $order = $field->getIndicator('2'); + if ("" === trim($order)) { + if ($subfield = $field->getSubfield('5')) { + $retval[$key]['source'] = $subfield->getData(); + } + foreach ($field->getSubfields() as $sf) { + $sf->getData(); + } } - // #5668 #5046 BSZ MARC may contain uppercase subfields but solrmarc set - // to lowercase them which introduces single char topics if ($subfields = $field->getSubfields('a')) { foreach ($subfields as $subfield) { if (strlen($subfield->getData()) > 1) { - $retval[$key]['subject'][] = $subfield->getData(); + $retval[$key]['subject'][$order] = $subfield->getData(); } } } if ($subfield = $field->getSubfield('t')) { - $retval[$key]['subject'][] = $subfield->getData(); + $retval[$key]['subject'][$order] = $subfield->getData(); } if ($subfield = $field->getSubfield('9')) { $retval[$key]['subsubject'] = $subfield->getData(); } } - return $retval; + if (empty($retval)) { + return $this->getTopicsField(); + } + foreach ([ + 'DE-627', //KXP + 'DE-576', //GBV + 'DE-101' //DNB + ] as $source) { + $return = []; + foreach ($retval as $entry) { + if (isset($entry['source']) && strpos($entry['source'],$source) !== false) { + $return[] = $entry; + } + } + if (!empty($return)) { + return $return; + } + } + return $retval; + } + + public function getTopicsField() + { + $retval = []; + + $fields = $this->getMarcRecord()->getFields('650'); + foreach ($fields as $field) { + $thesaurus = $field->getIndicator('2'); + if ($subfields = $field->getSubfields('a')) { + foreach ($subfields as $subfield) { + if (strlen($subfield->getData()) > 1) { + $retval[$thesaurus][]['subject'][] = $subfield->getData(); + } + } + } + } + + if (empty($retval)) { + return []; + } + + foreach ([ + '7', //'Source specified in subfield $2' + '4', //'Source not specified' + '0', //'Library of Congress Subject Headings' + '2', //'Medical Subject Headings' + ] as $thesaurus) { + if (isset($retval[$thesaurus])) { + return array_map( + 'unserialize', + array_unique( + array_map('serialize',$retval[$thesaurus]) + ) + ); + } + } + return current($retval); } /**