Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:IESW/opis
--<source lang="lua">
--=p.main({args={'Test','Test',s='Test'}})
p={}
local data=mw.loadData('Moduł:IESW/data')
local title=mw.title.getCurrentTitle()
local title2=mw.title.new(title.text)
local title3=tostring(title):gsub('Infoboks:','')
function table.val_to_str ( v )
if "string" == type( v ) then
v = string.gsub( v, "\n", "\\n" )
if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then
return "'" .. v .. "'"
end
return '"' .. string.gsub(v,'"', '\\"' ) .. '"'
else
return "table" == type( v ) and table.tostring( v ) or
tostring( v )
end
end
function table.key_to_str ( k )
if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then
return k
else
return "[" .. table.val_to_str( k ) .. "]"
end
end
function table.tostring( tbl )
local result, done = {}, {}
for k, v in ipairs( tbl ) do
table.insert( result, table.val_to_str( v ) )
done[ k ] = true
end
for k, v in pairs( tbl ) do
if not done[ k ] then
table.insert( result,
table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
end
end
return "{" .. table.concat( result, "," ) .. "}"
end
function p.main(frame)
local infobox=mw.html.create('infobox')
local group=mw.html.create('group')
local name=mw.html.create('title')
local default=mw.html.create('default')
local navigation=mw.html.create('navigation')
local nav=mw.html.create('navigation')
local mapa=mw.html.create('group')
local sound=mw.html.create('group')
local links=mw.html.create('div')
local e,gr,ob,ma,t,c,v,w,factbox,debug,tty='','','','','','','','','',''
local y,o,g,h,z,u,l,m,a,n={},{},{},{},{},{},{},{},{},{}
local vFile={
brak = true,
nie = true,
brak_pliku = true,
nie_istnieje = true,
plik_nie_istnieje = true
}
mapa:tag('header'):wikitext('Mapa')
sound:tag('header'):wikitext('Dźwięk')
for i,x in pairs(frame.args) do
u=mw.text.split(i,':')
o[tonumber(u[1])]=i
g[tonumber(u[1])]=x
if u[2] == 'Występowanie' then w=mw.text.split(x:gsub('%[+(.-)%]+','%1'),',') end
for j=1, #w do
a[j]=mw.text.split(mw.text.trim(w[j]),'@%^')
w[j]=a[j][1]
end
end
for i,_ in ipairs(g) do
h=y
y=mw.text.split(o[i],':')
l[i]={'',''}
l[i]=mw.text.split(g[i],'@%^')
g[i]=l[i][1]
group:attr('collapse',(y[4] or 'open'))
group:attr('layout',(y[6] or ''))
group:attr('show',(y[7] or ''))
if h[3] ~= y[3] and is(y[3]) then
group:tag('header'):wikitext(y[3])
end
if is(g[i]) then
if y[2] == 'Ikona' then
default:wikitext('<div class="pi-icon">[[Plik:'..g[i]..'|32px|right]]</div>')
elseif y[2] == 'Nazwa' then
name:attr('source',y[2])
default:wikitext('<div class="pi-title-icon">'..g[i]..'</div>')
elseif y[2] == 'Podtytuł' then
default:wikitext('<div class="pi-subtitle">'..g[i]..'</div>')
elseif y[2] == 'Nawigacja' then
n[i]=mw.text.split(mw.text.trim(g[i]):gsub(', ',','),',')
navi,navi0,navi1,navi2='','','',''
if #n[i] <= 3 then
for j=0,#n[i]-1 do
navi1=navi1..'<span class="changebox ESWhover" id="switch'..j..'">'..(n[i][j+1] or '')..'</span>'
if j <= #n[i]-2 then
navi1=navi1..' • '
end
end
else
for j=0,3 do
navi1=navi1..'<span class="changebox ESWhover" id="switch'..j..'">'..(n[i][j+1] or '')..'</span>'
if j <= 2 then
navi1=navi1..' • '
end
end
for j=4,#n[i]-1 do
navi2=navi2..'<span class="changebox ESWhover" id="switch'..j..'">'..(n[i][j+1] or '')..'</span>'
if j <= #n[i]-2 then
navi2=navi2..' • '
end
end
end
if #n[i] > 3 then
navi0='<span class="pi-toggle mw-customtoggle-change" title="Pokaż więcej">+</span>'
end
navi='<div class="pi-change">'..navi1..navi0..'<div class="mw-collapsible mw-collapsed pi-change mw-collapsible-content" id="mw-customcollapsible-change">'..navi2..'</div>'
navigation:wikitext(navi):done()
elseif y[2] == 'Plik' then
if vFile[mw.ustring.lower(g[i]:gsub(' ','_'))] then
navigation:wikitext('<div>Plik do danego artykułu nie istnieje. Nie wystąpił nigdy w serii [[The Elder Scrolls]].</div>'):done()
else
if is(w) then
for j=1, #w do
file=mw.html.create('image')
file
:attr('source',y[2])
:tag('default')
:wikitext(IESWFile(g[i]:gsub('Plik:',''),'',w[j]))
end
else
file=mw.html.create('image')
file
:attr('source',y[2])
:tag('default')
:wikitext(IESWFile(g[i]:gsub('Plik:',''),'',''))
end
end
elseif y[2] == 'Podpis pliku' and is(file) then
file
:tag('alt')
:attr('source',y[2])
:wikitext('<default>'..g[i]..'</default>')
file
:tag('caption')
:attr('source',y[2])
:wikitext('<default>'..g[i]..'</default>')
elseif y[2] == 'Mapa' then
if vFile[mw.ustring.lower(g[i]:gsub(' ','_'))] then
navigation:wikitext('<div>Mapa do danego artykułu nie istnieje. Nie wystąpiła nigdy w serii [[The Elder Scrolls]].</div>'):done()
else
for j=1, #w do
map=mw.html.create('image')
map
:attr('source',y[2])
:tag('default')
:wikitext(IESWFile(g[i]:gsub('Plik:',''),'_(mapa)',w[j]))
end
end
elseif y[2] == 'Podpis mapy' and is(map) then
map
:tag('alt')
:attr('source',y[2])
:wikitext('<default>'..g[i]..'</default>')
map
:tag('caption')
:attr('source',y[2])
:wikitext('<default>'..g[i]..'</default>')
elseif y[2] == 'Dźwięk' then
sound:wikitext('<navigation><div class="showhide-onhover"><span class="audio_button">'..IESWSound(g[i]:gsub('Plik:',''),'',w[j])..'</span></div></navigation>')
elseif y[2] == 'nav' then
group:tag('navigation'):wikitext(g[i]):done()
elseif y[2] == 'link' then
group:tag('navigation'):wikitext('['..g[i]..' Oficjalna strona internetowa]')
if ans() then
group:tag('navigation'):wikitext('{{#set:Oficjalna strona internetowa='..g[i]..'}}'):done()
end
elseif y[2] == 'szablon' then
t=g[i]
elseif y[2] == 'debug' then
debug=g[i]
elseif y[2] == 'kategoria' then
c=g[i]
elseif y[2] == 'motyw' then
infobox:attr('theme',IESWLine('Występowanie',g[i]:gsub('%[+(.-)%]+','%1'),3))
else
--56:Szczęście:Atrybuty:closed:l:horizontal:incomplete:cat:unique:sort:sep:none
--(frame.args.s,frame.args[1],frame.args[2],frame.args.u,frame.args.sort,frame.args.r,frame.args.cat,frame.args.none)
group:wikitext('<data source="'..y[2]..'"><label>'..y[2]..'</label><default>'..IESWCore(y[5],g[i],y[2],y[9],y[10],y[11],y[8],y[12],y[3],w,y[14],y[15])..'</default></data>')
end
elseif is(y[13]) then
group:wikitext('<data source="'..y[2]..'"><label>'..y[2]..'</label></data>')
else
if y[2] == 'Ikona' then
elseif y[2] == 'Nazwa' then
name:attr('source',y[2])
default:wikitext('<div class="pi-title-icon">'..title2.fullText:gsub('%b()','')..'</div>')
elseif y[2] == 'Podtytuł' then
elseif y[2] == 'Plik' then
for j=1, #w do
if is(IESWFile(g[i]:gsub('Plik:',''),'',w[j])) then
file=mw.html.create('image')
file
:attr('source',y[2])
:tag('default')
:wikitext(IESWFile(g[i]:gsub('Plik:',''),'',w[j]))
else
navigation:wikitext(IESWCaption('',w[j])):done()
end
end
elseif y[2] == 'Mapa' then
for j=1, #w do
if is(IESWFile(g[i]:gsub('Plik:',''),'',w[j])) then
map=mw.html.create('image')
map
:attr('source',y[2])
:tag('default')
:wikitext(IESWFile(g[i]:gsub('Plik:',''),'_(mapa)',w[j]))
else
navigation:wikitext(IESWCaption('m',w[j])):done()
end
end
else
if is(l[i][2]) then
group:wikitext('<data source="'..y[2]..'"><label>'..y[2]..'</label><default>'..l[i][2]..'</default></data>')
elseif is(y[15]) then
group:wikitext('<data source="'..y[2]..'"><label>'..y[2]..'</label><default>{{#if:{{IESWAutoGen|'..y[2]..'}}|{{IESWAutoGen|'..y[2]..'}}{{#set:'..y[2]..'={{IESWAutoGen|'..y[2]..'}}}}}}</default></data>')
end
end
end
z=mw.text.split(tostring(o[i+1]),':')
if z[3] ~= y[3] and is(z[3]) then
gr=gr..tostring(group)
group=mw.html.create('group')
end
end
gr=gr..tostring(group)
if ins() or uns() then
inf=''
else
inf='Infoboks:'
end
links
:attr('class','pi-links')
:tag('div')
:attr('class','pi-links-left left plainlinks')
:wikitext('[['..t..'|<span title="Zapoznaj się z dokumentacją szablonu.">s</span>]] • ['..tostring(mw.uri.fullUrl('Specjalna:Przegląd/'..title.fullText))..' <span title="Zobacz własności szablonu.">w</span>]')
links
:tag('div')
:attr('class','pi-links-right right plainlinks')
:wikitext('<span title="Podgląd">['..tostring(mw.uri.fullUrl(inf..title.fullText))..' p]</span> • <span title="Dyskusja">['..tostring(mw.uri.fullUrl('Dyskusja_infoboksu:'..title.fullText))..' d]</span> • <span title="Edytuj">['..tostring(mw.uri.fullUrl(inf..title.fullText,'action=edit'))..' e]</span> • <span title="Edytuj korzystając z formularza">['..tostring(mw.uri.fullUrl(inf..title.fullText,'action=formedit'))..' f]</span>')
if ins() then
e='[[Kategoria:'..c..']]<span style="font-size:14px;">Powrót do: [['..tostring(title2)..']]</span>'
factbox='{{Special:Browse/'..tostring(title2)..'}}'
end
name:node(default)
mapa:node(map)
infobox
:node(name)
:node(navigation)
:node(file)
:node(mapa)
:node(sound)
:wikitext(gr..'<navigation>'..tostring(links)..'</navigation>')
if t == 'Szablon:Karta' then
tty='<div class="Vuh-card"><div class="Vuh-border"><div class="Vuh-background">'..tostring(infobox)..'</div></div></div>'
end
--{{#ifeq:{{NAMESPACE}}||{{#switch:{{{Typ|}}}|Książka|Zwój={{Bethesda książka}}}}}}
e='<div class="only-sysop">{{IESWAutoEdit|'..t:gsub('.*:','')..'}}</div>{{IESWUpdate}}{{#vardefine:a|{{#expr:{{#var:a}}+1}}}}{{#ifexpr:{{#var:a}}=1|{{#vardefine:l|0}}}}<div class="changebox" id="switch{{#var:l}}{{#vardefine:l|{{#expr:{{#var:l}}+1}}}}">'..e..(tty or tostring(infobox))..factbox..'</div>'
if ins() and (mw.title.new(title3).isRedirect or not mw.title.new(title3).exists) then
e=e..'[[Kategoria:Infoboksy wymagające przeniesienia]]'
end
if is(debug) then
return mw.getCurrentFrame():preprocess('<pre>'..e..'</pre>')
else
return mw.getCurrentFrame():preprocess(e)
end
end
function IESWLine(v1,v2,v3,v4)
if v1 == "all" then
local suc, res = pcall(function() for k, v in pairs(data) do if k ~= 'forms' and v[mw.ustring.lower(v2)] ~= nil then return v[mw.ustring.lower(v2)] end end end)
local success, result = pcall(function() return suc and data['forms'][res][v3] end)
return success and result or data["#default"] or v2
else
local success, result = pcall(function() return data['forms'][data[v1][mw.ustring.lower(v2)]][v3] end)
return success and result or data["#default"] or v2
end
end
--(frame.args.s,frame.args[1],frame.args[2],frame.args.u,frame.args.sort,frame.args.r,frame.args.cat,frame.args.none)
function IESWCore(v1,v2,v3,v4,v5,v6,v7,v8,v9,wys,v10,v11)
local value,l,s='','',''
local z,r,h,li={},{},{},{}
local k=0
if is(v2) then
if not is(v3) then v3=v9 end
s=v1
if is(v10) then k2=v2 else k2=v2:gsub('%[+(.-)%]+','%1') end
if is(v11) then k2:gsub('<br.*?>',', '):gsub('\n',', ') end
v=mw.text.split(k2,v6 or ', ')
for _,z in ipairs(v) do
k=k+1
li[k]=mw.text.split(z:gsub(';',','):gsub('%$',';'),'%~')
z=li[k][1]:gsub('~%(+(.-)%)+','<%1>')
z=mw.text.trim(z):gsub('%<+(.-)%>+','(%1)')
if not is(v4) then
if not h[z] then
r[#r+1]=z
h[z]=true
end
else
r=z
end
end
if not is(v5) then
table.sort(r)
end
for i=1, #r do
if is(v7) or v3 == 'Występowanie' then
r[i]=IESWLine(v3,r[i],1)
end
l=r[i]:gsub('Zadanie:',''):gsub('%b()','')
if is(r[i]) then
if s == "i" then
r[i]='[[Plik:'..r[i]..'|16px]]'
elseif s == "a" then
r[i]='<div class="Vuh-attr Vuh-'..r[i]..'">'..l..'</div>'
elseif s == "p" then
r[i]='{{#dpl:execandexit=geturlargs}}{{#dplvar:default|poziom|1}}[['..v3..'::{{#replace:{{#iferror:{{#expr:{{#replace:'..r[i]..'|Poziom|1}}}}|'..r[i]..'|{{#expr:{{#replace:'..r[i]..'|Poziom|1}}}}}}|.|,}}|{{#replace:{{#iferror:{{#expr:{{#replace:'..r[i]..'|Poziom|{{#dplvar:poziom}}}}}}|'..r[i]..'|{{#expr:{{#replace:'..r[i]..'|Poziom|{{#dplvar:poziom}}}}}}}}|.|,}}]]'
elseif s == "r" then
r[i]='<div class="Vuh-rarity Vuh-rarity-'..r[i]..'">'..l..'</div>'
elseif s == "k" then
r[i]='<div style="background:rgb('..r[i]..')" class="pi-boxcolor"></div>'
elseif s == "sw" then
for j=1, #wys do
r[i]='[['..v3..'::'..l..IESWLine('Występowanie',wys[j],4)..'|'..l..']]'
end
elseif s == "s" then
r[i]='[['..v3..'::'..r[i]..'|'..l..']]'
elseif s == "l" then
r[i]='[['..r[i]..'|'..l..']]'
elseif s == "b" then
r[i]=r[i]
elseif s == "bs" then
r[i]='<span>'..r[i]..'</span>'
else
r[i]='[['..v3..'::'..r[i]..'|'..l..']]'
end
--for i=1,#v do
-- for b=2, k-1 do
-- li[i][2]=li[i][2]..tostring(li[i][b+1])
-- end
if is(li[i][2]) then
value=value..'<div data-line="'..v3..'">{{#iferror:'..mw.text.trim(r[i]..' '..li[i][2])..'|[[Kategoria:Infoboksy z niepoprawnymi wartościami ]]}}</div>'
else
value=value..'<div data-line="'..v3..'">{{#iferror:'..r[i]..'|[[Kategoria:Infoboksy z niepoprawnymi wartościami ]]}}</div>'
end
--end
if is(v7) and is(wys) then
if ans() then
for j=1, #wys do
value=value..'[[Kategoria:'..IESWLine('Występowanie',wys[j],2)..IESWLine(v3,mw.text.trim(l),2)..']]'
end
end
end
end
end
if is(v8) then
value=''
else
value=mw.getCurrentFrame():preprocess(value)
end
end
return value
end
function IESWCaption(v1,w)
local v,m,c='','',''
if is(v1) then
v2='_(mapa)'
m='map'
else
v2=''
m='grafik'
end
if ans() then
v=v..'[[Kategoria:Bez grafiki w infoboksie]]'
end
v=v..'<div>Artykuł nie posiada '..m..'? <span class="plainlinks">['..tostring(mw.uri.fullUrl('Specjalna:Prześlij','wpDestFile='..IESWFilexxx(v2,'png',w)..'&wpLicense=Fairuse'))..' Dodaj je!]</span></div>'
if ans() then
v=v..'{{#ifeq:{{#regexall:{{:{{BASEPAGENAME}}}}/plik{{!}}gallery{{!}}file/i|nope}}|nope||[[Kategoria:Bez grafiki w artykule]]}}'
end
return v
end
function IESWFile(v1,v2,w)
local v=''
v2=v2 or ''
w=w or ''
-- v='{{#arraydefine:#s#|'..v1..'|/(png{{!}}bmp{{!}}jp?g{{!}}gif)({{!}}.*?),/i}}{{#if:{{#arrayindex:#s#|1}}|{{#arraydefine:#l#|'..v1..'|;}}{{#tag:gallery|{{#regex:{{#arrayprint:#l#|{{!}}}}|/(.*?)(\.)(png{{!}}bmp{{!}}jp?g{{!}}gif)(\{{!}})?(.*?),/i|$1$2$3$4$5<nowiki /><nowiki />Plik:}}}}|{{#if:{{#arrayindex:#s#|0}}|'
if is(v1) then
if ans() then v=v..'{{#set:Plik=Plik:'..v1..'}}' end
v=v..'[[Plik:'..v1..']]'
else
if mw.title.new('Plik:'..IESWFilexxx(v2,'png',w)).exists then
if ans() then v=v..'{{#set:Plik=Plik:'..IESWFilexxx(v2,'png',w)..'}}' end
v=v..'[[Plik:'..IESWFilexxx(v2,'png',w)..']]'
elseif mw.title.new('Plik:'..IESWFilexxx(v2,'gif',w)).exists then
if ans() then v=v..'{{#set:Plik=Plik:'..IESWFilexxx(v2,'gif',w)..'}}' end
v=v..'[[Plik:'..IESWFilexxx(v2,'gif',w)..']]'
elseif mw.title.new('Plik:'..IESWFilexxx(v2,'jpg',w)).exists then
if ans() then v=v..'{{#set:Plik=Plik:'..IESWFilexxx(v2,'jpg',w)..'}}' end
v=v..'[[Plik:'..IESWFilexxx(v2,'jpg',w)..']]'
end
end
-- v=v..'}}}}'
return v
end
function IESWSound(v1,v2,w)
local v=''
v2=v2 or ''
w=w or ''
if is(v1) then
if ans() then v=v..'{{#set:Plik=Plik:'..v1..'}}' end
v=v..'[[Plik:'..v1..']]'
else
if mw.title.new('Plik:'..IESWFilexxx(v2,'oga',w)).exists then
if ans() then v=v..'{{#set:Plik=Plik:'..IESWFilexxx(v2,'oga',w)..'}}' end
v=v..'[[Plik:'..IESWFilexxx(v2,'oga',w)..'|► Odtwórz]]'
elseif mw.title.new('Plik:'..IESWFilexxx(v2,'ogg',w)).exists then
if ans() then v=v..'{{#set:Plik=Plik:'..IESWFilexxx(v2,'ogg',w)..'}}' end
v=v..'[[Plik:'..IESWFilexxx(v2,'ogg',w)..'|► Odtwórz]]'
elseif mw.title.new('Plik:'..IESWFilexxx(v2,'ogv',w)).exists then
if ans() then v=v..'{{#set:Plik=Plik:'..IESWFilexxx(v2,'ogv',w)..'}}' end
v=v..'[[Plik:'..IESWFilexxx(v2,'ogv',w)..'|► Odtwórz]]'
elseif mw.title.new('Plik:'..IESWFilexxx(v2,'mp3',w)).exists then
if ans() then v=v..'{{#set:Plik=Plik:'..IESWFilexxx(v2,'mp3',w)..'}}' end
v=v..'[[Plik:'..IESWFilexxx(v2,'mp3',w)..'|► Odtwórz]]'
end
end
return v
end
function IESWFilexxx(v1,v2,w)
return title3:gsub(tostring(IESWLine('Występowanie',w,5)),'')..v1..(IESWLine('Występowanie',w,4) or '')..'.'..v2
end
function p.getLine(frame)
if is(frame.args[5]) then
return frame:preprocess(frame.args[1])
else
return IESWLine(frame.args[1],frame.args[2],tonumber(frame.args[3]),frame.args[4])
end
end
function is(v)
return v ~= nil and v ~= ""
end
function _if(a,b,c)
if a then return b else return c end
end
function ans()
return title.namespace == 0 or title.namespace == 112
end
function ins()
return title.namespace == 114
end
function uns()
return title.namespace == 2
end
return p
--</source>
Treści społeczności są dostępne na podstawie licencji CC-BY-SA, o ile nie zaznaczono inaczej.