Compare commits
2 Commits
dc477014c7
...
0f5601e66d
Author | SHA1 | Date |
---|---|---|
Jean-Christian Paul Denis | 0f5601e66d | |
Jean-Christian Paul Denis | db52b2d87f |
27
CHANGELOG.md
27
CHANGELOG.md
|
@ -1,17 +1,25 @@
|
|||
todo
|
||||
* disable widgets
|
||||
construction 1.8 - 2023.08.06
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
* Require PHP 7.4+
|
||||
* Upgrade to Dotclear 2.27
|
||||
* Move third party repository
|
||||
* Use Dotclear style for changelog
|
||||
|
||||
1.7 - 2023.05.13
|
||||
construction 1.7 - 2023.05.13
|
||||
===========================================================
|
||||
* require dotclear 2.26
|
||||
* fix editor ID
|
||||
* fix nullsafe warnings
|
||||
* add plugin Unnistaller features
|
||||
|
||||
1.6 - 2023.04.10
|
||||
construction 1.6 - 2023.04.10
|
||||
===========================================================
|
||||
* require dotclear 2.26
|
||||
* use namespace
|
||||
|
||||
1.5 - 2022.12.31
|
||||
construction 1.5 - 2022.12.31
|
||||
===========================================================
|
||||
* update to dotclear 2.24
|
||||
* use json intead of serialize
|
||||
* use short settings names
|
||||
|
@ -19,13 +27,16 @@ todo
|
|||
* use abstract plugin id
|
||||
* fix phpstan and php-cs-fixer errors
|
||||
|
||||
v1.4 - 20-12-2022 - Pierre Van Glebeke
|
||||
construction 1.4 - 20-12-2022 - Pierre Van Glebeke
|
||||
===========================================================
|
||||
* màj partielle dc2.24
|
||||
|
||||
v1.3.1 - 18/02/2018 - Pierre Van Glebeke
|
||||
construction 1.3.1 - 18/02/2018 - Pierre Van Glebeke
|
||||
===========================================================
|
||||
* modif icon
|
||||
|
||||
v1.3 - 19/02/2015 - Pierre Van Glebeke
|
||||
construction 1.3 - 19/02/2015 - Pierre Van Glebeke
|
||||
===========================================================
|
||||
* cosmétique dc2.6
|
||||
* jeux mustek et currywurst
|
||||
* localisation
|
||||
|
|
16
README.md
16
README.md
|
@ -1,11 +1,11 @@
|
|||
# README
|
||||
|
||||
[![Release](https://img.shields.io/github/v/release/JcDenis/construction)](https://github.com/JcDenis/construction/releases)
|
||||
[![Date](https://img.shields.io/github/release-date/JcDenis/construction)](https://github.com/JcDenis/construction/releases)
|
||||
[![Issues](https://img.shields.io/github/issues/JcDenis/construction)](https://github.com/JcDenis/construction/issues)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
|
||||
[![Release](https://img.shields.io/github/v/release/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/releases)
|
||||
[![Date](https://img.shields.io/github/release-date/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/releases)
|
||||
[![Issues](https://img.shields.io/github/issues/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/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/construction)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/construction)](https://github.com/JcDenis/construction/blob/master/LICENSE)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/blob/master/LICENSE)
|
||||
|
||||
## WHAT IS DISCLAIMER ?
|
||||
|
||||
|
@ -20,7 +20,7 @@ Blog can be accessible to defined IP addresses.
|
|||
_construction_ requires:
|
||||
|
||||
* admin permissions on blog
|
||||
* Dotclear 2.26
|
||||
* Dotclear 2.27
|
||||
|
||||
## USAGE
|
||||
|
||||
|
@ -32,8 +32,8 @@ You can activate and setup _construction_ from sidebar menu "Construction".
|
|||
## LINKS
|
||||
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [GitHub Page](https://github.com/JcDenis/construction)
|
||||
* Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/construction)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/construction) or [GitHub Page](https://github.com/JcDenis/construction)
|
||||
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/construction/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/construction)
|
||||
* Help & discuss : [Dotclear forum](http://forum.dotclear.org/viewtopic.php?id=42875)
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
|
10
_define.php
10
_define.php
|
@ -18,16 +18,16 @@ $this->registerModule(
|
|||
'Construction',
|
||||
'Place your blog maintenance',
|
||||
'Osku and contributors',
|
||||
'1.7',
|
||||
'1.8',
|
||||
[
|
||||
'requires' => [['core', '2.26']],
|
||||
'requires' => [['core', '2.27']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
]),
|
||||
'priority' => 2000,
|
||||
'type' => 'plugin',
|
||||
'support' => 'http://forum.dotclear.org/viewtopic.php?id=42875',
|
||||
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
|
||||
'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',
|
||||
]
|
||||
);
|
||||
|
|
10
dcstore.xml
10
dcstore.xml
|
@ -2,12 +2,12 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="construction">
|
||||
<name>Construction</name>
|
||||
<version>1.7</version>
|
||||
<version>1.8</version>
|
||||
<author>Osku and contributors</author>
|
||||
<desc>Place your blog maintenance</desc>
|
||||
<file>https://github.com/JcDenis/construction/releases/download/v1.7/plugin-construction.zip</file>
|
||||
<da:dcmin>2.26</da:dcmin>
|
||||
<da:details>https://plugins.dotaddict.org/dc2/details/construction</da:details>
|
||||
<da:support>http://forum.dotclear.org/viewtopic.php?id=42875</da:support>
|
||||
<file>https://gitea.dotclear.watch/JcDenis/construction/releases/download/v1.8/plugin-construction.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/construction/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/construction/issues</da:support>
|
||||
</module>
|
||||
</modules>
|
||||
|
|
|
@ -14,65 +14,40 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\construction;
|
||||
|
||||
use dcAdmin;
|
||||
use dcCore;
|
||||
use dcPage;
|
||||
use dcFavorites;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Backend\{
|
||||
Favorites,
|
||||
Menus
|
||||
};
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
class Backend extends dcNsProcess
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) // nullsafe PHP < 8.0
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id);
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::BACKEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
My::name(),
|
||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
||||
dcPage::getPF(My::id() . '/icon.svg'),
|
||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]), dcCore::app()->blog->id),
|
||||
dcCore::app()->blog->settings->get(My::id())->get('flag') ? 'construction-blog' : ''
|
||||
);
|
||||
My::addBackendMenuItem(Menus::MENU_PLUGINS, [], '(&.*)?$', My::settings()->get('flag') ? 'construction-blog' : '');
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminPageHTMLHead' => function (): void {
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
if (dcCore::app()->blog->settings->get(My::id())->get('flag')) {
|
||||
echo dcPage::cssModuleLoad(My::id() . '/css/backend.css');
|
||||
if (My::settings()->get('flag')) {
|
||||
echo My::cssLoad('backend');
|
||||
}
|
||||
},
|
||||
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
|
||||
return;
|
||||
}
|
||||
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
||||
$favs->register(My::id(), [
|
||||
'title' => My::name(),
|
||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
||||
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||
'url' => My::manageUrl(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]),
|
||||
]);
|
||||
},
|
||||
|
|
|
@ -16,32 +16,30 @@ namespace Dotclear\Plugin\construction;
|
|||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Network\Http;
|
||||
use Exception;
|
||||
|
||||
class Frontend extends dcNsProcess
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_RC_PATH');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::FRONTEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehavior('publicBeforeDocument', function (): void {
|
||||
dcCore::app()->addBehavior('publicBeforeDocumentV2', function (): void {
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dcCore::app()->blog->settings->get(My::id())->get('flag')) {
|
||||
if (!My::settings()->get('flag')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -52,11 +50,11 @@ class Frontend extends dcNsProcess
|
|||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', DC_DEFAULT_TPLSET]));
|
||||
}
|
||||
|
||||
$all_allowed_ip = json_decode(dcCore::app()->blog->settings->get(My::id())->get('allowed_ip'), true);
|
||||
$all_allowed_ip = json_decode((string) My::settings()->get('allowed_ip'), true);
|
||||
if (!is_array($all_allowed_ip)) {
|
||||
$all_allowed_ip = [];
|
||||
}
|
||||
$extra_urls = json_decode(dcCore::app()->blog->settings->get(My::id())->get('extra_urls'), true);
|
||||
$extra_urls = json_decode((string) My::settings()->get('extra_urls'), true);
|
||||
if (!in_array(Http::realIP(), $all_allowed_ip)) {
|
||||
dcCore::app()->url->registerDefault(function (?string $args): void {
|
||||
dcCore::app()->url->type = 'default';
|
||||
|
@ -77,7 +75,7 @@ class Frontend extends dcNsProcess
|
|||
|
||||
echo dcCore::app()->tpl->getData(dcCore::app()->ctx->__get('current_tpl'));
|
||||
|
||||
# --BEHAVIOR-- publicAfterDocument
|
||||
# --BEHAVIOR-- publicAfterDocumentV2
|
||||
dcCore::app()->callBehavior('publicAfterDocumentV2');
|
||||
exit;
|
||||
});
|
||||
|
|
|
@ -15,32 +15,24 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\construction;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Exception;
|
||||
|
||||
class Install extends dcNsProcess
|
||||
class Install extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::INSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$s = dcCore::app()->blog->settings->get(My::id());
|
||||
$s = My::settings();
|
||||
|
||||
$s->put(
|
||||
'flag',
|
||||
|
|
|
@ -14,10 +14,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\construction;
|
||||
|
||||
use dcAuth;
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcPage;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
};
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
|
@ -35,31 +37,25 @@ use Dotclear\Helper\Html\Html;
|
|||
use Dotclear\Helper\Network\Http;
|
||||
use Exception;
|
||||
|
||||
class Manage extends dcNsProcess
|
||||
class Manage extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) // nullsafe PHP < 8.0
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]), dcCore::app()->blog->id);
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::MANAGE));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$s = dcCore::app()->blog->settings->get(My::id());
|
||||
$s = My::settings();
|
||||
|
||||
if (!empty($_POST['saveconfig'])) {
|
||||
try {
|
||||
|
@ -80,13 +76,11 @@ class Manage extends dcNsProcess
|
|||
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
|
||||
dcPage::addSuccessNotice(
|
||||
Notices::addSuccessNotice(
|
||||
__('Settings successfully updated.')
|
||||
);
|
||||
|
||||
dcCore::app()->adminurl->redirect(
|
||||
'admin.plugin.' . My::id()
|
||||
);
|
||||
My::redirect();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
@ -97,16 +91,16 @@ class Manage extends dcNsProcess
|
|||
|
||||
public static function render(): void
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$s = dcCore::app()->blog->settings->get(My::id());
|
||||
$s = My::settings();
|
||||
$editor = dcCore::app()->auth->getOption('editor');
|
||||
$nb_rows = count(json_decode($s->get('allowed_ip'), true));
|
||||
if ($nb_rows < 2) {
|
||||
|
@ -115,22 +109,22 @@ class Manage extends dcNsProcess
|
|||
$nb_rows = 10;
|
||||
}
|
||||
|
||||
dcPage::openModule(
|
||||
Page::openModule(
|
||||
My::name(),
|
||||
dcPage::jsConfirmClose('opts-forms') .
|
||||
Page::jsConfirmClose('opts-forms') .
|
||||
dcCore::app()->callBehavior('adminPostEditor', $editor['xhtml'], 'construction', ['#construction_message'], 'xhtml') .
|
||||
dcPage::jsModuleLoad(My::id() . '/js/backend.js')
|
||||
Page::jsLoad('backend')
|
||||
);
|
||||
|
||||
echo
|
||||
dcPage::breadcrumb([
|
||||
Page::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
My::name() => '',
|
||||
]) .
|
||||
dcPage::notices() .
|
||||
Notices::getNotices() .
|
||||
|
||||
(new Div())->id('construction_options')->items([
|
||||
(new Form(My::id() . 'form'))->method('post')->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()))->fields([
|
||||
(new Form(My::id() . 'form'))->method('post')->action(My::manageUrl())->fields([
|
||||
(new Div())->class('fieldset')->items([
|
||||
(new Text('h4', __('Configuration'))),
|
||||
(new Para())->class('filed')->items([
|
||||
|
@ -159,13 +153,12 @@ class Manage extends dcNsProcess
|
|||
]),
|
||||
]),
|
||||
(new Para())->items([
|
||||
dcCore::app()->formNonce(false),
|
||||
(new Hidden(['p'], 'construction')),
|
||||
(new Submit(['saveconfig']))->value(__('Save')),
|
||||
... My::hiddenFields(),
|
||||
]),
|
||||
]),
|
||||
])->render();
|
||||
|
||||
dcPage::closeModule();
|
||||
Page::closeModule();
|
||||
}
|
||||
}
|
||||
|
|
29
src/My.php
29
src/My.php
|
@ -14,36 +14,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\construction;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
*/
|
||||
class My
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/**
|
||||
* This module id.
|
||||
*/
|
||||
public static function id(): string
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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__);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,21 +15,19 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\construction;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
class Uninstall extends dcNsProcess
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::UNINSTALL));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue