diff --git a/CHANGELOG.md b/CHANGELOG.md index ad421c7..9ccba34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +entryPhotoExifWidget 1.5 - 2023.10.14 +=========================================================== +* Require Dotclear 2.28 +* Require PHP 8.1 +* Upgrade to Dotclear 2.28 + entryPhotoExifWidget 1.4 - 2023.08.12 =========================================================== * Require Dotclear 2.27 diff --git a/README.md b/README.md index 3e1ba1e..e62b797 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,22 @@ # README -[![Release](https://img.shields.io/badge/release-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases) -[![Date](https://img.shields.io/badge/date-2023.08.12-c44d58.svg)](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/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.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases) +![Date](https://img.shields.io/badge/date-2023.10.14-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/entryPhotoExifWidget) [![License](https://img.shields.io/github/license/JcDenis/entryPhotoExifWidget)](https://git.dotclear.watch/JcDenis/arlequin/blob/master/LICENSE) -## WHAT IS ENRTYPHOTOEXIFWIDGET ? +## ABOUT -_entryPhotoExifWidget_ **Entry Photo Exif Widget** is a plugin for the open-source -web publishing software called Dotclear. +_entryPhotoExifWidget_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). -Show images exif of an entry in a widget. +> Show images exif of an entry in a widget. ## REQUIREMENTS -_entryPhotoExifWidget_ requires: - +* Dotclear 2.28 +* PHP 8.1+ * permissions to manage widgets -* Dotclear 2.27 -* PHP 7.4+ ## USAGE @@ -30,13 +27,14 @@ Add and configure _Photo Exif Widget_ 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/entryPhotoExifWidget) or [GitHub Page](https://github.com/JcDenis/entryPhotoExifWidget) -* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/entryPhotoExifWidget) -* Discuss and help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=48992) +* [License](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/src/branch/master/LICENSE) +* [Packages & details](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/entryPhotoExifWidget)) +* [Sources & contributions](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget) (or on [GitHub](https://github.com/JcDenis/entryPhotoExifWidget)) +* [Issues & security](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/issues) (or on [GitHub](https://github.com/JcDenis/entryPhotoExifWidget/issues)) +* [Discuss and help](https://forum.dotclear.org/viewtopic.php?id=48992) ## CONTRIBUTORS -* Jean-Christian Denis +* Jean-Christian Denis (author) You are welcome to contribute to this code. diff --git a/_define.php b/_define.php index eefd575..187569d 100644 --- a/_define.php +++ b/_define.php @@ -1,29 +1,26 @@ registerModule( 'Entry Photo EXIF Widget', 'Show images EXIF of an entry', 'Jean-Christian Denis and contibutors', - '1.4', + '1.5', [ - 'requires' => [['core', '2.27']], - 'permissions' => dcCore::app()->auth->makePermissions([ - dcAuth::PERMISSION_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', diff --git a/dcstore.xml b/dcstore.xml index 9d6bc5c..38549c7 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -2,11 +2,11 @@ Entry Photo EXIF Widget - 1.4 + 1.5 Jean-Christian Denis and contibutors Show images EXIF of an entry - https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases/download/v1.4/plugin-entryPhotoExifWidget.zip - 2.27 + https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases/download/v1.5/plugin-entryPhotoExifWidget.zip + 2.28 https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/src/branch/master/README.md https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/issues diff --git a/src/Backend.php b/src/Backend.php index cc88a8d..a08294c 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,22 +1,19 @@ addBehavior('initWidgets', [Widgets::class, 'initWidgets']); + App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); return true; } diff --git a/src/Frontend.php b/src/Frontend.php index 519c38d..3903252 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,22 +1,19 @@ addBehavior('initWidgets', [Widgets::class, 'initWidgets']); + App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); return true; } diff --git a/src/My.php b/src/My.php index 3de5979..7948d4a 100644 --- a/src/My.php +++ b/src/My.php @@ -1,21 +1,19 @@ blog)) { + if (!App::blog()->isDefined()) { return; } $categories_combo = ['-' => '', __('Uncategorized') => 'null']; - $categories = dcCore::app()->blog->getCategories(); + $categories = App::blog()->getCategories(); while ($categories->fetch()) { $categories_combo[Html::escapeHTML($categories->f('cat_title'))] = $categories->f('cat_id'); } @@ -52,7 +49,7 @@ class Widgets $w->create( 'epew', __('Entry Photo EXIF'), - [Widgets::class, 'renderWidget'], + self::renderWidget(...), null, __('Show images exif of an entry') ) @@ -169,33 +166,30 @@ class Widgets public static function renderWidget(WidgetsElement $w): string { // Widget is offline - if ($w->offline) { + if ($w->offline || !App::blog()->isDefined()) { return ''; } - // nullsafe - if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) { - return ''; - } + $ctx = App::frontend()->context(); // Not in post context - if (!dcCore::app()->ctx->exists('posts') || !dcCore::app()->ctx->__get('posts')->f('post_id')) { + if (!$ctx->exists('posts') || !$ctx->__get('posts')->f('post_id')) { return ''; } // Not supported post type - if (!in_array(dcCore::app()->ctx->__get('posts')->f('post_type'), self::$supported_post_type)) { + if (!in_array($ctx->__get('posts')->f('post_type'), self::$supported_post_type)) { return ''; } // Category limit - if ($w->category == 'null' && dcCore::app()->ctx->__get('posts')->f('cat_id') !== null - || $w->category != 'null' && $w->category != '' && $w->category != dcCore::app()->ctx->__get('posts')->f('cat_id')) { + if ($w->category == 'null' && $ctx->__get('posts')->f('cat_id') !== null + || $w->category != 'null' && $w->category != '' && $w->category != $ctx->__get('posts')->f('cat_id')) { return ''; } # Content lookup - $text = dcCore::app()->ctx->__get('posts')->f('post_excerpt_xhtml') . dcCore::app()->ctx->__get('posts')->f('post_content_xhtml'); + $text = $ctx->__get('posts')->f('post_excerpt_xhtml') . $ctx->__get('posts')->f('post_content_xhtml'); # Find source images $images = self::getImageSource($text, $w->thumbsize); @@ -246,14 +240,14 @@ class Widgets public static function getImageSource(string $subject, string $size = ''): array { - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined()) { return []; } # Path and url - $p_url = (string) dcCore::app()->blog->settings->get('system')->get('public_url'); - $p_site = (string) preg_replace('#^(.+?//.+?)/(.*)$#', '$1', dcCore::app()->blog->url); - $p_root = dcCore::app()->blog->public_path; + $p_url = (string) App::blog()->settings()->get('system')->get('public_url'); + $p_site = (string) preg_replace('#^(.+?//.+?)/(.*)$#', '$1', App::blog()->url()); + $p_root = App::blog()->publicPath(); # Image pattern $pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/'); @@ -324,7 +318,7 @@ class Widgets public static function getImageMeta(?string $src): array { - if (is_null(dcCore::app()->blog)) { + if (!App::blog()->isDefined()) { return []; } @@ -399,8 +393,8 @@ class Widgets # DateTimeOriginal if (!empty($m['DateTimeOriginal'])) { - $dt_ft = dcCore::app()->blog->settings->get('system')->get('date_format') . ', ' . dcCore::app()->blog->settings->get('system')->get('time_format'); - $dt_tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone'); + $dt_ft = App::blog()->settings()->get('system')->get('date_format') . ', ' . App::blog()->settings()->get('system')->get('time_format'); + $dt_tz = App::blog()->settings()->get('system')->get('blog_timezone'); $metas['DateTimeOriginal'][1] = Date::dt2str($dt_ft, $m['DateTimeOriginal'], $dt_tz); }