Skip to content

Commit

Permalink
Merge pull request #155 from effective-webwork/backoffice-to-frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
claussni authored Jan 10, 2020
2 parents ea78852 + a507f17 commit 3749807
Show file tree
Hide file tree
Showing 152 changed files with 11,850 additions and 3,546 deletions.
2 changes: 2 additions & 0 deletions Build/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
container_name: kitodo-publication-mysql
command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci
hostname: db
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: typo3
Expand Down
57 changes: 39 additions & 18 deletions Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,25 @@
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;

abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
/**
* authorizationChecker
*
* @var \EWW\Dpf\Security\AuthorizationChecker
* @inject
*/
protected $authorizationChecker = null;

/**
* security
*
* @var \EWW\Dpf\Security\Security
* @inject
*/
protected $security = null;

/**
* clientRepository
Expand All @@ -27,29 +43,27 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
*/
protected $clientRepository = null;




protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
{
parent::initializeView($view);

if (TYPO3_MODE === 'BE') {
$selectedPageId = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
if ($selectedPageId) {
$client = $this->clientRepository->findAll()->current();
}
$client = $this->clientRepository->findAll()->current();

$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:manager.chooseClientMessage';
$message = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key, 'dpf');

if (!$client) {
$this->addFlashMessage(
$message,
$messageTitle = '',
$severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING,
$storeInSession = true
);
} else {
$view->assign('client', $client);
}
$key = 'LLL:EXT:dpf/Resources/Private/Language/locallang.xlf:manager.chooseClientMessage';
$message = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key, 'dpf');

if (!$client) {
$this->addFlashMessage(
$message,
$messageTitle = '',
$severity = \TYPO3\CMS\Core\Messaging\AbstractMessage::WARNING,
$storeInSession = true
);
} else {
$view->assign('client', $client);
}
}

Expand Down Expand Up @@ -132,4 +146,11 @@ protected function filterSafelyParameters($param)
}
}

public function initializeAction()
{
parent::initializeAction();

$signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
$signalSlotDispatcher->dispatch(get_class($this), 'actionChange', [$this->actionMethodName, get_class($this)]);
}
}
82 changes: 30 additions & 52 deletions Classes/Controller/AbstractDocumentFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
*/

use EWW\Dpf\Domain\Model\Document;
use EWW\Dpf\Services\Email\Notifier;
use EWW\Dpf\Services\Transfer\ElasticsearchRepository;
use EWW\Dpf\Helper\DocumentMapper;
use EWW\Dpf\Helper\ElasticsearchMapper;
use EWW\Dpf\Helper\FormDataReader;
use EWW\Dpf\Domain\Workflow\DocumentWorkflow;

/**
* DocumentFormController
*/
abstract class AbstractDocumentFormController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
abstract class AbstractDocumentFormController extends \EWW\Dpf\Controller\AbstractController
{

/**
Expand Down Expand Up @@ -82,7 +82,6 @@ abstract class AbstractDocumentFormController extends \TYPO3\CMS\Extbase\Mvc\Con
*/
public function listAction()
{

$documents = $this->documentRepository->findAll();

$documentTypes = $this->documentTypeRepository->findAll();
Expand Down Expand Up @@ -122,18 +121,6 @@ public function listAction()
$this->view->assign('documents', $documents);
}

/**
* action show
*
* @param \EWW\Dpf\Domain\Model\Document $document
* @return void
*/
public function showAction(\EWW\Dpf\Domain\Model\Document $document)
{

$this->view->assign('document', $document);
}

/**
* initialize newAction
*
Expand Down Expand Up @@ -210,10 +197,21 @@ public function initializeCreateAction()
*/
public function createAction(\EWW\Dpf\Domain\Model\DocumentForm $newDocumentForm)
{

$documentMapper = $this->objectManager->get(DocumentMapper::class);

/* @var $newDocument \EWW\Dpf\Domain\Model\Document */
$newDocument = $documentMapper->getDocument($newDocumentForm);

$workflow = $this->objectManager->get(DocumentWorkflow::class)->getWorkflow();

if ($this->request->getPluginName() === "Backoffice") {
$ownerUid = $this->security->getUser()->getUid();
$newDocument->setOwner($ownerUid);
$workflow->apply($newDocument, \EWW\Dpf\Domain\Workflow\DocumentWorkflow::TRANSITION_CREATE);
} else {
$workflow->apply($newDocument, \EWW\Dpf\Domain\Workflow\DocumentWorkflow::TRANSITION_CREATE_REGISTER);
}

// xml data fields are limited to 64 KB
if (strlen($newDocument->getXmlData()) >= 64 * 1024 || strlen($newDocument->getSlubInfoData() >= 64 * 1024)) {
throw new \EWW\Dpf\Exceptions\DocumentMaxSizeErrorException("Maximum document size exceeded.");
Expand All @@ -239,38 +237,25 @@ public function createAction(\EWW\Dpf\Domain\Model\DocumentForm $newDocumentForm
}
}
}

$notifier = $this->objectManager->get(Notifier::class);

$notifier->sendNewDocumentNotification($newDocument);

$requestArguments = $this->request->getArguments();

if (array_key_exists('savecontinue', $requestArguments)) {

$tmpDocument = $this->objectManager->get(Document::class);

$tmpDocument->setTitle($newDocument->getTitle());
$tmpDocument->setAuthors($newDocument->getAuthors());
$tmpDocument->setXmlData($newDocument->getXmlData());
$tmpDocument->setSlubInfoData($newDocument->getSlubInfoData());
$tmpDocument->setDocumentType($newDocument->getDocumentType());

$this->forward('new', null, null, array('newDocumentForm' => $documentMapper->getDocumentForm($tmpDocument)));
}

}

public function initializeEditAction()
{

$requestArguments = $this->request->getArguments();

if (array_key_exists('document', $requestArguments)) {
$documentUid = $this->request->getArgument('document');
$document = $this->documentRepository->findByUid($documentUid);
$mapper = $this->objectManager->get(DocumentMapper::class);
$documentForm = $mapper->getDocumentForm($document);

if ($this->request->getArgument('document') instanceof \EWW\Dpf\Domain\Model\Document) {
$document = $this->request->getArgument('document');
} elseif (is_numeric($this->request->getArgument('document'))) {
$document = $this->documentRepository->findByUid($this->request->getArgument('document'));
}

if ($document) {
$mapper = $this->objectManager->get(DocumentMapper::class);
$documentForm = $mapper->getDocumentForm($document);
}

} elseif (array_key_exists('documentForm', $requestArguments)) {
$documentForm = $this->request->getArgument('documentForm');
}
Expand Down Expand Up @@ -327,10 +312,9 @@ public function initializeUpdateAction()
*/
public function updateAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm)
{

$requestArguments = $this->request->getArguments();

$documentMapper = $this->objectManager->get(DocumentMapper::class);

/* @var $updateDocument \EWW\Dpf\Domain\Model\Document */
$updateDocument = $documentMapper->getDocument($documentForm);

// xml data fields are limited to 64 KB
Expand Down Expand Up @@ -366,12 +350,6 @@ public function updateAction(\EWW\Dpf\Domain\Model\DocumentForm $documentForm)
}

}

if (array_key_exists('savecontinue', $requestArguments)) {
$this->forward('edit', null, null, array('documentForm' => $documentForm));
}

$this->redirectToList();
}

/**
Expand All @@ -384,9 +362,9 @@ public function cancelAction()
$this->redirectToList();
}

public function initializeAction()
protected function redirectAfterUpdate()
{
parent::initializeAction();
$this->redirect('list');
}

protected function redirectToList($message = null)
Expand Down
17 changes: 1 addition & 16 deletions Classes/Controller/AbstractSearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ abstract class AbstractSearchController extends \EWW\Dpf\Controller\AbstractCont
private static $matches = ['title', 'abstract', 'author', 'language', 'tag', 'corporation', 'doctype', 'collections'];


protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
{
parent::initializeView($view);

if (TYPO3_MODE === 'BE') {
$selectedPageId = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
if ($selectedPageId) {
$client = $this->clientRepository->findAll()->current();
}
if (!$client) {
$this->redirect('list','Document');
}
}
}

/**
* get results from elastic search
* @param array $query elasticsearch search query
Expand Down Expand Up @@ -144,7 +129,7 @@ public function resultsFilter($query, $showDeleted = false)
// add doctypes
if($searchResultsFilter['doctype']) {

$uids = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $searchResultsFilter['doctype']);
$uids = GeneralUtility::trimExplode(',', $searchResultsFilter['doctype']);
$documentTypeRepository = $this->documentTypeRepository;
$documentTypes = array();
foreach($uids as $uid) {
Expand Down
4 changes: 2 additions & 2 deletions Classes/Controller/AjaxDocumentFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function groupAction($pageUid, $groupUid, $groupIndex)
$field->setUid($object->getUid());
$field->setDisplayName($object->getDisplayName());
$field->setMandatory($object->getMandatory());
$field->setBackendOnly($object->getBackendOnly());
$field->setAccessRestrictionRoles($object->getAccessRestrictionRoles());
$field->setInputField($object->getInputField());
$field->setInputOptions($object->getInputOptionList());
$field->setMaxIteration($object->getMaxIteration());
Expand Down Expand Up @@ -103,7 +103,7 @@ public function fieldAction($pageUid, $groupUid, $groupIndex, $fieldUid, $fieldI
$fieldItem->setUid($field->getUid());
$fieldItem->setDisplayName($field->getDisplayName());
$fieldItem->setMandatory($field->getMandatory());
$fieldItem->setBackendOnly($field->getBackendOnly());
$fieldItem->setAccessRestrictionRoles($field->getAccessRestrictionRoles());
$fieldItem->setInputField($field->getInputField());
$fieldItem->setInputOptions($field->getInputOptionList());
$fieldItem->setMaxIteration($field->getMaxIteration());
Expand Down
Loading

0 comments on commit 3749807

Please sign in to comment.