summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2012-01-24 21:58:30 +0000
committerTed Trask <ttrask01@yahoo.com>2012-01-24 21:58:30 +0000
commit9c895383e4fd8de8726c0b5dd60d62316abe6f57 (patch)
tree659d5b373a5911f96572c319db227efad2bd863e /lib
parentcd186cf6d5b7b775001f919797e7c621661ea2fa (diff)
downloadacf-core-9c895383e4fd8de8726c0b5dd60d62316abe6f57.tar.bz2
acf-core-9c895383e4fd8de8726c0b5dd60d62316abe6f57.tar.xz
Fixed menubuilder to only take the first menu file for a prefix/controller combination
Diffstat (limited to 'lib')
-rw-r--r--lib/menubuilder.lua92
1 files changed, 48 insertions, 44 deletions
diff --git a/lib/menubuilder.lua b/lib/menubuilder.lua
index 1b8e23b..43f2eba 100644
--- a/lib/menubuilder.lua
+++ b/lib/menubuilder.lua
@@ -62,59 +62,63 @@ end
get_menuitems = function (self)
local cats = {}
local reversecats = {}
+ local foundcontrollers = {}
for p in string.gmatch(self.conf.appdir, "[^,]+") do
p = (string.gsub(p, "/$", "")) --remove trailing /
for k,filename in pairs(get_candidates(p)) do
local controller = string.gsub(posix.basename(filename), ".menu$", "")
local prefix = (string.gsub(posix.dirname(filename), p, "")).."/"
+ if not foundcontrollers[prefix.."/"..controller] then
+ foundcontrollers[prefix.."/"..controller] = true
- -- open the menu file, and parse the contents
- local handle = io.open(filename)
- for x in handle:lines() do
- local result = parse_menu_line(x)
- if result then
- for i = 1,1 do -- loop so break works
- -- Add the category
- if nil == reversecats[result.cat] then
- table.insert ( cats,
- { name=result.cat,
- groups = {},
- reversegroups = {} } )
- reversecats[result.cat] = #cats
- end
- local cat = cats[reversecats[result.cat]]
- cat.priority = cat.priority or result.cat_prio
- -- Add the group
- if nil == result.group then break end
- if nil == cat.groups[cat.reversegroups[result.group]] then
- table.insert ( cat.groups,
- { name = result.group,
- controllers = {},
- reversetabs = {},
- tabs = {} } )
- cat.reversegroups[result.group] = #cat.groups
- end
- cat.groups[cat.reversegroups[result.group]].controllers[prefix..controller] = true
- local group = cat.groups[cat.reversegroups[result.group]]
- group.priority = group.priority or result.group_prio
- -- Add the tab
- if nil == result.tab or nil == result.action then break end
- local tab = { name = result.tab,
- controller = controller,
- prefix = prefix,
- action = result.action }
- table.insert(group.tabs, tab)
- if group.reversetabs[tab.name] then
- -- Flag for two tabs of same name
- group.flag = tab.name
- table.insert(group.reversetabs[tab.name], #group.tabs)
- else
- group.reversetabs[tab.name] = {#group.tabs}
- end
+ -- open the menu file, and parse the contents
+ local handle = io.open(filename)
+ for x in handle:lines() do
+ local result = parse_menu_line(x)
+ if result then
+ for i = 1,1 do -- loop so break works
+ -- Add the category
+ if nil == reversecats[result.cat] then
+ table.insert ( cats,
+ { name=result.cat,
+ groups = {},
+ reversegroups = {} } )
+ reversecats[result.cat] = #cats
+ end
+ local cat = cats[reversecats[result.cat]]
+ cat.priority = cat.priority or result.cat_prio
+ -- Add the group
+ if nil == result.group then break end
+ if nil == cat.groups[cat.reversegroups[result.group]] then
+ table.insert ( cat.groups,
+ { name = result.group,
+ controllers = {},
+ reversetabs = {},
+ tabs = {} } )
+ cat.reversegroups[result.group] = #cat.groups
+ end
+ cat.groups[cat.reversegroups[result.group]].controllers[prefix..controller] = true
+ local group = cat.groups[cat.reversegroups[result.group]]
+ group.priority = group.priority or result.group_prio
+ -- Add the tab
+ if nil == result.tab or nil == result.action then break end
+ local tab = { name = result.tab,
+ controller = controller,
+ prefix = prefix,
+ action = result.action }
+ table.insert(group.tabs, tab)
+ if group.reversetabs[tab.name] then
+ -- Flag for two tabs of same name
+ group.flag = tab.name
+ table.insert(group.reversetabs[tab.name], #group.tabs)
+ else
+ group.reversetabs[tab.name] = {#group.tabs}
+ end
+ end
end
end
+ handle:close()
end
- handle:close()
end
end