release 2023.10.11

This commit is contained in:
Jean-Christian Denis 2023-10-11 21:30:06 +02:00
parent 19c4447e46
commit 9d681dfee1
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
8 changed files with 94 additions and 103 deletions

View file

@ -1,3 +1,9 @@
lastBlogUpdate 2023.10.11
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
lastBlogUpdate 2023.08.12
===========================================================
* Require Dotclear 2.27

View file

@ -1,25 +1,22 @@
# README
[![Release](https://img.shields.io/badge/release-2023.08.12-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases)
[![Date](https://img.shields.io/badge/date-2023.08.12-c44d58.svg)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases)
[![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.11-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases)
![Date](https://img.shields.io/badge/date-2023.10.11-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/lastBlogUpdate)
[![License](https://img.shields.io/github/license/JcDenis/lastBlogUpdate)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/blob/master/LICENSE)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/src/branch/master/LICENSE)
## WHAT IS LASTBLOGUPDATE ?
## ABOUT
_last blog update_ is a plugin for the open-source
web publishing software called Dotclear.
_lastBlogUpdate_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
Simply show visitors last update of posts, comments, etc of your blog.
> Simply show visitors last update of posts, comments, etc of your blog.
## REQUIREMENTS
_lastBlogUpdate_ requires:
* permissions to manage widgets
* Dotclear 2.27
* PHP 7.4+
* Dotclear 2.28
* PHP 8.1+
## USAGE
@ -30,14 +27,15 @@ Add and configure _Last blog update_ 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/lastBlogUpdate) or [GitHub Page](https://github.com/JcDenis/lastBlogUpdate)
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/lastBlogUpdate)
* Discuss and help : [Dotclear Forum](ttp://forum.dotclear.org/viewtopic.php?pid=332950#p332950)
* [License](https://git.dotclear.watch/JcDenis/lastBlogUpdate/src/branch/master/LICENSE)
* [Packages & details](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/lastBlogUpdate))
* [Sources & contributions](https://git.dotclear.watch/JcDenis/lastBlogUpdate) (or on [GitHub](https://github.com/JcDenis/lastBlogUpdate))
* [Issues & security](https://git.dotclear.watch/JcDenis/lastBlogUpdate/issues) (or on [GitHub](https://github.com/JcDenis/lastBlogUpdate/issues))
* [Discuss & help](ttp://forum.dotclear.org/viewtopic.php?pid=332950#p332950)
## CONTRIBUTORS
* Jean-Christian Denis
* Jean-Christian Denis (author)
* Pierre Van Glabeke
You are welcome to contribute to this code.

View file

@ -1,30 +1,25 @@
<?php
/**
* @brief lastBlogUpdate, a plugin for Dotclear 2
* @file
* @brief The plugin lastBlogUpdate definition
* @ingroup lastBlogUpdate
*
* @package Dotclear
* @subpackage Plugin
* @defgroup lastBlogUpdate Plugin lastBlogUpdate.
*
* @author Jean-Christian Denis, Pierre Van Glabeke
* Show the dates of last updates of your blog in a widget.
*
* @author Jean-Christian Denis
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
$this->registerModule(
'Last blog update',
'Show the dates of last updates of your blog in a widget',
'Jean-Christian Denis, Pierre Van Glabeke',
'2023.08.12',
'2023.10.11',
[
'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_USAGE,
dcCore::app()->auth::PERMISSION_CONTENT_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',

View file

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="lastBlogUpdate">
<name>Last blog update</name>
<version>2023.08.12</version>
<version>2023.10.11</version>
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
<desc>Show the dates of last updates of your blog in a widget</desc>
<file>https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases/download/v2023.08.12/plugin-lastBlogUpdate.zip</file>
<da:dcmin>2.27</da:dcmin>
<file>https://github.com/JcDenis/lastBlogUpdate/releases/download/v2023.10.11/plugin-lastBlogUpdate.zip</file>
<da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/lastBlogUpdate/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/lastBlogUpdate/issues</da:support>
</module>

View file

@ -1,22 +1,20 @@
<?php
/**
* @brief lastBlogUpdate, 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\lastBlogUpdate;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
/**
* @brief lastBlogUpdate backend class.
* @ingroup lastBlogUpdate
*
* @author Jean-Christian Denis
* @copyright 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,7 +28,7 @@ class Backend extends Process
return false;
}
dcCore::app()->addBehaviors([
App::behavior()->addBehaviors([
'initWidgets' => [Widgets::class, 'initWidgets'],
]);

View file

@ -1,22 +1,20 @@
<?php
/**
* @brief lastBlogUpdate, 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\lastBlogUpdate;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
/**
* @brief lastBlogUpdate frontend class.
* @ingroup lastBlogUpdate
*
* @author Jean-Christian Denis
* @copyright 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,7 +28,7 @@ class Frontend extends Process
return false;
}
dcCore::app()->addBehaviors([
App::behavior()->addBehaviors([
'initWidgets' => [Widgets::class, 'initWidgets'],
]);

View file

@ -1,21 +1,20 @@
<?php
/**
* @brief lastBlogUpdate, 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\lastBlogUpdate;
use Dotclear\Module\MyPlugin;
/**
* @brief lastBlogUpdate My helper.
* @ingroup lastBlogUpdate
*
* @author Jean-Christian Denis
* @copyright 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,27 +1,24 @@
<?php
/**
* @brief lastBlogUpdate, 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\lastBlogUpdate;
use dcCore;
use dcMedia;
use Dotclear\App;
use Dotclear\Database\Statement\SelectStatement;
use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsStack;
use Dotclear\Plugin\widgets\WidgetsElement;
/**
* @brief lastBlogUpdate widgets class.
* @ingroup lastBlogUpdate
*
* @author Jean-Christian Denis
* @copyright 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
@ -109,9 +106,9 @@ class Widgets
);
# --BEHAVIOR-- lastBlogUpdateWidgetInit
dcCore::app()->callBehavior('lastBlogUpdateWidgetInit', $w);
App::behavior()->callBehavior('lastBlogUpdateWidgetInit', $w);
$w->lastblogupdate
$w->__get('lastblogupdate')
->addHomeOnly()
->addContentOnly()
->addClass()
@ -120,30 +117,30 @@ class Widgets
public static function parseWidget(WidgetsElement $w): string
{
if ($w->offline || is_null(dcCore::app()->blog)) {
if ($w->offline || !App::blog()->isDefined()) {
return '';
}
# Nothing to display
if (!$w->checkHomeOnly(dcCore::app()->url->type)
if (!$w->checkHomeOnly(App::url()->type)
|| !$w->blog_show && !$w->post_show && !$w->comment_show && !$w->media_show
|| !$w->blog_text && !$w->post_text && !$w->comment_text && !$w->media_text) {
return '';
}
$blog = $post = $comment = $media = $addons = '';
$tz = is_string(dcCore::app()->blog->settings->get('system')->get('blog_timezone')) ? dcCore::app()->blog->settings->get('system')->get('blog_timezone') : 'UTC';
$tz = is_string(App::blog()->settings()->get('system')->get('blog_timezone')) ? App::blog()->settings()->get('system')->get('blog_timezone') : 'UTC';
# Blog
if ($w->blog_show && $w->blog_text && is_numeric(dcCore::app()->blog->upddt)) {
if ($w->blog_show && $w->blog_text) {
$title = $w->blog_title ? sprintf('<strong>%s</strong>', Html::escapeHTML($w->blog_title)) : '';
$text = Date::str($w->blog_text, (int) dcCore::app()->blog->upddt, $tz);
$text = Date::str($w->blog_text, App::blog()->upddt(), $tz);
$blog = sprintf('<li>%s %s</li>', $title, $text);
}
# Post
if ($w->post_show && $w->post_text) {
$rs = dcCore::app()->blog->getPosts(['limit' => 1, 'no_content' => true]);
$rs = App::blog()->getPosts(['limit' => 1, 'no_content' => true]);
if (!$rs->isEmpty()) {
$title = $w->post_title ? sprintf('<strong>%s</strong>', Html::escapeHTML($w->post_title)) : '';
$text = Date::str($w->post_text, (int) strtotime(is_string($rs->f('post_upddt')) ? $rs->f('post_upddt') : ''), $tz);
@ -156,11 +153,11 @@ class Widgets
# Comment
if ($w->comment_show && $w->comment_text) {
$rs = dcCore::app()->blog->getComments(['limit' => 1, 'no_content' => true]);
$rs = App::blog()->getComments(['limit' => 1, 'no_content' => true]);
if (!$rs->isEmpty()) {
$title = $w->comment_title ? sprintf('<strong>%s</strong>', Html::escapeHTML($w->comment_title)) : '';
$text = Date::str($w->comment_text, (int) strtotime(is_string($rs->f('comment_upddt')) ? $rs->f('comment_upddt') : ''), $tz);
$link = dcCore::app()->blog->url . dcCore::app()->getPostPublicURL(is_string($rs->f('post_type')) ? $rs->f('post_type') : '', Html::sanitizeURL(is_string($rs->f('post_url')) ? $rs->f('post_url') : '')) . '#c' . $rs->f('comment_id');
$link = App::blog()->url() . App::postTypes()->get(is_string($rs->f('post_type')) ? $rs->f('post_type') : '')->publicUrl(Html::sanitizeURL(is_string($rs->f('post_url')) ? $rs->f('post_url') : '')) . '#c' . $rs->f('comment_id');
$over = is_string($rs->f('post_title')) ? $rs->f('post_title') : '';
$comment = sprintf('<li>%s <a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text);
@ -169,9 +166,9 @@ class Widgets
# Media
if ($w->media_show && $w->media_text) {
$path = dcCore::app()->blog->settings->get('system')->get('public_path');
$path = App::blog()->settings()->get('system')->get('public_path');
$sql = new SelectStatement();
$rs = $sql->from(dcCore::app()->prefix . dcMedia::MEDIA_TABLE_NAME)
$rs = $sql->from(App::con()->prefix() . App::postMedia()::MEDIA_TABLE_NAME)
->column('media_upddt')
->where('media_path = ' . $sql->quote(is_string($path) ? $path : ''))
->order('media_upddt DESC')
@ -187,7 +184,7 @@ class Widgets
}
# --BEHAVIOR-- lastBlogUpdateWidgetParse
$addons = dcCore::app()->callBehavior('lastBlogUpdateWidgetParse', $w);
$addons = App::behavior()->callBehavior('lastBlogUpdateWidgetParse', $w);
# Nothing to display
if (!$blog && !$post && !$comment && !$media && !$addons) {