Модуль:Wikidata/Biology
Материал из Томская энциклопедии
Для документации этого модуля может быть создана страница Модуль:Wikidata/Biology/doc
local p = {} local dictionary428 = mw.loadData('Модуль:Wikidata:Dictionary/P428') local dictionary835 = mw.loadData('Модуль:Wikidata:Dictionary/P835') --Property:P225 function p.formatTaxonNameClaim( context, options, statement ) local title = '<span style="font-style:italic; white-space: nowrap;">' .. context.formatSnak( options, statement.mainsnak ) .. '</span>' local result = ''; --taxon author if ( statement.qualifiers ) then if ( statement.qualifiers.P405 ) then local options405 = options:extends({ ["value-module"] = "Wikidata/Biology", ["value-function"] = "formatTaxonAuthorSnak", ["conjunction"] = " & ", }); local authors = {}; for _, qualifier in pairs( statement.qualifiers.P405 ) do table.insert(authors, context.formatSnak( options405, qualifier ) ); end result = result .. ' ' .. mw.text.listToText( authors, ", ", " & " ); end --Date of release if ( statement.qualifiers.P574 ) then result = result .. ', ' .. context.formatSnak( {}, statement.qualifiers.P574[0] ) end if ( string.len( result ) ~= 0 ) then result = '<span style="white-space: nowrap;">' .. result .. '</span>' end end result = title .. result .. context.formatRefs( options, statement ) return result end -- Qualifier P405 function p.formatTaxonAuthorSnak( context, options, value ) local author = "Q" .. value["numeric-id"]; local abbr = dictionary428[ author ] or dictionary835[ author ] local link = mw.wikibase.sitelink( author ) local label = mw.wikibase.label( author ) if ( abbr ) then return "[[" .. ( link or (":d:" .. author) ) .. "|" .. abbr[1] .. "]]"; else return "[[" .. ( link or (":d:" .. author) ) .. "|" .. ( label or author ) .. "]]"; end end return p