upgrade to Dotclear 2.28
This commit is contained in:
parent
2063f6e4f9
commit
f38c7328a9
38 changed files with 620 additions and 750 deletions
|
@ -1,3 +1,10 @@
|
|||
kUtRL 2023.10.19
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
* Upgrade plugin activityReport
|
||||
|
||||
kUtRL 2023.08.21
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-2023.08.21-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/kUtRL/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.08.21-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-2023.10.19-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/kUtRL/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.10.19-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/kUtRL)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/kUtRL/src/branch/master/LICENSE)
|
||||
|
||||
|
@ -14,7 +14,7 @@ _kUtRL_ is a plugin for the open-source web publishing software called [Dotclear
|
|||
|
||||
## REQUIREMENTS
|
||||
|
||||
* Dotclear 2.27
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
* Dotclear admin permission to configure
|
||||
* No specials permissions to shorten links on the fly
|
||||
|
|
28
_define.php
28
_define.php
|
@ -1,34 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin kUtRL definition
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
* @defgroup kUtRL Plugin kUtRL.
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
* Use, create and serve short url on your blog.
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @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(
|
||||
'Links shortener',
|
||||
'Use, create and serve short url on your blog',
|
||||
'Jean-Christian Denis and contributors',
|
||||
'2023.08.21',
|
||||
'2023.10.19',
|
||||
[
|
||||
'requires' => [
|
||||
['core', '2.27'],
|
||||
['php', '8.1'],
|
||||
],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_USAGE,
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
]),
|
||||
'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',
|
||||
|
|
20
_init.php
20
_init.php
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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 initkUtRL
|
||||
{
|
||||
public const KURL_TABLE_NAME = 'kutrl';
|
||||
}
|
|
@ -2,11 +2,11 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="kUtRL">
|
||||
<name>Links shortener</name>
|
||||
<version>2023.08.21</version>
|
||||
<version>2023.10.19</version>
|
||||
<author>Jean-Christian Denis and contributors</author>
|
||||
<desc>Use, create and serve short url on your blog</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/kUtRL/releases/download/v2023.08.21/plugin-kUtRL.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/kUtRL/releases/download/v2023.10.19/plugin-kUtRL.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/kUtRL/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/kUtRL/issues</da:support>
|
||||
</module>
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin kUtRL locales resources
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->resources['help']['kUtRL'] = __DIR__ . '/help/help.html';
|
||||
\Dotclear\App::backend()->resources()->set('help', 'kUtRL', __DIR__ . '/help/help.html');
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
* @file
|
||||
* @brief The plugin kUtRL locales resources
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->resources['help']['kUtRL'] = __DIR__ . '/help/help.html';
|
||||
\Dotclear\App::backend()->resources()->set('help', 'kUtRL', __DIR__ . '/help/help.html');
|
||||
|
|
54
src/ActivityReportAction.php
Normal file
54
src/ActivityReportAction.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\kUtRL;
|
||||
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Plugin\activityReport\{
|
||||
Action,
|
||||
ActivityReport,
|
||||
Group
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief kUtRL plugin activityReport class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* Add links actions to the plugin activity report.
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ActivityReportAction extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(true);
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$group = new Group(My::id(), My::name());
|
||||
|
||||
# from BEHAVIOR kutrlAfterCreateShortUrl in kUtRL/inc/lib.kutrl.srv.php
|
||||
$group->add(new Action(
|
||||
'kUtRLcreate',
|
||||
__('Short link creation'),
|
||||
__('New short link of type "%s" and hash "%s" was created.'),
|
||||
'kutrlAfterCreateShortUrl',
|
||||
function (MetaRecord $rs) {
|
||||
ActivityReport::instance()->addLog(My::id(), 'kUtRLcreate', [$rs->type, $rs->hash]);
|
||||
}
|
||||
));
|
||||
|
||||
ActivityReport::instance()->groups->add($group);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
# This file is used with plugin activityReport
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dcCore::app()->__get('activityReport')->addGroup('kutrl', __('Plugin kUtRL'));
|
||||
|
||||
# from BEHAVIOR kutrlAfterCreateShortUrl in kUtRL/inc/lib.kutrl.srv.php
|
||||
dcCore::app()->__get('activityReport')->addAction(
|
||||
'kutrl',
|
||||
'create',
|
||||
__('Short link creation'),
|
||||
__('New short link of type "%s" and hash "%s" was created.'),
|
||||
'kutrlAfterCreateShortUrl',
|
||||
function ($rs) {
|
||||
dcCore::app()->__get('activityReport')->addLog('kutrl', 'create', [$rs->type, $rs->hash]);
|
||||
}
|
||||
);
|
|
@ -1,24 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* Backend prepend.
|
||||
* @brief kUtRL backend class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
|
@ -38,29 +32,27 @@ class Backend extends Process
|
|||
|
||||
# Admin behaviors
|
||||
if (My::settings()->get('active')) {
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminDashboardFavoritesV2' => [BackendBehaviors::class, 'antispamDashboardFavoritesV2'],
|
||||
'adminColumnsListsV2' => [BackendBehaviors::class, 'adminColumnsListsV2'],
|
||||
'adminFiltersListsV2' => [BackendBehaviors::class, 'adminFiltersListsV2'],
|
||||
'adminPostHeaders' => [BackendBehaviors::class, 'adminPostHeaders'],
|
||||
'adminPostFormItems' => [BackendBehaviors::class, 'adminPostFormItems'],
|
||||
'adminAfterPostUpdate' => [BackendBehaviors::class, 'adminAfterPostUpdate'], // update existing short url
|
||||
'adminAfterPostUpdate' => [BackendBehaviors::class, 'adminAfterPostCreate'], // create new short url
|
||||
'adminAfterPostCreate' => [BackendBehaviors::class, 'adminAfterPostCreate'],
|
||||
'adminBeforePostDelete' => [BackendBehaviors::class, 'adminBeforePostDelete'],
|
||||
'adminPostsActions' => [BackendBehaviors::class, 'adminPostsActions'],
|
||||
App::behavior()->addBehaviors([
|
||||
'adminDashboardFavoritesV2' => BackendBehaviors::antispamDashboardFavoritesV2(...),
|
||||
'adminColumnsListsV2' => BackendBehaviors::adminColumnsListsV2(...),
|
||||
'adminFiltersListsV2' => BackendBehaviors::adminFiltersListsV2(...),
|
||||
'adminPostHeaders' => BackendBehaviors::adminPostHeaders(...),
|
||||
'adminPostFormItems' => BackendBehaviors::adminPostFormItems(...),
|
||||
'adminAfterPostUpdate' => BackendBehaviors::adminAfterPostUpdate(...), // update existing short url
|
||||
'adminAfterPostUpdate' => BackendBehaviors::adminAfterPostCreate(...), // create new short url
|
||||
'adminAfterPostCreate' => BackendBehaviors::adminAfterPostCreate(...),
|
||||
'adminBeforePostDelete' => BackendBehaviors::adminBeforePostDelete(...),
|
||||
'adminPostsActions' => BackendBehaviors::adminPostsActions(...),
|
||||
]);
|
||||
}
|
||||
|
||||
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initShorten']);
|
||||
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initRank']);
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'exportFullV2' => [ImportExportBehaviors::class, 'exportFullV2'],
|
||||
'exportSingleV2' => [ImportExportBehaviors::class, 'exportSingleV2'],
|
||||
'importInitV2' => [ImportExportBehaviors::class, 'importInitV2'],
|
||||
'importSingleV2' => [ImportExportBehaviors::class, 'importSingleV2'],
|
||||
'importFullV2' => [ImportExportBehaviors::class, 'importFullV2'],
|
||||
App::behavior()->addBehaviors([
|
||||
'initWidgets' => Widgets::init(...),
|
||||
'exportFullV2' => ImportExportBehaviors::exportFullV2(...),
|
||||
'exportSingleV2' => ImportExportBehaviors::exportSingleV2(...),
|
||||
'importInitV2' => ImportExportBehaviors::importInitV2(...),
|
||||
'importSingleV2' => ImportExportBehaviors::importSingleV2(...),
|
||||
'importFullV2' => ImportExportBehaviors::importFullV2(...),
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,27 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\{
|
||||
Action\ActionsPosts,
|
||||
Favorites,
|
||||
Notices
|
||||
};
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Database\{
|
||||
Cursor,
|
||||
MetaRecord
|
||||
};
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
|
@ -35,7 +28,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
|
||||
# Admin behaviors class
|
||||
/**
|
||||
* @brief kUtRL backend behaviors.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class BackendBehaviors
|
||||
{
|
||||
public static function antispamDashboardFavoritesV2(Favorites $favs): void
|
||||
|
@ -47,7 +46,7 @@ class BackendBehaviors
|
|||
'url' => My::manageUrl(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]),
|
||||
'permissions' => App::auth()->makePermissions([App::auth()::PERMISSION_ADMIN]),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -182,7 +181,7 @@ class BackendBehaviors
|
|||
return;
|
||||
}
|
||||
|
||||
$rs = dcCore::app()->blog->getPosts(['post_id' => $post_id]);
|
||||
$rs = App::blog()->getPosts(['post_id' => $post_id]);
|
||||
if ($rs->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -205,7 +204,7 @@ class BackendBehaviors
|
|||
|
||||
# ex: Send new url to messengers
|
||||
if (!empty($rs)) {
|
||||
dcCore::app()->callBehavior('adminAfterKutrlCreate', $rs, $title);
|
||||
App::behavior()->callBehavior('adminAfterKutrlCreate', $rs, $title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +218,7 @@ class BackendBehaviors
|
|||
return;
|
||||
}
|
||||
|
||||
$rs = dcCore::app()->blog->getPosts(['post_id' => $post_id]);
|
||||
$rs = App::blog()->getPosts(['post_id' => $post_id]);
|
||||
if ($rs->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -233,7 +232,7 @@ class BackendBehaviors
|
|||
|
||||
# ex: Send new url to messengers
|
||||
if (!empty($rs)) {
|
||||
dcCore::app()->callBehavior('adminAfterKutrlCreate', $rs, $title);
|
||||
App::behavior()->callBehavior('adminAfterKutrlCreate', $rs, $title);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,7 +244,7 @@ class BackendBehaviors
|
|||
return;
|
||||
}
|
||||
|
||||
$rs = dcCore::app()->blog->getPosts(['post_id' => $post_id]);
|
||||
$rs = App::blog()->getPosts(['post_id' => $post_id]);
|
||||
if ($rs->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -256,17 +255,17 @@ class BackendBehaviors
|
|||
public static function adminPostsActions(ActionsPosts $pa): void
|
||||
{
|
||||
if (!My::settings()->get('active')
|
||||
|| !dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]), dcCore::app()->blog->id)) {
|
||||
|| !App::auth()->check(App::auth()->makePermissions([App::auth()::PERMISSION_ADMIN]), App::blog()->id())) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pa->addAction(
|
||||
[My::name() => [__('Create short link') => 'kutrl_create']],
|
||||
[self::class, 'callbackCreate']
|
||||
self::callbackCreate(...)
|
||||
);
|
||||
$pa->addAction(
|
||||
[My::name() => [__('Delete short link') => 'kutrl_delete']],
|
||||
[self::class, 'callbackDelete']
|
||||
self::callbackDelete(...)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -279,7 +278,7 @@ class BackendBehaviors
|
|||
}
|
||||
|
||||
# No right
|
||||
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]), dcCore::app()->blog->id)) {
|
||||
if (!App::auth()->check(App::auth()->makePermissions([App::auth()::PERMISSION_ADMIN]), App::blog()->id())) {
|
||||
throw new Exception(__('No enough right'));
|
||||
}
|
||||
|
||||
|
@ -288,7 +287,7 @@ class BackendBehaviors
|
|||
}
|
||||
|
||||
# retrieve posts info and create hash
|
||||
$posts = dcCore::app()->blog->getPosts(['post_id' => $posts_ids]);
|
||||
$posts = App::blog()->getPosts(['post_id' => $posts_ids]);
|
||||
while ($posts->fetch()) {
|
||||
$kut->hash($posts->getURL());
|
||||
}
|
||||
|
@ -306,7 +305,7 @@ class BackendBehaviors
|
|||
}
|
||||
|
||||
# No right
|
||||
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_ADMIN]), dcCore::app()->blog->id)) {
|
||||
if (!App::auth()->check(App::auth()->makePermissions([App::auth()::PERMISSION_ADMIN]), App::blog()->id())) {
|
||||
throw new Exception(__('No enough right'));
|
||||
}
|
||||
|
||||
|
@ -315,7 +314,7 @@ class BackendBehaviors
|
|||
}
|
||||
|
||||
# retrieve posts info and create hash
|
||||
$posts = dcCore::app()->blog->getPosts(['post_id' => $posts_ids]);
|
||||
$posts = App::blog()->getPosts(['post_id' => $posts_ids]);
|
||||
while ($posts->fetch()) {
|
||||
$kut->remove($posts->getURL());
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
/**
|
||||
* @brief kUtRL combo.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Combo
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Notices;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
|
@ -30,7 +20,11 @@ use Dotclear\Helper\Html\Form\{
|
|||
use Exception;
|
||||
|
||||
/**
|
||||
* Backend module configuration.
|
||||
* @brief kUtRL config class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Config extends Process
|
||||
{
|
||||
|
@ -92,18 +86,18 @@ class Config extends Process
|
|||
$o->saveSettings();
|
||||
}
|
||||
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
App::blog()->triggerBlog();
|
||||
|
||||
Notices::addSuccessNotice(
|
||||
__('Configuration successfully updated.')
|
||||
);
|
||||
|
||||
dcCore::app()->admin->url->redirect(
|
||||
App::backend()->url()->redirect(
|
||||
'admin.plugins',
|
||||
['module' => My::id(), 'conf' => 1, 'chk' => 1, 'redir' => dcCore::app()->admin->list->getRedir()]
|
||||
['module' => My::id(), 'conf' => 1, 'chk' => 1, 'redir' => App::backend()->__get('list')->getRedir()]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +160,7 @@ class Config extends Process
|
|||
$img_chk = $img_green . ' ' . sprintf(__('%s API is well configured and runing.'), $o->name);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add(sprintf(__('Failed to test service %s: %s'), $o->name, $e->getMessage()));
|
||||
App::error()->add(sprintf(__('Failed to test service %s: %s'), $o->name, $e->getMessage()));
|
||||
}
|
||||
$s_items[] = (new Text(null, sprintf('<p><em>%s</em></p>', $img_chk) . $o->error->toHTML()));
|
||||
}
|
||||
|
|
|
@ -1,25 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* Frontend prepend.
|
||||
* @brief kUtRL frontend class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Frontend extends Process
|
||||
{
|
||||
|
@ -34,41 +27,40 @@ class Frontend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->tpl->setPath(
|
||||
dcCore::app()->tpl->getPath(),
|
||||
App::frontend()->template()->setPath(
|
||||
App::frontend()->template()->getPath(),
|
||||
My::path() . DIRECTORY_SEPARATOR . 'default-templates'
|
||||
);
|
||||
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initShorten']);
|
||||
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initRank']);
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'publicBeforeDocumentV2' => [FrontendBehaviors::class, 'publicBeforeDocumentV2'],
|
||||
'publicHeadContent' => [FrontendBehaviors::class, 'publicHeadContent'],
|
||||
'publicBeforeContentFilterV2' => [FrontendBehaviors::class, 'publicBeforeContentFilterV2'],
|
||||
'templateBeforeValueV2' => [FrontendBehaviors::class, 'templateBeforeValueV2'],
|
||||
'templateAfterValueV2' => [FrontendBehaviors::class, 'templateAfterValueV2'],
|
||||
App::behavior()->addBehaviors([
|
||||
'initWidgets' => Widgets::init(...),
|
||||
'publicBeforeDocumentV2' => FrontendBehaviors::publicBeforeDocumentV2(...),
|
||||
'publicHeadContent' => FrontendBehaviors::publicHeadContent(...),
|
||||
'publicBeforeContentFilterV2' => FrontendBehaviors::publicBeforeContentFilterV2(...),
|
||||
'templateBeforeValueV2' => FrontendBehaviors::templateBeforeValueV2(...),
|
||||
'templateAfterValueV2' => FrontendBehaviors::templateAfterValueV2(...),
|
||||
]);
|
||||
|
||||
dcCore::app()->tpl->addBlock('kutrlPageIf', [FrontendTemplate::class, 'pageIf']);
|
||||
dcCore::app()->tpl->addBlock('kutrlMsgIf', [FrontendTemplate::class, 'pageMsgIf']);
|
||||
App::frontend()->template()->addBlock('kutrlPageIf', FrontendTemplate::pageIf(...));
|
||||
App::frontend()->template()->addBlock('kutrlMsgIf', FrontendTemplate::pageMsgIf(...));
|
||||
|
||||
dcCore::app()->tpl->addValue('kutrlPageURL', [FrontendTemplate::class, 'pageURL']);
|
||||
dcCore::app()->tpl->addValue('kutrlMsg', [FrontendTemplate::class, 'pageMsg']);
|
||||
dcCore::app()->tpl->addValue('kutrlHumanField', [FrontendTemplate::class, 'humanField']);
|
||||
dcCore::app()->tpl->addValue('kutrlHumanFieldProtect', [FrontendTemplate::class, 'humanFieldProtect']);
|
||||
App::frontend()->template()->addValue('kutrlPageURL', FrontendTemplate::pageURL(...));
|
||||
App::frontend()->template()->addValue('kutrlMsg', FrontendTemplate::pageMsg(...));
|
||||
App::frontend()->template()->addValue('kutrlHumanField', FrontendTemplate::humanField(...));
|
||||
App::frontend()->template()->addValue('kutrlHumanFieldProtect', FrontendTemplate::humanFieldProtect(...));
|
||||
|
||||
dcCore::app()->tpl->addBlock('AttachmentKutrlIf', [FrontendTemplate::class, 'AttachmentKutrlIf']);
|
||||
dcCore::app()->tpl->addValue('AttachmentKutrl', [FrontendTemplate::class, 'AttachmentKutrl']);
|
||||
dcCore::app()->tpl->addBlock('MediaKutrlIf', [FrontendTemplate::class, 'MediaKutrlIf']);
|
||||
dcCore::app()->tpl->addValue('MediaKutrl', [FrontendTemplate::class, 'MediaKutrl']);
|
||||
dcCore::app()->tpl->addBlock('EntryAuthorKutrlIf', [FrontendTemplate::class, 'EntryAuthorKutrlIf']);
|
||||
dcCore::app()->tpl->addValue('EntryAuthorKutrl', [FrontendTemplate::class, 'EntryAuthorKutrl']);
|
||||
dcCore::app()->tpl->addBlock('EntryKutrlIf', [FrontendTemplate::class, 'EntryKutrlIf']);
|
||||
dcCore::app()->tpl->addValue('EntryKutrl', [FrontendTemplate::class, 'EntryKutrl']);
|
||||
dcCore::app()->tpl->addBlock('CommentAuthorKutrlIf', [FrontendTemplate::class, 'CommentAuthorKutrlIf']);
|
||||
dcCore::app()->tpl->addValue('CommentAuthorKutrl', [FrontendTemplate::class, 'CommentAuthorKutrl']);
|
||||
dcCore::app()->tpl->addBlock('CommentPostKutrlIf', [FrontendTemplate::class, 'CommentPostKutrlIf']);
|
||||
dcCore::app()->tpl->addValue('CommentPostKutrl', [FrontendTemplate::class, 'CommentPostKutrl']);
|
||||
App::frontend()->template()->addBlock('AttachmentKutrlIf', FrontendTemplate::AttachmentKutrlIf(...));
|
||||
App::frontend()->template()->addValue('AttachmentKutrl', FrontendTemplate::AttachmentKutrl(...));
|
||||
App::frontend()->template()->addBlock('MediaKutrlIf', FrontendTemplate::MediaKutrlIf(...));
|
||||
App::frontend()->template()->addValue('MediaKutrl', FrontendTemplate::MediaKutrl(...));
|
||||
App::frontend()->template()->addBlock('EntryAuthorKutrlIf', FrontendTemplate::EntryAuthorKutrlIf(...));
|
||||
App::frontend()->template()->addValue('EntryAuthorKutrl', FrontendTemplate::EntryAuthorKutrl(...));
|
||||
App::frontend()->template()->addBlock('EntryKutrlIf', FrontendTemplate::EntryKutrlIf(...));
|
||||
App::frontend()->template()->addValue('EntryKutrl', FrontendTemplate::EntryKutrl(...));
|
||||
App::frontend()->template()->addBlock('CommentAuthorKutrlIf', FrontendTemplate::CommentAuthorKutrlIf(...));
|
||||
App::frontend()->template()->addValue('CommentAuthorKutrl', FrontendTemplate::CommentAuthorKutrl(...));
|
||||
App::frontend()->template()->addBlock('CommentPostKutrlIf', FrontendTemplate::CommentPostKutrlIf(...));
|
||||
App::frontend()->template()->addValue('CommentPostKutrl', FrontendTemplate::CommentPostKutrl(...));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,30 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
|
||||
/**
|
||||
* @brief kUtRL frontend behaviors.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class FrontendBehaviors
|
||||
{
|
||||
# Disable URL shoretning on filtered tag
|
||||
public static function templateBeforeValueV2(string $tag, ArrayObject $attr): ?string
|
||||
{
|
||||
if (!empty($attr['disable_kutrl']) && in_array($tag, My::USED_TAGS)) {
|
||||
return '<?php dcCore::app()->ctx->__set("disable_kutrl", true); ?>';
|
||||
return '<?php App::frontend()->context()->__set("disable_kutrl", true); ?>';
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -34,7 +31,7 @@ class FrontendBehaviors
|
|||
public static function templateAfterValueV2(string $tag, ArrayObject $attr): ?string
|
||||
{
|
||||
if (!empty($attr['disable_kutrl']) && in_array($tag, My::USED_TAGS)) {
|
||||
return '<?php dcCore::app()->ctx->__set("disable_kutrl", false); ?>';
|
||||
return '<?php App::frontend()->context()->__set("disable_kutrl", false); ?>';
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -48,24 +45,24 @@ class FrontendBehaviors
|
|||
return null;
|
||||
}
|
||||
# URL shortening is disabled by tag attribute
|
||||
if (true !== dcCore::app()->ctx->__get('disable_kutrl')) {
|
||||
if (true !== App::frontend()->context()->__get('disable_kutrl')) {
|
||||
# plugin is not activated
|
||||
if (!My::settings()->get('active')
|
||||
|| !My::settings()->get('tpl_active')
|
||||
|| !dcCore::app()->ctx->exists('kutrl')
|
||||
|| !App::frontend()->context()->exists('kutrl')
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
# Existing
|
||||
if (false !== ($kutrl_rs = dcCore::app()->ctx->kutrl->isKnowUrl($args[0]))) {
|
||||
$args[0] = dcCore::app()->ctx->kutrl->url_base . $kutrl_rs->hash;
|
||||
if (false !== ($kutrl_rs = App::frontend()->context()->kutrl->isKnowUrl($args[0]))) {
|
||||
$args[0] = App::frontend()->context()->kutrl->url_base . $kutrl_rs->hash;
|
||||
# New
|
||||
} elseif (false !== ($kutrl_rs = dcCore::app()->ctx->kutrl->hash($args[0]))) {
|
||||
$args[0] = dcCore::app()->ctx->kutrl->url_base . $kutrl_rs->hash;
|
||||
} elseif (false !== ($kutrl_rs = App::frontend()->context()->kutrl->hash($args[0]))) {
|
||||
$args[0] = App::frontend()->context()->kutrl->url_base . $kutrl_rs->hash;
|
||||
|
||||
# ex: Send new url to messengers
|
||||
if (!empty($kutrl_rs)) {
|
||||
dcCore::app()->callBehavior('publicAfterKutrlCreate', $kutrl_rs, __('New public short URL'));
|
||||
App::behavior()->callBehavior('publicAfterKutrlCreate', $kutrl_rs, __('New public short URL'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +73,7 @@ class FrontendBehaviors
|
|||
$s = My::settings();
|
||||
|
||||
# Passive : all kutrl tag return long url
|
||||
dcCore::app()->ctx->kutrl_passive = (bool) $s->get('tpl_passive');
|
||||
App::frontend()->context()->kutrl_passive = (bool) $s->get('tpl_passive');
|
||||
|
||||
if (!$s->get('active')
|
||||
|| !$s->get('tpl_service')
|
||||
|
@ -85,7 +82,7 @@ class FrontendBehaviors
|
|||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->ctx->kutrl = $kut;
|
||||
App::frontend()->context()->kutrl = $kut;
|
||||
}
|
||||
|
||||
public static function publicHeadContent($_): void
|
||||
|
|
|
@ -1,39 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use dcTemplate;
|
||||
use Dotclear\App;
|
||||
|
||||
/**
|
||||
* @brief kUtRL frontend template.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class FrontendTemplate
|
||||
{
|
||||
public static function pageURL(ArrayObject$attr): string
|
||||
{
|
||||
$f = dcCore::app()->tpl->getFilters($attr);
|
||||
$f = App::frontend()->template()->getFilters($attr);
|
||||
|
||||
return '<?php echo ' . sprintf($f, 'dcCore::app()->blog->url.dcCore::app()->url->getBase("kutrl")') . '; ?>';
|
||||
return '<?php echo ' . sprintf($f, 'App::blog()->url().App::url()->getBase("kutrl")') . '; ?>';
|
||||
}
|
||||
|
||||
public static function pageIf(ArrayObject $attr, string $content): string
|
||||
{
|
||||
$operator = isset($attr['operator']) ? dcTemplate::getOperator($attr['operator']) : '&&';
|
||||
$operator = isset($attr['operator']) ? App::frontend()->template()->getOperator($attr['operator']) : '&&';
|
||||
|
||||
if (isset($attr['is_active'])) {
|
||||
$sign = (bool) $attr['is_active'] ? '' : '!';
|
||||
$if[] = $sign . 'dcCore::app()->blog->settings->get("' . My::id() . '")->get("srv_local_public")';
|
||||
$if[] = $sign . 'App::blog()->settings()->get("' . My::id() . '")->get("srv_local_public")';
|
||||
}
|
||||
if (empty($if)) {
|
||||
return $content;
|
||||
|
@ -47,11 +43,11 @@ class FrontendTemplate
|
|||
|
||||
public static function pageMsgIf(ArrayObject$attr, string $content): string
|
||||
{
|
||||
$operator = isset($attr['operator']) ? dcTemplate::getOperator($attr['operator']) : '&&';
|
||||
$operator = isset($attr['operator']) ? App::frontend()->template()->getOperator($attr['operator']) : '&&';
|
||||
|
||||
if (isset($attr['has_message'])) {
|
||||
$sign = (bool) $attr['has_message'] ? '!' : '=';
|
||||
$if[] = '"" ' . $sign . '= dcCore::app()->ctx->kutrl_msg';
|
||||
$if[] = '"" ' . $sign . '= App::frontend()->context()->kutrl_msg';
|
||||
}
|
||||
if (empty($if)) {
|
||||
return $content;
|
||||
|
@ -65,19 +61,19 @@ class FrontendTemplate
|
|||
|
||||
public static function pageMsg(ArrayObject$attr): string
|
||||
{
|
||||
return '<?php echo dcCore::app()->ctx->kutrl_msg; ?>';
|
||||
return '<?php echo App::frontend()->context()->kutrl_msg; ?>';
|
||||
}
|
||||
|
||||
public static function humanField(ArrayObject $attr): string
|
||||
{
|
||||
return "<?php echo sprintf(__('Confirm by writing \"%s\" in next field:'),dcCore::app()->ctx->kutrl_hmf); ?>";
|
||||
return "<?php echo sprintf(__('Confirm by writing \"%s\" in next field:'),App::frontend()->context()->kutrl_hmf); ?>";
|
||||
}
|
||||
|
||||
public static function humanFieldProtect(ArrayObject $attr): string
|
||||
{
|
||||
return
|
||||
'<input type="hidden" name="hmfp" id="hmfp" value="<?php echo dcCore::app()->ctx->kutrl_hmfp; ?>" />' .
|
||||
'<?php echo dcCore::app()->formNonce(); ?>';
|
||||
'<input type="hidden" name="hmfp" id="hmfp" value="<?php echo App::frontend()->context()->kutrl_hmfp; ?>" />' .
|
||||
'<?php echo App::nonce()->getFormNonce(); ?>';
|
||||
}
|
||||
|
||||
public static function AttachmentKutrlIf(ArrayObject$attr, string $content): string
|
||||
|
@ -92,69 +88,69 @@ class FrontendTemplate
|
|||
|
||||
public static function MediaKutrlIf(ArrayObject$attr, string $content): string
|
||||
{
|
||||
return self::genericKutrlIf('dcCore::app()->ctx->file_url', $attr, $content);
|
||||
return self::genericKutrlIf('App::frontend()->context()->file_url', $attr, $content);
|
||||
}
|
||||
|
||||
public static function MediaKutrl(ArrayObject $attr): string
|
||||
{
|
||||
return self::genericKutrl('dcCore::app()->ctx->file_url', $attr);
|
||||
return self::genericKutrl('App::frontend()->context()->file_url', $attr);
|
||||
}
|
||||
|
||||
public static function EntryAuthorKutrlIf(ArrayObject$attr, string $content): string
|
||||
{
|
||||
return self::genericKutrlIf('dcCore::app()->ctx->posts->user_url', $attr, $content);
|
||||
return self::genericKutrlIf('App::frontend()->context()->posts->user_url', $attr, $content);
|
||||
}
|
||||
|
||||
public static function EntryAuthorKutrl(ArrayObject $attr): string
|
||||
{
|
||||
return self::genericKutrl('dcCore::app()->ctx->posts->user_url', $attr);
|
||||
return self::genericKutrl('App::frontend()->context()->posts->user_url', $attr);
|
||||
}
|
||||
|
||||
public static function EntryKutrlIf(ArrayObject $attr, string $content): string
|
||||
{
|
||||
return self::genericKutrlIf('dcCore::app()->ctx->posts->getURL()', $attr, $content);
|
||||
return self::genericKutrlIf('App::frontend()->context()->posts->getURL()', $attr, $content);
|
||||
}
|
||||
|
||||
public static function EntryKutrl(ArrayObject $attr): string
|
||||
{
|
||||
return self::genericKutrl('dcCore::app()->ctx->posts->getURL()', $attr);
|
||||
return self::genericKutrl('App::frontend()->context()->posts->getURL()', $attr);
|
||||
}
|
||||
|
||||
public static function CommentAuthorKutrlIf(ArrayObject $attr, string $content): string
|
||||
{
|
||||
return self::genericKutrlIf('dcCore::app()->ctx->comments->getAuthorURL()', $attr, $content);
|
||||
return self::genericKutrlIf('App::frontend()->context()->comments->getAuthorURL()', $attr, $content);
|
||||
}
|
||||
|
||||
public static function CommentAuthorKutrl(ArrayObject $attr): string
|
||||
{
|
||||
return self::genericKutrl('dcCore::app()->ctx->comments->getAuthorURL()', $attr);
|
||||
return self::genericKutrl('App::frontend()->context()->comments->getAuthorURL()', $attr);
|
||||
}
|
||||
|
||||
public static function CommentPostKutrlIf(ArrayObject $attr, string $content): string
|
||||
{
|
||||
return self::genericKutrlIf('dcCore::app()->ctx->comments->getPostURL()', $attr, $content);
|
||||
return self::genericKutrlIf('App::frontend()->context()->comments->getPostURL()', $attr, $content);
|
||||
}
|
||||
|
||||
public static function CommentPostKutrl(ArrayObject $attr): string
|
||||
{
|
||||
return self::genericKutrl('dcCore::app()->ctx->comments->getPostURL()', $attr);
|
||||
return self::genericKutrl('App::frontend()->context()->comments->getPostURL()', $attr);
|
||||
}
|
||||
|
||||
protected static function genericKutrlIf(string $str, ArrayObject $attr, string $content): string
|
||||
{
|
||||
$operator = isset($attr['operator']) ? dcTemplate::getOperator($attr['operator']) : '&&';
|
||||
$operator = isset($attr['operator']) ? App::fontend()->template()->getOperator($attr['operator']) : '&&';
|
||||
|
||||
if (isset($attr['is_active'])) {
|
||||
$sign = (bool) $attr['is_active'] ? '' : '!';
|
||||
$if[] = $sign . 'dcCore::app()->ctx->exists("kutrl")';
|
||||
$if[] = $sign . 'App::frontend()->context()->exists("kutrl")';
|
||||
}
|
||||
if (isset($attr['passive_mode'])) {
|
||||
$sign = (bool) $attr['passive_mode'] ? '' : '!';
|
||||
$if[] = $sign . 'dcCore::app()->ctx->kutrl_passive';
|
||||
$if[] = $sign . 'App::frontend()->context()->kutrl_passive';
|
||||
}
|
||||
if (isset($attr['has_kutrl'])) {
|
||||
$sign = (bool) $attr['has_kutrl'] ? '!' : '=';
|
||||
$if[] = '(dcCore::app()->ctx->exists("kutrl") && false ' . $sign . '== dcCore::app()->ctx->kutrl->select(' . $str . ',null,null,"kutrl"))';
|
||||
$if[] = '(App::frontend()->context()->exists("kutrl") && false ' . $sign . '== App::frontend()->context()->kutrl->select(' . $str . ',null,null,"kutrl"))';
|
||||
}
|
||||
if (empty($if)) {
|
||||
return $content;
|
||||
|
@ -168,32 +164,32 @@ class FrontendTemplate
|
|||
|
||||
protected static function genericKutrl(string $str, ArrayObject $attr): string
|
||||
{
|
||||
$f = dcCore::app()->tpl->getFilters($attr);
|
||||
$f = App::frontend()->template()->getFilters($attr);
|
||||
|
||||
return
|
||||
"<?php \n" .
|
||||
# Preview
|
||||
"if (dcCore::app()->ctx->preview) { \n" .
|
||||
"if (App::frontend()->context()->preview) { \n" .
|
||||
' echo ' . sprintf($f, $str) . '; ' .
|
||||
"} else { \n" .
|
||||
# Disable
|
||||
"if (!dcCore::app()->ctx->exists('kutrl')) { \n" .
|
||||
"if (!App::frontend()->context()->exists('kutrl')) { \n" .
|
||||
# Passive mode
|
||||
' if (dcCore::app()->ctx->kutrl_passive) { ' .
|
||||
' if (App::frontend()->context()->kutrl_passive) { ' .
|
||||
' echo ' . sprintf($f, $str) . '; ' .
|
||||
" } \n" .
|
||||
"} else { \n" .
|
||||
# Existing
|
||||
' if (false !== ($kutrl_rs = dcCore::app()->ctx->kutrl->isKnowUrl(' . $str . '))) { ' .
|
||||
' echo ' . sprintf($f, 'dcCore::app()->ctx->kutrl->url_base.$kutrl_rs->hash') . '; ' .
|
||||
' if (false !== ($kutrl_rs = App::frontend()->context()->kutrl->isKnowUrl(' . $str . '))) { ' .
|
||||
' echo ' . sprintf($f, 'App::frontend()->context()->kutrl->url_base.$kutrl_rs->hash') . '; ' .
|
||||
" } \n" .
|
||||
# New
|
||||
' elseif (false !== ($kutrl_rs = dcCore::app()->ctx->kutrl->hash(' . $str . '))) { ' .
|
||||
' echo ' . sprintf($f, 'dcCore::app()->ctx->kutrl->url_base.$kutrl_rs->hash') . '; ' .
|
||||
' elseif (false !== ($kutrl_rs = App::frontend()->context()->kutrl->hash(' . $str . '))) { ' .
|
||||
' echo ' . sprintf($f, 'App::frontend()->context()->kutrl->url_base.$kutrl_rs->hash') . '; ' .
|
||||
|
||||
# ex: Send new url to messengers
|
||||
' if (!empty($kutrl_rs)) { ' .
|
||||
" dcCore::app()->callBehavior('publicAfterKutrlCreate',\$kutrl_rs,__('New public short URL')); " .
|
||||
" App::behavior()->callBehavior('publicAfterKutrlCreate',\$kutrl_rs,__('New public short URL')); " .
|
||||
" } \n" .
|
||||
|
||||
" } \n" .
|
||||
|
|
|
@ -1,25 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use dcUrlHandlers;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Frontend\Url;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Helper\Network\Http;
|
||||
|
||||
class FrontendUrl extends dcUrlHandlers
|
||||
/**
|
||||
* @brief kUtRL frontend URL handler.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class FrontendUrl extends Url
|
||||
{
|
||||
# Redirect !!! local !!! service only
|
||||
public static function redirectUrl(?string $args): void
|
||||
|
@ -38,15 +35,15 @@ class FrontendUrl extends dcUrlHandlers
|
|||
}
|
||||
|
||||
$args = $m[3] ?? '';
|
||||
dcCore::app()->ctx->kutrl_msg = '';
|
||||
dcCore::app()->ctx->kutrl_hmf = FrontendUtils::create();
|
||||
dcCore::app()->ctx->kutrl_hmfp = FrontendUtils::protect(dcCore::app()->ctx->kutrl_hmf);
|
||||
App::frontend()->context()->kutrl_msg = '';
|
||||
App::frontend()->context()->kutrl_hmf = FrontendUtils::create();
|
||||
App::frontend()->context()->kutrl_hmfp = FrontendUtils::protect(App::frontend()->context()->kutrl_hmf);
|
||||
|
||||
$kut = new Service\ServiceLocal();
|
||||
|
||||
# Nothing on url
|
||||
if ($m[1] == '/') {
|
||||
dcCore::app()->ctx->kutrl_msg = 'No link given.';
|
||||
App::frontend()->context()->kutrl_msg = 'No link given.';
|
||||
}
|
||||
# find suffix on redirect url
|
||||
$suffix = '';
|
||||
|
@ -62,7 +59,7 @@ class FrontendUrl extends dcUrlHandlers
|
|||
}
|
||||
# Not find, go to kutrl 404
|
||||
if (false === ($url = $kut->getUrl($args))) {
|
||||
//dcCore::app()->ctx->kutrl_msg = 'Failed to find short link.';
|
||||
//App::frontend()->context()->kutrl_msg = 'Failed to find short link.';
|
||||
//self::pageKutrl($kut);
|
||||
self::kutrl404();
|
||||
|
||||
|
@ -75,7 +72,7 @@ class FrontendUrl extends dcUrlHandlers
|
|||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
App::blog()->triggerBlog();
|
||||
Http::redirect($url . $suffix);
|
||||
}
|
||||
|
||||
|
@ -96,7 +93,7 @@ class FrontendUrl extends dcUrlHandlers
|
|||
return;
|
||||
}
|
||||
# Validation form
|
||||
$url = !empty($_POST['longurl']) ? trim(dcCore::app()->con->escapeStr((string) $_POST['longurl'])) : '';
|
||||
$url = !empty($_POST['longurl']) ? trim(App::con()->escapeStr((string) $_POST['longurl'])) : '';
|
||||
if (!empty($url)) {
|
||||
$hmf = !empty($_POST['hmf']) ? $_POST['hmf'] : '!';
|
||||
$hmfu = !empty($_POST['hmfp']) ? FrontendUtils::unprotect($_POST['hmfp']) : '?';
|
||||
|
@ -105,44 +102,44 @@ class FrontendUrl extends dcUrlHandlers
|
|||
if (!$err) {
|
||||
if ($hmf != $hmfu) {
|
||||
$err = true;
|
||||
dcCore::app()->ctx->kutrl_msg = __('Failed to verify protected field.');
|
||||
App::frontend()->context()->kutrl_msg = __('Failed to verify protected field.');
|
||||
}
|
||||
}
|
||||
if (!$err) {
|
||||
if (!$kut->testService()) {
|
||||
$err = true;
|
||||
dcCore::app()->ctx->kutrl_msg = __('Service is not well configured.');
|
||||
App::frontend()->context()->kutrl_msg = __('Service is not well configured.');
|
||||
}
|
||||
}
|
||||
if (!$err) {
|
||||
if (!$kut->isValidUrl($url)) {
|
||||
$err = true;
|
||||
dcCore::app()->ctx->kutrl_msg = __('This string is not a valid URL.');
|
||||
App::frontend()->context()->kutrl_msg = __('This string is not a valid URL.');
|
||||
}
|
||||
}
|
||||
if (!$err) {
|
||||
if (!$kut->isLongerUrl($url)) {
|
||||
$err = true;
|
||||
dcCore::app()->ctx->kutrl_msg = __('This link is too short.');
|
||||
App::frontend()->context()->kutrl_msg = __('This link is too short.');
|
||||
}
|
||||
}
|
||||
if (!$err) {
|
||||
if (!$kut->isProtocolUrl($url)) {
|
||||
$err = true;
|
||||
dcCore::app()->ctx->kutrl_msg = __('This type of link is not allowed.');
|
||||
App::frontend()->context()->kutrl_msg = __('This type of link is not allowed.');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$err) {
|
||||
if (!$kut->allow_external_url && !$kut->isBlogUrl($url)) {
|
||||
$err = true;
|
||||
dcCore::app()->ctx->kutrl_msg = __('Short links are limited to this blog URL.');
|
||||
App::frontend()->context()->kutrl_msg = __('Short links are limited to this blog URL.');
|
||||
}
|
||||
}
|
||||
if (!$err) {
|
||||
if ($kut->isServiceUrl($url)) {
|
||||
$err = true;
|
||||
dcCore::app()->ctx->kutrl_msg = __('This link is already a short link.');
|
||||
App::frontend()->context()->kutrl_msg = __('This link is already a short link.');
|
||||
}
|
||||
}
|
||||
if (!$err) {
|
||||
|
@ -152,7 +149,7 @@ class FrontendUrl extends dcUrlHandlers
|
|||
$url = $rs->url;
|
||||
$new_url = $kut->url_base . $rs->hash;
|
||||
|
||||
dcCore::app()->ctx->kutrl_msg = sprintf(
|
||||
App::frontend()->context()->kutrl_msg = sprintf(
|
||||
__('Short link for %s is %s'),
|
||||
Html::escapeHTML($url),
|
||||
'<a href="' . $new_url . '">' . $new_url . '</a>'
|
||||
|
@ -162,27 +159,27 @@ class FrontendUrl extends dcUrlHandlers
|
|||
if (!$err) {
|
||||
if (false === ($rs = $kut->hash($url))) {
|
||||
$err = true;
|
||||
dcCore::app()->ctx->kutrl_msg = __('Failed to create short link.');
|
||||
App::frontend()->context()->kutrl_msg = __('Failed to create short link.');
|
||||
} else {
|
||||
$url = $rs->url;
|
||||
$new_url = $kut->url_base . $rs->hash;
|
||||
|
||||
dcCore::app()->ctx->kutrl_msg = sprintf(
|
||||
App::frontend()->context()->kutrl_msg = sprintf(
|
||||
__('Short link for %s is %s'),
|
||||
Html::escapeHTML($url),
|
||||
'<a href="' . $new_url . '">' . $new_url . '</a>'
|
||||
);
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
App::blog()->triggerBlog();
|
||||
|
||||
# ex: Send new url to messengers
|
||||
if (!empty($rs)) {
|
||||
dcCore::app()->callBehavior('publicAfterKutrlCreate', $rs, __('New public short URL'));
|
||||
App::behavior()->callBehavior('publicAfterKutrlCreate', $rs, __('New public short URL'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::path() . '/default-templates');
|
||||
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), My::path() . '/default-templates');
|
||||
self::serveDocument('kutrl.html');
|
||||
}
|
||||
|
||||
|
@ -194,18 +191,18 @@ class FrontendUrl extends dcUrlHandlers
|
|||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), My::path() . '/default-templates');
|
||||
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), My::path() . '/default-templates');
|
||||
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
Http::head(404, 'Not Found');
|
||||
dcCore::app()->url->type = '404';
|
||||
dcCore::app()->ctx->current_tpl = 'kutrl404.html';
|
||||
dcCore::app()->ctx->content_type = 'text/html';
|
||||
App::url()->type = '404';
|
||||
App::frontend()->context()->current_tpl = 'kutrl404.html';
|
||||
App::frontend()->context()->content_type = 'text/html';
|
||||
|
||||
echo dcCore::app()->tpl->getData(dcCore::app()->ctx->current_tpl);
|
||||
echo App::frontend()->template()->getData(App::frontend()->context()->current_tpl);
|
||||
|
||||
# --BEHAVIOR-- publicAfterDocumentV2
|
||||
dcCore::app()->callBehavior('publicAfterDocumentV2');
|
||||
App::behavior()->callBehavior('publicAfterDocumentV2');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
/**
|
||||
* @brief kUtRL frontend utils.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class FrontendUtils
|
||||
{
|
||||
public static $chars = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
|
||||
# Import/export behaviors for Import/export plugin
|
||||
/**
|
||||
* @brief kUtRL importExport stuff.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ImportExportBehaviors
|
||||
{
|
||||
public static function exportSingleV2($exp, $blog_id)
|
||||
|
@ -25,7 +21,7 @@ class ImportExportBehaviors
|
|||
My::TABLE_NAME,
|
||||
'SELECT kut_id, blog_id, kut_service, kut_type, ' .
|
||||
'kut_hash, kut_url, kut_dt, kut_password, kut_counter ' .
|
||||
'FROM ' . dcCore::app()->prefix . My::TABLE_NAME . ' ' .
|
||||
'FROM ' . App::con()->prefix() . My::TABLE_NAME . ' ' .
|
||||
"WHERE blog_id = '" . $blog_id . "' "
|
||||
);
|
||||
}
|
||||
|
@ -37,7 +33,7 @@ class ImportExportBehaviors
|
|||
|
||||
public static function importInitV2($bk)
|
||||
{
|
||||
$bk->cur_kutrl = dcCore::app()->con->openCursor(dcCore::app()->prefix . My::TABLE_NAME);
|
||||
$bk->cur_kutrl = App::con()->openCursor(App::con()->prefix() . My::TABLE_NAME);
|
||||
$bk->kutrl = new Logs();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,27 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use dcNamespace;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Database\Structure;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Module installation.
|
||||
* @brief kUtRL install class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Install extends Process
|
||||
{
|
||||
|
@ -38,7 +31,7 @@ class Install extends Process
|
|||
|
||||
try {
|
||||
// Table
|
||||
$t = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$t = new Structure(App::con(), App::con()->prefix());
|
||||
$t->{My::TABLE_NAME}
|
||||
->kut_id('bigint', 0, false)
|
||||
->blog_id('varchar', 32, false)
|
||||
|
@ -56,18 +49,18 @@ class Install extends Process
|
|||
->index('idx_kut_service', 'btree', 'kut_service')
|
||||
->index('idx_kut_type', 'btree', 'kut_type');
|
||||
|
||||
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($t);
|
||||
(new Structure(App::con(), App::con()->prefix()))->synchronize($t);
|
||||
|
||||
// upgrade version < 2022.12.22 : upgrade settings id and ns and array
|
||||
$current = dcCore::app()->getVersion(My::id());
|
||||
$current = App::version()->getVersion(My::id());
|
||||
if ($current && version_compare($current, '2022.12.22', '<')) {
|
||||
$record = dcCore::app()->con->select(
|
||||
'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' .
|
||||
$record = App::con()->select(
|
||||
'SELECT * FROM ' . App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME . ' ' .
|
||||
"WHERE setting_ns = 'kUtRL' "
|
||||
);
|
||||
while ($record->fetch()) {
|
||||
if (preg_match('/^kutrl_(.*?)$/', $record->setting_id, $match)) {
|
||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME);
|
||||
$cur = App::blogWorkspace()->openBlogWorkspace();
|
||||
// avoid the use of serialize function
|
||||
if (in_array($record->setting_id, ['kutrl_srv_custom'])) {
|
||||
$cur->setting_value = json_encode(@unserialize(base64_decode((string) $record->setting_value)));
|
||||
|
@ -76,7 +69,7 @@ class Install extends Process
|
|||
$cur->setting_ns = basename(__DIR__);
|
||||
$cur->update(
|
||||
"WHERE setting_id = '" . $record->setting_id . "' and setting_ns = 'kUtRL' " .
|
||||
'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escapeStr((string) $record->blog_id) . "' "))
|
||||
'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . App::con()->escapeStr((string) $record->blog_id) . "' "))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +103,7 @@ class Install extends Process
|
|||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Filter\Filters;
|
||||
use Dotclear\Core\Backend\Listing\{
|
||||
Listing,
|
||||
|
@ -32,6 +22,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Dotclear\Helper\Html\Html;
|
||||
|
||||
/**
|
||||
* @brief kUtRL links listing.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class LinksListing extends Listing
|
||||
{
|
||||
public function display(Filters $filter, string $enclose_block): void
|
||||
|
@ -134,7 +131,7 @@ class LinksListing extends Listing
|
|||
]),
|
||||
'kut_hash' => (new Text('td', $hash))
|
||||
->class('nowrap'),
|
||||
'kut_dt' => (new Text('td', Html::escapeHTML(Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->kut_dt, dcCore::app()->auth->getInfo('user_tz')))))
|
||||
'kut_dt' => (new Text('td', Html::escapeHTML(Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->kut_dt, App::auth()->getInfo('user_tz')))))
|
||||
->class('nowrap'),
|
||||
'kut_service' => (new Text('td', $type))
|
||||
->class('nowrap'),
|
||||
|
|
41
src/Logs.php
41
src/Logs.php
|
@ -1,22 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* This file contents class to acces local short links records
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Database\Statement\{
|
||||
DeleteStatement,
|
||||
|
@ -25,6 +13,13 @@ use Dotclear\Database\Statement\{
|
|||
UpdateStatement
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief kUtRL logs class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Logs
|
||||
{
|
||||
public $table;
|
||||
|
@ -32,8 +27,8 @@ class Logs
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = dcCore::app()->prefix . My::TABLE_NAME;
|
||||
$this->con = dcCore::app()->con;
|
||||
$this->table = App::con()->prefix() . My::TABLE_NAME;
|
||||
$this->con = App::con();
|
||||
}
|
||||
|
||||
public function nextId(): int
|
||||
|
@ -57,7 +52,7 @@ class Logs
|
|||
|
||||
try {
|
||||
$cur->kut_id = $this->nextId();
|
||||
$cur->blog_id = dcCore::app()->blog->id;
|
||||
$cur->blog_id = App::blog()->id();
|
||||
$cur->kut_url = (string) $url;
|
||||
$cur->kut_hash = (string) $hash;
|
||||
$cur->kut_type = (string) $type;
|
||||
|
@ -101,7 +96,7 @@ class Logs
|
|||
$sql->as('kut_counter', 'counter'),
|
||||
])
|
||||
->from($this->table)
|
||||
->where('blog_id = ' . $sql->quote(dcCore::app()->blog->id))
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->and('kut_service = ' . $sql->quote($service))
|
||||
;
|
||||
|
||||
|
@ -135,7 +130,7 @@ class Logs
|
|||
$cur->kut_counter = 0;
|
||||
|
||||
$cur->update(
|
||||
"WHERE blog_id='" . $this->con->escapeStr(dcCore::app()->blog->id) . "' " .
|
||||
"WHERE blog_id='" . $this->con->escapeStr(App::blog()->id()) . "' " .
|
||||
"AND kut_id='" . $id . "' "
|
||||
);
|
||||
$this->con->unlock();
|
||||
|
@ -155,7 +150,7 @@ class Logs
|
|||
$sql = new DeleteStatement();
|
||||
$sql
|
||||
->from($this->table)
|
||||
->where('blog_id = ' . $sql->quote(dcCore::app()->blog->id))
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->and('kut_id = ' . $id)
|
||||
->delete();
|
||||
|
||||
|
@ -168,7 +163,7 @@ class Logs
|
|||
$rs = $sql
|
||||
->column('kut_counter')
|
||||
->from($this->table)
|
||||
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog?->id))
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->and('kut_id = ' . $id)
|
||||
->select();
|
||||
|
||||
|
@ -188,7 +183,7 @@ class Logs
|
|||
$ret = $sql->ref($this->table)
|
||||
->column('kut_counter')
|
||||
->value($counter)
|
||||
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog?->id))
|
||||
->where('blog_id = ' . $sql->quote(App::blog()->id()))
|
||||
->and('kut_id = ' . $id)
|
||||
->update();
|
||||
|
||||
|
@ -221,7 +216,7 @@ class Logs
|
|||
$sql->from($params['from']);
|
||||
}
|
||||
|
||||
$sql->where('S.blog_id = ' . $sql->quote(dcCore::app()->blog->id));
|
||||
$sql->where('S.blog_id = ' . $sql->quote(App::blog()->id()));
|
||||
|
||||
if (isset($params['kut_service'])) {
|
||||
$sql->and('kut_service = ' . $sql->quote($params['kut_service']));
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
|
@ -32,6 +22,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Dotclear\Helper\Html\Html;
|
||||
|
||||
/**
|
||||
* @brief kUtRL manage class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Manage extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
|
@ -59,7 +56,7 @@ class Manage extends Process
|
|||
if (null === $kut) {
|
||||
throw new Exception('Unknow service');
|
||||
}
|
||||
$url = trim(dcCore::app()->con->escapeStr((string) $_POST['str']));
|
||||
$url = trim(App::con()->escapeStr((string) $_POST['str']));
|
||||
$hash = empty($_POST['custom']) ? null : $_POST['custom'];
|
||||
|
||||
if (empty($url)) {
|
||||
|
@ -117,12 +114,12 @@ class Manage extends Process
|
|||
|
||||
# ex: Send new url to messengers
|
||||
if (!empty($rs)) {
|
||||
dcCore::app()->callBehavior('adminAfterKutrlCreate', $rs, __('New short URL'));
|
||||
App::behavior()->callBehavior('adminAfterKutrlCreate', $rs, __('New short URL'));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Filter\{
|
||||
Filters,
|
||||
FiltersLibrary
|
||||
|
@ -34,6 +24,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
Text
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief kUtRL manage links class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ManageLinks extends Process
|
||||
{
|
||||
private static Filters $kutrl_filter;
|
||||
|
@ -69,7 +66,7 @@ class ManageLinks extends Process
|
|||
$list_counter = $log->getLogs($params, true)->f(0);
|
||||
self::$kutrl_listing = new LinksListing($list_all, $list_counter);
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
|
||||
if (!empty($_POST['deletelinks'])) {
|
||||
|
@ -85,12 +82,12 @@ class ManageLinks extends Process
|
|||
$o->remove($rs->kut_url);
|
||||
}
|
||||
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
App::blog()->triggerBlog();
|
||||
|
||||
Notices::addSuccessNotice(__('Links successfully deleted'));
|
||||
My::redirect(self::$kutrl_filter->values());
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
App::error()->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
32
src/My.php
32
src/My.php
|
@ -1,15 +1,5 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
@ -17,14 +7,26 @@ namespace Dotclear\Plugin\kUtRL;
|
|||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definitions.
|
||||
* @brief kUtRL My helper.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/** @var string This module database table name */
|
||||
public const TABLE_NAME = \initkUtRL::KURL_TABLE_NAME;
|
||||
/**
|
||||
* This module database table name.
|
||||
*
|
||||
* @var string TABLE_NAME
|
||||
*/
|
||||
public const TABLE_NAME = 'kutrl';
|
||||
|
||||
/** @var array List of template tag which content URL that can be shorten */
|
||||
/**
|
||||
* List of template tag which content URL that can be shorten.
|
||||
*
|
||||
* @var array USED_TAGS
|
||||
*/
|
||||
public const USED_TAGS = [
|
||||
'AttachmentURL',
|
||||
'CategoryURL',
|
||||
|
|
|
@ -1,24 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Process;
|
||||
|
||||
/**
|
||||
* Module prepend.
|
||||
* @brief kUtRL prepend class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Prepend extends Process
|
||||
{
|
||||
|
@ -51,46 +45,41 @@ class Prepend extends Process
|
|||
}
|
||||
|
||||
# Services
|
||||
dcCore::app()->addBehavior('kutrlService', fn () => ['default', Service\ServiceDefault::class]);
|
||||
App::behavior()->addBehavior('kutrlService', fn () => ['default', Service\ServiceDefault::class]);
|
||||
if (!defined('SHORTEN_SERVICE_DISABLE_CUSTOM')) {
|
||||
dcCore::app()->addBehavior('kutrlService', fn () => ['custom', Service\ServiceCustom::class]);
|
||||
App::behavior()->addBehavior('kutrlService', fn () => ['custom', Service\ServiceCustom::class]);
|
||||
}
|
||||
if (!defined('SHORTEN_SERVICE_DISABLE_LOCAL')) {
|
||||
dcCore::app()->addBehavior('kutrlService', fn () => ['local', Service\ServiceLocal::class]);
|
||||
App::behavior()->addBehavior('kutrlService', fn () => ['local', Service\ServiceLocal::class]);
|
||||
}
|
||||
if (!defined('SHORTEN_SERVICE_DISABLE_BILBOLINKS')) {
|
||||
dcCore::app()->addBehavior('kutrlService', fn () => ['bilbolinks', Service\ServiceBilbolinks::class]);
|
||||
App::behavior()->addBehavior('kutrlService', fn () => ['bilbolinks', Service\ServiceBilbolinks::class]);
|
||||
}
|
||||
if (!defined('SHORTEN_SERVICE_DISABLE_BITLY')) {
|
||||
dcCore::app()->addBehavior('kutrlService', fn () => ['bitly', Service\ServiceBitly::class]);
|
||||
App::behavior()->addBehavior('kutrlService', fn () => ['bitly', Service\ServiceBitly::class]);
|
||||
}
|
||||
if (!defined('SHORTEN_SERVICE_DISABLE_ISGD')) {
|
||||
dcCore::app()->addBehavior('kutrlService', fn () => ['isgd', Service\ServiceIsgd::class]);
|
||||
App::behavior()->addBehavior('kutrlService', fn () => ['isgd', Service\ServiceIsgd::class]);
|
||||
}
|
||||
if (!defined('SHORTEN_SERVICE_DISABLE_YOURLS')) {
|
||||
dcCore::app()->addBehavior('kutrlService', fn () => ['yourls', Service\ServiceYourls::class]);
|
||||
App::behavior()->addBehavior('kutrlService', fn () => ['yourls', Service\ServiceYourls::class]);
|
||||
}
|
||||
|
||||
# Shorten url passed through wiki functions
|
||||
dcCore::app()->addBehaviors([
|
||||
'coreInitWikiPost' => [Wiki::class, 'coreInitWiki'],
|
||||
'coreInitWikiComment' => [Wiki::class, 'coreInitWiki'],
|
||||
'coreInitWikiSimpleComment' => [Wiki::class,'coreInitWiki'],
|
||||
App::behavior()->addBehaviors([
|
||||
'coreInitWikiPost' => Wiki::coreInitWiki(...),
|
||||
'coreInitWikiComment' => Wiki::coreInitWiki(...),
|
||||
'coreInitWikiSimpleComment' => Wiki::coreInitWiki(...),
|
||||
]);
|
||||
|
||||
# Public page
|
||||
dcCore::app()->url->register(
|
||||
App::url()->register(
|
||||
'kutrl',
|
||||
'go',
|
||||
'^go(/(.*?)|)$',
|
||||
[FrontendUrl::class, 'redirectUrl']
|
||||
FrontendUrl::redirectUrl(...)
|
||||
);
|
||||
|
||||
# Add kUtRL events on plugin activityReport
|
||||
if (defined('ACTIVITY_REPORT_V2')) {
|
||||
require_once $d . 'lib.kutrl.activityreport.php';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* Generic class for shorten link service
|
||||
* A service class must extends this one
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use dcError;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Div,
|
||||
|
@ -26,6 +12,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Dotclear\Helper\Network\HttpClient;
|
||||
|
||||
/**
|
||||
* @brief kUtRL service class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Service
|
||||
{
|
||||
public $error;
|
||||
|
@ -38,7 +31,7 @@ class Service
|
|||
{
|
||||
$this->settings = My::settings();
|
||||
$this->log = new Logs();
|
||||
$this->error = new dcError();
|
||||
$this->error = App::error();
|
||||
//$this->error->setHTMLFormat('%s', "%s\n");
|
||||
|
||||
$this->init();
|
||||
|
@ -144,7 +137,7 @@ class Service
|
|||
# Test if an url is from current blog
|
||||
public function isBlogUrl(string $url): bool
|
||||
{
|
||||
$base = dcCore::app()->blog->url;
|
||||
$base = App::blog()->url();
|
||||
$url = substr($url, 0, strlen($base));
|
||||
|
||||
return $url == $base;
|
||||
|
@ -177,7 +170,7 @@ class Service
|
|||
*/
|
||||
public function hash(string $url, ?string $hash = null)
|
||||
{
|
||||
$url = trim(dcCore::app()->con->escapeStr((string) $url));
|
||||
$url = trim(App::con()->escapeStr((string) $url));
|
||||
if ('undefined' === $this->id) {
|
||||
return false;
|
||||
}
|
||||
|
@ -202,10 +195,10 @@ class Service
|
|||
}
|
||||
|
||||
$this->log->insert($rs->url, $rs->hash, $rs->type, 'kutrl');
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
App::blog()->triggerBlog();
|
||||
|
||||
# --BEHAVIOR-- kutrlAfterCreateShortUrl
|
||||
dcCore::app()->callBehavior('kutrlAfterCreateShortUrl', $rs);
|
||||
App::behavior()->callBehavior('kutrlAfterCreateShortUrl', $rs);
|
||||
}
|
||||
|
||||
return $rs;
|
||||
|
@ -214,13 +207,27 @@ class Service
|
|||
/**
|
||||
* Create a hash for a given url (and its custom hash).
|
||||
*
|
||||
* @return false|ArrayObject
|
||||
* @return false|MetaRecord
|
||||
*/
|
||||
public function createHash(string $url, ?string $hash = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a shorlink record from values.
|
||||
*
|
||||
* @param string $hash The hash
|
||||
* @param string $url The url
|
||||
* @param string $type The type
|
||||
*
|
||||
* @return MetaRecord The link description record
|
||||
*/
|
||||
public function fromValue(string $hash, string $url, string $type): MetaRecord
|
||||
{
|
||||
return MetaRecord::newFromArray([['hash' => $hash, 'url' => $url, 'type' => $type]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an url from list of know urls.
|
||||
*/
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL\Service;
|
||||
|
||||
use ArrayObject;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Div,
|
||||
Input,
|
||||
|
@ -24,6 +13,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Dotclear\Plugin\kUtRL\Service;
|
||||
|
||||
/**
|
||||
* @brief kUtRL bilbolinks service class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ServiceBilbolinks extends Service
|
||||
{
|
||||
protected $config = [
|
||||
|
@ -106,11 +102,10 @@ class ServiceBilbolinks extends Service
|
|||
|
||||
return false;
|
||||
}
|
||||
$rs = new ArrayObject();
|
||||
$rs->hash = str_replace($this->url_base, '', $response);
|
||||
$rs->url = $url;
|
||||
$rs->type = $this->id;
|
||||
|
||||
return $rs;
|
||||
return $this->fromValue(
|
||||
str_replace($this->url_base, '', $response),
|
||||
$url,
|
||||
$this->id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL\Service;
|
||||
|
||||
use ArrayObject;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Div,
|
||||
Input,
|
||||
|
@ -24,6 +13,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Dotclear\Plugin\kUtRL\Service;
|
||||
|
||||
/**
|
||||
* @brief kUtRL btily service class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ServiceBitly extends Service
|
||||
{
|
||||
protected $config = [
|
||||
|
@ -101,12 +97,11 @@ class ServiceBitly extends Service
|
|||
|
||||
$rsp = json_decode($response);
|
||||
|
||||
$rs = new ArrayObject();
|
||||
$rs->hash = str_replace($this->url_base, '', (string) $rsp->link);
|
||||
$rs->url = (string) $rsp->long_url;
|
||||
$rs->type = $this->id;
|
||||
|
||||
return $rs;
|
||||
return $this->fromValue(
|
||||
str_replace($this->url_base, '', (string) $rsp->link),
|
||||
(string) $rsp->long_url,
|
||||
$this->id
|
||||
);
|
||||
}
|
||||
|
||||
private function headers()
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL\Service;
|
||||
|
||||
use ArrayObject;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
|
@ -25,6 +14,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Dotclear\Plugin\kUtRL\Service;
|
||||
|
||||
/**
|
||||
* @brief kUtRL custom service class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ServiceCustom extends Service
|
||||
{
|
||||
protected $config = [
|
||||
|
@ -154,11 +150,11 @@ class ServiceCustom extends Service
|
|||
|
||||
return false;
|
||||
}
|
||||
$rs = new ArrayObject();
|
||||
$rs->hash = str_replace($this->url_base, '', $response);
|
||||
$rs->url = $url;
|
||||
$rs->type = $this->id;
|
||||
|
||||
return $rs;
|
||||
return $this->fromValue(
|
||||
str_replace($this->url_base, '', $response),
|
||||
$url,
|
||||
$this->id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL\Service;
|
||||
|
||||
use ArrayObject;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Div,
|
||||
Note,
|
||||
|
@ -23,11 +12,18 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Dotclear\Plugin\kUtRL\Service;
|
||||
|
||||
# nb: "default" ne veut pas dire service par défaut
|
||||
# mais service simple et rapide configuré par des constantes
|
||||
# cela permet de configurer ces constantes dans le fichier
|
||||
# config de Dotclear pour une plateforme complète.
|
||||
|
||||
/**
|
||||
* @brief kUtRL default service class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* Note: "default" ne veut pas dire service par défaut
|
||||
* mais service simple et rapide configuré par des constantes
|
||||
* cela permet de configurer ces constantes dans le fichier
|
||||
* config de Dotclear pour une plateforme complète.
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ServiceDefault extends Service
|
||||
{
|
||||
protected function init(): void
|
||||
|
@ -98,11 +94,10 @@ class ServiceDefault extends Service
|
|||
return false;
|
||||
}
|
||||
|
||||
$rs = new ArrayObject();
|
||||
$rs->hash = str_replace($this->url_base, '', $response);
|
||||
$rs->url = $url;
|
||||
$rs->type = $this->id;
|
||||
|
||||
return $rs;
|
||||
return $this->fromValue(
|
||||
str_replace($this->url_base, '', $response),
|
||||
$url,
|
||||
$this->id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL\Service;
|
||||
|
||||
use ArrayObject;
|
||||
use Dotclear\Plugin\kUtRL\Service;
|
||||
|
||||
/**
|
||||
* @brief kUtRL is.gd service class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ServiceIsgd extends Service
|
||||
{
|
||||
protected $config = [
|
||||
|
@ -51,11 +47,10 @@ class ServiceIsgd extends Service
|
|||
return false;
|
||||
}
|
||||
|
||||
$rs = new ArrayObject();
|
||||
$rs->hash = str_replace($this->url_base, '', $response);
|
||||
$rs->url = $url;
|
||||
$rs->type = $this->id;
|
||||
|
||||
return $rs;
|
||||
return $this->fromValue(
|
||||
str_replace($this->url_base, '', $response),
|
||||
$url,
|
||||
$this->id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL\Service;
|
||||
|
||||
use ArrayObject;
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
|
@ -29,6 +18,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Plugin\kUtRL\Service;
|
||||
|
||||
/**
|
||||
* @brief kUtRL local service class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ServiceLocal extends Service
|
||||
{
|
||||
protected $config = [
|
||||
|
@ -44,7 +40,7 @@ class ServiceLocal extends Service
|
|||
$protocols = (string) $this->settings->get('srv_local_protocols');
|
||||
$this->config['allow_protocols'] = empty($protocols) ? [] : explode(',', $protocols);
|
||||
|
||||
$this->config['url_base'] = dcCore::app()->blog->url . dcCore::app()->url->getBase('kutrl') . '/';
|
||||
$this->config['url_base'] = App::blog()->url() . App::url()->getBase('kutrl') . '/';
|
||||
$this->config['url_min_len'] = strlen($this->url_base) + 2;
|
||||
}
|
||||
|
||||
|
@ -159,19 +155,19 @@ class ServiceLocal extends Service
|
|||
public function createHash(string $url, ?string $hash = null)
|
||||
{
|
||||
# Create response object
|
||||
$rs = new ArrayObject();
|
||||
$rs->type = 'local';
|
||||
$rs->url = $url;
|
||||
$rs_hash = '';
|
||||
$rs_type = 'local';
|
||||
$rs_url = $url;
|
||||
|
||||
# Normal link
|
||||
if ($hash === null) {
|
||||
$type = 'localnormal';
|
||||
$rs->hash = $this->next($this->last('localnormal'));
|
||||
$rs_hash = $this->next($this->last('localnormal'));
|
||||
|
||||
# Mixed custom link
|
||||
} elseif (preg_match('/^([A-Za-z0-9]{2,})\!\!$/', $hash, $m)) {
|
||||
$type = 'localmix';
|
||||
$rs->hash = $m[1] . $this->next(-1, $m[1]);
|
||||
$rs_hash = $m[1] . $this->next(-1, $m[1]);
|
||||
|
||||
# Custom link
|
||||
} elseif (preg_match('/^[A-Za-z0-9\.\-\_]{2,}$/', $hash)) {
|
||||
|
@ -181,7 +177,7 @@ class ServiceLocal extends Service
|
|||
return false;
|
||||
}
|
||||
$type = 'localcustom';
|
||||
$rs->hash = $hash;
|
||||
$rs_hash = $hash;
|
||||
|
||||
# Wrong char in custom hash
|
||||
} else {
|
||||
|
@ -192,9 +188,13 @@ class ServiceLocal extends Service
|
|||
|
||||
# Save link
|
||||
try {
|
||||
$this->log->insert($rs->url, $rs->hash, $type, $rs->type);
|
||||
$this->log->insert($rs_url, $rs_hash, $type, $rs_type);
|
||||
|
||||
return $rs;
|
||||
return $this->fromValue(
|
||||
$rs_hash,
|
||||
$rs_url,
|
||||
$rs_type
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$this->error->add(__('Failed to save link.'));
|
||||
}
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL\Service;
|
||||
|
||||
use ArrayObject;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Div,
|
||||
Input,
|
||||
|
@ -24,6 +13,13 @@ use Dotclear\Helper\Html\Form\{
|
|||
};
|
||||
use Dotclear\Plugin\kUtRL\Service;
|
||||
|
||||
/**
|
||||
* @brief kUtRL yourls service class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ServiceYourls extends Service
|
||||
{
|
||||
protected $config = [
|
||||
|
@ -142,12 +138,11 @@ class ServiceYourls extends Service
|
|||
$rsp = @simplexml_load_string($response);
|
||||
|
||||
if ($rsp && $rsp->status == 'success') {
|
||||
$rs = new ArrayObject();
|
||||
$rs->hash = $rsp->url[0]->keyword;
|
||||
$rs->url = $url;
|
||||
$rs->type = $this->id;
|
||||
|
||||
return $rs;
|
||||
return $this->fromValue(
|
||||
$rsp->url[0]->keyword,
|
||||
$url,
|
||||
$this->id
|
||||
);
|
||||
}
|
||||
$this->error->add(__('Unreadable service response.'));
|
||||
|
||||
|
|
|
@ -1,25 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
/**
|
||||
* Plugin Uninstaller actions.
|
||||
* @brief kUtRL uninstall class.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Uninstall extends Process
|
||||
{
|
||||
|
@ -30,7 +23,7 @@ class Uninstall extends Process
|
|||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* Generic class to play easily with services
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief kUtRL utils.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Utils
|
||||
{
|
||||
/**
|
||||
|
@ -28,7 +23,7 @@ class Utils
|
|||
*/
|
||||
public static function getServices(): ?array
|
||||
{
|
||||
$list = dcCore::app()->getBehaviors('kutrlService');
|
||||
$list = App::behavior()->getBehavior('kutrlService');
|
||||
|
||||
if (empty($list)) {
|
||||
return [];
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Form,
|
||||
Hidden,
|
||||
|
@ -27,30 +17,34 @@ use Dotclear\Helper\Html\Html;
|
|||
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||
|
||||
/**
|
||||
* @brief kUtRL widgets.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Widgets
|
||||
{
|
||||
public static function initShorten(WidgetsStack $w): void
|
||||
public static function init(WidgetsStack $w): void
|
||||
{
|
||||
$w
|
||||
->create(
|
||||
'shortenkutrl',
|
||||
My::name(),
|
||||
[self::class, 'parseShorten']
|
||||
self::parseShorten(...)
|
||||
)
|
||||
->addTitle(__('Shorten link'))
|
||||
->addHomeOnly()
|
||||
->addContentOnly()
|
||||
->addClass()
|
||||
->addOffline();
|
||||
}
|
||||
|
||||
public static function initRank(WidgetsStack $w): void
|
||||
{
|
||||
$w
|
||||
->create(
|
||||
'rankkutrl',
|
||||
__('Top of short links'),
|
||||
[self::class, 'parseRank']
|
||||
self::parseRank(...)
|
||||
)
|
||||
->addTitle(__('Top of short links'))
|
||||
->setting(
|
||||
|
@ -128,8 +122,8 @@ class Widgets
|
|||
|
||||
if (!$s->get('active')
|
||||
|| !$s->get('srv_local_public')
|
||||
|| !$w->checkHomeOnly(dcCore::app()->url->type)
|
||||
|| dcCore::app()->url->type == 'kutrl') {
|
||||
|| !$w->checkHomeOnly(App::url()->type)
|
||||
|| App::url()->type == 'kutrl') {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -143,7 +137,7 @@ class Widgets
|
|||
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
|
||||
(new Form(['shortenkutrlwidget']))
|
||||
->method('post')
|
||||
->action(dcCore::app()->blog->url . dcCore::app()->url->getBase('kutrl'))
|
||||
->action(App::blog()->url() . App::url()->getBase('kutrl'))
|
||||
->fields([
|
||||
(new Para())
|
||||
->items([
|
||||
|
@ -168,7 +162,7 @@ class Widgets
|
|||
(new Submit('submiturl'))
|
||||
->value(__('Shorten')),
|
||||
(new Hidden('hmfp', $hmfp)),
|
||||
dcCore::app()->formNonce(false),
|
||||
App::nonce()->formNonce(),
|
||||
]),
|
||||
])
|
||||
->render()
|
||||
|
@ -179,19 +173,19 @@ class Widgets
|
|||
{
|
||||
$s = My::settings();
|
||||
|
||||
if (!$s->get('active') || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||
if (!$s->get('active') || !$w->checkHomeOnly(App::url()->type)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$type = in_array($w->type, ['localnormal', 'localmix', 'localcustom']) ?
|
||||
"AND kut_type ='" . $w->type . "' " :
|
||||
'AND kut_type ' . dcCore::app()->con->in(['localnormal', 'localmix', 'localcustom']) . ' ';
|
||||
'AND kut_type ' . App::con()->in(['localnormal', 'localmix', 'localcustom']) . ' ';
|
||||
|
||||
$hide = (bool) $w->hideempty ? 'AND kut_counter > 0 ' : '';
|
||||
|
||||
$more = '';
|
||||
if ($w->type == 'localmix' && '' != $w->mixprefix) {
|
||||
$more = "AND kut_hash LIKE '" . dcCore::app()->con->escapeStr((string) $w->mixprefix) . "%' ";
|
||||
$more = "AND kut_hash LIKE '" . App::con()->escapeStr((string) $w->mixprefix) . "%' ";
|
||||
}
|
||||
|
||||
$order = ($w->sortby && in_array($w->sortby, ['kut_dt', 'kut_counter', 'kut_hash'])) ?
|
||||
|
@ -199,12 +193,12 @@ class Widgets
|
|||
|
||||
$order .= $w->sort == 'desc' ? ' DESC' : ' ASC';
|
||||
|
||||
$limit = dcCore::app()->con->limit(abs((int) $w->limit));
|
||||
$limit = App::con()->limit(abs((int) $w->limit));
|
||||
|
||||
$rs = dcCore::app()->con->select(
|
||||
$rs = App::con()->select(
|
||||
'SELECT kut_counter, kut_hash ' .
|
||||
'FROM ' . dcCore::app()->prefix . My::TABLE_NAME . ' ' .
|
||||
"WHERE blog_id='" . dcCore::app()->con->escapeStr((string) dcCore::app()->blog->id) . "' " .
|
||||
'FROM ' . App::con()->prefix() . My::TABLE_NAME . ' ' .
|
||||
"WHERE blog_id='" . App::con()->escapeStr(App::blog()->id()) . "' " .
|
||||
"AND kut_service = 'local' " .
|
||||
$type . $hide . $more . 'ORDER BY ' . $order . $limit
|
||||
);
|
||||
|
@ -220,7 +214,7 @@ class Widgets
|
|||
$rank = '<span class="rankkutrl-rank">' . $i . '</span>';
|
||||
|
||||
$hash = $rs->kut_hash;
|
||||
$url = dcCore::app()->blog->url . dcCore::app()->url->getBase('kutrl') . '/' . $hash;
|
||||
$url = App::blog()->url() . App::url()->getBase('kutrl') . '/' . $hash;
|
||||
$cut_len = - abs((int) $w->urllen);
|
||||
|
||||
if (strlen($url) > $cut_len) {
|
||||
|
@ -240,7 +234,7 @@ class Widgets
|
|||
}
|
||||
|
||||
$content .= '<li><a href="' .
|
||||
dcCore::app()->blog->url . dcCore::app()->url->getBase('kutrl') . '/' . $rs->kut_hash .
|
||||
App::blog()->url() . App::url()->getBase('kutrl') . '/' . $rs->kut_hash .
|
||||
'">' .
|
||||
str_replace(
|
||||
['%rank%', '%hash%', '%url%', '%count%', '%counttext%'],
|
||||
|
|
29
src/Wiki.php
29
src/Wiki.php
|
@ -1,31 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief kUtRL, a plugin for Dotclear 2
|
||||
*
|
||||
* This file contents class to shorten url pass through wiki
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis 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\kUtRL;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Helper\Html\WikiToHtml;
|
||||
|
||||
/**
|
||||
* @brief kUtRL wiki stuff.
|
||||
* @ingroup kUtRL
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Wiki
|
||||
{
|
||||
public static function coreInitWiki(WikiToHtml $wiki2xhtml): void
|
||||
{
|
||||
# Do nothing on comment preview and post preview
|
||||
if (!empty($_POST['preview'])
|
||||
|| isset(dcCore::app()->ctx) && dcCore::app()->ctx->preview
|
||||
|| (App::task()->checkContext('FRONTEND') && App::frontend()->context()->preview)
|
||||
|| !My::settings()?->get('active')
|
||||
) {
|
||||
return;
|
||||
|
@ -36,7 +31,7 @@ class Wiki
|
|||
foreach ($kut->allow_protocols as $protocol) {
|
||||
$wiki2xhtml->registerFunction(
|
||||
'url:' . $protocol,
|
||||
[self::class, 'transform']
|
||||
self::transform(...)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +65,7 @@ class Wiki
|
|||
$res['content'] = $res['url'];
|
||||
}
|
||||
|
||||
dcCore::app()->callBehavior('wikiAfterKutrlCreate', $rs, __('New short URL'));
|
||||
App::behavior()->callBehavior('wikiAfterKutrlCreate', $rs, __('New short URL'));
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue