Re: integrating into dotnetnuke

  •  03-02-2004, 7:32 PM

    Re: integrating into dotnetnuke

     

    EditHtml.ascx

    <%@ Register TagPrefix="ftb" Namespace="CuteEditor" Assembly="CuteEditor" %>

    <%@ Control language="vb" Inherits="DotNetNuke.EditHtml" CodeBehind="EditHtml.ascx.vb" AutoEventWireup="false" Explicit="True" %>

    <%@ Register TagPrefix="Portal" TagName="Title" Src="~/controls/DesktopModuleTitle.ascx"%>

    <portal:title runat="server" id="Title1" />

    <br>

    <table cellspacing="2" cellpadding="2" border="0" summary="Edit HTML Design Table">

    <tr valign="top">

    <td>&nbsp;</td>

    <td align="center">

    <asp:RadioButtonList ID="optView" Runat="server" CssClass="NormalTextBox" RepeatDirection="Horizontal" AutoPostBack="True">

    <asp:ListItem Value="B">Basic Text Box</asp:ListItem>

    <asp:ListItem Value="R">Rich Text Editor ( DotNetEdit )</asp:ListItem>

    </asp:RadioButtonList>

    </td>

    </tr>

    <tr valign="top">

    <td class="SubHead">

    <label for='<%=IIf(optView.SelectedItem.Value = "B" , txtDesktopHTML.ClientID, ftbDesktopText.ClientID)%>'>Desktop Content:</label>

    </td>

    <td>

    <asp:Panel ID="pnlBasicTextBox" Runat="server" Visible="False">

    <asp:TextBox id="txtDesktopHTML" runat="server" CssClass="NormalTextBox" textmode="multiline" rows="12" width="600" columns="75"></asp:TextBox><BR>

    <asp:RadioButtonList ID="optRender" Runat="server" CssClass="NormalTextBox" RepeatDirection="Horizontal" AutoPostBack="True">

    <asp:ListItem Value="T">Text</asp:ListItem>

    <asp:ListItem Value="H">HTML</asp:ListItem>

    </asp:RadioButtonList>

    </asp:Panel>

    <asp:Panel ID="pnlRichTextBox" Runat="server" Visible="False">

    <FTB:Editor id="ftbDesktopText" AutoConfigure="EnableAll" runat="server"></FTB:Editor>

    </asp:Panel>

    </td>

    </tr>

    <tr valign="top">

    <td class="SubHead">

    <label for="<%=txtMobileSummary.ClientID%>">Mobile Summary<br>

    (Optional):</label>

    </td>

    <td>

    <asp:TextBox id="txtMobileSummary" runat="server" CssClass="NormalTextBox" columns="75" width="600" rows="3" textmode="multiline" />

    </td>

    </tr>

    <tr valign="top">

    <td class="SubHead">

    <label for="<%=txtMobileDetails.ClientID%>">Mobile Details<br>

    (Optional):</label>

    </td>

    <td>

    <asp:TextBox id="txtMobileDetails" runat="server" CssClass="NormalTextBox" columns="75" width="600" rows="5" textmode="multiline" />

    </td>

    </tr>

    </table>

    <p>

    <asp:LinkButton id="cmdUpdate" Text="Update" runat="server" class="CommandButton" BorderStyle="none" />

    &nbsp;

    <asp:LinkButton id="cmdCancel" Text="Cancel" CausesValidation="False" runat="server" class="CommandButton" BorderStyle="none" />

    &nbsp;

    <asp:LinkButton id="cmdPreview" Text="Preview" CausesValidation="False" runat="server" class="CommandButton" BorderStyle="none" />

    &nbsp;

    </p>

    <table width="750" cellspacing="0" cellpadding="0">

    <tr valign="top">

    <td>

    <asp:Label ID="lblPreview" Runat="server" CssClass="Normal"></asp:Label>

    </td>

    </tr>

    </table>

     

     EditHtml.ascx.vb

     

     

    '

    ' DotNetNuke - http://www.dotnetnuke.com

    ' Copyright (c) 2002-2003

    ' by Shaun Walker ( sales@perpetualmotion.ca ) of Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )

    '

    ' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated

    ' documentation files (the "Software"), to deal in the Software without restriction, including without limitation

    ' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and

    ' to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    '

    ' The above copyright notice and this permission notice shall be included in all copies or substantial portions

    ' of the Software.

    '

    ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED

    ' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL

    ' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF

    ' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER

    ' DEALINGS IN THE SOFTWARE.

    '

    Namespace DotNetNuke

    Public Class EditHtml

    Inherits DotNetNuke.PortalModuleControl

    Protected WithEvents optView As System.Web.UI.WebControls.RadioButtonList

    Protected WithEvents pnlBasicTextBox As System.Web.UI.WebControls.Panel

    Protected WithEvents pnlRichTextBox As System.Web.UI.WebControls.Panel

    Protected WithEvents txtDesktopHTML As System.Web.UI.WebControls.TextBox

    Protected WithEvents optRender As System.Web.UI.WebControls.RadioButtonList

    Protected WithEvents ftbDesktopText As CuteEditor.Editor

    Protected WithEvents txtMobileSummary As System.Web.UI.WebControls.TextBox

    Protected WithEvents txtMobileDetails As System.Web.UI.WebControls.TextBox

    Protected WithEvents cmdUpdate As System.Web.UI.WebControls.LinkButton

    Protected WithEvents cmdCancel As System.Web.UI.WebControls.LinkButton

    Protected WithEvents cmdPreview As System.Web.UI.WebControls.LinkButton

    Protected WithEvents lblPreview As System.Web.UI.WebControls.Label

    #Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

    'CODEGEN: This method call is required by the Web Form Designer

    'Do not modify it using the code editor.

    InitializeComponent()

    End Sub

    #End Region

    '****************************************************************

    '

    ' The Page_Load event on this Page is used to obtain the ModuleId

    ' of the xml module to edit.

    '

    ' It then uses the DotNetNuke.HtmlTextDB() data component

    ' to populate the page's edit controls with the text details.

    '

    '****************************************************************

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    ' Obtain PortalSettings from Current Context

    Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)

    ' Get settings from the database

    Dim settings As Hashtable = PortalSettings.GetModuleSettings(ModuleId)

    Dim DesktopView As String = CType(settings("desktopview"), String)

    Dim LastDesktopView As String = DesktopView

    If optView.SelectedIndex <> -1 Then

    DesktopView = optView.SelectedItem.Value

    Dim admin As New AdminDB

    admin.UpdateModuleSetting(ModuleId, "desktopview", DesktopView)

    End If

    If DesktopView <> "" Then

    optView.Items.FindByValue(DesktopView).Selected = True

    Else

    optView.SelectedIndex = 0

    End If

    Dim TextRender As String = CType(settings("textrender"), String)

    If optRender.SelectedIndex <> -1 Then

    TextRender = optRender.SelectedItem.Value

    Dim admin As New AdminDB

    admin.UpdateModuleSetting(ModuleId, "textrender", TextRender)

    End If

    If TextRender <> "" Then

    optRender.Items.FindByValue(TextRender).Selected = True

    Else

    optRender.SelectedIndex = 0

    End If

    If optView.SelectedItem.Value = "B" Then

    pnlBasicTextBox.Visible = True

    pnlRichTextBox.Visible = False

    Else

    pnlBasicTextBox.Visible = False

    pnlRichTextBox.Visible = True

    End If

    If Page.IsPostBack = False Then

    ' Obtain a single row of text information

    Dim objHTML As New HtmlTextDB

    Dim dr As SqlDataReader = objHTML.GetHtmlText(ModuleId)

    If dr.Read() Then

    If optRender.SelectedItem.Value = "T" Then

    txtDesktopHTML.Text = FormatText(CType(dr("DesktopHtml"), String))

    Else

    txtDesktopHTML.Text = Server.HtmlDecode(CType(dr("DesktopHtml"), String))

    End If

    ftbDesktopText.Text = Server.HtmlDecode(CType(dr("DesktopHtml"), String))

    txtMobileSummary.Text = Server.HtmlDecode(CType(dr("MobileSummary"), String))

    txtMobileDetails.Text = Server.HtmlDecode(CType(dr("MobileDetails"), String))

    Else

    ftbDesktopText.Text = "Add Content..."

    txtDesktopHTML.Text = "Add Content..."

    txtMobileSummary.Text = ""

    txtMobileDetails.Text = ""

    End If

    dr.Close()

    ' Store URL Referrer to return to portal

    If Not Request.UrlReferrer Is Nothing Then

    ViewState("UrlReferrer") = Request.UrlReferrer.ToString()

    Else

    ViewState("UrlReferrer") = ""

    End If

    Else

    If (LastDesktopView <> optView.SelectedItem.Value) And (Not LastDesktopView Is Nothing) Then

    If optView.SelectedItem.Value = "B" Then

    If optRender.SelectedItem.Value = "T" Then

    txtDesktopHTML.Text = FormatText(ftbDesktopText.Text)

    Else

    txtDesktopHTML.Text = ftbDesktopText.Text

    End If

    Else

    If optRender.SelectedItem.Value = "T" Then

    ftbDesktopText.Text = FormatHTML(txtDesktopHTML.Text)

    Else

    ftbDesktopText.Text = txtDesktopHTML.Text

    End If

    End If

    Else

    If optView.SelectedItem.Value = "B" Then

    If optRender.SelectedItem.Value = "T" Then

    txtDesktopHTML.Text = FormatText(txtDesktopHTML.Text)

    Else

    txtDesktopHTML.Text = FormatHTML(txtDesktopHTML.Text)

    End If

    End If

    End If

    End If

    End Sub

     

    Private Function FormatText(ByVal strHTML As String) As String

    Dim strText As String = strHTML

    strText = Replace(strText, "<br>", ControlChars.Lf)

    strText = Replace(strText, "<BR>", ControlChars.Lf)

    strText = Server.HtmlDecode(strText)

    Return strText

    End Function

    Private Function FormatHTML(ByVal strText As String) As String

    Dim strHTML As String = strText

    strHTML = Replace(strHTML, Chr(13), "")

    strHTML = Replace(strHTML, ControlChars.Lf, "<br>")

    Return strHTML

    End Function

    '****************************************************************

    '

    ' The cmdUpdate_Click event handler on this Page is used to save

    ' the text changes to the database.

    '

    '****************************************************************

    Private Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdUpdate.Click

    Dim objHTML As New HtmlTextDB

    Dim strDesktopHTML As String

    If pnlBasicTextBox.Visible Then

    If optRender.SelectedItem.Value = "T" Then

    strDesktopHTML = FormatHTML(txtDesktopHTML.Text)

    Else

    strDesktopHTML = txtDesktopHTML.Text

    End If

    Else

    strDesktopHTML = Server.HtmlEncode(ftbDesktopText.Text)

    End If

    ' Update the text within the HtmlText table

    objHTML.UpdateHtmlText(ModuleId, strDesktopHTML, Server.HtmlEncode(txtMobileSummary.Text), Server.HtmlEncode(txtMobileDetails.Text))

    ' Redirect back to the portal home page

    Response.Redirect(CType(ViewState("UrlReferrer"), String), True)

    End Sub

     

    '****************************************************************

    '

    ' The cmdCancel_Click event handler on this Page is used to cancel

    ' out of the page, and return the user back to the portal home

    ' page.

    '

    '****************************************************************'

    Private Sub cmdCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdCancel.Click

    Response.Redirect(CType(ViewState("UrlReferrer"), String), True)

    End Sub

    Private Sub cmdPreview_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdPreview.Click

    ' Obtain PortalSettings from Current Context

    Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)

    Dim strDesktopHTML As String

    If pnlBasicTextBox.Visible Then

    strDesktopHTML = Server.HtmlEncode(txtDesktopHTML.Text)

    If optRender.SelectedItem.Value = "T" Then

    strDesktopHTML = Replace(strDesktopHTML, ControlChars.Lf, "<br>")

    End If

    Else

    strDesktopHTML = Server.HtmlEncode(ftbDesktopText.Text)

    End If

    lblPreview.Text = ManageUploadDirectory(Server.HtmlDecode(strDesktopHTML), _portalSettings.UploadDirectory)

    End Sub

    End Class

    End Namespace

     

     

    Hope it helps.  Let me know if you have any questions.


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View Complete Thread