Skip to content

Commit

Permalink
Merge 526a6be into dc56941
Browse files Browse the repository at this point in the history
  • Loading branch information
haogatyp committed Jul 2, 2021
2 parents dc56941 + 526a6be commit 8b5adc3
Show file tree
Hide file tree
Showing 19 changed files with 214 additions and 168 deletions.
1 change: 1 addition & 0 deletions Classes/Controller/AbstractDocumentFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use EWW\Dpf\Domain\Workflow\DocumentWorkflow;
use EWW\Dpf\Services\Email\Notifier;
use EWW\Dpf\Domain\Model\DepositLicenseLog;
use EWW\Dpf\Services\FeUser\GndDataService;
use Exception;

/**
Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/AjaxDocumentFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

use EWW\Dpf\Domain\Model\MetadataGroup;
use EWW\Dpf\Services\FeUser\GndDataService;
use EWW\Dpf\Services\Identifier\Urn;
use EWW\Dpf\Services\Transfer\DocumentTransferManager;
use EWW\Dpf\Services\Transfer\FedoraRepository;
Expand Down Expand Up @@ -74,7 +75,7 @@ public function groupAction($pageUid, $groupUid, $groupIndex)
$field->setMandatory($object->getMandatory());
$field->setAccessRestrictionRoles($object->getAccessRestrictionRoles());
$field->setInputField($object->getInputField());
$field->setInputOptions($object->getInputOptionList());
$field->setInputOptionList($object->getInputOptionList());
$field->setMaxIteration($object->getMaxIteration());
$field->setFillOutService($object->getFillOutService());
$field->setValidation($object->getValidation());
Expand Down Expand Up @@ -128,7 +129,7 @@ public function fieldAction($pageUid, $groupUid, $groupIndex, $fieldUid, $fieldI
$fieldItem->setMandatory($field->getMandatory());
$fieldItem->setAccessRestrictionRoles($field->getAccessRestrictionRoles());
$fieldItem->setInputField($field->getInputField());
$fieldItem->setInputOptions($field->getInputOptionList());
$fieldItem->setInputOptionList($field->getInputOptionList());
$fieldItem->setMaxIteration($field->getMaxIteration());
$fieldItem->setFillOutService($field->getFillOutService());
$fieldItem->setValidation($field->getValidation());
Expand Down Expand Up @@ -249,5 +250,4 @@ public function fillOutAction($fedoraPid)
}

}

}
72 changes: 72 additions & 0 deletions Classes/Controller/DataServiceAjaxController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
namespace EWW\Dpf\Controller;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use EWW\Dpf\Domain\Model\InputOptionList;
use EWW\Dpf\Services\FeUser\GndDataService;

/**
* DataServiceAjaxController
*/
class DataServiceAjaxController extends \EWW\Dpf\Controller\AbstractController
{
/**
* @param string $searchTerm
* @return false|string
*/
public function searchGndKeywordAction(string $searchTerm) {
$gndUserDataService = new GndDataService();
$result = $gndUserDataService->searchKeywordRequest($searchTerm);

$listArray = array();
$i = 0;
foreach ($result as $value) {
$listArray[$i]['value'] = $value->label;
$listArray[$i]['label'] = htmlentities($value->label);
$listArray[$i]['key'] = $value->id;
$i++;
}

return json_encode($listArray);
}

/**
* @param InputOptionList $inputOptionList
* @param string $searchTerm
* @return false|string
*/
public function autocompleteAction(InputOptionList $inputOptionList, string $searchTerm)
{
$listArray = array();
$i = 0;

if (
!empty(
$arr = preg_grep(
'/.*?'.$searchTerm.'.*?/i', $inputOptionList->getInputOptions()
)
)
) {
foreach ($arr as $key => $value) {
$listArray[$i]['value'] = $value;
$listArray[$i]['label'] = htmlentities($value);
$listArray[$i]['key'] = $key;
$i++;
}
}

return json_encode($listArray);
}
}
58 changes: 0 additions & 58 deletions Classes/Controller/GndController.php

This file was deleted.

43 changes: 27 additions & 16 deletions Classes/Domain/Model/DocumentFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class DocumentFormField extends AbstractFormElement

protected $selectOptions;

protected $inputOptions;

protected $fillOutService;

protected $defaultInputOption;
Expand All @@ -36,6 +34,11 @@ class DocumentFormField extends AbstractFormElement

protected $depositLicense = null;

/**
* @var \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList
*/
protected $inputOptionList;

/**
* @var string
*/
Expand Down Expand Up @@ -123,27 +126,35 @@ public function setInputField($inputField)
*/
public function getInputOptions()
{
return $this->inputOptions;
$inputOptions = array();

if ($this->inputOptionList) {
$inputOptions[''] = '';
foreach ($this->inputOptionList->getInputOptions() as $option => $label) {
$this->inputOptions[$option] = $label;
}

$this->defaultInputOption = trim($this->inputOptionList->getDefaultValue());
}

return $inputOptions;
}

/**
* @return \EWW\Dpf\Domain\Model\InputOptionList
*/
public function getInputOptionList()
{
return $this->inputOptionList;
}

/**
*
* @param \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList
*/
public function setInputOptions(\EWW\Dpf\Domain\Model\InputOptionList $inputOptionList = null)
public function setInputOptionList(\EWW\Dpf\Domain\Model\InputOptionList $inputOptionList = null)
{

$this->inputOptions = array();

if ($inputOptionList) {
$this->inputOptions[''] = '';
foreach ($inputOptionList->getInputOptions() as $option => $label) {
$this->inputOptions[$option] = $label;
}

$this->defaultInputOption = trim($inputOptionList->getDefaultValue());
}

$this->inputOptionList = $inputOptionList;
}

/**
Expand Down
24 changes: 16 additions & 8 deletions Classes/Domain/Model/InputOptionList.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,23 @@ public function setDisplayName($displayName)
*/
public function getInputOptions()
{

$values = explode("|", $this->getValueList());
$labels = explode("|", $this->getValueLabelList());

if (sizeof($values) != sizeof($labels)) {
throw new \Exception('Invalid input option list configuration.');
$valueList = $this->getValueList();
$valueLabelList = $this->getValueLabelList();

if (!empty($valueList) && !empty($valueLabelList)) {
$values = explode("|", $valueList);
$labels = explode("|", $valueLabelList);

if (sizeof($values) != sizeof($labels)) {
throw new \Exception('Invalid input option list configuration.');
}

return array_combine($values, $labels);
} elseif($valueList) {
return explode("|", $valueList);;
} else {
return explode("|", $valueLabelList);
}

return array_combine($values, $labels);
}

public function setL10nParent($l10nParent)
Expand Down
1 change: 1 addition & 0 deletions Classes/Domain/Model/MetadataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class MetadataObject extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity impl

const FILL_OUT_SERVICE_URN = 'urn';
const FILL_OUT_SERVICE_GND = 'gnd';
const FILL_OUT_AUTOCOMPLETE = 'autocomplete';

/**
* @var string
Expand Down
4 changes: 2 additions & 2 deletions Classes/Helper/DocumentMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function getDocumentForm(Document $document, $generateEmptyFields = true)
$documentFormField->setDataType($metadataObject->getDataType());
$documentFormField->setMaxIteration($metadataObject->getMaxIteration());
$documentFormField->setInputField($metadataObject->getInputField());
$documentFormField->setInputOptions($metadataObject->getInputOptionList());
$documentFormField->setInputOptionlist($metadataObject->getInputOptionList());
$documentFormField->setFillOutService($metadataObject->getFillOutService());
$documentFormField->setGndFieldUid($metadataObject->getGndFieldUid());
$documentFormField->setMaxInputLength($metadataObject->getMaxInputLength());
Expand Down Expand Up @@ -356,7 +356,7 @@ public function getDocumentForm(Document $document, $generateEmptyFields = true)
$documentFormField->setDataType($metadataObject->getDataType());
$documentFormField->setMaxIteration($metadataObject->getMaxIteration());
$documentFormField->setInputField($metadataObject->getInputField());
$documentFormField->setInputOptions($metadataObject->getInputOptionList());
$documentFormField->setInputOptionList($metadataObject->getInputOptionList());
$documentFormField->setFillOutService($metadataObject->getFillOutService());
$documentFormField->setGndFieldUid($metadataObject->getGndFieldUid());
$documentFormField->setMaxInputLength($metadataObject->getMaxInputLength());
Expand Down
2 changes: 1 addition & 1 deletion Classes/Helper/FormDataReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public function getDocumentForm()
$documentFormField->setValidation($metadataObject->getValidation());
$documentFormField->setDataType($metadataObject->getDataType());
$documentFormField->setMaxIteration($metadataObject->getMaxIteration());
$documentFormField->setInputOptions($metadataObject->getInputOptionList());
$documentFormField->setInputOptionList($metadataObject->getInputOptionList());
$documentFormField->setInputField($metadataObject->getInputField());
$documentFormField->setFillOutService($metadataObject->getFillOutService());
$documentFormField->setGndFieldUid($metadataObject->getGndFieldUid());
Expand Down
9 changes: 8 additions & 1 deletion Classes/Services/FeUser/GndDataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@ public function getOrganisationData($gndId) {
return $response->body;
}

}
public function searchKeywordRequest($searchTerm) {
$response = Request::get($this->apiUrl . 'search?filter=type:SubjectHeading&format=json:suggest&size=100&q=' . $this->searchTermReplacement($searchTerm))
->send();

return $response->body;
}

}
8 changes: 7 additions & 1 deletion Configuration/TCA/tx_dpf_domain_model_metadataobject.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
array('', 0),
array('LLL:EXT:dpf/Resources/Private/Language/locallang_db.xlf:tx_dpf_domain_model_metadataobject.fill_out_service.urn', \EWW\Dpf\Domain\Model\MetadataObject::FILL_OUT_SERVICE_URN),
array('LLL:EXT:dpf/Resources/Private/Language/locallang_db.xlf:tx_dpf_domain_model_metadataobject.fill_out_service.gnd', \EWW\Dpf\Domain\Model\MetadataObject::FILL_OUT_SERVICE_GND),
array('AUTOCOMPLETE', \EWW\Dpf\Domain\Model\MetadataObject::FILL_OUT_AUTOCOMPLETE),
),
'size' => 1,
'maxitems' => 1,
Expand All @@ -370,7 +371,12 @@
'onChange' => 'reload',
),
'gnd_field_uid' => array(
'displayCond' => 'FIELD:fill_out_service:=:'.\EWW\Dpf\Domain\Model\MetadataObject::FILL_OUT_SERVICE_GND,
'displayCond' => array(
'OR' => array(
'FIELD:fill_out_service:=:'.\EWW\Dpf\Domain\Model\MetadataObject::FILL_OUT_SERVICE_GND,
'FIELD:fill_out_service:=:'.\EWW\Dpf\Domain\Model\MetadataObject::FILL_OUT_AUTOCOMPLETE
)
),
'exclude' => 0,
'label' => 'LLL:EXT:dpf/Resources/Private/Language/locallang_db.xlf:tx_dpf_domain_model_metadataobject.gnd_field_uid',
'config' => array(
Expand Down
19 changes: 1 addition & 18 deletions Configuration/TypoScript/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,24 +196,6 @@ plugin.tx_dpf_backoffice {
}
}


// pi1 = GndAjax
// PAGE object for Ajax call:
search_page = PAGE
search_page {
typeNum = 427590

config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:application/json
debug = 0
no_cache = 1
admPanel = 0
}

10 < tt_content.list.20.dpf_kitodopublicationform
}

# Actions, only allowed for developers and configured hosts
[IP=devIP][hostname={$plugin.tx_dpf.settings.api.allowedHosts}]
plugin.tx_dpf.settings.allowedActions {
Expand Down Expand Up @@ -248,6 +230,7 @@ page.includeJSFooter.tx_dpf_moment = EXT:dpf/Resources/Public/JavaScript/moment-
page.includeJSFooter.tx_dpf_pooper = https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js
page.includeJSFooter.tx_dpf_bootstrap = EXT:dpf/Resources/Public/JavaScript/bootstrap.min.js
page.includeJSFooter.tx_dpf_bootstrap_datepicker = EXT:dpf/Resources/Public/JavaScript/bootstrap-datetimepicker-4_17_47.min.js
#page.includeJSFooter.tx_dpf_bootstrap_autocomplete = https://cdn.jsdelivr.net/gh/xcash/bootstrap-autocomplete@v2.3.7/dist/latest/bootstrap-autocomplete.min.js
page.includeJSFooter.tx_dpf_custom_file_input = EXT:dpf/Resources/Public/JavaScript/bs-custom-file-input.min.js
page.includeJSFooter.tx_dpfFilesaver = EXT:dpf/Resources/Public/JavaScript/FileSaver/FileSaver.min.js
page.includeJSFooter.tx_dpf_main = EXT:dpf/Resources/Public/JavaScript/kitodopublication.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
<target>Fillout Service</target>
</trans-unit>
<trans-unit id="gnd_field_uid.description" approved="yes">
<source>UID of the metadata object record which configures the GND No. field</source>
<target>UID des Metadatenobjekt-Datensatzes, der das Feld GND No. konfiguriert</target>
<source>UID of the metadata object record which configures the linked field</source>
<target>UID des Metadatenobjekt-Datensatzes, der das verknüpfte Feld konfiguriert</target>
</trans-unit>
<trans-unit id="input_field.description" approved="yes">
<source>Input field</source>
Expand Down
Loading

0 comments on commit 8b5adc3

Please sign in to comment.