Modul:Faktenbox/Common/Work
Aus FürthWiki
< Modul:Faktenbox | Common
Die Dokumentation für dieses Modul kann unter Modul:Faktenbox/Common/Work/Doku erstellt werden
local p = {}
local com = require("Modul:Common")
local dev = require("Modul:Development")
local str = require("Modul:String")
local wik = require("Modul:Wiki")
local smw = require("Modul:SMW")
function p.common_(fbdata)
-- mw.log("common_(fbdata)")
-- mw.logObject(fbdata, "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
smw.addAttrToList(fbdata.attrlist, "KlassenName", fbdata.klasse[1])
end
-- Formular
if fbdata.formular ~= nil then
fbdata.frame:callParserFunction("#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 com.isEmpty(fbdata.pargs) then
t = t .. "[[Kategorie:Hat leere Faktenbox]]"
end
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 fbdata.geoobjects == nil then
t = t .. "[[Kategorie:" .. fbdata.kategorie[1] .. ehemals_text .. " ohne Position]]"
end
-- Attribute setzen
mw.logObject(fbdata.attrlist, "fbdata.attrlist")
mw.smw.set(fbdata.attrlist)
-- mw.log("t = " .. t)
return t
end
function p.fbdata_(frame)
-- mw.log("fbdata_(frame)")
-- mw.logObject(fbdata, "fbdata")
-- Konsolenzeile zum Debuggen:
-- =p.fbdata_{pargs={a=1}}
local fbdata = {}
fbdata.frame, fbdata.pargs = dev.GetFrameAndParentArgs(frame)
wik.setPagenames(fbdata)
fbdata.attrlist = {}
-- mw.logObject(fbdata)
return fbdata
end
return p