summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2012-02-23 15:27:32 +0000
committerTed Trask <ttrask01@yahoo.com>2012-02-23 15:27:32 +0000
commit94e98d227ef5e21485bafd859b23d5d709ba79a8 (patch)
treef783f44685aaa33c0c127b992f74aad965deefad /lib
parentefdd93c695574329b3d98455a0a88320a1c79d5b (diff)
downloadacf-core-94e98d227ef5e21485bafd859b23d5d709ba79a8.tar.bz2
acf-core-94e98d227ef5e21485bafd859b23d5d709ba79a8.tar.xz
Removed controllerfunction.lua and moved handle_form and handle_clientdata into mvc.lua
mvc.lua has generic versions of the functions, overridden in acf_www and acf_cli with customizations
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile1
-rw-r--r--lib/README1
-rw-r--r--lib/controllerfunctions.lua99
3 files changed, 0 insertions, 101 deletions
diff --git a/lib/Makefile b/lib/Makefile
index e1e616b..adc2faf 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -6,7 +6,6 @@ LIB_DIST=menubuilder.lua\
authenticator-plaintext.lua\
roles.lua\
htmlviewfunctions.lua\
- controllerfunctions.lua\
modelfunctions.lua\
EXTRA_DIST=README Makefile
diff --git a/lib/README b/lib/README
index 0931934..be6f1dc 100644
--- a/lib/README
+++ b/lib/README
@@ -7,7 +7,6 @@ Also we use Lua Posix for the rest of the functionality.
apk.lua - Helps with package version/install/remove
authenticator-plaintext.lua - sub-authenticator for plaintext files
authenticator.lua - Used for authentication and roles, generic and uses sub-authenticator
-controllerfunctions.lua - Common controller functions
date.lua - Date and Time functions
format.lua - Library to help reformat strings and tables.
fs.lua - File and filesystem library
diff --git a/lib/controllerfunctions.lua b/lib/controllerfunctions.lua
deleted file mode 100644
index b0879ae..0000000
--- a/lib/controllerfunctions.lua
+++ /dev/null
@@ -1,99 +0,0 @@
-module(..., package.seeall)
-
-function handle_clientdata(form, clientdata, group)
- form.errtxt = nil
- for n,value in pairs(form.value) do
- value.errtxt = nil
- local name = n
- if group then name = group.."."..name end
- if name:find("%.") and not clientdata[name] then
- -- If the name has a '.' in it, haserl will interpret it as a table
- local actualval = clientdata
- for entry in name:gmatch("[^%.]+") do
- if tonumber(entry) then
- actualval = actualval[tonumber(entry)]
- else
- actualval = actualval[entry]
- end
- if not actualval then break end
- end
- clientdata[name] = actualval
- end
- if value.type == "group" then
- handle_clientdata(value, clientdata, name)
- elseif value.type == "boolean" then
- value.value = (clientdata[name] ~= nil) and (clientdata[name] ~= "false")
- elseif value.type == "multi" then
- if clientdata[name] == nil then
- -- for cli we use name[num] as the name
- clientdata[name] = {}
- for n,val in pairs(clientdata) do
- if string.find(n, "^"..name.."%[%d+%]$") then
- clientdata[name][tonumber(string.match(n, "%[(%d+)%]$"))] = val
- end
- end
- end
- -- FIXME this is because multi selects don't work in haserl
- local oldtable = clientdata[name] or {}
- -- Assume it's a sparse array, and remove blanks
- local newtable={}
- for x=1,table.maxn(oldtable) do
- if oldtable[x] then
- newtable[#newtable + 1] = oldtable[x]
- end
- end
- value.value = newtable
- elseif value.type == "list" then
- value.value = {}
- if clientdata[name] and clientdata[name] ~= "" then
- -- for www we use \r separated list
- for ip in string.gmatch(clientdata[name].."\n", "%s*([^\n]*%S)%s*\n") do
- table.insert(value.value, ip)
- end
- else
- -- for cli we use name[num] as the name
- for n,val in pairs(clientdata) do
- if string.find(n, "^"..name.."%[%d+%]$") then
- value.value[tonumber(string.match(n, "%[(%d+)%]$"))] = val
- end
- end
- end
- else
- value.value = clientdata[name] or value.value
- end
- end
-end
-
-function handle_form(self, getFunction, setFunction, clientdata, option, label, descr)
- local form = getFunction(clientdata)
-
- if clientdata.submit then
- handle_clientdata(form, clientdata)
-
- form = setFunction(form, clientdata.submit)
- if not form.errtxt and descr then
- form.descr = descr
- end
-
- if clientdata.redir then
- form.value.redir = cfe({ type="hidden", value=clientdata.redir, label="" })
- end
- form = self:redirect_to_referrer(form)
- if clientdata.redir and not form.errtxt then
- form.value = form.descr -- make it a command result
- form.descr = nil
- self:redirect(clientdata.redir, form)
- end
- else
- if clientdata.redir then
- form.value.redir = cfe({ type="hidden", value=clientdata.redir, label="" })
- end
- form = self:redirect_to_referrer() or form
- end
-
- form.type = "form"
- form.option = option or form.option
- form.label = label or form.label
-
- return form
-end