I have the editor working. I haven't spent the time to tightly couple it, though, so you have to first use telerik's update to save from the editor to DNN's edit page, and the use DNN's update to post changes to the database.
Here are my files: (This assumes you have the RadControls dir in the host root... I'm not sure the best place to put it. This does force you to add a alias to the portalalias table to get image inserts)
Caveat's: I made a change to the HTML module so that it doesn't inject the path to image files as it renders. Rather, I let R.A.D. code that into the html stream, and thus the database.
So any existing html with src= would have to change.
I think these are the only changes I needed. I can't swear to it. YMMV. :)
All changes is .vb should be tagged with -MBRANDON. I didn't tag all my changes in .aspx... I think it's just in the panel that displays the FTB.
Finally, I am still on 1.0.8, as I haven't had the time to start patching .9 with my enhancements.
-Mark
mbrandon@installed.net
EditHTML.ascx:
<%@ Register TagPrefix="radE" Namespace="Telerik.RadEditor" Assembly="RadEditor" %>
<%@ Control language="vb" Inherits="DotNetNuke.EditHtml" CodeBehind="EditHtml.ascx.vb" AutoEventWireup="false" Explicit="True" %>
<%@ Register TagPrefix="Portal" TagName="Title" Src="~/controls/DesktopModuleTitle.ascx"%>
<% 'MBRANDON: Switch to RAD from ftb %>
<% '@ Register TagPrefix="ftb" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
<portal:title runat="server" id="Title1" />
<br>
<table cellspacing="2" cellpadding="2" border="0">
<tr valign="top">
<td> </td>
<td align="middle">
<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</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr valign="top">
<td class="SubHead">
Desktop Content:
</td>
<td>
<asp:Panel ID="pnlBasicTextBox" Runat="server" Visible="False">
<asp:TextBox id="txtDesktopHTML" runat="server" CssClass="NormalTextBox" columns="75" width="600" rows="12" textmode="multiline"></asp:TextBox>
<BR>
<asp:RadioButtonList id="optRender" AutoPostBack="True" RepeatDirection="Horizontal" CssClass="NormalTextBox" Runat="server">
<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">
<radE:RadEditor id="ftbDesktopText" Runat="server" LicenseFile="~/RadControls/LicenseFile.xml"></radE:RadEditor>
</asp:Panel>
</td>
</tr>
<tr valign="top">
<td class="SubHead">
Mobile Summary<br>
(Optional):
</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">
Mobile Details<br>
(Optional):
</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" />
<asp:LinkButton id="cmdCancel" Text="Cancel" CausesValidation="False" runat="server" class="CommandButton" BorderStyle="none" />
<asp:LinkButton id="cmdPreview" Text="Preview" CausesValidation="False" runat="server" class="CommandButton" BorderStyle="none" />
</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.
'
Imports FreeTextBoxControls
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
'MBRANDON: Change ftb to RAD - also change all instance of .text to .value for RAD
'Protected WithEvents ftbDesktopText As FreeTextBoxControls.FreeTextBox
Protected WithEvents ftbDesktopText As Telerik.RadEditor.RadEditor
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
'MBRANDON: change to RAD paths
ftbDesktopText.ImagesPaths = New String() {_portalSettings.UploadDirectory.Substring(_portalSettings.UploadDirectory.IndexOf("/Portals/"))}
ftbDesktopText.MediaPaths = New String() {_portalSettings.UploadDirectory.Substring(_portalSettings.UploadDirectory.IndexOf("/Portals/"))}
ftbDesktopText.FlashPaths = New String() {_portalSettings.UploadDirectory.Substring(_portalSettings.UploadDirectory.IndexOf("/Portals/"))}
ftbDesktopText.UploadImagesPaths = New String() {_portalSettings.UploadDirectory.Substring(_portalSettings.UploadDirectory.IndexOf("/Portals/"))}
ftbDesktopText.UploadMediaPaths = New String() {_portalSettings.UploadDirectory.Substring(_portalSettings.UploadDirectory.IndexOf("/Portals/"))}
ftbDesktopText.UploadFlashPaths = New String() {_portalSettings.UploadDirectory.Substring(_portalSettings.UploadDirectory.IndexOf("/Portals/"))}
ftbDesktopText.AllowCustomColors = True
'ftbDesktopText.ImageGalleryPath = _portalSettings.UploadDirectory.Substring(_portalSettings.UploadDirectory.IndexOf("/Portals/"))
'MBRANDON: NOT needed for RAD
'ftbDesktopText.HelperFilesParameters = "tabid=" & TabId
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.Value = Server.HtmlDecode(CType(dr("DesktopHtml"), String))
txtMobileSummary.Text = Server.HtmlDecode(CType(dr("MobileSummary"), String))
txtMobileDetails.Text = Server.HtmlDecode(CType(dr("MobileDetails"), String))
Else
ftbDesktopText.Value = "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.Value)
Else
txtDesktopHTML.Text = ftbDesktopText.Value
End If
Else
If optRender.SelectedItem.Value = "T" Then
ftbDesktopText.Value = FormatHTML(txtDesktopHTML.Text)
Else
ftbDesktopText.Value = 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.Value)
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))
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
' Redirect back to the portal home page
Response.Redirect(CType(ViewState("UrlReferrer"), String))
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.Value)
End If
lblPreview.Text = ManageUploadDirectory(Server.HtmlDecode(strDesktopHTML), _portalSettings.UploadDirectory)
End Sub
End Class
End Namespace
HTMLModule.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 MustInherit Class HtmlModule
Inherits DotNetNuke.PortalModuleControl
Protected WithEvents HtmlHolder As System.Web.UI.HtmlControls.HtmlTableCell
#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 handler on this User Control is
' used to render a block of HTML or text to the page.
' The text/HTML to render is stored in the HtmlText
' database table. This method uses the DotNetNuke.HtmlTextDB()
' data component to encapsulate all data functionality.
'
'*******************************************************
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)
' Obtain the selected item from the HtmlText table
Dim objHTML As New HtmlTextDB()
Dim dr As SqlDataReader = objHTML.GetHtmlText(ModuleId)
If dr.Read() Then
' Dynamically add the file content into the page
Dim content As String = Server.HtmlDecode(CType(dr("DesktopHtml"), String))
'MBRANDON - r.a.d. editor will inject Upload Dir.
'HtmlHolder.Controls.Add(New LiteralControl(ManageUploadDirectory(content, _portalSettings.UploadDirectory)))
HtmlHolder.Controls.Add(New LiteralControl(content))
End If
' Close the datareader
dr.Close()
End Sub
'MBRANDON - Function no longer used.
'Private Function ManageUploadDirectory(ByVal strHTML As String, ByVal strUploadDirectory As String) As String
' Dim P As Integer
' P = InStr(1, strHTML.ToLower, "src=""")
' While P <> 0
' ManageUploadDirectory = ManageUploadDirectory & Left(strHTML, P + 4)
' strHTML = Mid(strHTML, P + 5)
' ' add uploaddirectory if we are linking internally
' Dim strSRC = Left(strHTML, InStr(1, strHTML, """") - 1)
' If InStr(1, strSRC, "://") = 0 Then
' strHTML = strUploadDirectory & strHTML
' End If
' P = InStr(1, strHTML.ToLower, "src=""")
' End While
' ManageUploadDirectory = ManageUploadDirectory & strHTML
'End Function
End Class
End Namespace