release 2023.10.07
This commit is contained in:
parent
41d0f50ba1
commit
c5ce39d983
@ -1,3 +1,9 @@
|
|||||||
|
myUrlHandlers 2023.10.07
|
||||||
|
===========================================================
|
||||||
|
* Require Dotclear 2.28
|
||||||
|
* Require PHP 8.1
|
||||||
|
* Upgrade to Dotclear 2.28
|
||||||
|
|
||||||
myUrlHandlers 2023.08.13
|
myUrlHandlers 2023.08.13
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.27
|
* Require Dotclear 2.27
|
||||||
|
27
README.md
27
README.md
@ -1,26 +1,22 @@
|
|||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases)
|
[![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases)
|
||||||
[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases)
|
![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/myUrlHandlers)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/myUrlHandlers)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/myUrlHandlers)](https://git.dotclear.watch/JcDenis/myUrlHandlers/blob/master/LICENSE)
|
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/myUrlHandlers/src/branch/master/LICENSE)
|
||||||
|
|
||||||
## WHAT IS MYURLHANLDERS ?
|
## ABOUT
|
||||||
|
|
||||||
_myUrlHandlers_ is a plugin for the open-source
|
_myUrlHandlers_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||||
web publishing software called Dotclear.
|
|
||||||
|
|
||||||
You can change public URL of each Dotclear parts,
|
> You can change public URL of each Dotclear parts, like post, category, etc and some plugins having public parts.
|
||||||
like post, category, etc and some plugins having public parts.
|
|
||||||
|
|
||||||
## REQUIREMENTS
|
## REQUIREMENTS
|
||||||
|
|
||||||
_myUrlHandlers_ requires:
|
|
||||||
|
|
||||||
* contentadmin permissions for management
|
* contentadmin permissions for management
|
||||||
* Dotclear 2.27
|
* Dotclear 2.28
|
||||||
* PHP 7.4+
|
* PHP 8.1+
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
@ -32,10 +28,11 @@ or you can add dashboard icon.
|
|||||||
|
|
||||||
## LINKS
|
## LINKS
|
||||||
|
|
||||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
* [License](https://git.dotclear.watch/JcDenis/myUrlHandlers/src/branch/master/LICENSE)
|
||||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/myUrlHandlers) or [GitHub Page](https://github.com/JcDenis/myUrlHandlers)
|
* [Packages & details](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/myUrlHandlers/alias))
|
||||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/myUrlHandlers)
|
* [Sources & contributions](https://git.dotclear.watch/JcDenis/myUrlHandlers) (or on [GitHub](https://github.com/JcDenis/myUrlHandlers))
|
||||||
* Discuss and help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=40893)
|
* [Issues & security](https://git.dotclear.watch/JcDenis/myUrlHandlers/issues) (or on [GitHub](https://github.com/JcDenis/myUrlHandlers/issues))
|
||||||
|
* [Discuss and help](https://forum.dotclear.org/viewtopic.php?id=40893)
|
||||||
|
|
||||||
## CONTRIBUTORS
|
## CONTRIBUTORS
|
||||||
|
|
||||||
|
10
_define.php
10
_define.php
@ -10,9 +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')) {
|
use Dotclear\App;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
'URL handlers',
|
'URL handlers',
|
||||||
@ -20,9 +18,9 @@ $this->registerModule(
|
|||||||
'Alex Pirine and contributors',
|
'Alex Pirine and contributors',
|
||||||
'2023.08.13',
|
'2023.08.13',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.27']],
|
'requires' => [['core', '2.28']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => App::auth()->makePermissions([
|
||||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||||
]),
|
]),
|
||||||
'priority' => 150000,
|
'priority' => 150000,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<version>2023.08.13</version>
|
<version>2023.08.13</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://git.dotclear.watch/JcDenis/myUrlHandlers/releases/download/v2023.08.13/plugin-myUrlHandlers.zip</file>
|
<file>https://github.com/JcDenis/myUrlHandlers/releases/download/v2023.08.13/plugin-myUrlHandlers.zip</file>
|
||||||
<da:dcmin>2.27</da:dcmin>
|
<da:dcmin>2.27</da:dcmin>
|
||||||
<da:details>https://git.dotclear.watch/JcDenis/myUrlHandlers/src/branch/master/README.md</da:details>
|
<da:details>https://git.dotclear.watch/JcDenis/myUrlHandlers/src/branch/master/README.md</da:details>
|
||||||
<da:support>https://git.dotclear.watch/JcDenis/myUrlHandlers/issues</da:support>
|
<da:support>https://git.dotclear.watch/JcDenis/myUrlHandlers/issues</da:support>
|
||||||
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\myUrlHandlers;
|
namespace Dotclear\Plugin\myUrlHandlers;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Core\Backend\Favorites;
|
use Dotclear\Core\Backend\Favorites;
|
||||||
|
|
||||||
@ -34,13 +34,13 @@ class Backend extends Process
|
|||||||
My::addBackendMenuItem();
|
My::addBackendMenuItem();
|
||||||
|
|
||||||
// register user backend dashboard icon
|
// register user backend dashboard icon
|
||||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void {
|
App::behavior()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void {
|
||||||
$favs->register(My::id(), [
|
$favs->register(My::id(), [
|
||||||
'title' => My::name(),
|
'title' => My::name(),
|
||||||
'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_CONTENT_ADMIN]),
|
'permissions' => App::auth()->makePermissions([App::auth()::PERMISSION_CONTENT_ADMIN]),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,8 +14,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\myUrlHandlers;
|
namespace Dotclear\Plugin\myUrlHandlers;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use dcNamespace;
|
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
class Install extends Process
|
class Install extends Process
|
||||||
@ -46,24 +45,24 @@ class Install extends Process
|
|||||||
|
|
||||||
private static function growUp(): void
|
private static function growUp(): void
|
||||||
{
|
{
|
||||||
$current = dcCore::app()->getVersion(My::id());
|
$current = App::version()->getVersion(My::id());
|
||||||
|
|
||||||
// Update settings id, ns, value
|
// Update settings id, ns, value
|
||||||
if ($current && version_compare($current, '2023.03.11', '<')) {
|
if ($current && version_compare($current, '2023.03.11', '<')) {
|
||||||
$record = dcCore::app()->con->select(
|
$record = App::con()->select(
|
||||||
'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' .
|
'SELECT * FROM ' . App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME . ' ' .
|
||||||
"WHERE setting_ns = 'myurlhandlers' AND setting_id = 'url_handlers' "
|
"WHERE setting_ns = 'myurlhandlers' AND setting_id = 'url_handlers' "
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($record->fetch()) {
|
while ($record->fetch()) {
|
||||||
$value = @unserialize($record->f('setting_value'));
|
$value = @unserialize($record->f('setting_value'));
|
||||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
$cur = App::blogWorkspace()->openBlogWorkspaceCursor();
|
||||||
$cur->setField('setting_id', My::NS_SETTING_ID);
|
$cur->setField('setting_id', My::NS_SETTING_ID);
|
||||||
$cur->setField('setting_ns', My::id());
|
$cur->setField('setting_ns', My::id());
|
||||||
$cur->setField('setting_value', json_encode(is_array($value) ? $value : []));
|
$cur->setField('setting_value', json_encode(is_array($value) ? $value : []));
|
||||||
$cur->update(
|
$cur->update(
|
||||||
"WHERE setting_id = '" . $record->f('setting_id') . "' and setting_ns = '" . $record->f('setting_ns') . "' " .
|
"WHERE setting_id = '" . $record->f('setting_id') . "' and setting_ns = '" . $record->f('setting_ns') . "' " .
|
||||||
'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . dcCore::app()->con->escapeStr((string) $record->f('blog_id')) . "' "))
|
'AND blog_id ' . (null === $record->f('blog_id') ? 'IS NULL ' : ("= '" . App::con()->escapeStr((string) $record->f('blog_id')) . "' "))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\myUrlHandlers;
|
namespace Dotclear\Plugin\myUrlHandlers;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Core\Backend\{
|
use Dotclear\Core\Backend\{
|
||||||
Notices,
|
Notices,
|
||||||
@ -103,7 +103,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());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -122,7 +122,7 @@ class Manage extends Process
|
|||||||
echo
|
echo
|
||||||
Page::breadcrumb(
|
Page::breadcrumb(
|
||||||
[
|
[
|
||||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
Html::escapeHTML(App::blog()->name()) => '',
|
||||||
My::name() => '',
|
My::name() => '',
|
||||||
]
|
]
|
||||||
) .
|
) .
|
||||||
@ -133,7 +133,7 @@ class Manage extends Process
|
|||||||
'<p class="message">' . __('No URL handler to configure.') . '</p>';
|
'<p class="message">' . __('No URL handler to configure.') . '</p>';
|
||||||
} else {
|
} else {
|
||||||
echo
|
echo
|
||||||
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post">' .
|
'<form action="' . App::backend()->getPageURL() . '" method="post">' .
|
||||||
'<div class="table-outer">' .
|
'<div class="table-outer">' .
|
||||||
'<table>' .
|
'<table>' .
|
||||||
'<caption>' . __('URL handlers list') . '</caption>' .
|
'<caption>' . __('URL handlers list') . '</caption>' .
|
||||||
@ -168,6 +168,11 @@ class Manage extends Process
|
|||||||
Page::closeModule();
|
Page::closeModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get handlers.
|
||||||
|
*
|
||||||
|
* @return array<string,string> The handlers
|
||||||
|
*/
|
||||||
private static function getHandlers(): array
|
private static function getHandlers(): array
|
||||||
{
|
{
|
||||||
# Read default handlers
|
# Read default handlers
|
||||||
|
@ -14,17 +14,30 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\myUrlHandlers;
|
namespace Dotclear\Plugin\myUrlHandlers;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\App;
|
||||||
|
use Dotclear\Core\PostType;
|
||||||
|
|
||||||
class MyUrlHandlers
|
class MyUrlHandlers
|
||||||
{
|
{
|
||||||
/** @var array $defaults The default URLs handlers */
|
/**
|
||||||
|
* The default URLs handlers.
|
||||||
|
*
|
||||||
|
* @var array<string,array<string,string>> $defaults
|
||||||
|
*/
|
||||||
private static array $defaults = [];
|
private static array $defaults = [];
|
||||||
|
|
||||||
/** @var array $url2post The posts types URLs */
|
/**
|
||||||
|
* The posts types URLs.
|
||||||
|
*
|
||||||
|
* @var array<string,string> $url2post
|
||||||
|
*/
|
||||||
private static array $url2post = [];
|
private static array $url2post = [];
|
||||||
|
|
||||||
/** @var array $post_adm_url The posts types admin URLs */
|
/**
|
||||||
|
* The posts types admin URLs.
|
||||||
|
*
|
||||||
|
* @var array<string,string> $post_adm_url
|
||||||
|
*/
|
||||||
private static array $post_adm_url = [];
|
private static array $post_adm_url = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +46,7 @@ class MyUrlHandlers
|
|||||||
public static function init(): void
|
public static function init(): void
|
||||||
{
|
{
|
||||||
# Set defaults
|
# Set defaults
|
||||||
foreach (dcCore::app()->url->getTypes() as $k => $v) {
|
foreach (App::url()->getTypes() as $k => $v) {
|
||||||
if (empty($v['url'])) {
|
if (empty($v['url'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -47,9 +60,9 @@ class MyUrlHandlers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (dcCore::app()->getPostTypes() as $k => $v) {
|
foreach (App::postTypes()->dump() as $pt) {
|
||||||
self::$url2post[$v['public_url']] = $k;
|
self::$url2post[$pt->public_url] = $pt->type;
|
||||||
self::$post_adm_url[$k] = $v['admin_url'];
|
self::$post_adm_url[$pt->type] = $pt->admin_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read user settings
|
# Read user settings
|
||||||
@ -70,7 +83,7 @@ class MyUrlHandlers
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->url->register(
|
App::url()->register(
|
||||||
$name,
|
$name,
|
||||||
$url,
|
$url,
|
||||||
sprintf(self::$defaults[$name]['representation'], $url),
|
sprintf(self::$defaults[$name]['representation'], $url),
|
||||||
@ -80,14 +93,18 @@ class MyUrlHandlers
|
|||||||
$k = self::$url2post[self::$defaults[$name]['url'] . '/%s'] ?? '';
|
$k = self::$url2post[self::$defaults[$name]['url'] . '/%s'] ?? '';
|
||||||
|
|
||||||
if ($k) {
|
if ($k) {
|
||||||
dcCore::app()->setPostType($k, self::$post_adm_url[$k], dcCore::app()->url->getBase($name) . '/%s');
|
App::postTypes()->set(new PostType(
|
||||||
|
$k,
|
||||||
|
self::$post_adm_url[$k],
|
||||||
|
App::url()->getBase($name) . '/%s'
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get default URLs handlers
|
* Get default URLs handlers.
|
||||||
*
|
*
|
||||||
* @return array The default URLs handlers
|
* @return array<string,string> The default URLs handlers
|
||||||
*/
|
*/
|
||||||
public static function getDefaults(): array
|
public static function getDefaults(): array
|
||||||
{
|
{
|
||||||
@ -102,29 +119,23 @@ class MyUrlHandlers
|
|||||||
/**
|
/**
|
||||||
* Get custom blog URLs handlers.
|
* Get custom blog URLs handlers.
|
||||||
*
|
*
|
||||||
* @return array The blog URLs handlers
|
* @return array<string,string> The blog URLs handlers
|
||||||
*/
|
*/
|
||||||
public static function getBlogHandlers(): array
|
public static function getBlogHandlers(): array
|
||||||
{
|
{
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
$handlers = json_decode((string) My::settings()->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 : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save custom URLs handlers
|
* Save custom URLs handlers.
|
||||||
*
|
*
|
||||||
* @param array $handlers The custom URLs handlers
|
* @param array<string,string> $handlers The custom URLs handlers
|
||||||
*/
|
*/
|
||||||
public static function saveBlogHandlers(array $handlers): void
|
public static function saveBlogHandlers(array $handlers): void
|
||||||
{
|
{
|
||||||
if (is_null(dcCore::app()->blog)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
My::settings()->put(My::NS_SETTING_ID, json_encode($handlers));
|
My::settings()->put(My::NS_SETTING_ID, json_encode($handlers));
|
||||||
dcCore::app()->blog->triggerBlog();
|
App::blog()->triggerBlog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Dotclear\Plugin\myUrlHandlers;
|
namespace Dotclear\Plugin\myUrlHandlers;
|
||||||
|
|
||||||
use dcCore;
|
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||||
|
|
||||||
@ -27,7 +26,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user