Moduł:Brudnopis/pietrasagh/CEEtraining

Z Wikipedii, wolnej encyklopedii

Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Brudnopis/pietrasagh/CEEtraining/opis

local p = {}

function p.main(frame)
	res = {'{| class="wikitable"\n | President || Photograph|| Year from || Year to || Country\n'}
	--
	item_json = mw.wikibase.getEntity("Q8882")

	for k,v in ipairs(item_json.claims["P1308"])	do
		president_id =	v.mainsnak.datavalue.value.id
		pres_json = 	mw.wikibase.getEntity(president_id)
		name =			'[[' .. pres_json.labels.en.value .. ']]'
		photo = 		pres_json.claims["P18"][1].mainsnak.datavalue.value
		year_from = 	'{{#time: Y|' ..  v.qualifiers["P580"][1].datavalue.value.time .. '}}'
		year_to =		v.qualifiers["P582"] and '{{#time: Y|' ..  v.qualifiers["P582"][1].datavalue.value.time .. '}}' or "" 
		country =		'[[' .. mw.wikibase.getLabel(pres_json.claims["P27"][1].mainsnak.datavalue.value.id) .. ']]'
		table.insert(res, '|-\n| ' .. name .. '\n'..
			   			  '|| [[File: ' .. photo .. '|100px]]\n' ..
			   			  '|| ' .. year_from .. '\n' ..
			   			  '|| ' .. year_to .. '\n' ..
			   			  '|| ' .. country .. '\n'
			   			  )
	end
	
	--	
	table.insert(res, '|}')
	return frame:preprocess(table.concat(res))
end

return p