<% 'ezyEdit 1.0 '8-Mar-2001 'TODO: '# Allow multiple pages. Database is setup up for it. We now need to allow user ' to choose which page to edit and set it to tableid '# Fix input strings to allow "'" 'SETUP INSTRUCTIONS 'If there is more than one table, you need to set Session("tableid") = S where S is the table number. 'To add new templates, edit ' templateSelect.asp *** Shows the drop down box of all available templates ' templateShow.asp *** The output of each template. (What the end user sees... colours,fonts,style) ' templateEdit.asp *** Code the editor sees when they edit their page. 'which together stores the template generation code. 'Change "thispage" to the name of the file which includes ezyedit.asp eg ("products.asp") 'Create a login page or call eelogin.asp which sets Session("EditAccess") = true when password is correct. 'showtable.asp is called by the editable page (eg products.asp) using the following as an example ' ' <% Session("tableID") = 1 % > ' ' ' <% Session("tableID") = 2 % > ' ' ' 'Session("tableID") is the table number you want inserted. The closing tag for table number two 'is present only because table number 2 happens to use a opening tag a template. 'NOTE: When creating new templates for clients, care must be taken to ensure tables are created and closed ' correctly. If you use a template to open a table tag, ensure it is being closed after including showtable.asp if not Session("EditAccess") = true then response.redirect "ezyedit/eelogin.asp" else thispage = Session("editablepage") 'the editable page ' return normal page templateid = request("templateID") 'Get the individual data template to edit. 'Setting of the tableid variable is a mess at the moment. It is so we can edit multiple tables. tableid = request("tableid") if not (tableid > 0) then tableid = Session("tableID") 'Get page to edit or show. if not (tableid > 0) then tableid = 1 'Show list of pages to edit and allow user to select. end if end if act = request("act") 'See if any actions are to be performed 'ezyEDIT DATABASE '***** Connection to ezyedit.mdb *****' set connVB = server.createobject("ADODB.Connection") 'response.write server.mappath("ezyedit/database/ezyedit.mdb") connVB.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("ezyedit/database/ezyedit.mdb") set rsHtmTable = connVB.Execute("SELECT * FROM HTMTABLE WHERE htmtableID=" & tableid) 'get the details for this page\ set rsTableNames = connVB.Execute("SELECT distinct title, htmtableID, DefaultTemplate FROM HTMTABLE") '***** Finished connection to ezyedit.mdb *****' %> <% if act = "add" then ' Set up a blank rsTemplate. This is so we can use the #include "templateEdit.asp" without errors set rsTemplate = connVB.Execute("SELECT * FROM TEMPLATES WHERE htmtableID = 0") %>
"> <% formName = "addtemplate" Select Case request("type") %> <% end select %> <%if CustomSave then%> <%Else%> <%end if%>
Please complete the details to add to the "<%=rsHtmTable("title")%>" table.
Template Type: <%=request("type")%>
Order Priority:
Items are sorted in Ascending order. eg. If you want it at the top, give it a low or even negative priority.
Check details are correct:
Check details are correct:
<% else 'IF NOT ADDING A TEMPLATE, DO MAIN ezyEDIT SECTION %>
<% if act = "edit" then set rsTemplate = connVB.Execute("SELECT * FROM TEMPLATES WHERE templateID =" & templateid) %> "> "> <% formName = "updatetemplate" Select Case rsTemplate("templateType") %> <% end select %> <%if CustomSave then%> <%Else%> <%end if%> <% else %> > <% end if 'IF EDIT TEMPLATE%>
<% Select Case act 'DO PROCESSING Case "delete" connVB.Execute("DELETE FROM TEMPLATES WHERE templateID =" & templateid) response.write("Deleted Successfully") Case "addatemplate" strTextA = replace(request("textA"),"'","''") strTextA = replace(strTextA, "", "") strTextA = replace(strTextA, "", "") SQL = "INSERT INTO TEMPLATES (templateType, htmtableID, orderpriority, textA, textB, textC, textD, textE, textF, imageA, imageB, imageC, imageD, imageE, imageF, classA, classB, classC, classD, classE, classF)" SQL = SQL + " values ('" & request("type") & "', " & TableID & ", " & request("order") & ", '" & strTextA & "', '" & replace(request("textB"),"'","''") & "', '" & replace(request("textC"),"'","''") & "', '" & replace(request("textD"),"'","''") & "', '" & replace(request("textE"),"'","''") & "', '" & replace(request("textF"),"'","''") & "', '" & request("imageA") & "', '" & request("imageB") & "', '" & request("imageC") & "', '" & request("imageD") & "', '" & request("imageE") & "', '" & request("imageF") & "', '" & request("classA") & "', '" & request("classB") & "', '" & request("classC") & "', '" & request("classD") & "', '" & request("classE") & "', '" & request("classF") & "')" 'response.write SQL connVB.Execute(SQL) response.write("Added successfully!") Case "updatetemplate" strTextA = replace(request("textA"),"'","''") strTextA = replace(strTextA, "", "") strTextA = replace(strTextA, "", "") SQL = "UPDATE TEMPLATES SET " & _ "templateType = '" & request("type") & "' ," & _ " htmtableID = " & tableid & "," & _ " orderpriority = " & request("order") & "," & _ " textA = '" & strTextA & "', " & _ " textB = '" & replace(request("textB"),"'","''") & "', " & _ " textC = '" & replace(request("textC"),"'","''") & "', " & _ " textD = '" & replace(request("textD"),"'","''") & "', " & _ " textE = '" & replace(request("textE"),"'","''") & "', " & _ " textF = '" & replace(request("textF"),"'","''") & "', " & _ " imageA = '" & request("imageA") & "', " & _ " imageB = '" & request("imageB") & "', " & _ " imageC = '" & request("imageC") & "', " & _ " imageD = '" & request("imageD") & "', " & _ " imageE = '" & request("imageE") & "', " & _ " imageF = '" & request("imageF") & "', " & _ " classA = '" & request("classA") & "', " & _ " classB = '" & request("classB") & "', " & _ " classC = '" & request("classC") & "', " & _ " classD = '" & request("classD") & "', " & _ " classE = '" & request("classE") & "', " & _ " classF = '" & request("classF") & "'" & _ " WHERE templateID = " & templateid 'response.write SQL connVB.Execute(SQL) response.write("Updated successfully!") End Select %>
X Logout and check changes
OR open the VIEW page and hit the refresh Button to see changes.

Please edit the contents of the "<%=rsHtmTable("title")%>" table
Template Type: <%=rsTemplate("templateType")%>
Order Priority:
Items are sorted in Ascending order. eg. If you want it at the top, give it a low or even negative priority.
">
Check details are correct:
Check details are correct:
Table Name:   
Add New Data To Page: Template Type:
<% rsTableNames.movefirst rsTableNames.Filter = "htmtableID = " & CInt(tableid) if not (rsTableNames.EOF AND rsTableNames.BOF) then templateType = rsTableNames("DefaultTemplate") Else templateType = "" End if %>

<% end if 'IF ADD TEMPLATE%>

The following table represents what will show in
<%=rsHtmTable("title")%>

<% set rsData = connVB.Execute("SELECT * FROM TEMPLATES WHERE htmtableID=" & tableid & " ORDER BY orderpriority") 'get all templates in this page while not (rsData.EOF OR rsData.BOF) set rsTemplate = connVB.Execute("SELECT * FROM TEMPLATES WHERE templateID =" & rsData("TemplateID")) Select Case rsTemplate("templateType") 'variations %> <% end Select%> " ACTION="<%=thispage%>" method=post> > <% rsData.movenext() Wend %>
.act.value='delete';SubmitIfGood(document.frm<%=rsTemplate("templateID")%>)"; onMouseOver="window.status='Delete This Template';return true;" onMouseOut="window.status='';return true;">[Delete]  .act.value='edit';document.frm<%=rsTemplate("templateID")%>.submit();" onMouseOver="window.status='Edit This Template';return true;" onMouseOut="window.status='';return true;">[Edit]   (<%=rsTemplate("templateType")%>) OrderPriority: <%=rsTemplate("OrderPriority")%>
 
<% end if %>