Compare commits
2 Commits
f64d6de462
...
0f28393c61
Author | SHA1 | Date |
---|---|---|
Jean-Christian Paul Denis | 0f28393c61 | |
Jean-Christian Paul Denis | 23ad6f8f07 |
64
CHANGELOG.md
64
CHANGELOG.md
|
@ -1,33 +1,45 @@
|
||||||
todo:
|
filesAlias 1.1 - 2023.08.12
|
||||||
- add form to admin media item page
|
===========================================================
|
||||||
|
* Require Dotclear 2.27
|
||||||
|
* Require PHP 7.4+
|
||||||
|
* Upgrade to Dotclear 2.27
|
||||||
|
* Move third party repository
|
||||||
|
* Use Dotclear style for CHANGELOG
|
||||||
|
|
||||||
1.0 - 2023.05.13
|
filesAlias 1.0 - 2023.05.13
|
||||||
- require dotclear 2.26
|
===========================================================
|
||||||
- fix type hint and nullsafe
|
* require dotclear 2.26
|
||||||
|
* fix type hint and nullsafe
|
||||||
|
|
||||||
0.9.1 - 2023.04.23
|
filesAlias 0.9.1 - 2023.04.23
|
||||||
- require dotclear 2.26
|
===========================================================
|
||||||
- use latest dotclear namespace (database)
|
* require dotclear 2.26
|
||||||
|
* use latest dotclear namespace (database)
|
||||||
|
|
||||||
0.9 - 2023.04.22
|
filesAlias 0.9 - 2023.04.22
|
||||||
- require dotclear 2.26
|
===========================================================
|
||||||
- add plugin Uninstaller features
|
* require dotclear 2.26
|
||||||
- use sql statement
|
* add plugin Uninstaller features
|
||||||
- fix nullsafe warnings
|
* use sql statement
|
||||||
- fix static init
|
* fix nullsafe warnings
|
||||||
- add code doc
|
* fix static init
|
||||||
|
* add code doc
|
||||||
|
|
||||||
0.8 - 2023.03.26
|
filesAlias 0.8 - 2023.03.26
|
||||||
- require dotclear 2.26
|
===========================================================
|
||||||
- use namespace
|
* require dotclear 2.26
|
||||||
|
* use namespace
|
||||||
|
|
||||||
0.7.1 - 2022.12.21
|
filesAlias 0.7.1 - 2022.12.21
|
||||||
- use abstract plugin id
|
===========================================================
|
||||||
- fix install
|
* use abstract plugin id
|
||||||
|
* fix install
|
||||||
|
|
||||||
0.7 - 2022.12.04
|
filesAlias 0.7 - 2022.12.04
|
||||||
- update to Dotclear 2.24
|
===========================================================
|
||||||
- refresh admin UI
|
* update to Dotclear 2.24
|
||||||
|
* refresh admin UI
|
||||||
|
|
||||||
0.6 - 2015.06.19
|
filesAlias 0.6 - 2015.06.19
|
||||||
- first public release
|
===========================================================
|
||||||
|
* first public release
|
32
README.md
32
README.md
|
@ -1,11 +1,10 @@
|
||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/github/v/release/JcDenis/filesAlias)](https://github.com/JcDenis/filesAlias/releases)
|
[![Release](https://img.shields.io/badge/release-1.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/filesAlias/releases)
|
||||||
[![Date](https://img.shields.io/github/release-date/JcDenis/filesAlias)](https://github.com/JcDenis/filesAlias/releases)
|
[![Date](https://img.shields.io/badge/date-2023.08.12-c44d58.svg)](https://git.dotclear.watch/JcDenis/filesAlias/releases)
|
||||||
[![Issues](https://img.shields.io/github/issues/JcDenis/filesAlias)](https://github.com/JcDenis/filesAlias/issues)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/filesAlias)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/filesAlias)
|
[![License](https://img.shields.io/github/license/JcDenis/filesAlias)](https://git.dotclear.watch/JcDenis/filesAlias/blob/master/LICENSE)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/filesAlias)](https://github.com/JcDenis/filesAlias/blob/master/LICENSE)
|
|
||||||
|
|
||||||
## WHAT IS FILESALIAS ?
|
## WHAT IS FILESALIAS ?
|
||||||
|
|
||||||
|
@ -17,10 +16,11 @@ Alias can be passworded and/or disposable.
|
||||||
|
|
||||||
## REQUIREMENTS
|
## REQUIREMENTS
|
||||||
|
|
||||||
_filesAlias_ requires:
|
_filesAlias_ requires:
|
||||||
|
|
||||||
* content admin permissions for management
|
* content admin permissions for management
|
||||||
* Dotclear 2.26
|
* Dotclear 2.27
|
||||||
|
* PHP 7.4+
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ You can change public URL handler (default is _pub/_) by using plugin myUrlhandl
|
||||||
|
|
||||||
## LINKS
|
## LINKS
|
||||||
|
|
||||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||||
* Source & contribution : [GitHub Page](https://github.com/JcDenis/filesAlias)
|
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/filesAlias) or [GitHub Page](https://github.com/JcDenis/filesAlias)
|
||||||
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/filesAlias)
|
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/filesAlias/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/filesAlias)
|
||||||
|
|
||||||
## CONTRIBUTORS
|
## CONTRIBUTORS
|
||||||
|
|
||||||
* Osku
|
* Osku (author)
|
||||||
* Pierre Van Glabeke
|
* Pierre Van Glabeke
|
||||||
* Jean-Christian Denis
|
* Jean-Christian Denis
|
||||||
|
|
||||||
You are welcome to contribute to this code.
|
You are welcome to contribute to this code.
|
||||||
|
|
13
_define.php
13
_define.php
|
@ -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,16 +18,15 @@ $this->registerModule(
|
||||||
'Files alias',
|
'Files alias',
|
||||||
"Manage aliases of your blog's media",
|
"Manage aliases of your blog's media",
|
||||||
'Osku and contributors',
|
'Osku and contributors',
|
||||||
'1.0',
|
'1.1',
|
||||||
[
|
[
|
||||||
'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,
|
||||||
]),
|
]),
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
//'support' => 'http://forum.dotclear.org/viewtopic.php?id=42317',
|
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||||
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
|
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||||
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
|
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
10
dcstore.xml
10
dcstore.xml
|
@ -2,12 +2,12 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="filesAlias">
|
<module id="filesAlias">
|
||||||
<name>Files alias</name>
|
<name>Files alias</name>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<author>Osku and contributors</author>
|
<author>Osku and contributors</author>
|
||||||
<desc>Manage aliases of your blog's media</desc>
|
<desc>Manage aliases of your blog's media</desc>
|
||||||
<file>https://github.com/JcDenis/filesAlias/releases/download/v1.0/plugin-filesAlias.zip</file>
|
<file>https://git.dotclear.watch/JcDenis/filesAlias/releases/download/v1.1/plugin-filesAlias.zip</file>
|
||||||
<da:dcmin>2.26</da:dcmin>
|
<da:dcmin>2.27</da:dcmin>
|
||||||
<da:details>https://plugins.dotaddict.org/dc2/details/filesAlias</da:details>
|
<da:details>https://git.dotclear.watch/JcDenis/filesAlias/src/branch/master/README.md</da:details>
|
||||||
<da:support>https://github.com/JcDenis/filesAlias</da:support>
|
<da:support>https://git.dotclear.watch/JcDenis/filesAlias/issues</da:support>
|
||||||
</module>
|
</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
|
@ -14,55 +14,32 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\filesAlias;
|
namespace Dotclear\Plugin\filesAlias;
|
||||||
|
|
||||||
use dcAdmin;
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcFavorites;
|
use Dotclear\Core\Backend\Favorites;
|
||||||
use dcMenu;
|
use Dotclear\Core\Process;
|
||||||
use dcNsProcess;
|
|
||||||
use dcPage;
|
|
||||||
|
|
||||||
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) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nullsafe
|
My::addBackendMenuItem();
|
||||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// backend sidebar menu icon
|
|
||||||
if ((dcCore::app()->menu[dcAdmin::MENU_BLOG] instanceof dcMenu)) {
|
|
||||||
dcCore::app()->menu[dcAdmin::MENU_BLOG]->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)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// backend user dashboard icon
|
// backend user dashboard icon
|
||||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
|
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void {
|
||||||
// nullsafe
|
|
||||||
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([
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
dcCore::app()->auth::PERMISSION_USAGE,
|
dcCore::app()->auth::PERMISSION_USAGE,
|
||||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||||
|
|
|
@ -15,20 +15,18 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\filesAlias;
|
namespace Dotclear\Plugin\filesAlias;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
class Frontend extends dcNsProcess
|
class Frontend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_RC_PATH');
|
return self::status(My::checkContext(My::FRONTEND));
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,25 +15,20 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\filesAlias;
|
namespace Dotclear\Plugin\filesAlias;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Database\Structure;
|
use Dotclear\Database\Structure;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
class Install extends dcNsProcess
|
class Install extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
if (defined('DC_CONTEXT_ADMIN')) {
|
return self::status(My::checkContext(My::INSTALL));
|
||||||
$version = dcCore::app()->plugins->moduleInfo(My::id(), 'version');
|
|
||||||
static::$init = is_string($version) ? dcCore::app()->newVersion(My::id(), $version) : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +47,7 @@ class Install extends dcNsProcess
|
||||||
->reference('fk_filesalias_blog', 'blog_id', 'blog', 'blog_id', 'cascade', 'cascade')
|
->reference('fk_filesalias_blog', 'blog_id', 'blog', 'blog_id', 'cascade', 'cascade')
|
||||||
;
|
;
|
||||||
|
|
||||||
$si = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
|
||||||
$changes = $si->synchronize($s);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
|
@ -16,8 +16,11 @@ namespace Dotclear\Plugin\filesAlias;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcMedia;
|
use dcMedia;
|
||||||
use dcNsProcess;
|
use Dotclear\Core\Backend\{
|
||||||
use dcPage;
|
Notices,
|
||||||
|
Page
|
||||||
|
};
|
||||||
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Checkbox,
|
Checkbox,
|
||||||
|
@ -32,30 +35,21 @@ use Dotclear\Helper\Html\Form\{
|
||||||
};
|
};
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
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) // nullsafe
|
|
||||||
&& dcCore::app()->auth->check(
|
|
||||||
dcCore::app()->auth->makePermissions([
|
|
||||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
|
||||||
]),
|
|
||||||
dcCore::app()->blog->id
|
|
||||||
);
|
|
||||||
|
|
||||||
return static::$init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nullsafe
|
// nullsafe
|
||||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
if (is_null(dcCore::app()->blog)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +61,8 @@ class Manage extends dcNsProcess
|
||||||
if (isset($_POST['a']) && is_array($_POST['a'])) {
|
if (isset($_POST['a']) && is_array($_POST['a'])) {
|
||||||
try {
|
try {
|
||||||
Utils::updateAliases($_POST['a']);
|
Utils::updateAliases($_POST['a']);
|
||||||
dcPage::addSuccessNotice(__('Aliases successfully updated.'));
|
Notices::addSuccessNotice(__('Aliases successfully updated.'));
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -89,8 +83,8 @@ class Manage extends dcNsProcess
|
||||||
if (!empty($found)) {
|
if (!empty($found)) {
|
||||||
try {
|
try {
|
||||||
Utils::createAlias($url, $target, $totrash, $password);
|
Utils::createAlias($url, $target, $totrash, $password);
|
||||||
dcPage::addSuccessNotice(__('Alias for this media created.'));
|
Notices::addSuccessNotice(__('Alias for this media created.'));
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -103,8 +97,8 @@ class Manage extends dcNsProcess
|
||||||
if (!empty($found)) {
|
if (!empty($found)) {
|
||||||
try {
|
try {
|
||||||
Utils::createAlias($url, $target, $totrash, $password);
|
Utils::createAlias($url, $target, $totrash, $password);
|
||||||
dcPage::addSuccessNotice(__('Alias for this media modified.'));
|
Notices::addSuccessNotice(__('Alias for this media modified.'));
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -119,11 +113,11 @@ class Manage extends dcNsProcess
|
||||||
|
|
||||||
public static function render(): void
|
public static function render(): void
|
||||||
{
|
{
|
||||||
if (!static::$init) {
|
if (!self::status()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::openModule(My::name());
|
Page::openModule(My::name());
|
||||||
|
|
||||||
if (($_REQUEST['part'] ?? '') == 'new') {
|
if (($_REQUEST['part'] ?? '') == 'new') {
|
||||||
self::displayAliasForm();
|
self::displayAliasForm();
|
||||||
|
@ -131,26 +125,26 @@ class Manage extends dcNsProcess
|
||||||
self::displayAliasList();
|
self::displayAliasList();
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::helpBlock('filesAlias');
|
Page::helpBlock('filesAlias');
|
||||||
|
|
||||||
dcPage::closeModule();
|
Page::closeModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function displayAliasForm(): void
|
private static function displayAliasForm(): void
|
||||||
{
|
{
|
||||||
// nullsafe
|
// nullsafe
|
||||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl) || is_null(dcCore::app()->media)) {
|
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->media)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb([
|
Page::breadcrumb([
|
||||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||||
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
My::name() => My::manageUrl(),
|
||||||
__('New alias') => '',
|
__('New alias') => '',
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices() .
|
Notices::getNotices() .
|
||||||
(new Form('filesalias_new'))->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()))->method('post')->fields([
|
(new Form('filesalias_new'))->action(My::manageUrl())->method('post')->fields([
|
||||||
(new Text('h3', Html::escapeHTML(__('New alias')))),
|
(new Text('h3', Html::escapeHTML(__('New alias')))),
|
||||||
(new Note())->text(sprintf(__('Do not put blog media URL "%s" in fields or it will be removed.'), dcCore::app()->media->root_url))->class('form-note'),
|
(new Note())->text(sprintf(__('Do not put blog media URL "%s" in fields or it will be removed.'), dcCore::app()->media->root_url))->class('form-note'),
|
||||||
// destination
|
// destination
|
||||||
|
@ -178,8 +172,7 @@ class Manage extends dcNsProcess
|
||||||
// submit
|
// submit
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Submit(['save']))->value(__('Save')),
|
(new Submit(['save']))->value(__('Save')),
|
||||||
(new Hidden(['part'], 'new')),
|
... My::hiddenFields(['part' => 'new']),
|
||||||
dcCore::app()->formNonce(false),
|
|
||||||
]),
|
]),
|
||||||
])->render();
|
])->render();
|
||||||
}
|
}
|
||||||
|
@ -187,20 +180,20 @@ class Manage extends dcNsProcess
|
||||||
private static function displayAliasList(): void
|
private static function displayAliasList(): void
|
||||||
{
|
{
|
||||||
// nullsafe
|
// nullsafe
|
||||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl) || is_null(dcCore::app()->media)) {
|
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->media)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aliases = Utils::getAliases();
|
$aliases = Utils::getAliases();
|
||||||
|
|
||||||
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() .
|
||||||
'<p class="top-add"><a class="button add" href="' .
|
'<p class="top-add"><a class="button add" href="' .
|
||||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id(), ['part' => 'new']) .
|
My::manageUrl(['part' => 'new']) .
|
||||||
'">' . __('New alias') . '</a></p>';
|
'">' . __('New alias') . '</a></p>';
|
||||||
|
|
||||||
if ($aliases->isEmpty()) {
|
if ($aliases->isEmpty()) {
|
||||||
|
@ -233,7 +226,7 @@ class Manage extends dcNsProcess
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
(new Form('filesalias_list'))->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()))->method('post')->fields([
|
(new Form('filesalias_list'))->action(My::manageUrl())->method('post')->fields([
|
||||||
(new Text(
|
(new Text(
|
||||||
'',
|
'',
|
||||||
'<div class="table-outer">' .
|
'<div class="table-outer">' .
|
||||||
|
@ -250,8 +243,7 @@ class Manage extends dcNsProcess
|
||||||
)),
|
)),
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Submit(['save']))->value(__('Update')),
|
(new Submit(['save']))->value(__('Update')),
|
||||||
(new Hidden(['part'], 'list')),
|
... My::hiddenFields(['part' => 'list']),
|
||||||
dcCore::app()->formNonce(false),
|
|
||||||
]),
|
]),
|
||||||
(new Note())->text(__('To remove a link, empty its alias or destination.'))->class('form-note'),
|
(new Note())->text(__('To remove a link, empty its alias or destination.'))->class('form-note'),
|
||||||
])->render();
|
])->render();
|
||||||
|
|
31
src/My.php
31
src/My.php
|
@ -14,36 +14,13 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\filesAlias;
|
namespace Dotclear\Plugin\filesAlias;
|
||||||
|
|
||||||
use dcCore;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module definitions.
|
* This module definitions.
|
||||||
*/
|
*/
|
||||||
class My extends \initFilesAlias
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
/**
|
/** @var string This plugin table name */
|
||||||
* This module id.
|
public const ALIAS_TABLE_NAME = 'filesalias';
|
||||||
*/
|
|
||||||
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__);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,20 +15,18 @@ declare(strict_types=1);
|
||||||
namespace Dotclear\Plugin\filesAlias;
|
namespace Dotclear\Plugin\filesAlias;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
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 = defined('DC_RC_PATH');
|
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\filesAlias;
|
namespace Dotclear\Plugin\filesAlias;
|
||||||
|
|
||||||
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