themes: filter menu entry title through translate()
[project/luci.git] / themes / freifunk / luasrc / view / themes / freifunk / 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 -%>
13 <%
14 require("luci.sys")
15 local load1, load5, load15 = luci.sys.loadavg()
16 local request  = require("luci.dispatcher").context.path
17 local category = request[1]
18 local tree     = luci.dispatcher.node()
19 local cattree  = category and luci.dispatcher.node(category)
20 local node     = luci.dispatcher.context.dispatched
21 local hostname = luci.sys.hostname()
22
23 local c = tree
24 for i,r in ipairs(request) do
25         if c.nodes and c.nodes[r] then
26                 c = c.nodes[r]
27                 c._menu_selected = true
28         end
29 end
30
31 require("luci.i18n").loadc("base")
32 require("luci.http").prepare_content("text/html")
33
34 -%>
35
36 <?xml version="1.0" encoding="utf-8"?>
37 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
38 <html xmlns="http://www.w3.org/1999/xhtml">
39 <head>
40         <link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
41         <% if node and node.css then %><link rel="stylesheet" type="text/css" href="<%=resource%>/<%=node.css%>" /><% end %>
42         <link rel="shortcut icon" href="<%=media%>/images/favicon.ico" />
43         <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
44         <meta http-equiv="content-script-type" content="text/javascript" />
45         <script type="text/javascript" src="<%=resource%>/xhr.js"></script>
46         <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
47
48         <!--[if lt IE 7]>
49                 <script type="text/javascript">
50                         function setup_hover() {
51                                 function ie_hover(e) {
52                                         e.onmouseover = function() { this.className = "hover" }
53                                         e.onmouseout  = function() { this.className = null    }
54                                 }
55
56                                 var lis  = document.getElementById("mainmenu").getElementsByTagName("LI");
57                                 var divs = document.getElementById("mainmenu").getElementsByTagName("DIV");
58
59                                 for( var i = 0; i < lis.length;  i++ ) ie_hover( lis[i]  );
60                                 for( var i = 0; i < divs.length; i++ ) ie_hover( divs[i] );
61                         }
62                 </script>
63         <![endif]-->
64 </head>
65 <body onload="window.setup_hover && setup_hover()">
66 <div id="all">
67 <center>
68
69 <div id="wrapper">
70 <%- if luci.sys.user.getuser("root") and not luci.sys.user.getpasswd("root") then -%>
71         <div class="warning">
72                 <strong><%:No password set!%></strong><br />
73                 <%:There is no password set on this router. Please configure a root password to protect the web interface and enable SSH.%>
74         </div>
75 <%- end -%>
76 <div id="main">
77
78
79 <div id="header">
80         <div id="headerleft">
81                 <div id="headerright">
82                         <div id="headerback">
83         <div id="schriftzug"><img src="<%=media%>/images/schriftzug.png" alt="Freifunk  ueberschrift" name="Freifunk_nordost_ueberschrift" border="0"> </div>
84         <div id="logo"><img src="<%=media%>/images/logo.png" alt="Freifunk logo" name="Freifunk_nordost" border="0"></a></div>
85         <div class="clear"></div>
86
87                         </div>
88                 </div>
89         </div>
90 </div>
91
92 <div class="pathbar separator black whitetext bold">
93 <%:Path%>: <%
94 local c = tree
95 local url = controller
96 for k,v in pairs(request) do
97         if c.nodes and c.nodes[v] then
98                 c = c.nodes[v]
99                 url = url .. "/" .. v
100         %><a href="<%=url%>"><%=pcdata(striptags(translate(c.title) or v))%></a> <% if k ~= #request then %>&#187; <% end
101         end
102 end
103 %>
104 </div>
105
106 <div class="menubar">
107         <div id="mainmenu" class="mainmenu">
108 <%-
109 local function submenu(prefix, node)
110         if not node.nodes or node.hidden then
111                 return false
112         end
113         local index = {}
114         local count = 0
115         for k, n in pairs(node.nodes) do
116                 if n.title and n.target then
117                         table.insert(index, {name=k, order=n.order or 100})
118                         count = count + 1
119                 end
120         end
121
122         table.sort(index, function(a, b) return a.order < b.order end)
123
124         if count > 0 then
125 %>
126         <ul>
127         <%- for j, v in pairs(index) do
128                 if not v.hidden and #v.name > 0 then
129                         local nnode = node.nodes[v.name]
130                         local href = controller .. prefix .. v.name
131                         href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
132                 %>
133                 <li>
134                         <span<% if nnode._menu_selected then %> class="active"<%end%>><a href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(nnode.title)))%></a></span>
135                         <%- submenu(prefix .. v.name .. "/", nnode) %>
136                 </li>
137                 <%- end %>
138         <%- end %>
139         </ul>
140 <%-
141         end
142 end
143
144 if cattree and cattree.nodes then
145         local index = {}
146         for k, node in pairs(cattree.nodes) do
147                 table.insert(index, {name=k, order=node.order or 100})
148         end
149
150         table.sort(index, function(a, b) return a.order < b.order end)
151
152         for i, k in ipairs(index) do
153                 node = cattree.nodes[k.name]
154                 if not node.hidden and node.title and node.target then
155                         local href = controller.."/"..category.."/"..k.name
156                         href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
157                         <div<% if node._menu_selected then %> class="preactive"<%end%>><a href="<%=pcdata(href)%>"><%=pcdata(striptags(translate(node.title)))%></a>
158                                 <%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
159                         </div>
160 <%              end
161         end
162 end
163 %>
164         </div>
165         <div class="modemenu">
166                 <ul><%
167                         for k,node in pairs(tree.nodes) do
168                                 if node.title and not node.hidden then %>
169                                         <li<% if request[1] == k then %> class="active"<%end%>><a href="<%=controller%>/<%=k%>"><%=pcdata(translate(node.title))%></a></li>
170 <%                              end
171                         end%>
172                 </ul>
173         </div>
174
175         <%
176                 if tree.nodes[category] and tree.nodes[category].ucidata then
177                         local ucic = 0
178
179                         for i, j in pairs(require("luci.model.uci").cursor():changes()) do
180                                 for k, l in pairs(j) do
181                                         for m, n in pairs(l) do
182                                                 ucic = ucic + 1;
183                                         end
184                                 end
185                         end
186         %>
187         <div class="mainmenu" style="float:right; margin-right:2em">
188                 <div>
189                         <% if ucic > 0 then %>
190                         <a class="warning" href="<%=controller%>/<%=category%>/uci/changes"><%:Unsaved Changes%>: <%=ucic%></a>
191                         <% submenu("/" .. category .. "/uci/", tree.nodes[category].nodes["uci"]) -%>
192                         <% else %>
193                         <a href="#"><%:Changes%>: 0</a>
194                         <% end %>
195                 </div>
196         </div>
197         <% end %>
198
199         <br class="clear" />
200 </div>
201 <div id="maincontent">
202 <% if category ~= "freifunk" and category ~= "splash" then %>
203 <noscript>
204         <div class="warning">
205                 <strong><%:Java Script required!%></strong><br />
206                 <%:You must enable Java Script in your browser or LuCI will not work properly.%>
207         </div>
208 </noscript>
209 <%end%>