Browse Source

Merge branch 'master' into use-strong-cryptography

pull/580/head
Alexander Bigga 2 months ago
committed by GitHub
parent
commit
e93de8fff1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 109 additions and 12 deletions
  1. +3
    -3
      Classes/Hooks/Form/FieldInformation/EditInProductionWarning.php
  2. +82
    -0
      Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php
  3. +1
    -1
      Configuration/TCA/tx_dlf_collections.php
  4. +1
    -1
      Configuration/TCA/tx_dlf_libraries.php
  5. +1
    -1
      Configuration/TCA/tx_dlf_metadata.php
  6. +8
    -2
      Configuration/TCA/tx_dlf_solrcores.php
  7. +1
    -1
      Configuration/TCA/tx_dlf_structures.php
  8. +4
    -0
      Resources/Private/Language/FlashMessages.xml
  9. +2
    -2
      Resources/Private/Language/Labels.xml
  10. +6
    -1
      ext_localconf.php

Classes/Hooks/Form/FieldWizard/EditInProductionWarning.php → Classes/Hooks/Form/FieldInformation/EditInProductionWarning.php View File

@@ -10,13 +10,13 @@
* LICENSE.txt file that was distributed with this source code.
*/

namespace Kitodo\Dlf\Hooks\Form\FieldWizard;
namespace Kitodo\Dlf\Hooks\Form\FieldInformation;

use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Backend\Form\AbstractNode;

/**
* FieldWizard renderType for TYPO3 FormEngine
* FieldInformation renderType for TYPO3 FormEngine
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @package TYPO3
@@ -42,7 +42,7 @@ class EditInProductionWarning extends AbstractNode
// Create flash message.
Helper::addMessage(
htmlspecialchars($GLOBALS['LANG']->getLL('flash.editInProductionWarning')),
htmlspecialchars($GLOBALS['LANG']->getLL('flash.attention')),
'', // We must not set a title/header, because <h4> isn't allowed in FieldInformation.
\TYPO3\CMS\Core\Messaging\FlashMessage::WARNING
);
// Add message to result array.

+ 82
- 0
Classes/Hooks/Form/FieldInformation/SolrCoreStatus.php View File

@@ -0,0 +1,82 @@
<?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\FieldInformation;

use Kitodo\Dlf\Common\Helper;
use Kitodo\Dlf\Common\Solr;
use TYPO3\CMS\Backend\Form\AbstractNode;

/**
* FieldInformation renderType for TYPO3 FormEngine
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @package TYPO3
* @subpackage dlf
* @access public
*/
class SolrCoreStatus extends AbstractNode
{
/**
* Shows Solr core status for given 'index_name'
*
* @access public
*
* @return array As defined in initializeResultArray() of AbstractNode
* Allowed tags are: "<a><br><br/><div><em><i><p><strong><span><code>"
*/
public function render(): array
{
$result = $this->initializeResultArray();
// Show only when editing existing records.
if ($this->data['command'] !== 'new') {
$core = $this->data['databaseRow']['index_name'];
// Load localization file.
$GLOBALS['LANG']->includeLLFile('EXT:dlf/Resources/Private/Language/FlashMessages.xml');
// Get Solr instance.
$solr = Solr::getInstance($core);
if ($solr->ready) {
// Get core data.
$coreAdminQuery = $solr->service->createCoreAdmin();
$action = $coreAdminQuery->createStatus();
$action->setCore($core);
$coreAdminQuery->setAction($action);
$response = $solr->service->coreAdmin($coreAdminQuery)->getStatusResult();
if ($response) {
$uptimeInSeconds = floor($response->getUptime() / 1000);
$dateTimeFrom = new \DateTime('@0');
$dateTimeTo = new \DateTime("@$uptimeInSeconds");
$uptime = $dateTimeFrom->diff($dateTimeTo)->format('%a ' . $GLOBALS['LANG']->getLL('flash.days') . ', %H:%I:%S');
$numDocuments = $response->getNumberOfDocuments();
$startTime = $response->getStartTime() ? strftime('%c', $response->getStartTime()->getTimestamp()) : 'N/A';
$lastModified = $response->getLastModified() ? strftime('%c', $response->getLastModified()->getTimestamp()) : 'N/A';
// Create flash message.
Helper::addMessage(
sprintf($GLOBALS['LANG']->getLL('flash.coreStatus'), $startTime, $uptime, $lastModified, $numDocuments),
'', // We must not set a title/header, because <h4> isn't allowed in FieldInformation.
\TYPO3\CMS\Core\Messaging\FlashMessage::INFO
);
}
} else {
// Could not fetch core status.
Helper::addMessage(
htmlspecialchars($GLOBALS['LANG']->getLL('solr.error')),
'', // We must not set a title/header, because <h4> isn't allowed in FieldInformation.
\TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
);
}
// Add message to result array.
$result['html'] = Helper::renderFlashMessages();
}
return $result;
}
}

+ 1
- 1
Configuration/TCA/tx_dlf_collections.php View File

@@ -125,7 +125,7 @@ return [
'max' => 255,
'eval' => 'required,uniqueInPid',
'default' => '',
'fieldWizard' => [
'fieldInformation' => [
'editInProductionWarning' => [
'renderType' => 'editInProductionWarning',
],


+ 1
- 1
Configuration/TCA/tx_dlf_libraries.php View File

@@ -89,7 +89,7 @@ return [
'max' => 255,
'eval' => 'required,uniqueInPid',
'default' => '',
'fieldWizard' => [
'fieldInformation' => [
'editInProductionWarning' => [
'renderType' => 'editInProductionWarning',
],


+ 1
- 1
Configuration/TCA/tx_dlf_metadata.php View File

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


+ 8
- 2
Configuration/TCA/tx_dlf_solrcores.php View File

@@ -44,11 +44,17 @@ return [
'index_name' => [
'label' => 'LLL:EXT:dlf/Resources/Private/Language/Labels.xml:tx_dlf_solrcores.index_name',
'config' => [
'type' => 'none',
'type' => 'input',
'size' => 30,
'max' => 255,
'eval' => 'alphanum,unique',
'eval' => 'alphanum,nospace,required,unique',
'default' => '',
'readOnly' => true,
'fieldInformation' => [
'solrCoreStatus' => [
'renderType' => 'solrCoreStatus',
],
],
],
],
],


+ 1
- 1
Configuration/TCA/tx_dlf_structures.php View File

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


+ 4
- 0
Resources/Private/Language/FlashMessages.xml View File

@@ -19,6 +19,8 @@
<label index="flash.done">Done!</label>
<label index="flash.warning">Warning!</label>
<label index="flash.error">Error!</label>
<label index="flash.coreStatus">Start Time: %s&lt;br /&gt;Uptime: %s&lt;br /&gt;Last Modified: %s&lt;br /&gt;Number of Documents: %u</label>
<label index="flash.days">days</label>
<label index="flash.running">Please wait...</label>
<label index="flash.newCollection">New collection "%s" [%u] added to database.</label>
<label index="flash.newLibrary">New library "%s" [%u] added to database.</label>
@@ -92,6 +94,8 @@
<label index="flash.done">Fertig!</label>
<label index="flash.warning">Warnung!</label>
<label index="flash.error">Fehler!</label>
<label index="flash.coreStatus">Startzeit: %s&lt;br /&gt;Laufzeit: %s&lt;br /&gt;Letzte Änderung: %s&lt;br /&gt;Anzahl Dokumente: %u</label>
<label index="flash.days">Tage</label>
<label index="flash.running">Indexierung läuft...</label>
<label index="flash.newCollection">Neue Sammlung "%s" [%u] zur Datenbank hinzugefügt.</label>
<label index="flash.newLibrary">Neue Bibliothek "%s" [%u] zur Datenbank hinzugefügt.</label>


+ 2
- 2
Resources/Private/Language/Labels.xml View File

@@ -107,7 +107,7 @@
<label index="tx_dlf_formats.tab1">General</label>
<label index="tx_dlf_solrcores">Solr Cores</label>
<label index="tx_dlf_solrcores.label">Display Label</label>
<label index="tx_dlf_solrcores.index_name">Solr Name</label>
<label index="tx_dlf_solrcores.index_name">Solr Core</label>
<label index="tx_dlf_solrcores.tab1">General</label>
<label index="tx_dlf_collections">Collections</label>
<label index="tx_dlf_collections.label">Display Label</label>
@@ -292,7 +292,7 @@
<label index="tx_dlf_formats.tab1">Allgemein</label>
<label index="tx_dlf_solrcores">Solr Kerne</label>
<label index="tx_dlf_solrcores.label">Anzeigeform</label>
<label index="tx_dlf_solrcores.index_name">Solr-Bezeichnung</label>
<label index="tx_dlf_solrcores.index_name">Solr-Kern</label>
<label index="tx_dlf_solrcores.tab1">Allgemein</label>
<label index="tx_dlf_collections">Sammlungen</label>
<label index="tx_dlf_collections.label">Anzeigeform</label>


+ 6
- 1
ext_localconf.php View File

@@ -254,5 +254,10 @@ if (\TYPO3_MODE === 'FE') {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][] = [
'nodeName' => 'editInProductionWarning',
'priority' => 30,
'class' => \Kitodo\Dlf\Hooks\Form\FieldWizard\EditInProductionWarning::class
'class' => \Kitodo\Dlf\Hooks\Form\FieldInformation\EditInProductionWarning::class
];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][] = [
'nodeName' => 'solrCoreStatus',
'priority' => 30,
'class' => \Kitodo\Dlf\Hooks\Form\FieldInformation\SolrCoreStatus::class
];

Loading…
Cancel
Save