Module:Πρότυπο:επίσης

Από Βικιλεξικό
Μετάβαση στην πλοήγηση Πήδηση στην αναζήτηση

Documentation for this module may be created at Module:Πρότυπο:επίσης/τεκμηρίωση

local export = {}

local nodatastr = "[[Κατηγορία:Λήμματα με πρόβλημα στην κλήση προτύπου]]"
errorhere = function(errstring)
    return '<font color=red>' .. errstring .. '</font>[[Κατηγορία:Σελίδες με σφάλματα στο πρότυπο]]'
end
local function serial_comma_join(seq)
	local hasduplicates=false
	if #seq == 1 then
		return seq[1] -- nothing to join
	end
	local ret = seq[1]
	for i = 2, #seq , 1 do
		local exists = false
		for i2 = i , 1, -1 do
			if seq[i] == seq[i2] then
				exists=true
				hasduplicates=true
			end
		end
		if not exists then 	ret = ret .. ", " .. seq[i] end
	end
	return ret,hasduplicates
end

function export.also(frame)
	local pargs = frame:getParent().args
	local lemma = mw.title.getCurrentTitle().fullText
	local items = {}
	
	for i, arg in ipairs(pargs) do
		if arg ~= lemma then
    		s = "[[" .. arg .. "]]"
			table.insert(items, s)
		end
	end

--εδώ στο cs:Modul:Viz δεν επιστρέφουν, αλλά προσθέτουν το: {{{1}}}
--όμως δεν καταλαβαίνω το λόγο οπότε...
	if #items == 0 then
		return nodatastr
	end
	
	local output,problems = serial_comma_join(items)
	local result = [=[{| class="ανακοίνωση-δείτε" style="border:1px solid #A0CCA0; background: #CCF5AA; padding: .1em; margin-bottom:1em; width:100%"
|-
| align="left" | [[Αρχείο:Noia 64 apps xeyes.png|30px|Τυπογραφικές παραλλαγές]] ''Δείτε επίσης'' : ]=] .. output .. '\n' .. [=[
|-
|}]=]
	if problems then result = result .. '\n' .. errorhere("Υπάρχουν δύο φορές κάποια ορίσματα!") end
	return result
end
 
return export