release 2.3

This commit is contained in:
Jean-Christian Denis 2023-07-29 23:29:53 +02:00
parent 2ab69d7d67
commit 55e39afceb
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
11 changed files with 71 additions and 112 deletions

View file

@ -1,3 +1,9 @@
2.3 - 2023.07.29
* require Dotclear 2.27
* require PHP 7.4+
* use new svg icon
* update to Dotclear 2.27-dev
2.2.1 - 2023.05.13 2.2.1 - 2023.05.13
* require dotclear 2.26 * require dotclear 2.26
* cleanup for dc2.26 stable * cleanup for dc2.26 stable

View file

@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/moreCSS)](https://github.com/JcDenis/moreCSS/releases) [![Release](https://img.shields.io/github/v/release/JcDenis/moreCSS)](https://github.com/JcDenis/moreCSS/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/moreCSS)](https://github.com/JcDenis/moreCSS/releases) [![Date](https://img.shields.io/github/release-date/JcDenis/moreCSS)](https://github.com/JcDenis/moreCSS/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/moreCSS)](https://github.com/JcDenis/moreCSS/issues) [![Issues](https://img.shields.io/github/issues/JcDenis/moreCSS)](https://github.com/JcDenis/moreCSS/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download) [![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/moreCSS) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/moreCSS)
[![License](https://img.shields.io/github/license/JcDenis/moreCSS)](https://github.com/JcDenis/moreCSS/blob/master/LICENSE) [![License](https://img.shields.io/github/license/JcDenis/moreCSS)](https://github.com/JcDenis/moreCSS/blob/master/LICENSE)
@ -19,8 +19,9 @@ without editing it.
_moreCSS_ requires: _moreCSS_ requires:
* content admin permissions to manage CSS * content admin permissions to manage CSS
* Dotclear 2.26 * Dotclear 2.27
* PHP 7.4+
## USAGE ## USAGE

View file

@ -10,7 +10,7 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian 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') || is_null(dcCore::app()->auth)) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -18,9 +18,9 @@ $this->registerModule(
'Style sheet', 'Style sheet',
'Another CSS stylesheet for the active theme', 'Another CSS stylesheet for the active theme',
'Osku and contributors', 'Osku and contributors',
'2.2.1', '2.3',
[ [
'requires' => [['core', '2.26']], 'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([ 'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]), ]),

View file

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="moreCSS"> <module id="moreCSS">
<name>Style sheet</name> <name>Style sheet</name>
<version>2.2.1</version> <version>2.3</version>
<author>Osku and contributors</author> <author>Osku and contributors</author>
<desc>Another CSS stylesheet for the active theme</desc> <desc>Another CSS stylesheet for the active theme</desc>
<file>https://github.com/JcDenis/moreCSS/releases/download/v2.2.1/plugin-moreCSS.zip</file> <file>https://github.com/JcDenis/moreCSS/releases/download/v2.3/plugin-moreCSS.zip</file>
<da:dcmin>2.26</da:dcmin> <da:dcmin>2.27</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/moreCSS</da:details> <da:details>https://plugins.dotaddict.org/dc2/details/moreCSS</da:details>
<da:support>http://forum.dotclear.org/viewtopic.php?id=44908</da:support> <da:support>http://forum.dotclear.org/viewtopic.php?id=44908</da:support>
</module> </module>

View file

@ -14,44 +14,34 @@ declare(strict_types=1);
namespace Dotclear\Plugin\moreCSS; namespace Dotclear\Plugin\moreCSS;
use dcAdmin;
use dcCore; use dcCore;
use dcFavorites; use Dotclear\Core\Process;
use dcNsProcess; use Dotclear\Core\Backend\{
use dcPage; Favorites,
Menus
};
class Backend extends dcNsProcess class Backend extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN'); return self::status(My::checkContext(My::BACKEND));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init || is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) { if (!self::status()) {
return false; return false;
} }
dcCore::app()->menu[dcAdmin::MENU_BLOG]->addItem( My::addBackendMenuItem(Menus::MENU_BLOG);
My::name(),
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
[dcPage::getPF(My::id() . '/icon.svg')],
preg_match('/' . preg_quote((string) dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)
);
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void { dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void {
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
return;
}
$favs->register(My::id(), [ $favs->register(My::id(), [
'title' => My::name(), 'title' => My::name(),
'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()), 'url' => My::manageUrl(),
'small-icon' => [dcPage::getPF(My::id() . '/icon.svg')], 'small-icon' => My::icons(),
'large-icon' => [dcPage::getPF(My::id() . '/icon.svg')], 'large-icon' => My::icons(),
'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), 'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]),
]); ]);
}); });

View file

@ -15,28 +15,23 @@ declare(strict_types=1);
namespace Dotclear\Plugin\moreCSS; namespace Dotclear\Plugin\moreCSS;
use dcCore; use dcCore;
use dcNsProcess;
use dcUtils; use dcUtils;
use Dotclear\Core\Process;
class Frontend extends dcNsProcess class Frontend extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_RC_PATH'); return self::status(My::checkContext(My::FRONTEND));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init || is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get('themes')->get('morecss_active')) { if (!self::status() || !dcCore::app()->blog->settings->get('themes')->get('morecss_active')) {
return false; return false;
} }
dcCore::app()->addBehavior('publicHeadContent', function (): void { dcCore::app()->addBehavior('publicHeadContent', function (): void {
if (is_null(dcCore::app()->blog)) {
return;
}
$css = (string) base64_decode((string) dcCore::app()->blog->settings->get('themes')->get('morecss_min')); $css = (string) base64_decode((string) dcCore::app()->blog->settings->get('themes')->get('morecss_min'));
if (!empty($css)) { if (!empty($css)) {
echo dcUtils::cssLoad( echo dcUtils::cssLoad(

View file

@ -15,22 +15,19 @@ declare(strict_types=1);
namespace Dotclear\Plugin\moreCSS; namespace Dotclear\Plugin\moreCSS;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use Exception; use Exception;
class Install extends dcNsProcess class Install extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN') return self::status(My::checkContext(My::INSTALL));
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init || is_null(dcCore::app()->blog)) { if (!self::status() || is_null(dcCore::app()->blog)) {
return false; return false;
} }

View file

@ -15,8 +15,11 @@ declare(strict_types=1);
namespace Dotclear\Plugin\moreCSS; namespace Dotclear\Plugin\moreCSS;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use dcPage; use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Checkbox, Checkbox,
Form, Form,
@ -29,22 +32,16 @@ use Dotclear\Helper\Html\Form\{
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Exception; use Exception;
class Manage extends dcNsProcess class Manage extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN') return self::status(My::checkContext(My::MANAGE));
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog)
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id);
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) { if (!self::status()) {
return false; return false;
} }
@ -68,12 +65,10 @@ class Manage extends dcNsProcess
$css_min = str_replace([' , ', ' ,', ', '], ',', $css_min); $css_min = str_replace([' , ', ' ,', ', '], ',', $css_min);
$s->put('morecss_min', base64_encode($css_min)); $s->put('morecss_min', base64_encode($css_min));
dcPage::addSuccessNotice( Notices::addSuccessNotice(
__('Configuration successfully updated.') __('Configuration successfully updated.')
); );
dcCore::app()->adminurl->redirect( My::redirect();
'admin.plugin.' . My::id()
);
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
@ -84,28 +79,28 @@ class Manage extends dcNsProcess
public static function render(): void public static function render(): void
{ {
if (!static::$init || is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs) || is_null(dcCore::app()->blog)) { if (!self::status()) {
return; return;
} }
$s = dcCore::app()->blog->settings->get('themes'); $s = dcCore::app()->blog->settings->get('themes');
dcPage::openModule( Page::openModule(
My::name(), My::name(),
( (
dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax') ? dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax') ?
dcPage::jsJson('dotclear_colorsyntax', ['colorsyntax' => dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')]) . Page::jsJson('dotclear_colorsyntax', ['colorsyntax' => dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')]) .
dcPage::jsLoadCodeMirror(dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme')) Page::jsLoadCodeMirror(dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme'))
: '' : ''
) )
); );
echo echo
dcPage::breadcrumb([ Page::breadcrumb([
Html::escapeHTML(dcCore::app()->blog->name) => '', Html::escapeHTML(dcCore::app()->blog->name) => '',
My::name() => '', My::name() => '',
]) . ]) .
dcPage::notices() . Notices::getNotices() .
(new Form('file-form'))->method('post')->action(dcCore::app()->admin->getPageURL())->fields([ (new Form('file-form'))->method('post')->action(dcCore::app()->admin->getPageURL())->fields([
(new Para())->items([ (new Para())->items([
@ -125,11 +120,11 @@ class Manage extends dcNsProcess
if (dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')) { if (dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax')) {
echo echo
dcPage::jsJson('theme_editor_mode', ['mode' => 'css']) . Page::jsJson('theme_editor_mode', ['mode' => 'css']) .
dcPage::jsModuleLoad('themeEditor/js/mode.js') . Page::jsLoad(dcCore::app()->blog->getPF('themeEditor/js/mode.js')) .
dcPage::jsRunCodeMirror('editor', 'morecss', 'dotclear', dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme')); Page::jsRunCodeMirror('editor', 'morecss', 'dotclear', dcCore::app()->auth->user_prefs->get('interface')->get('colorsyntax_theme'));
} }
dcPage::closeModule(); Page::closeModule();
} }
} }

View file

@ -15,35 +15,17 @@ declare(strict_types=1);
namespace Dotclear\Plugin\moreCSS; namespace Dotclear\Plugin\moreCSS;
use dcCore; use dcCore;
use Dotclear\Module\MyPlugin;
/** /**
* This module definitions. * This module definitions.
*/ */
class My class My extends MyPlugin
{ {
/** public static function checkCustomContext(int $context): ?bool
* This module id.
*/
public static function id(): string
{ {
return basename(dirname(__DIR__)); return in_array($context, [My::BACKEND, My::MENU]) ?
} dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)
: null;
/**
* This module name.
*/
public static function name(): string
{
$name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
return __(is_string($name) ? $name : self::id());
}
/**
* This module path.
*/
public static function path(): string
{
return dirname(__DIR__);
} }
} }

View file

@ -15,20 +15,18 @@ declare(strict_types=1);
namespace Dotclear\Plugin\moreCSS; namespace Dotclear\Plugin\moreCSS;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
class Prepend extends dcNsProcess class Prepend extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_RC_PATH'); return self::status(My::checkContext(My::PREPEND));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }
@ -37,9 +35,6 @@ class Prepend extends dcNsProcess
'morecss.css', 'morecss.css',
'^morecss\.css(.*?)$', '^morecss\.css(.*?)$',
function (string $args): void { function (string $args): void {
if (is_null(dcCore::app()->blog)) {
return;
}
header('Content-Type: text/css; charset=UTF-8'); header('Content-Type: text/css; charset=UTF-8');
echo "/* CSS for plugin moreCss */ \n"; echo "/* CSS for plugin moreCss */ \n";

View file

@ -15,21 +15,19 @@ declare(strict_types=1);
namespace Dotclear\Plugin\moreCSS; namespace Dotclear\Plugin\moreCSS;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller; use Dotclear\Plugin\Uninstaller\Uninstaller;
class Uninstall extends dcNsProcess class Uninstall extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN'); return self::status(My::checkContext(My::UNINSTALL));
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) { if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
return false; return false;
} }