Compare commits

..

3 Commits

Author SHA1 Message Date
ce1fe633ca
cosmetic (callable) 2023-10-19 20:40:17 +02:00
e0b138ae60
oups 2023-10-14 19:22:50 +02:00
9d681dfee1
release 2023.10.11 2023-10-11 21:30:06 +02:00
8 changed files with 97 additions and 109 deletions

View File

@ -1,3 +1,15 @@
lastBlogUpdate 2023.10.19
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Code review (callable)
lastBlogUpdate 2023.10.11
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
lastBlogUpdate 2023.08.12 lastBlogUpdate 2023.08.12
=========================================================== ===========================================================
* Require Dotclear 2.27 * Require Dotclear 2.27

View File

@ -1,25 +1,22 @@
# README # README
[![Release](https://img.shields.io/badge/release-2023.08.12-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases) [![Release](https://img.shields.io/badge/release-2023.10.19-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) ![Date](https://img.shields.io/badge/date-2023.10.19-c44d58.svg)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) [![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) [![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 _lastBlogUpdate_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
web publishing software called Dotclear.
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 ## REQUIREMENTS
_lastBlogUpdate_ requires: * Dotclear 2.28
* PHP 8.1+
* permissions to manage widgets * Dotclear permissions to manage widgets
* Dotclear 2.27
* PHP 7.4+
## USAGE ## USAGE
@ -30,14 +27,15 @@ Add and configure _Last blog update_ from widgets manager.
## LINKS ## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) * [License](https://git.dotclear.watch/JcDenis/lastBlogUpdate/src/branch/master/LICENSE)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/lastBlogUpdate) or [GitHub Page](https://github.com/JcDenis/lastBlogUpdate) * [Packages & details](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/lastBlogUpdate))
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/lastBlogUpdate) * [Sources & contributions](https://git.dotclear.watch/JcDenis/lastBlogUpdate) (or on [GitHub](https://github.com/JcDenis/lastBlogUpdate))
* Discuss and help : [Dotclear Forum](ttp://forum.dotclear.org/viewtopic.php?pid=332950#p332950) * [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 ## CONTRIBUTORS
* Jean-Christian Denis * Jean-Christian Denis (author)
* Pierre Van Glabeke * Pierre Van Glabeke
You are welcome to contribute to this code. You are welcome to contribute to this code.

View File

@ -1,33 +1,27 @@
<?php <?php
/** /**
* @brief lastBlogUpdate, a plugin for Dotclear 2 * @file
* @brief The plugin lastBlogUpdate definition
* @ingroup lastBlogUpdate
* *
* @package Dotclear * @defgroup lastBlogUpdate Plugin lastBlogUpdate.
* @subpackage Plugin
* *
* @author Jean-Christian Denis, Pierre Van Glabeke * Show the dates of last updates of your blog in a widget.
* *
* @copyright Jean-Christian Denis * @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) {
return null;
}
$this->registerModule( $this->registerModule(
'Last blog update', 'Last blog update',
'Show the dates of last updates of your blog in a widget', 'Show the dates of last updates of your blog in a widget',
'Jean-Christian Denis, Pierre Van Glabeke', 'Jean-Christian Denis, Pierre Van Glabeke',
'2023.08.12', '2023.10.19',
[ [
'requires' => [['core', '2.27']], 'requires' => [['core', '2.28']],
'permissions' => dcCore::app()->auth->makePermissions([ 'permissions' => 'My',
dcCore::app()->auth::PERMISSION_USAGE, 'type' => 'plugin',
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN, 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
]), 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'type' => 'plugin', 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
'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/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="lastBlogUpdate"> <module id="lastBlogUpdate">
<name>Last blog update</name> <name>Last blog update</name>
<version>2023.08.12</version> <version>2023.10.19</version>
<author>Jean-Christian Denis, Pierre Van Glabeke</author> <author>Jean-Christian Denis, Pierre Van Glabeke</author>
<desc>Show the dates of last updates of your blog in a widget</desc> <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> <file>https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases/download/v2023.10.19/plugin-lastBlogUpdate.zip</file>
<da:dcmin>2.27</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/lastBlogUpdate/src/branch/master/README.md</da:details> <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> <da:support>https://git.dotclear.watch/JcDenis/lastBlogUpdate/issues</da:support>
</module> </module>

View File

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

View File

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

View File

@ -1,21 +1,19 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\lastBlogUpdate; namespace Dotclear\Plugin\lastBlogUpdate;
use Dotclear\Module\MyPlugin; use Dotclear\Module\MyPlugin;
/**
* @brief lastBlogUpdate My helper.
* @ingroup lastBlogUpdate
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class My extends MyPlugin class My extends MyPlugin
{ {
// Use default permissions
} }

View File

@ -1,27 +1,23 @@
<?php <?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); declare(strict_types=1);
namespace Dotclear\Plugin\lastBlogUpdate; namespace Dotclear\Plugin\lastBlogUpdate;
use dcCore; use Dotclear\App;
use dcMedia;
use Dotclear\Database\Statement\SelectStatement; use Dotclear\Database\Statement\SelectStatement;
use Dotclear\Helper\Date; use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsStack; use Dotclear\Plugin\widgets\WidgetsStack;
use Dotclear\Plugin\widgets\WidgetsElement; use Dotclear\Plugin\widgets\WidgetsElement;
/**
* @brief lastBlogUpdate widgets class.
* @ingroup lastBlogUpdate
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Widgets class Widgets
{ {
public static function initWidgets(WidgetsStack $w): void public static function initWidgets(WidgetsStack $w): void
@ -30,7 +26,7 @@ class Widgets
->create( ->create(
'lastblogupdate', 'lastblogupdate',
__('Last blog update'), __('Last blog update'),
[self::class, 'parseWidget'], self::parseWidget(...),
null, null,
'Show the dates of last updates of your blog in a widget' 'Show the dates of last updates of your blog in a widget'
) )
@ -109,9 +105,9 @@ class Widgets
); );
# --BEHAVIOR-- lastBlogUpdateWidgetInit # --BEHAVIOR-- lastBlogUpdateWidgetInit
dcCore::app()->callBehavior('lastBlogUpdateWidgetInit', $w); App::behavior()->callBehavior('lastBlogUpdateWidgetInit', $w);
$w->lastblogupdate $w->__get('lastblogupdate')
->addHomeOnly() ->addHomeOnly()
->addContentOnly() ->addContentOnly()
->addClass() ->addClass()
@ -120,30 +116,30 @@ class Widgets
public static function parseWidget(WidgetsElement $w): string public static function parseWidget(WidgetsElement $w): string
{ {
if ($w->offline || is_null(dcCore::app()->blog)) { if ($w->offline || !App::blog()->isDefined()) {
return ''; return '';
} }
# Nothing to display # 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_show && !$w->post_show && !$w->comment_show && !$w->media_show
|| !$w->blog_text && !$w->post_text && !$w->comment_text && !$w->media_text) { || !$w->blog_text && !$w->post_text && !$w->comment_text && !$w->media_text) {
return ''; return '';
} }
$blog = $post = $comment = $media = $addons = ''; $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 # 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)) : ''; $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); $blog = sprintf('<li>%s %s</li>', $title, $text);
} }
# Post # Post
if ($w->post_show && $w->post_text) { 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()) { if (!$rs->isEmpty()) {
$title = $w->post_title ? sprintf('<strong>%s</strong>', Html::escapeHTML($w->post_title)) : ''; $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); $text = Date::str($w->post_text, (int) strtotime(is_string($rs->f('post_upddt')) ? $rs->f('post_upddt') : ''), $tz);
@ -156,11 +152,11 @@ class Widgets
# Comment # Comment
if ($w->comment_show && $w->comment_text) { 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()) { if (!$rs->isEmpty()) {
$title = $w->comment_title ? sprintf('<strong>%s</strong>', Html::escapeHTML($w->comment_title)) : ''; $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); $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') : ''; $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); $comment = sprintf('<li>%s <a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text);
@ -169,9 +165,9 @@ class Widgets
# Media # Media
if ($w->media_show && $w->media_text) { 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(); $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') ->column('media_upddt')
->where('media_path = ' . $sql->quote(is_string($path) ? $path : '')) ->where('media_path = ' . $sql->quote(is_string($path) ? $path : ''))
->order('media_upddt DESC') ->order('media_upddt DESC')
@ -187,7 +183,7 @@ class Widgets
} }
# --BEHAVIOR-- lastBlogUpdateWidgetParse # --BEHAVIOR-- lastBlogUpdateWidgetParse
$addons = dcCore::app()->callBehavior('lastBlogUpdateWidgetParse', $w); $addons = App::behavior()->callBehavior('lastBlogUpdateWidgetParse', $w);
# Nothing to display # Nothing to display
if (!$blog && !$post && !$comment && !$media && !$addons) { if (!$blog && !$post && !$comment && !$media && !$addons) {