Skip to content

Commit

Permalink
[TASK] Update backend preview images rendering for selects and input …
Browse files Browse the repository at this point in the history
…eval type formate „date“,“datetime“,“time“,“timesec“ and set version to 1.5.5
  • Loading branch information
Sascha Zander committed Mar 19, 2017
1 parent e1842a9 commit 333e1d2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
41 changes: 32 additions & 9 deletions Classes/Hooks/PageLayoutViewDrawItemHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function renderFieldPreview($fieldName, $row, $itemLabels = '', $fieldTab

switch ($fieldConfig['type']) {
case "input":
//If field is has a link wizard
//If field has a link wizard
if (isset($fieldConfig['wizards']['link']) && empty($fieldValue) === false) {
/*** @var \Denkwerk\DwContentElements\Service\Url $urlService */
$urlService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
Expand All @@ -158,6 +158,26 @@ public function renderFieldPreview($fieldName, $row, $itemLabels = '', $fieldTab
$fieldValue = $urlService->getUrl($row['pid'], $fieldValue);
}

// If field has an eval type, format the value by respect eval type
if (isset($fieldConfig['eval'])) {
foreach (explode(",", $fieldConfig['eval']) as $evaluation) {
switch (trim($evaluation)) {
case "date":
$fieldValue = date('Y-m-d', $fieldValue);
break;
case "datetime":
$fieldValue = date('Y-m-d H:i', $fieldValue);
break;
case "time":
$fieldValue = gmdate('H:i', $fieldValue);
break;
case "timesec":
$fieldValue = gmdate('H:i:s', $fieldValue);
break;
}
}
}

$filedContent .= '<p style="padding-right: 5px;margin:0;">
<b>' . $itemLabels . '</b><br />' .
strip_tags((string)$fieldValue) .
Expand Down Expand Up @@ -189,7 +209,6 @@ public function renderFieldPreview($fieldName, $row, $itemLabels = '', $fieldTab

//Get all items
if (version_compare(TYPO3_branch, '7.6', '<')) {

$formEngine = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
'TYPO3\\CMS\\Backend\\Form\\FormEngine'
);
Expand Down Expand Up @@ -242,30 +261,34 @@ public function renderFieldPreview($fieldName, $row, $itemLabels = '', $fieldTab
$items = $processedNodeStructureAsArray[1]['processedTca']['columns'][$fieldName]['config']['items'];
}
$fieldType = $fieldConfig['renderType'];

}

switch($fieldType) {
switch ($fieldType) {
case "checkbox":
case "selectCheckBox":
$value = explode(',', $fieldValue);
foreach ($items as $item) {
$filedContent .= $item[0] . '<br />' .
(in_array($item[1], $value) ? '&#10004;' : '&#10008;');
$filedContent .= $item[0] . ' ' .
(in_array($item[1], $value) ? '&#10004;' : '&#10008;') .
'<br />';
}
break;
case "singlebox":
case "selectSingleBox":
case "selectMultipleSideBySide":
$value = explode(',', $fieldValue);
$selectedContent = array();
foreach ($items as $item) {
$filedContent .= $item[0] . '<br />' .
(in_array($item[1], $value) ? '&#10004;' : '&#10008;');
if (in_array($item[1], $value)) {
$selectedContent[] = $item[0];
}
}
$filedContent .= implode("<br />", $selectedContent);
break;
default:
foreach ($items as $item) {
if ($item[1] == $fieldValue) {
$filedContent .= $item[0] . ' &#10004;';
$filedContent .= $item[0];
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dw-typo3/dw-content-elements",
"type": "typo3-cms-extension",
"version": "1.5.4",
"version": "1.5.5",
"description": "Custom content elements builder",
"homepage": "https://github.com/Digi92/dw_content_elements",
"require": {
Expand All @@ -20,4 +20,4 @@
"role": "Developer"
}
]
}
}
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'description' => 'Custom content elements',
'category' => 'misc',
'shy' => 0,
'version' => '1.5.4',
'version' => '1.5.5',
'dependencies' => 'cms,extbase',
'conflicts' => '',
'loadOrder' => '',
Expand Down

0 comments on commit 333e1d2

Please sign in to comment.