/// <summary> /// Generate properties. /// </summary> protected void GenerateProperties(FormInfo fi) { ltlProperties.Text = String.Empty; // Generate script to display and hide properties groups ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ShowHideProperties", ScriptHelper.GetScript(@" function ShowHideProperties(id) { var obj = document.getElementById(id); var objlink = document.getElementById(id+'_link'); if ((obj != null)&&(objlink != null)){ if (obj.style.display == 'none' ) { obj.style.display=''; objlink.innerHTML = '<img border=""0"" src=""" + minImg + @""" >'; } else {obj.style.display='none'; objlink.innerHTML = '<img border=""0"" src=""" + plImg + @""" >';} objlink.blur();}}")); // Get defintion elements var infos = fi.GetFormElements(true, false); bool isOpenSubTable = false; bool firstLoad = true; bool hasAnyProperties = false; string currentGuid = ""; string newCategory = null; // Check all items in object array foreach (IDataDefinitionItem contrl in infos) { // Generate row for form category if (contrl is FormCategoryInfo) { // Load castegory info FormCategoryInfo fci = contrl as FormCategoryInfo; if (fci != null) { if (isOpenSubTable) { ltlProperties.Text += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\"> </td><td colspan=\"2\" class=\"Center\"> </td><td class=\"PropertyRightBottom\"> </td></tr></table>"; isOpenSubTable = false; } if (currentGuid == "") { currentGuid = Guid.NewGuid().ToString().Replace("-", "_"); } // Generate properties content newCategory = @"<br /> <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable""> <tr> <td class=""CategoryLeftBorder""> </td> <td class=""CategoryTextCell"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(fci.GetPropertyValue(FormCategoryPropertyEnum.Caption, MacroContext.CurrentResolver))) + @"</td> <td class=""HiderCell""> <a id=""" + currentGuid + "_link\" href=\"#\" onclick=\"ShowHideProperties('" + currentGuid + @"'); return false;""> <img border=""0"" src=""" + minImg + @""" ></a> </td> <td class=""CategoryRightBorder""> </td> </tr> </table>"; } } else { hasAnyProperties = true; // Get form field info FormFieldInfo ffi = contrl as FormFieldInfo; if (ffi != null) { // If display only in dashboard and not dashbord zone (or none for admins) dont show if ((ffi.DisplayIn == "dashboard") && ((zoneType != WidgetZoneTypeEnum.Dashboard) && (zoneType != WidgetZoneTypeEnum.None))) { continue; } if (newCategory != null) { ltlProperties.Text += newCategory; newCategory = null; firstLoad = false; } else if (firstLoad) { if (currentGuid == "") { currentGuid = Guid.NewGuid().ToString().Replace("-", "_"); } // Generate properties content firstLoad = false; ltlProperties.Text += @"<br /> <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable""> <tr> <td class=""CategoryLeftBorder""> </td> <td class=""CategoryTextCell"">Default</td> <td class=""HiderCell""> <a id=""" + currentGuid + "_link\" href=\"#\" onclick=\"ShowHideProperties('" + currentGuid + @"'); return false;""> <img border=""0"" src=""" + minImg + @""" ></a> </td> <td class=""CategoryRightBorder""> </td> </tr> </table>"; } if (!isOpenSubTable) { isOpenSubTable = true; ltlProperties.Text += "" + "<table cellpadding=\"0\" cellspacing=\"0\" id=\"" + currentGuid + "\" class=\"PropertiesTable\" >"; currentGuid = ""; } string fieldCaption = DataHelper.GetNotEmpty( ResHelper.LocalizeString(ffi.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, MacroContext.CurrentResolver)), String.Empty ); string fieldDescription = DataHelper.GetNotEmpty( ResHelper.LocalizeString(ffi.GetPropertyValue(FormFieldPropertyEnum.FieldDescription, MacroContext.CurrentResolver)), GetString("WebPartDocumentation.DescriptionNoneAvailable") ); string doubleDot = ""; if (!String.IsNullOrEmpty(fieldCaption) && !fieldCaption.EndsWith(":", StringComparison.InvariantCulture)) { doubleDot = ":"; } ltlProperties.Text += @"<tr> <td class=""PropertyLeftBorder"" > </td> <td class=""PropertyContent"" style=""width:200px;"">" + HTMLHelper.HTMLEncode(fieldCaption) + doubleDot + @"</td> <td class=""PropertyRow"">" + HTMLHelper.HTMLEncode(fieldDescription) + @"</td> <td class=""PropertyRightBorder""> </td> </tr>"; } } } if (isOpenSubTable) { ltlProperties.Text += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\"> </td><td colspan=\"2\" class=\"Center\"> </td><td class=\"PropertyRightBottom\"> </td></tr></table>"; } if (!hasAnyProperties) { ltlProperties.Text = "<br /><div style=\"padding-left:5px;padding-right:5px; font-weight: bold;\">" + GetString("documentation.nopropertiesavaible") + "</div>"; } }
protected void Page_Load(object sender, EventArgs e) { // Register script for unimenu button selection AddMenuButtonSelectScript(this, "Contacts", null, "menu"); // Get current user info CurrentUserInfo user = CMSContext.CurrentUser; // Get contact info object ContactInfo ci = (ContactInfo)EditedObject; if (ci == null) { return; } // Check permission read ContactHelper.AuthorizedReadContact(ci.ContactSiteID, true); // Check if running under site manager (and distribute "site manager" flag to other tabs) string siteManagerParam = string.Empty; if (IsSiteManager) { siteManagerParam = "&issitemanager=1"; } // Set default help topic SetHelp("onlinemarketing_contact_general", "helpTopic"); // register scripts in modal dialog if (isDialogMode) { RegisterModalPageScripts(); } string append = null; if (ci.ContactMergedWithContactID != 0) { // Append '(merged)' behind contact name in breadcrumbs append = " " + GetString("om.contact.mergedsuffix"); } else if (ci.ContactSiteID == 0) { // Append '(global)' behind contact name in breadcrumbs append = " " + GetString("om.contact.globalsuffix"); } // Modify header appearance in modal dialog (display title instead of breadcrumbs) if (QueryHelper.GetBoolean("dialogmode", false)) { CurrentMaster.Title.TitleText = GetString("om.contact.edit") + " - " + HTMLHelper.HTMLEncode(ContactInfoProvider.GetContactFullName(ci)) + append; CurrentMaster.Title.TitleImage = GetImageUrl("Objects/OM_Contact/object.png"); } else { // Get url for breadcrumbs string url = ResolveUrl("~/CMSModules/ContactManagement/Pages/Tools/Contact/List.aspx"); url = URLHelper.AddParameterToUrl(url, "siteid", SiteID.ToString()); if (IsSiteManager) { url = URLHelper.AddParameterToUrl(url, "issitemanager", "1"); } CurrentPage.InitBreadcrumbs(2); CurrentPage.SetBreadcrumb(0, GetString("om.contact.list"), url, "_parent", null); CurrentPage.SetBreadcrumb(1, ContactInfoProvider.GetContactFullName(ci) + append, null, null, null); } // Check if contact has any custom fields int i = 0; FormInfo formInfo = FormHelper.GetFormInfo(ci.Generalized.DataClass.ClassName, false); if (formInfo.GetFormElements(true, false, true).Any()) { i = 1; } int contactId = ci.ContactID; bool ipTabAvailable = ActivitySettingsHelper.IPLoggingEnabled(CMSContext.CurrentSiteName) || ContactHelper.IsSiteManager; int counter = 0; // Initialize tabs InitTabs("content"); SetTab(counter++, GetString("general.general"), "Tab_General.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_general');"); if (i > 0) { // Add tab for custom fields SetTab(counter++, GetString("general.customfields"), "Tab_CustomFields.aspx?contactid=" + ci.ContactID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_customfields');"); } if (AccountHelper.AuthorizedReadAccount(ci.ContactSiteID, false) || ContactHelper.AuthorizedReadContact(ci.ContactSiteID, false)) { SetTab(counter++, GetString("om.account.list"), "Tab_Accounts.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_accounts');"); } SetTab(counter++, GetString("om.membership.list"), "Membership/Tab_Membership.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_membership');"); SetTab(counter++, GetString("om.activity.list"), "Tab_Activities.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_activities');"); if (ipTabAvailable) { SetTab(counter++, GetString("om.activity.iplist"), "Tab_IPs.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_ips');"); } // Show contact groups SetTab(counter++, GetString("om.contactgroup.list"), "Tab_ContactGroups.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_contactgroups');"); // Show scoring tab for site contacts if (ci.ContactSiteID > 0) { SetTab(counter++, GetString("om.score.list"), "Tab_Scoring.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_scoring');"); } // Hide last 3 tabs if the contact is merged if (ci.ContactMergedWithContactID == 0) { SetTab(counter++, GetString("om.contact.merge"), "Tab_Merge.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_merge');"); } // Data.com SetTab(counter++, "Data.com", "Tab_DataCom.aspx?contactid=" + contactId + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_contact_datacom');"); // Marketing automation if (WorkflowInfoProvider.IsMarketingAutomationAllowed()) { string stateUrl = String.Format("{0}?objectid={1}{2}", "Tab_Processes.aspx", contactId, siteManagerParam); SetTab(counter++, GetString("ma.contact.processes"), stateUrl, "SetHelpTopic('helpTopic', 'automation_state_list');"); } }
/// <summary> /// Loads data. /// </summary> private void LoadData() { // Initialize properties ArrayList itemList = null; FormFieldInfo formField = null; attributes.Clear(); // Load DataClass dci = DataClassInfoProvider.GetDataClass(this.ItemID); DataClassInfo tree = null; // For 'cms.document' add 'ecommerce.sku' fields, too if ((dci != null) && (dci.ClassName == "cms.document")) { // For 'cms.document' add 'ecommerce.sku' fields, too tree = DataClassInfoProvider.GetDataClass("ecommerce.sku"); if (tree != null) { // Load XML definition fi = FormHelper.GetFormInfo(tree.ClassName, false); // Get all fields itemList = fi.GetFormElements(true, true); } if (itemList != null) { // Store each field to array foreach (object item in itemList) { if (item is FormFieldInfo) { formField = ((FormFieldInfo)(item)); object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) }; attributes.Add(obj); } } } } if (dci != null) { // Load XML definition fi = FormHelper.GetFormInfo(dci.ClassName, false); // Get all fields itemList = fi.GetFormElements(true, true); ss = new SearchSettings(); ss.LoadData(dci.ClassSearchSettings); } if (itemList != null) { // Store each field to array foreach (object item in itemList) { if (item is FormFieldInfo) { formField = ((FormFieldInfo)(item)); object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) }; attributes.Add(obj); } } } // For 'cms.document' add 'cms.tree' fields, too if ((dci != null) && (dci.ClassName == "cms.document")) { tree = DataClassInfoProvider.GetDataClass("cms.tree"); if (tree != null) { // Load XML definition fi = FormHelper.GetFormInfo(tree.ClassName, false); // Get all fields itemList = fi.GetFormElements(true, true); } if (itemList != null) { // Store each field to array foreach (object item in itemList) { if (item is FormFieldInfo) { formField = ((FormFieldInfo)(item)); object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) }; attributes.Add(obj); } } } } // For 'cms.user' add 'cms.usersettings' fields, too if ((dci != null) && (dci.ClassName.ToLower() == "cms.user")) { tree = DataClassInfoProvider.GetDataClass("cms.usersettings"); if (tree != null) { // Load XML definition fi = FormHelper.GetFormInfo(tree.ClassName, false); // Get all fields itemList = fi.GetFormElements(true, true); } if (itemList != null) { // Store each field to array foreach (object item in itemList) { if (item is FormFieldInfo) { formField = ((FormFieldInfo)(item)); object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) }; attributes.Add(obj); } } } } }
/// <summary> /// Generate document content. /// </summary> /// <param name="wpi">WebPart info</param> /// <param name="gd">Guid</param> /// <param name="category">Category</param> protected void GenerateDocContent(FormInfo fi) { if (fi == null) { return; } // Get defintion elements ArrayList infos = fi.GetFormElements(true, false); bool isOpenSubTable = false; string currentGuid = ""; // Used for filter empty categories String categoryHeader = String.Empty; // Check all items in object array foreach (object contrl in infos) { // Generate row for form category if (contrl is FormCategoryInfo) { // Load castegory info FormCategoryInfo fci = contrl as FormCategoryInfo; if (fci != null) { // Close table from last category if (isOpenSubTable) { content += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\"> </td><td colspan=\"2\" class=\"Center\"> </td><td class=\"PropertyRightBottom\"> </td></tr></table>"; isOpenSubTable = false; } if (currentGuid == "") { currentGuid = Guid.NewGuid().ToString().Replace("-", "_"); } // Generate table for current category categoryHeader = @"<br /> <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable""> <tr> <td class=""CategoryLeftBorder""> </td> <td class=""CategoryTextCell"">" + HTMLHelper.HTMLEncode(fci.CategoryName) + @"</td> <td class=""CategoryRightBorder""> </td> </tr> </table>"; } } else { // Get form field info FormFieldInfo ffi = contrl as FormFieldInfo; if (ffi != null) { if (categoryHeader != String.Empty) { content += categoryHeader; categoryHeader = String.Empty; } if (!isOpenSubTable) { // Generate table for properties under one category isOpenSubTable = true; content += "" + "<table cellpadding=\"0\" cellspacing=\"0\" id=\"_" + currentGuid + "\" class=\"PropertiesTable\" >"; currentGuid = ""; } // Add ':' to caption string doubleDot = ""; if (!ffi.Caption.EndsWith(":")) { doubleDot = ":"; } content += @"<tr> <td class=""PropertyLeftBorder"" > </td> <td class=""PropertyContent"" style=""width:200px;"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ffi.Caption)) + doubleDot + @"</td> <td class=""PropertyRow"">" + HTMLHelper.HTMLEncode(resolver.ResolveMacros(DataHelper.GetNotEmpty(ffi.Description, GetString("WebPartDocumentation.DescriptionNoneAvailable")))) + @"</td> <td class=""PropertyRightBorder""> </td> </tr>"; if (ffi.Description == null || ffi.Description.Trim() == "") { undocumentedProperties++; } } } } // Close last category (if has any properties) if (isOpenSubTable) { content += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\"> </td><td colspan=\"2\" class=\"Center\"> </td><td class=\"PropertyRightBottom\"> </td></tr></table>"; } }
/// <summary> /// Initializes controls for activity rule. /// </summary> private void InitActivityRuleControls(string selectedActivityType) { ucActivityType.OnSelectedIndexChanged += new EventHandler(ucActivityType_OnSelectedIndexChanged); // Init activity selector from edited object if any string activityType = selectedActivityType; if ((EditForm.EditedObject != null) && !RequestHelper.IsPostBack()) { ucActivityType.Value = ValidationHelper.GetString(EditForm.Data["RuleParameter"], PredefinedActivityType.ABUSE_REPORT); activityType = ucActivityType.SelectedValue; PreviousActivityType = activityType; } // List of ignored columns string ignoredColumns = "|activitytype|activitysiteid|activityguid|activityactivecontactid|activityoriginalcontactid|pagevisitid|pagevisitactivityid|searchid|searchactivityid|"; // List of activities with "ActivityValue" StringBuilder sb = new StringBuilder(); sb.Append("|"); sb.Append(PredefinedActivityType.PURCHASE); sb.Append("|"); sb.Append(PredefinedActivityType.PURCHASEDPRODUCT); sb.Append("|"); sb.Append(PredefinedActivityType.RATING); sb.Append("|"); sb.Append(PredefinedActivityType.POLL_VOTING); sb.Append("|"); sb.Append(PredefinedActivityType.PRODUCT_ADDED_TO_SHOPPINGCART); sb.Append("|"); string showActivityValueFor = sb.ToString(); // Get columns from OM_Activity (i.e. base table for all activities) ActivityTypeInfo ati = ActivityTypeInfoProvider.GetActivityTypeInfo(activityType); FormInfo fi = new FormInfo(null); // Get columns from additional table (if any) according to selected activity type (page visit, search) FormInfo additionalFieldsForm = null; bool extraFieldsAtEnd = true; switch (activityType) { case PredefinedActivityType.PAGE_VISIT: case PredefinedActivityType.LANDING_PAGE: // Page visits additionalFieldsForm = FormHelper.GetFormInfo(OnlineMarketingObjectType.PAGEVISIT, false); break; case PredefinedActivityType.INTERNAL_SEARCH: case PredefinedActivityType.EXTERNAL_SEARCH: // Search additionalFieldsForm = FormHelper.GetFormInfo(OnlineMarketingObjectType.SEARCH, false); extraFieldsAtEnd = false; break; } // Get the activity form elements FormInfo filterFieldsForm = FormHelper.GetFormInfo(OnlineMarketingObjectType.ACTIVITY, true); var elements = filterFieldsForm.GetFormElements(true, false); FormCategoryInfo newCategory = null; string caption = null; string captionKey = null; foreach (var elem in elements) { if (elem is FormCategoryInfo) { // Form category newCategory = (FormCategoryInfo)elem; } else if (elem is FormFieldInfo) { // Form field FormFieldInfo ffi = (FormFieldInfo)elem; // Skip ignored columns if (ignoredColumns.IndexOfCSafe("|" + ffi.Name.ToLowerCSafe() + "|") >= 0) { continue; } string controlName = null; if (!ffi.PrimaryKey && (fi.GetFormField(ffi.Name) == null)) { // Set default filters switch (ffi.DataType) { case FormFieldDataTypeEnum.Text: case FormFieldDataTypeEnum.LongText: controlName = "textfilter"; ffi.Settings["OperatorFieldName"] = ffi.Name + ".operator"; break; case FormFieldDataTypeEnum.DateTime: controlName = "datetimefilter"; ffi.Settings["SecondDateFieldName"] = ffi.Name + ".seconddatetime"; break; case FormFieldDataTypeEnum.Integer: case FormFieldDataTypeEnum.LongInteger: controlName = "numberfilter"; ffi.Settings["OperatorFieldName"] = ffi.Name + ".operator"; break; case FormFieldDataTypeEnum.GUID: continue; } // For item ID and detail ID fields use control defined in activity type if (CMSString.Compare(ffi.Name, "ActivityItemID", true) == 0) { if (ati.ActivityTypeMainFormControl == null) { continue; } if (ati.ActivityTypeMainFormControl != String.Empty) { // Check if user defined control exists FormUserControlInfo fui = FormUserControlInfoProvider.GetFormUserControlInfo(ati.ActivityTypeMainFormControl); if (fui != null) { controlName = ati.ActivityTypeMainFormControl; } } // Set detailed caption captionKey = "activityitem." + activityType; caption = GetString(captionKey); if (!caption.EqualsCSafe(captionKey, true)) { ffi.Caption = caption; } } else if (CMSString.Compare(ffi.Name, "ActivityItemDetailID", true) == 0) { if (ati.ActivityTypeDetailFormControl == null) { continue; } if (ati.ActivityTypeDetailFormControl != String.Empty) { // Check if user defined control exists FormUserControlInfo fui = FormUserControlInfoProvider.GetFormUserControlInfo(ati.ActivityTypeDetailFormControl); if (fui != null) { controlName = ati.ActivityTypeDetailFormControl; } } // Set detailed caption captionKey = "activityitemdetail." + activityType; caption = GetString(captionKey); if (!caption.EqualsCSafe(captionKey, true)) { ffi.Caption = caption; } } else if (CMSString.Compare(ffi.Name, "ActivityNodeID", true) == 0) { // Document selector for NodeID controlName = "selectdocument"; } else if (CMSString.Compare(ffi.Name, "ActivityCulture", true) == 0) { // Culture selector for culture controlName = "sitecultureselector"; } else if (CMSString.Compare(ffi.Name, "ActivityValue", true) == 0) { // Show activity value only for relevant activity types if (!ati.ActivityTypeIsCustom && (showActivityValueFor.IndexOfCSafe("|" + activityType + "|", true) < 0)) { continue; } } if (controlName != null) { // SKU selector for product ffi.Settings["controlname"] = controlName; if (CMSString.Compare(controlName, "skuselector", true) == 0) { ffi.Settings["allowempty"] = true; } } // Ensure the category if (newCategory != null) { fi.AddFormCategory(newCategory); newCategory = null; // // Extra fields at the beginning if (!extraFieldsAtEnd && (additionalFieldsForm != null)) { AddExtraFields(ignoredColumns, fi, additionalFieldsForm); additionalFieldsForm = null; } } fi.AddFormField(ffi); } } } // Extra fields at end if (extraFieldsAtEnd && (additionalFieldsForm != null)) { // Ensure the category for extra fields if (newCategory != null) { fi.AddFormCategory(newCategory); newCategory = null; } AddExtraFields(ignoredColumns, fi, additionalFieldsForm); } LoadForm(activityFormCondition, fi, activityType); }
/// <summary> /// Reload data. /// </summary> /// <param name="setAutomatically">Indicates whether search options should be set automatically</param> public void ReloadSearch(bool setAutomatically) { ClassFields.ItemID = ItemID; ClassFields.ReloadData(setAutomatically, true); // Initialize properties List<IField> itemList = null; if (ClassInfo != null) { // Load XML definition fi = FormHelper.GetFormInfo(ClassInfo.ClassName, true); if (CMSString.Compare(ClassInfo.ClassName, "cms.user", true) == 0) { plcImage.Visible = false; ClassFields.DisplaySetAutomatically = false; pnlIndent.Visible = true; document = DataClassInfoProvider.GetDataClassInfo("cms.usersettings"); if (document != null) { FormInfo fiSettings = FormHelper.GetFormInfo(document.ClassName, true); fi.CombineWithForm(fiSettings, true, String.Empty); } } // Get all fields itemList = fi.GetFormElements(true, true); } if (itemList != null) { if (itemList.Any()) { pnlIndent.Visible = true; } // Store each field to array foreach (var item in itemList) { var formField = item as FormFieldInfo; if (formField != null) { object[] obj = { formField.Name, DataTypeManager.GetSystemType(TypeEnum.Field, formField.DataType) }; attributes.Add(obj); } } } if (AdvancedMode) { ReloadControls(); } }
/// <summary> /// Generate document content. /// </summary> /// <param name="wpi">WebPart info</param> /// <param name="gd">Guid</param> /// <param name="category">Category</param> protected void GenerateDocContent(FormInfo fi) { if (fi == null) { return; } // Get defintion elements ArrayList infos = fi.GetFormElements(true, false); bool isOpenSubTable = false; string currentGuid = ""; // Used for filter empty categories String categoryHeader = String.Empty; // Check all items in object array foreach (object contrl in infos) { // Generate row for form category if (contrl is FormCategoryInfo) { // Load castegory info FormCategoryInfo fci = contrl as FormCategoryInfo; if (fci != null) { // Close table from last category if (isOpenSubTable) { content += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\"> </td><td colspan=\"2\" class=\"Center\"> </td><td class=\"PropertyRightBottom\"> </td></tr></table>"; isOpenSubTable = false; } if (currentGuid == "") { currentGuid = Guid.NewGuid().ToString().Replace("-", "_"); } // Generate table for current category categoryHeader = @"<br /> <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable""> <tr> <td class=""CategoryLeftBorder""> </td> <td class=""CategoryTextCell"">" + HTMLHelper.HTMLEncode(fci.CategoryName) + @"</td> <td class=""CategoryRightBorder""> </td> </tr> </table>"; } } else { // Get form field info FormFieldInfo ffi = contrl as FormFieldInfo; if (ffi != null) { if (categoryHeader != String.Empty) { content += categoryHeader; categoryHeader = String.Empty; } if (!isOpenSubTable) { // Generate table for properties under one category isOpenSubTable = true; content += "" + "<table cellpadding=\"0\" cellspacing=\"0\" id=\"_" + currentGuid + "\" class=\"PropertiesTable\" >"; currentGuid = ""; } // Add ':' to caption string doubleDot = ""; if (!ffi.Caption.EndsWith(":")) { doubleDot = ":"; } content += @"<tr> <td class=""PropertyLeftBorder"" > </td> <td class=""PropertyContent"" style=""width:200px;"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ffi.Caption)) + doubleDot + @"</td> <td class=""PropertyRow"">" + HTMLHelper.HTMLEncode(resolver.ResolveMacros(DataHelper.GetNotEmpty(ffi.Description, GetString("WebPartDocumentation.DescriptionNoneAvailable")))) + @"</td> <td class=""PropertyRightBorder""> </td> </tr>"; if (ffi.Description == null || ffi.Description.Trim() == "") { undocumentedProperties++; } } } } // Close last category (if has any properties) if (isOpenSubTable) { content += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\"> </td><td colspan=\"2\" class=\"Center\"> </td><td class=\"PropertyRightBottom\"> </td></tr></table>"; } }
/// <summary> /// Loads custom fields collisions. /// </summary> private void LoadCustomFields() { // Check if account has any custom fields FormInfo formInfo = FormHelper.GetFormInfo(mParentAccount.ClassName, false); var list = formInfo.GetFormElements(true, false, true); if (list.OfType <FormFieldInfo>().Any()) { FormFieldInfo ffi; Literal content; LocalizedLabel lbl; CMSTextBox txt; content = new Literal(); content.Text = "<div class=\"form-horizontal\">"; plcCustomFields.Controls.Add(content); // Display all custom fields foreach (IField item in list) { ffi = item as FormFieldInfo; if (ffi != null) { // Display layout content = new Literal(); content.Text = "<div class=\"form-group\"><div class=\"editing-form-label-cell\">"; plcCustomFields.Controls.Add(content); lbl = new LocalizedLabel(); lbl.Text = ffi.GetDisplayName(MacroContext.CurrentResolver); lbl.DisplayColon = true; lbl.EnableViewState = false; lbl.CssClass = "control-label"; content = new Literal(); content.Text = "</div><div class=\"editing-form-control-cell\"><div class=\"control-group-inline-forced\">"; txt = new CMSTextBox(); txt.ID = "txt" + ffi.Name; lbl.AssociatedControlID = txt.ID; plcCustomFields.Controls.Add(lbl); plcCustomFields.Controls.Add(content); plcCustomFields.Controls.Add(txt); mCustomFields.Add(ffi.Name, new object[] { txt, ffi.DataType }); DataTable dt; // Get grouped dataset if (DataTypeManager.IsString(TypeEnum.Field, ffi.DataType)) { dt = SortGroupAccountsByColumn(ffi.Name + SqlHelper.ORDERBY_ASC, ffi.Name + " NOT LIKE ''", ffi.Name); } else { dt = SortGroupAccountsByColumn(ffi.Name + SqlHelper.ORDERBY_ASC, ffi.Name + " IS NOT NULL", ffi.Name); } // Load value into textbox txt.Text = ValidationHelper.GetString(mParentAccount.GetValue(ffi.Name), null); if (string.IsNullOrEmpty(txt.Text) && (dt.Rows.Count > 0)) { txt.Text = ValidationHelper.GetString(dt.Rows[0][ffi.Name], null); } // Display tooltip var img = new HtmlGenericControl("i"); img.Attributes["class"] = "validation-warning icon-exclamation-triangle form-control-icon"; DisplayTooltip(img, dt, ffi.Name, ValidationHelper.GetString(mParentAccount.GetValue(ffi.Name), ""), ffi.DataType); plcCustomFields.Controls.Add(img); content = new Literal(); content.Text = "</div></div></div>"; plcCustomFields.Controls.Add(content); mMergedAccounts.Tables[0].DefaultView.RowFilter = null; } } content = new Literal(); content.Text = "</div>"; plcCustomFields.Controls.Add(content); } else { tabCustomFields.Visible = false; tabCustomFields.HeaderText = null; } }
/// <summary> /// Initializes controls for activity rule. /// </summary> /// <param name="selectedActivity">Activity selected in drop-down menu</param> private void InitActivitySettings(string selectedActivity) { // Init activity selector from edited object if any LoadEditedActivityRule(ref selectedActivity); List <string> ignoredColumns = new List <string> { "activitytype", "activitysiteid", "activitycontactid" }; string[] activitiesWithValue = { PredefinedActivityType.PURCHASE, PredefinedActivityType.PURCHASEDPRODUCT, PredefinedActivityType.RATING, PredefinedActivityType.POLL_VOTING, PredefinedActivityType.PRODUCT_ADDED_TO_SHOPPINGCART }; // Get columns from OM_Activity (i.e. base table for all activities) ActivityTypeInfo ati = ActivityTypeInfoProvider.GetActivityTypeInfo(selectedActivity); var fi = new FormInfo(); // Get the activity form elements FormInfo filterFieldsForm = FormHelper.GetFormInfo(ActivityInfo.OBJECT_TYPE, true); IList <IDataDefinitionItem> elements = filterFieldsForm.GetFormElements(true, false); if ((selectedActivity != PredefinedActivityType.PAGE_VISIT) && (selectedActivity != PredefinedActivityType.LANDING_PAGE)) { // Show these fields only for 'Page visit' and 'Landing page' ignoredColumns.AddRange(new[] { "activityabvariantname", "activitymvtcombinationname" }); } FormCategoryInfo newCategory = null; foreach (IDataDefinitionItem elem in elements) { if (elem is FormCategoryInfo) { // Form category newCategory = (FormCategoryInfo)elem; } else if (elem is FormFieldInfo) { // Form field var ffi = (FormFieldInfo)elem; // Skip ignored columns if (ignoredColumns.Contains(ffi.Name, StringComparer.InvariantCultureIgnoreCase)) { continue; } if (!ffi.PrimaryKey && (fi.GetFormField(ffi.Name) == null)) { // Skip fields with Guid data type if (ffi.DataType == FieldDataType.Guid) { continue; } // Sets control name based on given datatype of field. Can be overwritten if more proper control is available string controlName = GetControlNameForFieldDataType(ffi); if (!GetControlNameForActivities(ffi, ati, selectedActivity, activitiesWithValue, ref controlName)) { continue; } if (controlName != null) { // SKU selector for product ffi.Settings["controlname"] = controlName; ffi.Settings["allowempty"] = controlName.EqualsCSafe("skuselector", true); } // Ensure the category if (newCategory != null) { fi.AddFormCategory(newCategory); newCategory = null; } fi.AddFormItem(ffi); } } } LoadActivityForm(fi, selectedActivity); }
protected void Page_Load(object sender, EventArgs e) { if (EditedObject != null) { // Register script for unimenu button selection CMSDeskPage.AddMenuButtonSelectScript(this, "Accounts", null, "menu"); // Get account info object AccountInfo ai = (AccountInfo)EditedObject; string append = null; // Check permission AccountHelper.AuthorizedReadAccount(ai.AccountSiteID, true); // Check if running under site manager (and distribute "site manager" flag to other tabs) string siteManagerParam = string.Empty; if (this.IsSiteManager) { siteManagerParam = "&issitemanager=1"; // Hide title CurrentMaster.Title.TitleText = CurrentMaster.Title.TitleImage = string.Empty; } else { // Set title CurrentMaster.Title.TitleImage = GetImageUrl("Objects/OM_Account/object.png"); CurrentMaster.Title.TitleText = GetString("om.account.edit"); } // Set default help topic SetHelp("onlinemarketing_account_general", "helpTopic"); // Append '(merged)' behind account name in breadcrumbs if (ai.AccountMergedWithAccountID != 0) { append = " " + GetString("om.account.mergedsuffix"); } // Append '(global)' else if (ai.AccountSiteID == 0) { append = " " + GetString("om.account.globalsuffix"); } // Modify header appearance in modal dialog (display title instead of breadcrumbs) if (QueryHelper.GetBoolean("dialogmode", false)) { CurrentMaster.Title.TitleText = GetString("om.account.edit") + " - " + HTMLHelper.HTMLEncode(ai.AccountName) + append; CurrentMaster.Title.TitleImage = GetImageUrl("Objects/OM_Account/object.png"); } else { // Get url for breadcrumbs string url = ResolveUrl("~/CMSModules/ContactManagement/Pages/Tools/Account/List.aspx"); url = URLHelper.AddParameterToUrl(url, "siteid", this.SiteID.ToString()); if (this.IsSiteManager) { url = URLHelper.AddParameterToUrl(url, "issitemanager", "1"); } CurrentPage.InitBreadcrumbs(2); CurrentPage.SetBreadcrumb(0, GetString("om.account.list"), url, "_parent", null); CurrentPage.SetBreadcrumb(1, HTMLHelper.HTMLEncode(CMSContext.ResolveMacros("{%EditedObject.DisplayName%}")) + append, null, null, null); } // Check if account has any custom fields int i = 0; FormInfo formInfo = FormHelper.GetFormInfo(ai.ClassName, false); if (formInfo.GetFormElements(true, false, true).Count > 0) { i = 1; } // Initialize tabs this.InitTabs(4 + i, "content"); this.SetTab(0, GetString("general.general"), "Tab_General.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_general');"); if (i > 0) { // Add tab for custom fields this.SetTab(1, GetString("general.customfields"), "Tab_CustomFields.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_customfields');"); } // Display contacts tab only if user is authorized to read contacts if (ContactHelper.AuthorizedReadContact(ai.AccountSiteID, false) || AccountHelper.AuthorizedReadAccount(ai.AccountSiteID, false)) { this.SetTab(1 + i, GetString("om.contact.list"), "Tab_Contacts.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_contacts');"); } // Hide last 2 tabs if the account is merged if (ai.AccountMergedWithAccountID == 0) { this.SetTab(2 + i, GetString("om.account.subsidiaries"), "Tab_Subsidiaries.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_subsidiaries');"); this.SetTab(3 + i, GetString("om.account.merge"), "Tab_Merge.aspx?accountid=" + ai.AccountID + siteManagerParam, "SetHelpTopic('helpTopic', 'onlinemarketing_account_merge');"); } } }
protected void Page_Load(object sender, EventArgs e) { // Get the group ID and the group InfoObject groupId = QueryHelper.GetInteger("groupid", 0); GroupInfo gi = GroupInfoProvider.GetGroupInfo(groupId); if (gi != null) { groupDisplayName = HTMLHelper.HTMLEncode(gi.GroupDisplayName); } // Page title CurrentMaster.Title.TitleText = GetString("Group.EditHeaderCaption"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/Community_Group/object.png"); CurrentMaster.Title.HelpTopicName = "group_general"; CurrentMaster.Title.HelpName = "helpTopic"; // Pagetitle breadcrumbs string[,] pageTitleTabs = new string[2, 3]; pageTitleTabs[0, 0] = GetString("Group.ItemListLink"); pageTitleTabs[0, 1] = "~/CMSModules/Groups/Tools/Group_List.aspx"; pageTitleTabs[0, 2] = "_parent"; pageTitleTabs[1, 0] = groupDisplayName; pageTitleTabs[1, 1] = ""; pageTitleTabs[1, 2] = ""; CurrentMaster.Title.Breadcrumbs = pageTitleTabs; // Tabs string[,] tabs = new string[10, 4]; // General tabs[0, 0] = GetString("General.General"); tabs[0, 1] = "SetHelpTopic('helpTopic', 'group_general');"; tabs[0, 2] = "Group_Edit_General.aspx?groupID=" + groupId; // Custom fields FormInfo formInfo = FormHelper.GetFormInfo(PredefinedObjectType.GROUP, false); if ((formInfo != null) && formInfo.GetFormElements(true, false, true).Any()) { tabs[1, 0] = GetString("general.customfields"); tabs[1, 2] = "Group_Edit_CustomFields.aspx?groupID=" + groupId; } // Security tabs[2, 0] = GetString("General.Security"); tabs[2, 1] = "SetHelpTopic('helpTopic', 'group_security');"; tabs[2, 2] = "Security/Security.aspx?groupID=" + groupId; // Members tabs[3, 0] = GetString("Group.Members"); tabs[3, 1] = "SetHelpTopic('helpTopic', 'group_members_list');"; tabs[3, 2] = "Members/Member_List.aspx?groupID=" + groupId; if (ResourceSiteInfoProvider.IsResourceOnSite("CMS.Roles", SiteContext.CurrentSiteName)) { tabs[4, 0] = GetString("general.roles"); tabs[4, 1] = "SetHelpTopic('helpTopic', 'group_roles_list');"; tabs[4, 2] = "Roles/Role_List.aspx?groupID=" + groupId; } if (ResourceSiteInfoProvider.IsResourceOnSite("CMS.Forums", SiteContext.CurrentSiteName)) { tabs[5, 0] = GetString("group_general.forums"); tabs[5, 1] = "SetHelpTopic('helpTopic', 'forum_list');"; tabs[5, 2] = "Forums/Groups/ForumGroups_List.aspx?groupid=" + groupId; } if (ResourceSiteInfoProvider.IsResourceOnSite("CMS.MediaLibrary", SiteContext.CurrentSiteName)) { tabs[6, 0] = GetString("Group.MediaLibrary"); tabs[6, 1] = "SetHelpTopic('helpTopic', 'library_list');"; tabs[6, 2] = "MediaLibrary/Library_List.aspx?groupid=" + groupId; } if (ResourceSiteInfoProvider.IsResourceOnSite("CMS.MessageBoards", SiteContext.CurrentSiteName)) { tabs[7, 0] = GetString("Group.MessageBoards"); tabs[7, 1] = "SetHelpTopic('helpTopic', 'group_messageboard');"; tabs[7, 2] = "MessageBoards/Boards_Default.aspx?groupid=" + groupId; } if (ResourceSiteInfoProvider.IsResourceOnSite("CMS.Polls", SiteContext.CurrentSiteName)) { tabs[8, 0] = GetString("Group.Polls"); tabs[8, 1] = "SetHelpTopic('helpTopic', 'polls_list');"; tabs[8, 2] = "Polls/Polls_List.aspx?groupID=" + groupId; } // Check whether license for project management is avilable // if no hide project management tab if (LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.ProjectManagement)) { // Check site availability if (ResourceSiteInfoProvider.IsResourceOnSite("CMS.ProjectManagement", SiteContext.CurrentSiteName)) { tabs[9, 0] = ResHelper.GetString("pm.project.list"); tabs[9, 1] = "SetHelpTopic('helpTopic', 'CMS_ProjectManagement_Projects');"; tabs[9, 2] = "ProjectManagement/Project/List.aspx?groupid=" + groupId; } } CurrentMaster.Tabs.Tabs = tabs; CurrentMaster.Tabs.UrlTarget = "content"; }
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); // Get page info PageInfo pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode, null, CMSContext.CurrentSite.CombineWithDefaultCulture); if (pi != null) { // Get template PageTemplateInfo pti = pi.GetInheritedTemplateInfo(CMSContext.PreferredCultureCode, CMSContext.CurrentSite.CombineWithDefaultCulture); // Get web part WebPartInstance webPart = pti.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 = wpi.WebPartProperties; } } else { wpProperties = wi.WebPartProperties; } FormInfo fi = new FormInfo(wpProperties); // General properties of webparts string beforeFormDefinition = PortalHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.Before); string afterFormDefinition = PortalHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.After); // General properties before custom if (!String.IsNullOrEmpty(beforeFormDefinition)) { // Load before properties FormInfo bfi = new FormInfo(beforeFormDefinition); bfi.UpdateExistingFields(fi); sb.Append(Environment.NewLine + "Default" + Environment.NewLine + Environment.NewLine + Environment.NewLine); sb.Append(GetProperties(bfi.GetFormElements(true, false), webPart)); } // Generate custom properties sb.Append(GetProperties(fi.GetFormElements(true, false), webPart)); // General properties after custom if (!String.IsNullOrEmpty(afterFormDefinition)) { FormInfo afi = new FormInfo(afterFormDefinition); // Load before properties afi.UpdateExistingFields(fi); sb.Append(GetProperties(afi.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_" + webPart.ControlID + ".txt"); Response.ContentType = "text/plain"; Response.BinaryWrite(file); RequestHelper.EndResponse(); } } } }
/// <summary> /// Loads custom fields collisions. /// </summary> private void LoadCustomFields() { // Check if account has any custom fields FormInfo formInfo = FormHelper.GetFormInfo(parentAccount.ClassName, false); var list = formInfo.GetFormElements(true, false, true); if (list.Any()) { FormFieldInfo ffi; Literal content; LocalizedLabel lbl; TextBox txt; Image img; content = new Literal(); content.Text = "<table class=\"CollisionPanel\">"; plcCustomFields.Controls.Add(content); // Display all custom fields foreach (IFormItem item in list) { ffi = item as FormFieldInfo; if (ffi != null) { // Display layout content = new Literal(); content.Text = "<tr class=\"CollisionRow\"><td class=\"LabelColumn\">"; plcCustomFields.Controls.Add(content); lbl = new LocalizedLabel(); lbl.Text = ffi.Caption; lbl.DisplayColon = true; lbl.EnableViewState = false; lbl.CssClass = "ContentLabel"; content = new Literal(); content.Text = "<td class=\"ComboBoxColumn\"><div class=\"ComboBox\">"; txt = new TextBox(); txt.ID = "txt" + ffi.Name; txt.CssClass = "TextBoxField"; lbl.AssociatedControlID = txt.ID; plcCustomFields.Controls.Add(lbl); plcCustomFields.Controls.Add(content); plcCustomFields.Controls.Add(txt); content = new Literal(); content.Text = "</div></td><td>"; plcCustomFields.Controls.Add(content); customFields.Add(ffi.Name, new object[] { txt, ffi.DataType }); DataTable dt; // Get grouped dataset if ((ffi.DataType == FormFieldDataTypeEnum.LongText) || (ffi.DataType == FormFieldDataTypeEnum.Text)) { dt = SortGroupAccountsByColumn(ffi.Name + " ASC", ffi.Name + " NOT LIKE ''", ffi.Name); } else { dt = SortGroupAccountsByColumn(ffi.Name + " ASC", ffi.Name + " IS NOT NULL", ffi.Name); } // Load value into textbox txt.Text = ValidationHelper.GetString(parentAccount.GetValue(ffi.Name), null); if (string.IsNullOrEmpty(txt.Text) && (dt.Rows.Count > 0)) { txt.Text = ValidationHelper.GetString(dt.Rows[0][ffi.Name], null); } img = new Image(); img.CssClass = "ResolveButton"; // Display tooltip DisplayTooltip(img, dt, ffi.Name, ValidationHelper.GetString(parentAccount.GetValue(ffi.Name), ""), ffi.DataType); plcCustomFields.Controls.Add(img); content = new Literal(); content.Text = "</td></tr>"; plcCustomFields.Controls.Add(content); mergedAccounts.Tables[0].DefaultView.RowFilter = null; } } content = new Literal(); content.Text = "</table>"; plcCustomFields.Controls.Add(content); } else { tabCustomFields.Visible = false; tabCustomFields.HeaderText = null; } }
/// <summary> /// Event handling creation of tabs. /// </summary> private void OnTabCreated(object sender, TabCreatedEventArgs e) { if (e.Tab == null) { return; } var tab = e.Tab; switch (tab.TabName.ToLowerCSafe()) { case "customfields": // Check custom fields of user { int customFields = 0; var userId = QueryHelper.GetInteger("objectid", 0); UserInfo ui = UserInfoProvider.GetUserInfo(userId); if (ui != null) { if (!MembershipContext.AuthenticatedUser.IsGlobalAdministrator && !ui.IsInSite(SiteContext.CurrentSiteName)) { URLHelper.SeeOther(UIHelper.GetInformationUrl(ResHelper.GetString("user.notinsite"))); } // Get user form information and check for visible non-system fields FormInfo formInfo = FormHelper.GetFormInfo(ui.ClassName, false); customFields = (formInfo.GetFormElements(true, false, true).Any() ? 1 : 0); // Check custom fields of user settings if needed if ((customFields == 0) && (ui.UserSettings != null)) { // Get user settings form information and check for visible non-system fields formInfo = FormHelper.GetFormInfo(ui.UserSettings.ClassName, false); customFields = (formInfo.GetFormElements(true, false, true).Any() ? 1 : 0); } } if (customFields == 0) { e.Tab = null; } } break; case "notifications": // Display notifications tab ? if (!LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.Notifications, ModuleName.NOTIFICATIONS)) { e.Tab = null; } break; case "languages": // Display languages tab ? if (!LicenseKeyInfoProvider.IsFeatureAvailable(FeatureEnum.Multilingual)) { e.Tab = null; } break; case "membership": // Display membership tab ? if (!LicenseKeyInfoProvider.IsFeatureAvailable(FeatureEnum.Membership)) { e.Tab = null; } break; case "departments": { // Is E-commerce on site ? bool ecommerceOnSite = false; if (SiteContext.CurrentSiteName != null) { // Check if E-commerce module is installed ecommerceOnSite = ModuleEntryManager.IsModuleLoaded(ModuleName.ECOMMERCE) && ResourceSiteInfoProvider.IsResourceOnSite("CMS.Ecommerce", SiteContext.CurrentSiteName); } if (!ecommerceOnSite) { e.Tab = null; } } break; case "sites": { bool showSites = false; if (MembershipContext.AuthenticatedUser.IsGlobalAdministrator) { int sitesCount = SiteInfoProvider.GetSitesCount(); if (sitesCount > 0) { showSites = true; } } if (!showSites) { e.Tab = null; } } break; case "friends": if (!LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.Friends, ModuleName.COMMUNITY)) { e.Tab = null; } break; } }
/// <summary> /// Load parameters from data form. /// </summary> protected void LoadParameters() { if (ReportInfo != null) { // Set the form FormInfo fi = new FormInfo(ReportInfo.ReportParameters); // Get datarow with required columns DataRow dr = fi.GetDataRow(); if (!RequestHelper.IsPostBack() || ForceLoadDefaultValues || !DisplayFilter) { fi.LoadDefaultValues(dr, true); } else { if ((!ForceLoadDefaultValues) && (formElem.DataRow != null)) { dr = formElem.DataRow; } } // show filter - based on DisplayFilter and number of visible elements mDisplayFilterResult = DisplayFilter && (fi.GetFormElements(true, false).Any()); formElem.DataRow = dr; formElem.SubmitButton.Visible = mDisplayFilterResult; formElem.SubmitButton.RegisterHeaderAction = false; formElem.FormInformation = fi; formElem.SubmitButton.Text = GetString("Report_View.btnUpdate"); formElem.SiteName = CMSContext.CurrentSiteName; formElem.ShowPrivateFields = true; formElem.Mode = FormModeEnum.Insert; formElem.Visible = mDisplayFilterResult; } }
protected TabItem Tabs_OnTabCreated(UIElementInfo element, TabItem tab, int tabIndex) { bool splitViewSupported = false; string lowerElementName = element.ElementName.ToLowerCSafe(); UIPageURLSettings settings = null; switch (lowerElementName) { case "products.general": case "products.attachments": case "products.metadata": case "products.categories": case "products.workflow": case "products.versions": splitViewSupported = true; break; } switch (lowerElementName) { case "products.attachments": case "products.metadata": case "products.categories": case "products.workflow": case "products.versions": case "products.relatedproducts": // Check if editing product with its document if (NodeID <= 0) { return(null); } break; case "products.documents": if ((NodeID <= 0) && DisplayTreeInProducts) { if (!CurrentUser.IsGlobalAdministrator || (sku == null) || !sku.IsGlobal) { return(null); } } break; case "products.preview": // Check if editing product with its document if (NodeID <= 0) { return(null); } settings = new UIPageURLSettings { Mode = "preview", NodeID = Node.NodeID, Culture = Node.DocumentCulture, Node = Node, AllowViewValidate = false }; tab.RedirectUrl = GetDocumentPageUrl(settings); tab.RedirectUrl = URLHelper.AddParameterToUrl(tab.RedirectUrl, "nodeid", NodeID.ToString()); tab.OnClientClick += "SetTab('PreviewTab')"; break; case "products.livesite": // Check if editing product with its document if (NodeID <= 0) { return(null); } settings = new UIPageURLSettings { Mode = "livesite", NodeID = Node.NodeID, Culture = Node.DocumentCulture, Node = Node, AllowViewValidate = false }; tab.RedirectUrl = GetDocumentPageUrl(settings); tab.RedirectUrl = URLHelper.AddParameterToUrl(tab.RedirectUrl, "nodeid", NodeID.ToString()); tab.OnClientClick += "SetTab('LiveSiteTab')"; break; case "products.customfields": case "productoptions.options.customfields": // Check if SKU has any custom fields FormInfo formInfo = FormHelper.GetFormInfo("ecommerce.sku", false); if (!formInfo.GetFormElements(true, false, true).Any()) { return(null); } break; case "products.advanced": tab.Expand = (NodeID <= 0); break; } // Open advanced tab when one of its subtabs is selected bool openAdvanced = false; switch (selectedTab) { case "options": case "volumediscounts": case "workflow": case "versions": case "documents": case "relatedproducts": openAdvanced = true; break; } // Ensure tab preselection if (lowerElementName.StartsWithCSafe("products.") && ((lowerElementName.Substring("products.".Length) == selectedTab) || (openAdvanced && (lowerElementName == "products.advanced")))) { CurrentMaster.Tabs.SelectedTab = tabIndex; } // Add SiteId parameter to each tab if (!string.IsNullOrEmpty(tab.RedirectUrl)) { tab.RedirectUrl = URLHelper.AddParameterToUrl(tab.RedirectUrl, "siteId", SiteID.ToString()); } // Ensure split view mode if ((NodeID > 0) && splitViewSupported && CMSContext.DisplaySplitMode) { tab.RedirectUrl = GetSplitViewUrl(tab.RedirectUrl); } // Make URL absolute tab.RedirectUrl = URLHelper.GetAbsoluteUrl(tab.RedirectUrl); return(tab); }
/// <summary> /// Reload data. /// </summary> /// <param name="setAutomatically">Indicates whether search options should be set automatically</param> public void ReloadSearch(bool setAutomatically) { ClassFields.ItemID = ItemID; ClassFields.ReloadData(setAutomatically, true); // Initialize properties List<IFormItem> itemList = null; FormFieldInfo formField = null; // Load DataClass dci = DataClassInfoProvider.GetDataClass(ItemID); if (dci != null) { // Load XML definition fi = FormHelper.GetFormInfo(dci.ClassName, true); if (CMSString.Compare(dci.ClassName, "cms.user", true) == 0) { plcImage.Visible = false; ClassFields.DisplaySetAutomatically = false; pnlIndent.Visible = true; document = DataClassInfoProvider.GetDataClass("cms.usersettings"); if (document != null) { FormInfo fiSettings = FormHelper.GetFormInfo(document.ClassName, true); fi.CombineWithForm(fiSettings, true, String.Empty); } } // Get all fields itemList = fi.GetFormElements(true, true); } if (itemList != null) { if (itemList.Any()) { pnlIndent.Visible = true; } // Store each field to array foreach (object item in itemList) { if (item is FormFieldInfo) { formField = ((FormFieldInfo)(item)); object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) }; attributes.Add(obj); } } } ReloadControls(); }
/// <summary> /// Load parameters from data form. /// </summary> private void LoadParameters() { if (ReportInfo != null) { // Set the form FormInfo fi = new FormInfo(ReportInfo.ReportParameters); // Get datarow with required columns DataRow dr = fi.GetDataRow(false); if (!RequestHelper.IsPostBack() || ForceLoadDefaultValues || !DisplayFilter) { fi.LoadDefaultValues(dr, true); } else if ((!ForceLoadDefaultValues) && (formParameters.DataRow != null)) { dr = formParameters.DataRow; } // Show filter - based on DisplayFilter and number of visible elements mDisplayFilterResult = DisplayFilter && (fi.GetFormElements(true, false).Any()); formParameters.DataRow = dr; formParameters.SubmitButton.Visible = mDisplayFilterResult; formParameters.SubmitButton.RegisterHeaderAction = false; formParameters.FormInformation = fi; formParameters.SubmitButton.ResourceString = "report_view.btnupdate"; formParameters.SiteName = SiteContext.CurrentSiteName; formParameters.Mode = FormModeEnum.Insert; formParameters.Visible = mDisplayFilterResult; wasInit = true; } }
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); // Get page info PageInfo pi = PageInfoProvider.GetPageInfo(CMSContext.CurrentSiteName, aliasPath, CMSContext.PreferredCultureCode, null, CMSContext.CurrentSite.CombineWithDefaultCulture); if (pi != null) { // Get template PageTemplateInfo pti = pi.GetInheritedTemplateInfo(CMSContext.PreferredCultureCode, CMSContext.CurrentSite.CombineWithDefaultCulture); // Get web part WebPartInstance webPart = pti.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 = wpi.WebPartProperties; } } else { wpProperties = wi.WebPartProperties; } FormInfo fi = new FormInfo(wpProperties); // General properties of webparts string beforeFormDefinition = PortalHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.Before); string afterFormDefinition = PortalHelper.GetWebPartProperties((WebPartTypeEnum)wi.WebPartType, PropertiesPosition.After); // General properties before custom if (!String.IsNullOrEmpty(beforeFormDefinition)) { // Load before properties FormInfo bfi = new FormInfo(beforeFormDefinition); bfi.UpdateExistingFields(fi); sb.Append(Environment.NewLine + "Default" + Environment.NewLine + Environment.NewLine + Environment.NewLine); sb.Append(GetProperties(bfi.GetFormElements(true, false), webPart)); } // Generate custom properties sb.Append(GetProperties(fi.GetFormElements(true, false), webPart)); // General properties after custom if (!String.IsNullOrEmpty(afterFormDefinition)) { FormInfo afi = new FormInfo(afterFormDefinition); // Load before properties afi.UpdateExistingFields(fi); sb.Append(GetProperties(afi.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_" + webPart.ControlID + ".txt"); Response.ContentType = "text/plain"; Response.BinaryWrite(file); RequestHelper.EndResponse(); } } } }
/// <summary> /// Loads data. /// </summary> private void LoadData() { // Initialize properties ArrayList itemList = null; FormFieldInfo formField = null; attributes.Clear(); // Load DataClass dci = DataClassInfoProvider.GetDataClass(this.ItemID); DataClassInfo tree = null; // For 'cms.document' add 'ecommerce.sku' fields, too if ((dci != null) && (dci.ClassName == "cms.document")) { // For 'cms.document' add 'ecommerce.sku' fields, too tree = DataClassInfoProvider.GetDataClass("ecommerce.sku"); if (tree != null) { // Load XML definition fi = FormHelper.GetFormInfo(tree.ClassName, false); // Get all fields itemList = fi.GetFormElements(true, true); } if (itemList != null) { // Store each field to array foreach (object item in itemList) { if (item is FormFieldInfo) { formField = ((FormFieldInfo)(item)); object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) }; attributes.Add(obj); } } } } if (dci != null) { // Load XML definition fi = FormHelper.GetFormInfo(dci.ClassName, false); // Get all fields itemList = fi.GetFormElements(true, true); ss = new SearchSettings(); ss.LoadData(dci.ClassSearchSettings); } if (itemList != null) { // Store each field to array foreach (object item in itemList) { if (item is FormFieldInfo) { formField = ((FormFieldInfo)(item)); object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) }; attributes.Add(obj); } } } // For 'cms.document' add 'cms.tree' fields, too if ((dci != null) && (dci.ClassName == "cms.document")) { tree = DataClassInfoProvider.GetDataClass("cms.tree"); if (tree != null) { // Load XML definition fi = FormHelper.GetFormInfo(tree.ClassName, false); // Get all fields itemList = fi.GetFormElements(true, true); } if (itemList != null) { // Store each field to array foreach (object item in itemList) { if (item is FormFieldInfo) { formField = ((FormFieldInfo)(item)); object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) }; attributes.Add(obj); } } } } // For 'cms.user' add 'cms.usersettings' fields, too if ((dci != null) && (dci.ClassName.ToLower() == "cms.user")) { tree = DataClassInfoProvider.GetDataClass("cms.usersettings"); if (tree != null) { // Load XML definition fi = FormHelper.GetFormInfo(tree.ClassName, false); // Get all fields itemList = fi.GetFormElements(true, true); } if (itemList != null) { // Store each field to array foreach (object item in itemList) { if (item is FormFieldInfo) { formField = ((FormFieldInfo)(item)); object[] obj = { formField.Name, FormHelper.GetDataType(formField.DataType) }; attributes.Add(obj); } } } } }
/// <summary> /// Generate properties. /// </summary> protected void GenerateProperties(FormInfo fi) { // Generate script to display and hide properties groups ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ShowHideProperties", ScriptHelper.GetScript(@" function ShowHideProperties(id) { var obj = document.getElementById(id); var objlink = document.getElementById(id+'_link'); if ((obj != null)&&(objlink != null)){ if (obj.style.display == 'none' ) { obj.style.display=''; objlink.innerHTML = '<img border=""0"" src=""" + minImg + @""" >'; } else {obj.style.display='none'; objlink.innerHTML = '<img border=""0"" src=""" + plImg + @""" >';} objlink.blur();}}")); // Get defintion elements var infos = fi.GetFormElements(true, false); bool isOpenSubTable = false; bool firstLoad = true; bool hasAnyProperties = false; string currentGuid = ""; string newCategory = null; // Check all items in object array foreach (IFormItem contrl in infos) { // Generate row for form category if (contrl is FormCategoryInfo) { // Load castegory info FormCategoryInfo fci = contrl as FormCategoryInfo; if (fci != null) { if (isOpenSubTable) { ltlProperties.Text += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\"> </td><td colspan=\"2\" class=\"Center\"> </td><td class=\"PropertyRightBottom\"> </td></tr></table>"; isOpenSubTable = false; } if (currentGuid == "") { currentGuid = Guid.NewGuid().ToString().Replace("-", "_"); } // Generate properties content newCategory = @"<br /> <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable""> <tr> <td class=""CategoryLeftBorder""> </td> <td class=""CategoryTextCell"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(fci.CategoryCaption)) + @"</td> <td class=""HiderCell""> <a id=""" + currentGuid + "_link\" href=\"#\" onclick=\"ShowHideProperties('" + currentGuid + @"'); return false;""> <img border=""0"" src=""" + minImg + @""" ></a> </td> <td class=""CategoryRightBorder""> </td> </tr> </table>"; } } else { hasAnyProperties = true; // Get form field info FormFieldInfo ffi = contrl as FormFieldInfo; if (ffi != null) { // If display only in dashboard and not dashbord zone (or none for admins) dont show if ((ffi.DisplayIn == "dashboard") && ((zoneType != WidgetZoneTypeEnum.Dashboard) && (zoneType != WidgetZoneTypeEnum.None))) { continue; } if (newCategory != null) { ltlProperties.Text += newCategory; newCategory = null; firstLoad = false; } else if (firstLoad) { if (currentGuid == "") { currentGuid = Guid.NewGuid().ToString().Replace("-", "_"); } // Generate properties content firstLoad = false; ltlProperties.Text += @"<br /> <table cellpadding=""0"" cellspacing=""0"" class=""CategoryTable""> <tr> <td class=""CategoryLeftBorder""> </td> <td class=""CategoryTextCell"">Default</td> <td class=""HiderCell""> <a id=""" + currentGuid + "_link\" href=\"#\" onclick=\"ShowHideProperties('" + currentGuid + @"'); return false;""> <img border=""0"" src=""" + minImg + @""" ></a> </td> <td class=""CategoryRightBorder""> </td> </tr> </table>"; } if (!isOpenSubTable) { isOpenSubTable = true; ltlProperties.Text += "" + "<table cellpadding=\"0\" cellspacing=\"0\" id=\"" + currentGuid + "\" class=\"PropertiesTable\" >"; currentGuid = ""; } string doubleDot = ""; if (!ffi.Caption.EndsWithCSafe(":")) { doubleDot = ":"; } ltlProperties.Text += @"<tr> <td class=""PropertyLeftBorder"" > </td> <td class=""PropertyContent"" style=""width:200px;"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(ffi.Caption)) + doubleDot + @"</td> <td class=""PropertyRow"">" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(DataHelper.GetNotEmpty(ffi.Description, GetString("WebPartDocumentation.DescriptionNoneAvailable")))) + @"</td> <td class=""PropertyRightBorder""> </td> </tr>"; } } } if (isOpenSubTable) { ltlProperties.Text += "<tr class=\"PropertyBottom\"><td class=\"PropertyLeftBottom\"> </td><td colspan=\"2\" class=\"Center\"> </td><td class=\"PropertyRightBottom\"> </td></tr></table>"; } if (!hasAnyProperties) { ltlProperties.Text = "<br /><div style=\"padding-left:5px;padding-right:5px; font-weight: bold;\">" + GetString("documentation.nopropertiesavaible") + "</div>"; } }
/// <summary> /// Initializes controls for activity rule. /// </summary> /// <param name="selectedActivity">Activity selected in drop-down menu</param> private void InitActivitySettings(string selectedActivity) { // Init activity selector from edited object if any LoadEditedActivityRule(ref selectedActivity); string[] ignoredColumns = { "activitytype", "activitysiteid", "activityguid", "activityactivecontactid", "activityoriginalcontactid", "pagevisitid", "pagevisitactivityid", "searchid", "searchactivityid" }; string[] activitiesWithValue = { PredefinedActivityType.PURCHASE, PredefinedActivityType.PURCHASEDPRODUCT, PredefinedActivityType.RATING, PredefinedActivityType.POLL_VOTING, PredefinedActivityType.PRODUCT_ADDED_TO_SHOPPINGCART }; // Get columns from OM_Activity (i.e. base table for all activities) ActivityTypeInfo ati = ActivityTypeInfoProvider.GetActivityTypeInfo(selectedActivity); var fi = new FormInfo(); // Get columns from additional table (if any) according to selected activity type bool extraFieldsAtEnd = true; FormInfo additionalFieldsForm = GetActivityAdditionalFields(selectedActivity, ref extraFieldsAtEnd); // Get the activity form elements FormInfo filterFieldsForm = FormHelper.GetFormInfo(ActivityInfo.OBJECT_TYPE, true); IList <IField> elements = filterFieldsForm.GetFormElements(true, false); FormCategoryInfo newCategory = null; foreach (IField elem in elements) { if (elem is FormCategoryInfo) { // Form category newCategory = (FormCategoryInfo)elem; } else if (elem is FormFieldInfo) { // Form field var ffi = (FormFieldInfo)elem; // Skip ignored columns if (ignoredColumns.Contains(ffi.Name.ToLowerCSafe())) { continue; } if ((!ffi.PrimaryKey) && (fi.GetFormField(ffi.Name) == null)) { // Skip fields with Guid data type if (ffi.DataType == FieldDataType.Guid) { continue; } // Sets control name based on given datatype of field. Can be overwritten if more proper control is available string controlName = GetControlNameForFieldDataType(ffi); if (!GetControlNameForActivities(ffi, ati, selectedActivity, activitiesWithValue, ref controlName)) { continue; } if (controlName != null) { // SKU selector for product ffi.Settings["controlname"] = controlName; ffi.Settings["allowempty"] = controlName.EqualsCSafe("skuselector", true); } // Ensure the category if (newCategory != null) { fi.AddFormCategory(newCategory); newCategory = null; // Extra fields at the beginning if ((!extraFieldsAtEnd) && (additionalFieldsForm != null)) { AddExtraActivityFields(ignoredColumns, fi, additionalFieldsForm); additionalFieldsForm = null; } } fi.AddFormItem(ffi); } } } // Extra fields at the end if ((extraFieldsAtEnd) && (additionalFieldsForm != null)) { // Ensure the category for extra fields if (newCategory != null) { fi.AddFormCategory(newCategory); } AddExtraActivityFields(ignoredColumns, fi, additionalFieldsForm); } LoadActivityForm(fi, selectedActivity); }