2010-08-31 11:50:07 -07:00
|
|
|
|
using System.Web.Mvc;
|
2010-06-08 10:50:08 -07:00
|
|
|
|
using Orchard.ContentManagement;
|
2010-08-31 11:50:07 -07:00
|
|
|
|
using Orchard.DisplayManagement;
|
2010-09-30 16:37:32 -07:00
|
|
|
|
using Orchard.Themes;
|
2010-06-08 10:50:08 -07:00
|
|
|
|
|
|
|
|
|
|
namespace Orchard.Core.Contents.Controllers {
|
2010-09-30 16:37:32 -07:00
|
|
|
|
[Themed]
|
2010-06-08 10:50:08 -07:00
|
|
|
|
public class ItemController : Controller {
|
|
|
|
|
|
private readonly IContentManager _contentManager;
|
|
|
|
|
|
|
2010-10-15 17:24:30 -07:00
|
|
|
|
public ItemController(IContentManager contentManager, IShapeFactory shapeFactory) {
|
2010-06-08 10:50:08 -07:00
|
|
|
|
_contentManager = contentManager;
|
2010-10-15 17:24:30 -07:00
|
|
|
|
Shape = shapeFactory;
|
2010-06-08 10:50:08 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2010-08-31 11:50:07 -07:00
|
|
|
|
dynamic Shape { get; set; }
|
|
|
|
|
|
|
2010-06-11 17:17:00 -07:00
|
|
|
|
// /Contents/Item/Display/72
|
2010-06-08 10:50:08 -07:00
|
|
|
|
public ActionResult Display(int id) {
|
|
|
|
|
|
var contentItem = _contentManager.Get(id, VersionOptions.Published);
|
2010-10-11 02:06:01 -07:00
|
|
|
|
var model = _contentManager.BuildDisplay(contentItem);
|
2010-09-13 14:26:07 -07:00
|
|
|
|
return View(model);
|
2010-06-08 10:50:08 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2010-06-11 17:17:00 -07:00
|
|
|
|
// /Contents/Item/Preview/72
|
|
|
|
|
|
// /Contents/Item/Preview/72?version=5
|
2010-06-08 10:50:08 -07:00
|
|
|
|
public ActionResult Preview(int id, int? version) {
|
|
|
|
|
|
var versionOptions = VersionOptions.Latest;
|
2010-09-13 14:26:07 -07:00
|
|
|
|
if (version != null)
|
2010-06-08 10:50:08 -07:00
|
|
|
|
versionOptions = VersionOptions.Number((int)version);
|
|
|
|
|
|
|
|
|
|
|
|
var contentItem = _contentManager.Get(id, versionOptions);
|
2010-10-11 02:06:01 -07:00
|
|
|
|
var model = _contentManager.BuildDisplay(contentItem);
|
2010-09-13 14:26:07 -07:00
|
|
|
|
return View("Display", model);
|
2010-06-08 10:50:08 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|