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

View File

@ -1,26 +1,22 @@
# README # README
[![Release](https://img.shields.io/github/v/release/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/releases) [![Release](https://img.shields.io/badge/release-1.9-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/construction/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/releases) ![Date](https://img.shields.io/badge/date-2023.10.15-c44d58.svg)
[![Issues](https://img.shields.io/github/issues/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/issues) [![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/construction)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.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)
[![License](https://img.shields.io/github/license/JcDenis/construction)](https://git.dotclear.watch/JcDenis/construction/blob/master/LICENSE)
## WHAT IS DISCLAIMER ? ## ABOUT
_construction_ is a plugin for the open-source _construction_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
web publishing software called Dotclear.
Put your blog on construction mode with a custom message on frontend. > Put your blog on construction mode with a custom message on frontend. Blog can be accessible to defined IP addresses.
Blog can be accessible to defined IP addresses.
## REQUIREMENTS ## REQUIREMENTS
_construction_ requires: * Dotclear 2.28
* PHP 8.1
* admin permissions on blog * Dotclear admin permissions on blog
* Dotclear 2.27
## USAGE ## USAGE
@ -31,15 +27,16 @@ You can activate and setup _construction_ from sidebar menu "Construction".
## LINKS ## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) * [License](https://git.dotclear.watch/JcDenis/construction/src/branch/master/LICENSE)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/construction) or [GitHub Page](https://github.com/JcDenis/construction) * [Packages & details](https://git.dotclear.watch/JcDenis/construction/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/construction))
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/construction/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/construction) * [Sources & contributions](https://git.dotclear.watch/JcDenis/construction) (or on [GitHub](https://github.com/JcDenis/construction))
* Help & discuss : [Dotclear forum](http://forum.dotclear.org/viewtopic.php?id=42875) * [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 ## CONTRIBUTORS
* Osku (author) * Osku (author)
* Pierre Van Glabeke * Pierre Van Glabeke
* Jean-Christian Denis * Jean-Christian Denis (latest)
You are welcome to contribute to this code. You are welcome to contribute to this code.

View File

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

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.8</version> <version>1.9</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://gitea.dotclear.watch/JcDenis/construction/releases/download/v1.8/plugin-construction.zip</file> <file>https://git.dotclear.watch/JcDenis/construction/releases/download/v1.9/plugin-construction.zip</file>
<da:dcmin>2.27</da:dcmin> <da:dcmin>2.28</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,26 +1,21 @@
<?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\App;
use Dotclear\Core\Backend\{ use Dotclear\Core\Backend\Favorites;
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
@ -34,9 +29,9 @@ class Backend extends Process
return false; 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 { 'adminPageHTMLHead' => function (): void {
if (My::settings()->get('flag')) { if (My::settings()->get('flag')) {
echo My::cssLoad('backend'); echo My::cssLoad('backend');
@ -48,7 +43,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' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]), 'permissions' => App::auth()->makePermissions([App::auth()::PERMISSION_ADMIN]),
]); ]);
}, },
]); ]);

View File

@ -1,25 +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 ArrayObject; use ArrayObject;
use dcCore; use Dotclear\App;
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
@ -33,9 +31,9 @@ class Frontend extends Process
return false; return false;
} }
dcCore::app()->addBehavior('publicBeforeDocumentV2', function (): void { App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void {
// nullsafe PHP < 8.0 // nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) { if (!App::blog()->isDefined()) {
return; return;
} }
@ -43,11 +41,11 @@ class Frontend extends Process
return; 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]))) { 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 { } 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); $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); $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)) {
dcCore::app()->url->registerDefault(function (?string $args): void { App::url()->registerDefault(function (?string $args): void {
dcCore::app()->url->type = 'default'; App::url()->type = 'default';
throw new Exception('Blog under construction', 503); throw new Exception('Blog under construction', 503);
}); });
dcCore::app()->url->registerError(function (?string $args, ?string $type, Exception $e): void { 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');
dcCore::app()->url->type = '503'; App::url()->type = '503';
dcCore::app()->ctx->__set('current_tpl', '503.html'); App::frontend()->context()->__set('current_tpl', '503.html');
dcCore::app()->ctx->__set('content_type', 'text/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 # --BEHAVIOR-- publicAfterDocumentV2
dcCore::app()->callBehavior('publicAfterDocumentV2'); App::behavior()->callBehavior('publicAfterDocumentV2');
exit; exit;
}); });
foreach (dcCore::app()->url->getTypes() as $k => $v) { foreach (App::url()->getTypes() as $k => $v) {
if (($k != 'contactme') && !in_array($k, $extra_urls)) { 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); 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( return '<?php echo ' . sprintf(
dcCore::app()->tpl->getFilters($attr), App::frontend()->template()->getFilters($attr),
'dcCore::app()->blog->settings->get("' . My::id() . '")->get("message")' '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( return '<?php echo ' . sprintf(
dcCore::app()->tpl->getFilters($attr), App::frontend()->template()->getFilters($attr),
'dcCore::app()->blog->settings->get("' . My::id() . '")->get("title")' 'App::blog()->settings()->get("' . My::id() . '")->get("title")'
) . '; ?>'; ) . '; ?>';
}); });

View File

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

View File

@ -1,20 +1,10 @@
<?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\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Core\Backend\{ use Dotclear\Core\Backend\{
Notices, Notices,
@ -37,6 +27,14 @@ 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
@ -51,7 +49,7 @@ class Manage extends Process
} }
// nullsafe PHP < 8.0 // nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) { if (!App::blog()->isDefined()) {
return false; return false;
} }
@ -74,7 +72,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));
dcCore::app()->blog->triggerBlog(); App::blog()->triggerBlog();
Notices::addSuccessNotice( Notices::addSuccessNotice(
__('Settings successfully updated.') __('Settings successfully updated.')
@ -82,7 +80,7 @@ class Manage extends Process
My::redirect(); My::redirect();
} catch (Exception $e) { } 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 // nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) { if (!App::blog()->isDefined()) {
return; return;
} }
$s = My::settings(); $s = My::settings();
$editor = dcCore::app()->auth->getOption('editor'); $editor = 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;
@ -112,7 +110,7 @@ class Manage extends Process
Page::openModule( Page::openModule(
My::name(), My::name(),
Page::jsConfirmClose('opts-forms') . 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') Page::jsLoad('backend')
); );

View File

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

View File

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