Compare commits

..

No commits in common. "master" and "v2.3" have entirely different histories.
master ... v2.3

12 changed files with 173 additions and 199 deletions

View File

@ -1,78 +1,47 @@
arlequin 2.5.1 - 2023.11.04
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Use last minute Dotclear 2.28 changes
* Fix typo
* Fix permissions
arlequin 2.5 - 2023.10.15
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
arlequin 2.4 - 2023.09.04
===========================================================
* Require Dotclear 2.27
* Require PHP 7.4+
* Fix crash on theme preview
* Use dotclear style for CHANGELOG
* Update README
arlequin 2.3 - 2023.08.06
===========================================================
* require Dotclear 2.27
* require PHP 7.4+
* move third party repository
arlequin 2.2 - 2023.07.30
===========================================================
2.2 - 2023.07.30
* require Dotclear 2.27
* require PHP 7.4+
* use new svg icon
* update to Dotclear 2.27-dev
arlequin 2.1 - 2023.05.13
===========================================================
2.1 - 2023.05.13
* require Dotclear 2.26
* fix nullsafe warnings
* add plugin Uninstaller features
arlequin 2.0 - 2023.04.11
===========================================================
2.0 - 2023.04.11
* require Dotclear 2.26
* use namespace
* add behavior to register models
* move settings names (lost previously saved)
* move models (lost previously saved)
arlequin 1.6 - 2022.12.14
===========================================================
1.6 - 2022.12.14
* Update to dotclear 2.24
arlequin 1.5 - 2021.09.16 Pierre Van Glabeke
===========================================================
1.5 - 2021.09.16 Pierre Van Glabeke
* champs rallongés
arlequin 1.4 - 2021.09.15 - Pierre Van Glabeke
===========================================================
1.4 - 2021.09.15 - Pierre Van Glabeke
* correction bug affichage dc2.19
* dc2.19 requis
arlequin 1.3 - 2018.01.21 - Pierre Van Glabeke
===========================================================
1.3 - 2018.01.21 - Pierre Van Glabeke
* modif setting
* modif index
* modif localisation
1.2 - 2.16.06.12 - Pierre Van Glabeke
===========================================================
* ajout code sécu resources.php
* modif intitulé dans admin
1.1 - 2.15.03.05 - Pierre Van Glabeke
===========================================================
* compatibilité dc2.7
* cosmétique dc2.6
* localisation

View File

@ -1,22 +1,26 @@
# README
[![Release](https://img.shields.io/badge/release-2.5.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/arlequin/releases)
![Date](https://img.shields.io/badge/date-2023.11.04-c44d58.svg)]
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/arlequin)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/arlequin/src/branch/master/LICENSE)
[![Release](https://img.shields.io/github/v/release/JcDenis/arlequin)](https://github.com/JcDenis/arlequin/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/arlequin)](https://github.com/JcDenis/arlequin/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/arlequin)](https://github.com/JcDenis/arlequin/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/arlequin)
[![License](https://img.shields.io/github/license/JcDenis/arlequin)](https://github.com/JcDenis/arlequin/blob/master/LICENSE)
## ABOUT
## WHAT IS ARLEQUIN ?
_arlequin_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
_arlequin_ is a plugin for the open-source
web publishing software called Dotclear.
> Allows visitors choose a theme.
It allows visitors to select a theme on your blog.
## REQUIREMENTS
* Dotclear 2.28
* PHP 8.1+
* Dotclear content admin permissions to manage theme and public menu
_arlequin_ requires:
* content admin permissions to manage theme and public menu
* Dotclear 2.27
* PHP 7.4+
## USAGE
@ -29,17 +33,16 @@ you should also add widget to allow visitor to select a theme.
## LINKS
* [License](https://git.dotclear.watch/JcDenis/arlequin/src/branch/master/LICENSE)
* [Packages & details](https://git.dotclear.watch/JcDenis/arlequin/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/arlequin))
* [Sources & contributions](https://git.dotclear.watch/JcDenis/arlequin) (or on [GitHub](https://github.com/JcDenis/arlequin))
* [Issues & security](https://git.dotclear.watch/JcDenis/arlequin/issues) (or on [GitHub](https://github.com/JcDenis/arlequin/issues))
* [Discuss & help](http://forum.dotclear.org/viewtopic.php?id=48345)
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/arlequin) or [GitHub Page](https://github.com/JcDenis/arlequin)
* Packages & details :[Gitea Page](https://git.dotclear.watch/JcDenis/arlequin/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/arlequin)
* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?id=48345)
## CONTRIBUTORS
* Oleksandr Syenchuk (author)
* Gaetan Guillard
* Pierre Van Glabeke
* Jean-Christian Denis (latest)
* Oleksandr Syenchuk (author)
* Gaetan Guillard
* Pierre Van Glabeke
* Jean-Christian Denis
You are welcome to contribute to this code.
You are welcome to contribute to this code.

View File

@ -1,30 +1,32 @@
<?php
/**
* @file
* @brief The plugin arlequin definition
* @ingroup arlequin
* @brief arlequin, a plugin for Dotclear 2
*
* @defgroup arlequin Plugin arlequin.
* @package Dotclear
* @subpackage Plugin
*
* Allows visitors choose a theme.
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
if (!defined('DC_RC_PATH')) {
return;
}
$this->registerModule(
'Arlequin',
'Allows visitors choose a theme',
'Oleksandr Syenchuk, Pierre Van Glabeke and contributors',
'2.5.1',
'2.3',
[
'requires' => [['core', '2.28']],
'permissions' => 'My',
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]),
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
]
);

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="arlequin">
<name>Arlequin</name>
<version>2.5.1</version>
<version>2.3</version>
<author>Oleksandr Syenchuk, Pierre Van Glabeke and contributors</author>
<desc>Allows visitors choose a theme</desc>
<file>https://git.dotclear.watch/JcDenis/arlequin/releases/download/v2.5.1/plugin-arlequin.zip</file>
<da:dcmin>2.28</da:dcmin>
<file>https://gitea.dotclear.watch/JcDenis/arlequin/releases/download/v2.3/plugin-arlequin.zip</file>
<da:dcmin>2.27</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/arlequin/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/arlequin/issues</da:support>
</module>

View File

@ -10,4 +10,8 @@
* @copyright Jean-Crhistian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
\Dotclear\App::backend()->resources()->set('help', 'arlequin', __DIR__ . '/help/arlequin.html');
if (!defined('DC_RC_PATH')) {
return;
}
dcCore::app()->resources['help']['arlequin'] = __DIR__ . '/help/arlequin.html';

View File

@ -10,4 +10,8 @@
* @copyright Jean-Crhistian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
\Dotclear\App::backend()->resources()->set('help', 'arlequin', __DIR__ . '/help/arlequin.html');
if (!defined('DC_RC_PATH')) {
return;
}
dcCore::app()->resources['help']['arlequin'] = __DIR__ . '/help/arlequin.html';

View File

@ -1,21 +1,26 @@
<?php
/**
* @brief arlequin, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\arlequin;
use Dotclear\App;
use dcCore;
use Dotclear\Core\Process;
use Dotclear\Core\Backend\Favorites;
use Dotclear\Core\Backend\{
Favorites,
Menus
};
/**
* @brief arlequin backend class.
* @ingroup arlequin
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Backend extends Process
{
public static function init(): bool
@ -29,21 +34,21 @@ class Backend extends Process
return false;
}
My::addBackendMenuItem(App::backend()->menus()::MENU_BLOG);
My::addBackendMenuItem(Menus::MENU_BLOG);
App::behavior()->addBehaviors([
dcCore::app()->addBehaviors([
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
$favs->register(My::id(), [
'title' => My::name(),
'url' => My::manageUrl(),
'small-icon' => My::icons(),
'large-icon' => My::icons(),
'permissions' => App::auth()->makePermissions([
App::auth()::PERMISSION_CONTENT_ADMIN,
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]),
]);
},
'initWidgets' => Widgets::initWidgets(...),
'initWidgets' => [Widgets::class, 'initWidgets'],
]);
return true;

View File

@ -1,35 +1,26 @@
<?php
/**
* @brief arlequin, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\arlequin;
use Dotclear\App;
use dcCore;
use Dotclear\Core\Process;
use Dotclear\Helper\Network\Http;
/**
* @brief arlequin frontend class.
* @ingroup arlequin
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Frontend extends Process
{
/**
* The arlequin theme cookie.
*
* @var string COOKIE_THEME_PREFIX
*/
public const COOKIE_THEME_PREFIX = 'dc_theme_';
/**
* The arlequin date cookie.
*
* @var string COOKIE_UPDDT_PREFIX
*/
public const COOKIE_UPDDT_PREFIX = 'dc_user_upddt_';
public static function init(): bool
@ -59,9 +50,9 @@ class Frontend extends Process
self::switchTheme($_COOKIE[self::COOKIE_THEME_PREFIX . self::cookieSuffix()]);
}
App::behavior()->addBehaviors([
'publicBeforeDocumentV2' => self::adjustCache(...),
'initWidgets' => Widgets::initWidgets(...),
dcCore::app()->addBehaviors([
'publicBeforeDocumentV2' => [self::class, 'adjustCache'],
'initWidgets' => [Widgets::class, 'initWidgets'],
]);
return true;
@ -69,29 +60,25 @@ class Frontend extends Process
protected static function cookieSuffix(): string
{
return base_convert(App::blog()->uid(), 16, 36);
return base_convert(dcCore::app()->blog->uid, 16, 36);
}
public static function adjustCache(): void
{
if (!empty($_COOKIE[self::COOKIE_UPDDT_PREFIX . self::cookieSuffix()])) {
App::cache()->addTime((int) $_COOKIE[self::COOKIE_UPDDT_PREFIX . self::cookieSuffix()]);
dcCore::app()->cache['mod_ts'][] = (int) $_COOKIE[self::COOKIE_UPDDT_PREFIX . self::cookieSuffix()];
}
}
public static function switchTheme(string $theme): void
{
if (App::blog()->settings()->get('system')->get('theme') == $theme) {
return;
}
if (My::settings()->get('mt_exclude')) {
if (in_array($theme, explode('/', My::settings()->get('mt_exclude')))) {
return;
}
}
App::blog()->settings()->get('system')->set('theme', $theme);
App::frontend()->theme = $theme;
dcCore::app()->blog->settings->get('system')->set('theme', $theme);
dcCore::app()->public->theme = $theme;
}
}

View File

@ -1,11 +1,21 @@
<?php
/**
* @brief arlequin, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\arlequin;
use ArrayObject;
use Dotclear\App;
use dcCore;
use Dotclear\Core\Process;
use Dotclear\Core\Backend\{
Notices,
@ -25,14 +35,6 @@ use Dotclear\Helper\Html\Form\{
use Dotclear\Helper\Html\Html;
use Exception;
/**
* @brief arlequin manage class.
* @ingroup arlequin
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Manage extends Process
{
public static function init(): bool
@ -60,7 +62,7 @@ class Manage extends Process
$s->put('exclude', 'customCSS', 'string', 'Excluded themes');
Notices::AddSuccessNotice(__('Settings have been reinitialized.'));
App::blog()->triggerBlog();
dcCore::app()->blog->triggerBlog();
}
// collect settings
@ -77,7 +79,7 @@ class Manage extends Process
$s->put('exclude', $exclude);
Notices::AddSuccessNotice(__('System settings have been updated.'));
App::blog()->triggerBlog();
dcCore::app()->blog->triggerBlog();
My::redirect(['config' => 1]);
}
@ -87,11 +89,11 @@ class Manage extends Process
$s->drop('exclude');
Notices::AddSuccessNotice(__('Settings have been reinitialized.'));
App::blog()->triggerBlog();
dcCore::app()->blog->triggerBlog();
My::redirect(['restore' => 1]);
}
} catch (Exception $e) {
App::error()->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
return true;
@ -105,7 +107,7 @@ class Manage extends Process
$models = new ArrayObject(My::distributedModels());
App::behavior()->callBehavior('arlequinAddModels', $models);
dcCore::app()->callBehavior('arlequinAddModels', $models);
$models = iterator_to_array($models);
$s = My::settings();
@ -142,12 +144,12 @@ class Manage extends Process
echo
Page::breadcrumb([
Html::escapeHTML(App::blog()->name()) => '',
My::name() => '',
Html::escapeHTML(dcCore::app()->blog->name) => '',
My::name() => '',
]) .
Notices::getNotices() .
(new Form(My::id() . 'form'))->method('post')->action(App::backend()->getPageURL())->fields([
(new Form(My::id() . 'form'))->method('post')->action(dcCore::app()->admin->getPageURL())->fields([
(new Text('h4', __('Switcher display format'))),
(new Div())->id('models'),
(new Div())->class('two-boxes odd')->items([
@ -159,17 +161,17 @@ class Manage extends Process
(new Div())->class('two-boxes even')->items([
(new Para())->items([
(new Label(__('Item HTML code:'), Label::OUTSIDE_LABEL_BEFORE))->for('e_html'),
(new Input('e_html'))->size(50)->maxlength(200)->value(Html::escapeHTML($model['e_html'])),
(new Input('e_html'))->size(50)->maxlenght(200)->value(Html::escapeHTML($model['e_html'])),
]),
(new Para())->items([
(new Label(__('Active item HTML code:'), Label::OUTSIDE_LABEL_BEFORE))->for('a_html'),
(new Input('a_html'))->size(50)->maxlength(200)->value(Html::escapeHTML($model['a_html'])),
(new Input('a_html'))->size(50)->maxlenght(200)->value(Html::escapeHTML($model['a_html'])),
]),
]),
(new Div())->class('two-boxes odd')->items([
(new Para())->items([
(new Label(__('Excluded themes:'), Label::OUTSIDE_LABEL_BEFORE))->for('exclude'),
(new Input('exclude'))->size(50)->maxlength(200)->value(Html::escapeHTML($s->get('exclude'))),
(new Input('exclude'))->size(50)->maxlenght(200)->value(Html::escapeHTML($s->get('exclude'))),
]),
(new Note())->class('form-note')->text('Semicolon separated list of themes IDs (theme folder name). Ex: ductile;berlin'),
]),

View File

@ -1,33 +1,34 @@
<?php
/**
* @brief arlequin, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\arlequin;
use Dotclear\App;
use dcCore;
use Dotclear\Module\MyPlugin;
/**
* @brief arlequin My helper.
* @ingroup arlequin
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* This module definitions.
*/
class My extends MyPlugin
{
public static function checkCustomContext(int $context): ?bool
{
return match ($context) {
// Add content admin to backend
self::MANAGE, self::MENU => App::task()->checkContext('BACKEND')
&& App::auth()->check(App::auth()->makePermissions([
App::auth()::PERMISSION_CONTENT_ADMIN,
]), App::blog()->id()),
default => null,
};
return !in_array($context, [My::BACKEND, My::MANAGE, My::MENU]) ? null :
defined('DC_CONTEXT_ADMIN')
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id);
}
/**
@ -40,8 +41,6 @@ class My extends MyPlugin
* 'e_html'=>'[HTML code]', // Code HTML d'un item pouvant être sélectionné
* 'a_html'=>'[HTML code]' // Code HTML d'un item actif (thème sélectionné)
* ]
*
* @return array<int, array<string, string>>
*/
public static function distributedModels(): array
{
@ -66,11 +65,6 @@ class My extends MyPlugin
];
}
/**
* Get default models.
*
* @return array<string, string>
*/
public static function defaultModel(): array
{
return [

View File

@ -1,20 +1,23 @@
<?php
/**
* @brief arlequin, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\arlequin;
use dcCore;
use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller;
/**
* @brief arlequin uninstall class.
* @ingroup arlequin
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Uninstall extends Process
{
public static function init(): bool
@ -24,7 +27,7 @@ class Uninstall extends Process
public static function process(): bool
{
if (!self::status()) {
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
return false;
}

View File

@ -1,24 +1,26 @@
<?php
/**
* @brief arlequin, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\arlequin;
use Dotclear\App;
use dcCore;
use dcModuleDefine;
use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Network\Http;
use Dotclear\Module\ModuleDefine;
use Dotclear\Plugin\widgets\WidgetsStack;
use Dotclear\Plugin\widgets\WidgetsElement;
/**
* @brief arlequin frontend class.
* @ingroup arlequin
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Widgets
{
public static function initWidgets(WidgetsStack $w): void
@ -26,7 +28,7 @@ class Widgets
$w->create(
'arlequin',
My::name(),
self::parseWidget(...),
[self::class,'parseWidget'],
null,
__('Theme switcher')
)
@ -39,13 +41,13 @@ class Widgets
public static function parseWidget(WidgetsElement $w): string
{
if ($w->offline || !$w->checkHomeOnly(App::url()->type)) {
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
return '';
}
$model = json_decode((string) My::settings()->get('model'), true);
$exclude = explode(';', (string) My::settings()->get('exclude'));
$modules = array_diff_key(App::themes()->getDefines(['state' => ModuleDefine::STATE_ENABLED], true), array_flip($exclude));
$modules = array_diff_key(dcCore::app()->themes->getDefines(['state' => dcModuleDefine::STATE_ENABLED], true), array_flip($exclude));
if (!is_array($model) || empty($modules)) {
return '';
}
@ -68,8 +70,7 @@ class Widgets
$res = '';
foreach ($modules as $id => $module) {
$id = (string) $id;
if ($id == App::frontend()->theme) {
if ($id == dcCore::app()->public->theme) {
$format = $model['a_html'];
} else {
$format = $model['e_html'];