upgrade to Dotclear 2.28
This commit is contained in:
parent
39df98dcd8
commit
53f72a8748
14 changed files with 175 additions and 219 deletions
|
@ -1,3 +1,9 @@
|
|||
alias 1.10 - 2023.10.15
|
||||
===========================================================
|
||||
* require Dotclear 2.28
|
||||
* require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
alias 1.9 - 2023.08.06
|
||||
===========================================================
|
||||
* require Dotclear 2.27
|
||||
|
|
16
README.md
16
README.md
|
@ -1,10 +1,10 @@
|
|||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-1.9-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/alias/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.08.07-c44d58.svg)]
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Release](https://img.shields.io/badge/release-1.10-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/alias/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.10.15-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/alias)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/alias/blob/master/LICENSE)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/alias/src/branch/master/LICENSE)
|
||||
|
||||
## ABOUT
|
||||
|
||||
|
@ -14,8 +14,8 @@ _alias_ is a plugin for the open-source web publishing software called [Dotclear
|
|||
|
||||
## REQUIREMENTS
|
||||
|
||||
* Dotclear 2.27
|
||||
* PHP 7.4+
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
* Dotclear admin permission for management
|
||||
|
||||
## USAGE
|
||||
|
@ -38,7 +38,7 @@ so more there are aliases, more page load is slow.
|
|||
|
||||
## LINKS
|
||||
|
||||
* [License](https://git.dotclear.watch/JcDenis/alias/blob/master/LICENSE)
|
||||
* [License](https://git.dotclear.watch/JcDenis/alias/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/alias/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/alias))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/alias) (or on [GitHub](https://github.com/JcDenis/alias))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/alias/issues) (or on [GitHub](https://github.com/JcDenis/alias/issues))
|
||||
|
@ -47,6 +47,6 @@ so more there are aliases, more page load is slow.
|
|||
|
||||
* Olivier Meunier (author)
|
||||
* Franck-paul
|
||||
* Jean-Christian Denis
|
||||
* Jean-Christian Denis (latest)
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
|
36
_define.php
36
_define.php
|
@ -1,33 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin alias definition
|
||||
* @ingroup alias
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup alias Plugin alias.
|
||||
*
|
||||
* @author Olivier Meunier and contributors
|
||||
* Create aliases of your blog's URLs.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Olivier Meunier (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(
|
||||
'alias',
|
||||
"Create aliases of your blog's URLs",
|
||||
'Olivier Meunier and contributors',
|
||||
'1.9',
|
||||
'1.10',
|
||||
[
|
||||
'requires' => [['core', '2.27']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
]),
|
||||
'type' => 'plugin',
|
||||
'priority' => 2,
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/alias/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/alias/src/branch/master/README.md',
|
||||
'repository' => 'https://git.dotclear.watch/JcDenis/alias/raw/branch/master/dcstore.xml',
|
||||
'requires' => [['core', '2.28']],
|
||||
'permissions' => 'My',
|
||||
'type' => 'plugin',
|
||||
'priority' => 2,
|
||||
'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',
|
||||
]
|
||||
);
|
||||
|
|
20
_init.php
20
_init.php
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier 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 initAlias
|
||||
{
|
||||
public const ALIAS_TABLE_NAME = 'alias';
|
||||
}
|
|
@ -2,11 +2,11 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="alias">
|
||||
<name>alias</name>
|
||||
<version>1.9</version>
|
||||
<version>1.10</version>
|
||||
<author>Olivier Meunier and contributors</author>
|
||||
<desc>Create aliases of your blog's URLs</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/alias/releases/download/v1.9/plugin-alias.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/alias/releases/download/v1.10/plugin-alias.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/alias/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/alias/issues</da:support>
|
||||
</module>
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin alias resources
|
||||
* @ingroup alias
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Olivier Meunier (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;
|
||||
}
|
||||
|
||||
dcCore::app()->resources['help']['alias'] = __DIR__ . '/help/help.html';
|
||||
\Dotclear\App::backend()->resources()->set('help', 'alias', __DIR__ . '/help/help.html');
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin alias resources
|
||||
* @ingroup alias
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* @author Olivier Meunier (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;
|
||||
}
|
||||
|
||||
dcCore::app()->resources['help']['alias'] = __DIR__ . '/help/help.html';
|
||||
\Dotclear\App::backend()->resources()->set('help', 'alias', __DIR__ . '/help/help.html');
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier 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\alias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Database\Statement\{
|
||||
DeleteStatement,
|
||||
SelectStatement
|
||||
|
@ -22,17 +12,33 @@ use Dotclear\Database\Statement\{
|
|||
use Exception;
|
||||
|
||||
/**
|
||||
* plugin Alias main class
|
||||
* @brief alias main class.
|
||||
* @ingroup alias
|
||||
*
|
||||
* @author Olivier Meunier (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Alias
|
||||
{
|
||||
/** @var array $aliases Stak of aliases */
|
||||
/**
|
||||
* Alias table name.
|
||||
*
|
||||
* @var string ALIAS_TABLE_NAME
|
||||
*/
|
||||
public const ALIAS_TABLE_NAME = 'alias';
|
||||
|
||||
/**
|
||||
* Stack of aliases.
|
||||
*
|
||||
* @var array<int, array<string, string>> $aliases
|
||||
*/
|
||||
protected array $aliases = [];
|
||||
|
||||
/**
|
||||
* Get aliases.
|
||||
*
|
||||
* @return array Stack of aliases
|
||||
* @return array<int, array<string, string>> Stack of aliases
|
||||
*/
|
||||
public function getAliases(): array
|
||||
{
|
||||
|
@ -40,20 +46,19 @@ class Alias
|
|||
return $this->aliases;
|
||||
}
|
||||
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql->from(dcCore::app()->prefix . My::ALIAS_TABLE_NAME)
|
||||
$rs = $sql->from(App::con()->prefix() . Alias::ALIAS_TABLE_NAME)
|
||||
->columns([
|
||||
'alias_url',
|
||||
'alias_destination',
|
||||
'alias_position',
|
||||
'alias_redirect',
|
||||
])
|
||||
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog->id))
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->order('alias_position ASC')
|
||||
->select();
|
||||
|
||||
|
@ -65,7 +70,7 @@ class Alias
|
|||
/**
|
||||
* Update aliases stack.
|
||||
*
|
||||
* @param array $aliases The alias stack
|
||||
* @param array<int, array<string, string>> $aliases The alias stack
|
||||
*/
|
||||
public function updateAliases(array $aliases): void
|
||||
{
|
||||
|
@ -76,7 +81,7 @@ class Alias
|
|||
}
|
||||
}
|
||||
|
||||
dcCore::app()->con->begin();
|
||||
App::con()->begin();
|
||||
|
||||
try {
|
||||
$this->deleteAliases();
|
||||
|
@ -86,9 +91,9 @@ class Alias
|
|||
}
|
||||
}
|
||||
|
||||
dcCore::app()->con->commit();
|
||||
App::con()->commit();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->con->rollback();
|
||||
App::con()->rollback();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
@ -104,8 +109,7 @@ class Alias
|
|||
*/
|
||||
public function createAlias(string $url, string $destination, int $position, bool $redirect): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -119,8 +123,8 @@ class Alias
|
|||
throw new Exception(__('Alias destination is empty.'));
|
||||
}
|
||||
|
||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . My::ALIAS_TABLE_NAME);
|
||||
$cur->setField('blog_id', (string) dcCore::app()->blog->id);
|
||||
$cur = App::con()->openCursor(App::con()->prefix() . Alias::ALIAS_TABLE_NAME);
|
||||
$cur->setField('blog_id', App::blog()->id());
|
||||
$cur->setField('alias_url', (string) $url);
|
||||
$cur->setField('alias_destination', (string) $destination);
|
||||
$cur->setField('alias_position', abs((int) $position));
|
||||
|
@ -135,14 +139,13 @@ class Alias
|
|||
*/
|
||||
public function deleteAlias(string $url): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(dcCore::app()->prefix . My::ALIAS_TABLE_NAME)
|
||||
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog->id))
|
||||
$sql->from(App::con()->prefix() . Alias::ALIAS_TABLE_NAME)
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->and('alias_url = ' . $sql->quote($url))
|
||||
->delete();
|
||||
}
|
||||
|
@ -152,14 +155,13 @@ class Alias
|
|||
*/
|
||||
public function deleteAliases(): void
|
||||
{
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
if (!App::blog()->isDefined()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(dcCore::app()->prefix . My::ALIAS_TABLE_NAME)
|
||||
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog->id))
|
||||
$sql->from(App::con()->prefix() . Alias::ALIAS_TABLE_NAME)
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->delete();
|
||||
}
|
||||
|
||||
|
@ -172,6 +174,6 @@ class Alias
|
|||
*/
|
||||
public static function removeBlogUrl(string $url): string
|
||||
{
|
||||
return is_null(dcCore::app()->blog) ? trim($url) : str_replace(dcCore::app()->blog->url, '', trim($url));
|
||||
return App::blog()->isDefined() ? str_replace(App::blog()->url(), '', trim($url)) : trim($url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier 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\alias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\importExport\{
|
||||
FlatBackupItem,
|
||||
|
@ -22,6 +12,14 @@ use Dotclear\Plugin\importExport\{
|
|||
FlatImportV2
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief alias backend class.
|
||||
* @ingroup alias
|
||||
*
|
||||
* @author Olivier Meunier (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
|
||||
|
@ -37,25 +35,25 @@ class Backend extends Process
|
|||
|
||||
My::addBackendMenuItem();
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
App::behavior()->addBehaviors([
|
||||
'exportFullV2' => function (FlatExport $exp): void {
|
||||
$exp->exportTable(My::ALIAS_TABLE_NAME);
|
||||
$exp->exportTable(Alias::ALIAS_TABLE_NAME);
|
||||
},
|
||||
'exportSingleV2' => function (FlatExport $exp, ?string $blog_id): void {
|
||||
$exp->export(
|
||||
'alias',
|
||||
'SELECT alias_url, alias_destination, alias_position ' .
|
||||
'FROM ' . dcCore::app()->prefix . My::ALIAS_TABLE_NAME . ' A ' .
|
||||
'FROM ' . App::con()->prefix() . Alias::ALIAS_TABLE_NAME . ' A ' .
|
||||
"WHERE A.blog_id = '" . $blog_id . "'"
|
||||
);
|
||||
},
|
||||
'importInitV2' => function (FlatImportV2 $bk): void {
|
||||
$bk->cur_alias = dcCore::app()->con->openCursor(dcCore::app()->prefix . My::ALIAS_TABLE_NAME);
|
||||
$bk->cur_alias = App::con()->openCursor(App::con()->prefix() . Alias::ALIAS_TABLE_NAME);
|
||||
$bk->alias = new Alias();
|
||||
$bk->aliases = $bk->alias->getAliases();
|
||||
},
|
||||
'importFullV2' => function (/*bool|FlatBackupItem */$line, FlatImportV2 $bk): void {
|
||||
if ($line->__name == My::ALIAS_TABLE_NAME) {
|
||||
if ($line->__name == Alias::ALIAS_TABLE_NAME) {
|
||||
$bk->cur_alias->clean();
|
||||
$bk->cur_alias->setField('blog_id', (string) $line->blog_id);
|
||||
$bk->cur_alias->setField('alias_url', (string) $line->alias_url);
|
||||
|
@ -65,7 +63,7 @@ class Backend extends Process
|
|||
}
|
||||
},
|
||||
'importSingleV2' => function (/*bool|FlatBackupItem */$line, FlatImportV2 $bk): void {
|
||||
if ($line->__name == My::ALIAS_TABLE_NAME) {
|
||||
if ($line->__name == Alias::ALIAS_TABLE_NAME) {
|
||||
$found = false;
|
||||
foreach ($bk->aliases as $v) {
|
||||
if ($v['alias_url'] == $line->alias_url) {
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier 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\alias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\Structure;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief alias install class.
|
||||
* @ingroup alias
|
||||
*
|
||||
* @author Olivier Meunier (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,8 +31,8 @@ class Install extends Process
|
|||
}
|
||||
|
||||
try {
|
||||
$s = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$s->__get(My::ALIAS_TABLE_NAME)
|
||||
$s = new Structure(App::con(), App::con()->prefix());
|
||||
$s->__get(Alias::ALIAS_TABLE_NAME)
|
||||
->field('blog_id', 'varchar', 32, false)
|
||||
->field('alias_url', 'varchar', 255, false)
|
||||
->field('alias_destination', 'varchar', 255, false)
|
||||
|
@ -49,11 +47,11 @@ class Install extends Process
|
|||
->reference('fk_alias_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 false;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier 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\alias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
|
@ -37,7 +27,12 @@ use Dotclear\Helper\Html\Html;
|
|||
use Exception;
|
||||
|
||||
/**
|
||||
* Manage contributions list
|
||||
* @brief alias manage class.
|
||||
* @ingroup alias
|
||||
*
|
||||
* @author Olivier Meunier (author)
|
||||
* @author Jean-Christian Denis (latest)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Manage extends Process
|
||||
{
|
||||
|
@ -66,7 +61,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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +72,7 @@ class Manage extends Process
|
|||
Notices::addSuccessNotice(__('Alias successfully created.'));
|
||||
My::redirect();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +101,7 @@ class Manage extends Process
|
|||
|
||||
(new Div())->items([
|
||||
(new Text('h3', __('New alias'))),
|
||||
(new Form(My::id() . '_form'))->method('post')->action(dcCore::app()->admin->getPageURL())->fields([
|
||||
(new Form(My::id() . '_form'))->method('post')->action(App::backend()->getPageURL())->fields([
|
||||
(new Para())->class('field')->items([
|
||||
(new Label(__('Alias URL:'), Label::OUTSIDE_LABEL_BEFORE))->for('alias_url'),
|
||||
(new Input('alias_url'))->size(50)->maxlenght(255),
|
||||
|
@ -115,7 +110,7 @@ class Manage extends Process
|
|||
(new Label(__('Alias destination:'), Label::OUTSIDE_LABEL_BEFORE))->for('alias_destination'),
|
||||
(new Input('alias_destination'))->size(50)->maxlenght(255),
|
||||
]),
|
||||
(new Note())->class('form-note')->text(sprintf(__('Do not put blog URL "%s" in fields.'), dcCore::app()->blog->url)),
|
||||
(new Note())->class('form-note')->text(sprintf(__('Do not put blog URL "%s" in fields.'), App::blog()->url())),
|
||||
(new Para())->items([
|
||||
(new Checkbox('alias_redirect', false))->value(1),
|
||||
(new Label(__('Do visible redirection to destination'), Label::OUTSIDE_LABEL_AFTER))->for('alias_redirect')->class('classic'),
|
||||
|
@ -143,7 +138,7 @@ class Manage extends Process
|
|||
echo '<p>' . __('No alias') . '</p>';
|
||||
} else {
|
||||
echo
|
||||
'<form action="' . dcCore::app()->admin->getPageURL() . '" method="post">' .
|
||||
'<form action="' . App::backend()->getPageURL() . '" method="post">' .
|
||||
'<p>' . sprintf(__('There is %s alias.', 'There are %s aliases.', count($aliases)), count($aliases)) . '</p>' .
|
||||
'<div class="table-outer">' .
|
||||
'<table>' .
|
||||
|
@ -167,7 +162,7 @@ class Manage extends Process
|
|||
'<td class="minimal">' .
|
||||
(new Number(['a[' . $k . '][alias_position]']))->min(1)->max(count($aliases))->default((int) $v['alias_position'])->class('position')->title(sprintf(__('position of %s'), Html::escapeHTML($v['alias_url'])))->render() . '</td>' .
|
||||
'<td class="maximal">' .
|
||||
(new Checkbox(['a[' . $k . '][alias_redirect]'], (bool) $v['alias_redirect']))->title(sprintf(__('visible redirection to %s'), Html::escapeHTML(dcCore::app()->blog->url . $v['alias_destination'])))->render() . '</td>' .
|
||||
(new Checkbox(['a[' . $k . '][alias_redirect]'], (bool) $v['alias_redirect']))->title(sprintf(__('visible redirection to %s'), Html::escapeHTML(App::blog()->url() . $v['alias_destination'])))->render() . '</td>' .
|
||||
'</tr>';
|
||||
}
|
||||
|
||||
|
|
37
src/My.php
37
src/My.php
|
@ -1,36 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier 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\alias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
* @brief alias My helper.
|
||||
* @ingroup alias
|
||||
*
|
||||
* @author Olivier Meunier (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 Plugin table name */
|
||||
public const ALIAS_TABLE_NAME = 'alias';
|
||||
|
||||
public static function checkCustomContext(int $context): ?bool
|
||||
{
|
||||
return !in_array($context, [My::BACKEND, My::MANAGE, My::MENU]) ? null :
|
||||
defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
]), dcCore::app()->blog->id);
|
||||
return match ($context) {
|
||||
My::BACKEND, My::MANAGE, My::MENU => App::task()->checkContext('BACKEND')
|
||||
&& App::auth()->check(App::auth()->makePermissions([
|
||||
App::auth()::PERMISSION_ADMIN,
|
||||
]), App::blog()->id()),
|
||||
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier 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\alias;
|
||||
|
||||
use dcCore;
|
||||
use dcUrlHandlers;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Frontend\Url;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Network\Http;
|
||||
|
||||
/**
|
||||
* @brief alias prepend class.
|
||||
* @ingroup alias
|
||||
*
|
||||
* @author Olivier Meunier (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
|
||||
|
@ -32,7 +30,7 @@ class Prepend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehavior('urlHandlerGetArgsDocument', function (dcUrlHandlers $handler): void {
|
||||
App::behavior()->addBehavior('urlHandlerGetArgsDocument', function (Url $handler): void {
|
||||
$found = $redir = false;
|
||||
$type = '';
|
||||
$part = $args = $_SERVER['URL_REQUEST_PART'];
|
||||
|
@ -63,19 +61,20 @@ class Prepend extends Process
|
|||
|
||||
// Use visible redirection
|
||||
if ($redir) {
|
||||
Http::redirect(dcCore::app()->blog->url . $part);
|
||||
Http::redirect(App::blog()->url() . $part);
|
||||
}
|
||||
|
||||
// regain URL type
|
||||
$_SERVER['URL_REQUEST_PART'] = $part;
|
||||
dcCore::app()->url->getArgs($part, $type, $args);
|
||||
$handler->getArgs($part, $type, $args);
|
||||
|
||||
// call real handler
|
||||
if (!$type) {
|
||||
dcCore::app()->url->callDefaultHandler($args);
|
||||
$handler->callDefaultHandler($args);
|
||||
} else {
|
||||
dcCore::app()->url->callHandler($type, $args);
|
||||
$handler->callHandler($type, $args);
|
||||
}
|
||||
exit;
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief alias, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Olivier Meunier 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\alias;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
/**
|
||||
* @brief alias uninstall class.
|
||||
* @ingroup alias
|
||||
*
|
||||
* @author Olivier Meunier (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;
|
||||
}
|
||||
|
||||
|
@ -35,7 +32,7 @@ class Uninstall extends Process
|
|||
->addUserAction(
|
||||
'tables',
|
||||
'delete',
|
||||
My::ALIAS_TABLE_NAME
|
||||
Alias::ALIAS_TABLE_NAME
|
||||
)
|
||||
->addUserAction(
|
||||
'plugins',
|
||||
|
@ -51,7 +48,7 @@ class Uninstall extends Process
|
|||
->addDirectAction(
|
||||
'tables',
|
||||
'delete',
|
||||
My::ALIAS_TABLE_NAME
|
||||
Alias::ALIAS_TABLE_NAME
|
||||
)
|
||||
->addDirectAction(
|
||||
'plugins',
|
||||
|
|
Loading…
Reference in a new issue