Compare commits

..

No commits in common. "0f28393c6182acddfded0871f799ed8e90806fdb" and "f64d6de462705247fd8cc2c057011fd081030131" have entirely different histories.

11 changed files with 183 additions and 128 deletions

View File

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

View File

@ -1,10 +1,11 @@
# README
[![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)
[![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)
## WHAT IS FILESALIAS ?
@ -19,8 +20,7 @@ Alias can be passworded and/or disposable.
_filesAlias_ requires:
* content admin permissions for management
* Dotclear 2.27
* PHP 7.4+
* Dotclear 2.26
## USAGE
@ -33,12 +33,12 @@ 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 : [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)
* Source & contribution : [GitHub Page](https://github.com/JcDenis/filesAlias)
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/filesAlias)
## CONTRIBUTORS
* Osku (author)
* Osku
* Pierre Van Glabeke
* Jean-Christian Denis

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')) {
if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
return null;
}
@ -18,15 +18,16 @@ $this->registerModule(
'Files alias',
"Manage aliases of your blog's media",
'Osku and contributors',
'1.1',
'1.0',
[
'requires' => [['core', '2.27']],
'requires' => [['core', '2.26']],
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]),
'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',
//'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',
]
);

View File

@ -2,12 +2,12 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="filesAlias">
<name>Files alias</name>
<version>1.1</version>
<version>1.0</version>
<author>Osku and contributors</author>
<desc>Manage aliases of your blog's media</desc>
<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>
<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>
</module>
</modules>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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