Compare commits

...

10 Commits

11 changed files with 306 additions and 250 deletions

View File

@ -1,5 +1,16 @@
dev
- fix PSR CS
1.3 - 2023.04.22
- require dotclear 2.26
- use latest dotclear namespace helper
- fix nullsafe warning
- fix static call on frontend and backend class
1.2 - 2023.03.12
- update to Dotclear 2.25
- use namespace
1.1 - 2022.11.20
- fix compatibility with Dotclear 2.24 (required)
- fix PSR and CS
- remove .lang.php file
- update readme file

View File

@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/entryPhotoExifWidget)](https://github.com/JcDenis/entryPhotoExifWidget/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/entryPhotoExifWidget)](https://github.com/JcDenis/entryPhotoExifWidget/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/entryPhotoExifWidget)](https://github.com/JcDenis/entryPhotoExifWidget/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.19-blue.svg)](https://fr.dotclear.org/download)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/entryPhotoExifWidget)
[![License](https://img.shields.io/github/license/JcDenis/entryPhotoExifWidget)](https://github.com/JcDenis/entryPhotoExifWidget/blob/master/LICENSE)
@ -19,7 +19,7 @@ Show images exif of an entry in a widget.
_entryPhotoExifWidget_ requires:
* permissions to manage widgets
* Dotclear 2.19
* Dotclear 2.26
## USAGE

View File

@ -1,17 +0,0 @@
<?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
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
require_once dirname(__FILE__) . '/_widgets.php';

View File

@ -15,16 +15,18 @@ if (!defined('DC_RC_PATH')) {
}
$this->registerModule(
'Entry Photo Exif Widget',
'Show images exif of an entry',
'Entry Photo EXIF Widget',
'Show images EXIF of an entry',
'Jean-Christian Denis and contibutors',
'1.0.4',
'1.3',
[
'requires' => [['core', '2.19']],
'permissions' => 'admin',
'requires' => [['core', '2.26']],
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
]),
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/entryPhotoExifWidget',
'details' => 'https://plugins.dotaddict.org/dc2/details/entryPhotoExifWidget',
'repository' => 'https://raw.githubusercontent.com/JcDenis/entryPhotoExifWidget/master/dcstore.xml'
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
]
);

View File

@ -1,17 +0,0 @@
<?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
*/
if (!defined('DC_RC_PATH')) {
return null;
}
require_once dirname(__FILE__) . '/_widgets.php';

View File

@ -1,10 +1,12 @@
<?xml version="1.0"?>
<modules xmlns:da="http://dotaddict.org/da/">
<module id="entryPhotoExifWidget">
<name>Entry Photo Exif Widget</name>
<version>1.0.3</version>
<name>Entry Photo EXIF Widget</name>
<version>1.3</version>
<author>Jean-Christian Denis and contibutors</author>
<desc>Show images exif of an entry</desc>
<file>https://github.com/JcDenis/entryPhotoExifWidget/releases/download/v1.0.3/plugin-entryPhotoExifWidget.zip</file>
<desc>Show images EXIF of an entry</desc>
<file>https://github.com/JcDenis/entryPhotoExifWidget/releases/download/v1.3/plugin-entryPhotoExifWidget.zip</file>
<da:dcmin>2.26</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/entryPhotoExifWidget</da:details>
<da:support>https://github.com/JcDenis/entryPhotoExifWidget</da:support>
</module>

View File

@ -0,0 +1,60 @@
<?php
/**
* @package Dotclear
*
* @copyright Olivier Meunier & Association Dotclear
* @copyright GPL-2.0-only
*/
#
# DOT NOT MODIFY THIS FILE !
#
use Dotclear\Helper\L10n;
L10n::$locales['Entry Photo EXIF'] = 'EXIF photo du billet';
L10n::$locales['Show images exif of an entry'] = 'Afficher les EXIF des images d\'un billet';
L10n::$locales['Show metadata: %s'] = 'Afficher les métadonnées de : %s';
L10n::$locales['Descritpion'] = 'Description';
L10n::$locales['Location'] = 'Lieu';
L10n::$locales['Manufacturer'] = 'Fabriquant';
L10n::$locales['Model'] = 'Modèle';
L10n::$locales['Lens'] = 'Objectif';
L10n::$locales['Exposure program'] = 'Program d\'exposition';
L10n::$locales['Exposure time'] = 'Temps d\'exposition';
L10n::$locales['Aperture'] = 'Ouverture';
L10n::$locales['Iso speed rating'] = 'ISO';
L10n::$locales['Focal lengh'] = 'Longueur de focale';
L10n::$locales['Exposure bias value'] = 'Décalage d\'exposition';
L10n::$locales['Metering mode'] = 'Mode de mesure';
L10n::$locales['Show empty metadata'] = 'Afficher les métadonées vides';
L10n::$locales['Category limit:'] = 'Limiter à une catégorie :';
L10n::$locales['Thumbnail size:'] = 'Taille de la miniature :';
L10n::$locales['Location:'] = 'Lieu :';
L10n::$locales['Manufacturer:'] = 'Fabricant :';
L10n::$locales['Model:'] = 'Modèle :';
L10n::$locales['Lens:'] = 'Objectif :';
L10n::$locales['Program:'] = 'Programme :';
L10n::$locales['Speed:'] = 'Vitesse :';
L10n::$locales['Aperture:'] = 'Ouverture :';
L10n::$locales['ISO:'] = 'ISO :';
L10n::$locales['Focal:'] = 'Focale :';
L10n::$locales['Exposure Bias:'] = 'Décalage d\'exposition :';
L10n::$locales['Metering mode:'] = 'Mode de mesure :';
L10n::$locales['Not defined'] = 'Non défini';
L10n::$locales['Manual'] = 'Manuel';
L10n::$locales['Normal program'] = 'Normal';
L10n::$locales['Aperture priority'] = 'Priorité à l\'ouverture';
L10n::$locales['Shutter priority'] = 'Priorité à la vitesse';
L10n::$locales['Creative program'] = 'Création';
L10n::$locales['Action program'] = 'Action';
L10n::$locales['Portait mode'] = 'Portrait';
L10n::$locales['Landscape mode'] = 'Paysage';
L10n::$locales['Unknow'] = 'Inconnu';
L10n::$locales['Average'] = 'Moyenne';
L10n::$locales['Center-weighted average'] = 'Centrale pondèrée';
L10n::$locales['Spot'] = 'Spot';
L10n::$locales['Multi spot'] = 'Multi spot';
L10n::$locales['Pattern'] = 'Multizone';
L10n::$locales['Partial'] = 'Partielle';
L10n::$locales['Show images EXIF of an entry in a widget'] = 'Affiche dans un widget les informations EXIF des photos d\'un billet';
L10n::$locales['Entry Photo EXIF Widget'] = 'Widget des EXIF de photo d\'un billet';

View File

@ -1,209 +1,153 @@
# Language: Français
# Module: entryPhotoExifWidget - 1.0
# Date: 2016-11-04 09:16:46
# Translated with translater 2063.10.22
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: entryPhotoExifWidget 1.0\n"
"Project-Id-Version: entryPhotoExifWidget 1.2\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2016-11-04T09:16:46+00:00\n"
"PO-Revision-Date: 2023-03-12T09:36:16+00:00\n"
"Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: _widgets.php:54
msgid "Entry Photo Exif"
msgid "Entry Photo EXIF"
msgstr "EXIF photo du billet"
#: _widgets.php:57
msgid "Show images exif of an entry"
msgstr "Afficher les EXIF des images d'un billet"
#: _widgets.php:68
#: _widgets.php:74
#: _widgets.php:80
#: _widgets.php:86
#: _widgets.php:92
#: _widgets.php:98
#: _widgets.php:104
#: _widgets.php:110
#: _widgets.php:116
#: _widgets.php:122
#: _widgets.php:128
#: _widgets.php:134
#: _widgets.php:140
#: _widgets.php:146
msgid "Show metadata: %s"
msgstr "Afficher les métadonnées de : %s"
#: _widgets.php:74
msgid "Descritpion"
msgstr "Description"
#: _widgets.php:80
msgid "Location"
msgstr "Lieu"
#: _widgets.php:92
msgid "Manufacturer"
msgstr "Fabriquant"
#: _widgets.php:98
msgid "Model"
msgstr "Modèle"
#: _widgets.php:104
msgid "Lens"
msgstr "Objectif"
#: _widgets.php:110
msgid "Exposure program"
msgstr "Program d'exposition"
#: _widgets.php:116
msgid "Exposure time"
msgstr "Temps d'exposition"
#: _widgets.php:122
msgid "Aperture"
msgstr "Ouverture"
#: _widgets.php:128
msgid "Iso speed rating"
msgstr "ISO"
#: _widgets.php:134
msgid "Focal lengh"
msgstr "Longueur de focale"
#: _widgets.php:140
msgid "Exposure bias value"
msgstr "Décalage d'exposition"
#: _widgets.php:146
msgid "Metering mode"
msgstr "Mode de mesure"
#: _widgets.php:152
msgid "Show empty metadata"
msgstr "Afficher les métadonées vides"
#: _widgets.php:158
msgid "Category limit:"
msgstr "Limiter à une catégorie :"
#: _widgets.php:165
msgid "Thumbnail size:"
msgstr "Taille de la miniature :"
#: _widgets.php:367
msgid "Location:"
msgstr "Lieu :"
#: _widgets.php:369
msgid "Manufacturer:"
msgstr "Fabricant :"
#: _widgets.php:370
msgid "Model:"
msgstr "Modèle :"
#: _widgets.php:371
msgid "Lens:"
msgstr "Objectif :"
#: _widgets.php:372
msgid "Program:"
msgstr "Programme :"
#: _widgets.php:373
msgid "Speed:"
msgstr "Vitesse :"
#: _widgets.php:374
msgid "Aperture:"
msgstr "Ouverture :"
#: _widgets.php:375
msgid "ISO:"
msgstr "ISO :"
#: _widgets.php:376
msgid "Focal:"
msgstr "Focale :"
#: _widgets.php:377
msgid "Exposure Bias:"
msgstr "Décalage d'exposition :"
#: _widgets.php:378
msgid "Metering mode:"
msgstr "Mode de mesure :"
#: _widgets.php:382
msgid "Not defined"
msgstr "Non défini"
#: _widgets.php:383
msgid "Manual"
msgstr "Manuel"
#: _widgets.php:384
msgid "Normal program"
msgstr "Normal"
#: _widgets.php:385
msgid "Aperture priority"
msgstr "Priorité à l'ouverture"
#: _widgets.php:386
msgid "Shutter priority"
msgstr "Priorité à la vitesse"
#: _widgets.php:387
msgid "Creative program"
msgstr "Création"
#: _widgets.php:388
msgid "Action program"
msgstr "Action"
#: _widgets.php:389
msgid "Portait mode"
msgstr "Portrait"
#: _widgets.php:390
msgid "Landscape mode"
msgstr "Paysage"
#: _widgets.php:394
msgid "Unknow"
msgstr "Inconnu"
#: _widgets.php:395
msgid "Average"
msgstr "Moyenne"
#: _widgets.php:396
msgid "Center-weighted average"
msgstr "Centrale pondèrée"
#: _widgets.php:397
msgid "Spot"
msgstr "Spot"
#: _widgets.php:398
msgid "Multi spot"
msgstr "Multi spot"
#: _widgets.php:399
msgid "Pattern"
msgstr "Multizone"
#: _widgets.php:400
msgid "Partial"
msgstr "Partielle"
msgid "Show images EXIF of an entry in a widget"
msgstr "Affiche dans un widget les informations EXIF des photos d'un billet"
msgid "Entry Photo EXIF Widget"
msgstr "Widget des EXIF de photo d'un billet"

39
src/Backend.php 100644
View File

@ -0,0 +1,39 @@
<?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 dcNsProcess;
class Backend extends dcNsProcess
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN');
return static::$init;
}
public static function process(): bool
{
if (!static::$init) {
return false;
}
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
return true;
}
}

39
src/Frontend.php 100644
View File

@ -0,0 +1,39 @@
<?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 dcNsProcess;
class Frontend extends dcNsProcess
{
public static function init(): bool
{
static::$init = defined('DC_RC_PATH');
return static::$init;
}
public static function process(): bool
{
if (!static::$init) {
return false;
}
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
return true;
}
}

View File

@ -10,28 +10,35 @@
* @copyright 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);
namespace Dotclear\Plugin\entryPhotoExifWidget;
use dcCore;
use Dotclear\Helper\Date;
use Dotclear\Helper\File\Image\ImageMeta;
use Dotclear\Helper\File\Path;
use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsElement;
use Dotclear\Plugin\widgets\WidgetsStack;
class Widgets
{
public static array $supported_post_type = ['post', 'page', 'gal', 'galitem'];
public static string $widget_content = '<ul>%s</ul>';
public static string $widget_text = '<li class="epew-%s"><strong>%s</strong> %s</li>';
public static string $widget_thumb = '<li><img class="img-thumbnail" alt="%s" src="%s" /></li>';
public static function initWidgets(WidgetsStack $w): void
{
if (is_null(dcCore::app()->blog)) {
return;
}
$core->addBehavior('initWidgets', ['entryPhotoExifWidget', 'setWidget']);
class entryPhotoExifWidget
{
public static $supported_post_type = ['post', 'page', 'gal', 'galitem'];
public static $widget_content = '<ul>%s</ul>';
public static $widget_text = '<li class="epew-%s"><strong>%s</strong> %s</li>';
public static $widget_thumb = '<li><img class="img-thumbnail" alt="%s" src="%s" /></li>';
public static function setWidget($w)
{
global $core;
$categories_combo = ['-' => '', __('Uncategorized') => 'null'];
$categories = $core->blog->getCategories();
$categories = dcCore::app()->blog->getCategories();
while ($categories->fetch()) {
$cat_title = html::escapeHTML($categories->cat_title);
$categories_combo[$cat_title] = $categories->cat_id;
$categories_combo[Html::escapeHTML($categories->f('cat_title'))] = $categories->f('cat_id');
}
$thumbnail_combo = [
@ -39,180 +46,163 @@ class entryPhotoExifWidget
__('square') => 'sq',
__('thumbnail') => 't',
__('small') => 's',
__('medium') => 'm'
__('medium') => 'm',
];
$w->create(
'epew',
__('Entry Photo Exif'),
['entryPhotoExifWidget', 'getWidget'],
__('Entry Photo EXIF'),
[Widgets::class, 'renderWidget'],
null,
__('Show images exif of an entry')
);
$w->epew->setting(
'title',
__('Title:'),
__('Photos EXIF'),
'text'
);
$w->epew->setting(
)
->addTitle(__('Photos EXIF'))
->setting(
'showmeta_Title',
sprintf(__('Show metadata: %s'), __('Title')),
0,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_Description',
sprintf(__('Show metadata: %s'), __('Descritpion')),
0,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_Location',
sprintf(__('Show metadata: %s'), __('Location')),
0,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_DateTimeOriginal',
sprintf(__('Show metadata: %s'), __('Date')),
0,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_Make',
sprintf(__('Show metadata: %s'), __('Manufacturer')),
0,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_Model',
sprintf(__('Show metadata: %s'), __('Model')),
1,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_Lens',
sprintf(__('Show metadata: %s'), __('Lens')),
1,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_ExposureProgram',
sprintf(__('Show metadata: %s'), __('Exposure program')),
0,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_Exposure',
sprintf(__('Show metadata: %s'), __('Exposure time')),
1,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_FNumber',
sprintf(__('Show metadata: %s'), __('Aperture')),
1,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_ISOSpeedRatings',
sprintf(__('Show metadata: %s'), __('Iso speed rating')),
1,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_FocalLength',
sprintf(__('Show metadata: %s'), __('Focal lengh')),
1,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_ExposureBiasValue',
sprintf(__('Show metadata: %s'), __('Exposure bias value')),
0,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta_MeteringMode',
sprintf(__('Show metadata: %s'), __('Metering mode')),
0,
'check'
);
$w->epew->setting(
)
->setting(
'showmeta',
__('Show empty metadata'),
0,
'check'
);
$w->epew->setting(
)
->setting(
'category',
__('Category limit:'),
'',
'combo',
$categories_combo
);
$w->epew->setting(
)
->setting(
'thumbsize',
__('Thumbnail size:'),
't',
'combo',
$thumbnail_combo
);
$w->epew->setting(
'content_only',
__('Content only'),
0,
'check'
);
$w->epew->setting(
'class',
__('CSS class:'),
''
);
$w->epew->setting(
'offline',
__('Offline'),
0,
'check'
);
)
->addContentOnly()
->addClass()
->addOffline();
}
public static function getWidget($w)
public static function renderWidget(WidgetsElement $w): string
{
global $core, $_ctx;
# Widget is offline
// Widget is offline
if ($w->offline) {
return null;
return '';
}
# Not in post context
if (!$_ctx->exists('posts') || !$_ctx->posts->post_id) {
return null;
// nullsafe
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
return '';
}
# Not supported post type
if (!in_array($_ctx->posts->post_type, self::$supported_post_type)) {
return null;
// Not in post context
if (!dcCore::app()->ctx->exists('posts') || !dcCore::app()->ctx->__get('posts')->f('post_id')) {
return '';
}
# Category limit
if ($w->category == 'null' && $_ctx->posts->cat_id !== null
|| $w->category != 'null' && $w->category != '' && $w->category != $_ctx->posts->cat_id) {
return null;
// Not supported post type
if (!in_array(dcCore::app()->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')) {
return '';
}
# Content lookup
$text = $_ctx->posts->post_excerpt_xhtml . $_ctx->posts->post_content_xhtml;
$text = dcCore::app()->ctx->__get('posts')->f('post_excerpt_xhtml') . dcCore::app()->ctx->__get('posts')->f('post_content_xhtml');
# Find source images
$images = self::getImageSource($core, $text, $w->thumbsize);
$images = self::getImageSource($text, $w->thumbsize);
# No images
if (empty($images)) {
return null;
return '';
}
$contents = '';
@ -220,7 +210,7 @@ class entryPhotoExifWidget
# Loop through images
foreach ($images as $img) {
# List metas
$metas = self::getImageMeta($core, $img['source']);
$metas = self::getImageMeta($img['source']);
$content = '';
foreach ($metas as $k => $v) {
@ -233,7 +223,7 @@ class entryPhotoExifWidget
# No meta
if (empty($content)) {
return null;
return '';
}
# Thumbnail
@ -244,27 +234,26 @@ class entryPhotoExifWidget
$contents .= $content;
}
# Nothing found
if (empty($contents)) {
return null;
}
# Paste widget
return $w->renderDiv(
$w->content_only,
(bool) $w->content_only,
'photoExifWidget ' . $w->class,
'',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
sprintf(self::$widget_content, $contents)
);
}
public static function getImageSource($core, $subject, $size = '')
public static function getImageSource(string $subject, string $size = ''): array
{
if (is_null(dcCore::app()->blog)) {
return [];
}
# Path and url
$p_url = $core->blog->settings->system->public_url;
$p_site = preg_replace('#^(.+?//.+?)/(.*)$#', '$1', $core->blog->url);
$p_root = $core->blog->public_path;
$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;
# Image pattern
$pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/');
@ -272,7 +261,7 @@ class entryPhotoExifWidget
# No image
if (!preg_match_all($pattern, $subject, $m)) {
return;
return [];
}
$res = $duplicate = [];
@ -281,7 +270,7 @@ class entryPhotoExifWidget
# Loop through images
foreach ($m[1] as $i => $img) {
$src = $thb = $alt = false;
$info = path::info($img);
$info = Path::info($img);
$base = $info['base'];
$ext = $info['extension'];
@ -326,15 +315,19 @@ class entryPhotoExifWidget
$res[] = [
'source' => $src,
'thumb' => $thb,
'title' => $alt
'title' => $alt,
];
}
return $res;
}
public static function getImageMeta($core, $src)
public static function getImageMeta(?string $src): array
{
if (is_null(dcCore::app()->blog)) {
return [];
}
$metas = [
'Title' => [__('Title:'), ''],
'Description' => [__('Description:'), ''],
@ -349,7 +342,7 @@ class entryPhotoExifWidget
'ISOSpeedRatings' => [__('ISO:'), ''],
'FocalLength' => [__('Focal:'), ''],
'ExposureBiasValue' => [__('Exposure Bias:'), ''],
'MeteringMode' => [__('Metering mode:'), '']
'MeteringMode' => [__('Metering mode:'), ''],
];
$exp_prog = [
@ -361,7 +354,7 @@ class entryPhotoExifWidget
5 => __('Creative program'),
6 => __('Action program'),
7 => __('Portait mode'),
8 => __('Landscape mode')
8 => __('Landscape mode'),
];
$met_mod = [
@ -372,58 +365,58 @@ class entryPhotoExifWidget
4 => __('Multi spot'),
5 => __('Pattern'),
6 => __('Partial'),
7 => __('Other')
7 => __('Other'),
];
if (!$src || !file_exists($src)) {
return $metas;
}
$m = imageMeta::readMeta($src);
$m = ImageMeta::readMeta($src);
# Title
if (!empty($m['Title'])) {
$metas['Title'][1] = html::escapeHTML($m['Title']);
$metas['Title'][1] = Html::escapeHTML($m['Title']);
}
# Description
if (!empty($m['Description'])) {
if (!empty($m['Title']) && $m['Title'] != $m['Description']) {
$metas['Description'][1] = html::escpeHTML($m['Description']);
$metas['Description'][1] = Html::escapeHTML($m['Description']);
}
}
# Location
if (!empty($m['City'])) {
$metas['Location'][1] .= html::escapeHTML($m['City']);
$metas['Location'][1] .= Html::escapeHTML($m['City']);
}
if (!empty($m['City']) && !empty($m['country'])) {
$metas['Location'][1] .= ', ';
}
if (!empty($m['country'])) {
$metas['Location'][1] .= html::escapeHTML($m['Country']);
$metas['Location'][1] .= Html::escapeHTML($m['Country']);
}
# DateTimeOriginal
if (!empty($m['DateTimeOriginal'])) {
$dt_ft = $core->blog->settings->system->date_format . ', ' . $core->blog->settings->system->time_format;
$dt_tz = $core->blog->settings->system->blog_timezone;
$metas['DateTimeOriginal'][1] = dt::dt2str($dt_ft, $m['DateTimeOriginal'], $dt_tz);
$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');
$metas['DateTimeOriginal'][1] = Date::dt2str($dt_ft, $m['DateTimeOriginal'], $dt_tz);
}
# Make
if (isset($m['Make'])) {
$metas['Make'][1] = html::escapeHTML($m['Make']);
$metas['Make'][1] = Html::escapeHTML($m['Make']);
}
# Model
if (isset($m['Model'])) {
$metas['Model'][1] = html::escapeHTML($m['Model']);
$metas['Model'][1] = Html::escapeHTML($m['Model']);
}
# Lens
if (isset($m['Lens'])) {
$metas['Lens'][1] = html::escapeHTML($m['Lens']);
$metas['Lens'][1] = Html::escapeHTML($m['Lens']);
}
# ExposureProgram