Mòdul:Wikidata from infobox

De Viquipèdia
Salta a la navegació Salta a la cerca
local p = {}
local SA = require "Module:SimpleArgs"
local WD = require "Module:Wikidata"
local PT = require "Module:Plain text"

function p.CollapsibleText (S)
	local Collapsed = ''
	if mw.ustring.len (PT._main(S)) > 40 then
		Collapsed = '<div class="NavFrame collapsed" style="border:none; padding: 0;">'
	end	
	return
		Collapsed..
		'<div class="NavHead" style="width:100%; background:transparent" align="left">'..
		'</div>'..
		'<div class="NavContent" style="text-align:left;">'..S..'</div></div>'
end --CollapsibleText

function p.LoadArg0 (args, Args, N, Prop, Format, FirstRank)
	local val = SA.Str_Par (args, Args)
	if (val == nil) and (Prop ~= nil) then
		if type(Prop) == "table" then
			for _, i in ipairs(Prop) do
				if FirstRank == true then
					val = WD.claim ({property=i, value=val, formatting=Format, list='firstrank'})
				else
					val = WD.claim ({property=i, value=val, formatting=Format})
				end 
				if val ~= nil then
					break
				end	
			end	
		else	
			val = WD.claim ({property=Prop, value=val, formatting=Format})
		end	
	end	
	return val
end --LoadArg0	

function p.Write (tab, Label, N, val)
	if val ~= nil then
		tab['label'..N] = Label
		tab['data'..N] = val
	end
	return tab, val ~= nil
end --Write	

function p.LoadArg (args, tab, Args, Label, N, Prop, Format, FirstRank)
	val = p.LoadArg0 (args, Args, N, Prop, Format, FirstRank)
	return p.Write (tab, Label, N, val)
end --LoadArg	

return p