Jump to content

Module:Autovirusbox

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Peter coxhead (talk | contribs) at 18:06, 15 January 2019. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

require('Module:No globals')
local p = {} -- functions made public
local l = {} -- internal functions, kept separate

function l.paramChk(taxon, parent, species, strain, serotype, virus)
	local infraTaxon = ''
	local infraTaxonRank = ''
	if strain ~= '' then
		infraTaxon = strain
		infraTaxonRank = 'strain'
	elseif serotype ~= '' then
		infraTaxon = serotype
		infraTaxonRank = 'serotype'
	elseif virus ~= '' then
		infraTaxon = virus
		infraTaxonRank = 'virus'
	end
	local autoTaxon = ''
	local autoTaxonType = ''
	if taxon ~= '' then
		if parent..species..infraTaxon  ~= '' then
			autoTaxonType = 'ERROR'
		else
			autoTaxon = taxon
			autoTaxonType = 'TAXON'
		end
	else
		if parent ~= '' then
			if species ~= '' then
				autotaxon = parent
				autoTaxonType = 'PARENT'
			else
				if infraTaxon ~= '' then
					autoTaxon = parent
					autoTaxonType = 'PARENT'
				else
					autoTaxonType = 'ERROR'
				end
			end
		end
	end
	return autoTaxon, autoTaxonType, infraTaxon, infraTaxonRank
end

function p.main(frame)
	local taxon = frame.args['taxon'] or ''
	local parent = frame.args['parent'] or ''
	local species = frame.args['species'] or ''
	local strain = frame.args['strain'] or ''
	local serotype = frame.args['serotype'] or ''
	local virus = frame.args['virus'] or ''
	local autoTaxon, autoTaxonType, infraTaxon, infraTaxonRank = l.paramChk(taxon, parent, species, strain, serotype, virus)
	-- show species in italics; bold if nothing below
	if species ~= '' then
		if infraTaxon ~= '' then
			species = "''"..species.."''"
		else
			species = "'''''"..species.."'''''"
		end
	end
	local displayParents = frame.args['display_parents'] or ''
--[[
	local authority = frame.args['authority'] or ''
	local parentAuthority = frame.args['parent_authority'] or ''
	local gParentAuthority = frame.args['grandparent_authority'] or ''
	local ggParentAuthority = frame.args['greatgrandparent_authority'] or ''
	local gggParentAuthority = frame.args['greatgreatgrandparent_authority'] or ''
	local typeGenusAuthority = frame.args['type_genus_authority'] or ''
]]
	local subdivisionRanks = frame.args['subdivision_ranks'] or ''
--[[
| subdivision_ranks = {{{subdivision ranks|{{{subdivision_ranks|{{children_rank|{{Taxon info|{{{taxon}}}|rank}} }} }}} }}}
]]
	local name = 'TO BE DONE'
	if autoTaxonType == 'ERROR' then name = 'ERROR: wrong parameters' end
	-- now call Taxobox/core
	local res = frame:expandTemplate{ title = 'Template:Taxobox/core/sandbox', args =
		{ virus = 'yes',
		  colour = frame:expandTemplate{ title = 'Template:Taxobox colour', args = { 'virus' } },
		  name = 'TO BE DONE',
		  parent = autoTaxon,
--[[
		  authority = authority,
          parent_authority = parentAuthority,
		  grandparent_authority = gparentAuthority,
		  grandparent_authority = gparentAuthority,
		  greatgrandparent_authority = ggparentAuthority,
		  greatgreatgrandparent_authority = gggparentAuthority,
]]		  
		  image = frame.args['image'] or '',
		  image_upright = frame.args['image_upright'] or '',
		  image_alt = frame.args['image_alt'] or '',
		  image_caption = frame.args['image_caption'] or '',
		  image2 = frame.args['image2'] or '',
		  image2_upright = frame.args['image2_upright'] or '',
		  image2_alt = frame.args['image2_alt'] or '',
		  image2_caption = frame.args['image2_caption'] or '',
		  species = species,
		  virus_infrasp = infraTaxon,
		  virus_infrasp_rank =  infraTaxonRank,
		  display_taxa = displayParents,
		  type_genus = frame.args['type_genus'] or '',
		  --type_genus_authority = frame.args['type_genus_authority'] or '',
		  type_species = frame.args['type_species'] or '',
		  --type_species_authority = frame.args['type_species_authority'] or ''
		  subdivision_ranks = subdivisionRanks,
		  subdivision = frame.args['subdivision'] or '',
		  type_strain = frame.args['type_strain'] or '',
		  synonyms = frame.args['synonyms'] or '',
		  synonyms_ref = frame.args['synonyms_ref'] or '',
		  range_map = frame.args['range_map'] or '',
		  range_map_upright = frame.args['range_map_upright'] or '',
		  range_map_alt = frame.args['range_map_alt'] or '',
		  range_map_caption = frame.args['range_map_caption'] or '',
		} }
	return res
end

return p