forked from DNNCommunity/DNN.Blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocalizedTextEdit.vb
193 lines (168 loc) · 5.68 KB
/
LocalizedTextEdit.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
'
' DNN Connect - http://dnn-connect.org
' Copyright (c) 2015
' by DNN Connect
'
' 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 DotNetNuke.Services.Localization
Imports DotNetNuke.Entities.Portals
Namespace Controls
Public MustInherit Class LocalizedTextEdit
Inherits System.Web.UI.WebControls.Panel
#Region " Private Members "
Private _localizedTexts As LocalizedText = Nothing
Friend pnlBox As System.Web.UI.WebControls.Panel
Private _defaultText As String = String.Empty
Private _supportedLocales As LocaleCollection = Nothing
Private _DefaultLanguage As String = Nothing
#End Region
#Region " Protected Methods "
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
If Not _PreRendered AndAlso (RebindOnPostback Or (Not Page.IsPostBack)) Then
DataBind()
End If
_PreRendered = True
End Sub
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
If Not _PreRendered AndAlso (RebindOnPostback Or (Not Page.IsPostBack)) Then
DataBind()
End If
_PreRendered = True
MyBase.Render(writer)
End Sub
Public Overrides Sub DataBind()
EnsureChildControls()
If Page.IsPostBack And (Not ManualUpdate) Then
Update()
End If
Rebind()
End Sub
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
_localizedTexts = New LocalizedText
If Not (savedState Is Nothing) Then
Dim myState As Object() = CType(savedState, Object())
If Not (myState(0) Is Nothing) Then
DefaultText = CStr(myState(0))
End If
If Not (myState(1) Is Nothing) Then
_localizedTexts.Deserialize(CStr(myState(1)))
End If
If Not (myState(2) Is Nothing) Then
MyBase.LoadViewState(myState(2))
End If
End If
End Sub
Protected Overrides Function SaveViewState() As Object
EnsureChildControls()
If Not ManualUpdate Then
Update()
End If
Dim allStates(2) As Object
allStates(0) = DefaultText
If _localizedTexts Is Nothing Then
allStates(1) = Nothing
Else
allStates(1) = _localizedTexts.ToString
End If
allStates(2) = MyBase.SaveViewState()
Return allStates
End Function
#End Region
#Region " Events "
Private Sub LocalizedTextEdit_Load(sender As Object, e As EventArgs) Handles Me.Load
EnsureChildControls()
End Sub
#End Region
#Region " Public Methods "
Public MustOverride Sub Update()
Public MustOverride Sub Rebind()
Public Function GetLocalizedTexts() As LocalizedText
If Not ManualUpdate Then
Update()
End If
Return LocalizedTexts
End Function
Public Sub InitialBind()
Dim mu As Boolean = ManualUpdate
ManualUpdate = True
DataBind()
ManualUpdate = mu
End Sub
#End Region
#Region " Properties "
Public Property TextBoxWidth As Unit = Unit.Pixel(0)
Public Property TextBoxHeight As Unit = Unit.Pixel(0)
Public Property MaxImage As String = "~/images/max.gif"
Public Property MinImage As String = "~/images/min.gif"
Public Property StartMaximized As Boolean = False
Public Property UseFlags As Boolean = True
Public Property RebindOnPostback As Boolean = True
Public Property ManualUpdate As Boolean = False
Public Property PreRendered As Boolean = False
Public Property JustUpdated As Boolean = False
Public Property CssPrefix As String = ""
Public Property ShowTranslations As Boolean = True
Public Property LocalizedTexts() As LocalizedText
Get
If _localizedTexts Is Nothing Then
_localizedTexts = New LocalizedText()
End If
Return _localizedTexts
End Get
Set(ByVal value As LocalizedText)
_localizedTexts = value
End Set
End Property
Public Property DefaultText() As String
Get
If Not ManualUpdate Then
Update()
End If
Return _defaultText
End Get
Set(ByVal value As String)
_defaultText = value
End Set
End Property
Public Property SupportedLocales() As LocaleCollection
Get
If _supportedLocales Is Nothing Then
_supportedLocales = New LocaleCollection
Dim objPortalSettings As PortalSettings = PortalController.Instance.GetCurrentPortalSettings()
For Each kvp As KeyValuePair(Of String, Locale) In LocaleController.Instance.GetLocales(objPortalSettings.PortalId)
_supportedLocales.Add(kvp.Key, kvp.Value)
Next
End If
Return _supportedLocales
End Get
Set(ByVal value As LocaleCollection)
_supportedLocales = value
End Set
End Property
Public Property DefaultLanguage() As String
Get
If _DefaultLanguage Is Nothing Then
_DefaultLanguage = DotNetNuke.Entities.Portals.PortalController.Instance.GetCurrentPortalSettings.DefaultLanguage
End If
Return _DefaultLanguage
End Get
Set(ByVal value As String)
_DefaultLanguage = value
End Set
End Property
#End Region
End Class
End Namespace