upgrade to dotclear 2.28

master v1.2
Jean-Christian Paul Denis 2023-10-20 18:04:17 +02:00
parent a4111065bb
commit aa7ec2d61d
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
8 changed files with 125 additions and 146 deletions

View File

@ -1,3 +1,9 @@
postInfoWidget 1.2 - 2023.10.20
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
postInfoWidget 1.1 - 2023.08.13
===========================================================
* Require Dotclear 2.27

View File

@ -1,25 +1,22 @@
# README
[![Release](https://img.shields.io/badge/release-1.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postInfoWidget/releases)
[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/postInfoWidget/releases)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
[![Release](https://img.shields.io/badge/release-1.2-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postInfoWidget/releases)
![Date](https://img.shields.io/badge/date-2023.10.20-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/postInfoWidget)
[![License](https://img.shields.io/github/license/JcDenis/postInfoWidget)](https://git.dotclear.watch/JcDenis/postInfoWidget/blob/master/LICENSE)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/postInfoWidget/src/branch/master/LICENSE)
## WHAT IS POSTINFOWIDGET ?
## ABOUT
_postInfoWidget_ "Entry information list" is a plugin for the open-source
web publishing software called Dotclear.
_postInfoWidget_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
Show entry details in a widget.
> Show entry details in a widget.
## REQUIREMENTS
_postInfoWidget_ requires:
* permissions to manage widgets
* Dotclear 2.26
* PHP 7.4
* Dotclear 2.28
* PHP 8.1
* Dotclear permissions to manage widgets
## USAGE
@ -30,14 +27,15 @@ Add and configure "Entry information list" from widgets manager.
## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/postInfoWidget) or [GitHub Page](https://github.com/JcDenis/postInfoWidget)
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/postInfoWidget/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/postInfoWidget)
* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=332974#p332974)
* [License](https://git.dotclear.watch/JcDenis/postInfoWidget/src/branch/master/LICENSE)
* [Packages & details](https://git.dotclear.watch/JcDenis/postInfoWidget/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/postInfoWidget))
* [Sources & contributions](https://git.dotclear.watch/JcDenis/postInfoWidget) (or on [GitHub](https://github.com/JcDenis/postInfoWidget))
* [Issues & security](https://git.dotclear.watch/JcDenis/postInfoWidget/issues) (or on [GitHub](https://github.com/JcDenis/postInfoWidget/issues))
* [Discuss & help](http://forum.dotclear.org/viewtopic.php?pid=332974#p332974)
## CONTRIBUTORS
* Jean-Christian Denis
* Jean-Christian Denis (author)
* Pierre Van Glabeke
You are welcome to contribute to this code.

View File

@ -1,33 +1,29 @@
<?php
/**
* @brief postInfoWidget, a plugin for Dotclear 2
* @file
* @brief The plugin postInfoWidget definition
* @ingroup postInfoWidget
*
* @package Dotclear
* @subpackage Plugin
* @defgroup postInfoWidget Plugin postInfoWidget.
*
* @author Jean-Christian Denis, Pierre Van Glabeke
* Show Entry informations on a widget.
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* @author Jean-Christian Denis
* @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(
'Entry information list',
'Show Entry informations on a widget',
'Jean-Christian Denis, Pierre Van Glabeke',
'1.1',
'1.2',
[
'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_USAGE,
dcAuth::PERMISSION_CONTENT_ADMIN,
]),
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
'requires' => [['core', '2.28']],
'permissions' => 'My',
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
]
);

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="postInfoWidget">
<name>Entry information list</name>
<version>1.1</version>
<version>1.2</version>
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
<desc>Show Entry informations on a widget</desc>
<file>https://git.dotclear.watch/JcDenis/postInfoWidget/releases/download/v1.1/plugin-postInfoWidget.zip</file>
<da:dcmin>2.27</da:dcmin>
<file>https://git.dotclear.watch/JcDenis/postInfoWidget/releases/download/v1.2/plugin-postInfoWidget.zip</file>
<da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/postInfoWidget/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/postInfoWidget/issues</da:support>
</module>

View File

@ -1,22 +1,19 @@
<?php
/**
* @brief postInfoWidget, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\postInfoWidget;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
/**
* @brief postInfoWidget backend class.
* @ingroup postInfoWidget
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Backend extends Process
{
public static function init(): bool
@ -30,9 +27,7 @@ class Backend extends Process
return false;
}
dcCore::app()->addBehaviors([
'initWidgets' => [Widgets::class, 'initWidgets'],
]);
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true;
}

View File

@ -1,22 +1,19 @@
<?php
/**
* @brief postInfoWidget, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\postInfoWidget;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
/**
* @brief postInfoWidget frontend class.
* @ingroup postInfoWidget
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Frontend extends Process
{
public static function init(): bool
@ -30,9 +27,7 @@ class Frontend extends Process
return false;
}
dcCore::app()->addBehaviors([
'initWidgets' => [Widgets::class, 'initWidgets'],
]);
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true;
}

View File

@ -1,21 +1,19 @@
<?php
/**
* @brief postInfoWidget, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\postInfoWidget;
use Dotclear\Module\MyPlugin;
/**
* @brief postInfoWidget My helper.
* @ingroup postInfoWidget
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class My extends MyPlugin
{
// Use default permissions
}

View File

@ -1,20 +1,10 @@
<?php
/**
* @brief postInfoWidget, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis, Pierre Van Glabeke
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
namespace Dotclear\Plugin\postInfoWidget;
use dcCore;
use Dotclear\App;
use Dotclear\Database\MetaRecord;
use Dotclear\Helper\{
Date,
@ -26,6 +16,13 @@ use Dotclear\Plugin\widgets\{
WidgetsElement
};
/**
* @brief postInfoWidget widgets class.
* @ingroup postInfoWidget
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Widgets
{
public static function initWidgets(WidgetsStack $w): void
@ -33,8 +30,8 @@ class Widgets
$w
->create(
'postinfowidget',
__('PostInfoWidget: entry information list'),
[self::class, 'publicWidget'],
__('Entry information list'),
self::publicWidget(...),
null,
__('Show Entry informations on a widget')
)
@ -76,7 +73,7 @@ class Widgets
'text'
);
if (dcCore::app()->plugins->moduleExists('tags')) {
if (App::plugins()->moduleExists('tags')) {
$w->__get('postinfowidget')->setting(
'tag_str',
__('Tags text (%T = tags list):'),
@ -173,7 +170,7 @@ class Widgets
);
//*/
# --BEHAVIOR-- postInfoWidgetAdmin
dcCore::app()->callBehavior('postInfoWidgetAdmin', $w);
App::behavior()->callBehavior('postInfoWidgetAdmin', $w);
$w->__get('postinfowidget')
->addContentOnly()
@ -183,14 +180,10 @@ class Widgets
public static function publicWidget(WidgetsElement $w): string
{
// nullsafe
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
return '';
}
if ($w->__get('offline')
|| dcCore::app()->url->type != 'post'
|| !dcCore::app()->ctx->__get('posts')->f('post_id')
if (!App::blog()->isDefined()
|| $w->__get('offline')
|| App::url()->type != 'post'
|| !App::frontend()->context()->__get('posts')->f('post_id')
) {
return '';
}
@ -204,8 +197,8 @@ class Widgets
'date',
Date::str(
$w->__get('dt_str'),
(int) strtotime(dcCore::app()->ctx->__get('posts')->f('post_dt')),
dcCore::app()->blog->settings->get('system')->get('blog_timezone')
(int) strtotime(App::frontend()->context()->__get('posts')->f('post_dt')),
App::blog()->settings()->get('system')->get('blog_timezone')
)
);
}
@ -216,8 +209,8 @@ class Widgets
'create',
Date::str(
$w->__get('creadt_str'),
(int) strtotime(dcCore::app()->ctx->__get('posts')->post_creadt),
dcCore::app()->blog->settings->get('system')->get('blog_timezone')
(int) strtotime(App::frontend()->context()->__get('posts')->post_creadt),
App::blog()->settings()->get('system')->get('blog_timezone')
)
);
}
@ -228,24 +221,24 @@ class Widgets
'update',
Date::str(
$w->__get('upddt_str'),
(int) strtotime(dcCore::app()->ctx->__get('posts')->f('post_upddt')),
dcCore::app()->blog->settings->get('system')->get('blog_timezone')
(int) strtotime(App::frontend()->context()->__get('posts')->f('post_upddt')),
App::blog()->settings()->get('system')->get('blog_timezone')
)
);
}
if ($w->__get('lang_str') != '') {
$ln = L10n::getISOcodes();
$lang_code = dcCore::app()->ctx->__get('posts')->f('post_lang') ?
dcCore::app()->ctx->__get('posts')->f('post_lang') :
dcCore::app()->blog->settings->get('system')->get('lang');
$lang_code = App::frontend()->context()->__get('posts')->f('post_lang') ?
App::frontend()->context()->__get('posts')->f('post_lang') :
App::blog()->settings()->get('system')->get('lang');
$lang_name = $ln[$lang_code] ?? $lang_code;
$lang_flag = file_exists(
dirname(__DIR__) .
'/img/flags/' .
$lang_code . '.png'
) ?
'<img src="' . dcCore::app()->blog->getQmarkURL() .
'<img src="' . App::blog()->getQmarkURL() .
'pf=postInfoWidget/img/flags/' .
$lang_code . '.png" alt="' . $lang_name . '" />' :
'';
@ -267,13 +260,13 @@ class Widgets
'author',
str_replace(
'%T',
dcCore::app()->ctx->__get('posts')->getAuthorLink(),
App::frontend()->context()->__get('posts')->getAuthorLink(),
Html::escapeHTML($w->__get('author_str'))
)
);
}
if ($w->__get('category_str') != '' && dcCore::app()->ctx->__get('posts')->f('cat_id')) {
if ($w->__get('category_str') != '' && App::frontend()->context()->__get('posts')->f('cat_id')) {
$content .= self::li(
$w,
'category',
@ -281,25 +274,25 @@ class Widgets
'%T',
sprintf(
$link,
dcCore::app()->ctx->__get('posts')->__call('getCategoryURL', []),
Html::escapeHTML(dcCore::app()->ctx->__get('posts')->f('cat_title'))
App::frontend()->context()->__get('posts')->__call('getCategoryURL', []),
Html::escapeHTML(App::frontend()->context()->__get('posts')->f('cat_title'))
),
Html::escapeHTML($w->__get('category_str'))
)
);
}
if ($w->__get('tag_str') != '' && dcCore::app()->plugins->moduleExists('tags')) {
$meta = dcCore::app()->meta->getMetadata([
if ($w->__get('tag_str') != '' && App::plugins()->moduleExists('tags')) {
$meta = App::meta()->getMetadata([
'meta_type' => 'tag',
'post_id' => dcCore::app()->ctx->__get('posts')->f('post_id'),
'post_id' => App::frontend()->context()->__get('posts')->f('post_id'),
]);
$metas = [];
while ($meta->fetch()) {
$metas[$meta->f('meta_id')] = sprintf(
$link,
dcCore::app()->blog->url .
dcCore::app()->url->getBase('tag') . '/' .
App::blog()->url() .
App::url()->getBase('tag') . '/' .
rawurlencode($meta->f('meta_id')),
$meta->f('meta_id')
);
@ -318,7 +311,7 @@ class Widgets
}
if ($w->__get('attachment_str') != '') {
$nb = dcCore::app()->ctx->__get('posts')->__call('countMedia', []);
$nb = App::frontend()->context()->__get('posts')->__call('countMedia', []);
if ($nb == 0) {
$attachment_numeric = 0;
$attachment_textual = __('no attachment');
@ -357,8 +350,8 @@ class Widgets
);
}
if ($w->__get('comment_str') != '' && dcCore::app()->ctx->__get('posts')->__call('commentsActive', [])) {
$nb = (int) dcCore::app()->ctx->__get('posts')->f('nb_comment');
if ($w->__get('comment_str') != '' && App::frontend()->context()->__get('posts')->__call('commentsActive', [])) {
$nb = (int) App::frontend()->context()->__get('posts')->f('nb_comment');
if ($nb == 0) {
$comment_numeric = 0;
$comment_textual = __('no comment');
@ -397,8 +390,8 @@ class Widgets
);
}
if ($w->__get('trackback_str') != '' && dcCore::app()->ctx->__get('posts')->__call('trackbacksActive', [])) {
$nb = (int) dcCore::app()->ctx->__get('posts')->f('nb_trackback');
if ($w->__get('trackback_str') != '' && App::frontend()->context()->__get('posts')->__call('trackbacksActive', [])) {
$nb = (int) App::frontend()->context()->__get('posts')->f('nb_trackback');
if ($nb == 0) {
$trackback_numeric = 0;
$trackback_textual = __('no trackback');
@ -446,26 +439,26 @@ class Widgets
[
sprintf(
$link,
dcCore::app()->ctx->__get('posts')->__call('getURL', []),
App::frontend()->context()->__get('posts')->__call('getURL', []),
__('Permalink')
),
dcCore::app()->ctx->__get('posts')->__call('getURL', []),
App::frontend()->context()->__get('posts')->__call('getURL', []),
],
Html::escapeHTML($w->__get('permalink_str'))
)
);
}
if ($w->__get('feed') && dcCore::app()->ctx->__get('posts')->__call('commentsActive', [])) {
if ($w->__get('feed') && App::frontend()->context()->__get('posts')->__call('commentsActive', [])) {
$content .= self::li(
$w,
'feed',
sprintf(
$link,
dcCore::app()->blog->url .
dcCore::app()->url->getBase('feed') .
App::blog()->url() .
App::url()->getBase('feed') .
'/atom/comments/' .
dcCore::app()->ctx->__get('posts')->f('post_id'),
App::frontend()->context()->__get('posts')->f('post_id'),
__("This post's comments feed")
)
);
@ -473,7 +466,7 @@ class Widgets
if ($w->__get('navprevpost')) {
$npp = self::nav(
dcCore::app()->ctx->__get('posts'),
App::frontend()->context()->__get('posts'),
-1,
false,
__('Previous entry'),
@ -489,7 +482,7 @@ class Widgets
}
if ($w->__get('navnextpost')) {
$nnp = self::nav(
dcCore::app()->ctx->__get('posts'),
App::frontend()->context()->__get('posts'),
1,
false,
__('Next entry'),
@ -506,7 +499,7 @@ class Widgets
if ($w->__get('navprevcat')) {
$npc = self::nav(
dcCore::app()->ctx->__get('posts'),
App::frontend()->context()->__get('posts'),
-1,
true,
__('Previous entry of this category'),
@ -523,7 +516,7 @@ class Widgets
if ($w->__get('navnextcat')) {
$nnc = self::nav(
dcCore::app()->ctx->__get('posts'),
App::frontend()->context()->__get('posts'),
1,
true,
__('Next entry of this category'),
@ -539,7 +532,7 @@ class Widgets
}
# --BEHAVIOR-- postInfoWidgetPublic
$content .= dcCore::app()->callBehavior('postInfoWidgetPublic', $w);
$content .= (string) App::behavior()->callBehavior('postInfoWidgetPublic', $w);
if (empty($content)) {
return '';
@ -581,13 +574,12 @@ class Widgets
public static function li(WidgetsElement $w, string $i, string $c): string
{
// nullsafe
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return '';
}
$s = ' style="padding-left:%spx;background: transparent url(\'' .
dcCore::app()->blog->getQmarkURL() .
App::blog()->getQmarkURL() .
'pf=postInfoWidget/img/%s%s.png\') no-repeat left center;"';
if ($w->__get('style') == 'small') {
$s = sprintf($s, 16, $i, '-small');
@ -603,12 +595,11 @@ class Widgets
public static function nav(MetaRecord $p, int $d, bool $r, string $t, string $c): string
{
// nullsafe
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return '';
}
$rs = dcCore::app()->blog->getNextPost($p, $d, $r);
$rs = App::blog()->getNextPost($p, $d, $r);
if (is_null($rs)) {
return '';
}