diff --git a/CHANGELOG.md b/CHANGELOG.md index c2ba6a9..04e7057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index bfc414a..e4ec88e 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/_define.php b/_define.php index cfdfd0f..4836eb6 100644 --- a/_define.php +++ b/_define.php @@ -1,33 +1,28 @@ 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, - ]), - '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/dcstore.xml b/dcstore.xml index 438311c..ca76731 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Last blog update - 2023.08.12 + 2023.10.11 Jean-Christian Denis, Pierre Van Glabeke Show the dates of last updates of your blog in a widget - https://git.dotclear.watch/JcDenis/lastBlogUpdate/releases/download/v2023.08.12/plugin-lastBlogUpdate.zip - 2.27 + https://github.com/JcDenis/lastBlogUpdate/releases/download/v2023.10.11/plugin-lastBlogUpdate.zip + 2.28 https://git.dotclear.watch/JcDenis/lastBlogUpdate/src/branch/master/README.md https://git.dotclear.watch/JcDenis/lastBlogUpdate/issues diff --git a/src/Backend.php b/src/Backend.php index d661960..711c37b 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,22 +1,20 @@ addBehaviors([ + App::behavior()->addBehaviors([ 'initWidgets' => [Widgets::class, 'initWidgets'], ]); diff --git a/src/Frontend.php b/src/Frontend.php index 91b9cbc..2a25824 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,22 +1,20 @@ addBehaviors([ + App::behavior()->addBehaviors([ 'initWidgets' => [Widgets::class, 'initWidgets'], ]); diff --git a/src/My.php b/src/My.php index 37b12aa..b528749 100644 --- a/src/My.php +++ b/src/My.php @@ -1,21 +1,20 @@ 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('%s', 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('
  • %s %s
  • ', $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('%s', 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('%s', 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('
  • %s %s
  • ', $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) {