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)
local systemText = ""
if system == "IUCN3.1" or system == "IUCN" then
output = p.IUCN31(frame, system, status)
systemText = " [[IUCN Red List|IUCN 3.1]]"
elseif system == "IUCN2.3" then
output = p.IUCN23(frame, system, status)
systemText = " [[IUCN Red List|IUCN 2.3]]"
elseif system == "CNCFLORA" then
output = p.CNCFlora(frame, system, status)
systemText = " [[CNCFlora]]"
elseif system == "NATURESERVE" or system == "TNC" then
output = p.NatureServe(frame, system, status)
systemText = " [[NatureServe conservation status|NatureServe]]"
elseif system == "EPBC" then
output = p.EPBC(frame, system, status)
systemText = " [[Environment Protection and Biodiversity Conservation Act 1999|EPBC Act]]"
elseif system == "ESA" then
output = p.ESA(frame, system, status)
systemText = " [[Endangered Species Act|ESA]]"
elseif system == "COSEWIC" then
output = p.COSEWIC(frame, system, status)
systemText = " [[Committee on the Status of Endangered Wildlife in Canada|COSEWIC]]"
elseif system == "DECF" then
output = p.DECF(frame, system, status)
systemText = " [[Declared Rare and Priority Flora List|DEC]]"
elseif system == "QLDNCA" then
output = p.QLDNCA(frame, system, status)
systemText = " [[Nature Conservation Act 1992|NCA]]"
elseif system == "CITES" then
output = p.CITES(frame, system, status)
systemText = " [[CITES]]"
elseif system == "NZTCS" then
output = p.NZTCS(frame, system, status)
systemText = " [[New Zealand Threat Classification System|NZ TCS]]"
else
end
if output ~= "ERROR" then
local thirdParam = "" --mw.text.trim(frame:getParent().args[3] or "")
local statusText = frame:getParent().args['status_text']
--local systemText = " [[IUCN Red List|IUCN 3.1]]"
if statusText then
systemText = "[[{{{status_text|#Conservation status}}}|See text]]"
end
output = output .. "<small> (" .. systemText .. thirdParam .. ")</small></div>"
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
--***************************************** IUCN 3.1 **********************************
function p.IUCN31(frame, system, status)
-- | EX = [[file:Status iucn3.1 EX.svg|frameless|link=|alt=]]<br />[[Extinction|Extinct]] {{#if:{{{extinct|}}}| ({{{extinct}}}) }} {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List extinct species]] | }}
-- | EW = [[file:Status iucn3.1 EW.svg|frameless|link=|alt=]]<br />[[Extinct in the Wild]] {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List extinct in the wild species]] | }}
-- | CR = [[file:Status iucn3.1 CR.svg|frameless|link=|alt=]]<br />[[Critically endangered species|Critically Endangered]] {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List critically endangered species]] |}}
-- | EN = [[file:Status iucn3.1 EN.svg|frameless|link=|alt=]]<br />[[Endangered species|Endangered]] {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List endangered species]] | }}
-- | VU = [[file:Status iucn3.1 VU.svg|frameless|link=|alt=]]<br />[[Vulnerable species|Vulnerable]] {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List vulnerable species]] |}}
local output = system .. ' ' .. status
if status == "EX" then
local extinct = "[[Extinction|Extinct]]"
if frame:getParent().args['extinct'] then extinct = " (" .. frame:getParent().args['extinct'] .. ")" end
output = p.addImage("Status iucn3.1 EX.svg") .. extinct .. p.addCategory("IUCN Red List extinct species")
elseif status == "EW" then
output = p.addImage("Status iucn3.1 EW.svg") .. "[[Extinct in the Wild]]" .. p.addCategory("IUCN Red List extinct in the wild species")
elseif status == "CR" then
output = p.addImage("Status iucn3.1 CR.svg") .. "[[Critically endangered species|Critically Endangered]]" .. p.addCategory("IUCN Red List critically endangered species")
elseif status == "EN" then
output = p.addImage("Status iucn3.1 EN.svg") .. "[[Endangered species|Endangered]]" .. p.addCategory("IUCN Red List endangered species")
elseif status == "VU" then
output = p.addImage("Status iucn3.1 VU.svg") .. "[[Vulnerable species|Vulnerable]]" .. p.addCategory("IUCN Red List vulnerable species")
-- | NT = [[file:Status iucn3.1 NT.svg|frameless|link=|alt=]]<br />[[Near Threatened]] {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List near threatened species]] | }}
-- | LC = [[file:Status iucn3.1 LC.svg|frameless|link=|alt=]]<br />[[Least Concern]] {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List least concern species]] |}}
-- | DD = [[file:Status iucn3.1 blank.svg|frameless|link=|alt=]]<br/>[[Data Deficient]] {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List data deficient species]] |}}
-- | NE = ''Not evaluated''
-- | NR = ''Not recognized''
-- | PE = [[file:Status iucn3.1 CR.svg|frameless|link=|alt=]]<br />[[Critically endangered]], possibly extinct {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List critically endangered species]] |}}
-- | PEW = [[file:Status iucn3.1 CR.svg|frameless|link=|alt=]]<br />[[Critically endangered]], possibly extinct in the wild {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:IUCN Red List critically endangered species]]|}}
elseif status == "NT" then
output = p.addImage("Status iucn3.1 NT.svg") .. "[[Near Threatened]]" .. p.addCategory("IUCN Red List near threatened species")
elseif status == "LC" then
output = p.addImage("Status iucn3.1 LC.svg") .. "[[Least Concern]]" .. p.addCategory("IUCN Red List least concern species")
elseif status == "DD" then
output = p.addImage("Status iucn3.1 blank.svg") .. "[[Data Deficient]]" .. p.addCategory("IUCN Red List data deficient species")
elseif status == "NE" then
output = "''Not evaluated''"
elseif status == "NR" then
output = "''Not recognized''"
elseif status == "PE" then
output = p.addImage("Status iucn3.1 CR.svg") .. "[[Critically endangered]], possibly extinct" .. p.addCategory("IUCN Red List critically endangered species")
elseif status == "PEW" then
output = p.addImage("Status iucn3.1 CR.svg") .. "[[Critically endangered]], possibly extinct in the wild" .. p.addCategory("IUCN Red List critically endangered species")
else
-- | '''''Invalid status'''''{{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:Invalid conservation status]]|}}
output = "'''''Invalid status'''''" .. p.addCategory("Invalid conservation status")
end
-- | '''''Invalid status'''''{{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:Invalid conservation status]]|}}
--}}<small> ({{#if:{{{status_text|}}}|[[{{{status_text|#Conservation status}}}|See text]]|[[IUCN Red List|IUCN 3.1]]}}){{{3|}}}</small></div><!--
-- local thirdParam = "" --mw.text.trim(frame:getParent().args[3] or "")
-- local statusText = frame:getParent().args['status_text']
-- local systemText = " [[IUCN Red List|IUCN 3.1]]"
-- if statusText then
-- systemText = "[[{{{status_text|#Conservation status}}}|See text]]"
-- end
-- output = output .. "<small> (" .. systemText .. thirdParam .. ")</small></div>"
return output
end
-- ********************************* IUCN 2.3 **********************************************
function p.IUCN23(frame, system, status)
local output = system .. ' ' .. status
if status == "EX" then
local extinct = "[[Extinction|Extinct]]"
if frame:getParent().args['extinct'] then extinct = " (" .. frame:getParent().args['extinct'] .. ")" end
output = p.addImage("Status iucn2.3 EX.svg") .. extinct .. p.addCategory("IUCN Red List extinct species")
elseif status == "EW" then
output = p.addImage("Status iucn2.3 EW.svg") .. "[[Extinct in the Wild]]" .. p.addCategory("IUCN Red List extinct in the wild species")
elseif status == "CR" then
output = p.addImage("Status iucn2.3 CR.svg") .. "[[Critically endangered species|Critically Endangered]]" .. p.addCategory("IUCN Red List critically endangered species")
elseif status == "EN" then
output = p.addImage("Status iucn2.3 EN.svg") .. "[[Endangered species|Endangered]]" .. p.addCategory("IUCN Red List endangered species")
elseif status == "VU" then
output = p.addImage("Status iucn2.3 VU.svg") .. "[[Vulnerable species|Vulnerable]]" .. p.addCategory("IUCN Red List vulnerable species")
elseif status == "LR" then
output = p.addImage("Status iucn2.3 blank.svg") .. "Lower risk" .. p.addCategory("Invalid conservation status")
elseif status == "CD" or status == "LR/CD" then
output = p.addImage("Status iucn2.3 CD.svg") .. "[[Conservation Dependent]]" .. p.addCategory("IUCN Red List conservation dependent species")
elseif status == "NT" or status == "LR/NT" then
output = p.addImage("Status iucn2.3 NT.svg") .. "[[Near Threatened]]" .. p.addCategory("IUCN Red List near threatened species")
elseif status == "LC" or status == "LR/LC" then
output = p.addImage("Status iucn2.3 LC.svg") .. "[[Least Concern]]" .. p.addCategory("IUCN Red List least concern species")
elseif status == "DD" then
output = p.addImage("Status iucn2.3 blank.svg") .. "[[Data Deficient]]" .. p.addCategory("IUCN Red List data deficient species")
elseif status == "NE" then
output = "''Not evaluated''"
elseif status == "NR" then
output = "''Not recognized''"
elseif status == "PE" then
output = p.addImage("Status iucn2.3 CR.svg") .. "[[Critically endangered]], possibly extinct" .. p.addCategory("IUCN Red List critically endangered species")
elseif status == "PEW" then
output = p.addImage("Status iucn2.3 CR.svg") .. "[[Critically endangered]], possibly extinct in the wild" .. p.addCategory("IUCN Red List critically endangered species")
else -- | '''''Invalid status'''''{{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:Invalid conservation status]]|}}
output = "'''''Invalid status'''''" .. p.addCategory("Invalid conservation status")
end
return output
end
--******************************************* CNCFlora***************************************
function p.CNCFlora(frame, system, status)
local output = system .. ' ' .. status
if status == "EX" then
output = p.addImage("Status iucn3.1 EX.svg") .. "[[Extinction|Extinct]]" --.. p.addCategory("IUCN Red List extinct species")
elseif status == "EW" then
output = p.addImage("Status iucn3.1 EW.svg") .. "[[Extinct in the Wild]]" --.. p.addCategory("IUCN Red List extinct in the wild species")
elseif status == "CR" then
output = p.addImage("Status iucn3.1 CR.svg") .. "[[Critically endangered species|Critically Endangered]]" --.. p.addCategory("IUCN Red List critically endangered species")
elseif status == "EN" then
output = p.addImage("Status iucn3.1 EN.svg") .. "[[Endangered species|Endangered]]" --.. p.addCategory("IUCN Red List endangered species")
elseif status == "VU" then
output = p.addImage("Status iucn3.1 VU.svg") .. "[[Vulnerable species|Vulnerable]]" --.. p.addCategory("IUCN Red List vulnerable species")
elseif status == "NT" then
output = p.addImage("Status iucn3.1 NT.svg") .. "[[Near Threatened]]" --.. p.addCategory("IUCN Red List near threatened species")
elseif status == "LC" then
output = p.addImage("Status iucn3.1 LC.svg") .. "[[Least Concern]]" --.. p.addCategory("IUCN Red List least concern species")
elseif status == "DD" then
output = p.addImage("Status iucn3.1 blank.svg") .. "[[Data Deficient]]" --.. p.addCategory("IUCN Red List data deficient species")
elseif status == "NE" then
output = "''Not evaluated''"
elseif status == "NR" then
output = "''Not recognized''"
elseif status == "PE" then
output = p.addImage("Status iucn3.1 CR.svg") .. "[[Critically endangered]], possibly extinct" --.. p.addCategory("IUCN Red List critically endangered species")
elseif status == "PEW" then
output = p.addImage("Status iucn3.1 CR.svg") .. "[[Critically endangered]], possibly extinct in the wild" --.. p.addCategory("IUCN Red List critically endangered species")
else
output = "'''''Invalid status'''''" --.. p.addCategory("Invalid conservation status")
end
return output
end
-- *************** Natureserve/TNC ********************************
function p.NatureServe(frame, system, status)
local output = system .. ' ' .. status
if status == "GX" then
local extinct = "Presumed [[Extinction|Extinct]]"
if frame:getParent().args['extinct'] then extinct = " (" .. frame:getParent().args['extinct'] .. ")" end
output = p.addImage("Status TNC GX.svg") .. extinct .. p.addCategory("NatureServe presumed extinct species")
elseif status == "GH" then
output = p.addImage("Status TNC GH.svg") .. "Possibly [[Extinction|Extinct]]" .. p.addCategory("NatureServe possibly extinct species")
elseif status == "G1" then
output = p.addImage("Status TNC G1.svg") .. "Critically Imperiled" .. p.addCategory("NatureServe critically imperiled species")
elseif status == "G2" then
output = p.addImage("Status TNC G2.svg") .. "Imperiled" .. p.addCategory("NatureServe imperiled species")
elseif status == "G3" then
output = p.addImage("Status TNC G3.svg") .. "Vulnerable" .. p.addCategory("NatureServe vulnerable species")
elseif status == "G4" then
output = p.addImage("Status TNC G4.svg") .. "Apparently Secure" .. p.addCategory("NatureServe apparently secure species")
elseif status == "G5" then
output = p.addImage("Status TNC G5.svg") .. "Secure" .. p.addCategory("NatureServe secure species")
elseif status == "GU" then
output = p.addImage("Status TNC blank.svg") .. "Unrankable"
elseif status == "TX" then
local extinct = "Presumed [[Extinction|Extinct]]"
if frame:getParent().args['extinct'] then extinct = " (" .. frame:getParent().args['extinct'] .. ")" end
output = p.addImage("Status TNC TX.svg") .. extinct .. p.addCategory("NatureServe presumed extinct species")
elseif status == "TH" then
output = p.addImage("Status TNC TH.svg") .. "Possibly [[Extinction|Extinct]]" .. p.addCategory("NatureServe possibly extinct species")
elseif status == "T1" then
output = p.addImage("Status TNC T1.svg") .. "Critically Imperiled" .. p.addCategory("NatureServe critically imperiled species")
elseif status == "T2" then
output = p.addImage("Status TNC T2.svg") .. "Imperiled" .. p.addCategory("NatureServe imperiled species")
elseif status == "T3" then
output = p.addImage("Status TNC T3.svg") .. "Vulnerable" .. p.addCategory("NatureServe vulnerable species")
elseif status == "T4" then
output = p.addImage("Status TNC T4.svg") .. "Apparently Secure" .. p.addCategory("NatureServe apparently secure species")
elseif status == "T5" then
output = p.addImage("Status TNC T5.svg") .. "Secure" .. p.addCategory("NatureServe secure species")
elseif status == "TU" then
output = p.addImage("Status TNC blank.svg") .. "Unrankable"
else
output = "'''''Invalid status'''''" --.. p.addCategory("")
end
return output
end
--[=[ *************NatureServe
| GX = [[file:Status TNC GX.svg|frameless|link=|alt=]]<br />Presumed [[Extinction|Extinct]] {{#if:{{{extinct|}}}| ({{{extinct}}}) }} {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe presumed extinct species]]|}}
| GH = [[file:Status TNC GH.svg|frameless|link=|alt=]]<br />Possibly [[Extinction|Extinct]] {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe possibly extinct species]]|}}
| G1 = [[file:Status TNC G1.svg|frameless|link=|alt=]]<br />Critically Imperiled {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe critically imperiled species]] |}}
| G2 = [[file:Status TNC G2.svg|frameless|link=|alt=]]<br />Imperiled {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe imperiled species]] |}}
| G3 = [[file:Status TNC G3.svg|frameless|link=|alt=]]<br />Vulnerable {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe vulnerable species]] |}}
| G4 = [[file:Status TNC G4.svg|frameless|link=|alt=]]<br />Apparently Secure {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe apparently secure species]] |}}
| G5 = [[file:Status TNC G5.svg|frameless|link=|alt=]]<br />Secure {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe secure species]]|}}
| GU = [[file:Status TNC blank.svg|frameless|link=|alt=]]<br />Unrankable
| TX = [[file:Status TNC TX.svg|frameless|link=|alt=]]<br />Presumed [[Extinction|Extinct]] {{#if:{{{extinct|}}}| ({{{extinct}}}) }} {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe presumed extinct species]]|}}
| TH = [[file:Status TNC TH.svg|frameless|link=|alt=]]<br />Possibly [[Extinction|Extinct]] {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe possibly extinct species]]|}}
| T1 = [[file:Status TNC T1.svg|frameless|link=|alt=]]<br />Critically Imperiled {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe critically imperiled species]]|}}
| T2 = [[file:Status TNC T2.svg|frameless|link=|alt=]]<br />Imperiled {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe imperiled species]] |}}
| T3 = [[file:Status TNC T3.svg|frameless|link=|alt=]]<br />Vulnerable {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe vulnerable species]]|}}
| T4 = [[file:Status TNC T4.svg|frameless|link=|alt=]]<br />Apparently Secure {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe apparently secure species]]|}}
| T5 = [[file:Status TNC T5.svg|frameless|link=|alt=]]<br />Secure {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:NatureServe secure species]] |}}
| TU = [[file:Status TNC T blank.svg|frameless|link=|alt=]]<br />Unrankable
| '''''Invalid status''''' {{#ifeq: {{NAMESPACEE}} | {{ns: 0}} | [[Category:Invalid conservation status]]|}}
}}<small> ({{#if:{{{status_text|}}}|[[{{{status_text|#Conservation status}}}|See text]]|[[NatureServe conservation status|NatureServe]]}}){{{3|}}}</small></div><!--
--]=]
-- *************** EPBC ********************************
function p.EPBC(frame, system, status)
local output = system .. ' ' .. status
return output
end
-- *************** ESA ********************************
function p.ESA(frame, system, status)
local output = system .. ' ' .. status
return output
end
-- *************** COSEWIC ********************************
function p.COSEWIC(frame, system, status)
local output = system .. ' ' .. status
return output
end
-- *************** DECF ********************************
function p.DECF(frame, system, status)
local output = system .. ' ' .. status
return output
end
-- *************** QLDNCA ********************************
function p.QLDNCA(frame, system, status)
local output = system .. ' ' .. status
return output
end
-- *************** CITES ********************************
function p.CITES(frame, system, status)
local output = system .. ' ' .. status
return output
end
-- *************** NZTCS ********************************
function p.NZTCS(frame, system, status)
local output = system .. ' ' .. status
return output
end
-- *************** functions for image and category output ********
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