Compare commits

...

10 Commits

11 changed files with 306 additions and 250 deletions

View File

@ -1,5 +1,16 @@
dev 1.3 - 2023.04.22
- fix PSR CS - 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 - remove .lang.php file
- update readme 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) [![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) [![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) [![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) [![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) [![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: _entryPhotoExifWidget_ requires:
* permissions to manage widgets * permissions to manage widgets
* Dotclear 2.19 * Dotclear 2.26
## USAGE ## 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( $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.0.4', '1.3',
[ [
'requires' => [['core', '2.19']], 'requires' => [['core', '2.26']],
'permissions' => 'admin', 'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
]),
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://github.com/JcDenis/entryPhotoExifWidget', 'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'https://plugins.dotaddict.org/dc2/details/entryPhotoExifWidget', 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubusercontent.com/JcDenis/entryPhotoExifWidget/master/dcstore.xml' '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,11 +1,13 @@
<?xml version="1.0"?>
<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.0.3</version> <version>1.3</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://github.com/JcDenis/entryPhotoExifWidget/releases/download/v1.0.3/plugin-entryPhotoExifWidget.zip</file> <file>https://github.com/JcDenis/entryPhotoExifWidget/releases/download/v1.3/plugin-entryPhotoExifWidget.zip</file>
<da:details>https://plugins.dotaddict.org/dc2/details/entryPhotoExifWidget</da:details> <da:dcmin>2.26</da:dcmin>
<da:support>https://github.com/JcDenis/entryPhotoExifWidget</da:support> <da:details>https://plugins.dotaddict.org/dc2/details/entryPhotoExifWidget</da:details>
</module> <da:support>https://github.com/JcDenis/entryPhotoExifWidget</da:support>
</module>
</modules> </modules>

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 "" msgid ""
msgstr "" msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "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" "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" "Last-Translator: Jean-Christian Denis\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\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" msgstr "EXIF photo du billet"
#: _widgets.php:57
msgid "Show images exif of an entry" msgid "Show images exif of an entry"
msgstr "Afficher les EXIF des images d'un billet" 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" msgid "Show metadata: %s"
msgstr "Afficher les métadonnées de : %s" msgstr "Afficher les métadonnées de : %s"
#: _widgets.php:74
msgid "Descritpion" msgid "Descritpion"
msgstr "Description" msgstr "Description"
#: _widgets.php:80
msgid "Location" msgid "Location"
msgstr "Lieu" msgstr "Lieu"
#: _widgets.php:92
msgid "Manufacturer" msgid "Manufacturer"
msgstr "Fabriquant" msgstr "Fabriquant"
#: _widgets.php:98
msgid "Model" msgid "Model"
msgstr "Modèle" msgstr "Modèle"
#: _widgets.php:104
msgid "Lens" msgid "Lens"
msgstr "Objectif" msgstr "Objectif"
#: _widgets.php:110
msgid "Exposure program" msgid "Exposure program"
msgstr "Program d'exposition" msgstr "Program d'exposition"
#: _widgets.php:116
msgid "Exposure time" msgid "Exposure time"
msgstr "Temps d'exposition" msgstr "Temps d'exposition"
#: _widgets.php:122
msgid "Aperture" msgid "Aperture"
msgstr "Ouverture" msgstr "Ouverture"
#: _widgets.php:128
msgid "Iso speed rating" msgid "Iso speed rating"
msgstr "ISO" msgstr "ISO"
#: _widgets.php:134
msgid "Focal lengh" msgid "Focal lengh"
msgstr "Longueur de focale" msgstr "Longueur de focale"
#: _widgets.php:140
msgid "Exposure bias value" msgid "Exposure bias value"
msgstr "Décalage d'exposition" msgstr "Décalage d'exposition"
#: _widgets.php:146
msgid "Metering mode" msgid "Metering mode"
msgstr "Mode de mesure" msgstr "Mode de mesure"
#: _widgets.php:152
msgid "Show empty metadata" msgid "Show empty metadata"
msgstr "Afficher les métadonées vides" msgstr "Afficher les métadonées vides"
#: _widgets.php:158
msgid "Category limit:" msgid "Category limit:"
msgstr "Limiter à une catégorie :" msgstr "Limiter à une catégorie :"
#: _widgets.php:165
msgid "Thumbnail size:" msgid "Thumbnail size:"
msgstr "Taille de la miniature :" msgstr "Taille de la miniature :"
#: _widgets.php:367
msgid "Location:" msgid "Location:"
msgstr "Lieu :" msgstr "Lieu :"
#: _widgets.php:369
msgid "Manufacturer:" msgid "Manufacturer:"
msgstr "Fabricant :" msgstr "Fabricant :"
#: _widgets.php:370
msgid "Model:" msgid "Model:"
msgstr "Modèle :" msgstr "Modèle :"
#: _widgets.php:371
msgid "Lens:" msgid "Lens:"
msgstr "Objectif :" msgstr "Objectif :"
#: _widgets.php:372
msgid "Program:" msgid "Program:"
msgstr "Programme :" msgstr "Programme :"
#: _widgets.php:373
msgid "Speed:" msgid "Speed:"
msgstr "Vitesse :" msgstr "Vitesse :"
#: _widgets.php:374
msgid "Aperture:" msgid "Aperture:"
msgstr "Ouverture :" msgstr "Ouverture :"
#: _widgets.php:375
msgid "ISO:" msgid "ISO:"
msgstr "ISO :" msgstr "ISO :"
#: _widgets.php:376
msgid "Focal:" msgid "Focal:"
msgstr "Focale :" msgstr "Focale :"
#: _widgets.php:377
msgid "Exposure Bias:" msgid "Exposure Bias:"
msgstr "Décalage d'exposition :" msgstr "Décalage d'exposition :"
#: _widgets.php:378
msgid "Metering mode:" msgid "Metering mode:"
msgstr "Mode de mesure :" msgstr "Mode de mesure :"
#: _widgets.php:382
msgid "Not defined" msgid "Not defined"
msgstr "Non défini" msgstr "Non défini"
#: _widgets.php:383
msgid "Manual" msgid "Manual"
msgstr "Manuel" msgstr "Manuel"
#: _widgets.php:384
msgid "Normal program" msgid "Normal program"
msgstr "Normal" msgstr "Normal"
#: _widgets.php:385
msgid "Aperture priority" msgid "Aperture priority"
msgstr "Priorité à l'ouverture" msgstr "Priorité à l'ouverture"
#: _widgets.php:386
msgid "Shutter priority" msgid "Shutter priority"
msgstr "Priorité à la vitesse" msgstr "Priorité à la vitesse"
#: _widgets.php:387
msgid "Creative program" msgid "Creative program"
msgstr "Création" msgstr "Création"
#: _widgets.php:388
msgid "Action program" msgid "Action program"
msgstr "Action" msgstr "Action"
#: _widgets.php:389
msgid "Portait mode" msgid "Portait mode"
msgstr "Portrait" msgstr "Portrait"
#: _widgets.php:390
msgid "Landscape mode" msgid "Landscape mode"
msgstr "Paysage" msgstr "Paysage"
#: _widgets.php:394
msgid "Unknow" msgid "Unknow"
msgstr "Inconnu" msgstr "Inconnu"
#: _widgets.php:395
msgid "Average" msgid "Average"
msgstr "Moyenne" msgstr "Moyenne"
#: _widgets.php:396
msgid "Center-weighted average" msgid "Center-weighted average"
msgstr "Centrale pondèrée" msgstr "Centrale pondèrée"
#: _widgets.php:397
msgid "Spot" msgid "Spot"
msgstr "Spot" msgstr "Spot"
#: _widgets.php:398
msgid "Multi spot" msgid "Multi spot"
msgstr "Multi spot" msgstr "Multi spot"
#: _widgets.php:399
msgid "Pattern" msgid "Pattern"
msgstr "Multizone" msgstr "Multizone"
#: _widgets.php:400
msgid "Partial" msgid "Partial"
msgstr "Partielle" 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 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;
}
$core->addBehavior('initWidgets', ['entryPhotoExifWidget', 'setWidget']); namespace Dotclear\Plugin\entryPhotoExifWidget;
class 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 $supported_post_type = ['post', 'page', 'gal', 'galitem']; public static array $supported_post_type = ['post', 'page', 'gal', 'galitem'];
public static $widget_content = '<ul>%s</ul>'; public static string $widget_content = '<ul>%s</ul>';
public static $widget_text = '<li class="epew-%s"><strong>%s</strong> %s</li>'; public static string $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 string $widget_thumb = '<li><img class="img-thumbnail" alt="%s" src="%s" /></li>';
public static function setWidget($w) public static function initWidgets(WidgetsStack $w): void
{ {
global $core; if (is_null(dcCore::app()->blog)) {
return;
}
$categories_combo = ['-' => '', __('Uncategorized') => 'null']; $categories_combo = ['-' => '', __('Uncategorized') => 'null'];
$categories = $core->blog->getCategories(); $categories = dcCore::app()->blog->getCategories();
while ($categories->fetch()) { while ($categories->fetch()) {
$cat_title = html::escapeHTML($categories->cat_title); $categories_combo[Html::escapeHTML($categories->f('cat_title'))] = $categories->f('cat_id');
$categories_combo[$cat_title] = $categories->cat_id;
} }
$thumbnail_combo = [ $thumbnail_combo = [
@ -39,180 +46,163 @@ class entryPhotoExifWidget
__('square') => 'sq', __('square') => 'sq',
__('thumbnail') => 't', __('thumbnail') => 't',
__('small') => 's', __('small') => 's',
__('medium') => 'm' __('medium') => 'm',
]; ];
$w->create( $w->create(
'epew', 'epew',
__('Entry Photo Exif'), __('Entry Photo EXIF'),
['entryPhotoExifWidget', 'getWidget'], [Widgets::class, 'renderWidget'],
null, null,
__('Show images exif of an entry') __('Show images exif of an entry')
); )
->addTitle(__('Photos EXIF'))
$w->epew->setting( ->setting(
'title',
__('Title:'),
__('Photos EXIF'),
'text'
);
$w->epew->setting(
'showmeta_Title', 'showmeta_Title',
sprintf(__('Show metadata: %s'), __('Title')), sprintf(__('Show metadata: %s'), __('Title')),
0, 0,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_Description', 'showmeta_Description',
sprintf(__('Show metadata: %s'), __('Descritpion')), sprintf(__('Show metadata: %s'), __('Descritpion')),
0, 0,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_Location', 'showmeta_Location',
sprintf(__('Show metadata: %s'), __('Location')), sprintf(__('Show metadata: %s'), __('Location')),
0, 0,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_DateTimeOriginal', 'showmeta_DateTimeOriginal',
sprintf(__('Show metadata: %s'), __('Date')), sprintf(__('Show metadata: %s'), __('Date')),
0, 0,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_Make', 'showmeta_Make',
sprintf(__('Show metadata: %s'), __('Manufacturer')), sprintf(__('Show metadata: %s'), __('Manufacturer')),
0, 0,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_Model', 'showmeta_Model',
sprintf(__('Show metadata: %s'), __('Model')), sprintf(__('Show metadata: %s'), __('Model')),
1, 1,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_Lens', 'showmeta_Lens',
sprintf(__('Show metadata: %s'), __('Lens')), sprintf(__('Show metadata: %s'), __('Lens')),
1, 1,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_ExposureProgram', 'showmeta_ExposureProgram',
sprintf(__('Show metadata: %s'), __('Exposure program')), sprintf(__('Show metadata: %s'), __('Exposure program')),
0, 0,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_Exposure', 'showmeta_Exposure',
sprintf(__('Show metadata: %s'), __('Exposure time')), sprintf(__('Show metadata: %s'), __('Exposure time')),
1, 1,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_FNumber', 'showmeta_FNumber',
sprintf(__('Show metadata: %s'), __('Aperture')), sprintf(__('Show metadata: %s'), __('Aperture')),
1, 1,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_ISOSpeedRatings', 'showmeta_ISOSpeedRatings',
sprintf(__('Show metadata: %s'), __('Iso speed rating')), sprintf(__('Show metadata: %s'), __('Iso speed rating')),
1, 1,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_FocalLength', 'showmeta_FocalLength',
sprintf(__('Show metadata: %s'), __('Focal lengh')), sprintf(__('Show metadata: %s'), __('Focal lengh')),
1, 1,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_ExposureBiasValue', 'showmeta_ExposureBiasValue',
sprintf(__('Show metadata: %s'), __('Exposure bias value')), sprintf(__('Show metadata: %s'), __('Exposure bias value')),
0, 0,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta_MeteringMode', 'showmeta_MeteringMode',
sprintf(__('Show metadata: %s'), __('Metering mode')), sprintf(__('Show metadata: %s'), __('Metering mode')),
0, 0,
'check' 'check'
); )
$w->epew->setting( ->setting(
'showmeta', 'showmeta',
__('Show empty metadata'), __('Show empty metadata'),
0, 0,
'check' 'check'
); )
$w->epew->setting( ->setting(
'category', 'category',
__('Category limit:'), __('Category limit:'),
'', '',
'combo', 'combo',
$categories_combo $categories_combo
); )
$w->epew->setting( ->setting(
'thumbsize', 'thumbsize',
__('Thumbnail size:'), __('Thumbnail size:'),
't', 't',
'combo', 'combo',
$thumbnail_combo $thumbnail_combo
); )
$w->epew->setting( ->addContentOnly()
'content_only', ->addClass()
__('Content only'), ->addOffline();
0,
'check'
);
$w->epew->setting(
'class',
__('CSS class:'),
''
);
$w->epew->setting(
'offline',
__('Offline'),
0,
'check'
);
} }
public static function getWidget($w) public static function renderWidget(WidgetsElement $w): string
{ {
global $core, $_ctx; // Widget is offline
# Widget is offline
if ($w->offline) { if ($w->offline) {
return null; return '';
} }
# Not in post context // nullsafe
if (!$_ctx->exists('posts') || !$_ctx->posts->post_id) { if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
return null; return '';
} }
# Not supported post type // Not in post context
if (!in_array($_ctx->posts->post_type, self::$supported_post_type)) { if (!dcCore::app()->ctx->exists('posts') || !dcCore::app()->ctx->__get('posts')->f('post_id')) {
return null; return '';
} }
# Category limit // Not supported post type
if ($w->category == 'null' && $_ctx->posts->cat_id !== null if (!in_array(dcCore::app()->ctx->__get('posts')->f('post_type'), self::$supported_post_type)) {
|| $w->category != 'null' && $w->category != '' && $w->category != $_ctx->posts->cat_id) { return '';
return null; }
// 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 # 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 # Find source images
$images = self::getImageSource($core, $text, $w->thumbsize); $images = self::getImageSource($text, $w->thumbsize);
# No images # No images
if (empty($images)) { if (empty($images)) {
return null; return '';
} }
$contents = ''; $contents = '';
@ -220,7 +210,7 @@ class entryPhotoExifWidget
# Loop through images # Loop through images
foreach ($images as $img) { foreach ($images as $img) {
# List metas # List metas
$metas = self::getImageMeta($core, $img['source']); $metas = self::getImageMeta($img['source']);
$content = ''; $content = '';
foreach ($metas as $k => $v) { foreach ($metas as $k => $v) {
@ -233,7 +223,7 @@ class entryPhotoExifWidget
# No meta # No meta
if (empty($content)) { if (empty($content)) {
return null; return '';
} }
# Thumbnail # Thumbnail
@ -244,27 +234,26 @@ class entryPhotoExifWidget
$contents .= $content; $contents .= $content;
} }
# Nothing found
if (empty($contents)) {
return null;
}
# Paste widget # Paste widget
return $w->renderDiv( return $w->renderDiv(
$w->content_only, (bool) $w->content_only,
'photoExifWidget ' . $w->class, 'photoExifWidget ' . $w->class,
'', '',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . ($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
sprintf(self::$widget_content, $contents) 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 # Path and url
$p_url = $core->blog->settings->system->public_url; $p_url = (string) dcCore::app()->blog->settings->get('system')->get('public_url');
$p_site = preg_replace('#^(.+?//.+?)/(.*)$#', '$1', $core->blog->url); $p_site = (string) preg_replace('#^(.+?//.+?)/(.*)$#', '$1', dcCore::app()->blog->url);
$p_root = $core->blog->public_path; $p_root = dcCore::app()->blog->public_path;
# Image pattern # Image pattern
$pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/'); $pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/');
@ -272,7 +261,7 @@ class entryPhotoExifWidget
# No image # No image
if (!preg_match_all($pattern, $subject, $m)) { if (!preg_match_all($pattern, $subject, $m)) {
return; return [];
} }
$res = $duplicate = []; $res = $duplicate = [];
@ -281,7 +270,7 @@ class entryPhotoExifWidget
# Loop through images # Loop through images
foreach ($m[1] as $i => $img) { foreach ($m[1] as $i => $img) {
$src = $thb = $alt = false; $src = $thb = $alt = false;
$info = path::info($img); $info = Path::info($img);
$base = $info['base']; $base = $info['base'];
$ext = $info['extension']; $ext = $info['extension'];
@ -326,15 +315,19 @@ class entryPhotoExifWidget
$res[] = [ $res[] = [
'source' => $src, 'source' => $src,
'thumb' => $thb, 'thumb' => $thb,
'title' => $alt 'title' => $alt,
]; ];
} }
return $res; return $res;
} }
public static function getImageMeta($core, $src) public static function getImageMeta(?string $src): array
{ {
if (is_null(dcCore::app()->blog)) {
return [];
}
$metas = [ $metas = [
'Title' => [__('Title:'), ''], 'Title' => [__('Title:'), ''],
'Description' => [__('Description:'), ''], 'Description' => [__('Description:'), ''],
@ -349,7 +342,7 @@ class entryPhotoExifWidget
'ISOSpeedRatings' => [__('ISO:'), ''], 'ISOSpeedRatings' => [__('ISO:'), ''],
'FocalLength' => [__('Focal:'), ''], 'FocalLength' => [__('Focal:'), ''],
'ExposureBiasValue' => [__('Exposure Bias:'), ''], 'ExposureBiasValue' => [__('Exposure Bias:'), ''],
'MeteringMode' => [__('Metering mode:'), ''] 'MeteringMode' => [__('Metering mode:'), ''],
]; ];
$exp_prog = [ $exp_prog = [
@ -361,7 +354,7 @@ class entryPhotoExifWidget
5 => __('Creative program'), 5 => __('Creative program'),
6 => __('Action program'), 6 => __('Action program'),
7 => __('Portait mode'), 7 => __('Portait mode'),
8 => __('Landscape mode') 8 => __('Landscape mode'),
]; ];
$met_mod = [ $met_mod = [
@ -372,58 +365,58 @@ class entryPhotoExifWidget
4 => __('Multi spot'), 4 => __('Multi spot'),
5 => __('Pattern'), 5 => __('Pattern'),
6 => __('Partial'), 6 => __('Partial'),
7 => __('Other') 7 => __('Other'),
]; ];
if (!$src || !file_exists($src)) { if (!$src || !file_exists($src)) {
return $metas; return $metas;
} }
$m = imageMeta::readMeta($src); $m = ImageMeta::readMeta($src);
# Title # Title
if (!empty($m['Title'])) { if (!empty($m['Title'])) {
$metas['Title'][1] = html::escapeHTML($m['Title']); $metas['Title'][1] = Html::escapeHTML($m['Title']);
} }
# Description # Description
if (!empty($m['Description'])) { if (!empty($m['Description'])) {
if (!empty($m['Title']) && $m['Title'] != $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 # Location
if (!empty($m['City'])) { 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'])) { if (!empty($m['City']) && !empty($m['country'])) {
$metas['Location'][1] .= ', '; $metas['Location'][1] .= ', ';
} }
if (!empty($m['country'])) { if (!empty($m['country'])) {
$metas['Location'][1] .= html::escapeHTML($m['Country']); $metas['Location'][1] .= Html::escapeHTML($m['Country']);
} }
# DateTimeOriginal # DateTimeOriginal
if (!empty($m['DateTimeOriginal'])) { if (!empty($m['DateTimeOriginal'])) {
$dt_ft = $core->blog->settings->system->date_format . ', ' . $core->blog->settings->system->time_format; $dt_ft = dcCore::app()->blog->settings->get('system')->get('date_format') . ', ' . dcCore::app()->blog->settings->get('system')->get('time_format');
$dt_tz = $core->blog->settings->system->blog_timezone; $dt_tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone');
$metas['DateTimeOriginal'][1] = dt::dt2str($dt_ft, $m['DateTimeOriginal'], $dt_tz); $metas['DateTimeOriginal'][1] = Date::dt2str($dt_ft, $m['DateTimeOriginal'], $dt_tz);
} }
# Make # Make
if (isset($m['Make'])) { if (isset($m['Make'])) {
$metas['Make'][1] = html::escapeHTML($m['Make']); $metas['Make'][1] = Html::escapeHTML($m['Make']);
} }
# Model # Model
if (isset($m['Model'])) { if (isset($m['Model'])) {
$metas['Model'][1] = html::escapeHTML($m['Model']); $metas['Model'][1] = Html::escapeHTML($m['Model']);
} }
# Lens # Lens
if (isset($m['Lens'])) { if (isset($m['Lens'])) {
$metas['Lens'][1] = html::escapeHTML($m['Lens']); $metas['Lens'][1] = Html::escapeHTML($m['Lens']);
} }
# ExposureProgram # ExposureProgram