mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-18 17:47:54 +08:00
Updating some extension methods and adding a simple enumerable Get to content manager
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4042221
This commit is contained in:
@@ -55,6 +55,12 @@ namespace Orchard.Models {
|
||||
return context2.ContentItem;
|
||||
}
|
||||
|
||||
public virtual IEnumerable<ContentItem> Get(IEnumerable<int> ids) {
|
||||
foreach(var id in ids) {
|
||||
yield return Get(id);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual ContentItem Get(int id) {
|
||||
// obtain root record to determine the model type
|
||||
var record = _contentItemRepository.Get(id);
|
||||
|
@@ -8,6 +8,7 @@ namespace Orchard.Models {
|
||||
void Create(ContentItem contentItem);
|
||||
|
||||
ContentItem Get(int id);
|
||||
IEnumerable<ContentItem> Get(IEnumerable<int> id);
|
||||
|
||||
IEnumerable<ModelTemplate> GetDisplays(IContent contentItem);
|
||||
IEnumerable<ModelTemplate> GetEditors(IContent contentItem);
|
||||
|
@@ -5,24 +5,8 @@ using Orchard.Models;
|
||||
|
||||
namespace Orchard.Mvc.Html {
|
||||
public static class ContentItemExtensions {
|
||||
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, string linkText, IContent item) {
|
||||
return ItemDisplayLink(html, linkText, item.ContentItem);
|
||||
}
|
||||
|
||||
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, IContent item) {
|
||||
return ItemDisplayLink(html, item.ContentItem);
|
||||
}
|
||||
|
||||
public static MvcHtmlString ItemEditLink(this HtmlHelper html, string linkText, IContent item) {
|
||||
return ItemEditLink(html, linkText, item.ContentItem);
|
||||
}
|
||||
|
||||
public static MvcHtmlString ItemEditLink(this HtmlHelper html, IContent item) {
|
||||
return ItemEditLink(html, item.ContentItem);
|
||||
}
|
||||
|
||||
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, string linkText, ContentItem item) {
|
||||
var display = item.As<IContentDisplayInfo>();
|
||||
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, string linkText, IContent content) {
|
||||
var display = content.As<IContentDisplayInfo>();
|
||||
if (display == null)
|
||||
return null;
|
||||
|
||||
@@ -30,12 +14,12 @@ namespace Orchard.Mvc.Html {
|
||||
return html.ActionLink(linkText ?? display.DisplayText, Convert.ToString(values["action"]), values);
|
||||
}
|
||||
|
||||
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, ContentItem item) {
|
||||
return ItemDisplayLink(html, null, item);
|
||||
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, IContent content) {
|
||||
return ItemDisplayLink(html, null, content);
|
||||
}
|
||||
|
||||
public static MvcHtmlString ItemEditLink(this HtmlHelper html, string linkText, ContentItem item) {
|
||||
var display = item.As<IContentDisplayInfo>();
|
||||
public static MvcHtmlString ItemEditLink(this HtmlHelper html, string linkText, IContent content) {
|
||||
var display = content.As<IContentDisplayInfo>();
|
||||
if (display == null)
|
||||
return null;
|
||||
|
||||
@@ -43,8 +27,8 @@ namespace Orchard.Mvc.Html {
|
||||
return html.ActionLink(linkText ?? display.DisplayText, Convert.ToString(values["action"]), values);
|
||||
}
|
||||
|
||||
public static MvcHtmlString ItemEditLink(this HtmlHelper html, ContentItem item) {
|
||||
return ItemEditLink(html, null, item);
|
||||
public static MvcHtmlString ItemEditLink(this HtmlHelper html, IContent content) {
|
||||
return ItemEditLink(html, null, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user