index = {}
for i,c in ipairs(controllers) do
- local module = "luci.controller." .. c:sub(#path+1, #c):gsub("/", ".")
+ local modname = "luci.controller." .. c:sub(#path+1, #c):gsub("/", ".")
for _, suffix in ipairs(suffixes) do
- module = module:gsub(suffix.."$", "")
+ modname = modname:gsub(suffix.."$", "")
end
- local mod = require(module)
+ local mod = require(modname)
local idx = mod.index
if type(idx) == "function" then
- index[module] = idx
+ index[modname] = idx
end
end
end
end
- local pageaction = true
http.header("X-CBI-State", state or 0)
+
if not config.noheader then
tpl.render("cbi/header", {state = state})
end
+
+ local redirect
+ local messages
+ local applymap = false
+ local pageaction = true
+ local parsechain = { }
+
for i, res in ipairs(maps) do
- res:render()
+ if res.apply_needed and res.parsechain then
+ local c
+ for _, c in ipairs(res.parsechain) do
+ parsechain[#parsechain+1] = c
+ end
+ applymap = true
+ end
+
+ if res.redirect then
+ redirect = redirect or res.redirect
+ end
+
if res.pageaction == false then
pageaction = false
end
+
+ if res.message then
+ messages = messages or { }
+ messages[#messages+1] = res.message
+ end
end
+
+ for i, res in ipairs(maps) do
+ res:render({
+ firstmap = (i == 1),
+ applymap = applymap,
+ redirect = redirect,
+ messages = messages,
+ pageaction = pageaction,
+ parsechain = parsechain
+ })
+ end
+
if not config.nofooter then
- tpl.render("cbi/footer", {flow = config, pageaction=pageaction, state = state, autoapply = config.autoapply})
+ tpl.render("cbi/footer", {
+ flow = config,
+ pageaction = pageaction,
+ redirect = redirect,
+ state = state,
+ autoapply = config.autoapply
+ })
end
end