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 Spaces;
using Spaces.Controls;
using System.Text;
using System.Collections.Generic;
public partial class Manage_PublicTags : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
            BindTags();
    }
    private void BindTags()
    {
        List<string> list = Utils.GetTags(Globals.GetSiteSettings().PublicTags) ;
        StringBuilder sb = new StringBuilder();
        foreach (string str in list)
        {
            sb.AppendFormat("{0}\n", str);

        }
        txtTags.Text = sb.ToString();
    }
    protected void btnTags_Click(object sender, EventArgs e)
    {
        string[] names = txtTags.Text.Trim().Split('\n');
        List<string> list = new List<string>();
        foreach (string s in names)
        {
            if (s.Trim() == string.Empty)
                continue;
            list.Add(s.Trim().Replace(",","").Replace("'","").Replace("\"",""));
        }
        SiteSettings siteset = Globals.GetSiteSettings();
        siteset.PublicTags = Utils.TagsToString(list);
      
        siteset.Save();
        BindTags();
        PageMsg.Text = Msg.GetMsg("增加推荐标签完成！");
    }
}
