Moduł:Sprawdź

 Dokumentacja modułu[zobacz] [edytuj] [historia] [odśwież]

Ten moduł zapewnia platformę programistyczną dla tworzenia szablonów budujących przypadki testowe szablonów Wikipedii. Przypadki testowe mogą być tworzone ręcznie, aczkolwiek te tworzone za pomocą szablonów opartych na module Lua, takim jak niniejszy moduł, mają taką zaletę, że argumenty szablonu muszą być wprowadzone jedynie jednokrotnie, co zmniejsza nakład pracy konieczny do tworzenia testów, a także zmniejsza ryzyko występowania błędów w danych wejściowych.

Porównaj

Ta funkcja jest obecnie wykorzystywana przez szablon {{Przypadek testowy}}.

Parametry

Funkcja do wykrywania wywołań szablonów z nierozpoznanymi, pustymi lub przestarzałymi parametrami. Należy ją wywołać ze wszystkimi możliwymi parametrami jakie przyjmuje szablon podlegający sprawdzaniu.

Opis parametrów
polestatusuwagi
bez nazwykonfiguracja działaniawymaganyklasa lub klasa odstęp suffix
innydeklaracja pola obsługiwanego w szablonieopcjonalnytxt, num, num?, uri, uri?, old, ^…$ lub pusty
Konfiguracja
  • klasa – ciąg znaków bez spacji umieszczany jako wartość atrybutu class w tagu <span> z wygenerowanym raportem
  • odstęp – ciąg znaków odstępu oddzielający pozostałą treść konfiguracji, jeśli zawiera znak nowej linii to przed wygenerowanym raportem jest również umieszczany znak nowej linii
  • suffix – treść dołączana po wygenerowanym raporcie, zwykle deklaracja technicznej kategorii
Sprawdzanie parametrów
  • pusty – parametr jest opcjonalny, jest to najczęściej stosowany sposób użycia
  • txt – oczekiwana jest dowolna niepusta wartość pola
  • text – oczekiwana jest dowolna niepusta wartość pola, która nie generuje obrazka
  • text? – oczekiwana jest wartość pola, która nie generuje obrazka
  • num – sprawdzanie czy przekazana wartość jest liczbą
  • num? – sprawdzanie czy przekazana wartość jest pusta lub jest liczbą
  • uri – sprawdzanie czy przekazana wartość jest linkiem obsługiwanym przez MediaWiki
  • uri? – sprawdzanie czy przekazana wartość jest pusta lub jest linkiem
  • grafika – sprawdzanie czy przekazana wartość jest nazwą pliku graficznego
  • grafika? – sprawdzanie czy przekazana wartość jest pusta lub jest nazwą pliku graficznego
  • old – informuje, że przekazywany parametr jest przestarzały
  • ^…$ – tekst rozpoczynający się znakiem ^ i zakończony na $ w całości traktowany jest jako wyrażenie regularne Lua wskazującego prawidłowy parametr
Tabela poprawności dla num i ^...$[a]
ModyfikatorBrak parametru

np. {{formatprice}}

Pusty parametr

np. {{formatprice|1=}}

Niepusty parametr

np. {{formatprice|123}}

?[b]poprawnepoprawnewg testu
bez mod.poprawnewg testuwg testu
!Brakujące pola: ...wg testuwg testu
Przykład
{{#invoke:Sprawdź|Parametry|=problemy-w-szablonie [[Kategoria:Błędy wywołań w szablonie]]|parametr_w_szablonie_1=|parametr_w_szablonie_2=num?}}

odn

Funkcja sprawdzająca prawidłowość parametrów w {{odn}}.

Uwagi

local function checkUri(uri)local urilen = #urifor _,v in ipairs(mw.loadData("Moduł:Cytuj/dane").supportedUriSchemas) doif (#v < urilen) and (string.lower(string.sub(uri,1, #v)) == v) thenreturn not string.match(uri, '%s')endendendfunction checkImageName(name)if not name or (#name==0) or string.match(name, "[#<>%[%]|{}]") thenreturn falseendlocal title = mw.title.makeTitle("Plik", name)if not title thenreturn falseendlocal res = {prefix = {plik = true,image = true,grafika = true,file = true,},extension = {jpg = true,jpeg = true,jpe = true,png = true,svg = true,tif = true,tiff = true,gif = true,xcf = true,pdf = true,djvu = true,webp = true,},}local prefix = string.match(name, "^:? *([^:]+) *:")if prefix and res.prefix[string.lower(prefix)] thenreturn falseendlocal extension = string.match(name, "%S.*%.([^%.]+)$")return extension and res.extension[string.lower(extension)]endlocal function findPlainHttp(text)if text thentext = mw.ustring.gsub(text, "%[[hH][tT][tT][pP][sS]?://%S+", "_")return string.match(text, "[hH][tT][tT][pP][sS]?://%S")endendlocal function findFile(text)-- schowaj wyjątek: obrazek generowany przez Szablon:Link-interwikitext = mw.ustring.gsub(text, "%[%[Plik:Wikidata%-logo%-en%.svg|10x9px|link=:d:Q%d+|Informacje powiązane z artykułem „.-” w Wikidanych%]%]", "")-- normalizetext = mw.ustring.gsub(text, "%s*[Pp]lik%s*:%s*", "Plik:")text = mw.ustring.gsub(text, "%s*[Ff]ile%s*:%s*", "Plik:")text = mw.ustring.gsub(text, "%s*[Gg]rafika%s*:%s*", "Plik:")text = mw.ustring.gsub(text, "%s*[Ii]mage%s*:%s*", "Plik:")return mw.ustring.match(text, "%[%[Plik:([^%[%]|]+)[|%]]")end-- Lista of template params for wikicode. Like this:-- | grafika = | data śmierci = | www = local function listToTplParams(strArray)return "| " .. table.concat(strArray, " = | ") .. " =";endlocal function showTemplate(templateName, args)local result = {}local flags = {}table.insert(result, mw.text.nowiki("{{"))if mw.isSubsting() thentable.insert(result, "subst:")endlocal title = mw.title.new(templateName)if not args thentable.insert(result, "[[")table.insert(result, title.nsText)table.insert(result, ":")table.insert(result, title.text)table.insert(result, "|")endif title.namespace ~= 10 thentable.insert(result, title.nsText)table.insert(result, ":")endtable.insert(result, title.text)if not args thentable.insert(result, "]]")endif args thenlocal i = 1while args[i] dotable.insert(result, "|")table.insert(result, mw.text.nowiki(args[i]))i = i + 1endfor k, v in pairs(args) dolocal index = tonumber(k)if (type(k) == "string") or (index and ((index < 1) or (index > i))) thentable.insert(result, "|")table.insert(result, tostring(k))table.insert(result, "=")table.insert(result, mw.text.nowiki(v))endendendtable.insert(result, mw.text.nowiki("}}"))return table.concat(result)endlocal function infoboxCatTitle(infobox, class)local catTitle = mw.title.makeTitle(14, "Infoboksy – "..class.." – "..infobox)if not catTitle.exists thenmw.logObject(catTitle, "Dedykowana kategoria błędów w infoboksie nie istnieje")catTitle = mw.title.makeTitle(14, "Infoboksy – "..class)endmw.logObject(catTitle, "infoboxCatTitle")return catTitleendlocal function daysInMonth(year, month)if month == 1 then return 31 endif month == 2 then return ((year % 4) == 0) and 29 or 28 endif month == 3 then return 31 endif month == 4 then return 30 endif month == 5 then return 31 endif month == 6 then return 30 endif month == 7 then return 31 endif month == 8 then return 31 endif month == 9 then return 30 endif month == 10 then return 31 endif month == 11 then return 30 endif month == 12 then return 31 endreturn 0endlocal function isDate20YYMMDD(date)local y, m, d = mw.ustring.match(date, "^(20[0-9][0-9])%-([01][0-9])%-([0123][0-9])$")local year = tonumber(y)local month = tonumber(m)local day = tonumber(d)local result = year and month and dayand (year >= 2001)and (month >= 1) and (month <= 12)and (day >= 1) and (day <= daysInMonth(year, month))if not result thenmw.logObject({date=date,year=year,month=month,day=day}, "isDate20YYMMDD")endreturn resultendreturn {["Porównaj"] = function(frame)local config = frame:getParent().args[""] or ""local options = mw.text.split(config, "|")local templateName = mw.text.trim(options[1])if #templateName == 0 thenlocal title = mw.title.getCurrentTitle()if title.namespace == 10 thentemplateName = mw.ustring.match(title.text, "^(.-)/opis")or mw.ustring.match(title.text, "^(.-)/test")or mw.ustring.match(title.text, "^(.-)/brudnopis")or title.textendif #templateName == 0 thenmw.log("brak nazwy szablonu")returnendendlocal templateTitle = mw.title.new(templateName, 10)if templateTitle.id == 0 thenmw.log("szablon '"..templateName.."' nie istnieje")returnendlocal sandboxName = templateName.."/brudnopis"local sandboxTitle = mw.title.new(sandboxName, 10)if sandboxTitle.id == 0 thenmw.log("brudnopis '"..sandboxName.."' nie istnieje")returnendlocal i = 2local showparams = truelocal showinfo = truelocal vertical = falsewhile i <= #options dolocal option = mw.text.trim(options[i])if option == "bez wikikodu" thenshowparams = falseelseif option == "bez opisu" thenshowinfo = falseelseif option == "pionowo" thenvertical = trueendi = i + 1endlocal templateParams = {}local params = {}for k, v in pairs(frame:getParent().args) doif k ~= "" thentemplateParams[k] = vtable.insert(params, k)endendlocal result = {}table.insert(result, '<table style="width: 100%;">')if showparams and (#params > 0) thenlocal compare = function(a, b)-- return a < bif (type(a) == "number") and (type(b) == "number") thenreturn a < bendif (type(a) == "string") and (type(b) == "string") thenreturn a < bendif (type(a) == "number") and (type(b) == "string") thenreturn trueendreturn falseendtable.sort(params, compare)table.insert(result, "<caption><code>&#x7B;&#x7B;")table.insert(result, templateName)for i, k in ipairs(params) dotable.insert(result, " &#x7C; ")local p = mw.text.nowiki(tostring(k))local v = mw.text.nowiki(templateParams[k])table.insert(result, p)table.insert(result, " = ")table.insert(result, v)endtable.insert(result, "&#x7D;&#x7D;</code></caption>")endlocal templateResult = frame:expandTemplate{ title=templateName, args=templateParams}local sandboxResult = frame:expandTemplate{ title=sandboxName, args=templateParams}if templateResult and string.match(templateResult, "^{|") thentemplateResult = "\n"..templateResultendif sandboxResult and string.match(sandboxResult, "^{|") thensandboxResult = "\n"..sandboxResultendif vertical and showinfo thentable.insert(result, '<tr><th style="width: 15em">[[Szablon:')table.insert(result, templateName)table.insert(result, '|Szablon]]</th><td>')table.insert(result, templateResult)table.insert(result, '</td></tr><tr><th>[[Szablon:')table.insert(result, sandboxName)table.insert(result, '|Brudnopis szablonu]]</th><td>')table.insert(result, sandboxResult)table.insert(result, '</td></tr>')elseif vertical thentable.insert(result, '<tr><td>')table.insert(result, templateResult)table.insert(result, '</td></tr><tr><td>')table.insert(result, sandboxResult)table.insert(result, '</td></tr>')elseif showinfo thentable.insert(result, '<tr><th style="width: 50%;">[[Szablon:')table.insert(result, templateName)table.insert(result, '|Szablon]]</th><th style="width: 50%;">[[Szablon:')table.insert(result, sandboxName)table.insert(result, '|Brudnopis szablonu]]</th></tr>')endtable.insert(result, '<tr style="vertical-align: top;"><td>')table.insert(result, templateResult)table.insert(result, '</td><td>')table.insert(result, sandboxResult)table.insert(result, '</td></tr>')endtable.insert(result, "</table>")return table.concat(result)end,["Parametry"] = function(frame)if mw.title.getCurrentTitle().contentModel ~= "wikitext" thenmw.logObject(mw.title.getCurrentTitle().contentModel, "mw.title.getCurrentTitle().contentModel")return -- to nie ma sensu w takim wypadkuendlocal unknown = {}local invalid = {}local deprecated = {}local nakedurl = {}local files = {}local templateName = frame:getParent():getTitle()local infobox = mw.ustring.match(templateName, "^Szablon:(.- infobox)$")local config = frame.args[""]local class, space, category = string.match(config or "", "^%s*(%S+)(%s+)(.-)%s*$")local nl = space and string.match(space, "\n") or ""class = class or configlocal function argName(arg)return type(arg) ~= "string" and tostring(arg) or ('"'..arg..'"')endlocal required = {}for k, v in pairs(frame.args) doif mw.ustring.match(v, "!$") thenrequired[k] = trueif infobox then-- odróżniaj pola sugerowane w infoboksach, które mogą być pusteif v == "!" or mw.ustring.match(v, "%?!$") thenrequired[k] = falseelselocal pattern = string.match(v,"^(^.-$)!?$")if pattern and mw.ustring.match("", pattern) thenrequired[k] = falseendendendendendlocal emptyArg = falsefor k, v in pairs(frame:getParent().args) dorequired[k] = nillocal kind = frame.args[k]if kind == "" or kind == "!" thenkind = "text?"endif k == "" thenemptyArg = velseif not kind thentable.insert(unknown, argName(k))elseif (kind == "num") or (kind == "num!") thenlocal n = tonumber(v)if not n then table.insert(invalid, argName(k)) endelseif (kind == "num?") or (kind == "num?!") thenlocal n = (#v == 0) or tonumber(v)if not n then table.insert(invalid, argName(k)) endelseif (kind == "grafika") or (kind == "grafika!") thenif findPlainHttp(v) thentable.insert(nakedurl, argName(k))elselocal g = checkImageName(v)if not g then table.insert(invalid, argName(k)) endendelseif (kind == "grafika?") or (kind == "grafika?!") thenif findPlainHttp(v) thentable.insert(nakedurl, argName(k))elselocal g = (#v == 0) or checkImageName(v)if not g then table.insert(invalid, argName(k)) endendelseif (kind == "uri") or (kind == "uri!") thenlocal u = checkUri(v)if not u then table.insert(invalid, argName(k)) endelseif (kind == "uri?") or (kind == "uri?!") thenlocal u = (#v == 0) or checkUri(v)if not u then table.insert(invalid, argName(k)) endelseif (kind == "txt") or (kind == "txt!") thenif #v == 0 thentable.insert(invalid, argName(k))elseif checkUri(v) thentable.insert(nakedurl, argName(k))elseif findPlainHttp(v) thentable.insert(nakedurl, argName(k))endelseif (kind == "text") or (kind == "text!") or (kind == "text?") thenif ((kind ~= "text?") and (#v == 0)) thentable.insert(invalid, argName(k))elseif findFile(v) thentable.insert(files, argName(k))elseif checkUri(v) thentable.insert(nakedurl, argName(k))elseif findPlainHttp(v) thentable.insert(nakedurl, argName(k))endelseif kind == "old" thentable.insert(deprecated, argName(k))elseif kind == "uri*" then -- specjalny przpadek dla pola 'url' w [[Szablon:Cytuj]]local u = checkUri(v) or checkUri(mw.text.unstripNoWiki(v))if not u then table.insert(invalid, argName(k)) endelselocal pattern = string.match(kind,"^(^.-$)!?$")if pattern and not mw.ustring.match(v, pattern) thentable.insert(invalid, argName(k))elseif (#v > 0) and checkUri(v) thentable.insert(nakedurl, argName(k))elseif findPlainHttp(v) thentable.insert(nakedurl, argName(k))endendendlocal missing = {}local suggested = {}mw.logObject(required, "required")for k, v in pairs(required) dotable.insert(v and missing or suggested, k)endif (#missing == 0) and (#suggested == 0) and (#unknown == 0) and (#invalid == 0) and (#deprecated == 0) and (#nakedurl == 0) and (#files == 0) thenreturn nilendlocal errorClasses = 0-- generate messages for each category of problemslocal messages = {}if #invalid > 0 thenerrorClasses = errorClasses + 2table.insert(messages, "Nieprawidłowe/puste pola: " .. mw.text.listToText(invalid) .. ".")endif (#missing > 0) or (#suggested > 0) thenerrorClasses = errorClasses + 1if (#missing > 0) then table.insert(messages, "Brakujące pola: " .. mw.text.listToText(missing) .. ".") endif (#suggested > 0) then table.insert(messages, "Sugerowane pola (wstaw w kodzie): <code>" .. listToTplParams(suggested) .. "</code>") endendif #unknown > 0 thenerrorClasses = errorClasses + 4table.insert(messages, "Nieznane pola: " .. mw.text.listToText(unknown) .. ".")endif #deprecated > 0 thenerrorClasses = errorClasses + 8table.insert(messages, "Przestarzałe pola: " .. mw.text.listToText(deprecated) .. ".")endif #nakedurl > 0 thenerrorClasses = errorClasses + 16table.insert(messages, "Gołe linki: " .. mw.text.listToText(nakedurl) .. ".")endif #files > 0 thenerrorClasses = errorClasses + 32table.insert(messages, "Nieoczekiwana grafika: " .. mw.text.listToText(files) .. ".")end-- render messageslocal message = mw.html.create()if emptyArg thenmessage:wikitext("|=", emptyArg, "| ")endif infobox thenmessage:wikitext("\n* ", table.concat(messages, "\n* "))elsemessage:wikitext(table.concat(messages, " "))endmessage = tostring(message)-- result containerlocal result = mw.html.create(infobox and "table" or "span")result:addClass("problemy"):addClass(class or nil):attr("aria-hidden", "true")local restext = resultif infobox thenresult:addClass("infobox")restext = result:tag("tr"):tag("td")elseresult:attr("data-nosnippet", "")end if templateName thenrestext:wikitext(showTemplate(templateName).." ")-- pomiń ten komunikat jeśli zabraknie tylko pól sugerowanych w infoboksieif not infobox or (errorClasses ~= 1) or (#missing > 0) then local warning = mw.html.create() warning:tag("code"):wikitext(showTemplate(templateName, frame:getParent().args)) warning:wikitext(" ") warning:tag("span"):addClass("problemy"):wikitext(message) mw.addWarning(tostring(warning)) end end  restext:wikitext(message) if category thenresult:wikitext(category)endif infobox thenif (errorClasses == 1) and (#missing <= 0) thenresult:addClass("tylko-braki") -- tylko SUGEROWANE brakiendif mw.title.getCurrentTitle().namespace == 0 thenif (#missing > 0) or (#suggested > 0) thenresult:wikitext("[[Kategoria:", infoboxCatTitle(infobox, "brakujące parametry").text, "]]")endif #invalid > 0 thenresult:wikitext("[[Kategoria:", infoboxCatTitle(infobox, "nieprawidłowe parametry").text, "]]")endif #unknown > 0 thenresult:wikitext("[[Kategoria:", infoboxCatTitle(infobox, "nieznane parametry").text, "]]")endif #deprecated > 0 thenresult:wikitext("[[Kategoria:", infoboxCatTitle(infobox, "przestarzałe parametry").text, "]]")endif #nakedurl > 0 thenresult:wikitext("[[Kategoria:", infoboxCatTitle(infobox, "gołe linki").text, "]]")endif #files > 0 thenresult:wikitext("[[Kategoria:", infoboxCatTitle(infobox, "grafika w nieodpowiednim miejscu").text, "]]")endendendreturn nl..tostring(result)end,["wartość"] = function(frame)local msg = frame.args.msglocal value = tonumber(frame.args[1]) or frame.args[1]local index = 2 -- pierwszy wzórwhile value dolocal pattern = frame.args[index]if not pattern thenbreak -- nie ma więcej wzorówendif mw.ustring.match(value, "^"..pattern.."$") thenreturn -- wzór pasuje, nie ma błędówend-- następny wzórindex = index + 1end-- komunikat błędureturn msgend,["odn"] = function(frame)local pf = frame:getParent()local i = 0 -- liczba argumentów pozycyjnychlocal problems = falselocal yeardetected = falsewhile true dolocal arg = pf.args[i + 1]if not arg thenproblems = i == 0 and "brak argumentów" or falsebreakend if (i >= 5) or yeardetected thenproblems = "za dużo argumentów pozycyjnych"breakend if #arg == 0 thenproblems = "pusty argument"breakend if arg ~= mw.text.trim(arg) thenproblems = "nieoczekiwane odstępy na początku lub końcu argumentu"breakend if string.match(arg, "^%d+%l?$") thenyeardetected = trueif i == 0 thenproblems = "rok musi być ostatnim parametrem po nazwiskach autorów"breakendelseif string.match(arg, "^s[%-%.:]%s*%d+") thenproblems = "prawdopodobnie nieprawidłowo podany numer strony"breakelseif string.match(arg, "%s%s") thenproblems = "podwójne odstępy"breakelseif mw.ustring.match(arg, "^%a+%d") thenif not mw.ustring.match(arg, "^[%u%d]+$") thenproblems = "prawdopodobnie sklejone argumenty (brak pionowej kreski)"breakendelseif mw.ustring.match(arg, "^OdeB ") then-- [[Ordre de Bataille]]elseif mw.ustring.match(arg, "^%u%l+%u") thenlocal justification = {["De"] = true,["Del"] = true,["Di"] = true,["Le"] = true,["Mac"] = true,["Mc"] = true,["Te"] = true, -- TeSelle["Sar"] = true, -- SarDesai["Van"] = true, -- VanBuren["La"] = true, -- LaSalle}if not justification[mw.ustring.match(arg, "^%u%l+")] thenproblems = "prawdopodobnie sklejone argumenty (brak pionowej kreski)"breakendend i = i + 1end if not problems thenlocal odn = pf.args.odnif odn and ((#odn ~= 1) or (odn < "a") or (odn > "z")) thenproblems = "nieoczekiwany parametr odn"endend  if not problems then local s = pf.args.s if s and string.match(s, "&[a-z]+;") then problems = "użyto encji HTML w numerze strony" end end if not problems thenif pf.args.strona or pf.args.ss or pf.args.strony or pf.args.p or pf.args.page or pf.args.pp or pf.args.pages thenproblems = "przestarzały parametr z numerem strony"endendlocal category = "Szablon odn do sprawdzenia" if not problems then  local function TextLinkToRFC() return (i == 1) and (pf.args.ref == "nie") and mw.ustring.match(pf.args[1], "^RFC [1-9][0-9]*$") end  local s = pf.args.s or "" local l = pf.args.loc or "" if (#s == 0) and (#l == 0) then local exception = TextLinkToRFC() if not exception then category = "Szablon odn bez numeru strony" problems = "brak numeru strony" end end end  if not problems then return nil end  local result = mw.html.create("span") :addClass("problemy") :addClass("problemy-w-odn"):attr("aria-hidden", "true"):attr("data-nosnippet", ""):attr("data-problemy", "ODN: "..problems) if mw.title.getCurrentTitle().namespace == 0 then result:wikitext("[[Kategoria:", category, "]]") end result:wikitext("&#8201;") -- thin space return tostring(result)end,["Wikidane"] = function(frame)local property = frame.args.cechalocal field = frame.args.polelocal value = frame.args[1]if not property or not field thenreturnendif not value thenvalue = frame:getParent().args[field]if not value or (#value == 0) thenreturnendendlocal entity = mw.wikibase.getEntity()if not entity or not entity.claims or not entity.claims[property] thenreturnendfor i, v in ipairs(entity.claims[property]) doif v.mainsnak.snaktype == "value" thenif value == v.mainsnak.datavalue.value thenreturnendendendlocal template = frame:getParent():getTitle()local infobox = mw.ustring.match(template, "^Szablon:(.- infobox)$")return mw.ustring.format("[[Kategoria:%s – niezgodność w Wikidanych – %s – %s]]", infobox and "Infoboksy" or "Szablony", infobox or template, field)end,["bez parametrów"] = function(frame)for k, v in pairs(frame:getParent().args) doreturn nilendreturn "tak"end,["pole z hostem"] = function (frame)local host = frame.args.hostif host and (#host > 0) thenfor k, v in pairs(frame:getParent().args) dolocal link = string.match(v, "[hH][tT][tT][pP][sS]?://[%S]+")if link thenlocal uri = mw.uri.new(link)local valid, _ = mw.uri.validate(uri)if valid and uri.host and (#uri.host > 0) thenif host == uri.host thenmw.logObject({k, link}, "cały")return kendif #host < #uri.host thenlocal s1 = '.'..hostlocal s2 = string.sub(uri.host, -#s1)if s1 == s2 thenmw.logObject({k, link}, "fragment")return kendendendendendendend,["pola z autorami"] = function (frame)local result = {}local nazwisko = frame.args["nazwisko"]local imie = frame.args["imię"]local autor = frame.args["autor"]local link = frame.args["link"]local maxIndex = tonumber(frame.args["max"])local prefix = frame.args["przed"] or ""local suffix = frame.args["po"] or ""for i = 1, maxIndex dolocal s = i == 1 and "" or tostring(i)local nin = string.gsub(nazwisko, '#', s)local iin = string.gsub(imie, '#', s)local ain = string.gsub(autor, '#', s)local lin = string.gsub(link, '#', s)local niv = frame:getParent().args[nin]local iiv = frame:getParent().args[iin]local aiv = frame:getParent().args[ain]local liv = frame:getParent().args[lin]local nis = niv and (#niv > 0)local iis = iiv and (#iiv > 0)local ais = aiv and (#aiv > 0)local lis = liv and (#liv > 0)local bad = (nis and ais) -- nazwisko -> zbędny autoror (nis and not iis) -- nazwisko bez imieniaor (lis and not nis and not ais) -- tylko linkor (iis and not nis) -- imię bez nazwiskaif bad thentable.insert(result, i)endendif #result > 0 thenreturn prefix..mw.text.listToText(result)..suffixendend,["uri"] = function(frame)mw.logObject(frame:getParent():getTitle(), "parent:title")_ = mw.title.new("Moduł:Sprawdź/deprecated/uri").idlocal link = frame.args["link"]local space = frame.args["spacja"]local check = checkUri(link)if check thenreturn linkendreturn (space and (check ~= nil)) and link or ""end,--[[Sprawdzanie url do szablonówWykorzystanie:{{#invoke:Sprawdź|url|{{{www|}}}|[{{{www}}} Strona internetowa]}}{{#invoke:Sprawdź|url|{{{www}}}|[{{{www}}} Strona internetowa]}}@param #1 Url do sprawdzenia.Ciąg typu "{{{abc}}}" pominie sprawdzenie, żeby pokazać wartość na stronie szablonu.@param #2 Tekst do wyświetlenia gdy OK.@return pusty string gdy błędny, "ok" lub zawartość #2 gdy OK.]] ["url"] = function(frame)local link = frame.args[1]local okText = frame.args[2] or "ok"local isValid = string.find(link, '{{{') == 1 or checkUri(link)if isValid thenreturn okTextendreturn ""end,["lista nazw niepustych argumentów"] = function(frame)local argNames = {}for k, v in pairs(frame:getParent().args) doif #mw.text.trim(v) > 0 thentable.insert(argNames, tostring(k))endendreturn table.concat(argNames, ", ")end,["zapis daty dostępu"] = function(frame)local accessDate = frame:getParent().args["data dostępu"]if accessDate and (#accessDate > 0) thenif not isDate20YYMMDD(accessDate) thenlocal builder = mw.html.create('span'):addClass('problemy'):wikitext('zły zapis daty dostępu')if mw.title.getCurrentTitle().namespace == 0 thenbuilder:wikitext('[[Kategoria:Szablon cytowania – zły zapis daty dostępu]]')endreturn builderendendend,}