|
|
| (22 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) |
| Zeile 4: |
Zeile 4: |
| local str = require("Modul:String") | | local str = require("Modul:String") |
| local wik = require("Modul:Wiki") | | local wik = require("Modul:Wiki") |
| local que = require("Modul:Queries") | | local smw = require("Modul:SMW") |
| local lfd = require("Modul:LinkFormDatum")
| |
|
| |
|
| local fab_zeilen = require("Modul:Faktenbox/Zeilen") | | local fab_zeilen = require("Modul:Faktenbox/Zeilen") |
| Zeile 23: |
Zeile 22: |
|
| |
|
| -- Zusammenbau | | -- Zusammenbau |
| t = t .. "<dl class = 'dataTable'>"
| |
| 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 |
| Zeile 29: |
Zeile 27: |
| end | | end |
| end | | end |
| t = t .. "</dl>" | | if t ~= "" then |
| t = t .. fab_zeilen.zeileSemantikBrowsenAbfrage_(fbdata)
| | t = p.table_header_footer_(t) |
| | t = t .. fab_zeilen.zeileSemantikBrowsenAbfrage_(fbdata) |
| | end |
|
| |
|
| -- Tab draus machen | | -- Tab draus machen |
| Zeile 38: |
Zeile 38: |
| end | | end |
|
| |
|
| function p.bildTab_(fbdata, seite) | | function p.bildTab_(fbdata) |
| -- mw.log("bildTab_(fbdata, " .. (seite or "nil") .. ")") | | -- mw.log("bildTab_(fbdata)") |
| -- mw.logObject(fbdata.pargs) | | -- mw.logObject(fbdata.pargs, "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 bild = fbdata.pargs["Bild"] |
| local beschreibung = beschreibung[1] or ""
| | if bild ~= nil then |
| if (fbdata.pargs["Bild"] or "") ~= "" and wik.pageExists("Bild:" .. fbdata.pargs["Bild"]) then | | local bildlink = "" |
| t = t .. '{| class = "factbox_imagetable" border = "0" cellpadding = "0" cellspacing = "0" width = "100%"\n' | | if fbdata.bildlink ~= nil then |
| t = t .. '|-\n' | | bildlink = "|link=" .. fbdata.bildlink |
| t = t .. '|[[Bild::Datei:' .. fbdata.pargs["Bild"] .. '|768px|link=' .. (seite or '') .. ']]\n'
| |
| if beschreibung ~= "" then
| |
| t = t .. '|-\n' | |
| t = t .. '|' .. beschreibung .. '\n'
| |
| end | | end |
| t = t .. '|}' | | if wik.pageExists("Datei:" .. bild) then |
| end
| | local beschreibung = smw.getValues("Datei:" .. bild, "Beschreibung") |
| -- Tab draus machen
| | t = t .. "{| class = \"factbox_imagetable\" border = \"0\" cellpadding = \"0\" cellspacing = \"0\" width = \"100%\"\n" |
| t = p.tab_(t, "Bild")
| | t = t .. "|-\n" |
| -- mw.log("t = " .. t)
| | t = t .. "|[[Datei:" .. bild .. "|768px" .. bildlink .. "]]\n" |
| return t
| | if beschreibung[1] ~= nil then |
| end
| | t = t .. "|-\n" |
| | | t = t .. "|" .. beschreibung[1] .. "\n" |
| function p.kartenTab_(fbdata)
| |
| -- mw.log("kartenTab_(fbdata)")
| |
| -- mw.logObject(fbdata)
| |
| -- Konsolenzeile zum Debuggen:
| |
| -- fab=require("Modul:Faktenbox/Work"); fab_common = require("Modul:Faktenbox/Common"); fbdata=fab_common.fbdata_{pargs={["location"]="Erlanger Straße 11, Fürth, Bayern, Deutschland",Debug="ja"}}; print(p.kartenTab_(fbdata))
| |
| -- fab=require("Modul:Faktenbox/Work"); fab_common = require("Modul:Faktenbox/Common"); fbdata=fab_common.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 |
| | t = t .. "|}" |
| end | | end |
| -- Verwende Geolokation des Gebäudes, sofern vorhanden und wenn keine location oder locationlist übergeben | | smw.addAttrToList(fbdata.attr.list, "Bild", "Datei:" .. bild) |
| 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 | | end |
| -- Tab draus machen | | -- Tab draus machen |
| t = p.tab_(t, "Karte") | | t = p.tab_(t, "Bild") |
| -- mw.log("t = " .. t) | | -- mw.logObject(t, "t") |
| return t | | return t |
| end | | end |
| Zeile 173: |
Zeile 120: |
| end | | end |
|
| |
|
| function p.adressenTab_(fbdata) | | function p.tab_(t, name) |
| -- mw.log("adressenTab_()")
| | t = str.strip(t) |
| -- mw.logObject(fbdata)
| | if t ~= "" then |
| -- Konsolenzeile zum Debuggen: | | t = "<tab name = ".. name .. ">" .. t .. "</tab>" |
| -- =p.adressenTab_({fullpagename="Jakob Bock"})
| |
| -- =p.adressenTab_({fullpagename="Ludwig Erhard"})
| |
| -- =p.adressenTab_({fullpagename="Druck & Kopie Hartmann KG"})
| |
| -- =p.adressenTab_({fullpagename="Rathaus"})
| |
| -- =p.adressenTab_({fullpagename="E-Tankstelle Hochstraße"})
| |
| -- =p.adressenTab_({fullpagename="TestPerson2"}) | |
| local t = ""
| |
| | |
| -- Attribute-Liste
| |
| local attr = {
| |
| ["Adressart"] = { querypostfix = "", default = ""}, | |
| ["Straße"] = { querypostfix = "#-", default = ""},
| |
| ["Hausnummer"] = { querypostfix = "", default = 0},
| |
| ["StraßeHnr"] = { querypostfix = "#-", default = ""},
| |
| ["VonObjekt"] = { querypostfix = "#-", default = ""},
| |
| ["AdresseVon"] = { querypostfix = "", default = ""},
| |
| ["AdresseBis"] = { querypostfix = "", default = ""},
| |
| ["Index"] = { querypostfix = "", default = 0} }
| |
| | |
| -- DB-Abfrage
| |
| local query = "[[-Has subobject::".. fbdata.fullpagename .. "]][[SubObjektTyp::Adresse]]|?#-|limit=100"
| |
| for i, a in pairs(attr) do
| |
| query = query .. "|?" .. i .. a.querypostfix
| |
| end | | end |
| local addresses = mw.smw.ask(query) | | return t |
| | end |
|
| |
|
| if addresses ~= nil then
| | function p.table_header_footer_(t) |
| | | t = str.strip(t) |
| -- defaults fehlender Attribute setzen
| | if t ~= "" then |
| for i, _ in pairs(addresses) do
| | t = "<dl class = \"dataTable\">" .. t .. "</dl>" |
| for j, a in pairs(attr) do
| |
| addresses[i][j] = addresses[i][j] or a.default
| |
| end
| |
| end
| |
| | |
| -- Tabelle sortieren
| |
| table.sort(addresses, function (k1, k2) return k1["Index"] < k2["Index"] end)
| |
| | |
| -- Liste erstellen
| |
| t = t .. "<nowiki></nowiki>\n" -- nötig, warum auch immer, damit erster Listeeintrag richtig gerendert wird
| |
| for _, e in ipairs(addresses) do
| |
| t = t .. "* '''" -- Zeilenanfang Liste
| |
| -- Straße/Hausnummer ausgeben
| |
| if wik.pageExists(e["StraßeHnr"]) then -- Link zu Einzel-Gebäude-Seite
| |
| t = t .. "[[" .. e["StraßeHnr"] .. "]]"
| |
| elseif wik.pageExists(e["VonObjekt"]) then -- alternativ Link zu Gebäude-Komplex-Seite
| |
| t = t .. "[[" .. e["VonObjekt"] .. "|" .. e["StraßeHnr"] .. "]]"
| |
| elseif wik.pageExists(e["Straße"]) then -- alternativ Link zu Straße-Seite
| |
| t = t .. "[[" .. e["Straße"] .. "]] " .. tostring(e["Hausnummer"])
| |
| else
| |
| t = t .. "" .. e["StraßeHnr"] .. "" -- alternativ nur fetter Text
| |
| end
| |
| t = t .. "'''"
| |
| | |
| -- Zusatzinfos in Klammern anfügen
| |
| local bracket = {}
| |
| if e["Adressart"] ~= "" then
| |
| table.insert(bracket, e["Adressart"])
| |
| end
| |
| if e["AdresseVon"] ~= "" then
| |
| table.insert(bracket, "von " .. lfd.formatDate(e["AdresseVon"]))
| |
| end
| |
| if e["AdresseBis"] ~= "" then
| |
| table.insert(bracket, "bis " .. lfd.formatDate(e["AdresseBis"]))
| |
| end
| |
| if #bracket > 0 then
| |
| t = t .. " (" .. table.concat(bracket, " ") ..")"
| |
| end
| |
| t = t .. "\n"
| |
| end
| |
| end | | end |
|
| |
| -- Tab draus machen
| |
| t = p.tab_(t, "Adressen")
| |
| -- mw.log("t = " .. t)
| |
| return t | | return t |
| end | | end |
|
| |
|
| function p.tab_(t, name) | | function p.factbox_header_footer_(t) |
| -- mw.log("tab(t)")
| |
| -- mw.logObject(t)
| |
| t = str.strip(t) | | t = str.strip(t) |
| if t ~= "" then | | if t ~= "" then |
| t = "<tab name = ".. name .. ">" .. t .. "</tab>" | | t = "<div class = \"factbox\"><tabs>" .. t .. "</tabs></div>" |
| end | | end |
| -- mw.log("t = " .. t)
| |
| return t | | return t |
| end | | end |
|
| |
|
| return p | | return p |