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