upgrade to Dotclear 2.28
This commit is contained in:
parent
0f28393c61
commit
e2b7c63504
18 changed files with 216 additions and 307 deletions
|
@ -1,3 +1,9 @@
|
|||
filesAlias 1.2 - 2023.10.17
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
filesAlias 1.1 - 2023.08.12
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
|
33
README.md
33
README.md
|
@ -1,26 +1,22 @@
|
|||
# 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)
|
||||
[![Release](https://img.shields.io/badge/release-1.2-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/filesAlias/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.10.17-c44d58.svg)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-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)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/filesAlias/src/branch/master/LICENSE)
|
||||
|
||||
## WHAT IS FILESALIAS ?
|
||||
## ABOUT
|
||||
|
||||
_filesAlias_ is a plugin for the open-source
|
||||
web publishing software called Dotclear.
|
||||
_filesAlias_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
|
||||
This plugin creates public aliases of your blog's media.
|
||||
Alias can be passworded and/or disposable.
|
||||
> Create public aliases of your blog's media. Alias can be passworded and/or disposable.
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
_filesAlias_ requires:
|
||||
|
||||
* content admin permissions for management
|
||||
* Dotclear 2.27
|
||||
* PHP 7.4+
|
||||
* Dotclear 2.28
|
||||
* PHP8.1+
|
||||
* Dotclear content admin permissions for management
|
||||
|
||||
## USAGE
|
||||
|
||||
|
@ -32,14 +28,15 @@ 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)
|
||||
* [License](https://git.dotclear.watch/JcDenis/filesAlias/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/filesAlias/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/filesAlias))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/filesAlias) (or on [GitHub](https://github.com/JcDenis/filesAlias))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/filesAlias/issues) (or on [GitHub](https://github.com/JcDenis/filesAlias/issues))
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Osku (author)
|
||||
* Pierre Van Glabeke
|
||||
* Jean-Christian Denis
|
||||
* Jean-Christian Denis (latest)
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
|
34
_define.php
34
_define.php
|
@ -1,32 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin filesAlias definition
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup filesAlias Plugin filesAlias.
|
||||
*
|
||||
* @author Osku and contributors
|
||||
* Manage aliases of your blog's media.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
declare(strict_types=1);
|
||||
|
||||
$this->registerModule(
|
||||
'Files alias',
|
||||
"Manage aliases of your blog's media",
|
||||
'Osku and contributors',
|
||||
'1.1',
|
||||
'1.2',
|
||||
[
|
||||
'requires' => [['core', '2.27']],
|
||||
'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',
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
'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',
|
||||
]
|
||||
);
|
||||
|
|
21
_init.php
21
_init.php
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class initFilesAlias
|
||||
{
|
||||
/** @var string This plugin table name */
|
||||
public const ALIAS_TABLE_NAME = 'filesalias';
|
||||
}
|
|
@ -2,11 +2,11 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="filesAlias">
|
||||
<name>Files alias</name>
|
||||
<version>1.1</version>
|
||||
<version>1.2</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>
|
||||
<file>https://git.dotclear.watch/JcDenis/filesAlias/releases/download/v1.2/plugin-filesAlias.zip</file>
|
||||
<da:dcmin>2.28</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>
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin filesAlias locales resources
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
dcCore::app()->resources['help']['filesAlias'] = __DIR__ . '/help/filesAlias.html';
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin filesAlias locales resources
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
dcCore::app()->resources['help']['filesAlias'] = __DIR__ . '/help/filesAlias.html';
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief filesAlias backend class.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -34,15 +32,15 @@ class Backend extends Process
|
|||
My::addBackendMenuItem();
|
||||
|
||||
// backend user 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_USAGE,
|
||||
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||
'permissions' => App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_USAGE,
|
||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief filesAlias frontend class.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Frontend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -31,14 +29,14 @@ class Frontend extends Process
|
|||
}
|
||||
|
||||
// add path to template
|
||||
dcCore::app()->tpl->setPath(
|
||||
dcCore::app()->tpl->getPath(),
|
||||
App::frontend()->template()->setPath(
|
||||
App::frontend()->template()->getPath(),
|
||||
My::path() . DIRECTORY_SEPARATOR . 'default-templates'
|
||||
);
|
||||
// register template value for file alias
|
||||
dcCore::app()->tpl->addValue(
|
||||
App::frontend()->template()->addValue(
|
||||
'fileAliasURL',
|
||||
[FrontendTemplate::class, 'fileAliasURL']
|
||||
FrontendTemplate::fileAliasURL(...)
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,24 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
|
||||
/**
|
||||
* File alias frontend template.
|
||||
* @brief filesAlias frontend template class.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class FrontendTemplate
|
||||
{
|
||||
|
@ -27,7 +22,7 @@ class FrontendTemplate
|
|||
*
|
||||
* attributes:
|
||||
*
|
||||
* - any filters See dcTemplate::getFilters()
|
||||
* - any filters See Tpl::getFilters()
|
||||
*
|
||||
* @param ArrayObject $attr The attributes
|
||||
*
|
||||
|
@ -36,8 +31,8 @@ class FrontendTemplate
|
|||
public static function fileAliasURL(ArrayObject $attr): string
|
||||
{
|
||||
return '<?php echo ' . sprintf(
|
||||
dcCore::app()->tpl->getFilters($attr),
|
||||
'dcCore::app()->blog->url.dcCore::app()->url->getBase("filesalias")."/".dcCore::app()->ctx->filealias->filesalias_url'
|
||||
App::frontend()->template()->getFilters($attr),
|
||||
'App::blog()->url().App::url()->getBase("filesalias")."/".App::frontend()->context()->filealias->filesalias_url'
|
||||
) . '; ?>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\Structure;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief filesAlias installation class.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Install extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -33,7 +31,7 @@ class Install extends Process
|
|||
}
|
||||
|
||||
try {
|
||||
$s = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$s = new Structure(App::con(), App::con()->prefix());
|
||||
|
||||
$s->__get(My::ALIAS_TABLE_NAME)
|
||||
->field('blog_id', 'varchar', 32, false)
|
||||
|
@ -47,11 +45,11 @@ 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);
|
||||
(new Structure(App::con(), App::con()->prefix()))->synchronize($s);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
||||
use dcCore;
|
||||
use dcMedia;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
|
@ -35,6 +24,14 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief filesAlias manage class.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Manage extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -44,19 +41,12 @@ class Manage extends Process
|
|||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
if (!self::status()
|
||||
|| !APP::blog()->isDefined()
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(dcCore::app()->media instanceof dcMedia)) {
|
||||
dcCore::app()->media = new dcMedia();
|
||||
}
|
||||
|
||||
// Update aliases
|
||||
if (isset($_POST['a']) && is_array($_POST['a'])) {
|
||||
try {
|
||||
|
@ -64,7 +54,7 @@ class Manage extends Process
|
|||
Notices::addSuccessNotice(__('Aliases successfully updated.'));
|
||||
My::redirect();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,8 +66,8 @@ class Manage extends Process
|
|||
$totrash = isset($_POST['filesalias_disposable']) ? true : false;
|
||||
$password = empty($_POST['filesalias_password']) ? '' : $_POST['filesalias_password'];
|
||||
|
||||
if (preg_match('/^' . preg_quote(dcCore::app()->media->root_url, '/') . '/', $target)) {
|
||||
$target = preg_replace('/^' . preg_quote(dcCore::app()->media->root_url, '/') . '/', '', $target);
|
||||
if (preg_match('/^' . preg_quote(App::media()->root_url, '/') . '/', $target)) {
|
||||
$target = preg_replace('/^' . preg_quote(App::media()->root_url, '/') . '/', '', $target);
|
||||
$found = Utils::getMediaId($target);
|
||||
|
||||
if (!empty($found)) {
|
||||
|
@ -86,10 +76,10 @@ class Manage extends Process
|
|||
Notices::addSuccessNotice(__('Alias for this media created.'));
|
||||
My::redirect();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
} else {
|
||||
dcCore::app()->error->add(__('Target is not in media manager.'));
|
||||
App::error()->add(__('Target is not in media manager.'));
|
||||
}
|
||||
} else {
|
||||
$found = Utils::getMediaId($target);
|
||||
|
@ -100,10 +90,10 @@ class Manage extends Process
|
|||
Notices::addSuccessNotice(__('Alias for this media modified.'));
|
||||
My::redirect();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
} else {
|
||||
dcCore::app()->error->add(__('Target is not in media manager.'));
|
||||
App::error()->add(__('Target is not in media manager.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,21 +122,20 @@ class Manage extends Process
|
|||
|
||||
private static function displayAliasForm(): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->media)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo
|
||||
Page::breadcrumb([
|
||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
My::name() => My::manageUrl(),
|
||||
__('New alias') => '',
|
||||
Html::escapeHTML(App::blog()->name()) => '',
|
||||
My::name() => My::manageUrl(),
|
||||
__('New alias') => '',
|
||||
]) .
|
||||
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'),
|
||||
(new Note())->text(sprintf(__('Do not put blog media URL "%s" in fields or it will be removed.'), App::media()->root_url))->class('form-note'),
|
||||
// destination
|
||||
(new Para())->items([
|
||||
(new Label(__('Destination:')))->for('filesalias_destination')->class('required'),
|
||||
|
@ -179,8 +168,7 @@ class Manage extends Process
|
|||
|
||||
private static function displayAliasList(): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->media)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -188,8 +176,8 @@ class Manage extends Process
|
|||
|
||||
echo
|
||||
Page::breadcrumb([
|
||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
My::name() => '',
|
||||
Html::escapeHTML(App::blog()->name()) => '',
|
||||
My::name() => '',
|
||||
]) .
|
||||
Notices::getNotices() .
|
||||
'<p class="top-add"><a class="button add" href="' .
|
||||
|
@ -206,7 +194,7 @@ class Manage extends Process
|
|||
$destination = is_string($aliases->f('filesalias_destination')) ? $aliases->f('filesalias_destination') : '';
|
||||
$password = is_string($aliases->f('filesalias_password')) ? $aliases->f('filesalias_password') : '';
|
||||
$disposable = !empty($aliases->f('filesalias_disposable'));
|
||||
$full = dcCore::app()->blog->url . dcCore::app()->url->getBase('filesalias') . '/' . Html::escapeHTML($url);
|
||||
$full = App::blog()->url() . App::url()->getBase('filesalias') . '/' . Html::escapeHTML($url);
|
||||
|
||||
$lines .= '<tr class="line" id="l_' . $i . '">' .
|
||||
'<td>' .
|
||||
|
@ -233,8 +221,8 @@ class Manage extends Process
|
|||
'<table><thead>' .
|
||||
'<caption>' . __('Aliases list') . '</caption>' .
|
||||
'<tr>' .
|
||||
'<th class="nowrap" scope="col">' . __('Destination') . ' - <ins>' . Html::escapeHTML(dcCore::app()->media->root_url) . '</ins><code>(-?-)</code></th>' .
|
||||
'<th class="nowrap" scope="col">' . __('Alias') . ' - <ins>' . dcCore::app()->blog->url . dcCore::app()->url->getBase('filesalias') . '/' . '</ins><code>(-?-)</code></th>' .
|
||||
'<th class="nowrap" scope="col">' . __('Destination') . ' - <ins>' . Html::escapeHTML(App::media()->root_url) . '</ins><code>(-?-)</code></th>' .
|
||||
'<th class="nowrap" scope="col">' . __('Alias') . ' - <ins>' . App::blog()->url() . App::url()->getBase('filesalias') . '/' . '</ins><code>(-?-)</code></th>' .
|
||||
'<th class="nowrap" scope="col">' . __('Password') . '</th>' .
|
||||
'<th class="nowrap" scope="col">' . __('Disposable') . '</th>' .
|
||||
'</tr></thead><body>' .
|
||||
|
|
27
src/My.php
27
src/My.php
|
@ -1,15 +1,5 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
@ -17,10 +7,21 @@ namespace Dotclear\Plugin\filesAlias;
|
|||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
* @brief filesAlias My helper.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/** @var string This plugin table name */
|
||||
/**
|
||||
* This plugin table name.
|
||||
*
|
||||
* @var string ALIAS_TABLE_NAME
|
||||
*/
|
||||
public const ALIAS_TABLE_NAME = 'filesalias';
|
||||
|
||||
// Use defautl permissions
|
||||
}
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
||||
/**
|
||||
* Adapted from Enrico Pallazzo class
|
||||
* @brief filesAlias randomizer class.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* Adapted from Enrico Pallazzo class.
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class PallazzoTools
|
||||
{
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* @brief filesAlias prepend class.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Prepend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -31,11 +29,11 @@ class Prepend extends Process
|
|||
}
|
||||
|
||||
// register file alias frontend URL handler
|
||||
dcCore::app()->url->register(
|
||||
App::url()->register(
|
||||
'filesalias',
|
||||
'pub',
|
||||
'^pub/(.+)$',
|
||||
[UrlHandler::class, 'alias']
|
||||
UrlHandler::alias(...)
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
/**
|
||||
* @brief filesAlias uninstall class.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -27,7 +24,7 @@ class Uninstall extends Process
|
|||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
||||
use dcCore;
|
||||
use dcMedia;
|
||||
use dcUrlHandlers;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Frontend\Url;
|
||||
|
||||
/**
|
||||
* File alias frontend URL handler.
|
||||
* @brief filesAlias frontend URL handler class.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class UrlHandler extends dcUrlHandlers
|
||||
class UrlHandler extends Url
|
||||
{
|
||||
/**
|
||||
* File alias page.
|
||||
|
@ -30,14 +24,9 @@ class UrlHandler extends dcUrlHandlers
|
|||
*/
|
||||
public static function alias(string $args): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->ctx)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$alias = Utils::getAlias($args);
|
||||
|
||||
dcCore::app()->ctx->__set('filealias', $alias);
|
||||
App::frontend()->context()->__set('filealias', $alias);
|
||||
|
||||
if ($alias->isEmpty()) {
|
||||
self::p404();
|
||||
|
@ -76,11 +65,7 @@ class UrlHandler extends dcUrlHandlers
|
|||
self::p404();
|
||||
}
|
||||
|
||||
if (!(dcCore::app()->media instanceof dcMedia)) {
|
||||
dcCore::app()->media = new dcMedia();
|
||||
}
|
||||
|
||||
$file = dcCore::app()->media->getFile($media);
|
||||
$file = App::media()->getFile($media);
|
||||
|
||||
if (empty($file->file)) {
|
||||
self::p404();
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief filesAlias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Osku and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\filesAlias;
|
||||
|
||||
use dcCore;
|
||||
use dcMedia;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Database\Statement\{
|
||||
DeleteStatement,
|
||||
|
@ -24,7 +13,12 @@ use Dotclear\Database\Statement\{
|
|||
use Exception;
|
||||
|
||||
/**
|
||||
* fileAlias records utils
|
||||
* @brief filesAlias records helper class.
|
||||
* @ingroup filesAlias
|
||||
*
|
||||
* @author Osku (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Utils
|
||||
{
|
||||
|
@ -35,18 +29,15 @@ class Utils
|
|||
*/
|
||||
public static function getAliases(): MetaRecord
|
||||
{
|
||||
// nullsafe
|
||||
$blog_id = is_null(dcCore::app()->blog) ? '' : dcCore::app()->blog->id;
|
||||
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql->from(dcCore::app()->prefix . My::ALIAS_TABLE_NAME)
|
||||
$rs = $sql->from(App::con()->prefix() . My::ALIAS_TABLE_NAME)
|
||||
->columns([
|
||||
'filesalias_url',
|
||||
'filesalias_destination',
|
||||
'filesalias_password',
|
||||
'filesalias_disposable',
|
||||
])
|
||||
->where('blog_id = ' . $sql->quote($blog_id))
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->order('filesalias_url ASC')
|
||||
->select();
|
||||
|
||||
|
@ -60,18 +51,15 @@ class Utils
|
|||
*/
|
||||
public static function getAlias(string $url): MetaRecord
|
||||
{
|
||||
// nullsafe
|
||||
$blog_id = is_null(dcCore::app()->blog) ? '' : dcCore::app()->blog->id;
|
||||
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql->from(dcCore::app()->prefix . My::ALIAS_TABLE_NAME)
|
||||
$rs = $sql->from(App::con()->prefix() . My::ALIAS_TABLE_NAME)
|
||||
->columns([
|
||||
'filesalias_url',
|
||||
'filesalias_destination',
|
||||
'filesalias_password',
|
||||
'filesalias_disposable',
|
||||
])
|
||||
->where('blog_id = ' . $sql->quote($blog_id))
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->and('filesalias_url = ' . $sql->quote($url))
|
||||
->order('filesalias_url ASC')
|
||||
->select();
|
||||
|
@ -97,7 +85,7 @@ class Utils
|
|||
*/
|
||||
public static function updateAliases(array $aliases): void
|
||||
{
|
||||
dcCore::app()->con->begin();
|
||||
App::con()->begin();
|
||||
|
||||
try {
|
||||
self::deleteAliases();
|
||||
|
@ -108,9 +96,9 @@ class Utils
|
|||
}
|
||||
}
|
||||
|
||||
dcCore::app()->con->commit();
|
||||
App::con()->commit();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->con->rollback();
|
||||
App::con()->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
@ -134,11 +122,8 @@ class Utils
|
|||
throw new Exception(__('File destination is empty.'));
|
||||
}
|
||||
|
||||
// nullsafe
|
||||
$blog_id = is_null(dcCore::app()->blog) ? '' : dcCore::app()->blog->id;
|
||||
|
||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . My::ALIAS_TABLE_NAME);
|
||||
$cur->setField('blog_id', $blog_id);
|
||||
$cur = App::con()->openCursor(App::con()->prefix() . My::ALIAS_TABLE_NAME);
|
||||
$cur->setField('blog_id', App::blog()->id());
|
||||
$cur->setField('filesalias_url', (string) $url);
|
||||
$cur->setField('filesalias_destination', (string) $destination);
|
||||
$cur->setField('filesalias_password', $password);
|
||||
|
@ -151,12 +136,9 @@ class Utils
|
|||
*/
|
||||
public static function deleteAliases(): void
|
||||
{
|
||||
// nullsafe
|
||||
$blog_id = is_null(dcCore::app()->blog) ? '' : dcCore::app()->blog->id;
|
||||
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(dcCore::app()->prefix . My::ALIAS_TABLE_NAME)
|
||||
->where('blog_id = ' . $sql->quote($blog_id))
|
||||
$sql->from(App::con()->prefix() . My::ALIAS_TABLE_NAME)
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->delete();
|
||||
}
|
||||
|
||||
|
@ -167,12 +149,9 @@ class Utils
|
|||
*/
|
||||
public static function deleteAlias(string $url): void
|
||||
{
|
||||
// nullsafe
|
||||
$blog_id = is_null(dcCore::app()->blog) ? '' : dcCore::app()->blog->id;
|
||||
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(dcCore::app()->prefix . My::ALIAS_TABLE_NAME)
|
||||
->where('blog_id = ' . $sql->quote($blog_id))
|
||||
$sql->from(App::con()->prefix() . My::ALIAS_TABLE_NAME)
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->and('filesalias_url = ' . $sql->quote($url))
|
||||
->delete();
|
||||
}
|
||||
|
@ -186,14 +165,13 @@ class Utils
|
|||
*/
|
||||
public static function getMediaId(string $target): int
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return 0;
|
||||
}
|
||||
$path = dcCore::app()->blog->settings->get('system')->get('public_path');
|
||||
$path = App::blog()->settings()->get('system')->get('public_path');
|
||||
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql->from(dcCore::app()->prefix . dcMedia::MEDIA_TABLE_NAME)
|
||||
$rs = $sql->from(App::con()->prefix() . App::postMedia()::MEDIA_TABLE_NAME)
|
||||
->column('media_id')
|
||||
->where('media_path = ' . $sql->quote(is_string($path) ? $path : ''))
|
||||
->and('media_file = ' . $sql->quote($target))
|
||||
|
|
Loading…
Reference in a new issue