File tree Expand file tree Collapse file tree 5 files changed +59
-18
lines changed
EventListener/DataContainer Expand file tree Collapse file tree 5 files changed +59
-18
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * This file is part of richardhj/contao-ajax_reload_element.
5+ *
6+ * Copyright (c) 2016-2018 Richard Henkenjohann
7+ *
8+ * @package richardhj/contao-ajax_reload_element
9+ * @author Richard Henkenjohann <richardhenkenjohann@googlemail.com>
10+ * @copyright 2016-2018 Richard Henkenjohann
11+ * @license https://github.com/richardhj/contao-ajax_reload_element/blob/master/LICENSE LGPL-3.0
12+ */
13+
14+ namespace Richardhj \ContaoAjaxReloadElementBundle \EventListener \DataContainer ;
15+
16+ use Contao \CoreBundle \DataContainer \PaletteManipulator ;
17+ use Contao \DataContainer ;
18+
19+ /**
20+ * Class ModifyPalettesListener
21+ */
22+ class ModifyPalettesListener
23+ {
24+ public function __invoke (DataContainer $ dc ): void
25+ {
26+ foreach ($ GLOBALS ['TL_DCA ' ][$ dc ->table ]['palettes ' ] as $ name => $ palette ) {
27+ if (!\is_string ($ palette )) {
28+ continue ;
29+ }
30+
31+ if ('tl_content ' === $ dc ->table && 'module ' === $ name ) {
32+ continue ;
33+ }
34+
35+ PaletteManipulator::create ()
36+ ->addField ('allowAjaxReload ' , 'expert_legend ' , PaletteManipulator::POSITION_APPEND )
37+ ->applyToPalette ($ name , $ dc ->table )
38+ ;
39+ }
40+ }
41+ }
Original file line number Diff line number Diff line change @@ -3,3 +3,6 @@ services:
33 arguments :
44 - ' @contao.image.picture_factory'
55 public : true
6+
7+ Richardhj\ContaoAjaxReloadElementBundle\EventListener\DataContanier\ModifyPalettesListener :
8+ public : true
Original file line number Diff line number Diff line change 1111 * @license https://github.com/richardhj/contao-ajax_reload_element/blob/master/LICENSE LGPL-3.0
1212 */
1313
14+ use Richardhj \ContaoAjaxReloadElementBundle \EventListener \DataContainer \ModifyPalettesListener ;
1415
1516/**
16- * Palettes
17+ * Config
1718 */
18- $ GLOBALS ['TL_DCA ' ]['tl_article ' ]['palettes ' ]['default ' ] .= ' ,allowAjaxReload ' ;
19+ $ GLOBALS ['TL_DCA ' ]['tl_article ' ]['config ' ]['onload_callback ' ][] = [ModifyPalettesListener::class, ' __invoke ' ] ;
1920
2021/**
2122 * Fields
Original file line number Diff line number Diff line change 1111 * @license https://github.com/richardhj/contao-ajax_reload_element/blob/master/LICENSE LGPL-3.0
1212 */
1313
14+ use Richardhj \ContaoAjaxReloadElementBundle \EventListener \DataContainer \ModifyPalettesListener ;
15+
16+ /**
17+ * Config
18+ */
19+ $ GLOBALS ['TL_DCA ' ]['tl_content ' ]['config ' ]['onload_callback ' ][] = [ModifyPalettesListener::class, '__invoke ' ];
1420
1521/**
1622 * Palettes
1723 */
1824$ GLOBALS ['TL_DCA ' ]['tl_content ' ]['palettes ' ]['__selector__ ' ][] = 'allowAjaxReload ' ;
19- foreach ($ GLOBALS ['TL_DCA ' ]['tl_content ' ]['palettes ' ] as $ name => $ palette ) {
20- if (in_array ($ name , ['__selector__ ' , 'module ' ])) {
21- continue ;
22- }
23-
24- $ GLOBALS ['TL_DCA ' ]['tl_content ' ]['palettes ' ][$ name ] .= ',allowAjaxReload ' ;
25- }
26-
2725$ GLOBALS ['TL_DCA ' ]['tl_content ' ]['subpalettes ' ]['allowAjaxReload ' ] = 'ajaxReloadFormSubmit ' ;
2826
2927/**
Original file line number Diff line number Diff line change 1111 * @license https://github.com/richardhj/contao-ajax_reload_element/blob/master/LICENSE LGPL-3.0
1212 */
1313
14+ use Richardhj \ContaoAjaxReloadElementBundle \EventListener \DataContainer \ModifyPalettesListener ;
15+
16+ /**
17+ * Config
18+ */
19+ $ GLOBALS ['TL_DCA ' ]['tl_module ' ]['config ' ]['onload_callback ' ][] = [ModifyPalettesListener::class, '__invoke ' ];
1420
1521/**
1622 * Palettes
1723 */
1824$ GLOBALS ['TL_DCA ' ]['tl_module ' ]['palettes ' ]['__selector__ ' ][] = 'allowAjaxReload ' ;
19- foreach ($ GLOBALS ['TL_DCA ' ]['tl_module ' ]['palettes ' ] as $ name => $ palette ) {
20- if ('__selector__ ' === $ name ) {
21- continue ;
22- }
23-
24- $ GLOBALS ['TL_DCA ' ]['tl_module ' ]['palettes ' ][$ name ] .= ',allowAjaxReload ' ;
25- }
26-
2725$ GLOBALS ['TL_DCA ' ]['tl_module ' ]['subpalettes ' ]['allowAjaxReload ' ] = 'ajaxReloadFormSubmit ' ;
2826
2927/**
You can’t perform that action at this time.
0 commit comments