Modul:InfoboxRoyalty
From Wikipedia, the free encyclopedia
local getArgs = require('Modul:Arguments').getArgs local infoboxBio = require('Modul:InfoboxBiography') local TableTools = require('Modul:TableTools') local wikidata = require('Modul:Wikidata') local editAtWd = require('Modul:EditAtWikidata').displayMessage local StringUtils = require('Modul:StringUtils') local p = {} local argscnt = 1
local function addLabel(ibargs, label) ibargs['label' .. tostring(argscnt)] = label end local function addHeader(ibargs, header) ibargs['header' .. tostring(argscnt)] = header argscnt = argscnt + 1 end local function addData(ibargs, data) ibargs['data' .. tostring(argscnt)] = data argscnt = argscnt + 1 end
local function fromArray(args) local ibargs = {['culoare cadru'] = 'CCBBEE', ['culoare text'] = '000', aboveclass = 'regalitate', wikidata = 'y', doc = args['caller'] or 'Infocaseta Regalitate', default_title = 'Domnia' } local origargs = TableTools.shallowClone(args) local numberedargs = TableTools.numData(origargs, true) local unnumberedargs = nil if origargs['succesiune'] or origargs['domnie'] then unnumberedargs = { succesiune = origargs['succesiune'], domnie = origargs['domnie'], ['încoronare'] = origargs['încoronare'] or origargs['incoronare'], predecesor = origargs['predecesor'], succesor = origargs['succesor'], regent = origargs['regent'] } table.insert(numberedargs, 1, unnumberedargs) end
ibargs['subheader1'] = origargs['titlu'] ibargs['subheaderstyle'] = 'background-color:#dedede;'
ibargs['name'] = origargs['nume'] ibargs['image'] = origargs['image'] or origargs['imagine'] ibargs['image_size'] = origargs['image_size'] or origargs['mărime'] ibargs['caption'] = origargs['descriere'] ibargs['spouse'] = origargs['soț'] or origargs['casatorit cu'] or origargs['căsătorit cu'] ibargs['spouse-type'] = origargs['spouse-type'] ibargs['children'] = origargs['urmași'] ibargs['birth_name'] = origargs['nume complet'] ibargs['father'] = origargs['tată'] or origargs['tatal'] ibargs['mother'] = origargs['mamă'] or origargs['mama'] if ibargs['father'] or ibargs['mother'] then ibargs['parents'] = table.concat(TableTools.compressSparseArray({ibargs['father'], ibargs['mother']}), tostring(mw.html.create('br'))) end ibargs['siblings'] = origargs['frați'] ibargs['birth_date'] = origargs['data nașterii'] or origargs['data nasterii'] ibargs['death_date'] = origargs['data decesului'] or origargs['data mortii'] or origargs['data morții'] ibargs['birth_place'] = origargs['locul nașterii'] or origargs['locul nasterii'] ibargs['death_place'] = origargs['locul decesului'] or origargs['locul mortii'] or origargs['locul morții'] ibargs['burial_place'] = origargs['locul înmormântării'] or origargs['înmormântat'] ibargs['burial_date'] = origargs['data înmormântării'] ibargs['occupation'] = origargs['ocupație'] ibargs['religion'] = origargs['religie'] ibargs['signature'] = origargs['semnătură'] or origargs['semnatura']
local capitalizeTitlesInList = function(list) local capitalizedList = {} if list then for _,eachElement in ipairs(list) do table.insert(capitalizedList, StringUtils._capitalize({eachElement})) end end return capitalizedList end
local royalTitle = origargs['titluri'] or origargs['altetitulaturi'] or table.concat(capitalizeTitlesInList(wikidata.getTimestampedValueList(nil, 'P97')), tostring(mw.html.create('br')))
local royalFamily = origargs['casa'] or origargs['casa regala'] or origargs['casă regală'] or origargs['casa regală'] or table.concat(capitalizeTitlesInList(wikidata.getTimestampedValueList(nil, 'P53')), tostring(mw.html.create('br'))) local royalAnthem = origargs['imn regal'] or wikidata.findOneValue('P85') local heirApparent = origargs['moștenitor'] or origargs['mostenitor']
if royalTitle or royalFamily or royalAnthem then addHeader(ibargs, 'Apartenență nobiliară') if royalTitle then addLabel(ibargs, 'Titluri') addData(ibargs, royalTitle) end if royalFamily then addLabel(ibargs, 'Familie nobiliară') addData(ibargs, royalFamily) end if royalAnthem then addLabel(ibargs, 'Imn regal') addData(ibargs, royalAnthem) end if heirApparent then addLabel(ibargs, 'Moștenitor') addData(ibargs, heirApparent) end end
local fem = args['f'] or args['femeie'] or wikidata.isFemale()
if not numberedargs or #numberedargs == 0 then local wdPositionClaims = wikidata.findClaimsForProperty(nil, 'P39') or {} for _,eachClaim in ipairs(wdPositionClaims) do if eachClaim.mainsnak.snaktype == 'value' then local positionQid = eachClaim.mainsnak.datavalue.value['numeric-id'] local linktoPosition = wikidata.findLinkToItem('Q' .. tostring(positionQid), true, fem, false) .. ' ' .. editAtWd('P39') addHeader(ibargs, linktoPosition) local reignTimes = {} if eachClaim.qualifiers then if eachClaim.qualifiers['P580'] and eachClaim.qualifiers['P580'][1] then if eachClaim.qualifiers['P580'][1].snaktype == 'value' then table.insert(reignTimes, wikidata.printSnak(eachClaim.qualifiers['P580'][1])) elseif eachClaim.qualifiers['P580'][1].snaktype == 'unknownvalue' then table.insert(reignTimes, '?') end end if eachClaim.qualifiers['P582'] and eachClaim.qualifiers['P582'][1] then if eachClaim.qualifiers['P582'][1].snaktype == 'value' then table.insert(reignTimes, wikidata.printSnak(eachClaim.qualifiers['P582'][1])) elseif eachClaim.qualifiers['P582'][1].snaktype == 'unknownvalue' then table.insert(reignTimes, '?') end end if #reignTimes == 0 and eachClaim.qualifiers['P585'] and eachClaim.qualifiers['P585'][1] then if eachClaim.qualifiers['P585'].snaktype == 'value' then table.insert(reignTimes, wikidata.printSnak(eachClaim.qualifiers['P585'][1])) elseif eachClaim.qualifiers['P585'].snaktype == 'unknownvalue' then table.insert(reignTimes, '?') end end if #reignTimes > 0 then addLabel(ibargs, 'Domnie') addData(ibargs, table.concat(reignTimes, mw.text.decode(' – ', true))) end if eachClaim.qualifiers['P1365'] and eachClaim.qualifiers['P1365'][1] then addLabel(ibargs, 'Predecesor') if eachClaim.qualifiers['P1365'][1].snaktype == 'value' then addData(ibargs, wikidata.printSnak(eachClaim.qualifiers['P1365'][1])) elseif eachClaim.qualifiers['P1365'][1].snaktype == 'novalue' then addData(ibargs, 'nimeni') else addData(ibargs, '?') end end if eachClaim.qualifiers['P1366'] and eachClaim.qualifiers['P1366'][1] then addLabel(ibargs, 'Succesor') if eachClaim.qualifiers['P1366'][1].snaktype == 'value' then addData(ibargs, wikidata.printSnak(eachClaim.qualifiers['P1366'][1])) elseif eachClaim.qualifiers['P1366'][1].snaktype == 'novalue' then addData(ibargs, 'nimeni') else addData(ibargs, '?') end end end end end else if not numberedargs[1].succesiune then addHeader(ibargs, 'Domnie') end for _,eachReign in ipairs(numberedargs) do if eachReign.succesiune then addHeader(ibargs, eachReign.succesiune) end if eachReign.domnie then addLabel(ibargs, 'Domnie') addData(ibargs, eachReign.domnie) end if eachReign.domnie or eachReign.succesiune then if eachReign['încoronare'] then addLabel(ibargs, eachReign['cor-type'] or 'Încoronare') addData(ibargs, eachReign['încoronare']) end if eachReign.predecesor then addLabel(ibargs, eachReign['pred-type'] or 'Predecesor') addData(ibargs, eachReign.predecesor) end if eachReign.succesor then addLabel(ibargs, eachReign['suc-type'] or 'Succesor') addData(ibargs, eachReign.succesor) end if eachReign.regent then addLabel(ibargs, eachReign['reg-type'] or 'Regent') addData(ibargs, eachReign.regent) end end
end end
return infoboxBio.displayInfoboxFromArgs(ibargs) end
local function fromFrame(frame) local args = getArgs(frame) return fromArray(args) end
p.fromFrame = fromFrame p.fromArray = fromArray return p