Modul:InfoboxBiography

De la Wikipedia, enciclopedia liberă
Sari la navigare Sari la căutare

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

local p = {}
local getArgs = require('Modul:Arguments').getArgs
local wikidata = require('Modul:Wikidata')
local lc = require('Modul:LocationAndCountry')
local bda = require('Modul:BirthDateAndAge')
local infobox = require('Modul:Infobox')
local infoboxImage = require('Modul:InfoboxImage').InfoboxImage
local join = require('Modul:Separated entries')._main
local StringUtils = require('Modul:StringUtils')
local DateUtils = require('Modul:DateUtils')
local Lang = require('Modul:Lang')
local TableTools = require('Modul:TableTools')
local toWdLinkGenerator = require('Modul:EditAtWikidata')
local NameAndImage = require('Modul:NameAndImage')
local libraryUtil = require( 'libraryUtil' )
local plural = require('Modul:Plural')

local _br_ = tostring(mw.html.create('br'))
local appendToString = StringUtils._appendToString
local prependToString = StringUtils._prependToString
local encloseString = StringUtils._encloseString

local function extractDedicatedArgFromInputArgs(retainedInputArgs, args, argNames, wikidataCallback)
	libraryUtil.checkType('extractDedicatedArgFromInputArgs', 1, retainedInputArgs, 'table', true)
	libraryUtil.checkType('extractDedicatedArgFromInputArgs', 2, args, 'table', false)
	libraryUtil.checkType('extractDedicatedArgFromInputArgs', 3, argNames, 'table', true)
	libraryUtil.checkType('extractDedicatedArgFromInputArgs', 4, wikidataCallback, 'function', true)
	
	if argNames == nil then return nil end
	local foundValue = nil
	for argNameIdx,argName in pairs(argNames) do
		local argv = args[argName]
		if argv and foundValue == nil then
			foundValue = argv
			break
		end
	end

	if foundValue then
		for argNameIdx,argName in pairs(argNames) do
			table.insert(retainedInputArgs, argName)
		end
		return foundValue
	end

	if args['embed'] ~= 'yes' and args['embed'] ~= 'y' and args['embed'] ~= 'da' then
		local wikidataValue, wikidataId, wikidataEntId = wikidataCallback()
		if wikidataValue and mw.ustring.len(mw.text.trim(wikidataValue)) > 0 then return wikidataValue .. toWdLinkGenerator.displayMessage(wikidataId, wikidataEntId) end
	end
	return nil
end

local function copyProperty(outputTable, inputTable, propName)
	libraryUtil.checkType('copyProperty', 1, outputTable, 'table', false)
	libraryUtil.checkType('copyProperty', 2, inputTable, 'table', false)
	libraryUtil.checkTypeMulti('copyProperty', 3, propName, {'string', 'number'})
	outputTable[propName] = inputTable[propName]
end

local function tableContains(haystackTable, needle)
	libraryUtil.checkType('tableContains', 1, haystackTable, 'table', true)
	if haystackTable == nil or needle == nil then return false end
	for k, v in pairs(haystackTable) do
		if v == needle then return true end
	end
	return false
end

local function processArgs(args)
	local processedArgs = {}
	local retainedInputArgs = {}
	local labeldatacount = 2
	
	processedArgs['child'] = (args['embed'] == 'yes' or args['embed'] == 'da' or args['embed'] == 'y') and 'yes' or nil
	if args['culoare cadru'] then processedArgs['culoare cadru'] = args['culoare cadru'] end
	if args['culoare text'] then processedArgs['culoare text'] = args['culoare text'] end
	copyProperty(processedArgs, args, 'aboveclass')
	processedArgs['navbar'] = 'false'

	if (processedArgs['child'] == nil) then
		processedArgs['header1'] = 'Date personale'
		local genderSuffix = ''
		local wikidataGender = wikidata.findOneValueNoRef('P21')
		if wikidataGender and mw.ustring.find(wikidataGender, 'femeie', 1, true) then genderSuffix = 'ă' end
		
		local imageName = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'image', 'Imagine', 'imagine', 'foto'}, function() return nil, nil, nil end)
		if imageName then
			if StringUtils._startsWithAny({mw.text.trim(imageName), '[['}) then
				imageName = StringUtils._substringBefore({mw.text.trim(imageName), ']]', '|'})
				imageName = StringUtils._removeStart({imageName, '[['})
			end
			imageName = StringUtils._removeStart({mw.text.trim(imageName), 'File:'})
			imageName = StringUtils._removeStart({imageName, 'Fișier:'})
			imageName = StringUtils._removeStart({imageName, 'Fişier:'})
			imageName = StringUtils._removeStart({imageName, 'Image:'})
			imageName = StringUtils._removeStart({imageName, 'Imagine:'})
			imageName = StringUtils._removeStart({imageName, 'Media:'})
			local imgTitle = mw.title.new(imageName, 6)
			if not imgTitle or not imgTitle.file or not imgTitle.file.exists then
				imageName = nil
			end
		end
		local imageCaption = args['caption'] or args['descriere'] or args['comentariu'] or args['Descriere']
		
		local wdImageName, wdImageCaption
		if imageName == nil then
			wdImageName, wdImageCaption = wikidata.findImageAndCaption()
			imageName = wdImageName
			imageCaption = wdImageCaption
		end
		if imageName and mw.ustring.len(imageName) > 0 then
			local imageSize = args['imagesize'] or args['image_size'] or args['Lățime']
			processedArgs['image'] = infoboxImage{image=imageName, size=imageSize, sizedefault='frameless', upright='1', suppressplaceholder='yes'}
			processedArgs['caption'] = imageCaption
		end
		
		local birthName = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'nume_naștere', 'birth_name'}, function() 
			local birthNameClaims = wikidata.findClaimsForProperty(nil, 'P1477')
			local roVal = nil
			if birthNameClaims then for _,eachBirthNameClaim in ipairs(birthNameClaims) do
				if eachBirthNameClaim.mainsnak.snaktype == 'value' then
					if eachBirthNameClaim.mainsnak.datavalue.value.language == 'ro' then roVal = eachBirthNameClaim.mainsnak.datavalue.value.text end
				end
			end end
			return roVal or wikidata.findOneValue('P1477'), 'P1477', nil
		end)
		if birthName and mw.ustring.len(birthName) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = 'Nume la naștere'
			processedArgs['data' .. tostring(labeldatacount)] = birthName
			labeldatacount = labeldatacount + 1
		end

		local nickname = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'porecla', 'poreclă', 'nickname'}, function() 
			local birthNameClaims = wikidata.findClaimsForProperty(nil, 'P1449')
			local roVals = {}
			local otherLangVals = {}
			if birthNameClaims then for _,eachBirthNameClaim in ipairs(birthNameClaims) do
				if wikidata.hasValueSnak(eachBirthNameClaim) and wikidata.claimHasRankAtLeastNormal(eachBirthNameClaim) then
					if eachBirthNameClaim.mainsnak.datavalue.value.language == 'ro' then
						table.insert(roVals, eachBirthNameClaim.mainsnak.datavalue.value.text)
					else
						table.insert(otherLangVals, Lang.fromArgs(eachBirthNameClaim.mainsnak.datavalue.value.language, nil, eachBirthNameClaim.mainsnak.datavalue.value.text, false))
					end
				end
			end end
			if #roVals == 0 and #otherLangVals == 0 then return nil end
			return mw.text.listToText(#roVals > 0 and roVals or otherLangVals, ', ', ', '), 'P1449', nil
		end)
		if nickname and mw.ustring.len(nickname) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = 'Poreclă'
			processedArgs['data' .. tostring(labeldatacount)] = nickname
			labeldatacount = labeldatacount + 1
		end

		local birthDate = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'data_nașterii', 'data_nasterii', 'birth_date', 'Născut'}, function() return bda._getBdaByWikidata{link = 'yes'}, 'P569', nil end)
		local birthPlace = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'locul_nașterii', 'locul_nasterii', 'birth_place', 'Loc naștere'}, function() return lc.displayFromParams('P19', nil, 'P569', 1, '; '), 'P19', nil end)
		if birthDate and mw.ustring.len(birthDate) > 0 or birthPlace and mw.ustring.len(birthPlace) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = 'Născut' .. genderSuffix
			processedArgs['data' .. tostring(labeldatacount)] = join({birthDate, birthPlace, separator = _br_})
			labeldatacount = labeldatacount + 1
		end

		local deathDate = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'data_deces', 'data_decesului', 'death_date', 'Decedat'}, function() return bda._getDdaByWikidata{link = 'yes'}, 'P570', nil end)
		local deathPlace = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'locul_decesului', 'death_place', 'Loc deces'	}, function() return lc.displayFromParams('P20', nil, 'P570', 1, '; ') end)
		if deathDate and mw.ustring.len(deathDate) > 0 or deathPlace and mw.ustring.len(deathPlace) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = 'Decedat' .. genderSuffix
			processedArgs['data' .. tostring(labeldatacount)] = join({deathDate, deathPlace, separator = _br_})
			labeldatacount = labeldatacount + 1
		end
		
		local burialSite = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'loc_odihna', 'locodihna', 'burial_place', 'final_resting_place'}, function() return wikidata.findOneValue('P119'), 'P119', nil end)
		if burialSite and mw.ustring.len(mw.text.trim(burialSite)) > 0 or args['burial_date'] then
			processedArgs['label' .. tostring(labeldatacount)] = 'Înmormântat' .. genderSuffix
			processedArgs['data' .. tostring(labeldatacount)] = table.concat(TableTools.compressSparseArray({args['burial_date'], burialSite}), tostring(mw.html.create('br')))
			labeldatacount = labeldatacount + 1
		end
		
		local causeOfDeath = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'cauza_decesului', 'death cause', 'death_cause'}, function()
				local mOD = wikidata.findOneValue('P1196')
				local cOD = wikidata.findOneValue('P509')
				local cODTbl = {}
				local cODPropTbl = {}
				if mOD then
					table.insert(cODTbl, mOD)
					table.insert(cODPropTbl, 'P1196')
				end
				if cOD then
					table.insert(cODTbl, cOD)
					table.insert(cODPropTbl, 'P509')
				end
				if #cODTbl == 2 then
					return appendToString({cODTbl[1], prependToString({encloseString({cODTbl[2], '(', ')'}), ' '})}), 'P509', nil
				elseif #cODTbl == 1 then
					return cODTbl[1], cODPropTbl[1], nil
				end
			return nil
		end)
		
		if causeOfDeath and mw.ustring.len(mw.text.trim(causeOfDeath)) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = 'Cauza decesului'
			processedArgs['data' .. tostring(labeldatacount)] = causeOfDeath
			labeldatacount = labeldatacount + 1
		end

		local parents = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'părinți', 'parents', 'parinti'}, function() return join({wikidata.findOneValue('P22'), wikidata.findOneValue('P25'), separator = _br_}), 'P22', nil end)
		if parents and mw.ustring.len(mw.text.trim(parents)) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = 'Părinți'
			processedArgs['data' .. tostring(labeldatacount)] = parents
			labeldatacount = labeldatacount + 1
		end
		
		local siblings = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'frați', 'frati', 'siblings'}, function()
			local tbl = {}
			local props = {'P7', 'P9', 'P3373'}
			local actualProp = nil
			local wdTbl = {wikidata.getValueList(nil, 'P7'), wikidata.getValueList(nil, 'P9'), wikidata.getValueList(nil, 'P3373')}
			for _i,lst in ipairs(wdTbl) do
				for _i1,v in ipairs(lst or {}) do 
					table.insert(tbl, v)
					actualProp = props[_i]
				end
			end
			tbl.separator = _br_
			return join(tbl), actualProp, nil
		end)
		if siblings and mw.ustring.len(mw.text.trim(siblings)) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = 'Frați și surori'
			processedArgs['data' .. tostring(labeldatacount)] = siblings
			labeldatacount = labeldatacount + 1
		end

		local partners = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'partener', 'partners'}, function() return nil, nil, nil end)
		if partners and mw.ustring.len(mw.text.trim(partners)) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = 'Partener(i)'
			processedArgs['data' .. tostring(labeldatacount)] = partners
			labeldatacount = labeldatacount + 1
		end
		
		local spouse = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'soț', 'soție', 'sot', 'sotie', 'spouse', 'căsătorit'}, function() return wikidata._getTimestampedValueListWithSeparator({_br_, 'P26'}), 'P26', nil end)
		if spouse and mw.ustring.len(mw.text.trim(spouse)) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = args['spouse-type'] or ('Căsătorit' .. genderSuffix .. ' cu')
			processedArgs['data' .. tostring(labeldatacount)] = spouse
			labeldatacount = labeldatacount + 1
		end
		
		local numberChildren = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'număr_copii', 'numărcopii', 'number_children', 'childrennumber'}, function() return wikidata.findOneValue('P1971'), 'P1971', nil end)
		if numberChildren and mw.ustring.len(mw.text.trim(numberChildren)) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = 'Număr de copii'
			processedArgs['data' .. tostring(labeldatacount)] = numberChildren
			labeldatacount = labeldatacount + 1
		end
		
		local children = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'copii', 'children'}, function() return wikidata._getValueListWithSeparator({_br_, 'P40'}), 'P40', nil end)
		if children and mw.ustring.len(mw.text.trim(children)) > 0 then
			processedArgs['label' .. tostring(labeldatacount)] = 'Copii'
			processedArgs['data' .. tostring(labeldatacount)] = children
			labeldatacount = labeldatacount + 1
		end

		local nationality = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'nationalitate', 'nationality', 'naționalitate', 'Naționalitate'}, function() return nil end)
		if nationality then
			processedArgs['label' .. tostring(labeldatacount)] = 'Naționalitate'
			processedArgs['data' .. tostring(labeldatacount)] = nationality
			labeldatacount = labeldatacount + 1
		end
		
		local rude = processedArgs['rude'] or processedArgs['relations']
		if rude then
			processedArgs['label' .. tostring(crtLineIndex)] = 'Rude'
			processedArgs['data' .. tostring(crtLineIndex)] = rude
			labeldatacount = labeldatacount + 1
		end

		local citizenship = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'cetatenie', 'cetățenie', 'citizenship'}, function() 
			local endOfCitizenship = wikidata.loadOneValueInChain({'P27', '_P582'})
			if not endOfCitizenship or endOfCitizenship == '' then endOfCitizenship = wikidata.loadOneValueInChain({'P570', 'raw'}) end
			return NameAndImage._nameAndFlagFromPropOfEntity('P27', nil, DateUtils.parseWikidataDate(endOfCitizenship))
		end)
		if citizenship then
			processedArgs['label' .. tostring(labeldatacount)] = 'Cetățenie'
			processedArgs['data' .. tostring(labeldatacount)] = citizenship
			labeldatacount = labeldatacount + 1
		end

		local ethnicityWdRetriever = function(entity)
			local ethnicityClaims = wikidata.findBestClaimsForProperty(entity, 'P172') -- ethnic group
			local retList = {}
			
			if ethnicityClaims then
				for _,eachEthnicityClaim in pairs(ethnicityClaims) do
					if eachEthnicityClaim.type == 'statement' and eachEthnicityClaim.mainsnak and eachEthnicityClaim.mainsnak.snaktype == 'value' then
						local callFunction = function(object, female)
							local returnValue = nil
							if object and object.claims and object.claims['P1549'] then
								for eachClaimIdx, eachClaim in pairs(object.claims['P1549']) do
									if eachClaim.type == 'statement' and eachClaim.mainsnak.snaktype == 'value' and eachClaim.mainsnak.datavalue then
										if eachClaim.mainsnak.datavalue.value.language == 'ro' then
											local qualifierIsFeminine = eachClaim.qualifiers and eachClaim.qualifiers['P21'] and eachClaim.qualifiers['P21'][1] and eachClaim.qualifiers['P21'][1].snaktype == 'value' and eachClaim.qualifiers['P21'][1].datavalue.value['numeric-id'] == 1775415
											if (qualifierIsFeminine and female) or (not qualifierIsFeminine and not female) then
												returnValue = eachClaim.mainsnak.datavalue.value.text
											end
										end
									end
								end
							end
							return returnValue
						end
						local callFunctionWithGender = function(object) return callFunction(object, false) end
						
						local female = false
						local genderClaims = wikidata.findBestClaimsForProperty(entity, 'P21')
						if genderClaims and genderClaims[1] and genderClaims[1].mainsnak and genderClaims[1].mainsnak.snaktype == 'value' then
							if genderClaims[1].mainsnak.datavalue.value['numeric-id'] == 6581072 then
								female = true
							end
						end
						if female then callFunctionWithGender = function(object) return callFunction(object, true) end end
						table.insert(retList, wikidata.findLinkToItemWithCallback(eachEthnicityClaim.mainsnak.datavalue.value['numeric-id'], false, callFunctionWithGender))
					end
				end
			end
			if #retList > 0 then
				retList.separator = tostring(mw.html.create('br'))
				return join(retList), 'P172', nil
			end
			return nil, nil, nil
		end
		local ethnicity = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'etnie', 'ethnicity'}, ethnicityWdRetriever)
		if ethnicity then
			processedArgs['label' .. tostring(labeldatacount)] = 'Etnie'
			processedArgs['data' .. tostring(labeldatacount)] = ethnicity
			labeldatacount = labeldatacount + 1
		end
		
		local religion = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'religie', 'religion', 'confesiune'}, function() return wikidata._getValueListWithSeparator({_br_, 'P140'}), 'P140', nil end)
		if religion then
			processedArgs['label' .. tostring(labeldatacount)] = 'Religie'
			processedArgs['data' .. tostring(labeldatacount)] = religion
			labeldatacount = labeldatacount + 1
		end
		
		local occupation = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'ocupație', 'occupation', 'ocupatie', 'profesiune', 'profesie'}, function() 
			local occupationClaims = wikidata.findBestClaimsForProperty(nil, 'P106')
			local fem = wikidata.isFemale()
			local occupationList = {}
			if occupationClaims then for _,eachOccupationClaim in ipairs(occupationClaims) do
				if eachOccupationClaim.mainsnak.snaktype == 'value' then
					table.insert(occupationList, wikidata.findLinkToItem(eachOccupationClaim.mainsnak.datavalue.value['numeric-id'], false, fem))
				end
			end end
			return table.concat(occupationList, tostring(mw.html.create('br'))), 'P106', nil
		end)
		
		if occupation then
			processedArgs['label' .. tostring(labeldatacount)] = 'Ocupație'
			processedArgs['data' .. tostring(labeldatacount)] = occupation
			labeldatacount = labeldatacount + 1
		end
		
		local work_location = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'loc_activitate', 'work_location'}, function() 
			local workLocations = wikidata.findValueListWithQualifiersInBrackets(nil, 'P937', false, {'$P580', '$P582'}, {'–'})
			if workLocations then return mw.text.listToText(workLocations, _br_, _br_), 'P937', nil end
		end)
		if work_location then
			processedArgs['label' .. tostring(labeldatacount)] = 'Locul desfășurării activității'
			processedArgs['data' .. tostring(labeldatacount)] = work_location
			labeldatacount = labeldatacount + 1
		end
		
		local net_worth = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'avere', 'net_worth'}, function() 
			return wikidata.findOneValue('P2218')
		end)
		if net_worth then
			processedArgs['label' .. tostring(labeldatacount)] = 'Avere'
			processedArgs['data' .. tostring(labeldatacount)] = net_worth
			labeldatacount = labeldatacount + 1
		end
		
		index = 1
		processedArgs['subheaderstyle'] = args['stilsubtitlu'] or args['subheaderstyle'] or 'font-weight: bold; font-size: 110%'
		if args['aniversare_naștere'] then
			local by = wikidata.findAnniversary('P569', mw.wikibase.getEntityIdForCurrentPage(), args['aniversare_naștere'])
			if by and by > 0 then
				processedArgs['subheader' .. tostring(index)] = plural.build_plural(by, "an", "ani") .. ' de la naștere'
				index = index + 1
			end
		end
		if args['aniversare_deces'] then
			local dy = wikidata.findAnniversary('P570', mw.wikibase.getEntityIdForCurrentPage(), args['aniversare_deces'])
			if dy and dy > 0 then
				processedArgs['subheader' .. tostring(index)] = plural.build_plural(dy, "an", "ani") .. ' de la moarte'
				index = index + 1
			end
		end
		processedArgs['title'] = args['Nume'] or args['nume'] or args['name'] or wikidata.findLabel()
		processedArgs['doc'] = args['doc']
		processedArgs['wikidata'] = args['wikidata']
	else
		processedArgs['title'] = args['default_title']
		processedArgs['parent_colspan'] = args['parent_colspan'] or '2'
	end
	table.insert(retainedInputArgs, 'title')
	
	labeldatacount = labeldatacount + 1

	local earliestHeaderNumberAfterGeneralLabels = 0
	local earliestDataNumberAfterGeneralLabels = 0

	local largestIndex = labeldatacount

	for argN, argV in pairs(args) do
		local headerStart
		local headerEnd
		local labelStart
		local labelEnd
		local dataStart
		local dataEnd
		headerStart, headerEnd = mw.ustring.find(argN, "header")
		labelStart, labelEnd = mw.ustring.find(argN, "label")
		dataStart, dataEnd = mw.ustring.find(argN, "data")
		styleStart, styleEnd = mw.ustring.find(argN, "style")
		classStart, classEnd = mw.ustring.find(argN, "class")
		
		local nr = ""
		local argumentName = nil
		if dataStart == 1 then
			nr = mw.ustring.sub(argN, 1 + dataEnd, mw.ustring.len(argN))
			argumentName = 'data'
			if argV and mw.ustring.len(mw.text.trim(argV)) > 0 and nr ~= nil and mw.ustring.match(nr, '%d+') then
				if earliestDataNumberAfterGeneralLabels == 0 or earliestDataNumberAfterGeneralLabels < tonumber(nr) then
					earliestDataNumberAfterGeneralLabels = tonumber(nr)
				end
			end
		elseif labelStart == 1 then
			nr = mw.ustring.sub(argN, 1 + labelEnd, mw.ustring.len(argN))
			argumentName = 'label'
		elseif headerStart == 1 then
			nr = mw.ustring.sub(argN, 1 + headerEnd, mw.ustring.len(argN))
			argumentName = 'header'
			if argV and mw.ustring.len(mw.text.trim(argV)) > 0 and nr ~= nil and mw.ustring.match(nr, '%d+') then
				if earliestHeaderNumberAfterGeneralLabels == 0 or earliestHeaderNumberAfterGeneralLabels < tonumber(nr) then
					earliestHeaderNumberAfterGeneralLabels = tonumber(nr)
				end
			end
		elseif styleStart == 1 then
			nr = mw.ustring.sub(argN, 1 + styleEnd, mw.ustring.len(argN))
			argumentName = 'style'
		elseif classStart == 1 then
			nr = mw.ustring.sub(argN, 1 + classEnd, mw.ustring.len(argN))
			argumentName = 'class'
		end
		if argumentName and nr and mw.ustring.len(mw.text.trim(nr)) > 0 and mw.ustring.gsub(nr, '%d+', '') == '' then
			local argumentidx = labeldatacount + tonumber(nr)
			processedArgs[argumentName .. tostring(argumentidx)] = argV
			largestIndex = math.max(largestIndex, argumentidx)
		elseif not tableContains(retainedInputArgs, argN) then
			processedArgs[argN] = argV
		end
	end
	if earliestDataNumberAfterGeneralLabels > 0 and (earliestHeaderNumberAfterGeneralLabels > earliestDataNumberAfterGeneralLabels or earliestHeaderNumberAfterGeneralLabels == 0) then
		processedArgs['header' .. tostring(labeldatacount - 1)] = args['bio_header'] or 'Activitate'
	end

	if not processedArgs['child'] then	
		local crtLineIndex = largestIndex + 1
		local signature = args['semnătură'] or args['semnatura'] or args['signature'] or wikidata.findOneValueNoRef('P109', nil)
		if signature and signature ~= '' then
			processedArgs['header' .. tostring(crtLineIndex)] = 'Semnătură'
			crtLineIndex = crtLineIndex + 1
			processedArgs['data' .. tostring(crtLineIndex)] = infoboxImage{image=signature, size='150', sizedefault='frameless', suppressplaceholder='yes'}
			crtLineIndex = crtLineIndex + 1
		end
		
		local onlinelinks = {}
		local linkstopullfromwd = {'P2013', 'P2002', 'P2035', 'P2847', 'P345', 'P3265', 'P3579', 'P3435', 'P2003', 'P2471', 'P2397', 'P6634'}
		local webaddr = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'sit', 'site', 'web', 'website', 'sit-web', 'site-web', 'sit-adresă', 'URL', 'url'}, function() return nil end)
		if webaddr then
			if mw.ustring.find(webaddr, '[', 1, true) then
				webaddr = StringUtils._substringBefore({StringUtils._substringAfter({webaddr, '['}), ' '})
			end
		end
		if webaddr and mw.ustring.len(mw.text.trim(webaddr)) > 0 then
			table.insert(onlinelinks, '[' .. webaddr .. ' Site web]')
		else
			table.insert(linkstopullfromwd, 1, 'P856')
		end
		local wdonlinelinks = wikidata.findOnlineLinks(linkstopullfromwd)
		for _,eachWdOnlineLink in ipairs(wdonlinelinks) do
			table.insert(onlinelinks, eachWdOnlineLink)
		end

		if #onlinelinks > 0 then
			processedArgs['header' .. tostring(crtLineIndex)] = 'Prezență online'
			crtLineIndex = crtLineIndex + 1
			processedArgs['data' .. tostring(crtLineIndex)] = tostring(
				mw.html.create('div')
					:css('text-align', 'center')
					:wikitext(table.concat(onlinelinks, tostring(mw.html.create('br'))))
			)
			crtLineIndex = crtLineIndex + 1
		end
	end
	return processedArgs
end

p.displayInfoboxFromArgs = function(args)
	local processedArgs = processArgs(args)
	local outtext = infobox._infobox(processedArgs)
	local maintcats = {}
	if not processedArgs.image then
		table.insert(maintcats, 'Articole biografice fără fotografii')
	end
	
	for _,eachMaintCat in ipairs(maintcats) do
		outtext = outtext .. '[[Categorie:' .. eachMaintCat .. ']]'
	end
	
	return outtext
end

p.displayInfobox = function(frame)
	local args = getArgs(frame, {parentFirst = true})
	return p.displayInfoboxFromArgs(args)
end

return p