diff options
author | Ted Trask <ttrask01@yahoo.com> | 2012-02-02 20:59:08 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2012-02-02 20:59:08 +0000 |
commit | df80810456f4a13d48eba24bfa1fa79b360c8426 (patch) | |
tree | a62390b08c245d5e615a9b074d73a8b15adf8d0a /lib | |
parent | 27c777f203a409442ca184f3aa20e703b4784927 (diff) | |
download | acf-core-df80810456f4a13d48eba24bfa1fa79b360c8426.tar.bz2 acf-core-df80810456f4a13d48eba24bfa1fa79b360c8426.tar.xz |
Changed viewfunctions.lua to htmlviewfunctions.lua and made it an actual module
It should have been a module all along, but wasn't
Unfortunately, this means changes to pretty much every view file
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile | 2 | ||||
-rw-r--r-- | lib/README | 2 | ||||
-rw-r--r-- | lib/htmlviewfunctions.lua (renamed from lib/viewfunctions.lua) | 30 |
3 files changed, 13 insertions, 21 deletions
diff --git a/lib/Makefile b/lib/Makefile index d8b1f0a..e1e616b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -5,7 +5,7 @@ LIB_DIST=menubuilder.lua\ authenticator.lua\ authenticator-plaintext.lua\ roles.lua\ - viewfunctions.lua\ + htmlviewfunctions.lua\ controllerfunctions.lua\ modelfunctions.lua\ @@ -18,4 +18,4 @@ processinfo.lua - Start/stop, find running, find version - process helpers roles.lua - Used to determine roles and permissions session.lua - Helps with Session mangement in ACF validator.lua - Validate web input for ACF. -viewfunctions.lua - Common view functions +htmlviewfunctions.lua - Common functions for HTML views diff --git a/lib/viewfunctions.lua b/lib/htmlviewfunctions.lua index e447fc3..ef59485 100644 --- a/lib/viewfunctions.lua +++ b/lib/htmlviewfunctions.lua @@ -1,7 +1,9 @@ +module(..., package.seeall) + html = require("acf.html") require("session") -function getlabel(myitem, value) +local function getlabel(myitem, value) if myitem and (myitem.type == "select" or myitem.type == "multi") then for x,val in ipairs(myitem.option) do local v,l @@ -20,10 +22,14 @@ function getlabel(myitem, value) return tostring(value) end -function displayitemcustom(myitem, header_level) +function displayitem(myitem, header_level, page_info) if not myitem then return end - if myitem.type == "group" then - header_level = header_level or 2 + if myitem.type == "form" then + header_level = header_level or 1 + io.write("<H"..tostring(header_level)..">"..html.html_escape(myitem.label).."</H"..tostring(header_level)..">") + displayform(myitem, nil, nil, page_info, header_level) + elseif myitem.type == "group" then + header_level = header_level or 1 io.write("<H"..tostring(header_level)..">"..html.html_escape(myitem.label).."</H"..tostring(header_level)..">") if myitem.descr then io.write('<P CLASS="descr">' .. string.gsub(html.html_escape(myitem.descr), "\n", "<BR>") .. "</P>\n") end if myitem.errtxt then io.write('<P CLASS="error">' .. string.gsub(html.html_escape(myitem.errtxt), "\n", "<BR>") .. "</P>\n") end @@ -43,7 +49,7 @@ function displayitemcustom(myitem, header_level) end for x,name in ipairs(order) do if myitem.value[name] then - displayitemcustom(myitem.value[name], tonumber(header_level)+1) + displayitem(myitem.value[name], tonumber(header_level)+1) end end elseif myitem.type ~= "hidden" then @@ -60,20 +66,6 @@ function displayitemcustom(myitem, header_level) io.write("</DD>\n") end end -function displayitem(myitem) - if not myitem then return end - io.write("<DT") - if myitem.errtxt then - myitem.class = "error" - io.write(" class='error'") - end - io.write(">" .. html.html_escape(myitem.label) .. "</DT>\n") - io.write("<DD>") - io.write(string.gsub(html.html_escape(tostring(myitem.value)), "\n", "<BR>") .. "\n") - if myitem.descr then io.write("<P CLASS='descr'>" .. string.gsub(html.html_escape(myitem.descr), "\n", "<BR>") .. "</P>\n") end - if myitem.errtxt then io.write("<P CLASS='error'>" .. string.gsub(html.html_escape(myitem.errtxt), "\n", "<BR>") .. "</P>\n") end - io.write("</DD>\n") -end function displayformitem(myitem, name, viewtype, header_level, group) if not myitem then return end |