Skip to content

Commit 874bc11

Browse files
committed
Fix Types for file picker contao 4.13 and 5+
1 parent 5067585 commit 874bc11

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/Contao/Widgets/MultiColumnWizard.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,16 +1071,21 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue)
10711071

10721072
// Add the help wizard
10731073
if (isset($arrField['eval']['helpwizard']) && $arrField['eval']['helpwizard']) {
1074+
$label = (isset($arrField['label']) && is_array($arrField['label']) && isset($arrField['label'][0]))
1075+
? $arrField['label'][0]
1076+
: 'Help';
1077+
1078+
// Construct the help wizard link
10741079
$xlabel .= ' <a href="contao/help.php?table=' . $this->strTable . '&amp;field=' . $this->strField
1075-
. '" title="' . StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['helpWizard'])
1076-
. '" onclick="Backend.openModalIframe({\'width\':735,\'height\':405,\'title\':\''
1077-
. StringUtil::specialchars(str_replace("'", "\\'", $arrField['label'][0]))
1078-
. '\',\'url\':this.href});return false">'
1079-
. Image::getHtml(
1080-
'about.gif',
1081-
$GLOBALS['TL_LANG']['MSC']['helpWizard'],
1082-
'style="vertical-align:text-bottom"'
1083-
) . '</a>';
1080+
. '" title="' . StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['helpWizard'])
1081+
. '" onclick="Backend.openModalIframe({\'width\':735,\'height\':405,\'title\':\''
1082+
. StringUtil::specialchars(str_replace("'", "\\'", $label))
1083+
. '\',\'url\':this.href});return false">'
1084+
. Image::getHtml(
1085+
'about.gif',
1086+
$GLOBALS['TL_LANG']['MSC']['helpWizard'],
1087+
'style="vertical-align:text-bottom"'
1088+
) . '</a>';
10841089
}
10851090

10861091
// Add the popup file manager

src/EventListener/Mcw/TinyMce.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public function executeEvent(GetTinyMceStringEvent $event)
4646
$table = $event->getTableName();
4747
$fieldId = $event->getFieldId();
4848

49-
list($file, $type) = explode('|', $field['eval']['rte'], 2) + [null, null];
49+
list ($file, $type) = explode('|', $field['eval']['rte'] ?? '') + [null, null];
5050

51-
$fileBrowserTypes = array();
51+
$fileBrowserTypes = [];
5252
// Since we don't know if this is the right call for other versions of contao
5353
// we won't use dependencies injection.
5454
$pickerBuilder = System::getContainer()->get('contao.picker.builder');
@@ -59,11 +59,14 @@ public function executeEvent(GetTinyMceStringEvent $event)
5959
}
6060
}
6161

62+
// Convert fileBrowserTypes to a comma-separated string for TinyMCE compatibility.
63+
$fileBrowserTypesString = implode(',', $fileBrowserTypes);
64+
6265
/** @var BackendTemplate|object $objTemplate */
6366
$objTemplate = new BackendTemplate('be_' . $file);
6467
$objTemplate->selector = 'ctrl_' . $fieldId;
6568
$objTemplate->type = $type;
66-
$objTemplate->fileBrowserTypes = json_encode($fileBrowserTypes);
69+
$objTemplate->fileBrowserTypes = $fileBrowserTypesString;
6770
$objTemplate->source = $table . '.' . $fieldId;
6871

6972
// Deprecated since Contao 4.0, to be removed in Contao 5.0

0 commit comments

Comments
 (0)