Modül:Wikidata/positions

Vikipedi, özgür ansiklopedi
Modül belgelemesi[oluştur]
local p = {}

function p.formatPositionClaim( context, options, statement )
	if (not context) then error('context is not specified') end;
	if (not options) then error('options is not specified') end;
	if (not statement) then error('statement is not specified') end;

	local args = {}
	
	if not statement.qualifiers or not statement.qualifiers['P580'] or not statement.qualifiers['P580'][1] then
		return '' 
	end
	
	if context.formatSnak( options, statement.mainsnak ) ~= nil then
		args['makam_'] = '<span class="ts-wikidata-positions-uppercasefirst">' .. context.formatSnak( options, statement.mainsnak ) .. '</span>'
	end
	if statement.qualifiers and statement.qualifiers['P642'] then
		local organizations = {}
		for _, v in pairs(statement.qualifiers['P642']) do
			table.insert(organizations, context.formatSnak( options, v ))
		end
		if args['makam_'] ~= nil then
			args['makam_'] = args['makam_'] .. ' (' .. mw.text.listToText(organizations) .. ')'
		end
	end
	
	local params = {
		['dönembaşı_'] = 'P580',
		['dönemsonu_'] = 'P582',
		['öncegelen_'] = 'P1365',
		['sonragelen_'] = 'P1366',
		['hükümeti_'] = 'P5054',
	}
	if statement.qualifiers and args['makam_'] ~= nil then
		for k, v in pairs(params) do
			if statement.qualifiers[v] then
				args[k] = context.formatSnak( options, statement.qualifiers[v][1] )
			end
		end
		else
			return nil
	end
	
	local res = options.frame:extensionTag( 'templatestyles', '', { src = 'Şablon:Wikidata/positions/styles.css' } );
	res = res .. options.frame:expandTemplate{ title = 'Makam sahibi bilgi kutusu/Makam', args = args }; 
	return res
end

return p