Idi na sadržaj

Modul:National squad

S Wikipedije, slobodne enciklopedije

Dokumentaciju za ovaj modul možete napraviti na stranici Modul:National squad/dok

-- This module implements [[Template:National squad]] and 
-- [[Template:National squad no numbers]] to avoid articles being added to 
-- [[:Category:Pages where template include size is exceeded]]
-- when the template is used many times.
local p = {}
local prefixes = {
	['muškarci'] = 'Muška ',
	['muška'] = 'Muška ',
	['muški'] = 'Muška ',
	['ženska'] = 'Ženska ',
	['žene'] = 'Ženska ',
	['ženski'] = 'Ženska ',
	[''] = ''
}
function p.main(frame)
	local getArgs = require('Modul:Arguments').getArgs
	local args = getArgs(frame, {parentFirst = true})
	local country = args['država_genitiv'] or '{{{država_genitiv}}}'
	local coach_label = args.trener_vrsta or 'Selektor'
	local comp = args['takmič'] or '{{{takmič}}}'
	local gender = prefixes[args.spol or ''] or ''
	local sport = args.sport or 'Nogometna'
	if(gender ~= '') then 
		sport = string.lower(args.sport) or 'nogometna'
	end
	local titlestyle = 'background-color:' .. (args.bg or 'transparent') .. ';'
		.. 'color:' .. (args.fg or 'inherit') .. ';' 
		.. 'border: 1px solid ' .. (args.bordercolor or args.border or '#aaa') .. ';'
--	local image = args.country ~= 'Unified Team' and frame:expandTemplate{
--		title = 'ZD', 
--		args = {args.country or 'none', args.flagvar or '', size = '50px'}
--	} or frame:expandTemplate{
--		title = 'ZD slika', 
--		args = {'Olympic flag.svg', size = '50px'}
--	}

	local ospan = '<span style="color:' .. (args.fg or 'inherit') .. '">'
	local cspan = '</span>'	
	local title = string.format('[[%s|%s%s%s]] na [[%s|%s%s%s]]', 
		args['ekipa link'] or (gender .. sport .. ' reprezentacija ' .. country), 
		ospan, args.naslov or 'Sastav ' .. country, cspan, 
		args['takmič link'] or comp, ospan, comp, cspan)
	
	local haspos = false
	
	-- Tracking and preview warnings
	local knownargs = {['bg']=1, ['fg']=1, ['bordercolor']=1, ['border']=1, ['selektor']=1, ['trener_vrsta']=1,
		['takmič']=1, ['takmič link']=1, ['država_genitiv']=1, ['spol']=1, 
		['list']=1, ['ime']=1, ['nonumbers'] = 1, ['bilješka']=1, ['sport']=1, ['ekipa link']=1, ['naslov']=1, ['stanje']=1}
	local badargs = {}
	local numlist = {}
	for k, v in pairs(args) do
		if knownargs[k] then
		elseif type(k) == 'string' then
			local n = tonumber(k:match('^p(%d+)$') or k:match('pos(%d+)') or '-1')
			if k:match('^p%d+$') and n >= 0 and n <= 99 then
				table.insert(numlist, k:match('^p(%d+)$'))
			elseif args.nonumbers and (k:match('^pos%d+$') and n >= 0 and n <= 99) then
				if v and v ~= '' then haspos = true end
			elseif v and v ~= '' then
				table.insert(badargs, k)
			end
		elseif v and v ~= '' then
			table.insert(badargs, k)
		end
	end
	table.sort(
		numlist,
		function (a, b) 
			return tonumber(a) < tonumber(b) or (tonumber(a) == tonumber(b) and #a > #b)
		end
	)
	local pv = require('Modul:If preview')
	local preview, tracking = '', ''
	if #badargs > 0 then
		for k, v in pairs(badargs) do
			if v == '' then	v = ' '	end
			v = mw.ustring.gsub(v, '[^%w\-_ ]', '?')
			preview = preview .. pv._warning({
				'Page using national squad with unknown parameter "' .. v .. '".'
			})
			tracking = tracking .. '[[Category:Pages using national squad with unknown parameters|' .. v .. ']]'
		end
	end
	if (args['naslov'] == nil and args['ekipa link'] == nil and args['država_genitiv'] == nil) or args['takmič'] == nil then
		tracking = tracking .. '[[Category:Pages using national squad with unknown parameters|!]]'
	end
	if not args['takmič link'] then
		tracking = tracking .. '[[Category:Pages using national squad without comp link]]'
	end
	if not args['sport'] then
		if not args['ekipa link'] then
			tracking = tracking .. '[[Category:Pages using national squad without sport or team link]]'
		end
	end
	if sport ~= 'Nogometna' and sport ~= 'nogometna' and sport ~= 'Futsalska' and sport ~= 'futsalska' and sport ~= 'Košarkaška' and sport ~= 'košarkaška' then
		if not args['ekipa link'] then
			local sortkey = mw.ustring.gsub(sport, '[^A-Za-z]', ' ')
			tracking = tracking .. '[[Category:Pages using national squad without team link and with an atypical sport|' .. sortkey .. ' ]]'
		end
	end
		if (sport ~= 'Nogometna' or sport ~= 'nogometna') and (sport ~= 'Futsalska' or sport ~= 'futsalska') and (sport ~= 'Košarkaška' or sport ~= 'košarkaška') then
		if not args['ekipa link'] then
			local sortkey = mw.ustring.gsub(sport, '[^A-Za-z]', ' ')
			tracking = tracking .. '[[Category:Pages using national squad without team link and with an atypical sport|' .. sortkey .. ' ]]'
		end
	end
	if prefixes[args.spol or ''] == nil then
		tracking = tracking .. '[[Category:Pages using national squad with unsupported gender]]'
	end
	if args.ime == nil then
		tracking = tracking .. '[[Category:Pages using national squad without name]]'
	end
	-- if tracking ~= '' and mw.title.getCurrentTitle().namespace > 0 then tracking = '' end
	
	local list1 = args.list or ''
	if list1 == '' then
		for i,k in ipairs(numlist) do
			if args['p' .. k] then
				local n = args.nonumbers and (args['pos' .. k] or '') or tostring(k)
				if n ~= '' or haspos == true then
					list1 = list1 .. string.format(
						'*%s&nbsp;<span class="vcard agent"><span class="fn">%s</span></span>\n',
						n, args['p' .. k])
				else
					list1 = list1 .. string.format(
						'*<span class="vcard agent"><span class="fn">%s</span></span>\n', args['p' .. k])
				end
			end
		end
		if args.selektor then
			list1 = list1 .. string.format(
				'*<span class="vcard agent">%s:&nbsp;<span class="fn">%s</span></span>',
				coach_label, args.selektor)
		end
	end
	local list3 = args['bilješka'] and ('' .. args['bilješka'] .. '') or nil
	
	return require('Modul:Navbox')._navbox({
		name = args.ime,
		state = args_stanje or 'autocollapse',
		titlestyle = titlestyle, 
		listclass = 'hlist', bodyclass = 'vcard', titleclass = 'fn org',
		title = title, list1 = list1, list3 = list3
	}) .. tracking .. preview
end

return p
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy