forked from 2sic/2sxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
View.ascx.cs
83 lines (74 loc) · 3.29 KB
/
View.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
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using ToSic.SexyContent.GettingStarted;
namespace ToSic.SexyContent
{
public partial class View : SexyViewContentOrApp, IActionable
{
/// <summary>
/// Page Load event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
// Reset messages visible states
pnlMessage.Visible = false;
pnlError.Visible = false;
base.Page_Load(sender, e);
}
/// <summary>
/// Process View if a Template has been set
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_PreRender(object sender, EventArgs e)
{
try
{
var isSharedModule = ModuleConfiguration.PortalID != ModuleConfiguration.OwnerPortalID;
if (!isSharedModule)
{
var noTemplatesYet = !Sexy.GetVisibleTemplates(PortalId).Any();
// If there are no templates configured - show "getting started" frame
if (noTemplatesYet && IsEditable && UserInfo.IsInRole(PortalSettings.AdministratorRoleName))
{
pnlGetStarted.Visible = true;
var gettingStartedControl = (GettingStartedFrame)LoadControl("~/DesktopModules/ToSIC_SexyContent/SexyContent/GettingStarted/GettingStartedFrame.ascx");
gettingStartedControl.ModuleID = this.ModuleId;
gettingStartedControl.ModuleConfiguration = this.ModuleConfiguration;
pnlGetStarted.Controls.Add(gettingStartedControl);
}
if (UserMayEditThisModule)
pnlTemplateChooser.Visible = true;
if (AppId.HasValue && !Sexy.PortalIsConfigured(Server, ControlPath))
Sexy.ConfigurePortal(Server);
}
if (AppId.HasValue)
{
if (Items.Any() && Template != null)
ProcessView(phOutput, pnlError, pnlMessage);
else if(!IsContentApp && UserMayEditThisModule) // Select first available template automatically if it's not set yet - then refresh page
{
var templates = Sexy.GetAvailableTemplatesForSelector(ModuleConfiguration).ToList();
if (templates.Any())
SexyUncached.UpdateTemplateForGroup(Sexy.GetContentGroupIdFromModule(ModuleConfiguration.ModuleID), templates.First().TemplateID, UserInfo.UserID);
Response.Redirect(Request.RawUrl);
}
}
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
}
}