Merge branch 'dev-extbase-fluid' of github.com:kitodo/kitodo-presentation into dev-extbase-fluid

This commit is contained in:
Alexander Bigga 2021-10-21 11:56:59 +02:00
commit f8c8752de3
12 changed files with 44 additions and 251 deletions

View File

@ -11,9 +11,7 @@
namespace Kitodo\Dlf\Controller;
use Kitodo\Dlf\Common\Document;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
@ -27,10 +25,8 @@ use TYPO3\CMS\Core\Utility\PathUtility;
* @subpackage dlf
* @access public
*/
class AudioplayerController extends ActionController
class AudioplayerController extends AbstractController
{
const PARAMETER_PREFIX = 'tx_dlf';
/**
* @var string
*/
@ -77,9 +73,9 @@ class AudioplayerController extends ActionController
}
/**
* The main method of the PlugIn
* The main method of the plugin
*
* @access public
* @return void
*/
public function mainAction()
{
@ -127,61 +123,4 @@ class AudioplayerController extends ActionController
}
}
// TODO: Needs to be placed in an abstract class
/**
* Loads the current document into $this->doc
*
* @access protected
*
* @return void
*/
protected function loadDocument($requestData)
{
// Check for required variable.
if (
!empty($requestData['id'])
&& !empty($this->settings['pages'])
) {
// Should we exclude documents from other pages than $this->settings['pages']?
$pid = (!empty($this->settings['excludeOther']) ? intval($this->settings['pages']) : 0);
// Get instance of \Kitodo\Dlf\Common\Document.
$this->doc = Document::getInstance($requestData['id'], $pid);
if (!$this->doc->ready) {
// Destroy the incomplete object.
$this->doc = null;
$this->logger->error('Failed to load document with UID ' . $requestData['id']);
} else {
// Set configuration PID.
$this->doc->cPid = $this->settings['pages'];
}
} elseif (!empty($requestData['recordId'])) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tx_dlf_documents');
// Get UID of document with given record identifier.
$result = $queryBuilder
->select('tx_dlf_documents.uid AS uid')
->from('tx_dlf_documents')
->where(
$queryBuilder->expr()->eq('tx_dlf_documents.record_id', $queryBuilder->expr()->literal($requestData['recordId'])),
Helper::whereExpression('tx_dlf_documents')
)
->setMaxResults(1)
->execute();
if ($resArray = $result->fetch()) {
$requestData['id'] = $resArray['uid'];
// Set superglobal $_GET array and unset variables to avoid infinite looping.
$_GET[$this->prefixId]['id'] = $requestData['id'];
unset($requestData['recordId'], $_GET[$this->prefixId]['recordId']);
// Try to load document.
$this->loadDocument($requestData);
} else {
$this->logger->error('Failed to load document with record ID "' . $requestData['recordId'] . '"');
}
} else {
$this->logger->error('Invalid UID ' . $requestData['id'] . ' or PID ' . $this->settings['pages'] . ' for document loading');
}
}
}

View File

@ -63,7 +63,7 @@ class FeedsController extends AbstractController
}
if (
!$this->settings['excludeOther']
!$this->settings['excludeOtherCollections']
|| empty($requestData['collection'])
|| GeneralUtility::inList($this->settings['collections'], $requestData['collection'])
) {

View File

@ -1,129 +0,0 @@
<?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\Plugin;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* Plugin AudioPlayer for the 'dlf' extension
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @package TYPO3
* @subpackage dlf
* @access public
*/
class AudioPlayer extends \Kitodo\Dlf\Common\AbstractPlugin
{
public $scriptRelPath = 'Classes/Plugin/AudioPlayer.php';
/**
* Holds the current audio file's URL, MIME type and optional label
*
* @var array
* @access protected
*/
protected $audio = [];
/**
* Adds Player javascript
*
* @access protected
*
* @return void
*/
protected function addPlayerJS()
{
// Inline CSS.
$inlineCSS = '#tx-dlf-audio { width: 100px; height: 100px; }';
// AudioPlayer configuration.
$audioPlayerConfiguration = '
$(document).ready(function() {
AudioPlayer = new dlfAudioPlayer({
audio: {
mimeType: "' . $this->audio['mimetype'] . '",
title: "' . $this->audio['label'] . '",
url: "' . $this->audio['url'] . '"
},
parentElId: "tx-dlf-audio",
swfPath: "' . PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath($this->extKey)) . 'Resources/Public/Javascript/jPlayer/jquery.jplayer.swf"
});
});
';
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addCssInlineBlock('kitodo-audioplayer-configuration', $inlineCSS);
$pageRenderer->addJsFooterInlineCode('kitodo-audioplayer-configuration', $audioPlayerConfiguration);
}
/**
* The main method of the PlugIn
*
* @access public
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
*
* @return string The content that is displayed on the website
*/
public function main($content, $conf)
{
$this->init($conf);
// Load current document.
$this->loadDocument();
if (
$this->doc === null
|| $this->doc->numPages < 1
) {
// Quit without doing anything if required variables are not set.
return $content;
} else {
// Set default values if not set.
// $this->piVars['page'] may be integer or string (physical structure @ID)
if (
(int) $this->piVars['page'] > 0
|| empty($this->piVars['page'])
) {
$this->piVars['page'] = MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
} else {
$this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalStructure);
}
$this->piVars['double'] = MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Check if there are any audio files available.
$fileGrpsAudio = GeneralUtility::trimExplode(',', $this->conf['settings.fileGrpAudio']);
while ($fileGrpAudio = array_shift($fileGrpsAudio)) {
if (!empty($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpAudio])) {
// Get audio data.
$this->audio['url'] = $this->doc->getFileLocation($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpAudio]);
$this->audio['label'] = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['label'];
$this->audio['mimetype'] = $this->doc->getFileMimeType($this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->piVars['page']]]['files'][$fileGrpAudio]);
break;
}
}
if (!empty($this->audio)) {
// Add jPlayer javascript.
$this->addPlayerJS();
} else {
// Quit without doing anything if required variables are not set.
return $content;
}
// Load template file.
$this->getTemplate();
return $this->pi_wrapInBaseClass($content);
}
}

View File

@ -16,7 +16,7 @@
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/Resources/Private/Language/AudioPlayer.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
<sheetTitle>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
@ -43,7 +43,7 @@
<settings.excludeOther>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/AudioPlayer.xml:tt_content.pi_flexform.excludeOther</label>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.excludeOther</label>
<config>
<type>check</type>
<default>1</default>
@ -53,7 +53,7 @@
<settings.elementId>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/AudioPlayer.xml:tt_content.pi_flexform.elementId</label>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.audioplayer.flexform.elementId</label>
<config>
<type>input</type>
<eval>required,alphanum_x,nospace</eval>
@ -64,7 +64,7 @@
<settings.templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/AudioPlayer.xml:tt_content.pi_flexform.templateFile</label>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>

View File

@ -61,7 +61,7 @@
<settings.excludeOther>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.excludeOther</label>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.excludeOtherCollections</label>
<config>
<type>check</type>
<default>0</default>

View File

@ -4,8 +4,8 @@ mod.wizards.newContentElement.wizardItems {
elements {
tx_dlf_audioplayer {
iconIdentifier = tx-dlf-audioplayer
title = LLL:EXT:dlf/Resources/Private/Language/AudioPlayer.xml:tt_content.plugin.title
description = LLL:EXT:dlf/Resources/Private/Language/AudioPlayer.xml:tt_content.plugin.description
title = LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.audioplayer.title
description = LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.audioplayer.description
tt_content_defValues {
CType = list
list_type = dlf_audioplayer

View File

@ -353,7 +353,7 @@ The TypoScript part is necessary to switch the page rendering to a different pag
:Default:
- :Property:
excludeOther_
excludeOtherCollections
:Data Type:
:ref:`t3tsref:data-type-boolean`
:Default:

View File

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<!--
* (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.
-->
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin AudioPlayer</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.plugin.title">Audio Player</label>
<label index="tt_content.plugin.description">Audio Player Plugin for Kitodo.Presentation</label>
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.excludeOther">Show only documents from the selected page</label>
<label index="tt_content.pi_flexform.elementId">@ID value of the HTML element for the audio player</label>
<label index="tt_content.pi_flexform.templateFile">Template file</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.plugin.title">Audio Player</label>
<label index="tt_content.plugin.description">Audio Player Plugin für Kitodo.Presentation</label>
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.excludeOther">Nur Dokumente der ausgewählten Seite anzeigen</label>
<label index="tt_content.pi_flexform.elementId">@ID-Wert des HTML-Elements für den Audioplayer</label>
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
</languageKey>
</data>
</T3locallang>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2021-10-20T14:50:48Z">
<file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2021-10-21T09:03:15Z">
<header>
<generator>LFEditor</generator>
</header>
@ -10,6 +10,10 @@
<target><![CDATA[Kollektionen]]></target>
</trans-unit>
<trans-unit id="flexform.excludeOther" approved="yes">
<source><![CDATA[Show only documents from the selected page]]></source>
<target><![CDATA[Nur Dokumente der ausgewählten Seite anzeigen]]></target>
</trans-unit>
<trans-unit id="flexform.excludeOtherCollections" approved="yes">
<source><![CDATA[Show only documents from the selected collection(s)]]></source>
<target><![CDATA[Nur Dokumente der ausgewählten Kollektion(en) berücksichtigen]]></target>
</trans-unit>
@ -49,6 +53,18 @@
<source><![CDATA[Template file]]></source>
<target><![CDATA[HTML-Template]]></target>
</trans-unit>
<trans-unit id="plugins.audioplayer.description" approved="yes">
<source><![CDATA[Audio Player Plugin for Kitodo.Presentation]]></source>
<target><![CDATA[Audio Player Plugin für Kitodo.Presentation]]></target>
</trans-unit>
<trans-unit id="plugins.audioplayer.flexform.elementId" approved="yes">
<source><![CDATA[@ID value of the HTML element for the audio player]]></source>
<target><![CDATA[@ID-Wert des HTML-Elements für den Audioplayer]]></target>
</trans-unit>
<trans-unit id="plugins.audioplayer.title" approved="yes">
<source><![CDATA[Kitodo: Audio Player]]></source>
<target><![CDATA[Kitodo: Audio Player]]></target>
</trans-unit>
<trans-unit id="plugins.feeds.description" approved="yes">
<source><![CDATA[Feeds Plugin for Kitodo.Presentation]]></source>
<target><![CDATA[Feeds Plugin für Kitodo.Presentation]]></target>

View File

@ -8,9 +8,12 @@
<trans-unit id="flexform.collections">
<source><![CDATA[Collections]]></source>
</trans-unit>
<trans-unit id="flexform.excludeOther">
<trans-unit id="flexform.excludeOtherCollections">
<source><![CDATA[Show only documents from the selected collection(s)]]></source>
</trans-unit>
<trans-unit id="flexform.excludeOther">
<source><![CDATA[Show only documents from the selected page]]></source>
</trans-unit>
<trans-unit id="flexform.library">
<source><![CDATA[Providing library]]></source>
</trans-unit>
@ -89,6 +92,15 @@
<trans-unit id="plugins.navigation.flexform.pageStep">
<source><![CDATA[How many pages should be skipped by "fast-forward" and "rewind" buttons?]]></source>
</trans-unit>
<trans-unit id="plugins.audioplayer.title">
<source><![CDATA[Kitodo: Audio Player]]></source>
</trans-unit>
<trans-unit id="plugins.audioplayer.description">
<source><![CDATA[Audio Player Plugin for Kitodo.Presentation]]></source>
</trans-unit>
<trans-unit id="plugins.audioplayer.flexform.elementId">
<source><![CDATA[@ID value of the HTML element for the audio player]]></source>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -1,12 +0,0 @@
<!--
* (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.
-->
<!-- ###TEMPLATE### -->
<div id="tx-dlf-audio" class="tx-dlf-audio"></div>
<!-- ###TEMPLATE### -->

View File

@ -1,3 +1,4 @@
<f:comment>
<!--
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
@ -7,7 +8,7 @@
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
-->
</f:comment>
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
<div class="tx-dlf-audioplayer">