libs: merge libs/cbi into libs/web
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 12 Oct 2010 05:15:32 +0000 (05:15 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 12 Oct 2010 05:15:32 +0000 (05:15 +0000)
105 files changed:
contrib/package/luci/Makefile
libs/cbi/htdocs/luci-static/resources/cbi.js [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/add.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/apply.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/arrow.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/download.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/edit.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/fieldadd.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/find.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/help.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/key.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/link.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/reload.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/remove.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/reset.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/save.gif [deleted file]
libs/cbi/htdocs/luci-static/resources/cbi/user.gif [deleted file]
libs/cbi/luasrc/cbi.lua [deleted file]
libs/cbi/luasrc/cbi/datatypes.lua [deleted file]
libs/cbi/luasrc/view/cbi/browser.htm [deleted file]
libs/cbi/luasrc/view/cbi/button.htm [deleted file]
libs/cbi/luasrc/view/cbi/cell_valuefooter.htm [deleted file]
libs/cbi/luasrc/view/cbi/cell_valueheader.htm [deleted file]
libs/cbi/luasrc/view/cbi/compound.htm [deleted file]
libs/cbi/luasrc/view/cbi/delegator.htm [deleted file]
libs/cbi/luasrc/view/cbi/dvalue.htm [deleted file]
libs/cbi/luasrc/view/cbi/dynlist.htm [deleted file]
libs/cbi/luasrc/view/cbi/filebrowser.htm [deleted file]
libs/cbi/luasrc/view/cbi/firewall_zonelist.htm [deleted file]
libs/cbi/luasrc/view/cbi/footer.htm [deleted file]
libs/cbi/luasrc/view/cbi/full_valuefooter.htm [deleted file]
libs/cbi/luasrc/view/cbi/full_valueheader.htm [deleted file]
libs/cbi/luasrc/view/cbi/fvalue.htm [deleted file]
libs/cbi/luasrc/view/cbi/header.htm [deleted file]
libs/cbi/luasrc/view/cbi/lvalue.htm [deleted file]
libs/cbi/luasrc/view/cbi/map.htm [deleted file]
libs/cbi/luasrc/view/cbi/mvalue.htm [deleted file]
libs/cbi/luasrc/view/cbi/network_ifacelist.htm [deleted file]
libs/cbi/luasrc/view/cbi/network_netlist.htm [deleted file]
libs/cbi/luasrc/view/cbi/nsection.htm [deleted file]
libs/cbi/luasrc/view/cbi/nullsection.htm [deleted file]
libs/cbi/luasrc/view/cbi/simpleform.htm [deleted file]
libs/cbi/luasrc/view/cbi/tabcontainer.htm [deleted file]
libs/cbi/luasrc/view/cbi/tabmenu.htm [deleted file]
libs/cbi/luasrc/view/cbi/tblsection.htm [deleted file]
libs/cbi/luasrc/view/cbi/tsection.htm [deleted file]
libs/cbi/luasrc/view/cbi/tvalue.htm [deleted file]
libs/cbi/luasrc/view/cbi/ucisection.htm [deleted file]
libs/cbi/luasrc/view/cbi/upload.htm [deleted file]
libs/cbi/luasrc/view/cbi/value.htm [deleted file]
libs/cbi/luasrc/view/cbi/valuefooter.htm [deleted file]
libs/cbi/luasrc/view/cbi/valueheader.htm [deleted file]
libs/cbi/root/lib/uci/upload/.gitignore [deleted file]
libs/web/htdocs/luci-static/resources/cbi.js [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/add.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/apply.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/arrow.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/download.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/edit.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/fieldadd.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/find.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/help.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/key.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/link.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/reload.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/remove.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/reset.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/save.gif [new file with mode: 0644]
libs/web/htdocs/luci-static/resources/cbi/user.gif [new file with mode: 0644]
libs/web/luasrc/cbi.lua [new file with mode: 0644]
libs/web/luasrc/cbi/datatypes.lua [new file with mode: 0644]
libs/web/luasrc/view/cbi/browser.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/button.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/cell_valuefooter.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/cell_valueheader.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/compound.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/delegator.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/dvalue.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/dynlist.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/filebrowser.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/firewall_zonelist.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/footer.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/full_valuefooter.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/full_valueheader.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/fvalue.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/header.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/lvalue.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/map.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/mvalue.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/network_ifacelist.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/network_netlist.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/nsection.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/nullsection.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/simpleform.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/tabcontainer.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/tabmenu.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/tblsection.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/tsection.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/tvalue.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/ucisection.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/upload.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/value.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/valuefooter.htm [new file with mode: 0644]
libs/web/luasrc/view/cbi/valueheader.htm [new file with mode: 0644]
libs/web/root/lib/uci/upload/.gitignore [new file with mode: 0644]

index dcc2c3c3b3283d9801775921a91c99cc416e7eea..4fe804b54c72d1098e21687253e46a59fb66ea57 100644 (file)
@@ -158,17 +158,6 @@ endif
 
 
 ### Libraries ###
-define Package/luci-cbi
-  $(call Package/luci/libtemplate)
-  DEPENDS+=+luci-web +luci-uci
-  TITLE:=Configuration Binding Interface
-endef
-
-define Package/luci-cbi/install
-       $(call Package/luci/install/template,$(1),libs/cbi)
-endef
-
-
 define Package/luci-uci
   $(call Package/luci/libtemplate)
   DEPENDS+=+libuci-lua
@@ -396,7 +385,7 @@ endef
 
 define Package/luci-admin-core
   $(call Package/luci/webtemplate)
-  DEPENDS+=+luci-web +luci-cbi +luci-i18n-english
+  DEPENDS+=+luci-web +luci-i18n-english
   TITLE:=Web UI Core Module
 endef
 
@@ -1079,9 +1068,6 @@ endef
 ifneq ($(CONFIG_PACKAGE_luci-core),)
        PKG_SELECTED_MODULES+=libs/core
 endif
-ifneq ($(CONFIG_PACKAGE_luci-cbi),)
-       PKG_SELECTED_MODULES+=libs/cbi
-endif
 ifneq ($(CONFIG_PACKAGE_luci-fastindex),)
        PKG_SELECTED_MODULES+=libs/fastindex
 endif
@@ -1323,7 +1309,6 @@ MAKE_FLAGS += \
 
 
 $(eval $(call BuildPackage,luci-core))
-$(eval $(call BuildPackage,luci-cbi))
 $(eval $(call BuildPackage,luci-fastindex))
 $(eval $(call BuildPackage,luci-http))
 $(eval $(call BuildPackage,luci-httpclient))
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi.js b/libs/cbi/htdocs/luci-static/resources/cbi.js
deleted file mode 100644 (file)
index 4af6e58..0000000
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
-       LuCI - Lua Configuration Interface
-
-       Copyright 2008 Steven Barth <steven@midlink.org>
-       Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
-
-       Licensed under the Apache License, Version 2.0 (the "License");
-       you may not use this file except in compliance with the License.
-       You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-*/
-
-var cbi_d = [];
-var cbi_t = [];
-var cbi_c = [];
-
-var cbi_validators = {
-
-       'integer': function(v)
-       {
-               return (v.match(/^-?[0-9]+$/) != null);
-       },
-
-       'uinteger': function(v)
-       {
-               return (cbi_validators.integer(v) && (v >= 0));
-       },
-
-       'ipaddr': function(v)
-       {
-               return cbi_validators.ip4addr(v) || cbi_validators.ip6addr(v);
-       },
-
-       'ip4addr': function(v)
-       {
-               if( v.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)(\/(\d+))?$/) )
-               {
-                       return (RegExp.$1 >= 0) && (RegExp.$1 <= 255) &&
-                              (RegExp.$2 >= 0) && (RegExp.$2 <= 255) &&
-                              (RegExp.$3 >= 0) && (RegExp.$3 <= 255) &&
-                              (RegExp.$4 >= 0) && (RegExp.$4 <= 255) &&
-                              (!RegExp.$5 || ((RegExp.$6 >= 0) && (RegExp.$6 <= 32)))
-                       ;
-               }
-
-               return false;
-       },
-
-       'ip6addr': function(v)
-       {
-               if( v.match(/^([a-fA-F0-9:.]+)(\/(\d+))?$/) )
-               {
-                       if( !RegExp.$2 || ((RegExp.$3 >= 0) && (RegExp.$3 <= 128)) )
-                       {
-                               var addr = RegExp.$1;
-
-                               if( addr == '::' )
-                               {
-                                       return true;
-                               }
-
-                               if( addr.indexOf('.') > 0 )
-                               {
-                                       var off = addr.lastIndexOf(':');
-
-                                       if( !(off && cbi_validators.ip4addr(addr.substr(off+1))) )
-                                               return false;
-
-                                       addr = addr.substr(0, off) + ':0:0';
-                               }
-
-                               if( addr.indexOf('::') < 0 )
-                               {
-                                       return (addr.match(/^(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}$/) != null);
-                               }
-
-                               var fields = 0;
-
-                               for( var i = 0, last = 0, comp = false; i <= addr.length; i++ )
-                               {
-                                       if( (addr.charAt(i) == ':') || (i == addr.length) )
-                                       {
-                                               if( (i == last) && !comp )
-                                               {
-                                                       comp = true;
-                                               }
-                                               else
-                                               {
-                                                       var f = addr.substring(last, i);
-                                                       if( !(f && f.match(/^[a-fA-F0-9]{1,4}$/)) )
-                                                               return false;
-                                               }
-
-                                               fields++;
-                                               last = i + 1;
-                                       }                               
-                               }
-
-                               return (fields == 8);
-                       }
-               }
-
-               return false;
-       },
-
-       'port': function(v)
-       {
-               return cbi_validators.integer(v) && (v >= 0) && (v <= 65535);
-       },
-
-       'portrange': function(v)
-       {
-               if( v.match(/^(\d+)-(\d+)$/) )
-               {
-                       var p1 = RegExp.$1;
-                       var p2 = RegExp.$2;
-
-                       return cbi_validators.port(p1) &&
-                              cbi_validators.port(p2) &&
-                              (parseInt(p1) <= parseInt(p2))
-                       ;
-               }
-               else
-               {
-                       return cbi_validators.port(v);
-               }
-       },
-
-       'macaddr': function(v)
-       {
-               return (v.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null);
-       },
-
-       'host': function(v)
-       {
-               return cbi_validators.hostname(v) || cbi_validators.ipaddr(v);
-       },
-
-       'hostname': function(v)
-       {
-               return (v.match(/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/) != null);
-       },
-
-       'wpakey': function(v)
-       {
-               if( v.length == 64 )
-                       return (v.match(/^[a-fA-F0-9]{64}$/) != null);
-               else
-                       return (v.length >= 8) && (v.length <= 63);
-       },
-
-       'wepkey': function(v)
-       {
-               if( v.substr(0,2) == 's:' )
-                       v = v.substr(2);
-
-               if( (v.length == 10) || (v.length == 26) )
-                       return (v.match(/^[a-fA-F0-9]{10,26}$/) != null);
-               else
-                       return (v.length == 5) || (v.length == 13);
-       },
-
-};
-
-
-function cbi_d_add(field, dep, next) {
-       var obj = document.getElementById(field);
-       if (obj) {
-               var entry
-               for (var i=0; i<cbi_d.length; i++) {
-                       if (cbi_d[i].id == field) {
-                               entry = cbi_d[i];
-                               break;
-                       }
-               }
-               if (!entry) {
-                       entry = {
-                               "node": obj,
-                               "id": field,
-                               "parent": obj.parentNode.id,
-                               "next": next,
-                               "deps": []
-                       };
-                       cbi_d.unshift(entry);
-               }
-               entry.deps.push(dep)
-       }
-}
-
-function cbi_d_checkvalue(target, ref) {
-       var t = document.getElementById(target);
-       var value;
-
-       if (!t) {
-               var tl = document.getElementsByName(target);
-
-               if( tl.length > 0 && tl[0].type == 'radio' )
-                       for( var i = 0; i < tl.length; i++ )
-                               if( tl[i].checked ) {
-                                       value = tl[i].value;
-                                       break;
-                               }
-
-               value = value ? value : "";
-       } else if (!t.value) {
-               value = "";
-       } else {
-               value = t.value;
-
-               if (t.type == "checkbox") {
-                       value = t.checked ? value : "";
-               }
-       }
-
-       return (value == ref)
-}
-
-function cbi_d_check(deps) {
-       var reverse;
-       var def = false;
-       for (var i=0; i<deps.length; i++) {
-               var istat = true;
-               reverse = false;
-               for (var j in deps[i]) {
-                       if (j == "!reverse") {
-                               reverse = true;
-                       } else if (j == "!default") {
-                               def = true;
-                               istat = false;
-                       } else {
-                               istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
-                       }
-               }
-               if (istat) {
-                       return !reverse;
-               }
-       }
-       return def;
-}
-
-function cbi_d_update() {
-       var state = false;
-       for (var i=0; i<cbi_d.length; i++) {
-               var entry = cbi_d[i];
-               var next  = document.getElementById(entry.next)
-               var node  = document.getElementById(entry.id)
-               var parent = document.getElementById(entry.parent)
-
-               if (node && node.parentNode && !cbi_d_check(entry.deps)) {
-                       node.parentNode.removeChild(node);
-                       state = true;
-                       if( entry.parent )
-                               cbi_c[entry.parent]--;
-               } else if ((!node || !node.parentNode) && cbi_d_check(entry.deps)) {
-                       if (!next) {
-                               parent.appendChild(entry.node);
-                       } else {
-                               next.parentNode.insertBefore(entry.node, next);
-                       }
-                       state = true;
-                       if( entry.parent )
-                               cbi_c[entry.parent]++;
-               }
-       }
-
-       if (entry.parent) {
-               cbi_t_update();
-       }
-
-       if (state) {
-               cbi_d_update();
-       }
-}
-
-function cbi_bind(obj, type, callback, mode) {
-       if (typeof mode == "undefined") {
-               mode = false;
-       }
-       if (!obj.addEventListener) {
-               ieCallback = function(){
-                       var e = window.event;
-                       if (!e.target && e.srcElement) {
-                               e.target = e.srcElement;
-                       };
-                       e.target['_eCB' + type + callback] = callback;
-                       e.target['_eCB' + type + callback](e);
-                       e.target['_eCB' + type + callback] = null;
-               };
-               obj.attachEvent('on' + type, ieCallback);
-       } else {
-               obj.addEventListener(type, callback, mode);
-       }
-       return obj;
-}
-
-function cbi_combobox(id, values, def, man) {
-       var selid = "cbi.combobox." + id;
-       if (document.getElementById(selid)) {
-               return
-       }
-
-       var obj = document.getElementById(id)
-       var sel = document.createElement("select");
-       sel.id = selid;
-       sel.className = 'cbi-input-select';
-       if (obj.className && obj.className.match(/cbi-input-invalid/)) {
-               sel.className += ' cbi-input-invalid';
-       }
-       if (obj.nextSibling) {
-               obj.parentNode.insertBefore(sel, obj.nextSibling);
-       } else {
-               obj.parentNode.appendChild(sel);
-       }
-
-       if (!values[obj.value]) {
-               if (obj.value == "") {
-                       var optdef = document.createElement("option");
-                       optdef.value = "";
-                       optdef.appendChild(document.createTextNode(def));
-                       sel.appendChild(optdef);
-               } else {
-                       var opt = document.createElement("option");
-                       opt.value = obj.value;
-                       opt.selected = "selected";
-                       opt.appendChild(document.createTextNode(obj.value));
-                       sel.appendChild(opt);
-               }
-       }
-
-       for (var i in values) {
-               var opt = document.createElement("option");
-               opt.value = i;
-
-               if (obj.value == i) {
-                       opt.selected = "selected";
-               }
-
-               opt.appendChild(document.createTextNode(values[i]));
-               sel.appendChild(opt);
-       }
-
-       var optman = document.createElement("option");
-       optman.value = "";
-       optman.appendChild(document.createTextNode(man));
-       sel.appendChild(optman);
-
-       obj.style.display = "none";
-
-       cbi_bind(sel, "change", function() {
-               if (sel.selectedIndex == sel.options.length - 1) {
-                       obj.style.display = "inline";
-                       sel.parentNode.removeChild(sel);
-                       obj.focus();
-               } else {
-                       obj.value = sel.options[sel.selectedIndex].value;
-                       sel.className = (!obj.validate || obj.validate())
-                               ? 'cbi-input-select' : 'cbi-input-select cbi-input-invalid';
-               }
-
-               try {
-                       cbi_d_update();
-               } catch (e) {
-                       //Do nothing
-               }
-       })
-}
-
-function cbi_combobox_init(id, values, def, man) {
-       var obj = document.getElementById(id);
-       cbi_bind(obj, "blur", function() {
-               cbi_combobox(id, values, def, man)
-       });
-       cbi_combobox(id, values, def, man);
-}
-
-function cbi_filebrowser(id, url, defpath) {
-       var field   = document.getElementById(id);
-       var browser = window.open(
-               url + ( field.value || defpath || '' ) + '?field=' + id,
-               "luci_filebrowser", "width=300,height=400,left=100,top=200,scrollbars=yes"
-       );
-
-       browser.focus();
-}
-
-//Hijacks the CBI form to send via XHR (requires Prototype)
-function cbi_hijack_forms(layer, win, fail, load) {
-       var forms = layer.getElementsByTagName('form');
-       for (var i=0; i<forms.length; i++) {
-               $(forms[i]).observe('submit', function(event) {
-                       // Prevent the form from also submitting the regular way
-                       event.stop();
-
-                       // Submit via XHR
-                       event.element().request({
-                               onSuccess: win,
-                               onFailure: fail
-                       });
-
-                       if (load) {
-                               load();
-                       }
-               });
-       }
-}
-
-
-function cbi_t_add(section, tab) {
-       var t = document.getElementById('tab.' + section + '.' + tab);
-       var c = document.getElementById('container.' + section + '.' + tab);
-
-       if( t && c ) {
-               cbi_t[section] = (cbi_t[section] || [ ]);
-               cbi_t[section][tab] = { 'tab': t, 'container': c, 'cid': c.id };
-       }
-}
-
-function cbi_t_switch(section, tab) {
-       if( cbi_t[section] && cbi_t[section][tab] ) {
-               var o = cbi_t[section][tab];
-               var h = document.getElementById('tab.' + section);
-               for( var tid in cbi_t[section] ) {
-                       var o2 = cbi_t[section][tid];
-                       if( o.tab.id != o2.tab.id ) {
-                               o2.tab.className = o2.tab.className.replace(/(^| )cbi-tab( |$)/, " cbi-tab-disabled ");
-                               o2.container.style.display = 'none';
-                       }
-                       else {
-                               if(h) h.value = tab;
-                               o2.tab.className = o2.tab.className.replace(/(^| )cbi-tab-disabled( |$)/, " cbi-tab ");
-                               o2.container.style.display = 'block';
-                       }
-               }
-       }
-       return false
-}
-
-function cbi_t_update() {
-       for( var sid in cbi_t )
-               for( var tid in cbi_t[sid] )
-                       if( cbi_c[cbi_t[sid][tid].cid] == 0 ) {
-                               cbi_t[sid][tid].tab.style.display = 'none';
-                       }
-                       else if( cbi_t[sid][tid].tab && cbi_t[sid][tid].tab.style.display == 'none' ) {
-                               cbi_t[sid][tid].tab.style.display = '';
-
-                               var t = cbi_t[sid][tid].tab;
-                               window.setTimeout(function() { t.className = t.className.replace(/ cbi-tab-highlighted/g, '') }, 750);
-                               cbi_t[sid][tid].tab.className += ' cbi-tab-highlighted';
-                       }
-}
-
-
-function cbi_validate_form(form, errmsg)
-{
-       if( form.cbi_validators )
-       {
-               for( var i = 0; i < form.cbi_validators.length; i++ )
-               {
-                       var validator = form.cbi_validators[i];
-                       if( !validator() && errmsg )
-                       {
-                               alert(errmsg);
-                               return false;
-                       }
-               }
-       }
-
-       return true;
-}
-
-function cbi_validate_reset(form)
-{
-       window.setTimeout(
-               function() { cbi_validate_form(form, null) }, 100
-       );
-
-       return true;
-}
-
-function cbi_validate_field(cbid, optional, type)
-{
-       var field = document.getElementById(cbid);
-       var vldcb = cbi_validators[type];
-
-       if( field && vldcb )
-       {
-               var validator = function(reset)
-               {
-                       // is not detached
-                       if( field.form )
-                       {
-                               field.className = field.className.replace(/ cbi-input-invalid/g, '');
-
-                               // validate value
-                               var value = (field.options) ? field.options[field.options.selectedIndex].value : field.value;
-                               if( !(((value.length == 0) && optional) || vldcb(value)) )
-                               {
-                                       // invalid
-                                       field.className += ' cbi-input-invalid';
-                                       return false;
-                               }
-                       }
-
-                       return true;
-               };
-
-               if( ! field.form.cbi_validators )
-                       field.form.cbi_validators = [ ];
-
-               field.form.cbi_validators.push(validator);
-               field.onblur = field.onkeyup = field.validate = validator;
-
-               validator();
-       }
-}
-
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/add.gif b/libs/cbi/htdocs/luci-static/resources/cbi/add.gif
deleted file mode 100644 (file)
index 0888abf..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/add.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/apply.gif b/libs/cbi/htdocs/luci-static/resources/cbi/apply.gif
deleted file mode 100644 (file)
index 82ae7ed..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/apply.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/arrow.gif b/libs/cbi/htdocs/luci-static/resources/cbi/arrow.gif
deleted file mode 100644 (file)
index 10d797e..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/arrow.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/download.gif b/libs/cbi/htdocs/luci-static/resources/cbi/download.gif
deleted file mode 100644 (file)
index f99a538..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/download.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/edit.gif b/libs/cbi/htdocs/luci-static/resources/cbi/edit.gif
deleted file mode 100644 (file)
index 7b02b6e..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/edit.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/fieldadd.gif b/libs/cbi/htdocs/luci-static/resources/cbi/fieldadd.gif
deleted file mode 100644 (file)
index 431ff64..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/fieldadd.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/find.gif b/libs/cbi/htdocs/luci-static/resources/cbi/find.gif
deleted file mode 100644 (file)
index 9ae5e34..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/find.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/help.gif b/libs/cbi/htdocs/luci-static/resources/cbi/help.gif
deleted file mode 100644 (file)
index 9dfa0e1..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/help.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/key.gif b/libs/cbi/htdocs/luci-static/resources/cbi/key.gif
deleted file mode 100644 (file)
index e3853e5..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/key.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/link.gif b/libs/cbi/htdocs/luci-static/resources/cbi/link.gif
deleted file mode 100644 (file)
index f0bb78d..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/link.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/reload.gif b/libs/cbi/htdocs/luci-static/resources/cbi/reload.gif
deleted file mode 100644 (file)
index 8268958..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/reload.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/remove.gif b/libs/cbi/htdocs/luci-static/resources/cbi/remove.gif
deleted file mode 100644 (file)
index bf43a0a..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/remove.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/reset.gif b/libs/cbi/htdocs/luci-static/resources/cbi/reset.gif
deleted file mode 100644 (file)
index c941c19..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/reset.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/save.gif b/libs/cbi/htdocs/luci-static/resources/cbi/save.gif
deleted file mode 100644 (file)
index 35e9499..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/save.gif and /dev/null differ
diff --git a/libs/cbi/htdocs/luci-static/resources/cbi/user.gif b/libs/cbi/htdocs/luci-static/resources/cbi/user.gif
deleted file mode 100644 (file)
index dcb5c2a..0000000
Binary files a/libs/cbi/htdocs/luci-static/resources/cbi/user.gif and /dev/null differ
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
deleted file mode 100644 (file)
index 8dd16b1..0000000
+++ /dev/null
@@ -1,1707 +0,0 @@
---[[
-LuCI - Configuration Bind Interface
-
-Description:
-Offers an interface for binding configuration values to certain
-data types. Supports value and range validation and basic dependencies.
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-module("luci.cbi", package.seeall)
-
-require("luci.template")
-local util = require("luci.util")
-require("luci.http")
-
-
---local event      = require "luci.sys.event"
-local fs         = require("nixio.fs")
-local uci        = require("luci.model.uci")
-local datatypes  = require("luci.cbi.datatypes")
-local class      = util.class
-local instanceof = util.instanceof
-
-FORM_NODATA  =  0
-FORM_PROCEED =  0
-FORM_VALID   =  1
-FORM_DONE       =  1
-FORM_INVALID = -1
-FORM_CHANGED =  2
-FORM_SKIP    =  4
-
-AUTO = true
-
-CREATE_PREFIX = "cbi.cts."
-REMOVE_PREFIX = "cbi.rts."
-
--- Loads a CBI map from given file, creating an environment and returns it
-function load(cbimap, ...)
-       local fs   = require "nixio.fs"
-       local i18n = require "luci.i18n"
-       require("luci.config")
-       require("luci.util")
-
-       local upldir = "/lib/uci/upload/"
-       local cbidir = luci.util.libpath() .. "/model/cbi/"
-       local func, err
-
-       if fs.access(cbidir..cbimap..".lua") then
-               func, err = loadfile(cbidir..cbimap..".lua")
-       elseif fs.access(cbimap) then
-               func, err = loadfile(cbimap)
-       else
-               func, err = nil, "Model '" .. cbimap .. "' not found!"
-       end
-
-       assert(func, err)
-
-       luci.i18n.loadc("base")
-
-       local env = {
-               translate=i18n.translate,
-               translatef=i18n.translatef,
-               arg={...}
-       }
-
-       setfenv(func, setmetatable(env, {__index =
-               function(tbl, key)
-                       return rawget(tbl, key) or _M[key] or _G[key]
-               end}))
-
-       local maps       = { func() }
-       local uploads    = { }
-       local has_upload = false
-
-       for i, map in ipairs(maps) do
-               if not instanceof(map, Node) then
-                       error("CBI map returns no valid map object!")
-                       return nil
-               else
-                       map:prepare()
-                       if map.upload_fields then
-                               has_upload = true
-                               for _, field in ipairs(map.upload_fields) do
-                                       uploads[
-                                               field.config .. '.' ..
-                                               field.section.sectiontype .. '.' ..
-                                               field.option
-                                       ] = true
-                               end
-                       end
-               end
-       end
-
-       if has_upload then
-               local uci = luci.model.uci.cursor()
-               local prm = luci.http.context.request.message.params
-               local fd, cbid
-
-               luci.http.setfilehandler(
-                       function( field, chunk, eof )
-                               if not field then return end
-                               if field.name and not cbid then
-                                       local c, s, o = field.name:gmatch(
-                                               "cbid%.([^%.]+)%.([^%.]+)%.([^%.]+)"
-                                       )()
-
-                                       if c and s and o then
-                                               local t = uci:get( c, s )
-                                               if t and uploads[c.."."..t.."."..o] then
-                                                       local path = upldir .. field.name
-                                                       fd = io.open(path, "w")
-                                                       if fd then
-                                                               cbid = field.name
-                                                               prm[cbid] = path
-                                                       end
-                                               end
-                                       end
-                               end
-
-                               if field.name == cbid and fd then
-                                       fd:write(chunk)
-                               end
-
-                               if eof and fd then
-                                       fd:close()
-                                       fd   = nil
-                                       cbid = nil
-                               end
-                       end
-               )
-       end
-
-       return maps
-end
-
-
--- Node pseudo abstract class
-Node = class()
-
-function Node.__init__(self, title, description)
-       self.children = {}
-       self.title = title or ""
-       self.description = description or ""
-       self.template = "cbi/node"
-end
-
--- hook helper
-function Node._run_hook(self, hook)
-       if type(self[hook]) == "function" then
-               return self[hook](self)
-       end
-end
-
-function Node._run_hooks(self, ...)
-       local f
-       local r = false
-       for _, f in ipairs(arg) do
-               if type(self[f]) == "function" then
-                       self[f](self)
-                       r = true
-               end
-       end
-       return r
-end
-
--- Prepare nodes
-function Node.prepare(self, ...)
-       for k, child in ipairs(self.children) do
-               child:prepare(...)
-       end
-end
-
--- Append child nodes
-function Node.append(self, obj)
-       table.insert(self.children, obj)
-end
-
--- Parse this node and its children
-function Node.parse(self, ...)
-       for k, child in ipairs(self.children) do
-               child:parse(...)
-       end
-end
-
--- Render this node
-function Node.render(self, scope)
-       scope = scope or {}
-       scope.self = self
-
-       luci.template.render(self.template, scope)
-end
-
--- Render the children
-function Node.render_children(self, ...)
-       for k, node in ipairs(self.children) do
-               node:render(...)
-       end
-end
-
-
---[[
-A simple template element
-]]--
-Template = class(Node)
-
-function Template.__init__(self, template)
-       Node.__init__(self)
-       self.template = template
-end
-
-function Template.render(self)
-       luci.template.render(self.template, {self=self})
-end
-
-function Template.parse(self, readinput)
-       self.readinput = (readinput ~= false)
-       return Map.formvalue(self, "cbi.submit") and FORM_DONE or FORM_NODATA
-end
-
-
---[[
-Map - A map describing a configuration file
-]]--
-Map = class(Node)
-
-function Map.__init__(self, config, ...)
-       Node.__init__(self, ...)
-
-       self.config = config
-       self.parsechain = {self.config}
-       self.template = "cbi/map"
-       self.apply_on_parse = nil
-       self.readinput = true
-       self.proceed = false
-       self.flow = {}
-
-       self.uci = uci.cursor()
-       self.save = true
-
-       self.changed = false
-
-       if not self.uci:load(self.config) then
-               error("Unable to read UCI data: " .. self.config)
-       end
-end
-
-function Map.formvalue(self, key)
-       return self.readinput and luci.http.formvalue(key)
-end
-
-function Map.formvaluetable(self, key)
-       return self.readinput and luci.http.formvaluetable(key) or {}
-end
-
-function Map.get_scheme(self, sectiontype, option)
-       if not option then
-               return self.scheme and self.scheme.sections[sectiontype]
-       else
-               return self.scheme and self.scheme.variables[sectiontype]
-                and self.scheme.variables[sectiontype][option]
-       end
-end
-
-function Map.submitstate(self)
-       return self:formvalue("cbi.submit")
-end
-
--- Chain foreign config
-function Map.chain(self, config)
-       table.insert(self.parsechain, config)
-end
-
-function Map.state_handler(self, state)
-       return state
-end
-
--- Use optimized UCI writing
-function Map.parse(self, readinput, ...)
-       self.readinput = (readinput ~= false)
-       self:_run_hooks("on_parse")
-
-       if self:formvalue("cbi.skip") then
-               self.state = FORM_SKIP
-               return self:state_handler(self.state)
-       end
-
-       Node.parse(self, ...)
-
-       if self.save then
-               for i, config in ipairs(self.parsechain) do
-                       self.uci:save(config)
-               end
-               if self:submitstate() and ((not self.proceed and self.flow.autoapply) or luci.http.formvalue("cbi.apply")) then
-                       self:_run_hooks("on_before_commit")
-                       for i, config in ipairs(self.parsechain) do
-                               self.uci:commit(config)
-
-                               -- Refresh data because commit changes section names
-                               self.uci:load(config)
-                       end
-                       self:_run_hooks("on_commit", "on_after_commit", "on_before_apply")
-                       if self.apply_on_parse then
-                               self.uci:apply(self.parsechain)
-                               self:_run_hooks("on_apply", "on_after_apply")
-                       else
-                               self._apply = function()
-                                       local cmd = self.uci:apply(self.parsechain, true)
-                                       return io.popen(cmd)
-                               end
-                       end
-
-                       -- Reparse sections
-                       Node.parse(self, true)
-
-               end
-               for i, config in ipairs(self.parsechain) do
-                       self.uci:unload(config)
-               end
-               if type(self.commit_handler) == "function" then
-                       self:commit_handler(self:submitstate())
-               end
-       end
-
-       if self:submitstate() then
-               if not self.save then
-                       self.state = FORM_INVALID
-               elseif self.proceed then
-                       self.state = FORM_PROCEED
-               else
-                       self.state = self.changed and FORM_CHANGED or FORM_VALID
-               end
-       else
-               self.state = FORM_NODATA
-       end
-
-       return self:state_handler(self.state)
-end
-
-function Map.render(self, ...)
-       self:_run_hooks("on_init")
-       Node.render(self, ...)
-       if false and self._apply then
-               local fp = self._apply()
-               fp:read("*a")
-               fp:close()
-               self:_run_hooks("on_apply")
-       end
-end
-
--- Creates a child section
-function Map.section(self, class, ...)
-       if instanceof(class, AbstractSection) then
-               local obj  = class(self, ...)
-               self:append(obj)
-               return obj
-       else
-               error("class must be a descendent of AbstractSection")
-       end
-end
-
--- UCI add
-function Map.add(self, sectiontype)
-       return self.uci:add(self.config, sectiontype)
-end
-
--- UCI set
-function Map.set(self, section, option, value)
-       if option then
-               return self.uci:set(self.config, section, option, value)
-       else
-               return self.uci:set(self.config, section, value)
-       end
-end
-
--- UCI del
-function Map.del(self, section, option)
-       if option then
-               return self.uci:delete(self.config, section, option)
-       else
-               return self.uci:delete(self.config, section)
-       end
-end
-
--- UCI get
-function Map.get(self, section, option)
-       if not section then
-               return self.uci:get_all(self.config)
-       elseif option then
-               return self.uci:get(self.config, section, option)
-       else
-               return self.uci:get_all(self.config, section)
-       end
-end
-
---[[
-Compound - Container
-]]--
-Compound = class(Node)
-
-function Compound.__init__(self, ...)
-       Node.__init__(self)
-       self.template = "cbi/compound"
-       self.children = {...}
-end
-
-function Compound.populate_delegator(self, delegator)
-       for _, v in ipairs(self.children) do
-               v.delegator = delegator
-       end
-end
-
-function Compound.parse(self, ...)
-       local cstate, state = 0
-
-       for k, child in ipairs(self.children) do
-               cstate = child:parse(...)
-               state = (not state or cstate < state) and cstate or state
-       end
-
-       return state
-end
-
-
---[[
-Delegator - Node controller
-]]--
-Delegator = class(Node)
-function Delegator.__init__(self, ...)
-       Node.__init__(self, ...)
-       self.nodes = {}
-       self.defaultpath = {}
-       self.pageaction = false
-       self.readinput = true
-       self.allow_reset = false
-       self.allow_cancel = false
-       self.allow_back = false
-       self.allow_finish = false
-       self.template = "cbi/delegator"
-end
-
-function Delegator.set(self, name, node)
-       assert(not self.nodes[name], "Duplicate entry")
-
-       self.nodes[name] = node
-end
-
-function Delegator.add(self, name, node)
-       node = self:set(name, node)
-       self.defaultpath[#self.defaultpath+1] = name
-end
-
-function Delegator.insert_after(self, name, after)
-       local n = #self.chain + 1
-       for k, v in ipairs(self.chain) do
-               if v == after then
-                       n = k + 1
-                       break
-               end
-       end
-       table.insert(self.chain, n, name)
-end
-
-function Delegator.set_route(self, ...)
-       local n, chain, route = 0, self.chain, {...}
-       for i = 1, #chain do
-               if chain[i] == self.current then
-                       n = i
-                       break
-               end
-       end
-       for i = 1, #route do
-               n = n + 1
-               chain[n] = route[i]
-       end
-       for i = n + 1, #chain do
-               chain[i] = nil
-       end
-end
-
-function Delegator.get(self, name)
-       local node = self.nodes[name]
-
-       if type(node) == "string" then
-               node = load(node, name)
-       end
-
-       if type(node) == "table" and getmetatable(node) == nil then
-               node = Compound(unpack(node))
-       end
-
-       return node
-end
-
-function Delegator.parse(self, ...)
-       if self.allow_cancel and Map.formvalue(self, "cbi.cancel") then
-               if self:_run_hooks("on_cancel") then
-                       return FORM_DONE
-               end
-       end
-
-       if not Map.formvalue(self, "cbi.delg.current") then
-               self:_run_hooks("on_init")
-       end
-
-       local newcurrent
-       self.chain = self.chain or self:get_chain()
-       self.current = self.current or self:get_active()
-       self.active = self.active or self:get(self.current)
-       assert(self.active, "Invalid state")
-
-       local stat = FORM_DONE
-       if type(self.active) ~= "function" then
-               self.active:populate_delegator(self)
-               stat = self.active:parse()
-       else
-               self:active()
-       end
-
-       if stat > FORM_PROCEED then
-               if Map.formvalue(self, "cbi.delg.back") then
-                       newcurrent = self:get_prev(self.current)
-               else
-                       newcurrent = self:get_next(self.current)
-               end
-       elseif stat < FORM_PROCEED then
-               return stat
-       end
-
-
-       if not Map.formvalue(self, "cbi.submit") then
-               return FORM_NODATA
-       elseif stat > FORM_PROCEED
-       and (not newcurrent or not self:get(newcurrent)) then
-               return self:_run_hook("on_done") or FORM_DONE
-       else
-               self.current = newcurrent or self.current
-               self.active = self:get(self.current)
-               if type(self.active) ~= "function" then
-                       self.active:populate_delegator(self)
-                       local stat = self.active:parse(false)
-                       if stat == FORM_SKIP then
-                               return self:parse(...)
-                       else
-                               return FORM_PROCEED
-                       end
-               else
-                       return self:parse(...)
-               end
-       end
-end
-
-function Delegator.get_next(self, state)
-       for k, v in ipairs(self.chain) do
-               if v == state then
-                       return self.chain[k+1]
-               end
-       end
-end
-
-function Delegator.get_prev(self, state)
-       for k, v in ipairs(self.chain) do
-               if v == state then
-                       return self.chain[k-1]
-               end
-       end
-end
-
-function Delegator.get_chain(self)
-       local x = Map.formvalue(self, "cbi.delg.path") or self.defaultpath
-       return type(x) == "table" and x or {x}
-end
-
-function Delegator.get_active(self)
-       return Map.formvalue(self, "cbi.delg.current") or self.chain[1]
-end
-
---[[
-Page - A simple node
-]]--
-
-Page = class(Node)
-Page.__init__ = Node.__init__
-Page.parse    = function() end
-
-
---[[
-SimpleForm - A Simple non-UCI form
-]]--
-SimpleForm = class(Node)
-
-function SimpleForm.__init__(self, config, title, description, data)
-       Node.__init__(self, title, description)
-       self.config = config
-       self.data = data or {}
-       self.template = "cbi/simpleform"
-       self.dorender = true
-       self.pageaction = false
-       self.readinput = true
-end
-
-SimpleForm.formvalue = Map.formvalue
-SimpleForm.formvaluetable = Map.formvaluetable
-
-function SimpleForm.parse(self, readinput, ...)
-       self.readinput = (readinput ~= false)
-
-       if self:formvalue("cbi.skip") then
-               return FORM_SKIP
-       end
-
-       if self:formvalue("cbi.cancel") and self:_run_hooks("on_cancel") then
-               return FORM_DONE
-       end
-
-       if self:submitstate() then
-               Node.parse(self, 1, ...)
-       end
-
-       local valid = true
-       for k, j in ipairs(self.children) do
-               for i, v in ipairs(j.children) do
-                       valid = valid
-                        and (not v.tag_missing or not v.tag_missing[1])
-                        and (not v.tag_invalid or not v.tag_invalid[1])
-                        and (not v.error)
-               end
-       end
-
-       local state =
-               not self:submitstate() and FORM_NODATA
-               or valid and FORM_VALID
-               or FORM_INVALID
-
-       self.dorender = not self.handle
-       if self.handle then
-               local nrender, nstate = self:handle(state, self.data)
-               self.dorender = self.dorender or (nrender ~= false)
-               state = nstate or state
-       end
-       return state
-end
-
-function SimpleForm.render(self, ...)
-       if self.dorender then
-               Node.render(self, ...)
-       end
-end
-
-function SimpleForm.submitstate(self)
-       return self:formvalue("cbi.submit")
-end
-
-function SimpleForm.section(self, class, ...)
-       if instanceof(class, AbstractSection) then
-               local obj  = class(self, ...)
-               self:append(obj)
-               return obj
-       else
-               error("class must be a descendent of AbstractSection")
-       end
-end
-
--- Creates a child field
-function SimpleForm.field(self, class, ...)
-       local section
-       for k, v in ipairs(self.children) do
-               if instanceof(v, SimpleSection) then
-                       section = v
-                       break
-               end
-       end
-       if not section then
-               section = self:section(SimpleSection)
-       end
-
-       if instanceof(class, AbstractValue) then
-               local obj  = class(self, section, ...)
-               obj.track_missing = true
-               section:append(obj)
-               return obj
-       else
-               error("class must be a descendent of AbstractValue")
-       end
-end
-
-function SimpleForm.set(self, section, option, value)
-       self.data[option] = value
-end
-
-
-function SimpleForm.del(self, section, option)
-       self.data[option] = nil
-end
-
-
-function SimpleForm.get(self, section, option)
-       return self.data[option]
-end
-
-
-function SimpleForm.get_scheme()
-       return nil
-end
-
-
-Form = class(SimpleForm)
-
-function Form.__init__(self, ...)
-       SimpleForm.__init__(self, ...)
-       self.embedded = true
-end
-
-
---[[
-AbstractSection
-]]--
-AbstractSection = class(Node)
-
-function AbstractSection.__init__(self, map, sectiontype, ...)
-       Node.__init__(self, ...)
-       self.sectiontype = sectiontype
-       self.map = map
-       self.config = map.config
-       self.optionals = {}
-       self.defaults = {}
-       self.fields = {}
-       self.tag_error = {}
-       self.tag_invalid = {}
-       self.tag_deperror = {}
-       self.changed = false
-
-       self.optional = true
-       self.addremove = false
-       self.dynamic = false
-end
-
--- Define a tab for the section
-function AbstractSection.tab(self, tab, title, desc)
-       self.tabs      = self.tabs      or { }
-       self.tab_names = self.tab_names or { }
-
-       self.tab_names[#self.tab_names+1] = tab
-       self.tabs[tab] = {
-               title       = title,
-               description = desc,
-               childs      = { }
-       }
-end
-
--- Check whether the section has tabs
-function AbstractSection.has_tabs(self)
-       return (self.tabs ~= nil) and (next(self.tabs) ~= nil)
-end
-
--- Appends a new option
-function AbstractSection.option(self, class, option, ...)
-       if instanceof(class, AbstractValue) then
-               local obj  = class(self.map, self, option, ...)
-               self:append(obj)
-               self.fields[option] = obj
-               return obj
-       elseif class == true then
-               error("No valid class was given and autodetection failed.")
-       else
-               error("class must be a descendant of AbstractValue")
-       end
-end
-
--- Appends a new tabbed option
-function AbstractSection.taboption(self, tab, ...)
-
-       assert(tab and self.tabs and self.tabs[tab],
-               "Cannot assign option to not existing tab %q" % tostring(tab))
-
-       local l = self.tabs[tab].childs
-       local o = AbstractSection.option(self, ...)
-
-       if o then l[#l+1] = o end
-
-       return o
-end
-
--- Render a single tab
-function AbstractSection.render_tab(self, tab, ...)
-
-       assert(tab and self.tabs and self.tabs[tab],
-               "Cannot render not existing tab %q" % tostring(tab))
-
-       for _, node in ipairs(self.tabs[tab].childs) do
-               node:render(...)
-       end
-end
-
--- Parse optional options
-function AbstractSection.parse_optionals(self, section)
-       if not self.optional then
-               return
-       end
-
-       self.optionals[section] = {}
-
-       local field = self.map:formvalue("cbi.opt."..self.config.."."..section)
-       for k,v in ipairs(self.children) do
-               if v.optional and not v:cfgvalue(section) and not self:has_tabs() then
-                       if field == v.option then
-                               field = nil
-                               self.map.proceed = true
-                       else
-                               table.insert(self.optionals[section], v)
-                       end
-               end
-       end
-
-       if field and #field > 0 and self.dynamic then
-               self:add_dynamic(field)
-       end
-end
-
--- Add a dynamic option
-function AbstractSection.add_dynamic(self, field, optional)
-       local o = self:option(Value, field, field)
-       o.optional = optional
-end
-
--- Parse all dynamic options
-function AbstractSection.parse_dynamic(self, section)
-       if not self.dynamic then
-               return
-       end
-
-       local arr  = luci.util.clone(self:cfgvalue(section))
-       local form = self.map:formvaluetable("cbid."..self.config.."."..section)
-       for k, v in pairs(form) do
-               arr[k] = v
-       end
-
-       for key,val in pairs(arr) do
-               local create = true
-
-               for i,c in ipairs(self.children) do
-                       if c.option == key then
-                               create = false
-                       end
-               end
-
-               if create and key:sub(1, 1) ~= "." then
-                       self.map.proceed = true
-                       self:add_dynamic(key, true)
-               end
-       end
-end
-
--- Returns the section's UCI table
-function AbstractSection.cfgvalue(self, section)
-       return self.map:get(section)
-end
-
--- Push events
-function AbstractSection.push_events(self)
-       --luci.util.append(self.map.events, self.events)
-       self.map.changed = true
-end
-
--- Removes the section
-function AbstractSection.remove(self, section)
-       self.map.proceed = true
-       return self.map:del(section)
-end
-
--- Creates the section
-function AbstractSection.create(self, section)
-       local stat
-
-       if section then
-               stat = section:match("^[%w_]+$") and self.map:set(section, nil, self.sectiontype)
-       else
-               section = self.map:add(self.sectiontype)
-               stat = section
-       end
-
-       if stat then
-               for k,v in pairs(self.children) do
-                       if v.default then
-                               self.map:set(section, v.option, v.default)
-                       end
-               end
-
-               for k,v in pairs(self.defaults) do
-                       self.map:set(section, k, v)
-               end
-       end
-
-       self.map.proceed = true
-
-       return stat
-end
-
-
-SimpleSection = class(AbstractSection)
-
-function SimpleSection.__init__(self, form, ...)
-       AbstractSection.__init__(self, form, nil, ...)
-       self.template = "cbi/nullsection"
-end
-
-
-Table = class(AbstractSection)
-
-function Table.__init__(self, form, data, ...)
-       local datasource = {}
-       local tself = self
-       datasource.config = "table"
-       self.data = data or {}
-
-       datasource.formvalue = Map.formvalue
-       datasource.formvaluetable = Map.formvaluetable
-       datasource.readinput = true
-
-       function datasource.get(self, section, option)
-               return tself.data[section] and tself.data[section][option]
-       end
-
-       function datasource.submitstate(self)
-               return Map.formvalue(self, "cbi.submit")
-       end
-
-       function datasource.del(...)
-               return true
-       end
-
-       function datasource.get_scheme()
-               return nil
-       end
-
-       AbstractSection.__init__(self, datasource, "table", ...)
-       self.template = "cbi/tblsection"
-       self.rowcolors = true
-       self.anonymous = true
-end
-
-function Table.parse(self, readinput)
-       self.map.readinput = (readinput ~= false)
-       for i, k in ipairs(self:cfgsections()) do
-               if self.map:submitstate() then
-                       Node.parse(self, k)
-               end
-       end
-end
-
-function Table.cfgsections(self)
-       local sections = {}
-
-       for i, v in luci.util.kspairs(self.data) do
-               table.insert(sections, i)
-       end
-
-       return sections
-end
-
-function Table.update(self, data)
-       self.data = data
-end
-
-
-
---[[
-NamedSection - A fixed configuration section defined by its name
-]]--
-NamedSection = class(AbstractSection)
-
-function NamedSection.__init__(self, map, section, stype, ...)
-       AbstractSection.__init__(self, map, stype, ...)
-
-       -- Defaults
-       self.addremove = false
-       self.template = "cbi/nsection"
-       self.section = section
-end
-
-function NamedSection.parse(self, novld)
-       local s = self.section
-       local active = self:cfgvalue(s)
-
-       if self.addremove then
-               local path = self.config.."."..s
-               if active then -- Remove the section
-                       if self.map:formvalue("cbi.rns."..path) and self:remove(s) then
-                               self:push_events()
-                               return
-                       end
-               else           -- Create and apply default values
-                       if self.map:formvalue("cbi.cns."..path) then
-                               self:create(s)
-                               return
-                       end
-               end
-       end
-
-       if active then
-               AbstractSection.parse_dynamic(self, s)
-               if self.map:submitstate() then
-                       Node.parse(self, s)
-               end
-               AbstractSection.parse_optionals(self, s)
-
-               if self.changed then
-                       self:push_events()
-               end
-       end
-end
-
-
---[[
-TypedSection - A (set of) configuration section(s) defined by the type
-       addremove:      Defines whether the user can add/remove sections of this type
-       anonymous:  Allow creating anonymous sections
-       validate:       a validation function returning nil if the section is invalid
-]]--
-TypedSection = class(AbstractSection)
-
-function TypedSection.__init__(self, map, type, ...)
-       AbstractSection.__init__(self, map, type, ...)
-
-       self.template = "cbi/tsection"
-       self.deps = {}
-       self.anonymous = false
-end
-
--- Return all matching UCI sections for this TypedSection
-function TypedSection.cfgsections(self)
-       local sections = {}
-       self.map.uci:foreach(self.map.config, self.sectiontype,
-               function (section)
-                       if self:checkscope(section[".name"]) then
-                               table.insert(sections, section[".name"])
-                       end
-               end)
-
-       return sections
-end
-
--- Limits scope to sections that have certain option => value pairs
-function TypedSection.depends(self, option, value)
-       table.insert(self.deps, {option=option, value=value})
-end
-
-function TypedSection.parse(self, novld)
-       if self.addremove then
-               -- Remove
-               local crval = REMOVE_PREFIX .. self.config
-               local name = self.map:formvaluetable(crval)
-               for k,v in pairs(name) do
-                       if k:sub(-2) == ".x" then
-                               k = k:sub(1, #k - 2)
-                       end
-                       if self:cfgvalue(k) and self:checkscope(k) then
-                               self:remove(k)
-                       end
-               end
-       end
-
-       local co
-       for i, k in ipairs(self:cfgsections()) do
-               AbstractSection.parse_dynamic(self, k)
-               if self.map:submitstate() then
-                       Node.parse(self, k, novld)
-               end
-               AbstractSection.parse_optionals(self, k)
-       end
-
-       if self.addremove then
-               -- Create
-               local created
-               local crval = CREATE_PREFIX .. self.config .. "." .. self.sectiontype
-               local name  = self.map:formvalue(crval)
-               if self.anonymous then
-                       if name then
-                               created = self:create()
-                       end
-               else
-                       if name then
-                               -- Ignore if it already exists
-                               if self:cfgvalue(name) then
-                                       name = nil;
-                               end
-
-                               name = self:checkscope(name)
-
-                               if not name then
-                                       self.err_invalid = true
-                               end
-
-                               if name and #name > 0 then
-                                       created = self:create(name) and name
-                                       if not created then
-                                               self.invalid_cts = true
-                                       end
-                               end
-                       end
-               end
-
-               if created then
-                       AbstractSection.parse_optionals(self, created)
-               end
-       end
-
-       if created or self.changed then
-               self:push_events()
-       end
-end
-
--- Verifies scope of sections
-function TypedSection.checkscope(self, section)
-       -- Check if we are not excluded
-       if self.filter and not self:filter(section) then
-               return nil
-       end
-
-       -- Check if at least one dependency is met
-       if #self.deps > 0 and self:cfgvalue(section) then
-               local stat = false
-
-               for k, v in ipairs(self.deps) do
-                       if self:cfgvalue(section)[v.option] == v.value then
-                               stat = true
-                       end
-               end
-
-               if not stat then
-                       return nil
-               end
-       end
-
-       return self:validate(section)
-end
-
-
--- Dummy validate function
-function TypedSection.validate(self, section)
-       return section
-end
-
-
---[[
-AbstractValue - An abstract Value Type
-       null:           Value can be empty
-       valid:          A function returning the value if it is valid otherwise nil
-       depends:        A table of option => value pairs of which one must be true
-       default:        The default value
-       size:           The size of the input fields
-       rmempty:        Unset value if empty
-       optional:       This value is optional (see AbstractSection.optionals)
-]]--
-AbstractValue = class(Node)
-
-function AbstractValue.__init__(self, map, section, option, ...)
-       Node.__init__(self, ...)
-       self.section = section
-       self.option  = option
-       self.map     = map
-       self.config  = map.config
-       self.tag_invalid = {}
-       self.tag_missing = {}
-       self.tag_reqerror = {}
-       self.tag_error = {}
-       self.deps = {}
-       self.subdeps = {}
-       --self.cast = "string"
-
-       self.track_missing = false
-       self.rmempty   = true
-       self.default   = nil
-       self.size      = nil
-       self.optional  = false
-end
-
-function AbstractValue.prepare(self)
-       self.cast = self.cast or "string"
-end
-
--- Add a dependencie to another section field
-function AbstractValue.depends(self, field, value)
-       local deps
-       if type(field) == "string" then
-               deps = {}
-               deps[field] = value
-       else
-               deps = field
-       end
-
-       table.insert(self.deps, {deps=deps, add=""})
-end
-
--- Generates the unique CBID
-function AbstractValue.cbid(self, section)
-       return "cbid."..self.map.config.."."..section.."."..self.option
-end
-
--- Return whether this object should be created
-function AbstractValue.formcreated(self, section)
-       local key = "cbi.opt."..self.config.."."..section
-       return (self.map:formvalue(key) == self.option)
-end
-
--- Returns the formvalue for this object
-function AbstractValue.formvalue(self, section)
-       return self.map:formvalue(self:cbid(section))
-end
-
-function AbstractValue.additional(self, value)
-       self.optional = value
-end
-
-function AbstractValue.mandatory(self, value)
-       self.rmempty = not value
-end
-
-function AbstractValue.parse(self, section, novld)
-       local fvalue = self:formvalue(section)
-       local cvalue = self:cfgvalue(section)
-
-       -- If favlue and cvalue are both tables and have the same content
-       -- make them identical
-       if type(fvalue) == "table" and type(cvalue) == "table" then
-               local equal = #fvalue == #cvalue
-               if equal then
-                       for i=1, #fvalue do
-                               if cvalue[i] ~= fvalue[i] then
-                                       equal = false
-                               end
-                       end
-               end
-               if equal then
-                       fvalue = cvalue
-               end
-       end
-
-       if fvalue and #fvalue > 0 then -- If we have a form value, write it to UCI
-               fvalue = self:transform(self:validate(fvalue, section))
-               if not fvalue and not novld then
-                       if self.error then
-                               self.error[section] = "invalid"
-                       else
-                               self.error = { [section] = "invalid" }
-                       end
-                       if self.section.error then
-                               table.insert(self.section.error[section], "invalid")
-                       else
-                               self.section.error = {[section] = {"invalid"}}
-                       end
-                       self.map.save = false
-               end
-               if fvalue and not (fvalue == cvalue) then
-                       if self:write(section, fvalue) then
-                               -- Push events
-                               self.section.changed = true
-                               --luci.util.append(self.map.events, self.events)
-                       end
-               end
-       else                                                    -- Unset the UCI or error
-               if self.rmempty or self.optional then
-                       if self:remove(section) then
-                               -- Push events
-                               self.section.changed = true
-                               --luci.util.append(self.map.events, self.events)
-                       end
-               elseif cvalue ~= fvalue and not novld then
-                       self:write(section, fvalue or "")
-                       if self.error then
-                               self.error[section] = "missing"
-                       else
-                               self.error = { [section] = "missing" }
-                       end
-                       self.map.save = false
-               end
-       end
-end
-
--- Render if this value exists or if it is mandatory
-function AbstractValue.render(self, s, scope)
-       if not self.optional or self.section:has_tabs() or self:cfgvalue(s) or self:formcreated(s) then
-               scope = scope or {}
-               scope.section   = s
-               scope.cbid      = self:cbid(s)
-               scope.striptags = luci.util.striptags
-               scope.pcdata    = luci.util.pcdata
-
-               scope.ifattr = function(cond,key,val)
-                       if cond then
-                               return string.format(
-                                       ' %s="%s"', tostring(key),
-                                       luci.util.pcdata(tostring( val
-                                        or scope[key]
-                                        or (type(self[key]) ~= "function" and self[key])
-                                        or "" ))
-                               )
-                       else
-                               return ''
-                       end
-               end
-
-               scope.attr = function(...)
-                       return scope.ifattr( true, ... )
-               end
-
-               Node.render(self, scope)
-       end
-end
-
--- Return the UCI value of this object
-function AbstractValue.cfgvalue(self, section)
-       local value = (self.error and self.error[section] == "invalid")
-               and self:formvalue(section) or self.map:get(section, self.option)
-       if not value then
-               return nil
-       elseif not self.cast or self.cast == type(value) then
-               return value
-       elseif self.cast == "string" then
-               if type(value) == "table" then
-                       return value[1]
-               end
-       elseif self.cast == "table" then
-               return luci.util.split(value, "%s+", nil, true)
-       end
-end
-
--- Validate the form value
-function AbstractValue.validate(self, value)
-       if self.datatype and value and datatypes[self.datatype] then
-               if type(value) == "table" then
-                       local v
-                       for _, v in ipairs(value) do
-                               if v and #v > 0 and not datatypes[self.datatype](v) then
-                                       return nil
-                               end
-                       end
-               else
-                       if not datatypes[self.datatype](value) then
-                               return nil
-                       end
-               end
-       end
-       return value
-end
-
-AbstractValue.transform = AbstractValue.validate
-
-
--- Write to UCI
-function AbstractValue.write(self, section, value)
-       return self.map:set(section, self.option, value)
-end
-
--- Remove from UCI
-function AbstractValue.remove(self, section)
-       return self.map:del(section, self.option)
-end
-
-
-
-
---[[
-Value - A one-line value
-       maxlength:      The maximum length
-]]--
-Value = class(AbstractValue)
-
-function Value.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template  = "cbi/value"
-       self.keylist = {}
-       self.vallist = {}
-end
-
-function Value.value(self, key, val)
-       val = val or key
-       table.insert(self.keylist, tostring(key))
-       table.insert(self.vallist, tostring(val))
-end
-
-
--- DummyValue - This does nothing except being there
-DummyValue = class(AbstractValue)
-
-function DummyValue.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template = "cbi/dvalue"
-       self.value = nil
-end
-
-function DummyValue.cfgvalue(self, section)
-       local value
-       if self.value then
-               if type(self.value) == "function" then
-                       value = self:value(section)
-               else
-                       value = self.value
-               end
-       else
-               value = AbstractValue.cfgvalue(self, section)
-       end
-       return value
-end
-
-function DummyValue.parse(self)
-
-end
-
-
---[[
-Flag - A flag being enabled or disabled
-]]--
-Flag = class(AbstractValue)
-
-function Flag.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template  = "cbi/fvalue"
-
-       self.enabled = "1"
-       self.disabled = "0"
-end
-
--- A flag can only have two states: set or unset
-function Flag.parse(self, section)
-       local fvalue = self:formvalue(section)
-
-       if fvalue then
-               fvalue = self.enabled
-       else
-               fvalue = self.disabled
-       end
-
-       if fvalue == self.enabled or (not self.optional and not self.rmempty) then
-               if not(fvalue == self:cfgvalue(section)) then
-                       self:write(section, fvalue)
-               end
-       else
-               self:remove(section)
-       end
-end
-
-
-
---[[
-ListValue - A one-line value predefined in a list
-       widget: The widget that will be used (select, radio)
-]]--
-ListValue = class(AbstractValue)
-
-function ListValue.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template  = "cbi/lvalue"
-
-       self.keylist = {}
-       self.vallist = {}
-       self.size   = 1
-       self.widget = "select"
-end
-
-function ListValue.value(self, key, val, ...)
-       if luci.util.contains(self.keylist, key) then
-               return
-       end
-
-       val = val or key
-       table.insert(self.keylist, tostring(key))
-       table.insert(self.vallist, tostring(val))
-
-       for i, deps in ipairs({...}) do
-               self.subdeps[#self.subdeps + 1] = {add = "-"..key, deps=deps}
-       end
-end
-
-function ListValue.validate(self, val)
-       if luci.util.contains(self.keylist, val) then
-               return val
-       else
-               return nil
-       end
-end
-
-
-
---[[
-MultiValue - Multiple delimited values
-       widget: The widget that will be used (select, checkbox)
-       delimiter: The delimiter that will separate the values (default: " ")
-]]--
-MultiValue = class(AbstractValue)
-
-function MultiValue.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template = "cbi/mvalue"
-
-       self.keylist = {}
-       self.vallist = {}
-
-       self.widget = "checkbox"
-       self.delimiter = " "
-end
-
-function MultiValue.render(self, ...)
-       if self.widget == "select" and not self.size then
-               self.size = #self.vallist
-       end
-
-       AbstractValue.render(self, ...)
-end
-
-function MultiValue.value(self, key, val)
-       if luci.util.contains(self.keylist, key) then
-               return
-       end
-
-       val = val or key
-       table.insert(self.keylist, tostring(key))
-       table.insert(self.vallist, tostring(val))
-end
-
-function MultiValue.valuelist(self, section)
-       local val = self:cfgvalue(section)
-
-       if not(type(val) == "string") then
-               return {}
-       end
-
-       return luci.util.split(val, self.delimiter)
-end
-
-function MultiValue.validate(self, val)
-       val = (type(val) == "table") and val or {val}
-
-       local result
-
-       for i, value in ipairs(val) do
-               if luci.util.contains(self.keylist, value) then
-                       result = result and (result .. self.delimiter .. value) or value
-               end
-       end
-
-       return result
-end
-
-
-StaticList = class(MultiValue)
-
-function StaticList.__init__(self, ...)
-       MultiValue.__init__(self, ...)
-       self.cast = "table"
-       self.valuelist = self.cfgvalue
-
-       if not self.override_scheme
-        and self.map:get_scheme(self.section.sectiontype, self.option) then
-               local vs = self.map:get_scheme(self.section.sectiontype, self.option)
-               if self.value and vs.values and not self.override_values then
-                       for k, v in pairs(vs.values) do
-                               self:value(k, v)
-                       end
-               end
-       end
-end
-
-function StaticList.validate(self, value)
-       value = (type(value) == "table") and value or {value}
-
-       local valid = {}
-       for i, v in ipairs(value) do
-               if luci.util.contains(self.keylist, v) then
-                       table.insert(valid, v)
-               end
-       end
-       return valid
-end
-
-
-DynamicList = class(AbstractValue)
-
-function DynamicList.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template  = "cbi/dynlist"
-       self.cast = "table"
-       self.keylist = {}
-       self.vallist = {}
-end
-
-function DynamicList.value(self, key, val)
-       val = val or key
-       table.insert(self.keylist, tostring(key))
-       table.insert(self.vallist, tostring(val))
-end
-
-function DynamicList.write(self, ...)
-       self.map.proceed = true
-       return AbstractValue.write(self, ...)
-end
-
-function DynamicList.formvalue(self, section)
-       local value = AbstractValue.formvalue(self, section)
-       value = (type(value) == "table") and value or {value}
-
-       local valid = {}
-       for i, v in ipairs(value) do
-               if v and #v > 0
-                and not self.map:formvalue("cbi.rle."..section.."."..self.option.."."..i)
-                and not self.map:formvalue("cbi.rle."..section.."."..self.option.."."..i..".x") then
-                       table.insert(valid, v)
-               end
-       end
-
-       return valid
-end
-
-
---[[
-TextValue - A multi-line value
-       rows:   Rows
-]]--
-TextValue = class(AbstractValue)
-
-function TextValue.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template  = "cbi/tvalue"
-end
-
---[[
-Button
-]]--
-Button = class(AbstractValue)
-
-function Button.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template  = "cbi/button"
-       self.inputstyle = nil
-       self.rmempty = true
-end
-
-
-FileUpload = class(AbstractValue)
-
-function FileUpload.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template = "cbi/upload"
-       if not self.map.upload_fields then
-               self.map.upload_fields = { self }
-       else
-               self.map.upload_fields[#self.map.upload_fields+1] = self
-       end
-end
-
-function FileUpload.formcreated(self, section)
-       return AbstractValue.formcreated(self, section) or
-               self.map:formvalue("cbi.rlf."..section.."."..self.option) or
-               self.map:formvalue("cbi.rlf."..section.."."..self.option..".x")
-end
-
-function FileUpload.cfgvalue(self, section)
-       local val = AbstractValue.cfgvalue(self, section)
-       if val and fs.access(val) then
-               return val
-       end
-       return nil
-end
-
-function FileUpload.formvalue(self, section)
-       local val = AbstractValue.formvalue(self, section)
-       if val then
-               if not self.map:formvalue("cbi.rlf."..section.."."..self.option) and
-                  not self.map:formvalue("cbi.rlf."..section.."."..self.option..".x")
-               then
-                       return val
-               end
-               fs.unlink(val)
-               self.value = nil
-       end
-       return nil
-end
-
-function FileUpload.remove(self, section)
-       local val = AbstractValue.formvalue(self, section)
-       if val and fs.access(val) then fs.unlink(val) end
-       return AbstractValue.remove(self, section)
-end
-
-
-FileBrowser = class(AbstractValue)
-
-function FileBrowser.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template = "cbi/browser"
-end
diff --git a/libs/cbi/luasrc/cbi/datatypes.lua b/libs/cbi/luasrc/cbi/datatypes.lua
deleted file mode 100644 (file)
index 53a3454..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
---[[
-
-LuCI - Configuration Bind Interface - Datatype Tests
-(c) 2010 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
-]]--
-
-local fs = require "nixio.fs"
-local ip = require "luci.ip"
-local math = require "math"
-local util = require "luci.util"
-
-local tonumber = tonumber
-
-module "luci.cbi.datatypes"
-
-
-function bool(val)
-       if val == "1" or val == "yes" or val == "on" or val == "true" then
-               return true
-       elseif val == "0" or val == "no" or val == "off" or val == "false" then
-               return true
-       elseif val == "" or val == nil then
-               return true
-       end
-
-       return false
-end
-
-function uint(val)
-       local n = tonumber(val)
-       if n ~= nil and math.floor(n) == n and n >= 0 then
-               return true
-       end
-
-       return false
-end
-
-function int(val)
-       local n = tonumber(val)
-       if n ~= nil and math.floor(n) == n then
-               return true
-       end
-
-       return false
-end
-
-function float(val)
-       return ( tonumber(val) ~= nil )
-end
-
-function ipaddr(val)
-       return ip4addr(val) or ip6addr(val)
-end
-
-function ip4addr(val)
-       if val then
-               return ip.IPv4(val) and true or false
-       end
-
-       return false
-end
-
-function ip4prefix(val)
-       val = tonumber(val)
-       return ( val and val >= 0 and val <= 32 )
-end
-
-function ip6addr(val)
-       if val then
-               return ip.IPv6(val) and true or false
-       end
-
-       return false
-end
-
-function ip6prefix(val)
-       val = tonumber(val)
-       return ( val and val >= 0 and val <= 128 )
-end
-
-function port(val)
-       val = tonumber(val)
-       return ( val and val >= 1 and val <= 65535 )
-end
-
-function portrange(val)
-       local p1, p2 = val:match("^(%d+)%-(%d+)$")
-       if p1 and p2 and port(p1) and port(p2) then
-               return true
-       else
-               return port(val)
-       end
-end
-
-function macaddr(val)
-       if val and val:match(
-               "^[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+:" ..
-                "[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+$"
-       ) then
-               local parts = util.split( val, ":" )
-
-               for i = 1,6 do
-                       parts[i] = tonumber( parts[i], 16 )
-                       if parts[i] < 0 or parts[i] > 255 then
-                               return false
-                       end
-               end
-
-               return true
-       end
-
-       return false
-end
-
-function hostname(val)
-       if val and val:match("[a-zA-Z0-9_][a-zA-Z0-9_%-%.]*") then
-               return true     -- XXX: ToDo: need better solution
-       end
-
-       return false
-end
-
-function host(val)
-       return hostname(val) or ipaddr(val)
-end
-
-function wpakey(val)
-       if #val == 64 then
-               return (val:match("^[a-fA-F0-9]+$") ~= nil)
-       else
-               return (#val >= 8) and (#val <= 63)
-       end
-end
-
-function wepkey(val)
-       if val:sub(1, 2) == "s:" then
-               val = val:sub(3)
-       end
-
-       if (#val == 10) or (#val == 26) then
-               return (val:match("^[a-fA-F0-9]+$") ~= nil)
-       else
-               return (#v == 5) or (#v == 13)
-       end
-end
-
-function string(val)
-       return true             -- Everything qualifies as valid string
-end
-
-function directory( val, seen )
-       local s = fs.stat(val)
-       seen = seen or { }
-
-       if s and not seen[s.ino] then
-               seen[s.ino] = true
-               if s.type == "dir" then
-                       return true
-               elseif s.type == "lnk" then
-                       return directory( fs.readlink(val), seen )
-               end
-       end
-
-       return false
-end
-
-function file( val, seen )
-       local s = fs.stat(val)
-       seen = seen or { }
-
-       if s and not seen[s.ino] then
-               seen[s.ino] = true
-               if s.type == "reg" then
-                       return true
-               elseif s.type == "lnk" then
-                       return file( fs.readlink(val), seen )
-               end
-       end
-
-       return false
-end
-
-function device( val, seen )
-       local s = fs.stat(val)
-       seen = seen or { }
-
-       if s and not seen[s.ino] then
-               seen[s.ino] = true
-               if s.type == "chr" or s.type == "blk" then
-                       return true
-               elseif s.type == "lnk" then
-                       return device( fs.readlink(val), seen )
-               end
-       end
-
-       return false
-end
diff --git a/libs/cbi/luasrc/view/cbi/browser.htm b/libs/cbi/luasrc/view/cbi/browser.htm
deleted file mode 100644 (file)
index 3b7b23f..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<%
-       local t = require("luci.tools.webadmin")
-       local v = self:cfgvalue(section)
--%>
-<%+cbi/valueheader%>
-       <input class="cbi-input-text" type="text"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
-       <input class="cbi-input-image" type="image" value="<%:Search file...%>" onclick="cbi_filebrowser('<%=cbid%>','<%=luci.dispatcher.build_url("admin", "filebrowser")%>'<%=self.default_path and ", '"..self.default_path.."'"%>);return false" alt="<%:Search file...%>" title="<%:Search file...%>" src="<%=resource%>/cbi/folder.png" style="vertical-align:bottom" />
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/button.htm b/libs/cbi/luasrc/view/cbi/button.htm
deleted file mode 100644 (file)
index 5a51897..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+cbi/valueheader%>
-       <% if self:cfgvalue(section) ~= false then %>
-               <input class="cbi-input-<%=self.inputstyle or "button" %>" type="submit"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.title)%> />
-       <% else %>
-               -
-       <% end %>
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/cell_valuefooter.htm b/libs/cbi/luasrc/view/cbi/cell_valuefooter.htm
deleted file mode 100644 (file)
index c325e49..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-</div>
-<div id="cbip-<%=self.config.."-"..section.."-"..self.option%>"></div>
-</td>
-
-<% if #self.deps > 0 then -%>
-       <script type="text/javascript">
-               <% for j, d in ipairs(self.deps) do -%>
-                       cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", {
-               <%-
-                       for k,v in pairs(d.deps) do
-               -%>
-                       <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
-                       <%-if next(d.deps, k) then-%>,<%-end-%>
-               <%-
-                       end
-               -%>
-                       }, "cbip-<%=self.config.."-"..section.."-"..self.option%>");
-               <%- end %>
-       </script>
-<%- end %>
\ No newline at end of file
diff --git a/libs/cbi/luasrc/view/cbi/cell_valueheader.htm b/libs/cbi/luasrc/view/cbi/cell_valueheader.htm
deleted file mode 100644 (file)
index 0f24f1f..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<td class="cbi-value-field<% if self.error and self.error[section] then %> cbi-value-error<% end %>">
-<div id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
diff --git a/libs/cbi/luasrc/view/cbi/compound.htm b/libs/cbi/luasrc/view/cbi/compound.htm
deleted file mode 100644 (file)
index fbd5a0a..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2009 Steven Barth <steven@midlink.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%- self:render_children() %>
\ No newline at end of file
diff --git a/libs/cbi/luasrc/view/cbi/delegator.htm b/libs/cbi/luasrc/view/cbi/delegator.htm
deleted file mode 100644 (file)
index ed7c6b4..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2009 Steven Barth <steven@midlink.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%- self.active:render() %>
-       <div class="cbi-page-actions">
-               <input type="hidden" name="cbi.delg.current" value="<%=self.current%>" />
-<% for _, x in ipairs(self.chain) do %>
-               <input type="hidden" name="cbi.delg.path" value="<%=x%>" />
-<% end %>
-<% if not self.disallow_pageactions then %>
-<% if self.allow_finish and not self:get_next(self.current) then %>
-       <input class="cbi-button cbi-button-finish" type="submit" value="<%:Finish%>" />
-<% elseif self:get_next(self.current) then %>
-               <input class="cbi-button cbi-button-next" type="submit" value="<%:Next Â»%>" />
-<% end %>
-<% if self.allow_cancel then %>
-               <input class="cbi-button cbi-button-cancel" type="submit" name="cbi.cancel" value="<%:Cancel%>" />
-<% end %>
-<% if self.allow_reset then %>
-               <input class="cbi-button cbi-button-reset" type="reset" value="<%:Reset%>" />
-<% end %>
-<% if self.allow_back and self:get_prev(self.current) then %>
-               <input class="cbi-button cbi-button-back" type="submit" name="cbi.delg.back" value="<%:« Back%>" />
-<% end %>
-<% end %>
-               <script type="text/javascript">cbi_d_update();</script>
-       </div>
\ No newline at end of file
diff --git a/libs/cbi/luasrc/view/cbi/dvalue.htm b/libs/cbi/luasrc/view/cbi/dvalue.htm
deleted file mode 100644 (file)
index 9745fff..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<%+cbi/valueheader%>
-<% if self.href then %><a href="<%=self.href%>"><% end -%>
-       <%=pcdata(self:cfgvalue(section) or self.default or "")%>
-<%- if self.href then %></a><%end%>
-&#160;
-<input type="hidden" id="<%=cbid%>" value="<%=pcdata(self:cfgvalue(section) or self.default or "")%>" />
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/dynlist.htm b/libs/cbi/luasrc/view/cbi/dynlist.htm
deleted file mode 100644 (file)
index 826e2e6..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+cbi/valueheader%>
-<%
-       local vals = self:cfgvalue(section) or {}
-       for i=1, #vals + 1 do
-               local val = vals[i]
-%>
-       <input class="cbi-input-text" value="<%=pcdata(val)%>" onchange="cbi_d_update(this.id)" type="text"<%= attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size")%> />
-       <% if i <= #vals then %>
-               <input class="cbi-input-image" type="image" value="<%:Delete%>" name="cbi.rle.<%=section .. "." .. self.option .. "." .. i%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
-       <% else %>
-               <input class="cbi-input-image" type="image" value="<%:Add%>" name="cbi.ale.<%=section .. "." .. self.option%>" alt="<%:Add%>" title="<%:Add%>" src="<%=resource%>/cbi/add.gif" />
-       <% end %>
-       <% if #self.keylist > 0 then -%>
-               <script type="text/javascript">
-                       cbi_combobox_init('<%=cbid .. "." .. i%>', {
-                       <%-
-                               for i, k in ipairs(self.keylist) do
-                       -%>
-                               <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
-                               <%-if i<#self.keylist then-%>,<%-end-%>
-                       <%-
-                               end
-                       -%>
-                       }, '<%- if not self.rmempty and not self.optional then -%>
-                               <%-:cbi_select-%>
-                       <%- end -%>', '<%: -- custom -- %>');
-               </script>
-       <% end -%>
-<% if i <= #vals then %><br />
-<% end end %>
-<% if self.datatype then -%>
-       <script type="text/javascript">
-               <% for i=1, #vals + 1 do -%>
-               cbi_validate_field('<%=cbid%>.<%=i%>', <%=tostring(self.optional == true or i > #vals)%>, '<%=self.datatype%>');
-               <%- end %>
-       </script>
-<% end -%>
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/filebrowser.htm b/libs/cbi/luasrc/view/cbi/filebrowser.htm
deleted file mode 100644 (file)
index f829572..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-    <title>Filebrowser - LuCI</title>
-       <style type="text/css">
-               #path, #listing {
-                       font-size: 85%;
-               }
-
-               ul {
-                       padding-left: 0;
-                       list-style-type: none;
-               }
-
-               li img {
-                       vertical-align: bottom;
-                       margin-right: 0.2em;
-               }
-       </style>
-
-       <script type="text/javascript">
-               function callback(path) {
-                       if( window.opener ) {
-                               var input = window.opener.document.getElementById('<%=luci.http.formvalue('field')%>');
-                               if( input ) {
-                                       input.value = path;
-                                       window.close();
-                               }
-                       }
-               }
-       </script>
-</head>
-<body>
-       <%
-               require("nixio.fs")
-               require("nixio.util")
-               require("luci.http")
-               require("luci.dispatcher")
-
-               local field   = luci.http.formvalue('field')
-               local request = luci.dispatcher.context.path
-               local path    = { '' }
-
-               for i = 3, #request do
-                       if request[i] ~= '..' and #request[i] > 0 then
-                               path[#path+1] = request[i]
-                       end
-               end
-
-               local filepath = table.concat( path, '/' )
-               local filestat = nixio.fs.stat( filepath )
-               local baseurl  = luci.dispatcher.build_url('admin', 'filebrowser')
-
-               if filestat and filestat.type == "reg" then
-                       table.remove( path, #path )
-                       filepath = table.concat( path, '/' ) .. '/'
-               elseif not ( filestat and filestat.type == "dir" ) then
-                       path     = { '' }
-                       filepath = '/'
-               else
-                       filepath = filepath .. '/'
-               end
-
-               local entries = nixio.util.consume((nixio.fs.dir(filepath)))
-       -%>
-    <div id="path">
-               Location:
-               <% for i, dir in ipairs(path) do %>
-                       <% if i == 1 then %>
-                               <a href="<%=baseurl%>?field=<%=field%>">(root)</a>
-                       <% elseif next(path, i) then %>
-                               <% baseurl = baseurl .. '/' .. dir %>
-                               / <a href="<%=baseurl%>?field=<%=field%>"><%=dir%></a>
-                       <% else %>
-                               <% baseurl = baseurl .. '/' .. dir %>
-                               / <%=dir%>
-                       <% end %>
-               <% end %>
-       </div>
-
-       <hr />
-
-       <div id="listing">
-               <ul>
-                       <% for _, e in luci.util.vspairs(entries) do
-                           local stat = nixio.fs.stat(filepath..e)
-                               if stat and stat.type == 'dir' then
-                       -%>
-                               <li class="dir">
-                                       <img src="/luci-static/resources/cbi/folder.png" alt="Directory" />
-                                       <a href="<%=baseurl%>/<%=e%>?field=<%=field%>"><%=e%>/</a>
-                               </li>
-                       <% end end -%>
-
-                       <% for _, e in luci.util.vspairs(entries) do
-                           local stat = nixio.fs.stat(filepath..e)
-                               if stat and stat.type ~= 'dir' then
-                       -%>
-                               <li class="file">
-                                       <img src="/luci-static/resources/cbi/file.png" alt="File" />
-                                       <a href="#" onclick="callback('<%=filepath..e%>')"><%=e%></a>
-                               </li>
-                       <% end end -%>
-               </ul>
-       </div>
-</body>
-</html>
diff --git a/libs/cbi/luasrc/view/cbi/firewall_zonelist.htm b/libs/cbi/luasrc/view/cbi/firewall_zonelist.htm
deleted file mode 100644 (file)
index 4f4106b..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+cbi/valueheader%>
-
-<%-
-       local utl = require "luci.util"
-       local fwm = require "luci.model.firewall"
-       local nwm = require "luci.model.network"
-
-       local zone, net, iface
-       local zones = fwm:get_zones()
-       local value = self:formvalue(section)
-       if not value or value == "-" then value = self:cfgvalue(section) or self.default end
-
-       local selected = false
-       local checked = { }
-
-       if value and #value == 0 then
-               value = nil
-       elseif type(value) == "table" then
-               for _, value in ipairs(value) do
-                       checked[value] = true
-               end
-       elseif value then
-               checked[value] = true           
-       end
--%>
-
-<ul style="margin:0; list-style-type:none; text-align:left">
-       <%
-               for _, zone in utl.spairs(zones, function(a,b) return (zones[a]:name() < zones[b]:name()) end) do
-                       if zone:name() ~= self.exclude then
-                               selected = selected or (value == zone:name())
-       %>
-       <li style="padding:0.5em">
-               <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(checked[zone:name()], "checked", "checked")%> /> &nbsp;
-               <label<%=attr("for", cbid .. "." .. zone:name())%> style="background-color:<%=zone:get_color()%>; padding:0.5em">
-                       <strong><%=zone:name()%>:</strong>
-                       <%
-                               local zempty = true
-                               for _, net in ipairs(zone:get_networks()) do
-                                       net = nwm:get_network(net)
-                                       if net then
-                                               zempty = false
-                       %>
-                               &nbsp;
-                               <%- if net:name() == self.network then -%>
-                                       <span style="background-color:#FFFFFF; border:1px solid #000000; padding:2px; font-weight:bold"><%=net:name()%>:
-                               <%- else -%>
-                                       <span style="background-color:#FFFFFF; border:1px solid #CCCCCC; padding:2px"><%=net:name()%>:
-                               <%- end -%>
-                               <%
-                                       local nempty = true
-                                       for _, iface in ipairs(net and net:get_interfaces() or {}) do
-                                               nempty = false
-                                %>
-                                       <img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
-                               <% end %>
-                               <% if nempty then %><em><%:(no interfaces attached)%></em><% end %>
-                               </span>
-                       <% end end %>
-                       <% if zempty then %><em><%:(no interfaces attached)%></em><% end %>
-               </label>
-       </li>
-       <% end end %>
-
-       <% if self.widget ~= "checkbox" and not self.nocreate then %>
-       <li style="padding:0.5em">
-               <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not selected, "checked", "checked")%> /> &nbsp;
-               <div style="background-color:<%=fwm.zone.get_color()%>; padding:0.5em; display:inline">
-                       <label<%=attr("for", cbid .. "_new")%>><em><%:unspecified -or- create:%>&nbsp;</em></label>
-                       <input style="width:6em" type="text"<%=attr("name", cbid .. ".newzone") .. ifattr(not selected, "value", luci.http.formvalue(cbid .. ".newzone") or self.default)%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
-               </div>
-       </li>
-       <% end %>
-</ul>
-
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/footer.htm b/libs/cbi/luasrc/view/cbi/footer.htm
deleted file mode 100644 (file)
index fe5b688..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-       <%- if pageaction then -%>
-       <div class="cbi-page-actions">
-               <% if flow.skip then %>
-                       <input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
-               <% end %>
-               <% if not autoapply then%>
-                       <input class="cbi-button cbi-button-apply" type="submit" name="cbi.apply" value="<%:Save & Apply%>" />
-               <% end %>
-               <input class="cbi-button cbi-button-save" type="submit" value="<%:Save%>" />
-               <input class="cbi-button cbi-button-reset" type="reset" value="<%:Reset%>" />
-               <script type="text/javascript">cbi_d_update();</script>
-       </div>
-       <%- end -%>
-</form>
-<%+footer%>
diff --git a/libs/cbi/luasrc/view/cbi/full_valuefooter.htm b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm
deleted file mode 100644 (file)
index c069b7f..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-               <% if self.description and #self.description > 0 then -%>
-                       <% if not luci.util.instanceof( self, luci.cbi.Flag ) or self.orientation == "horizontal" then -%>
-                               <br />
-                       <%- end %>
-                       <div class="cbi-value-description">
-                               <span class="cbi-value-helpicon"><img src="<%=resource%>/cbi/help.gif" alt="<%:help%>" /></span>
-                               <%=self.description%>
-                       </div>
-               <%- end %>
-       <%- if self.title and #self.title > 0 then -%>
-       </div>
-       <%- end -%>
-</div>
-
-
-<% if #self.deps > 0 or #self.subdeps > 0 then -%>
-       <script type="text/javascript" id="cbip-<%=self.config.."-"..section.."-"..self.option%>">
-               <% for j, d in ipairs(self.subdeps) do -%>
-                       cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", {
-               <%-
-                       for k,v in pairs(d.deps) do
-                               local depk
-                               if k:find("!", 1, true) then
-                                       depk = string.format('"%s"', k)
-                               elseif k:find(".", 1, true) then
-                                       depk = string.format('"cbid.%s"', k)
-                               else
-                                       depk = string.format('"cbid.%s.%s.%s"', self.config, section, k)
-                               end
-               -%>
-                       <%-= depk .. ":" .. string.format("%q", v)-%>
-                       <%-if next(d.deps, k) then-%>,<%-end-%>
-               <%-
-                       end
-               -%>
-                       }, "cbip-<%=self.config.."-"..section.."-"..self.option..d.add%>");
-               <%- end %>
-               <% for j, d in ipairs(self.deps) do -%>
-                       cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", {
-               <%-
-                       for k,v in pairs(d.deps) do
-                               local depk
-                               if k:find("!", 1, true) then
-                                       depk = string.format('"%s"', k)
-                               elseif k:find(".", 1, true) then
-                                       depk = string.format('"cbid.%s"', k)
-                               else
-                                       depk = string.format('"cbid.%s.%s.%s"', self.config, section, k)
-                               end
-               -%>
-                       <%-= depk .. ":" .. string.format("%q", v)-%>
-                       <%-if next(d.deps, k) then-%>,<%-end-%>
-               <%-
-                       end
-               -%>
-                       }, "cbip-<%=self.config.."-"..section.."-"..self.option..d.add%>");
-               <%- end %>
-       </script>
-<%- end %>
diff --git a/libs/cbi/luasrc/view/cbi/full_valueheader.htm b/libs/cbi/luasrc/view/cbi/full_valueheader.htm
deleted file mode 100644 (file)
index ecd4014..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<div class="cbi-value<% if self.error and self.error[section] then %> cbi-value-error<% end %>" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
-       <%- if self.title and #self.title > 0 then -%>
-       <label class="cbi-value-title"<%= attr("for", cbid) %>>
-       <%- if self.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=self.titleref%>"><%- end -%>
-               <%-=self.title-%>
-       <%- if self.titleref then -%></a><%- end -%>
-       </label>
-               <div class="cbi-value-field">
-       <%- end -%>
diff --git a/libs/cbi/luasrc/view/cbi/fvalue.htm b/libs/cbi/luasrc/view/cbi/fvalue.htm
deleted file mode 100644 (file)
index 35ebac6..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+cbi/valueheader%>
-       <input class="cbi-input-checkbox" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="checkbox"<%= attr("id", cbid) .. attr("name", cbid) .. ifattr((self:cfgvalue(section) or self.default) == self.enabled, "checked", "checked") %> value="1" />
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/header.htm b/libs/cbi/luasrc/view/cbi/header.htm
deleted file mode 100644 (file)
index fd1ab8b..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<%+header%>
-<form method="post" name="cbi" action="<%=REQUEST_URI%>" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, '<%:Some fields are invalid, cannot save values!%>')">
-       <div>
-               <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
-               <input type="hidden" name="cbi.submit" value="1" />
-               <input type="submit" value="<%:Save%>" class="hidden" />
-       </div>
diff --git a/libs/cbi/luasrc/view/cbi/lvalue.htm b/libs/cbi/luasrc/view/cbi/lvalue.htm
deleted file mode 100644 (file)
index 8c7581a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+cbi/valueheader%>
-<% if self.widget == "select" then %>
-       <select class="cbi-input-select" onchange="cbi_d_update(this.id)"<%= attr("id", cbid) .. attr("name", cbid) .. ifattr(self.size, "size") %>>
-       <% for i, key in pairs(self.keylist) do -%>
-               <option id="cbi-<%=self.config.."-"..section.."-"..self.option.."-"..key%>"<%= attr("value", key) .. ifattr((self:cfgvalue(section) or self.default) == key, "selected", "selected") %>><%=striptags(self.vallist[i])%></option>
-       <%- end %>
-       </select>
-<% elseif self.widget == "radio" then
-       local c = 0
-       for i, key in pairs(self.keylist) do
-       c = c + 1
-%>
-       <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%= attr("id", cbid..c) .. attr("name", cbid) .. attr("value", key) .. ifattr((self:cfgvalue(section) or self.default) == key, "checked", "checked") %> />
-       <label<%= attr("for", cbid..c) %>><%=self.vallist[i]%></label>
-<% if c == self.size then c = 0 %><% if self.orientation == "horizontal" then %>&nbsp;<% else %><br /><% end %>
-<% end end %>
-<% end %>
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/map.htm b/libs/cbi/luasrc/view/cbi/map.htm
deleted file mode 100644 (file)
index be0c37a..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<div class="cbi-map" id="cbi-<%=self.config%>">
-       <% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %>
-       <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
-       <%- if self._apply then -%>
-               <fieldset class="cbi-section" id="cbi-apply-<%=self.config%>">
-                       <legend><%:Applying changes%></legend>
-                       <script type="text/javascript"><![CDATA[
-                               var apply_xhr = new XHR();
-
-                               apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "restart", table.concat(self.parsechain, ","))%>', null,
-                                       function() {
-                                               var intv = window.setInterval(
-                                                       function() {
-                                                               apply_xhr.abort();
-                                                               apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "status")%>', null,
-                                                                       function(x) {
-                                                                               if( x.responseText == 'finish' )
-                                                                               {
-                                                                                       window.clearInterval(intv);
-
-                                                                                       var e = document.getElementById('cbi-apply-<%=self.config%>-status');
-                                                                                       if( e )
-                                                                                       {
-                                                                                               e.innerHTML = '<%:Configuration applied.%>';
-                                                                                               window.setTimeout(function() { e.parentNode.style.display = 'none' }, 1000);
-                                                                                       }
-                                                                               }
-                                                                               else
-                                                                               {
-                                                                                       var e = document.getElementById('cbi-apply-<%=self.config%>-status');
-                                                                                       if( e && x.responseText ) e.innerHTML = x.responseText;
-
-                                                                               }
-                                                                       }
-                                                               );
-                                                       }, 1000
-                                               )
-                                       }
-                               );
-                       ]]></script>
-
-                       <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
-                       <span id="cbi-apply-<%=self.config%>-status"><%:Waiting for router...%></span>
-               </fieldset>
-       <%- end -%>
-       <%- self:render_children() %>
-       <br />
-</div>
diff --git a/libs/cbi/luasrc/view/cbi/mvalue.htm b/libs/cbi/luasrc/view/cbi/mvalue.htm
deleted file mode 100644 (file)
index 3812a3f..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%
-local v = self:valuelist(section) or {}
-%>
-<%+cbi/valueheader%>
-<% if self.widget == "select" then %>
-       <select class="cbi-input-select" multiple="multiple"<%= attr("name", cbid) .. ifattr(self.size, "size") %>>
-       <% for i, key in pairs(self.keylist) do -%>
-               <option<%= attr("value", key) .. ifattr(luci.util.contains(v, key), "selected", "selected") %>><%=striptags(self.vallist[i])%></option>
-       <%- end %>
-       </select>
-<% elseif self.widget == "checkbox" then
-       local c = 0;
-       for i, key in pairs(self.keylist) do
-       c = c + 1
-%>
-       <input class="cbi-input-checkbox" type="checkbox"<%= attr("id", cbid..c) .. attr("name", cbid) .. attr("value", key) .. ifattr(luci.util.contains(v, key), "checked", "checked") %> />
-       <label<%= attr("for", cbid..c) %>><%=self.vallist[i]%></label><br />
-<% if c == self.size then c = 0 %><br />
-<% end end %>
-<% end %>
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/network_ifacelist.htm b/libs/cbi/luasrc/view/cbi/network_ifacelist.htm
deleted file mode 100644 (file)
index 2f98218..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+cbi/valueheader%>
-
-<%-
-       local utl = require "luci.util"
-       local net = require "luci.model.network"
-
-       local iface
-       local ifaces = net:get_interfaces()
-       local value = (self:formvalue(section) or self.default or "")
-       local checked = { }
-
-       if value and #value > 0 then
-               if type(value) == "table" then value = table.concat(value, " ") end
-               for value in value:gmatch("%S+") do
-                       checked[value] = true
-               end             
-       else
-               local n = self.network and net:get_network(self.network)
-               if n then
-                       local i
-                       for _, i in ipairs(n:get_interfaces()) do
-                               checked[i:name()] = true
-                       end
-               end
-       end
--%>
-
-<ul style="margin:0; list-style-type:none">
-       <% for _, iface in utl.spairs(ifaces, function(a,b) return (ifaces[a]:type() < ifaces[b]:type()) end) do
-         if not self.nobridges or not iface:is_bridge() then %>
-       <li>
-               <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. iface:name()) .. attr("name", cbid) .. attr("value", iface:name()) .. ifattr(checked[iface:name()], "checked", "checked")%> /> &nbsp;
-               <label<%=attr("for", cbid .. "." .. iface:name())%>>
-                       <img title="<%=iface:get_type_i18n()%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
-                       <%=iface:get_i18n()%><% local n = iface:get_network(); if n then %> (<%=n:name()%>)<% end %>
-               </label>
-       </li>
-       <% end end %>
-</ul>
-
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/network_netlist.htm b/libs/cbi/luasrc/view/cbi/network_netlist.htm
deleted file mode 100644 (file)
index c47b3a7..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+cbi/valueheader%>
-
-<%-
-       local utl = require "luci.util"
-       local nwm = require "luci.model.network"
-
-       local net, iface
-       local networks = nwm:get_networks()
-       local value = self:formvalue(section)
-
-       if not value or value == "-" then
-               value = self:cfgvalue(section) or self.default
-       end
--%>
-
-<ul style="margin:0; list-style-type:none; text-align:left">
-       <% for _, net in utl.spairs(networks, function(a,b) return (networks[a]:name() < networks[b]:name()) end) do
-              if net:name() ~= "loopback" then %>
-       <li style="padding:0.25em 0">
-               <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. net:name()) .. attr("name", cbid) .. attr("value", net:name()) .. ifattr(value == net:name(), "checked", "checked")%> /> &nbsp;
-               <label<%=attr("for", cbid .. "." .. net:name())%>>
-                       &nbsp;<span style="background-color:#FFFFFF; border:1px solid #CCCCCC; padding:2px"><%=net:name()%>:
-                               <%
-                                       local empty = true
-                                       for _, iface in ipairs(net:get_interfaces()) do
-                                               if not iface:is_bridge() then
-                                                       empty = false
-                                %>
-                                       <img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
-                               <% end end %>
-                               <% if empty then %><em><%:(no interfaces attached)%></em><% end %>
-                       </span>
-               </label>
-       </li>
-       <% end end %>
-
-       <% if self.widget ~= "checkbox" and not self.nocreate then %>
-       <li style="padding:0.25em 0">
-               <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not value, "checked", "checked")%> /> &nbsp;
-               <div style="padding:0.5em; display:inline">
-                       <label<%=attr("for", cbid .. "_new")%>><em><%:unspecified -or- create:%>&nbsp;</em></label>
-                       <input style="width:6em" type="text"<%=attr("name", cbid .. ".newnet")%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
-               </div>
-       </li>
-       <% end %>
-</ul>
-
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/nsection.htm b/libs/cbi/luasrc/view/cbi/nsection.htm
deleted file mode 100644 (file)
index 1d231c5..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008-2009 Jo-Philipp Wich <xm@subsignal>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<% if self:cfgvalue(self.section) then section = self.section %>
-       <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=section%>">
-               <% if self.title and #self.title > 0 then -%>
-                       <legend><%=self.title%></legend>
-               <%- end %>
-               <% if self.description and #self.description > 0 then -%>
-                       <div class="cbi-section-descr"><%=self.description%></div>
-               <%- end %>
-               <% if self.addremove then -%>
-                       <div class="cbi-section-remove right">
-                               <input type="submit" name="cbi.rns.<%=self.config%>.<%=section%>" value="<%:Delete%>" />
-                       </div>
-               <%- end %>
-               <%+cbi/tabmenu%>
-               <div class="cbi-section-node" id="cbi-<%=self.config%>-<%=section%>">
-                       <%+cbi/ucisection%>
-               </div>
-               <br />
-       </fieldset>
-<% elseif self.addremove then %>
-       <% if self.template_addremove then include(self.template_addremove) else -%>
-       <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.section%>">
-               <% if self.title and #self.title > 0 then -%>
-                       <legend><%=self.title%></legend>
-               <%- end %>
-               <div class="cbi-section-descr"><%=self.description%></div>
-               <input type="submit" class="cbi-button-add" name="cbi.cns.<%=self.config%>.<%=self.section%>" value="<%:Add%>" />
-       </fieldset>
-       <%- end %>
-<% end %>
-<!-- /nsection -->
diff --git a/libs/cbi/luasrc/view/cbi/nullsection.htm b/libs/cbi/luasrc/view/cbi/nullsection.htm
deleted file mode 100644 (file)
index f1c715b..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-               <fieldset class="cbi-section">
-                       <% if self.title and #self.title > 0 then -%>
-                               <legend><%=self.title%></legend>
-                       <%- end %>
-                       <div class="cbi-section-node" id="cbi-<%=self.config%>-<%=tostring(self):sub(8)%>">
-                               <% self:render_children(1, scope or {}) %>
-                       </div>
-                       <br />
-               </fieldset>
-               <%-
-                       if type(self.hidden) == "table" then
-                               for k, v in pairs(self.hidden) do
-               -%>
-                       <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
-               <%-
-                               end
-                       end
-               %>
diff --git a/libs/cbi/luasrc/view/cbi/simpleform.htm b/libs/cbi/luasrc/view/cbi/simpleform.htm
deleted file mode 100644 (file)
index 9c40f82..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<% if not self.embedded then %>
-<form method="post" action="<%=REQUEST_URI%>">
-       <div>
-               <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
-               <input type="hidden" name="cbi.submit" value="1" />
-       </div>
-<% end %>
-       <div class="cbi-map" id="cbi-<%=self.config%>">
-               <% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %>
-               <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
-               <% self:render_children() %>
-               <br />
-       </div>
-<%- if self.message then %>
-       <div><%=self.message%></div>
-<%- end %>
-<%- if self.errmessage then %>
-       <div class="error"><%=self.errmessage%></div>
-<%- end %>     
-<% if not self.embedded then %>
-       <div>
-<%-
-       if type(self.hidden) == "table" then
-               for k, v in pairs(self.hidden) do
--%>
-       <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
-<%-
-               end
-       end
-%>
-<%- if self.flow and self.flow.skip then %>
-       <input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
-<% end %>
-<%- if self.submit ~= false then %>
-       <input class="cbi-button-save" type="submit" value="
-               <%- if not self.submit then -%><%-:Submit-%><%-else-%><%=self.submit%><%end-%>
-       " />
-<% end %>
-<%- if self.reset ~= false then %>
-       <input class="cbi-button-reset" type="reset" value="
-               <%- if not self.reset then -%><%-:Reset-%><%-else-%><%=self.reset%><%end-%>
-       " />
-<% end %>
-<%- if self.cancel ~= false and self.on_cancel then %>
-       <input class="cbi-button-reset" type="submit" name="cbi.cancel" value="
-               <%- if not self.cancel then -%><%-:Cancel-%><%-else-%><%=self.cancel%><%end-%>
-       " />
-<% end %>
-               <script type="text/javascript">cbi_d_update();</script>
-       </div>
-</form>
-<% end %>
diff --git a/libs/cbi/luasrc/view/cbi/tabcontainer.htm b/libs/cbi/luasrc/view/cbi/tabcontainer.htm
deleted file mode 100644 (file)
index 9b2c798..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<% for tab, data in pairs(self.tabs) do %>
-       <div id="container.<%=self.config%>.<%=section%>.<%=tab%>"<% if tab ~= self.selected_tab then %> style="display:none"<% end %>>
-               <% if data.description then %><div class="cbi-tab-descr"><%=data.description%></div><% end %>
-               <% self:render_tab(tab, section, scope or {}) %>
-       </div>
-       <script type="text/javascript">cbi_t_add('<%=self.config%>.<%=section%>', '<%=tab%>')</script>
-<% end %>
diff --git a/libs/cbi/luasrc/view/cbi/tabmenu.htm b/libs/cbi/luasrc/view/cbi/tabmenu.htm
deleted file mode 100644 (file)
index 7648fe0..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<%- if self.tabs then %>
-       <ul class="cbi-tabmenu">
-       <%- self.selected_tab = luci.http.formvalue("tab." .. self.config .. "." .. section) %>
-       <%- for _, tab in ipairs(self.tab_names) do if #self.tabs[tab].childs > 0 then %>
-               <script type="text/javascript">cbi_c['container.<%=self.config%>.<%=section%>.<%=tab%>'] = <%=#self.tabs[tab].childs%>;</script>
-               <%- if not self.selected_tab then self.selected_tab = tab end %>
-               <li id="tab.<%=self.config%>.<%=section%>.<%=tab%>" class="cbi-tab<%=(tab == self.selected_tab) and '' or '-disabled'%>">
-                       <a onclick="this.blur(); return cbi_t_switch('<%=self.config%>.<%=section%>', '<%=tab%>')" href="<%=REQUEST_URI%>?tab.<%=self.config%>.<%=section%>=<%=tab%>"><%=self.tabs[tab].title%></a>
-                       <% if tab == self.selected_tab then %><input type="hidden" id="tab.<%=self.config%>.<%=section%>" name="tab.<%=self.config%>.<%=section%>" value="<%=tab%>" /><% end %>
-               </li>
-       <% end end -%>
-       </ul>
-<% end -%>
diff --git a/libs/cbi/luasrc/view/cbi/tblsection.htm b/libs/cbi/luasrc/view/cbi/tblsection.htm
deleted file mode 100644 (file)
index 0224610..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%-
-local rowcnt = 1
-function rowstyle()
-       rowcnt = rowcnt + 1
-       return (rowcnt % 2) + 1
-end
--%>
-
-<!-- tblsection -->
-<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
-       <% if self.title and #self.title > 0 then -%>
-               <legend><%=self.title%></legend>
-       <%- end %>
-       <div class="cbi-section-descr"><%=self.description%></div>
-       <div class="cbi-section-node">
-               <%- local count = 0 -%>
-               <table class="cbi-section-table">
-                       <tr class="cbi-section-table-titles">
-                       <%- if not self.anonymous then -%>
-                               <%- if self.sectionhead then -%>
-                                       <th class="cbi-section-table-cell"><%=self.sectionhead%></th>
-                               <%- else -%>
-                                       <th>&#160;</th>
-                               <%- end -%>
-                       <%- end -%>
-                       <%- for i, k in pairs(self.children) do if not k.optional then -%>
-                               <th class="cbi-section-table-cell">
-                               <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
-                                       <%-=k.title-%>
-                               <%- if k.titleref then -%></a><%- end -%>
-                               </th>
-                       <%- count = count + 1; end; end; if self.extedit or self.addremove then -%>
-                               <th class="cbi-section-table-cell">&#160;</th>
-                       <%- count = count + 1; end -%>
-                       </tr>
-                       <tr class="cbi-section-table-descr">
-                       <%- if not self.anonymous then -%>
-                               <%- if self.sectiondesc then -%>
-                                       <th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
-                               <%- else -%>
-                                       <th></th>
-                               <%- end -%>
-                       <%- end -%>
-                       <%- for i, k in pairs(self.children) do if not k.optional then -%>
-                               <th class="cbi-section-table-cell"><%=k.description%></th>
-                       <%- end; end; if self.extedit or self.addremove then -%>
-                               <th class="cbi-section-table-cell"></th>
-                       <%- end -%>
-                       </tr>
-                       <%- local isempty = true
-                           for i, k in ipairs(self:cfgsections()) do
-                                       section = k
-                                       isempty = false
-                                       scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
-                       -%>
-                       <tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
-                               <% if not self.anonymous then -%>
-                                       <th><h3><%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%></h3></th>
-                               <%- end %>
-
-
-                               <%-
-                                       for k, node in ipairs(self.children) do
-                                               if not node.optional then
-                                                       node:render(section, scope or {})
-                                               end
-                                       end
-                               -%>
-
-                               <%- if self.extedit or self.addremove then -%>
-                                       <td class="cbi-section-table-cell">
-                                               <%- if self.extedit then -%>
-                                                       <a href="
-                                                       <%- if type(self.extedit) == "string" then -%>
-                                                               <%=self.extedit:format(section)%>
-                                                       <%- elseif type(self.extedit) == "function" then -%>
-                                                               <%=self:extedit(section)%>
-                                                       <%- end -%>
-                                                       " title="<%:Edit%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:Edit%>" /></a>
-                                               <%- end; if self.addremove then %>
-                                                       <input type="image" value="<%:Delete%>" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
-                                               <%- end -%>
-                                       </td>
-                               <%- end -%>
-                       </tr>
-                       <%- end -%>
-
-                       <%- if isempty then -%>
-                       <tr class="cbi-section-table-row">
-                               <td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
-                       </tr>
-                       <%- end -%>
-               </table>
-
-               <% if self.error then %>
-                       <div class="cbi-section-error">
-                               <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
-                                       <li><%=pcdata(e):gsub("\n","<br />")%></li>
-                               <%- end end %></ul>
-                       </div>
-               <% end %>
-
-               <%- if self.addremove then -%>
-                       <% if self.template_addremove then include(self.template_addremove) else -%>
-                       <div class="cbi-section-create cbi-tblsection-create">
-                               <% if self.anonymous then %>
-                                       <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:Add%>" />
-                               <% else %>
-                                       <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
-                                       <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
-                                       <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" title="<%:Add%>" />
-                                       <% if self.invalid_cts then -%>
-                                               <br /><%:Invalid%></div>
-                                       <%- end %>
-                               <% end %>
-                       </div>
-                       <%- end %>
-               <%- end -%>
-       </div>
-</fieldset>
-<!-- /tblsection -->
diff --git a/libs/cbi/luasrc/view/cbi/tsection.htm b/libs/cbi/luasrc/view/cbi/tsection.htm
deleted file mode 100644 (file)
index 0fa285c..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
-       <% if self.title and #self.title > 0 then -%>
-               <legend><%=self.title%></legend>
-       <%- end %>
-       <div class="cbi-section-descr"><%=self.description%></div>
-       <% local isempty = true for i, k in ipairs(self:cfgsections()) do -%>
-               <% if self.addremove then -%>
-                       <div class="cbi-section-remove right">
-                               <input type="submit" name="cbi.rts.<%=self.config%>.<%=k%>" value="<%:Delete%>" />
-                       </div>
-               <%- end %>
-
-               <%- section = k; isempty = false -%>
-
-               <% if not self.anonymous then -%>
-                       <h3><%=section:upper()%></h3>
-               <%- end %>
-
-               <%+cbi/tabmenu%>
-
-               <fieldset class="cbi-section-node" id="cbi-<%=self.config%>-<%=section%>">
-                       <%+cbi/ucisection%>
-               </fieldset>
-               <br />
-       <%- end %>
-
-       <% if isempty then -%>
-               <em><%:This section contains no values yet%><br /><br /></em>
-       <%- end %>
-
-       <% if self.addremove then -%>
-               <% if self.template_addremove then include(self.template_addremove) else -%>
-               <div class="cbi-section-create">
-                       <% if self.anonymous then -%>
-                               <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" value="<%:Add%>" />
-                       <%- else -%>
-                               <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
-                               <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
-                               <input type="submit" class="cbi-button cbi-button-add" value="<%:Add%>" />
-                               <% if self.invalid_cts then -%>
-                                       <br /><%:Invalid%></div>
-                               <%- end %>
-                       <%- end %>
-               </div>
-               <%- end %>
-       <%- end %>
-</fieldset>
diff --git a/libs/cbi/luasrc/view/cbi/tvalue.htm b/libs/cbi/luasrc/view/cbi/tvalue.htm
deleted file mode 100644 (file)
index b628c5c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+cbi/valueheader%>
-       <textarea class="cbi-input-textarea" <% if not self.size then %> style="width: 100%"<% else %> cols="<%=self.size%>"<% end %> onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. ifattr(self.rows, "rows") .. ifattr(self.wrap, "wrap") %>>
-       <%-=pcdata(self:cfgvalue(section))-%>
-       </textarea>
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/ucisection.htm b/libs/cbi/luasrc/view/cbi/ucisection.htm
deleted file mode 100644 (file)
index db32c90..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<%-
-       if type(self.hidden) == "table" then
-               for k, v in pairs(self.hidden) do
--%>
-       <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
-<%-
-               end
-       end
-%>
-
-<% if self.tabs then %>
-       <%+cbi/tabcontainer%>
-<% else %>
-       <% self:render_children(section, scope or {}) %>
-<% end %>
-
-<% if self.error and self.error[section] then -%>
-       <div class="cbi-section-error">
-               <ul><% for _, e in ipairs(self.error[section]) do -%>
-                       <li>
-                               <%- if e == "invalid" then -%>
-                                       <%:One or more fields contain invalid values!%>
-                               <%- elseif e == "missing" then -%>
-                                       <%:One or more required fields have no value!%>
-                               <%- else -%>
-                                       <%=pcdata(e)%>
-                               <%- end -%>
-                       </li>
-               <%- end %></ul>
-       </div>
-<%- end %>
-
-<% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
-       <div class="cbi-optionals">
-               <% if self.dynamic then %>
-                       <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
-                       <% if self.optionals[section] and #self.optionals[section] > 0 then %>
-                       <script type="text/javascript">
-                               cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', {
-                               <%-
-                                       for i, val in pairs(self.optionals[section]) do
-                               -%>
-                                       <%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%>
-                                       <%-if next(self.optionals[section], i) then-%>,<%-end-%>
-                               <%-
-                                       end
-                               -%>
-                               }, '', '<%-: -- custom -- -%>');
-                       </script>
-                       <% end %>
-               <% else %>
-               <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
-                       <option><%: -- Additional Field -- %></option>
-                       <% for key, val in pairs(self.optionals[section]) do -%>
-                               <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
-                       <%- end %>
-               </select>
-               <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
-                       <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
-                       cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
-               <%-
-                       for k,v in pairs(d.deps) do
-               -%>
-                       <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
-                       <%-if next(d.deps, k) then-%>,<%-end-%>
-               <%-
-                       end
-               -%>
-                       });
-               <%- end %><% end %>
-               <% end %></script>
-       <% end %>
-               <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" />
-       </div>
-<% end %>
diff --git a/libs/cbi/luasrc/view/cbi/upload.htm b/libs/cbi/luasrc/view/cbi/upload.htm
deleted file mode 100644 (file)
index f5baa33..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008-2009 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<%
-       local t = require("luci.tools.webadmin")
-       local v = self:cfgvalue(section)
-       local s = v and nixio.fs.stat(v)
--%>
-<%+cbi/valueheader%>
-       <% if s then %>
-               <%:Uploaded File%> (<%=t.byte_format(s.size)%>)
-               <input type="hidden"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
-               <input class="cbi-input-image" type="image" value="<%:Replace entry%>" name="cbi.rlf.<%=section .. "." .. self.option%>" alt="<%:Replace entry%>" title="<%:Replace entry%>" src="<%=resource%>/cbi/reload.gif" />
-       <% else %>
-               <input class="cbi-input-file" type="file"<%= attr("name", cbid) .. attr("id", cbid) %> />
-       <% end %>
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/value.htm b/libs/cbi/luasrc/view/cbi/value.htm
deleted file mode 100644 (file)
index a7b49de..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-<%+cbi/valueheader%>
-       <input type="<%=self.password and 'password" class="cbi-input-password' or 'text" class="cbi-input-text' %>" onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section) or self.default) .. ifattr(self.size, "size")%> />
-       <% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
-       <% if #self.keylist > 0 or self.datatype then -%>
-       <script type="text/javascript">
-               <% if #self.keylist > 0 then -%>
-               cbi_combobox_init('<%=cbid%>', {
-               <%-
-                       for i, k in ipairs(self.keylist) do
-               -%>
-                       <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
-                       <%-if i<#self.keylist then-%>,<%-end-%>
-               <%-
-                       end
-               -%>
-               }, '<%- if not self.rmempty and not self.optional then -%>
-                       <%-: -- Please choose -- -%>
-               <%- end -%>', '
-               <%- if self.combobox_manual then -%>
-                       <%-=self.combobox_manual-%>
-               <%- else -%>
-                       <%-: -- custom -- -%>
-               <%- end -%>');
-               <%- end %>
-               <% if self.datatype then -%>
-               cbi_validate_field('<%=cbid%>', <%=tostring(self.optional == true)%>, '<%=self.datatype%>');
-               <%- end %>
-       </script>
-       <% end -%>
-<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/valuefooter.htm b/libs/cbi/luasrc/view/cbi/valuefooter.htm
deleted file mode 100644 (file)
index a65c7a3..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<% include( valuefooter or "cbi/full_valuefooter" ) %>
diff --git a/libs/cbi/luasrc/view/cbi/valueheader.htm b/libs/cbi/luasrc/view/cbi/valueheader.htm
deleted file mode 100644 (file)
index f3da909..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
-
-<% include( valueheader or "cbi/full_valueheader" ) %>
diff --git a/libs/cbi/root/lib/uci/upload/.gitignore b/libs/cbi/root/lib/uci/upload/.gitignore
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js
new file mode 100644 (file)
index 0000000..4af6e58
--- /dev/null
@@ -0,0 +1,518 @@
+/*
+       LuCI - Lua Configuration Interface
+
+       Copyright 2008 Steven Barth <steven@midlink.org>
+       Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
+
+       Licensed under the Apache License, Version 2.0 (the "License");
+       you may not use this file except in compliance with the License.
+       You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+*/
+
+var cbi_d = [];
+var cbi_t = [];
+var cbi_c = [];
+
+var cbi_validators = {
+
+       'integer': function(v)
+       {
+               return (v.match(/^-?[0-9]+$/) != null);
+       },
+
+       'uinteger': function(v)
+       {
+               return (cbi_validators.integer(v) && (v >= 0));
+       },
+
+       'ipaddr': function(v)
+       {
+               return cbi_validators.ip4addr(v) || cbi_validators.ip6addr(v);
+       },
+
+       'ip4addr': function(v)
+       {
+               if( v.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)(\/(\d+))?$/) )
+               {
+                       return (RegExp.$1 >= 0) && (RegExp.$1 <= 255) &&
+                              (RegExp.$2 >= 0) && (RegExp.$2 <= 255) &&
+                              (RegExp.$3 >= 0) && (RegExp.$3 <= 255) &&
+                              (RegExp.$4 >= 0) && (RegExp.$4 <= 255) &&
+                              (!RegExp.$5 || ((RegExp.$6 >= 0) && (RegExp.$6 <= 32)))
+                       ;
+               }
+
+               return false;
+       },
+
+       'ip6addr': function(v)
+       {
+               if( v.match(/^([a-fA-F0-9:.]+)(\/(\d+))?$/) )
+               {
+                       if( !RegExp.$2 || ((RegExp.$3 >= 0) && (RegExp.$3 <= 128)) )
+                       {
+                               var addr = RegExp.$1;
+
+                               if( addr == '::' )
+                               {
+                                       return true;
+                               }
+
+                               if( addr.indexOf('.') > 0 )
+                               {
+                                       var off = addr.lastIndexOf(':');
+
+                                       if( !(off && cbi_validators.ip4addr(addr.substr(off+1))) )
+                                               return false;
+
+                                       addr = addr.substr(0, off) + ':0:0';
+                               }
+
+                               if( addr.indexOf('::') < 0 )
+                               {
+                                       return (addr.match(/^(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}$/) != null);
+                               }
+
+                               var fields = 0;
+
+                               for( var i = 0, last = 0, comp = false; i <= addr.length; i++ )
+                               {
+                                       if( (addr.charAt(i) == ':') || (i == addr.length) )
+                                       {
+                                               if( (i == last) && !comp )
+                                               {
+                                                       comp = true;
+                                               }
+                                               else
+                                               {
+                                                       var f = addr.substring(last, i);
+                                                       if( !(f && f.match(/^[a-fA-F0-9]{1,4}$/)) )
+                                                               return false;
+                                               }
+
+                                               fields++;
+                                               last = i + 1;
+                                       }                               
+                               }
+
+                               return (fields == 8);
+                       }
+               }
+
+               return false;
+       },
+
+       'port': function(v)
+       {
+               return cbi_validators.integer(v) && (v >= 0) && (v <= 65535);
+       },
+
+       'portrange': function(v)
+       {
+               if( v.match(/^(\d+)-(\d+)$/) )
+               {
+                       var p1 = RegExp.$1;
+                       var p2 = RegExp.$2;
+
+                       return cbi_validators.port(p1) &&
+                              cbi_validators.port(p2) &&
+                              (parseInt(p1) <= parseInt(p2))
+                       ;
+               }
+               else
+               {
+                       return cbi_validators.port(v);
+               }
+       },
+
+       'macaddr': function(v)
+       {
+               return (v.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null);
+       },
+
+       'host': function(v)
+       {
+               return cbi_validators.hostname(v) || cbi_validators.ipaddr(v);
+       },
+
+       'hostname': function(v)
+       {
+               return (v.match(/^[a-zA-Z_][a-zA-Z0-9_\-.]*$/) != null);
+       },
+
+       'wpakey': function(v)
+       {
+               if( v.length == 64 )
+                       return (v.match(/^[a-fA-F0-9]{64}$/) != null);
+               else
+                       return (v.length >= 8) && (v.length <= 63);
+       },
+
+       'wepkey': function(v)
+       {
+               if( v.substr(0,2) == 's:' )
+                       v = v.substr(2);
+
+               if( (v.length == 10) || (v.length == 26) )
+                       return (v.match(/^[a-fA-F0-9]{10,26}$/) != null);
+               else
+                       return (v.length == 5) || (v.length == 13);
+       },
+
+};
+
+
+function cbi_d_add(field, dep, next) {
+       var obj = document.getElementById(field);
+       if (obj) {
+               var entry
+               for (var i=0; i<cbi_d.length; i++) {
+                       if (cbi_d[i].id == field) {
+                               entry = cbi_d[i];
+                               break;
+                       }
+               }
+               if (!entry) {
+                       entry = {
+                               "node": obj,
+                               "id": field,
+                               "parent": obj.parentNode.id,
+                               "next": next,
+                               "deps": []
+                       };
+                       cbi_d.unshift(entry);
+               }
+               entry.deps.push(dep)
+       }
+}
+
+function cbi_d_checkvalue(target, ref) {
+       var t = document.getElementById(target);
+       var value;
+
+       if (!t) {
+               var tl = document.getElementsByName(target);
+
+               if( tl.length > 0 && tl[0].type == 'radio' )
+                       for( var i = 0; i < tl.length; i++ )
+                               if( tl[i].checked ) {
+                                       value = tl[i].value;
+                                       break;
+                               }
+
+               value = value ? value : "";
+       } else if (!t.value) {
+               value = "";
+       } else {
+               value = t.value;
+
+               if (t.type == "checkbox") {
+                       value = t.checked ? value : "";
+               }
+       }
+
+       return (value == ref)
+}
+
+function cbi_d_check(deps) {
+       var reverse;
+       var def = false;
+       for (var i=0; i<deps.length; i++) {
+               var istat = true;
+               reverse = false;
+               for (var j in deps[i]) {
+                       if (j == "!reverse") {
+                               reverse = true;
+                       } else if (j == "!default") {
+                               def = true;
+                               istat = false;
+                       } else {
+                               istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
+                       }
+               }
+               if (istat) {
+                       return !reverse;
+               }
+       }
+       return def;
+}
+
+function cbi_d_update() {
+       var state = false;
+       for (var i=0; i<cbi_d.length; i++) {
+               var entry = cbi_d[i];
+               var next  = document.getElementById(entry.next)
+               var node  = document.getElementById(entry.id)
+               var parent = document.getElementById(entry.parent)
+
+               if (node && node.parentNode && !cbi_d_check(entry.deps)) {
+                       node.parentNode.removeChild(node);
+                       state = true;
+                       if( entry.parent )
+                               cbi_c[entry.parent]--;
+               } else if ((!node || !node.parentNode) && cbi_d_check(entry.deps)) {
+                       if (!next) {
+                               parent.appendChild(entry.node);
+                       } else {
+                               next.parentNode.insertBefore(entry.node, next);
+                       }
+                       state = true;
+                       if( entry.parent )
+                               cbi_c[entry.parent]++;
+               }
+       }
+
+       if (entry.parent) {
+               cbi_t_update();
+       }
+
+       if (state) {
+               cbi_d_update();
+       }
+}
+
+function cbi_bind(obj, type, callback, mode) {
+       if (typeof mode == "undefined") {
+               mode = false;
+       }
+       if (!obj.addEventListener) {
+               ieCallback = function(){
+                       var e = window.event;
+                       if (!e.target && e.srcElement) {
+                               e.target = e.srcElement;
+                       };
+                       e.target['_eCB' + type + callback] = callback;
+                       e.target['_eCB' + type + callback](e);
+                       e.target['_eCB' + type + callback] = null;
+               };
+               obj.attachEvent('on' + type, ieCallback);
+       } else {
+               obj.addEventListener(type, callback, mode);
+       }
+       return obj;
+}
+
+function cbi_combobox(id, values, def, man) {
+       var selid = "cbi.combobox." + id;
+       if (document.getElementById(selid)) {
+               return
+       }
+
+       var obj = document.getElementById(id)
+       var sel = document.createElement("select");
+       sel.id = selid;
+       sel.className = 'cbi-input-select';
+       if (obj.className && obj.className.match(/cbi-input-invalid/)) {
+               sel.className += ' cbi-input-invalid';
+       }
+       if (obj.nextSibling) {
+               obj.parentNode.insertBefore(sel, obj.nextSibling);
+       } else {
+               obj.parentNode.appendChild(sel);
+       }
+
+       if (!values[obj.value]) {
+               if (obj.value == "") {
+                       var optdef = document.createElement("option");
+                       optdef.value = "";
+                       optdef.appendChild(document.createTextNode(def));
+                       sel.appendChild(optdef);
+               } else {
+                       var opt = document.createElement("option");
+                       opt.value = obj.value;
+                       opt.selected = "selected";
+                       opt.appendChild(document.createTextNode(obj.value));
+                       sel.appendChild(opt);
+               }
+       }
+
+       for (var i in values) {
+               var opt = document.createElement("option");
+               opt.value = i;
+
+               if (obj.value == i) {
+                       opt.selected = "selected";
+               }
+
+               opt.appendChild(document.createTextNode(values[i]));
+               sel.appendChild(opt);
+       }
+
+       var optman = document.createElement("option");
+       optman.value = "";
+       optman.appendChild(document.createTextNode(man));
+       sel.appendChild(optman);
+
+       obj.style.display = "none";
+
+       cbi_bind(sel, "change", function() {
+               if (sel.selectedIndex == sel.options.length - 1) {
+                       obj.style.display = "inline";
+                       sel.parentNode.removeChild(sel);
+                       obj.focus();
+               } else {
+                       obj.value = sel.options[sel.selectedIndex].value;
+                       sel.className = (!obj.validate || obj.validate())
+                               ? 'cbi-input-select' : 'cbi-input-select cbi-input-invalid';
+               }
+
+               try {
+                       cbi_d_update();
+               } catch (e) {
+                       //Do nothing
+               }
+       })
+}
+
+function cbi_combobox_init(id, values, def, man) {
+       var obj = document.getElementById(id);
+       cbi_bind(obj, "blur", function() {
+               cbi_combobox(id, values, def, man)
+       });
+       cbi_combobox(id, values, def, man);
+}
+
+function cbi_filebrowser(id, url, defpath) {
+       var field   = document.getElementById(id);
+       var browser = window.open(
+               url + ( field.value || defpath || '' ) + '?field=' + id,
+               "luci_filebrowser", "width=300,height=400,left=100,top=200,scrollbars=yes"
+       );
+
+       browser.focus();
+}
+
+//Hijacks the CBI form to send via XHR (requires Prototype)
+function cbi_hijack_forms(layer, win, fail, load) {
+       var forms = layer.getElementsByTagName('form');
+       for (var i=0; i<forms.length; i++) {
+               $(forms[i]).observe('submit', function(event) {
+                       // Prevent the form from also submitting the regular way
+                       event.stop();
+
+                       // Submit via XHR
+                       event.element().request({
+                               onSuccess: win,
+                               onFailure: fail
+                       });
+
+                       if (load) {
+                               load();
+                       }
+               });
+       }
+}
+
+
+function cbi_t_add(section, tab) {
+       var t = document.getElementById('tab.' + section + '.' + tab);
+       var c = document.getElementById('container.' + section + '.' + tab);
+
+       if( t && c ) {
+               cbi_t[section] = (cbi_t[section] || [ ]);
+               cbi_t[section][tab] = { 'tab': t, 'container': c, 'cid': c.id };
+       }
+}
+
+function cbi_t_switch(section, tab) {
+       if( cbi_t[section] && cbi_t[section][tab] ) {
+               var o = cbi_t[section][tab];
+               var h = document.getElementById('tab.' + section);
+               for( var tid in cbi_t[section] ) {
+                       var o2 = cbi_t[section][tid];
+                       if( o.tab.id != o2.tab.id ) {
+                               o2.tab.className = o2.tab.className.replace(/(^| )cbi-tab( |$)/, " cbi-tab-disabled ");
+                               o2.container.style.display = 'none';
+                       }
+                       else {
+                               if(h) h.value = tab;
+                               o2.tab.className = o2.tab.className.replace(/(^| )cbi-tab-disabled( |$)/, " cbi-tab ");
+                               o2.container.style.display = 'block';
+                       }
+               }
+       }
+       return false
+}
+
+function cbi_t_update() {
+       for( var sid in cbi_t )
+               for( var tid in cbi_t[sid] )
+                       if( cbi_c[cbi_t[sid][tid].cid] == 0 ) {
+                               cbi_t[sid][tid].tab.style.display = 'none';
+                       }
+                       else if( cbi_t[sid][tid].tab && cbi_t[sid][tid].tab.style.display == 'none' ) {
+                               cbi_t[sid][tid].tab.style.display = '';
+
+                               var t = cbi_t[sid][tid].tab;
+                               window.setTimeout(function() { t.className = t.className.replace(/ cbi-tab-highlighted/g, '') }, 750);
+                               cbi_t[sid][tid].tab.className += ' cbi-tab-highlighted';
+                       }
+}
+
+
+function cbi_validate_form(form, errmsg)
+{
+       if( form.cbi_validators )
+       {
+               for( var i = 0; i < form.cbi_validators.length; i++ )
+               {
+                       var validator = form.cbi_validators[i];
+                       if( !validator() && errmsg )
+                       {
+                               alert(errmsg);
+                               return false;
+                       }
+               }
+       }
+
+       return true;
+}
+
+function cbi_validate_reset(form)
+{
+       window.setTimeout(
+               function() { cbi_validate_form(form, null) }, 100
+       );
+
+       return true;
+}
+
+function cbi_validate_field(cbid, optional, type)
+{
+       var field = document.getElementById(cbid);
+       var vldcb = cbi_validators[type];
+
+       if( field && vldcb )
+       {
+               var validator = function(reset)
+               {
+                       // is not detached
+                       if( field.form )
+                       {
+                               field.className = field.className.replace(/ cbi-input-invalid/g, '');
+
+                               // validate value
+                               var value = (field.options) ? field.options[field.options.selectedIndex].value : field.value;
+                               if( !(((value.length == 0) && optional) || vldcb(value)) )
+                               {
+                                       // invalid
+                                       field.className += ' cbi-input-invalid';
+                                       return false;
+                               }
+                       }
+
+                       return true;
+               };
+
+               if( ! field.form.cbi_validators )
+                       field.form.cbi_validators = [ ];
+
+               field.form.cbi_validators.push(validator);
+               field.onblur = field.onkeyup = field.validate = validator;
+
+               validator();
+       }
+}
+
diff --git a/libs/web/htdocs/luci-static/resources/cbi/add.gif b/libs/web/htdocs/luci-static/resources/cbi/add.gif
new file mode 100644 (file)
index 0000000..0888abf
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/add.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/apply.gif b/libs/web/htdocs/luci-static/resources/cbi/apply.gif
new file mode 100644 (file)
index 0000000..82ae7ed
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/apply.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/arrow.gif b/libs/web/htdocs/luci-static/resources/cbi/arrow.gif
new file mode 100644 (file)
index 0000000..10d797e
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/arrow.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/download.gif b/libs/web/htdocs/luci-static/resources/cbi/download.gif
new file mode 100644 (file)
index 0000000..f99a538
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/download.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/edit.gif b/libs/web/htdocs/luci-static/resources/cbi/edit.gif
new file mode 100644 (file)
index 0000000..7b02b6e
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/edit.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/fieldadd.gif b/libs/web/htdocs/luci-static/resources/cbi/fieldadd.gif
new file mode 100644 (file)
index 0000000..431ff64
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/fieldadd.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/find.gif b/libs/web/htdocs/luci-static/resources/cbi/find.gif
new file mode 100644 (file)
index 0000000..9ae5e34
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/find.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/help.gif b/libs/web/htdocs/luci-static/resources/cbi/help.gif
new file mode 100644 (file)
index 0000000..9dfa0e1
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/help.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/key.gif b/libs/web/htdocs/luci-static/resources/cbi/key.gif
new file mode 100644 (file)
index 0000000..e3853e5
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/key.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/link.gif b/libs/web/htdocs/luci-static/resources/cbi/link.gif
new file mode 100644 (file)
index 0000000..f0bb78d
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/link.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/reload.gif b/libs/web/htdocs/luci-static/resources/cbi/reload.gif
new file mode 100644 (file)
index 0000000..8268958
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/reload.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/remove.gif b/libs/web/htdocs/luci-static/resources/cbi/remove.gif
new file mode 100644 (file)
index 0000000..bf43a0a
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/remove.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/reset.gif b/libs/web/htdocs/luci-static/resources/cbi/reset.gif
new file mode 100644 (file)
index 0000000..c941c19
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/reset.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/save.gif b/libs/web/htdocs/luci-static/resources/cbi/save.gif
new file mode 100644 (file)
index 0000000..35e9499
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/save.gif differ
diff --git a/libs/web/htdocs/luci-static/resources/cbi/user.gif b/libs/web/htdocs/luci-static/resources/cbi/user.gif
new file mode 100644 (file)
index 0000000..dcb5c2a
Binary files /dev/null and b/libs/web/htdocs/luci-static/resources/cbi/user.gif differ
diff --git a/libs/web/luasrc/cbi.lua b/libs/web/luasrc/cbi.lua
new file mode 100644 (file)
index 0000000..8dd16b1
--- /dev/null
@@ -0,0 +1,1707 @@
+--[[
+LuCI - Configuration Bind Interface
+
+Description:
+Offers an interface for binding configuration values to certain
+data types. Supports value and range validation and basic dependencies.
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("luci.cbi", package.seeall)
+
+require("luci.template")
+local util = require("luci.util")
+require("luci.http")
+
+
+--local event      = require "luci.sys.event"
+local fs         = require("nixio.fs")
+local uci        = require("luci.model.uci")
+local datatypes  = require("luci.cbi.datatypes")
+local class      = util.class
+local instanceof = util.instanceof
+
+FORM_NODATA  =  0
+FORM_PROCEED =  0
+FORM_VALID   =  1
+FORM_DONE       =  1
+FORM_INVALID = -1
+FORM_CHANGED =  2
+FORM_SKIP    =  4
+
+AUTO = true
+
+CREATE_PREFIX = "cbi.cts."
+REMOVE_PREFIX = "cbi.rts."
+
+-- Loads a CBI map from given file, creating an environment and returns it
+function load(cbimap, ...)
+       local fs   = require "nixio.fs"
+       local i18n = require "luci.i18n"
+       require("luci.config")
+       require("luci.util")
+
+       local upldir = "/lib/uci/upload/"
+       local cbidir = luci.util.libpath() .. "/model/cbi/"
+       local func, err
+
+       if fs.access(cbidir..cbimap..".lua") then
+               func, err = loadfile(cbidir..cbimap..".lua")
+       elseif fs.access(cbimap) then
+               func, err = loadfile(cbimap)
+       else
+               func, err = nil, "Model '" .. cbimap .. "' not found!"
+       end
+
+       assert(func, err)
+
+       luci.i18n.loadc("base")
+
+       local env = {
+               translate=i18n.translate,
+               translatef=i18n.translatef,
+               arg={...}
+       }
+
+       setfenv(func, setmetatable(env, {__index =
+               function(tbl, key)
+                       return rawget(tbl, key) or _M[key] or _G[key]
+               end}))
+
+       local maps       = { func() }
+       local uploads    = { }
+       local has_upload = false
+
+       for i, map in ipairs(maps) do
+               if not instanceof(map, Node) then
+                       error("CBI map returns no valid map object!")
+                       return nil
+               else
+                       map:prepare()
+                       if map.upload_fields then
+                               has_upload = true
+                               for _, field in ipairs(map.upload_fields) do
+                                       uploads[
+                                               field.config .. '.' ..
+                                               field.section.sectiontype .. '.' ..
+                                               field.option
+                                       ] = true
+                               end
+                       end
+               end
+       end
+
+       if has_upload then
+               local uci = luci.model.uci.cursor()
+               local prm = luci.http.context.request.message.params
+               local fd, cbid
+
+               luci.http.setfilehandler(
+                       function( field, chunk, eof )
+                               if not field then return end
+                               if field.name and not cbid then
+                                       local c, s, o = field.name:gmatch(
+                                               "cbid%.([^%.]+)%.([^%.]+)%.([^%.]+)"
+                                       )()
+
+                                       if c and s and o then
+                                               local t = uci:get( c, s )
+                                               if t and uploads[c.."."..t.."."..o] then
+                                                       local path = upldir .. field.name
+                                                       fd = io.open(path, "w")
+                                                       if fd then
+                                                               cbid = field.name
+                                                               prm[cbid] = path
+                                                       end
+                                               end
+                                       end
+                               end
+
+                               if field.name == cbid and fd then
+                                       fd:write(chunk)
+                               end
+
+                               if eof and fd then
+                                       fd:close()
+                                       fd   = nil
+                                       cbid = nil
+                               end
+                       end
+               )
+       end
+
+       return maps
+end
+
+
+-- Node pseudo abstract class
+Node = class()
+
+function Node.__init__(self, title, description)
+       self.children = {}
+       self.title = title or ""
+       self.description = description or ""
+       self.template = "cbi/node"
+end
+
+-- hook helper
+function Node._run_hook(self, hook)
+       if type(self[hook]) == "function" then
+               return self[hook](self)
+       end
+end
+
+function Node._run_hooks(self, ...)
+       local f
+       local r = false
+       for _, f in ipairs(arg) do
+               if type(self[f]) == "function" then
+                       self[f](self)
+                       r = true
+               end
+       end
+       return r
+end
+
+-- Prepare nodes
+function Node.prepare(self, ...)
+       for k, child in ipairs(self.children) do
+               child:prepare(...)
+       end
+end
+
+-- Append child nodes
+function Node.append(self, obj)
+       table.insert(self.children, obj)
+end
+
+-- Parse this node and its children
+function Node.parse(self, ...)
+       for k, child in ipairs(self.children) do
+               child:parse(...)
+       end
+end
+
+-- Render this node
+function Node.render(self, scope)
+       scope = scope or {}
+       scope.self = self
+
+       luci.template.render(self.template, scope)
+end
+
+-- Render the children
+function Node.render_children(self, ...)
+       for k, node in ipairs(self.children) do
+               node:render(...)
+       end
+end
+
+
+--[[
+A simple template element
+]]--
+Template = class(Node)
+
+function Template.__init__(self, template)
+       Node.__init__(self)
+       self.template = template
+end
+
+function Template.render(self)
+       luci.template.render(self.template, {self=self})
+end
+
+function Template.parse(self, readinput)
+       self.readinput = (readinput ~= false)
+       return Map.formvalue(self, "cbi.submit") and FORM_DONE or FORM_NODATA
+end
+
+
+--[[
+Map - A map describing a configuration file
+]]--
+Map = class(Node)
+
+function Map.__init__(self, config, ...)
+       Node.__init__(self, ...)
+
+       self.config = config
+       self.parsechain = {self.config}
+       self.template = "cbi/map"
+       self.apply_on_parse = nil
+       self.readinput = true
+       self.proceed = false
+       self.flow = {}
+
+       self.uci = uci.cursor()
+       self.save = true
+
+       self.changed = false
+
+       if not self.uci:load(self.config) then
+               error("Unable to read UCI data: " .. self.config)
+       end
+end
+
+function Map.formvalue(self, key)
+       return self.readinput and luci.http.formvalue(key)
+end
+
+function Map.formvaluetable(self, key)
+       return self.readinput and luci.http.formvaluetable(key) or {}
+end
+
+function Map.get_scheme(self, sectiontype, option)
+       if not option then
+               return self.scheme and self.scheme.sections[sectiontype]
+       else
+               return self.scheme and self.scheme.variables[sectiontype]
+                and self.scheme.variables[sectiontype][option]
+       end
+end
+
+function Map.submitstate(self)
+       return self:formvalue("cbi.submit")
+end
+
+-- Chain foreign config
+function Map.chain(self, config)
+       table.insert(self.parsechain, config)
+end
+
+function Map.state_handler(self, state)
+       return state
+end
+
+-- Use optimized UCI writing
+function Map.parse(self, readinput, ...)
+       self.readinput = (readinput ~= false)
+       self:_run_hooks("on_parse")
+
+       if self:formvalue("cbi.skip") then
+               self.state = FORM_SKIP
+               return self:state_handler(self.state)
+       end
+
+       Node.parse(self, ...)
+
+       if self.save then
+               for i, config in ipairs(self.parsechain) do
+                       self.uci:save(config)
+               end
+               if self:submitstate() and ((not self.proceed and self.flow.autoapply) or luci.http.formvalue("cbi.apply")) then
+                       self:_run_hooks("on_before_commit")
+                       for i, config in ipairs(self.parsechain) do
+                               self.uci:commit(config)
+
+                               -- Refresh data because commit changes section names
+                               self.uci:load(config)
+                       end
+                       self:_run_hooks("on_commit", "on_after_commit", "on_before_apply")
+                       if self.apply_on_parse then
+                               self.uci:apply(self.parsechain)
+                               self:_run_hooks("on_apply", "on_after_apply")
+                       else
+                               self._apply = function()
+                                       local cmd = self.uci:apply(self.parsechain, true)
+                                       return io.popen(cmd)
+                               end
+                       end
+
+                       -- Reparse sections
+                       Node.parse(self, true)
+
+               end
+               for i, config in ipairs(self.parsechain) do
+                       self.uci:unload(config)
+               end
+               if type(self.commit_handler) == "function" then
+                       self:commit_handler(self:submitstate())
+               end
+       end
+
+       if self:submitstate() then
+               if not self.save then
+                       self.state = FORM_INVALID
+               elseif self.proceed then
+                       self.state = FORM_PROCEED
+               else
+                       self.state = self.changed and FORM_CHANGED or FORM_VALID
+               end
+       else
+               self.state = FORM_NODATA
+       end
+
+       return self:state_handler(self.state)
+end
+
+function Map.render(self, ...)
+       self:_run_hooks("on_init")
+       Node.render(self, ...)
+       if false and self._apply then
+               local fp = self._apply()
+               fp:read("*a")
+               fp:close()
+               self:_run_hooks("on_apply")
+       end
+end
+
+-- Creates a child section
+function Map.section(self, class, ...)
+       if instanceof(class, AbstractSection) then
+               local obj  = class(self, ...)
+               self:append(obj)
+               return obj
+       else
+               error("class must be a descendent of AbstractSection")
+       end
+end
+
+-- UCI add
+function Map.add(self, sectiontype)
+       return self.uci:add(self.config, sectiontype)
+end
+
+-- UCI set
+function Map.set(self, section, option, value)
+       if option then
+               return self.uci:set(self.config, section, option, value)
+       else
+               return self.uci:set(self.config, section, value)
+       end
+end
+
+-- UCI del
+function Map.del(self, section, option)
+       if option then
+               return self.uci:delete(self.config, section, option)
+       else
+               return self.uci:delete(self.config, section)
+       end
+end
+
+-- UCI get
+function Map.get(self, section, option)
+       if not section then
+               return self.uci:get_all(self.config)
+       elseif option then
+               return self.uci:get(self.config, section, option)
+       else
+               return self.uci:get_all(self.config, section)
+       end
+end
+
+--[[
+Compound - Container
+]]--
+Compound = class(Node)
+
+function Compound.__init__(self, ...)
+       Node.__init__(self)
+       self.template = "cbi/compound"
+       self.children = {...}
+end
+
+function Compound.populate_delegator(self, delegator)
+       for _, v in ipairs(self.children) do
+               v.delegator = delegator
+       end
+end
+
+function Compound.parse(self, ...)
+       local cstate, state = 0
+
+       for k, child in ipairs(self.children) do
+               cstate = child:parse(...)
+               state = (not state or cstate < state) and cstate or state
+       end
+
+       return state
+end
+
+
+--[[
+Delegator - Node controller
+]]--
+Delegator = class(Node)
+function Delegator.__init__(self, ...)
+       Node.__init__(self, ...)
+       self.nodes = {}
+       self.defaultpath = {}
+       self.pageaction = false
+       self.readinput = true
+       self.allow_reset = false
+       self.allow_cancel = false
+       self.allow_back = false
+       self.allow_finish = false
+       self.template = "cbi/delegator"
+end
+
+function Delegator.set(self, name, node)
+       assert(not self.nodes[name], "Duplicate entry")
+
+       self.nodes[name] = node
+end
+
+function Delegator.add(self, name, node)
+       node = self:set(name, node)
+       self.defaultpath[#self.defaultpath+1] = name
+end
+
+function Delegator.insert_after(self, name, after)
+       local n = #self.chain + 1
+       for k, v in ipairs(self.chain) do
+               if v == after then
+                       n = k + 1
+                       break
+               end
+       end
+       table.insert(self.chain, n, name)
+end
+
+function Delegator.set_route(self, ...)
+       local n, chain, route = 0, self.chain, {...}
+       for i = 1, #chain do
+               if chain[i] == self.current then
+                       n = i
+                       break
+               end
+       end
+       for i = 1, #route do
+               n = n + 1
+               chain[n] = route[i]
+       end
+       for i = n + 1, #chain do
+               chain[i] = nil
+       end
+end
+
+function Delegator.get(self, name)
+       local node = self.nodes[name]
+
+       if type(node) == "string" then
+               node = load(node, name)
+       end
+
+       if type(node) == "table" and getmetatable(node) == nil then
+               node = Compound(unpack(node))
+       end
+
+       return node
+end
+
+function Delegator.parse(self, ...)
+       if self.allow_cancel and Map.formvalue(self, "cbi.cancel") then
+               if self:_run_hooks("on_cancel") then
+                       return FORM_DONE
+               end
+       end
+
+       if not Map.formvalue(self, "cbi.delg.current") then
+               self:_run_hooks("on_init")
+       end
+
+       local newcurrent
+       self.chain = self.chain or self:get_chain()
+       self.current = self.current or self:get_active()
+       self.active = self.active or self:get(self.current)
+       assert(self.active, "Invalid state")
+
+       local stat = FORM_DONE
+       if type(self.active) ~= "function" then
+               self.active:populate_delegator(self)
+               stat = self.active:parse()
+       else
+               self:active()
+       end
+
+       if stat > FORM_PROCEED then
+               if Map.formvalue(self, "cbi.delg.back") then
+                       newcurrent = self:get_prev(self.current)
+               else
+                       newcurrent = self:get_next(self.current)
+               end
+       elseif stat < FORM_PROCEED then
+               return stat
+       end
+
+
+       if not Map.formvalue(self, "cbi.submit") then
+               return FORM_NODATA
+       elseif stat > FORM_PROCEED
+       and (not newcurrent or not self:get(newcurrent)) then
+               return self:_run_hook("on_done") or FORM_DONE
+       else
+               self.current = newcurrent or self.current
+               self.active = self:get(self.current)
+               if type(self.active) ~= "function" then
+                       self.active:populate_delegator(self)
+                       local stat = self.active:parse(false)
+                       if stat == FORM_SKIP then
+                               return self:parse(...)
+                       else
+                               return FORM_PROCEED
+                       end
+               else
+                       return self:parse(...)
+               end
+       end
+end
+
+function Delegator.get_next(self, state)
+       for k, v in ipairs(self.chain) do
+               if v == state then
+                       return self.chain[k+1]
+               end
+       end
+end
+
+function Delegator.get_prev(self, state)
+       for k, v in ipairs(self.chain) do
+               if v == state then
+                       return self.chain[k-1]
+               end
+       end
+end
+
+function Delegator.get_chain(self)
+       local x = Map.formvalue(self, "cbi.delg.path") or self.defaultpath
+       return type(x) == "table" and x or {x}
+end
+
+function Delegator.get_active(self)
+       return Map.formvalue(self, "cbi.delg.current") or self.chain[1]
+end
+
+--[[
+Page - A simple node
+]]--
+
+Page = class(Node)
+Page.__init__ = Node.__init__
+Page.parse    = function() end
+
+
+--[[
+SimpleForm - A Simple non-UCI form
+]]--
+SimpleForm = class(Node)
+
+function SimpleForm.__init__(self, config, title, description, data)
+       Node.__init__(self, title, description)
+       self.config = config
+       self.data = data or {}
+       self.template = "cbi/simpleform"
+       self.dorender = true
+       self.pageaction = false
+       self.readinput = true
+end
+
+SimpleForm.formvalue = Map.formvalue
+SimpleForm.formvaluetable = Map.formvaluetable
+
+function SimpleForm.parse(self, readinput, ...)
+       self.readinput = (readinput ~= false)
+
+       if self:formvalue("cbi.skip") then
+               return FORM_SKIP
+       end
+
+       if self:formvalue("cbi.cancel") and self:_run_hooks("on_cancel") then
+               return FORM_DONE
+       end
+
+       if self:submitstate() then
+               Node.parse(self, 1, ...)
+       end
+
+       local valid = true
+       for k, j in ipairs(self.children) do
+               for i, v in ipairs(j.children) do
+                       valid = valid
+                        and (not v.tag_missing or not v.tag_missing[1])
+                        and (not v.tag_invalid or not v.tag_invalid[1])
+                        and (not v.error)
+               end
+       end
+
+       local state =
+               not self:submitstate() and FORM_NODATA
+               or valid and FORM_VALID
+               or FORM_INVALID
+
+       self.dorender = not self.handle
+       if self.handle then
+               local nrender, nstate = self:handle(state, self.data)
+               self.dorender = self.dorender or (nrender ~= false)
+               state = nstate or state
+       end
+       return state
+end
+
+function SimpleForm.render(self, ...)
+       if self.dorender then
+               Node.render(self, ...)
+       end
+end
+
+function SimpleForm.submitstate(self)
+       return self:formvalue("cbi.submit")
+end
+
+function SimpleForm.section(self, class, ...)
+       if instanceof(class, AbstractSection) then
+               local obj  = class(self, ...)
+               self:append(obj)
+               return obj
+       else
+               error("class must be a descendent of AbstractSection")
+       end
+end
+
+-- Creates a child field
+function SimpleForm.field(self, class, ...)
+       local section
+       for k, v in ipairs(self.children) do
+               if instanceof(v, SimpleSection) then
+                       section = v
+                       break
+               end
+       end
+       if not section then
+               section = self:section(SimpleSection)
+       end
+
+       if instanceof(class, AbstractValue) then
+               local obj  = class(self, section, ...)
+               obj.track_missing = true
+               section:append(obj)
+               return obj
+       else
+               error("class must be a descendent of AbstractValue")
+       end
+end
+
+function SimpleForm.set(self, section, option, value)
+       self.data[option] = value
+end
+
+
+function SimpleForm.del(self, section, option)
+       self.data[option] = nil
+end
+
+
+function SimpleForm.get(self, section, option)
+       return self.data[option]
+end
+
+
+function SimpleForm.get_scheme()
+       return nil
+end
+
+
+Form = class(SimpleForm)
+
+function Form.__init__(self, ...)
+       SimpleForm.__init__(self, ...)
+       self.embedded = true
+end
+
+
+--[[
+AbstractSection
+]]--
+AbstractSection = class(Node)
+
+function AbstractSection.__init__(self, map, sectiontype, ...)
+       Node.__init__(self, ...)
+       self.sectiontype = sectiontype
+       self.map = map
+       self.config = map.config
+       self.optionals = {}
+       self.defaults = {}
+       self.fields = {}
+       self.tag_error = {}
+       self.tag_invalid = {}
+       self.tag_deperror = {}
+       self.changed = false
+
+       self.optional = true
+       self.addremove = false
+       self.dynamic = false
+end
+
+-- Define a tab for the section
+function AbstractSection.tab(self, tab, title, desc)
+       self.tabs      = self.tabs      or { }
+       self.tab_names = self.tab_names or { }
+
+       self.tab_names[#self.tab_names+1] = tab
+       self.tabs[tab] = {
+               title       = title,
+               description = desc,
+               childs      = { }
+       }
+end
+
+-- Check whether the section has tabs
+function AbstractSection.has_tabs(self)
+       return (self.tabs ~= nil) and (next(self.tabs) ~= nil)
+end
+
+-- Appends a new option
+function AbstractSection.option(self, class, option, ...)
+       if instanceof(class, AbstractValue) then
+               local obj  = class(self.map, self, option, ...)
+               self:append(obj)
+               self.fields[option] = obj
+               return obj
+       elseif class == true then
+               error("No valid class was given and autodetection failed.")
+       else
+               error("class must be a descendant of AbstractValue")
+       end
+end
+
+-- Appends a new tabbed option
+function AbstractSection.taboption(self, tab, ...)
+
+       assert(tab and self.tabs and self.tabs[tab],
+               "Cannot assign option to not existing tab %q" % tostring(tab))
+
+       local l = self.tabs[tab].childs
+       local o = AbstractSection.option(self, ...)
+
+       if o then l[#l+1] = o end
+
+       return o
+end
+
+-- Render a single tab
+function AbstractSection.render_tab(self, tab, ...)
+
+       assert(tab and self.tabs and self.tabs[tab],
+               "Cannot render not existing tab %q" % tostring(tab))
+
+       for _, node in ipairs(self.tabs[tab].childs) do
+               node:render(...)
+       end
+end
+
+-- Parse optional options
+function AbstractSection.parse_optionals(self, section)
+       if not self.optional then
+               return
+       end
+
+       self.optionals[section] = {}
+
+       local field = self.map:formvalue("cbi.opt."..self.config.."."..section)
+       for k,v in ipairs(self.children) do
+               if v.optional and not v:cfgvalue(section) and not self:has_tabs() then
+                       if field == v.option then
+                               field = nil
+                               self.map.proceed = true
+                       else
+                               table.insert(self.optionals[section], v)
+                       end
+               end
+       end
+
+       if field and #field > 0 and self.dynamic then
+               self:add_dynamic(field)
+       end
+end
+
+-- Add a dynamic option
+function AbstractSection.add_dynamic(self, field, optional)
+       local o = self:option(Value, field, field)
+       o.optional = optional
+end
+
+-- Parse all dynamic options
+function AbstractSection.parse_dynamic(self, section)
+       if not self.dynamic then
+               return
+       end
+
+       local arr  = luci.util.clone(self:cfgvalue(section))
+       local form = self.map:formvaluetable("cbid."..self.config.."."..section)
+       for k, v in pairs(form) do
+               arr[k] = v
+       end
+
+       for key,val in pairs(arr) do
+               local create = true
+
+               for i,c in ipairs(self.children) do
+                       if c.option == key then
+                               create = false
+                       end
+               end
+
+               if create and key:sub(1, 1) ~= "." then
+                       self.map.proceed = true
+                       self:add_dynamic(key, true)
+               end
+       end
+end
+
+-- Returns the section's UCI table
+function AbstractSection.cfgvalue(self, section)
+       return self.map:get(section)
+end
+
+-- Push events
+function AbstractSection.push_events(self)
+       --luci.util.append(self.map.events, self.events)
+       self.map.changed = true
+end
+
+-- Removes the section
+function AbstractSection.remove(self, section)
+       self.map.proceed = true
+       return self.map:del(section)
+end
+
+-- Creates the section
+function AbstractSection.create(self, section)
+       local stat
+
+       if section then
+               stat = section:match("^[%w_]+$") and self.map:set(section, nil, self.sectiontype)
+       else
+               section = self.map:add(self.sectiontype)
+               stat = section
+       end
+
+       if stat then
+               for k,v in pairs(self.children) do
+                       if v.default then
+                               self.map:set(section, v.option, v.default)
+                       end
+               end
+
+               for k,v in pairs(self.defaults) do
+                       self.map:set(section, k, v)
+               end
+       end
+
+       self.map.proceed = true
+
+       return stat
+end
+
+
+SimpleSection = class(AbstractSection)
+
+function SimpleSection.__init__(self, form, ...)
+       AbstractSection.__init__(self, form, nil, ...)
+       self.template = "cbi/nullsection"
+end
+
+
+Table = class(AbstractSection)
+
+function Table.__init__(self, form, data, ...)
+       local datasource = {}
+       local tself = self
+       datasource.config = "table"
+       self.data = data or {}
+
+       datasource.formvalue = Map.formvalue
+       datasource.formvaluetable = Map.formvaluetable
+       datasource.readinput = true
+
+       function datasource.get(self, section, option)
+               return tself.data[section] and tself.data[section][option]
+       end
+
+       function datasource.submitstate(self)
+               return Map.formvalue(self, "cbi.submit")
+       end
+
+       function datasource.del(...)
+               return true
+       end
+
+       function datasource.get_scheme()
+               return nil
+       end
+
+       AbstractSection.__init__(self, datasource, "table", ...)
+       self.template = "cbi/tblsection"
+       self.rowcolors = true
+       self.anonymous = true
+end
+
+function Table.parse(self, readinput)
+       self.map.readinput = (readinput ~= false)
+       for i, k in ipairs(self:cfgsections()) do
+               if self.map:submitstate() then
+                       Node.parse(self, k)
+               end
+       end
+end
+
+function Table.cfgsections(self)
+       local sections = {}
+
+       for i, v in luci.util.kspairs(self.data) do
+               table.insert(sections, i)
+       end
+
+       return sections
+end
+
+function Table.update(self, data)
+       self.data = data
+end
+
+
+
+--[[
+NamedSection - A fixed configuration section defined by its name
+]]--
+NamedSection = class(AbstractSection)
+
+function NamedSection.__init__(self, map, section, stype, ...)
+       AbstractSection.__init__(self, map, stype, ...)
+
+       -- Defaults
+       self.addremove = false
+       self.template = "cbi/nsection"
+       self.section = section
+end
+
+function NamedSection.parse(self, novld)
+       local s = self.section
+       local active = self:cfgvalue(s)
+
+       if self.addremove then
+               local path = self.config.."."..s
+               if active then -- Remove the section
+                       if self.map:formvalue("cbi.rns."..path) and self:remove(s) then
+                               self:push_events()
+                               return
+                       end
+               else           -- Create and apply default values
+                       if self.map:formvalue("cbi.cns."..path) then
+                               self:create(s)
+                               return
+                       end
+               end
+       end
+
+       if active then
+               AbstractSection.parse_dynamic(self, s)
+               if self.map:submitstate() then
+                       Node.parse(self, s)
+               end
+               AbstractSection.parse_optionals(self, s)
+
+               if self.changed then
+                       self:push_events()
+               end
+       end
+end
+
+
+--[[
+TypedSection - A (set of) configuration section(s) defined by the type
+       addremove:      Defines whether the user can add/remove sections of this type
+       anonymous:  Allow creating anonymous sections
+       validate:       a validation function returning nil if the section is invalid
+]]--
+TypedSection = class(AbstractSection)
+
+function TypedSection.__init__(self, map, type, ...)
+       AbstractSection.__init__(self, map, type, ...)
+
+       self.template = "cbi/tsection"
+       self.deps = {}
+       self.anonymous = false
+end
+
+-- Return all matching UCI sections for this TypedSection
+function TypedSection.cfgsections(self)
+       local sections = {}
+       self.map.uci:foreach(self.map.config, self.sectiontype,
+               function (section)
+                       if self:checkscope(section[".name"]) then
+                               table.insert(sections, section[".name"])
+                       end
+               end)
+
+       return sections
+end
+
+-- Limits scope to sections that have certain option => value pairs
+function TypedSection.depends(self, option, value)
+       table.insert(self.deps, {option=option, value=value})
+end
+
+function TypedSection.parse(self, novld)
+       if self.addremove then
+               -- Remove
+               local crval = REMOVE_PREFIX .. self.config
+               local name = self.map:formvaluetable(crval)
+               for k,v in pairs(name) do
+                       if k:sub(-2) == ".x" then
+                               k = k:sub(1, #k - 2)
+                       end
+                       if self:cfgvalue(k) and self:checkscope(k) then
+                               self:remove(k)
+                       end
+               end
+       end
+
+       local co
+       for i, k in ipairs(self:cfgsections()) do
+               AbstractSection.parse_dynamic(self, k)
+               if self.map:submitstate() then
+                       Node.parse(self, k, novld)
+               end
+               AbstractSection.parse_optionals(self, k)
+       end
+
+       if self.addremove then
+               -- Create
+               local created
+               local crval = CREATE_PREFIX .. self.config .. "." .. self.sectiontype
+               local name  = self.map:formvalue(crval)
+               if self.anonymous then
+                       if name then
+                               created = self:create()
+                       end
+               else
+                       if name then
+                               -- Ignore if it already exists
+                               if self:cfgvalue(name) then
+                                       name = nil;
+                               end
+
+                               name = self:checkscope(name)
+
+                               if not name then
+                                       self.err_invalid = true
+                               end
+
+                               if name and #name > 0 then
+                                       created = self:create(name) and name
+                                       if not created then
+                                               self.invalid_cts = true
+                                       end
+                               end
+                       end
+               end
+
+               if created then
+                       AbstractSection.parse_optionals(self, created)
+               end
+       end
+
+       if created or self.changed then
+               self:push_events()
+       end
+end
+
+-- Verifies scope of sections
+function TypedSection.checkscope(self, section)
+       -- Check if we are not excluded
+       if self.filter and not self:filter(section) then
+               return nil
+       end
+
+       -- Check if at least one dependency is met
+       if #self.deps > 0 and self:cfgvalue(section) then
+               local stat = false
+
+               for k, v in ipairs(self.deps) do
+                       if self:cfgvalue(section)[v.option] == v.value then
+                               stat = true
+                       end
+               end
+
+               if not stat then
+                       return nil
+               end
+       end
+
+       return self:validate(section)
+end
+
+
+-- Dummy validate function
+function TypedSection.validate(self, section)
+       return section
+end
+
+
+--[[
+AbstractValue - An abstract Value Type
+       null:           Value can be empty
+       valid:          A function returning the value if it is valid otherwise nil
+       depends:        A table of option => value pairs of which one must be true
+       default:        The default value
+       size:           The size of the input fields
+       rmempty:        Unset value if empty
+       optional:       This value is optional (see AbstractSection.optionals)
+]]--
+AbstractValue = class(Node)
+
+function AbstractValue.__init__(self, map, section, option, ...)
+       Node.__init__(self, ...)
+       self.section = section
+       self.option  = option
+       self.map     = map
+       self.config  = map.config
+       self.tag_invalid = {}
+       self.tag_missing = {}
+       self.tag_reqerror = {}
+       self.tag_error = {}
+       self.deps = {}
+       self.subdeps = {}
+       --self.cast = "string"
+
+       self.track_missing = false
+       self.rmempty   = true
+       self.default   = nil
+       self.size      = nil
+       self.optional  = false
+end
+
+function AbstractValue.prepare(self)
+       self.cast = self.cast or "string"
+end
+
+-- Add a dependencie to another section field
+function AbstractValue.depends(self, field, value)
+       local deps
+       if type(field) == "string" then
+               deps = {}
+               deps[field] = value
+       else
+               deps = field
+       end
+
+       table.insert(self.deps, {deps=deps, add=""})
+end
+
+-- Generates the unique CBID
+function AbstractValue.cbid(self, section)
+       return "cbid."..self.map.config.."."..section.."."..self.option
+end
+
+-- Return whether this object should be created
+function AbstractValue.formcreated(self, section)
+       local key = "cbi.opt."..self.config.."."..section
+       return (self.map:formvalue(key) == self.option)
+end
+
+-- Returns the formvalue for this object
+function AbstractValue.formvalue(self, section)
+       return self.map:formvalue(self:cbid(section))
+end
+
+function AbstractValue.additional(self, value)
+       self.optional = value
+end
+
+function AbstractValue.mandatory(self, value)
+       self.rmempty = not value
+end
+
+function AbstractValue.parse(self, section, novld)
+       local fvalue = self:formvalue(section)
+       local cvalue = self:cfgvalue(section)
+
+       -- If favlue and cvalue are both tables and have the same content
+       -- make them identical
+       if type(fvalue) == "table" and type(cvalue) == "table" then
+               local equal = #fvalue == #cvalue
+               if equal then
+                       for i=1, #fvalue do
+                               if cvalue[i] ~= fvalue[i] then
+                                       equal = false
+                               end
+                       end
+               end
+               if equal then
+                       fvalue = cvalue
+               end
+       end
+
+       if fvalue and #fvalue > 0 then -- If we have a form value, write it to UCI
+               fvalue = self:transform(self:validate(fvalue, section))
+               if not fvalue and not novld then
+                       if self.error then
+                               self.error[section] = "invalid"
+                       else
+                               self.error = { [section] = "invalid" }
+                       end
+                       if self.section.error then
+                               table.insert(self.section.error[section], "invalid")
+                       else
+                               self.section.error = {[section] = {"invalid"}}
+                       end
+                       self.map.save = false
+               end
+               if fvalue and not (fvalue == cvalue) then
+                       if self:write(section, fvalue) then
+                               -- Push events
+                               self.section.changed = true
+                               --luci.util.append(self.map.events, self.events)
+                       end
+               end
+       else                                                    -- Unset the UCI or error
+               if self.rmempty or self.optional then
+                       if self:remove(section) then
+                               -- Push events
+                               self.section.changed = true
+                               --luci.util.append(self.map.events, self.events)
+                       end
+               elseif cvalue ~= fvalue and not novld then
+                       self:write(section, fvalue or "")
+                       if self.error then
+                               self.error[section] = "missing"
+                       else
+                               self.error = { [section] = "missing" }
+                       end
+                       self.map.save = false
+               end
+       end
+end
+
+-- Render if this value exists or if it is mandatory
+function AbstractValue.render(self, s, scope)
+       if not self.optional or self.section:has_tabs() or self:cfgvalue(s) or self:formcreated(s) then
+               scope = scope or {}
+               scope.section   = s
+               scope.cbid      = self:cbid(s)
+               scope.striptags = luci.util.striptags
+               scope.pcdata    = luci.util.pcdata
+
+               scope.ifattr = function(cond,key,val)
+                       if cond then
+                               return string.format(
+                                       ' %s="%s"', tostring(key),
+                                       luci.util.pcdata(tostring( val
+                                        or scope[key]
+                                        or (type(self[key]) ~= "function" and self[key])
+                                        or "" ))
+                               )
+                       else
+                               return ''
+                       end
+               end
+
+               scope.attr = function(...)
+                       return scope.ifattr( true, ... )
+               end
+
+               Node.render(self, scope)
+       end
+end
+
+-- Return the UCI value of this object
+function AbstractValue.cfgvalue(self, section)
+       local value = (self.error and self.error[section] == "invalid")
+               and self:formvalue(section) or self.map:get(section, self.option)
+       if not value then
+               return nil
+       elseif not self.cast or self.cast == type(value) then
+               return value
+       elseif self.cast == "string" then
+               if type(value) == "table" then
+                       return value[1]
+               end
+       elseif self.cast == "table" then
+               return luci.util.split(value, "%s+", nil, true)
+       end
+end
+
+-- Validate the form value
+function AbstractValue.validate(self, value)
+       if self.datatype and value and datatypes[self.datatype] then
+               if type(value) == "table" then
+                       local v
+                       for _, v in ipairs(value) do
+                               if v and #v > 0 and not datatypes[self.datatype](v) then
+                                       return nil
+                               end
+                       end
+               else
+                       if not datatypes[self.datatype](value) then
+                               return nil
+                       end
+               end
+       end
+       return value
+end
+
+AbstractValue.transform = AbstractValue.validate
+
+
+-- Write to UCI
+function AbstractValue.write(self, section, value)
+       return self.map:set(section, self.option, value)
+end
+
+-- Remove from UCI
+function AbstractValue.remove(self, section)
+       return self.map:del(section, self.option)
+end
+
+
+
+
+--[[
+Value - A one-line value
+       maxlength:      The maximum length
+]]--
+Value = class(AbstractValue)
+
+function Value.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template  = "cbi/value"
+       self.keylist = {}
+       self.vallist = {}
+end
+
+function Value.value(self, key, val)
+       val = val or key
+       table.insert(self.keylist, tostring(key))
+       table.insert(self.vallist, tostring(val))
+end
+
+
+-- DummyValue - This does nothing except being there
+DummyValue = class(AbstractValue)
+
+function DummyValue.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template = "cbi/dvalue"
+       self.value = nil
+end
+
+function DummyValue.cfgvalue(self, section)
+       local value
+       if self.value then
+               if type(self.value) == "function" then
+                       value = self:value(section)
+               else
+                       value = self.value
+               end
+       else
+               value = AbstractValue.cfgvalue(self, section)
+       end
+       return value
+end
+
+function DummyValue.parse(self)
+
+end
+
+
+--[[
+Flag - A flag being enabled or disabled
+]]--
+Flag = class(AbstractValue)
+
+function Flag.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template  = "cbi/fvalue"
+
+       self.enabled = "1"
+       self.disabled = "0"
+end
+
+-- A flag can only have two states: set or unset
+function Flag.parse(self, section)
+       local fvalue = self:formvalue(section)
+
+       if fvalue then
+               fvalue = self.enabled
+       else
+               fvalue = self.disabled
+       end
+
+       if fvalue == self.enabled or (not self.optional and not self.rmempty) then
+               if not(fvalue == self:cfgvalue(section)) then
+                       self:write(section, fvalue)
+               end
+       else
+               self:remove(section)
+       end
+end
+
+
+
+--[[
+ListValue - A one-line value predefined in a list
+       widget: The widget that will be used (select, radio)
+]]--
+ListValue = class(AbstractValue)
+
+function ListValue.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template  = "cbi/lvalue"
+
+       self.keylist = {}
+       self.vallist = {}
+       self.size   = 1
+       self.widget = "select"
+end
+
+function ListValue.value(self, key, val, ...)
+       if luci.util.contains(self.keylist, key) then
+               return
+       end
+
+       val = val or key
+       table.insert(self.keylist, tostring(key))
+       table.insert(self.vallist, tostring(val))
+
+       for i, deps in ipairs({...}) do
+               self.subdeps[#self.subdeps + 1] = {add = "-"..key, deps=deps}
+       end
+end
+
+function ListValue.validate(self, val)
+       if luci.util.contains(self.keylist, val) then
+               return val
+       else
+               return nil
+       end
+end
+
+
+
+--[[
+MultiValue - Multiple delimited values
+       widget: The widget that will be used (select, checkbox)
+       delimiter: The delimiter that will separate the values (default: " ")
+]]--
+MultiValue = class(AbstractValue)
+
+function MultiValue.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template = "cbi/mvalue"
+
+       self.keylist = {}
+       self.vallist = {}
+
+       self.widget = "checkbox"
+       self.delimiter = " "
+end
+
+function MultiValue.render(self, ...)
+       if self.widget == "select" and not self.size then
+               self.size = #self.vallist
+       end
+
+       AbstractValue.render(self, ...)
+end
+
+function MultiValue.value(self, key, val)
+       if luci.util.contains(self.keylist, key) then
+               return
+       end
+
+       val = val or key
+       table.insert(self.keylist, tostring(key))
+       table.insert(self.vallist, tostring(val))
+end
+
+function MultiValue.valuelist(self, section)
+       local val = self:cfgvalue(section)
+
+       if not(type(val) == "string") then
+               return {}
+       end
+
+       return luci.util.split(val, self.delimiter)
+end
+
+function MultiValue.validate(self, val)
+       val = (type(val) == "table") and val or {val}
+
+       local result
+
+       for i, value in ipairs(val) do
+               if luci.util.contains(self.keylist, value) then
+                       result = result and (result .. self.delimiter .. value) or value
+               end
+       end
+
+       return result
+end
+
+
+StaticList = class(MultiValue)
+
+function StaticList.__init__(self, ...)
+       MultiValue.__init__(self, ...)
+       self.cast = "table"
+       self.valuelist = self.cfgvalue
+
+       if not self.override_scheme
+        and self.map:get_scheme(self.section.sectiontype, self.option) then
+               local vs = self.map:get_scheme(self.section.sectiontype, self.option)
+               if self.value and vs.values and not self.override_values then
+                       for k, v in pairs(vs.values) do
+                               self:value(k, v)
+                       end
+               end
+       end
+end
+
+function StaticList.validate(self, value)
+       value = (type(value) == "table") and value or {value}
+
+       local valid = {}
+       for i, v in ipairs(value) do
+               if luci.util.contains(self.keylist, v) then
+                       table.insert(valid, v)
+               end
+       end
+       return valid
+end
+
+
+DynamicList = class(AbstractValue)
+
+function DynamicList.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template  = "cbi/dynlist"
+       self.cast = "table"
+       self.keylist = {}
+       self.vallist = {}
+end
+
+function DynamicList.value(self, key, val)
+       val = val or key
+       table.insert(self.keylist, tostring(key))
+       table.insert(self.vallist, tostring(val))
+end
+
+function DynamicList.write(self, ...)
+       self.map.proceed = true
+       return AbstractValue.write(self, ...)
+end
+
+function DynamicList.formvalue(self, section)
+       local value = AbstractValue.formvalue(self, section)
+       value = (type(value) == "table") and value or {value}
+
+       local valid = {}
+       for i, v in ipairs(value) do
+               if v and #v > 0
+                and not self.map:formvalue("cbi.rle."..section.."."..self.option.."."..i)
+                and not self.map:formvalue("cbi.rle."..section.."."..self.option.."."..i..".x") then
+                       table.insert(valid, v)
+               end
+       end
+
+       return valid
+end
+
+
+--[[
+TextValue - A multi-line value
+       rows:   Rows
+]]--
+TextValue = class(AbstractValue)
+
+function TextValue.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template  = "cbi/tvalue"
+end
+
+--[[
+Button
+]]--
+Button = class(AbstractValue)
+
+function Button.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template  = "cbi/button"
+       self.inputstyle = nil
+       self.rmempty = true
+end
+
+
+FileUpload = class(AbstractValue)
+
+function FileUpload.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template = "cbi/upload"
+       if not self.map.upload_fields then
+               self.map.upload_fields = { self }
+       else
+               self.map.upload_fields[#self.map.upload_fields+1] = self
+       end
+end
+
+function FileUpload.formcreated(self, section)
+       return AbstractValue.formcreated(self, section) or
+               self.map:formvalue("cbi.rlf."..section.."."..self.option) or
+               self.map:formvalue("cbi.rlf."..section.."."..self.option..".x")
+end
+
+function FileUpload.cfgvalue(self, section)
+       local val = AbstractValue.cfgvalue(self, section)
+       if val and fs.access(val) then
+               return val
+       end
+       return nil
+end
+
+function FileUpload.formvalue(self, section)
+       local val = AbstractValue.formvalue(self, section)
+       if val then
+               if not self.map:formvalue("cbi.rlf."..section.."."..self.option) and
+                  not self.map:formvalue("cbi.rlf."..section.."."..self.option..".x")
+               then
+                       return val
+               end
+               fs.unlink(val)
+               self.value = nil
+       end
+       return nil
+end
+
+function FileUpload.remove(self, section)
+       local val = AbstractValue.formvalue(self, section)
+       if val and fs.access(val) then fs.unlink(val) end
+       return AbstractValue.remove(self, section)
+end
+
+
+FileBrowser = class(AbstractValue)
+
+function FileBrowser.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template = "cbi/browser"
+end
diff --git a/libs/web/luasrc/cbi/datatypes.lua b/libs/web/luasrc/cbi/datatypes.lua
new file mode 100644 (file)
index 0000000..53a3454
--- /dev/null
@@ -0,0 +1,206 @@
+--[[
+
+LuCI - Configuration Bind Interface - Datatype Tests
+(c) 2010 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+]]--
+
+local fs = require "nixio.fs"
+local ip = require "luci.ip"
+local math = require "math"
+local util = require "luci.util"
+
+local tonumber = tonumber
+
+module "luci.cbi.datatypes"
+
+
+function bool(val)
+       if val == "1" or val == "yes" or val == "on" or val == "true" then
+               return true
+       elseif val == "0" or val == "no" or val == "off" or val == "false" then
+               return true
+       elseif val == "" or val == nil then
+               return true
+       end
+
+       return false
+end
+
+function uint(val)
+       local n = tonumber(val)
+       if n ~= nil and math.floor(n) == n and n >= 0 then
+               return true
+       end
+
+       return false
+end
+
+function int(val)
+       local n = tonumber(val)
+       if n ~= nil and math.floor(n) == n then
+               return true
+       end
+
+       return false
+end
+
+function float(val)
+       return ( tonumber(val) ~= nil )
+end
+
+function ipaddr(val)
+       return ip4addr(val) or ip6addr(val)
+end
+
+function ip4addr(val)
+       if val then
+               return ip.IPv4(val) and true or false
+       end
+
+       return false
+end
+
+function ip4prefix(val)
+       val = tonumber(val)
+       return ( val and val >= 0 and val <= 32 )
+end
+
+function ip6addr(val)
+       if val then
+               return ip.IPv6(val) and true or false
+       end
+
+       return false
+end
+
+function ip6prefix(val)
+       val = tonumber(val)
+       return ( val and val >= 0 and val <= 128 )
+end
+
+function port(val)
+       val = tonumber(val)
+       return ( val and val >= 1 and val <= 65535 )
+end
+
+function portrange(val)
+       local p1, p2 = val:match("^(%d+)%-(%d+)$")
+       if p1 and p2 and port(p1) and port(p2) then
+               return true
+       else
+               return port(val)
+       end
+end
+
+function macaddr(val)
+       if val and val:match(
+               "^[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+:" ..
+                "[a-fA-F0-9]+:[a-fA-F0-9]+:[a-fA-F0-9]+$"
+       ) then
+               local parts = util.split( val, ":" )
+
+               for i = 1,6 do
+                       parts[i] = tonumber( parts[i], 16 )
+                       if parts[i] < 0 or parts[i] > 255 then
+                               return false
+                       end
+               end
+
+               return true
+       end
+
+       return false
+end
+
+function hostname(val)
+       if val and val:match("[a-zA-Z0-9_][a-zA-Z0-9_%-%.]*") then
+               return true     -- XXX: ToDo: need better solution
+       end
+
+       return false
+end
+
+function host(val)
+       return hostname(val) or ipaddr(val)
+end
+
+function wpakey(val)
+       if #val == 64 then
+               return (val:match("^[a-fA-F0-9]+$") ~= nil)
+       else
+               return (#val >= 8) and (#val <= 63)
+       end
+end
+
+function wepkey(val)
+       if val:sub(1, 2) == "s:" then
+               val = val:sub(3)
+       end
+
+       if (#val == 10) or (#val == 26) then
+               return (val:match("^[a-fA-F0-9]+$") ~= nil)
+       else
+               return (#v == 5) or (#v == 13)
+       end
+end
+
+function string(val)
+       return true             -- Everything qualifies as valid string
+end
+
+function directory( val, seen )
+       local s = fs.stat(val)
+       seen = seen or { }
+
+       if s and not seen[s.ino] then
+               seen[s.ino] = true
+               if s.type == "dir" then
+                       return true
+               elseif s.type == "lnk" then
+                       return directory( fs.readlink(val), seen )
+               end
+       end
+
+       return false
+end
+
+function file( val, seen )
+       local s = fs.stat(val)
+       seen = seen or { }
+
+       if s and not seen[s.ino] then
+               seen[s.ino] = true
+               if s.type == "reg" then
+                       return true
+               elseif s.type == "lnk" then
+                       return file( fs.readlink(val), seen )
+               end
+       end
+
+       return false
+end
+
+function device( val, seen )
+       local s = fs.stat(val)
+       seen = seen or { }
+
+       if s and not seen[s.ino] then
+               seen[s.ino] = true
+               if s.type == "chr" or s.type == "blk" then
+                       return true
+               elseif s.type == "lnk" then
+                       return device( fs.readlink(val), seen )
+               end
+       end
+
+       return false
+end
diff --git a/libs/web/luasrc/view/cbi/browser.htm b/libs/web/luasrc/view/cbi/browser.htm
new file mode 100644 (file)
index 0000000..3b7b23f
--- /dev/null
@@ -0,0 +1,23 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<%
+       local t = require("luci.tools.webadmin")
+       local v = self:cfgvalue(section)
+-%>
+<%+cbi/valueheader%>
+       <input class="cbi-input-text" type="text"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
+       <input class="cbi-input-image" type="image" value="<%:Search file...%>" onclick="cbi_filebrowser('<%=cbid%>','<%=luci.dispatcher.build_url("admin", "filebrowser")%>'<%=self.default_path and ", '"..self.default_path.."'"%>);return false" alt="<%:Search file...%>" title="<%:Search file...%>" src="<%=resource%>/cbi/folder.png" style="vertical-align:bottom" />
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/button.htm b/libs/web/luasrc/view/cbi/button.htm
new file mode 100644 (file)
index 0000000..5a51897
--- /dev/null
@@ -0,0 +1,21 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+       <% if self:cfgvalue(section) ~= false then %>
+               <input class="cbi-input-<%=self.inputstyle or "button" %>" type="submit"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.title)%> />
+       <% else %>
+               -
+       <% end %>
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/cell_valuefooter.htm b/libs/web/luasrc/view/cbi/cell_valuefooter.htm
new file mode 100644 (file)
index 0000000..c325e49
--- /dev/null
@@ -0,0 +1,34 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+</div>
+<div id="cbip-<%=self.config.."-"..section.."-"..self.option%>"></div>
+</td>
+
+<% if #self.deps > 0 then -%>
+       <script type="text/javascript">
+               <% for j, d in ipairs(self.deps) do -%>
+                       cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", {
+               <%-
+                       for k,v in pairs(d.deps) do
+               -%>
+                       <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
+                       <%-if next(d.deps, k) then-%>,<%-end-%>
+               <%-
+                       end
+               -%>
+                       }, "cbip-<%=self.config.."-"..section.."-"..self.option%>");
+               <%- end %>
+       </script>
+<%- end %>
\ No newline at end of file
diff --git a/libs/web/luasrc/view/cbi/cell_valueheader.htm b/libs/web/luasrc/view/cbi/cell_valueheader.htm
new file mode 100644 (file)
index 0000000..0f24f1f
--- /dev/null
@@ -0,0 +1,17 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<td class="cbi-value-field<% if self.error and self.error[section] then %> cbi-value-error<% end %>">
+<div id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
diff --git a/libs/web/luasrc/view/cbi/compound.htm b/libs/web/luasrc/view/cbi/compound.htm
new file mode 100644 (file)
index 0000000..fbd5a0a
--- /dev/null
@@ -0,0 +1,14 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2009 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%- self:render_children() %>
\ No newline at end of file
diff --git a/libs/web/luasrc/view/cbi/delegator.htm b/libs/web/luasrc/view/cbi/delegator.htm
new file mode 100644 (file)
index 0000000..ed7c6b4
--- /dev/null
@@ -0,0 +1,37 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2009 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%- self.active:render() %>
+       <div class="cbi-page-actions">
+               <input type="hidden" name="cbi.delg.current" value="<%=self.current%>" />
+<% for _, x in ipairs(self.chain) do %>
+               <input type="hidden" name="cbi.delg.path" value="<%=x%>" />
+<% end %>
+<% if not self.disallow_pageactions then %>
+<% if self.allow_finish and not self:get_next(self.current) then %>
+       <input class="cbi-button cbi-button-finish" type="submit" value="<%:Finish%>" />
+<% elseif self:get_next(self.current) then %>
+               <input class="cbi-button cbi-button-next" type="submit" value="<%:Next Â»%>" />
+<% end %>
+<% if self.allow_cancel then %>
+               <input class="cbi-button cbi-button-cancel" type="submit" name="cbi.cancel" value="<%:Cancel%>" />
+<% end %>
+<% if self.allow_reset then %>
+               <input class="cbi-button cbi-button-reset" type="reset" value="<%:Reset%>" />
+<% end %>
+<% if self.allow_back and self:get_prev(self.current) then %>
+               <input class="cbi-button cbi-button-back" type="submit" name="cbi.delg.back" value="<%:« Back%>" />
+<% end %>
+<% end %>
+               <script type="text/javascript">cbi_d_update();</script>
+       </div>
\ No newline at end of file
diff --git a/libs/web/luasrc/view/cbi/dvalue.htm b/libs/web/luasrc/view/cbi/dvalue.htm
new file mode 100644 (file)
index 0000000..9745fff
--- /dev/null
@@ -0,0 +1,22 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<%+cbi/valueheader%>
+<% if self.href then %><a href="<%=self.href%>"><% end -%>
+       <%=pcdata(self:cfgvalue(section) or self.default or "")%>
+<%- if self.href then %></a><%end%>
+&#160;
+<input type="hidden" id="<%=cbid%>" value="<%=pcdata(self:cfgvalue(section) or self.default or "")%>" />
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/dynlist.htm b/libs/web/luasrc/view/cbi/dynlist.htm
new file mode 100644 (file)
index 0000000..826e2e6
--- /dev/null
@@ -0,0 +1,52 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+<%
+       local vals = self:cfgvalue(section) or {}
+       for i=1, #vals + 1 do
+               local val = vals[i]
+%>
+       <input class="cbi-input-text" value="<%=pcdata(val)%>" onchange="cbi_d_update(this.id)" type="text"<%= attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size")%> />
+       <% if i <= #vals then %>
+               <input class="cbi-input-image" type="image" value="<%:Delete%>" name="cbi.rle.<%=section .. "." .. self.option .. "." .. i%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
+       <% else %>
+               <input class="cbi-input-image" type="image" value="<%:Add%>" name="cbi.ale.<%=section .. "." .. self.option%>" alt="<%:Add%>" title="<%:Add%>" src="<%=resource%>/cbi/add.gif" />
+       <% end %>
+       <% if #self.keylist > 0 then -%>
+               <script type="text/javascript">
+                       cbi_combobox_init('<%=cbid .. "." .. i%>', {
+                       <%-
+                               for i, k in ipairs(self.keylist) do
+                       -%>
+                               <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
+                               <%-if i<#self.keylist then-%>,<%-end-%>
+                       <%-
+                               end
+                       -%>
+                       }, '<%- if not self.rmempty and not self.optional then -%>
+                               <%-:cbi_select-%>
+                       <%- end -%>', '<%: -- custom -- %>');
+               </script>
+       <% end -%>
+<% if i <= #vals then %><br />
+<% end end %>
+<% if self.datatype then -%>
+       <script type="text/javascript">
+               <% for i=1, #vals + 1 do -%>
+               cbi_validate_field('<%=cbid%>.<%=i%>', <%=tostring(self.optional == true or i > #vals)%>, '<%=self.datatype%>');
+               <%- end %>
+       </script>
+<% end -%>
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/filebrowser.htm b/libs/web/luasrc/view/cbi/filebrowser.htm
new file mode 100644 (file)
index 0000000..f829572
--- /dev/null
@@ -0,0 +1,123 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>Filebrowser - LuCI</title>
+       <style type="text/css">
+               #path, #listing {
+                       font-size: 85%;
+               }
+
+               ul {
+                       padding-left: 0;
+                       list-style-type: none;
+               }
+
+               li img {
+                       vertical-align: bottom;
+                       margin-right: 0.2em;
+               }
+       </style>
+
+       <script type="text/javascript">
+               function callback(path) {
+                       if( window.opener ) {
+                               var input = window.opener.document.getElementById('<%=luci.http.formvalue('field')%>');
+                               if( input ) {
+                                       input.value = path;
+                                       window.close();
+                               }
+                       }
+               }
+       </script>
+</head>
+<body>
+       <%
+               require("nixio.fs")
+               require("nixio.util")
+               require("luci.http")
+               require("luci.dispatcher")
+
+               local field   = luci.http.formvalue('field')
+               local request = luci.dispatcher.context.path
+               local path    = { '' }
+
+               for i = 3, #request do
+                       if request[i] ~= '..' and #request[i] > 0 then
+                               path[#path+1] = request[i]
+                       end
+               end
+
+               local filepath = table.concat( path, '/' )
+               local filestat = nixio.fs.stat( filepath )
+               local baseurl  = luci.dispatcher.build_url('admin', 'filebrowser')
+
+               if filestat and filestat.type == "reg" then
+                       table.remove( path, #path )
+                       filepath = table.concat( path, '/' ) .. '/'
+               elseif not ( filestat and filestat.type == "dir" ) then
+                       path     = { '' }
+                       filepath = '/'
+               else
+                       filepath = filepath .. '/'
+               end
+
+               local entries = nixio.util.consume((nixio.fs.dir(filepath)))
+       -%>
+    <div id="path">
+               Location:
+               <% for i, dir in ipairs(path) do %>
+                       <% if i == 1 then %>
+                               <a href="<%=baseurl%>?field=<%=field%>">(root)</a>
+                       <% elseif next(path, i) then %>
+                               <% baseurl = baseurl .. '/' .. dir %>
+                               / <a href="<%=baseurl%>?field=<%=field%>"><%=dir%></a>
+                       <% else %>
+                               <% baseurl = baseurl .. '/' .. dir %>
+                               / <%=dir%>
+                       <% end %>
+               <% end %>
+       </div>
+
+       <hr />
+
+       <div id="listing">
+               <ul>
+                       <% for _, e in luci.util.vspairs(entries) do
+                           local stat = nixio.fs.stat(filepath..e)
+                               if stat and stat.type == 'dir' then
+                       -%>
+                               <li class="dir">
+                                       <img src="/luci-static/resources/cbi/folder.png" alt="Directory" />
+                                       <a href="<%=baseurl%>/<%=e%>?field=<%=field%>"><%=e%>/</a>
+                               </li>
+                       <% end end -%>
+
+                       <% for _, e in luci.util.vspairs(entries) do
+                           local stat = nixio.fs.stat(filepath..e)
+                               if stat and stat.type ~= 'dir' then
+                       -%>
+                               <li class="file">
+                                       <img src="/luci-static/resources/cbi/file.png" alt="File" />
+                                       <a href="#" onclick="callback('<%=filepath..e%>')"><%=e%></a>
+                               </li>
+                       <% end end -%>
+               </ul>
+       </div>
+</body>
+</html>
diff --git a/libs/web/luasrc/view/cbi/firewall_zonelist.htm b/libs/web/luasrc/view/cbi/firewall_zonelist.htm
new file mode 100644 (file)
index 0000000..4f4106b
--- /dev/null
@@ -0,0 +1,89 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+
+<%-
+       local utl = require "luci.util"
+       local fwm = require "luci.model.firewall"
+       local nwm = require "luci.model.network"
+
+       local zone, net, iface
+       local zones = fwm:get_zones()
+       local value = self:formvalue(section)
+       if not value or value == "-" then value = self:cfgvalue(section) or self.default end
+
+       local selected = false
+       local checked = { }
+
+       if value and #value == 0 then
+               value = nil
+       elseif type(value) == "table" then
+               for _, value in ipairs(value) do
+                       checked[value] = true
+               end
+       elseif value then
+               checked[value] = true           
+       end
+-%>
+
+<ul style="margin:0; list-style-type:none; text-align:left">
+       <%
+               for _, zone in utl.spairs(zones, function(a,b) return (zones[a]:name() < zones[b]:name()) end) do
+                       if zone:name() ~= self.exclude then
+                               selected = selected or (value == zone:name())
+       %>
+       <li style="padding:0.5em">
+               <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. zone:name()) .. attr("name", cbid) .. attr("value", zone:name()) .. ifattr(checked[zone:name()], "checked", "checked")%> /> &nbsp;
+               <label<%=attr("for", cbid .. "." .. zone:name())%> style="background-color:<%=zone:get_color()%>; padding:0.5em">
+                       <strong><%=zone:name()%>:</strong>
+                       <%
+                               local zempty = true
+                               for _, net in ipairs(zone:get_networks()) do
+                                       net = nwm:get_network(net)
+                                       if net then
+                                               zempty = false
+                       %>
+                               &nbsp;
+                               <%- if net:name() == self.network then -%>
+                                       <span style="background-color:#FFFFFF; border:1px solid #000000; padding:2px; font-weight:bold"><%=net:name()%>:
+                               <%- else -%>
+                                       <span style="background-color:#FFFFFF; border:1px solid #CCCCCC; padding:2px"><%=net:name()%>:
+                               <%- end -%>
+                               <%
+                                       local nempty = true
+                                       for _, iface in ipairs(net and net:get_interfaces() or {}) do
+                                               nempty = false
+                                %>
+                                       <img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
+                               <% end %>
+                               <% if nempty then %><em><%:(no interfaces attached)%></em><% end %>
+                               </span>
+                       <% end end %>
+                       <% if zempty then %><em><%:(no interfaces attached)%></em><% end %>
+               </label>
+       </li>
+       <% end end %>
+
+       <% if self.widget ~= "checkbox" and not self.nocreate then %>
+       <li style="padding:0.5em">
+               <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not selected, "checked", "checked")%> /> &nbsp;
+               <div style="background-color:<%=fwm.zone.get_color()%>; padding:0.5em; display:inline">
+                       <label<%=attr("for", cbid .. "_new")%>><em><%:unspecified -or- create:%>&nbsp;</em></label>
+                       <input style="width:6em" type="text"<%=attr("name", cbid .. ".newzone") .. ifattr(not selected, "value", luci.http.formvalue(cbid .. ".newzone") or self.default)%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
+               </div>
+       </li>
+       <% end %>
+</ul>
+
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/footer.htm b/libs/web/luasrc/view/cbi/footer.htm
new file mode 100644 (file)
index 0000000..fe5b688
--- /dev/null
@@ -0,0 +1,29 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+       <%- if pageaction then -%>
+       <div class="cbi-page-actions">
+               <% if flow.skip then %>
+                       <input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
+               <% end %>
+               <% if not autoapply then%>
+                       <input class="cbi-button cbi-button-apply" type="submit" name="cbi.apply" value="<%:Save & Apply%>" />
+               <% end %>
+               <input class="cbi-button cbi-button-save" type="submit" value="<%:Save%>" />
+               <input class="cbi-button cbi-button-reset" type="reset" value="<%:Reset%>" />
+               <script type="text/javascript">cbi_d_update();</script>
+       </div>
+       <%- end -%>
+</form>
+<%+footer%>
diff --git a/libs/web/luasrc/view/cbi/full_valuefooter.htm b/libs/web/luasrc/view/cbi/full_valuefooter.htm
new file mode 100644 (file)
index 0000000..c069b7f
--- /dev/null
@@ -0,0 +1,74 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+               <% if self.description and #self.description > 0 then -%>
+                       <% if not luci.util.instanceof( self, luci.cbi.Flag ) or self.orientation == "horizontal" then -%>
+                               <br />
+                       <%- end %>
+                       <div class="cbi-value-description">
+                               <span class="cbi-value-helpicon"><img src="<%=resource%>/cbi/help.gif" alt="<%:help%>" /></span>
+                               <%=self.description%>
+                       </div>
+               <%- end %>
+       <%- if self.title and #self.title > 0 then -%>
+       </div>
+       <%- end -%>
+</div>
+
+
+<% if #self.deps > 0 or #self.subdeps > 0 then -%>
+       <script type="text/javascript" id="cbip-<%=self.config.."-"..section.."-"..self.option%>">
+               <% for j, d in ipairs(self.subdeps) do -%>
+                       cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", {
+               <%-
+                       for k,v in pairs(d.deps) do
+                               local depk
+                               if k:find("!", 1, true) then
+                                       depk = string.format('"%s"', k)
+                               elseif k:find(".", 1, true) then
+                                       depk = string.format('"cbid.%s"', k)
+                               else
+                                       depk = string.format('"cbid.%s.%s.%s"', self.config, section, k)
+                               end
+               -%>
+                       <%-= depk .. ":" .. string.format("%q", v)-%>
+                       <%-if next(d.deps, k) then-%>,<%-end-%>
+               <%-
+                       end
+               -%>
+                       }, "cbip-<%=self.config.."-"..section.."-"..self.option..d.add%>");
+               <%- end %>
+               <% for j, d in ipairs(self.deps) do -%>
+                       cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", {
+               <%-
+                       for k,v in pairs(d.deps) do
+                               local depk
+                               if k:find("!", 1, true) then
+                                       depk = string.format('"%s"', k)
+                               elseif k:find(".", 1, true) then
+                                       depk = string.format('"cbid.%s"', k)
+                               else
+                                       depk = string.format('"cbid.%s.%s.%s"', self.config, section, k)
+                               end
+               -%>
+                       <%-= depk .. ":" .. string.format("%q", v)-%>
+                       <%-if next(d.deps, k) then-%>,<%-end-%>
+               <%-
+                       end
+               -%>
+                       }, "cbip-<%=self.config.."-"..section.."-"..self.option..d.add%>");
+               <%- end %>
+       </script>
+<%- end %>
diff --git a/libs/web/luasrc/view/cbi/full_valueheader.htm b/libs/web/luasrc/view/cbi/full_valueheader.htm
new file mode 100644 (file)
index 0000000..ecd4014
--- /dev/null
@@ -0,0 +1,24 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<div class="cbi-value<% if self.error and self.error[section] then %> cbi-value-error<% end %>" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
+       <%- if self.title and #self.title > 0 then -%>
+       <label class="cbi-value-title"<%= attr("for", cbid) %>>
+       <%- if self.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=self.titleref%>"><%- end -%>
+               <%-=self.title-%>
+       <%- if self.titleref then -%></a><%- end -%>
+       </label>
+               <div class="cbi-value-field">
+       <%- end -%>
diff --git a/libs/web/luasrc/view/cbi/fvalue.htm b/libs/web/luasrc/view/cbi/fvalue.htm
new file mode 100644 (file)
index 0000000..35ebac6
--- /dev/null
@@ -0,0 +1,17 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+       <input class="cbi-input-checkbox" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="checkbox"<%= attr("id", cbid) .. attr("name", cbid) .. ifattr((self:cfgvalue(section) or self.default) == self.enabled, "checked", "checked") %> value="1" />
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/header.htm b/libs/web/luasrc/view/cbi/header.htm
new file mode 100644 (file)
index 0000000..fd1ab8b
--- /dev/null
@@ -0,0 +1,22 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<%+header%>
+<form method="post" name="cbi" action="<%=REQUEST_URI%>" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, '<%:Some fields are invalid, cannot save values!%>')">
+       <div>
+               <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
+               <input type="hidden" name="cbi.submit" value="1" />
+               <input type="submit" value="<%:Save%>" class="hidden" />
+       </div>
diff --git a/libs/web/luasrc/view/cbi/lvalue.htm b/libs/web/luasrc/view/cbi/lvalue.htm
new file mode 100644 (file)
index 0000000..8c7581a
--- /dev/null
@@ -0,0 +1,32 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+<% if self.widget == "select" then %>
+       <select class="cbi-input-select" onchange="cbi_d_update(this.id)"<%= attr("id", cbid) .. attr("name", cbid) .. ifattr(self.size, "size") %>>
+       <% for i, key in pairs(self.keylist) do -%>
+               <option id="cbi-<%=self.config.."-"..section.."-"..self.option.."-"..key%>"<%= attr("value", key) .. ifattr((self:cfgvalue(section) or self.default) == key, "selected", "selected") %>><%=striptags(self.vallist[i])%></option>
+       <%- end %>
+       </select>
+<% elseif self.widget == "radio" then
+       local c = 0
+       for i, key in pairs(self.keylist) do
+       c = c + 1
+%>
+       <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%= attr("id", cbid..c) .. attr("name", cbid) .. attr("value", key) .. ifattr((self:cfgvalue(section) or self.default) == key, "checked", "checked") %> />
+       <label<%= attr("for", cbid..c) %>><%=self.vallist[i]%></label>
+<% if c == self.size then c = 0 %><% if self.orientation == "horizontal" then %>&nbsp;<% else %><br /><% end %>
+<% end end %>
+<% end %>
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/map.htm b/libs/web/luasrc/view/cbi/map.htm
new file mode 100644 (file)
index 0000000..be0c37a
--- /dev/null
@@ -0,0 +1,63 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<div class="cbi-map" id="cbi-<%=self.config%>">
+       <% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %>
+       <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
+       <%- if self._apply then -%>
+               <fieldset class="cbi-section" id="cbi-apply-<%=self.config%>">
+                       <legend><%:Applying changes%></legend>
+                       <script type="text/javascript"><![CDATA[
+                               var apply_xhr = new XHR();
+
+                               apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "restart", table.concat(self.parsechain, ","))%>', null,
+                                       function() {
+                                               var intv = window.setInterval(
+                                                       function() {
+                                                               apply_xhr.abort();
+                                                               apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "status")%>', null,
+                                                                       function(x) {
+                                                                               if( x.responseText == 'finish' )
+                                                                               {
+                                                                                       window.clearInterval(intv);
+
+                                                                                       var e = document.getElementById('cbi-apply-<%=self.config%>-status');
+                                                                                       if( e )
+                                                                                       {
+                                                                                               e.innerHTML = '<%:Configuration applied.%>';
+                                                                                               window.setTimeout(function() { e.parentNode.style.display = 'none' }, 1000);
+                                                                                       }
+                                                                               }
+                                                                               else
+                                                                               {
+                                                                                       var e = document.getElementById('cbi-apply-<%=self.config%>-status');
+                                                                                       if( e && x.responseText ) e.innerHTML = x.responseText;
+
+                                                                               }
+                                                                       }
+                                                               );
+                                                       }, 1000
+                                               )
+                                       }
+                               );
+                       ]]></script>
+
+                       <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
+                       <span id="cbi-apply-<%=self.config%>-status"><%:Waiting for router...%></span>
+               </fieldset>
+       <%- end -%>
+       <%- self:render_children() %>
+       <br />
+</div>
diff --git a/libs/web/luasrc/view/cbi/mvalue.htm b/libs/web/luasrc/view/cbi/mvalue.htm
new file mode 100644 (file)
index 0000000..3812a3f
--- /dev/null
@@ -0,0 +1,35 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%
+local v = self:valuelist(section) or {}
+%>
+<%+cbi/valueheader%>
+<% if self.widget == "select" then %>
+       <select class="cbi-input-select" multiple="multiple"<%= attr("name", cbid) .. ifattr(self.size, "size") %>>
+       <% for i, key in pairs(self.keylist) do -%>
+               <option<%= attr("value", key) .. ifattr(luci.util.contains(v, key), "selected", "selected") %>><%=striptags(self.vallist[i])%></option>
+       <%- end %>
+       </select>
+<% elseif self.widget == "checkbox" then
+       local c = 0;
+       for i, key in pairs(self.keylist) do
+       c = c + 1
+%>
+       <input class="cbi-input-checkbox" type="checkbox"<%= attr("id", cbid..c) .. attr("name", cbid) .. attr("value", key) .. ifattr(luci.util.contains(v, key), "checked", "checked") %> />
+       <label<%= attr("for", cbid..c) %>><%=self.vallist[i]%></label><br />
+<% if c == self.size then c = 0 %><br />
+<% end end %>
+<% end %>
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/network_ifacelist.htm b/libs/web/luasrc/view/cbi/network_ifacelist.htm
new file mode 100644 (file)
index 0000000..2f98218
--- /dev/null
@@ -0,0 +1,54 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+
+<%-
+       local utl = require "luci.util"
+       local net = require "luci.model.network"
+
+       local iface
+       local ifaces = net:get_interfaces()
+       local value = (self:formvalue(section) or self.default or "")
+       local checked = { }
+
+       if value and #value > 0 then
+               if type(value) == "table" then value = table.concat(value, " ") end
+               for value in value:gmatch("%S+") do
+                       checked[value] = true
+               end             
+       else
+               local n = self.network and net:get_network(self.network)
+               if n then
+                       local i
+                       for _, i in ipairs(n:get_interfaces()) do
+                               checked[i:name()] = true
+                       end
+               end
+       end
+-%>
+
+<ul style="margin:0; list-style-type:none">
+       <% for _, iface in utl.spairs(ifaces, function(a,b) return (ifaces[a]:type() < ifaces[b]:type()) end) do
+         if not self.nobridges or not iface:is_bridge() then %>
+       <li>
+               <input class="cbi-input-<%=self.widget or "radio"%>" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. iface:name()) .. attr("name", cbid) .. attr("value", iface:name()) .. ifattr(checked[iface:name()], "checked", "checked")%> /> &nbsp;
+               <label<%=attr("for", cbid .. "." .. iface:name())%>>
+                       <img title="<%=iface:get_type_i18n()%>" style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
+                       <%=iface:get_i18n()%><% local n = iface:get_network(); if n then %> (<%=n:name()%>)<% end %>
+               </label>
+       </li>
+       <% end end %>
+</ul>
+
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/network_netlist.htm b/libs/web/luasrc/view/cbi/network_netlist.htm
new file mode 100644 (file)
index 0000000..c47b3a7
--- /dev/null
@@ -0,0 +1,61 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+
+<%-
+       local utl = require "luci.util"
+       local nwm = require "luci.model.network"
+
+       local net, iface
+       local networks = nwm:get_networks()
+       local value = self:formvalue(section)
+
+       if not value or value == "-" then
+               value = self:cfgvalue(section) or self.default
+       end
+-%>
+
+<ul style="margin:0; list-style-type:none; text-align:left">
+       <% for _, net in utl.spairs(networks, function(a,b) return (networks[a]:name() < networks[b]:name()) end) do
+              if net:name() ~= "loopback" then %>
+       <li style="padding:0.25em 0">
+               <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)"<%=attr("type", self.widget or "radio") .. attr("id", cbid .. "." .. net:name()) .. attr("name", cbid) .. attr("value", net:name()) .. ifattr(value == net:name(), "checked", "checked")%> /> &nbsp;
+               <label<%=attr("for", cbid .. "." .. net:name())%>>
+                       &nbsp;<span style="background-color:#FFFFFF; border:1px solid #CCCCCC; padding:2px"><%=net:name()%>:
+                               <%
+                                       local empty = true
+                                       for _, iface in ipairs(net:get_interfaces()) do
+                                               if not iface:is_bridge() then
+                                                       empty = false
+                                %>
+                                       <img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
+                               <% end end %>
+                               <% if empty then %><em><%:(no interfaces attached)%></em><% end %>
+                       </span>
+               </label>
+       </li>
+       <% end end %>
+
+       <% if self.widget ~= "checkbox" and not self.nocreate then %>
+       <li style="padding:0.25em 0">
+               <input class="cbi-input-radio" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="radio"<%=attr("id", cbid .. "_new") .. attr("name", cbid) .. attr("value", "-") .. ifattr(not value, "checked", "checked")%> /> &nbsp;
+               <div style="padding:0.5em; display:inline">
+                       <label<%=attr("for", cbid .. "_new")%>><em><%:unspecified -or- create:%>&nbsp;</em></label>
+                       <input style="width:6em" type="text"<%=attr("name", cbid .. ".newnet")%> onfocus="document.getElementById('<%=cbid%>_new').checked=true" />
+               </div>
+       </li>
+       <% end %>
+</ul>
+
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/nsection.htm b/libs/web/luasrc/view/cbi/nsection.htm
new file mode 100644 (file)
index 0000000..1d231c5
--- /dev/null
@@ -0,0 +1,46 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008-2009 Jo-Philipp Wich <xm@subsignal>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<% if self:cfgvalue(self.section) then section = self.section %>
+       <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=section%>">
+               <% if self.title and #self.title > 0 then -%>
+                       <legend><%=self.title%></legend>
+               <%- end %>
+               <% if self.description and #self.description > 0 then -%>
+                       <div class="cbi-section-descr"><%=self.description%></div>
+               <%- end %>
+               <% if self.addremove then -%>
+                       <div class="cbi-section-remove right">
+                               <input type="submit" name="cbi.rns.<%=self.config%>.<%=section%>" value="<%:Delete%>" />
+                       </div>
+               <%- end %>
+               <%+cbi/tabmenu%>
+               <div class="cbi-section-node" id="cbi-<%=self.config%>-<%=section%>">
+                       <%+cbi/ucisection%>
+               </div>
+               <br />
+       </fieldset>
+<% elseif self.addremove then %>
+       <% if self.template_addremove then include(self.template_addremove) else -%>
+       <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.section%>">
+               <% if self.title and #self.title > 0 then -%>
+                       <legend><%=self.title%></legend>
+               <%- end %>
+               <div class="cbi-section-descr"><%=self.description%></div>
+               <input type="submit" class="cbi-button-add" name="cbi.cns.<%=self.config%>.<%=self.section%>" value="<%:Add%>" />
+       </fieldset>
+       <%- end %>
+<% end %>
+<!-- /nsection -->
diff --git a/libs/web/luasrc/view/cbi/nullsection.htm b/libs/web/luasrc/view/cbi/nullsection.htm
new file mode 100644 (file)
index 0000000..f1c715b
--- /dev/null
@@ -0,0 +1,32 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+               <fieldset class="cbi-section">
+                       <% if self.title and #self.title > 0 then -%>
+                               <legend><%=self.title%></legend>
+                       <%- end %>
+                       <div class="cbi-section-node" id="cbi-<%=self.config%>-<%=tostring(self):sub(8)%>">
+                               <% self:render_children(1, scope or {}) %>
+                       </div>
+                       <br />
+               </fieldset>
+               <%-
+                       if type(self.hidden) == "table" then
+                               for k, v in pairs(self.hidden) do
+               -%>
+                       <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
+               <%-
+                               end
+                       end
+               %>
diff --git a/libs/web/luasrc/view/cbi/simpleform.htm b/libs/web/luasrc/view/cbi/simpleform.htm
new file mode 100644 (file)
index 0000000..9c40f82
--- /dev/null
@@ -0,0 +1,66 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<% if not self.embedded then %>
+<form method="post" action="<%=REQUEST_URI%>">
+       <div>
+               <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
+               <input type="hidden" name="cbi.submit" value="1" />
+       </div>
+<% end %>
+       <div class="cbi-map" id="cbi-<%=self.config%>">
+               <% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %>
+               <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
+               <% self:render_children() %>
+               <br />
+       </div>
+<%- if self.message then %>
+       <div><%=self.message%></div>
+<%- end %>
+<%- if self.errmessage then %>
+       <div class="error"><%=self.errmessage%></div>
+<%- end %>     
+<% if not self.embedded then %>
+       <div>
+<%-
+       if type(self.hidden) == "table" then
+               for k, v in pairs(self.hidden) do
+-%>
+       <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
+<%-
+               end
+       end
+%>
+<%- if self.flow and self.flow.skip then %>
+       <input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
+<% end %>
+<%- if self.submit ~= false then %>
+       <input class="cbi-button-save" type="submit" value="
+               <%- if not self.submit then -%><%-:Submit-%><%-else-%><%=self.submit%><%end-%>
+       " />
+<% end %>
+<%- if self.reset ~= false then %>
+       <input class="cbi-button-reset" type="reset" value="
+               <%- if not self.reset then -%><%-:Reset-%><%-else-%><%=self.reset%><%end-%>
+       " />
+<% end %>
+<%- if self.cancel ~= false and self.on_cancel then %>
+       <input class="cbi-button-reset" type="submit" name="cbi.cancel" value="
+               <%- if not self.cancel then -%><%-:Cancel-%><%-else-%><%=self.cancel%><%end-%>
+       " />
+<% end %>
+               <script type="text/javascript">cbi_d_update();</script>
+       </div>
+</form>
+<% end %>
diff --git a/libs/web/luasrc/view/cbi/tabcontainer.htm b/libs/web/luasrc/view/cbi/tabcontainer.htm
new file mode 100644 (file)
index 0000000..9b2c798
--- /dev/null
@@ -0,0 +1,21 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<% for tab, data in pairs(self.tabs) do %>
+       <div id="container.<%=self.config%>.<%=section%>.<%=tab%>"<% if tab ~= self.selected_tab then %> style="display:none"<% end %>>
+               <% if data.description then %><div class="cbi-tab-descr"><%=data.description%></div><% end %>
+               <% self:render_tab(tab, section, scope or {}) %>
+       </div>
+       <script type="text/javascript">cbi_t_add('<%=self.config%>.<%=section%>', '<%=tab%>')</script>
+<% end %>
diff --git a/libs/web/luasrc/view/cbi/tabmenu.htm b/libs/web/luasrc/view/cbi/tabmenu.htm
new file mode 100644 (file)
index 0000000..7648fe0
--- /dev/null
@@ -0,0 +1,27 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<%- if self.tabs then %>
+       <ul class="cbi-tabmenu">
+       <%- self.selected_tab = luci.http.formvalue("tab." .. self.config .. "." .. section) %>
+       <%- for _, tab in ipairs(self.tab_names) do if #self.tabs[tab].childs > 0 then %>
+               <script type="text/javascript">cbi_c['container.<%=self.config%>.<%=section%>.<%=tab%>'] = <%=#self.tabs[tab].childs%>;</script>
+               <%- if not self.selected_tab then self.selected_tab = tab end %>
+               <li id="tab.<%=self.config%>.<%=section%>.<%=tab%>" class="cbi-tab<%=(tab == self.selected_tab) and '' or '-disabled'%>">
+                       <a onclick="this.blur(); return cbi_t_switch('<%=self.config%>.<%=section%>', '<%=tab%>')" href="<%=REQUEST_URI%>?tab.<%=self.config%>.<%=section%>=<%=tab%>"><%=self.tabs[tab].title%></a>
+                       <% if tab == self.selected_tab then %><input type="hidden" id="tab.<%=self.config%>.<%=section%>" name="tab.<%=self.config%>.<%=section%>" value="<%=tab%>" /><% end %>
+               </li>
+       <% end end -%>
+       </ul>
+<% end -%>
diff --git a/libs/web/luasrc/view/cbi/tblsection.htm b/libs/web/luasrc/view/cbi/tblsection.htm
new file mode 100644 (file)
index 0000000..0224610
--- /dev/null
@@ -0,0 +1,135 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%-
+local rowcnt = 1
+function rowstyle()
+       rowcnt = rowcnt + 1
+       return (rowcnt % 2) + 1
+end
+-%>
+
+<!-- tblsection -->
+<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
+       <% if self.title and #self.title > 0 then -%>
+               <legend><%=self.title%></legend>
+       <%- end %>
+       <div class="cbi-section-descr"><%=self.description%></div>
+       <div class="cbi-section-node">
+               <%- local count = 0 -%>
+               <table class="cbi-section-table">
+                       <tr class="cbi-section-table-titles">
+                       <%- if not self.anonymous then -%>
+                               <%- if self.sectionhead then -%>
+                                       <th class="cbi-section-table-cell"><%=self.sectionhead%></th>
+                               <%- else -%>
+                                       <th>&#160;</th>
+                               <%- end -%>
+                       <%- end -%>
+                       <%- for i, k in pairs(self.children) do if not k.optional then -%>
+                               <th class="cbi-section-table-cell">
+                               <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
+                                       <%-=k.title-%>
+                               <%- if k.titleref then -%></a><%- end -%>
+                               </th>
+                       <%- count = count + 1; end; end; if self.extedit or self.addremove then -%>
+                               <th class="cbi-section-table-cell">&#160;</th>
+                       <%- count = count + 1; end -%>
+                       </tr>
+                       <tr class="cbi-section-table-descr">
+                       <%- if not self.anonymous then -%>
+                               <%- if self.sectiondesc then -%>
+                                       <th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
+                               <%- else -%>
+                                       <th></th>
+                               <%- end -%>
+                       <%- end -%>
+                       <%- for i, k in pairs(self.children) do if not k.optional then -%>
+                               <th class="cbi-section-table-cell"><%=k.description%></th>
+                       <%- end; end; if self.extedit or self.addremove then -%>
+                               <th class="cbi-section-table-cell"></th>
+                       <%- end -%>
+                       </tr>
+                       <%- local isempty = true
+                           for i, k in ipairs(self:cfgsections()) do
+                                       section = k
+                                       isempty = false
+                                       scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
+                       -%>
+                       <tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
+                               <% if not self.anonymous then -%>
+                                       <th><h3><%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%></h3></th>
+                               <%- end %>
+
+
+                               <%-
+                                       for k, node in ipairs(self.children) do
+                                               if not node.optional then
+                                                       node:render(section, scope or {})
+                                               end
+                                       end
+                               -%>
+
+                               <%- if self.extedit or self.addremove then -%>
+                                       <td class="cbi-section-table-cell">
+                                               <%- if self.extedit then -%>
+                                                       <a href="
+                                                       <%- if type(self.extedit) == "string" then -%>
+                                                               <%=self.extedit:format(section)%>
+                                                       <%- elseif type(self.extedit) == "function" then -%>
+                                                               <%=self:extedit(section)%>
+                                                       <%- end -%>
+                                                       " title="<%:Edit%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:Edit%>" /></a>
+                                               <%- end; if self.addremove then %>
+                                                       <input type="image" value="<%:Delete%>" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
+                                               <%- end -%>
+                                       </td>
+                               <%- end -%>
+                       </tr>
+                       <%- end -%>
+
+                       <%- if isempty then -%>
+                       <tr class="cbi-section-table-row">
+                               <td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
+                       </tr>
+                       <%- end -%>
+               </table>
+
+               <% if self.error then %>
+                       <div class="cbi-section-error">
+                               <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
+                                       <li><%=pcdata(e):gsub("\n","<br />")%></li>
+                               <%- end end %></ul>
+                       </div>
+               <% end %>
+
+               <%- if self.addremove then -%>
+                       <% if self.template_addremove then include(self.template_addremove) else -%>
+                       <div class="cbi-section-create cbi-tblsection-create">
+                               <% if self.anonymous then %>
+                                       <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:Add%>" />
+                               <% else %>
+                                       <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
+                                       <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
+                                       <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" title="<%:Add%>" />
+                                       <% if self.invalid_cts then -%>
+                                               <br /><%:Invalid%></div>
+                                       <%- end %>
+                               <% end %>
+                       </div>
+                       <%- end %>
+               <%- end -%>
+       </div>
+</fieldset>
+<!-- /tblsection -->
diff --git a/libs/web/luasrc/view/cbi/tsection.htm b/libs/web/luasrc/view/cbi/tsection.htm
new file mode 100644 (file)
index 0000000..0fa285c
--- /dev/null
@@ -0,0 +1,62 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
+       <% if self.title and #self.title > 0 then -%>
+               <legend><%=self.title%></legend>
+       <%- end %>
+       <div class="cbi-section-descr"><%=self.description%></div>
+       <% local isempty = true for i, k in ipairs(self:cfgsections()) do -%>
+               <% if self.addremove then -%>
+                       <div class="cbi-section-remove right">
+                               <input type="submit" name="cbi.rts.<%=self.config%>.<%=k%>" value="<%:Delete%>" />
+                       </div>
+               <%- end %>
+
+               <%- section = k; isempty = false -%>
+
+               <% if not self.anonymous then -%>
+                       <h3><%=section:upper()%></h3>
+               <%- end %>
+
+               <%+cbi/tabmenu%>
+
+               <fieldset class="cbi-section-node" id="cbi-<%=self.config%>-<%=section%>">
+                       <%+cbi/ucisection%>
+               </fieldset>
+               <br />
+       <%- end %>
+
+       <% if isempty then -%>
+               <em><%:This section contains no values yet%><br /><br /></em>
+       <%- end %>
+
+       <% if self.addremove then -%>
+               <% if self.template_addremove then include(self.template_addremove) else -%>
+               <div class="cbi-section-create">
+                       <% if self.anonymous then -%>
+                               <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" value="<%:Add%>" />
+                       <%- else -%>
+                               <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
+                               <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
+                               <input type="submit" class="cbi-button cbi-button-add" value="<%:Add%>" />
+                               <% if self.invalid_cts then -%>
+                                       <br /><%:Invalid%></div>
+                               <%- end %>
+                       <%- end %>
+               </div>
+               <%- end %>
+       <%- end %>
+</fieldset>
diff --git a/libs/web/luasrc/view/cbi/tvalue.htm b/libs/web/luasrc/view/cbi/tvalue.htm
new file mode 100644 (file)
index 0000000..b628c5c
--- /dev/null
@@ -0,0 +1,19 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+       <textarea class="cbi-input-textarea" <% if not self.size then %> style="width: 100%"<% else %> cols="<%=self.size%>"<% end %> onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. ifattr(self.rows, "rows") .. ifattr(self.wrap, "wrap") %>>
+       <%-=pcdata(self:cfgvalue(section))-%>
+       </textarea>
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/ucisection.htm b/libs/web/luasrc/view/cbi/ucisection.htm
new file mode 100644 (file)
index 0000000..db32c90
--- /dev/null
@@ -0,0 +1,90 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<%-
+       if type(self.hidden) == "table" then
+               for k, v in pairs(self.hidden) do
+-%>
+       <input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
+<%-
+               end
+       end
+%>
+
+<% if self.tabs then %>
+       <%+cbi/tabcontainer%>
+<% else %>
+       <% self:render_children(section, scope or {}) %>
+<% end %>
+
+<% if self.error and self.error[section] then -%>
+       <div class="cbi-section-error">
+               <ul><% for _, e in ipairs(self.error[section]) do -%>
+                       <li>
+                               <%- if e == "invalid" then -%>
+                                       <%:One or more fields contain invalid values!%>
+                               <%- elseif e == "missing" then -%>
+                                       <%:One or more required fields have no value!%>
+                               <%- else -%>
+                                       <%=pcdata(e)%>
+                               <%- end -%>
+                       </li>
+               <%- end %></ul>
+       </div>
+<%- end %>
+
+<% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
+       <div class="cbi-optionals">
+               <% if self.dynamic then %>
+                       <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
+                       <% if self.optionals[section] and #self.optionals[section] > 0 then %>
+                       <script type="text/javascript">
+                               cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', {
+                               <%-
+                                       for i, val in pairs(self.optionals[section]) do
+                               -%>
+                                       <%-=string.format("%q", val.option) .. ":" .. string.format("%q", striptags(val.title))-%>
+                                       <%-if next(self.optionals[section], i) then-%>,<%-end-%>
+                               <%-
+                                       end
+                               -%>
+                               }, '', '<%-: -- custom -- -%>');
+                       </script>
+                       <% end %>
+               <% else %>
+               <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
+                       <option><%: -- Additional Field -- %></option>
+                       <% for key, val in pairs(self.optionals[section]) do -%>
+                               <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
+                       <%- end %>
+               </select>
+               <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
+                       <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
+                       cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
+               <%-
+                       for k,v in pairs(d.deps) do
+               -%>
+                       <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
+                       <%-if next(d.deps, k) then-%>,<%-end-%>
+               <%-
+                       end
+               -%>
+                       });
+               <%- end %><% end %>
+               <% end %></script>
+       <% end %>
+               <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:Add%>" />
+       </div>
+<% end %>
diff --git a/libs/web/luasrc/view/cbi/upload.htm b/libs/web/luasrc/view/cbi/upload.htm
new file mode 100644 (file)
index 0000000..f5baa33
--- /dev/null
@@ -0,0 +1,29 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008-2009 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<%
+       local t = require("luci.tools.webadmin")
+       local v = self:cfgvalue(section)
+       local s = v and nixio.fs.stat(v)
+-%>
+<%+cbi/valueheader%>
+       <% if s then %>
+               <%:Uploaded File%> (<%=t.byte_format(s.size)%>)
+               <input type="hidden"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
+               <input class="cbi-input-image" type="image" value="<%:Replace entry%>" name="cbi.rlf.<%=section .. "." .. self.option%>" alt="<%:Replace entry%>" title="<%:Replace entry%>" src="<%=resource%>/cbi/reload.gif" />
+       <% else %>
+               <input class="cbi-input-file" type="file"<%= attr("name", cbid) .. attr("id", cbid) %> />
+       <% end %>
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/value.htm b/libs/web/luasrc/view/cbi/value.htm
new file mode 100644 (file)
index 0000000..a7b49de
--- /dev/null
@@ -0,0 +1,44 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+       <input type="<%=self.password and 'password" class="cbi-input-password' or 'text" class="cbi-input-text' %>" onchange="cbi_d_update(this.id)"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section) or self.default) .. ifattr(self.size, "size")%> />
+       <% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
+       <% if #self.keylist > 0 or self.datatype then -%>
+       <script type="text/javascript">
+               <% if #self.keylist > 0 then -%>
+               cbi_combobox_init('<%=cbid%>', {
+               <%-
+                       for i, k in ipairs(self.keylist) do
+               -%>
+                       <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
+                       <%-if i<#self.keylist then-%>,<%-end-%>
+               <%-
+                       end
+               -%>
+               }, '<%- if not self.rmempty and not self.optional then -%>
+                       <%-: -- Please choose -- -%>
+               <%- end -%>', '
+               <%- if self.combobox_manual then -%>
+                       <%-=self.combobox_manual-%>
+               <%- else -%>
+                       <%-: -- custom -- -%>
+               <%- end -%>');
+               <%- end %>
+               <% if self.datatype then -%>
+               cbi_validate_field('<%=cbid%>', <%=tostring(self.optional == true)%>, '<%=self.datatype%>');
+               <%- end %>
+       </script>
+       <% end -%>
+<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/valuefooter.htm b/libs/web/luasrc/view/cbi/valuefooter.htm
new file mode 100644 (file)
index 0000000..a65c7a3
--- /dev/null
@@ -0,0 +1,16 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<% include( valuefooter or "cbi/full_valuefooter" ) %>
diff --git a/libs/web/luasrc/view/cbi/valueheader.htm b/libs/web/luasrc/view/cbi/valueheader.htm
new file mode 100644 (file)
index 0000000..f3da909
--- /dev/null
@@ -0,0 +1,16 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<% include( valueheader or "cbi/full_valueheader" ) %>
diff --git a/libs/web/root/lib/uci/upload/.gitignore b/libs/web/root/lib/uci/upload/.gitignore
new file mode 100644 (file)
index 0000000..e69de29