Skip to content

Commit

Permalink
[FEATURE][WIP] add generic rendering of contentBlock properties #35
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaseberle committed Jan 24, 2021
1 parent b7fb7a0 commit 89b092e
Show file tree
Hide file tree
Showing 28 changed files with 174 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Build/packages/example-local/src/EditorPreview.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<f:asset.css identifier="cb-{cb.key}" href="CB:{cb.key}/dist/EditorPreview.css"/>
<div class="counter">
<f:debug inline="1">{_all}</f:debug>
<f:render partial="Backend/Fields" arguments="{fields: cb.yaml.fields, values: _all, cb: cb}"/>
</div>

</html>
17 changes: 14 additions & 3 deletions Classes/Backend/Preview/PreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,20 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setTemplatePathAndFilename($cbConfiguration['EditorPreview.html']);

// TODO use TypoScript configuration for paths
$view->setPartialRootPaths([$cbConfiguration['srcPath']]);
$view->setLayoutRootPaths([$cbConfiguration['srcPath']]);
// TODO: use TypoScript configuration for paths
// TODO: add partialRootPath to cbConf
$view->setPartialRootPaths(
[
'EXT:contentblocks_reg_api/Resources/Private/Partials/',
$cbConfiguration['srcPath'],
]
);
$view->setLayoutRootPaths(
[
'EXT:contentblocks_reg_api/Resources/Private/Layouts/',
$cbConfiguration['srcPath'],
]
);

$view->assign('data', $record);

Expand Down
28 changes: 14 additions & 14 deletions Classes/Generator/FlexFormGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ protected function createTypoLink(array $field, array $contentBlock) :string
return '
<' . $field['_identifier'] . '>
<TCEforms>
<label>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<label>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.label</label>
<description>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<description>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.description</description>
<config>
<type>input</type>
Expand Down Expand Up @@ -171,9 +171,9 @@ protected function createInputField(array $field, array $contentBlock) :string
return '
<' . $field['_identifier'] . '>
<TCEforms>
<label>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<label>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.label</label>
<description>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<description>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.description</description>
<config>
<type>input</type>
Expand All @@ -199,9 +199,9 @@ protected function createImageField(array $field, array $contentBlock) :string
return '
<' . $field['_identifier'] . '>
<TCEforms>
<label>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<label>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.label</label>
<description>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<description>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.description</description>
<config>
Expand Down Expand Up @@ -283,9 +283,9 @@ protected function createTextarea(array $field, array $contentBlock) :string
return '
<' . $field['_identifier'] . '>
<TCEforms>
<label>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<label>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.label</label>
<description>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<description>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.description</description>
<config>
<type>text</type>
Expand Down Expand Up @@ -334,7 +334,7 @@ protected function createCollection(array $field, array $contentBlock) :string
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<sheetTitle>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.label</sheetTitle>
</TCEforms>
<type>array</type>
Expand All @@ -348,10 +348,10 @@ protected function createCollection(array $field, array $contentBlock) :string

return '<' . $field['_identifier'] . '>
<TCEforms>
<label>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<label>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.label</label>
<config>
<label>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<label>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.label</label>
<type>inline</type>
<foreign_table>tx_contentblocks_reg_api_collection</foreign_table>
Expand Down Expand Up @@ -396,7 +396,7 @@ protected function createCollection(array $field, array $contentBlock) :string
</config>
</content_block_field_identifier>
<content_block type="array">
<label>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<label>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.label</label>
</content_block>
</columns>
Expand Down Expand Up @@ -455,9 +455,9 @@ protected function createSelections($field, $contentBlock)
return '
<' . $field['_identifier'] . '>
<TCEforms>
<label>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<label>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.label</label>
<description>LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
<description>LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.' . $field['_identifier'] . '.description</description>
<config>
<type>' . $type . '</type>
Expand Down
4 changes: 2 additions & 2 deletions Classes/Generator/PageTsConfigGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function pageTsConfigForContentBlock(array $contentBlock): string
elements {
' . $contentBlock['CType'] . ' {
iconIdentifier = ' . $contentBlock['CType'] . '
title = LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor'] . '.' . $contentBlock['package'] . '.title
description = LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor'] . '.' . $contentBlock['package'] . '.description
title = LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor'] . '.' . $contentBlock['package'] . '.title
description = LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor'] . '.' . $contentBlock['package'] . '.description
tt_content_defValues {
CType = ' . $contentBlock['CType'] . '
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Generator/TcaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function setTca() :void
'tt_content',
'CType',
[
'LLL:' . $contentBlock['EditorInterface.xlf'] . ':' . $contentBlock['vendor']
'LLL:' . $contentBlock['EditorInterfaceXlf'] . ':' . $contentBlock['vendor']
. '.' . $contentBlock['package'] . '.title',
$contentBlock['CType'],
$contentBlock['CType'],
Expand Down
4 changes: 2 additions & 2 deletions Classes/Service/ConfigurationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ protected function byPath(SplFileInfo $splPath): array
'frontendPartialsPath' => $frontendPartialsPath,
'frontendLayoutsPath' => $frontendLayoutsPath,
'EditorPreview.html' => $editorPreviewHtml,
'EditorInterface.xlf' => $editorInterfaceXlf,
'EditorInterfaceXlf' => $editorInterfaceXlf,
'EditorLLL' => 'LLL:' . $editorInterfaceXlf . ':' . $vendor . '.' . $packageName,
'Frontend.xlf' => $frontendXlf,
'FrontendXlf' => $frontendXlf,
'FrontendLLL' => 'LLL:' . $frontendXlf . ':' . $vendor . '.' . $packageName,
'yaml' => $editorInterface,
];
Expand Down
4 changes: 4 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ lib.contentBlock {
-5 = EXT:contentblocks_reg_api/Resources/Private/Layouts/
}

partialRootPaths {
0 = EXT:contentblocks_reg_api/Resources/Private/Partials/
}

dataProcessing {
10 = Typo3Contentblocks\ContentblocksRegApi\DataProcessing\CbProcessor
20 = Typo3Contentblocks\ContentblocksRegApi\DataProcessing\FlexFormProcessor
Expand Down
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldName.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

<f:translate key="{cb.EditorLLL}.{field._identifier}.label" default="{cb.EditorLLL}.{field._identifier}.label" />

</html>
12 changes: 12 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Checkbox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

<f:if condition="{values.{field.identifier}}">
<f:then>
</f:then>
<f:else>
</f:else>
</f:if>

</html>
19 changes: 19 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Collection.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

<f:variable name="collectionValues" value="{values.{field.identifier}}"/>

<f:for each="{collectionValues}" as="collectionValue">
<ul style="border: 1px solid #bbb; margin: 2px">
<f:for each="{field.properties.fields}" as="collectionField">
<li>
<em>
<f:render partial="Backend/FieldName" arguments="{field: collectionField, cb: cb}"/>
</em>
<f:render partial="Backend/FieldValue/{collectionField.type}"
arguments="{field: collectionField, values: collectionValue, cb: cb}"/>
</li>
</f:for>
</ul>
</f:for>

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Color.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Date.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/DateTime.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Email.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

<f:image image="{values.{field.identifier}}" maxHeight="64" maxWidth="64"/>

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Integer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Money.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Number.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Percent.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}%

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Radiobox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Select.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Tel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Text.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Textarea.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Time.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
5 changes: 5 additions & 0 deletions Resources/Private/Partials/Backend/FieldValue/Url.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

{values.{field.identifier}}

</html>
15 changes: 15 additions & 0 deletions Resources/Private/Partials/Backend/Fields.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">

<b>Backend field representation: Work-in-progress</b>
<ul>
<f:for each="{fields}" as="field">
<li>
<em>
<f:render partial="Backend/FieldName" arguments="{field: field, cb: cb}"/>
</em>
<f:render partial="Backend/FieldValue/{field.type}" arguments="{field: field, values: values, cb: cb}"/>
</li>
</f:for>
</ul>

</html>

0 comments on commit 89b092e

Please sign in to comment.