Skip to content
Snippets Groups Projects
Commit 3be53ad6 authored by Alexander Purr's avatar Alexander Purr Committed by Dorian Merz
Browse files

refs #17176 [fid_adlr] subito partial copy - adlr specifics

* add adlr specific translations
* add subito partial copy special copyright warning for adlr
** add session to record controller via extending record controller delegator factory
** override partial copy record controller action
parent bd155794
No related merge requests found
......@@ -20,13 +20,13 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
*/
use fid\Controller\RecordControllerDelegatorFactory;
use fid\FormModel\PasswordChangeModel;
use fid_adlr\Controller\FeedbackController;
use fid_adlr\Controller\FeedbackControllerDelegatorFactory;
use fid_adlr\Controller\MyResearchController;
use fid_adlr\Controller\MyResearchControllerFactory;
use fid_adlr\Controller\RecordController;
use fid_adlr\Controller\RecordControllerDelegatorFactory;
use fid_adlr\Controller\SearchController;
use fid_adlr\Helper\Rss;
use fid_adlr\Hierarchy\TreeRenderer\JSTree as AdlrJSTree;
......
......@@ -21,10 +21,110 @@
namespace fid_adlr\Controller;
use fid\Service\DataTransferObject\Order;
use fid\Validator\SubitoPartialCopyPageBounds;
use fid\Validator\SubitoPartialCopyPageSelection;
use Zend\Form\Form;
use Zend\Http\PhpEnvironment\Request;
use Zend\Session\Container;
class RecordController extends \fid\Controller\RecordController
{
/**
* @var Container
*/
protected $session;
/**
* @param Container $session
*/
public function setSession($session): void
{
$this->session = $session;
}
public function getOrderLabel($driver)
{
return $this->getRecordCitation($driver);
}
public function fidSubitoPartialCopyAction ()
{
if (!($user = $this->getUser()))
{
return $this->forceLogin();
}
$type = "subito-partial-copy";
$driver = $this->loadRecord();
$recordId = $driver->tryMethod('getUniqueID');
$user = $this->client->requestUserDetails();
$messenger = $this->flashMessenger();
/** @var Form $form */
/** @var Request $request */
$request = $this->getRequest();
$form = $this->serviceLocator->get('fid-acquisition-subito-partial-copy-form');
// add number of pages specific validators
$recordPages = $driver->tryMethod('getNumberOfPages');
if ($recordPages)
{
$form->getInputFilter()->get('pages')->getValidatorChain()->attach(
new SubitoPartialCopyPageBounds(['numberPages' => $recordPages]),
true
);
// check if to pause selection validation for case that wrong warning message was thrown
if (!(isset($this->session->wrongSelection) && $this->session->wrongSelection == $request->getPost()->get('pages')))
{
$form->getInputFilter()->get('pages')->getValidatorChain()->attach(
new SubitoPartialCopyPageSelection(['numberPages' => $recordPages])
);
$wasWarned = false;
}
else
{
$wasWarned = true;
}
unset($this->session->wrongSelection);
}
if ($submitted = $this->formWasSubmitted())
{
$form->setData($request->getPost());
if ($form->isValid())
{
$url = $this->getRecordUrl($recordId);
$label = $this->getOrderLabel($driver);
$subitoPartialCopy = [
'selection' => $form->getData()['pages'],
'warning' => $wasWarned
];
$form->getHydrator()->hydrate(compact('driver','user', 'type', 'url', 'label', 'subitoPartialCopy'), $order = new Order());
$this->client->requestOrderCreation($order);
$message = $this->translate('fid::acquisition_success');
$messenger->addSuccessMessage($message);
return $this->redirect()->toRoute('record',['id' => $recordId]);
}
if ($errors = $form->getInputFilter()->get('pages')->getValidatorChain()->getMessages())
{
if( sizeof($errors) == 1 && array_key_exists ( SubitoPartialCopyPageSelection::PAGE_SELECTION, $errors ) )
{
$this->session->wrongSelection = $request->getPost()->get('pages');
}
}
}
$action = $this->url()->fromRoute('record-fidsubitopartialcopy',['id' => $recordId]);
$form->setAttribute('action', $action);
$form->prepare();
$view = $this->createViewModel();
$view->setVariables(compact('form','driver','user'));
$view->setTemplate('fid/record/acquisition-subito-partial-copy');
return $view;
}
}
<?php
/**
* FID adlr Record Controller Delegator Factory
*
* Copyright (C) Villanova University 2010.
* Copyright (C) Leipzig University Library 2020.
*
* 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 FID-adlr
* @package Controller
* @author Alexander Purr <purr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
*/
namespace fid_adlr\Controller;
use fid\Service\Client;
use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\DelegatorFactoryInterface;
use Zend\Session\Container;
class RecordControllerDelegatorFactory extends \fid\Controller\RecordControllerDelegatorFactory
{
public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null)
{
/** @var RecordController $instance */
$instance = parent::__invoke($container, $name, $callback,$options);
$session = new Container(
'Record', $container->get('Zend\Session\SessionManager')
);
$instance->setSession($session);
return $instance;
}
}
\ No newline at end of file
......@@ -52,6 +52,7 @@ Edit Account = Persönliche Angaben ändern
acquisition_fid_name = "adlr.link"
acquisition_library = "Universitätsbibliothek Leipzig"
acquisition_error_page_selection = "Der von Ihnen angegebene Seitenbereich überschreitet die urheberrechtlich erlaubten 10 Prozent des Gesamtumfangs. Das adlr.link-Team wird Ihre Bestellung daher wahrscheinlich nicht ausführen können. Bitte überprüfen Sie Ihre Angaben. Trotzdem bestellen?"
password_reset_form_title = "Passwort ändern"
password_reset_form_information = "Bitte geben Sie die E-Mail-Adresse ein, mit der Sie sich bei adlr.link registriert haben. Wir senden Ihnen einen Link per E-Mail, über den Sie Ihr Passwort ändern können."
......
......@@ -53,6 +53,7 @@ permission_extended_access = "Access to all services and licenses and staff view
acquisition_fid_name = "adlr.link"
acquisition_library = "Leipzig University Library"
acquisition_error_page_selection = "The page range you specify exceeds the 10 percent of the total volume permitted by copyright law. The adlr.link team will therefore probably not be able to process your order. Please check your order details. Order anyway?"
password_reset_form_title = "Change password"
password_reset_form_information = "Please enter the e-mail address by which you registered your user account at adlr.link. We will send you a link to change your password."
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment