release 1.5 (see changelog)
This commit is contained in:
parent
c5d581f5e8
commit
f3457039cb
13 changed files with 398 additions and 405 deletions
|
@ -1,3 +1,11 @@
|
|||
1.5 - 2022.12.31
|
||||
* update to dotclear 2.24
|
||||
* use json intead of serialize
|
||||
* use short settings names
|
||||
* use anonymous functions
|
||||
* use abstract plugin id
|
||||
* fix phpstan and php-cs-fixer errors
|
||||
|
||||
v1.4 - 20-12-2022 - Pierre Van Glebeke
|
||||
* màj partielle dc2.24
|
||||
|
47
README.md
47
README.md
|
@ -1,2 +1,45 @@
|
|||
# construction
|
||||
Cette extension permet de placer son blog en maintenance. Il est possible également de renseigner plusieurs IP autorisées.
|
||||
# README
|
||||
|
||||
[![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.24-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://github.com/JcDenis/construction/blob/master/LICENSE)
|
||||
|
||||
## WHAT IS DISCLAIMER ?
|
||||
|
||||
_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.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
_construction_ requires:
|
||||
|
||||
* admin permissions on blog
|
||||
* Dotclear 2.24
|
||||
|
||||
## USAGE
|
||||
|
||||
First install _construction_, manualy from a zip package or from
|
||||
Dotaddict repository. (See Dotclear's documentation to know how do this)
|
||||
|
||||
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 : [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
|
||||
|
||||
* Osku (author)
|
||||
* Pierre Van Glabeke
|
||||
* Jean-Christian Denis
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
|
78
_admin.php
78
_admin.php
|
@ -1,47 +1,41 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of construction, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
|
||||
dcCore::app()->blog->settings->addNamespace('construction');
|
||||
$menu_class = '';
|
||||
|
||||
if (dcCore::app()->blog->settings->construction->construction_flag)
|
||||
{
|
||||
dcCore::app()->addBehavior('adminPageHTMLHead','constructionadminPageHTMLHead');
|
||||
$menu_class = 'construction-blog';
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$_menu['Blog']->addItem(__('Construction'),
|
||||
'plugin.php?p=construction','index.php?pf=construction/icon.png',
|
||||
preg_match('/plugin.php\?p=construction(&.*)?$/',$_SERVER['REQUEST_URI']),
|
||||
dcCore::app()->auth->check('admin',dcCore::app()->blog->id),
|
||||
$menu_class
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
__('Construction'),
|
||||
dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
|
||||
urldecode(dcPage::getPF(basename(__DIR__) . '/icon.png')),
|
||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
||||
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), dcCore::app()->blog->id),
|
||||
dcCore::app()->blog->settings->get(basename(__DIR__))->get('flag') ? 'construction-blog' : ''
|
||||
);
|
||||
|
||||
function constructionadminPageHTMLHead()
|
||||
{
|
||||
echo '<style type="text/css">'."\n".'@import "index.php?pf=construction/css/admin.css";'."\n".'</style>'."\n";
|
||||
}
|
||||
|
||||
dcCore::app()->addBehavior('adminDashboardFavorites','constructionDashboardFavorites');
|
||||
|
||||
function constructionDashboardFavorites($core,$favs)
|
||||
{
|
||||
$favs->register('construction', array(
|
||||
'title' => __('Construction'),
|
||||
'url' => 'plugin.php?p=construction',
|
||||
'small-icon' => 'index.php?pf=construction/icon.png',
|
||||
'large-icon' => 'index.php?pf=construction/icon-big.png',
|
||||
'permissions' => 'usage,contentadmin'
|
||||
));
|
||||
}
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminPageHTMLHead' => function () {
|
||||
if (dcCore::app()->blog->settings->get(basename(__DIR__))->get('flag')) {
|
||||
echo dcPage::cssModuleLoad(basename(__DIR__) . '/css/admin.css');
|
||||
}
|
||||
},
|
||||
'adminDashboardFavoritesV2' => function (dcFavorites $favs) {
|
||||
$favs->register(basename(__DIR__), [
|
||||
'title' => __('Construction'),
|
||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
|
||||
'small-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon.png')),
|
||||
'large-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon-big.png')),
|
||||
'permissions' => dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]),
|
||||
]);
|
||||
},
|
||||
]);
|
||||
|
|
56
_define.php
56
_define.php
|
@ -1,29 +1,33 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of construction, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->registerModule(
|
||||
/* Name */ "Construction",
|
||||
/* Description*/ "Place your blog maintenance",
|
||||
/* Author */ "Osku and contributors",
|
||||
/* Version */ '1.4',
|
||||
/* Properties */
|
||||
array(
|
||||
'permissions' => 'admin',
|
||||
'priority' => 2000,
|
||||
'type' => 'plugin',
|
||||
'dc_min' => '2.24',
|
||||
'support' => 'http://forum.dotclear.org/viewtopic.php?id=42875',
|
||||
'details' => 'http://plugins.dotaddict.org/dc2/details/construction'
|
||||
)
|
||||
);
|
||||
'Construction',
|
||||
'Place your blog maintenance',
|
||||
'Osku and contributors',
|
||||
'1.5',
|
||||
[
|
||||
'requires' => [['core', '2.24']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
]),
|
||||
'priority' => 2000,
|
||||
'type' => 'plugin',
|
||||
'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',
|
||||
]
|
||||
);
|
||||
|
|
127
_install.php
127
_install.php
|
@ -1,67 +1,78 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of construction, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { exit; }
|
||||
|
||||
$new_version = dcCore::app()->plugins->moduleInfo('construction','version');
|
||||
|
||||
$current_version = dcCore::app()->getVersion('construction');
|
||||
|
||||
if (version_compare($current_version,$new_version,'>=')) {
|
||||
return;
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcCore::app()->blog->settings->addNamespace('construction');
|
||||
$s =& dcCore::app()->blog->settings->construction;
|
||||
try {
|
||||
// Version
|
||||
if (!dcCore::app()->newVersion(
|
||||
basename(__DIR__),
|
||||
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
|
||||
)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$s->put('construction_flag',
|
||||
false,
|
||||
'boolean',
|
||||
'Construction blog flag',
|
||||
true,
|
||||
true
|
||||
);
|
||||
$s = dcCore::app()->blog->settings->get(basename(__DIR__));
|
||||
|
||||
$s->put('construction_allowed_ip',
|
||||
serialize(array('127.0.0.1')),
|
||||
'string',
|
||||
'Construction blog allowed ip',
|
||||
true,
|
||||
true
|
||||
);
|
||||
$s->put(
|
||||
'flag',
|
||||
false,
|
||||
'boolean',
|
||||
'Construction blog flag',
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
$s->put('construction_title',
|
||||
__('Work in progress'),
|
||||
'string',
|
||||
'Construction blog title',
|
||||
true,
|
||||
true
|
||||
);
|
||||
$s->put(
|
||||
'allowed_ip',
|
||||
json_encode(['127.0.0.1']),
|
||||
'string',
|
||||
'Construction blog allowed ip',
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
$s->put('construction_message',
|
||||
__('<p>The blog is currently under construction.</p>'),
|
||||
'string',
|
||||
'Construction blog message',
|
||||
true,
|
||||
true
|
||||
);
|
||||
$s->put(
|
||||
'title',
|
||||
__('Work in progress'),
|
||||
'string',
|
||||
'Construction blog title',
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
$s->put('construction_extra_urls',
|
||||
serialize(array()),
|
||||
'string',
|
||||
'Construction blog message',
|
||||
true,
|
||||
true
|
||||
);
|
||||
$s->put(
|
||||
'message',
|
||||
__('<p>The blog is currently under construction.</p>'),
|
||||
'string',
|
||||
'Construction blog message',
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
dcCore::app()->setVersion('construction',$new_version);
|
||||
return true;
|
||||
$s->put(
|
||||
'extra_urls',
|
||||
json_encode([]),
|
||||
'string',
|
||||
'Construction blog message',
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
15
_prepend.php
15
_prepend.php
|
@ -1,15 +0,0 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of construction, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
if (version_compare(DC_VERSION,'2.2-beta','<')) { return; }
|
166
_public.php
166
_public.php
|
@ -1,103 +1,75 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of construction, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_RC_PATH')) { return; }
|
||||
|
||||
if (dcCore::app()->blog->settings->construction->construction_flag)
|
||||
{
|
||||
dcCore::app()->addBehavior('publicBeforeDocument',array('publicBehaviorsConstruction','checkVisitor'));
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcCore::app()->tpl->addValue('ConstructionMessage',array('tplConstruction','ConstructionMessage'));
|
||||
dcCore::app()->tpl->addValue('ConstructionTitle',array('tplConstruction','ConstructionTitle'));
|
||||
dcCore::app()->addBehavior('publicBeforeDocument', function () {
|
||||
if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('flag')) {
|
||||
return;
|
||||
}
|
||||
|
||||
class publicBehaviorsConstruction
|
||||
{
|
||||
public static function checkVisitor($core)
|
||||
{
|
||||
$tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->system->theme,'tplset');
|
||||
if (!empty($tplset) && is_dir(dirname(__FILE__).'/default-templates/'.$tplset)) {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), dirname(__FILE__).'/default-templates/'.$tplset);
|
||||
} else {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), dirname(__FILE__).'/default-templates/'.DC_DEFAULT_TPLSET);
|
||||
$tplset = dcCore::app()->themes->moduleInfo(dcCore::app()->blog->settings->get('system')->get('theme'), 'tplset');
|
||||
if (!empty($tplset) && is_dir(implode(DIRECTORY_SEPARATOR, [__DIR__, 'default-templates', $tplset]))) {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [__DIR__, 'default-templates', $tplset]));
|
||||
} else {
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), implode(DIRECTORY_SEPARATOR, [__DIR__, 'default-templates', DC_DEFAULT_TPLSET]));
|
||||
}
|
||||
|
||||
$all_allowed_ip = json_decode(dcCore::app()->blog->settings->get(basename(__DIR__))->get('allowed_ip'), true);
|
||||
if (!is_array($all_allowed_ip)) {
|
||||
$all_allowed_ip = [];
|
||||
}
|
||||
$extra_urls = json_decode(dcCore::app()->blog->settings->get(basename(__DIR__))->get('extra_urls'), true);
|
||||
if (!in_array(http::realIP(), $all_allowed_ip)) {
|
||||
dcCore::app()->url->registerDefault(function ($args) {
|
||||
dcCore::app()->url->type = 'default';
|
||||
|
||||
throw new Exception('Blog under construction', 503);
|
||||
});
|
||||
dcCore::app()->url->registerError(function ($args, $type, $e) {
|
||||
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');
|
||||
|
||||
echo dcCore::app()->tpl->getData(dcCore::app()->ctx->__get('current_tpl'));
|
||||
|
||||
# --BEHAVIOR-- publicAfterDocument
|
||||
dcCore::app()->callBehavior('publicAfterDocumentV2');
|
||||
exit;
|
||||
});
|
||||
|
||||
foreach (dcCore::app()->url->getTypes() as $k => $v) {
|
||||
if (($k != 'contactme') && !in_array($k, $extra_urls)) {
|
||||
dcCore::app()->url->register($k, $v['url'], $v['representation'], function () {
|
||||
throw new Exception('Blog under construction', 503);
|
||||
});
|
||||
}
|
||||
}
|
||||
$all_allowed_ip = unserialize(dcCore::app()->blog->settings->construction->construction_allowed_ip);
|
||||
$extra_urls = unserialize(dcCore::app()->blog->settings->construction->construction_extra_urls);
|
||||
if (!in_array(http::realIP(),$all_allowed_ip))
|
||||
{
|
||||
dcCore::app()->url->registerDefault(array('urlConstruction','constructionHandler'));
|
||||
dcCore::app()->url->registerError(array('urlConstruction','default503'));
|
||||
|
||||
foreach (dcCore::app()->url->getTypes() as $k=>$v)
|
||||
{
|
||||
if (($k != 'contactme') && !in_array($k,$extra_urls))
|
||||
{
|
||||
dcCore::app()->url->register($k,$v['url'],$v['representation'],array('urlConstruction','p503'));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class urlConstruction extends dcUrlHandlers
|
||||
{
|
||||
public static function p503()
|
||||
{
|
||||
throw new Exception ("Blog under construction",503);
|
||||
}
|
||||
|
||||
public static function default503($args,$type,$e)
|
||||
{
|
||||
//if ($e->getCode() == 503) {
|
||||
$_ctx =& $GLOBALS['_ctx'];
|
||||
$core =& $GLOBALS['core'];
|
||||
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
http::head(503,'Service Unavailable');
|
||||
dcCore::app()->url->type = '503';
|
||||
$_ctx->current_tpl = '503.html';
|
||||
$_ctx->content_type = 'text/html';
|
||||
|
||||
echo dcCore::app()->tpl->getData($_ctx->current_tpl);
|
||||
|
||||
# --BEHAVIOR-- publicAfterDocument
|
||||
dcCore::app()->callBehavior('publicAfterDocument',$core);
|
||||
exit;
|
||||
//}
|
||||
}
|
||||
|
||||
public static function constructionHandler($args)
|
||||
{
|
||||
$core =& $GLOBALS['core'];
|
||||
dcCore::app()->url->type = 'default';
|
||||
self::p503();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
class tplConstruction
|
||||
{
|
||||
public static function ConstructionMessage($attr)
|
||||
{
|
||||
$core =& $GLOBALS['core'];
|
||||
$f = dcCore::app()->tpl->getFilters($attr);
|
||||
return '<?php echo '.sprintf($f, 'dcCore::app()->blog->settings->construction->construction_message').'; ?>';
|
||||
}
|
||||
|
||||
public static function ConstructionTitle($attr)
|
||||
{
|
||||
$core =& $GLOBALS['core'];
|
||||
$f = dcCore::app()->tpl->getFilters($attr);
|
||||
return '<?php echo '.sprintf($f, 'dcCore::app()->blog->settings->construction->construction_title').'; ?>';
|
||||
}
|
||||
}
|
||||
dcCore::app()->tpl->addValue('ConstructionMessage', function ($attr) {
|
||||
return '<?php echo ' . sprintf(
|
||||
dcCore::app()->tpl->getFilters($attr),
|
||||
'dcCore::app()->blog->settings->get("' . basename(__DIR__) . '")->get("message")'
|
||||
) . '; ?>';
|
||||
});
|
||||
dcCore::app()->tpl->addValue('ConstructionTitle', function ($attr) {
|
||||
return '<?php echo ' . sprintf(
|
||||
dcCore::app()->tpl->getFilters($attr),
|
||||
'dcCore::app()->blog->settings->get("' . basename(__DIR__) . '")->get("title")'
|
||||
) . '; ?>';
|
||||
});
|
||||
|
|
13
dcstore.xml
Normal file
13
dcstore.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="construction">
|
||||
<name>Construction</name>
|
||||
<version>1.5</version>
|
||||
<author>Osku and contributors</author>
|
||||
<desc>Place your blog maintenance</desc>
|
||||
<file>https://github.com/JcDenis/construction/releases/download/v1.5/plugin-construction.zip</file>
|
||||
<da:dcmin>2.24</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>
|
190
index.php
190
index.php
|
@ -1,125 +1,115 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of construction, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2010 Osku and contributors
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
if (!defined('DC_CONTEXT_ADMIN')) { return; }
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$p_url = 'plugin.php?p=' . basename(dirname(__FILE__));
|
||||
dcPage::check(dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
]));
|
||||
|
||||
$page_title = __('Construction');
|
||||
$s = dcCore::app()->blog->settings->get(basename(__DIR__));
|
||||
|
||||
dcCore::app()->blog->settings->addNamespace('construction');
|
||||
$s =& dcCore::app()->blog->settings->construction;
|
||||
|
||||
$flag = $s->construction_flag;
|
||||
$allowed_ip = array();
|
||||
$myip = http::realIP();
|
||||
// editeur pour le message
|
||||
$post_format = dcCore::app()->auth->getOption('post_format');
|
||||
$post_editor = dcCore::app()->auth->getOption('editor');
|
||||
$admin_post_behavior = '';
|
||||
if ($post_editor && !empty($post_editor[$post_format])) {
|
||||
$admin_post_behavior = dcCore::app()->callBehavior('adminPostEditor', $post_editor[$post_format],
|
||||
'user_desc', array('#user_desc')
|
||||
);
|
||||
if (!empty($_POST['saveconfig'])) {
|
||||
try {
|
||||
$allowed_ip = [];
|
||||
foreach (explode("\n", $_POST['construction_allowed_ip']) as $ip) {
|
||||
$allowed_ip[] = trim($ip);
|
||||
}
|
||||
$extra_urls = [];
|
||||
foreach (explode(',', $_POST['construction_extra_urls']) as $url) {
|
||||
$extra_urls[] = trim($url);
|
||||
}
|
||||
if (!empty($_POST['saveconfig']))
|
||||
{
|
||||
try
|
||||
{
|
||||
$flag = (empty($_POST['construction_flag']))?false:true;
|
||||
|
||||
$s->put('construction_flag',$flag,'boolean','Construction blog flag');
|
||||
$all_ip = explode("\n",$_POST['construction_allowed_ip']);
|
||||
foreach ($all_ip as $ip) {
|
||||
$allowed_ip[] = trim($ip);
|
||||
}
|
||||
$urls = explode(",",$_POST['construction_extra_urls']);
|
||||
foreach ($urls as $url) {
|
||||
$extra_urls[] = trim($url);
|
||||
}
|
||||
$s->put('construction_allowed_ip',serialize($allowed_ip),'string','Construction blog allowed ip');
|
||||
$s->put('construction_title',$_POST['construction_title'],'string','Construction blog title');
|
||||
$s->put('construction_message',$_POST['construction_message'],'string','Construction blog message');
|
||||
$s->put('construction_extra_urls',serialize($extra_urls),'string','Construction extra allowed URLs');
|
||||
$s->put('flag', empty($_POST['construction_flag']) ? false : true);
|
||||
$s->put('allowed_ip', json_encode($allowed_ip));
|
||||
$s->put('title', $_POST['construction_title']);
|
||||
$s->put('message', $_POST['construction_message']);
|
||||
$s->put('extra_urls', json_encode($extra_urls));
|
||||
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
http::redirect($p_url.'&saved=1');
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
|
||||
dcAdminNotices::addSuccessNotice(
|
||||
__('Settings successfully updated.')
|
||||
);
|
||||
|
||||
dcCore::app()->adminurl->redirect(
|
||||
'admin.plugin.' . basename(__DIR__)
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$nb_rows = count(unserialize($s->construction_allowed_ip));
|
||||
$nb_rows = count(json_decode($s->get('allowed_ip'), true));
|
||||
if ($nb_rows < 2) {
|
||||
$nb_rows = 2;
|
||||
$nb_rows = 2;
|
||||
} elseif ($nb_rows > 10) {
|
||||
$nb_rows = 10;
|
||||
$nb_rows = 10;
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $page_title; ?></title>
|
||||
<?php echo dcPage::jsToolBar().
|
||||
$admin_post_behavior.
|
||||
dcPage::jsConfirmClose('opts-forms').
|
||||
dcPage::jsLoad('index.php?pf=construction/js/config.js'); ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
echo dcPage::breadcrumb(
|
||||
array(
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
'<span class="page-title">'.$page_title.'</span>' => ''
|
||||
));
|
||||
|
||||
if (!empty($msg)) {
|
||||
dcPage::message($msg);}
|
||||
if (!empty($_GET['saved'])) {
|
||||
dcPage::success(__('Configuration successfully updated.'));
|
||||
}
|
||||
|
||||
echo '<div id="construction_options">
|
||||
<form method="post" action="'.$p_url.'">
|
||||
$editor = dcCore::app()->auth->getOption('editor');
|
||||
|
||||
echo '
|
||||
<html><head><title>' . __('Construction') . '</title>' .
|
||||
dcPage::jsConfirmClose('opts-forms') .
|
||||
dcCore::app()->callBehavior('adminPostEditor', $editor['xhtml'], 'construction', ['#construction_message'], 'xhtml') .
|
||||
dcPage::jsModuleLoad(basename(__DIR__) . '/js/index.js') . '
|
||||
</head><body>' .
|
||||
|
||||
dcPage::breadcrumb([
|
||||
__('Plugins') => '',
|
||||
__('Construction') => '',
|
||||
]) .
|
||||
dcPage::notices() . '
|
||||
|
||||
<div id="construction_options">
|
||||
<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '">
|
||||
<div class="fieldset">
|
||||
<h4>'.__('Configuration').'</h4>
|
||||
<p class="field">'.
|
||||
form::checkbox('construction_flag', 1, $s->construction_flag).
|
||||
'<label class="classic" for="construction_flag">'.__('Plugin activation').'</label>
|
||||
<h4>' . __('Configuration') . '</h4>
|
||||
|
||||
<p class="field">' .
|
||||
form::checkbox('construction_flag', 1, $s->get('flag')) . '
|
||||
<label class="classic" for="construction_flag">' . __('Plugin activation') . '</label>
|
||||
</p>
|
||||
<p><label for="construction_allowed_ip">'.__('Allowed IP:').' </label>'.
|
||||
form::textarea('construction_allowed_ip',20,$nb_rows,html::escapeHTML(implode("\n",unserialize($s->construction_allowed_ip)))).
|
||||
|
||||
<p><label for="construction_allowed_ip">' . __('Allowed IP:') . '</label> ' .
|
||||
form::textarea('construction_allowed_ip', 20, $nb_rows, html::escapeHTML(implode("\n", json_decode($s->get('allowed_ip'), true)))) .
|
||||
'</p>
|
||||
<p class="info">'.sprintf(__('Your IP is <strong>%s</strong> - the allowed IP can view the blog normally.'),$myip).'</p>
|
||||
<p class="area"><label for="construction_extra_urls">'.__('Extra allowed URL types:').'</label>'.
|
||||
form::field('construction_extra_urls',20,255,html::escapeHTML(implode(',',unserialize($s->construction_extra_urls))),'maximal').
|
||||
<p class="form-note">' . sprintf(__('Your IP is <strong>%s</strong> - the allowed IP can view the blog normally.'), (string) http::realIP()) . '</p>
|
||||
|
||||
<p class="area"><label for="construction_extra_urls">' . __('Extra allowed URL types:') . '</label>' .
|
||||
form::field('construction_extra_urls', 20, 255, html::escapeHTML(implode(',', json_decode($s->get('extra_urls'), true))), 'maximal') .
|
||||
'</p>
|
||||
|
||||
</div>
|
||||
<div class="fieldset">
|
||||
<h4>'.__('Presentation').'</h4>
|
||||
<p class="area"><label for="construction_title">'.__('Title:').'</label>'.
|
||||
form::field('construction_title',20,255,html::escapeHTML($s->construction_title),'maximal').
|
||||
<h4>' . __('Presentation') . '</h4>
|
||||
<p class="area"><label for="construction_title">' . __('Title:') . '</label>' .
|
||||
form::field('construction_title', 20, 255, html::escapeHTML($s->get('title')), 'maximal') .
|
||||
'</p>
|
||||
<p class="area"><label for="construction_message">'.__('Message:').'</label>'.
|
||||
form::textarea('construction_message',40,10,html::escapeHTML($s->construction_message)).
|
||||
|
||||
<p class="area"><label for="construction_message">' . __('Message:') . '</label>' .
|
||||
form::textarea('construction_message', 40, 10, html::escapeHTML($s->get('message'))) .
|
||||
'</p>
|
||||
</div>
|
||||
<p>'.form::hidden(array('p'),'construction').
|
||||
dcCore::app()->formNonce().
|
||||
'<input type="submit" name="saveconfig" value="'.__('Save').'" />
|
||||
<p>' .
|
||||
form::hidden(['p'], 'construction') .
|
||||
dcCore::app()->formNonce() . '
|
||||
<input type="submit" name="saveconfig" value="' . __('Save') . '" />
|
||||
</p>
|
||||
</form>
|
||||
</div>';
|
||||
?>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>';
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
$(function() {
|
||||
if ($.isFunction(jsToolBar)) {
|
||||
var tbUser = new jsToolBar(document.getElementById('construction_message'));
|
||||
tbUser.draw('xhtml');
|
||||
}
|
||||
});
|
12
js/index.js
Normal file
12
js/index.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*global $, dotclear, jsToolBar */
|
||||
'use strict';
|
||||
|
||||
$(() => {
|
||||
if (typeof jsToolBar === 'function') {
|
||||
$('#disclaimer_text').each(function () {
|
||||
const tbWidgetTextDisclaimer = new jsToolBar(this);
|
||||
tbWidgetTextDisclaimer.context = 'disclaimer_text';
|
||||
tbWidgetTextDisclaimer.draw('xhtml');
|
||||
});
|
||||
}
|
||||
});
|
|
@ -1,39 +1,22 @@
|
|||
<?php
|
||||
// Language: Français
|
||||
// Module: construction - 1.3.1
|
||||
// Date: 2018-02-18 16:09:52
|
||||
// Translated with dcTranslater - 2018.02.14
|
||||
|
||||
#_admin.php:24
|
||||
#_admin.php:41
|
||||
#index.php:15
|
||||
$GLOBALS['__l10n']['Construction'] = 'Construction';
|
||||
|
||||
#_install.php:43
|
||||
$GLOBALS['__l10n']['Work in progress'] = 'Travaux en cours';
|
||||
|
||||
#_install.php:51
|
||||
$GLOBALS['__l10n']['<p>The blog is currently under construction.</p>'] = '<p>Le blog est actuellement en construction.</p>';
|
||||
|
||||
#index.php:94
|
||||
$GLOBALS['__l10n']['Configuration'] = 'Configuration';
|
||||
|
||||
#index.php:99
|
||||
$GLOBALS['__l10n']['Allowed IP:'] = 'IP autorisées :';
|
||||
|
||||
#index.php:102
|
||||
$GLOBALS['__l10n']['Your IP is <strong>%s</strong> - the allowed IP can view the blog normally.'] = 'Votre IP est <strong>%s</strong> - les IP autorisées peuvent visualiser le blog normalement.';
|
||||
|
||||
#index.php:103
|
||||
$GLOBALS['__l10n']['Extra allowed URL types:'] = 'Autres types d\'URL autorisées :';
|
||||
|
||||
#index.php:108
|
||||
$GLOBALS['__l10n']['Presentation'] = 'Présentation';
|
||||
|
||||
#index.php:112
|
||||
$GLOBALS['__l10n']['Message:'] = 'Message :';
|
||||
|
||||
$GLOBALS['__l10n']['Place your blog maintenance'] = 'Mettez votre blog en maintenance';
|
||||
|
||||
$GLOBALS['__l10n']['construction'] = 'construction';
|
||||
/**
|
||||
* @package Dotclear
|
||||
*
|
||||
* @copyright Olivier Meunier & Association Dotclear
|
||||
* @copyright GPL-2.0-only
|
||||
*/
|
||||
#
|
||||
# DOT NOT MODIFY THIS FILE !
|
||||
#
|
||||
|
||||
l10n::$locales['Construction'] = 'Construction';
|
||||
l10n::$locales['Work in progress'] = 'Travaux en cours';
|
||||
l10n::$locales['<p>The blog is currently under construction.</p>'] = '<p>Le blog est actuellement en construction.</p>';
|
||||
l10n::$locales['Settings successfully updated.'] = 'Paramètres mis à jour.';
|
||||
l10n::$locales['Configuration'] = 'Configuration';
|
||||
l10n::$locales['Allowed IP:'] = 'IP autorisées :';
|
||||
l10n::$locales['Your IP is <strong>%s</strong> - the allowed IP can view the blog normally.'] = 'Votre IP est <strong>%s</strong> - les IP autorisées peuvent visualiser le blog normalement.';
|
||||
l10n::$locales['Extra allowed URL types:'] = 'Autres types d\'URL autorisées :';
|
||||
l10n::$locales['Presentation'] = 'Présentation';
|
||||
l10n::$locales['Message:'] = 'Message :';
|
||||
l10n::$locales['Place your blog maintenance'] = 'Mettez votre blog en maintenance';
|
||||
|
|
|
@ -1,61 +1,45 @@
|
|||
# Language: Français
|
||||
# Module: construction - 1.3.1
|
||||
# Date: 2018-02-18 16:09:52
|
||||
# Translated with translater 2018.02.14
|
||||
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: construction 1.3.1\n"
|
||||
"Project-Id-Version: construction 1.5\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: 2018-02-18T16:09:52+00:00\n"
|
||||
"Last-Translator: brol\n"
|
||||
"PO-Revision-Date: 2022-12-31T18:01:51+00:00\n"
|
||||
"Last-Translator: Jean-Christian Denis\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: _admin.php:24
|
||||
#: _admin.php:41
|
||||
#: index.php:15
|
||||
msgid "Construction"
|
||||
msgstr "Construction"
|
||||
|
||||
#: _install.php:43
|
||||
msgid "Work in progress"
|
||||
msgstr "Travaux en cours"
|
||||
|
||||
#: _install.php:51
|
||||
msgid "<p>The blog is currently under construction.</p>"
|
||||
msgstr "<p>Le blog est actuellement en construction.</p>"
|
||||
|
||||
#: index.php:94
|
||||
msgid "Settings successfully updated."
|
||||
msgstr "Paramètres mis à jour."
|
||||
|
||||
msgid "Configuration"
|
||||
msgstr "Configuration"
|
||||
|
||||
#: index.php:99
|
||||
msgid "Allowed IP:"
|
||||
msgstr "IP autorisées :"
|
||||
|
||||
#: index.php:102
|
||||
msgid "Your IP is <strong>%s</strong> - the allowed IP can view the blog normally."
|
||||
msgstr "Votre IP est <strong>%s</strong> - les IP autorisées peuvent visualiser le blog normalement."
|
||||
|
||||
#: index.php:103
|
||||
msgid "Extra allowed URL types:"
|
||||
msgstr "Autres types d'URL autorisées :"
|
||||
|
||||
#: index.php:108
|
||||
msgid "Presentation"
|
||||
msgstr "Présentation"
|
||||
|
||||
#: index.php:112
|
||||
msgid "Message:"
|
||||
msgstr "Message :"
|
||||
|
||||
msgid "Place your blog maintenance"
|
||||
msgstr "Mettez votre blog en maintenance"
|
||||
|
||||
msgid "construction"
|
||||
msgstr "construction"
|
||||
|
||||
|
|
Loading…
Reference in a new issue