<commit_before>using System;
using System.Collections.Generic;
using System.ComponentModel;
using Subtext.Framework;
using Subtext.Framework.Components;

namespace Subtext.Web.Admin.UserControls
{
    public partial class CategoryLinkList : System.Web.UI.UserControl
    {
        public CategoryLinkList() {
            CategoryType = CategoryType.None;
        }

        private const string QRYSTR_CATEGORYFILTER = "catid";
        private const string QRYSTR_CATEGORYTYPE = "catType";
        protected ICollection<LinkCategoryLink> categoryLinks = new List<LinkCategoryLink>();

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                //Viewstate access is lost on postback for this control, so catType defaults to PostCollection.
                //So check if the catType is available in the query string and set this.catType's value to 
                //the querystring's category type enumeration
                if (!String.IsNullOrEmpty(Request.QueryString[Keys.QRYSTR_CATEGORYTYPE]))
                {
                    CategoryType = (CategoryType)Enum.Parse(typeof(CategoryType), Request.QueryString[Keys.QRYSTR_CATEGORYTYPE]);
                }
                BindCategoriesRepeater();
            }
        }

        private void BindCategoriesRepeater()
        {
            string baseUrl = "Default.aspx";

            if (this.CategoryType != CategoryType.None)
            {
                if (this.CategoryType == CategoryType.ImageCollection)
                {
                    baseUrl = "EditGalleries.aspx";
                    this.categoryLinks.Add(new LinkCategoryLink("All Galleries", "EditGalleries.aspx"));
                }
                else 
                {
                    this.categoryLinks.Add(new LinkCategoryLink("All Categories", "EditLinks.aspx"));
                }

                if (this.CategoryType != CategoryType.None)
                {
                    ICollection<LinkCategory> categories = Links.GetCategories(CategoryType, ActiveFilter.None);
                    foreach (LinkCategory current in categories)
                    {
                        this.categoryLinks.Add(new LinkCategoryLink(current.Title, string.Format(System.Globalization.CultureInfo.InvariantCulture, "{4}?{0}={1}&{2}={3}", QRYSTR_CATEGORYFILTER, current.Id, QRYSTR_CATEGORYTYPE, this.CategoryType, baseUrl)));
                    }
                }
            }
            rptCategories.DataSource = this.categoryLinks;
            rptCategories.DataBind();
        }

        [Browsable(true)]
        [Description("Sets the type of categories to load.")]
        public CategoryType CategoryType
        {
            get;
            set;
        }<commit_msg>Fixed a wrong url in the "All categories" link (it always went to EditLinks even when showing list of posts)<commit_after>using System;
using System.Collections.Generic;
using System.ComponentModel;
using Subtext.Framework;
using Subtext.Framework.Components;

namespace Subtext.Web.Admin.UserControls
{
    public partial class CategoryLinkList : System.Web.UI.UserControl
    {
        public CategoryLinkList() {
            CategoryType = CategoryType.None;
        }

        private const string QRYSTR_CATEGORYFILTER = "catid";
        private const string QRYSTR_CATEGORYTYPE = "catType";
        protected ICollection<LinkCategoryLink> categoryLinks = new List<LinkCategoryLink>();

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                //Viewstate access is lost on postback for this control, so catType defaults to PostCollection.
                //So check if the catType is available in the query string and set this.catType's value to 
                //the querystring's category type enumeration
                if (!String.IsNullOrEmpty(Request.QueryString[Keys.QRYSTR_CATEGORYTYPE]))
                {
                    CategoryType = (CategoryType)Enum.Parse(typeof(CategoryType), Request.QueryString[Keys.QRYSTR_CATEGORYTYPE]);
                }
                BindCategoriesRepeater();
            }
        }

        private void BindCategoriesRepeater()
        {
            string baseUrl = "Default.aspx";

            if (this.CategoryType != CategoryType.None)
            {
                if (this.CategoryType == CategoryType.ImageCollection)
                {
                    baseUrl = "EditGalleries.aspx";
                    this.categoryLinks.Add(new LinkCategoryLink("All Galleries", "EditGalleries.aspx"));
                }
                else if (this.CategoryType == CategoryType.LinkCollection)
                {
                    this.categoryLinks.Add(new LinkCategoryLink("All Categories", "EditLinks.aspx"));
                }
                else if (this.CategoryType == CategoryType.PostCollection)
                {
                    this.categoryLinks.Add(new LinkCategoryLink("All Categories", "Default.aspx"));
                }

                if (this.CategoryType != CategoryType.None)
                {
                    ICollection<LinkCategory> categories = Links.GetCategories(CategoryType, ActiveFilter.None);
                    foreach (LinkCategory current in categories)
                    {
                        this.categoryLinks.Add(new LinkCategoryLink(current.Title, string.Format(System.Globalization.CultureInfo.InvariantCulture, "{4}?{0}={1}&{2}={3}", QRYSTR_CATEGORYFILTER, current.Id, QRYSTR_CATEGORYTYPE, this.CategoryType, baseUrl)));
                    }
                }
            }
            rptCategories.DataSource = this.categoryLinks;
            rptCategories.DataBind();
        }

        [Browsable(true)]
        [Description("Sets the type of categories to load.")]
        public CategoryType CategoryType
        {
            get;
            set;
        }
{'fraction_non_alphanumeric': 0.08497391889618038, 'fraction_numerical': 0.0016826518593303045, 'mean_word_length': 1.9151544874938695, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6016117', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1420, 'n_words': 318}