Jump to content

Module:Sandbox/Cabayi

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Cabayi (talk | contribs) at 11:29, 28 April 2016 (t). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

p.hansard = function(frame)
	-- get from wikidata
	local entity = mw.wikibase.getEntityObject()
	local rettxt = ""
	for i = 1, 3 do			-- at most 3 parliaments to date (2016)
		if entity['claims']["P463"][i]["mainsnak"]["datavalue"]["value"]["numeric-id"] == nil then
			break			-- no parliament found
		end
		local parlid = entity['claims']["P463"][i]["mainsnak"]["datavalue"]["value"]["numeric-id"] 
		-- |P463|1|mainsnak|datavalue|value|numeric-id
		if parlid == nil then
			break			-- no parliament found
		elseif parlid == 21084471 then
			-- 2005-10
			rettxt = rettxt .. "[1]"
		elseif parlid == 21084472 then
			-- 2010-15
			rettxt = rettxt .. "[2]"
		elseif parlid == 21084473 then
			-- 2015-20
			rettxt = rettxt .. "[3]"
		else
			-- meh
		end
	end
	return rettxt
end

return p