/
Resource_FeaturedImage.ascx.cs
380 lines (277 loc) · 11.6 KB
/
Resource_FeaturedImage.ascx.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Services.Localization;
using DotNetNuke.Entities.Users;
namespace DNNGo.Modules.DNNGalleryPro
{
public partial class Resource_FeaturedImage : BaseModule
{
#region "属性"
/// <summary>
/// 提示操作类
/// </summary>
MessageTips mTips = new MessageTips();
/// <summary>
/// 当前页码
/// </summary>
public Int32 PageIndex = WebHelper.GetIntParam(HttpContext.Current.Request, "PageIndex", 1);
/// <summary>
/// 文章状态
/// </summary>
public Int32 ArticleStatus = WebHelper.GetIntParam(HttpContext.Current.Request, "Status", -1);
/// <summary>
/// 插入状态
/// </summary>
public Boolean InsertType = Convert.ToBoolean( WebHelper.GetStringParam(HttpContext.Current.Request, "Insert", "false"));
/// <summary>
/// 文件类型(调用页面的JS)
/// </summary>
public String File_Type = WebHelper.GetStringParam(HttpContext.Current.Request, "FileType", "");
/// <summary>
/// 文章搜索_标题
/// </summary>
public String Search_Title = WebHelper.GetStringParam(HttpContext.Current.Request, "SearchText", "");
/// <summary>
/// 总页码数
/// </summary>
public Int32 RecordPages
{
get;
set;
}
/// <summary>
/// 当前页面URL(不包含分页)
/// </summary>
public String CurrentUrl
{
get
{
List<String> urls = new List<String>();
if (ArticleStatus >= 0)
{
urls.Add(String.Format("Status={0}", ArticleStatus));
}
if (!String.IsNullOrEmpty(Orderfld))
{
urls.Add(String.Format("sort_f={0}", Orderfld));
}
if (OrderType > 0)
{
urls.Add(String.Format("sort_t={0}", OrderType));
}
if (!String.IsNullOrEmpty(Search_Title))
{
urls.Add(String.Format("SearchText={0}", Search_Title));
}
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.AppendFormat("{0}?PortalId={1}&TabId={2}&ModuleId={3}&language={4}&Insert={5}&FileType={6}", "Resource_FeaturedImage.aspx", PortalId, TabId, ModuleId, language, InsertType, File_Type);
foreach (String parameter in urls)
{
sb.AppendFormat("&{0}", parameter);
}
return sb.ToString(); ;
}
}
/// <summary>
/// 排序字段
/// </summary>
public string Orderfld = WebHelper.GetStringParam(HttpContext.Current.Request, "sort_f", "");
/// <summary>
/// 排序类型 1:降序 0:升序
/// </summary>
public int OrderType = WebHelper.GetIntParam(HttpContext.Current.Request, "sort_t", 1);
#endregion
#region "方法"
/// <summary>
/// 绑定列表
/// </summary>
private void BindDataList()
{
QueryParam qp = new QueryParam();
qp.OrderType = OrderType;
if (!String.IsNullOrEmpty(Orderfld))
{
qp.Orderfld = Orderfld;
}
else
{
qp.Orderfld = DNNGo_DNNGalleryPro_Files._.ID;
}
#region "分页的一系列代码"
int RecordCount = 0;
int pagesize = qp.PageSize = 10;
qp.PageIndex = PageIndex;
#endregion
//查询的方法
qp.Where = BindSearch();
List<DNNGo_DNNGalleryPro_Files> Articles = DNNGo_DNNGalleryPro_Files.FindAll(qp, out RecordCount);
qp.RecordCount = RecordCount;
RecordPages = qp.Pages;
lblRecordCount.Text = String.Format("{0} {2} / {1} {3}", RecordCount, RecordPages, ViewResourceText("Title_Items", "Items"), ViewResourceText("Title_Pages", "Pages"));
//ctlPagingControl.TotalRecords = RecordCount;
//if (RecordCount <= pagesize)
//{
// ctlPagingControl.Visible = false;
//}
gvArticleList.DataSource = Articles;
gvArticleList.DataBind();
BindGridViewEmpty<DNNGo_DNNGalleryPro_Files>(gvArticleList, new DNNGo_DNNGalleryPro_Files());
}
/// <summary>
/// 绑定页面项
/// </summary>
private void BindPageItem()
{
}
/// <summary>
/// 绑定查询的方法
/// </summary>
private List<SearchParam> BindSearch()
{
List<SearchParam> Where = new List<SearchParam>();
Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Files._.PortalId, Settings_PortalID, SearchType.Equal));
Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Files._.FileExtension, "'jpg','jpeg','gif','png','bmp'", SearchType.In));
//筛选文章的状态
if (ArticleStatus >= 0)
{
Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Files._.Status, ArticleStatus, SearchType.Equal));
}
if (!String.IsNullOrEmpty(Search_Title))
{
txtSearch.Text = HttpUtility.UrlDecode(Search_Title);
Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Files._.Name, HttpUtility.UrlDecode(Search_Title), SearchType.Like));
}
return Where;
}
#endregion
#region "事件"
/// <summary>
/// 页面加载
/// </summary>
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
BindDataList();
BindPageItem();
}
}
catch (Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
}
}
/// <summary>
/// 列表行创建
/// </summary>
protected void gvArticleList_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
foreach (TableCell var in e.Row.Cells)
{
if (var.Controls.Count > 0 && var.Controls[0] is LinkButton)
{
string Colume = ((LinkButton)var.Controls[0]).CommandArgument;
if (Colume == Orderfld)
{
LinkButton l = (LinkButton)var.Controls[0];
l.Text += string.Format("<i class=\"fa {0}{1}\"></i>", Orderfld == "Title" ? "fa-sort-alpha-" : "fa-sort-amount-", (OrderType == 0) ? "asc" : "desc");
}
}
}
}
}
/// <summary>
/// 列表行绑定
/// </summary>
protected void gvArticleList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//还原出数据
DNNGo_DNNGalleryPro_Files Media = e.Row.DataItem as DNNGo_DNNGalleryPro_Files;
if (Media != null && Media.ID > 0)
{
Label lblFileExtension = e.Row.FindControl("lblFileExtension") as Label;
lblFileExtension.Text = Media.FileExtension;
Image imgFileName = e.Row.FindControl("imgFileName") as Image;
HyperLink hlFileName = e.Row.FindControl("hlFileName") as HyperLink;
hlFileName.Text = Media.FileName.Replace("." + Media.FileExtension, "");
imgFileName.ImageUrl = GetPhotoExtension(Media.FileExtension, Media.FilePath);
hlFileName.NavigateUrl = GetPhotoPath(Media.FilePath);
HyperLink hlAdditional = e.Row.FindControl("hlAdditional") as HyperLink;
switch (File_Type.ToLower())
{
case "media": hlAdditional.Attributes.Add("onclick", String.Format("ReturnHtmlPicture('{0}','MediaID={1}');", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID)); ; break;
case "thumbnail": hlAdditional.Attributes.Add("onclick", String.Format("ReturnThumbnail('{0}','MediaID={1}');", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID)); break;
case "urllink": hlAdditional.Attributes.Add("onclick", String.Format("ReturnUrlLink('{0}','MediaID={1}');", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID)); break;
default: hlAdditional.Attributes.Add("onclick", String.Format("Return{2}('{0}','MediaID={1}');", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID, File_Type)); break;
}
//if (InsertType)
//{
// //插入到文章内容
// hlAdditional.Attributes.Add("onclick", String.Format("ReturnHtmlPicture('{0}',{1});", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID));
//}
//else
//{
// hlAdditional.Attributes.Add("onclick", String.Format("ReturnPicture('{0}',{1});", GetPhotoExtension(Media.FileExtension, Media.FilePath), Media.ID));
//}
//发布者信息
e.Row.Cells[1].Text = "--";
if (Media.LastUser > 0)
{
UserInfo uInfo = UserController.GetUserById(PortalId, Media.LastUser);
if (uInfo != null && uInfo.UserID > 0) e.Row.Cells[1].Text = String.Format("{0}<br />{1}", uInfo.Username, uInfo.DisplayName);
}
//发布时间
e.Row.Cells[2].Text = Media.LastTime.ToShortDateString();
//状态
e.Row.Cells[3].Text = EnumHelper.GetEnumTextVal(Media.Status, typeof(EnumFileStatus));
}
}
}
/// <summary>
/// 列表排序
/// </summary>
protected void gvArticleList_Sorting(object sender, GridViewSortEventArgs e)
{
if (Orderfld == e.SortExpression)
{
if (OrderType == 0)
{
OrderType = 1;
}
else
{
OrderType = 0;
}
}
Orderfld = e.SortExpression;
//BindDataList();
Response.Redirect(CurrentUrl);
}
/// <summary>
/// 搜索按钮事件
/// </summary>
protected void btnSearch_Click(object sender, EventArgs e)
{
try
{
Search_Title = HttpUtility.UrlEncode(txtSearch.Text.Trim());
Response.Redirect(CurrentUrl);
}
catch (Exception ex)
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
}
}
#endregion
}
}