summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-02-06 19:45:08 +0000
committerMika Havela <mika.havela@gmail.com>2008-02-06 19:45:08 +0000
commit488d84633e944dda8381ce9e8fd99674702b9e8c (patch)
treed2f0adc9468980f21ae528c7883b7efa87df9a37
parent13c4b25ab45c2ab897140fbafa59eafb9cacf000 (diff)
downloadacf-core-488d84633e944dda8381ce9e8fd99674702b9e8c.tar.bz2
acf-core-488d84633e944dda8381ce9e8fd99674702b9e8c.tar.xz
Changed the way the submenu-tabs is displayed. Now tabs are defined in the .menu files.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@705 ab2d0c66-481e-0410-8bed-d214d4d58bed
-rw-r--r--app/acf_www-controller.lua11
-rw-r--r--app/template-html.lsp6
-rw-r--r--lib/menubuilder.lua15
3 files changed, 22 insertions, 10 deletions
diff --git a/app/acf_www-controller.lua b/app/acf_www-controller.lua
index 4e89db3..6b4bfdf 100644
--- a/app/acf_www-controller.lua
+++ b/app/acf_www-controller.lua
@@ -179,13 +179,10 @@ view_resolver = function(self)
m=require("menubuilder")
local menu = m.get_menuitems(self.conf.appdir)
- -- A quick hack
- submenu = {}
- for k,v in pairs ( self.worker ) do
- if type ( self.worker[k] ) == "function" then
- table.insert (submenu, k)
- end
- end
+ -- Build the submenu table
+ local submenu = m.get_submenuitems(self.conf.appdir)
+ -- Show only tabs for current controller
+ submenu = submenu[pageinfo.controller]
return function (viewtable)
local template = haserl.loadfile (template)
diff --git a/app/template-html.lsp b/app/template-html.lsp
index f042e23..884c5cc 100644
--- a/app/template-html.lsp
+++ b/app/template-html.lsp
@@ -116,13 +116,13 @@ Content-Type: text/html
</div>
<? local class="" ?>
- <? for k,v in pairs(submenu) do
- if v == pageinfo.action then
+ <? for k,v in pairs(submenu or {}) do
+ if submenu[k]["action"] == pageinfo.action then
class="class='selected'"
else
class=""
end
- io.write (string.format('\t\t\t<a %s href="%s">%s</a>\n',class,v,v ))
+ io.write (string.format('\t\t\t<a %s href="%s">%s</a>\n',class,submenu[k]["action"],submenu[k]["tab"] ))
end
?>
diff --git a/lib/menubuilder.lua b/lib/menubuilder.lua
index 6def1fe..ecdf9f1 100644
--- a/lib/menubuilder.lua
+++ b/lib/menubuilder.lua
@@ -37,6 +37,21 @@ local t_compare = function (x,y,f)
return false
end
+-- Returns a table of all submenu items found
+-- Displayorder of the tabs comes from the order in the .menu files
+get_submenuitems = function (startdir)
+ local t = {}
+ local menuitems = get_menuitems(startdir)
+
+ for k,v in pairs(menuitems) do
+ if (menuitems[k]["tab"] ~= "") then
+ if not (t[menuitems[k]["controller"]]) then t[menuitems[k]["controller"]] = {} end
+ table.insert (t[menuitems[k]["controller"]], {tab=menuitems[k]["tab"],action=menuitems[k]["action"]})
+ end
+ end
+
+ return t
+end
-- returns a table of all the menu items found, sorted by priority
-- Table format: prefix controller cat group tab action