Moduł:Stopka

Z Nonsensopedii, polskiej encyklopedii humoru

Moduł szablonu {{Stopka}}. Zobacz też: Moduł:Stopka portal.


local tools = require('Moduł:Narzędzia')
local stopkaPortal = require('Moduł:Stopka portal')
local p = {}

local function doLocation(frame, args)
	local props = {}
	local name = mw.title.getCurrentTitle().fullText
	local ltype = 'landmark'
	props['Ma lokalizację'] = args['lokalizacja']
	
	if args['terc'] then
		local terc = args['terc']
		
		if #terc > 4 then
			ltype = 'adm3rd'	-- gmina jakowaś
		elseif #terc > 2 then
			ltype = 'adm2nd'	-- powiat
		else
			ltype = 'adm1st'	-- województwo
		end
	end
	
	if args['simc'] then
		props['SIMC'] = args['simc']
		ltype = 'city'
	end
	
	if args['wikidata'] then
		props['Ma identyfikator Wikidanych'] = args['wikidata']
	end
	
	if args['niepewne'] ~= nil then
		props['Ma niepewną lokalizację'] = true
	end
	
	mw.smw.set(props)
	local coords = mw.text.split(args['lokalizacja'], ',%s*')
	return frame:callParserFunction{ 
		name = '#coordinates', 
		args = {
    		coords[1],
    		coords[2],
    		'primary',
    		name = name,
    		type = ltype
		}
	}
end

function p.stopka(frame)
	local args = tools.getArgs(frame)
	local text = ''
	
	if args['lokalizacja'] then 
		text = text .. doLocation(frame, args)
	end
	
	text = text .. stopkaPortal.getText()
	return text
end

return p