Modul:Vorlage:Erweiterte Navigationsleiste

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen
Vorlagenprogrammierung Diskussionen Lua Unterseiten
Modul Deutsch English

Modul: Dokumentation

Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus


--
-- adapted from [[en:Module:Navbox]] and [[en:Module:Navbar]]
--

local p = {}

local templatestyles = 'Erweiterte Navigationsleiste/styles.css'
local lucky, TemplatePar = pcall( require, "Module:TemplatePar" ) -- require parameter check
if type( TemplatePar ) == "table" then
    TemplatePar = TemplatePar.TemplatePar()
else
    return "<span class='error'>" .. TemplatePar .. "</span>"
end

local getArgs -- lazily initialized

--
-- NAVBAR
--
local ul

local function addItem (mini, full, link, descrip, args, url)
	local l
	if url then
		l = {'[', '', ']'}
	else
		l = {'[[', '|', ']]'}
	end
	ul:tag('li')
		:addClass('nv-'..full)
		:wikitext(l[1] .. link .. l[2])
		:tag(args.mini and 'abbr' or 'span')
			:attr('title', descrip)
			:cssText(args.fontstyle)
			:wikitext(args.mini and mini or full)
			:done()
		:wikitext(l[3])
end

local function brackets (position, c, args, div)
	if args.brackets then
		div
			:tag('span')
				:css('margin-'..position, '-0.125em')
				:cssText(args.fontstyle)
				:wikitext(c)
	end
end

local function navbar(args)
	local show = {true, true, true, false, false, false}
	local titleArg = 1
	
	if args.collapsible then
		titleArg = 2
		if not args.plain then args.mini = 1 end
		if args.fontcolor then
			args.fontstyle = 'color:' .. args.fontcolor .. ';'
		end
		args.style = 'float:left; text-align:left'
	end
	
	if args.noedit then show[3] = false end
	
	local titleText = args[titleArg] or (':' .. mw.getCurrentFrame():getParent():getTitle())
	local title = mw.title.new(mw.text.trim(titleText), 'Vorlage')
	if not title then
		return
--		error('Invalid title ' .. titleText)
	end
	local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''
	
	local div = mw.html.create():tag('div')
	div
		:addClass('plainlinks')
		:addClass('navbox-hlist')
		:addClass('navbox-navbar')
		:addClass('nomobile')
		:cssText(args.style)

	if args.mini then div:addClass('navbox-mini') end

	if not (args.mini or args.plain) then
		div
			:tag('span')
				:css('word-spacing', 0)
				:cssText(args.fontstyle)
				:wikitext(args.text or 'This box:')
				:wikitext(' ')
	end
	
	brackets('right', '&#91; ', args, div)
	
	ul = div:tag('ul')
	if show[1] then addItem('v', 'view', title.fullText, 'Vorlage anzeigen', args) end
	if show[2] then addItem('d', 'talk', talkpage, 'Diskussion', args) end
	if show[3] then addItem('b', 'edit', title:fullUrl('action=edit'), 'Bearbeiten', args, true) end
	if show[4] then addItem('vg', 'hist', title:fullUrl('action=history'), 'Versionsgeschichte', args, true) end
	if show[5] then
		local move = mw.title.new ('Special:Movepage')
		addItem('vs', 'move', move:fullUrl('target='..title.fullText), 'Verschieben', args, true) end
	if show[6] then addItem('beo', 'watch', title:fullUrl('action=watch'), 'Beobachten', args, true) end
	
	brackets('left', ' &#93;', args, div)
	
	if args.collapsible then
		div
			:done()
		:tag('div')
			:css('font-size', '114%')
			:css('margin', args.mini and '0 4em' or '0 7em')
			:cssText(args.fontstyle)
			:wikitext(args[1])
	end

	return tostring(div:done())
end

--
-- NAVBOX
--
local args
local border
local listnums
local ODD_EVEN_MARKER = '\127_ODDEVEN_\127'
local RESTART_MARKER = '\127_ODDEVEN0_\127'
local REGEX_MARKER = '\127_ODDEVEN(%d?)_\127'

local function striped(wikitext, stylesheet, parameterissue)
	-- Return wikitext with markers replaced for odd/even striping.
	-- Child (subgroup) navboxes are flagged with a category that is removed
	-- by parent navboxes. The result is that the category shows all pages
	-- where a child navbox is not contained in a parent navbox.
	local orphanCat = '[[Kategorie:Wikipedia:Vorlagenfehler/Vorlage:Erweiterte Navigationsleiste/Verwaiste Untergruppe]]'
	if border == 'subgroup' then
		-- No change; striping occurs in outermost navbox.
		return wikitext .. orphanCat
	end
	local first, second = 'odd', 'even'
	if args.Zebra then
		if args.Zebra == 'umgekehrt' then
			first, second = second, first
		else
			if args.Zebra == '1' then 
				args.Zebra = 'odd'
			elseif args.Zebra == '2' then
				args.Zebra = 'even'
			end
			first = args.Zebra
			second = first
		end
	end
	local changer
	if first == second then
		changer = first
	else
		local index = 0
		changer = function (code)
			if code == '0' then
				-- Current occurrence is for a group before a nested table.
				-- Set it to first as a valid although pointless class.
				-- The next occurrence will be the first row after a title
				-- in a subgroup and will also be first.
				index = 0
				return first
			end
			index = index + 1
			return index % 2 == 1 and first or second
		end
	end
	local regex = orphanCat:gsub('([%[%]])', '%%%1')
	return (stylesheet .. (parameterissue or "") .. wikitext:gsub(regex, ''):gsub(REGEX_MARKER, changer))  -- () omits gsub count
end

local function processItem(item, nowrapitems)
	if item:sub(1, 2) == '{|' then
		-- Applying nowrap to lines in a table does not make sense.
		-- Add newlines to compensate for trim of x in |parm=x in a template.
		return '\n' .. item ..'\n'
	end
	item = mw.text.trim( item ):gsub('\n%s+', '\n') -- ignore whitespace at beginning of newline
	if not item:match ("{|") then
		item = item:gsub("\n([^%*<])", " %1") -- listed items without table/ul/ol
	end
	if nowrapitems == '1' then
		local lines = {}
		for line in (item .. '\n'):gmatch('([^\n]*)\n') do
			local prefix, content = line:match('^([*:;#]+)%s*(.*)')
			if prefix and not content:match('^<span class="navbox-nowrap">') then
				line = prefix .. '<span class="navbox-nowrap">' .. content .. '</span>'
			end
			table.insert(lines, line)
		end
		item = table.concat(lines, '\n')
	end
	if item:match('^[*:;#]') then
		return '\n' .. item ..'\n'
	end
	return item
end

--
--   Above/Below rows
--
local function getAboveBelowColspan()
	local ret = 2
	if args["Bild-links"] then ret = ret + 1 end
	if args.Bild then ret = ret + 1 end
	return ret
end

local function renderAboveRow(tbl)
	if not args.Untertitel and not args.Untertitel2 then return end
	local aboveclass
	if args["Untertitel-Class"] then
		if args["Untertitel-Class"] == '0' then
			aboveclass = nil
		else
			aboveclass = args["Untertitel-Class"]
		end
	else
		aboveclass = 'navbox-hlist'
	end
	local abovestyle, abovestyle2
	if args.Farbschema and args.Farbschema ~= "speziell" then
		if args.Farbschema == "einheitlich" and args.Farbe then
			abovestyle = "background-color:" .. args.Farbe
		elseif args.Farbschema == "eigen" and args.Farbe2 then
			abovestyle = "background-color:#" .. args.Farbe2
		elseif args.Farbschema == "grau" then
			abovestyle = "background-color:#EAEAEA"
		elseif args.Farbschema == "navbox" then
			abovestyle = "background-color:#E6E6FF"
		end
	elseif args["Untertitel-Style"] then
		abovestyle = args["Untertitel-Style"]
	end
	if args["Untertitel2-Style"] then
		abovestyle2 = args["Untertitel2-Style"]
	else
		abovestyle2 = abovestyle
	end
	
	if args.Untertitel then
		tbl:tag('tr')
			:tag('td')
				:addClass('navbox-abovebelow')
				:addClass(aboveclass)
				:cssText(args.Style)
				:cssText(abovestyle)
				:attr('colspan', getAboveBelowColspan())
				:tag('div')
					:wikitext(processItem(args.Untertitel, args.Nowrap))
	end
	if args.Untertitel2 then
		tbl:tag('tr')
			:tag('td')
				:addClass('navbox-abovebelow')
				:addClass(aboveclass)
				:cssText(args.Style)
				:cssText(abovestyle2)
				:attr('colspan', getAboveBelowColspan())
				:tag('div')
					:wikitext(processItem(args.Untertitel2, args.Nowrap))
	end
end

local function renderBelowRow(tbl)
	if not args.Weiteres and not args.Weiteres2 and not args.Anmerkungen then return end
	local belowclass
	if args["Weiteres-Class"] then
		if args["Weiteres-Class"] == '0' then 
			belowclass = nil 
		else
			belowclass = args["Weiteres-Class"]
		end
	else
		belowclass = 'navbox-hlist'
	end
	local belowstyle
	if args.Farbschema and args.Farbschema ~= "speziell" then
		if args.Farbschema == "einheitlich" and args.Farbe then
			belowstyle = "background-color:" .. args.Farbe
		elseif args.Farbschema == "eigen" and args.Farbe2 then
			belowstyle = "background-color:#" .. args.Farbe2
		elseif args.Farbschema == "grau" then
			belowstyle = "background-color:#EAEAEA"
		elseif args.Farbschema == "navbox" then
			belowstyle = "background-color:#E6E6FF"
		end
	elseif args["Weiteres-Style"] then
		belowstyle = args["Weiteres-Style"]
	end
	local boldbelow = "font-weight:bold"
	if args.NoBold then
		boldbelow = nil
	end
	
	if args.Weiteres then
		tbl:tag('tr')
			:tag('td')
				:addClass('navbox-abovebelow')
				:addClass(belowclass)
				:cssText(args.Style)
				:cssText(boldbelow)
				:cssText(belowstyle)
				:attr('colspan', getAboveBelowColspan())
				:tag('div')
					:wikitext(processItem(args.Weiteres, args.Nowrap))
	end
	if args.Weiteres2 then
		tbl:tag('tr')
			:tag('td')
				:addClass('navbox-abovebelow')
				:addClass(belowclass)
				:cssText(args.Style)
				:cssText(boldbelow)
				:cssText(belowstyle)
				:attr('colspan', getAboveBelowColspan())
				:tag('div')
					:wikitext(processItem(args.Weiteres2, args.Nowrap))
	end
	if args.Anmerkungen then
		tbl:tag('tr')
			:tag('td')
				:addClass('navbox-abovebelow')
				:cssText(args.Style)
				:cssText(belowstyle)
				:cssText('text-align:left')
				:attr('colspan', getAboveBelowColspan())
				:tag('div')
					:wikitext(processItem(args.Anmerkungen, args.Nowrap))
	end
end

--
--   List rows
--
local function renderListRow(tbl, index, listnum)
	local row = tbl:tag('tr')
	local listclass
	if args["Inhalt-Class"] then
		if args["Inhalt-Class"] == '0' then 
			listclass = nil 
		else
			listclass = args["Inhalt-Class"]
		end
	else
		listclass = 'navbox-hlist'
	end
	local groupstyle
	if args["Gruppen-Style"] then
		groupstyle = args["Gruppen-Style"]
	elseif args.Farbschema and args.Farbschema ~= "speziell" then
		if args.Farbschema == "einheitlich" and args.Farbe then
			groupstyle = "background-color:" .. args.Farbe
		elseif args.Farbschema == "eigen" and args.Farbe2 then
			groupstyle = "background-color:#" .. args.Farbe2
		elseif args.Farbschema == "grau" then
			groupstyle = "background-color:#EAEAEA"
		elseif args.Farbschema == "navbox" then
			groupstyle = "background-color:#E6E6FF"
		elseif args.Farbschema == "unscheinbar" then
			groupstyle = "background-color:#F5F5F5"
		end
	end

	if index == 1 and args["Bild-links"] then
		local imageleft = args["Bild-links"]
		if not imageleft:match("%[%[") then
			if not (imageleft:match("Datei:") or imageleft:match("File:") or imageleft:match("Bild:") or imageleft:match("Image:")) then
				imageleft = "[[Datei:" .. args["Bild-links"]
			else
				imageleft = "[[" .. args["Bild-links"]
			end
			if args["Bild-links-px"] then
				imageleft = imageleft .. "|" .. args["Bild-links-px"]
				if not args["Bild-links-px"]:match("px$") then
					imageleft = imageleft .. "px"
				end
			else
				imageleft = imageleft .. "|200px"
			end
			if args["Bild-links-Beschreibung"] then
				imageleft = imageleft .. "|" .. args["Bild-links-Beschreibung"]
			end
			imageleft = imageleft .. "|alt=]]"
		end
		row
			:tag('td')
				:addClass('navbox-image')
				:css('width', '1px')               -- Minimize width
				:css('padding', '0 2px 0 0')
				:cssText(args["Bild-links-Style"])
				:attr('rowspan', #listnums)
				:tag('div')
					:wikitext(processItem(imageleft))
	end

	if args['Gruppe' .. listnum] then
		local groupCell = row:tag('th')

		groupCell
			:attr('scope', 'row')
			:addClass('navbox-group')
			:addClass(args["Gruppen-Class"])
			:cssText(args.Style)
			:css('width', args["Gruppen-Breite"] or '1%') -- If groupwidth not specified, minimize width
			:cssText(groupstyle)
			:cssText(args['Gruppe' .. listnum .. '-Style'])
			:wikitext(args['Gruppe' .. listnum])
	end

	local listCell = row:tag('td')

	if args['Gruppe' .. listnum] then
		listCell
			:css('text-align', 'left')
			:css('border-left-width', '2px')
			:css('border-left-style', 'solid')
	else
		listCell:attr('colspan', 2)
	end

	if not args["Gruppen-Breite"] then
		listCell:css('width', '99%')
	end

	local rowstyle  -- usually nil so cssText(rowstyle) usually adds nothing
	if index % 2 == 1 then
		rowstyle = args["Zebra1-Style"]
	else
		rowstyle = args["Zebra2-Style"]
	end

	local listText = args['Inhalt' .. listnum]
	local oddEven = ODD_EVEN_MARKER
	if listText:sub(1, 12) == '</div><table' then
		-- Assume list text is for a subgroup navbox so no automatic striping for this row.
		oddEven = listText:find('<th[^>]*"navbox%-title"') and RESTART_MARKER or 'odd'
	end
	local listnumclass
	if args['Inhalt' .. listnum .. '-Class'] then
		if args['Inhalt' .. listnum .. '-Class'] == '0' then 
			listnumclass = nil 
		else
			listnumclass = args['Inhalt' .. listnum .. '-Class']
		end
		listclass = listnumclass
	end
	listCell
	--	:css('padding', '0')
		:cssText(args["Inhalt-Style"])
		:cssText(rowstyle)
		:cssText(args['Inhalt' .. listnum .. '-Style'])
		:addClass('navbox-list')
		:addClass('navbox-' .. oddEven)
		:addClass(listclass)
		:tag('div')
			:css('padding', (index == 1 and args["Inhalt1-Padding"]) or args["Inhalt-Padding"] or '0 0.25em')
			:wikitext(processItem(listText, args.Nowrap))

	if index == 1 and args.Bild then
		local imageright = args["Bild"]
		if not imageright:match("%[%[") then
			if not (imageright:match("Datei:") or imageright:match("File:") or imageright:match("Bild:") or imageright:match("Image:")) then
				imageright = "[[Datei:" .. args["Bild"]
			else
				imageright = "[[" .. args["Bild"]
			end
			if args["Bild-px"] then
				imageright = imageright .. "|" .. args["Bild-px"]
				if not args["Bild-px"]:match("px$") then
					imageright = imageright .. "px"
				end
			else
				imageright = imageright .. "|200px"
			end
			if args["Bild-Beschreibung"] then
				imageright = imageright .. "|" .. args["Bild-Beschreibung"]
			end
			imageright = imageright .. "|alt=]]"
		end
		row
			:tag('td')
				:addClass('navbox-image')
				:css('width', '1px')               -- Minimize width
				:css('padding', '0 0 0 2px')
				:cssText(args.Bildstyle)
				:attr('rowspan', #listnums)
				:tag('div')
					:wikitext(processItem(imageright))
	end
end


--
--   Tracking categories
--
local function hasBackgroundColors()
	for _, key in ipairs({'Titel-Style', 'Gruppen-Style', 'Style', 'Untertitel-Style', 'Weiteres-Style'}) do
		if tostring(args[key]):find('background', 1, true) then
			return true
		end
	end
end

local function hasBorders()
	for _, key in ipairs({'Gruppen-Style', 'Style', 'Untertitel-Style', 'Weiteres-Style'}) do
		if tostring(args[key]):find('border', 1, true) then
			return true
		end
	end
end

local function getTrackingCategories()
	local cats = {}
	if hasBackgroundColors() then table.insert(cats, 'Individuelle Hintergrundfarben') end
	if hasBorders() then table.insert(cats, 'Individueller Rahmen') end
	return cats
end

local function renderTrackingCategories(builder)
	local title = mw.title.getCurrentTitle()
	if title.namespace ~= 10 then return end -- not in template space
	local subpage = title.subpageText
	if subpage == 'doc' or subpage == 'sandbox' or subpage == 'testcases' then return end

	for _, cat in ipairs(getTrackingCategories()) do
		builder:wikitext('[[Kategorie:Wikipedia:Vorlagenwartung/Vorlage:Erweiterte Navigationsleiste/' .. cat .. ']]')
	end
end

--
--   Main navbox tables
--
local function renderMainTable()
	local bodyclass = args["Box-Class"]
	local div = mw.html.create('div')
		:addClass('NavContent')
	local tbl = mw.html.create('table')
		:tag('table')
			:addClass('navbox-nowraplinks')
			:addClass(bodyclass)

	tbl:css('border-spacing', 0)
	if border == 'subgroup' or border == 'none' then
		tbl
			:addClass('navbox-subgroup')
			:cssText(args["Box-Style"])
			:cssText(args.Style)
	else  -- regular navbox - bodystyle and style will be applied to the wrapper table
		tbl
			:addClass('navbox-inner')
			:css('background', 'transparent')
			:css('color', 'inherit')
	end
	tbl:cssText(args["Innen-Style"])

	renderAboveRow(tbl)
	for i, listnum in ipairs(listnums) do
		renderListRow(tbl, i, listnum)
	end
	renderBelowRow(tbl)
	
	if border == 'subgroup' or border == 'none' then
		return tbl
	else
		return div:node(tbl) -- wrap in NavContent div
	end
end

function p._navbox(navboxArgs, stylesheet)
	args = navboxArgs
	listnums = {}

	for k, _ in pairs(args) do
		if type(k) == 'string' then
			local listnum = k:match('^Inhalt(%d+)$')
			if listnum then 
				table.insert(listnums, tonumber(listnum))
			end
		end
	end
	table.sort(listnums)
	
	-- parameter check
	local parametercheck = {
		["optional"] = {	"Titel",
							"Titel-Style",
							"Titel-Class",
							"Style",
							"Name",
							"Untertitel",
							"Untertitel2",
							"Untertitel-Style",
							"Untertitel2-Style",
							"Untertitel-Class",
							"Weiteres",
							"Weiteres2",
							"Weiteres-Style",
							"Weiteres-Class",
							"Anmerkungen",
							"Rahmen",
							"1",
							"Farbschema",
							"Farbe",
							"Farbe1",
							"Farbe2",
							"Bild",
							"Bild-oben",
							"Bild-links",
							"Bildstyle",
							"Bild-links-Style",
							"Bild-Beschreibung",
							"Bild-px",
							"Bild-oben-Beschreibung",
							"Bild-oben-px",
							"Bild-links-Beschreibung",
							"Bild-links-px",
							"Gruppen-Breite",
							"Gruppen-Style",
							"Gruppen-Class",
							"Box-Style",
							"Box-Class",
							"Inhalt-Style",
							"Inhalt-Class",
							"check",
							"Nowrap",
							"Zebra",
							"Zebra1-Style",
							"Zebra2-Style",
							"Einbindung"
						},
		["template"]  = "[[Vorlage:Erweiterte Navigationsleiste|Erweiterte Navigationsleiste]]",
		["cat"]		  = "Wikipedia:Vorlagenfehler/Vorlage:Erweiterte Navigationsleiste/Parameter unbekannt oder veraltet",
		["format"]    = "0",
		["preview"]   = "1"
	}
	for n = 0, #listnums+1 do
		local m = n + 1
		table.insert (parametercheck["optional"], "Inhalt" .. m)
		table.insert (parametercheck["optional"], "Gruppe" .. m)
		table.insert (parametercheck["optional"], "Inhalt" .. m .. "-Style")
		table.insert (parametercheck["optional"], "Gruppe" .. m .. "-Style")
		table.insert (parametercheck["optional"], "Inhalt" .. m .. "-Class")
	end
	local parameterissue
	if not args.Einbindung then
		parameterissue = TemplatePar.check(parametercheck)
	end
	-- /

	border = mw.text.trim(args.Rahmen or args[1] or '')
	if border == 'Untergruppe' or border == 'child' then
		border = 'subgroup'
	end
	
	-- render title row of the navbox
	local navbardisplay
	local titleimage
	local titlestyle
	if args.Farbschema and args.Farbschema ~= "speziell" then
		if args.Farbschema == "einheitlich" and args.Farbe then
			titlestyle = "background-color:" .. args.Farbe
		elseif args.Farbschema == "eigen" and args.Farbe1 then
			titlestyle = "background-color:#" .. args.Farbe1
		elseif args.Farbschema == "grau" or args.Farbschema == "unscheinbar" then
			titlestyle = "background-color:#EAECF0"
		elseif args.Farbschema == "navbox" then
			titlestyle = "background-color:#D2D2FF"
		end
	elseif args["Titel-Style"] then
		titlestyle = args["Titel-Style"]
	end
	
	if args.Name and mw.getCurrentFrame():getParent():getTitle() ~= 'Vorlage:Erweiterte Navigationsleiste' then
		if args.Name:match ("&#123;&#123;") then
			args.Name = args.Name:gsub("&#123;", ""):gsub("&#125;", ""):gsub("Vorlage:", "")
		end
		navbardisplay = navbar{
			args.Name,
			mini = 1,
			fontstyle = 'border:none; box-shadow:none; padding:0;'
		}
	end
	if args["Bild-oben"] then
		titleimage = '<div class="NavPic"><span class="nomobile noviewer" aria-hidden="true" role="presentation">[[Datei:' .. args["Bild-oben"]
		if args["Bild-oben-px"] then
			titleimage = titleimage .. '|' .. args["Bild-oben-px"]
		elseif args.Untertitel then
			titleimage = titleimage .. '|' .. 'x30px'
		else
			titleimage = titleimage .. '|' .. 'x15px'
		end
		if args["Bild-oben-Beschreibung"] then
			titleimage = titleimage .. '|' .. args["Bild-oben-Beschreibung"]
		end
		titleimage = titleimage .. '|alt=]]</span></div>'
	end
	local title = ""
	if args.Titel then
		title = title .. (titleimage or '') 
		title = title .. '<div class="NavHead navbox-group navbox-title' .. (args["Titel-Class"] or '') .. '" style="'
		if titlestyle then
			title = title .. titlestyle .. ';' 
		end
		if args.Style then
			title = title .. args.Style .. ';' 
		end
		title = title .. '">' .. (navbardisplay or '')
		title = title .. '<span style="font-size:108%;">' .. (processItem(args.Titel) or '') .. '</span>'
	end
	title = title .. '</div>'

	-- render the main body of the navbox
	local tbl = renderMainTable()

	-- render the appropriate wrapper around the navbox, depending on the border param
	local res = mw.html.create()
	if border == 'none' then
		local nav = res:tag('div')
			:attr('role', 'navigation')
			:wikitext(title)
			:node(tbl)
		-- aria-labelledby title, otherwise above, otherwise lone group
		if args.Titel or args.Untertitel or (args.Gruppe1 and not args.Gruppe2) then
			nav:attr('aria-labelledby', mw.uri.anchorEncode(args.Titel or args.Untertitel or args.Gruppe1))
		else
			nav:attr('aria-label', 'Erweiterte Navigationsleiste')
		end
	elseif border == 'subgroup' then
		-- We assume that this navbox is being rendered in a list cell of a parent navbox, and is
		-- therefore inside a div with padding:0 0.25em. We start with a </div> to avoid the
		-- padding being applied, and at the end add a <div> to balance out the parent's </div>
		res:wikitext('</div>')
		if args.Titel then res:wikitext(title) end
		res
			:node(tbl)
			:wikitext('<div style="padding:0">')
	else
		local nav = res:tag('div')
			:attr('role', 'navigation')
			:addClass('navbox-container')
			:addClass('NavFrame')
			:addClass('erweiterte-navigationsleiste')
			:addClass('navigation-not-searchable')
			:cssText(args["Box-Style"])
			:cssText(args.Style)
			:wikitext(title)
			:node(tbl)
		-- aria-labelledby title, otherwise above, otherwise lone group
		if args.Titel or args.Untertitel or (args.Gruppe1 and not args.Gruppe2) then
			nav:attr('aria-labelledby', mw.uri.anchorEncode(args.Titel or args.Untertitel or args.Gruppe1))
		else
			nav:attr('aria-label', 'Erweiterte Navigationsleiste')
		end
	end

--	if (args.Nocat or 'false'):lower() == 'false' then
--		renderTrackingCategories(res)
--	end
	return striped(tostring(res), stylesheet, parameterissue)
end

function p.navbox(frame)
	if not getArgs then
		getArgs = require('Module:Arguments').getArgs
	end
	args = getArgs(frame, {wrappers = 'Vorlage:Erweiterte Navigationsleiste/Lua'})
	if frame.args.Rahmen then
		-- This allows Template:Navbox_subgroup to use {{#invoke:Navbox|navbox|border=...}}.
		args.Rahmen = frame.args.Rahmen
	end

	-- Read the arguments in the order they'll be output in, to make references number in the right order.
	local _
	_ = args.Titel
	_ = args.Untertitel
	for i = 1, 20 do
		_ = args["Gruppe" .. tostring(i)]
		_ = args["Inhalt" .. tostring(i)]
	end
	_ = args.Weiteres
	
	local stylesheet = frame:extensionTag{ name = 'templatestyles', args = { src = templatestyles} }

	return p._navbox(args, stylesheet)
end

-- get the template name of the actual navbox
function p.Name(frame)
	local ret = frame:getParent():getTitle()
	return ret or ""
end

return p