mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-01 16:44:45 +08:00
update 2026-09-20 16:59:13
This commit is contained in:
1 parent
4dd6850a75
commit
735d247cbe
23 files changed
+237
-115
No files matched your search
@@ -1542,11 +1542,18 @@ function set_type_cbi(s)
|
||||
obj.option_prefix = s_self.option_prefix
|
||||
obj.option = s_self.option_prefix .. option
|
||||
obj.cfgvalue = function(self, section)
|
||||
local v
|
||||
if self.rewrite_option then
|
||||
return self.map:get(section, self.rewrite_option)
|
||||
v = self.map:get(section, self.rewrite_option)
|
||||
else
|
||||
return self.map:get(section, self.config_option)
|
||||
v = self.map:get(section, self.config_option)
|
||||
end
|
||||
if util.instanceof(self, cbi.MultiValue) then
|
||||
if v and self.cast == "table" then
|
||||
return table.concat(v, " ")
|
||||
end
|
||||
end
|
||||
return v
|
||||
end
|
||||
obj.write = function(self, section, value)
|
||||
if s1.fields["type"]:formvalue(s_self.section) == s_self.type_name then
|
||||
@@ -1564,6 +1571,21 @@ function set_type_cbi(s)
|
||||
new_val = new_t
|
||||
end
|
||||
end
|
||||
if util.instanceof(self, cbi.MultiValue) then
|
||||
local new_t = {}
|
||||
if type(value) == "table" then
|
||||
new_t = table_remove_duplicates(value)
|
||||
else
|
||||
string.gsub(value, '[^' .. " " .. ']+', function(v)
|
||||
new_t[#new_t + 1] = v
|
||||
end)
|
||||
end
|
||||
if self.cast == "string" then
|
||||
new_val = table.concat(new_t, " ")
|
||||
else
|
||||
new_val = new_t
|
||||
end
|
||||
end
|
||||
if self.rewrite_option then
|
||||
self.map:set(section, self.rewrite_option, new_val)
|
||||
else
|
||||
@@ -1619,6 +1641,7 @@ end
|
||||
function type_cbi_section(s, s2)
|
||||
for i, v in ipairs(s2.children) do
|
||||
local o = s2.children[i]
|
||||
o.section = s
|
||||
s:append(o)
|
||||
s.fields[o.option] = o
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user