Butun axtardiqlarinizi tapmaq ucun buraya: DAXIL OLUN
  Mp4 Mp3 Axtar Yukle
  Video Axtar Yukle
  Shekil Axtar Yukle
  Informasiya Melumat Axtar
  Hazir Inshalar Toplusu
  AZERI CHAT + Tanishliq
  1-11 Sinif Derslikler Yukle
  Saglamliq Tibbi Melumat
  Whatsapp Plus Yukle(Yeni)

  • Ana səhifə
  • Təsadüfi
  • Yaxınlıqdakılar
  • Daxil ol
  • Nizamlamalar
İndi ianə et Əgər Vikipediya sizin üçün faydalıdırsa, bu gün ianə edin.

Modul:Wikidata/positions

  • Modul
  • Müzakirə
< Modul:Wikidata

Bu modulun sənədləşdirmə səhifəsi Modul:Wikidata/positions/doc səhifəsində yaradıla bilər

local p = {}

local topPriorityClasses = {
	Q48352 = true, Q2285706 = true, Q248577 = true,
	Q14212 = true, Q959664 = true, Q13409304 = true,
	Q39018 = true, Q116 = true, Q2304859 = true,
	Q12097 = true, Q719039 = true, Q16511993 = true,
	Q462189 = true, Q7645115 = true,
}

local lowPrioritySubclasses = {
	Q486839 = true, Q15628644 = true, Q41961533 = true,
	Q115168134 = true, Q115136557 = true, Q115252544 = true,
	Q27137568 = true, Q4175034 = true, Q1055894 = true,
	Q2786200 = true, Q15686806 = true, Q10084024 = true, 
}

local ignoredEntities = {
	Q140686 = true, Q1162163 = true, Q978044 = true,
	Q121998 = true, Q217713 = true, Q83307 = true,
	Q484876 = true, Q1553195 = true, Q6501749 = true,
	Q42178 = true, Q1255921 = true, Q11247470 = true,
	Q30461 = true, Q1127270 = true, Q22132694 = true, 
	Q380782 = true, Q1370385 = true, Q3250324 = true, 
	Q1467287 = true, 
}

local subjectEntity = mw.wikibase.getEntity()
local subjectGender = nil
if subjectEntity and subjectEntity.claims and subjectEntity.claims.P21 then
	local genderId = subjectEntity.claims.P21[1].mainsnak.datavalue and subjectEntity.claims.P21[1].mainsnak.datavalue.value.id
	subjectGender = genderId
end
local subjectDead = subjectEntity and subjectEntity.claims and subjectEntity.claims.P570 and true or false

local function parseTimeString(t)
	if not t then return nil end
	local y, m, d = t:match("^([%+%-]?%d+)%-(%d%d)%-(%d%d)")
	return y and m and d and tonumber(y) * 10000 + tonumber(m) * 100 + tonumber(d) or nil
end

local function getDateFromSnak(snak)
	return parseTimeString(snak and snak.datavalue and snak.datavalue.value and snak.datavalue.value.time)
end

local function getDirectedEntityLabel(entityId, targetStart, targetEnd)
	if ignoredEntities[entityId] then
		return nil
	end

	local label = nil
	local entity = mw.wikibase.getEntity(entityId)
	
	if entity and entity.claims then
		local genderedLabel = nil

		if subjectGender == "Q6581097" and entity.claims.P3321 then
			for _, claim in ipairs(entity.claims.P3321) do
				local val = claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value
				if val and val.language == "az" and val.text then
					genderedLabel = val.text
					break
				end
			end
		elseif subjectGender == "Q6581072" and entity.claims.P2521 then
			for _, claim in ipairs(entity.claims.P2521) do
				local val = claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value
				if val and val.language == "az" and val.text then
					genderedLabel = val.text
					break
				end
			end
		end

		if genderedLabel then
			label = genderedLabel
		end
	end

	if entity and entity.claims and entity.claims.P1448 then
		local bestFullCover, bestStart = nil, -1

		for _, claim in ipairs(entity.claims.P1448) do
			local dv = claim.mainsnak and claim.mainsnak.datavalue
			if dv and dv.value.language == "az" and dv.value.text then
				local labelText = dv.value.text
				local s = claim.qualifiers and claim.qualifiers.P580 and getDateFromSnak(claim.qualifiers.P580[1])
				local e = claim.qualifiers and claim.qualifiers.P582 and getDateFromSnak(claim.qualifiers.P582[1])
				
				if s and e and targetStart and targetEnd then
				    if e < targetEnd then
				    else
				        local overlapStart = math.max(s, targetStart)
				        local overlapEnd = math.min(e, targetEnd)
				        if overlapStart <= overlapEnd then
				            local overlapLength = overlapEnd - overlapStart
				            if not bestFullCover or overlapLength > bestStart then
				                bestFullCover = labelText
				                bestStart = overlapLength
				            end
				        end
				    end
				end

				local coversStart = not targetStart or not s or targetStart >= s
				local coversEnd = not targetEnd or not e or targetEnd <= e
				if coversStart and coversEnd then
					if (not bestFullCover) or ((s or 0) > bestStart) then
						bestFullCover = labelText
						bestStart = s or 0
					end
				end
			end
		end
		
		if bestFullCover then
			label = bestFullCover
		end
	end

	if not label then
		label = mw.wikibase.getLabelByLang(entityId, 'az')
	end
	if not label then
		return nil
	end

	local link = mw.wikibase.getSitelink(entityId, 'azwiki')
	if not link and entity then
		local fallbackIds = {}

		if entity.claims then
			for _, prop in ipairs({ "P2354", "P2389", "P361" }) do
				if entity.claims[prop] then
					for _, claim in ipairs(entity.claims[prop]) do
						local targetId = claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value.id
						if targetId and not ignoredEntities[targetId] then
							table.insert(fallbackIds, targetId)
						end
					end
				end
			end
		end

		local isLowPriority = false
		if entity.claims and entity.claims.P279 then
			for _, subclassClaim in ipairs(entity.claims.P279) do
				local subclassId = subclassClaim.mainsnak and subclassClaim.mainsnak.datavalue and subclassClaim.mainsnak.datavalue.value.id
				if subclassId and lowPrioritySubclasses[subclassId] then
					isLowPriority = true
					break
				end
			end
		end

		if isLowPriority and entity.claims and entity.claims.P361 then
			for _, claim in ipairs(entity.claims.P361) do
				local targetId = claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value.id
				if targetId and not ignoredEntities[targetId] then
					table.insert(fallbackIds, targetId)
				end
			end
		end

		for _, targetId in ipairs(fallbackIds) do
			local altLink = mw.wikibase.getSitelink(targetId, 'azwiki')
			if altLink then
				link = altLink
				break
			end
		end
	end

	if link then
		return '[[' .. link .. '|' .. label .. ']]'
	else
		return label
	end
end

local function selectQualifiedImage(claims, prop, targetDate)
    if not claims or not claims[prop] then return nil end

    local bestImage = nil
    local latestStart = nil

    for _, claim in ipairs(claims[prop]) do
        local image = claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value
        if image then
            local startTime, endTime
            if claim.qualifiers and claim.qualifiers.P580 and claim.qualifiers.P580[1].datavalue then
                startTime = claim.qualifiers.P580[1].datavalue.value.time
            end
            if claim.qualifiers and claim.qualifiers.P582 and claim.qualifiers.P582[1].datavalue then
                endTime = claim.qualifiers.P582[1].datavalue.value.time
            end

            local function parseTime(t)
                if not t then return nil end
                local y, m, d = t:match("^([%+%-]?%d+)%-(%d%d)%-(%d%d)")
                if y and m and d then
                    return tonumber(y) * 10000 + tonumber(m) * 100 + tonumber(d)
                end
                return nil
            end

            local s = parseTime(startTime)
            local e = parseTime(endTime)

            if (not s or targetDate >= s) and (not e or targetDate <= e) then
                return image
            end

            if s and (not latestStart or s > latestStart) then
                latestStart = s
                bestImage = image
            end
        end
    end

    return bestImage
end

function p.formatPositionClaims(context, options)
    local entity = mw.wikibase.getEntity()
	local statements = entity and entity.claims and entity.claims[options.property] or {}
    if not statements or #statements == 0 then
        return ""
    end

    local flatArray = {}

    for _, statement in ipairs(statements) do
        local qualifiers = statement.qualifiers
		if qualifiers and (qualifiers["P580"] or qualifiers["P582"]) then
			local skip = false
				for _, pid in ipairs({ "P108", "P2389", "P642", "P1001" }) do
					if qualifiers[pid] then
						skip = true
						break
					end
				end
				if not skip then
	            local mainsnak = statement.mainsnak
	            if mainsnak and mainsnak.datavalue and mainsnak.datavalue.value then
	                local entityId = mainsnak.datavalue.value.id
	                
	                local isLowPriority = false
					local isTopPriority = false
					local entity = mw.wikibase.getEntity(entityId)
					if entity and entity.claims and entity.claims.P279 then
						for _, subclassClaim in ipairs(entity.claims.P279) do
							local subclassId = subclassClaim.mainsnak and subclassClaim.mainsnak.datavalue and subclassClaim.mainsnak.datavalue.value.id
							if subclassId then
								if lowPrioritySubclasses[subclassId] then
									isLowPriority = true
								end
								if topPriorityClasses[subclassId] then
									isTopPriority = true
								end
							end
						end
					end
					
					
	                local startDate = qualifiers.P580 and getDateFromSnak(qualifiers.P580[1]) or nil
	                local endDate   = qualifiers.P582 and getDateFromSnak(qualifiers.P582[1]) or nil
	
					local rawLabel = getDirectedEntityLabel(entityId, startDate, endDate)
					
					if rawLabel and mw.text.trim(rawLabel) ~= "" then
					local isActing = qualifiers.P5102
					    and qualifiers.P5102[1].datavalue
					    and qualifiers.P5102[1].datavalue.value.id == "Q4676846"
					
					    local latest = qualifiers.P580 and getDateFromSnak(qualifiers.P580[1]) or nil
						table.insert(flatArray, {
						    label       = rawLabel,
						    statement   = statement,
						    latest      = latest,
						    lowPriority = isLowPriority,
						    topPriority = isTopPriority,
						    isActing    = isActing
						})
					end
				end
            end
        end
    end

    table.sort(flatArray, function(a, b)
        if not a.latest then return false end
        if not b.latest then return true end
        return a.latest > b.latest
    end)

	local results = {}
	
	local grouped = {}
	for _, item in ipairs(flatArray) do
	    local key = item.label
	    if not grouped[key] then
	        grouped[key] = {}
	    end
	    table.insert(grouped[key], item)
	end
	
	local usedStatements = {}
	local mergedBlocks = {}
	
	for _, group in pairs(grouped) do
	    table.sort(group, function(a, b)
	        local aStart = a.statement.qualifiers.P580 and getDateFromSnak(a.statement.qualifiers.P580[1]) or 0
	        local bStart = b.statement.qualifiers.P580 and getDateFromSnak(b.statement.qualifiers.P580[1]) or 0
	        return aStart < bStart
	    end)
	
	    local merged = {}
	    for _, current in ipairs(group) do
	        local currentStart = current.statement.qualifiers.P580 and getDateFromSnak(current.statement.qualifiers.P580[1])
	        local currentEnd = current.statement.qualifiers.P582 and getDateFromSnak(current.statement.qualifiers.P582[1])
	
	        if #merged == 0 then
				table.insert(merged, {
					label = current.label,
					start = currentStart,
					endd = currentEnd,
					items = { current },
					topPriority = current.topPriority,
					lowPriority = current.lowPriority
				})
			usedStatements[current.statement] = true
	        else
	            local last = merged[#merged]
				if last.endd and currentStart and last.endd == currentStart and
				    last.items[1].isActing == current.isActing then
	                last.endd = currentEnd
	                table.insert(last.items, current)
	                usedStatements[current.statement] = true
	            else
				table.insert(merged, {
					label = current.label,
					start = currentStart,
					endd = currentEnd,
					items = { current },
					topPriority = current.topPriority,
					lowPriority = current.lowPriority
				})
				usedStatements[current.statement] = true
	            end
	        end
	    end
	
	    for _, block in ipairs(merged) do
	        table.insert(mergedBlocks, block)
	    end
	    for _, item in ipairs(group) do
		    if not usedStatements[item.statement] then
				table.insert(mergedBlocks, {
					label = item.label,
					start = item.statement.qualifiers.P580 and getDateFromSnak(item.statement.qualifiers.P580[1]) or nil,
					endd = item.statement.qualifiers.P582 and getDateFromSnak(item.statement.qualifiers.P582[1]) or nil,
					items = { item },
					topPriority = item.topPriority,
					lowPriority = item.lowPriority
				})
		    end
		end
	end
	
	local labelGroups = {}
	local labels = {}
	for _, block in ipairs(mergedBlocks) do
	    if not labelGroups[block.label] then
			labelGroups[block.label] = {
				lowPriority = block.lowPriority,
				topPriority = block.topPriority,
				maxEnd = 0,
				blocks = {}
			}
	        table.insert(labels, block.label)
	    end
	    local g = labelGroups[block.label]
	    table.insert(g.blocks, block)
	    local e = block.endd or 0
	    if e > g.maxEnd then g.maxEnd = e end
	end
	
	for _, lbl in ipairs(labels) do
	    local g = labelGroups[lbl]
	
	    local noEndCount = 0
	    for _, block in ipairs(g.blocks) do
	        if not block.endd then
	            noEndCount = noEndCount + 1
	        end
	    end
	
	    if noEndCount <= 1 then
	        table.sort(g.blocks, function(a, b)
	            if not a.endd then return true end
	            if not b.endd then return false end
	            return a.endd > b.endd
	        end)
	    else
	        table.sort(g.blocks, function(a, b)
	            return (a.start or 0) > (b.start or 0)
	        end)
	
	        local latestStart, latestIndex = -1, nil
	        for i, block in ipairs(g.blocks) do
	            if not block.endd and block.start and block.start > latestStart then
	                latestStart = block.start
	                latestIndex = i
	            end
	        end
	
	        for i, block in ipairs(g.blocks) do
	            if not block.endd and i ~= latestIndex then
	                block.endd = 'unknown'
	            end
	        end
	    end
	end
	
	local function isIncumbent(block)
	    return not block.endd
	end
	
	table.sort(labels, function(a, b)
	    local A, B = labelGroups[a], labelGroups[b]
		local A_inc = not subjectDead and isIncumbent(A.blocks[1])
		local B_inc = not subjectDead and isIncumbent(B.blocks[1])
	
	    if A_inc ~= B_inc then
	        return A_inc
	    end
	
		if A.topPriority ~= B.topPriority then
			return A.topPriority
		end
		
		if A.lowPriority ~= B.lowPriority then
			return not A.lowPriority
		end
	
	    return A.maxEnd > B.maxEnd
	end)
	
	local sorted = {}
	for _, lbl in ipairs(labels) do
	    for _, block in ipairs(labelGroups[lbl].blocks) do
	        table.insert(sorted, block)
	    end
	end
	mergedBlocks = sorted
	
	local lastShownLabel = nil
	
	for _, block in ipairs(mergedBlocks) do
	    local representative = block.items[1].statement
	    local qualifiers = representative.qualifiers

		local onlyBlockWithThisLabel = true
		for _, b in ipairs(mergedBlocks) do
		    if b ~= block and b.label == block.label then
		        onlyBlockWithThisLabel = false
		        break
		    end
		end
		
		if onlyBlockWithThisLabel and block.items[1].isActing then
		    block.statusNote = "Səlahiyyətlərin icraçısı"
		end
		
		local hasMultipleSameLabel = false
		local hasAnyActing = false
		for _, b in ipairs(mergedBlocks) do
		    if b.label == block.label then
		        if b ~= block then hasMultipleSameLabel = true end
		        for _, item in ipairs(b.items) do
		            if item.isActing then
		                hasAnyActing = true
		                break
		            end
		        end
		    end
		end
		
		local actingNote = "''(səlahiyyətlərin icraçısı)''"
		if hasMultipleSameLabel and hasAnyActing then
		    block.actingNoteToAdd = actingNote
		end
	
	    local formattedLabel = '<span class="ts-wikidata-positions-uppercasefirst" style="white-space:normal;">' .. block.label .. '</span>'
	    if qualifiers and qualifiers.P642 then
	        local orgs = {}
	        for _, snak in ipairs(qualifiers.P642) do
	            local orgName = context.formatSnak(options, snak)
	            if orgName and orgName ~= "" then
	                table.insert(orgs, orgName)
	            end
	        end
	        if #orgs > 0 then
	            formattedLabel = formattedLabel .. " (" .. mw.text.listToText(orgs) .. ")"
	        end
	    end
	
	    local firstQ = block.items[1].statement.qualifiers
	    local lastQ = block.items[#block.items].statement.qualifiers
	
	    local args = {}
	    local hideLabel = (lastShownLabel == block.label)
		lastShownLabel = block.label
		
		args["vəzifə_"] = hideLabel and "" or formattedLabel
		args["status_"] = block.statusNote or ""
		local startSnak = firstQ["P580"] and firstQ["P580"][1]
		local endSnak = lastQ["P582"] and lastQ["P582"][1]
		args["başlanğıc_"] = block.omitDates and "" or (startSnak and context.formatSnak(options, startSnak) or "")
		
		if block.omitDates then
			args["son_"] = ""
		elseif endSnak then
			args["son_"] = context.formatSnak(options, endSnak)
		elseif block.endd == 'unknown' then
			args["son_"] = context.formatSnak(options, { snaktype = "somevalue", property = "P582" })
		elseif subjectDead then
			args["son_"] = "''bilinmir''"
		else
			args["son_"] = ""
		end
		
		if block.items[1].isActing and not block.statusNote then
		    local actingNote = "<br />(səlahiyyətlərin icraçısı)"
		    local hasStart = args["başlanğıc_"] and args["başlanğıc_"] ~= ""
		    local hasEnd = args["son_"] and args["son_"] ~= ""
		    
		    if hasStart and hasEnd then
		        args["son_"] = args["son_"] .. actingNote
		    elseif hasStart then
		        args["başlanğıc_"] = args["başlanğıc_"] .. actingNote
		    elseif hasEnd then
		        args["son_"] = args["son_"] .. actingNote
		    else
		        args["başlanğıc_"] = "(səlahiyyətlərin icraçısı)"
		    end
		end
		
		local subjectId = subjectEntity and subjectEntity.id
		
		if firstQ["P1365"] and firstQ["P1365"][1] then
			local snak = firstQ["P1365"][1]
			if snak.snaktype == "novalue" then
				args["əvvəlki_"] = "''vəzifə təsis edilib''"
			elseif snak.datavalue and snak.datavalue.value and snak.datavalue.value.id == subjectId then
				args["əvvəlki_"] = "''özü''"
			else
				args["əvvəlki_"] = context.formatSnak(options, snak)
			end
		else
			args["əvvəlki_"] = ""
		end
		
		if lastQ["P1366"] and lastQ["P1366"][1] then
			local snak = lastQ["P1366"][1]
			if snak.snaktype == "novalue" then
				args["sonrakı_"] = "''vəzifə ləğv edilib''"
			elseif snak.datavalue and snak.datavalue.value and snak.datavalue.value.id == subjectId then
				args["sonrakı_"] = "''özü''"
			else
				args["sonrakı_"] = context.formatSnak(options, snak)
			end
		else
			args["sonrakı_"] = ""
		end
	    args["seçki dairəsi_"] = firstQ["P768"] and context.formatSnak(options, firstQ["P768"][1]) or ""
	    
		local function markActing(label, personId, officeId, refDate, mode)
			if not label or not refDate or not (mode == "pre" or mode == "suc") then return label end
		
			local ent = mw.wikibase.getEntity(personId)
			if not ent or not ent.claims or not ent.claims.P39 then return label end
		
			for _, st in ipairs(ent.claims.P39) do
				local dv = st.mainsnak and st.mainsnak.datavalue
				if not dv or not dv.value or dv.value.id ~= officeId then
				else
					local isActing = false
					if st.qualifiers and st.qualifiers.P5102 then
						for _, q in ipairs(st.qualifiers.P5102) do
							if q.datavalue and q.datavalue.value.id == "Q4676846" then
								isActing = true
								break
							end
						end
					end
		
					if isActing then
						local s = st.qualifiers and st.qualifiers.P580 and getDateFromSnak(st.qualifiers.P580[1])
						local e = st.qualifiers and st.qualifiers.P582 and getDateFromSnak(st.qualifiers.P582[1])
		
						if mode == "pre" and e and e == refDate then
							return label .. ' <span style="font-size:95%;">(<abbr class="abbr" title="səlahiyyətləri müvəqqəti icra edən">i.&nbsp;e.</abbr>)</span>'
						elseif mode == "suc" and s and s == refDate then
							return label .. ' <span style="font-size:95%;">(<abbr class="abbr" title="səlahiyyətləri müvəqqəti icra edən">i.&nbsp;e.</abbr>)</span>'
						end
					end
				end
			end
		
			return label
		end
	    
	    if firstQ["P1365"] and firstQ["P1365"][1].datavalue then
	        local pid = firstQ["P1365"][1].datavalue.value.id
	        args["əvvəlki_"] = markActing(args["əvvəlki_"], pid, representative.mainsnak.datavalue.value.id, block.start, "pre")
	    end
	    if lastQ["P1366"] and lastQ["P1366"][1].datavalue then
	        local sid = lastQ["P1366"][1].datavalue.value.id
	        args["sonrakı_"] = markActing(args["sonrakı_"], sid, representative.mainsnak.datavalue.value.id, block.endd, "suc")
	    end
	
	    local mainEntity = representative.mainsnak and representative.mainsnak.datavalue and representative.mainsnak.datavalue.value
		local refSnak = lastQ["P582"] and lastQ["P582"][1]
		local refDate = refSnak and getDateFromSnak(refSnak)
		
		if not refDate then
			for i = #block.items, 1, -1 do
				local q = block.items[i].statement.qualifiers
				if q and q["P580"] and q["P580"][1] then
					refDate = getDateFromSnak(q["P580"][1])
					break
				end
			end
		end
	
	    if type(mainEntity) == "table" and mainEntity.id then
	        local ent = mw.wikibase.getEntity(mainEntity.id)
	
		local directCoat = refDate and (
			selectQualifiedImage(ent.claims, "P158", refDate) or
			selectQualifiedImage(ent.claims, "P94", refDate) or
			selectQualifiedImage(ent.claims, "P154", refDate)
		) or nil
		
		local directFlag = refDate and selectQualifiedImage(ent.claims, "P41", refDate) or nil
	
			if not hideLabel then
				if directCoat then args["bayraq_"] = directCoat end
				if directFlag then args["bayraq2_"] = directFlag end
			
				local function hasP31(entity, targetId)
					if not entity or not entity.claims or not entity.claims.P31 then return false end
					for _, claim in ipairs(entity.claims.P31) do
						local id = claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value.id
						if id == targetId then
							return true
						end
					end
					return false
				end
				
				local function getCountryFallbackIds(entity, targetStart, targetEnd)
					local ids = {}
					if not entity or not entity.claims then return ids end
				
					local function getCountryAtEnd(claims)
						if not claims then return nil end
						local matched = nil
						for _, claim in ipairs(claims) do
							local id = claim.mainsnak and claim.mainsnak.datavalue and claim.mainsnak.datavalue.value.id
							if id then
								local s = claim.qualifiers and claim.qualifiers.P580 and getDateFromSnak(claim.qualifiers.P580[1])
								local e = claim.qualifiers and claim.qualifiers.P582 and getDateFromSnak(claim.qualifiers.P582[1])
				
								local coversStart = not s or not targetEnd or targetEnd >= s
								local coversEnd   = not e or not targetEnd or targetEnd <= e
								if coversStart and coversEnd then
									matched = id
									break
								end
							end
						end
						return matched or (claims[1] and claims[1].mainsnak and claims[1].mainsnak.datavalue and claims[1].mainsnak.datavalue.value.id)
					end
				
					local p17 = getCountryAtEnd(entity.claims.P17)
					local p1001 = getCountryAtEnd(entity.claims.P1001)
				
					if p1001 then
						local subEntity = mw.wikibase.getEntity(p1001)
						if p17 == "Q159" and hasP31(subEntity, "Q41162") then
							table.insert(ids, p1001)
						elseif p17 == "Q15180" and hasP31(subEntity, "Q236036") then
							table.insert(ids, p1001)
						end
					end
				
					if p17 then table.insert(ids, p17) end
					if p1001 and p1001 ~= p17 then table.insert(ids, p1001) end
				
					return ids
				end
				
				if not args["bayraq_"] or not args["bayraq2_"] then
					local fallbackIds = getCountryFallbackIds(ent, block.start, block.endd)
					for _, cid in ipairs(fallbackIds) do
						local countryEntity = mw.wikibase.getEntity(cid)
						if countryEntity and countryEntity.claims then
							if not args["bayraq_"] then
								args["bayraq_"] =
									selectQualifiedImage(countryEntity.claims, "P94", refDate) or
									selectQualifiedImage(countryEntity.claims, "P154", refDate)
							end
							if not args["bayraq2_"] then
								args["bayraq2_"] = selectQualifiedImage(countryEntity.claims, "P41", refDate)
							end
						end
						if args["bayraq_"] and args["bayraq2_"] then break end
					end
				end
			end
	    end
	
	    local res = options.frame:extensionTag("templatestyles", "", {
	        src = "Şablon:Wikidata/positions/styles.css"
	    })
	    res = res .. options.frame:expandTemplate{
	        title = "Vəzifəli şəxs/vəzifə",
	        args  = args
	    }
	    table.insert(results, res)
	end
	
	return table.concat(results, "\n")
end

return p
Mənbə — "https://az.wikipedia.org/w/index.php?title=Modul:Wikidata/positions&oldid=8220292"
Informasiya Melumat Axtar