Documentation icon Τεκμηρίωση module[δημιουργία]
export = {}

local Lf = {} --τοπικές συναρτήσεις
local Ld = {} --τοπικές μεταβλητές, μπορούν να έχουν τα ίδια ονόματα με τις συναρτήσεις

local exists = function(arg)
	local larg = arg or ''
	return (larg ~= '')
end

local toblank = function(arg)
	local larg = arg or ''
	return larg
end

local firstof = function(arg1, arg2, ...)
	if exists(arg1) then return arg1 end
	if exists(arg2) then return arg2 end
	local args = { ... }
	local n = select( '#', ... )
	for xcounter in 1,n do
		if exists(args(xcounter)) then return args(xcounter) end
	end
	return ''
end

export.main = function(frame)
	local lc = {}
    lc['παράμετροι από την κλήση'] = frame.args
    --lc['args'] = frame:getParent().args
	return export.noframe(lc['παράμετροι από την κλήση'])
end

-- ' .. toblank(argh['']) .. '
export.noframe= function(argh)
	local lc = {}
	lc['κείμενο'] = ''
	if toblank(argh['header'])  ~= 'yes' then
		lc['κείμενο'] = lc['κείμενο'] .. '<table class="infobox ' .. toblank(argh['bodyclass']) .. '" cellspacing="5" style="width:22em; text-align:left; font-size:88%; line-height:1.5em; ' .. toblank(argh['bodystyle']) .. '">'
	end
	if exists(argh['title']) then
		lc['κείμενο'] = lc['κείμενο'] .. '<caption class="' .. toblank(argh['titleclass']) .. '" style="font-size:125%; font-weight:bold; ' .. toblank(argh['titlestyle']) .. '">' .. toblank(argh['title']) .. '</caption>'
	end
	if exists(argh['above']) then
		lc['κείμενο'] = lc['κείμενο'] .. Lf['row']({header=toblank(argh['above']),
			headerstyle='text-align:center; font-size:125%; font-weight:bold; ' .. toblank(argh['abovestyle']),
			class=toblank(argh['aboveclass']),
			rowclass=toblank(argh['aboverowclass'])
			})
	end

	if exists(argh['subheader']) then
		lc['κείμενο'] = lc['κείμενο'] .. Lf['row']({data=argh['subheader'] ,
			datastyle= toblank(argh['subheaderstyle']),
			class=toblank(argh['subheaderclass']),
			rowclass= argh['subheaderrowclass']
			})
	end
	for xcounter = 1,2 do
		local subheaderN = 'subheader' .. tostring(xcounter)
		local subheaderrowclassN = 'subheaderrowclass' .. tostring(xcounter)
		local subheaderstyleN = 'subheaderstyle'
		local subheaderclassN = 'subheaderclass'
		if exists(argh[subheaderN]) then
			lc['κείμενο'] = lc['κείμενο'] .. Lf['row']({data= argh[subheaderN] ,
				datastyle= toblank(argh[subheaderstyleN]),
				class=toblank(argh[subheaderclassN]),
				rowclass= toblank(argh[subheaderrowclassN])
				})
		end
	end
	--nonum image
	if exists(argh['image']) then
		local datastring = toblank(argh['image'])
		if exists(argh['caption']) then
			datastring = datastring .. toblank(argh['caption']) .. '|<br /><span style="' .. toblank(argh['captionstyle']) .. '">' .. toblank(argh['caption']) .. '</span>'
		end
		lc['κείμενο'] = lc['κείμενο'] .. Lf['row']({data=  datastring,
			datastyle= toblank(argh['imagestyle']),
			class=toblank(argh['imageclass']),
			rowclass= toblank(argh['imagerowclass'])
			})
	end
	--numbered images
	for xcounter = 1,6 do
		local imageN = 'image' .. tostring(xcounter)
		local imagerowclassN = 'imagerowclass' .. tostring(xcounter)
		local captionN = 'caption' .. tostring(xcounter)
		
		if exists(argh[imageN]) then
			local datastring = toblank(argh[imageN])
			if exists(argh[captionN]) then
				datastring = datastring .. toblank(argh[captionN]) .. '|<br /><span style="' .. toblank(argh['captionstyle']) .. '">' .. toblank(argh[captionN]) .. '</span>'
			end
			lc['κείμενο'] = lc['κείμενο'] .. Lf['row']({data=  datastring,
				datastyle= toblank(argh['imagestyle']),
				class=toblank(argh['imageclass']),
				rowclass= toblank(argh[imagerowclassN])
				})
		end
	end
	for xcounter = 1,99 do
		local headerN = 'header' .. tostring(xcounter)
		local labelN = 'label' .. tostring(xcounter)
		local dataN = 'data' .. tostring(xcounter)
		local classN = 'class' .. tostring(xcounter)
		local rowclassN = 'rowclass' .. tostring(xcounter)
		local rowstyleN = 'rowstyle' .. tostring(xcounter)
		local headerstyleN = 'headerstyle'
		local labelstyleN = 'labelstyle'
		local datastyleN = 'datastyle'
		--TODO: Stop if blank found? Stop in 81?
		if exists(argh[headerN]) or exists(argh[dataN]) then
			lc['κείμενο'] = lc['κείμενο'] .. Lf['row']({header = argh[headerN],
			headerstyle = toblank(argh[headerstyleN]),
			label = toblank(argh[labelN]),
			labelstyle = toblank(argh[labelstyleN]),
			data = toblank(argh[dataN]),
			datastyle = toblank(argh[datastyleN]),
			class = toblank(argh[classN]),
			rowclass = toblank(argh[rowclassN])
			})
		end

	end
	return lc['κείμενο']
end

Lf['row'] = function( tabledargs)
	local lc = {}
    lc['κείμενο'] = ''
    lc['header'] = tabledargs['header'] or ''
    lc['class'] = tabledargs['class'] or ''
    lc['headerstyle'] = tabledargs['headerstyle'] or ''
    lc['data'] = tabledargs['data'] or ''
    lc['rowclass'] = tabledargs['rowclass'] or ''
    lc['rowstyle'] = tabledargs['rowstyle'] or ''
    lc['label'] = tabledargs['label'] or ''
    lc['labelstyle'] = tabledargs['labelstyle'] or ''
    lc['datastyle'] = tabledargs['datastyle'] or ''

    if lc['header'] ~= '' then
    	lc['κείμενο'] = lc['κείμενο'] .. '<tr><th colspan="2" class="' .. lc['class'] .. '" style="text-align:center; ' .. lc['headerstyle'] .. '">' .. lc['header'] .. '</th></tr>'
    else
	    if lc['data'] ~= '' then
	    	lc['κείμενο'] = lc['κείμενο'] .. '<tr class="' .. lc['rowclass'] .. '" '
	    	if lc['rowstyle'] ~= '' then
	    		lc['κείμενο'] = lc['κείμενο'] .. 'style="' .. lc['rowstyle'] .. '"'
			end
			lc['κείμενο'] = lc['κείμενο'] .. '>'
			--εδώ έχει κάποιο πρόβλημα και στο πρότυπο; (δεν έχει έλεγχο για datastyle)
			if lc['label'] ~= '' then 
				lc['κείμενο'] = lc['κείμενο'] .. '<th scope="row" style="text-align:left; ' .. lc['labelstyle'] .. '">' .. lc['label'] .. '</th><td class="' .. lc['class']  .. '" style="' .. lc['datastyle'] .. '">'
			else
				lc['κείμενο'] = lc['κείμενο'] .. '<td colspan="2" class="' .. lc['class'] .. '" style="text-align:center; ' .. lc['datastyle'] .. '">'
			end
		end
	end
	lc['κείμενο'] = lc['κείμενο'] .. lc['data'] .. '</td></tr>'
	return lc['κείμενο']
end

return export