[FEAT] Fix some bug and css issues.

This commit is contained in:
NADAL Jean-Baptiste
2026-09-15 11:46:02 +02:00
parent a38fc0bfa9
commit 71d3b71362
26 changed files with 829 additions and 418 deletions
+13 -14
View File
@@ -594,7 +594,7 @@ class ScoreScanner {
rmdir($dir);
}
public function uploadPdf(string $scoreId, array $file, string $piece, string $instrument, string $version, string $key = '', string $clef = '', string $variant = '', string $part = '1', bool $watermark = false, string $watermarkPosition = 'left'): array {
public function uploadPdf(string $scoreId, array $file, string $piece, string $instrument, string $version, string $key = '', string $clef = '', string $variant = '', string $part = '1', bool $watermark = false, string $watermarkPosition = 'left', ?string $combined = null): array {
// Security: every input used to build a path or a filename is validated
if (!$this->isValidSegment($scoreId, '/^\d{1,6}$/')) {
return ['success' => false, 'error' => 'Invalid score id'];
@@ -680,20 +680,19 @@ class ScoreScanner {
$instName = $instrumentNames[$instrument] ?? $instrument;
// Build filename: instrument_variant_key_clef_part.pdf
$filenameParts = [$instName];
if (!empty($variant)) {
$filenameParts[] = $variant;
if (in_array($instrument, ['sup', 'par'], true) && $combined !== null && trim($combined) !== '') {
// Combined/superposed parts keep their real instrument names (e.g. "contrebasse-1+clarinette-1")
$combined = strtolower(trim($combined));
if (!$this->isValidSegment($combined, '/^[a-z0-9_+.-]+$/')) {
return ['success' => false, 'error' => 'Invalid combined instruments'];
}
$filename = $combined . '.pdf';
} else {
// NAMING.md: fields separated by '-', compound names/suffixes by '_'
$nameParts = array_values(array_filter([$instName, $key, $variant, $clef], fn($v) => $v !== ''));
$nameParts[] = $part;
$filename = implode('-', $nameParts) . '.pdf';
}
if (!empty($key)) {
$filenameParts[] = $key;
}
if (!empty($clef)) {
$filenameParts[] = $clef;
}
$filenameParts[] = $part;
$filename = implode('_', $filenameParts) . '.pdf';
$targetPath = $targetDir . '/' . $filename;