Skip to content

Commit

Permalink
Fixed compatibility with templates editor for Contao 4.9.2 (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoglo authored Apr 4, 2020
1 parent e436217 commit 3c5d006
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Resources/contao/dca/tl_templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@
is_callable([PackageUtil::class, 'getContaoVersion'])
&& version_compare(PackageUtil::getContaoVersion(), '4.7', '>=')
) {
$GLOBALS['TL_DCA']['tl_templates']['config']['validFileTypes'] .= ',php';
if (!empty($GLOBALS['TL_DCA']['tl_templates']['config']['validFileTypes'])) {
$GLOBALS['TL_DCA']['tl_templates']['config']['validFileTypes'] .= ',php';
}
$GLOBALS['TL_DCA']['tl_templates']['config']['onload_callback'][] = function() {
Config::set('editableFiles', Config::get('editableFiles') . ',php');
};
$originalButtonCallback = $GLOBALS['TL_DCA']['tl_templates']['list']['operations']['source']['button_callback'];
$GLOBALS['TL_DCA']['tl_templates']['list']['operations']['source']['button_callback'] = function($row, $href, $label, $title, $icon, $attributes) use ($originalButtonCallback) {
if (substr(basename($row['id']), 0, 5) !== 'rsce_' || substr($row['id'], -11) !== '_config.php') {
if (is_array($originalButtonCallback)) {
return System::importStatic($originalButtonCallback[0])->{$originalButtonCallback[1]}($row, $href, $label, $title, $icon, $attributes);
}
return $originalButtonCallback($row, $href, $label, $title, $icon, $attributes);
}
return '<a href="' . \Contao\Backend::addToUrl($href . '&amp;id=' . $row['id']) . '" title="' . Contao\StringUtil::specialchars($title) . '"' . $attributes . '>' . Contao\Image::getHtml($icon, $label) . '</a> ';
};
}

0 comments on commit 3c5d006

Please sign in to comment.