forked from DNNCommunity/DNN.Blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Admin.ascx.vb
181 lines (156 loc) · 8.12 KB
/
Admin.ascx.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
'
' Bring2mind - http://www.bring2mind.net
' Copyright (c) 2013
' by Bring2mind
'
' 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.Modules.Blog.Entities.Blogs
Imports System.Linq
Imports DotNetNuke.Modules.Blog.Entities.Posts
Imports DotNetNuke.Web.UI.WebControls
Imports DotNetNuke.Web.Client.ClientResourceManagement
Imports DotNetNuke.Modules.Blog.Common.Globals
Public Class Admin
Inherits BlogModuleBase
Private _totalPosts As Integer = -1
Private Sub Page_Init1(sender As Object, e As System.EventArgs) Handles Me.Init
AddJavascriptFile("jquery.dynatree.min.js", 60)
AddCssFile("dynatree.css")
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not BlogContext.Security.IsEditor Then
Throw New Exception("You do not have access to this resource. Please check your login status.")
End If
If Not Me.IsPostBack Then
Me.DataBind()
End If
DotNetNuke.UI.Utilities.ClientAPI.AddButtonConfirm(cmdEditTagsML, LocalizeString("LeavePage.Confirm"))
DotNetNuke.UI.Utilities.ClientAPI.AddButtonConfirm(cmdEditCategoriesML, LocalizeString("LeavePage.Confirm"))
End Sub
Private Sub cmdEditTagsML_Click(sender As Object, e As System.EventArgs) Handles cmdEditTagsML.Click
SaveChanges()
Response.Redirect(EditUrl("TermsEditML"), False)
End Sub
Private Sub cmdEditCategoriesML_Click(sender As Object, e As System.EventArgs) Handles cmdEditCategoriesML.Click
SaveChanges()
If Settings.VocabularyId > -1 Then
Response.Redirect(EditUrl("VocabularyId", Settings.VocabularyId.ToString, "TermsEditML"), False)
End If
End Sub
Private Sub cmdCreateVocabulary_Click(sender As Object, e As System.EventArgs) Handles cmdCreateVocabulary.Click
Settings.VocabularyId = Integration.Integration.CreateNewVocabulary(PortalId).VocabularyId
Me.DataBind()
End Sub
Private Sub ddVocabularyId_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ddVocabularyId.SelectedIndexChanged
Settings.VocabularyId = ddVocabularyId.SelectedValue.ToInt
Me.DataBind()
End Sub
Private Sub cmdCancel_Click(sender As Object, e As System.EventArgs) Handles cmdCancel.Click
Response.Redirect(DotNetNuke.Common.NavigateURL(TabId), False)
End Sub
Private Sub cmdUpdateSettings_Click(sender As Object, e As System.EventArgs) Handles cmdUpdate.Click
SaveChanges()
Response.Redirect(DotNetNuke.Common.NavigateURL(TabId), False)
End Sub
Private Sub SaveChanges()
Settings.AllowAttachments = chkAllowAttachments.Checked
Settings.SummaryModel = CType(ddSummaryModel.SelectedValue.ToInt, SummaryType)
Settings.AllowMultipleCategories = chkAllowMultipleCategories.Checked
Settings.AllowWLW = chkAllowWLW.Checked
Settings.WLWRecentPostsMax = txtWLWRecentPostsMax.Text.ToInt
Settings.VocabularyId = ddVocabularyId.SelectedValue.ToInt
Settings.ModifyPageDetails = chkModifyPageDetails.Checked
Settings.AutoGenerateMissingSummary = chkAutoGenerateMissingSummary.Checked
Settings.AutoGeneratedSummaryLength = Integer.Parse(txtAutoGeneratedSummaryLength.Text.Trim)
Settings.RssAllowContentInFeed = chkRssAllowContentInFeed.Checked
Settings.RssDefaultCopyright = txtRssDefaultCopyright.Text
Settings.RssDefaultNrItems = Integer.Parse(txtRssDefaultNrItems.Text)
Settings.RssEmail = txtEmail.Text
Settings.RssImageHeight = Integer.Parse(txtRssImageHeight.Text)
Settings.RssImageWidth = Integer.Parse(txtRssImageWidth.Text)
Settings.RssImageSizeAllowOverride = chkRssImageSizeAllowOverride.Checked
Settings.RssMaxNrItems = Integer.Parse(txtRssMaxNrItems.Text)
Settings.RssTtl = Integer.Parse(txtRssTtl.Text)
Settings.UpdateSettings()
If treeState.Value <> DotNetNuke.Modules.Blog.Entities.Terms.TermsController.GetCategoryTreeAsJson(Categories) Then
Dim categoryTree As List(Of Common.DynatreeItem) = Newtonsoft.Json.JsonConvert.DeserializeObject(Of List(Of Common.DynatreeItem))(treeState.Value)
Dim ReturnedIds As New List(Of Integer)
Dim i As Integer = 1
For Each rootNode As Common.DynatreeItem In categoryTree
AddOrUpdateCategory(-1, i, rootNode, ReturnedIds)
i += 1
Next
Dim deleteCategories As New List(Of Entities.Terms.TermInfo)
For Each t As Entities.Terms.TermInfo In Categories.Values
If Not ReturnedIds.Contains(t.TermId) Then deleteCategories.Add(t)
Next
For Each categoryToDelete As Entities.Terms.TermInfo In deleteCategories
DotNetNuke.Entities.Content.Common.Util.GetTermController().DeleteTerm(categoryToDelete)
Next
Categories = Entities.Terms.TermsController.GetTermsByVocabulary(ModuleId, Settings.VocabularyId, BlogContext.Locale, True) ' clear the cache
End If
End Sub
Private Sub AddOrUpdateCategory(parentId As Integer, viewOrder As Integer, category As Common.DynatreeItem, ByRef returnedIds As List(Of Integer))
If String.IsNullOrEmpty(category.title) Then Exit Sub
Dim termId As Integer = -1
If IsNumeric(category.key) Then termId = Integer.Parse(category.key)
termId = Data.DataProvider.Instance.SetTerm(termId, Settings.VocabularyId, parentId, viewOrder, category.title, "", UserId)
returnedIds.Add(termId)
Dim i As Integer = 1
For Each subCategory As Common.DynatreeItem In category.children
AddOrUpdateCategory(termId, i, subCategory, returnedIds)
i += 1
Next
End Sub
Public Overrides Sub DataBind()
MyBase.DataBind()
chkAllowAttachments.Checked = Settings.AllowAttachments
Try
ddSummaryModel.Items.FindByValue(CInt(Settings.SummaryModel).ToString).Selected = True
Catch ex As Exception
End Try
cmdEditTagsML.Enabled = BlogContext.IsMultiLingualSite
cmdEditCategoriesML.Enabled = BlogContext.IsMultiLingualSite And Settings.VocabularyId > -1
chkAllowMultipleCategories.Checked = Settings.AllowMultipleCategories
chkAllowWLW.Checked = Settings.AllowWLW
chkModifyPageDetails.Checked = Settings.ModifyPageDetails
chkAutoGenerateMissingSummary.Checked = Settings.AutoGenerateMissingSummary
txtAutoGeneratedSummaryLength.Text = Settings.AutoGeneratedSummaryLength.ToString
chkRssAllowContentInFeed.Checked = Settings.RssAllowContentInFeed
txtRssDefaultCopyright.Text = Settings.RssDefaultCopyright
txtRssDefaultNrItems.Text = Settings.RssDefaultNrItems.ToString
txtEmail.Text = Settings.RssEmail
txtRssImageHeight.Text = Settings.RssImageHeight.ToString
txtRssImageWidth.Text = Settings.RssImageWidth.ToString
chkRssImageSizeAllowOverride.Checked = Settings.RssImageSizeAllowOverride
txtRssMaxNrItems.Text = Settings.RssMaxNrItems.ToString
txtRssTtl.Text = Settings.RssTtl.ToString
txtWLWRecentPostsMax.Text = Settings.WLWRecentPostsMax.ToString
ddVocabularyId.Items.Clear()
ddVocabularyId.DataSource = Common.Globals.GetPortalVocabularies(PortalId)
ddVocabularyId.DataBind()
ddVocabularyId.Items.Insert(0, New ListItem(LocalizeString("NoneSpecified"), "-1"))
Try
ddVocabularyId.Items.FindByValue(Settings.VocabularyId.ToString).Selected = True
Catch ex As Exception
End Try
treeState.Value = DotNetNuke.Modules.Blog.Entities.Terms.TermsController.GetCategoryTreeAsJson(Categories)
If Not DotNetNuke.Services.Localization.LocaleController.Instance.GetLocales(PortalId).Count > 1 Then
cmdEditTagsML.Visible = False
cmdEditCategoriesML.Visible = False
End If
End Sub
End Class