Skip to content

Commit

Permalink
Use router to generate backend routes
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Mar 19, 2024
1 parent 904d115 commit c9e188e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Module/Slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 10 additions & 4 deletions src/Slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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&amp;table=tl_rocksolid_slider_license&amp;ref=' . System::getContainer()->get('request_stack')->getCurrentRequest()->get('_contao_referer_id')) . '<br>' . $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')]))
) . '<br>' . $GLOBALS['TL_DCA'][$table]['fields'][$field]['label'][1],
);
}

Expand All @@ -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 '<div class="tl_message" style="padding: 15px">'
. sprintf($GLOBALS['TL_LANG']['tl_rocksolid_slider']['proLegendDescription'], 'contao?do=rocksolid_slider&amp;table=tl_rocksolid_slider_license&amp;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')]))
)
. '</div>';
},
);
Expand Down

0 comments on commit c9e188e

Please sign in to comment.