local p =
function p.main(frame) local args if frame:getParent.args[1 ] then args = frame:getParent.args else args = frame.args end local input = "" local divider = "|" local o = "
Short title | Citation | Royal assent | ||
---|---|---|---|---|
Long title | ||||
" local h = for i = 1, 2 do h[i ] = mw.ustring.char(i + 57343) end for i, _ in pairs(args) do input = args[i ] if mw.ustring.find(input, "") then input = mw.ustring.gsub(input, "%[%[(.*)|(.*)%]%]", "%[%[%1" .. h[ 1 ] .. "%2%]%]") input = mw.ustring.gsub(input, "style=", h[2 ]) local leg = local s = "" local c = 1 local par input = mw.ustring.sub(input, mw.ustring.find(input, "|") + 1) while input ~= "" do if mw.ustring.find(input, "|") then divider = "|" else divider = "}" end s = mw.ustring.sub(input, 1, mw.ustring.find(input, divider) - 1) if mw.ustring.find(s, "=") then par = mw.ustring.sub(s, 1, mw.ustring.find(s, "=") - 1) leg[par ] = mw.ustring.sub(s, mw.ustring.find(s, "=") + 1) else par = c leg[c ] = mw.ustring.sub(input, 1, mw.ustring.find(input, divider) - 1) c = c + 1 end leg[par ] = mw.ustring.gsub(leg[par ], "%[%[(.*)" .. h[ 1 ] .. "(.*)%]%]", "%[%[%1|%2%]%]") leg[par ] = mw.ustring.gsub(leg[par ], h[2 ], "style=") if divider "|" then input = mw.ustring.sub(input, mw.ustring.find(input, "|") + 1) else input = "" end end o = o .. p.act(leg) end end o = o .. " |
function p.act(args) local data = mw.loadData("Module:Legislationuk/data") local legShortTitle = args[1 ] or "" local link = args["link" ] or "" local legNote1 = args["note1" ] or "" local cyShortTitle = args["cyshort" ] or "" local legType = args[2 ] or "" local legNumber = args[3 ] or "" local legNote2 = args["note2" ] or "" local legDate = args[4 ] or "" local legNote3 = args["note3" ] or "" local maintained = args["maintained" ] or "" local archived = args["archived" ] or "" local repealed = args["repealed" ] or "" local legLongTitle = args[5 ] or "" local legNote4 = args["note4" ] or "" local cyLongTitle = args["cylong" ] or "" local url = args["url" ] or "" legDate = os.time local o = "
\'\'\'" end o = o .. legShortTitle .. "\'\'\'" .. legNote1 if repealed
" if maintained
"y" and archived ~= "n" then o = o .. "
"anaw" or legType
" if legDate < os.time then for _, t in ipairs(data) do if tonumber(legDate) >= tonumber(t.sDate.date) and tonumber(legDate) <= tonumber(t.eDate.date) then o = o .. t.citation end end else o = o .. os.date("%Y", legDate) end local lt = o = o .. " " .. lt[legType ] .. legNote2 .. "
" .. os.date("*t", legDate).day .. " " .. os.date("%B %Y", legDate) .. legNote3 .. "
" if legLongTitle ~= "" then o = o .. legLongTitle .. legNote4 else o = o .. " " end o = o .. "
" if cyLongTitle ~= "" then o = o .. "
" .. cyLongTitle .. "
" end local c = 1 local n = 0 local po = args["po1" ] while po do local poIsShortTitle = args["po" .. c .. "short" ] local poNote1 = args["po" .. c .. "note1" ] or "" local poYearOffset = args["po" .. c .. "year" ] or "" local poIsLongTitle = args["po" .. c .. "long" ] local poLongTitle if poIsLongTitle
" return oend
function p.po(args) local frame = mw.getCurrentFrame local o = "
\'\'\'" .. args[1 ] .. "\'\'\'" .. args[3 ] if args[6 ]
" .. args[4 ] .. args[5 ] else return o end else o = o .. " style=max-height:8.25em;overflow:auto>" .. args[1 ] .. args[3 ] return o endend
function p.ordinal(args) local ordinal, digit =, mw.ustring.sub(args, -1) if tonumber(digit) > 0 and tonumber(digit) <= 3 and mw.ustring.sub(args, -2) ~= 11 and mw.ustring.sub(args, -2) ~= 12 and mw.ustring.sub(args, -2) ~= 13 then return args .. ordinal[tonumber(digit) ] else return args .. "th" endend
function p.roman(args) local inputRoman = tonumber(args[1 ]) if inputRoman < 400 then inputRoman = tostring(inputRoman) return mw.ustring.lower(require("Module:Roman").main) elseif inputRoman
function p.header(frame) local data = mw.loadData("Module:Legislationuk/data") local pargs = frame:getParent.args local args = frame.args local inputType = pargs[1 ] or args[1 ] or "" local inputState = pargs["state" ] or args["state" ] or "" local inputNumber = tonumber(pargs[2 ]) or tonumber(args[2 ]) or "" local inputSession = pargs["session" ] or args["session" ] or "" local actsPublic = tonumber(pargs[3 ]) or tonumber(args[3 ]) or 0 local actsLocal = tonumber(pargs[4 ]) or tonumber(args[4 ]) or 0 local actsPrivate = tonumber(pargs[5 ]) or tonumber(args[5 ]) or 0 local currentSession = "" local o = "" if inputState
"wales" or inputState
"scotland" then o = o .. frame:preprocess("") elseif inputState
"northern ireland" then if inputNumber >= 2000 then o = o .. frame:preprocess("") end elseif inputType
"only" then o = o .. frame:preprocess("") else o = o .. frame:preprocess("") end o = o .. " " .. frame:expandTemplate .. " " .. frame:expandTemplate .. " " .. frame:expandTemplate .. " " if inputState
"" then o = o .. frame:expandTemplate else o = o .. frame:expandTemplate end o = o .. "\n\n" .. "This is a list of Acts of the Scottish Parliament " elseif inputState
2020 then o = o .. "Act of the National Assembly for Wales|Acts of the National Assembly for Wales]] and Acts of Senedd Cymru " elseif inputNumber <= 2020 and inputNumber >= 2012 then o = o .. "Act of the National Assembly for Wales|Acts of the National Assembly for Wales]] " else o = o .. "Measure of the National Assembly for Wales|Measures of the National Assembly for Wales]] " end elseif inputState
"parliament" and inputSession
"parliament" then o = o .. p.ordinal(inputSession) .. " session of the " .. p.ordinal(inputNumber) .. " " end o = o .. "Parliament of the United Kingdom" end if inputType
tonumber(t.session.parliament) and (tonumber(inputSession)
"only" and tonumber(t.session.number)
"current" then if inputSession
"only" then o = o .. "consisted of a single session that " end o = o .. "ran from " .. os.date("*t", t.sDate.date).day .. " " .. os.date("%B %Y", t.sDate.date) if t.sDate.citation.work ~= "LG" then o = o .. frame:extensionTag("ref", p.citation(t.sDate.citation) .. ".") else o = o .. frame:extensionTag("ref", p.citation(t.sDate.citation)) end o = o .. " until " .. os.date("*t", t.eDate.date).day .. " " .. os.date("%B %Y", t.eDate.date) .. "." if t.eDate.citation.work ~= "LG" then o = o .. frame:extensionTag("ref", p.citation(t.eDate.citation) .. ".") else o = o .. frame:extensionTag("ref", p.citation(t.eDate.citation)) end end end end end if inputState
"wales" then if inputNumber >= 2020 then o = o .. " Acts of Senedd Cymru are enacted by Senedd Cymru (the Welsh Parliament; or simply the Senedd), which has" elseif inputNumber >= 2012 then o = o .. " Acts of the National Assembly for Wales are Acts of Senedd Cymru enacted by Senedd Cymru (the Welsh Parliament; or simply the Senedd) under its former name of the National Assembly for Wales." .. frame:extensionTag("ref", ".") .. " It has" else o = o .. " Measures of the National Assembly for Wales were enacted by Senedd Cymru (the Welsh Parliament; or simply the Senedd) under its former name of the National Assembly for Wales," .. frame:extensionTag("ref", ".") .. " as part of its" end o = o .. " legislative authority over devolved matters in relation to Wales under the authority of the Government of Wales Act 2006." if inputNumber >= 2012 then o = o .. frame:extensionTag("ref", ".") if inputNumber
2011 then o = o .. "," else o = o .. "." end o = o .. frame:extensionTag("ref", "; .") if inputNumber
"northern ireland" then if inputNumber >= 2000 then o = o .. " Acts of the Northern Ireland Assembly are enacted by the Northern Ireland Assembly, which has legislative authority over devolved matters in relation to Northern Ireland under the authority of the Northern Ireland Act 1998." .. frame:extensionTag("ref", ".") end end if inputType
__TOC__
\n" if inputState
"wales" and inputNumber <= 2011 then o = o .. "Measures " else o = o .. "Acts " end if inputState
"wales" or (inputState
"year" and inputNumber >= 1963) or (inputType
"parliament" and tonumber(inputNumber)
"parliament" and tonumber(inputNumber)
4 then o = o .. " while the convention used for earlier Acts is to cite" else o = o .. " as opposed to the convention used for earlier Acts of citing" end o = o .. " the regnal year(s) in which the relevant " if inputType
"year" then o = o .. "parliamentary session" else o = o .. "parliamentary session" end o = o .. " was held," .. frame:extensionTag("ref", "; cf. and the .") .. " as opposed to the convention used for later Acts of citing the calendar year." .. frame:extensionTag("ref", ".") end end o = o .. " Each " if inputState
"year" and inputNumber >= 1963) or (inputType
"parliament" and tonumber(inputNumber)
5) then o = o .. "year" elseif inputType
42 and tonumber(inputSession)
"scotland" then o = o .. "numbered consecutively with Arabic numerals, following the prefix \"asp\"." .. frame:extensionTag("ref", "; formerly the .") elseif inputState
2020 then o = o .. "anaw\" or \"asc\" respectively" elseif inputNumber <= 2020 and inputNumber >= 2012 then o = o .. "anaw\"" else o = o .. "nawm\"" end o = o .. " (or, in Welsh, \"" if inputNumber >= 2021 then o = o .. "dsc" elseif inputNumber
"northern ireland" then o = o .. "given a chapter number (abbreviated \"c.\") denoted by Arabic numerals," .. frame:extensionTag("ref", "; .") .. " and citations are usually followed by the suffix \"(N.I.)\" so as to prevent confusion with Acts of Parliament of the United Kingdom." else o = o .. "given a chapter number (abbreviated \"c.\"), denoted by Arabic numerals in the case of public general acts, lowercase Roman numerals in the case of local acts, or italicised Arabic numerals in the case of personal acts. These run as separate series." .. frame:extensionTag("ref", ".") end o = o .. "\n\n" if inputState
2020 then o = o .. actsPublic .. " Acts of the National Assembly for Wales and " .. actsLocal .. " Acts of Senedd Cymru " else o = o .. actsPublic + actsLocal + actsPrivate if inputState
"scotland" then o = o .. " of the Scottish Parliament " elseif inputState
"northern ireland" then o = o .. " of the Northern Ireland Assembly " else o = o .. " of Parliament " end end if inputNumber
"y" then if acts
1 then o = o .. "was" else o = o .. "were" end end o = o .. " passed " if inputType
"only" then o = o .. "only" else o = o .. p.ordinal(inputSession) end o = o .. " session" end local actsPublicString = "" local actsLocalString = "" local actsPrivateString = "" if inputState
"wales" or (inputState
0 then o = o .. ": " .. actsPublicString .. " and " .. actsLocalString .. "." elseif actsPublic > 0 and actsLocal
0 and actsLocal > 0 and actsPrivate > 0 then o = o .. ": " .. actsLocalString .. " and " .. actsPrivateString .. "." elseif actsPublic > 0 and actsLocal
0 then if actsPublic
2 then o = o .. "; both " else o = o .. "; all " end if inputNumber
"y" then o = o .. "are" else o = o .. "were" end o = o .. " public general acts." end elseif actsPublic
0 then if actsLocal
2 then o = o .. "; both " else o = o .. "; all " end if inputNumber
"y" then o = o .. "are" else o = o .. "were" end o = o .. " local acts." end elseif actsPublic
0 and actsPrivate > 0 then if actsPrivate
2 then o = o .. "; both " else o = o .. "; all " end if inputNumber
"y" then o = o .. "are" else o = o .. "were" end o = o .. " personal acts." end end end o = o .. "\n\n indicates that a" if inputState
"wales" then o = o .. "" else o = o .. "" end o = o .. " indicates the location of the original " if inputState
"wales" then o = o .. "National Library of Wales." else o = o .. "Parliamentary Archives." end return oend
function p.citation(frame) local t = frame or "" local o = "" elseif t["work" ]
"before 1" then o = o .. "before p. 1|no-pp=yes" else o = o .. t.page end o = o .. "}}" elseif t["work" ]
"LG" then o = o .. "London Gazette|issue=" .. t.issue if t.supplement ~= "" then o = o .. "|supp=" .. t.supplement end o = o .. "|page" if mw.ustring.find(t.page, "–") then o = o .. "s" end o = o .. "=" .. t.page o = o .. "|date=" .. os.date("*t", t.date).day .. " " .. os.date("%B %Y", t.date) .. "}}" end return oend
return p