Browse Source

Merge pull request #553 from sebastian-meyer/fix-datahandler

Make index_name editable
pull/577/head
Sebastian Meyer 1 year ago
committed by GitHub
parent
commit
87be21eb7d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      Classes/Hooks/DataHandler.php
  2. 53
      Classes/Hooks/Form/FieldWizard/EditInProductionWarning.php
  3. 7
      Configuration/TCA/tx_dlf_collections.php
  4. 7
      Configuration/TCA/tx_dlf_libraries.php
  5. 5
      Configuration/TCA/tx_dlf_metadata.php
  6. 5
      Configuration/TCA/tx_dlf_structures.php
  7. 26
      Resources/Private/Language/FlashMessages.xml
  8. 24
      Resources/Private/Language/Labels.xml
  9. 6
      ext_localconf.php

32
Classes/Hooks/DataHandler.php

@ -101,12 +101,12 @@ class DataHandler
break;
}
} elseif ($status == 'update') {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($table);
switch ($table) {
// Field post-processing for table "tx_dlf_metadata".
case 'tx_dlf_metadata':
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($table);
// Store field in index if it should appear in lists.
if (!empty($fieldArray['is_listed'])) {
$fieldArray['index_stored'] = 1;
@ -157,32 +157,6 @@ class DataHandler
$fieldArray['index_indexed'] = $resArray['index_autocomplete'];
}
}
// Field post-processing for tables "tx_dlf_metadata" and "tx_dlf_structures".
case 'tx_dlf_structures':
// The index name should not be changed in production.
if (isset($fieldArray['index_name'])) {
if (count($fieldArray) < 2) {
// Unset the whole field array.
$fieldArray = [];
} else {
// Get current index name.
$result = $queryBuilder
->select($table . '.index_autocomplete AS index_autocomplete')
->from($table)
->where(
$queryBuilder->expr()->eq($table . '.uid', intval($id)),
Helper::whereExpression($table)
)
->setMaxResults(1)
->execute();
if ($resArray = $result->fetch()) {
// Reset indexing to current.
$fieldArray['index_indexed'] = $resArray['index_autocomplete'];
}
}
Helper::devLog('Prevented change of index_name for UID ' . $id . ' in table "' . $table . '"', DEVLOG_SEVERITY_NOTICE);
}
break;
}
}

53
Classes/Hooks/Form/FieldWizard/EditInProductionWarning.php

@ -0,0 +1,53 @@
<?php
/**
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
namespace Kitodo\Dlf\Hooks\Form\FieldWizard;
use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Backend\Form\AbstractNode;
/**
* FieldWizard renderType for TYPO3 FormEngine
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @package TYPO3
* @subpackage dlf
* @access public
*/
class EditInProductionWarning extends AbstractNode
{
/**
* Generates warning message when editing 'index_name' field
*
* @access public
*
* @return array As defined in initializeResultArray() of AbstractNode
*/
public function render(): array
{
$result = $this->initializeResultArray();
// Show warning only when editing existing records.
if ($this->data['command'] !== 'new') {
// Load localization file.
$GLOBALS['LANG']->includeLLFile('EXT:dlf/Resources/Private/Language/FlashMessages.xml');
// Create flash message.
Helper::addMessage(
htmlspecialchars($GLOBALS['LANG']->getLL('flash.editInProductionWarning')),
htmlspecialchars($GLOBALS['LANG']->getLL('flash.attention')),
\TYPO3\CMS\Core\Messaging\FlashMessage::WARNING
);
// Add message to result array.
$result['html'] = Helper::renderFlashMessages();
}
return $result;
}
}

7
Configuration/TCA/tx_dlf_collections.php

@ -120,11 +120,16 @@ return [
'l10n_mode' => 'exclude',
'label' => 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_collections.index_name',
'config' => [
'type' => 'none',
'type' => 'input',
'size' => 30,
'max' => 255,
'eval' => 'required,uniqueInPid',
'default' => '',
'fieldWizard' => [
'editInProductionWarning' => [
'renderType' => 'editInProductionWarning',
],
],
],
],
'index_search' => [

7
Configuration/TCA/tx_dlf_libraries.php

@ -84,11 +84,16 @@ return [
'exclude' => 1,
'label' => 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_libraries.index_name',
'config' => [
'type' => 'none',
'type' => 'input',
'size' => 30,
'max' => 255,
'eval' => 'required,uniqueInPid',
'default' => '',
'fieldWizard' => [
'editInProductionWarning' => [
'renderType' => 'editInProductionWarning',
],
],
],
],
'website' => [

5
Configuration/TCA/tx_dlf_metadata.php

@ -101,6 +101,11 @@ return [
'max' => 255,
'eval' => 'required,nospace,alphanum_x,uniqueInPid',
'default' => '',
'fieldWizard' => [
'editInProductionWarning' => [
'renderType' => 'editInProductionWarning',
],
],
],
],
'format' => [

5
Configuration/TCA/tx_dlf_structures.php

@ -111,6 +111,11 @@ return [
'max' => 255,
'eval' => 'required,nospace,alphanum_x,uniqueInPid',
'default' => '',
'fieldWizard' => [
'editInProductionWarning' => [
'renderType' => 'editInProductionWarning',
],
],
],
],
'oai_name' => [

26
Resources/Private/Language/FlashMessages.xml

@ -58,6 +58,7 @@
<label index="flash.solrException">Apache Solr exception thrown:</label>
<label index="flash.solrNoConnection">Could not connect to Apache Solr server.</label>
<label index="flash.seeLog">See administration log for more details.</label>
<label index="flash.editInProductionWarning">Changing this most likely requires re-indexing all documents.</label>
<label index="update.metadataConfig">Updating metadata configuration...</label>
<label index="update.metadataConfigOkay">...successfully completed!</label>
<label index="update.metadataConfigNotOkay">...incomplete! Please check your configuration manually.</label>
@ -69,12 +70,12 @@
<label index="update.solariumSolrUpdateNotOkay">...failed for core %s! Please check your Solr configuration.</label>
<label index="update.FormatClasses">Switching format classes to namespaces...</label>
<label index="update.FormatClassesOkay">...successfully completed! Please check all format records in the page tree's root.</label>
<label index="update.documentAddFormat">Add document format column...</label>
<label index="update.documentAddFormatOkay">...successfully completed!</label>
<label index="update.documentAddFormatNotOkay">...incomplete! Please add column document_format for table tx_dlf_document manually.</label>
<label index="update.documentSetFormatForOldEntries">Set document format for existing entries to 'METS'...</label>
<label index="update.documentSetFormatForOldEntriesOkay">...successfully completed!</label>
<label index="update.documentSetFormatForOldEntriesNotOkay">...incomplete! Please set missing tx_dlf_document.document_format values to 'METS'.</label>
<label index="update.documentAddFormat">Add document format column...</label>
<label index="update.documentAddFormatOkay">...successfully completed!</label>
<label index="update.documentAddFormatNotOkay">...incomplete! Please add column document_format for table tx_dlf_document manually.</label>
<label index="update.documentSetFormatForOldEntries">Set document format for existing entries to 'METS'...</label>
<label index="update.documentSetFormatForOldEntriesOkay">...successfully completed!</label>
<label index="update.documentSetFormatForOldEntriesNotOkay">...incomplete! Please set missing tx_dlf_document.document_format values to 'METS'.</label>
<label index="solr.connected">Connection established!</label>
<label index="solr.status">Apache Solr is running and taking requests.</label>
<label index="solr.notConnected">Connection failed!</label>
@ -130,6 +131,7 @@
<label index="flash.solrException">Apache Solr meldet Ausnahmefehler:</label>
<label index="flash.solrNoConnection">Verbindung zu Apache Solr Server konnte nicht hergestellt werden.</label>
<label index="flash.seeLog">Alle Details des Indexierungslaufs stehen im Administrationsprotokoll.</label>
<label index="flash.editInProductionWarning">Eine Änderung erfordert höchstwahrscheinlich die Re-Indexierung aller Dokumente.</label>
<label index="update.metadataConfig">Aktualisierung der Metadatenkonfiguration...</label>
<label index="update.metadataConfigOkay">...erfolgreich beendet! Alle Datensätze wurden ins IRRE-Schema konvertiert.</label>
<label index="update.metadataConfigNotOkay">...abgebrochen! Die Überführung der Datensätze ins IRRE-Schema muss manuell erfolgen.</label>
@ -141,12 +143,12 @@
<label index="update.solariumSolrUpdateNotOkay">...für Kern %s fehlgeschlagen! Bitte überprüfen Sie die Solr-Konfiguration.</label>
<label index="update.FormatClasses">Format-Klassen auf Namensräume umstellen...</label>
<label index="update.FormatClassesOkay">...erfolgreich beendet! Bitte prüfen Sie dennoch alle Formateinträge im Wurzelknoten des Seitenbaums.</label>
<label index="update.documentAddFormat">Füge Format-Spalte zu Dokument-Tabelle hinzu...</label>
<label index="update.documentAddFormatOkay">...erfolgreich beendet!</label>
<label index="update.documentAddFormatNotOkay">...abgebrochen! Bitte fügen Sie die Spalte document_format manuell zur Tabelle table tx_dlf_document hinzu.</label>
<label index="update.documentSetFormatForOldEntries">Setze das Format für bestehende Dokumente auf 'METS'...</label>
<label index="update.documentSetFormatForOldEntriesOkay">...erfolgreich beendet!</label>
<label index="update.documentSetFormatForOldEntriesNotOkay">...abgebrochen! Bitte in der Tabelle tx_dlf_document.document_format 'METS'.</label>
<label index="update.documentAddFormat">Füge Format-Spalte zu Dokument-Tabelle hinzu...</label>
<label index="update.documentAddFormatOkay">...erfolgreich beendet!</label>
<label index="update.documentAddFormatNotOkay">...abgebrochen! Bitte fügen Sie die Spalte document_format manuell zur Tabelle table tx_dlf_document hinzu.</label>
<label index="update.documentSetFormatForOldEntries">Setze das Format für bestehende Dokumente auf 'METS'...</label>
<label index="update.documentSetFormatForOldEntriesOkay">...erfolgreich beendet!</label>
<label index="update.documentSetFormatForOldEntriesNotOkay">...abgebrochen! Bitte in der Tabelle tx_dlf_document.document_format 'METS'.</label>
<label index="solr.connected">Verbindung hergestellt!</label>
<label index="solr.status">Apache Solr ist verfügbar und nimmt Anfragen entgegen.</label>
<label index="solr.notConnected">Verbindung fehlgeschlagen!</label>

24
Resources/Private/Language/Labels.xml

@ -56,9 +56,9 @@
<label index="tx_dlf_documents.owner">Owner</label>
<label index="tx_dlf_documents.status">Status</label>
<label index="tx_dlf_documents.status.default">default</label>
<label index="tx_dlf_documents.document_format">METS or IIIF</label>
<label index="tx_dlf_documents.document_format.mets">METS</label>
<label index="tx_dlf_documents.document_format.iiif">IIIF</label>
<label index="tx_dlf_documents.document_format">METS or IIIF</label>
<label index="tx_dlf_documents.document_format.mets">METS</label>
<label index="tx_dlf_documents.document_format.iiif">IIIF</label>
<label index="tx_dlf_documents.tab1">Titledata</label>
<label index="tx_dlf_documents.tab2">Identifier</label>
<label index="tx_dlf_documents.tab3">Access</label>
@ -186,9 +186,9 @@
<label index="config.fileGrpDownload">Download fileGrp: @USE attribute value (default is "DOWNLOAD")</label>
<label index="config.fileGrpFulltext">Fulltext fileGrp: @USE attribute value (default is "FULLTEXT")</label>
<label index="config.fileGrpAudio">Audio fileGrp: @USE attribute value (default is "AUDIO")</label>
<label index="config.indexAnnotations">Handle IIIF annotations with motivation "painting" as fulltext?: Handling annotations as fulltexts means they are indexed (default is "FALSE")</label>
<label index="config.iiifThumbnailWidth">Maximum thumbnail width for IIIF images: Only for images without a thumbnail declaration (default is "150")</label>
<label index="config.iiifThumbnailHeight">Maximum thumbnail height for IIIF images: Only for images without a thumbnail declaration (default is "150")</label>
<label index="config.indexAnnotations">Handle IIIF annotations with motivation "painting" as fulltext?: Handling annotations as fulltexts means they are indexed (default is "FALSE")</label>
<label index="config.iiifThumbnailWidth">Maximum thumbnail width for IIIF images: Only for images without a thumbnail declaration (default is "150")</label>
<label index="config.iiifThumbnailHeight">Maximum thumbnail height for IIIF images: Only for images without a thumbnail declaration (default is "150")</label>
<label index="config.solrConnect">Solr Connection</label>
<label index="config.solrHttps">Use HTTPS: (default is "FALSE")</label>
<label index="config.solrHost">Solr Server Host: (default is "localhost")</label>
@ -241,9 +241,9 @@
<label index="tx_dlf_documents.owner">Besitzer</label>
<label index="tx_dlf_documents.status">Status</label>
<label index="tx_dlf_documents.status.default">Standard</label>
<label index="tx_dlf_documents.document_format">METS oder IIIF</label>
<label index="tx_dlf_documents.document_format.mets">METS</label>
<label index="tx_dlf_documents.document_format.iiif">IIIF</label>
<label index="tx_dlf_documents.document_format">METS oder IIIF</label>
<label index="tx_dlf_documents.document_format.mets">METS</label>
<label index="tx_dlf_documents.document_format.iiif">IIIF</label>
<label index="tx_dlf_documents.tab1">Titeldaten</label>
<label index="tx_dlf_documents.tab2">Identifier</label>
<label index="tx_dlf_documents.tab3">Zugriff</label>
@ -371,9 +371,9 @@
<label index="config.fileGrpDownload">Download fileGrp: @USE Attributwert der Downloads (Standard ist "DOWNLOAD")</label>
<label index="config.fileGrpFulltext">Volltext fileGrp: @USE Attributwert der Volltexte (Standard ist "FULLTEXT")</label>
<label index="config.fileGrpAudio">Audio fileGrp: @USE Attributwert der Audiodateien (Standard ist "AUDIO")</label>
<label index="config.indexAnnotations">IIIF-Annotationen mit Motivation "painting" als Volltext behandeln?: Als Volltext behandelte Annotationen werden im Suchindex indexiert (Standard ist "FALSE")</label>
<label index="config.iiifThumbnailWidth">Maximale Thumbnail-Breite für IIIF-Images: Gilt nur für Bilder ohne Thumbnail-Angaben (Standard ist "150")</label>
<label index="config.iiifThumbnailHeight">Maximale Thumbnail-Höhe für IIIF-Images: Gilt nur für Bilder ohne Thumbnail-Angaben (Standard ist "150")</label>
<label index="config.indexAnnotations">IIIF-Annotationen mit Motivation "painting" als Volltext behandeln?: Als Volltext behandelte Annotationen werden im Suchindex indexiert (Standard ist "FALSE")</label>
<label index="config.iiifThumbnailWidth">Maximale Thumbnail-Breite für IIIF-Images: Gilt nur für Bilder ohne Thumbnail-Angaben (Standard ist "150")</label>
<label index="config.iiifThumbnailHeight">Maximale Thumbnail-Höhe für IIIF-Images: Gilt nur für Bilder ohne Thumbnail-Angaben (Standard ist "150")</label>
<label index="config.solrConnect">Solr Verbindung</label>
<label index="config.solrHttps">HTTPS verwenden: (Standard ist "FALSE")</label>
<label index="config.solrHost">Solr Server Host: (Standard ist "localhost")</label>

6
ext_localconf.php

@ -250,3 +250,9 @@ if (\TYPO3_MODE === 'FE') {
return ($hook->getDocumentType($pid) === $type);
}
}
// Add new renderType for TCA fields.
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][] = [
'nodeName' => 'editInProductionWarning',
'priority' => 30,
'class' => \Kitodo\Dlf\Hooks\Form\FieldWizard\EditInProductionWarning::class
];

Loading…
Cancel
Save