From 698beec5cc8d0602fdabc346d1828eae4e05f772 Mon Sep 17 00:00:00 2001
From: Ciprian Hossu <ciprian.hossu@sgalinski.de>
Date: Thu, 11 Jun 2020 14:13:47 +0300
Subject: [PATCH] [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
 				) . '</th>' . '</tr>';
 
-			// 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 .= '<row>' . '<td><strong>' . $translationServiceObject->translate(
 							trim($labelId)
 						) . '</strong></td>';
+
 					// Display value
-					$itemContent .= '<td>' . $setting['vDEF'] . '</td>' . '</tr>';
+					// Show different icon for the 'Show API Result' field, depending on checkbox value
+					if ($key === 'settings.showApiResult') {
+						if ($setting['vDEF'] === '0') {
+							$itemContent .= '<td>' . GeneralUtility::makeInstance(IconFactory::class)->getIcon(
+									'actions-close', Icon::SIZE_SMALL
+								)
+									->render('inline') . '</td>' . '</tr>';
+						} else {
+							$itemContent .= '<td>' . GeneralUtility::makeInstance(IconFactory::class)->getIcon(
+									'actions-check', Icon::SIZE_SMALL
+								)
+									->render('inline') . '</td>' . '</tr>';
+						}
+					// Remaining values
+					} else {
+						$itemContent .= '<td>' . $setting['vDEF'] . '</td>' . '</tr>';
+					}
 				}
 			}
 
-- 
GitLab