Skip to content

Commit beddc36

Browse files
committed
Fix issue #1026
The page picker in render settings did pass the value to the modal screen. This commit fixes this by applying a load of inline javascript code to pass the value along. I wish the MCW would understand how widgets in DCG work.
1 parent dbf1002 commit beddc36

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

contao/dca/tl_metamodel_rendersettings.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@
315315
'label' => &$GLOBALS['TL_LANG']['tl_metamodel_rendersettings']['jumpTo_page'],
316316
'exclude' => true,
317317
'inputType' => 'text',
318-
// TODO: change callbacks to event handlers.
319318
'wizard' => array
320319
(
321320
array('MetaModels\Dca\RenderSettings', 'pagePicker')

src/MetaModels/Dca/RenderSettings.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@
3333
class RenderSettings
3434
{
3535
/**
36-
* Return the link picker wizard.
36+
* Return the link picker wizard - this is called from Multi column wizard in render settings jumpTo page handling.
37+
*
38+
* We should change this callback to event handlers as soon as MCW understands how DcGeneral events work.
39+
* So far MCW does not build sub widgets the MCW way, therefore we need to keep this as it is, despite the fact that
40+
* we are jumping multiple hoops with the inline javascript code to obtain the value.
3741
*
3842
* @param DC_General $dataContainer The DC_General currently in use.
3943
*
@@ -49,14 +53,6 @@ public function pagePicker(DC_General $dataContainer)
4953
$dataContainer->inputName
5054
);
5155

52-
$options = sprintf(
53-
"{'width':765,'title':'%s','url':'%s','id':'%s','tag':'ctrl_%s','self':this}",
54-
$environment->getTranslator()->translate('MOD.page.0'),
55-
$url,
56-
$dataContainer->inputName,
57-
$dataContainer->inputName
58-
);
59-
6056
$event = new GenerateHtmlEvent(
6157
'pickpage.gif',
6258
$environment->getTranslator()->translate('MSC.pagepicker'),
@@ -66,9 +62,16 @@ public function pagePicker(DC_General $dataContainer)
6662
$environment->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_GET_HTML, $event);
6763

6864
return sprintf(
69-
' <a href="%s"%s>%s</a>',
65+
' <a href="%1$s" onclick="Backend.openModalSelector(' .
66+
'{\'width\':765,' .
67+
'\'title\':\'%2$s\',' .
68+
'\'url\': this.href + \'&value=\' + ' .
69+
// We have no access to the current value as MCW does not understand DCG so far. So we do it all in JS.
70+
'/{{link_url::([^}]*)}}/.exec($(\'ctrl_%3$s\').value)[1],\'id\':\'ctrl_%3$s\'}' .
71+
'); return false;">%4$s</a>',
7072
$url,
71-
' onclick="Backend.openModalSelector(' . $options . '); return false;"',
73+
specialchars(str_replace('\'', '\\\'', $environment->getTranslator()->translate('MOD.page.0'))),
74+
$dataContainer->inputName,
7275
$event->getHtml()
7376
);
7477
}

0 commit comments

Comments
 (0)