Modul:InfoboxBiography
Aspect
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 wdu_b = require('Modul:WikidataUtils/Biography')
local Transliteration = require('Modul:Transliteration')
local MIN_YEAR_TO_DISPLAY_CITIZENSHIP = 1800
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'
local q = args.q or mw.wikibase.getEntityIdForCurrentPage()
if (processedArgs['child'] == nil) then
processedArgs['header1'] = 'Date personale'
local genderSuffix = wdu_b.isFemale() and 'ă' or ''
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 = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'caption', 'descriere', 'comentariu', 'Descriere'}, function() return nil, nil, nil end)
local wdImageName, wdImageCaption
if imageName == nil then
wdImageName, wdImageCaption = wikidata.findImageAndCaption(q)
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(q, 'P1477')
local roVal = nil
local otherLangVals = {}
if birthNameClaims then for _,eachBirthNameClaim in ipairs(birthNameClaims) do
if wikidata.isClaimTrue(eachBirthNameClaim) and wikidata.hasValueSnak(eachBirthNameClaim) then
if eachBirthNameClaim.mainsnak.datavalue.value.language == 'ro' then
roVal = eachBirthNameClaim.mainsnak.datavalue.value.text
else
local thisName = nil
if Transliteration.isTransliterationSupported(eachBirthNameClaim.mainsnak.datavalue.value.language) then
thisName = Lang.fromArgs(eachBirthNameClaim.mainsnak.datavalue.value.language .. '-Latn', nil, Transliteration.transliterate(eachBirthNameClaim.mainsnak.datavalue.value.text, eachBirthNameClaim.mainsnak.datavalue.value.language), false)
else
thisName = Lang.fromArgs(eachBirthNameClaim.mainsnak.datavalue.value.language, nil, eachBirthNameClaim.mainsnak.datavalue.value.text, false)
end
table.insert(otherLangVals, thisName)
end
end
end end
if roVal then return roVal, 'P1477', q
elseif #otherLangVals then return mw.text.listToText(otherLangVals, tostring(mw.html.create('br'))), 'P1449', q
else return nil
end
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(q, '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', q
end)
if nickname and mw.ustring.len(nickname) > 0 then
processedArgs['label' .. tostring(labeldatacount)] = args['tip_poreclă'] or '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', q = q}, 'P569', q end)
local birthPlace = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'locul_nașterii', 'locul_nasterii', 'birth_place', 'Loc naștere'}, function() return lc.displayFromParams('P19', nil, 'P569', 1, '; ', true), 'P19', q 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', q = q}, 'P570', q end)
local deathPlace = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'locul_decesului', 'death_place', 'Loc deces' }, function() return lc.displayFromParams('P20', q, 'P570', 1, '; ', true), 'P20', q 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 table.concat(wikidata.findValueListWithDecoratedQualifiers(q, 'P119', false, {'$P580', '$P582'}, {'–'}) or {}, tostring(mw.html.create('br'))), 'P119', q 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', q)
local cOD = wikidata.findOneValue('P509', q)
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', q
elseif #cODTbl == 1 then
return cODTbl[1], cODPropTbl[1], q
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', q), wikidata.findOneValue('P25', q), separator = _br_}), 'P22', q 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(q, 'P7'), wikidata.getValueList(q, 'P9'), wikidata.getValueList(q, '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, q
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', q}), 'P26', q 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._getValueListWithSeparator({_br_, 'P1971', q}), 'P1971', q 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', q, '10'}), 'P40', q 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 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()
if wdu_b.isDead() then
local dateOfDeathClaims = wikidata.findBestClaimsForProperty(q, 'P570')
for _,eachDateOfDeathClaim in ipairs(dateOfDeathClaims) do
local dateOfDeath = DateUtils.extractDateFromWikidataSnak(eachDateOfDeathClaim.mainsnak)
if dateOfDeath and dateOfDeath.year < MIN_YEAR_TO_DISPLAY_CITIZENSHIP then return nil end
end
end
local endOfCitizenship = wikidata.loadOneValueInChain({q, 'P27', '_P582'})
if not endOfCitizenship or endOfCitizenship == '' then endOfCitizenship = wikidata.loadOneValueInChain({q, 'P570', 'raw'}) end
local list = wikidata.findValueListWithDecoratedQualifiers(q, 'P27', false, {'$P580–$P582'}, {}, 'P41', '20px')
if list then return mw.text.listToText(list, _br_, _br_), 'P27', q else return nil 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 = {}
local female = wdu_b.isFemale(entity)
if ethnicityClaims then
for _,eachEthnicityClaim in pairs(ethnicityClaims) do
if wikidata.hasValueSnak(eachEthnicityClaim) then
local callFunction = function(objectId, female)
local returnValue = nil
if objectId then
local demonymClaims = wikidata.findClaimsForProperty(objectId, 'P1549')
for eachClaimIdx, eachClaim in pairs(demonymClaims) do
if wikidata.isClaimTrue(eachClaim) and wikidata.hasValueSnak(eachClaim) 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 )
or ( eachClaim.qualifiers['P21'] and eachClaim.qualifiers['P21'][1] and eachClaim.qualifiers['P21'][1].snaktype == 'value' and eachClaim.qualifiers['P21'][1].datavalue.value['numeric-id'] == 6581072 )
or (eachClaim.qualifiers['P518'] and eachClaim.qualifiers['P518'][1] and eachClaim.qualifiers['P518'][1].snaktype == 'value' and eachClaim.qualifiers['P518'][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
if female then callFunctionWithGender = function(object) return callFunction(object, true) end end
table.insert(retList, wikidata.findLinkToItemWithCallback(eachEthnicityClaim.mainsnak.datavalue.value['numeric-id'], false, nil, 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 nationality = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'nationalitate', 'nationality', 'naționalitate', 'Naționalitate'}, function() return nil end)
if not ethnicity and not citizenship and nationality then
processedArgs['label' .. tostring(labeldatacount)] = 'Naționalitate'
processedArgs['data' .. tostring(labeldatacount)] = nationality
labeldatacount = labeldatacount + 1
end
local religion = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'religie', 'religion', 'confesiune'}, function() return wikidata._getValueListWithSeparator({_br_, 'P140', q}), 'P140', q 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(q, 'P106')
local fem = wdu_b.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', q
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(q, 'P937', false, {'$P580', '$P582'}, {'–'})
if workLocations then return mw.text.listToText(workLocations, _br_, _br_), 'P937', q 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 spoken_langs = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'limbi_vorbite', 'limba_vorbita'}, function()
local spokenLangs = wikidata.findValueListWithQualifiersInBrackets(q, 'P1412', false, {'$P3831'}, {', '})
if spokenLangs then return mw.text.listToText(spokenLangs, _br_, _br_), 'P1412', q end
end)
if spoken_langs then
processedArgs['label' .. tostring(labeldatacount)] = 'Limbi vorbite'
processedArgs['data' .. tostring(labeldatacount)] = spoken_langs
labeldatacount = labeldatacount + 1
end
local net_worth = extractDedicatedArgFromInputArgs(retainedInputArgs, args, {'avere', 'net_worth'}, function()
return wikidata.findOneValue('P2218', q), 'P2218', q
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', q, 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.findRoLabel(q) or wikidata.findNativeOrEnglishLabel(q)
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', q)
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', class='skin-invert'}
crtLineIndex = crtLineIndex + 1
end
local onlinelinks = {}
local linkstopullfromwd = {'P2013', 'P2002', 'P2035', 'P2847', 'P345', 'P3265', 'P3579', 'P3435', 'P2003', 'P2471', 'P2397', 'P6634', 'P2572', 'P7085', 'P3789', 'P11245'}
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, q)
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