local p = -- local g = -- these are variables with global scope in this sub-moduleg.info =
--testing function to show automatic taxonomy within a table function p.showTaxonomyTable(frame) g.templateArgs = g.info.auto= false g.taxonTable = p.loadTaxonomyTable(frame) local output = '\n
- style="vertical-align:top;" ' --output = output .. '\n! Rank | Taxon \n | -' -- oldversion starting new row output = output .. '\n! Rank | Taxon' -- don't start a new row here g.htmlTable = mw.html.create('table') :addClass('infobox'):addClass('biota') :cssText("text-align: left; width: 200px; font-size: 100%") output = output .. p.taxoboxList(frame) output = output .. '\n |
---|
--function p.getTaxonomyTableRows(frame, htmlTable, templateArgs, info) g.htmlTable = htmlTable g.templateArgs = templateArgs g.info = info g.taxonTable = p.loadTaxonomyTable(frame) return p.taxoboxList(frame)end--testing function to output the heirarchy table from the automatic taxonomy as a wikitablefunction p.showTaxonomyHierarchyRaw(frame, taxonTable) local output = '
' .. k end for i=1, #taxonTable, 1 do output = output .. '\n | -' for k,v in pairs(taxonTable[i]) do output = output .. '\n | ' .. v end end output = output .. '\n |
---|
function p.loadTaxonomyTable(frame) local ok, taxonInfo local taxonTable= local i = 1 -- load authorities from template parameters local authorities = -- get the name of the first taxon local taxon = g.templateArgs['taxon'] or g.templateArgs['parent'] or "Felis" --taxon= 'Felis' --taxon= 'Worthenella' --taxon= 'Fereuungulata' --local authority = 'authority' -- the following section is an alternative method for adding rows for species, subspecies, etc -- if g.templateArgs['species_name'] then
if g.templateArgs['variety_name'] then taxonTable[i]= i=i+1 end if g.templateArgs['subspecies_name'] then taxonTable[i]= i=i+1 end -- TODO if subgenus
taxonTable[i]= i=i+1 taxon = g.templateArgs['parent'] end -- -- while i<100 do
ok, taxonTable[i] = g.getTaxonInfo(frame, taxon)
--if ok and taxonTable[i]['parent'] ~= "" then if ok then if taxonTable[i]['same_as'] and taxonTable[i]['same_as'] ~= "" then taxon = taxonTable[i]['same_as'] local ok, sameAsTable = g.getTaxonInfo(frame, taxon) if ok then for k,v in pairs(taxonTable[i]) do if v
"" then -- have we reached the top of the heirarchy? break else taxon = taxonTable[i]['parent'] -- set the taxon for the next loop end else break end i = i + 1 end --we have a complete table taxonTable.n = #taxonTable - 1 -- minus one as last one has parent=life and displays as Genus: Ursus
return taxonTableend
--function g.getTaxonInfo(frame, taxon) local ok, taxonInfo = pcall(frame.expandTemplate, frame,) if ok then local split= mw.text.split(taxonInfo, "$", true) -- all: returns "parent$rank$link_target$unnamed parameter$always_display$extinct$same_as$refs" local taxonRow = return ok, taxonRow endend
local res =
-- generic display to replace >6, 5,4,3,2,1 sections for i = taxonTable.n, 1, -1 do if i
end return resend--function g.isPrincipalRank(rank) -- Remove "ichno" and "oo" and then check for a major taxon ("oordo" becomes "rdo"): rank = string.gsub(rank, "ichno", "") rank = string.gsub(rank, "oo", "") if rank
"phylum" or rank
"classis" or rank
"rdo" or rank
"genus" or rank
"subspecies" or rank
"regnum" or rank
"divisio" or rank
"ordo" or rank
"familia" or rank
"species" or rank
"variety" then return false else return true -- rank is an infrarank endend--function g.showTaxonRow (frame, i, boldFirst, virus)
-- -- do we want to display the taxon? if g.taxonTable[i]['always_display']
"true" or g.isPrincipalRank(g.taxonTable[i]['rank']) then -- or major ranks -- continue else --if g.isInfraTaxon(g.taxonTable[i]['rank']) then -- or a major rank (=not a minor rank) return "" end
-- local bold = "no" if boldFirst
"species" or rank
"variety" then -- no processing of name necessary (already set to species_name, subspecies_name, etc) else taxonName = frame:expandTemplate end --rank local taxonRank = g.taxonTable[i]['rank'] taxonRank = frame:expandTemplate if g.taxonTable[i]['rank']
return p