Skip to content

Commit cddd2bf

Browse files
Reimplement ToolboxController and replace with sections in template
1 parent 151b2cd commit cddd2bf

File tree

3 files changed

+99
-95
lines changed

3 files changed

+99
-95
lines changed

Classes/Controller/ToolboxController.php

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,15 @@ private function renderTools(): void
7777
$tools = explode(',', $this->settings['tools']);
7878

7979
foreach ($tools as $tool) {
80-
match ($tool) {
81-
'tx_dlf_multiviewaddsourcetool', 'multiviewaddsourcetool' => $this->renderToolByName('renderMultiViewAddSourceTool'),
82-
'tx_dlf_annotationtool', 'annotationtool' => $this->renderToolByName('renderAnnotationTool'),
83-
'tx_dlf_audiovideotool', 'audiovideotool' => $this->renderToolByName('renderAudioVideoTool'),
84-
'tx_dlf_fulltextdownloadtool', 'fulltextdownloadtool' => $this->renderToolByName('renderFulltextDownloadTool'),
85-
'tx_dlf_fulltexttool', 'fulltexttool' => $this->renderToolByName('renderFulltextTool'),
86-
'tx_dlf_imagedownloadtool', 'imagedownloadtool' => $this->renderToolByName('renderImageDownloadTool'),
87-
'tx_dlf_imagemanipulationtool', 'imagemanipulationtool' => $this->renderToolByName('renderImageManipulationTool'),
88-
'tx_dlf_modeldownloadtool', 'modeldownloadtool' => $this->renderToolByName('renderModelDownloadTool'),
89-
'tx_dlf_pdfdownloadtool', 'pdfdownloadtool' => $this->renderToolByName('renderPdfDownloadTool'),
90-
'tx_dlf_rotationtool', 'rotationtool' => $this->renderToolByName('renderRotationTool'),
91-
'tx_dlf_scoretool', 'scoretool' => $this->renderToolByName('renderScoreTool'),
92-
'tx_dlf_searchindocumenttool', 'searchindocumenttool' => $this->renderToolByName('renderSearchInDocumentTool'),
93-
'tx_dlf_viewerselectiontool', 'viewerselectiontool' => $this->renderToolByName('renderViewerSelectionTool'),
94-
'tx_dlf_zoomtool', 'zoomtool' => $this->renderToolByName('renderZoomTool'),
95-
default => $this->logger->warning('Incorrect tool configuration: "' . $this->settings['tools'] . '". Tool "' . $tool . '" does not exist.')
96-
};
80+
$this->renderToolByName($tool);
9781
}
82+
83+
$toolsToRender = [];
84+
foreach ($tools as $tool) {
85+
$toolsToRender[$tool] = true;
86+
}
87+
88+
$this->view->assign('tools', $toolsToRender);
9889
}
9990
}
10091

@@ -109,8 +100,15 @@ private function renderTools(): void
109100
*/
110101
private function renderToolByName(string $tool): void
111102
{
112-
$this->$tool();
113-
$this->view->assign($tool, true);
103+
$functionName = 'render' . ucfirst($tool);
104+
if (!method_exists($this, $functionName)) {
105+
if ($functionName != 'rotationTool' && $functionName != 'zoomTool') {
106+
// rotation and zoom tool do not need a function, because they only render the buttons, no view arguments are needed
107+
$this->logger->warning('Incorrect tool configuration: "' . $this->settings['tools'] . '". Tool "' . $tool . '" does not exist.');
108+
}
109+
return;
110+
}
111+
$this->$functionName();
114112
}
115113

116114
/**
@@ -710,30 +708,4 @@ private function isFullTextEmpty(): bool
710708
}
711709
return true;
712710
}
713-
714-
/**
715-
* Renders the rotation tool (used in template)
716-
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
717-
*
718-
* @access private
719-
*
720-
* @return void
721-
*/
722-
private function renderRotationTool(): void
723-
{
724-
// Empty function, no view arguments needed
725-
}
726-
727-
/**
728-
* Renders the zoom tool (used in template)
729-
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
730-
*
731-
* @access private
732-
*
733-
* @return void
734-
*/
735-
private function renderZoomTool(): void
736-
{
737-
// Empty function, no view arguments needed
738-
}
739711
}

Documentation/Plugins/Index.rst

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,19 +1231,19 @@ TypoScript Configuration
12311231
`t3tsref:data-type-string`
12321232
:Default:
12331233
:Values:
1234-
* annotationtool
1235-
* audiovideotool
1236-
* fulltextdownloadtool
1237-
* fulltexttool
1238-
* imagedownloadtool
1239-
* imagemanipulationtool
1240-
* modeldownloadtool
1241-
* multiviewaddsourcetool
1242-
* pdfdownloadtool
1243-
* rotationtool
1244-
* searchindocumenttool
1245-
* scoretool
1246-
* zooomtool
1234+
* annotationTool
1235+
* audioVideoTool
1236+
* fulltextDownloadTool
1237+
* fulltextTool
1238+
* imageDownloadTool
1239+
* imageManipulationTool
1240+
* modelDownloadTool
1241+
* multiViewAddSourceTool
1242+
* pdfDownloadTool
1243+
* rotationtTool
1244+
* searchIndocumentTool
1245+
* scoreTool
1246+
* zooomTool
12471247

12481248
- :Property:
12491249
showAsList
@@ -1276,7 +1276,7 @@ This tool loads the Buttons for the Audiolabel-Image, Equalizer and Marker Table
12761276
12771277
plugin.tx_dlf_audiovideotool {
12781278
settings {
1279-
tools = audiovideotool
1279+
tools = audioVideoTool
12801280
}
12811281
}
12821282
@@ -1326,9 +1326,24 @@ The fulltext is fetched and rendered by JavaScript into the `<div id="tx-dlf-ful
13261326
13271327
plugin.tx_dlf_fulltexttool {
13281328
settings {
1329-
tools = fulltexttool
1329+
tools = fulltextTool
13301330
activateFullTextInitially = 0
13311331
fullTextScrollElement = html, body
1332+
showAsList = 0
1333+
}
1334+
}
1335+
1336+
Image Tool
1337+
~~~~~~~~~~~~~~~~~~~~~~
1338+
This tool adds buttons for rotating, zooming and manipulating the image to the toolbox and display them as list of elements.
1339+
1340+
.. code-block:: typoscript
1341+
:caption: Example configuration for Image Tool
1342+
1343+
plugin.tx_dlf_imagetool {
1344+
settings {
1345+
tools = rotationTool,zoomTool,imageManipulationTool
1346+
showAsList = 1
13321347
}
13331348
}
13341349
@@ -1344,7 +1359,7 @@ This tool makes it possible to extract the model URL from the METS file or use t
13441359
13451360
plugin.tx_dlf_modeldownloadtool {
13461361
settings {
1347-
tools = modeldownloadtool
1362+
tools = modelDownloadTool
13481363
}
13491364
}
13501365
@@ -1381,7 +1396,7 @@ The provided MIDI output of `Verovio` is played using the `html-midi-player <htt
13811396
13821397
plugin.tx_dlf_scoretool {
13831398
settings {
1384-
tools = scoretool
1399+
tools = scoreTool
13851400
midiPlayerSoundFont = default
13861401
}
13871402
}
@@ -1466,7 +1481,7 @@ This plugin adds a possibility to search all appearances of the phrase in curren
14661481
14671482
plugin.tx_dlf_searchindocumenttool {
14681483
settings {
1469-
tools = searchindocumenttool
1484+
tools = searchInDocumentTool
14701485
idInputName = tx_dlf[id]
14711486
pidInputName = tx_dlf[pid]
14721487
queryInputName = tx_dlf[query]
@@ -1491,7 +1506,7 @@ The model URL is extracted from the METS file or taken from the provided model p
14911506
14921507
plugin.tx_dlf_viewerselectiontool {
14931508
settings {
1494-
tools = viewerselectiontool
1509+
tools = viewerSelectionTool
14951510
}
14961511
}
14971512

Resources/Private/Templates/Toolbox/Main.html

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,65 +12,82 @@
1212
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
1313
data-namespace-typo3-fluid="true">
1414

15-
<f:if condition="{multiViewAddSourceTool}">
15+
<f:comment>Render all toolbox tools in the given order.</f:comment>
16+
<f:for each="{tools}" key="tool" as="enabled">
17+
<f:if condition="{tool}">
18+
<f:render section="render.{tool}" arguments="{_all}"/>
19+
</f:if>
20+
</f:for>
21+
22+
<f:section name="{render.multiViewAddSourceTool}">
1623
<f:render partial="Toolbox/MultiViewAddSourceTool" arguments="{_all}" />
17-
</f:if>
24+
</f:section>
1825

1926
<f:if condition="{settings.showAsList}">
2027
<ul>
2128
</f:if>
2229

23-
<f:if condition="{renderAnnotationTool}">
24-
<f:render partial="Toolbox/AnnotationTool" arguments="{_all}" />
25-
</f:if>
30+
<f:section name="{render.annotationTool}">
31+
<f:render partial="Toolbox/AnnotationTool" arguments="{_all}" />
32+
</f:section>
2633

27-
<f:if condition="{renderAudioVideoTool}">
28-
<f:render partial="Toolbox/AudioVideoTool" arguments="{_all}" />
29-
</f:if>
34+
<f:section name="{render.audioVideoTool}">
35+
<f:render partial="Toolbox/AudioVideoTool" arguments="{_all}" />
36+
</f:section>
3037

31-
<f:if condition="{renderImageDownloadTool} && {imageDownload}">
38+
<f:section name="{render.imageDownloadTool}">
39+
<f:if condition="{imageDownload}">
3240
<f:render partial="Toolbox/ImageDownloadTool" arguments="{_all}" />
3341
</f:if>
42+
</f:section>
3443

35-
<f:if condition="{renderImageManipulationTool}">
36-
<f:render partial="Toolbox/ImageManipulationTool" arguments="{_all}" />
37-
</f:if>
44+
<f:section name="{render.imageManipulationTool}">
45+
<f:render partial="Toolbox/ImageManipulationTool" arguments="{_all}" />
46+
</f:section>
3847

39-
<f:if condition="{renderFulltextDownloadTool}">
40-
<f:render partial="Toolbox/FulltextDownloadTool" arguments="{_all}" />
41-
</f:if>
48+
<f:section name="{render.fulltextDownloadTool}">
49+
<f:render partial="Toolbox/FulltextDownloadTool" arguments="{_all}" />
50+
</f:section>
4251

43-
<f:if condition="{renderFulltextTool}">
44-
<f:render partial="Toolbox/FulltextTool" arguments="{_all}" />
45-
</f:if>
52+
<f:section name="{render.fulltextTool}">
53+
<f:render partial="Toolbox/FulltextTool" arguments="{_all}" />
54+
</f:section>
4655

47-
<f:if condition="{renderModelDownloadTool} && {modelUrl}">
56+
<f:section name="{render.modelDownloadTool}">
57+
<f:if condition="{modelUrl}">
4858
<f:render partial="Toolbox/ModelDownloadTool" arguments="{_all}" />
4959
</f:if>
60+
</f:section>
5061

51-
<f:if condition="{renderPdfDownloadTool}">
52-
<f:render partial="Toolbox/PdfDownloadTool" arguments="{_all}" />
53-
</f:if>
62+
<f:section name="{render.pdfDownloadTool}">
63+
<f:render partial="Toolbox/PdfDownloadTool" arguments="{_all}" />
64+
</f:section>
5465

55-
<f:if condition="{renderRotationTool}">
56-
<f:render partial="Toolbox/RotationTool" arguments="{_all}" />
57-
</f:if>
66+
<f:section name="{render.rotationTool}">
67+
<f:render partial="Toolbox/RotationTool" arguments="{_all}" />
68+
</f:section>
5869

59-
<f:if condition="{renderScoreTool} && {score}">
70+
<f:section name="{render.scoreTool}">
71+
<f:if condition="{score}">
6072
<f:render partial="Toolbox/ScoreTool" arguments="{_all}" />
6173
</f:if>
74+
</f:section>
6275

63-
<f:if condition="{renderSearchInDocumentTool} && {searchInDocument}">
76+
<f:section name="{render.searchInDocumentTool}">
77+
<f:if condition="{searchInDocument}">
6478
<f:render partial="Toolbox/SearchInDocumentTool" arguments="{_all}" />
6579
</f:if>
80+
</f:section>
6681

67-
<f:if condition="{renderViewerSelectionTool} && {viewers}">
82+
<f:section name="{render.viewerSelectionTool}">
83+
<f:if condition="{viewers}">
6884
<f:render partial="Toolbox/ViewerSelectionTool" arguments="{_all}" />
6985
</f:if>
86+
</f:section>
7087

71-
<f:if condition="{renderZoomTool}">
72-
<f:render partial="Toolbox/ZoomTool" arguments="{_all}" />
73-
</f:if>
88+
<f:section name="{render.zoomTool}">
89+
<f:render partial="Toolbox/ZoomTool" arguments="{_all}" />
90+
</f:section>
7491

7592
<f:if condition="{settings.showAsList}">
7693
</ul>

0 commit comments

Comments
 (0)