Index: class.tx_templavoila_api.php
===================================================================
--- class.tx_templavoila_api.php (revision 33776)
+++ class.tx_templavoila_api.php (working copy)
@@ -1488,6 +1488,7 @@ class tx_templavoila_api {
if ($fieldData['type'] == 'array') {
$tree['previewData']['sheets'][$sheetKey][$fieldKey]['subElements'][$lKey] = $flexformContentArr['data'][$sheetKey][$lKey][$fieldKey]['el'];
+ $tree['previewData']['sheets'][$sheetKey][$fieldKey]['childElements'][$lKey] = $this->getContentTree_processSubFlexFields($table, $row, array($fieldKey=>$fieldData), $tt_content_elementRegister, $flexformContentArr['data'][$sheetKey][$lKey], $vKeys);
}
}
}
@@ -1518,6 +1519,45 @@ class tx_templavoila_api {
}
/**
+ * Merge the datastructure and the related content into a proper tree-structure
+ *
+ * @param string $table
+ * @param array $row
+ * @param array $fieldData
+ * @param object $tt_content_elementRegister
+ * @param array $contentArr
+ * @param array $vKeys
+ * @return array
+ */
+ function getContentTree_processSubFlexFields($table, $row, $fieldData, &$tt_content_elementRegister, $contentArr, $vKeys) {
+ if (!is_array($fieldData)) {
+ return array();
+ }
+ $result = array();
+ foreach ($fieldData as $fieldKey=>$fieldValue) {
+ if ($fieldValue['type'] == 'array') {
+ if (is_array($contentArr) && isset($contentArr[$fieldKey]) && is_array($contentArr[$fieldKey]['el'])) {
+ $result[$fieldKey]['config'] = $fieldValue;
+ unset ($result[$fieldKey]['config']['el']);
+ if ($fieldValue['section']==1) {
+ foreach ($contentArr[$fieldKey]['el'] as $i=>$data) {
+ $result[$fieldKey]['data']['el'][$i] = $this->getContentTree_processSubFlexFields($table, $row, $fieldValue['el'], $tt_content_elementRegister, $data, $vKeys);
+ }
+ } else {
+ $result[$fieldKey]['data']['el'] = $this->getContentTree_processSubFlexFields($table, $row, $fieldValue['el'], $tt_content_elementRegister, $contentArr[$fieldKey]['el'], $vKeys);
+ }
+ }
+ } else {
+ $result[$fieldKey]['config'] = $fieldData[$fieldKey];
+ foreach ($vKeys as $vKey) {
+ $result[$fieldKey]['data'][$vKey] = $contentArr[$fieldKey][$vKey];
+ }
+ }
+ }
+ return $result;
+ }
+
+ /**
* Sub function for rendering the content tree. Handles sub content elements of the current element.
*
* @param string $listOfSubElementUids: List of tt_content elements to process
Index: mod1/index.php
===================================================================
--- mod1/index.php (revision 33776)
+++ mod1/index.php (working copy)
@@ -1303,34 +1303,11 @@ class tx_templavoila_module1 extends t3lib_SCbase {
$TCEformsConfiguration = $fieldData['TCEforms']['config'];
$TCEformsLabel = $this->localizedFFLabel($fieldData['TCEforms']['label'], 1); // title for non-section elements
- if ($fieldData['type']=='array') { // Making preview for array/section parts of a FlexForm structure:
- if (is_array($fieldData['subElements'][$lKey])) {
- if ($fieldData['section']) {
- $previewContent .= '
';
- foreach($fieldData['subElements'][$lKey] as $sectionData) {
- if (is_array($sectionData)) {
- $sectionFieldKey = key($sectionData);
- if (is_array ($sectionData[$sectionFieldKey]['el'])) {
-
- foreach ($sectionData[$sectionFieldKey]['el'] as $containerFieldKey => $containerData) {
- $previewContent .= '- ' . $containerFieldKey . ' ' .
- htmlspecialchars(t3lib_div::fixed_lgd_cs(strip_tags($containerData[$vKey]),200)) .
- '
';
- }
-
- }
-
- }
- }
- $previewContent .= '
';
- if ($this->currentElementBelongsToCurrentPage || (!$this->currentElementBelongsToCurrentPage && $this->modTSconfig['properties']['enableEditIconForRefElements'])) {
- $previewContent = $this->link_edit($previewContent, $elData['table'], $previewData['fullRow']['uid']);
- }
- } else {
- foreach ($fieldData['subElements'][$lKey] as $containerKey => $containerData) {
- $previewContent .= ''.$containerKey.' '.$this->link_edit(htmlspecialchars(t3lib_div::fixed_lgd_cs(strip_tags($containerData[$vKey]),200)), $elData['table'], $previewData['fullRow']['uid']).'
';
- }
- }
+ if ($fieldData['type']=='array') { // Making preview for array/section parts of a FlexForm structure:;
+ if(is_array($fieldData['childElements'][$lKey])) {
+ $previewContent .= $this->render_previewSubData($fieldData['childElements'][$lKey], $elData['table'], $previewData['fullRow']['uid'], $vKey);
+ } else {
+ // no child elements found here
}
} else { // Preview of flexform fields on top-level:
$fieldValue = $fieldData['data'][$lKey][$vKey];
@@ -1353,6 +1330,69 @@ class tx_templavoila_module1 extends t3lib_SCbase {
}
/**
+ * Merge the datastructure and the related content into a proper tree-structure
+ *
+ * @param array $fieldData
+ * @param string $table
+ * @param integer $uid
+ * @param string $vKey
+ * @return array
+ */
+ function render_previewSubData($fieldData, $table, $uid, $vKey) {
+ if (!is_array($fieldData)) {
+ return;
+ }
+
+ $result = '';
+ foreach ($fieldData as $fieldKey => $fieldValue) {
+ if ($fieldValue['config']['type'] == 'array') {
+ if (isset($fieldValue['data']['el'])) {
+ if ($fieldValue['config']['section']) {
+ $result .= '';
+ $result .= ($fieldValue['config']['TCEforms']['label'] ? $fieldValue['config']['TCEforms']['label'] : $fieldValue['config']['tx_templavoila']['title']);
+ $result .= '';
+ $result .= '';
+ foreach ($fieldValue['data']['el'] as $i => $sub) {
+ $data = $this->render_previewSubData($sub, $table, $uid, $vKey);
+ if ($data) {
+ $result .= '- ' . $data . '
';
+ }
+ }
+ $result .= '
';
+ } else {
+ $result .= $this->render_previewSubData($fieldValue['data']['el'], $table, $uid, $vKey);
+ }
+ }
+ } else {
+ $label = $data = '';
+ if (isset($fieldValue['config']['TCEforms']['config']['type']) && $fieldValue['config']['TCEforms']['config']['type'] == 'group') {
+ if ($fieldValue['config']['TCEforms']['config']['internal_type'] == 'file') {
+ // Render preview for images:
+ $thumbnail = t3lib_BEfunc::thumbCode (array('dummyFieldName'=> $fieldValue['data'][$vKey]), '', 'dummyFieldName', $this->doc->backPath, '', $fieldValue['config']['TCEforms']['config']['uploadfolder']);
+ if (isset($fieldValue['config']['TCEforms']['label'])) {
+ $label = $fieldValue['config']['TCEforms']['label'];
+ }
+ $data = $thumbnail;
+ }
+ } else if (isset($fieldValue['config']['TCEforms']['config']['type']) && $fieldValue['config']['TCEforms']['config']['type'] != '') {
+ // Render for everything else:
+ if (isset($fieldValue['config']['TCEforms']['label'])) {
+ $label = $fieldValue['config']['TCEforms']['label'];
+ }
+ $data = (!$fieldValue['data'][$vKey] ? '' : $this->link_edit(htmlspecialchars(t3lib_div::fixed_lgd_cs(strip_tags($fieldValue['data'][$vKey]),200)), $table, $uid)) . '
';
+ } else {
+ // @todo no idea what we should to here
+ }
+
+ if ($label && $data) {
+ $result .= '' . $label . ' ' . $data . '';
+ }
+ }
+ }
+ return $result;
+ }
+
+ /**
* Returns an HTMLized preview of a certain content element. If you'd like to register a new content type, you can easily use the hook
* provided at the beginning of the function.
*
@@ -1366,6 +1406,7 @@ class tx_templavoila_module1 extends t3lib_SCbase {
$hookObjectsArr = $this->hooks_prepareObjectsArray ('renderPreviewContentClass');
$alreadyRendered = FALSE;
+
// Hook: renderPreviewContent_preProcess. Set 'alreadyRendered' to true if you provided a preview content for the current cType !
foreach($hookObjectsArr as $hookObj) {
if (method_exists ($hookObj, 'renderPreviewContent_preProcess')) {