/// <summary> /// Handles the OnValidateControl event of the wwDataBinder control. /// </summary> /// <param name="item">The wwDataBindingItem item.</param> /// <returns>Returns <c>true</c> if the item is valid; otherwise returns <c>false</c>.</returns> protected bool wwDataBinder_ValidateControl(GalleryServerPro.WebControls.wwDataBindingItem item) { if (item.ControlInstance == txtMaxErrorItems) { if ((chkAutoTrimLog.Checked) && (Convert.ToInt32(txtMaxErrorItems.Text, CultureInfo.InvariantCulture) <= 0)) { item.BindingErrorMessage = Resources.GalleryServerPro.Admin_Error_Invalid_MaxNumberErrorItems_Msg; return(false); } } if (item.ControlInstance == txtJQueryScriptPath) { if (!ValidateUrl(txtJQueryScriptPath.Text.Trim())) { item.BindingErrorMessage = Resources.GalleryServerPro.Admin_Site_Settings_InvalidJQueryPath; return(false); } } if (item.ControlInstance == txtJQueryUiScriptPath) { if (!ValidateUrl(txtJQueryUiScriptPath.Text.Trim())) { item.BindingErrorMessage = Resources.GalleryServerPro.Admin_Site_Settings_InvalidJQueryPath; return(false); } } return(true); }
protected bool wwDataBinder_BeforeUnbindControl(GalleryServerPro.WebControls.wwDataBindingItem item) { if (!this.chkEnablePaging.Checked) { // When paging is disabled, we store "0" in the config file. if (item.ControlId == this.txtPageSize.ID) { txtPageSize.Text = "0"; return(true); // true indicates that we want to save this setting to the config file } // When paging is unchecked, several child items are disabled via javascript. Disabled HTML items are not // posted during a postback, so we don't have accurate information about their states. For these controls // (except the page size as configured above) don't save anything by returning false. Furthermore, to // prevent these child controls from incorrectly reverting to an empty or unchecked state in the UI, // assign their properties to their config setting. if (item.ControlId == this.ddlPagerLocation.ID) { this.ddlPagerLocation.SelectedValue = Core.PagerLocation; return(false); } } return(true); }
/// <summary> /// Handles the OnBeforeUnBindControl event of the wwDataBinder control. /// </summary> /// <param name="item">The wwDataBindingItem item.</param> protected bool wwDataBinder_BeforeUnbindControl(GalleryServerPro.WebControls.wwDataBindingItem item) { // When auto trim is disabled, we store "0" in the config table. if (!chkAutoTrimLog.Checked && item.ControlId == txtMaxErrorItems.ID) { txtMaxErrorItems.Text = "0"; } if (item.ControlId == txtJQueryScriptPath.ID) { string url = txtJQueryScriptPath.Text.Trim(); if (!String.IsNullOrEmpty(url) && !Utils.IsAbsoluteUrl(url) && (!url.StartsWith("~", StringComparison.Ordinal))) { url = String.Concat("~", url); // Ensure relative URLs start with "~" } txtJQueryScriptPath.Text = url; } if (item.ControlId == txtJQueryUiScriptPath.ID) { string url = txtJQueryUiScriptPath.Text.Trim(); if (!String.IsNullOrEmpty(url) && !Utils.IsAbsoluteUrl(url) && (!url.StartsWith("~", StringComparison.Ordinal))) { url = String.Concat("~", url); // Ensure relative URLs start with "~" } txtJQueryUiScriptPath.Text = url; } return(true); }
private static bool ValidatePathIsReadable(GalleryServerPro.WebControls.wwDataBindingItem item, string pathToTest, Label pathLabel) { // Verify that the IIS process identity has read permission to the specified path. bool isValid = false; string fullPhysicalPath = HelperFunctions.CalculateFullPath(AppSetting.Instance.PhysicalApplicationPath, pathToTest); try { HelperFunctions.ValidatePhysicalPathExistsAndIsReadable(fullPhysicalPath); isValid = true; } catch (GalleryServerPro.ErrorHandler.CustomExceptions.CannotReadFromDirectoryException ex) { item.BindingErrorMessage = ex.Message; } if (isValid) { pathLabel.Text = fullPhysicalPath; pathLabel.CssClass = "gsp_msgfriendly"; } else { pathLabel.Text = String.Concat("<", Resources.GalleryServerPro.Admin_MediaObjects_InvalidPath, ">"); pathLabel.CssClass = "gsp_msgwarning"; } return(isValid); }
/// <summary> /// Handles the OnAfterBindControl event of the wwDataBinder control. /// </summary> /// <param name="item">The wwDataBindingItem item.</param> protected void wwDataBinder_AfterBindControl(GalleryServerPro.WebControls.wwDataBindingItem item) { if (item.ControlInstance == txtPageSize) { int pageSize = Convert.ToInt32(this.txtPageSize.Text, CultureInfo.CurrentCulture); if (pageSize == 0) { // Disable the checkbox because feature is turned off (a "0" indicates it is off). Set textbox to // an empty string because we don't want to display 0. chkEnablePaging.Checked = false; txtPageSize.Text = String.Empty; } else if (pageSize > 0) { chkEnablePaging.Checked = true; // Select the checkbox when max # of items is > 0 } else { // We'll never get here because the config definition uses an IntegerValidator to force the number // to be greater than 0. } } if (item.ControlInstance == lblLastAutoSync) { if (GallerySettings.LastAutoSync == DateTime.MinValue) { lblLastAutoSync.Text = Resources.GalleryServerPro.Admin_Albums_LastAutoSync_Never_Lbl; } } }
/// <summary> /// Handles the OnAfterBindControl event of the wwDataBinder control. /// </summary> /// <param name="item">The wwDataBindingItem item.</param> protected void wwDataBinder_AfterBindControl(GalleryServerPro.WebControls.wwDataBindingItem item) { // HTML encode the data if (item.ControlId == lblUserName.ID) { lblUserName.Text = Utils.HtmlEncode(lblUserName.Text); } }
protected bool wwDataBinder_BeforeUnbindControl(GalleryServerPro.WebControls.wwDataBindingItem item) { // When auto trim is disabled, we store "0" in the config file. if (!chkAutoTrimLog.Checked) { txtMaxErrorItems.Text = "0"; } return(true); }
protected bool wwDataBinder_ValidateControl(GalleryServerPro.WebControls.wwDataBindingItem item) { if (item.ControlInstance == txtMaxErrorItems) { if ((chkAutoTrimLog.Checked) && (Convert.ToInt32(txtMaxErrorItems.Text) <= 0)) { item.BindingErrorMessage = Resources.GalleryServerPro.Admin_Error_Invalid_MaxNumberErrorItems_Msg; return(false); } } return(true); }
protected bool wwDataBinder_ValidateControl(GalleryServerPro.WebControls.wwDataBindingItem item) { if (item.ControlInstance == txtPageSize) { if ((chkEnablePaging.Checked) && (Convert.ToInt32(txtPageSize.Text) <= 0)) { item.BindingErrorMessage = Resources.GalleryServerPro.Admin_Error_Invalid_PageSize_Msg; return(false); } } return(true); }
private bool ValidateReadOnlyGallery(GalleryServerPro.WebControls.wwDataBindingItem item) { // When a gallery is read only, the following must be true: // 1. The thumbnail and optimized path must be different than the media object path. // 2. The SynchAlbumTitleAndDirectoryName setting must be false. // 3. User albums must be disabled. // We only need to execute this once on a postback. If we already ran it, then return our previous result. This helps // prevent the same error message from being shown multiple times. if (_validateReadOnlyGalleryHasExecuted) { return(_validateReadOnlyGalleryResult); } bool isValid = true; string mediaObjectPath = this.txtMoPath.Text; string thumbnailPath = (String.IsNullOrEmpty(this.txtThumbnailCachePath.Text) ? mediaObjectPath : this.txtThumbnailCachePath.Text); string optimizedPath = (String.IsNullOrEmpty(this.txtOptimizedCachePath.Text) ? mediaObjectPath : this.txtOptimizedCachePath.Text); // 1. The thumbnail and optimized path must be different than the media object path. if ((mediaObjectPath.Equals(thumbnailPath, StringComparison.OrdinalIgnoreCase)) || (mediaObjectPath.Equals(optimizedPath, StringComparison.OrdinalIgnoreCase))) { isValid = false; item.BindingErrorMessage = string.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.Admin_MediaObjects_Cannot_Set_MO_Path_Read_Only_Cache_Location_Not_Set, mediaObjectPath, thumbnailPath, optimizedPath); } // 2. The SynchAlbumTitleAndDirectoryName setting must be false. if (chkSynchAlbumTitleAndDirectoryName.Checked) { isValid = false; item.BindingErrorMessage = Resources.GalleryServerPro.Admin_MediaObjects_Cannot_Set_MO_Path_Read_Only_Synch_Title_And_Directory_Enabled; } // 3. User albums must be disabled. if (Configuration.ConfigManager.GetGalleryServerProConfigSection().Core.EnableUserAlbum) { isValid = false; item.BindingErrorMessage = Resources.GalleryServerPro.Admin_MediaObjects_Cannot_Set_MO_Path_Read_Only_User_Albums_Enabled; } // Set the flag so we don't have to repeat the validation later in the page lifecycle. this._validateReadOnlyGalleryHasExecuted = true; this._validateReadOnlyGalleryResult = isValid; return(isValid); }
/// <summary> /// Handles the OnBeforeUnBindControl event of the wwDataBinder control. /// </summary> /// <param name="item">The wwDataBindingItem item.</param> protected bool wwDataBinder_BeforeUnbindControl(GalleryServerPro.WebControls.wwDataBindingItem item) { if (!this.chkEnablePaging.Checked) { // When paging is disabled, we store "0" in the config file. if (item.ControlId == this.txtPageSize.ID) { txtPageSize.Text = "0"; return(true); // true indicates that we want to save this setting } // Disabled HTML items are not posted during a postback, so we don't have accurate information about their states. // Look for the checkboxes that cause other controls to be disabled, and assign the value of the disabled control to their // database setting. This allows disabled controls to retain their original value if an admin later re-enables them. if (item.ControlId == this.ddlPagerLocation.ID) { this.ddlPagerLocation.SelectedValue = GallerySettingsUpdateable.PagerLocation.ToString(); return(false); } } if (!this.chkEnableAutoSync.Checked) { // When the auto-sync feature is unchecked, the interval textbox is disabled via javascript. if (item.ControlId == this.txtAutoSyncIntervalMinutes.ID) { this.txtAutoSyncIntervalMinutes.Text = GallerySettings.AutoSyncIntervalMinutes.ToString(CultureInfo.CurrentCulture); return(false); } } if (!this.chkEnableRemoteSync.Checked) { // When the remote sync feature is unchecked, the remote access password textbox is disabled via javascript. if (item.ControlId == this.txtRemoteAccessPassword.ID) { this.txtRemoteAccessPassword.Text = GallerySettings.RemoteAccessPassword; return(false); } } return(true); }
private bool ValidatePathIsWriteable(GalleryServerPro.WebControls.wwDataBindingItem item, string pathToTest, Label pathLabel) { // Verify that the IIS process identity has write permission to the specified path. // We only need to execute this once for each unique path. If we already tested this path, then return that test result. This helps // prevent the same error message from being shown multiple times. if (_pathsThatHaveBeenTestedForWriteability.ContainsKey(pathToTest)) { return(_pathsThatHaveBeenTestedForWriteability[pathToTest]); } bool isValid = false; string fullPhysicalPath = HelperFunctions.CalculateFullPath(AppSetting.Instance.PhysicalApplicationPath, pathToTest); try { HelperFunctions.ValidatePhysicalPathExistsAndIsReadWritable(fullPhysicalPath); isValid = true; } catch (GalleryServerPro.ErrorHandler.CustomExceptions.CannotWriteToDirectoryException ex) { item.BindingErrorMessage = ex.Message; } if (isValid) { pathLabel.Text = fullPhysicalPath; pathLabel.CssClass = "gsp_msgfriendly"; } else { pathLabel.Text = String.Concat("<", Resources.GalleryServerPro.Admin_MediaObjects_InvalidPath, ">"); pathLabel.CssClass = "gsp_msgwarning"; } // Set the flag so we don't have to repeat the validation later in the page lifecycle. _pathsThatHaveBeenTestedForWriteability.Add(pathToTest, isValid); return(isValid); }
/// <summary> /// Handles the OnValidateControl event of the wwDataBinder control. /// </summary> /// <param name="item">The wwDataBindingItem item.</param> /// <returns>Returns <c>true</c> if the item is valid; otherwise returns <c>false</c>.</returns> protected bool wwDataBinder_ValidateControl(GalleryServerPro.WebControls.wwDataBindingItem item) { if (item.ControlInstance == txtPageSize) { if ((chkEnablePaging.Checked) && (Convert.ToInt32(txtPageSize.Text, CultureInfo.CurrentCulture) <= 0)) { item.BindingErrorMessage = Resources.GalleryServerPro.Admin_Error_Invalid_PageSize_Msg; return(false); } } if (item.ControlInstance == txtRemoteAccessPassword) { if (chkEnableRemoteSync.Checked && String.IsNullOrEmpty(txtRemoteAccessPassword.Text)) { item.BindingErrorMessage = Resources.GalleryServerPro.Admin_Albums_RemoteAccessPassword_Required_Msg; return(false); } } return(true); }
protected void wwDataBinder_AfterBindControl(GalleryServerPro.WebControls.wwDataBindingItem item) { if (item.ControlInstance == txtPageSize) { int pageSize = Convert.ToInt32(this.txtPageSize.Text); if (pageSize == 0) { // Disable the checkbox because feature is turned off (a "0" indicates it is off). Set textbox to // an empty string because we don't want to display 0. chkEnablePaging.Checked = false; txtPageSize.Text = String.Empty; } else if (pageSize > 0) { chkEnablePaging.Checked = true; // Select the checkbox when max # of items is > 0 } else { // We'll never get here because the config definition uses an IntegerValidator to force the number // to be greater than 0. } } }
protected bool wwDataBinder_ValidateControl(GalleryServerPro.WebControls.wwDataBindingItem item) { // Validate various settings to make sure they don't conflict with each other. // Validate the media object path. if (item.ControlInstance == this.txtMoPath) { if (this.chkPathIsReadOnly.Checked) { return(ValidateReadOnlyGallery(item) && ValidatePathIsReadable(item, this.txtMoPath.Text, this.lblMoPath)); } else { return(ValidatePathIsWriteable(item, this.txtMoPath.Text, this.lblMoPath)); } } // Validate the media object thumbnail path. else if (item.ControlInstance == this.txtThumbnailCachePath) { string pathToTest = this.txtThumbnailCachePath.Text.Trim(); if (String.IsNullOrEmpty(pathToTest)) { pathToTest = this.txtMoPath.Text; } if (this.chkPathIsReadOnly.Checked) { return(ValidateReadOnlyGallery(item) && ValidatePathIsWriteable(item, pathToTest, this.lblThumbnailCachePath)); } else { return(ValidatePathIsWriteable(item, pathToTest, this.lblThumbnailCachePath)); } } // Validate the media object optimized image path. else if (item.ControlInstance == this.txtOptimizedCachePath) { string pathToTest = this.txtOptimizedCachePath.Text.Trim(); if (String.IsNullOrEmpty(pathToTest)) { pathToTest = this.txtMoPath.Text; } if (this.chkPathIsReadOnly.Checked) { return(ValidateReadOnlyGallery(item) && ValidatePathIsWriteable(item, pathToTest, this.lblOptimizedCachePath)); } else { return(ValidatePathIsWriteable(item, pathToTest, this.lblOptimizedCachePath)); } } // Validate the "media files are read-only" option else if (item.ControlInstance == this.chkPathIsReadOnly) { if (this.chkPathIsReadOnly.Checked) { return(ValidateReadOnlyGallery(item) && ValidatePathIsReadable(item, this.txtMoPath.Text, this.lblMoPath)); } else { return(ValidatePathIsWriteable(item, this.txtMoPath.Text, this.lblMoPath)); } } return(true); }
/// <summary> /// Handles the OnValidateControl event of the wwDataBinder control. /// </summary> /// <param name="item">The wwDataBindingItem item.</param> /// <returns>Returns <c>true</c> if the item is valid; otherwise returns <c>false</c>.</returns> protected bool wwDataBinder_ValidateControl(GalleryServerPro.WebControls.wwDataBindingItem item) { // Validate various settings to make sure they don't conflict with each other. return(true); }