Jump to content
Wikipedia The Free Encyclopedia

Module:Conservation status

From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
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.
Page extended-confirmed-protected 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 }}.

The above documentation is transcluded from Module:Conservation status/doc. (edit | history)
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Subpages of this module.

 localp={}

 -- function main() - entry point for template
 functionp.main(frame)
 localsystem=mw.text.trim(frame:getParent().args[1])-- needs trim() for unnamed parameters
 localstatus=mw.text.trim(frame:getParent().args[2])
 localrefs=mw.text.trim(frame:getParent().args[3]or"")

 --TODO add handling of extinct parameter

 return'! colspan = 2 | <div style = "text-align:center;">[[Conservation status]]</div>'-- header row
 ..'\n|-'
 ..'\n| colspan = 2 | <div style = "text-align:center;">'
 ..p._main(frame,system,status,refs)-- status content 
 ..'</div>'


 end
 -- function status() - entry point for direct invoke testing (assumes table structure and adds cell content)
 functionp.status(frame)
 localsystem=mw.text.trim(frame.args[1])
 localstatus=mw.text.trim(frame.args[2])
 localrefs=mw.text.trim(frame.args[3]or"")
 --TODO if system and status then return
 returnp._main(frame,system,status,refs)
 end
 functionp._main(frame,system,status,refs)

 localoutput="ERROR"
 system=string.upper(system)
 status=string.upper(status)
 localsystemText=""

 --TODO check for system; if none give needs handling with long list of possible statuses to match current system

 ifsystem=="IUCN3.1"orsystem=="IUCN"then
 output=p.IUCN31(frame,system,status)
 systemText="[[IUCN Red List|IUCN 3.1]]"
 elseifsystem=="IUCN2.3"then
 output=p.IUCN23(frame,system,status)
 systemText="[[IUCN Red List|IUCN 2.3]]"
 elseifsystem=="CNCFLORA"then
 --output = p.CNCFlora(frame, system, status)
 output=p.UsesIUCN31(frame,system,status)-- uses IUCN3.1 system and criteria (need to block catgories)
 systemText="[[CNCFlora]]"
 elseifsystem=="TPWCA"then
 output=p.UsesIUCN31(frame,system,status)-- uses IUCN3.1 system and criteria (need to block catgories)
 systemText="[[NTFlora#TPWCA|TPWCA]]"
 elseifsystem=="SANBI"orsystem=="RLSAP"then
 output=p.SANBI(frame,system,status)
 systemText="[[Red List of South African Plants|SANBI Red List]]"
 elseifsystem=="NATURESERVE"orsystem=="TNC"then
 output=p.NatureServe(frame,system,status)
 systemText="[[NatureServe conservation status|NatureServe]]"
 elseifsystem=="EPBC"then
 output=p.EPBC(frame,system,status)
 systemText="[[Environment Protection and Biodiversity Conservation Act 1999|EPBC Act]]"
 elseifsystem=="ESA"then
 output=p.ESA(frame,system,status)
 systemText="[[Endangered Species Act|ESA]]"
 elseifsystem=="COSEWIC"then
 output=p.COSEWIC(frame,system,status)
 systemText="[[Committee on the Status of Endangered Wildlife in Canada|COSEWIC]]"
 elseifsystem=="DECF"then
 output=p.DECF(frame,system,status)
 systemText="[[Declared Rare and Priority Flora List|DEC]]"
 elseifsystem=="NSWBCA"then
 output=p.NSWBCA(frame,system,status)
 systemText="[[Biodiversity Conservation Act 2016 (NSW)|NSWBCA]]"
 elseifsystem=="QLDNCA"then
 output=p.QLDNCA(frame,system,status)
 systemText="[[Nature Conservation Act 1992|NCA]]"
 elseifsystem=="CITES"then
 output=p.CITES(frame,system,status,colour)
 systemText="[[CITES]]"
 elseifsystem=="NZTCS"then
 output=p.NZTCS(frame,system,status)
 systemText="[[New Zealand Threat Classification System|NZ TCS]]"
 else
 output=p.SystemNotRecognised(frame,system,status)
 systemText="[["..system.."]]"-- should this be linked?
 end
 ifoutput~="ERROR"then
 --[=[ template code
  	 <small>&nbsp;({{#if:{{{status_text|}}}
  	 |[[{{{status_text|#Conservation status}}}|See text]] -- links to section in article?
  	 |[[IUCN Red List|IUCN 3.1]]}}){{{3|}}}</small>
  ]=]
 localstatusText=frame:getParent().args['status_text']
 --local systemText = " [[IUCN Red List|IUCN 3.1]]"
 ifstatusTextthen
 ifstatusText==""thenstatusText="#Conservation status"end
 systemText="[["..statusText.."|See text]]"
 end
 output=output.."<small>&nbsp;("..systemText..")"..refs.."</small>"-- "</div>"

 returnoutput
 end
 end
 --[[ OTHER SYSTEMS
  Territory Parks and Wildlife Conservation Act 2000 (TPWCA)

 ]]

 functionp.SystemNotRecognised(frame,system,status)
 localoutput=system..' '..status
 ifstatus=="EX"then
 localextinct="[[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status iucn3.1 EX.svg")..extinct
 elseifstatus=="CR"then
 output="[[Critically endangered species|Critically Endangered]]"
 elseifstatus=="EN"then
 output="[[Endangered species|Endangered]]"
 elseifstatus=="NT"then
 output="[[Near Threatened]]"
 else
 output=status
 end
 returnoutput..p.addCategory("Taxoboxes with an unrecognised status system")
 end

 --***************************************** IUCN 3.1 **********************************
 functionp.IUCN31(frame,system,status)

 -- | EX = [[file:Status iucn3.1 EX.svg|frameless|link=|alt=]]<br />[[Extinction|Extinct]] {{#if:{{{extinct|}}}|&nbsp;({{{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]] |}}

 localoutput=system..' '..status
 ifstatus=="EX"then
 localextinct="[[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status iucn3.1 EX.svg")..extinct..p.addCategory("IUCN Red List extinct species")
 elseifstatus=="EW"then
 output=p.addImage("Status iucn3.1 EW.svg").."[[Extinct in the Wild]]"..p.addCategory("IUCN Red List extinct in the wild species")
 elseifstatus=="CR"then
 output=p.addImage("Status iucn3.1 CR.svg").."[[Critically endangered species|Critically Endangered]]"..p.addCategory("IUCN Red List critically endangered species")
 elseifstatus=="EN"then
 output=p.addImage("Status iucn3.1 EN.svg").."[[Endangered species (IUCN status)|Endangered]]"..p.addCategory("IUCN Red List endangered species")
 elseifstatus=="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|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]]|}}


 elseifstatus=="NT"then
 output=p.addImage("Status iucn3.1 NT.svg").."[[Near Threatened]]"..p.addCategory("IUCN Red List near threatened species")
 elseifstatus=="LC"then
 output=p.addImage("Status iucn3.1 LC.svg").."[[Least Concern]]"..p.addCategory("IUCN Red List least concern species")
 elseifstatus=="DD"then
 output=p.addImage("Status iucn3.1 blank.svg").."[[Data deficient|Data Deficient]]"..p.addCategory("IUCN Red List data deficient species")
 elseifstatus=="NE"then
 output="''Not evaluated''"
 elseifstatus=="NR"then
 output="''Not recognized''"
 elseifstatus=="PE"then
 output=p.addImage("Status iucn3.1 CR.svg").."[[Critically endangered]], possibly extinct"..p.addCategory("IUCN Red List critically endangered species")
 elseifstatus=="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>&nbsp;({{#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>&nbsp;(" .. systemText .. thirdParam .. ")</small></div>"
 returnoutput
 end

 -- ********************************* IUCN 2.3 **********************************************
 functionp.IUCN23(frame,system,status)

 localoutput=system..' '..status
 ifstatus=="EX"then
 localextinct="[[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status iucn2.3 EX.svg")..extinct..p.addCategory("IUCN Red List extinct species")
 elseifstatus=="EW"then
 output=p.addImage("Status iucn2.3 EW.svg").."[[Extinct in the Wild]]"..p.addCategory("IUCN Red List extinct in the wild species")
 elseifstatus=="CR"then
 output=p.addImage("Status iucn2.3 CR.svg").."[[Critically endangered species|Critically Endangered]]"..p.addCategory("IUCN Red List critically endangered species")
 elseifstatus=="EN"then
 output=p.addImage("Status iucn2.3 EN.svg").."[[Endangered species (IUCN status)|Endangered]]"..p.addCategory("IUCN Red List endangered species")
 elseifstatus=="VU"then
 output=p.addImage("Status iucn2.3 VU.svg").."[[Vulnerable species|Vulnerable]]"..p.addCategory("IUCN Red List vulnerable species")
 elseifstatus=="LR"then
 output=p.addImage("Status iucn2.3 blank.svg").."Lower risk"..p.addCategory("Invalid conservation status")
 elseifstatus=="CD"orstatus=="LR/CD"then
 output=p.addImage("Status iucn2.3 CD.svg").."[[Conservation Dependent]]"..p.addCategory("IUCN Red List conservation dependent species")
 elseifstatus=="NT"orstatus=="LR/NT"then
 output=p.addImage("Status iucn2.3 NT.svg").."[[Near Threatened]]"..p.addCategory("IUCN Red List near threatened species")
 elseifstatus=="LC"orstatus=="LR/LC"then
 output=p.addImage("Status iucn2.3 LC.svg").."[[Least Concern]]"..p.addCategory("IUCN Red List least concern species")
 elseifstatus=="DD"then
 output=p.addImage("Status iucn2.3 blank.svg").."[[Data deficient|Data Deficient]]"..p.addCategory("IUCN Red List data deficient species")
 elseifstatus=="NE"then
 output="''Not evaluated''"
 elseifstatus=="NR"then
 output="''Not recognized''"
 elseifstatus=="PE"then
 output=p.addImage("Status iucn2.3 CR.svg").."[[Critically endangered]], possibly extinct"..p.addCategory("IUCN Red List critically endangered species")
 elseifstatus=="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

 returnoutput
 end

 --******************************************* CNCFlora***************************************

 -- Note: this is not needed if using IUCN 3.1 system and criteria; just use that function with no catgories
 -- alternatively rename this function as p.UsesIUCN31()
 --function p.CNCFlora(frame, system, status)
 functionp.UsesIUCN31(frame,system,status)


 localoutput=system..' '..status
 ifstatus=="EX"then
 output=p.addImage("Status iucn3.1 EX.svg").."[[Extinction|Extinct]]"--.. p.addCategory("IUCN Red List extinct species")
 elseifstatus=="EW"then
 output=p.addImage("Status iucn3.1 EW.svg").."[[Extinct in the Wild]]"--.. p.addCategory("IUCN Red List extinct in the wild species")
 elseifstatus=="CR"then
 output=p.addImage("Status iucn3.1 CR.svg").."[[Critically endangered species|Critically Endangered]]"--.. p.addCategory("IUCN Red List critically endangered species")
 elseifstatus=="EN"then
 output=p.addImage("Status iucn3.1 EN.svg").."[[Endangered species|Endangered]]"--.. p.addCategory("IUCN Red List endangered species")
 elseifstatus=="VU"then
 output=p.addImage("Status iucn3.1 VU.svg").."[[Vulnerable species|Vulnerable]]"--.. p.addCategory("IUCN Red List vulnerable species")
 elseifstatus=="NT"then
 output=p.addImage("Status iucn3.1 NT.svg").."[[Near Threatened]]"--.. p.addCategory("IUCN Red List near threatened species")
 elseifstatus=="LC"then
 output=p.addImage("Status iucn3.1 LC.svg").."[[Least Concern]]"--.. p.addCategory("IUCN Red List least concern species")
 elseifstatus=="DD"then
 output=p.addImage("Status iucn3.1 blank.svg").."[[Data deficient|Data Deficient]]"--.. p.addCategory("IUCN Red List data deficient species")
 elseifstatus=="NE"then
 output="''Not evaluated''"
 elseifstatus=="NR"then
 output="''Not recognized''"
 elseifstatus=="PE"then
 output=p.addImage("Status iucn3.1 CR.svg").."[[Critically endangered]], possibly extinct"--.. p.addCategory("IUCN Red List critically endangered species")
 elseifstatus=="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

 returnoutput
 end
 -- *************** Natureserve/TNC ********************************
 functionp.NatureServe(frame,system,status)

 localoutput=system..' '..status
 ifstatus=="GX"then
 localextinct="Presumed [[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status TNC GX.svg")..extinct..p.addCategory("NatureServe presumed extinct species")
 elseifstatus=="GH"then
 output=p.addImage("Status TNC GH.svg").."Possibly [[Extinction|Extinct]]"..p.addCategory("NatureServe possibly extinct species")
 elseifstatus=="G1"then
 output=p.addImage("Status TNC G1.svg").."Critically Imperiled"..p.addCategory("NatureServe critically imperiled species")
 elseifstatus=="G2"then
 output=p.addImage("Status TNC G2.svg").."Imperiled"..p.addCategory("NatureServe imperiled species")
 elseifstatus=="G3"then
 output=p.addImage("Status TNC G3.svg").."Vulnerable"..p.addCategory("NatureServe vulnerable species")
 elseifstatus=="G4"then
 output=p.addImage("Status TNC G4.svg").."Apparently Secure"..p.addCategory("NatureServe apparently secure species")
 elseifstatus=="G5"then
 output=p.addImage("Status TNC G5.svg").."Secure"..p.addCategory("NatureServe secure species")
 elseifstatus=="GU"then
 output=p.addImage("Status TNC blank.svg").."Unrankable"
 elseifstatus=="GNR"then
 output=p.addImage("Status TNC blank.svg").."Unranked"
 elseifstatus=="TX"then
 localextinct="Presumed [[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status TNC TX.svg")..extinct..p.addCategory("NatureServe presumed extinct species")
 elseifstatus=="TH"then
 output=p.addImage("Status TNC TH.svg").."Possibly [[Extinction|Extinct]]"..p.addCategory("NatureServe possibly extinct species")
 elseifstatus=="T1"then
 output=p.addImage("Status TNC T1.svg").."Critically Imperiled"..p.addCategory("NatureServe critically imperiled species")
 elseifstatus=="T2"then
 output=p.addImage("Status TNC T2.svg").."Imperiled"..p.addCategory("NatureServe imperiled species")
 elseifstatus=="T3"then
 output=p.addImage("Status TNC T3.svg").."Vulnerable"..p.addCategory("NatureServe vulnerable species")
 elseifstatus=="T4"then
 output=p.addImage("Status TNC T4.svg").."Apparently Secure"..p.addCategory("NatureServe apparently secure species")
 elseifstatus=="T5"then
 output=p.addImage("Status TNC T5.svg").."Secure"..p.addCategory("NatureServe secure species")
 elseifstatus=="TU"then
 output=p.addImage("Status TNC blank.svg").."Unrankable"
 else
 output="'''''Invalid status'''''"..p.addCategory("Invalid conservation status")
 end
 returnoutput
 end

 -- ********* EPBC: Environment Protection and Biodiversity Conservation Act 1999 (Australia) ************
 functionp.SANBI(frame,system,status)

 localoutput=system..' '..status
 ifstatus=="EX"then
 localextinct="[[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status SANBI EX.svg")..extinct--.. p.addCategory("SANBI Red List extinct biota")
 elseifstatus=="EW"then
 output=p.addImage("Status SANBI EW.svg").."[[Extinct in the Wild]]"--.. p.addCategory("SANBI Red List extinct in the wild biota")
 elseifstatus=="RE"then
 output=p.addImage("Status SANBI RE.svg").."Regionally Extinct"--.. p.addCategory("SANBI Red List regionally extinct biota")
 elseifstatus=="CR"then
 output=p.addImage("Status SANBI CR.svg").."[[Critically endangered species|Critically endangered]]"--.. p.addCategory("SANBI Red List critically endangered biota")
 elseifstatus=="EN"then
 output=p.addImage("Status SANBI EN.svg").."[[Endangered species|Endangered]]"--.. p.addCategory("SANBI Red List endangered biota")
 elseifstatus=="VU"then
 output=p.addImage("Status SANBI VU.svg").."[[Vulnerable species|Vulnerable]]"--.. p.addCategory("SANBI Red List vulnerable biota")
 elseifstatus=="NT"then
 output=p.addImage("Status SANBI NT.svg").."[[Near Threatened]]"--.. p.addCategory("SANBI Red List near threatened biota")
 elseifstatus=="LC"then
 output=p.addImage("Status SANBI LC.svg").."[[Least Concern]]"--.. p.addCategory("SANBI Red List least concern biota")
 else
 output="'''''Invalid status'''''"..p.addCategory("Invalid conservation status")
 end

 returnoutput
 end
 functionp.EPBC(frame,system,status)

 localoutput=system..' '..status
 ifstatus=="EX"then
 localextinct="[[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status EPBC EX.svg")..extinct..p.addCategory("EPBC Act extinct biota")
 elseifstatus=="EW"then
 output=p.addImage("Status EPBC EW.svg").."[[Extinct in the Wild]]"..p.addCategory("EPBC Act extinct in the wild biota")
 elseifstatus=="CR"then
 output=p.addImage("Status EPBC CR.svg").."[[Critically endangered species|Critically endangered]]"..p.addCategory("EPBC Act critically endangered biota")
 elseifstatus=="EN"then
 output=p.addImage("Status EPBC EN.svg").."[[Endangered species|Endangered]]"..p.addCategory("EPBC Act endangered biota")
 elseifstatus=="VU"then
 output=p.addImage("Status EPBC VU.svg").."[[Vulnerable species|Vulnerable]]"..p.addCategory("EPBC Act vulnerable biota")
 elseifstatus=="CD"then
 output=p.addImage("Status EPBC CD.svg").."[[Conservation Dependent]]"..p.addCategory("EPBC Act conservation dependent biota")
 elseifstatus=="DL"orstatus=="DELISTED"then
 output=p.addImage("Status EPBC DL.svg").."Delisted"
 else
 output="'''''Invalid status'''''"..p.addCategory("Invalid conservation status")
 end

 returnoutput
 end

 -- *************** ESA ********************************
 functionp.ESA(frame,system,status)

 localoutput=system..' '..status
 ifstatus=="EX"then
 localextinct="[[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status ESA EX.svg")..extinct
 elseifstatus=="LE"orstatus=="E"then
 output=p.addImage("Status ESA LE.svg").."[[Endangered species|Endangered]]"..p.addCategory("ESA endangered species")
 elseifstatus=="LT"orstatus=="T"then
 output=p.addImage("Status ESA EX.svg").."[[Threatened species|Threatened]]"..p.addCategory("ESA threatened species")
 elseifstatus=="DL"orstatus=="DELISTED"then
 output=p.addImage("Status ESA DL.svg").."Delisted"
 else
 output="'''''Invalid status'''''"..p.addCategory("Invalid conservation status")
 end

 returnoutput
 end
 -- ********** COSEWIC: Committee on the Status of Endangered Wildlife in Canada **************
 functionp.COSEWIC(frame,system,status)

 localoutput=system..' '..status
 ifstatus=="X"then
 localextinct="[[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status COSEWIC X.svg")..extinct
 elseifstatus=="XT"then
 output=p.addImage("Status COSEWIC XT.svg").."Extirpated (Canada)"
 elseifstatus=="E"then
 output=p.addImage("Status COSEWIC E.svg").."[[Endangered species|Endangered]]"
 elseifstatus=="T"then
 output=p.addImage("Status COSEWIC T.svg").."[[Threatened species|Threatened]]"
 elseifstatus=="SC"then
 output=p.addImage("Status COSEWIC SC.svg").."Special Concern"
 elseifstatus=="DD"then
 output=p.addImage("Status_COSEWIC_blank.svg").."Data Deficient"
 elseifstatus=="NAR"then
 output=p.addImage("Status COSEWIC NAR.svg").."[[Least Concern|Not at risk]]"
 else
 output="'''''Invalid status'''''"..p.addCategory("Invalid conservation status")
 end
 returnoutput
 end
 -- *************** DECF ********************************
 functionp.DECF(frame,system,status)

 localoutput=system..' '..status
 ifstatus=="X"then
 localextinct="Declared Rare&nbsp;— Presumed [[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status DECF X.svg")..extinct
 elseifstatus=="R"then
 output=p.addImage("Status DECF R.svg").."Declared [[Rare species|rare]]"
 elseifstatus=="P1"then
 output=p.addImage("Status DECF P1.svg").."Priority One&nbsp;— Poorly Known Taxa"
 elseifstatus=="P2"then
 output=p.addImage("Status DECF P2.svg").."Priority Two&nbsp;— Poorly Known Taxa"
 elseifstatus=="P3"then
 output=p.addImage("Status DECF P3.svg").."Priority Three&nbsp;— Poorly Known Taxa"
 elseifstatus=="P4"then
 output=p.addImage("Status DECF P4.svg").."Priority Four&nbsp;— Rare Taxa"
 elseifstatus=="DL"orstatus=="DELISTED"then
 output=p.addImage("Status DECF DL.svg").."Delisted"
 else
 output="'''''Invalid status'''''"..p.addCategory("Invalid conservation status")
 end

 returnoutput
 end



 -- *************** QLDNCA (Queensland Nature Conservation Act ********************************
 -- https://www.data.qld.gov.au/dataset/conservation-status-of-queensland-wildlife/resource/d20c485d-b5dc-4c07-8304-df6a21783d4b 
 functionp.QLDNCA(frame,system,status)

 localoutput=system..' '..status
 ifstatus=="EX"then
 output="[[Extinct]]"..p.addCategory("Nature Conservation Act extinct biota")
 elseifstatus=="EW"orstatus=="PE"then-- PE is the code used but keep EW for compatibility
 output="[[Extinct in the Wild]]"..p.addCategory("Nature Conservation Act extinct in the wild biota")
 elseifstatus=="CR"then
 output="[[Critically endangered species|Critically Endangered]]"..p.addCategory("Nature Conservation Act critically endangered biota")
 elseifstatus=="EN"orstatus=="E"then
 output="[[Endangered species|Endangered]]"..p.addCategory("Nature Conservation Act endangered biota")
 elseifstatus=="VU"orstatus=="V"then
 output="[[Vulnerable species|Vulnerable]] "..p.addCategory("Nature Conservation Act vulnerable biota")
 elseifstatus=="R"then
 output="Rare"..p.addCategory("Nature Conservation Act rare biota")
 elseifstatus=="NT"then
 output="[[Near Threatened]]"..p.addCategory("Nature Conservation Act near threatened biota")
 elseifstatus=="SL"then
 output="[[Special Least Concern]]"..p.addCategory("Nature Conservation Act special least concern biota")
 elseifstatus=="LC"orstatus=="C"then
 output="[[Least Concern]]"..p.addCategory("Nature Conservation Act least concern biota")
 else
 output="'''''Invalid status'''''"..p.addCategory("Invalid conservation status")
 end

 returnoutput
 end
 -- *************** NSWBCA ********************************
 functionp.NSWBCA(frame,system,status)
 localoutput=system..' '..status
 ifstatus=="EX"then
 output="[[Extinct]]"
 elseifstatus=="EW"then
 output="[[Extinct in the Wild]]"
 elseifstatus=="CR"then
 output="[[Critically endangered species|Critically Endangered]]"
 elseifstatus=="EN"then
 output="[[Endangered species|Endangered]]"
 elseifstatus=="VU"then
 output="[[Vulnerable species|Vulnerable]] "
 -- elseif status == "R" then
 -- 	output = "Rare" 
 -- elseif status == "NT" then
 -- 	output = "[[Near Threatened]]" 
 elseifstatus=="LC"then
 output="[[Least Concern]]"
 else
 output="'''''Invalid status'''''"..p.addCategory("Invalid conservation status")
 end
 returnoutput
 end
 -- *************** CITES ********************************
 functionp.CITES(frame,system,status,colour)

 --colours: Animalia 	rgb(235,235,210)	Archaeplastida 	rgb(180,250,180)
 localcolour2=frame:getParent().args['colour']
 localcategoryPrefix="Taxa"
 --mw.addWarning (tostring(colour))
 ifcolour=='rgb(235,235,210)'thencategoryPrefix="Fauna"
 elseifcolour=='rgb(180,250,180)'thencategoryPrefix="Flora"
 elsemw.addWarning(tostring(colour))
 end

 localoutput=system..' '..status
 ifstatus=="CITES_A1"then
 output="[[CITES]] Appendix I"..p.addCategory(categoryPrefix.." listed on CITES Appendix I")
 elseifstatus=="CITES_A2"then
 output="[[CITES]] Appendix II"..p.addCategory(categoryPrefix.." listed on CITES Appendix II")
 elseifstatus=="CITES_A3"then
 output="[[CITES]] Appendix III"..p.addCategory(categoryPrefix.." listed on CITES Appendix III")
 else
 output="'''''Invalid status'''''"..p.addCategory("Invalid conservation status")
 end
 returnoutput

 end

 -- *************** NZTCS ********************************
 functionp.NZTCS(frame,system,status)

 localoutput=system..' '..status
 ifstatus=="EX"then
 localextinct="Declared Rare&nbsp;— Presumed [[Extinction|Extinct]]"
 ifframe:getParent().args['extinct']thenextinct="&nbsp;("..frame:getParent().args['extinct']..")"end
 output=p.addImage("Status NZTCS EX.svg")..extinct
 -- Threatened categories (NC,NE,NV)
 elseifstatus=="NC"then
 output=p.addImage("Status NZTCS NC.svg").."Nationally Critical"
 elseifstatus=="NE"then
 output=p.addImage("Status NZTCS NE.svg").."Nationally endangered"
 elseifstatus=="NV"then
 output=p.addImage("Status NZTCS NV.svg").."Nationally vulnerable"
 -- Chronically Threatened and At Risk categories (version 2002): SD,GD,SP,RR
 elseifstatus=="SD"then
 output=p.addImage("Status NZTCS SD.svg").."Serious Decline"
 elseifstatus=="GD"then
 output=p.addImage("Status NZTCS GD.svg").."Gradual Decline"
 elseifstatus=="SP"then
 output=p.addImage("Status NZTCS SP.svg").."Sparse"
 elseifstatus=="RR"then
 output=p.addImage("Status NZTCS RR.svg").."Range Restricted"
 -- At Risk categories (2008 version): 
 elseifstatus=="D"orstatus=="d"then
 output=p.addImage("Status NZTCS D.svg").."Declining"
 elseifstatus=="R"orstatus=="r"then
 output=p.addImage("Status NZTCS R.svg").."Recovering"
 elseifstatus=="REL"orstatus=="Rel"orstatus=="rel"then
 output=p.addImage("Status NZTCS REL.svg").."Relict"
 elseifstatus=="NU"orstatus=="nu"then
 output=p.addImage("Status NZTCS NU.svg").."Naturally Uncommon"
 -- otherwise invalid conservation status
 else
 output="'''''Invalid status'''''"..p.addCategory("Invalid conservation status")
 end

 returnoutput

 end


 -- *************** functions for image and category output ********
 functionp.addImage(file)
 iffile~=""then
 return"[[File:"..file.."|frameless|link=|alt=|class=skin-invert-image]]<br />"
 end
 return""
 end
 functionp.addCategory(category)
 localns=mw.title.getCurrentTitle().namespace
 -- ns = 0 -- to test category put on page
 ifcategory~=""andns==0then
 return"[[Category:"..category.."]]"
 end
 return""
 end


 returnp

AltStyle によって変換されたページ (->オリジナル) /