upgrade to Dotclear 2.28
This commit is contained in:
parent
58cde86263
commit
53e4a8ee58
12 changed files with 145 additions and 146 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
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
|
arlequin 2.4 - 2023.09.04
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.27
|
* Require Dotclear 2.27
|
||||||
|
|
12
README.md
12
README.md
|
@ -1,8 +1,8 @@
|
||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-2.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/arlequin/releases)
|
[![Release](https://img.shields.io/badge/release-2.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/arlequin/releases)
|
||||||
![Date](https://img.shields.io/badge/date-2023.09.04-c44d58.svg)]
|
![Date](https://img.shields.io/badge/date-2023.10.15-c44d58.svg)]
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
[![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)
|
[![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)
|
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/arlequin/src/branch/master/LICENSE)
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ _arlequin_ is a plugin for the open-source web publishing software called [Dotcl
|
||||||
|
|
||||||
## REQUIREMENTS
|
## REQUIREMENTS
|
||||||
|
|
||||||
|
* Dotclear 2.28
|
||||||
|
* PHP 8.1+
|
||||||
* Dotclear content admin permissions to manage theme and public menu
|
* Dotclear content admin permissions to manage theme and public menu
|
||||||
* Dotclear 2.27
|
|
||||||
* PHP 7.4+
|
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
@ -40,6 +40,6 @@ you should also add widget to allow visitor to select a theme.
|
||||||
* Oleksandr Syenchuk (author)
|
* Oleksandr Syenchuk (author)
|
||||||
* Gaetan Guillard
|
* Gaetan Guillard
|
||||||
* Pierre Van Glabeke
|
* Pierre Van Glabeke
|
||||||
* Jean-Christian Denis
|
* Jean-Christian Denis (latest)
|
||||||
|
|
||||||
You are welcome to contribute to this code.
|
You are welcome to contribute to this code.
|
||||||
|
|
34
_define.php
34
_define.php
|
@ -1,32 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @brief arlequin, a plugin for Dotclear 2
|
* @file
|
||||||
|
* @brief The plugin arlequin definition
|
||||||
|
* @ingroup arlequin
|
||||||
*
|
*
|
||||||
* @package Dotclear
|
* @defgroup arlequin Plugin arlequin.
|
||||||
* @subpackage Plugin
|
|
||||||
*
|
*
|
||||||
* @author Oleksandr Syenchuk, Pierre Van Glabeke and contributors
|
* Allows visitors choose a theme.
|
||||||
*
|
*
|
||||||
* @copyright Jean-Christian Denis
|
* @author Oleksandr Syenchuk (author)
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @author Jean-Christian Denis (latest)
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
declare(strict_types=1);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
'Arlequin',
|
'Arlequin',
|
||||||
'Allows visitors choose a theme',
|
'Allows visitors choose a theme',
|
||||||
'Oleksandr Syenchuk, Pierre Van Glabeke and contributors',
|
'Oleksandr Syenchuk, Pierre Van Glabeke and contributors',
|
||||||
'2.4',
|
'2.5',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.27']],
|
'requires' => [['core', '2.28']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => 'My',
|
||||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
'type' => 'plugin',
|
||||||
]),
|
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||||
'type' => 'plugin',
|
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||||
'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',
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="arlequin">
|
<module id="arlequin">
|
||||||
<name>Arlequin</name>
|
<name>Arlequin</name>
|
||||||
<version>2.4</version>
|
<version>2.5</version>
|
||||||
<author>Oleksandr Syenchuk, Pierre Van Glabeke and contributors</author>
|
<author>Oleksandr Syenchuk, Pierre Van Glabeke and contributors</author>
|
||||||
<desc>Allows visitors choose a theme</desc>
|
<desc>Allows visitors choose a theme</desc>
|
||||||
<file>https://git.dotclear.watch/JcDenis/arlequin/releases/download/v2.4/plugin-arlequin.zip</file>
|
<file>https://git.dotclear.watch/JcDenis/arlequin/releases/download/v2.5/plugin-arlequin.zip</file>
|
||||||
<da:dcmin>2.27</da:dcmin>
|
<da:dcmin>2.28</da:dcmin>
|
||||||
<da:details>https://git.dotclear.watch/JcDenis/arlequin/src/branch/master/README.md</da:details>
|
<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>
|
<da:support>https://git.dotclear.watch/JcDenis/arlequin/issues</da:support>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -10,8 +10,4 @@
|
||||||
* @copyright Jean-Crhistian Denis
|
* @copyright Jean-Crhistian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
\Dotclear\App::backend()->resources()->set('help', 'arlequin', __DIR__ . '/help/arlequin.html');
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dcCore::app()->resources['help']['arlequin'] = __DIR__ . '/help/arlequin.html';
|
|
||||||
|
|
|
@ -10,8 +10,4 @@
|
||||||
* @copyright Jean-Crhistian Denis
|
* @copyright Jean-Crhistian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
\Dotclear\App::backend()->resources()->set('help', 'arlequin', __DIR__ . '/help/arlequin.html');
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dcCore::app()->resources['help']['arlequin'] = __DIR__ . '/help/arlequin.html';
|
|
||||||
|
|
|
@ -1,26 +1,21 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\arlequin;
|
namespace Dotclear\Plugin\arlequin;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Core\Backend\{
|
use Dotclear\Core\Backend\Favorites;
|
||||||
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
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -34,21 +29,21 @@ class Backend extends Process
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
My::addBackendMenuItem(Menus::MENU_BLOG);
|
My::addBackendMenuItem(App::backend()->menus()::MENU_BLOG);
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
App::behavior()->addBehaviors([
|
||||||
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
||||||
$favs->register(My::id(), [
|
$favs->register(My::id(), [
|
||||||
'title' => My::name(),
|
'title' => My::name(),
|
||||||
'url' => My::manageUrl(),
|
'url' => My::manageUrl(),
|
||||||
'small-icon' => My::icons(),
|
'small-icon' => My::icons(),
|
||||||
'large-icon' => My::icons(),
|
'large-icon' => My::icons(),
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => App::auth()->makePermissions([
|
||||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
# 'initWidgets' => Widgets::initWidgets(...),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,26 +1,35 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\arlequin;
|
namespace Dotclear\Plugin\arlequin;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Helper\Network\Http;
|
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
|
class Frontend extends Process
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The arlequin theme cookie.
|
||||||
|
*
|
||||||
|
* @var string COOKIE_THEME_PREFIX
|
||||||
|
*/
|
||||||
public const COOKIE_THEME_PREFIX = 'dc_theme_';
|
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 const COOKIE_UPDDT_PREFIX = 'dc_user_upddt_';
|
||||||
|
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -50,9 +59,9 @@ class Frontend extends Process
|
||||||
self::switchTheme($_COOKIE[self::COOKIE_THEME_PREFIX . self::cookieSuffix()]);
|
self::switchTheme($_COOKIE[self::COOKIE_THEME_PREFIX . self::cookieSuffix()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
App::behavior()->addBehaviors([
|
||||||
'publicBeforeDocumentV2' => [self::class, 'adjustCache'],
|
'publicBeforeDocumentV2' => self::adjustCache(...),
|
||||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
# 'initWidgets' => Widgets::initWidgets(...),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -60,19 +69,19 @@ class Frontend extends Process
|
||||||
|
|
||||||
protected static function cookieSuffix(): string
|
protected static function cookieSuffix(): string
|
||||||
{
|
{
|
||||||
return base_convert(dcCore::app()->blog->uid, 16, 36);
|
return base_convert(App::blog()->uid(), 16, 36);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function adjustCache(): void
|
public static function adjustCache(): void
|
||||||
{
|
{
|
||||||
if (!empty($_COOKIE[self::COOKIE_UPDDT_PREFIX . self::cookieSuffix()])) {
|
if (!empty($_COOKIE[self::COOKIE_UPDDT_PREFIX . self::cookieSuffix()])) {
|
||||||
dcCore::app()->cache['mod_ts'][] = (int) $_COOKIE[self::COOKIE_UPDDT_PREFIX . self::cookieSuffix()];
|
App::frontend()->cache()->addTime((int) $_COOKIE[self::COOKIE_UPDDT_PREFIX . self::cookieSuffix()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function switchTheme(string $theme): void
|
public static function switchTheme(string $theme): void
|
||||||
{
|
{
|
||||||
if (dcCore::app()->blog->settings->get('system')->get('theme') == $theme) {
|
if (App::blog()->settings()->get('system')->get('theme') == $theme) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +91,7 @@ class Frontend extends Process
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->blog->settings->get('system')->set('theme', $theme);
|
App::blog()->settings()->get('system')->set('theme', $theme);
|
||||||
dcCore::app()->public->theme = $theme;
|
App::frontend()->theme = $theme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,11 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\arlequin;
|
namespace Dotclear\Plugin\arlequin;
|
||||||
|
|
||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Core\Backend\{
|
use Dotclear\Core\Backend\{
|
||||||
Notices,
|
Notices,
|
||||||
|
@ -35,6 +25,14 @@ use Dotclear\Helper\Html\Form\{
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Exception;
|
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
|
class Manage extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -62,7 +60,7 @@ class Manage extends Process
|
||||||
$s->put('exclude', 'customCSS', 'string', 'Excluded themes');
|
$s->put('exclude', 'customCSS', 'string', 'Excluded themes');
|
||||||
|
|
||||||
Notices::AddSuccessNotice(__('Settings have been reinitialized.'));
|
Notices::AddSuccessNotice(__('Settings have been reinitialized.'));
|
||||||
dcCore::app()->blog->triggerBlog();
|
App::blog()->triggerBlog();
|
||||||
}
|
}
|
||||||
|
|
||||||
// collect settings
|
// collect settings
|
||||||
|
@ -79,7 +77,7 @@ class Manage extends Process
|
||||||
$s->put('exclude', $exclude);
|
$s->put('exclude', $exclude);
|
||||||
|
|
||||||
Notices::AddSuccessNotice(__('System settings have been updated.'));
|
Notices::AddSuccessNotice(__('System settings have been updated.'));
|
||||||
dcCore::app()->blog->triggerBlog();
|
App::blog()->triggerBlog();
|
||||||
My::redirect(['config' => 1]);
|
My::redirect(['config' => 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,11 +87,11 @@ class Manage extends Process
|
||||||
$s->drop('exclude');
|
$s->drop('exclude');
|
||||||
|
|
||||||
Notices::AddSuccessNotice(__('Settings have been reinitialized.'));
|
Notices::AddSuccessNotice(__('Settings have been reinitialized.'));
|
||||||
dcCore::app()->blog->triggerBlog();
|
App::blog()->triggerBlog();
|
||||||
My::redirect(['restore' => 1]);
|
My::redirect(['restore' => 1]);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
App::error()->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -107,7 +105,7 @@ class Manage extends Process
|
||||||
|
|
||||||
$models = new ArrayObject(My::distributedModels());
|
$models = new ArrayObject(My::distributedModels());
|
||||||
|
|
||||||
dcCore::app()->callBehavior('arlequinAddModels', $models);
|
App::behavior()->callBehavior('arlequinAddModels', $models);
|
||||||
|
|
||||||
$models = iterator_to_array($models);
|
$models = iterator_to_array($models);
|
||||||
$s = My::settings();
|
$s = My::settings();
|
||||||
|
@ -144,12 +142,12 @@ class Manage extends Process
|
||||||
|
|
||||||
echo
|
echo
|
||||||
Page::breadcrumb([
|
Page::breadcrumb([
|
||||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
Html::escapeHTML(App::blog()->name()) => '',
|
||||||
My::name() => '',
|
My::name() => '',
|
||||||
]) .
|
]) .
|
||||||
Notices::getNotices() .
|
Notices::getNotices() .
|
||||||
|
|
||||||
(new Form(My::id() . 'form'))->method('post')->action(dcCore::app()->admin->getPageURL())->fields([
|
(new Form(My::id() . 'form'))->method('post')->action(App::backend()->getPageURL())->fields([
|
||||||
(new Text('h4', __('Switcher display format'))),
|
(new Text('h4', __('Switcher display format'))),
|
||||||
(new Div())->id('models'),
|
(new Div())->id('models'),
|
||||||
(new Div())->class('two-boxes odd')->items([
|
(new Div())->class('two-boxes odd')->items([
|
||||||
|
|
41
src/My.php
41
src/My.php
|
@ -1,34 +1,32 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\arlequin;
|
namespace Dotclear\Plugin\arlequin;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Module\MyPlugin;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module definitions.
|
* @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
|
||||||
*/
|
*/
|
||||||
class My extends MyPlugin
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
public static function checkCustomContext(int $context): ?bool
|
public static function checkCustomContext(int $context): ?bool
|
||||||
{
|
{
|
||||||
return !in_array($context, [My::BACKEND, My::MANAGE, My::MENU]) ? null :
|
return match ($context) {
|
||||||
defined('DC_CONTEXT_ADMIN')
|
self::BACKEND, self::MANAGE, self::MENU => App::task()->checkContext('BACKEND')
|
||||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
&& App::auth()->check(App::auth()->makePermissions([
|
||||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||||
]), dcCore::app()->blog->id);
|
]), App::blog()->id()),
|
||||||
|
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,6 +39,8 @@ class My extends MyPlugin
|
||||||
* 'e_html'=>'[HTML code]', // Code HTML d'un item pouvant être sélectionné
|
* '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é)
|
* '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
|
public static function distributedModels(): array
|
||||||
{
|
{
|
||||||
|
@ -65,6 +65,11 @@ class My extends MyPlugin
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get default models.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
public static function defaultModel(): array
|
public static function defaultModel(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\arlequin;
|
namespace Dotclear\Plugin\arlequin;
|
||||||
|
|
||||||
use dcCore;
|
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
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
|
class Uninstall extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
|
@ -27,7 +24,7 @@ class Uninstall extends Process
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
<?php
|
<?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);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\arlequin;
|
namespace Dotclear\Plugin\arlequin;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use dcModuleDefine;
|
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Dotclear\Helper\Network\Http;
|
use Dotclear\Helper\Network\Http;
|
||||||
|
use Dotclear\Module\ModuleDefine;
|
||||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
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
|
class Widgets
|
||||||
{
|
{
|
||||||
public static function initWidgets(WidgetsStack $w): void
|
public static function initWidgets(WidgetsStack $w): void
|
||||||
|
@ -28,7 +26,7 @@ class Widgets
|
||||||
$w->create(
|
$w->create(
|
||||||
'arlequin',
|
'arlequin',
|
||||||
My::name(),
|
My::name(),
|
||||||
[self::class,'parseWidget'],
|
self::parseWidget(...),
|
||||||
null,
|
null,
|
||||||
__('Theme switcher')
|
__('Theme switcher')
|
||||||
)
|
)
|
||||||
|
@ -41,13 +39,13 @@ class Widgets
|
||||||
|
|
||||||
public static function parseWidget(WidgetsElement $w): string
|
public static function parseWidget(WidgetsElement $w): string
|
||||||
{
|
{
|
||||||
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
if ($w->offline || !$w->checkHomeOnly(App::url()->type)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$model = json_decode((string) My::settings()->get('model'), true);
|
$model = json_decode((string) My::settings()->get('model'), true);
|
||||||
$exclude = explode(';', (string) My::settings()->get('exclude'));
|
$exclude = explode(';', (string) My::settings()->get('exclude'));
|
||||||
$modules = array_diff_key(dcCore::app()->themes->getDefines(['state' => dcModuleDefine::STATE_ENABLED], true), array_flip($exclude));
|
$modules = array_diff_key(App::themes()->getDefines(['state' => ModuleDefine::STATE_ENABLED], true), array_flip($exclude));
|
||||||
if (!is_array($model) || empty($modules)) {
|
if (!is_array($model) || empty($modules)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -70,7 +68,8 @@ class Widgets
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
foreach ($modules as $id => $module) {
|
foreach ($modules as $id => $module) {
|
||||||
if ($id == dcCore::app()->public->theme) {
|
$id = (string) $id;
|
||||||
|
if ($id == App::frontend()->theme) {
|
||||||
$format = $model['a_html'];
|
$format = $model['a_html'];
|
||||||
} else {
|
} else {
|
||||||
$format = $model['e_html'];
|
$format = $model['e_html'];
|
||||||
|
|
Loading…
Reference in a new issue