diff --git a/CHANGELOG.md b/CHANGELOG.md
index 41eb843..69bf33c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/README.md b/README.md
index 645dc99..1c6c259 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/_define.php b/_define.php
index e501efe..82d4b3b 100644
--- a/_define.php
+++ b/_define.php
@@ -1,37 +1,29 @@
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,
- ]),
- 'type' => 'plugin',
- 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
- 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
- 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
+ 'requires' => [['core', '2.28']],
+ 'permissions' => 'My',
+ 'type' => 'plugin',
+ 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
+ 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
+ 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
]
);
diff --git a/_init.php b/_init.php
deleted file mode 100644
index cfa2c49..0000000
--- a/_init.php
+++ /dev/null
@@ -1,20 +0,0 @@
-
%s
', $img_chk) . $o->error->toHTML())); } diff --git a/src/Frontend.php b/src/Frontend.php index 1f610f0..1c3e682 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,25 +1,18 @@ 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; } diff --git a/src/FrontendBehaviors.php b/src/FrontendBehaviors.php index d10d404..dd992ba 100644 --- a/src/FrontendBehaviors.php +++ b/src/FrontendBehaviors.php @@ -1,30 +1,27 @@ ctx->__set("disable_kutrl", true); ?>'; + return '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 'ctx->__set("disable_kutrl", false); ?>'; + return '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 diff --git a/src/FrontendTemplate.php b/src/FrontendTemplate.php index b864f0c..90db5ff 100644 --- a/src/FrontendTemplate.php +++ b/src/FrontendTemplate.php @@ -1,39 +1,35 @@ tpl->getFilters($attr); + $f = App::frontend()->template()->getFilters($attr); - return 'blog->url.dcCore::app()->url->getBase("kutrl")') . '; ?>'; + return '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 'ctx->kutrl_msg; ?>'; + return 'context()->kutrl_msg; ?>'; } public static function humanField(ArrayObject $attr): string { - return "ctx->kutrl_hmf); ?>"; + return "context()->kutrl_hmf); ?>"; } public static function humanFieldProtect(ArrayObject $attr): string { return - '' . - 'formNonce(); ?>'; + '' . + '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 "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" . diff --git a/src/FrontendUrl.php b/src/FrontendUrl.php index c2a4de8..6a51e24 100644 --- a/src/FrontendUrl.php +++ b/src/FrontendUrl.php @@ -1,25 +1,22 @@ ctx->kutrl_msg = ''; - dcCore::app()->ctx->kutrl_hmf = FrontendUtils::create(); - dcCore::app()->ctx->kutrl_hmfp = FrontendUtils::protect(dcCore::app()->ctx->kutrl_hmf); + $args = $m[3] ?? ''; + 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']) : '?'; @@ -104,45 +101,45 @@ class FrontendUrl extends dcUrlHandlers $err = false; if (!$err) { if ($hmf != $hmfu) { - $err = true; - dcCore::app()->ctx->kutrl_msg = __('Failed to verify protected field.'); + $err = true; + 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.'); + $err = true; + 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.'); + $err = true; + 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.'); + $err = true; + 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.'); + $err = true; + 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.'); + $err = true; + 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.'); + $err = true; + 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), '' . $new_url . '' @@ -161,28 +158,28 @@ class FrontendUrl extends dcUrlHandlers } if (!$err) { if (false === ($rs = $kut->hash($url))) { - $err = true; - dcCore::app()->ctx->kutrl_msg = __('Failed to create short link.'); + $err = true; + 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), '' . $new_url . '' ); - 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; } } diff --git a/src/FrontendUtils.php b/src/FrontendUtils.php index 6593064..ffdf539 100644 --- a/src/FrontendUtils.php +++ b/src/FrontendUtils.php @@ -1,19 +1,16 @@ 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(); } diff --git a/src/Install.php b/src/Install.php index dab7c48..92455db 100644 --- a/src/Install.php +++ b/src/Install.php @@ -1,27 +1,20 @@ 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; } diff --git a/src/LinksListing.php b/src/LinksListing.php index 3b65b76..5b35717 100644 --- a/src/LinksListing.php +++ b/src/LinksListing.php @@ -1,21 +1,11 @@ (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'), diff --git a/src/Logs.php b/src/Logs.php index b22bb14..8b8ec74 100644 --- a/src/Logs.php +++ b/src/Logs.php @@ -1,22 +1,10 @@ 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'])); diff --git a/src/Manage.php b/src/Manage.php index 30fe2e4..c86b0fb 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -1,20 +1,10 @@ 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; diff --git a/src/ManageLinks.php b/src/ManageLinks.php index de37869..37bd30f 100644 --- a/src/ManageLinks.php +++ b/src/ManageLinks.php @@ -1,20 +1,10 @@ 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()); } } diff --git a/src/My.php b/src/My.php index db57e75..c9cbbf5 100644 --- a/src/My.php +++ b/src/My.php @@ -1,15 +1,5 @@ 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; } } diff --git a/src/Service.php b/src/Service.php index ac51573..9c16de0 100644 --- a/src/Service.php +++ b/src/Service.php @@ -1,24 +1,10 @@ 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. */ diff --git a/src/Service/ServiceBilbolinks.php b/src/Service/ServiceBilbolinks.php index 7eb56ed..c2e5fc5 100644 --- a/src/Service/ServiceBilbolinks.php +++ b/src/Service/ServiceBilbolinks.php @@ -1,20 +1,9 @@ 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 + ); } } diff --git a/src/Service/ServiceBitly.php b/src/Service/ServiceBitly.php index bf4383d..4edadcd 100644 --- a/src/Service/ServiceBitly.php +++ b/src/Service/ServiceBitly.php @@ -1,20 +1,9 @@ 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() diff --git a/src/Service/ServiceCustom.php b/src/Service/ServiceCustom.php index 4a98645..2c7838a 100644 --- a/src/Service/ServiceCustom.php +++ b/src/Service/ServiceCustom.php @@ -1,20 +1,9 @@ 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 + ); } } diff --git a/src/Service/ServiceDefault.php b/src/Service/ServiceDefault.php index 72422bb..1f6e045 100644 --- a/src/Service/ServiceDefault.php +++ b/src/Service/ServiceDefault.php @@ -1,20 +1,9 @@ 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 + ); } } diff --git a/src/Service/ServiceIsgd.php b/src/Service/ServiceIsgd.php index e875d93..a59fc74 100644 --- a/src/Service/ServiceIsgd.php +++ b/src/Service/ServiceIsgd.php @@ -1,22 +1,18 @@ 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 + ); } } diff --git a/src/Service/ServiceLocal.php b/src/Service/ServiceLocal.php index 4748313..3942aa1 100644 --- a/src/Service/ServiceLocal.php +++ b/src/Service/ServiceLocal.php @@ -1,21 +1,10 @@ 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.')); } diff --git a/src/Service/ServiceYourls.php b/src/Service/ServiceYourls.php index e5f5071..119174a 100644 --- a/src/Service/ServiceYourls.php +++ b/src/Service/ServiceYourls.php @@ -1,20 +1,9 @@ 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.')); diff --git a/src/Uninstall.php b/src/Uninstall.php index 1dca400..b1fa1bf 100644 --- a/src/Uninstall.php +++ b/src/Uninstall.php @@ -1,25 +1,18 @@ plugins->moduleExists('Uninstaller')) { + if (!self::status()) { return false; } diff --git a/src/Utils.php b/src/Utils.php index 3ee1e1c..e40655c 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -1,24 +1,19 @@ getBehaviors('kutrlService'); + $list = App::behavior()->getBehavior('kutrlService'); if (empty($list)) { return []; diff --git a/src/Widgets.php b/src/Widgets.php index 80f5111..7ca5621 100644 --- a/src/Widgets.php +++ b/src/Widgets.php @@ -1,20 +1,10 @@ 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 = '' . $i . ''; $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 .= '