2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
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
10 http://www.apache.org/licenses/LICENSE-2.0
19 return (rowcnt % 2) + 1
24 <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
25 <% if self.title and #self.title > 0 then -%>
26 <legend><%=self.title%></legend>
28 <div class="cbi-section-descr"><%=self.description%></div>
29 <div class="cbi-section-node">
30 <%- local count = 0 -%>
31 <table class="cbi-section-table">
32 <tr class="cbi-section-table-titles">
33 <%- if not self.anonymous then -%>
34 <%- if self.sectionhead then -%>
35 <th class="cbi-section-table-cell"><%=self.sectionhead%></th>
40 <%- for i, k in pairs(self.children) do if not k.optional then -%>
41 <th class="cbi-section-table-cell">
42 <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
44 <%- if k.titleref then -%></a><%- end -%>
46 <%- count = count + 1; end; end; if self.extedit or self.addremove then -%>
47 <th class="cbi-section-table-cell"> </th>
48 <%- count = count + 1; end -%>
50 <tr class="cbi-section-table-descr">
51 <%- if not self.anonymous then -%>
52 <%- if self.sectiondesc then -%>
53 <th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
58 <%- for i, k in pairs(self.children) do if not k.optional then -%>
59 <th class="cbi-section-table-cell"><%=k.description%></th>
60 <%- end; end; if self.extedit or self.addremove then -%>
61 <th class="cbi-section-table-cell"></th>
64 <%- local isempty = true
65 for i, k in ipairs(self:cfgsections()) do
68 scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
70 <tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
71 <% if not self.anonymous then -%>
72 <th><h3><%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%></h3></th>
77 for k, node in ipairs(self.children) do
78 if not node.optional then
79 node:render(section, scope or {})
84 <%- if self.extedit or self.addremove then -%>
85 <td class="cbi-section-table-cell">
86 <%- if self.extedit then -%>
88 <%- if type(self.extedit) == "string" then -%>
89 <%=self.extedit:format(section)%>
90 <%- elseif type(self.extedit) == "function" then -%>
91 <%=self:extedit(section)%>
93 " title="<%:Edit%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:Edit%>" /></a>
94 <%- end; if self.addremove then %>
95 <input type="image" value="<%:Delete%>" onclick="this.form.cbi_state='del-section'; return true" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
102 <%- if isempty then -%>
103 <tr class="cbi-section-table-row">
104 <td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
109 <% if self.error then %>
110 <div class="cbi-section-error">
111 <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
112 <li><%=pcdata(e):gsub("\n","<br />")%></li>
117 <%- if self.addremove then -%>
118 <% if self.template_addremove then include(self.template_addremove) else -%>
119 <div class="cbi-section-create cbi-tblsection-create">
120 <% if self.anonymous then %>
121 <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:Add%>" />
123 <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
124 <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
125 <input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />
126 <% if self.invalid_cts then -%>
127 <br /><%:Invalid%></div>