<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentPicker.Settings;
using Orchard.Core.Common.Models;
using Orchard.Core.Contents.Settings;
using Orchard.Core.Contents.ViewModels;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Mvc;
using Orchard.Settings;
using Orchard.Themes;
using Orchard.UI.Navigation;

namespace Orchard.ContentPicker.Controllers {
    public class AdminController : Controller {
        private readonly ISiteService _siteService;
        private readonly IContentDefinitionManager _contentDefinitionManager;
        private readonly INavigationManager _navigationManager;

        public AdminController(
            IOrchardServices orchardServices,
            ISiteService siteService,
            IContentDefinitionManager contentDefinitionManager,
            INavigationManager navigationManager) {
            _siteService = siteService;
            _contentDefinitionManager = contentDefinitionManager;
            _navigationManager = navigationManager;
            Services = orchardServices;

            T = NullLocalizer.Instance;
        }

        public IOrchardServices Services { get; set; }
        public Localizer T { get; set; }

        [Themed(false)]
        public ActionResult Index(ListContentsViewModel model, PagerParameters pagerParameters, string part, string field) {

            IEnumerable<MenuItem> menuItems = _navigationManager.BuildMenu("content-picker").ToList();

            var contentPickerMenuItem = menuItems.FirstOrDefault();
            if (contentPickerMenuItem == null) {
                return HttpNotFound();
            }

            if (contentPickerMenuItem.Items.All(x => x.Text.ToString() != T("Recent Content").Text)) {
                // the default tab should not be displayed, redirect to the next one
                var root = menuItems.FirstOrDefault();
                if (root == null) {
                    return HttpNotFound();
                }

                var firstChild = root.Items.First();
                if (firstChild == null) {<commit_msg>#19994: Fixing content picker reidrect loop<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentPicker.Settings;
using Orchard.Core.Common.Models;
using Orchard.Core.Contents.Settings;
using Orchard.Core.Contents.ViewModels;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Mvc;
using Orchard.Settings;
using Orchard.Themes;
using Orchard.UI.Navigation;

namespace Orchard.ContentPicker.Controllers {
    public class AdminController : Controller {
        private readonly ISiteService _siteService;
        private readonly IContentDefinitionManager _contentDefinitionManager;
        private readonly INavigationManager _navigationManager;

        public AdminController(
            IOrchardServices orchardServices,
            ISiteService siteService,
            IContentDefinitionManager contentDefinitionManager,
            INavigationManager navigationManager) {
            _siteService = siteService;
            _contentDefinitionManager = contentDefinitionManager;
            _navigationManager = navigationManager;
            Services = orchardServices;

            T = NullLocalizer.Instance;
        }

        public IOrchardServices Services { get; set; }
        public Localizer T { get; set; }

        [Themed(false)]
        public ActionResult Index(ListContentsViewModel model, PagerParameters pagerParameters, string part, string field) {

            IEnumerable<MenuItem> menuItems = _navigationManager.BuildMenu("content-picker").ToList();

            var contentPickerMenuItem = menuItems.FirstOrDefault();
            if (contentPickerMenuItem == null) {
                return HttpNotFound();
            }

            if (contentPickerMenuItem.Items.All(x => x.Text.TextHint != "Recent Content")) {
                // the default tab should not be displayed, redirect to the next one
                var root = menuItems.FirstOrDefault();
                if (root == null) {
                    return HttpNotFound();
                }

                var firstChild = root.Items.First();
                if (firstChild == null) {
{'fraction_non_alphanumeric': 0.07377758546083946, 'fraction_numerical': 0.0010817827780181739, 'mean_word_length': 2.836514522821577, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6990047', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1083, 'n_words': 279}