protected void Page_Load(object sender, EventArgs e) { if (QueryHelper.ValidateHash("hash")) { // Check site availability if (!ResourceSiteInfoProvider.IsResourceOnSite("CMS.MediaLibrary", SiteContext.CurrentSiteName)) { RedirectToResourceNotAvailableOnSite("CMS.MediaLibrary"); } // Initialize controls SetupControls(); } else { createFolder.Visible = false; string url = ResolveUrl(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext", true)); ScriptHelper.RegisterStartupScript(Page, typeof(string), "redirect", ScriptHelper.GetScript(String.Format("if (window.parent != null) {{ window.parent.location = '{0}' }}", url))); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Users", "Read")) { RedirectToAccessDenied("CMS.Users", "Read"); } // Try to get parameters... string identifier = QueryHelper.GetString("params", null); Hashtable parameters = (Hashtable)WindowHelper.GetItem(identifier); // ... and validate hash if ((QueryHelper.ValidateHash("hash", "selectedvalue")) && (parameters != null)) { selectionDialog.LocalizeItems = QueryHelper.GetBoolean("localize", true); // Load resource prefix string resourcePrefix = ValidationHelper.GetString(parameters["ResourcePrefix"], "general"); // Set the page title string titleText = GetString(resourcePrefix + ".selectitem|general.selectitem"); // Validity group text pnlDateTimeHeading.ResourceString = resourcePrefix + ".bindingproperties"; PageTitle.TitleText = titleText; Page.Title = titleText; // Remove additional dialog padding CurrentMaster.PanelContent.RemoveCssClass("dialog-content"); } else { // Redirect to error page URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext", true)); } ((ICMSModalMasterPage)CurrentMaster).ShowSaveAndCloseButton(); }
protected void Page_Load(object sender, EventArgs e) { if (!QueryHelper.ValidateHash("hash")) { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("imageeditor.badhashtitle", "imageeditor.badhashtext")); } else { ScriptHelper.RegisterJQueryCrop(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSAdminControls/ImageEditor/ImageEditorInnerPage.js"); CssRegistration.RegisterBootstrap(Page); SetBrowserClass(); string imgUrl = QueryHelper.GetString("imgurl", null); if (String.IsNullOrEmpty(imgUrl)) { string query = RequestContext.CurrentQueryString; query = URLHelper.RemoveParameterFromUrl(query, "hash"); var settings = new HashSettings(HashValidationSalts.GET_IMAGE_VERSION); query = URLHelper.AddParameterToUrl(query, "hash", ValidationHelper.GetHashString(query, settings)); imgContent.ImageUrl = UrlResolver.ResolveUrl("~/CMSPages/GetImageVersion.aspx" + query); int imgwidth = QueryHelper.GetInteger("imgwidth", 0); int imgheight = QueryHelper.GetInteger("imgheight", 0); if ((imgwidth > 0) && (imgheight > 0)) { imgContent.Width = imgwidth; imgContent.Height = imgheight; } } else { imgContent.ImageUrl = imgUrl; } } }
/// <summary> /// Page Load. /// </summary> protected void Page_Load(object sender, EventArgs e) { Guid userGuid = QueryHelper.GetGuid("userguid", Guid.Empty); // If StopProcessing flag is set or userguid is empty, do nothing if (StopProcessing || (userGuid == Guid.Empty)) { Visible = false; return; } // Validate hash if (!QueryHelper.ValidateHash("hash", "aliaspath", new HashSettings(""))) { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext")); } // Get registered user RegisteredUser = UserInfo.Provider.Get(userGuid); // Set default url DefaultUrl = ResolveUrl("~/"); bool controlPb = false; if (RequestHelper.IsPostBack()) { Control pbCtrl = ControlsHelper.GetPostBackControl(Page); if (pbCtrl == btnConfirm) { controlPb = true; } } SetupControls(!controlPb); if (!controlPb) { CheckUserStatus(); } }
private bool TryGetUrl(out string url) { url = PageBuilderHelper.GetPreviewLink(Node, MembershipContext.AuthenticatedUser.UserName); if (url == null) { url = URLHelper.ResolveUrl(AdministrationUrlHelper.GetInformationUrl("document.nopreviewavailable")); return(false); } if (DocumentManager.AllowSave) { url = PageBuilderHelper.AddEditModeParameter(url); } if (dataPropagated) { url = PageBuilderHelper.AddClearPageCacheParameter(url); } return(true); }
protected override void OnPreInit(EventArgs e) { isDialog = QueryHelper.GetBoolean("editonlycode", false); if (isDialog) { // Check hash var settings = new HashSettings("") { Redirect = false }; if (!QueryHelper.ValidateHash("hash", "saved;name;templateid;selectorid;tabmode;siteid;selectedsiteid", settings, true)) { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext")); } MasterPageFile = "~/CMSMasterPages/UI/Dialogs/ModalDialogPage.master"; } base.OnPreInit(e); }
protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); // Page has been opened from CMSDesk isDialog = QueryHelper.GetBoolean("editonlycode", false); if (isDialog) { // Check hash if (!QueryHelper.ValidateHash("hash", "objectid")) { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext")); } } else { CheckGlobalAdministrator(); // Don't require site in Page types application RequireSite = false; } }
/// <summary> /// Callback event handler. /// </summary> /// <param name="argument">Callback argument</param> public void RaiseCallbackEvent(string eventArgument) { if (String.IsNullOrEmpty(eventArgument)) { return; } var parts = eventArgument.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2) { mNodePreviewUrl = DocumentUIHelper.GetDocumentPageUrl(new UIPageURLSettings { NodeID = ValidationHelper.GetInteger(parts[0], 0), Culture = parts[1], Mode = ViewModeEnum.Preview.ToString(), AllowViewValidate = false, }); } mNodePreviewUrl = mNodePreviewUrl ?? URLHelper.ResolveUrl(AdministrationUrlHelper.GetInformationUrl("document.nopreviewavailable")); }
/// <summary> /// Render Folder icon preview HTML. /// </summary> /// <param name="defaultValue">Determine default value which should be checked</param> private void GetFolderIconPreview(string defaultValue) { foreach (string[] folderInfo in GetPredefinedIconFoldersSet()) { string dirName = folderInfo[0]; string iconName = folderInfo[1]; string path = GetImagePath(IconsFolder + "/" + dirName + "/" + iconName); // Icon image CMSImage imgFolder = new CMSImage { ImageUrl = AdministrationUrlHelper.ResolveImageUrl(path), AlternateText = iconName, EnableViewState = false }; // Icon panel CMSPanel pnlFolder = new CMSPanel { EnableViewState = false }; pnlFolder.AddCssClass("iconItem"); pnlFolder.Controls.Add(imgFolder); pnlFolder.Attributes.Add("onclick", string.Format("SelectItem_{0}(this);SetAction_{0}('changefolder','{1}');RaiseHiddenPostBack_{0}();", ClientID, dirName)); // Check for selected value if ((defaultValue == String.Empty) || (dirName.ToLowerCSafe() == defaultValue.ToLowerCSafe())) { defaultValue = dirName; pnlFolder.AddCssClass("selected"); } // Add controls pnlMain.Controls.Add(pnlFolder); } // Actualize value of current icon folder CurrentIconFolder = defaultValue; }
protected void Page_Load(object sender, EventArgs e) { if (DialogMode) { // Check hash if (!ValidationHelper.ValidateHash("?editonlycode=1", QueryHelper.GetString("hash", String.Empty), new HashSettings(""))) { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext")); } // Setup help PageTitle.HelpTopicName = HELP_TOPIC_LINK; } editElem.OnAfterSave += editElem_OnAfterSave; var transformation = editElem.EditedObject as TransformationInfo; if (transformation != null) { // Set parent identifier transformation.TransformationClassID = (ClassID > 0) ? ClassID : filter.ClassId; } ucTransfCode.ClassID = ClassID; if (ClassID <= 0) { // Class is not defined, display doc type filter to select under which class the transformation should be crated filter.SelectedValue = QueryHelper.GetString("selectedvalue", null); filter.FilterMode = TransformationInfo.OBJECT_TYPE; ucTransfCode.ClassID = filter.ClassId; CurrentMaster.DisplayControlsPanel = true; } else { CurrentMaster.DisplayControlsPanel = false; } }
protected void Page_Load(object sender, EventArgs e) { if (QueryHelper.ValidateHash("hash", "category")) { // Get site ID, if 0 then global object files are required int siteId = QueryHelper.GetInteger("siteid", -1); if (siteId < 0) { // If not set use current site ID siteId = SiteContext.CurrentSiteID; } // Initialize attachment list AttachmentList.Visible = true; AttachmentList.ObjectID = ObjectId; if (siteId > 0) { AttachmentList.SiteID = siteId; } AttachmentList.AllowPasteAttachments = QueryHelper.GetBoolean("allowpaste", true); AttachmentList.ObjectType = ObjectType; AttachmentList.Category = ObjectCategory; AttachmentList.ItemsPerPage = 10; AttachmentList.OnAfterDelete += AttachmentList_OnAfterChange; AttachmentList.OnAfterUpload += AttachmentList_OnAfterChange; AttachmentList.IsLiveSite = false; AttachmentList.UploadMode = MultifileUploaderModeEnum.DirectMultiple; } else { AttachmentList.StopProcessing = true; AttachmentList.Visible = false; // Redirect to error page string url = ResolveUrl(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext", true)); ScriptHelper.RegisterStartupScript(this, typeof(string), "BadHashRedirection", string.Format("window.location = '{0}';", url), true); } }
protected void Page_Load(object sender, EventArgs e) { // If StopProcessing flag is set, do nothing if (StopProcessing) { Visible = false; return; } // Validate hash if (!QueryHelper.ValidateHash("hash", "aliaspath", new HashSettings())) { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext")); } // Get data from query string mSubscriptionHash = QueryHelper.GetString("boardsubscriptionhash", string.Empty); mRequestTime = QueryHelper.GetString("datetime", string.Empty); bool controlPb = false; if (RequestHelper.IsPostBack()) { Control pbCtrl = ControlsHelper.GetPostBackControl(Page); if (pbCtrl == btnConfirm) { controlPb = true; } } // Setup controls SetupControls(!controlPb); if (!controlPb) { CheckAndSubscribe(mSubscriptionHash, mRequestTime, true); } }
protected void Page_Load(object sender, EventArgs e) { // Initialize modal page RegisterEscScript(); if (QueryHelper.ValidateHash("hash")) { string title = GetString("general.editmetadata"); Page.Title = title; PageTitle.TitleText = title; // Default image Save += (s, ea) => { if (metaDataEditor.SaveMetadata()) { ltlScript.Text += ScriptHelper.GetScript("CloseDialog();"); } }; AddNoCacheTag(); // Set metadata editor properties metaDataEditor.ObjectGuid = QueryHelper.GetGuid("attachmentguid", Guid.Empty); metaDataEditor.ObjectType = AttachmentInfo.OBJECT_TYPE; metaDataEditor.ExternalControlID = QueryHelper.GetText("clientid", null); metaDataEditor.VersionHistoryID = QueryHelper.GetInteger("versionhistoryid", 0); metaDataEditor.SiteName = CurrentSiteName; } else { // Hide all controls metaDataEditor.Visible = false; string url = ResolveUrl(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext", true)); ltlScript.Text = ScriptHelper.GetScript("window.location = '" + url + "';"); } }
protected void Page_Load(object sender, EventArgs e) { if (DonationSKU == null) { // Redirect if DonationSKU object is not set URLHelper.Redirect(AdministrationUrlHelper.GetAccessDeniedUrl(ResHelper.GetString("dialogs.badhashtext"))); } else { // Set localized SKU name lblSKUName.Text = GetString(DonationSKU.SKUName); donationPropertiesElem.SKU = DonationSKU; if (!donationPropertiesElem.DonationAmountInitialized && (donationAmount > 0)) { // Convert from main to cart currency donationPropertiesElem.DonationAmount = ECommerceContext.CurrentShoppingCart.ApplyExchangeRate(donationAmount); } } // Initialize buttons btnDonate.Click += btnDonate_Click; }
/// <summary> /// Page_Load event handler. /// </summary> protected void Page_Load(object sender, EventArgs e) { if (Node == null) { return; } bool nodeIsRoot = Node.IsRoot(); pageOptionsVisible = !string.IsNullOrEmpty(UIMetadataElementName) && !string.IsNullOrEmpty(UIModuleName) && MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement(UIModuleName, UIMetadataElementName); if (pageOptionsVisible && !nodeIsRoot) { SetupInheritCheckbox("DocumentPageTitle"); SetupInheritCheckbox("DocumentPageDescription"); SetupInheritCheckbox("DocumentPageKeyWords"); } tagsVisible = !string.IsNullOrEmpty(UITagsElementName) && !string.IsNullOrEmpty(UIModuleName) && MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement(UIModuleName, UITagsElementName); if (tagsVisible) { if (!nodeIsRoot) { SetupInheritCheckbox("DocumentTagGroupID"); } InitializeTagSelector(); } if (!pageOptionsVisible && !tagsVisible) { // Redirect to info message if no UI available URLHelper.Redirect(AdministrationUrlHelper.GetInformationUrl("uiprofile.uinotavailable")); } }
protected void Page_Load(object sender, EventArgs e) { string source = QueryHelper.GetString("source", ""); MediaSourceEnum src = CMSDialogHelper.GetMediaSource(source); if (src == MediaSourceEnum.Content) { // Check site availability if (!ResourceSiteInfoProvider.IsResourceOnSite("CMS.Content", SiteContext.CurrentSiteName)) { RedirectToResourceNotAvailableOnSite("CMS.Content"); } } // Check UIProfile string output = QueryHelper.GetString("output", ""); bool checkUI = (output != "copy") && (output != "move") && (output != "link") && (output != "linkdoc") && (output != "relationship") && (output != "selectpath"); if (checkUI) { string errorMessage = ""; OutputFormatEnum outputFormat = CMSDialogHelper.GetOutputFormat(output, QueryHelper.GetBoolean("link", false)); if ((outputFormat == OutputFormatEnum.HTMLLink) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertLink")) { errorMessage = "InsertLink"; } else if ((outputFormat == OutputFormatEnum.HTMLMedia) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertImageOrMedia")) { errorMessage = "InsertImageOrMedia"; } if (errorMessage != "") { RedirectToUIElementAccessDenied("CMS.WYSIWYGEditor", errorMessage); return; } switch (src) { case MediaSourceEnum.DocumentAttachments: case MediaSourceEnum.Attachment: if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "AttachmentsTab")) { errorMessage = "AttachmentsTab"; } break; case MediaSourceEnum.Content: if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "ContentTab")) { errorMessage = "ContentTab"; } break; case MediaSourceEnum.MetaFile: if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "MetafilesTab")) { errorMessage = "MetafilesTab"; } break; } if (errorMessage != "") { RedirectToUIElementAccessDenied("CMS.MediaDialog", errorMessage); return; } } // CKEditor's plugin filebrowser add custom params to url. // This ensures that custom params aren't validated if (QueryHelper.ValidateHash("hash", "CKEditor;CKEditorFuncNum;langCode", validateWithoutExcludedParameters: true)) { CMSDialogHelper.RegisterDialogHelper(Page); ScriptHelper.RegisterStartupScript(Page, typeof(Page), "InitResizers", ScriptHelper.GetScript("InitResizers();")); linkMedia.InitFromQueryString(); } else { linkMedia.StopProcessing = true; linkMedia.Visible = false; string url = ResolveUrl(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext", true)); ltlScript.Text = ScriptHelper.GetScript("if (window.parent != null) { window.parent.location = '" + url + "' }"); } }
/// <summary> /// OK click handler (Proceed registration). /// </summary> protected void btnOK_Click(object sender, EventArgs e) { if (PortalContext.IsDesignMode(PortalContext.ViewMode) || (HideOnCurrentPage) || (!IsVisible)) { // Do not process } else { String siteName = SiteContext.CurrentSiteName; #region "Banned IPs" // Ban IP addresses which are blocked for registration if (!BannedIPInfoProvider.IsAllowed(siteName, BanControlEnum.Registration)) { ShowError(GetString("banip.ipisbannedregistration")); return; } #endregion #region "Check Email & password" string[] siteList = { siteName }; // If AssignToSites field set if (!String.IsNullOrEmpty(AssignToSites)) { siteList = AssignToSites.Split(';'); } // Check whether another user with this user name (which is effectively email) does not exist UserInfo ui = UserInfoProvider.GetUserInfo(txtEmail.Text); SiteInfo si = SiteContext.CurrentSite; UserInfo siteui = UserInfoProvider.GetUserInfo(UserInfoProvider.EnsureSitePrefixUserName(txtEmail.Text, si)); if ((ui != null) || (siteui != null)) { ShowError(GetString("Webparts_Membership_RegistrationForm.UserAlreadyExists").Replace("%%name%%", HTMLHelper.HTMLEncode(txtEmail.Text))); return; } // Check whether password is same if (passStrength.Text != txtConfirmPassword.Text) { ShowError(GetString("Webparts_Membership_RegistrationForm.PassworDoNotMatch")); return; } if ((PasswordMinLength > 0) && (passStrength.Text.Length < PasswordMinLength)) { ShowError(String.Format(GetString("Webparts_Membership_RegistrationForm.PasswordMinLength"), PasswordMinLength)); return; } if (!passStrength.IsValid()) { ShowError(AuthenticationHelper.GetPolicyViolationMessage(SiteContext.CurrentSiteName)); return; } if ((!txtEmail.IsValid()) || (txtEmail.Text.Length > EMAIL_MAX_LENGTH)) { ShowError(String.Format(GetString("Webparts_Membership_RegistrationForm.EmailIsNotValid"), EMAIL_MAX_LENGTH)); return; } #endregion #region "Captcha" // Check if captcha is required and verify captcha text if (DisplayCaptcha && !scCaptcha.IsValid()) { // Display error message if catcha text is not valid ShowError(GetString("Webparts_Membership_RegistrationForm.captchaError")); return; } #endregion #region "User properties" var userEmail = txtEmail.Text.Trim(); ui = new UserInfo(); ui.PreferredCultureCode = ""; ui.Email = userEmail; ui.FirstName = txtFirstName.Text.Trim(); ui.LastName = txtLastName.Text.Trim(); ui.FullName = UserInfoProvider.GetFullName(ui.FirstName, String.Empty, ui.LastName); ui.MiddleName = ""; ui.UserMFRequired = chkUseMultiFactorAutentization.Checked; // User name as put by user (no site prefix included) var plainUserName = userEmail; ui.UserName = plainUserName; // Check if the given email can be used as user name if (!ValidationHelper.IsUserName(plainUserName)) { ShowError(String.Format(GetString("Webparts_Membership_RegistrationForm.UserNameNotValid"), HTMLHelper.HTMLEncode(plainUserName))); return; } // Ensure site prefixes if (UserInfoProvider.UserNameSitePrefixEnabled(siteName)) { ui.UserName = UserInfoProvider.EnsureSitePrefixUserName(plainUserName, si); } ui.Enabled = EnableUserAfterRegistration; ui.UserURLReferrer = CookieHelper.GetValue(CookieName.UrlReferrer); ui.UserCampaign = Service <ICampaignService> .Entry().CampaignCode; ui.SiteIndependentPrivilegeLevel = UserPrivilegeLevelEnum.None; ui.UserSettings.UserRegistrationInfo.IPAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; ui.UserSettings.UserRegistrationInfo.Agent = HttpContext.Current.Request.UserAgent; // Check whether confirmation is required bool requiresConfirmation = SettingsKeyInfoProvider.GetBoolValue(siteName + ".CMSRegistrationEmailConfirmation"); bool requiresAdminApprove = false; if (!requiresConfirmation) { // If confirmation is not required check whether administration approval is required requiresAdminApprove = SettingsKeyInfoProvider.GetBoolValue(siteName + ".CMSRegistrationAdministratorApproval"); if (requiresAdminApprove) { ui.Enabled = false; ui.UserSettings.UserWaitingForApproval = true; } } else { // EnableUserAfterRegistration is overridden by requiresConfirmation - user needs to be confirmed before enable ui.Enabled = false; } // Set user's starting alias path if (!String.IsNullOrEmpty(StartingAliasPath)) { ui.UserStartingAliasPath = MacroResolver.ResolveCurrentPath(StartingAliasPath); } #endregion #region "Reserved names" // Check for reserved user names like administrator, sysadmin, ... if (UserInfoProvider.NameIsReserved(siteName, plainUserName)) { ShowError(GetString("Webparts_Membership_RegistrationForm.UserNameReserved").Replace("%%name%%", HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(ui.UserName, true)))); return; } if (UserInfoProvider.NameIsReserved(siteName, ui.UserNickName)) { ShowError(GetString("Webparts_Membership_RegistrationForm.UserNameReserved").Replace("%%name%%", HTMLHelper.HTMLEncode(ui.UserNickName))); return; } #endregion #region "License limitations" string errorMessage = String.Empty; UserInfoProvider.CheckLicenseLimitation(ui, ref errorMessage); if (!String.IsNullOrEmpty(errorMessage)) { ShowError(errorMessage); return; } #endregion // Check whether email is unique if it is required if (!UserInfoProvider.IsEmailUnique(userEmail, siteList, 0)) { ShowError(GetString("UserInfo.EmailAlreadyExist")); return; } // Set password UserInfoProvider.SetPassword(ui, passStrength.Text); #region "Welcome Emails (confirmation, waiting for approval)" bool error = false; EmailTemplateInfo template = null; string emailSubject = null; // Send welcome message with username and password, with confirmation link, user must confirm registration if (requiresConfirmation) { template = EmailTemplateProvider.GetEmailTemplate("RegistrationConfirmation", siteName); emailSubject = EmailHelper.GetSubject(template, GetString("RegistrationForm.RegistrationConfirmationEmailSubject")); } // Send welcome message with username and password, with information that user must be approved by administrator else if (SendWelcomeEmail) { if (requiresAdminApprove) { template = EmailTemplateProvider.GetEmailTemplate("Membership.RegistrationWaitingForApproval", siteName); emailSubject = EmailHelper.GetSubject(template, GetString("RegistrationForm.RegistrationWaitingForApprovalSubject")); } // Send welcome message with username and password, user can logon directly else { template = EmailTemplateProvider.GetEmailTemplate("Membership.Registration", siteName); emailSubject = EmailHelper.GetSubject(template, GetString("RegistrationForm.RegistrationSubject")); } } if (template != null) { // Create relation between contact and user. This ensures that contact will be correctly recognized when user approves registration (if approval is required) int contactId = ModuleCommands.OnlineMarketingGetCurrentContactID(); if (contactId > 0) { ModuleCommands.OnlineMarketingCreateRelation(ui.UserID, MembershipType.CMS_USER, contactId); } // Email message EmailMessage email = new EmailMessage(); email.EmailFormat = EmailFormatEnum.Default; email.Recipients = ui.Email; email.From = SettingsKeyInfoProvider.GetValue(siteName + ".CMSNoreplyEmailAddress"); email.Subject = emailSubject; try { var resolver = MembershipResolvers.GetMembershipRegistrationResolver(ui, AuthenticationHelper.GetRegistrationApprovalUrl(ApprovalPage, ui.UserGUID, siteName, NotifyAdministrator)); EmailSender.SendEmailWithTemplateText(siteName, email, template, resolver, true); } catch (Exception ex) { EventLogProvider.LogException("E", "RegistrationForm - SendEmail", ex); error = true; } } // If there was some error, user must be deleted if (error) { ShowError(GetString("RegistrationForm.UserWasNotCreated")); // Email was not send, user can't be approved - delete it UserInfoProvider.DeleteUser(ui); return; } #endregion #region "Administrator notification email" // Notify administrator if enabled and e-mail confirmation is not required if (!requiresConfirmation && NotifyAdministrator && (FromAddress != String.Empty) && (ToAddress != String.Empty)) { EmailTemplateInfo mEmailTemplate; if (SettingsKeyInfoProvider.GetBoolValue(siteName + ".CMSRegistrationAdministratorApproval")) { mEmailTemplate = EmailTemplateProvider.GetEmailTemplate("Registration.Approve", siteName); } else { mEmailTemplate = EmailTemplateProvider.GetEmailTemplate("Registration.New", siteName); } if (mEmailTemplate == null) { // Log missing e-mail template EventLogProvider.LogEvent(EventType.ERROR, "RegistrationForm", "GetEmailTemplate", eventUrl: RequestContext.RawURL); } else { EmailMessage message = new EmailMessage(); message.EmailFormat = EmailFormatEnum.Default; message.From = EmailHelper.GetSender(mEmailTemplate, FromAddress); message.Recipients = ToAddress; message.Subject = GetString("RegistrationForm.EmailSubject"); try { MacroResolver resolver = MembershipResolvers.GetRegistrationResolver(ui); EmailSender.SendEmailWithTemplateText(siteName, message, mEmailTemplate, resolver, false); } catch { EventLogProvider.LogEvent(EventType.ERROR, "Membership", "RegistrationEmail"); } } } #endregion #region "Web analytics" // Track successful registration conversion if (TrackConversionName != String.Empty) { if (AnalyticsHelper.AnalyticsEnabled(siteName) && !AnalyticsHelper.IsIPExcluded(siteName, RequestContext.UserHostAddress)) { // Log conversion HitLogProvider.LogConversions(siteName, LocalizationContext.PreferredCultureCode, TrackConversionName, 0, ConversionValue); } } // Log registered user if confirmation is not required if (!requiresConfirmation) { AnalyticsHelper.LogRegisteredUser(siteName, ui); } #endregion #region "On-line marketing - activity" // Log registered user if confirmation is not required if (!requiresConfirmation) { MembershipActivityLogger.LogRegistration(ui.UserName, DocumentContext.CurrentDocument); // Log login activity if (ui.Enabled) { MembershipActivityLogger.LogLogin(ui.UserName, DocumentContext.CurrentDocument); } } #endregion #region "Roles & authentication" string[] roleList = AssignRoles.Split(';'); foreach (string sn in siteList) { // Add new user to the current site UserInfoProvider.AddUserToSite(ui.UserName, sn); foreach (string roleName in roleList) { if (!String.IsNullOrEmpty(roleName)) { String s = roleName.StartsWith(".", StringComparison.Ordinal) ? "" : sn; // Add user to desired roles if (RoleInfoProvider.RoleExists(roleName, s)) { UserInfoProvider.AddUserToRole(ui.UserName, roleName, s); } } } } if (DisplayMessage.Trim() != String.Empty) { pnlForm.Visible = false; lblText.Visible = true; lblText.Text = DisplayMessage; } else { if (ui.Enabled) { AuthenticationHelper.AuthenticateUser(ui.UserName, true); } if (RedirectToURL != String.Empty) { URLHelper.Redirect(UrlResolver.ResolveUrl(RedirectToURL)); } else if (QueryHelper.GetString("ReturnURL", "") != String.Empty) { string url = QueryHelper.GetString("ReturnURL", ""); // Do url decode url = Server.UrlDecode(url); // Check that url is relative path or hash is ok if (url.StartsWith("~", StringComparison.Ordinal) || url.StartsWith("/", StringComparison.Ordinal) || QueryHelper.ValidateHash("hash", "aliaspath")) { URLHelper.Redirect(UrlResolver.ResolveUrl(url)); } // Absolute path with wrong hash else { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext")); } } } #endregion lblError.Visible = false; } }
/// <summary> /// OnButtonCreated event handler. /// </summary> protected void ucUIToolbar_OnButtonCreated(object sender, UniMenuArgs e) { if ((e.UIElement == null) || (e.ButtonControl == null)) { return; } switch (e.UIElement.ElementName.ToLowerCSafe()) { case "onsitedelete": if (isRootDocument) { DisableButton(e, GetString("onsitedit.deleteroot")); } break; case "onsitesave": if (e.ButtonControl != null) { string saveEnabledTooltip = GetString("onsiteedit.saveenabledtooltip"); string saveDisabledTooltip = GetString("onsiteedit.savedisabledtooltip"); e.ButtonControl.CssClass = "BigButtonDisabled OESaveButton"; e.ButtonControl.Attributes.Add("data-enabledTooltip", saveEnabledTooltip); e.ButtonControl.Attributes.Add("data-disabledTooltip", saveDisabledTooltip); e.ButtonControl.ToolTip = saveDisabledTooltip; } break; case "onsiteclose": case "onsitesignout": { string script = string.Empty; // Show javascript confirmation when the document is not found or published if (IsPageNotFound || ((CurrentPageInfo != null) && !CurrentPageInfo.IsPublished && URLRewriter.PageNotFoundForNonPublished(SiteContext.CurrentSiteName))) { script = "if (!confirm(" + ScriptHelper.GetLocalizedString("onsiteedit.signout404confirmation") + ")) { return false; } "; is404 = true; } // Sign out postback script string eventCode = (e.UIElement.ElementName.ToLowerCSafe() == "onsitesignout") ? "signout" : "changeviewmode"; script += ControlsHelper.GetPostBackEventReference(this, eventCode); script = checkChanges + script; e.ButtonControl.Attributes.Add("onclick", script); } break; case "onsitecmsdesk": { string buttonScript = String.Format("self.location.href = '{0}?nodeid={1}&returnviewmode=editlive{2}';", ResolveUrl(AdministrationUrlHelper.GetAdministrationUrl()), NodeId, ApplicationUrlHelper.GetApplicationHash("cms.content", "content")); buttonScript = checkChanges + buttonScript; e.ButtonControl.Attributes.Add("onclick", buttonScript); } break; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); ScriptHelper.RegisterModule(this, "CMS/Mole"); // In case invalid site configuration skip VirtualContextAuhtenticator initialization if (!string.IsNullOrWhiteSpace(SiteContext.CurrentSite?.SitePresentationURL) && !string.IsNullOrWhiteSpace(SiteContext.CurrentSite?.DomainName)) { // In case current user was not properly initialized redirect to the access denied page if (CurrentUser.UserAuthenticationGUID == Guid.Empty) { URLHelper.Redirect(AdministrationUrlHelper.GetAccessDeniedUrl("membership.usersessioninvalid")); } ScriptHelper.RegisterModule(this, "CMS/VirtualContextAuthenticator", new { authenticationFrameUrl = GetMvcAuthenticationFrameUrl(), refreshInterval = Convert.ToInt32(new VirtualContextAuthenticationConfiguration().Validity.TotalSeconds) }); var loadAuthenticationFrameCallback = Page.ClientScript.GetCallbackEventReference(this, "arg", "window.CMS.VirtualContextAuthenticator.loadAuthenticationFrame", ""); var callbackScript = $"function raiseGetAuthenticationFrameUrlCallback() {{ var arg = '{GET_MVC_AUTHENTICATION_CALLBACK}'; {loadAuthenticationFrameCallback}; }}"; ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "loadAuthenticationFrameCallback", callbackScript, true); } ScriptHelper.RegisterModule(this, "CMS/BreadcrumbsPin", new { pinId = "js-single-object-dashboard-pin" }); ScriptHelper.RegisterModule(this, "CMS/Header", new { selectorId = siteSelector.DropDownSingleSelect.ClientID, dashboardLinkId = lnkDashboard.ClientID }); EnsureHideMessageCallback(); CheckSubscriptionLicences(); CheckTrial(); CheckEcommerceLicenseLimitations(); // Display the techPreview info if there is a key in the web.config pnlTechPreview.Visible = ValidationHelper.GetBoolean(Service.Resolve <IAppSettingsService>()["CMSUseTechnicalPreview"], false) && CheckWarningMessage(SESSION_KEY_TECH_PREVIEW); pwdExpiration.ShowChangePasswordLink = true; pwdExpiration.ExpirationTextBefore = GetString("passwordexpiration.expired"); pwdExpiration.ExpirationWarningTextBefore = string.Format(GetString("passwordexpiration.willexpire"), MembershipContext.AuthenticatedUser.UserPasswordExpiration); string scHideWarning = @" function HideWarning(id, key) { if(key) { HideMessage(key); } if(!id) { id = '" + pnlPwdExp.ClientID + @"'; } var panel = $cmsj('#' + id); if(panel) { panel.hide(); window.top.layouts[0].resizeAll(); } } function ReceiveMessage() {} "; ScriptHelper.RegisterStartupScript(this, typeof(string), "HideHeaderWarning", scHideWarning, true); // Site selector settings siteSelector.UpdatePanel.RenderMode = UpdatePanelRenderMode.Inline; siteSelector.AllowAll = false; siteSelector.UniSelector.OnSelectionChanged += SiteSelector_OnSelectionChanged; siteSelector.DropDownSingleSelect.AutoPostBack = true; siteSelector.OnlyRunningSites = true; // Allow empty for not-existing current site if (SiteContext.CurrentSite == null) { siteSelector.AllowEmpty = true; } if (!RequestHelper.IsPostBack()) { siteSelector.Value = SiteContext.CurrentSiteID; } // Show only assigned sites for not global admins if (!MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) { siteSelector.UserId = MembershipContext.AuthenticatedUser.UserID; } StringBuilder script = new StringBuilder(); script.Append( @" function CheckChanges() { var innerFrame = parent.frames['cmsdesktop']; if (innerFrame.CheckChanges && !innerFrame.CheckChanges()) { return false; } else { return true; } } "); ScriptHelper.RegisterStartupScript(this, typeof(string), "headerScript", ScriptHelper.GetScript(script.ToString())); ScriptHelper.RegisterModule(this, "CMS/Breadcrumbs", new { moreBreadcrumbsText = GetString("breadcrumbs.more"), splitViewModeText = GetString("SplitMode.Compare") }); EnsureStagingTaskGroupMenu(); lnkDashboard.Attributes.Add("href", "#"); }
protected override void OnPreInit(EventArgs e) { RequireSite = false; CurrentUserInfo currentUser = MembershipContext.AuthenticatedUser; if (!currentUser.IsAuthorizedPerResource("CMS.Design", "ReadCMSCSSStylesheet")) { RedirectToAccessDenied("CMS.Design", "ReadCMSCSSStylesheet"); } // Page has been opened in CMSDesk and only stylesheet style editing is allowed isDialog = (QueryHelper.GetBoolean("dialog", false) || QueryHelper.GetBoolean("isindialog", false)); // Check for UI permissions bool isUserAuthorizedPagesApp = currentUser.IsAuthorizedPerUIElement("CMS.Content", new string[] { "Properties", "Properties.General", "General.Design", "Design.EditCSSStylesheets" }, SiteContext.CurrentSiteName); bool isUserAuthorizedCssStylesheetsApp = currentUser.IsAuthorizedPerUIElement("CMS.Design", new string[] { "EditStylesheet", "StylesheetGeneral" }, SiteContext.CurrentSiteName); if (!isUserAuthorizedPagesApp && !isUserAuthorizedCssStylesheetsApp) { var uiElement = isDialog ? "EditStylesheet;StylesheetGeneral" : "Properties;Properties.General;General.Design;Design.EditCSSStylesheets"; RedirectToUIElementAccessDenied("CMS.Content", uiElement); } // Prevent replacing of the master page with dialog master page RequiresDialog = false; if (isDialog) { // Check hash if (!QueryHelper.ValidateHash("hash", "objectid", null, true)) { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext")); } // Check 'Modify CSS stylesheets' permission if (!currentUser.IsAuthorizedPerResource("CMS.Design", "ModifyCMSCSSStylesheet")) { RedirectToAccessDenied("CMS.Design", "ModifyCMSCSSStylesheet"); } } string stylesheet = QueryHelper.GetString("objectid", "0"); // If default stylesheet defined and selected, choose it if (stylesheet == "default") { si = PortalContext.CurrentSiteStylesheet; } // Default stylesheet not selected try to find stylesheet selected if (si != null) { cssStylesheetId = si.StylesheetID; } else { cssStylesheetId = ValidationHelper.GetInteger(stylesheet, 0); if (cssStylesheetId > 0) { // Get the stylesheet si = CssStylesheetInfoProvider.GetCssStylesheetInfo(cssStylesheetId); } } SetEditedObject(si, null); // Check site association in case that user is not admin var checkSiteAssociation = !currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin); if ((si != null) && isDialog && checkSiteAssociation) { // Check if stylesheet is under current site int siteId = (CurrentSite != null) ? CurrentSite.SiteID : 0; DataSet ds = CssStylesheetSiteInfoProvider.GetCssStylesheetSites() .WhereEquals("SiteID", siteId) .WhereEquals("StylesheetID", si.StylesheetID) .TopN(1); if (DataHelper.DataSourceIsEmpty(ds)) { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("cssstylesheet.errorediting", "cssstylesheet.notallowedtoedit")); } } base.OnPreInit(e); }
/// <summary> /// Page load. /// </summary> protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(QueryHelper.GetString("queryname", string.Empty)) && !QueryHelper.ValidateHash("hash")) { URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext")); } else { int mTypeOfInput = 1; // Handle to ListBox postback ItemSelection1.OnPostBack += ItemSelection1_OnPostBack; ItemSelection1.OnMoveLeft += ItemSelection1_OnMoveLeft; // Initialize resource strings PageTitle.TitleText = GetString("GridColumnDesigner.Title"); ItemSelection1.LeftColumnLabel.Text = GetString("ItemSelection.Avaliable"); ItemSelection1.RightColumnLabel.Text = GetString("ItemSelection.Displayed"); mSelColId = QueryHelper.GetString("SelColId", ""); mColId = QueryHelper.GetString("ColId", ""); // Set-up ColumnListBox ItemSelection1.RightColumListBox.SelectionMode = ListSelectionMode.Single; ItemSelection1.RightColumListBox.AutoPostBack = true; // Get classnames or queryname from querystring if (!string.IsNullOrEmpty(Request.QueryString["classnames"])) { hdnClassNames.Value = Request.QueryString["classnames"]; mTypeOfInput = 1; } if (!string.IsNullOrEmpty(Request.QueryString["queryname"])) { hdnClassNames.Value = Request.QueryString["queryname"]; mTypeOfInput = 2; } // Get data from viewstate tmpColumns = FromView(ViewColumns); // Load Columns names if (FirstLoad <= 1) { FirstLoad++; // Use dataClass or Query to get names of columns switch (mTypeOfInput) { case 1: LoadFromDataClass(); break; case 2: LoadFromQuery(); break; } // Read XML ReadXML(hdnSelectedColumns.Value); if (!string.IsNullOrEmpty(ViewColumns)) { radSelect.Checked = true; radGenerate.Checked = false; } // Move selected columns if (tmpColumns != null) { for (int i = tmpColumns.GetLowerBound(0); i <= tmpColumns.GetUpperBound(0); i++) { ListItem LI = ItemSelection1.LeftColumListBox.Items.FindByText(tmpColumns[i, 1]); if (LI != null) { ItemSelection1.RightColumListBox.Items.Add(LI); ItemSelection1.LeftColumListBox.Items.Remove(LI); } } } } if (!RequestHelper.IsPostBack()) { // Reload page to get data from parent in javascript string script = String.Format(@" document.getElementById('{0}').value = wopener.GetClassNames('{1}'); document.getElementById('{2}').value = wopener.GetSelectedColumns('{3}'); document.body.onload = function () {{ {4} }}; ", hdnClassNames.ClientID, ScriptHelper.GetString(mColId, false), hdnSelectedColumns.ClientID, ScriptHelper.GetString(mSelColId, false), ControlsHelper.GetPostBackEventReference(ItemSelection1.RightColumListBox, "")); ScriptHelper.RegisterStartupScript(this, typeof(string), "LoadScript", script, true); } // Show or hide dialog ItemSelection1.Visible = !radGenerate.Checked; pnlProperties.Visible = !radGenerate.Checked; } }
protected void Page_Load(object sender, EventArgs e) { // Register script files ScriptHelper.RegisterCMS(this); ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Operation.js"); // Set current UI culture currentCulture = CultureHelper.PreferredUICultureCode; // Initialize current user currentUser = MembershipContext.AuthenticatedUser; // Initialize current site currentSite = SiteContext.CurrentSite; // Initialize events ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished; ctlAsyncLog.OnError += ctlAsyncLog_OnError; ctlAsyncLog.OnCancel += ctlAsyncLog_OnCancel; if (!RequestHelper.IsCallback()) { DataSet allDocs = null; TreeProvider tree = new TreeProvider(currentUser); // Current Node ID to delete string parentAliasPath = string.Empty; if (Parameters != null) { parentAliasPath = ValidationHelper.GetString(Parameters["parentaliaspath"], string.Empty); } if (string.IsNullOrEmpty(parentAliasPath)) { nodeIdsArr = QueryHelper.GetString("nodeid", string.Empty).Trim('|').Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string nodeId in nodeIdsArr) { int id = ValidationHelper.GetInteger(nodeId, 0); if (id != 0) { nodeIds.Add(id); } } } else { var where = new WhereCondition(WhereCondition) .WhereNotEquals("ClassName", SystemDocumentTypes.Root); allDocs = tree.SelectNodes(currentSite.SiteName, parentAliasPath.TrimEnd(new[] { '/' }) + "/%", TreeProvider.ALL_CULTURES, true, ClassID > 0 ? DataClassInfoProvider.GetClassName(ClassID) : TreeProvider.ALL_CLASSNAMES, where.ToString(true), "DocumentName", TreeProvider.ALL_LEVELS, false, 0, DocumentColumnLists.SELECTNODES_REQUIRED_COLUMNS + ",DocumentName,NodeParentID,NodeSiteID,NodeAliasPath,NodeSKUID"); if (!DataHelper.DataSourceIsEmpty(allDocs)) { foreach (DataTable table in allDocs.Tables) { foreach (DataRow row in table.Rows) { nodeIds.Add(ValidationHelper.GetInteger(row["NodeID"], 0)); } } } } // Setup page title text and image PageTitle.TitleText = GetString("Content.DeleteTitle"); EnsureDocumentBreadcrumbs(PageBreadcrumbs, action: PageTitle.TitleText); // Register the dialog script ScriptHelper.RegisterDialogScript(this); ctlAsyncLog.TitleText = GetString("ContentDelete.DeletingDocuments"); // Set visibility of panels pnlContent.Visible = true; pnlLog.Visible = false; bool isMultilingual = CultureSiteInfoProvider.IsSiteMultilingual(currentSite.SiteName); if (!isMultilingual) { // Set all cultures checkbox chkAllCultures.Checked = true; pnlAllCultures.Visible = false; } if (nodeIds.Count > 0) { if (nodeIds.Count == 1) { // Single document deletion int nodeId = ValidationHelper.GetInteger(nodeIds[0], 0); TreeNode node = null; if (string.IsNullOrEmpty(parentAliasPath)) { // Get any culture if current not found node = tree.SelectSingleNode(nodeId, CultureCode) ?? tree.SelectSingleNode(nodeId, TreeProvider.ALL_CULTURES); } else { if (allDocs != null) { DataRow dr = allDocs.Tables[0].Rows[0]; node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr, tree); } } if (node != null) { bool rootDeleteDisabled = false; if (IsProductsMode) { string startingPath = SettingsKeyInfoProvider.GetValue(CurrentSiteName + ".CMSStoreProductsStartingPath"); if (node.NodeAliasPath.CompareToCSafe(startingPath) == 0) { string closeLink = "<a href=\"#\"><span style=\"cursor: pointer;\" " + "onclick=\"SelectNode(" + node.NodeID + "); return false;\">" + GetString("general.back") + "</span></a>"; ShowError(string.Format(GetString("com.productsection.deleteroot"), closeLink, "")); pnlDelete.Visible = false; rootDeleteDisabled = true; } } if (node.IsRoot() && isMultilingual) { // Hide 'Delete all cultures' checkbox pnlAllCultures.Visible = false; if (!URLHelper.IsPostback()) { // Check if there are any documents in another culture or current culture has some documents pnlDeleteRoot.Visible = IsAnyDocumentInAnotherCulture(node) && (tree.SelectNodesCount(SiteContext.CurrentSiteName, "/%", LocalizationContext.PreferredCultureCode, false, null, null, null, TreeProvider.ALL_LEVELS, false) > 0); if (pnlDeleteRoot.Visible) { // Insert 'Delete current root' option if current root node is translated to current culture if (node.DocumentCulture == LocalizationContext.PreferredCultureCode) { rblRoot.Items.Add(new ListItem(GetString("rootdeletion.currentroot"), "current")); } rblRoot.Items.Add(new ListItem(GetString("rootdeletion.currentculture"), "allculturepages")); rblRoot.Items.Add(new ListItem(GetString("rootdeletion.allpages"), "allpages")); } else { rblRoot.Items.Add(new ListItem(GetString("rootdeletion.allpages"), "allpages")); } if (rblRoot.SelectedIndex < 0) { rblRoot.SelectedIndex = 0; } } } // Display warning for root node if (!rootDeleteDisabled && node.IsRoot()) { if (!currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) { pnlDelete.Visible = false; ShowInformation(GetString("delete.rootonlyglobaladmin")); } else { if ((rblRoot.SelectedValue == "allpages") || !isMultilingual || ((rblRoot.SelectedValue == "allculturepages") && !IsAnyDocumentInAnotherCulture(node))) { messagesPlaceholder.ShowWarning(GetString("Delete.RootWarning")); plcDeleteRoot.Visible = true; } else { plcDeleteRoot.Visible = false; } } } hasChildren = node.NodeHasChildren; bool authorizedToDeleteSKU = !node.HasSKU || IsUserAuthorizedToModifySKU(node); if (!RequestHelper.IsPostBack()) { bool authorizedToDeleteDocument = IsUserAuthorizedToDeleteDocument(node); if (!authorizedToDeleteDocument || !authorizedToDeleteSKU) { pnlDelete.Visible = false; RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath))); } } if (node.IsLink) { PageTitle.TitleText = GetString("Content.DeleteTitleLink") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(node.GetDocumentName())) + "\""; headQuestion.Text = GetString("ContentDelete.QuestionLink"); chkAllCultures.Checked = true; plcCheck.Visible = false; } else { string nodeName = HTMLHelper.HTMLEncode(node.GetDocumentName()); // Get name for root document if (node.IsRoot()) { nodeName = HTMLHelper.HTMLEncode(currentSite.DisplayName); } PageTitle.TitleText = GetString("Content.DeleteTitle") + " \"" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(nodeName)) + "\""; } // Show or hide checkbox pnlDestroy.Visible = CanDestroy(node); cancelNodeId = IsMultipleAction ? node.NodeParentID : node.NodeID; lblDocuments.Text = HTMLHelper.HTMLEncode(node.GetDocumentName()); SetSeoPanelVisibility(node); } else { if (!RequestHelper.IsPostBack()) { URLHelper.Redirect(AdministrationUrlHelper.GetInformationUrl("editeddocument.notexists")); } else { // Hide everything pnlContent.Visible = false; } } headQuestion.Text = GetString("ContentDelete.Question"); lblAllCultures.Text = GetString("ContentDelete.AllCultures"); lblDestroy.Text = GetString("ContentDelete.Destroy"); headDeleteDocument.Text = GetString("ContentDelete.Document"); } else if (nodeIds.Count > 1) { string where = "NodeID IN ("; foreach (int nodeID in nodeIds) { where += nodeID + ","; } where = where.TrimEnd(',') + ")"; DataSet ds = allDocs ?? tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, "DocumentName", -1, false); if (!DataHelper.DataSourceIsEmpty(ds)) { string docList = null; if (string.IsNullOrEmpty(parentAliasPath)) { cancelNodeId = DataHelper.GetIntValue(ds.Tables[0].Rows[0], "NodeParentID"); } else { cancelNodeId = TreePathUtils.GetNodeIdByAliasPath(currentSite.SiteName, parentAliasPath); } bool canDestroy = true; bool permissions = true; foreach (DataTable table in ds.Tables) { foreach (DataRow dr in table.Rows) { bool isLink = (dr["NodeLinkedNodeID"] != DBNull.Value); string name = (string)dr["DocumentName"]; docList += HTMLHelper.HTMLEncode(name); if (isLink) { docList += DocumentUIHelper.GetDocumentMarkImage(Page, DocumentMarkEnum.Link); } docList += "<br />"; lblDocuments.Text = docList; // Set visibility of checkboxes TreeNode node = TreeNode.New(ValidationHelper.GetString(dr["ClassName"], string.Empty), dr); SetSeoPanelVisibility(node); if (!IsUserAuthorizedToDeleteDocument(node)) { permissions = false; AddError(String.Format( GetString("cmsdesk.notauthorizedtodeletedocument"), HTMLHelper.HTMLEncode(node.NodeAliasPath)), null); } // Can destroy if "can destroy all previous AND current" canDestroy = CanDestroy(node) && canDestroy; if (!hasChildren) { hasChildren = node.NodeHasChildren; } } } pnlDelete.Visible = permissions; pnlDestroy.Visible = canDestroy; } else { if (!RequestHelper.IsPostBack()) { URLHelper.Redirect(AdministrationUrlHelper.GetInformationUrl("editeddocument.notexists")); } else { // Hide everything pnlContent.Visible = false; } } headQuestion.Text = GetString("ContentDelete.QuestionMultiple"); PageTitle.TitleText = GetString("Content.DeleteTitleMultiple"); lblAllCultures.Text = GetString("ContentDelete.AllCulturesMultiple"); lblDestroy.Text = GetString("ContentDelete.DestroyMultiple"); headDeleteDocument.Text = GetString("global.pages"); } lblAltPath.AssociatedControlClientID = selAltPath.PathTextBox.ClientID; selAltPath.SiteID = currentSite.SiteID; chkUseDeletedPath.CheckedChanged += chkUseDeletedPath_CheckedChanged; if (!RequestHelper.IsPostBack()) { selAltPath.Enabled = false; chkAltSubNodes.Enabled = false; chkAltAliases.Enabled = false; // Set default path if is defined selAltPath.Value = SettingsKeyInfoProvider.GetValue(CurrentSiteName + ".CMSDefaultDeletedNodePath"); if (!hasChildren) { chkAltSubNodes.Checked = false; chkAltSubNodes.Enabled = false; } } // If user has allowed cultures specified if (currentUser.UserHasAllowedCultures) { // Get all site cultures DataSet siteCultures = CultureSiteInfoProvider.GetSiteCultures(currentSite.SiteName); bool denyAllCulturesDeletion = false; // Check that user can edit all site cultures foreach (DataRow culture in siteCultures.Tables[0].Rows) { string cultureCode = DataHelper.GetStringValue(culture, "CultureCode"); if (!currentUser.IsCultureAllowed(cultureCode, currentSite.SiteName)) { denyAllCulturesDeletion = true; } } // If user can't edit all site cultures if (denyAllCulturesDeletion) { // Hide all cultures selector pnlAllCultures.Visible = false; chkAllCultures.Checked = false; } } pnlDeleteDocument.Visible = pnlAllCultures.Visible || pnlDestroy.Visible; } else { // Hide everything pnlContent.Visible = false; } } // Initialize header action InitializeActionMenu(); }
/// <summary> /// Creates collection of tabs which should be displayed to the user. /// </summary> private void GetTabs() { UITabs tabControl = CurrentMaster.Tabs; bool checkUI = true; // Disable personalization for none-HTML editors if ((CustomOutputFormat == "copy") || (CustomOutputFormat == "move") || (CustomOutputFormat == "link") || (CustomOutputFormat == "relationship") || (CustomOutputFormat == "selectpath")) { checkUI = false; } else if (IsLiveSite) { // Ensure personalization of the HTML editor on the live site checkUI = ValidationHelper.GetBoolean(SettingsHelper.AppSettings["CKEditor:PersonalizeToolbarOnLiveSite"], false); } if (checkUI) { if ((OutputFormat == OutputFormatEnum.HTMLMedia) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertImageOrMedia")) { ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + UrlResolver.ResolveUrl(AdministrationUrlHelper.GetAccessDeniedUrl("CMS.WYSIWYGEditor", null, "InsertImageOrMedia")) + "';} ")); return; } if ((OutputFormat == OutputFormatEnum.HTMLLink) && !MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.WYSIWYGEditor", "InsertLink")) { ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + UrlResolver.ResolveUrl(AdministrationUrlHelper.GetAccessDeniedUrl("CMS.WYSIWYGEditor", null, "InsertLink")) + "';} ")); return; } if ((CustomOutputFormat == "linkdoc") && !(MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Content", "New.LinkExistingDocument") && MembershipContext.AuthenticatedUser.IsAuthorizedPerUIElement("CMS.Content", "New"))) { ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + UrlResolver.ResolveUrl(AdministrationUrlHelper.GetAccessDeniedUrl("CMS.Content", null, "New.LinkExistingDocument")) + "';} ")); return; } } // Attachments if ((CustomOutputFormat == "") && (!HasMetaFileObjectInfo) && !HideAttachments && (OutputFormat != OutputFormatEnum.NodeGUID) && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "AttachmentsTab"))) { tabControl.AddTab(new UITabItem() { Text = GetString("general.attachments"), RedirectUrl = GetFilePath("Tabs_Media.aspx", "source", CMSDialogHelper.GetMediaSource(MediaSourceEnum.DocumentAttachments)) }); if (SelectedTab == "attachments") { mSelectedTabIndex = tabControl.TabItems.Count - 1; } } else if ((CustomOutputFormat == "") && (HasMetaFileObjectInfo) && !HideAttachments && (OutputFormat != OutputFormatEnum.NodeGUID) && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "MetafilesTab"))) { // Metafile attachments tabControl.AddTab(new UITabItem() { Text = GetString("general.attachments"), RedirectUrl = GetFilePath("Tabs_Media.aspx", "source", CMSDialogHelper.GetMediaSource(MediaSourceEnum.MetaFile)) }); if (SelectedTab == "attachments") { mSelectedTabIndex = tabControl.TabItems.Count - 1; } } else if (SelectedTab == "attachments") { SelectedTab = "web"; } // Content if (!HideContent && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "ContentTab"))) { tabControl.AddTab(new UITabItem() { Text = GetString("general.content"), RedirectUrl = GetFilePath("Tabs_Media.aspx", "source", CMSDialogHelper.GetMediaSource(MediaSourceEnum.Content)) }); if (SelectedTab == "content") { mSelectedTabIndex = tabControl.TabItems.Count - 1; } } else if (SelectedTab == "content") { SelectedTab = "web"; } // Media libraries if ((CustomOutputFormat == "") && !HideMediaLibraries && (OutputFormat != OutputFormatEnum.NodeGUID) && ModuleManager.IsModuleLoaded(ModuleName.MEDIALIBRARY) && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "MediaLibrariesTab"))) { tabControl.AddTab(new UITabItem() { Text = GetString("dialogs.header.libraries"), RedirectUrl = GetMediaLibrariesPath() }); if (SelectedTab == "libraries") { mSelectedTabIndex = tabControl.TabItems.Count - 1; } } else if (SelectedTab == "libraries") { SelectedTab = "web"; } // Web if ((CustomOutputFormat == "") && !HideWeb && (OutputFormat != OutputFormatEnum.NodeGUID) && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "WebTab"))) { tabControl.AddTab(new UITabItem() { Text = GetString("dialogs.header.web"), RedirectUrl = (OutputFormat == OutputFormatEnum.BBLink) || (OutputFormat == OutputFormatEnum.HTMLLink) ? GetFilePath("Tabs_WebLink.aspx") : GetFilePath("Tabs_Web.aspx") }); if (SelectedTab == "web") { mSelectedTabIndex = tabControl.TabItems.Count - 1; } } // Anchor & E-mail if ((CustomOutputFormat == "") && ((OutputFormat == OutputFormatEnum.BBLink) || (OutputFormat == OutputFormatEnum.HTMLLink) || (OutputFormat == OutputFormatEnum.Custom))) { // Anchor if (!HideAnchor && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "AnchorTab"))) { tabControl.AddTab(new UITabItem() { Text = GetString("dialogs.header.anchor"), RedirectUrl = GetFilePath("Tabs_Anchor.aspx") }); if (SelectedTab == "anchor") { mSelectedTabIndex = tabControl.TabItems.Count - 1; } } else if (SelectedTab == "anchor") { SelectedTab = "web"; } // E-mail if (!HideEmail && (!checkUI || currentUser.IsAuthorizedPerUIElement("CMS.MediaDialog", "EmailTab"))) { tabControl.AddTab(new UITabItem() { Text = GetString("general.email"), RedirectUrl = GetFilePath("Tabs_Email.aspx") }); if (SelectedTab == "email") { mSelectedTabIndex = tabControl.TabItems.Count - 1; } } else if (SelectedTab == "email") { SelectedTab = "web"; } } string selectedUrl = ((mSelectedTabIndex > 0) ? tabControl.TabItems[mSelectedTabIndex].RedirectUrl : ((tabControl.TabItems.Count > 0) ? tabControl.TabItems[0].RedirectUrl : String.Empty)); if (!String.IsNullOrEmpty(selectedUrl)) { ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + selectedUrl.Replace("&", "&").Replace("'", "%27") + "';} ")); } // No tab is displayed -> load UI Not available if (tabControl.TabItems.Count == 0) { ScriptHelper.RegisterStartupScript(this, typeof(string), "frameLoad", ScriptHelper.GetScript("if (window.parent.frames['insertContent']) { window.parent.frames['insertContent'].location= '" + UrlResolver.ResolveUrl(AdministrationUrlHelper.GetInformationUrl("uiprofile.uinotavailable")) + "';} ")); } else if (tabControl.TabItems.Count == 1) { tabControl.Visible = false; // Hide empty space because of hidden tab control ScriptHelper.RegisterStartupScript(this, typeof(string), "headerFrameHide", ScriptHelper.GetScript("parent.$cmsj('#rowsFrameset').attr('rows','" + CMSPage.TitleOnlyHeight + ", *, " + CMSPage.FooterFrameHeight + "')")); } }
protected void Page_Load(object sender, EventArgs e) { ucSelectString.Scope = ReportInfo.OBJECT_TYPE; pnlConnectionString.Visible = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.reporting", "SetConnectionString"); Title = "Report General"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ReloadPage", ScriptHelper.GetScript("function ReloadPage() { \n" + Page.ClientScript.GetPostBackEventReference(btnHdnReload, null) + "}")); reportId = QueryHelper.GetInteger("reportId", 0); // control initializations rfvReportDisplayName.ErrorMessage = GetString("Report_New.EmptyDisplayName"); rfvReportName.ErrorMessage = GetString("Report_New.EmptyCodeName"); lblReportDisplayName.Text = GetString("Report_New.DisplayNameLabel"); lblReportName.Text = GetString("Report_New.NameLabel"); lblReportCategory.Text = GetString("Report_General.CategoryLabel"); lblLayout.Text = GetString("Report_General.LayoutLabel"); lblGraphs.Text = GetString("Report_General.GraphsLabel") + ":"; lblHtmlGraphs.Text = GetString("Report_General.HtmlGraphsLabel") + ":"; lblTables.Text = GetString("Report_General.TablesLabel") + ":"; lblValues.Text = GetString("Report_General.TablesValues") + ":"; lblReportAccess.Text = GetString("Report_General.ReportAccessLabel"); actionsElem.ActionsList.Add(new SaveAction()); actionsElem.ActionPerformed += actionsElem_ActionPerformed; AttachmentTitle.TitleText = GetString("general.attachments"); attachmentList.AllowPasteAttachments = true; attachmentList.ObjectID = reportId; attachmentList.ObjectType = ReportInfo.OBJECT_TYPE; attachmentList.Category = ObjectAttachmentsCategories.LAYOUT; // Get report info ri = ReportInfoProvider.GetReportInfo(reportId); if (ri == null) { URLHelper.SeeOther(AdministrationUrlHelper.GetInformationUrl("editedobject.notexists")); } if (!RequestHelper.IsPostBack()) { LoadData(); } htmlTemplateBody.AutoDetectLanguage = false; htmlTemplateBody.DefaultLanguage = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName; htmlTemplateBody.EditorAreaCSS = ""; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ReportingHTML", ScriptHelper.GetScript(" var reporting_htmlTemplateBody = '" + htmlTemplateBody.ClientID + "'")); // initialize item list controls ilGraphs.Report = ri; ilTables.Report = ri; ilValues.Report = ri; ilHtmlGraphs.Report = ri; ilGraphs.EditUrl = "ReportGraph_Edit.aspx"; ilTables.EditUrl = "ReportTable_Edit.aspx"; ilValues.EditUrl = "ReportValue_Edit.aspx"; ilHtmlGraphs.EditUrl = "ReportHtmlGraph_Edit.aspx"; ilGraphs.ItemType = ReportItemType.Graph; ilTables.ItemType = ReportItemType.Table; ilValues.ItemType = ReportItemType.Value; ilHtmlGraphs.ItemType = ReportItemType.HtmlGraph; // Refresh script string script = "function RefreshWOpener(w) { if (w.refreshPageOnClose){ " + ControlsHelper.GetPostBackEventReference(this, "arg") + " }}"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ReportingRefresh", ScriptHelper.GetScript(script)); }
/// <summary> /// Initialization from query string. /// </summary> public void InitFromQueryString() { // Get allowed and excluded folders and extensions FileSystemDialogConfiguration config = Config; Hashtable p; var paramsGuid = QueryHelper.GetString("params", ""); if (!String.IsNullOrEmpty(paramsGuid)) { // Try to get parameters p = (Hashtable)WindowHelper.GetItem(paramsGuid, true); // ... and validate hash if ((p == null) || !QueryHelper.ValidateHash("hash", "selectedvalue")) { // Redirect to error page URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext")); return; } } else { p = new Hashtable(); } config.AllowManage = ValidationHelper.GetBoolean(GetParameter(p, "allow_manage"), config.AllowManage); config.AllowedExtensions = ValidationHelper.GetString(GetParameter(p, "allowed_extensions"), config.AllowedExtensions); config.NewTextFileExtension = ValidationHelper.GetString(GetParameter(p, "newfile_extension"), config.NewTextFileExtension); config.AllowedFolders = ValidationHelper.GetString(GetParameter(p, "allowed_folders"), config.AllowedFolders); config.ExcludedExtensions = ValidationHelper.GetString(GetParameter(p, "excluded_extensions"), config.ExcludedExtensions); config.ExcludedFolders = ValidationHelper.GetString(GetParameter(p, "excluded_folders"), config.ExcludedFolders); config.AllowNonApplicationPath = ValidationHelper.GetBoolean(GetParameter(p, "allow_nonapp_path"), config.AllowNonApplicationPath); // Get starting path var startingPath = ValidationHelper.GetString(GetParameter(p, "starting_path"), "~/"); if (startingPath.StartsWithCSafe("~") && (startingPath != "~/")) { startingPath = startingPath.TrimEnd('/'); } else { // If only application path allowed, set it if (!config.AllowNonApplicationPath) { string startPath = startingPath; if (startingPath.StartsWithCSafe("~")) { startPath = Server.MapPath(startingPath); } if (!startPath.StartsWithCSafe(Server.MapPath("~/"))) { startingPath = "~/"; } } else if (!startingPath.EndsWithCSafe(":\\")) { startingPath = startingPath.TrimEnd('\\'); } } config.StartingPath = startingPath; // Get selected path var selectedPath = ValidationHelper.GetString(GetParameter(p, "selected_path"), String.Empty); // If starting path under website try to map selected path if (startingPath.StartsWithCSafe("~") && !String.IsNullOrEmpty(selectedPath)) { try { var absolutePath = Server.MapPath(selectedPath); var absoluteStartingPath = Server.MapPath(startingPath); selectedPath = absolutePath.Replace(absoluteStartingPath, startingPath); } catch { } } // Fix slashes selectedPath = selectedPath.StartsWithCSafe("~") ? Path.EnsureSlashes(selectedPath, true) : Path.EnsureBackslashes(selectedPath, true); config.SelectedPath = selectedPath; // Get default path config.DefaultPath = ValidationHelper.GetString(GetParameter(p, "default_path"), String.Empty); string origDefaultPath = config.DefaultPath; if (selectedPath.StartsWithCSafe(startingPath)) { // item to be selected string selectedItem = config.SelectedPath.Replace(startingPath, string.Empty); char slashChar = '\\'; if (selectedPath.StartsWithCSafe("~")) { slashChar = '/'; } selectedItem = selectedItem.TrimStart(slashChar).TrimEnd(slashChar); // Check if config path ends with file, if yes then select file otherwise select item if (File.Exists(Server.MapPath(config.SelectedPath))) { if (selectedItem.LastIndexOf(slashChar) != -1) { selectedItem = selectedItem.Substring(0, selectedItem.LastIndexOfCSafe(slashChar)); } } config.DefaultPath = selectedItem; } string defaultPath = Path.Combine(startingPath, config.DefaultPath); if (startingPath.StartsWithCSafe("~")) { try { defaultPath = Server.MapPath(defaultPath); } catch { // Set default path defaultPath = string.Empty; } } if (!Directory.Exists(defaultPath)) { try { defaultPath = Server.MapPath(Path.Combine(startingPath, origDefaultPath)); } catch { // Set default path defaultPath = string.Empty; } config.DefaultPath = Directory.Exists(defaultPath) ? origDefaultPath : string.Empty; } // Get mode config.ShowFolders = ValidationHelper.GetBoolean(GetParameter(p, "show_folders"), false); config.AllowZipFolders = ValidationHelper.GetBoolean(GetParameter(p, "allow_zip_folders"), false); }
protected void Page_Load(object sender, EventArgs e) { if (QueryHelper.ValidateHash("hash")) { if (QueryHelper.GetBoolean("refresh", false)) { var script = String.Empty; if (!imageEditor.IsUndoRedoPossible()) { script = @" $cmsj(window).unload(function () { " + GetRefresh() + @" })"; } // Register update script ScriptHelper.RegisterJQuery(Page); script += @" $cmsj(window).on('beforeunload', function () { if (wopener.EditDialogStateUpdate) { wopener.EditDialogStateUpdate('false'); } }) $cmsj(window).load(function () { if (wopener.EditDialogStateUpdate) { wopener.EditDialogStateUpdate('true'); } })"; ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "DialogStateUpdate", script, true); } PageTitle.TitleText = GetString("general.editimage"); // Register postback ControlsHelper.RegisterPostbackControl(btnRedo); ControlsHelper.RegisterPostbackControl(btnUndo); ControlsHelper.RegisterPostbackControl(btnSave); ControlsHelper.RegisterPostbackControl(btnClose); btnSave.Click += btnSave_Click; btnUndo.Click += btnUndo_Click; btnRedo.Click += btnRedo_Click; btnClose.Click += btnClose_Click; btnUndo.Visible = imageEditor.IsUndoRedoPossible(); btnRedo.Visible = imageEditor.IsUndoRedoPossible(); btnSave.Visible = imageEditor.IsUndoRedoPossible(); AddNoCacheTag(); } else { // Hide all controls imageEditor.Visible = false; btnUndo.Visible = false; btnRedo.Visible = false; btnSave.Visible = false; btnClose.Visible = false; string url = ResolveUrl(AdministrationUrlHelper.GetErrorPageUrl("dialogs.badhashtitle", "dialogs.badhashtext", true)); ltlScript.Text = ScriptHelper.GetScript(String.Format("window.location = '{0}';", url)); } }
protected void Page_Load(object sender, EventArgs e) { // Init ICMSMasterPage currentMaster = Page.Master as ICMSMasterPage; previewState = GetPreviewStateFromCookies(THEME); InitHeaderActions(); ScriptHelper.RegisterClientScriptBlock(Page, typeof(String), "performAction", ScriptHelper.GetScript("function actionPerformed(action) { " + Page.ClientScript.GetPostBackEventReference(btnAction, "#").Replace("'#'", "action") + ";}")); txtContent.ShowBookmarks = true; txtContent.FullScreenParentElementID = "divContent"; if (QueryHelper.ValidateHash("hash")) { identifier = QueryHelper.GetString("identifier", null); if (!String.IsNullOrEmpty(identifier)) { prop = WindowHelper.GetItem(identifier) as Hashtable; if (prop != null) { lblName.Text = GetString("general.filename"); filePath = Server.MapPath(ValidationHelper.GetString(prop["filepath"], "")); extension = ValidationHelper.GetString(prop["newfileextension"], ""); if (!String.IsNullOrEmpty(extension)) { // New file newFile = true; if (!extension.StartsWith(".", StringComparison.Ordinal)) { extension = "." + extension; } filePath = ValidationHelper.GetString(prop["targetpath"], ""); if (currentMaster != null) { currentMaster.Title.TitleText = GetString("filemanagernew.header.file"); } } else { // Edit file if (!File.Exists(filePath)) { // Redirect to error page URLHelper.Redirect(AdministrationUrlHelper.GetErrorPageUrl("Error.Header", "general.filedoesntexist", true)); } fileName = Path.GetFileNameWithoutExtension(filePath); // Setup the controls if (!RequestHelper.IsPostBack()) { txtName.Text = fileName; txtContent.Text = File.ReadAllText(filePath); if (QueryHelper.GetBoolean("saved", false)) { ShowChangesSaved(); String script = "wopener.SetRefreshAction();"; ScriptHelper.RegisterStartupScript(Page, typeof(String), "refreshScript", ScriptHelper.GetScript(script)); } } extension = Path.GetExtension(filePath); if (currentMaster != null) { currentMaster.Title.TitleText = GetString("filemanageredit.header.file"); } } // Setup the syntax highlighting switch (extension.TrimStart('.').ToLowerCSafe()) { case "css": txtContent.Language = LanguageEnum.CSS; break; case "skin": txtContent.Language = LanguageEnum.ASPNET; break; case "xml": txtContent.Language = LanguageEnum.XML; break; case "html": txtContent.Language = LanguageEnum.HTMLMixed; break; case "cs": txtContent.Language = LanguageEnum.CSharp; break; case "js": txtContent.Language = LanguageEnum.JavaScript; break; } // Setup the labels lblExt.Text = extension; } } } RegisterInitScripts(pnlContent.ClientID, pnlMenu.ClientID, ((previewState != 0) && !newFile)); }