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
===========================================================
* Require Dotclear 2.27

View file

@ -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.

View file

@ -1,29 +1,26 @@
<?php
/**
* @brief entryPhotoExifWidget, a plugin for Dotclear 2
* @file
* @brief The plugin entryPhotoExifWidget definition
* @ingroup entryPhotoExifWidget
*
* @package Dotclear
* @subpackage Plugin
* @defgroup entryPhotoExifWidget Plugin entryPhotoExifWidget.
*
* @author Jean-Christian Denis and contibutors
* Show images EXIF of an entry.
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
declare(strict_types=1);
$this->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',

View file

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="entryPhotoExifWidget">
<name>Entry Photo EXIF Widget</name>
<version>1.4</version>
<version>1.5</version>
<author>Jean-Christian Denis and contibutors</author>
<desc>Show images EXIF of an entry</desc>
<file>https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases/download/v1.4/plugin-entryPhotoExifWidget.zip</file>
<da:dcmin>2.27</da:dcmin>
<file>https://git.dotclear.watch/JcDenis/entryPhotoExifWidget/releases/download/v1.5/plugin-entryPhotoExifWidget.zip</file>
<da:dcmin>2.28</da:dcmin>
<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>
</module>

View file

@ -1,22 +1,19 @@
<?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);
namespace Dotclear\Plugin\entryPhotoExifWidget;
use dcCore;
use Dotclear\App;
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
{
public static function init(): bool
@ -30,7 +27,7 @@ class Backend extends Process
return false;
}
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true;
}

View file

@ -1,22 +1,19 @@
<?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);
namespace Dotclear\Plugin\entryPhotoExifWidget;
use dcCore;
use Dotclear\App;
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
{
public static function init(): bool
@ -30,7 +27,7 @@ class Frontend extends Process
return false;
}
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true;
}

View file

@ -1,21 +1,19 @@
<?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);
namespace Dotclear\Plugin\entryPhotoExifWidget;
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
{
// Use default permissions
}

View file

@ -1,20 +1,10 @@
<?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);
namespace Dotclear\Plugin\entryPhotoExifWidget;
use dcCore;
use Dotclear\App;
use Dotclear\Helper\Date;
use Dotclear\Helper\File\Image\ImageMeta;
use Dotclear\Helper\File\Path;
@ -22,6 +12,13 @@ use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsElement;
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
{
public static array $supported_post_type = ['post', 'page', 'gal', 'galitem'];
@ -31,12 +28,12 @@ class Widgets
public static function initWidgets(WidgetsStack $w): void
{
if (is_null(dcCore::app()->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);
}