2022-01-31 09:10:49 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is part of DeltaCMS.
|
|
|
|
* For full copyright and license information, please see the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
* @author Sylvain Lelièvre <lelievresylvain@free.fr>
|
|
|
|
* @copyright Copyright (C) 2021-2022, Sylvain Lelièvre
|
|
|
|
* @license GNU General Public License, version 3
|
|
|
|
* @link https://deltacms.fr/
|
|
|
|
*
|
|
|
|
* Delta was created from version 11.2.00.24 of ZwiiCMS
|
|
|
|
* @author Rémi Jean <remi.jean@outlook.com>
|
|
|
|
* @copyright Copyright (C) 2008-2018, Rémi Jean
|
|
|
|
* @author Frédéric Tempez <frederic.tempez@outlook.com>
|
|
|
|
* @copyright Copyright (C) 2018-2021, Frédéric Tempez
|
|
|
|
*/
|
|
|
|
|
|
|
|
class redirection extends common {
|
|
|
|
|
2022-11-07 16:37:05 +01:00
|
|
|
const VERSION = '2.2';
|
2022-01-31 09:10:49 +01:00
|
|
|
const REALNAME = 'Redirection';
|
|
|
|
const DELETE = true;
|
|
|
|
const UPDATE = '0.0';
|
|
|
|
const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json)
|
|
|
|
|
|
|
|
public static $actions = [
|
2022-11-07 16:37:05 +01:00
|
|
|
'config' => self::GROUP_EDITOR,
|
2022-01-31 09:10:49 +01:00
|
|
|
'index' => self::GROUP_VISITOR
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuration
|
|
|
|
*/
|
|
|
|
public function config() {
|
2022-03-06 13:35:21 +01:00
|
|
|
// Lexique
|
2022-07-05 08:16:26 +02:00
|
|
|
include('./module/redirection/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_redirection.php');
|
|
|
|
|
2022-01-31 09:10:49 +01:00
|
|
|
// Soumission du formulaire
|
|
|
|
if($this->isPost()) {
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'url', $this->getInput('redirectionConfigUrl', helper::FILTER_URL, true)]);
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => helper::baseUrl() . $this->getUrl(),
|
2022-07-05 08:16:26 +02:00
|
|
|
'notification' => $text['redirection']['config'][0],
|
2022-01-31 09:10:49 +01:00
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
2022-07-05 08:16:26 +02:00
|
|
|
'title' => $text['redirection']['config'][1],
|
2022-01-31 09:10:49 +01:00
|
|
|
'view' => 'config'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Accueil
|
|
|
|
*/
|
|
|
|
public function index() {
|
|
|
|
// Message si l'utilisateur peut éditer la page
|
|
|
|
if(
|
|
|
|
$this->getUser('password') === $this->getInput('DELTA_USER_PASSWORD')
|
2022-11-07 16:37:05 +01:00
|
|
|
AND $this->getUser('group') >= self::GROUP_EDITOR
|
2022-01-31 09:10:49 +01:00
|
|
|
AND $this->getUrl(1) !== 'force'
|
|
|
|
) {
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'display' => self::DISPLAY_LAYOUT_BLANK,
|
|
|
|
'title' => '',
|
|
|
|
'view' => 'index'
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
// Sinon redirection
|
|
|
|
else {
|
|
|
|
// Incrémente le compteur de clics
|
|
|
|
$this->setData(['module', $this->getUrl(0), 'count', helper::filter($this->getData(['module', $this->getUrl(0), 'count']) + 1, helper::FILTER_INT)]);
|
|
|
|
// Valeurs en sortie
|
|
|
|
$this->addOutput([
|
|
|
|
'redirect' => $this->getData(['module', $this->getUrl(0), 'url']),
|
|
|
|
'state' => true
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|