Commit 8493fc44 authored by Tim Wagner's avatar Tim Wagner
Browse files

[TASK] Refactor Backend Preview

parent f6be476a
......@@ -54,27 +54,29 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
$this->adaptPluginHeaderContent($headerContent, $row);
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setPartialRootPaths(['EXT:sg_youtube/Resources/Private/Partials/Backend']);
$view->setTemplateRootPaths(['EXT:sg_youtube/Resources/Private/Templates/Youtube']);
$view->setTemplate('Backend.html');
$view->assign('uid', $row['uid']);
// Set plugin options array
$pluginOptions = GeneralUtility::xml2array($row['pi_flexform'], 'T3:');
$templateOptions = [];
if (is_array($pluginOptions)) {
foreach ($pluginOptions['data']['sDEF']['lDEF'] as $option => $value) {
if ($option !== 'settings.showApiResult') {
// $option has the format 'settings.<key>', but in the template we want the language label which
// has the format 'flexform.<key>'.
$templateOptions[str_replace('settings.', '', $option)] = $value['vDEF'];
}
}
// Get available plugin settings and their values from flexform
$pluginConfiguration = GeneralUtility::xml2array(
$row['pi_flexform'], 'T3DataStructure'
)['data']['sDEF']['lDEF'];
$view->assignMultiple([
'pluginOptions' => $templateOptions,
'showApiResult' => $pluginOptions['data']['sDEF']['lDEF']['settings.showApiResult']['vDEF']
]);
}
$templateData = [
'youtubeId' => $pluginConfiguration['settings.id']['vDEF'],
'maxResults' => $pluginConfiguration['settings.maxResults']['vDEF'],
'showDescription' => (int) ($pluginConfiguration['settings.showDescription']['vDEF'] ?? 1),
'disableLightbox' => $pluginConfiguration['settings.disableLightbox']['vDEF'],
'disableLightboxMobile' => $pluginConfiguration['settings.disableLightboxMobile']['vDEF'],
'aspectRatio' => $pluginConfiguration['settings.aspectRatio']['vDEF'],
'thumbnailType' => $pluginConfiguration['settings.thumbnailType']['vDEF'],
'thumbnailImagesCount' => $pluginConfiguration['settings.thumbnailImages']['vDEF'],
'showApiResult' => $pluginConfiguration['settings.showApiResult']['vDEF'],
];
$view->assign('data', $templateData);
$itemContent .= $view->render();
}
......
......@@ -17,6 +17,10 @@
<source><![CDATA[Settings]]></source>
<target><![CDATA[Einstellungen]]></target>
</trans-unit>
<trans-unit id="backendPreview.thumbnailImagesCount" approved="yes">
<source><![CDATA[Number of thumbnail replacement images]]></source>
<target><![CDATA[Anzahl der Thumbnail-Ersatzbilder]]></target>
</trans-unit>
<trans-unit id="backendPreview.values" approved="yes">
<source><![CDATA[Values]]></source>
<target><![CDATA[Werte]]></target>
......
......@@ -14,6 +14,9 @@
<trans-unit id="backendPreview.settings">
<source><![CDATA[Settings]]></source>
</trans-unit>
<trans-unit id="backendPreview.thumbnailImagesCount">
<source><![CDATA[Number of thumbnail replacement images]]></source>
</trans-unit>
<trans-unit id="backendPreview.values">
<source><![CDATA[Values]]></source>
</trans-unit>
......
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<f:if condition="{boolValue}">
<f:then>
<core:icon alternativeMarkupIdentifier="inline" identifier="actions-check"/>
</f:then>
<f:else>
<core:icon alternativeMarkupIdentifier="inline" identifier="actions-close"/>
</f:else>
</f:if>
......@@ -8,7 +8,7 @@
<be:link.editRecord uid="{uid}" table="tt_content">
<br/>
<f:if condition="{showApiResult} == 1">
<f:if condition="{data.showApiResult}">
<div class="alert alert-warning">
<h4 class="alert-title">
<f:translate key="backendPreview.apiDebugWarning.header" extensionName="SgYoutube"/>
......@@ -29,17 +29,91 @@
</th>
</tr>
</thead>
<tbody>
<f:for each="{pluginOptions}" as="option" key="labelKey">
<tr>
<th scope="row">
<f:translate key="flexform.id" extensionName="SgYoutube"/>
</th>
<td>
{data.youtubeId}
</td>
</tr>
<tr>
<th scope="row">
<f:translate key="flexform.maxResults" extensionName="SgYoutube"/>
</th>
<td>
{data.maxResults}
</td>
</tr>
<tr>
<th scope="row">
<f:translate key="flexform.showDescription" extensionName="SgYoutube"/>
</th>
<td>
<f:render partial="BooleanIcon" arguments="{boolValue: '{data.showDescription}'}"/>
</td>
</tr>
<tr>
<th scope="row">
<f:translate key="flexform.disableLightbox" extensionName="SgYoutube"/>
</th>
<td>
<f:render partial="BooleanIcon" arguments="{boolValue: '{data.disableLightbox}'}"/>
</td>
</tr>
<tr>
<th scope="row">
<f:translate key="flexform.disableLightboxMobile" extensionName="SgYoutube"/>
</th>
<td>
<f:render partial="BooleanIcon" arguments="{boolValue: '{data.disableLightboxMobile}'}"/>
</td>
</tr>
<tr>
<th scope="row">
<f:translate key="flexform.thumbnailType" extensionName="SgYoutube"/>
</th>
<td>
<f:if condition="{data.thumbnailType}">
<f:then>
<f:translate key="flexform.thumbnailType.{data.thumbnailType}"
extensionName="SgYoutube"/>
</f:then>
<f:else>
<f:translate key="flexform.thumbnailType.default" extensionName="SgYoutube"/>
</f:else>
</f:if>
</td>
</tr>
<f:if condition="{data.thumbnailType} == 'byAspectRatio'">
<tr>
<th scope="row">
<f:translate key="flexform.aspectRatio" extensionName="SgYoutube"/>
</th>
<td>
{data.aspectRatio}
</td>
</tr>
</f:if>
<f:if condition="{data.thumbnailImagesCount} > 0">
<tr>
<th scope="row">
<f:translate key="flexform.{labelKey}" extensionName="SgYoutube"/>
<f:translate key="backendPreview.thumbnailImagesCount" extensionName="SgYoutube"/>
</th>
<td>
{option}
{data.thumbnailImagesCount}
</td>
</tr>
</f:for>
</f:if>
</tbody>
</table>
</be:link.editRecord>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment