diff --git a/local/languages/de.ini b/local/languages/de.ini index 0fd0654be21865e07f6d9d2a81d1fc2750c87863..c6d5f9fd962ff48df27af8eba9b97d2cf40671d1 100644 --- a/local/languages/de.ini +++ b/local/languages/de.ini @@ -1966,6 +1966,7 @@ support_by_dfg = "Die Nationallizenzen wurden gefördert durch die" (fa-home object) = "Online-Ressource" (fa-globe) = "Online-Ressource" (fa-home passive) = "beschaffbar" +(fa-question) = "entfernt / ersetzt" ; HierarchyTree select hierarchyTreeSelect = "Übergeordnete Werke:" diff --git a/local/languages/en.ini b/local/languages/en.ini index 277299f8cd95148fdc5548d2842e67a33a4bed33..6401d825478793b3e52b41a51f342f036ceca160 100644 --- a/local/languages/en.ini +++ b/local/languages/en.ini @@ -2068,6 +2068,7 @@ support_by_dfg = "National licenses were sponsored by " (fa-home object) = "online resource" (fa-globe) = "online resource" (fa-home passive) = "available on request" +(fa-question) = "removed or replaced" ; HierarchyTree select hierarchyTreeSelect = "Parent items:" diff --git a/module/finc/config/module.config.php b/module/finc/config/module.config.php index b0fa8ae795efd380c186b9d7e25e83b83ab7818f..b2f39e304cdf7b8452a8434d147891356501df92 100644 --- a/module/finc/config/module.config.php +++ b/module/finc/config/module.config.php @@ -41,6 +41,7 @@ $config = [ 'finc\Controller\DocumentDeliveryServiceController' => 'finc\Controller\DocumentDeliveryServiceControllerFactory', 'finc\Controller\Admin\I18nController' => 'finc\Controller\Admin\I18nControllerFactory', 'finc\Controller\RecordsController' => 'VuFind\Controller\AbstractBaseFactory', + 'finc\Controller\CartController' => 'VuFind\Controller\CartControllerFactory', ], 'aliases' => [ 'AdminI18n' => 'finc\Controller\Admin\I18nController', @@ -50,6 +51,8 @@ $config = [ 'VuFind\Controller\MyResearchController' => 'finc\Controller\MyResearchController', 'VuFind\Controller\RecordController' => 'finc\Controller\RecordController', 'VuFind\Controller\RecordsController' => 'finc\Controller\RecordsController', + 'Cart' => 'finc\Controller\CartController', + 'cart' => 'finc\Controller\CartController' ], ], 'controller_plugins' => [ diff --git a/module/finc/src/finc/Controller/CartController.php b/module/finc/src/finc/Controller/CartController.php new file mode 100644 index 0000000000000000000000000000000000000000..6f21439655578ce521de5a5d1cb080007ff8fcec --- /dev/null +++ b/module/finc/src/finc/Controller/CartController.php @@ -0,0 +1,138 @@ +<?php +/** + * Book Bag / Bulk Action Controller + * + * PHP version 7 + * + * Copyright (C) Leipzig University Library 2021. + * + * 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 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 + */ +namespace finc\Controller; + +/** + * Book Bag / Bulk Action Controller + * + * @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 Main Site + */ +class CartController extends \VuFind\Controller\CartController +{ + /** + * Delete group of records from favorites. + * + * @return mixed + */ + public function deleteAction() + { + // Force login: + $user = $this->getUser(); + if (!$user) { + return $this->forceLogin(); + } + + // Get target URL for after deletion: + $listID = $this->params()->fromPost('listID'); + + $newUrl = empty($listID) + ? $this->url()->fromRoute('myresearch-favorites') + : $this->url()->fromRoute('userList', ['id' => $listID]); + + // Fail if we have nothing to delete: + $ids = null === $this->params()->fromPost('selectAll') + ? $this->params()->fromPost('ids') + : $this->params()->fromPost('idsAll'); + if (!is_array($ids) || empty($ids)) { + $this->flashMessenger()->addMessage('bulk_noitems_advice', 'error'); + // finc specific: dont redirect in layout context for performance reasons - page reloads after closing of lighbox anyway + if ($this->params()->fromPost('layout', $this->params()->fromQuery('layout')) === 'lightbox') { + return; + } + // finc specific - END + return $this->redirect()->toUrl($newUrl); + } + + // Process the deletes if necessary: + if ($this->formWasSubmitted('submit')) { + $this->favorites()->delete($ids, $listID, $user); + $this->flashMessenger()->addMessage('fav_delete_success', 'success'); + // finc specific: dont redirect in layout context for performance reasons - page reloads after closing of lighbox anyway + if ($this->params()->fromPost('layout', $this->params()->fromQuery('layout')) === 'lightbox') { + return; + } + // finc specific - END + return $this->redirect()->toUrl($newUrl); + } + + // If we got this far, the operation has not been confirmed yet; show + // the necessary dialog box: + if (empty($listID)) { + $list = false; + } else { + $table = $this->getTable('UserList'); + $list = $table->getExisting($listID); + } + return $this->createViewModel( + [ + 'list' => $list, 'deleteIDS' => $ids, + 'records' => $this->getRecordLoader()->loadBatch($ids) + ] + ); + } + + /** + * Support method: redirect to the page we were on when the bulk action was + * initiated. + * + * @param string $flashNamespace Namespace for flash message (null for none) + * @param string $flashMsg Flash message to set (ignored if namespace null) + * + * @return mixed + */ + public function redirectToSource($flashNamespace = null, $flashMsg = null) + { + // Set flash message if requested: + if (null !== $flashNamespace && !empty($flashMsg)) { + $this->flashMessenger()->addMessage($flashMsg, $flashNamespace); + } + + // finc specific: dont redirect in layout context for performance reasons - page reloads after closing of lighbox anyway + if ($this->params()->fromPost('layout', $this->params()->fromQuery('layout')) === 'lightbox') { + $view = $this->createViewModel($this->params()->fromPost()); + $view->setTemplate('default/flash-message'); + return $view; + } + // finc specific - END + + // If we entered the controller in the expected way (i.e. via the + // myresearchbulk action), we should have a source set in the followup + // memory. If that's missing for some reason, just forward to MyResearch. + if (isset($this->session->url)) { + $target = $this->session->url; + unset($this->session->url); + } else { + $target = $this->url()->fromRoute('myresearch-home'); + } + return $this->redirect()->toUrl($target); + } +} diff --git a/module/finc/src/finc/Controller/RecordController.php b/module/finc/src/finc/Controller/RecordController.php index 5e29ba1c9e7a31a61da5f519dba7a5651dd87f51..acb8975cea63de14e78c11e7be1d3453c4808569 100644 --- a/module/finc/src/finc/Controller/RecordController.php +++ b/module/finc/src/finc/Controller/RecordController.php @@ -31,6 +31,7 @@ namespace finc\Controller; use finc\Rewrite\EblRewrite; use Zend\Log\LoggerAwareInterface as LoggerAwareInterface; +use Zend\View\View; /** * Record Controller @@ -61,4 +62,54 @@ class RecordController extends \VuFind\Controller\RecordController implements { return $this->serviceLocator->get(EblRewrite::class); } + + /** + * ProcessSave -- store the results of the Save action. + * + * @return mixed + */ + protected function processSave() + { + // Retrieve user object and force login if necessary: + if (!($user = $this->getUser())) { + return $this->forceLogin(); + } + + // Perform the save operation: + $driver = $this->loadRecord(); + $post = $this->getRequest()->getPost()->toArray(); + $tagParser = $this->serviceLocator->get('VuFind\Tags'); + $post['mytags'] + = $tagParser->parse($post['mytags'] ?? ''); + $favorites = $this->serviceLocator + ->get('VuFind\Favorites\FavoritesService'); + $results = $favorites->save($post, $user, $driver); + + // Display a success status message: + $listUrl = $this->url()->fromRoute('userList', ['id' => $results['listId']]); + $message = [ + 'html' => true, + 'msg' => $this->translate('bulk_save_success') . '. ' + . '<a href="' . $listUrl . '" class="gotolist">' + . $this->translate('go_to_list') . '</a>.' + ]; + $this->flashMessenger()->addMessage($message, 'success'); + + // finc specific: dont redirect in layout context for performance reasons + if ($this->params()->fromPost('layout', $this->params()->fromQuery('layout')) === 'lightbox') { + $view = $this->createViewModel($this->params()->fromPost()); + $view->setTemplate('default/flash-message'); + return $view; + } + // finc specific - END + + // redirect to followup url saved in saveAction + if ($url = $this->getFollowupUrl()) { + $this->clearFollowupUrl(); + return $this->redirect()->toUrl($url); + } + + // No followup info found? Send back to record view: + return $this->redirectToRecord(); + } } diff --git a/module/finc/src/finc/Hierarchy/TreeRenderer/JSTree.php b/module/finc/src/finc/Hierarchy/TreeRenderer/JSTree.php index 27545e6589dd0f06b9c170fccfc37af3fdeb19cd..33089995cb340666e0520ad52a9f72f22463605b 100644 --- a/module/finc/src/finc/Hierarchy/TreeRenderer/JSTree.php +++ b/module/finc/src/finc/Hierarchy/TreeRenderer/JSTree.php @@ -99,7 +99,7 @@ class JSTree extends \VuFind\Hierarchy\TreeRenderer\JSTree ] ]; } - $cache[$route] = $this->router->fromRoute($route, $params, $options); + $cache[$route] = $this->router->fromRoute($route, $params, $options ?? []); } elseif ($route == 'parent') { // this is nearly the same as for collections // but links on the record view i.e. record route @@ -118,7 +118,7 @@ class JSTree extends \VuFind\Hierarchy\TreeRenderer\JSTree } // use route 'record' here to avoid linking to the // collection view - $cache[$route] = $this->router->fromRoute('record', $params, $options); + $cache[$route] = $this->router->fromRoute('record', $params, $options ?? []); } else { $tab = $this->treeRendererConfig->linkedTabDefault ?? 'Description'; $params = [ diff --git a/module/finc/src/finc/ILS/Driver/FincILS.php b/module/finc/src/finc/ILS/Driver/FincILS.php index cdfafb8250baf4cc515f8844b320b238bbd91ee9..0ab8821c741002ad32a3749c30fa73dc4d57609d 100644 --- a/module/finc/src/finc/ILS/Driver/FincILS.php +++ b/module/finc/src/finc/ILS/Driver/FincILS.php @@ -480,7 +480,7 @@ class FincILS extends PAIA implements LoggerAwareInterface { if (isset($item['id']) && preg_match( - "/^" . $this->daiaIdPrefix . "([A-Za-z0-9]+):([^:]+)$/", + "/^" . $this->daiaIdPrefix . "([A-Za-z0-9]+):(.+)$/", $item['id'], $matches ) diff --git a/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php b/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php index 669e122b3fde56a5fc212e2f8910b5b29b65b8f3..2abc6a74c621c2eae16a1f72a609628c5c829a1d 100644 --- a/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php +++ b/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php @@ -757,7 +757,7 @@ trait LiberoDingTrait $this->getWebScraperUrl() . 'getMyLoanHistory.jsp', $params, null, - $this->_getLiberoDingRequestHeaders() + $this->getLiberoDingRequestHeaders() ); } catch (\Exception $e) { throw new ILSException($e->getMessage()); diff --git a/module/finc/src/finc/View/Helper/Root/MultiDataFieldsTrait.php b/module/finc/src/finc/View/Helper/Root/MultiDataFieldsTrait.php index 0f137ca2a6525f0f3072aa4fa5a872cba0576234..c60b928230643400c2e3e64ba4f65af36d41a09f 100644 --- a/module/finc/src/finc/View/Helper/Root/MultiDataFieldsTrait.php +++ b/module/finc/src/finc/View/Helper/Root/MultiDataFieldsTrait.php @@ -179,4 +179,46 @@ trait MultiDataFieldsTrait return $final; } + /** + * Multiline function for publication details + * used as a switch to use getImprint for DefaultRecord + * + * @param $data + * @param $options + * @param $driver + * @return array[] + */ + public function publicationDetailsImprint($data, $options, $driver) + { + $type = $driver->tryMethod('getRecordType'); + if ($type === 'default') { + $data = $driver->tryMethod('getImprint'); + if (empty($data)) { + return []; + } + return [[ + 'label' => 'Published', + 'values' => $data, + 'options' => [ + 'pos' => $options['pos'], + 'renderType' => 'RecordDriverTemplate', + 'template' => 'data-imprint.phtml', + ], + ]]; + } else { + $data = $driver->tryMethod('getPublicationDetails'); + if (empty($data)) { + return []; + } + return [[ + 'label' => 'Published', + 'values' => $data, + 'options' => [ + 'pos' => $options['pos'], + 'renderType' => 'RecordDriverTemplate', + 'template' => 'data-publicationDetails.phtml', + ], + ]]; + } + } } diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/record-icon-class.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/record-icon-class.phtml index c9db1eba1145a5242ff7bea91bad01fe2763c155..c665701859e2e522a6d8516918ad73c3656a7231 100644 --- a/themes/finc/templates/RecordDriver/DefaultRecord/record-icon-class.phtml +++ b/themes/finc/templates/RecordDriver/DefaultRecord/record-icon-class.phtml @@ -12,6 +12,9 @@ switch ($normalizedValue) { case 'free': echo 'fa-globe'; break; + case 'missing': + echo 'fa-question'; + break; default: echo 'fa-book'; break; diff --git a/themes/finc/templates/default/flash-message.phtml b/themes/finc/templates/default/flash-message.phtml new file mode 100644 index 0000000000000000000000000000000000000000..5d02c875ab456fb6e4ed2f7518b561dcf449bf92 --- /dev/null +++ b/themes/finc/templates/default/flash-message.phtml @@ -0,0 +1 @@ +<?=$this->flashmessages();?>