release 1.5

This commit is contained in:
Jean-Christian Denis 2023-10-14 10:24:38 +02:00
parent 8d2745457c
commit 53b730cf6c
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
8 changed files with 89 additions and 102 deletions

View file

@ -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 entryPhotoExifWidget 1.4 - 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-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases) [![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.08.12-c44d58.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.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/entryPhotoExifWidget) [![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) [![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 _entryPhotoExifWidget_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
web publishing software called Dotclear.
Show images exif of an entry in a widget. > Show images exif of an entry in a widget.
## REQUIREMENTS ## REQUIREMENTS
_entryPhotoExifWidget_ requires: * Dotclear 2.28
* PHP 8.1+
* permissions to manage widgets * permissions to manage widgets
* Dotclear 2.27
* PHP 7.4+
## USAGE ## USAGE
@ -30,13 +27,14 @@ Add and configure _Photo Exif Widget_ 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/entryPhotoExifWidget/src/branch/master/LICENSE)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget) or [GitHub Page](https://github.com/JcDenis/entryPhotoExifWidget) * [Packages & details](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/entryPhotoExifWidget))
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/entryPhotoExifWidget) * [Sources & contributions](https://git.dotclear.watch/JcDenis/entryPhotoExifWidget) (or on [GitHub](https://github.com/JcDenis/entryPhotoExifWidget))
* Discuss and help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=48992) * [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 ## CONTRIBUTORS
* Jean-Christian Denis * Jean-Christian Denis (author)
You are welcome to contribute to this code. You are welcome to contribute to this code.

View file

@ -1,29 +1,26 @@
<?php <?php
/** /**
* @brief entryPhotoExifWidget, a plugin for Dotclear 2 * @file
* @brief The plugin entryPhotoExifWidget definition
* @ingroup entryPhotoExifWidget
* *
* @package Dotclear * @defgroup entryPhotoExifWidget Plugin entryPhotoExifWidget.
* @subpackage Plugin
* *
* @author Jean-Christian Denis and contibutors * Show images EXIF of an entry.
* *
* @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')) { declare(strict_types=1);
return null;
}
$this->registerModule( $this->registerModule(
'Entry Photo EXIF Widget', 'Entry Photo EXIF Widget',
'Show images EXIF of an entry', 'Show images EXIF of an entry',
'Jean-Christian Denis and contibutors', 'Jean-Christian Denis and contibutors',
'1.4', '1.5',
[ [
'requires' => [['core', '2.27']], 'requires' => [['core', '2.28']],
'permissions' => dcCore::app()->auth->makePermissions([ 'permissions' => 'My',
dcAuth::PERMISSION_ADMIN,
]),
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', '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/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="entryPhotoExifWidget"> <module id="entryPhotoExifWidget">
<name>Entry Photo EXIF Widget</name> <name>Entry Photo EXIF Widget</name>
<version>1.4</version> <version>1.5</version>
<author>Jean-Christian Denis and contibutors</author> <author>Jean-Christian Denis and contibutors</author>
<desc>Show images EXIF of an entry</desc> <desc>Show images EXIF of an entry</desc>
<file>https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases/download/v1.4/plugin-entryPhotoExifWidget.zip</file> <file>https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases/download/v1.5/plugin-entryPhotoExifWidget.zip</file>
<da:dcmin>2.27</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/issues</da:support>
</module> </module>

View file

@ -1,22 +1,19 @@
<?php <?php
/**
* @brief entryPhotoExifWidget, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and contibutors
*
* @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\entryPhotoExifWidget; namespace Dotclear\Plugin\entryPhotoExifWidget;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief entryPhotoExifWidget backend class.
* @ingroup entryPhotoExifWidget
*
* @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,7 +27,7 @@ class Backend extends Process
return false; return false;
} }
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']); App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true; return true;
} }

View file

@ -1,22 +1,19 @@
<?php <?php
/**
* @brief entryPhotoExifWidget, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and contibutors
*
* @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\entryPhotoExifWidget; namespace Dotclear\Plugin\entryPhotoExifWidget;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief entryPhotoExifWidget frontend class.
* @ingroup entryPhotoExifWidget
*
* @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,7 +27,7 @@ class Frontend extends Process
return false; return false;
} }
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']); App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true; return true;
} }

View file

@ -1,21 +1,19 @@
<?php <?php
/**
* @brief entryPhotoExifWidget, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and contibutors
*
* @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\entryPhotoExifWidget; namespace Dotclear\Plugin\entryPhotoExifWidget;
use Dotclear\Module\MyPlugin; use Dotclear\Module\MyPlugin;
/**
* @brief entryPhotoExifWidget My helper.
* @ingroup entryPhotoExifWidget
*
* @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,20 +1,10 @@
<?php <?php
/**
* @brief entryPhotoExifWidget, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and contibutors
*
* @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\entryPhotoExifWidget; namespace Dotclear\Plugin\entryPhotoExifWidget;
use dcCore; use Dotclear\App;
use Dotclear\Helper\Date; use Dotclear\Helper\Date;
use Dotclear\Helper\File\Image\ImageMeta; use Dotclear\Helper\File\Image\ImageMeta;
use Dotclear\Helper\File\Path; use Dotclear\Helper\File\Path;
@ -22,6 +12,13 @@ use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsElement; use Dotclear\Plugin\widgets\WidgetsElement;
use Dotclear\Plugin\widgets\WidgetsStack; use Dotclear\Plugin\widgets\WidgetsStack;
/**
* @brief entryPhotoExifWidget widgets class.
* @ingroup entryPhotoExifWidget
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Widgets class Widgets
{ {
public static array $supported_post_type = ['post', 'page', 'gal', 'galitem']; public static array $supported_post_type = ['post', 'page', 'gal', 'galitem'];
@ -31,12 +28,12 @@ class Widgets
public static function initWidgets(WidgetsStack $w): void public static function initWidgets(WidgetsStack $w): void
{ {
if (is_null(dcCore::app()->blog)) { if (!App::blog()->isDefined()) {
return; return;
} }
$categories_combo = ['-' => '', __('Uncategorized') => 'null']; $categories_combo = ['-' => '', __('Uncategorized') => 'null'];
$categories = dcCore::app()->blog->getCategories(); $categories = App::blog()->getCategories();
while ($categories->fetch()) { while ($categories->fetch()) {
$categories_combo[Html::escapeHTML($categories->f('cat_title'))] = $categories->f('cat_id'); $categories_combo[Html::escapeHTML($categories->f('cat_title'))] = $categories->f('cat_id');
} }
@ -52,7 +49,7 @@ class Widgets
$w->create( $w->create(
'epew', 'epew',
__('Entry Photo EXIF'), __('Entry Photo EXIF'),
[Widgets::class, 'renderWidget'], self::renderWidget(...),
null, null,
__('Show images exif of an entry') __('Show images exif of an entry')
) )
@ -169,33 +166,30 @@ class Widgets
public static function renderWidget(WidgetsElement $w): string public static function renderWidget(WidgetsElement $w): string
{ {
// Widget is offline // Widget is offline
if ($w->offline) { if ($w->offline || !App::blog()->isDefined()) {
return ''; return '';
} }
// nullsafe $ctx = App::frontend()->context();
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
return '';
}
// Not in post 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 ''; return '';
} }
// Not supported post type // 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 ''; return '';
} }
// Category limit // Category limit
if ($w->category == 'null' && dcCore::app()->ctx->__get('posts')->f('cat_id') !== null if ($w->category == 'null' && $ctx->__get('posts')->f('cat_id') !== null
|| $w->category != 'null' && $w->category != '' && $w->category != dcCore::app()->ctx->__get('posts')->f('cat_id')) { || $w->category != 'null' && $w->category != '' && $w->category != $ctx->__get('posts')->f('cat_id')) {
return ''; return '';
} }
# Content lookup # 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 # Find source images
$images = self::getImageSource($text, $w->thumbsize); $images = self::getImageSource($text, $w->thumbsize);
@ -246,14 +240,14 @@ class Widgets
public static function getImageSource(string $subject, string $size = ''): array public static function getImageSource(string $subject, string $size = ''): array
{ {
if (is_null(dcCore::app()->blog)) { if (!App::blog()->isDefined()) {
return []; return [];
} }
# Path and url # Path and url
$p_url = (string) dcCore::app()->blog->settings->get('system')->get('public_url'); $p_url = (string) App::blog()->settings()->get('system')->get('public_url');
$p_site = (string) preg_replace('#^(.+?//.+?)/(.*)$#', '$1', dcCore::app()->blog->url); $p_site = (string) preg_replace('#^(.+?//.+?)/(.*)$#', '$1', App::blog()->url());
$p_root = dcCore::app()->blog->public_path; $p_root = App::blog()->publicPath();
# Image pattern # Image pattern
$pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/'); $pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/');
@ -324,7 +318,7 @@ class Widgets
public static function getImageMeta(?string $src): array public static function getImageMeta(?string $src): array
{ {
if (is_null(dcCore::app()->blog)) { if (!App::blog()->isDefined()) {
return []; return [];
} }
@ -399,8 +393,8 @@ class Widgets
# DateTimeOriginal # DateTimeOriginal
if (!empty($m['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_ft = App::blog()->settings()->get('system')->get('date_format') . ', ' . App::blog()->settings()->get('system')->get('time_format');
$dt_tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone'); $dt_tz = App::blog()->settings()->get('system')->get('blog_timezone');
$metas['DateTimeOriginal'][1] = Date::dt2str($dt_ft, $m['DateTimeOriginal'], $dt_tz); $metas['DateTimeOriginal'][1] = Date::dt2str($dt_ft, $m['DateTimeOriginal'], $dt_tz);
} }