Compare commits

..
Author SHA1 Message Date
Terranom674 5bff85df3d Disable automatic workflow triggers; manual runs only 2026-10-19 20:28:53 +02:00
3 changed files with 20 additions and 116 deletions

No files matched your search

+3 -34
View File
@@ -14,14 +14,13 @@ function bratonien_tools_filter_webdav_gallery_derivative_url($url, $params, $sr
return $url;
}
$derivative_path = '';
try
{
$derivative = new DerivativeImage($params, $src_image);
if (!$derivative->same_as_source())
{
$derivative_path = $derivative->get_path();
if ($derivative_path !== '' && is_file($derivative_path) && is_readable($derivative_path))
$path = $derivative->get_path();
if ($path !== '' && is_file($path) && is_readable($path))
{
return $url;
}
@@ -29,37 +28,7 @@ function bratonien_tools_filter_webdav_gallery_derivative_url($url, $params, $sr
}
catch (Throwable $e)
{
error_log('Bratonien WebDAV derivative lookup #'.(int)$src_image->id.': '.$e->getMessage());
}
$script_name = basename((string)($_SERVER['SCRIPT_NAME'] ?? ''));
if ($script_name === 'picture.php' && function_exists('bratonien_tools_webdav_generate_derivative'))
{
$detail = '';
try
{
if (bratonien_tools_webdav_generate_derivative($params, $src_image, $detail))
{
if ($derivative_path === '')
{
$probe = new DerivativeImage($params, $src_image);
if (!$probe->same_as_source()) $derivative_path = $probe->get_path();
}
if ($derivative_path !== '' && is_file($derivative_path) && is_readable($derivative_path))
{
return $url;
}
}
}
catch (Throwable $e)
{
$detail = get_class($e).': '.$e->getMessage();
}
if ($detail !== '')
{
error_log('Bratonien WebDAV picture derivative #'.(int)$src_image->id.': '.$detail);
}
error_log('Bratonien WebDAV gallery derivative lookup #'.(int)$src_image->id.': '.$e->getMessage());
}
$preview_url = bratonien_tools_webdav_image_url((int)$src_image->id, true);
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Bratonien Tools
Version: 0.9.7.9
Version: 0.9.7.7
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
Author: Bratonien
+16 -81
View File
@@ -6,7 +6,7 @@ if (PHP_SAPI !== 'cli')
exit(1);
}
const BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION = '0.9.7.8';
const BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION = '0.9.7.5';
$options = getopt('', array('piwigo-root:', 'connection-id:'));
$piwigo_root = rtrim((string)($options['piwigo-root'] ?? ''), '/');
@@ -46,75 +46,25 @@ if (!function_exists('bratonien_tools_webdav_image_source_info') || !function_ex
exit(1);
}
function bratonien_tools_webdav_modus_config()
try
{
global $conf;
$modus = $conf['modus_theme'] ?? array();
if (is_string($modus) && $modus !== '')
{
$decoded = @unserialize($modus);
if (is_array($decoded)) $modus = $decoded;
}
if (!is_array($modus)) $modus = array();
return array_merge(
array(
'index_photo_deriv'=>'2small',
'index_photo_deriv_hdpi'=>'xsmall',
),
$modus
);
}
function bratonien_tools_webdav_gallery_base_params()
{
$modus = bratonien_tools_webdav_modus_config();
$type = trim((string)($modus['index_photo_deriv'] ?? '2small'));
$params = $type !== '' ? @ImageStdParams::get_by_type($type) : null;
if ($params) return $params;
$params = ImageStdParams::get_by_type(IMG_THUMB);
if (!$params)
$standard_gallery = ImageStdParams::get_by_type(IMG_THUMB);
if (!$standard_gallery || !isset($standard_gallery->sizing->ideal_size))
{
throw new RuntimeException('Piwigo-Galeriederivat ist nicht konfiguriert.');
}
return $params;
}
function bratonien_tools_webdav_modus_gallery_params(SrcImage $src, $base_params)
{
$row_height = (int)$base_params->max_height();
$candidates = array($base_params);
foreach (ImageStdParams::get_defined_type_map() as $params)
{
if (
$params->max_height() > $row_height
&& $params->sizing->max_crop == $base_params->sizing->max_crop
)
{
$candidates[] = $params;
if (count($candidates) === 3) break;
}
}
$selected = $base_params;
foreach ($candidates as $params)
{
$selected = $params;
$probe = new DerivativeImage($params, $src);
$size = $probe->get_size();
if ((int)$size[1] >= $row_height - 2) break;
}
return $selected;
}
try
{
$gallery_base_params = bratonien_tools_webdav_gallery_base_params();
$gallery_base_type = (string)$gallery_base_params->type;
$gallery_params = clone $standard_gallery;
$gallery_params->sizing = new SizingParams(
array(
(int)$standard_gallery->sizing->ideal_size[0],
(int)$standard_gallery->sizing->ideal_size[1],
),
0,
null
);
$gallery_params->type = IMG_THUMB;
$gallery_params->use_watermark = false;
$images = 0;
$generated_or_ready = 0;
@@ -123,7 +73,6 @@ try
$legacy_derivatives_rebuilt = 0;
$errors = 0;
$error_lines = array();
$variant_counts = array();
$result = pwg_query('SELECT * FROM '.IMAGES_TABLE.' ORDER BY id');
while ($row = pwg_db_fetch_assoc($result))
@@ -175,11 +124,6 @@ try
$src = new SrcImage($row);
try
{
$gallery_params = bratonien_tools_webdav_modus_gallery_params($src, $gallery_base_params);
$variant = (string)$gallery_params->type;
if ($variant === '') $variant = 'custom';
$variant_counts[$variant] = ($variant_counts[$variant] ?? 0) + 1;
$probe = new DerivativeImage($gallery_params, $src);
if ($probe->same_as_source())
{
@@ -246,18 +190,9 @@ try
}
}
ksort($variant_counts);
$variant_parts = array();
foreach ($variant_counts as $type=>$count)
{
$variant_parts[] = $type.':'.$count;
}
echo 'WebDAV-Derivative-Builder: version='.BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION.
' bilder='.$images.
' varianten_pro_bild=1'.
' modus_basis='.$gallery_base_type.
' modus_varianten='.implode(',', $variant_parts).
' varianten=1'.
' bereit='.$generated_or_ready.
' identisch='.$identity.
' metadaten_repariert='.$metadata_repaired.