From 2ca4f2b8d89b1feea9a2abe23e71fface3098c2d Mon Sep 17 00:00:00 2001 From: Robert Lange <robert.lange@uni-leipzig.de> Date: Wed, 15 Dec 2021 11:22:46 +0100 Subject: [PATCH] refs #21064 [fid] fix code style * devops info: ** run "./install-codestylechecker.sh install" to install dependencies for git hooks code style checks ** see https://projekte.ub.uni-leipzig.de/projects/finc-intern/wiki/Code-Quality-Checking_mit_PHPStorm#section-5 for integration of CS Fixer validation in PHPStorm * $HOME/bin/codestylechecker/php-cs-fixer3 fix --config=$HOME/bin/codestylechecker/vufind.php-cs-fixer.php_cs module/fid/src/ * add missing class and method comments * move view helper classes to correct directory * run codesniffer-beautifier for modules and templates co-authored by: Dorian Merz <merz@ub.uni-leipzig.de> co-authored by: Alexander Purr <purr@ub.uni-leipzig.de> --- module/fid/config/module.config.php | 3 +- .../fid/src/AjaxHandler/GetResolverLinks.php | 36 +- .../AjaxHandler/GetResolverLinksFactory.php | 3 +- .../CustomTraits/FidAcquisitionTrait.php | 179 +++++++-- .../src/Controller/MyResearchController.php | 46 ++- .../MyResearchControllerFactory.php | 30 +- .../fid/src/Controller/RecordController.php | 12 +- .../RecordControllerDelegatorFactory.php | 57 ++- module/fid/src/Controller/UserController.php | 362 ++++++++++++------ .../src/Controller/UserControllerFactory.php | 27 +- .../fid/src/FormModel/PasswordChangeModel.php | 59 ++- .../fid/src/FormModel/PasswordResetModel.php | 47 ++- module/fid/src/FormModel/UserDeleteModel.php | 58 ++- .../fid/src/FormModel/UsernameChangeModel.php | 59 ++- module/fid/src/Helper/TranslatorDelegator.php | 29 +- module/fid/src/Hydrator/OrderHydrator.php | 81 +++- .../Hydrator/OrderMissingRecordHydrator.php | 58 ++- .../fid/src/Hydrator/OrderUpdateHydrator.php | 62 ++- .../Hydrator/Strategy/UserDataStrategy.php | 51 ++- module/fid/src/Hydrator/UserHydrator.php | 28 +- .../Hydrator/UserHydratorDelegatorFactory.php | 34 +- .../InputFilter/RootAwareBaseInputFilter.php | 27 +- .../InputFilter/UserCreateFormInputFilter.php | 31 +- .../fid/src/Listener/ClientConfigListener.php | 53 ++- module/fid/src/Listener/ErrorListener.php | 36 +- module/fid/src/Listener/LocaleListener.php | 39 +- module/fid/src/RecordTab/Worldcat.php | 10 +- .../src/Role/PermissionProvider/Factory.php | 2 - .../PermissionProvider/FidApiPermission.php | 11 +- .../OrderCreationRequestUserNormalizer.php | 44 ++- module/fid/src/Service/Client.php | 336 ++++++++++------ module/fid/src/Service/ClientException.php | 20 +- module/fid/src/Service/ClientFactory.php | 58 +-- .../Service/DataTransferObject/Address.php | 118 +++++- .../Service/DataTransferObject/Library.php | 106 +++-- .../src/Service/DataTransferObject/Logon.php | 94 +++-- .../src/Service/DataTransferObject/Order.php | 124 +++++- .../src/Service/DataTransferObject/Record.php | 46 ++- .../src/Service/DataTransferObject/User.php | 216 +++++++++-- .../Service/UserAuthorizationException.php | 20 +- .../Service/UserNotAuthorizedException.php | 20 +- .../src/Service/UserNotLoggedinException.php | 20 +- .../Validator/SubitoPartialCopyPageBounds.php | 35 +- .../Validator/SubitoPartialCopyPageOrder.php | 33 +- ...bitoPartialCopyPageRangeValidatorTrait.php | 37 +- .../SubitoPartialCopyPageSelection.php | 39 +- module/fid/src/View/Helper/Root/Factory.php | 2 - .../Helper/Root}/FormLabel.php | 33 +- module/fid/src/View/Helper/Root/GetIt.php | 66 +++- .../Root/RecordDataFormatterFactory.php | 16 +- .../Helper/Root}/SearchTabs.php | 9 +- .../fid/src/View/Helper/Root/UserGroups.php | 50 ++- module/fid/src/VuFind/Auth/Authenticator.php | 59 ++- .../src/VuFind/Auth/AuthenticatorFactory.php | 29 +- .../fid/src/VuFind/Auth/ILSAuthenticator.php | 29 +- .../VuFind/Auth/ILSAuthenticatorFactory.php | 33 +- module/fid/src/VuFind/Db/Row/User.php | 47 ++- .../VuFind/Db/Row/UserDelegatorFactory.php | 32 +- module/fid/src/VuFind/ILS/Fid.php | 73 +++- module/fid/src/VuFind/ILS/FidFactory.php | 29 +- module/fid/src/VuFind/Resolver/Driver/Ezb.php | 64 +++- .../Resolver/Driver/EzbDelegatorFactory.php | 34 +- themes/fid/templates/Helpers/openurl.phtml | 14 +- .../templates/ajax/resolverLinks-button.phtml | 2 +- .../templates/ajax/resolverLinks-print.phtml | 12 +- themes/fid/templates/ajax/resolverLinks.phtml | 14 +- .../fid/templates/fid/admin/list-entry.phtml | 6 +- themes/fid/templates/fid/admin/list.phtml | 6 +- .../fid/order/order-edit-missing-record.phtml | 5 +- .../fid/templates/fid/order/order-edit.phtml | 6 +- .../acquisition-digitization-fields.phtml | 22 +- .../fid/record/acquisition-digitization.phtml | 5 +- .../fid/record/acquisition-pda.phtml | 2 +- .../record/acquisition-subito-article.phtml | 2 +- .../acquisition-subito-partial-copy.phtml | 4 +- .../fid/user/orders/additionals-data.phtml | 9 +- themes/fid/templates/fid/user/policy.phtml | 15 +- themes/fid/templates/fid/user/terms.phtml | 17 +- themes/fid/templates/footer.phtml | 12 +- .../myresearch/menu-additional-entries.phtml | 8 +- themes/fid/templates/myresearch/menu.phtml | 20 +- themes/fid/templates/myresearch/profile.phtml | 20 +- themes/fid/theme.config.php | 32 +- 83 files changed, 2908 insertions(+), 826 deletions(-) rename module/fid/src/{Helper => View/Helper/Root}/FormLabel.php (61%) rename module/fid/src/{Helper => View/Helper/Root}/SearchTabs.php (92%) diff --git a/module/fid/config/module.config.php b/module/fid/config/module.config.php index e6e6be49fbc..a27e4a9b799 100644 --- a/module/fid/config/module.config.php +++ b/module/fid/config/module.config.php @@ -18,6 +18,7 @@ * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ + use fid\Controller\MyResearchController; use fid\Controller\MyResearchControllerFactory; use fid\Controller\RecordController; @@ -30,7 +31,6 @@ use fid\FormModel\PasswordChangeModel; use fid\FormModel\PasswordResetModel; use fid\FormModel\UserDeleteModel; use fid\FormModel\UsernameChangeModel; -use fid\Helper\FormLabel; use fid\Helper\TranslatorDelegator; use fid\Hydrator\OrderHydrator; use fid\Hydrator\UserHydrator; @@ -41,6 +41,7 @@ use fid\Listener\LocaleListener; use fid\Serializer\OrderCreationRequestUserNormalizer; use fid\Service\Client; use fid\Service\ClientFactory; +use fid\View\Helper\Root\FormLabel; use fid\VuFind\Auth\Authenticator; use fid\VuFind\Auth\AuthenticatorFactory; use fid\VuFind\Auth\ILSAuthenticator; diff --git a/module/fid/src/AjaxHandler/GetResolverLinks.php b/module/fid/src/AjaxHandler/GetResolverLinks.php index ba15d1a8b85..810640b01e9 100644 --- a/module/fid/src/AjaxHandler/GetResolverLinks.php +++ b/module/fid/src/AjaxHandler/GetResolverLinks.php @@ -68,8 +68,8 @@ class GetResolverLinks extends \VuFind\AjaxHandler\GetResolverLinks * @param SessionSettings $ss Session settings * @param ResolverManager $pm Resolver driver plugin manager * @param RendererInterface $renderer View renderer - * @param Config $config Top-level VuFind configuration (config.ini) - * @param Config $resolver Top-level VuFind configuration (Resolver.ini) + * @param Config $config Top-level VuFind config (config.ini) + * @param Config $resolver Top-level VuFind config (Resolver.ini) */ public function __construct( SessionSettings $ss, @@ -107,7 +107,8 @@ class GetResolverLinks extends \VuFind\AjaxHandler\GetResolverLinks if (in_array($requestedResolver, $resolvers) && isset($this->resolverConfig->$requestedResolver) ) { - $resolverType = $this->resolverConfig->$requestedResolver->resolver ?? 'generic'; + $resolverType = $this->resolverConfig + ->$requestedResolver->resolver ?? 'generic'; if (!$this->pluginManager->has($resolverType)) { return $this->formatResponse( $this->translate("Could not load driver for $resolverType"), @@ -163,8 +164,8 @@ class GetResolverLinks extends \VuFind\AjaxHandler\GetResolverLinks if (isset($this->resolverConfig->$requestedResolver) && isset($this->resolverConfig->$requestedResolver->url) ) { - // Trim off any parameters (for legacy compatibility -- default config - // used to include extraneous parameters): + // Trim off any parameters for legacy compatibility + // default config used to include extraneous parameters): [$base] = explode( '?', $this->resolverConfig->$requestedResolver->url @@ -178,9 +179,13 @@ class GetResolverLinks extends \VuFind\AjaxHandler\GetResolverLinks // Render the links using the view: $view = [ - 'openUrlBase' => $base, 'openUrl' => $openUrl, - 'electronic' => $electronic, 'unknown' => $unknown, 'services' => $services, - 'searchClassId' => $searchClassId, 'resolver' => $requestedResolver, + 'openUrlBase' => $base, + 'openUrl' => $openUrl, + 'electronic' => $electronic, + 'unknown' => $unknown, + 'services' => $services, + 'searchClassId' => $searchClassId, + 'resolver' => $requestedResolver, 'moreOptionsLink' => $moreOptionsLink ]; $viewPrint = [ @@ -193,9 +198,18 @@ class GetResolverLinks extends \VuFind\AjaxHandler\GetResolverLinks ]; } - $html = $this->renderer->render("ajax/resolverLinks.phtml", $view); - $print = $this->renderer->render("ajax/resolverLinks-print.phtml", $viewPrint); - $button = $this->renderer->render("ajax/resolverLinks-button.phtml", $viewButton); + $html = $this->renderer->render( + "ajax/resolverLinks.phtml", + $view + ); + $print = $this->renderer->render( + "ajax/resolverLinks-print.phtml", + $viewPrint + ); + $button = $this->renderer->render( + "ajax/resolverLinks-button.phtml", + $viewButton + ); // output HTML encoded in JSON object return $this->formatResponse(compact('html', 'print', 'button')); diff --git a/module/fid/src/AjaxHandler/GetResolverLinksFactory.php b/module/fid/src/AjaxHandler/GetResolverLinksFactory.php index 870129b2f15..c7bd3c3561d 100644 --- a/module/fid/src/AjaxHandler/GetResolverLinksFactory.php +++ b/module/fid/src/AjaxHandler/GetResolverLinksFactory.php @@ -30,6 +30,7 @@ namespace fid\AjaxHandler; use Interop\Container\ContainerInterface; +use Zend\ServiceManager\Factory\FactoryInterface; /** * Factory for GetResolverLinks AJAX handler. @@ -41,7 +42,7 @@ use Interop\Container\ContainerInterface; * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development Wiki */ -class GetResolverLinksFactory implements \Zend\ServiceManager\Factory\FactoryInterface +class GetResolverLinksFactory implements FactoryInterface { /** * Create an object diff --git a/module/fid/src/Controller/CustomTraits/FidAcquisitionTrait.php b/module/fid/src/Controller/CustomTraits/FidAcquisitionTrait.php index 3afd09184d9..ab62f853238 100644 --- a/module/fid/src/Controller/CustomTraits/FidAcquisitionTrait.php +++ b/module/fid/src/Controller/CustomTraits/FidAcquisitionTrait.php @@ -20,10 +20,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category VuFind FID + * @category VuFind * @package Controller * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Controller\CustomTraits; @@ -43,40 +44,72 @@ use Zend\Form\Form; * * @category VuFind * @package Controller + * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License - * @link http://finc.info Main Site + * @link https://vufind.org/wiki/development Wiki */ trait FidAcquisitionTrait { /** + * Instance of fidis client + * * @var Client */ protected $client; + /** + * Type of acquisition + * + * @var string + */ protected $type; + /** + * ZendForm form configuration assigned in module.config.php + * + * @var string + */ protected $formConfig = "fid-acquisition-form"; /** - * @param Client $client + * Setting fidis client + * + * @param Client $client fidis client + * + * @return void */ public function setClient(Client $client): void { $this->client = $client; } + /** + * PDA / direct delivery route action + * + * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel + */ public function fidPdaAction() { $this->type = self::PDA; return $this->runAcquisition(); } + /** + * Subito article route action + * + * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel + */ public function fidSubitoArticleAction() { $this->type = self::SUBITO_ARTICLE; return $this->runAcquisition(); } + /** + * Subito partial copy route action + * + * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel + */ public function fidSubitoPartialCopyAction() { $this->type = self::SUBITO_PARTIAL_COPY; @@ -84,6 +117,11 @@ trait FidAcquisitionTrait return $this->runAcquisition(); } + /** + * Normal digitization-on-demand route action + * + * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel + */ public function fidDigitizationAction() { $this->type = self::DIGITIZATION; @@ -91,6 +129,11 @@ trait FidAcquisitionTrait return $this->runAcquisition(); } + /** + * Open / free digitization-on-demand route action + * + * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel + */ public function fidDigitizationMissingRecordAction() { $this->type = self::DIGITIZATION; @@ -98,19 +141,26 @@ trait FidAcquisitionTrait return $this->runDigitizationMissingRecord(); } + /** + * Main logic for handling acquisitions. + * The method can be used only if the order set is stored in Solr. + * + * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel + * @throws \fid\Service\ClientException + * @throws \fid\Service\UserNotAuthorizedException + */ protected function runAcquisition() { if (!($user = $this->getUser())) { return $this->forceLogin(); } - /** - * @var User $user - */ - $user = $this->client->requestUserDetails(); + /* var User $user */ + $user = $this->client->requestUserUpdate(); try { - /* pass if permission is granted, else throw exception and switch to catch block */ + /* pass if permission is granted, + * else throw exception and switch to catch block */ $this->permission()->check('fid.Acquisitions', 'exception'); $driver = $this->loadRecord(); @@ -119,9 +169,7 @@ trait FidAcquisitionTrait //store current url in session for multi-step form (edit address) $this->followup()->store(); - /** - * @var Form $form - */ + /* @var Form $form */ $form = $this->serviceLocator->get($this->formConfig); $this->addOptinalFormValidators($form); @@ -133,9 +181,17 @@ trait FidAcquisitionTrait $label = $this->getOrderLabel($driver); $type = $this->type; $status = $this->getDefaultStatus(); - $hydratorData = compact('type', 'driver', 'user', 'url', 'label', 'status'); + $hydratorData = compact( + 'type', + 'driver', + 'user', + 'url', + 'label', + 'status' + ); $hydratorData += $this->addTypeSpecificOrderInformation($form); - $form->getHydrator()->hydrate($hydratorData, $order = new Order()); + $form->getHydrator() + ->hydrate($hydratorData, $order = new Order()); $this->client->requestOrderCreation($order); $this->client->requestUserDetails(null, true); $message = $this->translate('fid::acquisition_success'); @@ -149,7 +205,8 @@ trait FidAcquisitionTrait } $typeWithoutHyphens = preg_replace("/[^a-zA-Z]+/", "", $this->type); - $action = $this->url()->fromRoute("record-fid$typeWithoutHyphens", ['id' => $recordId]); + $action = $this->url() + ->fromRoute("record-fid$typeWithoutHyphens", ['id' => $recordId]); $form->setAttribute('action', $action); $form->prepare(); @@ -163,20 +220,31 @@ trait FidAcquisitionTrait return $view; } + /** + * Build record url + * + * @param $recordId record ID + * + * @return string record url + */ protected function getRecordUrl($recordId) { - return $this->url()->fromRoute('record', ['id' => $recordId], ['force_canonical' => true]); + return $this->url() + ->fromRoute('record', ['id' => $recordId], ['force_canonical' => true]); } + /** + * Compose citation if citation format is supported, else return record title + * + * @return string citation | title + */ protected function getRecordCitation() { $driver = $this->loadRecord(); - /** - * @var Citation $helper - */ + /* @var Citation $helper */ $helper = $this->getViewRenderer()->plugin('citation'); $helper->__invoke($driver); - $priorityFormats = [ 'APA', 'MLA', 'ISBD' ]; + $priorityFormats = ['APA', 'MLA', 'ISBD']; $existingFormats = $driver->getCitationFormats(); $formats = array_intersect($priorityFormats, $existingFormats); if (!empty($formats)) { @@ -186,11 +254,21 @@ trait FidAcquisitionTrait } } + /** + * Use record title as label + * + * @return string label + */ protected function getOrderLabel() { return $this->loadRecord()->tryMethod('getTitle'); } + /** + * Set up permission denied view + * + * @return \Zend\View\Model\ViewModel + */ protected function getPermissionDeniedView() { $view = AbstractBase::createViewModel(); @@ -199,6 +277,14 @@ trait FidAcquisitionTrait return $view; } + /** + * Append acquisition type specific field validators + * For subito partial copy append validation for page selection + * + * @param \VuFind\Form\Form $form formular + * + * @return void + */ protected function addOptinalFormValidators($form) { if ($this->type == self::SUBITO_PARTIAL_COPY) { @@ -210,12 +296,21 @@ trait FidAcquisitionTrait true ); $form->getInputFilter()->get('pages')->getValidatorChain()->attach( - new SubitoPartialCopyPageSelection(['numberPages' => $recordPages]) + new SubitoPartialCopyPageSelection( + ['numberPages' => $recordPages] + ) ); } } } + /** + * Collect type specific order information coming from addional form field + * + * @param \VuFind\Form\Form $form formular + * + * @return array|array[] + */ protected function addTypeSpecificOrderInformation($form) { $data = []; @@ -252,15 +347,27 @@ trait FidAcquisitionTrait return $data; } + /** + * Hooking function for handeling validators + * and error messages FID instance specific by overriding + * + * @param \VuFind\Form\Form $form formular + * + * @return void + */ protected function handleOptionalErrorMessages($form) { } + /** + * Load default aquisition status. + * Default status can be configured by each qcuisituon type. + * + * @return null|string + */ protected function getDefaultStatus() { - /** - * @var Config $config - */ + /* @var Config $config */ $config = $this->getConfig('fid'); if (isset($config[$this->type . 'Edit']['statusOptions'])) { return $this->getConfig('fid')[$this->type . 'Edit']['statusOptions'][0]; @@ -269,24 +376,30 @@ trait FidAcquisitionTrait } } + /** + * Special logic for handling free / open digitization-on-demand + * without existing Solr record. + * Method orients on procedure of runAquisition() + * + * @return mixed|\Zend\Http\Response|\Zend\View\Model\ViewModel + * @throws \fid\Service\ClientException + * @throws \fid\Service\UserNotAuthorizedException + */ protected function runDigitizationMissingRecord() { if (!($user = $this->getUser())) { return $this->forceLogin(); } - /** - * @var User $user - */ + /* @var User $user */ $user = $this->client->requestUserDetails(); try { - /* pass if permission is granted, else throw exception and switch to catch block */ + /* pass if permission is granted, + * else throw exception and switch to catch block */ $this->permission()->check('fid.Acquisitions', 'exception'); - /** - * @var Form $form - */ + /* @var Form $form */ $form = $this->serviceLocator->get($this->formConfig); $this->addOptinalFormValidators($form); @@ -299,7 +412,8 @@ trait FidAcquisitionTrait $status = $this->getDefaultStatus(); $hydratorData = compact('type', 'user', 'label', 'status'); $hydratorData += $this->addTypeSpecificOrderInformation($form); - $form->getHydrator()->hydrate($hydratorData, $order = new Order()); + $form->getHydrator() + ->hydrate($hydratorData, $order = new Order()); $this->client->requestOrderCreation($order); $this->client->requestUserDetails(null, true); $message = $this->translate('fid::acquisition_success'); @@ -311,7 +425,8 @@ trait FidAcquisitionTrait } } - $action = $this->url()->fromRoute("record-fiddigitizationmissingrecord", ['id' => 'none']); + $action = $this->url() + ->fromRoute("record-fiddigitizationmissingrecord", ['id' => 'none']); $form->setAttribute('action', $action); $form->prepare(); diff --git a/module/fid/src/Controller/MyResearchController.php b/module/fid/src/Controller/MyResearchController.php index e68643dc1d5..44b04bda4bc 100644 --- a/module/fid/src/Controller/MyResearchController.php +++ b/module/fid/src/Controller/MyResearchController.php @@ -2,10 +2,10 @@ /** * MyResearch Controller * - * PHP version 7 - * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -23,13 +23,14 @@ * @package Controller * @author Robert Lange <lange@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License - * @link https://vufind.org Main Site + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Controller; use fid\Service\Client; use fid\Service\ClientException; use fid\Service\DataTransferObject\Library; +use fid\Service\DataTransferObject\User; use VuFind\Exception\Forbidden; use VuFind\Exception\ListPermission as ListPermissionException; use VuFind\Search\RecommendListener; @@ -42,16 +43,20 @@ use Zend\ServiceManager\ServiceLocatorInterface; * @package Controller * @author Robert Lange <lange@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License - * @link https://vufind.org Main Site + * @link https://vufind.org/wiki/development Wiki */ class MyResearchController extends \VuFind\Controller\MyResearchController { /** + * Main Configuration + * * @var \Zend\Config\Config */ protected $mainConfig; /** + * Fidis client + * * @var \fid\Service\Client */ protected $fidClient; @@ -59,8 +64,7 @@ class MyResearchController extends \VuFind\Controller\MyResearchController /** * MyResearchController constructor. * - * @param ServiceLocatorInterface $serviceLocator - * @param array fid config $config + * @param ServiceLocatorInterface $serviceLocator Container interfafce */ public function __construct( ServiceLocatorInterface $serviceLocator @@ -70,7 +74,11 @@ class MyResearchController extends \VuFind\Controller\MyResearchController } /** - * @param Client $fidClient + * Set fidis client + * + * @param Client $fidClient fidis client + * + * @return void */ public function setFidClient(Client $fidClient): void { @@ -154,7 +162,10 @@ class MyResearchController extends \VuFind\Controller\MyResearchController } /** - * @param $patron + * Get patrons home libray if saved by patron + * + * @param $patron patron + * * @return \fid\Service\DataTransferObject\Library | null * @throws \fid\Service\ClientException */ @@ -167,7 +178,8 @@ class MyResearchController extends \VuFind\Controller\MyResearchController return $patron['libs'][$homeLibrary]; } - /* no home library found in patron object? => fetch library from api directly */ + /* no home library found in patron object? + * then fetch library from api directly */ return $this->fidClient->requestLibraryById($homeLibrary); } @@ -182,13 +194,16 @@ class MyResearchController extends \VuFind\Controller\MyResearchController public function hasLicenses(): bool { // Are licenses configured - if (!isset($this->mainConfig['MediaLicenses']) || count($this->mainConfig['MediaLicenses']) == 0) { + if (!isset($this->mainConfig['MediaLicenses']) + || count($this->mainConfig['MediaLicenses']) == 0 + ) { return false; } // Has user rights to access? try { - return $this->permission()->check('access.Licenses', 'exception') == null; + return + $this->permission()->check('access.Licenses', 'exception') == null; } catch (Forbidden $e) { // Permission Plugin needs cumbersome exception for logged-in users } @@ -212,7 +227,8 @@ class MyResearchController extends \VuFind\Controller\MyResearchController foreach ($configLicenses as $key => $value) { $licenses[$i]['name'] = $key; $licenses[$i]['url'] = $value; - $licenses[$i]['desc'] = $this->translate('licenses_' . $key . '_desc', [], ''); + $licenses[$i]['desc'] + = $this->translate('licenses_' . $key . '_desc', [], ''); $i++; } } @@ -288,7 +304,11 @@ class MyResearchController extends \VuFind\Controller\MyResearchController $results = $runner->run($request, 'Favorites', $setupCallback); return $this->createViewModel( - ['params' => $results->getParams(), 'results' => $results, 'context' => "favorite"] + [ + 'params' => $results->getParams(), + 'results' => $results, + 'context' => "favorite" + ] ); } catch (ListPermissionException $e) { if (!$this->getUser()) { diff --git a/module/fid/src/Controller/MyResearchControllerFactory.php b/module/fid/src/Controller/MyResearchControllerFactory.php index 8813fafb649..c8486ffd0d7 100644 --- a/module/fid/src/Controller/MyResearchControllerFactory.php +++ b/module/fid/src/Controller/MyResearchControllerFactory.php @@ -2,10 +2,10 @@ /** * Service MyResearchControllerFactory * - * PHP version 7 - * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -31,18 +31,38 @@ use fid\Service\Client; use Psr\Container\ContainerInterface; use Zend\ServiceManager\ServiceManager; +/** + * Service MyResearchControllerFactory + * + * @category VuFind + * @package Controller + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class MyResearchControllerFactory { + /** + * Constructor + * + * @return null + */ public function __construct() { return null; } + /** + * Invoke method + * + * @param ContainerInterface $container Container interface + * @param $requested_name Controller name + * + * @return mixed + */ public function __invoke(ContainerInterface $container, $requested_name) { - /** - * @var ServiceManager $serviceManager - */ + /* @var ServiceManager $serviceManager */ $serviceManager = $container->get(ServiceManager::class); $controller = new $requested_name($serviceManager); $controller->setFidClient($container->get(Client::class)); diff --git a/module/fid/src/Controller/RecordController.php b/module/fid/src/Controller/RecordController.php index 91cc2cfc929..ea24fe41f8c 100644 --- a/module/fid/src/Controller/RecordController.php +++ b/module/fid/src/Controller/RecordController.php @@ -19,13 +19,23 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * @category VuFind FID + * @category VuFind * @package Controller * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Controller; +/** + * Record Controller + * + * @category VuFind + * @package Controller + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class RecordController extends \finc\Controller\RecordController { use CustomTraits\FidAcquisitionTrait; diff --git a/module/fid/src/Controller/RecordControllerDelegatorFactory.php b/module/fid/src/Controller/RecordControllerDelegatorFactory.php index ccc7f51d735..27543df6da3 100644 --- a/module/fid/src/Controller/RecordControllerDelegatorFactory.php +++ b/module/fid/src/Controller/RecordControllerDelegatorFactory.php @@ -1,17 +1,64 @@ <?php +/** + * Service RecordControllerDelegatorFactory + * + * PHP version 7 + * + * Copyright (C) 2019 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind + * @package Controller + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ namespace fid\Controller; use fid\Service\Client; use Interop\Container\ContainerInterface; use Zend\ServiceManager\Factory\DelegatorFactoryInterface; +/** + * Service RecordControllerDelegatorFactory + * + * @category VuFind + * @package Controller + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class RecordControllerDelegatorFactory implements DelegatorFactoryInterface { - public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null) - { - /** - * @var RecordController $instance - */ + /** + * Invoke method + * + * @param ContainerInterface $container Container interface + * @param $name name + * @param callable $callback callback function + * @param array|null $options options + * + * @return RecordController + */ + public function __invoke( + ContainerInterface $container, + $name, + callable $callback, + array $options = null + ) { + /* @var RecordController $instance */ $instance = call_user_func($callback); $instance->setClient($container->get(Client::class)); return $instance; diff --git a/module/fid/src/Controller/UserController.php b/module/fid/src/Controller/UserController.php index 2e0e28930c9..a960f90cc3c 100644 --- a/module/fid/src/Controller/UserController.php +++ b/module/fid/src/Controller/UserController.php @@ -1,5 +1,7 @@ <?php /** + * PHP version 7 + * * Copyright (C) 2019 Leipzig University Library * * This program is free software; you can redistribute it and/or modify @@ -15,9 +17,12 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Controller + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Controller; @@ -43,19 +48,35 @@ use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger; use Zend\ServiceManager\ServiceLocatorInterface; use Zend\View\Model\ViewModel; +/** + * User Controller + * + * @category VuFind + * @package Controller + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class UserController extends AbstractBase { /** + * AuthManager + * * @var AuthManager */ protected $authManager; /** + * Fidis client + * * @var Client */ protected $client; /** + * Configuration + * * @var array */ protected $config; @@ -63,10 +84,10 @@ class UserController extends AbstractBase /** * RegistrationController constructor. * - * @param ServiceLocatorInterface $serviceLocator - * @param AuthManager $authManager - * @param Client $client - * @param array $config + * @param ServiceLocatorInterface $serviceLocator Service Locator + * @param AuthManager $authManager Authentication Manager + * @param Client $client fidis client + * @param array $config Configuration */ public function __construct( ServiceLocatorInterface $serviceLocator, @@ -81,15 +102,16 @@ class UserController extends AbstractBase } /** + * Registration init (registration part 1) route action + * Starting registration process + * * @noinspection PhpUnused * @return ViewModel */ public function initAction() { - /** - * @var Form $form - * @var Request $request - */ + /* @var Form $form */ + /* @var Request $request */ $request = $this->getRequest(); $form = $this->serviceLocator->get('user-init-form'); $forwarded = $this->params()->fromRoute('forwarded', false); @@ -113,21 +135,20 @@ class UserController extends AbstractBase } /** - * @param Form $form + * Registration init (registration part 1) by requesting + * email registration link via fidis after succeded formular validation. + * + * @param Form $form Formular * * @return mixed|Response */ protected function init(Form $form) { - /** - * @var User $user - */ + /* @var User $user */ $messenger = $this->getMessenger(); $user = $form->getHydrator()->hydrate($form->getData(), new User()); - /** - * @noinspection PhpUndefinedFieldInspection - */ + /* @noinspection PhpUndefinedFieldInspection */ $query['lng'] = $this->layout()->userLang; $username = $query['username'] = $user->getUsername(); $firstname = $query['firstname'] = $user->getFirstname(); @@ -164,26 +185,31 @@ class UserController extends AbstractBase return $this->redirect()->toRoute('myresearch-home'); } + /** + * Get flash messenger + * + * @return FlashMessenger + */ protected function getMessenger(): FlashMessenger { - /** - * @noinspection PhpUndefinedMethodInspection - * @var FlashMessenger $messenger - */ + /* @noinspection PhpUndefinedMethodInspection */ + /* @var FlashMessenger $messenger */ return $this->flashMessenger(); } /** + * Create new user (registration part 2) route action. + * Finish registration process. + * Action is triggert by link receved by email + * * @noinspection PhpUnused * @return Response|ViewModel */ public function createAction() { - /** - * @var Form $form - * @var Request $request - * @var Select $homeLibraryElement - */ + /* @var Form $form */ + /* @var Request $request */ + /* @var Select $homeLibraryElement */ $request = $this->getRequest(); $query = $request->getQuery(); $messenger = $this->getMessenger(); @@ -248,11 +274,17 @@ class UserController extends AbstractBase return $view; } + /** + * Create new user (registration part 2) + * via fidis after succeded formular validation. + * + * @param Form $form Formular + * + * @return Response + */ protected function create(Form $form) { - /** - * @var User $user - */ + /* @var User $user */ $messenger = $this->getMessenger(); $user = $form->getHydrator()->hydrate($form->getData(), new User()); @@ -260,9 +292,7 @@ class UserController extends AbstractBase $this->client->requestUserCreation($user); $message = $this->translate('fid::user_create_success'); $messenger->addSuccessMessage($message); - /** - * @noinspection PhpParamsInspection - */ + /* @noinspection PhpParamsInspection */ $this->authManager->create($this->getRequest()); } catch (ClientException $exception) { $message = $this->translate('fid::user_create_error'); @@ -282,16 +312,16 @@ class UserController extends AbstractBase } /** + * User / profile update route action + * * @return Response|ViewModel * @throws UserNotAuthorizedException */ public function updateAction() { - /** - * @var Form $form - * @var Request $request - * @var Select $homeLibraryElement - */ + /* @var Form $form */ + /* @var Request $request */ + /* @var Select $homeLibraryElement */ try { $request = $this->getRequest(); $user = $this->client->requestUserDetails(); @@ -339,8 +369,10 @@ class UserController extends AbstractBase } /** - * @param Form $form - * @param string $redirect + * Finish user update via fidis after succeded formular validation + * + * @param Form $form Formular + * @param string $redirect Route name * * @return Response * @throws UserNotAuthorizedException @@ -388,14 +420,14 @@ class UserController extends AbstractBase } /** + * Request change username email (update username part 1) route action + * * @noinspection PhpUnused * @return ViewModel */ public function changeUsernameAction() { - /** - * @var Request $request - */ + /* @var Request $request */ $request = $this->getRequest(); $form = $this->serviceLocator->get(UsernameChangeModel::class); $forwarded = $this->params()->fromRoute('forwarded', false); @@ -414,6 +446,14 @@ class UserController extends AbstractBase return $view; } + /** + * Request change username email (update username part 1) + * via fidis after succeded formular validation. + * + * @param Form $form Formular + * + * @return mixed|Response + */ protected function changeUsername(Form $form) { $messenger = $this->getMessenger(); @@ -422,9 +462,7 @@ class UserController extends AbstractBase new UsernameChangeModel() ); - /** - * @noinspection PhpUndefinedFieldInspection - */ + /* @noinspection PhpUndefinedFieldInspection */ $query['lng'] = $this->layout()->userLang; $username = $query['username'] = $model->getUsername(); $baseUrl = $this->url()->fromRoute( @@ -455,14 +493,15 @@ class UserController extends AbstractBase } /** + * Execute update username (update username part 2) route action. + * Action is triggert by link receved by email + * * @noinspection PhpUnused * @return Response */ public function updateUsernameAction() { - /** - * @var Request $request - */ + /* @var Request $request */ $request = $this->getRequest(); $query = $request->getQuery(); $messenger = $this->getMessenger(); @@ -503,6 +542,8 @@ class UserController extends AbstractBase } /** + * Confirm delete profile route action + * * @noinspection PhpUnused * @return Response */ @@ -512,9 +553,7 @@ class UserController extends AbstractBase return $this->forceLogin(); } - /** - * @var User $user - */ + /* @var User $user */ $user = $this->client->requestUserDetails(null, true); if ($user->getData()['deleted'] ?? false) { $view = $this->createViewModel(); @@ -530,13 +569,9 @@ class UserController extends AbstractBase return $view; } - /** - * @var Request $request - */ + /* @var Request $request */ $request = $this->getRequest(); - /** - * @var Form $form - */ + /* @var Form $form */ $form = $this->serviceLocator->get(UserDeleteModel::class); $forwarded = $this->params()->fromRoute('forwarded', false); @@ -554,29 +589,42 @@ class UserController extends AbstractBase return $view; } + /** + * Save user as deleted via fidis after succeded password confirmation. + * And log out user. + * + * @param Form $form Formular + * + * @return Response|ViewModel + * @throws ClientException + * @throws UserNotAuthorizedException + */ protected function deleteUser(Form $form) { $messenger = $this->getMessenger(); - /** - * @var UserDeleteModel $model - */ - $model = $form->getHydrator()->hydrate($form->getData(), new UserDeleteModel()); + /* @var UserDeleteModel $model */ + $model = $form->getHydrator() + ->hydrate($form->getData(), new UserDeleteModel()); $error = []; try { - /** - * @var User $user - */ + /* @var User $user */ $user = $this->client->requestUserDetails(); - if ($this->client->checkCredentials($user->getUsername(), $model->getPasswordConfirmation())) { + if ($this->client->checkCredentials( + $user->getUsername(), + $model->getPasswordConfirmation() + ) + ) { $user->setDeleted(true); $user->setDeletedAt(date('Y-m-d H:i:s', time())); $user = $this->client->requestUserUpdate($user); if (!$user->isDeleted()) { - $error['msg'] = $this->translate('fid::user_delete_error_unknown'); + $error['msg'] = $this + ->translate('fid::user_delete_error_unknown'); } } else { - $error['msg'] = $this->translate('fid::user_delete_error_wrong_password'); + $error['msg'] = $this + ->translate('fid::user_delete_error_wrong_password'); } } catch (ClientException $exception) { $error['msg'] = $this->translate('fid::user_delete_error_unknown'); @@ -595,6 +643,11 @@ class UserController extends AbstractBase return $view; } + /** + * Display policy route action + * + * @return ViewModel + */ public function policyAction() { $viewModel = $this->createViewModel(); @@ -605,6 +658,11 @@ class UserController extends AbstractBase return $viewModel; } + /** + * Display terms route action + * + * @return ViewModel + */ public function termsAction() { $viewModel = $this->createViewModel(); @@ -616,23 +674,23 @@ class UserController extends AbstractBase } /** - * Reset password action - Allows the reset password form to appear. + * Request reset password mail (reset password part 1) route action + * Allows the reset password form to appear, must be confirmed by user. * * @return ViewModel */ public function resetPasswordAction() { - /** - * @var Form $form - * @var Request $request - */ + /* @var Form $form */ + /* @var Request $request */ $request = $this->getRequest(); $form = $this->serviceLocator->get(PasswordResetModel::class); $forwarded = $this->params()->fromRoute('forwarded', false); if ($this->getUser()) { $form->get('username')->setAttribute('disabled', 'true'); - $form->get('username')->setValue($this->client->requestUserDetails()->getUsername()); + $form->get('username') + ->setValue($this->client->requestUserDetails()->getUsername()); $form->setValidationGroup(['submit']); } @@ -650,15 +708,22 @@ class UserController extends AbstractBase return $view; } + /** + * Send reset password email via fidis to user + * + * @param Form $form Formular + * + * @return Response + * @throws ClientException + * @throws UserNotAuthorizedException + */ protected function sendResetPassword(Form $form) { $messenger = $this->getMessenger(); if ($this->getUser()) { $username = $this->client->requestUserDetails()->getUsername(); } else { - /** - * @var PasswordResetModel $model - */ + /* @var PasswordResetModel $model */ $model = $form->getHydrator()->hydrate( $form->getData(), new PasswordResetModel() @@ -667,9 +732,7 @@ class UserController extends AbstractBase } try { - /** - * @noinspection PhpUndefinedFieldInspection - */ + /* @noinspection PhpUndefinedFieldInspection */ $query['lng'] = $this->layout()->userLang; $baseUrl = $this->url()->fromRoute( 'fid/user/change-password', @@ -691,15 +754,15 @@ class UserController extends AbstractBase } /** - * Reset password action - Allows the change password form to appear. + * Reset password route action (reset password part 2). + * Action is triggerd by email link. + * Allows the change password form to appear. * * @return Response|ViewModel */ public function changePasswordAction() { - /** - * @var Request $request - */ + /* @var Request $request */ $request = $this->getRequest(); $query = $request->getQuery(); $messenger = $this->getMessenger(); @@ -743,11 +806,19 @@ class UserController extends AbstractBase return $view; } + /** + * Update password by passing it to user model + * and run update password request to fidis + * + * @param Form $form Formular + * + * @return Response + * @throws UserNotAuthorizedException + * @throws \fid\Service\UserNotLoggedinException + */ protected function changePassword(Form $form) { - /** - * @var PasswordChangeModel $model - */ + /* @var PasswordChangeModel $model */ $messenger = $this->getMessenger(); $model = $form->getHydrator()->hydrate( $form->getData(), @@ -761,9 +832,7 @@ class UserController extends AbstractBase $message = $this->translate('fid::password_change_success'); $message = sprintf($message, $username = $user->getUsername()); $messenger->addSuccessMessage($message); - /** - * @var Request $request - */ + /* @var Request $request */ $request = clone $this->getRequest(); $params = clone $request->getPost(); $params->set('username', $username); @@ -787,15 +856,20 @@ class UserController extends AbstractBase ); } + /** + * Edit user route action. + * Only for admins. + * + * @return mixed|Response|ViewModel + * @throws UserNotAuthorizedException + */ public function editAction() { if (!$this->getUser()) { return $this->forceLogin(); } - /** - * @var Request $request - */ + /* @var Request $request */ $request = $this->getRequest(); $userId = $this->params()->fromRoute('userid'); if (empty($userId)) { @@ -842,10 +916,8 @@ class UserController extends AbstractBase return $this->redirect()->toRoute('fid/admin/list'); } - /** - * @var Form $form - * @var Select $homeLibraryElement - */ + /* @var Form $form */ + /* @var Select $homeLibraryElement */ $form = $this->serviceLocator->get('admin-edit-form'); $homeLibraryElement = $form->get('home_library'); $homeLibraryElement->setValueOptions($libraries); @@ -879,6 +951,11 @@ class UserController extends AbstractBase return $viewModel; } + /** + * Display admins user list route action + * + * @return mixed|ViewModel + */ public function listAction() { if (!$this->getUser()) { @@ -905,6 +982,12 @@ class UserController extends AbstractBase return $viewModel; } + /** + * Display users order list route action + * + * @return mixed|void|ViewModel + * @throws UserNotAuthorizedException + */ public function ordersAction() { if (!$this->getUser()) { @@ -924,6 +1007,11 @@ class UserController extends AbstractBase } } + /** + * Display admins order list route action + * + * @return mixed|void|ViewModel + */ public function adminOrdersAction() { if (!$this->getUser()) { @@ -937,7 +1025,8 @@ class UserController extends AbstractBase $viewModel->setTemplate('fid/user/admin-orders'); return $viewModel; } catch (UserNotAuthorizedException $exception) { - $this->getMessenger()->addErrorMessage('fid::read_order_list_not_allowed'); + $this->getMessenger() + ->addErrorMessage('fid::read_order_list_not_allowed'); } catch (ClientException $exception) { $this->getMessenger()->addErrorMessage('fid::read_order_list_error'); $this->redirect()->toRoute('myresearch-profile'); @@ -945,13 +1034,22 @@ class UserController extends AbstractBase } /** - * @param ViewModel $viewModel + * Add back url to view model. + * Get back url from query parameter or request header. + * + * @param ViewModel $viewModel View model + * * @return bool */ protected function setBackUrl(ViewModel $viewModel): bool { - if (!empty($query = $this->getRequest()->getQuery()) && !empty($query->get('backUrl'))) { - $viewModel->setVariable('backUrl', $this->getRequest()->getQuery()->get('backUrl')); + if (!empty($query = $this->getRequest()->getQuery()) + && !empty($query->get('backUrl')) + ) { + $viewModel->setVariable( + 'backUrl', + $this->getRequest()->getQuery()->get('backUrl') + ); return true; } @@ -964,6 +1062,8 @@ class UserController extends AbstractBase } /** + * Request download of user list route action + * * @return HttpResponse * @throws ClientException * @throws UserNotAuthorizedException @@ -981,6 +1081,14 @@ class UserController extends AbstractBase ); } + /** + * Build user list export file + * + * @param User[] $userList User List + * @param string[] $fields Fields to render + * + * @return HttpResponse + */ protected function createExportFile($userList, $fields=null) { $response = new HttpResponse(); @@ -988,13 +1096,12 @@ class UserController extends AbstractBase $response->getHeaders()->addHeaders( [ 'Content-type' => 'text/plain', - 'Content-Disposition' => 'attachment; filename="' . $prefix . '_' . date('Ymd_His') . '.txt"' + 'Content-Disposition' => 'attachment; filename="' + . $prefix . '_' . date('Ymd_His') . '.txt"' ] ); $output = implode("\t", $fields) . "\n"; - /** - * @var User $user - */ + /* @var User $user */ foreach ($userList as $user) { $output .= $user->export($fields) . "\n"; } @@ -1002,6 +1109,13 @@ class UserController extends AbstractBase return $response; } + /** + * Helper method for appling job title options on job title form element + * + * @param Form $form Formular + * + * @return void + */ protected function applyJobTitleOptions($form) { if ($jobTitleOptions = $this->config['Forms']['jobTitleOptions'] ?? null) { @@ -1017,15 +1131,19 @@ class UserController extends AbstractBase } } + /** + * Edit single order route action + * + * @return mixed|Response|ViewModel + * @throws \Exception + */ public function editOrderAction() { if (!$this->getUser()) { return $this->forceLogin(); } - /** - * @var Request $request - */ + /* @var Request $request */ $request = $this->getRequest(); $orderId = $this->params()->fromRoute('orderid'); if (empty($orderId)) { @@ -1045,12 +1163,12 @@ class UserController extends AbstractBase $recordId = $order->getRecordId(); $driver = $recordId ? $this->getRecordLoader()->load($recordId) : null; - /** - * @var Form $form - * @var Select $statusElement - */ + /* @var Form $form */ + /* @var Select $statusElement */ $form = $this->config[$order->getType() . "Edit"]['form'] - ? $this->serviceLocator->get('order-edit-form-' . $this->config[$order->getType() . "Edit"]['form']) + ? $this->serviceLocator->get( + 'order-edit-form-' . $this->config[$order->getType() . "Edit"]['form'] + ) : null; $this->applyStatusOptions($form, $order->getType()); @@ -1080,6 +1198,16 @@ class UserController extends AbstractBase return $viewModel; } + /** + * Helper method for generating status options list and + * applies it to update order status input element. + * Display only options stored in configuration. + * + * @param Form $form Formular + * @param string $type Acquisition type + * + * @return void + */ protected function applyStatusOptions($form, $type) { if ($statusOptions = $this->config["{$type}Edit"]['statusOptions'] ?? null) { @@ -1095,6 +1223,14 @@ class UserController extends AbstractBase } } + /** + * Update order via fidis and redirect to order list + * + * @param Form $form Formular + * @param Order $order Order object + * + * @return Response + */ protected function updateOrder(Form $form, Order $order) { $data = $form->getData(); diff --git a/module/fid/src/Controller/UserControllerFactory.php b/module/fid/src/Controller/UserControllerFactory.php index fbe8fefa4c4..9b3e76a6a3f 100644 --- a/module/fid/src/Controller/UserControllerFactory.php +++ b/module/fid/src/Controller/UserControllerFactory.php @@ -1,5 +1,9 @@ <?php /** + * Service UserControllerFactory + * + * PHP version 7 + * * Copyright (C) 2019 Leipzig University Library * * This program is free software; you can redistribute it and/or modify @@ -15,9 +19,12 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Controller + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Controller; @@ -27,10 +34,22 @@ use VuFind\Auth\Manager as AuthManager; use VuFind\Config\PluginManager as ConfigManager; use Zend\ServiceManager\ServiceLocatorInterface; +/** + * Service UserControllerFactory + * + * @category VuFind + * @package Controller + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class UserControllerFactory { /** - * @param ContainerInterface|ServiceLocatorInterface $container + * Invoke method for user controller + * + * @param ContainerInterface|ServiceLocatorInterface $container Service container * * @return UserController */ diff --git a/module/fid/src/FormModel/PasswordChangeModel.php b/module/fid/src/FormModel/PasswordChangeModel.php index e31add1894f..00bfd9ea139 100644 --- a/module/fid/src/FormModel/PasswordChangeModel.php +++ b/module/fid/src/FormModel/PasswordChangeModel.php @@ -1,7 +1,11 @@ <?php /** + * Password change form model + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,30 +19,39 @@ * 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 + * @category VuFind + * @package Form_Model + * @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 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\FormModel; +/** + * Password change form model + * + * @category VuFind + * @package Form_Model + * @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 + * @link https://vufind.org/wiki/development Wiki + */ class PasswordChangeModel { - /** - * @var string - */ + /* @var string */ protected $password; - /** - * @var string - */ + /* @var string */ protected $passwordConfirmation; - /** - * @var string - */ + /* @var string */ protected $submit; /** + * Get password + * * @return string */ public function getPassword(): string @@ -47,7 +60,11 @@ class PasswordChangeModel } /** - * @param string $password + * Set password + * + * @param string $password Password + * + * @return void */ public function setPassword(string $password): void { @@ -55,6 +72,8 @@ class PasswordChangeModel } /** + * Get password confirmation + * * @return string */ public function getPasswordConfirmation(): string @@ -63,7 +82,11 @@ class PasswordChangeModel } /** - * @param string $passwordConfirmation + * Set password confirmation + * + * @param string $passwordConfirmation Password confirmation + * + * @return void */ public function setPasswordConfirmation(string $passwordConfirmation): void { @@ -71,6 +94,8 @@ class PasswordChangeModel } /** + * Get submit + * * @return string */ public function getSubmit(): string @@ -79,7 +104,11 @@ class PasswordChangeModel } /** - * @param string $submit + * Set submit + * + * @param string $submit Submit + * + * @return void */ public function setSubmit(string $submit): void { diff --git a/module/fid/src/FormModel/PasswordResetModel.php b/module/fid/src/FormModel/PasswordResetModel.php index d65083b599e..1f0a835ca51 100644 --- a/module/fid/src/FormModel/PasswordResetModel.php +++ b/module/fid/src/FormModel/PasswordResetModel.php @@ -1,7 +1,11 @@ <?php /** + * Password reset form model + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,25 +19,36 @@ * 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 + * @category VuFind + * @package Form_Model + * @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 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\FormModel; +/** + * Password reset form model + * + * @category VuFind + * @package Form_Model + * @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 + * @link https://vufind.org/wiki/development Wiki + */ class PasswordResetModel { - /** - * @var string - */ + /* @var string */ protected $username; - /** - * @var string - */ + /* @var string */ protected $submit; /** + * Get Username + * * @return string */ public function getUsername(): string @@ -42,7 +57,11 @@ class PasswordResetModel } /** - * @param string $username + * Set Username + * + * @param string $username Username + * + * @return void */ public function setUsername(string $username): void { @@ -50,6 +69,8 @@ class PasswordResetModel } /** + * Get submit + * * @return string */ public function getSubmit(): string @@ -58,7 +79,11 @@ class PasswordResetModel } /** - * @param string $submit + * Set submit + * + * @param string $submit Submit + * + * @return void */ public function setSubmit(string $submit): void { diff --git a/module/fid/src/FormModel/UserDeleteModel.php b/module/fid/src/FormModel/UserDeleteModel.php index e66ca692bf6..091ad1b2421 100644 --- a/module/fid/src/FormModel/UserDeleteModel.php +++ b/module/fid/src/FormModel/UserDeleteModel.php @@ -1,6 +1,10 @@ <?php /** - * Copyright (C) 2020 Leipzig University Library + * User delete form model + * + * Copyright (C) 2019 Leipzig University Library + * + * PHP Version 7 * * 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 @@ -15,29 +19,37 @@ * 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> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Form_Model + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\FormModel; +/** + * User delete form model + * + * @category VuFind + * @package Form_Model + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class UserDeleteModel { - /** - * @var string - */ + /* @var string */ protected $id; - /** - * @var string - */ + /* @var string */ protected $passwordConfirmation; - /** - * @var string - */ + /* @var string */ protected $submit; /** + * Get password confirmation + * * @return string */ public function getPasswordConfirmation(): string @@ -46,7 +58,11 @@ class UserDeleteModel } /** - * @param string $password + * Set password confirmation + * + * @param string $password Password confirmation + * + * @return void */ public function setPasswordConfirmation(string $password): void { @@ -54,6 +70,8 @@ class UserDeleteModel } /** + * Get submit + * * @return string */ public function getSubmit(): string @@ -62,7 +80,11 @@ class UserDeleteModel } /** - * @param string $submit + * Set submit + * + * @param string $submit Submit + * + * @return void */ public function setSubmit(string $submit): void { @@ -70,6 +92,8 @@ class UserDeleteModel } /** + * Get ID + * * @return string */ public function getId(): string @@ -78,7 +102,11 @@ class UserDeleteModel } /** - * @param string $id + * Set ID + * + * @param string $id ID + * + * @return void */ public function setId(string $id) { diff --git a/module/fid/src/FormModel/UsernameChangeModel.php b/module/fid/src/FormModel/UsernameChangeModel.php index 084f5114199..df99fc81a34 100644 --- a/module/fid/src/FormModel/UsernameChangeModel.php +++ b/module/fid/src/FormModel/UsernameChangeModel.php @@ -1,7 +1,11 @@ <?php /** + * Username change form model + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,30 +19,39 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Form_Model + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\FormModel; +/** + * Username change form model + * + * @category VuFind + * @package Form_Model + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class UsernameChangeModel { - /** - * @var string - */ + /* @var string */ protected $username; - /** - * @var string - */ + /* @var string */ protected $usernameConfirmation; - /** - * @var string - */ + /* @var string */ protected $submit; /** + * Get username + * * @return string */ public function getUsername(): string @@ -47,7 +60,11 @@ class UsernameChangeModel } /** - * @param string $username + * Set username + * + * @param string $username Username + * + * @return void */ public function setUsername(string $username): void { @@ -55,6 +72,8 @@ class UsernameChangeModel } /** + * Get username confirmation + * * @return string */ public function getUsernameConfirmation(): string @@ -63,7 +82,11 @@ class UsernameChangeModel } /** - * @param string $usernameConfirmation + * Set username confirmation + * + * @param string $usernameConfirmation Username confirmation + * + * @return void */ public function setUsernameConfirmation(string $usernameConfirmation): void { @@ -71,6 +94,8 @@ class UsernameChangeModel } /** + * Get submit + * * @return string */ public function getSubmit(): string @@ -79,7 +104,11 @@ class UsernameChangeModel } /** - * @param string $submit + * Set submit + * + * @param string $submit Submit value + * + * @return void */ public function setSubmit(string $submit): void { diff --git a/module/fid/src/Helper/TranslatorDelegator.php b/module/fid/src/Helper/TranslatorDelegator.php index 66735db524e..d63177de765 100644 --- a/module/fid/src/Helper/TranslatorDelegator.php +++ b/module/fid/src/Helper/TranslatorDelegator.php @@ -1,7 +1,11 @@ <?php /** + * Translator Delegator + * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,16 +19,37 @@ * 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> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package View_Helpers + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Helper; use Psr\Container\ContainerInterface; use Zend\I18n\Translator\Resources; +/** + * Translator Delegator + * + * @category VuFind + * @package View_Helpers + * @author Robert Lange <lange@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class TranslatorDelegator { + /** + * Invoke method for creating translator object. + * + * @param ContainerInterface $container Container + * @param $name Class name + * @param callable $callback Callback function + * + * @return false|mixed + */ public function __invoke( ContainerInterface $container, $name, diff --git a/module/fid/src/Hydrator/OrderHydrator.php b/module/fid/src/Hydrator/OrderHydrator.php index e85feda8d1f..edc7163bde8 100644 --- a/module/fid/src/Hydrator/OrderHydrator.php +++ b/module/fid/src/Hydrator/OrderHydrator.php @@ -1,42 +1,91 @@ <?php +/** + * Order hydrator + * + * Copyright (C) 2021 Leipzig University Library + * + * PHP Version 7 + * + * 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. + * + * @category VuFind + * @package Hydrator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @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 + * @link https://vufind.org/wiki/development Wiki + */ namespace fid\Hydrator; use fid\Service\DataTransferObject\Order; use VuFind\RecordDriver\DefaultRecord; use Zend\Hydrator\AbstractHydrator; +/** + * Order hydrator for saving aquistions data correctly to dto before sending to fidis + * + * @category VuFind + * @package Hydrator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @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 + * @link https://vufind.org/wiki/development Wiki + */ class OrderHydrator extends AbstractHydrator { + /** + * Extract method: + * Not implemented, not in use + * + * @param Order $object Order object + * + * @return void + */ public function extract($object) { - - // TODO: Implement extract() method. } /** - * @param array $data - * @param Order|object $object - * @return Order|object|void + * Save acquisition data to order object + * + * @param array $data Relevant data + * @param Order $object Order object + * + * @return Order|void */ public function hydrate(array $data, $object) { - /** - * @var DefaultRecord $driver - */ + /* @var DefaultRecord $driver */ $driver = $data['driver']; $object->setType($data['type']); $object->setUser($data['user']); - $partialCopy = array_key_exists('subitoPartialCopy', $data) ? $data['subitoPartialCopy'] : null; - $digitization = array_key_exists('digitization', $data) ? $data['digitization'] : null; + $partialCopy = array_key_exists('subitoPartialCopy', $data) + ? $data['subitoPartialCopy'] : null; + $digitization = array_key_exists('digitization', $data) + ? $data['digitization'] : null; $pda = array_key_exists('pda', $data) ? $data['pda'] : null; /* Collect needed record data */ $id = $driver->tryMethod('getUniqueID'); $title = $driver->tryMethod('getTitle'); $pdetails = $driver->tryMethod('getPublicationDetails'); - $publicationDetails = $this->toArray(!empty($pdetails) ? $pdetails[0] : null); + $publicationDetails + = $this->toArray(!empty($pdetails) ? $pdetails[0] : null); $authors = $driver->tryMethod('getDeduplicatedAuthors'); $primaryAuthor = $driver->tryMethod('getPrimaryAuthor'); $secondaryAuthors = $driver->tryMethod('getSecondaryAuthors'); @@ -77,7 +126,15 @@ class OrderHydrator extends AbstractHydrator $object->setLabel($data['label']); } - public function toArray($object) : array + /** + * Helper function to convert object member variables to array. + * Member name becomes array key. + * + * @param $object Object + * + * @return array + */ + protected function toArray($object) : array { $array = (array)$object; $keys = str_replace('*', '', array_keys($array)); diff --git a/module/fid/src/Hydrator/OrderMissingRecordHydrator.php b/module/fid/src/Hydrator/OrderMissingRecordHydrator.php index debe7570ed9..7cde620598b 100644 --- a/module/fid/src/Hydrator/OrderMissingRecordHydrator.php +++ b/module/fid/src/Hydrator/OrderMissingRecordHydrator.php @@ -1,28 +1,74 @@ <?php +/** + * Order missing record hydrator + * + * Copyright (C) 2021 Leipzig University Library + * + * PHP Version 7 + * + * 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. + * + * @category VuFind + * @package Hydrator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ namespace fid\Hydrator; use fid\Service\DataTransferObject\Order; use Zend\Hydrator\AbstractHydrator; +/** + * Order missing record (free/ open digitization-on-demand) hydrator + * for saving aquistions data correctly before sending to fidis. + * + * @category VuFind + * @package Hydrator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class OrderMissingRecordHydrator extends AbstractHydrator { + /** + * Extract method: + * Not implemented, not in use + * + * @param Order $object Order object + * + * @return void + */ public function extract($object) { - - // TODO: Implement extract() method. } /** - * @param array $data - * @param Order|object $object - * @return Order|object|void + * Save free/ open digitization-on-demand data to order object + * + * @param array $data Data to hydrate + * @param Order $object Order object + * + * @return Order */ public function hydrate(array $data, $object) { $object->setType($data['type']); $object->setUser($data['user']); - $digitization = array_key_exists('digitization', $data) ? $data['digitization'] : null; + $digitization + = array_key_exists('digitization', $data) ? $data['digitization'] : null; $partialCopy = null; $pda = null; $record = null; diff --git a/module/fid/src/Hydrator/OrderUpdateHydrator.php b/module/fid/src/Hydrator/OrderUpdateHydrator.php index c098d7d6162..cb7af9dd51b 100644 --- a/module/fid/src/Hydrator/OrderUpdateHydrator.php +++ b/module/fid/src/Hydrator/OrderUpdateHydrator.php @@ -1,30 +1,82 @@ <?php +/** + * Order update hydrator + * + * Copyright (C) 2021 Leipzig University Library + * + * PHP Version 7 + * + * 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. + * + * @category VuFind + * @package Hydrator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ namespace fid\Hydrator; use fid\Service\DataTransferObject\Order; use Zend\Hydrator\AbstractHydrator; +/** + * Order update hydrator for getting order data + * or update aquistions data correctly before sending to fidis + * + * @category VuFind + * @package Hydrator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class OrderUpdateHydrator extends AbstractHydrator { public const DATE_FORMAT = 'Y-m-d'; + /** + * Extract and return due date and status + * + * @param Order $object Order object + * + * @return array + */ public function extract($object) { - $retval['due_date'] = $object->getDueDate() ? $object->getDueDate()->format(self::DATE_FORMAT) : ''; + $retval['due_date'] = $object->getDueDate() + ? $object->getDueDate()->format(self::DATE_FORMAT) : ''; $retval['status'] = $object->getStatus() ?? 'open'; return $retval; } /** - * @param array $data - * @param Order|object $object - * @return Order|object|void + * Save due date and status to order + * + * @param array $data Data to save to order object + * @param Order $object Order object + * + * @return Order */ public function hydrate(array $data, $object) { $data['status'] ? $object->setStatus($data['status']) : null; !empty($data['due_date']) - ? $object->setDueDate(\DateTime::createFromFormat(self::DATE_FORMAT, $data['due_date'])) + ? $object->setDueDate( + \DateTime::createFromFormat( + self::DATE_FORMAT, + $data['due_date'] + ) + ) : null; return $object; } diff --git a/module/fid/src/Hydrator/Strategy/UserDataStrategy.php b/module/fid/src/Hydrator/Strategy/UserDataStrategy.php index 48808dff111..a18a147a552 100644 --- a/module/fid/src/Hydrator/Strategy/UserDataStrategy.php +++ b/module/fid/src/Hydrator/Strategy/UserDataStrategy.php @@ -1,7 +1,11 @@ <?php /** + * User data strategy + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,27 +19,55 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Hydrator + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Hydrator\Strategy; +use fid\Hydrator\UserHydrator; +use fid\Hydrator\UserHydratorDelegatorFactory; use Zend\Hydrator\NamingStrategy\NamingStrategyInterface; use Zend\Hydrator\Strategy\StrategyInterface; +/** + * User data strategy + * + * @category VuFind + * @package Hydrator + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + * + * @see UserHydrator + * @see UserHydratorDelegatorFactory + */ class UserDataStrategy implements StrategyInterface { - /** - * @var NamingStrategyInterface - */ + /* @var NamingStrategyInterface */ protected $namingStrategy; + /** + * Constructor + * + * @param NamingStrategyInterface $namingStrategy Naming Startegy + */ public function __construct(NamingStrategyInterface $namingStrategy) { $this->namingStrategy = $namingStrategy; } + /** + * Extract method + * + * @param array|mixed $value Value(s) + * + * @return array|mixed + */ public function extract($value) { if (!is_array($value)) { @@ -50,6 +82,13 @@ class UserDataStrategy implements StrategyInterface return $result ?? []; } + /** + * Hydrate method + * + * @param array|mixed $value Value(s) + * + * @return array|mixed + */ public function hydrate($value) { if (!is_array($value)) { diff --git a/module/fid/src/Hydrator/UserHydrator.php b/module/fid/src/Hydrator/UserHydrator.php index f8f922c0d6d..698e2150fee 100644 --- a/module/fid/src/Hydrator/UserHydrator.php +++ b/module/fid/src/Hydrator/UserHydrator.php @@ -1,7 +1,11 @@ <?php /** + * User Hydrator + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,14 +19,32 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Hydrator + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Hydrator; +use fid\Hydrator\Strategy\UserDataStrategy; use Zend\Hydrator\ClassMethods; +/** + * User Hydrator + * Gets functionality by using UserDataStrategy + * + * @category VuFind + * @package Hydrator + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + * + * @see UserDataStrategy + * @see UserHydratorDelegatorFactory + */ class UserHydrator extends ClassMethods { } diff --git a/module/fid/src/Hydrator/UserHydratorDelegatorFactory.php b/module/fid/src/Hydrator/UserHydratorDelegatorFactory.php index 6ee434ffe80..f6e10fa4bd0 100644 --- a/module/fid/src/Hydrator/UserHydratorDelegatorFactory.php +++ b/module/fid/src/Hydrator/UserHydratorDelegatorFactory.php @@ -1,7 +1,11 @@ <?php /** + * User Hydrator Delegator Factory + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,8 +19,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Hydrator + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Hydrator; @@ -28,17 +35,34 @@ use Zend\Hydrator\ClassMethods; use Zend\Hydrator\Strategy\CollectionStrategy; use Zend\ServiceManager\Factory\DelegatorFactoryInterface; +/** + * User Hydrator Delegator Factory + * + * @category VuFind + * @package Hydrator + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class UserHydratorDelegatorFactory implements DelegatorFactoryInterface { + /** + * Init user hydrator object and apply naming strategy + * + * @param ContainerInterface $container Service Container + * @param $name Class name + * @param callable $callback Callback funcktion + * @param array|null $options Options + * + * @return AbstractHydrator + */ public function __invoke( ContainerInterface $container, $name, callable $callback, array $options = null ) { - /** - * @var AbstractHydrator $hydrator - */ + /* @var AbstractHydrator $hydrator */ $hydrator = call_user_func($callback); $namingStrategy = $hydrator->getNamingStrategy(); $hydrator->addStrategy('data', new UserDataStrategy($namingStrategy)); diff --git a/module/fid/src/InputFilter/RootAwareBaseInputFilter.php b/module/fid/src/InputFilter/RootAwareBaseInputFilter.php index f85be6465fd..d4963337766 100644 --- a/module/fid/src/InputFilter/RootAwareBaseInputFilter.php +++ b/module/fid/src/InputFilter/RootAwareBaseInputFilter.php @@ -1,7 +1,11 @@ <?php /** + * Root aware base input filter + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,17 +19,36 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Input_Filter + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\InputFilter; use Zend\InputFilter\BaseInputFilter; +/** + * Root aware base input filter + * + * @category VuFind + * @package Input_Filter + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class RootAwareBaseInputFilter extends BaseInputFilter { public const ROOT = '__ROOT__'; + /** + * {@inheritdoc} + * + * @param mixed|null $context Context + * + * @return bool + */ public function isValid($context = null) { $values = array_merge($this->getRawValues(), (array)$this->data); diff --git a/module/fid/src/InputFilter/UserCreateFormInputFilter.php b/module/fid/src/InputFilter/UserCreateFormInputFilter.php index a48cfe20d70..4bdb9e93f8e 100644 --- a/module/fid/src/InputFilter/UserCreateFormInputFilter.php +++ b/module/fid/src/InputFilter/UserCreateFormInputFilter.php @@ -1,7 +1,11 @@ <?php /** + * User create form input filter + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,15 +19,34 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Alexander Purr <purr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Input_Filter + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\InputFilter; +/** + * User create form input filter + * + * @category VuFind + * @package Input_Filter + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class UserCreateFormInputFilter extends RootAwareBaseInputFilter { + /** + * Appand standard fidis permissions + * + * @return array + */ public function getValues() { $permissions = [ diff --git a/module/fid/src/Listener/ClientConfigListener.php b/module/fid/src/Listener/ClientConfigListener.php index 4933f652946..5945d1bdf91 100644 --- a/module/fid/src/Listener/ClientConfigListener.php +++ b/module/fid/src/Listener/ClientConfigListener.php @@ -1,7 +1,11 @@ <?php /** + * Fidis client config listener + * * Copyright (C) 2020 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,8 +19,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Listener; @@ -30,6 +37,15 @@ use Zend\EventManager\EventManagerInterface; use Zend\Mvc\MvcEvent; use Zend\View\Model\ViewModel; +/** + * Fidis client config listener + * + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class ClientConfigListener extends AbstractListenerAggregate { protected const PARAM = 'fidis_base_url'; @@ -42,12 +58,12 @@ class ClientConfigListener extends AbstractListenerAggregate protected const STATUS = '%sFidis: %s'; - /** - * @var array - */ + /* @var array */ protected $config; /** + * Get configuration + * * @return array */ public function getConfig(): array @@ -55,23 +71,32 @@ class ClientConfigListener extends AbstractListenerAggregate return $this->config; } + /** + * Attach onDispatch method to event (MvcEvent::EVENT_ROUTE) + * + * @param EventManagerInterface $events Event manager + * @param $priority Used priority + * + * @return void + */ public function attach(EventManagerInterface $events, $priority = 9000) { $events->attach(static::EVENT, [$this, 'onDispatch'], $priority); } /** - * @param MvcEvent $event + * Handling fidis base url update via GET parameter (if allowed in config) + * + * @param MvcEvent $event Event * + * @return void * @throws ClientException */ public function onDispatch(MvcEvent $event) { - /** - * @var Config $config - * @var PluginManager $configManager - * @var ContainerInterface $container - */ + /* @var Config $config */ + /* @var PluginManager $configManager */ + /* @var ContainerInterface $container */ $request = $event->getRequest(); $container = $event->getApplication()->getServiceManager(); $configManager = $container->get(PluginManager::class); @@ -98,10 +123,8 @@ class ClientConfigListener extends AbstractListenerAggregate $baseUrl = $config->baseUrl; } - /** - * @var ViewModel $viewModel - * @var CookieManager $cookieManager - */ + /* @var ViewModel $viewModel */ + /* @var CookieManager $cookieManager */ $this->config['baseUrl'] = $baseUrl; $cookieManager = $container->get(CookieManager::class); $cookieManager->set(self::PARAM, $baseUrl); diff --git a/module/fid/src/Listener/ErrorListener.php b/module/fid/src/Listener/ErrorListener.php index 6b68145f75e..19a136d87d8 100644 --- a/module/fid/src/Listener/ErrorListener.php +++ b/module/fid/src/Listener/ErrorListener.php @@ -1,7 +1,11 @@ <?php /** + * Error listener + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,16 +19,29 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Listener; use Zend\EventManager\AbstractListenerAggregate; use Zend\EventManager\EventInterface; use Zend\EventManager\EventManagerInterface; +use Zend\Log\Filter\Priority; use Zend\Mvc\MvcEvent; +/** + * Error listener + * + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class ErrorListener extends AbstractListenerAggregate { protected const ERROR_EVENTS @@ -33,6 +50,15 @@ class ErrorListener extends AbstractListenerAggregate MvcEvent::EVENT_RENDER_ERROR, ]; + /** + * Attach onError method to events: + * MvcEvent::EVENT_DISPATCH_ERROR and MvcEvent::EVENT_RENDER_ERROR + * + * @param EventManagerInterface $events Event manager + * @param $priority Used priority + * + * @return void + */ public function attach(EventManagerInterface $events, $priority = 20000) { foreach (static::ERROR_EVENTS as $event) { @@ -41,7 +67,11 @@ class ErrorListener extends AbstractListenerAggregate } /** - * @param EventInterface|MvcEvent $event + * On error event handling + * + * @param EventInterface|MvcEvent $event Event + * + * @return void */ public function onError(EventInterface $event): void { diff --git a/module/fid/src/Listener/LocaleListener.php b/module/fid/src/Listener/LocaleListener.php index 3634bf9813f..48c97fa4d6a 100644 --- a/module/fid/src/Listener/LocaleListener.php +++ b/module/fid/src/Listener/LocaleListener.php @@ -1,7 +1,11 @@ <?php /** + * Locale listener + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,35 +19,58 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Listener; use fid\Service\Client; use Zend\EventManager\AbstractListenerAggregate; use Zend\EventManager\EventManagerInterface; +use Zend\Log\Filter\Priority; use Zend\Mvc\I18n\Translator; use Zend\Mvc\MvcEvent; +/** + * Locale listener + * + * @category VuFind + * @package Listener + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class LocaleListener extends AbstractListenerAggregate { protected const EVENT = MvcEvent::EVENT_DISPATCH; + /** + * Attach onDispatch method to event (MvcEvent::EVENT_DISPATCH) + * + * @param EventManagerInterface $events Event manager + * @param $priority Used priority + * + * @return void + */ public function attach(EventManagerInterface $events, $priority = 9000) { $events->attach(static::EVENT, [$this, 'onDispatch'], $priority); } /** - * @param MvcEvent $event + * Set fidis clients locale + * + * @param MvcEvent $event Event + * + * @return void */ public function onDispatch(MvcEvent $event) { $container = $event->getApplication()->getServiceManager(); - /** - * @var Client $client - */ + /* @var Client $client */ $client = $container->get(Client::class); $locale = $container->get(Translator::class)->getLocale(); $client->setLocale($locale); diff --git a/module/fid/src/RecordTab/Worldcat.php b/module/fid/src/RecordTab/Worldcat.php index dfd75e5d040..ddcdf3c0bb1 100644 --- a/module/fid/src/RecordTab/Worldcat.php +++ b/module/fid/src/RecordTab/Worldcat.php @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category VuFind - * @package RecordTabs + * @package RecordTab * @author Demian Katz <demian.katz@villanova.edu> * @author André Lahmann <lahmann@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License @@ -32,7 +32,7 @@ namespace fid\RecordTab; * Staff view tab for AI records * * @category VuFind - * @package RecordTabs + * @package RecordTab * @author Demian Katz <demian.katz@villanova.edu> * @author Gregor Gawol <gawol@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License @@ -65,7 +65,11 @@ class Worldcat extends \VuFind\RecordTab\AbstractBase */ public function isActive() { - if (!$this->getRecordDriver()->tryMethod('hasRecordPermission', [$this->accessPermission])) { + $hasRecordPermission = $this->getRecordDriver()->tryMethod( + 'hasRecordPermission', + [$this->accessPermission] + ); + if (!$hasRecordPermission) { return false; } $oclc = $this->getRecordDriver()->tryMethod('getOCLC'); diff --git a/module/fid/src/Role/PermissionProvider/Factory.php b/module/fid/src/Role/PermissionProvider/Factory.php index 761c717d219..9c22dd2663f 100644 --- a/module/fid/src/Role/PermissionProvider/Factory.php +++ b/module/fid/src/Role/PermissionProvider/Factory.php @@ -37,8 +37,6 @@ use Zend\ServiceManager\ServiceManager; * @author Demian Katz <demian.katz@villanova.edu> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development:plugins:hierarchy_components Wiki - * - * @codeCoverageIgnore */ class Factory extends \VuFind\Role\PermissionProvider\Factory { diff --git a/module/fid/src/Role/PermissionProvider/FidApiPermission.php b/module/fid/src/Role/PermissionProvider/FidApiPermission.php index ce7763537a3..32fd4bc146c 100644 --- a/module/fid/src/Role/PermissionProvider/FidApiPermission.php +++ b/module/fid/src/Role/PermissionProvider/FidApiPermission.php @@ -25,7 +25,7 @@ * @author Demian Katz <demian.katz@villanova.edu> * @author Jochen Lienhard <lienhard@ub.uni-freiburg.de> * @author Ere Maijala <ere.maijala@helsinki.fi> - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Dorian Merz <merz@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org Main Page */ @@ -49,10 +49,17 @@ use VuFind\Role\PermissionProvider\PermissionProviderInterface; class FidApiPermission implements PermissionProviderInterface { /** + * Fid client + * * @var FidApiClient */ - private $client; + protected $client; + /** + * FidApiPermission constructor. + * + * @param FidApiClient $client fid client + */ public function __construct(FidApiClient $client) { $this->client = $client; diff --git a/module/fid/src/Serializer/OrderCreationRequestUserNormalizer.php b/module/fid/src/Serializer/OrderCreationRequestUserNormalizer.php index 6eafa10b223..70bcfcc0574 100644 --- a/module/fid/src/Serializer/OrderCreationRequestUserNormalizer.php +++ b/module/fid/src/Serializer/OrderCreationRequestUserNormalizer.php @@ -2,6 +2,8 @@ /** * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,9 +17,15 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * Serializer for Order Requests to FIDIS API + * https://git.sc.uni-leipzig.de/ubl/finc/fid/fidis/-/blob/master/bundle/Entity/Order.php + * + * @category VuFind + * @package Serializer + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Serializer; @@ -26,11 +34,33 @@ use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; +/** + * Class OrderCreationRequestUserNormalizer + * + * Serializer for Order Requests to FIDIS API + * https://git.sc.uni-leipzig.de/ubl/finc/fid/fidis/-/blob/master/bundle/Entity/Order.php + * + * @category VuFind + * @package Serializer + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class OrderCreationRequestUserNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface { use NormalizerAwareTrait; + /** + * {@inheritdoc} + * + * @param mixed $data Order data + * @param null $format Format the normalization result will be encoded as + * @param array $context Context options for the normalizer + * + * @return bool true if Serializer supports normalization otherwise false + */ public function supportsNormalization( $data, $format = null, @@ -41,9 +71,11 @@ class OrderCreationRequestUserNormalizer implements } /** - * @param mixed|User $object - * @param null $format - * @param array $context + * {@inheritdoc} + * + * @param mixed|User $object Object to normalize + * @param null $format Format the normalization result will be encoded as + * @param array $context Context options for the normalizer * * @return array|bool|float|int|string */ diff --git a/module/fid/src/Service/Client.php b/module/fid/src/Service/Client.php index 5a37773170d..0cafa080f93 100644 --- a/module/fid/src/Service/Client.php +++ b/module/fid/src/Service/Client.php @@ -1,7 +1,11 @@ <?php /** + * Fidis client + * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,8 +19,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service; @@ -38,6 +45,15 @@ use Symfony\Component\Serializer\SerializerInterface; use VuFind\Cookie\CookieManager; use Zend\Session\Container as Session; +/** + * FID client class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class Client { protected const ERRMSG_HTTPCLIENT @@ -46,62 +62,44 @@ class Client protected const ERRMSG_HTTPRESPONSE = 'An unexcected http response occured.'; - /** - * @var string - */ + /* @var string */ protected $config; - /** - * @var Session - */ + /* @var Session */ protected $session; - /** - * @var CookieManager - */ + /* @var CookieManager */ protected $cookies; - /** - * @var SerializerInterface - */ + /* @var SerializerInterface */ protected $serializer; - /** - * @var HttpClientInterface - */ + /* @var HttpClientInterface */ protected $httpClient; - /** - * @var UriFactoryInterface - */ + /* @var UriFactoryInterface */ protected $uriFactory; - /** - * @var StreamFactoryInterface - */ + /* @var StreamFactoryInterface */ protected $streamFactory; - /** - * @var RequestFactoryInterface - */ + /* @var RequestFactoryInterface */ protected $requestFactory; - /** - * @var string - */ + /* @var string */ protected $locale = 'en'; /** * Client constructor. * - * @param array $config - * @param Session $session - * @param CookieManager $cookies - * @param SerializerInterface $serializer - * @param HttpClientInterface $httpClient - * @param UriFactoryInterface $uriFactory - * @param StreamFactoryInterface $streamFactory - * @param RequestFactoryInterface $requestFactory + * @param array $config config + * @param Session $session session + * @param CookieManager $cookies cookies + * @param SerializerInterface $serializer serializer + * @param HttpClientInterface $httpClient httpClient + * @param UriFactoryInterface $uriFactory uriFactory + * @param StreamFactoryInterface $streamFactory streamFactory + * @param RequestFactoryInterface $requestFactory requestFactory */ public function __construct( array $config, @@ -124,13 +122,22 @@ class Client } /** - * @param string $locale + * Set local for translations + * + * @param string $locale locale + * + * @return void */ public function setLocale(string $locale): void { $this->locale = $locale; } + /** + * Get if user is logged in + * + * @return bool + */ public function isLoggedOn(): bool { try { @@ -141,9 +148,12 @@ class Client } /** - * @param string[] $credentials + * Get user logon + * + * @param string ...$credentials credentials * * @return Logon + * * @throws ClientException */ public function logon(string ...$credentials): Logon @@ -175,8 +185,10 @@ class Client } /** - * @param string $username - * @param string $password + * Check credentials + * + * @param string $username username + * @param string $password password * * @return bool */ @@ -196,6 +208,10 @@ class Client } /** + * Logout + * + * @return void + * * @throws ClientException */ public function logoff(): void @@ -222,9 +238,12 @@ class Client } /** - * @param Order $order + * Request creation of an order + * + * @param Order $order order * * @return Order + * * @throws ClientException */ public function requestOrderCreation(Order $order): Order @@ -243,9 +262,7 @@ class Client if ($response->getStatusCode() !== 201) { $this->throwException($response); } - /** - * @var Order $result - */ + /* @var Order $result */ $result = $this->serializer->deserialize( (string)$response->getBody(), Order::class, @@ -259,6 +276,15 @@ class Client return $result; } + /** + * Get record by id + * + * @param string $recordid record_id + * + * @return Record + * + * @throws ClientException + */ public function requestRecord(string $recordid) : Record { $request = $this->buildRequest('get', "records/$recordid"); @@ -267,9 +293,7 @@ class Client if ($response->getStatusCode() !== 200) { $this->throwException($response); } - /** - * @var Record $record - */ + /* @var Record $record */ $record = $this->serializer->deserialize( (string)$response->getBody(), Record::class, @@ -280,7 +304,10 @@ class Client } /** + * Get list of orders + * * @return array|Order[] + * * @throws ClientException */ public function requestOrderList(): array @@ -291,9 +318,7 @@ class Client if ($response->getStatusCode() !== 200) { $this->throwException($response); } - /** - * @var Order[] $list - */ + /* @var Order[] $list */ $list = $this->serializer->deserialize( (string)$response->getBody(), Order::class . '[]', @@ -311,7 +336,13 @@ class Client } /** + * Get order by id + * TODO: Why can id be null? + * + * @param null $orderId order identifier + * * @return Order|null + * * @throws ClientException * @throws UserNotAuthorizedException */ @@ -324,9 +355,7 @@ class Client $this->throwException($response); } - /** - * @var Order $order - */ + /* @var Order $order */ $order = $this->serializer->deserialize( (string)$response->getBody(), Order::class, @@ -337,13 +366,21 @@ class Client } /** - * @param Order $user + * Update order + * + * @param Order $order order + * * @return bool + * * @throws ClientException */ public function requestOrderUpdate(Order $order) : bool { - $body = $this->serializer->serialize($order, 'json', ['groups' => ['order:update:request']]); + $body = $this->serializer->serialize( + $order, + 'json', + ['groups' => ['order:update:request']] + ); $request = $this->buildRequest('put', "orders/{$order->getId()}", $body); $response = $this->sendAuthenticatedRequest($request); @@ -356,10 +393,14 @@ class Client } /** - * @param string $baseUrl - * @param string $username - * @param string $firstname - * @param string $lastname + * Request registration link + * + * @param string $baseUrl baseUrl + * @param string $username username + * @param string $firstname firstname + * @param string $lastname lastname + * + * @return void * * @throws ClientException */ @@ -386,10 +427,13 @@ class Client } /** - * @param string $baseUrl - * @param string $username + * Request (new) password link by mail + * + * @param string $baseUrl base url + * @param string $username username * * @return void + * * @throws ClientException */ public function requestPasswordLink(string $baseUrl, string $username): void @@ -404,8 +448,12 @@ class Client } /** - * @param string $baseUrl - * @param string $username + * Request (new) username link by mail + * + * @param string $baseUrl base url + * @param string $username username + * + * @return void * * @throws ClientException */ @@ -421,23 +469,28 @@ class Client } /** + * Get user details + * + * @param null $userId user identifier + * @param bool $forceReload force reload + * * @return User|null + * * @throws ClientException * @throws UserNotAuthorizedException + * @throws UserNotLoggedinException */ - public function requestUserDetails($userId = null, $forceRelaod = false): ?User + public function requestUserDetails($userId = null, $forceReload = false): ?User { $logon = $this->restoreLogon(); - /** - * @var User $user - */ + /* @var User $user */ $user = $this->session['user'] ?? null; $ownId = $logon->getOwnerId(); if (null === $userId || $userId === $ownId) { // user asks for own profile data - if (!empty($user) && !$forceRelaod) { + if (!empty($user) && !$forceReload) { return $user; } $userId = $ownId; @@ -453,9 +506,7 @@ class Client $this->throwException($response); } - /** - * @var User $user - */ + /* @var User $user */ $user = $this->serializer->deserialize( (string)$response->getBody(), User::class, @@ -470,9 +521,12 @@ class Client } /** - * @param User $user + * Create new user + * + * @param User $user user data * * @return User + * * @throws ClientException */ public function requestUserCreation(User $user): User @@ -491,9 +545,7 @@ class Client if ($response->getStatusCode() !== 201) { $this->throwException($response); } - /** - * @var User $result - */ + /* @var User $result */ $result = $this->serializer->deserialize( (string)$response->getBody(), User::class, @@ -505,9 +557,12 @@ class Client } /** - * @param User $user + * Update user + * + * @param User $user user * * @return User + * * @throws ClientException */ public function requestUserUpdate(User $user): User @@ -516,9 +571,12 @@ class Client } /** - * @param User $user + * Update password + * + * @param User $user user * * @return User + * * @throws ClientException */ public function requestUserPasswordUpdate(User $user): User @@ -530,9 +588,12 @@ class Client } /** - * @param User $user + * Update username + * + * @param User $user user * * @return User + * * @throws ClientException */ public function requestUserUsernameUpdate(User $user): User @@ -546,7 +607,10 @@ class Client } /** + * Get list of users + * * @return User[] + * * @throws ClientException * @throws UserNotAuthorizedException */ @@ -566,9 +630,7 @@ class Client if ($response->getStatusCode() !== 200) { $this->throwException($response); } - /** - * @var Library[] $list - */ + /* @var Library[] $list */ $list = $this->serializer->deserialize( (string)$response->getBody(), User::class . '[]', @@ -585,17 +647,27 @@ class Client return $this->session['users'] = array_combine($keys, $list); } + /** + * Empty user list from session + * + * @return void + */ public function flushUserList() { unset($this->session['users']); } /** - * throws an Exception in case the user does not have the requested permission + * Authorize user + * + * Throws an Exception in case the user does not have the requested permission * or the permission cannot be verified * - * @param String $permission Name of the permission - * @param User|null $user user object or null if we want to validate the currently logged in user + * @param String $permission Name of the permission + * @param User|null $user user or null for the currently logged in user + * + * @return void + * * @throws ClientException * @throws UserNotLoggedinException * @throws UserNotAuthorizedException @@ -619,9 +691,12 @@ class Client } /** - * @param String $permission + * Check if user is authorized + * + * @param String $permission name of permission * * @return bool + * * @throws ClientException */ public function isAuthorized(String $permission) @@ -635,7 +710,10 @@ class Client } /** + * Get list of libraries + * * @return Library[] + * * @throws ClientException */ public function requestLibraryList(): array @@ -650,9 +728,7 @@ class Client if ($response->getStatusCode() !== 200) { $this->throwException($response); } - /** - * @var Library[] $list - */ + /* @var Library[] $list */ $list = $this->serializer->deserialize( (string)$response->getBody(), Library::class . '[]', @@ -677,8 +753,12 @@ class Client } /** - * @param $id + * Get library by id + * + * @param $id identifier + * * @return Library + * * @throws ClientException */ public function requestLibraryById($id): Library @@ -694,9 +774,7 @@ class Client $this->throwException($response); } - /** - * @var Library $list - */ + /* @var Library $list */ $library = $this->serializer->deserialize( (string)$response->getBody(), Library::class, @@ -714,14 +792,18 @@ class Client $this->session->homeLibrary = []; } - return $this->session->homeLibrary[$this->locale] = array_combine($phpTypeCasting, [$library])[$id]; + return $this->session->homeLibrary[$this->locale] + = array_combine($phpTypeCasting, [$library])[$id]; } /** - * @param User $user - * @param array $groups + * Do update user + * + * @param User $user user + * @param array $groups groups * * @return User + * * @throws ClientException */ protected function doRequestUserUpdate(User $user, array $groups): User @@ -733,9 +815,7 @@ class Client if ($response->getStatusCode() !== 200) { $this->throwException($response); } - /** - * @var User $result - */ + /* @var User $result */ $result = $this->serializer->deserialize( (string)$response->getBody(), User::class, @@ -752,7 +832,12 @@ class Client } /** + * Refresh logon + * + * @param Logon $logon logon + * * @return Logon + * * @throws ClientException */ protected function refreshLogon(Logon $logon): Logon @@ -776,10 +861,13 @@ class Client } /** - * @param RequestInterface $request - * @param bool $retryOn401 + * Send request for authentication + * + * @param RequestInterface $request request + * @param bool $retryOn401 retry if http status is Unauthorized * * @return ResponseInterface + * * @throws ClientException */ protected function sendAuthenticatedRequest( @@ -799,9 +887,12 @@ class Client } /** - * @param RequestInterface $request + * Send request + * + * @param RequestInterface $request request * * @return ResponseInterface + * * @throws ClientException */ protected function sendRequest(RequestInterface $request): ResponseInterface @@ -813,6 +904,16 @@ class Client } } + /** + * Build request object + * + * @param string $verb verb + * @param string $path path + * @param string $body body + * @param array $query query + * + * @return RequestInterface + */ protected function buildRequest( string $verb, string $path, @@ -844,7 +945,11 @@ class Client } /** - * @param ResponseInterface $response + * Throw exception + * + * @param ResponseInterface $response response + * + * @return void * * @throws ClientException */ @@ -856,14 +961,15 @@ class Client } /** + * Restore logon + * * @return Logon + * * @throws ClientException */ protected function restoreLogon(): Logon { - /** - * @var Logon $logon - */ + /* @var Logon $logon */ if ($logon = $this->session['logon'] ?? null) { $logon->setToken($this->cookies->get('finc_fid_logon')); if (time() < $logon->getExpiresAt()) { @@ -876,6 +982,13 @@ class Client throw new ClientException('Missing or expired logon.', 401); } + /** + * Store logon + * + * @param Logon $logon logon + * + * @return Logon + */ protected function storeLogon(Logon $logon): Logon { $this->cookies->set('finc_fid_logon', $token = $logon->getToken()); @@ -885,12 +998,17 @@ class Client return $logon; } + /** + * Parse logon + * + * @param string $logon logon + * + * @return Logon + */ protected function parseLogon(string $logon): Logon { $logon = $this->serializer->deserialize($logon, Logon::class, 'json'); - /** - * @var Logon $logon - */ + /* @var Logon $logon */ return $logon; } } diff --git a/module/fid/src/Service/ClientException.php b/module/fid/src/Service/ClientException.php index 3e10451c98f..1691046a5f9 100644 --- a/module/fid/src/Service/ClientException.php +++ b/module/fid/src/Service/ClientException.php @@ -1,7 +1,11 @@ <?php /** + * Fidis client exception + * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,11 +19,23 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service; +/** + * FID client exception class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class ClientException extends \Exception { } diff --git a/module/fid/src/Service/ClientFactory.php b/module/fid/src/Service/ClientFactory.php index 5e9af766797..4b949464590 100644 --- a/module/fid/src/Service/ClientFactory.php +++ b/module/fid/src/Service/ClientFactory.php @@ -1,6 +1,10 @@ <?php /** - * Copyright (C) 2020 Leipzig University Library + * Fidis client factory + * + * Copyright (C) 2019 Leipzig University Library + * + * PHP version 7 * * 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 @@ -15,8 +19,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service; @@ -31,47 +38,42 @@ use VuFind\Cookie\CookieManager; use Zend\Session\Container as Session; use Zend\Session\SessionManager; +/** + * FID client factory class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class ClientFactory { /** - * @param ContainerInterface $container + * Invoke Client + * + * @param ContainerInterface $container container * * @return Client */ public function __invoke(ContainerInterface $container): Client { - /** - * @var ClientConfigListener $clientConfigListener - */ + /* @var ClientConfigListener $clientConfigListener */ $clientConfigListener = $container->get(ClientConfigListener::class); - /** - * @var SessionManager $sessionManager - */ + /* @var SessionManager $sessionManager */ $sessionManager = $container->get(SessionManager::class); $session = new Session(Client::class, $sessionManager); - /** - * @var CookieManager $cookies - */ + /* @var CookieManager $cookies */ $cookies = $container->get(CookieManager::class); - /** - * @var SerializerInterface $serializer - */ + /* @var SerializerInterface $serializer */ $serializer = $container->get(SerializerInterface::class); - /** - * @var HttpClientInterface $httpClient - */ + /* @var HttpClientInterface $httpClient */ $httpClient = $container->get(HttpClientInterface::class); - /** - * @var UriFactoryInterface $uriFactory - */ + /* @var UriFactoryInterface $uriFactory */ $uriFactory = $container->get(UriFactoryInterface::class); - /** - * @var StreamFactoryInterface $streamFactory - */ + /* @var StreamFactoryInterface $streamFactory */ $streamFactory = $container->get(StreamFactoryInterface::class); - /** - * @var RequestFactoryInterface $requestFactory - */ + /* @var RequestFactoryInterface $requestFactory */ $requestFactory = $container->get(RequestFactoryInterface::class); return new Client( diff --git a/module/fid/src/Service/DataTransferObject/Address.php b/module/fid/src/Service/DataTransferObject/Address.php index 8b1ea912994..de9a6ca6883 100644 --- a/module/fid/src/Service/DataTransferObject/Address.php +++ b/module/fid/src/Service/DataTransferObject/Address.php @@ -1,7 +1,11 @@ <?php /** + * Dto for fid address data + * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,16 +19,30 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service\DataTransferObject; use Symfony\Component\Serializer\Annotation\Groups; +/** + * FID address dto class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class Address { /** + * Address identifier + * * @var string|null * @Groups({ * "user:details:response", @@ -35,12 +53,12 @@ class Address */ protected $id; - /** - * @var User|null - */ + /* @var User|null */ protected $user; /** + * First address line + * * @var string|null * @Groups({ * "user:details:response", @@ -53,6 +71,8 @@ class Address protected $line1; /** + * Second address line + * * @var string|null * @Groups({ * "user:details:response", @@ -65,6 +85,8 @@ class Address protected $line2; /** + * Postal + * * @var string|null * @Groups({ * "user:details:response", @@ -77,6 +99,8 @@ class Address protected $zip; /** + * Town + * * @var string|null * @Groups({ * "user:details:response", @@ -89,6 +113,8 @@ class Address protected $city; /** + * Country + * * @var string|null * @Groups({ * "user:details:response", @@ -101,6 +127,8 @@ class Address protected $country; /** + * Get address identifier + * * @return string|null */ public function getId(): ?string @@ -109,7 +137,11 @@ class Address } /** - * @param string|null $id + * Get address identifier + * + * @param string|null $id identifier + * + * @return void */ public function setId(?string $id): void { @@ -117,22 +149,30 @@ class Address } /** - * @return User|null + * Set user + * + * @param User|null $user User + * + * @return void */ - public function getUser(): ?User + public function setUser(?User $user): void { - return $this->user; + $this->user = $user; } /** - * @param User|null $user + * Get user + * + * @return User|null */ - public function setUser(?User $user): void + public function getUser(): ?User { - $this->user = $user; + return $this->user; } /** + * Get first line + * * @return string|null */ public function getLine1(): ?string @@ -141,7 +181,11 @@ class Address } /** - * @param string|null $line1 + * Set first line + * + * @param string|null $line1 first line + * + * @return void */ public function setLine1(?string $line1): void { @@ -149,6 +193,8 @@ class Address } /** + * Get second line + * * @return string|null */ public function getLine2(): ?string @@ -157,7 +203,11 @@ class Address } /** - * @param string|null $line2 + * Set second line + * + * @param string|null $line2 second line + * + * @return void */ public function setLine2(?string $line2): void { @@ -165,6 +215,8 @@ class Address } /** + * Get postal + * * @return string|null */ public function getZip(): ?string @@ -173,7 +225,11 @@ class Address } /** - * @param string|null $zip + * Set postal + * + * @param string|null $zip postal + * + * @return void */ public function setZip(?string $zip): void { @@ -181,7 +237,9 @@ class Address } /** - * @return string|null + * Get town + * + * @return string|null town */ public function getCity(): ?string { @@ -189,7 +247,11 @@ class Address } /** - * @param string|null $city + * Set town + * + * @param string|null $city town + * + * @return void */ public function setCity(?string $city): void { @@ -197,6 +259,8 @@ class Address } /** + * Get country + * * @return string|null */ public function getCountry(): ?string @@ -205,18 +269,34 @@ class Address } /** - * @param string|null $country + * Set country + * + * @param string|null $country country + * + * @return void */ public function setCountry(?string $country): void { $this->country = $country; } + /** + * Represent object as a string + * + * @return string + */ public function __toString() { - return $this->id . ': ' . $this->line1 . ' ' . $this->line2 . '; ' . $this->zip . ' ' . $this->city . '; ' . $this->country; + return $this->id . ': ' . $this->line1 . ' ' + . $this->line2 . '; ' . $this->zip . ' ' + . $this->city . '; ' . $this->country; } + /** + * Check if line1, zip and city is set + * + * @return bool + */ public function isCompleteAddress() : bool { return strlen($this->line1) > 0 diff --git a/module/fid/src/Service/DataTransferObject/Library.php b/module/fid/src/Service/DataTransferObject/Library.php index 56a0e84bb5e..3063dc9c522 100644 --- a/module/fid/src/Service/DataTransferObject/Library.php +++ b/module/fid/src/Service/DataTransferObject/Library.php @@ -1,6 +1,10 @@ <?php /** - * Copyright (C) 2019 Leipzig University Library + * FID dto for libraries + * + * Copyright (C) 2019 Leipzig University Library + * + * PHP version 7 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,49 +19,49 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license https://opensource.org/licenses/GPL-3.0 GNU GPLv3 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service\DataTransferObject; +/** + * FID library dto class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class Library { - /** - * @var string - */ + /* @var string */ protected $id; - /** - * @var string - */ + /* @var string */ protected $ezb = ''; - /** - * @var string - */ + /* @var string */ protected $dbis = ''; - /** - * @var string - */ + /* @var string */ protected $network = ''; - /** - * @var string - */ + /* @var string */ protected $boss = ''; - /** - * @var string - */ + /* @var string */ protected $isil = ''; - /** - * @var string - */ + /* @var string */ protected $label = ''; /** + * Get identifier + * * @return string */ public function getId(): string @@ -66,7 +70,11 @@ class Library } /** - * @param string $id + * Set identifier + * + * @param string $id identifier + * + * @return void */ public function setId(string $id): void { @@ -74,6 +82,8 @@ class Library } /** + * Get Electronic Journal Database + * * @return string */ public function getEzb(): string @@ -82,7 +92,11 @@ class Library } /** - * @param string $ezb + * Get Electronic Journal Database + * + * @param string $ezb ezb + * + * @return void */ public function setEzb(string $ezb): void { @@ -90,6 +104,8 @@ class Library } /** + * Get Database Information System + * * @return string */ public function getDbis(): string @@ -98,7 +114,11 @@ class Library } /** - * @param string $dbis + * Set Database Information System + * + * @param string $dbis dbis + * + * @return void */ public function setDbis(string $dbis): void { @@ -106,6 +126,8 @@ class Library } /** + * Get network + * * @return string */ public function getNetwork(): string @@ -114,7 +136,11 @@ class Library } /** - * @param string $network + * Set Network + * + * @param string $network network + * + * @return void */ public function setNetwork(string $network): void { @@ -122,6 +148,8 @@ class Library } /** + * Get BSZ One Stop Search + * * @return string */ public function getBoss(): string @@ -130,7 +158,11 @@ class Library } /** - * @param string $boss + * Set BSZ One Stop Search + * + * @param string $boss BOSS + * + * @return void */ public function setBoss(string $boss): void { @@ -138,6 +170,8 @@ class Library } /** + * Get international standard identifier + * * @return string */ public function getIsil(): string @@ -146,7 +180,11 @@ class Library } /** - * @param string $isil + * Set international standard identifier + * + * @param string $isil ISIL + * + * @return void */ public function setIsil(string $isil): void { @@ -154,6 +192,8 @@ class Library } /** + * Get label + * * @return string */ public function getLabel(): string @@ -162,7 +202,11 @@ class Library } /** - * @param string $label + * Set label + * + * @param string $label label + * + * @return void */ public function setLabel(string $label): void { diff --git a/module/fid/src/Service/DataTransferObject/Logon.php b/module/fid/src/Service/DataTransferObject/Logon.php index 25afa7aec6e..9d2b43e510b 100644 --- a/module/fid/src/Service/DataTransferObject/Logon.php +++ b/module/fid/src/Service/DataTransferObject/Logon.php @@ -1,7 +1,11 @@ <?php /** + * Dto for fid session + * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,44 +19,46 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service\DataTransferObject; +/** + * FID logon dto class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class Logon { - /** - * @var string|null - */ + /* @var string|null */ protected $username; - /** - * @var string|null - */ + /* @var string|null */ protected $password; - /** - * @var int|null - */ + /* @var int|null */ protected $stalesAt; - /** - * @var int|null - */ + /* @var int|null */ protected $expiresAt; - /** - * @var string|null - */ + /* @var string|null */ protected $token; - /** - * @var string|null - */ + /* @var string|null */ protected $ownerId; /** + * Get name of user + * * @return string|null */ public function getUsername(): ?string @@ -61,7 +67,11 @@ class Logon } /** - * @param string|null $username + * Set name of user + * + * @param string|null $username username + * + * @return void */ public function setUsername(?string $username): void { @@ -69,6 +79,8 @@ class Logon } /** + * Get user password + * * @return string|null */ public function getPassword(): ?string @@ -77,7 +89,11 @@ class Logon } /** - * @param string|null $password + * Set user password + * + * @param string|null $password password + * + * @return void */ public function setPassword(?string $password): void { @@ -85,7 +101,9 @@ class Logon } /** - * @return string|null + * Get auth token + * + * @return string|null token */ public function getToken(): ?string { @@ -93,6 +111,8 @@ class Logon } /** + * Get time in seconds when logon will stale + * * @return int|null */ public function getStalesAt(): ?int @@ -101,7 +121,11 @@ class Logon } /** - * @param int|null $stalesAt + * Set time in seconds when logon will stale + * + * @param int|null $stalesAt stales at + * + * @return void */ public function setStalesAt(?int $stalesAt): void { @@ -109,6 +133,8 @@ class Logon } /** + * Get time in seconds when logon will expire + * * @return int|null */ public function getExpiresAt(): ?int @@ -117,7 +143,11 @@ class Logon } /** - * @param int|null $expiresAt + * Set time in seconds when logon will expire + * + * @param int|null $expiresAt expires at + * + * @return void */ public function setExpiresAt(?int $expiresAt): void { @@ -125,7 +155,11 @@ class Logon } /** - * @param string|null $token + * Set token + * + * @param string|null $token token + * + * @return void */ public function setToken(?string $token): void { @@ -133,6 +167,8 @@ class Logon } /** + * Get owner identifier + * * @return string|null */ public function getOwnerId(): ?string @@ -141,7 +177,11 @@ class Logon } /** - * @param string|null $ownerId + * Set owner identifier + * + * @param string|null $ownerId owner id + * + * @return void */ public function setOwnerId(?string $ownerId): void { diff --git a/module/fid/src/Service/DataTransferObject/Order.php b/module/fid/src/Service/DataTransferObject/Order.php index e368c3dee04..a93da5a43fb 100644 --- a/module/fid/src/Service/DataTransferObject/Order.php +++ b/module/fid/src/Service/DataTransferObject/Order.php @@ -1,7 +1,11 @@ <?php /** + * Dto for fid order + * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,8 +19,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service\DataTransferObject; @@ -24,9 +31,20 @@ namespace fid\Service\DataTransferObject; use Symfony\Component\Serializer\Annotation\Groups; +/** + * FID order dto class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class Order { /** + * Identifier + * * @var string|null * @Groups({ * "order:creation:response", @@ -40,6 +58,8 @@ class Order protected $id; /** + * Type of order + * * @var string * @Groups({ * "order:creation:request", @@ -54,6 +74,8 @@ class Order protected $type = ''; /** + * Label + * * @var string * @Groups({ * "order:creation:request", @@ -68,6 +90,8 @@ class Order protected $label = ''; /** + * User + * * @var User|null * @Groups({ * "order:creation:request", @@ -82,6 +106,8 @@ class Order protected $user; /** + * Custom data + * * @var array * @Groups({ * "order:creation:request", @@ -96,6 +122,8 @@ class Order protected $data = []; /** + * Creation time + * * @var \DateTime * @Groups({ * "order:creation:response", @@ -111,6 +139,8 @@ class Order public const DATETIME_FORMAT = 'Y-m-d H:i:s'; /** + * Get identifier + * * @return string|null */ public function getId(): ?string @@ -119,7 +149,11 @@ class Order } /** - * @param string|null $id + * Set identifier + * + * @param string|null $id identifier + * + * @return void */ public function setId(?string $id): void { @@ -127,6 +161,8 @@ class Order } /** + * Get label + * * @return string */ public function getLabel(): string @@ -135,7 +171,11 @@ class Order } /** - * @param string $label + * Set label + * + * @param string $label label + * + * @return void */ public function setLabel(string $label): void { @@ -143,6 +183,8 @@ class Order } /** + * Get type of order + * * @return string */ public function getType(): string @@ -151,7 +193,11 @@ class Order } /** - * @param string $type + * Set type of order + * + * @param string $type type + * + * @return void */ public function setType(string $type): void { @@ -159,6 +205,8 @@ class Order } /** + * Get fid user + * * @return User|null */ public function getUser(): ?User @@ -167,7 +215,11 @@ class Order } /** - * @param User|null $user + * Set fid user + * + * @param User|null $user user + * + * @return void */ public function setUser(?User $user): void { @@ -175,6 +227,8 @@ class Order } /** + * Get data - container for additional miscellaneous information + * * @return array */ public function getData(): array @@ -183,7 +237,11 @@ class Order } /** - * @param array $data + * Set data - container for additional miscellaneous information + * + * @param array $data custom data + * + * @return void */ public function setData(array $data): void { @@ -191,6 +249,8 @@ class Order } /** + * Get creation date + * * @return \DateTime */ public function getCreatedAt(): \DateTime @@ -199,27 +259,48 @@ class Order } /** - * @param \DateTime $createdAt + * Set creation date + * + * @param \DateTime $createdAt created at + * + * @return void */ public function setCreatedAt(\DateTime $createdAt): void { $this->createdAt = $createdAt; } + /** + * Get order label + * + * @return string + */ public function __toString() { return $this->getLabel(); } + /** + * Get due date + * + * @return \DateTime|null + */ public function getDueDate(): ? \DateTime { return (!empty($this->data['dueDate'])) - ? \DateTime::createFromFormat(self::DATETIME_FORMAT, $this->data['dueDate']) + ? \DateTime::createFromFormat( + self::DATETIME_FORMAT, + $this->data['dueDate'] + ) : null; } /** - * @param \DateTime $dueDate + * Set due date + * + * @param \DateTime $date due date + * + * @return void */ public function setDueDate(\DateTime $date) { @@ -228,11 +309,21 @@ class Order $this->setData($data); } + /** + * Get due date as string d.m.Y. + * + * @return String + */ public function displayDueDate(): String { return $this->getDueDate() ? $this->getDueDate()->format('d.m.Y') : ''; } + /** + * Check due date + * + * @return bool + */ public function isOverdue() : bool { if ($duedate = $this->getDueDate()) { @@ -244,6 +335,8 @@ class Order } /** + * Get order status + * * @return string */ public function getStatus(): ? string @@ -252,7 +345,11 @@ class Order } /** - * @param string $status + * Set order status + * + * @param string $status status + * + * @return void */ public function setStatus(?string $status): void { @@ -261,6 +358,11 @@ class Order } } + /** + * Get record identifier + * + * @return mixed|null + */ public function getRecordId() { return $this->data['record']['id'] ?? null; diff --git a/module/fid/src/Service/DataTransferObject/Record.php b/module/fid/src/Service/DataTransferObject/Record.php index f2981bd704e..715f44aefe5 100644 --- a/module/fid/src/Service/DataTransferObject/Record.php +++ b/module/fid/src/Service/DataTransferObject/Record.php @@ -1,6 +1,10 @@ <?php /** - * Copyright (C) 2019 Leipzig University Library + * Dto for short record representation in fid (orders) + * + * Copyright (C) 2019 Leipzig University Library + * + * PHP version 7 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,24 +19,34 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license https://opensource.org/licenses/GPL-3.0 GNU GPLv3 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service\DataTransferObject; +/** + * FID order dto class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class Record { - /** - * @var string - */ + /* @var string */ protected $id; - /** - * @var bool - */ + /* @var bool */ protected $ordered = ''; /** + * Get identifier + * * @return string */ public function getId(): string @@ -41,7 +55,11 @@ class Record } /** - * @param string $id + * Set identifier + * + * @param string $id record_id + * + * @return void */ public function setId(string $id): void { @@ -49,6 +67,8 @@ class Record } /** + * Get is ordered + * * @return bool */ public function getOrdered(): bool @@ -57,7 +77,11 @@ class Record } /** - * @param bool $ordered + * Set is ordered + * + * @param bool $ordered is Ordered + * + * @return void */ public function setOrdered(bool $ordered): void { diff --git a/module/fid/src/Service/DataTransferObject/User.php b/module/fid/src/Service/DataTransferObject/User.php index 42c642eff19..b7ef437c664 100644 --- a/module/fid/src/Service/DataTransferObject/User.php +++ b/module/fid/src/Service/DataTransferObject/User.php @@ -1,7 +1,11 @@ <?php /** + * Dto for fid user + * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,16 +19,30 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service\DataTransferObject; use Symfony\Component\Serializer\Annotation\Groups; +/** + * FID order dto class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class User { /** + * Identifier + * * @var null|string * @Groups({ * "order:creation:response", @@ -38,6 +56,8 @@ class User protected $id; /** + * Username + * * @var null|string * @Groups({ * "order:creation:response", @@ -53,6 +73,8 @@ class User protected $username; /** + * Password + * * @var null|string * @Groups({ * "user:details:response", @@ -63,6 +85,8 @@ class User protected $password; /** + * Salutation + * * @var string * @Groups({ * "user:details:response", @@ -75,6 +99,8 @@ class User protected $salutation; /** + * Academic title + * * @var string * @Groups({ * "user:details:response", @@ -87,6 +113,8 @@ class User protected $academicTitle; /** + * Firstname + * * @var null|string * @Groups({ * "order:creation:response", @@ -102,6 +130,8 @@ class User protected $firstname; /** + * Lastname + * * @var null|string * @Groups({ * "order:creation:response", @@ -117,6 +147,8 @@ class User protected $lastname; /** + * Home library + * * @var null|string * @Groups({ * "user:details:response", @@ -129,6 +161,8 @@ class User protected $homeLibrary; /** + * College + * * @var string * @Groups({ * "user:details:response", @@ -141,6 +175,8 @@ class User protected $college = ''; /** + * Job title + * * @var string * @Groups({ * "user:details:response", @@ -153,6 +189,8 @@ class User protected $jobTitle = ''; /** + * Addresses + * * @var Address[] * @Groups({ * "user:details:response", @@ -165,6 +203,8 @@ class User protected $addresses = []; /** + * Orders + * * @var Order[] * @Groups({ * "user:details:response", @@ -175,6 +215,8 @@ class User protected $orders = []; /** + * Permissions + * * @var array[] * @Groups({ * "user:details:response", @@ -187,6 +229,8 @@ class User protected $permissions = []; /** + * Custom Data + * * @var array * @Groups({ * "user:details:response", @@ -202,7 +246,7 @@ class User * Magic function as shortcut for all getters * TODO ensure public visibility of all called getters * - * @param $name + * @param $name name * * @return |null */ @@ -217,6 +261,8 @@ class User } /** + * Get identifier + * * @return string|null */ public function getId(): ?string @@ -225,7 +271,11 @@ class User } /** - * @param string|null $id + * Set identifier + * + * @param string|null $id id + * + * @return void */ public function setId(?string $id): void { @@ -233,6 +283,8 @@ class User } /** + * Get username + * * @return string|null */ public function getUsername(): ?string @@ -241,7 +293,11 @@ class User } /** - * @param string|null $username + * Set username + * + * @param string|null $username username + * + * @return void */ public function setUsername(?string $username): void { @@ -249,6 +305,8 @@ class User } /** + * Get password + * * @return string|null */ public function getPassword(): ?string @@ -257,7 +315,11 @@ class User } /** - * @param string|null $password + * Set password + * + * @param string|null $password password + * + * @return void */ public function setPassword(?string $password): void { @@ -265,6 +327,8 @@ class User } /** + * Get salutation + * * @return string|null */ public function getSalutation(): ?string @@ -273,7 +337,11 @@ class User } /** - * @param string|null $salutation + * Set salutation + * + * @param string|null $salutation salutation + * + * @return void */ public function setSalutation(?string $salutation): void { @@ -281,6 +349,8 @@ class User } /** + * Get academic title + * * @return string|null */ public function getAcademicTitle(): ?string @@ -289,7 +359,11 @@ class User } /** - * @param string|null $academicTitle + * Set academic title + * + * @param string|null $academicTitle academic title + * + * @return void */ public function setAcademicTitle(?string $academicTitle): void { @@ -297,6 +371,8 @@ class User } /** + * Get firsname + * * @return string|null */ public function getFirstname(): ?string @@ -305,7 +381,11 @@ class User } /** - * @param string|null $firstname + * Set firstname + * + * @param string|null $firstname firstname + * + * @return void */ public function setFirstname(?string $firstname): void { @@ -313,6 +393,8 @@ class User } /** + * Get lastname + * * @return string|null */ public function getLastname(): ?string @@ -321,7 +403,11 @@ class User } /** - * @param string|null $lastname + * Set lastname + * + * @param string|null $lastname lastname + * + * @return void */ public function setLastname(?string $lastname): void { @@ -329,6 +415,8 @@ class User } /** + * Get home library + * * @return string */ public function getHomeLibrary(): string @@ -337,7 +425,11 @@ class User } /** - * @param string $homeLibrary + * Set home library + * + * @param string $homeLibrary home library + * + * @return void */ public function setHomeLibrary(string $homeLibrary): void { @@ -345,6 +437,8 @@ class User } /** + * Get collage + * * @return string */ public function getCollege(): string @@ -353,7 +447,11 @@ class User } /** - * @param string $college + * Set collage + * + * @param string $college college + * + * @return void */ public function setCollege(string $college): void { @@ -361,6 +459,8 @@ class User } /** + * Get job title + * * @return string|null */ public function getJobTitle(): ?string @@ -369,7 +469,11 @@ class User } /** - * @param string|null $jobTitle + * Set job title + * + * @param string|null $jobTitle job title + * + * @return void */ public function setJobTitle(?string $jobTitle): void { @@ -377,6 +481,8 @@ class User } /** + * Get addresses + * * @return Address[] */ public function getAddresses(): array @@ -385,6 +491,8 @@ class User } /** + * Get delivery address + * * @return Address | null */ public function getDeliveryAddress(): ?Address @@ -392,11 +500,14 @@ class User if (empty($addresses = $this->getAddresses())) { return null; } - $addressIndex = !empty($this->getData()["deliveryAddress"]) ? $this->getData()["deliveryAddress"] : 0; + $addressIndex = !empty($this->getData()["deliveryAddress"]) ? + $this->getData()["deliveryAddress"] : 0; return $addresses[$addressIndex]; } /** + * Get deleted flag + * * @return bool */ public function isDeleted(): bool @@ -405,6 +516,10 @@ class User } /** + * Set deleted flag + * + * @param bool $delete delete + * * @return void */ public function setDeleted(bool $delete): void @@ -416,7 +531,10 @@ class User } /** - * @param string $deletedAt + * Set deleted at + * + * @param string $deletedAt deleted at + * * @return void */ public function setDeletedAt(string $deletedAt): void @@ -425,11 +543,14 @@ class User } /** + * Get whether delivery address is a business address + * * @return boolean */ public function deliveryAddressIsBusinessAddress(): bool { - $addressIndex = !empty($this->getData()["deliveryAddress"]) ? $this->getData()["deliveryAddress"] : 0; + $addressIndex = !empty($this->getData()["deliveryAddress"]) ? + $this->getData()["deliveryAddress"] : 0; if ($addressIndex == 0) { return true; } else { @@ -438,15 +559,22 @@ class User } /** + * Get if user has subscribed a fid newsletter + * * @return boolean */ public function isNewsletter(): bool { - return !empty($this->getData()["newsletter"]) ? $this->getData()["newsletter"] : 0; + return !empty($this->getData()["newsletter"]) ? + $this->getData()["newsletter"] : 0; } /** - * @param Address[] $addresses + * Set addresses + * + * @param Address[] $addresses addresses + * + * @return void */ public function setAddresses(array $addresses): void { @@ -457,6 +585,8 @@ class User } /** + * Get orders + * * @return Order[] */ public function getOrders(): array @@ -465,7 +595,11 @@ class User } /** - * @param Order[] $orders + * Set orders + * + * @param Order[] $orders orders + * + * @return void */ public function setOrders(array $orders): void { @@ -476,7 +610,11 @@ class User } /** - * @param Order $order + * Add order + * + * @param Order $order order + * + * @return void */ public function addOrder($order): void { @@ -484,6 +622,8 @@ class User } /** + * Get permissions + * * @return array[] */ public function getPermissions(): array @@ -492,13 +632,24 @@ class User } /** - * @param array[] $permissions + * Set permissions + * + * @param array[] $permissions permissions + * + * @return void */ public function setPermissions(array $permissions): void { $this->permissions = $permissions; } + /** + * Check is user has given permission + * + * @param $permission permission + * + * @return bool + */ public function hasPermission($permission): bool { if (isset($this->permissions[$permission]) @@ -510,6 +661,8 @@ class User } /** + * Get custom data + * * @return array */ public function getData(): array @@ -518,7 +671,11 @@ class User } /** - * @param array $data + * Set custom data + * + * @param array $data data + * + * @return void */ public function setData(array $data): void { @@ -526,6 +683,8 @@ class User } /** + * Get libero id + * * @return string */ public function getLiberoId() : string @@ -533,6 +692,11 @@ class User return 'FID' . str_pad($this->getId(), 10, "0", STR_PAD_LEFT); } + /** + * Get all properties except password + * + * @return array + */ public function getFieldList() { $fields = []; @@ -545,6 +709,14 @@ class User return $fields; } + /** + * Export user data as string + * + * @param array $fields fields + * @param string $delimiter delimiter + * + * @return string + */ public function export($fields, $delimiter="\t") { $output = ''; diff --git a/module/fid/src/Service/UserAuthorizationException.php b/module/fid/src/Service/UserAuthorizationException.php index e8557c35035..d5ab5a59a5c 100644 --- a/module/fid/src/Service/UserAuthorizationException.php +++ b/module/fid/src/Service/UserAuthorizationException.php @@ -1,7 +1,11 @@ <?php /** + * Fidis client user authorization exception + * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,11 +19,23 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service; +/** + * FID client user authorization exception class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class UserAuthorizationException extends \Exception { } diff --git a/module/fid/src/Service/UserNotAuthorizedException.php b/module/fid/src/Service/UserNotAuthorizedException.php index f0845ad537c..366d2a3c0de 100644 --- a/module/fid/src/Service/UserNotAuthorizedException.php +++ b/module/fid/src/Service/UserNotAuthorizedException.php @@ -1,7 +1,11 @@ <?php /** + * Fidis client user unauthorized exception + * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,11 +19,23 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service; +/** + * FID client user unauthorized exception class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class UserNotAuthorizedException extends UserAuthorizationException { } diff --git a/module/fid/src/Service/UserNotLoggedinException.php b/module/fid/src/Service/UserNotLoggedinException.php index 37a27dbbbf5..d82071a071e 100644 --- a/module/fid/src/Service/UserNotLoggedinException.php +++ b/module/fid/src/Service/UserNotLoggedinException.php @@ -1,7 +1,11 @@ <?php /** + * Fidis client user logged-out exception + * * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,11 +19,23 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Service; +/** + * FID client user logged-out exception class + * + * @category VuFind + * @package Service + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class UserNotLoggedinException extends UserAuthorizationException { } diff --git a/module/fid/src/Validator/SubitoPartialCopyPageBounds.php b/module/fid/src/Validator/SubitoPartialCopyPageBounds.php index 35bc8a99f53..ab6569d778a 100644 --- a/module/fid/src/Validator/SubitoPartialCopyPageBounds.php +++ b/module/fid/src/Validator/SubitoPartialCopyPageBounds.php @@ -1,7 +1,11 @@ <?php /** + * Subito partial copy page bounds validator + * * Copyright (C) 2020 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,13 +19,25 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Alexander Purr <purr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Validator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Validator; use Zend\Validator\AbstractValidator; +/** + * Subito partial copy page bounds validator + * + * @category VuFind + * @package Validator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class SubitoPartialCopyPageBounds extends AbstractValidator { use SubitoPartialCopyPageRangeValidatorTrait; @@ -37,14 +53,23 @@ class SubitoPartialCopyPageBounds extends AbstractValidator self::PAGE_BOUNDS => "acquisition_error_page_bounds", ]; - public function isValid($value) + /** + * Validate if given page range is beetween first and last page of a record + * + * @param string $value From to page range + * + * @return bool + */ + public function isValid(string $value) : bool { if ($this->options['numberPages'] == null) { return false; } - $this->extractPages($value); + $this->_extractPages($value); - if (($this->pageEnd > $this->options['numberPages']) || ($this->pageStart < 1)) { + if (($this->_pageEnd > $this->options['numberPages']) + || ($this->_pageStart < 1) + ) { $this->error(self::PAGE_BOUNDS); return false; } else { diff --git a/module/fid/src/Validator/SubitoPartialCopyPageOrder.php b/module/fid/src/Validator/SubitoPartialCopyPageOrder.php index 0415c5a348d..8b8ef7b2e51 100644 --- a/module/fid/src/Validator/SubitoPartialCopyPageOrder.php +++ b/module/fid/src/Validator/SubitoPartialCopyPageOrder.php @@ -1,7 +1,11 @@ <?php /** + * Subito partial copy page order validator + * * Copyright (C) 2020 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,13 +19,25 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Alexander Purr <purr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Validator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Validator; use Zend\Validator\AbstractValidator; +/** + * Subito partial copy page order validator + * + * @category VuFind + * @package Validator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class SubitoPartialCopyPageOrder extends AbstractValidator { use SubitoPartialCopyPageRangeValidatorTrait; @@ -32,11 +48,18 @@ class SubitoPartialCopyPageOrder extends AbstractValidator self::PAGES_ORDER => "acquisition_error_page_order", ]; - public function isValid($value) + /** + * Validate if given page range is ordered correctly + * + * @param string $value From to page range + * + * @return bool + */ + public function isValid($value): bool { - $this->extractPages($value); + $this->_extractPages($value); - if ($this->pageStart > $this->pageEnd) { + if ($this->_pageStart > $this->_pageEnd) { $this->error(self::PAGES_ORDER); return false; } else { diff --git a/module/fid/src/Validator/SubitoPartialCopyPageRangeValidatorTrait.php b/module/fid/src/Validator/SubitoPartialCopyPageRangeValidatorTrait.php index ee91dbc6a10..87a4551c814 100644 --- a/module/fid/src/Validator/SubitoPartialCopyPageRangeValidatorTrait.php +++ b/module/fid/src/Validator/SubitoPartialCopyPageRangeValidatorTrait.php @@ -1,7 +1,11 @@ <?php /** + * Subito partial copy page range validator trait + * * Copyright (C) 2020 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,23 +19,42 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Alexander Purr <purr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Validator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Validator; use fid\Controller\RecordController; +/** + * Subito partial copy page range validator trait + * + * @category VuFind + * @package Validator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ trait SubitoPartialCopyPageRangeValidatorTrait { - private $pageStart = null; + private $_pageStart = null; - private $pageEnd = null; + private $_pageEnd = null; - private function extractPages($value) + /** + * Extract start and end page of a page range (string like '12-123') + * + * @param string $value From to page range + * + * @return void + */ + private function _extractPages(string $value) { preg_match(RecordController::PAGE_RANGE_PATTERN, $value, $matches); - $this->pageStart = (int)$matches[1]; - $this->pageEnd = (int)$matches[2]; + $this->_pageStart = (int)$matches[1]; + $this->_pageEnd = (int)$matches[2]; } } diff --git a/module/fid/src/Validator/SubitoPartialCopyPageSelection.php b/module/fid/src/Validator/SubitoPartialCopyPageSelection.php index 00f5be4679e..59695b8319a 100644 --- a/module/fid/src/Validator/SubitoPartialCopyPageSelection.php +++ b/module/fid/src/Validator/SubitoPartialCopyPageSelection.php @@ -1,7 +1,11 @@ <?php /** + * Subito partial copy page selection validator + * * Copyright (C) 2020 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,13 +19,25 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Alexander Purr <purr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Validator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\Validator; use Zend\Validator\AbstractValidator; +/** + * Subito partial copy page selection validator + * + * @category VuFind + * @package Validator + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class SubitoPartialCopyPageSelection extends AbstractValidator { use SubitoPartialCopyPageRangeValidatorTrait; @@ -39,15 +55,26 @@ class SubitoPartialCopyPageSelection extends AbstractValidator 'percentagedLimit' => 10 ]; - public function isValid($value) + /** + * Validate if given page selection does not exceed percentaged limit of a record + * + * @param string $value From to page range + * + * @return bool + */ + public function isValid(string $value) : bool { if ($this->options['numberPages'] == null) { return false; } - $this->extractPages($value); + $this->_extractPages($value); - $selection = $this->pageEnd - $this->pageStart; - $permittedSelection = (($this->options['percentagedLimit'] / 100) * $this->options['numberPages']) + $this->options['tolerancePages']; + $selection = $this->_pageEnd - $this->_pageStart; + $permittedSelection = ( + ($this->options['percentagedLimit'] / 100) + * $this->options['numberPages'] + ) + + $this->options['tolerancePages']; if ($selection > $permittedSelection) { $this->error(self::PAGE_SELECTION); return false; diff --git a/module/fid/src/View/Helper/Root/Factory.php b/module/fid/src/View/Helper/Root/Factory.php index 044f0f58ea6..748ade57589 100644 --- a/module/fid/src/View/Helper/Root/Factory.php +++ b/module/fid/src/View/Helper/Root/Factory.php @@ -38,8 +38,6 @@ use Interop\Container\ContainerInterface; * @author Demian Katz <demian.katz@villanova.edu> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development Wiki - * - * @codeCoverageIgnore */ class Factory { diff --git a/module/fid/src/Helper/FormLabel.php b/module/fid/src/View/Helper/Root/FormLabel.php similarity index 61% rename from module/fid/src/Helper/FormLabel.php rename to module/fid/src/View/Helper/Root/FormLabel.php index c6312fd1150..f6e435d1d8b 100644 --- a/module/fid/src/Helper/FormLabel.php +++ b/module/fid/src/View/Helper/Root/FormLabel.php @@ -1,7 +1,11 @@ <?php /** + * Zend Form Label View Helper + * * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,17 +19,38 @@ * 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 + * @category VuFind + * @package View_Helpers + * @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 + * @link https://vufind.org/wiki/development Wiki */ -namespace fid\Helper; +namespace fid\View\Helper\Root; use Zend\Form\Element; +use Zend\Form\ElementInterface; use Zend\Form\View\Helper\FormLabel as Base; +/** + * Improved Zend Form Label View Helper by adding attributes + * + * @category VuFind + * @package View_Helpers + * @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 + * @link https://vufind.org/wiki/development Wiki + */ class FormLabel extends Base { + /** + * {@inheritdoc} + * + * @param null|array|ElementInterface $element Form element + * + * @return string + */ public function openTag($element = null) { if ($element instanceof Element) { diff --git a/module/fid/src/View/Helper/Root/GetIt.php b/module/fid/src/View/Helper/Root/GetIt.php index af1f8c9e2be..53c88f13f93 100644 --- a/module/fid/src/View/Helper/Root/GetIt.php +++ b/module/fid/src/View/Helper/Root/GetIt.php @@ -46,19 +46,13 @@ class GetIt extends AbstractHelper { use TranslatorAwareTrait; - /** - * @var \Zend\Config\Config - */ + /* @var \Zend\Config\Config */ protected $config; - /** - * @var AbstractBase - */ + /* @var AbstractBase */ protected $driver; - /** - * @var array list of available source ID definitions from config - */ + /* @var array list of available source ID definitions from config */ protected $sids = [ 'source_idsV1', 'source_idsV3', @@ -165,7 +159,7 @@ class GetIt extends AbstractHelper protected $accordeonColorDefault; /** - * second color of the accordeon + * Second color of the accordeon * * @var */ @@ -179,7 +173,7 @@ class GetIt extends AbstractHelper protected $accordeonHeadlineDefault; /** - * second headline text of the get it box + * Second headline text of the get it box * * @var */ @@ -188,7 +182,9 @@ class GetIt extends AbstractHelper /** * GetIt constructor. * - * @param Config $getItConfig Get It box Configuration + * @param $getItConfig Config + * @param $fidClient FIDIS Client + * @param $permissionManager Permission Manager */ public function __construct($getItConfig, $fidClient, $permissionManager) { @@ -200,7 +196,9 @@ class GetIt extends AbstractHelper /** * Get Solr field data * - * @param $driver + * @param $driver Record Driver + * + * @return GetIt GetIt View Helper */ public function __invoke($driver) { @@ -224,6 +222,13 @@ class GetIt extends AbstractHelper return $this; } + /** + * Check if User is authorized + * + * @param $permission Permission + * + * @return bool + */ protected function hasPermission($permission) { return $this->permissionManager->isAuthorized($permission); @@ -232,7 +237,7 @@ class GetIt extends AbstractHelper /** * Retrieve SIDs from config (getit.ini) * - * @param $value + * @param $value sid * * @return array */ @@ -245,7 +250,7 @@ class GetIt extends AbstractHelper /** * Retrieve NonSIDs from config (getit.ini) * - * @param $value + * @param $value sid * * @return string */ @@ -259,7 +264,7 @@ class GetIt extends AbstractHelper * Read specific config of given record * Set default Values of getit box * - * @return array config of given record + * @return array config of given record */ public function getConfig() { @@ -340,6 +345,8 @@ class GetIt extends AbstractHelper * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record * @param $noticeLinkType string type of link + * + * @return void */ public function get_config_source_idsV1( &$accordeonColor, @@ -379,6 +386,8 @@ class GetIt extends AbstractHelper * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record * @param $noticeLinkType string type of link + * + * @return void */ public function get_config_source_idsV3( &$accordeonColor, @@ -397,7 +406,8 @@ class GetIt extends AbstractHelper ) { $accordeonColor = $this->accordeonColorAlternative; $accordeonHeadline = $this->accordeonHeadlineAlternative; - $boxHeadline = $this->fidClient->isLoggedOn() ? $this->translate('Get it') : $this->translate('getit_logged_not'); + $boxHeadline = $this->fidClient->isLoggedOn() ? + $this->translate('Get it') : $this->translate('getit_logged_not'); $notice = ''; $isAiSidRecord = true; $showArticleButton = $this->config->Permission->allowSubitoArticleCopy ?? true; @@ -421,6 +431,8 @@ class GetIt extends AbstractHelper * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record * @param $noticeLinkType string type of link + * + * @return void */ public function get_config_source_idsV4( &$accordeonColor, @@ -437,7 +449,8 @@ class GetIt extends AbstractHelper &$isAiSidRecord, &$noticeLinkType ) { - $boxHeadline = $this->fidClient->isLoggedOn() ? $this->translate('Get it') : $this->translate('getit_logged_not'); + $boxHeadline = $this->fidClient->isLoggedOn() ? + $this->translate('Get it') : $this->translate('getit_logged_not'); if ($this->fidClient->isLoggedOn()) { $notice = $this->translate('getit_text_12'); } else { @@ -465,6 +478,8 @@ class GetIt extends AbstractHelper * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record * @param $noticeLinkType string type of link + * + * @return void */ public function get_config_source_idsV5( &$accordeonColor, @@ -499,7 +514,8 @@ class GetIt extends AbstractHelper $notice = $this->translate('getit_text_3_1'); $noticeLinkType = "register"; } - $boxHeadline = $this->fidClient->isLoggedOn() ? $this->translate('Get it') : $this->translate('getit_logged_not'); + $boxHeadline = $this->fidClient->isLoggedOn() ? + $this->translate('Get it') : $this->translate('getit_logged_not'); $showLinks = $this->fidClient->isLoggedOn() && $hasEBookAccess; } @@ -521,6 +537,8 @@ class GetIt extends AbstractHelper * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record * @param $noticeLinkType string type of link + * + * @return void */ public function get_config_source_idsV6( &$accordeonColor, @@ -558,6 +576,8 @@ class GetIt extends AbstractHelper * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record * @param $noticeLinkType string type of link + * + * @return void */ public function get_config_source_idsV7( &$accordeonColor, @@ -597,6 +617,8 @@ class GetIt extends AbstractHelper * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record * @param $noticeLinkType string type of link + * + * @return void */ public function get_config_source_idsV8( &$accordeonColor, @@ -785,6 +807,8 @@ class GetIt extends AbstractHelper * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record * @param $noticeLinkType string type of link + * + * @return void */ public function get_config_source_idsV9( &$accordeonColor, @@ -854,6 +878,8 @@ class GetIt extends AbstractHelper * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record * @param $noticeLinkType string type of link + * + * @return void */ public function get_config_source_idsV10( &$accordeonColor, @@ -893,6 +919,8 @@ class GetIt extends AbstractHelper * @param $hideNotice boolean hide notice * @param $isAiSidRecord boolean is given record an ai record * @param $noticeLinkType string type of link + * + * @return void */ public function get_config_source_idsV11( &$accordeonColor, diff --git a/module/fid/src/View/Helper/Root/RecordDataFormatterFactory.php b/module/fid/src/View/Helper/Root/RecordDataFormatterFactory.php index 218028f8808..32dd7611e09 100644 --- a/module/fid/src/View/Helper/Root/RecordDataFormatterFactory.php +++ b/module/fid/src/View/Helper/Root/RecordDataFormatterFactory.php @@ -19,18 +19,28 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category VuFind FID + * @category VuFind * @package View_Helpers * @author Alexander Purr <purr@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki */ namespace fid\View\Helper\Root; -use finc\View\Helper\Root\RecordDataFormatterFactory as FincRecordDataFormatterFactory; +use finc\View\Helper\Root\RecordDataFormatterFactory as Base; use VuFind\View\Helper\Root\RecordDataFormatter; use VuFind\View\Helper\Root\RecordDataFormatter\SpecBuilder; -class RecordDataFormatterFactory extends FincRecordDataFormatterFactory +/** + * Record Data Formatter Factory for Record view + * + * @category VuFind + * @package View_Helpers + * @author Alexander Purr <purr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ +class RecordDataFormatterFactory extends Base { /** * Create the helper. diff --git a/module/fid/src/Helper/SearchTabs.php b/module/fid/src/View/Helper/Root/SearchTabs.php similarity index 92% rename from module/fid/src/Helper/SearchTabs.php rename to module/fid/src/View/Helper/Root/SearchTabs.php index 5ee9dc96cb4..f8043f084ce 100644 --- a/module/fid/src/Helper/SearchTabs.php +++ b/module/fid/src/View/Helper/Root/SearchTabs.php @@ -6,6 +6,7 @@ * * Copyright (C) Villanova University 2010. * Copyright (C) The National Library of Finland 2015-2016. + * Copyright (C) 2021 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, @@ -26,7 +27,7 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development Wiki */ -namespace fid\Helper; +namespace fid\View\Helper\Root; /** * "Search tabs" view helper @@ -52,7 +53,8 @@ class SearchTabs extends \VuFind\View\Helper\Root\SearchTabs */ protected function createBasicTab($id, $class, $label, $newUrl, $permissionName) { - $retval = parent::createBasicTab($id, $class, $label, $newUrl, $permissionName); + $retval + = parent::createBasicTab($id, $class, $label, $newUrl, $permissionName); $retval['hiddenFilters'] = $this->helper->getTabFilterConfig()[$id] ?? null; return $retval; @@ -90,7 +92,8 @@ class SearchTabs extends \VuFind\View\Helper\Root\SearchTabs */ protected function createHomeTab($id, $class, $label, $filters, $permissionName) { - $retval = parent::createHomeTab($id, $class, $label, $filters, $permissionName); + $retval + = parent::createHomeTab($id, $class, $label, $filters, $permissionName); $retval['hiddenFilters'] = $this->helper->getTabFilterConfig()[$id] ?? null; return $retval; diff --git a/module/fid/src/View/Helper/Root/UserGroups.php b/module/fid/src/View/Helper/Root/UserGroups.php index e3fe6d2dfe8..c36a3d9e9b6 100644 --- a/module/fid/src/View/Helper/Root/UserGroups.php +++ b/module/fid/src/View/Helper/Root/UserGroups.php @@ -49,11 +49,17 @@ class UserGroups extends AbstractHelper protected $displayOrder; - private $groups; + private $_groups; + /** + * UserGroups constructor. + * + * @param $fidConfig fid.ini + */ public function __construct($fidConfig) { - $this->displayRoles = $fidConfig->UserProfile['role_display']->toArray() ?? []; + $this->displayRoles = $fidConfig->UserProfile['role_display'] + ->toArray() ?? []; foreach ($fidConfig->UserProfile['role_display_priority'] ?? [] as $prios) { $roles = explode('>', $prios); while (count($roles) > 1) { @@ -63,22 +69,33 @@ class UserGroups extends AbstractHelper } } } - $this->displayOrder = explode('>', $fidConfig->UserProfile['role_display_order'] ?? ''); + $this->displayOrder = explode( + '>', + $fidConfig->UserProfile['role_display_order'] ?? '' + ); } + /** + * Invoke UserGroups + * + * @param $permissions Permissions + * + * @return $this + */ public function __invoke($permissions) { - $this->groups['requested'] = - $this->groups['granted'] = array_fill_keys($this->displayOrder, null); + $this->_groups['requested'] + = $this->_groups['granted'] + = array_fill_keys($this->displayOrder, null); foreach ($permissions as $permission => $status) { // $status is in ['granted','requested'] if (in_array($permission, $this->displayRoles)) { - $this->groups[$status][$permission] = - $this->translate('fid::label_access_level_' . $permission); + $this->_groups[$status][$permission] + = $this->translate('fid::label_access_level_' . $permission); } } foreach (['granted','requested'] as $status) { - $groups = array_filter($this->groups[$status]); + $groups = array_filter($this->_groups[$status]); foreach ((array)$this->rolePriority as $role => $prioritized) { if (isset($groups[$role])) { foreach ($prioritized as $prio) { @@ -89,18 +106,29 @@ class UserGroups extends AbstractHelper } } } - $this->groups[$status] = $groups; + $this->_groups[$status] = $groups; } return $this; } + /** + * Get granted user groups + * + * @return string|null + */ public function granted() { - return !empty($this->groups['granted']) ? implode("; ", $this->groups['granted']) : null; + return !empty($this->_groups['granted']) ? + implode("; ", $this->_groups['granted']) : null; } + /** + * Get user groups, which are requested for access + * + * @return string|null + */ public function requested() { - return !empty($this->groups['requested']) ? implode('; ', $this->groups['requested']) : null; + return !empty($this->_groups['requested']) ? implode('; ', $this->_groups['requested']) : null; } } diff --git a/module/fid/src/VuFind/Auth/Authenticator.php b/module/fid/src/VuFind/Auth/Authenticator.php index ccefd6dc9ba..c019c2da59d 100644 --- a/module/fid/src/VuFind/Auth/Authenticator.php +++ b/module/fid/src/VuFind/Auth/Authenticator.php @@ -2,6 +2,8 @@ /** * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,8 +17,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Auth + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\VuFind\Auth; @@ -29,6 +34,15 @@ use VuFind\Db\Row\User as UserRow; use VuFind\Exception\Auth as AuthException; use Zend\Http\PhpEnvironment\Request; +/** + * Class Authenticator + * + * @category VuFind + * @package Auth + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class Authenticator extends AbstractBase { protected const AUTH_ERROR_BAD_CREDENTIALS @@ -44,17 +58,27 @@ class Authenticator extends AbstractBase = 'fid::auth_error_account_deleted'; /** + * Fid client + * * @var Client */ protected $client; + /** + * Authenticator constructor. + * + * @param Client $client fid client + */ public function __construct(Client $client) { $this->client = $client; } /** - * @param Request $request + * {@inheritdoc} + * + * @param Request $request Request object containing + * new account details. * * @return VuFindUser|UserRow * @throws AuthException @@ -66,7 +90,10 @@ class Authenticator extends AbstractBase } /** - * @param Request $request + * {@inheritdoc} + * + * @param Request $request Request object containing + * account credentials. * * @return VuFindUser|UserRow * @throws AuthException @@ -94,9 +121,7 @@ class Authenticator extends AbstractBase throw new AuthException(self::AUTH_ERROR_ACCOUNT_BLOCKED); } - /** - * @var User $user - */ + /* @var User $user */ $user = $this->client->requestUserDetails(); if ($user->isDeleted()) { $this->client->logoff(); @@ -104,9 +129,7 @@ class Authenticator extends AbstractBase } if ($ownerId = $logon->getOwnerId()) { - /** - * @var VuFindUser $userRow - */ + /* @var VuFindUser $userRow */ $userRow = $this->getUserTable()->getByUsername($ownerId); return $userRow; @@ -117,7 +140,9 @@ class Authenticator extends AbstractBase } /** - * @param string $url + * {@inheritdoc} + * + * @param string $url URL to redirect user to after logging out. * * @return string * @throws ClientException @@ -129,6 +154,8 @@ class Authenticator extends AbstractBase } /** + * {@inheritdoc} + * * @return bool */ public function isExpired() @@ -136,11 +163,21 @@ class Authenticator extends AbstractBase return !$this->client->isLoggedOn(); } + /** + * {@inheritdoc} + * + * @return bool + */ public function supportsCreation() { return true; } + /** + * {@ineritdoc} + * + * @return bool + */ public function supportsPasswordRecovery() { return true; diff --git a/module/fid/src/VuFind/Auth/AuthenticatorFactory.php b/module/fid/src/VuFind/Auth/AuthenticatorFactory.php index e939baa19c2..60981792fc3 100644 --- a/module/fid/src/VuFind/Auth/AuthenticatorFactory.php +++ b/module/fid/src/VuFind/Auth/AuthenticatorFactory.php @@ -2,6 +2,8 @@ /** * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,21 +17,38 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Auth + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\VuFind\Auth; use fid\Service\Client; use Psr\Container\ContainerInterface; +/** + * Class AuthenticatorFactory + * + * @category VuFind + * @package Auth + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class AuthenticatorFactory { + /** + * Create an Authenticator object + * + * @param ContainerInterface $container Service container + * + * @return Authenticator + */ public function __invoke(ContainerInterface $container) { - /** - * @var Client $client - */ + /* @var Client $client */ $client = $container->get(Client::class); return new Authenticator($client); diff --git a/module/fid/src/VuFind/Auth/ILSAuthenticator.php b/module/fid/src/VuFind/Auth/ILSAuthenticator.php index bfa7533bc3d..5870a867cdd 100644 --- a/module/fid/src/VuFind/Auth/ILSAuthenticator.php +++ b/module/fid/src/VuFind/Auth/ILSAuthenticator.php @@ -2,6 +2,8 @@ /** * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,8 +17,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Auth + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\VuFind\Auth; @@ -24,19 +29,37 @@ use fid\Service\Client; use fid\Service\ClientException; use fid\Service\UserNotAuthorizedException; +/** + * Class ILSAuthenticator + * + * @category VuFind + * @package Auth + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class ILSAuthenticator { /** + * Fid Client + * * @var Client */ protected $client; + /** + * ILSAuthenticator constructor. + * + * @param Client $client fid Client + */ public function __construct(Client $client) { $this->client = $client; } /** + * Attempt to log in the user to the backend, and save credentials if it works. + * * @return array|null * @throws ClientException * @throws UserNotAuthorizedException @@ -47,6 +70,8 @@ class ILSAuthenticator } /** + * Log the current user into the catalog using stored credentials. + * * @return array|null * @throws ClientException * @throws UserNotAuthorizedException diff --git a/module/fid/src/VuFind/Auth/ILSAuthenticatorFactory.php b/module/fid/src/VuFind/Auth/ILSAuthenticatorFactory.php index a651d05a8e0..359bfe4d4be 100644 --- a/module/fid/src/VuFind/Auth/ILSAuthenticatorFactory.php +++ b/module/fid/src/VuFind/Auth/ILSAuthenticatorFactory.php @@ -2,6 +2,8 @@ /** * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,8 +17,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Auth + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\VuFind\Auth; @@ -25,15 +30,37 @@ use ProxyManager\Factory\LazyLoadingValueHolderFactory; use Psr\Container\ContainerInterface; use VuFind\Auth\ILSAuthenticator as ProxyClass; +/** + * Class ILSAuthenticatorFactory + * + * @category VuFind + * @package Auth + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class ILSAuthenticatorFactory { + /** + * Create ILSAuthenticator object + * + * @param ContainerInterface $container Service container + * + * @return \ProxyManager\Proxy\VirtualProxyInterface + */ public function __invoke(ContainerInterface $container) { $factory = new LazyLoadingValueHolderFactory(); return $factory->createProxy( ProxyClass::class, - function (&$object, $proxy, $method, $params, &$initializer) use ($container) { + function ( + &$object, + $proxy, + $method, + $params, + &$initializer + ) use ($container) { $initializer = null; $client = $container->get(Client::class); $object = new ILSAuthenticator($client); diff --git a/module/fid/src/VuFind/Db/Row/User.php b/module/fid/src/VuFind/Db/Row/User.php index a41643383b8..bef677adf11 100644 --- a/module/fid/src/VuFind/Db/Row/User.php +++ b/module/fid/src/VuFind/Db/Row/User.php @@ -2,6 +2,8 @@ /** * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,8 +17,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Db + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\VuFind\Db\Row; @@ -24,20 +29,40 @@ use fid\Service\Client; use fid\Service\ClientException; use VuFind\Db\Row\User as BaseUser; +/** + * Class User + * + * @category VuFind + * @package Db + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class User extends BaseUser { /** + * Fid client + * * @var Client */ protected $client; + /** + * Setter for fid client + * + * @param Client $client fid client + * + * @return void + */ public function setClient(Client $client) { $this->client = $client; } /** - * @param string $offset + * Read data from user + * + * @param string $offset name of user field to read data from * * @return mixed|string|null * @throws ClientException @@ -47,11 +72,27 @@ class User extends BaseUser return $this->readUserFields($offset) ?: parent::offsetGet($offset); } + /** + * Magic getter function. Reads user fields + * + * @param string $name field name + * + * @return false|mixed|string + */ public function __get($name) { return $this->readUserFields($name) ?: parent::__get($name); } + /** + * Reads user fields from client + * + * @param string $offset name of user field to read from + * + * @return false|string|null + * @throws ClientException + * @throws \fid\Service\UserNotAuthorizedException + */ protected function readUserFields($offset) { $user = $this->client->requestUserDetails(); diff --git a/module/fid/src/VuFind/Db/Row/UserDelegatorFactory.php b/module/fid/src/VuFind/Db/Row/UserDelegatorFactory.php index e7464ac313c..cd4e541e0e3 100644 --- a/module/fid/src/VuFind/Db/Row/UserDelegatorFactory.php +++ b/module/fid/src/VuFind/Db/Row/UserDelegatorFactory.php @@ -2,6 +2,8 @@ /** * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,24 +17,44 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Db + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\VuFind\Db\Row; use fid\Service\Client; use Psr\Container\ContainerInterface; +/** + * Class UserDelegatorFactory + * Adds Client to user object on creation + * + * @category VuFind + * @package Db + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class UserDelegatorFactory { + /** + * Adds Client to user object on creation + * + * @param ContainerInterface $container service container + * @param string $name name of class to instantiate + * @param callable $callback constructor callback + * + * @return User + */ public function __invoke( ContainerInterface $container, $name, callable $callback ) { - /** - * @var User $user - */ + /* @var User $user */ $user = call_user_func($callback); $user->setClient($container->get(Client::class)); diff --git a/module/fid/src/VuFind/ILS/Fid.php b/module/fid/src/VuFind/ILS/Fid.php index c9d40e9f06b..3f67c6dd3ba 100644 --- a/module/fid/src/VuFind/ILS/Fid.php +++ b/module/fid/src/VuFind/ILS/Fid.php @@ -2,6 +2,8 @@ /** * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,8 +17,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package ILS + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\VuFind\ILS; @@ -25,23 +30,47 @@ use fid\Service\ClientException; use VuFind\Exception\ILS as ILSException; use VuFind\ILS\Driver\AbstractBase; +/** + * Class Fid + * + * @category VuFind + * @package ILS + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class Fid extends AbstractBase { /** + * Fid client + * * @var Client */ protected $client; + /** + * Fid constructor. + * + * @param Client $client fid client + */ public function __construct(Client $client) { $this->client = $client; } + /** + * Initialize the Fid object + * + * @return void + */ public function init() { + // intentionally left blank } /** + * Login user + * * @return array|null * @throws ClientException */ @@ -56,26 +85,66 @@ class Fid extends AbstractBase return ['id' => $user->getId()]; } + /** + * Method should not be called + * + * @param string $id Record id + * + * @return mixed|void + * @throws ILSException + */ public function getStatus($id) { throw new ILSException('Method not available'); } + /** + * Method should not be called + * + * @param array $ids Record ids + * + * @return array|void + * @throws ILSException + */ public function getStatuses($ids) { throw new ILSException('Method not available'); } + /** + * Method should not be called + * + * @param string $id Record id + * @param array|null $patron patron data + * + * @return array|void + * @throws ILSException + */ public function getHolding($id, array $patron = null) { throw new ILSException('Method not available'); } + /** + * Method should not be called + * + * @param string $id Record id + * + * @return array|void + * @throws ILSException + */ public function getPurchaseHistory($id) { throw new ILSException('Method not available'); } + /** + * Return patron data as is + * + * @param mixed $patron patron data + * + * @return mixed + */ public function getMyProfile($patron) { return $patron; diff --git a/module/fid/src/VuFind/ILS/FidFactory.php b/module/fid/src/VuFind/ILS/FidFactory.php index fa66f098309..a4ce61d3c92 100644 --- a/module/fid/src/VuFind/ILS/FidFactory.php +++ b/module/fid/src/VuFind/ILS/FidFactory.php @@ -2,6 +2,8 @@ /** * Copyright (C) 2019 Leipzig University Library * + * PHP version 7 + * * 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. @@ -15,21 +17,38 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package ILS + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\VuFind\ILS; use fid\Service\Client; use Psr\Container\ContainerInterface; +/** + * Class FidFactory + * + * @category VuFind + * @package ILS + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class FidFactory { + /** + * Create an Fid object + * + * @param ContainerInterface $container Service container + * + * @return Fid + */ public function __invoke(ContainerInterface $container): Fid { - /** - * @var Client $client - */ + /* @var Client $client */ $client = $container->get(Client::class); return new Fid($client); diff --git a/module/fid/src/VuFind/Resolver/Driver/Ezb.php b/module/fid/src/VuFind/Resolver/Driver/Ezb.php index 152f4f4c983..7af1b7e17cc 100644 --- a/module/fid/src/VuFind/Resolver/Driver/Ezb.php +++ b/module/fid/src/VuFind/Resolver/Driver/Ezb.php @@ -2,6 +2,8 @@ /** * Copyright (C) Leipzig University Library 2019. * + * PHP Version 7 + * * 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. @@ -15,8 +17,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @category VuFind + * @package Resolver + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\VuFind\Resolver\Driver; @@ -29,12 +34,19 @@ use Zend\Config\Config; /** * Class Ezb + * Driver for EZB link resolver * - * @package fid\VuFind\Resolver\Driver + * @category VuFind + * @package Resolver + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ class Ezb extends BaseEzb { /** + * Link resolver configuration + * * @var Config */ protected $config; @@ -60,12 +72,26 @@ class Ezb extends BaseEzb */ protected $baseUrl; + /** + * Collected record messages + * + * @var array + */ protected $messages = []; + /** + * Collected states of results + * + * @var array + */ protected $stateOfResults = []; /** - * @param Config $config + * Setter for $config + * + * @param Config $config resolver configuration + * + * @return void */ public function setConfig(Config $config): void { @@ -73,7 +99,11 @@ class Ezb extends BaseEzb } /** - * @param Client $fidClient + * Setter for $fidClient + * + * @param Client $fidClient fid client + * + * @return void */ public function setFidClient(Client $fidClient): void { @@ -81,7 +111,11 @@ class Ezb extends BaseEzb } /** - * @param Connection $ils + * Setter for $ils + * + * @param Connection $ils ILS connection + * + * @return void */ public function setIls(Connection $ils): void { @@ -89,7 +123,11 @@ class Ezb extends BaseEzb } /** - * @param string $baseUrl + * Setter for $baseUrl + * + * @param string $baseUrl resolver's base URL + * + * @return void */ public function setBaseUrl(string $baseUrl): void { @@ -100,8 +138,9 @@ class Ezb extends BaseEzb * Fetch Links * Fetches a set of links corresponding to an OpenURL * - * @param string $openURL openURL (url-encoded)* - * @return string raw XML returned by resolver + * @param string $openURL openURL (url-encoded)* + * + * @return string raw XML returned by resolver */ public function fetchLinks($openURL) { @@ -268,7 +307,8 @@ class Ezb extends BaseEzb "Result[@state={$state}][" . ($i + 1) . "]/AccessLevel"; $accessLevel = $xpath->query($accessLevelXP, $result)->item(0); if (isset($accessLevel)) { - $record['title'] = $accessLevel_mapping[strip_tags($accessLevel->nodeValue)]; + $record['title'] + = $accessLevel_mapping[strip_tags($accessLevel->nodeValue)]; } // set message of the record @@ -286,8 +326,8 @@ class Ezb extends BaseEzb $record['href'] = $journalUrl->nodeValue; } - $stateOfResultXP = "/OpenURLResponseXML/Full/ElectronicData/ResultList/" . - "Result/@state"; + $stateOfResultXP = "/OpenURLResponseXML/Full/ElectronicData/" . + "ResultList/Result/@state"; $stateOfResult = $xpath->query($stateOfResultXP, $result)->item(0); if (isset($stateOfResult->nodeValue)) { $this->stateOfResults[] = $stateOfResult->nodeValue; diff --git a/module/fid/src/VuFind/Resolver/Driver/EzbDelegatorFactory.php b/module/fid/src/VuFind/Resolver/Driver/EzbDelegatorFactory.php index bf012de4f35..43e23ecf101 100644 --- a/module/fid/src/VuFind/Resolver/Driver/EzbDelegatorFactory.php +++ b/module/fid/src/VuFind/Resolver/Driver/EzbDelegatorFactory.php @@ -2,6 +2,8 @@ /** * Copyright (C) Leipzig University Library 2019. * + * PHP Version 7 + * * 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. @@ -15,8 +17,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @category VuFind + * @package Resolver + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ namespace fid\VuFind\Resolver\Driver; @@ -24,13 +29,26 @@ use fid\Service\Client; use Interop\Container\ContainerInterface; use Zend\ServiceManager\Factory\DelegatorFactoryInterface; +/** + * Class EzbDelegatorFactory + * + * @category VuFind + * @package Resolver + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki + */ class EzbDelegatorFactory implements DelegatorFactoryInterface { /** - * @param ContainerInterface $container - * @param string $name - * @param callable $callback - * @param array|null $options + * Create an Ezb object and set + * config, fid client, ILS connection, and base URL + * + * @param ContainerInterface $container Service container + * @param string $name class name for object to create + * @param callable $callback instantiation callback + * @param array|null $options options + * * @return Ezb|object */ public function __invoke( @@ -42,9 +60,7 @@ class EzbDelegatorFactory implements DelegatorFactoryInterface $ezbConfig = $container->get('VuFind\Config')->get('Resolver'); $fidClient = $container->get(Client::class); $ils = $container->get('VuFind\ILS\Connection'); - /** - * @var Ezb $ezb - */ + /* @var Ezb $ezb */ $ezb = call_user_func($callback); $ezb->setConfig($ezbConfig->Ezb); $ezb->setFidClient($fidClient); diff --git a/themes/fid/templates/Helpers/openurl.phtml b/themes/fid/templates/Helpers/openurl.phtml index 2590123aa55..8ad1c7e790c 100644 --- a/themes/fid/templates/Helpers/openurl.phtml +++ b/themes/fid/templates/Helpers/openurl.phtml @@ -3,15 +3,15 @@ echo $this->inlineScript(\Zend\View\Helper\HeadScript::FILE, 'openurl.js', 'SET'); $classes = ''; if ($this->openUrlEmbed) { - $classes = "fulltext"; + $classes = "fulltext"; } elseif ($this->openUrlWindow) { - $classes = 'fulltext openUrlWindow window_settings:' . $this->escapeHtmlAttr($this->openUrlWindow); + $classes = 'fulltext openUrlWindow window_settings:' . $this->escapeHtmlAttr($this->openUrlWindow); } if (!empty($classes)) { - $class = ' class="' . $classes . '"'; - $class_ib = ' class="imagebased ' . $classes . '"'; + $class = ' class="' . $classes . '"'; + $class_ib = ' class="imagebased ' . $classes . '"'; } else { - $class = $class_ib = ''; + $class = $class_ib = ''; } ?> @@ -27,10 +27,10 @@ <?php $style = ''; if ($this->openUrlGraphicWidth) { - $style .= 'width:' . $this->escapeHtmlAttr($this->openUrlGraphicWidth) . 'px;'; + $style .= 'width:' . $this->escapeHtmlAttr($this->openUrlGraphicWidth) . 'px;'; } if ($this->openUrlGraphicHeight) { - $style .= 'height:' . $this->escapeHtmlAttr($this->openUrlGraphicHeight) . 'px;'; + $style .= 'height:' . $this->escapeHtmlAttr($this->openUrlGraphicHeight) . 'px;'; } ?> <img src="<?=$this->escapeHtmlAttr($this->openUrlGraphic)?>" alt="<?=$this->transEsc('Get full text')?>" style="<?=$style?>" /> diff --git a/themes/fid/templates/ajax/resolverLinks-button.phtml b/themes/fid/templates/ajax/resolverLinks-button.phtml index 62873ca8527..4d1140a07c3 100644 --- a/themes/fid/templates/ajax/resolverLinks-button.phtml +++ b/themes/fid/templates/ajax/resolverLinks-button.phtml @@ -8,7 +8,7 @@ $controllerClass = 'controller:SolrMarcFincPDA'; ?> <?php /* refs #17647: status 4, 10 or -1 can display the button - GG */ ?> <?php if (preg_grep('/(4|10|-1)/', $this->showOrderButton) && $user): ?> - <a class="btn btn-primary pda-button <?=$controllerClass?> full-order" data-lightbox href="<?=$this->url('record-fidsubitoarticle', array('id' => $this->recordId))?>" rel="nofollow"> + <a class="btn btn-primary pda-button <?=$controllerClass?> full-order" data-lightbox href="<?=$this->url('record-fidsubitoarticle', ['id' => $this->recordId])?>" rel="nofollow"> <?=$this->transEsc('getit_order')?> </a> <?php $script = <<<JS diff --git a/themes/fid/templates/ajax/resolverLinks-print.phtml b/themes/fid/templates/ajax/resolverLinks-print.phtml index 972116bf51e..b8ef10b3602 100644 --- a/themes/fid/templates/ajax/resolverLinks-print.phtml +++ b/themes/fid/templates/ajax/resolverLinks-print.phtml @@ -15,7 +15,7 @@ $user = $account->isLoggedIn(); </div> <?php else: ?> <?php - $url = '<a href="'.$this->url('myresearch-account').'?auth_method='.$account->getAuthMethod().'" target="_blank" data-lightbox>'.$this->transEsc('getit_text_3_2').'</a>'; + $url = '<a href="' . $this->url('myresearch-account') . '?auth_method=' . $account->getAuthMethod() . '" target="_blank" data-lightbox>' . $this->transEsc('getit_text_3_2') . '</a>'; ?> <?=sprintf($this->translate('getit_text_10'), $url)?> <?php $script = <<<JS @@ -34,10 +34,10 @@ JS; <ul> <?php foreach ($this->print as $link): ?> <li> - <?=isset($link['Location'])?$this->transEsc('ezb_location'). ': ' . $this->escapeHtml($link['Location']) . '<br/>':''?> - <?=isset($link['Signature'])?$this->transEsc('Call Number'). ': ' . $this->escapeHtml($link['Signature']) . '<br/>':''?> - <?=isset($link['Period'])?$this->transEsc('ezb_period'). ': ' . $this->escapeHtml($link['Period']) . '<br/>':''?> - <?=isset($link['Holding_comment'])?$this->transEsc('ezb_comment'). ': ' . $this->escapeHtml($link['Holding_comment']) . '<br/>':''?> + <?=isset($link['Location']) ? $this->transEsc('ezb_location') . ': ' . $this->escapeHtml($link['Location']) . '<br/>' : ''?> + <?=isset($link['Signature']) ? $this->transEsc('Call Number') . ': ' . $this->escapeHtml($link['Signature']) . '<br/>' : ''?> + <?=isset($link['Period']) ? $this->transEsc('ezb_period') . ': ' . $this->escapeHtml($link['Period']) . '<br/>' : ''?> + <?=isset($link['Holding_comment']) ? $this->transEsc('ezb_comment') . ': ' . $this->escapeHtml($link['Holding_comment']) . '<br/>' : ''?> </li> <?php endforeach; ?> </ul> @@ -45,7 +45,7 @@ JS; <?php endif; ?> <?php /* finc-specific change #9274 - CK */ ?> - <?php if ($noResolverContent): // no content to show, so tell the user ?> + <?php if ($noResolverContent): // no content to show, so tell the user?> <span id="noResolverContentMessage" class="hidden"><?=$this->resolver . ': ' . $this->translate('no_resolver_links')?></span> <script>if ($('#urlsHideable').length) { $('#urlsHideable').show(); } else { $('#noResolverContentMessage').show(); }</script> <?php endif; ?> diff --git a/themes/fid/templates/ajax/resolverLinks.phtml b/themes/fid/templates/ajax/resolverLinks.phtml index 8f795e48db9..98048799ff5 100644 --- a/themes/fid/templates/ajax/resolverLinks.phtml +++ b/themes/fid/templates/ajax/resolverLinks.phtml @@ -13,19 +13,19 @@ <?php if (!empty($link['href'])): ?> <?php /* fid: #16136 remove traffic light - GG */?> <?= $this->externalLink( - $this->escapeHtmlAttr($link['href']), - '<i class="icon icon-external-link" aria-hidden="true"></i>' + $this->escapeHtmlAttr($link['href']), + '<i class="icon icon-external-link" aria-hidden="true"></i>' . (isset($link['title']) ? $this->escapeHtml($this->transEsc($link['title'])) : ''), - [ + [ 'title' => isset($link['service_type']) ? $this->escapeHtmlAttr($link['service_type']) : '', 'class' => !empty($link['access']) ? 'access-' . $link['access'] : '' ], - true - ); ?> + true +); ?> <br /> <?php /* fid: #16136 remove coverage - GG */?> <?php else: ?> - <?=isset($link['title'])?$this->escapeHtml($this->transEsc($link['title'])):''?> + <?=isset($link['title']) ? $this->escapeHtml($this->transEsc($link['title'])) : ''?> <?php endif; ?> </li> <?php endif; ?> @@ -53,7 +53,7 @@ <?php /* finc-specific change - commented out in #7643 - END */ ?> <?php /* finc-specific change #9274 - CK */ ?> - <?php if ($noResolverContent): // no content to show, so tell the user ?> + <?php if ($noResolverContent): // no content to show, so tell the user?> <span id="noResolverContentMessage" class="hidden"><?=$this->resolver . ': ' . $this->translate('no_resolver_links')?></span> <script>if ($('#urlsHideable').length) { $('#urlsHideable').show(); } else { $('#noResolverContentMessage').show(); }</script> <?php endif; ?> diff --git a/themes/fid/templates/fid/admin/list-entry.phtml b/themes/fid/templates/fid/admin/list-entry.phtml index af5cfab3ece..db2b5611242 100644 --- a/themes/fid/templates/fid/admin/list-entry.phtml +++ b/themes/fid/templates/fid/admin/list-entry.phtml @@ -4,14 +4,14 @@ $permissions = []; foreach ($config['Admin']['permission_options'] ?? [] as $perm) { $state = $user->getPermissions()[$perm]; /* #16383: set requested as bold text - GG */ - $state = $state === 'requested' ? '<strong>'.$this->escapeHtml($state).'</strong>' : $state; - $permissions[$perm] = $this->escapeHtml($perm)." ($state)"; + $state = $state === 'requested' ? '<strong>' . $this->escapeHtml($state) . '</strong>' : $state; + $permissions[$perm] = $this->escapeHtml($perm) . " ($state)"; } foreach ($this->fields as $field): ?> <?php if ($field === 'Permissions'): ?> - <td><?=implode(', ',$permissions)?></td> + <td><?=implode(', ', $permissions)?></td> <?php else: ?> <td><?=$this->escapeHtml($user->$field)?></td> <?php endif; ?> diff --git a/themes/fid/templates/fid/admin/list.phtml b/themes/fid/templates/fid/admin/list.phtml index 75d304de875..f7adc2972f3 100644 --- a/themes/fid/templates/fid/admin/list.phtml +++ b/themes/fid/templates/fid/admin/list.phtml @@ -23,15 +23,15 @@ echo $this->inlineScript(\Zend\View\Helper\HeadScript::SCRIPT, $script, 'SET'); <td><!-- empty cell --></td> <th>#</th> <?php foreach ($fields as $fieldname): ?> - <th><?=$this->translate('fid::'.$fieldname)?></th> + <th><?=$this->translate('fid::' . $fieldname)?></th> <?php endforeach; ?> </tr> <?php /* #16383 */ ?> </thead> <tbody> <?php foreach ($list as $id => $user):?> - <?php $tooltip = $this->translate('fid::user_edit',['%%userid%%' => $id]); ?> - <tr><td><a href="<?=$this->url('fid/admin/edit',['userid' => $id])?>" title="<?=$tooltip?>"><i class="fa fa-pencil-square-o"></i><span class="sr-only"><?=$tooltip?></span></a></td><th><?=$id?></th><?= $this->render('fid/admin/list-entry',['user' => $user,'fields'=>$fields, 'config' => $config]) ?></tr> + <?php $tooltip = $this->translate('fid::user_edit', ['%%userid%%' => $id]); ?> + <tr><td><a href="<?=$this->url('fid/admin/edit', ['userid' => $id])?>" title="<?=$tooltip?>"><i class="fa fa-pencil-square-o"></i><span class="sr-only"><?=$tooltip?></span></a></td><th><?=$id?></th><?= $this->render('fid/admin/list-entry', ['user' => $user,'fields'=>$fields, 'config' => $config]) ?></tr> <?php endforeach; ?> <?php /* #16383 */ ?> </tbody> diff --git a/themes/fid/templates/fid/order/order-edit-missing-record.phtml b/themes/fid/templates/fid/order/order-edit-missing-record.phtml index 144a2c896f6..4e0f4ffed3a 100644 --- a/themes/fid/templates/fid/order/order-edit-missing-record.phtml +++ b/themes/fid/templates/fid/order/order-edit-missing-record.phtml @@ -7,7 +7,7 @@ <?php $externalUrl = $this->order->getData()['digitization']['external_url'] ?? null; $recordLabel = $this->order->getLabel(); -if($externalUrl) : ?> +if ($externalUrl) : ?> <?= $this->externalLink($externalUrl, $recordLabel, ['data-lightbox-ignore' => '']) ?> <?php else: ?> <?=$recordLabel?> @@ -18,7 +18,8 @@ if($externalUrl) : ?> $arrTemplate = '<tr></tr><th>%%LABEL%%:</th><td> %%VALUE%%</td></tr>'; ?> <?= $this->renderArray( - $arrTemplate, $this->order->getData()['digitization'], + $arrTemplate, + $this->order->getData()['digitization'], [ $this->transEsc('fid::acquisition_label_responsible') => 'responsible', $this->transEsc('fid::acquisition_label_year') => 'year', diff --git a/themes/fid/templates/fid/order/order-edit.phtml b/themes/fid/templates/fid/order/order-edit.phtml index b8d4170b82f..aca7d567a05 100644 --- a/themes/fid/templates/fid/order/order-edit.phtml +++ b/themes/fid/templates/fid/order/order-edit.phtml @@ -20,11 +20,7 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 */ -use Zend\Form\Element; use Zend\Form\Form; -use Zend\Form\View\Helper\FormElementErrors; -use Zend\Form\View\Helper\FormLabel; -use Zend\Form\View\Helper\FormSubmit; $driver = $this->driver; $order = $this->order; @@ -38,7 +34,7 @@ $this->headTitle($title = $this->translate("fid::acquisition_{$order->getType()} <?=$this->render('fid/record/acquisition-contact-details'); ?> -<?php if ($driver != null ): ?> +<?php if ($driver != null): ?> <?php $formatter = $this->recordDataFormatter(); $this->coreFields = $formatter->getData($driver, $formatter->getDefaults('fid-acquisition-general')); diff --git a/themes/fid/templates/fid/record/acquisition-digitization-fields.phtml b/themes/fid/templates/fid/record/acquisition-digitization-fields.phtml index 5fc013c898c..ed01476dd25 100644 --- a/themes/fid/templates/fid/record/acquisition-digitization-fields.phtml +++ b/themes/fid/templates/fid/record/acquisition-digitization-fields.phtml @@ -22,10 +22,6 @@ use Zend\Form\Element; use Zend\Form\Form; -use Zend\Form\View\Helper\FormElementErrors; -use Zend\Form\View\Helper\FormLabel; -use Zend\Form\View\Helper\FormSelect; -use Zend\Form\View\Helper\FormSubmit; /** @var Form $form */ ?> @@ -34,7 +30,7 @@ use Zend\Form\View\Helper\FormSubmit; <h2><?= $this->translate("fid::acquisition_info_requested_item") ?></h2> - <? /* title */ ?> + <?php /* title */ ?> <?php /** @var Element\Text $elemTitle */ $elemTitle = $form->get('title'); @@ -47,7 +43,7 @@ use Zend\Form\View\Helper\FormSubmit; <?= $this->formElement($elemTitle) ?> </div> - <? /* responsible */ ?> + <?php /* responsible */ ?> <?php /** @var Element\Text $elemResponsible */ $elemResponsible = $form->get('responsible'); @@ -60,7 +56,7 @@ use Zend\Form\View\Helper\FormSubmit; <?= $this->formElement($elemResponsible) ?> </div> - <? /* year */ ?> + <?php /* year */ ?> <?php /** @var Element\Text $elemYear */ $elemYear = $form->get('year'); @@ -73,7 +69,7 @@ use Zend\Form\View\Helper\FormSubmit; <?= $this->formElement($elemYear) ?> </div> - <? /* language */ ?> + <?php /* language */ ?> <?php /** @var Element\Text $elemLanguage */ $elemLanguage = $form->get('language'); @@ -88,7 +84,7 @@ use Zend\Form\View\Helper\FormSubmit; <?php endif; ?> -<? /* library */ ?> +<?php /* library */ ?> <?php /** @var Element\Text $elemFormat */ $elemLibrary = $form->get('library'); @@ -102,7 +98,7 @@ $elemLibrary->setAttributes(['class' => 'form-control']); <?= $this->formElement($elemLibrary) ?> </div> -<? /* signature */ ?> +<?php /* signature */ ?> <?php /** @var Element\Text $elemSignature */ $elemSignature = $form->get('signature'); @@ -116,7 +112,7 @@ $elemSignature->setAttributes(['class' => 'form-control']); <?= $this->formElement($elemSignature) ?> </div> -<? /* external_url */ ?> +<?php /* external_url */ ?> <?php /** @var Element\Url $elemExternalUrl */ $elemExternalUrl = $form->get('external_url'); @@ -130,7 +126,7 @@ $elemExternalUrl->setAttributes(['class' => 'form-control']); <?= $this->formElement($elemExternalUrl) ?> </div> -<? /* format */ ?> +<?php /* format */ ?> <?php /** @var Element\Select $elemFormat */ $elemFormat = $form->get('format'); @@ -144,7 +140,7 @@ $elemFormat->setAttributes(['class' => 'form-control']); <?= $this->formElement($elemFormat) ?> </div> -<? /* comments */ ?> +<?php /* comments */ ?> <?php /** @var Element\Textarea $elemComment */ $elemComment = $form->get('comment'); diff --git a/themes/fid/templates/fid/record/acquisition-digitization.phtml b/themes/fid/templates/fid/record/acquisition-digitization.phtml index 1446734d34b..69f477c7028 100644 --- a/themes/fid/templates/fid/record/acquisition-digitization.phtml +++ b/themes/fid/templates/fid/record/acquisition-digitization.phtml @@ -24,7 +24,6 @@ use Zend\Form\Element; use Zend\Form\Form; use Zend\Form\View\Helper\FormElementErrors; use Zend\Form\View\Helper\FormLabel; -use Zend\Form\View\Helper\FormSelect; use Zend\Form\View\Helper\FormSubmit; /** @var Form $form */ @@ -39,7 +38,7 @@ $formSubmit->setTranslatorTextDomain('fid'); $formElementErrors = $this->formElementErrors(); $formElementErrors->setTranslatorTextDomain('fid'); $this->headTitle($title = $this->translate("fid::acquisition_digitization")); -$form->setAttribute('class','fid-acquisition-form'); +$form->setAttribute('class', 'fid-acquisition-form'); ?> <h1><?= $title ?></h1> @@ -80,7 +79,7 @@ $form->setAttribute('class','fid-acquisition-form'); <div class="row confirmation"> <div class="col col-xs-12"> - <? /* submit button */ ?> + <?php /* submit button */ ?> <?php /** @var Element\Submit $elemSubmit */ $elemSubmit = $form->get('submit'); diff --git a/themes/fid/templates/fid/record/acquisition-pda.phtml b/themes/fid/templates/fid/record/acquisition-pda.phtml index a5bc87b75cb..c1810cee72e 100644 --- a/themes/fid/templates/fid/record/acquisition-pda.phtml +++ b/themes/fid/templates/fid/record/acquisition-pda.phtml @@ -38,7 +38,7 @@ $formSubmit->setTranslatorTextDomain('fid'); $formElementErrors = $this->formElementErrors(); $formElementErrors->setTranslatorTextDomain('fid'); $this->headTitle($title = $this->translate("fid::acquisition_pda")); -$form->setAttribute('class','fid-acquisition-form'); +$form->setAttribute('class', 'fid-acquisition-form'); ?> <h1><?= $title ?></h1> diff --git a/themes/fid/templates/fid/record/acquisition-subito-article.phtml b/themes/fid/templates/fid/record/acquisition-subito-article.phtml index 99612d70c71..f600aebba04 100644 --- a/themes/fid/templates/fid/record/acquisition-subito-article.phtml +++ b/themes/fid/templates/fid/record/acquisition-subito-article.phtml @@ -38,7 +38,7 @@ $formSubmit->setTranslatorTextDomain('fid'); $formElementErrors = $this->formElementErrors(); $formElementErrors->setTranslatorTextDomain('fid'); $this->headTitle($title = $this->translate("fid::acquisition_subito_article")); -$form->setAttribute('class','fid-acquisition-form'); +$form->setAttribute('class', 'fid-acquisition-form'); ?> <h1><?= $title ?></h1> diff --git a/themes/fid/templates/fid/record/acquisition-subito-partial-copy.phtml b/themes/fid/templates/fid/record/acquisition-subito-partial-copy.phtml index ddaf79bf871..c4976c6a2a3 100644 --- a/themes/fid/templates/fid/record/acquisition-subito-partial-copy.phtml +++ b/themes/fid/templates/fid/record/acquisition-subito-partial-copy.phtml @@ -38,7 +38,7 @@ $formSubmit->setTranslatorTextDomain('fid'); $formElementErrors = $this->formElementErrors(); $formElementErrors->setTranslatorTextDomain('fid'); $this->headTitle($title = $this->translate("fid::acquisition_subito_partial_copy")); -$form->setAttribute('class','fid-acquisition-form'); +$form->setAttribute('class', 'fid-acquisition-form'); ?> <h1><?= $title ?></h1> @@ -76,7 +76,7 @@ $elemComment->setAttributes(['class' => 'form-control']); ?> <div class="row pages"> - <?php if ( ! ( $this->formElementErrors($elemComment) == "" && $this->formElementErrors($elemPages) == "" ) ): ?> + <?php if (! ($this->formElementErrors($elemComment) == "" && $this->formElementErrors($elemPages) == "")): ?> <div class="col col-xs-12"> <div class="form-group"> <?= $this->formElementErrors($elemPages) ?> diff --git a/themes/fid/templates/fid/user/orders/additionals-data.phtml b/themes/fid/templates/fid/user/orders/additionals-data.phtml index 25c8c596c32..4a718d37c3d 100644 --- a/themes/fid/templates/fid/user/orders/additionals-data.phtml +++ b/themes/fid/templates/fid/user/orders/additionals-data.phtml @@ -9,7 +9,7 @@ <?php else: ?> <?php $externalUrl = $this->order->getData()['digitization']['external_url'] ?? null; - if($externalUrl) : ?> + if ($externalUrl) : ?> <?= $this->externalLink($externalUrl, $recordLabel, ['data-lightbox-ignore' => '']) ?> <?php else: ?> <?=$recordLabel?> @@ -19,15 +19,16 @@ $arrTemplate = '<dt>%%LABEL%%:</dt><dd> %%VALUE%%</dd>'; ?> <?= $this->renderArray( - $arrTemplate, $this->order->getData()['digitization'], - [ + $arrTemplate, + $this->order->getData()['digitization'], + [ $this->transEsc('fid::acquisition_label_responsible') => 'responsible', $this->transEsc('fid::acquisition_label_year') => 'year', $this->transEsc('fid::acquisition_label_language') => 'language', $this->transEsc('fid::acquisition_label_library') => 'library', $this->transEsc('fid::acquisition_label_signature') => 'signature' ] - ) ?> + ) ?> </dl> <?php endif; ?> </td> diff --git a/themes/fid/templates/fid/user/policy.phtml b/themes/fid/templates/fid/user/policy.phtml index 0c7e00bbb9e..5290d9baf37 100644 --- a/themes/fid/templates/fid/user/policy.phtml +++ b/themes/fid/templates/fid/user/policy.phtml @@ -1,14 +1,15 @@ <!-- fid - policy begin --> <?php $lang = $this->layout()->userLang; ?> -<?php if (isset($backUrl) && $this->layout()->getTemplate() == 'layout/lightbox') +<?php if (isset($backUrl) && $this->layout()->getTemplate() == 'layout/lightbox') { $backButton = '<div class="form-group"> - <a class="back-to-login btn btn-primary" href="'.$backUrl.'"> + <a class="back-to-login btn btn-primary" href="' . $backUrl . '"> <i class="fa fa-chevron-left" aria-hidden="true"></i>' - .$this->transEsc('back_to_form') - .'</a> + . $this->transEsc('back_to_form') + . '</a> </div>'; +} ?> -<?php if(isset($backButton)):?><?=$backButton?><?php endif; ?> -<?=$this->render('fid/user/policy-'.$lang.'.phtml')?> -<?php if(isset($backButton)):?><?=$backButton?><?php endif; ?> +<?php if (isset($backButton)):?><?=$backButton?><?php endif; ?> +<?=$this->render('fid/user/policy-' . $lang . '.phtml')?> +<?php if (isset($backButton)):?><?=$backButton?><?php endif; ?> <!-- fid - policy end --> diff --git a/themes/fid/templates/fid/user/terms.phtml b/themes/fid/templates/fid/user/terms.phtml index 43abf76dd9e..854475db55e 100644 --- a/themes/fid/templates/fid/user/terms.phtml +++ b/themes/fid/templates/fid/user/terms.phtml @@ -1,15 +1,16 @@ <!-- fid - terms begin --> <?php $lang = $this->layout()->userLang; ?> -<?php $fileExists = file_exists(dirname(__FILE__) . '/terms-'.$lang.'.phtml'); ?> -<?php if (isset($backUrl) && $this->layout()->getTemplate() == 'layout/lightbox') +<?php $fileExists = file_exists(dirname(__FILE__) . '/terms-' . $lang . '.phtml'); ?> +<?php if (isset($backUrl) && $this->layout()->getTemplate() == 'layout/lightbox') { $backButton = '<div class="form-group"> - <a class="back-to-login btn btn-primary" href="'.$backUrl.'"> + <a class="back-to-login btn btn-primary" href="' . $backUrl . '"> <i class="fa fa-chevron-left" aria-hidden="true"></i>' - .$this->transEsc('back_to_form') - .'</a> + . $this->transEsc('back_to_form') + . '</a> </div>'; +} ?> -<?php if(isset($backButton)):?><?=$backButton?><?php endif; ?> -<?=$this->render('fid/user/terms-'.$lang.'.phtml')?> -<?php if(isset($backButton)):?><?=$backButton?><?php endif; ?> +<?php if (isset($backButton)):?><?=$backButton?><?php endif; ?> +<?=$this->render('fid/user/terms-' . $lang . '.phtml')?> +<?php if (isset($backButton)):?><?=$backButton?><?php endif; ?> <!-- fid - terms end --> diff --git a/themes/fid/templates/footer.phtml b/themes/fid/templates/footer.phtml index f8243b8f6d6..d44709ff763 100644 --- a/themes/fid/templates/footer.phtml +++ b/themes/fid/templates/footer.phtml @@ -37,18 +37,22 @@ <div class="footer-column"> <?=$this->layout()->poweredBy?> <span lang="en">Powered by</span> - <?= $this->externalLink( + <?= + $this->externalLink( "https://vufind.org", '<img src="' . $this->imageLink('vufind_logo.png') . '" alt="' . $this->translate('vufind-logo_alt') . '" aria-hidden="true"/>', ['title' => $this->translate('vufind-logo_title')], true - ) ?> - <?= $this->externalLink( + ) + ?> + <?= + $this->externalLink( "https://blog.finc.info", '<img src="' . $this->imageLink('finc_logo.png') . '" alt="' . $this->translate('finc-logo_alt') . '" aria-hidden="true"/>', ['title' => $this->translate('finc-logo_title')], true - ) ?> + ) + ?> </div> </div> </footer> diff --git a/themes/fid/templates/myresearch/menu-additional-entries.phtml b/themes/fid/templates/myresearch/menu-additional-entries.phtml index 0139c66ec6e..368ce78c6de 100644 --- a/themes/fid/templates/myresearch/menu-additional-entries.phtml +++ b/themes/fid/templates/myresearch/menu-additional-entries.phtml @@ -1,9 +1,9 @@ <?php /** -* @author Robert Lange <lange@@ub.uni-leipzig.de> -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License -* @link https://vufind.org Main Page -*/ + * @author Robert Lange <lange@@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ ?> <!-- fid: myresearch - menu-additional-entries.phtml --> <?php /* skeleton for additional menu entries */ ?> diff --git a/themes/fid/templates/myresearch/menu.phtml b/themes/fid/templates/myresearch/menu.phtml index 26befc4ee09..e14097d2057 100644 --- a/themes/fid/templates/myresearch/menu.phtml +++ b/themes/fid/templates/myresearch/menu.phtml @@ -1,14 +1,14 @@ <?php /** -* -* copied from /bootstrap3/templates/myresearch/menu.phtml -* changed for fid specific menu -* refs #15480 add password change to fid profile -* -* @author Robert Lange <lange@@ub.uni-leipzig.de> -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License -* @link https://vufind.org Main Page -*/ + * + * copied from /bootstrap3/templates/myresearch/menu.phtml + * changed for fid specific menu + * refs #15480 add password change to fid profile + * + * @author Robert Lange <lange@@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Page + */ ?> <!-- fid: myresearch - menu.phtml --> <?php @@ -82,7 +82,7 @@ <a href="<?=$this->url('editList', ['id' => 'NEW'])?>"> <i class="fa fa-fw fa-plus" aria-hidden="true"></i> <?=$this->transEsc('Create a List') ?> </a> - <?=$this->context($this)->renderInContext('myresearch/menu-additional-entries.phtml', array())?> + <?=$this->context($this)->renderInContext('myresearch/menu-additional-entries.phtml', [])?> </div> <?php endif ?> <?php if ($this->permission()->allowDisplay('fid.ReadList')): ?> diff --git a/themes/fid/templates/myresearch/profile.phtml b/themes/fid/templates/myresearch/profile.phtml index ae132eaf627..7a78b48f716 100644 --- a/themes/fid/templates/myresearch/profile.phtml +++ b/themes/fid/templates/myresearch/profile.phtml @@ -26,14 +26,14 @@ if (is_array($profile)) { <?php if (is_array($this->profile)): ?> <table class="table table-striped"> <?=$this->renderArray( - $arrTemplate, - $profile, - array_merge( - $profile['firstname'] ? [$this->transEsc('First Name') => 'firstname'] : [], - $profile['lastname'] ? [$this->transEsc('Last Name') => 'lastname'] : [], - $profile['address1'] ?? '' ? [$this->transEsc('Address') . ' 1' => 'address1'] : [], - $profile['address2'] ?? '' ? [$this->transEsc('Address') . ' 2' => 'address2'] : [], - [ + $arrTemplate, + $profile, + array_merge( + $profile['firstname'] ? [$this->transEsc('First Name') => 'firstname'] : [], + $profile['lastname'] ? [$this->transEsc('Last Name') => 'lastname'] : [], + $profile['address1'] ?? '' ? [$this->transEsc('Address') . ' 1' => 'address1'] : [], + $profile['address2'] ?? '' ? [$this->transEsc('Address') . ' 2' => 'address2'] : [], + [ $this->transEsc('Email') => 'email', $this->transEsc('Phone Number') => 'phone', $this->transEsc('Mobile Number') => 'mobile_phone', @@ -41,8 +41,8 @@ if (is_array($profile)) { $this->transEsc('Expires') => 'expiration_date', $this->transEsc('fid::requested_groups') => 'requested_group' ] - ) - )?> + ) +)?> </table> <a href="<?=$this->url('fid/user/update')?>" class="btn btn-primary"><?=$this->transEsc('fid::Edit Account')?></a> <?php elseif ('ils-none' !== $this->ils()->getOfflineMode() && $this->patronLoginView && !empty($this->patronLoginView->getTemplate())): ?> diff --git a/themes/fid/theme.config.php b/themes/fid/theme.config.php index a372ae4df9d..0bf48e0d51d 100644 --- a/themes/fid/theme.config.php +++ b/themes/fid/theme.config.php @@ -2,6 +2,8 @@ /** * Copyright (C) 2019 Leipzig University Library * + * PHP Version 7 + * * 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. @@ -15,30 +17,34 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> - * @author Dorian Merz <merz@ub.uni-leipzig.de> - * @author Gregor Gawol <gawol@ub.uni-leipzig.de> - * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @category VuFind + * @package Themes + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @author Dorian Merz <merz@ub.uni-leipzig.de> + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + * @link https://vufind.org/wiki/development Wiki */ return [ 'extends' => 'finc', - 'helpers' => array( - 'factories' => array( + 'helpers' => [ + 'factories' => [ 'fid\View\Helper\Root\UserGroups' => 'fid\View\Helper\Root\Factory::getUserGroups', 'fid\View\Helper\Root\GetIt' => 'fid\View\Helper\Root\Factory::getGetIt', - 'fid\Helper\SearchTabs' => 'VuFind\View\Helper\Root\SearchTabsFactory', + 'fid\View\Helper\Root\SearchTabs' => + 'VuFind\View\Helper\Root\SearchTabsFactory', 'VuFind\View\Helper\Root\RecordDataFormatter' => 'fid\View\Helper\Root\RecordDataFormatterFactory', - ), - 'aliases' => array( + ], + 'aliases' => [ 'usergroups' => 'UserGroups', 'UserGroups' => 'fid\View\Helper\Root\UserGroups', 'getit' => 'fid\View\Helper\Root\GetIt', 'GetIt' => 'fid\View\Helper\Root\GetIt', - 'searchTabs' => 'fid\Helper\SearchTabs', - ) - ), -]; \ No newline at end of file + 'searchTabs' => 'fid\View\Helper\Root\SearchTabs', + ] + ], +]; -- GitLab