From 2ef487b2477303076356b3258b594dae0b3b9792 Mon Sep 17 00:00:00 2001 From: Ciprian Hossu Date: Wed, 10 Jun 2020 12:17:04 +0300 Subject: [PATCH 1/8] [FEATURE] Add backend preview for the YouTube Videos plugin --- Classes/Hooks/PluginRenderer.php | 177 ++++++++++++++++++++ Resources/Private/Language/de.locallang.xlf | 10 +- Resources/Private/Language/locallang.xlf | 8 +- ext_localconf.php | 3 + 4 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 Classes/Hooks/PluginRenderer.php diff --git a/Classes/Hooks/PluginRenderer.php b/Classes/Hooks/PluginRenderer.php new file mode 100644 index 0000000..f02fdf9 --- /dev/null +++ b/Classes/Hooks/PluginRenderer.php @@ -0,0 +1,177 @@ +' . $labelPluginName . ''; + + // Header + if ($row['header']) { + if ($row['header_layout'] === '10') { + $headerContent .= '

' . $row['header'] . '

'; + } elseif ($row['header_layout'] === '100') { + $headerContent .= '
' . $row['header'] . '
'; + } else { + $headerContent .= '' . $row['header'] . ''; + } + } + + //Header link + if ($row['header_link']) { + $headerContent .= '
' . $translationServiceObject->translate( + $labelHeaderLink + ) . ' (' . $translationServiceObject->translate( + $labelHeader + ) . '): ' . $row['header_link'] . '
'; + } + + // Subheader + if ($row['subheader']) { + $headerContent .= '
' . '' . $translationServiceObject->translate( + $labelSubheader + ) . '' . ': ' . $row['subheader'] . '
'; + } + // Content link + if ($row['tx_sgcontentlink_contentlink']) { + $headerContent .= '
' . '' . $translationServiceObject->translate( + $labelContentLink + ) . '' . ': ' . $row['tx_sgcontentlink_contentlink'] . '
'; + } + + // Set plugin options array + $pluginOptions = GeneralUtility::xml2array($row['pi_flexform'], 'T3:'); + + // Get the FlexForm configuration file + $xmlFilePath = $GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['sgyoutube_youtube,list']; + $xmlContent = GeneralUtility::getFileAbsFileName( + str_replace( + 'FILE:EXT:', 'EXT:', $xmlFilePath + ) + ); + + // Get contents of the FlexForm configuration file + $xmlString = file_get_contents($xmlContent); + $arrayJobs = GeneralUtility::xml2array($xmlString); + + // Begin rendering of table + $itemContent .= '
' . ''; + + // Table header + $labelSettings = 'LLL:EXT:sg_youtube/Resources/Private/Language/locallang.xlf:settings'; + $labelvalue = 'LLL:EXT:sg_youtube/Resources/Private/Language/locallang.xlf:values'; + $itemContent .= '' . ''; + $itemContent .= '' . ''; + + // Table content rows + // Loop through plugin options + foreach ($pluginOptions['data']['sDEF']['lDEF'] as $key => $setting) { + // if plugin option exists within the Flexform configuration file + if (array_key_exists($key, $arrayJobs['sheets']['sDEF']['ROOT']['el'])) { + // Display label + $labelId = $arrayJobs['sheets']['sDEF']['ROOT']['el'][$key]['TCEforms']['label']; + $itemContent .= '' . ''; + // Display value + $itemContent .= '' . ''; + } + } + + // Record Storage + if ($row['pages'] !== '') { + // Record Storage Page label + $labelRecordStorage = 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel'; + + // Get storage page(s) + $backendUtilityObject = GeneralUtility::makeInstance(BackendUtility::class); + $storagePageIds = explode(',', $row['pages']); + $storagePages = []; + + foreach ($storagePageIds as $i => $storagePageId) { + $storagePages[] = $backendUtilityObject->getRecord( + 'pages', $storagePageId, 'title' + )['title'] . ' ' . '(' . $storagePageId . ')'; + } + + // Render 'Record Storage Page' row + $itemContent .= '' . ''; + $itemContent .= '' . ''; + } + + // End rendering of table + $itemContent .= '
' . $translationServiceObject->translate( + $labelSettings + ) . '' . $translationServiceObject->translate( + $labelvalue + ) . '
' . $translationServiceObject->translate( + trim($labelId) + ) . '' . $setting['vDEF'] . '
' . $translationServiceObject->translate( + $labelRecordStorage + ) . '' . implode(', ', $storagePages) . '
'; + $drawItem = FALSE; + } + } +} diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index 2560a6e..09a1846 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -1,6 +1,6 @@ - +
LFEditor
@@ -49,6 +49,14 @@ + + + + + + + +
\ No newline at end of file diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 69910c0..11714e9 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -38,6 +38,12 @@ + + + + + + - \ No newline at end of file + diff --git a/ext_localconf.php b/ext_localconf.php index 2fb5f10..ad9a2bd 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -40,3 +40,6 @@ if (!defined('TYPO3_MODE')) { ] ); +//Hooks +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']['sg_youtube'] + = \SGalinski\SgYoutube\Hooks\PluginRenderer::class; -- GitLab From 14cad4e86bf46e57155fb3c46506516a8cc2fcbe Mon Sep 17 00:00:00 2001 From: Ciprian Hossu Date: Thu, 11 Jun 2020 07:19:25 +0300 Subject: [PATCH 2/8] [BUGFIX] Remove header and content links from plugin preview --- Classes/Hooks/PluginRenderer.php | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/Classes/Hooks/PluginRenderer.php b/Classes/Hooks/PluginRenderer.php index f02fdf9..d094afb 100644 --- a/Classes/Hooks/PluginRenderer.php +++ b/Classes/Hooks/PluginRenderer.php @@ -50,20 +50,11 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { $labelPluginName = BackendUtility::getLabelFromItemListMerged( $row['pid'], 'tt_content', 'list_type', $row['list_type'] ); - $labelHeader = BackendUtility::getItemLabel( - 'tt_content', 'header' - ); - $labelHeaderLink = BackendUtility::getItemLabel( - 'tt_content', 'header_link' - ); $labelSubheader = BackendUtility::getItemLabel( 'tt_content', 'subheader' ); - $labelContentLink = BackendUtility::getItemLabel( - 'tt_content', 'tx_sgcontentlink_contentlink' - ); - // Make instance of TranslationService class + // Instantiate TranslationService class $translationServiceObject = GeneralUtility::makeInstance(TranslationService::class); // Begin rendering of content element fields @@ -81,27 +72,12 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { } } - //Header link - if ($row['header_link']) { - $headerContent .= '
' . $translationServiceObject->translate( - $labelHeaderLink - ) . ' (' . $translationServiceObject->translate( - $labelHeader - ) . '): ' . $row['header_link'] . '
'; - } - // Subheader if ($row['subheader']) { $headerContent .= '
' . '' . $translationServiceObject->translate( $labelSubheader ) . '' . ': ' . $row['subheader'] . '
'; } - // Content link - if ($row['tx_sgcontentlink_contentlink']) { - $headerContent .= '
' . '' . $translationServiceObject->translate( - $labelContentLink - ) . '' . ': ' . $row['tx_sgcontentlink_contentlink'] . '
'; - } // Set plugin options array $pluginOptions = GeneralUtility::xml2array($row['pi_flexform'], 'T3:'); @@ -154,7 +130,7 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { // Get storage page(s) $backendUtilityObject = GeneralUtility::makeInstance(BackendUtility::class); $storagePageIds = explode(',', $row['pages']); - $storagePages = []; + $storagePages = array(); foreach ($storagePageIds as $i => $storagePageId) { $storagePages[] = $backendUtilityObject->getRecord( -- GitLab From 698beec5cc8d0602fdabc346d1828eae4e05f772 Mon Sep 17 00:00:00 2001 From: Ciprian Hossu Date: Thu, 11 Jun 2020 14:13:47 +0300 Subject: [PATCH 3/8] [BUGFIX] Use icons for displaying the value of the Show API result field --- Classes/Hooks/PluginRenderer.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Classes/Hooks/PluginRenderer.php b/Classes/Hooks/PluginRenderer.php index d094afb..1f3bf83 100644 --- a/Classes/Hooks/PluginRenderer.php +++ b/Classes/Hooks/PluginRenderer.php @@ -23,6 +23,8 @@ namespace SGalinski\SgYoutube\Hooks; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\PageLayoutView; use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface; +use TYPO3\CMS\Core\Imaging\Icon; +use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Form\Service\TranslationService; @@ -107,18 +109,36 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { $labelvalue ) . '' . ''; - // Table content rows - // Loop through plugin options + // Loop through plugin options and render rows foreach ($pluginOptions['data']['sDEF']['lDEF'] as $key => $setting) { + // if plugin option exists within the Flexform configuration file if (array_key_exists($key, $arrayJobs['sheets']['sDEF']['ROOT']['el'])) { + // Display label $labelId = $arrayJobs['sheets']['sDEF']['ROOT']['el'][$key]['TCEforms']['label']; $itemContent .= '' . '' . $translationServiceObject->translate( trim($labelId) ) . ''; + // Display value - $itemContent .= '' . $setting['vDEF'] . '' . ''; + // Show different icon for the 'Show API Result' field, depending on checkbox value + if ($key === 'settings.showApiResult') { + if ($setting['vDEF'] === '0') { + $itemContent .= '' . GeneralUtility::makeInstance(IconFactory::class)->getIcon( + 'actions-close', Icon::SIZE_SMALL + ) + ->render('inline') . '' . ''; + } else { + $itemContent .= '' . GeneralUtility::makeInstance(IconFactory::class)->getIcon( + 'actions-check', Icon::SIZE_SMALL + ) + ->render('inline') . '' . ''; + } + // Remaining values + } else { + $itemContent .= '' . $setting['vDEF'] . '' . ''; + } } } -- GitLab From 880fbabf9d190a06bda5efca24c7f3493176661f Mon Sep 17 00:00:00 2001 From: Ciprian Hossu Date: Fri, 12 Jun 2020 14:52:45 +0300 Subject: [PATCH 4/8] [BUGFIX] Change configuration array variable name. --- Classes/Hooks/PluginRenderer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/Hooks/PluginRenderer.php b/Classes/Hooks/PluginRenderer.php index 1f3bf83..1607890 100644 --- a/Classes/Hooks/PluginRenderer.php +++ b/Classes/Hooks/PluginRenderer.php @@ -94,7 +94,7 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { // Get contents of the FlexForm configuration file $xmlString = file_get_contents($xmlContent); - $arrayJobs = GeneralUtility::xml2array($xmlString); + $configurationArray = GeneralUtility::xml2array($xmlString); // Begin rendering of table $itemContent .= '
' . ''; @@ -113,10 +113,10 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { foreach ($pluginOptions['data']['sDEF']['lDEF'] as $key => $setting) { // if plugin option exists within the Flexform configuration file - if (array_key_exists($key, $arrayJobs['sheets']['sDEF']['ROOT']['el'])) { + if (array_key_exists($key, $configurationArray['sheets']['sDEF']['ROOT']['el'])) { // Display label - $labelId = $arrayJobs['sheets']['sDEF']['ROOT']['el'][$key]['TCEforms']['label']; + $labelId = $configurationArray['sheets']['sDEF']['ROOT']['el'][$key]['TCEforms']['label']; $itemContent .= '' . ''; -- GitLab From 72479e3cfe22da99ddb62d3dbde3d8e225c73fb8 Mon Sep 17 00:00:00 2001 From: Ciprian Hossu Date: Mon, 15 Jun 2020 14:03:37 +0300 Subject: [PATCH 5/8] [BUGFIX] Add condition for flexform configuration file. Add function for returning records array. --- Classes/Hooks/PluginRenderer.php | 158 +++++++++++++++++-------------- 1 file changed, 86 insertions(+), 72 deletions(-) diff --git a/Classes/Hooks/PluginRenderer.php b/Classes/Hooks/PluginRenderer.php index 1607890..448c812 100644 --- a/Classes/Hooks/PluginRenderer.php +++ b/Classes/Hooks/PluginRenderer.php @@ -35,6 +35,25 @@ use TYPO3\CMS\Form\Service\TranslationService; * @package SGalinski\SgYoutube\Hooks */ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { + /** + * Return an array of pages or categories, with their respective ids + * + * @param $recodIds + * @return array $records + */ + public function buildRecordArray($table, $recodIds) { + $backendUtilityObject = GeneralUtility::makeInstance(BackendUtility::class); + $recordsArray = explode(',', $recodIds); + $records = []; + + foreach ($recordsArray as $i => $recordId) { + $records[] = $backendUtilityObject->getRecord( + $table, $recordId, 'title' + )['title'] . ' ' . '(' . $recordId . ')'; + } + return $records; + } + /** * Preprocesses the preview rendering of a content element of type "sg_youtube" * @@ -48,6 +67,8 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { public function preProcess(PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row) { if ($row['list_type'] === 'sgyoutube_youtube') { + $drawItem = FALSE; + // Content element labels $labelPluginName = BackendUtility::getLabelFromItemListMerged( $row['pid'], 'tt_content', 'list_type', $row['list_type'] @@ -86,88 +107,81 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface { // Get the FlexForm configuration file $xmlFilePath = $GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['sgyoutube_youtube,list']; - $xmlContent = GeneralUtility::getFileAbsFileName( - str_replace( - 'FILE:EXT:', 'EXT:', $xmlFilePath - ) - ); - - // Get contents of the FlexForm configuration file - $xmlString = file_get_contents($xmlContent); - $configurationArray = GeneralUtility::xml2array($xmlString); - - // Begin rendering of table - $itemContent .= '
' . '
' . $translationServiceObject->translate( trim($labelId) ) . '
'; - - // Table header - $labelSettings = 'LLL:EXT:sg_youtube/Resources/Private/Language/locallang.xlf:settings'; - $labelvalue = 'LLL:EXT:sg_youtube/Resources/Private/Language/locallang.xlf:values'; - $itemContent .= '' . ''; - $itemContent .= '' . ''; - // Loop through plugin options and render rows - foreach ($pluginOptions['data']['sDEF']['lDEF'] as $key => $setting) { - - // if plugin option exists within the Flexform configuration file - if (array_key_exists($key, $configurationArray['sheets']['sDEF']['ROOT']['el'])) { - - // Display label - $labelId = $configurationArray['sheets']['sDEF']['ROOT']['el'][$key]['TCEforms']['label']; - $itemContent .= '' . ''; - - // Display value - // Show different icon for the 'Show API Result' field, depending on checkbox value - if ($key === 'settings.showApiResult') { - if ($setting['vDEF'] === '0') { - $itemContent .= '' . ''; + if ($xmlFilePath !== '') { + $xmlContent = GeneralUtility::getFileAbsFileName( + str_replace( + 'FILE:EXT:', 'EXT:', $xmlFilePath + ) + ); + + // Get contents of the FlexForm configuration file + $xmlString = file_get_contents($xmlContent); + $configurationArray = GeneralUtility::xml2array($xmlString); + + // Begin rendering of table + $itemContent .= '
' . '
' . $translationServiceObject->translate( - $labelSettings - ) . '' . $translationServiceObject->translate( - $labelvalue - ) . '
' . $translationServiceObject->translate( - trim($labelId) - ) . '' . GeneralUtility::makeInstance(IconFactory::class)->getIcon( - 'actions-close', Icon::SIZE_SMALL - ) - ->render('inline') . '
'; + + // Table header + $labelSettings = 'LLL:EXT:sg_youtube/Resources/Private/Language/locallang.xlf:settings'; + $labelvalue = 'LLL:EXT:sg_youtube/Resources/Private/Language/locallang.xlf:values'; + $itemContent .= '' . ''; + $itemContent .= '' . ''; + + // Loop through plugin options and render rows + foreach ($pluginOptions['data']['sDEF']['lDEF'] as $key => $setting) { + + // if plugin option exists within the Flexform configuration file + if (array_key_exists($key, $configurationArray['sheets']['sDEF']['ROOT']['el'])) { + + // Display label + $labelId = $configurationArray['sheets']['sDEF']['ROOT']['el'][$key]['TCEforms']['label']; + $itemContent .= '' . ''; + + // Display value + // Show different icon for the 'Show API Result' field, depending on checkbox value + if ($key === 'settings.showApiResult') { + if ($setting['vDEF'] === '0') { + $itemContent .= '' . ''; + } else { + $itemContent .= '' . ''; + } + // Remaining values } else { - $itemContent .= '' . ''; + $itemContent .= '' . ''; } - // Remaining values - } else { - $itemContent .= '' . ''; } } - } - // Record Storage - if ($row['pages'] !== '') { - // Record Storage Page label - $labelRecordStorage = 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel'; + // Record Storage + if ($row['pages'] !== '') { + // Record Storage Page label + $labelRecordStorage = 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel'; - // Get storage page(s) - $backendUtilityObject = GeneralUtility::makeInstance(BackendUtility::class); - $storagePageIds = explode(',', $row['pages']); - $storagePages = array(); - - foreach ($storagePageIds as $i => $storagePageId) { - $storagePages[] = $backendUtilityObject->getRecord( - 'pages', $storagePageId, 'title' - )['title'] . ' ' . '(' . $storagePageId . ')'; + // Render 'Record Storage Page' row + $itemContent .= '' . ''; + $itemContent .= '' . ''; } - // Render 'Record Storage Page' row - $itemContent .= '' . ''; - $itemContent .= '' . ''; + // End rendering of table + $itemContent .= '
' . $translationServiceObject->translate( + $labelSettings + ) . '' . $translationServiceObject->translate( + $labelvalue + ) . '
' . $translationServiceObject->translate( + trim($labelId) + ) . '' . GeneralUtility::makeInstance(IconFactory::class)->getIcon( + 'actions-close', Icon::SIZE_SMALL + ) + ->render('inline') . '
' . GeneralUtility::makeInstance(IconFactory::class)->getIcon( + 'actions-check', Icon::SIZE_SMALL + ) + ->render('inline') . '
' . GeneralUtility::makeInstance(IconFactory::class)->getIcon( - 'actions-check', Icon::SIZE_SMALL - ) - ->render('inline') . '
' . $setting['vDEF'] . '
' . $setting['vDEF'] . '
' . $translationServiceObject->translate( + $labelRecordStorage + ) . '' . implode( + ', ', $this->buildRecordArray('pages', $row['pages']) + ) . '
' . $translationServiceObject->translate( - $labelRecordStorage - ) . '' . implode(', ', $storagePages) . '
'; } - - // End rendering of table - $itemContent .= ''; - $drawItem = FALSE; } } } -- GitLab From 286cacb3e0204c99530e7890041c7d5df3937e5d Mon Sep 17 00:00:00 2001 From: Tim Wagner Date: Wed, 24 Jun 2020 20:23:45 +0200 Subject: [PATCH 6/8] [TASK] Render plugin backend preview with Fluid template --- .../Hooks/PageLayoutView/PluginRenderer.php | 108 ++++++++++ Classes/Hooks/PluginRenderer.php | 187 ------------------ .../FlexForms/flexform_sgyoutube_youtube.xml | 4 +- Resources/Private/Language/de.locallang.xlf | 42 ++-- Resources/Private/Language/locallang.xlf | 34 ++-- .../Private/Templates/Youtube/Backend.html | 31 +++ ext_localconf.php | 2 +- 7 files changed, 187 insertions(+), 221 deletions(-) create mode 100644 Classes/Hooks/PageLayoutView/PluginRenderer.php delete mode 100644 Classes/Hooks/PluginRenderer.php create mode 100644 Resources/Private/Templates/Youtube/Backend.html diff --git a/Classes/Hooks/PageLayoutView/PluginRenderer.php b/Classes/Hooks/PageLayoutView/PluginRenderer.php new file mode 100644 index 0000000..ebd6630 --- /dev/null +++ b/Classes/Hooks/PageLayoutView/PluginRenderer.php @@ -0,0 +1,108 @@ + $recordId) { + $records[] = $backendUtilityObject::getRecord( + $table, $recordId, 'title' + )['title'] . ' ' . '(' . $recordId . ')'; + } + return $records; + } + + /** + * Preprocesses the preview rendering of a content element of type "sg_youtube" + * + * @param PageLayoutView $parentObject Calling parent object + * @param bool $drawItem Whether to draw the item using the default functionality + * @param string $headerContent Header content + * @param string $itemContent Item content + * @param array $row Record row of tt_content + * @return void + * @noinspection ReferencingObjectsInspection + */ + public function preProcess( + PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row + ): void { + if ($row['list_type'] === 'sgyoutube_youtube') { + $drawItem = FALSE; + + $view = GeneralUtility::makeInstance(StandaloneView::class); + $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 = []; + foreach ($pluginOptions['data']['sDEF']['lDEF'] as $option => $value) { + if ($option !== 'settings.showApiResult') { + // $option has the format 'settings.', but in the template we need the language label which + // has the format 'flexform.'. + $templateOptions[str_replace('settings.', 'flexform.', $option)] = $value['vDEF']; + } + } + + $languageService = GeneralUtility::makeInstance(LanguageService::class); + $templateOptions['flexform.thumbnailType'] = $languageService->sL( + 'LLL:EXT:sg_youtube/Resources/Private/Language/locallang.xlf:flexform.thumbnailType.' . $templateOptions['flexform.thumbnailType'] + ); + + $view->assignMultiple([ + 'pluginOptions' => $templateOptions, + 'showApiResult' => $pluginOptions['data']['sDEF']['lDEF']['settings.showApiResult']['vDEF'] + ]); + + // Content element labels + $pluginName = BackendUtility::getLabelFromItemListMerged( + $row['pid'], 'tt_content', 'list_type', $row['list_type'] + ); + $headerContent = '[' . $pluginName . '] ' . $headerContent; + + $itemContent .= $view->render(); + } + } +} diff --git a/Classes/Hooks/PluginRenderer.php b/Classes/Hooks/PluginRenderer.php deleted file mode 100644 index 448c812..0000000 --- a/Classes/Hooks/PluginRenderer.php +++ /dev/null @@ -1,187 +0,0 @@ - $recordId) { - $records[] = $backendUtilityObject->getRecord( - $table, $recordId, 'title' - )['title'] . ' ' . '(' . $recordId . ')'; - } - return $records; - } - - /** - * Preprocesses the preview rendering of a content element of type "sg_youtube" - * - * @param PageLayoutView $parentObject Calling parent object - * @param bool $drawItem Whether to draw the item using the default functionality - * @param string $headerContent Header content - * @param string $itemContent Item content - * @param array $row Record row of tt_content - * @return void - */ - public function preProcess(PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row) { - if ($row['list_type'] === 'sgyoutube_youtube') { - - $drawItem = FALSE; - - // Content element labels - $labelPluginName = BackendUtility::getLabelFromItemListMerged( - $row['pid'], 'tt_content', 'list_type', $row['list_type'] - ); - $labelSubheader = BackendUtility::getItemLabel( - 'tt_content', 'subheader' - ); - - // Instantiate TranslationService class - $translationServiceObject = GeneralUtility::makeInstance(TranslationService::class); - - // Begin rendering of content element fields - // Plugin name - $headerContent = '
' . $labelPluginName . '
'; - - // Header - if ($row['header']) { - if ($row['header_layout'] === '10') { - $headerContent .= '

' . $row['header'] . '

'; - } elseif ($row['header_layout'] === '100') { - $headerContent .= '
' . $row['header'] . '
'; - } else { - $headerContent .= '' . $row['header'] . ''; - } - } - - // Subheader - if ($row['subheader']) { - $headerContent .= '
' . '' . $translationServiceObject->translate( - $labelSubheader - ) . '' . ': ' . $row['subheader'] . '
'; - } - - // Set plugin options array - $pluginOptions = GeneralUtility::xml2array($row['pi_flexform'], 'T3:'); - - // Get the FlexForm configuration file - $xmlFilePath = $GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['sgyoutube_youtube,list']; - - if ($xmlFilePath !== '') { - $xmlContent = GeneralUtility::getFileAbsFileName( - str_replace( - 'FILE:EXT:', 'EXT:', $xmlFilePath - ) - ); - - // Get contents of the FlexForm configuration file - $xmlString = file_get_contents($xmlContent); - $configurationArray = GeneralUtility::xml2array($xmlString); - - // Begin rendering of table - $itemContent .= '
' . ''; - - // Table header - $labelSettings = 'LLL:EXT:sg_youtube/Resources/Private/Language/locallang.xlf:settings'; - $labelvalue = 'LLL:EXT:sg_youtube/Resources/Private/Language/locallang.xlf:values'; - $itemContent .= '' . ''; - $itemContent .= '' . ''; - - // Loop through plugin options and render rows - foreach ($pluginOptions['data']['sDEF']['lDEF'] as $key => $setting) { - - // if plugin option exists within the Flexform configuration file - if (array_key_exists($key, $configurationArray['sheets']['sDEF']['ROOT']['el'])) { - - // Display label - $labelId = $configurationArray['sheets']['sDEF']['ROOT']['el'][$key]['TCEforms']['label']; - $itemContent .= '' . ''; - - // Display value - // Show different icon for the 'Show API Result' field, depending on checkbox value - if ($key === 'settings.showApiResult') { - if ($setting['vDEF'] === '0') { - $itemContent .= '' . ''; - } else { - $itemContent .= '' . ''; - } - // Remaining values - } else { - $itemContent .= '' . ''; - } - } - } - - // Record Storage - if ($row['pages'] !== '') { - // Record Storage Page label - $labelRecordStorage = 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel'; - - // Render 'Record Storage Page' row - $itemContent .= '' . ''; - $itemContent .= '' . ''; - } - - // End rendering of table - $itemContent .= '
' . $translationServiceObject->translate( - $labelSettings - ) . '' . $translationServiceObject->translate( - $labelvalue - ) . '
' . $translationServiceObject->translate( - trim($labelId) - ) . '' . GeneralUtility::makeInstance(IconFactory::class)->getIcon( - 'actions-close', Icon::SIZE_SMALL - ) - ->render('inline') . '
' . GeneralUtility::makeInstance(IconFactory::class)->getIcon( - 'actions-check', Icon::SIZE_SMALL - ) - ->render('inline') . '
' . $setting['vDEF'] . '
' . $translationServiceObject->translate( - $labelRecordStorage - ) . '' . implode( - ', ', $this->buildRecordArray('pages', $row['pages']) - ) . '
'; - } - } - } -} diff --git a/Configuration/FlexForms/flexform_sgyoutube_youtube.xml b/Configuration/FlexForms/flexform_sgyoutube_youtube.xml index e2d3945..5522d30 100644 --- a/Configuration/FlexForms/flexform_sgyoutube_youtube.xml +++ b/Configuration/FlexForms/flexform_sgyoutube_youtube.xml @@ -16,7 +16,7 @@ 0 -