This repository has been archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
View.ascx.vb
170 lines (134 loc) · 6.45 KB
/
View.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
Imports DotNetNuke
Imports DotNetNuke.Services.Localization
Namespace DNNStuff.Favorites
Partial Class View
Inherits Entities.Modules.PortalModuleBase
Implements Entities.Modules.IActionable
Private _favSettings As FavoritesSettings
Private ReadOnly Property FavSettings As FavoritesSettings
Get
If _favSettings Is Nothing Then
_favSettings = New FavoritesSettings(ModuleId)
End If
Return _favSettings
End Get
End Property
#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
#Region " Menu Actions"
Public ReadOnly Property ModuleActions() As Entities.Modules.Actions.ModuleActionCollection _
Implements Entities.Modules.IActionable.ModuleActions
Get
Dim menuActions As New Entities.Modules.Actions.ModuleActionCollection
menuActions.Add(GetNextActionID, Localization.GetString(Common.ViewOptions, LocalResourceFile),
Entities.Modules.Actions.ModuleActionType.ContentOptions, "", "",
EditUrl(Common.ViewOptions), False, Security.SecurityAccessLevel.Edit, True, False)
Return menuActions
End Get
End Property
#End Region
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If HttpContext.Current.User.Identity.IsAuthenticated Then
BindFavs()
Else
DisplayUnathenticatedMessage()
End If
End Sub
Private Sub RefreshPage()
Response.Redirect(Request.Url.ToString)
End Sub
Private Sub BindFavs()
Dim favs As ArrayList = FavoritesController.GetFavorites(UserId, PortalId)
dlUrls.DataSource = favs
dlUrls.DataBind()
If favs.Count = 0 Then
DisplayEmptyMessage()
End If
End Sub
Private Sub DisplayUnathenticatedMessage()
phText.Controls.Add(New LiteralControl(FavSettings.Unauthenticated))
End Sub
Private Sub DisplayEmptyMessage()
phText.Controls.Add(New LiteralControl(FavSettings.Empty))
End Sub
Private Function ReplaceFavoriteTokens(ByVal text As String, ByVal tokens As Hashtable) As String
' do generic replacements
text = TokenReplacement.ReplaceGenericTokens(Me, text)
' do favorite specific replacements
Dim replacer As New DNNStuff.Utilities.RegularExpression.TokenReplacement(tokens)
replacer.ReplaceIfNotFound = False
Return replacer.Replace(text)
End Function
#Region " Data Presentation"
Private Sub dlUrls_ItemCommand(ByVal source As Object,
ByVal e As RepeaterCommandEventArgs) _
Handles dlUrls.ItemCommand
If e.CommandName = "Delete" Then
FavoritesController.DeleteFavorite(Int32.Parse(e.CommandArgument.ToString))
RefreshPage()
End If
End Sub
Private Sub dlUrls_ItemDataBound(ByVal sender As Object,
ByVal e As RepeaterItemEventArgs) _
Handles dlUrls.ItemDataBound
' create tokens
Dim tokens As Hashtable = StandardTokenList()
' header
If e.Item.ItemType = ListItemType.Header Then
e.Item.Controls.Add(ParseControl(ReplaceFavoriteTokens(FavSettings.Header, tokens)))
End If
' footer
If e.Item.ItemType = ListItemType.Footer Then
e.Item.Controls.Add(ParseControl(ReplaceFavoriteTokens(FavSettings.Footer, tokens)))
End If
' favorite item
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim fav As FavoriteInfo = CType(e.Item.DataItem, FavoriteInfo)
Dim url As String = ""
Dim title As String = ""
Dim name As String = ""
Dim safeTitle As String = ""
If FavSettings.UseFullUrl Then
url = fav.PageUrl
title = fav.PageTitle
name = fav.PageTitle
Else
url = fav.Tab.FullUrl
title = IIf(fav.Tab.Title.Length = 0, fav.Tab.TabName, fav.Tab.Title)
name = fav.Tab.TabName
End If
safeTitle = title
If title.Length > FavSettings.MaxTitleChars Then
safeTitle = safeTitle.Substring(0, FavSettings.MaxTitleChars) & " ..."
End If
tokens.Add("TITLE", title)
tokens.Add("DESCRIPTION", fav.Tab.Description)
tokens.Add("NAME", name)
tokens.Add("URL", url)
tokens.Add("LINKNAME", String.Format("<a href='{0}' title='{1}'>{2}</a>", url, title, name))
tokens.Add("LINKTITLE", String.Format("<a href='{0}' title='{1}'>{2}</a>", url, title, safeTitle))
tokens.Add("LINK", tokens("LINKNAME"))
tokens.Add("DELETEACTION",
String.Format(
"<asp:Linkbutton ID=""btnRemoveFavorite"" Title=""Remove"" Runat=""server"" ResourceKey=""btnRemoveFavorite"" CommandName=""Delete"" CommandArgument=""{0}"" ><img border=0 align=absmiddle src='{1}'></asp:LinkButton>",
fav.FavoriteId, ResolveUrl(Localization.GetString("DeleteImage.Text", LocalResourceFile))))
e.Item.Controls.Add(ParseControl(ReplaceFavoriteTokens(FavSettings.Body, tokens)))
End If
End Sub
Private Function StandardTokenList() As Hashtable
Dim tokens As New Hashtable
tokens.Add("IMAGEURL", ResolveUrl("~/images"))
Return tokens
End Function
#End Region
End Class
End Namespace