Modul:Error: Porovnání verzí

Z Wikipedie, otevřené encyklopedie
Smazaný obsah Přidaný obsah
Danny B. (diskuse | příspěvky)
Error
(Žádný rozdíl)

Verze z 18. 4. 2013, 13:19

-- @brief
--  Error handling.
-- 
-- @author
--  [[meta:User:Danny B.]]
local Error = {}
----------------------------------------


-- @brief
--  Generate the error message.
-- 
-- @param
--  errorData Table
-- 
-- @return
--  Wikitext
function Error.getMessage( errorData )
	
	local output
	local template = mw.text.trim( errorData.template or "" )
	local text = mw.text.trim( errorData.text or "" )
	
	
	if template ~= "" then
		template = "<nowiki>{{</nowiki>[[Šablona:" .. template .. "|" .. template .. "]]<nowiki>}}</nowiki> — "
	end
	
	if text ~= "" then
		text = ": " .. template .. text
	elseif template ~= "" then
		text = ": " .. template .. "Chybné vložení."
	end
	
	output = "<strong class=\"error\">CHYBA" .. text .. "</strong>"
	
	return output
	
end


-- @brief
--  Generate the error category.
-- 
-- @param
--  errorData Table
-- 
-- @return
--  Wikitext
function Error.getCategory( errorData )
	
	local output
	local template = mw.text.trim( errorData.template or "" )
	local category = mw.text.trim( errorData.category or "" )
	
	
	if category ~= "" then
		if template ~= "" then
			category = category .. " v šabloně " .. template
		end
	else
		category = mw.text.trim( "Opravit chybné volání šablony " .. template )
	end
	
	output = "[[Kategorie:Údržba:" .. category .. "]]"
	
	return output
	
end


-- @brief
--  Generate the error message and error category.
-- 
-- @param
--  errorData Table
-- 
-- @return
--  Wikitext
function Error.getText( errorData )
	
	local output = ""
	
	
	output = output .. Error.getMessage( errorData )
	output = output .. "<includeonly>" .. Error.getCategory( errorData ) .. "</includeonly>"
	
	return output
	
end


----------------------------------------
return Error