arlequin/index.php

116 lines
4.3 KiB
PHP
Raw Normal View History

2022-12-14 22:35:40 +00:00
<?php
/**
* @brief arlequin, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
*
* @copyright Jean-Crhistian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return;
}
2015-04-22 13:29:49 +00:00
2022-12-14 22:35:40 +00:00
$mt_models = [];
2015-04-22 13:29:49 +00:00
2022-12-14 22:35:40 +00:00
try {
include __DIR__ . '/inc/models.php';
2015-04-22 13:29:49 +00:00
2022-12-14 22:35:40 +00:00
// Initialisation
dcCore::app()->blog->settings->addNamespace('arlequinMulti');
[$mt_cfg, $mt_exclude] = adminArlequin::loadSettings(dcCore::app()->blog->settings);
if (adminArlequin::$initialized) {
dcAdminNotices::AddSuccessNotice(__('Settings have been reinitialized.'));
}
2015-04-22 13:29:49 +00:00
2022-12-14 22:35:40 +00:00
// Enregistrement des données depuis les formulaires
if (isset($_POST['mt_action_config'])) {
$mt_cfg['e_html'] = $_POST['e_html'];
$mt_cfg['a_html'] = $_POST['a_html'];
$mt_cfg['s_html'] = $_POST['s_html'];
$mt_exclude = $_POST['mt_exclude'];
}
2015-04-22 13:29:49 +00:00
2022-12-14 22:35:40 +00:00
// Traitement des requêtes
if (isset($_POST['mt_action_config'])) {
dcCore::app()->blog->settings->arlequinMulti->put('mt_cfg', serialize($mt_cfg));
dcCore::app()->blog->settings->arlequinMulti->put('mt_exclude', $mt_exclude);
dcAdminNotices::AddSuccessNotice(__('System settings have been updated.'));
dcCore::app()->blog->triggerBlog();
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), ['config' => 1]);
}
if (isset($_POST['mt_action_restore'])) {
dcCore::app()->blog->settings->arlequinMulti->drop('mt_cfg');
dcCore::app()->blog->settings->arlequinMulti->drop('mt_exclude');
dcAdminNotices::AddSuccessNotice(__('Settings have been reinitialized.'));
dcCore::app()->blog->triggerBlog();
dcCore::app()->adminurl->redirect('admin.plugin.' . basename(__DIR__), ['restore' => 1]);
}
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
2015-04-22 13:29:49 +00:00
}
// Headers
2022-12-14 22:35:40 +00:00
$jsModels = '';
$cslashes = "\n\"\'";
foreach ($mt_models as $m) { // @phpstan-ignore-line
$jsModels .= "\t" .
'arlequin.addModel(' .
'"' . html::escapeJS($m['name']) . '",' .
'"' . addcslashes($m['s_html'], $cslashes) . '",' .
'"' . addcslashes($m['e_html'], $cslashes) . '",' .
'"' . addcslashes($m['a_html'], $cslashes) . '"' .
");\n";
2015-04-22 13:29:49 +00:00
}
2022-12-14 22:35:40 +00:00
// DISPLAY
2015-04-22 13:29:49 +00:00
echo '
2022-12-14 22:35:40 +00:00
<html><head><title>' . __('Arlequin') . '</title>' .
dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/models.js')) . '
2015-04-22 13:29:49 +00:00
<script type="text/javascript">
//<![CDATA[
2022-12-14 22:35:40 +00:00
arlequin.msg.predefined_models = "' . html::escapeJS(__('Predefined models')) . '";
arlequin.msg.select_model = "' . html::escapeJS(__('Select a model')) . '";
arlequin.msg.user_defined = "' . html::escapeJS(__('User defined')) . '";
2015-04-22 13:29:49 +00:00
$(function() {
arlequin.addDefault();
2022-12-14 22:35:40 +00:00
' . $jsModels . '
2015-04-22 13:29:49 +00:00
});
//]]>
</script>
2022-12-14 22:35:40 +00:00
</head><body>' .
dcPage::breadcrumb([
html::escapeHTML(dcCore::app()->blog->name) => '',
'<span class="page-title">' . __('Arlequin') . '</span>' => '',
]) .
dcPage::notices() . '
2015-04-22 13:29:49 +00:00
2022-12-14 22:35:40 +00:00
<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" method="post">
<h4>' . __('Switcher display format') . '</h4>
2015-04-22 13:29:49 +00:00
<div id="models"></div>
2022-12-14 22:35:40 +00:00
<div class="two-boxes odd">
<p><label for="s_html">' . __('Switcher HTML code:') . '</label> ' .
form::textArea('s_html', 50, 10, html::escapeHTML($mt_cfg['s_html'])) . '</p>
</div><div class="two-boxes even">
<p><label for="e_html">' . __('Item HTML code:') . '</label> ' .
form::field('e_html', 50, 200, html::escapeHTML($mt_cfg['e_html'])) . '</p>
<p><label for="a_html">' . __('Active item HTML code:') . '</label> ' .
form::field('a_html', 50, 200, html::escapeHTML($mt_cfg['a_html'])) . '</p>
</div><div class="two-boxes odd">
<p><label for="mt_exclude">' . __("Excluded themes (separated by slashs '/'):") . '</label> ' .
form::field('mt_exclude', 50, 200, html::escapeHTML($mt_exclude)) . '</p>
<p class="info">' . __('The names to be taken into account are those of the theme files.') . '</p>
2015-04-22 13:29:49 +00:00
</div>
2022-12-14 22:35:40 +00:00
<p>
<input type="submit" name="mt_action_config" value="' . __('Save') . '" />
<input type="submit" name="mt_action_restore" value="' . __('Restore defaults') . '" />' .
dcCore::app()->formNonce() . '</p>
2015-04-22 13:29:49 +00:00
</form>';
dcPage::helpBlock('arlequin'); ?>
2021-09-17 20:37:54 +00:00
</body></html>