„Modul:Ikon” változatai közötti eltérés

A Wikipédiából, a szabad enciklopédiából
[ellenőrzött változat][ellenőrzött változat]
Tartalom törölve Tartalom hozzáadva
láthatóikon paraméter, hibatűrőbb
Volánbusz-ikonok javítása
58. sor: 58. sor:
end
end
local args = getArgs(frame, {removeBlanks = false})
local args = getArgs(frame, {removeBlanks = false})
local typ = getType(args[1])
local typ = args[1]
local typ_link = getType(typ)
local city = mw.getCurrentFrame():expandTemplate{ title = 'Ikon/Város', args = { args[2] } }
local city = mw.getCurrentFrame():expandTemplate{ title = 'Ikon/Város', args = { args[2] } }
local list = {}
local list = {}
for i, v in ipairs(args) do
for i, v in ipairs(args) do
if i > 2 and v ~= '' then
if i > 2 and v ~= '' then
table.insert(list, text(v, typ, city))
table.insert(list, text(v, typ_link, city))
end
end
end
end

A lap 2017. május 31., 20:23-kori változata

Ikon[mi ez?] • [dokumentáció: mutat, szerkeszt] • [tesztek: létrehozás]

local p = {}
local getArgs = require('Modul:Arguments').getArgs
local template = nil

local function hanyas(...)
	hanyas = require('Modul:Nyelvtani modul').hanyas
	return hanyas(...)
end

local function getType(typ)
	local name = 'Ikon/Típus'
	if template and mw.title.new(template .. '/Típus', 10).exists then
		name = template .. '/Típus'
	end
	return mw.getCurrentFrame():expandTemplate{ title = name, args = { typ } }
end

local function icon(typ, city)
	local name = 'Ikon/Képek'
	if template and mw.title.new(template .. '/Képek', 10).exists then
		name = template .. '/Képek'
	end
	return mw.getCurrentFrame():expandTemplate{ title = name, args = { typ, city } }
end

local function text(sign, typ, city)
	if template and mw.title.new(template .. '/Szöveg', 10).exists then
		return mw.getCurrentFrame():expandTemplate{ title = template .. '/Szöveg', args = { sign, typ, city } }
	end
	local number = tonumber(sign)
	local title
	if number then
		if (number > 299.5 and number < 899.5) or (number > 999.5 and number < 8999.5) then
			-- 300..899, 1000..8999
			title = string.format('%s %s', hanyas(number), typ)
		else
			-- 1..299, 900..999
			title = string.format('%s %s (%s)', hanyas(number), typ, city)
		end
	else
		if string.lower(sign) == 'tesco' then
			title = string.format('Tesco-busz (%s)', city)
			sign = 'Tesco'
		else
			title = string.format('%s %s (%s)', sign, typ, city)
		end
	end
	if mw.title.new(title) and mw.title.new(title).exists then
		return string.format('[[%s|%s]]', title, sign)
	else
		return sign
	end
end

function p.ikon(frame, name)
	if name then
		template = name
	end
	local args = getArgs(frame, {removeBlanks = false})
	local typ = args[1]
	local typ_link = getType(typ)
	local city = mw.getCurrentFrame():expandTemplate{ title = 'Ikon/Város', args = { args[2] } }
	local list = {}
	for i, v in ipairs(args) do
		if i > 2 and v ~= '' then
			table.insert(list, text(v, typ_link, city))
		end
	end
	list = table.concat(list, ', ')
	if (args['láthatóikon'] or 'igen') == 'igen' then
		return string.format('<span class="noviewer">%s</span> %s', icon(typ, city), list)
	else
		return list
	end
end

setmetatable(p, {
	__index = function(t, name)
		return function(frame)
			return t.ikon(frame, name)
		end
	end
})

return p