--
require('strict')local p = local l = -- separate out local functions
--Trim leading and trailing spaces, always returning a string. function l.trim(str) str = mw.text.trim(str) if str
--Ensure double .. is present if the mode is cs1 and the auth(ority) ends with . Deals with "bug" in citation templates. function p.authchk(frame) local auth = frame.args[1] or "" local mode = frame.args[2] or "cs1" return l.authchk(auth, mode)end
function l.authchk(auth, mode) if mode
".." then -- no action elseif mw.ustring.sub(auth, -1)
"cs2" and mw.ustring.sub(auth, -2)
--Check arguments and generate a reference to the appropriate database given by "db". function l.refgen(db, frame) local taxon = frame.args[1] or "" if taxon
"" then return " ***ERROR: ID not supplied! " end id = mw.text.trim(id) local mode = frame.args[4] or "cs1" mode = mw.text.trim(mode) auth = l.authchk(auth, mode) if db
"IPNI" then return l.IPNI(taxon, auth, id, mode) elseif db
--Generate reference to the Global Compositae Database for a species. function p.GCDsp(frame) return l.refgen("GCDsp", frame)end
function l.GCDsp(taxon, auth, id, mode) --Example output: [1] local res = "[2] " return resend
--Generate reference to IPNI. function p.IPNI(frame) return l.refgen("IPNI", frame)end
function l.IPNI(taxon, auth, id, mode) --Example output: local res = "" return resend
--Generate reference to PoWO. function p.POWO(frame) return l.refgen("POWO", frame)end
function l.POWO(taxon, auth, id, mode) --Example output: [3] local res = "[4] " return resend
return p