luci-0.9: merge r5176-r5182
authorJo-Philipp Wich <jow@openwrt.org>
Fri, 31 Jul 2009 00:18:13 +0000 (00:18 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Fri, 31 Jul 2009 00:18:13 +0000 (00:18 +0000)
applications/luci-statistics/luasrc/statistics/i18n.lua
libs/cbi/luasrc/cbi.lua
libs/cbi/luasrc/view/cbi/delegator.htm
modules/admin-full/luasrc/model/cbi/admin_system/system.lua
modules/admin-mini/luasrc/model/cbi/mini/system.lua

index 4cbcdd4cf3a1a5d83a640a24a01af749729e3c3b..213131bd318a29246fcb24cbb9f49929e1b5e87a 100644 (file)
@@ -43,13 +43,13 @@ end
 
 function Instance.title( self, plugin, pinst, dtype, dinst )
 
-       local title = self.i18n.translate(
+       local title = self.i18n.string(
                string.format( "stat_dg_title_%s_%s_%s", plugin, pinst, dtype ),
-               self.i18n.translate(
+               self.i18n.string(
                        string.format( "stat_dg_title_%s_%s", plugin, pinst ),
-                       self.i18n.translate(
+                       self.i18n.string(
                                string.format( "stat_dg_title_%s__%s", plugin, dtype ),
-                               self.i18n.translate(
+                               self.i18n.string(
                                        string.format( "stat_dg_title_%s", plugin ),
                                        self.graph:_mkpath( plugin, pinst, dtype )
                                )
@@ -68,13 +68,13 @@ end
 
 function Instance.label( self, plugin, pinst, dtype, dinst )
 
-       local label = self.i18n.translate(
+       local label = self.i18n.string(
                string.format( "stat_dg_label_%s_%s_%s", plugin, pinst, dtype ),
-               self.i18n.translate(
+               self.i18n.string(
                        string.format( "stat_dg_label_%s_%s", plugin, pinst ),
-                       self.i18n.translate(
+                       self.i18n.string(
                                string.format( "stat_dg_label_%s__%s", plugin, dtype ),
-                               self.i18n.translate(
+                               self.i18n.string(
                                        string.format( "stat_dg_label_%s", plugin ),
                                        self.graph:_mkpath( plugin, pinst, dtype )
                                )
@@ -93,13 +93,13 @@ end
 
 function Instance.ds( self, source )
 
-       local label = self.i18n.translate(
+       local label = self.i18n.string(
                string.format( "stat_ds_%s_%s_%s", source.type, source.instance, source.ds ),
-               self.i18n.translate(
+               self.i18n.string(
                        string.format( "stat_ds_%s_%s", source.type, source.instance ),
-                       self.i18n.translate(
+                       self.i18n.string(
                                string.format( "stat_ds_label_%s__%s", source.type, source.ds ),
-                               self.i18n.translate(
+                               self.i18n.string(
                                        string.format( "stat_ds_%s", source.type ),
                                        source.type .. "_" .. source.instance:gsub("[^%w]","_") .. "_" .. source.ds
                                )
index f3c481cf84fd9c4ea0a6226591f445a46bf8712f..83f5c27e7c48f4661142312b9e63f38b947b63da 100644 (file)
@@ -60,17 +60,18 @@ function load(cbimap, ...)
 
        local upldir = "/lib/uci/upload/"
        local cbidir = luci.util.libpath() .. "/model/cbi/"
-
-       assert(fs.stat(cbimap) or
-               fs.stat(cbidir..cbimap..".lua") or
-               fs.stat(cbidir..cbimap..".lua.gz"),
-                       "Model not found!")
-
-       local func, err = loadfile(cbimap)
-       if not func then
-               func, err = loadfile(cbidir..cbimap..".lua") or
-                       loadfile(cbidir..cbimap..".lua.gz")
+       local func, err
+
+       if fs.access(cbimap) then
+               func, err = loadfile(cbimap)
+       elseif fs.access(cbidir..cbimap..".lua") then
+               func, err = loadfile(cbidir..cbimap..".lua")
+       elseif fs.access(cbidir..cbimap..".lua.gz") then
+               func, err = loadfile(cbidir..cbimap..".lua.gz")
+       else
+               func, err = nil, "Model '" .. cbimap .. "' not found!"
        end
+
        assert(func, err)
 
        luci.i18n.loadc("cbi")
@@ -286,6 +287,11 @@ 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
@@ -499,6 +505,7 @@ function Delegator.__init__(self, ...)
        self.defaultpath = {}
        self.pageaction = false
        self.readinput = true
+       self.allow_reset = false
        self.allow_back = false
        self.allow_finish = false
        self.template = "cbi/delegator"
@@ -572,9 +579,14 @@ function Delegator.parse(self, ...)
                else
                        newcurrent = self:get_next(self.current)
                end
+       elseif stat < FORM_PROCEED then
+               return stat
        end
+       
 
-       if not newcurrent or not self:get(newcurrent) then
+       if not Map.formvalue(self, "cbi.submit") then
+               return FORM_NODATA
+       elseif not newcurrent or not self:get(newcurrent) then
                return FORM_DONE
        else
                self.current = newcurrent
index 523eebcda585cbdbab6ac5d6ee972089822f47fa..95fd270f8b1997ea793fec8b39e09aca02ecfc00 100644 (file)
@@ -20,7 +20,9 @@ $Id$
 <% 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="<%:cbi_back &lt; Back%>" />
 <% end %>
+<% if self.allow_reset then %>
                <input class="cbi-button cbi-button-reset" type="reset" value="<%:reset%>" />
+<% end %>
 <% if self.allow_finish and not self:get_next(self.current) then %>
        <input class="cbi-button cbi-button-finish" type="submit" value="<%:cbi_finish Finish%>" />
 <% elseif self:get_next(self.current) then %>
index 1d35dee7f641383757ece8dae39c00399c21303e..da51b452d1f59020e7774f1fa98a368adcc6d53e 100644 (file)
@@ -40,6 +40,7 @@ s:option(DummyValue, "_memtotal", translate("m_i_memory")).value =
   tostring(translate("mem_buffered", "")),
   100 * memfree / memtotal,
   tostring(translate("mem_free", ""))
+)
 
 s:option(DummyValue, "_systime", translate("m_i_systemtime")).value =
  os.date("%c")
index 4ef97e48e1f64efdea86f55210ecf350efeb636c..4e7f9568b2485c2d9eb4b9698c6e6b7c8b693a61 100644 (file)
@@ -43,6 +43,7 @@ s:option(DummyValue, "_memtotal", translate("m_i_memory")).value =
   tostring(translate("mem_buffered", "")),
   100 * memfree / memtotal,
   tostring(translate("mem_free", ""))
+)
 
 s:option(DummyValue, "_systime", translate("m_i_systemtime")).value =
  os.date("%c")