MrmbeCmMaintenancePreviewRenderer.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Meramo\mrm_be\Hooks\PageLayoutView;
  3. use \TYPO3\CMS\Core\Utility\GeneralUtility;
  4. use \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
  5. use \TYPO3\CMS\Backend\View\PageLayoutView;
  6. use \TYPO3\CMS\Core\Service\FlexFormService;
  7. use \TYPO3\CMS\Extbase\Utility\LocalizationUtility;
  8. /**
  9. * Contains a preview rendering for the page module for CTYPE="mrm_be_cm_maintenance"
  10. */
  11. class MrmBeCmMaintenancePreviewRenderer implements PageLayoutViewDrawItemHookInterface
  12. {
  13. /**
  14. * Preprocesses the preview rendering of a content element of type "My new content element"
  15. *
  16. * @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
  17. * @param bool $drawItem Whether to draw the item using the default functionality
  18. * @param string $headerContent Header content
  19. * @param string $itemContent Item content
  20. * @param array $row Record row of tt_content
  21. * @return void
  22. */
  23. public function preProcess(
  24. PageLayoutView &$parentObject,
  25. &$drawItem,
  26. &$headerContent,
  27. &$itemContent,
  28. array &$row
  29. )
  30. {
  31. if($row['CType'] === 'mrm_be_cm_maintenance') {
  32. // Hier wird das aussehen der oben angezeigt Komponent festgelegt
  33. $headerContent = '<b>' . LocalizationUtility::translate('LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:'.$row['CType'].'.title', '').'</b>';
  34. $ffs = GeneralUtility::makeInstance(FlexFormService::class);
  35. $flex = $ffs->convertFlexFormContentToArray($row['pi_flexform']);
  36. $start = $flex['starttime'];
  37. $start = date('d.m.Y H:i', $start);
  38. $end = $flex['endtime'];
  39. $end = date('d.m.Y H:i', $end);
  40. $infotext = $flex['infotext'];
  41. $itemContent = '<div style="display: flex; flex-direction: row; justify-content: flex-start"><img src="/typo3conf/ext/mrm_be/Resources/Public/Icons/'.$row['CType'].'.svg" style="width: 32px; height: 32px; margin-right: 6px;"><div style="display: flex; flex-direction: column; min-width: 0;"><strong>'.\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('LLL:EXT:mrm_be/Resources/Private/Language/locallang_ttc.xlf:'.$row['CType'].'.title', '').': </strong><b>'.$flex['key'].'</b><br>'.$start.'<br>'.$end.'<br><em style="white-space:nowrap; overflow:hidden;text-overflow: ellipsis;">'.$infotext.'</em></div></div>';
  42. $drawItem = false;
  43. }
  44. }
  45. }