Modul:Klasse: Unterschied zwischen den Versionen

1.724 Bytes hinzugefügt ,  Donnerstag um 09:29
+ attributListeParser(), Attribut-Tabelle
("Faktenbox-Daten nicht unterstützt (Einzelwerte)")
(+ attributListeParser(), Attribut-Tabelle)
Zeile 6: Zeile 6:
local frm = require("Modul:Formular")
local frm = require("Modul:Formular")
local fab = require("Modul:Faktenbox")
local fab = require("Modul:Faktenbox")
local htm = require("Modul:HTML")


function p.Faktenbox( frame )
function p.Faktenbox( frame )
Zeile 76: Zeile 77:
'</tr>'
'</tr>'
t=t..'</table>'
t=t..'</table>'
-- Attribut-Tabelle
attr_list = p.attributListeParser(args.AttributListe)
if #attr_list > 0 then
attr = {"Attribut", "Datentyp", "EhemalsAttribut",
"Anzeigegenauigkeit", "Einzahl", "Mehrzahl", "Delimiter",
"FieldArgs", "Infotext", "Anzeigeformat"}
-- Tabellen-Kopf
t = t .. htm.tableHeader(attr)
-- Tabellen-Zeilen
for i, a in ipairs(attr_list) do
local line = {}
-- Attribut-Attribute
local attr_val = atr.getAttrAttributes(a, title)
attr_val = attr_val or {}
-- Zeile befüllen
for i, l in ipairs(attr) do
if l == "Attribut" then
line[i] = "[[Attribut:" .. a .. "|" .. a .. "]]"
else
line[i] = attr_val[l] or ""
end
end
t = t .. htm.tableLine(line)
end
-- Tabellen-Fuß
t = t .. htm.tableFooter()
end
return t
return t
end
end
Zeile 168: Zeile 198:
-- mw.logObject(t, "t")
-- mw.logObject(t, "t")
     return t
     return t
end
function p.attributListeParser(attribut_liste)
-- Kommandozeile zum Debuggen:
-- mw.logObject(p.attributListeParser("Test1;Test2; Test3 ;; ; "))
local attr_list = {}
if not com.isEmpty(attribut_liste) then
local loop_count = 0
repeat
loop_count = loop_count + 1
-- mw.logObject(loop_count, "loop_count")
-- Komma finden
local semicolon = string.find(attribut_liste, ";")
if semicolon == nil then -- letzter Eintrag
semicolon = #attribut_liste + 1
end
-- mw.logObject(semicolon, "semicolon")
-- aufteilen und zur attr_list hinzufügen
local attr = str.strip(string.sub(attribut_liste, 1, semicolon - 1))
-- mw.logObject(attr, "attr")
if attr ~= "" then
table.insert(attr_list, attr)
end
attribut_liste = string.sub(attribut_liste, semicolon + 1)
until attribut_liste == "" or loop_count >= 100 -- max. Durchläufe
end
return attr_list
end
end


return p
return p