using System;
using System.Data;
using System.Configuration;
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;

namespace JuSNS.Web
{
    public class BlogUi
    {
        /// <summary>
        /// 取得日志内容的导航
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        static public string GetContent(object input)
        {
            if (input == null || input == DBNull.Value)
                return string.Empty;
            string s = JuSNS.Common.Input.HtmlEncode(input.ToString());
            if (s.Length <= 60)
                return s;
            else
                return s.Substring(0, 60) + "...";
        }
        /// <summary>
        /// 取得标题
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        static public string GetTitle(object input)
        {
            if (input == null || input == DBNull.Value)
                return "无标题";
            return JuSNS.Common.Input.HtmlEncode(input.ToString());
        }
        /// <summary>
        /// 取得评论
        /// </summary>
        /// <param name="blogid"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        static public string GetComments(object blogid, object input)
        {
            int n = Convert.ToInt32(input);
            if (n < 1)
                return "0";
            else
                return n.ToString();
        }
        /// <summary>
        /// 取得阅读数
        /// </summary>
        /// <param name="blogid"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        static public string GetReads(object blogid, object input)
        {
            int n = Convert.ToInt32(input);
            if (n < 1)
                return "没有阅读";
            else
                return "<a href=\"article.aspx?r=" + blogid + "\">" + n + " 次阅读</a>";
        }
    }
}
