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