Merge branch 'master' into use-strong-cryptography
このコミットが含まれているのは:
コミット
e93de8fff1
|
@ -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.
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -125,7 +125,7 @@ return [
|
|||
'max' => 255,
|
||||
'eval' => 'required,uniqueInPid',
|
||||
'default' => '',
|
||||
'fieldWizard' => [
|
||||
'fieldInformation' => [
|
||||
'editInProductionWarning' => [
|
||||
'renderType' => 'editInProductionWarning',
|
||||
],
|
||||
|
|
|
@ -89,7 +89,7 @@ return [
|
|||
'max' => 255,
|
||||
'eval' => 'required,uniqueInPid',
|
||||
'default' => '',
|
||||
'fieldWizard' => [
|
||||
'fieldInformation' => [
|
||||
'editInProductionWarning' => [
|
||||
'renderType' => 'editInProductionWarning',
|
||||
],
|
||||
|
|
|
@ -101,7 +101,7 @@ return [
|
|||
'max' => 255,
|
||||
'eval' => 'required,nospace,alphanum_x,uniqueInPid',
|
||||
'default' => '',
|
||||
'fieldWizard' => [
|
||||
'fieldInformation' => [
|
||||
'editInProductionWarning' => [
|
||||
'renderType' => 'editInProductionWarning',
|
||||
],
|
||||
|
|
|
@ -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',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
|
|
@ -111,7 +111,7 @@ return [
|
|||
'max' => 255,
|
||||
'eval' => 'required,nospace,alphanum_x,uniqueInPid',
|
||||
'default' => '',
|
||||
'fieldWizard' => [
|
||||
'fieldInformation' => [
|
||||
'editInProductionWarning' => [
|
||||
'renderType' => 'editInProductionWarning',
|
||||
],
|
||||
|
|
|
@ -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<br />Uptime: %s<br />Last Modified: %s<br />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<br />Laufzeit: %s<br />Letzte Änderung: %s<br />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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
];
|
||||
|
|
読み込み中…
新しいイシューから参照