📄 managesectionadmin.cs
字号:
{
HyperLink SectionAdminLink = (HyperLink)e.Item.FindControl( "SectionAdminLink" );
SectionAdminLink.DataBinding += new EventHandler(SectionAdminLink_DataBinding);
Literal SectionDescription = (Literal)e.Item.FindControl( "SectionDescription") ;
SectionDescription.DataBinding += new EventHandler(SectionDescription_DataBinding);
Literal SubSectionAdmin = (Literal)e.Item.FindControl( "SubSectionAdmin") ;
SubSectionAdmin.DataBinding += new EventHandler(SubSectionAdmin_DataBinding);
ImageButton MoveSectionUp = (ImageButton)e.Item.FindControl( "MoveSectionUp" );
MoveSectionUp.DataBinding += new EventHandler(MoveSectionUp_DataBinding);
ImageButton MoveSectionDown = (ImageButton)e.Item.FindControl( "MoveSectionDown" );
MoveSectionDown.DataBinding += new EventHandler(MoveSectionDown_DataBinding);
}
#endregion
#region SectionList Controls DataBinding
private void SectionAdminLink_DataBinding(object sender, EventArgs e)
{
HyperLink SectionAdminLink = (HyperLink)sender;
RepeaterItem container = (RepeaterItem)SectionAdminLink.NamingContainer;
SectionAdminLink.Text = Convert.ToString( DataBinder.Eval( container.DataItem, "Name" ) );
SectionAdminLink.NavigateUrl = GetAdminSectionLink( (Int32)DataBinder.Eval( container.DataItem, "SectionID" ) );
}
private void SectionDescription_DataBinding(object sender, EventArgs e)
{
Literal SectionDescription = (Literal)sender;
RepeaterItem container = (RepeaterItem)SectionDescription.NamingContainer;
Section section = container.DataItem as Section;
if(section != null)
SectionDescription.Text = Context.Server.HtmlEncode(section.Description);
}
private void SubSectionAdmin_DataBinding(object sender, EventArgs e)
{
Literal SubSectionAdmin = (Literal)sender;
RepeaterItem container = (RepeaterItem)SubSectionAdmin.NamingContainer;
SubSectionAdmin.Text = FormatSubSectionAdmin( (Section)container.DataItem );
}
private void MoveSectionUp_DataBinding(object sender, EventArgs e)
{
ImageButton MoveSectionUp = (ImageButton)sender;
RepeaterItem container = (RepeaterItem)MoveSectionUp.NamingContainer;
MoveSectionUp.CommandName = "MoveSectionUp";
MoveSectionUp.CommandArgument = Convert.ToString( DataBinder.Eval( container.DataItem, "SectionID" ) );
}
private void MoveSectionDown_DataBinding(object sender, EventArgs e)
{
ImageButton MoveSectionDown = (ImageButton)sender;
RepeaterItem container = (RepeaterItem)MoveSectionDown.NamingContainer;
MoveSectionDown.CommandName = "MoveSectionDown";
MoveSectionDown.CommandArgument = Convert.ToString( DataBinder.Eval( container.DataItem, "SectionID" ) );
}
#endregion
#region Command Handlers
private void SectionList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch( e.CommandName )
{
case "MoveSectionUp":
MoveSectionUp( Convert.ToInt32( e.CommandArgument ) );
break;
case "MoveSectionDown":
MoveSectionDown( Convert.ToInt32( e.CommandArgument ) );
break;
}
}
private void GroupRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch( e.CommandName )
{
case "MoveGroupUp":
MoveGroupUp( Convert.ToInt32( e.CommandArgument ) );
break;
case "MoveGroupDown":
MoveGroupDown( Convert.ToInt32( e.CommandArgument ) );
break;
case "CreateNewSection":
Control newSectionButton = (Control)e.CommandSource;
TextBox SectionName = newSectionButton.NamingContainer.FindControl( "SectionName" ) as TextBox;
TextBox SectionOwners = newSectionButton.NamingContainer.FindControl( "SectionOwner" ) as TextBox;
CreateNewSection( SectionName.Text, SectionOwners == null ? null : SectionOwners.Text, Convert.ToInt32( e.CommandArgument ) );
break;
case "CreateNewSectionGroup":
Control newGroupButton = (Control)e.CommandSource;
TextBox SectionGroupName = (TextBox)newGroupButton.NamingContainer.FindControl( "SectionGroupName" );
CreateNewGroup( SectionGroupName.Text.Trim() );
break;
}
}
#endregion
protected virtual void MoveSectionUp( Int32 SectionID )
{
Sections.ChangeSectionSortOrder(SectionID, true);
IsEdit = true;
DataBindGroups();
}
protected virtual void MoveSectionDown( Int32 SectionID )
{
Sections.ChangeSectionSortOrder(SectionID, false);
IsEdit = true;
DataBindGroups();
}
protected virtual void MoveGroupUp( Int32 GroupID )
{
Groups.ChangeSortOrder(GroupID, true);
IsEdit = true;
DataBindGroups();
}
protected virtual void MoveGroupDown( Int32 GroupID )
{
Groups.ChangeSortOrder(GroupID, false);
IsEdit = true;
DataBindGroups();
}
protected virtual void CreateNewSection( String sectionName, string owners, Int32 sectionGroupID )
{
// Empty string checking
//
if ( sectionName == null || sectionName.Trim() == "" )
{
DataBindGroups();
return;
}
// Get the new Section
Section s = GetNewSection(sectionName, sectionGroupID);
// Make sure it wasn't a duplicate
if(s == null)
{
DataBindGroups();
return;
}
// Continue creating
s.Owners = owners;
s.SectionID = Sections.AddSection(s);
SetDefaultPermissions(s);
IsEdit = true;
DataBindGroups();
}
protected virtual Section GetNewSection( String sectionName, Int32 sectionGroupID )
{
// Create the Section
//
//TODO: Add message static appKey was edited if true
string formattedKey = null;
Globals.ValidateApplicationKey(sectionName, out formattedKey);
// Check to see if it is a duplicate
if(CheckForDuplicate(formattedKey) == true)
return null;
Section s = CreateBlankSection;
s.GroupID = sectionGroupID;
s.Name = sectionName;
s.ApplicationKey = formattedKey;
s.IsActive = true;
s.SettingsID = CSContext.Current.SiteSettings.SettingsID;
s.ApplicationType = ApplicationType;
return s;
}
/// <summary>
/// Allows default permissions to be set. By default, this method is empty
/// </summary>
/// <param name="createdSection"></param>
protected virtual void SetDefaultPermissions(Section createdSection)
{
}
protected virtual void CreateNewGroup( String groupName )
{
// Make sure we have a name
if ( groupName == null || groupName.Trim() == "" )
{
DataBindGroups();
return;
}
// Make sure it isn't a duplicate
ArrayList groups = GetGroups();
foreach(Group g in groups)
{
if(g.Name == groupName)
{
DataBindGroups();
return;
}
}
// Create the forum group
//
Group group = new Group( groupName );
group.ApplicationType = this.ApplicationType;
Groups.AddGroup( group );
IsEdit = true;
DataBindGroups();
}
protected abstract bool CheckForDuplicate(string applicationKey);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -