* luci/themes: fix xml errors triggered by query strings in menu entries
[project/luci.git] / themes / fledermaus / luasrc / view / themes / fledermaus / 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$
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("default")
34 require("luci.http").prepare_content("text/html")
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">
41 <head>
42 <link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
43 <% if node and node.css then %><link rel="stylesheet" type="text/css" href="<%=resource%>/<%=node.css%>" /><% end %>
44 <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
45 <meta http-equiv="content-script-type" content="text/javascript" />
46 <title><%=striptags( hostname .. ( (node and node.title) and ' - ' .. 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="header"><div id="header2">
67 <span id="header3">freifunk kamikaze</span><br />
68 <span id="header4">now with even more bats and stuff</span>
69 </div></div>
70
71 <div class="pathbar separator black whitetext bold">
72 <%:path%>: <%
73 local c = tree
74 local url = controller
75 for k,v in pairs(request) do
76 if c.nodes and c.nodes[v] then
77 c = c.nodes[v]
78 url = url .. "/" .. v
79 %><a href="<%=url%>"><%=c.title or v%></a> <% if k ~= #request then %>&#187; <% end
80 end
81 end
82 %>
83 </div>
84
85 <div class="menubar">
86 <div id="mainmenu" class="mainmenu">
87 <%-
88 local function submenu(prefix, node)
89 if not node.nodes or node.hidden then
90 return false
91 end
92 local index = {}
93 local count = 0
94 for k, n in pairs(node.nodes) do
95 if n.title and n.target then
96 table.insert(index, {name=k, order=n.order or 100})
97 count = count + 1
98 end
99 end
100
101 table.sort(index, function(a, b) return a.order < b.order end)
102
103 if count > 0 then
104 %>
105 <ul>
106 <%- for j, v in pairs(index) do
107 if not v.hidden and #v.name > 0 then
108 local nnode = node.nodes[v.name]
109 local href = controller .. prefix .. v.name
110 href = (nnode.query) and href .. luci.http.build_querystring(nnode.query) or href
111 %>
112 <li>
113 <span<% if nnode._menu_selected then %> class="active"<%end%>><a href="<%=luci.util.pcdata(href)%>"><%=nnode.title%></a></span>
114 <%- submenu(prefix .. v.name .. "/", nnode) %>
115 </li>
116 <%- end %>
117 <%- end %>
118 </ul>
119 <%-
120 end
121 end
122
123 if cattree and cattree.nodes then
124 local index = {}
125 for k, node in pairs(cattree.nodes) do
126 table.insert(index, {name=k, order=node.order or 100})
127 end
128
129 table.sort(index, function(a, b) return a.order < b.order end)
130
131 for i, k in ipairs(index) do
132 node = cattree.nodes[k.name]
133 if not node.hidden and node.title and node.target then
134 local href = controller.."/"..category.."/"..k.name
135 href = (k.query) and href .. luci.http.build_querystring(k.query) or href %>
136 <div<% if node._menu_selected then %> class="preactive"<%end%>><a href="<%=href%>"><%=node.title%></a>
137 <%submenu("/" .. category .. "/" .. k.name .. "/", node)%>
138 </div>
139 <% end
140 end
141 end
142 %>
143 </div>
144 <div class="modemenu">
145 <ul><%
146 for k,node in pairs(tree.nodes) do
147 if node.title and not node.hidden then %>
148 <li<% if request[1] == k then %> class="active"<%end%>><a href="<%=controller%>/<%=k%>"><%=node.title%></a></li>
149 <% end
150 end%>
151 </ul>
152 </div>
153
154 <%
155 if tree.nodes[category] and tree.nodes[category].ucidata then
156 local ucic = 0
157
158 for i, j in pairs(require("luci.model.uci").cursor():changes()) do
159 for k, l in pairs(j) do
160 for m, n in pairs(l) do
161 ucic = ucic + 1;
162 end
163 end
164 end
165 %>
166 <div class="mainmenu" style="float:right; margin-right:2em">
167 <div>
168 <% if ucic > 0 then %>
169 <a class="warning" href="<%=controller%>/<%=category%>/uci/changes"><%:unsavedchanges%>: <%=ucic%></a>
170 <% submenu("/" .. category .. "/uci/", tree.nodes[category].nodes["uci"]) -%>
171 <% else %>
172 <a href="#"><%:changes%>: 0</a>
173 <% end %>
174 </div>
175 </div>
176 <% end %>
177
178 <br class="clear" />
179 </div>
180 <div id="content">