⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 moderationaction.cs

📁 一个ASP.NET下的中文内容管理和社区系统
💻 CS
字号:
namespace ASPNET.StarterKit.Communities {

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
   


    //*********************************************************************
    //
    // ModerationAction Class
    //
    // WebControl that displays different actions that can be taken
    // when moderating community content. 
    //
    //*********************************************************************
    
    public class ModerationAction : WebControl, INamingContainer {

    
        //*********************************************************************
        //
        // ModerationAction Constructor
        //
        // Creates a WebControl with a table tag as its containing
        // tag.
        //
        //*********************************************************************
        
        public ModerationAction() : base(HtmlTextWriterTag.Table){}
       

    
        //*********************************************************************
        //
        // ContentPageID Property
        //
        // The ContentPageID of the content being moderated.
        //
        //*********************************************************************
        
        public int ContentPageID {
            get {return (int)ViewState["ContentPageID"];}
            set {ViewState["ContentPageID"] = value; }
        }
        

    
        //*********************************************************************
        //
        // ApproveText Property
        //
        // The text used for approving content.
        //
        //*********************************************************************
           
        public string ApproveText {
            get {
                if (ViewState["ApproveText"] == null)
                    return "Approve";
                else
                    return (string)ViewState["ApproveText"];
            }
            set { ViewState["ApproveText"] = value; }
        }


    
        //*********************************************************************
        //
        // ApproveCommentText Property
        //
        // The text used for approving and commenting.
        //
        //*********************************************************************

        public string ApproveCommentText {
            get {
                if (ViewState["ApproveCommentText"] == null)
                    return "Approve and Comment";
                else
                    return (string)ViewState["ApproveCommentText"];
            }
            set { ViewState["ApproveCommentText"] = value; }
        }


    
        //*********************************************************************
        //
        // MoveText Property
        //
        // The text used for moving content.
        //
        //*********************************************************************
        
        public string MoveText {
            get {
                if (ViewState["MoveText"] == null)
                    return "Move";
                else
                    return (string)ViewState["MoveText"];
            }
            set { ViewState["MoveText"] = value; }
        }

    
        //*********************************************************************
        //
        // DeleteText Property
        //
        // The text used for deleting content.
        //
        //*********************************************************************

        public string DeleteText {
            get {
                if (ViewState["DeleteText"] == null)
                    return "Delete";
                else
                    return (string)ViewState["DeleteText"];
            } 
            set { ViewState["DeleteText"] = value; }
        }
   

    
        //*********************************************************************
        //
        // CreateChildControls Method
        //
        // Adds controls to this control's Controls collection.
        //
        //*********************************************************************
    
        override protected void CreateChildControls() {
            LinkButton lnk;
            HyperLink hlnk;
            
            // Calculate return Url
            string returnUrl = Context.Server.UrlEncode(CommunityGlobals.CalculatePath("Moderation_ModerateSection.aspx"));
            
            // Get UserInfo
            UserInfo objUserInfo = (UserInfo)Context.Items["UserInfo"];
            
            // Get SectionInfo
            SectionInfo objSectionInfo = (SectionInfo)Context.Items["SectionInfo"];
            
            // Approve Link
            lnk = new LinkButton();
            lnk.Text = ApproveText;
            lnk.CommandName = "Approve";
            lnk.CommandArgument = ContentPageID.ToString();
            Controls.Add(lnk);
  
            // Approve Comment Link
            if (objUserInfo.MayComment && objSectionInfo.EnableComments) {
              lnk = new LinkButton();
              lnk.Text = ApproveCommentText;
              lnk.CommandName = "ApproveComment";
              lnk.CommandArgument = ContentPageID.ToString();
              Controls.Add(lnk);
            }
 
 
            // Move Link
            hlnk = new HyperLink();
            hlnk.Text = MoveText;
            hlnk.NavigateUrl = CommunityGlobals.CalculatePath(String.Format("ContentPages_MoveContentPage.aspx?id={0}&ReturnUrl={1}", ContentPageID, returnUrl));
            Controls.Add(hlnk);
 
            // Delete Link
            if (objUserInfo.MayDelete) {
                hlnk = new HyperLink();
                hlnk.Text = DeleteText;
                hlnk.NavigateUrl = CommunityGlobals.CalculatePath(String.Format("ContentPages_DeleteContentPage.aspx?id={0}&ReturnUrl={1}", ContentPageID, returnUrl));
                Controls.Add(hlnk);
            }
        }

    
        //*********************************************************************
        //
        // Render Method
        //
        // Renders different moderation options.
        //
        //*********************************************************************

        protected override void Render(HtmlTextWriter tw) {
            if (Controls.Count > 0) {
                tw.RenderBeginTag(HtmlTextWriterTag.Table);
                tw.RenderBeginTag(HtmlTextWriterTag.Tr);
                
                int controlCount = Controls.Count;
                int counter = 0;
                
                foreach (Control control in Controls) {
                    counter ++;
                    tw.RenderBeginTag(HtmlTextWriterTag.Td);
                    control.RenderControl(tw);
                    tw.RenderEndTag(); // close td
                    
                    // Render Separator
                    if (counter < controlCount) {
                        tw.RenderBeginTag(HtmlTextWriterTag.Td);
                        tw.Write("|");
                        tw.RenderEndTag(); // close td
                    }
                }
                tw.RenderEndTag(); // close tr
                tw.RenderEndTag(); // close table
            }       
        }    
    
    
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -