Re: Help with upgrade from version 3 to version 4 on Cute Editor for ASP

  •  05-23-2005, 12:59 PM

    Re: Help with upgrade from version 3 to version 4 on Cute Editor for ASP

    Here you go Adam. This page has nine editors on the page. The information is stored is stored in a SQL Server database.
     
    <%@LANGUAGE="VBSCRIPT"%>
    <!-- #include file = "CuteEditor_Files_V4/include_CuteEditor.asp" -->
    <!--#include file="Connections/dbconnections.asp" -->
    <!--#include virtual="secure.asp"-->
    <%
    ' *** Edit Operations: declare variables
    Dim MM_editAction
    Dim MM_abortEdit
    Dim MM_editQuery
    Dim MM_editCmd
    Dim MM_editConnection
    Dim MM_editTable
    Dim MM_editRedirectUrl
    Dim MM_editColumn
    Dim MM_recordId
    Dim MM_fieldsStr
    Dim MM_columnsStr
    Dim MM_fields
    Dim MM_columns
    Dim MM_typeArray
    Dim MM_formVal
    Dim MM_delim
    Dim MM_altVal
    Dim MM_emptyVal
    Dim MM_i
    MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
    If (Request.QueryString <> "") Then
      MM_editAction = MM_editAction & "?" & Request.QueryString
    End If
    ' boolean to abort record edit
    MM_abortEdit = false
    ' query string to execute
    MM_editQuery = ""
    %>
    <%
    ' *** Update Record: set variables
    If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then
      MM_editConnection = MM_dbconnections_STRING
      MM_editTable = "dbo.district_content"
      MM_editColumn = "ID"
      MM_recordId = "" + Request("MM_recordId") + ""
      MM_editRedirectUrl = "District_pub.asp"
      MM_fieldsStr  = "chan_one_title|value|chan_one_content|value|chan_two_title|value|Chan_two_content|value|chan_three_title|value|Chan_three_content|value|chan_four_title|value|Chan_four_content|value|chan_five_title|value|Chan_five_content|value|chan_six_title|value|Chan_six_content|value|chan_seven_title|value|Chan_seven_content|value|chan_eight_title|value|Chan_eight_content|value|chan_nine_title|value|Chan_nine_content|value|lstupdate|value"
      MM_columnsStr = "Chan_one_title|',none,''|Chan_one_Content|',none,''|Chan_two_title|',none,''|Chan_two_Content|',none,''|Chan_three_title|',none,''|Chan_three_Content|',none,''|Chan_four_title|',none,''|Chan_four_Content|',none,''|Chan_five_title|',none,''|Chan_five_Content|',none,''|Chan_six_title|',none,''|Chan_six_Content|',none,''|Chan_seven_title|',none,''|Chan_seven_Content|',none,''|Chan_eight_title|',none,''|Chan_eight_content|',none,''|Chan_nine_title|',none,''|Chan_nine_Content|',none,''|lstupdate|',none,''"
      ' create the MM_fields and MM_columns arrays
      MM_fields = Split(MM_fieldsStr, "|")
      MM_columns = Split(MM_columnsStr, "|")
     
      ' set the form values
      For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
        MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
      Next
      ' append the query string to the redirect URL
      If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
        If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
          MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
        Else
          MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
        End If
      End If
    End If
    %>
    <%
    ' *** Update Record: construct a sql update statement and execute it
    If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
      ' create the sql update statement
      MM_editQuery = "update " & MM_editTable & " set "
      For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
        MM_formVal = MM_fields(MM_i+1)
        MM_typeArray = Split(MM_columns(MM_i+1),",")
        MM_delim = MM_typeArray(0)
        If (MM_delim = "none") Then MM_delim = ""
        MM_altVal = MM_typeArray(1)
        If (MM_altVal = "none") Then MM_altVal = ""
        MM_emptyVal = MM_typeArray(2)
        If (MM_emptyVal = "none") Then MM_emptyVal = ""
        If (MM_formVal = "") Then
          MM_formVal = MM_emptyVal
        Else
          If (MM_altVal <> "") Then
            MM_formVal = MM_altVal
          ElseIf (MM_delim = "'") Then  ' escape quotes
            MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
          Else
            MM_formVal = MM_delim + MM_formVal + MM_delim
          End If
        End If
        If (MM_i <> LBound(MM_fields)) Then
          MM_editQuery = MM_editQuery & ","
        End If
        MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
      Next
      MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
      If (Not MM_abortEdit) Then
        ' execute the update
        Set MM_editCmd = Server.CreateObject("ADODB.Command")
        MM_editCmd.ActiveConnection = MM_editConnection
        MM_editCmd.CommandText = MM_editQuery
        MM_editCmd.Execute
        MM_editCmd.ActiveConnection.Close
        If (MM_editRedirectUrl <> "") Then
          Response.Redirect(MM_editRedirectUrl)
        End If
      End If
    End If
    %>
    <%
    Dim Recordset1__MMColParam
    Recordset1__MMColParam = "1"
    If (Request.QueryString("DistrictID") <> "") Then
      Recordset1__MMColParam = Request.QueryString("DistrictID")
    End If
    CurrentPage="District_edit.asp?DistrictID=" & Request.QueryString("DistrictID")
    %>
    <%
    Dim Recordset1
    Dim Recordset1_numRows
    Set Recordset1 = Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection = MM_dbconnections_STRING
    Recordset1.Source = "SELECT ID, DistrictID, hdr_img, hdr_title, Chan_one_title, Chan_two_title, Chan_three_title, Chan_four_title, Chan_five_title, Chan_six_title, Chan_seven_title, Chan_eight_title, Chan_nine_title, Chan_one_Content, Chan_two_Content, Chan_three_Content, Chan_four_Content, Chan_five_Content, Chan_six_Content, Chan_seven_Content, Chan_eight_content,  Chan_nine_Content FROM dbo.district_content WHERE DistrictID = '" + Replace(Recordset1__MMColParam, "'", "''") + "'"
    Recordset1.CursorType = 0
    Recordset1.CursorLocation = 2
    Recordset1.LockType = 1
    Recordset1.Open()
    Recordset1_numRows = 0
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Lutheran School Portal District Page - Edit</title>
    <link rel="StyleSheet" type="text/css" href="CSS/lsp-1.css" title="LSP Default">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="css/lsp-1.css" rel="stylesheet" type="text/css">
    <script language="javascript">
     function UpdateData()
     {
      save(Chan1Editor)     
      save(Chan2Editor)
      save(Chan3Editor)
      save(Chan4Editor)
      save(Chan5Editor)
      save(Chan6Editor)
      save(Chan7Editor)
      save(Chan8Editor)
      save(Chan9Editor)
        
     }
    </script>
    </head>
    <BODY BGCOLOR=#FFFFFF LEFTMARGIN=2 TOPMARGIN=3 MARGINWIDTH=0 MARGINHEIGHT=0>
    <form action="<%=MM_editAction%>" method="POST" name="form1">
    <table width="800" border="0" cellspacing="0" cellpadding="0">
    <!-- begin Top bar -->
    <tr><td height="40" colspan="5" align="left" valign="middle" nowrap bgcolor="326698"><img src="logos/<%=(Recordset1.Fields.Item("hdr_img").Value)%>" border="0" align="absmiddle">
    &nbsp;<b><font color="#FFFFFF" size="+1">District Page for&nbsp;"<%=(Recordset1.Fields.Item("hdr_title").Value)%>"</font></b></td>
      </tr>
      
    <tr><td colspan="5"><img src="images/spacer.gif" width="1" height="5" border="0" alt=""></td></tr>
    <tr>
    <td colspan="5"><font color="#CC0000"><strong>Attention Content Editor:</strong></font> <br> <strong><font color="#CC0000">NOTE:</font> Be
      sure and click the &quot;Update&quot; button at the bottom of this page to save your
      changes!</strong><br>
     </td></tr>
     <!-- end top bar -->
     <tr>
     <!-- begin left thin column -->
     <td width="25%" align="left" valign="top">
     <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFfff"><tr><td bgcolor="326698"><h3>Title:&nbsp;<input name="chan_one_title" type="text" value="<%=trim((Recordset1.Fields.Item("Chan_one_title").Value))%>" size="25" maxlength="100">
     </h3></td></tr>
    <tr><td><table class="tabl" width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="5" align="center"><tr><td align="left"><%
    content = trim((Recordset1.Fields.Item("Chan_one_Content").Value))
    if isNull(content) or IsEmpty(content) or len(trim(content))= 0 then
     content = " "
    end if  
              Set editor = New CuteEditor
              editor.ID = "Chan1Editor"
              editor.Text = content
              editor.FilesPath = "CuteEditor_Files_V4"
              editor.ImageGalleryPath = "/uploads"
              editor.MaxImageSize = 50
              editor.DocumentPath = "/uploads/documents"
              editor.MaxDocumentSize = 2000
              editor.AutoConfigure = "Thin"
              editor.ShowBottomBar = true
              editor.ShowHtmlMode = true
              'editor.ShowLogo = false
              editor.HelpUrl = "editorhelp.htm"
              editor.Width = 260
              editor.Height = 250
              editor.Draw()
           %></td></tr>
     </table></td></tr></table><br>
     <table width="100%" border="0" cellspacing="0" cellpadding="0"  align="center"><tr><td bgcolor="#326698"><h3>Title:&nbsp;<input name="chan_two_title" type="text" value="<%=trim((Recordset1.Fields.Item("Chan_two_title").Value))%>" size="25" maxlength="100">
        </h3></td></tr>
    <tr><td align="left"><table class="tabl" width="100%" border="0" cellspacing="0" cellpadding="5" align="center"><tr><td align="left"><%
    content = trim((Recordset1.Fields.Item("Chan_two_Content").Value))
    if isNull(content) or IsEmpty(content) or len(trim(content))= 0 then
     content = " "
    end if  
              Set editor = New CuteEditor
              editor.ID = "Chan2Editor"
              editor.Text = content
              editor.FilesPath = "CuteEditor_Files_V4"
              editor.ImageGalleryPath = "/uploads"
              editor.MaxImageSize = 50
              editor.DocumentPath = "/uploads/documents"
              editor.MaxDocumentSize = 2000
              editor.AutoConfigure = "Thin"
              editor.ShowBottomBar = true
              editor.ShowHtmlMode = true
              editor.ShowLogo = false
              editor.HelpUrl = "editorhelp.htm"
              editor.Width = 260
              editor.Height = 250
              editor.Draw()
           %></td></tr></table>
    </td></tr></table><br>
     <table width="100%" border="0" cellspacing="0" cellpadding="0"  align="center"><tr><td bgcolor="#326698"><h3>Title:&nbsp;<input name="chan_three_title" type="text" value="<%=trim((Recordset1.Fields.Item("Chan_three_title").Value))%>" size="25" maxlength="100">
        </h3></td></tr>
    <tr><td align="left"><table class="tabl" width="100%" border="0" cellspacing="0" cellpadding="5" align="center"><tr><td align="left"><%
    content = trim((Recordset1.Fields.Item("Chan_three_Content").Value))
    if isNull(content) or IsEmpty(content) or len(trim(content))= 0 then
     content = " "
    end if  
              Set editor = New CuteEditor
              editor.ID = "Chan3Editor"
              editor.Text = content
              editor.FilesPath = "CuteEditor_Files_V4"
              editor.ImageGalleryPath = "/uploads"
              editor.MaxImageSize = 50
              editor.DocumentPath = "/uploads/documents"
              editor.MaxDocumentSize = 2000
              editor.AutoConfigure = "Thin"
              editor.ShowBottomBar = true
              editor.ShowHtmlMode = true
              editor.ShowLogo = false
              editor.HelpUrl = "editorhelp.htm"
              editor.Width = 260
              editor.Height = 250
              editor.Draw()
           %></td></tr></table>
    </td></tr></table>
     
    </td>
     <!-- End of left thin column -->
     <!-- begin left vertical spacer -->
     <td><img src="images/spacer.gif" width="3" height="1" border="0" alt=""></td>
    <!-- End of vertical spacer -->
    <!-- begin of center thick column -->
    <td width="50%" align="left" valign="top">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFfff"><tr><td bgcolor="326698"><h3>School Information</h3></td></tr>
    <tr><td><table class="tabl" width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="5" align="center"><tr>
      <td align="left"><strong>This area will be populated with information
          regarding the schools in this district.</strong></td>
    </tr>
     </table></td></tr></table><br>
     <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFfff"><tr><td bgcolor="326698"><h3>Title:&nbsp;<input name="chan_four_title" type="text"  size="50" maxlength="65" value="<%=trim((Recordset1.Fields.Item("Chan_four_title").Value))%>">
     </h3></td></tr>
    <tr><td><table class="tabl" width="100%" border="0" cellspacing="0" cellpadding="5" align="center"><tr><td align="left"><%
    content = trim((Recordset1.Fields.Item("Chan_four_Content").Value))
    if isNull(content) or IsEmpty(content) or len(trim(content))= 0 then
     content = " "
    end if  
              Set editor = New CuteEditor
              editor.ID = "Chan4Editor"
              editor.Text = content
              editor.FilesPath = "CuteEditor_Files_V4"
              editor.ImageGalleryPath = "/uploads"
              editor.MaxImageSize = 50
              editor.DocumentPath = "/uploads/documents"
              editor.MaxDocumentSize = 2000
              editor.AutoConfigure = "Wide"
              editor.ShowBottomBar = true
              editor.ShowHtmlMode = true
              editor.ShowLogo = false
              editor.Subsequent = true
              editor.HelpUrl = "editorhelp.htm"
              editor.Width = 400
              editor.Height = 250
              editor.Draw()
        %><</td></tr></table></td></tr></table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0"  align="center"><tr><td bgcolor="#326698"><h3>Title:&nbsp;<input name="chan_five_title" type="text" value="<%=trim((Recordset1.Fields.Item("Chan_five_title").Value))%>" size="50" maxlength="100">
        </h3></td></tr>
    <tr><td align="left"><table class="tabl" width="100%" border="0" cellspacing="0" cellpadding="5" align="center"><tr><td align="left"><%
    content = trim((Recordset1.Fields.Item("Chan_five_Content").Value))
    if isNull(content) or IsEmpty(content) or len(trim(content))= 0 then
     content = " "
    end if  
              Set editor = New CuteEditor
              editor.ID = "Chan5Editor"
              editor.Text = content
              editor.FilesPath = "CuteEditor_Files_V4"
              editor.ImageGalleryPath = "/uploads"
              editor.MaxImageSize = 50
              editor.DocumentPath = "/uploads/documents"
              editor.MaxDocumentSize = 2000
              editor.AutoConfigure = "Thin"
              editor.ShowBottomBar = true
              editor.ShowHtmlMode = true
              editor.ShowLogo = false
              editor.HelpUrl = "editorhelp.htm"
              editor.Width = 260
              editor.Height = 250
              editor.Draw()
           %></td></tr></table>
    </td></tr></table><br>
    <table width="100%" border="0" cellspacing="0" cellpadding="0"  align="center"><tr><td bgcolor="#326698"><h3>Title:&nbsp;<input name="chan_six_title" type="text" value="<%=trim((Recordset1.Fields.Item("Chan_six_title").Value))%>" size="50" maxlength="100">
        </h3></td></tr>
    <tr><td align="left"><table class="tabl" width="100%" border="0" cellspacing="0" cellpadding="5" align="center"><tr><td align="left"><%
    content = trim((Recordset1.Fields.Item("Chan_six_Content").Value))
    if isNull(content) or IsEmpty(content) or len(trim(content))= 0 then
     content = " "
    end if  
              Set editor = New CuteEditor
              editor.ID = "Chan6Editor"
              editor.Text = content
              editor.FilesPath = "CuteEditor_Files_V4"
              editor.ImageGalleryPath = "/uploads"
              editor.MaxImageSize = 50
              editor.DocumentPath = "/uploads/documents"
              editor.MaxDocumentSize = 2000
              editor.AutoConfigure = "Thin"
              editor.ShowBottomBar = true
              editor.ShowHtmlMode = true
              editor.ShowLogo = false
              editor.HelpUrl = "editorhelp.htm"
              editor.Width = 260
              editor.Height = 250
              editor.Draw()
           %></td></tr></table>
    </td></tr></table><br>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFfff"><tr><td bgcolor="326698"><h3>Title:&nbsp;<input name="chan_seven_title" type="text" size="50" maxlength="65" value="<%=trim((Recordset1.Fields.Item("Chan_seven_title").Value))%>">
    </h3></td></tr>
    <tr><td><table class="tabl" width="100%" border="0" cellspacing="0" cellpadding="5" align="center"><tr><td align="left"><%
    content = trim((Recordset1.Fields.Item("Chan_seven_Content").Value))
    if isNull(content) or IsEmpty(content) or len(trim(content))= 0 then
     content = " "
    end if  
              Set editor = New CuteEditor
              editor.ID = "Chan7Editor"
              editor.Text = content
              editor.FilesPath = "CuteEditor_Files_V4"
              editor.ImageGalleryPath = "/uploads"
              editor.MaxImageSize = 50
              editor.DocumentPath = "/uploads/documents"
              editor.MaxDocumentSize = 2000
              editor.AutoConfigure = "Wide"
              editor.ShowBottomBar = true
              editor.ShowHtmlMode = true
              editor.ShowLogo = false
              editor.Subsequent = true
              editor.HelpUrl = "editorhelp.htm"
              editor.Width = 400
              editor.Height = 250
              editor.Draw()
        %></td></tr></table></td></tr></table>
    </td>
    <!-- End of middle column -->
    <!-- Begin of right vertical spacer -->
     
     <td><img src="images/spacer.gif" width="3" height="1" border="0" alt=""></td>
    <!-- End of right vertical spacer -->
    <!-- Begin right thin column -->
        <td width="25%" valign="top">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFfff"><tr bgcolor="326698"><td bgcolor="326698"><h3>Documents</h3></td><td width="25" align="right"><a href="distfile_uploader.asp?DFDistrictID=<%=(Recordset1.Fields.Item("DistrictID").Value)%>" target="_blank"><img src="images/savedoc_btn.gif" alt="Click Here to add a document." border="0" align="absmiddle"></a></td></tr>
    <tr><td colspan="2"><table class="tabl" width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="5" align="center"><tr>
      <td align="left"><span class="sml">Here you can post documents specific to your district such
        as registration forms, newsletters, etc. Click on the <img src="images/savedoc_btn.gif" border="0" align="absmiddle"> button
        to upload a new document.<br>
        Your current document files are listed below.</span></td>
    </tr>
    <tr><td align="left"><iframe name="DistDocs" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%" height="170" scrolling="auto" src="Distfiles_edit.asp?DFDistrictID=<%=(Recordset1.Fields.Item("DistrictID").Value)%>"></iframe></td></tr>
     </table></td></tr></table><br>
     <table width="100%" border="0" cellspacing="0" cellpadding="0"  align="center"><tr><td bgcolor="#326698"><h3>Title:&nbsp;<input name="chan_eight_title" type="text" value="<%=trim((Recordset1.Fields.Item("Chan_eight_title").Value))%>" size="25" maxlength="100">
        </h3></td></tr>
    <tr><td align="left"><table class="tabl" width="100%" border="0" cellspacing="0" cellpadding="5" align="center"><tr><td align="left"><%
    content = trim((Recordset1.Fields.Item("Chan_eight_Content").Value))
    if isNull(content) or IsEmpty(content) or len(trim(content))= 0 then
     content = " "
    end if  
              Set editor = New CuteEditor
              editor.ID = "Chan8Editor"
              editor.Text = content
              editor.FilesPath = "CuteEditor_Files_V4"
              editor.ImageGalleryPath = "/uploads"
              editor.MaxImageSize = 50
              editor.DocumentPath = "/uploads/documents"
              editor.MaxDocumentSize = 2000
              editor.AutoConfigure = "thin"
              editor.ShowBottomBar = true
              editor.ShowHtmlMode = true
              editor.ShowLogo = false
              editor.HelpUrl = "editorhelp.htm"
              editor.Width = 260
              editor.Height = 250
              editor.Draw()
           %></td></tr></table>
    </td></tr></table><br>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFfff"><tr><td bgcolor="326698"><h3>Title:&nbsp;<input name="chan_nine_title" type="text"  size="25" maxlength="65" value="<%=trim((Recordset1.Fields.Item("Chan_nine_title").Value))%>">
    </h3></td></tr>
    <tr><td><table class="tabl" width="100%" border="0" cellspacing="0" cellpadding="5" align="center"><tr><td align="left"><%
    content = trim((Recordset1.Fields.Item("Chan_nine_Content").Value))
    if isNull(content) or IsEmpty(content) or len(trim(content))= 0 then
     content = " "
    end if  
              Set editor = New CuteEditor
              editor.ID = "Chan9Editor"
              editor.Text = content
              editor.FilesPath = "CuteEditor_Files_V4"
              editor.ImageGalleryPath = "/uploads"
              editor.MaxImageSize = 50
              editor.DocumentPath = "/uploads/documents"
              editor.MaxDocumentSize = 2000
              editor.AutoConfigure = "Wide"
              editor.ShowBottomBar = true
              editor.ShowHtmlMode = true
              editor.ShowLogo = false
              editor.Subsequent = true
              editor.HelpUrl = "editorhelp.htm"
              editor.Width = 400
              editor.Height = 250
              editor.Draw()
        %></td></tr></table></td></tr></table></td></tr>
    <!-- End of right thin column -->
    <input type="hidden" name="lstupdate" value="<%=Date()%>">
    <!-- begin of footer -->
      <tr><td colspan="5" align="center"><div align="center"><b>Click on the Update button when you are finished making changes.<br>
        The next page you see is the actual page as it will be shown in the portal.<br>
        To return to this page from the published page, click on the "Edit
        District Page" tab on the menu bar.</b></div></td></tr> 
       <tr bgcolor="#F5F5F5">
        <td colspan="5" align="center"><div align="center"><input name="Submit" type="submit" value="Update" onclick="UpdateData()">
    <input type="hidden" name="MM_update" value="form1">
      <input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("ID").Value %>"></div></td>
      </tr>
     <tr><td colspan="5"><img src="images/spacer.gif" width="1" height="15" border="0" alt=""></td></tr>    
    <tr><td colspan="5"><!--#include file="footer.asp"--></td></tr>
    </table>
    </form>
    </body>
    </html>
    <%
    Recordset1.Close()
    Set Recordset1 = Nothing
    %>
View Complete Thread