Modul:InfoboxPolitician

De la Wikipedia, enciclopedia liberă

Documentația acestui modul poate fi creată la Modul:InfoboxPolitician/doc

local p = {}

local infobox = require('Modul:InfoboxBiography')
local wikidata = require('Modul:Wikidata')
local infoboxImage = require('Modul:InfoboxImage').InfoboxImage
local bda = require('Modul:BirthDateAndAge')
local lc = require('Modul:LocationAndCountry')
local join = require('Modul:Separated entries')._main
local DateUtils = require('Modul:DateUtils')
local StringUtils = require('Modul:StringUtils')
local TableTools = require('Modul:TableTools')
local wdLinker = require('Modul:EditAtWikidata')
local getArgs = require('Modul:Arguments').getArgs

local _br_ = tostring(mw.html.create('br'))

local function extractDataAndNumberFromMultiParam(argName, paramNames)
	local actualParamName = nil
	local actualParamNumber
	local prevParamName = nil
	for paramIndex = 1, #paramNames do
		local nlStart, nlEnd = mw.ustring.find(argName, paramNames[paramIndex])
		if nlStart == 1 then
			actualParamName = mw.ustring.sub(argName, 1, nlEnd)
			local presumedIndex = mw.ustring.find(argName, "%d+$") or (1 + #(paramNames[paramIndex]))
			local indexStr = mw.text.trim(mw.ustring.sub(argName, presumedIndex, #argName) or "")
			local headingUnderscores = mw.ustring.match(indexStr, '^_+')
			if headingUnderscores then
				indexStr = mw.ustring.sub(indexStr, #headingUnderscores)
			end
			if indexStr == "" then
				actualParamNumber = 1
			elseif mw.ustring.match(indexStr, "^%d+$") then
				actualParamNumber = 1 + tonumber(indexStr)
			else
				actualParamName = prevParamName
			end
			prevParamName = actualParamName
		end
	end
	if not actualParamName then return nil, nil end
	return actualParamName, actualParamNumber
end

local function extractQualifierShortNames(claim, qualifierId)
	if claim == nil or claim.qualifiers == nil or qualifierId == nil or claim.qualifiers[qualifierId] == nil then return {} end
	local nameList = {}
	if claim.qualifiers and claim.qualifiers[qualifierId] then 
		for qualIdx,qualifier in ipairs(claim.qualifiers[qualifierId]) do
			local name = nil
			if qualifier.datatype == 'wikibase-item' and qualifier.datavalue and qualifier.datavalue.type == 'wikibase-entityid' then
				local QID = StringUtils.prependIfMissing({tostring(qualifier.datavalue.value['numeric-id']), 'Q'})
				name = wikidata.findOneValueNoRef('P1813', QID) -- short name
				local link = nil
				if name == nil then
					link = wikidata.printSnak(qualifier)
				else 
					-- link = '[[' .. (mw.wikibase.sitelink(QID) or (':d:' .. QID)) .. '|' .. name .. ']]'
					link = wikidata.findLinkToItemWithCallback(QID, false, nil, function() return name end)
				end
				link = link .. wikidata.outputReferences(qualifier)
				table.insert(nameList, link)
			end
		end
	end
	return nameList
end

local function computeArguments(origArgs)
	local processedArgs = {}
	local functii = {}
	local embedded = {}
	for argK, argV in pairs(origArgs) do
		if argV ~= nil and mw.ustring.len(mw.text.trim(argV)) > 0 then
			processedArgs[argK] = mw.text.trim(argV)
		end
	end

	local fem = wikidata.isFemale()

	for argK, argV in pairs(processedArgs) do
		local presumedFunctionParamName, presumedFunctionParamNumber = extractDataAndNumberFromMultiParam(argK, {"functia", "funcție", "office"})
		if presumedFunctionParamName and presumedFunctionParamNumber and type(presumedFunctionParamNumber) == 'number' then
			if not functii[presumedFunctionParamNumber] then functii[presumedFunctionParamNumber] = {} end
			functii[presumedFunctionParamNumber].denumire = argV
		end
		
		local presumedOrderParamName, presumedOrderParamNumber = extractDataAndNumberFromMultiParam(argK, {"ordine", "order"})
		if presumedOrderParamName and presumedOrderParamNumber and type(presumedOrderParamNumber) == 'number' then
			if not functii[presumedOrderParamNumber] then functii[presumedOrderParamNumber] = {} end
			functii[presumedOrderParamNumber].ordine = argV
		end

		local presumedNomParamName, presumedNomParamNumber = extractDataAndNumberFromMultiParam(argK, {"nominalizat", "candidat", "nominee", "candidate"})
		if presumedNomParamName and presumedNomParamNumber and type(presumedNomParamNumber) == 'number' then
			if not functii[presumedNomParamNumber] then functii[presumedNomParamNumber] = {} end
			functii[presumedNomParamNumber].nom = argV
		end

		local presumedStartParamName, presumedStartParamNumber = extractDataAndNumberFromMultiParam(argK, {"inceput", "început", "term_start"})
		if presumedStartParamName and presumedStartParamNumber and type(presumedStartParamNumber) == 'number' then
			if not functii[presumedStartParamNumber] then functii[presumedStartParamNumber] = {} end
			functii[presumedStartParamNumber].startTime = argV
		end

		local presumedEndParamName, presumedEndParamNumber = extractDataAndNumberFromMultiParam(argK, {"sfarsit", "sfârșit", "term_end"})
		if presumedEndParamName and presumedEndParamNumber and type(presumedEndParamNumber) == 'number' then
			if not functii[presumedEndParamNumber] then functii[presumedEndParamNumber] = {} end
			functii[presumedEndParamNumber].endTime = argV
		end

		local presumedVpParamName, presumedVpParamNumber = extractDataAndNumberFromMultiParam(argK, {"vice_presedinte", "vice_președinte", "vicepreședinte", "vicepresedinte", "vicepresident"})
		if presumedVpParamName and presumedVpParamNumber and type(presumedVpParamNumber) == 'number' then
			if not functii[presumedVpParamNumber] then functii[presumedVpParamNumber] = {} end
			functii[presumedVpParamNumber].vp = argV
		end

		local presumedVpmParamName, presumedVpmParamNumber = extractDataAndNumberFromMultiParam(argK, {"vice_prim_ministru", "viceprimeminister"})
		if presumedVpmParamName and presumedVpmParamNumber and type(presumedVpmParamNumber) == 'number' then
			if not functii[presumedVpmParamNumber] then functii[presumedVpmParamNumber] = {} end
			functii[presumedVpmParamNumber].vpm = argV
		end

		local presumedDptyParamName, presumedDptyParamNumber = extractDataAndNumberFromMultiParam(argK, {"deputy", "deputat", "loctiitor", "locțiitor"})
		if presumedDptyParamName and presumedDptyParamNumber and type(presumedDptyParamNumber) == 'number' then
			if not functii[presumedDptyParamNumber] then functii[presumedDptyParamNumber] = {} end
			functii[presumedDptyParamNumber].deputy = argV
		end

		local presumedPresParamName, presumedPresParamNumber = extractDataAndNumberFromMultiParam(argK, {"presedinte", "președinte", "president"})
		if presumedPresParamName and presumedPresParamNumber and type(presumedPresParamNumber) == 'number' then
			if not functii[presumedPresParamNumber] then functii[presumedPresParamNumber] = {} end
			functii[presumedPresParamNumber].president = argV
		end

		local presumedPmParamName, presumedPmParamNumber = extractDataAndNumberFromMultiParam(argK, {"primministru", "prim_ministru", "primeminister"})
		if presumedPmParamName and presumedPmParamNumber and type(presumedPmParamNumber) == 'number' then
			if not functii[presumedPmParamNumber] then functii[presumedPmParamNumber] = {} end
			functii[presumedPmParamNumber].pm = argV
		end

		local presumedMnrchParamName, presumedMnrchParamNumber = extractDataAndNumberFromMultiParam(argK, {"monarh", "monarch"})
		if presumedMnrchParamName and presumedMnrchParamNumber and type(presumedMnrchParamNumber) == 'number' then
			if not functii[presumedMnrchParamNumber] then functii[presumedMnrchParamNumber] = {} end
			functii[presumedMnrchParamNumber].monarch = argV
		end

		local presumedPredParamName, presumedPredParamNumber = extractDataAndNumberFromMultiParam(argK, {"predecesor", "predecessor"})
		if presumedPredParamName and presumedPredParamNumber and type(presumedPredParamNumber) == 'number' then
			if not functii[presumedPredParamNumber] then functii[presumedPredParamNumber] = {} end
			functii[presumedPredParamNumber].pred = argV
		end

		local presumedSuccParamName, presumedSuccParamNumber = extractDataAndNumberFromMultiParam(argK, {"succesor", "successor"})
		if presumedSuccParamName and presumedSuccParamNumber and type(presumedSuccParamNumber) == 'number' then
			if not functii[presumedSuccParamNumber] then functii[presumedSuccParamNumber] = {} end
			functii[presumedSuccParamNumber].succ = argV
		end

		local presumedCircParamName, presumedCircParamNumber = extractDataAndNumberFromMultiParam(argK, {"circumscriptia", "circumscripția"})
		if presumedCircParamName and presumedCircParamNumber and type(presumedCircParamNumber) == 'number' then
			if not functii[presumedCircParamNumber] then functii[presumedCircParamNumber] = {} end
			functii[presumedCircParamNumber].circumscription = argV
		end

		local presumedEmbeddedParamName, presumedEmbeddedParamNumber = extractDataAndNumberFromMultiParam(argK, {"embedded"})
		if presumedEmbeddedParamName and presumedEmbeddedParamNumber and type(presumedEmbeddedParamNumber) == 'number' then
			embedded[presumedEmbeddedParamNumber] = argV
		end
	end
	if table.maxn(functii) == 0 then
		local wikidataPositions = wikidata.findSortedClaimsForProperty(nil, 'P39')
		if wikidataPositions then
			for psnIdx = 1,#wikidataPositions do
				if mw.wikibase.entity.claimRanks['RANK_' .. mw.ustring.upper(wikidataPositions[psnIdx].rank)] > mw.wikibase.entity.claimRanks.RANK_DEPRECATED then
					local posn = {}
					local posnIdStr = StringUtils._prependIfMissing({tostring(wikidataPositions[psnIdx].mainsnak.datavalue.value['numeric-id']), 'Q'})

					local orderValues = wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P1545')
					local orderTexts = {}
					
					local posnTitleParts = {}
					if orderValues then
						for _,eachRawOrder in ipairs(orderValues) do
							if eachRawOrder and mw.text.trim(eachRawOrder) ~= '' then
								if eachRawOrder == '1' then table.insert(orderTexts, 'primul')
								else table.insert(orderTexts, 'al ' .. eachRawOrder .. '-lea')
								end
							end 
						end
						orderTexts.conjunction = ' și '
						orderTexts.separator = ', '
					end
					if #orderTexts > 0 then
						table.insert(posnTitleParts, StringUtils._capitalize({join(orderTexts)}))
					end
	
					local roPosnLabel = mw.wikibase.getLabelByLang(posnIdStr, 'ro')
					if roPosnLabel and #posnTitleParts == 0 then roPosnLabel = StringUtils._capitalize({roPosnLabel}) end
					if wikidataPositions[psnIdx].qualifiers and wikidataPositions[psnIdx].qualifiers['P642'] then
						table.insert(posnTitleParts, roPosnLabel or wikidata.findNativeOrEnglishLabel(posnIdStr, #posnTitleParts == 0))
						table.insert(posnTitleParts, 'în')
						table.insert(posnTitleParts, table.concat(wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P642'), ', '))
					else
						table.insert(posnTitleParts,
							(mw.wikibase.sitelink(posnIdStr) or wikidata.loadOneValueInChain({posnIdStr, 'P2354'}))
								and wikidata.findLinkToItem(posnIdStr, #orderTexts == 0, fem, false)
							or roPosnLabel or wikidata.findNativeOrEnglishLabel(posnIdStr, #orderTexts == 0))
					end
					table.insert(posnTitleParts, wdLinker.displayMessage('P39'))
					posn.denumire = table.concat(posnTitleParts, ' ')
					local possibleStartTime = table.concat(wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P580'), ', ')
					if possibleStartTime and mw.text.trim(possibleStartTime) ~= '' then
						posn.startTime = possibleStartTime
					end
					local possibleEndTime = table.concat(wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P582'), ', ')
					if possibleEndTime and mw.text.trim(possibleEndTime) ~= '' then
						posn.endTime = possibleEndTime
					end
					posn.refs = wikidata.outputReferences(wikidataPositions[psnIdx])
					local possibleLegislature = table.concat(wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P2937'), ', ')
					if possibleLegislature and mw.text.trim(possibleLegislature) ~= '' then
						posn.legislature = possibleLegislature
					end
					posn.pred = table.concat(wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P155'), ', ')
					if posn.pred == nil or mw.text.trim(posn.pred) == '' then posn.pred = table.concat(wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P1365'), tostring(mw.html.create('br'))) end
					posn.succ = table.concat(wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P156'), ', ')
					if posn.succ == nil or mw.text.trim(posn.succ) == '' then posn.succ = table.concat(wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P1366'), tostring(mw.html.create('br'))) end
					posn.circumscription = table.concat(extractQualifierShortNames(wikidataPositions[psnIdx], 'P768'), tostring(mw.html.create('br')))
					if posn.headofstate == nil or mw.text.trim(posn.headofstate) == '' then posn.headofstate = table.concat(wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P35'), tostring(mw.html.create('br'))) end
					if posn.cabinet == nil or mw.text.trim(posn.cabinet) == '' then
						posn.cabinet = table.concat(wikidata.findQualifierValueListForClaim(wikidataPositions[psnIdx], 'P5054'), tostring(mw.html.create('br')))
					end
					table.insert(functii, posn)
				end
			end
		end
	end
	local childMode = (processedArgs['embed'] == 'yes' or processedArgs['embed'] == 'da')
	local mainMode = not childMode
	local computedArgs = {}
	computedArgs.aboveclass = origArgs['aboveclass'] or 'biografii'
	computedArgs['culoare cadru'] = origArgs['culoare cadru'] or 'E6E6FA'
	computedArgs['culoare text'] = origArgs['culoare text'] or '000'
	computedArgs['headerstyle'] = 'border-top-style: solid; border-color:#aaa; border-top-width: 1px; padding-top: 3px; padding-bottom: 3px'
	computedArgs['subheader1'] = origArgs['subheader']
	
	computedArgs.embed = childMode and 'yes' or 'no'
	computedArgs.doc = origArgs['doc'] or 'Infocaseta Om politic'
	computedArgs.wikidata = 'y'
	computedArgs['name'] = processedArgs['nume'] or processedArgs['name'] or (mainMode and (StringUtils._emptyToNil({wikidata.findLabel()}) or mw.title.getCurrentTitle().text))
	computedArgs.default_title = 'Cariera politică'
	computedArgs.parent_colspan = processedArgs['parent_colspan'] or '2'
	
	local imageTitle = processedArgs['imagine'] or processedArgs['image']
	local imageCaption = processedArgs['caption'] or processedArgs['descriere'] or processedArgs['comentariu'] or processedArgs['Descriere']
	local imageSize = processedArgs['dimensiune_imagine'] or processedArgs['imagesize'] or processedArgs['image_size'] or processedArgs['mărime']
	local smallImageTitle = processedArgs['imagine_mică'] or processedArgs['smallimage']
	local wdImageName, wdImageCaption
	if imageTitle == nil then
		wdImageTitle, wdImageCaption = wikidata.findImageAndCaption()
		imageTitle = wdImageName
		imageCaption = wdImageCaption
	end

	if imageTitle and imageTitle ~= '' then	computedArgs.image = infoboxImage{image=imageTitle, size = imageSize, sizedefault = frameless, suppressplaceholder='yes'}
	elseif smallImageTitle then computedArgs.image = '[[Fișier:' .. smallImageTitle .. ']]' end
	computedArgs.caption = imageCaption
	
	local crtLineIndex = 1
	
	if origArgs['extra_header'] then
		local extraDataIdxes = TableTools.affixNums(origArgs, 'extra_data')
		if #extraDataIdxes > 0 then
			computedArgs['header' .. tostring(crtLineIndex)] = origArgs['extra_header']
			crtLineIndex = crtLineIndex + 1
			for _,eachExtraDataIdx in ipairs(extraDataIdxes) do
				computedArgs['data' .. tostring(crtLineIndex)] = origArgs['extra_data' .. tostring(eachExtraDataIdx)]
				computedArgs['label' .. tostring(crtLineIndex)] = origArgs['extra_label' .. tostring(eachExtraDataIdx)]
				crtLineIndex = crtLineIndex + 1
			end
		end
	end
	
	local prevPosition = nil
	for functionIdx = 1,table.maxn(functii) do
		if functii[functionIdx] then
			if functii[functionIdx].denumire or functii[functionIdx].ordine then
				if prevPosition == nil or prevPosition.denumire == nil or prevPosition.denumire ~= functii[functionIdx].denumire then
					computedArgs['header' .. tostring(crtLineIndex)] = (functii[functionIdx].ordine or '') .. ' ' .. (functii[functionIdx].denumire or '')
					crtLineIndex = crtLineIndex + 1
				end
			end
			if functii[functionIdx].nom then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Candidat'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].nom
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].startTime and functii[functionIdx].endTime then
				computedArgs['data' .. tostring(crtLineIndex)] = "'''În funcție'''<br/>" .. functii[functionIdx].startTime .. '&nbsp;&ndash;&nbsp;' .. functii[functionIdx].endTime .. (functii[functionIdx].refs or '')
				crtLineIndex = crtLineIndex + 1
			elseif functii[functionIdx].startTime then
				local startDate = DateUtils.parseDate(mw.ustring.gsub(mw.ustring.gsub(functii[functionIdx].startTime, "%[%[", ""), "%]%]", ""))
				if StringUtils._startsWith({functii[functionIdx].startTime, '<time datetime="'}) then
					startDate = DateUtils.parseDate(
									StringUtils.substringBefore({
										StringUtils.substringAfter(
											{functii[functionIdx].startTime, '<time datetime="'}),
										'"'}))
				end
				if startDate and DateUtils.compare(os.date('*t'), startDate) < 0 then
					computedArgs['data' .. tostring(crtLineIndex)] = 'Va&nbsp;prelua&nbsp;funcția'
				else
					computedArgs['data' .. tostring(crtLineIndex)] = 'Deținător&nbsp;actual'
				end
				computedArgs['style' .. tostring(crtLineIndex)] = 'background-color: #eeeeff;'
				crtLineIndex = crtLineIndex + 1
				computedArgs['data' .. tostring(crtLineIndex)] = "'''Funcție&nbsp;asumată'''<br/>" .. functii[functionIdx].startTime .. (functii[functionIdx].refs or '')
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].vp then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Vicepreședinte'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].vp
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].vpm then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Viceprim-ministru'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].vpm
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].deputy then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Locțiitor'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].deputy
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].president then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Președinte'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].president
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].pm then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Prim-ministru'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].pm
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].monarch then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Monarh'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].monarch
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].headofstate then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Șef al statului'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].headofstate
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].cabinet then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Guvern'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].cabinet
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].pred then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Precedat&nbsp;de'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].pred
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].succ then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Succedat&nbsp;de'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].succ
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].circumscription then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Circumscripția'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].circumscription
				crtLineIndex = crtLineIndex + 1
			end
			if functii[functionIdx].legislature then
				computedArgs['label' .. tostring(crtLineIndex)] = 'Legislatură'
				computedArgs['data' .. tostring(crtLineIndex)] = functii[functionIdx].legislature
				crtLineIndex = crtLineIndex + 1
			end
			prevPosition = functii[functionIdx]
		end
	end
	if table.maxn(functii) > 0 then
		computedArgs['data' .. tostring(crtLineIndex)] = tostring(mw.html.create('hr'))
		crtLineIndex = crtLineIndex + 1
	end
	
	local wikidataGender = wikidata.findOneValueNoRef('P21')
	local gender = nil
	if wikidataGender then
		if mw.ustring.find(wikidataGender, 'femeie') then gender = 'f'
		else gender = 'm' end
	end
	computedArgs['birth_date'] = processedArgs['data_nasterii'] or processedArgs['data_nașterii'] or processedArgs['birth_date']
	computedArgs['birth_name'] = processedArgs['nume_la_naștere'] or processedArgs['birth_name'] or processedArgs['birthname']
	computedArgs['death_date'] = processedArgs['data_decesului'] or processedArgs['death_date']
	computedArgs['birth_place'] = processedArgs['locul_nasterii'] or processedArgs['locul_nașterii'] or processedArgs['birth_place']
	computedArgs['death_place'] = processedArgs['locul_decesului'] or processedArgs['death_place']

	local awards = processedArgs['premii'] or processedArgs['awards']
	if awards == nil then
		if processedArgs['ordine și medalii românești'] and processedArgs['ordine și medalii străine'] then
			awards = table.concat({processedArgs['ordine și medalii românești'], processedArgs['ordine și medalii străine']}, tostring(mw.html.create('br')))
		else if processedArgs['ordine și medalii românești'] then 
				awards = processedArgs['ordine și medalii românești']
			else if processedArgs['ordine și medalii străine'] then awards = processedArgs['ordine și medalii străine'] end
			end
		end
	end
	if mainMode and awards == nil then
		local wikidataAwards = wikidata.findClaimsForProperty(nil, 'P166')
		if wikidataAwards and #wikidataAwards > 0 then
			local awardsList = {}
			for _idx,eachClaim in ipairs(wikidataAwards) do
				if _idx < 10 and eachClaim.mainsnak.snaktype == 'value' then
					local award = wikidata.printSnak(eachClaim.mainsnak) .. wikidata.outputReferences(eachClaim.mainsnak)
					local fromList = {}
					if eachClaim.qualifiers then
						for _,eachQualProp in ipairs({'P1027', 'P642'}) do
							if eachClaim.qualifiers[eachQualProp] then
								for _,eachQual in ipairs(eachClaim.qualifiers[eachQualProp]) do
									table.insert(fromList, wikidata.printSnak(eachQual))
								end
							end
						end
						if #fromList > 0 then
							award = award .. ' de la ' .. table.concat(fromList, ', ')
						end
					end
					local awardTimestamp = wikidata.printTimestampForClaim(eachClaim)
					if awardTimestamp and mw.ustring.len(mw.text.trim(awardTimestamp)) > 2 then
						award = award .. awardTimestamp
					end
					table.insert(awardsList, award)
				end
			end
			local lineBr = tostring(mw.html.create('br'))
			awards = table.concat(awardsList, lineBr)
			if #wikidataAwards > 10 then
				awards = awards .. lineBr .. wdLinker.displayMessageWithCustomText('P166', nil, tostring(mw.html.create('small'):wikitext('...mai multe...')))
			end
		end
	end
	if awards then
		computedArgs['label' .. tostring(crtLineIndex)] = 'Premii'
		computedArgs['data' .. tostring(crtLineIndex)] = awards
		crtLineIndex = crtLineIndex + 1
	end
	
	local parties = processedArgs['partid'] or processedArgs['party']
	if parties == nil then
		local wikidataParties = wikidata.findSortedClaimsForProperty(nil, 'P102')
		if wikidataParties and #wikidataParties > 0 then
			local partiesList = {}
			for partyIdx=1,#wikidataParties do
				local crtEntry = ''
				if wikidataParties[partyIdx].mainsnak.snaktype == 'value' then
					crtEntry = wikidata.findLinkToItemWithCallback(wikidataParties[partyIdx].mainsnak.datavalue.value['numeric-id'], true, function(entityObject)
						local entityObjectQId = entityObject and StringUtils._prependIfMissing({tostring(entityObject.id), 'Q'})
						local returnValueCandidate = nil
						if entityObject and entityObject.claims and entityObject.claims['P1813'] and #(entityObject.claims['P1813']) > 0 then
							local inPartyEndDate = nil
							if wikidataParties[partyIdx].qualifiers and wikidataParties[partyIdx].qualifiers['P582'] and wikidataParties[partyIdx].qualifiers['P582'][1] then
								inPartyEndDate = DateUtils.extractDateFromWikidataSnak(wikidataParties[partyIdx].qualifiers['P582'][1])
							end

							local returnValueRank = mw.wikibase.entity.claimRanks.RANK_DEPRECATED --initial rank is lowest, so that practically anything is accepted here
							local returnValueEndDate = inPartyEndDate and {year = 1, month = 1, day = 1} or os.date('*t')
							for _,eachPartyShortNameClaim in ipairs(entityObject.claims['P1813']) do
								if eachPartyShortNameClaim.type == 'statement' and eachPartyShortNameClaim.mainsnak.snaktype == 'value' and eachPartyShortNameClaim.mainsnak.datavalue.value.language == 'ro' then

									local namingEndDate = {} -- empty date
									if eachPartyShortNameClaim.qualifiers and eachPartyShortNameClaim.qualifiers['P582'] and #(eachPartyShortNameClaim.qualifiers['P582']) > 0 then
										namingEndDate = DateUtils.extractDateFromWikidataSnak(eachPartyShortNameClaim.qualifiers['P582'][1])
									end
									if inPartyEndDate == nil then 
										--in this case, we don't have a time reference to get the party name, so we get the best we've got: the most recent among those with the highest rank
										local candidateRank = mw.wikibase.entity.claimRanks['RANK_' .. mw.ustring.upper(eachPartyShortNameClaim.rank)]
										if candidateRank > returnValueRank then
											--we found a candidate with a better rank
											returnValueCandidate = eachPartyShortNameClaim.mainsnak.datavalue.value.text
											returnValueEndDate = namingEndDate
											returnValueRank = candidateRank
										elseif candidateRank == returnValueRank then
											--same rank, we now care about which is more recent
											if returnValueEndDate ~= nil then
												mw.logObject(namingEndDate)
												if DateUtils.compare(namingEndDate, returnValueEndDate) > 0 then
													--the naming end date is more recent than the end date of the candidate return value
													returnValueCandidate = eachPartyShortNameClaim.mainsnak.datavalue.value.text
													returnValueEndDate = namingEndDate
													--else not interested: examined date is older than what we already have
												end
											--else not interested: we have one value without end date, which means it's current
											end
										--else not interested: lower rank
										end
									else
										--in this case, we want the one with the oldest end date, but newer than the time reference
										if namingEndDate and DateUtils.compare(namingEndDate, inPartyEndDate) >= 0 then
											-- the naming end date is more recent than the time reference
											if DateUtils.compare(namingEndDate, returnValueEndDate) < 0 then
												--the naming end date is older than the current candidate return value
												returnValueCandidate = eachPartyShortNameClaim.mainsnak.datavalue.value.text
												returnValueEndDate = namingEndDate
												--else not interested: we have a candidate that is already closer to the time reference than this one
											end
										--else not interested: either not dated or ended before the time reference
										end
									end
								--else not interested: unknown or no value, or foreign language
								end
							end --for
							if not returnValueCandidate then returnValueCandidate = wikidata.findOneValue('P1813', entityObjectQId) end
						end
						return returnValueCandidate
					end)
				elseif wikidataParties[partyIdx].mainsnak == 'novalue' then
					crtEntry = "''Niciunul''"
				end
				
				crtEntry = crtEntry .. wikidata.printTimestampForClaim(wikidataParties[partyIdx])
				if crtEntry ~= '' then table.insert(partiesList, crtEntry) end
			end
			parties = table.concat(partiesList, tostring(mw.html.create('br')))
		end
	end
	if parties then
		computedArgs['label' .. tostring(crtLineIndex)] = 'Partid politic'
		computedArgs['data' .. tostring(crtLineIndex)] = parties
		crtLineIndex = crtLineIndex + 1
	end
	local ideology = wikidata._getValueListWithSeparator({_br_, 'P1142'})
	if ideology and ideology ~= '' then
		computedArgs['label' .. tostring(crtLineIndex)] = 'Ideologie'
		computedArgs['data' .. tostring(crtLineIndex)] =  StringUtils._appendToString({
				ideology,
				wdLinker.displayMessage('P1142')
			})
		crtLineIndex = crtLineIndex + 1
	end
	computedArgs['label' .. tostring(crtLineIndex)] = 'Alte afilieri'
	computedArgs['data' .. tostring(crtLineIndex)] = processedArgs['alte afilieri'] or processedArgs['otherparty']
	crtLineIndex = crtLineIndex + 1
	computedArgs['label' .. tostring(crtLineIndex)] = 'Grup europarlamentar'
	computedArgs['data' .. tostring(crtLineIndex)] = processedArgs['grup_europarlamentar']
	crtLineIndex = crtLineIndex + 1
	computedArgs['label' .. tostring(crtLineIndex)] = 'Rezidență'
	computedArgs['data' .. tostring(crtLineIndex)] = processedArgs['rezidenta'] or processedArgs['rezidență'] or processedArgs['residence']
	crtLineIndex = crtLineIndex + 1
	computedArgs['spouse'] = processedArgs['sot'] or processedArgs['soț'] or processedArgs['spouse'] or processedArgs['sotia'] or processedArgs['soție']

	computedArgs['partener'] = processedArgs['partener'] or processedArgs['parteneră']
	computedArgs['children'] = processedArgs['copii'] or processedArgs['children']
	computedArgs['parents'] = processedArgs['părinți'] or processedArgs['parents']
	computedArgs['siblings'] = processedArgs['frati'] or processedArgs['frați']
	computedArgs['avere'] = processedArgs['avere'] or processedArgs['net_worth']

	local alma_mater = processedArgs['alma_mater']
	if mainMode and alma_mater == nil then
		local wikidataAlmaMater = wikidata.findValueListWithQualifiersInBrackets(nil, 'P69', false, {'$P512', '$P812', '$P582'}, {' în ', ', '})
		if wikidataAlmaMater then alma_mater = table.concat(wikidataAlmaMater, tostring(mw.html.create('br'))) end
	end
	if alma_mater then
		computedArgs['label' .. tostring(crtLineIndex)] = '[[Alma mater]]'
		computedArgs['data' .. tostring(crtLineIndex)] = alma_mater
		crtLineIndex = crtLineIndex + 1
	end
	computedArgs['label' .. tostring(crtLineIndex)] = 'Cunoscut' .. (gender == nil and '(ă)' or gender == 'f' and 'ă' or '') .. ' pentru'
	computedArgs['data' .. tostring(crtLineIndex)] = processedArgs['cunoscut_pentru']
	crtLineIndex = crtLineIndex + 1
	computedArgs['label' .. tostring(crtLineIndex)] = 'Societăți'
	computedArgs['data' .. tostring(crtLineIndex)] = processedArgs['societăți']
	crtLineIndex = crtLineIndex + 1
	computedArgs['label' .. tostring(crtLineIndex)] = 'Organizații'
	computedArgs['data' .. tostring(crtLineIndex)] = processedArgs['organizații']
	crtLineIndex = crtLineIndex + 1
	computedArgs['occupation'] = processedArgs['ocupatia'] or processedArgs['ocupație'] or processedArgs['occupation']
	computedArgs['label' .. tostring(crtLineIndex)] = 'Profesie'
	computedArgs['data' .. tostring(crtLineIndex)] = processedArgs['profesia'] or processedArgs['profesie'] or processedArgs['profession']
	crtLineIndex = crtLineIndex + 1
	computedArgs['nationality'] = processedArgs['nationalitatea'] or processedArgs['naționalitate'] or processedArgs['nationality']
	computedArgs['ethnicity'] = processedArgs['etnie'] or processedArgs['ethnicity']
	computedArgs['citizenship'] = processedArgs['cetatenie'] or processedArgs['cetățenie'] or processedArgs['citizenship']
	computedArgs['religion'] = processedArgs['religie'] or processedArgs['religia'] or processedArgs['confesiune'] or processedArgs['religion']
	computedArgs['signature'] = processedArgs['semnătură'] or processedArgs['semnatura'] or processedArgs['signature']
	crtLineIndex = crtLineIndex + 1
	computedArgs['data' .. tostring(crtLineIndex)] = processedArgs['note'] or processedArgs['footnotes']
	crtLineIndex = crtLineIndex + 1
	for embeddedIdx = 1, table.maxn(embedded) do
		if embedded[embeddedIdx] then
			computedArgs['data' .. tostring(crtLineIndex)] = embedded[embeddedIdx]
			crtLineIndex = crtLineIndex + 1
		end
	end
	return computedArgs
end

p.show = function(frame)
	local infoboxArguments = computeArguments(getArgs(frame))
	mw.logObject(infoboxArguments['name'])
	mw.logObject(mw.title.getCurrentTitle().text)
	return infobox.displayInfoboxFromArgs(infoboxArguments)
end

p.fromArray = computeArguments

return p