Sari la conținut

Modul:InfoboxActor

De la Wikipedia, enciclopedia liberă

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

local getArgs = require('Modul:Arguments').getArgs
local infoboxbio = require('Modul:InfoboxBiography')
local wikidata = require('Modul:Wikidata')
local infoboxImage = require('Modul:InfoboxImage').InfoboxImage
local TableTools = require('Modul:TableTools')
local join = require('Modul:Separated entries')._main
local p = {}

local function processArgs(args)
	local outArgs = {
		doc = 'Infocaseta Actor',
		wikidata = 'y',
		aboveclass = 'cinema',
		abovestyle = 'background-color:{{{bgcolor|#F0E68C}}}; color:#000000;',
		datastyle = 'text-align:left',
	}
	outArgs['culoare cadru'] = 'F0E68C'
	outArgs['child'] = args['embed']
	outArgs['title'] = outArgs['child'] and 'Cariera actoricească' or args['nume'] or wikidata.findLabel(nil, 'ro')
	local imageName = args['imagine'] or args['image'] or (outArgs['child'] == nil and wikidata.findOneValueNoRef('P18'))
	local imageSize = args['dimensiune imagine'] or args['imagesize']
	outArgs['image'] = infoboxImage{image=imageName, size=imageSize, suppressplaceholder = 'yes', sizedefault='frameless'}
	outArgs['caption'] = args['descriere'] or args['descriere imagine'] or args['caption']
	outArgs['birth_name'] = args['nume naștere'] or args['birth_name']
	outArgs['birth_date'] = args['dată naștere'] or args['birth_date']
	outArgs['birth_place'] = args['loc naștere'] or args['birth_place']
	outArgs['death_date'] = args['dată deces'] or args['death_date']
	outArgs['death_place'] = args['loc deces'] or args['death_place']
	outArgs['citizenship'] = args['cetățenie'] or args['citizenship']
	outArgs['etnie'] = args['etnie']
	outArgs['parents'] = args['părinți'] or args['parents']
	outArgs['spouse'] = args['căsătorit cu'] or args['spouse']
	outArgs['copii'] = args['children'] or args['copii']
	outArgs['partener'] = args['partener'] or args['partner']
	outArgs['frați'] = args['frați']
	outArgs['occupation'] = args['ocupație'] or args['occupation']
	
	local idx = 1
	
	outArgs['label' .. tostring(idx)] = '[[Alma mater]]'
	outArgs['data' .. tostring(idx)] = args['alma mater'] or (outArgs['child'] == nil and wikidata._getValueListWithSeparator({tostring(mw.html.create('br')), 'P69'}))
	idx = idx + 1

	outArgs['label' .. tostring(idx)] = 'Înălțime'
	outArgs['data' .. tostring(idx)] = args['înălțime']
	idx = idx + 1
	
	outArgs['label' .. tostring(idx)] = 'Alte nume'
	outArgs['data' .. tostring(idx)] = args['alte nume']
	idx = idx + 1

	outArgs['label' .. tostring(idx)] = 'Ani de activitate'
	outArgs['data' .. tostring(idx)] = args['ani de activitate'] or args['years_active']
	idx = idx + 1

	outArgs['label' .. tostring(idx)] = 'Site oficial'
	outArgs['data' .. tostring(idx)] = args['website']
	if args['data' .. tostring(idx)] == nil then
		local wdSite = wikidata.findOneValueNoRef('P856')
		outArgs['data' .. tostring(idx)] = '[' .. wdSite .. ' ' .. wdSite .. ']'
	end
	idx = idx + 1

	outArgs['label' .. tostring(idx)] = 'Roluri importante'
	outArgs['data' .. tostring(idx)] = args['roluri importante']
	idx = idx + 1

	outArgs['label' .. tostring(idx)] = 'Influențe'
	outArgs['data' .. tostring(idx)] = args['influențe']
	idx = idx + 1

	outArgs['label' .. tostring(idx)] = 'A influențat pe'
	outArgs['data' .. tostring(idx)] = args['influențat']
	idx = idx + 1

	outArgs['label' .. tostring(idx)] = 'Debut'
	outArgs['data' .. tostring(idx)] = args['operă_de_debut']
	idx = idx + 1
	
	local oscar = args['oscar']
	local gglobe = args['goldenglobeawards']
	local bafta = args['bafta']
	local cesar = args['cesar']
	local emmy = args['emmy']
	local tony = args['tony']
	local goya = args['goya']
	local afia = args['afia']
	local filmfare = args['filmfare']
	local olivier = args['olivier']
	local gopo = args['gopo']
	local otherawards = args['alte premii']
	
	local oscarlist = {}
	local emmieslist = {}
	local otherawardslist = {}
	
	local wdAwardClaims = wikidata.findBestClaimsForProperty(nil, 'P166')
	if wdAwardClaims then
		for wdAwardClaimIdx, eachWdAwardClaim in pairs(wdAwardClaims) do
			if eachWdAwardClaim.type == 'statement' and eachWdAwardClaim.mainsnak.snaktype == 'value' then
				local awardId = eachWdAwardClaim.mainsnak.datavalue.value['numeric-id']
				local awardInstanceOfs = wikidata.findBestClaimsForProperty('Q' .. tostring(awardId), 'P31')
				local awardSubclassOfs = wikidata.findBestClaimsForProperty('Q' .. tostring(awardId), 'P279')
				local awardSuperclasses = {}
				if awardInstanceOfs then
					for _,eachAward in pairs(awardInstanceOfs) do
						table.insert(awardSuperclasses, eachAward)
					end
				end
				if awardSubclassOfs then
					for _,eachAward in pairs(awardSubclassOfs) do
						table.insert(awardSuperclasses, eachAward)
					end
				end

				local forWork = wikidata.findQualifierValueListForClaim(eachWdAwardClaim, 'P1686') -- for work
				local pointInTime = wikidata.findQualifierValueListForClaim(eachWdAwardClaim, 'P585') -- point in time
				local awardName = wikidata.printSnak(eachWdAwardClaim)
				local awardSpecification = ''
				if pointInTime and #pointInTime > 0 then
					awardSpecification = awardSpecification .. ' (' .. pointInTime[1] .. ')'
				end
				if forWork and #forWork > 0 then
					forWork.separator = ', '
					forWork.conjunction = ' și '
					awardSpecification = awardSpecification .. ' pentru ' .. join(forWork)
				end

				local supertype = 'other'
				for _,eachAwardsuperclassClaim in pairs(awardSuperclasses) do
					if eachAwardsuperclassClaim.type == 'statement' and eachAwardsuperclassClaim.mainsnak.snaktype == 'value' then
						local typeId = eachAwardsuperclassClaim.mainsnak.datavalue.value['numeric-id']
						if typeId == 19020 then  --oscar
							awardName = mw.ustring.gsub(awardName, '|Premiul Oscar pentru ', '|')
							awardName = mw.ustring.gsub(awardName, '|%s*(%a)', function(m1) return '|' .. mw.ustring.upper(m1) end)
							table.insert(oscarlist, awardName .. awardSpecification)
						elseif typeId == 123737 then --emmy
							table.insert(emmieslist, awardName .. awardSpecification)
						else
							table.insert(otherawardslist, awardName .. awardSpecification)
						end
					end
				end
			end
		end
	end
	if #oscarslist > 0 then
		oscarslist.separator = tostring(mw.html.create('br'))
		oscar = join(oscarslist)
	end
	if #emmieslist > 0 then
		emmieslist.separator = tostring(mw.html.create('br'))
		emmy = join(emmieslist)
	end
	if otherawards == nil and #otherawardslist > 0 then
		otherawardslist.separator = tostring(mw.html.create('br'))
		otherawards = join(otherawardslist)
	end
	
	if oscar then
		outArgs['header' .. tostring(idx)] = '[[Premii Oscar]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = oscar
		idx = idx + 1
	end
	
	if gglobe then
		outArgs['header' .. tostring(idx)] = '[[Premii Globul de Aur]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = gglobe
		idx = idx + 1
	end
	
	if bafta then
		outArgs['header' .. tostring(idx)] = '[[Premiile BAFTA|Premii BAFTA]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = bafta
		idx = idx + 1
	end
	
	if cesar then
		outArgs['header' .. tostring(idx)] = '[[Premiul César|Premii César]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = oscar
		idx = idx + 1
	end

	if emmy then
		outArgs['header' .. tostring(idx)] = '[[Premii Emmy]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = emmy
		idx = idx + 1
	end

	if tony then
		outArgs['header' .. tostring(idx)] = '[[Premiile Tony|Premii Tony]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = tony
		idx = idx + 1
	end
	
	if goya then
		outArgs['header' .. tostring(idx)] = '[[Premii Goya]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = goya
		idx = idx + 1
	end
	
	if afia then
		outArgs['header' .. tostring(idx)] = '[[Australian Film Institute Awards|Premii AFI]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = afia
		idx = idx + 1
	end

	if filmfare then
		outArgs['header' .. tostring(idx)] = '[[Premii Filmfare]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = filmfare
		idx = idx + 1
	end

	if olivier then
		outArgs['header' .. tostring(idx)] = '[[Premii Laurence Olivier]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = olivier
		idx = idx + 1
	end

	if otherawards then
		outArgs['header' .. tostring(idx)] = 'Alte premii'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = otherawards
		idx = idx + 1
	end

	if gopo then
		outArgs['header' .. tostring(idx)] = '[[Premiile Gopo|Premii Gopo]]'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = gopo
		idx = idx + 1
	end

	local signature = args['signature'] or args['semnătură'] or (outArgs['child'] == nil and wikidata.findOneValueNoRef('P109'))
	if signature then
		outArgs['header' .. tostring(idx)] = 'Semnătură'
		idx = idx + 1
		outArgs['data' .. tostring(idx)] = infoboxImage{image=signature, size = '170px', sizedefault='frameless', suppressplaceholder='yes'}
		idx = idx + 1
	end
	
	local embeddedIdsPresent = TableTools.affixNums(args, 'embedded')
	if embeddedIdsPresent then
		for _,eachEmbeddedId in pairs(embeddedIdsPresent) do
			outArgs['data' .. tostring(idx)] = args['embedded' .. tostring(eachEmbeddedId)]
			idx = idx + 1
		end
	end
	return outArgs
end

p.fromArgs = function(args)
	local processedArgs = processArgs(args)
	return infoboxbio.displayInfoboxFromArgs(processArgs)
end

p.fromFrame = function(frame)
	local args = getArgs(frame)
	return p.fromArgs(args)
end

return p