From 8997f1f6dc27262042a30c35266a95672e4406d4 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 22 Oct 2008 18:50:22 +0000 Subject: 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 --- lib/viewfunctions.lua | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'lib/viewfunctions.lua') 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("" .. myitem.label .. "\n") + io.write("
\n") end - io.write(">" .. myitem.label .. "\n") - io.write("
") if (viewtype == "viewonly") then myitem.disabled = "true" end @@ -163,13 +165,21 @@ function displayformitem(myitem, name, viewtype) io.write("
\n") end -function displayform(myform, order, finishingorder) +function displayformstart(myform) if not myform then return end if myform.descr then io.write('

' .. string.gsub(myform.descr, "\n", "
") .. "

\n") end if myform.errtxt then io.write('

' .. string.gsub(myform.errtxt, "\n", "
") .. "

\n") end io.write('
\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('
\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('
\n') + displayformend(myform) +end + +function displayformend(myform) + if not myform then return end + io.write('
\n') io.write('
\n') io.write('
\n') io.write('
') @@ -215,7 +232,7 @@ function displaycommandresults(commands, session) if #cmdresult > 0 then io.write("

Command Result

\n
\n") for i,result in ipairs(cmdresult) do - if result.value ~= "" then io.write(result.value:gsub("\n", "
") .. "\n") end + if type(result.value) == "string" and result.value ~= "" then io.write(result.value:gsub("\n", "
") .. "\n") end if result.descr then io.write('

' .. string.gsub(result.descr, "\n", "
") .. "

\n") end if result.errtxt then io.write('

' .. string.gsub(result.errtxt, "\n", "
") .. "

\n") end end -- cgit v1.2.3