📄 entryview.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Web.UI.WebControls;
using CommunityServer.Blogs.Components;
using CommunityServer.Components;
using CommunityServer.Controls;
namespace CommunityServer.Blogs.Controls
{
/// <summary>
/// Summary description for EntryView.
/// </summary>
public class EntryView : WeblogThemedControl
{
public EntryView():base()
{
}
private Literal EntryTitle = null;
private Literal EntryBody = null;
private Literal EntryDesc = null;
private HyperLink AuthorLink = null;
private RatingImageButton Ratings = null;
protected override void AttachChildControls()
{
EntryTitle = FindControl( "EntryTitle" ) as Literal;
EntryBody = FindControl( "EntryBody" ) as Literal;
EntryDesc = FindControl( "EntryDesc" ) as Literal;
AuthorLink = FindControl( "AuthorLink" ) as HyperLink;
Ratings = FindControl("Ratings") as RatingImageButton;
}
private WeblogPost _dataSource;
/// <summary>
/// Property DataSource (object)
/// </summary>
public WeblogPost DataSource
{
get
{ return this._dataSource; }
set
{ this._dataSource = value; }
}
public override void DataBind()
{
base.DataBind();
if(DataSource != null)
{
//make sure we only render posts where they are supposed to be
if(DataSource.SectionID == CurrentWeblog.SectionID && DataSource.PostDate < DateTime.Now)
{
EntryTitle.Text = DataSource.Subject;
EntryBody.Text = DataSource.FormattedBody;
EntryDesc.Text = string.Format("posted on {0}",DataSource.BloggerTime.ToString(ThemeConfig.DateFormat));
if(DataSource.EnableRatings)
{
Ratings.Visible = true;
Ratings.TotalRatings = DataSource.TotalRatings;
Ratings.Rating = DataSource.Rating;
}
else
{
Ratings.Visible = false;
}
if(AuthorLink != null)
{
AuthorLink.Text = DataSource.Username;
AuthorLink.NavigateUrl = Globals.GetSiteUrls().UserProfile(DataSource.AuthorID);
}
Views.AddWebCount(DataSource.PostID);
TrackbackMarkUp tb = new TrackbackMarkUp();
tb.Title = DataSource.Subject;
tb.PermaLink = BlogUrls.Instance().Post(DataSource,CurrentWeblog);
tb.PingUrl = BlogUrls.Instance().TrackbackPingUrl(DataSource.PostID);
this.Controls.Add(tb);
}
else
{
Context.Response.StatusCode = 404;
Context.Response.SuppressContent = true;
Context.Response.End();
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -