15.082
Bearbeitungen
(zeileSemantikBrowsenAbfrage alles links) |
(+ getTelUri()) |
||
| (6 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 geo = require("Modul:Geo") | local geo = require("Modul:Geo") | ||
local que = require("Modul:Queries") | local que = require("Modul:Queries") | ||
local lfd = require("Modul:LinkFormDatum") | local lfd = require("Modul:LinkFormDatum") | ||
local wob = require("Modul:Wörterbuch") | |||
local | |||
function p.zeileKategorieSeite_(fbdata, kindex) | function p.zeileKategorieSeite_(fbdata, kindex) | ||
| Zeile 78: | Zeile 47: | ||
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 | |||
t = t .. "n" -- Mehrzahl | |||
end | |||
end | end | ||
t = t .. "</dt><dd>[[Straße" .. is .. "::" .. sh.name .. "]]" | t = t .. "</dt><dd>[[Straße" .. is .. "::" .. sh.name .. "]]" | ||
| Zeile 191: | Zeile 163: | ||
-- =p.zeileSemantikBrowsenAbfrage_{fullpagename="Rathaus"} | -- =p.zeileSemantikBrowsenAbfrage_{fullpagename="Rathaus"} | ||
local t = "" | local t = "" | ||
t = t .. " | t = t .. " " | ||
t = t .. "[[Bild:IconSearch.svg|16px|semantisches Browsen|link=[[Spezial:Durchsuchen/" .. fbdata.fullpagename .. "]]]] " | t = t .. "[[Bild:IconSearch.svg|16px|semantisches Browsen|link=[[Spezial:Durchsuchen/" .. fbdata.fullpagename .. "]]]]" | ||
t = t .. " " | |||
t = t .. "[[Spezial:Durchsuchen/" .. fbdata.fullpagename .. "|Sem. Browsen]]" | t = t .. "[[Spezial:Durchsuchen/" .. fbdata.fullpagename .. "|Sem. Browsen]]" | ||
if fbdata.kategorie ~= nil and wik.pageExists("Formular:Abfrage " .. fbdata.kategorie[1]) then | if fbdata.kategorie ~= nil and wik.pageExists("Formular:Abfrage " .. fbdata.kategorie[1]) then | ||
t = t .. " / {{#queryformlink:form=Abfrage " .. fbdata.kategorie[1] .. "|link text=Abfrage}}" | t = t .. " / {{#queryformlink:form=Abfrage " .. fbdata.kategorie[1] .. "|link text=Abfrage}}" | ||
end | end | ||
-- mw.logObject(t, "t") | -- mw.logObject(t, "t") | ||
return t | return t | ||
| Zeile 228: | Zeile 200: | ||
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 | local attr_text = args.attr_text or wob.attr_text(attr_name) | ||
if #attr_val > 1 then | if #attr_val > 1 then | ||
attr_text = | attr_text = wob.mehrzahl(attr_text) -- Mehrzahl | ||
end | end | ||
t = t .. "<dt>" .. attr_text .. "</dt>" | t = t .. "<dt>" .. attr_text .. "</dt>" | ||
| Zeile 245: | Zeile 217: | ||
t = t .. p.setPageAttr(attr_name, val, args.val_show_only) | t = t .. p.setPageAttr(attr_name, val, args.val_show_only) | ||
else -- alle anderen Attribut-Datentypen | else -- alle anderen Attribut-Datentypen | ||
if mw.smw.getPropertyType(attr_name) == "_tel" then -- Telefonnummer Spezialbehandlung | |||
val = p.getTelUri(val) | |||
end | |||
t = t .. p.setStandardAttr(attr_name, val, args.exclude_bracket_values, args.val_show_only) | t = t .. p.setStandardAttr(attr_name, val, args.exclude_bracket_values, args.val_show_only) | ||
end | end | ||
| Zeile 314: | Zeile 289: | ||
-- mw.logObject(t, "t") | -- mw.logObject(t, "t") | ||
return t | return t | ||
end | |||
function p.getTelUri(val) | |||
local tel = str.strip(val) -- preload default | |||
if mw.ustring.sub(tel, 1, 1) == "0" and -- beginnt mit 0zzz (z = Zahl) | |||
(tonumber(mw.ustring.sub(tel, 2, 2)) or 0) > 0 then | |||
tel = "+49 " .. mw.ustring.sub(tel, 2) | |||
elseif mw.ustring.sub(tel, 1, 3) == "+49" then -- +49 (0) ... | |||
s, e = mw.ustring.find(tel, "%(0%)") | |||
if s ~= nil then | |||
tel = mw.ustring.sub(tel, 1, s - 1) .. " " .. mw.ustring.sub(tel, e + 1) | |||
end | |||
end | |||
-- Alle unerlaubten Zeichen und mehrfache Leerzeichen ausfiltern | |||
local telUri = "" | |||
local previous_char = "" | |||
tel = tel .. " " | |||
for i = 1, mw.ustring.len(tel) do | |||
local char = mw.ustring.sub(tel, i, i) | |||
if tonumber(char) ~= nil or | |||
char == "+" or char == "-" or char == "/" or | |||
(char == " " and previous_char ~= " ") then | |||
telUri = telUri .. previous_char | |||
previous_char = char | |||
end | |||
end | |||
return telUri | |||
end | end | ||
return p | return p | ||