Compare commits

..
Author SHA1 Message Date
Terranom674 dc64cbd4d2 Disable automatic workflow triggers; manual runs only 2026-10-19 20:28:43 +02:00
4 changed files with 38 additions and 58 deletions

No files matched your search

+1 -2
View File
@@ -1,8 +1,7 @@
name: Syntax Check
on:
push:
pull_request:
workflow_dispatch:
jobs:
php-syntax:
+11 -18
View File
@@ -49,21 +49,18 @@ function bratonien_tools_webdav_image_source_info($image_id)
}
$root_path = '';
$root_found = false;
$roots = isset($config['roots']) && is_array($config['roots']) ? $config['roots'] : array();
foreach ($roots as $root)
{
if ((int)($root['fileid'] ?? 0) === $root_fileid)
{
$root_path = trim((string)($root['webdav_path'] ?? ''), '/');
$root_found = true;
break;
}
}
if (!$root_found) return $cache[$image_id] = null;
if ($root_path === '') return $cache[$image_id] = null;
$root_is_base = $root_path === '';
$webdav_path = $root_is_base ? $relative_path : $root_path.'/'.$relative_path;
$webdav_path = $root_path.'/'.$relative_path;
$content_type = '';
$size = 0;
$etag = '';
@@ -93,7 +90,6 @@ function bratonien_tools_webdav_image_source_info($image_id)
'image_id'=>$image_id,
'connection_id'=>$connection_id,
'webdav_path'=>$webdav_path,
'root_is_base'=>$root_is_base,
'content_type'=>$content_type,
'size'=>$size,
'etag'=>$etag,
@@ -419,22 +415,19 @@ function bratonien_tools_filter_webdav_derivative_url($url, $params, $src_image,
$info = bratonien_tools_webdav_image_source_info((int)$src_image->id);
if (!$info) return $url;
if (empty($info['root_is_base']))
try
{
try
$derivative = new DerivativeImage($params, $src_image);
if (!$derivative->same_as_source())
{
$derivative = new DerivativeImage($params, $src_image);
if (!$derivative->same_as_source())
{
$path = $derivative->get_path();
if ($path !== '' && is_file($path) && is_readable($path)) return $url;
}
}
catch (Throwable $e)
{
error_log('Bratonien WebDAV derivative lookup #'.(int)$src_image->id.': '.$e->getMessage());
$path = $derivative->get_path();
if ($path !== '' && is_file($path) && is_readable($path)) return $url;
}
}
catch (Throwable $e)
{
error_log('Bratonien WebDAV derivative lookup #'.(int)$src_image->id.': '.$e->getMessage());
}
$preview_url = bratonien_tools_webdav_image_url((int)$src_image->id, true);
return $preview_url ?: $url;
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Bratonien Tools
Version: 0.9.7.4
Version: 0.9.7.2
Description: Erweiterbare Administrationswerkzeuge fuer die Bratonien-Piwigo-Installation.
Plugin URI: https://github.com/Terranom674/Piwigo_Bratonien_Tools
Author: Bratonien
+25 -37
View File
@@ -6,7 +6,7 @@ if (PHP_SAPI !== 'cli')
exit(1);
}
const BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION = '0.9.7.4';
const BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION = '0.9.6.1';
$options = getopt('', array('piwigo-root:', 'connection-id:'));
$piwigo_root = rtrim((string)($options['piwigo-root'] ?? ''), '/');
@@ -48,27 +48,12 @@ if (!function_exists('bratonien_tools_webdav_image_source_info') || !function_ex
try
{
$standard_gallery = ImageStdParams::get_by_type(IMG_THUMB);
if (!$standard_gallery || !isset($standard_gallery->sizing->ideal_size))
$variants = bratonien_tools_webdav_derivative_variants();
if (!$variants)
{
throw new RuntimeException('Piwigo-Galeriederivat ist nicht konfiguriert.');
throw new RuntimeException('Keine Piwigo-Derivate konfiguriert.');
}
// Only the gallery thumbnail is prebuilt. Keep the Piwigo target type/path,
// but never crop to the 1x1 placeholder geometry. The real Nextcloud
// preview dimensions determine the aspect ratio.
$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;
$identity = 0;
@@ -124,31 +109,34 @@ try
}
$src = new SrcImage($row);
try
foreach ($variants as $variant_name => $params)
{
$probe = new DerivativeImage($gallery_params, $src);
if ($probe->same_as_source())
try
{
$identity++;
continue;
}
$probe = new DerivativeImage($params, $src);
if ($probe->same_as_source())
{
$identity++;
continue;
}
$detail = '';
if (bratonien_tools_webdav_generate_derivative($gallery_params, $src, $detail))
{
$generated_or_ready++;
$detail = '';
if (bratonien_tools_webdav_generate_derivative($params, $src, $detail))
{
$generated_or_ready++;
}
else
{
$errors++;
$error_lines[] = 'Bild #'.$image_id.' '.$variant_name.': '.($detail !== '' ? $detail : 'Derivat konnte nicht erzeugt werden.');
}
}
else
catch (Throwable $e)
{
$errors++;
$error_lines[] = 'Bild #'.$image_id.' Galerie: '.($detail !== '' ? $detail : 'Galeriederivat konnte nicht erzeugt werden.');
$error_lines[] = 'Bild #'.$image_id.' '.$variant_name.': '.get_class($e).': '.$e->getMessage();
}
}
catch (Throwable $e)
{
$errors++;
$error_lines[] = 'Bild #'.$image_id.' Galerie: '.get_class($e).': '.$e->getMessage();
}
}
if ($metadata_repaired > 0)
@@ -171,7 +159,7 @@ try
echo 'WebDAV-Derivative-Builder: version='.BRATONIEN_WEBDAV_DERIVATIVE_BUILDER_VERSION.
' bilder='.$images.
' varianten=1'.
' varianten='.count($variants).
' bereit='.$generated_or_ready.
' identisch='.$identity.
' metadaten_repariert='.$metadata_repaired.