/// <summary> /// CheckedChanged event handler. /// </summary> protected void checkBox_CheckedChanged(object sender, EventArgs e) { CMSCheckBox checkBox = (CMSCheckBox)sender; // Get field name that can be set as inherited by checkbox KeyValuePair <string, CMSCheckBox> item = checkboxList.FirstOrDefault(x => x.Value.ClientID == checkBox.ClientID); if (item.Key != null) { FormEngineUserControl mainControl = Control.FieldControls[item.Key]; if (checkBox.Checked) { // Value is inherited mainControl.Enabled = false; if (!String.IsNullOrEmpty(Node.NodeSiteName)) { mainControl.Value = Node.GetInheritedValue(item.Key, SiteInfoProvider.CombineWithDefaultCulture(Node.NodeSiteName)); } } else { // Text area is enabled mainControl.Enabled = true; } if (item.Key == "DocumentTagGroupID") { InitializeTagSelector(); } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { repElem.StopProcessing = true; } else { SetContext(); // Setup the control PageInfo currentPage = DocumentContext.CurrentPageInfo; if (currentPage != null) { repElem.ControlContext = ControlContext; repElem.SiteName = SiteContext.CurrentSiteName; repElem.Path = "/%"; repElem.CultureCode = currentPage.DocumentCulture; repElem.CombineWithDefaultCulture = SiteInfoProvider.CombineWithDefaultCulture(SiteContext.CurrentSiteName); repElem.ClassNames = ClassNames; repElem.OrderBy = OrderBy; repElem.MaxRelativeLevel = -1; repElem.SelectOnlyPublished = SelectOnlyPublished; repElem.RelationshipWithNodeGuid = currentPage.NodeGUID; repElem.RelationshipName = RelationshipName; repElem.RelatedNodeIsOnTheLeftSide = CurrentDocumentIsOnTheLeftSide; repElem.TopN = SelectTopN; repElem.Columns = Columns; repElem.WhereCondition = WhereCondition; repElem.CacheDependencies = CacheDependencies; repElem.CacheMinutes = CacheMinutes; if (TransformationName != string.Empty) { repElem.TransformationName = TransformationName; } repElem.HideControlForZeroRows = HideControlForZeroRows; repElem.ZeroRowsText = ZeroRowsText; repElem.EnablePaging = false; } ReleaseContext(); } }
protected void Page_Load(object sender, EventArgs e) { bool isSplitMode = CMSContext.DisplaySplitMode; EnsureSplitModeCrossoverScript(); ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "refreshtree", ScriptHelper.GetScript("function RefreshTree(expandNodeId, selectNodeId) { parent.RefreshTree(expandNodeId, selectNodeId); } function SelectNode(selectNodeId) { parent.SelectNode(selectNodeId); }")); bool combineWithDefaultCulture = !isSplitMode && SiteInfoProvider.CombineWithDefaultCulture(CMSContext.CurrentSiteName); string name = null; // When node ID specified if (NodeID > 0) { // Check if product node exists TreeNode node = Tree.SelectSingleNode(NodeID, CultureCode, combineWithDefaultCulture); if (node == null) { // Product does not exist -> redirect to new culture version creation dialog RedirectToNewCultureVersionPage(); } else { // Get the name for automatic title name = (node.NodeAliasPath == "/" ? CMSContext.CurrentSite.DisplayName : node.GetDocumentName()); } } else if (ProductID > 0) { SKUInfo sku = SKUInfoProvider.GetSKUInfo(ProductID); name = (sku != null) ? sku.SKUName : null; } if (!String.IsNullOrEmpty(name)) { ScriptHelper.RegisterTitleScript(this, ResHelper.LocalizeString(name)); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { // Public user is not allowed for widgets if (!AuthenticationHelper.IsAuthenticated()) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } var viewMode = ViewModeCode.FromString(QueryHelper.GetString("viewmode", String.Empty)); var hash = QueryHelper.GetString("hash", String.Empty); LiveSiteWidgetsParameters dialogparameters = new LiveSiteWidgetsParameters(aliasPath, viewMode) { ZoneId = zoneId, ZoneType = zoneType, InstanceGuid = instanceGuid, TemplateId = templateId, IsInlineWidget = inline }; if (!dialogparameters.ValidateHash(hash)) { return; } // Set page title Page.Title = GetString(isNewWidget ? "widgets.propertiespage.titlenew" : "widgets.propertiespage.title"); if ((widgetId != string.Empty) && (aliasPath != string.Empty)) { // Get page info var siteName = SiteContext.CurrentSiteName; PageInfo pi = PageInfoProvider.GetPageInfo(siteName, aliasPath, LocalizationContext.PreferredCultureCode, null, SiteInfoProvider.CombineWithDefaultCulture(siteName)); if (pi == null) { return; } // Get template instance PageTemplateInstance templateInstance = CMSPortalManager.GetTemplateInstanceForEditing(pi); // Get widget from instance WidgetInfo wi = null; if (!isNewWidget) { // Get the instance of widget WebPartInstance widgetInstance = templateInstance.GetWebPart(instanceGuid, widgetId); if (widgetInstance == null) { return; } // Get widget info by widget name(widget type) wi = WidgetInfoProvider.GetWidgetInfo(widgetInstance.WebPartType); } // Widget instance hasn't created yet else { wi = WidgetInfoProvider.GetWidgetInfo(ValidationHelper.GetInteger(widgetId, 0)); } if (wi != null) { WebPartZoneInstance zone = templateInstance.GetZone(zoneId); if (zone != null) { var currentUser = MembershipContext.AuthenticatedUser; bool checkSecurity = true; // Check security // It is group zone type but widget is not allowed in group if (zone.WidgetZoneType == WidgetZoneTypeEnum.Group) { // Should always be, only group widget are allowed in group zone if (wi.WidgetForGroup) { if (!currentUser.IsGroupAdministrator(pi.NodeGroupID)) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } // All ok, don't check classic security checkSecurity = false; } } if (checkSecurity && !WidgetRoleInfoProvider.IsWidgetAllowed(wi, currentUser.UserID, AuthenticationHelper.IsAuthenticated())) { RedirectToAccessDenied(GetString("widgets.security.notallowed")); } } } } // If all ok, set up frames rowsFrameset.Attributes.Add("rows", string.Format("{0}, *", TitleOnlyHeight)); frameHeader.Attributes.Add("src", "widgetproperties_header.aspx" + RequestContext.CurrentQueryString); if (inline && !isNewWidget) { frameContent.Attributes.Add("src", ResolveUrl("~/CMSPages/Blank.htm")); } else { frameContent.Attributes.Add("src", "widgetproperties_properties_frameset.aspx" + RequestContext.CurrentQueryString); } }
protected void Page_Load(object sender, EventArgs e) { string aliasPath = QueryHelper.GetString("aliaspath", ""); string webpartId = QueryHelper.GetString("webpartid", ""); string zoneId = QueryHelper.GetString("zoneid", ""); Guid webpartGuid = QueryHelper.GetGuid("webpartguid", Guid.Empty); int templateId = QueryHelper.GetInteger("templateId", 0); PageTemplateInfo pti = null; if (templateId > 0) { pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId); } if (pti == null) { var siteName = SiteContext.CurrentSiteName; PageInfo pi = PageInfoProvider.GetPageInfo(siteName, aliasPath, LocalizationContext.PreferredCultureCode, null, SiteInfoProvider.CombineWithDefaultCulture(siteName)); if (pi != null) { pti = pi.UsedPageTemplateInfo; } } if (pti != null) { // Get web part WebPartInstance webPart = pti.TemplateInstance.GetWebPart(webpartGuid, webpartId); if (webPart != null) { StringBuilder sb = new StringBuilder(); Hashtable properties = webPart.Properties; // Get the webpart object WebPartInfo wi = WebPartInfoProvider.GetWebPartInfo(webPart.WebPartType); if (wi != null) { // Add the header sb.Append("Webpart properties (" + wi.WebPartDisplayName + ")" + Environment.NewLine + Environment.NewLine); sb.Append("Alias path: " + aliasPath + Environment.NewLine); sb.Append("Zone ID: " + zoneId + Environment.NewLine + Environment.NewLine); string wpProperties = "<default></default>"; // Get the form info object and load it with the data if (wi.WebPartParentID > 0) { // Load parent properties WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(wi.WebPartParentID); if (wpi != null) { wpProperties = FormHelper.MergeFormDefinitions(wpi.WebPartProperties, wi.WebPartProperties); } } else { wpProperties = wi.WebPartProperties; } FormInfo fi = new FormInfo(wpProperties); // General properties of webparts string beforeFormDefinition = PortalFormHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.Before); string afterFormDefinition = PortalFormHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.After); // General properties before custom if (!String.IsNullOrEmpty(beforeFormDefinition)) { // Load before definition fi = new FormInfo(FormHelper.MergeFormDefinitions(beforeFormDefinition, wpProperties, true)); // Add Default category for first before items sb.Append(Environment.NewLine + "Default" + Environment.NewLine + Environment.NewLine + Environment.NewLine); } // General properties after custom if (!String.IsNullOrEmpty(afterFormDefinition)) { // Load after definition fi = new FormInfo(FormHelper.MergeFormDefinitions(fi.GetXmlDefinition(), afterFormDefinition, true)); } // Generate all properties sb.Append(GetProperties(fi.GetFormElements(true, false), webPart)); // Send the text file to the user to download UTF8Encoding enc = new UTF8Encoding(); byte[] file = enc.GetBytes(sb.ToString()); Response.AddHeader("Content-disposition", "attachment; filename=webpartproperties_" + HTTPHelper.GetDispositionFilename(webPart.ControlID) + ".txt"); Response.ContentType = "text/plain"; Response.BinaryWrite(file); RequestHelper.EndResponse(); } } } }
protected void chkPageVisitInherit_CheckedChanged(object sender, EventArgs e) { chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked; if (chkPageVisitInherit.Checked && (Node != null)) { string siteName = CMSContext.CurrentSiteName; if (!String.IsNullOrEmpty(siteName)) { chkLogPageVisit.Checked = ValidationHelper.GetBoolean(Node.GetInheritedValue("DocumentLogVisitActivity", SiteInfoProvider.CombineWithDefaultCulture(siteName)), false); } } }
protected void Page_Load(object sender, EventArgs e) { // Switch the view mode CMSContext.ViewMode = ViewModeEnum.Preview; // Get the document int nodeId = 0; if (Request.QueryString["nodeid"] != null) { nodeId = ValidationHelper.GetInteger(Request.QueryString["nodeid"], 0); } string siteName = CMSContext.CurrentSiteName; TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode node = null; // Check split mode bool isSplitMode = CMSContext.DisplaySplitMode; bool combineWithDefaultCulture = isSplitMode ? false : SiteInfoProvider.CombineWithDefaultCulture(siteName); // Get the document node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode, combineWithDefaultCulture); // Redirect to the live URL if (node != null) { // If no workflow defined, hide the menu bar WorkflowManager wm = new WorkflowManager(tree); WorkflowInfo wi = wm.GetNodeWorkflow(node); if (wi == null) { headersize = "0"; } else { // Get current step info WorkflowStepInfo si = wm.GetStepInfo(node); if (si != null) { switch (si.StepName.ToLower()) { case "published": case "archived": headersize = "0"; break; } } } // Check the document availability if (!node.DocumentCulture.Equals(CMSContext.PreferredCultureCode, StringComparison.InvariantCultureIgnoreCase) && (!SiteInfoProvider.CombineWithDefaultCulture(siteName) || !node.DocumentCulture.Equals(CultureHelper.GetDefaultCulture(siteName), StringComparison.InvariantCultureIgnoreCase))) { viewpage = "~/CMSMessages/PageNotAvailable.aspx?reason=missingculture"; } else { // Use permanent URL to get proper preview mode viewpage = URLRewriter.GetEditingUrl(node); } } else { viewpage = isSplitMode ? "~/CMSModules/Content/CMSDesk/New/NewCultureVersion.aspx" + URLHelper.Url.Query : "~/CMSMessages/PageNotAvailable.aspx?reason=missingculture&showlink=false"; } // Register synchronization script for split mode if (isSplitMode) { RegisterSplitModeSync(false, false); } viewpage = ResolveUrl(viewpage); }
/// <summary> /// PreRender event handler. /// </summary> protected void Page_PreRender(object sender, EventArgs e) { if ((Node != null) && (TagGroupSelector != null)) { bool noneSelected = ValidationHelper.GetInteger(TagGroupSelector.Value, 0) == 0; int parentValue = ValidationHelper.GetInteger(Node.GetInheritedValue("DocumentTagGroupID", SiteInfoProvider.CombineWithDefaultCulture(Node.NodeSiteName)), 0); // Allow empty value in selector if node has no tag group selected and parent tag group also isn't set TagGroupSelector.SetValue("AllowEmpty", noneSelected || ((Node.DocumentTagGroupID == 0) && (parentValue == 0))); if (!TagGroupSelector.HasData) { // Hide tag module controls and show information if no tag group exists Control.MessagesPlaceHolder.ShowInformation(ResHelper.GetString("PageProperties.TagsInfo")); Control.FieldsToHide.Add("DocumentTagGroupID"); Control.FieldsToHide.Add("DocumentTagGroupIDInherit"); Control.FieldsToHide.Add("DocumentTags"); } else { Control.FieldControls["DocumentTags"].Enabled = !noneSelected; if (noneSelected) { // Clear tags if no tag group selected Control.FieldControls["DocumentTags"].Text = String.Empty; } } } }
protected void chkTagGroupSelector_CheckedChanged(object sender, EventArgs e) { if (chkTagGroupSelector.Checked) { // Value is inherited tagGroupSelectorElem.Enabled = false; if (!String.IsNullOrEmpty(siteName)) { // Load parent value to tag group selector int value = ValidationHelper.GetInteger(node.GetInheritedValue("DocumentTagGroupID", SiteInfoProvider.CombineWithDefaultCulture(siteName)), 0); if (value == 0) { tagGroupSelectorElem.AddNoneItemsRecord = true; } tagGroupSelectorElem.Value = value; tagGroupSelectorElem.ReloadData(); } } else { tagGroupSelectorElem.Enabled = true; } }
protected void chkKeyWords_CheckedChanged(object sender, EventArgs e) { if (chkKeyWords.Checked) { // Value is inherited txtKeywords.Enabled = false; if (!String.IsNullOrEmpty(siteName)) { txtKeywords.Text = ValidationHelper.GetString(node.GetInheritedValue("DocumentPageKeyWords", SiteInfoProvider.CombineWithDefaultCulture(siteName)), ""); } } else { // Textbox is enabled txtKeywords.Enabled = true; } }
private void ReloadData() { if (node != null) { bool isRoot = (node.NodeAliasPath == "/"); // Check read permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath)); } // Check modify permissions else if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { hasModifyPermission = false; pnlForm.Enabled = false; tagSelectorElem.Enabled = false; lblWorkflowInfo.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), node.NodeAliasPath); } TreeNode tmpNode = node.Clone(); // If values are inherited set nulls tmpNode.SetValue("DocumentPageTitle", DBNull.Value); tmpNode.SetValue("DocumentPageKeyWords", DBNull.Value); tmpNode.SetValue("DocumentPageDescription", DBNull.Value); tmpNode.SetValue("DocumentTagGroupID", DBNull.Value); // Load the inherited values SiteInfo si = SiteInfoProvider.GetSiteInfo(node.NodeSiteID); if (si != null) { tmpNode.LoadInheritedValues(new string[] { "DocumentPageTitle", "DocumentPageKeyWords", "DocumentPageDescription", "DocumentTagGroupID" }, SiteInfoProvider.CombineWithDefaultCulture(si.SiteName)); } if (!pnlUIPage.IsHidden) { // Page title if (node.GetValue("DocumentPageTitle") != null) { txtTitle.Text = node.GetValue("DocumentPageTitle").ToString(); } else { if (!isRoot) { txtTitle.Enabled = false; chkTitle.Checked = true; txtTitle.Text = ValidationHelper.GetString(tmpNode.GetValue("DocumentPageTitle"), ""); } } // Page key words if (node.GetValue("DocumentPageKeyWords") != null) { txtKeywords.Text = node.GetValue("DocumentPageKeyWords").ToString(); } else { if (!isRoot) { txtKeywords.Enabled = false; chkKeyWords.Checked = true; txtKeywords.Text = ValidationHelper.GetString(tmpNode.GetValue("DocumentPageKeyWords"), ""); } } // Page description if (node.GetValue("DocumentPageDescription") != null) { txtDescription.Text = node.GetValue("DocumentPageDescription").ToString(); } else { if (!isRoot) { txtDescription.Enabled = false; chkDescription.Checked = true; txtDescription.Text = ValidationHelper.GetString(tmpNode.GetValue("DocumentPageDescription"), ""); } } } if (!pnlUITags.IsHidden) { // Tag group if (node.GetValue("DocumentTagGroupID") != null) { object tagGroupId = node.GetValue("DocumentTagGroupID"); tagGroupSelectorElem.Value = tagGroupId; } else { if (!isRoot) { // Get the inherited tag group int tagGroup = ValidationHelper.GetInteger(tmpNode.GetValue("DocumentTagGroupID"), 0); if (tagGroup > 0) { tagGroupSelectorElem.Value = tagGroup; } else { tagGroupSelectorElem.AddNoneItemsRecord = true; } tagGroupSelectorElem.Enabled = false; chkTagGroupSelector.Checked = true; } else { // Add 'none' option to Root document tagGroupSelectorElem.AddNoneItemsRecord = true; } } // Tags tagSelectorElem.Value = node.DocumentTags; } } }
/// <summary> /// Logs rating activity /// </summary> /// <param name="value">Rating value</param> private void LogActivity(double value) { if ((CMSContext.ViewMode != ViewModeEnum.LiveSite) || !ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser)) { return; } string siteName = CMSContext.CurrentSiteName; if (!ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(siteName) || !ActivitySettingsHelper.ContentRatingEnabled(siteName)) { return; } bool logActivity = false; TreeNode currentDoc = CMSContext.CurrentDocument; if (currentDoc != null) { if (CMSContext.CurrentDocument.DocumentLogVisitActivity == null) { logActivity = ValidationHelper.GetBoolean(currentDoc.GetInheritedValue("DocumentLogVisitActivity", SiteInfoProvider.CombineWithDefaultCulture(siteName)), false); } else { logActivity = currentDoc.DocumentLogVisitActivity == true; } if (logActivity) { var data = new ActivityData() { ContactID = ModuleCommands.OnlineMarketingGetCurrentContactID(), SiteID = CMSContext.CurrentSiteID, Type = PredefinedActivityType.RATING, TitleData = String.Format("{0} ({1})", value.ToString(), currentDoc.DocumentName), URL = URLHelper.CurrentRelativePath, NodeID = currentDoc.NodeID, Value = value.ToString(), Culture = currentDoc.DocumentCulture, Campaign = CMSContext.Campaign }; ActivityLogProvider.LogActivity(data); } } }
/// <summary> /// Displays the report /// </summary> /// <param name="reload">If true display reload control is reloaded</param> private void DisplayReport(bool reload) { ucGraphType.ProcessChartSelectors(false); // Prepare report parameters DataTable dtp = new DataTable(); dtp.Columns.Add("FromDate", typeof(DateTime)); dtp.Columns.Add("ToDate", typeof(DateTime)); dtp.Columns.Add("CodeName", typeof(string)); dtp.Columns.Add("MVTestName", typeof(string)); dtp.Columns.Add("ConversionName", typeof(string)); dtp.Columns.Add("CombinationName", typeof(string)); object[] parameters = new object[6]; parameters[0] = ucGraphType.From; parameters[1] = ucGraphType.To; parameters[2] = ""; parameters[3] = ValidationHelper.GetString(ucMVTests.Value, String.Empty); // Conversion String conversion = ValidationHelper.GetString(ucConversions.Value, String.Empty); if (conversion == ucConversions.AllRecordValue) { conversion = String.Empty; } parameters[4] = ValidationHelper.GetString(conversion, String.Empty); // Combination String combination = ValidationHelper.GetString(usCombination.Value, String.Empty); if (combination == usCombination.AllRecordValue) { combination = String.Empty; } parameters[5] = ValidationHelper.GetString(combination, String.Empty); dtp.Rows.Add(parameters); dtp.AcceptChanges(); string reportName = ucGraphType.GetReportName(QueryHelper.GetString("reportCodeName", String.Empty)); // Hide show selectors by report name if (reportName.Contains("mvtestconversionsbycombinations")) { pnlConversion.Visible = false; } else { pnlCultures.Visible = false; pnlCombination.Visible = false; } // Load conversion by mvt code name if (pnlConversion.Visible) { ucConversions.MVTestName = ValidationHelper.GetString(ucMVTests.Value, String.Empty); ucConversions.PostbackOnDropDownChange = true; ucConversions.ReloadData(true); } // Load combination by mvt name if (pnlCombination.Visible) { string name = ValidationHelper.GetString(ucMVTests.Value, String.Empty); if ((name != String.Empty) && (name != ucMVTests.AllRecordValue)) { string cultureWhere = String.Empty; string siteName = CMSContext.CurrentSiteName; MVTestInfo mvt = MVTestInfoProvider.GetMVTestInfo(name, siteName); if (mvt != null) { string culture = ValidationHelper.GetString(usCulture.Value, String.Empty); if ((culture != String.Empty) && (culture != usCulture.AllRecordValue)) { cultureWhere = " AND DocumentCulture = '" + culture.Replace("'", "''") + "'"; } // Get the used page template column string colName = "DocumentPageTemplateID"; PageInfo pi = PageInfoProvider.GetPageInfo(siteName, mvt.MVTestPage, culture, null, SiteInfoProvider.CombineWithDefaultCulture(siteName)); if (pi != null) { colName = pi.GetUsedPageTemplateIdColumn(); } // Prepare where condition string where = String.Format("MVTCombinationPageTemplateID IN (SELECT {0} FROM View_CMS_Tree_Joined WHERE NodeSiteID = {1} AND NodeAliasPath ='{2}'{3})", colName, CMSContext.CurrentSiteID, mvt.MVTestPage, cultureWhere); usCombination.WhereCondition = SqlHelperClass.AddWhereCondition(usCombination.WhereCondition, where); usCombination.ReloadData(true); } } } // Set report ucDisplayReport.ReportName = reportName; if (!ucDisplayReport.IsReportLoaded()) { ShowError(String.Format(GetString("Analytics_Report.ReportDoesnotExist"), reportName)); } else { ucDisplayReport.LoadFormParameters = false; ucDisplayReport.DisplayFilter = false; ucDisplayReport.ReportParameters = dtp.Rows[0]; ucDisplayReport.GraphImageWidth = 100; ucDisplayReport.IgnoreWasInit = true; ucDisplayReport.UseExternalReload = true; ucDisplayReport.UseProgressIndicator = true; ucDisplayReport.SelectedInterval = HitsIntervalEnumFunctions.HitsConversionToString(ucGraphType.SelectedInterval); // Reload data only if parameter is set if (reload) { ucDisplayReport.ReloadData(true); } } }
/// <summary> /// Setups checkbox for inheriting value. /// </summary> /// <param name="fieldName">Name of field which can have inherited value</param> private void SetupInheritCheckbox(string fieldName) { CMSCheckBox checkBox = GetCheckBox(fieldName); if (checkBox == null) { return; } checkBox.AutoPostBack = true; checkBox.CheckedChanged += checkBox_CheckedChanged; // Check if node has saved some value if ((Node.GetValue(fieldName) == null) && (!URLHelper.IsPostback())) { checkBox.Checked = true; // Init inherited value FormEngineUserControl mainControl = Control.FieldControls[fieldName]; if (!String.IsNullOrEmpty(Node.NodeSiteName) && (mainControl != null)) { mainControl.Text = ValidationHelper.GetString(Node.GetInheritedValue(fieldName, SiteInfoProvider.CombineWithDefaultCulture(Node.NodeSiteName)), ""); mainControl.Enabled = false; } } }
/// <summary> /// Raises the <see cref="E:Init"/> event. /// </summary> protected override void OnInit(EventArgs e) { if (!MembershipContext.AuthenticatedUser.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) { 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)); 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.SubmitButton.Visible = false; editElem.UIFormControl.OnBeforeSave += UIFormControl_OnBeforeSaved; }
private bool CheckValidationVisibility(string mode, int nodeId) { CurrentUserInfo curUser = CMSContext.CurrentUser; string siteName = CMSContext.CurrentSiteName; if (curUser.IsAuthorizedPerUIElement("CMS.Content", "Validation", siteName)) { TreeProvider tree = new TreeProvider(curUser); bool combineWithDefaultCulture = tree.CombineWithDefaultCulture; // Get the document TreeNode node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode, combineWithDefaultCulture); if (node != null) { if (VALIDATION_EXCLUDED_CLASS_NAMES.Contains(";" + node.NodeClassName.ToLower() + ";")) { return(false); } // Check the document availability else if (!node.DocumentCulture.Equals(CMSContext.PreferredCultureCode, StringComparison.InvariantCultureIgnoreCase) && (!SiteInfoProvider.CombineWithDefaultCulture(siteName) || !node.DocumentCulture.Equals(CultureHelper.GetDefaultCulture(siteName), StringComparison.InvariantCultureIgnoreCase)) || ((mode == "livesite") && !node.IsPublished)) { return(false); } } else { return(false); } } else { return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { const string CONTENT_CMSDESK_FOLDER = "~/CMSModules/Content/CMSDesk/"; // Register script files ScriptHelper.RegisterScriptFile(this, CONTENT_CMSDESK_FOLDER + "EditTabs.js"); bool checkCulture = false; bool splitViewSupported = false; string action = QueryHelper.GetString("action", "edit").ToLowerCSafe(); switch (action) { // New dialog / new page form case "new": int classId = QueryHelper.GetInteger("classid", 0); if (classId <= 0) { // Get by class name if specified string className = QueryHelper.GetString("classname", string.Empty); if (className != string.Empty) { classInfo = DataClassInfoProvider.GetDataClassInfo(className); if (classInfo != null) { classId = classInfo.ClassID; } } } const string EC_PRODUCTS_FOLDER = "~/CMSModules/Ecommerce/Pages/Tools/Products/"; if (classId > 0) { viewpage = ResolveUrl(CONTENT_CMSDESK_FOLDER + "Edit/Edit.aspx"); // Check if document type is allowed under parent node if (parentNodeID > 0) { // Get the node TreeNode = Tree.SelectSingleNode(parentNodeID, TreeProvider.ALL_CULTURES); if (TreeNode != null) { if (!DocumentHelper.IsDocumentTypeAllowed(TreeNode, classId)) { viewpage = CONTENT_CMSDESK_FOLDER + "NotAllowed.aspx?action=child"; } } } // Use product page when product type is selected classInfo = classInfo ?? DataClassInfoProvider.GetDataClassInfo(classId); if ((classInfo != null) && (classInfo.ClassIsProduct)) { viewpage = ResolveUrl(EC_PRODUCTS_FOLDER + "Product_New.aspx"); } } else { if (parentNodeID > 0) { viewpage = EC_PRODUCTS_FOLDER + "New_ProductOrSection.aspx"; } else { viewpage = EC_PRODUCTS_FOLDER + "Product_New.aspx?parentNodeId=0"; } } break; case "delete": // Delete dialog viewpage = CONTENT_CMSDESK_FOLDER + "Delete.aspx"; break; default: // Edit mode viewpage = CONTENT_CMSDESK_FOLDER + "Edit/edit.aspx?mode=editform"; splitViewSupported = true; // Ensure class info if ((classInfo == null) && (Node != null)) { classInfo = DataClassInfoProvider.GetDataClassInfo(Node.NodeClassName); } // Check explicit editing page url if ((classInfo != null) && !string.IsNullOrEmpty(classInfo.ClassEditingPageURL)) { viewpage = URLHelper.AppendQuery(ResolveUrl(classInfo.ClassEditingPageURL), RequestContext.CurrentQueryString); } checkCulture = true; break; } // If culture version should be checked, check if (checkCulture) { // Check (and ensure) the proper content culture if (!CheckPreferredCulture()) { RefreshParentWindow(); } // Check split mode bool isSplitMode = PortalUIHelper.DisplaySplitMode; bool combineWithDefaultCulture = !isSplitMode && SiteInfoProvider.CombineWithDefaultCulture(SiteContext.CurrentSiteName); var nodeId = QueryHelper.GetInteger("nodeid", 0); TreeNode = Tree.SelectSingleNode(nodeId, CultureCode, combineWithDefaultCulture); if (TreeNode == null) { // Document does not exist -> redirect to new culture version creation dialog viewpage = ProductUIHelper.GetNewCultureVersionPageUrl(); } } // Apply the additional transformations to the view page URL viewpage = URLHelper.AppendQuery(viewpage, RequestContext.CurrentQueryString); viewpage = URLHelper.RemoveParameterFromUrl(viewpage, "mode"); viewpage = URLHelper.AddParameterToUrl(viewpage, "mode", "productssection"); viewpage = ResolveUrl(viewpage); viewpage = URLHelper.AddParameterToUrl(viewpage, "hash", QueryHelper.GetHash(viewpage)); // Split mode enabled if (splitViewSupported && PortalUIHelper.DisplaySplitMode && (TreeNode != null) && (action == "edit" || action == "preview" || (TreeNode.IsPublished && action == "livesite"))) { viewpage = DocumentUIHelper.GetSplitViewUrl(viewpage); } URLHelper.Redirect(UrlResolver.ResolveUrl(viewpage)); }
protected void Page_Load(object sender, EventArgs e) { // Register script files ltlScript.Text += ScriptHelper.GetIncludeScript("~/CMSModules/Content/CMSDesk/ContentEditFrameset.js"); int classId = 0; bool checkCulture = false; bool splitViewSupported = false; nodeId = QueryHelper.GetInteger("nodeid", 0); string action = QueryHelper.GetString("action", "edit").ToLower(); switch (action) { // New dialog / new page form case "new": classId = QueryHelper.GetInteger("classid", 0); if (classId <= 0) { // Get by class name if specified string className = QueryHelper.GetString("classname", string.Empty); if (className != string.Empty) { DataClassInfo ci = DataClassInfoProvider.GetDataClass(className); if (ci != null) { classId = ci.ClassID; } } } if (classId > 0) { viewpage = "Edit/EditFrameset.aspx"; // Check if document type is allowed under parent node if (nodeId > 0) { // Get the node TreeNode = Tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); if (TreeNode != null) { if (!DataClassInfoProvider.IsChildClassAllowed(ValidationHelper.GetInteger(TreeNode.GetValue("NodeClassID"), 0), classId)) { viewpage = "NotAllowed.aspx?action=child"; } } } } else { viewpage = "New/new.aspx"; } break; case "newvariant": viewpage = "Edit/EditFrameset.aspx"; break; case "delete": // Delete dialog viewpage = "Delete.aspx"; break; case "preview": checkCulture = true; string previewUrl = null; TreeNode = Tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); if (TreeNode != null) { classId = ValidationHelper.GetInteger(TreeNode.GetValue("NodeClassID"), 0); DataClassInfo ci = DataClassInfoProvider.GetDataClass(classId); if (ci != null) { if (!string.IsNullOrEmpty(ci.ClassPreviewPageUrl)) { previewUrl = ci.ClassPreviewPageUrl; } } } // Preview mode if (CheckValidationVisibility(action, nodeId)) { if (String.IsNullOrEmpty(previewUrl)) { previewUrl = "preview.aspx"; } viewpage = URLHelper.AddParameterToUrl("View/ViewValidate.aspx", "viewpage", previewUrl); } else { if (String.IsNullOrEmpty(previewUrl)) { previewUrl = "View/preview.aspx"; } viewpage = previewUrl; splitViewSupported = true; } break; case "listing": // Listing mode viewpage = "View/listing.aspx"; TreeNode = Tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); if (TreeNode != null) { classId = ValidationHelper.GetInteger(TreeNode.GetValue("NodeClassID"), 0); DataClassInfo ci = DataClassInfoProvider.GetDataClass(classId); if (ci != null) { if (!string.IsNullOrEmpty(ci.ClassListPageURL)) { viewpage = ci.ClassListPageURL; } } } break; case "livesite": checkCulture = true; // Live site mode if (CheckValidationVisibility(action, nodeId)) { viewpage = URLHelper.AddParameterToUrl("View/ViewValidate.aspx", "viewpage", "livesite.aspx"); } else { viewpage = "View/livesite.aspx"; splitViewSupported = true; } break; case "newculture": // New document culture viewpage = "Edit/EditFrameset.aspx"; break; default: // Edit mode viewpage = "Edit/EditFrameset.aspx"; checkCulture = true; break; } // If culture version should be checked, check if (checkCulture) { // Check (and ensure) the proper content culture CheckPreferredCulture(true); // Check split mode bool isSplitMode = CMSContext.DisplaySplitMode; bool combineWithDefaultCulture = !isSplitMode && SiteInfoProvider.CombineWithDefaultCulture(CMSContext.CurrentSiteName); TreeNode = Tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode, combineWithDefaultCulture); if (TreeNode == null) { if ((action == "preview") || (action == "livesite")) { viewpage = "~/CMSMessages/PageNotAvailable.aspx?reason=splitviewmissingculture&showlink=false"; } else { // Document does not exist -> redirect to new culture version creation dialog viewpage = "Edit/NewCultureVersion.aspx"; } } } // Apply the additional transformations to the view page URL viewpage = URLHelper.AppendQuery(viewpage, URLHelper.Url.Query); viewpage = ResolveUrl(viewpage); viewpage = URLHelper.AddParameterToUrl(viewpage, "hash", QueryHelper.GetHash(viewpage)); // Split mode enabled if (splitViewSupported && CMSContext.DisplaySplitMode && (TreeNode != null) && (action == "preview" || (TreeNode.IsPublished && action == "livesite"))) { viewpage = GetSplitViewUrl(viewpage); } }
/// <summary> /// Checks if page visit activity logging is enabled, if so returns contact ID. /// </summary> /// <param name="file">File to be sent</param> /// <param name="contactId">Current contact ID</param> protected bool LoggingActivityEnabled(CMSOutputFile file, out int contactId) { contactId = 0; if ((file == null) || (file.FileNode == null)) { return(false); } // Check if logging is enabled if (ActivitySettingsHelper.ActivitiesEnabledAndModuleLoaded(CurrentSiteName) && ActivitySettingsHelper.ActivitiesEnabledForThisUser(CMSContext.CurrentUser) && ActivitySettingsHelper.PageVisitsEnabled(CurrentSiteName)) { if (file.Attachment != null) { // Get allowed extensions (if not specified log everything) bool doLog = true; string tracked = SettingsKeyProvider.GetStringValue(CurrentSiteName + ".CMSActivityTrackedExtensions"); if (!String.IsNullOrEmpty(tracked)) { string extension = file.Attachment.AttachmentExtension; if (extension != null) { string extensions = String.Format(";{0};", tracked.ToLower().Trim().Trim(';')); extension = extension.TrimStart('.').ToLower(); doLog = extensions.Contains(String.Format(";{0};", extension)); } } if (doLog) { // Check if logging is enabled for current document TreeNode fileNode = file.FileNode; if ((fileNode != null) && ((fileNode.DocumentLogVisitActivity == true) || (fileNode.DocumentLogVisitActivity == null) && ValidationHelper.GetBoolean(fileNode.GetInheritedValue("DocumentLogVisitActivity", SiteInfoProvider.CombineWithDefaultCulture(CurrentSiteName)), false))) { contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); return(contactId > 0); } } } } return(false); }
protected void Page_Load(object sender, EventArgs e) { // Switch the view mode CMSContext.ViewMode = ViewModeEnum.LiveSite; // Get the document int nodeId = 0; if (Request.QueryString["nodeid"] != null) { nodeId = ValidationHelper.GetInteger(Request.QueryString["nodeid"], 0); } string siteName = CMSContext.CurrentSiteName; TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); TreeNode node = null; // Check split mode bool isSplitMode = CMSContext.DisplaySplitMode; bool combineWithDefaultCulture = isSplitMode ? false : SiteInfoProvider.CombineWithDefaultCulture(siteName); // Get the document node = tree.SelectSingleNode(nodeId, CMSContext.PreferredCultureCode, combineWithDefaultCulture); // Redirect to the live URL string url = null; if (node != null) { // Check if the node is published or available if (!node.DocumentCulture.Equals(CMSContext.PreferredCultureCode, StringComparison.InvariantCultureIgnoreCase) && (!SiteInfoProvider.CombineWithDefaultCulture(siteName) || !node.DocumentCulture.Equals(CultureHelper.GetDefaultCulture(siteName), StringComparison.InvariantCultureIgnoreCase))) { url = "~/CMSMessages/PageNotAvailable.aspx?reason=missingculture"; } if ((url == null) && !node.IsPublished && URLRewriter.PageNotFoundForNonPublished(siteName)) { // Try to find published document in default culture if (SiteInfoProvider.CombineWithDefaultCulture(siteName)) { string defaultCulture = CultureHelper.GetDefaultCulture(siteName); node = tree.SelectSingleNode(nodeId, defaultCulture, false); if ((node != null) && node.IsPublished) { // Do not use document URL path - preferred culture could be changed url = CMSContext.GetUrl(node.NodeAliasPath, null); } } if (url == null) { // Document is not published url = "~/CMSMessages/PageNotAvailable.aspx?reason=notpublished"; } } } else { url = isSplitMode ? "~/CMSModules/Content/CMSDesk/New/NewCultureVersion.aspx" + URLHelper.Url.Query : "~/CMSMessages/PageNotAvailable.aspx?reason=missingculture&showlink=false"; } if (url == null) { // Do not use document URL path - preferred culture could be changed url = CMSContext.GetUrl(node.NodeAliasPath, null); } // Split mode if (CMSContext.DisplaySplitMode) { url = URLHelper.AddParameterToUrl(url, "cmssplitmode", "1"); } URLHelper.Redirect(url); }