📄 galleryadmin.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.IO;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using CommunityServer.Components;
using CommunityServer.Galleries.Components;
namespace CommunityServer.Galleries.Controls
{
public class GalleryAdmin : GalleryAdminTemplatedWebControl
{
#region Child Controls
private TextBox Name;
private TextBox Description;
private TextBox ApplicationKeyLabel;
private DropDownList Themes;
private TextBox CustomCSS;
private TextBox CategoryListingColumns;
private TextBox CategoryListingRows;
private TextBox PictureListingColumns;
private TextBox PictureListingRows;
private GalleryThreadSortDropDownList PicturesSortBy;
private TextBox Owners;
private RadioButtonList EnableComments;
private RadioButtonList ModerateComments;
private RadioButtonList EnableRatings;
private RadioButtonList EnableExif;
private ListBox ExifTypes;
private RadioButtonList EnableOrderPrints;
private TextBox ThumbnailX;
private TextBox ThumbnailY;
private TextBox ThumbnailQuality;
private TextBox ThumbnailBrightness;
private TextBox SecondaryThumbnailX;
private TextBox SecondaryThumbnailY;
private TextBox SecondaryThumbnailQuality;
private TextBox PictureDetailsX;
private TextBox PictureDetailsY;
private TextBox PictureDetailsQuality;
private TextBox SlideshowX;
private TextBox SlideshowY;
private TextBox SlideshowQuality;
private Literal CacheSize;
private RadioButtonList IsActive;
private RadioButtonList IsSearchable;
private Button Save;
private Button Delete;
private LinkButton ThumbnailRebuild;
private LinkButton SecondaryThumbnailRebuild;
private LinkButton CleanCache;
private LinkButton ClearCache;
#endregion
#region Public Properties
[DefaultValue( "" )]
public virtual string ApplicationKey
{
get
{
Object state = ViewState["ApplicationKey"];
if(state != null)
return (string)state;
return "";
}
set { ViewState["ApplicationKey"] = value; }
}
[DefaultValue( -1 )]
public virtual int SectionID
{
get
{
Object state = ViewState["SectionID"];
if(state != null)
return (int)state;
return -1;
}
set { ViewState["SectionID"] = value; }
}
#endregion
#region Skin
protected override void AttachChildControls()
{
Name = (TextBox)FindControl( "Name" );
Description = (TextBox)FindControl( "Description" );
ApplicationKeyLabel = (TextBox)FindControl( "ApplicationKey" );
Owners = (TextBox)FindControl( "Owners" );
Themes = FindControl("Themes") as DropDownList;
CustomCSS = FindControl("CustomCSS") as TextBox;
CategoryListingColumns = (TextBox)FindControl( "CategoryListingColumns" );
CategoryListingRows = (TextBox)FindControl( "CategoryListingRows" );
PictureListingColumns = (TextBox)FindControl( "PictureListingColumns" );
PictureListingRows = (TextBox)FindControl( "PictureListingRows" );
PicturesSortBy = (GalleryThreadSortDropDownList)FindControl( "PicturesSortBy" );
EnableComments = (RadioButtonList)FindControl( "EnableComments" );
ModerateComments = (RadioButtonList)FindControl( "ModerateComments" );
EnableRatings = (RadioButtonList)FindControl( "EnableRatings" );
EnableExif = (RadioButtonList)FindControl( "EnableExif" );
ExifTypes = (ListBox)FindControl( "ExifTypes" );
EnableOrderPrints = (RadioButtonList)FindControl( "EnableOrderPrints" );
ThumbnailX = (TextBox)FindControl( "ThumbnailX" );
ThumbnailY = (TextBox)FindControl( "ThumbnailY" );
ThumbnailQuality = (TextBox)FindControl( "ThumbnailQuality" );
ThumbnailBrightness = (TextBox)FindControl( "ThumbnailBrightness" );
SecondaryThumbnailX = (TextBox)FindControl( "SecondaryThumbnailX" );
SecondaryThumbnailY = (TextBox)FindControl( "SecondaryThumbnailY" );
SecondaryThumbnailQuality = (TextBox)FindControl( "SecondaryThumbnailQuality" );
PictureDetailsX = (TextBox)FindControl( "PictureDetailsX" );
PictureDetailsY = (TextBox)FindControl( "PictureDetailsY" );
PictureDetailsQuality = (TextBox)FindControl( "PictureDetailsQuality" );
SlideshowX = (TextBox)FindControl( "SlideshowX" );
SlideshowY = (TextBox)FindControl( "SlideshowY" );
SlideshowQuality = (TextBox)FindControl( "SlideshowQuality" );
CacheSize = (Literal)FindControl( "CacheSize" );
IsActive = (RadioButtonList)FindControl( "IsActive" );
IsSearchable = (RadioButtonList)FindControl( "IsSearchable" );
Save = (Button)FindControl( "Save" );
Delete = (Button)FindControl( "Delete" );
ThumbnailRebuild = (LinkButton)FindControl( "ThumbnailRebuild" );
SecondaryThumbnailRebuild = (LinkButton)FindControl( "SecondaryThumbnailRebuild" );
CleanCache = (LinkButton)FindControl( "CleanCache" );
ClearCache = (LinkButton)FindControl( "ClearCache" );
InitializeChildControls();
}
private void InitializeChildControls()
{
Save.Click += new EventHandler(Save_Click);
Delete.Click += new EventHandler(Delete_Click);
Delete.Attributes["onclick"] = "if ( !confirm('" + ResourceManager.GetString("GalleryAdmin_DeleteGalleryVerify").Replace("'", @"\'") + "') ) {return false; } ";
ThumbnailRebuild.Click += new EventHandler(ThumbnailRebuild_Click);
SecondaryThumbnailRebuild.Click += new EventHandler(SecondaryThumbnailRebuild_Click);
CleanCache.Click += new EventHandler(CleanCache_Click);
ClearCache.Click += new EventHandler(ClearCache_Click);
bool enableThemes = GalleryConfiguration.Instance().EnableThemes;
FindControl("Theme_Section").Visible = enableThemes;
FindControl("CustomCSS_Section").Visible = enableThemes;
// Hide the ApplicationKey row if the user is not an administrator
if(!CSContext.Current.User.IsGalleryAdministrator)
{
FindControl( "AppKeyRow" ).Visible = false;
FindControl( "OwnerRow" ).Visible = false;
FindControl( "ActiveRow" ).Visible = false;
FindControl( "SearchableRow" ).Visible = false;
Delete.Visible = false;
}
}
#endregion
protected override void OnInit(EventArgs e)
{
base.OnInit (e);
SectionID = CSContext.Current.ForumID;
ApplicationKey = CSContext.Current.ApplicationKey;
// Access check
Permissions.AccessCheck( GetGallery(), Permission.Administer, CSContext.Current.User );
}
private Gallery GetGallery()
{
Gallery gallery;
if(SectionID == -1)
{
gallery = Galleries.GetGallery(ApplicationKey, false);
SectionID = gallery.SectionID;
}
else
{
gallery = Galleries.GetGallery(SectionID, false);
ApplicationKey = gallery.ApplicationKey;
}
return gallery;
}
/// <summary>
/// Populates the Themes dropdown list with all know blog themes and color choices
/// </summary>
private void PopulateThemes()
{
Themes.Items.Clear();
string dirPath = Context.Server.MapPath("~/Themes/Galleries");
DirectoryInfo dirAllSkins = new DirectoryInfo(dirPath);
foreach(DirectoryInfo dirSkin in dirAllSkins.GetDirectories())
{
DirectoryInfo dirStyle = new DirectoryInfo(Path.Combine(dirSkin.FullName, "Style"));
if(dirStyle.Exists)
{
Themes.Items.Add(new ListItem(dirSkin.Name, dirSkin.Name.ToLower() + "@"));
foreach(FileInfo fi in dirStyle.GetFiles("*.css"))
{
string name = Path.GetFileNameWithoutExtension(fi.FullName).ToLower();
if( name != "style")
{
string themeText = string.Format("{0} - {1}", dirSkin.Name, name);
string themeValue = string.Format("{0}@{1}.css", dirSkin.Name, name);
Themes.Items.Add(new ListItem(themeText,themeValue.ToLower()));
}
}
}
}
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender (e);
HtmlAnchor ThumbnailPreview = (HtmlAnchor)FindControl( "ThumbnailPreview" );
HtmlAnchor SecondaryThumbnailPreview = (HtmlAnchor)FindControl( "SecondaryThumbnailPreview" );
HtmlAnchor PictureDetailsPreview = (HtmlAnchor)FindControl( "PictureDetailsPreview" );
HtmlAnchor SlideshowPreview = (HtmlAnchor)FindControl( "SlideshowPreview" );
ThumbnailPreview.Attributes.Add("onclick", "TogglePreview('" + ThumbnailX.ClientID + "', '" + ThumbnailY.ClientID + "', '" + ThumbnailPreview.ClientID + "');");
SecondaryThumbnailPreview.Attributes.Add("onclick", "TogglePreview('" + SecondaryThumbnailX.ClientID + "', '" + SecondaryThumbnailY.ClientID + "', '" + SecondaryThumbnailPreview.ClientID + "');");
PictureDetailsPreview.Attributes.Add("onclick", "TogglePreview('" + PictureDetailsX.ClientID + "', '" + PictureDetailsY.ClientID + "', '" + PictureDetailsPreview.ClientID + "');");
SlideshowPreview.Attributes.Add("onclick", "TogglePreview('" + SlideshowX.ClientID + "', '" + SlideshowY.ClientID + "', '" + SlideshowPreview.ClientID + "');");
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// Load the data
if(!this.Page.IsPostBack)
DataBind();
}
public override void DataBind()
{
base.DataBind();
// Get the gallery
Gallery gallery = GetGallery();
// Add a list of all the different EXIF properties
Array properties = Enum.GetValues(typeof(ExifProperty));
foreach(ExifProperty property in properties)
ExifTypes.Items.Add( new ListItem( property.ToString(), ((int)property).ToString() ) );
// Set all of the values from the gallery
Name.Text = gallery.Name;
Description.Text = gallery.Description;
ApplicationKeyLabel.Text = gallery.ApplicationKey;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -