Modulo:mprotlind
MODULO | ||
Memtesto ne disponeblas. |
--[===[
MODULE "MPROTLIND" (protekto perlindungan)
"eo.wiktionary.org/wiki/Modulo:mprotlind" <!--2019-Jun-26-->
Purpose: peeks page protection status (only "true" or "false") with
possibility to override for documentation or testing purposes
Utilo: ellegas protektan statuson de pagxo (nur "true" aux "false") kun
eblo transpasi por dokumentaj aux testaj celoj
Used by templates / Uzata far sxablonoj:
- altauzoriskoprotekto
Required submodules / Bezonataj submoduloj:
- none / neniuj
Incoming: - nothing (seized from caller's frame instead)
Returned: - "0" or "1"
Parameters seized from the caller's frame:
- 1 named optional parameter
- "protpageoverridetestonly" (value "0" or "1" to override,
anything else is ignored)
Using "mw.title.getCurrentTitle().protectionLevels.edit[1]"
and "mw.title.getCurrentTitle().protectionLevels.move[1]".
]===]
local protlind = {}
------------------------------------------------------------------------
---- MAIN EXPORTED FUNCTION ----
------------------------------------------------------------------------
function protlind.ek (arxframent)
-- general unknown type
local vartmp = 0 -- variable without type
-- special type "args" AKA "arx"
local arxcaller = 0 -- metaized "args" from caller's "frame" (NOT our own)
-- general "str"
local strpar = "" -- incoming from named parameter
local strret = "" -- output string
---- SEIZE 1 OPTIONAL NAMED PARAMETER SUBMITTED TO CALLER ----
arxcaller = arxframent:getParent().args -- "args" from caller's "frame"
vartmp = arxcaller["protpageoverridetestonly"]
if (type(vartmp)=="string") then
strpar = vartmp -- do not care about possible errors -- can even be empty
end--if
---- CARRY OUT THE HARD WORK ----
if ((strpar=="0") or (strpar=="1")) then
strret = strpar
else
strret = "0"
vartmp = mw.title.getCurrentTitle().protectionLevels.edit[1]
if (type(vartmp)=="string") then
if (vartmp~="") then
strret = "1"
end--if
end--if
vartmp = mw.title.getCurrentTitle().protectionLevels.move[1]
if (type(vartmp)=="string") then
if (vartmp~="") then
strret = "1"
end--if
end--if
end--if
---- RETURN THE JUNK STRING ----
return strret
end--function
---- RETURN THE JUNK LUA TABLE ----
return protlind