Compare commits
4 Commits
e9fbee43e3
...
dev/lukas
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f15e92d65 | ||
|
|
942affd5e5 | ||
|
|
02ba53724e | ||
|
|
d0bba3d3f8 |
139
EXTENSION.md
139
EXTENSION.md
@@ -1,8 +1,47 @@
|
|||||||
## Neue Ideenkarte anlegen
|
# Neue Ideenkarte anlegen
|
||||||
1. DNS record ```<name>``` A 195.59.32.237 600s
|
|
||||||
2. Nginx Weiterleitung in ```default.conf```:
|
|
||||||
|
|
||||||
|
## Übersicht
|
||||||
|
|
||||||
|
| Variable | Bedeutung |
|
||||||
|
|---|---|
|
||||||
|
| `<name>` | Name der Kommune (z.B. `lohne`) |
|
||||||
|
| `<ID>` | Eindeutige Port-ID für die Datenbank (z.B. `4` → Port `5434`) |
|
||||||
|
| `<branch-name>` | Git-Branch des Frontend-Repos |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Schritt 1 — DNS Record anlegen
|
||||||
|
|
||||||
|
Im DNS-Panel einen neuen A-Record anlegen:
|
||||||
|
|
||||||
|
| Feld | Wert |
|
||||||
|
|---|---|
|
||||||
|
| Name | `<name>` |
|
||||||
|
| Typ | `A` |
|
||||||
|
| Ziel | `195.59.32.237` |
|
||||||
|
| TTL | `600s` |
|
||||||
|
|
||||||
|
> ⚠️ DNS muss vollständig propagiert sein, bevor Certbot in Schritt 3 ausgeführt wird.
|
||||||
|
|
||||||
|
Propagation prüfen:
|
||||||
|
```bash
|
||||||
|
dig <name>.endex-geodaten.de
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Schritt 2 — Nginx `default.conf` anpassen
|
||||||
|
|
||||||
|
### 2a — Subdomain in den Port-80-Block eintragen
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
server_name endex-geodaten.de www.endex-geodaten.de git.endex-geodaten.de lohne.endex-geodaten.de <name>.endex-geodaten.de localhost;
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2b — Neuen HTTPS-Server-Block hinzufügen
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
# WEBGIS <NAME>
|
||||||
server {
|
server {
|
||||||
listen 443 ssl;
|
listen 443 ssl;
|
||||||
server_name <name>.endex-geodaten.de;
|
server_name <name>.endex-geodaten.de;
|
||||||
@@ -26,8 +65,34 @@ server {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Docker container für UI
|
---
|
||||||
|
|
||||||
|
## Schritt 3 — SSL-Zertifikat erneuern
|
||||||
|
|
||||||
|
Da kein Wildcard-Zertifikat verwendet wird, muss das Cert neu ausgestellt werden:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose run --rm certbot certonly --webroot \
|
||||||
|
--webroot-path=/var/www/certbot \
|
||||||
|
-d endex-geodaten.de \
|
||||||
|
-d www.endex-geodaten.de \
|
||||||
|
-d git.endex-geodaten.de \
|
||||||
|
-d lohne.endex-geodaten.de \
|
||||||
|
-d <name>.endex-geodaten.de
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Nginx neu laden:
|
||||||
|
```bash
|
||||||
|
docker compose exec nginx nginx -s reload
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Schritt 4 — Docker Container in `docker-compose.yml` anlegen
|
||||||
|
|
||||||
|
### PHP/UI Container
|
||||||
|
|
||||||
|
```yaml
|
||||||
webgis-<name>-php:
|
webgis-<name>-php:
|
||||||
build: php-docker/
|
build: php-docker/
|
||||||
container_name: webgis-<name>-php
|
container_name: webgis-<name>-php
|
||||||
@@ -38,41 +103,81 @@ server {
|
|||||||
- webgis-<name>-nw
|
- webgis-<name>-nw
|
||||||
```
|
```
|
||||||
|
|
||||||
und Datenbank anlegen.
|
### Datenbank Container
|
||||||
|
|
||||||
```
|
```yaml
|
||||||
webgis-<name>db:
|
webgis-<name>-db:
|
||||||
image: postgis/postgis:15-3.3
|
image: postgis/postgis:15-3.3
|
||||||
container_name: webgis-<name>-db
|
container_name: webgis-<name>-db
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:543<ID>:5432" # inside the container always 5432
|
- "127.0.0.1:543<ID>:5432" # inside the container always 5432
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER=${WEBGIS_DB_USER} # maybe go back to default username
|
- POSTGRES_USER=${WEBGIS_<NAME>_DB_USER}
|
||||||
- POSTGRES_PASSWORD=${WEBGIS_DB_PW} # must be secure and unique
|
- POSTGRES_PASSWORD=${WEBGIS_<NAME>_DB_PW}
|
||||||
- POSTGRES_DB=${WEBGIS_DB_NAME} #same as container name
|
- POSTGRES_DB=${WEBGIS_<NAME>_DB_NAME}
|
||||||
volumes:
|
volumes:
|
||||||
- ./webgis-<name>-data:/var/lib/postgresql/data
|
- ./webgis-<name>-data:/var/lib/postgresql/data
|
||||||
networks:
|
networks:
|
||||||
- webgis-<name>-nw
|
- webgis-<name>-nw
|
||||||
```
|
```
|
||||||
|
|
||||||
4. nginx Volume für neue Stadt in ```docker-compose.yml``` anlegen
|
### Netzwerk ergänzen
|
||||||
```
|
|
||||||
./webgis-<name>:/var/www/webgis-<name>
|
Unter dem `networks:` Block am Ende der `docker-compose.yml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
networks:
|
||||||
|
webgis-<name>-nw:
|
||||||
|
driver: bridge
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
5. Frontend source code nach ```webgis-<name>``` klonen
|
## Schritt 5 — Nginx Volume ergänzen
|
||||||
|
|
||||||
|
Beim nginx-Service in `docker-compose.yml` das neue Volume eintragen:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
volumes:
|
||||||
|
- ./webgis-<name>:/var/www/webgis-<name>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Schritt 6 — Frontend Source Code klonen
|
||||||
|
|
||||||
|
```bash
|
||||||
git submodule add -b <branch-name> https://git.endex-geodaten.de/lukas.uptmoor/webgis-<name>.git
|
git submodule add -b <branch-name> https://git.endex-geodaten.de/lukas.uptmoor/webgis-<name>.git
|
||||||
```
|
```
|
||||||
|
|
||||||
Jede Kommune sollte ein eigenes Repo kriegen, da Features am Anfang variieren.
|
> Jede Kommune erhält ein eigenes Repo, da Features initial variieren können.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
6. Mit der Datenbank verbinden über SSH-Tunnel
|
## Schritt 7 — Container starten
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up -d webgis-<name>-php webgis-<name>-db
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Logs prüfen:
|
||||||
|
```bash
|
||||||
|
docker compose logs -f webgis-<name>-php
|
||||||
|
docker compose logs -f webgis-<name>-db
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Schritt 8 — Datenbank vorbereiten
|
||||||
|
|
||||||
|
SSH-Tunnel öffnen:
|
||||||
|
```bash
|
||||||
ssh -L 5433:localhost:543<ID> root@endex-geodaten.de
|
ssh -L 5433:localhost:543<ID> root@endex-geodaten.de
|
||||||
```
|
```
|
||||||
und Datenbank für Anwendung vorbereiten.
|
|
||||||
|
Strukturen laden:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -it webgis-<name>-db psql -U $POSTGRES_USER -d $POSTGRES_DB < migrations/001_initial_schema.sql
|
||||||
|
```
|
||||||
48
legacy/delete_data.php
Normal file
48
legacy/delete_data.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
// ToDo's
|
||||||
|
// Whitelists oder Prepared Statements gegen SQL-Injection hinzufügen
|
||||||
|
|
||||||
|
|
||||||
|
include 'init.php';
|
||||||
|
|
||||||
|
$request = htmlspecialchars($_POST['request'], ENT_QUOTES);
|
||||||
|
|
||||||
|
if ($request=='buildings') {
|
||||||
|
$webgis_id = htmlspecialchars($_POST['webgis_id'], ENT_QUOTES);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$pdo -> query("DELETE FROM buildings WHERE webgis_id = '$webgis_id'");
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo "ERROR ".$e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request == 'pipelines') {
|
||||||
|
$webgis_id = htmlspecialchars($_POST['webgis_id'], ENT_QUOTES);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$pdo -> query("DELETE from pipelines where webgis_id= '$webgis_id' ");
|
||||||
|
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
echo "ERROR ".$e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request == 'valves') {
|
||||||
|
$webgis_id = htmlspecialchars($_POST['webgis_id'], ENT_QUOTES);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$pdo -> query("DELETE from valves where webgis_id= '$webgis_id' ");
|
||||||
|
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
echo "ERROR ".$e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
52
legacy/find_data.php
Normal file
52
legacy/find_data.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// ToDo's
|
||||||
|
// Whitelists oder Prepared Statements gegen SQL-Injection hinzufügen
|
||||||
|
|
||||||
|
// PostgreSQL-Serververbindung
|
||||||
|
include 'init.php';
|
||||||
|
|
||||||
|
// HTTP-POST-Methode für Formulardaten
|
||||||
|
$table = htmlspecialchars($_POST['table'], ENT_QUOTES);
|
||||||
|
$field = htmlspecialchars($_POST['field'], ENT_QUOTES);
|
||||||
|
$value = htmlspecialchars($_POST['value'], ENT_QUOTES);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Datenbankabfrage
|
||||||
|
$result = $pdo -> query("SELECT *, ST_AsGeoJSON(geom) as geojson FROM $table WHERE $field = '$value'");
|
||||||
|
|
||||||
|
$features = [];
|
||||||
|
|
||||||
|
foreach($result as $row) {
|
||||||
|
// PHP-Objekt erstellen
|
||||||
|
$geometry = json_decode($row['geojson']);
|
||||||
|
|
||||||
|
// PHP-Objekt bereinigen
|
||||||
|
unset($row['geom']);
|
||||||
|
unset($row['geojson']);
|
||||||
|
|
||||||
|
// JSON-Feature hinzufügen
|
||||||
|
$feature = [
|
||||||
|
"type"=>"Feature",
|
||||||
|
"geometry"=>$geometry,
|
||||||
|
"properties"=>$row
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($features, $feature);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Feature-Collection hinzufügen
|
||||||
|
$featureCollection = [
|
||||||
|
"type"=>"FeatureCollection",
|
||||||
|
"features"=>$features
|
||||||
|
];
|
||||||
|
|
||||||
|
echo json_encode($featureCollection);
|
||||||
|
|
||||||
|
// Fehlernachricht ausgeben
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
echo "ERROR ".$e->getMessage();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
73
legacy/insert_data.php
Normal file
73
legacy/insert_data.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// ToDo's
|
||||||
|
// Whitelists oder Prepared Statements gegen SQL-Injection hinzufügen
|
||||||
|
|
||||||
|
// PostgreSQL-Serververbindung
|
||||||
|
include 'init.php';
|
||||||
|
|
||||||
|
$request = htmlspecialchars($_POST['request'], ENT_QUOTES);
|
||||||
|
|
||||||
|
if ($request == 'valves') {
|
||||||
|
$valve_id = htmlspecialchars($_POST['valve_id'], ENT_QUOTES);
|
||||||
|
$valve_type = htmlspecialchars($_POST['valve_type'], ENT_QUOTES);
|
||||||
|
$valve_dma_id = htmlspecialchars($_POST['valve_dma_id'], ENT_QUOTES);
|
||||||
|
$valve_diameter = htmlspecialchars($_POST['valve_diameter'], ENT_QUOTES);
|
||||||
|
$valve_visibility = htmlspecialchars($_POST['valve_visibility'], ENT_QUOTES);
|
||||||
|
$valve_location = htmlspecialchars($_POST['valve_location'], ENT_QUOTES);
|
||||||
|
$valve_geometry = $_POST['valve_geometry'];
|
||||||
|
|
||||||
|
$result = $pdo -> query("SELECT * FROM valves WHERE valve_id = '$valve_id'");
|
||||||
|
|
||||||
|
if ($result->rowCount()>0) {
|
||||||
|
echo "ERROR: Valve ID already exists. Please type in another ID!";
|
||||||
|
} else {
|
||||||
|
// Datenbankabfrage
|
||||||
|
$result = $pdo -> query("INSERT INTO valves(valve_id, valve_type, valve_dma_id, valve_diameter, valve_location, valve_visibility, geom) VALUES ('$valve_id', '$valve_type', '$valve_dma_id', '$valve_diameter', '$valve_location', '$valve_visibility', ST_SetSRID(ST_GeomFromGeoJSON('$valve_geometry'), 4326))");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request == 'pipelines') {
|
||||||
|
$pipeline_id = htmlspecialchars($_POST['pipeline_id'], ENT_QUOTES);
|
||||||
|
$pipeline_category = htmlspecialchars($_POST['pipeline_category'], ENT_QUOTES);
|
||||||
|
$pipeline_dma_id = htmlspecialchars($_POST['pipeline_dma_id'], ENT_QUOTES);
|
||||||
|
$pipeline_diameter = htmlspecialchars($_POST['pipeline_diameter'], ENT_QUOTES);
|
||||||
|
$pipeline_method = htmlspecialchars($_POST['pipeline_method'], ENT_QUOTES);
|
||||||
|
$pipeline_location = htmlspecialchars($_POST['pipeline_location'], ENT_QUOTES);
|
||||||
|
$pipeline_geometry = $_POST['pipeline_geometry'];
|
||||||
|
|
||||||
|
$result = $pdo -> query("SELECT * FROM pipelines WHERE pipeline_id = '$pipeline_id'");
|
||||||
|
|
||||||
|
if ($result->rowCount()>0) {
|
||||||
|
echo "ERROR: Pipeline ID already exists. Please type in another ID!";
|
||||||
|
} else {
|
||||||
|
// Datenbankabfrage
|
||||||
|
$result = $pdo -> query("INSERT INTO pipelines(pipeline_id, pipeline_category, pipeline_dma_id, pipeline_diameter, pipeline_method, pipeline_location, geom) VALUES ('$pipeline_id', '$pipeline_category', '$pipeline_dma_id', '$pipeline_diameter', '$pipeline_method', '$pipeline_location', ST_SetSRID(ST_GeomFromGeoJSON('$pipeline_geometry'), 4326))");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request == 'buildings') {
|
||||||
|
|
||||||
|
$account_no = htmlspecialchars($_POST['account_no'], ENT_QUOTES);
|
||||||
|
$building_category = htmlspecialchars($_POST['building_category'], ENT_QUOTES);
|
||||||
|
$building_dma_id = htmlspecialchars($_POST['building_dma_id'], ENT_QUOTES);
|
||||||
|
$building_storey = htmlspecialchars($_POST['building_storey'], ENT_QUOTES);
|
||||||
|
$building_population = htmlspecialchars($_POST['building_population'], ENT_QUOTES);
|
||||||
|
$building_location = htmlspecialchars($_POST['building_location'], ENT_QUOTES);
|
||||||
|
$building_geometry = $_POST['building_geometry'];
|
||||||
|
|
||||||
|
$result = $pdo -> query("SELECT *from buildings where account_no= '$account_no'");
|
||||||
|
|
||||||
|
if ($result->rowCount()>0) {
|
||||||
|
echo "ERROR: Building ID already exists. Please type in another ID!";
|
||||||
|
} else {
|
||||||
|
$sql = $pdo -> query("INSERT INTO buildings(account_no, building_category, building_dma_id, building_storey, building_population, building_location, geom) VALUES ('$account_no', '$building_category', '$building_dma_id', '$building_storey', '$building_population', '$building_location', ST_Force3DZ(ST_SetSRID(ST_GeomFromGeoJSON('$building_geometry'), 4326)))");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
63
legacy/load_data.php
Normal file
63
legacy/load_data.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// ToDo's
|
||||||
|
// Whitelists oder Prepared Statements gegen SQL-Injection hinzufügen
|
||||||
|
|
||||||
|
// PostgreSQL-Serververbindung
|
||||||
|
include 'init.php';
|
||||||
|
|
||||||
|
// HTTP-POST-Methode für Formulardaten
|
||||||
|
$table = htmlspecialchars($_POST['table'], ENT_QUOTES);
|
||||||
|
$dma_id = htmlspecialchars($_POST['dma_id'], ENT_QUOTES);
|
||||||
|
|
||||||
|
if($table == 'valves') {
|
||||||
|
$dma_id_field = "valve_dma_id";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($table == 'buildings') {
|
||||||
|
$dma_id_field = "building_dma_id";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($table == 'pipelines') {
|
||||||
|
$dma_id_field = "pipeline_dma_id";
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Datenbankabfrage
|
||||||
|
$result = $pdo -> query("SELECT *, ST_AsGeoJSON(geom) as geojson FROM $table WHERE $dma_id_field = '$dma_id'");
|
||||||
|
|
||||||
|
$features = [];
|
||||||
|
|
||||||
|
foreach($result as $row) {
|
||||||
|
// PHP-Objekt erstellen
|
||||||
|
$geometry = json_decode($row['geojson']);
|
||||||
|
|
||||||
|
// PHP-Objekt bereinigen
|
||||||
|
unset($row['geom']);
|
||||||
|
unset($row['geojson']);
|
||||||
|
|
||||||
|
// JSON-Feature hinzufügen
|
||||||
|
$feature = [
|
||||||
|
"type"=>"Feature",
|
||||||
|
"geometry"=>$geometry,
|
||||||
|
"properties"=>$row
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($features, $feature);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Feature-Collection hinzufügen
|
||||||
|
$featureCollection = [
|
||||||
|
"type"=>"FeatureCollection",
|
||||||
|
"features"=>$features
|
||||||
|
];
|
||||||
|
|
||||||
|
echo json_encode($featureCollection);
|
||||||
|
|
||||||
|
// Fehlernachricht ausgeben
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
echo "ERROR ".$e->getMessage();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
97
legacy/test.html
Normal file
97
legacy/test.html
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Document</title>
|
||||||
|
|
||||||
|
<!-- jQuery UI -->
|
||||||
|
<link rel="stylesheet" href="source/jquery-ui.min.css">
|
||||||
|
<script src="source/jquery-ui.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Bootstrap Stylesheet & Skript -->
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
|
||||||
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="styles.css">
|
||||||
|
|
||||||
|
<!-- Sidebar Plugin -->
|
||||||
|
<link rel="stylesheet" href="plugins/sidebar/leaflet-sidebar.css">
|
||||||
|
<script src="plugins/sidebar/leaflet-sidebar.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Button Plugin -->
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet-easybutton@2/src/easy-button.css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/leaflet-easybutton@2/src/easy-button.js"></script>
|
||||||
|
|
||||||
|
<!-- Font Plugin -->
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css">
|
||||||
|
|
||||||
|
<!-- PolylineMeasure Plugin -->
|
||||||
|
<link rel="stylesheet" href="https://ppete2.github.io/Leaflet.PolylineMeasure/Leaflet.PolylineMeasure.css">
|
||||||
|
<script src="https://ppete2.github.io/Leaflet.PolylineMeasure/Leaflet.PolylineMeasure.js"></script>
|
||||||
|
|
||||||
|
<!-- MousePosition Plugin -->
|
||||||
|
<link rel="stylesheet" href="plugins/mouseposition/L.Control.MousePosition.css">
|
||||||
|
<script src="plugins/mouseposition/L.Control.MousePosition.js"></script>
|
||||||
|
|
||||||
|
<!-- Geoman Plugin -->
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/@geoman-io/leaflet-geoman-free@latest/dist/leaflet-geoman.css">
|
||||||
|
<script src="https://unpkg.com/@geoman-io/leaflet-geoman-free@latest/dist/leaflet-geoman.js"></script>
|
||||||
|
|
||||||
|
<!-- Minimap Plugin -->
|
||||||
|
<link rel="stylesheet" href="plugins/minimap/Control.MiniMap.min.css">
|
||||||
|
<script src="plugins/minimap/Control.MiniMap.min.js"></script>
|
||||||
|
|
||||||
|
<!-- ajax Plugin -->
|
||||||
|
<script src="plugins/ajax/leaflet.ajax.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="popup-container">
|
||||||
|
|
||||||
|
<input type="hidden" name="building_database_id" class="updateBuilding" value="something">
|
||||||
|
<input type="hidden" name="account_no_old" class="updateBuilding" value="something">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="popup-form-group">
|
||||||
|
<label class="control-label popup-label">Building ID</label>
|
||||||
|
<input type="text" class="form-control popup-input text-center updateBuilding" value="something" name="account_no">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="popup-form-group">
|
||||||
|
<label class="control-label popup-label">Category</label>
|
||||||
|
<input type="text" class="form-control popup-input text-center updateBuilding" value="something" name="building_category">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="popup-form-group">
|
||||||
|
<label class="control-label popup-label">Storey</label>
|
||||||
|
<input type="number" class="form-control popup-input text-center updateBuilding" value="something" name="building_storey">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="popup-form-group">
|
||||||
|
<label class="control-label popup-label">Population</label>
|
||||||
|
<input type="number" class="form-control popup-input text-center updateBuilding" value="something" name="building_population">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="popup-form-group">
|
||||||
|
<label class="control-label popup-label">Location</label>
|
||||||
|
<input type="text" class="form-control popup-input text-center updateBuilding" value="something" name="building_locationn">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="popup-button-group">
|
||||||
|
<button type="submit" class="btn btn-success popup-button">Update</button>
|
||||||
|
<button type="submit" class="btn btn-danger popup-button">Delete</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
98
legacy/update_data.php
Normal file
98
legacy/update_data.php
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
include 'init.php';
|
||||||
|
|
||||||
|
$request = htmlspecialchars($_POST['request'], ENT_QUOTES);
|
||||||
|
|
||||||
|
if ($request=='buildings') {
|
||||||
|
$webgis_id = htmlspecialchars($_POST['webgis_id'], ENT_QUOTES);
|
||||||
|
$account_no_old = htmlspecialchars($_POST['account_no_old'], ENT_QUOTES);
|
||||||
|
$account_no = htmlspecialchars($_POST['account_no'], ENT_QUOTES);
|
||||||
|
$building_category = htmlspecialchars($_POST['building_category'], ENT_QUOTES);
|
||||||
|
$building_storey = htmlspecialchars($_POST['building_storey'], ENT_QUOTES);
|
||||||
|
$building_population = htmlspecialchars($_POST['building_population'], ENT_QUOTES);
|
||||||
|
$building_location = htmlspecialchars($_POST['building_location'], ENT_QUOTES);
|
||||||
|
$building_dma_id = htmlspecialchars($_POST['building_dma_id'], ENT_QUOTES);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if ($account_no_old != $account_no) {
|
||||||
|
$result = $pdo -> query("SELECT * FROM buildings WHERE account_no = '$account_no'");
|
||||||
|
|
||||||
|
if ($result -> rowCount()>0) {
|
||||||
|
echo "ERROR: Account Number already exists. Pleas type in another Account Number!";
|
||||||
|
} else {
|
||||||
|
$pdo -> query("UPDATE buildings SET account_no = '$account_no', building_category = '$building_category', building_storey = '$building_storey', building_population = '$building_population', building_location = '$building_location', building_dma_id = '$building_dma_id' WHERE webgis_id = '$webgis_id'");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { $pdo -> query("UPDATE buildings SET account_no = '$account_no', building_category = '$building_category', building_storey = '$building_storey', building_population = '$building_population', building_location = '$building_location', building_dma_id = '$building_dma_id' WHERE webgis_id = '$webgis_id'");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo "ERROR ".$e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($request == 'pipelines') {
|
||||||
|
$webgis_id = htmlspecialchars($_POST['webgis_id'], ENT_QUOTES);
|
||||||
|
$pipeline_id_old = htmlspecialchars($_POST['pipeline_id_old'], ENT_QUOTES);
|
||||||
|
$pipeline_id = htmlspecialchars($_POST['pipeline_id'], ENT_QUOTES);
|
||||||
|
$pipeline_dma_id = htmlspecialchars($_POST['pipeline_dma_id'], ENT_QUOTES);
|
||||||
|
$pipeline_diameter = htmlspecialchars($_POST['pipeline_diameter'], ENT_QUOTES);
|
||||||
|
$pipeline_location = htmlspecialchars($_POST['pipeline_location'], ENT_QUOTES);
|
||||||
|
$pipeline_category = htmlspecialchars($_POST['pipeline_category'], ENT_QUOTES);
|
||||||
|
$pipeline_length = htmlspecialchars($_POST['pipeline_length'], ENT_QUOTES);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if ($pipeline_id_old != $pipeline_id) {
|
||||||
|
$result = $pdo -> query("SELECT *from pipelines where pipeline_id = '$pipeline_id' ");
|
||||||
|
|
||||||
|
if ($result -> rowCount()>0) {
|
||||||
|
echo "ERROR: Pipeline ID already exists. Please choose a new ID";
|
||||||
|
} else {
|
||||||
|
$pdo -> query("UPDATE pipelines set pipeline_id = '$pipeline_id', pipeline_dma_id = '$pipeline_dma_id', pipeline_diameter = '$pipeline_diameter', pipeline_location = '$pipeline_location', pipeline_category='$pipeline_category', pipeline_length='$pipeline_length' where webgis_id = '$webgis_id'");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$pdo -> query("UPDATE pipelines set pipeline_id = '$pipeline_id', pipeline_dma_id = '$pipeline_dma_id', pipeline_diameter = '$pipeline_diameter', pipeline_location = '$pipeline_location', pipeline_category='$pipeline_category', pipeline_length='$pipeline_length' where webgis_id = '$webgis_id'");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
echo "ERROR ".$e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($request == 'valves') {
|
||||||
|
$webgis_id = htmlspecialchars($_POST['webgis_id'], ENT_QUOTES);
|
||||||
|
$valve_id_old = htmlspecialchars($_POST['valve_id_old'], ENT_QUOTES);
|
||||||
|
$valve_id = htmlspecialchars($_POST['valve_id'], ENT_QUOTES);
|
||||||
|
$valve_dma_id = htmlspecialchars($_POST['valve_dma_id'], ENT_QUOTES);
|
||||||
|
$valve_type = htmlspecialchars($_POST['valve_type'], ENT_QUOTES);
|
||||||
|
$valve_diameter = htmlspecialchars($_POST['valve_diameter'], ENT_QUOTES);
|
||||||
|
$valve_location = htmlspecialchars($_POST['valve_location'], ENT_QUOTES);
|
||||||
|
$valve_visibility = htmlspecialchars($_POST['valve_visibility'], ENT_QUOTES);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if ($valve_id_old != $valve_id) {
|
||||||
|
$result = $pdo -> query("SELECT *from valves where valve_id = '$valve_id' ");
|
||||||
|
|
||||||
|
if ($result -> rowCount()>0) {
|
||||||
|
echo "ERROR: Valve ID already exists. Please choose a new ID";
|
||||||
|
} else {
|
||||||
|
$pdo -> query("UPDATE valves set valve_id = '$valve_id', valve_dma_id = '$valve_dma_id', valve_type = '$valve_type', valve_diameter = '$valve_diameter', valve_location = '$valve_location', valve_visibility = '$valve_visibility' where webgis_id = '$webgis_id' ");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$pdo -> query("UPDATE valves set valve_id = '$valve_id', valve_dma_id = '$valve_dma_id', valve_type = '$valve_type', valve_diameter = '$valve_diameter', valve_location = '$valve_location', valve_visibility = '$valve_visibility' where webgis_id = '$webgis_id' ");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(PDOException $e) {
|
||||||
|
echo "ERROR ".$e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -31,5 +31,6 @@ CREATE INDEX idx_comments_browser ON comments(browser_id);
|
|||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
ALTER TABLE contributions
|
ALTER TABLE contributions
|
||||||
ADD COLUMN photo_path VARCHAR(255) DEFAULT NULL;
|
ADD COLUMN photo_path VARCHAR(255) DEFAULT NULL;
|
||||||
|
ADD COLUMN comment_count INTEGER NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
COMMENT ON COLUMN contributions.photo_path IS 'Relative Path to uploaded Photo. NULL = no Photo.';
|
COMMENT ON COLUMN contributions.photo_path IS 'Relative Path to uploaded Photo. NULL = no Photo.';
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
-- =====================================================================
|
|
||||||
-- Migration 007: Adds Status Column to Comments for Moderation
|
|
||||||
-- =====================================================================
|
|
||||||
|
|
||||||
-- Adds Status Column with Default 'pending'
|
|
||||||
ALTER TABLE comments
|
|
||||||
ADD COLUMN status VARCHAR(20) NOT NULL DEFAULT 'pending'
|
|
||||||
CHECK (status IN ('pending', 'approved', 'rejected'));
|
|
||||||
|
|
||||||
-- Index for fast Status Filtering
|
|
||||||
CREATE INDEX idx_comments_status ON comments(status);
|
|
||||||
|
|
||||||
-- Approves existing Comments
|
|
||||||
UPDATE comments SET status = 'approved';
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
-- =====================================================================
|
|
||||||
-- Migration 008: Adds comment_count Column with automatic Trigger
|
|
||||||
-- Mirrors Pattern from likes_count and dislikes_count.
|
|
||||||
-- =====================================================================
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 1: Adds comment_count Column to Contributions
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
ALTER TABLE contributions
|
|
||||||
ADD COLUMN comment_count INTEGER NOT NULL DEFAULT 0;
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 2: Backfills existing Comment Counts
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
UPDATE contributions c
|
|
||||||
SET comment_count = (
|
|
||||||
SELECT COUNT(*)
|
|
||||||
FROM comments cm
|
|
||||||
WHERE cm.contribution_id = c.contribution_id
|
|
||||||
AND cm.status = 'approved'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 3: Trigger Function to update comment_count
|
|
||||||
-- Fires on Status Change on comments. Only counts approved Comments
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
CREATE OR REPLACE FUNCTION update_comment_count()
|
|
||||||
RETURNS TRIGGER AS $$
|
|
||||||
BEGIN
|
|
||||||
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
|
|
||||||
UPDATE contributions
|
|
||||||
SET comment_count = (
|
|
||||||
SELECT COUNT(*) FROM comments
|
|
||||||
WHERE contribution_id = NEW.contribution_id
|
|
||||||
AND status = 'approved'
|
|
||||||
)
|
|
||||||
WHERE contribution_id = NEW.contribution_id;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF TG_OP = 'DELETE' OR (TG_OP = 'UPDATE' AND OLD.contribution_id != NEW.contribution_id) THEN
|
|
||||||
UPDATE contributions
|
|
||||||
SET comment_count = (
|
|
||||||
SELECT COUNT(*) FROM comments
|
|
||||||
WHERE contribution_id = OLD.contribution_id
|
|
||||||
AND status = 'approved'
|
|
||||||
)
|
|
||||||
WHERE contribution_id = OLD.contribution_id;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 4: Attaches Trigger to comments Table
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
CREATE TRIGGER trigger_update_comment_count
|
|
||||||
AFTER INSERT OR DELETE OR UPDATE OF status
|
|
||||||
ON comments
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE FUNCTION update_comment_count();
|
|
||||||
@@ -1,181 +0,0 @@
|
|||||||
-- =====================================================================
|
|
||||||
-- Migration 009: Tasks Module — Tasks with Reward System
|
|
||||||
-- =====================================================================
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 1: Tasks Table
|
|
||||||
-- Stores community Tasks with Geometry, Moderation and Completion.
|
|
||||||
-- Status Flow: pending → rejected | open → completed → verified
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
CREATE TABLE IF NOT EXISTS tasks (
|
|
||||||
task_id SERIAL PRIMARY KEY,
|
|
||||||
municipality_id INTEGER NOT NULL REFERENCES municipalities(municipality_id),
|
|
||||||
geom GEOMETRY(Geometry, 4326) NOT NULL,
|
|
||||||
geom_type VARCHAR(10) NOT NULL CHECK (geom_type IN ('point', 'line', 'polygon')),
|
|
||||||
category VARCHAR(50) NOT NULL,
|
|
||||||
title VARCHAR(200) NOT NULL,
|
|
||||||
description TEXT DEFAULT '',
|
|
||||||
points_reward INTEGER NOT NULL DEFAULT 25,
|
|
||||||
author_name VARCHAR(100) NOT NULL,
|
|
||||||
browser_id VARCHAR(36),
|
|
||||||
photo_path VARCHAR(255),
|
|
||||||
status VARCHAR(20) NOT NULL DEFAULT 'pending'
|
|
||||||
CHECK (status IN ('pending', 'rejected', 'open', 'completed', 'verified')),
|
|
||||||
address VARCHAR(255),
|
|
||||||
|
|
||||||
-- Completion Fields (NULL until completed)
|
|
||||||
completed_by_name VARCHAR(100),
|
|
||||||
completed_by_browser VARCHAR(36),
|
|
||||||
completion_photo VARCHAR(255),
|
|
||||||
completion_comment TEXT,
|
|
||||||
completed_at TIMESTAMP,
|
|
||||||
|
|
||||||
-- Counters (updated via Triggers)
|
|
||||||
likes_count INTEGER NOT NULL DEFAULT 0,
|
|
||||||
dislikes_count INTEGER NOT NULL DEFAULT 0,
|
|
||||||
comment_count INTEGER NOT NULL DEFAULT 0,
|
|
||||||
|
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE INDEX idx_tasks_municipality ON tasks(municipality_id);
|
|
||||||
CREATE INDEX idx_tasks_status ON tasks(status);
|
|
||||||
CREATE INDEX idx_tasks_category ON tasks(category);
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 2: User Points Table
|
|
||||||
-- One Entry per verified Task Completion. Leaderboard via SUM/GROUP BY.
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
CREATE TABLE IF NOT EXISTS user_points (
|
|
||||||
points_id SERIAL PRIMARY KEY,
|
|
||||||
municipality_id INTEGER NOT NULL REFERENCES municipalities(municipality_id),
|
|
||||||
user_name VARCHAR(100) NOT NULL,
|
|
||||||
points INTEGER NOT NULL DEFAULT 25,
|
|
||||||
task_id INTEGER NOT NULL REFERENCES tasks(task_id) ON DELETE CASCADE,
|
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT NOW()
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE INDEX idx_user_points_municipality ON user_points(municipality_id);
|
|
||||||
CREATE INDEX idx_user_points_user ON user_points(user_name);
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 3: Extends Votes Table for Tasks
|
|
||||||
-- Either contribution_id OR task_id is set, not both.
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
ALTER TABLE votes
|
|
||||||
ADD COLUMN task_id INTEGER REFERENCES tasks(task_id) ON DELETE CASCADE;
|
|
||||||
|
|
||||||
CREATE INDEX idx_votes_task ON votes(task_id);
|
|
||||||
|
|
||||||
-- Unique Vote per Browser per Task
|
|
||||||
ALTER TABLE votes
|
|
||||||
ADD CONSTRAINT votes_task_browser_unique
|
|
||||||
UNIQUE (task_id, browser_id);
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 4: Extends Comments Table for Tasks
|
|
||||||
-- Either contribution_id OR task_id is set, not both.
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
ALTER TABLE comments
|
|
||||||
ADD COLUMN task_id INTEGER REFERENCES tasks(task_id) ON DELETE CASCADE;
|
|
||||||
|
|
||||||
CREATE INDEX idx_comments_task ON comments(task_id);
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 5: Trigger — updated_at Timestamp for Tasks
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
CREATE TRIGGER set_tasks_updated_at
|
|
||||||
BEFORE UPDATE ON tasks
|
|
||||||
FOR EACH ROW
|
|
||||||
EXECUTE FUNCTION set_updated_at();
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 6: Trigger — Vote Counts for Tasks
|
|
||||||
-- Mirrors the Pattern from Contributions.
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
CREATE OR REPLACE FUNCTION update_task_vote_counts()
|
|
||||||
RETURNS TRIGGER AS $$
|
|
||||||
BEGIN
|
|
||||||
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
|
|
||||||
IF NEW.task_id IS NOT NULL THEN
|
|
||||||
UPDATE tasks SET
|
|
||||||
likes_count = (SELECT COUNT(*) FROM votes WHERE task_id = NEW.task_id AND vote_type = 'like'),
|
|
||||||
dislikes_count = (SELECT COUNT(*) FROM votes WHERE task_id = NEW.task_id AND vote_type = 'dislike')
|
|
||||||
WHERE task_id = NEW.task_id;
|
|
||||||
END IF;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF TG_OP = 'DELETE' OR (TG_OP = 'UPDATE' AND OLD.task_id IS NOT NULL) THEN
|
|
||||||
UPDATE tasks SET
|
|
||||||
likes_count = (SELECT COUNT(*) FROM votes WHERE task_id = OLD.task_id AND vote_type = 'like'),
|
|
||||||
dislikes_count = (SELECT COUNT(*) FROM votes WHERE task_id = OLD.task_id AND vote_type = 'dislike')
|
|
||||||
WHERE task_id = OLD.task_id;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
|
|
||||||
CREATE TRIGGER trigger_update_task_vote_counts
|
|
||||||
AFTER INSERT OR DELETE OR UPDATE ON votes
|
|
||||||
FOR EACH ROW
|
|
||||||
WHEN (NEW.task_id IS NOT NULL OR OLD.task_id IS NOT NULL)
|
|
||||||
EXECUTE FUNCTION update_task_vote_counts();
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 7: Trigger — Comment Count for Tasks
|
|
||||||
-- Only counts approved Comments. Mirrors Contribution Pattern.
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
CREATE OR REPLACE FUNCTION update_task_comment_count()
|
|
||||||
RETURNS TRIGGER AS $$
|
|
||||||
BEGIN
|
|
||||||
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
|
|
||||||
IF NEW.task_id IS NOT NULL THEN
|
|
||||||
UPDATE tasks
|
|
||||||
SET comment_count = (
|
|
||||||
SELECT COUNT(*) FROM comments
|
|
||||||
WHERE task_id = NEW.task_id AND status = 'approved'
|
|
||||||
)
|
|
||||||
WHERE task_id = NEW.task_id;
|
|
||||||
END IF;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
IF TG_OP = 'DELETE' OR (TG_OP = 'UPDATE' AND OLD.task_id IS NOT NULL) THEN
|
|
||||||
UPDATE tasks
|
|
||||||
SET comment_count = (
|
|
||||||
SELECT COUNT(*) FROM comments
|
|
||||||
WHERE task_id = OLD.task_id AND status = 'approved'
|
|
||||||
)
|
|
||||||
WHERE task_id = OLD.task_id;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
RETURN NULL;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE plpgsql;
|
|
||||||
|
|
||||||
CREATE TRIGGER trigger_update_task_comment_count
|
|
||||||
AFTER INSERT OR DELETE OR UPDATE OF status ON comments
|
|
||||||
FOR EACH ROW
|
|
||||||
WHEN (NEW.task_id IS NOT NULL OR OLD.task_id IS NOT NULL)
|
|
||||||
EXECUTE FUNCTION update_task_comment_count();
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
-- Block 8: Views for QGIS (optional)
|
|
||||||
-- ---------------------------------------------------------------------
|
|
||||||
CREATE OR REPLACE VIEW tasks_points AS
|
|
||||||
SELECT * FROM tasks WHERE geom_type = 'point';
|
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW tasks_lines AS
|
|
||||||
SELECT * FROM tasks WHERE geom_type = 'line';
|
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW tasks_polygons AS
|
|
||||||
SELECT * FROM tasks WHERE geom_type = 'polygon';
|
|
||||||
669
public/admin.php
669
public/admin.php
@@ -3,6 +3,12 @@
|
|||||||
// Moderation Page
|
// Moderation Page
|
||||||
// Lists Contributions for Review. Moderators can approve, reject,
|
// Lists Contributions for Review. Moderators can approve, reject,
|
||||||
// edit and delete Contributions. Includes Map Preview and Filtering.
|
// edit and delete Contributions. Includes Map Preview and Filtering.
|
||||||
|
//
|
||||||
|
// ToDo's:
|
||||||
|
// - Comment Moderation Tab
|
||||||
|
// - News Management Tab
|
||||||
|
// - User Management Tab
|
||||||
|
// - Analytics Tab
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
|
|
||||||
// Reads Environment Configfile
|
// Reads Environment Configfile
|
||||||
@@ -51,7 +57,6 @@ $stmt = $pdo->prepare("SELECT * FROM municipalities WHERE slug = :slug");
|
|||||||
$stmt->execute([':slug' => getenv('MUNICIPALITY_SLUG')]);
|
$stmt->execute([':slug' => getenv('MUNICIPALITY_SLUG')]);
|
||||||
$municipality = $stmt->fetch();
|
$municipality = $stmt->fetch();
|
||||||
|
|
||||||
|
|
||||||
// Loads News for Moderation
|
// Loads News for Moderation
|
||||||
$stmt = $pdo->prepare("
|
$stmt = $pdo->prepare("
|
||||||
SELECT news_id, title, content, author_name, published_at, created_at
|
SELECT news_id, title, content, author_name, published_at, created_at
|
||||||
@@ -62,30 +67,6 @@ $stmt = $pdo->prepare("
|
|||||||
$stmt->execute([':mid' => $municipality['municipality_id']]);
|
$stmt->execute([':mid' => $municipality['municipality_id']]);
|
||||||
$news_items = $stmt->fetchAll();
|
$news_items = $stmt->fetchAll();
|
||||||
|
|
||||||
|
|
||||||
// Loads all Comments with Contribution Titles for Moderation
|
|
||||||
$stmt = $pdo->prepare("
|
|
||||||
SELECT cm.comment_id, cm.contribution_id, cm.author_name, cm.browser_id,
|
|
||||||
cm.content, cm.status, cm.created_at,
|
|
||||||
co.title AS contribution_title, co.category AS contribution_category
|
|
||||||
FROM comments cm
|
|
||||||
JOIN contributions co ON cm.contribution_id = co.contribution_id
|
|
||||||
WHERE co.municipality_id = :mid
|
|
||||||
ORDER BY cm.created_at DESC
|
|
||||||
");
|
|
||||||
$stmt->execute([':mid' => $municipality['municipality_id']]);
|
|
||||||
$all_comments = $stmt->fetchAll();
|
|
||||||
|
|
||||||
// Counts Comments per Status
|
|
||||||
$comment_counts = ['pending' => 0, 'approved' => 0, 'rejected' => 0];
|
|
||||||
foreach ($all_comments as $c) {
|
|
||||||
if (isset($comment_counts[$c['status']])) {
|
|
||||||
$comment_counts[$c['status']]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$comment_counts['total'] = count($all_comments);
|
|
||||||
|
|
||||||
|
|
||||||
// Shows Login Page if not authenticated
|
// Shows Login Page if not authenticated
|
||||||
if ($page === 'login' || !is_admin()) {
|
if ($page === 'login' || !is_admin()) {
|
||||||
show_login_page($municipality, $login_error ?? null);
|
show_login_page($municipality, $login_error ?? null);
|
||||||
@@ -103,8 +84,8 @@ $categories = get_categories();
|
|||||||
|
|
||||||
// Loads all Contributions for Municipality
|
// Loads all Contributions for Municipality
|
||||||
$stmt = $pdo->prepare("
|
$stmt = $pdo->prepare("
|
||||||
SELECT contribution_id, title, category, description, author_name, photo_path,
|
SELECT contribution_id, title, category, description, author_name,
|
||||||
geom_type, status, likes_count, dislikes_count, comment_count, created_at, updated_at
|
geom_type, status, likes_count, dislikes_count, created_at, updated_at
|
||||||
FROM contributions
|
FROM contributions
|
||||||
WHERE municipality_id = :mid
|
WHERE municipality_id = :mid
|
||||||
ORDER BY created_at DESC
|
ORDER BY created_at DESC
|
||||||
@@ -131,7 +112,7 @@ $counts['total'] = count($all_contributions);
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Moderation — <?= htmlspecialchars($municipality['name']) ?></title>
|
<title>Moderation — <?= htmlspecialchars($municipality['name']) ?></title>
|
||||||
<link rel="icon" href="assets/shield-halved-solid-off-black.png" type="image/png">
|
<link rel="icon" href="<?= htmlspecialchars($municipality['logo_path'] ?? 'assets/icon-municipality.png') ?>" type="image/png">
|
||||||
|
|
||||||
<!-- Loads CSS Dependencies -->
|
<!-- Loads CSS Dependencies -->
|
||||||
|
|
||||||
@@ -178,9 +159,6 @@ $counts['total'] = count($all_contributions);
|
|||||||
<button class="page-tab active" onclick="showPageTab('contributions')">
|
<button class="page-tab active" onclick="showPageTab('contributions')">
|
||||||
<i class="fa-solid fa-list-check"></i> Beiträge
|
<i class="fa-solid fa-list-check"></i> Beiträge
|
||||||
</button>
|
</button>
|
||||||
<button class="page-tab" onclick="showPageTab('comments')">
|
|
||||||
<i class="fa-solid fa-comments"></i> Kommentare
|
|
||||||
</button>
|
|
||||||
<button class="page-tab" onclick="showPageTab('news')">
|
<button class="page-tab" onclick="showPageTab('news')">
|
||||||
<i class="fa-solid fa-newspaper"></i> Neuigkeiten
|
<i class="fa-solid fa-newspaper"></i> Neuigkeiten
|
||||||
</button>
|
</button>
|
||||||
@@ -198,6 +176,27 @@ $counts['total'] = count($all_contributions);
|
|||||||
<!-- ========================================================= -->
|
<!-- ========================================================= -->
|
||||||
<div id="tab-contributions" class="page-tab-content">
|
<div id="tab-contributions" class="page-tab-content">
|
||||||
|
|
||||||
|
<!-- Statistics Cards -->
|
||||||
|
<div class="stats-grid">
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-number"><?= $counts['total'] ?></div>
|
||||||
|
<div class="stat-label">Alle</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-number"><?= $counts['pending'] ?></div>
|
||||||
|
<div class="stat-label">Ausstehend</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-number"><?= $counts['approved'] ?></div>
|
||||||
|
<div class="stat-label">Akzeptiert</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-number"><?= $counts['rejected'] ?></div>
|
||||||
|
<div class="stat-label">Abgelehnt</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Status Filter Tabs -->
|
<!-- Status Filter Tabs -->
|
||||||
<div class="filter-tabs">
|
<div class="filter-tabs">
|
||||||
<button class="filter-tab active" onclick="filterByStatus('all', this)">
|
<button class="filter-tab active" onclick="filterByStatus('all', this)">
|
||||||
@@ -258,28 +257,9 @@ $counts['total'] = count($all_contributions);
|
|||||||
<!-- Expanded Detail -->
|
<!-- Expanded Detail -->
|
||||||
<div class="contribution-row-detail">
|
<div class="contribution-row-detail">
|
||||||
<div class="detail-layout">
|
<div class="detail-layout">
|
||||||
<!-- Map and Photo Slider -->
|
<!-- Map Preview -->
|
||||||
<div class="detail-slider" id="slider-<?= $item['contribution_id'] ?>">
|
<div class="detail-map" id="map-<?= $item['contribution_id'] ?>"
|
||||||
<!-- Slide 1: Map -->
|
data-contribution-id="<?= $item['contribution_id'] ?>">
|
||||||
<div class="detail-slide active" data-slide="map">
|
|
||||||
<div class="detail-map" id="map-<?= $item['contribution_id'] ?>"
|
|
||||||
data-contribution-id="<?= $item['contribution_id'] ?>">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php if (!empty($item['photo_path'])): ?>
|
|
||||||
<!-- Slide 2: Photo -->
|
|
||||||
<div class="detail-slide" data-slide="photo" style="display:none;">
|
|
||||||
<img src="<?= htmlspecialchars($item['photo_path']) ?>" alt="Foto"
|
|
||||||
class="detail-slide-photo" onclick="window.open('<?= htmlspecialchars($item['photo_path']) ?>', '_blank')">
|
|
||||||
</div>
|
|
||||||
<!-- Slider Arrows -->
|
|
||||||
<button class="slider-arrow slider-arrow-left" onclick="slideDetail(<?= $item['contribution_id'] ?>, -1)">
|
|
||||||
<i class="fa-solid fa-chevron-left"></i>
|
|
||||||
</button>
|
|
||||||
<button class="slider-arrow slider-arrow-right" onclick="slideDetail(<?= $item['contribution_id'] ?>, 1)">
|
|
||||||
<i class="fa-solid fa-chevron-right"></i>
|
|
||||||
</button>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
@@ -297,10 +277,6 @@ $counts['total'] = count($all_contributions);
|
|||||||
<i class="fa-solid fa-thumbs-up"></i> <?= $item['likes_count'] ?>
|
<i class="fa-solid fa-thumbs-up"></i> <?= $item['likes_count'] ?>
|
||||||
·
|
·
|
||||||
<i class="fa-solid fa-thumbs-down"></i> <?= $item['dislikes_count'] ?>
|
<i class="fa-solid fa-thumbs-down"></i> <?= $item['dislikes_count'] ?>
|
||||||
·
|
|
||||||
<i class="fa-solid fa-comment"></i> <?= $item['comment_count'] ?? 0 ?>
|
|
||||||
|
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -321,7 +297,7 @@ $counts['total'] = count($all_contributions);
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($item['status'] !== 'pending'): ?>
|
<?php if ($item['status'] !== 'pending'): ?>
|
||||||
<button class="btn btn-reset" onclick="changeStatus(<?= $item['contribution_id'] ?>, 'pending')">
|
<button class="btn btn-reset" onclick="changeStatus(..., 'pending')">
|
||||||
<i class="fa-solid fa-rotate-left"></i> Zurücksetzen
|
<i class="fa-solid fa-rotate-left"></i> Zurücksetzen
|
||||||
</button>
|
</button>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@@ -346,113 +322,6 @@ $counts['total'] = count($all_contributions);
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- ========================================================= -->
|
|
||||||
<!-- Comments Moderation Tab -->
|
|
||||||
<!-- ========================================================= -->
|
|
||||||
<div id="tab-comments" class="page-tab-content" style="display:none;">
|
|
||||||
|
|
||||||
<!-- Status Filter Tabs for Comments -->
|
|
||||||
<div class="filter-tabs" id="comment-filter-tabs">
|
|
||||||
<button class="filter-tab active" onclick="filterCommentsByStatus('all', this)">
|
|
||||||
Alle <span class="tab-count"><?= $comment_counts['total'] ?></span>
|
|
||||||
</button>
|
|
||||||
<button class="filter-tab" onclick="filterCommentsByStatus('pending', this)">
|
|
||||||
Ausstehend <span class="tab-count"><?= $comment_counts['pending'] ?></span>
|
|
||||||
</button>
|
|
||||||
<button class="filter-tab" onclick="filterCommentsByStatus('approved', this)">
|
|
||||||
Akzeptiert <span class="tab-count"><?= $comment_counts['approved'] ?></span>
|
|
||||||
</button>
|
|
||||||
<button class="filter-tab" onclick="filterCommentsByStatus('rejected', this)">
|
|
||||||
Abgelehnt <span class="tab-count"><?= $comment_counts['rejected'] ?></span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Sort Controls -->
|
|
||||||
<div class="sort-controls">
|
|
||||||
<span id="comment-visible-count"><?= $comment_counts['total'] ?> Kommentare</span>
|
|
||||||
<select onchange="sortCommentRows(this.value)">
|
|
||||||
<option value="date-desc">Neueste zuerst</option>
|
|
||||||
<option value="date-asc">Älteste zuerst</option>
|
|
||||||
<option value="contribution">Nach Beitrag</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Comments List -->
|
|
||||||
<div id="comments-mod-container">
|
|
||||||
<?php if (empty($all_comments)): ?>
|
|
||||||
<div class="empty-state">
|
|
||||||
<i class="fa-solid fa-comments" style="font-size:2rem;margin-bottom:8px;display:block;"></i>
|
|
||||||
Noch keine Kommentare vorhanden.
|
|
||||||
</div>
|
|
||||||
<?php else: ?>
|
|
||||||
<?php foreach ($all_comments as $comment):
|
|
||||||
$comment_cat = $categories[$comment['contribution_category'] ?? ''] ?? ['label' => 'Unbekannt', 'faIcon' => 'fa-question', 'color' => '#999'];
|
|
||||||
$comment_status_label = ['pending' => 'Ausstehend', 'approved' => 'Akzeptiert', 'rejected' => 'Abgelehnt'];
|
|
||||||
?>
|
|
||||||
<div class="contribution-row comment-mod-row"
|
|
||||||
data-status="<?= $comment['status'] ?>"
|
|
||||||
data-date="<?= $comment['created_at'] ?>"
|
|
||||||
data-contribution="<?= htmlspecialchars($comment['contribution_title']) ?>">
|
|
||||||
|
|
||||||
<!-- Collapsed: Contribution Title + Comment Status + Category -->
|
|
||||||
<div class="contribution-row-header" onclick="toggleRow(this.parentElement)">
|
|
||||||
<div class="contribution-row-summary">
|
|
||||||
<span class="title"><?= htmlspecialchars($comment['contribution_title']) ?></span>
|
|
||||||
<span class="badge badge-<?= $comment['status'] ?>"><?= $comment_status_label[$comment['status']] ?? $comment['status'] ?></span>
|
|
||||||
<span class="badge badge-category">
|
|
||||||
<i class="fa-solid <?= $comment_cat['faIcon'] ?>"></i>
|
|
||||||
<?= $comment_cat['label'] ?>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<i class="fa-solid fa-chevron-down collapse-icon"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Expanded Detail -->
|
|
||||||
<div class="contribution-row-detail">
|
|
||||||
<div style="padding:12px 0;">
|
|
||||||
<!-- Comment Content -->
|
|
||||||
<div style="font-size:0.9rem;line-height:1.6;color:var(--color-text);margin-bottom:12px;">
|
|
||||||
<?= nl2br(htmlspecialchars($comment['content'])) ?>
|
|
||||||
</div>
|
|
||||||
<!-- Meta -->
|
|
||||||
<div class="detail-meta">
|
|
||||||
<span><i class="fa-solid fa-user"></i> <?= htmlspecialchars($comment['author_name']) ?></span>
|
|
||||||
<span><i class="fa-solid fa-calendar"></i> <?= date('d.m.Y, H:i', strtotime($comment['created_at'])) ?> Uhr</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Action Buttons -->
|
|
||||||
<div class="action-buttons">
|
|
||||||
<?php if ($comment['status'] !== 'approved'): ?>
|
|
||||||
<button class="btn btn-approve" onclick="changeCommentStatus(<?= $comment['comment_id'] ?>, 'approved')">
|
|
||||||
<i class="fa-solid fa-check"></i> Akzeptieren
|
|
||||||
</button>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ($comment['status'] !== 'rejected'): ?>
|
|
||||||
<button class="btn btn-reject" onclick="changeCommentStatus(<?= $comment['comment_id'] ?>, 'rejected')">
|
|
||||||
<i class="fa-solid fa-xmark"></i> Ablehnen
|
|
||||||
</button>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ($comment['status'] !== 'pending'): ?>
|
|
||||||
<button class="btn btn-reset" onclick="changeCommentStatus(<?= $comment['comment_id'] ?>, 'pending')">
|
|
||||||
<i class="fa-solid fa-rotate-left"></i> Zurücksetzen
|
|
||||||
</button>
|
|
||||||
<?php endif; ?>
|
|
||||||
<button class="btn btn-edit" onclick="editModComment(<?= $comment['comment_id'] ?>, '<?= htmlspecialchars(addslashes($comment['content']), ENT_QUOTES) ?>')">
|
|
||||||
<i class="fa-solid fa-pen"></i> Bearbeiten
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-delete" onclick="deleteModComment(<?= $comment['comment_id'] ?>)">
|
|
||||||
<i class="fa-solid fa-trash"></i> Löschen
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- ========================================================= -->
|
<!-- ========================================================= -->
|
||||||
<!-- News Article Tab -->
|
<!-- News Article Tab -->
|
||||||
<!-- ========================================================= -->
|
<!-- ========================================================= -->
|
||||||
@@ -522,27 +391,463 @@ $counts['total'] = count($all_contributions);
|
|||||||
|
|
||||||
|
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
<!-- Loads JavaScript Dependencies -->
|
<!-- JavaScript: Leaflet, Interactions, API Calls -->
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<!-- ============================================================= -->
|
|
||||||
<!-- Admin Configuration passed to JavaScript -->
|
|
||||||
<!-- ============================================================= -->
|
|
||||||
<script>
|
<script>
|
||||||
const ADMIN_CONFIG = {
|
// Municipality Configuration for Map Previews
|
||||||
id: <?= $municipality['municipality_id'] ?>,
|
const MUNICIPALITY_CENTER = [<?= $municipality['center_lat'] ?>, <?= $municipality['center_lng'] ?>];
|
||||||
name: "<?= htmlspecialchars($municipality['name'], ENT_QUOTES) ?>",
|
const MUNICIPALITY_ID = <?= $municipality['municipality_id'] ?>;
|
||||||
slug: "<?= htmlspecialchars($municipality['slug'], ENT_QUOTES) ?>",
|
const API_URL = 'api/contributions.php';
|
||||||
center: [<?= $municipality['center_lat'] ?>, <?= $municipality['center_lng'] ?>],
|
const PRIMARY_COLOR = '<?= htmlspecialchars($municipality['primary_color']) ?>';
|
||||||
zoom: <?= $municipality['default_zoom'] ?>,
|
|
||||||
primaryColor: "<?= htmlspecialchars($municipality['primary_color'], ENT_QUOTES) ?>"
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- Application Logic -->
|
// Current Status Filter
|
||||||
<script src="js/admin.js"></script>
|
let currentFilter = 'all';
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Page Tab Navigation
|
||||||
|
// =============================================================
|
||||||
|
|
||||||
|
function showPageTab(tabName) {
|
||||||
|
// Hides all Tab Contents
|
||||||
|
document.querySelectorAll('.page-tab-content').forEach(function (el) {
|
||||||
|
el.style.display = 'none';
|
||||||
|
});
|
||||||
|
|
||||||
|
// Deactivates all Tab Buttons
|
||||||
|
document.querySelectorAll('.page-tab').forEach(function (el) {
|
||||||
|
el.classList.remove('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Shows selected Tab and activates Button
|
||||||
|
document.getElementById('tab-' + tabName).style.display = 'block';
|
||||||
|
event.currentTarget.classList.add('active');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Collapsible Rows
|
||||||
|
// =============================================================
|
||||||
|
|
||||||
|
function toggleRow(row) {
|
||||||
|
const wasOpen = row.classList.contains('open');
|
||||||
|
|
||||||
|
// Closes all open Rows
|
||||||
|
document.querySelectorAll('.contribution-row.open').forEach(function (el) {
|
||||||
|
el.classList.remove('open');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Toggles clicked Row
|
||||||
|
if (!wasOpen) {
|
||||||
|
row.classList.add('open');
|
||||||
|
|
||||||
|
// Loads Map Preview if not already loaded
|
||||||
|
const mapDiv = row.querySelector('.detail-map');
|
||||||
|
if (mapDiv && !mapDiv.dataset.loaded) {
|
||||||
|
loadMapPreview(mapDiv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Map Preview (Leaflet Mini Map per Contribution)
|
||||||
|
// =============================================================
|
||||||
|
|
||||||
|
function loadMapPreview(mapDiv) {
|
||||||
|
const contributionId = mapDiv.dataset.contributionId;
|
||||||
|
|
||||||
|
// Fetches all Contributions to find the Geometry
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('action', 'read');
|
||||||
|
formData.append('municipality_id', MUNICIPALITY_ID);
|
||||||
|
formData.append('status', 'all');
|
||||||
|
|
||||||
|
fetch(API_URL, { method: 'POST', body: formData })
|
||||||
|
.then(function (r) { return r.json(); })
|
||||||
|
.then(function (data) {
|
||||||
|
if (!data.features) return;
|
||||||
|
|
||||||
|
// Finds specific Contribution
|
||||||
|
const feature = data.features.find(function (f) {
|
||||||
|
return f.properties.contribution_id == contributionId;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!feature) {
|
||||||
|
mapDiv.innerHTML = '<div style="padding:20px;color:#999;text-align:center;font-size:0.8rem;">Geometrie nicht gefunden.</div>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creates Leaflet Mini Map
|
||||||
|
const miniMap = L.map(mapDiv, {
|
||||||
|
zoomControl: false,
|
||||||
|
attributionControl: false,
|
||||||
|
dragging: true,
|
||||||
|
scrollWheelZoom: false
|
||||||
|
});
|
||||||
|
|
||||||
|
L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', {
|
||||||
|
maxZoom: 20
|
||||||
|
}).addTo(miniMap);
|
||||||
|
|
||||||
|
// Adds Geometry to Mini Map
|
||||||
|
const geojsonLayer = L.geoJSON(feature, {
|
||||||
|
style: { color: PRIMARY_COLOR, weight: 3, fillOpacity: 0.2 },
|
||||||
|
pointToLayer: function (f, latlng) {
|
||||||
|
return L.circleMarker(latlng, {
|
||||||
|
radius: 8, color: '#ffffff', weight: 2,
|
||||||
|
fillColor: PRIMARY_COLOR, fillOpacity: 0.9
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).addTo(miniMap);
|
||||||
|
|
||||||
|
// Fits Map to Geometry Bounds
|
||||||
|
const bounds = geojsonLayer.getBounds();
|
||||||
|
if (bounds.isValid()) {
|
||||||
|
miniMap.fitBounds(bounds, { padding: [25, 25], maxZoom: 17 });
|
||||||
|
} else {
|
||||||
|
miniMap.setView(MUNICIPALITY_CENTER, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
mapDiv.dataset.loaded = 'true';
|
||||||
|
})
|
||||||
|
.catch(function () {
|
||||||
|
mapDiv.innerHTML = '<div style="padding:20px;color:#999;text-align:center;font-size:0.8rem;">Karte nicht verfügbar.</div>';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Status Filter
|
||||||
|
// =============================================================
|
||||||
|
|
||||||
|
function filterByStatus(status, tabButton) {
|
||||||
|
currentFilter = status;
|
||||||
|
|
||||||
|
// Updates active Tab
|
||||||
|
document.querySelectorAll('.filter-tab').forEach(function (el) {
|
||||||
|
el.classList.remove('active');
|
||||||
|
});
|
||||||
|
tabButton.classList.add('active');
|
||||||
|
|
||||||
|
// Shows/Hides Contribution Rows
|
||||||
|
let visibleCount = 0;
|
||||||
|
document.querySelectorAll('.contribution-row').forEach(function (row) {
|
||||||
|
if (status === 'all' || row.dataset.status === status) {
|
||||||
|
row.style.display = '';
|
||||||
|
visibleCount++;
|
||||||
|
} else {
|
||||||
|
row.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Updates Count Display
|
||||||
|
document.getElementById('visible-count').textContent = visibleCount + ' Beiträge';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Sort Contributions
|
||||||
|
// =============================================================
|
||||||
|
|
||||||
|
function sortContributions(sortBy) {
|
||||||
|
const container = document.getElementById('contributions-container');
|
||||||
|
const rows = Array.from(container.querySelectorAll('.contribution-row'));
|
||||||
|
|
||||||
|
rows.sort(function (a, b) {
|
||||||
|
if (sortBy === 'date-desc') {
|
||||||
|
return new Date(b.dataset.date) - new Date(a.dataset.date);
|
||||||
|
} else if (sortBy === 'date-asc') {
|
||||||
|
return new Date(a.dataset.date) - new Date(b.dataset.date);
|
||||||
|
} else if (sortBy === 'category') {
|
||||||
|
return a.dataset.category.localeCompare(b.dataset.category);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reappends sorted Rows
|
||||||
|
rows.forEach(function (row) {
|
||||||
|
container.appendChild(row);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// API Helper
|
||||||
|
// =============================================================
|
||||||
|
|
||||||
|
function apiCall(data) {
|
||||||
|
const formData = new FormData();
|
||||||
|
for (const key in data) {
|
||||||
|
formData.append(key, data[key]);
|
||||||
|
}
|
||||||
|
return fetch(API_URL, { method: 'POST', body: formData })
|
||||||
|
.then(function (r) { return r.json(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Change Contribution Status
|
||||||
|
// =============================================================
|
||||||
|
|
||||||
|
function changeStatus(contributionId, newStatus) {
|
||||||
|
const labels = { approved: 'freigeben', rejected: 'ablehnen', pending: 'zurücksetzen' };
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Beitrag ' + labels[newStatus] + '?',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Ja',
|
||||||
|
cancelButtonText: 'Abbrechen',
|
||||||
|
confirmButtonColor: PRIMARY_COLOR
|
||||||
|
}).then(function (result) {
|
||||||
|
if (!result.isConfirmed) return;
|
||||||
|
|
||||||
|
apiCall({
|
||||||
|
action: 'update',
|
||||||
|
contribution_id: contributionId,
|
||||||
|
status: newStatus
|
||||||
|
}).then(function (response) {
|
||||||
|
if (response.error) {
|
||||||
|
Swal.fire('Fehler', response.error, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Reloads Page to reflect Changes
|
||||||
|
location.reload();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Edit Contribution (Title and Description)
|
||||||
|
// =============================================================
|
||||||
|
|
||||||
|
function editContribution(contributionId, currentTitle, currentDescription) {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Beitrag bearbeiten',
|
||||||
|
html:
|
||||||
|
'<div style="text-align:left;">' +
|
||||||
|
'<div style="margin-bottom:12px;">' +
|
||||||
|
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Titel</label>' +
|
||||||
|
'<input id="swal-title" class="swal2-input" style="margin:0;width:100%;" value="' + currentTitle + '">' +
|
||||||
|
'</div>' +
|
||||||
|
'<div>' +
|
||||||
|
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Beschreibung</label>' +
|
||||||
|
'<textarea id="swal-description" class="swal2-textarea" style="margin:0;width:100%;">' + currentDescription + '</textarea>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Speichern',
|
||||||
|
cancelButtonText: 'Abbrechen',
|
||||||
|
confirmButtonColor: PRIMARY_COLOR,
|
||||||
|
preConfirm: function () {
|
||||||
|
return {
|
||||||
|
title: document.getElementById('swal-title').value.trim(),
|
||||||
|
description: document.getElementById('swal-description').value.trim()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}).then(function (result) {
|
||||||
|
if (!result.isConfirmed) return;
|
||||||
|
|
||||||
|
apiCall({
|
||||||
|
action: 'update',
|
||||||
|
contribution_id: contributionId,
|
||||||
|
title: result.value.title,
|
||||||
|
description: result.value.description
|
||||||
|
}).then(function (response) {
|
||||||
|
if (response.error) {
|
||||||
|
Swal.fire('Fehler', response.error, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Swal.fire('Gespeichert!', 'Beitrag wurde aktualisiert.', 'success')
|
||||||
|
.then(function () { location.reload(); });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Delete Contribution
|
||||||
|
// =============================================================
|
||||||
|
|
||||||
|
function deleteContribution(contributionId) {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Beitrag löschen?',
|
||||||
|
text: 'Diese Aktion kann nicht rückgängig gemacht werden.',
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Beitrag löschen',
|
||||||
|
cancelButtonText: 'Abbrechen',
|
||||||
|
confirmButtonColor: '#c62828'
|
||||||
|
}).then(function (result) {
|
||||||
|
if (!result.isConfirmed) return;
|
||||||
|
|
||||||
|
apiCall({
|
||||||
|
action: 'delete',
|
||||||
|
contribution_id: contributionId
|
||||||
|
}).then(function (response) {
|
||||||
|
if (response.error) {
|
||||||
|
Swal.fire('Fehler', response.error, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Swal.fire('Gelöscht!', 'Beitrag wurde gelöscht.', 'success')
|
||||||
|
.then(function () { location.reload(); });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Create News Article
|
||||||
|
// =============================================================
|
||||||
|
|
||||||
|
function createNews() {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Neuigkeit hinzufügen',
|
||||||
|
html:
|
||||||
|
'<div style="text-align:left;">' +
|
||||||
|
'<div style="margin-bottom:12px;">' +
|
||||||
|
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Titel</label>' +
|
||||||
|
'<input id="swal-news-title" class="swal2-input" style="margin:0;width:100%;" placeholder="Titel der Neuigkeit">' +
|
||||||
|
'</div>' +
|
||||||
|
'<div style="margin-bottom:12px;">' +
|
||||||
|
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Inhalt</label>' +
|
||||||
|
'<textarea id="swal-news-content" class="swal2-textarea" style="margin:0;width:100%;" placeholder="Neuigkeit verfassen..."></textarea>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div>' +
|
||||||
|
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Autor</label>' +
|
||||||
|
'<input id="swal-news-author" class="swal2-input" style="margin:0;width:100%;" value="Stadtverwaltung">' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Veröffentlichen',
|
||||||
|
cancelButtonText: 'Abbrechen',
|
||||||
|
confirmButtonColor: PRIMARY_COLOR,
|
||||||
|
preConfirm: function () {
|
||||||
|
const title = document.getElementById('swal-news-title').value.trim();
|
||||||
|
const content = document.getElementById('swal-news-content').value.trim();
|
||||||
|
const author = document.getElementById('swal-news-author').value.trim() || 'Stadtverwaltung';
|
||||||
|
if (!title || !content) {
|
||||||
|
Swal.showValidationMessage('Titel und Inhalt sind Pflichtfelder.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return { title: title, content: content, author_name: author };
|
||||||
|
}
|
||||||
|
}).then(function (result) {
|
||||||
|
if (!result.isConfirmed) return;
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('action', 'create_news');
|
||||||
|
formData.append('municipality_id', MUNICIPALITY_ID);
|
||||||
|
formData.append('title', result.value.title);
|
||||||
|
formData.append('content', result.value.content);
|
||||||
|
formData.append('author_name', result.value.author_name);
|
||||||
|
|
||||||
|
fetch(API_URL, { method: 'POST', body: formData })
|
||||||
|
.then(function (r) { return r.json(); })
|
||||||
|
.then(function (response) {
|
||||||
|
if (response.error) {
|
||||||
|
Swal.fire('Fehler', response.error, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Swal.fire('Veröffentlicht!', 'Neuigkeit wurde veröffentlicht.', 'success')
|
||||||
|
.then(function () { location.reload(); });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Edit News Article
|
||||||
|
// =============================================================
|
||||||
|
function editNews(newsId, currentTitle, currentContent, currentAuthor) {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Neuigkeit bearbeiten',
|
||||||
|
html:
|
||||||
|
'<div style="text-align:left;">' +
|
||||||
|
'<div style="margin-bottom:12px;">' +
|
||||||
|
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Titel</label>' +
|
||||||
|
'<input id="swal-news-title" class="swal2-input" style="margin:0;width:100%;" value="' + currentTitle + '">' +
|
||||||
|
'</div>' +
|
||||||
|
'<div style="margin-bottom:12px;">' +
|
||||||
|
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Inhalt</label>' +
|
||||||
|
'<textarea id="swal-news-content" class="swal2-textarea" style="margin:0;width:100%;">' + currentContent + '</textarea>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div>' +
|
||||||
|
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Autor</label>' +
|
||||||
|
'<input id="swal-news-author" class="swal2-input" style="margin:0;width:100%;" value="' + currentAuthor + '">' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Speichern',
|
||||||
|
cancelButtonText: 'Abbrechen',
|
||||||
|
confirmButtonColor: PRIMARY_COLOR,
|
||||||
|
preConfirm: function () {
|
||||||
|
return {
|
||||||
|
title: document.getElementById('swal-news-title').value.trim(),
|
||||||
|
content: document.getElementById('swal-news-content').value.trim(),
|
||||||
|
author_name: document.getElementById('swal-news-author').value.trim() || 'Stadtverwaltung'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}).then(function (result) {
|
||||||
|
if (!result.isConfirmed) return;
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('action', 'update_news');
|
||||||
|
formData.append('news_id', newsId);
|
||||||
|
formData.append('title', result.value.title);
|
||||||
|
formData.append('content', result.value.content);
|
||||||
|
formData.append('author_name', result.value.author_name);
|
||||||
|
|
||||||
|
fetch(API_URL, { method: 'POST', body: formData })
|
||||||
|
.then(function (r) { return r.json(); })
|
||||||
|
.then(function (response) {
|
||||||
|
if (response.error) {
|
||||||
|
Swal.fire('Fehler', response.error, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Swal.fire('Gespeichert!', 'Neuigkeit wurde aktualisiert.', 'success')
|
||||||
|
.then(function () { location.reload(); });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// =============================================================
|
||||||
|
// Create News Article
|
||||||
|
// =============================================================
|
||||||
|
function deleteNews(newsId) {
|
||||||
|
Swal.fire({
|
||||||
|
title: 'Neuigkeit löschen?',
|
||||||
|
text: 'Diese Aktion kann nicht rückgängig gemacht werden.',
|
||||||
|
icon: 'warning',
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonText: 'Löschen',
|
||||||
|
cancelButtonText: 'Abbrechen',
|
||||||
|
confirmButtonColor: '#c62828'
|
||||||
|
}).then(function (result) {
|
||||||
|
if (!result.isConfirmed) return;
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('action', 'delete_news');
|
||||||
|
formData.append('news_id', newsId);
|
||||||
|
|
||||||
|
fetch(API_URL, { method: 'POST', body: formData })
|
||||||
|
.then(function (r) { return r.json(); })
|
||||||
|
.then(function (response) {
|
||||||
|
if (response.error) {
|
||||||
|
Swal.fire('Fehler', response.error, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Swal.fire('Gelöscht!', 'Neuigkeit wurde gelöscht.', 'success')
|
||||||
|
.then(function () { location.reload(); });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -576,7 +881,7 @@ function show_login_page($municipality, $error = null) {
|
|||||||
<input type="password" name="password" placeholder="Passwort" autofocus>
|
<input type="password" name="password" placeholder="Passwort" autofocus>
|
||||||
<button type="submit"><i class="fa-solid fa-right-to-bracket"></i> Anmelden</button>
|
<button type="submit"><i class="fa-solid fa-right-to-bracket"></i> Anmelden</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="back-link"><i class="fa fa-arrow-left"></i> <a href="index.php">Zurück zum Bürgerportal</a></div>
|
<div class="back-link"><i class="fa fa-arrow-left"></i></i> <a href="index.php">Zurück zum Bürgerportal</a></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -56,9 +56,6 @@ switch ($action) {
|
|||||||
case 'delete_comment':
|
case 'delete_comment':
|
||||||
handle_delete_comment($input);
|
handle_delete_comment($input);
|
||||||
break;
|
break;
|
||||||
case 'update_comment':
|
|
||||||
handle_update_comment($input);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
error_response('Unknown Action. Supported Actions are read, create, update, delete, vote.');
|
error_response('Unknown Action. Supported Actions are read, create, update, delete, vote.');
|
||||||
}
|
}
|
||||||
@@ -579,9 +576,9 @@ function handle_read_comments($input) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $pdo->prepare("
|
$stmt = $pdo->prepare("
|
||||||
SELECT comment_id, contribution_id, author_name, browser_id, content, status, created_at
|
SELECT comment_id, contribution_id, author_name, browser_id, content, created_at
|
||||||
FROM comments
|
FROM comments
|
||||||
WHERE contribution_id = :cid AND status = 'approved'
|
WHERE contribution_id = :cid
|
||||||
ORDER BY created_at ASC
|
ORDER BY created_at ASC
|
||||||
");
|
");
|
||||||
$stmt->execute([':cid' => $input['contribution_id']]);
|
$stmt->execute([':cid' => $input['contribution_id']]);
|
||||||
@@ -632,6 +629,14 @@ function handle_create_comment($input) {
|
|||||||
':content' => $input['content']
|
':content' => $input['content']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$stmt2 = $pdo->prepare("
|
||||||
|
UPDATE contributions
|
||||||
|
SET comment_count = comment_count + 1
|
||||||
|
WHERE contribution_id = :cid;
|
||||||
|
");
|
||||||
|
|
||||||
|
$stmt2->execute([':cid' => $input['contribution_id']]);
|
||||||
|
|
||||||
json_response([
|
json_response([
|
||||||
'message' => 'Comment created successfully.',
|
'message' => 'Comment created successfully.',
|
||||||
'comment_id' => (int) $pdo->lastInsertId()
|
'comment_id' => (int) $pdo->lastInsertId()
|
||||||
@@ -659,54 +664,17 @@ function handle_delete_comment($input) {
|
|||||||
$stmt = $pdo->prepare("DELETE FROM comments WHERE comment_id = :id");
|
$stmt = $pdo->prepare("DELETE FROM comments WHERE comment_id = :id");
|
||||||
$stmt->execute([':id' => $input['comment_id']]);
|
$stmt->execute([':id' => $input['comment_id']]);
|
||||||
|
|
||||||
|
$stmt2 = $pdo->prepare("
|
||||||
|
UPDATE contributions
|
||||||
|
SET comment_count = comment_count - 1
|
||||||
|
WHERE contribution_id = :cid;
|
||||||
|
");
|
||||||
|
|
||||||
|
$stmt2->execute([':cid' => $input['contribution_id']]);
|
||||||
|
|
||||||
json_response(['message' => 'Comment deleted successfully.']);
|
json_response(['message' => 'Comment deleted successfully.']);
|
||||||
|
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
error_response('Database Error: ' . $e->getMessage(), 500);
|
error_response('Database Error: ' . $e->getMessage(), 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
|
||||||
// UPDATE COMMENT: Changes Comment Status or Content
|
|
||||||
// Required: comment_id
|
|
||||||
// Optional: status, content
|
|
||||||
// ---------------------------------------------------------------------
|
|
||||||
function handle_update_comment($input) {
|
|
||||||
$pdo = get_db();
|
|
||||||
|
|
||||||
$missing = validate_required($input, ['comment_id']);
|
|
||||||
if (!empty($missing)) {
|
|
||||||
error_response('Missing Fields: ' . implode(', ', $missing));
|
|
||||||
}
|
|
||||||
|
|
||||||
$set = [];
|
|
||||||
$params = [':id' => $input['comment_id']];
|
|
||||||
|
|
||||||
// Updates Status if provided
|
|
||||||
if (isset($input['status']) && $input['status'] !== '') {
|
|
||||||
$valid = ['pending', 'approved', 'rejected'];
|
|
||||||
if (!in_array($input['status'], $valid)) {
|
|
||||||
error_response('Invalid Status.');
|
|
||||||
}
|
|
||||||
$set[] = "status = :status";
|
|
||||||
$params[':status'] = $input['status'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updates Content if provided
|
|
||||||
if (isset($input['content']) && $input['content'] !== '') {
|
|
||||||
$set[] = "content = :content";
|
|
||||||
$params[':content'] = $input['content'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($set)) {
|
|
||||||
error_response('No Fields to update.');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$stmt = $pdo->prepare("UPDATE comments SET " . implode(', ', $set) . " WHERE comment_id = :id");
|
|
||||||
$stmt->execute($params);
|
|
||||||
json_response(['message' => 'Comment updated successfully.']);
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
error_response('Database Error: ' . $e->getMessage(), 500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
@@ -11,7 +11,7 @@ $municipality = $stmt->fetch();
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Impressum — <?= htmlspecialchars($municipality['name']) ?></title>
|
<title>Impressum — <?= htmlspecialchars($municipality['name']) ?></title>
|
||||||
<link rel="icon" href="assets/scale-balanced-solid-off-black.png" type="image/png">
|
<link rel="icon" href="<?= htmlspecialchars($municipality['logo_path'] ?? 'assets/icon-municipality.png') ?>" type="image/png">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||||||
<link rel="stylesheet" href="styles.css">
|
<link rel="stylesheet" href="styles.css">
|
||||||
<style>:root { --color-primary: <?= htmlspecialchars($municipality['primary_color']) ?>; }</style>
|
<style>:root { --color-primary: <?= htmlspecialchars($municipality['primary_color']) ?>; }</style>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ require_once __DIR__ . '/api/auth.php';
|
|||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
// Loads Municipality Configuration
|
// Loads Municipality Configuration
|
||||||
|
// ToDo's: Dynamic Loading via URL Slug once multi-tenant Routing
|
||||||
|
// is implemented. Hardcoded Slug for now.
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
$pdo = get_db();
|
$pdo = get_db();
|
||||||
$stmt = $pdo->prepare("SELECT * FROM municipalities WHERE slug = :slug");
|
$stmt = $pdo->prepare("SELECT * FROM municipalities WHERE slug = :slug");
|
||||||
@@ -33,8 +35,8 @@ $news_items = $stmt->fetchAll();
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Mitmachkarte <?= htmlspecialchars($municipality['name']) ?></title>
|
<title>Bürgerbeteiligungsportal <?= htmlspecialchars($municipality['name']) ?></title>
|
||||||
<link rel="icon" href="assets/user-group-solid-off-black.png" type="image/png">
|
<link rel="icon" href="<?= htmlspecialchars($municipality['logo_path'] ?? 'assets/icon-municipality.png') ?>" type="image/png">
|
||||||
<meta name="description" content="Bürgerbeteiligungsportal. Hinweise und Vorschläge auf der Karte eintragen.">
|
<meta name="description" content="Bürgerbeteiligungsportal. Hinweise und Vorschläge auf der Karte eintragen.">
|
||||||
|
|
||||||
|
|
||||||
@@ -66,10 +68,6 @@ $news_items = $stmt->fetchAll();
|
|||||||
<!-- Application Styles -->
|
<!-- Application Styles -->
|
||||||
<link rel="stylesheet" href="styles.css">
|
<link rel="stylesheet" href="styles.css">
|
||||||
|
|
||||||
<!-- Shepherd.js Onboarding Tour -->
|
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/shepherd.js@11.2.0/dist/css/shepherd.css">
|
|
||||||
|
|
||||||
|
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
<!-- Municipality Theme loaded from Database -->
|
<!-- Municipality Theme loaded from Database -->
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
@@ -89,7 +87,7 @@ $news_items = $stmt->fetchAll();
|
|||||||
<header id="app-header">
|
<header id="app-header">
|
||||||
<div class="header-left">
|
<div class="header-left">
|
||||||
<?php if (!empty($municipality['logo_path'])): ?>
|
<?php if (!empty($municipality['logo_path'])): ?>
|
||||||
<img src="assets/user-group-solid-off-white.png" alt="user-group-solid-off-white" class="header-logo" onerror="this.style.display='none'">
|
<img src="<?= htmlspecialchars($municipality['logo_path']) ?>" alt="<?= htmlspecialchars($municipality['name']) ?>" class="header-logo" onerror="this.style.display='none'">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<h1 class="header-title">Mitmachkarte <?= htmlspecialchars($municipality['name']) ?></h1>
|
<h1 class="header-title">Mitmachkarte <?= htmlspecialchars($municipality['name']) ?></h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -185,30 +183,17 @@ $news_items = $stmt->fetchAll();
|
|||||||
<span class="leaflet-sidebar-close"><i class="fa-solid fa-xmark"></i></span>
|
<span class="leaflet-sidebar-close"><i class="fa-solid fa-xmark"></i></span>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="sidebar-body">
|
<div class="sidebar-body">
|
||||||
<h3><i class="fa-solid fa-book"></i> Interaktive Anleitung</h3>
|
|
||||||
<p>Klicken Sie unten auf Tutorial starten um Schritt für Schritt durch die Kernfunktionen der Mitmachkarte geführt zu werden.</p>
|
|
||||||
<p>
|
|
||||||
<button class="btn btn-primary" onclick="if(typeof restartOnboarding==='function'){sidebar.close();restartOnboarding()}" style="font-size:0.85rem;">
|
|
||||||
<i class="fa-solid fa-route"></i> Tutorial starten
|
|
||||||
</button>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3><i class="fa-solid fa-map-location-dot"></i> Karte bedienen</h3>
|
<h3><i class="fa-solid fa-map-location-dot"></i> Karte bedienen</h3>
|
||||||
<p>Verschieben Sie die Karte per Mausklick und Ziehen. Zoomen Sie mit dem Mausrad oder den Zoom-Buttons.</p>
|
<p>Verschieben Sie die Karte per Mausklick und Ziehen. Zoomen Sie mit dem Mausrad oder den Zoom-Buttons.</p>
|
||||||
|
|
||||||
<h3><i class="fa-solid fa-location-dot"></i> Beitrag hinzufügen</h3>
|
<h3><i class="fa-solid fa-plus"></i> Beitrag erstellen</h3>
|
||||||
<p>Verwenden Sie die Zeichenwerkzeuge rechts, um Hinweise, Anregungen und Vorschläge auf der Mitmachkarte als Punkte, Linien oder Flächen hinzuzufügen.</p>
|
<p>Verwenden Sie die Zeichenwerkzeuge rechts, um Beiträge als Punkte, Linien oder Flächen zu zeichnen. Anschließend können Sie Kategorie und Beschreibung hinzufügen.</p>
|
||||||
|
|
||||||
<h3><i class="fa-solid fa-thumbs-up"></i> Bewerten</h3>
|
<h3><i class="fa-solid fa-thumbs-up"></i> Abstimmen</h3>
|
||||||
<p>Klicken Sie auf bestehende Beiträge und nutzen Sie die Bewertungsfunktion, um Ihre Meinung zu äußern.</p>
|
<p>Klicken Sie auf bestehende Beiträge und nutzen Sie die Like/Dislike Funktion, um Ihre Meinung kundzugeben.</p>
|
||||||
|
|
||||||
<h3><i class="fa-solid fa-comments"></i> Kommentieren</h3>
|
|
||||||
<p>Gerne können Sie Ihre Meinung zu bestehenden Beiträgen auch durch die Kommentarfunktion äußern.</p>
|
|
||||||
|
|
||||||
<h3><i class="fa-solid fa-magnifying-glass"></i> Suchen</h3>
|
<h3><i class="fa-solid fa-magnifying-glass"></i> Suchen</h3>
|
||||||
<p>Verwenden Sie die Adresssuche rechts, um schnell den richtigen Ort auf der Mitmachkarte zu finden.</p>
|
<p>Verwenden Sie die Adresssuche rechts, um bestimmte Orte auf der Karte zu finden.</p>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -261,7 +246,7 @@ $news_items = $stmt->fetchAll();
|
|||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
<footer id="app-footer">
|
<footer id="app-footer">
|
||||||
<span class="dev-warning">
|
<span class="dev-warning">
|
||||||
<i class="fa-solid fa-triangle-exclamation"></i> Demoversion - nicht in Rücksprache mit der Stadt Lohne entwickelt! Alle Beitrage, Kommentare und Personen sind frei erfunden.
|
<i class="fa-solid fa-triangle-exclamation"></i> Pilotprojekt - nicht offiziell von der Stadt Lohne (Oldenburg) beauftragt
|
||||||
</span>
|
</span>
|
||||||
<div class="footer-content">
|
<div class="footer-content">
|
||||||
<span class="footer-text">© <a href="https://endex-geodaten.de" target="_blank" style="color:inherit;">endex GmbH</a></span>
|
<span class="footer-text">© <a href="https://endex-geodaten.de" target="_blank" style="color:inherit;">endex GmbH</a></span>
|
||||||
@@ -282,7 +267,7 @@ $news_items = $stmt->fetchAll();
|
|||||||
<li>Bestehende Beiträge der Bürgerschaft betrachten und bewerten</li>
|
<li>Bestehende Beiträge der Bürgerschaft betrachten und bewerten</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p style="background:#fff3cd;padding:10px;border-radius:6px;border:1px solid #ffc107;font-size:0.85rem;color:#856404;">
|
<p style="background:#fff3cd;padding:10px;border-radius:6px;border:1px solid #ffc107;font-size:0.85rem;color:#856404;">
|
||||||
<i class="fa-solid fa-triangle-exclamation"></i> <strong>Hinweis:</strong> Demoversion - nicht in Rücksprache mit der Stadt Lohne entwickelt! Alle Beitrage, Kommentare und Personen sind frei erfunden.
|
<i class="fa-solid fa-triangle-exclamation"></i> <strong>Hinweis:</strong> Dieses Bürgerbeteiligungsportal befindet sich noch in der Entwicklung und wurde nicht offiziell beauftragt.
|
||||||
</p>
|
</p>
|
||||||
<p>Zum Hinzufügen von Beiträgen geben Sie bitte zunächst Ihren Namen ein.</p> <div class="modal-actions">
|
<p>Zum Hinzufügen von Beiträgen geben Sie bitte zunächst Ihren Namen ein.</p> <div class="modal-actions">
|
||||||
<button class="btn btn-primary" onclick="closeWelcomeAndShowLogin()">Loslegen</button>
|
<button class="btn btn-primary" onclick="closeWelcomeAndShowLogin()">Loslegen</button>
|
||||||
@@ -357,7 +342,7 @@ $news_items = $stmt->fetchAll();
|
|||||||
|
|
||||||
|
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
<!-- Loads JavaScript Dependencies -->
|
<!-- Loads JavaScript Dependencies -->
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
|
|
||||||
<!-- Leaflet 1.9.4 -->
|
<!-- Leaflet 1.9.4 -->
|
||||||
@@ -381,18 +366,11 @@ $news_items = $stmt->fetchAll();
|
|||||||
<!-- SweetAlert2 -->
|
<!-- SweetAlert2 -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.14.0/dist/sweetalert2.all.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.14.0/dist/sweetalert2.all.min.js"></script>
|
||||||
|
|
||||||
<!-- Shepherd.js Library -->
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/shepherd.js@11.2.0/dist/js/shepherd.min.js"></script>
|
|
||||||
|
|
||||||
<!-- Onboarding Logic -->
|
|
||||||
<script src="js/onboarding.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
<!-- Municipality Configuration passed to JavaScript -->
|
<!-- Municipality Configuration passed to JavaScript -->
|
||||||
<!-- ============================================================= -->
|
<!-- ============================================================= -->
|
||||||
<script>
|
<script>
|
||||||
// Municipality Configuration from Database
|
// Municipality Configuration from Database — used by app.js
|
||||||
const MUNICIPALITY = {
|
const MUNICIPALITY = {
|
||||||
id: <?= $municipality['municipality_id'] ?>,
|
id: <?= $municipality['municipality_id'] ?>,
|
||||||
name: "<?= htmlspecialchars($municipality['name'], ENT_QUOTES) ?>",
|
name: "<?= htmlspecialchars($municipality['name'], ENT_QUOTES) ?>",
|
||||||
|
|||||||
@@ -1,637 +0,0 @@
|
|||||||
// =====================================================================
|
|
||||||
// WebGIS Moderation Portal — Application Logic
|
|
||||||
// Initializes Map Preview, loads Contributions from the API,
|
|
||||||
// handles CRUD Workflow, sorting and filtering for Contributions,
|
|
||||||
// Comments and News, and manages all UI Interactions
|
|
||||||
//
|
|
||||||
// Depends on: ADMIN_CONFIG Object set in Moderation Page
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 0: Configuration and Application State
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
// API Endpoint as relative Path
|
|
||||||
const API_URL = 'api/contributions.php';
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 1: Page Tab Navigation
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
// Restores active Tab after Page Reload
|
|
||||||
const savedTab = sessionStorage.getItem('admin_active_tab');
|
|
||||||
if (savedTab) {
|
|
||||||
// Delays to ensure DOM is ready
|
|
||||||
setTimeout(function () {
|
|
||||||
const tabBtn = document.querySelector('.page-tab[onclick*="' + savedTab + '"]');
|
|
||||||
if (tabBtn) tabBtn.click();
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Page Tab Navigation
|
|
||||||
function showPageTab(tabName) {
|
|
||||||
// Saves active Tab for Persistence after Reload
|
|
||||||
sessionStorage.setItem('admin_active_tab', tabName);
|
|
||||||
|
|
||||||
document.querySelectorAll('.page-tab-content').forEach(function (el) {
|
|
||||||
el.style.display = 'none';
|
|
||||||
});
|
|
||||||
|
|
||||||
// Deactivates all Tab Buttons
|
|
||||||
document.querySelectorAll('.page-tab').forEach(function (el) {
|
|
||||||
el.classList.remove('active');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Shows selected Tab and activates Button
|
|
||||||
document.getElementById('tab-' + tabName).style.display = 'block';
|
|
||||||
event.currentTarget.classList.add('active');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 2: Collapsible Rows for Contributions and Comments
|
|
||||||
// =====================================================================
|
|
||||||
function toggleRow(row) {
|
|
||||||
const wasOpen = row.classList.contains('open');
|
|
||||||
|
|
||||||
// Closes all open Rows
|
|
||||||
document.querySelectorAll('.contribution-row.open').forEach(function (el) {
|
|
||||||
el.classList.remove('open');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Toggles clicked Row
|
|
||||||
if (!wasOpen) {
|
|
||||||
row.classList.add('open');
|
|
||||||
|
|
||||||
// Loads Map Preview if not already loaded
|
|
||||||
const mapDiv = row.querySelector('.detail-map');
|
|
||||||
if (mapDiv && !mapDiv.dataset.loaded) {
|
|
||||||
loadMapPreview(mapDiv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 3: Details Slider for Maps and Photos
|
|
||||||
// =====================================================================
|
|
||||||
function slideDetail(contributionId, direction) {
|
|
||||||
const slider = document.getElementById('slider-' + contributionId);
|
|
||||||
if (!slider) return;
|
|
||||||
|
|
||||||
const slides = slider.querySelectorAll('.detail-slide');
|
|
||||||
let activeIndex = -1;
|
|
||||||
|
|
||||||
// Finds active Slide
|
|
||||||
slides.forEach(function (slide, i) {
|
|
||||||
if (slide.style.display !== 'none') activeIndex = i;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Calculates next Slide Index
|
|
||||||
const nextIndex = (activeIndex + direction + slides.length) % slides.length;
|
|
||||||
|
|
||||||
// Switches Slides
|
|
||||||
slides.forEach(function (slide) { slide.style.display = 'none'; });
|
|
||||||
slides[nextIndex].style.display = 'block';
|
|
||||||
|
|
||||||
// Loads Map if switching to Map Slide
|
|
||||||
if (slides[nextIndex].dataset.slide === 'map') {
|
|
||||||
const mapDiv = slides[nextIndex].querySelector('.detail-map');
|
|
||||||
if (mapDiv && !mapDiv.dataset.loaded) {
|
|
||||||
loadMapPreview(mapDiv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 4: Map Preview (Leaflet Mini Map per Contribution)
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
// Erstellt eine Leaflet-Mini-Map in einem Beitrags-Detail-Container.
|
|
||||||
// Lädt alle Beiträge via API und zeigt die Geometrie des entsprechenden Beitrags.
|
|
||||||
// Markiert die Map als geladen (data-loaded="true"), um doppeltes Laden zu verhindern.
|
|
||||||
function loadMapPreview(mapDiv) {
|
|
||||||
const contributionId = mapDiv.dataset.contributionId;
|
|
||||||
|
|
||||||
// Fetches all Contributions to find the Geometry
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('action', 'read');
|
|
||||||
formData.append('municipality_id', ADMIN_CONFIG.id);
|
|
||||||
formData.append('status', 'all');
|
|
||||||
|
|
||||||
fetch(API_URL, { method: 'POST', body: formData })
|
|
||||||
.then(function (r) { return r.json(); })
|
|
||||||
.then(function (data) {
|
|
||||||
if (!data.features) return;
|
|
||||||
|
|
||||||
// Finds specific Contribution
|
|
||||||
const feature = data.features.find(function (f) {
|
|
||||||
return f.properties.contribution_id == contributionId;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!feature) {
|
|
||||||
mapDiv.innerHTML = '<div style="padding:20px;color:#999;text-align:center;font-size:0.8rem;">Geometrie nicht gefunden.</div>';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates Leaflet Mini Map
|
|
||||||
const miniMap = L.map(mapDiv, {
|
|
||||||
zoomControl: false,
|
|
||||||
attributionControl: false,
|
|
||||||
dragging: true,
|
|
||||||
scrollWheelZoom: false
|
|
||||||
});
|
|
||||||
|
|
||||||
L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', {
|
|
||||||
maxZoom: 20
|
|
||||||
}).addTo(miniMap);
|
|
||||||
|
|
||||||
// Adds Geometry to Mini Map
|
|
||||||
const geojsonLayer = L.geoJSON(feature, {
|
|
||||||
style: {
|
|
||||||
color: ADMIN_CONFIG.primaryColor,
|
|
||||||
weight: 3,
|
|
||||||
fillOpacity: 0.2
|
|
||||||
},
|
|
||||||
pointToLayer: function (f, latlng) {
|
|
||||||
return L.circleMarker(latlng, {
|
|
||||||
radius: 8,
|
|
||||||
color: '#ffffff',
|
|
||||||
weight: 2,
|
|
||||||
fillColor: ADMIN_CONFIG.primaryColor,
|
|
||||||
fillOpacity: 0.9
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}).addTo(miniMap);
|
|
||||||
|
|
||||||
// Fits Map to Geometry Bounds
|
|
||||||
const bounds = geojsonLayer.getBounds();
|
|
||||||
if (bounds.isValid()) {
|
|
||||||
miniMap.fitBounds(bounds, { padding: [25, 25], maxZoom: 17 });
|
|
||||||
} else {
|
|
||||||
miniMap.setView(ADMIN_CONFIG.center, 15);
|
|
||||||
}
|
|
||||||
|
|
||||||
mapDiv.dataset.loaded = 'true';
|
|
||||||
})
|
|
||||||
.catch(function () {
|
|
||||||
mapDiv.innerHTML = '<div style="padding:20px;color:#999;text-align:center;font-size:0.8rem;">Karte nicht verfügbar.</div>';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 5: Contributions Filter and Sorting
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
// Filters Contributions
|
|
||||||
let currentFilter = 'all';
|
|
||||||
function filterByStatus(status, tabButton) {
|
|
||||||
currentFilter = status;
|
|
||||||
|
|
||||||
// Updates active Tab
|
|
||||||
document.querySelectorAll('.filter-tab').forEach(function (el) {
|
|
||||||
el.classList.remove('active');
|
|
||||||
});
|
|
||||||
tabButton.classList.add('active');
|
|
||||||
|
|
||||||
// Shows or Hides Contribution Rows
|
|
||||||
let visibleCount = 0;
|
|
||||||
document.querySelectorAll('#contributions-container .contribution-row').forEach(function (row) {
|
|
||||||
if (status === 'all' || row.dataset.status === status) {
|
|
||||||
row.style.display = '';
|
|
||||||
visibleCount++;
|
|
||||||
} else {
|
|
||||||
row.style.display = 'none';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Updates Count Display
|
|
||||||
document.getElementById('visible-count').textContent = visibleCount + ' Beiträge';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Sorts Contributions
|
|
||||||
function sortContributions(sortBy) {
|
|
||||||
const container = document.getElementById('contributions-container');
|
|
||||||
const rows = Array.from(container.querySelectorAll('.contribution-row'));
|
|
||||||
|
|
||||||
rows.sort(function (a, b) {
|
|
||||||
if (sortBy === 'date-desc') return new Date(b.dataset.date) - new Date(a.dataset.date);
|
|
||||||
if (sortBy === 'date-asc') return new Date(a.dataset.date) - new Date(b.dataset.date);
|
|
||||||
if (sortBy === 'category') return a.dataset.category.localeCompare(b.dataset.category);
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Reappends sorted Rows
|
|
||||||
rows.forEach(function (row) { container.appendChild(row); });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 6: Comments Filter and Sorting
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
// Filters Comments
|
|
||||||
function filterCommentsByStatus(status, tabButton) {
|
|
||||||
|
|
||||||
// Updates active Tab
|
|
||||||
document.querySelectorAll('#comment-filter-tabs .filter-tab').forEach(function (el) {
|
|
||||||
el.classList.remove('active');
|
|
||||||
});
|
|
||||||
tabButton.classList.add('active');
|
|
||||||
|
|
||||||
// Shows or Hides Comments Rows
|
|
||||||
let visibleCount = 0;
|
|
||||||
document.querySelectorAll('.comment-mod-row').forEach(function (row) {
|
|
||||||
if (status === 'all' || row.dataset.status === status) {
|
|
||||||
row.style.display = '';
|
|
||||||
visibleCount++;
|
|
||||||
} else {
|
|
||||||
row.style.display = 'none';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Updates Count Display
|
|
||||||
document.getElementById('comment-visible-count').textContent = visibleCount + ' Kommentare';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Sorts Comments
|
|
||||||
function sortCommentRows(sortBy) {
|
|
||||||
const container = document.getElementById('comments-mod-container');
|
|
||||||
const rows = Array.from(container.querySelectorAll('.comment-mod-row'));
|
|
||||||
|
|
||||||
rows.sort(function (a, b) {
|
|
||||||
if (sortBy === 'date-desc') return new Date(b.dataset.date) - new Date(a.dataset.date);
|
|
||||||
if (sortBy === 'date-asc') return new Date(a.dataset.date) - new Date(b.dataset.date);
|
|
||||||
if (sortBy === 'contribution') return a.dataset.contribution.localeCompare(b.dataset.contribution);
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
// Reappends sorted Rows
|
|
||||||
rows.forEach(function (row) { container.appendChild(row); });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 7: Helper Functions
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
// Sends a POST request to API
|
|
||||||
// promise-based instead of callback-based
|
|
||||||
function apiCall(data) {
|
|
||||||
const formData = new FormData();
|
|
||||||
for (const key in data) {
|
|
||||||
formData.append(key, data[key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fetch(API_URL, { method: 'POST', body: formData })
|
|
||||||
.then(function (r) { return r.json(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Escapes HTML to prevent Cross-Site Scripting (XSS) in Popups and Lists
|
|
||||||
function escapeHtml(text) {
|
|
||||||
|
|
||||||
if (!text) return '';
|
|
||||||
const div = document.createElement('div');
|
|
||||||
div.appendChild(document.createTextNode(text));
|
|
||||||
return div.innerHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 8: CRUD Operations for Contributions
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
// STATUS: Changes Contribution Status
|
|
||||||
function changeStatus(contributionId, newStatus) {
|
|
||||||
const labels = { approved: 'freigeben', rejected: 'ablehnen', pending: 'zurücksetzen' };
|
|
||||||
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Beitrag ' + labels[newStatus] + '?',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonText: 'Ja',
|
|
||||||
cancelButtonText: 'Abbrechen',
|
|
||||||
confirmButtonColor: ADMIN_CONFIG.primaryColor
|
|
||||||
}).then(function (result) {
|
|
||||||
if (!result.isConfirmed) return;
|
|
||||||
|
|
||||||
apiCall({
|
|
||||||
action: 'update',
|
|
||||||
contribution_id: contributionId,
|
|
||||||
status: newStatus
|
|
||||||
}).then(function (response) {
|
|
||||||
if (response.error) {
|
|
||||||
Swal.fire('Fehler', response.error, 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Reloads Page to reflect Changes
|
|
||||||
location.reload();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// UPDATE: Edits existing Contributions
|
|
||||||
function editContribution(contributionId, currentTitle, currentDescription) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Beitrag bearbeiten',
|
|
||||||
html:
|
|
||||||
'<div style="text-align:left;">' +
|
|
||||||
'<div style="margin-bottom:12px;">' +
|
|
||||||
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Titel</label>' +
|
|
||||||
'<input id="swal-title" class="swal2-input" style="margin:0;width:100%;" value="' + escapeHtml(currentTitle) + '">' +
|
|
||||||
'</div>' +
|
|
||||||
'<div>' +
|
|
||||||
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Beschreibung</label>' +
|
|
||||||
'<textarea id="swal-description" class="swal2-textarea" style="margin:0;width:100%;">' + escapeHtml(currentDescription) + '</textarea>' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonText: 'Speichern',
|
|
||||||
cancelButtonText: 'Abbrechen',
|
|
||||||
confirmButtonColor: ADMIN_CONFIG.primaryColor,
|
|
||||||
preConfirm: function () {
|
|
||||||
return {
|
|
||||||
title: document.getElementById('swal-title').value.trim(),
|
|
||||||
description: document.getElementById('swal-description').value.trim()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}).then(function (result) {
|
|
||||||
if (!result.isConfirmed) return;
|
|
||||||
|
|
||||||
apiCall({
|
|
||||||
action: 'update',
|
|
||||||
contribution_id: contributionId,
|
|
||||||
title: result.value.title,
|
|
||||||
description: result.value.description
|
|
||||||
}).then(function (response) {
|
|
||||||
if (response.error) {
|
|
||||||
Swal.fire('Fehler', response.error, 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Swal.fire('Gespeichert!', 'Beitrag wurde aktualisiert.', 'success')
|
|
||||||
.then(function () { location.reload(); });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// DELETE: Deletes existing Contributions
|
|
||||||
function deleteContribution(contributionId) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Beitrag löschen?',
|
|
||||||
text: 'Diese Aktion kann nicht rückgängig gemacht werden.',
|
|
||||||
icon: 'warning',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonText: 'Beitrag löschen',
|
|
||||||
cancelButtonText: 'Abbrechen',
|
|
||||||
confirmButtonColor: '#c62828'
|
|
||||||
}).then(function (result) {
|
|
||||||
if (!result.isConfirmed) return;
|
|
||||||
|
|
||||||
apiCall({
|
|
||||||
action: 'delete',
|
|
||||||
contribution_id: contributionId
|
|
||||||
}).then(function (response) {
|
|
||||||
if (response.error) {
|
|
||||||
Swal.fire('Fehler', response.error, 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Swal.fire('Gelöscht!', 'Beitrag wurde gelöscht.', 'success')
|
|
||||||
.then(function () { location.reload(); });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 9: CRUD Operations for Comments
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
// STATUS: Changes Comment Status
|
|
||||||
function changeCommentStatus(commentId, newStatus) {
|
|
||||||
const labels = { approved: 'akzeptieren', rejected: 'ablehnen', pending: 'zurücksetzen' };
|
|
||||||
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Kommentar ' + labels[newStatus] + '?',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonText: 'Ja',
|
|
||||||
cancelButtonText: 'Abbrechen',
|
|
||||||
confirmButtonColor: ADMIN_CONFIG.primaryColor
|
|
||||||
}).then(function (result) {
|
|
||||||
if (!result.isConfirmed) return;
|
|
||||||
|
|
||||||
apiCall({
|
|
||||||
action: 'update_comment',
|
|
||||||
comment_id: commentId,
|
|
||||||
status: newStatus
|
|
||||||
}).then(function (response) {
|
|
||||||
if (response.error) {
|
|
||||||
Swal.fire('Fehler', response.error, 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
location.reload();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// UPDATE: Edits existing Comments
|
|
||||||
function editModComment(commentId, currentContent) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Kommentar bearbeiten',
|
|
||||||
html:
|
|
||||||
'<div style="text-align:left;">' +
|
|
||||||
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Inhalt</label>' +
|
|
||||||
'<textarea id="swal-comment-content" class="swal2-textarea" style="margin:0;width:100%;">' + escapeHtml(currentContent) + '</textarea>' +
|
|
||||||
'</div>',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonText: 'Speichern',
|
|
||||||
cancelButtonText: 'Abbrechen',
|
|
||||||
confirmButtonColor: ADMIN_CONFIG.primaryColor,
|
|
||||||
preConfirm: function () {
|
|
||||||
return { content: document.getElementById('swal-comment-content').value.trim() };
|
|
||||||
}
|
|
||||||
}).then(function (result) {
|
|
||||||
if (!result.isConfirmed) return;
|
|
||||||
|
|
||||||
apiCall({
|
|
||||||
action: 'update_comment',
|
|
||||||
comment_id: commentId,
|
|
||||||
content: result.value.content
|
|
||||||
}).then(function (response) {
|
|
||||||
if (response.error) {
|
|
||||||
Swal.fire('Fehler', response.error, 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Swal.fire('Gespeichert!', 'Kommentar wurde aktualisiert.', 'success')
|
|
||||||
.then(function () { location.reload(); });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// DELETE: Deletes existing Comments
|
|
||||||
function deleteModComment(commentId) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Kommentar löschen?',
|
|
||||||
text: 'Diese Aktion kann nicht rückgängig gemacht werden.',
|
|
||||||
icon: 'warning',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonText: 'Löschen',
|
|
||||||
cancelButtonText: 'Abbrechen',
|
|
||||||
confirmButtonColor: '#c62828'
|
|
||||||
}).then(function (result) {
|
|
||||||
if (!result.isConfirmed) return;
|
|
||||||
|
|
||||||
apiCall({
|
|
||||||
action: 'delete_comment',
|
|
||||||
comment_id: commentId
|
|
||||||
}).then(function (response) {
|
|
||||||
if (response.error) {
|
|
||||||
Swal.fire('Fehler', response.error, 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Swal.fire('Gelöscht!', 'Kommentar wurde entfernt.', 'success')
|
|
||||||
.then(function () { location.reload(); });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =====================================================================
|
|
||||||
// Block 10: CRUD Operations for News
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
// CREATE: Submits new News Article
|
|
||||||
function createNews() {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Neuigkeit hinzufügen',
|
|
||||||
html:
|
|
||||||
'<div style="text-align:left;">' +
|
|
||||||
'<div style="margin-bottom:12px;">' +
|
|
||||||
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Titel</label>' +
|
|
||||||
'<input id="swal-news-title" class="swal2-input" style="margin:0;width:100%;" placeholder="Titel der Neuigkeit">' +
|
|
||||||
'</div>' +
|
|
||||||
'<div style="margin-bottom:12px;">' +
|
|
||||||
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Inhalt</label>' +
|
|
||||||
'<textarea id="swal-news-content" class="swal2-textarea" style="margin:0;width:100%;" placeholder="Neuigkeit verfassen..."></textarea>' +
|
|
||||||
'</div>' +
|
|
||||||
'<div>' +
|
|
||||||
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Autor</label>' +
|
|
||||||
'<input id="swal-news-author" class="swal2-input" style="margin:0;width:100%;" value="Stadtverwaltung">' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonText: 'Veröffentlichen',
|
|
||||||
cancelButtonText: 'Abbrechen',
|
|
||||||
confirmButtonColor: ADMIN_CONFIG.primaryColor,
|
|
||||||
preConfirm: function () {
|
|
||||||
const title = document.getElementById('swal-news-title').value.trim();
|
|
||||||
const content = document.getElementById('swal-news-content').value.trim();
|
|
||||||
const author = document.getElementById('swal-news-author').value.trim() || 'Stadtverwaltung';
|
|
||||||
if (!title || !content) {
|
|
||||||
Swal.showValidationMessage('Titel und Inhalt sind Pflichtfelder.');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return { title, content, author_name: author };
|
|
||||||
}
|
|
||||||
}).then(function (result) {
|
|
||||||
if (!result.isConfirmed) return;
|
|
||||||
|
|
||||||
apiCall({
|
|
||||||
action: 'create_news',
|
|
||||||
municipality_id: ADMIN_CONFIG.id,
|
|
||||||
title: result.value.title,
|
|
||||||
content: result.value.content,
|
|
||||||
author_name: result.value.author_name
|
|
||||||
}).then(function (response) {
|
|
||||||
if (response.error) {
|
|
||||||
Swal.fire('Fehler', response.error, 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Swal.fire('Veröffentlicht!', 'Neuigkeit wurde veröffentlicht.', 'success')
|
|
||||||
.then(function () { location.reload(); });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// UPDATE: Edits existing News
|
|
||||||
function editNews(newsId, currentTitle, currentContent, currentAuthor) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Neuigkeit bearbeiten',
|
|
||||||
html:
|
|
||||||
'<div style="text-align:left;">' +
|
|
||||||
'<div style="margin-bottom:12px;">' +
|
|
||||||
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Titel</label>' +
|
|
||||||
'<input id="swal-news-title" class="swal2-input" style="margin:0;width:100%;" value="' + escapeHtml(currentTitle) + '">' +
|
|
||||||
'</div>' +
|
|
||||||
'<div style="margin-bottom:12px;">' +
|
|
||||||
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Inhalt</label>' +
|
|
||||||
'<textarea id="swal-news-content" class="swal2-textarea" style="margin:0;width:100%;">' + escapeHtml(currentContent) + '</textarea>' +
|
|
||||||
'</div>' +
|
|
||||||
'<div>' +
|
|
||||||
'<label style="display:block;font-weight:600;font-size:1.15rem;margin-bottom:4px;">Autor</label>' +
|
|
||||||
'<input id="swal-news-author" class="swal2-input" style="margin:0;width:100%;" value="' + escapeHtml(currentAuthor) + '">' +
|
|
||||||
'</div>' +
|
|
||||||
'</div>',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonText: 'Speichern',
|
|
||||||
cancelButtonText: 'Abbrechen',
|
|
||||||
confirmButtonColor: ADMIN_CONFIG.primaryColor,
|
|
||||||
preConfirm: function () {
|
|
||||||
return {
|
|
||||||
title: document.getElementById('swal-news-title').value.trim(),
|
|
||||||
content: document.getElementById('swal-news-content').value.trim(),
|
|
||||||
author_name: document.getElementById('swal-news-author').value.trim() || 'Stadtverwaltung'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}).then(function (result) {
|
|
||||||
if (!result.isConfirmed) return;
|
|
||||||
|
|
||||||
apiCall({
|
|
||||||
action: 'update_news',
|
|
||||||
news_id: newsId,
|
|
||||||
title: result.value.title,
|
|
||||||
content: result.value.content,
|
|
||||||
author_name: result.value.author_name
|
|
||||||
}).then(function (response) {
|
|
||||||
if (response.error) {
|
|
||||||
Swal.fire('Fehler', response.error, 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Swal.fire('Gespeichert!', 'Neuigkeit wurde aktualisiert.', 'success')
|
|
||||||
.then(function () { location.reload(); });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// DELETE: Deletes existing News
|
|
||||||
function deleteNews(newsId) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Neuigkeit löschen?',
|
|
||||||
text: 'Diese Aktion kann nicht rückgängig gemacht werden.',
|
|
||||||
icon: 'warning',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonText: 'Löschen',
|
|
||||||
cancelButtonText: 'Abbrechen',
|
|
||||||
confirmButtonColor: '#c62828'
|
|
||||||
}).then(function (result) {
|
|
||||||
if (!result.isConfirmed) return;
|
|
||||||
|
|
||||||
apiCall({
|
|
||||||
action: 'delete_news',
|
|
||||||
news_id: newsId
|
|
||||||
}).then(function (response) {
|
|
||||||
if (response.error) {
|
|
||||||
Swal.fire('Fehler', response.error, 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Swal.fire('Gelöscht!', 'Neuigkeit wurde gelöscht.', 'success')
|
|
||||||
.then(function () { location.reload(); });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,9 @@
|
|||||||
// Initializes Leaflet Map, loads Contributions from the API,
|
// Initializes Leaflet Map, loads Contributions from the API,
|
||||||
// handles CRUD Workflow, and manages all UI Interactions.
|
// handles CRUD Workflow, and manages all UI Interactions.
|
||||||
//
|
//
|
||||||
// Depends on: MUNICIPALITY Object set in Citizen Portal
|
// Depends on: MUNICIPALITY Object set in Main Page, Leaflet, Geoman,
|
||||||
|
// Sidebar, Geocoder, PolylineMeasure, Fullscreen,
|
||||||
|
// and SweetAlert2 Plugins.
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
|
|
||||||
|
|
||||||
@@ -15,8 +17,7 @@
|
|||||||
const API_URL = 'api/contributions.php';
|
const API_URL = 'api/contributions.php';
|
||||||
|
|
||||||
// Username set via Login Modal stored in sessionStorage
|
// Username set via Login Modal stored in sessionStorage
|
||||||
let currentUser = sessionStorage.getItem('webgis_user') ||
|
let currentUser = sessionStorage.getItem('webgis_user') || '';
|
||||||
decodeURIComponent(document.cookie.replace(/(?:(?:^|.*;\s*)webgis_user\s*=\s*([^;]*).*$)|^.*$/, '$1')) || '';
|
|
||||||
|
|
||||||
// Browser Identification Number for anonymous User Identification stored as Cookie
|
// Browser Identification Number for anonymous User Identification stored as Cookie
|
||||||
let browserId = getBrowserId();
|
let browserId = getBrowserId();
|
||||||
@@ -408,6 +409,11 @@ function buildPopupHtml(feature) {
|
|||||||
if (props.photo_path) {
|
if (props.photo_path) {
|
||||||
html += '<div class="popup-photo-container" id="photo-container-' + props.contribution_id + '" style="display:none;">' +
|
html += '<div class="popup-photo-container" id="photo-container-' + props.contribution_id + '" style="display:none;">' +
|
||||||
'<img src="' + escapeHtml(props.photo_path) + '" alt="Foto" class="popup-photo-img" onclick="window.open(\'' + escapeHtml(props.photo_path) + '\', \'_blank\')">' +
|
'<img src="' + escapeHtml(props.photo_path) + '" alt="Foto" class="popup-photo-img" onclick="window.open(\'' + escapeHtml(props.photo_path) + '\', \'_blank\')">' +
|
||||||
|
'</div>' +
|
||||||
|
'<div class="popup-photo-toggle">' +
|
||||||
|
'<button class="popup-photo-btn" onclick="togglePhoto(' + props.contribution_id + ')">' +
|
||||||
|
'<i class="fa-solid fa-camera"></i> <span id="photo-label-' + props.contribution_id + '">Foto anzeigen</span>' +
|
||||||
|
'</button>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,23 +423,15 @@ function buildPopupHtml(feature) {
|
|||||||
' · <i class="fa-solid fa-calendar"></i> ' + dateStr +
|
' · <i class="fa-solid fa-calendar"></i> ' + dateStr +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
// Vote Buttons and Photo Toggle
|
// Vote Buttons
|
||||||
html += '<div class="popup-detail-votes">' +
|
html += '<div class="popup-detail-votes">' +
|
||||||
'<button class="popup-vote-btn' + (userVotes[props.contribution_id] === 'like' ? ' liked' : '') + '" id="vote-like-' + props.contribution_id + '" onclick="voteContribution(' + props.contribution_id + ', \'like\')" title="Gefällt mir">' +
|
'<button class="popup-vote-btn' + (userVotes[props.contribution_id] === 'like' ? ' liked' : '') + '" id="vote-like-' + props.contribution_id + '" onclick="voteContribution(' + props.contribution_id + ', \'like\')" title="Gefällt mir">' +
|
||||||
'<i class="fa-solid fa-thumbs-up"></i> <span id="likes-' + props.contribution_id + '">' + props.likes_count + '</span>' +
|
'<i class="fa-solid fa-thumbs-up"></i> <span id="likes-' + props.contribution_id + '">' + props.likes_count + '</span>' +
|
||||||
'</button>' +
|
'</button>' +
|
||||||
'<button class="popup-vote-btn' + (userVotes[props.contribution_id] === 'dislike' ? ' disliked' : '') + '" id="vote-dislike-' + props.contribution_id + '" onclick="voteContribution(' + props.contribution_id + ', \'dislike\')" title="Gefällt mir nicht">' +
|
'<button class="popup-vote-btn' + (userVotes[props.contribution_id] === 'dislike' ? ' disliked' : '') + '" id="vote-dislike-' + props.contribution_id + '" onclick="voteContribution(' + props.contribution_id + ', \'dislike\')" title="Gefällt mir nicht">' +
|
||||||
'<i class="fa-solid fa-thumbs-down"></i> <span id="dislikes-' + props.contribution_id + '">' + props.dislikes_count + '</span>' +
|
'<i class="fa-solid fa-thumbs-down"></i> <span id="dislikes-' + props.contribution_id + '">' + props.dislikes_count + '</span>' +
|
||||||
'</button>';
|
'</button>' +
|
||||||
|
'</div>';
|
||||||
// Photo Toggle Button
|
|
||||||
if (props.photo_path) {
|
|
||||||
html += '<button class="popup-vote-btn" onclick="togglePhoto(' + props.contribution_id + ')" title="Foto">' +
|
|
||||||
'<i class="fa-solid fa-camera"></i> <span id="photo-label-' + props.contribution_id + '">Foto anzeigen</span>' +
|
|
||||||
'</button>';
|
|
||||||
}
|
|
||||||
|
|
||||||
html += '</div>';
|
|
||||||
|
|
||||||
// Edit and Delete Buttons for Author or Admin
|
// Edit and Delete Buttons for Author or Admin
|
||||||
if (props.browser_id === browserId || (typeof IS_ADMIN !== 'undefined' && IS_ADMIN)) {
|
if (props.browser_id === browserId || (typeof IS_ADMIN !== 'undefined' && IS_ADMIN)) {
|
||||||
@@ -954,7 +952,6 @@ function submitLogin() {
|
|||||||
}
|
}
|
||||||
currentUser = name;
|
currentUser = name;
|
||||||
sessionStorage.setItem('webgis_user', currentUser);
|
sessionStorage.setItem('webgis_user', currentUser);
|
||||||
document.cookie = 'webgis_user=' + encodeURIComponent(name) + ';path=/;max-age=31536000;SameSite=Lax';
|
|
||||||
document.getElementById('login-modal').style.display = 'none';
|
document.getElementById('login-modal').style.display = 'none';
|
||||||
|
|
||||||
// Open Create Modal if Geometry is pending
|
// Open Create Modal if Geometry is pending
|
||||||
@@ -978,15 +975,7 @@ function showInfoModal() {
|
|||||||
'<strong>' + MUNICIPALITY.name + '</strong> mitzuwirken.</p>' +
|
'<strong>' + MUNICIPALITY.name + '</strong> mitzuwirken.</p>' +
|
||||||
'<p style="text-align:left;line-height:1.6;">Bitte tragen Sie Hinweise, Anregungen und Vorschläge ' +
|
'<p style="text-align:left;line-height:1.6;">Bitte tragen Sie Hinweise, Anregungen und Vorschläge ' +
|
||||||
'mithilfe der Zeichenwerkzeuge auf der Karte ein.</p>',
|
'mithilfe der Zeichenwerkzeuge auf der Karte ein.</p>',
|
||||||
showDenyButton: true,
|
confirmButtonColor: MUNICIPALITY.primaryColor
|
||||||
confirmButtonText: 'Schließen',
|
|
||||||
denyButtonText: '<i class="fa-solid fa-route"></i> Tutorial starten',
|
|
||||||
confirmButtonColor: MUNICIPALITY.primaryColor,
|
|
||||||
denyButtonColor: '#546E7A'
|
|
||||||
}).then(function (result) {
|
|
||||||
if (result.isDenied && typeof restartOnboarding === 'function') {
|
|
||||||
restartOnboarding();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1116,6 +1105,14 @@ function loadComments(contributionId) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
listContainer.innerHTML = html;
|
listContainer.innerHTML = html;
|
||||||
|
|
||||||
|
const count = response.comments.length;
|
||||||
|
const header = document.querySelector('#comments-toggle-' + contributionId)?.closest('.popup-comments-header');
|
||||||
|
if (header) {
|
||||||
|
header.innerHTML = '<i class="fa-solid fa-comments"></i> Kommentare (' + count + ')' +
|
||||||
|
' <i class="fa-solid fa-chevron-down popup-comments-toggle" id="comments-toggle-' + contributionId + '"></i>';
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1137,14 +1134,9 @@ function submitComment(contributionId) {
|
|||||||
Swal.fire('Fehler', response.error, 'error');
|
Swal.fire('Fehler', response.error, 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Clears Input and reloads Comments
|
||||||
if (input) input.value = '';
|
if (input) input.value = '';
|
||||||
Swal.fire({
|
loadComments(contributionId);
|
||||||
title: 'Eingereicht!',
|
|
||||||
text: 'Ihr Kommentar wurde erfolgreich eingereicht und wird nach Prüfung durch das Moderationsteam veröffentlicht.',
|
|
||||||
icon: 'success',
|
|
||||||
timer: 3000,
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,277 +0,0 @@
|
|||||||
// =====================================================================
|
|
||||||
// WebGIS Citizen Participation Portal — Onboarding Tour
|
|
||||||
// Guides Users through the Participation Portal
|
|
||||||
// =====================================================================
|
|
||||||
|
|
||||||
|
|
||||||
// =================================================================
|
|
||||||
// Block 1: Onboarding Configuration
|
|
||||||
// =================================================================
|
|
||||||
|
|
||||||
// ONBOARDING_MODE — Controls when the Tutorial is shown:
|
|
||||||
const ONBOARDING_MODE = 'once';
|
|
||||||
// 'once' — Shown on first Visit, stored in localStorage
|
|
||||||
// 'session' — Shown per Browser Session, stored in sessionStorage
|
|
||||||
// 'always' — Shows always, nothing stored
|
|
||||||
|
|
||||||
// Prevents double Initialization
|
|
||||||
let onboardingStarted = false;
|
|
||||||
|
|
||||||
|
|
||||||
// =================================================================
|
|
||||||
// Block 2: Tour Initialization
|
|
||||||
// =================================================================
|
|
||||||
|
|
||||||
function initOnboardingTour() {
|
|
||||||
|
|
||||||
// Checks if Tutorial should be shown based on Onboarding Mode
|
|
||||||
if (ONBOARDING_MODE === 'once' && localStorage.getItem('webgis_onboarding_done')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ONBOARDING_MODE === 'session' && sessionStorage.getItem('webgis_onboarding_done')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Waits for Welcome and Login Modals to be closed
|
|
||||||
waitForModalsToClose(function () {
|
|
||||||
setTimeout(startTour, 600);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =================================================================
|
|
||||||
// Block 3: Modal Watcher — Starts Tour other Welcome and Login Modals closed
|
|
||||||
// =================================================================
|
|
||||||
|
|
||||||
function waitForModalsToClose(callback) {
|
|
||||||
const welcomeModal = document.getElementById('welcome-modal');
|
|
||||||
const loginModal = document.getElementById('login-modal');
|
|
||||||
|
|
||||||
const checkInterval = setInterval(function () {
|
|
||||||
const welcomeHidden = !welcomeModal || welcomeModal.style.display === 'none' || welcomeModal.style.display === '';
|
|
||||||
const loginHidden = !loginModal || loginModal.style.display === 'none' || loginModal.style.display === '';
|
|
||||||
|
|
||||||
if (welcomeHidden && loginHidden) {
|
|
||||||
clearInterval(checkInterval);
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}, 300);
|
|
||||||
|
|
||||||
// Safety Timeout
|
|
||||||
setTimeout(function () {
|
|
||||||
clearInterval(checkInterval);
|
|
||||||
callback();
|
|
||||||
}, 30000);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =================================================================
|
|
||||||
// Block 4: Tour Definition
|
|
||||||
// =================================================================
|
|
||||||
|
|
||||||
function startTour() {
|
|
||||||
// Prevents double Start
|
|
||||||
if (onboardingStarted) return;
|
|
||||||
onboardingStarted = true;
|
|
||||||
|
|
||||||
const tour = new Shepherd.Tour({
|
|
||||||
useModalOverlay: true,
|
|
||||||
defaultStepOptions: {
|
|
||||||
cancelIcon: { enabled: true },
|
|
||||||
scrollTo: false,
|
|
||||||
classes: 'onboarding-step',
|
|
||||||
popperOptions: {
|
|
||||||
modifiers: [
|
|
||||||
{ name: 'offset', options: { offset: [0, 14] } }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// Step 1: Welcome
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
tour.addStep({
|
|
||||||
id: 'welcome',
|
|
||||||
title: '<i class="fa-solid fa-hand-wave"></i> Wilkommen bei der Mitmachkarte!',
|
|
||||||
text: 'Dieses interaktive Tutorial zeigt Ihnen die Kernfunktionen der Mitmachkarte.' +
|
|
||||||
'<br><br><span style="font-size:0.8rem;color:var(--color-text-secondary);">Sie können das Tutorial jederzeit durch den Hilfe-Tab der Seitenleiste wiederholen.</span>',
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
text: 'Überspringen',
|
|
||||||
action: tour.cancel,
|
|
||||||
classes: 'shepherd-button-secondary'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Los geht\'s <i class="fa-solid fa-arrow-right"></i>',
|
|
||||||
action: tour.next,
|
|
||||||
classes: 'shepherd-button-primary'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// Step 2: Drawing Tools
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
tour.addStep({
|
|
||||||
id: 'drawing-tools',
|
|
||||||
title: '<i class="fa-solid fa-pencil"></i> Beitrag hinzufügen',
|
|
||||||
text: 'Verwenden Sie die <strong>Zeichenwerkzeuge</strong>, um Hinweise, Anregungen und Vorschläge auf der Mitmachkarte als Punkte, Linien oder Flächen hinzuzufügen.',
|
|
||||||
attachTo: {
|
|
||||||
element: '.leaflet-pm-toolbar',
|
|
||||||
on: 'left'
|
|
||||||
},
|
|
||||||
beforeShowPromise: function () {
|
|
||||||
return new Promise(function (resolve) {
|
|
||||||
sidebar.close();
|
|
||||||
setTimeout(resolve, 300);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
text: '<i class="fa-solid fa-arrow-left"></i> Zurück',
|
|
||||||
action: tour.back,
|
|
||||||
classes: 'shepherd-button-secondary'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Weiter <i class="fa-solid fa-arrow-right"></i>',
|
|
||||||
action: tour.next,
|
|
||||||
classes: 'shepherd-button-primary'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// Step 3: Address Search
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
tour.addStep({
|
|
||||||
id: 'address-search',
|
|
||||||
title: '<i class="fa-solid fa-magnifying-glass"></i> Adresssuche',
|
|
||||||
text: 'Verwenden Sie die <strong>Adresssuche</strong>, um schnell den richtigen Ort auf der Mitmachkarte zu finden.',
|
|
||||||
attachTo: {
|
|
||||||
element: '.leaflet-control-geocoder',
|
|
||||||
on: 'left'
|
|
||||||
},
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
text: '<i class="fa-solid fa-arrow-left"></i> Zurück',
|
|
||||||
action: tour.back,
|
|
||||||
classes: 'shepherd-button-secondary'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Weiter <i class="fa-solid fa-arrow-right"></i>',
|
|
||||||
action: tour.next,
|
|
||||||
classes: 'shepherd-button-primary'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// Step 4: Layer Control
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
tour.addStep({
|
|
||||||
id: 'layer-control',
|
|
||||||
title: '<i class="fa-solid fa-layer-group"></i> Kartenansicht',
|
|
||||||
text: 'Wechseln Sie zwischen verschiedenen <strong>Hintergrundkarten</strong> und <strong>Satellitenbildern</strong>.',
|
|
||||||
attachTo: {
|
|
||||||
element: '.leaflet-control-layers',
|
|
||||||
on: 'left'
|
|
||||||
},
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
text: '<i class="fa-solid fa-arrow-left"></i> Zurück',
|
|
||||||
action: tour.back,
|
|
||||||
classes: 'shepherd-button-secondary'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Weiter <i class="fa-solid fa-arrow-right"></i>',
|
|
||||||
action: tour.next,
|
|
||||||
classes: 'shepherd-button-primary'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// Step 5: Sidebar
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
tour.addStep({
|
|
||||||
id: 'sidebar',
|
|
||||||
title: '<i class="fa-solid fa-bars"></i> Seitenleiste',
|
|
||||||
text: 'In der Seitenleiste finden Sie <strong>Hilfestellungen</strong>, <strong>Listenansichten</strong> und <strong>Neuigkeiten</strong>.',
|
|
||||||
attachTo: {
|
|
||||||
element: '#sidebar',
|
|
||||||
on: 'right'
|
|
||||||
},
|
|
||||||
beforeShowPromise: function () {
|
|
||||||
return new Promise(function (resolve) {
|
|
||||||
sidebar.open('tab-help');
|
|
||||||
setTimeout(resolve, 400);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
buttons: [
|
|
||||||
{
|
|
||||||
text: '<i class="fa-solid fa-arrow-left"></i> Zurück',
|
|
||||||
action: tour.back,
|
|
||||||
classes: 'shepherd-button-secondary'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'Tutorial abschließen <i class="fa-solid fa-check"></i>',
|
|
||||||
action: tour.next,
|
|
||||||
classes: 'shepherd-button-primary'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
// Completion and Cancellation
|
|
||||||
// -----------------------------------------------------------------
|
|
||||||
tour.on('complete', function () {
|
|
||||||
markOnboardingDone();
|
|
||||||
onboardingStarted = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
tour.on('cancel', function () {
|
|
||||||
markOnboardingDone();
|
|
||||||
onboardingStarted = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
tour.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =================================================================
|
|
||||||
// Marks Onboarding as completed
|
|
||||||
// =================================================================
|
|
||||||
|
|
||||||
function markOnboardingDone() {
|
|
||||||
if (ONBOARDING_MODE === 'once') {
|
|
||||||
localStorage.setItem('webgis_onboarding_done', 'true');
|
|
||||||
} else if (ONBOARDING_MODE === 'session') {
|
|
||||||
sessionStorage.setItem('webgis_onboarding_done', 'true');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =================================================================
|
|
||||||
// Manual Tour Restart
|
|
||||||
// =================================================================
|
|
||||||
|
|
||||||
function restartOnboarding() {
|
|
||||||
localStorage.removeItem('webgis_onboarding_done');
|
|
||||||
sessionStorage.removeItem('webgis_onboarding_done');
|
|
||||||
onboardingStarted = false;
|
|
||||||
startTour();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// =================================================================
|
|
||||||
// Auto-Start on Page Load
|
|
||||||
// =================================================================
|
|
||||||
|
|
||||||
initOnboardingTour();
|
|
||||||
@@ -11,7 +11,7 @@ $municipality = $stmt->fetch();
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Datenschutz — <?= htmlspecialchars($municipality['name']) ?></title>
|
<title>Datenschutz — <?= htmlspecialchars($municipality['name']) ?></title>
|
||||||
<link rel="icon" href="assets/lock-solid-off-black.png" type="image/png">
|
<link rel="icon" href="<?= htmlspecialchars($municipality['logo_path'] ?? 'assets/icon-municipality.png') ?>" type="image/png">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||||||
<link rel="stylesheet" href="styles.css">
|
<link rel="stylesheet" href="styles.css">
|
||||||
<style>:root { --color-primary: <?= htmlspecialchars($municipality['primary_color']) ?>; }</style>
|
<style>:root { --color-primary: <?= htmlspecialchars($municipality['primary_color']) ?>; }</style>
|
||||||
|
|||||||
@@ -634,6 +634,10 @@ select.form-input { cursor: pointer; }
|
|||||||
----------------------------------------------------------------- */
|
----------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Photo Toggle Button */
|
/* Photo Toggle Button */
|
||||||
|
.popup-photo-toggle {
|
||||||
|
margin: var(--space-sm) 0;
|
||||||
|
}
|
||||||
|
|
||||||
.popup-photo-btn {
|
.popup-photo-btn {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -764,123 +768,6 @@ select.form-input { cursor: pointer; }
|
|||||||
.popup-comment-submit:hover { filter: brightness(1.15); }
|
.popup-comment-submit:hover { filter: brightness(1.15); }
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------
|
|
||||||
4.9 Onboarding Tour (Shepherd.js Overrides)
|
|
||||||
----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/* Step Container */
|
|
||||||
.shepherd-element {
|
|
||||||
max-width: 340px;
|
|
||||||
border-radius: 12px !important;
|
|
||||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;
|
|
||||||
font-family: var(--font-body) !important;
|
|
||||||
z-index: 2100 !important;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shepherd-element .shepherd-content {
|
|
||||||
border-radius: 12px !important;
|
|
||||||
padding: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Header */
|
|
||||||
.shepherd-element .shepherd-header {
|
|
||||||
background: var(--color-primary) !important;
|
|
||||||
padding: 14px 20px !important;
|
|
||||||
border-radius: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shepherd-element .shepherd-title {
|
|
||||||
color: white !important;
|
|
||||||
font-size: 1rem !important;
|
|
||||||
font-weight: 600 !important;
|
|
||||||
font-family: var(--font-body) !important;
|
|
||||||
display: flex !important;
|
|
||||||
align-items: center !important;
|
|
||||||
gap: 6px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shepherd-element .shepherd-cancel-icon {
|
|
||||||
color: white !important;
|
|
||||||
opacity: 0.7;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shepherd-element .shepherd-cancel-icon:hover { opacity: 1; }
|
|
||||||
|
|
||||||
/* Body Text */
|
|
||||||
.shepherd-element .shepherd-text {
|
|
||||||
padding: 16px 20px !important;
|
|
||||||
font-size: 0.88rem !important;
|
|
||||||
line-height: 1.6 !important;
|
|
||||||
color: var(--color-text) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Footer Buttons */
|
|
||||||
.shepherd-element .shepherd-footer {
|
|
||||||
padding: 0 20px 16px 20px !important;
|
|
||||||
border-top: none !important;
|
|
||||||
display: flex !important;
|
|
||||||
justify-content: flex-end !important;
|
|
||||||
gap: 8px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shepherd-element .shepherd-button {
|
|
||||||
border: none !important;
|
|
||||||
border-radius: 6px !important;
|
|
||||||
padding: 8px 16px !important;
|
|
||||||
font-size: 0.85rem !important;
|
|
||||||
font-weight: 600 !important;
|
|
||||||
font-family: var(--font-body) !important;
|
|
||||||
cursor: pointer !important;
|
|
||||||
transition: filter 150ms ease !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shepherd-element .shepherd-button:hover { filter: brightness(1.1); }
|
|
||||||
|
|
||||||
/* Primary Button */
|
|
||||||
.shepherd-button-primary {
|
|
||||||
background: var(--color-primary) !important;
|
|
||||||
color: white !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Secondary Button */
|
|
||||||
.shepherd-button-secondary {
|
|
||||||
background: var(--color-bg) !important;
|
|
||||||
color: var(--color-text) !important;
|
|
||||||
border: 1px solid var(--color-border) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.shepherd-button-secondary:hover {
|
|
||||||
background: var(--color-border) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Modal Overlay */
|
|
||||||
.shepherd-modal-overlay-container {
|
|
||||||
z-index: 2050 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Arrow Colors */
|
|
||||||
.shepherd-arrow:before {
|
|
||||||
background: var(--color-primary) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Welcome Step */
|
|
||||||
.shepherd-element:not([data-popper-placement]) {
|
|
||||||
position: fixed !important;
|
|
||||||
top: 50% !important;
|
|
||||||
left: 50% !important;
|
|
||||||
transform: translate(-50%, -50%) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mobile */
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.shepherd-element { max-width: 300px !important; }
|
|
||||||
.shepherd-element .shepherd-text { font-size: 0.82rem !important; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* =================================================================
|
/* =================================================================
|
||||||
SECTION 5: Admin-specific Styles (admin.php)
|
SECTION 5: Admin-specific Styles (admin.php)
|
||||||
================================================================= */
|
================================================================= */
|
||||||
@@ -1149,60 +1036,6 @@ select.form-input { cursor: pointer; }
|
|||||||
.back-link a { color: var(--color-text-secondary); }
|
.back-link a { color: var(--color-text-secondary); }
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------
|
|
||||||
5.8 Detail Slider (Map/Photo in Admin)
|
|
||||||
----------------------------------------------------------------- */
|
|
||||||
.detail-slider {
|
|
||||||
width: 220px;
|
|
||||||
height: 170px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
position: relative;
|
|
||||||
border-radius: 6px;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
background: #f0f0f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detail-slide { width: 100%; height: 100%; }
|
|
||||||
|
|
||||||
.detail-slide-photo {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detail-slider .detail-map {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.slider-arrow {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
background: rgba(0, 0, 0, 0.5);
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
border-radius: 50%;
|
|
||||||
cursor: pointer;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 0.7rem;
|
|
||||||
z-index: 1000;
|
|
||||||
transition: background var(--transition-fast);
|
|
||||||
}
|
|
||||||
|
|
||||||
.slider-arrow:hover { background: rgba(0, 0, 0, 0.7); }
|
|
||||||
.slider-arrow-left { left: 4px; }
|
|
||||||
.slider-arrow-right { right: 4px; }
|
|
||||||
|
|
||||||
|
|
||||||
/* =================================================================
|
/* =================================================================
|
||||||
SECTION 6: Responsive Overrides
|
SECTION 6: Responsive Overrides
|
||||||
================================================================= */
|
================================================================= */
|
||||||
@@ -1242,8 +1075,6 @@ select.form-input { cursor: pointer; }
|
|||||||
.action-buttons .btn { justify-content: center; }
|
.action-buttons .btn { justify-content: center; }
|
||||||
.filter-tabs { overflow-x: auto; }
|
.filter-tabs { overflow-x: auto; }
|
||||||
.page-tabs { overflow-x: auto; }
|
.page-tabs { overflow-x: auto; }
|
||||||
.detail-slider { width: 100%; height: 200px; }
|
|
||||||
|
|
||||||
|
|
||||||
/* Legal */
|
/* Legal */
|
||||||
.page-content-box { padding: 20px; }
|
.page-content-box { padding: 20px; }
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ Citizen Participation Portal for Lohne (Oldenburg).
|
|||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
- `migrations/` — versioned SQL Schema Migrations
|
- `migrations/` — versioned SQL Schema Migrations
|
||||||
|
- `api/` — Backend (PHP)
|
||||||
- `public/` — Frontend (HTML, CSS, JS)
|
- `public/` — Frontend (HTML, CSS, JS)
|
||||||
- `scripts/` — Maintenance Scripts (backup, deployment)
|
- `scripts/` — Maintenance Scripts (backup, deployment)
|
||||||
|
- `legacy/` — Reference Code from Prototype
|
||||||
|
|
||||||
## Local Setup
|
## Local Setup
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user