Compare commits

..

2 Commits

Author SHA1 Message Date
Jean-Christian Paul Denis 0f28393c61
release 1.1 2023-08-12 23:33:55 +02:00
Jean-Christian Paul Denis 23ad6f8f07
upgrade to Dotclear 2.27 2023-08-12 23:31:55 +02:00
11 changed files with 128 additions and 183 deletions

View File

@ -1,33 +1,45 @@
todo:
- add form to admin media item page
filesAlias 1.1 - 2023.08.12
===========================================================
* 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
- require dotclear 2.26
- fix type hint and nullsafe
filesAlias 1.0 - 2023.05.13
===========================================================
* require dotclear 2.26
* fix type hint and nullsafe
0.9.1 - 2023.04.23
- require dotclear 2.26
- use latest dotclear namespace (database)
filesAlias 0.9.1 - 2023.04.23
===========================================================
* require dotclear 2.26
* use latest dotclear namespace (database)
0.9 - 2023.04.22
- require dotclear 2.26
- add plugin Uninstaller features
- use sql statement
- fix nullsafe warnings
- fix static init
- add code doc
filesAlias 0.9 - 2023.04.22
===========================================================
* require dotclear 2.26
* add plugin Uninstaller features
* use sql statement
* fix nullsafe warnings
* fix static init
* add code doc
0.8 - 2023.03.26
- require dotclear 2.26
- use namespace
filesAlias 0.8 - 2023.03.26
===========================================================
* require dotclear 2.26
* use namespace
0.7.1 - 2022.12.21
- use abstract plugin id
- fix install
filesAlias 0.7.1 - 2022.12.21
===========================================================
* use abstract plugin id
* fix install
0.7 - 2022.12.04
- update to Dotclear 2.24
- refresh admin UI
filesAlias 0.7 - 2022.12.04
===========================================================
* update to Dotclear 2.24
* refresh admin UI
0.6 - 2015.06.19
- first public release
filesAlias 0.6 - 2015.06.19
===========================================================
* first public release

View File

@ -1,11 +1,10 @@
# README
[![Release](https://img.shields.io/github/v/release/JcDenis/filesAlias)](https://github.com/JcDenis/filesAlias/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/filesAlias)](https://github.com/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.26-blue.svg)](https://fr.dotclear.org/download)
[![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://github.com/JcDenis/filesAlias/blob/master/LICENSE)
[![Release](https://img.shields.io/badge/release-1.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/filesAlias/releases)
[![Date](https://img.shields.io/badge/date-2023.08.12-c44d58.svg)](https://git.dotclear.watch/JcDenis/filesAlias/releases)
[![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/filesAlias)
[![License](https://img.shields.io/github/license/JcDenis/filesAlias)](https://git.dotclear.watch/JcDenis/filesAlias/blob/master/LICENSE)
## WHAT IS FILESALIAS ?
@ -17,10 +16,11 @@ Alias can be passworded and/or disposable.
## REQUIREMENTS
_filesAlias_ requires:
_filesAlias_ requires:
* content admin permissions for management
* Dotclear 2.26
* content admin permissions for management
* Dotclear 2.27
* PHP 7.4+
## USAGE
@ -32,14 +32,14 @@ You can change public URL handler (default is _pub/_) by using plugin myUrlhandl
## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contribution : [GitHub Page](https://github.com/JcDenis/filesAlias)
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/filesAlias)
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/filesAlias) or [GitHub Page](https://github.com/JcDenis/filesAlias)
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/filesAlias/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/filesAlias)
## CONTRIBUTORS
* Osku
* Pierre Van Glabeke
* Jean-Christian Denis
* Osku (author)
* Pierre Van Glabeke
* Jean-Christian Denis
You are welcome to contribute to this code.
You are welcome to contribute to this code.

View File

@ -10,7 +10,7 @@
* @copyright Jean-Christian Denis
* @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;
}
@ -18,16 +18,15 @@ $this->registerModule(
'Files alias',
"Manage aliases of your blog's media",
'Osku and contributors',
'1.0',
'1.1',
[
'requires' => [['core', '2.26']],
'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]),
'type' => 'plugin',
//'support' => 'http://forum.dotclear.org/viewtopic.php?id=42317',
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
]
);

View File

@ -2,12 +2,12 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="filesAlias">
<name>Files alias</name>
<version>1.0</version>
<version>1.1</version>
<author>Osku and contributors</author>
<desc>Manage aliases of your blog's media</desc>
<file>https://github.com/JcDenis/filesAlias/releases/download/v1.0/plugin-filesAlias.zip</file>
<da:dcmin>2.26</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/filesAlias</da:details>
<da:support>https://github.com/JcDenis/filesAlias</da:support>
<file>https://git.dotclear.watch/JcDenis/filesAlias/releases/download/v1.1/plugin-filesAlias.zip</file>
<da:dcmin>2.27</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/filesAlias/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/filesAlias/issues</da:support>
</module>
</modules>

View File

@ -14,55 +14,32 @@ declare(strict_types=1);
namespace Dotclear\Plugin\filesAlias;
use dcAdmin;
use dcCore;
use dcFavorites;
use dcMenu;
use dcNsProcess;
use dcPage;
use Dotclear\Core\Backend\Favorites;
use Dotclear\Core\Process;
class Backend extends dcNsProcess
class Backend extends Process
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN');
return static::$init;
return self::status(My::checkContext(My::BACKEND));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}
// nullsafe
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)
);
}
My::addBackendMenuItem();
// backend user dashboard icon
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs): void {
// nullsafe
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
return;
}
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (Favorites $favs): void {
$favs->register(My::id(), [
'title' => My::name(),
'url' => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'),
'url' => My::manageUrl(),
'small-icon' => My::icons(),
'large-icon' => My::icons(),
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_USAGE,
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,

View File

@ -15,20 +15,18 @@ declare(strict_types=1);
namespace Dotclear\Plugin\filesAlias;
use dcCore;
use dcNsProcess;
use Dotclear\Core\Process;
class Frontend extends dcNsProcess
class Frontend extends Process
{
public static function init(): bool
{
static::$init = defined('DC_RC_PATH');
return static::$init;
return self::status(My::checkContext(My::FRONTEND));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}

View File

@ -15,25 +15,20 @@ declare(strict_types=1);
namespace Dotclear\Plugin\filesAlias;
use dcCore;
use dcNsProcess;
use Dotclear\Core\Process;
use Dotclear\Database\Structure;
use Exception;
class Install extends dcNsProcess
class Install extends Process
{
public static function init(): bool
{
if (defined('DC_CONTEXT_ADMIN')) {
$version = dcCore::app()->plugins->moduleInfo(My::id(), 'version');
static::$init = is_string($version) ? dcCore::app()->newVersion(My::id(), $version) : true;
}
return static::$init;
return self::status(My::checkContext(My::INSTALL));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}
@ -52,8 +47,7 @@ class Install extends dcNsProcess
->reference('fk_filesalias_blog', 'blog_id', 'blog', 'blog_id', 'cascade', 'cascade')
;
$si = new Structure(dcCore::app()->con, dcCore::app()->prefix);
$changes = $si->synchronize($s);
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
return true;
} catch (Exception $e) {

View File

@ -16,8 +16,11 @@ namespace Dotclear\Plugin\filesAlias;
use dcCore;
use dcMedia;
use dcNsProcess;
use dcPage;
use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Core\Process;
use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Html\Form\{
Checkbox,
@ -32,30 +35,21 @@ use Dotclear\Helper\Html\Form\{
};
use Exception;
class Manage extends dcNsProcess
class Manage extends Process
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN')
&& !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;
return self::status(My::checkContext(My::MANAGE));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}
// nullsafe
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
if (is_null(dcCore::app()->blog)) {
return false;
}
@ -67,8 +61,8 @@ class Manage extends dcNsProcess
if (isset($_POST['a']) && is_array($_POST['a'])) {
try {
Utils::updateAliases($_POST['a']);
dcPage::addSuccessNotice(__('Aliases successfully updated.'));
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
Notices::addSuccessNotice(__('Aliases successfully updated.'));
My::redirect();
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
}
@ -89,8 +83,8 @@ class Manage extends dcNsProcess
if (!empty($found)) {
try {
Utils::createAlias($url, $target, $totrash, $password);
dcPage::addSuccessNotice(__('Alias for this media created.'));
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
Notices::addSuccessNotice(__('Alias for this media created.'));
My::redirect();
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
}
@ -103,8 +97,8 @@ class Manage extends dcNsProcess
if (!empty($found)) {
try {
Utils::createAlias($url, $target, $totrash, $password);
dcPage::addSuccessNotice(__('Alias for this media modified.'));
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id());
Notices::addSuccessNotice(__('Alias for this media modified.'));
My::redirect();
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
}
@ -119,11 +113,11 @@ class Manage extends dcNsProcess
public static function render(): void
{
if (!static::$init) {
if (!self::status()) {
return;
}
dcPage::openModule(My::name());
Page::openModule(My::name());
if (($_REQUEST['part'] ?? '') == 'new') {
self::displayAliasForm();
@ -131,26 +125,26 @@ class Manage extends dcNsProcess
self::displayAliasList();
}
dcPage::helpBlock('filesAlias');
Page::helpBlock('filesAlias');
dcPage::closeModule();
Page::closeModule();
}
private static function displayAliasForm(): void
{
// 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;
}
echo
dcPage::breadcrumb([
Page::breadcrumb([
Html::escapeHTML(dcCore::app()->blog->name) => '',
My::name() => dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
My::name() => My::manageUrl(),
__('New alias') => '',
]) .
dcPage::notices() .
(new Form('filesalias_new'))->action(dcCore::app()->adminurl->get('admin.plugin.' . My::id()))->method('post')->fields([
Notices::getNotices() .
(new Form('filesalias_new'))->action(My::manageUrl())->method('post')->fields([
(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'),
// destination
@ -178,8 +172,7 @@ class Manage extends dcNsProcess
// submit
(new Para())->items([
(new Submit(['save']))->value(__('Save')),
(new Hidden(['part'], 'new')),
dcCore::app()->formNonce(false),
... My::hiddenFields(['part' => 'new']),
]),
])->render();
}
@ -187,20 +180,20 @@ class Manage extends dcNsProcess
private static function displayAliasList(): void
{
// 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;
}
$aliases = Utils::getAliases();
echo
dcPage::breadcrumb([
Page::breadcrumb([
Html::escapeHTML(dcCore::app()->blog->name) => '',
My::name() => '',
]) .
dcPage::notices() .
Notices::getNotices() .
'<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>';
if ($aliases->isEmpty()) {
@ -233,7 +226,7 @@ class Manage extends dcNsProcess
}
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(
'',
'<div class="table-outer">' .
@ -250,8 +243,7 @@ class Manage extends dcNsProcess
)),
(new Para())->items([
(new Submit(['save']))->value(__('Update')),
(new Hidden(['part'], 'list')),
dcCore::app()->formNonce(false),
... My::hiddenFields(['part' => 'list']),
]),
(new Note())->text(__('To remove a link, empty its alias or destination.'))->class('form-note'),
])->render();

View File

@ -14,36 +14,13 @@ declare(strict_types=1);
namespace Dotclear\Plugin\filesAlias;
use dcCore;
use Dotclear\Module\MyPlugin;
/**
* This module definitions.
*/
class My extends \initFilesAlias
class My extends MyPlugin
{
/**
* 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__);
}
/** @var string This plugin table name */
public const ALIAS_TABLE_NAME = 'filesalias';
}

View File

@ -15,20 +15,18 @@ declare(strict_types=1);
namespace Dotclear\Plugin\filesAlias;
use dcCore;
use dcNsProcess;
use Dotclear\Core\Process;
class Prepend extends dcNsProcess
class Prepend extends Process
{
public static function init(): bool
{
static::$init = defined('DC_RC_PATH');
return static::$init;
return self::status(My::checkContext(My::PREPEND));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}

View File

@ -15,21 +15,19 @@ declare(strict_types=1);
namespace Dotclear\Plugin\filesAlias;
use dcCore;
use dcNsProcess;
use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller;
class Uninstall extends dcNsProcess
class Uninstall extends Process
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN');
return static::$init;
return self::status(My::checkContext(My::UNINSTALL));
}
public static function process(): bool
{
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
return false;
}