Modul:InfoboxFormerCountry
Acest modul implementează Format:Infocaseta Fostă țară
local p = {}
local wikidata = require('Modul:Wikidata')
local ib = require('Modul:Infobox')
local getArgs = require('Modul:Arguments').getArgs
local StringUtils = require('Modul:StringUtils')
local illWd = require('Modul:Ill-wd').fromArgs
local TableTools = require('Modul:TableTools')
local DateUtils = require('Modul:DateUtils')
local GregorianDate = require('Modul:GregorianDate')
local Formatnum = require('Modul:Formatnum')
local round = require('Modul:Matematică')._round
local function isClaimWithData(claim)
return claim and claim['type'] == 'statement' and claim.mainsnak and claim.mainsnak.snaktype == 'value'
end
local function listContains(haystack, needle)
for _,eachHay in ipairs(haystack) do
if eachHay == needle then return true end
end
return false
end
local function listContainsAny(haystack, needles)
for _,eachNeedle in ipairs(needles) do
if listContains(haystack, eachNeedle) then return true end
end
return false
end
local function removeWikiLinkSyntax(str)
if not str then return nil end
local ret = str
ret = mw.ustring.gsub(ret, '%[%[(.-)|?(.-)%]%]', function(linkName, linkLabel) return linkLabel end)
return ret
end
local function analyzeOtherCountries(args, argPrefix, wdId)
local others = {}
local othersLinks = {}
local othersImages = {}
local othersFlags = {}
local othersFlagsBorders = {}
othersLinks = TableTools.affixNums(args, argPrefix)
for otherIdx = 1,#othersLinks do
local crtOther = {}
crtOther.link = args[argPrefix .. othersLinks[otherIdx]]
crtOther.rawImage = args['imagine_' .. argPrefix .. othersLinks[otherIdx]]
crtOther.flag = args['steag_' .. argPrefix .. othersLinks[otherIdx]] or 'Blank.png'
crtOther.flagBorder = args['steag_' .. argPrefix .. othersLinks[otherIdx]] and 'yes' or args['border_' .. argPrefix .. othersLinks[otherIdx]] or 'yes'
table.insert(others, crtOther)
end
if #others == 0 then
local wdOtherIds = wikidata.getBestEntityIdsList(nil, wdId)
if wdOtherIds then for _,eachOtherId in ipairs(wdOtherIds) do
local crtOther = {}
local qOtherId = StringUtils._prependIfMissing({tostring(eachOtherId), 'Q'})
crtOther.link = mw.wikibase.sitelink(qOtherId) or ('d:' .. qOtherId)
crtOther.label = wikidata.findOneValueNoRef('P1813', qOtherId) or wikidata.findLabel(qOtherId)
local flagName = wikidata.findOneValueNoRef('P41', qOtherId)
crtOther.flag = flagName and mw.ustring.len(mw.text.trim(flagName)) > 0 and flagName or 'Blank.png'
crtOther.flagBorder = 'yes'
table.insert(others, crtOther)
end end
end
return others
end
local function appendOthersToTableCell(others, seeBelowDisplayString, othersDisplayString, thresholdBroken, linkLeft)
local out = ''
if others and #others > 0 then
if thresholdBroken then
out = '[[#before-after|' .. seeBelowDisplayString .. ']]'
else
for _,eachOther in ipairs(others) do
if linkLeft then out = out .. '[[' .. eachOther.link .. '|' .. othersDisplayString .. ']] ' end
if eachOther.flag == 'Blank.png' and eachOther.rawImage then
out = out .. eachOther.rawImage
else
out = out .. '[[Fișier:' .. eachOther.flag .. '|30px'
if eachOther.flagBorder ~= 'no' then out = out .. '|border' end
out = out .. '|link=' .. eachOther.link .. ']]'
end
if not linkLeft then out = out .. '[[' .. eachOther.link .. '|' .. othersDisplayString .. ']] ' end
end
end
end
return out
end
local function extractSymbolData(args, argSuffixes, imageP, defaultImageSize, articleP, defaultSymbolName)
local symbol = {}
for _,eachSuffix in ipairs(argSuffixes) do
symbol.image = symbol.image or args['imagine_' .. eachSuffix]
symbol.size = symbol.size or args[eachSuffix .. '_dimensiune']
symbol.link = symbol.link or args[eachSuffix]
symbol.border = symbol.border or args['bordură_' .. eachSuffix]
symbol.symbolType = symbol.symbolType or args['tip_' .. eachSuffix] or args[eachSuffix .. '_tip']
end
symbol.image = symbol.image or wikidata.findOneValueNoRef(imageP)
symbol.size = symbol.size or defaultImageSize
symbol.symbolType = symbol.symbolType or defaultSymbolName
if not symbol.link then
local symbolWdIds = wikidata.getBestEntityIdsList(nil, articleP)
if symbolWdIds and #symbolWdIds > 0 then
symbol.link = mw.wikibase.sitelink(StringUtils._prependIfMissing({tostring(symbolWdIds[1]), 'Q'})) or (':d:Q' .. tostring(symbolWdIds[1]))
end
end
return symbol
end
local function extractLocationMapData(args, paramName, paramNameSize, paramNameCaption, wdProp)
local locationMap = nil
if args[paramName] then
locationMap = {}
locationMap.mapImage = args[paramName]
locationMap.size = args[paramNameSize] or '300px'
locationMap.caption = args[paramNameCaption] or 'Localizare'
elseif wdProp then
local wdLocationMaps = wikidata.findBestClaimsForProperty(q, wdProp)
if wdLocationMaps and #wdLocationMaps > 0 and isClaimWithData(wdLocationMaps[1]) then
locationMap = {}
locationMap.mapImage = wdLocationMaps[1].mainsnak.datavalue.value
locationMap.size = '300px'
if wdLocationMaps[1].qualifiers and wdLocationMaps[1].qualifiers['P2096'] then
for _,eachLegendQualifier in ipairs(wdLocationMaps[1].qualifiers['P2096']) do
if eachLegendQualifier.snaktype == 'value' and eachLegendQualifier.datavalue.value.language == 'ro' then
locationMap.caption = eachLegendQualifier.datavalue.value.text
end
end
end
locationMap.caption = locationMap.caption or 'Localizare'
end
end
return locationMap
end
local function createEventFromArgs(args, evtNameArg, evtDateArg, evtYearArg)
if not args[evtNameArg] then return nil end
local evt = {}
evt.event = args[evtNameArg]
local dateFromArg = nil
if StringUtils._endsWith({removeWikiLinkSyntax(args[evtDateArg]), removeWikiLinkSyntax(args[evtYearArg])}) then
dateFromArg = removeWikiLinkSyntax(args[evtDateArg])
else
dateFromArg = removeWikiLinkSyntax(mw.text.trim(table.concat({args[evtDateArg] or '', args[evtYearArg] or ''}, ' ')))
end
if dateFromArg and mw.ustring.len(dateFromArg) > 0 then
if StringUtils._startsWith({dateFromArg, '<time'}) then
evt.displayedDate = dateFromArg
end
evt.date = DateUtils.parseDate(dateFromArg)
end
return evt
end
p.fromArgs = function(countryName, names, officialLanguages, categories, statutText, predecessors, successors, startDate, endDate, lifeSpan, coA, flag,
motto, anthem, locationMaps, capitals, religion, leadership, history, stats, economics, countryToday, notes)
local ibArgs = {}
ibArgs['culoare cadru'] = '#F9F9F9'
ibArgs.antet = 'blank'
ibArgs.title = countryName
ibArgs.doc = 'Infocaseta Fostă țară'
ibArgs.wikidata = 'y'
ibArgs.subheaderstyle = 'line-height:1.2em; font-size:135%'
local dataIndex = 1
local idx = 1
for _,eachName in ipairs(names) do
ibArgs['subheader' .. tostring(idx)] = eachName
idx = idx + 1
end
if statutText and mw.ustring.len(mw.text.trim(statutText)) > 0 then
ibArgs['subheader' .. tostring(idx)] = "— '''" .. statutText .. "''' —"
idx = idx + 1
end
local predDisplayString = tostring(mw.html.create('span'):css('font-size', '300%'):wikitext('←'):allDone())
local succDisplayString = tostring(mw.html.create('span'):css('font-size', '300%'):wikitext('→'):allDone())
if (successors and #successors > 0) or (predecessors and #predecessors > 0) or startDate or endDate or lifeSpan then
local seeBelowDisplayString = tostring(mw.html.create('span'):css('font-size', '300%'):wikitext('↓'):allDone())
local predSuccTable = mw.html.create('table'):attr('width', '100%'):css('text-align', 'center'):css('margin', '0 auto'):css('background', 'transparent')
local predSuccTableRow = predSuccTable:tag('tr')
local predTableCell = predSuccTableRow:tag('td'):attr('width', '50px'):css('vertical-align', 'middle'):css('line-height', '105%'):css('font-size', '30%'):css('border', '0')
predTableCell:wikitext(appendOthersToTableCell(predecessors, seeBelowDisplayString, predDisplayString, successors and #successors > 5 or predecessors and #predecessors > 5, true))
local lifeSpanTableCell = predSuccTableRow:tag('td'):cssText('vertical-align:middle; text-align:center; font-size:115%; border:0')
if not endDate and not lifeSpan then
lifeSpanTableCell:wikitext("'''Durată de existență?'''")
else
lifeSpanTableCell:wikitext(lifeSpan
or (startDate and endDate and startDate.precision == endDate.precision and startDate.year == endDate.year) and DateUtils.formatDate(endDate, link)
or ((startDate and (DateUtils.formatDate(startDate, true)
.. ' ') or '') .. '– '
.. DateUtils.formatDate(endDate, true)))
end
local succTableCell = predSuccTableRow:tag('td'):attr('width', '50px'):css('vertical-align', 'middle'):css('line-height', '105%'):css('font-size', '30%'):css('border', '0'):css('text-align', 'left')
succTableCell:wikitext(appendOthersToTableCell(successors, seeBelowDisplayString, succDisplayString, successors and #successors > 5 or predecessors and #predecessors > 5, false))
ibArgs['data' .. tostring(dataIndex)] = tostring(predSuccTable)
dataIndex = dataIndex + 1
end
if flag and flag.image and coA and coA.image then
local symbolsTable = mw.html.create('table'):attr('width', '100%'):cssText('text-align:center; margin:0 auto; background:none;')
local symbolsTableRow = symbolsTable:tag('tr')
local flagCell = symbolsTableRow:tag('td'):attr('align', 'center'):cssText('border:0; vertical-align:middle;')
flagCell:wikitext('[[Fișier:', flag.image, '|', flag.size, flag.border ~= 'no' and '|border' or '', '|Drapel]]')
local coACell = symbolsTableRow:tag('td'):attr('align', 'center'):cssText('border:0; vertical-align:middle;')
coACell:wikitext('[[Fișier:', coA.image, '|', coA.size, '|Stemă]]')
local symbolsTableRow2 = symbolsTable:tag('tr'):css('font-size', '95%')
local flagSubCell = symbolsTableRow2:tag('td'):css('border', '0'):css('text-align', 'center')
if flag.link then flagSubCell:wikitext('[[', flag.link, '|', flag.symbolType, ']]') else flagSubCell:wikitext(flag.symbolType) end
local coASubCell = symbolsTableRow2:tag('td'):css('border', '0'):css('text-align', 'center')
if coA.link then coASubCell:wikitext('[[', coA.link, '|', coA.symbolType, ']]') else coASubCell:wikitext(coA.symbolType) end
ibArgs['data' .. tostring(dataIndex)] = tostring(symbolsTable)
dataIndex = dataIndex + 1
elseif flag and flag.image or coA and coA.image then
local oneSymbol = flag and flag.image and flag or coA and coA.image and coA
local oneSymbolDescr = flag and flag.image and 'Drapel' or coA and coA.image and 'Stemă'
local symbolsTable = mw.html.create('table'):attr('width', '100%'):cssText('text-align:center; margin:0 auto; background:none;')
local symbolsTableRow = symbolsTable:tag('tr')
local symbolCell = symbolsTableRow:tag('td'):attr('align', 'center'):cssText('border:0; vertical-align:middle;')
symbolCell:wikitext('[[Fișier:', oneSymbol.image, '|', oneSymbol.size, oneSymbol.border ~= 'no' and '|border' or '', '|', oneSymbolDescr, ']]')
local symbolsTableRow2 = symbolsTable:tag('tr'):css('font-size', '95%')
local symbolSubCell = symbolsTableRow2:tag('td'):css('border', '0'):css('text-align', 'center')
if oneSymbol.link then symbolSubCell:wikitext('[[', oneSymbol.link, '|', oneSymbol.symbolType or oneSymbolDescr, ']]') else symbolSubCell:wikitext(oneSymbol.symbolType or oneSymbolDescr) end
ibArgs['data' .. tostring(dataIndex)] = tostring(symbolsTable)
dataIndex = dataIndex + 1
end
if motto then
ibArgs['header' .. tostring(dataIndex)] = '[[Deviză|Deviză națională]]'
dataIndex = dataIndex + 1
ibArgs['data' .. tostring(dataIndex)] = motto
dataIndex = dataIndex + 1
end
if anthem and mw.ustring.len(mw.text.trim(anthem)) > 0 then
ibArgs['header' .. tostring(dataIndex)] = '[[Imn național]]'
dataIndex = dataIndex + 1
ibArgs['data' .. tostring(dataIndex)] = anthem
dataIndex = dataIndex + 1
end
if locationMaps and #locationMaps > 0 then
for _,eachLocationMap in ipairs(locationMaps) do
local captionDiv = mw.html.create('div'):cssText('padding-top:0.5em;line-height:1.25em;font-size:90%;'):wikitext(eachLocationMap.caption)
ibArgs['data' .. tostring(dataIndex)] = '[[Fișier:' .. eachLocationMap.mapImage .. '|' .. eachLocationMap.size .. '|center|' .. (eachLocationMap.caption or '') .. ']]' .. tostring(captionDiv)
dataIndex = dataIndex + 1
end
end
if capitals and capitals.official then
ibArgs['label' .. tostring(dataIndex)] = '[[Listă a fostelor capitale naționale|Capitală]]'
ibArgs['data' .. tostring(dataIndex)] = capitals.official
dataIndex = dataIndex + 1
end
if capitals and capitals.exile then
ibArgs['label' .. tostring(dataIndex)] = 'Capitală în exil'
ibArgs['data' .. tostring(dataIndex)] = capitals.exile
dataIndex = dataIndex + 1
end
if officialLanguages and #officialLanguages > 0 then
ibArgs['label' .. tostring(dataIndex)] = 'Limb' .. (#officialLanguages == 1 and 'ă' or 'i')
ibArgs['data' .. tostring(dataIndex)] = table.concat(officialLanguages, tostring(mw.html.create('br')))
dataIndex = dataIndex + 1
end
if religion then
ibArgs['label' .. tostring(dataIndex)] = '[[Religie de stat|Religie]]'
ibArgs['data' .. tostring(dataIndex)] = religion
dataIndex = dataIndex + 1
end
if leadership and TableTools.size(leadership) > 0 then
ibArgs['header' .. tostring(dataIndex)] = 'Guvernare'
dataIndex = dataIndex + 1
if leadership.form then
ibArgs['label' .. tostring(dataIndex)] = '[[Formă de guvernare]]'
ibArgs['data' .. tostring(dataIndex)] = leadership.form
dataIndex = dataIndex + 1
end
if leadership.leaders and #(leadership.leaders) > 0 then
ibArgs['label' .. tostring(dataIndex)] = leadership.position or 'Conducător'
ibArgs['data' .. tostring(dataIndex)] = ' '
dataIndex = dataIndex + 1
for _,eachLeaderInList in ipairs(leadership.leaders) do
if eachLeaderInList.years then ibArgs['label' .. tostring(dataIndex)] = ' - ' .. eachLeaderInList.years end
if StringUtils._startsWithAny({eachLeaderInList.link, 'd:', ':d:'}) or mw.title.new(eachLeaderInList.link, 0) then
ibArgs['data' .. tostring(dataIndex)] = '[[' .. eachLeaderInList.link .. ((eachLeaderInList.label and eachLeaderInList.label ~= eachLeaderInList.link) and ('|' .. eachLeaderInList.label) or '') .. ']]'
else
ibArgs['data' .. tostring(dataIndex)] = eachLeaderInList.link
end
ibArgs['lblstyle' .. tostring(dataIndex)] = 'font-weight: normal;'
dataIndex = dataIndex + 1
end
end
if leadership.reps and #(leadership.reps) > 0 then
ibArgs['label' .. tostring(dataIndex)] = leadership.positionRep or 'Guvernator'
ibArgs['data' .. tostring(dataIndex)] = ' '
dataIndex = dataIndex + 1
for _,eachLeaderInList in ipairs(leadership.reps) do
if eachLeaderInList.years then ibArgs['label' .. tostring(dataIndex)] = ' - ' .. eachLeaderInList.years end
ibArgs['data' .. tostring(dataIndex)] = eachLeaderInList.link
ibArgs['lblstyle' .. tostring(dataIndex)] = 'font-weight: normal;'
dataIndex = dataIndex + 1
end
end
if leadership.aids and #(leadership.aids) > 0 then
ibArgs['label' .. tostring(dataIndex)] = leadership.positionAid or 'Prim-ministru'
ibArgs['data' .. tostring(dataIndex)] = ' '
dataIndex = dataIndex + 1
for _,eachLeaderInList in ipairs(leadership.aids) do
if eachLeaderInList.years then ibArgs['label' .. tostring(dataIndex)] = ' - ' .. eachLeaderInList.years end
ibArgs['data' .. tostring(dataIndex)] = eachLeaderInList.link
ibArgs['lblstyle' .. tostring(dataIndex)] = 'font-weight: normal;'
dataIndex = dataIndex + 1
end
end
if leadership.legislative then
ibArgs['label' .. tostring(dataIndex)] = '[[Legislativ]]'
ibArgs['data' .. tostring(dataIndex)] = leadership.legislative
dataIndex = dataIndex + 1
if leadership.chambers and #(leadership.chambers) > 0 then
for _,eachChamberInList in ipairs(leadership.chambers) do
ibArgs['label' .. tostring(dataIndex)] = ' - ' .. eachChamberInList.chamberType
ibArgs['data' .. tostring(dataIndex)] = eachChamberInList.link
ibArgs['lblstyle' .. tostring(dataIndex)] = 'font-weight: normal;'
dataIndex = dataIndex + 1
end
end
end
end
if history and TableTools.size(history) > 0 then
ibArgs['header' .. tostring(dataIndex)] = 'Istorie'
dataIndex = dataIndex + 1
if history.era then
ibArgs['label' .. tostring(dataIndex)] = '[[Epoca istorică]]'
ibArgs['data' .. tostring(dataIndex)] = history.era
dataIndex = dataIndex + 1
end
if history.before then
ibArgs['label' .. tostring(dataIndex)] = history.before.event
ibArgs['data' .. tostring(dataIndex)] = history.before.date and GregorianDate.displayDualDateIfInInterval(history.before.date, true) or ' '
ibArgs['lblstyle' .. tostring(dataIndex)] = 'font-weight: normal;'
dataIndex = dataIndex + 1
end
if history.moments and #(history.moments) > 0 then
for _,eachMoment in ipairs(history.moments) do
ibArgs['label' .. tostring(dataIndex)] = eachMoment.event
ibArgs['data' .. tostring(dataIndex)] = eachMoment.displayedDate or eachMoment.date and GregorianDate.displayDualDateIfInInterval(eachMoment.date, true) or ' '
ibArgs['lblstyle' .. tostring(dataIndex)] = 'font-weight: normal;'
dataIndex = dataIndex + 1
end
end
if history.after then
ibArgs['label' .. tostring(dataIndex)] = history.after.event
ibArgs['data' .. tostring(dataIndex)] = history.after.date and GregorianDate.displayDualDateIfInInterval(history.after.date, true) or ' '
ibArgs['lblstyle' .. tostring(dataIndex)] = 'font-weight: normal;'
dataIndex = dataIndex + 1
end
end
if stats and TableTools.size(stats) > 0 then
ibArgs['header' .. tostring(dataIndex)] = 'Date statistice'
dataIndex = dataIndex + 1
if stats.area and #(stats.area) > 0 then
ibArgs['label' .. tostring(dataIndex)] = '[[Listă a țărilor după suprafață|Suprafață]]'
ibArgs['data' .. tostring(dataIndex)] = ' '
dataIndex = dataIndex + 1
for _,eachArea in ipairs(stats.area) do
ibArgs['label' .. tostring(dataIndex)] = ' - ' .. tostring(eachArea.year or '')
ibArgs['data' .. tostring(dataIndex)] = mw.language.getContentLanguage():formatNum(eachArea.area) .. ' km²'
ibArgs['lblstyle' .. tostring(dataIndex)] = 'font-weight: normal;'
dataIndex = dataIndex + 1
end
end
if stats.pop and #(stats.pop) > 0 then
ibArgs['label' .. tostring(dataIndex)] = '[[Listă a țărilor după populație|Populație]]'
ibArgs['data' .. tostring(dataIndex)] = ' '
dataIndex = dataIndex + 1
for _,eachPop in ipairs(stats.pop) do
ibArgs['label' .. tostring(dataIndex)] = ' - ' .. (eachPop.year or 'est.')
ibArgs['data' .. tostring(dataIndex)] = mw.language.getContentLanguage():formatNum(eachPop.pop) .. ' loc.'
ibArgs['lblstyle' .. tostring(dataIndex)] = 'font-weight: normal;'
dataIndex = dataIndex + 1
if #(stats.index[eachPop.index]) > 1 then
for _,eachDataAtIndex in ipairs(stats.index[eachPop.index]) do
if eachDataAtIndex.area then
ibArgs['label' .. tostring(dataIndex)] = ' [[Densitatea populației|Densitate]]'
ibArgs['data' .. tostring(dataIndex)] = mw.language.getContentLanguage():formatNum(round(eachPop.pop / eachDataAtIndex.area, 1)) .. ' loc./km²'
ibArgs['lblstyle' .. tostring(dataIndex)] = 'font-weight: normal;'
dataIndex = dataIndex + 1
end
end
end
end
end
end
if economics and TableTools.size(economics) > 0 then
ibArgs['header' .. tostring(dataIndex)] = 'Economie'
dataIndex = dataIndex + 1
if economics.currency then
ibArgs['label' .. tostring(dataIndex)] = '[[Monedă]]'
ibArgs['data' .. tostring(dataIndex)] = economics.currency
dataIndex = dataIndex + 1
end
end
if #predecessors > 5 or #successors > 5 then
local predSuccTable = mw.html.create('table'):attr('width', '95%'):css('text-align', 'center'):css('margin', '0 auto'):css('background', 'transparent')
local predSuccTableRow = predSuccTable:tag('tr')
local predTableCell = predSuccTableRow:tag('td'):attr('align', 'center'):css('padding-bottom', '0'):css('border', '0')
predTableCell:wikitext((#predecessors > 0) and "'''Precedat de'''" or '')
local succTableCell = predSuccTableRow:tag('td'):attr('align', 'center'):css('padding-bottom', '0'):css('border', '0')
succTableCell:wikitext((#successors > 0) and "'''Succedat de'''" or '')
local mainTableRow = predSuccTable:tag('tr')
local mainTablePredCell = mainTableRow:tag('td'):attr('valign', 'top'):attr('align', 'center'):css('border', '0')
mainTablePredCell:tag('div'):attr('id', 'before-after')
if #predecessors > 0 then
local predTable = mainTablePredCell:tag('table'):attr('width', '100%'):cssText('background: transparent; text-align:center; margin:0 auto; border:0;')
for _,eachPred in ipairs(predecessors) do
local crtRow = predTable:tag('tr')
local crtPredFlagCell = crtRow:tag('td'):css('border', '0'):css('padding', '0'):css('vertical-align', 'middle')
if not eachPred.flag and eachPred.rawImage then crtPredFlagCell:wikitext(eachPred.rawImage)
elseif eachPred.flag then crtPredFlagCell:wikitext('[[Fișier:', eachPred.flag, '|20px', eachPred.flagBorder == 'no' and '' or '|border', ']]') end
local crtPredNameCell = crtRow:tag('td'):css('border', '0'):css('padding', '0'):css('vertical-align', 'middle'):css('text-align', 'left')
crtPredNameCell:wikitext(' [[', eachPred.link, ((eachPred.label and eachPred.label ~= eachPred.link) and ('|' .. eachPred.label) or ''), ']]')
end
end
local mainTableSuccCell = mainTableRow:tag('td'):attr('valign', 'top'):attr('align', 'center'):css('border', '0')
if #successors > 0 then
local succTable = mainTableSuccCell:tag('table'):attr('width', '100%'):cssText('background: transparent; text-align:center; margin:0 auto; border:0;')
for _,eachSucc in ipairs(successors) do
local crtRow = succTable:tag('tr')
local crtSuccNameCell = crtRow:tag('td'):css('border', '0'):css('padding', '0'):css('vertical-align', 'middle'):css('text-align', 'right')
crtSuccNameCell:wikitext(' [[', eachSucc.link, ((eachSucc.label and eachSucc.label ~= eachSucc.link) and ('|' .. eachSucc.label) or ''), ']]')
local crtSuccFlagCell = crtRow:tag('td'):css('border', '0'):css('padding', '0'):css('vertical-align', 'middle')
if not eachSucc.flag and eachSucc.rawImage then crtSuccFlagCell:wikitext(eachPred.rawImage)
elseif eachSucc.flag then crtSuccFlagCell:wikitext('[[Fișier:', eachSucc.flag, '|20px', eachSucc.flagBorder == 'no' and '' or '|border', ']]') end
end
end
ibArgs['data' .. tostring(dataIndex)] = tostring(predSuccTable)
dataIndex = dataIndex + 1
end
if StringUtils.emptyToNil({countryToday}) then
ibArgs['header' .. tostring(dataIndex)] = 'În prezent parte din'
dataIndex = dataIndex + 1
ibArgs['data' .. tostring(dataIndex)] = countryToday
dataIndex = dataIndex + 1
end
if notes then
ibArgs['data' .. tostring(dataIndex)] = notes
ibArgs['style' .. tostring(dataIndex)] = 'font-size: 85%;'
dataIndex = dataIndex + 1
end
local ibox = ib.infobox(ibArgs)
if categories then for _,eachCat in ipairs(categories) do
ibox = ibox .. '\n[[Category:' .. eachCat .. ']]'
end end
return ibox
end
p.fromArray = function(args)
local countryName = wikidata.findLabel()
local names = {}
local categories = {}
for _,eachName in ipairs({'nume_comun', 'nume_oficial_lung', 'nume_nativ'}) do
if args[eachName] ~= nil and args[eachName] ~= countryName then
table.insert(names, args[eachName])
end
end
local officialLanguageClaims = wikidata.findBestClaimsForProperty(nil, 'P37')
local officialLanguages = {}
if not args['nume_nativ'] and officialLanguageClaims then
for _,eachLangClaim in ipairs(officialLanguageClaims) do
if isClaimWithData(eachLangClaim) then
local languageItemId = eachLangClaim.mainsnak.datavalue.value['numeric-id']
local languageItemIdStr = StringUtils.prependIfMissing({tostring(languageItemId), 'Q'})
local languageEntity = mw.wikibase.getEntityObject(languageItemIdStr)
local langWikiCode = wikidata.findOneValueNoRef('P424', languageItemIdStr)
if languageEntity and langWikiCode then
local nameInNativeLang = mw.wikibase.getEntityObject():getLabel(langWikiCode)
if nameInNativeLang then table.insert(names, nameInNativeLang) end
end
table.insert(officialLanguages, illWd(languageItemIdStr))
end
end
end
if #officialLanguages < 1 and args['limbi_comune'] then
table.insert(officialLanguages, args['limbi_comune'])
end
local regionMissing = true
if args['continent'] then
if args['regiune'] then
regionMissing = false
if mw.ustring.lower(args['regiune']) == 'italia' then table.insert(categories, 'Foste state din Peninsula Italiană')
elseif mw.ustring.lower(args['regiune']) == 'balcani' then table.insert(categories, 'Foste state din Balcani')
elseif mw.ustring.lower(args['regiune']) == 'caucaz' then table.insert(categories, 'Foste state din Caucaz')
elseif mw.ustring.lower(args['regiune']) == 'regatul unit' then table.insert(categories, 'Foste state din istoria Regatului Unit')
elseif mw.ustring.lower(args['regiune']) == 'țările de jos' then table.insert(categories, 'Foste state din istoria Țărilor de Jos')
elseif mw.ustring.lower(args['regiune']) == 'china' then table.insert(categories, 'Foste state din istoria Chinei')
elseif mw.ustring.lower(args['regiune']) == 'japonia' then table.insert(categories, 'Foste state din istoria Japoniei')
elseif mw.ustring.lower(args['regiune']) == 'coreea' then table.insert(categories, 'Foste state din istoria Coreei')
else regionMissing = true
end
end
if regionMissing then
if args['country'] or args['țară'] then
if mw.ustring.lower(args['country'] or args['țară']) == 'china' then table.insert(categories, 'Foste state din istoria Chinei')
elseif mw.ustring.lower(args['country'] or args['țară']) == 'japonia' then table.insert(categories, 'Foste state din istoria Japoniei')
elseif mw.ustring.lower(args['country'] or args['țară']) == 'coreea' then table.insert(categories, 'Foste state din istoria Coreei')
elseif mw.ustring.lower(args['country'] or args['țară']) == 'malaezia' then table.insert(categories, 'Foste state din istoria Malaeziei')
end
else
if mw.ustring.lower(args['continent']) == 'europa' then table.insert(categories, 'Foste state din Europa')
elseif mw.ustring.lower(args['continent']) == 'asia' then table.insert(categories, 'Foste state din Asia')
elseif mw.ustring.lower(args['continent']) == 'oceania' then table.insert(categories, 'Foste state din Oceania')
elseif mw.ustring.lower(args['continent']) == 'africa' then table.insert(categories, 'Foste state din Africa')
elseif mw.ustring.lower(args['continent']) == 'america de sud' then table.insert(categories, 'Foste state din America de Sud')
elseif mw.ustring.lower(args['continent']) == 'america de nord' then table.insert(categories, 'Foste state din America de Nord')
elseif mw.ustring.lower(args['continent']) == 'eurasia' then table.insert(categories, 'Foste state din Europa'); table.insert(categories, 'Foste state din Asia')
elseif mw.ustring.lower(args['continent']) == 'afroeurasia' then table.insert(categories, 'Foste state din Europa'); table.insert(categories, 'Foste state din Asia'); table.insert(categories, 'Foste state din Africa')
end
end
end
end
local continentNames = {}
if #categories < 1 then
local wdContinents = wikidata.getBestEntityIdsList(nil, 'P30')
if wdContinents then
for _,eachContinent in ipairs(wdContinents) do
if eachContinent == 5401 or eachContinent == 27527 then
table.insert(continentNames, 'Europa')
table.insert(continentNames, 'Asia')
if eachContinent == 27527 then table.insert(continentNames, 'Africa') end
else
local wdContinentName = wikidata.findLabel(StringUtils._prependIfMissing({tostring(eachContinent), 'Q'}), 'ro')
table.insert(continentNames, wdContinentName)
end
end
end
for _,eachContinentName in ipairs(continentNames) do
table.insert(categories, 'Foste state din ' .. eachContinentName)
end
end
local statutText = nil
if args['statut'] then
if mw.ustring.lower(args['statut']) == 'regat al commonwealthului națiunilor' then table.insert(categories, 'Foste Regate ale Commonwealthului Națiunilor')
elseif mw.ustring.lower(args['statut']) == 'imperiu' then table.insert(categories, 'Foste imperii'); statutText = args['statut_text'] or StringUtils._capitalize({mw.ustring.lower(args['statut'])})
elseif mw.ustring.lower(args['statut']) == 'regat al commonwealthului națiunilor' then table.insert(categories, 'Foste imperii')
elseif mw.ustring.lower(args['statut']) == 'federație' or mw.ustring.lower(args['statut']) == 'federal' then table.insert(categories, 'Foste federații'); statutText = args['statut_text'] or StringUtils._capitalize({mw.ustring.lower(args['statut'])})
elseif mw.ustring.lower(args['statut']) == 'confederație' then table.insert(categories, 'Foste confederații'); statutText = args['statut_text'] or StringUtils._capitalize({mw.ustring.lower(args['statut'])})
elseif mw.ustring.lower(args['statut']) == 'uniune' or mw.ustring.lower(args['statut']) == 'uniune statală' then table.insert(categories, 'Foste uniuni statale'); statutText = args['statut_text'] or StringUtils._capitalize({mw.ustring.lower(args['statut'])})
elseif mw.ustring.lower(args['statut']) == 'uniune' or mw.ustring.lower(args['statut']) == 'uniune personală' then table.insert(categories, 'Foste uniuni personale'); statutText = args['statut_text'] or StringUtils._capitalize({mw.ustring.lower(args['statut'])})
elseif mw.ustring.lower(args['statut']) == 'nerecunoscut' or mw.ustring.lower(args['statut']) == 'stat nerecunoscut' then table.insert(categories, 'Foste state nerecunoscute')
elseif mw.ustring.lower(args['statut']) == 'oraș stat' or mw.ustring.lower(args['statut']) == 'oraș-stat' or mw.ustring.lower(args['statut']) == 'oraș' then
if args['imperiu'] == 'Sfântul Imperiu Roman' or args['imperiu'] == 'SIR' then
table.insert(categories, 'Țări din Sfântul Imperiu Roman')
table.insert(categories, 'Orașe imperiale libere')
statutText = '[[Oraș imperial liber]] al [[Sfântul Imperiu Roman|Sfântului Imperiu Roman]]'
else
statutText = 'Oraș-stat' .. (args['imperiu'] and (' din ' .. args['imperiu']) or '')
end
table.insert(categories, 'Foste orașe-stat')
elseif mw.ustring.lower(args['statut']) == 'gubernie' then table.insert(categories, 'Guberniile Imperiului Rus'); statutText = args['statut_text'] or StringUtils._capitalize({mw.ustring.lower(args['statut'])})
elseif mw.ustring.lower(args['statut']) == 'domeniu al commonwealthului' then table.insert(categories, 'Foste domenii ale Commonwealthului'); statutText = illWd('Q202686')
elseif mw.ustring.lower(args['statut']) == 'mandat al ligii națiunilor' or mw.ustring.lower(args['statut']) == 'liga națiunilor' or mw.ustring.lower(args['statut']) == 'mandat' then
table.insert(categories, 'Mandate ale Ligii Națiunilor')
if args['imperiu'] and (mw.ustring.lower(args['imperiu']) == 'regatul unit' or mw.ustring.lower(args['imperiu']) == 'uk') then
statutText = '[[Mandat al Ligii Națiunilor|Mandat]] al [[Regatul Unit|Regatului Unit]]'
else
statutText = illWd('Q426759')
end
elseif mw.ustring.lower(args['statut']) == 'statut special liga națiunilor' then table.insert(categories, 'Teritorii cu statut special ale Ligii Națiunilor')
elseif mw.ustring.lower(args['statut']) == 'teritoriu sub tutela națiunilor unite' or mw.ustring.lower(args['statut']) == 'teritoriu sub tutela onu' or mw.ustring.lower(args['statut']) == 'teritoriu sub tutelă' then
table.insert(categories, 'Teritorii sub tutela Națiunilor Unite')
if args['imperiu'] then
if mw.ustring.lower(args['imperiu']) == 'regatul unit' then statutText = illWd('Q985073', 'Teritoriu sub tutela') .. ' [[Regatul Unit|Regatului Unit]]'
elseif mw.ustring.lower(args['imperiu']) == 'statele unite' then statutText = illWd('Q985073', 'Teritoriu sub tutela') .. ' [[Statele Unite ale Americii|Statelor Unite]]'
else statutText = illWd('Q985073')
end
end
elseif mw.ustring.lower(args['statut']) == 'protectorat' then
table.insert(categories, 'Foste protectorate')
if args['imperiu'] then
if mw.ustring.lower(args['imperiu']) == 'regatul unit' then statutText = 'Protectorat' .. ' al [[Regatul Unit|Regatului Unit]]'
elseif mw.ustring.lower(args['imperiu']) == 'statele unite' then statutText = 'Protectorat' .. ' al [[Statele Unite ale Americii|Statelor Unite]]'
else statutText = 'Protectorat al cui?'
end
end
elseif mw.ustring.lower(args['statut']) == 'stat clientelar' or mw.ustring.lower(args['statut']) == 'marionetă' or mw.ustring.lower(args['statut']) == 'stat-marionetă' or mw.ustring.lower(args['statut']) == 'stat marionetă' then
if args['imperiu'] and (mw.ustring.lower(args['imperiu']) == 'franța' or mw.ustring.lower(args['imperiu']) == 'franței' or mw.ustring.lower(args['imperiu']) == 'primul imperiu francez') then
table.insert(categories, 'Stat clientelar al Franței revoluționare și napoleoniene')
statutText = illWd('Q472538')
else
table.insert(categories, 'Foste state clientelare')
statutText = illWd('Q208164') .. (args['imperiu'] and (' dependent de ' .. args['imperiu']) or '')
end
elseif args['statut'] and (mw.ustring.lower(args['statut']) == 'satelit' or mw.ustring.lower(args['statut']) == 'stat satelit' or mw.ustring.lower(args['statut']) == 'stat-satelit') then
table.insert(categories, 'State satelit ale URSS')
statutText = 'Stat satelit al [[Uniunea Sovietică|Uniunii Sovietice]]'
elseif args['statut'] and mw.ustring.lower(args['statut']) == 'colonie' then
if args['imperiu'] and (mw.ustring.lower(args['imperiu']) == 'franța' or mw.ustring.lower(args['imperiu']) == 'franței' or mw.ustring.lower(args['imperiu']) == 'primul imperiu francez' or mw.ustring.lower(args['imperiu']) == 'imperiul francez') then table.insert(categories, 'Foste colonii franceze'); statutText = '[[Imperiul colonial francez|Colonie franceză]]'
elseif mw.ustring.lower(args['imperiu']) == 'regatul unit' or mw.ustring.lower(args['imperiu']) == 'regatului unit' or mw.ustring.lower(args['imperiu']) == 'uk' or mw.ustring.lower(args['imperiu']) == 'imperiul britanic' or mw.ustring.lower(args['imperiu']) == 'imperiu britanic' or mw.ustring.lower(args['imperiu']) == 'anglia' then table.insert(categories, 'Foste colonii britanice'); statutText = '[[Imperiul Britanic|Colonie britanică]]'
elseif mw.ustring.lower(args['imperiu']) == 'țările de jos' or mw.ustring.lower(args['imperiu']) == 'olanda' or mw.ustring.lower(args['imperiu']) == 'nl' then table.insert(categories, 'Foste colonii neerlandeze'); statutText = '[[Imperiul Neerlandez|Colonie neerlandeză]]'
elseif mw.ustring.lower(args['imperiu']) == 'belgia' then table.insert(categories, 'Foste colonii belgiene'); statutText = '[[Imperiul colonial belgian| Colonie belgiană]]'
elseif mw.ustring.lower(args['imperiu']) == 'spania' or mw.ustring.lower(args['imperiu']) == 'imperiul spaniol' then table.insert(categories, 'Foste colonii spaniole'); statutText = '[[Imperiul Spaniol|Colonie spaniolă]]'
elseif mw.ustring.lower(args['imperiu']) == 'portugalia' then table.insert(categories, 'Foste colonii portugheze'); statutText = '[[Imperiul Portughez|Colonie portugheză]]'
elseif mw.ustring.lower(args['imperiu']) == 'germania' or mw.ustring.lower(args['imperiu']) == 'imperiul german' then table.insert(categories, 'Foste colonii germane'); statutText = illWd('Q329618', 'Colonie germană')
elseif mw.ustring.lower(args['imperiu']) == 'italia' then table.insert(categories, 'Foste colonii italiene'); statutText = '[[Imperiul Italian|Colonie italiană]]'
elseif mw.ustring.lower(args['imperiu']) == 'suedia' then table.insert(categories, 'Foste colonii suedeze'); statutText = illWd('Q175358', 'Colonie suedeză')
elseif mw.ustring.lower(args['imperiu']) == 'danemarca' then table.insert(categories, 'Foste colonii daneze'); statutText = illWd('Q302132', 'Colonie daneză')
elseif mw.ustring.lower(args['imperiu']) == 'norvegia' then table.insert(categories, 'Foste colonii norvegiene'); statutText = illWd('Q22969571', 'Colonie norvegiană')
elseif mw.ustring.lower(args['imperiu']) == 'japonia' then table.insert(categories, 'Foste colonii japoneze'); statutText = '[[Imperiul Japonez|Colonie japoneză]]'
else table.insert(categories, 'Foste colonii'); statutText = 'Colonie ' .. (args['imperiu'] and (' a ' .. args['imperiu']) or ' a cui?')
end
elseif mw.ustring.lower(args['statut']) == 'guvern în exil' then table.insert(categories, 'Guverne în exil'); statutText = '[[Guvern în exil]]'
elseif mw.ustring.lower(args['statut']) == 'guvern provizoriu' or mw.ustring.lower(args['statut']) == 'provizoriu' then table.insert(categories, 'Guverne provizorii'); statutText = '[[Guvern provizoriu]]'
elseif mw.ustring.lower(args['statut']) == 'special' or mw.ustring.lower(args['statut']) == 'teritoriu special' or mw.ustring.lower(args['statut']) == 'ocupație militară' or mw.ustring.lower(args['statut']) == 'rămășiță de stat' then table.insert(categories, 'Teritorii Speciale')
elseif mw.ustring.lower(args['statut']) == 'subdiviziune' or mw.ustring.lower(args['statut']) == 'provincie' then table.insert(categories, 'Provincii'); statutText = args['statut_text'] or (args['statut'] .. ' a ' .. (args['imperiu'] or ' cui?'))
elseif mw.ustring.lower(args['statut']) == 'vasal' then
if args['imperiu'] and (mw.ustring.lower(args['imperiu']) == 'sir' or mw.ustring.lower(args['imperiu']) == 'sfântul imperiu roman') then
statutText = args['statut_text'] or (illWd('Q26830017', 'Stat') .. ' al [[Sfântul Imperiu Roman|Sfântului Imperiu Roman]]')
else
statutText = args['statut_text'] or ('Vasal' .. (args['imperiu'] and (' al ' .. args['imperiu']) or ' al cui?'))
end
elseif mw.ustring.lower(args['statut']) == 'fief' then
statutText = 'Fief' .. (args['imperiu'] and (' al ' .. args['imperiu']) or ' al cui?')
elseif mw.ustring.lower(args['statut']) == 'abație' then
if args['statutText'] then statutText = args['statut_text']
elseif args['imperiu'] and (mw.ustring.lower(args['imperiu']) == 'sir' or mw.ustring.lower(args['imperiu']) == 'sfântul imperiu roman') then
statutText = illWd('Q708751') .. ' a [[Sfântul Imperiu Roman|Sfântului Imperiu Roman]]'
else
statutText = 'Abație' .. (args['imperiu'] and (' a ' .. args['imperiu']) or ' a cui?')
end
else
statutText = args['statut_text'] or args['statut']
end
end
local predecessors = analyzeOtherCountries(args, 'p', 'P155')
if not predecessors or 0 == #predecessors then
predecessors = analyzeOtherCountries(args, 'p', 'P1365')
end
local successors = analyzeOtherCountries(args, 's', 'P156')
if not successors or 0 == #successors then
successors = analyzeOtherCountries(args, 's', 'P1366')
end
local startDateParsed = DateUtils.parseDate(removeWikiLinkSyntax(args['an_început']))
local endDateParsed = DateUtils.parseDate(removeWikiLinkSyntax(args['an_sfârșit']))
local endDate = nil
if endDateParsed then endDate = endDateParsed end
local startDate = nil
if startDateParsed then startDate = startDateParsed end
local lifeSpan = args['perioadă_existență']
if endDate == nil then
local wdEndDates = wikidata.findDateValues('P576')
if wdEndDates and #wdEndDates > 0 then endDate = wdEndDates[1] end
end
if startDate == nil then
local wdStartDates = wikidata.findDateValues('P571')
if wdStartDates and #wdStartDates > 0 then startDate = wdStartDates[1] end
end
if endDate ~= nil and endDate.precision >= 9 then table.insert(categories, 'Desființări în ' .. DateUtils.formatYear(endDate.year)) end
if startDate ~= nil and startDate.precision >= 9 then table.insert(categories, 'Fondări în ' .. DateUtils.formatYear(startDate.year)) end
local flag = extractSymbolData(args, {'steag'}, 'P41', '125px', 'P163', 'Drapel')
local coA = extractSymbolData(args, {'stemă', 'simbol'}, 'P94', '85px', 'P237', 'Stemă')
local motto = args['deviză_națională'] or wikidata.findOneValue('P1546')
local anthem = args['imn_național'] or wikidata._getTimestampedValueListWithSeparator({tostring(mw.html.create('br')), 'P85'})
local locationMaps = {}
local tmpMap = extractLocationMapData(args, 'imagine_hartă', 'imagine_hartă_size', 'imagine_hartă_text', 'P242')
if tmpMap then table.insert(locationMaps, tmpMap) end
tmpMap = extractLocationMapData(args, 'imagine_hartă2', 'imagine_hartă_size2', 'imagine_hartă_text2')
if tmpMap then table.insert(locationMaps, tmpMap) end
tmpMap = extractLocationMapData(args, 'image_map2', 'image_map2_size', 'imagine_hartă_text2')
if tmpMap then table.insert(locationMaps, tmpMap) end
local capitals = {}
capitals.official = args['capitala'] or wikidata.findOneValue('P36')
capitals.exile = args['capitala_exil']
local religion = args['religie'] or wikidata._getValueListWithSeparator({tostring(mw.html.create('br')), 'P3075'})
local leadership = {}
local lcTipGvnmt = args['tip_guvernământ'] and mw.ustring.lower(args['tip_guvernământ'])
local wdTipGvnmtIds = wikidata.getBestEntityIdsList(nil, 'P122')
if lcTipGvnmt and StringUtils._startsWith(lcTipGvnmt, 'monarhie') or lcTipGvnmt == 'regat al commonwealthului națiunilor' then
local tipGvnmtTitle = mw.title.new(args['tip_guvernământ'])
if tipGvnmtTitle and tipGvnmtTitle.exists then
leadership.form = '[[' .. args['tip_guvernământ'] .. ']]'
else
leadership.form = args['tip_guvernământ']
end
for _,eachContinentName in ipairs(continentNames) do
table.insert(categories, 'Foste monarhii din ' .. eachContinentName)
end
elseif wdTipGvnmtIds and listContainsAny(wdTipGvnmtIds, {2994894, 184558, 41614, 584683}) then
for _,eachContinentName in ipairs(continentNames) do
table.insert(categories, 'Foste monarhii din ' .. eachContinentName)
end
elseif lcTipGvnmt == 'republică' or wdTipGvnmtIds and listContains(wdTipGvnmtIds, 7270) then
leadership.form = StringUtils._prependIfMissing({StringUtils._appendIfMissing({args['tip_guvernământ'], ']]'}), '[['})
table.insert(categories, 'Foste republici')
elseif StringUtils._startsWith({lcTipGvnmt, 'republică federa'}) or wdTipGvnmtIds and listContains(wdTipGvnmtIds, 512187) then
leadership.form = illWd('Q512187')
table.insert(categories, 'Foste republici')
elseif StringUtils._startsWith({lcTipGvnmt, 'republică populară'}) or wdTipGvnmtIds and listContains(wdTipGvnmtIds, 465613) then
leadership.form = illWd('Q465613')
table.insert(categories, 'Foste republici')
elseif lcTipGvnmt == 'ducat' or wdTipGvnmtIds and listContains(wdTipGvnmtIds, 154547) then
leadership.form = illWd('Q154547')
table.insert(categories, 'Foste ducate')
elseif lcTipGvnmt == 'regat' or wdTipGvnmtIds and listContains(wdTipGvnmtIds, 1250464) then
leadership.form = illWd('Q1250464')
table.insert(categories, 'Foste regate')
elseif lcTipGvnmt == 'principat' or wdTipGvnmtIds and listContains(wdTipGvnmtIds, 208500) then
leadership.form = illWd('Q208500')
table.insert(categories, 'Foste principate')
elseif lcTipGvnmt == 'emirat' or wdTipGvnmtIds and listContains(wdTipGvnmtIds, 189898) then
leadership.form = illWd('Q189898')
table.insert(categories, 'Foste emirate')
elseif listContains({'stat socialist', 'republică socialistă'}, lcTipGvnmt) or wdTipGvnmtIds and listContains(wdTipGvnmtIds, 842112) then
leadership.form = illWd('Q842112')
table.insert(categories, 'Foste republici socialiste')
elseif listContains({'dictatură', 'dictatură militară'}, lcTipGvnmt) or wdTipGvnmtIds and listContainsAny(wdTipGvnmtIds, {317, 49896}) then
leadership.form = illWd('Q317')
table.insert(categories, 'Foste dictaturi')
elseif listContains({'teocrație'}, lcTipGvnmt) or wdTipGvnmtIds and listContainsAny(wdTipGvnmtIds, {44405}) then
leadership.form = illWd('Q44405')
table.insert(categories, 'Foste teocrații')
elseif listContains({'gubernie'}, lcTipGvnmt) or wdTipGvnmtIds and listContainsAny(wdTipGvnmtIds, {86622}) then
leadership.form = illWd('Q86622')
table.insert(categories, 'Guberniile Imperiului Rus')
elseif listContains({'republică autonomă'}, lcTipGvnmt) or wdTipGvnmtIds and listContainsAny(wdTipGvnmtIds, {1977835}) then
leadership.form = illWd('Q1977835')
table.insert(categories, 'Republici autonome ale Uniunii Sovietice')
end
if not leadership.form and wdTipGvnmtIds then
local gvnmtLinkList = {}
for _,eachGvnmtId in ipairs(wdTipGvnmtIds) do
table.insert(gvnmtLinkList, wikidata.findLinkToItem(StringUtils._prependIfMissing({tostring(eachGvnmtId), 'Q'})))
end
leadership.form = table.concat(gvnmtLinkList, tostring(mw.html.create('br')))
end
leadership.position = args['denumire_lider'] or wikidata.findOneValueNoRef('P1906')
local argLeadersNums = TableTools.affixNums(args, 'leader')
if argLeadersNums and #argLeadersNums > 0 then
leadership.leaders = {}
for _,eachArgLeaderNum in ipairs(argLeadersNums) do
local newLeader = {}
newLeader.link = args['leader' .. tostring(eachArgLeaderNum)]
newLeader.years = args['an_leader' .. tostring(eachArgLeaderNum)]
table.insert(leadership.leaders, newLeader)
end
end
leadership.positionRep = args['denumire_reprezentant']
local argReps = TableTools.affixNums(args, 'reprezentant')
if argReps and #argReps > 0 then
leadership.reps = {}
for _,eachArgRepNum in ipairs(argReps) do
local newRep = {}
newRep.link = args['reprezentant' .. tostring(eachArgRepNum)]
newRep.years = args['an_reprezentant' .. tostring(eachArgRepNum)]
table.insert(leadership.reps, newRep)
end
end
leadership.positionAid = args['denumire_adjunct'] or wikidata.findOneValueNoRef('P1313')
local argAid = TableTools.affixNums(args, 'adjunct')
if argAid and #argAid > 0 then
leadership.aids = {}
for _,eachArgAidNum in ipairs(argAid) do
local newAid = {}
newAid.link = args['adjunct' .. tostring(eachArgAidNum)]
newAid.years = args['an_adjunct' .. tostring(eachArgAidNum)]
table.insert(leadership.aids, newAid)
end
end
leadership.legislative = args['legislativ'] or wikidata.findOneValue('P194')
local argChambers = TableTools.affixNums(args, 'camera')
if argChambers and #argChambers > 0 then
leadership.chambers = {}
for argChamberIdx,eachArgChamberNum in ipairs(argChambers) do
local newChamber = {}
newChamber.chamberType = args['tip_camera' .. tostring(eachArgChamberNum)] or (argChamberIdx == 1 and 'Camera superioară' or (argChamberIdx == 2 and 'Camera inferioară' or ('Camera a ' .. argChamberIdx .. '-a')))
newChamber.link = args['camera' .. tostring(eachArgChamberNum)]
table.insert(leadership.chambers, newChamber)
end
end
local history = {}
local eraId = nil
local eraMap = {['Q361'] = 'primul război mondial', ['Q362'] = 'al doilea război mondial', ['Q8683'] = 'războiul rece', ['Q154611'] = 'perioada interbelică'}
if args['era'] then
history.era = args['era']
else
local eraIds = wikidata.getBestEntityIdsList(nil, 'P2348')
if eraIds and #eraIds > 0 then eraId = StringUtils._prependIfMissing({tostring(eraIds[1]), 'Q'}) end
end
if eraId or history.era then
local lcEra = eraId and eraMap[eraId] or history.era and mw.ustring.lower(history.era)
if lcEra == 'Războiul Rece' then
table.insert(categories, 'Foste forme de guvernare ale Războiului Rece')
elseif lcEra == 'perioada interbelică' then
table.insert(categories, 'Foste forme de guvernare ale perioadei interbelice')
elseif endDate ~= nil and startDate ~= nil and math.abs(endDate.year - startDate.year) < 10 then
if lcEra == 'Al Doilea Război Mondial' or (endDate.year < 1945 and startDate.year > 1938) then
table.insert(categories, 'State efemere ale celui de-al Doilea Război Mondial')
elseif lcEra == 'Primul Război Mondial' or (endDate.year < 1919 and startDate.year > 1913) then
table.insert(categories, 'State efemere ale Primului Război Mondial')
else
table.insert(categories, 'State efemere')
end
end
end
local argEvents = TableTools.affixNums(args, 'eveniment')
if (argEvents and #argEvents > 0) or args['eveniment_înainte'] or args['eveniment_început'] or args['eveniment_sfârșit'] or args['eveniment_după'] then
history.before = createEventFromArgs(args, 'eveniment_înainte', 'dată_înainte', 'an_înainte')
history.after = createEventFromArgs(args, 'eveniment_după', 'dată_după', 'an_după')
history.moments = {}
if args['eveniment_început'] then
local newEvent = createEventFromArgs(args, 'eveniment_început', 'dată_început', 'an_început')
if newEvent then table.insert(history.moments, newEvent) end
elseif startDate then
local newEvent = {}
newEvent.event = 'Fondare'
newEvent.date = startDate
table.insert(history.moments, newEvent)
end
for _,eachEventNum in ipairs(argEvents) do
local newEvent = createEventFromArgs(args, 'eveniment' .. eachEventNum, 'dată_eveniment' .. eachEventNum, 'an_eveniment' .. eachEventNum)
if newEvent then table.insert(history.moments, newEvent) end
end
if args['eveniment_sfârșit'] then
local newEvent = createEventFromArgs(args, 'eveniment_sfârșit', 'dată_sfârșit', 'an_sfârșit')
if newEvent then table.insert(history.moments, newEvent) end
elseif endDate then
local newEvent = {}
newEvent.event = 'Desființare'
newEvent.date = endDate
table.insert(history.moments, newEvent)
end
end
if not history.moments or #(history.moments) == 0 then
local wdMoments = wikidata.findSortedClaimsForProperty(nil, 'P793')
history.moments = {}
if wdMoments and #wdMoments > 0 then
for _,eachWdMoment in ipairs(wdMoments) do if isClaimWithData(eachWdMoment) then
local newEvent = {}
newEvent.event = wikidata.printSnak(eachWdMoment.mainsnak)
if eachWdMoment.qualifiers and eachWdMoment.qualifiers['P585'] and eachWdMoment.qualifiers['P585'][1] then
newEvent.date = wikidata.extractDateFromClaim(eachWdMoment.qualifiers['P585'][1])
end
table.insert(history.moments, newEvent)
end end
end
end
local stats = {}
local argAreaNums = TableTools.affixNums(args, 'stat_suprafață')
if argAreaNums and #argAreaNums > 0 then
stats.area = {}
stats.index = {}
for _,eachArgAreaNum in ipairs(argAreaNums) do
local areaMatch = mw.ustring.match(args['stat_suprafață' .. eachArgAreaNum], '[%d%.]+')
if areaMatch then
local newArea = {}
newArea.index = tonumber(eachArgAreaNum)
newArea.year = args['stat_an' .. eachArgAreaNum]
newArea.area = tonumber(Formatnum._stripSeparators(areaMatch))
newArea.ref = args['ref_suprafață' .. eachArgAreaNum]
table.insert(stats.area, newArea)
stats.index[newArea.index] = stats.index[newArea.index] or {}
table.insert(stats.index[newArea.index], newArea)
end
end
end
local argPopNums = TableTools.affixNums(args, 'stat_pop')
if argPopNums and #argPopNums > 0 then
stats.pop = {}
stats.index = stats.index or {}
for _,argPopNums in ipairs(argPopNums) do
local popMatch = mw.ustring.match(args['stat_pop' .. argPopNums], '%d+')
if popMatch then
local newPop = {}
newPop.index = tonumber(argPopNums)
newPop.pop = tonumber(popMatch)
newPop.year = args['stat_an' .. argPopNums]
table.insert(stats.pop, newPop)
stats.index[newPop.index] = stats.index[newPop.index] or {}
table.insert(stats.index[newPop.index], newPop)
end
end
end
local economics = {}
if args['monedă'] then
economics.currency = args['monedă']
else
economics.currency = wikidata._getTimestampedValueListWithSeparator({tostring(mw.html.create('br')), 'P38'})
if economics.currency and #(economics.currency) == 0 then economics.currency = nil end
end
local countryToday = args['azi'] or args['prezent'] or args['today'] -- or wikidata._getBestValuesWithSeparator(nil, 'P17', tostring(mw.html.create('br')))
local notes = args['note']
return p.fromArgs(countryName, names, officialLanguages, categories, statutText, predecessors, successors, startDate, endDate, lifeSpan, coA, flag,
motto, anthem, locationMaps, capitals, religion, leadership, history, stats, economics, countryToday, notes)
end
p.fromFrame = function(frame)
local args = getArgs(frame)
return p.fromArray(args)
end
return p