Line 1: '
Line 2: ' DotNetNuke® - http://www.dotnetnuke.com
Line 3: ' Copyright (c) 2002-2005
Line 4: ' by Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )
Line 5: '
Line 6: ' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
Line 7: ' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
Line 8: ' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
Line 9: ' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Line 10: '
Line 11: ' The above copyright notice and this permission notice shall be included in all copies or substantial portions
Line 12: ' of the Software.
Line 13: '
Line 14: ' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
Line 15: ' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
Line 16: ' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Line 17: ' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
Line 18: ' DEALINGS IN THE SOFTWARE.
Line 19: '
Line 20: Imports DotNetNuke.Modules.IFrame.Domain
Line 21: Imports DotNetNuke.Modules.IFrame.Data
Line 22: Imports DotNetNuke.Entities.Modules
Line 23: Imports System.Xml
Line 24:
Line 25: Namespace DotNetNuke.Modules.IFrame
Line 26: ''' <summary>
Line 27: ''' IFrame Module controller.
Line 28: ''' </summary>
Line 29: Public Class Controller
Line 30: Implements IPortable
Line 31:
Line 32: #Region "| Fields |"
Line 33:
Line 34: Protected Const RootElement As String = "iframe"
Line 35: Protected Const ParameterGroupElement As String = "parameters"
Line 36: Protected Const ParameterElement As String = "param"
Line 37: Protected Const ParameterNameElement As String = "name"
Line 38: Protected Const ParameterTypeElement As String = "type"
Line 39: Protected Const ParameterArgumentElement As String = "argument"
Line 40:
Line 41: Private _dataProvider As DataProvider
Line 42:
Line 43: #End Region
Line 44:
Line 45:
Line 46: #Region "| Sub-Classes |"
Line 47:
Line 48: ''' <summary>
Line 49: ''' IFrame Module properties.
Line 50: ''' </summary>
Line 51: ''' <remarks>
Line 52: ''' All properties will be used as <c>iframe</c> tag attributes unless preceded by the
Line 53: ''' NotAnAttributePrefix value.
Line 54: ''' </remarks>
Line 55: Public Class Properties
Line 56: Public Const NotAnAttributePrefix As String = "x-"
Line 57:
Line 58: 'Public Const UrlParameter As String = "x-url" 'removed!
Line 59:
Line 60: Public Const Name As String = "name"
Line 61: Public Const Source As String = "src"
Line 62: Public Const SourceType As String = NotAnAttributePrefix + "src-type"
Line 63: Public Const Height As String = "height"
Line 64: Public Const Autoheight As String = NotAnAttributePrefix + "autoheight"
Line 65: Public Const Width As String = "width"
Line 66: Public Const CssStyle As String = "style"
Line 67: Public Const OnLoad As String = "onload"
Line 68: Public Const ToolTip As String = "title"
Line 69: Public Const Scrolling As String = "scrolling"
Line 70: Public Const Border As String = "frameborder"
Line 71: Public Const AllowTransparency As String = "allowtransparency"
Line 72: Public Const UseAsHash As String = NotAnAttributePrefix + "use-as-hash"
Line 73: End Class
Line 74:
Line 75: #End Region
Line 76:
Line 77:
Line 78: #Region "| Import/Export |"
Line 79:
Line 80: ''' <summary>
Line 81: ''' Exports module settings.
Line 82: ''' </summary>
Line 83: ''' <param name="ModuleID">Unique identifier of the module to be exported.</param>
Line 84: Public Function ExportModule(ByVal ModuleID As Integer) As String Implements IPortable.ExportModule
Line 85:
Line 86: ' constants
Line 87: Const StartTagFormat As String = "<{0}>"
Line 88: Const EndTagFormat As String = "</{0}>"
Line 89: Const TagFormat As String = "<{0}>{1}</{0}>"
Line 90:
Line 91: ' init vars
Line 92: Dim objController As New ModuleController
Line 93: Dim objSettings As Hashtable = objController.GetModuleSettings(ModuleID)
Line 94: Dim sbXml As New StringBuilder
Line 95: Dim colParameters As IFrameParameterCollection
Line 96:
Line 97: ' start xml
Line 98: sbXml.AppendFormat(StartTagFormat, RootElement)
Line 99:
Line 100: ' save all keys
Line 101: For Each key As Object In objSettings.Keys
Line 102: sbXml.AppendFormat(TagFormat, Convert.ToString(key), _
Line 103: XmlUtils.XMLEncode(Convert.ToString(objSettings(key))))
Line 104: Next
Line 105:
Line 106: ' save all parameters
Line 107: sbXml.AppendFormat(StartTagFormat, ParameterGroupElement)
Line 108: colParameters = GetParameters(ModuleID)
Line 109: For i As Integer = 0 To colParameters.Count - 1
Line 110: If colParameters(i).IsValid Then
Line 111: sbXml.AppendFormat(StartTagFormat, ParameterElement)
Line 112: sbXml.AppendFormat(TagFormat, ParameterNameElement, XmlUtils.XMLEncode(colParameters(i).Name))
Line 113: sbXml.AppendFormat(TagFormat, ParameterTypeElement, _
Line 114: XmlUtils.XMLEncode( _
Line 115: [Enum].GetName(colParameters(i).Type.GetType(), _
Line 116: colParameters(i).Type)))
Line 117: If colParameters(i).IsArgumentRequired Then _
Line 118: sbXml.AppendFormat(TagFormat, ParameterArgumentElement, _
Line 119: XmlUtils.XMLEncode(colParameters(i).TypeArgument))
Line 120: sbXml.AppendFormat(EndTagFormat, ParameterElement)
Line 121: End If
Line 122: Next
Line 123: sbXml.AppendFormat(EndTagFormat, ParameterGroupElement)
Line 124:
Line 125: ' end xml
Line 126: sbXml.AppendFormat(EndTagFormat, RootElement)
Line 127:
Line 128: ' return xml
Line 129: Return sbXml.ToString()
Line 130:
Line 131: End Function
Line 132:
Line 133:
Line 134: ''' <summary>
Line 135: ''' Imports module settings.
Line 136: ''' </summary>
Line 137: ''' <param name="ModuleID">Unique identifier of the module to be exported.</param>
Line 138: ''' <param name="Content">XML content to import.</param>
Line 139: ''' <param name="Version">Version of the content being imported.</param>
Line 140: ''' <param name="UserID">Unique identifier of the user importing the content.</param>
Line 141: Public Sub ImportModule(ByVal ModuleID As Integer, ByVal Content As String, ByVal Version As String, _
Line 142: ByVal UserID As Integer) Implements IPortable.ImportModule
Line 143:
Line 144: ' init vars
Line 145: Dim objController As New ModuleController
Line 146: Dim objXml As XmlNode = GetContent(Content, RootElement)
Line 147:
Line 148: ' update settings
Line 149: For i As Integer = 0 To objXml.ChildNodes.Count - 1
Line 150: ' init vars
Line 151: Dim objNode As XmlNode = objXml.ChildNodes(i)
Line 152: Dim strKey As String = objNode.LocalName
Line 153:
Line 154: ' if not parameters node, save setting; otherwise, add to data store
Line 155: If strKey <> ParameterGroupElement Then
Line 156: ' handle version conflicts
Line 157: Select Case Version
Line 158: Case "03.02.00"
Line 159: Case Else
Line 160: If strKey = "border" Then strKey = Properties.Border
Line 161: End Select
Line 162:
Line 163: ' update settings
Line 164: objController.UpdateModuleSetting(ModuleID, strKey, objNode.InnerText)
Line 165: Else
Line 166: ' loop thru parameters
Line 167: For j As Integer = 0 To objNode.ChildNodes.Count - 1
Line 168: Dim objParam As New IFrameParameter
Line 169: objParam.ModuleID = ModuleID
Line 170: For k As Integer = 0 To objNode.ChildNodes(j).ChildNodes.Count - 1
Line 171: Dim objParamPropertyNode As XmlNode = objNode.ChildNodes(j).ChildNodes(k)
Line 172: Select Case objParamPropertyNode.LocalName
Line 173: Case ParameterNameElement
Line 174: objParam.Name = objParamPropertyNode.InnerText
Line 175: Case ParameterTypeElement
Line 176: objParam.Type = IFrameParameter.ParseType(objParamPropertyNode.InnerText)
Line 177: Case ParameterArgumentElement
Line 178: objParam.TypeArgument = objParamPropertyNode.InnerText
Line 179: End Select
Line 180: Next
Line 181:
Line 182: ' add param
Line 183: If objParam.IsValid Then AddParameter(objParam)
Line 184: Next
Line 185: End If
Line 186: Next
Line 187:
Line 188: End Sub
Line 189:
Line 190: #End Region
Line 191:
Line 192:
Line 193: #Region "| Data Access |"
Line 194:
Line 195: ''' <summary>
Line 196: ''' Gets the single instance of the current <see cref="DataProvider"/>.
Line 197: ''' </summary>
Line 198: Protected ReadOnly Property DataProvider() As DataProvider
Line 199: Get
Line 200: If Me._dataProvider Is Nothing Then
Line 201: Me._dataProvider = DataProvider.Instance
Line 202: End If
Line 203: Return Me._dataProvider
Line 204: End Get
Line 205: End Property
Line 206:
Line 207:
Line 208: ''' <summary>
Line 209: ''' Creates a new object in the data store.
Line 210: ''' </summary>
Line 211: ''' <param name="Parameter">Parameter object.</param>
Line 212: Public Sub AddParameter(ByVal Parameter As IFrameParameter)
Line 213: DataProvider.AddParameter(Parameter)
Line 214: End Sub
Line 215:
Line 216:
Line 217: ''' <summary>
Line 218: ''' Retrieves an existing object from the data store.
Line 219: ''' </summary>
Line 220: ''' <param name="Key">Parameter identifier.</param>
Line 221: Public Function GetParameter(ByVal Key As IFrameParameter.UniqueKey) As IFrameParameter
Line 222: Return DataProvider.GetParameter(Key)
Line 223: End Function
Line 224:
Line 225:
Line 226: ''' <summary>
Line 227: ''' Retrieves a collection of objects from the data store.
Line 228: ''' </summary>
Line 229: ''' <param name="ModuleID">Module identifier.</param>
Line 230: Public Function GetParameters(ByVal ModuleID As Integer) As IFrameParameterCollection
Line 231: Return DataProvider.GetParameters(ModuleID)
Line 232: End Function
Line 233:
Line 234:
Line 235: ''' <summary>
Line 236: ''' Updates an existing object in the data store.
Line 237: ''' </summary>
Line 238: ''' <param name="Parameter">Parameter object.</param>
Line 239: Public Sub UpdateParameter(ByVal Parameter As IFrameParameter)
Line 240: DataProvider.UpdateParameter(Parameter)
Line 241: End Sub
Line 242:
Line 243:
Line 244: ''' <summary>
Line 245: ''' Removes an existing object from the data store.
Line 246: ''' </summary>
Line 247: ''' <param name="Key">Parameter identifier.</param>
Line 248: Public Sub DeleteParameter(ByVal Key As IFrameParameter.UniqueKey)
Line 249: DataProvider.DeleteParameter(Key)
Line 250: End Sub
Line 251:
Line 252: #End Region
Line 253: End Class
Line 254: End Namespace
|