Modul:Cimec

De la Wikipedia, enciclopedia liberă

Documentația acestui modul poate fi creată la Modul:Cimec/doc

globalFrame = nil
cimec = {};
local coords = require("Modul:Coordonate")
local getArgs = require('Modul:Arguments').getArgs

function cimec.clasate_buildLinks(args)
	return "[https://clasate.cimec.ro/Detaliu.asp?tit=&k=" .. args["url_inp"] .. " Cimec]"
	--args["url_sursă"]
	--args["q"]
end

-- This function implements {{Bun mobil clasat}}
function cimec.clasate_getElementLine(frame)
	globalFrame = frame
	local args = getArgs(frame)
	--mw.logObject(args)
	if args['Imagine'] then
		foto = "[[" .. args['Imagine'] .. "|faracadru|150px]]"
	else
		foto = ""
	end
	name = (args['Nume'] or "")
	if args['Tip'] then name = name .. "<br/>''Tip:'' " .. args['Tip'] end
	if args['Autor'] then name = name .. "<br/>''Autor:'' " .. args['Autor'] end
	description = ""
	for _,arg in ipairs({"Descriere", "Descriere_avers", "Descriere_revers", "Descriere_exergă", "Legendă_revers"}) do
		if description == "" then newline = "" else newline = "<br/>" end
		if arg == "Descriere" then 
			label = "" 
		else 
			label,_ = mw.ustring.gsub(arg, "_", " ")
			label = "''" .. label .. ":'' "
		end
		if args[arg] then description = description .. newline .. label .. args[arg] end
	end
	owner = args['Deținător']
	details = ""
	for _,arg in ipairs({"Datare", "Școală", "Descoperit", "Dimensiuni", "Material"}) do
		if details == "" then newline = "" else newline = "<br/>" end
		if args[arg] then details = details .. newline .. "''" ..arg .. ":'' " .. args[arg] end
	end
	if args['Locație'] then owner = owner .. ", " .. args['Locație'] end
	domain = args['Domeniu']
	category = args['Categorie']
	order = args['Clasare']
	links = cimec.clasate_buildLinks(args)

	local htmlRow = mw.html.create('tr')
		:tag('td'):wikitext(foto):done()
		:tag('td'):wikitext(name):done()
		:tag('td'):wikitext(details):done()
		:tag('td'):wikitext(description):done()
		:tag('td'):wikitext(owner):done()
		:tag('td'):wikitext(links):done()
		
	htmlRow:allDone()
	return tostring(htmlRow)
end

-- This function implements {{ÎnceputTabelClasate}}
function cimec.clasate_getHeaderLine(frame)
	globalFrame = frame
	local htmlRow = mw.html.create('tr')
		:tag('th'):wikitext('Foto'):done()
		:tag('th'):wikitext('Informații generale'):done()
		:tag('th'):wikitext('Detalii tehnice'):done()
		:tag('th'):wikitext('Descriere'):done()
		:tag('th'):wikitext('Deținător'):done()
		:tag('th'):wikitext('Legături'):done()

	if frame:getParent().args["erori"] ~= nil and frame:getParent().args["erori"] ~= 1 then
		htmlRow:done()
	else
		htmlRow:done()--tag('th'):attr('class', 'noprint nomobile unsortable'):wikitext('Erori'):done()
	end
	htmlRow:allDone()
	return tostring(htmlRow)
end


return cimec