Modul:Citát

Z Wikislovníku
Skočit na navigaci Skočit na vyhledávání

Dokumentaci tohoto modulu lze vytvořit na stránce Nápověda:Modul:Citát

local p = {}

local function IsLanguageCode (code)
	local Language = require( 'Modul:Languages' )
	if Language[code] ~= nil then
		return true
	else
		return false
	end
end

function p.print (frame)
	local out = ""
	local arg = frame:getParent().args
	local languageCode = false
	if arg[1] then
		if IsLanguageCode(arg[1]) then
			languageCode = arg[1]
		else
			return "CHYBA! Špatný kód jazyka!"
		end
	else
		if arg["jazyk"] and arg["jazyk"] ~= "" then
			if IsLanguageCode (arg["jazyk"]) then
				languageCode = arg["jazyk"]
			else
				return "CHYBA! Špatný kód jazyka!"
			end
		end
	end

	local text = false
	if arg[2] then
		if arg[2] ~= "" then
			text = arg[2]
		else
			return "CHYBA! Nezadán text citace!"
		end
		if arg["text"] and arg["text"] ~= "" then
			return "CHYBA! Citace zadána dvakrát!"
		end
	else
		if arg["text"] then
			if arg["text"] ~= "" then
				text = arg["text"]
			else
				return "CHYBA! Nezadán text citace!"
			end
		end
	end
	local translation = false
	if arg[3] then
		if arg[3] ~= "" then
			translation = arg[3]
		else
			return "CHYBA! Nezadán text překladu!"
		end
		if arg["překlad"] and arg["překlad"] ~= "" then
			return "CHYBA! Překlad zadán dvakrát!"
		end
	else
		if arg["překlad"] then
			if arg["překlad"] ~= "" then
				translation = arg["překlad"]
			else
				return "CHYBA! Nezadán text překladu!"
			end
		end
	end
	
	
	local autor = arg["autor"] or ""
	
	local dilo = arg["dílo"] or ""
	
	if arg["wikizdroje"] and arg["wikizdroje"] ~= "" then
		dilo = "[[:s:" .. arg["wikizdroje"] .. "|" .. dilo .. "]]"
	end
	
	local priznak = false
	if arg["příznak"] and arg["příznak"] ~= "" then
		priznak = arg["příznak"]
	end
	
	local rok = arg["rok"] or ""
	
	if text then
		out = out .. "''"
		if priznak == "zast." then
			out = out .. "<span style=\"color:#72777d\">"
		end
		out = out .. text 
		if priznak then
			out = out .. "</span>"
		end
		
		out = out .. "''"
		if dilo ~= "" then
			out = out .. "<br />"
			out = out .. "<small>— ("
			if autor ~= "" then
				out = out .. autor .. ": " 
			end
			out = out .. dilo .. ". " 
			if rok ~= "" then
				out = out .. rok .. "."
			end
			out = out .. ")</small>"
		end
	end

	return out
end
return p