From c9e188e05446a37b1d3d0c5a3b4548c798fc43b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Auswo=CC=88ger?= Date: Tue, 19 Mar 2024 14:24:36 +0100 Subject: [PATCH] Use router to generate backend routes --- src/Module/Slider.php | 4 ++-- src/Slider.php | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Module/Slider.php b/src/Module/Slider.php index a064cd2..d085569 100644 --- a/src/Module/Slider.php +++ b/src/Module/Slider.php @@ -48,12 +48,12 @@ public function generate() $template->title = $this->name; $template->id = $this->id; $template->link = $this->name; - $template->href = 'contao?do=themes&table=tl_module&act=edit&id=' . $this->id; + $template->href = StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', ['do' => 'themes', 'table' => 'tl_module', 'act' => 'edit', 'id'=> $this->id])); if ($this->objModel->rsts_id && ($slider = SliderModel::findByPk($this->objModel->rsts_id)) !== null) { $template->id = $slider->id; $template->link = $slider->name; - $template->href = 'contao?do=rocksolid_slider&table=tl_rocksolid_slide&id=' . $slider->id; + $template->href = StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', ['do' => 'rocksolid_slider', 'table' => 'tl_rocksolid_slide', 'id'=> $slider->id])); } return $template->parse(); diff --git a/src/Slider.php b/src/Slider.php index 5c7c5ac..d8583e9 100644 --- a/src/Slider.php +++ b/src/Slider.php @@ -124,7 +124,7 @@ public function headerCallback($headerFields, $dc) ->execute($dc->currentPid); if ($sliderData->numRows && $sliderData->type !== 'content') { - $this->redirect('contao?do=rocksolid_slider&act=edit&id=' . $dc->currentPid . '&ref=' . Input::get('ref') . '&rt=' . System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue()); + $this->redirect(System::getContainer()->get('router')->generate('contao_backend', ['do' => 'rocksolid_slider', 'act' => 'edit', 'id' => $dc->currentPid, 'ref' => Input::get('ref'), 'rt' => System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue()])); } return $headerFields; @@ -147,7 +147,7 @@ public function headerCallbackContent($headerFields, $dc) ->execute($dc->currentPid); if ($slideData->numRows && $slideData->type !== 'content') { - $this->redirect('contao?do=rocksolid_slider&table=tl_rocksolid_slide&act=edit&id=' . $dc->currentPid . '&ref=' . Input::get('ref') . '&rt=' . System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue()); + $this->redirect(System::getContainer()->get('router')->generate('contao_backend', ['do' => 'rocksolid_slider', 'table' => 'tl_rocksolid_slide', 'act' => 'edit', 'id' => $dc->currentPid, 'ref' => Input::get('ref'), 'rt' => System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue()])); } return $headerFields; @@ -270,7 +270,10 @@ protected function removeProFields($table, $fields = array(), $legends = array() } $GLOBALS['TL_DCA'][$table]['fields'][$field]['label'] = array( $GLOBALS['TL_DCA'][$table]['fields'][$field]['label'][0], - sprintf($GLOBALS['TL_LANG']['tl_rocksolid_slider']['proFieldDescription'], 'contao?do=rocksolid_slider&table=tl_rocksolid_slider_license&ref=' . System::getContainer()->get('request_stack')->getCurrentRequest()->get('_contao_referer_id')) . '
' . $GLOBALS['TL_DCA'][$table]['fields'][$field]['label'][1], + sprintf( + $GLOBALS['TL_LANG']['tl_rocksolid_slider']['proFieldDescription'], + StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', ['do' => 'rocksolid_slider', 'table' => 'tl_rocksolid_slider_license', 'ref' => System::getContainer()->get('request_stack')->getCurrentRequest()->get('_contao_referer_id')])) + ) . '
' . $GLOBALS['TL_DCA'][$table]['fields'][$field]['label'][1], ); } @@ -281,7 +284,10 @@ protected function removeProFields($table, $fields = array(), $legends = array() $GLOBALS['TL_DCA'][$table]['fields']['rsts_getPro'] = array( 'input_field_callback' => function() { return '
' - . sprintf($GLOBALS['TL_LANG']['tl_rocksolid_slider']['proLegendDescription'], 'contao?do=rocksolid_slider&table=tl_rocksolid_slider_license&ref=' . System::getContainer()->get('request_stack')->getCurrentRequest()->get('_contao_referer_id')) + . sprintf( + $GLOBALS['TL_LANG']['tl_rocksolid_slider']['proLegendDescription'], + StringUtil::specialcharsUrl(System::getContainer()->get('router')->generate('contao_backend', ['do' => 'rocksolid_slider', 'table' => 'tl_rocksolid_slider_license', 'ref' => System::getContainer()->get('request_stack')->getCurrentRequest()->get('_contao_referer_id')])) + ) . '
'; }, );