/* This is an adaptation of the original FeaturedArticle created by
* Brendan Tompkins at http://www.codebetter.com. See this post for the originals
* http://codebetter.com/blogs/brendan.tompkins/archive/2005/06/15/64634.aspx
*
* The original controls required a rebuild of the CommunityServer source
* files, and furthermore were not compatible with version 2.0
* To make life easier for those who don't want to mess around with the
* source files (myself for example) I rewrote them as User Controls.
*
* You are free to alter the source as long as this header stays in place.
* Jacob Reimers
* http://www.reimers.dk
*/
using System;
using System.Web;
using System.Web.UI.WebControls;
using CommunityServer;
using CommunityServer.Components;
using CommunityServer.Blogs.Components;
public partial class FeaturedArticle : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack || !EnableViewState)
{
DataBind();
}
}
private bool showBlog = true;
private bool showDate = true;
private int articleId;
private string sectionTitle = String.Empty;
///
/// Gets or sets a value indicating whether [show blog].
///
///
/// true if [show blog]; otherwise, false.
///
public bool ShowBlog
{
get { return showBlog; }
set { showBlog = value; }
}
///
/// Gets or sets a value indicating whether [show date].
///
///
/// true if [show date]; otherwise, false.
///
public bool ShowDate
{
get { return showDate; }
set { showDate = value; }
}
///
/// Gets or sets the article id.
///
///
public int ArticleId
{
get { return articleId; }
set { articleId = value; }
}
///
/// Gets or sets the title.
///
///
public string Title
{
get { return sectionTitle; }
set { sectionTitle = value; }
}
public override void DataBind()
{
base.DataBind();
if (sectionTitle.Length > 0)
{
title.Text = sectionTitle;
}
CommunityServer.Blogs.Components.BlogThreadQuery query = new CommunityServer.Blogs.Components.BlogThreadQuery();
query.PostID = this.articleId;
query.IncludeCategories = false;
query.ReturnFullThread = true;
PostSet ps = WeblogPosts.GetPosts(query, true);
if (ps != null)
{
ps.Organize();
WeblogPost we = ps.ThreadStarter as WeblogPost;
this.articleTitle.Text = we.Subject;
this.articleTitle.NavigateUrl = BlogUrls.Instance().Post(we);
this.readMore.NavigateUrl = BlogUrls.Instance().Post(we);
this.authorLink.Text = Users.GetUser(we.AuthorID, false).CommonNameOrUserName;
this.authorLink.NavigateUrl = we.Weblog.Url;
this.description.Text = we.Excerpt;
}
}
}