forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChannelTree.cs
More file actions
70 lines (62 loc) · 3.03 KB
/
ChannelTree.cs
File metadata and controls
70 lines (62 loc) · 3.03 KB
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
using System.Collections.Specialized;
using System.Text;
using System.Web.UI;
using SiteServer.BackgroundPages.Core;
using SiteServer.CMS.Core;
using SiteServer.CMS.Model;
using SiteServer.CMS.Model.Enumerations;
using SiteServer.CMS.Plugin;
using SiteServer.Utils;
using SiteServer.Utils.Enumerations;
namespace SiteServer.BackgroundPages.Controls
{
public class ChannelTree : Control
{
protected override void Render(HtmlTextWriter writer)
{
var builder = new StringBuilder();
var request = new AuthRequest();
var siteId = TranslateUtils.ToInt(Page.Request.QueryString["siteId"]);
var contentModelPluginId = Page.Request.QueryString["contentModelPluginId"];
var linkUrl = Page.Request.QueryString["linkUrl"];
var additional = new NameValueCollection();
if (!string.IsNullOrEmpty(linkUrl))
{
additional["linkUrl"] = linkUrl;
}
if (siteId > 0)
{
var siteInfo = SiteManager.GetSiteInfo(siteId);
if (siteInfo != null)
{
var scripts = ChannelLoading.GetScript(siteInfo, contentModelPluginId, ELoadingType.ContentTree, additional);
builder.Append(scripts);
var channelIdList = ChannelManager.GetChannelIdList(ChannelManager.GetChannelInfo(siteInfo.Id, siteInfo.Id), EScopeType.SelfAndChildren, string.Empty, string.Empty, string.Empty);
foreach (var channelId in channelIdList)
{
var channelInfo = ChannelManager.GetChannelInfo(siteInfo.Id, channelId);
var enabled = request.AdminPermissions.IsOwningChannelId(channelInfo.Id);
if (!string.IsNullOrEmpty(contentModelPluginId) &&
!StringUtils.EqualsIgnoreCase(channelInfo.ContentModelPluginId, contentModelPluginId))
{
enabled = false;
}
if (!enabled)
{
if (!request.AdminPermissions.IsDescendantOwningChannelId(channelInfo.SiteId, channelInfo.Id)) continue;
if (!IsDesendantContentModelPluginIdExists(channelInfo, contentModelPluginId)) continue;
}
builder.Append(ChannelLoading.GetChannelRowHtml(siteInfo, channelInfo, enabled, ELoadingType.ContentTree, additional, request.AdminPermissions));
}
}
}
writer.Write(builder);
}
private bool IsDesendantContentModelPluginIdExists(ChannelInfo channelInfo, string contentModelPluginId)
{
if (string.IsNullOrEmpty(contentModelPluginId)) return true;
var channelIdList = ChannelManager.GetChannelIdList(channelInfo, EScopeType.Descendant, string.Empty, string.Empty, contentModelPluginId);
return channelIdList.Count > 0;
}
}
}