diff options
author | Ted Trask <ttrask01@yahoo.com> | 2008-07-02 15:56:04 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2008-07-02 15:56:04 +0000 |
commit | 997b4dcd33463841aa8f1ca6d59dea7bc9d38ae9 (patch) | |
tree | 31555c8bdf9da14b96e146569b4c5dab3138d6f6 /lib/controllerfunctions.lua | |
parent | 9a0afb466ef66b0d27fd12652c3fe198d4fcfe6d (diff) | |
download | acf-core-997b4dcd33463841aa8f1ca6d59dea7bc9d38ae9.tar.bz2 acf-core-997b4dcd33463841aa8f1ca6d59dea7bc9d38ae9.tar.xz |
Modified core to create model and controller function libraries and some common html views. Moved cfe to a library. Modified redirect_to_referrer function - may break some pages.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1267 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/controllerfunctions.lua')
-rw-r--r-- | lib/controllerfunctions.lua | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/controllerfunctions.lua b/lib/controllerfunctions.lua new file mode 100644 index 0000000..23e57d4 --- /dev/null +++ b/lib/controllerfunctions.lua @@ -0,0 +1,51 @@ +module(..., package.seeall) + +function handle_form(self, getFunction, setFunction, clientdata, option, label, descr) + local form = getFunction() + + if clientdata[option] then + form.errtxt = nil + for name,value in pairs(form.value) do + value.errtxt = nil + if value.type == "boolean" then + value.value = (clientdata[name] ~= nil) + elseif value.type == "list" then + value.value = {} + if clientdata[name] and clientdata[name] ~= "" then + for ip in string.gmatch(clientdata[name].."\n", "%s*(%S[^\n]*%S)%s*\n") do + table.insert(value.value, ip) + end + end + else + value.value = clientdata[name] or value.value + end + end + form = setFunction(form) + if not form.errtxt then + form.descr = descr + end + form = self:redirect_to_referrer(form) + else + form = self:redirect_to_referrer() or form + end + + form.type = "form" + form.option = option + form.label = label + + return form +end + +function handle_startstop(self, startstopfunction, getstatusfunction, clientdata) + local result + if clientdata.action then + result = startstopfunction(clientdata.action) + end + result = self:redirect_to_referrer(result) + + local status = getstatusfunction() + status = status.value.status + + return cfe({ type="group", value={status=status, result=result} }) +end + |