themes: filter menu entry title through translate()
[project/luci.git] / themes / freifunk-hannover / luasrc / view / themes / freifunk-hannover / header.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id: header.htm 4079 2009-01-17 17:59:11Z Cyrus $
13
14 -%>
15 <%
16 require("luci.sys")
17 local load1, load5, load15 = luci.sys.loadavg()
18 local request  = require("luci.dispatcher").context.path
19 local category = request[1]
20 local tree     = luci.dispatcher.node()
21 local cattree  = category and luci.dispatcher.node(category)
22 local node     = luci.dispatcher.context.dispatched
23 local hostname = luci.sys.hostname()
24
25 local c = tree
26 for i,r in ipairs(request) do
27         if c.nodes and c.nodes[r] then
28                 c = c.nodes[r]
29                 c._menu_selected = true
30         end
31 end
32
33 require("luci.i18n").loadc("base")
34 require("luci.http").prepare_content("application/xhtml+xml")
35
36 -%>
37
38 <?xml version="1.0" encoding="utf-8"?>
39 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
40 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
41 <head>
42 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
43 <meta http-equiv="Content-Script-Type" content="text/javascript" />
44 <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
45 <!--[if lt IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie6.css" /><![endif]-->
46 <!--[if IE 7]><link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/ie7.css" /><![endif]-->
47 <% if node and node.css then %><link rel="stylesheet" type="text/css" media="screen" href="<%=resource%>/<%=node.css%>" />
48 <% end -%>
49 <script type="text/javascript" src="<%=resource%>/VarType.js"></script>
50 <script type="text/javascript" src="<%=resource%>/XHTML1.js"></script>
51 <script type="text/javascript" src="<%=resource%>/Dropdowns.js"></script>
52 <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
53
54 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
55 </head>
56 <body class="lang_<%=luci.i18n.context.lang%>">
57
58
59 <%- if luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
60         <div class="warning">
61                 <strong><%:No password set!%></strong><br />
62                 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
63         </div>
64 <%- end -%>
65
66 <p class="skiplink">
67 <span id="skiplink1"><a href="#navigation"><%:Skip to navigation%></a></span>
68 <span id="skiplink2"><a href="#content"><%:Skip to content%></a></span>
69 </p>
70
71 <div id="header">
72 <h1><%=luci.version.distname%></h1>
73 <p>
74 <%=luci.version.distversion%><br />
75 <%:Load%>: <%="%.2f" % load1%> <%="%.2f" % load5%> <%="%.2f" % load15%><br />
76 <%:Hostname%>: <%=hostname%>
77 </p>
78 </div>
79
80 <div id="menubar">
81 <h2 class="navigation"><a id="navigation" name="navigation"><%:Navigation%></a></h2>
82 <ul id="mainmenu" class="dropdowns">
83 <%-
84 local function submenu(prefix, node)
85         if not node.nodes or node.hidden then
86                 return false
87         end
88         local index = {}
89         local count = 0
90         for k, n in pairs(node.nodes) do
91                 if n.title and n.target then
92                         table.insert(index, {name=k, order=n.order or 100})
93                         count = count + 1
94                 end
95         end
96
97         table.sort(index, function(a, b) return a.order < b.order end)
98
99         if count > 0 then
100 %>
101 <ul id="submenu_<%=string.gsub(string.gsub(prefix, "/", "_"), "^_(.-)_$", "%1")%>">
102 <%-
103                 for j, v in pairs(index) do
104                         if #v.name > 0 then
105                                 local nnode = node.nodes[v.name]
106                                 local href = controller .. prefix .. v.name .. "/"
107                                 href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
108 %>
109 <li><a<% if nnode._menu_selected then %> class="active"<%end%> href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a><%-
110 submenu(prefix .. v.name .. "/", nnode)
111 %></li>
112 <%-
113                         end
114                 end
115 %>
116 </ul>
117 <%
118         end
119 end
120
121 if cattree and cattree.nodes then
122         local index = {}
123         for k, node in pairs(cattree.nodes) do
124                 table.insert(index, {name=k, order=node.order or 100})
125         end
126
127         table.sort(index, function(a, b) return a.order < b.order end)
128
129         for i, k in ipairs(index) do
130                 node = cattree.nodes[k.name]
131                 if node.title and node.target and not node.hidden then
132                         local href = controller.."/"..category.."/"..k.name.."/"
133                         href = (k.query) and href .. luci.http.build_querystring(k.query) or href
134 %>
135 <li><a<% if node._menu_selected then %> class="preactive"<%end%> href="<%=pcdata(href)%>"><%=pcdata(translate(node.title))%></a><%
136 submenu("/" .. category .. "/" .. k.name .. "/", node)
137 %></li><% end
138         end
139 end
140 %>
141 </ul>
142
143 <ul id="modemenu"><%
144 for k,node in pairs(tree.nodes) do
145         if node.title and not node.hidden then %>
146 <li><a<% if request[1] == k then %> class="active"<%end%> href="<%=controller%>/<%=k%>/"><%=pcdata(translate(node.title))%></a></li><%
147         end
148 end
149 %>
150 </ul>
151
152 <%
153 if tree.nodes[category] and tree.nodes[category].ucidata then
154         local ucic = 0
155         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
156                 for k, l in pairs(j) do
157                         for m, n in pairs(l) do
158                                 ucic = ucic + 1;
159                         end
160                 end
161         end
162 -%>
163 <ul id="savemenu" class="dropdowns">
164 <li><% if ucic > 0 then %><a class="warning" href="<%=controller%>/<%=category%>/uci/changes/"><%:Unsaved Changes%>: <%=ucic%></a><%
165 submenu("/" .. category .. "/uci/", tree.nodes[category].nodes["uci"])
166 else -%>
167 <a href="#"><%:Changes%>: 0</a><% end -%>
168 </li>
169 </ul><% end %>
170
171 <div class="clear"></div>
172 </div>
173 <div id="maincontent">
174 <% if category ~= "freifunk" and category ~= "splash" then %>
175 <noscript>
176         <div class="warning">
177                 <strong><%:Java Script required!%></strong><br />
178                 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
179         </div>
180 </noscript>
181 <% end %>