Module:PHLawAmend/list
Appearance
This module depends on the following other modules: |
local p = {}
local getArgs = require('Module:Arguments').getArgs
local abbrsModule = require('Module:PHLawAmend/abbrs')
local abbrs = abbrsModule.main
function p.list(frame)
local args = getArgs(frame)
--Check if theres a president abbr
local cat
if args[3] and string.find(args[3], "%(%a+%)") then
local presStart, presEnd = string.find(args[3], "%(%a+%)")
local pres = abbrsModule.presidents[string.sub(args[3], presStart+1, presEnd-1)][1]
cat = abbrs[args[1]][2]..pres..'/' .. args[2] .. '/' .. args[3]
elseif abbrs[args[1]] then
cat = abbrs[args[1]][2]..'/' .. args[2] .. '/' .. args[3]
elseif args[1] then
error('No abbreviation found for ' .. args[1])
else
error('Missing first argument')
end
local a = frame:callParserFunction("#ifexist", "Category:"..cat, frame:preprocess(
"<DynamicPageList>"..
"\ncategory="..cat..
"\nmode=none"..
"\nordermethod=sortkey"..
"\nnamespace=main"..
"</DynamicPageList>"
), '')
return a
end
function p.statusText( frame )
repeal = frame:callParserFunction("#ifexist", "Category:"..abbrs[frame.args[1]][2]..'/repeal/' .. frame.args[2], "true", "false")
amend = frame:callParserFunction("#ifexist", "Category:"..abbrs[frame.args[1]][2]..'/amend/' .. frame.args[2], "true", "false")
if (repeal == "true" and amend == "true") then return "Amended and repealed (whole or part)"
elseif (repeal == "true" and amend == "false") then return "Repealed (whole or part)"
elseif (repeal == "false" and amend == "true") then return "Amended"
else return "In force" end
end
function p.statusStyle( frame )
repeal = frame:callParserFunction("#ifexist", "Category:"..abbrs[frame.args[1]][2]..'/repeal/' .. frame.args[2], "true", "false")
amend = frame:callParserFunction("#ifexist", "Category:"..abbrs[frame.args[1]][2]..'/amend/' .. frame.args[2], "true", "false")
if (repeal == "true" and amend == "true") then return "background-color: #FFFFCC;"
elseif (repeal == "true" and amend == "false") then return "background-color: #ed9a9a;"
elseif (repeal == "false" and amend == "true") then return "background-color: #AAF0D1;"
else return "background-color: #8dd6a0;" end
end
return p