Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
TYPO3
sg_youtube
Commits
8493fc44
Commit
8493fc44
authored
Feb 24, 2021
by
Tim Wagner
Browse files
[TASK] Refactor Backend Preview
parent
f6be476a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Classes/Hooks/PageLayoutView/PluginRenderer.php
View file @
8493fc44
...
...
@@ -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
();
}
...
...
Resources/Private/Language/de.locallang.xlf
View file @
8493fc44
...
...
@@ -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>
...
...
Resources/Private/Language/locallang.xlf
View file @
8493fc44
...
...
@@ -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>
...
...
Resources/Private/Partials/Backend/BooleanIcon.html
0 → 100644
View file @
8493fc44
{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>
Resources/Private/Templates/Youtube/Backend.html
View file @
8493fc44
...
...
@@ -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:f
or
>
</f:
i
f>
</tbody>
</table>
</be:link.editRecord>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment