public void OptionSetBeanTest01() { LocalizedLabel lLabel = new LocalizedLabel("Option1", 1041); LocalizedLabel lLabel2 = new LocalizedLabel("Option2", LANG_CODE); PicklistAttributeMetadata meta = new PicklistAttributeMetadata(); meta.OptionSet = new OptionSetMetadata() { Name = "optionSet", DisplayName = new Label("optiondisplay", LANG_CODE), Options = { new OptionMetadata(new Label(lLabel, null), 1), new OptionMetadata(new Label("Option2", LANG_CODE), 2), new OptionMetadata(new Label(lLabel2, null), 3) } }; OptionSetBean cls = new OptionSetBean(meta); Assert.True(cls.HasOptionSet()); Assert.AreEqual("Option1", cls.GetValue(1), "ラベルあり"); Assert.Null(cls.GetValue(2), "ラベルなし"); Assert.AreEqual("Option2", cls.GetValue(3), "ラベルあり"); }
protected void Page_PreRender(object sender, EventArgs e) { plcPageSize.Visible = (DisplayPager && ShowPageSize && (drpPageSize.Items.Count > 1)); // Handle pager only if visible if (pagerElem.Visible) { if (UniPager.PageCount > UniPager.GroupSize) { LocalizedLabel lblPage = ControlsHelper.GetChildControl(UniPager, typeof(LocalizedLabel), "lblPage") as LocalizedLabel; using (Control drpPage = ControlsHelper.GetChildControl(UniPager, typeof(DropDownList), "drpPage")) { using (Control txtPage = ControlsHelper.GetChildControl(UniPager, typeof(TextBox), "txtPage")) { if ((lblPage != null) && (drpPage != null) && (txtPage != null)) { if (UniPager.PageCount > 20) { drpPage.Visible = false; // Set labels associated control for US Section 508 validation lblPage.AssociatedControlClientID = txtPage.ClientID; } else { txtPage.Visible = false; // Set labels associated control for US Section 508 validation lblPage.AssociatedControlClientID = drpPage.ClientID; } } } } } else { // Remove direct page control if only one group of pages is shown using (Control plcDirectPage = ControlsHelper.GetChildControl(UniPager, typeof(PlaceHolder), "plcDirectPage")) { if (plcDirectPage != null) { plcDirectPage.Controls.Clear(); } } } } plcSpace.Visible = !pagerElem.Visible; // Hide entire control if pager and page size drodown is hidden if (!plcPageSize.Visible && !pagerElem.Visible) { Visible = false; UniPager.Enabled = false; } PagerLoaded = true; }
/// <summary> /// Display invalid logon attempts. /// </summary> private string GetLogonAttemptsUnlockingLink() { LocalizedLabel failureLit = Login1.FindControl("FailureText") as LocalizedLabel; if (failureLit == null) { return(string.Empty); } return("<a href=\"#\" onclick=\"" + Page.ClientScript.GetCallbackEventReference(this, "null", "UpdateLabel_" + ClientID, "'" + failureLit.ClientID + "'") + ";\">" + GetString("general.clickhere") + "</a>"); }
public void OptionSetBeanTest04() { LocalizedLabel lLabel = new LocalizedLabel("Option1", 1041); StringAttributeMetadata meta = new StringAttributeMetadata(); OptionSetBean cls = new OptionSetBean(meta); Assert.False(cls.HasOptionSet()); }
protected void Page_PreRender(object sender, EventArgs e) { // Get label for info text field LocalizedLabel infoTextLabel = editForm.FieldLabels["InfoText"]; // Set label to render without colon. It is used for info message through whole form width. if (infoTextLabel != null) { infoTextLabel.DisplayColon = false; } }
protected void MappingItemRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { LocalizedLabel literal = e.Item.FindControl("FieldNameLiteral") as LocalizedLabel; CMSDropDownList dropDownList = e.Item.FindControl("AttributeNamesDropDownList") as CMSDropDownList; FormFieldInfo fieldInfo = e.Item.DataItem as FormFieldInfo; literal.Text = ResHelper.LocalizeString(fieldInfo.GetDisplayName(MacroContext.CurrentResolver)); dropDownList.Items.Add(new ListItem(String.Empty, String.Empty)); dropDownList.Items.AddRange(mContext.EntityInfo.Items.Select(x => new ListItem(ResHelper.LocalizeString(x.DisplayName), x.Name)).ToArray()); mAttributeNamesDropDownLists.Add(fieldInfo.Name, dropDownList); }
private void AddError(bool condition, LocalizedLabel label, string validationResult) { if (condition) { string anchorScript = label != null?String.Format("onclick=\"{0}\";", MessagesPlaceHolder.GetAnchorScript(label.ClientID, null)) : String.Empty; AddError(label.GetText(), validationResult, anchorScript); mSubmitValid = false; } }
/// <summary> /// Shows required field marks not handled automatically. /// </summary> private void ShowCustomRequiredMarks() { // Show required marks for fields visible only if the dynamic type is selected LocalizedLabel dynamicUrlLabel = NewForm.FieldLabels["NewsletterDynamicURL"]; if (dynamicUrlLabel != null) { dynamicUrlLabel.ShowRequiredMark = true; } ShowRequiredMarkForSubscriptionTemplateIDField(); }
private RetrieveEntityResponse ExecuteInternal(RetrieveEntityRequest request) { var name = new LocalizedLabel(request.LogicalName, Info.LanguageCode); var response = new RetrieveEntityResponse(); response.Results["EntityMetadata"] = new EntityMetadata { DisplayCollectionName = new Label(name, new [] { name }), }; return(response); }
public override void ReloadData() { int currPos = Convert.ToInt32(Math.Round(CurrentRating * MaxRating, MidpointRounding.AwayFromZero)); plcContent.Controls.Clear(); plcContent.Controls.Add(new LiteralControl("<table class=\"CntRatingRadioTable\"><tr>\n")); // Create radio buttons for (int i = 1; i <= MaxRating; i++) { plcContent.Controls.Add(new LiteralControl("<td>")); CMSRadioButton radBtn = new CMSRadioButton(); radBtn.ID = "radBtn_" + Convert.ToString(i); radBtn.Enabled = Enabled; if (!Enabled) { radBtn.Checked = i == currPos; } radBtn.GroupName = ClientID; plcContent.Controls.Add(radBtn); // WAI validation LocalizedLabel lbl = new LocalizedLabel(); lbl.Display = false; lbl.EnableViewState = false; lbl.ResourceString = "general.rating"; lbl.AssociatedControlID = radBtn.ID; plcContent.Controls.Add(lbl); plcContent.Controls.Add(new LiteralControl("</td>")); } plcContent.Controls.Add(new LiteralControl("\n</tr>\n<tr>\n")); // Create labels for (int i = 1; i <= MaxRating; i++) { plcContent.Controls.Add(new LiteralControl("<td>" + i.ToString() + "</td>")); } plcContent.Controls.Add(new LiteralControl("\n</tr>\n</table>")); if (Enabled) { btnSubmit.Text = ResHelper.GetString("general.ok"); btnSubmit.Click += new EventHandler(btnSubmit_Click); } // Hide button when control is disabled or external management is used btnSubmit.Visible = Enabled && !ExternalManagement; }
private void SetLabel(LocalizedLabel label, string suffix, string defaultString) { string stringPrefixName = "cloning.settings." + TranslationHelper.GetSafeClassName(typeInfo.ObjectType) + "."; string newString = stringPrefixName + suffix; if (GetString(newString) != newString) { label.ResourceString = newString; } else { label.ResourceString = defaultString; } }
public override void ReloadData() { int currPos = Convert.ToInt32(Math.Round(CurrentRating * MaxRating, MidpointRounding.AwayFromZero)); plcContent.Controls.Clear(); plcContent.Controls.Add(new LiteralControl("<table class=\"CntRatingRadioTable\"><tr>\n")); // Create radio buttons for (int i = 1; i <= MaxRating; i++) { plcContent.Controls.Add(new LiteralControl("<td>")); RadioButton radBtn = new RadioButton(); radBtn.ID = "radBtn_" + Convert.ToString(i); radBtn.Enabled = Enabled; if (!Enabled) { radBtn.Checked = i == currPos; } radBtn.GroupName = ClientID; plcContent.Controls.Add(radBtn); // WAI validation LocalizedLabel lbl = new LocalizedLabel(); lbl.Display = false; lbl.EnableViewState = false; lbl.ResourceString = "general.rating"; lbl.AssociatedControlID = radBtn.ID; plcContent.Controls.Add(lbl); plcContent.Controls.Add(new LiteralControl("</td>")); } plcContent.Controls.Add(new LiteralControl("\n</tr>\n<tr>\n")); // Create labels for (int i = 1; i <= MaxRating; i++) { plcContent.Controls.Add(new LiteralControl("<td>" + i.ToString() + "</td>")); } plcContent.Controls.Add(new LiteralControl("\n</tr>\n</table>")); if (Enabled) { btnSubmit.Text = ResHelper.GetString("general.ok"); btnSubmit.Click += new EventHandler(btnSubmit_Click); } // Hide button when control is disabled or external management is used btnSubmit.Visible = Enabled && !ExternalManagement; }
private static void CreateMenu() { MenuWobject = new WObject("Main Menu"); MenuCameraWobj = new WObject("Main Menu Camera Wobject") { Parent = MenuWobject }; Camera MainMenuCamera = MenuCameraWobj.AddModule <Camera>(); MenuBGWObject = new WObject("Main Menu Background Object"); MenuBGWObject.Parent = MenuWobject; MainMenuCamera.FOV = 80.0D; MainMenuCamera.WObject.LocalRotation = new Quaternion(25, 0, 0); MenuBGWObject.AddModule <MenuBackgroundControler>(); WObject bgPanel = new WObject("Background Panel") { Parent = MenuWobject }; bgPanel.Parent = MenuWobject; LocalizedLabel lbVersion = bgPanel.AddModule <LocalizedLabel>(); lbVersion.LocalizationArgs = new object[] { Winecrash.Version }; lbVersion.Localization = "#winecrash:ui.mainmenu.gameversion"; lbVersion.Aligns = TextAligns.Down | TextAligns.Left; lbVersion.AutoSize = true; lbVersion.MinAnchor = new Vector2F(0.0F, 0.0F); lbVersion.MaxAnchor = new Vector2F(1.0F, 0.05F); lbVersion.Color = Color256.White; lbVersion.Left = 20.0D; Label lbCopyright = bgPanel.AddModule <Label>(); lbCopyright.Text = "Copyright Arekva 2020\nAll Rights Reserved"; lbCopyright.Aligns = TextAligns.Down | TextAligns.Right; lbCopyright.AutoSize = true; lbCopyright.MinAnchor = new Vector2F(0.0F, 0.0F); lbCopyright.MaxAnchor = new Vector2F(1.0F, 0.1F); lbCopyright.Color = Color256.White; lbCopyright.Right = 20.0D; CreateMain(); CreateOptions(); CreateMultiplayer(); }
/// <summary> /// Handles content tree changes performed when Attribute type of rule is selected. /// </summary> private void AttributeRuleTypeSelected() { // Show markup containing controls related to attribute settings plcAttributeSettings.Visible = true; if (attributeFormCondition.FieldLabels != null) { // Change visual style of form label LocalizedLabel ll = attributeFormCondition.FieldLabels[mSelectedAttribute.Name]; if (ll != null) { ll.ResourceString = "om.score.condition"; } } }
public virtual ILocalizedLabelBatchBuilder Append(Guid solutionId, string label, string labelTypeName, string columnName, Guid objectId) { var entity = new LocalizedLabel { ComponentState = 0, SolutionId = solutionId, Label = label, LabelTypeCode = ModuleCollection.GetIdentity(labelTypeName), LanguageId = _appContext.GetFeature <Xms.Organization.Domain.Organization>().LanguageId, ObjectColumnName = columnName, ObjectId = objectId, LocalizedLabelId = Guid.NewGuid() }; _entities.Add(entity); return(this); }
private static void AddValueCell(Panel row, string valueText) { var valueCell = new Panel { CssClass = "editing-form-value-cell" }; row.Controls.Add(valueCell); var valueControl = new LocalizedLabel { CssClass = "form-control-text", ResourceString = valueText }; valueCell.Controls.Add(valueControl); }
/// <summary> /// Logging in handler. /// </summary> private void loginElem_LoggingIn(object sender, LoginCancelEventArgs e) { // Ban IP addresses which are blocked for login if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.Login)) { e.Cancel = true; LocalizedLabel failureLit = loginElem.FindControl("FailureText") as LocalizedLabel; if (failureLit != null) { failureLit.Visible = true; failureLit.Text = GetString("banip.ipisbannedlogin"); } } loginElem.RememberMeSet = PersistentLogin; }
/// <summary> /// Shows required field marks not handled automatically. /// </summary> private void ShowCustomRequiredMarks() { // Show required marks for fields visible only if the template-based type is selected LocalizedLabel templateLabel = NewForm.FieldLabels["NewsletterTemplateID"]; if (templateLabel != null) { templateLabel.ShowRequiredMark = true; } // Show required marks for fields visible only if the dynamic type is selected LocalizedLabel dynamicUrlLabel = NewForm.FieldLabels["NewsletterDynamicURL"]; if (dynamicUrlLabel != null) { dynamicUrlLabel.ShowRequiredMark = true; } }
private static void AddLabelCell(Panel row, string labelText) { var labelCell = new Panel { CssClass = "editing-form-label-cell" }; row.Controls.Add(labelCell); var labelControl = new LocalizedLabel { CssClass = "control-label", ResourceString = labelText, DisplayColon = true }; labelCell.Controls.Add(labelControl); }
void btnItem_Click(object sender, EventArgs e) { // Check if should send password if (IsForgottenPassword) { SetForgottenPasswordMode(); TextBox txtUserName = (TextBox)Login1.FindControl("UserName"); LocalizedLabel lblForgottenResult = (LocalizedLabel)Login1.FindControl("lblForgottenResult"); if (txtUserName != null) { // Reset password string siteName = CMSContext.CurrentSiteName; lblForgottenResult.Visible = true; bool success; lblForgottenResult.Text = UserInfoProvider.ForgottenEmailRequest(txtUserName.Text.Trim(), siteName, "Logon page", SettingsKeyProvider.GetStringValue(siteName + ".CMSSendPasswordEmailsFrom"), null, UserInfoProvider.GetResetPasswordUrl(siteName), out success); } } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); plcActivity.Visible = !AttributeRuleSelected; plcActivitySettings.Visible = !AttributeRuleSelected; plcAttribute.Visible = AttributeRuleSelected; if (AttributeRuleSelected) { if (formCondition.FieldLabels != null) { LocalizedLabel ll = (LocalizedLabel)formCondition.FieldLabels[selectedField.Name]; if (ll != null) { ll.ResourceString = "om.score.condition"; } } } }
/// <summary> /// Login error handler. /// </summary> protected void loginElem_LoginError(object sender, EventArgs e) { // Check if custom failure text is not set if (string.IsNullOrEmpty(FailureText)) { LocalizedLabel failureLit = loginElem.FindControl("FailureText") as LocalizedLabel; if (failureLit != null) { // Display account lock information if (AuthenticationHelper.DisplayAccountLockInformation(CMSContext.CurrentSiteName)) { // Check if account locked due to reaching maximum invalid logon attempts string link = "<a href=\"#\" onclick=\"" + Page.ClientScript.GetCallbackEventReference(this, "null", "UpdateLabel_" + ClientID, "'" + failureLit.ClientID + "'") + ";\">" + GetString("general.clickhere") + "</a>"; if (ValidationHelper.GetBoolean(RequestStockHelper.GetItem("UserAccountLockedInvalidLogonAttempts"), false)) { loginElem.FailureText = GetString("invalidlogonattempts.unlockaccount.accountlocked"); if (!ErrorAsPopup) { loginElem.FailureText += string.Format(GetString("invalidlogonattempts.unlockaccount.accountlockedlink"), link); } } if (ValidationHelper.GetBoolean(RequestStockHelper.GetItem("UserAccountLockedPasswordExpired"), false)) { loginElem.FailureText = GetString("passwordexpiration.accountlocked"); if (!ErrorAsPopup) { loginElem.FailureText += string.Format(GetString("invalidlogonattempts.unlockaccount.accountlockedlink"), link); } } } } } //Display the failure message in a client-side alert box if (ErrorAsPopup) { ScriptHelper.RegisterStartupScript(this, GetType(), "LoginError", ScriptHelper.GetScript("alert(" + ScriptHelper.GetString(loginElem.FailureText) + ");")); LocalizedLabel error = (LocalizedLabel)loginElem.FindControl("FailureText"); error.Visible = false; } }
/// <summary> /// Creates textboxs. /// </summary> private void CreateTextBoxs() { textBoxList = new List <TextBox>(Count); pnlAnswer.Controls.Clear(); for (int i = 0; i < Count; i++) { LocalizedLabel sepLabel = null; var txtBox = new CMSTextBox { ID = "captcha_" + i, MaxLength = 1, CssClass = "CaptchaTextBoxSmall" }; if (i > 0) { sepLabel = new LocalizedLabel { Text = Separator, CssClass = "form-control-text" }; pnlAnswer.Controls.Add(sepLabel); } pnlAnswer.Controls.Add(txtBox); textBoxList.Add(txtBox); if (sepLabel != null) { // Connect the separator with next textbox so each textbox has its own label sepLabel.AssociatedControlClientID = txtBox.ClientID; } else if (Form == null) { // If inside form, the label tag is provided by form label, otherwise it has own label lblSecurityCode.AssociatedControlClientID = txtBox.ClientID; } } }
/// <summary> /// Gets <c>Label</c> instance for the input <c>SettingsKeyInfo</c> object. /// </summary> /// <param name="settingsKey"><c>SettingsKeyInfo</c> instance</param> /// <param name="inputControl">Input control associated to the label</param> /// <param name="groupNo">Number representing index of the processing settings group</param> /// <param name="keyNo">Number representing index of the processing SettingsKeyInfo</param> private Label GetLabel(SettingsKeyInfo settingsKey, Control inputControl, int groupNo, int keyNo) { LocalizedLabel label = new LocalizedLabel { EnableViewState = false, ID = string.Format(@"lblDispName{0}{1}", groupNo, keyNo), CssClass = "control-label editing-form-label", Text = HTMLHelper.HTMLEncode(settingsKey.KeyDisplayName), DisplayColon = true }; if (inputControl != null) { label.AssociatedControlID = inputControl.ID; } ScriptHelper.AppendTooltip(label, ResHelper.LocalizeString(settingsKey.KeyDescription), null); return(label); }
protected void Page_PreRender(object sender, EventArgs e) { // Get label for info text field LocalizedLabel infoTextLabel = editForm.FieldLabels["InfoText"]; // Set label to render without colon. It is used for info message through whole form width. if (infoTextLabel != null) { infoTextLabel.DisplayColon = false; } foreach (KeyValuePair <string, SKUInfo> item in options) { // Fill attributes labels if (editForm.FieldControls[item.Key] != null) { editForm.FieldControls[item.Key].Value = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(item.Value.SKUName)); } } }
public static string GetOptionSetLabel(OptionMetadata optionMetadata, int?languageCode) { string label = string.Empty; if (optionMetadata != null) { label = optionMetadata.Label.UserLocalizedLabel.Label; if (languageCode != null) { LocalizedLabel localizedLabel = optionMetadata.Label.LocalizedLabels.FirstOrDefault(item => item.LanguageCode.Equals(languageCode)); if (localizedLabel != null) { label = localizedLabel.Label; } } } return(label); }
public void OptionSetBeanTest03() { LocalizedLabel lLabel = new LocalizedLabel("Option1", 1041); StatusAttributeMetadata meta = new StatusAttributeMetadata(); meta.OptionSet = new OptionSetMetadata() { Name = "optionSet", DisplayName = new Label("optiondisplay", LANG_CODE), Options = { new OptionMetadata(new Label(lLabel, null), 1) } }; OptionSetBean cls = new OptionSetBean(meta); Assert.True(cls.HasOptionSet()); Assert.AreEqual("Option1", cls.GetValue(1), "ラベルあり"); }
/// <summary> /// Sets SkinId to all controls in logon form. /// </summary> private void SetSkinID(string skinId) { if (skinId != "") { Login1.SkinID = skinId; LocalizedLabel lbl = (LocalizedLabel)Login1.FindControl("lblUserName"); if (lbl != null) { lbl.SkinID = skinId; } lbl = (LocalizedLabel)Login1.FindControl("lblPassword"); if (lbl != null) { lbl.SkinID = skinId; } TextBox txt = (TextBox)Login1.FindControl("UserName"); if (txt != null) { txt.SkinID = skinId; } txt = (TextBox)Login1.FindControl("Password"); if (txt != null) { txt.SkinID = skinId; } LocalizedCheckBox chk = (LocalizedCheckBox)Login1.FindControl("chkRememberMe"); if (chk != null) { chk.SkinID = skinId; } LocalizedButton btn = (LocalizedButton)Login1.FindControl("LoginButton"); if (btn != null) { btn.SkinID = skinId; } } }
public void GetAttributeInfoAttributeString( string logicalName, string optionLabel, int optionValue, string expected) { var localizedLabel = new LocalizedLabel(optionLabel, 1033); var metadata = new PicklistAttributeMetadata { LogicalName = logicalName, OptionSet = new OptionSetMetadata { Options = { new OptionMetadata { Label = new Label(localizedLabel, new[]{ localizedLabel }), Value = optionValue } } } }; Assert.Equal(expected, new PropertyGenerator(metadata, Template.Property).GetAttributeInfoAttributeString()); }
/// <summary> /// Ligging in handler. /// </summary> private void Login1_LoggingIn(object sender, LoginCancelEventArgs e) { // Ban IP addresses which are blocked for login if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.Login)) { e.Cancel = true; LocalizedLabel failureLit = Login1.FindControl("FailureText") as LocalizedLabel; if (failureLit != null) { failureLit.Visible = true; failureLit.Text = GetString("banip.ipisbannedlogin"); } } if (((CheckBox)Login1.FindControl("chkRememberMe")).Checked) { Login1.RememberMeSet = true; } else { Login1.RememberMeSet = false; } }
/// <summary> /// Creates poll answer section. /// </summary> /// <param name="reload">Indicates postback</param> /// <param name="hasVoted">Indicates if user has voted</param> protected void CreateAnswerSection(bool reload, bool hasVoted) { pnlAnswer.Controls.Clear(); if (pi != null) { // Get poll's answers DataSet ds = Answers; if (!DataHelper.DataSourceIsEmpty(ds)) { int count = 0; int maxCount = 0; long sumCount = 0; // Sum answer counts and get highest foreach (DataRow row in ds.Tables[0].Rows) { if (ValidationHelper.GetBoolean(row["AnswerEnabled"], true)) { count = ValidationHelper.GetInteger(row["AnswerCount"], 0); sumCount += count; if (count > maxCount) { maxCount = count; } } } LocalizedCheckBox chkItem = null; LocalizedRadioButton radItem = null; LocalizedLabel lblItem = null; int index = 0; bool enabled = false; pnlAnswer.Controls.Add(new LiteralControl("<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">")); // Create the answers foreach (DataRow row in ds.Tables[0].Rows) { enabled = ValidationHelper.GetBoolean(row["AnswerEnabled"], true); if (enabled) { pnlAnswer.Controls.Add(new LiteralControl("<tr><td class=\"PollAnswer\" colspan=\"2\">")); if (((reload) && (this.ShowResultsAfterVote)) || (!hasPermission && !this.HideWhenNotAuthorized) || (!isOpened && !this.HideWhenNotOpened) || (this.CheckVoted && PollInfoProvider.HasVoted(pi.PollID))) { // Add label lblItem = new LocalizedLabel(); lblItem.ID = "lbl" + ValidationHelper.GetInteger(row["AnswerID"], 0); lblItem.EnableViewState = false; lblItem.Text = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], "")); lblItem.CssClass = "PollAnswerText"; pnlAnswer.Controls.Add(lblItem); } else { if (pi.PollAllowMultipleAnswers) { // Add checkboxes for multiple answers chkItem = new LocalizedCheckBox(); chkItem.ID = "chk" + ValidationHelper.GetInteger(row["AnswerID"], 0); chkItem.AutoPostBack = false; chkItem.Text = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], "")); chkItem.Checked = false; chkItem.CssClass = "PollAnswerCheck"; pnlAnswer.Controls.Add(chkItem); } else { // Add radiobuttons radItem = new LocalizedRadioButton(); radItem.ID = "rad" + ValidationHelper.GetInteger(row["AnswerID"], 0); radItem.AutoPostBack = false; radItem.GroupName = pi.PollCodeName + "Group"; radItem.Text = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], "")); radItem.Checked = false; radItem.CssClass = "PollAnswerRadio"; pnlAnswer.Controls.Add(radItem); } } pnlAnswer.Controls.Add(new LiteralControl("</td></tr>")); if (this.ShowGraph || (hasVoted || reload) && this.ShowResultsAfterVote) { // Create graph under the answer CreateGraph(maxCount, ValidationHelper.GetInteger(row["AnswerCount"], 0), sumCount, index); } index++; } } pnlAnswer.Controls.Add(new LiteralControl("</table>")); } } }
private void CreateLookupAttribute(string entityLogicalName, AttributeTemplate attributeTemplate) { var schemaName = attributeTemplate.LogicalName + "_" + attributeTemplate.LookupEntityLogicalName + "_" + entityLogicalName; if(schemaName.Length > 100) { schemaName = schemaName.Substring(default(int), 100); } var createOneToManyRequest = new CreateOneToManyRequest { Lookup = new LookupAttributeMetadata { Description = GetLabelWithLocalized(attributeTemplate.Description), DisplayName = GetLabelWithLocalized(attributeTemplate.DisplayNameShort), LogicalName = attributeTemplate.LogicalName, SchemaName = attributeTemplate.LogicalName, RequiredLevel = new AttributeRequiredLevelManagedProperty(attributeTemplate.IsRequired ? AttributeRequiredLevel.SystemRequired : AttributeRequiredLevel.None) }, OneToManyRelationship = new OneToManyRelationshipMetadata { ReferencedEntity = attributeTemplate.LookupEntityLogicalName, ReferencingEntity = entityLogicalName, SchemaName = schemaName } }; if (!string.IsNullOrWhiteSpace(attributeTemplate.OtherDisplayName)) { var otherDisplayLabel = new LocalizedLabel(attributeTemplate.OtherDisplayName, DefaultConfiguration.OtherLanguageCode); createOneToManyRequest.Lookup.DisplayName.LocalizedLabels.Add(otherDisplayLabel); } if (!string.IsNullOrWhiteSpace(attributeTemplate.OtherDescription)) { var otherDescriptionLabel = new LocalizedLabel(attributeTemplate.OtherDescription, DefaultConfiguration.OtherLanguageCode); createOneToManyRequest.Lookup.Description.LocalizedLabels.Add(otherDescriptionLabel); } CreateRequest createWebRequest = null; if (attributeTemplate.DisplayName.Length > DefaultConfiguration.AttributeDisplayNameMaxLength) { createWebRequest = GetCreateWebResourceRequest(entityLogicalName, attributeTemplate); } ExecuteOperation(GetSharedOrganizationService(), createOneToManyRequest, string.Format("An error occured while creating the attribute: {0}", attributeTemplate.LogicalName)); if (createWebRequest != null) { ExecuteOperation(GetSharedOrganizationService(), createWebRequest, string.Format("An error occured while creating the web resource for attribute: {0}", attributeTemplate.LogicalName)); } }
/// <summary> /// Add filter field to the filter table. /// </summary> /// <param name="filter">Filter definition</param> /// <param name="columnSourceName">Column source field name</param> /// <param name="fieldDisplayName">Field display name</param> /// <param name="filterWrapperControl">Wrapper control for filter</param> /// <param name="filterValue">Filter value</param> private void AddFilterField(ColumnFilter filter, string columnSourceName, string fieldDisplayName, Control filterWrapperControl, string filterValue) { string fieldSourceName = filter.Source ?? columnSourceName; if (String.IsNullOrEmpty(fieldSourceName) || (filter == null) || (filterWrapperControl == null)) { return; } string fieldPath = filter.Path; string filterFormat = filter.Format; int filterSize = filter.Size; Unit filterWidth = filter.Width; Panel fieldWrapperPanel = new Panel() { CssClass = "form-group" }; Panel fieldLabelPanel = new Panel() { CssClass = "filter-form-label-cell" }; Panel fieldOptionPanel = new Panel() { CssClass = "filter-form-condition-cell" }; Panel fieldInputPanel = new Panel() { CssClass = "filter-form-value-cell" }; // Ensure fieldSourceName is JavaScript valid fieldSourceName = fieldSourceName.Replace(ALL, "__ALL__"); int index = GetNumberOfFilterFieldsWithSameSourceColumn(fieldSourceName); string filterControlID = fieldSourceName + (index > 0 ? index.ToString() : String.Empty); Label textName = new Label { Text = String.IsNullOrEmpty(fieldDisplayName) ? String.Empty : fieldDisplayName + ":", ID = String.Format("{0}Name", filterControlID), EnableViewState = false, CssClass = "control-label" }; fieldLabelPanel.Controls.Add(textName); fieldWrapperPanel.Controls.Add(fieldLabelPanel); // Filter value string value = null; if (filterValue != null) { value = ValidationHelper.GetString(filterValue, null); } // Filter definition UniGridFilterField filterDefinition = new UniGridFilterField(); filterDefinition.Type = filter.Type; filterDefinition.Label = textName; filterDefinition.Format = filterFormat; filterDefinition.FilterRow = fieldWrapperPanel; // Set the filter default value string defaultValue = filter.DefaultValue; // Remember default values of filter field controls for potential UniGrid reset string optionFilterFieldValue = null; string valueFilterFieldValue = null; switch (filterDefinition.Type) { // Text filter case UniGridFilterTypeEnum.Text: { CMSDropDownList textOptionFilterField = new CMSDropDownList(); ControlsHelper.FillListWithTextSqlOperators(textOptionFilterField); textOptionFilterField.ID = filterControlID; // Set the value SetDropdownValue(value, null, textOptionFilterField); optionFilterFieldValue = textOptionFilterField.SelectedValue; LocalizedLabel lblSelect = new LocalizedLabel { EnableViewState = false, CssClass = "sr-only", AssociatedControlID = textOptionFilterField.ID, ResourceString = "filter.mode" }; fieldOptionPanel.Controls.Add(lblSelect); fieldOptionPanel.Controls.Add(textOptionFilterField); fieldWrapperPanel.Controls.Add(fieldOptionPanel); CMSTextBox textValueFilterField = new CMSTextBox { ID = String.Format("{0}TextValue", filterControlID) }; // Set value SetTextboxValue(value, defaultValue, textValueFilterField); valueFilterFieldValue = textValueFilterField.Text; if (filterSize > 0) { textValueFilterField.MaxLength = filterSize; } if (!filterWidth.IsEmpty) { textValueFilterField.Width = filterWidth; } fieldInputPanel.Controls.Add(textValueFilterField); fieldWrapperPanel.Controls.Add(fieldInputPanel); textName.AssociatedControlID = textValueFilterField.ID; filterDefinition.OptionsControl = textOptionFilterField; filterDefinition.ValueControl = textValueFilterField; } break; // Boolean filter case UniGridFilterTypeEnum.Bool: { CMSDropDownList booleanOptionFilterField = new CMSDropDownList(); booleanOptionFilterField.Items.Add(new ListItem(GetString("general.selectall"), String.Empty)); booleanOptionFilterField.Items.Add(new ListItem(GetString("general.yes"), "1")); booleanOptionFilterField.Items.Add(new ListItem(GetString("general.no"), "0")); booleanOptionFilterField.ID = filterControlID; textName.AssociatedControlID = booleanOptionFilterField.ID; // Set the value SetDropdownValue(value, defaultValue, booleanOptionFilterField); valueFilterFieldValue = booleanOptionFilterField.SelectedValue; // Set input panel wide for boolean Drop-down list fieldInputPanel.CssClass = "filter-form-value-cell-wide"; fieldInputPanel.Controls.Add(booleanOptionFilterField); fieldWrapperPanel.Controls.Add(fieldInputPanel); filterDefinition.ValueControl = booleanOptionFilterField; } break; // Integer filter case UniGridFilterTypeEnum.Integer: case UniGridFilterTypeEnum.Double: { CMSDropDownList numberOptionFilterField = new CMSDropDownList(); numberOptionFilterField.Items.Add(new ListItem(GetString("filter.equals"), "=")); numberOptionFilterField.Items.Add(new ListItem(GetString("filter.notequals"), "<>")); numberOptionFilterField.Items.Add(new ListItem(GetString("filter.lessthan"), "<")); numberOptionFilterField.Items.Add(new ListItem(GetString("filter.greaterthan"), ">")); numberOptionFilterField.ID = filterControlID; // Set the value SetDropdownValue(value, null, numberOptionFilterField); optionFilterFieldValue = numberOptionFilterField.SelectedValue; LocalizedLabel lblSelect = new LocalizedLabel { EnableViewState = false, CssClass = "sr-only", AssociatedControlID = numberOptionFilterField.ID, ResourceString = "filter.mode" }; // Add filter field fieldOptionPanel.Controls.Add(lblSelect); fieldOptionPanel.Controls.Add(numberOptionFilterField); fieldWrapperPanel.Controls.Add(fieldOptionPanel); CMSTextBox numberValueFilterField = new CMSTextBox { ID = String.Format("{0}NumberValue", filterControlID) }; // Set value SetTextboxValue(value, defaultValue, numberValueFilterField); valueFilterFieldValue = numberValueFilterField.Text; if (filterSize > 0) { numberValueFilterField.MaxLength = filterSize; } if (!filterWidth.IsEmpty) { numberValueFilterField.Width = filterWidth; } numberValueFilterField.EnableViewState = false; fieldInputPanel.Controls.Add(numberValueFilterField); fieldWrapperPanel.Controls.Add(fieldInputPanel); filterDefinition.OptionsControl = numberOptionFilterField; filterDefinition.ValueControl = numberValueFilterField; } break; case UniGridFilterTypeEnum.Site: { // Site selector fieldPath = "~/CMSFormControls/Filters/SiteFilter.ascx"; } break; case UniGridFilterTypeEnum.Custom: // Load custom path { if (String.IsNullOrEmpty(fieldPath)) { throw new Exception("[UniGrid.AddFilterField]: Filter field path is not set"); } } break; default: // Not supported filter type throw new Exception("[UniGrid.AddFilterField]: Filter type '" + filterDefinition.Type + "' is not supported. Supported filter types: integer, double, bool, text, site, custom."); } // Else if filter path is defined use custom filter if (fieldPath != null) { // Add to the controls collection CMSAbstractBaseFilterControl filterControl = LoadFilterControl(fieldPath, filterControlID, value, filterDefinition, filter); if (filterControl != null) { // Set default value if (!String.IsNullOrEmpty(defaultValue)) { filterControl.SelectedValue = defaultValue; } fieldInputPanel.Controls.Add(filterControl); } fieldInputPanel.CssClass = "filter-form-value-cell-wide"; fieldWrapperPanel.Controls.Add(fieldInputPanel); } RaiseOnFilterFieldCreated(fieldSourceName, filterDefinition); FilterFields[String.Format("{0}{1}", fieldSourceName, (index > 0 ? "#" + index : String.Empty))] = filterDefinition; filterWrapperControl.Controls.Add(fieldWrapperPanel); // Store initial filter state for potential UniGrid reset if (filterDefinition.OptionsControl != null) { InitialFilterStateControls.Add(new KeyValuePair<Control, object>(filterDefinition.OptionsControl, optionFilterFieldValue)); } if (filterDefinition.ValueControl != null) { if (!(filterDefinition.ValueControl is CMSAbstractBaseFilterControl)) { InitialFilterStateControls.Add(new KeyValuePair<Control, object>(filterDefinition.ValueControl, valueFilterFieldValue)); } } }
private RetrieveEntityResponse ExecuteInternal(RetrieveEntityRequest request) { var name = new LocalizedLabel(request.LogicalName, Info.LanguageCode); var response = new RetrieveEntityResponse(); response.Results["EntityMetadata"] = new EntityMetadata { DisplayCollectionName = new Label(name, new [] { name }), }; return response; }
/// <summary> /// Creates poll answer section. /// </summary> /// <param name="reload">Indicates postback</param> /// <param name="hasVoted">Indicates if user has voted</param> protected void CreateAnswerSection(bool reload, bool hasVoted) { pnlAnswer.Controls.Clear(); if (pi != null) { // Get poll's answers DataSet ds = Answers; if (!DataHelper.DataSourceIsEmpty(ds)) { int count = 0; int maxCount = 0; long sumCount = 0; bool hideSomeForm = false; foreach (DataRow row in ds.Tables[0].Rows) { // Sum answer counts and get highest if (ValidationHelper.GetBoolean(row["AnswerEnabled"], true)) { count = ValidationHelper.GetInteger(row["AnswerCount"], 0); sumCount += count; if (count > maxCount) { maxCount = count; } } // Check if any open-ended answer form should be hidden if (ValidationHelper.GetBoolean(row["AnswerHideForm"], false)) { hideSomeForm = true; } } CMSCheckBox chkItem = null; CMSRadioButton radItem = null; LocalizedLabel lblItem = null; BizForm viewBiz = null; string formName = null; int index = 0; bool enabled = false; bool bizFormsAvailable = ModuleManager.IsModuleLoaded(ModuleName.BIZFORM) && ResourceSiteInfoProvider.IsResourceOnSite(ModuleName.BIZFORM, SiteContext.CurrentSiteName); pnlAnswer.Controls.Add(new LiteralControl("<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">")); // Create the answers foreach (DataRow row in ds.Tables[0].Rows) { enabled = ValidationHelper.GetBoolean(row["AnswerEnabled"], true); if (enabled) { pnlAnswer.Controls.Add(new LiteralControl("<tr><td class=\"PollAnswer\" colspan=\"2\">")); if (((reload) && (ShowResultsAfterVote)) || (!hasPermission && !HideWhenNotAuthorized) || (!isOpened && !HideWhenNotOpened) || (CheckVoted && PollInfoProvider.HasVoted(pi.PollID))) { // Add label lblItem = new LocalizedLabel(); lblItem.ID = "lbl" + ValidationHelper.GetInteger(row["AnswerID"], 0); lblItem.EnableViewState = false; lblItem.Text = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], string.Empty)); lblItem.CssClass = "PollAnswerText"; pnlAnswer.Controls.Add(lblItem); } else { if (pi.PollAllowMultipleAnswers) { // Add checkboxes for multiple answers chkItem = new CMSCheckBox(); chkItem.ID = "chk" + ValidationHelper.GetInteger(row["AnswerID"], 0); chkItem.AutoPostBack = false; chkItem.Text = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], string.Empty)); chkItem.Checked = false; chkItem.CssClass = "PollAnswerCheck"; if (hideSomeForm) { chkItem.AutoPostBack = true; chkItem.CheckedChanged += AnswerSelectionChanged; } pnlAnswer.Controls.Add(chkItem); } else { // Add radiobuttons radItem = new CMSRadioButton(); radItem.ID = "rad" + ValidationHelper.GetInteger(row["AnswerID"], 0); radItem.AutoPostBack = false; radItem.GroupName = pi.PollCodeName + "Group"; radItem.Text = HTMLHelper.HTMLEncode(ValidationHelper.GetString(row["AnswerText"], string.Empty)); radItem.Checked = false; radItem.CssClass = "PollAnswerRadio"; if (hideSomeForm) { radItem.AutoPostBack = true; radItem.CheckedChanged += AnswerSelectionChanged; } pnlAnswer.Controls.Add(radItem); } formName = ValidationHelper.GetString(row["AnswerForm"], string.Empty); if (!string.IsNullOrEmpty(formName) && bizFormsAvailable) { // Add forms for open ended answers viewBiz = new BizForm(); viewBiz.FormName = formName; viewBiz.SiteName = SiteContext.CurrentSiteName; viewBiz.AlternativeFormFullName = ValidationHelper.GetString(row["AnswerAlternativeForm"], string.Empty); viewBiz.ID = "frm" + ValidationHelper.GetInteger(row["AnswerID"], 0); viewBiz.IsLiveSite = IsLiveSite; viewBiz.OnAfterDataLoad += Form_AfterDataLoad; viewBiz.CssClass = "PollAnswerForm"; viewBiz.Visible = !ValidationHelper.GetBoolean(row["AnswerHideForm"], false); viewBiz.FormClearAfterSave = true; viewBiz.FormRedirectToUrl = String.Empty; viewBiz.FormDisplayText = String.Empty; pnlAnswer.Controls.Add(viewBiz); } } pnlAnswer.Controls.Add(new LiteralControl("</td></tr>")); if (ShowGraph || (hasVoted || reload) && ShowResultsAfterVote) { // Create graph under the answer CreateGraph(maxCount, ValidationHelper.GetInteger(row["AnswerCount"], 0), sumCount, index); } index++; } } pnlAnswer.Controls.Add(new LiteralControl("</table>")); } } }
/// <summary> /// Loads custom fields collisions. /// </summary> private void LoadCustomFields() { // Check if account has any custom fields FormInfo formInfo = FormHelper.GetFormInfo(parentAccount.ClassName, false); ArrayList list = formInfo.GetFormElements(true, false, true); if (list.Count > 0) { 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 for (int i = 0; i < list.Count; i++) { ffi = list[i] 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 mergedAccounts.Tables[0].DefaultView.Sort = ffi.Name + " ASC"; if ((ffi.DataType == FormFieldDataTypeEnum.LongText) || (ffi.DataType == FormFieldDataTypeEnum.Text)) { mergedAccounts.Tables[0].DefaultView.RowFilter = ffi.Name + " NOT LIKE ''"; } else { mergedAccounts.Tables[0].DefaultView.RowFilter = ffi.Name + " IS NOT NULL"; } dt = mergedAccounts.Tables[0].DefaultView.ToTable(true, 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> /// Loads custom fields collisions. /// </summary> private void LoadCustomFields() { // Check if contact has any custom fields FormInfo formInfo = FormHelper.GetFormInfo(mParentContact.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 form-merge-collisions\">"; plcCustomFields.Controls.Add(content); 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-value-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 = SortGroupContactsByColumn(ffi.Name + SqlHelper.ORDERBY_ASC, ffi.Name + " NOT LIKE ''", ffi.Name); } else { dt = SortGroupContactsByColumn(ffi.Name + SqlHelper.ORDERBY_ASC, ffi.Name + " IS NOT NULL", ffi.Name); } // Load value into textbox txt.Text = ValidationHelper.GetString(mParentContact.GetValue(ffi.Name), null); if (string.IsNullOrEmpty(txt.Text) && (dt.Rows.Count > 0)) { txt.Text = ValidationHelper.GetString(dt.Rows[0][ffi.Name], null); } var img = new HtmlGenericControl("i"); img.Attributes["class"] = "validation-warning icon-exclamation-triangle form-control-icon"; DisplayTooltip(img, dt, ffi.Name, ValidationHelper.GetString(mParentContact.GetValue(ffi.Name), ""), ffi.DataType); plcCustomFields.Controls.Add(img); content = new Literal(); content.Text = "</div></div></div>"; plcCustomFields.Controls.Add(content); mMergedContacts.Tables[0].DefaultView.RowFilter = null; } } content = new Literal(); content.Text = "</div>"; plcCustomFields.Controls.Add(content); } else { tabCustomFields.Visible = false; tabCustomFields.HeaderText = null; } }
/// <summary> /// Add filter field to the filter table. /// </summary> /// <param name="fieldType">Field type</param> /// <param name="fieldPath">Filter contol file path. If not starts with ~/ default directory '~/CMSAdminControls/UI/UniGrid/Filters/' will be inserted at begining</param> /// <param name="filterFormat">Filter format string</param> /// <param name="fieldSourceName">Source field name</param> /// <param name="fieldDisplayName">Field display name</param> /// <param name="filterTable">Filter table</param> /// <param name="filterOption">Filter option</param> /// <param name="filterValue">Filter value</param> /// <param name="filterSize">Filter size</param> private void AddFilterField(string fieldType, string fieldPath, string filterFormat, string fieldSourceName, string fieldDisplayName, Table filterTable, object filterOption, object filterValue, int filterSize) { TableRow tRow = new TableRow(); TableCell tCellName = new TableCell(); TableCell tCellOption = new TableCell(); TableCell tCellValue = new TableCell(); // Ensure fieldSourceName is Javascript valid fieldSourceName = fieldSourceName.Replace(ALL, "__ALL__"); // Label Label textName = new Label { Text = fieldDisplayName + ":", ID = fieldSourceName + "Name", EnableViewState = false }; tCellName.Controls.Add(textName); tRow.Cells.Add(tCellName); // Filter option string option = null; if (filterOption != null) { option = ValidationHelper.GetString(filterOption, null); } // Filter value string value = null; if (filterValue != null) { value = ValidationHelper.GetString(filterValue, null); } // Filter definition // 0 = Type // 1 = Format // 2 = Option control // 3 = Filter value control // 4 = FilterID object[] filterDefinition = new object[5]; filterDefinition[0] = (fieldType != null) ? fieldType.ToLower() : null; filterDefinition[1] = filterFormat; // If no filter path us default filter if (String.IsNullOrEmpty(fieldPath)) { switch (fieldType.ToLower()) { // Text filter case "text": { DropDownList textOptionFilterField = new DropDownList(); textOptionFilterField.Items.Add(new ListItem("LIKE", "LIKE")); textOptionFilterField.Items.Add(new ListItem("NOT LIKE", "NOT LIKE")); textOptionFilterField.Items.Add(new ListItem("=", "=")); textOptionFilterField.Items.Add(new ListItem("<>", "<>")); textOptionFilterField.CssClass = "ContentDropdown"; textOptionFilterField.ID = fieldSourceName; // Select filter option try { textOptionFilterField.SelectedValue = option; } catch { } LocalizedLabel lblSelect = new LocalizedLabel { EnableViewState = false, Display = false, AssociatedControlID = textOptionFilterField.ID, ResourceString = "general.select" }; tCellOption.Controls.Add(lblSelect); tCellOption.Controls.Add(textOptionFilterField); tRow.Cells.Add(tCellOption); // Add text field TextBox textValueFilterField = new TextBox { ID = fieldSourceName + "TextValue", Text = value }; if (filterSize > 0) { textValueFilterField.MaxLength = filterSize; } tCellValue.Controls.Add(textValueFilterField); tRow.Cells.Add(tCellValue); textName.AssociatedControlID = textValueFilterField.ID; filterDefinition[2] = textOptionFilterField; filterDefinition[3] = textValueFilterField; } break; // Boolean filter case "bool": { DropDownList booleanOptionFilterField = new DropDownList(); booleanOptionFilterField.Items.Add(new ListItem(GetString("general.selectall"), "")); booleanOptionFilterField.Items.Add(new ListItem(GetString("general.yes"), "1")); booleanOptionFilterField.Items.Add(new ListItem(GetString("general.no"), "0")); booleanOptionFilterField.CssClass = "ContentDropdown"; booleanOptionFilterField.ID = fieldSourceName; textName.AssociatedControlID = booleanOptionFilterField.ID; // Select filter option try { booleanOptionFilterField.SelectedValue = value; } catch { } tCellValue.Controls.Add(booleanOptionFilterField); tRow.Cells.Add(tCellValue); filterDefinition[3] = booleanOptionFilterField; } break; // Integer filter case "integer": case "double": { DropDownList numberOptionFilterField = new DropDownList(); numberOptionFilterField.Items.Add(new ListItem("=", "=")); numberOptionFilterField.Items.Add(new ListItem("<>", "<>")); numberOptionFilterField.Items.Add(new ListItem("<", "<")); numberOptionFilterField.Items.Add(new ListItem(">", ">")); numberOptionFilterField.CssClass = "ContentDropdown"; numberOptionFilterField.ID = fieldSourceName; // Select filter option try { numberOptionFilterField.SelectedValue = option; } catch { } LocalizedLabel lblSelect = new LocalizedLabel { EnableViewState = false, Display = false, AssociatedControlID = numberOptionFilterField.ID, ResourceString = "general.select" }; // Add filter field tCellOption.Controls.Add(lblSelect); tCellOption.Controls.Add(numberOptionFilterField); tRow.Cells.Add(tCellOption); TextBox numberValueFilterField = new TextBox { ID = fieldSourceName + "NumberValue", Text = value }; if (filterSize > 0) { numberValueFilterField.MaxLength = filterSize; } numberValueFilterField.EnableViewState = false; tCellValue.Controls.Add(numberValueFilterField); tRow.Cells.Add(tCellValue); filterDefinition[2] = numberOptionFilterField; filterDefinition[3] = numberValueFilterField; } break; } } // Else if filter path is defined use custom filter else { string path = fieldPath.StartsWith("~/") ? fieldPath : FilterDirectoryPath + fieldPath.TrimStart('/'); CMSAbstractBaseFilterControl filterControl = LoadControl(path) as CMSAbstractBaseFilterControl; if (filterControl != null) { filterControl.ID = fieldSourceName; tCellValue.Controls.Add(filterControl); } tCellValue.Attributes["colspan"] = "2"; tRow.Cells.Add(tCellValue); if (filterControl != null) { filterControl.FilteredControl = this; if (!RequestHelper.IsPostBack()) { filterControl.Value = value; } filterDefinition[3] = filterControl; filterDefinition[4] = filterControl.ID; } } mFilterFields.Add(filterDefinition); filterTable.Rows.Add(tRow); }
public LocalizedLabelInfo(LocalizedLabel amd) { this.amd = amd; }
/// <summary> /// Adds contact's custom fields to the dialog. /// </summary> /// <param name="fields">Array list with custom fields (FormFieldInfo)</param> protected void AddCustomFields(IEnumerable<IField> fields) { CMSModules_AdminControls_Controls_Class_ClassFields fieldControl = null; // Initialize hashtable that will store controls for custom fields customControls = new Hashtable(); // Add form to the placeholder 'Custom' Panel form = new Panel { CssClass = "form-horizontal" }; plcCustom.Controls.Add(form); FormFieldInfo field; foreach (IField item in fields) { if (!(item is FormFieldInfo)) { continue; } field = item as FormFieldInfo; Panel formGroup = new Panel { CssClass = "form-group" }; form.Controls.Add(formGroup); // Create label div Panel labelPanel = new Panel { CssClass = "editing-form-label-cell" }; formGroup.Controls.Add(labelPanel); // Create label LocalizedLabel label = new LocalizedLabel(); label.Text = ResHelper.LocalizeString(field.GetDisplayName(MacroContext.CurrentResolver)); label.EnableViewState = false; label.DisplayColon = true; label.CssClass = "control-label"; labelPanel.Controls.Add(label); // Create value div Panel valuePanel = new Panel { CssClass = "editing-form-value-cell" }; formGroup.Controls.Add(valuePanel); // Create control fieldControl = (CMSModules_AdminControls_Controls_Class_ClassFields)Page.LoadUserControl("~/CMSModules/AdminControls/Controls/Class/ClassFields.ascx"); fieldControl.ID = "fld" + field.Name; fieldControl.ClassName = ClassName; fieldControl.FieldDataType = field.DataType; valuePanel.Controls.Add(fieldControl); // Store the control to hashtable customControls.Add(field.Name, fieldControl); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // WAI validation lblUserName = (LocalizedLabel)loginElem.FindControl("lblUserName"); if (lblUserName != null) { lblUserName.Text = GetString("general.username"); if (!ShowUserNameLabel) { lblUserName.Attributes.Add("style", "display: none;"); } } lblPassword = (LocalizedLabel)loginElem.FindControl("lblPassword"); if (lblPassword != null) { lblPassword.Text = GetString("general.password"); if (!ShowPasswordLabel) { lblPassword.Attributes.Add("style", "display: none;"); } } // Set properties for validator rfv = (RequiredFieldValidator)loginElem.FindControl("rfvUserNameRequired"); rfv.ErrorMessage = GetString("edituser.erroremptyusername"); rfv.ToolTip = GetString("edituser.erroremptyusername"); rfv.ValidationGroup = ClientID + "_MiniLogon"; // Set failure text if (!string.IsNullOrEmpty(FailureText)) { loginElem.FailureText = ResHelper.LocalizeString(FailureText); } else { loginElem.FailureText = GetString("Login_FailureText"); } // Set visibility of buttons login = (LocalizedButton)loginElem.FindControl("btnLogon"); if (login != null) { login.Visible = !ShowImageButton; login.ValidationGroup = ClientID + "_MiniLogon"; } loginImg = (ImageButton)loginElem.FindControl("btnImageLogon"); if (loginImg != null) { loginImg.Visible = ShowImageButton; loginImg.ImageUrl = ImageUrl; loginImg.ValidationGroup = ClientID + "_MiniLogon"; } // Ensure display control as inline and is used right default button container = (Panel)loginElem.FindControl("pnlLogonMiniForm"); if (container != null) { container.Attributes.Add("style", "display: inline;"); if (ShowImageButton) { if (loginImg != null) { container.DefaultButton = loginImg.ID; } else if (login != null) { container.DefaultButton = login.ID; } } } CMSTextBox txtUserName = (CMSTextBox)loginElem.FindControl("UserName"); if (txtUserName != null) { txtUserName.EnableAutoComplete = SecurityHelper.IsAutoCompleteEnabledForLogin(CMSContext.CurrentSiteName); } if (!string.IsNullOrEmpty(UserNameText)) { // Initialize javascript for focus and blur UserName textbox user = (TextBox)loginElem.FindControl("UserName"); user.Attributes.Add("onfocus", "MLUserFocus_" + ClientID + "('focus');"); user.Attributes.Add("onblur", "MLUserFocus_" + ClientID + "('blur');"); string focusScript = "function MLUserFocus_" + ClientID + "(type)" + "{" + "var userNameBox = document.getElementById('" + user.ClientID + "');" + "if(userNameBox.value == '" + UserNameText + "' && type == 'focus')" + "{userNameBox.value = '';}" + "else if (userNameBox.value == '' && type == 'blur')" + "{userNameBox.value = '" + UserNameText + "';}" + "}"; ScriptHelper.RegisterClientScriptBlock(this, GetType(), "MLUserNameFocus_" + ClientID, ScriptHelper.GetScript(focusScript)); } loginElem.LoggedIn += loginElem_LoggedIn; loginElem.LoggingIn += loginElem_LoggingIn; loginElem.LoginError += loginElem_LoginError; if (!RequestHelper.IsPostBack()) { // Set SkinID properties if (!StandAlone && (PageCycle < PageCycleEnum.Initialized) && (ValidationHelper.GetString(Page.StyleSheetTheme, string.Empty) == string.Empty)) { SetSkinID(SkinID); } } if (string.IsNullOrEmpty(loginElem.UserName)) { loginElem.UserName = UserNameText; } // Register script to update logon error message Label failureLit = loginElem.FindControl("FailureText") as Label; if (failureLit != null) { StringBuilder sbScript = new StringBuilder(); sbScript.Append(@" function UpdateLabel_", ClientID, @"(content, context) { var lbl = document.getElementById(context); if(lbl) { lbl.innerHTML = content; lbl.className = ""InfoLabel""; } }"); ScriptHelper.RegisterClientScriptBlock(this, GetType(), "InvalidLogonAttempts_" + ClientID, sbScript.ToString(), true); } } }
/// <summary> /// Adds contact's custom fields to the dialog. /// </summary> /// <param name="fields">Array list with custom fields (FormFieldInfo)</param> protected void AddCustomFields(ArrayList fields) { TableRow tabRow = null; TableCell tabCell = null; LocalizedLabel label = null; CMSModules_AdminControls_Controls_Class_ClassFields fieldControl = null; // Initialize hashtable that will store controls for custom fields customControls = new Hashtable(); // Add table to the placeholder 'Custom' Table table = new Table(); plcCustom.Controls.Add(table); int i = 0; bool newRow = true; foreach (FormFieldInfo field in fields) { newRow = (i % 2) == 0; // Create new row - each row contains two controls if (newRow) { tabRow = new TableRow(); table.Rows.Add(tabRow); } // Create lable cell tabCell = new TableCell(); tabCell.CssClass = "ContactLabel"; tabRow.Cells.Add(tabCell); // Create label label = new LocalizedLabel(); label.Text = ResHelper.LocalizeString(field.Caption); label.EnableViewState = false; label.DisplayColon = true; tabCell.Controls.Add(label); // Create control cell tabCell = new TableCell(); if (newRow) { tabCell.CssClass = "ContactControl"; } else { tabCell.CssClass = "ContactControlRight"; } tabRow.Cells.Add(tabCell); // Create control fieldControl = (CMSModules_AdminControls_Controls_Class_ClassFields)Page.LoadControl("~/CMSModules/AdminControls/Controls/Class/ClassFields.ascx"); fieldControl.ID = "fld" + field.Name; fieldControl.ClassName = ClassName; fieldControl.FieldDataType = field.DataType; tabCell.Controls.Add(fieldControl); // Store the control to hashtable customControls.Add(field.Name, fieldControl); i++; } }
private void CreateGlobalOptionSetAttribute(AttributeTemplate attributeTemplate) { var optionMetadataCollection = GetOptionMetadataCollection(attributeTemplate); var createOptionSetRequest = new CreateOptionSetRequest { OptionSet = new OptionSetMetadata(optionMetadataCollection) { Name = attributeTemplate.GlobalOptionSetListLogicalName, DisplayName = GetLabelWithLocalized(attributeTemplate.DisplayNameShort), Description = GetLabelWithLocalized(attributeTemplate.Description), IsGlobal = true, OptionSetType = OptionSetType.Picklist } }; if (!string.IsNullOrWhiteSpace(attributeTemplate.OtherDisplayName)) { var otherDisplayLabel = new LocalizedLabel(attributeTemplate.OtherDisplayName, DefaultConfiguration.OtherLanguageCode); createOptionSetRequest.OptionSet.DisplayName.LocalizedLabels.Add(otherDisplayLabel); } if (!string.IsNullOrWhiteSpace(attributeTemplate.OtherDescription)) { var otherDescriptionLabel = new LocalizedLabel(attributeTemplate.OtherDescription, DefaultConfiguration.OtherLanguageCode); createOptionSetRequest.OptionSet.Description.LocalizedLabels.Add(otherDescriptionLabel); } ExecuteOperation(GetSharedOrganizationService(), createOptionSetRequest, string.Format("An error occured while creating the attribute: {0}", attributeTemplate.LogicalName)); createdGlobalOptionSetList.Add(attributeTemplate.GlobalOptionSetListLogicalName); }
private CreateAttributeRequest GetCreateAttributeRequest(string entityLogicalName, AttributeTemplate attributeTemplate) { if (attributeTemplate.AttributeType == typeof(Primary)) { return null; } var createAttributeRequest = new CreateAttributeRequest {EntityName = entityLogicalName}; if (attributeTemplate.AttributeType == typeof (string)) { createAttributeRequest.Attribute = CreateStringAttributeMetadata(attributeTemplate); } else if (attributeTemplate.AttributeType == typeof (int)) { createAttributeRequest.Attribute = CreateIntAttributeMetadata(attributeTemplate); } else if (attributeTemplate.AttributeType == typeof (decimal)) { createAttributeRequest.Attribute = CreateDecimalAttributeMetadata(attributeTemplate); } else if (attributeTemplate.AttributeType == typeof (OptionSet)) { createAttributeRequest.Attribute = CreateOptionSetAttributeMetadata(attributeTemplate); } else if (attributeTemplate.AttributeType == typeof (GlobalOptionSet)) { createAttributeRequest.Attribute = CreateGlobalOptionSetAttributeMetadata(attributeTemplate); } else if (attributeTemplate.AttributeType == typeof (bool)) { createAttributeRequest.Attribute = CreateBoolAttributeMetadata(attributeTemplate); } else if (attributeTemplate.AttributeType == typeof (Money)) { createAttributeRequest.Attribute = CreateMoneyAttributeMetadata(attributeTemplate); } else if (attributeTemplate.AttributeType == typeof (DateTime)) { createAttributeRequest.Attribute = CreateDateTimeAttributeMetadata(attributeTemplate); } else if (attributeTemplate.AttributeType == typeof (Multiline)) { createAttributeRequest.Attribute = CreateMultilineAttributeMetadata(attributeTemplate); } else if (attributeTemplate.AttributeType == typeof(float)) { createAttributeRequest.Attribute = CreateFloatAttributeMetadata(attributeTemplate); } else { var exception = new Exception(string.Format("Given attribute type is not supported. Type: {0}", attributeTemplate.AttributeType)); errorList.Add(exception); return null; } createAttributeRequest.Attribute.SchemaName = attributeTemplate.LogicalName; createAttributeRequest.Attribute.RequiredLevel = new AttributeRequiredLevelManagedProperty(attributeTemplate.IsRequired ? AttributeRequiredLevel.SystemRequired : AttributeRequiredLevel.None); createAttributeRequest.Attribute.DisplayName = GetLabelWithLocalized(attributeTemplate.DisplayNameShort); createAttributeRequest.Attribute.Description = GetLabelWithLocalized(attributeTemplate.Description); if(!string.IsNullOrWhiteSpace(attributeTemplate.OtherDisplayName)) { var otherDisplayLabel = new LocalizedLabel(attributeTemplate.OtherDisplayName, DefaultConfiguration.OtherLanguageCode); createAttributeRequest.Attribute.DisplayName.LocalizedLabels.Add(otherDisplayLabel); } if (!string.IsNullOrWhiteSpace(attributeTemplate.OtherDescription)) { var otherDescriptionLabel = new LocalizedLabel(attributeTemplate.OtherDescription, DefaultConfiguration.OtherLanguageCode); createAttributeRequest.Attribute.Description.LocalizedLabels.Add(otherDescriptionLabel); } return createAttributeRequest; }
/// <summary> /// Add filter field to the filter table. /// </summary> /// <param name="filter">Filter definition</param> /// <param name="columnSourceName">Column source field name</param> /// <param name="fieldDisplayName">Field display name</param> /// <param name="filterTable">Filter table</param> /// <param name="filterOption">Filter option</param> /// <param name="filterValue">Filter value</param> private void AddFilterField(ColumnFilter filter, string columnSourceName, string fieldDisplayName, Table filterTable, object filterOption, object filterValue) { string fieldType = filter.Type; string fieldPath = filter.Path; string filterFormat = filter.Format; string fieldSourceName = filter.Source ?? columnSourceName; int filterSize = filter.Size; Unit filterWidth = filter.Width; TableRow tRow = new TableRow(); TableCell tCellName = new TableCell(); TableCell tCellOption = new TableCell(); TableCell tCellValue = new TableCell(); // Ensure fieldSourceName is JavaScript valid fieldSourceName = fieldSourceName.Replace(ALL, "__ALL__"); // Label Label textName = new Label { Text = String.IsNullOrEmpty(fieldDisplayName) ? "" : fieldDisplayName + ":", ID = fieldSourceName + "Name", EnableViewState = false }; tCellName.Controls.Add(textName); tRow.Cells.Add(tCellName); // Filter option string option = null; if (filterOption != null) { option = ValidationHelper.GetString(filterOption, null); } // Filter value string value = null; if (filterValue != null) { value = ValidationHelper.GetString(filterValue, null); } // Filter definition UniGridFilterField filterDefinition = new UniGridFilterField(); filterDefinition.Type = (fieldType != null) ? fieldType.ToLowerCSafe() : "custom"; filterDefinition.Label = textName; filterDefinition.Format = filterFormat; filterDefinition.FilterRow = tRow; string customPath = null; // Set the filter default value string defaultValue = filter.DefaultValue; // Remember default values of filter field controls for potential UniGrid reset string optionFilterFieldValue = null; string valueFilterFieldValue = null; switch (filterDefinition.Type) { // Text filter case "text": { DropDownList textOptionFilterField = new DropDownList(); textOptionFilterField.Items.Add(new ListItem("LIKE", "LIKE")); textOptionFilterField.Items.Add(new ListItem("NOT LIKE", "NOT LIKE")); textOptionFilterField.Items.Add(new ListItem("=", "=")); textOptionFilterField.Items.Add(new ListItem("<>", "<>")); textOptionFilterField.CssClass = "ContentDropdown"; textOptionFilterField.ID = fieldSourceName; // Set the value SetDropdownValue(value, null, textOptionFilterField); optionFilterFieldValue = textOptionFilterField.SelectedValue; LocalizedLabel lblSelect = new LocalizedLabel { EnableViewState = false, Display = false, AssociatedControlID = textOptionFilterField.ID, ResourceString = "general.select" }; tCellOption.Controls.Add(lblSelect); tCellOption.Controls.Add(textOptionFilterField); tRow.Cells.Add(tCellOption); // Add text field TextBox textValueFilterField = new TextBox { ID = fieldSourceName + "TextValue", CssClass = "FilterTextBox", }; // Set value SetTextboxValue(value, defaultValue, textValueFilterField); valueFilterFieldValue = textValueFilterField.Text; if (filterSize > 0) { textValueFilterField.MaxLength = filterSize; } if (!filterWidth.IsEmpty) { textValueFilterField.Width = filterWidth; } tCellValue.Controls.Add(textValueFilterField); tRow.Cells.Add(tCellValue); textName.AssociatedControlID = textValueFilterField.ID; filterDefinition.OptionsControl = textOptionFilterField; filterDefinition.ValueControl = textValueFilterField; } break; // Boolean filter case "bool": { DropDownList booleanOptionFilterField = new DropDownList(); booleanOptionFilterField.Items.Add(new ListItem(GetString("general.selectall"), "")); booleanOptionFilterField.Items.Add(new ListItem(GetString("general.yes"), "1")); booleanOptionFilterField.Items.Add(new ListItem(GetString("general.no"), "0")); booleanOptionFilterField.CssClass = "ContentDropdown"; booleanOptionFilterField.ID = fieldSourceName; textName.AssociatedControlID = booleanOptionFilterField.ID; // Set the value SetDropdownValue(value, defaultValue, booleanOptionFilterField); valueFilterFieldValue = booleanOptionFilterField.SelectedValue; tCellValue.Controls.Add(booleanOptionFilterField); tRow.Cells.Add(tCellValue); filterDefinition.ValueControl = booleanOptionFilterField; } break; // Integer filter case "integer": case "double": { DropDownList numberOptionFilterField = new DropDownList(); numberOptionFilterField.Items.Add(new ListItem("=", "=")); numberOptionFilterField.Items.Add(new ListItem("<>", "<>")); numberOptionFilterField.Items.Add(new ListItem("<", "<")); numberOptionFilterField.Items.Add(new ListItem(">", ">")); numberOptionFilterField.CssClass = "ContentDropdown"; numberOptionFilterField.ID = fieldSourceName; // Set the value SetDropdownValue(value, null, numberOptionFilterField); optionFilterFieldValue = numberOptionFilterField.SelectedValue; LocalizedLabel lblSelect = new LocalizedLabel { EnableViewState = false, Display = false, AssociatedControlID = numberOptionFilterField.ID, ResourceString = "general.select" }; // Add filter field tCellOption.Controls.Add(lblSelect); tCellOption.Controls.Add(numberOptionFilterField); tRow.Cells.Add(tCellOption); TextBox numberValueFilterField = new TextBox { ID = fieldSourceName + "NumberValue", }; // Set value SetTextboxValue(value, defaultValue, numberValueFilterField); valueFilterFieldValue = numberValueFilterField.Text; if (filterSize > 0) { numberValueFilterField.MaxLength = filterSize; } if (!filterWidth.IsEmpty) { numberValueFilterField.Width = filterWidth; } numberValueFilterField.EnableViewState = false; tCellValue.Controls.Add(numberValueFilterField); tRow.Cells.Add(tCellValue); filterDefinition.OptionsControl = numberOptionFilterField; filterDefinition.ValueControl = numberValueFilterField; } break; case "site": { // Site selector customPath = "~/CMSFormControls/Filters/SiteFilter.ascx"; } break; case "custom": // Load custom path { if (String.IsNullOrEmpty(fieldPath)) { throw new Exception("[UniGrid.AddFilterField]: Filter field path is not set"); } customPath = fieldPath; } break; default: // Not supported filter type throw new Exception("[UniGrid.AddFilterField]: Filter type '" + filterDefinition.Type + "' is not supported. Supported filter types: integer, double, bool, text, site, custom."); } // Else if filter path is defined use custom filter if (customPath != null) { customPath = (customPath.StartsWithCSafe("~/") ? customPath : FilterDirectoryPath + customPath.TrimStart('/')); // Add to the controls collection CMSAbstractBaseFilterControl filterControl = LoadFilterControl(fieldPath, fieldSourceName, value, filterDefinition, customPath); if (filterControl != null) { // Set default value if (!String.IsNullOrEmpty(defaultValue)) { filterControl.SelectedValue = defaultValue; } tCellValue.Controls.Add(filterControl); } tCellValue.Attributes["colspan"] = "2"; tRow.Cells.Add(tCellValue); } RaiseOnFilterFieldCreated(fieldSourceName, filterDefinition); FilterFields[fieldSourceName] = filterDefinition; filterTable.Rows.Add(tRow); // Store initial filter state for potential UniGrid reset if (filterDefinition.OptionsControl != null) { InitialFilterStateControls.Add(new KeyValuePair<Control, object>(filterDefinition.OptionsControl, optionFilterFieldValue)); } if (filterDefinition.ValueControl != null) { if (!(filterDefinition.ValueControl is CMSAbstractBaseFilterControl)) { InitialFilterStateControls.Add(new KeyValuePair<Control, object>(filterDefinition.ValueControl, valueFilterFieldValue)); } } }
/// <summary> /// Adds textbox/dropdown list determining sort column, dropdown list determining sort direction and 'then by' label /// </summary> /// <param name="i">Index of a control</param> /// <param name="sortColumn">Sort column</param> /// <param name="sortDirection">Sort direction</param> /// <param name="addThenBy">Whether to add 'then by' label</param> private void AddRow(int i, string sortColumn, string sortDirection, bool addThenBy) { hdnIndices.Value += i + ";"; Panel pnlOrderBy = new Panel { ID = PNLORDERBY_ID_PREFIX + i }; LocalizedLabel lblThenBy = null; if (addThenBy) { // Add 'Then by' label lblThenBy = new LocalizedLabel { ResourceString = "orderbycontrol.thenby", CssClass = "ThenBy", EnableViewState = false, ID = LBLTHENBY_ID_PREFIX + i }; } // Add dropdown list for setting direction CMSDropDownList drpDirection = new CMSDropDownList { ID = DRPDIRECTION_ID_PREFIX + i, CssClass = "ShortDropDownList", AutoPostBack = true, Enabled = Enabled }; drpDirection.Items.Add(new ListItem(GetString("general.ascending"), ASC)); drpDirection.Items.Add(new ListItem(GetString("general.descending"), DESC)); if (!String.IsNullOrEmpty(sortDirection)) { drpDirection.SelectedValue = sortDirection; } Control orderByControl = null; switch (Mode) { // Add textbox for column name case SelectorMode.TextBox: CMSTextBox txtColumn = new CMSTextBox { ID = TXTCOLUMN_ID_PREFIX + i, AutoPostBack = true, Enabled = Enabled }; txtColumn.TextChanged += txtBox_TextChanged; if (!String.IsNullOrEmpty(sortColumn)) { // Set sorting column txtColumn.Text = sortColumn; } orderByControl = txtColumn; break; // Add dropdown list for column selection case SelectorMode.DropDownList: CMSDropDownList drpColumn = new CMSDropDownList { ID = DRPCOLUMN_ID_PREFIX + i, CssClass = "ColumnDropDown", AutoPostBack = true, Enabled = Enabled }; drpColumn.SelectedIndexChanged += drpOrderBy_SelectedIndexChanged; drpColumn.Items.Add(new ListItem(GetString("orderbycontrol.selectcolumn"), SELECT_COLUMN)); drpColumn.Items.AddRange(CloneItems(Columns.ToArray())); if (!String.IsNullOrEmpty(sortColumn)) { // Set sorting column drpColumn.SelectedValue = sortColumn; } orderByControl = drpColumn; break; } // Add controls to panel if (lblThenBy != null) { pnlOrderBy.Controls.Add(WrapControl(lblThenBy)); } if (orderByControl != null) { pnlOrderBy.Controls.Add(WrapControl(orderByControl)); } pnlOrderBy.Controls.Add(WrapControl(drpDirection)); // Add panel to place holder plcOrderBy.Controls.Add(pnlOrderBy); if (Enabled) { // Setup enable/disable script for direction dropdown list if (orderByControl is TextBox) { ((TextBox)orderByControl).Attributes.Add("onkeyup", SET_DIRECTION_TXT + "('" + orderByControl.ClientID + "')"); ScriptHelper.RegisterStartupScript(this, typeof (string), "setEnabledTxt" + orderByControl.ClientID, ScriptHelper.GetScript("$cmsj(document).ready(function() {" + SET_DIRECTION_TXT + "('" + orderByControl.ClientID + "');})")); } else { ScriptHelper.RegisterStartupScript(this, typeof (string), "setEnabledDrp" + orderByControl.ClientID, ScriptHelper.GetScript("$cmsj(document).ready(function() {" + SET_DIRECTION_DRP + "('" + orderByControl.ClientID + "');})")); } } // Add row to collection orderByRows.Add(new OrderByRow(i, lblThenBy, orderByControl, drpDirection, pnlOrderBy)); }
/// <summary> /// Loads custom fields collisions. /// </summary> private void LoadCustomFields() { // Check if contact has any custom fields FormInfo formInfo = FormHelper.GetFormInfo(parentContact.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); 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><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 = SortGroupContactsByColumn(ffi.Name + " ASC", ffi.Name + " NOT LIKE ''", ffi.Name); } else { dt = SortGroupContactsByColumn(ffi.Name + " ASC", ffi.Name + " IS NOT NULL", ffi.Name); } // Load value into textbox txt.Text = ValidationHelper.GetString(parentContact.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"; DisplayTooltip(img, dt, ffi.Name, ValidationHelper.GetString(parentContact.GetValue(ffi.Name), ""), ffi.DataType); plcCustomFields.Controls.Add(img); content = new Literal(); content.Text = "</td></tr>"; plcCustomFields.Controls.Add(content); mergedContacts.Tables[0].DefaultView.RowFilter = null; } } content = new Literal(); content.Text = "</table>"; plcCustomFields.Controls.Add(content); } else { tabCustomFields.Visible = false; tabCustomFields.HeaderText = null; } }
private void ReloadData() { if (node != null) { // Check read permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied) { RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), node.NodeAliasPath)); } else { // Log activities checkboxes if (!RequestHelper.IsPostBack()) { bool? logVisit = node.DocumentLogVisitActivity; chkLogPageVisit.Checked = (logVisit == true); chkPageVisitInherit.Checked = (logVisit == null); chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked; if (logVisit == null) { chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty); } } // Show document group owner selector if (ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Groups)) { plcOwnerGroup.Controls.Clear(); // Initialize table TableRow rowOwner = new TableRow(); TableCell cellTitle = new TableCell(); TableCell cellSelector = new TableCell(); // Initialize caption LocalizedLabel lblOwnerGroup = new LocalizedLabel(); lblOwnerGroup.EnableViewState = false; lblOwnerGroup.ResourceString = "community.group.documentowner"; lblOwnerGroup.ID = "lblOwnerGroup"; cellTitle.Controls.Add(lblOwnerGroup); // Initialize selector fcDocumentGroupSelector = (FormEngineUserControl)Page.LoadControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx"); fcDocumentGroupSelector.ID = "fcDocumentGroupSelector"; fcDocumentGroupSelector.StopProcessing = this.pnlUIOwner.IsHidden; cellSelector.Controls.Add(fcDocumentGroupSelector); fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(node.GetValue("NodeGroupID"), 0); fcDocumentGroupSelector.SetValue("siteid", CMSContext.CurrentSiteID); fcDocumentGroupSelector.SetValue("nodeid", nodeId); // Add controls to containers rowOwner.Cells.Add(cellTitle); rowOwner.Cells.Add(cellSelector); plcOwnerGroup.Controls.Add(rowOwner); plcOwnerGroup.Visible = true; } // Check modify permissions if (CMSContext.CurrentUser.IsAuthorizedPerDocument(node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied) { // disable form editing DisableFormEditing(); // show access denied message lblInfo.Text = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), node.NodeAliasPath); lblInfo.Visible = true; } // Show owner editing only when authorized to change the permissions if (canEditOwner) { lblOwner.Visible = false; usrOwner.Visible = true; usrOwner.SetValue("AdditionalUsers", new int[] { node.NodeOwner }); } else { usrOwner.Visible = false; } if (!RequestHelper.IsPostBack()) { if (canEditOwner) { usrOwner.Value = node.GetValue("NodeOwner"); } // Search chkExcludeFromSearch.Checked = node.DocumentSearchExcluded; } // Load the data lblName.Text = HttpUtility.HtmlEncode(node.DocumentName); lblNamePath.Text = HttpUtility.HtmlEncode(Convert.ToString(node.GetValue("DocumentNamePath"))); lblAliasPath.Text = Convert.ToString(node.NodeAliasPath); string typeName = DataClassInfoProvider.GetDataClass(node.NodeClassName).ClassDisplayName; lblType.Text = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName)); lblNodeID.Text = Convert.ToString(node.NodeID); // Modifier SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId"); // Get modified time TimeZoneInfo usedTimeZone = null; DateTime lastModified = ValidationHelper.GetDateTime(node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME); lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help"); if (!canEditOwner) { // Owner SetUserLabel(lblOwner, "NodeOwner"); } // Creator SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId"); DateTime createdWhen = ValidationHelper.GetDateTime(node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME); lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help"); // URL string liveUrl = node.IsLink ? CMSContext.GetUrl(node.NodeAliasPath, null) : CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath); lnkLiveURL.Text = ResolveUrl(liveUrl); lnkLiveURL.NavigateUrl = liveUrl; bool isRoot = (node.NodeClassName.ToLower() == "cms.root"); // Preview URL if (!isRoot) { plcPreview.Visible = true; string path = canEdit ? "/CMSModules/CMS_Content/Properties/resetlink.png" : "/CMSModules/CMS_Content/Properties/resetlinkdisabled.png"; btnResetPreviewGuid.ImageUrl = GetImageUrl(path); btnResetPreviewGuid.ToolTip = GetString("GeneralProperties.InvalidatePreviewURL"); btnResetPreviewGuid.ImageAlign = ImageAlign.AbsBottom; btnResetPreviewGuid.Click += new ImageClickEventHandler(btnResetPreviewGuid_Click); btnResetPreviewGuid.OnClientClick = "if(!confirm('" + GetString("GeneralProperties.GeneratePreviewURLConf") + "')){return false;}"; InitPreviewUrl(); } lblGUID.Text = Convert.ToString(node.NodeGUID); lblDocGUID.Text = (node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : node.DocumentGUID.ToString(); lblDocID.Text = Convert.ToString(node.DocumentID); // Culture CultureInfo ci = CultureInfoProvider.GetCultureInfo(node.DocumentCulture); lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : node.DocumentCulture); lblPublished.Text = (node.IsPublished ? "<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>" : "<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>"); if (!RequestHelper.IsPostBack()) { // Init radio buttons for cache settings if (isRoot) { radInherit.Visible = false; chkCssStyle.Visible = false; switch (node.NodeCacheMinutes) { case -1: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; txtCacheMinutes.Text = ""; break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; txtCacheMinutes.Text = ""; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; txtCacheMinutes.Text = node.NodeCacheMinutes.ToString(); break; } } else { switch (node.NodeCacheMinutes) { case -1: // Cache setting is inherited radNo.Checked = false; radYes.Checked = false; radInherit.Checked = true; txtCacheMinutes.Text = ""; break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; txtCacheMinutes.Text = ""; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; txtCacheMinutes.Text = node.NodeCacheMinutes.ToString(); break; } } if (!radYes.Checked) { txtCacheMinutes.Enabled = false; } } if (!RequestHelper.IsPostBack()) { if (node.GetValue("DocumentStylesheetID") == null) { // If default site not exist edit is set to -1 - disabled if (CMSContext.CurrentSiteStylesheet != null) { ctrlSiteSelectStyleSheet.Value = "default"; } else { ctrlSiteSelectStyleSheet.Value = -1; } } else { // If stylesheet is inherited from parent document if (ValidationHelper.GetInteger(node.GetValue("DocumentStylesheetID"), 0) == -1) { if (!isRoot) { chkCssStyle.Checked = true; // Get parent stylesheet string value = PageInfoProvider.GetParentProperty(CMSContext.CurrentSite.SiteID, node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelperClass.GetSafeQueryString(node.DocumentCulture, false) + "'", "DocumentStylesheetID"); if (String.IsNullOrEmpty(value)) { // If default site stylesheet not exist edit is set to -1 - disabled if (CMSContext.CurrentSiteStylesheet != null) { ctrlSiteSelectStyleSheet.Value = "default"; } else { ctrlSiteSelectStyleSheet.Value = -1; } } else { // Set parent stylesheet to current document ctrlSiteSelectStyleSheet.Value = value; } } } else { ctrlSiteSelectStyleSheet.Value = node.GetValue("DocumentStylesheetID"); } } } // Disable new button if document inherit stylesheet if (!isRoot && chkCssStyle.Checked) { ctrlSiteSelectStyleSheet.Enabled = false; ctrlSiteSelectStyleSheet.ButtonNew.Enabled = false; } // Initialize Rating control RefreshCntRatingResult(); double rating = 0.0f; if (node.DocumentRatings > 0) { rating = node.DocumentRatingValue / node.DocumentRatings; } ratingControl.MaxRating = 10; ratingControl.CurrentRating = rating; ratingControl.Visible = true; ratingControl.Enabled = false; // Initialize Reset button for rating btnResetRating.Text = GetString("general.reset"); btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;"; object[] param = new object[1]; param[0] = node.DocumentID; // Check ad-hoc forum counts hasAdHocForum = (ModuleCommands.ForumsGetDocumentForumsCount(node.DocumentID) > 0); // Ad-Hoc message boards check hasAdHocBoard = (ModuleCommands.MessageBoardGetDocumentBoardsCount(node.DocumentID) > 0); plcAdHocForums.Visible = hasAdHocForum; plcAdHocBoards.Visible = hasAdHocBoard; } } else { btnResetRating.Visible = false; } }
/// <summary> /// Default constructor for 'order by' row. /// </summary> /// <param name="index">Index of a row</param> /// <param name="thenByLabel">Label 'then by'</param> /// <param name="orderByControl">Control for specifying column</param> /// <param name="directionDropDown">Control for specifying sort direction</param> /// <param name="panel">Wrapping panel</param> public OrderByRow(int index, LocalizedLabel thenByLabel, Control orderByControl, CMSDropDownList directionDropDown, Panel panel) { Index = index; ThenByLabel = thenByLabel; ColumnControl = orderByControl; DirectionDropDown = directionDropDown; Panel = panel; }
/// <summary> /// Generate apropriate icons if source folder is changed. /// </summary> /// <param name="folderName">Name of selected folder</param> /// <param name="defaultValue">Determine default value which should be checked</param> private void HandleChangeFolderAction(string folderName, string defaultValue) { try { DirectoryInfo di = DirectoryInfo.New(DirectoryHelper.CombinePath(FullIconFolderPath, folderName)); string directoryName = di.Name; ArrayList iconList = GetIconsInFolder(di); string defaultIcon = (iconList.Contains(defaultValue)) ? defaultValue : String.Empty; foreach (string fileInfo in iconList) { string path = GetImagePath(IconsFolder + "/" + directoryName + "/" + fileInfo); // Size caption LocalizedLabel lblIcon = new LocalizedLabel { ResourceString = "iconcaption." + fileInfo.Remove(fileInfo.LastIndexOfCSafe('.')), EnableViewState = false }; // Icon image CMSImage imgIcon = new CMSImage { ImageUrl = UIHelper.ResolveImageUrl(path), AlternateText = fileInfo, EnableViewState = false }; // Icon panel CMSPanel pnlIcon = new CMSPanel { CssClass = "iconItem", EnableViewState = false }; pnlIcon.Attributes.Add("onclick", string.Format("SelectItem_{0}(this);SetAction_{0}('select','{1}');RaiseHiddenPostBack_{0}();", ClientID, fileInfo)); pnlIcon.Controls.Add(imgIcon); pnlIcon.Controls.Add(lblIcon); // Check for selected value if ((defaultIcon == String.Empty) || (fileInfo.ToLowerCSafe() == defaultValue.ToLowerCSafe())) { defaultIcon = fileInfo; pnlIcon.AddCssClass("selected"); } // Add controls pnlChild.Controls.Add(pnlIcon); } CurrentIcon = defaultIcon; } catch (Exception ex) { lblError.Text += "[IconSelector.HandleChangeFolderAction]: Error getting icons in selected icon folder. Original exception: " + ex.Message; } CurrentIconFolder = folderName; pnlUpdateIcons.Update(); }
private void ReloadData() { if (Node != null) { // Log activities checkboxes if (!RequestHelper.IsPostBack()) { bool? logVisit = Node.DocumentLogVisitActivity; chkLogPageVisit.Checked = (logVisit == true); if (Node.NodeParentID > 0) // Init "inherit" option for child nodes (and hide option for root) { chkPageVisitInherit.Checked = (logVisit == null); if (logVisit == null) { chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty); } } chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked; } // Check modify permission canEdit = (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Denied); // Show document group owner selector if (ModuleEntryManager.IsModuleLoaded(ModuleName.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.Groups)) { plcOwnerGroup.Controls.Clear(); // Initialize panel content Panel rowWrapperPanel = new Panel(); rowWrapperPanel.CssClass = "form-group"; Panel lblPanel = new Panel(); lblPanel.CssClass = "editing-form-label-cell"; Panel ctrlPanel = new Panel(); ctrlPanel.CssClass = "editing-form-value-cell"; // Initialize caption LocalizedLabel lblOwnerGroup = new LocalizedLabel(); lblOwnerGroup.EnableViewState = false; lblOwnerGroup.ResourceString = "community.group.documentowner"; lblOwnerGroup.ID = "lblOwnerGroup"; lblOwnerGroup.CssClass = "control-label"; lblPanel.Controls.Add(lblOwnerGroup); // Initialize selector fcDocumentGroupSelector = (FormEngineUserControl)Page.LoadUserControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx"); fcDocumentGroupSelector.ID = "fcDocumentGroupSelector"; fcDocumentGroupSelector.StopProcessing = pnlUIOwner.IsHidden; ctrlPanel.Controls.Add(fcDocumentGroupSelector); fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(Node.GetValue("NodeGroupID"), 0); fcDocumentGroupSelector.SetValue("siteid", SiteContext.CurrentSiteID); fcDocumentGroupSelector.SetValue("nodeid", Node.NodeID); // Add controls to containers rowWrapperPanel.Controls.Add(lblPanel); rowWrapperPanel.Controls.Add(ctrlPanel); plcOwnerGroup.Controls.Add(rowWrapperPanel); plcOwnerGroup.Visible = true; } // Show owner editing only when authorized to change the permissions if (canEditOwner) { lblOwner.Visible = false; usrOwner.Visible = true; usrOwner.SetValue("AdditionalUsers", new[] { Node.NodeOwner }); } else { usrOwner.Visible = false; } if (!RequestHelper.IsPostBack()) { if (canEditOwner) { usrOwner.Value = Node.GetValue("NodeOwner"); } } // Load the data lblName.Text = HttpUtility.HtmlEncode(Node.GetDocumentName()); lblNamePath.Text = HttpUtility.HtmlEncode(Convert.ToString(Node.GetValue("DocumentNamePath"))); lblAliasPath.Text = Convert.ToString(Node.NodeAliasPath); string typeName = DataClassInfoProvider.GetDataClassInfo(Node.NodeClassName).ClassDisplayName; lblType.Text = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName)); lblNodeID.Text = Convert.ToString(Node.NodeID); // Modifier SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId"); // Get modified time TimeZoneInfo usedTimeZone; DateTime lastModified = ValidationHelper.GetDateTime(Node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME); lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help"); if (!canEditOwner) { // Owner SetUserLabel(lblOwner, "NodeOwner"); } // Creator SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId"); DateTime createdWhen = ValidationHelper.GetDateTime(Node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME); lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, MembershipContext.AuthenticatedUser, SiteContext.CurrentSite, out usedTimeZone); ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetUTCLongStringOffset(usedTimeZone), "help"); // URL string liveUrl = Node.IsLink ? DocumentURLProvider.GetUrl(Node.NodeAliasPath) : DocumentURLProvider.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath); lnkLiveURL.Text = URLHelper.ResolveUrl(liveUrl); lnkLiveURL.NavigateUrl = URLHelper.ResolveUrl(liveUrl); string permanentUrl = DocumentURLProvider.GetPermanentDocUrl(Node.NodeGUID, Node.NodeAlias, Node.NodeSiteName, PageInfoProvider.PREFIX_CMS_GETDOC, ".aspx"); lnkPermanentUrl.Text = URLHelper.ResolveUrl(permanentUrl); lnkPermanentUrl.NavigateUrl = URLHelper.ResolveUrl(permanentUrl); bool isRoot = (Node.NodeClassName.ToLowerCSafe() == "cms.root"); // Preview URL if (!isRoot) { plcPreview.Visible = true; btnResetPreviewGuid.ToolTip = GetString("GeneralProperties.InvalidatePreviewURL"); btnResetPreviewGuid.Click += btnResetPreviewGuid_Click; btnResetPreviewGuid.OnClientClick = "if(!confirm(" + ScriptHelper.GetLocalizedString("GeneralProperties.GeneratePreviewURLConf") + ")){return false;}"; InitPreviewUrl(); } lblGUID.Text = Convert.ToString(Node.NodeGUID); lblDocGUID.Text = (Node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : Node.DocumentGUID.ToString(); lblDocID.Text = Convert.ToString(Node.DocumentID); // Culture CultureInfo ci = CultureInfoProvider.GetCultureInfo(Node.DocumentCulture); lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : Node.DocumentCulture); lblPublished.Text = (Node.IsPublished ? "<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>" : "<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>"); // Load page info for inherited cache settings currentPage = PageInfoProvider.GetPageInfo(Node.DocumentGUID); if (!RequestHelper.IsPostBack()) { // Init radio buttons for cache settings if (isRoot) { radInherit.Visible = false; radFSInherit.Visible = false; chkCssStyle.Visible = false; } else { // Show what is inherited value radInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeCacheMinutes") + ")"; radFSInherit.Text = GetString("GeneralProperties.radInherit") + " (" + GetInheritedCacheCaption("NodeAllowCacheInFileSystem") + ")"; } string cacheMinutes = ""; switch (Node.NodeCacheMinutes) { case -1: // Cache setting is inherited { radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; if (!isRoot) { radInherit.Checked = true; radNo.Checked = false; if ((currentPage != null) && (currentPage.NodeCacheMinutes > 0)) { cacheMinutes = currentPage.NodeCacheMinutes.ToString(); } } } break; case 0: // Cache is off radNo.Checked = true; radYes.Checked = false; radInherit.Checked = false; break; default: // Cache is enabled radNo.Checked = false; radYes.Checked = true; radInherit.Checked = false; cacheMinutes = Node.NodeCacheMinutes.ToString(); break; } // Set secured radio buttons switch (Node.NodeAllowCacheInFileSystem) { case 0: radFSNo.Checked = true; break; case 1: radFSYes.Checked = true; break; default: if (!isRoot) { radFSInherit.Checked = true; } else { radFSYes.Checked = true; } break; } txtCacheMinutes.Text = cacheMinutes; if (!radYes.Checked) { txtCacheMinutes.Enabled = false; } if (Node.GetValue("DocumentStylesheetID") == null) { ctrlSiteSelectStyleSheet.Value = GetDefaultStylesheet(); } else { // If stylesheet is inherited from parent document if (ValidationHelper.GetInteger(Node.GetValue("DocumentStylesheetID"), 0) == -1) { if (!isRoot) { chkCssStyle.Checked = true; // Get parent stylesheet string value = GetParentProperty(); ctrlSiteSelectStyleSheet.Value = String.IsNullOrEmpty(value) ? GetDefaultStylesheet() : value; } } else { ctrlSiteSelectStyleSheet.Value = Node.GetValue("DocumentStylesheetID"); } } } // Disable new button if document inherit stylesheet bool disableCssSelector = (!isRoot && chkCssStyle.Checked); ctrlSiteSelectStyleSheet.Enabled = !disableCssSelector; ctrlSiteSelectStyleSheet.ButtonNewEnabled = !disableCssSelector; // Initialize Rating control RefreshCntRatingResult(); double rating = 0.0f; if (Node.DocumentRatings > 0) { rating = Node.DocumentRatingValue / Node.DocumentRatings; } ratingControl.MaxRating = 10; ratingControl.CurrentRating = rating; ratingControl.Visible = true; ratingControl.Enabled = false; // Initialize Reset button for rating btnResetRating.Text = GetString("general.reset"); btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;"; object[] param = new object[1]; param[0] = Node.DocumentID; plcAdHocForums.Visible = hasAdHocForum; plcAdHocBoards.Visible = hasAdHocBoard; if (!canEdit) { // Disable form editing DisableFormEditing(); } } else { btnResetRating.Visible = false; } }
/// <summary> /// Gets <c>Label</c> instance for the input <c>SettingsKeyInfo</c> object. /// </summary> /// <param name="settingsKey"><c>SettingsKeyInfo</c> instance</param> /// <param name="inputControl">Input control associated to the label</param> /// <param name="groupNo">Number representing index of the processing settings group</param> /// <param name="keyNo">Number representing index of the processing SettingsKeyInfo</param> private Label GetLabel(SettingsKeyInfo settingsKey, Control inputControl, int groupNo, int keyNo) { LocalizedLabel label = new LocalizedLabel { EnableViewState = false, ID = string.Format(@"lblDispName{0}{1}", groupNo, keyNo), CssClass = "control-label editing-form-label", Text = settingsKey.KeyDisplayName, DisplayColon = true }; if (inputControl != null) { label.AssociatedControlID = inputControl.ID; } ScriptHelper.AppendTooltip(label, ResHelper.LocalizeString(settingsKey.KeyDescription), null); return label; }
/// <summary> /// Returns true if the returned value is valid. /// </summary> public override bool IsValid() { int i = 0; // Check errors in textbox foreach (OrderByRow row in orderByRows) { int index = row.Index; Panel panel = row.Panel; string text = row.Column; bool isLastRow = (orderByRows.IndexOf(row) == orderByRows.Count - 1); // Check whether entered value is an identifier if (!ValidationHelper.IsIdentifier(text) && !isLastRow) { LocalizedLabel lblError = new LocalizedLabel { ResourceString = "orderbycontrol.notidentifier", CssClass = "ErrorLabel", EnableViewState = false, ID = "lblError" + index }; panel.Controls.Add(lblError); i++; } } return (i == 0); }