summaryrefslogtreecommitdiffstats
path: root/lib/viewfunctions.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-10-22 18:50:22 +0000
committerTed Trask <ttrask01@yahoo.com>2008-10-22 18:50:22 +0000
commit8997f1f6dc27262042a30c35266a95672e4406d4 (patch)
tree548e8a666a7aa8f6e39e76e47b0c150d44dd92f1 /lib/viewfunctions.lua
parent7106e09511f1b873eaae17d2a6ae8bf008d06446 (diff)
downloadacf-core-8997f1f6dc27262042a30c35266a95672e4406d4.tar.bz2
acf-core-8997f1f6dc27262042a30c35266a95672e4406d4.tar.xz
Modified viewfunctions to split displayform, creating displayformstart and displayformend, to provide flexibility while still using the library. Also added support for hidden fields - including a common redir field. Removed redirectOnSuccess from controllerfunctions handle_form, and replaced it with the redir field. Removed redirectOnSuccess from controllers that used it and added handlecommandresults and redir entries to links and forms throughout many views. This will cause a redirect to the originating view when a form is successfully completed. acf_www-controller now includes orig_action in page_info to report the original action launched by the user.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@1560 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib/viewfunctions.lua')
-rw-r--r--lib/viewfunctions.lua35
1 files changed, 26 insertions, 9 deletions
diff --git a/lib/viewfunctions.lua b/lib/viewfunctions.lua
index 19911a0..c3e4b6a 100644
--- a/lib/viewfunctions.lua
+++ b/lib/viewfunctions.lua
@@ -102,13 +102,15 @@ end
function displayformitem(myitem, name, viewtype)
if not myitem then return end
if name then myitem.name = name end
- io.write("<DT")
- if myitem.errtxt then
- myitem.class = "error"
- io.write(' class="error"')
+ if myitem.type ~= "hidden" then
+ io.write("<DT")
+ if myitem.errtxt then
+ myitem.class = "error"
+ io.write(' class="error"')
+ end
+ io.write(">" .. myitem.label .. "</DT>\n")
+ io.write("<DD></DD>\n")
end
- io.write(">" .. myitem.label .. "</DT>\n")
- io.write("<DD>")
if (viewtype == "viewonly") then
myitem.disabled = "true"
end
@@ -163,13 +165,21 @@ function displayformitem(myitem, name, viewtype)
io.write("</DD>\n")
end
-function displayform(myform, order, finishingorder)
+function displayformstart(myform)
if not myform then return end
if myform.descr then io.write('<P CLASS="descr">' .. string.gsub(myform.descr, "\n", "<BR>") .. "</P>\n") end
if myform.errtxt then io.write('<P CLASS="error">' .. string.gsub(myform.errtxt, "\n", "<BR>") .. "</P>\n") end
io.write('<form action="' .. (myform.action or "") .. '" method="POST">\n')
+ if myform.value.redir then
+ displayformitem(myform.value.redir, "redir")
+ end
+end
+
+function displayform(myform, order, finishingorder)
+ if not myform then return end
+ displayformstart(myform)
io.write('<DL>\n')
- local reverseorder= {}
+ local reverseorder= {["redir"]=0}
if order then
for x,name in ipairs(order) do
reverseorder[name] = x
@@ -199,6 +209,13 @@ function displayform(myform, order, finishingorder)
end
end
end
+ io.write('</DL>\n')
+ displayformend(myform)
+end
+
+function displayformend(myform)
+ if not myform then return end
+ io.write('<DL>\n')
io.write('<DT></DT><DD><input class="submit" type="submit" name="' .. myform.option .. '" value="' .. (myform.submit or myform.option) .. '"></DD>\n')
io.write('</DL>\n')
io.write('</FORM>')
@@ -215,7 +232,7 @@ function displaycommandresults(commands, session)
if #cmdresult > 0 then
io.write("<H1>Command Result</H1>\n<DL>\n")
for i,result in ipairs(cmdresult) do
- if result.value ~= "" then io.write(result.value:gsub("\n", "<BR>") .. "\n") end
+ if type(result.value) == "string" and result.value ~= "" then io.write(result.value:gsub("\n", "<BR>") .. "\n") end
if result.descr then io.write('<P CLASS="descr">' .. string.gsub(result.descr, "\n", "<BR>") .. "</P>\n") end
if result.errtxt then io.write('<P CLASS="error">' .. string.gsub(result.errtxt, "\n", "<BR>") .. "</P>\n") end
end