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
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
|
27
README.md
27
README.md
|
@ -1,26 +1,22 @@
|
|||
# README
|
||||
|
||||
[![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)
|
||||
[![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
|
||||
web publishing software called Dotclear.
|
||||
_myUrlHandlers_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
|
||||
You can change public URL of each Dotclear parts,
|
||||
like post, category, etc and some plugins having public parts.
|
||||
> You can change public URL of each Dotclear parts, like post, category, etc and some plugins having public parts.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
_myUrlHandlers_ requires:
|
||||
|
||||
* contentadmin permissions for management
|
||||
* Dotclear 2.27
|
||||
* PHP 7.4+
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
|
||||
## USAGE
|
||||
|
||||
|
@ -32,10 +28,11 @@ or you can add dashboard icon.
|
|||
|
||||
## LINKS
|
||||
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/myUrlHandlers) or [GitHub Page](https://github.com/JcDenis/myUrlHandlers)
|
||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/myUrlHandlers)
|
||||
* Discuss and help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=40893)
|
||||
* [License](https://git.dotclear.watch/JcDenis/myUrlHandlers/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/myUrlHandlers/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/myUrlHandlers/alias))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/myUrlHandlers) (or on [GitHub](https://github.com/JcDenis/myUrlHandlers))
|
||||
* [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
|
||||
|
||||
|
|
10
_define.php
10
_define.php
|
@ -10,9 +10,7 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
use Dotclear\App;
|
||||
|
||||
$this->registerModule(
|
||||
'URL handlers',
|
||||
|
@ -20,9 +18,9 @@ $this->registerModule(
|
|||
'Alex Pirine and contributors',
|
||||
'2023.08.13',
|
||||
[
|
||||
'requires' => [['core', '2.27']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'priority' => 150000,
|
||||
'type' => 'plugin',
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<version>2023.08.13</version>
|
||||
<author>Alex Pirine and contributors</author>
|
||||
<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: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>
|
||||
|
|
|
@ -14,7 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\myUrlHandlers;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
|
||||
|
@ -34,13 +34,13 @@ class Backend extends Process
|
|||
My::addBackendMenuItem();
|
||||
|
||||
// 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(), [
|
||||
'title' => My::name(),
|
||||
'url' => My::manageUrl(),
|
||||
'small-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;
|
||||
|
||||
use dcCore;
|
||||
use dcNamespace;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
class Install extends Process
|
||||
|
@ -46,24 +45,24 @@ class Install extends Process
|
|||
|
||||
private static function growUp(): void
|
||||
{
|
||||
$current = dcCore::app()->getVersion(My::id());
|
||||
$current = App::version()->getVersion(My::id());
|
||||
|
||||
// Update settings id, ns, value
|
||||
if ($current && version_compare($current, '2023.03.11', '<')) {
|
||||
$record = dcCore::app()->con->select(
|
||||
'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' .
|
||||
$record = App::con()->select(
|
||||
'SELECT * FROM ' . App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME . ' ' .
|
||||
"WHERE setting_ns = 'myurlhandlers' AND setting_id = 'url_handlers' "
|
||||
);
|
||||
|
||||
while ($record->fetch()) {
|
||||
$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_ns', My::id());
|
||||
$cur->setField('setting_value', json_encode(is_array($value) ? $value : []));
|
||||
$cur->update(
|
||||
"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;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
|
@ -103,7 +103,7 @@ class Manage extends Process
|
|||
My::redirect();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -122,7 +122,7 @@ class Manage extends Process
|
|||
echo
|
||||
Page::breadcrumb(
|
||||
[
|
||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
Html::escapeHTML(App::blog()->name()) => '',
|
||||
My::name() => '',
|
||||
]
|
||||
) .
|
||||
|
@ -133,7 +133,7 @@ class Manage extends Process
|
|||
'<p class="message">' . __('No URL handler to configure.') . '</p>';
|
||||
} else {
|
||||
echo
|
||||
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post">' .
|
||||
'<form action="' . App::backend()->getPageURL() . '" method="post">' .
|
||||
'<div class="table-outer">' .
|
||||
'<table>' .
|
||||
'<caption>' . __('URL handlers list') . '</caption>' .
|
||||
|
@ -168,6 +168,11 @@ class Manage extends Process
|
|||
Page::closeModule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get handlers.
|
||||
*
|
||||
* @return array<string,string> The handlers
|
||||
*/
|
||||
private static function getHandlers(): array
|
||||
{
|
||||
# Read default handlers
|
||||
|
|
|
@ -14,17 +14,30 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\myUrlHandlers;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\PostType;
|
||||
|
||||
class MyUrlHandlers
|
||||
{
|
||||
/** @var array $defaults The default URLs handlers */
|
||||
/**
|
||||
* The default URLs handlers.
|
||||
*
|
||||
* @var array<string,array<string,string>> $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 = [];
|
||||
|
||||
/** @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 = [];
|
||||
|
||||
/**
|
||||
|
@ -33,7 +46,7 @@ class MyUrlHandlers
|
|||
public static function init(): void
|
||||
{
|
||||
# Set defaults
|
||||
foreach (dcCore::app()->url->getTypes() as $k => $v) {
|
||||
foreach (App::url()->getTypes() as $k => $v) {
|
||||
if (empty($v['url'])) {
|
||||
continue;
|
||||
}
|
||||
|
@ -47,9 +60,9 @@ class MyUrlHandlers
|
|||
}
|
||||
}
|
||||
|
||||
foreach (dcCore::app()->getPostTypes() as $k => $v) {
|
||||
self::$url2post[$v['public_url']] = $k;
|
||||
self::$post_adm_url[$k] = $v['admin_url'];
|
||||
foreach (App::postTypes()->dump() as $pt) {
|
||||
self::$url2post[$pt->public_url] = $pt->type;
|
||||
self::$post_adm_url[$pt->type] = $pt->admin_url;
|
||||
}
|
||||
|
||||
# Read user settings
|
||||
|
@ -70,7 +83,7 @@ class MyUrlHandlers
|
|||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->url->register(
|
||||
App::url()->register(
|
||||
$name,
|
||||
$url,
|
||||
sprintf(self::$defaults[$name]['representation'], $url),
|
||||
|
@ -80,14 +93,18 @@ class MyUrlHandlers
|
|||
$k = self::$url2post[self::$defaults[$name]['url'] . '/%s'] ?? '';
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -102,29 +119,23 @@ class MyUrlHandlers
|
|||
/**
|
||||
* Get custom blog URLs handlers.
|
||||
*
|
||||
* @return array The blog URLs handlers
|
||||
* @return array<string,string> The blog URLs handlers
|
||||
*/
|
||||
public static function getBlogHandlers(): array
|
||||
{
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return [];
|
||||
}
|
||||
$handlers = json_decode((string) My::settings()->get(My::NS_SETTING_ID), true);
|
||||
|
||||
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
|
||||
{
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
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;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
|
@ -27,7 +26,7 @@ class Uninstall extends Process
|
|||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue