2 Copyright 2009 Daniel Dickinson
3 Licensed to the public under the Apache License 2.0.
10 return (rowcnt % 2) + 1
15 <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
16 <% if self.title and #self.title > 0 then -%>
17 <legend><%=self.title%></legend>
19 <div class="cbi-section-descr"><%=self.description%></div>
20 <div class="cbi-section-node">
21 <%- local count = 0 -%>
22 <table class="cbi-section-table">
23 <tr class="cbi-section-table-titles">
24 <%- if not self.anonymous then -%>
25 <%- if self.sectionhead then -%>
26 <th class="cbi-section-table-cell"><%=self.sectionhead%></th>
31 <%- for i, k in pairs(self.children) do if not k.optional then -%>
32 <th class="cbi-section-table-cell">
33 <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
35 <%- if k.titleref then -%></a><%- end -%>
37 <%- count = count + 1; end; end; if self.extedit or self.addremove then -%>
38 <th class="cbi-section-table-cell"> </th>
39 <%- count = count + 1; end -%>
41 <tr class="cbi-section-table-descr">
42 <%- if not self.anonymous then -%>
43 <%- if self.sectiondesc then -%>
44 <th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
49 <%- for i, k in pairs(self.children) do if not k.optional then -%>
50 <th class="cbi-section-table-cell"><%=k.description%></th>
51 <%- end; end; if self.extedit or self.addremove then -%>
52 <th class="cbi-section-table-cell"></th>
55 <%- local isempty = true
56 for i, k in ipairs(self:cfgsections()) do
59 scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
61 <tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
62 <% if not self.anonymous then -%>
63 <th><h3><%=k%></h3></th>
66 <%- for k, node in ipairs(self.children) do -%>
67 <%- if not node.optional then -%>
68 <%- nodevalue = node:cfgvalue(section) -%>
69 <%- if nodevalue and ( nodevalue ~= "" ) and string.find(nodevalue, 'http://', 1, plain) then
71 node.template = "diag/smapvalue"
74 <%- node:render(section, scope or {}) -%>
78 <%- if self.extedit or self.addremove then -%>
79 <td class="cbi-section-table-cell">
80 <%- if self.extedit then -%>
82 <%- if type(self.extedit) == "string" then -%>
83 <%=self.extedit:format(section)%>
84 <%- elseif type(self.extedit) == "function" then -%>
85 <%=self:extedit(section)%>
87 " title="<%:Edit%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:Edit%>" /></a>
88 <%- end; if self.addremove then %>
89 <input type="image" value="<%:Delete%>" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
96 <%- if isempty then -%>
97 <tr class="cbi-section-table-row">
98 <td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
103 <% if self.error then %>
104 <div class="cbi-section-error">
105 <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
106 <li><%=luci.util.pcdata(e):gsub("\n","<br />")%></li>
111 <%- if self.addremove then -%>
112 <% if self.template_addremove then include(self.template_addremove) else -%>
113 <div class="cbi-section-create cbi-smapsection-create">
114 <% if self.anonymous then %>
115 <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:Add%>" />
117 <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
118 <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
119 <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" title="<%:Add%>" />
120 <% if self.invalid_cts then -%>
121 <br /><%:Invalid%></div>
129 <!-- /smapsection -->