Modul:Reihenabfrage: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
local p = {} | local p = {} | ||
function print_r ( t ) | |||
local print_r_cache={} | |||
local function sub_print_r(t,indent) | |||
if (print_r_cache[tostring(t)]) then | |||
print(indent.."*"..tostring(t)) | |||
else | |||
print_r_cache[tostring(t)]=true | |||
if (type(t)=="table") then | |||
for pos,val in pairs(t) do | |||
if (type(val)=="table") then | |||
print(indent.."["..pos.."] => "..tostring(t).." {") | |||
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8)) | |||
print(indent..string.rep(" ",string.len(pos)+6).."}") | |||
else | |||
print(indent.."["..pos.."] => "..tostring(val)) | |||
end | |||
end | |||
else | |||
print(indent..tostring(t)) | |||
end | |||
end | |||
end | |||
sub_print_r(t," ") | |||
end | |||
function holeReihen(frame,artikel) | function holeReihen(frame,artikel) | ||
Zeile 55: | Zeile 80: | ||
function p.Abfrage(frame) | function p.Abfrage(frame) | ||
return holeGeschichten(frame) | return print_r(holeGeschichten(frame)) | ||
end | end | ||
return p | return p |
Version vom 12. April 2019, 14:04 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Reihenabfrage/Doku erstellt werden
local p = {} function print_r ( t ) local print_r_cache={} local function sub_print_r(t,indent) if (print_r_cache[tostring(t)]) then print(indent.."*"..tostring(t)) else print_r_cache[tostring(t)]=true if (type(t)=="table") then for pos,val in pairs(t) do if (type(val)=="table") then print(indent.."["..pos.."] => "..tostring(t).." {") sub_print_r(val,indent..string.rep(" ",string.len(pos)+8)) print(indent..string.rep(" ",string.len(pos)+6).."}") else print(indent.."["..pos.."] => "..tostring(val)) end end else print(indent..tostring(t)) end end end sub_print_r(t," ") end function holeReihen(frame,artikel) local a=frame:callParserFunction( '#ask', '[[-Has subobject::'..artikel..']]', '?Reihe ist#=', 'sep=€', 'mainlabel=-' ) return mw.text.split(a,'€',true) end function holeAttribut(frame,artikel,attribut) local a=frame:callParserFunction( '#ask', '[['..artikel..']]', '?'..attribut..'#=', 'mainlabel=-' ) return a end function holeGeschichten(frame) local r={} local i=0 local s='<q>[[Geschichten:+]] OR [[Lieder:+]] OR [[Heroldartikel:+]]</q>' local a=frame:callParserFunction( '#ask',s, 'mainlabel=-', '?#=', 'sep=€', 'limit=10', 'searchlabel=', 'format=list', 'sort=Erstellt', 'order=desc' ) local t=mw.text.split(a,'€',true) for key,value in pairs(t) do local reihen=holeReihen(frame,value) local beschreibung=holeAttribut(frame,value,"Kurzbeschreibung") local wappen=holeAttribut(frame,value,"Wappen ist") for key2,value2 in pairs(reihen) do r[i]={} r[i]["Artikel"]=value r[i]["Reihe"]=value2 r[i]["Beschreibung"]=beschreibung r[i]["Wappen"]=wappen i=i+1 end end return r end function p.Abfrage(frame) return print_r(holeGeschichten(frame)) end return p