public void AddItem([FromUri] int?sortOrder = null) { var contentGroupId = Sexy.GetContentGroupIdFromModule(ActiveModule.ModuleID); var templateId = Sexy.GetTemplateForModule(ActiveModule.ModuleID).TemplateID; SexyUncached.AddContentGroupItem(contentGroupId, UserInfo.UserID, templateId, null, sortOrder.HasValue ? sortOrder.Value + 1 : sortOrder, true, ContentGroupItemType.Content, false); }
protected void Page_Load(object sender, EventArgs e) { ServicesFramework.Instance.RequestAjaxAntiForgerySupport(); try { // If logged in, inject Edit JavaScript, and delete / add items if (UserMayEditThisModule) { ClientScriptManager ClientScript = Page.ClientScript; // ToDo: Move these RegisterScripts to JS to prevent including AngularJS twice (from other modules) ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/Js/AngularJS/angular.min.js", 80); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/Js/2sxc.TemplateSelector.js", 81); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/Js/2sxc.ApiService.js", 82); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/Js/ViewEdit.js", 82); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/Js/2sxc.DnnActionMenuMapper.js", 83); var hasContent = AppId.HasValue && Template != null && Items.Any(p => p.EntityID.HasValue); var templateChooserVisible = Settings.ContainsKey(SexyContent.SettingsShowTemplateChooser) ? Boolean.Parse(Settings[SexyContent.SettingsShowTemplateChooser].ToString()) : !hasContent; ((DotNetNuke.UI.Modules.ModuleHost) this.Parent).Attributes.Add("data-2sxc", Newtonsoft.Json.JsonConvert.SerializeObject(new { moduleId = ModuleId, manage = new { isEditMode = UserMayEditThisModule, templateChooserVisible = templateChooserVisible, hasContent = hasContent, isContentApp = IsContentApp, appId = AppId, isList = AppId.HasValue && Items.Count > 1, templateId = Template != null ? Template.TemplateID : new int?(), contentTypeId = Template != null ? Template.AttributeSetID : 0, config = new { portalId = PortalId, tabId = TabId, moduleId = ModuleId, contentGroupId = AppId.HasValue ? Sexy.GetContentGroupIdFromModule(ModuleId) : 0, dialogUrl = DotNetNuke.Common.Globals.NavigateURL(this.TabId), returnUrl = Request.RawUrl, appPath = AppId.HasValue ? Sexy.App.Path : null, cultureDimension = AppId.HasValue ? Sexy.GetCurrentLanguageID() : new int?(), isList = Template != null && Template.UseForList } } })); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/Js/2sxc.api.js", 90); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/Js/2sxc.api.manage.js", 91); } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
/// <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); } }
public void SetAppId(int?appId) { // Reset template to nothing (prevents errors after changing app) SexyUncached.UpdateTemplateForGroup(Sexy.GetContentGroupIdFromModule(ActiveModule.ModuleID), null, UserInfo.UserID); SexyContent.SetAppIdForModule(ActiveModule, appId); // Change to 1. template if app has been set if (appId.HasValue) { var sexyForNewApp = new SexyContent(Sexy.App.ZoneId, appId.Value, false); var templates = sexyForNewApp.GetAvailableTemplatesForSelector(ActiveModule).ToList(); if (templates.Any()) { SexyUncached.UpdateTemplateForGroup(Sexy.GetContentGroupIdFromModule(ActiveModule.ModuleID), templates.First().TemplateID, UserInfo.UserID); } else { SexyUncached.UpdateTemplateForGroup(Sexy.GetContentGroupIdFromModule(ActiveModule.ModuleID), null, UserInfo.UserID); } } }
public void SaveTemplateId([FromUri] int?templateId) { SexyUncached.UpdateTemplateForGroup(Sexy.GetContentGroupIdFromModule(ActiveModule.ModuleID), templateId, UserInfo.UserID); }