|
|
| (16 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) |
| Zeile 1: |
Zeile 1: |
| p = {} | | local p = {} |
|
| |
|
| local com = require("Modul:Common") | | local com = require("Modul:Common") |
| local dev = require("Modul:Development")
| |
| local str = require("Modul:String") | | local str = require("Modul:String") |
| local wik = require("Modul:Wiki") | | local wik = require("Modul:Wiki") |
| local mez = require("Modul:Mehrzahl")
| |
| local geo = require("Modul:Geo")
| |
| local que = require("Modul:Queries") | | local que = require("Modul:Queries") |
| local lfd = require("Modul:LinkFormDatum")
| |
|
| |
|
| local fab_zeilen = require("Modul:Faktenbox/Zeilen") | | local fab_zeilen = require("Modul:Faktenbox/Zeilen") |
| | local fab_common = require("Modul:Faktenbox/Common") |
|
| |
|
| function p.Faktenbox(frame) | | function p.universalDatenTab_(fbdata) |
| -- mw.log("Faktenbox(frame)")
| | -- mw.log("datenUniversalTab_(fbdata)") |
| -- mw.logObject(frame)
| |
| -- Konsolenzeile zum Debuggen:
| |
| -- =p.Faktenbox{pargs={Bild="Schwabacher Straße 12 Dez 2020 1.jpg",["Straße"]="Schwabacher Straße",location="Rathaus Fürth",Objekt="Häusle"}}
| |
| | |
| -- Basis-Faktenbox-Daten (Klasse/Kategorie/Formular)
| |
| -- Kein(e) Klasse/Kategorie/Formular!
| |
| local fbdata = p.fbdata(frame)
| |
| | |
| -- Tabs einsammeln und zusammenfügen
| |
| local box =
| |
| "<div class = factbox><tabs>" ..
| |
| p.bildTab(fbdata) ..
| |
| p.kartenTab(fbdata) ..
| |
| p.datenUniversalDatenTab(fbdata) ..
| |
| "</tabs></div>"
| |
| | |
| -- Sonstige gemeinsame Dinge anfügen (Klasse, Formular, Kategorien, Wartung, ...)
| |
| box = box .. p.common(fbdata, false)
| |
| mw.log("box = " .. box)
| |
| | |
| -- Pre-Processing und String-Länge checken
| |
| box = fbdata.frame:preprocess(box)
| |
| box = box .. com.returnStringCheck(box)
| |
| -- mw.log("box = " .. box)
| |
| return box
| |
| end
| |
| | |
| function p.datenUniversalDatenTab(fbdata)
| |
| -- mw.log("datenUniversalTab(fbdata)") | |
| -- mw.logObject(fbdata) | | -- mw.logObject(fbdata) |
| -- Konsolenzeile zum Debuggen (Achtung! Bug in Fehlerbereinigungskonsole! Kann nur 1x ausgeführt werden!): | | -- Konsolenzeile zum Debuggen (Achtung! Bug in Fehlerbereinigungskonsole! Kann nur 1x ausgeführt werden!): |
| -- fab=require("Modul:Faktenbox/Work"); fbdata=p.fbdata{pargs={lat="Bla", Objekt="Häusle", Test="BlaBla"}}; print(p.datenTab(fbdata)) | | -- fab=require("Modul:Faktenbox/Work"); fab_common = require("Modul:Faktenbox/Common"); fbdata=fab_common.fbdata_{pargs={lat="Bla", Objekt="Häusle", Test="BlaBla"}}; print(p.datenUniversalDatenTab_(fbdata)) |
| local t = "" | | local t = "" |
| local no_show_attr = { | | local no_show_attr = { |
| Zeile 57: |
Zeile 25: |
| for a, _ in pairs(fbdata.pargs) do | | for a, _ in pairs(fbdata.pargs) do |
| if not com.isTrue(no_show_attr[a]) then | | if not com.isTrue(no_show_attr[a]) then |
| t = t .. p.zeile{attr_name = a, fbdata = fbdata, delimiter = ";"} | | t = t .. fab_zeilen.zeile_{attr_name = a, fbdata = fbdata, delimiter = ";"} |
| end | | end |
| end | | end |
| t = t .. "</dl>" | | t = t .. "</dl>" |
| t = t .. p.faktenboxSemantikBrowsen(fbdata) | | t = t .. fab_zeilen.zeileSemantikBrowsenAbfrage_(fbdata) |
|
| |
|
| -- Tab draus machen | | -- Tab draus machen |
| t = p.tab(t, "Daten") | | t = p.tab_(t, "Daten") |
| -- mw.log("t = " .. t) | | -- mw.log("t = " .. t) |
| return t | | return t |
| end | | end |
|
| |
|
| function p.bildTab(fbdata, seite) | | function p.bildTab_(fbdata, seite) |
| -- mw.log("bild(fbdata, " .. (seite or "nil") .. ")") | | -- mw.log("bildTab_(fbdata, " .. (seite or "nil") .. ")") |
| -- mw.logObject(fbdata.pargs) | | -- mw.logObject(fbdata.pargs) |
| -- Konsolenzeile zum Debuggen: | | -- Konsolenzeile zum Debuggen: |
| -- =p.bildTab{pargs={Bild="Erloeserkirche.jpg"}} | | -- =p.bildTab_{pargs={Bild="Erloeserkirche.jpg"}} |
| local t = "" | | local t = "" |
| local beschreibung = que.getValues("Datei:" .. (fbdata.pargs["Bild"] or ""), "Beschreibung") | | local beschreibung = que.getValues("Datei:" .. (fbdata.pargs["Bild"] or ""), "Beschreibung") |
| local beschreibung = beschreibung[1] or "" | | local beschreibung = beschreibung[1] or "" |
| if (fbdata.pargs["Bild"] or "") ~= "" and wik.pageexists("Bild:" .. fbdata.pargs["Bild"]) then | | if (fbdata.pargs["Bild"] or "") ~= "" and wik.pageExists("Bild:" .. fbdata.pargs["Bild"]) then |
| t = t .. '{| class = "factbox_imagetable" border = "0" cellpadding = "0" cellspacing = "0" width = "100%"\n' | | t = t .. '{| class = "factbox_imagetable" border = "0" cellpadding = "0" cellspacing = "0" width = "100%"\n' |
| t = t .. '|-\n' | | t = t .. '|-\n' |
| Zeile 88: |
Zeile 56: |
| end | | end |
| -- Tab draus machen | | -- Tab draus machen |
| t = p.tab(t, "Bild") | | t = p.tab_(t, "Bild") |
| -- mw.log("t = " .. t)
| |
| return t
| |
| end
| |
| | |
| function p.kartenTab(fbdata)
| |
| -- mw.log("kartenTab(fbdata)")
| |
| -- mw.logObject(fbdata)
| |
| -- Konsolenzeile zum Debuggen:
| |
| -- fab=require("Modul:Faktenbox/Work"); fbdata=p.fbdata{pargs={["location"]="Erlanger Straße 11, Fürth, Bayern, Deutschland",Debug="ja"}}; print(p.kartenTab(fbdata))
| |
| -- fab=require("Modul:Faktenbox/Work"); fbdata=p.fbdata{pargs={["Gebäude"]="Erlanger Straße 11;Erlanger Straße 12",Debug="ja"}}; print(p.kartenTab(fbdata))
| |
| t = ""
| |
| if string.find(fbdata.pagename, ";") ~= nil then
| |
| t = "Semikolon im Artikel-/Seitennamen für korrekte Kartendarstellung nicht erlaubt!"
| |
| else
| |
| local args = {
| |
| lat = fbdata.pargs["lat"] or "", location = fbdata.pargs["location"] or "",
| |
| lon = fbdata.pargs["lon"] or "", locationlist = fbdata.pargs["locationlist"] or "",
| |
| geojson = fbdata.pargs["geojson"] or "", zoom = fbdata.pargs["zoom"] or "18", -- 18 ist default-zoom
| |
| Debug = fbdata.pargs["Debug"] or "",
| |
| width = "", height = "", -- passt sich beides automatisch an die Box an
| |
| box = "nein", form = "ja" -- keine eigene Box; Seite hat Formular
| |
| }
| |
| -- Wenn kein geojson-Formular-Wert vorgegeben, prüfen,
| |
| -- ob sich hinter der Artikelseite eine gleichnamige GeoJson-Karte versteckt oder
| |
| -- über Formular-Wert GeoJsonKarte eine Karte aktiviert ist
| |
| if args.geojson == "" then
| |
| if wik.pageexists("GeoJson:" .. fbdata.pagename) or com.isTrue(fbdata.pargs["GeoJsonKarte"]) then
| |
| args.geojson = fbdata.pagename
| |
| end
| |
| end
| |
| -- Verwende Geolokation des Gebäudes, sofern vorhanden und wenn keine location oder locationlist übergeben
| |
| if args.location == "" and args.locationlist == "" then
| |
| local gebaeude = str.splitAndStrip(fbdata.pargs["Gebäude"] or "", ";")
| |
| if #gebaeude > 0 then -- Gebäude angegeben?
| |
| args.locationlist = ""
| |
| local first = true
| |
| for _, g in ipairs(gebaeude) do -- alle Gebäude durchiterieren
| |
| local seite = que.getValues(g, "Seite", true)
| |
| if seite[1] ~= fbdata.pagename then -- Weiterleitung auf sich selbst rausfiltern
| |
| local geolokation = que.getValues(g, "Geolokation", true)
| |
| for _, l in ipairs(geolokation) do -- alle Geolokationen eines Gebäudes durchiterieren
| |
| if first then
| |
| first = false
| |
| else
| |
| args.locationlist = args.locationlist .. ";"
| |
| end
| |
| args.locationlist = args.locationlist .. l
| |
| end
| |
| end
| |
| end
| |
| end
| |
| end
| |
| -- Karte-Vorlage einbinden
| |
| -- mw.logObject(args)
| |
| if (args.lat ~= "" and args.lon ~= "") or args.location ~= "" or args.locationlist ~= "" or args.geojson ~= "" then
| |
| t = fbdata.frame:expandTemplate{title = "Karte", args = args}
| |
| end
| |
| end
| |
| -- Tab draus machen
| |
| t = p.tab(t, "Karte")
| |
| -- mw.log("t = " .. t) | | -- mw.log("t = " .. t) |
| return t | | return t |
| end | | end |
|
| |
|
| function p.benennungenTab(fbdata) | | function p.benennungenTab_(fbdata) |
| -- mw.log("benennungenTab()") | | -- mw.log("benennungenTab_()") |
| -- mw.logObject(fbdata) | | -- mw.logObject(fbdata) |
| -- Konsolenzeile zum Debuggen: | | -- Konsolenzeile zum Debuggen: |
| -- =p.benennungenTab({fullpagename="Engelhardtsteg"}) | | -- =p.benennungenTab_({fullpagename="Engelhardtsteg"}) |
| -- =p.benennungenTab({fullpagename="Jakob-Henle-Straße"}) | | -- =p.benennungenTab_({fullpagename="Jakob-Henle-Straße"}) |
| -- =p.benennungenTab({fullpagename="Eichhornstraße"}) | | -- =p.benennungenTab_({fullpagename="Eichhornstraße"}) |
| -- =p.benennungenTab({fullpagename="Georg-Brandstätter-Straße"}) | | -- =p.benennungenTab_({fullpagename="Georg-Brandstätter-Straße"}) |
| local t = "" | | local t = "" |
|
| |
|
| Zeile 199: |
Zeile 107: |
|
| |
|
| -- Tab draus machen | | -- Tab draus machen |
| t = p.tab(t, "Benennungen") | | t = p.tab_(t, "Benennungen") |
| -- mw.log("t = " .. t) | | -- mw.log("t = " .. t) |
| return t | | return t |
| end | | end |
|
| |
|
| function p.adressenTab(fbdata) | | function p.tab_(t, name) |
| local t = fbdata.frame:expandTemplate{title = 'CommonTabs/Adressen'}
| |
| t = p.tab(t, "Adressen")
| |
| return t
| |
| end
| |
| | |
| -- wrapper für functions von Modul:Faktenbox/Zeilen
| |
| function p.zeileKategorieSeite(fbdata, kindex) return fab_zeilen.zeileKategorieSeite_(fbdata, kindex) end
| |
| function p.zeileStrasseHnr(fbdata) return fab_zeilen.zeileStrasseHnr_(fbdata) end
| |
| function p.zeileAktenNr(fbdata) return fab_zeilen.zeileAktenNr_(fbdata) end
| |
| function p.zeileGeoDaten(fbdata) return fab_zeilen.zeileGeoDaten_(fbdata) end
| |
| function p.zeileDatum(args) return fab_zeilen.zeileDatum_(args) end
| |
| function p.zeile(args) return fab_zeilen.zeile_(args) end
| |
| | |
| function p.faktenboxSemantikBrowsen(fbdata)
| |
| -- mw.log("faktenboxSemantikBrowsen(fbdata)")
| |
| -- mw.logObject(fbdata)
| |
| -- Konsolenzeile zum Debuggen:
| |
| -- =p.faktenboxSemantikBrowsen{pargs={Bild="Erloeserkirche.jpg"}}
| |
| local t = ""
| |
| t = t .. "<dl class = 'dataTable'>"
| |
| t = t .. "<dt>[[Bild:IconSearch.svg|16px|semantisches Browsen|link=[[Spezial:Durchsuchen/" .. fbdata.fullpagename .. "]]]]</dt>"
| |
| t = t .. "<dd>[[Spezial:Durchsuchen/" .. fbdata.fullpagename .. "|Semantisches Browsen]]</dd>"
| |
| t = t .. "</dl>"
| |
| -- mw.log("t = " .. t)
| |
| return t
| |
| end
| |
| | |
| function p.common(fbdata)
| |
| -- mw.log("common(fbdata)")
| |
| -- mw.logObject(fbdata)
| |
| -- Konsolenzeile zum Debuggen:
| |
| -- =p.common{formular="Gebäude/Work",klasse={"Gebäude","Kirche"},kategorie={"Gebäude","Kirchen"},strasse_hnr={suspekt=true},positionscheck=true,pargs={Bild="Angie Oeckl.JPG",Ehemals="Ja",DenkmalstatusBesteht="Ja",Stadtteil="Ronhof; Nordstadt ",location="bla"},pagename="Test/Test;Test"}
| |
| local t = ""
| |
| -- Klasse
| |
| if fbdata.klasse ~= nil then
| |
| t = t .. "{{#set:KlassenName=" .. fbdata.klasse[1] .. "}}"
| |
| end
| |
| -- Formular
| |
| if fbdata.formular ~= nil then
| |
| t = t .. "{{#default_form:" .. fbdata.formular .. "}}"
| |
| end
| |
| -- Kategorien
| |
| local ehemals_text = ""
| |
| if com.isTrue(fbdata.pargs["Ehemals"]) then
| |
| ehemals_text = " (ehemals)"
| |
| end
| |
| if fbdata.kategorie ~= nil then
| |
| for _, k in ipairs(fbdata.kategorie) do
| |
| t = t .. "[[Kategorie:" .. k .. ehemals_text .. "]]"
| |
| end
| |
| end
| |
| if com.isTrue(fbdata.pargs["DenkmalstatusBesteht"]) then
| |
| t = t .. "[[Kategorie:Denkmalliste]]"
| |
| end
| |
| local stadtteil = str.splitAndStrip(fbdata.pargs["Stadtteil"] or "", ";")
| |
| for _, s in ipairs(stadtteil) do
| |
| s = str.strip(tostring(s or ""))
| |
| t = t .. "[[Kategorie:" .. s .. "]]"
| |
| end
| |
| -- Wartungs-Kategorien
| |
| if (fbdata.pargs["Bild"] or "") == "" then
| |
| if fbdata.kategorie ~= nil then
| |
| t = t .. "[[Kategorie:" .. fbdata.kategorie[1] .. " ohne Bild]]"
| |
| else
| |
| t = t .. "[[Kategorie:Ohne Bild]]"
| |
| end
| |
| elseif not wik.pageexists("Bild:" .. fbdata.pargs["Bild"]) then
| |
| t = t .. "[[Kategorie:Bild nicht gefunden]]"
| |
| end
| |
| if string.find(fbdata.pagename, ";") ~= nil then
| |
| t = t .. "[[Kategorie:Hat Semikolon]]"
| |
| end
| |
| if string.find(fbdata.pagename, "/") ~= nil then
| |
| t = t .. "[[Kategorie:Hat Slash]]"
| |
| end
| |
| if fbdata.strasse_hnr ~= nil then
| |
| if fbdata.strasse_hnr.suspekt then
| |
| t = t .. "[[Kategorie:Gebäude mit verdächtiger Straße-Hausnummer-Kombination]]"
| |
| end
| |
| end
| |
| if fbdata.positionscheck and fbdata.kategorie ~= nil and
| |
| not ((fbdata.pargs["lat"] or "") ~= "" or (fbdata.pargs["lon"] or "") ~= "" or
| |
| (fbdata.pargs["location"] or "") ~= "" or wik.pageexists("GeoJson:" .. (fbdata.pargs["geojson"] or fbdata.pagename))) then
| |
| t = t .. "[[Kategorie:" .. fbdata.kategorie[1] .. ehemals_text .. " ohne Position]]"
| |
| end
| |
| -- mw.log("t = " .. t)
| |
| return t
| |
| end
| |
| | |
| function p.tab(t, name)
| |
| -- mw.log("tab(t)") | | -- mw.log("tab(t)") |
| -- mw.logObject(t) | | -- mw.logObject(t) |
| Zeile 303: |
Zeile 121: |
| -- mw.log("t = " .. t) | | -- mw.log("t = " .. t) |
| return t | | return t |
| end
| |
|
| |
| function p.fbdata(frame)
| |
| -- mw.log("fbdata(frame)")
| |
| -- mw.logObject(frame)
| |
| -- Konsolenzeile zum Debuggen:
| |
| -- =p.fbdata{pargs={a=1}}
| |
| local fbdata = {}
| |
| fbdata.frame, fbdata.pargs = dev.GetFrameAndParentArgs(frame)
| |
| wik.setPagenames(fbdata)
| |
| -- mw.logObject(fbdata)
| |
| return fbdata
| |
| end | | end |
|
| |
|
| return p | | return p |