release 2023.07.29
This commit is contained in:
parent
27337e065f
commit
1f2fd02790
@ -1,3 +1,8 @@
|
|||||||
|
2023.07.29
|
||||||
|
* require dotclear 2.27
|
||||||
|
* require PHP 7.4+
|
||||||
|
* update to dotclear 2.27-dev
|
||||||
|
|
||||||
2023.05.13
|
2023.05.13
|
||||||
* require dotclear 2.26
|
* require dotclear 2.26
|
||||||
* cleanup for dc2.26 stable
|
* cleanup for dc2.26 stable
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
[![Release](https://img.shields.io/github/v/release/JcDenis/myUrlHandlers)](https://github.com/JcDenis/myUrlHandlers/releases)
|
[![Release](https://img.shields.io/github/v/release/JcDenis/myUrlHandlers)](https://github.com/JcDenis/myUrlHandlers/releases)
|
||||||
[![Date](https://img.shields.io/github/release-date/JcDenis/myUrlHandlers)](https://github.com/JcDenis/myUrlHandlers/releases)
|
[![Date](https://img.shields.io/github/release-date/JcDenis/myUrlHandlers)](https://github.com/JcDenis/myUrlHandlers/releases)
|
||||||
[![Issues](https://img.shields.io/github/issues/JcDenis/myUrlHandlers)](https://github.com/JcDenis/myUrlHandlers/issues)
|
[![Issues](https://img.shields.io/github/issues/JcDenis/myUrlHandlers)](https://github.com/JcDenis/myUrlHandlers/issues)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.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-green.svg)](https://plugins.dotaddict.org/dc2/details/myUrlHandlers)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/myUrlHandlers)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/myUrlHandlers)](https://github.com/JcDenis/myUrlHandlers/blob/master/LICENSE)
|
[![License](https://img.shields.io/github/license/JcDenis/myUrlHandlers)](https://github.com/JcDenis/myUrlHandlers/blob/master/LICENSE)
|
||||||
|
|
||||||
@ -20,7 +20,8 @@ like post, category, etc and some plugins having public parts.
|
|||||||
_myUrlHandlers_ requires:
|
_myUrlHandlers_ requires:
|
||||||
|
|
||||||
* contentadmin permissions for management
|
* contentadmin permissions for management
|
||||||
* Dotclear 2.26
|
* Dotclear 2.27
|
||||||
|
* PHP 7.4+
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,9 +18,9 @@ $this->registerModule(
|
|||||||
'URL handlers',
|
'URL handlers',
|
||||||
'Change Dotclear URL handlers',
|
'Change Dotclear URL handlers',
|
||||||
'Alex Pirine and contributors',
|
'Alex Pirine and contributors',
|
||||||
'2023.05.13',
|
'2023.07.29',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.26']],
|
'requires' => [['core', '2.27']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||||
]),
|
]),
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="myUrlHandlers">
|
<module id="myUrlHandlers">
|
||||||
<name>URL handlers</name>
|
<name>URL handlers</name>
|
||||||
<version>2023.05.13</version>
|
<version>2023.07.29</version>
|
||||||
<author>Alex Pirine and contributors</author>
|
<author>Alex Pirine and contributors</author>
|
||||||
<desc>Change Dotclear URL handlers</desc>
|
<desc>Change Dotclear URL handlers</desc>
|
||||||
<file>https://github.com/JcDenis/myUrlHandlers/releases/download/v2023.05.13/plugin-myUrlHandlers.zip</file>
|
<file>https://github.com/JcDenis/myUrlHandlers/releases/download/v2023.07.29/plugin-myUrlHandlers.zip</file>
|
||||||
<da:dcmin>2.26</da:dcmin>
|
<da:dcmin>2.27</da:dcmin>
|
||||||
<da:details>http://plugins.dotaddict.org/dc2/details/myUrlHandlers</da:details>
|
<da:details>http://plugins.dotaddict.org/dc2/details/myUrlHandlers</da:details>
|
||||||
<da:support>https://github.com/JcDenis/myUrlHandlers</da:support>
|
<da:support>https://github.com/JcDenis/myUrlHandlers</da:support>
|
||||||
</module>
|
</module>
|
||||||
|
@ -14,46 +14,32 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\myUrlHandlers;
|
namespace Dotclear\Plugin\myUrlHandlers;
|
||||||
|
|
||||||
use dcAdmin;
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcFavorites;
|
use Dotclear\Core\Process;
|
||||||
use dcPage;
|
use Dotclear\Core\backend\Favorites;
|
||||||
use dcNsProcess;
|
|
||||||
|
|
||||||
class Backend extends dcNsProcess
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
return self::status(My::checkContext(My::BACKEND));
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init || is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add backend sidebar menu icon
|
My::addBackendMenuItem();
|
||||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
|
||||||
My::name(),
|
|
||||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
|
||||||
dcPage::getPF(My::id() . '/icon.svg'),
|
|
||||||
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
|
||||||
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)
|
|
||||||
);
|
|
||||||
|
|
||||||
// register user backend dashboard icon
|
// register user backend dashboard icon
|
||||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void {
|
||||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$favs->register(My::id(), [
|
$favs->register(My::id(), [
|
||||||
'title' => My::name(),
|
'title' => My::name(),
|
||||||
'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
'url' => My::manageUrl(),
|
||||||
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
'small-icon' => My::icons(),
|
||||||
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
'large-icon' => My::icons(),
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]),
|
'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
@ -16,27 +16,24 @@ namespace Dotclear\Plugin\myUrlHandlers;
|
|||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNamespace;
|
use dcNamespace;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
class Install extends dcNsProcess
|
class Install extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
return self::status(My::checkContext(My::INSTALL));
|
||||||
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init || is_null(dcCore::app()->blog)) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::growUp();
|
self::growUp();
|
||||||
|
|
||||||
dcCore::app()->blog->settings->get(My::id())->put(
|
My::settings()->put(
|
||||||
My::NS_SETTING_ID,
|
My::NS_SETTING_ID,
|
||||||
json_encode([]),
|
json_encode([]),
|
||||||
'string',
|
'string',
|
||||||
|
@ -15,8 +15,11 @@ declare(strict_types=1);
|
|||||||
namespace Dotclear\Plugin\myUrlHandlers;
|
namespace Dotclear\Plugin\myUrlHandlers;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
use dcPage;
|
use Dotclear\Core\Backend\{
|
||||||
|
Notices,
|
||||||
|
Page
|
||||||
|
};
|
||||||
use Dotclear\Helper\Html\Form\Input;
|
use Dotclear\Helper\Html\Form\Input;
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Dotclear\Helper\Text;
|
use Dotclear\Helper\Text;
|
||||||
@ -25,22 +28,16 @@ use Exception;
|
|||||||
/**
|
/**
|
||||||
* Manage contributions list
|
* Manage contributions list
|
||||||
*/
|
*/
|
||||||
class Manage extends dcNsProcess
|
class Manage extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
return self::status(My::checkContext(My::MANAGE));
|
||||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog)
|
|
||||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
|
||||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
|
||||||
]), dcCore::app()->blog->id);
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init || is_null(dcCore::app()->adminurl)) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,12 +95,12 @@ class Manage extends dcNsProcess
|
|||||||
|
|
||||||
if (isset($_POST['act_save'])) {
|
if (isset($_POST['act_save'])) {
|
||||||
MyUrlHandlers::saveBlogHandlers($handlers);
|
MyUrlHandlers::saveBlogHandlers($handlers);
|
||||||
dcPage::addSuccessNotice(__('URL handlers have been successfully updated.'));
|
Notices::addSuccessNotice(__('URL handlers have been successfully updated.'));
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
|
My::redirect();
|
||||||
} elseif (isset($_POST['act_restore'])) {
|
} elseif (isset($_POST['act_restore'])) {
|
||||||
MyUrlHandlers::saveBlogHandlers([]);
|
MyUrlHandlers::saveBlogHandlers([]);
|
||||||
dcPage::addSuccessNotice(__('URL handlers have been successfully restored.'));
|
Notices::addSuccessNotice(__('URL handlers have been successfully restored.'));
|
||||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
|
My::redirect();
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
@ -114,22 +111,22 @@ class Manage extends dcNsProcess
|
|||||||
|
|
||||||
public static function render(): void
|
public static function render(): void
|
||||||
{
|
{
|
||||||
if (!static::$init || is_null(dcCore::app()->blog)) {
|
if (!self::status()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$handlers = self::getHandlers();
|
$handlers = self::getHandlers();
|
||||||
|
|
||||||
dcPage::openModule(My::name());
|
Page::openModule(My::name());
|
||||||
|
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb(
|
Page::breadcrumb(
|
||||||
[
|
[
|
||||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||||
My::name() => '',
|
My::name() => '',
|
||||||
]
|
]
|
||||||
) .
|
) .
|
||||||
dcPage::notices();
|
Notices::getNotices();
|
||||||
|
|
||||||
if (empty($handlers)) {
|
if (empty($handlers)) {
|
||||||
echo
|
echo
|
||||||
@ -164,11 +161,11 @@ class Manage extends dcNsProcess
|
|||||||
'<p>' .
|
'<p>' .
|
||||||
'<input type="submit" name="act_save" value="' . __('Save') . '" /> ' .
|
'<input type="submit" name="act_save" value="' . __('Save') . '" /> ' .
|
||||||
'<input class="delete" type="submit" name="act_restore" value="' . __('Reset') . '" />' .
|
'<input class="delete" type="submit" name="act_restore" value="' . __('Reset') . '" />' .
|
||||||
dcCore::app()->formNonce() . '</p>' .
|
My::parsedHiddenFields() . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::closeModule();
|
Page::closeModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getHandlers(): array
|
private static function getHandlers(): array
|
||||||
|
33
src/My.php
33
src/My.php
@ -14,39 +14,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\myUrlHandlers;
|
namespace Dotclear\Plugin\myUrlHandlers;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
class My extends MyPlugin
|
||||||
* This module definitions.
|
|
||||||
*/
|
|
||||||
class My
|
|
||||||
{
|
{
|
||||||
/** @var string This module settings ID */
|
/** @var string This module settings ID */
|
||||||
public const NS_SETTING_ID = 'handlers';
|
public const NS_SETTING_ID = 'handlers';
|
||||||
|
|
||||||
/**
|
|
||||||
* This module id.
|
|
||||||
*/
|
|
||||||
public static function id(): string
|
|
||||||
{
|
|
||||||
return basename(dirname(__DIR__));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This module name.
|
|
||||||
*/
|
|
||||||
public static function name(): string
|
|
||||||
{
|
|
||||||
$name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
|
|
||||||
|
|
||||||
return __(is_string($name) ? $name : self::id());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This module path.
|
|
||||||
*/
|
|
||||||
public static function path(): string
|
|
||||||
{
|
|
||||||
return dirname(__DIR__);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class MyUrlHandlers
|
|||||||
if (is_null(dcCore::app()->blog)) {
|
if (is_null(dcCore::app()->blog)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$handlers = json_decode((string) dcCore::app()->blog->settings->get(My::id())->get(My::NS_SETTING_ID), true);
|
$handlers = json_decode((string) My::settings()->get(My::NS_SETTING_ID), true);
|
||||||
|
|
||||||
return is_array($handlers) ? $handlers : [];
|
return is_array($handlers) ? $handlers : [];
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ class MyUrlHandlers
|
|||||||
if (is_null(dcCore::app()->blog)) {
|
if (is_null(dcCore::app()->blog)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dcCore::app()->blog->settings->get(My::id())->put(My::NS_SETTING_ID, json_encode($handlers));
|
My::settings()->put(My::NS_SETTING_ID, json_encode($handlers));
|
||||||
dcCore::app()->blog->triggerBlog();
|
dcCore::app()->blog->triggerBlog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,20 +14,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\myUrlHandlers;
|
namespace Dotclear\Plugin\myUrlHandlers;
|
||||||
|
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
class Prepend extends dcNsProcess
|
class Prepend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = true;
|
return self::status(My::checkContext(My::PREPEND));
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,21 +15,19 @@ declare(strict_types=1);
|
|||||||
namespace Dotclear\Plugin\myUrlHandlers;
|
namespace Dotclear\Plugin\myUrlHandlers;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||||
|
|
||||||
class Uninstall extends dcNsProcess
|
class Uninstall extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
return self::status(My::checkContext(My::UNINSTALL));
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user