/// <summary> /// Loads template based on UI element settings /// </summary> private void LoadTemplate() { // Init the page components manPortal.SetMainPagePlaceholder(plc); DocumentContext.CurrentPageInfo = PageInfoProvider.GetVirtualPageInfo(UIElement.ElementPageTemplateID); }
/// <summary> /// Clones template as adhoc from original node. /// </summary> /// <param name="newNode">New node which will use new adhoc template</param> private void CloneTemplateAsAdHoc(TreeNode newNode) { PageInfo originalPage = PageInfoProvider.GetPageInfo(mNode.NodeSiteName, mNode.NodeAliasPath, mNode.DocumentCulture, null, mNode.NodeID, false); if (originalPage == null) { return; } PageTemplateInfo originalTemplate = originalPage.UsedPageTemplateInfo; // If template is not adhoc or is inherited, create adhoc from original node template if ((originalTemplate != null) && (originalTemplate.IsReusable || mNode.NodeInheritPageTemplate)) { var newDisplayName = string.Format("Ad-hoc: {0} ({1})", txtDocumentName.Text.Trim(), GetString("abtesting.abvarianttemplate")); var adHocTemplate = PageTemplateInfoProvider.CloneTemplateAsAdHoc(originalTemplate, newDisplayName, SiteContext.CurrentSiteID, Guid.Empty); if (newNode.NodeTemplateForAllCultures) { newNode.NodeTemplateID = adHocTemplate.PageTemplateId; } else { newNode.DocumentPageTemplateID = adHocTemplate.PageTemplateId; } newNode.NodeInheritPageTemplate = false; } }
/// <summary> /// PreInit event handler. /// </summary> protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); // Init the page components PageManager = manPortal; manPortal.SetMainPagePlaceholder(plc); int pageTemplateId = QueryHelper.GetInteger("templateid", 0); UIContext.EditedObject = PageTemplateInfoProvider.GetPageTemplateInfo(pageTemplateId); // Prepare the page info PageInfo pi = PageInfoProvider.GetVirtualPageInfo(pageTemplateId); pi.DocumentNamePath = "/" + ResHelper.GetString("edittabs.design"); DocumentContext.CurrentPageInfo = pi; // Set the design mode PortalContext.SetRequestViewMode(ViewModeEnum.Design); ContextHelper.Add("DisplayContentInDesignMode", "0", true, false, false, DateTime.MinValue); ManagersContainer = plcManagers; ScriptManagerControl = manScript; }
private void SaveData() { if (node != null) { // Update fields node.NodeBodyElementAttributes = txtBodyCss.Text; node.NodeDocType = txtDocType.Text; node.NodeHeadTags = txtHeadTags.Value.ToString(); // Update the node node.Update(); // Update search index if (DocumentHelper.IsSearchTaskCreationAllowed(node)) { SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, TreeNode.OBJECT_TYPE, SearchFieldsConstants.ID, node.GetSearchID(), node.DocumentID); } // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree); RegisterRefreshScript(); // Empty variable for exitwithoutchanges dialog ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "SubmitAction", "CMSContentManager.changed(false);", true); // Clear cache PageInfoProvider.RemoveAllPageInfosFromCache(); ShowChangesSaved(); // Clear content changed flag DocumentManager.ClearContentChanged(); } }
/// <summary> /// Gets the inherited page template from the parent node /// </summary> /// <param name="currentNode">Document node</param> protected int GetInheritedPageTemplateId(TreeNode currentNode) { string aliasPath = currentNode.NodeAliasPath; // For root, there is no inheritance possible if (String.IsNullOrEmpty(aliasPath) || (aliasPath == "/")) { return(0); } aliasPath = TreePathUtils.GetParentPath(aliasPath); // Get the parent page info PageInfo pi = PageInfoProvider.GetPageInfo(currentNode.NodeSiteName, aliasPath, currentNode.DocumentCulture, null, currentNode.NodeParentID, true); if (pi == null) { return(0); } // Get template used by the page info pageTemplateInfo = pi.UsedPageTemplateInfo; return(pageTemplateInfo != null ? pageTemplateInfo.PageTemplateId : 0); }
private void SaveData() { if (node != null) { // Update fields node.NodeBodyElementAttributes = txtBodyCss.Text; node.NodeDocType = txtDocType.Text; node.NodeHeadTags = txtHeadTags.Value.ToString(); // Update the node node.Update(); // Update search index if ((node.PublishedVersionExists) && (SearchIndexInfoProvider.SearchEnabled)) { SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID()); } // Log synchronization DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree); RegisterRefreshScript(); // Empty variable for exitwithoutchanges dialog ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "SubmitAction", ScriptHelper.GetScript("NotChanged();")); // Clear cache PageInfoProvider.RemoveAllPageInfosFromCache(); ShowChangesSaved(); } }
/// <summary> /// Raises the <see cref="E:Init"/> event. /// </summary> protected override void OnInit(EventArgs e) { if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.contentpersonalization", "Read")) { RedirectToAccessDenied(String.Format(GetString("general.permissionresource"), "Read", "Content personalization")); } // Set the ParentObject manually tor inherited templates if (editElem.UIFormControl.ParentObject == null) { string aliasPath = QueryHelper.GetString("aliaspath", string.Empty); // Get page info for the given document PageInfo pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode, null, CMSContext.CurrentSite.CombineWithDefaultCulture); if (pi != null) { editElem.UIFormControl.ParentObject = pi.PageTemplateInfo; } } // Get information whether the control is used for a web part or zone variant variantType = VariantTypeFunctions.GetVariantTypeEnum(QueryHelper.GetString("varianttype", string.Empty)); base.OnInit(e); // Check permissions and redirect OnlineMarketingContext.CheckPermissions(variantType); // Get the alias path of the current node if (Node == null) { editElem.StopProcessing = true; } editElem.UIFormControl.OnBeforeSave += new EventHandler(UIFormControl_OnBeforeSaved); }
/// <summary> /// PreInit event handler. /// </summary> protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); // Init the page components PageManager = manPortal; manPortal.SetMainPagePlaceholder(plc); int webPartId = QueryHelper.GetInteger("webpartid", 0); wpi = WebPartInfoProvider.GetWebPartInfo(webPartId); UIContext.EditedObject = wpi; // If default configuration not available, do not display content configAvailable = wpi.HasDefaultConfiguration(); var pt = wpi.GetVirtualPageTemplate(); PageInfo pi = PageInfoProvider.GetVirtualPageInfo(pt); pi.DocumentNamePath = "/" + ResHelper.GetString("edittabs.design"); DocumentContext.CurrentPageInfo = pi; // Set the design mode PortalContext.SetRequestViewMode(ViewModeEnum.DesignWebPart); ManagersContainer = plcManagers; ScriptManagerControl = manScript; }
/// <summary> /// Fires when the page loads /// </summary> private void OnLoad(object sender, EventArgs eventArgs) { var page = (CMSPage)Control.Page; var manager = page.DocumentManager; manager.RedirectForNonExistingDocument = false; manager.Tree.CombineWithDefaultCulture = false; var node = manager.Node; if (node != null) { Node = node; ScriptHelper.RegisterScriptFile(Control.Page, "~/CMSModules/Content/CMSDesk/EditTabs.js"); // Document from different site if (node.NodeSiteID != SiteContext.CurrentSiteID) { URLHelper.Redirect(DocumentUIHelper.GetPageNotAvailable(string.Empty, false, node.DocumentName)); } showProductTab = node.HasSKU; // Initialize required variables isWireframe = node.IsWireframe(); hasWireframe = isWireframe || (node.NodeWireframeTemplateID > 0); try { var pi = PageInfoProvider.GetPageInfo(node.NodeSiteName, node.NodeAliasPath, node.DocumentCulture, node.DocumentUrlPath, false); if ((pi != null) && (pi.DesignPageTemplateInfo != null)) { var pti = pi.DesignPageTemplateInfo; showMasterPage = pti.IsPortal && ((node.NodeAliasPath == "/") || pti.ShowAsMasterTemplate); showDesign = ((pti.PageTemplateType == PageTemplateTypeEnum.Portal) || (pti.PageTemplateType == PageTemplateTypeEnum.AspxPortal)); } } catch { // Page info not found - probably tried to display document from different site } if (node.NodeClassName.EqualsCSafe("CMS.File", true)) { showDesign = false; showMasterPage = false; } DocumentUIHelper.EnsureDocumentBreadcrumbs(page.PageBreadcrumbs, node, null, null); } else if (!PortalContext.ViewMode.IsDesign(true)) { // Document does not exist -> redirect to new culture version creation dialog RedirectToNewCultureVersionPage(); } }
/// <summary> /// Gets the inherited page template from the parent node /// </summary> /// <param name="node">Document node</param> protected int GetInheritedPageTemplateId(TreeNode node) { string aliasPath = node.NodeAliasPath; // For root, there is no inheritance possible if (String.IsNullOrEmpty(aliasPath) || (aliasPath == "/")) { return(0); } aliasPath = TreePathUtils.GetParentPath(aliasPath); // Get the page info PageInfo pi = PageInfoProvider.GetPageInfo(node.NodeSiteName, aliasPath, node.DocumentCulture, node.DocumentUrlPath, node.NodeParentID, true); if (pi != null) { // Get template used by the page info pti = pi.UsedPageTemplateInfo; if (pti != null) { return(pti.PageTemplateId); } } return(0); }
/// <summary> /// Ensures dashboard initialization. /// </summary> public void SetupDashboard() { // Register placeholder for context menu ICMSPage page = Page as ICMSPage; if (page != null) { page.ContextMenuContainer = plcCtx; } if (PortalPageInstance == null) { throw new Exception("[DashboardControl.SetupDashboard] Portal page instance must be set."); } // Default settings for drag and drop for dashboard manPortal.HighlightDropableAreas = HighlightDropableAreas; manPortal.ActivateZoneBorder = ActivateZoneBorder; string dashboardName = QueryHelper.GetString("DashboardName", PersonalizationInfoProvider.UNDEFINEDDASHBOARD); // Set culture CultureInfo ci = CultureHelper.PreferredUICultureInfo; Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci; // Init the page components PortalPageInstance.PageManager = manPortal; manPortal.SetMainPagePlaceholder(plc); string templateName = QueryHelper.GetString("templatename", String.Empty); PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName); if (pti != null) { if (pti.PageTemplateType != PageTemplateTypeEnum.Dashboard) { RedirectToAccessDenied("dashboard.invalidpagetemplate"); } // Prepare virtual page info PageInfo pi = PageInfoProvider.GetVirtualPageInfo(pti.PageTemplateId); pi.DocumentNamePath = "/" + templateName; DocumentContext.CurrentPageInfo = pi; // Set the design mode PortalContext.SetRequestViewMode(ViewModeEnum.DashboardWidgets); PortalContext.DashboardName = dashboardName; PortalPageInstance.ManagersContainer = plcManagers; PortalPageInstance.ScriptManagerControl = manScript; } else { RedirectToInformation(GetString("dashboard.notemplate")); } }
/// <summary> /// Gets a list of links of tags assigned for the specific document pointing to the page with URL specified. /// </summary> /// <param name="documentGroupId">ID of the group document tags belong to</param> /// <param name="documentTags">String containing all the tags related to the document</param> /// <param name="nodeAliasPath">Node alias path</param> /// <param name="documentListPage">Path or URL of the page displaying other documents of the specified tag</param> public static string GetDocumentTags(object documentGroupId, object documentTags, object nodeAliasPath, string documentListPage) { string result = ""; string tags = ValidationHelper.GetString(documentTags, ""); if (tags.Trim() != "") { // If list page was specified make a list of links, otherwise return just list of tags bool renderLink = !string.IsNullOrEmpty(documentListPage); string listPageUrl = ""; int groupId = ValidationHelper.GetInteger(documentGroupId, 0); if (renderLink) { // If page specified by URL if (ValidationHelper.IsURL(documentListPage)) { // Resolve URL listPageUrl = URLHelper.ResolveUrl(documentListPage); } else { // Resolve path listPageUrl = CMSContext.CurrentResolver.ResolvePath(documentListPage); } // Look for group ID of document parent if not supplied if (groupId == 0) { string aliasPath = ValidationHelper.GetString(nodeAliasPath, CMSContext.CurrentPageInfo.NodeAliasPath); string strGroupId = PageInfoProvider.GetParentProperty(CMSContext.CurrentSiteID, (String.IsNullOrEmpty(aliasPath) ? CMSContext.CurrentPageInfo.NodeAliasPath : aliasPath), "DocumentTagGroupID IS NOT NULL", "DocumentTagGroupID"); groupId = ValidationHelper.GetInteger(strGroupId, 0); } } // Go through the specified tags and make a list of them string[] tagsArr = tags.Split(','); for (int i = 0; i < tagsArr.Length; i++) { tagsArr[i] = tagsArr[i].Replace("\"", "").Trim(); } Array.Sort(tagsArr); foreach (string tag in tagsArr) { if (renderLink) { result += "<a href=\"" + listPageUrl + "?tagname=" + HttpUtility.UrlPathEncode(tag) + "&groupid=" + groupId + "\">" + HTMLHelper.HTMLEncode(tag) + "</a>, "; } else { result += HTMLHelper.HTMLEncode(tag) + ","; } } result = result.Trim().TrimEnd(','); } return(result); }
protected void chkCssStyle_CheckedChanged(object sender, EventArgs e) { if (chkCssStyle.Checked) { // Set stylesheet to stylesheet selector ctrlSiteSelectStyleSheet.Enabled = false; ctrlSiteSelectStyleSheet.ButtonNewEnabled = false; string value = PageInfoProvider.GetParentProperty(SiteContext.CurrentSite.SiteID, Node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelper.GetSafeQueryString(Node.DocumentCulture, false) + "'", "DocumentStylesheetID"); if (String.IsNullOrEmpty(value)) { ctrlSiteSelectStyleSheet.Value = GetDefaultStylesheet(); } else { try { ctrlSiteSelectStyleSheet.Value = value; } catch { } } } else { ctrlSiteSelectStyleSheet.Enabled = true; ctrlSiteSelectStyleSheet.ButtonNewEnabled = true; } }
/// <summary> /// Sets the view mode. /// </summary> /// <param name="viewMode">The view mode</param> private void SetViewMode(ViewModeEnum viewMode) { if (PortalHelper.IsOnSiteEditingEnabled(SiteContext.CurrentSiteName) && AuthenticationHelper.IsAuthenticated()) { // Remove the "viewmode" param from url and redirect string returnUrl = URLHelper.RemoveParameterFromUrl(RequestContext.CurrentURL, "viewmode"); PortalContext.ViewMode = viewMode; // Switch view mode if (viewMode.IsEditLive()) { // Handle default alias path if (URLRewritingContext.CurrentPageInfoSource == PageInfoSource.DefaultAliasPath) { string aliasPath = PageInfoProvider.GetDefaultAliasPath(RequestContext.CurrentDomain, SiteContext.CurrentSiteName); if (!String.IsNullOrEmpty(aliasPath)) { string query = URLHelper.GetQuery(returnUrl); returnUrl = URLHelper.ResolveUrl(DocumentURLProvider.GetUrl(aliasPath)); returnUrl = URLHelper.AppendQuery(returnUrl, query); } } } else if (is404) { // Redirect to the root document when page not found returnUrl = ResolveUrl("~/"); } // Redirect to the URL URLHelper.Redirect(returnUrl); } }
protected void Page_Load(object sender, EventArgs e) { // Redirect to the web site root by default string returnUrl = URLHelper.ResolveUrl("~/"); // Check whether on-site editing is enabled if (PortalHelper.IsOnSiteEditingEnabled(CMSContext.CurrentSiteName)) { CurrentUserInfo cui = CMSContext.CurrentUser; // Check the permissions if ((cui != null) && cui.IsEditor && cui.IsAuthorizedPerResource("cms.content", "ExploreTree") && cui.IsAuthorizedPerResource("cms.content", "Read")) { // Set edit-live view mode PortalContext.SetViewMode(ViewModeEnum.EditLive); } else { // Redirect to access denied page when the current user does not have permissions for the OnSite editing CMSPage.RedirectToUINotAvailable(); } // Try get return URL string queryUrl = QueryHelper.GetString("returnurl", String.Empty); if (!String.IsNullOrEmpty(queryUrl) && (queryUrl.StartsWith("~/") || queryUrl.StartsWith("/"))) { // Remove return url duplication if exist int commaIndex = queryUrl.IndexOfCSafe(",", 0, false); if (commaIndex > 0) { queryUrl = queryUrl.Substring(0, commaIndex); } returnUrl = URLHelper.ResolveUrl(queryUrl); } // Use default alias path if return url isn't defined else { string aliasPath = PageInfoProvider.GetDefaultAliasPath(URLHelper.GetCurrentDomain(), CMSContext.CurrentSiteName); if (!String.IsNullOrEmpty(aliasPath)) { // Get the document which will be displayed for the default alias path TreeProvider tr = new TreeProvider(); TreeNode node = tr.SelectSingleNode(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode, true); if (node != null) { aliasPath = node.NodeAliasPath; } returnUrl = DocumentURLProvider.GetUrl(aliasPath); returnUrl = URLHelper.ResolveUrl(returnUrl); } } // Remove view mode value from query string returnUrl = URLHelper.RemoveParameterFromUrl(returnUrl, "viewmode"); } // Redirect to the requested page URLHelper.Redirect(returnUrl); }
/// <summary> /// PreInit event handler. /// </summary> protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); // Init the page components manPortal.SetMainPagePlaceholder(plc); var ui = UIElementInfo.Provider.Get(QueryHelper.GetInteger("elementid", 0)); // Clear UIContext data of element "Modules.UserInterface.Design" (put by UIElement attribute to check permissions) var ctx = pnlContext.UIContext; ctx.Data = null; ctx.HideControlOnError = false; if (ui != null) { ctx.UIElement = ui; // Store resource name ctx.ResourceName = ApplicationUrlHelper.GetResourceName(ui.ElementResourceID); // Provide empty object in case of editing if (!ui.RepresentsNew) { var objectType = UIContextHelper.GetObjectType(ctx); if (!String.IsNullOrEmpty(objectType)) { ctx.EditedObject = GetEmptyObject(objectType); } } int pageTemplateId = ui.ElementPageTemplateID; // If no page template is set, dont show any content if (pageTemplateId == 0) { RedirectToInformation(GetString("uielement.design.notemplate")); } DocumentContext.CurrentPageInfo = PageInfoProvider.GetVirtualPageInfo(pageTemplateId); // Set the design mode bool enable = (SystemContext.DevelopmentMode || (ui.ElementResourceID == QueryHelper.GetInteger("moduleId", 0) && ui.ElementIsCustom)); PortalContext.SetRequestViewMode(ViewModeEnum.Design); // If displayed module is not selected, disable design mode if (!enable) { plc.ViewMode = ViewModeEnum.DesignDisabled; } RequestStockHelper.Add(CookieName.DisplayContentInDesignMode, PortalHelper.DisplayContentInUIElementDesignMode, true); ManagersContainer = plcManagers; ScriptManagerControl = manScript; } }
/// <summary> /// Gets value from parent node /// </summary> private string GetParentProperty() { var where = new WhereCondition() .WhereNotEquals("DocumentStylesheetID", -1) .Or() .WhereNull("DocumentStylesheetID"); return(PageInfoProvider.GetParentProperty <string>(Node.NodeSiteID, Node.NodeAliasPath, "DocumentStylesheetID", Node.DocumentCulture, where)); }
/// <summary> /// Gets a list of links of tags assigned for the specific document pointing to the page with URL specified. /// </summary> /// <param name="documentGroupId">ID of the group document tags belong to</param> /// <param name="documentTags">String containing all the tags related to the document</param> /// <param name="nodeAliasPath">Node alias path</param> /// <param name="documentListPage">Path or URL of the page displaying other documents of the specified tag</param> public static string GetDocumentTags(object documentGroupId, object documentTags, object nodeAliasPath, string documentListPage) { var groupId = ValidationHelper.GetInteger(documentGroupId, 0); var tags = ValidationHelper.GetString(documentTags, null); var path = ValidationHelper.GetString(nodeAliasPath, null); var listPage = ValidationHelper.GetString(documentListPage, null); if ((tags == null) || (tags.Trim() == string.Empty)) { return(string.Empty); } // If list page was specified make a list of links, otherwise return just list of tags bool renderLink = !string.IsNullOrEmpty(listPage); if (renderLink) { // Get list page URL listPage = ValidationHelper.IsURL(listPage) ? URLHelper.ResolveUrl(listPage) : MacroContext.CurrentResolver.ResolvePath(listPage); // Look for group ID of document parent if not supplied if (groupId == 0) { var culture = MembershipContext.AuthenticatedUser.PreferredCultureCode; var currentPageInfo = DocumentContext.CurrentPageInfo; // Get context data if (path == null) { path = currentPageInfo.NodeAliasPath; culture = currentPageInfo.DocumentCulture; } groupId = PageInfoProvider.GetParentProperty <int>(currentPageInfo.NodeSiteID, path, "DocumentTagGroupID", culture, "DocumentTagGroupID IS NOT NULL"); } } // Get sorted list of document tags var tagList = TagHelper.GetTags(tags); var list = tagList.Values.Cast <string>().ToList(); list = list.Select(t => t.Replace("\"", "").Trim()).ToList(); list.Sort(); var result = list.Select(t => { var encodedTag = HTMLHelper.HTMLEncode(t); if (renderLink) { return("<a href=\"" + listPage + "?tagname=" + HttpUtility.UrlEncode(t) + "&groupid=" + groupId + "\">" + encodedTag + "</a>"); } return(encodedTag); }); return(result.Join(", ")); }
/// <summary> /// Loads template based on UI element settings /// </summary> private void LoadTemplate() { // Init the page components manPortal.SetMainPagePlaceholder(plc); // Prepare the page info PageInfo pi = PageInfoProvider.GetVirtualPageInfo(UIElement.ElementPageTemplateID); pi.DocumentNamePath = "/" + ResHelper.GetString("edittabs.design"); DocumentContext.CurrentPageInfo = pi; }
/// <summary> /// PreInit event handler. /// </summary> protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); // Init the page components manPortal.SetMainPagePlaceholder(plc); var ui = UIElementInfoProvider.GetUIElementInfo(QueryHelper.GetInteger("elementid", 0)); // Clear UIContext data of element "Modules.UserInterface.Design" (put by UIElement attribute to check permissions) UIContext.Data = null; if (ui != null) { UIContext.UIElement = ui; // Store resource name UIContext.ResourceName = UIContextHelper.GetResourceName(ui.ElementResourceID); int pageTemplateId = ui.ElementPageTemplateID; // If no page template is set, dont show any content if (pageTemplateId == 0) { RedirectToInformation(GetString("uielement.design.notemplate")); } // Prepare the page info PageInfo pi = PageInfoProvider.GetVirtualPageInfo(pageTemplateId); pi.DocumentNamePath = "/" + ResHelper.GetString("edittabs.design"); DocumentContext.CurrentPageInfo = pi; // Set the design mode bool enable = (SystemContext.DevelopmentMode || (ui.ElementResourceID == QueryHelper.GetInteger("moduleId", 0) && ui.ElementIsCustom)); PortalContext.SetRequestViewMode(ViewModeEnum.Design); // If displayed module is not selected, disable design mode if (!enable) { plc.ViewMode = ViewModeEnum.DesignDisabled; } ContextHelper.Add("DisplayContentInDesignMode", PortalHelper.DisplayContentInUIElementDesignMode, true, false, false, DateTime.MinValue); ManagersContainer = plcManagers; ScriptManagerControl = manScript; } }
/// <summary> /// Raises the <see cref="E:Init"/> event. /// </summary> protected override void OnInit(EventArgs e) { if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.mvtest", "Read")) { RedirectToAccessDenied(String.Format(GetString("general.permissionresource"), "Read", "MVT testing")); } // Register the Save and close button as the form submit button HeaderActions.Visible = false; editElem.UIFormControl.SubmitButton.Visible = false; btnOk.Click += (s, ea) => editElem.UIFormControl.SaveData(null); // Turn off update document for this page EnsureDocumentManager = false; // Set the ParentObject manually tor inherited templates if (editElem.UIFormControl.ParentObject == null) { var aliasPath = QueryHelper.GetString("aliaspath", string.Empty); var siteName = SiteContext.CurrentSiteName; // Get page info for the given document PageInfo pi = PageInfoProvider.GetPageInfo(siteName, aliasPath, LocalizationContext.PreferredCultureCode, null, SiteInfoProvider.CombineWithDefaultCulture(siteName)); if (pi != null) { editElem.UIFormControl.ParentObject = pi.UsedPageTemplateInfo; } } // Get information whether the control is used for a web part or zone variant variantType = VariantTypeFunctions.GetVariantTypeEnum(QueryHelper.GetString("varianttype", string.Empty)); mTemplateID = QueryHelper.GetInteger("templateid", 0); base.OnInit(e); // Check permissions and redirect VariantPermissionsChecker.CheckPermissions(variantType); // Get the alias path of the current node if (Node == null) { editElem.StopProcessing = true; } editElem.UIFormControl.OnBeforeSave += UIFormControl_OnBeforeSaved; }
/// <summary> /// Generates URL for document displayed under default alias path. /// </summary> /// <returns></returns> private static string GetUrlOfDocumentWithDefaultAliasPath() { var returnUrl = GetURLWithoutViewMode(); var node = DocumentContext.CurrentDocument; string query = URLHelper.GetQuery(returnUrl); // Default alias path exists string aliasPath = PageInfoProvider.GetDefaultAliasPath(RequestContext.CurrentDomain, SiteContext.CurrentSiteName); if (!String.IsNullOrEmpty(aliasPath) && (node != null)) { var url = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(node)); url = URLHelper.AppendQuery(url, query); returnUrl = UrlResolver.ResolveUrl(url); } return(returnUrl); }
/// <summary> /// PreInit event handler. /// </summary> protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); // Init the page components PageManager = manPortal; manPortal.SetMainPagePlaceholder(plc); int pageTemplateId = QueryHelper.GetInteger("templateid", 0); UIContext.EditedObject = PageTemplateInfoProvider.GetPageTemplateInfo(pageTemplateId); DocumentContext.CurrentPageInfo = PageInfoProvider.GetVirtualPageInfo(pageTemplateId); // Set the design mode PortalContext.SetRequestViewMode(ViewModeEnum.Design); RequestStockHelper.Add(CookieName.DisplayContentInDesignMode, "0", true); ManagersContainer = plcManagers; ScriptManagerControl = manScript; }
protected void chkCssStyle_CheckedChanged(object sender, EventArgs e) { if (chkCssStyle.Checked) { // Set stylesheet to stylesheet selector ctrlSiteSelectStyleSheet.CurrentDropDown.Enabled = false; ctrlSiteSelectStyleSheet.ButtonNewEnabled = false; string value = PageInfoProvider.GetParentProperty(CMSContext.CurrentSite.SiteID, Node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelperClass.GetSafeQueryString(Node.DocumentCulture, false) + "'", "DocumentStylesheetID"); if (String.IsNullOrEmpty(value)) { // If default site stylesheet not exist edit is set to -1 - disabled if (CMSContext.CurrentSiteStylesheet != null) { ctrlSiteSelectStyleSheet.CurrentDropDown.SelectedValue = "default"; } else { ctrlSiteSelectStyleSheet.CurrentDropDown.SelectedValue = "-1"; } } else { try { ctrlSiteSelectStyleSheet.CurrentDropDown.SelectedValue = value; } catch { } } } else { ctrlSiteSelectStyleSheet.CurrentDropDown.Enabled = true; ctrlSiteSelectStyleSheet.ButtonNewEnabled = true; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { partPlaceholder.CheckPermissions = CheckPermissions; partPlaceholder.CacheMinutes = CacheMinutes; // Load content only when default page template or path is defined string templateName = PageTemplate; string path = Path; if ((templateName != "") || (path != "")) { ViewModeEnum viewMode = ViewModeEnum.Unknown; // Process template only if the control is on the last hierarchy page PageInfo currentPage = PagePlaceholder.PageInfo; PageInfo usePage; PageTemplateInfo ti = null; if (String.IsNullOrEmpty(path)) { // Use the same page usePage = PagePlaceholder.PageInfo; if (UseDefaultTemplateOnSubPages || (currentPage.ChildPageInfo == null) || (currentPage.ChildPageInfo.UsedPageTemplateInfo == null) || (currentPage.ChildPageInfo.UsedPageTemplateInfo.PageTemplateId == 0)) { ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName); } } else { // Resolve the path first path = MacroResolver.ResolveCurrentPath(path); // Get specific page usePage = PageInfoProvider.GetPageInfo(SiteContext.CurrentSiteName, path, LocalizationContext.PreferredCultureCode, null, SiteContext.CurrentSite.CombineWithDefaultCulture); if (PortalManager.ViewMode != ViewModeEnum.LiveSite) { viewMode = ViewModeEnum.Preview; // Set design mode for document's placeholder if is currently displayed TreeNode tn = DocumentContext.CurrentDocument; if ((tn != null) && (PortalContext.ViewMode == ViewModeEnum.Design) && tn.NodeAliasPath.EqualsCSafe(path, true)) { viewMode = ViewModeEnum.Design; } // Get latest version data of current document content if (usePage != null) { usePage.LoadVersion(); } } // Get the appropriate page template if (String.IsNullOrEmpty(templateName)) { ti = (usePage != null) ? usePage.UsedPageTemplateInfo : null; } else { ti = PageTemplateInfoProvider.GetPageTemplateInfo(templateName); } } if ((usePage != null) && (ti != null)) { // If same template as current page, avoid cycling if (ti.PageTemplateId == currentPage.UsedPageTemplateInfo.PageTemplateId) { lblError.Text = GetString("WebPart.PagePlaceHolder.CurrentTemplateNotAllowed"); lblError.Visible = true; } else { usePage = usePage.Clone(); // Setup the page template int templateId = ti.PageTemplateId; usePage.SetPageTemplateId(templateId); usePage.UsedPageTemplateInfo = ti; // Load the current page info with the template and document if (viewMode != ViewModeEnum.Unknown) { partPlaceholder.ViewMode = viewMode; } partPlaceholder.UsingDefaultPageTemplate = !string.IsNullOrEmpty(templateName); partPlaceholder.UsingDefaultDocument = !string.IsNullOrEmpty(path); partPlaceholder.PageLevel = PagePlaceholder.PageLevel; partPlaceholder.LoadContent(usePage); } } } } }
protected void Page_Load(object sender, EventArgs e) { var previewState = GetPreviewStateFromCookies(MASTERPAGE); // Keep current user var user = MembershipContext.AuthenticatedUser; // Get document node tree = new TreeProvider(user); node = UIContext.EditedObject as TreeNode; // Register the dialog script ScriptHelper.RegisterDialogScript(Page); // Register save changes ScriptHelper.RegisterSaveChanges(Page); // Save changes support bool confirmChanges = SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSConfirmChanges"); string script = string.Empty; if (confirmChanges) { script = "CMSContentManager.confirmLeave=" + ScriptHelper.GetString(ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode), true, false) + "; \n"; script += "CMSContentManager.confirmLeaveShort=" + ScriptHelper.GetString(ResHelper.GetString("Content.ConfirmLeaveShort", user.PreferredUICultureCode), true, false) + "; \n"; } else { script += "CMSContentManager.confirmChanges = false;"; } ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", script, true); try { if (node != null) { DocumentContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(node.NodeSiteName, node.NodeAliasPath, node.DocumentCulture, null, node.NodeID, false); // Title string title = DocumentContext.CurrentTitle; if (!string.IsNullOrEmpty(title)) { title = "<title>" + title + "</title>"; } // Body class string bodyCss = DocumentContext.CurrentBodyClass; if (bodyCss != null && bodyCss.Trim() != "") { bodyCss = "class=\"" + bodyCss + "\""; } else { bodyCss = ""; } // Metadata string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />"; string description = DocumentContext.CurrentDescription; if (description != "") { meta += "<meta name=\"description\" content=\"" + description + "\" />"; } string keywords = DocumentContext.CurrentKeyWords; if (keywords != "") { meta += "<meta name=\"keywords\" content=\"" + keywords + "\" />"; } // Site style sheet string cssSiteSheet = ""; int stylesheetId = DocumentContext.CurrentPageInfo.DocumentStylesheetID; CssStylesheetInfo cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : SiteContext.CurrentSite.SiteDefaultStylesheetID); if (cssInfo != null) { cssSiteSheet = CssLinkHelper.GetCssFileLink(CssLinkHelper.GetStylesheetUrl(cssInfo.StylesheetName)); } // Theme CSS files string themeCssFiles = ""; if (cssInfo != null) { try { string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName)); if (Directory.Exists(directory)) { foreach (string file in Directory.GetFiles(directory, "*.css")) { themeCssFiles += CssLinkHelper.GetCssFileLink(CssLinkHelper.GetPhysicalCssUrl(cssInfo.StylesheetName, Path.GetFileName(file))); } } } catch { } } // Add values to page mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2); mBody = bodyCss; } } catch { ShowError(GetString("MasterPage.PageEditErr")); } LoadData(); // Add save action SaveAction save = new SaveAction(); save.CommandArgument = ComponentEvents.SAVE_DATA; save.CommandName = ComponentEvents.SAVE_DATA; headerActions.ActionsList.Add(save); if (pti != null) { // Disable buttons for no-template bool actionsEnabled = (pti.PageTemplateId > 0); // Edit layout HeaderAction action = new HeaderAction { Text = GetString("content.ui.pagelayout"), Tooltip = GetString("pageplaceholder.editlayouttooltip"), OnClientClick = "EditLayout();return false;", Enabled = actionsEnabled }; headerActions.ActionsList.Add(action); string elemUrl = ApplicationUrlHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", pti.PageTemplateId); // Edit page properties action action = new HeaderAction { Text = GetString("PageProperties.EditTemplateProperties"), Tooltip = GetString("PageProperties.EditTemplateProperties"), OnClientClick = "modalDialog('" + elemUrl + "', 'TemplateSelection', '85%', '85%');return false;", Enabled = actionsEnabled }; CMSPagePlaceholder.RegisterEditLayoutScript(this, pti.PageTemplateId, node.NodeAliasPath, null); headerActions.ActionsList.Add(action); // Preview HeaderAction preview = new HeaderAction { Text = GetString("general.preview"), OnClientClick = "performToolbarAction('split');return false;", Visible = ((previewState == 0) && !PortalUIHelper.DisplaySplitMode), Tooltip = GetString("preview.tooltip") }; headerActions.ActionsList.Add(preview); headerActions.ActionPerformed += headerActions_ActionPerformed; } RegisterInitScripts(pnlBody.ClientID, pnlMenu.ClientID, false); }
/// <summary> /// Gets stylesheet identifier value from parent node /// </summary> private string GetStylesheetParentValue() { var where = new WhereCondition().WhereNotEquals("DocumentInheritsStylesheet", true); return(PageInfoProvider.GetParentProperty <string>(Node.NodeSiteID, Node.NodeAliasPath, "DocumentStylesheetID", Node.DocumentCulture, where)); }
private void ReloadData() { if (Node != null) { // Hide parts which are not relevant to content only nodes if (ShowContentOnlyProperties) { pnlUIAdvanced.Visible = false; pnlUICache.Visible = false; pnlUIDesign.Visible = false; plcPermanent.Visible = false; pnlUIOnlineMarketing.Visible = false; } // Log activities checkboxes if (!RequestHelper.IsPostBack()) { bool?logVisit = Node.DocumentLogVisitActivity; chkLogPageVisit.Checked = (logVisit == true); if (Node.NodeParentID > 0) // Init "inherit" option for child nodes (and hide option for root) { chkPageVisitInherit.Checked = (logVisit == null); if (logVisit == null) { chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty); } } chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked; } // Check modify permission canEdit = (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Denied); // Show document group owner selector if (ModuleEntryManager.IsModuleLoaded(ModuleName.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.Groups)) { plcOwnerGroup.Controls.Clear(); // Initialize panel content Panel rowWrapperPanel = new Panel(); rowWrapperPanel.CssClass = "form-group"; Panel lblPanel = new Panel(); lblPanel.CssClass = "editing-form-label-cell"; Panel ctrlPanel = new Panel(); ctrlPanel.CssClass = "editing-form-value-cell"; // Initialize caption LocalizedLabel lblOwnerGroup = new LocalizedLabel(); lblOwnerGroup.EnableViewState = false; lblOwnerGroup.ResourceString = "community.group.documentowner"; lblOwnerGroup.ID = "lblOwnerGroup"; lblOwnerGroup.CssClass = "control-label"; lblPanel.Controls.Add(lblOwnerGroup); // Initialize selector fcDocumentGroupSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx"); fcDocumentGroupSelector.ID = "fcDocumentGroupSelector"; fcDocumentGroupSelector.StopProcessing = pnlUIOwner.IsHidden; ctrlPanel.Controls.Add(fcDocumentGroupSelector); fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(Node.GetValue("NodeGroupID"), 0); fcDocumentGroupSelector.SetValue("siteid", SiteContext.CurrentSiteID); fcDocumentGroupSelector.SetValue("nodeid", Node.NodeID); // Add controls to containers rowWrapperPanel.Controls.Add(lblPanel); rowWrapperPanel.Controls.Add(ctrlPanel); plcOwnerGroup.Controls.Add(rowWrapperPanel); plcOwnerGroup.Visible = true; } // Show owner editing only when authorized to change the permissions if (canEditOwner) { lblOwner.Visible = false; usrOwner.Visible = true; usrOwner.SetValue("AdditionalUsers", new[] { Node.NodeOwner }); } else { usrOwner.Visible = false; } if (!RequestHelper.IsPostBack()) { if (canEditOwner) { usrOwner.Value = Node.GetValue("NodeOwner"); } } // Load the data lblName.Text = HttpUtility.HtmlEncode(Node.GetDocumentName()); lblNamePath.Text = HttpUtility.HtmlEncode(Convert.ToString(Node.GetValue("DocumentNamePath"))); lblAliasPath.Text = Convert.ToString(Node.NodeAliasPath); string typeName = DataClassInfoProvider.GetDataClassInfo(Node.NodeClassName).ClassDisplayName; lblType.Text = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName)); lblNodeID.Text = Convert.ToString(Node.NodeID); // Modifier SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId"); // Get modified time TimeZoneInfo usedTimeZone; DateTime lastModified = ValidationHelper.GetDateTime(Node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME); lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help"); if (!canEditOwner) { // Owner SetUserLabel(lblOwner, "NodeOwner"); } // Creator SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId"); DateTime createdWhen = ValidationHelper.GetDateTime(Node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME); lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help"); // URL if (plcPermanent.Visible) { string permanentUrl = DocumentURLProvider.GetPermanentDocUrl(Node.NodeGUID, Node.NodeAlias, Node.NodeSiteName, extension: ".aspx"); permanentUrl = URLHelper.ResolveUrl(permanentUrl); lnkPermanentURL.HRef = permanentUrl; lnkPermanentURL.InnerText = permanentUrl; } string liveUrl = DocumentURLProvider.GetAbsoluteLiveSiteURL(Node); lnkLiveURL.HRef = liveUrl; lnkLiveURL.InnerText = liveUrl; bool isRoot = Node.IsRoot(); // Hide preview URL for root node if (!isRoot) { plcPreview.Visible = true; btnResetPreviewGuid.ToolTip = GetString("GeneralProperties.InvalidatePreviewURL"); btnResetPreviewGuid.Click += btnResetPreviewGuid_Click; btnResetPreviewGuid.OnClientClick = "if(!confirm(" + ScriptHelper.GetLocalizedString("GeneralProperties.GeneratePreviewURLConf") + ")){return false;}"; InitPreviewUrl(); } lblGUID.Text = Convert.ToString(Node.NodeGUID); lblDocGUID.Text = (Node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : Node.DocumentGUID.ToString(); lblDocID.Text = Convert.ToString(Node.DocumentID); // Culture CultureInfo ci = CultureInfoProvider.GetCultureInfo(Node.DocumentCulture); lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : Node.DocumentCulture); if (Node.IsPublished) { lblPublished.Text = GetString("General.Yes"); lblPublished.CssClass += " DocumentPublishedYes"; } else { lblPublished.CssClass += " DocumentPublishedNo"; lblPublished.Text = GetString("General.No"); } // Load page info for inherited cache settings currentPage = PageInfoProvider.GetPageInfo(Node.NodeSiteName, Node.NodeAliasPath, Node.DocumentCulture, null, Node.NodeID, false); if (!RequestHelper.IsPostBack()) { // Init radio buttons for cache settings if (isRoot) { radInherit.Visible = false; radFSInherit.Visible = false; chkCssStyle.Visible = false; } else { // Show what is inherited value radInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeCacheMinutes") + ")"; radFSInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeAllowCacheInFileSystem") + ")"; } string cacheMinutes = ""; switch (Node.NodeCacheMinutes) { case null: // Cache setting is inherited { radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; if (!isRoot) { radInherit.Checked = true; radNo.Checked = false; if ((currentPage != null) && (currentPage.NodeCacheMinutes > 0)) { cacheMinutes = currentPage.NodeCacheMinutes.ToString(); } } } break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; cacheMinutes = Node.NodeCacheMinutes.ToString(); break; } // Set secured radio buttons switch (Node.NodeAllowCacheInFileSystem) { case false: radFSNo.Checked = true; break; case true: radFSYes.Checked = true; break; default: if (!isRoot) { radFSInherit.Checked = true; } else { radFSYes.Checked = true; } break; } txtCacheMinutes.Text = cacheMinutes; if (!radYes.Checked) { txtCacheMinutes.Enabled = false; } var defaultStylesheet = GetDefaultStylesheet(); if (Node.DocumentInheritsStylesheet && !isRoot) { chkCssStyle.Checked = true; // Get stylesheet from the parent node string value = GetStylesheetParentValue(); ctrlSiteSelectStyleSheet.Value = String.IsNullOrEmpty(value) ? defaultStylesheet : value; } else { // Get stylesheet from the current node var stylesheetId = Node.DocumentStylesheetID; ctrlSiteSelectStyleSheet.Value = (stylesheetId == 0) ? defaultStylesheet : stylesheetId.ToString(); } } // Disable new button if document inherit stylesheet bool disableCssSelector = (!isRoot && chkCssStyle.Checked); ctrlSiteSelectStyleSheet.Enabled = !disableCssSelector; ctrlSiteSelectStyleSheet.ButtonNewEnabled = !disableCssSelector; // Initialize Rating control RefreshCntRatingResult(); double rating = 0.0f; if (Node.DocumentRatings > 0) { rating = Node.DocumentRatingValue / Node.DocumentRatings; } ratingControl.MaxRating = 10; ratingControl.CurrentRating = rating; ratingControl.Visible = true; ratingControl.Enabled = false; // Initialize Reset button for rating btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;"; object[] param = new object[1]; param[0] = Node.DocumentID; plcAdHocForums.Visible = hasAdHocForum; plcAdHocBoards.Visible = hasAdHocBoard; if (!canEdit) { // Disable form editing DisableFormEditing(); } } else { btnResetRating.Visible = false; } }
/// <summary> /// Processes the specified version of the file and returns the data to the output stream. /// </summary> /// <param name="attachmentGuid">Attachment GUID</param> /// <param name="versionHistoryId">Document version history ID</param> protected void ProcessFile(Guid attachmentGuid, int versionHistoryId) { AttachmentInfo atInfo = GetFile(attachmentGuid, versionHistoryId); if (atInfo != null) { // If attachment is image, try resize byte[] mFile = atInfo.AttachmentBinary; if (mFile != null) { string mimetype = null; if (ImageHelper.IsImage(atInfo.AttachmentExtension)) { if (AttachmentManager.CanResizeImage(atInfo, Width, Height, MaxSideSize)) { // Do not search thumbnail on the disk mFile = AttachmentManager.GetImageThumbnail(atInfo, CurrentSiteName, Width, Height, MaxSideSize, false); mimetype = "image/jpeg"; } } if (mFile != null) { outputFile = NewOutputFile(atInfo, mFile); } else { outputFile = NewOutputFile(); } outputFile.Height = Height; outputFile.Width = Width; outputFile.MaxSideSize = MaxSideSize; outputFile.MimeType = mimetype; } // Get the file document if (node == null) { node = TreeProvider.SelectSingleDocument(atInfo.AttachmentDocumentID); } if (node != null) { // Check secured area SiteInfo si = SiteInfoProvider.GetSiteInfo(node.NodeSiteID); if (si != null) { if (pi == null) { pi = PageInfoProvider.GetPageInfo(si.SiteName, node.NodeAliasPath, node.DocumentCulture, node.DocumentUrlPath, false); } if (pi != null) { URLRewriter.RequestSecurePage(pi, false, ViewMode, CurrentSiteName); URLRewriter.CheckSecuredAreas(CurrentSiteName, pi, false, ViewMode); } } // Check the permissions for the document if ((CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Allowed) || (node.NodeOwner == CurrentUser.UserID)) { if (outputFile == null) { outputFile = NewOutputFile(); } outputFile.AliasPath = node.NodeAliasPath; outputFile.CultureCode = node.DocumentCulture; if (IsLiveSite && AttachmentManager.CheckPublishedFiles(CurrentSiteName)) { outputFile.IsPublished = node.IsPublished; } outputFile.FileNode = node; } else { outputFile = null; } } } }
protected void Page_Load(object sender, EventArgs e) { CMSContext.ViewMode = ViewModeEnum.MasterPage; // Keep current user user = CMSContext.CurrentUser; // Check UIProfile if (!user.IsAuthorizedPerUIElement("CMS.Content", "MasterPage")) { RedirectToCMSDeskUIElementAccessDenied("CMS.Content", "MasterPage"); } // Check "Design" permission if (!user.IsAuthorizedPerResource("CMS.Design", "Design")) { RedirectToAccessDenied("CMS.Design", "Design"); } // Register the scripts ScriptHelper.RegisterProgress(this); ScriptHelper.RegisterSaveShortcut(btnSave, null, false); // Save changes support bool confirmChanges = SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSConfirmChanges"); string script = string.Empty; if (confirmChanges) { script = "var confirmLeave='" + ResHelper.GetString("Content.ConfirmLeave", user.PreferredUICultureCode) + "'; \n"; } else { script += "confirmChanges = false;"; } ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "saveChangesScript", ScriptHelper.GetScript(script)); nodeId = QueryHelper.GetInteger("NodeId", 0); try { CMSContext.CurrentPageInfo = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, "/", CMSContext.PreferredCultureCode, null, false); // Title string title = CMSContext.CurrentTitle; if (!string.IsNullOrEmpty(title)) { title = "<title>" + title + "</title>"; } // Body class string bodyCss = CMSContext.CurrentBodyClass; if (bodyCss != null && bodyCss.Trim() != "") { bodyCss = "class=\"" + bodyCss + "\""; } else { bodyCss = ""; } // metadata string meta = "<meta http-equiv=\"pragma\" content=\"no-cache\" />"; string description = CMSContext.CurrentDescription; if (description != "") { meta += "<meta name=\"description\" content=\"" + description + "\" />"; } string keywords = CMSContext.CurrentKeyWords; if (keywords != "") { meta += "<meta name=\"keywords\" content=\"" + keywords + "\" />"; } // Site style sheet string cssSiteSheet = ""; CssStylesheetInfo cssInfo = null; int stylesheetId = CMSContext.CurrentPageInfo.DocumentStylesheetID; cssInfo = CssStylesheetInfoProvider.GetCssStylesheetInfo((stylesheetId > 0) ? stylesheetId : CMSContext.CurrentSite.SiteDefaultStylesheetID); if (cssInfo != null) { cssSiteSheet = CSSHelper.GetCSSFileLink(CSSHelper.GetStylesheetUrl(cssInfo.StylesheetName)); } // Theme css files string themeCssFiles = ""; if (cssInfo != null) { try { string directory = URLHelper.GetPhysicalPath(string.Format("~/App_Themes/{0}/", cssInfo.StylesheetName)); if (Directory.Exists(directory)) { foreach (string file in Directory.GetFiles(directory, "*.css")) { themeCssFiles += CSSHelper.GetCSSFileLink(CSSHelper.GetPhysicalCSSUrl(cssInfo.StylesheetName, Path.GetFileName(file))); } } } catch { } } // Add values to page mHead = FormatHTML(HighlightHTML(title + meta + cssSiteSheet + themeCssFiles), 2); mBody = bodyCss; } catch { lblError.Visible = true; lblError.Text = GetString("MasterPage.PageEditErr"); } // Prepare the hints and typw dropdown lblType.Text = ResHelper.GetString("PageLayout.Type"); if (drpType.Items.Count == 0) { drpType.Items.Add(new ListItem(ResHelper.GetString("TransformationType.Ascx"), TransformationTypeEnum.Ascx.ToString())); drpType.Items.Add(new ListItem(ResHelper.GetString("TransformationType.Html"), TransformationTypeEnum.Html.ToString())); } string lang = ValidationHelper.GetString(SettingsHelper.AppSettings["CMSProgrammingLanguage"], "C#"); ltlDirectives.Text = "<%@ Control Language=\"" + lang + "\" ClassName=\"Simple\" Inherits=\"CMS.PortalControls.CMSAbstractLayout\" %><br /><%@ Register Assembly=\"CMS.PortalControls\" Namespace=\"CMS.PortalControls\" TagPrefix=\"cc1\" %>"; if (!SettingsKeyProvider.UsingVirtualPathProvider) { lblChecked.Visible = true; lblChecked.Text = "<br />" + AddSpaces(2) + GetString("MasterPage.VirtualPathProviderNotRunning"); txtLayout.ReadOnly = true; } LoadData(); // Register synchronization script for split mode if (CMSContext.DisplaySplitMode) { RegisterSplitModeSync(true, false); } }