Test de redirection

This commit is contained in:
fredtempez 2019-12-01 16:24:38 +01:00
parent 57dd3ea049
commit 3e0525d2fe
3 changed files with 24 additions and 5 deletions

View File

@ -1393,9 +1393,20 @@ class core extends common {
}
// Redirection
if($output['redirect']) {
http_response_code(301);
header('Location:' . $output['redirect']);
exit();
// Redirection Lity
if ($output['script'] === 'redirectdatality') {
$this->addOutput ([
'content' => '<a href="' . $output['redirect'] . '" class="displayNone" data-lity id="redirectdatality">Lien</a>',
'script' => '$(document).on("lity:close", function(event, instance) {
location.replace("' . helper::baseURl() . '");
});
document.getElementById("redirectdatality").click();'
]);
} else {
http_response_code(301);
header('Location:' . $output['redirect']);
exit();
}
}
}
// Données en sortie applicables même lorsqu'une notice est présente

View File

@ -19,7 +19,7 @@ class redirection extends common {
'index' => self::GROUP_VISITOR
];
const REDIRECTION_VERSION = '1.3';
const REDIRECTION_VERSION = '1.4';
/**
* Configuration
@ -27,7 +27,10 @@ class redirection extends common {
public function config() {
// Soumission du formulaire
if($this->isPost()) {
$this->setData(['module', $this->getUrl(0), 'url', $this->getInput('redirectionConfigUrl', helper::FILTER_URL, true)]);
$this->setData(['module', $this->getUrl(0), [
'url' => $this->getInput('redirectionConfigUrl', helper::FILTER_URL, true),
'openIn' => $this->getInput('redirectionConfigOpenIn', helper::FILTER_BOOLEAN)
]]);
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(),
@ -66,6 +69,7 @@ class redirection extends common {
// Valeurs en sortie
$this->addOutput([
'redirect' => $this->getData(['module', $this->getUrl(0), 'url']),
'script' => $this->getData(['module', $this->getUrl(0), 'openIn']) ? 'redirectdatality' : '',
'state' => true
]);
}

View File

@ -21,6 +21,10 @@
'placeholder' => 'http://',
'value' => $this->getData(['module', $this->getUrl(0), 'url'])
]); ?>
<?php echo template::checkbox('redirectionConfigOpenIn', true , 'Ouvrir dans une popup intégrée', [
'checked' => $this->getData(['module', $this->getUrl(0), 'openIn'])
]);
?>
</div>
</div>
<div class="col6">