-
Notifications
You must be signed in to change notification settings - Fork 8
/
GalleryPage.aspx.cs
226 lines (202 loc) · 6.34 KB
/
GalleryPage.aspx.cs
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
using DotNetNuke;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities;
using DotNetNuke.Framework;
using DotNetNuke.Security;
using DotNetNuke.Services;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.Profile;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DotNetNuke.Entities.Users;
namespace DotNetNuke.Modules.Gallery
{
// Class from which all gallery pop-up pages (Viewer.aspx, Slideshow.aspx, FlashPlayer.aspx,
// MediaPlayer.aspx, ExifMetaData.aspx inherit.
public partial class GalleryPageBase : DotNetNuke.Framework.PageBase
{
private DotNetNuke.Modules.Gallery.Config _GalleryConfig;
private DotNetNuke.Modules.Gallery.Authorization _GalleryAuthorization;
private DotNetNuke.Modules.Gallery.BaseRequest _CurrentRequest;
private int _TabId = -1;
private int _ModuleId = -1;
private string _Ctl = "";
private string _localResourceFile = "";
public Gallery.Config GalleryConfig {
get {
if (_GalleryConfig == null) {
_GalleryConfig = Config.GetGalleryConfig(ModuleId);
}
return _GalleryConfig;
}
}
public Gallery.Authorization GalleryAuthorization {
get {
if (_GalleryAuthorization == null) {
_GalleryAuthorization = new Gallery.Authorization(ModuleId);
}
return _GalleryAuthorization;
}
}
public BaseRequest CurrentRequest {
get { return _CurrentRequest; }
set { _CurrentRequest = value; }
}
public int PortalId {
get { return PortalSettings.PortalId; }
}
public string Ctl {
get { return _Ctl; }
}
public int TabId {
get { return _TabId; }
}
public int ModuleId {
get { return _ModuleId; }
}
public UserInfo UserInfo {
get { return UserController.GetCurrentUserInfo(); }
}
public int UserId {
get {
int functionReturnValue = 0;
if (HttpContext.Current.Request.IsAuthenticated) {
functionReturnValue = UserInfo.UserID;
} else {
functionReturnValue = -1;
}
return functionReturnValue;
}
}
public new string LocalResourceFile {
get {
if (string.IsNullOrEmpty(_localResourceFile)) {
//Hack to adjust for legacy use of 'exif' rather than 'exifmetadata' as ControlKey for
//ExifMetaData.ascx in module definitions
string ctlName = null;
if (_Ctl.ToLower() == "exif") {
ctlName = "ExifMetaData";
} else {
ctlName = _Ctl;
}
_localResourceFile = this.TemplateSourceDirectory + "/" + DotNetNuke.Services.Localization.Localization.LocalResourceDirectory + "/" + ctlName + ".ascx.resx";
}
return _localResourceFile;
}
set { _localResourceFile = value; }
}
public string ControlTitle {
get { return lblTitle.Text; }
set { lblTitle.Text = value; }
}
public void AddStyleSheet(string id, string href, bool isFirst)
{
//Find the placeholder control
Control objCSS = this.Header.FindControl("CSS");
if ((objCSS != null)) {
//First see if we have already added the <LINK> control
Control objCtrl = Page.Header.FindControl(id);
if (objCtrl == null) {
HtmlLink objLink = new HtmlLink();
objLink.ID = id;
objLink.Attributes["rel"] = "stylesheet";
objLink.Attributes["type"] = "text/css";
objLink.Href = href;
if (isFirst) {
//Find the first HtmlLink
int iLink = 0;
for (iLink = 0; iLink <= objCSS.Controls.Count - 1; iLink++) {
if (objCSS.Controls[iLink] is HtmlLink) {
break; // TODO: might not be correct. Was : Exit For
}
}
objCSS.Controls.AddAt(iLink, objLink);
} else {
objCSS.Controls.Add(objLink);
}
}
}
}
private void Page_Load(object sender, System.EventArgs e)
{
if ((Request.QueryString["mid"] != null)) {
_ModuleId = int.Parse(Request.QueryString["mid"]);
}
if ((Request.QueryString["tabid"] != null)) {
_TabId = int.Parse(Request.QueryString["tabid"]);
if (_TabId != PortalSettings.ActiveTab.TabID) {
Response.Redirect(Common.Globals.AccessDeniedURL(), true);
}
} else {
_TabId = PortalSettings.ActiveTab.TabID;
}
Entities.Modules.ModuleController modController = new Entities.Modules.ModuleController();
System.Collections.Generic.Dictionary<int, Entities.Modules.ModuleInfo> modDictionary = null;
modDictionary = modController.GetTabModules(_TabId);
if (!modDictionary.ContainsKey(ModuleId) || !(modDictionary[_ModuleId].DesktopModule.ModuleName == "DNN_Gallery")) {
Response.Redirect(Common.Globals.AccessDeniedURL(), true);
}
if ((Request.QueryString["ctl"] != null)) {
_Ctl = Request.QueryString["ctl"];
}
if (GalleryAuthorization.HasViewPermission()) {
AddStyleSheet(GalleryConfig.Theme + "_stylesheet", GalleryConfig.Css, true);
string ctlFileName = "";
switch (_Ctl.ToLower()) {
case "viewer":
ctlFileName = "ControlViewer.ascx";
break;
case "slideshow":
ctlFileName = "ControlSlideshow.ascx";
break;
case "flashplayer":
ctlFileName = "ControlFlashPlayer.ascx";
break;
case "mediaplayer":
ctlFileName = "ControlMediaPlayer.ascx";
break;
case "exif":
ctlFileName = "ControlExif.ascx";
break;
default:
Response.Redirect(Common.Globals.AccessDeniedURL(), true);
break;
}
System.Web.UI.Control ctlToLoad = LoadControl("Controls/" + ctlFileName);
if ((ctlToLoad != null)) {
ctlToLoad.ID = "ctl" + _Ctl;
phControl.Controls.Add(ctlToLoad);
if (_Ctl.ToLower() == "viewer" && GalleryAuthorization.HasEditPermission()) {
Title = Localization.GetString("ControlTitle_editor", LocalResourceFile);
} else {
Title = Localization.GetString("ControlTitle_" + _Ctl.ToLower(), LocalResourceFile);
}
btnClose.Text = Localization.GetString("btnClose", GalleryConfig.SharedResourceFile);
}
} else {
Response.Redirect(Common.Globals.AccessDeniedURL(), true);
}
}
public GalleryPageBase()
{
Load += Page_Load;
}
}
}