2021-11-05 21:52:46 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @brief improve, a plugin for Dotclear 2
|
|
|
|
*
|
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
|
|
|
*
|
|
|
|
* @author Jean-Christian Denis and contributors
|
|
|
|
*
|
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-11-13 21:57:51 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2022-12-21 14:41:27 +00:00
|
|
|
namespace Dotclear\Plugin\improve;
|
2021-11-05 21:52:46 +00:00
|
|
|
|
2021-11-13 21:57:51 +00:00
|
|
|
/* dotclear */
|
|
|
|
use dcCore;
|
|
|
|
use dcPage;
|
2021-11-05 21:52:46 +00:00
|
|
|
|
2021-11-13 21:57:51 +00:00
|
|
|
/* clearbricks */
|
|
|
|
use form;
|
2021-11-05 21:52:46 +00:00
|
|
|
|
2021-11-13 21:57:51 +00:00
|
|
|
/* php */
|
|
|
|
use Exception;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Admin Improve configuration class
|
|
|
|
*
|
|
|
|
* Set preference for this plugin.
|
|
|
|
*/
|
2022-12-21 14:41:27 +00:00
|
|
|
class Config
|
2021-11-13 21:57:51 +00:00
|
|
|
{
|
2022-12-21 14:41:27 +00:00
|
|
|
private static $init = false;
|
2021-11-13 21:57:51 +00:00
|
|
|
|
2022-12-21 14:41:27 +00:00
|
|
|
public static function init(): bool
|
2021-11-13 21:57:51 +00:00
|
|
|
{
|
2022-12-21 14:41:27 +00:00
|
|
|
if (defined('DC_CONTEXT_ADMIN')) {
|
|
|
|
dcPage::checkSuper();
|
|
|
|
self::$init = true;
|
|
|
|
}
|
2021-11-13 21:57:51 +00:00
|
|
|
|
2022-12-21 14:41:27 +00:00
|
|
|
return self::$init;
|
2021-11-13 21:57:51 +00:00
|
|
|
}
|
2021-11-05 21:52:46 +00:00
|
|
|
|
2022-12-21 14:41:27 +00:00
|
|
|
public static function process(): void
|
2021-11-13 21:57:51 +00:00
|
|
|
{
|
2022-12-21 14:41:27 +00:00
|
|
|
if (!self::$init) {
|
|
|
|
return;
|
2021-11-05 21:52:46 +00:00
|
|
|
}
|
|
|
|
|
2021-11-13 21:57:51 +00:00
|
|
|
if (empty($_POST['save'])) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
$pdisabled = '';
|
|
|
|
if (!empty($_POST['disabled']) && is_array($_POST['disabled'])) {
|
|
|
|
$pdisabled = implode(';', $_POST['disabled']);
|
|
|
|
}
|
2022-12-21 14:41:27 +00:00
|
|
|
dcCore::app()->blog->settings->get(Core::id())->put('disabled', $pdisabled);
|
|
|
|
dcCore::app()->blog->settings->get(Core::id())->put('nodetails', !empty($_POST['nodetails']));
|
2021-11-13 21:57:51 +00:00
|
|
|
|
|
|
|
dcPage::addSuccessNotice(__('Configuration successfully updated'));
|
|
|
|
|
2022-11-12 21:58:44 +00:00
|
|
|
dcCore::app()->adminurl->redirect(
|
2021-11-13 21:57:51 +00:00
|
|
|
'admin.plugins',
|
2022-12-01 10:09:24 +00:00
|
|
|
['module' => 'improve', 'conf' => 1, 'chk' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
2021-11-13 21:57:51 +00:00
|
|
|
);
|
|
|
|
} catch (Exception $e) {
|
2022-11-12 21:58:44 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-11-13 21:57:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-21 14:41:27 +00:00
|
|
|
public static function render()
|
2021-11-13 21:57:51 +00:00
|
|
|
{
|
2022-12-21 14:41:27 +00:00
|
|
|
if (!self::$init) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$improve = new Core();
|
|
|
|
|
|
|
|
$modules = [];
|
|
|
|
foreach ($improve->modules() as $action) {
|
|
|
|
$modules[$action->name()] = $action->id();
|
|
|
|
}
|
|
|
|
$modules = array_merge($modules, array_flip($improve->disabled()));
|
|
|
|
|
2021-11-13 21:57:51 +00:00
|
|
|
echo '<div class="fieldset"><h4>' . __('List of disabled actions:') . '</h4>';
|
2021-11-05 21:52:46 +00:00
|
|
|
|
2022-12-21 14:41:27 +00:00
|
|
|
foreach ($modules as $name => $id) {
|
2021-11-13 21:57:51 +00:00
|
|
|
echo
|
|
|
|
'<p><label class="classic" title="' . $id . '">' .
|
2022-12-21 14:41:27 +00:00
|
|
|
form::checkbox(['disabled[]'], $id, ['checked' => array_key_exists($id, $improve->disabled())]) .
|
2021-11-13 21:57:51 +00:00
|
|
|
__($name) . '</label></p>';
|
|
|
|
}
|
|
|
|
echo
|
|
|
|
'</div><div class="fieldset"><h4>' . __('Options') . '</h4>' .
|
|
|
|
'<p><label class="classic">' .
|
2022-12-21 14:41:27 +00:00
|
|
|
form::checkbox('nodetails', '1', ['checked' => dcCore::app()->blog->settings->get(Core::id())->get('nodetails')]) .
|
2021-11-13 21:57:51 +00:00
|
|
|
__('Hide details of rendered actions') . '</label></p>' .
|
|
|
|
'</div>';
|
|
|
|
}
|
2021-11-05 21:52:46 +00:00
|
|
|
}
|