svg upload in floors ausgebaut
This commit is contained in:
@@ -38,7 +38,7 @@ if (!empty($floor['svg_path'])) {
|
|||||||
<div class="floor-edit">
|
<div class="floor-edit">
|
||||||
<h1><?php echo $pageTitle; ?></h1>
|
<h1><?php echo $pageTitle; ?></h1>
|
||||||
|
|
||||||
<form method="post" action="?module=floors&action=save" enctype="multipart/form-data" class="edit-form">
|
<form method="post" action="?module=floors&action=save" class="edit-form">
|
||||||
<?php if ($isEdit): ?>
|
<?php if ($isEdit): ?>
|
||||||
<input type="hidden" name="id" value="<?php echo $floorId; ?>">
|
<input type="hidden" name="id" value="<?php echo $floorId; ?>">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -86,12 +86,6 @@ if (!empty($floor['svg_path'])) {
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Grundriss (SVG)</legend>
|
<legend>Grundriss (SVG)</legend>
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="svg_file">SVG-Datei hochladen</label>
|
|
||||||
<input type="file" id="svg_file" name="svg_file" accept=".svg">
|
|
||||||
<small>Optional. Wenn ein Zeichnungsinhalt im Editor erstellt wird, wird dieser beim Speichern bevorzugt.</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<textarea id="floor-svg-content" name="floor_svg_content" hidden><?php echo htmlspecialchars($existingSvgContent); ?></textarea>
|
<textarea id="floor-svg-content" name="floor_svg_content" hidden><?php echo htmlspecialchars($existingSvgContent); ?></textarea>
|
||||||
|
|
||||||
<div id="floor-svg-editor" class="floor-svg-editor">
|
<div id="floor-svg-editor" class="floor-svg-editor">
|
||||||
@@ -178,7 +172,6 @@ if (!empty($floor['svg_path'])) {
|
|||||||
|
|
||||||
.form-group input[type="text"],
|
.form-group input[type="text"],
|
||||||
.form-group input[type="number"],
|
.form-group input[type="number"],
|
||||||
.form-group input[type="file"],
|
|
||||||
.form-group select,
|
.form-group select,
|
||||||
.form-group textarea {
|
.form-group textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -43,43 +43,9 @@ if (!empty($errors)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// =========================
|
// =========================
|
||||||
// SVG-Upload verarbeiten (optional)
|
// SVG aus Editor verarbeiten (optional)
|
||||||
// =========================
|
// =========================
|
||||||
$svgPath = null;
|
$svgPath = null;
|
||||||
if (!empty($_FILES['svg_file']['name'])) {
|
|
||||||
$file = $_FILES['svg_file'];
|
|
||||||
$tmpName = $file['tmp_name'];
|
|
||||||
$originalName = basename($file['name']);
|
|
||||||
$fileExt = strtolower(pathinfo($originalName, PATHINFO_EXTENSION));
|
|
||||||
|
|
||||||
// Nur SVG erlaubt
|
|
||||||
if ($fileExt !== 'svg') {
|
|
||||||
$_SESSION['error'] = "Nur SVG-Dateien sind erlaubt";
|
|
||||||
$redirectUrl = $floorId ? "?module=floors&action=edit&id=$floorId" : "?module=floors&action=edit";
|
|
||||||
header("Location: $redirectUrl");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zielverzeichnis
|
|
||||||
$uploadDir = __DIR__ . '/../../uploads/floorplans/';
|
|
||||||
if (!is_dir($uploadDir)) {
|
|
||||||
mkdir($uploadDir, 0755, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Eindeutiger Dateiname
|
|
||||||
$newFileName = uniqid('floor_') . '.svg';
|
|
||||||
$destPath = $uploadDir . $newFileName;
|
|
||||||
|
|
||||||
if (move_uploaded_file($tmpName, $destPath)) {
|
|
||||||
$svgPath = 'uploads/floorplans/' . $newFileName;
|
|
||||||
} else {
|
|
||||||
$_SESSION['error'] = "Datei-Upload fehlgeschlagen";
|
|
||||||
$redirectUrl = $floorId ? "?module=floors&action=edit&id=$floorId" : "?module=floors&action=edit";
|
|
||||||
header("Location: $redirectUrl");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($floorSvgContent !== '') {
|
if ($floorSvgContent !== '') {
|
||||||
$storedSvgPath = storeSvgEditorContent($sql, $floorId, $floorSvgContent);
|
$storedSvgPath = storeSvgEditorContent($sql, $floorId, $floorSvgContent);
|
||||||
if ($storedSvgPath === false) {
|
if ($storedSvgPath === false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user