Module:Conservation status
Appearance
| This module is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected. |
| This module is currently under extended confirmed protection. Extended confirmed protection prevents edits from all unregistered editors and registered users with fewer than 30 days tenure and 500 edits. The policy on community use specifies that extended confirmed protection can be applied to combat disruption, if semi-protection has proven to be ineffective. Extended confirmed protection may also be applied to enforce arbitration sanctions. Please discuss any changes on the talk page; you may submit an edit request to ask for uncontroversial changes supported by consensus. |
Module to generate conservation status information in taxoboxes. Plan is to replace {{Taxobox/species}}.
Usage
Entry point function "status", currently used in {{taxobox/species}} for some conservation systems:
{{#invoke:Conservation status|status|conservation status system|conservation status code|status reference}}
The entry point function "main" is planned to replace {{taxobox/species}}.
local p = {}
function p.main(frame)
local output = "ERROR"
local status = mw.text.trim(frame:getParent().args[2]) -- needs trim() for unnamed parameters
local system = mw.text.trim(frame:getParent().args[1])
system = string.upper(system)
status = string.upper(status)
if system == "IUCN3.1" or system == "IUCN" then
output = p.IUCN31(system, status)
end
if output ~= "ERROR" then
return '! colspan = 2 | <div style = "text-align:center;">[[Conservation status]]</div>' -- header
.. '\n|-'
.. '\n| colspan = 2 | <div style = "text-align:center;">' .. output .. '</div>'
end
end
function p.IUCN31(system, status)
-- | EN = [[file:Status iucn3.1 EN.svg|frameless|link=|alt=]]<br />[[Endangered species|Endangered]]
-- {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List endangered species]] | }}
local output = system .. ' ' .. status
if status == "EN" then
output = p.addImage("Status iucn3.1 EN.svg") .. "[[Endangered species|Endangered]]"
.. p.addCategory("IUCN Red List endangered species")
end
return output
end
function p.addImage(file)
if file ~= "" then
return "[[File:" .. file .. "|frameless|link=|alt=]]<br />"
end
return ""
end
function p.addCategory(category)
local ns = mw.title.getCurrentTitle().namespace
-- ns = 0 -- to test category put on page
if category ~= "" and ns == 0 then
return "[[Category:" .. category .. "]]"
end
return ""
end
return p