Compare commits

..

4 Commits
v1.8 ... main

Author SHA1 Message Date
Jean-Christian Paul Denis 258ef1815f
oups 2023-10-15 22:03:10 +02:00
Jean-Christian Paul Denis 55fc1c543b
upgrade to Dotclear 2.28 2023-10-15 21:58:21 +02:00
Jean-Christian Paul Denis 2e4d99f3f8
fix ZIP URL 2023-08-07 23:16:17 +02:00
Jean-Christian Paul Denis 035146978c
use static badge 2023-08-07 00:58:34 +02:00
10 changed files with 136 additions and 158 deletions

View File

@ -1,3 +1,9 @@
construction 1.9 - 2023.10.15
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
construction 1.8 - 2023.08.06
===========================================================
* Require Dotclear 2.27

View File

@ -1,26 +1,22 @@
# 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)
[![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)
[![Release](https://img.shields.io/badge/release-1.9-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/construction/releases)
![Date](https://img.shields.io/badge/date-2023.10.15-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/construction)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/construction/src/branch/master/LICENSE)
## WHAT IS DISCLAIMER ?
## ABOUT
_construction_ is a plugin for the open-source
web publishing software called Dotclear.
_construction_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
Put your blog on construction mode with a custom message on frontend.
Blog can be accessible to defined IP addresses.
> Put your blog on construction mode with a custom message on frontend. Blog can be accessible to defined IP addresses.
## REQUIREMENTS
_construction_ requires:
* admin permissions on blog
* Dotclear 2.27
* Dotclear 2.28
* PHP 8.1
* Dotclear admin permissions on blog
## USAGE
@ -31,15 +27,16 @@ 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)
* Help & discuss : [Dotclear forum](http://forum.dotclear.org/viewtopic.php?id=42875)
* [License](https://git.dotclear.watch/JcDenis/construction/src/branch/master/LICENSE)
* [Packages & details](https://git.dotclear.watch/JcDenis/construction/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/construction))
* [Sources & contributions](https://git.dotclear.watch/JcDenis/construction) (or on [GitHub](https://github.com/JcDenis/construction))
* [Issues & security](https://git.dotclear.watch/JcDenis/construction/issues) (or on [GitHub](https://github.com/JcDenis/construction/issues))
* [Help & discuss](http://forum.dotclear.org/viewtopic.php?id=42875)
## CONTRIBUTORS
* Osku (author)
* Pierre Van Glabeke
* Jean-Christian Denis
* Jean-Christian Denis (latest)
You are welcome to contribute to this code.

View File

@ -1,29 +1,27 @@
<?php
/**
* @brief construction, a plugin for Dotclear 2
* @file
* @brief The plugin construction definition
* @ingroup construction
*
* @package Dotclear
* @subpackage Plugin
* @defgroup construction Plugin construction.
*
* @author Osku and contributors
* Place your blog maintenance.
*
* @copyright Jean-Christian Denis
* @author Osku (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return;
}
declare(strict_types=1);
$this->registerModule(
'Construction',
'Place your blog maintenance',
'Osku and contributors',
'1.8',
'1.9',
[
'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
]),
'requires' => [['core', '2.28']],
'permissions' => 'My',
'priority' => 2000,
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="construction">
<name>Construction</name>
<version>1.8</version>
<version>1.9</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>
<file>https://git.dotclear.watch/JcDenis/construction/releases/download/v1.9/plugin-construction.zip</file>
<da:dcmin>2.28</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>

View File

@ -1,26 +1,21 @@
<?php
/**
* @brief construction, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Osku 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\construction;
use dcCore;
use Dotclear\Core\Backend\{
Favorites,
Menus
};
use Dotclear\App;
use Dotclear\Core\Backend\Favorites;
use Dotclear\Core\Process;
/**
* @brief construction backend class.
* @ingroup construction
*
* @author Osku (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
@ -34,9 +29,9 @@ class Backend extends Process
return false;
}
My::addBackendMenuItem(Menus::MENU_PLUGINS, [], '(&.*)?$', My::settings()->get('flag') ? 'construction-blog' : '');
My::addBackendMenuItem(App::backend()->menus()::MENU_PLUGINS, [], '(&.*)?$', My::settings()->get('flag') ? 'construction-blog' : '');
dcCore::app()->addBehaviors([
App::behavior()->addBehaviors([
'adminPageHTMLHead' => function (): void {
if (My::settings()->get('flag')) {
echo My::cssLoad('backend');
@ -48,7 +43,7 @@ class Backend extends Process
'url' => My::manageUrl(),
'small-icon' => My::icons(),
'large-icon' => My::icons(),
'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]),
'permissions' => App::auth()->makePermissions([App::auth()::PERMISSION_ADMIN]),
]);
},
]);

View File

@ -1,25 +1,23 @@
<?php
/**
* @brief construction, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Osku 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\construction;
use ArrayObject;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
use Dotclear\Helper\Network\Http;
use Exception;
/**
* @brief construction frontend class.
* @ingroup construction
*
* @author Osku (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Frontend extends Process
{
public static function init(): bool
@ -33,9 +31,9 @@ class Frontend extends Process
return false;
}
dcCore::app()->addBehavior('publicBeforeDocumentV2', function (): void {
App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void {
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return;
}
@ -43,11 +41,11 @@ class Frontend extends Process
return;
}
$tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->get('system')->get('theme'), 'tplset');
$tplset = App::themes()->moduleInfo(App::blog()->settings()->get('system')->get('theme'), 'tplset');
if (!empty($tplset) && is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) {
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]));
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]));
} else {
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', DC_DEFAULT_TPLSET]));
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', App::config()->defaultTplset()]));
}
$all_allowed_ip = json_decode((string) My::settings()->get('allowed_ip'), true);
@ -56,33 +54,28 @@ class Frontend extends Process
}
$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';
App::url()->registerDefault(function (?string $args): void {
App::url()->type = 'default';
throw new Exception('Blog under construction', 503);
});
dcCore::app()->url->registerError(function (?string $args, ?string $type, Exception $e): void {
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->ctx)) {
return;
}
App::url()->registerError(function (?string $args, ?string $type, Exception $e): void {
header('Content-Type: text/html; charset=UTF-8');
Http::head(503, 'Service Unavailable');
dcCore::app()->url->type = '503';
dcCore::app()->ctx->__set('current_tpl', '503.html');
dcCore::app()->ctx->__set('content_type', 'text/html');
App::url()->type = '503';
App::frontend()->context()->__set('current_tpl', '503.html');
App::frontend()->context()->__set('content_type', 'text/html');
echo dcCore::app()->tpl->getData(dcCore::app()->ctx->__get('current_tpl'));
echo App::frontend()->template()->getData(App::frontend()->context()->__get('current_tpl'));
# --BEHAVIOR-- publicAfterDocumentV2
dcCore::app()->callBehavior('publicAfterDocumentV2');
App::behavior()->callBehavior('publicAfterDocumentV2');
exit;
});
foreach (dcCore::app()->url->getTypes() as $k => $v) {
foreach (App::url()->getTypes() as $k => $v) {
if (($k != 'contactme') && !in_array($k, $extra_urls)) {
dcCore::app()->url->register($k, $v['url'], $v['representation'], function () {
App::url()->register($k, $v['url'], $v['representation'], function () {
throw new Exception('Blog under construction', 503);
});
}
@ -90,16 +83,16 @@ class Frontend extends Process
}
});
dcCore::app()->tpl->addValue('ConstructionMessage', function (ArrayObject $attr): string {
App::frontend()->template()->addValue('ConstructionMessage', function (ArrayObject $attr): string {
return '<?php echo ' . sprintf(
dcCore::app()->tpl->getFilters($attr),
'dcCore::app()->blog->settings->get("' . My::id() . '")->get("message")'
App::frontend()->template()->getFilters($attr),
'App::blog()->settings()->get("' . My::id() . '")->get("message")'
) . '; ?>';
});
dcCore::app()->tpl->addValue('ConstructionTitle', function (ArrayObject $attr): string {
App::frontend()->template()->addValue('ConstructionTitle', function (ArrayObject $attr): string {
return '<?php echo ' . sprintf(
dcCore::app()->tpl->getFilters($attr),
'dcCore::app()->blog->settings->get("' . My::id() . '")->get("title")'
App::frontend()->template()->getFilters($attr),
'App::blog()->settings()->get("' . My::id() . '")->get("title")'
) . '; ?>';
});

View File

@ -1,23 +1,21 @@
<?php
/**
* @brief construction, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Osku 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\construction;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
use Exception;
/**
* @brief construction install class.
* @ingroup construction
*
* @author Osku (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Install extends Process
{
public static function init(): bool
@ -81,7 +79,7 @@ class Install extends Process
return true;
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
App::error()->add($e->getMessage());
}
return true;

View File

@ -1,20 +1,10 @@
<?php
/**
* @brief construction, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Osku 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\construction;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
use Dotclear\Core\Backend\{
Notices,
@ -37,6 +27,14 @@ use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Network\Http;
use Exception;
/**
* @brief construction manage class.
* @ingroup construction
*
* @author Osku (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
@ -51,7 +49,7 @@ class Manage extends Process
}
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return false;
}
@ -74,7 +72,7 @@ class Manage extends Process
$s->put('message', $_POST['construction_message']);
$s->put('extra_urls', json_encode($extra_urls));
dcCore::app()->blog->triggerBlog();
App::blog()->triggerBlog();
Notices::addSuccessNotice(
__('Settings successfully updated.')
@ -82,7 +80,7 @@ class Manage extends Process
My::redirect();
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
App::error()->add($e->getMessage());
}
}
@ -96,12 +94,12 @@ class Manage extends Process
}
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return;
}
$s = My::settings();
$editor = dcCore::app()->auth->getOption('editor');
$editor = App::auth()->getOption('editor');
$nb_rows = count(json_decode($s->get('allowed_ip'), true));
if ($nb_rows < 2) {
$nb_rows = 2;
@ -112,7 +110,7 @@ class Manage extends Process
Page::openModule(
My::name(),
Page::jsConfirmClose('opts-forms') .
dcCore::app()->callBehavior('adminPostEditor', $editor['xhtml'], 'construction', ['#construction_message'], 'xhtml') .
App::behavior()->callBehavior('adminPostEditor', $editor['xhtml'], 'construction', ['#construction_message'], 'xhtml') .
Page::jsLoad('backend')
);

View File

@ -1,15 +1,5 @@
<?php
/**
* @brief construction, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Osku 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\construction;
@ -17,8 +7,14 @@ namespace Dotclear\Plugin\construction;
use Dotclear\Module\MyPlugin;
/**
* This module definitions.
* @brief construction My helper.
* @ingroup construction
*
* @author Osku (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class My extends MyPlugin
{
// Use default permissions
}

View File

@ -1,23 +1,20 @@
<?php
/**
* @brief construction, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Osku 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\construction;
use dcCore;
use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller;
/**
* @brief construction uninstall class.
* @ingroup construction
*
* @author Osku (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
@ -27,7 +24,7 @@ class Uninstall extends Process
public static function process(): bool
{
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
if (!self::status()) {
return false;
}