Пример #1
0
 public ActionResult Configure(RobotsTxtConfiguration model)
 {
     _manager.SaveConfiguration(model);
     _settingService.ClearCache();
     SuccessNotification(_localizationService.GetResource("Admin.Plugins.Saved"));
     return(Configure());
 }
 public void SaveConfiguration(RobotsTxtConfiguration config)
 {
     _settingService.SetSetting("Plugins.Misc.CustomRobotsTxt.All", config.All);
     _settingService.SetSetting("Plugins.Misc.CustomRobotsTxt.BlogPost", config.BlogPost);
     _settingService.SetSetting("Plugins.Misc.CustomRobotsTxt.Category", config.Category);
     _settingService.SetSetting("Plugins.Misc.CustomRobotsTxt.Manufacturer", config.Manufacturer);
     _settingService.SetSetting("Plugins.Misc.CustomRobotsTxt.NewsItem", config.NewsItem);
     _settingService.SetSetting("Plugins.Misc.CustomRobotsTxt.Product", config.Product);
     _settingService.SetSetting("Plugins.Misc.CustomRobotsTxt.Topic", config.Topic);
     _settingService.SetSetting("Plugins.Misc.CustomRobotsTxt.Vendor", config.Vendor);
 }
        public RobotsTxtConfiguration GetConfiguration()
        {
            var config = new RobotsTxtConfiguration
            {
                All          = _settingService.GetSettingByKey("Plugins.Misc.CustomRobotsTxt.All", false),
                BlogPost     = _settingService.GetSettingByKey("Plugins.Misc.CustomRobotsTxt.BlogPost", false),
                Category     = _settingService.GetSettingByKey("Plugins.Misc.CustomRobotsTxt.Category", false),
                Manufacturer = _settingService.GetSettingByKey("Plugins.Misc.CustomRobotsTxt.Manufacturer", false),
                NewsItem     = _settingService.GetSettingByKey("Plugins.Misc.CustomRobotsTxt.NewsItem", false),
                Product      = _settingService.GetSettingByKey("Plugins.Misc.CustomRobotsTxt.Product", false),
                Topic        = _settingService.GetSettingByKey("Plugins.Misc.CustomRobotsTxt.Topic", false),
                Vendor       = _settingService.GetSettingByKey("Plugins.Misc.CustomRobotsTxt.Vendor", false),
            };

            return(config);
        }
        private string DisableSelected(RobotsTxtConfiguration config)
        {
            if (Url == null)
            {
                throw new InvalidOperationException("Url property cannot be null");
            }

            var sb = GetDefaultRobotsTextFile();

            if (config.BlogPost)
            {
                DisableBlogPosts(sb);
            }

            if (config.NewsItem)
            {
                DisableNews(sb);
            }

            if (config.Category)
            {
                DisableCategories(sb);
            }

            if (config.Manufacturer)
            {
                DisableManufacturers(sb);
            }

            if (config.Topic)
            {
                DisableTopics(sb);
            }

            if (config.Vendor)
            {
                DisableVendors(sb);
            }

            if (config.Product)
            {
                DisableProducts(sb);
            }

            return(sb.ToString());
        }