Module:Conservation status
Appearance
![]() | This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
![]() | This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
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