Marvel Database
Advertisement
Marvel Database

La documentazione per questo modulo può essere creata in Modulo:StaffCorrection/man

local p = {}
local StaffNames = mw.loadData('Module:StaffCorrection/data')
local h = require("Module:HF")

function p.lua_get_corrected_name(name)
	local output = ''
	
	if not h.isempty(name)
		then output = StaffNames[ string.lower( mw.text.trim(name) ) ] or mw.text.trim(name)
	end
	
	return output
end


function p.get_corrected_name(frame)
	return p.lua_get_corrected_name(frame.args[1])
end


function p.lua_get_staff_link_and_category(name, subcategory)
	local corrected_name = ''
	local s = ''
	local category = ''
	local output = ''
	
	if not h.isempty(name)
		then
			name = mw.text.trim(name)
			name = h.break_link(name, 1)
			s = string.lower(name)
			if h.in_list( {'non accreditato', 'n/a'}, s )
				then output = 'Non Accreditato'
				else
					corrected_name = p.lua_get_corrected_name(name)
					output = h.Link(corrected_name, name)
					if not h.isempty(subcategory)
						then category = corrected_name..'/'..subcategory
					end
			end
	end
	
	return output, category
end


function p.lua_get_creators(list)
	local i
	local link
	local category
	local links = ''
	local categories = ''

	if not h.isempty(list)
		then
			links = {}
			categories = {}
			list = mw.text.split(list, ';')
			for i = 1, #list do
				link, category = p.lua_get_staff_link_and_category(list[i], 'Creatore')
				table.insert(links, link)
				table.insert(categories, category)
			end
			links = mw.text.listToText(links, ', ', ', ')
	end
	
	return links, categories
end


function p.get_creators(frame)
	local getArgs = require('Dev:Arguments').getArgs
	local args = getArgs (frame)
	local list = args[1]
	local links
	local categories

	links, categories = p.lua_get_creators(list)
	return links..h.add_categories(categories)
end


return p
Advertisement