protected void Page_Load(object sender, EventArgs e) { // Check permissions if (CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Localization", "LocalizeStrings")) { // Set title CurrentMaster.Title.TitleText = GetString("localizable.localizefield"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_UICulture/new.png"); CurrentMaster.Title.HelpTopicName = "localize_field"; CurrentMaster.Title.HelpName = "helpTopic"; // Validate hash Regex re = RegexHelper.GetRegex(@"[\w\d_$$]*"); identifier = QueryHelper.GetString("params", ""); if (!QueryHelper.ValidateHash("hash") || !re.IsMatch(identifier)) { pnlContent.Visible = false; return; } // Load dialog parameters Hashtable parameters = (Hashtable)WindowHelper.GetItem(identifier); if (parameters != null) { hdnValue = ValidationHelper.GetString(parameters["HiddenValue"], String.Empty); textbox = ValidationHelper.GetString(parameters["TextBoxID"], String.Empty); hdnIsMacro = ValidationHelper.GetString(parameters["HiddenIsMacro"], String.Empty); plainText = ValidationHelper.GetString(parameters["TextBoxValue"], String.Empty); btnLocalizeField = ValidationHelper.GetString(parameters["ButtonLocalizeField"], String.Empty); btnLocalizeString = ValidationHelper.GetString(parameters["ButtonLocalizeString"], String.Empty); btnRemoveLocalization = ValidationHelper.GetString(parameters["ButtonRemoveLocalization"], String.Empty); resourceKeyPrefix = ValidationHelper.GetString(parameters["ResourceKeyPrefix"], String.Empty); } btnOk.Click += btnOk_Click; lstExistingOrNew.Items[0].Text = GetString("localizable.createnew"); lstExistingOrNew.Items[1].Text = GetString("localizable.useexisting"); // Disable option to use existing resource string for user who is not admin if (!CurrentUser.UserSiteManagerAdmin) { lstExistingOrNew.Items[1].Enabled = false; } // If "create new" is selected if (lstExistingOrNew.SelectedIndex == 0) { if (!SettingsKeyProvider.DevelopmentMode) { lblPrefix.Text = resourceKeyPrefix; lblPrefix.Visible = true; } lblSelectKey.ResourceString = GetString("localizable.newkey"); resourceSelector.Visible = false; txtNewResource.Visible = true; if (!RequestHelper.IsPostBack()) { txtNewResource.Text = ResHelper.GetUniqueResStringKey(plainText, resourceKeyPrefix, SettingsKeyProvider.DevelopmentMode); } } // If "use existing" is selected else { lblSelectKey.ResourceString = GetString("localizable.existingkey"); resourceSelector.Visible = true; txtNewResource.Visible = false; } } // Dialog is not available for unauthorized user else { ShowError(GetString("security.accesspage.onlyglobaladmin")); pnlControls.Visible = false; } }