Compare commits

..

No commits in common. "0f5601e66d88b6a1a51a8c4a8e6f4bc8987b455e" and "dc477014c7a0ee3ea8d6b67f9d1a9eedf6ab5269" have entirely different histories.

10 changed files with 153 additions and 95 deletions

View File

@ -1,25 +1,17 @@
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
todo
* disable widgets
construction 1.7 - 2023.05.13
===========================================================
1.7 - 2023.05.13
* require dotclear 2.26
* fix editor ID
* fix nullsafe warnings
* add plugin Unnistaller features
construction 1.6 - 2023.04.10
===========================================================
1.6 - 2023.04.10
* require dotclear 2.26
* use namespace
construction 1.5 - 2022.12.31
===========================================================
1.5 - 2022.12.31
* update to dotclear 2.24
* use json intead of serialize
* use short settings names
@ -27,16 +19,13 @@ construction 1.5 - 2022.12.31
* use abstract plugin id
* fix phpstan and php-cs-fixer errors
construction 1.4 - 20-12-2022 - Pierre Van Glebeke
===========================================================
v1.4 - 20-12-2022 - Pierre Van Glebeke
* màj partielle dc2.24
construction 1.3.1 - 18/02/2018 - Pierre Van Glebeke
===========================================================
v1.3.1 - 18/02/2018 - Pierre Van Glebeke
* modif icon
construction 1.3 - 19/02/2015 - Pierre Van Glebeke
===========================================================
v1.3 - 19/02/2015 - Pierre Van Glebeke
* cosmétique dc2.6
* jeux mustek et currywurst
* localisation

View File

@ -1,11 +1,11 @@
# README
[![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)
[![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)
[![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://git.dotclear.watch/JcDenis/construction/blob/master/LICENSE)
[![License](https://img.shields.io/github/license/JcDenis/construction)](https://github.com/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.27
* Dotclear 2.26
## 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 : [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)
* Source & contribution : [GitHub Page](https://github.com/JcDenis/construction)
* Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/construction)
* Help & discuss : [Dotclear forum](http://forum.dotclear.org/viewtopic.php?id=42875)
## CONTRIBUTORS

View File

@ -18,16 +18,16 @@ $this->registerModule(
'Construction',
'Place your blog maintenance',
'Osku and contributors',
'1.8',
'1.7',
[
'requires' => [['core', '2.27']],
'requires' => [['core', '2.26']],
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
]),
'priority' => 2000,
'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',
'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',
]
);

View File

@ -2,12 +2,12 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="construction">
<name>Construction</name>
<version>1.8</version>
<version>1.7</version>
<author>Osku and contributors</author>
<desc>Place your blog maintenance</desc>
<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>
<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>
</module>
</modules>

View File

@ -14,40 +14,65 @@ declare(strict_types=1);
namespace Dotclear\Plugin\construction;
use dcAdmin;
use dcCore;
use Dotclear\Core\Backend\{
Favorites,
Menus
};
use Dotclear\Core\Process;
use dcPage;
use dcFavorites;
use dcNsProcess;
class Backend extends Process
class Backend extends dcNsProcess
{
public static function init(): bool
{
return self::status(My::checkContext(My::BACKEND));
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;
}
public static function process(): bool
{
if (!self::status()) {
if (!static::$init) {
return false;
}
My::addBackendMenuItem(Menus::MENU_PLUGINS, [], '(&.*)?$', My::settings()->get('flag') ? 'construction-blog' : '');
// 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' : ''
);
dcCore::app()->addBehaviors([
'adminPageHTMLHead' => function (): void {
if (My::settings()->get('flag')) {
echo My::cssLoad('backend');
// 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');
}
},
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
return;
}
$favs->register(My::id(), [
'title' => My::name(),
'url' => My::manageUrl(),
'small-icon' => My::icons(),
'large-icon' => My::icons(),
'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'),
'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]),
]);
},

View File

@ -16,30 +16,32 @@ namespace Dotclear\Plugin\construction;
use ArrayObject;
use dcCore;
use Dotclear\Core\Process;
use dcNsProcess;
use Dotclear\Helper\Network\Http;
use Exception;
class Frontend extends Process
class Frontend extends dcNsProcess
{
public static function init(): bool
{
return self::status(My::checkContext(My::FRONTEND));
static::$init = defined('DC_RC_PATH');
return static::$init;
}
public static function process(): bool
{
if (!self::status()) {
if (!static::$init) {
return false;
}
dcCore::app()->addBehavior('publicBeforeDocumentV2', function (): void {
dcCore::app()->addBehavior('publicBeforeDocument', function (): void {
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
return;
}
if (!My::settings()->get('flag')) {
if (!dcCore::app()->blog->settings->get(My::id())->get('flag')) {
return;
}
@ -50,11 +52,11 @@ class Frontend extends Process
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', DC_DEFAULT_TPLSET]));
}
$all_allowed_ip = json_decode((string) My::settings()->get('allowed_ip'), true);
$all_allowed_ip = json_decode(dcCore::app()->blog->settings->get(My::id())->get('allowed_ip'), true);
if (!is_array($all_allowed_ip)) {
$all_allowed_ip = [];
}
$extra_urls = json_decode((string) My::settings()->get('extra_urls'), true);
$extra_urls = json_decode(dcCore::app()->blog->settings->get(My::id())->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';
@ -75,7 +77,7 @@ class Frontend extends Process
echo dcCore::app()->tpl->getData(dcCore::app()->ctx->__get('current_tpl'));
# --BEHAVIOR-- publicAfterDocumentV2
# --BEHAVIOR-- publicAfterDocument
dcCore::app()->callBehavior('publicAfterDocumentV2');
exit;
});

View File

@ -15,24 +15,32 @@ declare(strict_types=1);
namespace Dotclear\Plugin\construction;
use dcCore;
use Dotclear\Core\Process;
use dcNsProcess;
use Exception;
class Install extends Process
class Install extends dcNsProcess
{
public static function init(): bool
{
return self::status(My::checkContext(My::INSTALL));
static::$init = defined('DC_CONTEXT_ADMIN')
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
return static::$init;
}
public static function process(): bool
{
if (!self::status()) {
if (!static::$init) {
return false;
}
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
return false;
}
try {
$s = My::settings();
$s = dcCore::app()->blog->settings->get(My::id());
$s->put(
'flag',

View File

@ -14,12 +14,10 @@ declare(strict_types=1);
namespace Dotclear\Plugin\construction;
use dcAuth;
use dcCore;
use Dotclear\Core\Process;
use Dotclear\Core\Backend\{
Notices,
Page
};
use dcNsProcess;
use dcPage;
use Dotclear\Helper\Html\Form\{
Checkbox,
Div,
@ -37,25 +35,31 @@ use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Network\Http;
use Exception;
class Manage extends Process
class Manage extends dcNsProcess
{
public static function init(): bool
{
return self::status(My::checkContext(My::MANAGE));
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;
}
public static function process(): bool
{
if (!self::status()) {
if (!static::$init) {
return false;
}
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
return false;
}
$s = My::settings();
$s = dcCore::app()->blog->settings->get(My::id());
if (!empty($_POST['saveconfig'])) {
try {
@ -76,11 +80,13 @@ class Manage extends Process
dcCore::app()->blog->triggerBlog();
Notices::addSuccessNotice(
dcPage::addSuccessNotice(
__('Settings successfully updated.')
);
My::redirect();
dcCore::app()->adminurl->redirect(
'admin.plugin.' . My::id()
);
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
}
@ -91,16 +97,16 @@ class Manage extends Process
public static function render(): void
{
if (!self::status()) {
if (!static::$init) {
return;
}
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
return;
}
$s = My::settings();
$s = dcCore::app()->blog->settings->get(My::id());
$editor = dcCore::app()->auth->getOption('editor');
$nb_rows = count(json_decode($s->get('allowed_ip'), true));
if ($nb_rows < 2) {
@ -109,22 +115,22 @@ class Manage extends Process
$nb_rows = 10;
}
Page::openModule(
dcPage::openModule(
My::name(),
Page::jsConfirmClose('opts-forms') .
dcPage::jsConfirmClose('opts-forms') .
dcCore::app()->callBehavior('adminPostEditor', $editor['xhtml'], 'construction', ['#construction_message'], 'xhtml') .
Page::jsLoad('backend')
dcPage::jsModuleLoad(My::id() . '/js/backend.js')
);
echo
Page::breadcrumb([
dcPage::breadcrumb([
__('Plugins') => '',
My::name() => '',
]) .
Notices::getNotices() .
dcPage::notices() .
(new Div())->id('construction_options')->items([
(new Form(My::id() . 'form'))->method('post')->action(My::manageUrl())->fields([
(new Form(My::id() . 'form'))->method('post')->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()))->fields([
(new Div())->class('fieldset')->items([
(new Text('h4', __('Configuration'))),
(new Para())->class('filed')->items([
@ -153,12 +159,13 @@ class Manage extends Process
]),
]),
(new Para())->items([
dcCore::app()->formNonce(false),
(new Hidden(['p'], 'construction')),
(new Submit(['saveconfig']))->value(__('Save')),
... My::hiddenFields(),
]),
]),
])->render();
Page::closeModule();
dcPage::closeModule();
}
}

View File

@ -14,11 +14,36 @@ declare(strict_types=1);
namespace Dotclear\Plugin\construction;
use Dotclear\Module\MyPlugin;
use dcCore;
/**
* This module definitions.
*/
class My extends MyPlugin
class My
{
/**
* 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__);
}
}

View File

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