20.731
Bearbeitungen
(Umstellung fbdata.attr) Markierung: Zurückgesetzt |
(Bessere Tel.-Anzeige) |
||
| (16 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 8: | Zeile 8: | ||
local lfd = require("Modul:LinkFormDatum") | local lfd = require("Modul:LinkFormDatum") | ||
local wob = require("Modul:Wörterbuch") | local wob = require("Modul:Wörterbuch") | ||
local fab_red_links = require("Modul:Faktenbox/Zeilen/RedLinks") | |||
function p.zeileKategorieSeite_(fbdata, kindex) | function p.zeileKategorieSeite_(fbdata, kindex) | ||
| Zeile 15: | Zeile 17: | ||
-- =p.zeileKategorieSeite_({pagename="fpn",kategorie={"kat1","kat2"},kategorie_einzahl={"k1","k2"},klasse={"kla1","kla2"}}, 2) | -- =p.zeileKategorieSeite_({pagename="fpn",kategorie={"kat1","kat2"},kategorie_einzahl={"k1","k2"},klasse={"kla1","kla2"}}, 2) | ||
local t = "" | local t = "" | ||
local | local kategorie = wob.mehrzahl((fbdata.kategorie or fbdata.klasse)[kindex or 1]) | ||
local kategorie_einzahl = (fbdata.kategorie_einzahl or fbdata.klasse)[kindex or 1] | |||
t = t .. "<dt>[[:Kategorie:" .. kategorie .. "|" .. kategorie_einzahl .. "]]</dt>" | |||
t = t .. "<dt>[[:Kategorie:" . | |||
if wik.pageExists("Kategorie:" .. fbdata.pagename) then | if wik.pageExists("Kategorie:" .. fbdata.pagename) then | ||
t = t .. "<dd>[[:Kategorie:" .. fbdata.pagename .. "|" .. fbdata.pagename .. "]]</dd>" | t = t .. "<dd>[[:Kategorie:" .. fbdata.pagename .. "|" .. fbdata.pagename .. "]]</dd>" | ||
else | else | ||
t = t .. "<dd>'''" .. fbdata. | t = t .. "<dd>'''" .. fbdata.fullpagename .. "'''</dd>" | ||
end | end | ||
-- mw.logObject(t, "t") | -- mw.logObject(t, "t") | ||
return t | return t | ||
| Zeile 38: | Zeile 35: | ||
-- =p.zeileStrasseHnr_{strasse_hnr={strasse={{name="Erlanger Straße",hausnummer={"11", "13"}},{name="XY Straße",hausnummer={}}},anzahlGebaeude=3}} | -- =p.zeileStrasseHnr_{strasse_hnr={strasse={{name="Erlanger Straße",hausnummer={"11", "13"}},{name="XY Straße",hausnummer={}}},anzahlGebaeude=3}} | ||
local t = "" | local t = "" | ||
for is, sh in ipairs(fbdata.strasse_hnr.strasse) do -- Straßen/Hausnummer-Kombis durchiterieren | for is, sh in ipairs(fbdata.strasse_hnr.strasse) do -- Straßen/Hausnummer-Kombis durchiterieren | ||
t = t .. "<dt>" | t = t .. "<dt>" | ||
if is > 1 then | if is > 1 then | ||
t = t .. is .. ". " -- Numerierungsanzeige "2., "3." usw. | if is == 2 and #sh.hausnummer == 0 then | ||
t = t .. "Ecke " -- Sonderfall Ecke | |||
else | |||
t = t .. is .. ". " -- Numerierungsanzeige "2., "3." usw. | |||
end | |||
else | else | ||
is = "" -- keine 1, aber 2, 3, ... für weitere Verwendung | is = "" -- keine 1, aber 2, 3, ... für weitere Verwendung | ||
end | end | ||
t = t .. "Straße" | t = t .. "Straße" | ||
if #sh.hausnummer > 0 then | if #sh.hausnummer > 0 then | ||
t = t .. " / " .. "Hausnummer" -- nur wenn Hausnummern vorhanden | t = t .. " / " .. "Hausnummer" -- nur wenn Hausnummern vorhanden | ||
if #sh.hausnummer > 1 then | if #sh.hausnummer > 1 then | ||
t = t .. "n" -- Mehrzahl | t = t .. "n" -- Mehrzahl | ||
end | end | ||
end | end | ||
t = t .. "</dt><dd>[[" .. sh.name .. "]]" | t = t .. "</dt><dd>[[" .. sh.name .. "]]" | ||
smw.addAttrToList(fbdata.attr.list, "Straße" .. is, sh.name) | smw.addAttrToList(fbdata.attr.list, "Straße" .. is, sh.name) | ||
for ih, h in ipairs(sh.hausnummer) do -- Hausnummern durchiterieren | for ih, h in ipairs(sh.hausnummer) do -- Hausnummern durchiterieren | ||
local strasse_hnr_ = sh.name .. " " .. h | local strasse_hnr_ = sh.name .. " " .. h | ||
if ih > 1 then | if ih > 1 then | ||
t = t .. "," -- Kommas davor ab 2. Hausnummer | t = t .. "," -- Kommas davor ab 2. Hausnummer | ||
end | end | ||
if wik.pageExists(strasse_hnr_) then -- Link, wenn Seite vorhanden | if wik.pageExists(strasse_hnr_) then -- Link, wenn Seite vorhanden | ||
t = t .. " [[" .. strasse_hnr_ .. "|" .. h .. "]]" | t = t .. " [[" .. strasse_hnr_ .. "|" .. h .. "]]" | ||
else | else | ||
| Zeile 80: | Zeile 81: | ||
-- =p.zeileAktenNr_{pargs={AktenNr="D-5-63-000-1464"}} | -- =p.zeileAktenNr_{pargs={AktenNr="D-5-63-000-1464"}} | ||
local t = "" | local t = "" | ||
local aktennr = str.splitAndStrip(fbdata.pargs["AktenNr"] | local aktennr = str.splitAndStrip(fbdata.pargs["AktenNr"], ";") | ||
if #aktennr > 0 then | if #aktennr > 0 then | ||
t = t .. "<dt>" .. "Akten-Nr.</dt><dd>" | t = t .. "<dt>" .. "Akten-Nr.</dt><dd>" | ||
| Zeile 90: | Zeile 91: | ||
if #p > 1 then | if #p > 1 then | ||
t = t .. "{{#queryformlink:form=Abfrage Denkmalschutz|link text=" .. a .. "|query string=Abfrage Denkmalschutz[AktenNr]=" .. a .. "&_run}}" | t = t .. "{{#queryformlink:form=Abfrage Denkmalschutz|link text=" .. a .. "|query string=Abfrage Denkmalschutz[AktenNr]=" .. a .. "&_run}}" | ||
else | |||
t = t .. a | |||
end | end | ||
smw.addAttrToList(fbdata.attr.list, "AktenNr", a) | smw.addAttrToList(fbdata.attr.list, "AktenNr", a) | ||
| Zeile 143: | Zeile 146: | ||
-- =p.zeileDatum_{attr_date="Weihedatum",date="1959/11/15",attr_day="Weihetag",attr_year="Weihejahr"} | -- =p.zeileDatum_{attr_date="Weihedatum",date="1959/11/15",attr_day="Weihetag",attr_year="Weihejahr"} | ||
local t = "" | local t = "" | ||
if args.date ~= nil then | |||
t = t .. "<dt>" .. (args.attr_text or args.attr_date) .. "</dt><dd>" | t = t .. "<dt>" .. (args.attr_text or args.attr_date) .. "</dt><dd>" | ||
if com.isTrue(args.val_show_only) then | if com.isTrue(args.val_show_only) then | ||
t = t .. lfd.linkFormDate(date) | t = t .. lfd.linkFormDate(args.date) | ||
else | else | ||
t = t .. lfd.linkFormDate(date, args.attr_date, args.attr_day, args.attr_year) | t = t .. lfd.linkFormDate(args.date, args.attr_date, args.attr_day, args.attr_year) | ||
end | end | ||
t = t .. "</dd>" | t = t .. "</dd>" | ||
| Zeile 200: | Zeile 202: | ||
if #attr_val > 0 then | if #attr_val > 0 then | ||
-- Attribut-Text ermitteln und in Zeile übernehmen | -- Attribut-Text ermitteln und in Zeile übernehmen | ||
local attr_text = args.attr_text or wob. | local attr_text = args.attr_text or wob.attrText(attr_name, args.fbdata.klasse[1]) | ||
if #attr_val > 1 then | if #attr_val > 1 then | ||
attr_text = wob.mehrzahl(attr_text) -- Mehrzahl | attr_text = wob.mehrzahl(attr_text) -- Mehrzahl | ||
| Zeile 214: | Zeile 216: | ||
t = t .. ", " -- Listen-Kommata | t = t .. ", " -- Listen-Kommata | ||
end | end | ||
if mw.smw.getPropertyType(attr_name) == "_wpg" then | if not wik.pageExists("Attribut:" .. attr_name) then -- Spezialbehandlung Attribut nicht vorhanden | ||
t = t .. p.setStandardAttr(args.fbdata.attr.list, attr_name, val, args.exclude_bracket_values, args.val_show_only) | |||
else | |||
mw.logObject(attr_name, "attr_name") | |||
val = | local attr_type = mw.smw.getPropertyType(attr_name) | ||
mw.logObject(attr_type, "attr_type") | |||
if attr_type == "_wpg" then -- Seiten-Attribute Spezialbehandlung | |||
t = t .. p.setPageAttr(args.fbdata.attr.list, attr_name, val, args.val_show_only) | |||
elseif attr_type == "_ema" then -- E-Mail-Attribute Spezialbehandlung | |||
t = t .. p.setEmailAttr(args.fbdata.attr.list, attr_name, val, args.val_show_only) | |||
elseif attr_type == "_tel" then -- Telefon-Attribute Spezialbehandlung | |||
t = t .. p.setTelAttr(args.fbdata.attr.list, attr_name, val, args.val_show_only) | |||
else -- Standard-Attribute | |||
t = t .. p.setStandardAttr(args.fbdata.attr.list, attr_name, val, args.exclude_bracket_values, args.val_show_only) | |||
end | end | ||
end | end | ||
end | end | ||
| Zeile 239: | Zeile 249: | ||
t = t .. "[[" .. val .. "]]" | t = t .. "[[" .. val .. "]]" | ||
else | else | ||
val_pre_bracket, val_without_bracket, val_post_bracket = str.bracketSplitAndStrip(val) -- nach Klammern suchen und aufteilen | local val_pre_bracket, val_without_bracket, val_post_bracket = str.bracketSplitAndStrip(val) -- nach Klammern suchen und aufteilen | ||
if | if wik.pageExists(val_without_bracket) then -- Seite ohne Klammern vorhanden? | ||
if val_pre_bracket ~= "" then -- Klammer-Text vor eigentlicher Seite | if val_pre_bracket ~= "" then -- Klammer-Text vor eigentlicher Seite | ||
t = t .. val_pre_bracket .. " " | t = t .. val_pre_bracket .. " " | ||
| Zeile 251: | Zeile 259: | ||
end | end | ||
val = val_without_bracket | val = val_without_bracket | ||
-- auch ohne Klammern existiert keine Seite => dann roten Link anzeigen? | |||
elseif fab_red_links.red_links[name] ~= false then -- auch nil als default als roten Link | |||
t = t .. "[[" .. val .. "]]" | |||
else | |||
t = t .. val | |||
end | end | ||
end | end | ||
if not val_show_only then | if not val_show_only then | ||
smw.addAttrToList(attrlist, name, val) | smw.addAttrToList(attrlist, name, val) | ||
end | |||
-- mw.logObject(t, "t") | |||
return t | |||
end | |||
function p.setEmailAttr(attrlist, name, val, val_show_only) | |||
local t = "" | |||
local val_pre_bracket, email, val_post_bracket = str.bracketSplitAndStrip(val) -- nach Klammern suchen und aufteilen | |||
if val_pre_bracket ~= "" then | |||
t = t .. val_pre_bracket .. " " | |||
end | |||
t = t .. "[mailto:" .. email .. " " .. email .. "]" | |||
if val_post_bracket ~= "" then | |||
t = t .. " " .. val_post_bracket | |||
end | |||
if not val_show_only then | |||
smw.addAttrToList(attrlist, name, email) | |||
end | |||
mw.logObject(t, "t") | |||
return t | |||
end | |||
function p.setTelAttr(attrlist, name, val, val_show_only) | |||
local t = "" | |||
local val_pre_bracket, tel, val_post_bracket = -- nach Klammern suchen und aufteilen | |||
str.bracketSplitAndStrip(val) | |||
tel = val_pre_bracket .. " " .. tel -- Klammer am Anfang wieder anfügen | |||
tel = p.getTelUri(tel) | |||
if string.sub(tel, 1, 1) == "+" then | |||
t = t .. "[tel:" .. tel .. " " .. val .. "]" | |||
else | |||
t = t .. val | |||
end | |||
if not val_show_only then | |||
smw.addAttrToList(attrlist, name, tel) | |||
end | end | ||
-- mw.logObject(t, "t") | -- mw.logObject(t, "t") | ||
| Zeile 281: | Zeile 329: | ||
function p.getTelUri(val) | function p.getTelUri(val) | ||
-- Alles außer Zahlen und + am Anfang ausfiltern | |||
local tel = "" | |||
local pre_plus = false | |||
for i = 1, mw.ustring.len(val) do | |||
local char = mw.ustring.sub(val, i, i) | |||
if (char == "+" and not pre_plus) or tonumber(char) ~= nil then -- + am Anfang erlaubt | |||
tel = tel .. char | |||
tel = | pre_plus = true | ||
end | end | ||
end | end | ||
-- | -- Sonderbehandlungen | ||
if mw.ustring.sub(tel, 1, 2) == "00" then -- 00 ... | |||
tel = "+" .. mw.ustring.sub(tel, 3) | |||
tel = | end | ||
if mw.ustring.sub(tel, 1, 1) == "0" and -- beginnt mit 0zzz (z = Zahl 1-9) | |||
(tonumber(mw.ustring.sub(tel, 2, 2)) or 0) > 0 then -- dann wird +49 angenommen | |||
tel = "+49" .. mw.ustring.sub(tel, 2) | |||
elseif mw.ustring.sub(tel, 1, 4) == "+490" then -- +49(0) ... | |||
tel = "+49" .. mw.ustring.sub(tel, 5) | |||
end | end | ||
return | return tel | ||
end | end | ||
return p | return p | ||