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 construction 1.8 - 2023.08.06
=========================================================== ===========================================================
* Require Dotclear 2.27 * Require Dotclear 2.27

View File

@ -1,22 +1,26 @@
# README # README
[![Release](https://img.shields.io/badge/release-1.9-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/construction/releases) [![Release](https://img.shields.io/github/v/release/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/releases)
![Date](https://img.shields.io/badge/date-2023.10.15-c44d58.svg) [![Date](https://img.shields.io/github/release-date/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/releases)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download) [![Issues](https://img.shields.io/github/issues/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/issues)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/construction) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/construction/src/branch/master/LICENSE) [![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 ## REQUIREMENTS
* Dotclear 2.28 _construction_ requires:
* PHP 8.1
* Dotclear admin permissions on blog * admin permissions on blog
* Dotclear 2.27
## USAGE ## USAGE
@ -27,16 +31,15 @@ You can activate and setup _construction_ from sidebar menu "Construction".
## LINKS ## LINKS
* [License](https://git.dotclear.watch/JcDenis/construction/src/branch/master/LICENSE) * License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* [Packages & details](https://git.dotclear.watch/JcDenis/construction/releases) (or on [Dotaddict](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)
* [Sources & contributions](https://git.dotclear.watch/JcDenis/construction) (or on [GitHub](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)
* [Issues & security](https://git.dotclear.watch/JcDenis/construction/issues) (or on [GitHub](https://github.com/JcDenis/construction/issues)) * Help & discuss : [Dotclear forum](http://forum.dotclear.org/viewtopic.php?id=42875)
* [Help & discuss](http://forum.dotclear.org/viewtopic.php?id=42875)
## CONTRIBUTORS ## CONTRIBUTORS
* Osku (author) * Osku (author)
* Pierre Van Glabeke * Pierre Van Glabeke
* Jean-Christian Denis (latest) * 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 <?php
/** /**
* @file * @brief construction, a plugin for Dotclear 2
* @brief The plugin construction definition
* @ingroup construction
* *
* @defgroup construction Plugin construction. * @package Dotclear
* @subpackage Plugin
* *
* Place your blog maintenance. * @author Osku and contributors
* *
* @author Osku (author) * @copyright Jean-Christian Denis
* @author Jean-Christian Denis (latest)
* @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
*/ */
declare(strict_types=1); if (!defined('DC_RC_PATH')) {
return;
}
$this->registerModule( $this->registerModule(
'Construction', 'Construction',
'Place your blog maintenance', 'Place your blog maintenance',
'Osku and contributors', 'Osku and contributors',
'1.9', '1.8',
[ [
'requires' => [['core', '2.28']], 'requires' => [['core', '2.27']],
'permissions' => 'My', 'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
]),
'priority' => 2000, 'priority' => 2000,
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="construction"> <module id="construction">
<name>Construction</name> <name>Construction</name>
<version>1.9</version> <version>1.8</version>
<author>Osku and contributors</author> <author>Osku and contributors</author>
<desc>Place your blog maintenance</desc> <desc>Place your blog maintenance</desc>
<file>https://git.dotclear.watch/JcDenis/construction/releases/download/v1.9/plugin-construction.zip</file> <file>https://gitea.dotclear.watch/JcDenis/construction/releases/download/v1.8/plugin-construction.zip</file>
<da:dcmin>2.28</da:dcmin> <da:dcmin>2.27</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/construction/src/branch/master/README.md</da:details> <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> <da:support>https://git.dotclear.watch/JcDenis/construction/issues</da:support>
</module> </module>

View File

@ -1,21 +1,26 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\construction; namespace Dotclear\Plugin\construction;
use Dotclear\App; use dcCore;
use Dotclear\Core\Backend\Favorites; use Dotclear\Core\Backend\{
Favorites,
Menus
};
use Dotclear\Core\Process; 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 class Backend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -29,9 +34,9 @@ class Backend extends Process
return false; 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 { 'adminPageHTMLHead' => function (): void {
if (My::settings()->get('flag')) { if (My::settings()->get('flag')) {
echo My::cssLoad('backend'); echo My::cssLoad('backend');
@ -43,7 +48,7 @@ class Backend extends Process
'url' => My::manageUrl(), 'url' => My::manageUrl(),
'small-icon' => My::icons(), 'small-icon' => My::icons(),
'large-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 <?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); declare(strict_types=1);
namespace Dotclear\Plugin\construction; namespace Dotclear\Plugin\construction;
use ArrayObject; use ArrayObject;
use Dotclear\App; use dcCore;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Helper\Network\Http; use Dotclear\Helper\Network\Http;
use Exception; 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 class Frontend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -31,9 +33,9 @@ class Frontend extends Process
return false; return false;
} }
App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void { dcCore::app()->addBehavior('publicBeforeDocumentV2', function (): void {
// nullsafe PHP < 8.0 // nullsafe PHP < 8.0
if (!App::blog()->isDefined()) { if (is_null(dcCore::app()->blog)) {
return; return;
} }
@ -41,11 +43,11 @@ class Frontend extends Process
return; 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]))) { 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 { } 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); $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); $extra_urls = json_decode((string) My::settings()->get('extra_urls'), true);
if (!in_array(Http::realIP(), $all_allowed_ip)) { if (!in_array(Http::realIP(), $all_allowed_ip)) {
App::url()->registerDefault(function (?string $args): void { dcCore::app()->url->registerDefault(function (?string $args): void {
App::url()->type = 'default'; dcCore::app()->url->type = 'default';
throw new Exception('Blog under construction', 503); 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'); header('Content-Type: text/html; charset=UTF-8');
Http::head(503, 'Service Unavailable'); Http::head(503, 'Service Unavailable');
App::url()->type = '503'; dcCore::app()->url->type = '503';
App::frontend()->context()->__set('current_tpl', '503.html'); dcCore::app()->ctx->__set('current_tpl', '503.html');
App::frontend()->context()->__set('content_type', 'text/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 # --BEHAVIOR-- publicAfterDocumentV2
App::behavior()->callBehavior('publicAfterDocumentV2'); dcCore::app()->callBehavior('publicAfterDocumentV2');
exit; exit;
}); });
foreach (App::url()->getTypes() as $k => $v) { foreach (dcCore::app()->url->getTypes() as $k => $v) {
if (($k != 'contactme') && !in_array($k, $extra_urls)) { 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); 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( return '<?php echo ' . sprintf(
App::frontend()->template()->getFilters($attr), dcCore::app()->tpl->getFilters($attr),
'App::blog()->settings()->get("' . My::id() . '")->get("message")' '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( return '<?php echo ' . sprintf(
App::frontend()->template()->getFilters($attr), dcCore::app()->tpl->getFilters($attr),
'App::blog()->settings()->get("' . My::id() . '")->get("title")' 'dcCore::app()->blog->settings->get("' . My::id() . '")->get("title")'
) . '; ?>'; ) . '; ?>';
}); });

View File

@ -1,21 +1,23 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\construction; namespace Dotclear\Plugin\construction;
use Dotclear\App; use dcCore;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Exception; 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 class Install extends Process
{ {
public static function init(): bool public static function init(): bool
@ -79,7 +81,7 @@ class Install extends Process
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
App::error()->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
return true; return true;

View File

@ -1,10 +1,20 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\construction; namespace Dotclear\Plugin\construction;
use Dotclear\App; use dcCore;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Core\Backend\{ use Dotclear\Core\Backend\{
Notices, Notices,
@ -27,14 +37,6 @@ use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Network\Http; use Dotclear\Helper\Network\Http;
use Exception; 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 class Manage extends Process
{ {
public static function init(): bool public static function init(): bool
@ -49,7 +51,7 @@ class Manage extends Process
} }
// nullsafe PHP < 8.0 // nullsafe PHP < 8.0
if (!App::blog()->isDefined()) { if (is_null(dcCore::app()->blog)) {
return false; return false;
} }
@ -72,7 +74,7 @@ class Manage extends Process
$s->put('message', $_POST['construction_message']); $s->put('message', $_POST['construction_message']);
$s->put('extra_urls', json_encode($extra_urls)); $s->put('extra_urls', json_encode($extra_urls));
App::blog()->triggerBlog(); dcCore::app()->blog->triggerBlog();
Notices::addSuccessNotice( Notices::addSuccessNotice(
__('Settings successfully updated.') __('Settings successfully updated.')
@ -80,7 +82,7 @@ class Manage extends Process
My::redirect(); My::redirect();
} catch (Exception $e) { } 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 // nullsafe PHP < 8.0
if (!App::blog()->isDefined()) { if (is_null(dcCore::app()->blog)) {
return; return;
} }
$s = My::settings(); $s = My::settings();
$editor = App::auth()->getOption('editor'); $editor = dcCore::app()->auth->getOption('editor');
$nb_rows = count(json_decode($s->get('allowed_ip'), true)); $nb_rows = count(json_decode($s->get('allowed_ip'), true));
if ($nb_rows < 2) { if ($nb_rows < 2) {
$nb_rows = 2; $nb_rows = 2;
@ -110,7 +112,7 @@ class Manage extends Process
Page::openModule( Page::openModule(
My::name(), My::name(),
Page::jsConfirmClose('opts-forms') . 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') Page::jsLoad('backend')
); );

View File

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

View File

@ -1,20 +1,23 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\construction; namespace Dotclear\Plugin\construction;
use dcCore;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller; 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 class Uninstall extends Process
{ {
public static function init(): bool public static function init(): bool
@ -24,7 +27,7 @@ class Uninstall extends Process
public static function process(): bool public static function process(): bool
{ {
if (!self::status()) { if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
return false; return false;
} }