21.056
Bearbeitungen
(- Modul:Queries) |
(+ Attribut:Gebäude) |
||
| (4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
local p = {} | local p = {} | ||
local str = require("Modul:String") | local str = require("Modul:String") | ||
local wik = require("Modul:Wiki") | local wik = require("Modul:Wiki") | ||
local kal = require("Modul:Kalender") | |||
local lfd = require("Modul:LinkFormDatum") | local lfd = require("Modul:LinkFormDatum") | ||
| Zeile 28: | Zeile 28: | ||
["StraßeHnr"] = { querypostfix = "#-", default = ""}, | ["StraßeHnr"] = { querypostfix = "#-", default = ""}, | ||
["VonObjekt"] = { querypostfix = "#-", default = ""}, | ["VonObjekt"] = { querypostfix = "#-", default = ""}, | ||
["Gebäude"] = { querypostfix = "#-", default = ""}, | |||
["AdresseVon"] = { querypostfix = "", default = ""}, | ["AdresseVon"] = { querypostfix = "", default = ""}, | ||
["AdresseBis"] = { querypostfix = "", default = ""}} | ["AdresseBis"] = { querypostfix = "", default = ""}, | ||
["Kommentar"] = { querypostfix = "", default = ""}} | |||
-- SMW-DB-Abfrage | -- SMW-DB-Abfrage | ||
| Zeile 58: | Zeile 60: | ||
-- Liste erstellen | -- Liste erstellen | ||
t = t .. "<nowiki></nowiki>\n" | t = t .. "<nowiki></nowiki>\n" -- nötig, warum auch immer, damit erster Listeeintrag richtig gerendert wird | ||
for _, e in ipairs(addresses) do | for _, e in ipairs(addresses) do | ||
t = t .. "* '''" | t = t .. "* '''" -- Zeilenanfang Liste | ||
-- Straße/Hausnummer ausgeben | -- Straße/Hausnummer ausgeben | ||
if wik.pageExists(e["StraßeHnr"]) then | if wik.pageExists(e["StraßeHnr"]) then -- Link zu Einzel-Gebäude-Seite | ||
t = t .. "[[" .. e["StraßeHnr"] .. "]]" | t = t .. "[[" .. e["StraßeHnr"] .. "]]" | ||
elseif wik.pageExists(e["VonObjekt"]) then | elseif wik.pageExists(e["VonObjekt"]) then -- alternativ Link zu Gebäude-Komplex-Seite | ||
t = t .. "[[" .. e["VonObjekt"] .. "|" .. e["StraßeHnr"] .. "]]" | t = t .. "[[" .. e["VonObjekt"] .. "|" .. e["StraßeHnr"] .. "]]" | ||
elseif wik.pageExists(e["Straße"]) then | elseif wik.pageExists(e["Gebäude"]) then -- alternativ Link zu Gebäude-Komplex-Seite | ||
t = t .. "[[" .. e["Gebäude"] .. "|" .. e["StraßeHnr"] .. "]]" | |||
elseif wik.pageExists(e["Straße"]) then -- alternativ Link zu Straße-Seite | |||
t = t .. "[[" .. e["Straße"] .. "]] " .. tostring(e["Hausnummer"]) | t = t .. "[[" .. e["Straße"] .. "]] " .. tostring(e["Hausnummer"]) | ||
elseif e["StraßeHnr"] ~= "" then | |||
t = t .. "" | t = t .. e["StraßeHnr"] -- alternativ nur fetter Text | ||
elseif e["Kommentar"] ~= "" then | |||
t = t .. e["Kommentar"] -- alternativ nur fetter Text | |||
else | |||
t = t .. " " -- damit es keine Probleme gibt mit ''' | |||
end | end | ||
t = t .. "'''" | t = t .. "'''" | ||
| Zeile 149: | Zeile 157: | ||
-- mw.log("smwDate2SortIndex(" .. date .. ")") | -- mw.log("smwDate2SortIndex(" .. date .. ")") | ||
-- Datum in Index wandeln | -- Datum in Index wandeln | ||
-- Bsp.: 23 | -- Bsp.: 23 April 1989 => 19890423 | ||
-- Konsolenzeile zum Debuggen: | -- Konsolenzeile zum Debuggen: | ||
-- =p.smwDate2SortIndex("2000") | -- =p.smwDate2SortIndex("2000") | ||
| Zeile 156: | Zeile 164: | ||
local sort_index = "" | local sort_index = "" | ||
local date=str.split2(date, " ") | local date=str.split2(date, " ") | ||
if #date == 1 then | if #date == 1 then -- nur Jahr vorhanden | ||
sort_index = tostring(date[1]) | sort_index = tostring(date[1]) | ||
if vonbis == "von" then | if vonbis == "von" then | ||
| Zeile 163: | Zeile 171: | ||
sort_index = sort_index .. "0000" | sort_index = sort_index .. "0000" | ||
end | end | ||
elseif #date == 2 then | elseif #date == 2 then -- nur Monat + Jahr vorhanden | ||
sort_index = tostring(date[2]) .. string.format("%02d", | sort_index = tostring(date[2]) .. string.format("%02d", kal.month_numbers[date[1]]) | ||
if vonbis == "von" then | if vonbis == "von" then | ||
sort_index = sort_index .. "99" | sort_index = sort_index .. "99" | ||
| Zeile 170: | Zeile 178: | ||
sort_index = sort_index .. "00" | sort_index = sort_index .. "00" | ||
end | end | ||
elseif #date == 3 then | elseif #date == 3 then -- komplettes Datum vorhanden | ||
sort_index = tostring(date[3]) .. string.format("%02d", | sort_index = tostring(date[3]) .. | ||
string.format("%02d", kal.month_numbers[date[2]]) .. | |||
string.format("%02d", tonumber(string.match(date[1], "%d*"))) | |||
end | end | ||
sort_index = tonumber(sort_index) or 0 | sort_index = tonumber(sort_index) or 0 | ||