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/module/finc/config/module.config.php b/module/finc/config/module.config.php index 515cee83dffde153dc95b8c1f5e2ee32ed7a3658..f071ee477657b4d7746a8413e786e16023a94d62 100644 --- a/module/finc/config/module.config.php +++ b/module/finc/config/module.config.php @@ -16,10 +16,16 @@ $config = [ 'finc\Cover\Loader' => 'VuFind\Cover\LoaderFactory', 'finc\Cover\Router' => 'finc\Cover\RouterFactory', ], + 'aliases' => [ + 'MvcTranslator' => 'Zend\Mvc\I18n\Translator', + ], 'delegators' => [ 'VuFindSearch\Service' => [ 'finc\Service\MungerInjectionDelegatorFactory', ], + 'Zend\Mvc\I18n\Translator' => [ + 'finc\I18n\Translator\ZendI18nResourcesInjector', + ], ], 'aliases' => [ 'VuFind\Cache\Manager' => 'finc\Cache\Manager', @@ -46,6 +52,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 +65,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/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..1a23302e1b3c07eb7eaee4dbc733f5a95b79b06f --- /dev/null +++ b/module/finc/src/finc/I18n/Translator/ZendI18nResourcesInjector.php @@ -0,0 +1,49 @@ +<?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