using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using digioz;

public partial class controls_Forum : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ForumList loForums = ForumManagement.GetForumList();
        PortalSettings coPortalSettings = PortalSettingsManagement.GetPortalSettings(); ;

        lblDisplay.Text = "<table class=\"displaybox forumdisplay\" ><tr class=\"forummainheader\"><td class=\"forummainname\">Forum Name</td><td class=\"forummaintopics\">Topics</td><td class=\"forummainposts\">Posts</td><td class=\"forummainlastpost\">Last Post</td></tr>";

        foreach (Forum loForum in loForums)
        {
            string lsForumImage = string.Empty;
            if (!string.IsNullOrEmpty(loForum.ForumImage))
            {
                lsForumImage = string.Format("<img  src=\"pictures/{0}\" alt=\"\" class=\"forumimage\"/>", loForum.ForumImage);
            }

            lblDisplay.Text += "<tr>";
            lblDisplay.Text += "<td>"
                            + lsForumImage
                            + "<a href=\"?page=" + Server.UrlEncode(digioz.Encryption64.Encrypt("Forum View", coPortalSettings.URLEncryptionKey)) + "&forum=" + loForum.ID + "\">" 
                            + loForum.ForumName + "</a><br /><div style=\"clear:both\">" 
                            + loForum.ForumDesc + "</div></td>";
            lblDisplay.Text += "<td><center>" + loForum.ForumTopics + "</center></td>";
            lblDisplay.Text += "<td><center>" + loForum.ForumPosts + "</center></td>";

            if (loForum.ForumLastPostSubject == null || loForum.ForumLastPostSubject == String.Empty)
            {
                lblDisplay.Text += "<td>No Posts</td>";
            }
            else
            {
                lblDisplay.Text += "<td><a href=\"?page=" + Server.UrlEncode(digioz.Encryption64.Encrypt("Forum Topic View", coPortalSettings.URLEncryptionKey)) + "&forum=" + loForum.ID + "&topic=" + loForum.ForumLastPostID.ToString() + "\">" + loForum.ForumLastPostSubject + "</a></td>";
            }
            
            lblDisplay.Text += "</tr>";
        }

        lblDisplay.Text += "</table>";

    }
}
