/**
  * Modifies the Element to disable Dragging for cols
  *
  * @param	tx_cms_layout	$parentObject:  Calling parent object
  * @param	boolean         $drawItem:      Whether to draw the item using the default functionalities
  * @param	string	        $headerContent: Header content
  * @param	string	        $itemContent:   Item content
  * @param	array			$row:           Record row of tt_content
  * @return	void
  */
 private function renderPreview(\TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
 {
     // Preview of content_designer elements
     $expr = '/^' . $this->prefix . '(.*)$/si';
     if (preg_match($expr, $row['CType'], $match)) {
         // Load the TypoScript Config
         $config = array('row' => &$row);
         $typoScript = TypoScript::loadConfig($config, substr($this->prefix, 0, strlen($this->prefix) - 1), $row['pid']);
         $this->typoScript = $typoScript[$row['CType']];
         unset($typoScript, $config);
         // Render the preview with default labels etc.? (default is now off)
         $drawItem = $this->typoScript['settings.']['enableDefaultDrawItem'] == 1 ? TRUE : FALSE;
         // Render the preview
         if (empty($this->settings['renderMethod']) || !isset($this->settings['renderMethod'])) {
             $this->settings['renderMethod'] = 'flexForm';
         }
         if ($this->typoScript['settings.']['renderMethod'] == 'tca') {
             $previewRenderer = GeneralUtility::makeInstance(\KERN23\ContentDesigner\Utility\DrawItem\Tca::class);
         } else {
             $previewRenderer = GeneralUtility::makeInstance(\KERN23\ContentDesigner\Utility\DrawItem\FlexForm::class);
         }
         $previewRenderer->getContentElementPreview($this->typoScript, $row, $headerContent, $itemContent);
         // Link the preview content
         $itemContent = $parentObject->linkEditContent($itemContent, $row);
     }
 }
 /**
  * The main hook function called by core function getFlexFormDS()
  *
  * @param $dataStructArray
  * @param $conf
  * @param $row
  * @param $table
  * @param $fieldName
  */
 public function getFlexFormDS_postProcessDS(&$dataStructArray, &$conf, &$row, &$table, &$fieldName)
 {
     // Check for valid table and/or CType
     if ($table != 'tt_content' || !is_array($row) || !array_key_exists('CType', $row) || !strlen($row['CType'])) {
         return false;
     }
     // Init cache
     $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
     $cache = $objectManager->get(CacheManager::class, $objectManager)->getCache('content_designer');
     $cacheIdentifier = $row['CType'];
     // Restore dataStructArray from cache if necessary
     $cachedDataStructArray = $cache->get($cacheIdentifier);
     if (!array_key_exists('pi_flexform', $row) && $cachedDataStructArray) {
         $dataStructArray = $cachedDataStructArray;
         return true;
     }
     // Cache dataStructArray
     $cache->set($cacheIdentifier, $dataStructArray, array(), 0);
     $curObjType = $this->getElementTypeAndTable($row);
     // Get the typoscript configuration object
     $typoScript = TypoScript::loadConfig($conf, substr($this->prefix, 0, strlen($this->prefix) - 1), $row['pid'], $curObjType['table'] . '.');
     // Check whether to extend other CType's and identify the current element
     if (!is_array($typoScript['___extendCType'][$row['CType'] . '.']) && !$curObjType) {
         return FALSE;
     }
     // If a flexFile defined or copied by a plugin, nothing is to do
     $tsObj =& $typoScript[$this->prefix . $curObjType['CType']]['settings.'];
     $tsObjAltern =& $typoScript[$this->prefix . substr($curObjType['CType'], 0, strlen($curObjType['CType']) - 1)]['settings.'];
     # alternative access
     $tsObjCType =& $typoScript['___extendCType'][$row['CType'] . '.'];
     if (empty($tsObj['renderMethod']) || !isset($tsObj['renderMethod'])) {
         $tsObj['renderMethod'] = 'flexForm';
     }
     if (empty($tsObjAltern['renderMethod']) || !isset($tsObjAltern['renderMethod'])) {
         $tsObjAltern['renderMethod'] = 'flexForm';
     }
     if ($tsObj['renderMethod'] != 'flexForm' && $tsObjAltern['renderMethod'] != 'flexForm') {
         unset($typoScript);
         return false;
     }
     // Load the Field Configuration for the current selected Object
     if (!empty($cObject = $tsObj['cObject.']) || !empty($cObject = $tsObjAltern['cObject.']) || !empty($cObject =& $tsObjCType)) {
         unset($typoScript);
     } else {
         return false;
     }
     // Create the dataStructArray
     $this->getDataStructArray($cObject, $dataStructArray);
     // Cache modified dataStructArray
     $cache->set($cacheIdentifier, $dataStructArray, array(), 0);
     return true;
 }
 /**
  * Extends the pages configuration the magic to modify the fields are comming in the Hooks (FlexFormDs)
  *
  * @return void
  */
 public static function extendPagesTca()
 {
     // Get current page id
     $table = 'pages';
     $pageUid = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('edit');
     $pageUid = @key($pageUid[$table]);
     // Load TS Setup for content designer pages
     $pagesConfig = TypoScript::loadConfig($config, self::CD_PREFIX, $pageUid, $table . '.', TRUE);
     // do we have something to add?
     if (is_array($pagesConfig) && count($pagesConfig[self::CD_PREFIX . '_flexform']['settings.']['cObject.'])) {
         $cdItem =& $pagesConfig[self::CD_PREFIX . '_flexform']['settings.'];
         ExtensionManagementUtility::addToAllTCAtypes('pages', $cdItem['tca']);
         if ($cdItem['cObjectFlexFile']) {
             // Use a FlexForm File
             $GLOBALS['TCA']['pages']['columns'][self::CD_PREFIX . '_flexform']['config']['ds']['default'] = 'FILE:' . $cdItem['cObjectFlexFile'];
         } else {
             // Use base XML structure (the rest comes with TypoScript)
             $GLOBALS['TCA']['pages']['columns'][self::CD_PREFIX . '_flexform']['config']['ds']['default'] = 'FILE:EXT:content_designer/Configuration/FlexForms/defaultPages.xml';
         }
     }
 }