mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 12:53:33 +08:00
- Settings support for packages and their injection to settings admin.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4041325
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Core.Settings.Models;
|
||||
using Orchard.Core.Settings.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Models;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Models.Driver;
|
||||
|
||||
namespace Orchard.Core.Settings.Controllers {
|
||||
[ValidateInput(false)]
|
||||
public class AdminController : Controller {
|
||||
public class AdminController : Controller, IModelUpdater {
|
||||
private readonly ISiteService _siteService;
|
||||
private readonly IModelManager _modelManager;
|
||||
private readonly INotifier _notifier;
|
||||
|
||||
public AdminController(ISiteService siteService, INotifier notifier) {
|
||||
public AdminController(ISiteService siteService, IModelManager modelManager, INotifier notifier) {
|
||||
_siteService = siteService;
|
||||
_modelManager = modelManager;
|
||||
_notifier = notifier;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -22,21 +25,30 @@ namespace Orchard.Core.Settings.Controllers {
|
||||
|
||||
public ActionResult Index() {
|
||||
var model = new Orchard.Core.Settings.ViewModels.SettingsIndexViewModel {
|
||||
SiteSettings = _siteService.GetSiteSettings().As<SiteModel>() };
|
||||
Site = _siteService.GetSiteSettings().As<SiteModel>() };
|
||||
model.Editors = _modelManager.GetEditors(model.Site);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[AcceptVerbs(HttpVerbs.Post)]
|
||||
public ActionResult Index(FormCollection input) {
|
||||
var viewModel = new SettingsIndexViewModel { SiteSettings = _siteService.GetSiteSettings().As<SiteModel>() };
|
||||
UpdateModel(viewModel.SiteSettings, input.ToValueProvider());
|
||||
try {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
_notifier.Error("Editing Settings failed: " + exception.Message);
|
||||
return View();
|
||||
var viewModel = new SettingsIndexViewModel { Site = _siteService.GetSiteSettings().As<SiteModel>() };
|
||||
viewModel.Editors = _modelManager.UpdateEditors(viewModel.Site, this);
|
||||
|
||||
if (!TryUpdateModel(viewModel, input.ToValueProvider())) {
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
_notifier.Information(T("Settings updated"));
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
#region IModelUpdater Members
|
||||
|
||||
bool IModelUpdater.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user