Compare commits

..

No commits in common. "main" and "v1.8" have entirely different histories.
main ... v1.8

10 changed files with 158 additions and 136 deletions

View File

@ -1,9 +1,3 @@
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,22 +1,26 @@
# README
[![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)
[![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)
## ABOUT
## WHAT IS DISCLAIMER ?
_construction_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
_construction_ is a plugin for the open-source
web publishing software called Dotclear.
> 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
* Dotclear 2.28
* PHP 8.1
* Dotclear admin permissions on blog
_construction_ requires:
* admin permissions on blog
* Dotclear 2.27
## USAGE
@ -27,16 +31,15 @@ You can activate and setup _construction_ from sidebar menu "Construction".
## LINKS
* [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)
* 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)
## CONTRIBUTORS
* Osku (author)
* Pierre Van Glabeke
* Jean-Christian Denis (latest)
* Osku (author)
* Pierre Van Glabeke
* Jean-Christian Denis
You are welcome to contribute to this code.
You are welcome to contribute to this code.

View File

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

View File

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

View File

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

View File

@ -1,21 +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 Dotclear\App;
use dcCore;
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
@ -79,7 +81,7 @@ class Install extends Process
return true;
} catch (Exception $e) {
App::error()->add($e->getMessage());
dcCore::app()->error->add($e->getMessage());
}
return true;

View File

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

View File

@ -1,5 +1,15 @@
<?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;
@ -7,14 +17,8 @@ namespace Dotclear\Plugin\construction;
use Dotclear\Module\MyPlugin;
/**
* @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
* This module definitions.
*/
class My extends MyPlugin
{
// Use default permissions
}

View File

@ -1,20 +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 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
@ -24,7 +27,7 @@ class Uninstall extends Process
public static function process(): bool
{
if (!self::status()) {
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
return false;
}