Modul:Autotaxobox: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
Perbarui sintaks LUA per versi terbaru dari modul yang bersangkutan. |
|||
Baris 8:
]]
local TaxonItalics = require('Module:TaxonItalics') -- use a function from Module:TaxonItalics to italicize a taxon name
local p = {}
Baris 82 ⟶ 83:
|ggparent_authority = taxonomic authority for TAXON's greatgreatgrandparent
|bold_first = 'bold' to bold TAXON in its row
|virus = 'yes' to apply virus taxa italicization standards
}}
=============================================================================]]
Baris 93 ⟶ 95:
local gggParentAuth = frame.args['gggparent_authority'] or ''
local boldFirst = frame.args['bold_first'] or 'link' -- values 'link' or 'bold'
local virus = frame.args['virus'] or 'no' -- values 'yes' or 'no'
local taxonTable = p.makeTable(frame, currTaxon)
local res = ''
-- display all taxa above possible greatgreatgrandparent
for i = taxonTable.n, 6, -1 do
res = res .. frame:expandTemplate{ title = 'Template:Taxobox/showtaxon', args = { taxonTable[i], fc = tostring(displayN >= i), virus = virus } }
end
-- display greatgreatgrandparent, if it exists
if taxonTable.n >= 5 then
res = res .. frame:expandTemplate{ title = 'Template:Taxobox/showtaxon', args = { taxonTable[5], authority = gggParentAuth, fc = tostring(displayN >= 5), virus = virus } }
end
-- display greatgrandparent, if it exists; force the display if an infrataxon is below
Baris 108 ⟶ 111:
frame.expandTemplate{ title = 'Template:Infrataxon()', args = { taxonTable[3] } } == 'true' or
frame.expandTemplate{ title = 'Template:Infrataxon()', args = { taxonTable[2] } } == 'true'
res = res .. frame:expandTemplate{ title = 'Template:Taxobox/showtaxon', args = { taxonTable[4], authority = ggParentAuth, fc = tostring(force), virus = virus } }
end
-- display grandparent, if it exists; force the display if an infrataxon is below
Baris 114 ⟶ 117:
local force = tostring(displayN >= 3) or
frame.expandTemplate{ title = 'Template:Infrataxon()', args = { taxonTable[2] } } == 'true'
res = res .. frame:expandTemplate{ title = 'Template:Taxobox/showtaxon', args = { taxonTable[3], authority = gParentAuth, fc = tostring(force), virus = virus } }
end
-- display parent, if it exists
if taxonTable.n >= 2 then
res = res .. frame:expandTemplate{ title = 'Template:Taxobox/showtaxon', args = { taxonTable[2], authority = parentAuth, fc = tostring(displayN >= 2), virus = virus } }
end
-- display target taxon
res = res .. frame:expandTemplate{ title = 'Template:Taxobox/showtaxon', args = { taxonTable[1], authority = auth, fc = 'true', format = boldFirst, virus = virus } }
return res
end
Baris 267 ⟶ 270:
end
end
if linkTarget == '' then linkTarget = linkText end
if italic == 'yes' then linkText = TaxonItalics.italicizeTaxonName(linkText, false) end
local link = ''
if bold == 'yes' then link = '<b>' .. linkText .. '</b>'
else
if linkTarget == linkText
else link = linkTarget .. '|' .. linkText
end
link = '[[' .. link .. ']]'
end
if (extinct == 'yes' or extinct == 'true') and not string.find(link, '†', 1, true) then
link = '<span style="font-style:normal;font-weight:normal;">†</span>' .. link
Baris 299 ⟶ 303:
end
return res .. '|}\n'
end
--[[============================== find =====================================
Returns the taxon above the specified taxon with a given rank.
Usage: {{#invoke:Autotaxobox|find|TAXON|RANK}}
=============================================================================]]
function p.find(frame)
local currTaxon = frame.args[1] or ''
if currTaxon == '' then return '<span class="error">no taxon supplied</span>' end
local rank = frame.args[2] or ''
if rank == '' then return '<span class="error">no rank supplied</span>' end
local inHierarchy = true -- still in the taxonomic hierarchy or off the top?
local searching = true -- still searching
while inHierarchy and searching do
local ok, parent = p.getTaxonInfoItem(frame, currTaxon, 'parent')
currTaxon = parent
local ok, currRank = p.getTaxonInfoItem(frame, currTaxon, 'rank')
if currRank == rank then
searching = false
end
else
inHierarchy = false
end
end
if inHierarchy and not searching then return currTaxon
else return '<span class="error">rank not found</span>'
end
end
Baris 404 ⟶ 437:
return p.getTaxonInfoLink(frame, taxon)
end
local ok, info
-- item ~= 'link'▼
-- item == 'dagger' is another special case
local ok, info = pcall(frame.expandTemplate, frame, { title = 'Template:Taxonomy/' .. taxon, args = {['machine code'] = item } })▼
if
ok, info = p.getTaxonInfoItem(frame, taxon, 'extinct')
▲ if info == '' then
if info == 'yes' or info == 'true' then
local sameAsTaxon = frame:expandTemplate{ title = 'Template:Taxonomy/' .. taxon, args = {['machine code'] = 'same as' } }▼
else
ok, info = pcall(frame.expandTemplate, frame, { title = 'Template:Taxonomy/' .. sameAsTaxon, args = {['machine code'] = item } })▼
info = ''
end
end
▲ -- item ~= 'link' or 'dagger'
else
▲
if ok then
if info == '' then
-- try 'same as'
▲ local sameAsTaxon = frame:expandTemplate{ title = 'Template:Taxonomy/' .. taxon, args = {['machine code'] = 'same as' } }
if sameAsTaxon ~= '' then
▲ ok, info = pcall(frame.expandTemplate, frame, { title = 'Template:Taxonomy/' .. sameAsTaxon, args = {['machine code'] = item } })
end
end
end
Baris 498 ⟶ 544:
['mirordo-mb'] = 1001,
nanophylum = 1494,
nanordo =
ordo = 1000,
parafamilia = 800,
parvclassis = 1396; -- same as subterclassis
parvordo = 996,
phylum = 1500,
Baris 518 ⟶ 565:
subsectio = 498,
subspecies = 298,
subterclassis = 1396; -- same as parvclassis
subtribus = 698,
superclassis = 1403,
|